@ones-editor/editor 0.0.3-beta.22 → 0.0.3-beta.25

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  (function(){"use strict";try{if(typeof document!="undefined"){var t=document.createElement("style");t.appendChild(document.createTextNode(`@charset "UTF-8";@keyframes ones-editor-blink{0%,to{background-color:transparent}50%{background-color:var(--primary-color)}}*{--link-color: #338fe5;--color-0: #e52727;--color-1: #eb6414;--color-2: #f0a100;--color-3: #24b47e;--color-4: #338fe5;--color-5: #9678d3;--color-6: #909090;--background-color-0: #fad4d4;--background-color-1: #fbe0d0;--background-color-2: #fceccc;--background-color-3: #d3f0e5;--background-color-4: #d6e9fa;--background-color-5: #eae4f6;--background-color-6: #dedede;--background-color-7: #e52727;--background-color-8: #eb6414;--background-color-9: #f0a100;--background-color-10: #24b47e;--background-color-11: #338fe5;--background-color-12: #9678d3;--background-color-13: #909090;--background-color-14: #e8e8e8;--font-family: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto, Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue, sans-serif}div.editor-root{--text-color: #303030;--primary-color: #338fe5;--background-selection: #338fe533;--background-code: #eeeeee}div.editor-root{color:var(--text-color);position:relative;box-sizing:border-box;height:100%;width:100%;z-index:1}div.editor-root *{box-sizing:border-box;font-family:var(--font-family)}div.editor-root.active div.editor-content .editor-cursor{opacity:1}div.editor-root .safari.mobile div.editor-content .editor-input{pointer-events:all;width:8px}div.editor-root div.editor-content{height:100%;width:100%;padding:0 30px 30px}div.editor-root div.editor-content .editor-cursor{position:absolute;background:var(--primary-color);width:2px;animation:ones-editor-blink 1s ease-in-out infinite;opacity:0;pointer-events:none}div.editor-root div.editor-content .editor-input{position:absolute;opacity:0;pointer-events:none;width:16px;height:20px;font-size:16px}div.editor-root div.editor-content div[data-type=editor-container]{position:relative}div.editor-root div.editor-content div[data-type=editor-container].root{user-select:none;height:100%;width:100%;cursor:text}div.editor-root div.editor-content div[data-type=editor-container].root>.container-blocks>*+*{margin-top:1em}div.editor-root div.editor-content div[data-type=editor-container].root.select-all div[data-type=editor-block]:not(:first-of-type){background-color:var(--background-selection)}div.editor-root div.editor-content div[data-type=editor-container].root.select-all div[data-type=editor-block]:not(:first-of-type) div[data-type=block-background]>.editor-selection-background{background-color:transparent!important}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-quoted]+div[data-type=editor-block][data-style-quoted]{margin-top:0;padding-top:0}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block]{position:relative;--font-size: 14px;--line-height: 1.6}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-align=center] div[data-type=block-content]{text-align:center}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-align=right] div[data-type=block-content]{text-align:end}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].block-hidden{display:none}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-block-type=text]{cursor:text}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]{word-break:break-word;position:relative}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span{line-height:1.4em;cursor:text}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text{white-space:pre-wrap}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text.link{color:var(--link-color)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text.link:hover{text-decoration:underline}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text.style-bold{font-weight:700}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text.style-italic{font-style:italic}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text.style-underline{text-decoration:underline}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text.style-line-through{text-decoration:line-through}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text.style-underline.style-line-through{text-decoration:underline line-through}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text.style-code{border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px;background-color:var(--background-code);padding:4px;font:.8em Monaco,Consolas,"Andale Mono",DejaVu Sans Mono,monospace}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text.style-subscript{vertical-align:sub;font-size:70%}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text.style-superscript{vertical-align:super;font-size:70%}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-color="0"]{color:var(--color-0)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-color="1"]{color:var(--color-1)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-color="2"]{color:var(--color-2)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-color="3"]{color:var(--color-3)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-color="4"]{color:var(--color-4)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-color="5"]{color:var(--color-5)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-color="6"]{color:var(--color-6)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="0"]{background-color:var(--background-color-0)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="1"]{background-color:var(--background-color-1)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="2"]{background-color:var(--background-color-2)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="3"]{background-color:var(--background-color-3)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="4"]{background-color:var(--background-color-4)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="5"]{background-color:var(--background-color-5)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="6"]{background-color:var(--background-color-6)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="7"]{background-color:var(--background-color-7)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="8"]{background-color:var(--background-color-8)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="9"]{background-color:var(--background-color-9)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="10"]{background-color:var(--background-color-10)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="11"]{background-color:var(--background-color-11)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="12"]{background-color:var(--background-color-12)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="13"]{background-color:var(--background-color-13)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.text[data-style-bg-color="14"]{background-color:var(--background-color-14)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span[data-type=editor-insertion].inputting-insertion>span[data-type=insertion-content]{border-bottom:1px solid var(--primary-color)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span[data-type=editor-insertion].remote-cursor-insertion{width:0px;position:relative;display:inline-block;vertical-align:text-bottom;overflow:visible;height:1em}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span[data-type=editor-insertion].remote-cursor-insertion>span[data-type=insertion-content]{position:absolute;color:transparent;width:3px;left:-3px;border-right:var(--cursor-color) 1px solid;text-overflow:clip;display:inline-block;top:-5px;bottom:0}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span[data-type=editor-insertion].remote-cursor-insertion>span[data-type=insertion-content] span[data-cursor-name]{display:inline-block;width:8px}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span[data-type=editor-insertion].remote-cursor-insertion>span[data-type=insertion-content] span[data-cursor-name]:hover:before,div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span[data-type=editor-insertion].remote-cursor-insertion.active>span[data-type=insertion-content] span[data-cursor-name]:before{content:attr(data-cursor-name);position:absolute;top:-12px;height:1.1em;background-color:var(--cursor-color);z-index:27;left:0px;color:#fff;white-space:nowrap;font-size:12px;display:flex;align-items:center;padding:1px 4px}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] span[data-type=box-content]{border-radius:2px;margin-left:8px;margin-right:8px}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] span[data-type=editor-box].br-box>span[data-type=box-content] img{vertical-align:middle;max-width:1em}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-tools] .editor-block-anchor{position:absolute}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-background] .editor-selection-background{position:absolute;background-color:var(--background-selection);z-index:1;pointer-events:none}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block,div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].unknown-block{cursor:default}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.hover>div[data-type=block-content],div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].unknown-block.hover>div[data-type=block-content]{outline:1px solid #338fe5}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block>div[data-type=block-content],div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].unknown-block>div[data-type=block-content]{display:flex}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.hover .embed-hover-content{outline:1px solid #338fe5}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected .embed-selected-content{position:relative}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block.selected .embed-selected-content:before{content:" ";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;z-index:1;background-color:#338fe5;opacity:.1}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].unknown-block{color:#909090;font-size:12px}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].unknown-block>div[data-type=block-content]{padding:5px}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-quoted]{border-left:4px solid #e8e8e8;color:#909090}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-quoted]:not([data-list-level]){padding-left:8px}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-heading="1"]{--font-size: 28px;--line-height: 1.5}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-heading="2"]{--font-size: 26px;--line-height: 1.5}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-heading="3"]{--font-size: 24px;--line-height: 1.5}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-heading="4"]{--font-size: 22px;--line-height: 1.5}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-heading="5"]{--font-size: 20px;--line-height: 1.6}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-heading="6"]{--font-size: 18px;--line-height: 1.6}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-heading="7"]{--font-size: 16px;--line-height: 1.6}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-heading="8"]{--font-size: 14px;--line-height: 1.6}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-heading]{font-size:var(--font-size);line-height:var(--line-height);font-weight:700}.editor-disable-scroll{position:fixed;left:0;top:0;width:100vw;height:100vh;z-index:9900;overflow:hidden}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-anchor{position:absolute;pointer-events:none;z-index:-1}.editor-command-bar.toolbar .color-button{width:24px;height:24px;display:flex;padding:0;margin:0;align-items:center;justify-content:center;background-color:transparent;border:0;outline:0;border-radius:3px;cursor:pointer}.editor-command-bar.toolbar .color-button[data-color="0"]{color:var(--color-0)}.editor-command-bar.toolbar .color-button[data-color="1"]{color:var(--color-1)}.editor-command-bar.toolbar .color-button[data-color="2"]{color:var(--color-2)}.editor-command-bar.toolbar .color-button[data-color="3"]{color:var(--color-3)}.editor-command-bar.toolbar .color-button[data-color="4"]{color:var(--color-4)}.editor-command-bar.toolbar .color-button[data-color="5"]{color:var(--color-5)}.editor-command-bar.toolbar .color-button[data-color="6"]{color:var(--color-6)}.editor-command-bar.toolbar .color-button[data-background-color="0"]{background-color:var(--background-color-0)}.editor-command-bar.toolbar .color-button[data-background-color="1"]{background-color:var(--background-color-1)}.editor-command-bar.toolbar .color-button[data-background-color="2"]{background-color:var(--background-color-2)}.editor-command-bar.toolbar .color-button[data-background-color="3"]{background-color:var(--background-color-3)}.editor-command-bar.toolbar .color-button[data-background-color="4"]{background-color:var(--background-color-4)}.editor-command-bar.toolbar .color-button[data-background-color="5"]{background-color:var(--background-color-5)}.editor-command-bar.toolbar .color-button[data-background-color="6"]{background-color:var(--background-color-6)}.editor-command-bar.toolbar .color-button[data-background-color="7"]{background-color:var(--background-color-7)}.editor-command-bar.toolbar .color-button[data-background-color="8"]{background-color:var(--background-color-8)}.editor-command-bar.toolbar .color-button[data-background-color="9"]{background-color:var(--background-color-9)}.editor-command-bar.toolbar .color-button[data-background-color="10"]{background-color:var(--background-color-10)}.editor-command-bar.toolbar .color-button[data-background-color="11"]{background-color:var(--background-color-11)}.editor-command-bar.toolbar .color-button[data-background-color="12"]{background-color:var(--background-color-12)}.editor-command-bar.toolbar .color-button[data-background-color="13"]{background-color:var(--background-color-13)}.editor-command-bar.toolbar .color-button[data-background-color="14"]{background-color:var(--background-color-14)}.tippy-content{white-space:pre-line}.editor-button{min-height:26px;min-width:46px;font-size:12px;font-weight:500;outline:none;background-color:var(--editor-button-bg-color, #338fe5);color:var(--editor-button-color, #fff);border:0;padding:4px 8px;border-radius:4px;margin-right:8px;cursor:pointer}.editor-button:hover{background-color:#5ca5ea}[data-theme=dropdown-list]{border-radius:4px;background:white;position:relative;max-width:calc(100vw - 24px);box-shadow:#0f0f0f0d 0 0 0 1px,#0f0f0f1a 0 3px 6px,#0f0f0f33 0 9px 24px;overflow:hidden;color:#000}[data-theme=dropdown-list] .tippy-content{padding:0}[data-theme=dropdown-list] .filterable-list{min-width:100px;max-width:300px}[data-theme=dropdown-list] .filterable-list .filter{padding:8px}[data-theme=dropdown-list] .filterable-list .filter .filter-container{width:100%;font-size:14px;line-height:20px;padding:3px 6px;position:relative;border-radius:3px;box-shadow:#0f0f0f1a 0 0 0 1px inset;background:rgba(242,241,238,.6);cursor:text;height:28px;box-sizing:border-box;display:flex;align-items:center}[data-theme=dropdown-list] .filterable-list .filter .filter-container input.filter-input{border:none;outline:none;flex-grow:1;background:transparent}[data-theme=dropdown-list] .filterable-list .list{max-height:60vh;overflow-y:auto;padding:8px 0}[data-theme=dropdown-list] .filterable-list .list .list-item{user-select:none;transition:background 20ms ease-in 0s;cursor:pointer;width:calc(100% - 8px);margin-left:4px;margin-right:4px;border-radius:3px;height:24px;padding:4px 8px;display:flex;align-items:center;box-sizing:border-box}[data-theme=dropdown-list] .filterable-list .list .list-item .list-text{white-space:nowrap}[data-theme=dropdown-list] .filterable-list .list .list-item.selected{background-color:#eee}::placeholder{color:#bbb}.toast{font-family:Avenir,Helvetica,Arial,sans-serif;visibility:hidden;min-width:250px;margin-left:-125px;background-color:#333;color:#fff;text-align:center;border-radius:2px;padding:8px;position:fixed;z-index:1;left:50%;bottom:30px}.toast.show{visibility:visible;animation:toast_fade_in .5s,toast_fade_out .5s 2.5s}.toast.positioned.show{animation:toast_fade_in_positioned .5s,toast_fade_out_positioned .5s 2.5s}.toast.positioned{bottom:unset}@keyframes toast_fade_in{0%{bottom:0;opacity:0}to{bottom:30px;opacity:1}}@keyframes toast_fade_out{0%{bottom:30px;opacity:1}to{bottom:0;opacity:0}}@keyframes toast_fade_in_positioned{0%{opacity:0}to{opacity:1}}@keyframes toast_fade_out_positioned{0%{opacity:1}to{opacity:0}}.tippy-box[data-animation=fade][data-state=hidden]{opacity:0}[data-tippy-root]{max-width:calc(100vw - 10px)}.tippy-box{position:relative;background-color:#333;color:#fff;border-radius:4px;font-size:14px;line-height:1.4;white-space:normal;outline:0;transition-property:transform,visibility,opacity}.tippy-box[data-placement^=top]>.tippy-arrow{bottom:0}.tippy-box[data-placement^=top]>.tippy-arrow:before{bottom:-7px;left:0;border-width:8px 8px 0;border-top-color:initial;transform-origin:center top}.tippy-box[data-placement^=bottom]>.tippy-arrow{top:0}.tippy-box[data-placement^=bottom]>.tippy-arrow:before{top:-7px;left:0;border-width:0 8px 8px;border-bottom-color:initial;transform-origin:center bottom}.tippy-box[data-placement^=left]>.tippy-arrow{right:0}.tippy-box[data-placement^=left]>.tippy-arrow:before{border-width:8px 0 8px 8px;border-left-color:initial;right:-7px;transform-origin:center left}.tippy-box[data-placement^=right]>.tippy-arrow{left:0}.tippy-box[data-placement^=right]>.tippy-arrow:before{left:-7px;border-width:8px 8px 8px 0;border-right-color:initial;transform-origin:center right}.tippy-box[data-inertia][data-state=visible]{transition-timing-function:cubic-bezier(.54,1.5,.38,1.11)}.tippy-arrow{width:16px;height:16px;color:#333}.tippy-arrow:before{content:"";position:absolute;border-color:transparent;border-style:solid}.tippy-content{position:relative;padding:5px 9px;z-index:1}div.tippy-box[data-theme=toolbar] .tippy-content,div.tippy-box[data-theme=menu] .tippy-content{padding:0}div.tippy-box[data-theme=menu] .tippy-content .editor-command-bar.menu{min-width:180px}.editor-command-bar{pointer-events:all;display:flex;box-sizing:border-box;--text-color: #606060;--primary-color: #338fe5;--selected-color: #f8f8f8;--separator-color: #dedede;--warn-color: #fdf4f4}.editor-command-bar.menu{display:flex;flex-direction:column;align-items:flex-start;padding:5px 0;background:#ffffff;box-shadow:0 0 1px #30303040,0 12px 24px #30303026;border-radius:2px;max-height:50vh;overflow:auto}.editor-command-bar.menu .command-item.standard{color:var(--text-color);user-select:none;transition:background 20ms ease-in 0s;cursor:pointer;width:100%;height:32px;padding:6px 10px;display:flex;align-items:center;box-sizing:border-box}.editor-command-bar.menu .command-item.standard .menu-item-icon{align-items:center;height:24px;width:24px;margin-right:5px;margin-top:-2px;display:flex;flex-direction:column;justify-content:center}.editor-command-bar.menu .command-item.standard .menu-item-name{white-space:nowrap;flex-grow:1;display:flex;align-items:center}.editor-command-bar.menu .command-item.standard .item-shortcut{color:#b2bccd}.editor-command-bar.menu .command-item.standard .menu-item-sub-indicator{display:flex;align-items:center;justify-content:center}.editor-command-bar.menu .command-item.standard .menu-item-sub-indicator svg{width:16px;height:16px}.editor-command-bar.menu .command-item.standard.disabled{color:#c7c7c7;cursor:not-allowed}.editor-command-bar.menu .command-item.separator{height:1px;margin:4px 0;background-color:var(--separator-color);width:100%}.editor-command-bar.menu .command-item.section{font-size:.8em;color:#ccc;padding:5px 5px 5px 10px}.editor-command-bar.menu .command-item.selected{background-color:var(--selected-color)}.editor-command-bar.menu .command-item.selected[data-id=delete]{background-color:var(--warn-color)}.editor-command-bar.menu .command-item.selected.disabled{background-color:transparent}.editor-command-bar.menu .command-item.checked{color:var(--primary-color)}.editor-command-bar.menu .command-item.checked .menu-item-checked-icon{display:flex;align-items:center;justify-content:center;margin-left:10px}.editor-command-bar.menu .command-item.checked.disabled{color:#c7c7c7}.editor-command-bar.menu .command-item span.highlight{color:#e52727}.editor-command-bar.toolbar{display:flex;flex-direction:row;align-items:flex-start;padding:5px 10px;gap:5px;background:#ffffff;box-shadow:0 0 1px #30303033,0 8px 16px #30303026;border-radius:3px}.editor-command-bar.toolbar .command-item{background:transparent;border:none;display:flex;align-items:center;justify-content:center;color:var(--text-color);height:24px;padding:0;cursor:pointer;border-radius:3px;min-width:24px}.editor-command-bar.toolbar .command-item.selected{background-color:var(--selected-color)}.editor-command-bar.toolbar .command-item.disabled{color:#c7c7c7}.editor-command-bar.toolbar .command-item.checked{color:var(--primary-color)}.editor-command-bar.toolbar .command-item.checked.disabled{color:#c7c7c7}.editor-command-bar.toolbar .command-item.separator{margin:auto 2px;height:20px;min-width:1px;width:1px;background-color:var(--separator-color);padding:0;pointer-events:none;cursor:default}.editor-command-bar.toolbar .command-item .toolbar-item-name-container,.editor-command-bar.toolbar .command-item .toolbar-item-icon-container{display:flex}.editor-command-bar.toolbar .command-item[data-dropdown=true]{padding-left:4px;padding-right:4px}.editor-command-bar.toolbar .command-item[data-dropdown=true] .toolbar-item-icon-container{width:24px;height:24px;align-items:center;justify-content:center}.editor-command-bar.toolbar .command-item .toolbar-item-dropdown-container{display:flex}.editor-command-bar.toolbar .command-item .toolbar-item-dropdown-container svg{transform:rotate(360deg);transition:transform .2s linear}.editor-command-bar.toolbar .command-item.active .toolbar-item-dropdown-container svg{transform:rotate(180deg)}.editor-command-bar.toolbar .editor-button+.editor-button{margin-left:5px}.tippy-box[data-theme~=light]{color:#26323d;box-shadow:0 0 20px 4px #9aa1b126,0 4px 80px -8px #24282f40,0 4px 4px -2px #5b5e6926;background-color:#fff}.tippy-box[data-theme~=light][data-placement^=top]>.tippy-arrow:before{border-top-color:#fff}.tippy-box[data-theme~=light][data-placement^=bottom]>.tippy-arrow:before{border-bottom-color:#fff}.tippy-box[data-theme~=light][data-placement^=left]>.tippy-arrow:before{border-left-color:#fff}.tippy-box[data-theme~=light][data-placement^=right]>.tippy-arrow:before{border-right-color:#fff}.tippy-box[data-theme~=light]>.tippy-backdrop{background-color:#fff}.tippy-box[data-theme~=light]>.tippy-svg-arrow{fill:#fff}.scale-border:after,.color-palette .palette-container-row .background-color-button.selected:after,.color-palette .palette-container-row .background-color-button:hover:after{content:"";outline:1px solid #d6e9fa;border-radius:3px;position:absolute;left:0;right:0;top:0;bottom:0;transform:scale(1.1)}.color-palette{display:flex;flex-direction:column;align-items:center;padding-top:5px;background-color:#fff;--active-color: #2872b7}.color-palette .bar-desc{box-sizing:border-box;width:100%;height:24px;padding-left:10px;margin-bottom:10px;line-height:24px;font-size:12px;font-weight:500;background:#F8F8F8;color:#909090}.color-palette .palette-container{padding:0 10px}.color-palette .background-color .palette-container-row:first-child{margin-bottom:5px}.color-palette .palette-container-row{display:flex;flex-direction:row;margin-bottom:20px}.color-palette .palette-container-row .color-button{width:24px;height:24px;border:none;outline:none;cursor:pointer;border-radius:3px;background-color:#fff;border:1px solid #f0f0f0;display:flex;margin:0;padding:0;align-items:center;justify-content:center}.color-palette .palette-container-row .color-button:hover{border:1px solid #d6e9fa}.color-palette .palette-container-row .color-button.selected{border:1px solid var(--primary-color)}.color-palette .palette-container-row .color-button[data-color-index="-1"]{color:var(--text-color)}.color-palette .palette-container-row .color-button[data-color-index="0"]{color:var(--color-0)}.color-palette .palette-container-row .color-button[data-color-index="1"]{color:var(--color-1)}.color-palette .palette-container-row .color-button[data-color-index="2"]{color:var(--color-2)}.color-palette .palette-container-row .color-button[data-color-index="3"]{color:var(--color-3)}.color-palette .palette-container-row .color-button[data-color-index="4"]{color:var(--color-4)}.color-palette .palette-container-row .color-button[data-color-index="5"]{color:var(--color-5)}.color-palette .palette-container-row .color-button[data-color-index="6"]{color:var(--color-6)}.color-palette .palette-container-row .background-color-button{width:24px;height:24px;border:none;outline:none;cursor:pointer;border-radius:3px;position:relative}.color-palette .palette-container-row .background-color-button.selected:after{outline:1px solid var(--primary-color)}.color-palette .palette-container-row .background-color-button[data-color-index="-1"]{position:relative;background-color:#fff;border:1px solid #e8e8e8}.color-palette .palette-container-row .background-color-button[data-color-index="-1"]:after{transform:scale(1.2)}.color-palette .palette-container-row .background-color-button[data-color-index="-1"]:before{content:"";position:absolute;width:1px;height:56px;top:2px;left:22px;background-color:#c7c7c7;transform:rotate(45deg) scale(.5);transform-origin:-1px -2px}.color-palette .palette-container-row .background-color-button[data-color-index="0"]{background-color:var(--background-color-0)}.color-palette .palette-container-row .background-color-button[data-color-index="1"]{background-color:var(--background-color-1)}.color-palette .palette-container-row .background-color-button[data-color-index="2"]{background-color:var(--background-color-2)}.color-palette .palette-container-row .background-color-button[data-color-index="3"]{background-color:var(--background-color-3)}.color-palette .palette-container-row .background-color-button[data-color-index="4"]{background-color:var(--background-color-4)}.color-palette .palette-container-row .background-color-button[data-color-index="5"]{background-color:var(--background-color-5)}.color-palette .palette-container-row .background-color-button[data-color-index="6"]{background-color:var(--background-color-6)}.color-palette .palette-container-row .background-color-button[data-color-index="7"]{background-color:var(--background-color-7)}.color-palette .palette-container-row .background-color-button[data-color-index="8"]{background-color:var(--background-color-8)}.color-palette .palette-container-row .background-color-button[data-color-index="9"]{background-color:var(--background-color-9)}.color-palette .palette-container-row .background-color-button[data-color-index="10"]{background-color:var(--background-color-10)}.color-palette .palette-container-row .background-color-button[data-color-index="11"]{background-color:var(--background-color-11)}.color-palette .palette-container-row .background-color-button[data-color-index="12"]{background-color:var(--background-color-12)}.color-palette .palette-container-row .background-color-button[data-color-index="13"]{background-color:var(--background-color-13)}.color-palette .palette-container-row .background-color-button[data-color-index="14"]{background-color:var(--background-color-14)}.color-palette .palette-container-row .color-button+.color-button{margin-left:5px}.color-palette .palette-container-row .background-color-button+.background-color-button{margin-left:5px}.color-palette .clear-button-container{box-sizing:border-box;width:100%;margin-bottom:5px;padding:0 10px}.color-palette .clear-button-container .clear-button{box-sizing:border-box;padding:3px 10px;width:100%;height:26px;background:#ffffff;color:#606060;border:1px solid #c7c7c7;border-radius:3px;cursor:pointer}.color-palette .clear-button-container .clear-button:hover{border-color:var(--primary-color);color:var(--primary-color)}.color-palette .clear-button-container .clear-button:active{border-color:var(--active-color);color:var(--active-color);background-color:#d6e9fa}.editor-input-wrap .editor-input-label{margin-top:8px;margin-bottom:8px;position:relative}.editor-input-wrap .editor-input-label.required:before{content:"*";color:#e82100;position:absolute;left:-8px;top:3px}.editor-input-wrap .editor-input-label .span{font-size:14px;line-height:1.4;font-weight:700;color:#303030}.editor-input-wrap .editor-input-container{display:flex;border:none;border-radius:4px;padding:4px;background-color:#fff}.editor-input-wrap .editor-input-container .editor-input{outline:none;border:1px solid #c7c7c7;border-radius:3px;padding:4px 10px;font-size:14px;line-height:1.4;color:#000;width:100%}.editor-input-wrap .editor-input-container .editor-input:focus{border-color:#338fe5;box-shadow:0 0 0 2px #338fe533}.editor-input-wrap.error .editor-input-container{border:1px solid #e82100}.editor-input-wrap.error .editor-input-container .editor-input{border:none;outline:none;box-shadow:unset}.editor-input-wrap.error .editor-input-error{margin-top:8px;color:red;display:block}.editor-input-wrap .editor-input-error{display:none}div.scroll-container-root{position:relative}div.scroll-container-root>div.scroll-container{position:relative;overflow-x:auto;overflow-y:hidden;box-sizing:border-box;line-height:0px}div.scroll-container-root>div.scroll-container>.scroll-area{position:relative;display:inline-block;overflow:hidden;line-height:normal}div.scroll-container-root>div.scroll-container{scrollbar-width:none}div.scroll-container-root>div.scroll-container::-webkit-scrollbar{height:0;opacity:0}div.scroll-container-root>div.container-scroll-tool .container-border-shadow{position:absolute;top:0;opacity:0;width:0;border:none;pointer-events:none;transition:opacity 50ms ease-in;z-index:1}div.scroll-container-root>div.container-scroll-tool .container-right-border-shadow{right:0;background:linear-gradient(90deg,rgba(31,35,41,0) 0,rgba(31,35,41,.1));border-right:0px solid #dee0e3}div.scroll-container-root>div.container-scroll-tool .container-left-border-shadow{left:0;background:linear-gradient(270deg,rgba(31,35,41,0) 0,rgba(31,35,41,.1));border-left:0px solid #dee0e3}div.scroll-container-root>div.container-scroll-tool .container-border-shadow.active{width:8px;opacity:1}div.scroll-container-root>div.container-scroll-tool .container-right-border-shadow.active{border-right-width:1px}div.scroll-container-root>div.container-scroll-tool .container-left-border-shadow.active{border-left-width:1px}div.scroll-container-root>div.container-scroll-tool .container-scrollbar{position:absolute;left:0;z-index:1000;visibility:visible;overflow-x:auto;overflow-y:hidden;cursor:auto}div.scroll-container-root>div.container-scroll-tool .container-scrollbar div{height:1px}div.scroll-container-root>div.container-scroll-tool div.container-scrollbar.fixed{position:fixed}div.scroll-container-root.mac>div.container-scroll-tool .container-scrollbar{opacity:.6;transition:opacity .1s ease-in-out}div.scroll-container-root.mac>div.container-scroll-tool .container-scrollbar::-webkit-scrollbar{height:8px}div.scroll-container-root.mac>div.container-scroll-tool .container-scrollbar::-webkit-scrollbar-track{background-color:transparent}div.scroll-container-root.mac>div.container-scroll-tool .container-scrollbar::-webkit-scrollbar-thumb{background-color:#646a73cc;border-radius:8px}div.scroll-container-root.mac>div.container-scroll-tool .container-scrollbar::-webkit-scrollbar-button{display:none}[data-tippy-root]{font-family:Avenir,Helvetica,Arial,sans-serif}[data-command-bar-id=editor-toolbar]{padding-top:10px;padding-bottom:5px}[data-command-bar-id=editor-toolbar] .command-item[data-id=link-text]{width:unset}[data-command-bar-id=editor-toolbar] .command-item[data-id=link-text]:hover{background-color:transparent}[data-command-bar-id=editor-toolbar] .command-item[data-id=link-text] .link-href-button{max-width:400px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}[data-command-bar-id=editor-toolbar] .command-item[data-id=link-text] .link-href-button:hover{text-decoration:underline}[data-command-bar-id=quick-menu],[data-command-bar-id=empty-block-menu]{box-sizing:border-box;width:240px}[data-command-bar-id=quick-menu] .command-item.menu-item,[data-command-bar-id=empty-block-menu] .command-item.menu-item{width:100%;cursor:pointer}[data-command-bar-id=quick-menu] .command-item.menu-item.section,[data-command-bar-id=empty-block-menu] .command-item.menu-item.section{height:24px;padding:2px 10px;font-weight:500;font-size:12px;line-height:20px;color:#909090;background:#F8F8F8;min-height:initial;box-sizing:border-box;margin-bottom:5px}[data-command-bar-id=quick-menu] .command-item.menu-item .quick-menu-item,[data-command-bar-id=empty-block-menu] .command-item.menu-item .quick-menu-item{color:#303030;display:flex;width:100%;padding:6px 10px}[data-command-bar-id=quick-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-icon-container,[data-command-bar-id=empty-block-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-icon-container{display:flex;align-items:center;justify-content:center;padding-right:6px}[data-command-bar-id=quick-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-icon-container .quick-menu-item-icon,[data-command-bar-id=empty-block-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-icon-container .quick-menu-item-icon{width:16px;height:16px;display:flex;align-items:center;justify-content:center}[data-command-bar-id=quick-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content,[data-command-bar-id=empty-block-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content{flex-grow:1;display:flex;flex-direction:column;justify-content:center}[data-command-bar-id=quick-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-1,[data-command-bar-id=empty-block-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-1{display:flex;align-items:center}[data-command-bar-id=quick-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-1 .item-name,[data-command-bar-id=empty-block-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-1 .item-name{flex-grow:1;font-size:14px;line-height:22px;color:#303030}[data-command-bar-id=quick-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-1 .item-shortcut,[data-command-bar-id=empty-block-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-1 .item-shortcut{color:#b2bccd}[data-command-bar-id=quick-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-1 .quick-menu-item-submenu-icon,[data-command-bar-id=empty-block-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-1 .quick-menu-item-submenu-icon{display:flex;align-items:center;margin-left:12px}[data-command-bar-id=quick-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-2,[data-command-bar-id=empty-block-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-2{margin-top:5px}[data-command-bar-id=quick-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-2 .item-markdown,[data-command-bar-id=empty-block-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-2 .item-markdown{color:#b2bccd}[data-command-bar-id=quick-menu] .command-item.menu-item[data-id=placeholder] .quick-menu-item-icon-container,[data-command-bar-id=empty-block-menu] .command-item.menu-item[data-id=placeholder] .quick-menu-item-icon-container{display:none}[data-command-bar-id=quick-menu] .command-item.menu-item[data-id=placeholder] .item-name.text,[data-command-bar-id=empty-block-menu] .command-item.menu-item[data-id=placeholder] .item-name.text{color:#909090!important;padding:5px 0}[data-command-bar-id=block-menu]{width:240px}div.tippy-box .editor-tooltip-desc{display:block;margin-top:2px;color:#a8a9ab}.link-popup-content{padding:10px 7px}.link-popup-content .link-popup-gap{margin-top:16px}.link-popup-content .editor-input-container{padding:4px 0}.link-popup-content .editor-input-container .editor-input{width:330px;line-height:1.5}.link-popup-content .editor-input-wrap .editor-input-label{margin-bottom:4px}.link-popup-content .link-popup-footer{margin:10px 0 5px;text-align:right}.link-popup-content .link-popup-footer button{min-width:58px;min-height:30px;padding:0 10px;border-radius:3px;background-color:#eef3f8;font-size:14px;color:#fff;cursor:pointer;outline:none}.link-popup-content .link-popup-footer .cancel-button{margin:0 8px 0 0;background-color:transparent;border:1px solid #c7c7c7;color:#606060}.link-popup-content .link-popup-footer .cancel-button:hover{color:#303030;background:#eee;border:1px solid #c7c7c7}.link-popup-content .link-popup-footer .submit-button{outline:none;background-color:#338fe5;color:#fff;border:0}.link-popup-content .link-popup-footer .submit-button:disabled{color:#fff;background-color:#338fe580}.link-popup-content .link-popup-footer .submit-button:disabled:hover{background-color:#338fe580}.link-popup-content .link-popup-footer .submit-button:hover{background-color:#5ca5ea}:root{--mindmap-bg-color: #f0f2f4}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block.focused [data-type=block-tools] .editor-mindmap-svg{border-radius:3px;outline:1px solid #338FE5}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block.editor-in-mindmap-first{height:600px;min-width:150px}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block [data-type=block-content]{margin-right:24px;transition:background-color .25s linear}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block [data-type=block-tools] .editor-mindmap-svg{position:absolute;left:0;top:0;right:0;bottom:0;z-index:2;font-size:14px;background-color:var(--mindmap-bg-color)}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block [data-type=block-tools] .mindmap-toolbar{position:absolute;top:8px;right:8px;height:24px;z-index:3}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block [data-type=block-tools] .mindmap-toolbar .editor-button.mindmap-button{background-color:transparent;outline:none;border:none;fill:none;color:#c1c1c1;cursor:pointer;min-width:initial;margin-right:0}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block [data-type=block-tools] .mindmap-toolbar .editor-button.mindmap-button:hover{color:#5587f0}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block.to-mindmap-highlight [data-type=block-content],.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block.to-mindmap-highlight:hover [data-type=block-content]{background-color:#eaf3fc}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block button[data-button-id=list-to-mindmap],.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block button[data-button-id=list-block-mention]{position:absolute;right:0;top:0;flex-grow:0;flex-shrink:0;width:24px;height:24px;min-width:24px;min-height:24px;padding:0;border:0;outline:0;display:flex;align-items:center;justify-content:end;background-color:transparent}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block button[data-button-id=list-to-mindmap] svg,.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block button[data-button-id=list-block-mention] svg{width:16px;height:16px}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block button[data-button-id=list-block-mention]:hover>svg{cursor:initial;background-color:#eee}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block button+button[data-button-id=list-block-mention]{right:20px}div.editor-root div.editor-content div[data-block-type=list][data-list-level="1"]{padding-left:0}div.editor-root div.editor-content div[data-block-type=list][data-list-level="2"]{padding-left:24px}div.editor-root div.editor-content div[data-block-type=list][data-list-level="3"]{padding-left:48px}div.editor-root div.editor-content div[data-block-type=list][data-list-level="4"]{padding-left:72px}div.editor-root div.editor-content div[data-block-type=list][data-list-level="5"]{padding-left:96px}div.editor-root div.editor-content div[data-block-type=list][data-list-level="6"]{padding-left:120px}div.editor-root div.editor-content div[data-block-type=list][data-list-level="7"]{padding-left:144px}div.editor-root div.editor-content div[data-block-type=list][data-list-level="8"]{padding-left:168px}div.editor-root div.editor-content div[data-block-type=list][data-list-level="9"]{padding-left:192px}div.editor-root div.editor-content div[data-block-type=list][data-list-level="10"]{padding-left:216px}div.editor-root div.editor-content div[data-block-type=list][data-list-level="11"]{padding-left:240px}div.editor-root div.editor-content div[data-block-type=list][data-list-level="12"]{padding-left:264px}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block+div[data-type=editor-block].list-block{margin-top:0}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block{display:flex;padding-bottom:2px;padding-top:2px}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block[data-list-type=text-only] .list-container{pointer-events:none}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block[data-list-type=checked] div[data-type=block-content] span.text{color:#c7c7c7}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block [data-type=block-content]{position:relative;flex-grow:1;padding-left:2px;margin-right:29px}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block .list-container{display:flex;min-width:24px;align-items:center;justify-content:center;flex-shrink:0;border-radius:3px;height:calc(var(--font-size) * var(--line-height))}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block .list-container .list-marker{min-width:16px;border:none;background-color:transparent;outline:none;display:flex;align-items:center;justify-content:flex-end;padding:0;overflow:visible;color:var(--primary-color);font-size:var(--font-size)}.editor-root.readonly button[data-button-id=mindmap-close]{display:none}.editor-root:not(.readonly) div[data-type=editor-block].list-block.active [data-type=block-content],.editor-root:not(.readonly) div[data-type=editor-block].list-block.hover [data-type=block-content]{background-color:#f4f4f4}.editor-root:not(.readonly) div[data-type=editor-block].list-block.active [data-type=block-content] .list-container,.editor-root:not(.readonly) div[data-type=editor-block].list-block.hover [data-type=block-content] .list-container{cursor:pointer}.editor-root:not(.readonly) div[data-type=editor-block].list-block .list-container:hover .list-marker{cursor:pointer}.editor-root:not(.readonly) div[data-type=editor-block].list-block:not([data-list-type=unchecked]):not([data-list-type=checked]) .list-container:hover{background-color:var(--background-selection)}.editor-root:not(.readonly) div[data-type=editor-block].list-block[data-list-type=unchecked] .list-container:hover .list-marker svg>*{fill:var(--background-selection)}[data-tippy-root] .customize-start-panel{max-width:350px;padding:0 16px;color:#333;font-size:14px;line-height:21px;user-select:none;background-color:#fff!important}[data-tippy-root] .customize-start-panel-input{width:64px;margin:0 8px;border:1px solid #CFD6E1;height:24px;border-radius:3px;padding:1px 0 1px 8px;outline:none;color:inherit;background-color:#fff}[data-tippy-root] .customize-start-panel-button{min-width:40px;font-size:12px;min-height:30px;margin:0 8px 0 0;background-color:var(--primary-color);color:#fff;outline:none;border:none;padding:4px 8px;border-radius:4px;cursor:pointer}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="1"]{padding-left:24px}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="1"]>div[data-type=block-content]{position:relative}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="2"]{padding-left:48px}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="2"]>div[data-type=block-content]{position:relative}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="3"]{padding-left:72px}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="3"]>div[data-type=block-content]{position:relative}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="4"]{padding-left:96px}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="4"]>div[data-type=block-content]{position:relative}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="5"]{padding-left:120px}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="5"]>div[data-type=block-content]{position:relative}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="6"]{padding-left:144px}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="6"]>div[data-type=block-content]{position:relative}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="7"]{padding-left:168px}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="7"]>div[data-type=block-content]{position:relative}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="8"]{padding-left:192px}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="8"]>div[data-type=block-content]{position:relative}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="9"]{padding-left:216px}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="9"]>div[data-type=block-content]{position:relative}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="10"]{padding-left:240px}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="10"]>div[data-type=block-content]{position:relative}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="11"]{padding-left:264px}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="11"]>div[data-type=block-content]{position:relative}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="12"]{padding-left:288px}div.editor-root div.editor-content div[data-block-type=text][block-padding-level="12"]>div[data-type=block-content]{position:relative}div.editor-root div.editor-content div[data-type=editor-container]>.embed-block[data-embed-type=math]>div[data-type=block-content] img{margin:auto;padding:8px}.mathjax-editor-textarea{border:none;outline:none;width:400px;height:128px}.editor-text-button{border:0;color:var(--text-button-color, #c1c1c1);background-color:var(--text-button-bg-color, transparent);cursor:pointer;border-radius:var(--editor-border-radius, 3px);font-size:14px;padding:1px 6px;display:flex;align-items:center}.editor-text-button:hover{color:var(--text-button-color-hover, #5587F0);background-color:var(--text-button-bg-color-hover, transparent)}div[data-type=editor-block].table-block{--table-bar-width: 6px;--table-bar-left: -6px;--table-bar-top: -6px}div[data-type=editor-block].table-block>div[data-type=block-content]{position:relative;left:-26px}div[data-type=editor-block].table-block.locked-by-self>[data-type=block-content]:after,div[data-type=editor-block].table-block.locked-by-others>[data-type=block-content]:after{display:none}div[data-type=editor-block].table-block.locked-by-self>[data-type=block-content] div[data-type=table-content],div[data-type=editor-block].table-block.locked-by-others>[data-type=block-content] div[data-type=table-content]{position:relative}div[data-type=editor-block].table-block.locked-by-self>[data-type=block-content] div[data-type=table-content]:after,div[data-type=editor-block].table-block.locked-by-others>[data-type=block-content] div[data-type=table-content]:after{content:" ";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;z-index:1;background-color:#303030;opacity:.1}div[data-type=editor-block].table-block div[data-type=table-tools] .table-resize-gripper{position:absolute;background-color:transparent;cursor:col-resize;padding:0 2px}div[data-type=editor-block].table-block div[data-type=table-tools] .table-resize-gripper>.table-resize-gripper-indicator{pointer-events:none;background-color:var(--primary-color);width:100%;height:100%}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container{position:absolute;background-color:transparent;z-index:10}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container.top{left:var(--table-bar-left);top:var(--table-bar-top);right:0;height:var(--table-bar-width);flex-direction:row}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container.left{top:0;left:var(--table-bar-left);width:var(--table-bar-width);bottom:0;flex-direction:column}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar{position:absolute;left:0;top:0;right:0;bottom:0;cursor:pointer;display:flex}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar.left{flex-direction:column}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .table-border-bar-cell{background-color:#eee;position:relative;flex-grow:0;flex-shrink:0}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .table-border-bar-cell.corner{width:var(--table-bar-width)}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .table-border-bar-cell.top{height:100%}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .table-border-bar-cell:hover{background-color:#ddd}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .table-border-bar-cell.selected{background-color:var(--primary-color)}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .table-border-bar-cell.danger{background-color:#e52727}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root{position:relative}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root.top{max-width:0;width:0;overflow:visible}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root.top:last-child{margin-left:-2px}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root.left{max-height:0;height:0;overflow:visible}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root.left:last-child{margin-top:-2px}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root .button-container{position:absolute;width:26px;height:26px;display:flex;align-items:center;justify-content:center;z-index:1}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root .button-container.top{right:-14px;top:-22px}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root .button-container.left{transform:rotate(270deg);left:-22px;bottom:-14px}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root .button-container .insert-indicator{position:absolute;width:3px;height:3px;background:#ccc;border-radius:50%;margin-top:6px}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root .button-container:hover .insert-indicator{display:none}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root .button-container:hover .insert-column-button{display:unset}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root .button-container:hover .insert-column-button span.icon{margin-top:2px}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root .button-container:hover .drop-marker{opacity:1;transform:scale(.7)}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root .button-container .drop-marker{width:26px;height:26px;border-radius:3px;background:var(--primary-color);cursor:pointer;opacity:0;transform:scale(.4);transition:transform .2s ease-in,opacity .2s ease-in}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root .button-container .drop-marker:after{content:"";display:block;width:10px;height:1px;background-color:#fff;position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)}div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container .table-border-bar .button-root .button-container .drop-marker:before{content:"";display:block;width:1px;height:10px;background-color:#fff;position:absolute;left:50%;top:50%;transform:translate(-50%,-50%)}div[data-type=editor-block].table-block div[data-type=table-tools] .editor-table-chart{padding-top:16px}div[data-type=editor-block].table-block div[data-type=table-content]{position:relative}div[data-type=editor-block].table-block div[data-type=table-content] .error{color:red;border:1px solid red;padding:8px}div[data-type=editor-block].table-block div[data-type=table-content]>table{border-collapse:collapse;width:max-content;border-spacing:0}div[data-type=editor-block].table-block div[data-type=table-content]>table colgroup col{min-width:40px}div[data-type=editor-block].table-block div[data-type=table-content]>table,div[data-type=editor-block].table-block div[data-type=table-content]>table td,div[data-type=editor-block].table-block div[data-type=table-content]>table th{border:1px solid grey;background-color:transparent}div[data-type=editor-block].table-block div[data-type=table-content]>table tr td.danger{background-color:#fce9e9!important}div[data-type=editor-block].table-block div[data-type=table-content]>table td{min-width:40px;border:2px solid #ddd;padding:0;position:relative}div[data-type=editor-block].table-block div[data-type=table-content]>table td .table-cell-menu-btn{display:none;position:absolute;right:2px;top:2px;padding:0;width:16px;height:16px;border:none;border-radius:3px;background:#eaf3fc;color:#338fe5;cursor:pointer;transform:rotate(0);transition:transform .2s}div[data-type=editor-block].table-block div[data-type=table-content]>table td .table-cell-menu-btn.active{transform:rotate(180deg)}div[data-type=editor-block].table-block div[data-type=table-content]>table td div[data-type=editor-container].child{padding:8px}div[data-type=editor-block].table-block div[data-type=table-content]>table td div[data-type=editor-container].child div[data-type=editor-block].table-block>div[data-type=block-content]{pointer-events:none}div[data-type=editor-block].table-block div[data-type=table-content]>table td div[data-type=editor-container].child div[data-type=editor-block].table-block>div[data-type=block-content] div[data-type=table-content]{pointer-events:auto}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-0{background-color:var(--background-color-0)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-1{background-color:var(--background-color-1)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-2{background-color:var(--background-color-2)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-3{background-color:var(--background-color-3)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-4{background-color:var(--background-color-4)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-5{background-color:var(--background-color-5)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-6{background-color:var(--background-color-6)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-7{background-color:var(--background-color-7)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-8{background-color:var(--background-color-8)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-9{background-color:var(--background-color-9)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-10{background-color:var(--background-color-10)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-11{background-color:var(--background-color-11)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-12{background-color:var(--background-color-12)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-13{background-color:var(--background-color-13)}div[data-type=editor-block].table-block div[data-type=table-content]>table td.style-bg-color-14{background-color:var(--background-color-14)}div[data-type=editor-block].table-block div[data-type=table-content]>table.row-title>tbody>tr:first-child>td,div[data-type=editor-block].table-block div[data-type=table-content]>table.col-title td.col-title-item{background-color:#f8f8f8}div[data-type=editor-block].table-block div[data-type=table-content]>table.stripe:not(.row-title)>tbody>tr:nth-of-type(2n),div[data-type=editor-block].table-block div[data-type=table-content]>table.stripe.row-title>tbody>tr:nth-of-type(2n + 1){background-color:#f5f8fb}div[data-type=editor-block].table-block div[data-type=table-content]>table.no-border,div[data-type=editor-block].table-block div[data-type=table-content]>.no-border>tbody>tr>td{border:1px dashed;border-color:transparent}div[data-type=editor-block].table-block.focused div[data-type=table-content]>table.no-border,div[data-type=editor-block].table-block.focused div[data-type=table-content]>table.no-border>tbody>tr>td,div[data-type=editor-block].table-block.child-focused div[data-type=table-content]>table.no-border,div[data-type=editor-block].table-block.child-focused div[data-type=table-content]>table.no-border>tbody>tr>td{border-color:#b9bfc8}div[data-type=editor-block].table-block.full-selected div[data-type=table-content]>table{background-color:var(--background-selection)}div[data-type=editor-block].table-block div[data-type=table-content]>table tbody tr td.selected,div[data-type=editor-block].table-block div[data-type=table-content]>table.row-title tbody tr td.selected,div[data-type=editor-block].table-block div[data-type=table-content]>table.col-title tbody tr td.selected{background-color:var(--background-selection)}div[data-type=editor-block].table-block div[data-type=table-content]>table td div[data-type=editor-block].table-block div[data-type=table-content]>table{max-width:100%}.command-item.menu-item .table-creator{background-color:#fff;padding:0 5px}.command-item.menu-item .table-creator .table-creator-row{display:flex}.command-item.menu-item .table-creator .table-creator-row .table-creator-cell{width:16px;height:16px;margin:3px;border:solid 1px #ddd}.command-item.menu-item .table-creator .table-creator-row .table-creator-cell.active{background-color:#99c7f2}div.editor-root div.editor-content div[data-type=editor-container].root div[data-type=editor-block].table-block{margin-top:0}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color]{width:100%}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .bar-desc{display:none}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item{box-sizing:border-box;width:100%;height:32px;padding:5px 10px;display:flex;align-items:center;justify-content:space-between;color:var(--text-color)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-sub-indicator{display:flex;align-items:center;margin-left:5px}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-sub-indicator svg{height:16px;width:16px}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button{width:24px;height:24px;border:none;outline:none;cursor:pointer;border-radius:3px;position:relative;margin-left:auto}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="-1"]{position:relative;background-color:#fff;border:1px solid #e8e8e8}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="-1"]:after{transform:scale(1.2)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="-1"]:before{content:"";position:absolute;width:1px;height:56px;top:2px;left:22px;background-color:#c7c7c7;transform:rotate(45deg) scale(.5);transform-origin:-1px -2px}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="0"]{background-color:var(--background-color-0)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="1"]{background-color:var(--background-color-1)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="2"]{background-color:var(--background-color-2)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="3"]{background-color:var(--background-color-3)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="4"]{background-color:var(--background-color-4)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="5"]{background-color:var(--background-color-5)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="6"]{background-color:var(--background-color-6)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="7"]{background-color:var(--background-color-7)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="8"]{background-color:var(--background-color-8)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="9"]{background-color:var(--background-color-9)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="10"]{background-color:var(--background-color-10)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="11"]{background-color:var(--background-color-11)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="12"]{background-color:var(--background-color-12)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="13"]{background-color:var(--background-color-13)}div.tippy-box[data-theme=menu] .tippy-content div[data-id=cell-background-color] .cell-background-color-item .item-button[data-color-index="14"]{background-color:var(--background-color-14)}div.editor-root div.editor-content div[data-type=editor-block] [data-type=block-tools] .block-resizer{position:absolute;background-color:transparent;border:1px solid #338FE5;pointer-events:none;z-index:1;display:none}div.editor-root div.editor-content div[data-type=editor-block] [data-type=block-tools] .block-resizer.active{display:block}div.editor-root div.editor-content div[data-type=editor-block] [data-type=block-tools] .block-resizer .resize-gripper{position:absolute;width:16px;height:16px;border:2px solid white;background-color:#338fe5;border-radius:50%;pointer-events:all}div.editor-root div.editor-content div[data-type=editor-block] [data-type=block-tools] .block-resizer .resize-gripper.bottom{left:calc(50% - 8px);bottom:-8px;cursor:ns-resize}div.editor-root div.editor-content div[data-type=editor-block] [data-type=block-tools] .block-resizer .resize-gripper.top-left{left:-8px;top:-8px;cursor:nwse-resize}div.editor-root div.editor-content div[data-type=editor-block] [data-type=block-tools] .block-resizer .resize-gripper.top-right{right:-8px;top:-8px;cursor:nesw-resize}div.editor-root div.editor-content div[data-type=editor-block] [data-type=block-tools] .block-resizer .resize-gripper.bottom-left{left:-8px;bottom:-8px;cursor:nesw-resize}div.editor-root div.editor-content div[data-type=editor-block] [data-type=block-tools] .block-resizer .resize-gripper.bottom-right{right:-8px;bottom:-8px;cursor:nwse-resize}.editor-dialog-container{min-width:500px;position:relative;left:-9px}.editor-dialog-container .dialog-header{display:flex;justify-content:space-between;align-items:center;padding:0 20px;border-bottom:1px solid #e8e8e8}.editor-dialog-container .dialog-header .close-icon{cursor:pointer}.editor-dialog-container .dialog-header .dialog-header-title{padding:8px 0 11px;font-size:18px;font-weight:700;flex-grow:1}.editor-dialog-container .dialog-content{padding:20px;border-bottom:1px solid #e8e8e8}.editor-dialog-container .dialog-footer{margin:10px 0 5px;padding:0 20px;text-align:right}.editor-dialog-container .dialog-footer button{min-width:58px;min-height:30px;padding:0 10px;border-radius:3px;background-color:#eef3f8;font-size:14px;color:#fff;cursor:pointer}.editor-dialog-container .dialog-footer .cancel-button{margin:0 8px 0 0;background-color:transparent;border:1px solid #c7c7c7;color:#606060}.editor-dialog-container .dialog-footer .cancel-button:hover{color:#303030;background:#eee;border:1px solid #c7c7c7}.editor-dialog-container .dialog-footer .submit-button{outline:none;background-color:#338fe5;color:#fff;border:0}.editor-dialog-container .dialog-footer .submit-button:hover{background-color:#5ca5ea}.embed-block[data-embed-type=webpage]{min-height:100px;max-height:1000px}.embed-block[data-embed-type=webpage] .webpage-mask{position:absolute;left:0;right:0;top:0;bottom:0;z-index:1;background-color:transparent}.embed-block[data-embed-type=webpage].resizing [data-type=block-tools] .block-resizer{pointer-events:all!important}.embed-block[data-embed-type=webpage].hover>div[data-type=block-content]{outline:none!important}.embed-block[data-embed-type=webpage].selected>div[data-type=block-content]{outline:none!important}.embed-block[data-embed-type=webpage].selected>div[data-type=block-content]:before{content:" ";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;z-index:1;background-color:#338fe5;opacity:.1}.embed-block[data-embed-type=webpage]>div[data-type=block-content]{justify-content:center;height:100%}.embed-block[data-embed-type=webpage]>div[data-type=block-content]>.editor-embed{width:100%}.embed-block[data-embed-type=webpage]>div[data-type=block-content]>.editor-embed .editor-preview-iframe{width:100%;max-height:500px;height:100%;border:none;position:relative}.embed-block[data-embed-type=webpage]>div[data-type=block-content]>.editor-embed .editor-preview-iframe-loading{position:absolute;top:0;left:0;bottom:0;right:0;display:flex;justify-content:center;align-items:center;background-color:#fff}.webpage-content .help-container{color:#303030;border:1px solid #dedede;padding:10px;border-radius:4px;border-left:4px solid #338fe5;margin-top:16px;margin-bottom:16px}.webpage-content .help-container .help-content{display:flex;align-items:center}.webpage-content .help-container .help-content .help-icon{color:#338fe5;margin-right:12px}.webpage-content .help-link-container{margin-top:8px;display:flex;align-items:center}.webpage-content .help-link-container .help-link-content{display:flex;align-items:center;color:#338fe5;text-decoration:none}.webpage-content .help-link-container .help-link-content .help-link-icon{width:16px;height:16px;margin-left:8px}div.editor-root:not(.readonly) div.editor-content div[data-type=editor-container] div[data-type=editor-block] [data-type=block-content][data-title-placeholder]:before{position:absolute;left:0;top:0;right:0;bottom:0;content:attr(data-title-placeholder);color:#ccc}div.editor-root:not(.readonly) div.editor-content div[data-type=editor-container] div[data-type=editor-block] [data-type=block-content][data-content-placeholder]:before{position:absolute;left:0;top:0;right:0;bottom:0;content:attr(data-content-placeholder);color:#ccc;overflow:hidden;white-space:nowrap;text-overflow:ellipsis;display:flex;align-items:center}div.editor-root:not(.readonly) div.editor-content div[data-type=editor-container] div[data-type=editor-block] [data-type=block-tools] .block-placeholder-container{position:absolute;left:0;top:0;right:0}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block{counter-reset:code-line}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block.full-selected{background-color:var(--background-selection)}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block.editing-language div[data-type=block-tools] .code-block-header,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block.child-focused div[data-type=block-tools] .code-block-header,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block:hover div[data-type=block-tools] .code-block-header{opacity:1}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block.wrap>div[data-type=block-tools] .code-block-header button[data-id=wrap] *{color:var(--primary-color)}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block:not(.wrap)>div[data-type=block-content] div[data-type=editor-container].child{overflow-x:auto}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block:not(.wrap)>div[data-type=block-content] div[data-type=editor-container].child div[data-type=block-content]{word-break:keep-all;overflow:visible}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block:not(.wrap)>div[data-type=block-content] div[data-type=editor-container].child div[data-type=block-content]>span.text{white-space:pre}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-tools] .code-block-header{opacity:0;transition:opacity .3s ease-in 0s;position:absolute;top:0;display:flex;padding-left:16px;padding-right:4px;align-items:center;left:0;right:0;height:32px}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-tools] .code-block-header .language-select{font-size:14px;color:#999;cursor:pointer;display:flex;align-items:center}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-tools] .code-block-header .language-select .arrow-icon{width:16px;height:16px}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-tools] .code-block-header .code-header-spacer{flex-grow:1}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-tools] .code-block-header .code-header-button{display:flex;justify-content:center;align-items:center;height:24px;background:#ddd;border:none;border-radius:2px;margin-left:4px;cursor:pointer}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-tools] .code-block-header .code-header-button .button-icon{width:16px;height:16px;display:flex;align-items:center;justify-content:center}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-tools] .code-block-header .code-header-button .button-label{margin-left:4px;font-size:14px}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block.full-selected>div[data-type=block-content]>div.editor-code-root>div.code-text-root{background-color:unset}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root{background-color:var(--background-code)}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container]{padding-left:32px;padding-top:32px;padding-bottom:24px}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container].selected{background-color:var(--background-selection)}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] *{font-family:Consolas,Monaco,Andale Mono,Ubuntu Mono,monospace;font-size:14px}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block+div.text-block{margin-top:4px}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block:before{content:counter(code-line);counter-increment:code-line;position:absolute;left:-48px;top:10px;z-index:1;margin-top:-6px;display:block;width:48px;padding-right:8px;text-align:right;color:#aaa;box-sizing:border-box;font-size:12px;font-weight:400;line-height:12px;letter-spacing:0;white-space:nowrap;opacity:1}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-comment,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-prolog,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-doctype,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-cdata{color:#708090}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-punctuation{color:#999}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-namespace{opacity:.7}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-property,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-tag,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-boolean,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-number,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-constant,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-symbol,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-deleted{color:#905}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-selector,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-attr-name,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-string,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-char,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-builtin,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-inserted{color:#690}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-operator,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-entity,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-url,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-string{color:#9a6e3a}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-atrule,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-attr-value,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-keyword{color:#07a}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-function,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-class-name{color:#dd4a68}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-regex,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-important,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-variable{color:#e90}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-important,.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-bold{font-weight:700}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-italic{font-style:italic}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-text-root>div.child[data-type=editor-container] div.text-block>div[data-type=block-content] span.style-code-entity{cursor:help}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-caption-root{padding:8px}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block>div[data-type=block-content]>div.editor-code-root>div.code-caption-root *{color:#aaa}.before-content,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image].selected [data-type=block-content] .images .image-container.active:before,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image].selected:not(.focused) [data-type=block-content] .images .image-container:before{content:" ";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;z-index:1;background-color:#338fe5;opacity:.1}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image]{display:flex}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image][data-style-align=left]{justify-content:flex-start}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image][data-style-align=right]{justify-content:flex-end}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image].hover [data-type=block-content]{outline:none}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image].hover [data-type=block-content] .images .image-container.empty:hover,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image].hover [data-type=block-content] .images .image-container.error:hover{outline:1px solid #338FE5}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image].selected [data-type=block-content]{outline:none}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image].multi [data-type=block-tools] .block-resizer{display:none}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image]:not(.multi) [data-type=block-content] .images.empty{min-height:400px}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content]{cursor:default}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images{width:100%;display:flex;align-items:flex-start}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-splitter{width:10px;flex-grow:0;flex-shrink:0;padding:0 4px;cursor:col-resize;height:100%}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-splitter .image-splitter-indicator{width:100%;height:100%}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-splitter:active .image-splitter-indicator,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-splitter:hover .image-splitter-indicator{background-color:#d9d9d9}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container{position:relative;flex:1;background-color:#f8f8f8;display:flex;min-height:inherit}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container img{max-width:100%;height:auto}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container.empty .upload-image-icon{color:#c7c7c7}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container.error{height:100%;outline:1px solid #DEDEDE;border-radius:3px}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container.error img{display:none}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .load-error,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .upload-error{position:absolute;left:0;top:0;right:0;bottom:0;display:flex;flex-direction:column;align-items:center;justify-content:center;z-index:1}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .load-error .error-icon,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .upload-error .error-icon{color:#c7c7c7}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .load-error .error-message,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .upload-error .error-message{display:flex;flex-direction:column;align-items:center;overflow:hidden}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .load-error .error-message .line-1,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .upload-error .error-message .line-1{margin-top:10px;font-size:18px;font-weight:500;color:#303030;height:26px;vertical-align:middle;line-height:26px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;flex-shrink:0}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .load-error .error-message .line-2,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .load-error .error-message .line-3,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .upload-error .error-message .line-2,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .upload-error .error-message .line-3{font-size:14px;color:#606060;vertical-align:middle;height:22px;line-height:22px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;flex-shrink:0}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .load-error .error-message .line-2 a,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .load-error .error-message .line-3 a,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .upload-error .error-message .line-2 a,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .upload-error .error-message .line-3 a{text-decoration:none;color:#338fe5}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .load-error .line-3 a{display:inline-flex;align-items:center;text-decoration:none}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .load-error .line-3 a:after{content:" ";display:inline-block;width:16px;height:16px;margin-left:5px;background-image:url("data:image/svg+xml,%3Csvg width='17' height='16' viewBox='0 0 17 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M6.5 2H3.5C2.94772 2 2.5 2.44772 2.5 3V13C2.5 13.5523 2.94772 14 3.5 14H13.5C14.0523 14 14.5 13.5523 14.5 13V10' stroke='%23338FE5'/%3E%3Cpath d='M14.5 2L9 7.5' stroke='%23338FE5'/%3E%3Cpath d='M8.5 2H14.5V8' stroke='%23338FE5'/%3E%3C/svg%3E%0A")}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .uploading-progress-mask{position:absolute;top:0;left:0;right:0;bottom:0;background-color:#303030;opacity:.8;display:flex;align-items:center;justify-content:center}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .uploading-progress-mask .uploading-progress-bar{width:75%;height:6px;border-radius:3px;display:flex;background-color:#fff}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .uploading-progress-mask .uploading-progress-bar .uploading-progress-bar-value{background-color:#338fe5}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container .image-warning{position:absolute;right:5px;top:5px;color:#fff;background-color:#f8f8f8;width:24px;height:24px;display:flex;align-items:center;justify-content:center;border-radius:3px;z-index:2}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container.empty{display:flex;flex-direction:column;align-items:center;outline:1px solid #DEDEDE;border-radius:3px;justify-content:center}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-content] .images .image-container.empty svg{width:64px;height:64px}.editor-root[readonly=true] .image-splitter{visibility:hidden}.editor-root .editor-content div[data-type=editor-block].dragging{opacity:.4}.editor-root .editor-content div[data-type=editor-block].dragging div[data-type=block-tools] .block-helper{opacity:0}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper{position:absolute;right:100%;top:0;padding-right:8px;display:flex;align-items:center}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .helper-sizer{width:0;opacity:0;pointer-events:none}div[data-type=editor-block].locked-by-self>[data-type=block-content],div[data-type=editor-block].locked-by-others>[data-type=block-content]{position:relative}div[data-type=editor-block].locked-by-self>[data-type=block-content]:after,div[data-type=editor-block].locked-by-others>[data-type=block-content]:after{content:" ";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;z-index:1;background-color:#303030;opacity:.1}div[data-type=editor-block].locked-by-self.text-block>[data-type=block-content]:after,div[data-type=editor-block].locked-by-others.text-block>[data-type=block-content]:after{outline:2px solid #303030}.editor-root{--selected-color: #e8e8e8}.editor-root .editor-content .editor-drop-indicator{position:absolute;background-color:var(--primary-color);pointer-events:none;transition:top .2s linear,left .2s linear,width .2s linear}.editor-root .editor-content div[data-type=editor-block].text-block.highlighted{outline:2px solid var(--background-selection);background-color:var(--background-selection)}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .block-button{width:24px;height:24px;cursor:grab;margin:0;padding:0;display:flex;align-items:center;justify-content:center;background-color:transparent;border:none;border-radius:3px}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .block-button:hover{background-color:var(--selected-color)}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .block-button svg{width:16px;height:16px}.drag-image-container{position:fixed;z-index:100;max-width:50%;border-radius:3px;box-shadow:0 3px 20px #00000026;background-color:#fff}.drag-image-container.drag-placeholder{width:500px;height:200px;border:1px solid #dedede;border-radius:3px;background:#e8e8e8}.drag-image-container .drag-image{width:100%;display:none}.drag-image-container[data-status=loaded] .drag-image{display:block}.drag-image-container[data-status=loaded] .drag-loading{display:none}.editor-command-bar-root .editor-command-bar .command-item.menu-item{display:flex;align-items:center;flex:none}.editor-command-bar-root .editor-command-bar .command-item.menu-item .text-styles{padding:5px 10px;background-color:#fff}.editor-command-bar-root .editor-command-bar .command-item.menu-item .text-styles .text-style-section+.text-style-section{margin-top:5px}.editor-command-bar-root .editor-command-bar .command-item.menu-item .text-styles .text-style-section{display:flex;flex-wrap:wrap}.editor-command-bar-root .editor-command-bar .command-item.menu-item .text-styles .text-style-section .style-icon{width:24px;height:24px;padding:0;margin:0 5px 0 0;display:flex;align-items:center;justify-content:center;background-color:transparent;border:none;outline:none;cursor:pointer;border-radius:3px;color:#606060}.editor-command-bar-root .editor-command-bar .command-item.menu-item .text-styles .text-style-section .style-icon svg{width:16px;height:16px}.editor-command-bar-root .editor-command-bar .command-item.menu-item .text-styles .text-style-section .style-icon:hover{background-color:var(--selected-color)}.editor-command-bar-root .editor-command-bar .command-item.menu-item .text-styles .text-style-section .style-icon.active{color:#338fe5}:root{--editor-quoted-color: #7084a4;--editor-drawio-empty-svg: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNDgiIGhlaWdodD0iNDgiIHZpZXdCb3g9IjAgMCA0OCA0OCIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik0zOC43MjAzIDI4LjcwOTdIMjUuOTIzM0MyNS4yMTY1IDI4LjcwOTcgMjQuNjQzNSAyOC4xNDgxIDI0LjY0MzUgMjcuNDU1MlYyNS43MzMzSDIwLjUyODNDMjAuNDk4NiAyNS43Njk2IDIwLjQ2NjkgMjUuODA0MiAyMC40MzMzIDI1LjgzN0wxNS45MTkyIDMwLjI2MjFWMzQuNzU1NkgyNC42NDM1VjMzLjcyNzZDMjQuNjQzNSAzMy4wMzQ4IDI1LjIxNjUgMzIuNDczMiAyNS45MjMzIDMyLjQ3MzJIMzguNzIwM0MzOS40MjcgMzIuNDczMiA0MCAzMy4wMzQ4IDQwIDMzLjcyNzZWMzguNzQ1NUM0MCAzOS40MzgzIDM5LjQyNyA0MCAzOC43MjAzIDQwSDI1LjkyMzNDMjUuMjE2NSA0MCAyNC42NDM1IDM5LjQzODMgMjQuNjQzNSAzOC43NDU1VjM3LjMzMzNIMTQuNjI2M0MxMy45MTIyIDM3LjMzMzMgMTMuMzMzMyAzNi43NTYyIDEzLjMzMzMgMzYuMDQ0NFYzMC42OTQxTDguMzc4NTIgMjUuODM3QzguMTM2MjYgMjUuNjAxNCA4IDI1LjI4MDggOCAyNC45NDYzQzggMjQuNjExOCA4LjEzNjI2IDI0LjI5MTEgOC4zNzg1MiAyNC4wNTU2TDEzLjMzMzMgMTkuMTk4NVYxNS43NzJDMTEuNzc5OCAxNS4yMjI5IDEwLjY2NjcgMTMuNzQxNiAxMC42NjY3IDEyQzEwLjY2NjcgOS43OTA4NSAxMi40NTc1IDggMTQuNjY2NyA4QzE2Ljg3NTggOCAxOC42NjY2IDkuNzkwODUgMTguNjY2NiAxMkMxOC42NjY2IDEzLjcyNjUgMTcuNTU4OCAxNS4yNTgxIDE1LjkxOTEgMTUuNzk4OFYxOS4yODg4QzE1LjkxOTEgMTkuMzkxOCAxNS45MDY4IDE5LjQ5NDMgMTUuODgyMyAxOS41OTQzTDE5LjUxNTEgMjMuMTU1NUgyNC42NDM1VjIyLjQzNzNDMjQuNjQzNSAyMS43NDQ1IDI1LjIxNjUgMjEuMTgyOSAyNS45MjMzIDIxLjE4MjlIMzguNzIwM0MzOS40MjcgMjEuMTgyOSA0MCAyMS43NDQ1IDQwIDIyLjQzNzNWMjcuNDU1MkM0MCAyOC4xNDgxIDM5LjQyNyAyOC43MDk3IDM4LjcyMDMgMjguNzA5N1pNMjcuMjAzIDM3LjQ5MUgzNy40NDA2VjM0Ljk4MjFIMjcuMjAzVjM3LjQ5MVpNMTQuNDA1OSAyOC4xOTU0TDExLjA5MTUgMjQuOTQ2M0wxNC40MDU5IDIxLjY5NzJMMTcuNzIwNCAyNC45NDYzTDE0LjQwNTkgMjguMTk1NFpNMjcuMjAzIDI2LjIwMDhIMzcuNDQwNlYyMy42OTE4SDI3LjIwM1YyNi4yMDA4WiIgZmlsbD0iIzA3MTQyQSIvPgo8L3N2Zz4K)}.flex-center,.editor-drawio-iframe-container.loading:before,.embed-block .editor-empty-drawio.editor-drawio-content.editor-embed:after,.embed-block .editor-empty-drawio.editor-drawio-content.editor-embed:before{display:flex;align-items:center;justify-content:center}.full-screen,.editor-drawio-iframe-container.loading:before,.drawio-iframe-element,.editor-drawio-iframe-container{width:100%;height:100%}.editor-drawio-iframe-container{position:fixed;top:0;left:0;z-index:10}div[data-type=editor-block].embed-block[data-embed-type=drawio]>div[data-type=block-content]{outline:1px solid #DEDEDE}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio]>div[data-type=block-content]{justify-content:center;border-radius:3px;padding:10px}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio]>div[data-type=block-content] .editor-drawio-content{text-align:center}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block].embed-block[data-embed-type=drawio].selected>div[data-type=block-content]:before{content:" ";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;z-index:1;background-color:#338fe5;opacity:.1}.embed-block .editor-empty-drawio.editor-drawio-content.editor-embed{width:240px;height:80px;display:inline-block;text-align:center}.embed-block .editor-empty-drawio.editor-drawio-content.editor-embed:before{background-image:var(--editor-drawio-empty-svg);position:absolute;content:" ";color:var(--editor-quoted-color);top:8px;left:calc(50% - 24px);width:48px;height:48px}.embed-block .editor-empty-drawio.editor-drawio-content.editor-embed:after{position:absolute;content:attr(data-empty-drawio-content);color:var(--editor-quoted-color);bottom:0;left:0;width:100%;height:32px;top:50%}div.editor-root div.editor-content div[data-type=editor-container] div[data-embed-type=drawio].embed-block>div[data-type=block-content] img{max-width:100%;height:auto}.editor-drawio-iframe-container.loading:before{content:attr(data-placeholder);position:absolute;top:0;left:0;background-color:#f7f6f3;z-index:2}.editor-content .editing{background-color:#cdcdcd40}.editor-content div[data-type=block-tools] .embed-code-editor-container{position:absolute;top:0;left:0px;right:0px;bottom:0;background-color:#cdcdcd40;z-index:var(--wiz-editor-z-embed-code-editor-mask);padding:8px}.editor-content div[data-type=block-tools] .embed-code-editor-container textarea{width:100%;height:100%;resize:none;outline:none;padding:12px;border:1px solid #b9bfc8;border-radius:4px;background-color:#fff;color:#333}.flex-row-center,.embed-block div[data-type=block-content] .graph-embed,div[data-embed-type=mermaid] div[data-type=block-content] .graph-embed,div[data-embed-type=flowchart] div[data-type=block-content] .graph-embed,div[data-embed-type=plantuml] div[data-type=block-content] .graph-embed,.embed-block div[data-type=block-content] .invalid-code:not(.empty-embed),div[data-embed-type=mermaid] div[data-type=block-content] .invalid-code:not(.empty-embed),div[data-embed-type=flowchart] div[data-type=block-content] .invalid-code:not(.empty-embed),div[data-embed-type=plantuml] div[data-type=block-content] .invalid-code:not(.empty-embed),.embed-block div[data-type=block-content] .empty-embed:after,div[data-embed-type=mermaid] div[data-type=block-content] .empty-embed:after,div[data-embed-type=flowchart] div[data-type=block-content] .empty-embed:after,div[data-embed-type=plantuml] div[data-type=block-content] .empty-embed:after,.embed-block,div[data-embed-type=mermaid],div[data-embed-type=flowchart],div[data-embed-type=plantuml]{display:flex;flex-direction:row;align-items:center;justify-content:center}.embed-block div[data-type=block-content],div[data-embed-type=mermaid] div[data-type=block-content],.embed-block div[data-type=block-content],div[data-embed-type=flowchart] div[data-type=block-content],.embed-block div[data-type=block-content],div[data-embed-type=plantuml] div[data-type=block-content]{width:100%;position:relative}.embed-block div[data-type=block-content] .empty-embed,div[data-embed-type=mermaid] div[data-type=block-content] .empty-embed,.embed-block div[data-type=block-content] .empty-embed,div[data-embed-type=flowchart] div[data-type=block-content] .empty-embed,.embed-block div[data-type=block-content] .empty-embed,div[data-embed-type=plantuml] div[data-type=block-content] .empty-embed{width:100%;min-height:106px;background-color:#cdcdcd40}.embed-block div[data-type=block-content] .empty-embed:after,div[data-embed-type=mermaid] div[data-type=block-content] .empty-embed:after,.embed-block div[data-type=block-content] .empty-embed:after,div[data-embed-type=flowchart] div[data-type=block-content] .empty-embed:after,.embed-block div[data-type=block-content] .empty-embed:after,div[data-embed-type=plantuml] div[data-type=block-content] .empty-embed:after{content:attr(data-empty-tips);position:absolute;top:0;right:0;width:100%;height:100%;color:#07142a;white-space:nowrap}.embed-block div[data-type=block-content] .invalid-code:not(.empty-embed),div[data-embed-type=mermaid] div[data-type=block-content] .invalid-code:not(.empty-embed),.embed-block div[data-type=block-content] .invalid-code:not(.empty-embed),div[data-embed-type=flowchart] div[data-type=block-content] .invalid-code:not(.empty-embed),.embed-block div[data-type=block-content] .invalid-code:not(.empty-embed),div[data-embed-type=plantuml] div[data-type=block-content] .invalid-code:not(.empty-embed){width:100%;height:100px}.embed-block div[data-type=block-content] .invalid-code:not(.empty-embed) img,div[data-embed-type=mermaid] div[data-type=block-content] .invalid-code:not(.empty-embed) img,.embed-block div[data-type=block-content] .invalid-code:not(.empty-embed) img,div[data-embed-type=flowchart] div[data-type=block-content] .invalid-code:not(.empty-embed) img,.embed-block div[data-type=block-content] .invalid-code:not(.empty-embed) img,div[data-embed-type=plantuml] div[data-type=block-content] .invalid-code:not(.empty-embed) img{display:none}.embed-block div[data-type=block-content] .invalid-code:not(.empty-embed):after,div[data-embed-type=mermaid] div[data-type=block-content] .invalid-code:not(.empty-embed):after,.embed-block div[data-type=block-content] .invalid-code:not(.empty-embed):after,div[data-embed-type=flowchart] div[data-type=block-content] .invalid-code:not(.empty-embed):after,.embed-block div[data-type=block-content] .invalid-code:not(.empty-embed):after,div[data-embed-type=plantuml] div[data-type=block-content] .invalid-code:not(.empty-embed):after{content:attr(data-invalid-text);position:absolute;top:0;right:0;width:100%;height:100%;outline:1px solid red;display:flex;flex-direction:row;align-items:center;justify-content:center;color:red}.embed-block div[data-type=block-content] .embed-img-content,div[data-embed-type=mermaid] div[data-type=block-content] .embed-img-content,.embed-block div[data-type=block-content] .embed-img-content,div[data-embed-type=flowchart] div[data-type=block-content] .embed-img-content,.embed-block div[data-type=block-content] .embed-img-content,div[data-embed-type=plantuml] div[data-type=block-content] .embed-img-content{width:100%;text-align:center}.embed-block div[data-type=block-content] .mermaid-embed-img,div[data-embed-type=mermaid] div[data-type=block-content] .mermaid-embed-img,.embed-block div[data-type=block-content] .mermaid-embed-img,div[data-embed-type=flowchart] div[data-type=block-content] .mermaid-embed-img,.embed-block div[data-type=block-content] .mermaid-embed-img,div[data-embed-type=plantuml] div[data-type=block-content] .mermaid-embed-img{max-width:100%;min-width:200px}.embed-block div[data-type=block-content] .editor-plantuml-img,div[data-embed-type=mermaid] div[data-type=block-content] .editor-plantuml-img,.embed-block div[data-type=block-content] .editor-plantuml-img,div[data-embed-type=flowchart] div[data-type=block-content] .editor-plantuml-img,.embed-block div[data-type=block-content] .editor-plantuml-img,div[data-embed-type=plantuml] div[data-type=block-content] .editor-plantuml-img{max-width:100%}.embed-block div[data-type=block-content] .embed-graph-img-content,div[data-embed-type=mermaid] div[data-type=block-content] .embed-graph-img-content,.embed-block div[data-type=block-content] .embed-graph-img-content,div[data-embed-type=flowchart] div[data-type=block-content] .embed-graph-img-content,.embed-block div[data-type=block-content] .embed-graph-img-content,div[data-embed-type=plantuml] div[data-type=block-content] .embed-graph-img-content{width:100%;text-align:center}.embed-block div[data-type=block-content] .embed-graph-img-content img,div[data-embed-type=mermaid] div[data-type=block-content] .embed-graph-img-content img,.embed-block div[data-type=block-content] .embed-graph-img-content img,div[data-embed-type=flowchart] div[data-type=block-content] .embed-graph-img-content img,.embed-block div[data-type=block-content] .embed-graph-img-content img,div[data-embed-type=plantuml] div[data-type=block-content] .embed-graph-img-content img{max-width:100%}.embed-block div[data-type=block-content] .graph-embed,div[data-embed-type=mermaid] div[data-type=block-content] .graph-embed,.embed-block div[data-type=block-content] .graph-embed,div[data-embed-type=flowchart] div[data-type=block-content] .graph-embed,.embed-block div[data-type=block-content] .graph-embed,div[data-embed-type=plantuml] div[data-type=block-content] .graph-embed{width:100%}.hr-transition,.embed-block div[data-type=block-content] .editor-embed-container .editor-embed-hr{transition:border-top ease-in-out .4s}.embed-block div[data-type=block-content] .editor-embed-container{display:flex;align-items:center;width:100%}.embed-block div[data-type=block-content] .editor-embed-container .editor-embed-hr{display:block;width:100%;border:none;margin:0;border-top:2px dashed #cccccc;cursor:pointer}.embed-block:is(.focused) div[data-type=block-content] .editor-embed-container .editor-embed-hr{caret-color:transparent}.embed-block[data-type=editor-block][data-embed-type=hr]>div[data-type=block-content] .editor-embed-container{height:30px}.embed-block[data-type=editor-block][data-embed-type=hr].hover>div[data-type=block-content]{outline:none!important}.embed-block[data-type=editor-block][data-embed-type=hr].selected>div[data-type=block-content]{outline:none!important}.embed-block[data-type=editor-block][data-embed-type=hr].selected>div[data-type=block-content]:before{content:" ";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;z-index:1;background-color:#338fe5;opacity:.1}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-anchor[data-id=paste-special-button-anchor]{z-index:unset}[data-command-bar-id=paste-special-button] .editor-command-bar.toolbar{padding:0}[data-command-bar-id=paste-special-button] .editor-command-bar.toolbar .command-item[data-dropdown=true]{padding-left:9px;padding-right:5px}.editor-find-dialog{--popover-input-border: 1px solid #CFD6E1;--editor-find-dialog-input-container-border-color: #CFD6E1;--editor-find-dialog-input-container-bg-color: transparent;--editor-border-radius-big: 3px;--editor-color: #07142A;--button-black-text-color: #333;--editor-find-dialog-button-color: #333;--editor-find-dialog-icon-button-color: #333;--editor-find-dialog-button-border-bg-color: rgba(255, 255, 255, .56);--editor-find-dialog-input-placeholder-color: #b9bfc8;--editor-find-dialog-button-disabled-color: #ccc !important;--editor-find-dialog-button-hover-color: rgba(150, 150, 150, .2);--editor-find-dialog-button-border: solid 1px #ccc;box-sizing:border-box;width:400px;background-color:var(--editor-find-dialog-bg-color);border:var(--editor-find-dialog-border);border-radius:var(--editor-border-radius-big);display:flex;padding:8px 8px 0 16px;align-items:flex-start;font-size:14px;font-family:var(--editor-font-family)}.editor-find-dialog .editor-find-content{display:flex;flex-direction:column;flex-grow:1;font-family:inherit}.editor-find-dialog .editor-find-dialog-row{display:flex;margin-bottom:8px;align-items:center}.editor-find-dialog .editor-find-dialog-label{width:80px;flex-grow:0;flex-shrink:0;align-self:center}.editor-find-dialog .editor-find-dialog-input-container{border:var(--popover-input-border);border-color:var(--editor-find-dialog-input-container-border-color);background-color:var(--editor-find-dialog-input-container-bg-color);border-radius:var(--editor-border-radius-big);flex-grow:1;display:flex;padding:2px;align-items:center;height:32px;box-sizing:border-box}.editor-find-dialog .editor-find-dialog-input{border:none;flex-grow:1;width:80px;outline:none;background-color:transparent;color:var(--editor-color)}.editor-find-dialog .editor-find-dialog-input::placeholder{color:var(--editor-find-dialog-input-placeholder-color);opacity:1}.editor-find-dialog .editor-find-dialog-prev{width:24px}.editor-find-dialog .editor-find-dialog-curr{flex-grow:0;text-align:center;flex-shrink:1;display:flex;align-items:center;margin-bottom:2px}.editor-find-dialog .editor-find-dialog-next{width:24px}.editor-find-dialog .editor-find-dialog-icon-button{cursor:pointer;border-radius:4px;color:var(--editor-find-dialog-icon-button-color);background-color:var(--editor-find-dialog-button-border-bg-color);border:none;display:flex;padding:0}.editor-find-dialog .editor-find-dialog-button{padding:6px 16px;cursor:pointer;border-radius:4px;color:var(--editor-find-dialog-button-color);background-color:var(--editor-find-dialog-button-border-bg-color);margin:0 4px;border:none;font-family:inherit;line-height:21px}.editor-find-dialog .editor-find-dialog-button.icon-button{width:32px;height:32px}.editor-find-dialog .editor-find-dialog-button.active,.editor-find-dialog .editor-find-dialog-button:hover{background-color:var(--editor-find-dialog-button-hover-color)}.editor-find-dialog .editor-find-dialog-button:disabled{color:var(--editor-find-dialog-button-disabled-color);cursor:default}.editor-find-dialog .editor-find-dialog-button:disabled:hover{background-color:transparent}.editor-find-dialog .editor-find-dialog-button svg{fill:currentColor}.editor-find-dialog .editor-find-dialog-space{flex-grow:1}.editor-find-dialog .editor-find-dialog-icon-button-border{margin:0 0 0 8px;cursor:pointer;border-radius:4px;color:var(--button-black-text-color);border:var(--editor-find-dialog-button-border);background-color:var(--editor-find-dialog-button-border-bg-color);padding:0;width:32px;display:flex;justify-content:center;align-items:center}.editor-find-dialog .editor-find-dialog-button-close{margin:0 0 0 8px;cursor:pointer;border-radius:4px;color:var(--button-black-text-color);background-color:var(--editor-find-dialog-button-border-bg-color);border:none;padding:0;width:32px;height:32px;display:flex;justify-content:center;align-items:center}.editor-find-dialog .editor-find-dialog-icon-button-border svg,.editor-find-dialog .editor-find-dialog-button-close svg{fill:currentColor}.editor-find-dialog .editor-highlight{opacity:.6;pointer-events:none}.editor-find-dialog .editor-highlight .editor-highlight-child{position:absolute;background-color:bisque}.editor-find-dialog .editor-highlight.active .editor-highlight-child{position:absolute;background-color:tomato}.editor-find-dialog .editor-search-result-highlight{opacity:.6;pointer-events:none}.editor-find-dialog .editor-search-result-highlight .editor-highlight-child{position:absolute;background-color:#40e0d0}.editor-find-dialog .editor-find-dialog-status{display:flex}.editor-highlight{opacity:.6;pointer-events:none}.editor-highlight .editor-highlight-child{position:absolute;background-color:bisque}.editor-highlight.active .editor-highlight-child{position:absolute;background-color:tomato}.editor-search-result-highlight{opacity:.6;pointer-events:none}.editor-search-result-highlight .editor-highlight-child{position:absolute;background-color:#40e0d0}.editor-find-dialog-status{display:flex}.comment-editor{font-size:14px;border:1px solid #c7c7c7;border-radius:3px;padding:1px 10px;margin:6px 10px 0}.comment-editor:after{content:"";height:0;display:block;clear:both}.comment-editor-root{display:inline-block;min-width:calc(100% - 40px);padding-top:2px}.comment-editor-root .editor-root .editor-content{padding:0}.comment-editor-img{float:right;color:#c1c1c1;padding:0}.comment-editor-root:not(.comment-editor-readonly) .editor-root .editor-content [data-type=editor-block]:not([data-block-type=text]){width:248px}.comment-editor-editing{border:1px solid #338fe5}.comment-editor-readonly{border:none;padding-left:37px;margin:0}.comment-editor-readonly .comment-editor-img{display:none}.comment-item-root{position:relative;margin-top:10px}.comment-item-root:not(.last-comment-item):before{content:" ";display:block;position:absolute;left:20px;width:1px;background-color:var(--editor-border-color, #e8e8e8);overflow:hidden;opacity:.8;top:21px;bottom:-12px;transform:scaleX(.5)}.comment-item-root .item-head{padding:0 10px;position:relative;display:flex;align-items:center}.comment-item-root .item-head-avatar{margin-right:5px;width:var(--editor-comment-avatar-width, 21px);height:var(--editor-comment-avatar-width, 21px);border-radius:100%}.comment-item-root .item-head-username{font-size:var(--editor-comment-username-font-size, 12px);color:var(--editor-comment-username-color, #07142a);overflow:hidden;text-overflow:ellipsis;white-space:nowrap}.comment-item-root .item-head-modified{margin-left:8px;font-size:12px;color:var(--editor-comment-modified-color, #808080);flex-grow:1;white-space:nowrap}.comment-item-root .item-head-tools{display:flex;align-items:center;visibility:hidden}.comment-item-root .item-head-tools .editor-text-button svg{width:20px;height:20px}.comment-item-root .item-head-tools.active{visibility:visible}.comment-item-root .item-actions{margin-top:10px;display:flex;justify-content:flex-end}.comment-item-root .item-actions.hidden{display:none}.comment-item-root .item-actions .editor-button[data-button-id=comment-item-cancel]{color:#606060;background:transparent;border:1px solid #c7c7c7}.comment-item-root .item-actions .editor-button[data-button-id=comment-item-cancel]:hover{color:#303030;background:#eee;border:1px solid #c7c7c7}.comment-item-root .item-actions .editor-button.disabled[data-button-id=comment-item-ok]{color:#fff;background-color:#338fe580;cursor:default}.comment-item-root:hover:not(.comment-item-editing) .item-head-tools{visibility:visible}.mobile-comment-item{margin-top:4px;background-color:var(--editor-comment-layer-bg-color);padding-bottom:20px;color:var(--editor-comment-username-color)}.mobile-comment-item .item-head{padding:12px;display:flex;align-items:center}.mobile-comment-item .item-head-avatar{width:var(--editor-comment-avatar-size);height:var(--editor-comment-avatar-size);flex-grow:0}.mobile-comment-item .item-head-username{margin-left:12px}.mobile-comment-item .item-head-modified{margin-left:12px;color:#999}.mobile-comment-item .item-editor .comment-editor-readonly{padding-left:18px}.mini-comment-item{position:relative;line-height:16px;width:20px;height:16px;text-align:center;font-size:12px;border-radius:1px;background-color:var(--editor-comment-active-color, #FFC328);color:var(--editor-comment-mini-text-color, #ffffff);cursor:pointer}.mini-comment-item:after{content:"";position:absolute;left:50%;bottom:-4px;width:6px;height:6px;background-color:var(--editor-comment-active-color, #FFC328);border-radius:1px;transform:matrix(.71,.61,.82,-.71,0,0) translate(-50%);z-index:-1}.comment-quick-reply .quick-reply-button{position:absolute;left:8px;bottom:3px;z-index:2;color:var(--editor-comment-quick-reply-color, #7084A4);font-size:12px}.comment-quick-reply .quick-reply-button.editor-text-button:hover{color:var(--text-button-color-hover, #5587F0);background-color:var(--text-button-bg-color-hover, transparent)}.comment-quick-reply .quick-reply-editor{display:none}.comment-quick-reply .quick-reply-editor .reply-editor-actions{display:flex;justify-content:flex-end;margin-top:10px}.comment-quick-reply .quick-reply-editor .reply-editor-actions .editor-button[data-button-id=quick-reply-cancel]{color:#606060;background:transparent;border:1px solid #c7c7c7}.comment-quick-reply .quick-reply-editor .reply-editor-actions .editor-button[data-button-id=quick-reply-cancel]:hover{color:#303030;background:#eee;border:1px solid #c7c7c7}.comment-quick-reply .quick-reply-editor .reply-editor-actions .editor-button.disabled[data-button-id=quick-reply-ok]{color:#fff;background-color:#338fe580;cursor:default}.comment-quick-reply.hidden,.comment-quick-reply.reply-editor-editing .quick-reply-button{display:none}.comment-quick-reply.reply-editor-editing .quick-reply-editor{display:block}:root{--editor-font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Robot, "Helvetica Neue", Helvetica, Arial, sans-serif;--editor-comment-layer-bg-color:#ffffff;--comment-root-border-color: #eaeaea;--editor-comment-layer-active-border-color: #cecece;--editor-box-shadow: 0px 3px 20px rgba(0, 0, 0, .15);--wiz-editor-z-comment-group-active-top-before: 29;--editor-comment-quote-color: #909090;--editor-comment-quote-before-bg-color: #909090;--editor-comment-switch-button-width: 12px;--editor-comment-active-color: #FFC328;--editor-bg-color: #ffffff;--wiz-editor-z-comment-head:11;--text-button-color-hover:#5587f0;--editor-comment-username-color:#07142A;--editor-comment-avatar-size: 32px}.disabled-scroll{overflow:hidden}.editor-root .editor-content div[data-type=editor-block].text-block.comment span{border-bottom:2px solid #f8e6ab}.editor-root .editor-content div[data-type=editor-block].text-block.comment.active span{background-color:#f8e6ab}.editor-root .editor-content div[data-type=editor-block] span.text.comment{border-bottom:2px solid #f8e6ab}.editor-root .editor-content div[data-type=editor-block] span.text.comment.active{background-color:#f8e6ab}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-comment-button{all:unset;position:absolute;right:-28px;top:0;width:24px;height:24px;display:flex;align-items:center;justify-content:center;padding:0;border-radius:3px;color:#07142a;cursor:pointer}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-comment-button:hover{background:#eaeaea}.editor-web-comment-root{position:absolute;right:0;width:300px;top:0;bottom:0;transition:width .16s ease-in;will-change:width;font-family:var(--editor-font-family)}.editor-web-comment-root .comment-groups-container .comment-group-item-root{position:absolute;left:50%;right:0;width:290px;transform:translate(-50%);border-color:var(--editor-comment-layer-active-border-color);box-shadow:var(--editor-box-shadow);padding-bottom:18px}.editor-web-comment-root .comment-groups-container .comment-group-item-root:not(.no-animation){transition:top .2s ease-in,opacity .35s ease-in}.editor-web-comment-root .comment-groups-container .comment-group-item-root:before{content:"";position:absolute;left:0;right:0;height:6px;background-color:#fff;border-radius:2px 2px 0 0;z-index:var(--wiz-editor-z-comment-group-active-top-before)}.editor-web-comment-root .comment-groups-container .comment-group-item-root .comment-item-head{display:flex;align-items:center}.editor-web-comment-root .comment-groups-container .comment-group-item-root .comment-item-head .item-head-quote{font-size:12px;line-height:12px;height:12px;color:var(--editor-comment-quote-color);padding:18px 12px 10px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;width:100%;max-width:calc(100% - 80px)}.editor-web-comment-root .comment-groups-container .comment-group-item-root .comment-item-head .item-head-quote:before{content:"";display:block;width:2px;height:100%;background-color:var(--editor-comment-quote-before-bg-color);margin-right:6px;float:left;border-radius:10px}.editor-web-comment-root .comment-groups-container .comment-group-item-root .comment-item-head .item-head-switch{display:flex;align-items:center;height:22px;padding-top:6px;visibility:hidden}.editor-web-comment-root .comment-groups-container .comment-group-item-root .comment-item-head .item-head-switch .editor-text-button{padding:0;width:var(--editor-comment-switch-button-width);margin:3px 0;color:#606060}.editor-web-comment-root .comment-groups-container .comment-group-item-root .comment-item-head .item-head-switch .editor-text-button[data-button-id=switch-up]{margin-right:16px}.editor-web-comment-root .comment-groups-container .comment-group-item-root .comment-item-head .item-head-switch .editor-text-button:not(.disabled):hover{color:var(--text-button-color-hover)}.editor-web-comment-root .comment-groups-container .comment-group-item-root .comment-item-head .item-head-switch .editor-text-button.disabled{color:#60606080;cursor:not-allowed}.editor-web-comment-root .comment-groups-container .comment-group-item-root.active:before{background-color:var(--editor-comment-active-color)}.editor-web-comment-root .comment-groups-container .comment-group-item-root.active .item-head-switch{visibility:visible}.editor-mobile-comments-root{position:fixed;left:0;right:0;bottom:0;top:0;overflow:hidden;z-index:11}.editor-mobile-comments-root .mobile-comment-mask{position:absolute;left:0;right:0;bottom:0;top:0;background-color:#00000073}.editor-mobile-comments-root .mobile-comment-groups-container{position:absolute;width:100%;height:100vh;z-index:1;overflow:hidden}.editor-mobile-comments-root .mobile-comment-groups-container .mobile-comment-groups-scroll-container{padding:0 12px}.editor-mobile-comments-root .mobile-comment-pull-info-container{position:absolute;right:0;left:0;bottom:100px;z-index:2;text-align:center;display:none}.editor-mobile-comments-root .mobile-comment-pull-info-container .mobile-comment-pull-info{display:inline-block;padding:12px;border-radius:36px;margin:0 auto;background-color:#000c;color:#fff;font-size:12px;opacity:0;transition:opacity .25s cubic-bezier(.65,.05,.36,1)}.editor-mobile-comments-root .mobile-comment-pull-info-container.active{display:block}.editor-mobile-comments-root .mobile-comment-pull-info-container.active .mobile-comment-pull-info{opacity:1}.editor-mobile-comments-root .mobile-group-item-root{margin:0 auto;width:100%;height:100vh;overflow:hidden}.editor-mobile-comments-root .mobile-group-item-root .mobile-group-item{min-height:calc(100vh + 1px);padding-bottom:50px}.editor-mobile-comments-root .mobile-group-item-root .mobile-group-item-space{height:50vh}.editor-mobile-comments-root .mobile-group-item-root .mobile-group-item-abstract{background-color:var(--editor-comment-layer-bg-color);padding:12px;color:#999;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.editor-mini-comment-root{position:absolute;right:0;top:0;bottom:0;width:48px;border-left:1px solid #f0f0f0;transition:width .16s ease-in;will-change:width;font-family:var(--editor-font-family);border:none;background-color:transparent;z-index:11}.editor-mini-comment-root .comment-groups-container{width:100%;height:100%}.editor-mini-comment-root .comment-groups-container .mini-group-item{position:absolute;top:0;left:50%;margin-left:-10px;transition:top .2s cubic-bezier(.65,.05,.36,1)}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] [data-box-type=file] span[data-type=box-content]{margin:0}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] [data-box-type=file] span[data-type=box-content] span.file-icon{display:inline-flex;vertical-align:text-bottom}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] [data-box-type=file] span[data-type=box-content] .file-name{color:var(--primary-color);padding:0;border-radius:12px;margin-right:4px;white-space:wrap;word-break:break-all;cursor:pointer}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office]{justify-content:start}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office].hover [data-type=block-content]{border-radius:3px}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office] [data-type=block-content]{width:unset;height:48px;cursor:pointer}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office] [data-type=block-content] .card-root{display:flex;align-items:center;min-width:360px;max-width:100%;background-color:#f5f6f7;border-radius:3px}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office] [data-type=block-content] .card-root:before{border-radius:3px}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office] [data-type=block-content] .card-root .file-details{display:flex;flex-direction:column;justify-content:center;font-size:14px;flex-grow:1}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office] [data-type=block-content] .card-root .file-details .file-name{color:#1f2329}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office] [data-type=block-content] .card-root .file-details .file-size{color:#646a73;font-size:12px;margin-top:2px}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office] [data-type=block-content] .card-root .file-actions button{width:34px;height:34px;background-color:#fff;border:1px solid #dee0e3;border-radius:50%;margin:0 8px;padding:0;background-repeat:no-repeat;background-position:50%;cursor:pointer;display:flex;align-items:center;justify-content:center;flex-shrink:0}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office] [data-type=block-content] .card-root .file-actions button svg{width:16px;height:16px}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office] [data-type=block-content] .card-root .file-icon{display:flex;width:36px;height:36px;margin:6px 6px 6px 12px}div.editor-root div.editor-content div[data-type=editor-container] div.embed-block[data-type=editor-block][data-embed-type=office] [data-type=block-content] .card-root .file-icon>svg{width:100%;height:100%}:root{--hover-color: #40a9ff}.flex-column-center,.embed-block[data-embed-type=video]>div[data-type=block-content] .media-empty,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-empty,.embed-block[data-embed-type=video]>div[data-type=block-content] .media-error,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-error{display:flex;justify-content:center;align-items:center;flex-flow:column}.common{width:400px;height:180px;background-color:#fafafa;border:1px dashed #d9d9d9;border-radius:2px;transition:border-color .3s}.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-empty,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-error{height:200px}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-empty,.embed-block[data-embed-type=video]>div[data-type=block-content] .media-error{height:400px}.embed-block[data-embed-type=video].locked-by-self>[data-type=block-content]:after,.embed-block[data-embed-type=video].locked-by-others>[data-type=block-content]:after,.embed-block[data-embed-type=audio].locked-by-self>[data-type=block-content]:after,.embed-block[data-embed-type=audio].locked-by-others>[data-type=block-content]:after{display:none}.embed-block[data-embed-type=video].locked-by-self>[data-type=block-content] .video-container,.embed-block[data-embed-type=video].locked-by-self>[data-type=block-content] .audio-container,.embed-block[data-embed-type=video].locked-by-others>[data-type=block-content] .video-container,.embed-block[data-embed-type=video].locked-by-others>[data-type=block-content] .audio-container,.embed-block[data-embed-type=audio].locked-by-self>[data-type=block-content] .video-container,.embed-block[data-embed-type=audio].locked-by-self>[data-type=block-content] .audio-container,.embed-block[data-embed-type=audio].locked-by-others>[data-type=block-content] .video-container,.embed-block[data-embed-type=audio].locked-by-others>[data-type=block-content] .audio-container{position:relative}.embed-block[data-embed-type=video].locked-by-self>[data-type=block-content] .video-container:after,.embed-block[data-embed-type=video].locked-by-self>[data-type=block-content] .audio-container:after,.embed-block[data-embed-type=video].locked-by-others>[data-type=block-content] .video-container:after,.embed-block[data-embed-type=video].locked-by-others>[data-type=block-content] .audio-container:after,.embed-block[data-embed-type=audio].locked-by-self>[data-type=block-content] .video-container:after,.embed-block[data-embed-type=audio].locked-by-self>[data-type=block-content] .audio-container:after,.embed-block[data-embed-type=audio].locked-by-others>[data-type=block-content] .video-container:after,.embed-block[data-embed-type=audio].locked-by-others>[data-type=block-content] .audio-container:after{content:" ";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;z-index:1;background-color:#303030;opacity:.1}.embed-block[data-embed-type=video].hover>div[data-type=block-content],.embed-block[data-embed-type=audio].hover>div[data-type=block-content]{outline:none!important}.embed-block[data-embed-type=video]>div[data-type=block-content],.embed-block[data-embed-type=audio]>div[data-type=block-content]{justify-content:center;max-width:100%}.embed-block[data-embed-type=video]>div[data-type=block-content] .media,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media{width:100%;display:flex;justify-content:center}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-progress,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-progress{position:relative;max-width:100%}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-progress audio,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-progress audio{display:block;width:100%}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-progress video,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-progress video{display:block;max-width:100%}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-progress .uploading-progress-mask,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-progress .uploading-progress-mask{position:absolute;top:0;left:0;right:0;bottom:0;background-color:#303030;opacity:.8;display:flex;align-items:center;justify-content:center}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-progress .uploading-progress-mask .uploading-progress-bar,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-progress .uploading-progress-mask .uploading-progress-bar{width:75%;height:6px;border-radius:3px;display:flex;background-color:#fff;overflow:hidden}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-progress .uploading-progress-mask .uploading-progress-bar .uploading-progress-bar-value,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-progress .uploading-progress-mask .uploading-progress-bar .uploading-progress-bar-value{background-color:#338fe5}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-error,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-error{width:100%;background:#F8F8F8;outline:1px solid #DEDEDE;border-radius:3px}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-error-icon svg,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-error-icon svg{width:48px;height:48px;color:#c7c7c7}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-error .line-1,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-error .line-1{margin-top:10px;font-size:18px;text-align:center;color:#303030}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-error .line-2,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-error .line-2{margin-top:5px;font-size:14px;text-align:center;color:#606060}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-error a,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-error a{margin-left:4px;color:#338fe5;cursor:pointer;text-decoration:none}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-empty,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-empty{width:100%;background:#FFFFFF;outline:1px solid #DEDEDE;border-radius:3px}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-empty svg,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-empty svg{width:48px;height:48px;color:#c7c7c7}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-element,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-element{width:100%;display:flex;justify-content:center}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-element .video-container video,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-element .video-container video{display:block;min-width:50px;max-width:100%}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-element .audio-container,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-element .audio-container{width:100%}.embed-block[data-embed-type=video]>div[data-type=block-content] .media-element .audio-container audio,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-element .audio-container audio{display:block;width:100%}:root{--editor-version-select-bg-color: green;--editor-version-button-border: black;--editor-bg-color: #ffffff;--editor-version-list-bg-color: #f5f8fb;--editor-version-select-bg-color: #dae6f2}.version-dialog{display:flex;background-color:var(--editor-bg-color);width:100%;height:100%;color:var(--editor-color);font-family:var(--font-family)}.version-dialog-note-viewer{flex:1;display:flex;flex-direction:column;width:0;padding:16px 32px 32px 16px}.version-dialog-note-viewer .dialog-button-text{margin-top:1px;margin-left:-4px}.version-dialog-action-container{height:48px;display:flex;align-items:center;justify-content:space-between;padding-bottom:16px;box-sizing:border-box}.version-dialog-note-viewer .dialog-text-button{outline:none;background:transparent;border:none;display:flex;align-items:center;color:var(--editor-color);font-size:16px;font-weight:500;padding:4px 0;cursor:pointer}.dialog-text-button .dialog-button-icon{margin-right:0;width:24px;height:24px}.dialog-text-button .dialog-button-icon svg{fill:currentColor}.dialog-version-button{outline:none;background:transparent;border:1px solid var(--editor-version-button-border);min-width:88px;height:32px;color:var(--editor-color);font-weight:500;padding:4px 0;border-radius:4px;font-size:16px;cursor:pointer}.dialog-version-button[disabled]{color:#7084a4;cursor:not-allowed;pointer-events:unset;background-color:#cfd6e1}.version-dialog-versions-list{width:320px;background:var(--editor-version-list-bg-color);overflow-y:auto;padding:32px 8px}.version-dialog-list-header{padding:0 12px;font-size:16px;display:flex;align-items:center;margin-top:16px;margin-bottom:12px}.dialog-version-list-item{padding:4px 12px;border-radius:8px;cursor:pointer}.dialog-version-list-item.child{padding-left:32px}.dialog-version-list-item.active{background-color:var(--editor-version-select-bg-color)}.dialog-version-list-item:not(.active):hover{background:rgba(112,132,164,.1)}.dialog-version-list-item-title{display:flex;align-items:center;margin-top:16px;margin-bottom:12px}.dialog-version-list-item-title .dialog-version-list-item-date{font-size:14px}.dialog-version-list-item-now-ver{border-radius:3px;background:#909090;color:#fff;padding:3px 4px;font-size:12px;line-height:14px;margin-left:8px}.dialog-version-list-item-authors{list-style:none;margin:0;padding-left:0;font-size:14px}.dialog-version-list-item-author{display:flex;align-items:center;margin-right:8px;margin-top:8px;margin-bottom:12px}.dialog-version-list-item-mark-author{width:10px;height:10px;border-radius:5px;margin-right:8px;margin-top:1px}.version-dialog-editor{flex-grow:1;overflow-y:auto}.editor-main.history .root-container .editor-block .text-element .inline-plugin.editor-box-loading{display:none}.version-dialog .dialog-version-item-from-container{color:#909090;font-size:12px;line-height:1.5em;margin-bottom:4px}.editor-root.history .history-inserted-block[data-type=editor-block]:not(.table-block,.list-block,.text-block) [data-type=block-content]{border:4px solid var(--op-selected-color)}.editor-root.history .history-inserted-block[data-type=editor-block]:not(.table-block,.list-block,.text-block){position:relative}.editor-root.history .history-inserted-block[data-type=editor-block]:not(.table-block,.list-block,.text-block):hover:after{content:attr(data-op-description);position:absolute;top:-26px;left:0;line-height:24px;background-color:var(--op-color);min-width:20px;opacity:1;color:#fff;padding:0 8px;z-index:var(--wiz-editor-z-history-op-description, 10);font-size:14px;font-weight:400;white-space:nowrap;border-radius:3px}.editor-root.history .history-inserted-block[data-type=editor-block].table-block table{border:4px solid var(--op-selected-color)}.editor-root.history .history-inserted-block[data-type=editor-block].table-block table .child{pointer-events:none}.editor-root.history .history-inserted-block[data-type=editor-block].table-block{position:relative}.editor-root.history .history-inserted-block[data-type=editor-block].table-block:hover:after{content:attr(data-op-description);position:absolute;top:-26px;left:0;line-height:24px;background-color:var(--op-color);min-width:20px;opacity:1;color:#fff;padding:0 8px;z-index:var(--wiz-editor-z-history-op-description, 10);font-size:14px;font-weight:400;white-space:nowrap;border-radius:3px}.editor-root.history .history-deleted-block[data-type=editor-block]:is(.code-block,.table-block,.embed-block) [data-type=block-content]{border:4px solid var(--op-selected-color)}.editor-root.history .history-deleted-block[data-type=editor-block]:is(.code-block,.table-block,.embed-block) [data-type=block-content]{position:relative}.editor-root.history .history-deleted-block[data-type=editor-block]:is(.code-block,.table-block,.embed-block) [data-type=block-content]:after,.editor-root.history .history-deleted-block[data-type=editor-block]:is(.code-block,.table-block,.embed-block) [data-type=block-content]:before{content:" ";position:absolute;display:flex;z-index:var(--wiz-editor-z-history-delete-marker);color:var(--op-color);justify-items:center;align-items:center;justify-content:center;align-content:center;pointer-events:none;overflow:visible;max-width:100%;max-height:100%;left:calc(50% - 16px);top:calc(50% - 2px);width:32px;height:4px;background-color:var(--op-color);transform:rotate(45deg);opacity:1}.editor-root.history .history-deleted-block[data-type=editor-block]:is(.code-block,.table-block,.embed-block) [data-type=block-content]:before{transform:rotate(135deg)}.editor-root.history .history-deleted-block[data-type=editor-block]:is(.code-block,.table-block,.embed-block){position:relative}.editor-root.history .history-deleted-block[data-type=editor-block]:is(.code-block,.table-block,.embed-block):hover:after{content:attr(data-op-description);position:absolute;top:-26px;left:0;line-height:24px;background-color:var(--op-color);min-width:20px;opacity:1;color:#fff;padding:0 8px;z-index:var(--wiz-editor-z-history-op-description, 10);font-size:14px;font-weight:400;white-space:nowrap;border-radius:3px}.editor-root.history .history-inserted-text{line-height:revert!important;background-color:var(--op-selected-color)}.editor-root.history .history-inserted-text{position:relative}.editor-root.history .history-inserted-text:hover:after{content:attr(data-op-description);position:absolute;top:-26px;left:0;line-height:24px;background-color:var(--op-color);min-width:20px;opacity:1;color:#fff;padding:0 8px;z-index:var(--wiz-editor-z-history-op-description, 10);font-size:14px;font-weight:400;white-space:nowrap;border-radius:3px}.editor-root.history .history-deleted-box{background-color:var(--op-selected-color);text-decoration:line-through}.editor-root.history .history-deleted-box{position:relative}.editor-root.history .history-deleted-box:hover:after{content:attr(data-op-description);position:absolute;top:-26px;left:0;line-height:24px;background-color:var(--op-color);min-width:20px;opacity:1;color:#fff;padding:0 8px;z-index:var(--wiz-editor-z-history-op-description, 10);font-size:14px;font-weight:400;white-space:nowrap;border-radius:3px}.editor-root.history [data-box-type=history-deleted-box]>span[data-type=box-content]{border:none!important;margin:0!important}.editor-root.history [data-type=editor-block].table-block div[data-type=block-content]{overflow-x:revert}.dialog-root{position:fixed;left:0;top:0;bottom:0;right:0;background-color:#639;z-index:1}.editor-root .editor-content div[data-type=editor-block].heading-collapsed div[data-type=block-tools] .block-helper .heading-collapse-button svg{transform:rotate(270deg)}.editor-root .editor-content div[data-type=editor-block].focused div[data-type=block-tools] .block-helper .heading-marker,.editor-root .editor-content div[data-type=editor-block].highlighted div[data-type=block-tools] .block-helper .heading-marker{display:none}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .heading-marker,.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .heading-collapse-button{width:24px;height:24px;cursor:grab;margin:0;padding:0;display:flex;align-items:center;justify-content:center;background-color:transparent;border:none;border-radius:3px}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .heading-marker:hover,.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .heading-collapse-button:hover{background-color:var(--selected-color)}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .heading-marker svg,.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .heading-collapse-button svg{transform:rotate(360deg);transition:transform .2s linear}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .heading-marker svg,.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .heading-collapse-button svg{width:16px;height:16px}.editor-root .editor-content div[data-type=editor-block] div[data-type=block-tools] .block-helper .heading-marker:hover{background-color:transparent}.embed-block div[data-type=block-content] .editor-toc-container{display:block;width:100%;background-color:#f0f0f0;padding:20px}.embed-block div[data-type=block-content] .editor-toc-container.loading{margin:0;min-height:100px}.embed-block div[data-type=block-content] .editor-toc-container .toc-node+.toc-node{margin-top:10px}.embed-block div[data-type=block-content] .editor-toc-container .toc-node .toc-text{cursor:pointer;color:var(--primary-color)}.embed-block div[data-type=block-content] .editor-toc-container .toc-node .toc-children{margin-top:10px;padding-left:20px}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] [data-box-type=mention] span[data-type=box-content]{margin:0}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] [data-box-type=mention] span[data-type=box-content] .mention-name{color:var(--primary-color);padding:0;border-radius:12px;margin-left:4px;margin-right:4px;white-space:wrap;word-break:break-all;cursor:pointer}[data-command-bar-id=editor-mention] .editor-command-bar.menu .command-item.menu-item .menu-item-icon{width:24px;height:24px;border-radius:50%;overflow:hidden}[data-command-bar-id=editor-mention] .editor-command-bar.menu .command-item.menu-item .menu-item-icon img{width:100%;height:100%}.editor-main .editor-templates{position:absolute;bottom:70px;height:240px;width:min(800px,100%)}.editor-main .editor-templates .editor-templates-title{color:#909090;margin-bottom:0;font-size:14px;margin-left:20px}.editor-main .editor-templates .editor-templates-cards{display:flex;margin-left:4px}.editor-main .editor-templates .editor-templates-cards .editor-template-card{box-sizing:border-box;display:flex;flex-direction:column;align-items:center;justify-content:center;margin-left:0;margin-right:-12px;cursor:pointer;width:172px;height:220px;background-image:url(data:image/svg+xml;base64,Cjxzdmcgd2lkdGg9IjE0MCIgaGVpZ2h0PSIxODAiIHZpZXdCb3g9IjAgMCAxNDAgMTgwIiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNMC41IDNDMC41IDEuNjE5MjkgMS42MTkyOSAwLjUgMyAwLjVIMTM3QzEzOC4zODEgMC41IDEzOS41IDEuNjE5MjkgMTM5LjUgM1YxNzdDMTM5LjUgMTc4LjM4MSAxMzguMzgxIDE3OS41IDEzNyAxNzkuNUgzQzEuNjE5MjkgMTc5LjUgMC41IDE3OC4zODEgMC41IDE3N1YzWiIgZmlsbD0id2hpdGUiIHN0cm9rZT0iI0U4RThFOCIvPgo8L3N2Zz4K);background-position-x:16px;background-position-y:16px;background-repeat:no-repeat;padding:16px 16px 32px;flex-shrink:0}.editor-main .editor-templates .editor-templates-cards .editor-template-card:hover{background-image:url(data:image/svg+xml;base64,Cjxzdmcgd2lkdGg9IjE3MiIgaGVpZ2h0PSIyMTIiIHZpZXdCb3g9IjAgMCAxNzIgMjEyIiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8ZyBmaWx0ZXI9InVybCgjZmlsdGVyMF9kZF83MTlfMTIzNDMpIj4KPHBhdGggZD0iTTE2IDExQzE2IDkuMzQzMTQgMTcuMzQzMSA4IDE5IDhIMTUzQzE1NC42NTcgOCAxNTYgOS4zNDMxNSAxNTYgMTFWMTg1QzE1NiAxODYuNjU3IDE1NC42NTcgMTg4IDE1MyAxODhIMTlDMTcuMzQzMSAxODggMTYgMTg2LjY1NyAxNiAxODVWMTFaIiBmaWxsPSJ3aGl0ZSIvPgo8cGF0aCBkPSJNMTkgOC41SDE1M0MxNTQuMzgxIDguNSAxNTUuNSA5LjYxOTI5IDE1NS41IDExVjE4NUMxNTUuNSAxODYuMzgxIDE1NC4zODEgMTg3LjUgMTUzIDE4Ny41SDE5QzE3LjYxOTMgMTg3LjUgMTYuNSAxODYuMzgxIDE2LjUgMTg1VjExQzE2LjUgOS42MTkyOSAxNy42MTkzIDguNSAxOSA4LjVaIiBzdHJva2U9IiNFOEU4RTgiLz4KPC9nPgo8ZGVmcz4KPGZpbHRlciBpZD0iZmlsdGVyMF9kZF83MTlfMTIzNDMiIHg9IjAiIHk9IjAiIHdpZHRoPSIxNzIiIGhlaWdodD0iMjEyIiBmaWx0ZXJVbml0cz0idXNlclNwYWNlT25Vc2UiIGNvbG9yLWludGVycG9sYXRpb24tZmlsdGVycz0ic1JHQiI+CjxmZUZsb29kIGZsb29kLW9wYWNpdHk9IjAiIHJlc3VsdD0iQmFja2dyb3VuZEltYWdlRml4Ii8+CjxmZUNvbG9yTWF0cml4IGluPSJTb3VyY2VBbHBoYSIgdHlwZT0ibWF0cml4IiB2YWx1ZXM9IjAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDEyNyAwIiByZXN1bHQ9ImhhcmRBbHBoYSIvPgo8ZmVPZmZzZXQgZHk9IjgiLz4KPGZlR2F1c3NpYW5CbHVyIHN0ZERldmlhdGlvbj0iOCIvPgo8ZmVDb2xvck1hdHJpeCB0eXBlPSJtYXRyaXgiIHZhbHVlcz0iMCAwIDAgMCAwLjE4ODIzNSAwIDAgMCAwIDAuMTg4MjM1IDAgMCAwIDAgMC4xODgyMzUgMCAwIDAgMC4xNSAwIi8+CjxmZUJsZW5kIG1vZGU9Im5vcm1hbCIgaW4yPSJCYWNrZ3JvdW5kSW1hZ2VGaXgiIHJlc3VsdD0iZWZmZWN0MV9kcm9wU2hhZG93XzcxOV8xMjM0MyIvPgo8ZmVDb2xvck1hdHJpeCBpbj0iU291cmNlQWxwaGEiIHR5cGU9Im1hdHJpeCIgdmFsdWVzPSIwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAxMjcgMCIgcmVzdWx0PSJoYXJkQWxwaGEiLz4KPGZlT2Zmc2V0Lz4KPGZlR2F1c3NpYW5CbHVyIHN0ZERldmlhdGlvbj0iMC41Ii8+CjxmZUNvbG9yTWF0cml4IHR5cGU9Im1hdHJpeCIgdmFsdWVzPSIwIDAgMCAwIDAuMTg4MjM1IDAgMCAwIDAgMC4xODgyMzUgMCAwIDAgMCAwLjE4ODIzNSAwIDAgMCAwLjIgMCIvPgo8ZmVCbGVuZCBtb2RlPSJub3JtYWwiIGluMj0iZWZmZWN0MV9kcm9wU2hhZG93XzcxOV8xMjM0MyIgcmVzdWx0PSJlZmZlY3QyX2Ryb3BTaGFkb3dfNzE5XzEyMzQzIi8+CjxmZUJsZW5kIG1vZGU9Im5vcm1hbCIgaW49IlNvdXJjZUdyYXBoaWMiIGluMj0iZWZmZWN0Ml9kcm9wU2hhZG93XzcxOV8xMjM0MyIgcmVzdWx0PSJzaGFwZSIvPgo8L2ZpbHRlcj4KPC9kZWZzPgo8L3N2Zz4K);background-position-x:0px;background-position-y:8px;border:none}.editor-main .editor-templates .editor-templates-cards .editor-template-card.more{background-image:url(data:image/svg+xml;base64,Cjxzdmcgd2lkdGg9IjE1NiIgaGVpZ2h0PSIxOTMiIHZpZXdCb3g9IjAgMCAxNTYgMTkzIiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cmVjdCB4PSIwLjU0MTY3NSIgeT0iMTMuMjE1NyIgd2lkdGg9IjEzOSIgaGVpZ2h0PSIxNzkiIHJ4PSIyLjUiIHRyYW5zZm9ybT0icm90YXRlKC01IDAuNTQxNjc1IDEzLjIxNTcpIiBmaWxsPSJ3aGl0ZSIgc3Ryb2tlPSIjRThFOEU4Ii8+CjxyZWN0IHg9IjE0LjA2NzciIHk9IjcuMTg4MDQiIHdpZHRoPSIxMzkiIGhlaWdodD0iMTc5IiByeD0iMi41IiB0cmFuc2Zvcm09InJvdGF0ZSgyIDE0LjA2NzcgNy4xODgwNCkiIGZpbGw9IndoaXRlIiBzdHJva2U9IiNFOEU4RTgiLz4KPHJlY3QgeD0iNi41IiB5PSI3LjUiIHdpZHRoPSIxMzkiIGhlaWdodD0iMTc5IiByeD0iMi41IiBmaWxsPSJ3aGl0ZSIgc3Ryb2tlPSIjRThFOEU4Ii8+Cjwvc3ZnPgo=);background-position-x:16px;background-position-y:8px;padding-left:24px;margin-left:-5px}.editor-main .editor-templates .editor-templates-cards .editor-template-card.more:hover{width:188px;background-image:url(data:image/svg+xml;base64,Cjxzdmcgd2lkdGg9IjE4NyIgaGVpZ2h0PSIyMjQiIHZpZXdCb3g9IjAgMCAxODcgMjI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8ZyBmaWx0ZXI9InVybCgjZmlsdGVyMF9kZF85MTlfMTI3NzYpIj4KPHJlY3QgeD0iMTYuNTQxNyIgeT0iMjEuMjE1NyIgd2lkdGg9IjEzOSIgaGVpZ2h0PSIxNzkiIHJ4PSIyLjUiIHRyYW5zZm9ybT0icm90YXRlKC01IDE2LjU0MTcgMjEuMjE1NykiIGZpbGw9IndoaXRlIiBzdHJva2U9IiNFOEU4RTgiLz4KPHJlY3QgeD0iMzAuMDY3NyIgeT0iMTUuMTg4IiB3aWR0aD0iMTM5IiBoZWlnaHQ9IjE3OSIgcng9IjIuNSIgdHJhbnNmb3JtPSJyb3RhdGUoMiAzMC4wNjc3IDE1LjE4OCkiIGZpbGw9IndoaXRlIiBzdHJva2U9IiNFOEU4RTgiLz4KPHJlY3QgeD0iMjIuNSIgeT0iMTUuNSIgd2lkdGg9IjEzOSIgaGVpZ2h0PSIxNzkiIHJ4PSIyLjUiIGZpbGw9IndoaXRlIiBzdHJva2U9IiNFOEU4RTgiLz4KPC9nPgo8ZGVmcz4KPGZpbHRlciBpZD0iZmlsdGVyMF9kZF85MTlfMTI3NzYiIHg9IjAiIHk9IjAuNTU5NDQ4IiB3aWR0aD0iMTg3LjE1NSIgaGVpZ2h0PSIyMjMuNTE3IiBmaWx0ZXJVbml0cz0idXNlclNwYWNlT25Vc2UiIGNvbG9yLWludGVycG9sYXRpb24tZmlsdGVycz0ic1JHQiI+CjxmZUZsb29kIGZsb29kLW9wYWNpdHk9IjAiIHJlc3VsdD0iQmFja2dyb3VuZEltYWdlRml4Ii8+CjxmZUNvbG9yTWF0cml4IGluPSJTb3VyY2VBbHBoYSIgdHlwZT0ibWF0cml4IiB2YWx1ZXM9IjAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDEyNyAwIiByZXN1bHQ9ImhhcmRBbHBoYSIvPgo8ZmVPZmZzZXQgZHk9IjgiLz4KPGZlR2F1c3NpYW5CbHVyIHN0ZERldmlhdGlvbj0iOCIvPgo8ZmVDb2xvck1hdHJpeCB0eXBlPSJtYXRyaXgiIHZhbHVlcz0iMCAwIDAgMCAwLjE4ODIzNSAwIDAgMCAwIDAuMTg4MjM1IDAgMCAwIDAgMC4xODgyMzUgMCAwIDAgMC4xNSAwIi8+CjxmZUJsZW5kIG1vZGU9Im5vcm1hbCIgaW4yPSJCYWNrZ3JvdW5kSW1hZ2VGaXgiIHJlc3VsdD0iZWZmZWN0MV9kcm9wU2hhZG93XzkxOV8xMjc3NiIvPgo8ZmVDb2xvck1hdHJpeCBpbj0iU291cmNlQWxwaGEiIHR5cGU9Im1hdHJpeCIgdmFsdWVzPSIwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAxMjcgMCIgcmVzdWx0PSJoYXJkQWxwaGEiLz4KPGZlT2Zmc2V0Lz4KPGZlR2F1c3NpYW5CbHVyIHN0ZERldmlhdGlvbj0iMC41Ii8+CjxmZUNvbG9yTWF0cml4IHR5cGU9Im1hdHJpeCIgdmFsdWVzPSIwIDAgMCAwIDAuMTg4MjM1IDAgMCAwIDAgMC4xODgyMzUgMCAwIDAgMCAwLjE4ODIzNSAwIDAgMCAwLjIgMCIvPgo8ZmVCbGVuZCBtb2RlPSJub3JtYWwiIGluMj0iZWZmZWN0MV9kcm9wU2hhZG93XzkxOV8xMjc3NiIgcmVzdWx0PSJlZmZlY3QyX2Ryb3BTaGFkb3dfOTE5XzEyNzc2Ii8+CjxmZUJsZW5kIG1vZGU9Im5vcm1hbCIgaW49IlNvdXJjZUdyYXBoaWMiIGluMj0iZWZmZWN0Ml9kcm9wU2hhZG93XzkxOV8xMjc3NiIgcmVzdWx0PSJzaGFwZSIvPgo8L2ZpbHRlcj4KPC9kZWZzPgo8L3N2Zz4K);background-position-x:0px;background-position-y:0px;padding-left:24px;padding-right:32px}.editor-main .editor-templates .editor-templates-cards .editor-template-card .editor-template-thumb-container{flex-grow:1;position:relative;margin:20px 15px 0;overflow:hidden}.editor-main .editor-templates .editor-templates-cards .editor-template-card.starred .editor-template-thumb-container:before{position:absolute;top:0px;right:0px;width:16px;height:16px;background-image:url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTciIGhlaWdodD0iMTYiIHZpZXdCb3g9IjAgMCAxNyAxNiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0iTTE1Ljk0MzYgNS45NjQzMkMxNS44MDU0IDUuNTUxMDEgMTUuNDQ5NSA1LjI1IDE1LjAyMjggNS4xODUwOUwxMC44NTc4IDQuNTQ1MjdMOS4wNDg1MiAwLjY2NjcyNUM4Ljg1ODExIDAuMjU5NzEgOC40NDk5OSAwIDguMDAxNzggMEM3LjU1Mzc2IDAgNy4xNDU0NCAwLjI1OTcxIDYuOTU1MjQgMC42NjY3MjVMNS4xNDU3NyA0LjU0NTI3TDAuOTgwOTE0IDUuMTg1MDlDMC41NTI2OTggNS4yNSAwLjE5ODE4NSA1LjU1MTAxIDAuMDYwMDc5NiA1Ljk2NDMyQy0wLjA3ODAyNTUgNi4zNzc3NCAwLjAyNjI3ODQgNi44MzM3NiAwLjMyODU5IDcuMTQ0MjdMMy4zNzk1IDEwLjI4OTZMMi42NzE5OCAxNC42NTExQzIuNjAxNDcgMTUuMDkgMi43ODU1OCAxNS41MzAyIDMuMTQ2MiAxNS43ODgzQzMuMzQ1NyAxNS45MjkyIDMuNTc5MTEgMTYuMDAwNiAzLjgxMjIyIDE2LjAwMDZDNC4wMDQwMyAxNi4wMDA2IDQuMTk3NDMgMTUuOTUxNSA0LjM3MDk0IDE1Ljg1NjVMOC4wMDE3OCAxMy45MDIyTDExLjYzMjggMTUuODU2NUMxMS44MDYyIDE1Ljk1MTUgMTEuOTk5NSAxNi4wMDA2IDEyLjE5MTQgMTYuMDAwNkMxMi40MjQ2IDE2LjAwMDYgMTIuNjU3OSAxNS45MjkyIDEyLjg1NzUgMTUuNzg4M0MxMy4yMTgxIDE1LjUzMDIgMTMuNDAyMiAxNS4wOSAxMy4zMzAyIDE0LjY1MTFMMTIuNjIyNyAxMC4yODk2TDE1LjY3NTEgNy4xNDQyN0MxNS45Nzc0IDYuODMzNzYgMTYuMDgwMiA2LjM3Nzc0IDE1Ljk0MzYgNS45NjQzMloiIGZpbGw9IiNGRkI4MDYiLz4KPC9zdmc+Cg==);content:""}.editor-main .editor-templates .editor-templates-cards .editor-template-card .editor-template-thumb-container img{max-width:100%}.editor-main .editor-templates .editor-templates-cards .editor-template-card.more .editor-template-thumb-container{margin-right:5px}.editor-main .editor-templates .editor-templates-cards .editor-template-card .editor-template-name{height:40px;padding-left:10px;padding-right:10px;width:100%;display:flex;align-items:center;color:#303030;font-weight:500;flex-shrink:0}.editor-main .editor-templates .editor-templates-cards .editor-template-card.customized .editor-template-name:before{content:var(--editor-template-customized-text);height:16px;border-radius:3px;background-color:#448aff;color:#fff;font-size:11px;font-weight:500;line-height:16px;padding:0 4px;margin-right:4px;white-space:nowrap}.editor-main .editor-templates .editor-templates-cards .editor-template-card:hover .editor-template-name{color:#338fe5}.editor-main .editor-templates .editor-templates-cards .editor-template-card.more .editor-template-name{padding-right:5px}.editor-main .editor-templates .editor-templates-cards .editor-template-card .editor-template-name span{display:block;width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.editor-main .editor-templates .editor-templates-cards .editor-template-card.more .editor-template-name span{padding-left:0;text-align:center}.editor-main .editor-templates .editor-templates-cards .editor-template-card.new .editor-template-thumb-container{flex-grow:unset;margin-top:0;padding-top:25px}.editor-main .editor-templates .editor-templates-cards .editor-template-card.new .editor-template-name span{padding-left:0;text-align:center}.editor-main .editor-templates .editor-templates-cards .editor-template-card.more .editor-template-thumb-container,.editor-main .editor-templates .editor-templates-cards .editor-template-card.new .editor-template-thumb-container{display:flex;align-items:center;justify-content:center}.editor-main .editor-templates .editor-templates-cards .editor-template-card.new .editor-template-thumb-container img{width:32px;height:32px}.editor-root .editor-templates{position:fixed;bottom:70px;height:256px;width:min(800px,100%);width:auto;max-width:100%;padding-left:60px;padding-right:44px;overflow:hidden}.editor-root .editor-templates .editor-templates-cards{margin-left:-16px}.editor-root .editor-templates .editor-templates-title{color:#909090;font-size:14px;margin-left:0;margin-bottom:20px;line-height:19.6px}.editor-root .editor-templates .editor-templates-cards{display:flex;margin-left:0}.editor-root .editor-templates .editor-templates-cards .editor-template-card{box-sizing:border-box;display:flex;flex-direction:column;align-items:center;justify-content:center;cursor:pointer;flex-shrink:0;height:192px;width:188px;background:none;border:1px solid #e8e8e8;border-radius:3px;margin:0 0 0 15px;padding:0;align-items:revert}.editor-root .editor-templates .editor-templates-cards .editor-template-card:first-child{margin-left:0}.editor-root .editor-templates .editor-templates-cards .editor-template-card:hover{box-shadow:0 0 1px #30303033,0 8px 16px #30303026}.editor-root .editor-templates .editor-templates-cards .editor-template-card:hover>.editor-template-name{color:#338fe5}.editor-root .editor-templates .editor-templates-cards .editor-template-card .editor-template-name{border-top:1px solid #dedede;padding-left:20px;padding-right:20px;flex:0 0 50px;font-size:14px;line-height:22px;color:#303030}.editor-root .editor-templates .editor-templates-cards .editor-template-card:hover{width:188px;background-image:url(data:image/svg+xml;base64,Cjxzdmcgd2lkdGg9IjE4NyIgaGVpZ2h0PSIyMjQiIHZpZXdCb3g9IjAgMCAxODcgMjI0IiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8ZyBmaWx0ZXI9InVybCgjZmlsdGVyMF9kZF85MTlfMTI3NzYpIj4KPHJlY3QgeD0iMTYuNTQxNyIgeT0iMjEuMjE1NyIgd2lkdGg9IjEzOSIgaGVpZ2h0PSIxNzkiIHJ4PSIyLjUiIHRyYW5zZm9ybT0icm90YXRlKC01IDE2LjU0MTcgMjEuMjE1NykiIGZpbGw9IndoaXRlIiBzdHJva2U9IiNFOEU4RTgiLz4KPHJlY3QgeD0iMzAuMDY3NyIgeT0iMTUuMTg4IiB3aWR0aD0iMTM5IiBoZWlnaHQ9IjE3OSIgcng9IjIuNSIgdHJhbnNmb3JtPSJyb3RhdGUoMiAzMC4wNjc3IDE1LjE4OCkiIGZpbGw9IndoaXRlIiBzdHJva2U9IiNFOEU4RTgiLz4KPHJlY3QgeD0iMjIuNSIgeT0iMTUuNSIgd2lkdGg9IjEzOSIgaGVpZ2h0PSIxNzkiIHJ4PSIyLjUiIGZpbGw9IndoaXRlIiBzdHJva2U9IiNFOEU4RTgiLz4KPC9nPgo8ZGVmcz4KPGZpbHRlciBpZD0iZmlsdGVyMF9kZF85MTlfMTI3NzYiIHg9IjAiIHk9IjAuNTU5NDQ4IiB3aWR0aD0iMTg3LjE1NSIgaGVpZ2h0PSIyMjMuNTE3IiBmaWx0ZXJVbml0cz0idXNlclNwYWNlT25Vc2UiIGNvbG9yLWludGVycG9sYXRpb24tZmlsdGVycz0ic1JHQiI+CjxmZUZsb29kIGZsb29kLW9wYWNpdHk9IjAiIHJlc3VsdD0iQmFja2dyb3VuZEltYWdlRml4Ii8+CjxmZUNvbG9yTWF0cml4IGluPSJTb3VyY2VBbHBoYSIgdHlwZT0ibWF0cml4IiB2YWx1ZXM9IjAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDEyNyAwIiByZXN1bHQ9ImhhcmRBbHBoYSIvPgo8ZmVPZmZzZXQgZHk9IjgiLz4KPGZlR2F1c3NpYW5CbHVyIHN0ZERldmlhdGlvbj0iOCIvPgo8ZmVDb2xvck1hdHJpeCB0eXBlPSJtYXRyaXgiIHZhbHVlcz0iMCAwIDAgMCAwLjE4ODIzNSAwIDAgMCAwIDAuMTg4MjM1IDAgMCAwIDAgMC4xODgyMzUgMCAwIDAgMC4xNSAwIi8+CjxmZUJsZW5kIG1vZGU9Im5vcm1hbCIgaW4yPSJCYWNrZ3JvdW5kSW1hZ2VGaXgiIHJlc3VsdD0iZWZmZWN0MV9kcm9wU2hhZG93XzkxOV8xMjc3NiIvPgo8ZmVDb2xvck1hdHJpeCBpbj0iU291cmNlQWxwaGEiIHR5cGU9Im1hdHJpeCIgdmFsdWVzPSIwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAwIDAgMCAxMjcgMCIgcmVzdWx0PSJoYXJkQWxwaGEiLz4KPGZlT2Zmc2V0Lz4KPGZlR2F1c3NpYW5CbHVyIHN0ZERldmlhdGlvbj0iMC41Ii8+CjxmZUNvbG9yTWF0cml4IHR5cGU9Im1hdHJpeCIgdmFsdWVzPSIwIDAgMCAwIDAuMTg4MjM1IDAgMCAwIDAgMC4xODgyMzUgMCAwIDAgMCAwLjE4ODIzNSAwIDAgMCAwLjIgMCIvPgo8ZmVCbGVuZCBtb2RlPSJub3JtYWwiIGluMj0iZWZmZWN0MV9kcm9wU2hhZG93XzkxOV8xMjc3NiIgcmVzdWx0PSJlZmZlY3QyX2Ryb3BTaGFkb3dfOTE5XzEyNzc2Ii8+CjxmZUJsZW5kIG1vZGU9Im5vcm1hbCIgaW49IlNvdXJjZUdyYXBoaWMiIGluMj0iZWZmZWN0Ml9kcm9wU2hhZG93XzkxOV8xMjc3NiIgcmVzdWx0PSJzaGFwZSIvPgo8L2ZpbHRlcj4KPC9kZWZzPgo8L3N2Zz4K);background-position-x:0px;background-position-y:0px;padding-left:24px;padding-right:32px}.editor-root .editor-templates .editor-templates-cards .editor-template-card .editor-template-thumb-container{flex-grow:1;position:relative;overflow:hidden;flex:1;padding:10px 5px 0;height:142px;margin:0;overflow:revert}.editor-root .editor-templates .editor-templates-cards .editor-template-card .editor-template-thumb-container>img{max-width:100%}.editor-root .editor-templates .editor-templates-cards .editor-template-card .editor-template-name{height:40px;width:100%;display:flex;align-items:center;font-weight:500;flex-shrink:0;border-top:1px solid #dedede;padding-left:20px;padding-right:20px;flex:0 0 50px;font-size:14px;line-height:22px;color:#303030}.editor-root .editor-templates .editor-templates-cards .editor-template-card:hover{background:none;padding:0}.editor-root .editor-templates .editor-templates-cards .editor-template-card:hover .editor-template-name{color:#338fe5}.editor-root .editor-templates .editor-templates-cards .editor-template-card.more .editor-template-name{padding-right:5px}.editor-root .editor-templates .editor-templates-cards .editor-template-card .editor-template-name span{display:block;width:100%;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}.editor-root .editor-templates .editor-templates-cards .editor-template-card.more .editor-template-name span{padding-left:0;text-align:center}.editor-root .editor-templates .editor-templates-cards .editor-template-card.more .editor-template-thumb-container{display:flex;align-items:center;justify-content:center}div[data-type=editor-block].encrypted-block{border:2px solid #ccc;padding:8px;border-radius:4px}div[data-type=editor-block].encrypted-block.encrypted div[data-type=block-content]{min-height:60px;width:100%}div[data-type=editor-block].encrypted-block.full-selected>div[data-type=block-content]{background-color:var(--background-selection)}div[data-type=editor-block].encrypted-block .password-container{position:absolute;top:0;left:0;right:0;bottom:0;display:flex;align-items:center;justify-content:center}`)),document.head.appendChild(t)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
2
- (function(g,be){typeof exports=="object"&&typeof module<"u"?be(exports,require("kiwi-intl"),require("lodash.merge"),require("string-template"),require("nanoid"),require("events"),require("query-string"),require("js-base64"),require("snabbdom"),require("lodash.clonedeep"),require("lodash.isequal"),require("quill-delta"),require("tiny-typed-emitter"),require("lodash.intersection"),require("ot-json1"),require("axios"),require("lodash.findlastindex"),require("reconnecting-websocket"),require("fast-sha256"),require("lodash.debounce"),require("tippy.js"),require("blueimp-md5"),require("css-color-converter"),require("markmap-view"),require("lodash.throttle"),require("prismjs"),require("prismjs/components/prism-c"),require("prismjs/components/prism-cpp"),require("prismjs/components/prism-abap"),require("prismjs/components/prism-arduino"),require("prismjs/components/prism-bash"),require("prismjs/components/prism-basic"),require("prismjs/components/prism-clojure"),require("prismjs/components/prism-coffeescript"),require("prismjs/components/prism-csharp"),require("prismjs/components/prism-css"),require("prismjs/components/prism-dart"),require("prismjs/components/prism-diff"),require("prismjs/components/prism-docker"),require("prismjs/components/prism-elixir"),require("prismjs/components/prism-elm"),require("prismjs/components/prism-erlang"),require("prismjs/components/prism-flow"),require("prismjs/components/prism-fortran"),require("prismjs/components/prism-fsharp"),require("prismjs/components/prism-gherkin"),require("prismjs/components/prism-glsl"),require("prismjs/components/prism-go"),require("prismjs/components/prism-graphql"),require("prismjs/components/prism-groovy"),require("prismjs/components/prism-haskell"),require("prismjs/components/prism-java"),require("prismjs/components/prism-javascript"),require("prismjs/components/prism-json"),require("prismjs/components/prism-julia"),require("prismjs/components/prism-kotlin"),require("prismjs/components/prism-latex"),require("prismjs/components/prism-less"),require("prismjs/components/prism-lisp"),require("prismjs/components/prism-livescript"),require("prismjs/components/prism-lua"),require("prismjs/components/prism-makefile"),require("prismjs/components/prism-markdown"),require("prismjs/components/prism-markup"),require("prismjs/components/prism-matlab"),require("prismjs/components/prism-mermaid"),require("prismjs/components/prism-nix"),require("prismjs/components/prism-objectivec"),require("prismjs/components/prism-ocaml"),require("prismjs/components/prism-pascal"),require("prismjs/components/prism-perl"),require("prismjs/components/prism-php"),require("prismjs/components/prism-powershell"),require("prismjs/components/prism-prolog"),require("prismjs/components/prism-protobuf"),require("prismjs/components/prism-python"),require("prismjs/components/prism-r"),require("prismjs/components/prism-reason"),require("prismjs/components/prism-ruby"),require("prismjs/components/prism-rust"),require("prismjs/components/prism-sass"),require("prismjs/components/prism-scala"),require("prismjs/components/prism-scheme"),require("prismjs/components/prism-scss"),require("prismjs/components/prism-solidity"),require("prismjs/components/prism-sql"),require("prismjs/components/prism-swift"),require("prismjs/components/prism-typescript"),require("prismjs/components/prism-vbnet"),require("prismjs/components/prism-verilog"),require("prismjs/components/prism-vhdl"),require("prismjs/components/prism-visual-basic"),require("prismjs/components/prism-wasm"),require("prismjs/components/prism-yaml"),require("mime-db"),require("dom-to-image"),require("plantuml-encoder"),require("@guyplusplus/turndown-plugin-gfm"),require("turndown"),require("marked"),require("@better-scroll/core")):typeof define=="function"&&define.amd?define(["exports","kiwi-intl","lodash.merge","string-template","nanoid","events","query-string","js-base64","snabbdom","lodash.clonedeep","lodash.isequal","quill-delta","tiny-typed-emitter","lodash.intersection","ot-json1","axios","lodash.findlastindex","reconnecting-websocket","fast-sha256","lodash.debounce","tippy.js","blueimp-md5","css-color-converter","markmap-view","lodash.throttle","prismjs","prismjs/components/prism-c","prismjs/components/prism-cpp","prismjs/components/prism-abap","prismjs/components/prism-arduino","prismjs/components/prism-bash","prismjs/components/prism-basic","prismjs/components/prism-clojure","prismjs/components/prism-coffeescript","prismjs/components/prism-csharp","prismjs/components/prism-css","prismjs/components/prism-dart","prismjs/components/prism-diff","prismjs/components/prism-docker","prismjs/components/prism-elixir","prismjs/components/prism-elm","prismjs/components/prism-erlang","prismjs/components/prism-flow","prismjs/components/prism-fortran","prismjs/components/prism-fsharp","prismjs/components/prism-gherkin","prismjs/components/prism-glsl","prismjs/components/prism-go","prismjs/components/prism-graphql","prismjs/components/prism-groovy","prismjs/components/prism-haskell","prismjs/components/prism-java","prismjs/components/prism-javascript","prismjs/components/prism-json","prismjs/components/prism-julia","prismjs/components/prism-kotlin","prismjs/components/prism-latex","prismjs/components/prism-less","prismjs/components/prism-lisp","prismjs/components/prism-livescript","prismjs/components/prism-lua","prismjs/components/prism-makefile","prismjs/components/prism-markdown","prismjs/components/prism-markup","prismjs/components/prism-matlab","prismjs/components/prism-mermaid","prismjs/components/prism-nix","prismjs/components/prism-objectivec","prismjs/components/prism-ocaml","prismjs/components/prism-pascal","prismjs/components/prism-perl","prismjs/components/prism-php","prismjs/components/prism-powershell","prismjs/components/prism-prolog","prismjs/components/prism-protobuf","prismjs/components/prism-python","prismjs/components/prism-r","prismjs/components/prism-reason","prismjs/components/prism-ruby","prismjs/components/prism-rust","prismjs/components/prism-sass","prismjs/components/prism-scala","prismjs/components/prism-scheme","prismjs/components/prism-scss","prismjs/components/prism-solidity","prismjs/components/prism-sql","prismjs/components/prism-swift","prismjs/components/prism-typescript","prismjs/components/prism-vbnet","prismjs/components/prism-verilog","prismjs/components/prism-vhdl","prismjs/components/prism-visual-basic","prismjs/components/prism-wasm","prismjs/components/prism-yaml","mime-db","dom-to-image","plantuml-encoder","@guyplusplus/turndown-plugin-gfm","turndown","marked","@better-scroll/core"],be):(g=typeof globalThis<"u"?globalThis:g||self,be(g["oneseditor-editor"]={},g.KiwiIntl,g.merge,g.stringFormat,g.nanoid$1,g.events,g.queryString,g.jsBase64,g.snabbdom,g.cloneDeep,g.isEqual,g.Delta,g.tinyTypedEmitter,g.intersection,g.json1,g.axios,g.findLastIndex,g.ReconnectingWebSocket,g.sha256,g.debounce,g.tippy$1,g.md5,g.cssColorConverter,g.markmap,g.throttle,g.Prism,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,g.mime,g.domToImage,g.plantumlEncoder,g.turndownPluginGfm,g.TurndownService,g.marked,g.BetterScroll))})(this,function(g,be,Eo,_7,N7,Mf,P7,pi,to,$7,H7,j7,Wt,F7,z7,V7,U7,q7,W7,G7,Rf,Z7,$a,Y7,Q7,K7,ZH,YH,QH,KH,JH,XH,tj,ej,nj,oj,rj,ij,sj,lj,cj,aj,dj,uj,hj,fj,mj,gj,pj,Cj,bj,vj,kj,yj,wj,Bj,Ej,Ij,xj,Sj,Tj,Dj,Lj,Mj,Rj,Aj,Oj,_j,Nj,Pj,$j,Hj,jj,Fj,zj,Vj,Uj,qj,Wj,Gj,Zj,Yj,Qj,Kj,Jj,Xj,tF,eF,nF,oF,rF,iF,sF,lF,J7,X7,t8,e8,n8,o8,r8){"use strict";var WH=Object.defineProperty;var GH=(g,be,Eo)=>be in g?WH(g,be,{enumerable:!0,configurable:!0,writable:!0,value:Eo}):g[be]=Eo;var h=(g,be,Eo)=>(GH(g,typeof be!="symbol"?be+"":be,Eo),Eo);const Mt=n=>n&&typeof n=="object"&&"default"in n?n:{default:n};function Ha(n){if(n&&n.__esModule)return n;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(t,e,o.get?o:{enumerable:!0,get:()=>n[e]})}}return t.default=n,Object.freeze(t)}const i8=Mt(be),ja=Mt(Eo),s8=Mt(_7),Af=Mt(Mf),Y=Mt($7),Zs=Mt(H7),ee=Mt(j7),Fa=Mt(F7),Ys=Ha(z7),l8=Mt(V7),c8=Mt(U7),a8=Mt(q7),d8=Ha(W7),ie=Mt(G7),za=Mt(Rf),Ci=Mt(Z7),u8=Ha(Y7),h8=Mt(Q7),bi=Mt(K7),Of=Mt(J7),f8=Mt(X7),m8=Mt(t8),g8=Mt(n8),_f=Mt(r8);function p8(n){const t=o=>o<10?`0${String(o)}`:String(o),e=o=>o<10?`00${String(o)}`:o<100?`0${String(o)}`:String(o);return`${n.getFullYear()}-${t(n.getMonth()+1)}-${t(n.getDate())} ${t(n.getHours())}:${t(n.getMinutes())}:${t(n.getSeconds())}.${e(n.getMilliseconds())}`}const Nf=new Map,fa=class{constructor(t){h(this,"times",new Map);this.category=t}_log(t,e,o,r){var v;const i=typeof process>"u"?{}:process;let s="";if(typeof e=="object")try{s="message"in e?e.message:JSON.stringify(e,null,4)}catch{s=""}else typeof e=="string"?e&&(s=e):s=JSON.stringify(e);s=r?`${s} - ${r}`:s;const l=`${this.category}`;let c=console.log;t==="WARN "&&(c=console.warn),t==="ERROR"&&(c=console.error);const a=`${p8(new Date)}`,u=t,f=l,m=fa.extParams?"[{date}] {level}: [{module} {extParams}] - {msg}":"[{date}] {level}: [{module}] - {msg}",C=[s8.default(((v=i.env)==null?void 0:v.LOG_TEMPLATE)||m,{date:a,level:u,module:f,msg:s,extParams:fa.extParams})];if(typeof e=="object"){const w=e.stack;w&&C.push(w)}if(c===console.error){const w=new Error().stack;w&&C.push(w)}c(...C),o&&this._log(t,o)}log(t,e){this._log("INFO ",t,void 0,e)}debug(t,e){this._log("DEBUG",t,void 0,e)}info(t,e){this._log("INFO ",t,void 0,e)}warn(t,e,o){this._log("WARN ",t,e,o)}error(t,e,o){this._log("ERROR",t,e,o)}time(t){this.times.set(t,Date.now())}timeEnd(t){this.timeLog(t),this.times.delete(t)}timeLog(t){const e=this.times.get(t);if(!e){this.warn(`no time label: ${t}`);return}this.debug(`${t}: ${Date.now()-e}`)}static setExtParams(t){this.extParams=t}};let vi=fa;h(vi,"extParams","");function y(n){const t=Nf.get(n);if(t)return t;const e=new vi(n);return Nf.set(n,e),e}const C8={name:"Ones Editor",date:{dateFromFuture:"From future",dateJustNow:"Just now",dateYesterday:"Yesterday",dateMinutesAgo:"{num} minutes ago",date1HourAgo:"1 hour ago",dateHoursAgo:"{num} hours ago",dateDaysAgo:"{num} days ago",dateWeeksAgo:"{num} weeks ago"},common:{cancel:"cancel"}},b8={name:"Ones Editor",date:{dateFromFuture:"\u6765\u81EA\u672A\u6765",dateJustNow:"\u521A\u521A",dateYesterday:"\u6628\u5929",dateMinutesAgo:"{num}\u5206\u949F\u524D",date1HourAgo:"1\u5C0F\u65F6\u524D",dateHoursAgo:"{num}\u5C0F\u65F6\u524D",dateDaysAgo:"{num}\u5929\u524D",dateWeeksAgo:"{num}\u5468\u524D"},common:{cancel:"\u53D6\u6D88"}},v8=y("i18n"),k8={"en-US":C8,"zh-CN":b8},Qs=i8.default.init("en-US",k8);function y8(n=void 0){Qs.setLang&&Qs.setLang(n||"en-US")}function w8(n){ja.default(Qs.__metas__,n)}function B8(n,t){const e=Qs.get(n,t);return e===n&&v8.warn(`no locale value for key ${n}`),e}const S=Object.freeze(Object.defineProperty({__proto__:null,setLang:y8,mergeLang:w8,t:B8},Symbol.toStringTag,{value:"Module"})),cF="";class Pf{constructor(t,e){this.editor=t,this.data=e}getData(){return this.data}getEditor(){return this.editor}destroy(){}}class E8 extends Error{constructor(t){if(super(t),this.code="Assert",this.stack){const e=this.stack.split(`
2
+ (function(g,be){typeof exports=="object"&&typeof module<"u"?be(exports,require("kiwi-intl"),require("lodash.merge"),require("string-template"),require("nanoid"),require("events"),require("query-string"),require("js-base64"),require("snabbdom"),require("lodash.clonedeep"),require("lodash.isequal"),require("quill-delta"),require("tiny-typed-emitter"),require("lodash.intersection"),require("ot-json1"),require("axios"),require("lodash.findlastindex"),require("reconnecting-websocket"),require("fast-sha256"),require("lodash.debounce"),require("tippy.js"),require("blueimp-md5"),require("css-color-converter"),require("markmap-view"),require("lodash.throttle"),require("prismjs"),require("prismjs/components/prism-c"),require("prismjs/components/prism-cpp"),require("prismjs/components/prism-abap"),require("prismjs/components/prism-arduino"),require("prismjs/components/prism-bash"),require("prismjs/components/prism-basic"),require("prismjs/components/prism-clojure"),require("prismjs/components/prism-coffeescript"),require("prismjs/components/prism-csharp"),require("prismjs/components/prism-css"),require("prismjs/components/prism-dart"),require("prismjs/components/prism-diff"),require("prismjs/components/prism-docker"),require("prismjs/components/prism-elixir"),require("prismjs/components/prism-elm"),require("prismjs/components/prism-erlang"),require("prismjs/components/prism-flow"),require("prismjs/components/prism-fortran"),require("prismjs/components/prism-fsharp"),require("prismjs/components/prism-gherkin"),require("prismjs/components/prism-glsl"),require("prismjs/components/prism-go"),require("prismjs/components/prism-graphql"),require("prismjs/components/prism-groovy"),require("prismjs/components/prism-haskell"),require("prismjs/components/prism-java"),require("prismjs/components/prism-javascript"),require("prismjs/components/prism-json"),require("prismjs/components/prism-julia"),require("prismjs/components/prism-kotlin"),require("prismjs/components/prism-latex"),require("prismjs/components/prism-less"),require("prismjs/components/prism-lisp"),require("prismjs/components/prism-livescript"),require("prismjs/components/prism-lua"),require("prismjs/components/prism-makefile"),require("prismjs/components/prism-markdown"),require("prismjs/components/prism-markup"),require("prismjs/components/prism-matlab"),require("prismjs/components/prism-mermaid"),require("prismjs/components/prism-nix"),require("prismjs/components/prism-objectivec"),require("prismjs/components/prism-ocaml"),require("prismjs/components/prism-pascal"),require("prismjs/components/prism-perl"),require("prismjs/components/prism-php"),require("prismjs/components/prism-powershell"),require("prismjs/components/prism-prolog"),require("prismjs/components/prism-protobuf"),require("prismjs/components/prism-python"),require("prismjs/components/prism-r"),require("prismjs/components/prism-reason"),require("prismjs/components/prism-ruby"),require("prismjs/components/prism-rust"),require("prismjs/components/prism-sass"),require("prismjs/components/prism-scala"),require("prismjs/components/prism-scheme"),require("prismjs/components/prism-scss"),require("prismjs/components/prism-solidity"),require("prismjs/components/prism-sql"),require("prismjs/components/prism-swift"),require("prismjs/components/prism-typescript"),require("prismjs/components/prism-vbnet"),require("prismjs/components/prism-verilog"),require("prismjs/components/prism-vhdl"),require("prismjs/components/prism-visual-basic"),require("prismjs/components/prism-wasm"),require("prismjs/components/prism-yaml"),require("mime-db"),require("dom-to-image"),require("plantuml-encoder"),require("@guyplusplus/turndown-plugin-gfm"),require("turndown"),require("marked"),require("@better-scroll/core")):typeof define=="function"&&define.amd?define(["exports","kiwi-intl","lodash.merge","string-template","nanoid","events","query-string","js-base64","snabbdom","lodash.clonedeep","lodash.isequal","quill-delta","tiny-typed-emitter","lodash.intersection","ot-json1","axios","lodash.findlastindex","reconnecting-websocket","fast-sha256","lodash.debounce","tippy.js","blueimp-md5","css-color-converter","markmap-view","lodash.throttle","prismjs","prismjs/components/prism-c","prismjs/components/prism-cpp","prismjs/components/prism-abap","prismjs/components/prism-arduino","prismjs/components/prism-bash","prismjs/components/prism-basic","prismjs/components/prism-clojure","prismjs/components/prism-coffeescript","prismjs/components/prism-csharp","prismjs/components/prism-css","prismjs/components/prism-dart","prismjs/components/prism-diff","prismjs/components/prism-docker","prismjs/components/prism-elixir","prismjs/components/prism-elm","prismjs/components/prism-erlang","prismjs/components/prism-flow","prismjs/components/prism-fortran","prismjs/components/prism-fsharp","prismjs/components/prism-gherkin","prismjs/components/prism-glsl","prismjs/components/prism-go","prismjs/components/prism-graphql","prismjs/components/prism-groovy","prismjs/components/prism-haskell","prismjs/components/prism-java","prismjs/components/prism-javascript","prismjs/components/prism-json","prismjs/components/prism-julia","prismjs/components/prism-kotlin","prismjs/components/prism-latex","prismjs/components/prism-less","prismjs/components/prism-lisp","prismjs/components/prism-livescript","prismjs/components/prism-lua","prismjs/components/prism-makefile","prismjs/components/prism-markdown","prismjs/components/prism-markup","prismjs/components/prism-matlab","prismjs/components/prism-mermaid","prismjs/components/prism-nix","prismjs/components/prism-objectivec","prismjs/components/prism-ocaml","prismjs/components/prism-pascal","prismjs/components/prism-perl","prismjs/components/prism-php","prismjs/components/prism-powershell","prismjs/components/prism-prolog","prismjs/components/prism-protobuf","prismjs/components/prism-python","prismjs/components/prism-r","prismjs/components/prism-reason","prismjs/components/prism-ruby","prismjs/components/prism-rust","prismjs/components/prism-sass","prismjs/components/prism-scala","prismjs/components/prism-scheme","prismjs/components/prism-scss","prismjs/components/prism-solidity","prismjs/components/prism-sql","prismjs/components/prism-swift","prismjs/components/prism-typescript","prismjs/components/prism-vbnet","prismjs/components/prism-verilog","prismjs/components/prism-vhdl","prismjs/components/prism-visual-basic","prismjs/components/prism-wasm","prismjs/components/prism-yaml","mime-db","dom-to-image","plantuml-encoder","@guyplusplus/turndown-plugin-gfm","turndown","marked","@better-scroll/core"],be):(g=typeof globalThis<"u"?globalThis:g||self,be(g["oneseditor-editor"]={},g.KiwiIntl,g.merge,g.stringFormat,g.nanoid$1,g.events,g.queryString,g.jsBase64,g.snabbdom,g.cloneDeep,g.isEqual,g.Delta,g.tinyTypedEmitter,g.intersection,g.json1,g.axios,g.findLastIndex,g.ReconnectingWebSocket,g.sha256,g.debounce,g.tippy$1,g.md5,g.cssColorConverter,g.markmap,g.throttle,g.Prism,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,null,g.mime,g.domToImage,g.plantumlEncoder,g.turndownPluginGfm,g.TurndownService,g.marked,g.BetterScroll))})(this,function(g,be,Eo,_7,N7,Mf,P7,pi,to,$7,H7,j7,Wt,F7,z7,U7,V7,q7,W7,G7,Rf,Z7,$a,Y7,Q7,K7,ZH,YH,QH,KH,JH,XH,tj,ej,nj,oj,rj,ij,sj,lj,cj,aj,dj,uj,hj,fj,mj,gj,pj,Cj,bj,vj,kj,yj,wj,Bj,Ej,Ij,xj,Sj,Tj,Dj,Lj,Mj,Rj,Aj,Oj,_j,Nj,Pj,$j,Hj,jj,Fj,zj,Uj,Vj,qj,Wj,Gj,Zj,Yj,Qj,Kj,Jj,Xj,tF,eF,nF,oF,rF,iF,sF,lF,J7,X7,t8,e8,n8,o8,r8){"use strict";var WH=Object.defineProperty;var GH=(g,be,Eo)=>be in g?WH(g,be,{enumerable:!0,configurable:!0,writable:!0,value:Eo}):g[be]=Eo;var h=(g,be,Eo)=>(GH(g,typeof be!="symbol"?be+"":be,Eo),Eo);const Mt=n=>n&&typeof n=="object"&&"default"in n?n:{default:n};function Ha(n){if(n&&n.__esModule)return n;const t=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const e in n)if(e!=="default"){const o=Object.getOwnPropertyDescriptor(n,e);Object.defineProperty(t,e,o.get?o:{enumerable:!0,get:()=>n[e]})}}return t.default=n,Object.freeze(t)}const i8=Mt(be),ja=Mt(Eo),s8=Mt(_7),Af=Mt(Mf),Y=Mt($7),Zs=Mt(H7),ee=Mt(j7),Fa=Mt(F7),Ys=Ha(z7),l8=Mt(U7),c8=Mt(V7),a8=Mt(q7),d8=Ha(W7),ie=Mt(G7),za=Mt(Rf),Ci=Mt(Z7),u8=Ha(Y7),h8=Mt(Q7),bi=Mt(K7),Of=Mt(J7),f8=Mt(X7),m8=Mt(t8),g8=Mt(n8),_f=Mt(r8);function p8(n){const t=o=>o<10?`0${String(o)}`:String(o),e=o=>o<10?`00${String(o)}`:o<100?`0${String(o)}`:String(o);return`${n.getFullYear()}-${t(n.getMonth()+1)}-${t(n.getDate())} ${t(n.getHours())}:${t(n.getMinutes())}:${t(n.getSeconds())}.${e(n.getMilliseconds())}`}const Nf=new Map,fa=class{constructor(t){h(this,"times",new Map);this.category=t}_log(t,e,o,r){var v;const i=typeof process>"u"?{}:process;let s="";if(typeof e=="object")try{s="message"in e?e.message:JSON.stringify(e,null,4)}catch{s=""}else typeof e=="string"?e&&(s=e):s=JSON.stringify(e);s=r?`${s} - ${r}`:s;const l=`${this.category}`;let c=console.log;t==="WARN "&&(c=console.warn),t==="ERROR"&&(c=console.error);const a=`${p8(new Date)}`,u=t,f=l,m=fa.extParams?"[{date}] {level}: [{module} {extParams}] - {msg}":"[{date}] {level}: [{module}] - {msg}",C=[s8.default(((v=i.env)==null?void 0:v.LOG_TEMPLATE)||m,{date:a,level:u,module:f,msg:s,extParams:fa.extParams})];if(typeof e=="object"){const w=e.stack;w&&C.push(w)}if(c===console.error){const w=new Error().stack;w&&C.push(w)}c(...C),o&&this._log(t,o)}log(t,e){this._log("INFO ",t,void 0,e)}debug(t,e){this._log("DEBUG",t,void 0,e)}info(t,e){this._log("INFO ",t,void 0,e)}warn(t,e,o){this._log("WARN ",t,e,o)}error(t,e,o){this._log("ERROR",t,e,o)}time(t){this.times.set(t,Date.now())}timeEnd(t){this.timeLog(t),this.times.delete(t)}timeLog(t){const e=this.times.get(t);if(!e){this.warn(`no time label: ${t}`);return}this.debug(`${t}: ${Date.now()-e}`)}static setExtParams(t){this.extParams=t}};let vi=fa;h(vi,"extParams","");function y(n){const t=Nf.get(n);if(t)return t;const e=new vi(n);return Nf.set(n,e),e}const C8={name:"Ones Editor",date:{dateFromFuture:"From future",dateJustNow:"Just now",dateYesterday:"Yesterday",dateMinutesAgo:"{num} minutes ago",date1HourAgo:"1 hour ago",dateHoursAgo:"{num} hours ago",dateDaysAgo:"{num} days ago",dateWeeksAgo:"{num} weeks ago"},common:{cancel:"cancel"}},b8={name:"Ones Editor",date:{dateFromFuture:"\u6765\u81EA\u672A\u6765",dateJustNow:"\u521A\u521A",dateYesterday:"\u6628\u5929",dateMinutesAgo:"{num}\u5206\u949F\u524D",date1HourAgo:"1\u5C0F\u65F6\u524D",dateHoursAgo:"{num}\u5C0F\u65F6\u524D",dateDaysAgo:"{num}\u5929\u524D",dateWeeksAgo:"{num}\u5468\u524D"},common:{cancel:"\u53D6\u6D88"}},v8=y("i18n"),k8={"en-US":C8,"zh-CN":b8},Qs=i8.default.init("en-US",k8);function y8(n=void 0){Qs.setLang&&Qs.setLang(n||"en-US")}function w8(n){ja.default(Qs.__metas__,n)}function B8(n,t){const e=Qs.get(n,t);return e===n&&v8.warn(`no locale value for key ${n}`),e}const S=Object.freeze(Object.defineProperty({__proto__:null,setLang:y8,mergeLang:w8,t:B8},Symbol.toStringTag,{value:"Module"})),cF="";class Pf{constructor(t,e){this.editor=t,this.data=e}getData(){return this.data}getEditor(){return this.editor}destroy(){}}class E8 extends Error{constructor(t){if(super(t),this.code="Assert",this.stack){const e=this.stack.split(`
3
3
  `);if(e.length>1)if(this.lineNumber&&this.columnNumber){const o=e[1].match(/(.*)@(.*):(\d+):(\d+)/);o&&(this.lineNumber=+o[3],this.columnNumber=+o[4],this.fileName=o[2]),e.splice(0,1)}else e.splice(1,1);this.stack=e.join(`
4
4
  `)}}}function d(n,t,e){if(!t)throw n.error(`assert failed: ${e}`),new E8(e)}const I8=N7.customAlphabet("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",8),$f="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";function x8(){return $f[Date.now()%$f.length]}const N=()=>`${x8()}${I8()}`;class Hf extends Af.default.EventEmitter{constructor(e=60){super();h(this,"cache",new Map);h(this,"expiredSeconds");this.expiredSeconds=e,this.startAutoClear()}delete(e){const o=this.cache.get(e);o&&this.emit("delete",o.data),this.cache.delete(e)}getSync(e,o){const r=this.cache.get(e),i=Date.now();if(r&&(i-r.lastRead)/1e3<this.expiredSeconds)return r.lastRead=i,r.data;const s=o(e);return this.cache.set(e,{lastRead:i,data:s}),s}async get(e,o){const r=this.cache.get(e),i=Date.now();if(r&&(i-r.lastRead)/1e3<this.expiredSeconds)return r.lastRead=i,r.data;const s=await o(e);return this.cache.set(e,{lastRead:i,data:s}),s}startAutoClear(){setInterval(()=>{const e=Date.now();Array.from(this.cache.entries()).forEach(([o,r])=>{(e-r.lastRead)/1e3>this.expiredSeconds&&this.delete(o)})},10*1e3)}}class ki{constructor(){h(this,"_callbacks",new Set)}get callbacks(){return Array.from(this._callbacks)}registerCallback(t){this._callbacks.add(t)}unregisterCallback(t){this._callbacks.delete(t)}clearCallbacks(){this._callbacks.clear()}}const S8=y("await-locker");class T8{constructor(){h(this,"_acquired",!1);h(this,"_waitingResolvers",[]);this._acquired=!1,this._waitingResolvers=[]}acquireAsync(t){return this._acquired?new Promise((e,o)=>{this._waitingResolvers.push(e),t&&t>0&&setTimeout(()=>{const r=this._waitingResolvers.indexOf(e);if(r!==-1){this._waitingResolvers.splice(r,1);const i=new Error(`lock timeout: ${t}, waiting resolves: ${this._waitingResolvers.length}`);o(i)}},t)}):(this._acquired=!0,Promise.resolve())}tryAcquire(){return this._acquired?!1:(this._acquired=!0,!0)}release(){if(!this._acquired)throw new Error("Cannot release an unacquired lock");if(this._waitingResolvers.length>0){const t=this._waitingResolvers.shift();d(S8,t,"Resolver missing"),t(void 0)}else this._acquired=!1}acquired(){return this._acquired}debug(){const t=this._waitingResolvers.length;return console.log(`waiting resolves: ${t}`),{waitingCount:t}}}class D8{constructor(){h(this,"_map");this._map=new Map}getLocker(t){let e=this._map.get(t);return e||(e=new T8,this._map.set(t,e)),e}async lock(t,e){await this.getLocker(t).acquireAsync(e)}release(t){this.getLocker(t).release()}remove(t){this.isLocking(t)||this._map.delete(t)}isLocking(t){return this._map.has(t)?this.getLocker(t).acquired():!1}}const Rn=new D8;/**
5
5
  * @name string-character-is-astral-surrogate
@@ -8,22 +8,22 @@
8
8
  * @author Roy Revelt, Codsen Ltd
9
9
  * @license MIT
10
10
  * {@link https://codsen.com/os/string-character-is-astral-surrogate/}
11
- */function L8(n){if(typeof n=="string")return n.length===0?!1:n.charCodeAt(0)>=55296&&n.charCodeAt(0)<=56319;if(n===void 0)return!1;throw new TypeError(`string-character-is-astral-surrogate/isHighSurrogate(): the input is not string but ${typeof n}`)}function Va(n){if(typeof n=="string")return n.length===0?!1:n.charCodeAt(0)>=56320&&n.charCodeAt(0)<=57343;if(n===void 0)return!1;throw new TypeError(`string-character-is-astral-surrogate/isLowSurrogate(): the input is not string but ${typeof n}`)}const yi="\u200B";function M8(n){return[...n].length}function R8(n,t,e){const r=[...n];let i;return e===void 0?i=r.length:i=t+e,r.slice(t,i).join("")}const Io=y("dom-utils");function M(n,...t){n&&n.nodeType===Node.ELEMENT_NODE&&n.classList.add(...t)}function lt(n,t){return n instanceof HTMLElement?n.classList.contains(t):!1}function F(n,...t){n&&n.nodeType===Node.ELEMENT_NODE&&n.classList.remove(...t),n.classList.length===0&&n.removeAttribute("class")}function b(n,t,e,o){const r=document.createElement(n);return t&&t.length>0&&M(r,...t),e&&e.appendChild(r),o&&(typeof o=="string"?r.innerText=o:qa(r,o)),r}function hr(n,t,e){const o=b("button",t,e);return o.innerHTML=n,o}function jf(n,t,e){const o=b("img",t,e);return o.src=n,o}function Ff(n,t){try{const e=document.createRange();return e.setStart(n,t),e}catch(e){d(Io,!1,`failed to create range: ${n.childNodes.length}, ${t}, ${e.message}`)}}function Ks(n,t,e,o){try{const r=document.createRange();return r.setStart(n,t),r.setEnd(e,o),r}catch(r){d(Io,!1,`failed to create expanded range: ${n.childNodes.length}, ${t}, ${e.childNodes.length}, ${o}, ${r.message}`)}}function Js(n){const t=n.getClientRects();return d(Io,t.length>=1,"getFirstClientRect: no rects"),t[0]}function xo(n){const t=n.getClientRects();return d(Io,t.length>=1,"getLastClientRect: no rects"),t[t.length-1]}function hn(n,t,e){const o=n.left+n.width/2,r=n.top+n.height/2;return(o-t)**2+(r-e)**2}function zf(n,t,e){const o=n.data;d(Io,o,"invalid text node, no data");let r=Number.MAX_SAFE_INTEGER,i=0;const s=document.createRange();for(let l=0;l<=o.length;l++){if(l<o.length&&Va(o[l]))continue;s.setStart(n,l);const c=s.getClientRects();for(let a=0;a<c.length;a++){const u=c[a],f=hn(u,t,e);f<r&&(r=f,i=l)}}return i}function Xs(n,t){if(n===t)return 0;if((!n.parentElement||!t.parentElement)&&d(Io,!1,"invalid dom node to compare"),n.parentElement===t.parentElement){const i=Array.from(n.parentElement.children);return i.indexOf(n)-i.indexOf(t)}const e=i=>{const s=[i];for(;i.parentElement;)s.unshift(i.parentElement),i=i.parentElement;return s},o=e(n),r=e(t);o[0]!==r[0]&&d(Io,!1,"invalid dom node to compare, different tree");for(let i=1;;i++){const s=o[i],l=r[i];if(s===l)continue;const c=o[i-1],a=Array.from(c.children);return a.indexOf(s)-a.indexOf(l)}}function Ua(n){var r,i;const t=window.getComputedStyle(n),e=(r=Number.parseInt(t.paddingLeft,10))!=null?r:0,o=(i=Number.parseInt(t.paddingRight,10))!=null?i:0;return e+o}function Vf(n){return!document.documentElement.contains(n)}function vt(n,t){let e=t;for(;e;){if(n===e)return!0;e=e.parentNode}return!1}function Uf(n,t,e){if(document.getElementById(t)){setTimeout(e);return}const r=document.createElement("script");r.async=!0,r.src=n,r.id=t,document.head.appendChild(r),r.onload=()=>e(),r.onerror=i=>{if(i instanceof Event){const s=i.target;let l="";s&&(l=s.src),e(new URIError(`The script ${l} didn't load correctly.`))}else e(new URIError(`The script ${i} didn't load correctly.`))}}async function So(n,t){const e=new Promise((o,r)=>{Uf(n,t,i=>{i?r(i):o(void 0)})});try{await Rn.lock(t),await e}finally{Rn.release(t)}}function qa(n,t){Object.entries(t).forEach(([e,o])=>{n.dataset[e]=`${o}`})}function Wa(n,t){Object.entries(t).forEach(([e,o])=>{n.setAttribute(e,o)})}function Ga(n,t){Object.entries(t).forEach(([e,o])=>{n.style.setProperty(e,o)})}function wi(n){let t=0,e=0,o=n;do t+=o.offsetTop||0,e+=o.offsetLeft||0,o=o.offsetParent;while(o);return{top:t,left:e}}function Bi(n,t){return!n.target||!(n.target instanceof Element)?null:n.target.closest(t)}class A8{constructor(t){h(this,"element");this.element=t}getHorizontalScroll(){return this.element.scrollLeft}getVerticalScroll(){return this.element.scrollTop}getMaxHorizontalScroll(){return this.element.scrollWidth-this.element.clientWidth}getMaxVerticalScroll(){return this.element.scrollHeight-this.element.clientHeight}getHorizontalElementScrollOffset(t,e){return wi(t).left-wi(e).left}getVerticalElementScrollOffset(t,e){return wi(t).top-wi(e).top}scrollTo(t,e){this.element.scrollLeft=t,this.element.scrollTop=e}}class O8{constructor(){h(this,"element",window)}getHorizontalScroll(){return window.scrollX||document.documentElement.scrollLeft}getVerticalScroll(){return window.scrollY||document.documentElement.scrollTop}getMaxHorizontalScroll(){return Math.max(document.body.scrollWidth,document.documentElement.scrollWidth,document.body.offsetWidth,document.documentElement.offsetWidth,document.body.clientWidth,document.documentElement.clientWidth)-window.innerWidth}getMaxVerticalScroll(){return Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.body.clientHeight,document.documentElement.clientHeight)-window.innerHeight}getHorizontalElementScrollOffset(t){return(window.scrollX||document.documentElement.scrollLeft)+t.getBoundingClientRect().left}getVerticalElementScrollOffset(t){return(window.scrollY||document.documentElement.scrollTop)+t.getBoundingClientRect().top}scrollTo(t,e){window.scrollTo(t,e)}}const An={elements:[],cancelMethods:[],add:(n,t)=>{An.elements.push(n),An.cancelMethods.push(t)},remove:(n,t)=>{const e=An.elements.indexOf(n);e>-1&&(t&&An.cancelMethods[e](),An.elements.splice(e,1),An.cancelMethods.splice(e,1))}},qf=typeof window<"u",_8={cancelOnUserAction:!0,easing:n=>--n*n*n+1,elementToScroll:qf?window:null,horizontalOffset:0,maxDuration:3e3,minDuration:250,speed:500,verticalOffset:0};async function Ei(n,t={}){if(!qf)return new Promise(O=>{O(!1)});if(!window.Promise)throw"Browser doesn't support Promises, and animated-scroll-to depends on it, please provide a polyfill.";let e,o,r;const i={..._8,...t},s=i.elementToScroll===window,l=!!i.elementToScroll.nodeName;if(!s&&!l)throw"Element to scroll needs to be either window or DOM element.";const c=s?document.documentElement:i.elementToScroll;getComputedStyle(c).getPropertyValue("scroll-behavior")==="smooth"&&console.warn(`${c.tagName} has "scroll-behavior: smooth" which can mess up with animated-scroll-to's animations`);const u=s?new O8:new A8(i.elementToScroll);if(n instanceof Element){if(r=n,l&&(!i.elementToScroll.contains(r)||i.elementToScroll.isSameNode(r)))throw"options.elementToScroll has to be a parent of scrollToElement";e=u.getHorizontalElementScrollOffset(r,i.elementToScroll),o=u.getVerticalElementScrollOffset(r,i.elementToScroll)}else if(typeof n=="number")e=u.getHorizontalScroll(),o=n;else if(Array.isArray(n)&&n.length===2)e=n[0]===null?u.getHorizontalScroll():n[0],o=n[1]===null?u.getVerticalScroll():n[1];else throw`Wrong function signature. Check documentation.
11
+ */function L8(n){if(typeof n=="string")return n.length===0?!1:n.charCodeAt(0)>=55296&&n.charCodeAt(0)<=56319;if(n===void 0)return!1;throw new TypeError(`string-character-is-astral-surrogate/isHighSurrogate(): the input is not string but ${typeof n}`)}function Ua(n){if(typeof n=="string")return n.length===0?!1:n.charCodeAt(0)>=56320&&n.charCodeAt(0)<=57343;if(n===void 0)return!1;throw new TypeError(`string-character-is-astral-surrogate/isLowSurrogate(): the input is not string but ${typeof n}`)}const yi="\u200B";function M8(n){return[...n].length}function R8(n,t,e){const r=[...n];let i;return e===void 0?i=r.length:i=t+e,r.slice(t,i).join("")}const Io=y("dom-utils");function M(n,...t){n&&n.nodeType===Node.ELEMENT_NODE&&n.classList.add(...t)}function lt(n,t){return n instanceof HTMLElement?n.classList.contains(t):!1}function F(n,...t){n&&n.nodeType===Node.ELEMENT_NODE&&n.classList.remove(...t),n.classList.length===0&&n.removeAttribute("class")}function b(n,t,e,o){const r=document.createElement(n);return t&&t.length>0&&M(r,...t),e&&e.appendChild(r),o&&(typeof o=="string"?r.innerText=o:qa(r,o)),r}function hr(n,t,e){const o=b("button",t,e);return o.innerHTML=n,o}function jf(n,t,e){const o=b("img",t,e);return o.src=n,o}function Ff(n,t){try{const e=document.createRange();return e.setStart(n,t),e}catch(e){d(Io,!1,`failed to create range: ${n.childNodes.length}, ${t}, ${e.message}`)}}function Ks(n,t,e,o){try{const r=document.createRange();return r.setStart(n,t),r.setEnd(e,o),r}catch(r){d(Io,!1,`failed to create expanded range: ${n.childNodes.length}, ${t}, ${e.childNodes.length}, ${o}, ${r.message}`)}}function Js(n){const t=n.getClientRects();return d(Io,t.length>=1,"getFirstClientRect: no rects"),t[0]}function xo(n){const t=n.getClientRects();return d(Io,t.length>=1,"getLastClientRect: no rects"),t[t.length-1]}function hn(n,t,e){const o=n.left+n.width/2,r=n.top+n.height/2;return(o-t)**2+(r-e)**2}function zf(n,t,e){const o=n.data;d(Io,o,"invalid text node, no data");let r=Number.MAX_SAFE_INTEGER,i=0;const s=document.createRange();for(let l=0;l<=o.length;l++){if(l<o.length&&Ua(o[l]))continue;s.setStart(n,l);const c=s.getClientRects();for(let a=0;a<c.length;a++){const u=c[a],f=hn(u,t,e);f<r&&(r=f,i=l)}}return i}function Xs(n,t){if(n===t)return 0;if((!n.parentElement||!t.parentElement)&&d(Io,!1,"invalid dom node to compare"),n.parentElement===t.parentElement){const i=Array.from(n.parentElement.children);return i.indexOf(n)-i.indexOf(t)}const e=i=>{const s=[i];for(;i.parentElement;)s.unshift(i.parentElement),i=i.parentElement;return s},o=e(n),r=e(t);o[0]!==r[0]&&d(Io,!1,"invalid dom node to compare, different tree");for(let i=1;;i++){const s=o[i],l=r[i];if(s===l)continue;const c=o[i-1],a=Array.from(c.children);return a.indexOf(s)-a.indexOf(l)}}function Va(n){var r,i;const t=window.getComputedStyle(n),e=(r=Number.parseInt(t.paddingLeft,10))!=null?r:0,o=(i=Number.parseInt(t.paddingRight,10))!=null?i:0;return e+o}function Uf(n){return!document.documentElement.contains(n)}function vt(n,t){let e=t;for(;e;){if(n===e)return!0;e=e.parentNode}return!1}function Vf(n,t,e){if(document.getElementById(t)){setTimeout(e);return}const r=document.createElement("script");r.async=!0,r.src=n,r.id=t,document.head.appendChild(r),r.onload=()=>e(),r.onerror=i=>{if(i instanceof Event){const s=i.target;let l="";s&&(l=s.src),e(new URIError(`The script ${l} didn't load correctly.`))}else e(new URIError(`The script ${i} didn't load correctly.`))}}async function So(n,t){const e=new Promise((o,r)=>{Vf(n,t,i=>{i?r(i):o(void 0)})});try{await Rn.lock(t),await e}finally{Rn.release(t)}}function qa(n,t){Object.entries(t).forEach(([e,o])=>{n.dataset[e]=`${o}`})}function Wa(n,t){Object.entries(t).forEach(([e,o])=>{n.setAttribute(e,o)})}function Ga(n,t){Object.entries(t).forEach(([e,o])=>{n.style.setProperty(e,o)})}function wi(n){let t=0,e=0,o=n;do t+=o.offsetTop||0,e+=o.offsetLeft||0,o=o.offsetParent;while(o);return{top:t,left:e}}function Bi(n,t){return!n.target||!(n.target instanceof Element)?null:n.target.closest(t)}class A8{constructor(t){h(this,"element");this.element=t}getHorizontalScroll(){return this.element.scrollLeft}getVerticalScroll(){return this.element.scrollTop}getMaxHorizontalScroll(){return this.element.scrollWidth-this.element.clientWidth}getMaxVerticalScroll(){return this.element.scrollHeight-this.element.clientHeight}getHorizontalElementScrollOffset(t,e){return wi(t).left-wi(e).left}getVerticalElementScrollOffset(t,e){return wi(t).top-wi(e).top}scrollTo(t,e){this.element.scrollLeft=t,this.element.scrollTop=e}}class O8{constructor(){h(this,"element",window)}getHorizontalScroll(){return window.scrollX||document.documentElement.scrollLeft}getVerticalScroll(){return window.scrollY||document.documentElement.scrollTop}getMaxHorizontalScroll(){return Math.max(document.body.scrollWidth,document.documentElement.scrollWidth,document.body.offsetWidth,document.documentElement.offsetWidth,document.body.clientWidth,document.documentElement.clientWidth)-window.innerWidth}getMaxVerticalScroll(){return Math.max(document.body.scrollHeight,document.documentElement.scrollHeight,document.body.offsetHeight,document.documentElement.offsetHeight,document.body.clientHeight,document.documentElement.clientHeight)-window.innerHeight}getHorizontalElementScrollOffset(t){return(window.scrollX||document.documentElement.scrollLeft)+t.getBoundingClientRect().left}getVerticalElementScrollOffset(t){return(window.scrollY||document.documentElement.scrollTop)+t.getBoundingClientRect().top}scrollTo(t,e){window.scrollTo(t,e)}}const An={elements:[],cancelMethods:[],add:(n,t)=>{An.elements.push(n),An.cancelMethods.push(t)},remove:(n,t)=>{const e=An.elements.indexOf(n);e>-1&&(t&&An.cancelMethods[e](),An.elements.splice(e,1),An.cancelMethods.splice(e,1))}},qf=typeof window<"u",_8={cancelOnUserAction:!0,easing:n=>--n*n*n+1,elementToScroll:qf?window:null,horizontalOffset:0,maxDuration:3e3,minDuration:250,speed:500,verticalOffset:0};async function Ei(n,t={}){if(!qf)return new Promise(O=>{O(!1)});if(!window.Promise)throw"Browser doesn't support Promises, and animated-scroll-to depends on it, please provide a polyfill.";let e,o,r;const i={..._8,...t},s=i.elementToScroll===window,l=!!i.elementToScroll.nodeName;if(!s&&!l)throw"Element to scroll needs to be either window or DOM element.";const c=s?document.documentElement:i.elementToScroll;getComputedStyle(c).getPropertyValue("scroll-behavior")==="smooth"&&console.warn(`${c.tagName} has "scroll-behavior: smooth" which can mess up with animated-scroll-to's animations`);const u=s?new O8:new A8(i.elementToScroll);if(n instanceof Element){if(r=n,l&&(!i.elementToScroll.contains(r)||i.elementToScroll.isSameNode(r)))throw"options.elementToScroll has to be a parent of scrollToElement";e=u.getHorizontalElementScrollOffset(r,i.elementToScroll),o=u.getVerticalElementScrollOffset(r,i.elementToScroll)}else if(typeof n=="number")e=u.getHorizontalScroll(),o=n;else if(Array.isArray(n)&&n.length===2)e=n[0]===null?u.getHorizontalScroll():n[0],o=n[1]===null?u.getVerticalScroll():n[1];else throw`Wrong function signature. Check documentation.
12
12
  Available method signatures are:
13
13
  animateScrollTo(y:number, options)
14
14
  animateScrollTo([x:number | null, y:number | null], options)
15
- animateScrollTo(scrollToElement:Element, options)`;e+=i.horizontalOffset,o+=i.verticalOffset;const f=u.getMaxHorizontalScroll(),m=u.getHorizontalScroll();e>f&&(e=f);const C=e-m,v=u.getMaxVerticalScroll(),w=u.getVerticalScroll();w<o?o-=window.innerHeight*3/4:o-=window.innerHeight*1/4,o>v&&(o=v);const E=o-w,L=Math.abs(Math.round(C/1e3*i.speed)),x=Math.abs(Math.round(E/1e3*i.speed));let A=L>x?L:x;return A<i.minDuration?A=i.minDuration:A>i.maxDuration&&(A=i.maxDuration),new Promise((O,P)=>{C===0&&E===0&&O(!0),An.remove(u.element,!0);let U;const tt=()=>{oe(),cancelAnimationFrame(U),O(!1)};An.add(u.element,tt);const ot=Fe=>Fe.preventDefault(),ut=i.cancelOnUserAction?tt:ot,dt=i.cancelOnUserAction?{passive:!0}:{passive:!1},yt=["wheel","touchstart","keydown","mousedown"],oe=()=>{yt.forEach(Fe=>{u.element.removeEventListener(Fe,ut,dt)})};yt.forEach(Fe=>{u.element.addEventListener(Fe,ut,dt)});const Jn=Date.now(),Xt=()=>{const Fe=Date.now()-Jn,vo=Fe/A,ar=Math.round(m+C*i.easing(vo)),dr=Math.round(w+E*i.easing(vo));Fe<A&&(ar!==e||dr!==o)?(u.scrollTo(ar,dr),U=requestAnimationFrame(Xt)):(u.scrollTo(e,o),cancelAnimationFrame(U),oe(),An.remove(u.element,!1),O(!0))};U=requestAnimationFrame(Xt)})}function To(n,t,e){return n.left<=t&&t<=n.right&&n.top<=e&&e<=n.bottom}function N8(n){const t="\xA0";if(!n)return"";if(n===" ")return t;let e=n;return e.startsWith(" ")&&(e=t+e.substr(1)),e.endsWith(" ")&&(e=e.substr(0,e.length-1)+t),e=e.replace(/ {2}/g,` ${t}`),e}function Wf(n){if(!/["'&<>]/.exec(n))return n;const o={'"':"&quot;","'":"&#39;","&":"&amp;","<":"&lt;",">":"&gt;"};return n.split("").map(l=>o[l]||l).join("")}function Gf(n){const t=document.getElementById(n);t&&t.remove()}function Zf(n,t){const e=document.getElementById(t);if(e)return e.textContent=n,e;const o=document.createElement("style");return o.id=t,o.textContent=n,document.head.append(o),o}function Ii(n){const t="custom-cursor-style";if(n){const e=`body * { cursor: ${n} !important}`;Zf(e,t)}else Gf(t)}const Yf=3,Qf=y("drag-drop");class Kf{constructor(t){h(this,"dragStarted",!1);h(this,"mouseDownEvent",null);h(this,"_dragOffsetX",0);h(this,"_dragOffsetY",0);h(this,"handleMouseDown",t=>{t.preventDefault(),t.stopPropagation(),this.mouseDownEvent=t;const e=this.options.elem.getBoundingClientRect();this._dragOffsetX=this.mouseDownEvent.x-e.left,this._dragOffsetY=this.mouseDownEvent.y-e.top,this.bindEvents()});h(this,"handleMouseMove",t=>{var i;t.preventDefault(),t.stopPropagation(),d(Qf,this.mouseDownEvent,"no mouse down event");const e=t.x-this.mouseDownEvent.x,o=t.y-this.mouseDownEvent.y;if(this.dragStarted){this.onDragging(t,e,o);return}const r=(i=this.options.minThreshold)!=null?i:Yf;(Math.abs(e)>=r||Math.abs(o)>=r)&&this.onDragStart(this.mouseDownEvent)});h(this,"handleMouseUp",t=>{if(t.button===0){d(Qf,this.mouseDownEvent,"no mouse down event");const e=t.x-this.mouseDownEvent.x,o=t.y-this.mouseDownEvent.y;this.onDragEnd(t,e,o),t.preventDefault(),t.stopPropagation()}});this.options=t,this.options.mouseDownEvent?this.handleMouseDown(this.options.mouseDownEvent):this.trackEvents()}get data(){return this.options.data}get dragOffsetX(){return this._dragOffsetX}get dragOffsetY(){return this._dragOffsetY}get dragOffset(){return{x:this._dragOffsetX,y:this._dragOffsetY}}trackEvents(){this.options.elem.addEventListener("mousedown",this.handleMouseDown)}untrackEvents(){this.options.elem.removeEventListener("mousedown",this.handleMouseDown)}bindEvents(){document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}unbindEvents(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}onDragStart(t){this.dragStarted=!0,this.options.cursor&&Ii(this.options.cursor),this.options.onDragStart(this,t,this.options.elem)}onDragging(t,e,o){this.options.onDragging(this,t,this.options.elem,e,o)}onDragEnd(t,e,o){this.options.cursor&&Ii(null),this.dragStarted&&this.options.onDragEnd(this,t,this.options.elem,e,o),this.unbindEvents(),this.dragStarted=!1}destroy(){this.unbindEvents(),this.untrackEvents()}}function Za(n){return new Kf(n)}const P8=y("character");function Jf(n,t){for(let e=0;e<t.length;e++){const o=t[e][0],r=t[e].length>1?t[e][1]:null;if(r===null&&n===o||r!==null&&n>=o&&n<=r)return!0}return!1}function Xf(n){const t=n.charAt(0);return t>="0"&&t<="9"}function tm(n){const t=n.charAt(0);return t>="a"&&t<="z"||t>="A"&&t<="Z"||t.toUpperCase()!==t.toLowerCase()?!0:RegExp(/^\p{L}/,"u").test(t)}function tl(n){const t=[[9,13],[32],[160]];return Jf(n.charCodeAt(0),t)}function em(n){const t=[[12352,12687],[13056,13183],[13312,15661],[19968,40959],[63744,64255],[44032,55215]];return Jf(n.charCodeAt(0),t)}function Ya(n,t){let e=t;return d(P8,e.length===1,"invalid char length"),e==="]"&&(e="\\]"),e==="\\"&&(e="\\\\"),n.replace(new RegExp(`^[${e}]+|[${e}]+$`,"g"),"")}const On=navigator.userAgent;function nm(){const n=navigator.userAgent.toLowerCase();return n.indexOf("safari")!==-1&&!(n.indexOf("chrome")>-1)}function Qa(){return navigator.userAgent.toLowerCase().indexOf("firefox")>-1}const It={isAndroid:!!On.match(/Android/i),isIOS:!!On.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/i),isIPad:!!On.match(/iPad/i),isIPhone:!!On.match(/iPhone/i),isLinux:!!On.match(/Linux/i),isMac:!!On.match(/Macintosh/i),isMobile:!!On.match(/AppleWebKit.*Mobile.*/i),isWindows:!!On.match(/Window/i),isIe:!!On.match(/msie|trident/i),isSafari:nm(),isMobileSafari:!1};It.isMobileSafari=It.isMobile&&It.isSafari;function Ka(n){return n?n.length===1||n==="Process"||n==="Unidentified"&&It.isAndroid:!1}function om(n){switch(n){case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":case"End":case"Home":case"PageDown":case"PageUp":return!0;default:return!1}}function $8(n){return om(n.key)}function H8(n){switch(n){case"ArrowUp":case"ArrowLeft":case"Home":case"PageUp":return!0;default:return!1}}function Do(n){return n.ctrlKey||n.altKey||n.shiftKey||n.metaKey}function j8(n){return n.key?!!(n.ctrlKey||n.metaKey||n.altKey):!1}function rm(n){return It.isMac?n.metaKey&&!n.ctrlKey:!n.metaKey&&n.ctrlKey}function F8(n){return rm(n)&&!n.altKey&&!n.shiftKey}function z8(n){return!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&n.altKey}function im(n){return!Do(n)&&n.key==="Enter"}function V8(n){return n.key==="Enter"&&n.shiftKey&&!n.altKey&&!n.ctrlKey&&!n.metaKey}function Ja(n){return!Do(n)&&n.key==="Escape"}function U8(n){return!Do(n)&&n.key==="Delete"}function sm(n){return!Do(n)&&n.key==="Backspace"}function q8(n){return!Do(n)&&n.key==="Tab"}function W8(n){return n.shiftKey&&n.key==="Tab"&&!n.ctrlKey&&!n.metaKey}function G8(n){if(!n)return"";if(It.isMac){const t=n.replace("CtrlOrCmd","\u2318").replace("Shift","\u21E7").replace("Ctrl","\u2303").replace("Alt","\u2325").replace(/\+(?!$)/gm,""),e={"\u2318":4,"\u21E7":3,"\u2325":2,"\u2303":1};return t.split(/(?=[\s\S])/u).sort((r,i)=>{var c,a;const s=(c=e[r])!=null?c:5,l=(a=e[i])!=null?a:5;return s-l}).join("")}return n.replace("CtrlOrCmd","Ctrl")}function lm(n){const t={ctrl:!1,alt:!1,shift:!1,cmd:!1,key:""},e=n.toLocaleUpperCase().split("+");for(let o=0;o<e.length;o++){const r=e[o];r==="CTRL"||r==="CONTROL"?t.ctrl=!0:r==="ALT"||r==="OPTION"?t.alt=!0:r==="SHIFT"?t.shift=!0:r==="CMD"||r==="COMMAND"?t.cmd=!0:r==="CMDORCTRL"||r==="CTRLORCMD"?It.isMac?t.cmd=!0:t.ctrl=!0:r==="SPACE"?t.key=" ":t.key=r.substring(0,1)+r.substring(1).toLocaleLowerCase()}return t}function _n(n,t){const e=lm(t);return e.ctrl!==n.ctrlKey||e.alt!==n.altKey||e.shift!==n.shiftKey||It.isMac&&e.cmd!==n.metaKey?!1:e.key.length===1?e.key===n.key.toUpperCase():e.key.toUpperCase()===n.key.toUpperCase()}function Xa(n,t){return P7.stringifyUrl({url:n,query:t})}function Lo(n){return typeof n=="string"?pi.Base64.encode(n,!0):pi.Base64.fromUint8Array(n,!0)}function el(n){return pi.Base64.decode(n)}function Z8(n){return pi.Base64.toUint8Array(n)}function cm(n){return new Blob([pi.Base64.toUint8Array(n)])}const Y8=to.init([to.classModule,to.styleModule,to.datasetModule,to.attributesModule,to.propsModule]);function xi(n,t){const e=to.toVNode(n),o=to.toVNode(t);Y8(e,o)}async function am(n,t){const e=new FileReader,o=new Promise((i,s)=>{e.onload=i,e.onerror=s});return e.readAsDataURL(new Blob([n],{type:t})),await o,e.result}async function nl(n){const t=new FileReader,e=new Promise((r,i)=>{t.onload=r,t.onerror=i});return t.readAsDataURL(n),await e,t.result}function Q8(n,...t){const e=n.tagName.toLowerCase();for(let o=0,r=t.length;o<r;o++)if(e===t[o].toLowerCase())return!0;return!1}function Nn(n){let t=n;for(;t;){const e=window.getComputedStyle(t);if(/auto|scroll/i.test(e.overflowY))break;t=t.parentElement}return(!t||Q8(t,"body"))&&(t=document.documentElement),t}function dm(n){if(document.querySelector(`.editor-disable-scroll[data-scroll-id="${n}"]`))return;const t=b("div",["editor-disable-scroll"],null);t.setAttribute("data-scroll-id",n),t.onwheel=e=>{e.preventDefault(),e.stopPropagation()},document.body.appendChild(t)}function um(n){var t;(t=document.querySelector(`.editor-disable-scroll[data-scroll-id="${n}"]`))==null||t.remove()}function t1(n,t,e){const o=new Blob([n]),r=new File([o],e,{type:t});return URL.createObjectURL(r)}function ol(n){const t=document.createElement("template");if("content"in t)return t.innerHTML=n,document.importNode(t.content,!0);const e=document.createDocumentFragment(),o=document.createElement("div");for(o.innerHTML=n;o.firstChild;)e.appendChild(o.firstChild);return e}function hm(n){const t=document.createElement("div");return t.appendChild(n),t.innerHTML}function fm(n){let t=n.getPropertyValue("font");if(t)return t;const e=n.getPropertyValue("font-style"),o=n.getPropertyValue("font-variant"),r=n.getPropertyValue("font-weight"),i=n.getPropertyValue("font-size"),s=n.getPropertyValue("font-family");return t=`${e} ${o} ${r} ${i} ${s}`.replace(/ +/g," ").trim(),t}function rl(n,t){const o=(rl.canvas||(rl.canvas=document.createElement("canvas"))).getContext("2d");return o?(typeof t=="string"?t?o.font=t:o.font=fm(window.getComputedStyle(document.body)):t instanceof Element&&(o.font=fm(window.getComputedStyle(t))),o.measureText(n).width+4):200}const K8=y("editor-clipboard");async function J8(n,t){if(t.clipboardData){const e=t.clipboardData;for(const o of n)e.setData(o.type,o.data);return!0}return!1}async function il(n){try{const t={};n.forEach(o=>{t[o.type]=o.data});const e=new ClipboardItem(t);return await navigator.clipboard.write([e]),!0}catch(t){return K8.error(t),!1}}function fr(n,t){return new Promise((e,o)=>{const r=document.createElement("input");r.type="file",r.style.display="none",t!=null&&t.multiple&&(r.multiple=!0),r.accept=n,r.onchange=()=>{const i=r.files;if(i){const s=t!=null&&t.multiple?Array.from(i):i[0];e(s)}r.remove()},r.onerror=i=>{o(i),r.remove()},r.click()})}function sl(n){return Array.isArray(n)?n.every(t=>t instanceof File):!1}function mm(n){const t=n;if(!t)return"";const e=t.lastIndexOf(".");return e===-1?"":t.slice(e+1)}function ll(n,t){const e=document.createElement("a");e.setAttribute("download",`${t||""}`),e.setAttribute("href",`${n}`),e.click(),e.remove()}const gm=y("auto-scroll");function pm(n,t){return!(n.scrollHeight===n.clientHeight||t==="top"&&n.scrollTop===0||t==="bottom"&&n.scrollTop+n.clientHeight===n.scrollHeight||t==="left"&&n.scrollLeft===0||t==="right"&&n.scrollLeft+n.clientWidth===n.scrollWidth)}function Cm(n,{direction:t,step:e}){let o=null;const r=t==="left"||t==="right",i=()=>{if(!pm(n,t))return gm.debug("No need for scroll"),null;if(r){const s=n.scrollLeft,l=t==="left"?s-e:s+e;n.scrollLeft=l}else{const s=n.scrollTop,l=t==="top"?s-e:s+e;n.scrollTop=l}return o=requestAnimationFrame(i),o};return o=requestAnimationFrame(i),()=>{o&&cancelAnimationFrame(o)}}class bm{constructor(t){h(this,"cancelScroll",null);h(this,"options");h(this,"scrollDomInfo");h(this,"scrolling",!1);h(this,"getScrollingDirection",t=>{const{x:e,y:o}=t,{top:r,bottom:i,left:s,right:l}=this.scrollDomInfo,{edge:c}=this.options;return c.top&&o>=r&&o<=c.top+r?"top":c.bottom&&o<=i&&o>=i-c.bottom?"bottom":c.left&&e>=s&&e<=s+c.left?"left":c.right&&e<=l&&e>=l-c.right?"right":null});h(this,"handleMouseMove",t=>{var s;const{scrollElement:e,step:o=10,onDirectionChange:r}=this.options,i=this.getScrollingDirection(t);if(i){if(this.scrolling)return;gm.debug(`scroll direction: ${i}`),this.cancelScroll=Cm(e,{direction:i,step:o}),r==null||r(i),this.scrolling=!0}else(s=this.cancelScroll)==null||s.call(this),this.scrolling=!1});this.options=t,this.scrollDomInfo=this.getScrollDomInfo()}getScrollDomInfo(){const{scrollElement:t}=this.options,e=t.clientTop,o=t.clientLeft,r=t.clientHeight,i=t.clientWidth;return{left:o,top:e,right:i,bottom:r}}active(){const{trackMouseEvent:t="mousemove"}=this.options;window.addEventListener(t,this.handleMouseMove,!0)}inactive(){var e;const{trackMouseEvent:t="mousemove"}=this.options;window.removeEventListener(t,this.handleMouseMove,!0),(e=this.cancelScroll)==null||e.call(this),this.scrolling=!1}}function vm(n,t){if(n===0)return"0 Bytes";const e=1024,o=t||2,r=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],i=Math.floor(Math.log(n)/Math.log(e));return`${parseFloat((n/e**i).toFixed(o))} ${r[i]}`}function e1(n,t){let e=`${n}`;const o=t-e.length;for(let r=0;r<o;r++)e=`0${e}`;return e}const{t:Mo}=S;function n1(n,t){const e=new Date(n).getTime()+864e5*t;return new Date(e)}function X8(n,t){const e=n,o=Math.floor(t/12),r=t-o*12;return o&&e.setFullYear(e.getFullYear()+o),r&&e.setMonth(e.getMonth()+r),e}function tC(n,t){return n1(n,t)}function o1(n,t){const e=new Date(n),o=new Date(t);return e.getDate()===o.getDate()&&e.getMonth()===o.getMonth()&&e.getFullYear()===o.getFullYear()}function km(n){const t=new Date,e=new Date(n);return o1(t,e)}function ym(n){const t=n1(new Date,-1);return o1(t,n)}function eC(n,t){return Math.round((n.getTime()-t.getTime())/864e5)}function wm(n,t){const e=new Date(n);if(t){const o=e.getFullYear(),r=e.getMonth()+1,i=e.getDate();let s=t;return s=s.replace("yyyy",`${o}`),s=s.replace("mm",e1(r,2)),s=s.replace("dd",e1(i,2)),s=s.replace("m",`${r}`),s=s.replace("d",`${i}`),s}return n.toLocaleDateString()}function r1(n,t){const e=new Date(n),o=new Date;if(e.getTime()-o.getTime()>10*1e3)return S.t("date.dateFromFuture");if(km(e)){const i=(o.getTime()-n.getTime())/1e3;if(i<10*60)return Mo("date.dateJustNow");if(i<60*60)return Mo("date.dateMinutesAgo",{num:`${Math.floor(i/60)}`});const s=Math.floor(i/60/60);return s===1?Mo("date.date1HourAgo"):Mo("date.dateHoursAgo",{num:`${s}`})}if(ym(n))return Mo("date.dateYesterday");const r=Math.floor((o.getTime()-n.getTime())/1e3/24/60/60)+1;return r<14?Mo("date.dateDaysAgo",{num:`${r}`}):r<28?Mo("date.dateWeeksAgo",{num:`${Math.round(r/7)}`}):wm(n,t)}function i1(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function nC(n,t,e){return n.replace(new RegExp(i1(t),"g"),e)}function oC(n,t,e){return n.replace(new RegExp(i1(t),"gi"),e)}const Bm=y("container-children");function Rt(n){const t=Array.from(n.querySelectorAll(":scope > .container-blocks > div[data-type=editor-block]"));return d(Bm,t.length>0,"container have not any child block"),t}function Qt(n){const t=n.querySelector(":scope > .container-blocks > div[data-type=editor-block]");return d(Bm,t,"container have not any child block"),t}function Gt(n){const t=Rt(n);return t[t.length-1]}function Ve(n){return Rt(n).length}function mr(n,t){return Rt(n)[t]}const Ue=y("block-dom");function gr(n){return n instanceof HTMLDivElement?n.getAttribute("data-type")==="editor-block":!1}function Em(n){M(n,"block-hidden")}function Im(n){F(n,"block-hidden")}function cl(n){return!lt(n,"block-hidden")}function G(n){const{id:t}=n;return d(Ue,t,"no block id"),t}function it(n){const t=n.getAttribute("data-block-type");return d(Ue,t,"invalid block dom, no data-type"),t}function z(n){const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest("div[data-type=editor-block]");return e||null}function H(n){const t=n.closest("div[data-type=editor-container]");return d(Ue,t,"failed to get block container"),t}function rt(n){const t=n.querySelector(":scope >div[data-type=block-content]");return d(Ue,t,"no block content"),t}function At(n){let t=n.querySelector(":scope >div[data-type=block-tools]");return t||(t=b("div",[],n),t.setAttribute("data-type","block-tools")),d(Ue,t,"no block tools"),t}function al(n){const t=n.querySelector(":scope >div[data-type=block-tools]");return t||null}function xm(n){let t=n.querySelector(":scope > div[data-type=block-background]");return t||(t=b("div",[],n),t.setAttribute("data-type","block-background")),t}function Sm(n,t,e){const o=n.editorDecorators.decorateBlock(t,e),{id:r,type:i}=o;d(Ue,r,"no block id");const s=b("div",[`${i}-block`],null);s.id=r,s.setAttribute("data-type","editor-block"),s.setAttribute("data-block-type",i);const l=n.editorBlockRenders.renderBlock(n,t,e);return l.classes&&M(s,...l.classes),l.attributes&&Object.entries(l.attributes).forEach(([c,a])=>{s.setAttribute(c,a)}),l.styles&&Object.entries(l.styles).forEach(([c,a])=>{s.style.setProperty(c,a)}),s}function eo(n,t){const e=b(t,[],null);return e.setAttribute("data-type","block-content"),n&&n.appendChild(e),e}function Tm(n){const t=b("span",[`${n.type}-box`],null);return t.setAttribute("data-type","editor-box"),t.setAttribute("data-box-type",n.type),t.id=n.id,t}function Si(n){const t=n.getAttribute("data-box-type");return d(Ue,t,"not a valid box element, no type"),t}function s1(n){return n instanceof HTMLSpanElement?n.getAttribute("data-type")==="editor-box":!1}function Dm(n){const{id:t}=n;return d(Ue,t,"no box id"),t}function l1(n){const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest("span[data-type=editor-box]");return e||null}function Lm(n){n.innerHTML="",b("span",["box-space-start"],n,yi);const t=b("span",[],n);return t.setAttribute("data-type","box-content"),b("span",["box-space-start"],n,yi),t}function c1(n){const t=n.querySelector("span[data-type=box-content]");return d(Ue,t,"invalid box dom, no content"),t}function Mm(n,t){const e=b("span",[`${n}-insertion`],null);return e.setAttribute("data-type","editor-insertion"),e.setAttribute("data-insertion-id",t),e}function Rm(n,t){return n.rootContainer.querySelector(`[data-insertion-id=${t}]`)}function Am(n){n.innerHTML="",b("span",["insertion-space-start"],n,yi);const t=b("span",[],n);return t.setAttribute("data-type","insertion-content"),b("span",["insertion-space-start"],n,yi),t}function a1(n){const t=n.querySelector("span[data-type=insertion-content]");return d(Ue,t,"invalid insertion-child dom, no content"),t}function gt(n){let t=n.previousElementSibling;for(;t;){if(gr(t))return t;t=t.nextElementSibling}return null}function ht(n){let t=n.nextElementSibling;for(;t;){if(gr(t))return t;t=t.nextElementSibling}return null}function pr(n){let t=n.previousElementSibling;for(;t;){if(gr(t)&&cl(t))return t;t=t.previousElementSibling}return null}function Cr(n){let t=n.nextElementSibling;for(;t;){if(gr(t)&&cl(t))return t;t=t.nextElementSibling}return null}function K(n){const t=H(n),o=Rt(t).indexOf(n);return d(Ue,o!==-1,"invalid block & container dom, failed to get block index"),o}function d1(n){return!n||!(n instanceof Node)?!1:!!z(n)}function Ti(n){if(!d1(n))return!1;const t=n,e=t instanceof Element?t:t.parentElement;return e?!!e.closest("div[data-type=block-tools]"):!1}const Om=y("element");function u1(n,t,e){const o=b("div",[t],n);return o.setAttribute("data-type","editor-container"),o.setAttribute("data-container-id",e),b("div",["container-blocks"],o),o}function br(n,t){const e=n.rootElement.querySelector(`[data-container-id=${t}`);return d(Om,e,`no container: ${t}`),e}function _m(n,t){return n.rootElement.querySelector(`[data-container-id=${t}`)}function dl(n){const t=n.querySelector(":scope > .container-blocks");return d(Om,t,"no container blocks element"),t}function rC(n){let t=n.querySelector(":scope > .container-tools");return t||(t=b("div",["container-tools"],n)),t}const Nm=y("container");function fn(n){return n.getAttribute("data-type")==="editor-container"}function Ct(n){return lt(n,"root")}function qe(n){return lt(n,"child")}function V(n){const t=n.getAttribute("data-container-id");return d(Nm,t,"no id for container"),Ct(n)&&d(Nm,t==="root",`invalid root container id, : ${t}`),t}function Pm(n,t){const e=V(n);return t.getContainerBlocks(e)}const $m=y("block-path");function Ro(n){const t=[];let e=n;for(;e;){const o=H(e);if(t.unshift({containerId:V(o),blockIndex:K(e)}),Ct(o))return t;const r=z(o);d($m,r,"no parent block"),e=r}return d($m,!1,"no parent block"),[]}const iC=y("child-container-path");function Hm(n){if(Ct(n))return[];const t=z(n);return d(iC,t,"no parent block"),Ro(t)}const jm=y("load-blocks");function h1(n,t,e){const o=V(t),r=Pm(t,n.doc);d(jm,r.length>0,"no blocks in container");const i=document.createDocumentFragment();r.forEach((l,c)=>{const a=n.editorBlocks.createBlock([...e,{containerId:o,blockIndex:c}],t,l);i.appendChild(a)}),dl(t).appendChild(i)}function sC(n,t,e){const o=dl(n),r=Rt(n);return d(jm,t>=0&&t<=r.length,"invalid block index"),t===r.length?o.appendChild(e):o.insertBefore(e,r[t]),e}function lC(n,t,e,o){const r=Hm(t);r.push({containerId:V(t),blockIndex:e});const i=n.editorBlocks.createBlock(r,t,o);return sC(t,e,i),i}const Fm=y("root-container");class cC{constructor(t,e){h(this,"resizeObserver");h(this,"handleContextMenu",t=>{t.preventDefault()});h(this,"handleResize",()=>{try{this.editor.selection.updateSelection(null),this.editor.emit("resize",this.editor)}catch(t){Fm.warn(`failed to update selection while container resizing: ${t.message}`)}});h(this,"handleClick",t=>{var o,r;this.editor.emit("click",this.editor,t);const e=t.target;if(!Ti(e)&&(t.detail===1&&this.editor.input.focus(),t.detail===3&&this.editor.selectionHandler.handleTripleClick(t),t.detail===1&&t.button===0)){const i=document.elementFromPoint(t.clientX,t.clientY);if(i&&vt(this.rootContainer,i)){const s=l1(i);if(s){const l=z(s);d(Fm,l,"no parent block"),(r=(o=this.editor.editorBoxes.getBoxClass(Si(s)))==null?void 0:o.handleClickBox)==null||r.call(o,this.editor,s,t)}}}});h(this,"handleDblClick",t=>{Ti(t.target)||this.editor.selectionHandler.handleDblClick(t)});h(this,"handleMouseDown",t=>{const e=t.target;if(!!e&&e instanceof Node&&!Ti(e)){if(e instanceof HTMLElement&&e.draggable){this.editor.selectionHandler.handleMouseDown(t),this.editor.selectionHandler.stopSelection(),this.editor.input.focus();return}t.button===0&&(document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),this.editor.selectionHandler.handleMouseDown(t)),It.isMobileSafari||(t.preventDefault(),this.editor.input.focus()),t.button===2&&t.stopPropagation()}});h(this,"handleMouseMove",t=>{this.editor.selectionHandler.handleMouseMove(t)});h(this,"handleMouseUp",t=>{t.button===0&&(this.editor.selectionHandler.handleMouseUp(t),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp))});this.editor=t,this.rootContainer=e,this.editor=t,this.resizeObserver=new ResizeObserver(this.handleResize),this.bindEvents(e)}bindEvents(t){this.resizeObserver.observe(t);const e=this.editor.rootElement;e.onmousedown=this.handleMouseDown,e.ondblclick=this.handleDblClick,e.onclick=this.handleClick,e.oncontextmenu=this.handleContextMenu}unbindEvents(){this.resizeObserver.disconnect();const t=this.editor.rootElement;t.onmousedown=null,t.ondblclick=null,t.onclick=null,t.oncontextmenu=null}destroy(){this.unbindEvents()}reload(){const t=this.editor.selection.range,e=dl(this.rootContainer);e.innerHTML="",h1(this.editor,this.rootContainer,[]);const o=this.editor.findBlockById(t.start.blockId);if(o)this.editor.selection.selectBlock(o,0);else{const r=Qt(this.rootContainer);this.editor.selection.selectBlock(r,0)}}}function zm(n){const t=u1(n.contentElement,"root","root");return n.rootContainer=t,h1(n,t,[]),new cC(n,t)}function Vm(n,t,e,o){const r=_m(n,o);if(r)return e.appendChild(r),r;const i=u1(e,"child",o);return h1(n,i,t),i}const Um=y("block-class");function kt(n,t){return n.editorBlocks.getBlockClass(it(t))}function qm(n,t){const e=n.editorBlocks.getBlockClass(it(t));return d(Um,e.blockKind==="text",`is not a text block, ${e.blockType}`),e}function ve(n,t){const e=n.editorBlocks.getBlockClass(it(t));return d(Um,e.blockKind==="complex",`is not a text block, ${e.blockType}`),e}function vr(n,t){return n.editorBlocks.getBlockClass(t)}const f1=y("block");function Z(n,t){return kt(n,t).getBlockTextLength(t)}function Wm(n){n.editorBlocks.forEach(t=>{t.clearSelection(n)})}function Gm(n,t,e,o){kt(n,t).updateSelection(n,t,e,o)}function ul(n){for(;;){const t=H(n);if(Ct(t))return n;const e=z(t);d(f1,e,"no parent block exists for child container"),n=e}}function Zm(n,t){const e=kt(n,t);if(!!e.getMinWidth)return e.getMinWidth(n,t)}function Ym(n,t,e){const o=kt(n,t);o.handleBlockElementUpdated&&o.handleBlockElementUpdated(n,t,e)}function hl(n,t,e,o){try{const r=vr(n,e).convertFrom;return r?r(n,t,o):null}catch{return f1.debug(`unsupported block type: ${e}`),null}}function Ao(n,t,e){const o=kt(n,t);return o.getClientRects?o.getClientRects(n,t,e):[t.getBoundingClientRect()]}function aC(n,t){const e=kt(n,t);if(e.getBlockStyles)return e.getBlockStyles(n,t);const o=n.getBlockData(t),r=Object.fromEntries(Object.entries(o).filter(([i])=>i.startsWith("style-")));return Object.entries(r).forEach(([,i])=>{const s=typeof i;d(f1,s==="string"||s==="number"||s==="boolean","invalid style value")}),r}function Qm(n,t){const e=n.getBoundingClientRect().width;return t.withPadding?e:e-Ua(n)}function m1(n,t){let e=Number.MAX_SAFE_INTEGER;const o=Rt(t);for(let i=0;i<o.length;i++){const s=o[i],l=Zm(n,s);l&&(e=Math.min(e,l))}return e===Number.MAX_SAFE_INTEGER?void 0:e+Ua(t)}function j(n,t){return kt(n,t).blockKind==="text"}function Di(n,t){return n.editorBlocks.getBlockClass(t).blockKind==="text"}function ct(n,t){return kt(n,t).blockKind==="complex"}function dC(n,t){return!ct(n,t)}function We(n,t){return kt(n,t).blockKind}function wt(n,t){return We(n,t)==="text"?Z(n,t)===0:!1}function g1(n,t){const e=Rt(t);return e.length!==1?!1:wt(n,e[0])}function Ge(n,t,e){return kt(n,t).getCaretRect(t,e)}function uC(n,t){var r,i;const e=kt(n,t);return(i=(r=e.getOptions)==null?void 0:r.call(e,n))!=null?i:{name:it(t)}}function Km(n,t){var r;const e=kt(n,t);return(r=e.getBlockProperties)==null?void 0:r.call(e,n,t)}function p1(n,t){var i,s;const e=kt(n,t),o=(i=e.getBlockProperties)==null?void 0:i.call(e,n,t);let r={};o!=null&&o.blockCommands&&(r={...o.blockCommands});for(const l of n.blockHooks){const c=(s=l.commands)==null?void 0:s.call(l,n,t);c&&(r[c.group]=c)}return r}function Jm(n,t,e){var s,l,c,a;const o=kt(n,t),r=(s=o.getBlockProperties)==null?void 0:s.call(o,n,t);let i={};r!=null&&r.blockCommands&&(i={...r.blockCommands});for(const u of n.blockHooks){const f=(l=u.commands)==null?void 0:l.call(u,n,t);f&&(i[f.group]=f)}return(a=(c=i[e])==null?void 0:c.commands)!=null?a:[]}const Xm=y("embed-block-common");function Te(n){return it(n)==="embed"}function De(n){d(Xm,Te(n),"not an embed block");const t=n.getAttribute("data-embed-type");return d(Xm,t,"no embed data type"),t}function hC(n,t){return n.editorEmbeds.getEmbedClass(De(t))}function Oo(n,t){return n.editorEmbeds.getEmbedClass(t)}async function tg(n,t,e,o,r){const i=Oo(n,t);if(!i.getOptions)return null;const s=i.getOptions(n);if(!s.insertEmbedCommandItems||!s.insertEmbedCommandItems||s.insertEmbedCommandItems.length===0||!s.handleInsertEmptyEmbed)return null;const l=s.insertEmbedCommandItems[0];return s.handleInsertEmptyEmbed(n,{item:l,containerId:e,blockIndex:o,data:r})}function fC(n,t,e,o,r){var l,c;const i=(c=(l=vr(n,t)).getOptions)==null?void 0:c.call(l,n);if(!i||!i.insertBlockCommandItems||i.insertBlockCommandItems.length===0||!i.handleInsertEmptyBlock)return null;const s=i.insertBlockCommandItems[0];return i.handleInsertEmptyBlock(n,{item:s,containerId:e,blockIndex:o,data:r})}const mC=y("execute-block-command");function eg(n,t,e,o){var a;d(mC,Te(t),"not a embed block");const r=De(t),i=Oo(n,r);if(!i.getOptions)return;const s=(a=i.getBlockProperties)==null?void 0:a.call(i,n,t),l=s==null?void 0:s.blockCommands;if(!l)return;const c=Object.entries(l);for(const u of c)if(u[0]===e)return u[1].executeCommand(n,t,o)}function ng(n,t,e,o){const r=p1(n,t);if(!r)return;const i=Object.entries(r);for(const s of i)if(s[0]===e)return s[1].executeCommand(n,t,o)}const gC=y("complex-block-position");class Ze{constructor(t,e,o){h(this,"blockId");h(this,"childContainerId");h(this,"custom");t instanceof HTMLElement?this.blockId=G(t):(d(gC,typeof t=="string",`not a valid block id: ${t}`),this.blockId=t),this.childContainerId=e,o!==void 0&&(this.custom=o)}isSimple(){return!1}}const pC=y("simple-block-position");class Vt{constructor(t,e,o){h(this,"blockId");h(this,"offset");h(this,"type");t instanceof HTMLElement?this.blockId=G(t):(d(pC,typeof t=="string",`not a valid block id: ${t}`),this.blockId=t),this.offset=e,this.type=o}isSimple(){return!0}}const C1=y("editor-position");function $(n,t,e){return new Vt(n,t,e)}function bt(n,t,e){return new Ze(n,t,e)}function kr(n){return n instanceof Vt}function b1(n){return n instanceof Ze}function v1(n,t,e){if(kr(t)&&kr(e)){const o=t,r=e;if(o.blockId===r.blockId)return o.offset-r.offset;const i=n.getBlockById(t.blockId),s=n.getBlockById(e.blockId);return d(C1,i!==s,"comparePosition: blocks are the same"),Xs(i,s)}if(b1(t)&&b1(e)){const o=t,r=e;if(o.childContainerId===r.childContainerId)return 0;const i=n.getContainerById(o.childContainerId),s=n.getContainerById(r.childContainerId);return d(C1,i!==s,"comparePosition: containers are the same"),Xs(i,s)}return d(C1,!1,"invalid "),0}const fl=y("simple-range");class se{constructor(t,e){h(this,"editor");h(this,"_anchor");h(this,"_focus");h(this,"reverse");this.editor=t,this._anchor=e.anchor,this._focus=e.focus,this.reverse=v1(this.editor,this._anchor,this._focus)>0}isCollapsed(){return this.start.blockId===this.end.blockId&&this.start.offset===this.end.offset}isEqual(t){if(!(t instanceof se))return!1;const e=t,{start:o,end:r}=e;return this.start.blockId===o.blockId&&this.start.offset===o.offset&&this.start.type===o.type&&this.end.blockId===r.blockId&&this.end.offset===r.offset&&this.end.type===r.type}isSimple(){return!0}isReverse(){return this.reverse}getEditor(){return this.editor}get start(){return this.reverse?this._focus:this._anchor}get end(){return this.reverse?this._anchor:this._focus}get anchor(){return this._anchor}get focus(){return this._focus}getSelectedBlocks(){const{editor:t}=this,e=t.getBlockById(this.start.blockId),o=t.getBlockById(this.end.blockId);d(fl,e,"no start block"),d(fl,o,"no end block");const r=H(e),i=H(o);d(fl,r===i,"invalid range");const s=[];if(e===o)s.push({block:e,start:this.start,end:this.end});else{const l=K(e),c=K(o);d(fl,l<c,"invalid range, start > index"),s.push({block:e,start:this.start,end:$(e,Z(this.editor,e),"end")});const a=Rt(r);for(let u=l+1;u<c;u+=1){const f=a[u];s.push({block:f,start:$(f,0,"home"),end:$(f,Z(this.editor,f),"end")})}s.push({block:o,start:$(o,0,"home"),end:this.end})}return s}getSelectedContainers(){return[]}getAnchorPos(){return this.isReverse()?this.end:this.start}getFocusedPos(){return this.isReverse()?this.start:this.end}clone(){return new se(this.editor,this)}toDocRange(){return{anchor:this.anchor,focus:this.focus}}}y("unknown-block");function CC(n,t,e,o,r){M(o,"unknown-block");const i=eo(o,"div");return i.innerText=`unknown block (${r.type}): ${JSON.stringify(r)}`,i}function bC(n){return 1}function vC(n,t,e,o){return null}function kC(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t))return null;const i=G(t),s=$(i,0,"home"),l=$(i,1,"end");return new se(n,{anchor:s,focus:l})}function yC(n,t){const o=rt(n).getBoundingClientRect();return new DOMRect(o.left+o.width/2,o.top,1,o.height)}function wC(n,t,e,o){M(t,"selected")}function BC(n){n.rootContainer.querySelectorAll("div.unknown-block[data-type=editor-block]").forEach(t=>{F(t,"selected")})}const EC={blockType:"unknown-block",blockKind:"embed",createBlockContent:CC,getBlockTextLength:bC,getRangeFromPoint:kC,moveCaret:vC,getCaretRect:yC,updateSelection:wC,clearSelection:BC},k1=y("editor-blocks");class og{constructor(t){h(this,"blocks",new Map);this.editor=t}registerBlockClass(t){const e=t.blockType,o=this.blocks.get(e);d(k1,!o,`duplicated block type: ${e}`),this.blocks.set(e,t)}getBlockClass(t){const e=this.blocks.get(t);return d(k1,e,`unknown block type: ${t}`),e}hasBlock(t){return this.blocks.has(t)}createBlock(t,e,o){const r=Sm(this.editor,t,o);let i;this.hasBlock(o.type)?i=this.getBlockClass(o.type):i=this.registerUnknownBlock(o.type);const s=i.createBlockContent(this.editor,t,e,r,o);return s.parentElement!==r&&(k1.warn("content parent is not block"),r.appendChild(s)),this.editor.blockHooks.forEach(l=>{var c;(c=l.create)==null||c.call(l,this.editor,t,e,r,o)}),r}forEach(t){this.blocks.forEach(t)}registerUnknownBlock(t){const e={...EC,blockType:t};return this.editor.editorBlocks.registerBlockClass(e),e}}const rg=y("editor-embeds");class ig{constructor(t){h(this,"objects",new Map);this.editor=t}registerEmbedClass(t){const e=t.embedType,o=this.objects.get(e);d(rg,!o,`duplicated embed object type: ${e}`),this.objects.set(e,t)}getEmbedClass(t){const e=this.objects.get(t);return d(rg,e,`unknown embed type: ${t}`),e}getEmbedClassFromBlock(t){return this.getEmbedClass(De(t))}forEach(t){this.objects.forEach(t)}}const sg=y("embed-block");function IC(n,t,e,o,r){const i=eo(o,"div");d(sg,r.type==="embed",`not an embed data: ${JSON.stringify(r)}`);const s=r;return d(sg,s.embedType&&s.embedData,`not an embed data: ${JSON.stringify(s)}`),n.editorEmbeds.getEmbedClass(s.embedType).createEmbedContent(n,i,s,t,e,o),o.setAttribute("data-embed-type",s.embedType),i}function xC(n){return 1}function SC(n,t,e,o){return null}function TC(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t))return null;const i=G(t),s=$(i,0,"home"),l=$(i,1,"end");return new se(n,{anchor:s,focus:l})}function DC(n,t){const o=rt(n).getBoundingClientRect();return new DOMRect(o.left+o.width/2,o.top,1,o.height)}function LC(n,t,e,o){M(t,"selected")}function MC(n){n.rootContainer.querySelectorAll("div.embed-block[data-type=editor-block][data-block-type=embed]").forEach(t=>{F(t,"selected")})}function RC(n,t,e){let o=null;return n.editorEmbeds.forEach(r=>{var s,l;const i=(l=(s=r.convertFrom)==null?void 0:s.call(r,n,t,e))!=null?l:null;i&&(o=i)}),o}function AC(n,t,e,o){const r=Oo(n,t.embedType);return r.convertTo?r.convertTo(n,t,e,o):""}function OC(n,t){const e=hC(n,t);return e.getBlockProperties?e.getBlockProperties(n,t):{}}function _C(n){const t=new Map,e=[];return n.editorEmbeds.forEach(o=>{if(o.getOptions){const r=o.getOptions(n);r.insertEmbedCommandItems&&r.insertEmbedCommandItems.forEach(i=>{e.push(i),t.set(i.id,o)})}}),{name:"EmbedBlock",insertBlockCommandItems:e,async handleInsertEmptyBlock(o,r){const i=t.get(r.item.id);if(!i||!i.getOptions)return null;const s=i.getOptions(o);return s.handleInsertEmptyEmbed?s.handleInsertEmptyEmbed(o,r):null}}}function NC(n,t,e,o){const r=De(t),i=Oo(n,r);!i.handleDeleteBlock||i.handleDeleteBlock(n,t,e,o)}function PC(n,t,e){const o=De(t),r=Oo(n,o);return r.handleUpdateBlock?r.handleUpdateBlock(n,t,e):!1}function $C(n,t,e,o,r){const i=De(t),s=Oo(n,i);if(s.handleDropOver)return s.handleDropOver(n,t,e,o,r)}function HC(n,t,e,o,r){const i=De(t),s=Oo(n,i);if(s.handleDrop&&n.isWritable())return s.handleDrop(n,t,e,o,r)}const lg={blockType:"embed",blockKind:"embed",createBlockContent:IC,getBlockTextLength:xC,getRangeFromPoint:TC,moveCaret:SC,getCaretRect:DC,updateSelection:LC,clearSelection:MC,convertFrom:RC,convertTo:AC,getBlockProperties:OC,getOptions:_C,handleDeleteBlock:NC,handleUpdateBlock:PC,handleDropOver:$C,handleDrop:HC},le=y("complex-block-helper");function Le(n,t){return ve(n,t).getChildContainers(n,t)}function yr(n,t,e,o){return e.isSimple()?(d(le,o.isSimple(),"invalid start and end position"),Le(n,t)):(d(le,!e.isSimple(),"invalid start pos"),d(le,!o.isSimple(),"invalid end pos"),ve(n,t).getSelectedContainers(n,t,e,o))}function jC(n,t){if(K(t)!==0)return!1;const e=z(H(t));if(!e)return!1;d(le,ct(n,e),"not a complex block");const o=H(t),i=Le(n,e).indexOf(o);return d(le,i>=0,"not valid child container"),i===0}function y1(n,t){const e=Le(n,t);if(e.length===0)return null;const o=e[0],r=Qt(o);return ct(n,r)?y1(n,r):r}function wr(n,t){const e=Le(n,t);if(e.length===0)return null;const o=e[e.length-1],r=Gt(o);return ct(n,r)?wr(n,r):r}function cg(n,t){d(le,qe(t),"not a child container");const e=z(t);d(le,e,"no parent block"),d(le,ct(n,e),"not a complex block");const o=Le(n,e),r=o.indexOf(t);if(d(le,r!==-1,"child container not found"),r===0){const l=gt(e);return l?ct(n,l)?wr(n,l):l:null}const i=o[r-1],s=Gt(i);return ct(n,s)?wr(n,s):s}function ag(n,t){d(le,ct(n,t),"not a complex block");const e=Le(n,t);if(d(le,e.length>0,"no child container"),e.length===1)return e;const o=e[0],r=o.getBoundingClientRect();let i=r.left,s=r.right;const l=[o];for(let c=1;c<e.length;c++){const a=e[c],u=a.getBoundingClientRect();if(u.right<=i){l.push(a),i=u.left;continue}if(u.left>=s){s=u.right;continue}}return l}function dg(n,t){d(le,ct(n,t),"not a complex block");const e=Le(n,t);if(d(le,e.length>0,"no child container"),e.length===1)return e;const o=e[e.length-1],r=o.getBoundingClientRect();let i=r.left,s=r.right;const l=[o];for(let c=e.length-2;c>=0;c--){const a=e[c],u=a.getBoundingClientRect();if(u.right<=i){l.push(a),i=u.left;continue}if(u.left>=s){s=u.right;continue}}return l}function ug(n,t,e,o){const r=t.getBoundingClientRect(),i=o<r.top,s=i?ag(n,t):dg(n,t);let l=s[0],c=hn(l.getBoundingClientRect(),e,o);for(let a=1;a<s.length;a++){const u=s[a],f=u.getBoundingClientRect(),m=hn(f,e,o);m<c&&(l=u,c=m)}return i?Qt(l):Gt(l)}function ml(n,t,e,o){const r=G(t);d(le,r===e.blockId,"invalid start pos"),d(le,r===o.blockId,"invalid end pos");const i=ve(n,t);return i.adjustSelectionPos?i.adjustSelectionPos(n,t,e,o):{anchor:e,focus:o}}class Ye{constructor(t,e){h(this,"editor");h(this,"reverse");h(this,"_anchor");h(this,"_focus");this.editor=t,this._anchor=e.anchor,this._focus=e.focus,this.reverse=v1(this.editor,this._anchor,this._focus)>0}isCollapsed(){return!1}isEqual(t){if(!(t instanceof Ye))return!1;const e=t,{anchor:o,focus:r}=e;return this._anchor.blockId===o.blockId&&this._anchor.childContainerId===o.childContainerId&&this._focus.blockId===r.blockId&&this._focus.childContainerId===r.childContainerId&&this._anchor.custom===o.custom&&this._focus.custom===r.custom}isReverse(){return this.reverse}isSimple(){return!1}getEditor(){return this.editor}get anchor(){return this._anchor}get focus(){return this._focus}get start(){return this.reverse?this._focus:this._anchor}get end(){return this.reverse?this._anchor:this._focus}getSelectedBlocks(){const t=this.start,e=this.end;return[{block:this.editor.getBlockById(t.blockId),start:t,end:e}]}getAnchorPos(){return this._anchor}getFocusedPos(){return this._focus}getSelectedContainers(){const t=this.editor.getBlockById(this._anchor.blockId);return yr(this.editor,t,this.start,this.end)}clone(){return new Ye(this.editor,this)}toDocRange(){return{anchor:this._anchor,focus:this._focus}}}const FC=y("selection-range");function Ut(n,t){const{anchor:e,focus:o}=t;return e instanceof Vt&&o instanceof Vt?new se(n,{anchor:e,focus:o}):(d(FC,e instanceof Ze&&o instanceof Ze,"start position type does not math end type"),new Ye(n,{anchor:e,focus:o}))}function Ot(n,t,e,o){const r=new Vt(t,e,"normal"),i=new Vt(t,o!=null?o:e,"normal");return Ut(n,{anchor:r,focus:i})}function zC(n){return!!n.anchor.childContainerId}function no(n,t){var r,i;if(zC(t)){const s=bt(t.anchor.blockId,t.anchor.childContainerId,(r=t.anchor)==null?void 0:r.custom),l=bt(t.focus.blockId,t.focus.childContainerId,(i=t.focus)==null?void 0:i.custom);return Ut(n,{anchor:s,focus:l})}const e=$(t.anchor.blockId,t.anchor.offset,"normal"),o=$(t.focus.blockId,t.focus.offset,"normal");return Ut(n,{anchor:e,focus:o})}function w1(n,t){const e=[];return Rt(t).forEach(r=>{e.push(r),ct(n,r)&&Le(n,r).forEach(s=>{e.push(...w1(n,s))})}),e}function B1(n,t){let e=w1(n,n.rootContainer);return t!=null&&t.simpleBlockOnly&&(e=e.filter(o=>!ct(n,o))),e}function Qe(n,t){const e=n.selection.range.getSelectedBlocks(),o=[];for(const r of e)o.push(r),ct(n,r.block)&&yr(n,r.block,r.start,r.end).forEach(s=>{const c=w1(n,s).map(a=>({block:a,start:$(a,0,"home"),end:$(a,Z(n,a),"home")}));o.push(...c)});return t!=null&&t.simpleBlockOnly?o.filter(r=>!ct(n,r.block)):o}const aF="";function _o(n,t,e,o){const r=At(t);let i=r.querySelector(`.block-anchor[data-id=${e}]`);i||(i=b("div",["block-anchor"],r),i.setAttribute("data-id",e));const s=o!=null?o:t.getBoundingClientRect(),l=t.getBoundingClientRect(),c=new DOMRect(s.left-l.left,s.top-l.top,s.width,s.height);return i.style.left=`${c.left}px`,i.style.top=`${c.top}px`,i.style.width=`${c.width}px`,i.style.height=`${c.height}px`,i}const Pn=y("text-block-child");function Li(n){return n.tagName==="SPAN"}function Me(n){return d(Pn,Li(n),"not a valid text child"),n.getAttribute("data-type")==="editor-box"}function $n(n){return d(Pn,Li(n),"not a valid text child"),n.getAttribute("data-type")==="editor-insertion"}function Mi(n){return!Me(n)&&!$n(n)}function hg(n){return d(Pn,Li(n),"not a valid text child"),Me(n)?"box":$n(n)?"insertion":"text"}function Re(n){const t=hg(n);return t==="insertion"?0:t==="box"?1:(d(Pn,n.textContent!==null,"text block content is undefined"),d(Pn,n.textContent.length>=0,"text block content length is negative"),n.textContent.length)}function Hn(n){const t=rt(n),e=Array.from(t.children);return e.forEach(o=>{d(Pn,Li(o),"not a valid text child")}),e}function gl(n,t){const e=Hn(n);let o=0;for(let r=0;r<e.length;r++){const i=e[r],s=Re(i);if(o+s<t){o+=s;continue}if(o===t)return{prev:e[r-1],next:i,offset:0};if(o+s===t)return{prev:i,next:e[r+1],offset:0};const l=t-o;return d(Pn,l>0,"invalid offset value"),d(Pn,!Me(i),"invalid box child"),{prev:i,next:i,offset:l}}d(Pn,!1,`invalid block child at position: ${t}`)}function Ri(n){const t=Hn(n);let e=0;return t.forEach(o=>{e+=Re(o)}),e}const fg=y("box");function E1(n){return!n.attributes||!n.attributes.box?!1:(d(fg,n.attributes.box===!0,`invalid op attribute box property, ${n.attributes.box}`),d(fg,n.attributes.type,`no box type: ${JSON.stringify(n)}`),!0)}const mg=y("rich-text-length");function I1(n){return d(mg,typeof n.insert=="string","op.insert is not string"),n.insert.length}function ce(n){let t=0;return n.forEach(e=>{e.insert&&(d(mg,typeof e.insert=="string","op.insert is not string"),t+=I1(e))}),t}const mn=y("split-text");function Ae(n,t,e){if(n=Y.default(n),t===0)return{left:[],right:n};if(t===-1)return{left:n,right:[]};let o=0;for(let r=0;r<n.length;r++){const i=n[r];d(mn,typeof i=="object",`invalid op type, ${typeof i}`),d(mn,typeof i.insert=="string",`invalid op.insert type, ${typeof i.insert}`);const s=I1(i);if(o+s<t)o+=s;else{if(o+s===t)return{left:n.slice(0,r+1),right:n.slice(r+1)};{d(mn,o+s>t,`invalid offset, ${o}, ${s}, ${t}`);const l=t-o,c=Y.default(i);d(mn,c.insert,"no copied.insert"),d(mn,typeof c.insert=="string","invalid copied.insert type"),c.insert=c.insert.substr(0,l),i.insert=i.insert.substr(l),c.insert===""&&d(mn,!1,"invalid copied.insert, is empty string"),i.insert===""&&d(mn,!1,"invalid op.insert, is empty string");const a=[i,...n.slice(r+1)],u=[...n.splice(0,r),c];return e&&(e.sourceOp=i),{left:u,right:a}}}}throw new Error(`invalid split offset: ${t}, ${JSON.stringify(n)}`)}function Kt(n,t,e){d(mn,t>=0,"invalid offset, < 0"),d(mn,e>0,"invalid length, <= 0"),d(mn,t+e<=ce(n),"invalid offset + length < text length");const{left:o,right:r}=Ae(n,t+e),{left:i,right:s}=Ae(o,t);return{left:i,middle:s,right:r}}function gg(n,t){const e=Array.from(new Set(t)).sort((i,s)=>i-s),o=[];let r=n;for(let i=e.length-1;i>=0;i--){const s=e[i],{left:l,right:c}=Ae(r,s);r=l,o.unshift(c)}return r.length>0&&o.unshift(r),o}function pg(n,t,e){return Kt(n,t,e).middle}const Br=y("text-block-content");function VC(n,t,e,o,r){if(d(Br,o,"no text for block"),o.length===0&&(!r||r.size===0)){e.innerHTML="<span><br></span>";return}const i=[];r&&i.push(...r.keys());const s=f=>n.editorInsertions.createInsertion(e,f),l=(f,m)=>{const C=r==null?void 0:r.get(m);C&&(C.forEach(v=>{f.appendChild(s(v))}),r==null||r.delete(m))},c=document.createDocumentFragment();let a=0;const u=gg(o,i);for(let f=0;f<u.length;f++){l(c,a);const m=u[f];a+=ce(m);for(let C=0;C<m.length;C++){const v=m[C];if(E1(v)){d(Br,v.attributes,`op is not an valid box: ${JSON.stringify(v)}`);const E=n.editorBoxes.createBox(e,v.attributes);d(Br,E instanceof HTMLSpanElement,`invalid box element: ${E.tagName}`),c.appendChild(E);continue}d(Br,v.insert,`no insert in op: ${JSON.stringify(v)}`);const w=b("span",["text"],c,v.insert);if(v.attributes){const E=n.editorBlockRenders.renderText(t,v.attributes);E.classes&&M(w,...E.classes),E.attributes&&Object.entries(E.attributes).forEach(([L,x])=>{w.setAttribute(L,x)}),E.styles&&Object.entries(E.styles).forEach(([L,x])=>{w.style.setProperty(L,x)})}c.appendChild(w)}}l(c,a),e.innerHTML="",e.appendChild(c)}function pl(n,t,e,o,r){const{text:i,insertions:s}=n.editorDecorators.decorateText(t,r),l=n.compositingText;if(l){const c=n.selection.range.start;d(Br,c.isSimple(),"not an simple position while compositing"),c.blockId===e&&s.set(c.offset,[{type:"inputting",id:N(),text:l}])}return VC(n,t,o,i,s)}function UC(n){const t=n.rootContainer.querySelectorAll('span[data-type="editor-insertion"].inputting-insertion');t.length&&Br.debug(`remove ${t.length} temp composition span`),Array.from(t).forEach(e=>e.remove())}const Zt=y("text-range");function qC(n,t){const e=(i,s)=>{if($n(i))return d(Zt,s===0,`invalid offset for insertion child: ${s}`),{child:i,container:i,offset:2};if(Me(i))return d(Zt,s===0||s===1,`invalid offset for box: ${s}`),{child:i,container:i,offset:s===0?1:2};const l=i.firstChild;return d(Zt,l,"no child node for text child"),d(Zt,l instanceof Text||l instanceof HTMLBRElement,`invalid child for text child, ${l.nodeName}`),l instanceof HTMLBRElement?(d(Zt,s>=0&&s<=0,"invalid offset for text child"),{child:i,container:l,offset:s}):(d(Zt,s>=0&&s<=l.data.length,"invalid offset for text child"),{child:i,container:l,offset:s})};let o=0;const r=Hn(n);for(let i=0;i<r.length;i++){const s=r[i],l=Re(s);if(t===o)return[e(s,0)];if(t<o+l)return[e(s,t-o)];if(t===o+l){const c=[];c.push(e(s,Re(s)));const a=r[i+1];return a&&c.push(e(a,0)),c}o+=l}d(Zt,!1,"failed to get range info")}function WC(n,t,e){if(t===e?d(Zt,$n(n),"only insertion child can be zero offset"):d(Zt,t<e,`invalid start & end: ${t}, ${e}`),$n(n)){d(Zt,t===e,`invalid insertion child range offset: ${t}, ${e}`),d(Zt,t===0,`invalid insertion child range start: ${t}`);const i=n;return d(Zt,i.children.length===3,`invalid insertion dom, children.length = ${i.children.length}`),Ks(i,1,i,2)}if(Me(n)){d(Zt,t+1===e,`invalid box child range offset: ${t}, ${e}`),d(Zt,t===0,`invalid box child range start: ${t}`);const i=n;return d(Zt,i.children.length===3,`invalid box dom, children.length = ${i.children.length}`),Ks(i,1,i,2)}const o=Re(n);d(Zt,e<=o,`invalid child end: ${e}, ${o}`);const r=n.firstChild;return d(Zt,r instanceof Text,"invalid block text child"),d(Zt,r.data.length>=e,`invalid range end: ${e}, ${r.data.length}`),Ks(r,t,r,e)}const Ke=y("caret-rect");function GC(n,t){if(s1(t)){const e=t,o=c1(e);if(e.getAttribute("data-box-type")==="br"){const r=rt(n),i=Number.parseFloat(window.getComputedStyle(r).lineHeight)||o.getBoundingClientRect().height,s=Array.from(o.getClientRects());d(Ke,s.length>0,"no box client rects");const l=r.getBoundingClientRect(),c=s[0],a=new DOMRect(l.left,c.bottom,1,i);return s.push(a),s}return o.getClientRects()}return a1(t).getClientRects()}function Oe(n,t){var l,c;const e=qC(n,t.offset);if(e[1]&&e[0].child!==((l=e[1])==null?void 0:l.child)){if(t.type==="end"){const u=xo(e[0].child);return new DOMRect(u.right,u.top,1,u.height)}d(Ke,e[1],"invalid ranges");const a=Js(e[1].child);return new DOMRect(a.left,a.top,1,a.height)}let r=e[0];if(d(Ke,e.length>=1,"failed to get block range"),e.length===1)r=e[0];else{if(d(Ke,e.length>=2,`invalid range info length: ${e.length}`),$n(e[e.length-1].child)){r=e[e.length-1];const a=r.child,f=a1(a).getClientRects();d(Ke,f.length>=1,"no client rects for box content");const m=f[f.length-1];return new DOMRect(m.right,m.y,1,m.height)}t.type==="home"?r=e[1]:t.type==="end"||Mi(e[0].child)?r=e[0]:Mi(e[1].child)&&(r=e[1])}if(r.container instanceof HTMLBRElement){d(Ke,t.offset===0,"invalid offset for empty block text");const a=(c=r.container.parentElement)==null?void 0:c.parentElement;d(Ke,a===rt(n),"invalid br parent, is not block parent");const u=a.getBoundingClientRect();return new DOMRect(u.left,u.top,1,u.height)}const s=Ff(r.container,r.offset).getClientRects();if(s.length===0){d(Ke,!Mi(r.child),"only box or insertion child range has zero client rect"),d(Ke,r.offset===1||r.offset===2,"invalid offset for box or insertion child");const a=r.child,u=GC(n,a);if(d(Ke,u.length>=1,"no client rects for box content"),r.offset===1){const m=u[0];return new DOMRect(m.x,m.y,1,m.height)}const f=u[u.length-1];return t.type==="end"||r.offset===2?new DOMRect(f.right,f.y,1,f.height):new DOMRect(f.x,f.y,1,f.height)}return d(Ke,s.length>0,"no client rects for range"),t.type==="home"?s[s.length-1]:s[0]}const gn=y("client-rects");function ZC(n){const t=Hn(n);let e=0;const o=[];for(let r=0;r<t.length;r++){const i=t[r],s=Re(i);o.push({child:i,startBlockOffset:e,endBlockOffset:e+s}),e+=s}return o}function YC(n,t,e,o){d(gn,e<o,`invalid from & to: ${e}, ${o}`);const r=Z(n,t);d(gn,e>=0&&o>=0&&e<=r&&o<=r,`invalid offset: ${e}, ${o}, length: ${r}`);const i=ZC(t),s=i.findIndex(C=>C.startBlockOffset<=e&&e<C.endBlockOffset),l=i.findIndex(C=>C.startBlockOffset<o&&o<=C.endBlockOffset);if(d(gn,s!==-1,"failed to find start child"),d(gn,l!==-1,"failed to find end child"),d(gn,s<=l,`invalid start index & end index: ${s}, ${l}`),s===l){const C=i[s];return[{child:C.child,startChildOffset:e-C.startBlockOffset,endChildOffset:o-C.startBlockOffset}]}const c=[],a=i[s],u={child:a.child,startChildOffset:e-a.startBlockOffset,endChildOffset:Re(a.child)};c.push(u);for(let C=s+1;C<l;C++){const v=i[C],w={child:v.child,startChildOffset:0,endChildOffset:v.endBlockOffset-v.startBlockOffset};c.push(w)}const f=i[l],m={child:f.child,startChildOffset:0,endChildOffset:o-f.startBlockOffset};return c.push(m),c}function QC(n){const t=(o,r)=>o.left<=r.left&&o.top<=r.top&&o.right>=r.right&&o.bottom>=r.bottom&&(o.width!==r.width||o.height!==r.height);n=n.filter(o=>!n.find(i=>t(o,i)));const e=[];return n=n.filter(o=>e.find(r=>r.left===o.left&&r.top===o.top&&r.width===o.width&&r.height===o.height)?!1:(e.push(o),!0)),n}function Cg(n,t,e,o){if(Z(n,t)===0){const u=rt(t).getBoundingClientRect();return[new DOMRect(u.left,u.top,4,u.height)]}const r=e.offset,i=o.offset;if(r===i)return[Oe(t,e)];const l=YC(n,t,r,i).map(a=>WC(a.child,a.startChildOffset,a.endChildOffset)),c=[];return l.forEach(a=>{const u=QC(Array.from(a.getClientRects()));c.push(...u)}),c}function KC(n,t,e){d(gn,e instanceof se,"invalid range");const o=e.start,r=e.end;return d(gn,o.isSimple(),"text block only allow simple position"),d(gn,r.isSimple(),"text block only allow simple position"),d(gn,o.blockId===r.blockId,"only allow update one text block selection"),d(gn,o.blockId===G(t),"only allow update one text block selection"),Cg(n,t,o,r)}const x1=y("selection-background");function JC(n,t,e,o){d(x1,e.isSimple(),"text block only allow simple position"),d(x1,o.isSimple(),"text block only allow simple position"),d(x1,e.blockId===o.blockId,"only allow update one text block selection");const r=e.offset,i=o.offset;if(r===i&&(Z(n,t)!==0||n.selection.range.isCollapsed()))return;const s=Cg(n,t,e,o),l=t.getBoundingClientRect(),c=xm(t);c.innerHTML="",s.forEach(a=>{const u=b("div",["editor-selection-background"],c);u.style.left=`${a.left-l.left}px`,u.style.top=`${a.top-l.top}px`,u.style.width=`${a.width}px`,u.style.height=`${a.height}px`})}function XC(n){n.rootContainer.querySelectorAll("div[data-type=block-background]").forEach(t=>{t.remove()})}const No=y("text-offset"),bg="\u200D";function Er(n,t){const e=Hn(n);let o=0;for(let r=0;r<e.length;r++){const i=e[r],s=Re(i);if(i===t){const l=o+s;return{start:o,end:l}}o+=s}d(No,!1,"can not find child in children")}function fe(n,t){d(No,t>=0,`invalid offset: ${t}`);const e=gl(n,t),{prev:o,next:r,offset:i}=e;if(!o&&!r&&d(No,!1,"invalid offset, no prev & next child at offset"),o!==r)return!0;const s=o;if(d(No,s,"no child"),Me(s))return d(No,i===0||i===1,`invalid box child offset: ${i}`),!0;const l=s.textContent;d(No,l,"no content for text child");const c=l.charAt(i-1),a=l.charAt(i);return!(c===bg||a===bg||Va(l[i]))}function Po(n,t){if(t===0)return 0;const e=t-1;if(fe(n,e))return e;let o=e-1;for(;!fe(n,o);)o-=1;return o}function Ir(n,t){const e=Ri(n);if(d(No,t>=0&&t<=e,`invalid offset: ${t}, ${e}`),t===e)return e;const o=t+1;if(fe(n,o))return o;let r=o+1;for(;!fe(n,r);)r+=1;return r}const $o=y("line-breaker");function Ai(n){const t=c=>{const a=Js(c);return xo(c).top>a.top+a.height/2},e=(c,a)=>{const u=xo(c);return Js(a).left<u.right},o=(c,a)=>{const u=xo(c),f=xo(a);return f.top+f.height/2>u.bottom},r=c=>{if(c.length===0||c.length===1)return!1;const a=c[0],u=c[c.length-1];return a.right-u.left>10},i=[];let s=0;const l=Hn(n);for(let c=0;c<l.length;c++){const a=l[c];if($n(a)){const E=a,L=l[c+1];if(!L)break;const x=l[c-1];if(x&&o(x,E)&&i.push({offset:s,type:"betweenChild",childInfo:{prevChild:x,nextChild:E,wrap:"nextWrapped",prevWrapped:t(x),nextWrapped:t(E)}}),e(E,L)){i.push({offset:s,type:"betweenChild",childInfo:{prevChild:x,nextChild:E,wrap:"nowrap",prevWrapped:t(x),nextWrapped:t(E)}});continue}continue}if(Me(a)){const E=a,L=l[c+1];if(!L)break;const x=l[c-1];if(x&&o(x,E)&&i.push({offset:s,type:"betweenChild",childInfo:{prevChild:x,nextChild:E,wrap:"nextWrapped",prevWrapped:t(x),nextWrapped:t(E)}}),e(E,L)){s+=1,i.push({offset:s,type:"betweenChild",childInfo:{prevChild:x,nextChild:a,wrap:"nowrap",prevWrapped:t(x),nextWrapped:t(a)}});continue}s+=1;continue}const u=a,f=u.getClientRects();if(d($o,f.length>0,"invalid text child dom"),f.length===1){const E=l[c+1];if(!E)break;if(e(u,E)){s+=Re(u),i.push({offset:s,type:"betweenChild",childInfo:{prevChild:u,nextChild:E,wrap:"nowrap",prevWrapped:t(u),nextWrapped:t(E)}});continue}s+=Re(u);continue}const m=u.firstChild;d($o,m,"invalid text child, no text node"),d($o,m instanceof Text,`invalid text child, not a valid text node: ${typeof m}`);const C=document.createRange(),v=document.createRange(),w=Re(u);d($o,m.data.length===w,"text node data length not equal child text length");for(let E=0;E<m.data.length;E++){if(!fe(n,s+E))continue;C.setStart(m,E),Qa()&&C.selectNodeContents(m);const L=C.getClientRects();if(d($o,L.length>=1,"invalid text node, no client rects"),r(L)){const U=s+E;i.push({offset:U,type:"textBreakWord",childInfo:{prevChild:a,nextChild:a,wrap:"nowrap",prevWrapped:t(a),nextWrapped:t(a)}});continue}let x=E+1;fe(n,s+x)||(x=E+2),v.setStart(m,x);const A=v.getClientRects(),O=L[0];A[0].left<O.right&&d($o,!1,"span pre-wrap should not has a line-wrap by white space")}s+=w}return i}function S1(n,t){const e=Ai(n);for(let o=0;o<e.length;o++){const{offset:r,type:i}=e[o];if(t.offset<r)return{lineIndex:o,lineBreaks:e};if(t.offset===r&&t.type==="end")return{lineIndex:o,lineBreaks:e}}return d($o,t.offset<=Ri(n),"invalid position, offset > block length"),{lineIndex:e.length,lineBreaks:e}}const tb=y("line-offset");function T1(n){const t=Ai(n),e=[];let o=0;for(let r=0;r<t.length;r++){const i=t[r];e.push({start:o,end:i.offset}),o=i.offset}return e.push({start:o,end:Ri(n)}),e}function Cl(n,t){const e=T1(n);return d(tb,t>=0&&t<e.length,`invalid line index: ${t}, ${e.length}`),e[t]}function vg(n,t){const{lineIndex:e}=S1(n,t);return Cl(n,e)}function eb(n){const t=T1(n),e=n.getBoundingClientRect(),o=[];return t.forEach(({start:r,end:i})=>{const s=$(n,r,"home");let l=Oe(n,s);const c=$(n,i,"end"),a=Oe(n,c);l.top+l.height/2<a.top&&(l=new DOMRect(e.left-1e4,a.top,1,a.height));const u=new DOMRect(l.left,a.top,a.left-l.left,a.height),f=new DOMRect(e.left,a.top,e.width,a.height);o.push({start:r,end:i,rect:f,contentRect:u})}),o}function nb(n,t,e){const r=eb(n).find(s=>To(s.rect,t,e));if(!r)return null;const i=r.contentRect;return t-i.left<i.right-t?$(n,r.start,"home"):$(n,r.end,"end")}function kg(n,t,e){const o=Oe(n,t),r=Oe(n,e),i=o.top+o.height/2,s=r.top+r.height/2,l=r.top<i&&i<r.bottom,c=o.top<s&&s<o.bottom;return l&&c}function yg(n){return T1(n).length}const Ho=y("find-text-position");function wg(n,t){const{start:e,end:o}=Cl(n,t),r=G(n),i=Oe(n,$(r,e,"home"));if(!(Oe(n,$(r,o,"end")).top>i.top+i.height/2))return!1;const c=gl(n,e);return d(Ho,c.next,"no next child at offset"),d(Ho,!Mi(c.next),"next child is not text child"),!0}function ob(n,t){const e=G(n);d(Ho,wg(n,t),"line is not wrapped");const{start:o,end:r}=Cl(n,t),i=$(e,o,"home");for(let s=o+1;s<=r;s+=1){let l="normal";s===o?l="home":s===r&&(l="end");const c=$(e,s,l);if(!kg(n,i,c))return s-1}return d(Ho,!1,"failed to find wrapped offset"),0}function bl(n,t,e,o,r,i,s){d(Ho,j(n,t),`not a text kind block: ${it(t)}`);const{start:l,end:c}=Cl(t,e);let a=l;const u=G(t);if(t===o&&wg(t,e)){const E=ob(t,e);(i==="up"||i==="down"&&kg(t,r,$(u,l,"home")))&&(a=E+1)}let f=Number.MAX_SAFE_INTEGER;const m=Ge(n,o,r),C=s!=null?s:m.left+m.width/2,v=m.top+m.height/2;let w=$(u,a,"home");for(let E=a;E<=c;E++){if(!fe(t,E))continue;let L="normal";E===l?L="home":E===c&&(L="end");const x=$(u,E,L),A=Oe(t,x),O=hn(A,C,v);O<f&&(f=O,w=x)}return w}function rb(n,t,e,o,r){return d(Ho,j(n,t),"not a text block"),bl(n,t,yg(t)-1,e,o,"up",r)}function ib(n,t,e,o,r){return d(Ho,j(n,t),"not a text block"),bl(n,t,0,e,o,"down",r)}function sb(n,t,e,o){const{lineIndex:r}=S1(t,e);if(r===yg(t)-1)return null;const i=bl(n,t,r+1,t,e,"down",o);return i||null}function lb(n,t){if(t.offset===0)return null;const e=Ai(n),o=e.find(r=>r.offset===t.offset);if(!o){const r=Po(n,t.offset);return e.find(s=>s.offset===r)?{offset:r,type:"home"}:{offset:r,type:"normal"}}if(o.type==="betweenChild"){if(t.type==="home"&&o.childInfo.wrap==="nowrap")return{offset:t.offset,type:"end"};if(o.childInfo.prevWrapped)return{offset:Po(n,t.offset),type:"normal"}}return{offset:Po(n,t.offset),type:"normal"}}function cb(n,t){const e=Ri(n);if(t.offset===e)return null;const o=Ai(n),r=o.find(i=>i.offset===t.offset);if(!r){const i=Ir(n,t.offset),s=o.find(l=>l.offset===i);return s?s.type==="betweenChild"?{offset:i,type:"end"}:{offset:i,type:"home"}:{offset:i,type:"normal"}}return r.type==="betweenChild"?r.childInfo.wrap==="nowrap"&&t.type==="end"?{offset:t.offset,type:"home"}:{offset:Ir(n,t.offset),type:"home"}:{offset:Ir(n,t.offset),type:"normal"}}function ab(n,t,e,o){const{lineIndex:r}=S1(t,e);if(r===0)return null;const i=bl(n,t,r-1,t,e,"up",o);return i||null}const db=y("move-caret");function ub(n,t,e,o){if(o==="ArrowLeft"){const r=lb(t,e);return r?$(G(t),r.offset,r.type):null}if(o==="ArrowRight"){const r=cb(t,e);return r?$(G(t),r.offset,r.type):null}if(o==="ArrowUp"){const r=ab(n,t,e,n.selection.getSuggestedCaretX());return r?$(G(t),r.offset,r.type):null}if(o==="ArrowDown"){const r=sb(n,t,e,n.selection.getSuggestedCaretX());return r?$(G(t),r.offset,r.type):null}d(db,!1,`invalid navigation direction: ${o}`)}const D1=y("text-range");function hb(n){const t=[];return Hn(n).forEach(o=>{const r=Array.from(o.getClientRects()).map(i=>({rect:i,child:o}));t.push(...r)}),t}function fb(n,t,e){const o=hb(n);for(let r=1;r<o.length;r++){const i=o[r-1],s=o[r];if(t>=i.rect.right&&t<=s.rect.left&&e>=i.rect.top&&e<=i.rect.bottom&&e>=s.rect.top&&e<=s.rect.bottom)return Er(n,s.child).start}return null}function mb(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t))return null;const i=r.closest("div[data-type=block-content]>span");if(!i){const L=t.getBoundingClientRect();if(!To(L,e,o))return null;const x=fb(t,e,o);if(x!==null){const O=$(t,x,"normal");return new se(n,{anchor:O,focus:O})}const A=nb(t,e,o);return A?new se(n,{anchor:A,focus:A}):null}const s=Hn(t);d(D1,s.indexOf(i)!==-1,"failed to find child in children");const l=Er(t,i);d(D1,l,"failed to get child offset");const{start:c}=l;let a,u;$n(i)||Me(i)?(a=c,u=0):(d(D1,i.firstChild instanceof Text,"child is not text"),a=c+zf(i.firstChild,e,o),u=0);const f=G(t),C=Ai(t).find(L=>L.offset===a);let v="normal";if(C){const L=$(f,a,"home"),x=$(f,a,"end"),A=Oe(t,L),O=Oe(t,x),P=hn(A,e,o),U=hn(O,e,o);v=P<U?"home":"end"}const w=$(f,a,v);let E;return u&&(E=$(f,a+u,v)),new se(n,{anchor:w,focus:E!=null?E:w})}const gb=y("create-text-op");function _e(n,t){d(gb,n,"text is empty");const e={insert:n};return t&&Object.keys(t).length>0&&(e.attributes=t),e}function L1(n,t){if(n.length===0)return[];if(n.indexOf(`
15
+ animateScrollTo(scrollToElement:Element, options)`;e+=i.horizontalOffset,o+=i.verticalOffset;const f=u.getMaxHorizontalScroll(),m=u.getHorizontalScroll();e>f&&(e=f);const C=e-m,v=u.getMaxVerticalScroll(),w=u.getVerticalScroll();w<o?o-=window.innerHeight*3/4:o-=window.innerHeight*1/4,o>v&&(o=v);const E=o-w,L=Math.abs(Math.round(C/1e3*i.speed)),x=Math.abs(Math.round(E/1e3*i.speed));let A=L>x?L:x;return A<i.minDuration?A=i.minDuration:A>i.maxDuration&&(A=i.maxDuration),new Promise((O,P)=>{C===0&&E===0&&O(!0),An.remove(u.element,!0);let V;const tt=()=>{oe(),cancelAnimationFrame(V),O(!1)};An.add(u.element,tt);const ot=Fe=>Fe.preventDefault(),ut=i.cancelOnUserAction?tt:ot,dt=i.cancelOnUserAction?{passive:!0}:{passive:!1},yt=["wheel","touchstart","keydown","mousedown"],oe=()=>{yt.forEach(Fe=>{u.element.removeEventListener(Fe,ut,dt)})};yt.forEach(Fe=>{u.element.addEventListener(Fe,ut,dt)});const Jn=Date.now(),Xt=()=>{const Fe=Date.now()-Jn,vo=Fe/A,ar=Math.round(m+C*i.easing(vo)),dr=Math.round(w+E*i.easing(vo));Fe<A&&(ar!==e||dr!==o)?(u.scrollTo(ar,dr),V=requestAnimationFrame(Xt)):(u.scrollTo(e,o),cancelAnimationFrame(V),oe(),An.remove(u.element,!1),O(!0))};V=requestAnimationFrame(Xt)})}function To(n,t,e){return n.left<=t&&t<=n.right&&n.top<=e&&e<=n.bottom}function N8(n){const t="\xA0";if(!n)return"";if(n===" ")return t;let e=n;return e.startsWith(" ")&&(e=t+e.substr(1)),e.endsWith(" ")&&(e=e.substr(0,e.length-1)+t),e=e.replace(/ {2}/g,` ${t}`),e}function Wf(n){if(!/["'&<>]/.exec(n))return n;const o={'"':"&quot;","'":"&#39;","&":"&amp;","<":"&lt;",">":"&gt;"};return n.split("").map(l=>o[l]||l).join("")}function Gf(n){const t=document.getElementById(n);t&&t.remove()}function Zf(n,t){const e=document.getElementById(t);if(e)return e.textContent=n,e;const o=document.createElement("style");return o.id=t,o.textContent=n,document.head.append(o),o}function Ii(n){const t="custom-cursor-style";if(n){const e=`body * { cursor: ${n} !important}`;Zf(e,t)}else Gf(t)}const Yf=3,Qf=y("drag-drop");class Kf{constructor(t){h(this,"dragStarted",!1);h(this,"mouseDownEvent",null);h(this,"_dragOffsetX",0);h(this,"_dragOffsetY",0);h(this,"handleMouseDown",t=>{t.preventDefault(),t.stopPropagation(),this.mouseDownEvent=t;const e=this.options.elem.getBoundingClientRect();this._dragOffsetX=this.mouseDownEvent.x-e.left,this._dragOffsetY=this.mouseDownEvent.y-e.top,this.bindEvents()});h(this,"handleMouseMove",t=>{var i;t.preventDefault(),t.stopPropagation(),d(Qf,this.mouseDownEvent,"no mouse down event");const e=t.x-this.mouseDownEvent.x,o=t.y-this.mouseDownEvent.y;if(this.dragStarted){this.onDragging(t,e,o);return}const r=(i=this.options.minThreshold)!=null?i:Yf;(Math.abs(e)>=r||Math.abs(o)>=r)&&this.onDragStart(this.mouseDownEvent)});h(this,"handleMouseUp",t=>{if(t.button===0){d(Qf,this.mouseDownEvent,"no mouse down event");const e=t.x-this.mouseDownEvent.x,o=t.y-this.mouseDownEvent.y;this.onDragEnd(t,e,o),t.preventDefault(),t.stopPropagation()}});this.options=t,this.options.mouseDownEvent?this.handleMouseDown(this.options.mouseDownEvent):this.trackEvents()}get data(){return this.options.data}get dragOffsetX(){return this._dragOffsetX}get dragOffsetY(){return this._dragOffsetY}get dragOffset(){return{x:this._dragOffsetX,y:this._dragOffsetY}}trackEvents(){this.options.elem.addEventListener("mousedown",this.handleMouseDown)}untrackEvents(){this.options.elem.removeEventListener("mousedown",this.handleMouseDown)}bindEvents(){document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}unbindEvents(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}onDragStart(t){this.dragStarted=!0,this.options.cursor&&Ii(this.options.cursor),this.options.onDragStart(this,t,this.options.elem)}onDragging(t,e,o){this.options.onDragging(this,t,this.options.elem,e,o)}onDragEnd(t,e,o){this.options.cursor&&Ii(null),this.dragStarted&&this.options.onDragEnd(this,t,this.options.elem,e,o),this.unbindEvents(),this.dragStarted=!1}destroy(){this.unbindEvents(),this.untrackEvents()}}function Za(n){return new Kf(n)}const P8=y("character");function Jf(n,t){for(let e=0;e<t.length;e++){const o=t[e][0],r=t[e].length>1?t[e][1]:null;if(r===null&&n===o||r!==null&&n>=o&&n<=r)return!0}return!1}function Xf(n){const t=n.charAt(0);return t>="0"&&t<="9"}function tm(n){const t=n.charAt(0);return t>="a"&&t<="z"||t>="A"&&t<="Z"||t.toUpperCase()!==t.toLowerCase()?!0:RegExp(/^\p{L}/,"u").test(t)}function tl(n){const t=[[9,13],[32],[160]];return Jf(n.charCodeAt(0),t)}function em(n){const t=[[12352,12687],[13056,13183],[13312,15661],[19968,40959],[63744,64255],[44032,55215]];return Jf(n.charCodeAt(0),t)}function Ya(n,t){let e=t;return d(P8,e.length===1,"invalid char length"),e==="]"&&(e="\\]"),e==="\\"&&(e="\\\\"),n.replace(new RegExp(`^[${e}]+|[${e}]+$`,"g"),"")}const On=navigator.userAgent;function nm(){const n=navigator.userAgent.toLowerCase();return n.indexOf("safari")!==-1&&!(n.indexOf("chrome")>-1)}function Qa(){return navigator.userAgent.toLowerCase().indexOf("firefox")>-1}const It={isAndroid:!!On.match(/Android/i),isIOS:!!On.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/i),isIPad:!!On.match(/iPad/i),isIPhone:!!On.match(/iPhone/i),isLinux:!!On.match(/Linux/i),isMac:!!On.match(/Macintosh/i),isMobile:!!On.match(/AppleWebKit.*Mobile.*/i),isWindows:!!On.match(/Window/i),isIe:!!On.match(/msie|trident/i),isSafari:nm(),isMobileSafari:!1};It.isMobileSafari=It.isMobile&&It.isSafari;function Ka(n){return n?n.length===1||n==="Process"||n==="Unidentified"&&It.isAndroid:!1}function om(n){switch(n){case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":case"End":case"Home":case"PageDown":case"PageUp":return!0;default:return!1}}function $8(n){return om(n.key)}function H8(n){switch(n){case"ArrowUp":case"ArrowLeft":case"Home":case"PageUp":return!0;default:return!1}}function Do(n){return n.ctrlKey||n.altKey||n.shiftKey||n.metaKey}function j8(n){return n.key?!!(n.ctrlKey||n.metaKey||n.altKey):!1}function rm(n){return It.isMac?n.metaKey&&!n.ctrlKey:!n.metaKey&&n.ctrlKey}function F8(n){return rm(n)&&!n.altKey&&!n.shiftKey}function z8(n){return!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&n.altKey}function im(n){return!Do(n)&&n.key==="Enter"}function U8(n){return n.key==="Enter"&&n.shiftKey&&!n.altKey&&!n.ctrlKey&&!n.metaKey}function Ja(n){return!Do(n)&&n.key==="Escape"}function V8(n){return!Do(n)&&n.key==="Delete"}function sm(n){return!Do(n)&&n.key==="Backspace"}function q8(n){return!Do(n)&&n.key==="Tab"}function W8(n){return n.shiftKey&&n.key==="Tab"&&!n.ctrlKey&&!n.metaKey}function G8(n){if(!n)return"";if(It.isMac){const t=n.replace("CtrlOrCmd","\u2318").replace("Shift","\u21E7").replace("Ctrl","\u2303").replace("Alt","\u2325").replace(/\+(?!$)/gm,""),e={"\u2318":4,"\u21E7":3,"\u2325":2,"\u2303":1};return t.split(/(?=[\s\S])/u).sort((r,i)=>{var c,a;const s=(c=e[r])!=null?c:5,l=(a=e[i])!=null?a:5;return s-l}).join("")}return n.replace("CtrlOrCmd","Ctrl")}function lm(n){const t={ctrl:!1,alt:!1,shift:!1,cmd:!1,key:""},e=n.toLocaleUpperCase().split("+");for(let o=0;o<e.length;o++){const r=e[o];r==="CTRL"||r==="CONTROL"?t.ctrl=!0:r==="ALT"||r==="OPTION"?t.alt=!0:r==="SHIFT"?t.shift=!0:r==="CMD"||r==="COMMAND"?t.cmd=!0:r==="CMDORCTRL"||r==="CTRLORCMD"?It.isMac?t.cmd=!0:t.ctrl=!0:r==="SPACE"?t.key=" ":t.key=r.substring(0,1)+r.substring(1).toLocaleLowerCase()}return t}function _n(n,t){const e=lm(t);return e.ctrl!==n.ctrlKey||e.alt!==n.altKey||e.shift!==n.shiftKey||It.isMac&&e.cmd!==n.metaKey?!1:e.key.length===1?e.key===n.key.toUpperCase():e.key.toUpperCase()===n.key.toUpperCase()}function Xa(n,t){return P7.stringifyUrl({url:n,query:t})}function Lo(n){return typeof n=="string"?pi.Base64.encode(n,!0):pi.Base64.fromUint8Array(n,!0)}function el(n){return pi.Base64.decode(n)}function Z8(n){return pi.Base64.toUint8Array(n)}function cm(n){return new Blob([pi.Base64.toUint8Array(n)])}const Y8=to.init([to.classModule,to.styleModule,to.datasetModule,to.attributesModule,to.propsModule]);function xi(n,t){const e=to.toVNode(n),o=to.toVNode(t);Y8(e,o)}async function am(n,t){const e=new FileReader,o=new Promise((i,s)=>{e.onload=i,e.onerror=s});return e.readAsDataURL(new Blob([n],{type:t})),await o,e.result}async function nl(n){const t=new FileReader,e=new Promise((r,i)=>{t.onload=r,t.onerror=i});return t.readAsDataURL(n),await e,t.result}function Q8(n,...t){const e=n.tagName.toLowerCase();for(let o=0,r=t.length;o<r;o++)if(e===t[o].toLowerCase())return!0;return!1}function Nn(n){let t=n;for(;t;){const e=window.getComputedStyle(t);if(/auto|scroll/i.test(e.overflowY))break;t=t.parentElement}return(!t||Q8(t,"body"))&&(t=document.documentElement),t}function dm(n){if(document.querySelector(`.editor-disable-scroll[data-scroll-id="${n}"]`))return;const t=b("div",["editor-disable-scroll"],null);t.setAttribute("data-scroll-id",n),t.onwheel=e=>{e.preventDefault(),e.stopPropagation()},document.body.appendChild(t)}function um(n){var t;(t=document.querySelector(`.editor-disable-scroll[data-scroll-id="${n}"]`))==null||t.remove()}function t1(n,t,e){const o=new Blob([n]),r=new File([o],e,{type:t});return URL.createObjectURL(r)}function ol(n){const t=document.createElement("template");if("content"in t)return t.innerHTML=n,document.importNode(t.content,!0);const e=document.createDocumentFragment(),o=document.createElement("div");for(o.innerHTML=n;o.firstChild;)e.appendChild(o.firstChild);return e}function hm(n){const t=document.createElement("div");return t.appendChild(n),t.innerHTML}function fm(n){let t=n.getPropertyValue("font");if(t)return t;const e=n.getPropertyValue("font-style"),o=n.getPropertyValue("font-variant"),r=n.getPropertyValue("font-weight"),i=n.getPropertyValue("font-size"),s=n.getPropertyValue("font-family");return t=`${e} ${o} ${r} ${i} ${s}`.replace(/ +/g," ").trim(),t}function rl(n,t){const o=(rl.canvas||(rl.canvas=document.createElement("canvas"))).getContext("2d");return o?(typeof t=="string"?t?o.font=t:o.font=fm(window.getComputedStyle(document.body)):t instanceof Element&&(o.font=fm(window.getComputedStyle(t))),o.measureText(n).width+4):200}const K8=y("editor-clipboard");async function J8(n,t){if(t.clipboardData){const e=t.clipboardData;for(const o of n)e.setData(o.type,o.data);return!0}return!1}async function il(n){try{const t={};n.forEach(o=>{t[o.type]=o.data});const e=new ClipboardItem(t);return await navigator.clipboard.write([e]),!0}catch(t){return K8.error(t),!1}}function fr(n,t){return new Promise((e,o)=>{const r=document.createElement("input");r.type="file",r.style.display="none",t!=null&&t.multiple&&(r.multiple=!0),r.accept=n,r.onchange=()=>{const i=r.files;if(i){const s=t!=null&&t.multiple?Array.from(i):i[0];e(s)}r.remove()},r.onerror=i=>{o(i),r.remove()},r.click()})}function sl(n){return Array.isArray(n)?n.every(t=>t instanceof File):!1}function mm(n){const t=n;if(!t)return"";const e=t.lastIndexOf(".");return e===-1?"":t.slice(e+1)}function ll(n,t){const e=document.createElement("a");e.setAttribute("download",`${t||""}`),e.setAttribute("href",`${n}`),e.click(),e.remove()}const gm=y("auto-scroll");function pm(n,t){return!(n.scrollHeight===n.clientHeight||t==="top"&&n.scrollTop===0||t==="bottom"&&n.scrollTop+n.clientHeight===n.scrollHeight||t==="left"&&n.scrollLeft===0||t==="right"&&n.scrollLeft+n.clientWidth===n.scrollWidth)}function Cm(n,{direction:t,step:e}){let o=null;const r=t==="left"||t==="right",i=()=>{if(!pm(n,t))return gm.debug("No need for scroll"),null;if(r){const s=n.scrollLeft,l=t==="left"?s-e:s+e;n.scrollLeft=l}else{const s=n.scrollTop,l=t==="top"?s-e:s+e;n.scrollTop=l}return o=requestAnimationFrame(i),o};return o=requestAnimationFrame(i),()=>{o&&cancelAnimationFrame(o)}}class bm{constructor(t){h(this,"cancelScroll",null);h(this,"options");h(this,"scrollDomInfo");h(this,"scrolling",!1);h(this,"getScrollingDirection",t=>{const{x:e,y:o}=t,{top:r,bottom:i,left:s,right:l}=this.scrollDomInfo,{edge:c}=this.options;return c.top&&o>=r&&o<=c.top+r?"top":c.bottom&&o<=i&&o>=i-c.bottom?"bottom":c.left&&e>=s&&e<=s+c.left?"left":c.right&&e<=l&&e>=l-c.right?"right":null});h(this,"handleMouseMove",t=>{var s;const{scrollElement:e,step:o=10,onDirectionChange:r}=this.options,i=this.getScrollingDirection(t);if(i){if(this.scrolling)return;gm.debug(`scroll direction: ${i}`),this.cancelScroll=Cm(e,{direction:i,step:o}),r==null||r(i),this.scrolling=!0}else(s=this.cancelScroll)==null||s.call(this),this.scrolling=!1});this.options=t,this.scrollDomInfo=this.getScrollDomInfo()}getScrollDomInfo(){const{scrollElement:t}=this.options,e=t.clientTop,o=t.clientLeft,r=t.clientHeight,i=t.clientWidth;return{left:o,top:e,right:i,bottom:r}}active(){const{trackMouseEvent:t="mousemove"}=this.options;window.addEventListener(t,this.handleMouseMove,!0)}inactive(){var e;const{trackMouseEvent:t="mousemove"}=this.options;window.removeEventListener(t,this.handleMouseMove,!0),(e=this.cancelScroll)==null||e.call(this),this.scrolling=!1}}function vm(n,t){if(n===0)return"0 Bytes";const e=1024,o=t||2,r=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],i=Math.floor(Math.log(n)/Math.log(e));return`${parseFloat((n/e**i).toFixed(o))} ${r[i]}`}function e1(n,t){let e=`${n}`;const o=t-e.length;for(let r=0;r<o;r++)e=`0${e}`;return e}const{t:Mo}=S;function n1(n,t){const e=new Date(n).getTime()+864e5*t;return new Date(e)}function X8(n,t){const e=n,o=Math.floor(t/12),r=t-o*12;return o&&e.setFullYear(e.getFullYear()+o),r&&e.setMonth(e.getMonth()+r),e}function tC(n,t){return n1(n,t)}function o1(n,t){const e=new Date(n),o=new Date(t);return e.getDate()===o.getDate()&&e.getMonth()===o.getMonth()&&e.getFullYear()===o.getFullYear()}function km(n){const t=new Date,e=new Date(n);return o1(t,e)}function ym(n){const t=n1(new Date,-1);return o1(t,n)}function eC(n,t){return Math.round((n.getTime()-t.getTime())/864e5)}function wm(n,t){const e=new Date(n);if(t){const o=e.getFullYear(),r=e.getMonth()+1,i=e.getDate();let s=t;return s=s.replace("yyyy",`${o}`),s=s.replace("mm",e1(r,2)),s=s.replace("dd",e1(i,2)),s=s.replace("m",`${r}`),s=s.replace("d",`${i}`),s}return n.toLocaleDateString()}function r1(n,t){const e=new Date(n),o=new Date;if(e.getTime()-o.getTime()>10*1e3)return S.t("date.dateFromFuture");if(km(e)){const i=(o.getTime()-n.getTime())/1e3;if(i<10*60)return Mo("date.dateJustNow");if(i<60*60)return Mo("date.dateMinutesAgo",{num:`${Math.floor(i/60)}`});const s=Math.floor(i/60/60);return s===1?Mo("date.date1HourAgo"):Mo("date.dateHoursAgo",{num:`${s}`})}if(ym(n))return Mo("date.dateYesterday");const r=Math.floor((o.getTime()-n.getTime())/1e3/24/60/60)+1;return r<14?Mo("date.dateDaysAgo",{num:`${r}`}):r<28?Mo("date.dateWeeksAgo",{num:`${Math.round(r/7)}`}):wm(n,t)}function i1(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function nC(n,t,e){return n.replace(new RegExp(i1(t),"g"),e)}function oC(n,t,e){return n.replace(new RegExp(i1(t),"gi"),e)}const Bm=y("container-children");function Rt(n){const t=Array.from(n.querySelectorAll(":scope > .container-blocks > div[data-type=editor-block]"));return d(Bm,t.length>0,"container have not any child block"),t}function Qt(n){const t=n.querySelector(":scope > .container-blocks > div[data-type=editor-block]");return d(Bm,t,"container have not any child block"),t}function Gt(n){const t=Rt(n);return t[t.length-1]}function Ue(n){return Rt(n).length}function mr(n,t){return Rt(n)[t]}const Ve=y("block-dom");function gr(n){return n instanceof HTMLDivElement?n.getAttribute("data-type")==="editor-block":!1}function Em(n){M(n,"block-hidden")}function Im(n){F(n,"block-hidden")}function cl(n){return!lt(n,"block-hidden")}function G(n){const{id:t}=n;return d(Ve,t,"no block id"),t}function it(n){const t=n.getAttribute("data-block-type");return d(Ve,t,"invalid block dom, no data-type"),t}function z(n){const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest("div[data-type=editor-block]");return e||null}function H(n){const t=n.closest("div[data-type=editor-container]");return d(Ve,t,"failed to get block container"),t}function rt(n){const t=n.querySelector(":scope >div[data-type=block-content]");return d(Ve,t,"no block content"),t}function At(n){let t=n.querySelector(":scope >div[data-type=block-tools]");return t||(t=b("div",[],n),t.setAttribute("data-type","block-tools")),d(Ve,t,"no block tools"),t}function al(n){const t=n.querySelector(":scope >div[data-type=block-tools]");return t||null}function xm(n){let t=n.querySelector(":scope > div[data-type=block-background]");return t||(t=b("div",[],n),t.setAttribute("data-type","block-background")),t}function Sm(n,t,e){const o=n.editorDecorators.decorateBlock(t,e),{id:r,type:i}=o;d(Ve,r,"no block id");const s=b("div",[`${i}-block`],null);s.id=r,s.setAttribute("data-type","editor-block"),s.setAttribute("data-block-type",i);const l=n.editorBlockRenders.renderBlock(n,t,e);return l.classes&&M(s,...l.classes),l.attributes&&Object.entries(l.attributes).forEach(([c,a])=>{s.setAttribute(c,a)}),l.styles&&Object.entries(l.styles).forEach(([c,a])=>{s.style.setProperty(c,a)}),s}function eo(n,t){const e=b(t,[],null);return e.setAttribute("data-type","block-content"),n&&n.appendChild(e),e}function Tm(n){const t=b("span",[`${n.type}-box`],null);return t.setAttribute("data-type","editor-box"),t.setAttribute("data-box-type",n.type),t.id=n.id,t}function Si(n){const t=n.getAttribute("data-box-type");return d(Ve,t,"not a valid box element, no type"),t}function s1(n){return n instanceof HTMLSpanElement?n.getAttribute("data-type")==="editor-box":!1}function Dm(n){const{id:t}=n;return d(Ve,t,"no box id"),t}function l1(n){const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest("span[data-type=editor-box]");return e||null}function Lm(n){n.innerHTML="",b("span",["box-space-start"],n,yi);const t=b("span",[],n);return t.setAttribute("data-type","box-content"),b("span",["box-space-start"],n,yi),t}function c1(n){const t=n.querySelector("span[data-type=box-content]");return d(Ve,t,"invalid box dom, no content"),t}function Mm(n,t){const e=b("span",[`${n}-insertion`],null);return e.setAttribute("data-type","editor-insertion"),e.setAttribute("data-insertion-id",t),e}function Rm(n,t){return n.rootContainer.querySelector(`[data-insertion-id=${t}]`)}function Am(n){n.innerHTML="",b("span",["insertion-space-start"],n,yi);const t=b("span",[],n);return t.setAttribute("data-type","insertion-content"),b("span",["insertion-space-start"],n,yi),t}function a1(n){const t=n.querySelector("span[data-type=insertion-content]");return d(Ve,t,"invalid insertion-child dom, no content"),t}function gt(n){let t=n.previousElementSibling;for(;t;){if(gr(t))return t;t=t.nextElementSibling}return null}function ht(n){let t=n.nextElementSibling;for(;t;){if(gr(t))return t;t=t.nextElementSibling}return null}function pr(n){let t=n.previousElementSibling;for(;t;){if(gr(t)&&cl(t))return t;t=t.previousElementSibling}return null}function Cr(n){let t=n.nextElementSibling;for(;t;){if(gr(t)&&cl(t))return t;t=t.nextElementSibling}return null}function K(n){const t=H(n),o=Rt(t).indexOf(n);return d(Ve,o!==-1,"invalid block & container dom, failed to get block index"),o}function d1(n){return!n||!(n instanceof Node)?!1:!!z(n)}function Ti(n){if(!d1(n))return!1;const t=n,e=t instanceof Element?t:t.parentElement;return e?!!e.closest("div[data-type=block-tools]"):!1}const Om=y("element");function u1(n,t,e){const o=b("div",[t],n);return o.setAttribute("data-type","editor-container"),o.setAttribute("data-container-id",e),b("div",["container-blocks"],o),o}function br(n,t){const e=n.rootElement.querySelector(`[data-container-id=${t}`);return d(Om,e,`no container: ${t}`),e}function _m(n,t){return n.rootElement.querySelector(`[data-container-id=${t}`)}function dl(n){const t=n.querySelector(":scope > .container-blocks");return d(Om,t,"no container blocks element"),t}function rC(n){let t=n.querySelector(":scope > .container-tools");return t||(t=b("div",["container-tools"],n)),t}const Nm=y("container");function fn(n){return n.getAttribute("data-type")==="editor-container"}function Ct(n){return lt(n,"root")}function qe(n){return lt(n,"child")}function U(n){const t=n.getAttribute("data-container-id");return d(Nm,t,"no id for container"),Ct(n)&&d(Nm,t==="root",`invalid root container id, : ${t}`),t}function Pm(n,t){const e=U(n);return t.getContainerBlocks(e)}const $m=y("block-path");function Ro(n){const t=[];let e=n;for(;e;){const o=H(e);if(t.unshift({containerId:U(o),blockIndex:K(e)}),Ct(o))return t;const r=z(o);d($m,r,"no parent block"),e=r}return d($m,!1,"no parent block"),[]}const iC=y("child-container-path");function Hm(n){if(Ct(n))return[];const t=z(n);return d(iC,t,"no parent block"),Ro(t)}const jm=y("load-blocks");function h1(n,t,e){const o=U(t),r=Pm(t,n.doc);d(jm,r.length>0,"no blocks in container");const i=document.createDocumentFragment();r.forEach((l,c)=>{const a=n.editorBlocks.createBlock([...e,{containerId:o,blockIndex:c}],t,l);i.appendChild(a)}),dl(t).appendChild(i)}function sC(n,t,e){const o=dl(n),r=Rt(n);return d(jm,t>=0&&t<=r.length,"invalid block index"),t===r.length?o.appendChild(e):o.insertBefore(e,r[t]),e}function lC(n,t,e,o){const r=Hm(t);r.push({containerId:U(t),blockIndex:e});const i=n.editorBlocks.createBlock(r,t,o);return sC(t,e,i),i}const Fm=y("root-container");class cC{constructor(t,e){h(this,"resizeObserver");h(this,"handleContextMenu",t=>{t.preventDefault()});h(this,"handleResize",()=>{try{this.editor.selection.updateSelection(null),this.editor.emit("resize",this.editor)}catch(t){Fm.warn(`failed to update selection while container resizing: ${t.message}`)}});h(this,"handleClick",t=>{var o,r;this.editor.emit("click",this.editor,t);const e=t.target;if(!Ti(e)&&(t.detail===1&&this.editor.input.focus(),t.detail===3&&this.editor.selectionHandler.handleTripleClick(t),t.detail===1&&t.button===0)){const i=document.elementFromPoint(t.clientX,t.clientY);if(i&&vt(this.rootContainer,i)){const s=l1(i);if(s){const l=z(s);d(Fm,l,"no parent block"),(r=(o=this.editor.editorBoxes.getBoxClass(Si(s)))==null?void 0:o.handleClickBox)==null||r.call(o,this.editor,s,t)}}}});h(this,"handleDblClick",t=>{Ti(t.target)||this.editor.selectionHandler.handleDblClick(t)});h(this,"handleMouseDown",t=>{const e=t.target;if(!!e&&e instanceof Node&&!Ti(e)){if(e instanceof HTMLElement&&e.draggable){this.editor.selectionHandler.handleMouseDown(t),this.editor.selectionHandler.stopSelection(),this.editor.input.focus();return}t.button===0&&(document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),this.editor.selectionHandler.handleMouseDown(t)),It.isMobileSafari||(t.preventDefault(),this.editor.input.focus()),t.button===2&&t.stopPropagation()}});h(this,"handleMouseMove",t=>{this.editor.selectionHandler.handleMouseMove(t)});h(this,"handleMouseUp",t=>{t.button===0&&(this.editor.selectionHandler.handleMouseUp(t),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp))});this.editor=t,this.rootContainer=e,this.editor=t,this.resizeObserver=new ResizeObserver(this.handleResize),this.bindEvents(e)}bindEvents(t){this.resizeObserver.observe(t);const e=this.editor.rootElement;e.onmousedown=this.handleMouseDown,e.ondblclick=this.handleDblClick,e.onclick=this.handleClick,e.oncontextmenu=this.handleContextMenu}unbindEvents(){this.resizeObserver.disconnect();const t=this.editor.rootElement;t.onmousedown=null,t.ondblclick=null,t.onclick=null,t.oncontextmenu=null}destroy(){this.unbindEvents()}reload(){const t=this.editor.selection.range,e=dl(this.rootContainer);e.innerHTML="",h1(this.editor,this.rootContainer,[]);const o=this.editor.findBlockById(t.start.blockId);if(o)this.editor.selection.selectBlock(o,0);else{const r=Qt(this.rootContainer);this.editor.selection.selectBlock(r,0)}}}function zm(n){const t=u1(n.contentElement,"root","root");return n.rootContainer=t,h1(n,t,[]),new cC(n,t)}function Um(n,t,e,o){const r=_m(n,o);if(r)return e.appendChild(r),r;const i=u1(e,"child",o);return h1(n,i,t),i}const Vm=y("block-class");function kt(n,t){return n.editorBlocks.getBlockClass(it(t))}function qm(n,t){const e=n.editorBlocks.getBlockClass(it(t));return d(Vm,e.blockKind==="text",`is not a text block, ${e.blockType}`),e}function ve(n,t){const e=n.editorBlocks.getBlockClass(it(t));return d(Vm,e.blockKind==="complex",`is not a text block, ${e.blockType}`),e}function vr(n,t){return n.editorBlocks.getBlockClass(t)}const f1=y("block");function Z(n,t){return kt(n,t).getBlockTextLength(t)}function Wm(n){n.editorBlocks.forEach(t=>{t.clearSelection(n)})}function Gm(n,t,e,o){kt(n,t).updateSelection(n,t,e,o)}function ul(n){for(;;){const t=H(n);if(Ct(t))return n;const e=z(t);d(f1,e,"no parent block exists for child container"),n=e}}function Zm(n,t){const e=kt(n,t);if(!!e.getMinWidth)return e.getMinWidth(n,t)}function Ym(n,t,e){const o=kt(n,t);o.handleBlockElementUpdated&&o.handleBlockElementUpdated(n,t,e)}function hl(n,t,e,o){try{const r=vr(n,e).convertFrom;return r?r(n,t,o):null}catch{return f1.debug(`unsupported block type: ${e}`),null}}function Ao(n,t,e){const o=kt(n,t);return o.getClientRects?o.getClientRects(n,t,e):[t.getBoundingClientRect()]}function aC(n,t){const e=kt(n,t);if(e.getBlockStyles)return e.getBlockStyles(n,t);const o=n.getBlockData(t),r=Object.fromEntries(Object.entries(o).filter(([i])=>i.startsWith("style-")));return Object.entries(r).forEach(([,i])=>{const s=typeof i;d(f1,s==="string"||s==="number"||s==="boolean","invalid style value")}),r}function Qm(n,t){const e=n.getBoundingClientRect().width;return t.withPadding?e:e-Va(n)}function m1(n,t){let e=Number.MAX_SAFE_INTEGER;const o=Rt(t);for(let i=0;i<o.length;i++){const s=o[i],l=Zm(n,s);l&&(e=Math.min(e,l))}return e===Number.MAX_SAFE_INTEGER?void 0:e+Va(t)}function j(n,t){return kt(n,t).blockKind==="text"}function Di(n,t){return n.editorBlocks.getBlockClass(t).blockKind==="text"}function ct(n,t){return kt(n,t).blockKind==="complex"}function dC(n,t){return!ct(n,t)}function We(n,t){return kt(n,t).blockKind}function wt(n,t){return We(n,t)==="text"?Z(n,t)===0:!1}function g1(n,t){const e=Rt(t);return e.length!==1?!1:wt(n,e[0])}function Ge(n,t,e){return kt(n,t).getCaretRect(t,e)}function uC(n,t){var r,i;const e=kt(n,t);return(i=(r=e.getOptions)==null?void 0:r.call(e,n))!=null?i:{name:it(t)}}function Km(n,t){var r;const e=kt(n,t);return(r=e.getBlockProperties)==null?void 0:r.call(e,n,t)}function p1(n,t){var i,s;const e=kt(n,t),o=(i=e.getBlockProperties)==null?void 0:i.call(e,n,t);let r={};o!=null&&o.blockCommands&&(r={...o.blockCommands});for(const l of n.blockHooks){const c=(s=l.commands)==null?void 0:s.call(l,n,t);c&&(r[c.group]=c)}return r}function Jm(n,t,e){var s,l,c,a;const o=kt(n,t),r=(s=o.getBlockProperties)==null?void 0:s.call(o,n,t);let i={};r!=null&&r.blockCommands&&(i={...r.blockCommands});for(const u of n.blockHooks){const f=(l=u.commands)==null?void 0:l.call(u,n,t);f&&(i[f.group]=f)}return(a=(c=i[e])==null?void 0:c.commands)!=null?a:[]}const Xm=y("embed-block-common");function Te(n){return it(n)==="embed"}function De(n){d(Xm,Te(n),"not an embed block");const t=n.getAttribute("data-embed-type");return d(Xm,t,"no embed data type"),t}function hC(n,t){return n.editorEmbeds.getEmbedClass(De(t))}function Oo(n,t){return n.editorEmbeds.getEmbedClass(t)}async function tg(n,t,e,o,r){const i=Oo(n,t);if(!i.getOptions)return null;const s=i.getOptions(n);if(!s.insertEmbedCommandItems||!s.insertEmbedCommandItems||s.insertEmbedCommandItems.length===0||!s.handleInsertEmptyEmbed)return null;const l=s.insertEmbedCommandItems[0];return s.handleInsertEmptyEmbed(n,{item:l,containerId:e,blockIndex:o,data:r})}function fC(n,t,e,o,r){var l,c;const i=(c=(l=vr(n,t)).getOptions)==null?void 0:c.call(l,n);if(!i||!i.insertBlockCommandItems||i.insertBlockCommandItems.length===0||!i.handleInsertEmptyBlock)return null;const s=i.insertBlockCommandItems[0];return i.handleInsertEmptyBlock(n,{item:s,containerId:e,blockIndex:o,data:r})}const mC=y("execute-block-command");function eg(n,t,e,o){var a;d(mC,Te(t),"not a embed block");const r=De(t),i=Oo(n,r);if(!i.getOptions)return;const s=(a=i.getBlockProperties)==null?void 0:a.call(i,n,t),l=s==null?void 0:s.blockCommands;if(!l)return;const c=Object.entries(l);for(const u of c)if(u[0]===e)return u[1].executeCommand(n,t,o)}function ng(n,t,e,o){const r=p1(n,t);if(!r)return;const i=Object.entries(r);for(const s of i)if(s[0]===e)return s[1].executeCommand(n,t,o)}const gC=y("complex-block-position");class Ze{constructor(t,e,o){h(this,"blockId");h(this,"childContainerId");h(this,"custom");t instanceof HTMLElement?this.blockId=G(t):(d(gC,typeof t=="string",`not a valid block id: ${t}`),this.blockId=t),this.childContainerId=e,o!==void 0&&(this.custom=o)}isSimple(){return!1}}const pC=y("simple-block-position");class Ut{constructor(t,e,o){h(this,"blockId");h(this,"offset");h(this,"type");t instanceof HTMLElement?this.blockId=G(t):(d(pC,typeof t=="string",`not a valid block id: ${t}`),this.blockId=t),this.offset=e,this.type=o}isSimple(){return!0}}const C1=y("editor-position");function $(n,t,e){return new Ut(n,t,e)}function bt(n,t,e){return new Ze(n,t,e)}function kr(n){return n instanceof Ut}function b1(n){return n instanceof Ze}function v1(n,t,e){if(kr(t)&&kr(e)){const o=t,r=e;if(o.blockId===r.blockId)return o.offset-r.offset;const i=n.getBlockById(t.blockId),s=n.getBlockById(e.blockId);return d(C1,i!==s,"comparePosition: blocks are the same"),Xs(i,s)}if(b1(t)&&b1(e)){const o=t,r=e;if(o.childContainerId===r.childContainerId)return 0;const i=n.getContainerById(o.childContainerId),s=n.getContainerById(r.childContainerId);return d(C1,i!==s,"comparePosition: containers are the same"),Xs(i,s)}return d(C1,!1,"invalid "),0}const fl=y("simple-range");class se{constructor(t,e){h(this,"editor");h(this,"_anchor");h(this,"_focus");h(this,"reverse");this.editor=t,this._anchor=e.anchor,this._focus=e.focus,this.reverse=v1(this.editor,this._anchor,this._focus)>0}isCollapsed(){return this.start.blockId===this.end.blockId&&this.start.offset===this.end.offset}isEqual(t){if(!(t instanceof se))return!1;const e=t,{start:o,end:r}=e;return this.start.blockId===o.blockId&&this.start.offset===o.offset&&this.start.type===o.type&&this.end.blockId===r.blockId&&this.end.offset===r.offset&&this.end.type===r.type}isSimple(){return!0}isReverse(){return this.reverse}getEditor(){return this.editor}get start(){return this.reverse?this._focus:this._anchor}get end(){return this.reverse?this._anchor:this._focus}get anchor(){return this._anchor}get focus(){return this._focus}getSelectedBlocks(){const{editor:t}=this,e=t.getBlockById(this.start.blockId),o=t.getBlockById(this.end.blockId);d(fl,e,"no start block"),d(fl,o,"no end block");const r=H(e),i=H(o);d(fl,r===i,"invalid range");const s=[];if(e===o)s.push({block:e,start:this.start,end:this.end});else{const l=K(e),c=K(o);d(fl,l<c,"invalid range, start > index"),s.push({block:e,start:this.start,end:$(e,Z(this.editor,e),"end")});const a=Rt(r);for(let u=l+1;u<c;u+=1){const f=a[u];s.push({block:f,start:$(f,0,"home"),end:$(f,Z(this.editor,f),"end")})}s.push({block:o,start:$(o,0,"home"),end:this.end})}return s}getSelectedContainers(){return[]}getAnchorPos(){return this.isReverse()?this.end:this.start}getFocusedPos(){return this.isReverse()?this.start:this.end}clone(){return new se(this.editor,this)}toDocRange(){return{anchor:this.anchor,focus:this.focus}}}y("unknown-block");function CC(n,t,e,o,r){M(o,"unknown-block");const i=eo(o,"div");return i.innerText=`unknown block (${r.type}): ${JSON.stringify(r)}`,i}function bC(n){return 1}function vC(n,t,e,o){return null}function kC(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t))return null;const i=G(t),s=$(i,0,"home"),l=$(i,1,"end");return new se(n,{anchor:s,focus:l})}function yC(n,t){const o=rt(n).getBoundingClientRect();return new DOMRect(o.left+o.width/2,o.top,1,o.height)}function wC(n,t,e,o){M(t,"selected")}function BC(n){n.rootContainer.querySelectorAll("div.unknown-block[data-type=editor-block]").forEach(t=>{F(t,"selected")})}const EC={blockType:"unknown-block",blockKind:"embed",createBlockContent:CC,getBlockTextLength:bC,getRangeFromPoint:kC,moveCaret:vC,getCaretRect:yC,updateSelection:wC,clearSelection:BC},k1=y("editor-blocks");class og{constructor(t){h(this,"blocks",new Map);this.editor=t}registerBlockClass(t){const e=t.blockType,o=this.blocks.get(e);d(k1,!o,`duplicated block type: ${e}`),this.blocks.set(e,t)}getBlockClass(t){const e=this.blocks.get(t);return d(k1,e,`unknown block type: ${t}`),e}hasBlock(t){return this.blocks.has(t)}createBlock(t,e,o){const r=Sm(this.editor,t,o);let i;this.hasBlock(o.type)?i=this.getBlockClass(o.type):i=this.registerUnknownBlock(o.type);const s=i.createBlockContent(this.editor,t,e,r,o);return s.parentElement!==r&&(k1.warn("content parent is not block"),r.appendChild(s)),this.editor.blockHooks.forEach(l=>{var c;(c=l.create)==null||c.call(l,this.editor,t,e,r,o)}),r}forEach(t){this.blocks.forEach(t)}registerUnknownBlock(t){const e={...EC,blockType:t};return this.editor.editorBlocks.registerBlockClass(e),e}}const rg=y("editor-embeds");class ig{constructor(t){h(this,"objects",new Map);this.editor=t}registerEmbedClass(t){const e=t.embedType,o=this.objects.get(e);d(rg,!o,`duplicated embed object type: ${e}`),this.objects.set(e,t)}getEmbedClass(t){const e=this.objects.get(t);return d(rg,e,`unknown embed type: ${t}`),e}getEmbedClassFromBlock(t){return this.getEmbedClass(De(t))}forEach(t){this.objects.forEach(t)}}const sg=y("embed-block");function IC(n,t,e,o,r){const i=eo(o,"div");d(sg,r.type==="embed",`not an embed data: ${JSON.stringify(r)}`);const s=r;return d(sg,s.embedType&&s.embedData,`not an embed data: ${JSON.stringify(s)}`),n.editorEmbeds.getEmbedClass(s.embedType).createEmbedContent(n,i,s,t,e,o),o.setAttribute("data-embed-type",s.embedType),i}function xC(n){return 1}function SC(n,t,e,o){return null}function TC(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t))return null;const i=G(t),s=$(i,0,"home"),l=$(i,1,"end");return new se(n,{anchor:s,focus:l})}function DC(n,t){const o=rt(n).getBoundingClientRect();return new DOMRect(o.left+o.width/2,o.top,1,o.height)}function LC(n,t,e,o){M(t,"selected")}function MC(n){n.rootContainer.querySelectorAll("div.embed-block[data-type=editor-block][data-block-type=embed]").forEach(t=>{F(t,"selected")})}function RC(n,t,e){let o=null;return n.editorEmbeds.forEach(r=>{var s,l;const i=(l=(s=r.convertFrom)==null?void 0:s.call(r,n,t,e))!=null?l:null;i&&(o=i)}),o}function AC(n,t,e,o){const r=Oo(n,t.embedType);return r.convertTo?r.convertTo(n,t,e,o):""}function OC(n,t){const e=hC(n,t);return e.getBlockProperties?e.getBlockProperties(n,t):{}}function _C(n){const t=new Map,e=[];return n.editorEmbeds.forEach(o=>{if(o.getOptions){const r=o.getOptions(n);r.insertEmbedCommandItems&&r.insertEmbedCommandItems.forEach(i=>{e.push(i),t.set(i.id,o)})}}),{name:"EmbedBlock",insertBlockCommandItems:e,async handleInsertEmptyBlock(o,r){const i=t.get(r.item.id);if(!i||!i.getOptions)return null;const s=i.getOptions(o);return s.handleInsertEmptyEmbed?s.handleInsertEmptyEmbed(o,r):null}}}function NC(n,t,e,o){const r=De(t),i=Oo(n,r);!i.handleDeleteBlock||i.handleDeleteBlock(n,t,e,o)}function PC(n,t,e){const o=De(t),r=Oo(n,o);return r.handleUpdateBlock?r.handleUpdateBlock(n,t,e):!1}function $C(n,t,e,o,r){const i=De(t),s=Oo(n,i);if(s.handleDropOver)return s.handleDropOver(n,t,e,o,r)}function HC(n,t,e,o,r){const i=De(t),s=Oo(n,i);if(s.handleDrop&&n.isWritable())return s.handleDrop(n,t,e,o,r)}const lg={blockType:"embed",blockKind:"embed",createBlockContent:IC,getBlockTextLength:xC,getRangeFromPoint:TC,moveCaret:SC,getCaretRect:DC,updateSelection:LC,clearSelection:MC,convertFrom:RC,convertTo:AC,getBlockProperties:OC,getOptions:_C,handleDeleteBlock:NC,handleUpdateBlock:PC,handleDropOver:$C,handleDrop:HC},le=y("complex-block-helper");function Le(n,t){return ve(n,t).getChildContainers(n,t)}function yr(n,t,e,o){return e.isSimple()?(d(le,o.isSimple(),"invalid start and end position"),Le(n,t)):(d(le,!e.isSimple(),"invalid start pos"),d(le,!o.isSimple(),"invalid end pos"),ve(n,t).getSelectedContainers(n,t,e,o))}function jC(n,t){if(K(t)!==0)return!1;const e=z(H(t));if(!e)return!1;d(le,ct(n,e),"not a complex block");const o=H(t),i=Le(n,e).indexOf(o);return d(le,i>=0,"not valid child container"),i===0}function y1(n,t){const e=Le(n,t);if(e.length===0)return null;const o=e[0],r=Qt(o);return ct(n,r)?y1(n,r):r}function wr(n,t){const e=Le(n,t);if(e.length===0)return null;const o=e[e.length-1],r=Gt(o);return ct(n,r)?wr(n,r):r}function cg(n,t){d(le,qe(t),"not a child container");const e=z(t);d(le,e,"no parent block"),d(le,ct(n,e),"not a complex block");const o=Le(n,e),r=o.indexOf(t);if(d(le,r!==-1,"child container not found"),r===0){const l=gt(e);return l?ct(n,l)?wr(n,l):l:null}const i=o[r-1],s=Gt(i);return ct(n,s)?wr(n,s):s}function ag(n,t){d(le,ct(n,t),"not a complex block");const e=Le(n,t);if(d(le,e.length>0,"no child container"),e.length===1)return e;const o=e[0],r=o.getBoundingClientRect();let i=r.left,s=r.right;const l=[o];for(let c=1;c<e.length;c++){const a=e[c],u=a.getBoundingClientRect();if(u.right<=i){l.push(a),i=u.left;continue}if(u.left>=s){s=u.right;continue}}return l}function dg(n,t){d(le,ct(n,t),"not a complex block");const e=Le(n,t);if(d(le,e.length>0,"no child container"),e.length===1)return e;const o=e[e.length-1],r=o.getBoundingClientRect();let i=r.left,s=r.right;const l=[o];for(let c=e.length-2;c>=0;c--){const a=e[c],u=a.getBoundingClientRect();if(u.right<=i){l.push(a),i=u.left;continue}if(u.left>=s){s=u.right;continue}}return l}function ug(n,t,e,o){const r=t.getBoundingClientRect(),i=o<r.top,s=i?ag(n,t):dg(n,t);let l=s[0],c=hn(l.getBoundingClientRect(),e,o);for(let a=1;a<s.length;a++){const u=s[a],f=u.getBoundingClientRect(),m=hn(f,e,o);m<c&&(l=u,c=m)}return i?Qt(l):Gt(l)}function ml(n,t,e,o){const r=G(t);d(le,r===e.blockId,"invalid start pos"),d(le,r===o.blockId,"invalid end pos");const i=ve(n,t);return i.adjustSelectionPos?i.adjustSelectionPos(n,t,e,o):{anchor:e,focus:o}}class Ye{constructor(t,e){h(this,"editor");h(this,"reverse");h(this,"_anchor");h(this,"_focus");this.editor=t,this._anchor=e.anchor,this._focus=e.focus,this.reverse=v1(this.editor,this._anchor,this._focus)>0}isCollapsed(){return!1}isEqual(t){if(!(t instanceof Ye))return!1;const e=t,{anchor:o,focus:r}=e;return this._anchor.blockId===o.blockId&&this._anchor.childContainerId===o.childContainerId&&this._focus.blockId===r.blockId&&this._focus.childContainerId===r.childContainerId&&this._anchor.custom===o.custom&&this._focus.custom===r.custom}isReverse(){return this.reverse}isSimple(){return!1}getEditor(){return this.editor}get anchor(){return this._anchor}get focus(){return this._focus}get start(){return this.reverse?this._focus:this._anchor}get end(){return this.reverse?this._anchor:this._focus}getSelectedBlocks(){const t=this.start,e=this.end;return[{block:this.editor.getBlockById(t.blockId),start:t,end:e}]}getAnchorPos(){return this._anchor}getFocusedPos(){return this._focus}getSelectedContainers(){const t=this.editor.getBlockById(this._anchor.blockId);return yr(this.editor,t,this.start,this.end)}clone(){return new Ye(this.editor,this)}toDocRange(){return{anchor:this._anchor,focus:this._focus}}}const FC=y("selection-range");function Vt(n,t){const{anchor:e,focus:o}=t;return e instanceof Ut&&o instanceof Ut?new se(n,{anchor:e,focus:o}):(d(FC,e instanceof Ze&&o instanceof Ze,"start position type does not math end type"),new Ye(n,{anchor:e,focus:o}))}function Ot(n,t,e,o){const r=new Ut(t,e,"normal"),i=new Ut(t,o!=null?o:e,"normal");return Vt(n,{anchor:r,focus:i})}function zC(n){return!!n.anchor.childContainerId}function no(n,t){var r,i;if(zC(t)){const s=bt(t.anchor.blockId,t.anchor.childContainerId,(r=t.anchor)==null?void 0:r.custom),l=bt(t.focus.blockId,t.focus.childContainerId,(i=t.focus)==null?void 0:i.custom);return Vt(n,{anchor:s,focus:l})}const e=$(t.anchor.blockId,t.anchor.offset,"normal"),o=$(t.focus.blockId,t.focus.offset,"normal");return Vt(n,{anchor:e,focus:o})}function w1(n,t){const e=[];return Rt(t).forEach(r=>{e.push(r),ct(n,r)&&Le(n,r).forEach(s=>{e.push(...w1(n,s))})}),e}function B1(n,t){let e=w1(n,n.rootContainer);return t!=null&&t.simpleBlockOnly&&(e=e.filter(o=>!ct(n,o))),e}function Qe(n,t){const e=n.selection.range.getSelectedBlocks(),o=[];for(const r of e)o.push(r),ct(n,r.block)&&yr(n,r.block,r.start,r.end).forEach(s=>{const c=w1(n,s).map(a=>({block:a,start:$(a,0,"home"),end:$(a,Z(n,a),"home")}));o.push(...c)});return t!=null&&t.simpleBlockOnly?o.filter(r=>!ct(n,r.block)):o}const aF="";function _o(n,t,e,o){const r=At(t);let i=r.querySelector(`.block-anchor[data-id=${e}]`);i||(i=b("div",["block-anchor"],r),i.setAttribute("data-id",e));const s=o!=null?o:t.getBoundingClientRect(),l=t.getBoundingClientRect(),c=new DOMRect(s.left-l.left,s.top-l.top,s.width,s.height);return i.style.left=`${c.left}px`,i.style.top=`${c.top}px`,i.style.width=`${c.width}px`,i.style.height=`${c.height}px`,i}const Pn=y("text-block-child");function Li(n){return n.tagName==="SPAN"}function Me(n){return d(Pn,Li(n),"not a valid text child"),n.getAttribute("data-type")==="editor-box"}function $n(n){return d(Pn,Li(n),"not a valid text child"),n.getAttribute("data-type")==="editor-insertion"}function Mi(n){return!Me(n)&&!$n(n)}function hg(n){return d(Pn,Li(n),"not a valid text child"),Me(n)?"box":$n(n)?"insertion":"text"}function Re(n){const t=hg(n);return t==="insertion"?0:t==="box"?1:(d(Pn,n.textContent!==null,"text block content is undefined"),d(Pn,n.textContent.length>=0,"text block content length is negative"),n.textContent.length)}function Hn(n){const t=rt(n),e=Array.from(t.children);return e.forEach(o=>{d(Pn,Li(o),"not a valid text child")}),e}function gl(n,t){const e=Hn(n);let o=0;for(let r=0;r<e.length;r++){const i=e[r],s=Re(i);if(o+s<t){o+=s;continue}if(o===t)return{prev:e[r-1],next:i,offset:0};if(o+s===t)return{prev:i,next:e[r+1],offset:0};const l=t-o;return d(Pn,l>0,"invalid offset value"),d(Pn,!Me(i),"invalid box child"),{prev:i,next:i,offset:l}}d(Pn,!1,`invalid block child at position: ${t}`)}function Ri(n){const t=Hn(n);let e=0;return t.forEach(o=>{e+=Re(o)}),e}const fg=y("box");function E1(n){return!n.attributes||!n.attributes.box?!1:(d(fg,n.attributes.box===!0,`invalid op attribute box property, ${n.attributes.box}`),d(fg,n.attributes.type,`no box type: ${JSON.stringify(n)}`),!0)}const mg=y("rich-text-length");function I1(n){return d(mg,typeof n.insert=="string","op.insert is not string"),n.insert.length}function ce(n){let t=0;return n.forEach(e=>{e.insert&&(d(mg,typeof e.insert=="string","op.insert is not string"),t+=I1(e))}),t}const mn=y("split-text");function Ae(n,t,e){if(n=Y.default(n),t===0)return{left:[],right:n};if(t===-1)return{left:n,right:[]};let o=0;for(let r=0;r<n.length;r++){const i=n[r];d(mn,typeof i=="object",`invalid op type, ${typeof i}`),d(mn,typeof i.insert=="string",`invalid op.insert type, ${typeof i.insert}`);const s=I1(i);if(o+s<t)o+=s;else{if(o+s===t)return{left:n.slice(0,r+1),right:n.slice(r+1)};{d(mn,o+s>t,`invalid offset, ${o}, ${s}, ${t}`);const l=t-o,c=Y.default(i);d(mn,c.insert,"no copied.insert"),d(mn,typeof c.insert=="string","invalid copied.insert type"),c.insert=c.insert.substr(0,l),i.insert=i.insert.substr(l),c.insert===""&&d(mn,!1,"invalid copied.insert, is empty string"),i.insert===""&&d(mn,!1,"invalid op.insert, is empty string");const a=[i,...n.slice(r+1)],u=[...n.splice(0,r),c];return e&&(e.sourceOp=i),{left:u,right:a}}}}throw new Error(`invalid split offset: ${t}, ${JSON.stringify(n)}`)}function Kt(n,t,e){d(mn,t>=0,"invalid offset, < 0"),d(mn,e>0,"invalid length, <= 0"),d(mn,t+e<=ce(n),"invalid offset + length < text length");const{left:o,right:r}=Ae(n,t+e),{left:i,right:s}=Ae(o,t);return{left:i,middle:s,right:r}}function gg(n,t){const e=Array.from(new Set(t)).sort((i,s)=>i-s),o=[];let r=n;for(let i=e.length-1;i>=0;i--){const s=e[i],{left:l,right:c}=Ae(r,s);r=l,o.unshift(c)}return r.length>0&&o.unshift(r),o}function pg(n,t,e){return Kt(n,t,e).middle}const Br=y("text-block-content");function UC(n,t,e,o,r){if(d(Br,o,"no text for block"),o.length===0&&(!r||r.size===0)){e.innerHTML="<span><br></span>";return}const i=[];r&&i.push(...r.keys());const s=f=>n.editorInsertions.createInsertion(e,f),l=(f,m)=>{const C=r==null?void 0:r.get(m);C&&(C.forEach(v=>{f.appendChild(s(v))}),r==null||r.delete(m))},c=document.createDocumentFragment();let a=0;const u=gg(o,i);for(let f=0;f<u.length;f++){l(c,a);const m=u[f];a+=ce(m);for(let C=0;C<m.length;C++){const v=m[C];if(E1(v)){d(Br,v.attributes,`op is not an valid box: ${JSON.stringify(v)}`);const E=n.editorBoxes.createBox(e,v.attributes);d(Br,E instanceof HTMLSpanElement,`invalid box element: ${E.tagName}`),c.appendChild(E);continue}d(Br,v.insert,`no insert in op: ${JSON.stringify(v)}`);const w=b("span",["text"],c,v.insert);if(v.attributes){const E=n.editorBlockRenders.renderText(t,v.attributes);E.classes&&M(w,...E.classes),E.attributes&&Object.entries(E.attributes).forEach(([L,x])=>{w.setAttribute(L,x)}),E.styles&&Object.entries(E.styles).forEach(([L,x])=>{w.style.setProperty(L,x)})}c.appendChild(w)}}l(c,a),e.innerHTML="",e.appendChild(c)}function pl(n,t,e,o,r){const{text:i,insertions:s}=n.editorDecorators.decorateText(t,r),l=n.compositingText;if(l){const c=n.selection.range.start;d(Br,c.isSimple(),"not an simple position while compositing"),c.blockId===e&&s.set(c.offset,[{type:"inputting",id:N(),text:l}])}return UC(n,t,o,i,s)}function VC(n){const t=n.rootContainer.querySelectorAll('span[data-type="editor-insertion"].inputting-insertion');t.length&&Br.debug(`remove ${t.length} temp composition span`),Array.from(t).forEach(e=>e.remove())}const Zt=y("text-range");function qC(n,t){const e=(i,s)=>{if($n(i))return d(Zt,s===0,`invalid offset for insertion child: ${s}`),{child:i,container:i,offset:2};if(Me(i))return d(Zt,s===0||s===1,`invalid offset for box: ${s}`),{child:i,container:i,offset:s===0?1:2};const l=i.firstChild;return d(Zt,l,"no child node for text child"),d(Zt,l instanceof Text||l instanceof HTMLBRElement,`invalid child for text child, ${l.nodeName}`),l instanceof HTMLBRElement?(d(Zt,s>=0&&s<=0,"invalid offset for text child"),{child:i,container:l,offset:s}):(d(Zt,s>=0&&s<=l.data.length,"invalid offset for text child"),{child:i,container:l,offset:s})};let o=0;const r=Hn(n);for(let i=0;i<r.length;i++){const s=r[i],l=Re(s);if(t===o)return[e(s,0)];if(t<o+l)return[e(s,t-o)];if(t===o+l){const c=[];c.push(e(s,Re(s)));const a=r[i+1];return a&&c.push(e(a,0)),c}o+=l}d(Zt,!1,"failed to get range info")}function WC(n,t,e){if(t===e?d(Zt,$n(n),"only insertion child can be zero offset"):d(Zt,t<e,`invalid start & end: ${t}, ${e}`),$n(n)){d(Zt,t===e,`invalid insertion child range offset: ${t}, ${e}`),d(Zt,t===0,`invalid insertion child range start: ${t}`);const i=n;return d(Zt,i.children.length===3,`invalid insertion dom, children.length = ${i.children.length}`),Ks(i,1,i,2)}if(Me(n)){d(Zt,t+1===e,`invalid box child range offset: ${t}, ${e}`),d(Zt,t===0,`invalid box child range start: ${t}`);const i=n;return d(Zt,i.children.length===3,`invalid box dom, children.length = ${i.children.length}`),Ks(i,1,i,2)}const o=Re(n);d(Zt,e<=o,`invalid child end: ${e}, ${o}`);const r=n.firstChild;return d(Zt,r instanceof Text,"invalid block text child"),d(Zt,r.data.length>=e,`invalid range end: ${e}, ${r.data.length}`),Ks(r,t,r,e)}const Ke=y("caret-rect");function GC(n,t){if(s1(t)){const e=t,o=c1(e);if(e.getAttribute("data-box-type")==="br"){const r=rt(n),i=Number.parseFloat(window.getComputedStyle(r).lineHeight)||o.getBoundingClientRect().height,s=Array.from(o.getClientRects());d(Ke,s.length>0,"no box client rects");const l=r.getBoundingClientRect(),c=s[0],a=new DOMRect(l.left,c.bottom,1,i);return s.push(a),s}return o.getClientRects()}return a1(t).getClientRects()}function Oe(n,t){var l,c;const e=qC(n,t.offset);if(e[1]&&e[0].child!==((l=e[1])==null?void 0:l.child)){if(t.type==="end"){const u=xo(e[0].child);return new DOMRect(u.right,u.top,1,u.height)}d(Ke,e[1],"invalid ranges");const a=Js(e[1].child);return new DOMRect(a.left,a.top,1,a.height)}let r=e[0];if(d(Ke,e.length>=1,"failed to get block range"),e.length===1)r=e[0];else{if(d(Ke,e.length>=2,`invalid range info length: ${e.length}`),$n(e[e.length-1].child)){r=e[e.length-1];const a=r.child,f=a1(a).getClientRects();d(Ke,f.length>=1,"no client rects for box content");const m=f[f.length-1];return new DOMRect(m.right,m.y,1,m.height)}t.type==="home"?r=e[1]:t.type==="end"||Mi(e[0].child)?r=e[0]:Mi(e[1].child)&&(r=e[1])}if(r.container instanceof HTMLBRElement){d(Ke,t.offset===0,"invalid offset for empty block text");const a=(c=r.container.parentElement)==null?void 0:c.parentElement;d(Ke,a===rt(n),"invalid br parent, is not block parent");const u=a.getBoundingClientRect();return new DOMRect(u.left,u.top,1,u.height)}const s=Ff(r.container,r.offset).getClientRects();if(s.length===0){d(Ke,!Mi(r.child),"only box or insertion child range has zero client rect"),d(Ke,r.offset===1||r.offset===2,"invalid offset for box or insertion child");const a=r.child,u=GC(n,a);if(d(Ke,u.length>=1,"no client rects for box content"),r.offset===1){const m=u[0];return new DOMRect(m.x,m.y,1,m.height)}const f=u[u.length-1];return t.type==="end"||r.offset===2?new DOMRect(f.right,f.y,1,f.height):new DOMRect(f.x,f.y,1,f.height)}return d(Ke,s.length>0,"no client rects for range"),t.type==="home"?s[s.length-1]:s[0]}const gn=y("client-rects");function ZC(n){const t=Hn(n);let e=0;const o=[];for(let r=0;r<t.length;r++){const i=t[r],s=Re(i);o.push({child:i,startBlockOffset:e,endBlockOffset:e+s}),e+=s}return o}function YC(n,t,e,o){d(gn,e<o,`invalid from & to: ${e}, ${o}`);const r=Z(n,t);d(gn,e>=0&&o>=0&&e<=r&&o<=r,`invalid offset: ${e}, ${o}, length: ${r}`);const i=ZC(t),s=i.findIndex(C=>C.startBlockOffset<=e&&e<C.endBlockOffset),l=i.findIndex(C=>C.startBlockOffset<o&&o<=C.endBlockOffset);if(d(gn,s!==-1,"failed to find start child"),d(gn,l!==-1,"failed to find end child"),d(gn,s<=l,`invalid start index & end index: ${s}, ${l}`),s===l){const C=i[s];return[{child:C.child,startChildOffset:e-C.startBlockOffset,endChildOffset:o-C.startBlockOffset}]}const c=[],a=i[s],u={child:a.child,startChildOffset:e-a.startBlockOffset,endChildOffset:Re(a.child)};c.push(u);for(let C=s+1;C<l;C++){const v=i[C],w={child:v.child,startChildOffset:0,endChildOffset:v.endBlockOffset-v.startBlockOffset};c.push(w)}const f=i[l],m={child:f.child,startChildOffset:0,endChildOffset:o-f.startBlockOffset};return c.push(m),c}function QC(n){const t=(o,r)=>o.left<=r.left&&o.top<=r.top&&o.right>=r.right&&o.bottom>=r.bottom&&(o.width!==r.width||o.height!==r.height);n=n.filter(o=>!n.find(i=>t(o,i)));const e=[];return n=n.filter(o=>e.find(r=>r.left===o.left&&r.top===o.top&&r.width===o.width&&r.height===o.height)?!1:(e.push(o),!0)),n}function Cg(n,t,e,o){if(Z(n,t)===0){const u=rt(t).getBoundingClientRect();return[new DOMRect(u.left,u.top,4,u.height)]}const r=e.offset,i=o.offset;if(r===i)return[Oe(t,e)];const l=YC(n,t,r,i).map(a=>WC(a.child,a.startChildOffset,a.endChildOffset)),c=[];return l.forEach(a=>{const u=QC(Array.from(a.getClientRects()));c.push(...u)}),c}function KC(n,t,e){d(gn,e instanceof se,"invalid range");const o=e.start,r=e.end;return d(gn,o.isSimple(),"text block only allow simple position"),d(gn,r.isSimple(),"text block only allow simple position"),d(gn,o.blockId===r.blockId,"only allow update one text block selection"),d(gn,o.blockId===G(t),"only allow update one text block selection"),Cg(n,t,o,r)}const x1=y("selection-background");function JC(n,t,e,o){d(x1,e.isSimple(),"text block only allow simple position"),d(x1,o.isSimple(),"text block only allow simple position"),d(x1,e.blockId===o.blockId,"only allow update one text block selection");const r=e.offset,i=o.offset;if(r===i&&(Z(n,t)!==0||n.selection.range.isCollapsed()))return;const s=Cg(n,t,e,o),l=t.getBoundingClientRect(),c=xm(t);c.innerHTML="",s.forEach(a=>{const u=b("div",["editor-selection-background"],c);u.style.left=`${a.left-l.left}px`,u.style.top=`${a.top-l.top}px`,u.style.width=`${a.width}px`,u.style.height=`${a.height}px`})}function XC(n){n.rootContainer.querySelectorAll("div[data-type=block-background]").forEach(t=>{t.remove()})}const No=y("text-offset"),bg="\u200D";function Er(n,t){const e=Hn(n);let o=0;for(let r=0;r<e.length;r++){const i=e[r],s=Re(i);if(i===t){const l=o+s;return{start:o,end:l}}o+=s}d(No,!1,"can not find child in children")}function fe(n,t){d(No,t>=0,`invalid offset: ${t}`);const e=gl(n,t),{prev:o,next:r,offset:i}=e;if(!o&&!r&&d(No,!1,"invalid offset, no prev & next child at offset"),o!==r)return!0;const s=o;if(d(No,s,"no child"),Me(s))return d(No,i===0||i===1,`invalid box child offset: ${i}`),!0;const l=s.textContent;d(No,l,"no content for text child");const c=l.charAt(i-1),a=l.charAt(i);return!(c===bg||a===bg||Ua(l[i]))}function Po(n,t){if(t===0)return 0;const e=t-1;if(fe(n,e))return e;let o=e-1;for(;!fe(n,o);)o-=1;return o}function Ir(n,t){const e=Ri(n);if(d(No,t>=0&&t<=e,`invalid offset: ${t}, ${e}`),t===e)return e;const o=t+1;if(fe(n,o))return o;let r=o+1;for(;!fe(n,r);)r+=1;return r}const $o=y("line-breaker");function Ai(n){const t=c=>{const a=Js(c);return xo(c).top>a.top+a.height/2},e=(c,a)=>{const u=xo(c);return Js(a).left<u.right},o=(c,a)=>{const u=xo(c),f=xo(a);return f.top+f.height/2>u.bottom},r=c=>{if(c.length===0||c.length===1)return!1;const a=c[0],u=c[c.length-1];return a.right-u.left>10},i=[];let s=0;const l=Hn(n);for(let c=0;c<l.length;c++){const a=l[c];if($n(a)){const E=a,L=l[c+1];if(!L)break;const x=l[c-1];if(x&&o(x,E)&&i.push({offset:s,type:"betweenChild",childInfo:{prevChild:x,nextChild:E,wrap:"nextWrapped",prevWrapped:t(x),nextWrapped:t(E)}}),e(E,L)){i.push({offset:s,type:"betweenChild",childInfo:{prevChild:x,nextChild:E,wrap:"nowrap",prevWrapped:t(x),nextWrapped:t(E)}});continue}continue}if(Me(a)){const E=a,L=l[c+1];if(!L)break;const x=l[c-1];if(x&&o(x,E)&&i.push({offset:s,type:"betweenChild",childInfo:{prevChild:x,nextChild:E,wrap:"nextWrapped",prevWrapped:t(x),nextWrapped:t(E)}}),e(E,L)){s+=1,i.push({offset:s,type:"betweenChild",childInfo:{prevChild:x,nextChild:a,wrap:"nowrap",prevWrapped:t(x),nextWrapped:t(a)}});continue}s+=1;continue}const u=a,f=u.getClientRects();if(d($o,f.length>0,"invalid text child dom"),f.length===1){const E=l[c+1];if(!E)break;if(e(u,E)){s+=Re(u),i.push({offset:s,type:"betweenChild",childInfo:{prevChild:u,nextChild:E,wrap:"nowrap",prevWrapped:t(u),nextWrapped:t(E)}});continue}s+=Re(u);continue}const m=u.firstChild;d($o,m,"invalid text child, no text node"),d($o,m instanceof Text,`invalid text child, not a valid text node: ${typeof m}`);const C=document.createRange(),v=document.createRange(),w=Re(u);d($o,m.data.length===w,"text node data length not equal child text length");for(let E=0;E<m.data.length;E++){if(!fe(n,s+E))continue;C.setStart(m,E),Qa()&&C.selectNodeContents(m);const L=C.getClientRects();if(d($o,L.length>=1,"invalid text node, no client rects"),r(L)){const V=s+E;i.push({offset:V,type:"textBreakWord",childInfo:{prevChild:a,nextChild:a,wrap:"nowrap",prevWrapped:t(a),nextWrapped:t(a)}});continue}let x=E+1;fe(n,s+x)||(x=E+2),v.setStart(m,x);const A=v.getClientRects(),O=L[0];A[0].left<O.right&&d($o,!1,"span pre-wrap should not has a line-wrap by white space")}s+=w}return i}function S1(n,t){const e=Ai(n);for(let o=0;o<e.length;o++){const{offset:r,type:i}=e[o];if(t.offset<r)return{lineIndex:o,lineBreaks:e};if(t.offset===r&&t.type==="end")return{lineIndex:o,lineBreaks:e}}return d($o,t.offset<=Ri(n),"invalid position, offset > block length"),{lineIndex:e.length,lineBreaks:e}}const tb=y("line-offset");function T1(n){const t=Ai(n),e=[];let o=0;for(let r=0;r<t.length;r++){const i=t[r];e.push({start:o,end:i.offset}),o=i.offset}return e.push({start:o,end:Ri(n)}),e}function Cl(n,t){const e=T1(n);return d(tb,t>=0&&t<e.length,`invalid line index: ${t}, ${e.length}`),e[t]}function vg(n,t){const{lineIndex:e}=S1(n,t);return Cl(n,e)}function eb(n){const t=T1(n),e=n.getBoundingClientRect(),o=[];return t.forEach(({start:r,end:i})=>{const s=$(n,r,"home");let l=Oe(n,s);const c=$(n,i,"end"),a=Oe(n,c);l.top+l.height/2<a.top&&(l=new DOMRect(e.left-1e4,a.top,1,a.height));const u=new DOMRect(l.left,a.top,a.left-l.left,a.height),f=new DOMRect(e.left,a.top,e.width,a.height);o.push({start:r,end:i,rect:f,contentRect:u})}),o}function nb(n,t,e){const r=eb(n).find(s=>To(s.rect,t,e));if(!r)return null;const i=r.contentRect;return t-i.left<i.right-t?$(n,r.start,"home"):$(n,r.end,"end")}function kg(n,t,e){const o=Oe(n,t),r=Oe(n,e),i=o.top+o.height/2,s=r.top+r.height/2,l=r.top<i&&i<r.bottom,c=o.top<s&&s<o.bottom;return l&&c}function yg(n){return T1(n).length}const Ho=y("find-text-position");function wg(n,t){const{start:e,end:o}=Cl(n,t),r=G(n),i=Oe(n,$(r,e,"home"));if(!(Oe(n,$(r,o,"end")).top>i.top+i.height/2))return!1;const c=gl(n,e);return d(Ho,c.next,"no next child at offset"),d(Ho,!Mi(c.next),"next child is not text child"),!0}function ob(n,t){const e=G(n);d(Ho,wg(n,t),"line is not wrapped");const{start:o,end:r}=Cl(n,t),i=$(e,o,"home");for(let s=o+1;s<=r;s+=1){let l="normal";s===o?l="home":s===r&&(l="end");const c=$(e,s,l);if(!kg(n,i,c))return s-1}return d(Ho,!1,"failed to find wrapped offset"),0}function bl(n,t,e,o,r,i,s){d(Ho,j(n,t),`not a text kind block: ${it(t)}`);const{start:l,end:c}=Cl(t,e);let a=l;const u=G(t);if(t===o&&wg(t,e)){const E=ob(t,e);(i==="up"||i==="down"&&kg(t,r,$(u,l,"home")))&&(a=E+1)}let f=Number.MAX_SAFE_INTEGER;const m=Ge(n,o,r),C=s!=null?s:m.left+m.width/2,v=m.top+m.height/2;let w=$(u,a,"home");for(let E=a;E<=c;E++){if(!fe(t,E))continue;let L="normal";E===l?L="home":E===c&&(L="end");const x=$(u,E,L),A=Oe(t,x),O=hn(A,C,v);O<f&&(f=O,w=x)}return w}function rb(n,t,e,o,r){return d(Ho,j(n,t),"not a text block"),bl(n,t,yg(t)-1,e,o,"up",r)}function ib(n,t,e,o,r){return d(Ho,j(n,t),"not a text block"),bl(n,t,0,e,o,"down",r)}function sb(n,t,e,o){const{lineIndex:r}=S1(t,e);if(r===yg(t)-1)return null;const i=bl(n,t,r+1,t,e,"down",o);return i||null}function lb(n,t){if(t.offset===0)return null;const e=Ai(n),o=e.find(r=>r.offset===t.offset);if(!o){const r=Po(n,t.offset);return e.find(s=>s.offset===r)?{offset:r,type:"home"}:{offset:r,type:"normal"}}if(o.type==="betweenChild"){if(t.type==="home"&&o.childInfo.wrap==="nowrap")return{offset:t.offset,type:"end"};if(o.childInfo.prevWrapped)return{offset:Po(n,t.offset),type:"normal"}}return{offset:Po(n,t.offset),type:"normal"}}function cb(n,t){const e=Ri(n);if(t.offset===e)return null;const o=Ai(n),r=o.find(i=>i.offset===t.offset);if(!r){const i=Ir(n,t.offset),s=o.find(l=>l.offset===i);return s?s.type==="betweenChild"?{offset:i,type:"end"}:{offset:i,type:"home"}:{offset:i,type:"normal"}}return r.type==="betweenChild"?r.childInfo.wrap==="nowrap"&&t.type==="end"?{offset:t.offset,type:"home"}:{offset:Ir(n,t.offset),type:"home"}:{offset:Ir(n,t.offset),type:"normal"}}function ab(n,t,e,o){const{lineIndex:r}=S1(t,e);if(r===0)return null;const i=bl(n,t,r-1,t,e,"up",o);return i||null}const db=y("move-caret");function ub(n,t,e,o){if(o==="ArrowLeft"){const r=lb(t,e);return r?$(G(t),r.offset,r.type):null}if(o==="ArrowRight"){const r=cb(t,e);return r?$(G(t),r.offset,r.type):null}if(o==="ArrowUp"){const r=ab(n,t,e,n.selection.getSuggestedCaretX());return r?$(G(t),r.offset,r.type):null}if(o==="ArrowDown"){const r=sb(n,t,e,n.selection.getSuggestedCaretX());return r?$(G(t),r.offset,r.type):null}d(db,!1,`invalid navigation direction: ${o}`)}const D1=y("text-range");function hb(n){const t=[];return Hn(n).forEach(o=>{const r=Array.from(o.getClientRects()).map(i=>({rect:i,child:o}));t.push(...r)}),t}function fb(n,t,e){const o=hb(n);for(let r=1;r<o.length;r++){const i=o[r-1],s=o[r];if(t>=i.rect.right&&t<=s.rect.left&&e>=i.rect.top&&e<=i.rect.bottom&&e>=s.rect.top&&e<=s.rect.bottom)return Er(n,s.child).start}return null}function mb(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t))return null;const i=r.closest("div[data-type=block-content]>span");if(!i){const L=t.getBoundingClientRect();if(!To(L,e,o))return null;const x=fb(t,e,o);if(x!==null){const O=$(t,x,"normal");return new se(n,{anchor:O,focus:O})}const A=nb(t,e,o);return A?new se(n,{anchor:A,focus:A}):null}const s=Hn(t);d(D1,s.indexOf(i)!==-1,"failed to find child in children");const l=Er(t,i);d(D1,l,"failed to get child offset");const{start:c}=l;let a,u;$n(i)||Me(i)?(a=c,u=0):(d(D1,i.firstChild instanceof Text,"child is not text"),a=c+zf(i.firstChild,e,o),u=0);const f=G(t),C=Ai(t).find(L=>L.offset===a);let v="normal";if(C){const L=$(f,a,"home"),x=$(f,a,"end"),A=Oe(t,L),O=Oe(t,x),P=hn(A,e,o),V=hn(O,e,o);v=P<V?"home":"end"}const w=$(f,a,v);let E;return u&&(E=$(f,a+u,v)),new se(n,{anchor:w,focus:E!=null?E:w})}const gb=y("create-text-op");function _e(n,t){d(gb,n,"text is empty");const e={insert:n};return t&&Object.keys(t).length>0&&(e.attributes=t),e}function L1(n,t){if(n.length===0)return[];if(n.indexOf(`
16
16
  `)===-1)return[_e(n,t)];const e=n.replace(/\r\n/g,`
17
17
  `).replace(/\r/g,`
18
18
  `).replace(/\n/g," "),o=[];return e&&o.push(_e(e,t)),o}const vl=y("merge-ops");function M1(n){if(n.length<=1)return n;const t=(r,i)=>r.insert===void 0||i.insert===void 0||r.delete!==void 0||i.delete!==void 0||r.retain!==void 0||i.retain!==void 0||r.attributes!==void 0&&i.attributes===void 0||r.attributes===void 0&&i.attributes!==void 0?!1:r.attributes===void 0?(d(vl,i.attributes===void 0,"op2.attributes is not undefined"),!0):(d(vl,r.attributes&&i.attributes,"op1.attributes && op2.attributes is undefined"),Zs.default(r.attributes,i.attributes)),e=[];let o=n[0];e.push(o);for(let r=1;r<n.length;r+=1){const i=n[r];t(o,i)?(d(vl,typeof o.insert=="string","before.insert is not string"),d(vl,typeof i.insert=="string","op.insert is not string"),o.insert+=i.insert):(e.push(i),o=i)}return e}function pb(n){let t;for(t=n.length-1;t>=0;t--){const e=n[t];if(!e.attributes||!e.attributes.box||e.attributes.type!=="br")break}return t===n.length-1?n:n.slice(0,t+1)}const Bg=y("delete-text");function R1(n,t,e){const{left:o,right:r}=Kt(n,t,e),i=[...o,...r];return M1(i)}function Eg(n,t){d(Bg,n>=0,`invalid offset: ${n}`),d(Bg,t>=1,`invalid delete count: ${t}`);const e=[];return n!==0&&e.push({retain:n}),e.push({delete:t}),e}const Ig=y("delta");function xg(n,t){const e=new ee.default(n),o=new ee.default(t);return e.diff(o).ops}function Cb(n,t,e){return new ee.default(t).transformPosition(n,!e)}function bb(n){d(Ig,n,"ops is null or undefined");for(let t=0;t<n.length;t++){const e=n[t];if(e.insert===null||e.insert===void 0||e.retain!==void 0||e.delete!==void 0)return!1}return!0}function vb(n,t){const e=new ee.default(n),o=new ee.default(t);return e.compose(o).ops}class ne{static ensureValidText(t){d(Ig,bb(t),`text is not a valid text, ${JSON.stringify(t)}`)}static diff(t,e){return this.ensureValidText(t),this.ensureValidText(e),xg(t,e)}static transformCursor(t,e,o){return Cb(t,e,o)}static transformOffset(t,e,o){const r=xg(t,e),i=new ee.default(r);return o.map(s=>i.transformPosition(s))}static apply(t,e){this.ensureValidText(t);const o=vb(t,e);return this.ensureValidText(o),o}}const Sg=y("insert-text");function xr(n,t,e,o){d(Sg,e,`invalid text to insert: ${e}`);const{left:r,right:i}=Ae(n,t),s=typeof e=="string"?[_e(e,o)]:e,l=[...r,...s,...i];return M1(l)}function Tg(n){return{insert:" ",attributes:n}}function kl(n,t,e){if(d(Sg,n>=0,`invalid offset: ${n}`),t.length===0)return[];const o=[];if(n>0&&o.push({retain:n}),typeof t!="string")return o.push(...t),o;const i={insert:t.replaceAll(`\r
19
19
  `," ").replaceAll(`
20
20
  `," ").replaceAll("\r"," ")};return e&&Object.keys(e).length>0&&(i.attributes=e),o.push(i),o}function kb(n,t){return[...n,...t]}const Dg=y("text-op");function A1(n){return d(Dg,typeof n.insert=="string","invalid op, no insert"),n.insert.length}function Lg(n,t){const e=n;let o=0;for(let r=0;r<e.length;r++){const i=e[r];d(Dg,typeof i.insert=="string","invalid text op, no insert");const s=o+A1(i);if(s>t)return[i];if(s===t){const l=[i];return r<e.length-1&&l.push(e[r+1]),l}o=s}return[]}const O1="style-color-",_1="style-bg-color-";function yl(n,t,e){const o=Y.default(n);return o.forEach(r=>{if(!(r.attributes&&r.attributes.box===!0))if(e===void 0){if(!r.attributes||r.attributes[t]===void 0)return;delete r.attributes[t],Object.keys(r.attributes).length===0&&delete r.attributes}else r.attributes||(r.attributes={}),r.attributes[t]=e}),o}function N1(n,t,e,o){const r=Y.default(n);return r.forEach(i=>{i.attributes&&i.attributes.box===!0||i.attributes&&((o==null?void 0:o.ignoreValue)||i.attributes[t]===e)&&(delete i.attributes[t],Object.keys(i.attributes).length===0&&delete i.attributes)}),r}function wl(n,t,e,o,r){if(t===0)return e;const i=Kt(e,n,t);return[...i.left,...yl(i.middle,o,r),...i.right]}function Sr(n,t,e,o,r,i){if(t===0)return e;const s=Kt(e,n,t);return[...s.left,...N1(s.middle,o,r,i),...s.right]}function Bl(n,t){const e=Lg(n,t);if(e.length===1)return e[0].attributes;if(e.length===2)return e[1].attributes}function Mg(n,t,e,o){if(t===0)return e;const r=Kt(e,n,t),i=r.middle.map(s=>o(s));return[...r.left,...i,...r.right]}function Rg(n,t){t==="color"?Object.keys(n).forEach(e=>{e.startsWith("style-color-")&&delete n[e]}):t==="backgroundColor"&&Object.keys(n).forEach(e=>{e.startsWith("style-bg-color-")&&delete n[e]})}function yb(n,t){if(!n.attributes||n.attributes.box)return;const e=n.attributes;Rg(e,t),Object.keys(e).length===0&&delete n.attributes}function wb(n,t,e){n.attributes||(n.attributes={}),!n.attributes.box&&(t==="color"?n.attributes[`style-color-${e}`]=!0:n.attributes[`style-bg-color-${e}`]=!0)}function Ag(n,t,e,o,r){const i=Y.default(e);return Mg(n,t,i,l=>(yb(l,o),r!==null&&wb(l,o,r),l))}function P1(n){var r,i;if(!n||n.box)return[null,null];const t=Array.from(Object.keys(n));let e=null,o=null;for(let s=0;s<t.length;s++){const l=t[s];l.startsWith(O1)?e=(r=Number.parseInt(l.substring(O1.length),10))!=null?r:null:l.startsWith(_1)&&(o=(i=Number.parseInt(l.substring(_1.length),10))!=null?i:null)}return[e,o]}function Og(n,t,e){Rg(n,t),t==="color"?n[`style-color-${e}`]=!0:n[`style-bg-color-${e}`]=!0}function _g(n){return n.attributes?n.attributes.box?[null,null]:P1(n.attributes):[null,null]}function Ng(n,t,e){let o=[];if(t===0?n!==0&&(o=Kt(e,n-1,1).middle):o=Kt(e,n,t).middle,o.length===0)return[null,null];let[r,i]=_g(o[0]);if(r===null&&i===null)return[r,i];for(let s=1;s<o.length;s++){const l=o[s];if(!l.attributes)return[null,null];if(l.attributes.box)continue;const[c,a]=_g(l);c===null||r===null?r=null:r=c===r?r:null,a===null||i===null?i=null:i=a===i?i:null}return[r,i]}function Pg(n){return Y.default(n)}const Bb=y("update-op-attribute");function $g(n,t,e,o){const r=Pg(n),i=r.findIndex(l=>l.attributes?l.attributes[t]===e:!1);d(Bb,i!==-1,`can not find op by key: ${t}, value: ${e}`);const s=r[i];return s.attributes={...s.attributes,...o},r}const Eb="\u200B",Ib=y("to-plain-text");function Tt(n,t){let e="";return n.forEach(o=>{if(d(Ib,typeof o.insert=="string","invalid op"),o.attributes&&o.attributes.box===!0){if(t!=null&&t.boxReplacement){e+=t.boxReplacement;return}if(o.attributes.text){e+=o.attributes.text;return}e+=" "}e+=o.insert}),e}function El(n,t,e,o){const r=Bl(n,t),i=R1(n,t,e-t);return o?xr(i,t,o,r!=null?r:null):i}function $1(n,t){if(!t)return[];const e=t.length,o=Tt(n,{boxReplacement:" "}).toLowerCase();t=t.toLowerCase();let r=o.indexOf(t,0);const i=[];for(;r!==-1;)i.push({start:r,end:r+e}),r=o.indexOf(t,r+e);return i}function Hg(n,t,e,o){const r=$1(n,t);let i=Y.default(n);return r.length===0||(r.reverse().forEach(s=>{i=El(i,s.start,s.end,e)}),o&&(o.count=r.length)),i}function Oi(n,t){return n?[{insert:n,attributes:t}]:[]}function jn(n,t){return{id:N(),type:"text",text:typeof n=="string"?Oi(n):n,...t}}function Il(n){return jn(n!=null?n:"")}function oo(n,t){return{blocks:{root:(n!=null?n:"").replaceAll("\r","").split(`
21
- `).map((r,i)=>{const l=i===0&&(t==null?void 0:t.firstLineAsTitle)?{"style-heading":1}:void 0;return jn(r,l)})},meta:{},comments:{}}}function xl(n){const t=n.blocks.root;if(t.length!==1)return!1;const e=t[0];return!(!e.text||ce(e.text))}function jg(n,t){const e=N();return n.localInsertChildContainer(e,t),e}function pn(n,t){return jg(n,[Il(t)])}function Fg(n){return typeof n.offset=="number"}function Sl(n){return Fg(n.anchor)}function zg(n){return Sl(n)&&n.anchor.offset===n.focus.offset&&n.anchor.blockId===n.focus.blockId}function Vg(n,t){return{blockId:n,offset:t}}function Tl(n,t){const e=Vg(n,t);return{anchor:e,focus:e}}function Ug(n,t){return{blockId:n,childContainerId:t}}function xb(n,t){const e=Ug(n,t);return{anchor:e,focus:e}}const H1=y("text-block");function Sb(n,t,e,o,r){const{text:i}=r;d(H1,i,"no text for text block");const s=eo(o,"div");return o.classList.add("drag-preview-element"),pl(n,t,r.id,s,i),s}function Tb(n,t,e){d(H1,e,"no text to update");const o=eo(null,"div");o.classList.add("drag-preview-element"),pl(n,Ro(t),G(t),o,e);const r=rt(t);xi(r,o)}function Db(n,t,e){return KC(n,t,e)}function qg(n,t){let e="";return t.forEach(o=>{if(!!o.insert){if(o.attributes&&o.attributes.box===!0&&o.attributes.type==="math"){e+=`[${S.t("mathjax.abstract")}] `;return}e+=o.insert}}),e}function Lb(n,t){d(H1,j(n,t),"block in not textBlock");const e=n.selection.range;let o="";if(e.isCollapsed()){const r=n.getBlockText(t);o=qg(n,r)}else{const r=G(t),i=Qe(n,{simpleBlockOnly:!0}).find(s=>G(s.block)===r);if(i&&!wt(n,i.block)){const s=n.getBlockText(t),{start:l,end:c}=i,a=l.offset,u=c.offset-a,{middle:f}=Kt(s,a,u);o=qg(n,f)}}return{abstract:o.trim()}}const _i={blockType:"text",blockKind:"text",createBlockContent:Sb,getBlockTextLength:Ri,getRangeFromPoint:mb,moveCaret:ub,updateSelection:JC,clearSelection:XC,getCaretRect:Oe,getClientRects:Db,setBlockText:Tb,getBlockProperties:Lb},Mb=pl,Wg=y("text-box");function Rb(n,t,e,o){d(Wg,o.text,`no text for text box data: ${JSON.stringify(o)}`),d(Wg,typeof o.text=="string",`invalid text type for text box data: ${JSON.stringify(o)}`),b("span",[],e,o.text)}const Gg={boxType:"text",updateBoxContent:Rb},Ab="data:image/svg+xml;base64,Cjxzdmcgdmlld0JveD0iMCAwIDI0IDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNMTguMjQ0NSA2QzE3LjgyNzQgNiAxNy41MzYzIDYuMjkxMTcgMTcuNTM2MyA2LjcwODI2QzE3LjUzNjMgNi45ODM3IDE3LjU1OTkgNy4yMzU1MyAxNy41NTk5IDcuNjEzMjdDMTcuNTU5OSAxMC4yODExIDE2LjYyMzQgMTEuMzc0OSAxMy45NzkyIDExLjM3NDlIOC45NDI2Nkw3LjEyNDc5IDExLjQ4NTFMOS41NDA3NSA5LjI4MTYyTDExLjE5MzQgNy41OTc1M0MxMS4zMjcxIDcuNDcxNjEgMTEuMzk4IDcuMjgyNzQgMTEuMzk4IDcuMDkzODdDMTEuMzk4IDYuNjkyNTIgMTEuMDk4OSA2LjQwMTM1IDEwLjY5NzYgNi40MDEzNUMxMC41MDg3IDYuNDAxMzUgMTAuMzM1NiA2LjQ3MjE4IDEwLjE3ODIgNi42MjE3TDUuMjQzOTYgMTEuNTQ4MUM1LjA4NjU3IDExLjcwNTUgNSAxMS44OTQzIDUgMTIuMDkxMUM1IDEyLjI4NzggNS4wODY1NyAxMi40NzY3IDUuMjQzOTYgMTIuNjI2MkwxMC4xNjI1IDE3LjUzNjhDMTAuMzM1NiAxNy43MDk5IDEwLjUwODcgMTcuNzgwOCAxMC42OTc2IDE3Ljc4MDhDMTEuMDk4OSAxNy43ODA4IDExLjM5OCAxNy40ODk2IDExLjM5OCAxNy4wODgzQzExLjM5OCAxNi44OTE1IDExLjMyNzEgMTYuNzEwNSAxMS4xOTM0IDE2LjU4NDZMOS41NDA3NSAxNC45MDA1TDcuMTMyNjYgMTIuNjk3TDguOTQyNjYgMTIuODA3MkgxNC4wNTc5QzE3LjU1OTkgMTIuODA3MiAxOSAxMS4yNDExIDE5IDcuNjc2MjJDMTkgNy4yMzU1MyAxOC45OTIxIDYuODY1NjUgMTguOTM3IDYuNjEzODNDMTguODc0MSA2LjI5OTA0IDE4LjY3NzMgNiAxOC4yNDQ1IDZaIiBmaWxsPSIjQjJCQ0NEIi8+Cjwvc3ZnPgo=";function Ob(n,t,e,o){jf(Ab,[],e),b("br",[],e)}const Zg={boxType:"br",updateBoxContent:Ob},Yg=y("editor-boxes");class Qg{constructor(t){h(this,"boxes",new Map);this.editor=t}registerBoxClass(t){const e=t.boxType,o=this.boxes.get(e);d(Yg,!o,`duplicated box type: ${e}`),this.boxes.set(e,t)}getBoxClass(t){const e=this.boxes.get(t);return d(Yg,e,`unknown box type: ${t}`),e}createBox(t,e){const o=Tm(e),r=Lm(o);return this.getBoxClass(e.type).updateBoxContent(this.editor,o,r,e),o}}function _b(n,t,e,o){b("span",[],e,o.text)}const Kg={insertionType:"inputting",updateInsertionContent:_b},Jg=y("editor-insertion");class Xg{constructor(t){h(this,"insertions",new Map);this.editor=t}registerInsertionClass(t){const e=t.insertionType,o=this.insertions.get(e);d(Jg,!o,`duplicated insertion type: ${e}`),this.insertions.set(e,t)}getInsertionClass(t){const e=this.insertions.get(t);return d(Jg,e,`unknown insertion type: ${t}`),e}createInsertion(t,e){const o=Mm(e.type,e.id),r=Am(o);return this.getInsertionClass(e.type).updateInsertionContent(this.editor,o,r,e),o}}class Nb{constructor(t){h(this,"cursors",new Map);h(this,"timer");this.editor=t,this.timer=this.startTimer()}add(t,e){this.cursors.set(t,e)}startTimer(){return setInterval(()=>{const t=Date.now();Array.from(this.cursors).forEach(([e,o])=>{if(t-o>3e3){const r=Rm(this.editor,e);r&&F(r,"active"),this.cursors.delete(e)}})},1e3)}destroy(){clearInterval(this.timer)}}function Pb(n,t,e,o){var l;const r=o;Date.now()-r.time<5*1e3&&(n.addCustom("active-cursors",a=>new Nb(a)).add(r.id,r.time),M(t,"active")),b("span",[],e,"|").setAttribute("data-cursor-name",r.name),t.style.setProperty("--cursor-color",n.getColor((l=r.rainbowIndex)!=null?l:0))}const j1={insertionType:"remote-cursor",updateInsertionContent:Pb};class t2{constructor(t){h(this,"decorators",[]);this.editor=t}registerDecorator(t){this.decorators.push(t)}decorateBlock(t,e){let o=e;return this.decorators.forEach(r=>{if(r.decorateBlock){const i=r.decorateBlock(this.editor,t,e);i&&(o=Y.default(i))}}),o}decorateText(t,e){let o=e;const r=new Map;return this.decorators.forEach(i=>{if(i.decorateText){const s=i.decorateText(this.editor,t,e);if(s){const{insertions:l,text:c}=s;l&&Array.from(l.entries()).forEach(([a,u])=>{const f=r.get(a);f?f.push(...u):r.set(a,u)}),c&&(o=Y.default(c))}}}),{insertions:r,text:o}}}const $b=y("block-to-html");function F1(n,t,e){const o=vr(n,t.type);if(o.convertTo)return o.convertTo(n,t,e,"html");if(o.blockKind!=="text")return`[${t.type}]`;d($b,t.text,"no text");const r=Tt(t.text);return`<div>${Wf(r)}</div>`}const Hb=y("block-to-text");function Dl(n,t,e){const o=vr(n,t.type);return o.convertTo?o.convertTo(n,t,e,"text"):o.blockKind!=="text"?`[${t.type}]`:(d(Hb,t.text,"no text"),Tt(t.text))}function e2(n,t,e){const o=vr(n,t.type);return o.convertTo?o.convertTo(n,t,e,"markdown"):Dl(n,t,e)}function n2(n,t){return t.blocks.root.map(r=>F1(n,r,t)).join(`
21
+ `).map((r,i)=>{const l=i===0&&(t==null?void 0:t.firstLineAsTitle)?{"style-heading":1}:void 0;return jn(r,l)})},meta:{},comments:{}}}function xl(n){const t=n.blocks.root;if(t.length!==1)return!1;const e=t[0];return!(!e.text||ce(e.text))}function jg(n,t){const e=N();return n.localInsertChildContainer(e,t),e}function pn(n,t){return jg(n,[Il(t)])}function Fg(n){return typeof n.offset=="number"}function Sl(n){return Fg(n.anchor)}function zg(n){return Sl(n)&&n.anchor.offset===n.focus.offset&&n.anchor.blockId===n.focus.blockId}function Ug(n,t){return{blockId:n,offset:t}}function Tl(n,t){const e=Ug(n,t);return{anchor:e,focus:e}}function Vg(n,t){return{blockId:n,childContainerId:t}}function xb(n,t){const e=Vg(n,t);return{anchor:e,focus:e}}const H1=y("text-block");function Sb(n,t,e,o,r){const{text:i}=r;d(H1,i,"no text for text block");const s=eo(o,"div");return o.classList.add("drag-preview-element"),pl(n,t,r.id,s,i),s}function Tb(n,t,e){d(H1,e,"no text to update");const o=eo(null,"div");o.classList.add("drag-preview-element"),pl(n,Ro(t),G(t),o,e);const r=rt(t);xi(r,o)}function Db(n,t,e){return KC(n,t,e)}function qg(n,t){let e="";return t.forEach(o=>{if(!!o.insert){if(o.attributes&&o.attributes.box===!0&&o.attributes.type==="math"){e+=`[${S.t("mathjax.abstract")}] `;return}e+=o.insert}}),e}function Lb(n,t){d(H1,j(n,t),"block in not textBlock");const e=n.selection.range;let o="";if(e.isCollapsed()){const r=n.getBlockText(t);o=qg(n,r)}else{const r=G(t),i=Qe(n,{simpleBlockOnly:!0}).find(s=>G(s.block)===r);if(i&&!wt(n,i.block)){const s=n.getBlockText(t),{start:l,end:c}=i,a=l.offset,u=c.offset-a,{middle:f}=Kt(s,a,u);o=qg(n,f)}}return{abstract:o.trim()}}const _i={blockType:"text",blockKind:"text",createBlockContent:Sb,getBlockTextLength:Ri,getRangeFromPoint:mb,moveCaret:ub,updateSelection:JC,clearSelection:XC,getCaretRect:Oe,getClientRects:Db,setBlockText:Tb,getBlockProperties:Lb},Mb=pl,Wg=y("text-box");function Rb(n,t,e,o){d(Wg,o.text,`no text for text box data: ${JSON.stringify(o)}`),d(Wg,typeof o.text=="string",`invalid text type for text box data: ${JSON.stringify(o)}`),b("span",[],e,o.text)}const Gg={boxType:"text",updateBoxContent:Rb},Ab="data:image/svg+xml;base64,Cjxzdmcgdmlld0JveD0iMCAwIDI0IDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNMTguMjQ0NSA2QzE3LjgyNzQgNiAxNy41MzYzIDYuMjkxMTcgMTcuNTM2MyA2LjcwODI2QzE3LjUzNjMgNi45ODM3IDE3LjU1OTkgNy4yMzU1MyAxNy41NTk5IDcuNjEzMjdDMTcuNTU5OSAxMC4yODExIDE2LjYyMzQgMTEuMzc0OSAxMy45NzkyIDExLjM3NDlIOC45NDI2Nkw3LjEyNDc5IDExLjQ4NTFMOS41NDA3NSA5LjI4MTYyTDExLjE5MzQgNy41OTc1M0MxMS4zMjcxIDcuNDcxNjEgMTEuMzk4IDcuMjgyNzQgMTEuMzk4IDcuMDkzODdDMTEuMzk4IDYuNjkyNTIgMTEuMDk4OSA2LjQwMTM1IDEwLjY5NzYgNi40MDEzNUMxMC41MDg3IDYuNDAxMzUgMTAuMzM1NiA2LjQ3MjE4IDEwLjE3ODIgNi42MjE3TDUuMjQzOTYgMTEuNTQ4MUM1LjA4NjU3IDExLjcwNTUgNSAxMS44OTQzIDUgMTIuMDkxMUM1IDEyLjI4NzggNS4wODY1NyAxMi40NzY3IDUuMjQzOTYgMTIuNjI2MkwxMC4xNjI1IDE3LjUzNjhDMTAuMzM1NiAxNy43MDk5IDEwLjUwODcgMTcuNzgwOCAxMC42OTc2IDE3Ljc4MDhDMTEuMDk4OSAxNy43ODA4IDExLjM5OCAxNy40ODk2IDExLjM5OCAxNy4wODgzQzExLjM5OCAxNi44OTE1IDExLjMyNzEgMTYuNzEwNSAxMS4xOTM0IDE2LjU4NDZMOS41NDA3NSAxNC45MDA1TDcuMTMyNjYgMTIuNjk3TDguOTQyNjYgMTIuODA3MkgxNC4wNTc5QzE3LjU1OTkgMTIuODA3MiAxOSAxMS4yNDExIDE5IDcuNjc2MjJDMTkgNy4yMzU1MyAxOC45OTIxIDYuODY1NjUgMTguOTM3IDYuNjEzODNDMTguODc0MSA2LjI5OTA0IDE4LjY3NzMgNiAxOC4yNDQ1IDZaIiBmaWxsPSIjQjJCQ0NEIi8+Cjwvc3ZnPgo=";function Ob(n,t,e,o){jf(Ab,[],e),b("br",[],e)}const Zg={boxType:"br",updateBoxContent:Ob},Yg=y("editor-boxes");class Qg{constructor(t){h(this,"boxes",new Map);this.editor=t}registerBoxClass(t){const e=t.boxType,o=this.boxes.get(e);d(Yg,!o,`duplicated box type: ${e}`),this.boxes.set(e,t)}getBoxClass(t){const e=this.boxes.get(t);return d(Yg,e,`unknown box type: ${t}`),e}createBox(t,e){const o=Tm(e),r=Lm(o);return this.getBoxClass(e.type).updateBoxContent(this.editor,o,r,e),o}}function _b(n,t,e,o){b("span",[],e,o.text)}const Kg={insertionType:"inputting",updateInsertionContent:_b},Jg=y("editor-insertion");class Xg{constructor(t){h(this,"insertions",new Map);this.editor=t}registerInsertionClass(t){const e=t.insertionType,o=this.insertions.get(e);d(Jg,!o,`duplicated insertion type: ${e}`),this.insertions.set(e,t)}getInsertionClass(t){const e=this.insertions.get(t);return d(Jg,e,`unknown insertion type: ${t}`),e}createInsertion(t,e){const o=Mm(e.type,e.id),r=Am(o);return this.getInsertionClass(e.type).updateInsertionContent(this.editor,o,r,e),o}}class Nb{constructor(t){h(this,"cursors",new Map);h(this,"timer");this.editor=t,this.timer=this.startTimer()}add(t,e){this.cursors.set(t,e)}startTimer(){return setInterval(()=>{const t=Date.now();Array.from(this.cursors).forEach(([e,o])=>{if(t-o>3e3){const r=Rm(this.editor,e);r&&F(r,"active"),this.cursors.delete(e)}})},1e3)}destroy(){clearInterval(this.timer)}}function Pb(n,t,e,o){var l;const r=o;Date.now()-r.time<5*1e3&&(n.addCustom("active-cursors",a=>new Nb(a)).add(r.id,r.time),M(t,"active")),b("span",[],e,"|").setAttribute("data-cursor-name",r.name),t.style.setProperty("--cursor-color",n.getColor((l=r.rainbowIndex)!=null?l:0))}const j1={insertionType:"remote-cursor",updateInsertionContent:Pb};class t2{constructor(t){h(this,"decorators",[]);this.editor=t}registerDecorator(t){this.decorators.push(t)}decorateBlock(t,e){let o=e;return this.decorators.forEach(r=>{if(r.decorateBlock){const i=r.decorateBlock(this.editor,t,e);i&&(o=Y.default(i))}}),o}decorateText(t,e){let o=e;const r=new Map;return this.decorators.forEach(i=>{if(i.decorateText){const s=i.decorateText(this.editor,t,e);if(s){const{insertions:l,text:c}=s;l&&Array.from(l.entries()).forEach(([a,u])=>{const f=r.get(a);f?f.push(...u):r.set(a,u)}),c&&(o=Y.default(c))}}}),{insertions:r,text:o}}}const $b=y("block-to-html");function F1(n,t,e){const o=vr(n,t.type);if(o.convertTo)return o.convertTo(n,t,e,"html");if(o.blockKind!=="text")return`[${t.type}]`;d($b,t.text,"no text");const r=Tt(t.text);return`<div>${Wf(r)}</div>`}const Hb=y("block-to-text");function Dl(n,t,e){const o=vr(n,t.type);return o.convertTo?o.convertTo(n,t,e,"text"):o.blockKind!=="text"?`[${t.type}]`:(d(Hb,t.text,"no text"),Tt(t.text))}function e2(n,t,e){const o=vr(n,t.type);return o.convertTo?o.convertTo(n,t,e,"markdown"):Dl(n,t,e)}function n2(n,t){return t.blocks.root.map(r=>F1(n,r,t)).join(`
22
22
  `)}function jb(n,t){return`<!doctype html><html><head><meta charset="utf8" /></head><body>${n2(n,t)}</body></html>`}function o2(n,t){return t.blocks.root.map(r=>Dl(n,r,t)).join(`
23
23
  `)}function Fb(n,t){return t.blocks.root.map(r=>e2(n,r,t)).join(`
24
- `)}const Ll=y("action-helper");function ro(n,t){const e=H(t),o=V(e),r=K(t);return n.doc.getBlockData(o,r)}function ke(n,t){d(Ll,j(n,t),"not a text kind block");const o=ro(n,t).text;return d(Ll,o,"no text in block"),o}function Ml(n,t,e){return Ae(ke(n,t),e).left}function r2(n,t){const e=z(t);d(Ll,e,"no parent block");const o=ke(n,e),r=Dm(t),i=o.find(s=>{const l=s.attributes;return l?l.box&&l.id===r:!1});return d(Ll,i,"failed to find box"),i.attributes}const zb=y("get-text-position");function Tr(n,t){const e=t!=null?t:n.selection.range.start;e instanceof Vt||d(zb,!1,`invalid insert pos type: ${typeof e}`);const{blockId:o}=e,r=n.getBlockById(o),i=K(r),s=H(r),l=V(s),{offset:c}=e;return{block:r,container:s,containerId:l,blockIndex:i,offset:c}}const Ni=y("insert-text");function i2(n,t,e,o){var s;const r=n.doc.getBlockData(t,e);if(d(Ni,r,"no block data"),d(Ni,r.text,"no block text"),ce(r.text)===0)return d(Ni,o===0,"invalid text offset"),n.editorCommandProviders.getEmptyBlockTextAttributes(n,r.id);if(o===0)return;const i=Kt(r.text,o-1,1).middle;if(!((s=i[0].attributes)!=null&&s.box))return i[0].attributes}function Vb(n,t,e){const o=H(t),r=V(o),i=K(t);return i2(n,r,i,e)}function s2(n,t,e,o){const r=H(t),i=V(r),s=K(t),l=Vb(n,t,e),c=kl(e,o,l!=null?l:null);return n.doc.localUpdateBlockText(i,s,c),ke(n,t)}function l2(n,t,e,o){const r=H(t),i=V(r),s=K(t),l=kl(e," ",o);return n.doc.localUpdateBlockText(i,s,l),ke(n,t)}function z1(n,t,e,o,r){const i=n.doc.getBlockData(e,o);d(Ni,i,"no block data"),d(Ni,i.text,"no block text");const s=i2(n,e,o,r),l=kl(r,t,s!=null?s:null);return n.doc.localUpdateBlockText(e,o,l),ke(n,n.getBlockById(i.id))}function V1(n,t){n.selection.range.isCollapsed()||n.clearSelectedContents();const{containerId:e,blockIndex:o,offset:r}=Tr(n);z1(n,t,e,o,r)}const Rl=y("update-composition-text");function c2(n){const t=n.selection.range.start;t instanceof Vt||d(Rl,!1,`invalid insert pos type: ${typeof t}`);const{blockId:e}=t,o=n.getBlockById(e);d(Rl,j(n,o),"not a text kind block");const r=H(o),i=V(r),s=K(o),l=n.doc.getBlockData(i,s);d(Rl,l,"no block data in doc"),d(Rl,l.text,"no text data in text block");const c=rt(o);pl(n,Ro(o),e,c,l.text)}function a2(n){UC(n)}function Dr(n,t,e,o,r){return n.doc.localInsertBlock(t,e,o,r),n.getBlockById(o.id)}const Al=y("delete-block-text");function U1(n,t,e,o){d(Al,j(n,t),"block is not a text kind block");const r=H(t),i=V(r),s=K(t),l=n.doc.getBlockData(i,s);d(Al,l,"no block data in doc"),d(Al,l.text,"no text data in text block");let c=e;fe(t,e)||(c=Po(t,c));let a=e+o;d(Al,a<=Z(n,t),`invalid offset and count: ${e}, ${o}`),fe(t,a)||(a=Ir(t,a));const u=a-c,f=Eg(c,u);return n.doc.localUpdateBlockText(i,s,f),u}const q1=y("break-text-block");function d2(n,t){const o=n.getBlockData(t).quoted;return o?{quoted:o}:{}}function Pi(n,t,e,o){d(q1,j(n,t),`block is not a text kind block: ${it(t)}`),d(q1,e>=0&&e<=Z(n,t),`invalid offset: ${e}`);const r=H(t),i=V(r),s=K(t),l=o!=null&&o.copyBlockAttributes?d2(n,t):{};if(!(o!=null&&o.forceInsertAfter)&&(e===0||e===Z(n,t))){const C=e===0?s:s+1,v={...jn(""),...l,...o==null?void 0:o.newBlockData},w=Ot(n,t.id,0),E=Dr(n,i,C,v,w);return{block:t,newBlock:E}}d(q1,fe(t,e),"not a valid offset");const c=ke(n,t),{right:a}=Ae(c,e),u=ce(a);u>0&&U1(n,t,e,u);const f={...jn(a),...l,...o==null?void 0:o.newBlockData},m=Dr(n,i,s+1,f,Ot(n,f.id,0));return{block:t,newBlock:m}}const Ub=y("prepare-insert-new-block");function qb(n,t,e){if(t&&e!==void 0&&e!==null){const a=n.getContainerById(t),u=Rt(a);return d(Ub,e>=0&&e<=u.length,`invalid blockIndex: ${e}`),{containerId:t,blockIndex:e}}const o=n.selection.range.start;if(!o.isSimple())return null;const r=n.getBlockById(o.blockId);if(t=V(H(r)),e=K(r),!j(n,r))return{containerId:t,blockIndex:e+1};const s=o.offset;if(s===0||s===Z(n,r))return{containerId:t,blockIndex:s===0?e:e+1};const c=Pi(n,r,s).newBlock;return{containerId:t,blockIndex:K(c)}}const Wb=y("auto-insert-block");function u2(n,t,e,o,r){const i=qb(n,e,o);d(Wb,i,`not an valid insert position: ${n.selection.range}`);const s={blockId:t.id,offset:0},l={anchor:s,focus:s};return Dr(n,i.containerId,i.blockIndex,t,r!=null?r:l)}const Gb=y("range-in-block");function h2(n,t){const e=t.getEditor(),o=e.getBlockById(t.start.blockId),r=e.getBlockById(t.end.blockId),i=o===n||vt(n,o),s=r===n||vt(n,r);return!!(i||s)}function f2(n,t){let e;const o=gt(t);if(o)e=Ot(n,o,Z(n,o));else{const r=ht(t);d(Gb,r,"no prev and next block while deleting a block"),e=Ot(n,r,0)}return e}const Zb=y("delete-block");function Ol(n,t,e){t.children&&(e.push(...t.children),t.children.forEach(o=>{n.getChildContainerData(o).forEach(i=>{Ol(n,i,e)})}))}function W1(n,t,e){const o=H(t),r=V(o),i=K(t),s=n.doc.getBlockData(r,i);return d(Zb,s,"no block data in doc"),n.doc.localDeleteBlock(r,i,Ut(n,{anchor:e.start,focus:e.end})),s}function G1(n,t,e){const o=H(t);Ve(o)===1&&n.insertTextBlock("",V(o),0);let r=e?no(n,e):null;if(!r){const l=n.selection.range;h2(t,l)?r=f2(n,t):r=l}const i=W1(n,t,r),s=[];return Ol(n,i,s),s.length>0&&n.doc.localDeleteChildContainers(s),i}function Yb(n,t){const e=[t];n.doc.getContainerBlocks(t).forEach(r=>{Ol(n,r,e)}),n.doc.localDeleteChildContainers(e)}function m2(n,t){const e=[...t];t.forEach(o=>{n.doc.getContainerBlocks(o).forEach(i=>{Ol(n,i,e)})}),n.doc.localDeleteChildContainers(e)}const Z1=y("merge-text-block");function g2(n,t,e){d(Z1,j(n,t),"only text block can be merged"),d(Z1,j(n,e),"only text block can be merged");const o=ro(n,t),r=ro(n,e),i=o.text,s=r.text;d(Z1,i&&s,"block data has no text");const l=H(t),c=V(l),a=K(t),u=Z(n,t),f=z1(n,s,c,a,u),m=Ot(n,t,ce(i));return G1(n,e,m),f}const Cn=y("clear-selected-contents");function _l(n,t){d(Cn,j(n,t.block),"not a text kind block");const{start:e,end:o}=t;d(Cn,e.isSimple(),"not a simple block position"),d(Cn,o.isSimple(),"not a simple block position");const r=e.offset,i=o.offset;d(Cn,r<=i,`invalid delete text offset: ${r}, ${i}`),r!==i&&n.deleteTextFromBlock(t.block,r,i-r)}function p2(n,t,e){const o=V(t),r=Rt(t),i=e.focus?void 0:n.selection.range.toDocRange(),s=n.insertTextBlock("",o,0,{newRange:i});e.focus&&n.selection.selectBlock(s,0),r.reverse().forEach(l=>{n.deleteBlock(l)})}function Qb(n,t){const{block:e,start:o,end:r}=t;if(j(n,e)){_l(n,t);return}if(Te(e)||o.isSimple()){d(Cn,r.isSimple(),"invalid range");const s=H(e),l=K(e),c=n.insertTextBlock("",V(s),l);n.selection.selectBlock(c,0),n.deleteBlock(e);return}d(Cn,ct(n,e),"invalid block kind"),d(Cn,!o.isSimple()&&!r.isSimple(),"invalid range"),yr(n,e,o,r),n.selection.range.getSelectedContainers().forEach((s,l)=>{p2(n,s,{focus:l===0})})}function Kb(n){const t=n.selection.range;if(t.isCollapsed())return;const e=t.getSelectedBlocks();if(d(Cn,e.length>0,"no selected block"),e.length===1){Qb(n,e[0]);return}const o=e[0],r=o.block,i=H(r);d(Cn,e.length>1,"no selected block");const s=e[e.length-1],l=s.block;if(j(n,r)){_l(n,o);const u=Ot(n,o.block,o.start.offset);if(e.slice(1,e.length-1).reverse().forEach(m=>n.deleteBlock(m.block)),j(n,l)){_l(n,s),n.mergeTextBlock(r,l,{focus:!0}),n.selection.setRange(u);return}n.deleteBlock(l),n.selection.setRange(u);return}if(j(n,l)){_l(n,s),e.slice(0,e.length-1).reverse().forEach(u=>n.deleteBlock(u.block)),n.selection.selectBlock(s.block,0);return}if(e.length===Ve(i)){p2(n,i,{focus:!0});return}const c=gt(r),a=ht(l);d(Cn,c||a,"no prev or next block"),e.forEach(u=>n.deleteBlock(u.block))}function Y1(n){n.selection.range.isCollapsed()||n.undoManager.runInGroup(()=>{n.emit("beforeClearSelection",n),Kb(n),n.emit("afterClearSelection",n)})}function C2(n,t,e){const o=H(t),r=V(o),i=K(t);return n.doc.localUpdateBlockText(r,i,e),setTimeout(()=>{n.selection.updateSelection(null)}),ke(n,t)}function b2(n,t,e){const o=n.getBlockText(t),r=ne.diff(o,e);C2(n,t,r)}function Nl(n,t,e){const o=ke(n,t),r=typeof e=="string"?Oi(e):e,i=ne.diff(o,r);return C2(n,t,i)}const $i=y("update-block-data");function Pl(n,t,e,o){const r=H(t),i=V(r),s=K(t),l=n.doc.getBlockData(i,s),c={insert:{},delete:[]},a=new Set(Object.keys(l)),u=new Set(Object.keys(e));return a.forEach(m=>{if(!u.has(m)){if(m==="id"||m==="type"||m==="text")return;$i.debug(`delete key: ${m}`),c.delete.push(m)}}),Object.entries(e).forEach(([m,C])=>{d($i,m!=="id"&&m!=="type",`invalid block data delta, ${m}`);const v=l[m];if(C==null){v!=null&&($i.debug(`delete key: ${m}`),c.delete.push(m));return}v!==C&&(Zs.default(v,C)||m==="text"&&ne.diff(v,C).length===0||(a.has(m)?($i.debug(`replace key: ${m}`),c.delete.push(m)):$i.debug(`insert key: ${m}`),c.insert[m]=C))}),n.doc.localUpdateBlockData(i,s,c,o),ro(n,t)}function v2(n,t,e,o){const i={...n.getBlockData(t),embedData:e};return n.updateBlockData(t,i,o)}function Q1(n,t,e){if(!ct(n,t)||!(e!=null&&e.tryFocusToChildSimpleBlock)){n.selection.selectBlock(t,0);return}const r=ve(n,t).getChildContainers(n,t)[0],i=Qt(r);Q1(n,i,e)}function jo(n){const t=[];let e={};return n.forEach(o=>{t.push(...o.blocks.root);const{root:r,...i}=o.blocks;e={...e,...i}}),{blocks:{...e,root:t},meta:{},comments:{}}}const $l=y("clone-block");function Fo(n,t,e,o){const r=n.getBlockClass(e.type);if(r.blockToDoc)return r.blockToDoc(t,e,(u,f)=>(d($l,e!==f,"invalid child block"),Fo(n,u,e,o)));let i={};const s=new Map,l=Y.default(e);l.children&&(l.children=l.children.map(u=>{const f=N(),m=t.blocks[u];d($l,Array.isArray(m),"invalid child blocks");const C=m.map(L=>Fo(n,t,L,o)),v=jo(C),{root:w,...E}=v.blocks;return i={...i,...E},i[f]=v.blocks.root,s.set(u,f),f}));const c=Array.from(s.entries()),a=u=>{for(const f of c){const[m,C]=f,v=`${m}/`;if(u.startsWith(v)){const w=u.substring(v.length),E=`${C}/${w}`;return $l.debug(`replace key: ${u} -> ${E}`),E}}return u};return Array.from(Object.entries(l)).forEach(([u,f])=>{const m=a(u);m!==u&&delete l.key,l[m]=f}),l.id=N(),o&&(o.blockIdMap.set(e.id,l.id),s.forEach((u,f)=>o.containerIdMap.set(f,u))),{blocks:{root:[l],...i},meta:{},comments:{}}}function K1(n,t,e,o){const r=t.blocks[e];d($l,Array.isArray(r),"invalid child blocks");const i=r.map(l=>Fo(n,t,l,o));return jo(i)}function J1(n,t,e){const o=t.blocks.root.map(r=>Fo(n.editorBlocks,t,r,e));return Y.default(jo(o))}const k2=y("insert-doc");function y2(n,t,e,o,r){if(ct(n,t)){k2.warn("failed to insert doc into a complex block");return}const i=J1(n,o,r),s=H(t),l=K(t),c=V(s);n.doc.beginBatchUpdate(),n.undoManager.runInGroup(()=>{var x,A,O;Object.entries(i.blocks).forEach(([P,U])=>{P!=="root"&&n.doc.localInsertChildContainer(P,U)});const a=i.blocks.root;if(Te(t)){n.deleteBlock(t);let P;a.reverse().forEach(U=>{const tt=n.insertBlock(c,l,U);P||(P=tt)}),P&&n.selection.selectBlock(P,Z(n,P));return}if(d(k2,j(n,t),"not a text block"),wt(n,t)){const P=K(t);let U;a.forEach((tt,ot)=>{const ut=n.insertBlock(c,P+ot,tt);ot===a.length-1&&(U=ut)}),U&&n.selection.selectBlock(U,Z(n,U));return}if(a.length===1){const P=a[0];if(Di(n,P.type)){n.insertTextToBlock(t,e,(x=P.text)!=null?x:[]);return}n.breakTextBlock(t,e),n.insertBlock(c,l+1,P);return}const u=e===Z(n,t),f=e===0,m=a[0],C=a[a.length-1];let v;!u&&!f?v=n.breakTextBlock(t,e,{forceInsertAfter:!0}):v=t;const w=f?l:l+1;u?(v=n.insertBlock(c,l+1,C),n.selection.selectBlock(v,Z(n,v))):(n.selection.selectBlock(v,0),Di(n,C.type)?n.insertTextToBlock(v,0,(A=C.text)!=null?A:[]):n.insertBlock(c,w,C));const E=n.selection.range;let L=w;Di(n,m.type)?f?(n.insertBlock(c,w,m),L+=1):n.insertTextToBlock(t,e,(O=m.text)!=null?O:[]):(n.insertBlock(c,w,m),L+=1),a.slice(1,a.length-1).reverse().forEach(P=>{n.insertBlock(c,L,P)}),n.selection.setRange(E)}),n.doc.endBatchUpdate()}function X1(n,t,e,o,r){const i=J1(n,o,r),s=V(t),l=[];return n.undoManager.runInGroup(()=>{Object.entries(i.blocks).forEach(([a,u])=>{a!=="root"&&n.doc.localInsertChildContainer(a,u)}),i.blocks.root.reverse().forEach(a=>{const u=n.insertBlock(s,e,a);l.push(u)})}),l}function w2(n,t,e){const o=Ve(t);X1(n,t,o,e);for(let r=0;r<o;r++){const i=Qt(t);n.deleteBlock(i)}}const Hi=y("add-text-attribute");function Jb(n,t,e,o){const{start:r,end:i}=e;d(Hi,r.blockId===i.blockId&&r.blockId===G(t),"invalid range"),d(Hi,o,"invalid attribute name");const s=n.getBlockText(t),l=Sr(r.offset,i.offset-r.offset,s,o,void 0,{ignoreValue:!0});return n.setBlockText(t,l),l}function B2(n,t,e,o,r){const{start:i,end:s}=e;d(Hi,i.blockId===s.blockId&&i.blockId===G(t),"invalid range"),d(Hi,o,"invalid attribute name");const l=n.getBlockText(t),c=wl(i.offset,s.offset-i.offset,l,o,r);return n.setBlockText(t,c),c}function Lr(n,t,e,o,r){const{start:i,end:s}=e;d(Hi,i.blockId===s.blockId&&i.blockId===G(t),"invalid range");const l=n.getBlockText(t),c=Ag(i.offset,s.offset-i.offset,l,o,r);return n.setBlockText(t,c),c}function E2(n,t,e,o){const r=Qe(n,{simpleBlockOnly:!0});n.undoManager.runInGroup(()=>{r.forEach(i=>{const{block:s,start:l,end:c}=i;if(!j(n,s))return;if(wt(n,s)){o(n,G(s),t,e);return}const a=Ut(n,{anchor:l,focus:c});t==="color"||t==="backgroundColor"?Lr(n,s,a,t,e):(Lr(n,s,a,"color",null),Lr(n,s,a,"backgroundColor",null))})})}function I2(n,t,e){const o=Qe(n,{simpleBlockOnly:!0});n.undoManager.runInGroup(()=>{o.forEach(r=>{const{block:i,start:s,end:l}=r;if(!j(n,i))return;if(wt(n,i)){(t==="clearColor"||t==="clearAll")&&e(n,G(i),"color",null),(t==="clearBackground"||t==="clearAll")&&e(n,G(i),"backgroundColor",null);return}const c=Ut(n,{anchor:s,focus:l});(t==="clearColor"||t==="clearAll")&&Lr(n,i,c,"color",null),(t==="clearBackground"||t==="clearAll")&&Lr(n,i,c,"backgroundColor",null)})})}function td(n,t){const e=Qe(n,{simpleBlockOnly:!0}).filter(s=>j(n,s.block));if(e.length===0)return[null,null];const o=s=>{if(Z(n,s.block)===0)return t(n,G(s.block));const l=s.start,c=s.end,a=n.getBlockText(s.block);return Ng(l.offset,c.offset-l.offset,a)};let[r,i]=o(e[0]);return r===null&&i===null?[r,i]:(e.forEach(s=>{const[l,c]=o(s);l===null||r===null?r=null:r=l===r?r:null,c===null||i===null?i=null:i=c===i?i:null}),[r,i])}function x2(n){let t=Gt(n.rootContainer);if(ct(n,t)){const e=wr(n,t);e&&(t=e)}n.selection.selectBlock(t,Z(n,t))}function S2(n){x2(n),n.focus()}const ed=y("selected-block-to-doc");function T2(n,t,e){!t.children||t.children.forEach(o=>{const r=n.getChildContainerData(o);r.forEach(i=>{T2(n,i,e)}),e.blocks[o]=Y.default(r)})}function Hl(n,t,e={ignoreLockInfo:!0}){const o=kt(n,t.block);if(o.selectionToDoc)return o.selectionToDoc(n,t);const r=Y.default(ro(n,t.block));if(!e.ignoreLockInfo&&r.lock&&delete r.lock,j(n,t.block)){const s=t.start,l=t.end;if(d(ed,r.text,"no block text"),s.offset===l.offset)return{blocks:{root:[{...r,text:[]}]},meta:{},comments:{}};const{middle:c}=Kt(r.text,s.offset,l.offset-s.offset);return{blocks:{root:[{...r,text:c}]},meta:{},comments:{}}}if(Te(t.block))return{blocks:{root:[r]},meta:{},comments:{}};d(ed,ct(n,t.block),"not complex block"),d(ed,r.children,"no children");const i={blocks:{root:[r]},meta:{},comments:{}};return T2(n,r,i),i}function nd(n,t,e=!0){const o=$(t,0,"normal"),r=$(t,Z(n,t),"end");return Hl(n,{block:t,start:o,end:r},{ignoreLockInfo:e})}const Xb=y("block-to-doc");function tv(n,t){d(Xb,t.length>0,"invalid params, no blocks");const e=t.map(o=>nd(n,o));return jo(e)}function jl(n){const e=n.selection.range.getSelectedBlocks().map(o=>Hl(n,o));return jo(e)}function od(n,t){const e=n.getContainerById(t),i=Rt(e).map(s=>({start:$(s,0,"home"),end:$(s,Z(n,s),"end"),block:s})).map(s=>Hl(n,s));return jo(i)}function D2(n,t,e){if(t.type==="embed"){const s=t.embedData.src;s&&typeof s=="string"&&e.add(s);return}const o=t.text;o&&o.forEach(i=>{i.attributes&&i.attributes.src&&typeof i.attributes.src=="string"&&e.add(i.attributes.src)});const r=t.children;r&&r.forEach(i=>{n.blocks[i].forEach(l=>{D2(n,l,e)})})}function ev(n,t){const e=new Set;return t.blocks.root.forEach(r=>{const i=n.editorBlocks.getBlockClass(r.type);i.getResources?i.getResources(r).forEach(s=>{e.add(s)}):D2(t,r,e)}),Array.from(e)}function rd(n,t){return t.blocks.root.map(r=>F1(n,r,t)).join(`
24
+ `)}const Ll=y("action-helper");function ro(n,t){const e=H(t),o=U(e),r=K(t);return n.doc.getBlockData(o,r)}function ke(n,t){d(Ll,j(n,t),"not a text kind block");const o=ro(n,t).text;return d(Ll,o,"no text in block"),o}function Ml(n,t,e){return Ae(ke(n,t),e).left}function r2(n,t){const e=z(t);d(Ll,e,"no parent block");const o=ke(n,e),r=Dm(t),i=o.find(s=>{const l=s.attributes;return l?l.box&&l.id===r:!1});return d(Ll,i,"failed to find box"),i.attributes}const zb=y("get-text-position");function Tr(n,t){const e=t!=null?t:n.selection.range.start;e instanceof Ut||d(zb,!1,`invalid insert pos type: ${typeof e}`);const{blockId:o}=e,r=n.getBlockById(o),i=K(r),s=H(r),l=U(s),{offset:c}=e;return{block:r,container:s,containerId:l,blockIndex:i,offset:c}}const Ni=y("insert-text");function i2(n,t,e,o){var s;const r=n.doc.getBlockData(t,e);if(d(Ni,r,"no block data"),d(Ni,r.text,"no block text"),ce(r.text)===0)return d(Ni,o===0,"invalid text offset"),n.editorCommandProviders.getEmptyBlockTextAttributes(n,r.id);if(o===0)return;const i=Kt(r.text,o-1,1).middle;if(!((s=i[0].attributes)!=null&&s.box))return i[0].attributes}function Ub(n,t,e){const o=H(t),r=U(o),i=K(t);return i2(n,r,i,e)}function s2(n,t,e,o){const r=H(t),i=U(r),s=K(t),l=Ub(n,t,e),c=kl(e,o,l!=null?l:null);return n.doc.localUpdateBlockText(i,s,c),ke(n,t)}function l2(n,t,e,o){const r=H(t),i=U(r),s=K(t),l=kl(e," ",o);return n.doc.localUpdateBlockText(i,s,l),ke(n,t)}function z1(n,t,e,o,r){const i=n.doc.getBlockData(e,o);d(Ni,i,"no block data"),d(Ni,i.text,"no block text");const s=i2(n,e,o,r),l=kl(r,t,s!=null?s:null);return n.doc.localUpdateBlockText(e,o,l),ke(n,n.getBlockById(i.id))}function U1(n,t){n.selection.range.isCollapsed()||n.clearSelectedContents();const{containerId:e,blockIndex:o,offset:r}=Tr(n);z1(n,t,e,o,r)}const Rl=y("update-composition-text");function c2(n){const t=n.selection.range.start;t instanceof Ut||d(Rl,!1,`invalid insert pos type: ${typeof t}`);const{blockId:e}=t,o=n.getBlockById(e);d(Rl,j(n,o),"not a text kind block");const r=H(o),i=U(r),s=K(o),l=n.doc.getBlockData(i,s);d(Rl,l,"no block data in doc"),d(Rl,l.text,"no text data in text block");const c=rt(o);pl(n,Ro(o),e,c,l.text)}function a2(n){VC(n)}function Dr(n,t,e,o,r){return n.doc.localInsertBlock(t,e,o,r),n.getBlockById(o.id)}const Al=y("delete-block-text");function V1(n,t,e,o){d(Al,j(n,t),"block is not a text kind block");const r=H(t),i=U(r),s=K(t),l=n.doc.getBlockData(i,s);d(Al,l,"no block data in doc"),d(Al,l.text,"no text data in text block");let c=e;fe(t,e)||(c=Po(t,c));let a=e+o;d(Al,a<=Z(n,t),`invalid offset and count: ${e}, ${o}`),fe(t,a)||(a=Ir(t,a));const u=a-c,f=Eg(c,u);return n.doc.localUpdateBlockText(i,s,f),u}const q1=y("break-text-block");function d2(n,t){const o=n.getBlockData(t).quoted;return o?{quoted:o}:{}}function Pi(n,t,e,o){d(q1,j(n,t),`block is not a text kind block: ${it(t)}`),d(q1,e>=0&&e<=Z(n,t),`invalid offset: ${e}`);const r=H(t),i=U(r),s=K(t),l=o!=null&&o.copyBlockAttributes?d2(n,t):{};if(!(o!=null&&o.forceInsertAfter)&&(e===0||e===Z(n,t))){const C=e===0?s:s+1,v={...jn(""),...l,...o==null?void 0:o.newBlockData},w=Ot(n,t.id,0),E=Dr(n,i,C,v,w);return{block:t,newBlock:E}}d(q1,fe(t,e),"not a valid offset");const c=ke(n,t),{right:a}=Ae(c,e),u=ce(a);u>0&&V1(n,t,e,u);const f={...jn(a),...l,...o==null?void 0:o.newBlockData},m=Dr(n,i,s+1,f,Ot(n,f.id,0));return{block:t,newBlock:m}}const Vb=y("prepare-insert-new-block");function qb(n,t,e){if(t&&e!==void 0&&e!==null){const a=n.getContainerById(t),u=Rt(a);return d(Vb,e>=0&&e<=u.length,`invalid blockIndex: ${e}`),{containerId:t,blockIndex:e}}const o=n.selection.range.start;if(!o.isSimple())return null;const r=n.getBlockById(o.blockId);if(t=U(H(r)),e=K(r),!j(n,r))return{containerId:t,blockIndex:e+1};const s=o.offset;if(s===0||s===Z(n,r))return{containerId:t,blockIndex:s===0?e:e+1};const c=Pi(n,r,s).newBlock;return{containerId:t,blockIndex:K(c)}}const Wb=y("auto-insert-block");function u2(n,t,e,o,r){const i=qb(n,e,o);d(Wb,i,`not an valid insert position: ${n.selection.range}`);const s={blockId:t.id,offset:0},l={anchor:s,focus:s};return Dr(n,i.containerId,i.blockIndex,t,r!=null?r:l)}const Gb=y("range-in-block");function h2(n,t){const e=t.getEditor(),o=e.getBlockById(t.start.blockId),r=e.getBlockById(t.end.blockId),i=o===n||vt(n,o),s=r===n||vt(n,r);return!!(i||s)}function f2(n,t){let e;const o=gt(t);if(o)e=Ot(n,o,Z(n,o));else{const r=ht(t);d(Gb,r,"no prev and next block while deleting a block"),e=Ot(n,r,0)}return e}const Zb=y("delete-block");function Ol(n,t,e){t.children&&(e.push(...t.children),t.children.forEach(o=>{n.getChildContainerData(o).forEach(i=>{Ol(n,i,e)})}))}function W1(n,t,e){const o=H(t),r=U(o),i=K(t),s=n.doc.getBlockData(r,i);return d(Zb,s,"no block data in doc"),n.doc.localDeleteBlock(r,i,Vt(n,{anchor:e.start,focus:e.end})),s}function G1(n,t,e){const o=H(t);Ue(o)===1&&n.insertTextBlock("",U(o),0);let r=e?no(n,e):null;if(!r){const l=n.selection.range;h2(t,l)?r=f2(n,t):r=l}const i=W1(n,t,r),s=[];return Ol(n,i,s),s.length>0&&n.doc.localDeleteChildContainers(s),i}function Yb(n,t){const e=[t];n.doc.getContainerBlocks(t).forEach(r=>{Ol(n,r,e)}),n.doc.localDeleteChildContainers(e)}function m2(n,t){const e=[...t];t.forEach(o=>{n.doc.getContainerBlocks(o).forEach(i=>{Ol(n,i,e)})}),n.doc.localDeleteChildContainers(e)}const Z1=y("merge-text-block");function g2(n,t,e){d(Z1,j(n,t),"only text block can be merged"),d(Z1,j(n,e),"only text block can be merged");const o=ro(n,t),r=ro(n,e),i=o.text,s=r.text;d(Z1,i&&s,"block data has no text");const l=H(t),c=U(l),a=K(t),u=Z(n,t),f=z1(n,s,c,a,u),m=Ot(n,t,ce(i));return G1(n,e,m),f}const Cn=y("clear-selected-contents");function _l(n,t){d(Cn,j(n,t.block),"not a text kind block");const{start:e,end:o}=t;d(Cn,e.isSimple(),"not a simple block position"),d(Cn,o.isSimple(),"not a simple block position");const r=e.offset,i=o.offset;d(Cn,r<=i,`invalid delete text offset: ${r}, ${i}`),r!==i&&n.deleteTextFromBlock(t.block,r,i-r)}function p2(n,t,e){const o=U(t),r=Rt(t),i=e.focus?void 0:n.selection.range.toDocRange(),s=n.insertTextBlock("",o,0,{newRange:i});e.focus&&n.selection.selectBlock(s,0),r.reverse().forEach(l=>{n.deleteBlock(l)})}function Qb(n,t){const{block:e,start:o,end:r}=t;if(j(n,e)){_l(n,t);return}if(Te(e)||o.isSimple()){d(Cn,r.isSimple(),"invalid range");const s=H(e),l=K(e),c=n.insertTextBlock("",U(s),l);n.selection.selectBlock(c,0),n.deleteBlock(e);return}d(Cn,ct(n,e),"invalid block kind"),d(Cn,!o.isSimple()&&!r.isSimple(),"invalid range"),yr(n,e,o,r),n.selection.range.getSelectedContainers().forEach((s,l)=>{p2(n,s,{focus:l===0})})}function Kb(n){const t=n.selection.range;if(t.isCollapsed())return;const e=t.getSelectedBlocks();if(d(Cn,e.length>0,"no selected block"),e.length===1){Qb(n,e[0]);return}const o=e[0],r=o.block,i=H(r);d(Cn,e.length>1,"no selected block");const s=e[e.length-1],l=s.block;if(j(n,r)){_l(n,o);const u=Ot(n,o.block,o.start.offset);if(e.slice(1,e.length-1).reverse().forEach(m=>n.deleteBlock(m.block)),j(n,l)){_l(n,s),n.mergeTextBlock(r,l,{focus:!0}),n.selection.setRange(u);return}n.deleteBlock(l),n.selection.setRange(u);return}if(j(n,l)){_l(n,s),e.slice(0,e.length-1).reverse().forEach(u=>n.deleteBlock(u.block)),n.selection.selectBlock(s.block,0);return}if(e.length===Ue(i)){p2(n,i,{focus:!0});return}const c=gt(r),a=ht(l);d(Cn,c||a,"no prev or next block"),e.forEach(u=>n.deleteBlock(u.block))}function Y1(n){n.selection.range.isCollapsed()||n.undoManager.runInGroup(()=>{n.emit("beforeClearSelection",n),Kb(n),n.emit("afterClearSelection",n)})}function C2(n,t,e){const o=H(t),r=U(o),i=K(t);return n.doc.localUpdateBlockText(r,i,e),setTimeout(()=>{n.selection.updateSelection(null)}),ke(n,t)}function b2(n,t,e){const o=n.getBlockText(t),r=ne.diff(o,e);C2(n,t,r)}function Nl(n,t,e){const o=ke(n,t),r=typeof e=="string"?Oi(e):e,i=ne.diff(o,r);return C2(n,t,i)}const $i=y("update-block-data");function Pl(n,t,e,o){const r=H(t),i=U(r),s=K(t),l=n.doc.getBlockData(i,s),c={insert:{},delete:[]},a=new Set(Object.keys(l)),u=new Set(Object.keys(e));return a.forEach(m=>{if(!u.has(m)){if(m==="id"||m==="type"||m==="text")return;$i.debug(`delete key: ${m}`),c.delete.push(m)}}),Object.entries(e).forEach(([m,C])=>{d($i,m!=="id"&&m!=="type",`invalid block data delta, ${m}`);const v=l[m];if(C==null){v!=null&&($i.debug(`delete key: ${m}`),c.delete.push(m));return}v!==C&&(Zs.default(v,C)||m==="text"&&ne.diff(v,C).length===0||(a.has(m)?($i.debug(`replace key: ${m}`),c.delete.push(m)):$i.debug(`insert key: ${m}`),c.insert[m]=C))}),n.doc.localUpdateBlockData(i,s,c,o),ro(n,t)}function v2(n,t,e,o){const i={...n.getBlockData(t),embedData:e};return n.updateBlockData(t,i,o)}function Q1(n,t,e){if(!ct(n,t)||!(e!=null&&e.tryFocusToChildSimpleBlock)){n.selection.selectBlock(t,0);return}const r=ve(n,t).getChildContainers(n,t)[0],i=Qt(r);Q1(n,i,e)}function jo(n){const t=[];let e={};return n.forEach(o=>{t.push(...o.blocks.root);const{root:r,...i}=o.blocks;e={...e,...i}}),{blocks:{...e,root:t},meta:{},comments:{}}}const $l=y("clone-block");function Fo(n,t,e,o){const r=n.getBlockClass(e.type);if(r.blockToDoc)return r.blockToDoc(t,e,(u,f)=>(d($l,e!==f,"invalid child block"),Fo(n,u,e,o)));let i={};const s=new Map,l=Y.default(e);l.children&&(l.children=l.children.map(u=>{const f=N(),m=t.blocks[u];d($l,Array.isArray(m),"invalid child blocks");const C=m.map(L=>Fo(n,t,L,o)),v=jo(C),{root:w,...E}=v.blocks;return i={...i,...E},i[f]=v.blocks.root,s.set(u,f),f}));const c=Array.from(s.entries()),a=u=>{for(const f of c){const[m,C]=f,v=`${m}/`;if(u.startsWith(v)){const w=u.substring(v.length),E=`${C}/${w}`;return $l.debug(`replace key: ${u} -> ${E}`),E}}return u};return Array.from(Object.entries(l)).forEach(([u,f])=>{const m=a(u);m!==u&&delete l.key,l[m]=f}),l.id=N(),o&&(o.blockIdMap.set(e.id,l.id),s.forEach((u,f)=>o.containerIdMap.set(f,u))),{blocks:{root:[l],...i},meta:{},comments:{}}}function K1(n,t,e,o){const r=t.blocks[e];d($l,Array.isArray(r),"invalid child blocks");const i=r.map(l=>Fo(n,t,l,o));return jo(i)}function J1(n,t,e){const o=t.blocks.root.map(r=>Fo(n.editorBlocks,t,r,e));return Y.default(jo(o))}const k2=y("insert-doc");function y2(n,t,e,o,r){if(ct(n,t)){k2.warn("failed to insert doc into a complex block");return}const i=J1(n,o,r),s=H(t),l=K(t),c=U(s);n.doc.beginBatchUpdate(),n.undoManager.runInGroup(()=>{var x,A,O;Object.entries(i.blocks).forEach(([P,V])=>{P!=="root"&&n.doc.localInsertChildContainer(P,V)});const a=i.blocks.root;if(Te(t)){n.deleteBlock(t);let P;a.reverse().forEach(V=>{const tt=n.insertBlock(c,l,V);P||(P=tt)}),P&&n.selection.selectBlock(P,Z(n,P));return}if(d(k2,j(n,t),"not a text block"),wt(n,t)){const P=K(t);let V;a.forEach((tt,ot)=>{const ut=n.insertBlock(c,P+ot,tt);ot===a.length-1&&(V=ut)}),V&&n.selection.selectBlock(V,Z(n,V));return}if(a.length===1){const P=a[0];if(Di(n,P.type)){n.insertTextToBlock(t,e,(x=P.text)!=null?x:[]);return}n.breakTextBlock(t,e),n.insertBlock(c,l+1,P);return}const u=e===Z(n,t),f=e===0,m=a[0],C=a[a.length-1];let v;!u&&!f?v=n.breakTextBlock(t,e,{forceInsertAfter:!0}):v=t;const w=f?l:l+1;u?(v=n.insertBlock(c,l+1,C),n.selection.selectBlock(v,Z(n,v))):(n.selection.selectBlock(v,0),Di(n,C.type)?n.insertTextToBlock(v,0,(A=C.text)!=null?A:[]):n.insertBlock(c,w,C));const E=n.selection.range;let L=w;Di(n,m.type)?f?(n.insertBlock(c,w,m),L+=1):n.insertTextToBlock(t,e,(O=m.text)!=null?O:[]):(n.insertBlock(c,w,m),L+=1),a.slice(1,a.length-1).reverse().forEach(P=>{n.insertBlock(c,L,P)}),n.selection.setRange(E)}),n.doc.endBatchUpdate()}function X1(n,t,e,o,r){const i=J1(n,o,r),s=U(t),l=[];return n.undoManager.runInGroup(()=>{Object.entries(i.blocks).forEach(([a,u])=>{a!=="root"&&n.doc.localInsertChildContainer(a,u)}),i.blocks.root.reverse().forEach(a=>{const u=n.insertBlock(s,e,a);l.push(u)})}),l}function w2(n,t,e){const o=Ue(t);X1(n,t,o,e);for(let r=0;r<o;r++){const i=Qt(t);n.deleteBlock(i)}}const Hi=y("add-text-attribute");function Jb(n,t,e,o){const{start:r,end:i}=e;d(Hi,r.blockId===i.blockId&&r.blockId===G(t),"invalid range"),d(Hi,o,"invalid attribute name");const s=n.getBlockText(t),l=Sr(r.offset,i.offset-r.offset,s,o,void 0,{ignoreValue:!0});return n.setBlockText(t,l),l}function B2(n,t,e,o,r){const{start:i,end:s}=e;d(Hi,i.blockId===s.blockId&&i.blockId===G(t),"invalid range"),d(Hi,o,"invalid attribute name");const l=n.getBlockText(t),c=wl(i.offset,s.offset-i.offset,l,o,r);return n.setBlockText(t,c),c}function Lr(n,t,e,o,r){const{start:i,end:s}=e;d(Hi,i.blockId===s.blockId&&i.blockId===G(t),"invalid range");const l=n.getBlockText(t),c=Ag(i.offset,s.offset-i.offset,l,o,r);return n.setBlockText(t,c),c}function E2(n,t,e,o){const r=Qe(n,{simpleBlockOnly:!0});n.undoManager.runInGroup(()=>{r.forEach(i=>{const{block:s,start:l,end:c}=i;if(!j(n,s))return;if(wt(n,s)){o(n,G(s),t,e);return}const a=Vt(n,{anchor:l,focus:c});t==="color"||t==="backgroundColor"?Lr(n,s,a,t,e):(Lr(n,s,a,"color",null),Lr(n,s,a,"backgroundColor",null))})})}function I2(n,t,e){const o=Qe(n,{simpleBlockOnly:!0});n.undoManager.runInGroup(()=>{o.forEach(r=>{const{block:i,start:s,end:l}=r;if(!j(n,i))return;if(wt(n,i)){(t==="clearColor"||t==="clearAll")&&e(n,G(i),"color",null),(t==="clearBackground"||t==="clearAll")&&e(n,G(i),"backgroundColor",null);return}const c=Vt(n,{anchor:s,focus:l});(t==="clearColor"||t==="clearAll")&&Lr(n,i,c,"color",null),(t==="clearBackground"||t==="clearAll")&&Lr(n,i,c,"backgroundColor",null)})})}function td(n,t){const e=Qe(n,{simpleBlockOnly:!0}).filter(s=>j(n,s.block));if(e.length===0)return[null,null];const o=s=>{if(Z(n,s.block)===0)return t(n,G(s.block));const l=s.start,c=s.end,a=n.getBlockText(s.block);return Ng(l.offset,c.offset-l.offset,a)};let[r,i]=o(e[0]);return r===null&&i===null?[r,i]:(e.forEach(s=>{const[l,c]=o(s);l===null||r===null?r=null:r=l===r?r:null,c===null||i===null?i=null:i=c===i?i:null}),[r,i])}function x2(n){let t=Gt(n.rootContainer);if(ct(n,t)){const e=wr(n,t);e&&(t=e)}n.selection.selectBlock(t,Z(n,t))}function S2(n){x2(n),n.focus()}const ed=y("selected-block-to-doc");function T2(n,t,e){!t.children||t.children.forEach(o=>{const r=n.getChildContainerData(o);r.forEach(i=>{T2(n,i,e)}),e.blocks[o]=Y.default(r)})}function Hl(n,t,e={ignoreLockInfo:!0}){const o=kt(n,t.block);if(o.selectionToDoc)return o.selectionToDoc(n,t);const r=Y.default(ro(n,t.block));if(!e.ignoreLockInfo&&r.lock&&delete r.lock,j(n,t.block)){const s=t.start,l=t.end;if(d(ed,r.text,"no block text"),s.offset===l.offset)return{blocks:{root:[{...r,text:[]}]},meta:{},comments:{}};const{middle:c}=Kt(r.text,s.offset,l.offset-s.offset);return{blocks:{root:[{...r,text:c}]},meta:{},comments:{}}}if(Te(t.block))return{blocks:{root:[r]},meta:{},comments:{}};d(ed,ct(n,t.block),"not complex block"),d(ed,r.children,"no children");const i={blocks:{root:[r]},meta:{},comments:{}};return T2(n,r,i),i}function nd(n,t,e=!0){const o=$(t,0,"normal"),r=$(t,Z(n,t),"end");return Hl(n,{block:t,start:o,end:r},{ignoreLockInfo:e})}const Xb=y("block-to-doc");function tv(n,t){d(Xb,t.length>0,"invalid params, no blocks");const e=t.map(o=>nd(n,o));return jo(e)}function jl(n){const e=n.selection.range.getSelectedBlocks().map(o=>Hl(n,o));return jo(e)}function od(n,t){const e=n.getContainerById(t),i=Rt(e).map(s=>({start:$(s,0,"home"),end:$(s,Z(n,s),"end"),block:s})).map(s=>Hl(n,s));return jo(i)}function D2(n,t,e){if(t.type==="embed"){const s=t.embedData.src;s&&typeof s=="string"&&e.add(s);return}const o=t.text;o&&o.forEach(i=>{i.attributes&&i.attributes.src&&typeof i.attributes.src=="string"&&e.add(i.attributes.src)});const r=t.children;r&&r.forEach(i=>{n.blocks[i].forEach(l=>{D2(n,l,e)})})}function ev(n,t){const e=new Set;return t.blocks.root.forEach(r=>{const i=n.editorBlocks.getBlockClass(r.type);i.getResources?i.getResources(r).forEach(s=>{e.add(s)}):D2(t,r,e)}),Array.from(e)}function rd(n,t){return t.blocks.root.map(r=>F1(n,r,t)).join(`
25
25
  `)}function id(n,t){return t.blocks.root.map(r=>Dl(n,r,t)).join(`
26
- `)}function sd(n,t){return`<!doctype html><html><head><meta charset="utf8" />${`<meta charset="utf-8"><ones-editor-doc data-source="ones-editor-doc::${Lo(JSON.stringify(t))}::ones-editor-doc" />`}</head><body>${n}</body></html>`}function ld(n,t){var i,s,l;const e=(l=(s=(i=n.doc).getServerMeta)==null?void 0:s.call(i))!=null?l:{},o=ev(n,t),r={};o.forEach(c=>{const a=n.doc.buildResourceUrl(c,{withToken:!0});r[c]=a}),t.meta={...e,resources:r}}function nv(n,t){if(t.preventDefault(),t.stopPropagation(),!t.clipboardData||n.selection.range.isCollapsed())return;const e=jl(n);ld(n,e);const o=rd(n,e),r=id(n,e),i=sd(o,e);t.clipboardData.setData("text/html",i),t.clipboardData.setData("text/plain",r),t.clipboardData.setData("text/x-ones-editor-doc",JSON.stringify(e))}function ov(n){if(n.selection.range.isCollapsed())return;const t=jl(n);ld(n,t);const e=rd(n,t),o=sd(e,t),r=new Blob([o],{type:"text/html"});il([{type:"text/html",data:r}])}async function cd(n,t){const e=nd(n,t,!1);ld(n,e);const o=rd(n,e),r=id(n,e),i=sd(o,e);return il([{type:"text/plain",data:new Blob([r],{type:"text/plain"})},{type:"text/html",data:new Blob([i],{type:"text/html"})}])}const ad=y("editor-input");class rv{constructor(t,e){h(this,"editor");h(this,"composing",!1);h(this,"callbacks");h(this,"inputElement");h(this,"handleDocumentSelectionChange",()=>{setTimeout(()=>{var e;const t=(e=document.getSelection())==null?void 0:e.focusNode;t&&this.editor.contains(t)&&!Ti(t)?(this.editor.emit("focus",this.editor),this.callbacks.onFocus(),this.editor.input.focus()):(this.editor.emit("blur",this.editor),this.callbacks.onBlur())},100)});h(this,"handleEditorSelectionChanged",()=>{const e=!this.editor.isWritable();this.inputElement.readOnly=e});h(this,"handleReadonlyChanged",()=>{this.handleEditorSelectionChanged()});h(this,"handleCompositionstart",t=>{this.composing=!0,this.callbacks.onCompositionStart(t)});h(this,"handleCompositionend",t=>{this.composing=!1,this.callbacks.onUpdateCompositionText(t,this.inputElement.value,!0),this.inputElement.value=""});h(this,"handleInput",t=>{if(t instanceof InputEvent&&!!t.data){if(this.editor.readonly){this.inputElement.value="";return}this.composing?this.callbacks.onUpdateCompositionText(t,t.data,!1):(this.callbacks.onInsertText(t,t.data),this.inputElement.value="")}});h(this,"handleKeyDown",t=>{if(!this.composing){if(this.callbacks.onKeyDown(t)){t.preventDefault(),t.stopPropagation();return}setTimeout(()=>{this.composing||(this.inputElement.value="")})}});h(this,"handleCopy",t=>{nv(this.editor,t)});h(this,"handleCut",t=>{if(this.editor.readonly){t.stopPropagation(),t.preventDefault();return}ad.debug("on cut")});h(this,"handlePaste",t=>{if(this.editor.readonly){t.stopPropagation(),t.preventDefault();return}this.callbacks.onPaste(t)});this.editor=t,this.callbacks=e;const o=b("input",["editor-input"],t.contentElement);o.type="text",o.name="editor-input",o.onkeydown=this.handleKeyDown,o.oninput=this.handleInput,o.oncopy=this.handleCopy,o.onpaste=this.handlePaste,o.oncut=this.handleCut,o.addEventListener("compositionstart",this.handleCompositionstart),o.addEventListener("compositionend",this.handleCompositionend),this.inputElement=o,document.addEventListener("selectionchange",this.handleDocumentSelectionChange),this.editor.addListener("selectionChanged",this.handleEditorSelectionChanged),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}destroy(){this.callbacks.destroy(),document.removeEventListener("selectionchange",this.handleDocumentSelectionChange),this.editor.removeListener("selectionChanged",this.handleEditorSelectionChanged),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged);const t=this.inputElement;t.removeEventListener("compositionstart",this.handleCompositionstart),t.removeEventListener("compositionend",this.handleCompositionend),t.onkeydown=null,t.oninput=null,t.oncopy=null,t.onpaste=null,t.oncut=null}getInput(){return this.inputElement}focus(){this.editor.selection.caret.visible()||this.editor.selection.caret.update(),It.isMobileSafari?this.inputElement.focus():setTimeout(()=>{this.inputElement.focus()})}handleChanged(t){this.callbacks.onChanged(t)}handleRemoteChanged(t){this.callbacks.onRemoteChanged(t)}addHandler(t){this.callbacks.addHandler(t)}removeHandler(t){this.callbacks.removeHandler(t)}defaultInsertText(t,e,o,r,i){d(ad,t===this.editor,"invalid editor"),this.callbacks.defaultInsertText(t,e,o,r,i)}defaultHandleKeydown(t,e){return d(ad,t===this.editor,"invalid editor"),this.callbacks.defaultHandleKeydown(t,e)}}function iv(n){const e=n.rootElement.getBoundingClientRect(),o=window.innerWidth,r=window.innerHeight,i=0-e.top+r/2,s=0-e.left+o/2,l=n.input.inputElement;l.style.left=`${s}px`,l.style.top=`${i}px`}const dd=y("editor-caret");class sv{constructor(t){h(this,"editor");h(this,"caretElem");h(this,"handleReadOnlyChanged",()=>{this.update()});this.editor=t,this.caretElem=b("div",["editor-cursor"],this.editor.contentElement),this.editor.on("readonlyChanged",this.handleReadOnlyChanged)}destroy(){this.editor.off("readonlyChanged",this.handleReadOnlyChanged)}visible(){const t=window.getComputedStyle(this.caretElem);return t.display!=="none"&&t.opacity!=="0"}hasCaret(){if(this.editor.readonly||!this.editor.selection.range.isCollapsed())return!1;const t=this.editor.selection.range.start;if(!(t instanceof Vt))return!1;const e=this.editor.getBlockById(t.blockId);return!!j(this.editor,e)}update(){if(Vf(this.editor.rootElement))return;const t=this.caretElem;if(this.hasCaret())t.style.display="";else{t.style.display="none",iv(this.editor);return}const{range:e}=this.editor.selection;d(dd,e.isCollapsed,"range is not collapsed");const o=e.start;d(dd,o instanceof Vt,"only simple block position can has caret");const r=this.editor.getBlockById(o.blockId);d(dd,j(this.editor,r),"only text kind block can has caret");let i;const s=r.querySelector("span.inputting-insertion");s?(i=xo(s),i=new DOMRect(i.right,i.top,1,i.height)):i=Oe(r,o);const l=this.editor.contentElement.getBoundingClientRect(),c=i.left-l.left,a=i.top-l.top;t.style.left=`${c}px`,t.style.top=`${a}px`,t.style.height=`${i.height}px`;const u=this.editor.input.inputElement;u.style.left=`${c}px`,u.style.top=`${a+i.height-24}px`,It.isMobileSafari&&(u.style.left=`${c-4}px`,u.style.height=`${i.height}px`)}}function lv(n){Wm(n),n.selection.range.getSelectedBlocks().forEach(t=>Gm(n,t.block,t.start,t.end))}function L2(n){return Nn(n.rootContainer).clientHeight}function cv(n){return n.getFirstBlock().getBoundingClientRect().top}function av(n){return n.getLastBlock().getBoundingClientRect().bottom}function ud(n){const t=Nn(n.rootContainer);return new DOMRect(t.clientLeft,t.clientTop,t.clientWidth,t.clientHeight)}function dv(n,t){const e=ud(n),o=n.getBlockById(t.blockId),i=Ge(n,o,t);return To(e,i.x,i.y)&&To(e,i.right,i.bottom)}function uv(n,t){const e=ud(n),o=t.getBoundingClientRect();return o.top>=e.top&&o.top<=e.bottom||o.bottom<=e.bottom&&o.bottom>=e.top}function hv(n,t){const e=ud(n),o=t.getBoundingClientRect();return To(e,o.x,o.y)||To(e,o.right,o.bottom)}function fv(n){const t=n.selection,e=t.range.focus;if(!e.isSimple()){const a=e,u=n.getContainerById(a.childContainerId);hv(n,u)||u.scrollIntoView();return}if(t.range.start.blockId===t.range.end.blockId){const a=n.getBlockById(t.range.start.blockId);if(Te(a)&&uv(n,a))return}const o=e,r=n.getBlockById(o.blockId);if(dv(n,o))return;const i=Ge(n,r,o),s=r.getBoundingClientRect(),l=At(r),c=b("div",["editor-block-anchor"],l);c.style.top=`${i.top-s.top}px`,Ei(c),setTimeout(()=>{c.remove()})}function mv(n,t){if(t.isCollapsed())return!1;const e=Qt(n.rootContainer),o=Gt(n.rootContainer),{start:r,end:i}=t;return r.blockId===G(e)&&r.offset===0&&i.blockId===G(o)&&i.offset===Z(n,o)}const Fl=y("editor-selection");class gv{constructor(t){h(this,"editor");h(this,"caret");h(this,"_range");h(this,"lastCaretRect");h(this,"handleBlockDelete",(t,e,o,r)=>{if(o||r.child)return;const i=this.range;if(h2(e,i)){Fl.debug("adjust selection because remote deleted current block");const s=f2(t,e);this.setRange(s)}});this.editor=t;const e=t.getFirstBlock(),o=G(e);this.caret=new sv(t);const r=$(o,0,"normal");this._range=Ut(t,{anchor:r,focus:r}),this.lastCaretRect=null,this.editor.addListener("blockDeleted",this.handleBlockDelete),setTimeout(()=>{this.updateFocusedBlock(null)})}destroy(){this.caret.destroy()}get range(){return this._range}get focusedBlock(){return this.getFocusedBlock()}get startBlock(){return this.getStartBlock()}get endBlock(){return this.getEndBlock()}getFocusedBlock(){const t=this.range.focus;return this.editor.getBlockById(t.blockId)}getStartBlock(){const t=this.range.start;return this.editor.getBlockById(t.blockId)}getEndBlock(){const t=this.range.end;return this.editor.getBlockById(t.blockId)}selectBlock(t,e,o){const r=$(t,e,"normal");let i;o&&(i=$(t,o,"normal")),this.setSelection(r,i)}setSelection(t,e,o){if(e||(e=t),this.verifyPos(t),this.verifyPos(e),!this.selectionChanging(t,e))return this.range;const r=Ut(this.editor,{anchor:t,focus:e});if(this.range.isEqual(r))return this.range;const i=this._range;return this._range=r,this.selectionChanged(),this.updateFocusedBlock(i),lt(this.editor.rootContainer,"select-all")&&(!r.isSimple()||!mv(this.editor,r))&&F(this.editor.rootContainer,"select-all"),o!=null&&o.noScroll||this.scrollIntoView(),this.range}setRange(t){return this.setSelection(t.anchor,t.focus)}updateSelection(){this.caret.update(),lv(this.editor)}getFocusedPos(){return this.range.focus}getAnchorPos(){return this.range.anchor}selectionChanging(t,e){return!0}selectionChanged(){this.updateSelection(),this.editor.emit("selectionChanged",this.editor)}updateLastCaretRect(){const t=this.range.focus;if(!kr(t))return;const e=this.editor.getBlockById(t.blockId);this.lastCaretRect=Ge(this.editor,e,t)}getSuggestedCaretX(){var t;return(t=this.lastCaretRect)==null?void 0:t.x}scrollIntoView(){fv(this.editor)}verifyPos(t){const e=this.editor.getBlockById(t.blockId);if(t.isSimple())t.offset>=0&&t.offset<=Z(this.editor,e)||d(Fl,!1,"invalid block position, out of range");else{const o=t.childContainerId;!!this.editor.getContainerById(o)||d(Fl,!1,"invalid complex block position, no container found")}}updateFocusedBlock(t){if(t&&this.range.start.blockId===t.start.blockId)return;let e;t&&t.start.blockId===t.end.blockId&&(e=this.editor.findBlockById(t.start.blockId));let o;(this.range.isCollapsed()||!this.range.isSimple()||this.range.start.blockId===this.range.end.blockId)&&(o=this.editor.getBlockById(this.range.start.blockId));let r=!1;e&&lt(e,"focused")&&(F(e,"focused"),r=!0),this.removeAllBlockFocusedClass(),o&&this.setBlockFocused(o)&&(r=!0),r&&this.editor.emit("focusBlockChanged",this.editor,o!=null?o:null,e!=null?e:null)}verify(){this.verifyPos(this._range.start),this.verifyPos(this._range.end)}removeAllBlockFocusedClass(){this.editor.rootContainer.querySelectorAll('div[data-type="editor-block"].focused, div[data-type="editor-block"].child-focused').forEach(t=>{F(t,"focused"),F(t,"child-focused")})}setBlockFocused(t){if(lt(t,"focused"))return!1;M(t,"focused");let e=H(t);for(;qe(e);){const o=z(e);d(Fl,o,"parent block not found"),M(o,"child-focused"),e=H(o)}return!0}}const M2=y("line-offset");function hd(n){const t=n.selection.range.focus;d(M2,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId);if(t.offset===0||!j(n,e))return $(e,0,"home");let r=vg(e,t).start;const{next:i}=gl(e,r);return i&&Me(i)&&Si(i)==="br"&&(r+=1),$(e,r,"home")}function fd(n){const t=n.selection.range.focus;d(M2,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId);if(t.offset===Z(n,e)||!j(n,e))return $(e,0,"end");const o=vg(e,t);return $(e,o.end,"end")}function pv(n){if(!n.selection.range.focus.isSimple())return;const e=hd(n),o=fd(n);!e||!o||n.selection.setSelection(e,o)}const Ne=y("block-text");function R2(n,t,e){d(Ne,j(n,t),"not a text kind block"),d(Ne,fe(t,e),"not a valid offset"),d(Ne,e>0&&e<=Z(n,t),`invalid offset: ${e}`);const o=Po(t,e),r=e-o;r===0&&d(Ne,!1,`no text before offset: ${e}`);const i=ke(n,t),{middle:s}=Kt(i,o,r);d(Ne,s.length===1,"failed to split text to 3 parts");const l=s[0];return E1(l)?{op:l,charType:"box",offset:o,length:1}:{op:l,charType:tl(l.insert)?"space":"text",offset:o,length:l.insert.length}}function A2(n,t,e){d(Ne,j(n,t),"not a text kind block"),d(Ne,fe(t,e),"not a valid offset"),d(Ne,e>=0&&e<Z(n,t),`invalid offset: ${e}`);const r=Ir(t,e)-e;r===0&&d(Ne,!1,`no text after offset: ${e}`);const i=ke(n,t),{middle:s}=Kt(i,e,r);d(Ne,s.length===1,"failed to split text to 3 parts");const l=s[0];return E1(l)?{op:l,charType:"box",offset:e,length:1}:{op:l,charType:tl(l.insert)?"space":"text",offset:e,length:l.insert.length}}function O2(n,t,e,o){let r=e;for(;r>0;){const i=R2(n,t,r);if(i.charType!==o)return i;r-=i.length}return null}function _2(n,t,e,o){const r=Z(n,t);let i=e;for(;i<r;){const s=A2(n,t,i);if(s.charType!==o)return s;i+=s.length}return null}function N2(n,t,e){if(d(Ne,j(n,t),"invalid blok type"),wt(n,t))return 0;const o=R2(n,t,e);if(o.charType==="box")return e-1;let r=e;if(o.charType==="space"){const s=O2(n,t,r,"space");if(!s||s.offset===0)return 0;if(s.charType==="box")return s.offset;r=s.offset}const i=O2(n,t,r,"text");return i?i.offset+i.length:0}function P2(n,t,e){if(d(Ne,j(n,t),"invalid blok type"),wt(n,t))return 0;const o=A2(n,t,e);if(o.charType==="box")return e+1;let r=e;if(o.charType==="space"){const s=_2(n,t,r,"space");if(!s||s.offset===0)return Z(n,t);if(s.charType==="box")return s.offset;r=s.offset}const i=_2(n,t,r,"text");return i?i.offset:Z(n,t)}const $2=y("word-offset");function md(n,t){const e=n.selection.range.focus;d($2,e.isSimple(),"invalid range type");const o=n.getBlockById(e.blockId);if(wt(n,o))return $(o,0,"home");if(e.offset===0||!j(n,o)){const s=gt(o);if(!s)return null;const l=$(s,Z(n,s),"end");if(t==="select"&&j(n,s)){const c=N2(n,s,l.offset);return $(s,c,"normal")}return l}const r=N2(n,o,e.offset);return $(o,r,"normal")}function gd(n,t){const e=n.selection.range.focus;d($2,e.isSimple(),"invalid range type");const o=n.getBlockById(e.blockId);if(wt(n,o))return $(o,0,"end");if(e.offset===Z(n,o)||!j(n,o)){const s=ht(o);if(!s)return null;const l=$(s,0,"home");if(t==="select"&&j(n,s)){const c=P2(n,s,l.offset);return $(s,c,"end")}return l}const r=P2(n,o,e.offset);return $(o,r,"normal")}function Cv(n){const t=n.selection.range.focus;if(!t.isSimple())return;const e=n.findBlockById(t.blockId);if(!e||!j(n,e))return;const o=md(n,"select"),r=gd(n,"select");!o||!r||n.selection.setSelection(o,r)}const me=y("adjust-selection-pos");function H2(n){const t=[];for(;n;){const e=H(n);if(t.unshift(e),Ct(e))return t;const o=z(e);d(me,o,"child container has not parent container"),n=o}d(me,!1,"should not come here: getParentContainers")}function j2(n,t){for(;t;){const e=H(t);if(e===n)return t;const o=z(e);d(me,o,"could not find parent block for a child container"),t=o}d(me,!1,"no parent block in specified container")}function bv(n,t){const e=H2(n),o=H2(t);d(me,e.length>0&&o.length>0,"block has not parent container"),d(me,e[0]===o[0],"root container does not equal");let r=e[0];for(let l=1;l<e.length||o.length;l++)if(e[l]!==o[l]){r=e[l-1];break}const i=j2(r,n),s=j2(r,t);return{parentContainer:r,newBlock1:i,newBlock2:s}}function F2(n,t){let e=z(t);for(d(me,e,"element is not in a block");e;){const o=H(e);d(me,qe(o),"not a child container");const r=z(o);if(d(me,r,"child container has not parent block"),r===n)return o;e=r}d(me,!1,"failed to find parent container in complex block")}function zl(n,t,e){const o=n.getBlockById(t.blockId),r=n.getBlockById(e.blockId);if(o===r)return t instanceof Vt&&e instanceof Vt?{anchor:t,focus:e}:(d(me,t instanceof Ze&&e instanceof Ze,"both start and end are not simple or complex"),ml(n,o,t,e));const i=H(o),s=H(r);if(i===s)return t instanceof Ze&&(t=$(o,0,"home")),e instanceof Ze&&(e=$(r,Z(n,r),"end")),d(me,t instanceof Vt,"not valid position type"),d(me,e instanceof Vt,"not valid position type"),{anchor:t,focus:e};if(o.contains(s))return null;if(r.contains(i)){if(t instanceof Vt&&e instanceof Ze){const v=n.getContainerById(e.childContainerId);if(v===i)return{anchor:e,focus:e};const w=z(i);if(w&&w===z(v)){const E=bt(w,V(i)),L=bt(w,V(v));return ml(n,w,E,L)}}return null}const l=Xs(o,r)>0,{newBlock1:c,newBlock2:a}=bv(o,r);if(c===a){const v=c,w=F2(v,o),E=F2(v,r);return t=bt(c,V(w)),e=bt(c,V(E)),me.debug(`select in complex block: ${w.id}, ${E.id}`),ml(n,v,t,e)}let u=l?Z(n,c):0;c===o&&t instanceof Vt&&(u=t.offset);let m=l?0:Z(n,a);return a===r&&e instanceof Vt&&(m=e.offset),t=$(c,u,l?"end":"home"),e=$(a,m,l?"home":"end"),{anchor:t,focus:e}}const vv=y("range-from-point");function z2(n,t,e){const o=[0,-12,12];for(let r=0;r<o.length;r++){const i=document.elementsFromPoint(t,e+o[r])[0];if(!i||!n.rootContainer.contains(i))continue;const s=z(i);if(!s||!n.contains(s))continue;const l=kt(n,s).getRangeFromPoint(n,s,t,e+o[r]);if(l)return l}return null}function V2(n,t,e,o){const r=t.getBoundingClientRect();if(o<=r.top){const l=Qt(t),c=$(l,0,"home");return new se(n,{anchor:c,focus:c})}const i=Gt(t),s=$(i,Z(n,i),"end");return new se(n,{anchor:s,focus:s})}function kv(n,t,e){const o=z2(n,t,e);if(o){if(o instanceof se)return o;d(vv,o instanceof Ye,`invalid range type: ${typeof o}`);const c=o,a=n.getContainerById(c.start.childContainerId);return V2(n,a,t,e)}const r=document.elementsFromPoint(t,e)[0];if(!r)return null;const{children:i}=r,s=Array.from(i).filter(c=>fn(c));if(s.length===0)return null;const l=s.reduce((c,a)=>{const u=c.getBoundingClientRect(),f=a.getBoundingClientRect();return hn(u,t,e)>hn(f,t,e)?a:c});return V2(n,l,t,e)}class yv{constructor(t){h(this,"editor");h(this,"startPos",null);h(this,"lastCaretRect");h(this,"mouseDownEvent",null);h(this,"handleMouseDown",t=>{this.mouseDownEvent=t;const e=kv(this.editor,t.x,t.y);if(e){if(e instanceof Ye)return;const o=this.editor.selection.range;if(t.shiftKey&&o.isSimple()){const r=o.anchor;this.editor.selection.setSelection(r,e.focus),this.startPos=e.start}else this.editor.selection.setSelection(e.anchor,e.focus),this.startPos=e.start;this.editor.selection.updateLastCaretRect()}});h(this,"handleMouseMove",t=>{if(!this.startPos||!this.mouseDownEvent||Math.abs(this.mouseDownEvent.x-t.x)<3&&Math.abs(this.mouseDownEvent.y-t.y)<3)return;const e=z2(this.editor,t.x,t.y);if(!e)return;const o=zl(this.editor,this.startPos,e.end);if(!o)return;const{anchor:r,focus:i}=o;this.editor.selection.setSelection(r,i)});h(this,"handleMouseUp",t=>{this.startPos=null});this.editor=t,this.startPos=null,this.lastCaretRect=new DOMRect}isSelecting(){return this.startPos!==null}stopSelection(){this.startPos=null}handleDblClick(t){Cv(this.editor)}handleTripleClick(t){pv(this.editor)}}const wv=y("move-complex-block-position");function Bv(n,t,e){const o=n.getBlockById(t.blockId);d(wv,ct(n,o),"is not a complex block");const r=ve(n,o),i=n.getContainerById(t.childContainerId),s=r.getNextContainer(n,o,i,e,{noWrap:!0});return s?bt(o,V(s)):null}const ji=y("move-simple-block-position");function U2(n,t){const e=Le(n,t);d(ji,e.length>0,"complex block has not any child container");const o=e[0];return Qt(o)}function q2(n,t){const e=Le(n,t);d(ji,e.length>0,"complex block has not any child container");const o=e[e.length-1];return Gt(o)}function W2(n,t,e){const o=e?U2(n,t):q2(n,t);return ct(n,o)?W2(n,o,e):o}function Ev(n,t){const e=n.getBlockById(t.blockId);return ct(n,e)&&t.offset===0?U2(n,e):Cr(e)}function Iv(n,t){const e=n.getBlockById(t.blockId);return ct(n,e)&&t.offset===1?q2(n,e):pr(e)}function pd(n){return n==="ArrowLeft"||n==="ArrowUp"}function Cd(n,t,e){const o=H(t);if(Ct(o))return null;const r=z(o);d(ji,r,"child container has not parent block"),d(ji,ct(n,r),"is not a complex block");const i=ve(n,r).getNextContainer(n,r,o,e);return i?pd(e)?Gt(i):Qt(i):Cd(n,r,e)}function xv(n,t,e){const o=H(t);if(Ct(o))return null;const r=z(o);if(d(ji,r,"child container has not parent block"),pd(e)){const l=gt(r);if(l)return l}else{const l=ht(r);if(l)return l}const i=Cd(n,r,e);if(i)return i;let s=r;for(;!Ct(H(s));)s=z(H(s));return pd(e)?gt(s):ht(s)}function Sv(n,t,e){return!ct(n,t)||ve(n,t).enableKeyboardSelect?t:W2(n,t,e==="ArrowDown"||e==="ArrowRight")}function Tv(n,t,e){const o=n.getBlockById(t.blockId),i=kt(n,o).moveCaret(n,o,t,e);if(i)return i;let s=e==="ArrowDown"||e==="ArrowRight"?Ev(n,t):Iv(n,t);if(s||(s=Cd(n,o,e),s||(s=xv(n,o,e))),!s){if(e==="ArrowDown"||e==="ArrowRight"){if(n.readonly||!Ct(H(o)))return null;const l=n.insertTextBlock("",V(n.rootContainer),Ve(n.rootContainer));return $(l,0,"home")}return null}if(s=Sv(n,s,e),j(n,s)){const l=n.selection.getSuggestedCaretX();if(e==="ArrowDown")return ib(n,s,o,t,l);if(e==="ArrowUp")return rb(n,s,o,t,l)}return e==="ArrowLeft"||e==="ArrowUp"?$(s,Z(n,s),"end"):e==="ArrowRight"||e==="ArrowDown"?$(s,0,"home"):null}function Dv(n,t,e){if(t==="ArrowLeft")return e.start;const o=e.end,r=n.getBlockById(o.blockId);if(j(n,r))return o;const i=ht(r);if(i)return $(i,0,"home");if(!Ct(H(r))||n.readonly)return o;const s=n.insertTextBlock("",V(n.rootContainer),Ve(n.rootContainer));return $(s,0,"home")}function Lv(n,t,e){const o=n.selection.range;let r;if(o instanceof se)e==="move"&&!o.isCollapsed()&&(t==="ArrowLeft"||t==="ArrowRight")?r=Dv(n,t,o):r=Tv(n,o.getFocusedPos(),t);else if(r=Bv(n,o.focus,t),e==="move"){const i=r!=null?r:o.focus,s=n.getContainerById(i.childContainerId);if(t==="ArrowLeft"||t==="ArrowUp"){const l=Gt(s);r=$(l,0,"home")}else{const l=Qt(s);r=$(l,Z(n,l),"end")}}return r?e==="move"?{anchor:r,focus:r}:zl(n,o.anchor,r):null}function io(n,t,e){const o=Lv(n,t,e);if(!o)return!1;const{anchor:r,focus:i}=o;return n.selection.setSelection(r,i),(t==="ArrowLeft"||t==="ArrowRight")&&n.selection.updateLastCaretRect(),!0}function Mv(n){return io(n,"ArrowLeft","move"),!0}function Rv(n){return io(n,"ArrowRight","move"),!0}function Av(n){return io(n,"ArrowUp","move"),!0}function Ov(n){if(io(n,"ArrowDown","move")||n.readonly)return!0;const t=n.getFocusedBlock(),e=H(t);if(Ct(e)||Gt(e)!==t)return!0;const o=n.rootContainer;return n.insertTextBlock("",V(o),Ve(o)),!0}function _v(n){return io(n,"ArrowDown","select"),!0}function Nv(n){return io(n,"ArrowLeft","select"),!0}function Pv(n){return io(n,"ArrowRight","select"),!0}function $v(n){return io(n,"ArrowUp","select"),!0}function Hv(n){if(!n.selection.range.focus.isSimple())return!1;const e=md(n,"move");return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function jv(n){if(!n.selection.range.focus.isSimple())return!1;const e=gd(n,"move");return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function Fv(n){if(!n.selection.range.focus.isSimple())return!1;const e=md(n,"select");return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function zv(n){if(!n.selection.range.focus.isSimple())return!1;const e=gd(n,"select");return e?(n.selection.setSelection(n.selection.range.anchor,e),n.selection.updateLastCaretRect(),!0):!1}y("find-block");function bd(n,t){if(!ct(n,t))return t;const o=ve(n,t).getChildContainers(n,t)[0],i=Rt(o)[0];return bd(n,i)}function vd(n,t){if(!ct(n,t))return t;const e=ve(n,t).getChildContainers(n,t),o=e[e.length-1],r=Rt(o),i=r[r.length-1];return vd(n,i)}function Vv(n){const t=vd(n,Gt(n.rootContainer)),e=$(t,Z(n,t),"end");return n.selection.setSelection(e),!0}function Uv(n){const t=bd(n,n.getFirstBlock()),e=$(t,0,"home");return n.selection.setSelection(e),!0}function qv(n){const t=bd(n,n.getFirstBlock()),e=$(t,0,"home");return n.selection.setSelection(n.selection.getAnchorPos(),e),!0}function Wv(n){const t=vd(n,Gt(n.rootContainer)),e=$(t,Z(n,t),"end");return n.selection.setSelection(n.selection.getAnchorPos(),e),!0}function Gv(n){if(!n.selection.range.focus.isSimple())return!1;const e=hd(n);return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function Zv(n){if(!n.selection.range.focus.isSimple())return!1;const e=fd(n);return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function Yv(n){if(!n.selection.range.focus.isSimple())return!1;const e=hd(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function Qv(n){if(!n.selection.range.focus.isSimple())return!1;const e=fd(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}const G2=y("find-block-position");function Kv(n,t,e,o){d(G2,ct(n,t),"is not a complex block");const r=ve(n,t).getChildContainers(n,t);d(G2,r.length>0,"complex block has not any child container");const i=Ge(n,e,o),s=i.left+i.width/2,l=i.top+i.height/2,c=ug(n,t,s,l);return kd(n,c,e,o)}function kd(n,t,e,o){if(ct(n,t))return Kv(n,t,e,o);const r=G(t);let i=Number.MAX_SAFE_INTEGER;const s=Ge(n,e,o),l=s.left+s.width/2,c=s.top+s.height/2;let a=$(r,0,"home");const u=Z(n,t);for(let f=0;f<=u;f++){const m=$(r,f,"normal"),C=Ge(n,t,m),v=hn(C,l,c);v<i&&(i=v,a=m)}return a}const Z2=y("page-offset");function Jv(n,t){const e=L2(n)*.9,r=t.getBoundingClientRect().bottom-e;if(r<cv(n))return n.getFirstBlock();const i=gt(t);if(!i)return n.getFirstBlock();let s=i;for(;s;){if(s.getBoundingClientRect().y<r)return s;s=gt(s)}return n.getFirstBlock()}function Xv(n,t){const e=L2(n)*.9,o=t.getBoundingClientRect(),r=av(n),i=o.top+e;if(i>r)return n.getLastBlock();const s=ht(t);if(!s)return n.getLastBlock();let l=s;for(;l;){if(l.getBoundingClientRect().bottom>i)return l;l=ht(l)}return n.getLastBlock()}function Y2(n){const t=n.selection.range.focus;d(Z2,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId),o=Jv(n,e);let r;return o===n.getFirstBlock()?r=$(o,0,"home"):r=kd(n,o,e,t),r}function Q2(n){const t=n.selection.range.focus;d(Z2,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId),o=Xv(n,e);let r;return o===n.getLastBlock()?r=$(o,Z(n,o),"end"):r=kd(n,o,e,t),r}function tk(n){if(!n.selection.range.focus.isSimple())return!1;const e=Y2(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function ek(n){if(!n.selection.range.focus.isSimple())return!1;const e=Q2(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function nk(n){if(!n.selection.range.focus.isSimple())return!1;const e=Y2(n);if(!e)return!1;const o=zl(n,n.selection.getAnchorPos(),e);if(!o)return!1;const{anchor:r,focus:i}=o;return n.selection.setSelection(r,i),n.selection.updateLastCaretRect(),!0}function ok(n){if(!n.selection.range.focus.isSimple())return!1;const e=Q2(n);if(!e)return!1;const o=zl(n,n.selection.getAnchorPos(),e);if(!o)return!1;const{anchor:r,focus:i}=o;return n.selection.setSelection(r,i),n.selection.updateLastCaretRect(),!0}const Fi=y("select-all");function rk(n,t){const e=t.getEditor(),o=ve(e,n).getChildContainers(e,n),r=o[0],i=o[o.length-1],s=G(n);return t.start.blockId===s&&t.start.childContainerId===V(r)&&t.end.blockId===s&&t.end.childContainerId===V(i)}function ik(n,t){d(Fi,t,"no parent block"),d(Fi,ct(n,t),"not a complex block");const e=ve(n,t).getChildContainers(n,t),o=e[0],r=e[e.length-1];n.selection.setRange(Ut(n,{anchor:bt(t,V(o)),focus:bt(t,V(r))}))}function K2(n,t){const e=H(t),o=Rt(e),r=o[0],i=o[o.length-1],s=$(r,0,"home"),l=$(i,Z(n,i),"end");n.selection.setSelection(s,l,{noScroll:!0})}function sk(n){const t=n.getFocusedBlock(),e=n.selection.range;if(e.start.isSimple()){if(e.start.blockId===e.end.blockId&&j(n,t)){const r=e.start,i=e.end,s=Z(n,t);if(r.offset>0||i.offset<s)return n.selection.selectBlock(t,0,s),!1}return M(n.rootContainer,"select-all"),K2(n,Qt(n.rootContainer)),!1}return d(Fi,!e.isSimple(),"invalid range type"),rk(t,e)?(K2(n,t),!1):(d(Fi,t,"no parent block"),d(Fi,ct(n,t),"not a complex block"),ik(n,t),!0)}function lk(n){return n.readonly||!n.isWritable()?!1:(n.undoManager.undo(),!0)}function ck(n){return n.readonly||!n.isWritable()?!1:(n.undoManager.redo(),!0)}const J2=y("delete-text");function X2(n,t,e,o){const r=o!=null?o:n.selection.range.start;r instanceof Vt||d(J2,!1,`invalid insert pos type: ${typeof r}`);const{blockId:i}=r,s=n.getBlockById(i);d(J2,j(n,s),"block is not a text kind block");let{offset:l}=r;if(t==="backward"){if(l-e<0)return 0;if(!fe(s,l-e)){const c=Po(s,l);e=l-c}}else if(t==="forward"&&l+e>Z(n,s))return 0;return t==="backward"&&(l-=e),n.deleteTextFromBlock(s,l,e)}function t0(n,t){if(n.getBlockData(t).quoted){const e={quoted:null};return n.updateBlockData(t,e),!0}return!1}const ak=y("handle-backspace");function yd(n,t){if(!wt(n,t))return;const e=H(t);Ve(e)!==1&&n.deleteBlock(t)}function dk(n,t){if(!n.selection.range.isCollapsed()){n.clearSelectedContents();return}const e=n.selection.range.start,o=n.getBlockById(e.blockId);if(j(n,o))if(e.offset===0){if(t0(n,o))return;const r=gt(o);if(r)if(j(n,r))n.mergeTextBlock(r,o,{focus:!0});else if(ct(n,r)){yd(n,o);const i=wr(n,r);i?n.selection.selectBlock(i,Z(n,i)):n.selection.selectBlock(r,0,Z(n,r))}else yd(n,o),d(ak,Te(r),"prev block is not embed block"),n.selection.selectBlock(r,1);else{const i=H(o);if(qe(i)){const s=cg(n,i);s&&(yd(n,o),n.selection.selectBlock(s,Z(n,s)))}}}else X2(n,"backward",1,null);else{const r=K(o),i=H(o);n.insertTextBlock("",V(i),r),n.deleteBlock(o)}}function uk(n,t){if(!n.selection.range.isCollapsed()){n.clearSelectedContents();return}const e=n.selection.range.start,o=n.getBlockById(e.blockId);if(j(n,o))if(e.offset===Z(n,o)){const r=ht(o);r&&(j(n,r)?n.mergeTextBlock(o,r,{focus:!0}):wt(n,o)?n.deleteBlock(o,Ot(n,r,0)):n.deleteBlock(r))}else X2(n,"forward",1,null);else{const r=K(o),i=H(o);n.insertTextBlock("",V(i),r),n.deleteBlock(o)}}function hk(n,t){n.selection.range.isCollapsed()||n.clearSelectedContents();const e=n.getFocusedBlock();if(j(n,e)){if(wt(n,e)&&t0(n,e))return;const o=n.selection.range.start,r=n.breakTextBlock(e,o.offset,{copyBlockAttributes:!0});o.offset!==0?n.selection.selectBlock(r,0):n.selection.scrollIntoView()}else{const o=n.insertTextBlock();n.selection.selectBlock(o,0)}}function fk(n,t){const e=n.selection.range.getSelectedBlocks()[0],{block:o}=e;if(!j(n,o))return!1;const r=e.end;return n.insertBoxToBlock(o,r.offset,{type:"br",id:N(),box:!0,created:Date.now()}),!0}const mk=y("input-handler-actions");function gk(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(hk(n),!0))}function pk(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(uk(n),!0))}function Ck(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(dk(n),!0))}function bk(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(fk(n),!0))}function vk(n){return n.readonly||!n.isWritable()||!window.isSecureContext?!1:(navigator.clipboard.readText().then(t=>{const e=n.selection.focusedBlock,o=n.selection.range.start;d(mk,o.isSimple(),"not simple position"),n.insertTextToBlock(e,o.offset,t)}),!0)}function kk(n){return ov(n),Y1(n),!0}const Vl={ArrowDown:Ov,ArrowUp:Av,ArrowLeft:Mv,ArrowRight:Rv,"Shift+ArrowDown":_v,"Shift+ArrowUp":$v,"Shift+ArrowLeft":Nv,"Shift+ArrowRight":Pv,"CtrlOrCmd+ArrowLeft":Hv,"CtrlOrCmd+ArrowRight":jv,"CtrlOrCmd+Shift+ArrowLeft":Fv,"CtrlOrCmd+Shift+ArrowRight":zv,"CtrlOrCmd+ArrowUp":Uv,"CtrlOrCmd+ArrowDown":Vv,"CtrlOrCmd+Shift+ArrowUp":qv,"CtrlOrCmd+Shift+ArrowDown":Wv,"CtrlOrCmd+A":sk,Home:Yv,End:Qv,"Shift+Home":Gv,"Shift+End":Zv,PageUp:tk,PageDown:ek,"Shift+PageUp":nk,"Shift+PageDown":ok,"CtrlOrCmd+X":kk,"CtrlOrCmd+Z":lk,"CtrlOrCmd+Shift+Z":ck,Enter:gk,Delete:pk,Backspace:Ck,"Shift+Enter":bk,"CtrlOrCmd+Shift+V":vk};function e0(n,t){return n.shortcuts.handleKeyboardEvents(n,t)!==void 0}function n0(n,t,e){if(t.type==="embed"){const i=t.embedData,s=i.src;if(s&&typeof s=="string"){const l=e.get(s);l&&(i.src=l)}return}const o=t.text;o&&o.forEach(i=>{if(i.attributes&&i.attributes.src&&typeof i.attributes.src=="string"){const s=e.get(i.attributes.src);s&&(i.attributes.src=s)}});const r=t.children;r&&r.forEach(i=>{n.blocks[i].forEach(l=>{n0(n,l,e)})})}function o0(n,t,e){if(e.size===0)return;t.blocks.root.forEach(r=>{const i=n.editorBlocks.getBlockClass(r.type);i.replaceResources?i.replaceResources(r,e):n0(t,r,e)})}async function yk(n,t){const e=t.filter(i=>i.indexOf(":")===-1),o=await n.doc.addResources(e),r=new Map;if(e.length!==o.length)return r;for(let i=0;i<e.length;i++)r.set(e[i],o[i]);return r}function wk(n,t){var i,s;const o=t.meta.serverId;if(!o||typeof o!="string")return!1;const r=(s=(i=n.doc).getServerMeta)==null?void 0:s.call(i);return!(!r||r.serverId!==o)}async function Bk(n,t){const o=t.meta.resources;if(!o||Object.keys(o).length===0)return;let r=new Map;if(wk(n,t)){const s=Array.from(Object.keys(o));r=await yk(n,s),o0(n,t,r)}const i=new Map;Object.entries(o).forEach(([s,l])=>{r.get(s)===void 0&&s!==l&&i.set(s,l)}),i.size!==0&&o0(n,t,i)}async function Ek(n,t){await Bk(n,t),n.undoManager.runInGroup(()=>{n.clearSelectedContents();const{block:e,offset:o}=Tr(n);n.insertDoc(e,o,t)})}const Ik=["text/x-ones-editor-doc","image/*","text/html","text/plain","text/markdown","*"];function xk(n){let t;for(const e of Ik)if(t=n[e],t)break;return t||null}class Sk{constructor(t){h(this,"editor");h(this,"handlers",[]);this.editor=t}onInsertText(t,e){if(!j(this.editor,this.editor.getFocusedBlock()))return;const{containerId:o,blockIndex:r,offset:i}=Tr(this.editor);this.handleBeforeInsertText(o,r,i,e)||(this.defaultInsertText(this.editor,o,r,i,e),this.handleAfterInsertText(o,r,i,e))}onKeyDown(t){if(this.handleBeforeKeyDown(t))return!0;const e=this.defaultHandleKeydown(this.editor,t);return this.handleAfterKeyDown(t)?!0:e}onChanged(t){for(let e=0;e<this.handlers.length;e++){const o=this.handlers[e];o.handleChanged&&o.handleChanged(this.editor,t)}}onRemoteChanged(t){for(let e=0;e<this.handlers.length;e++){const o=this.handlers[e];o.handleRemoteChanged&&o.handleRemoteChanged(this.editor,t)}}onCompositionStart(t){this.editor.updateCompositionText("",!1);const{containerId:e,blockIndex:o,offset:r}=Tr(this.editor);for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];s.handleCompositionStart&&s.handleCompositionStart(this.editor,e,o,r)}}onUpdateCompositionText(t,e,o){this.editor.updateCompositionText(e,o),this.editor.selection.caret.update();const{containerId:r,blockIndex:i,offset:s}=Tr(this.editor);for(let l=0;l<this.handlers.length;l++){const c=this.handlers[l];c.handleUpdateCompositionText&&c.handleUpdateCompositionText(this.editor,r,i,s,o)}}onPaste(t){if(t.preventDefault(),t.stopPropagation(),!t.clipboardData)return;this.editor.dataConverter.fromData(this.editor,t.clipboardData).then(async o=>{if(!o)return;for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];if(s.handleBeforePaste&&await s.handleBeforePaste(this.editor,t,o))return}const r=xk(o);if(!!r){await this.pasteDoc(r);for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];if(s.handleAfterPaste&&await s.handleAfterPaste(this.editor,t,o))return}}})}onFocus(){M(this.editor.rootElement,"active")}onBlur(){F(this.editor.rootElement,"active")}addHandler(t){this.handlers.push(t)}removeHandler(t){const e=this.handlers.indexOf(t);e!==-1&&this.handlers.splice(e)}handleBeforeInsertText(t,e,o,r){for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];if(s.handleBeforeInsertText&&s.handleBeforeInsertText(this.editor,t,e,o,r))return!0}return!1}handleAfterInsertText(t,e,o,r){for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];if(s.handleAfterInsertText&&s.handleAfterInsertText(this.editor,t,e,o,r))return!0}return!1}handleBeforeKeyDown(t){for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleBeforeKeyDown&&r.handleBeforeKeyDown(this.editor,t))return!0}const e=this.defaultHandleKeydown(this.editor,t);for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleAfterKeyDown&&r.handleAfterKeyDown(this.editor,t))return!0}return e}handleAfterKeyDown(t){for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleBeforeKeyDown&&r.handleBeforeKeyDown(this.editor,t))return!0}const e=this.defaultHandleKeydown(this.editor,t);for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleAfterKeyDown&&r.handleAfterKeyDown(this.editor,t))return!0}return e}defaultInsertText(t,e,o,r,i){V1(this.editor,i)}defaultHandleKeydown(t,e){return e0(this.editor,e)?(e.preventDefault(),e.stopPropagation(),!0):!1}async pasteDoc(t){for(let e=0;e<this.handlers.length;e++){const o=this.handlers[e];if(o.handleBeforePasteDoc&&await o.handleBeforePasteDoc(this.editor,t))return}await Ek(this.editor,t);for(let e=0;e<this.handlers.length;e++){const o=this.handlers[e];if(o.handleAfterPasteDoc&&await o.handleAfterPasteDoc(this.editor,t))return}}destroy(){this.handlers.forEach(t=>{var e;(e=t.destroy)==null||e.call(t,this.editor)}),this.handlers=[]}}function Tk(n,t,e){const o=mr(t,e);return o.remove(),o}const wd=y("copy-dom-attributes"),r0=["onabort","onanimationcancel","onanimationend","onanimationiteration","onanimationstart","onauxclick","onblur","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","onformdata","ongotpointercapture","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onlostpointercapture","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onpause","onplay","onplaying","onpointercancel","onpointerdown","onpointerenter","onpointerleave","onpointermove","onpointerout","onpointerover","onpointerup","onprogress","onratechange","onreset","onresize","onscroll","onsecuritypolicyviolation","onseeked","onseeking","onselect","onselectionchange","onselectstart","onslotchange","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","ontouchcancel","ontouchend","ontouchmove","ontouchstart","ontransitioncancel","ontransitionend","ontransitionrun","ontransitionstart","onvolumechange","onwaiting","onwebkitanimationend","onwebkitanimationiteration","onwebkitanimationstart","onwebkittransitionend","onwheel"];function Dk(n,t){for(let l=0;l<r0.length;l++){const c=r0[l];t[c]=n[c]}const e=n.attributes,o=t.attributes,r=[],i=[];for(let l=0;l<e.length;l++){const c=e[l],a=o.getNamedItem(c.name);a?a.value!==c.value&&(a.value=c.value,i.push(c)):r.push(c)}const s=[];for(let l=0;l<o.length;l++){const c=o[l];e.getNamedItem(c.name)||s.push(c)}r.forEach(l=>{wd.debug(`add attribute: ${l.name}, ${l.value}`),t.setAttribute(l.name,l.value)}),i.forEach(l=>{wd.debug(`copy attribute: ${l.name}, ${l.value}`),t.setAttribute(l.name,l.value)}),s.forEach(l=>{wd.debug(`delete attribute: ${l.name}`),t.removeAttribute(l.name)})}function i0(n){const t=Array.from(n.childNodes);return t.forEach(e=>{e instanceof HTMLElement&&e.getAttribute("data-type")==="block-tools"||e.remove()}),t}function s0(n,t,e){var a;const o=n.getContainerById(t),r=mr(o,e),i=Ro(r),s=n.doc.getBlockData(t,e),l=kt(n,r);if((a=l==null?void 0:l.handleUpdateBlock)==null?void 0:a.call(l,n,r,s))n.editorBlockRenders.updateBlock(n,i,r,s);else{const u=n.editorBlocks.createBlock(i,o,s),f=i0(u);i0(r),f.forEach(C=>r.appendChild(C));const m=al(u);if(m){const C=al(r);C&&C.remove(),r.appendChild(m)}Dk(u,r)}Ym(n,r,s),n.blockHooks.forEach(u=>{var f;(f=u.update)==null||f.call(u,n,i,o,r,s)}),setTimeout(()=>{n.selection.updateSelection(null)})}const Lk=y("transform-selection");function l0(n,t,e,o){const{range:r}=n.selection,{anchor:i,focus:s}=r;if(i.blockId!==t&&s.blockId!==t)return r;d(Lk,i.isSimple()&&s.isSimple(),"invalid text pos type");let l=i;if(i.blockId===t){const a=ne.transformCursor(i.offset,e,o);l=$(t,a,"normal")}let c=s;if(s.blockId===t){const a=ne.transformCursor(s.offset,e,o);c=$(t,a,"normal")}return Ut(n,{anchor:l,focus:c})}const Mk=y("handle-block-text-changed");function Rk(n,t,e,o,r){const i=n.getContainerById(t),s=mr(i,e),l=n.doc.getBlockData(t,e);if(d(Mk,l.text,"no block text"),qm(n,s).setBlockText(n,s,l.text),!r){const c=l0(n,l.id,o,r);n.selection.setRange(c)}}function Ak(n,t){const e=Y.default(n);return t.delete.forEach(r=>{delete e[r]}),{...e,...t.insert}}function c0(n,t,e,o){const r=kt(n,t);r.handleDeleteBlock&&r.handleDeleteBlock(n,t,e,o),n.emit("blockDeleted",n,t,e,o)}function Ok(n,t,e,o){const r=n.getBlockByIndex(t,e);r.querySelectorAll('[data-type="editor-block"]').forEach(i=>{c0(n,i,o,{child:!0})}),c0(n,r,o,{child:!1})}const so=y("editor-doc");class _k extends ki{constructor(e,o,r){super();h(this,"localEvents",[]);this.editor=e,this.externalDoc=o,this.externalDoc.registerCallback(this),this.registerLocalEvents(r)}beginBatchUpdate(){return this.externalDoc.beginBatchUpdate()}endBatchUpdate(){return this.externalDoc.endBatchUpdate()}registerLocalEvents(e){this.localEvents.push(e)}toJSON(){return this.externalDoc.toJSON()}getVersionHelper(){var o,r;return(r=(o=this.externalDoc).getVersionHelper)==null?void 0:r.call(o)}getContainerBlocks(e){return this.externalDoc.getContainerBlocks(e)}getBlockData(e,o){return this.externalDoc.getBlockData(e,o)}localUpdateBlockText(e,o,r){d(so,this.editor.isWritable(),"editor is readonly");const i=this.getBlockData(e,o),s=i.text;d(so,s,`no text, ${e}, ${o}`);const l=l0(this.editor,i.id,r,!0),c=ne.apply(s,r);this.localEvents.forEach(u=>u.onBeforeUpdateBlockText(e,i.id,s,c,l.toDocRange()));const a=this.externalDoc.localUpdateBlockText(e,o,r);return this.editor.selection.setRange(l),a}localUpdateBlockData(e,o,r,i){d(so,this.editor.isWritable(),"editor is readonly");const s=Y.default(this.getBlockData(e,o)),l=Y.default(Ak(s,r));this.localEvents.forEach(a=>a.onBeforeUpdateBlockData(e,s.id,s,l,i));const c=this.externalDoc.localUpdateBlockData(e,o,r,i);return this.editor.selection.setRange(no(this.editor,i)),c}localInsertBlock(e,o,r,i){d(so,this.editor.isWritable(),"editor is readonly"),this.localEvents.forEach(l=>l.onBeforeInsertBlock(e,o,r,i));const s=this.externalDoc.localInsertBlock(e,o,r,i);return this.editor.selection.setRange(no(this.editor,i)),s}localDeleteBlock(e,o,r){d(so,this.editor.isWritable(),"editor is readonly");const i=Y.default(this.getBlockData(e,o));this.localEvents.forEach(l=>l.onBeforeDeleteBlock(e,o,i,r));const s=this.externalDoc.localDeleteBlock(e,o,r);return this.editor.selection.setRange(no(this.editor,r)),s}localDeleteChildContainers(e){return d(so,this.editor.isWritable(),"editor is readonly"),e.forEach(o=>{const r=Y.default(this.getContainerBlocks(o));this.localEvents.forEach(i=>i.onBeforeDeleteChildContainer(o,r))}),this.externalDoc.localDeleteChildContainers(e)}localInsertChildContainer(e,o){return d(so,this.editor.isWritable(),"editor is readonly"),this.localEvents.forEach(r=>r.onBeforeInsertChildContainer(e,Y.default(o))),this.externalDoc.localInsertChildContainer(e,o)}onRequestReload(e){so.debug(`reload doc: ${e}`),this.editor.reload(),this.callbacks.forEach(o=>{var r;return(r=o.onRequestReload)==null?void 0:r.call(o,e)})}onUpdateBlockText(e,o,r,i){this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockText)==null?void 0:l.call(s,e,o,r,i)}),Rk(this.editor,e,o,r,i),i&&this.editor.emit("docChanged",this.editor)}onUpdateBlockData(e,o,r,i){this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,e,o,r,i)}),s0(this.editor,e,o),i&&this.editor.emit("docChanged",this.editor)}onInsertBlock(e,o,r,i){this.callbacks.forEach(l=>{var c;return(c=l.onInsertBlock)==null?void 0:c.call(l,e,o,r,i)});const s=this.editor.getContainerById(e);lC(this.editor,s,o,r),i&&this.editor.emit("docChanged",this.editor)}onDeleteBlock(e,o,r){Ok(this.editor,e,o,r),this.callbacks.forEach(s=>{var l;return(l=s.onDeleteBlock)==null?void 0:l.call(s,e,o,r)});const i=this.editor.getContainerById(e);Tk(this.editor,i,o),r&&this.editor.emit("docChanged",this.editor)}onInsertChildContainer(e,o,r){this.callbacks.forEach(i=>{var s;return(s=i.onInsertChildContainer)==null?void 0:s.call(i,e,o,r)})}onDeleteChildContainer(e,o){this.callbacks.forEach(r=>{var i;return(i=r.onDeleteChildContainer)==null?void 0:i.call(r,e,o)})}onCustomMessage(e){this.callbacks.forEach(o=>{var r;return(r=o.onCustomMessage)==null?void 0:r.call(o,e)})}onStatusChanged(e){this.callbacks.forEach(o=>{var r;return(r=o.onStatusChanged)==null?void 0:r.call(o,e)})}onError(e){this.callbacks.forEach(o=>{var r;return(r=o.onError)==null?void 0:r.call(o,e)})}uploadResource(e,o){return this.externalDoc.uploadResource(e,o)}addResources(e){return this.externalDoc.addResources(e)}buildResourceUrl(e,o){return this.externalDoc.buildResourceUrl(e,o)}request(e,o){return this.externalDoc.request(e,o)}broadcastMessage(e){return this.externalDoc.broadcastMessage(e)}getUser(){return this.externalDoc.getUser()}getRemoteUsers(){return this.externalDoc.getRemoteUsers()}destroy(){this.externalDoc.destroy(),this.clearCallbacks()}getServerMeta(){var e,o,r;return(r=(o=(e=this.externalDoc).getServerMeta)==null?void 0:o.call(e))!=null?r:{}}}function a0(n,t){if(n.length===0){n.push(t);return}const e=n[n.length-1];if(!e.combinable(t)){n.push(t);return}e.combine(t)}const Bd=y("undo-action");class Mr{constructor(t,e,o){h(this,"beforeRange");h(this,"afterRange");this.containerId=e,this.beforeRange=t.selection.range.clone().toDocRange(),this.afterRange=o}undo(t){return!1}redo(t){return!1}combinable(t){return d(Bd,t,"no other action"),!1}combine(t){d(Bd,!1,"no other")}setAfterRange(t){this.afterRange&&Bd.warn("after range has already set"),this.afterRange=t}}const Nk=y("block-action");class d0 extends Mr{constructor(e,o,r,i,s){super(e,o,s);h(this,"blockData");h(this,"blockIndex");this.blockData=Y.default(i),this.blockIndex=r}deleteBlock(e,o){if(!e.getContainerById(this.containerId))return!1;const i=e.getBlockById(this.blockData.id);return i?(d(Nk,this.blockIndex===K(i),"invalid block index"),W1(e,i,no(e,o)),!0):!1}insertBlock(e,o){return Dr(e,this.containerId,this.blockIndex,Y.default(this.blockData),o),!0}}class Pk extends d0{undo(t){return this.deleteBlock(t,this.beforeRange)}redo(t){return this.insertBlock(t,this.afterRange)}}class $k extends d0{undo(t){return this.insertBlock(t,this.beforeRange)}redo(t){return this.deleteBlock(t,this.afterRange)}}class Hk extends Mr{constructor(e){super(e,V(e.rootContainer),e.selection.range.toDocRange());h(this,"actions",[])}addAction(e){a0(this.actions,e),this.afterRange=e.afterRange}undo(e){let o=!1;return this.actions.concat().reverse().forEach(r=>{r.undo(e)&&(o=!0)}),o}redo(e){let o=!1;return this.actions.forEach(r=>{r.redo(e)&&(o=!0)}),o}setAfterRange(e){this.afterRange=e;const o=this.actions[this.actions.length-1];!o||o instanceof Mr&&(o.afterRange||o.setAfterRange(e))}}const zo=y("update-block-data-action");class Ul extends Mr{constructor(e,o,r,i,s,l){super(e,o,l);h(this,"beforeBlockData");h(this,"afterBlockData");h(this,"blockId");this.blockId=r,d(zo,this.blockId===i.id,"invalid block id"),d(zo,this.blockId===s.id,"invalid block id"),this.beforeBlockData=Y.default(i),this.afterBlockData=Y.default(s),d(zo,this.beforeBlockData.type===this.afterBlockData.type,"invalid block type")}undo(e){d(zo,e,"no editor");const o=e.getBlockById(this.blockId);if(!o)return!1;const r=e.getContainerById(this.containerId);return d(zo,r,"no container"),Pl(e,o,Ul.toAttributes(this.beforeBlockData),this.beforeRange),!0}redo(e){d(zo,e,"no editor");const o=e.getBlockById(this.blockId);if(!o)return!1;const r=e.getContainerById(this.containerId);return d(zo,r,"no container"),Pl(e,o,Ul.toAttributes(this.afterBlockData),this.afterRange),!0}static toAttributes(e){const o=Y.default(e);return delete o.id,delete o.type,o}}const Ed=y("update-block-text-action");class zi extends Mr{constructor(e,o,r,i,s,l){super(e,o,l);h(this,"beforeRichTextData");h(this,"afterRichTextData");h(this,"blockId");h(this,"type");this.blockId=r,this.beforeRichTextData=Y.default(i),this.afterRichTextData=Y.default(s),this.type=zi.calType(i,s)}static calType(e,o){d(Ed,e,"no old data"),d(Ed,o,"no new data");const i=ne.diff(e,o),s=new Set;let l=!1;const c=u=>em(u)?`cjk_${u}`:Xf(u)?"number":tl(u)?"space":tm(u)?"letter":"unknown";let a=!1;return i.forEach(u=>{u.insert?u.insert===" "?s.add("insert_letter"):typeof u.insert=="string"&&u.insert.startsWith(" ")&&u.insert.length>1?(l=!0,a=!0,s.add(`insert_${c(u.insert.substr(1))}`)):s.add(`insert_${c(u.insert)}`):u.delete&&(l?l=!1:s.add("delete"))}),{textType:Array.from(s).join("|"),begin:a}}undo(e){if(!e.getContainerById(this.containerId))return!1;const r=e.getBlockById(this.blockId);return r?(Nl(e,r,this.beforeRichTextData),!0):!1}redo(e){if(!e.getContainerById(this.containerId))return!1;const r=e.getBlockById(this.blockId);return r?(Nl(e,r,this.afterRichTextData),!0):!1}combinable(e){if(!(e instanceof zi)||e.type.begin||this.type.textType!==e.type.textType||e.blockId!==this.blockId)return!1;const o=e.beforeRange,r=o.anchor;if(!r.isSimple())return!1;const i=this.afterRange;if(!i)return!1;const s=i.anchor;return!(!s.isSimple()||s.blockId!==o.anchor.blockId||s.offset!==r.offset)}combine(e){d(Ed,e instanceof zi,"invalid action type");const o=e;this.afterRichTextData=o.afterRichTextData,this.afterRange=e.afterRange}}class u0 extends Mr{constructor(t,e,o){super(t,e,t.selection.range.toDocRange()),this.blocks=o}deleteChildContainer(t){return t.doc.localDeleteChildContainers([this.containerId]),!0}insertChildContainer(t){return t.doc.localInsertChildContainer(this.containerId,Y.default(this.blocks)),!0}}class jk extends u0{undo(t){return this.deleteChildContainer(t)}redo(t){return this.insertChildContainer(t)}}class Fk extends u0{undo(t){return this.insertChildContainer(t)}redo(t){return this.deleteChildContainer(t)}}const Je=y("undo");class zk{constructor(t){h(this,"editor");h(this,"actions",[]);h(this,"undoCursor");h(this,"currentGroup",null);h(this,"groupCounter",0);h(this,"undoRedoing",!1);h(this,"handleSelectionChange",t=>{if(this.currentGroup){this.currentGroup.setAfterRange(t.selection.range.toDocRange());return}const e=this.actions[this.actions.length-1];!e||e.afterRange||e.setAfterRange(t.selection.range.toDocRange())});this.editor=t,this.undoCursor=-1,this.editor.addListener("selectionChanged",this.handleSelectionChange)}reset(){this.actions=[],this.undoCursor=-1}prepareSaveUndoState(){this.undoCursor!==-1&&(this.actions.splice(this.undoCursor),this.undoCursor=-1)}addAction(t){this.currentGroup?this.currentGroup.addAction(t):(a0(this.actions,t),setTimeout(()=>{this.editor.input.handleChanged(t)}))}beginGroup(){this.groupCounter===0?(d(Je,!this.currentGroup,"current group already exists"),this.currentGroup=new Hk(this.editor),this.groupCounter=1):(d(Je,this.currentGroup,"current group not exists"),this.groupCounter+=1)}endGroup(){d(Je,this.currentGroup,"current group not exists"),d(Je,this.groupCounter>0,"group counter === 0"),this.groupCounter-=1,this.groupCounter===0&&(this.currentGroup.actions.length===0?Je.warn("empty undo group, skip it"):(this.actions.push(this.currentGroup),this.editor.input.handleChanged(this.currentGroup)),this.currentGroup=null)}hasGroup(){return this.groupCounter>0}runInGroup(t){this.beginGroup();try{const e=t();return setTimeout(()=>this.editor.selection.caret.update()),e}catch(e){throw Je.error(`failed to run action: ${e.message}`),e}finally{this.endGroup()}}undo(){this.undoCursor===-1&&(this.undoCursor=this.actions.length);try{for(this.undoRedoing=!0;this.undoCursor>0;){this.undoCursor-=1;const t=this.actions[this.undoCursor];if(t.undo(this.editor)){try{this.editor.selection.setRange(no(this.editor,t.beforeRange))}catch(e){Je.error(`undo: failed to restore caret pos: ${e.message}`)}return this.editor.input.handleChanged(t),!0}}return!1}finally{this.undoRedoing=!1}}redo(){this.undoCursor===-1&&(this.undoCursor=this.actions.length);try{for(this.undoRedoing=!0;this.undoCursor<this.actions.length;){const t=this.actions[this.undoCursor];if(this.undoCursor+=1,t.redo(this.editor)){try{const e=t.afterRange;e?this.editor.selection.setRange(no(this.editor,e)):Je.warn("no after range")}catch(e){Je.error(`redo: failed to set caret pos after redo: ${e.message}`)}return this.editor.input.handleChanged(t),!0}}return!1}finally{this.undoRedoing=!1}}canUndo(){return!(this.actions.length===0||this.undoCursor===0)}canRedo(){return!(this.actions.length===0||this.undoCursor===-1||this.undoCursor===this.actions.length)}lastAction(){var e;const t=this.undoCursor===-1?this.actions.length-1:this.undoCursor-1;return(e=this.actions[t])!=null?e:null}undoTo(t){for(;;){const e=this.lastAction();if(!e||e===t)return!0;if(!this.undo())return!1}}onBeforeUpdateBlockText(t,e,o,r,i){this.undoRedoing||(this.prepareSaveUndoState(),ne.diff(o,r).length!==0&&this.addAction(new zi(this.editor,t,e,o,r,i)))}onBeforeUpdateBlockData(t,e,o,r,i){if(this.undoRedoing)return;this.prepareSaveUndoState();const s=new Ul(this.editor,t,e,o,r,i);this.addAction(s)}onBeforeInsertBlock(t,e,o,r){this.undoRedoing||(this.prepareSaveUndoState(),d(Je,e>=0,"invalid block index"),d(Je,o,"no block data"),this.addAction(new Pk(this.editor,t,e,o,r)))}onBeforeDeleteBlock(t,e,o,r){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new $k(this.editor,t,e,o,r)))}onBeforeInsertChildContainer(t,e){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new jk(this.editor,t,e)))}onBeforeDeleteChildContainer(t,e){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new Fk(this.editor,t,e)))}}class Vk{async fromData(t,e){const o=e.getData("text/x-ones-editor-doc");if(o)return{"text/x-ones-editor-doc":JSON.parse(o)}}}class Uk{constructor(){h(this,"converters",[]);this.addConverter(new Vk)}async fromData(t,e){let o={};for(const r of this.converters){const i=await r.fromData(t,e);i&&(o={...o,...i})}return o}addConverter(t){this.converters.push(t)}}class qk{constructor(t){h(this,"renders",[]);this.editor=t}registerRender(t){this.renders.push(t)}renderText(t,e){const o={classes:[],attributes:{},styles:{}};return this.renders.forEach(r=>{if(r.renderText){const i=r.renderText(this.editor,t,e);i.classes&&o.classes.push(...i.classes),i.attributes&&(o.attributes={...o.attributes,...i.attributes}),i.styles&&(o.styles={...o.styles,...i.styles})}}),o}renderBlock(t,e,o){const r={classes:[],attributes:{},styles:{}};return this.renders.forEach(i=>{if(i.renderBlock){const s=i.renderBlock(this.editor,e,o);s.classes&&r.classes.push(...s.classes),s.attributes&&(r.attributes={...r.attributes,...s.attributes}),s.styles&&(r.styles={...r.styles,...s.styles})}}),r}updateBlock(t,e,o,r){this.renders.forEach(i=>{var s;(s=i.updateBlock)==null||s.call(i,t,e,o,r)})}}class _t extends Wt.TypedEmitter{constructor(e){super();h(this,"hoveringBlock",null);h(this,"hoveringTextChild",null);h(this,"filters",[]);h(this,"finders",[]);h(this,"handleDocumentMouseMove",e=>{if(this.hoveringBlock){for(const s of this.filters)if(s.isInBlock(this.hoveringBlock,e))return}const o=document.elementFromPoint(e.x,e.y);if(!o){this.setHoveringBlock(null,e,null);return}let r=z(o);if((!r||!vt(this.editor.rootContainer,r))&&(r=this.findBlockByFinders(e),!r)){this.setHoveringBlock(null,e,null);return}const i=this.getParentTextContentChild(r,o);this.setHoveringBlock(r,e,i)});this.editor=e,document.addEventListener("mousemove",this.handleDocumentMouseMove)}destroy(){document.removeEventListener("mousemove",this.handleDocumentMouseMove),this.filters.forEach(e=>e.destroy()),this.filters=[],this.finders.forEach(e=>e.destroy()),this.finders=[]}addFilter(e){this.filters.push(e)}addFinder(e){this.finders.push(e)}hoveringBlockId(){return this.hoveringBlock?G(this.hoveringBlock):""}findBlockByFinders(e){for(let o=0;o<this.finders.length;o++){const i=this.finders[o].findTargetBlock(this.editor,e);if(i)return i}return null}setHoveringBlock(e,o,r){if(this.hoveringBlock===e&&this.hoveringTextChild===r)return;if(this.hoveringBlock!==e){const s=this.hoveringBlock&&vt(this.editor.rootContainer,this.hoveringBlock)?this.hoveringBlock:null;s&&F(s,"hover"),e&&M(e,"hover"),this.hoveringBlock=e,this.emit("change",this.hoveringBlock,s,o)}const i=this.hoveringTextChild;this.hoveringTextChild=r,this.emit("childChange",this.hoveringBlock,r,i,o)}static get(e){return e.addCustom("standard-hovering-block",()=>new _t(e))}getParentTextContentChild(e,o){if(!j(this.editor,e))return null;const r=rt(e);return o.parentElement===r?o:l1(o)}}const h0="style-color-",f0="style-bg-color-";class Wk{renderText(t,e,o){const r=[],i={};return Object.entries(o).forEach(([s,l])=>{l===!0?s.startsWith(h0)?i["data-style-color"]=s.substring(h0.length):s.startsWith(f0)?i["data-style-bg-color"]=s.substring(f0.length):s.startsWith("style")&&r.push(s):typeof l=="string"&&s==="link"&&(r.push("link"),i.link=l)}),{classes:r,attributes:i}}renderBlock(t,e,o){var l,c;const r={};Object.entries(o).filter(a=>a[0].startsWith("style-")).forEach(([a,u])=>{r[`data-${a}`]=`${u}`});const s=[];return((c=(l=t.selection)==null?void 0:l.range)==null?void 0:c.start.blockId)===o.id&&s.push("focused"),typeof o.align=="string"&&o.align&&(r["data-style-align"]=o.align),o.heading&&(r["data-style-heading"]=String(o.heading)),o.quoted&&(r["data-style-quoted"]="true"),_t.get(t).hoveringBlockId()===o.id&&s.push("hover"),{attributes:r,classes:s}}updateBlock(t,e,o,r){var s,l;Array.from(o.attributes).forEach(c=>{c.name.startsWith("data-style-")&&o.removeAttribute(c.name)}),Object.entries(r).filter(c=>c[0].startsWith("style-")).forEach(([c,a])=>{o.setAttribute(`data-${c}`,`${a}`)}),((l=(s=t.selection)==null?void 0:s.range)==null?void 0:l.start.blockId)===r.id&&M(o,"focused"),_t.get(t).hoveringBlockId()===r.id&&M(o,"hover")}}function Gk(n){n.editorBlocks.registerBlockClass(_i),n.editorBlocks.registerBlockClass(lg),n.editorBoxes.registerBoxClass(Gg),n.editorBoxes.registerBoxClass(Zg),n.editorInsertions.registerInsertionClass(Kg),n.editorBlockRenders.registerRender(new Wk)}function Zk(n,t){Gk(n),t!=null&&t.blocks&&t.blocks.forEach(e=>n.editorBlocks.registerBlockClass(e)),t!=null&&t.boxes&&t.boxes.forEach(e=>n.editorBoxes.registerBoxClass(e)),t!=null&&t.embeds&&t.embeds.forEach(e=>n.editorEmbeds.registerEmbedClass(e)),t!=null&&t.insertions&&t.insertions.forEach(e=>n.editorInsertions.registerInsertionClass(e)),t!=null&&t.decorators&&t.decorators.forEach(e=>n.editorDecorators.registerDecorator(e)),t!=null&&t.dataConverters&&t.dataConverters.forEach(e=>n.dataConverter.addConverter(e)),t!=null&&t.commandProviders&&t.commandProviders.forEach(e=>n.editorCommandProviders.registerCommandProvider(e)),t!=null&&t.textRenders&&t.textRenders.forEach(e=>n.editorBlockRenders.registerRender(e))}const m0=y("range-commands");function g0(n,t){n.forEach(e=>{e.source=t,e.children&&g0(e.children,t)})}function p0(n,t,e){const o=G(t);d(m0,o===e.start.blockId,"invalid start range"),d(m0,o===e.end.blockId,"invalid end range");const r=n.editorCommandProviders.getCommandProviders();let i=[];return r.forEach(s=>{const l=s.getAvailableCommands(n,t,e);g0(l,s.id),i.push(...l)}),r.forEach(s=>{if(s.filterCommands){const l=s.filterCommands(n,t,e,i);l&&(i=l)}}),ct(n,t)&&yr(n,t,e.start,e.end).forEach(l=>{Rt(l).forEach(a=>{const u=Z(n,a),f=Ut(n,{anchor:$(a,0,"home"),focus:$(a,u,"end")}),m=p0(n,a,f);i.push(...m)})}),i}function C0(n){const t=n.getEditor(),e=n.getSelectedBlocks(),o=[];return e.forEach(r=>{const i=Ut(t,{anchor:r.start,focus:r.end});p0(t,r.block,i).forEach(l=>{o.push(l)})}),o}function b0(n,t,e,o,r,i){var u;const s=n.editorCommandProviders.getCommandProviders();for(let f=0;f<s.length;f++){const m=s[f];if(m.beforeExecuteCommand&&m.beforeExecuteCommand(n,t,e,o,r))return!1}const l=n.editorCommandProviders.getCommandProvider(o.source),c={};if((u=l.executeCommand)!=null&&u.call(l,n,t,e,o,r,{}))return i[G(t)]=c,!0;let a=!1;return ct(n,t)&&yr(n,t,e.start,e.end).forEach(m=>{Rt(m).forEach(v=>{const w=Z(n,v),E=Ut(n,{anchor:$(v,0,"home"),focus:$(v,w,"end")});b0(n,v,E,o,r,i)&&(a=!0)})}),s.forEach(f=>{f.afterExecuteCommand&&f.afterExecuteCommand(n,t,e,o,r,i)}),a}function v0(n,t,e){const o=n.getEditor(),r={},i=o.editorCommandProviders.getCommandProvider(t.source);return i.executeRangeCommand&&i.executeRangeCommand(o,n,t,e,r)||n.getSelectedBlocks().forEach(l=>{const c=Ut(o,{anchor:l.start,focus:l.end});b0(o,l.block,c,t,e,r)}),r}const Yk=y("command-providers");class k0{constructor(t){h(this,"providers",[]);this.editor=t}registerCommandProvider(t){this.providers.push(t)}getCommandProviders(){return this.providers}getCommandProvider(t){const e=this.providers.find(o=>o.id===t);return d(Yk,e,`no command provider, id=${t}`),e}getCommands(t){return C0(t)}executeCommand(t,e,o){return this.editor.undoManager.runInGroup(()=>v0(t,e,o))}getEmptyBlockTextAttributes(t,e){let o={};if(this.providers.forEach(r=>{var s;const i=(s=r.getEmptyBlockTextAttributes)==null?void 0:s.call(r,t,e);i&&(o={...o,...i})}),Object.keys(o).length!==0)return o}}function Qk(n,t){const e=H(t),o=V(e),r=K(t);s0(n,o,r)}const Kk=y("table-scroll");class y0{constructor(t,e,o,r,i){h(this,"handleEvent",t=>{this.handler(this.editor,t,this.data)});this.editor=t,this.dom=e,this.name=o,this.handler=r,this.data=i,e.addEventListener(o,this.handleEvent)}destroy(){this.dom.removeEventListener(this.name,this.handleEvent)}}class Jk{constructor(t){h(this,"handlers",new Map);this.editor=t}destroy(){Array.from(this.handlers.entries()).forEach(([t,e])=>{e.forEach(o=>o.destroy()),this.handlers.delete(t)})}addEventListener(t,e,o,r){const i=this.handlers.get(t);if(i){if(i.find(s=>s.handler===o&&s.name===e)){Kk.warn(`event has already registered: ${e}`);return}i.push(new y0(this.editor,t,e,o,r))}else{const s=new y0(this.editor,t,e,o,r);this.handlers.set(t,[s])}}removeEventListener(t,e,o){if(!t){for(const[i,s]of Array.from(this.handlers.entries()))for(let l=s.length-1;l>=0;l--){const c=s[l];if(e)e===c.name&&o===c.handler&&s.splice(l,1);else if(o===c.handler){s.splice(l,1),c.destroy(),s.length===0&&this.handlers.delete(i);continue}}return}const r=this.handlers.get(t);if(r){const i=r.findIndex(s=>s.handler===o&&s.name===e);if(i!==-1){const s=r[i];r.splice(i,1),s.destroy(),r.length===0&&this.handlers.delete(t)}}}removeAllListeners(t,e){const o=this.handlers.get(t);if(o)if(e)for(let r=0;r<o.length;r++){const i=o[r];i.name===e&&(o.splice(r,1),i.destroy())}else o.forEach(r=>{r.destroy()}),this.handlers.delete(t)}}const w0=y("update-block-text");function Xk(n,t){const e=n.getBoxById(t.id),o=z(e);d(w0,o,"no parent block"),d(w0,j(n,o),"not a text block");const r=n.getBlockText(o),i=$g(r,"id",t.id,t);b2(n,o,i)}function ty(n,t){for(const e of n.blockHooks)if(e.writable){const o=e.writable(n,t);if(typeof o=="boolean")return o}return!0}function ey(n){return n.readonly?!1:!Qe(n).find(o=>!n.isBlockWritable(o.block))}class ny{constructor(t){this.editor=t}getKey(t){return`${this.editor.id}-${t}`}async getItem(t){return window.localStorage.getItem(this.getKey(t))}async setItem(t,e){if(!e){this.removeItem(t);return}window.localStorage.setItem(this.getKey(t),e)}async removeItem(t){window.localStorage.removeItem(this.getKey(t))}}class oy{constructor(){h(this,"shortcuts",[])}handleKeyboardEvents(t,e){const o=this.shortcuts;for(const r of o){const i=Object.entries(r);for(const[s,l]of i)if(_n(e,s)){const c=l(t,e);if(c!==void 0)return c}}}}const Fn=y("editor");class ry extends Wt.TypedEmitter{constructor(e,o,r){var i,s,l,c,a,u,f;super();h(this,"parent");h(this,"rootElement");h(this,"contentElement");h(this,"rootContainerObject");h(this,"rootContainer");h(this,"input");h(this,"selection");h(this,"selectionHandler");h(this,"doc");h(this,"id");h(this,"clientId");h(this,"compositingText","");h(this,"undoManager");h(this,"shortcuts",new oy);h(this,"dataConverter",new Uk);h(this,"editorBlocks",new og(this));h(this,"editorBoxes",new Qg(this));h(this,"editorInsertions",new Xg(this));h(this,"editorEmbeds",new ig(this));h(this,"editorDecorators",new t2(this));h(this,"editorCommandProviders",new k0(this));h(this,"editorBlockRenders",new qk(this));h(this,"blockHooks",[]);h(this,"domEvents",new Jk(this));h(this,"customs",new Map);h(this,"options");h(this,"inputHandlers",new Sk(this));h(this,"settingsProvider");h(this,"_readonly",!1);Fn.debug("create editor"),this.setMaxListeners(100),this.options={colors:(i=r==null?void 0:r.colors)!=null?i:["#9923E9","#4587C2","#8BDB7A","#FB28D3","#CBC619","#10FEEB","#812A1A","#8A3F25","#22D742","#A53E74","#555C87","#57E0AA"],componentsOptions:(l=(s=r==null?void 0:r.components)==null?void 0:s.options)!=null?l:{},scrollContainer:r==null?void 0:r.scrollContainer},this.settingsProvider=(c=r==null?void 0:r.settingsProvider)!=null?c:new ny(this),Zk(this,r==null?void 0:r.components),this.blockHooks.push(...(u=(a=r==null?void 0:r.components)==null?void 0:a.blockHooks)!=null?u:[]),this.id=(f=r==null?void 0:r.id)!=null?f:N(),this.clientId=N(),this.undoManager=new zk(this),this.doc=new _k(this,o,this.undoManager),this.parent=e,this.rootElement=b("div",["editor-root"],this.parent),this.rootElement.setAttribute("data-editor-client-id",this.clientId),this.contentElement=b("div",["editor-content"],this.rootElement),this.rootContainerObject=zm(this),this.rootContainer=this.rootContainerObject.rootContainer,this.input=new rv(this,this.inputHandlers),this.selection=new gv(this),this.selectionHandler=new yv(this),r!=null&&r.shortcuts&&this.shortcuts.shortcuts.push(...r.shortcuts),It.isMobile&&M(this.rootElement,"mobile"),It.isSafari&&M(this.rootElement,"safari"),this._readonly&&M(this.rootElement,"readonly"),this.emit("load",this,!1)}get readonly(){return this._readonly}set readonly(e){this._readonly=e,e?M(this.rootElement,"readonly"):F(this.rootElement,"readonly"),this.emit("readonlyChanged",this)}get scrollContainer(){return this.options.scrollContainer?this.options.scrollContainer:Nn(this.rootContainer)}addCustom(e,o){const r=this.customs.get(e);if(r)return r;const i=o(this);return this.customs.set(e,i),i}getCustom(e){const o=this.customs.get(e);return d(Fn,o,`${e} does not exists`),o}replaceCustom(e,o){const r=this.customs.get(e);return r&&r.destroy(),this.customs.set(e,o),o}findCustom(e){return this.customs.get(e)}findCustomByType(e){const o=this.customs.values();for(const r of o)if(r instanceof e)return r;return null}destroyCustom(e){const o=this.customs.get(e);o&&(this.customs.delete(e),o.destroy())}getComponentOptions(e){return this.options.componentsOptions[e]}registerLocalEvents(e){this.doc.registerLocalEvents(e)}reload(){this.rootContainerObject.reload(),this.emit("load",this,!0)}createBlock(e,o,r){return this.editorBlocks.createBlock(e,o,r)}createBox(e,o){return this.editorBoxes.createBox(e,o)}createInsertion(e,o){return this.editorInsertions.createInsertion(e,o)}destroy(){Fn.debug("destroy editor"),this.emit("destroy",this),this.input.destroy(),this.rootContainerObject.destroy(),this.rootElement.remove(),this.doc.destroy(),this.customs.forEach(e=>e.destroy()),this.customs.clear(),this.selection.destroy(),this.domEvents.destroy(),this.removeAllListeners(),this.inputHandlers.destroy()}focus(){this.input.focus()}focusToBlock(e,o){Q1(this,e,o)}isWritable(){return ey(this)}isBlockWritable(e){return ty(this,e)}getChildContainerData(e){const o=this.doc.getContainerBlocks(e);return d(Fn,o,`no child container data: ${e}, ${JSON.stringify(this.doc)}`),d(Fn,Array.isArray(o),`container data is not an array: ${JSON.stringify(o)}`),o}createChildContainer(e,o,r){return Vm(this,e,o,r)}getFirstBlock(){return this.rootContainer.querySelector("[data-type=editor-block]")}getLastBlock(){const e=Array.from(this.rootContainer.querySelectorAll(":scope [data-type=editor-block]"));return e[e.length-1]}getFocusedBlock(){return this.selection.getFocusedBlock()}findBlockById(e){const o=this.rootContainer.querySelector(`#${e}`);return o&&d(Fn,gr(o),"not an valid block element"),o!=null?o:null}findBoxById(e){const o=this.rootContainer.querySelector(`#${e}`);return o&&d(Fn,s1(o),"not an valid box element"),o!=null?o:null}getBlockById(e){const o=this.findBlockById(e);return d(Fn,o,`no block, id=${e}`),o}getBoxById(e){const o=this.findBoxById(e);return d(Fn,o,`no box, id=${e}`),o}getBlockByIndex(e,o){const r=this.getContainerById(e);return mr(r,o)}getBlockIndex(e){if(typeof e=="string"){const o=this.getBlockById(e);return K(o)}return K(e)}getContainerById(e){return br(this,e)}getParentContainer(e){return H(e)}reloadBlock(e){Qk(this,e)}contains(e){const o=e instanceof Element?e:e.parentElement;return o?o.closest("div.editor-root")===this.rootElement:!1}insertBlock(e,o,r,i){const s={blockId:r.id,offset:0},l={anchor:s,focus:s};return Dr(this,e,o,r,i!=null?i:l)}insertEmbed(e,o,r,i,s){const l={id:N(),type:"embed",embedType:r,embedData:i};return this.insertBlock(e,o,l,s)}deleteBlock(e,o){G1(this,e,o)}mergeTextBlock(e,o){return g2(this,e,o)}breakTextBlock(e,o,r){return Pi(this,e,o,r).newBlock}getTextPosition(){return Tr(this)}getBlockString(e,o){const r=this.getBlockText(e);return Tt(r,o)}getBlockData(e){return ro(this,e)}getBoxData(e){return r2(this,e)}getBlockText(e){return ke(this,e)}setBlockText(e,o){b2(this,e,o)}deleteTextFromBlock(e,o,r){return U1(this,e,o,r)}insertTextToBlock(e,o,r){return s2(this,e,o,r)}insertBoxToBlock(e,o,r){return l2(this,e,o,r)}pasteDoc(e){return this.inputHandlers.pasteDoc(e)}insertDoc(e,o,r,i){y2(this,e,o,r,i)}insertDocAt(e,o,r,i){return X1(this,e,o,r,i)}deleteChildContainers(e){m2(this,e)}replaceBlockText(e,o){return Nl(this,e,o)}updateBlockData(e,o,r){const i={...this.getBlockData(e),...o},{id:s,type:l,...c}=i;return Pl(this,e,c,(r!=null?r:this.selection.range).toDocRange())}updateEmbedData(e,o,r){return v2(this,e,o,r)}updateBoxData(e){Xk(this,e)}getSelectedText(){const e=jl(this);return id(this,e)}clearSelectedContents(){Y1(this)}insertTextBlock(e,o,r,i){const s=jn(e!=null?e:"");return u2(this,s,o,r,i==null?void 0:i.newRange)}updateCompositionText(e,o){if(e&&!o&&(this.selection.range.isCollapsed()||this.clearSelectedContents()),!e&&!o){a2(this);return}o?(this.compositingText="",Qa()||V1(this,e)):(this.compositingText=e,c2(this))}getColor(e){const o=this.options.colors;return o.length===0?"#FF1A75":o[e%o.length]}}function Vi(n,t,e){return new ry(n,t,e)}function iy(n){const t=(o,r)=>{const i=o.findIndex(l=>l.id===r.id);if(i===-1){o.push(r);return}const s=o[i];if(s.value!==r.value){o.splice(i,1);return}if(!!s.states){if(!r.states){s.states=[];return}s.states=Fa.default(s.states,r.states)}},e=[];return n.forEach(o=>{o.forEach(r=>{t(e,r)})}),e}const sy=["#FBBFBD","#FFDDB6","#FFF897","#C5F0C1","#CEDDFE","#DCC9FC","#E5E6E8","#F76964","#FFA53D","#FFE928","#63D156","#A0BBFE","#C4A5FB","#BBBFC3"];class ql extends Wt.TypedEmitter{constructor(e){super();h(this,"users",new Map);h(this,"cursors",new Map);h(this,"addingUser",!1);h(this,"colors");this.colors=e&&e.length>0?e:sy}setCursor(e){this.addUser(e.user);const o=this.cursors.get(e.user.userId);if(o&&Zs.default(o,e))return;this.cursors.set(e.user.userId,e);const r=new Set([e.range.anchor.blockId,e.range.focus.blockId]),i=new Set(r);o&&new Set([o.range.anchor.blockId,o.range.focus.blockId]).forEach(l=>{r.has(l)||i.add(l)}),this.emit("remote-carets-change",[...i])}addUsers(e){this.addingUser=!0,e.forEach(o=>this.addUser(o)),this.addingUser=!1,this.emit("change",Array.from(this.users.values()))}addUser(e){this.users.set(e.userId,e),this.addingUser||this.emit("change",Array.from(this.users.values()))}findUser(e){var o;return(o=this.users.get(e))!=null?o:null}removeUser(e){this.users.delete(e),this.cursors.delete(e),this.emit("change",Array.from(this.users.values()))}updateUsers(e){this.users.clear(),this.addingUser=!0;try{e.forEach(o=>{this.addUser(o)})}finally{this.addingUser=!1}setTimeout(()=>{this.emit("change",Array.from(this.users.values()))},300)}getSimpleCursors(e){const o=new Map;return Array.from(this.cursors.values()).filter(r=>r.range.anchor.blockId===e&&Sl(r.range)&&zg(r.range)).forEach(r=>{const i=r.range.anchor.offset;let s=o.get(i);s||(s=[],o.set(i,s)),s.push(r)}),o}getCursors(e){return Array.from(this.cursors.values()).filter(o=>o.range.anchor.blockId===e||o.range.focus.blockId===e)}onUpdateBlockText(e,o,r){if(!e.text)return;this.getCursors(e.id).forEach(l=>{if(Sl(l.range)){const{anchor:c,focus:a}=l.range;c.blockId===e.id&&(c.offset=ne.transformCursor(c.offset,o,r)),a.blockId===e.id&&(a.offset=ne.transformCursor(a.offset,o,r))}})}getFixedUserColor(e,o){let r=0;Array.from(e).forEach(s=>{r+=s.charCodeAt(0)});const i=r%this.colors.length;return this.colors[i]}destroy(){this.removeAllListeners()}}const Jt=y("local-doc");class Id extends ki{constructor(e){super();h(this,"doc");e?this.doc=e:this.doc={meta:{},comments:{},blocks:{root:[jn("")]}}}beginBatchUpdate(){return 0}endBatchUpdate(){return 0}toJSON(){return Y.default(this.doc)}getContainerBlocks(e){return this.doc.blocks[e]}getBlockData(e,o){const r=this.getContainerBlocks(e);d(Jt,r,`no container data: ${e}`);const i=r[o];return d(Jt,i,`no block data: ${o}`),i}localUpdateBlockText(e,o,r){const i=this.getBlockData(e,o);d(Jt,i.text,"no text for data");const s=ne.apply(i.text,r);return i.text=s,d(Jt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(l=>{var c;return(c=l.onUpdateBlockText)==null?void 0:c.call(l,e,o,r,!0)}),s}localUpdateBlockData(e,o,r){const i=this.getBlockData(e,o);return r.delete.forEach(s=>delete i[s]),Object.entries(r.insert).forEach(([s,l])=>{i[s]=l}),d(Jt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,e,o,r,!0)}),i}localInsertBlock(e,o,r){const i=this.getContainerBlocks(e);return d(Jt,i,`no container data: ${e}`),d(Jt,o>=0&&o<=i.length,`invalid block index: ${o}, ${i.length}`),i.splice(o,0,r),d(Jt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onInsertBlock)==null?void 0:l.call(s,e,o,r,!0)}),r}localDeleteBlock(e,o){const r=this.getContainerBlocks(e);d(Jt,r,`no container data: ${e}`),d(Jt,o>=0&&o<=r.length,`invalid block index: ${o}, ${r.length}`);const i=r[o];return r.splice(o,1),d(Jt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onDeleteBlock)==null?void 0:l.call(s,e,o,!0)}),i}localInsertChildContainer(e,o){this.doc.blocks[e]=o,d(Jt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onInsertChildContainer)==null?void 0:i.call(r,e,o,!0)})}localDeleteChildContainers(e){Jt.debug(`delete child containers: ${e}`),e.forEach(o=>{d(Jt,this.doc.blocks[o],`no child container: ${o}`),delete this.doc.blocks[o]}),e.forEach(o=>{d(Jt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onDeleteChildContainer)==null?void 0:i.call(r,o,!0)})})}uploadResource(e,o){d(Jt,!1,"not implemented")}async addResources(e){return e}buildResourceUrl(e){return e}request(e,o){d(Jt,!1,"not implemented")}broadcastMessage(e){}getUser(){return{permission:"w",userId:"-",displayName:"-",avatarUrl:"-",rainbowIndex:0}}getRemoteUsers(){return new ql}setDoc(e){this.doc=Y.default(e),this.callbacks.forEach(o=>{var r;return(r=o.onRequestReload)==null?void 0:r.call(o,"change doc")})}destroy(){this.clearCallbacks()}}function Vo(n){return Ct(H(n))}class ly{constructor(t){this.cleanup=t}destroy(){var t;(t=this.cleanup)==null||t.call(this)}}function xd(n,t,e){n.addCustom(t,()=>{var i;const o=(i=e())!=null?i:void 0;return new ly(o)})}const B0=y("remote-cursor");class cy{constructor(){h(this,"remoteUsers",new ql)}onCustomMessage(t){const e=t;if(e.type==="onlineUsers"){const o=e;this.handleUpdateUsers(o.users)}else e.type==="caret"?(B0.debug(`remote caret received: ${e}`),this.handleUpdateCaret(e)):B0.debug(`unknown remote message received: ${t}`)}handleUpdateUsers(t){this.remoteUsers.updateUsers(t)}handleUpdateCaret(t){const e=this.remoteUsers.findUser(t.userId);!e||this.remoteUsers.setCursor({oneseditor:"cursor",user:e,range:t.range,time:Date.now()})}destroy(){this.remoteUsers.destroy()}}function ay(n){const{blocks:t,meta:e,comments:o,...r}=n;return{rootBlocks:t,meta:e,comments:o,childBlocks:r}}function Ui(n){const{childBlocks:t,meta:e,comments:o,rootBlocks:r}=ay(Y.default(n));return{blocks:{root:r,...t},meta:e,comments:o}}function lo(n){return n==="root"?"blocks":n}function Rr(n){return n==="blocks"?"root":n}const dy={type:{name:"rich-text",uri:"http://sharejs.org/types/rich-text/v1",create(n){return new ee.default(n)},apply(n,t){const e=new ee.default(n),o=new ee.default(t);return e.compose(o).ops},compose(n,t){const e=new ee.default(n),o=new ee.default(t);return e.compose(o).ops},diff(n,t){const e=new ee.default(n),o=new ee.default(t);return e.diff(o).ops},transform(n,t,e){const o=new ee.default(n);return new ee.default(t).transform(o,e==="left").ops},transformCursor(n,t,e){return t.transformPosition(n,!e)},normalize(n){return n},serialize(n){return n.ops},deserialize(n){return n},transformPresence(n,t,e){if(!n)return null;const o=new ee.default(t),r=this.transformCursor(n.index,o,e),i=this.transformCursor(n.index+n.length,o,e);return{...n,index:r,length:i-r}}}};var qi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},co={},Sd=Af.default.EventEmitter;co.EventEmitter=Sd,co.mixin=uy;function uy(n){for(var t in Sd.prototype)n.prototype[t]=Sd.prototype[t]}var E0=["info","warn","error"];function I0(){var n={};E0.forEach(function(t){n[t]=console[t].bind(console)}),this.setMethods(n)}var hy=I0;I0.prototype.setMethods=function(n){n=n||{};var t=this;E0.forEach(function(e){typeof n[e]=="function"&&(t[e]=n[e])})};var fy=hy,my=new fy,x0=my;function Uo(n,t){this.code=n,this.message=t||"",Error.captureStackTrace?Error.captureStackTrace(this,Uo):this.stack=new Error().stack}Uo.prototype=Object.create(Error.prototype),Uo.prototype.constructor=Uo,Uo.prototype.name="ShareDBError",Uo.CODES={ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT:"ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT",ERR_APPLY_SNAPSHOT_NOT_PROVIDED:"ERR_APPLY_SNAPSHOT_NOT_PROVIDED",ERR_CLIENT_ID_BADLY_FORMED:"ERR_CLIENT_ID_BADLY_FORMED",ERR_CANNOT_PING_OFFLINE:"ERR_CANNOT_PING_OFFLINE",ERR_CONNECTION_SEQ_INTEGER_OVERFLOW:"ERR_CONNECTION_SEQ_INTEGER_OVERFLOW",ERR_CONNECTION_STATE_TRANSITION_INVALID:"ERR_CONNECTION_STATE_TRANSITION_INVALID",ERR_DATABASE_ADAPTER_NOT_FOUND:"ERR_DATABASE_ADAPTER_NOT_FOUND",ERR_DATABASE_DOES_NOT_SUPPORT_SUBSCRIBE:"ERR_DATABASE_DOES_NOT_SUPPORT_SUBSCRIBE",ERR_DATABASE_METHOD_NOT_IMPLEMENTED:"ERR_DATABASE_METHOD_NOT_IMPLEMENTED",ERR_DEFAULT_TYPE_MISMATCH:"ERR_DEFAULT_TYPE_MISMATCH",ERR_DOC_MISSING_VERSION:"ERR_DOC_MISSING_VERSION",ERR_DOC_ALREADY_CREATED:"ERR_DOC_ALREADY_CREATED",ERR_DOC_DOES_NOT_EXIST:"ERR_DOC_DOES_NOT_EXIST",ERR_DOC_TYPE_NOT_RECOGNIZED:"ERR_DOC_TYPE_NOT_RECOGNIZED",ERR_DOC_WAS_DELETED:"ERR_DOC_WAS_DELETED",ERR_INFLIGHT_OP_MISSING:"ERR_INFLIGHT_OP_MISSING",ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION:"ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION",ERR_MAX_SUBMIT_RETRIES_EXCEEDED:"ERR_MAX_SUBMIT_RETRIES_EXCEEDED",ERR_MESSAGE_BADLY_FORMED:"ERR_MESSAGE_BADLY_FORMED",ERR_MILESTONE_ARGUMENT_INVALID:"ERR_MILESTONE_ARGUMENT_INVALID",ERR_OP_ALREADY_SUBMITTED:"ERR_OP_ALREADY_SUBMITTED",ERR_OP_NOT_ALLOWED_IN_PROJECTION:"ERR_OP_NOT_ALLOWED_IN_PROJECTION",ERR_OP_SUBMIT_REJECTED:"ERR_OP_SUBMIT_REJECTED",ERR_OP_VERSION_MISMATCH_AFTER_TRANSFORM:"ERR_OP_VERSION_MISMATCH_AFTER_TRANSFORM",ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM:"ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM",ERR_OP_VERSION_NEWER_THAN_CURRENT_SNAPSHOT:"ERR_OP_VERSION_NEWER_THAN_CURRENT_SNAPSHOT",ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED:"ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED",ERR_OT_OP_BADLY_FORMED:"ERR_OT_OP_BADLY_FORMED",ERR_OT_OP_NOT_APPLIED:"ERR_OT_OP_NOT_APPLIED",ERR_OT_OP_NOT_PROVIDED:"ERR_OT_OP_NOT_PROVIDED",ERR_PRESENCE_TRANSFORM_FAILED:"ERR_PRESENCE_TRANSFORM_FAILED",ERR_PROTOCOL_VERSION_NOT_SUPPORTED:"ERR_PROTOCOL_VERSION_NOT_SUPPORTED",ERR_QUERY_EMITTER_LISTENER_NOT_ASSIGNED:"ERR_QUERY_EMITTER_LISTENER_NOT_ASSIGNED",ERR_SNAPSHOT_READ_SILENT_REJECTION:"ERR_SNAPSHOT_READ_SILENT_REJECTION",ERR_SNAPSHOT_READS_REJECTED:"ERR_SNAPSHOT_READS_REJECTED",ERR_SUBMIT_TRANSFORM_OPS_NOT_FOUND:"ERR_SUBMIT_TRANSFORM_OPS_NOT_FOUND",ERR_TYPE_CANNOT_BE_PROJECTED:"ERR_TYPE_CANNOT_BE_PROJECTED",ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE:"ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE",ERR_UNKNOWN_ERROR:"ERR_UNKNOWN_ERROR"};var Wl=Uo,Wi={},S0=gy;function gy(n,t,e,o){var r=function(s,l,c,a){t(c,s,l,"left"),t(a,l,s,"right")},i=n.transformX=function(s,l){e(s),e(l);for(var c=[],a=0;a<l.length;a++){for(var u=l[a],f=[],m=0;m<s.length;){var C=[];if(r(s[m],u,f,C),m++,C.length===1)u=C[0];else if(C.length===0){for(var v=m;v<s.length;v++)o(f,s[v]);u=null;break}else{for(var w=i(s.slice(m),C),E=0;E<w[0].length;E++)o(f,w[0][E]);for(var L=0;L<w[1].length;L++)o(c,w[1][L]);u=null;break}}u!=null&&o(c,u),s=f}return[s,c]};n.transform=function(s,l,c){if(!(c==="left"||c==="right"))throw new Error("type must be 'left' or 'right'");return l.length===0?s:s.length===1&&l.length===1?t([],s[0],l[0],c):c==="left"?i(s,l)[0]:i(l,s)[1]}}var T0={exports:{}},ao=T0.exports={name:"text0",uri:"http://sharejs.org/types/textv0",create:function(n){if(n!=null&&typeof n!="string")throw new Error("Initial data must be a string");return n||""}},Td=function(n,t,e){return n.slice(0,t)+e+n.slice(t)},Dd=function(n){if(typeof n.p!="number")throw new Error("component missing position field");if(typeof n.i=="string"==(typeof n.d=="string"))throw new Error("component needs an i or d field");if(n.p<0)throw new Error("position cannot be negative")},Gl=function(n){for(var t=0;t<n.length;t++)Dd(n[t])};ao.apply=function(n,t){var e;Gl(t);for(var o=0;o<t.length;o++){var r=t[o];if(r.i!=null)n=Td(n,r.p,r.i);else{if(e=n.slice(r.p,r.p+r.d.length),r.d!==e)throw new Error("Delete component '"+r.d+"' does not match deleted text '"+e+"'");n=n.slice(0,r.p)+n.slice(r.p+r.d.length)}}return n};var zn=ao._append=function(n,t){if(!(t.i===""||t.d===""))if(n.length===0)n.push(t);else{var e=n[n.length-1];e.i!=null&&t.i!=null&&e.p<=t.p&&t.p<=e.p+e.i.length?n[n.length-1]={i:Td(e.i,t.p-e.p,t.i),p:e.p}:e.d!=null&&t.d!=null&&t.p<=e.p&&e.p<=t.p+t.d.length?n[n.length-1]={d:Td(t.d,e.p-t.p,e.d),p:t.p}:n.push(t)}};ao.compose=function(n,t){Gl(n),Gl(t);for(var e=n.slice(),o=0;o<t.length;o++)zn(e,t[o]);return e},ao.normalize=function(n){var t=[];(n.i!=null||n.p!=null)&&(n=[n]);for(var e=0;e<n.length;e++){var o=n[e];o.p==null&&(o.p=0),zn(t,o)}return t};var Ld=function(n,t,e){return t.i!=null?t.p<n||t.p===n&&e?n+t.i.length:n:n<=t.p?n:n<=t.p+t.d.length?t.p:n-t.d.length};ao.transformCursor=function(n,t,e){for(var o=e==="right",r=0;r<t.length;r++)n=Ld(n,t[r],o);return n};var py=ao._tc=function(n,t,e,o){if(Dd(t),Dd(e),t.i!=null)zn(n,{i:t.i,p:Ld(t.p,e,o==="right")});else if(e.i!=null){var r=t.d;t.p<e.p&&(zn(n,{d:r.slice(0,e.p-t.p),p:t.p}),r=r.slice(e.p-t.p)),r!==""&&zn(n,{d:r,p:t.p+e.i.length})}else if(t.p>=e.p+e.d.length)zn(n,{d:t.d,p:t.p-e.d.length});else if(t.p+t.d.length<=e.p)zn(n,t);else{var i={d:"",p:t.p};t.p<e.p&&(i.d=t.d.slice(0,e.p-t.p)),t.p+t.d.length>e.p+e.d.length&&(i.d+=t.d.slice(e.p+e.d.length-t.p));var s=Math.max(t.p,e.p),l=Math.min(t.p+t.d.length,e.p+e.d.length),c=t.d.slice(s-t.p,l-t.p),a=e.d.slice(s-e.p,l-e.p);if(c!==a)throw new Error("Delete ops delete different text in the same region of the document");i.d!==""&&(i.p=Ld(i.p,e),zn(n,i))}return n},Cy=function(n){return n.i!=null?{d:n.i,p:n.p}:{i:n.d,p:n.p}};ao.invert=function(n){n=n.slice().reverse();for(var t=0;t<n.length;t++)n[t]=Cy(n[t]);return n},S0(ao,py,Gl,zn);var Zl=function(n){return Object.prototype.toString.call(n)=="[object Array]"},by=function(n){return!!n&&n.constructor===Object},Xe=function(n){return JSON.parse(JSON.stringify(n))},et={name:"json0",uri:"http://sharejs.org/types/JSONv0"},Vn={};et.registerSubtype=function(n){Vn[n.name]=n},et.create=function(n){return n===void 0?null:Xe(n)},et.invertComponent=function(n){var t={p:n.p};return n.t&&Vn[n.t]&&(t.t=n.t,t.o=Vn[n.t].invert(n.o)),n.si!==void 0&&(t.sd=n.si),n.sd!==void 0&&(t.si=n.sd),n.oi!==void 0&&(t.od=n.oi),n.od!==void 0&&(t.oi=n.od),n.li!==void 0&&(t.ld=n.li),n.ld!==void 0&&(t.li=n.ld),n.na!==void 0&&(t.na=-n.na),n.lm!==void 0&&(t.lm=n.p[n.p.length-1],t.p=n.p.slice(0,n.p.length-1).concat([n.lm])),t},et.invert=function(n){for(var t=n.slice().reverse(),e=[],o=0;o<t.length;o++)e.push(et.invertComponent(t[o]));return e},et.checkValidOp=function(n){for(var t=0;t<n.length;t++)if(!Zl(n[t].p))throw new Error("Missing path")},et.checkList=function(n){if(!Zl(n))throw new Error("Referenced element not a list")},et.checkObj=function(n){if(!by(n))throw new Error("Referenced element not an object (it was "+JSON.stringify(n)+")")};function Gi(n){n.t="text0";var t={p:n.p.pop()};n.si!=null&&(t.i=n.si),n.sd!=null&&(t.d=n.sd),n.o=[t]}function Zi(n){n.p.push(n.o[0].p),n.o[0].i!=null&&(n.si=n.o[0].i),n.o[0].d!=null&&(n.sd=n.o[0].d),delete n.t,delete n.o}et.apply=function(n,t){et.checkValidOp(t),t=Xe(t);for(var e={data:n},o=0;o<t.length;o++){var r=t[o];(r.si!=null||r.sd!=null)&&Gi(r);for(var i=null,s=e,l="data",c=0;c<r.p.length;c++){var a=r.p[c];if(i=s,s=s[l],l=a,i==null)throw new Error("Path invalid")}if(r.t&&r.o!==void 0&&Vn[r.t])s[l]=Vn[r.t].apply(s[l],r.o);else if(r.na!==void 0){if(typeof s[l]!="number")throw new Error("Referenced element not a number");s[l]+=r.na}else if(r.li!==void 0&&r.ld!==void 0)et.checkList(s),s[l]=r.li;else if(r.li!==void 0)et.checkList(s),s.splice(l,0,r.li);else if(r.ld!==void 0)et.checkList(s),s.splice(l,1);else if(r.lm!==void 0){if(et.checkList(s),r.lm!=l){var u=s[l];s.splice(l,1),s.splice(r.lm,0,u)}}else if(r.oi!==void 0)et.checkObj(s),s[l]=r.oi;else if(r.od!==void 0)et.checkObj(s),delete s[l];else throw new Error("invalid / missing instruction in op")}return e.data},et.shatter=function(n){for(var t=[],e=0;e<n.length;e++)t.push([n[e]]);return t},et.incrementalApply=function(n,t,e){for(var o=0;o<t.length;o++){var r=[t[o]];n=et.apply(n,r),e(r,n)}return n};var vy=et.pathMatches=function(n,t,e){if(n.length!=t.length)return!1;for(var o=0;o<n.length;o++)if(n[o]!==t[o]&&(!e||o!==n.length-1))return!1;return!0};et.append=function(n,t){if(t=Xe(t),n.length===0){n.push(t);return}var e=n[n.length-1];if((t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(Gi(t),Gi(e)),vy(t.p,e.p))if(t.t&&e.t&&t.t===e.t&&Vn[t.t]){if(e.o=Vn[t.t].compose(e.o,t.o),t.si!=null||t.sd!=null){for(var o=t.p,r=0;r<e.o.length-1;r++)t.o=[e.o.pop()],t.p=o.slice(),Zi(t),n.push(t);Zi(e)}}else e.na!=null&&t.na!=null?n[n.length-1]={p:e.p,na:e.na+t.na}:e.li!==void 0&&t.li===void 0&&t.ld===e.li?e.ld!==void 0?delete e.li:n.pop():e.od!==void 0&&e.oi===void 0&&t.oi!==void 0&&t.od===void 0?e.oi=t.oi:e.oi!==void 0&&t.od!==void 0?t.oi!==void 0?e.oi=t.oi:e.od!==void 0?delete e.oi:n.pop():t.lm!==void 0&&t.p[t.p.length-1]===t.lm||n.push(t);else(t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(Zi(t),Zi(e)),n.push(t)},et.compose=function(n,t){et.checkValidOp(n),et.checkValidOp(t);for(var e=Xe(n),o=0;o<t.length;o++)et.append(e,t[o]);return e},et.normalize=function(n){var t=[];n=Zl(n)?n:[n];for(var e=0;e<n.length;e++){var o=n[e];o.p==null&&(o.p=[]),et.append(t,o)}return t},et.commonLengthForOps=function(n,t){var e=n.p.length,o=t.p.length;if((n.na!=null||n.t)&&e++,(t.na!=null||t.t)&&o++,e===0)return-1;if(o===0)return null;e--,o--;for(var r=0;r<e;r++){var i=n.p[r];if(r>=o||i!==t.p[r])return null}return e},et.canOpAffectPath=function(n,t){return et.commonLengthForOps({p:t},n)!=null},et.transformComponent=function(n,t,e,o){t=Xe(t);var r=et.commonLengthForOps(e,t),i=et.commonLengthForOps(t,e),s=t.p.length,l=e.p.length;if((t.na!=null||t.t)&&s++,(e.na!=null||e.t)&&l++,i!=null&&l>s&&t.p[i]==e.p[i]){if(t.ld!==void 0){var c=Xe(e);c.p=c.p.slice(s),t.ld=et.apply(Xe(t.ld),[c])}else if(t.od!==void 0){var c=Xe(e);c.p=c.p.slice(s),t.od=et.apply(Xe(t.od),[c])}}if(r!=null){var a=s==l,c=e;if((t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(Gi(t),c=Xe(e),Gi(c)),c.t&&Vn[c.t]){if(t.t&&t.t===c.t){var u=Vn[t.t].transform(t.o,c.o,o);if(t.si!=null||t.sd!=null)for(var f=t.p,m=0;m<u.length;m++)t.o=[u[m]],t.p=f.slice(),Zi(t),et.append(n,t);else(!Zl(u)||u.length>0)&&(t.o=u,et.append(n,t));return n}}else if(e.na===void 0){if(e.li!==void 0&&e.ld!==void 0){if(e.p[r]===t.p[r])if(a){if(t.ld!==void 0)if(t.li!==void 0&&o==="left")t.ld=Xe(e.li);else return n}else return n}else if(e.li!==void 0)t.li!==void 0&&t.ld===void 0&&a&&t.p[r]===e.p[r]?o==="right"&&t.p[r]++:e.p[r]<=t.p[r]&&t.p[r]++,t.lm!==void 0&&a&&e.p[r]<=t.lm&&t.lm++;else if(e.ld!==void 0){if(t.lm!==void 0&&a){if(e.p[r]===t.p[r])return n;var f=e.p[r],C=t.p[r],v=t.lm;(f<v||f===v&&C<v)&&t.lm--}if(e.p[r]<t.p[r])t.p[r]--;else if(e.p[r]===t.p[r]){if(l<s)return n;if(t.ld!==void 0)if(t.li!==void 0)delete t.ld;else return n}}else if(e.lm!==void 0)if(t.lm!==void 0&&s===l){var C=t.p[r],v=t.lm,w=e.p[r],E=e.lm;if(w!==E)if(C===w)if(o==="left")t.p[r]=E,C===v&&(t.lm=E);else return n;else C>w&&t.p[r]--,C>E?t.p[r]++:C===E&&w>E&&(t.p[r]++,C===v&&t.lm++),(v>w||v===w&&v>C)&&t.lm--,v>E?t.lm++:v===E&&(E>w&&v>C||E<w&&v<C?o==="right"&&t.lm++:v>C?t.lm++:v===w&&t.lm--)}else if(t.li!==void 0&&t.ld===void 0&&a){var C=e.p[r],v=e.lm;f=t.p[r],f>C&&t.p[r]--,f>v&&t.p[r]++}else{var C=e.p[r],v=e.lm;f=t.p[r],f===C?t.p[r]=v:(f>C&&t.p[r]--,(f>v||f===v&&C>v)&&t.p[r]++)}else if(e.oi!==void 0&&e.od!==void 0){if(t.p[r]===e.p[r])if(t.oi!==void 0&&a){if(o==="right")return n;t.od=e.oi}else return n}else if(e.oi!==void 0){if(t.oi!==void 0&&t.p[r]===e.p[r])if(o==="left")et.append(n,{p:t.p,od:e.oi});else return n}else if(e.od!==void 0&&t.p[r]==e.p[r]){if(!a)return n;if(t.oi!==void 0)delete t.od;else return n}}}return et.append(n,t),n},S0(et,et.transformComponent,et.checkValidOp,et.append);var ky=T0.exports;et.registerSubtype(ky);var yy=et,wy={type:yy};(function(n){n.defaultType=wy.type,n.map={},n.register=function(t){t.name&&(n.map[t.name]=t),t.uri&&(n.map[t.uri]=t)},n.register(n.defaultType)})(Wi);var tn={};(function(n){n.doNothing=t;function t(){}n.hasKeys=function(e){for(var o in e)return!0;return!1},n.isInteger=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e},n.isValidVersion=function(e){return e===null?!0:n.isInteger(e)&&e>=0},n.isValidTimestamp=function(e){return n.isValidVersion(e)},n.MAX_SAFE_INTEGER=9007199254740991,n.dig=function(){for(var e=arguments[0],o=1;o<arguments.length;o++){var r=arguments[o];e=e[r]||(o===arguments.length-1?void 0:{})}return e},n.digOrCreate=function(){for(var e=arguments[0],o=arguments[arguments.length-1],r=1;r<arguments.length-1;r++){var i=arguments[r];e=e[i]||(e[i]=r===arguments.length-2?o():{})}return e},n.digAndRemove=function(){for(var e=arguments[0],o=[e],r=1;r<arguments.length-1;r++){var i=arguments[r];if(!e.hasOwnProperty(i))break;e=e[i],o.push(e)}for(var r=o.length-1;r>=0;r--){var s=o[r],i=arguments[r+1],l=s[i];(r===o.length-1||!n.hasKeys(l))&&delete s[i]}},n.supportsPresence=function(e){return e&&typeof e.transformPresence=="function"},n.callEach=function(e,o){var r=!1;return e.forEach(function(i){i&&(i(o),r=!0)}),r},n.truthy=function(e){return!!e},n.nextTick=function(e){if(typeof process<"u"&&process.nextTick)return process.nextTick.apply(null,arguments);for(var o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];setTimeout(function(){e.apply(null,o)})},n.clone=function(e){return e===void 0?void 0:JSON.parse(JSON.stringify(e))}})(tn);var D0=Array.isArray,L0=Object.keys,By=Object.prototype.hasOwnProperty,Ey=function n(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){var o=D0(t),r=D0(e),i,s,l;if(o&&r){if(s=t.length,s!=e.length)return!1;for(i=s;i--!==0;)if(!n(t[i],e[i]))return!1;return!0}if(o!=r)return!1;var c=t instanceof Date,a=e instanceof Date;if(c!=a)return!1;if(c&&a)return t.getTime()==e.getTime();var u=t instanceof RegExp,f=e instanceof RegExp;if(u!=f)return!1;if(u&&f)return t.toString()==e.toString();var m=L0(t);if(s=m.length,s!==L0(e).length)return!1;for(i=s;i--!==0;)if(!By.call(e,m[i]))return!1;for(i=s;i--!==0;)if(l=m[i],!n(t[l],e[l]))return!1;return!0}return t!==t&&e!==e},M0=co,Iy=x0,ye=Wl,Yl=Wi,en=tn,xy=en.clone,Sy=Ey,ge=ye.CODES,Ty=st;function st(n,t,e){M0.EventEmitter.call(this),this.connection=n,this.collection=t,this.id=e,this.version=null,this.type=null,this.data=void 0,this.inflightFetch=[],this.inflightSubscribe=null,this.pendingFetch=[],this.pendingSubscribe=[],this.subscribed=!1,this.wantSubscribe=!1,this._wantsDestroy=!1,this.inflightOp=null,this.pendingOps=[],this.type=null,this.applyStack=null,this.preventCompose=!1,this.submitSource=!1,this.paused=!1,this._dataStateVersion=0}M0.mixin(st),st.prototype.destroy=function(n){this._wantsDestroy=!0;var t=this;t.whenNothingPending(function(){t.wantSubscribe?t.unsubscribe(function(e){if(e)return n?n(e):t.emit("error",e);t.connection._destroyDoc(t),n&&n()}):(t.connection._destroyDoc(t),n&&n())})},st.prototype._setType=function(n){if(typeof n=="string"&&(n=Yl.map[n]),n)this.type=n;else if(n===null)this.type=n,this._setData(void 0);else{var t=new ye(ge.ERR_DOC_TYPE_NOT_RECOGNIZED,"Missing type "+n);return this.emit("error",t)}},st.prototype._setData=function(n){this.data=n,this._dataStateVersion++},st.prototype.ingestSnapshot=function(n,t){if(!n)return t&&t();if(typeof n.v!="number"){var e=new ye(ge.ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION,"Missing version in ingested snapshot. "+this.collection+"."+this.id);return t?t(e):this.emit("error",e)}if(this.type||this.hasWritePending()){if(this.version==null){if(this.hasWritePending())return t&&this.once("no write pending",t);var e=new ye(ge.ERR_DOC_MISSING_VERSION,"Cannot ingest snapshot in doc with null version. "+this.collection+"."+this.id);return t?t(e):this.emit("error",e)}return n.v>this.version?this.fetch(t):t&&t()}if(this.version>n.v)return t&&t();this.version=n.v;var o=n.type===void 0?Yl.defaultType:n.type;this._setType(o),this._setData(this.type&&this.type.deserialize?this.type.deserialize(n.data):n.data),this.emit("load"),t&&t()},st.prototype.whenNothingPending=function(n){var t=this;en.nextTick(function(){if(t.hasPending()){t.once("nothing pending",n);return}n()})},st.prototype.hasPending=function(){return!!(this.inflightOp||this.pendingOps.length||this.inflightFetch.length||this.inflightSubscribe||this.pendingFetch.length||this.pendingSubscribe.length)},st.prototype.hasWritePending=function(){return!!(this.inflightOp||this.pendingOps.length)},st.prototype._emitNothingPending=function(){this.hasWritePending()||(this.emit("no write pending"),!this.hasPending()&&this.emit("nothing pending"))},st.prototype._emitResponseError=function(n,t){if(n&&n.code===ge.ERR_SNAPSHOT_READ_SILENT_REJECTION){this.wantSubscribe=!1,t&&t(),this._emitNothingPending();return}if(t){t(n),this._emitNothingPending();return}this._emitNothingPending(),this.emit("error",n)},st.prototype._handleFetch=function(n,t){var e=this.pendingFetch;this.pendingFetch=[];var o=this.inflightFetch.shift();if(o&&e.push(o),e.length&&(o=function(r){en.callEach(e,r)}),n)return this._emitResponseError(n,o);this.ingestSnapshot(t,o),this._emitNothingPending()},st.prototype._handleSubscribe=function(n,t){var e=this.inflightSubscribe;this.inflightSubscribe=null;var o=this.pendingFetch;this.pendingFetch=[],e.callback&&o.push(e.callback);var r;if(o.length&&(r=function(i){en.callEach(o,i)}),n)return this._emitResponseError(n,r);this.subscribed=e.wantSubscribe,this.subscribed?this.ingestSnapshot(t,r):r&&r(),this._emitNothingPending(),this._flushSubscribe()},st.prototype._handleOp=function(n,t){if(n)return this.inflightOp?(n.code===ge.ERR_OP_SUBMIT_REJECTED&&(n=null),this._rollback(n)):this.emit("error",n);if(this.inflightOp&&t.src===this.inflightOp.src&&t.seq===this.inflightOp.seq){this._opAcknowledged(t);return}if(this.version==null||t.v>this.version){this.fetch();return}if(!(t.v<this.version)){if(this.inflightOp){var e=Ql(this.inflightOp,t);if(e)return this._hardRollback(e)}for(var o=0;o<this.pendingOps.length;o++){var e=Ql(this.pendingOps[o],t);if(e)return this._hardRollback(e)}this.version++;try{this._otApply(t,!1)}catch(r){return this._hardRollback(r)}}},st.prototype._onConnectionStateChanged=function(){this.connection.canSend?(this.flush(),this._resubscribe()):(this.inflightOp&&(this.pendingOps.unshift(this.inflightOp),this.inflightOp=null),this.subscribed=!1,this.inflightSubscribe&&(this.inflightSubscribe.wantSubscribe?(this.pendingSubscribe.unshift(this.inflightSubscribe),this.inflightSubscribe=null):this._handleSubscribe()),this.inflightFetch.length&&(this.pendingFetch=this.pendingFetch.concat(this.inflightFetch),this.inflightFetch.length=0))},st.prototype._resubscribe=function(){if(!this.pendingSubscribe.length&&this.wantSubscribe)return this.subscribe();var n=this.pendingSubscribe.some(function(t){return t.wantSubscribe});!n&&this.pendingFetch.length&&this.fetch(),this._flushSubscribe()},st.prototype.fetch=function(n){if(this.connection.canSend){var t=this.connection.sendFetch(this);Dy(this.inflightFetch,t,n);return}this.pendingFetch.push(n)},st.prototype.subscribe=function(n){var t=!0;this._queueSubscribe(t,n)},st.prototype.unsubscribe=function(n){var t=!1;this._queueSubscribe(t,n)},st.prototype._queueSubscribe=function(n,t){var e=this.pendingSubscribe[this.pendingSubscribe.length-1]||this.inflightSubscribe,o=e&&e.wantSubscribe===n;if(o){e.callback=Ly([e.callback,t]);return}this.pendingSubscribe.push({wantSubscribe:!!n,callback:t}),this._flushSubscribe()},st.prototype._flushSubscribe=function(){if(!(this.inflightSubscribe||!this.pendingSubscribe.length)){if(this.connection.canSend){this.inflightSubscribe=this.pendingSubscribe.shift(),this.wantSubscribe=this.inflightSubscribe.wantSubscribe,this.wantSubscribe?this.connection.sendSubscribe(this):(this.subscribed=!1,this.connection.sendUnsubscribe(this));return}if(!this.pendingSubscribe[0].wantSubscribe){this.inflightSubscribe=this.pendingSubscribe.shift();var n=this;en.nextTick(function(){n._handleSubscribe()})}}};function Dy(n,t,e){if(t){var o=n.pop();n.push(function(r){o&&o(r),e&&e(r)})}else n.push(e)}function Ly(n){return n=n.filter(en.truthy),n.length?function(t){en.callEach(n,t)}:null}st.prototype.flush=function(){!this.connection.canSend||this.inflightOp||!this.paused&&this.pendingOps.length&&this._sendOp()};function My(n){delete n.op,delete n.create,delete n.del}function Ql(n,t){if(n.del)return My(t);if(t.del)return new ye(ge.ERR_DOC_WAS_DELETED,"Document was deleted");if(t.create)return new ye(ge.ERR_DOC_ALREADY_CREATED,"Document already created");if("op"in t){if(n.create)return new ye(ge.ERR_DOC_ALREADY_CREATED,"Document already created");if(n.type.transformX){var e=n.type.transformX(n.op,t.op);n.op=e[0],t.op=e[1]}else{var o=n.type.transform(n.op,t.op,"left"),r=n.type.transform(t.op,n.op,"right");n.op=o,t.op=r}}}st.prototype._otApply=function(n,t){if("op"in n){if(!this.type)throw new ye(ge.ERR_DOC_DOES_NOT_EXIST,"Cannot apply op to uncreated document. "+this.collection+"."+this.id);if(this.emit("before op batch",n.op,t),!t&&this.type===Yl.defaultType&&n.op.length>1){this.applyStack||(this.applyStack=[]);for(var e=this.applyStack.length,o=0;o<n.op.length;o++){var r=n.op[o],i={op:[r]};this.emit("before op",i.op,t,n.src);for(var s=e;s<this.applyStack.length;s++){var l=Ql(this.applyStack[s],i);if(l)return this._hardRollback(l)}this._setData(this.type.apply(this.data,i.op)),this.emit("op",i.op,t,n.src)}this.emit("op batch",n.op,t),this._popApplyStack(e);return}this.emit("before op",n.op,t,n.src),this._setData(this.type.apply(this.data,n.op)),this.emit("op",n.op,t,n.src),this.emit("op batch",n.op,t);return}if(n.create){this._setType(n.create.type),this.type.deserialize?this.type.createDeserialized?this._setData(this.type.createDeserialized(n.create.data)):this._setData(this.type.deserialize(this.type.create(n.create.data))):this._setData(this.type.create(n.create.data)),this.emit("create",t);return}if(n.del){var c=this.data;this._setType(null),this.emit("del",c,t);return}},st.prototype._sendOp=function(){if(!!this.connection.canSend){var n=this.connection.id;this.inflightOp||(this.inflightOp=this.pendingOps.shift());var t=this.inflightOp;if(!t){var e=new ye(ge.ERR_INFLIGHT_OP_MISSING,"No op to send on call to _sendOp");return this.emit("error",e)}if(t.sentAt=Date.now(),t.retries=t.retries==null?0:t.retries+1,t.seq==null){if(this.connection.seq>=en.MAX_SAFE_INTEGER)return this.emit("error",new ye(ge.ERR_CONNECTION_SEQ_INTEGER_OVERFLOW,"Connection seq has exceeded the max safe integer, maybe from being open for too long"));t.seq=this.connection.seq++}this.connection.sendOp(this,t),t.src==null&&(t.src=n)}},st.prototype._submit=function(n,t,e){if(t||(t=!0),"op"in n){if(!this.type){var o=new ye(ge.ERR_DOC_DOES_NOT_EXIST,"Cannot submit op. Document has not been created. "+this.collection+"."+this.id);return e?e(o):this.emit("error",o)}this.type.normalize&&(n.op=this.type.normalize(n.op))}try{this._pushOp(n,t,e),this._otApply(n,t)}catch(i){return this._hardRollback(i)}var r=this;en.nextTick(function(){r.flush()})},st.prototype._pushOp=function(n,t,e){if(n.source=t,this.applyStack)this.applyStack.push(n);else{var o=this._tryCompose(n);if(o){o.callbacks.push(e);return}}n.type=this.type,n.callbacks=[e],this.pendingOps.push(n)},st.prototype._popApplyStack=function(n){if(n>0){this.applyStack.length=n;return}var t=this.applyStack[0];if(this.applyStack=null,!!t){var e=this.pendingOps.indexOf(t);if(e!==-1)for(var o=this.pendingOps.splice(e),e=0;e<o.length;e++){var t=o[e],r=this._tryCompose(t);r?r.callbacks=r.callbacks.concat(t.callbacks):this.pendingOps.push(t)}}},st.prototype._tryCompose=function(n){if(!this.preventCompose){var t=this.pendingOps[this.pendingOps.length-1];if(!(!t||t.sentAt)&&!(this.submitSource&&!Sy(n.source,t.source))){if(t.create&&"op"in n)return t.create.data=this.type.apply(t.create.data,n.op),t;if("op"in t&&"op"in n&&this.type.compose)return t.op=this.type.compose(t.op,n.op),t}}},st.prototype.submitOp=function(n,t,e){typeof t=="function"&&(e=t,t=null);var o={op:n},r=t&&t.source;this._submit(o,r,e)},st.prototype.create=function(n,t,e,o){if(typeof t=="function"?(o=t,e=null,t=null):typeof e=="function"&&(o=e,e=null),t||(t=Yl.defaultType.uri),this.type){var r=new ye(ge.ERR_DOC_ALREADY_CREATED,"Document already exists");return o?o(r):this.emit("error",r)}var i={create:{type:t,data:n}},s=e&&e.source;this._submit(i,s,o)},st.prototype.del=function(n,t){if(typeof n=="function"&&(t=n,n=null),!this.type){var e=new ye(ge.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");return t?t(e):this.emit("error",e)}var o={del:!0},r=n&&n.source;this._submit(o,r,t)},st.prototype.pause=function(){this.paused=!0},st.prototype.resume=function(){this.paused=!1,this.flush()},st.prototype.toSnapshot=function(){return{v:this.version,data:xy(this.data),type:this.type.uri}},st.prototype._opAcknowledged=function(n){if(this.inflightOp.create)this.version=n.v;else if(n.v!==this.version)return Iy.warn("Invalid version from server. Expected: "+this.version+" Received: "+n.v,n),this.fetch();this.version++,this._clearInflightOp()},st.prototype._rollback=function(n){var t=this.inflightOp;if("op"in t&&t.type.invert){try{t.op=t.type.invert(t.op)}catch{return this._hardRollback(n)}for(var e=0;e<this.pendingOps.length;e++){var o=Ql(this.pendingOps[e],t);if(o)return this._hardRollback(o)}try{this._otApply(t,!1)}catch(r){return this._hardRollback(r)}this._clearInflightOp(n);return}this._hardRollback(n)},st.prototype._hardRollback=function(n){var t=[];this.inflightOp&&t.push(this.inflightOp),t=t.concat(this.pendingOps),this._setType(null),this.version=null,this.inflightOp=null,this.pendingOps=[];var e=this;this.fetch(function(){for(var o=!!t.length,r=0;r<t.length;r++)o=en.callEach(t[r].callbacks,n)&&o;if(n&&!o)return e.emit("error",n)})},st.prototype._clearInflightOp=function(n){var t=this.inflightOp;this.inflightOp=null;var e=en.callEach(t.callbacks,n);if(this.flush(),this._emitNothingPending(),n&&!e)return this.emit("error",n)};var qo={};qo.ACTIONS={initLegacy:"init",handshake:"hs",queryFetch:"qf",querySubscribe:"qs",queryUnsubscribe:"qu",queryUpdate:"q",bulkFetch:"bf",bulkSubscribe:"bs",bulkUnsubscribe:"bu",fetch:"f",subscribe:"s",unsubscribe:"u",op:"op",snapshotFetch:"nf",snapshotFetchByTimestamp:"nt",pingPong:"pp",presence:"p",presenceSubscribe:"ps",presenceUnsubscribe:"pu",presenceRequest:"pr"};var R0=co,A0=qo.ACTIONS,Ry=tn,Ay=pe;function pe(n,t,e,o,r,i,s){R0.EventEmitter.call(this),this.action=n,this.connection=t,this.id=e,this.collection=o,this.query=r,this.results=null,i&&i.results&&(this.results=i.results,delete i.results),this.extra=void 0,this.options=i,this.callback=s,this.ready=!1,this.sent=!1}R0.mixin(pe),pe.prototype.hasPending=function(){return!this.ready},pe.prototype.send=function(){if(!!this.connection.canSend){var n={a:this.action,id:this.id,c:this.collection,q:this.query};if(this.options&&(n.o=this.options),this.results){for(var t=[],e=0;e<this.results.length;e++){var o=this.results[e];t.push([o.id,o.version])}n.r=t}this.connection.send(n),this.sent=!0}},pe.prototype.destroy=function(n){this.connection.canSend&&this.action===A0.querySubscribe&&this.connection.send({a:A0.queryUnsubscribe,id:this.id}),this.connection._destroyQuery(this),n&&Ry.nextTick(n)},pe.prototype._onConnectionStateChanged=function(){this.connection.canSend&&!this.sent?this.send():this.sent=!1},pe.prototype._handleFetch=function(n,t,e){this.connection._destroyQuery(this),this._handleResponse(n,t,e)},pe.prototype._handleSubscribe=function(n,t,e){this._handleResponse(n,t,e)},pe.prototype._handleResponse=function(n,t,e){var o=this.callback;if(this.callback=null,n)return this._finishResponse(n,o);if(!t)return this._finishResponse(null,o);var r=this,i=1,s=function(u){if(u)return r._finishResponse(u,o);--i||r._finishResponse(null,o)};if(Array.isArray(t))i+=t.length,this.results=this._ingestSnapshots(t,s),this.extra=e;else for(var l in t){i++;var c=t[l],a=this.connection.get(c.c||this.collection,l);a.ingestSnapshot(c,s)}s()},pe.prototype._ingestSnapshots=function(n,t){for(var e=[],o=0;o<n.length;o++){var r=n[o],i=this.connection.get(r.c||this.collection,r.d);i.ingestSnapshot(r,t),e.push(i)}return e},pe.prototype._finishResponse=function(n,t){if(this.emit("ready"),this.ready=!0,n)return this.connection._destroyQuery(this),t?t(n):this.emit("error",n);t&&t(null,this.results,this.extra)},pe.prototype._handleError=function(n){this.emit("error",n)},pe.prototype._handleDiff=function(n){for(var t=0;t<n.length;t++){var e=n[t];e.type==="insert"&&(e.values=this._ingestSnapshots(e.values))}for(var t=0;t<n.length;t++){var e=n[t];switch(e.type){case"insert":var o=e.values;Array.prototype.splice.apply(this.results,[e.index,0].concat(o)),this.emit("insert",o,e.index);break;case"remove":var i=e.howMany||1,r=this.results.splice(e.index,i);this.emit("remove",r,e.index);break;case"move":var i=e.howMany||1,s=this.results.splice(e.from,i);Array.prototype.splice.apply(this.results,[e.to,0].concat(s)),this.emit("move",s,e.from,e.to);break}}this.emit("changed",this.results)},pe.prototype._handleExtra=function(n){this.extra=n,this.emit("extra",n)};var O0=co,Oy=qo.ACTIONS,_y=tn,_0=bn;function bn(n,t){if(O0.EventEmitter.call(this),!t||typeof t!="string")throw new Error("LocalPresence presenceId must be a string");this.presence=n,this.presenceId=t,this.connection=n.connection,this.presenceVersion=0,this.value=null,this._pendingMessages=[],this._callbacksByPresenceVersion={}}O0.mixin(bn),bn.prototype.submit=function(n,t){this.value=n,this.send(t)},bn.prototype.send=function(n){var t=this._message();this._pendingMessages.push(t),this._callbacksByPresenceVersion[t.pv]=n,this._sendPending()},bn.prototype.destroy=function(n){var t=this;this.submit(null,function(e){if(e)return t._callbackOrEmit(e,n);delete t.presence.localPresences[t.presenceId],n&&n()})},bn.prototype._sendPending=function(){if(!!this.connection.canSend){var n=this;this._pendingMessages.forEach(function(t){n.connection.send(t)}),this._pendingMessages=[]}},bn.prototype._ack=function(n,t){var e=this._getCallback(t);this._callbackOrEmit(n,e)},bn.prototype._message=function(){return{a:Oy.presence,ch:this.presence.channel,id:this.presenceId,p:this.value,pv:this.presenceVersion++}},bn.prototype._getCallback=function(n){var t=this._callbacksByPresenceVersion[n];return delete this._callbacksByPresenceVersion[n],t},bn.prototype._callbackOrEmit=function(n,t){if(t)return _y.nextTick(t,n);n&&this.emit("error",n)};var Ny=tn,N0=Md;function Md(n,t){this.presence=n,this.presenceId=t,this.connection=this.presence.connection,this.value=null,this.presenceVersion=0}Md.prototype.receiveUpdate=function(n){n.pv<this.presenceVersion||(this.value=n.p,this.presenceVersion=n.pv,this.presence._updateRemotePresence(this))},Md.prototype.destroy=function(n){delete this.presence._remotePresenceInstances[this.presenceId],delete this.presence.remotePresences[this.presenceId],n&&Ny.nextTick(n)};var Rd={exports:{}};(function(n,t){(function(e,o){o(t)})(qi,function(e){function o(p,k){k=k|0;for(var B=Math.max(p.length-k,0),I=Array(B),D=0;D<B;D++)I[D]=p[k+D];return I}var r=function(p){var k=o(arguments,1);return function(){var B=o(arguments);return p.apply(null,k.concat(B))}},i=function(p){return function(){var k=o(arguments),B=k.pop();p.call(this,k,B)}};function s(p){var k=typeof p;return p!=null&&(k=="object"||k=="function")}var l=typeof setImmediate=="function"&&setImmediate,c=typeof process=="object"&&typeof process.nextTick=="function";function a(p){setTimeout(p,0)}function u(p){return function(k){var B=o(arguments,1);p(function(){k.apply(null,B)})}}var f;l?f=setImmediate:c?f=process.nextTick:f=a;var m=u(f);function C(p){return i(function(k,B){var I;try{I=p.apply(this,k)}catch(D){return B(D)}s(I)&&typeof I.then=="function"?I.then(function(D){v(B,null,D)},function(D){v(B,D.message?D:new Error(D))}):B(null,I)})}function v(p,k,B){try{p(k,B)}catch(I){m(w,I)}}function w(p){throw p}var E=typeof Symbol=="function";function L(p){return E&&p[Symbol.toStringTag]==="AsyncFunction"}function x(p){return L(p)?C(p):p}function A(p){return function(k){var B=o(arguments,1),I=i(function(D,T){var R=this;return p(k,function(_,q){x(_).apply(R,D.concat(q))},T)});return B.length?I.apply(this,B):I}}var O=typeof qi=="object"&&qi&&qi.Object===Object&&qi,P=typeof self=="object"&&self&&self.Object===Object&&self,U=O||P||Function("return this")(),tt=U.Symbol,ot=Object.prototype,ut=ot.hasOwnProperty,dt=ot.toString,yt=tt?tt.toStringTag:void 0;function oe(p){var k=ut.call(p,yt),B=p[yt];try{p[yt]=void 0;var I=!0}catch{}var D=dt.call(p);return I&&(k?p[yt]=B:delete p[yt]),D}var Jn=Object.prototype,Xt=Jn.toString;function Fe(p){return Xt.call(p)}var vo="[object Null]",ar="[object Undefined]",dr=tt?tt.toStringTag:void 0;function ko(p){return p==null?p===void 0?ar:vo:dr&&dr in Object(p)?oe(p):Fe(p)}var ma="[object AsyncFunction]",$P="[object Function]",HP="[object GeneratorFunction]",jP="[object Proxy]";function FP(p){if(!s(p))return!1;var k=ko(p);return k==$P||k==HP||k==ma||k==jP}var zP=9007199254740991;function B9(p){return typeof p=="number"&&p>-1&&p%1==0&&p<=zP}function $s(p){return p!=null&&B9(p.length)&&!FP(p)}var hf={};function ft(){}function yo(p){return function(){if(p!==null){var k=p;p=null,k.apply(this,arguments)}}}var ff=typeof Symbol=="function"&&Symbol.iterator,VP=function(p){return ff&&p[ff]&&p[ff]()};function UP(p,k){for(var B=-1,I=Array(p);++B<p;)I[B]=k(B);return I}function ga(p){return p!=null&&typeof p=="object"}var qP="[object Arguments]";function E9(p){return ga(p)&&ko(p)==qP}var I9=Object.prototype,WP=I9.hasOwnProperty,GP=I9.propertyIsEnumerable,ZP=E9(function(){return arguments}())?E9:function(p){return ga(p)&&WP.call(p,"callee")&&!GP.call(p,"callee")},dn=Array.isArray;function YP(){return!1}var x9=typeof e=="object"&&e&&!e.nodeType&&e,S9=x9&&!0&&n&&!n.nodeType&&n,QP=S9&&S9.exports===x9,T9=QP?U.Buffer:void 0,KP=T9?T9.isBuffer:void 0,JP=KP||YP,XP=9007199254740991,t$=/^(?:0|[1-9]\d*)$/;function e$(p,k){var B=typeof p;return k=k==null?XP:k,!!k&&(B=="number"||B!="symbol"&&t$.test(p))&&p>-1&&p%1==0&&p<k}var n$="[object Arguments]",o$="[object Array]",r$="[object Boolean]",i$="[object Date]",s$="[object Error]",l$="[object Function]",c$="[object Map]",a$="[object Number]",d$="[object Object]",u$="[object RegExp]",h$="[object Set]",f$="[object String]",m$="[object WeakMap]",g$="[object ArrayBuffer]",p$="[object DataView]",C$="[object Float32Array]",b$="[object Float64Array]",v$="[object Int8Array]",k$="[object Int16Array]",y$="[object Int32Array]",w$="[object Uint8Array]",B$="[object Uint8ClampedArray]",E$="[object Uint16Array]",I$="[object Uint32Array]",Bt={};Bt[C$]=Bt[b$]=Bt[v$]=Bt[k$]=Bt[y$]=Bt[w$]=Bt[B$]=Bt[E$]=Bt[I$]=!0,Bt[n$]=Bt[o$]=Bt[g$]=Bt[r$]=Bt[p$]=Bt[i$]=Bt[s$]=Bt[l$]=Bt[c$]=Bt[a$]=Bt[d$]=Bt[u$]=Bt[h$]=Bt[f$]=Bt[m$]=!1;function x$(p){return ga(p)&&B9(p.length)&&!!Bt[ko(p)]}function S$(p){return function(k){return p(k)}}var D9=typeof e=="object"&&e&&!e.nodeType&&e,Hs=D9&&!0&&n&&!n.nodeType&&n,T$=Hs&&Hs.exports===D9,mf=T$&&O.process,L9=function(){try{var p=Hs&&Hs.require&&Hs.require("util").types;return p||mf&&mf.binding&&mf.binding("util")}catch{}}(),M9=L9&&L9.isTypedArray,D$=M9?S$(M9):x$,L$=Object.prototype,M$=L$.hasOwnProperty;function R$(p,k){var B=dn(p),I=!B&&ZP(p),D=!B&&!I&&JP(p),T=!B&&!I&&!D&&D$(p),R=B||I||D||T,_=R?UP(p.length,String):[],q=_.length;for(var Q in p)(k||M$.call(p,Q))&&!(R&&(Q=="length"||D&&(Q=="offset"||Q=="parent")||T&&(Q=="buffer"||Q=="byteLength"||Q=="byteOffset")||e$(Q,q)))&&_.push(Q);return _}var A$=Object.prototype;function O$(p){var k=p&&p.constructor,B=typeof k=="function"&&k.prototype||A$;return p===B}function _$(p,k){return function(B){return p(k(B))}}var N$=_$(Object.keys,Object),P$=Object.prototype,$$=P$.hasOwnProperty;function H$(p){if(!O$(p))return N$(p);var k=[];for(var B in Object(p))$$.call(p,B)&&B!="constructor"&&k.push(B);return k}function gf(p){return $s(p)?R$(p):H$(p)}function j$(p){var k=-1,B=p.length;return function(){return++k<B?{value:p[k],key:k}:null}}function F$(p){var k=-1;return function(){var I=p.next();return I.done?null:(k++,{value:I.value,key:k})}}function z$(p){var k=gf(p),B=-1,I=k.length;return function D(){var T=k[++B];return T==="__proto__"?D():B<I?{value:p[T],key:T}:null}}function V$(p){if($s(p))return j$(p);var k=VP(p);return k?F$(k):z$(p)}function Dn(p){return function(){if(p===null)throw new Error("Callback was already called.");var k=p;p=null,k.apply(this,arguments)}}function pa(p){return function(k,B,I){if(I=yo(I||ft),p<=0||!k)return I(null);var D=V$(k),T=!1,R=0,_=!1;function q(W,X){if(R-=1,W)T=!0,I(W);else{if(X===hf||T&&R<=0)return T=!0,I(null);_||Q()}}function Q(){for(_=!0;R<p&&!T;){var W=D();if(W===null){T=!0,R<=0&&I(null);return}R+=1,B(W.value,W.key,Dn(q))}_=!1}Q()}}function ur(p,k,B,I){pa(k)(p,x(B),I)}function te(p,k){return function(B,I,D){return p(B,k,I,D)}}function U$(p,k,B){B=yo(B||ft);var I=0,D=0,T=p.length;T===0&&B(null);function R(_,q){_?B(_):(++D===T||q===hf)&&B(null)}for(;I<T;I++)k(p[I],I,Dn(R))}var q$=te(ur,1/0),wo=function(p,k,B){var I=$s(p)?U$:q$;I(p,x(k),B)};function ai(p){return function(k,B,I){return p(wo,k,x(B),I)}}function R9(p,k,B,I){I=I||ft,k=k||[];var D=[],T=0,R=x(B);p(k,function(_,q,Q){var W=T++;R(_,function(X,Et){D[W]=Et,Q(X)})},function(_){I(_,D)})}var Ca=ai(R9),A9=A(Ca);function di(p){return function(k,B,I,D){return p(pa(B),k,x(I),D)}}var ui=di(R9),pf=te(ui,1),O9=A(pf);function ba(p,k){for(var B=-1,I=p==null?0:p.length;++B<I&&k(p[B],B,p)!==!1;);return p}function W$(p){return function(k,B,I){for(var D=-1,T=Object(k),R=I(k),_=R.length;_--;){var q=R[p?_:++D];if(B(T[q],q,T)===!1)break}return k}}var G$=W$();function js(p,k){return p&&G$(p,k,gf)}function Z$(p,k,B,I){for(var D=p.length,T=B+(I?1:-1);I?T--:++T<D;)if(k(p[T],T,p))return T;return-1}function Y$(p){return p!==p}function Q$(p,k,B){for(var I=B-1,D=p.length;++I<D;)if(p[I]===k)return I;return-1}function va(p,k,B){return k===k?Q$(p,k,B):Z$(p,Y$,B)}var Cf=function(p,k,B){typeof k=="function"&&(B=k,k=null),B=yo(B||ft);var I=gf(p),D=I.length;if(!D)return B(null);k||(k=D);var T={},R=0,_=!1,q=Object.create(null),Q=[],W=[],X={};js(p,function(xt,St){if(!dn(xt)){Et(St,[xt]),W.push(St);return}var Yt=xt.slice(0,xt.length-1),Xn=Yt.length;if(Xn===0){Et(St,xt),W.push(St);return}X[St]=Xn,ba(Yt,function(gi){if(!p[gi])throw new Error("async.auto task `"+St+"` has a non-existent dependency `"+gi+"` in "+Yt.join(", "));Ln(gi,function(){Xn--,Xn===0&&Et(St,xt)})})}),zH(),re();function Et(xt,St){Q.push(function(){Mn(xt,St)})}function re(){if(Q.length===0&&R===0)return B(null,T);for(;Q.length&&R<k;){var xt=Q.shift();xt()}}function Ln(xt,St){var Yt=q[xt];Yt||(Yt=q[xt]=[]),Yt.push(St)}function ze(xt){var St=q[xt]||[];ba(St,function(Yt){Yt()}),re()}function Mn(xt,St){if(!_){var Yt=Dn(function(gi,Df){if(R--,arguments.length>2&&(Df=o(arguments,1)),gi){var Lf={};js(T,function(UH,qH){Lf[qH]=UH}),Lf[xt]=Df,_=!0,q=Object.create(null),B(gi,Lf)}else T[xt]=Df,ze(xt)});R++;var Xn=x(St[St.length-1]);St.length>1?Xn(T,Yt):Xn(Yt)}}function zH(){for(var xt,St=0;W.length;)xt=W.pop(),St++,ba(VH(xt),function(Yt){--X[Yt]===0&&W.push(Yt)});if(St!==D)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function VH(xt){var St=[];return js(p,function(Yt,Xn){dn(Yt)&&va(Yt,xt,0)>=0&&St.push(Xn)}),St}};function hi(p,k){for(var B=-1,I=p==null?0:p.length,D=Array(I);++B<I;)D[B]=k(p[B],B,p);return D}var K$="[object Symbol]";function J$(p){return typeof p=="symbol"||ga(p)&&ko(p)==K$}var X$=1/0,_9=tt?tt.prototype:void 0,N9=_9?_9.toString:void 0;function bf(p){if(typeof p=="string")return p;if(dn(p))return hi(p,bf)+"";if(J$(p))return N9?N9.call(p):"";var k=p+"";return k=="0"&&1/p==-X$?"-0":k}function tH(p,k,B){var I=-1,D=p.length;k<0&&(k=-k>D?0:D+k),B=B>D?D:B,B<0&&(B+=D),D=k>B?0:B-k>>>0,k>>>=0;for(var T=Array(D);++I<D;)T[I]=p[I+k];return T}function eH(p,k,B){var I=p.length;return B=B===void 0?I:B,!k&&B>=I?p:tH(p,k,B)}function nH(p,k){for(var B=p.length;B--&&va(k,p[B],0)>-1;);return B}function oH(p,k){for(var B=-1,I=p.length;++B<I&&va(k,p[B],0)>-1;);return B}function rH(p){return p.split("")}var iH="\\ud800-\\udfff",sH="\\u0300-\\u036f",lH="\\ufe20-\\ufe2f",cH="\\u20d0-\\u20ff",aH=sH+lH+cH,dH="\\ufe0e\\ufe0f",uH="\\u200d",hH=RegExp("["+uH+iH+aH+dH+"]");function fH(p){return hH.test(p)}var P9="\\ud800-\\udfff",mH="\\u0300-\\u036f",gH="\\ufe20-\\ufe2f",pH="\\u20d0-\\u20ff",CH=mH+gH+pH,bH="\\ufe0e\\ufe0f",vH="["+P9+"]",vf="["+CH+"]",kf="\\ud83c[\\udffb-\\udfff]",kH="(?:"+vf+"|"+kf+")",$9="[^"+P9+"]",H9="(?:\\ud83c[\\udde6-\\uddff]){2}",j9="[\\ud800-\\udbff][\\udc00-\\udfff]",yH="\\u200d",F9=kH+"?",z9="["+bH+"]?",wH="(?:"+yH+"(?:"+[$9,H9,j9].join("|")+")"+z9+F9+")*",BH=z9+F9+wH,EH="(?:"+[$9+vf+"?",vf,H9,j9,vH].join("|")+")",IH=RegExp(kf+"(?="+kf+")|"+EH+BH,"g");function xH(p){return p.match(IH)||[]}function V9(p){return fH(p)?xH(p):rH(p)}function SH(p){return p==null?"":bf(p)}var TH=/^\s+|\s+$/g;function DH(p,k,B){if(p=SH(p),p&&(B||k===void 0))return p.replace(TH,"");if(!p||!(k=bf(k)))return p;var I=V9(p),D=V9(k),T=oH(I,D),R=nH(I,D)+1;return eH(I,T,R).join("")}var LH=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,MH=/,/,RH=/(=.+)?(\s*)$/,AH=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;function OH(p){return p=p.toString().replace(AH,""),p=p.match(LH)[2].replace(" ",""),p=p?p.split(MH):[],p=p.map(function(k){return DH(k.replace(RH,""))}),p}function U9(p,k){var B={};js(p,function(I,D){var T,R=L(I),_=!R&&I.length===1||R&&I.length===0;if(dn(I))T=I.slice(0,-1),I=I[I.length-1],B[D]=T.concat(T.length>0?q:I);else if(_)B[D]=I;else{if(T=OH(I),I.length===0&&!R&&T.length===0)throw new Error("autoInject task functions require explicit parameters.");R||T.pop(),B[D]=T.concat(q)}function q(Q,W){var X=hi(T,function(Et){return Q[Et]});X.push(W),x(I).apply(null,X)}}),Cf(B,k)}function un(){this.head=this.tail=null,this.length=0}function q9(p,k){p.length=1,p.head=p.tail=k}un.prototype.removeLink=function(p){return p.prev?p.prev.next=p.next:this.head=p.next,p.next?p.next.prev=p.prev:this.tail=p.prev,p.prev=p.next=null,this.length-=1,p},un.prototype.empty=function(){for(;this.head;)this.shift();return this},un.prototype.insertAfter=function(p,k){k.prev=p,k.next=p.next,p.next?p.next.prev=k:this.tail=k,p.next=k,this.length+=1},un.prototype.insertBefore=function(p,k){k.prev=p.prev,k.next=p,p.prev?p.prev.next=k:this.head=k,p.prev=k,this.length+=1},un.prototype.unshift=function(p){this.head?this.insertBefore(this.head,p):q9(this,p)},un.prototype.push=function(p){this.tail?this.insertAfter(this.tail,p):q9(this,p)},un.prototype.shift=function(){return this.head&&this.removeLink(this.head)},un.prototype.pop=function(){return this.tail&&this.removeLink(this.tail)},un.prototype.toArray=function(){for(var p=Array(this.length),k=this.head,B=0;B<this.length;B++)p[B]=k.data,k=k.next;return p},un.prototype.remove=function(p){for(var k=this.head;k;){var B=k.next;p(k)&&this.removeLink(k),k=B}return this};function W9(p,k,B){if(k==null)k=1;else if(k===0)throw new Error("Concurrency must not be zero");var I=x(p),D=0,T=[],R=!1;function _(X,Et,re){if(re!=null&&typeof re!="function")throw new Error("task callback must be a function");if(W.started=!0,dn(X)||(X=[X]),X.length===0&&W.idle())return m(function(){W.drain()});for(var Ln=0,ze=X.length;Ln<ze;Ln++){var Mn={data:X[Ln],callback:re||ft};Et?W._tasks.unshift(Mn):W._tasks.push(Mn)}R||(R=!0,m(function(){R=!1,W.process()}))}function q(X){return function(Et){D-=1;for(var re=0,Ln=X.length;re<Ln;re++){var ze=X[re],Mn=va(T,ze,0);Mn===0?T.shift():Mn>0&&T.splice(Mn,1),ze.callback.apply(ze,arguments),Et!=null&&W.error(Et,ze.data)}D<=W.concurrency-W.buffer&&W.unsaturated(),W.idle()&&W.drain(),W.process()}}var Q=!1,W={_tasks:new un,concurrency:k,payload:B,saturated:ft,unsaturated:ft,buffer:k/4,empty:ft,drain:ft,error:ft,started:!1,paused:!1,push:function(X,Et){_(X,!1,Et)},kill:function(){W.drain=ft,W._tasks.empty()},unshift:function(X,Et){_(X,!0,Et)},remove:function(X){W._tasks.remove(X)},process:function(){if(!Q){for(Q=!0;!W.paused&&D<W.concurrency&&W._tasks.length;){var X=[],Et=[],re=W._tasks.length;W.payload&&(re=Math.min(re,W.payload));for(var Ln=0;Ln<re;Ln++){var ze=W._tasks.shift();X.push(ze),T.push(ze),Et.push(ze.data)}D+=1,W._tasks.length===0&&W.empty(),D===W.concurrency&&W.saturated();var Mn=Dn(q(X));I(Et,Mn)}Q=!1}},length:function(){return W._tasks.length},running:function(){return D},workersList:function(){return T},idle:function(){return W._tasks.length+D===0},pause:function(){W.paused=!0},resume:function(){W.paused!==!1&&(W.paused=!1,m(W.process))}};return W}function G9(p,k){return W9(p,1,k)}var fi=te(ur,1);function Bo(p,k,B,I){I=yo(I||ft);var D=x(B);fi(p,function(T,R,_){D(k,T,function(q,Q){k=Q,_(q)})},function(T){I(T,k)})}function yf(){var p=hi(arguments,x);return function(){var k=o(arguments),B=this,I=k[k.length-1];typeof I=="function"?k.pop():I=ft,Bo(p,k,function(D,T,R){T.apply(B,D.concat(function(_){var q=o(arguments,1);R(_,q)}))},function(D,T){I.apply(B,[D].concat(T))})}}var Z9=function(){return yf.apply(null,o(arguments).reverse())},_H=Array.prototype.concat,ka=function(p,k,B,I){I=I||ft;var D=x(B);ui(p,k,function(T,R){D(T,function(_){return _?R(_):R(null,o(arguments,1))})},function(T,R){for(var _=[],q=0;q<R.length;q++)R[q]&&(_=_H.apply(_,R[q]));return I(T,_)})},Y9=te(ka,1/0),Q9=te(ka,1),K9=function(){var p=o(arguments),k=[null].concat(p);return function(){var B=arguments[arguments.length-1];return B.apply(this,k)}};function Fs(p){return p}function mi(p,k){return function(B,I,D,T){T=T||ft;var R=!1,_;B(I,function(q,Q,W){D(q,function(X,Et){X?W(X):p(Et)&&!_?(R=!0,_=k(!0,q),W(null,hf)):W()})},function(q){q?T(q):T(null,R?_:k(!1))})}}function J9(p,k){return k}var ya=ai(mi(Fs,J9)),zs=di(mi(Fs,J9)),wa=te(zs,1);function X9(p){return function(k){var B=o(arguments,1);B.push(function(I){var D=o(arguments,1);typeof console=="object"&&(I?console.error&&console.error(I):console[p]&&ba(D,function(T){console[p](T)}))}),x(k).apply(null,B)}}var t7=X9("dir");function e7(p,k,B){B=Dn(B||ft);var I=x(p),D=x(k);function T(_){if(_)return B(_);var q=o(arguments,1);q.push(R),D.apply(this,q)}function R(_,q){if(_)return B(_);if(!q)return B(null);I(T)}R(null,!0)}function wf(p,k,B){B=Dn(B||ft);var I=x(p),D=function(T){if(T)return B(T);var R=o(arguments,1);if(k.apply(this,R))return I(D);B.apply(null,[null].concat(R))};I(D)}function n7(p,k,B){wf(p,function(){return!k.apply(this,arguments)},B)}function o7(p,k,B){B=Dn(B||ft);var I=x(k),D=x(p);function T(_){if(_)return B(_);D(R)}function R(_,q){if(_)return B(_);if(!q)return B(null);I(T)}D(R)}function r7(p){return function(k,B,I){return p(k,I)}}function Ba(p,k,B){wo(p,r7(x(k)),B)}function Vs(p,k,B,I){pa(k)(p,r7(x(B)),I)}var Us=te(Vs,1);function Bf(p){return L(p)?p:i(function(k,B){var I=!0;k.push(function(){var D=arguments;I?m(function(){B.apply(null,D)}):B.apply(null,D)}),p.apply(this,k),I=!1})}function Ea(p){return!p}var Ia=ai(mi(Ea,Ea)),qs=di(mi(Ea,Ea)),xa=te(qs,1);function i7(p){return function(k){return k==null?void 0:k[p]}}function NH(p,k,B,I){var D=new Array(k.length);p(k,function(T,R,_){B(T,function(q,Q){D[R]=!!Q,_(q)})},function(T){if(T)return I(T);for(var R=[],_=0;_<k.length;_++)D[_]&&R.push(k[_]);I(null,R)})}function PH(p,k,B,I){var D=[];p(k,function(T,R,_){B(T,function(q,Q){q?_(q):(Q&&D.push({index:R,value:T}),_())})},function(T){T?I(T):I(null,hi(D.sort(function(R,_){return R.index-_.index}),i7("value")))})}function Ef(p,k,B,I){var D=$s(k)?NH:PH;D(p,k,x(B),I||ft)}var Sa=ai(Ef),Ws=di(Ef),Ta=te(Ws,1);function s7(p,k){var B=Dn(k||ft),I=x(Bf(p));function D(T){if(T)return B(T);I(D)}D()}var Da=function(p,k,B,I){I=I||ft;var D=x(B);ui(p,k,function(T,R){D(T,function(_,q){return _?R(_):R(null,{key:q,val:T})})},function(T,R){for(var _={},q=Object.prototype.hasOwnProperty,Q=0;Q<R.length;Q++)if(R[Q]){var W=R[Q].key,X=R[Q].val;q.call(_,W)?_[W].push(X):_[W]=[X]}return I(T,_)})},l7=te(Da,1/0),c7=te(Da,1),a7=X9("log");function La(p,k,B,I){I=yo(I||ft);var D={},T=x(B);ur(p,k,function(R,_,q){T(R,_,function(Q,W){if(Q)return q(Q);D[_]=W,q()})},function(R){I(R,D)})}var d7=te(La,1/0),u7=te(La,1);function h7(p,k){return k in p}function f7(p,k){var B=Object.create(null),I=Object.create(null);k=k||Fs;var D=x(p),T=i(function(_,q){var Q=k.apply(null,_);h7(B,Q)?m(function(){q.apply(null,B[Q])}):h7(I,Q)?I[Q].push(q):(I[Q]=[q],D.apply(null,_.concat(function(){var W=o(arguments);B[Q]=W;var X=I[Q];delete I[Q];for(var Et=0,re=X.length;Et<re;Et++)X[Et].apply(null,W)})))});return T.memo=B,T.unmemoized=p,T}var Ma;c?Ma=process.nextTick:l?Ma=setImmediate:Ma=a;var m7=u(Ma);function If(p,k,B){B=B||ft;var I=$s(k)?[]:{};p(k,function(D,T,R){x(D)(function(_,q){arguments.length>2&&(q=o(arguments,1)),I[T]=q,R(_)})},function(D){B(D,I)})}function g7(p,k){If(wo,p,k)}function p7(p,k,B){If(pa(k),p,B)}var xf=function(p,k){var B=x(p);return W9(function(I,D){B(I[0],D)},k,1)},C7=function(p,k){var B=xf(p,k);return B.push=function(I,D,T){if(T==null&&(T=ft),typeof T!="function")throw new Error("task callback must be a function");if(B.started=!0,dn(I)||(I=[I]),I.length===0)return m(function(){B.drain()});D=D||0;for(var R=B._tasks.head;R&&D>=R.priority;)R=R.next;for(var _=0,q=I.length;_<q;_++){var Q={data:I[_],priority:D,callback:T};R?B._tasks.insertBefore(R,Q):B._tasks.push(Q)}m(B.process)},delete B.unshift,B};function b7(p,k){if(k=yo(k||ft),!dn(p))return k(new TypeError("First argument to race must be an array of functions"));if(!p.length)return k();for(var B=0,I=p.length;B<I;B++)x(p[B])(k)}function Ra(p,k,B,I){var D=o(p).reverse();Bo(D,k,B,I)}function Aa(p){var k=x(p);return i(function(I,D){return I.push(function(R,_){if(R)D(null,{error:R});else{var q;arguments.length<=2?q=_:q=o(arguments,1),D(null,{value:q})}}),k.apply(this,I)})}function v7(p){var k;return dn(p)?k=hi(p,Aa):(k={},js(p,function(B,I){k[I]=Aa.call(this,B)})),k}function k7(p,k,B,I){Ef(p,k,function(D,T){B(D,function(R,_){T(R,!_)})},I)}var y7=ai(k7),Sf=di(k7),w7=te(Sf,1);function B7(p){return function(){return p}}function Oa(p,k,B){var I=5,D=0,T={times:I,intervalFunc:B7(D)};function R(W,X){if(typeof X=="object")W.times=+X.times||I,W.intervalFunc=typeof X.interval=="function"?X.interval:B7(+X.interval||D),W.errorFilter=X.errorFilter;else if(typeof X=="number"||typeof X=="string")W.times=+X||I;else throw new Error("Invalid arguments for async.retry")}if(arguments.length<3&&typeof p=="function"?(B=k||ft,k=p):(R(T,p),B=B||ft),typeof k!="function")throw new Error("Invalid arguments for async.retry");var _=x(k),q=1;function Q(){_(function(W){W&&q++<T.times&&(typeof T.errorFilter!="function"||T.errorFilter(W))?setTimeout(Q,T.intervalFunc(q)):B.apply(null,arguments)})}Q()}var E7=function(p,k){k||(k=p,p=null);var B=x(k);return i(function(I,D){function T(R){B.apply(null,I.concat(R))}p?Oa(p,T,D):Oa(T,D)})};function I7(p,k){If(fi,p,k)}var _a=ai(mi(Boolean,Fs)),Gs=di(mi(Boolean,Fs)),Na=te(Gs,1);function x7(p,k,B){var I=x(k);Ca(p,function(T,R){I(T,function(_,q){if(_)return R(_);R(null,{value:T,criteria:q})})},function(T,R){if(T)return B(T);B(null,hi(R.sort(D),i7("value")))});function D(T,R){var _=T.criteria,q=R.criteria;return _<q?-1:_>q?1:0}}function S7(p,k,B){var I=x(p);return i(function(D,T){var R=!1,_;function q(){var Q=p.name||"anonymous",W=new Error('Callback function "'+Q+'" timed out.');W.code="ETIMEDOUT",B&&(W.info=B),R=!0,T(W)}D.push(function(){R||(T.apply(null,arguments),clearTimeout(_))}),_=setTimeout(q,k),I.apply(null,D)})}var $H=Math.ceil,HH=Math.max;function jH(p,k,B,I){for(var D=-1,T=HH($H((k-p)/(B||1)),0),R=Array(T);T--;)R[I?T:++D]=p,p+=B;return R}function Pa(p,k,B,I){var D=x(B);ui(jH(0,p,1),k,D,I)}var T7=te(Pa,1/0),D7=te(Pa,1);function L7(p,k,B,I){arguments.length<=3&&(I=B,B=k,k=dn(p)?[]:{}),I=yo(I||ft);var D=x(B);wo(p,function(T,R,_){D(k,T,R,_)},function(T){I(T,k)})}function M7(p,k){var B=null,I;k=k||ft,Us(p,function(D,T){x(D)(function(R,_){arguments.length>2?I=o(arguments,1):I=_,B=R,T(!R)})},function(){k(B,I)})}function R7(p){return function(){return(p.unmemoized||p).apply(null,arguments)}}function Tf(p,k,B){B=Dn(B||ft);var I=x(k);if(!p())return B(null);var D=function(T){if(T)return B(T);if(p())return I(D);var R=o(arguments,1);B.apply(null,[null].concat(R))};I(D)}function A7(p,k,B){Tf(function(){return!p.apply(this,arguments)},k,B)}var O7=function(p,k){if(k=yo(k||ft),!dn(p))return k(new Error("First argument to waterfall must be an array of functions"));if(!p.length)return k();var B=0;function I(T){var R=x(p[B++]);T.push(Dn(D)),R.apply(null,T)}function D(T){if(T||B===p.length)return k.apply(null,arguments);I(o(arguments,1))}I([])},FH={apply:r,applyEach:A9,applyEachSeries:O9,asyncify:C,auto:Cf,autoInject:U9,cargo:G9,compose:Z9,concat:Y9,concatLimit:ka,concatSeries:Q9,constant:K9,detect:ya,detectLimit:zs,detectSeries:wa,dir:t7,doDuring:e7,doUntil:n7,doWhilst:wf,during:o7,each:Ba,eachLimit:Vs,eachOf:wo,eachOfLimit:ur,eachOfSeries:fi,eachSeries:Us,ensureAsync:Bf,every:Ia,everyLimit:qs,everySeries:xa,filter:Sa,filterLimit:Ws,filterSeries:Ta,forever:s7,groupBy:l7,groupByLimit:Da,groupBySeries:c7,log:a7,map:Ca,mapLimit:ui,mapSeries:pf,mapValues:d7,mapValuesLimit:La,mapValuesSeries:u7,memoize:f7,nextTick:m7,parallel:g7,parallelLimit:p7,priorityQueue:C7,queue:xf,race:b7,reduce:Bo,reduceRight:Ra,reflect:Aa,reflectAll:v7,reject:y7,rejectLimit:Sf,rejectSeries:w7,retry:Oa,retryable:E7,seq:yf,series:I7,setImmediate:m,some:_a,someLimit:Gs,someSeries:Na,sortBy:x7,timeout:S7,times:T7,timesLimit:Pa,timesSeries:D7,transform:L7,tryEach:M7,unmemoize:R7,until:A7,waterfall:O7,whilst:Tf,all:Ia,allLimit:qs,allSeries:xa,any:_a,anyLimit:Gs,anySeries:Na,find:ya,findLimit:zs,findSeries:wa,forEach:Ba,forEachSeries:Us,forEachLimit:Vs,forEachOf:wo,forEachOfSeries:fi,forEachOfLimit:ur,inject:Bo,foldl:Bo,foldr:Ra,select:Sa,selectLimit:Ws,selectSeries:Ta,wrapSync:C};e.default=FH,e.apply=r,e.applyEach=A9,e.applyEachSeries=O9,e.asyncify=C,e.auto=Cf,e.autoInject=U9,e.cargo=G9,e.compose=Z9,e.concat=Y9,e.concatLimit=ka,e.concatSeries=Q9,e.constant=K9,e.detect=ya,e.detectLimit=zs,e.detectSeries=wa,e.dir=t7,e.doDuring=e7,e.doUntil=n7,e.doWhilst=wf,e.during=o7,e.each=Ba,e.eachLimit=Vs,e.eachOf=wo,e.eachOfLimit=ur,e.eachOfSeries=fi,e.eachSeries=Us,e.ensureAsync=Bf,e.every=Ia,e.everyLimit=qs,e.everySeries=xa,e.filter=Sa,e.filterLimit=Ws,e.filterSeries=Ta,e.forever=s7,e.groupBy=l7,e.groupByLimit=Da,e.groupBySeries=c7,e.log=a7,e.map=Ca,e.mapLimit=ui,e.mapSeries=pf,e.mapValues=d7,e.mapValuesLimit=La,e.mapValuesSeries=u7,e.memoize=f7,e.nextTick=m7,e.parallel=g7,e.parallelLimit=p7,e.priorityQueue=C7,e.queue=xf,e.race=b7,e.reduce=Bo,e.reduceRight=Ra,e.reflect=Aa,e.reflectAll=v7,e.reject=y7,e.rejectLimit=Sf,e.rejectSeries=w7,e.retry=Oa,e.retryable=E7,e.seq=yf,e.series=I7,e.setImmediate=m,e.some=_a,e.someLimit=Gs,e.someSeries=Na,e.sortBy=x7,e.timeout=S7,e.times=T7,e.timesLimit=Pa,e.timesSeries=D7,e.transform=L7,e.tryEach=M7,e.unmemoize=R7,e.until=A7,e.waterfall=O7,e.whilst=Tf,e.all=Ia,e.allLimit=qs,e.allSeries=xa,e.any=_a,e.anyLimit=Gs,e.anySeries=Na,e.find=ya,e.findLimit=zs,e.findSeries=wa,e.forEach=Ba,e.forEachSeries=Us,e.forEachLimit=Vs,e.forEachOf=wo,e.forEachOfSeries=fi,e.forEachOfLimit=ur,e.inject=Bo,e.foldl=Bo,e.foldr=Ra,e.select=Sa,e.selectLimit=Ws,e.selectSeries=Ta,e.wrapSync=C,Object.defineProperty(e,"__esModule",{value:!0})})})(Rd,Rd.exports);var P0={exports:{}},Ad=P0.exports=function(n,t){if(t||(t=16),n===void 0&&(n=128),n<=0)return"0";for(var e=Math.log(Math.pow(2,n))/Math.log(t),o=2;e===1/0;o*=2)e=Math.log(Math.pow(2,n/o))/Math.log(t)*o;for(var r=e-Math.floor(e),i="",o=0;o<Math.floor(e);o++){var s=Math.floor(Math.random()*t).toString(t);i=s+i}if(r){var l=Math.pow(t,r),s=Math.floor(Math.random()*l).toString(t);i=s+i}var c=parseInt(i,t);return c!==1/0&&c>=Math.pow(2,n)?Ad(n,t):i};Ad.rack=function(n,t,e){var o=function(i){var s=0;do{if(s++>10)if(e)n+=e;else throw new Error("too many ID collisions, use more bits");var l=Ad(n,t)}while(Object.hasOwnProperty.call(r,l));return r[l]=i,l},r=o.hats={};return o.get=function(i){return o.hats[i]},o.set=function(i,s){return o.hats[i]=s,o},o.bits=n||128,o.base=t||16,o};var $0=co,Py=_0,$y=N0,Kl=tn,Od=Rd.exports,Hy=P0.exports,H0=qo.ACTIONS,j0=Pt;function Pt(n,t){if($0.EventEmitter.call(this),!t||typeof t!="string")throw new Error("Presence channel must be provided");this.connection=n,this.channel=t,this.wantSubscribe=!1,this.subscribed=!1,this.remotePresences={},this.localPresences={},this._remotePresenceInstances={},this._subscriptionCallbacksBySeq={},this._wantsDestroy=!1}$0.mixin(Pt),Pt.prototype.subscribe=function(n){this._sendSubscriptionAction(!0,n)},Pt.prototype.unsubscribe=function(n){this._sendSubscriptionAction(!1,n)},Pt.prototype.create=function(n){if(this._wantsDestroy)throw new Error("Presence is being destroyed");n=n||Hy();var t=this._createLocalPresence(n);return this.localPresences[n]=t,t},Pt.prototype.destroy=function(n){this._wantsDestroy=!0;var t=this,e=Object.keys(t.localPresences);this.unsubscribe(function(o){if(o)return t._callbackOrEmit(o,n);var r=Object.keys(t._remotePresenceInstances);Od.parallel([function(i){Od.each(e,function(s,l){t.localPresences[s].destroy(l)},i)},function(i){if(!t._wantsDestroy)return i();Od.each(r,function(s,l){t._remotePresenceInstances[s].destroy(l)},i)}],function(i){t._wantsDestroy&&delete t.connection._presences[t.channel],t._callbackOrEmit(i,n)})})},Pt.prototype._sendSubscriptionAction=function(n,t){this.wantSubscribe=!!n;var e=this.wantSubscribe?H0.presenceSubscribe:H0.presenceUnsubscribe,o=this.connection._presenceSeq++;this._subscriptionCallbacksBySeq[o]=t,this.connection.canSend&&this.connection._sendPresenceAction(e,o,this)},Pt.prototype._handleSubscribe=function(n,t){this.wantSubscribe&&(this.subscribed=!0);var e=this._subscriptionCallback(t);this._callbackOrEmit(n,e)},Pt.prototype._handleUnsubscribe=function(n,t){this.subscribed=!1;var e=this._subscriptionCallback(t);this._callbackOrEmit(n,e)},Pt.prototype._receiveUpdate=function(n,t){var e=Kl.dig(this.localPresences,t.id);if(e)return e._ack(n,t.pv);if(n)return this.emit("error",n);var o=this,r=Kl.digOrCreate(this._remotePresenceInstances,t.id,function(){return o._createRemotePresence(t.id)});r.receiveUpdate(t)},Pt.prototype._updateRemotePresence=function(n){this.remotePresences[n.presenceId]=n.value,n.value===null&&this._removeRemotePresence(n.presenceId),this.emit("receive",n.presenceId,n.value)},Pt.prototype._broadcastAllLocalPresence=function(n){if(n)return this.emit("error",n);for(var t in this.localPresences){var e=this.localPresences[t];e.value!==null&&e.send()}},Pt.prototype._removeRemotePresence=function(n){this._remotePresenceInstances[n].destroy(),delete this._remotePresenceInstances[n],delete this.remotePresences[n]},Pt.prototype._onConnectionStateChanged=function(){if(!!this.connection.canSend){this._resubscribe();for(var n in this.localPresences)this.localPresences[n]._sendPending()}},Pt.prototype._resubscribe=function(){var n=[];for(var t in this._subscriptionCallbacksBySeq){var e=this._subscriptionCallback(t);n.push(e)}if(!this.wantSubscribe)return this._callEachOrEmit(n);var o=this;this.subscribe(function(r){o._callEachOrEmit(n,r)})},Pt.prototype._subscriptionCallback=function(n){var t=this._subscriptionCallbacksBySeq[n];return delete this._subscriptionCallbacksBySeq[n],t},Pt.prototype._callbackOrEmit=function(n,t){if(t)return Kl.nextTick(t,n);n&&this.emit("error",n)},Pt.prototype._createLocalPresence=function(n){return new Py(this,n)},Pt.prototype._createRemotePresence=function(n){return new $y(this,n)},Pt.prototype._callEachOrEmit=function(n,t){var e=Kl.callEach(n,t);!e&&t&&this.emit("error",t)};var Yi=_0,F0=Wl,jy=tn,z0=F0.CODES,Fy=nn;function nn(n,t){Yi.call(this,n,t),this.collection=this.presence.collection,this.id=this.presence.id,this._doc=this.connection.get(this.collection,this.id),this._isSending=!1,this._docDataVersionByPresenceVersion={},this._opHandler=this._transformAgainstOp.bind(this),this._createOrDelHandler=this._handleCreateOrDel.bind(this),this._loadHandler=this._handleLoad.bind(this),this._destroyHandler=this.destroy.bind(this),this._registerWithDoc()}nn.prototype=Object.create(Yi.prototype),nn.prototype.submit=function(n,t){if(!this._doc.type){if(n===null)return this._callbackOrEmit(null,t);var e={code:z0.ERR_DOC_DOES_NOT_EXIST,message:"Cannot submit presence. Document has not been created"};return this._callbackOrEmit(e,t)}this._docDataVersionByPresenceVersion[this.presenceVersion]=this._doc._dataStateVersion,Yi.prototype.submit.call(this,n,t)},nn.prototype.destroy=function(n){this._doc.removeListener("op",this._opHandler),this._doc.removeListener("create",this._createOrDelHandler),this._doc.removeListener("del",this._createOrDelHandler),this._doc.removeListener("load",this._loadHandler),this._doc.removeListener("destroy",this._destroyHandler),Yi.prototype.destroy.call(this,n)},nn.prototype._sendPending=function(){if(!this._isSending){this._isSending=!0;var n=this;this._doc.whenNothingPending(function(){n._isSending=!1,n.connection.canSend&&(n._pendingMessages.forEach(function(t){t.t=n._doc.type.uri,t.v=n._doc.version,n.connection.send(t)}),n._pendingMessages=[],n._docDataVersionByPresenceVersion={})})}},nn.prototype._registerWithDoc=function(){this._doc.on("op",this._opHandler),this._doc.on("create",this._createOrDelHandler),this._doc.on("del",this._createOrDelHandler),this._doc.on("load",this._loadHandler),this._doc.on("destroy",this._destroyHandler)},nn.prototype._transformAgainstOp=function(n,t){var e=this,o=this._doc._dataStateVersion;this._pendingMessages.forEach(function(r){var i=e._docDataVersionByPresenceVersion[r.pv];if(!(i>=o))try{r.p=e._transformPresence(r.p,n,t),e._docDataVersionByPresenceVersion[r.pv]=o}catch(l){var s=e._getCallback(r.pv);e._callbackOrEmit(l,s)}});try{this.value=this._transformPresence(this.value,n,t)}catch(r){this.emit("error",r)}},nn.prototype._handleCreateOrDel=function(){this._pendingMessages.forEach(function(n){n.p=null}),this.value=null},nn.prototype._handleLoad=function(){this.value=null,this._pendingMessages=[],this._docDataVersionByPresenceVersion={}},nn.prototype._message=function(){var n=Yi.prototype._message.call(this);return n.c=this.collection,n.d=this.id,n.v=null,n.t=null,n},nn.prototype._transformPresence=function(n,t,e){var o=this._doc.type;if(!jy.supportsPresence(o))throw new F0(z0.ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE,"Type does not support presence: "+o.name);return o.transformPresence(n,t,e)};var V0={};(function(n){var t=Wi,e=Wl,o=tn,r=e.CODES;n.checkOp=function(l){if(l==null||typeof l!="object")return new e(r.ERR_OT_OP_BADLY_FORMED,"Op must be an object");if(l.create!=null){if(typeof l.create!="object")return new e(r.ERR_OT_OP_BADLY_FORMED,"Create data must be an object");var c=l.create.type;if(typeof c!="string")return new e(r.ERR_OT_OP_BADLY_FORMED,"Missing create type");var a=t.map[c];if(a==null||typeof a!="object")return new e(r.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type")}else if(l.del!=null){if(l.del!==!0)return new e(r.ERR_OT_OP_BADLY_FORMED,"del value must be true")}else if(!("op"in l))return new e(r.ERR_OT_OP_BADLY_FORMED,"Missing op, create, or del");if(l.src!=null&&typeof l.src!="string")return new e(r.ERR_OT_OP_BADLY_FORMED,"src must be a string");if(l.seq!=null&&typeof l.seq!="number")return new e(r.ERR_OT_OP_BADLY_FORMED,"seq must be a number");if(l.src==null&&l.seq!=null||l.src!=null&&l.seq==null)return new e(r.ERR_OT_OP_BADLY_FORMED,"Both src and seq must be set together");if(l.m!=null&&typeof l.m!="object")return new e(r.ERR_OT_OP_BADLY_FORMED,"op.m must be an object or null")},n.normalizeType=function(l){return t.map[l]&&t.map[l].uri},n.apply=function(l,c){if(typeof l!="object")return new e(r.ERR_APPLY_SNAPSHOT_NOT_PROVIDED,"Missing snapshot");if(l.v!=null&&c.v!=null&&l.v!==c.v)return new e(r.ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT,"Version mismatch");if(c.create){if(l.type)return new e(r.ERR_DOC_ALREADY_CREATED,"Document already exists");var a=c.create,u=t.map[a.type];if(!u)return new e(r.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{l.data=u.create(a.data),l.type=u.uri,l.v++}catch(m){return m}}else if(c.del)l.data=void 0,l.type=null,l.v++;else if("op"in c){var f=i(l,c.op);if(f)return f;l.v++}else l.v++};function i(l,c){if(!l.type)return new e(r.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");if(c===void 0)return new e(r.ERR_OT_OP_NOT_PROVIDED,"Missing op");var a=t.map[l.type];if(!a)return new e(r.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{l.data=a.apply(l.data,c)}catch(u){return new e(r.ERR_OT_OP_NOT_APPLIED,u.message)}}n.transform=function(l,c,a){if(c.v!=null&&c.v!==a.v)return new e(r.ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM,"Version mismatch");if(a.del){if(c.create||"op"in c)return new e(r.ERR_DOC_WAS_DELETED,"Document was deleted")}else{if(a.create&&("op"in c||c.create||c.del)||"op"in a&&c.create)return new e(r.ERR_DOC_ALREADY_CREATED,"Document was created remotely");if("op"in a&&"op"in c){if(!l)return new e(r.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");if(typeof l=="string"&&(l=t.map[l],!l))return new e(r.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{c.op=l.transform(c.op,a.op,"left")}catch(u){return u}}}c.v!=null&&c.v++},n.applyOps=function(l,c,a){a=a||{};for(var u=0;u<c.length;u++){var f=c[u];if(a._normalizeLegacyJson0Ops)try{s(l,f)}catch{return new e(r.ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED,"Cannot normalize legacy json0 op")}l.v=f.v;var m=n.apply(l,f);if(m)return m}},n.transformPresence=function(l,c,a){var u=this.checkOp(c);if(u)return u;var f=l.t;if(typeof f=="string"&&(f=t.map[f]),!f)return{code:r.ERR_DOC_TYPE_NOT_RECOGNIZED,message:"Unknown type"};if(!o.supportsPresence(f))return{code:r.ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE,message:"Type does not support presence"};if(c.create||c.del){l.p=null,l.v++;return}try{l.p=l.p===null?null:f.transformPresence(l.p,c.op,a)}catch(m){return{code:r.ERR_PRESENCE_TRANSFORM_FAILED,message:m.message||m}}l.v++};function s(l,c){if(l.type===t.defaultType.uri){var a=c.op;if(!!a){var u=l.data;a.length>1&&(u=o.clone(u));for(var f=0;f<a.length;f++){var m=a[f];typeof m.lm=="string"&&(m.lm=+m.lm);for(var C=m.p,v=u,w=0;w<C.length;w++){var E=C[w];Object.prototype.toString.call(v)=="[object Array]"?C[w]=+E:v.constructor===Object&&(C[w]=E.toString()),v=v[E]}f<a.length-1&&(u=t.defaultType.apply(u,[m]))}}}}})(V0);var Qi=N0,zy=V0,Vy=Pe;function Pe(n,t){Qi.call(this,n,t),this.collection=this.presence.collection,this.id=this.presence.id,this.src=null,this.presenceVersion=null,this._doc=this.connection.get(this.collection,this.id),this._pending=null,this._opCache=null,this._pendingSetPending=!1,this._opHandler=this._handleOp.bind(this),this._createDelHandler=this._handleCreateDel.bind(this),this._loadHandler=this._handleLoad.bind(this),this._registerWithDoc()}Pe.prototype=Object.create(Qi.prototype),Pe.prototype.receiveUpdate=function(n){this._pending&&n.pv<this._pending.pv||(this.src=n.src,this._pending=n,this._setPendingPresence())},Pe.prototype.destroy=function(n){this._doc.removeListener("op",this._opHandler),this._doc.removeListener("create",this._createDelHandler),this._doc.removeListener("del",this._createDelHandler),this._doc.removeListener("load",this._loadHandler),Qi.prototype.destroy.call(this,n)},Pe.prototype._registerWithDoc=function(){this._doc.on("op",this._opHandler),this._doc.on("create",this._createDelHandler),this._doc.on("del",this._createDelHandler),this._doc.on("load",this._loadHandler)},Pe.prototype._setPendingPresence=function(){if(!this._pendingSetPending){this._pendingSetPending=!0;var n=this;this._doc.whenNothingPending(function(){if(n._pendingSetPending=!1,!!n._pending){if(n._pending.pv<n.presenceVersion)return n._pending=null;if(n._pending.v>n._doc.version)return n._doc.fetch();!n._catchUpStalePresence()||(n.value=n._pending.p,n.presenceVersion=n._pending.pv,n._pending=null,n.presence._updateRemotePresence(n))}})}},Pe.prototype._handleOp=function(n,t,e){var o=e===this.src;this._transformAgainstOp(n,o),this._cacheOp(n,o),this._setPendingPresence()},Qi.prototype._handleCreateDel=function(){this._cacheOp(null),this._setPendingPresence()},Qi.prototype._handleLoad=function(){this.value=null,this._pending=null,this._opCache=null,this.presence._updateRemotePresence(this)},Pe.prototype._transformAgainstOp=function(n,t){if(!!this.value){try{this.value=this._doc.type.transformPresence(this.value,n,t)}catch(e){return this.presence.emit("error",e)}this.presence._updateRemotePresence(this)}},Pe.prototype._catchUpStalePresence=function(){if(this._pending.v>=this._doc.version)return!0;if(!this._opCache)return this._startCachingOps(),this._doc.fetch(),this.presence.subscribe(),!1;for(;this._opCache[this._pending.v];){var n=this._opCache[this._pending.v],t=n.op,e=n.isOwnOp;t===null?(this._pending.p=null,this._pending.v++):zy.transformPresence(this._pending,t,e)}var o=this._pending.v>=this._doc.version;return o&&this._stopCachingOps(),o},Pe.prototype._startCachingOps=function(){this._opCache=[]},Pe.prototype._stopCachingOps=function(){this._opCache=null},Pe.prototype._cacheOp=function(n,t){this._opCache&&(n=n?{op:n}:null,this._opCache[this._doc.version-1]={op:n,isOwnOp:t})};var U0=j0,Uy=Fy,qy=Vy;function Ar(n,t,e){var o=Ar.channel(t,e);U0.call(this,n,o),this.collection=t,this.id=e}var Wy=Ar;Ar.prototype=Object.create(U0.prototype),Ar.channel=function(n,t){return n+"."+t},Ar.prototype._createLocalPresence=function(n){return new Uy(this,n)},Ar.prototype._createRemotePresence=function(n){return new qy(this,n)};var Gy=Zy;function Zy(n,t,e,o,r){this.id=n,this.v=t,this.type=e,this.data=o,this.m=r}var Yy=Gy,q0=co,W0=Ki;function Ki(n,t,e,o,r){if(q0.EventEmitter.call(this),typeof r!="function")throw new Error("Callback is required for SnapshotRequest");this.requestId=t,this.connection=n,this.id=o,this.collection=e,this.callback=r,this.sent=!1}q0.mixin(Ki),Ki.prototype.send=function(){!this.connection.canSend||(this.connection.send(this._message()),this.sent=!0)},Ki.prototype._onConnectionStateChanged=function(){this.connection.canSend?this.sent||this.send():this.sent=!1},Ki.prototype._handleResponse=function(n,t){if(this.emit("ready"),n)return this.callback(n);var e=t.meta?t.meta:null,o=new Yy(this.id,t.v,t.type,t.data,e);this.callback(null,o)};var G0=W0,Qy=tn,Ky=qo.ACTIONS,Jy=_d;function _d(n,t,e,o,r,i){if(G0.call(this,n,t,e,o,i),!Qy.isValidVersion(r))throw new Error("Snapshot version must be a positive integer or null");this.version=r}_d.prototype=Object.create(G0.prototype),_d.prototype._message=function(){return{a:Ky.snapshotFetch,id:this.requestId,c:this.collection,d:this.id,v:this.version}};var Z0=W0,Xy=tn,tw=qo.ACTIONS,ew=Nd;function Nd(n,t,e,o,r,i){if(Z0.call(this,n,t,e,o,i),!Xy.isValidTimestamp(r))throw new Error("Snapshot timestamp must be a positive integer or null");this.timestamp=r}Nd.prototype=Object.create(Z0.prototype),Nd.prototype._message=function(){return{a:tw.snapshotFetchByTimestamp,id:this.requestId,c:this.collection,d:this.id,ts:this.timestamp}};var nw=Ty,ow=Ay,rw=j0,Y0=Wy,iw=Jy,sw=ew,Q0=co,Or=Wl,pt=qo.ACTIONS,K0=Wi,on=tn,Ji=x0,Xi=Or.CODES;function J0(n){return n.readyState===0||n.readyState===1?"connecting":"disconnected"}var lw=J;function J(n){Q0.EventEmitter.call(this),this.collections={},this.nextQueryId=1,this.nextSnapshotRequestId=1,this.queries={},this._presences={},this._snapshotRequests={},this.seq=1,this._presenceSeq=1,this.id=null,this.agent=null,this.debug=!1,this.state=J0(n),this.bindToSocket(n)}Q0.mixin(J),J.prototype.bindToSocket=function(n){this.socket&&(this.socket.close(),this.socket.onmessage=null,this.socket.onopen=null,this.socket.onerror=null,this.socket.onclose=null),this.socket=n;var t=J0(n);this._setState(t),this.canSend=!1;var e=this;n.onmessage=function(o){try{var r=typeof o.data=="string"?JSON.parse(o.data):o.data}catch{Ji.warn("Failed to parse message",o);return}e.debug&&Ji.info("RECV",JSON.stringify(r));var i={data:r};if(e.emit("receive",i),!!i.data)try{e.handleMessage(i.data)}catch(s){on.nextTick(function(){e.emit("error",s)})}},n.readyState===1&&e._initializeHandshake(),n.onopen=function(){e._setState("connecting"),e._initializeHandshake()},n.onerror=function(o){e.emit("connection error",o)},n.onclose=function(o){o==="closed"||o==="Closed"?e._setState("closed",o):o==="stopped"||o==="Stopped by server"?e._setState("stopped",o):e._setState("disconnected",o)}},J.prototype.handleMessage=function(n){var t=null;switch(n.error&&(t=X0(n.error,n),delete n.error),n.a){case pt.initLegacy:return this._handleLegacyInit(n);case pt.handshake:return this._handleHandshake(t,n);case pt.queryFetch:var e=this.queries[n.id];e&&e._handleFetch(t,n.data,n.extra);return;case pt.querySubscribe:var e=this.queries[n.id];e&&e._handleSubscribe(t,n.data,n.extra);return;case pt.queryUnsubscribe:return;case pt.queryUpdate:var e=this.queries[n.id];if(!e)return;if(t)return e._handleError(t);n.diff&&e._handleDiff(n.diff),n.hasOwnProperty("extra")&&e._handleExtra(n.extra);return;case pt.bulkFetch:return this._handleBulkMessage(t,n,"_handleFetch");case pt.bulkSubscribe:case pt.bulkUnsubscribe:return this._handleBulkMessage(t,n,"_handleSubscribe");case pt.snapshotFetch:case pt.snapshotFetchByTimestamp:return this._handleSnapshotFetch(t,n);case pt.fetch:var o=this.getExisting(n.c,n.d);o&&o._handleFetch(t,n.data);return;case pt.subscribe:case pt.unsubscribe:var o=this.getExisting(n.c,n.d);o&&o._handleSubscribe(t,n.data);return;case pt.op:var o=this.getExisting(n.c,n.d);o&&o._handleOp(t,n);return;case pt.presence:return this._handlePresence(t,n);case pt.presenceSubscribe:return this._handlePresenceSubscribe(t,n);case pt.presenceUnsubscribe:return this._handlePresenceUnsubscribe(t,n);case pt.presenceRequest:return this._handlePresenceRequest(t,n);case pt.pingPong:return this._handlePingPong(t);default:Ji.warn("Ignoring unrecognized message",n)}};function X0(n,t){var e=new Error(n.message);return e.code=n.code,t&&(e.data=t),e}J.prototype._handleBulkMessage=function(n,t,e){if(t.data)for(var o in t.data){var r=t.data[o],i=this.getExisting(t.c,o);i&&(n?i[e](n):r.error?i[e](X0(r.error)):i[e](null,r))}else if(Array.isArray(t.b))for(var s=0;s<t.b.length;s++){var o=t.b[s],i=this.getExisting(t.c,o);i&&i[e](n)}else if(t.b)for(var o in t.b){var i=this.getExisting(t.c,o);i&&i[e](n)}else Ji.error("Invalid bulk message",t)},J.prototype._reset=function(){this.agent=null},J.prototype._setState=function(n,t){if(this.state!==n){if(n==="connecting"&&this.state!=="disconnected"&&this.state!=="stopped"&&this.state!=="closed"||n==="connected"&&this.state!=="connecting"){var e=new Or(Xi.ERR_CONNECTION_STATE_TRANSITION_INVALID,"Cannot transition directly from "+this.state+" to "+n);return this.emit("error",e)}this.state=n,this.canSend=n==="connected",(n==="disconnected"||n==="stopped"||n==="closed")&&this._reset(),this.startBulk();for(var o in this.queries){var r=this.queries[o];r._onConnectionStateChanged()}for(var i in this.collections){var s=this.collections[i];for(var o in s)s[o]._onConnectionStateChanged()}for(var l in this._presences)this._presences[l]._onConnectionStateChanged();for(var o in this._snapshotRequests){var c=this._snapshotRequests[o];c._onConnectionStateChanged()}this.endBulk(),this.emit(n,t),this.emit("state",n,t)}},J.prototype.startBulk=function(){this.bulk||(this.bulk={})},J.prototype.endBulk=function(){if(this.bulk)for(var n in this.bulk){var t=this.bulk[n];this._sendBulk("f",n,t.f),this._sendBulk("s",n,t.s),this._sendBulk("u",n,t.u)}this.bulk=null},J.prototype._sendBulk=function(n,t,e){if(!!e){var o=[],r={},i=0,s;for(var l in e){var c=e[l];c==null?o.push(l):(r[l]=c,s=l,i++)}if(o.length===1){var l=o[0];this.send({a:n,c:t,d:l})}else o.length&&this.send({a:"b"+n,c:t,b:o});if(i===1){var a=r[s];this.send({a:n,c:t,d:s,v:a})}else i&&this.send({a:"b"+n,c:t,b:r})}},J.prototype._sendActions=function(n,t,e){if(this._addDoc(t),this.bulk){var o=this.bulk[t.collection]||(this.bulk[t.collection]={}),r=o[n]||(o[n]={}),i=r.hasOwnProperty(t.id);return r[t.id]=e,i}else{var s={a:n,c:t.collection,d:t.id,v:e};this.send(s)}},J.prototype.sendFetch=function(n){return this._sendActions(pt.fetch,n,n.version)},J.prototype.sendSubscribe=function(n){return this._sendActions(pt.subscribe,n,n.version)},J.prototype.sendUnsubscribe=function(n){return this._sendActions(pt.unsubscribe,n)},J.prototype.sendOp=function(n,t){this._addDoc(n);var e={a:pt.op,c:n.collection,d:n.id,v:n.version,src:t.src,seq:t.seq,x:{}};"op"in t&&(e.op=t.op),t.create&&(e.create=t.create),t.del&&(e.del=t.del),n.submitSource&&(e.x.source=t.source),this.send(e)},J.prototype.send=function(n){this.debug&&Ji.info("SEND",JSON.stringify(n)),this.emit("send",n),this.socket.send(JSON.stringify(n))},J.prototype.ping=function(){if(!this.canSend)throw new Or(Xi.ERR_CANNOT_PING_OFFLINE,"Socket must be CONNECTED to ping");var n={a:pt.pingPong};this.send(n)},J.prototype.close=function(){this.socket.close()},J.prototype.getExisting=function(n,t){if(this.collections[n])return this.collections[n][t]},J.prototype.get=function(n,t){var e=this.collections[n]||(this.collections[n]={}),o=e[t];return o||(o=e[t]=new nw(this,n,t),this.emit("doc",o)),o._wantsDestroy=!1,o},J.prototype._destroyDoc=function(n){!n._wantsDestroy||(on.digAndRemove(this.collections,n.collection,n.id),n.emit("destroy"))},J.prototype._addDoc=function(n){var t=this.collections[n.collection];t||(t=this.collections[n.collection]={}),t[n.id]!==n&&(t[n.id]=n)},J.prototype._createQuery=function(n,t,e,o,r){var i=this.nextQueryId++,s=new ow(n,this,i,t,e,o,r);return this.queries[i]=s,s.send(),s},J.prototype._destroyQuery=function(n){delete this.queries[n.id]},J.prototype.createFetchQuery=function(n,t,e,o){return this._createQuery(pt.queryFetch,n,t,e,o)},J.prototype.createSubscribeQuery=function(n,t,e,o){return this._createQuery(pt.querySubscribe,n,t,e,o)},J.prototype.hasPending=function(){return!!(this._firstDoc(Jl)||this._firstQuery(Jl)||this._firstSnapshotRequest())};function Jl(n){return n.hasPending()}J.prototype.hasWritePending=function(){return!!this._firstDoc(cw)};function cw(n){return n.hasWritePending()}J.prototype.whenNothingPending=function(n){var t=this._firstDoc(Jl);if(t){t.once("nothing pending",this._nothingPendingRetry(n));return}var e=this._firstQuery(Jl);if(e){e.once("ready",this._nothingPendingRetry(n));return}var o=this._firstSnapshotRequest();if(o){o.once("ready",this._nothingPendingRetry(n));return}on.nextTick(n)},J.prototype._nothingPendingRetry=function(n){var t=this;return function(){on.nextTick(function(){t.whenNothingPending(n)})}},J.prototype._firstDoc=function(n){for(var t in this.collections){var e=this.collections[t];for(var o in e){var r=e[o];if(n(r))return r}}},J.prototype._firstQuery=function(n){for(var t in this.queries){var e=this.queries[t];if(n(e))return e}},J.prototype._firstSnapshotRequest=function(){for(var n in this._snapshotRequests)return this._snapshotRequests[n]},J.prototype.fetchSnapshot=function(n,t,e,o){typeof e=="function"&&(o=e,e=null);var r=this.nextSnapshotRequestId++,i=new iw(this,r,n,t,e,o);this._snapshotRequests[i.requestId]=i,i.send()},J.prototype.fetchSnapshotByTimestamp=function(n,t,e,o){typeof e=="function"&&(o=e,e=null);var r=this.nextSnapshotRequestId++,i=new sw(this,r,n,t,e,o);this._snapshotRequests[i.requestId]=i,i.send()},J.prototype._handleSnapshotFetch=function(n,t){var e=this._snapshotRequests[t.id];!e||(delete this._snapshotRequests[t.id],e._handleResponse(n,t))},J.prototype._handleLegacyInit=function(n){if(n.protocolMinor)return this._initializeHandshake();this._initialize(n)},J.prototype._initializeHandshake=function(){this.send({a:pt.handshake,id:this.id})},J.prototype._handleHandshake=function(n,t){if(n)return this.emit("error",n);this._initialize(t)},J.prototype._handlePingPong=function(n){if(n)return this.emit("error",n);this.emit("pong")},J.prototype._initialize=function(n){if(this.state==="connecting"){if(n.protocol!==1)return this.emit("error",new Or(Xi.ERR_PROTOCOL_VERSION_NOT_SUPPORTED,"Unsupported protocol version: "+n.protocol));if(K0.map[n.type]!==K0.defaultType)return this.emit("error",new Or(Xi.ERR_DEFAULT_TYPE_MISMATCH,n.type+" does not match the server default type"));if(typeof n.id!="string")return this.emit("error",new Or(Xi.ERR_CLIENT_ID_BADLY_FORMED,"Client id must be a string"));this.id=n.id,this._setState("connected")}},J.prototype.getPresence=function(n){var t=this,e=on.digOrCreate(this._presences,n,function(){return new rw(t,n)});return e._wantsDestroy=!1,e},J.prototype.getDocPresence=function(n,t){var e=Y0.channel(n,t),o=this,r=on.digOrCreate(this._presences,e,function(){return new Y0(o,n,t)});return r._wantsDestroy=!1,r},J.prototype._sendPresenceAction=function(n,t,e){this._addPresence(e);var o={a:n,ch:e.channel,seq:t};return this.send(o),o.seq},J.prototype._addPresence=function(n){on.digOrCreate(this._presences,n.channel,function(){return n})},J.prototype._handlePresenceSubscribe=function(n,t){var e=on.dig(this._presences,t.ch);e&&e._handleSubscribe(n,t.seq)},J.prototype._handlePresenceUnsubscribe=function(n,t){var e=on.dig(this._presences,t.ch);e&&e._handleUnsubscribe(n,t.seq)},J.prototype._handlePresence=function(n,t){var e=on.dig(this._presences,t.ch);e&&e._receiveUpdate(n,t)},J.prototype._handlePresenceRequest=function(n,t){var e=on.dig(this._presences,t.ch);e&&e._broadcastAllLocalPresence(n,t)};var t5=lw,aw=Wi;const Xl={err:1001,msg:"user auth error",name:"AuthError"},dw={err:1002,msg:"you don't have required permission",name:"PermissionError"},Pd={err:1003,msg:"Too many user connected",name:"MaxUserError"},ts={err:1004,msg:"document server changed, reload it",name:"RequestReloadError"},uw={err:1005,msg:"app id must be at least 2 chars, doc id must be at least 5 chars",name:"DocIdError"},hw={err:1028,msg:"upload file ext not allowed",name:"FileExtError"},es="x-live-editor-token",tc="x-live-editor-base-url",ae=y("auth-connection");function fw(n){try{n()}catch(t){ae.error(t)}}class mw{constructor(t,e){h(this,"connection");h(this,"ws");h(this,"retryCount");h(this,"events",new Mf.EventEmitter);h(this,"token",null);h(this,"resourceToken",null);this.url=t,this.reAuthFunc=e,this.retryCount=0}getBaseURL(){const t=new URL(this.url);return`${t.protocol==="wss:"?"https:":"http:"}//${t.host}${t.pathname}`}getBase64BaseURL(){return Lo(this.getBaseURL())}async auth(t){d(ae,t.token,"no auth token");const e=`${this.getBaseURL()}/auth`,o=await window.fetch(e,{method:"GET",headers:{[es]:t.token,[tc]:this.getBase64BaseURL()},credentials:"include"});if(o.status!==200)throw new Error("http auth error");return this.token=t.token,await o.json()}async logout(){if(!this.token)return;const t=`${this.getBaseURL()}/logout`;await window.fetch(t,{method:"GET",headers:{[tc]:Lo(this.getBaseURL())}})}async init(t){const e=await this.auth(t);this.resourceToken=e.read,this.ws=new a8.default(this.url,void 0,{maxReconnectionDelay:2500,minReconnectionDelay:1e3}),this.connection=Object.create(t5.prototype),d(ae,this.connection,"no this.connection"),this.ws,this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:t})};const o=this.connection.handleMessage.bind(this.connection);this.connection.handleMessage=r=>{var s;const i=r;if(this.connection&&(this.connection.lastReceiveTime=Date.now()),"err"in i||i.a==="pong")this.handleMessage(i);else{Object.prototype.hasOwnProperty.call(i,"a")&&i.a!=="init"&&i.a!=="hs"&&(this.retryCount=0);try{o(i)}catch(l){if((l==null?void 0:l.type)==="writeConflict"){this.emitWriteConflictError(l);return}if((s=l==null?void 0:l.message)!=null&&s.startsWith("Cannot invert subtype")){this.emitWriteConflictError(l);return}throw l}}},t5.apply(this.connection,[this.ws])}async handleAuthError(){if(this.reAuthFunc&&this.retryCount<5){this.retryCount+=1,ae.info(`retrying re-auth attempt no. ${this.retryCount}`);try{if(this.connection){const t=await this.reAuthFunc();await this.auth(t),this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:t})}}}catch(t){ae.error(t),setTimeout(()=>this.handleAuthError(),0)}}else ae.error("auth error, cannot retry anymore"),this.emitAuthError(),this.end(!1)}emitAuthError(){const t=new Error(Xl.msg);t.code=Xl.err,this.events.emit("error",t)}emitRequestReloadError(){const t=new Error(ts.msg);t.code=ts.err,this.events.emit("requestReloadError",t)}emitWriteConflictError(t){this.events.emit("writeConflictError",t)}emitMaxUsersError(){this.events.emit("maxUsersError"),this.end(!1)}handleMessage(t){const e=t;if(e.a==="pong")return;const o=e.err;if(o===Xl.err)ae.warn("auth error"),this.handleAuthError();else if(o===Pd.err)ae.warn(Pd.msg),this.emitMaxUsersError();else if(o===ts.err){ae.warn(ts.msg);try{this.emitRequestReloadError()}catch(r){ae.error(`error occurred while process reload error: ${JSON.stringify(r)}`)}finally{this.end(!1)}}else ae.error(`unknown message received: ${JSON.stringify(e)}`),this.emitAuthError()}get(t,e){return d(ae,this.connection,"no this.connection"),this.connection.get(t,e)}addEventListener(t,e){t==="error"?this.events.addListener(t,e):(d(ae,this.ws,"no this.ws"),this.ws.addEventListener(t,e))}onWriteConflictError(t){this.events.addListener("writeConflictError",t)}onMaxUsersError(t){d(ae,this.events.listenerCount("maxUsersError")===0,"too many maxUserError listener"),this.events.addListener("maxUsersError",t)}onRequestReloadError(t){d(ae,this.events.listenerCount("requestReloadError")===0,"to many requestReloadError listener"),this.events.addListener("requestReloadError",t)}end(t){var e;this.reAuthFunc=void 0,this.events.removeAllListeners(),fw(()=>{var o;return(o=this.connection)==null?void 0:o.close()}),this.connection=void 0,(e=this.ws)==null||e.close(),this.ws=void 0,t&&this.logout()}}y("utils/file");function gw(){function n(){return new Promise(t=>{const e=new FileReader;e.onload=()=>{t(e.result)},e.readAsArrayBuffer(this)})}File.prototype.arrayBuffer=File.prototype.arrayBuffer||n,Blob.prototype.arrayBuffer=Blob.prototype.arrayBuffer||n}gw();async function pw(n){const e=n.size,o=Math.floor((e+102400-1)/102400),r=new d8.Hash;for(let s=0;s<o;s++){const l=s*102400;let c=l+102400;c>e&&(c=e);const u=await n.slice(l,c,n.type).arrayBuffer();r.update(new Uint8Array(u))}const i=r.digest();return Lo(i)}const vn=y("sharedb-doc/client");class Cw{constructor(t,e,o){h(this,"connection");h(this,"auth");h(this,"doc",null);h(this,"reAuthFunc");h(this,"clientId",N());h(this,"getDoc",async()=>{const t=o=>new Promise((r,i)=>{o.fetch(s=>{s?i(s):r()})});d(vn,!this.doc,"This websocket has opened a doc."),await this.connection.init(this.auth);const e=this.connection.get(this.auth.appId,this.auth.docId);return this.doc=e,await t(e),vn.debug(e),e});this.auth=t;const r=`${e}/${this.auth.appId}/${this.auth.docId}`;aw.register(Ys.type),this.connection=new mw(r,o),this.reAuthFunc=o}editorServer(){const t=this.apiServer(),e=`/${this.auth.appId}/${this.auth.docId}`;return d(vn,t.endsWith(e),`invalid api server: ${t}, ${e}`),t.substr(0,t.length-e.length)}close(t){this.connection.end(t),this.doc=null}on(t,e){this.connection.addEventListener(t,o=>{(t==="error"||this.doc)&&e(o)})}onWriteConflictError(t){this.connection.onWriteConflictError(t)}onMaxUsersError(t){this.connection.onMaxUsersError(t)}onRequestReloadError(t){this.connection.onRequestReloadError(t)}async authOnly(){await this.connection.auth(this.auth)}getResourceToken(){return this.connection.resourceToken}hasDocContainer(){return!!this.doc}apiServer(){const t=this.connection.url;if(t.startsWith("ws://"))return`http://${t.substring(5)}`;if(t.startsWith("wss://"))return`https://${t.substring(6)}`;throw new Error(`invalid server url: ${t}`)}async getFileUrlByHash(t,e,o,r,i){try{const s=`${t}/${e}`,l=await this.request(s,{method:"post",headers:{...i},data:{name:o,size:r}});return l.data&&Array.isArray(l.data)&&l.data.length===1?l.data[0]:""}catch{return""}}async getFileUrlsByHashes(t){const o=`${this.apiServer()}/resources`;let r=[];t.forEach(l=>{const c=l.split("|");r.push(...c)}),r=Array.from(new Set(r));const i=r.map(l=>this.getFileUrlByHash(o,l,"",0,{[es]:this.connection.token}));return await Promise.all(i)}async uploadFile(t,e,o,r,i){let s=e.size;if(s===0)throw new Error("file is empty");s+=500;const l=C=>{vn.info(`on progress: ${C.loaded}`);let v=C.loaded*100/s;v>100&&(v=100),r(v)},c=await pw(e),a=await this.getFileUrlByHash(t,c,e.name,e.size,o);if(a)return r(-1),a;let u=t;i!=null&&i.thumbnail&&(u+="/thumbnail");const f=new FormData;f.append("file-size",`${e.size}`),f.append("file-hash",c),f.append("file",e,e.name);const m=await this.request(u,{method:"post",data:f,withCredentials:!0,headers:{...o},onUploadProgress:l});return vn.info(m),r(100),Array.isArray(m.data)?m.data[0]:m.data}async uploadResource(t,e=()=>{},o){const i=`${this.apiServer()}/resources`;d(vn,this.connection.token,"no connection token");const s=await this.uploadFile(i,t,{[es]:this.connection.token},e,o);return d(vn,s,"no result"),s}async request(t,e){var i,s;let o=this.connection.token,r;for(let l=0;l<2;l++){const c=e||{};c.url=t,c.headers||(c.headers={}),d(vn,o,"no token"),c.headers={...c.headers,[es]:o,[tc]:this.connection.getBase64BaseURL()};try{return await l8.default(t,c)}catch(a){if(r=a,((i=a==null?void 0:a.response)==null?void 0:i.status)===403&&this.reAuthFunc){const u=await this.reAuthFunc();if(await this.connection.auth(u),!u.token)throw a;o=u.token;continue}throw(s=a.response)!=null&&s.data&&(a.responseData=a.response.data),a}}throw d(vn,r,"no error"),r}async getVersions(){const e=`${this.apiServer()}/versions`,o=await this.request(e),r=o.data.versions,i=o.data.latest;return i&&r.findIndex(s=>s.version===i)===-1&&r.unshift({version:-1,tag:"",published:!1}),r}async getVersion(t){const o=`${this.apiServer()}/versions/${t}`,r=await this.request(o);return JSON.parse(r.data.data)}async getLatestVersion(){const e=`${this.apiServer()}/versions/latest`,o=await this.request(e);return JSON.parse(o.data.data)}async getVersionOps(t,e){let r=`${this.apiServer()}/versions/before/${t}?withOp=true`;e!==void 0&&e!==0&&(r+=`&from=${e}`);const i=await this.request(r),s=i.data.ops,l=c8.default(s,u=>!!u.create);let c=null;l!==-1&&(c=s[l],s.splice(0,l+1));let a;return c?(d(vn,c.create,"no createDoc.create"),a=c.create.data):a=JSON.parse(i.data.data),a.blocks||(a.blocks=[]),{doc:a,ops:i.data.ops}}async revertVersion(t){const o=`${this.apiServer()}/versions/revert/${t}`;await this.request(o,{method:"post",data:{}})}async createVersion(t,e){const r=`${this.apiServer()}/versions`;return(await this.request(r,{method:"post",data:{publish:e,tag:t}})).data}async recognizeLink(t){const o=`${this.apiServer()}/resources/external/${Lo(t)}`;return(await this.request(o)).data}buildResourceUrl(t,e){if(!t)return"";if(t.startsWith("https:")||t.startsWith("http:")||t.startsWith("file:")||t.startsWith("data:")||t.startsWith("blob:"))return t;let r=`${this.apiServer()}/resources/${encodeURIComponent(t)}`;const i=[];if(e!=null&&e.withToken&&i.push(`token=${this.getResourceToken()}`),e!=null&&e.downloadFileName&&i.push(`&fileName=${encodeURIComponent(e.downloadFileName)}`),i.length>0){const s=i.join("&");r+=`?${s}`}return r}}function bw(){return{blocks:[{id:N(),type:"text",text:[]}],comments:{},meta:{}}}const $d=y("block-ids");class vw{constructor(){h(this,"ids",new Map)}onInsertBlock(t){const e=Array.from(this.ids.keys()).sort((r,i)=>i-r);for(let r=0;r<e.length;r++){const i=e[r];if(i>=t){const s=this.ids.get(i);d($d,s!==void 0,"old id is not exists"),this.ids.delete(i),this.ids.set(i+1,s)}}const o=N();this.ids.set(t,o)}onDeleteBlock(t){this.ids.delete(t);const e=Array.from(this.ids.keys()).sort((o,r)=>o-r);for(let o=0;o<e.length;o++){const r=e[o];if(r>t){const i=this.ids.get(r);d($d,i!==void 0,"old id is not exists"),this.ids.delete(r),this.ids.set(r-1,i)}}}getId(t){let e=this.ids.get(t);return e||(e=N(),this.ids.set(t,e)),e}getById(t){return Array.from(this.ids.entries()).find(([,e])=>e===t)}}class kw{constructor(){h(this,"ids",new Map)}getContainerIds(t){let e=this.ids.get(t);return e||(e=new vw,this.ids.set(t,e)),e}onInsertBlock(t,e){this.getContainerIds(t).onInsertBlock(e)}onDeleteBlock(t,e){this.getContainerIds(t).onDeleteBlock(e)}getBlockId(t,e){return this.getContainerIds(t).getId(e)}getBlockIndexById(t){const e=Array.from(this.ids.entries());for(let o=0;o<e.length;o++){const r=e[o],i=r[1].getById(t);if(i)return{containerId:r[0],blockIndex:i[0]}}return d($d,!1,"fault error: failed to get block index"),{containerId:"error",blockIndex:-1}}}class e5{constructor(t=new Set,e=new Map){this.deletedKeys=t,this.insertedValues=e}insert(t,e){this.insertedValues.set(t,e)}delete(t){this.deletedKeys.add(t)}toDocBlockDelta(){const t={};return this.insertedValues.forEach((e,o)=>{t[o]=e}),{insert:t,delete:Array.from(this.deletedKeys)}}}const Nt=y("op-parser");function _r(n){return n==="blocks"?"root":n}class yw{constructor(t,e){h(this,"updatingBlockDataDeltaMap",new Map);h(this,"blockIds",new kw);this.handler=t,this.local=e}onDeleteBlock(t,e){const o=this.blockIds.getBlockId(t,e);this.blockIds.onDeleteBlock(t,e);const r=this.updatingBlockDataDeltaMap.get(o);r&&(Nt.debug(`ignore update object data before delete block: ${JSON.stringify(r)}`),this.updatingBlockDataDeltaMap.delete(o)),this.handler.onDeleteBlock(_r(t),e,this.local)}onInsertBlock(t,e,o){this.blockIds.onInsertBlock(t,e),this.handler.onInsertBlock(_r(t),e,o,this.local)}onUpdateBlockText(t,e,o){this.handler.onUpdateBlockText(_r(t),e,o,this.local)}onDeleteBlockData(t,e,o){const r=this.blockIds.getBlockId(t,e);let i=this.updatingBlockDataDeltaMap.get(r);i||(i=new e5,this.updatingBlockDataDeltaMap.set(r,i)),i.delete(o)}onInsertBlockData(t,e,o,r){const i=this.blockIds.getBlockId(t,e);let s=this.updatingBlockDataDeltaMap.get(i);s||(s=new e5,this.updatingBlockDataDeltaMap.set(i,s)),s.insert(o,r)}executeUpdateBlockDataActions(){Array.from(this.updatingBlockDataDeltaMap.entries()).forEach(([t,e])=>{const{containerId:o,blockIndex:r}=this.blockIds.getBlockIndexById(t);this.handler.onUpdateBlockData(_r(o),r,e.toDocBlockDelta(),this.local)})}}class n5{}class Hd{constructor(t){h(this,"key");this.key=t}}function ww(n,t,e){const o=t.concat(),r=o[0];if(typeof r!="number"||(o.shift(),o.length===1))return!1;const i=o[0];if(typeof i!="object"||!i.i||Object.keys(i).length!==1)return!1;for(let l=1;l<o.length;l++){const c=o[l];if(!Array.isArray(c)||c.length!==2||typeof c[0]!="string")return!1;const u=c[1];if(typeof u!="object"||u.i===void 0||Object.keys(u).length!==1)return!1}const s=i.i;d(Nt,s.id,"block id is required"),d(Nt,s.type,"block type is required");for(let l=1;l<o.length;l++){const c=o[l],a=c[0],u=c[1];s[a]=u.i}return e.onInsertBlock(n,r,s),!0}function jd(n,t,e,o){if(e==="upsert"&&ww(n,t,o))return;d(Nt,Array.isArray(t),`invalid block op: ${n}, ${JSON.stringify(t)}`);const r=t.concat(),i=r[0];r.shift();const s=[];for(;r.length>0;){const l=r[0];if(l==="text"){const c=r[1];if(d(Nt,typeof c=="object",`invalid block op: ${n}, ${JSON.stringify(t)}`),d(Nt,c.et==="rich-text",`invalid block op: ${n}, ${JSON.stringify(t)}`),r.splice(0,2),e==="upsert"){const u=c.e;o.onUpdateBlockText(n,i,u)}d(Nt,r.length===0,`invalid block ops.length !== 0, ${JSON.stringify(r)}`)}else if(Array.isArray(l)){d(Nt,l.length===2,`invalid block op: data.length !== 2, ${JSON.stringify(l)}`);const c=l[0];d(Nt,typeof c=="string",`invalid block op: key ${JSON.stringify(c)}`);const a=l[1];if(c==="text"){if(d(Nt,typeof a=="object",`invalid opData type, ${JSON.stringify(a)}`),a.i&&e==="upsert"&&o.onInsertBlockData(n,i,c,a.i),a.r&&e==="remove"&&o.onDeleteBlockData(n,i,c),a.et==="rich-text"&&e==="upsert"){const f=a.e;o.onUpdateBlockText(n,i,f)}}else e==="remove"&&a.r&&s.push(new Hd(c)),e==="upsert"&&a.i&&o.onInsertBlockData(n,i,c,a.i);r.shift()}else if(typeof l=="object"){const c=l;e==="remove"&&c.r&&s.push(new n5),e==="upsert"&&c.i&&o.onInsertBlock(n,i,c.i),r.shift()}else{d(Nt,typeof l=="string","data is not string"),d(Nt,l!=="text","data !== 'text'"),d(Nt,r.length===2,`invalid block op: ops.length !== 2, ${JSON.stringify(r)}`);const c=l,a=r[1];e==="remove"&&a.r&&s.push(new Hd(c)),e==="upsert"&&a.i&&o.onInsertBlockData(n,i,c,a.i),r.splice(0,2)}}s.reverse(),s.forEach(l=>{l instanceof n5?o.onDeleteBlock(n,i):l instanceof Hd?o.onDeleteBlockData(n,i,l.key):d(Nt,!1,`invalid action type: ${typeof l}, ${JSON.stringify(l)}`)})}function Bw(n,t,e,o){Nt.warn(`unsupported meta op, ${JSON.stringify(n)}`)}function Ew(n,t,e,o){const r=n[1],i=n[2];d(Nt,r,`invalid comment op, no commentId: ${JSON.stringify(n)}`),d(Nt,i,`invalid comment op, no actions: ${JSON.stringify(n)}`),typeof i=="string"?Nt.error(`unknown comment op, ${JSON.stringify(n)}`):i.i&&i.r?t==="upsert"&&o.onUpdateComment(r,e.local):i.i?t==="upsert"&&o.onCreateComment(r,e.local):i.r?t==="remove"&&o.onDeleteComment(r,e.local):Nt.error(`unknown comment op, ${JSON.stringify(n)}`)}function Fd(n,t,e,o){const r=n[0];if(Array.isArray(r)){r.forEach(l=>{Fd(l,t,e,o)});return}const i=r;if(d(Nt,typeof i=="string",`invalid container id: ${JSON.stringify(n)}`),i==="meta"){Bw(n);return}if(i==="comments"){Ew(n,t,e,o);return}const s=i;if(Array.isArray(n[1]))t==="remove"?n.slice(1).reverse().forEach(l=>{jd(s,l,t,e)}):n.slice(1).forEach(l=>{jd(s,l,t,e)});else if(typeof n[1]=="object"){const l=n[1];l.r&&t==="remove"&&o.onDeleteContainer(_r(s),e.local),l.i&&t==="upsert"&&o.onCreateContainer(_r(s),l.i,e.local)}else d(Nt,typeof n[1]=="number",`invalid ops[1], not a number: ${JSON.stringify(n)}`),jd(s,n.slice(1),t,e)}function o5(n,t,e){const o=new yw(t,e);for(let r=0;r<2;r++){const i=r===0?"remove":"upsert",s=Y.default(n),l=s[0];Array.isArray(l)?s.forEach(c=>{Fd(c,i,o,t)}):Fd(s,i,o,t)}o.executeUpdateBlockDataActions()}const Iw=y("sharedb-comments");function xw(n){if(n.doc)return Y.default(n.doc);const t=n.blocks;d(Iw,t,"no comment blocks");const e={blocks:{root:t},meta:{},comments:{}};return Object.entries(n).forEach(([o,r])=>{Array.isArray(r)&&(e.blocks[o]=r)}),Y.default(e)}function Sw(n){const{id:t,groupId:e,userId:o,displayName:r,avatarUrl:i,abstract:s,created:l,modified:c}=n;return{id:t,groupId:e,userId:o,displayName:r,avatarUrl:i,abstract:s,created:l,modified:c}}function r5(n,t){const e={...n,doc:t};return delete e.blocks,Y.default(e)}const Dt=y("sharedb-doc/doc-container"),i5="ot-json1";Ys.type.registerSubtype(dy.type),Ys.type.name=i5,Ys.type.invert=null;class ec extends ki{constructor(e,o){super();h(this,"doc");h(this,"client");h(this,"localPresence");h(this,"remoteCaretHandler",new cy);h(this,"batching",0);h(this,"status","clean");h(this,"handleNothingPending",()=>{this.setStatus("clean")});h(this,"handleCreate",()=>{this.callbacks.forEach(e=>{var o;return(o=e.onRequestReload)==null?void 0:o.call(e,"doc created")})});h(this,"handleDel",()=>{});h(this,"insertObject",async(e,o,r)=>{const i=[e,o,{i:r}];return this.submitOp(i)});h(this,"deleteObject",async(e,o)=>{const r=[e,o,{r:!0}];return this.submitOp(r)});h(this,"replaceObject",async(e,o,r)=>{const i=[e,o,{r:!0,i:r}];return this.submitOp(i)});h(this,"updateObject",async(e,o,r)=>{const i=this.data()[e][o],s=[e,o];return Object.entries(r).forEach(([l,c])=>{if(!Zs.default(i[l],c))if(i[l]===void 0){if(c!=null){const a={i:c};s.push([l,a])}}else if(c==null){const a={r:!0};s.push([l,a])}else{const a={r:!0,i:c};s.push([l,a])}}),Object.entries(i).forEach(([l,c])=>{if((r[l]===void 0||r[l]===null)&&c!==void 0){const a={r:!0};s.push([l,a])}}),s.length<=2?Promise.resolve():this.submitOp(s)});h(this,"broadcastMessage",async e=>{const o={type:"custom",data:e,clientId:this.client.clientId};this.localPresence&&this.localPresence.submit(o)});h(this,"data",()=>this.doc.data);h(this,"submitOp",async e=>new Promise((o,r)=>{this.setStatus("dirty"),this.doc.submitOp(e,{},i=>{i?(Dt.error(`invalid op, ${i.message}, ${JSON.stringify(e)}`),r(i)):o()}),d(Dt,this.doc.data,"no data after submit op, may be the submitted op is invalid")}));h(this,"createDoc",async e=>new Promise((o,r)=>{this.doc.create(e,i5,i=>{i?r(i):o()})}));h(this,"submitInsertChildContainer",async(e,o)=>{const r=[lo(e),{i:o}];return this.submitOp(r)});h(this,"submitDeleteChildContainer",async e=>{const o=[lo(e),{r:!0}];return this.submitOp(o)});h(this,"submitInsertBlock",async(e,o,r)=>{const i=[lo(e),o,{i:r}];return this.submitOp(i)});h(this,"submitDeleteBlock",async(e,o)=>{const r=[lo(e),o,{r:!0}];return this.submitOp(r)});h(this,"submitUpdateBlockData",async(e,o,r)=>{if(r.delete.length===0&&Object.keys(r.insert).length===0)return Promise.resolve();const i=[lo(e),o],s=new Set(r.delete);Object.entries(r.insert).forEach(([c,a])=>{if(s.has(c)){const u={r:!0,i:a};i.push([c,u])}});const l=new Set(Object.keys(r.insert));return r.delete.forEach(c=>{if(l.has(c))return;const a={r:!0};i.push([c,a])}),Object.entries(r.insert).forEach(([c,a])=>{if(s.has(c))return;const u={i:a};i.push([c,u])}),this.submitOp(i)});h(this,"submitUpdateRichText",async(e,o,r)=>{const i=[lo(e),o,"text",{e:r,et:"rich-text"}];return this.submitOp(i)});h(this,"handleOp",(e,o,r)=>{o5(e,this,!!o)});this.client=e,this.doc=o,this.doc.preventCompose=!0,this.registerCallback(this.remoteCaretHandler)}beginBatchUpdate(){return this.doc.preventCompose=!1,this.batching++,this.batching}endBatchUpdate(){return this.batching--,d(Dt,this.batching>=0,"invalid call beginBatchUpdate/endBatchUpdate"),this.batching===0&&(this.doc.preventCompose=!0),this.batching}static async load(e){try{const o=new Cw(e.auth,e.serverUrl,e.reAuthFunc),r=await o.getDoc(),i=new ec(o,r);if(r.type===null){if(e.autoCreateDoc===!1){const s=new Error("doc not exists");throw s.code="DocNotExists",s}await i.createDoc(e.templateData||bw())}return await i.initPresence(),await i.subscribe(),i.initEvents(),i}catch(o){throw Dt.error(o),Dt.error(`failed to load doc: ${JSON.stringify(o)}`),o}}setStatus(e){this.status!==e&&(this.status=e,this.callbacks.forEach(o=>{var r;return(r=o.onStatusChanged)==null?void 0:r.call(o,e)}))}initEvents(){this.doc.on("nothing pending",this.handleNothingPending),this.doc.on("create",this.handleCreate),this.doc.on("del",()=>this.handleDel)}clearEvents(){this.doc.off("nothing pending",this.handleNothingPending),this.doc.off("create",this.handleCreate),this.doc.off("del",()=>this.handleDel)}initPresence(){return new Promise((e,o)=>{if(this.localPresence)e();else{const r=this.doc.connection.getPresence(`${this.doc.collection}:${this.doc.id}`);r.on("receive",(i,s)=>{this.onCustomMessage(s)}),r.subscribe(i=>{i?o(i):(this.localPresence=r.create(N()),e())})}})}subscribe(){return new Promise((e,o)=>{this.doc.subscribe(r=>{r?o(r):(this.doc.on("op",this.handleOp),e())})})}toJSON(){return Ui(this.data())}getContainerBlocks(e){const o=this.data();d(Dt,o,"no doc data");const r=o[lo(e)];return d(Dt,r,`no container data: ${e}`),Y.default(r)}getBlockData(e,o){const r=lo(e),i=this.getContainerBlocks(r);d(Dt,i,`no container data: ${r}`);const s=i[o];return d(Dt,s,`no block data: ${o}`),s}localInsertBlock(e,o,r){return this.submitInsertBlock(e,o,r),this.getBlockData(e,o)}localDeleteBlock(e,o){const r=this.getBlockData(e,o);return this.submitDeleteBlock(e,o),r}localUpdateBlockText(e,o,r){const i=this.getBlockData(e,o);d(Dt,i.text,"no block text");const s=Y.default(i.text);this.submitUpdateRichText(e,o,r);const l=ne.apply(s,r);return d(Dt,l,"no block text"),l}localUpdateBlockData(e,o,r){const i=Y.default(this.getBlockData(e,o));return this.submitUpdateBlockData(e,o,r),i}localInsertChildContainer(e,o){this.submitInsertChildContainer(e,o)}localDeleteChildContainers(e){this.beginBatchUpdate(),e.forEach(o=>{this.submitDeleteChildContainer(o)}),this.endBatchUpdate()}getComments(){return Object.values(this.data().comments).map(o=>Sw(o))}getComment(e){return this.data().comments[e]}getCommentDoc(e){const o=this.data().comments[e];return xw(o)}localCreateComment(e,o){const r=r5(e,o),s=["comments",r.id,{i:r}];return this.submitOp(s)}localDeleteComment(e){const o=["comments",e,{r:!0}];return this.submitOp(o)}localUpdateComment(e,o){const r=r5(e,o),i=["comments",e.id,{r:!0,i:r}];return this.submitOp(i)}destroy(){var e;this.clearEvents(),this.clearCallbacks(),this.doc.destroy(),(e=this.localPresence)==null||e.destroy(),this.client.close(!1),this.remoteCaretHandler.destroy()}onDeleteBlock(e,o,r){d(Dt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var s;return(s=i.onDeleteBlock)==null?void 0:s.call(i,Rr(e),o,r)})}onInsertBlock(e,o,r,i){d(Dt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onInsertBlock)==null?void 0:l.call(s,Rr(e),o,r,i)})}onUpdateBlockData(e,o,r,i){d(Dt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,Rr(e),o,r,i)})}onUpdateBlockText(e,o,r,i){d(Dt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockText)==null?void 0:l.call(s,Rr(e),o,r,i)})}onDeleteContainer(e,o){d(Dt,this.callbacks.length>0,"no callbacks"),d(Dt,e!=="root","should not delete root container in doc"),this.callbacks.forEach(r=>{var i;return(i=r.onDeleteChildContainer)==null?void 0:i.call(r,Rr(e),o)})}onCreateContainer(e,o,r){d(Dt,this.callbacks.length>0,"no callbacks"),d(Dt,e!=="root","should not create root container in doc"),this.callbacks.forEach(i=>{var s;return(s=i.onInsertChildContainer)==null?void 0:s.call(i,Rr(e),o,r)})}onDeleteComment(e,o){d(Dt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onDeleteComment)==null?void 0:i.call(r,e,o)})}onCreateComment(e,o){d(Dt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onCreateComment)==null?void 0:i.call(r,e,o)})}onUpdateComment(e,o){d(Dt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onUpdateComment)==null?void 0:i.call(r,e,o)})}onCustomMessage(e){const o=e;(o==null?void 0:o.type)==="custom"&&(o==null?void 0:o.clientId)!==this.client.clientId?this.callbacks.forEach(r=>{var i;return(i=r.onCustomMessage)==null?void 0:i.call(r,o.data)}):(o==null?void 0:o.type)==="onlineUsers"&&setTimeout(()=>{const r={type:"custom",data:e,clientId:"-"};this.onCustomMessage(r)})}async addResources(e){return await this.client.getFileUrlsByHashes(e)}async uploadResource(e,o){var i;return{resourceId:await this.client.uploadResource(e,(i=o==null?void 0:o.onProgress)!=null?i:()=>{})}}buildResourceUrl(e,o){return this.client.buildResourceUrl(e,o)}request(e,o){return this.client.request(e,o)}getUser(){const e=this.client.clientId,{permission:o,userId:r,displayName:i,avatarUrl:s}=this.client.auth;return{permission:o,clientId:e,userId:r,displayName:i,avatarUrl:s,rainbowIndex:0}}getRemoteUsers(){return this.remoteCaretHandler.remoteUsers}getVersionHelper(){return this}getVersions(){return this.client.getVersions()}async getVersion(e){const o=await this.client.getVersion(e);return Ui(o)}async getLatestVersion(){const e=await this.client.getLatestVersion();return Ui(e)}async getHistoryData(e,o){const{doc:r,ops:i}=await this.client.getVersionOps(e,o),s=i.map(l=>({user:l.meta.createdBy,data:l}));return{doc:Ui(r),historyData:s}}async getVersionData(e,o){const{doc:r,ops:i}=await this.client.getVersionOps(e,o);return{doc:Ui(r),versionData:i}}revertVersion(e){return this.client.revertVersion(e)}createVersion(e,o){return this.client.createVersion(e,o)}async recognizeLink(e){return this.client.recognizeLink(e)}parseHistoryData(e,o){o5(e.data.op,o,!0)}getServerMeta(){return{appId:this.client.auth.appId,docId:this.client.auth.docId,serverId:this.client.apiServer()}}}y("remote-cursor");class s5{constructor(t){h(this,"handleDocSelectionChange",()=>{this.broadcastCaretPos()});h(this,"broadcastCaretPos",ie.default(()=>{const t={type:"caret",userId:this.editor.doc.getUser().userId,range:this.editor.selection.range.toDocRange()};this.editor.doc.broadcastMessage(t)},300));h(this,"handleRemoteCaretsChanged",t=>{t.forEach(e=>{const o=this.editor.findBlockById(e);o&&this.editor.reloadBlock(o)})});this.editor=t,this.editor.addListener("selectionChanged",this.handleDocSelectionChange),this.editor.doc.getRemoteUsers().addListener("remote-carets-change",this.handleRemoteCaretsChanged)}destroy(){this.editor.removeListener("selectionChanged",this.handleDocSelectionChange),this.editor.doc.getRemoteUsers().removeListener("remote-carets-change",this.handleRemoteCaretsChanged)}}const l5=y("remote-cursor-decorator");class zd{decorateText(t,e,o){const r=t.doc.getRemoteUsers();if(!r)return{};const i=new Map,{containerId:s,blockIndex:l}=e[e.length-1];d(l5,typeof s=="string","invalid path containerId"),d(l5,typeof l=="number","invalid path blockIndex");const c=t.doc.getBlockData(s,l),a=ce(o);return r.getSimpleCursors(c.id).forEach((f,m)=>{m>a&&(m=a);const C=f.map(w=>({id:N(),type:"remote-cursor",name:w.user.displayName,time:w.time,rainbowIndex:w.user.rainbowIndex})),v=i.get(m);v?v.push(...C):i.set(m,C)}),{insertions:i}}}class c5 extends Wt.TypedEmitter{constructor(t){super(),this.editor=t,this.editor.doc.registerCallback(this)}handleChild(t,e,o){if(Ct(br(this.editor,t)))return;const r=this.editor.getBlockByIndex(t,e),i=z(this.editor.getContainerById(t));i&&this.emit("change",this.editor,i,r,o)}onUpdateBlockData(t,e){this.handleChild(t,e,"data-change")}onUpdateBlockText(t,e){this.handleChild(t,e,"text-change")}destroy(){this.editor.doc.unregisterCallback(this)}}function Tw(n,t){n.addCustom("child-block-tracker",()=>new c5(n)).addListener("change",t)}function Dw(n,t){n.addCustom("child-block-tracker",()=>new c5(n)).removeListener("change",t)}const dF="",Lw={colorPalette:{colorDesc:"\u5B57\u4F53\u989C\u8272",backgroundDesc:"\u80CC\u666F\u989C\u8272",reset:"\u6062\u590D\u9ED8\u8BA4"},search:{emptyTips:"\u6682\u65E0\u641C\u7D22\u7ED3\u679C"}},Mw={colorPalette:{colorDesc:"Text Color",backgroundDesc:"Background Color",reset:"Reset"},search:{emptyTips:"\u6682\u65E0\u641C\u7D22\u7ED3\u679C"}};S.mergeLang({"zh-CN":Lw,"en-US":Mw});const uF="",Rw=y("button");function Aw(n){const t=n.getAttribute("data-button-id");return t||d(Rw,!1,"unknown button id"),t}function Ow(n){var e;if(!(n instanceof Node))return null;const t=n.parentElement;return t?n instanceof HTMLButtonElement&&n.classList.contains("editor-button")?n:(e=t.closest("button.editor-button"))!=null?e:null:null}function kn(n,t,e,o,r){const i=b("button",["editor-button"],null);return i.setAttribute("data-button-id",n),r&&i.setAttribute(`data-editor-tooltip-${r}`,t),e?typeof e=="string"?e.startsWith("<")?i.innerHTML=e:i.innerText=e:i.appendChild(e):i.innerText=t,o&&(o.indexOf("checked")!==-1&&M(i,"checked"),o.indexOf("disabled")!==-1&&(i.disabled=!0)),i}function Vd(n,t,e){e?n.setAttribute(`data-editor-tooltip-${e}`,t):n.innerText=t}function _w(n){return b("span",["editor-separator",n],null)}const uo=y("filterable-list");function Nw(n){var e;const t=b("div",["list-item"],null);return t.setAttribute("data-id",n.id),t.appendChild(b("div",["list-item-text"],null,n.name)),(e=n.states)!=null&&e.includes("selected")&&M(t,"selected"),t}function a5(n){const t=b("div",["list-root"],null);return n.forEach(e=>{t.appendChild(Nw(e))}),t}function d5(n,t){let e=n;return t&&(e=n.map(o=>({...o,states:o.id===t?["selected"]:void 0}))),e}function Pw(n,t){const e=b("div",["filterable-list"],null),o=b("div",["filter"],e),r=b("div",["filter-container"],o),i=b("input",["filter-input"],r);t&&t.placeholder&&(i.placeholder=t.placeholder);const s=b("div",["list"],e),l=a5(d5(n,t==null?void 0:t.initialSelectedId));return s.appendChild(l),e}function u5(n,t,e){const o=n.querySelector(".list");d(uo,o,"no list root");const r=a5(d5(t,e)),i=o.querySelector(".list-root");if(d(uo,i,"no exists menu"),xi(i,r),e){const s=o.querySelector(".list-item.selected");s&&(d(uo,s,"no selected menu item"),s.scrollIntoView({block:"nearest"}))}}class h5{constructor(t,e){h(this,"root");h(this,"visibleItems");h(this,"selectedId");h(this,"filter","");h(this,"onSelected",null);h(this,"handleKeydown",t=>{this.processKeyDown(t)});h(this,"handleInputChanged",()=>{const t=this.root.querySelector(".filter-input");d(uo,t,"no input");const e=t.value.toLocaleLowerCase();this.setFilter(e)});h(this,"handleClick",t=>{this.processClick(t)});var o;this.items=t,this.options=e,this.root=Pw(t,e),this.bindEvents(),this.selectedId=(o=e==null?void 0:e.initialSelectedId)!=null?o:"",this.visibleItems=t}bindEvents(){const t=this.root.querySelector(".filter-input");d(uo,t,"no input"),t.addEventListener("keyup",this.handleInputChanged),t.addEventListener("keydown",this.handleKeydown),this.root.addEventListener("click",this.handleClick)}unbindEvents(){const t=this.root.querySelector(".filter-input");d(uo,t,"no input"),t.removeEventListener("keyup",this.handleInputChanged),t.removeEventListener("keydown",this.handleKeydown),this.root.removeEventListener("click",this.handleClick)}destroy(){this.unbindEvents(),this.onSelected=null}getSelectedIndex(){return this.selectedId?this.visibleItems.findIndex(t=>t.id===this.selectedId):-1}setSelectedId(t){this.selectedId=t,u5(this.root,this.visibleItems,t)}focus(){const t=this.root.querySelector(".filter-input");d(uo,t,"no input"),t.focus()}reset(){this.setFilter("");const t=this.root.querySelector(".filter-input");d(uo,t,"no input"),t.value=""}setFilter(t){this.filter!==t&&(this.filter=t,this.visibleItems=this.items.filter(e=>e.name.toLocaleLowerCase().includes(t)),u5(this.root,this.visibleItems,this.selectedId))}processClick(t){var s,l;const e=t.target;if(!(e instanceof HTMLElement))return;const o=e.closest(".list-item");if(!o)return;const r=(s=o.getAttribute("data-id"))!=null?s:"",i=(l=this.visibleItems.find(c=>c.id===r))!=null?l:null;this.onSelected&&this.onSelected(this,i)}processKeyDown(t){var e;if(t.key==="ArrowUp"){let o=this.getSelectedIndex();o===-1?o=this.visibleItems.length-1:o>0&&(o-=1);let r="";o!==-1&&(r=this.visibleItems[o].id),this.setSelectedId(r);return}if(t.key==="ArrowDown"){let o=this.getSelectedIndex();o===-1?o=0:o<this.visibleItems.length-1&&(o+=1);let r="";o!==-1&&(r=this.visibleItems[o].id),this.setSelectedId(r);return}if(t.key==="Enter"){const o=(e=this.visibleItems.find(r=>r.id===this.selectedId))!=null?e:null;this.onSelected&&this.onSelected(this,o)}}}class f5 extends h5{constructor(e,o,r){super(e,r);h(this,"tippyInstance");h(this,"onShow",null);h(this,"onHide",null);h(this,"custom",null);h(this,"handleShow",()=>{this.onShow&&this.onShow(this)});h(this,"handleHide",()=>{this.onHide&&this.onHide(this)});h(this,"handleShown",()=>{this.focus()});this.tippyInstance=za.default(o,{interactive:!0,content:this.root,trigger:"manual",triggerTarget:null,hideOnClick:!0,arrow:!1,theme:"dropdown-list",offset:[0,0],onHide:this.handleHide,onShow:this.handleShow,onShown:this.handleShown})}destroy(){super.destroy(),this.onShow=null,this.onHide=null}show(e){this.tippyInstance.setProps({getReferenceClientRect:()=>e.getBoundingClientRect()}),this.reset(),this.tippyInstance.show(),this.focus()}processKeyDown(e){super.processKeyDown(e),(e.key==="Esc"||e.key==="Enter")&&this.tippyInstance.hide()}processClick(e){super.processClick(e);const o=e.target;!(o instanceof HTMLElement)||!o.closest(".list-item")||this.tippyInstance.hide()}}const hF="",fF="";function m5(n,t){const e=document.createElement("div");e.classList.add("toast","show"),t!=null&&t.theme&&e.setAttribute("data-theme",t.theme),t!=null&&t.id&&e.setAttribute("data-id",t.id),t!=null&&t.html?e.innerHTML=n:e.textContent=n,t!=null&&t.position&&(e.style.left=`${t.position.x}px`,e.style.top=`${t.position.y}px`,e.classList.add("positioned")),document.body.appendChild(e),setTimeout(()=>{e.classList.remove("show"),setTimeout(()=>{e.remove()},500)},(t==null?void 0:t.duration)||3e3)}const mF="",Nr=y("ui-command-bar-base"),$w={itemElementTag:"div",tippyArrow:!1},df=class extends Wt.TypedEmitter{constructor(e,o,r){var i,s;super();h(this,"content");h(this,"items");h(this,"subBar",null);h(this,"parentItem",null);h(this,"closeable",null);h(this,"options");h(this,"id");h(this,"handleDocumentKeydown",e=>{if(!!this.isVisible){if(this.subBar){this.subBar.handleDocumentKeydown(e);return}if(this.items.length!==0){if(e.key==="Escape"){this.close();return}if(e.key==="ArrowUp"){const o=this.getPrevItemIndex(this.getSelectedItemIndex());this.selectItem(this.items[o].id)}else if(e.key==="ArrowDown"){const o=this.getNextItemIndex(this.getSelectedItemIndex());this.selectItem(this.items[o].id)}else if(e.key==="ArrowRight"){const o=this.getSelectedItem();o&&o.children&&this.showSubCommandBar(o.childrenMenuId)}else if(e.key==="ArrowLeft")this.parentItem&&this.close();else if(e.key==="Enter"){const o=this.getSelectedItemIndex();if(o===-1)return;const r=this.items[o],i=this.getItemElementById(r.id);i&&this.emit("click",this,r,i)}}}});h(this,"handleDocumentMouseDown",e=>{e.target instanceof Element&&(this.isInCommandBar(e.target)||this.close())});h(this,"handleHidden",()=>{this.close(),this.emit("close",this),um(this.id)});h(this,"handleShow",()=>{this.popper&&(this.popper.setAttribute("data-command-bar-id",this.id),this.options.classes&&M(this.popper,...this.options.classes)),this.emit("show",this),this.options.disablePageScroll&&dm(this.id)});h(this,"handleItemMouseEnter",e=>{const o=this.getParentCommandItemElement(e.target);if(!o)return;const r=this.getItemElementId(o),i=this.getItemById(r);if(this.selectItem(r),i.manualShowChildren)return;const s=i.childrenMenuId||"";this.showSubCommandBar(s)});h(this,"handleItemMouseLeave",e=>{var r,i;const o=this.getParentCommandItemElement(e.target);!o||((i=(r=this.subBar)==null?void 0:r.parentItem)==null?void 0:i.id)!==this.getItemElementId(o)&&(F(o,"selected"),this.emit("selectionChange",this,""))});h(this,"handleItemClick",e=>{const o=this.getParentCommandItemElement(e.target);if(!o)return;const r=this.getItemElementId(o),i=this.items.find(s=>s.id===r);if(!!i&&!(i.states&&i.states.indexOf("disabled")!==-1)){if(i.children&&i.children.length>0&&i.manualShowChildren){this.showSubCommandBar(i.childrenMenuId);return}i.element||(this.emit("click",this,i,o),this.options.autoClose&&this.close())}});h(this,"handleWheel",e=>{if(!this.options.disablePageScroll&&!document.querySelector(".editor-disable-scroll"))return;const o=e.target;if(!o||!(o instanceof Node))return;const r=o instanceof HTMLElement?o:o.parentElement;if(!r)return;const i=Nn(r);if(!vt(this.content,i)){e.stopPropagation(),e.preventDefault();return}e.deltaY<0?i.scrollTop===0&&(e.stopPropagation(),e.preventDefault()):e.deltaY>0&&i.scrollTop+i.clientHeight>=i.scrollHeight&&(e.stopPropagation(),e.preventDefault())});this.id=(i=r==null?void 0:r.id)!=null?i:N(),this.options={...$w,...r},this.items=e,this.parentItem=(s=r==null?void 0:r.parentItem)!=null?s:null,this.closeable=o!=null?o:null,this.content=this.createCommandBarContent(e)}close(){this.subBar&&this.subBar.close(),document.removeEventListener("keydown",this.handleDocumentKeydown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}click(e,o){this.emit("click",this,e,o)}destroy(){var e;this.close(),this.removeAllListeners(),(e=this.subBar)==null||e.destroy(),this.subBar=null,this.closeable=null,this.content.removeEventListener("wheel",this.handleWheel)}get isSubCommandBar(){return!!this.parentItem}updateItems(e){var r;this.subBar&&e.findIndex(s=>{var l,c;return s.id===((c=(l=this.subBar)==null?void 0:l.parentItem)==null?void 0:c.id)})===-1&&((r=this.subBar)==null||r.destroy(),this.subBar=null),this.items=e;const o=this.createCommandBarContent(e);this.content.innerHTML="",Array.from(o.children).forEach(i=>{this.content.appendChild(i)})}get popper(){return this.content.closest("[data-tippy-root]")}getSelectedItemIndex(){const e=this.getSelectedItem();return e?this.items.indexOf(e):-1}getPrevItemIndex(e){if(e<=0)return this.items.length-1;let o=e-1;for(;;){const r=this.items[o].type;if(r!=="separator"&&r!=="section")return o;if(o-=1,o<=0)return this.items.length-1}}getNextItemIndex(e){let o=e+1;for(;;){if(!this.items[o])return this.getNextItemIndex(-1);const r=this.items[o].type;if(r!=="separator"&&r!=="section")return o;if(o+=1,o>this.items.length-1)return 0}}clearSelectedItem(){const e=this.getSelectedItem();if(!e)return;const o=this.getItemElementById(e.id);o&&F(o,"selected")}selectItem(e){const o=this.getSelectedItem();if(o){if(o.id===e)return;const i=o.id,s=this.getItemElementById(i);s&&F(s,"selected")}const r=this.getItemElementById(e);r?(M(r,"selected"),this.emit("selectionChange",this,r.getAttribute("data-id")||""),r.scrollIntoView({block:"nearest"})):this.emit("selectionChange",this,"")}showSubCommandBar(e){var s,l;const o=this.getSelectedItem();if(!o)return;if(this.subBar){if(((s=this.subBar.parentItem)==null?void 0:s.id)===o.id){o.manualShowChildren&&this.subBar.close();return}this.subBar.destroy(),this.subBar=null}if(!o.children)return;const r=this.getItemElementById(o.id);if(!r)return;const i=df.createSubCommandBar(o,(l=this.closeable)!=null?l:this,e?{id:e}:{});this.subBar=i,this.subBar.on("click",(c,a,u)=>{this.emit("click",c,a,u)}),this.subBar.on("close",()=>{var c;(c=this.subBar)==null||c.destroy(),this.subBar=null,F(r,"active")}),o.beforePopup&&o.beforePopup(i),this.subBar.manualShow(r,this.getSubBarOptions(o)),M(r,"active")}isInCommandBar(e){if(!e||!(e instanceof Node))return!1;const o=this.getCommandBarRoot();return o&&vt(o,e)||vt(this.content,e)?!0:this.subBar?this.subBar.isInCommandBar(e):!1}createCommandItem(e){var i,s,l,c;let o=(i=this.options.itemElementTag)!=null?i:"div";e.element&&(o="div");const r=b(o,["command-item"],null);return r.setAttribute("data-id",e.id),e.type==="separator"?r.classList.add("separator"):e.type==="section"?r.classList.add("section","text"):((s=e.states)!=null&&s.includes("selected")&&r.classList.add("selected"),(l=e.states)!=null&&l.includes("checked")&&r.classList.add("checked"),(c=e.states)!=null&&c.includes("disabled")&&r.classList.add("disabled"),r.onclick=this.handleItemClick,r.onmouseenter=this.handleItemMouseEnter,r.onmouseleave=this.handleItemMouseLeave,e.element?typeof e.element=="function"?r.appendChild(e.element(e)):r.appendChild(e.element):r.classList.add("standard")),this.initItemElement(e,r),r}getItemById(e){const o=this.items.find(r=>r.id===e);return d(Nr,o,`can not find command item for id: ${e}`),o}getSelectedItem(){const e=this.content.querySelector(":scope >.editor-command-bar >.command-item.selected");if(e){const o=this.getItemElementId(e),r=this.items.find(i=>i.id===o);return d(Nr,r,`can not find command item for id: ${o}`),r}return null}getItemElementId(e){const o=e.getAttribute("data-id");return d(Nr,o,"no data-id attribute"),o}getItemElementById(e){const o=this.content.querySelector(`:scope >.editor-command-bar > .command-item[data-id="${e}"]`);return d(Nr,o,`no exists command item, id=${e}`),o}getParentCommandItemElement(e){if(!e||!(e instanceof Element))return null;if(lt(e,"command-item"))return e;const o=e.closest(".command-item");return o||null}createCommandBarContent(e){const o=b("div",["editor-command-bar-root"],null),r=b("div",["editor-command-bar"],o);return e.forEach(i=>{var l;const s=this.createCommandItem(i);r.appendChild(s),i.element&&i.setCloseable&&i.setCloseable((l=this.closeable)!=null?l:this)}),this.initCommandBarElement(r),o.addEventListener("wheel",this.handleWheel),o}getSubBarOptions(e){var o;return{placement:(o=e.childrenPlacement)!=null?o:"right-start"}}static registerManualCommandBar(e,o){this.commandBarCreators.set(e,o)}static createSubCommandBar(e,o,r){var l;d(Nr,e.children&&e.children.length>0,"no item children");const i=(l=e.childrenType)!=null?l:"menu",s=this.commandBarCreators.get(i);return d(Nr,s,`no creator for command type: ${i}`),s(e,o,r)}static hasExistsCommandBar(){return!!document.querySelector("[data-command-bar-id]")}};let ho=df;h(ho,"commandBarCreators",new Map),y("ui-command-bar");class nc extends ho{constructor(){super(...arguments);h(this,"tippyInstance",null)}manualShow(e,o){var r,i;if(!this.isVisible){if(this.tippyInstance&&(this.tippyInstance.destroy(),this.tippyInstance=null),this.tippyInstance=za.default(e,{interactive:!0,content:this.content,trigger:"manual",triggerTarget:null,hideOnClick:!1,placement:(r=o==null?void 0:o.placement)!=null?r:"bottom-start",maxWidth:650,arrow:this.options.tippyArrow,appendTo:document.body,onShow:this.handleShow,onHidden:this.handleHidden,theme:o==null?void 0:o.theme,getReferenceClientRect:o==null?void 0:o.getReferenceClientRect,offset:(i=o==null?void 0:o.offset)!=null?i:[0,0]}),o!=null&&o.point){const{x:s,y:l}=o.point;this.tippyInstance.setProps({getReferenceClientRect:()=>new DOMRect(s,l,0,0)})}this.clearSelectedItem(),this.tippyInstance.show(),this.parentItem||(document.addEventListener("keydown",this.handleDocumentKeydown),document.addEventListener("mousedown",this.handleDocumentMouseDown)),this.popper&&this.options.id&&this.popper.setAttribute("data-command-bar-id",this.options.id)}}close(){var e;super.close(),this.isVisible&&((e=this.tippyInstance)==null||e.hide())}destroy(){var e;(e=this.tippyInstance)==null||e.destroy(),this.tippyInstance=null,super.destroy()}getCommandBarRoot(){return this.content.closest("[data-tippy-root]")}get isVisible(){var e,o;return(o=(e=this.tippyInstance)==null?void 0:e.state.isVisible)!=null?o:!1}get popper(){return this.content.closest("[data-tippy-root]")}}function Hw(){const n={};for(let t=1;t<=8;t++)n[`heading-${t}`]={shortcut:`/h${t}`};return n}const g5={"insert-hr":{shortcut:"/hr"},"insert-uml":{shortcut:"/uml"},"insert-table":{shortcut:"/table"},"insert-image":{shortcut:"/image"},"insert-code":{shortcut:"/code"},"insert-link":{shortcut:"/link"},"insert-drawio":{shortcut:"/uml"},"insert-video":{shortcut:"/video"},"insert-audio":{shortcut:"/audio"},"insert-math":{shortcut:"/math"},"insert-webPage":{shortcut:"/web"},"insert-bilibili":{shortcut:"/bilibili"},"insert-youku":{shortcut:"/youku"},"insert-figma":{shortcut:"/figma"},"insert-modao":{shortcut:"/modao"},"insert-tencent":{shortcut:"/tencent"},"insert-unordered":{shortcut:"/bl"},"insert-ordered":{shortcut:"/nu"},"insert-checkbox":{shortcut:"/todo"},"insert-quote":{shortcut:"/quote"},...Hw()};function Ud(n){var t,e,o;return(o=(e=n.shortcut)!=null?e:(t=g5[n.id])==null?void 0:t.shortcut)!=null?o:""}function jw(n){var t,e;return(e=(t=g5[n.id])==null?void 0:t.markdown)!=null?e:""}const qd=`<?xml version="1.0" ?>
26
+ `)}function sd(n,t){return`<!doctype html><html><head><meta charset="utf8" />${`<meta charset="utf-8"><ones-editor-doc data-source="ones-editor-doc::${Lo(JSON.stringify(t))}::ones-editor-doc" />`}</head><body>${n}</body></html>`}function ld(n,t){var i,s,l;const e=(l=(s=(i=n.doc).getServerMeta)==null?void 0:s.call(i))!=null?l:{},o=ev(n,t),r={};o.forEach(c=>{const a=n.doc.buildResourceUrl(c,{withToken:!0});r[c]=a}),t.meta={...e,resources:r}}function nv(n,t){if(t.preventDefault(),t.stopPropagation(),!t.clipboardData||n.selection.range.isCollapsed())return;const e=jl(n);ld(n,e);const o=rd(n,e),r=id(n,e),i=sd(o,e);t.clipboardData.setData("text/html",i),t.clipboardData.setData("text/plain",r),t.clipboardData.setData("text/x-ones-editor-doc",JSON.stringify(e))}function ov(n){if(n.selection.range.isCollapsed())return;const t=jl(n);ld(n,t);const e=rd(n,t),o=sd(e,t),r=new Blob([o],{type:"text/html"});il([{type:"text/html",data:r}])}async function cd(n,t){const e=nd(n,t,!1);ld(n,e);const o=rd(n,e),r=id(n,e),i=sd(o,e);return il([{type:"text/plain",data:new Blob([r],{type:"text/plain"})},{type:"text/html",data:new Blob([i],{type:"text/html"})}])}const ad=y("editor-input");class rv{constructor(t,e){h(this,"editor");h(this,"composing",!1);h(this,"callbacks");h(this,"inputElement");h(this,"handleDocumentSelectionChange",()=>{setTimeout(()=>{var e;const t=(e=document.getSelection())==null?void 0:e.focusNode;t&&this.editor.contains(t)&&!Ti(t)?(this.editor.emit("focus",this.editor),this.callbacks.onFocus(),this.editor.input.focus()):(this.editor.emit("blur",this.editor),this.callbacks.onBlur())},100)});h(this,"handleEditorSelectionChanged",()=>{const e=!this.editor.isWritable();this.inputElement.readOnly=e});h(this,"handleReadonlyChanged",()=>{this.handleEditorSelectionChanged()});h(this,"handleCompositionstart",t=>{this.composing=!0,this.callbacks.onCompositionStart(t)});h(this,"handleCompositionend",t=>{this.composing=!1,this.callbacks.onUpdateCompositionText(t,this.inputElement.value,!0),this.inputElement.value=""});h(this,"handleInput",t=>{if(t instanceof InputEvent&&!!t.data){if(this.editor.readonly){this.inputElement.value="";return}this.composing?this.callbacks.onUpdateCompositionText(t,t.data,!1):(this.callbacks.onInsertText(t,t.data),this.inputElement.value="")}});h(this,"handleKeyDown",t=>{if(!this.composing){if(this.callbacks.onKeyDown(t)){t.preventDefault(),t.stopPropagation();return}setTimeout(()=>{this.composing||(this.inputElement.value="")})}});h(this,"handleCopy",t=>{nv(this.editor,t)});h(this,"handleCut",t=>{if(this.editor.readonly){t.stopPropagation(),t.preventDefault();return}ad.debug("on cut")});h(this,"handlePaste",t=>{if(this.editor.readonly){t.stopPropagation(),t.preventDefault();return}this.callbacks.onPaste(t)});this.editor=t,this.callbacks=e;const o=b("input",["editor-input"],t.contentElement);o.type="text",o.name="editor-input",o.onkeydown=this.handleKeyDown,o.oninput=this.handleInput,o.oncopy=this.handleCopy,o.onpaste=this.handlePaste,o.oncut=this.handleCut,o.addEventListener("compositionstart",this.handleCompositionstart),o.addEventListener("compositionend",this.handleCompositionend),this.inputElement=o,document.addEventListener("selectionchange",this.handleDocumentSelectionChange),this.editor.addListener("selectionChanged",this.handleEditorSelectionChanged),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}destroy(){this.callbacks.destroy(),document.removeEventListener("selectionchange",this.handleDocumentSelectionChange),this.editor.removeListener("selectionChanged",this.handleEditorSelectionChanged),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged);const t=this.inputElement;t.removeEventListener("compositionstart",this.handleCompositionstart),t.removeEventListener("compositionend",this.handleCompositionend),t.onkeydown=null,t.oninput=null,t.oncopy=null,t.onpaste=null,t.oncut=null}getInput(){return this.inputElement}focus(){this.editor.selection.caret.visible()||this.editor.selection.caret.update(),It.isMobileSafari?this.inputElement.focus():setTimeout(()=>{this.inputElement.focus()})}handleChanged(t){this.callbacks.onChanged(t)}handleRemoteChanged(t){this.callbacks.onRemoteChanged(t)}addHandler(t){this.callbacks.addHandler(t)}removeHandler(t){this.callbacks.removeHandler(t)}defaultInsertText(t,e,o,r,i){d(ad,t===this.editor,"invalid editor"),this.callbacks.defaultInsertText(t,e,o,r,i)}defaultHandleKeydown(t,e){return d(ad,t===this.editor,"invalid editor"),this.callbacks.defaultHandleKeydown(t,e)}}function iv(n){const e=n.rootElement.getBoundingClientRect(),o=window.innerWidth,r=window.innerHeight,i=0-e.top+r/2,s=0-e.left+o/2,l=n.input.inputElement;l.style.left=`${s}px`,l.style.top=`${i}px`}const dd=y("editor-caret");class sv{constructor(t){h(this,"editor");h(this,"caretElem");h(this,"handleReadOnlyChanged",()=>{this.update()});this.editor=t,this.caretElem=b("div",["editor-cursor"],this.editor.contentElement),this.editor.on("readonlyChanged",this.handleReadOnlyChanged)}destroy(){this.editor.off("readonlyChanged",this.handleReadOnlyChanged)}visible(){const t=window.getComputedStyle(this.caretElem);return t.display!=="none"&&t.opacity!=="0"}hasCaret(){if(this.editor.readonly||!this.editor.selection.range.isCollapsed())return!1;const t=this.editor.selection.range.start;if(!(t instanceof Ut))return!1;const e=this.editor.getBlockById(t.blockId);return!!j(this.editor,e)}update(){if(Uf(this.editor.rootElement))return;const t=this.caretElem;if(this.hasCaret())t.style.display="";else{t.style.display="none",iv(this.editor);return}const{range:e}=this.editor.selection;d(dd,e.isCollapsed,"range is not collapsed");const o=e.start;d(dd,o instanceof Ut,"only simple block position can has caret");const r=this.editor.getBlockById(o.blockId);d(dd,j(this.editor,r),"only text kind block can has caret");let i;const s=r.querySelector("span.inputting-insertion");s?(i=xo(s),i=new DOMRect(i.right,i.top,1,i.height)):i=Oe(r,o);const l=this.editor.contentElement.getBoundingClientRect(),c=i.left-l.left,a=i.top-l.top;t.style.left=`${c}px`,t.style.top=`${a}px`,t.style.height=`${i.height}px`;const u=this.editor.input.inputElement;u.style.left=`${c}px`,u.style.top=`${a+i.height-24}px`,It.isMobileSafari&&(u.style.left=`${c-4}px`,u.style.height=`${i.height}px`)}}function lv(n){Wm(n),n.selection.range.getSelectedBlocks().forEach(t=>Gm(n,t.block,t.start,t.end))}function L2(n){return Nn(n.rootContainer).clientHeight}function cv(n){return n.getFirstBlock().getBoundingClientRect().top}function av(n){return n.getLastBlock().getBoundingClientRect().bottom}function ud(n){const t=Nn(n.rootContainer);return new DOMRect(t.clientLeft,t.clientTop,t.clientWidth,t.clientHeight)}function dv(n,t){const e=ud(n),o=n.getBlockById(t.blockId),i=Ge(n,o,t);return To(e,i.x,i.y)&&To(e,i.right,i.bottom)}function uv(n,t){const e=ud(n),o=t.getBoundingClientRect();return o.top>=e.top&&o.top<=e.bottom||o.bottom<=e.bottom&&o.bottom>=e.top}function hv(n,t){const e=ud(n),o=t.getBoundingClientRect();return To(e,o.x,o.y)||To(e,o.right,o.bottom)}function fv(n){const t=n.selection,e=t.range.focus;if(!e.isSimple()){const a=e,u=n.getContainerById(a.childContainerId);hv(n,u)||u.scrollIntoView();return}if(t.range.start.blockId===t.range.end.blockId){const a=n.getBlockById(t.range.start.blockId);if(Te(a)&&uv(n,a))return}const o=e,r=n.getBlockById(o.blockId);if(dv(n,o))return;const i=Ge(n,r,o),s=r.getBoundingClientRect(),l=At(r),c=b("div",["editor-block-anchor"],l);c.style.top=`${i.top-s.top}px`,Ei(c),setTimeout(()=>{c.remove()})}function mv(n,t){if(t.isCollapsed())return!1;const e=Qt(n.rootContainer),o=Gt(n.rootContainer),{start:r,end:i}=t;return r.blockId===G(e)&&r.offset===0&&i.blockId===G(o)&&i.offset===Z(n,o)}const Fl=y("editor-selection");class gv{constructor(t){h(this,"editor");h(this,"caret");h(this,"_range");h(this,"lastCaretRect");h(this,"handleBlockDelete",(t,e,o,r)=>{if(o||r.child)return;const i=this.range;if(h2(e,i)){Fl.debug("adjust selection because remote deleted current block");const s=f2(t,e);this.setRange(s)}});this.editor=t;const e=t.getFirstBlock(),o=G(e);this.caret=new sv(t);const r=$(o,0,"normal");this._range=Vt(t,{anchor:r,focus:r}),this.lastCaretRect=null,this.editor.addListener("blockDeleted",this.handleBlockDelete),setTimeout(()=>{this.updateFocusedBlock(null)})}destroy(){this.caret.destroy()}get range(){return this._range}get focusedBlock(){return this.getFocusedBlock()}get startBlock(){return this.getStartBlock()}get endBlock(){return this.getEndBlock()}getFocusedBlock(){const t=this.range.focus;return this.editor.getBlockById(t.blockId)}getStartBlock(){const t=this.range.start;return this.editor.getBlockById(t.blockId)}getEndBlock(){const t=this.range.end;return this.editor.getBlockById(t.blockId)}selectBlock(t,e,o){const r=$(t,e,"normal");let i;o&&(i=$(t,o,"normal")),this.setSelection(r,i)}setSelection(t,e,o){if(e||(e=t),this.verifyPos(t),this.verifyPos(e),!this.selectionChanging(t,e))return this.range;const r=Vt(this.editor,{anchor:t,focus:e});if(this.range.isEqual(r))return this.range;const i=this._range;return this._range=r,this.selectionChanged(),this.updateFocusedBlock(i),lt(this.editor.rootContainer,"select-all")&&(!r.isSimple()||!mv(this.editor,r))&&F(this.editor.rootContainer,"select-all"),o!=null&&o.noScroll||this.scrollIntoView(),this.range}setRange(t){return this.setSelection(t.anchor,t.focus)}updateSelection(){this.caret.update(),lv(this.editor)}getFocusedPos(){return this.range.focus}getAnchorPos(){return this.range.anchor}selectionChanging(t,e){return!0}selectionChanged(){this.updateSelection(),this.editor.emit("selectionChanged",this.editor)}updateLastCaretRect(){const t=this.range.focus;if(!kr(t))return;const e=this.editor.getBlockById(t.blockId);this.lastCaretRect=Ge(this.editor,e,t)}getSuggestedCaretX(){var t;return(t=this.lastCaretRect)==null?void 0:t.x}scrollIntoView(){fv(this.editor)}verifyPos(t){const e=this.editor.getBlockById(t.blockId);if(t.isSimple())t.offset>=0&&t.offset<=Z(this.editor,e)||d(Fl,!1,"invalid block position, out of range");else{const o=t.childContainerId;!!this.editor.getContainerById(o)||d(Fl,!1,"invalid complex block position, no container found")}}updateFocusedBlock(t){if(t&&this.range.start.blockId===t.start.blockId)return;let e;t&&t.start.blockId===t.end.blockId&&(e=this.editor.findBlockById(t.start.blockId));let o;(this.range.isCollapsed()||!this.range.isSimple()||this.range.start.blockId===this.range.end.blockId)&&(o=this.editor.getBlockById(this.range.start.blockId));let r=!1;e&&lt(e,"focused")&&(F(e,"focused"),r=!0),this.removeAllBlockFocusedClass(),o&&this.setBlockFocused(o)&&(r=!0),r&&this.editor.emit("focusBlockChanged",this.editor,o!=null?o:null,e!=null?e:null)}verify(){this.verifyPos(this._range.start),this.verifyPos(this._range.end)}removeAllBlockFocusedClass(){this.editor.rootContainer.querySelectorAll('div[data-type="editor-block"].focused, div[data-type="editor-block"].child-focused').forEach(t=>{F(t,"focused"),F(t,"child-focused")})}setBlockFocused(t){if(lt(t,"focused"))return!1;M(t,"focused");let e=H(t);for(;qe(e);){const o=z(e);d(Fl,o,"parent block not found"),M(o,"child-focused"),e=H(o)}return!0}}const M2=y("line-offset");function hd(n){const t=n.selection.range.focus;d(M2,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId);if(t.offset===0||!j(n,e))return $(e,0,"home");let r=vg(e,t).start;const{next:i}=gl(e,r);return i&&Me(i)&&Si(i)==="br"&&(r+=1),$(e,r,"home")}function fd(n){const t=n.selection.range.focus;d(M2,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId);if(t.offset===Z(n,e)||!j(n,e))return $(e,0,"end");const o=vg(e,t);return $(e,o.end,"end")}function pv(n){if(!n.selection.range.focus.isSimple())return;const e=hd(n),o=fd(n);!e||!o||n.selection.setSelection(e,o)}const Ne=y("block-text");function R2(n,t,e){d(Ne,j(n,t),"not a text kind block"),d(Ne,fe(t,e),"not a valid offset"),d(Ne,e>0&&e<=Z(n,t),`invalid offset: ${e}`);const o=Po(t,e),r=e-o;r===0&&d(Ne,!1,`no text before offset: ${e}`);const i=ke(n,t),{middle:s}=Kt(i,o,r);d(Ne,s.length===1,"failed to split text to 3 parts");const l=s[0];return E1(l)?{op:l,charType:"box",offset:o,length:1}:{op:l,charType:tl(l.insert)?"space":"text",offset:o,length:l.insert.length}}function A2(n,t,e){d(Ne,j(n,t),"not a text kind block"),d(Ne,fe(t,e),"not a valid offset"),d(Ne,e>=0&&e<Z(n,t),`invalid offset: ${e}`);const r=Ir(t,e)-e;r===0&&d(Ne,!1,`no text after offset: ${e}`);const i=ke(n,t),{middle:s}=Kt(i,e,r);d(Ne,s.length===1,"failed to split text to 3 parts");const l=s[0];return E1(l)?{op:l,charType:"box",offset:e,length:1}:{op:l,charType:tl(l.insert)?"space":"text",offset:e,length:l.insert.length}}function O2(n,t,e,o){let r=e;for(;r>0;){const i=R2(n,t,r);if(i.charType!==o)return i;r-=i.length}return null}function _2(n,t,e,o){const r=Z(n,t);let i=e;for(;i<r;){const s=A2(n,t,i);if(s.charType!==o)return s;i+=s.length}return null}function N2(n,t,e){if(d(Ne,j(n,t),"invalid blok type"),wt(n,t))return 0;const o=R2(n,t,e);if(o.charType==="box")return e-1;let r=e;if(o.charType==="space"){const s=O2(n,t,r,"space");if(!s||s.offset===0)return 0;if(s.charType==="box")return s.offset;r=s.offset}const i=O2(n,t,r,"text");return i?i.offset+i.length:0}function P2(n,t,e){if(d(Ne,j(n,t),"invalid blok type"),wt(n,t))return 0;const o=A2(n,t,e);if(o.charType==="box")return e+1;let r=e;if(o.charType==="space"){const s=_2(n,t,r,"space");if(!s||s.offset===0)return Z(n,t);if(s.charType==="box")return s.offset;r=s.offset}const i=_2(n,t,r,"text");return i?i.offset:Z(n,t)}const $2=y("word-offset");function md(n,t){const e=n.selection.range.focus;d($2,e.isSimple(),"invalid range type");const o=n.getBlockById(e.blockId);if(wt(n,o))return $(o,0,"home");if(e.offset===0||!j(n,o)){const s=gt(o);if(!s)return null;const l=$(s,Z(n,s),"end");if(t==="select"&&j(n,s)){const c=N2(n,s,l.offset);return $(s,c,"normal")}return l}const r=N2(n,o,e.offset);return $(o,r,"normal")}function gd(n,t){const e=n.selection.range.focus;d($2,e.isSimple(),"invalid range type");const o=n.getBlockById(e.blockId);if(wt(n,o))return $(o,0,"end");if(e.offset===Z(n,o)||!j(n,o)){const s=ht(o);if(!s)return null;const l=$(s,0,"home");if(t==="select"&&j(n,s)){const c=P2(n,s,l.offset);return $(s,c,"end")}return l}const r=P2(n,o,e.offset);return $(o,r,"normal")}function Cv(n){const t=n.selection.range.focus;if(!t.isSimple())return;const e=n.findBlockById(t.blockId);if(!e||!j(n,e))return;const o=md(n,"select"),r=gd(n,"select");!o||!r||n.selection.setSelection(o,r)}const me=y("adjust-selection-pos");function H2(n){const t=[];for(;n;){const e=H(n);if(t.unshift(e),Ct(e))return t;const o=z(e);d(me,o,"child container has not parent container"),n=o}d(me,!1,"should not come here: getParentContainers")}function j2(n,t){for(;t;){const e=H(t);if(e===n)return t;const o=z(e);d(me,o,"could not find parent block for a child container"),t=o}d(me,!1,"no parent block in specified container")}function bv(n,t){const e=H2(n),o=H2(t);d(me,e.length>0&&o.length>0,"block has not parent container"),d(me,e[0]===o[0],"root container does not equal");let r=e[0];for(let l=1;l<e.length||o.length;l++)if(e[l]!==o[l]){r=e[l-1];break}const i=j2(r,n),s=j2(r,t);return{parentContainer:r,newBlock1:i,newBlock2:s}}function F2(n,t){let e=z(t);for(d(me,e,"element is not in a block");e;){const o=H(e);d(me,qe(o),"not a child container");const r=z(o);if(d(me,r,"child container has not parent block"),r===n)return o;e=r}d(me,!1,"failed to find parent container in complex block")}function zl(n,t,e){const o=n.getBlockById(t.blockId),r=n.getBlockById(e.blockId);if(o===r)return t instanceof Ut&&e instanceof Ut?{anchor:t,focus:e}:(d(me,t instanceof Ze&&e instanceof Ze,"both start and end are not simple or complex"),ml(n,o,t,e));const i=H(o),s=H(r);if(i===s)return t instanceof Ze&&(t=$(o,0,"home")),e instanceof Ze&&(e=$(r,Z(n,r),"end")),d(me,t instanceof Ut,"not valid position type"),d(me,e instanceof Ut,"not valid position type"),{anchor:t,focus:e};if(o.contains(s))return null;if(r.contains(i)){if(t instanceof Ut&&e instanceof Ze){const v=n.getContainerById(e.childContainerId);if(v===i)return{anchor:e,focus:e};const w=z(i);if(w&&w===z(v)){const E=bt(w,U(i)),L=bt(w,U(v));return ml(n,w,E,L)}}return null}const l=Xs(o,r)>0,{newBlock1:c,newBlock2:a}=bv(o,r);if(c===a){const v=c,w=F2(v,o),E=F2(v,r);return t=bt(c,U(w)),e=bt(c,U(E)),me.debug(`select in complex block: ${w.id}, ${E.id}`),ml(n,v,t,e)}let u=l?Z(n,c):0;c===o&&t instanceof Ut&&(u=t.offset);let m=l?0:Z(n,a);return a===r&&e instanceof Ut&&(m=e.offset),t=$(c,u,l?"end":"home"),e=$(a,m,l?"home":"end"),{anchor:t,focus:e}}const vv=y("range-from-point");function z2(n,t,e){const o=[0,-12,12];for(let r=0;r<o.length;r++){const i=document.elementsFromPoint(t,e+o[r])[0];if(!i||!n.rootContainer.contains(i))continue;const s=z(i);if(!s||!n.contains(s))continue;const l=kt(n,s).getRangeFromPoint(n,s,t,e+o[r]);if(l)return l}return null}function U2(n,t,e,o){const r=t.getBoundingClientRect();if(o<=r.top){const l=Qt(t),c=$(l,0,"home");return new se(n,{anchor:c,focus:c})}const i=Gt(t),s=$(i,Z(n,i),"end");return new se(n,{anchor:s,focus:s})}function kv(n,t,e){const o=z2(n,t,e);if(o){if(o instanceof se)return o;d(vv,o instanceof Ye,`invalid range type: ${typeof o}`);const c=o,a=n.getContainerById(c.start.childContainerId);return U2(n,a,t,e)}const r=document.elementsFromPoint(t,e)[0];if(!r)return null;const{children:i}=r,s=Array.from(i).filter(c=>fn(c));if(s.length===0)return null;const l=s.reduce((c,a)=>{const u=c.getBoundingClientRect(),f=a.getBoundingClientRect();return hn(u,t,e)>hn(f,t,e)?a:c});return U2(n,l,t,e)}class yv{constructor(t){h(this,"editor");h(this,"startPos",null);h(this,"lastCaretRect");h(this,"mouseDownEvent",null);h(this,"handleMouseDown",t=>{this.mouseDownEvent=t;const e=kv(this.editor,t.x,t.y);if(e){if(e instanceof Ye)return;const o=this.editor.selection.range;if(t.shiftKey&&o.isSimple()){const r=o.anchor;this.editor.selection.setSelection(r,e.focus),this.startPos=e.start}else this.editor.selection.setSelection(e.anchor,e.focus),this.startPos=e.start;this.editor.selection.updateLastCaretRect()}});h(this,"handleMouseMove",t=>{if(!this.startPos||!this.mouseDownEvent||Math.abs(this.mouseDownEvent.x-t.x)<3&&Math.abs(this.mouseDownEvent.y-t.y)<3)return;const e=z2(this.editor,t.x,t.y);if(!e)return;const o=zl(this.editor,this.startPos,e.end);if(!o)return;const{anchor:r,focus:i}=o;this.editor.selection.setSelection(r,i)});h(this,"handleMouseUp",t=>{this.startPos=null});this.editor=t,this.startPos=null,this.lastCaretRect=new DOMRect}isSelecting(){return this.startPos!==null}stopSelection(){this.startPos=null}handleDblClick(t){Cv(this.editor)}handleTripleClick(t){pv(this.editor)}}const wv=y("move-complex-block-position");function Bv(n,t,e){const o=n.getBlockById(t.blockId);d(wv,ct(n,o),"is not a complex block");const r=ve(n,o),i=n.getContainerById(t.childContainerId),s=r.getNextContainer(n,o,i,e,{noWrap:!0});return s?bt(o,U(s)):null}const ji=y("move-simple-block-position");function V2(n,t){const e=Le(n,t);d(ji,e.length>0,"complex block has not any child container");const o=e[0];return Qt(o)}function q2(n,t){const e=Le(n,t);d(ji,e.length>0,"complex block has not any child container");const o=e[e.length-1];return Gt(o)}function W2(n,t,e){const o=e?V2(n,t):q2(n,t);return ct(n,o)?W2(n,o,e):o}function Ev(n,t){const e=n.getBlockById(t.blockId);return ct(n,e)&&t.offset===0?V2(n,e):Cr(e)}function Iv(n,t){const e=n.getBlockById(t.blockId);return ct(n,e)&&t.offset===1?q2(n,e):pr(e)}function pd(n){return n==="ArrowLeft"||n==="ArrowUp"}function Cd(n,t,e){const o=H(t);if(Ct(o))return null;const r=z(o);d(ji,r,"child container has not parent block"),d(ji,ct(n,r),"is not a complex block");const i=ve(n,r).getNextContainer(n,r,o,e);return i?pd(e)?Gt(i):Qt(i):Cd(n,r,e)}function xv(n,t,e){const o=H(t);if(Ct(o))return null;const r=z(o);if(d(ji,r,"child container has not parent block"),pd(e)){const l=gt(r);if(l)return l}else{const l=ht(r);if(l)return l}const i=Cd(n,r,e);if(i)return i;let s=r;for(;!Ct(H(s));)s=z(H(s));return pd(e)?gt(s):ht(s)}function Sv(n,t,e){return!ct(n,t)||ve(n,t).enableKeyboardSelect?t:W2(n,t,e==="ArrowDown"||e==="ArrowRight")}function Tv(n,t,e){const o=n.getBlockById(t.blockId),i=kt(n,o).moveCaret(n,o,t,e);if(i)return i;let s=e==="ArrowDown"||e==="ArrowRight"?Ev(n,t):Iv(n,t);if(s||(s=Cd(n,o,e),s||(s=xv(n,o,e))),!s){if(e==="ArrowDown"||e==="ArrowRight"){if(n.readonly||!Ct(H(o)))return null;const l=n.insertTextBlock("",U(n.rootContainer),Ue(n.rootContainer));return $(l,0,"home")}return null}if(s=Sv(n,s,e),j(n,s)){const l=n.selection.getSuggestedCaretX();if(e==="ArrowDown")return ib(n,s,o,t,l);if(e==="ArrowUp")return rb(n,s,o,t,l)}return e==="ArrowLeft"||e==="ArrowUp"?$(s,Z(n,s),"end"):e==="ArrowRight"||e==="ArrowDown"?$(s,0,"home"):null}function Dv(n,t,e){if(t==="ArrowLeft")return e.start;const o=e.end,r=n.getBlockById(o.blockId);if(j(n,r))return o;const i=ht(r);if(i)return $(i,0,"home");if(!Ct(H(r))||n.readonly)return o;const s=n.insertTextBlock("",U(n.rootContainer),Ue(n.rootContainer));return $(s,0,"home")}function Lv(n,t,e){const o=n.selection.range;let r;if(o instanceof se)e==="move"&&!o.isCollapsed()&&(t==="ArrowLeft"||t==="ArrowRight")?r=Dv(n,t,o):r=Tv(n,o.getFocusedPos(),t);else if(r=Bv(n,o.focus,t),e==="move"){const i=r!=null?r:o.focus,s=n.getContainerById(i.childContainerId);if(t==="ArrowLeft"||t==="ArrowUp"){const l=Gt(s);r=$(l,0,"home")}else{const l=Qt(s);r=$(l,Z(n,l),"end")}}return r?e==="move"?{anchor:r,focus:r}:zl(n,o.anchor,r):null}function io(n,t,e){const o=Lv(n,t,e);if(!o)return!1;const{anchor:r,focus:i}=o;return n.selection.setSelection(r,i),(t==="ArrowLeft"||t==="ArrowRight")&&n.selection.updateLastCaretRect(),!0}function Mv(n){return io(n,"ArrowLeft","move"),!0}function Rv(n){return io(n,"ArrowRight","move"),!0}function Av(n){return io(n,"ArrowUp","move"),!0}function Ov(n){if(io(n,"ArrowDown","move")||n.readonly)return!0;const t=n.getFocusedBlock(),e=H(t);if(Ct(e)||Gt(e)!==t)return!0;const o=n.rootContainer;return n.insertTextBlock("",U(o),Ue(o)),!0}function _v(n){return io(n,"ArrowDown","select"),!0}function Nv(n){return io(n,"ArrowLeft","select"),!0}function Pv(n){return io(n,"ArrowRight","select"),!0}function $v(n){return io(n,"ArrowUp","select"),!0}function Hv(n){if(!n.selection.range.focus.isSimple())return!1;const e=md(n,"move");return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function jv(n){if(!n.selection.range.focus.isSimple())return!1;const e=gd(n,"move");return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function Fv(n){if(!n.selection.range.focus.isSimple())return!1;const e=md(n,"select");return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function zv(n){if(!n.selection.range.focus.isSimple())return!1;const e=gd(n,"select");return e?(n.selection.setSelection(n.selection.range.anchor,e),n.selection.updateLastCaretRect(),!0):!1}y("find-block");function bd(n,t){if(!ct(n,t))return t;const o=ve(n,t).getChildContainers(n,t)[0],i=Rt(o)[0];return bd(n,i)}function vd(n,t){if(!ct(n,t))return t;const e=ve(n,t).getChildContainers(n,t),o=e[e.length-1],r=Rt(o),i=r[r.length-1];return vd(n,i)}function Uv(n){const t=vd(n,Gt(n.rootContainer)),e=$(t,Z(n,t),"end");return n.selection.setSelection(e),!0}function Vv(n){const t=bd(n,n.getFirstBlock()),e=$(t,0,"home");return n.selection.setSelection(e),!0}function qv(n){const t=bd(n,n.getFirstBlock()),e=$(t,0,"home");return n.selection.setSelection(n.selection.getAnchorPos(),e),!0}function Wv(n){const t=vd(n,Gt(n.rootContainer)),e=$(t,Z(n,t),"end");return n.selection.setSelection(n.selection.getAnchorPos(),e),!0}function Gv(n){if(!n.selection.range.focus.isSimple())return!1;const e=hd(n);return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function Zv(n){if(!n.selection.range.focus.isSimple())return!1;const e=fd(n);return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function Yv(n){if(!n.selection.range.focus.isSimple())return!1;const e=hd(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function Qv(n){if(!n.selection.range.focus.isSimple())return!1;const e=fd(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}const G2=y("find-block-position");function Kv(n,t,e,o){d(G2,ct(n,t),"is not a complex block");const r=ve(n,t).getChildContainers(n,t);d(G2,r.length>0,"complex block has not any child container");const i=Ge(n,e,o),s=i.left+i.width/2,l=i.top+i.height/2,c=ug(n,t,s,l);return kd(n,c,e,o)}function kd(n,t,e,o){if(ct(n,t))return Kv(n,t,e,o);const r=G(t);let i=Number.MAX_SAFE_INTEGER;const s=Ge(n,e,o),l=s.left+s.width/2,c=s.top+s.height/2;let a=$(r,0,"home");const u=Z(n,t);for(let f=0;f<=u;f++){const m=$(r,f,"normal"),C=Ge(n,t,m),v=hn(C,l,c);v<i&&(i=v,a=m)}return a}const Z2=y("page-offset");function Jv(n,t){const e=L2(n)*.9,r=t.getBoundingClientRect().bottom-e;if(r<cv(n))return n.getFirstBlock();const i=gt(t);if(!i)return n.getFirstBlock();let s=i;for(;s;){if(s.getBoundingClientRect().y<r)return s;s=gt(s)}return n.getFirstBlock()}function Xv(n,t){const e=L2(n)*.9,o=t.getBoundingClientRect(),r=av(n),i=o.top+e;if(i>r)return n.getLastBlock();const s=ht(t);if(!s)return n.getLastBlock();let l=s;for(;l;){if(l.getBoundingClientRect().bottom>i)return l;l=ht(l)}return n.getLastBlock()}function Y2(n){const t=n.selection.range.focus;d(Z2,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId),o=Jv(n,e);let r;return o===n.getFirstBlock()?r=$(o,0,"home"):r=kd(n,o,e,t),r}function Q2(n){const t=n.selection.range.focus;d(Z2,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId),o=Xv(n,e);let r;return o===n.getLastBlock()?r=$(o,Z(n,o),"end"):r=kd(n,o,e,t),r}function tk(n){if(!n.selection.range.focus.isSimple())return!1;const e=Y2(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function ek(n){if(!n.selection.range.focus.isSimple())return!1;const e=Q2(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function nk(n){if(!n.selection.range.focus.isSimple())return!1;const e=Y2(n);if(!e)return!1;const o=zl(n,n.selection.getAnchorPos(),e);if(!o)return!1;const{anchor:r,focus:i}=o;return n.selection.setSelection(r,i),n.selection.updateLastCaretRect(),!0}function ok(n){if(!n.selection.range.focus.isSimple())return!1;const e=Q2(n);if(!e)return!1;const o=zl(n,n.selection.getAnchorPos(),e);if(!o)return!1;const{anchor:r,focus:i}=o;return n.selection.setSelection(r,i),n.selection.updateLastCaretRect(),!0}const Fi=y("select-all");function rk(n,t){const e=t.getEditor(),o=ve(e,n).getChildContainers(e,n),r=o[0],i=o[o.length-1],s=G(n);return t.start.blockId===s&&t.start.childContainerId===U(r)&&t.end.blockId===s&&t.end.childContainerId===U(i)}function ik(n,t){d(Fi,t,"no parent block"),d(Fi,ct(n,t),"not a complex block");const e=ve(n,t).getChildContainers(n,t),o=e[0],r=e[e.length-1];n.selection.setRange(Vt(n,{anchor:bt(t,U(o)),focus:bt(t,U(r))}))}function K2(n,t){const e=H(t),o=Rt(e),r=o[0],i=o[o.length-1],s=$(r,0,"home"),l=$(i,Z(n,i),"end");n.selection.setSelection(s,l,{noScroll:!0})}function sk(n){const t=n.getFocusedBlock(),e=n.selection.range;if(e.start.isSimple()){if(e.start.blockId===e.end.blockId&&j(n,t)){const r=e.start,i=e.end,s=Z(n,t);if(r.offset>0||i.offset<s)return n.selection.selectBlock(t,0,s),!1}return M(n.rootContainer,"select-all"),K2(n,Qt(n.rootContainer)),!1}return d(Fi,!e.isSimple(),"invalid range type"),rk(t,e)?(K2(n,t),!1):(d(Fi,t,"no parent block"),d(Fi,ct(n,t),"not a complex block"),ik(n,t),!0)}function lk(n){return n.readonly||!n.isWritable()?!1:(n.undoManager.undo(),!0)}function ck(n){return n.readonly||!n.isWritable()?!1:(n.undoManager.redo(),!0)}const J2=y("delete-text");function X2(n,t,e,o){const r=o!=null?o:n.selection.range.start;r instanceof Ut||d(J2,!1,`invalid insert pos type: ${typeof r}`);const{blockId:i}=r,s=n.getBlockById(i);d(J2,j(n,s),"block is not a text kind block");let{offset:l}=r;if(t==="backward"){if(l-e<0)return 0;if(!fe(s,l-e)){const c=Po(s,l);e=l-c}}else if(t==="forward"&&l+e>Z(n,s))return 0;return t==="backward"&&(l-=e),n.deleteTextFromBlock(s,l,e)}function t0(n,t){if(n.getBlockData(t).quoted){const e={quoted:null};return n.updateBlockData(t,e),!0}return!1}const ak=y("handle-backspace");function yd(n,t){if(!wt(n,t))return;const e=H(t);Ue(e)!==1&&n.deleteBlock(t)}function dk(n,t){if(!n.selection.range.isCollapsed()){n.clearSelectedContents();return}const e=n.selection.range.start,o=n.getBlockById(e.blockId);if(j(n,o))if(e.offset===0){if(t0(n,o))return;const r=gt(o);if(r)if(j(n,r))n.mergeTextBlock(r,o,{focus:!0});else if(ct(n,r)){yd(n,o);const i=wr(n,r);i?n.selection.selectBlock(i,Z(n,i)):n.selection.selectBlock(r,0,Z(n,r))}else yd(n,o),d(ak,Te(r),"prev block is not embed block"),n.selection.selectBlock(r,1);else{const i=H(o);if(qe(i)){const s=cg(n,i);s&&(yd(n,o),n.selection.selectBlock(s,Z(n,s)))}}}else X2(n,"backward",1,null);else{const r=K(o),i=H(o);n.insertTextBlock("",U(i),r),n.deleteBlock(o)}}function uk(n,t){if(!n.selection.range.isCollapsed()){n.clearSelectedContents();return}const e=n.selection.range.start,o=n.getBlockById(e.blockId);if(j(n,o))if(e.offset===Z(n,o)){const r=ht(o);r&&(j(n,r)?n.mergeTextBlock(o,r,{focus:!0}):wt(n,o)?n.deleteBlock(o,Ot(n,r,0)):n.deleteBlock(r))}else X2(n,"forward",1,null);else{const r=K(o),i=H(o);n.insertTextBlock("",U(i),r),n.deleteBlock(o)}}function hk(n,t){n.selection.range.isCollapsed()||n.clearSelectedContents();const e=n.getFocusedBlock();if(j(n,e)){if(wt(n,e)&&t0(n,e))return;const o=n.selection.range.start,r=n.breakTextBlock(e,o.offset,{copyBlockAttributes:!0});o.offset!==0?n.selection.selectBlock(r,0):n.selection.scrollIntoView()}else{const o=n.insertTextBlock();n.selection.selectBlock(o,0)}}function fk(n,t){const e=n.selection.range.getSelectedBlocks()[0],{block:o}=e;if(!j(n,o))return!1;const r=e.end;return n.insertBoxToBlock(o,r.offset,{type:"br",id:N(),box:!0,created:Date.now()}),!0}const mk=y("input-handler-actions");function gk(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(hk(n),!0))}function pk(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(uk(n),!0))}function Ck(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(dk(n),!0))}function bk(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(fk(n),!0))}function vk(n){return n.readonly||!n.isWritable()||!window.isSecureContext?!1:(navigator.clipboard.readText().then(t=>{const e=n.selection.focusedBlock,o=n.selection.range.start;d(mk,o.isSimple(),"not simple position"),n.insertTextToBlock(e,o.offset,t)}),!0)}function kk(n){return ov(n),Y1(n),!0}const Ul={ArrowDown:Ov,ArrowUp:Av,ArrowLeft:Mv,ArrowRight:Rv,"Shift+ArrowDown":_v,"Shift+ArrowUp":$v,"Shift+ArrowLeft":Nv,"Shift+ArrowRight":Pv,"CtrlOrCmd+ArrowLeft":Hv,"CtrlOrCmd+ArrowRight":jv,"CtrlOrCmd+Shift+ArrowLeft":Fv,"CtrlOrCmd+Shift+ArrowRight":zv,"CtrlOrCmd+ArrowUp":Vv,"CtrlOrCmd+ArrowDown":Uv,"CtrlOrCmd+Shift+ArrowUp":qv,"CtrlOrCmd+Shift+ArrowDown":Wv,"CtrlOrCmd+A":sk,Home:Yv,End:Qv,"Shift+Home":Gv,"Shift+End":Zv,PageUp:tk,PageDown:ek,"Shift+PageUp":nk,"Shift+PageDown":ok,"CtrlOrCmd+X":kk,"CtrlOrCmd+Z":lk,"CtrlOrCmd+Shift+Z":ck,Enter:gk,Delete:pk,Backspace:Ck,"Shift+Enter":bk,"CtrlOrCmd+Shift+V":vk};function e0(n,t){return n.shortcuts.handleKeyboardEvents(n,t)!==void 0}function n0(n,t,e){if(t.type==="embed"){const i=t.embedData,s=i.src;if(s&&typeof s=="string"){const l=e.get(s);l&&(i.src=l)}return}const o=t.text;o&&o.forEach(i=>{if(i.attributes&&i.attributes.src&&typeof i.attributes.src=="string"){const s=e.get(i.attributes.src);s&&(i.attributes.src=s)}});const r=t.children;r&&r.forEach(i=>{n.blocks[i].forEach(l=>{n0(n,l,e)})})}function o0(n,t,e){if(e.size===0)return;t.blocks.root.forEach(r=>{const i=n.editorBlocks.getBlockClass(r.type);i.replaceResources?i.replaceResources(r,e):n0(t,r,e)})}async function yk(n,t){const e=t.filter(i=>i.indexOf(":")===-1),o=await n.doc.addResources(e),r=new Map;if(e.length!==o.length)return r;for(let i=0;i<e.length;i++)r.set(e[i],o[i]);return r}function wk(n,t){var i,s;const o=t.meta.serverId;if(!o||typeof o!="string")return!1;const r=(s=(i=n.doc).getServerMeta)==null?void 0:s.call(i);return!(!r||r.serverId!==o)}async function Bk(n,t){const o=t.meta.resources;if(!o||Object.keys(o).length===0)return;let r=new Map;if(wk(n,t)){const s=Array.from(Object.keys(o));r=await yk(n,s),o0(n,t,r)}const i=new Map;Object.entries(o).forEach(([s,l])=>{r.get(s)===void 0&&s!==l&&i.set(s,l)}),i.size!==0&&o0(n,t,i)}async function Ek(n,t){await Bk(n,t),n.undoManager.runInGroup(()=>{n.clearSelectedContents();const{block:e,offset:o}=Tr(n);n.insertDoc(e,o,t)})}const Ik=["text/x-ones-editor-doc","image/*","text/html","text/plain","text/markdown","*"];function xk(n){let t;for(const e of Ik)if(t=n[e],t)break;return t||null}class Sk{constructor(t){h(this,"editor");h(this,"handlers",[]);this.editor=t}onInsertText(t,e){if(!j(this.editor,this.editor.getFocusedBlock()))return;const{containerId:o,blockIndex:r,offset:i}=Tr(this.editor);this.handleBeforeInsertText(o,r,i,e)||(this.defaultInsertText(this.editor,o,r,i,e),this.handleAfterInsertText(o,r,i,e))}onKeyDown(t){if(this.handleBeforeKeyDown(t))return!0;const e=this.defaultHandleKeydown(this.editor,t);return this.handleAfterKeyDown(t)?!0:e}onChanged(t){for(let e=0;e<this.handlers.length;e++){const o=this.handlers[e];o.handleChanged&&o.handleChanged(this.editor,t)}}onRemoteChanged(t){for(let e=0;e<this.handlers.length;e++){const o=this.handlers[e];o.handleRemoteChanged&&o.handleRemoteChanged(this.editor,t)}}onCompositionStart(t){this.editor.updateCompositionText("",!1);const{containerId:e,blockIndex:o,offset:r}=Tr(this.editor);for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];s.handleCompositionStart&&s.handleCompositionStart(this.editor,e,o,r)}}onUpdateCompositionText(t,e,o){this.editor.updateCompositionText(e,o),this.editor.selection.caret.update();const{containerId:r,blockIndex:i,offset:s}=Tr(this.editor);for(let l=0;l<this.handlers.length;l++){const c=this.handlers[l];c.handleUpdateCompositionText&&c.handleUpdateCompositionText(this.editor,r,i,s,o)}}onPaste(t){if(t.preventDefault(),t.stopPropagation(),!t.clipboardData)return;this.editor.dataConverter.fromData(this.editor,t.clipboardData).then(async o=>{if(!o)return;for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];if(s.handleBeforePaste&&await s.handleBeforePaste(this.editor,t,o))return}const r=xk(o);if(!!r){await this.pasteDoc(r);for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];if(s.handleAfterPaste&&await s.handleAfterPaste(this.editor,t,o))return}}})}onFocus(){M(this.editor.rootElement,"active")}onBlur(){F(this.editor.rootElement,"active")}addHandler(t){this.handlers.push(t)}removeHandler(t){const e=this.handlers.indexOf(t);e!==-1&&this.handlers.splice(e)}handleBeforeInsertText(t,e,o,r){for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];if(s.handleBeforeInsertText&&s.handleBeforeInsertText(this.editor,t,e,o,r))return!0}return!1}handleAfterInsertText(t,e,o,r){for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];if(s.handleAfterInsertText&&s.handleAfterInsertText(this.editor,t,e,o,r))return!0}return!1}handleBeforeKeyDown(t){for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleBeforeKeyDown&&r.handleBeforeKeyDown(this.editor,t))return!0}const e=this.defaultHandleKeydown(this.editor,t);for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleAfterKeyDown&&r.handleAfterKeyDown(this.editor,t))return!0}return e}handleAfterKeyDown(t){for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleBeforeKeyDown&&r.handleBeforeKeyDown(this.editor,t))return!0}const e=this.defaultHandleKeydown(this.editor,t);for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleAfterKeyDown&&r.handleAfterKeyDown(this.editor,t))return!0}return e}defaultInsertText(t,e,o,r,i){U1(this.editor,i)}defaultHandleKeydown(t,e){return e0(this.editor,e)?(e.preventDefault(),e.stopPropagation(),!0):!1}async pasteDoc(t){for(let e=0;e<this.handlers.length;e++){const o=this.handlers[e];if(o.handleBeforePasteDoc&&await o.handleBeforePasteDoc(this.editor,t))return}await Ek(this.editor,t);for(let e=0;e<this.handlers.length;e++){const o=this.handlers[e];if(o.handleAfterPasteDoc&&await o.handleAfterPasteDoc(this.editor,t))return}}destroy(){this.handlers.forEach(t=>{var e;(e=t.destroy)==null||e.call(t,this.editor)}),this.handlers=[]}}function Tk(n,t,e){const o=mr(t,e);return o.remove(),o}const wd=y("copy-dom-attributes"),r0=["onabort","onanimationcancel","onanimationend","onanimationiteration","onanimationstart","onauxclick","onblur","oncanplay","oncanplaythrough","onchange","onclick","onclose","oncontextmenu","oncuechange","ondblclick","ondrag","ondragend","ondragenter","ondragleave","ondragover","ondragstart","ondrop","ondurationchange","onemptied","onended","onerror","onfocus","onformdata","ongotpointercapture","oninput","oninvalid","onkeydown","onkeypress","onkeyup","onload","onloadeddata","onloadedmetadata","onloadstart","onlostpointercapture","onmousedown","onmouseenter","onmouseleave","onmousemove","onmouseout","onmouseover","onmouseup","onpause","onplay","onplaying","onpointercancel","onpointerdown","onpointerenter","onpointerleave","onpointermove","onpointerout","onpointerover","onpointerup","onprogress","onratechange","onreset","onresize","onscroll","onsecuritypolicyviolation","onseeked","onseeking","onselect","onselectionchange","onselectstart","onslotchange","onstalled","onsubmit","onsuspend","ontimeupdate","ontoggle","ontouchcancel","ontouchend","ontouchmove","ontouchstart","ontransitioncancel","ontransitionend","ontransitionrun","ontransitionstart","onvolumechange","onwaiting","onwebkitanimationend","onwebkitanimationiteration","onwebkitanimationstart","onwebkittransitionend","onwheel"];function Dk(n,t){for(let l=0;l<r0.length;l++){const c=r0[l];t[c]=n[c]}const e=n.attributes,o=t.attributes,r=[],i=[];for(let l=0;l<e.length;l++){const c=e[l],a=o.getNamedItem(c.name);a?a.value!==c.value&&(a.value=c.value,i.push(c)):r.push(c)}const s=[];for(let l=0;l<o.length;l++){const c=o[l];e.getNamedItem(c.name)||s.push(c)}r.forEach(l=>{wd.debug(`add attribute: ${l.name}, ${l.value}`),t.setAttribute(l.name,l.value)}),i.forEach(l=>{wd.debug(`copy attribute: ${l.name}, ${l.value}`),t.setAttribute(l.name,l.value)}),s.forEach(l=>{wd.debug(`delete attribute: ${l.name}`),t.removeAttribute(l.name)})}function i0(n){const t=Array.from(n.childNodes);return t.forEach(e=>{e instanceof HTMLElement&&e.getAttribute("data-type")==="block-tools"||e.remove()}),t}function s0(n,t,e){var a;const o=n.getContainerById(t),r=mr(o,e),i=Ro(r),s=n.doc.getBlockData(t,e),l=kt(n,r);if((a=l==null?void 0:l.handleUpdateBlock)==null?void 0:a.call(l,n,r,s))n.editorBlockRenders.updateBlock(n,i,r,s);else{const u=n.editorBlocks.createBlock(i,o,s),f=i0(u);i0(r),f.forEach(C=>r.appendChild(C));const m=al(u);if(m){const C=al(r);C&&C.remove(),r.appendChild(m)}Dk(u,r)}Ym(n,r,s),n.blockHooks.forEach(u=>{var f;(f=u.update)==null||f.call(u,n,i,o,r,s)}),setTimeout(()=>{n.selection.updateSelection(null)})}const Lk=y("transform-selection");function l0(n,t,e,o){const{range:r}=n.selection,{anchor:i,focus:s}=r;if(i.blockId!==t&&s.blockId!==t)return r;d(Lk,i.isSimple()&&s.isSimple(),"invalid text pos type");let l=i;if(i.blockId===t){const a=ne.transformCursor(i.offset,e,o);l=$(t,a,"normal")}let c=s;if(s.blockId===t){const a=ne.transformCursor(s.offset,e,o);c=$(t,a,"normal")}return Vt(n,{anchor:l,focus:c})}const Mk=y("handle-block-text-changed");function Rk(n,t,e,o,r){const i=n.getContainerById(t),s=mr(i,e),l=n.doc.getBlockData(t,e);if(d(Mk,l.text,"no block text"),qm(n,s).setBlockText(n,s,l.text),!r){const c=l0(n,l.id,o,r);n.selection.setRange(c)}}function Ak(n,t){const e=Y.default(n);return t.delete.forEach(r=>{delete e[r]}),{...e,...t.insert}}function c0(n,t,e,o){const r=kt(n,t);r.handleDeleteBlock&&r.handleDeleteBlock(n,t,e,o),n.emit("blockDeleted",n,t,e,o)}function Ok(n,t,e,o){const r=n.getBlockByIndex(t,e);r.querySelectorAll('[data-type="editor-block"]').forEach(i=>{c0(n,i,o,{child:!0})}),c0(n,r,o,{child:!1})}const so=y("editor-doc");class _k extends ki{constructor(e,o,r){super();h(this,"localEvents",[]);this.editor=e,this.externalDoc=o,this.externalDoc.registerCallback(this),this.registerLocalEvents(r)}beginBatchUpdate(){return this.externalDoc.beginBatchUpdate()}endBatchUpdate(){return this.externalDoc.endBatchUpdate()}registerLocalEvents(e){this.localEvents.push(e)}toJSON(){return this.externalDoc.toJSON()}getVersionHelper(){var o,r;return(r=(o=this.externalDoc).getVersionHelper)==null?void 0:r.call(o)}getContainerBlocks(e){return this.externalDoc.getContainerBlocks(e)}getBlockData(e,o){return this.externalDoc.getBlockData(e,o)}localUpdateBlockText(e,o,r){d(so,this.editor.isWritable(),"editor is readonly");const i=this.getBlockData(e,o),s=i.text;d(so,s,`no text, ${e}, ${o}`);const l=l0(this.editor,i.id,r,!0),c=ne.apply(s,r);this.localEvents.forEach(u=>u.onBeforeUpdateBlockText(e,i.id,s,c,l.toDocRange()));const a=this.externalDoc.localUpdateBlockText(e,o,r);return this.editor.selection.setRange(l),a}localUpdateBlockData(e,o,r,i){d(so,this.editor.isWritable(),"editor is readonly");const s=Y.default(this.getBlockData(e,o)),l=Y.default(Ak(s,r));this.localEvents.forEach(a=>a.onBeforeUpdateBlockData(e,s.id,s,l,i));const c=this.externalDoc.localUpdateBlockData(e,o,r,i);return this.editor.selection.setRange(no(this.editor,i)),c}localInsertBlock(e,o,r,i){d(so,this.editor.isWritable(),"editor is readonly"),this.localEvents.forEach(l=>l.onBeforeInsertBlock(e,o,r,i));const s=this.externalDoc.localInsertBlock(e,o,r,i);return this.editor.selection.setRange(no(this.editor,i)),s}localDeleteBlock(e,o,r){d(so,this.editor.isWritable(),"editor is readonly");const i=Y.default(this.getBlockData(e,o));this.localEvents.forEach(l=>l.onBeforeDeleteBlock(e,o,i,r));const s=this.externalDoc.localDeleteBlock(e,o,r);return this.editor.selection.setRange(no(this.editor,r)),s}localDeleteChildContainers(e){return d(so,this.editor.isWritable(),"editor is readonly"),e.forEach(o=>{const r=Y.default(this.getContainerBlocks(o));this.localEvents.forEach(i=>i.onBeforeDeleteChildContainer(o,r))}),this.externalDoc.localDeleteChildContainers(e)}localInsertChildContainer(e,o){return d(so,this.editor.isWritable(),"editor is readonly"),this.localEvents.forEach(r=>r.onBeforeInsertChildContainer(e,Y.default(o))),this.externalDoc.localInsertChildContainer(e,o)}onRequestReload(e){so.debug(`reload doc: ${e}`),this.editor.reload(),this.callbacks.forEach(o=>{var r;return(r=o.onRequestReload)==null?void 0:r.call(o,e)})}onUpdateBlockText(e,o,r,i){this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockText)==null?void 0:l.call(s,e,o,r,i)}),Rk(this.editor,e,o,r,i),i&&this.editor.emit("docChanged",this.editor)}onUpdateBlockData(e,o,r,i){this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,e,o,r,i)}),s0(this.editor,e,o),i&&this.editor.emit("docChanged",this.editor)}onInsertBlock(e,o,r,i){this.callbacks.forEach(l=>{var c;return(c=l.onInsertBlock)==null?void 0:c.call(l,e,o,r,i)});const s=this.editor.getContainerById(e);lC(this.editor,s,o,r),i&&this.editor.emit("docChanged",this.editor)}onDeleteBlock(e,o,r){Ok(this.editor,e,o,r),this.callbacks.forEach(s=>{var l;return(l=s.onDeleteBlock)==null?void 0:l.call(s,e,o,r)});const i=this.editor.getContainerById(e);Tk(this.editor,i,o),r&&this.editor.emit("docChanged",this.editor)}onInsertChildContainer(e,o,r){this.callbacks.forEach(i=>{var s;return(s=i.onInsertChildContainer)==null?void 0:s.call(i,e,o,r)})}onDeleteChildContainer(e,o){this.callbacks.forEach(r=>{var i;return(i=r.onDeleteChildContainer)==null?void 0:i.call(r,e,o)})}onCustomMessage(e){this.callbacks.forEach(o=>{var r;return(r=o.onCustomMessage)==null?void 0:r.call(o,e)})}onStatusChanged(e){this.callbacks.forEach(o=>{var r;return(r=o.onStatusChanged)==null?void 0:r.call(o,e)})}onError(e){this.callbacks.forEach(o=>{var r;return(r=o.onError)==null?void 0:r.call(o,e)})}uploadResource(e,o){return this.externalDoc.uploadResource(e,o)}addResources(e){return this.externalDoc.addResources(e)}buildResourceUrl(e,o){return this.externalDoc.buildResourceUrl(e,o)}request(e,o){return this.externalDoc.request(e,o)}broadcastMessage(e){return this.externalDoc.broadcastMessage(e)}getUser(){return this.externalDoc.getUser()}getRemoteUsers(){return this.externalDoc.getRemoteUsers()}destroy(){this.externalDoc.destroy(),this.clearCallbacks()}getServerMeta(){var e,o,r;return(r=(o=(e=this.externalDoc).getServerMeta)==null?void 0:o.call(e))!=null?r:{}}}function a0(n,t){if(n.length===0){n.push(t);return}const e=n[n.length-1];if(!e.combinable(t)){n.push(t);return}e.combine(t)}const Bd=y("undo-action");class Mr{constructor(t,e,o){h(this,"beforeRange");h(this,"afterRange");this.containerId=e,this.beforeRange=t.selection.range.clone().toDocRange(),this.afterRange=o}undo(t){return!1}redo(t){return!1}combinable(t){return d(Bd,t,"no other action"),!1}combine(t){d(Bd,!1,"no other")}setAfterRange(t){this.afterRange&&Bd.warn("after range has already set"),this.afterRange=t}}const Nk=y("block-action");class d0 extends Mr{constructor(e,o,r,i,s){super(e,o,s);h(this,"blockData");h(this,"blockIndex");this.blockData=Y.default(i),this.blockIndex=r}deleteBlock(e,o){if(!e.getContainerById(this.containerId))return!1;const i=e.getBlockById(this.blockData.id);return i?(d(Nk,this.blockIndex===K(i),"invalid block index"),W1(e,i,no(e,o)),!0):!1}insertBlock(e,o){return Dr(e,this.containerId,this.blockIndex,Y.default(this.blockData),o),!0}}class Pk extends d0{undo(t){return this.deleteBlock(t,this.beforeRange)}redo(t){return this.insertBlock(t,this.afterRange)}}class $k extends d0{undo(t){return this.insertBlock(t,this.beforeRange)}redo(t){return this.deleteBlock(t,this.afterRange)}}class Hk extends Mr{constructor(e){super(e,U(e.rootContainer),e.selection.range.toDocRange());h(this,"actions",[])}addAction(e){a0(this.actions,e),this.afterRange=e.afterRange}undo(e){let o=!1;return this.actions.concat().reverse().forEach(r=>{r.undo(e)&&(o=!0)}),o}redo(e){let o=!1;return this.actions.forEach(r=>{r.redo(e)&&(o=!0)}),o}setAfterRange(e){this.afterRange=e;const o=this.actions[this.actions.length-1];!o||o instanceof Mr&&(o.afterRange||o.setAfterRange(e))}}const zo=y("update-block-data-action");class Vl extends Mr{constructor(e,o,r,i,s,l){super(e,o,l);h(this,"beforeBlockData");h(this,"afterBlockData");h(this,"blockId");this.blockId=r,d(zo,this.blockId===i.id,"invalid block id"),d(zo,this.blockId===s.id,"invalid block id"),this.beforeBlockData=Y.default(i),this.afterBlockData=Y.default(s),d(zo,this.beforeBlockData.type===this.afterBlockData.type,"invalid block type")}undo(e){d(zo,e,"no editor");const o=e.getBlockById(this.blockId);if(!o)return!1;const r=e.getContainerById(this.containerId);return d(zo,r,"no container"),Pl(e,o,Vl.toAttributes(this.beforeBlockData),this.beforeRange),!0}redo(e){d(zo,e,"no editor");const o=e.getBlockById(this.blockId);if(!o)return!1;const r=e.getContainerById(this.containerId);return d(zo,r,"no container"),Pl(e,o,Vl.toAttributes(this.afterBlockData),this.afterRange),!0}static toAttributes(e){const o=Y.default(e);return delete o.id,delete o.type,o}}const Ed=y("update-block-text-action");class zi extends Mr{constructor(e,o,r,i,s,l){super(e,o,l);h(this,"beforeRichTextData");h(this,"afterRichTextData");h(this,"blockId");h(this,"type");this.blockId=r,this.beforeRichTextData=Y.default(i),this.afterRichTextData=Y.default(s),this.type=zi.calType(i,s)}static calType(e,o){d(Ed,e,"no old data"),d(Ed,o,"no new data");const i=ne.diff(e,o),s=new Set;let l=!1;const c=u=>em(u)?`cjk_${u}`:Xf(u)?"number":tl(u)?"space":tm(u)?"letter":"unknown";let a=!1;return i.forEach(u=>{u.insert?u.insert===" "?s.add("insert_letter"):typeof u.insert=="string"&&u.insert.startsWith(" ")&&u.insert.length>1?(l=!0,a=!0,s.add(`insert_${c(u.insert.substr(1))}`)):s.add(`insert_${c(u.insert)}`):u.delete&&(l?l=!1:s.add("delete"))}),{textType:Array.from(s).join("|"),begin:a}}undo(e){if(!e.getContainerById(this.containerId))return!1;const r=e.getBlockById(this.blockId);return r?(Nl(e,r,this.beforeRichTextData),!0):!1}redo(e){if(!e.getContainerById(this.containerId))return!1;const r=e.getBlockById(this.blockId);return r?(Nl(e,r,this.afterRichTextData),!0):!1}combinable(e){if(!(e instanceof zi)||e.type.begin||this.type.textType!==e.type.textType||e.blockId!==this.blockId)return!1;const o=e.beforeRange,r=o.anchor;if(!r.isSimple())return!1;const i=this.afterRange;if(!i)return!1;const s=i.anchor;return!(!s.isSimple()||s.blockId!==o.anchor.blockId||s.offset!==r.offset)}combine(e){d(Ed,e instanceof zi,"invalid action type");const o=e;this.afterRichTextData=o.afterRichTextData,this.afterRange=e.afterRange}}class u0 extends Mr{constructor(t,e,o){super(t,e,t.selection.range.toDocRange()),this.blocks=o}deleteChildContainer(t){return t.doc.localDeleteChildContainers([this.containerId]),!0}insertChildContainer(t){return t.doc.localInsertChildContainer(this.containerId,Y.default(this.blocks)),!0}}class jk extends u0{undo(t){return this.deleteChildContainer(t)}redo(t){return this.insertChildContainer(t)}}class Fk extends u0{undo(t){return this.insertChildContainer(t)}redo(t){return this.deleteChildContainer(t)}}const Je=y("undo");class zk{constructor(t){h(this,"editor");h(this,"actions",[]);h(this,"undoCursor");h(this,"currentGroup",null);h(this,"groupCounter",0);h(this,"undoRedoing",!1);h(this,"handleSelectionChange",t=>{if(this.currentGroup){this.currentGroup.setAfterRange(t.selection.range.toDocRange());return}const e=this.actions[this.actions.length-1];!e||e.afterRange||e.setAfterRange(t.selection.range.toDocRange())});this.editor=t,this.undoCursor=-1,this.editor.addListener("selectionChanged",this.handleSelectionChange)}reset(){this.actions=[],this.undoCursor=-1}prepareSaveUndoState(){this.undoCursor!==-1&&(this.actions.splice(this.undoCursor),this.undoCursor=-1)}addAction(t){this.currentGroup?this.currentGroup.addAction(t):(a0(this.actions,t),setTimeout(()=>{this.editor.input.handleChanged(t)}))}beginGroup(){this.groupCounter===0?(d(Je,!this.currentGroup,"current group already exists"),this.currentGroup=new Hk(this.editor),this.groupCounter=1):(d(Je,this.currentGroup,"current group not exists"),this.groupCounter+=1)}endGroup(){d(Je,this.currentGroup,"current group not exists"),d(Je,this.groupCounter>0,"group counter === 0"),this.groupCounter-=1,this.groupCounter===0&&(this.currentGroup.actions.length===0?Je.warn("empty undo group, skip it"):(this.actions.push(this.currentGroup),this.editor.input.handleChanged(this.currentGroup)),this.currentGroup=null)}hasGroup(){return this.groupCounter>0}runInGroup(t){this.beginGroup();try{const e=t();return setTimeout(()=>this.editor.selection.caret.update()),e}catch(e){throw Je.error(`failed to run action: ${e.message}`),e}finally{this.endGroup()}}undo(){this.undoCursor===-1&&(this.undoCursor=this.actions.length);try{for(this.undoRedoing=!0;this.undoCursor>0;){this.undoCursor-=1;const t=this.actions[this.undoCursor];if(t.undo(this.editor)){try{this.editor.selection.setRange(no(this.editor,t.beforeRange))}catch(e){Je.error(`undo: failed to restore caret pos: ${e.message}`)}return this.editor.input.handleChanged(t),!0}}return!1}finally{this.undoRedoing=!1}}redo(){this.undoCursor===-1&&(this.undoCursor=this.actions.length);try{for(this.undoRedoing=!0;this.undoCursor<this.actions.length;){const t=this.actions[this.undoCursor];if(this.undoCursor+=1,t.redo(this.editor)){try{const e=t.afterRange;e?this.editor.selection.setRange(no(this.editor,e)):Je.warn("no after range")}catch(e){Je.error(`redo: failed to set caret pos after redo: ${e.message}`)}return this.editor.input.handleChanged(t),!0}}return!1}finally{this.undoRedoing=!1}}canUndo(){return!(this.actions.length===0||this.undoCursor===0)}canRedo(){return!(this.actions.length===0||this.undoCursor===-1||this.undoCursor===this.actions.length)}lastAction(){var e;const t=this.undoCursor===-1?this.actions.length-1:this.undoCursor-1;return(e=this.actions[t])!=null?e:null}undoTo(t){for(;;){const e=this.lastAction();if(!e||e===t)return!0;if(!this.undo())return!1}}onBeforeUpdateBlockText(t,e,o,r,i){this.undoRedoing||(this.prepareSaveUndoState(),ne.diff(o,r).length!==0&&this.addAction(new zi(this.editor,t,e,o,r,i)))}onBeforeUpdateBlockData(t,e,o,r,i){if(this.undoRedoing)return;this.prepareSaveUndoState();const s=new Vl(this.editor,t,e,o,r,i);this.addAction(s)}onBeforeInsertBlock(t,e,o,r){this.undoRedoing||(this.prepareSaveUndoState(),d(Je,e>=0,"invalid block index"),d(Je,o,"no block data"),this.addAction(new Pk(this.editor,t,e,o,r)))}onBeforeDeleteBlock(t,e,o,r){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new $k(this.editor,t,e,o,r)))}onBeforeInsertChildContainer(t,e){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new jk(this.editor,t,e)))}onBeforeDeleteChildContainer(t,e){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new Fk(this.editor,t,e)))}}class Uk{async fromData(t,e){const o=e.getData("text/x-ones-editor-doc");if(o)return{"text/x-ones-editor-doc":JSON.parse(o)}}}class Vk{constructor(){h(this,"converters",[]);this.addConverter(new Uk)}async fromData(t,e){let o={};for(const r of this.converters){const i=await r.fromData(t,e);i&&(o={...o,...i})}return o}addConverter(t){this.converters.push(t)}}class qk{constructor(t){h(this,"renders",[]);this.editor=t}registerRender(t){this.renders.push(t)}renderText(t,e){const o={classes:[],attributes:{},styles:{}};return this.renders.forEach(r=>{if(r.renderText){const i=r.renderText(this.editor,t,e);i.classes&&o.classes.push(...i.classes),i.attributes&&(o.attributes={...o.attributes,...i.attributes}),i.styles&&(o.styles={...o.styles,...i.styles})}}),o}renderBlock(t,e,o){const r={classes:[],attributes:{},styles:{}};return this.renders.forEach(i=>{if(i.renderBlock){const s=i.renderBlock(this.editor,e,o);s.classes&&r.classes.push(...s.classes),s.attributes&&(r.attributes={...r.attributes,...s.attributes}),s.styles&&(r.styles={...r.styles,...s.styles})}}),r}updateBlock(t,e,o,r){this.renders.forEach(i=>{var s;(s=i.updateBlock)==null||s.call(i,t,e,o,r)})}}class _t extends Wt.TypedEmitter{constructor(e){super();h(this,"hoveringBlock",null);h(this,"hoveringTextChild",null);h(this,"filters",[]);h(this,"finders",[]);h(this,"handleDocumentMouseMove",e=>{if(this.hoveringBlock){for(const s of this.filters)if(s.isInBlock(this.hoveringBlock,e))return}const o=document.elementFromPoint(e.x,e.y);if(!o){this.setHoveringBlock(null,e,null);return}let r=z(o);if((!r||!vt(this.editor.rootContainer,r))&&(r=this.findBlockByFinders(e),!r)){this.setHoveringBlock(null,e,null);return}const i=this.getParentTextContentChild(r,o);this.setHoveringBlock(r,e,i)});this.editor=e,document.addEventListener("mousemove",this.handleDocumentMouseMove)}destroy(){document.removeEventListener("mousemove",this.handleDocumentMouseMove),this.filters.forEach(e=>e.destroy()),this.filters=[],this.finders.forEach(e=>e.destroy()),this.finders=[]}addFilter(e){this.filters.push(e)}addFinder(e){this.finders.push(e)}hoveringBlockId(){return this.hoveringBlock?G(this.hoveringBlock):""}findBlockByFinders(e){for(let o=0;o<this.finders.length;o++){const i=this.finders[o].findTargetBlock(this.editor,e);if(i)return i}return null}setHoveringBlock(e,o,r){if(this.hoveringBlock===e&&this.hoveringTextChild===r)return;if(this.hoveringBlock!==e){const s=this.hoveringBlock&&vt(this.editor.rootContainer,this.hoveringBlock)?this.hoveringBlock:null;s&&F(s,"hover"),e&&M(e,"hover"),this.hoveringBlock=e,this.emit("change",this.hoveringBlock,s,o)}const i=this.hoveringTextChild;this.hoveringTextChild=r,this.emit("childChange",this.hoveringBlock,r,i,o)}static get(e){return e.addCustom("standard-hovering-block",()=>new _t(e))}getParentTextContentChild(e,o){if(!j(this.editor,e))return null;const r=rt(e);return o.parentElement===r?o:l1(o)}}const h0="style-color-",f0="style-bg-color-";class Wk{renderText(t,e,o){const r=[],i={};return Object.entries(o).forEach(([s,l])=>{l===!0?s.startsWith(h0)?i["data-style-color"]=s.substring(h0.length):s.startsWith(f0)?i["data-style-bg-color"]=s.substring(f0.length):s.startsWith("style")&&r.push(s):typeof l=="string"&&s==="link"&&(r.push("link"),i.link=l)}),{classes:r,attributes:i}}renderBlock(t,e,o){var l,c;const r={};Object.entries(o).filter(a=>a[0].startsWith("style-")).forEach(([a,u])=>{r[`data-${a}`]=`${u}`});const s=[];return((c=(l=t.selection)==null?void 0:l.range)==null?void 0:c.start.blockId)===o.id&&s.push("focused"),typeof o.align=="string"&&o.align&&(r["data-style-align"]=o.align),o.heading&&(r["data-style-heading"]=String(o.heading)),o.quoted&&(r["data-style-quoted"]="true"),_t.get(t).hoveringBlockId()===o.id&&s.push("hover"),{attributes:r,classes:s}}updateBlock(t,e,o,r){var s,l;Array.from(o.attributes).forEach(c=>{c.name.startsWith("data-style-")&&o.removeAttribute(c.name)}),Object.entries(r).filter(c=>c[0].startsWith("style-")).forEach(([c,a])=>{o.setAttribute(`data-${c}`,`${a}`)}),((l=(s=t.selection)==null?void 0:s.range)==null?void 0:l.start.blockId)===r.id&&M(o,"focused"),_t.get(t).hoveringBlockId()===r.id&&M(o,"hover")}}function Gk(n){n.editorBlocks.registerBlockClass(_i),n.editorBlocks.registerBlockClass(lg),n.editorBoxes.registerBoxClass(Gg),n.editorBoxes.registerBoxClass(Zg),n.editorInsertions.registerInsertionClass(Kg),n.editorBlockRenders.registerRender(new Wk)}function Zk(n,t){Gk(n),t!=null&&t.blocks&&t.blocks.forEach(e=>n.editorBlocks.registerBlockClass(e)),t!=null&&t.boxes&&t.boxes.forEach(e=>n.editorBoxes.registerBoxClass(e)),t!=null&&t.embeds&&t.embeds.forEach(e=>n.editorEmbeds.registerEmbedClass(e)),t!=null&&t.insertions&&t.insertions.forEach(e=>n.editorInsertions.registerInsertionClass(e)),t!=null&&t.decorators&&t.decorators.forEach(e=>n.editorDecorators.registerDecorator(e)),t!=null&&t.dataConverters&&t.dataConverters.forEach(e=>n.dataConverter.addConverter(e)),t!=null&&t.commandProviders&&t.commandProviders.forEach(e=>n.editorCommandProviders.registerCommandProvider(e)),t!=null&&t.textRenders&&t.textRenders.forEach(e=>n.editorBlockRenders.registerRender(e))}const m0=y("range-commands");function g0(n,t){n.forEach(e=>{e.source=t,e.children&&g0(e.children,t)})}function p0(n,t,e){const o=G(t);d(m0,o===e.start.blockId,"invalid start range"),d(m0,o===e.end.blockId,"invalid end range");const r=n.editorCommandProviders.getCommandProviders();let i=[];return r.forEach(s=>{const l=s.getAvailableCommands(n,t,e);g0(l,s.id),i.push(...l)}),r.forEach(s=>{if(s.filterCommands){const l=s.filterCommands(n,t,e,i);l&&(i=l)}}),ct(n,t)&&yr(n,t,e.start,e.end).forEach(l=>{Rt(l).forEach(a=>{const u=Z(n,a),f=Vt(n,{anchor:$(a,0,"home"),focus:$(a,u,"end")}),m=p0(n,a,f);i.push(...m)})}),i}function C0(n){const t=n.getEditor(),e=n.getSelectedBlocks(),o=[];return e.forEach(r=>{const i=Vt(t,{anchor:r.start,focus:r.end});p0(t,r.block,i).forEach(l=>{o.push(l)})}),o}function b0(n,t,e,o,r,i){var u;const s=n.editorCommandProviders.getCommandProviders();for(let f=0;f<s.length;f++){const m=s[f];if(m.beforeExecuteCommand&&m.beforeExecuteCommand(n,t,e,o,r))return!1}const l=n.editorCommandProviders.getCommandProvider(o.source),c={};if((u=l.executeCommand)!=null&&u.call(l,n,t,e,o,r,{}))return i[G(t)]=c,!0;let a=!1;return ct(n,t)&&yr(n,t,e.start,e.end).forEach(m=>{Rt(m).forEach(v=>{const w=Z(n,v),E=Vt(n,{anchor:$(v,0,"home"),focus:$(v,w,"end")});b0(n,v,E,o,r,i)&&(a=!0)})}),s.forEach(f=>{f.afterExecuteCommand&&f.afterExecuteCommand(n,t,e,o,r,i)}),a}function v0(n,t,e){const o=n.getEditor(),r={},i=o.editorCommandProviders.getCommandProvider(t.source);return i.executeRangeCommand&&i.executeRangeCommand(o,n,t,e,r)||n.getSelectedBlocks().forEach(l=>{const c=Vt(o,{anchor:l.start,focus:l.end});b0(o,l.block,c,t,e,r)}),r}const Yk=y("command-providers");class k0{constructor(t){h(this,"providers",[]);this.editor=t}registerCommandProvider(t){this.providers.push(t)}getCommandProviders(){return this.providers}getCommandProvider(t){const e=this.providers.find(o=>o.id===t);return d(Yk,e,`no command provider, id=${t}`),e}getCommands(t){return C0(t)}executeCommand(t,e,o){return this.editor.undoManager.runInGroup(()=>v0(t,e,o))}getEmptyBlockTextAttributes(t,e){let o={};if(this.providers.forEach(r=>{var s;const i=(s=r.getEmptyBlockTextAttributes)==null?void 0:s.call(r,t,e);i&&(o={...o,...i})}),Object.keys(o).length!==0)return o}}function Qk(n,t){const e=H(t),o=U(e),r=K(t);s0(n,o,r)}const Kk=y("table-scroll");class y0{constructor(t,e,o,r,i){h(this,"handleEvent",t=>{this.handler(this.editor,t,this.data)});this.editor=t,this.dom=e,this.name=o,this.handler=r,this.data=i,e.addEventListener(o,this.handleEvent)}destroy(){this.dom.removeEventListener(this.name,this.handleEvent)}}class Jk{constructor(t){h(this,"handlers",new Map);this.editor=t}destroy(){Array.from(this.handlers.entries()).forEach(([t,e])=>{e.forEach(o=>o.destroy()),this.handlers.delete(t)})}addEventListener(t,e,o,r){const i=this.handlers.get(t);if(i){if(i.find(s=>s.handler===o&&s.name===e)){Kk.warn(`event has already registered: ${e}`);return}i.push(new y0(this.editor,t,e,o,r))}else{const s=new y0(this.editor,t,e,o,r);this.handlers.set(t,[s])}}removeEventListener(t,e,o){if(!t){for(const[i,s]of Array.from(this.handlers.entries()))for(let l=s.length-1;l>=0;l--){const c=s[l];if(e)e===c.name&&o===c.handler&&s.splice(l,1);else if(o===c.handler){s.splice(l,1),c.destroy(),s.length===0&&this.handlers.delete(i);continue}}return}const r=this.handlers.get(t);if(r){const i=r.findIndex(s=>s.handler===o&&s.name===e);if(i!==-1){const s=r[i];r.splice(i,1),s.destroy(),r.length===0&&this.handlers.delete(t)}}}removeAllListeners(t,e){const o=this.handlers.get(t);if(o)if(e)for(let r=0;r<o.length;r++){const i=o[r];i.name===e&&(o.splice(r,1),i.destroy())}else o.forEach(r=>{r.destroy()}),this.handlers.delete(t)}}const w0=y("update-block-text");function Xk(n,t){const e=n.getBoxById(t.id),o=z(e);d(w0,o,"no parent block"),d(w0,j(n,o),"not a text block");const r=n.getBlockText(o),i=$g(r,"id",t.id,t);b2(n,o,i)}function ty(n,t){for(const e of n.blockHooks)if(e.writable){const o=e.writable(n,t);if(typeof o=="boolean")return o}return!0}function ey(n){return n.readonly?!1:!Qe(n).find(o=>!n.isBlockWritable(o.block))}class ny{constructor(t){this.editor=t}getKey(t){return`${this.editor.id}-${t}`}async getItem(t){return window.localStorage.getItem(this.getKey(t))}async setItem(t,e){if(!e){this.removeItem(t);return}window.localStorage.setItem(this.getKey(t),e)}async removeItem(t){window.localStorage.removeItem(this.getKey(t))}}class oy{constructor(){h(this,"shortcuts",[])}handleKeyboardEvents(t,e){const o=this.shortcuts;for(const r of o){const i=Object.entries(r);for(const[s,l]of i)if(_n(e,s)){const c=l(t,e);if(c!==void 0)return c}}}}const Fn=y("editor");class ry extends Wt.TypedEmitter{constructor(e,o,r){var i,s,l,c,a,u,f;super();h(this,"parent");h(this,"rootElement");h(this,"contentElement");h(this,"rootContainerObject");h(this,"rootContainer");h(this,"input");h(this,"selection");h(this,"selectionHandler");h(this,"doc");h(this,"id");h(this,"clientId");h(this,"compositingText","");h(this,"undoManager");h(this,"shortcuts",new oy);h(this,"dataConverter",new Vk);h(this,"editorBlocks",new og(this));h(this,"editorBoxes",new Qg(this));h(this,"editorInsertions",new Xg(this));h(this,"editorEmbeds",new ig(this));h(this,"editorDecorators",new t2(this));h(this,"editorCommandProviders",new k0(this));h(this,"editorBlockRenders",new qk(this));h(this,"blockHooks",[]);h(this,"domEvents",new Jk(this));h(this,"customs",new Map);h(this,"options");h(this,"inputHandlers",new Sk(this));h(this,"settingsProvider");h(this,"_readonly",!1);Fn.debug("create editor"),this.setMaxListeners(100),this.options={colors:(i=r==null?void 0:r.colors)!=null?i:["#9923E9","#4587C2","#8BDB7A","#FB28D3","#CBC619","#10FEEB","#812A1A","#8A3F25","#22D742","#A53E74","#555C87","#57E0AA"],componentsOptions:(l=(s=r==null?void 0:r.components)==null?void 0:s.options)!=null?l:{},scrollContainer:r==null?void 0:r.scrollContainer},this.settingsProvider=(c=r==null?void 0:r.settingsProvider)!=null?c:new ny(this),Zk(this,r==null?void 0:r.components),this.blockHooks.push(...(u=(a=r==null?void 0:r.components)==null?void 0:a.blockHooks)!=null?u:[]),this.id=(f=r==null?void 0:r.id)!=null?f:N(),this.clientId=N(),this.undoManager=new zk(this),this.doc=new _k(this,o,this.undoManager),this.parent=e,this.rootElement=b("div",["editor-root"],this.parent),this.rootElement.setAttribute("data-editor-client-id",this.clientId),this.contentElement=b("div",["editor-content"],this.rootElement),this.rootContainerObject=zm(this),this.rootContainer=this.rootContainerObject.rootContainer,this.input=new rv(this,this.inputHandlers),this.selection=new gv(this),this.selectionHandler=new yv(this),r!=null&&r.shortcuts&&this.shortcuts.shortcuts.push(...r.shortcuts),It.isMobile&&M(this.rootElement,"mobile"),It.isSafari&&M(this.rootElement,"safari"),this._readonly&&M(this.rootElement,"readonly"),this.emit("load",this,!1)}get readonly(){return this._readonly}set readonly(e){this._readonly=e,e?M(this.rootElement,"readonly"):F(this.rootElement,"readonly"),this.emit("readonlyChanged",this)}get scrollContainer(){return this.options.scrollContainer?this.options.scrollContainer:Nn(this.rootContainer)}addCustom(e,o){const r=this.customs.get(e);if(r)return r;const i=o(this);return this.customs.set(e,i),i}getCustom(e){const o=this.customs.get(e);return d(Fn,o,`${e} does not exists`),o}replaceCustom(e,o){const r=this.customs.get(e);return r&&r.destroy(),this.customs.set(e,o),o}findCustom(e){return this.customs.get(e)}findCustomByType(e){const o=this.customs.values();for(const r of o)if(r instanceof e)return r;return null}destroyCustom(e){const o=this.customs.get(e);o&&(this.customs.delete(e),o.destroy())}getComponentOptions(e){return this.options.componentsOptions[e]}registerLocalEvents(e){this.doc.registerLocalEvents(e)}reload(){this.rootContainerObject.reload(),this.emit("load",this,!0)}createBlock(e,o,r){return this.editorBlocks.createBlock(e,o,r)}createBox(e,o){return this.editorBoxes.createBox(e,o)}createInsertion(e,o){return this.editorInsertions.createInsertion(e,o)}destroy(){Fn.debug("destroy editor"),this.emit("destroy",this),this.input.destroy(),this.rootContainerObject.destroy(),this.rootElement.remove(),this.doc.destroy(),this.customs.forEach(e=>e.destroy()),this.customs.clear(),this.selection.destroy(),this.domEvents.destroy(),this.removeAllListeners(),this.inputHandlers.destroy()}focus(){this.input.focus()}focusToBlock(e,o){Q1(this,e,o)}isWritable(){return ey(this)}isBlockWritable(e){return ty(this,e)}getChildContainerData(e){const o=this.doc.getContainerBlocks(e);return d(Fn,o,`no child container data: ${e}, ${JSON.stringify(this.doc)}`),d(Fn,Array.isArray(o),`container data is not an array: ${JSON.stringify(o)}`),o}createChildContainer(e,o,r){return Um(this,e,o,r)}getFirstBlock(){return this.rootContainer.querySelector("[data-type=editor-block]")}getLastBlock(){const e=Array.from(this.rootContainer.querySelectorAll(":scope [data-type=editor-block]"));return e[e.length-1]}getFocusedBlock(){return this.selection.getFocusedBlock()}findBlockById(e){const o=this.rootContainer.querySelector(`#${e}`);return o&&d(Fn,gr(o),"not an valid block element"),o!=null?o:null}findBoxById(e){const o=this.rootContainer.querySelector(`#${e}`);return o&&d(Fn,s1(o),"not an valid box element"),o!=null?o:null}getBlockById(e){const o=this.findBlockById(e);return d(Fn,o,`no block, id=${e}`),o}getBoxById(e){const o=this.findBoxById(e);return d(Fn,o,`no box, id=${e}`),o}getBlockByIndex(e,o){const r=this.getContainerById(e);return mr(r,o)}getBlockIndex(e){if(typeof e=="string"){const o=this.getBlockById(e);return K(o)}return K(e)}getContainerById(e){return br(this,e)}getParentContainer(e){return H(e)}reloadBlock(e){Qk(this,e)}contains(e){const o=e instanceof Element?e:e.parentElement;return o?o.closest("div.editor-root")===this.rootElement:!1}insertBlock(e,o,r,i){const s={blockId:r.id,offset:0},l={anchor:s,focus:s};return Dr(this,e,o,r,i!=null?i:l)}insertEmbed(e,o,r,i,s){const l={id:N(),type:"embed",embedType:r,embedData:i};return this.insertBlock(e,o,l,s)}deleteBlock(e,o){G1(this,e,o)}mergeTextBlock(e,o){return g2(this,e,o)}breakTextBlock(e,o,r){return Pi(this,e,o,r).newBlock}getTextPosition(){return Tr(this)}getBlockString(e,o){const r=this.getBlockText(e);return Tt(r,o)}getBlockData(e){return ro(this,e)}getBoxData(e){return r2(this,e)}getBlockText(e){return ke(this,e)}setBlockText(e,o){b2(this,e,o)}deleteTextFromBlock(e,o,r){return V1(this,e,o,r)}insertTextToBlock(e,o,r){return s2(this,e,o,r)}insertBoxToBlock(e,o,r){return l2(this,e,o,r)}pasteDoc(e){return this.inputHandlers.pasteDoc(e)}insertDoc(e,o,r,i){y2(this,e,o,r,i)}insertDocAt(e,o,r,i){return X1(this,e,o,r,i)}deleteChildContainers(e){m2(this,e)}replaceBlockText(e,o){return Nl(this,e,o)}updateBlockData(e,o,r){const i={...this.getBlockData(e),...o},{id:s,type:l,...c}=i;return Pl(this,e,c,(r!=null?r:this.selection.range).toDocRange())}updateEmbedData(e,o,r){return v2(this,e,o,r)}updateBoxData(e){Xk(this,e)}getSelectedText(){const e=jl(this);return id(this,e)}clearSelectedContents(){Y1(this)}insertTextBlock(e,o,r,i){const s=jn(e!=null?e:"");return u2(this,s,o,r,i==null?void 0:i.newRange)}updateCompositionText(e,o){if(e&&!o&&(this.selection.range.isCollapsed()||this.clearSelectedContents()),!e&&!o){a2(this);return}o?(this.compositingText="",Qa()||U1(this,e)):(this.compositingText=e,c2(this))}getColor(e){const o=this.options.colors;return o.length===0?"#FF1A75":o[e%o.length]}}function Ui(n,t,e){return new ry(n,t,e)}function iy(n){const t=(o,r)=>{const i=o.findIndex(l=>l.id===r.id);if(i===-1){o.push(r);return}const s=o[i];if(s.value!==r.value){o.splice(i,1);return}if(!!s.states){if(!r.states){s.states=[];return}s.states=Fa.default(s.states,r.states)}},e=[];return n.forEach(o=>{o.forEach(r=>{t(e,r)})}),e}const sy=["#FBBFBD","#FFDDB6","#FFF897","#C5F0C1","#CEDDFE","#DCC9FC","#E5E6E8","#F76964","#FFA53D","#FFE928","#63D156","#A0BBFE","#C4A5FB","#BBBFC3"];class ql extends Wt.TypedEmitter{constructor(e){super();h(this,"users",new Map);h(this,"cursors",new Map);h(this,"addingUser",!1);h(this,"colors");this.colors=e&&e.length>0?e:sy}setCursor(e){this.addUser(e.user);const o=this.cursors.get(e.user.userId);if(o&&Zs.default(o,e))return;this.cursors.set(e.user.userId,e);const r=new Set([e.range.anchor.blockId,e.range.focus.blockId]),i=new Set(r);o&&new Set([o.range.anchor.blockId,o.range.focus.blockId]).forEach(l=>{r.has(l)||i.add(l)}),this.emit("remote-carets-change",[...i])}addUsers(e){this.addingUser=!0,e.forEach(o=>this.addUser(o)),this.addingUser=!1,this.emit("change",Array.from(this.users.values()))}addUser(e){this.users.set(e.userId,e),this.addingUser||this.emit("change",Array.from(this.users.values()))}findUser(e){var o;return(o=this.users.get(e))!=null?o:null}removeUser(e){this.users.delete(e),this.cursors.delete(e),this.emit("change",Array.from(this.users.values()))}updateUsers(e){this.users.clear(),this.addingUser=!0;try{e.forEach(o=>{this.addUser(o)})}finally{this.addingUser=!1}setTimeout(()=>{this.emit("change",Array.from(this.users.values()))},300)}getSimpleCursors(e){const o=new Map;return Array.from(this.cursors.values()).filter(r=>r.range.anchor.blockId===e&&Sl(r.range)&&zg(r.range)).forEach(r=>{const i=r.range.anchor.offset;let s=o.get(i);s||(s=[],o.set(i,s)),s.push(r)}),o}getCursors(e){return Array.from(this.cursors.values()).filter(o=>o.range.anchor.blockId===e||o.range.focus.blockId===e)}onUpdateBlockText(e,o,r){if(!e.text)return;this.getCursors(e.id).forEach(l=>{if(Sl(l.range)){const{anchor:c,focus:a}=l.range;c.blockId===e.id&&(c.offset=ne.transformCursor(c.offset,o,r)),a.blockId===e.id&&(a.offset=ne.transformCursor(a.offset,o,r))}})}getFixedUserColor(e,o){let r=0;Array.from(e).forEach(s=>{r+=s.charCodeAt(0)});const i=r%this.colors.length;return this.colors[i]}destroy(){this.removeAllListeners()}}const Jt=y("local-doc");class Id extends ki{constructor(e,o){super();h(this,"doc");h(this,"serviceUrl");e?this.doc=e:this.doc={meta:{},comments:{},blocks:{root:[jn("")]}},this.serviceUrl=(o==null?void 0:o.serverUrl)||""}beginBatchUpdate(){return 0}endBatchUpdate(){return 0}toJSON(){return Y.default(this.doc)}getContainerBlocks(e){return this.doc.blocks[e]}getBlockData(e,o){const r=this.getContainerBlocks(e);d(Jt,r,`no container data: ${e}`);const i=r[o];return d(Jt,i,`no block data: ${o}`),i}localUpdateBlockText(e,o,r){const i=this.getBlockData(e,o);d(Jt,i.text,"no text for data");const s=ne.apply(i.text,r);return i.text=s,d(Jt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(l=>{var c;return(c=l.onUpdateBlockText)==null?void 0:c.call(l,e,o,r,!0)}),s}localUpdateBlockData(e,o,r){const i=this.getBlockData(e,o);return r.delete.forEach(s=>delete i[s]),Object.entries(r.insert).forEach(([s,l])=>{i[s]=l}),d(Jt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,e,o,r,!0)}),i}localInsertBlock(e,o,r){const i=this.getContainerBlocks(e);return d(Jt,i,`no container data: ${e}`),d(Jt,o>=0&&o<=i.length,`invalid block index: ${o}, ${i.length}`),i.splice(o,0,r),d(Jt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onInsertBlock)==null?void 0:l.call(s,e,o,r,!0)}),r}localDeleteBlock(e,o){const r=this.getContainerBlocks(e);d(Jt,r,`no container data: ${e}`),d(Jt,o>=0&&o<=r.length,`invalid block index: ${o}, ${r.length}`);const i=r[o];return r.splice(o,1),d(Jt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onDeleteBlock)==null?void 0:l.call(s,e,o,!0)}),i}localInsertChildContainer(e,o){this.doc.blocks[e]=o,d(Jt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onInsertChildContainer)==null?void 0:i.call(r,e,o,!0)})}localDeleteChildContainers(e){Jt.debug(`delete child containers: ${e}`),e.forEach(o=>{d(Jt,this.doc.blocks[o],`no child container: ${o}`),delete this.doc.blocks[o]}),e.forEach(o=>{d(Jt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onDeleteChildContainer)==null?void 0:i.call(r,o,!0)})})}uploadResource(e,o){d(Jt,!1,"not implemented")}async addResources(e){return e}buildResourceUrl(e){return e}request(e,o){d(Jt,!1,"not implemented")}broadcastMessage(e){}getServerMeta(){return{serverId:this.serviceUrl}}getUser(){return{permission:"w",userId:"-",displayName:"-",avatarUrl:"-",rainbowIndex:0}}getRemoteUsers(){return new ql}setDoc(e){this.doc=Y.default(e),this.callbacks.forEach(o=>{var r;return(r=o.onRequestReload)==null?void 0:r.call(o,"change doc")})}destroy(){this.clearCallbacks()}}function Uo(n){return Ct(H(n))}class ly{constructor(t){this.cleanup=t}destroy(){var t;(t=this.cleanup)==null||t.call(this)}}function xd(n,t,e){n.addCustom(t,()=>{var i;const o=(i=e())!=null?i:void 0;return new ly(o)})}const B0=y("remote-cursor");class cy{constructor(){h(this,"remoteUsers",new ql)}onCustomMessage(t){const e=t;if(e.type==="onlineUsers"){const o=e;this.handleUpdateUsers(o.users)}else e.type==="caret"?(B0.debug(`remote caret received: ${e}`),this.handleUpdateCaret(e)):B0.debug(`unknown remote message received: ${t}`)}handleUpdateUsers(t){this.remoteUsers.updateUsers(t)}handleUpdateCaret(t){const e=this.remoteUsers.findUser(t.userId);!e||this.remoteUsers.setCursor({oneseditor:"cursor",user:e,range:t.range,time:Date.now()})}destroy(){this.remoteUsers.destroy()}}function ay(n){const{blocks:t,meta:e,comments:o,...r}=n;return{rootBlocks:t,meta:e,comments:o,childBlocks:r}}function Vi(n){const{childBlocks:t,meta:e,comments:o,rootBlocks:r}=ay(Y.default(n));return{blocks:{root:r,...t},meta:e,comments:o}}function lo(n){return n==="root"?"blocks":n}function Rr(n){return n==="blocks"?"root":n}const dy={type:{name:"rich-text",uri:"http://sharejs.org/types/rich-text/v1",create(n){return new ee.default(n)},apply(n,t){const e=new ee.default(n),o=new ee.default(t);return e.compose(o).ops},compose(n,t){const e=new ee.default(n),o=new ee.default(t);return e.compose(o).ops},diff(n,t){const e=new ee.default(n),o=new ee.default(t);return e.diff(o).ops},transform(n,t,e){const o=new ee.default(n);return new ee.default(t).transform(o,e==="left").ops},transformCursor(n,t,e){return t.transformPosition(n,!e)},normalize(n){return n},serialize(n){return n.ops},deserialize(n){return n},transformPresence(n,t,e){if(!n)return null;const o=new ee.default(t),r=this.transformCursor(n.index,o,e),i=this.transformCursor(n.index+n.length,o,e);return{...n,index:r,length:i-r}}}};var qi=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},co={},Sd=Af.default.EventEmitter;co.EventEmitter=Sd,co.mixin=uy;function uy(n){for(var t in Sd.prototype)n.prototype[t]=Sd.prototype[t]}var E0=["info","warn","error"];function I0(){var n={};E0.forEach(function(t){n[t]=console[t].bind(console)}),this.setMethods(n)}var hy=I0;I0.prototype.setMethods=function(n){n=n||{};var t=this;E0.forEach(function(e){typeof n[e]=="function"&&(t[e]=n[e])})};var fy=hy,my=new fy,x0=my;function Vo(n,t){this.code=n,this.message=t||"",Error.captureStackTrace?Error.captureStackTrace(this,Vo):this.stack=new Error().stack}Vo.prototype=Object.create(Error.prototype),Vo.prototype.constructor=Vo,Vo.prototype.name="ShareDBError",Vo.CODES={ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT:"ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT",ERR_APPLY_SNAPSHOT_NOT_PROVIDED:"ERR_APPLY_SNAPSHOT_NOT_PROVIDED",ERR_CLIENT_ID_BADLY_FORMED:"ERR_CLIENT_ID_BADLY_FORMED",ERR_CANNOT_PING_OFFLINE:"ERR_CANNOT_PING_OFFLINE",ERR_CONNECTION_SEQ_INTEGER_OVERFLOW:"ERR_CONNECTION_SEQ_INTEGER_OVERFLOW",ERR_CONNECTION_STATE_TRANSITION_INVALID:"ERR_CONNECTION_STATE_TRANSITION_INVALID",ERR_DATABASE_ADAPTER_NOT_FOUND:"ERR_DATABASE_ADAPTER_NOT_FOUND",ERR_DATABASE_DOES_NOT_SUPPORT_SUBSCRIBE:"ERR_DATABASE_DOES_NOT_SUPPORT_SUBSCRIBE",ERR_DATABASE_METHOD_NOT_IMPLEMENTED:"ERR_DATABASE_METHOD_NOT_IMPLEMENTED",ERR_DEFAULT_TYPE_MISMATCH:"ERR_DEFAULT_TYPE_MISMATCH",ERR_DOC_MISSING_VERSION:"ERR_DOC_MISSING_VERSION",ERR_DOC_ALREADY_CREATED:"ERR_DOC_ALREADY_CREATED",ERR_DOC_DOES_NOT_EXIST:"ERR_DOC_DOES_NOT_EXIST",ERR_DOC_TYPE_NOT_RECOGNIZED:"ERR_DOC_TYPE_NOT_RECOGNIZED",ERR_DOC_WAS_DELETED:"ERR_DOC_WAS_DELETED",ERR_INFLIGHT_OP_MISSING:"ERR_INFLIGHT_OP_MISSING",ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION:"ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION",ERR_MAX_SUBMIT_RETRIES_EXCEEDED:"ERR_MAX_SUBMIT_RETRIES_EXCEEDED",ERR_MESSAGE_BADLY_FORMED:"ERR_MESSAGE_BADLY_FORMED",ERR_MILESTONE_ARGUMENT_INVALID:"ERR_MILESTONE_ARGUMENT_INVALID",ERR_OP_ALREADY_SUBMITTED:"ERR_OP_ALREADY_SUBMITTED",ERR_OP_NOT_ALLOWED_IN_PROJECTION:"ERR_OP_NOT_ALLOWED_IN_PROJECTION",ERR_OP_SUBMIT_REJECTED:"ERR_OP_SUBMIT_REJECTED",ERR_OP_VERSION_MISMATCH_AFTER_TRANSFORM:"ERR_OP_VERSION_MISMATCH_AFTER_TRANSFORM",ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM:"ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM",ERR_OP_VERSION_NEWER_THAN_CURRENT_SNAPSHOT:"ERR_OP_VERSION_NEWER_THAN_CURRENT_SNAPSHOT",ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED:"ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED",ERR_OT_OP_BADLY_FORMED:"ERR_OT_OP_BADLY_FORMED",ERR_OT_OP_NOT_APPLIED:"ERR_OT_OP_NOT_APPLIED",ERR_OT_OP_NOT_PROVIDED:"ERR_OT_OP_NOT_PROVIDED",ERR_PRESENCE_TRANSFORM_FAILED:"ERR_PRESENCE_TRANSFORM_FAILED",ERR_PROTOCOL_VERSION_NOT_SUPPORTED:"ERR_PROTOCOL_VERSION_NOT_SUPPORTED",ERR_QUERY_EMITTER_LISTENER_NOT_ASSIGNED:"ERR_QUERY_EMITTER_LISTENER_NOT_ASSIGNED",ERR_SNAPSHOT_READ_SILENT_REJECTION:"ERR_SNAPSHOT_READ_SILENT_REJECTION",ERR_SNAPSHOT_READS_REJECTED:"ERR_SNAPSHOT_READS_REJECTED",ERR_SUBMIT_TRANSFORM_OPS_NOT_FOUND:"ERR_SUBMIT_TRANSFORM_OPS_NOT_FOUND",ERR_TYPE_CANNOT_BE_PROJECTED:"ERR_TYPE_CANNOT_BE_PROJECTED",ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE:"ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE",ERR_UNKNOWN_ERROR:"ERR_UNKNOWN_ERROR"};var Wl=Vo,Wi={},S0=gy;function gy(n,t,e,o){var r=function(s,l,c,a){t(c,s,l,"left"),t(a,l,s,"right")},i=n.transformX=function(s,l){e(s),e(l);for(var c=[],a=0;a<l.length;a++){for(var u=l[a],f=[],m=0;m<s.length;){var C=[];if(r(s[m],u,f,C),m++,C.length===1)u=C[0];else if(C.length===0){for(var v=m;v<s.length;v++)o(f,s[v]);u=null;break}else{for(var w=i(s.slice(m),C),E=0;E<w[0].length;E++)o(f,w[0][E]);for(var L=0;L<w[1].length;L++)o(c,w[1][L]);u=null;break}}u!=null&&o(c,u),s=f}return[s,c]};n.transform=function(s,l,c){if(!(c==="left"||c==="right"))throw new Error("type must be 'left' or 'right'");return l.length===0?s:s.length===1&&l.length===1?t([],s[0],l[0],c):c==="left"?i(s,l)[0]:i(l,s)[1]}}var T0={exports:{}},ao=T0.exports={name:"text0",uri:"http://sharejs.org/types/textv0",create:function(n){if(n!=null&&typeof n!="string")throw new Error("Initial data must be a string");return n||""}},Td=function(n,t,e){return n.slice(0,t)+e+n.slice(t)},Dd=function(n){if(typeof n.p!="number")throw new Error("component missing position field");if(typeof n.i=="string"==(typeof n.d=="string"))throw new Error("component needs an i or d field");if(n.p<0)throw new Error("position cannot be negative")},Gl=function(n){for(var t=0;t<n.length;t++)Dd(n[t])};ao.apply=function(n,t){var e;Gl(t);for(var o=0;o<t.length;o++){var r=t[o];if(r.i!=null)n=Td(n,r.p,r.i);else{if(e=n.slice(r.p,r.p+r.d.length),r.d!==e)throw new Error("Delete component '"+r.d+"' does not match deleted text '"+e+"'");n=n.slice(0,r.p)+n.slice(r.p+r.d.length)}}return n};var zn=ao._append=function(n,t){if(!(t.i===""||t.d===""))if(n.length===0)n.push(t);else{var e=n[n.length-1];e.i!=null&&t.i!=null&&e.p<=t.p&&t.p<=e.p+e.i.length?n[n.length-1]={i:Td(e.i,t.p-e.p,t.i),p:e.p}:e.d!=null&&t.d!=null&&t.p<=e.p&&e.p<=t.p+t.d.length?n[n.length-1]={d:Td(t.d,e.p-t.p,e.d),p:t.p}:n.push(t)}};ao.compose=function(n,t){Gl(n),Gl(t);for(var e=n.slice(),o=0;o<t.length;o++)zn(e,t[o]);return e},ao.normalize=function(n){var t=[];(n.i!=null||n.p!=null)&&(n=[n]);for(var e=0;e<n.length;e++){var o=n[e];o.p==null&&(o.p=0),zn(t,o)}return t};var Ld=function(n,t,e){return t.i!=null?t.p<n||t.p===n&&e?n+t.i.length:n:n<=t.p?n:n<=t.p+t.d.length?t.p:n-t.d.length};ao.transformCursor=function(n,t,e){for(var o=e==="right",r=0;r<t.length;r++)n=Ld(n,t[r],o);return n};var py=ao._tc=function(n,t,e,o){if(Dd(t),Dd(e),t.i!=null)zn(n,{i:t.i,p:Ld(t.p,e,o==="right")});else if(e.i!=null){var r=t.d;t.p<e.p&&(zn(n,{d:r.slice(0,e.p-t.p),p:t.p}),r=r.slice(e.p-t.p)),r!==""&&zn(n,{d:r,p:t.p+e.i.length})}else if(t.p>=e.p+e.d.length)zn(n,{d:t.d,p:t.p-e.d.length});else if(t.p+t.d.length<=e.p)zn(n,t);else{var i={d:"",p:t.p};t.p<e.p&&(i.d=t.d.slice(0,e.p-t.p)),t.p+t.d.length>e.p+e.d.length&&(i.d+=t.d.slice(e.p+e.d.length-t.p));var s=Math.max(t.p,e.p),l=Math.min(t.p+t.d.length,e.p+e.d.length),c=t.d.slice(s-t.p,l-t.p),a=e.d.slice(s-e.p,l-e.p);if(c!==a)throw new Error("Delete ops delete different text in the same region of the document");i.d!==""&&(i.p=Ld(i.p,e),zn(n,i))}return n},Cy=function(n){return n.i!=null?{d:n.i,p:n.p}:{i:n.d,p:n.p}};ao.invert=function(n){n=n.slice().reverse();for(var t=0;t<n.length;t++)n[t]=Cy(n[t]);return n},S0(ao,py,Gl,zn);var Zl=function(n){return Object.prototype.toString.call(n)=="[object Array]"},by=function(n){return!!n&&n.constructor===Object},Xe=function(n){return JSON.parse(JSON.stringify(n))},et={name:"json0",uri:"http://sharejs.org/types/JSONv0"},Un={};et.registerSubtype=function(n){Un[n.name]=n},et.create=function(n){return n===void 0?null:Xe(n)},et.invertComponent=function(n){var t={p:n.p};return n.t&&Un[n.t]&&(t.t=n.t,t.o=Un[n.t].invert(n.o)),n.si!==void 0&&(t.sd=n.si),n.sd!==void 0&&(t.si=n.sd),n.oi!==void 0&&(t.od=n.oi),n.od!==void 0&&(t.oi=n.od),n.li!==void 0&&(t.ld=n.li),n.ld!==void 0&&(t.li=n.ld),n.na!==void 0&&(t.na=-n.na),n.lm!==void 0&&(t.lm=n.p[n.p.length-1],t.p=n.p.slice(0,n.p.length-1).concat([n.lm])),t},et.invert=function(n){for(var t=n.slice().reverse(),e=[],o=0;o<t.length;o++)e.push(et.invertComponent(t[o]));return e},et.checkValidOp=function(n){for(var t=0;t<n.length;t++)if(!Zl(n[t].p))throw new Error("Missing path")},et.checkList=function(n){if(!Zl(n))throw new Error("Referenced element not a list")},et.checkObj=function(n){if(!by(n))throw new Error("Referenced element not an object (it was "+JSON.stringify(n)+")")};function Gi(n){n.t="text0";var t={p:n.p.pop()};n.si!=null&&(t.i=n.si),n.sd!=null&&(t.d=n.sd),n.o=[t]}function Zi(n){n.p.push(n.o[0].p),n.o[0].i!=null&&(n.si=n.o[0].i),n.o[0].d!=null&&(n.sd=n.o[0].d),delete n.t,delete n.o}et.apply=function(n,t){et.checkValidOp(t),t=Xe(t);for(var e={data:n},o=0;o<t.length;o++){var r=t[o];(r.si!=null||r.sd!=null)&&Gi(r);for(var i=null,s=e,l="data",c=0;c<r.p.length;c++){var a=r.p[c];if(i=s,s=s[l],l=a,i==null)throw new Error("Path invalid")}if(r.t&&r.o!==void 0&&Un[r.t])s[l]=Un[r.t].apply(s[l],r.o);else if(r.na!==void 0){if(typeof s[l]!="number")throw new Error("Referenced element not a number");s[l]+=r.na}else if(r.li!==void 0&&r.ld!==void 0)et.checkList(s),s[l]=r.li;else if(r.li!==void 0)et.checkList(s),s.splice(l,0,r.li);else if(r.ld!==void 0)et.checkList(s),s.splice(l,1);else if(r.lm!==void 0){if(et.checkList(s),r.lm!=l){var u=s[l];s.splice(l,1),s.splice(r.lm,0,u)}}else if(r.oi!==void 0)et.checkObj(s),s[l]=r.oi;else if(r.od!==void 0)et.checkObj(s),delete s[l];else throw new Error("invalid / missing instruction in op")}return e.data},et.shatter=function(n){for(var t=[],e=0;e<n.length;e++)t.push([n[e]]);return t},et.incrementalApply=function(n,t,e){for(var o=0;o<t.length;o++){var r=[t[o]];n=et.apply(n,r),e(r,n)}return n};var vy=et.pathMatches=function(n,t,e){if(n.length!=t.length)return!1;for(var o=0;o<n.length;o++)if(n[o]!==t[o]&&(!e||o!==n.length-1))return!1;return!0};et.append=function(n,t){if(t=Xe(t),n.length===0){n.push(t);return}var e=n[n.length-1];if((t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(Gi(t),Gi(e)),vy(t.p,e.p))if(t.t&&e.t&&t.t===e.t&&Un[t.t]){if(e.o=Un[t.t].compose(e.o,t.o),t.si!=null||t.sd!=null){for(var o=t.p,r=0;r<e.o.length-1;r++)t.o=[e.o.pop()],t.p=o.slice(),Zi(t),n.push(t);Zi(e)}}else e.na!=null&&t.na!=null?n[n.length-1]={p:e.p,na:e.na+t.na}:e.li!==void 0&&t.li===void 0&&t.ld===e.li?e.ld!==void 0?delete e.li:n.pop():e.od!==void 0&&e.oi===void 0&&t.oi!==void 0&&t.od===void 0?e.oi=t.oi:e.oi!==void 0&&t.od!==void 0?t.oi!==void 0?e.oi=t.oi:e.od!==void 0?delete e.oi:n.pop():t.lm!==void 0&&t.p[t.p.length-1]===t.lm||n.push(t);else(t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(Zi(t),Zi(e)),n.push(t)},et.compose=function(n,t){et.checkValidOp(n),et.checkValidOp(t);for(var e=Xe(n),o=0;o<t.length;o++)et.append(e,t[o]);return e},et.normalize=function(n){var t=[];n=Zl(n)?n:[n];for(var e=0;e<n.length;e++){var o=n[e];o.p==null&&(o.p=[]),et.append(t,o)}return t},et.commonLengthForOps=function(n,t){var e=n.p.length,o=t.p.length;if((n.na!=null||n.t)&&e++,(t.na!=null||t.t)&&o++,e===0)return-1;if(o===0)return null;e--,o--;for(var r=0;r<e;r++){var i=n.p[r];if(r>=o||i!==t.p[r])return null}return e},et.canOpAffectPath=function(n,t){return et.commonLengthForOps({p:t},n)!=null},et.transformComponent=function(n,t,e,o){t=Xe(t);var r=et.commonLengthForOps(e,t),i=et.commonLengthForOps(t,e),s=t.p.length,l=e.p.length;if((t.na!=null||t.t)&&s++,(e.na!=null||e.t)&&l++,i!=null&&l>s&&t.p[i]==e.p[i]){if(t.ld!==void 0){var c=Xe(e);c.p=c.p.slice(s),t.ld=et.apply(Xe(t.ld),[c])}else if(t.od!==void 0){var c=Xe(e);c.p=c.p.slice(s),t.od=et.apply(Xe(t.od),[c])}}if(r!=null){var a=s==l,c=e;if((t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(Gi(t),c=Xe(e),Gi(c)),c.t&&Un[c.t]){if(t.t&&t.t===c.t){var u=Un[t.t].transform(t.o,c.o,o);if(t.si!=null||t.sd!=null)for(var f=t.p,m=0;m<u.length;m++)t.o=[u[m]],t.p=f.slice(),Zi(t),et.append(n,t);else(!Zl(u)||u.length>0)&&(t.o=u,et.append(n,t));return n}}else if(e.na===void 0){if(e.li!==void 0&&e.ld!==void 0){if(e.p[r]===t.p[r])if(a){if(t.ld!==void 0)if(t.li!==void 0&&o==="left")t.ld=Xe(e.li);else return n}else return n}else if(e.li!==void 0)t.li!==void 0&&t.ld===void 0&&a&&t.p[r]===e.p[r]?o==="right"&&t.p[r]++:e.p[r]<=t.p[r]&&t.p[r]++,t.lm!==void 0&&a&&e.p[r]<=t.lm&&t.lm++;else if(e.ld!==void 0){if(t.lm!==void 0&&a){if(e.p[r]===t.p[r])return n;var f=e.p[r],C=t.p[r],v=t.lm;(f<v||f===v&&C<v)&&t.lm--}if(e.p[r]<t.p[r])t.p[r]--;else if(e.p[r]===t.p[r]){if(l<s)return n;if(t.ld!==void 0)if(t.li!==void 0)delete t.ld;else return n}}else if(e.lm!==void 0)if(t.lm!==void 0&&s===l){var C=t.p[r],v=t.lm,w=e.p[r],E=e.lm;if(w!==E)if(C===w)if(o==="left")t.p[r]=E,C===v&&(t.lm=E);else return n;else C>w&&t.p[r]--,C>E?t.p[r]++:C===E&&w>E&&(t.p[r]++,C===v&&t.lm++),(v>w||v===w&&v>C)&&t.lm--,v>E?t.lm++:v===E&&(E>w&&v>C||E<w&&v<C?o==="right"&&t.lm++:v>C?t.lm++:v===w&&t.lm--)}else if(t.li!==void 0&&t.ld===void 0&&a){var C=e.p[r],v=e.lm;f=t.p[r],f>C&&t.p[r]--,f>v&&t.p[r]++}else{var C=e.p[r],v=e.lm;f=t.p[r],f===C?t.p[r]=v:(f>C&&t.p[r]--,(f>v||f===v&&C>v)&&t.p[r]++)}else if(e.oi!==void 0&&e.od!==void 0){if(t.p[r]===e.p[r])if(t.oi!==void 0&&a){if(o==="right")return n;t.od=e.oi}else return n}else if(e.oi!==void 0){if(t.oi!==void 0&&t.p[r]===e.p[r])if(o==="left")et.append(n,{p:t.p,od:e.oi});else return n}else if(e.od!==void 0&&t.p[r]==e.p[r]){if(!a)return n;if(t.oi!==void 0)delete t.od;else return n}}}return et.append(n,t),n},S0(et,et.transformComponent,et.checkValidOp,et.append);var ky=T0.exports;et.registerSubtype(ky);var yy=et,wy={type:yy};(function(n){n.defaultType=wy.type,n.map={},n.register=function(t){t.name&&(n.map[t.name]=t),t.uri&&(n.map[t.uri]=t)},n.register(n.defaultType)})(Wi);var tn={};(function(n){n.doNothing=t;function t(){}n.hasKeys=function(e){for(var o in e)return!0;return!1},n.isInteger=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e},n.isValidVersion=function(e){return e===null?!0:n.isInteger(e)&&e>=0},n.isValidTimestamp=function(e){return n.isValidVersion(e)},n.MAX_SAFE_INTEGER=9007199254740991,n.dig=function(){for(var e=arguments[0],o=1;o<arguments.length;o++){var r=arguments[o];e=e[r]||(o===arguments.length-1?void 0:{})}return e},n.digOrCreate=function(){for(var e=arguments[0],o=arguments[arguments.length-1],r=1;r<arguments.length-1;r++){var i=arguments[r];e=e[i]||(e[i]=r===arguments.length-2?o():{})}return e},n.digAndRemove=function(){for(var e=arguments[0],o=[e],r=1;r<arguments.length-1;r++){var i=arguments[r];if(!e.hasOwnProperty(i))break;e=e[i],o.push(e)}for(var r=o.length-1;r>=0;r--){var s=o[r],i=arguments[r+1],l=s[i];(r===o.length-1||!n.hasKeys(l))&&delete s[i]}},n.supportsPresence=function(e){return e&&typeof e.transformPresence=="function"},n.callEach=function(e,o){var r=!1;return e.forEach(function(i){i&&(i(o),r=!0)}),r},n.truthy=function(e){return!!e},n.nextTick=function(e){if(typeof process<"u"&&process.nextTick)return process.nextTick.apply(null,arguments);for(var o=[],r=1;r<arguments.length;r++)o[r-1]=arguments[r];setTimeout(function(){e.apply(null,o)})},n.clone=function(e){return e===void 0?void 0:JSON.parse(JSON.stringify(e))}})(tn);var D0=Array.isArray,L0=Object.keys,By=Object.prototype.hasOwnProperty,Ey=function n(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){var o=D0(t),r=D0(e),i,s,l;if(o&&r){if(s=t.length,s!=e.length)return!1;for(i=s;i--!==0;)if(!n(t[i],e[i]))return!1;return!0}if(o!=r)return!1;var c=t instanceof Date,a=e instanceof Date;if(c!=a)return!1;if(c&&a)return t.getTime()==e.getTime();var u=t instanceof RegExp,f=e instanceof RegExp;if(u!=f)return!1;if(u&&f)return t.toString()==e.toString();var m=L0(t);if(s=m.length,s!==L0(e).length)return!1;for(i=s;i--!==0;)if(!By.call(e,m[i]))return!1;for(i=s;i--!==0;)if(l=m[i],!n(t[l],e[l]))return!1;return!0}return t!==t&&e!==e},M0=co,Iy=x0,ye=Wl,Yl=Wi,en=tn,xy=en.clone,Sy=Ey,ge=ye.CODES,Ty=st;function st(n,t,e){M0.EventEmitter.call(this),this.connection=n,this.collection=t,this.id=e,this.version=null,this.type=null,this.data=void 0,this.inflightFetch=[],this.inflightSubscribe=null,this.pendingFetch=[],this.pendingSubscribe=[],this.subscribed=!1,this.wantSubscribe=!1,this._wantsDestroy=!1,this.inflightOp=null,this.pendingOps=[],this.type=null,this.applyStack=null,this.preventCompose=!1,this.submitSource=!1,this.paused=!1,this._dataStateVersion=0}M0.mixin(st),st.prototype.destroy=function(n){this._wantsDestroy=!0;var t=this;t.whenNothingPending(function(){t.wantSubscribe?t.unsubscribe(function(e){if(e)return n?n(e):t.emit("error",e);t.connection._destroyDoc(t),n&&n()}):(t.connection._destroyDoc(t),n&&n())})},st.prototype._setType=function(n){if(typeof n=="string"&&(n=Yl.map[n]),n)this.type=n;else if(n===null)this.type=n,this._setData(void 0);else{var t=new ye(ge.ERR_DOC_TYPE_NOT_RECOGNIZED,"Missing type "+n);return this.emit("error",t)}},st.prototype._setData=function(n){this.data=n,this._dataStateVersion++},st.prototype.ingestSnapshot=function(n,t){if(!n)return t&&t();if(typeof n.v!="number"){var e=new ye(ge.ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION,"Missing version in ingested snapshot. "+this.collection+"."+this.id);return t?t(e):this.emit("error",e)}if(this.type||this.hasWritePending()){if(this.version==null){if(this.hasWritePending())return t&&this.once("no write pending",t);var e=new ye(ge.ERR_DOC_MISSING_VERSION,"Cannot ingest snapshot in doc with null version. "+this.collection+"."+this.id);return t?t(e):this.emit("error",e)}return n.v>this.version?this.fetch(t):t&&t()}if(this.version>n.v)return t&&t();this.version=n.v;var o=n.type===void 0?Yl.defaultType:n.type;this._setType(o),this._setData(this.type&&this.type.deserialize?this.type.deserialize(n.data):n.data),this.emit("load"),t&&t()},st.prototype.whenNothingPending=function(n){var t=this;en.nextTick(function(){if(t.hasPending()){t.once("nothing pending",n);return}n()})},st.prototype.hasPending=function(){return!!(this.inflightOp||this.pendingOps.length||this.inflightFetch.length||this.inflightSubscribe||this.pendingFetch.length||this.pendingSubscribe.length)},st.prototype.hasWritePending=function(){return!!(this.inflightOp||this.pendingOps.length)},st.prototype._emitNothingPending=function(){this.hasWritePending()||(this.emit("no write pending"),!this.hasPending()&&this.emit("nothing pending"))},st.prototype._emitResponseError=function(n,t){if(n&&n.code===ge.ERR_SNAPSHOT_READ_SILENT_REJECTION){this.wantSubscribe=!1,t&&t(),this._emitNothingPending();return}if(t){t(n),this._emitNothingPending();return}this._emitNothingPending(),this.emit("error",n)},st.prototype._handleFetch=function(n,t){var e=this.pendingFetch;this.pendingFetch=[];var o=this.inflightFetch.shift();if(o&&e.push(o),e.length&&(o=function(r){en.callEach(e,r)}),n)return this._emitResponseError(n,o);this.ingestSnapshot(t,o),this._emitNothingPending()},st.prototype._handleSubscribe=function(n,t){var e=this.inflightSubscribe;this.inflightSubscribe=null;var o=this.pendingFetch;this.pendingFetch=[],e.callback&&o.push(e.callback);var r;if(o.length&&(r=function(i){en.callEach(o,i)}),n)return this._emitResponseError(n,r);this.subscribed=e.wantSubscribe,this.subscribed?this.ingestSnapshot(t,r):r&&r(),this._emitNothingPending(),this._flushSubscribe()},st.prototype._handleOp=function(n,t){if(n)return this.inflightOp?(n.code===ge.ERR_OP_SUBMIT_REJECTED&&(n=null),this._rollback(n)):this.emit("error",n);if(this.inflightOp&&t.src===this.inflightOp.src&&t.seq===this.inflightOp.seq){this._opAcknowledged(t);return}if(this.version==null||t.v>this.version){this.fetch();return}if(!(t.v<this.version)){if(this.inflightOp){var e=Ql(this.inflightOp,t);if(e)return this._hardRollback(e)}for(var o=0;o<this.pendingOps.length;o++){var e=Ql(this.pendingOps[o],t);if(e)return this._hardRollback(e)}this.version++;try{this._otApply(t,!1)}catch(r){return this._hardRollback(r)}}},st.prototype._onConnectionStateChanged=function(){this.connection.canSend?(this.flush(),this._resubscribe()):(this.inflightOp&&(this.pendingOps.unshift(this.inflightOp),this.inflightOp=null),this.subscribed=!1,this.inflightSubscribe&&(this.inflightSubscribe.wantSubscribe?(this.pendingSubscribe.unshift(this.inflightSubscribe),this.inflightSubscribe=null):this._handleSubscribe()),this.inflightFetch.length&&(this.pendingFetch=this.pendingFetch.concat(this.inflightFetch),this.inflightFetch.length=0))},st.prototype._resubscribe=function(){if(!this.pendingSubscribe.length&&this.wantSubscribe)return this.subscribe();var n=this.pendingSubscribe.some(function(t){return t.wantSubscribe});!n&&this.pendingFetch.length&&this.fetch(),this._flushSubscribe()},st.prototype.fetch=function(n){if(this.connection.canSend){var t=this.connection.sendFetch(this);Dy(this.inflightFetch,t,n);return}this.pendingFetch.push(n)},st.prototype.subscribe=function(n){var t=!0;this._queueSubscribe(t,n)},st.prototype.unsubscribe=function(n){var t=!1;this._queueSubscribe(t,n)},st.prototype._queueSubscribe=function(n,t){var e=this.pendingSubscribe[this.pendingSubscribe.length-1]||this.inflightSubscribe,o=e&&e.wantSubscribe===n;if(o){e.callback=Ly([e.callback,t]);return}this.pendingSubscribe.push({wantSubscribe:!!n,callback:t}),this._flushSubscribe()},st.prototype._flushSubscribe=function(){if(!(this.inflightSubscribe||!this.pendingSubscribe.length)){if(this.connection.canSend){this.inflightSubscribe=this.pendingSubscribe.shift(),this.wantSubscribe=this.inflightSubscribe.wantSubscribe,this.wantSubscribe?this.connection.sendSubscribe(this):(this.subscribed=!1,this.connection.sendUnsubscribe(this));return}if(!this.pendingSubscribe[0].wantSubscribe){this.inflightSubscribe=this.pendingSubscribe.shift();var n=this;en.nextTick(function(){n._handleSubscribe()})}}};function Dy(n,t,e){if(t){var o=n.pop();n.push(function(r){o&&o(r),e&&e(r)})}else n.push(e)}function Ly(n){return n=n.filter(en.truthy),n.length?function(t){en.callEach(n,t)}:null}st.prototype.flush=function(){!this.connection.canSend||this.inflightOp||!this.paused&&this.pendingOps.length&&this._sendOp()};function My(n){delete n.op,delete n.create,delete n.del}function Ql(n,t){if(n.del)return My(t);if(t.del)return new ye(ge.ERR_DOC_WAS_DELETED,"Document was deleted");if(t.create)return new ye(ge.ERR_DOC_ALREADY_CREATED,"Document already created");if("op"in t){if(n.create)return new ye(ge.ERR_DOC_ALREADY_CREATED,"Document already created");if(n.type.transformX){var e=n.type.transformX(n.op,t.op);n.op=e[0],t.op=e[1]}else{var o=n.type.transform(n.op,t.op,"left"),r=n.type.transform(t.op,n.op,"right");n.op=o,t.op=r}}}st.prototype._otApply=function(n,t){if("op"in n){if(!this.type)throw new ye(ge.ERR_DOC_DOES_NOT_EXIST,"Cannot apply op to uncreated document. "+this.collection+"."+this.id);if(this.emit("before op batch",n.op,t),!t&&this.type===Yl.defaultType&&n.op.length>1){this.applyStack||(this.applyStack=[]);for(var e=this.applyStack.length,o=0;o<n.op.length;o++){var r=n.op[o],i={op:[r]};this.emit("before op",i.op,t,n.src);for(var s=e;s<this.applyStack.length;s++){var l=Ql(this.applyStack[s],i);if(l)return this._hardRollback(l)}this._setData(this.type.apply(this.data,i.op)),this.emit("op",i.op,t,n.src)}this.emit("op batch",n.op,t),this._popApplyStack(e);return}this.emit("before op",n.op,t,n.src),this._setData(this.type.apply(this.data,n.op)),this.emit("op",n.op,t,n.src),this.emit("op batch",n.op,t);return}if(n.create){this._setType(n.create.type),this.type.deserialize?this.type.createDeserialized?this._setData(this.type.createDeserialized(n.create.data)):this._setData(this.type.deserialize(this.type.create(n.create.data))):this._setData(this.type.create(n.create.data)),this.emit("create",t);return}if(n.del){var c=this.data;this._setType(null),this.emit("del",c,t);return}},st.prototype._sendOp=function(){if(!!this.connection.canSend){var n=this.connection.id;this.inflightOp||(this.inflightOp=this.pendingOps.shift());var t=this.inflightOp;if(!t){var e=new ye(ge.ERR_INFLIGHT_OP_MISSING,"No op to send on call to _sendOp");return this.emit("error",e)}if(t.sentAt=Date.now(),t.retries=t.retries==null?0:t.retries+1,t.seq==null){if(this.connection.seq>=en.MAX_SAFE_INTEGER)return this.emit("error",new ye(ge.ERR_CONNECTION_SEQ_INTEGER_OVERFLOW,"Connection seq has exceeded the max safe integer, maybe from being open for too long"));t.seq=this.connection.seq++}this.connection.sendOp(this,t),t.src==null&&(t.src=n)}},st.prototype._submit=function(n,t,e){if(t||(t=!0),"op"in n){if(!this.type){var o=new ye(ge.ERR_DOC_DOES_NOT_EXIST,"Cannot submit op. Document has not been created. "+this.collection+"."+this.id);return e?e(o):this.emit("error",o)}this.type.normalize&&(n.op=this.type.normalize(n.op))}try{this._pushOp(n,t,e),this._otApply(n,t)}catch(i){return this._hardRollback(i)}var r=this;en.nextTick(function(){r.flush()})},st.prototype._pushOp=function(n,t,e){if(n.source=t,this.applyStack)this.applyStack.push(n);else{var o=this._tryCompose(n);if(o){o.callbacks.push(e);return}}n.type=this.type,n.callbacks=[e],this.pendingOps.push(n)},st.prototype._popApplyStack=function(n){if(n>0){this.applyStack.length=n;return}var t=this.applyStack[0];if(this.applyStack=null,!!t){var e=this.pendingOps.indexOf(t);if(e!==-1)for(var o=this.pendingOps.splice(e),e=0;e<o.length;e++){var t=o[e],r=this._tryCompose(t);r?r.callbacks=r.callbacks.concat(t.callbacks):this.pendingOps.push(t)}}},st.prototype._tryCompose=function(n){if(!this.preventCompose){var t=this.pendingOps[this.pendingOps.length-1];if(!(!t||t.sentAt)&&!(this.submitSource&&!Sy(n.source,t.source))){if(t.create&&"op"in n)return t.create.data=this.type.apply(t.create.data,n.op),t;if("op"in t&&"op"in n&&this.type.compose)return t.op=this.type.compose(t.op,n.op),t}}},st.prototype.submitOp=function(n,t,e){typeof t=="function"&&(e=t,t=null);var o={op:n},r=t&&t.source;this._submit(o,r,e)},st.prototype.create=function(n,t,e,o){if(typeof t=="function"?(o=t,e=null,t=null):typeof e=="function"&&(o=e,e=null),t||(t=Yl.defaultType.uri),this.type){var r=new ye(ge.ERR_DOC_ALREADY_CREATED,"Document already exists");return o?o(r):this.emit("error",r)}var i={create:{type:t,data:n}},s=e&&e.source;this._submit(i,s,o)},st.prototype.del=function(n,t){if(typeof n=="function"&&(t=n,n=null),!this.type){var e=new ye(ge.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");return t?t(e):this.emit("error",e)}var o={del:!0},r=n&&n.source;this._submit(o,r,t)},st.prototype.pause=function(){this.paused=!0},st.prototype.resume=function(){this.paused=!1,this.flush()},st.prototype.toSnapshot=function(){return{v:this.version,data:xy(this.data),type:this.type.uri}},st.prototype._opAcknowledged=function(n){if(this.inflightOp.create)this.version=n.v;else if(n.v!==this.version)return Iy.warn("Invalid version from server. Expected: "+this.version+" Received: "+n.v,n),this.fetch();this.version++,this._clearInflightOp()},st.prototype._rollback=function(n){var t=this.inflightOp;if("op"in t&&t.type.invert){try{t.op=t.type.invert(t.op)}catch{return this._hardRollback(n)}for(var e=0;e<this.pendingOps.length;e++){var o=Ql(this.pendingOps[e],t);if(o)return this._hardRollback(o)}try{this._otApply(t,!1)}catch(r){return this._hardRollback(r)}this._clearInflightOp(n);return}this._hardRollback(n)},st.prototype._hardRollback=function(n){var t=[];this.inflightOp&&t.push(this.inflightOp),t=t.concat(this.pendingOps),this._setType(null),this.version=null,this.inflightOp=null,this.pendingOps=[];var e=this;this.fetch(function(){for(var o=!!t.length,r=0;r<t.length;r++)o=en.callEach(t[r].callbacks,n)&&o;if(n&&!o)return e.emit("error",n)})},st.prototype._clearInflightOp=function(n){var t=this.inflightOp;this.inflightOp=null;var e=en.callEach(t.callbacks,n);if(this.flush(),this._emitNothingPending(),n&&!e)return this.emit("error",n)};var qo={};qo.ACTIONS={initLegacy:"init",handshake:"hs",queryFetch:"qf",querySubscribe:"qs",queryUnsubscribe:"qu",queryUpdate:"q",bulkFetch:"bf",bulkSubscribe:"bs",bulkUnsubscribe:"bu",fetch:"f",subscribe:"s",unsubscribe:"u",op:"op",snapshotFetch:"nf",snapshotFetchByTimestamp:"nt",pingPong:"pp",presence:"p",presenceSubscribe:"ps",presenceUnsubscribe:"pu",presenceRequest:"pr"};var R0=co,A0=qo.ACTIONS,Ry=tn,Ay=pe;function pe(n,t,e,o,r,i,s){R0.EventEmitter.call(this),this.action=n,this.connection=t,this.id=e,this.collection=o,this.query=r,this.results=null,i&&i.results&&(this.results=i.results,delete i.results),this.extra=void 0,this.options=i,this.callback=s,this.ready=!1,this.sent=!1}R0.mixin(pe),pe.prototype.hasPending=function(){return!this.ready},pe.prototype.send=function(){if(!!this.connection.canSend){var n={a:this.action,id:this.id,c:this.collection,q:this.query};if(this.options&&(n.o=this.options),this.results){for(var t=[],e=0;e<this.results.length;e++){var o=this.results[e];t.push([o.id,o.version])}n.r=t}this.connection.send(n),this.sent=!0}},pe.prototype.destroy=function(n){this.connection.canSend&&this.action===A0.querySubscribe&&this.connection.send({a:A0.queryUnsubscribe,id:this.id}),this.connection._destroyQuery(this),n&&Ry.nextTick(n)},pe.prototype._onConnectionStateChanged=function(){this.connection.canSend&&!this.sent?this.send():this.sent=!1},pe.prototype._handleFetch=function(n,t,e){this.connection._destroyQuery(this),this._handleResponse(n,t,e)},pe.prototype._handleSubscribe=function(n,t,e){this._handleResponse(n,t,e)},pe.prototype._handleResponse=function(n,t,e){var o=this.callback;if(this.callback=null,n)return this._finishResponse(n,o);if(!t)return this._finishResponse(null,o);var r=this,i=1,s=function(u){if(u)return r._finishResponse(u,o);--i||r._finishResponse(null,o)};if(Array.isArray(t))i+=t.length,this.results=this._ingestSnapshots(t,s),this.extra=e;else for(var l in t){i++;var c=t[l],a=this.connection.get(c.c||this.collection,l);a.ingestSnapshot(c,s)}s()},pe.prototype._ingestSnapshots=function(n,t){for(var e=[],o=0;o<n.length;o++){var r=n[o],i=this.connection.get(r.c||this.collection,r.d);i.ingestSnapshot(r,t),e.push(i)}return e},pe.prototype._finishResponse=function(n,t){if(this.emit("ready"),this.ready=!0,n)return this.connection._destroyQuery(this),t?t(n):this.emit("error",n);t&&t(null,this.results,this.extra)},pe.prototype._handleError=function(n){this.emit("error",n)},pe.prototype._handleDiff=function(n){for(var t=0;t<n.length;t++){var e=n[t];e.type==="insert"&&(e.values=this._ingestSnapshots(e.values))}for(var t=0;t<n.length;t++){var e=n[t];switch(e.type){case"insert":var o=e.values;Array.prototype.splice.apply(this.results,[e.index,0].concat(o)),this.emit("insert",o,e.index);break;case"remove":var i=e.howMany||1,r=this.results.splice(e.index,i);this.emit("remove",r,e.index);break;case"move":var i=e.howMany||1,s=this.results.splice(e.from,i);Array.prototype.splice.apply(this.results,[e.to,0].concat(s)),this.emit("move",s,e.from,e.to);break}}this.emit("changed",this.results)},pe.prototype._handleExtra=function(n){this.extra=n,this.emit("extra",n)};var O0=co,Oy=qo.ACTIONS,_y=tn,_0=bn;function bn(n,t){if(O0.EventEmitter.call(this),!t||typeof t!="string")throw new Error("LocalPresence presenceId must be a string");this.presence=n,this.presenceId=t,this.connection=n.connection,this.presenceVersion=0,this.value=null,this._pendingMessages=[],this._callbacksByPresenceVersion={}}O0.mixin(bn),bn.prototype.submit=function(n,t){this.value=n,this.send(t)},bn.prototype.send=function(n){var t=this._message();this._pendingMessages.push(t),this._callbacksByPresenceVersion[t.pv]=n,this._sendPending()},bn.prototype.destroy=function(n){var t=this;this.submit(null,function(e){if(e)return t._callbackOrEmit(e,n);delete t.presence.localPresences[t.presenceId],n&&n()})},bn.prototype._sendPending=function(){if(!!this.connection.canSend){var n=this;this._pendingMessages.forEach(function(t){n.connection.send(t)}),this._pendingMessages=[]}},bn.prototype._ack=function(n,t){var e=this._getCallback(t);this._callbackOrEmit(n,e)},bn.prototype._message=function(){return{a:Oy.presence,ch:this.presence.channel,id:this.presenceId,p:this.value,pv:this.presenceVersion++}},bn.prototype._getCallback=function(n){var t=this._callbacksByPresenceVersion[n];return delete this._callbacksByPresenceVersion[n],t},bn.prototype._callbackOrEmit=function(n,t){if(t)return _y.nextTick(t,n);n&&this.emit("error",n)};var Ny=tn,N0=Md;function Md(n,t){this.presence=n,this.presenceId=t,this.connection=this.presence.connection,this.value=null,this.presenceVersion=0}Md.prototype.receiveUpdate=function(n){n.pv<this.presenceVersion||(this.value=n.p,this.presenceVersion=n.pv,this.presence._updateRemotePresence(this))},Md.prototype.destroy=function(n){delete this.presence._remotePresenceInstances[this.presenceId],delete this.presence.remotePresences[this.presenceId],n&&Ny.nextTick(n)};var Rd={exports:{}};(function(n,t){(function(e,o){o(t)})(qi,function(e){function o(p,k){k=k|0;for(var B=Math.max(p.length-k,0),I=Array(B),D=0;D<B;D++)I[D]=p[k+D];return I}var r=function(p){var k=o(arguments,1);return function(){var B=o(arguments);return p.apply(null,k.concat(B))}},i=function(p){return function(){var k=o(arguments),B=k.pop();p.call(this,k,B)}};function s(p){var k=typeof p;return p!=null&&(k=="object"||k=="function")}var l=typeof setImmediate=="function"&&setImmediate,c=typeof process=="object"&&typeof process.nextTick=="function";function a(p){setTimeout(p,0)}function u(p){return function(k){var B=o(arguments,1);p(function(){k.apply(null,B)})}}var f;l?f=setImmediate:c?f=process.nextTick:f=a;var m=u(f);function C(p){return i(function(k,B){var I;try{I=p.apply(this,k)}catch(D){return B(D)}s(I)&&typeof I.then=="function"?I.then(function(D){v(B,null,D)},function(D){v(B,D.message?D:new Error(D))}):B(null,I)})}function v(p,k,B){try{p(k,B)}catch(I){m(w,I)}}function w(p){throw p}var E=typeof Symbol=="function";function L(p){return E&&p[Symbol.toStringTag]==="AsyncFunction"}function x(p){return L(p)?C(p):p}function A(p){return function(k){var B=o(arguments,1),I=i(function(D,T){var R=this;return p(k,function(_,q){x(_).apply(R,D.concat(q))},T)});return B.length?I.apply(this,B):I}}var O=typeof qi=="object"&&qi&&qi.Object===Object&&qi,P=typeof self=="object"&&self&&self.Object===Object&&self,V=O||P||Function("return this")(),tt=V.Symbol,ot=Object.prototype,ut=ot.hasOwnProperty,dt=ot.toString,yt=tt?tt.toStringTag:void 0;function oe(p){var k=ut.call(p,yt),B=p[yt];try{p[yt]=void 0;var I=!0}catch{}var D=dt.call(p);return I&&(k?p[yt]=B:delete p[yt]),D}var Jn=Object.prototype,Xt=Jn.toString;function Fe(p){return Xt.call(p)}var vo="[object Null]",ar="[object Undefined]",dr=tt?tt.toStringTag:void 0;function ko(p){return p==null?p===void 0?ar:vo:dr&&dr in Object(p)?oe(p):Fe(p)}var ma="[object AsyncFunction]",$P="[object Function]",HP="[object GeneratorFunction]",jP="[object Proxy]";function FP(p){if(!s(p))return!1;var k=ko(p);return k==$P||k==HP||k==ma||k==jP}var zP=9007199254740991;function B9(p){return typeof p=="number"&&p>-1&&p%1==0&&p<=zP}function $s(p){return p!=null&&B9(p.length)&&!FP(p)}var hf={};function ft(){}function yo(p){return function(){if(p!==null){var k=p;p=null,k.apply(this,arguments)}}}var ff=typeof Symbol=="function"&&Symbol.iterator,UP=function(p){return ff&&p[ff]&&p[ff]()};function VP(p,k){for(var B=-1,I=Array(p);++B<p;)I[B]=k(B);return I}function ga(p){return p!=null&&typeof p=="object"}var qP="[object Arguments]";function E9(p){return ga(p)&&ko(p)==qP}var I9=Object.prototype,WP=I9.hasOwnProperty,GP=I9.propertyIsEnumerable,ZP=E9(function(){return arguments}())?E9:function(p){return ga(p)&&WP.call(p,"callee")&&!GP.call(p,"callee")},dn=Array.isArray;function YP(){return!1}var x9=typeof e=="object"&&e&&!e.nodeType&&e,S9=x9&&!0&&n&&!n.nodeType&&n,QP=S9&&S9.exports===x9,T9=QP?V.Buffer:void 0,KP=T9?T9.isBuffer:void 0,JP=KP||YP,XP=9007199254740991,t$=/^(?:0|[1-9]\d*)$/;function e$(p,k){var B=typeof p;return k=k==null?XP:k,!!k&&(B=="number"||B!="symbol"&&t$.test(p))&&p>-1&&p%1==0&&p<k}var n$="[object Arguments]",o$="[object Array]",r$="[object Boolean]",i$="[object Date]",s$="[object Error]",l$="[object Function]",c$="[object Map]",a$="[object Number]",d$="[object Object]",u$="[object RegExp]",h$="[object Set]",f$="[object String]",m$="[object WeakMap]",g$="[object ArrayBuffer]",p$="[object DataView]",C$="[object Float32Array]",b$="[object Float64Array]",v$="[object Int8Array]",k$="[object Int16Array]",y$="[object Int32Array]",w$="[object Uint8Array]",B$="[object Uint8ClampedArray]",E$="[object Uint16Array]",I$="[object Uint32Array]",Bt={};Bt[C$]=Bt[b$]=Bt[v$]=Bt[k$]=Bt[y$]=Bt[w$]=Bt[B$]=Bt[E$]=Bt[I$]=!0,Bt[n$]=Bt[o$]=Bt[g$]=Bt[r$]=Bt[p$]=Bt[i$]=Bt[s$]=Bt[l$]=Bt[c$]=Bt[a$]=Bt[d$]=Bt[u$]=Bt[h$]=Bt[f$]=Bt[m$]=!1;function x$(p){return ga(p)&&B9(p.length)&&!!Bt[ko(p)]}function S$(p){return function(k){return p(k)}}var D9=typeof e=="object"&&e&&!e.nodeType&&e,Hs=D9&&!0&&n&&!n.nodeType&&n,T$=Hs&&Hs.exports===D9,mf=T$&&O.process,L9=function(){try{var p=Hs&&Hs.require&&Hs.require("util").types;return p||mf&&mf.binding&&mf.binding("util")}catch{}}(),M9=L9&&L9.isTypedArray,D$=M9?S$(M9):x$,L$=Object.prototype,M$=L$.hasOwnProperty;function R$(p,k){var B=dn(p),I=!B&&ZP(p),D=!B&&!I&&JP(p),T=!B&&!I&&!D&&D$(p),R=B||I||D||T,_=R?VP(p.length,String):[],q=_.length;for(var Q in p)(k||M$.call(p,Q))&&!(R&&(Q=="length"||D&&(Q=="offset"||Q=="parent")||T&&(Q=="buffer"||Q=="byteLength"||Q=="byteOffset")||e$(Q,q)))&&_.push(Q);return _}var A$=Object.prototype;function O$(p){var k=p&&p.constructor,B=typeof k=="function"&&k.prototype||A$;return p===B}function _$(p,k){return function(B){return p(k(B))}}var N$=_$(Object.keys,Object),P$=Object.prototype,$$=P$.hasOwnProperty;function H$(p){if(!O$(p))return N$(p);var k=[];for(var B in Object(p))$$.call(p,B)&&B!="constructor"&&k.push(B);return k}function gf(p){return $s(p)?R$(p):H$(p)}function j$(p){var k=-1,B=p.length;return function(){return++k<B?{value:p[k],key:k}:null}}function F$(p){var k=-1;return function(){var I=p.next();return I.done?null:(k++,{value:I.value,key:k})}}function z$(p){var k=gf(p),B=-1,I=k.length;return function D(){var T=k[++B];return T==="__proto__"?D():B<I?{value:p[T],key:T}:null}}function U$(p){if($s(p))return j$(p);var k=UP(p);return k?F$(k):z$(p)}function Dn(p){return function(){if(p===null)throw new Error("Callback was already called.");var k=p;p=null,k.apply(this,arguments)}}function pa(p){return function(k,B,I){if(I=yo(I||ft),p<=0||!k)return I(null);var D=U$(k),T=!1,R=0,_=!1;function q(W,X){if(R-=1,W)T=!0,I(W);else{if(X===hf||T&&R<=0)return T=!0,I(null);_||Q()}}function Q(){for(_=!0;R<p&&!T;){var W=D();if(W===null){T=!0,R<=0&&I(null);return}R+=1,B(W.value,W.key,Dn(q))}_=!1}Q()}}function ur(p,k,B,I){pa(k)(p,x(B),I)}function te(p,k){return function(B,I,D){return p(B,k,I,D)}}function V$(p,k,B){B=yo(B||ft);var I=0,D=0,T=p.length;T===0&&B(null);function R(_,q){_?B(_):(++D===T||q===hf)&&B(null)}for(;I<T;I++)k(p[I],I,Dn(R))}var q$=te(ur,1/0),wo=function(p,k,B){var I=$s(p)?V$:q$;I(p,x(k),B)};function ai(p){return function(k,B,I){return p(wo,k,x(B),I)}}function R9(p,k,B,I){I=I||ft,k=k||[];var D=[],T=0,R=x(B);p(k,function(_,q,Q){var W=T++;R(_,function(X,Et){D[W]=Et,Q(X)})},function(_){I(_,D)})}var Ca=ai(R9),A9=A(Ca);function di(p){return function(k,B,I,D){return p(pa(B),k,x(I),D)}}var ui=di(R9),pf=te(ui,1),O9=A(pf);function ba(p,k){for(var B=-1,I=p==null?0:p.length;++B<I&&k(p[B],B,p)!==!1;);return p}function W$(p){return function(k,B,I){for(var D=-1,T=Object(k),R=I(k),_=R.length;_--;){var q=R[p?_:++D];if(B(T[q],q,T)===!1)break}return k}}var G$=W$();function js(p,k){return p&&G$(p,k,gf)}function Z$(p,k,B,I){for(var D=p.length,T=B+(I?1:-1);I?T--:++T<D;)if(k(p[T],T,p))return T;return-1}function Y$(p){return p!==p}function Q$(p,k,B){for(var I=B-1,D=p.length;++I<D;)if(p[I]===k)return I;return-1}function va(p,k,B){return k===k?Q$(p,k,B):Z$(p,Y$,B)}var Cf=function(p,k,B){typeof k=="function"&&(B=k,k=null),B=yo(B||ft);var I=gf(p),D=I.length;if(!D)return B(null);k||(k=D);var T={},R=0,_=!1,q=Object.create(null),Q=[],W=[],X={};js(p,function(xt,St){if(!dn(xt)){Et(St,[xt]),W.push(St);return}var Yt=xt.slice(0,xt.length-1),Xn=Yt.length;if(Xn===0){Et(St,xt),W.push(St);return}X[St]=Xn,ba(Yt,function(gi){if(!p[gi])throw new Error("async.auto task `"+St+"` has a non-existent dependency `"+gi+"` in "+Yt.join(", "));Ln(gi,function(){Xn--,Xn===0&&Et(St,xt)})})}),zH(),re();function Et(xt,St){Q.push(function(){Mn(xt,St)})}function re(){if(Q.length===0&&R===0)return B(null,T);for(;Q.length&&R<k;){var xt=Q.shift();xt()}}function Ln(xt,St){var Yt=q[xt];Yt||(Yt=q[xt]=[]),Yt.push(St)}function ze(xt){var St=q[xt]||[];ba(St,function(Yt){Yt()}),re()}function Mn(xt,St){if(!_){var Yt=Dn(function(gi,Df){if(R--,arguments.length>2&&(Df=o(arguments,1)),gi){var Lf={};js(T,function(VH,qH){Lf[qH]=VH}),Lf[xt]=Df,_=!0,q=Object.create(null),B(gi,Lf)}else T[xt]=Df,ze(xt)});R++;var Xn=x(St[St.length-1]);St.length>1?Xn(T,Yt):Xn(Yt)}}function zH(){for(var xt,St=0;W.length;)xt=W.pop(),St++,ba(UH(xt),function(Yt){--X[Yt]===0&&W.push(Yt)});if(St!==D)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function UH(xt){var St=[];return js(p,function(Yt,Xn){dn(Yt)&&va(Yt,xt,0)>=0&&St.push(Xn)}),St}};function hi(p,k){for(var B=-1,I=p==null?0:p.length,D=Array(I);++B<I;)D[B]=k(p[B],B,p);return D}var K$="[object Symbol]";function J$(p){return typeof p=="symbol"||ga(p)&&ko(p)==K$}var X$=1/0,_9=tt?tt.prototype:void 0,N9=_9?_9.toString:void 0;function bf(p){if(typeof p=="string")return p;if(dn(p))return hi(p,bf)+"";if(J$(p))return N9?N9.call(p):"";var k=p+"";return k=="0"&&1/p==-X$?"-0":k}function tH(p,k,B){var I=-1,D=p.length;k<0&&(k=-k>D?0:D+k),B=B>D?D:B,B<0&&(B+=D),D=k>B?0:B-k>>>0,k>>>=0;for(var T=Array(D);++I<D;)T[I]=p[I+k];return T}function eH(p,k,B){var I=p.length;return B=B===void 0?I:B,!k&&B>=I?p:tH(p,k,B)}function nH(p,k){for(var B=p.length;B--&&va(k,p[B],0)>-1;);return B}function oH(p,k){for(var B=-1,I=p.length;++B<I&&va(k,p[B],0)>-1;);return B}function rH(p){return p.split("")}var iH="\\ud800-\\udfff",sH="\\u0300-\\u036f",lH="\\ufe20-\\ufe2f",cH="\\u20d0-\\u20ff",aH=sH+lH+cH,dH="\\ufe0e\\ufe0f",uH="\\u200d",hH=RegExp("["+uH+iH+aH+dH+"]");function fH(p){return hH.test(p)}var P9="\\ud800-\\udfff",mH="\\u0300-\\u036f",gH="\\ufe20-\\ufe2f",pH="\\u20d0-\\u20ff",CH=mH+gH+pH,bH="\\ufe0e\\ufe0f",vH="["+P9+"]",vf="["+CH+"]",kf="\\ud83c[\\udffb-\\udfff]",kH="(?:"+vf+"|"+kf+")",$9="[^"+P9+"]",H9="(?:\\ud83c[\\udde6-\\uddff]){2}",j9="[\\ud800-\\udbff][\\udc00-\\udfff]",yH="\\u200d",F9=kH+"?",z9="["+bH+"]?",wH="(?:"+yH+"(?:"+[$9,H9,j9].join("|")+")"+z9+F9+")*",BH=z9+F9+wH,EH="(?:"+[$9+vf+"?",vf,H9,j9,vH].join("|")+")",IH=RegExp(kf+"(?="+kf+")|"+EH+BH,"g");function xH(p){return p.match(IH)||[]}function U9(p){return fH(p)?xH(p):rH(p)}function SH(p){return p==null?"":bf(p)}var TH=/^\s+|\s+$/g;function DH(p,k,B){if(p=SH(p),p&&(B||k===void 0))return p.replace(TH,"");if(!p||!(k=bf(k)))return p;var I=U9(p),D=U9(k),T=oH(I,D),R=nH(I,D)+1;return eH(I,T,R).join("")}var LH=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,MH=/,/,RH=/(=.+)?(\s*)$/,AH=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;function OH(p){return p=p.toString().replace(AH,""),p=p.match(LH)[2].replace(" ",""),p=p?p.split(MH):[],p=p.map(function(k){return DH(k.replace(RH,""))}),p}function V9(p,k){var B={};js(p,function(I,D){var T,R=L(I),_=!R&&I.length===1||R&&I.length===0;if(dn(I))T=I.slice(0,-1),I=I[I.length-1],B[D]=T.concat(T.length>0?q:I);else if(_)B[D]=I;else{if(T=OH(I),I.length===0&&!R&&T.length===0)throw new Error("autoInject task functions require explicit parameters.");R||T.pop(),B[D]=T.concat(q)}function q(Q,W){var X=hi(T,function(Et){return Q[Et]});X.push(W),x(I).apply(null,X)}}),Cf(B,k)}function un(){this.head=this.tail=null,this.length=0}function q9(p,k){p.length=1,p.head=p.tail=k}un.prototype.removeLink=function(p){return p.prev?p.prev.next=p.next:this.head=p.next,p.next?p.next.prev=p.prev:this.tail=p.prev,p.prev=p.next=null,this.length-=1,p},un.prototype.empty=function(){for(;this.head;)this.shift();return this},un.prototype.insertAfter=function(p,k){k.prev=p,k.next=p.next,p.next?p.next.prev=k:this.tail=k,p.next=k,this.length+=1},un.prototype.insertBefore=function(p,k){k.prev=p.prev,k.next=p,p.prev?p.prev.next=k:this.head=k,p.prev=k,this.length+=1},un.prototype.unshift=function(p){this.head?this.insertBefore(this.head,p):q9(this,p)},un.prototype.push=function(p){this.tail?this.insertAfter(this.tail,p):q9(this,p)},un.prototype.shift=function(){return this.head&&this.removeLink(this.head)},un.prototype.pop=function(){return this.tail&&this.removeLink(this.tail)},un.prototype.toArray=function(){for(var p=Array(this.length),k=this.head,B=0;B<this.length;B++)p[B]=k.data,k=k.next;return p},un.prototype.remove=function(p){for(var k=this.head;k;){var B=k.next;p(k)&&this.removeLink(k),k=B}return this};function W9(p,k,B){if(k==null)k=1;else if(k===0)throw new Error("Concurrency must not be zero");var I=x(p),D=0,T=[],R=!1;function _(X,Et,re){if(re!=null&&typeof re!="function")throw new Error("task callback must be a function");if(W.started=!0,dn(X)||(X=[X]),X.length===0&&W.idle())return m(function(){W.drain()});for(var Ln=0,ze=X.length;Ln<ze;Ln++){var Mn={data:X[Ln],callback:re||ft};Et?W._tasks.unshift(Mn):W._tasks.push(Mn)}R||(R=!0,m(function(){R=!1,W.process()}))}function q(X){return function(Et){D-=1;for(var re=0,Ln=X.length;re<Ln;re++){var ze=X[re],Mn=va(T,ze,0);Mn===0?T.shift():Mn>0&&T.splice(Mn,1),ze.callback.apply(ze,arguments),Et!=null&&W.error(Et,ze.data)}D<=W.concurrency-W.buffer&&W.unsaturated(),W.idle()&&W.drain(),W.process()}}var Q=!1,W={_tasks:new un,concurrency:k,payload:B,saturated:ft,unsaturated:ft,buffer:k/4,empty:ft,drain:ft,error:ft,started:!1,paused:!1,push:function(X,Et){_(X,!1,Et)},kill:function(){W.drain=ft,W._tasks.empty()},unshift:function(X,Et){_(X,!0,Et)},remove:function(X){W._tasks.remove(X)},process:function(){if(!Q){for(Q=!0;!W.paused&&D<W.concurrency&&W._tasks.length;){var X=[],Et=[],re=W._tasks.length;W.payload&&(re=Math.min(re,W.payload));for(var Ln=0;Ln<re;Ln++){var ze=W._tasks.shift();X.push(ze),T.push(ze),Et.push(ze.data)}D+=1,W._tasks.length===0&&W.empty(),D===W.concurrency&&W.saturated();var Mn=Dn(q(X));I(Et,Mn)}Q=!1}},length:function(){return W._tasks.length},running:function(){return D},workersList:function(){return T},idle:function(){return W._tasks.length+D===0},pause:function(){W.paused=!0},resume:function(){W.paused!==!1&&(W.paused=!1,m(W.process))}};return W}function G9(p,k){return W9(p,1,k)}var fi=te(ur,1);function Bo(p,k,B,I){I=yo(I||ft);var D=x(B);fi(p,function(T,R,_){D(k,T,function(q,Q){k=Q,_(q)})},function(T){I(T,k)})}function yf(){var p=hi(arguments,x);return function(){var k=o(arguments),B=this,I=k[k.length-1];typeof I=="function"?k.pop():I=ft,Bo(p,k,function(D,T,R){T.apply(B,D.concat(function(_){var q=o(arguments,1);R(_,q)}))},function(D,T){I.apply(B,[D].concat(T))})}}var Z9=function(){return yf.apply(null,o(arguments).reverse())},_H=Array.prototype.concat,ka=function(p,k,B,I){I=I||ft;var D=x(B);ui(p,k,function(T,R){D(T,function(_){return _?R(_):R(null,o(arguments,1))})},function(T,R){for(var _=[],q=0;q<R.length;q++)R[q]&&(_=_H.apply(_,R[q]));return I(T,_)})},Y9=te(ka,1/0),Q9=te(ka,1),K9=function(){var p=o(arguments),k=[null].concat(p);return function(){var B=arguments[arguments.length-1];return B.apply(this,k)}};function Fs(p){return p}function mi(p,k){return function(B,I,D,T){T=T||ft;var R=!1,_;B(I,function(q,Q,W){D(q,function(X,Et){X?W(X):p(Et)&&!_?(R=!0,_=k(!0,q),W(null,hf)):W()})},function(q){q?T(q):T(null,R?_:k(!1))})}}function J9(p,k){return k}var ya=ai(mi(Fs,J9)),zs=di(mi(Fs,J9)),wa=te(zs,1);function X9(p){return function(k){var B=o(arguments,1);B.push(function(I){var D=o(arguments,1);typeof console=="object"&&(I?console.error&&console.error(I):console[p]&&ba(D,function(T){console[p](T)}))}),x(k).apply(null,B)}}var t7=X9("dir");function e7(p,k,B){B=Dn(B||ft);var I=x(p),D=x(k);function T(_){if(_)return B(_);var q=o(arguments,1);q.push(R),D.apply(this,q)}function R(_,q){if(_)return B(_);if(!q)return B(null);I(T)}R(null,!0)}function wf(p,k,B){B=Dn(B||ft);var I=x(p),D=function(T){if(T)return B(T);var R=o(arguments,1);if(k.apply(this,R))return I(D);B.apply(null,[null].concat(R))};I(D)}function n7(p,k,B){wf(p,function(){return!k.apply(this,arguments)},B)}function o7(p,k,B){B=Dn(B||ft);var I=x(k),D=x(p);function T(_){if(_)return B(_);D(R)}function R(_,q){if(_)return B(_);if(!q)return B(null);I(T)}D(R)}function r7(p){return function(k,B,I){return p(k,I)}}function Ba(p,k,B){wo(p,r7(x(k)),B)}function Us(p,k,B,I){pa(k)(p,r7(x(B)),I)}var Vs=te(Us,1);function Bf(p){return L(p)?p:i(function(k,B){var I=!0;k.push(function(){var D=arguments;I?m(function(){B.apply(null,D)}):B.apply(null,D)}),p.apply(this,k),I=!1})}function Ea(p){return!p}var Ia=ai(mi(Ea,Ea)),qs=di(mi(Ea,Ea)),xa=te(qs,1);function i7(p){return function(k){return k==null?void 0:k[p]}}function NH(p,k,B,I){var D=new Array(k.length);p(k,function(T,R,_){B(T,function(q,Q){D[R]=!!Q,_(q)})},function(T){if(T)return I(T);for(var R=[],_=0;_<k.length;_++)D[_]&&R.push(k[_]);I(null,R)})}function PH(p,k,B,I){var D=[];p(k,function(T,R,_){B(T,function(q,Q){q?_(q):(Q&&D.push({index:R,value:T}),_())})},function(T){T?I(T):I(null,hi(D.sort(function(R,_){return R.index-_.index}),i7("value")))})}function Ef(p,k,B,I){var D=$s(k)?NH:PH;D(p,k,x(B),I||ft)}var Sa=ai(Ef),Ws=di(Ef),Ta=te(Ws,1);function s7(p,k){var B=Dn(k||ft),I=x(Bf(p));function D(T){if(T)return B(T);I(D)}D()}var Da=function(p,k,B,I){I=I||ft;var D=x(B);ui(p,k,function(T,R){D(T,function(_,q){return _?R(_):R(null,{key:q,val:T})})},function(T,R){for(var _={},q=Object.prototype.hasOwnProperty,Q=0;Q<R.length;Q++)if(R[Q]){var W=R[Q].key,X=R[Q].val;q.call(_,W)?_[W].push(X):_[W]=[X]}return I(T,_)})},l7=te(Da,1/0),c7=te(Da,1),a7=X9("log");function La(p,k,B,I){I=yo(I||ft);var D={},T=x(B);ur(p,k,function(R,_,q){T(R,_,function(Q,W){if(Q)return q(Q);D[_]=W,q()})},function(R){I(R,D)})}var d7=te(La,1/0),u7=te(La,1);function h7(p,k){return k in p}function f7(p,k){var B=Object.create(null),I=Object.create(null);k=k||Fs;var D=x(p),T=i(function(_,q){var Q=k.apply(null,_);h7(B,Q)?m(function(){q.apply(null,B[Q])}):h7(I,Q)?I[Q].push(q):(I[Q]=[q],D.apply(null,_.concat(function(){var W=o(arguments);B[Q]=W;var X=I[Q];delete I[Q];for(var Et=0,re=X.length;Et<re;Et++)X[Et].apply(null,W)})))});return T.memo=B,T.unmemoized=p,T}var Ma;c?Ma=process.nextTick:l?Ma=setImmediate:Ma=a;var m7=u(Ma);function If(p,k,B){B=B||ft;var I=$s(k)?[]:{};p(k,function(D,T,R){x(D)(function(_,q){arguments.length>2&&(q=o(arguments,1)),I[T]=q,R(_)})},function(D){B(D,I)})}function g7(p,k){If(wo,p,k)}function p7(p,k,B){If(pa(k),p,B)}var xf=function(p,k){var B=x(p);return W9(function(I,D){B(I[0],D)},k,1)},C7=function(p,k){var B=xf(p,k);return B.push=function(I,D,T){if(T==null&&(T=ft),typeof T!="function")throw new Error("task callback must be a function");if(B.started=!0,dn(I)||(I=[I]),I.length===0)return m(function(){B.drain()});D=D||0;for(var R=B._tasks.head;R&&D>=R.priority;)R=R.next;for(var _=0,q=I.length;_<q;_++){var Q={data:I[_],priority:D,callback:T};R?B._tasks.insertBefore(R,Q):B._tasks.push(Q)}m(B.process)},delete B.unshift,B};function b7(p,k){if(k=yo(k||ft),!dn(p))return k(new TypeError("First argument to race must be an array of functions"));if(!p.length)return k();for(var B=0,I=p.length;B<I;B++)x(p[B])(k)}function Ra(p,k,B,I){var D=o(p).reverse();Bo(D,k,B,I)}function Aa(p){var k=x(p);return i(function(I,D){return I.push(function(R,_){if(R)D(null,{error:R});else{var q;arguments.length<=2?q=_:q=o(arguments,1),D(null,{value:q})}}),k.apply(this,I)})}function v7(p){var k;return dn(p)?k=hi(p,Aa):(k={},js(p,function(B,I){k[I]=Aa.call(this,B)})),k}function k7(p,k,B,I){Ef(p,k,function(D,T){B(D,function(R,_){T(R,!_)})},I)}var y7=ai(k7),Sf=di(k7),w7=te(Sf,1);function B7(p){return function(){return p}}function Oa(p,k,B){var I=5,D=0,T={times:I,intervalFunc:B7(D)};function R(W,X){if(typeof X=="object")W.times=+X.times||I,W.intervalFunc=typeof X.interval=="function"?X.interval:B7(+X.interval||D),W.errorFilter=X.errorFilter;else if(typeof X=="number"||typeof X=="string")W.times=+X||I;else throw new Error("Invalid arguments for async.retry")}if(arguments.length<3&&typeof p=="function"?(B=k||ft,k=p):(R(T,p),B=B||ft),typeof k!="function")throw new Error("Invalid arguments for async.retry");var _=x(k),q=1;function Q(){_(function(W){W&&q++<T.times&&(typeof T.errorFilter!="function"||T.errorFilter(W))?setTimeout(Q,T.intervalFunc(q)):B.apply(null,arguments)})}Q()}var E7=function(p,k){k||(k=p,p=null);var B=x(k);return i(function(I,D){function T(R){B.apply(null,I.concat(R))}p?Oa(p,T,D):Oa(T,D)})};function I7(p,k){If(fi,p,k)}var _a=ai(mi(Boolean,Fs)),Gs=di(mi(Boolean,Fs)),Na=te(Gs,1);function x7(p,k,B){var I=x(k);Ca(p,function(T,R){I(T,function(_,q){if(_)return R(_);R(null,{value:T,criteria:q})})},function(T,R){if(T)return B(T);B(null,hi(R.sort(D),i7("value")))});function D(T,R){var _=T.criteria,q=R.criteria;return _<q?-1:_>q?1:0}}function S7(p,k,B){var I=x(p);return i(function(D,T){var R=!1,_;function q(){var Q=p.name||"anonymous",W=new Error('Callback function "'+Q+'" timed out.');W.code="ETIMEDOUT",B&&(W.info=B),R=!0,T(W)}D.push(function(){R||(T.apply(null,arguments),clearTimeout(_))}),_=setTimeout(q,k),I.apply(null,D)})}var $H=Math.ceil,HH=Math.max;function jH(p,k,B,I){for(var D=-1,T=HH($H((k-p)/(B||1)),0),R=Array(T);T--;)R[I?T:++D]=p,p+=B;return R}function Pa(p,k,B,I){var D=x(B);ui(jH(0,p,1),k,D,I)}var T7=te(Pa,1/0),D7=te(Pa,1);function L7(p,k,B,I){arguments.length<=3&&(I=B,B=k,k=dn(p)?[]:{}),I=yo(I||ft);var D=x(B);wo(p,function(T,R,_){D(k,T,R,_)},function(T){I(T,k)})}function M7(p,k){var B=null,I;k=k||ft,Vs(p,function(D,T){x(D)(function(R,_){arguments.length>2?I=o(arguments,1):I=_,B=R,T(!R)})},function(){k(B,I)})}function R7(p){return function(){return(p.unmemoized||p).apply(null,arguments)}}function Tf(p,k,B){B=Dn(B||ft);var I=x(k);if(!p())return B(null);var D=function(T){if(T)return B(T);if(p())return I(D);var R=o(arguments,1);B.apply(null,[null].concat(R))};I(D)}function A7(p,k,B){Tf(function(){return!p.apply(this,arguments)},k,B)}var O7=function(p,k){if(k=yo(k||ft),!dn(p))return k(new Error("First argument to waterfall must be an array of functions"));if(!p.length)return k();var B=0;function I(T){var R=x(p[B++]);T.push(Dn(D)),R.apply(null,T)}function D(T){if(T||B===p.length)return k.apply(null,arguments);I(o(arguments,1))}I([])},FH={apply:r,applyEach:A9,applyEachSeries:O9,asyncify:C,auto:Cf,autoInject:V9,cargo:G9,compose:Z9,concat:Y9,concatLimit:ka,concatSeries:Q9,constant:K9,detect:ya,detectLimit:zs,detectSeries:wa,dir:t7,doDuring:e7,doUntil:n7,doWhilst:wf,during:o7,each:Ba,eachLimit:Us,eachOf:wo,eachOfLimit:ur,eachOfSeries:fi,eachSeries:Vs,ensureAsync:Bf,every:Ia,everyLimit:qs,everySeries:xa,filter:Sa,filterLimit:Ws,filterSeries:Ta,forever:s7,groupBy:l7,groupByLimit:Da,groupBySeries:c7,log:a7,map:Ca,mapLimit:ui,mapSeries:pf,mapValues:d7,mapValuesLimit:La,mapValuesSeries:u7,memoize:f7,nextTick:m7,parallel:g7,parallelLimit:p7,priorityQueue:C7,queue:xf,race:b7,reduce:Bo,reduceRight:Ra,reflect:Aa,reflectAll:v7,reject:y7,rejectLimit:Sf,rejectSeries:w7,retry:Oa,retryable:E7,seq:yf,series:I7,setImmediate:m,some:_a,someLimit:Gs,someSeries:Na,sortBy:x7,timeout:S7,times:T7,timesLimit:Pa,timesSeries:D7,transform:L7,tryEach:M7,unmemoize:R7,until:A7,waterfall:O7,whilst:Tf,all:Ia,allLimit:qs,allSeries:xa,any:_a,anyLimit:Gs,anySeries:Na,find:ya,findLimit:zs,findSeries:wa,forEach:Ba,forEachSeries:Vs,forEachLimit:Us,forEachOf:wo,forEachOfSeries:fi,forEachOfLimit:ur,inject:Bo,foldl:Bo,foldr:Ra,select:Sa,selectLimit:Ws,selectSeries:Ta,wrapSync:C};e.default=FH,e.apply=r,e.applyEach=A9,e.applyEachSeries=O9,e.asyncify=C,e.auto=Cf,e.autoInject=V9,e.cargo=G9,e.compose=Z9,e.concat=Y9,e.concatLimit=ka,e.concatSeries=Q9,e.constant=K9,e.detect=ya,e.detectLimit=zs,e.detectSeries=wa,e.dir=t7,e.doDuring=e7,e.doUntil=n7,e.doWhilst=wf,e.during=o7,e.each=Ba,e.eachLimit=Us,e.eachOf=wo,e.eachOfLimit=ur,e.eachOfSeries=fi,e.eachSeries=Vs,e.ensureAsync=Bf,e.every=Ia,e.everyLimit=qs,e.everySeries=xa,e.filter=Sa,e.filterLimit=Ws,e.filterSeries=Ta,e.forever=s7,e.groupBy=l7,e.groupByLimit=Da,e.groupBySeries=c7,e.log=a7,e.map=Ca,e.mapLimit=ui,e.mapSeries=pf,e.mapValues=d7,e.mapValuesLimit=La,e.mapValuesSeries=u7,e.memoize=f7,e.nextTick=m7,e.parallel=g7,e.parallelLimit=p7,e.priorityQueue=C7,e.queue=xf,e.race=b7,e.reduce=Bo,e.reduceRight=Ra,e.reflect=Aa,e.reflectAll=v7,e.reject=y7,e.rejectLimit=Sf,e.rejectSeries=w7,e.retry=Oa,e.retryable=E7,e.seq=yf,e.series=I7,e.setImmediate=m,e.some=_a,e.someLimit=Gs,e.someSeries=Na,e.sortBy=x7,e.timeout=S7,e.times=T7,e.timesLimit=Pa,e.timesSeries=D7,e.transform=L7,e.tryEach=M7,e.unmemoize=R7,e.until=A7,e.waterfall=O7,e.whilst=Tf,e.all=Ia,e.allLimit=qs,e.allSeries=xa,e.any=_a,e.anyLimit=Gs,e.anySeries=Na,e.find=ya,e.findLimit=zs,e.findSeries=wa,e.forEach=Ba,e.forEachSeries=Vs,e.forEachLimit=Us,e.forEachOf=wo,e.forEachOfSeries=fi,e.forEachOfLimit=ur,e.inject=Bo,e.foldl=Bo,e.foldr=Ra,e.select=Sa,e.selectLimit=Ws,e.selectSeries=Ta,e.wrapSync=C,Object.defineProperty(e,"__esModule",{value:!0})})})(Rd,Rd.exports);var P0={exports:{}},Ad=P0.exports=function(n,t){if(t||(t=16),n===void 0&&(n=128),n<=0)return"0";for(var e=Math.log(Math.pow(2,n))/Math.log(t),o=2;e===1/0;o*=2)e=Math.log(Math.pow(2,n/o))/Math.log(t)*o;for(var r=e-Math.floor(e),i="",o=0;o<Math.floor(e);o++){var s=Math.floor(Math.random()*t).toString(t);i=s+i}if(r){var l=Math.pow(t,r),s=Math.floor(Math.random()*l).toString(t);i=s+i}var c=parseInt(i,t);return c!==1/0&&c>=Math.pow(2,n)?Ad(n,t):i};Ad.rack=function(n,t,e){var o=function(i){var s=0;do{if(s++>10)if(e)n+=e;else throw new Error("too many ID collisions, use more bits");var l=Ad(n,t)}while(Object.hasOwnProperty.call(r,l));return r[l]=i,l},r=o.hats={};return o.get=function(i){return o.hats[i]},o.set=function(i,s){return o.hats[i]=s,o},o.bits=n||128,o.base=t||16,o};var $0=co,Py=_0,$y=N0,Kl=tn,Od=Rd.exports,Hy=P0.exports,H0=qo.ACTIONS,j0=Pt;function Pt(n,t){if($0.EventEmitter.call(this),!t||typeof t!="string")throw new Error("Presence channel must be provided");this.connection=n,this.channel=t,this.wantSubscribe=!1,this.subscribed=!1,this.remotePresences={},this.localPresences={},this._remotePresenceInstances={},this._subscriptionCallbacksBySeq={},this._wantsDestroy=!1}$0.mixin(Pt),Pt.prototype.subscribe=function(n){this._sendSubscriptionAction(!0,n)},Pt.prototype.unsubscribe=function(n){this._sendSubscriptionAction(!1,n)},Pt.prototype.create=function(n){if(this._wantsDestroy)throw new Error("Presence is being destroyed");n=n||Hy();var t=this._createLocalPresence(n);return this.localPresences[n]=t,t},Pt.prototype.destroy=function(n){this._wantsDestroy=!0;var t=this,e=Object.keys(t.localPresences);this.unsubscribe(function(o){if(o)return t._callbackOrEmit(o,n);var r=Object.keys(t._remotePresenceInstances);Od.parallel([function(i){Od.each(e,function(s,l){t.localPresences[s].destroy(l)},i)},function(i){if(!t._wantsDestroy)return i();Od.each(r,function(s,l){t._remotePresenceInstances[s].destroy(l)},i)}],function(i){t._wantsDestroy&&delete t.connection._presences[t.channel],t._callbackOrEmit(i,n)})})},Pt.prototype._sendSubscriptionAction=function(n,t){this.wantSubscribe=!!n;var e=this.wantSubscribe?H0.presenceSubscribe:H0.presenceUnsubscribe,o=this.connection._presenceSeq++;this._subscriptionCallbacksBySeq[o]=t,this.connection.canSend&&this.connection._sendPresenceAction(e,o,this)},Pt.prototype._handleSubscribe=function(n,t){this.wantSubscribe&&(this.subscribed=!0);var e=this._subscriptionCallback(t);this._callbackOrEmit(n,e)},Pt.prototype._handleUnsubscribe=function(n,t){this.subscribed=!1;var e=this._subscriptionCallback(t);this._callbackOrEmit(n,e)},Pt.prototype._receiveUpdate=function(n,t){var e=Kl.dig(this.localPresences,t.id);if(e)return e._ack(n,t.pv);if(n)return this.emit("error",n);var o=this,r=Kl.digOrCreate(this._remotePresenceInstances,t.id,function(){return o._createRemotePresence(t.id)});r.receiveUpdate(t)},Pt.prototype._updateRemotePresence=function(n){this.remotePresences[n.presenceId]=n.value,n.value===null&&this._removeRemotePresence(n.presenceId),this.emit("receive",n.presenceId,n.value)},Pt.prototype._broadcastAllLocalPresence=function(n){if(n)return this.emit("error",n);for(var t in this.localPresences){var e=this.localPresences[t];e.value!==null&&e.send()}},Pt.prototype._removeRemotePresence=function(n){this._remotePresenceInstances[n].destroy(),delete this._remotePresenceInstances[n],delete this.remotePresences[n]},Pt.prototype._onConnectionStateChanged=function(){if(!!this.connection.canSend){this._resubscribe();for(var n in this.localPresences)this.localPresences[n]._sendPending()}},Pt.prototype._resubscribe=function(){var n=[];for(var t in this._subscriptionCallbacksBySeq){var e=this._subscriptionCallback(t);n.push(e)}if(!this.wantSubscribe)return this._callEachOrEmit(n);var o=this;this.subscribe(function(r){o._callEachOrEmit(n,r)})},Pt.prototype._subscriptionCallback=function(n){var t=this._subscriptionCallbacksBySeq[n];return delete this._subscriptionCallbacksBySeq[n],t},Pt.prototype._callbackOrEmit=function(n,t){if(t)return Kl.nextTick(t,n);n&&this.emit("error",n)},Pt.prototype._createLocalPresence=function(n){return new Py(this,n)},Pt.prototype._createRemotePresence=function(n){return new $y(this,n)},Pt.prototype._callEachOrEmit=function(n,t){var e=Kl.callEach(n,t);!e&&t&&this.emit("error",t)};var Yi=_0,F0=Wl,jy=tn,z0=F0.CODES,Fy=nn;function nn(n,t){Yi.call(this,n,t),this.collection=this.presence.collection,this.id=this.presence.id,this._doc=this.connection.get(this.collection,this.id),this._isSending=!1,this._docDataVersionByPresenceVersion={},this._opHandler=this._transformAgainstOp.bind(this),this._createOrDelHandler=this._handleCreateOrDel.bind(this),this._loadHandler=this._handleLoad.bind(this),this._destroyHandler=this.destroy.bind(this),this._registerWithDoc()}nn.prototype=Object.create(Yi.prototype),nn.prototype.submit=function(n,t){if(!this._doc.type){if(n===null)return this._callbackOrEmit(null,t);var e={code:z0.ERR_DOC_DOES_NOT_EXIST,message:"Cannot submit presence. Document has not been created"};return this._callbackOrEmit(e,t)}this._docDataVersionByPresenceVersion[this.presenceVersion]=this._doc._dataStateVersion,Yi.prototype.submit.call(this,n,t)},nn.prototype.destroy=function(n){this._doc.removeListener("op",this._opHandler),this._doc.removeListener("create",this._createOrDelHandler),this._doc.removeListener("del",this._createOrDelHandler),this._doc.removeListener("load",this._loadHandler),this._doc.removeListener("destroy",this._destroyHandler),Yi.prototype.destroy.call(this,n)},nn.prototype._sendPending=function(){if(!this._isSending){this._isSending=!0;var n=this;this._doc.whenNothingPending(function(){n._isSending=!1,n.connection.canSend&&(n._pendingMessages.forEach(function(t){t.t=n._doc.type.uri,t.v=n._doc.version,n.connection.send(t)}),n._pendingMessages=[],n._docDataVersionByPresenceVersion={})})}},nn.prototype._registerWithDoc=function(){this._doc.on("op",this._opHandler),this._doc.on("create",this._createOrDelHandler),this._doc.on("del",this._createOrDelHandler),this._doc.on("load",this._loadHandler),this._doc.on("destroy",this._destroyHandler)},nn.prototype._transformAgainstOp=function(n,t){var e=this,o=this._doc._dataStateVersion;this._pendingMessages.forEach(function(r){var i=e._docDataVersionByPresenceVersion[r.pv];if(!(i>=o))try{r.p=e._transformPresence(r.p,n,t),e._docDataVersionByPresenceVersion[r.pv]=o}catch(l){var s=e._getCallback(r.pv);e._callbackOrEmit(l,s)}});try{this.value=this._transformPresence(this.value,n,t)}catch(r){this.emit("error",r)}},nn.prototype._handleCreateOrDel=function(){this._pendingMessages.forEach(function(n){n.p=null}),this.value=null},nn.prototype._handleLoad=function(){this.value=null,this._pendingMessages=[],this._docDataVersionByPresenceVersion={}},nn.prototype._message=function(){var n=Yi.prototype._message.call(this);return n.c=this.collection,n.d=this.id,n.v=null,n.t=null,n},nn.prototype._transformPresence=function(n,t,e){var o=this._doc.type;if(!jy.supportsPresence(o))throw new F0(z0.ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE,"Type does not support presence: "+o.name);return o.transformPresence(n,t,e)};var U0={};(function(n){var t=Wi,e=Wl,o=tn,r=e.CODES;n.checkOp=function(l){if(l==null||typeof l!="object")return new e(r.ERR_OT_OP_BADLY_FORMED,"Op must be an object");if(l.create!=null){if(typeof l.create!="object")return new e(r.ERR_OT_OP_BADLY_FORMED,"Create data must be an object");var c=l.create.type;if(typeof c!="string")return new e(r.ERR_OT_OP_BADLY_FORMED,"Missing create type");var a=t.map[c];if(a==null||typeof a!="object")return new e(r.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type")}else if(l.del!=null){if(l.del!==!0)return new e(r.ERR_OT_OP_BADLY_FORMED,"del value must be true")}else if(!("op"in l))return new e(r.ERR_OT_OP_BADLY_FORMED,"Missing op, create, or del");if(l.src!=null&&typeof l.src!="string")return new e(r.ERR_OT_OP_BADLY_FORMED,"src must be a string");if(l.seq!=null&&typeof l.seq!="number")return new e(r.ERR_OT_OP_BADLY_FORMED,"seq must be a number");if(l.src==null&&l.seq!=null||l.src!=null&&l.seq==null)return new e(r.ERR_OT_OP_BADLY_FORMED,"Both src and seq must be set together");if(l.m!=null&&typeof l.m!="object")return new e(r.ERR_OT_OP_BADLY_FORMED,"op.m must be an object or null")},n.normalizeType=function(l){return t.map[l]&&t.map[l].uri},n.apply=function(l,c){if(typeof l!="object")return new e(r.ERR_APPLY_SNAPSHOT_NOT_PROVIDED,"Missing snapshot");if(l.v!=null&&c.v!=null&&l.v!==c.v)return new e(r.ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT,"Version mismatch");if(c.create){if(l.type)return new e(r.ERR_DOC_ALREADY_CREATED,"Document already exists");var a=c.create,u=t.map[a.type];if(!u)return new e(r.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{l.data=u.create(a.data),l.type=u.uri,l.v++}catch(m){return m}}else if(c.del)l.data=void 0,l.type=null,l.v++;else if("op"in c){var f=i(l,c.op);if(f)return f;l.v++}else l.v++};function i(l,c){if(!l.type)return new e(r.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");if(c===void 0)return new e(r.ERR_OT_OP_NOT_PROVIDED,"Missing op");var a=t.map[l.type];if(!a)return new e(r.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{l.data=a.apply(l.data,c)}catch(u){return new e(r.ERR_OT_OP_NOT_APPLIED,u.message)}}n.transform=function(l,c,a){if(c.v!=null&&c.v!==a.v)return new e(r.ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM,"Version mismatch");if(a.del){if(c.create||"op"in c)return new e(r.ERR_DOC_WAS_DELETED,"Document was deleted")}else{if(a.create&&("op"in c||c.create||c.del)||"op"in a&&c.create)return new e(r.ERR_DOC_ALREADY_CREATED,"Document was created remotely");if("op"in a&&"op"in c){if(!l)return new e(r.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");if(typeof l=="string"&&(l=t.map[l],!l))return new e(r.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{c.op=l.transform(c.op,a.op,"left")}catch(u){return u}}}c.v!=null&&c.v++},n.applyOps=function(l,c,a){a=a||{};for(var u=0;u<c.length;u++){var f=c[u];if(a._normalizeLegacyJson0Ops)try{s(l,f)}catch{return new e(r.ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED,"Cannot normalize legacy json0 op")}l.v=f.v;var m=n.apply(l,f);if(m)return m}},n.transformPresence=function(l,c,a){var u=this.checkOp(c);if(u)return u;var f=l.t;if(typeof f=="string"&&(f=t.map[f]),!f)return{code:r.ERR_DOC_TYPE_NOT_RECOGNIZED,message:"Unknown type"};if(!o.supportsPresence(f))return{code:r.ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE,message:"Type does not support presence"};if(c.create||c.del){l.p=null,l.v++;return}try{l.p=l.p===null?null:f.transformPresence(l.p,c.op,a)}catch(m){return{code:r.ERR_PRESENCE_TRANSFORM_FAILED,message:m.message||m}}l.v++};function s(l,c){if(l.type===t.defaultType.uri){var a=c.op;if(!!a){var u=l.data;a.length>1&&(u=o.clone(u));for(var f=0;f<a.length;f++){var m=a[f];typeof m.lm=="string"&&(m.lm=+m.lm);for(var C=m.p,v=u,w=0;w<C.length;w++){var E=C[w];Object.prototype.toString.call(v)=="[object Array]"?C[w]=+E:v.constructor===Object&&(C[w]=E.toString()),v=v[E]}f<a.length-1&&(u=t.defaultType.apply(u,[m]))}}}}})(U0);var Qi=N0,zy=U0,Uy=Pe;function Pe(n,t){Qi.call(this,n,t),this.collection=this.presence.collection,this.id=this.presence.id,this.src=null,this.presenceVersion=null,this._doc=this.connection.get(this.collection,this.id),this._pending=null,this._opCache=null,this._pendingSetPending=!1,this._opHandler=this._handleOp.bind(this),this._createDelHandler=this._handleCreateDel.bind(this),this._loadHandler=this._handleLoad.bind(this),this._registerWithDoc()}Pe.prototype=Object.create(Qi.prototype),Pe.prototype.receiveUpdate=function(n){this._pending&&n.pv<this._pending.pv||(this.src=n.src,this._pending=n,this._setPendingPresence())},Pe.prototype.destroy=function(n){this._doc.removeListener("op",this._opHandler),this._doc.removeListener("create",this._createDelHandler),this._doc.removeListener("del",this._createDelHandler),this._doc.removeListener("load",this._loadHandler),Qi.prototype.destroy.call(this,n)},Pe.prototype._registerWithDoc=function(){this._doc.on("op",this._opHandler),this._doc.on("create",this._createDelHandler),this._doc.on("del",this._createDelHandler),this._doc.on("load",this._loadHandler)},Pe.prototype._setPendingPresence=function(){if(!this._pendingSetPending){this._pendingSetPending=!0;var n=this;this._doc.whenNothingPending(function(){if(n._pendingSetPending=!1,!!n._pending){if(n._pending.pv<n.presenceVersion)return n._pending=null;if(n._pending.v>n._doc.version)return n._doc.fetch();!n._catchUpStalePresence()||(n.value=n._pending.p,n.presenceVersion=n._pending.pv,n._pending=null,n.presence._updateRemotePresence(n))}})}},Pe.prototype._handleOp=function(n,t,e){var o=e===this.src;this._transformAgainstOp(n,o),this._cacheOp(n,o),this._setPendingPresence()},Qi.prototype._handleCreateDel=function(){this._cacheOp(null),this._setPendingPresence()},Qi.prototype._handleLoad=function(){this.value=null,this._pending=null,this._opCache=null,this.presence._updateRemotePresence(this)},Pe.prototype._transformAgainstOp=function(n,t){if(!!this.value){try{this.value=this._doc.type.transformPresence(this.value,n,t)}catch(e){return this.presence.emit("error",e)}this.presence._updateRemotePresence(this)}},Pe.prototype._catchUpStalePresence=function(){if(this._pending.v>=this._doc.version)return!0;if(!this._opCache)return this._startCachingOps(),this._doc.fetch(),this.presence.subscribe(),!1;for(;this._opCache[this._pending.v];){var n=this._opCache[this._pending.v],t=n.op,e=n.isOwnOp;t===null?(this._pending.p=null,this._pending.v++):zy.transformPresence(this._pending,t,e)}var o=this._pending.v>=this._doc.version;return o&&this._stopCachingOps(),o},Pe.prototype._startCachingOps=function(){this._opCache=[]},Pe.prototype._stopCachingOps=function(){this._opCache=null},Pe.prototype._cacheOp=function(n,t){this._opCache&&(n=n?{op:n}:null,this._opCache[this._doc.version-1]={op:n,isOwnOp:t})};var V0=j0,Vy=Fy,qy=Uy;function Ar(n,t,e){var o=Ar.channel(t,e);V0.call(this,n,o),this.collection=t,this.id=e}var Wy=Ar;Ar.prototype=Object.create(V0.prototype),Ar.channel=function(n,t){return n+"."+t},Ar.prototype._createLocalPresence=function(n){return new Vy(this,n)},Ar.prototype._createRemotePresence=function(n){return new qy(this,n)};var Gy=Zy;function Zy(n,t,e,o,r){this.id=n,this.v=t,this.type=e,this.data=o,this.m=r}var Yy=Gy,q0=co,W0=Ki;function Ki(n,t,e,o,r){if(q0.EventEmitter.call(this),typeof r!="function")throw new Error("Callback is required for SnapshotRequest");this.requestId=t,this.connection=n,this.id=o,this.collection=e,this.callback=r,this.sent=!1}q0.mixin(Ki),Ki.prototype.send=function(){!this.connection.canSend||(this.connection.send(this._message()),this.sent=!0)},Ki.prototype._onConnectionStateChanged=function(){this.connection.canSend?this.sent||this.send():this.sent=!1},Ki.prototype._handleResponse=function(n,t){if(this.emit("ready"),n)return this.callback(n);var e=t.meta?t.meta:null,o=new Yy(this.id,t.v,t.type,t.data,e);this.callback(null,o)};var G0=W0,Qy=tn,Ky=qo.ACTIONS,Jy=_d;function _d(n,t,e,o,r,i){if(G0.call(this,n,t,e,o,i),!Qy.isValidVersion(r))throw new Error("Snapshot version must be a positive integer or null");this.version=r}_d.prototype=Object.create(G0.prototype),_d.prototype._message=function(){return{a:Ky.snapshotFetch,id:this.requestId,c:this.collection,d:this.id,v:this.version}};var Z0=W0,Xy=tn,tw=qo.ACTIONS,ew=Nd;function Nd(n,t,e,o,r,i){if(Z0.call(this,n,t,e,o,i),!Xy.isValidTimestamp(r))throw new Error("Snapshot timestamp must be a positive integer or null");this.timestamp=r}Nd.prototype=Object.create(Z0.prototype),Nd.prototype._message=function(){return{a:tw.snapshotFetchByTimestamp,id:this.requestId,c:this.collection,d:this.id,ts:this.timestamp}};var nw=Ty,ow=Ay,rw=j0,Y0=Wy,iw=Jy,sw=ew,Q0=co,Or=Wl,pt=qo.ACTIONS,K0=Wi,on=tn,Ji=x0,Xi=Or.CODES;function J0(n){return n.readyState===0||n.readyState===1?"connecting":"disconnected"}var lw=J;function J(n){Q0.EventEmitter.call(this),this.collections={},this.nextQueryId=1,this.nextSnapshotRequestId=1,this.queries={},this._presences={},this._snapshotRequests={},this.seq=1,this._presenceSeq=1,this.id=null,this.agent=null,this.debug=!1,this.state=J0(n),this.bindToSocket(n)}Q0.mixin(J),J.prototype.bindToSocket=function(n){this.socket&&(this.socket.close(),this.socket.onmessage=null,this.socket.onopen=null,this.socket.onerror=null,this.socket.onclose=null),this.socket=n;var t=J0(n);this._setState(t),this.canSend=!1;var e=this;n.onmessage=function(o){try{var r=typeof o.data=="string"?JSON.parse(o.data):o.data}catch{Ji.warn("Failed to parse message",o);return}e.debug&&Ji.info("RECV",JSON.stringify(r));var i={data:r};if(e.emit("receive",i),!!i.data)try{e.handleMessage(i.data)}catch(s){on.nextTick(function(){e.emit("error",s)})}},n.readyState===1&&e._initializeHandshake(),n.onopen=function(){e._setState("connecting"),e._initializeHandshake()},n.onerror=function(o){e.emit("connection error",o)},n.onclose=function(o){o==="closed"||o==="Closed"?e._setState("closed",o):o==="stopped"||o==="Stopped by server"?e._setState("stopped",o):e._setState("disconnected",o)}},J.prototype.handleMessage=function(n){var t=null;switch(n.error&&(t=X0(n.error,n),delete n.error),n.a){case pt.initLegacy:return this._handleLegacyInit(n);case pt.handshake:return this._handleHandshake(t,n);case pt.queryFetch:var e=this.queries[n.id];e&&e._handleFetch(t,n.data,n.extra);return;case pt.querySubscribe:var e=this.queries[n.id];e&&e._handleSubscribe(t,n.data,n.extra);return;case pt.queryUnsubscribe:return;case pt.queryUpdate:var e=this.queries[n.id];if(!e)return;if(t)return e._handleError(t);n.diff&&e._handleDiff(n.diff),n.hasOwnProperty("extra")&&e._handleExtra(n.extra);return;case pt.bulkFetch:return this._handleBulkMessage(t,n,"_handleFetch");case pt.bulkSubscribe:case pt.bulkUnsubscribe:return this._handleBulkMessage(t,n,"_handleSubscribe");case pt.snapshotFetch:case pt.snapshotFetchByTimestamp:return this._handleSnapshotFetch(t,n);case pt.fetch:var o=this.getExisting(n.c,n.d);o&&o._handleFetch(t,n.data);return;case pt.subscribe:case pt.unsubscribe:var o=this.getExisting(n.c,n.d);o&&o._handleSubscribe(t,n.data);return;case pt.op:var o=this.getExisting(n.c,n.d);o&&o._handleOp(t,n);return;case pt.presence:return this._handlePresence(t,n);case pt.presenceSubscribe:return this._handlePresenceSubscribe(t,n);case pt.presenceUnsubscribe:return this._handlePresenceUnsubscribe(t,n);case pt.presenceRequest:return this._handlePresenceRequest(t,n);case pt.pingPong:return this._handlePingPong(t);default:Ji.warn("Ignoring unrecognized message",n)}};function X0(n,t){var e=new Error(n.message);return e.code=n.code,t&&(e.data=t),e}J.prototype._handleBulkMessage=function(n,t,e){if(t.data)for(var o in t.data){var r=t.data[o],i=this.getExisting(t.c,o);i&&(n?i[e](n):r.error?i[e](X0(r.error)):i[e](null,r))}else if(Array.isArray(t.b))for(var s=0;s<t.b.length;s++){var o=t.b[s],i=this.getExisting(t.c,o);i&&i[e](n)}else if(t.b)for(var o in t.b){var i=this.getExisting(t.c,o);i&&i[e](n)}else Ji.error("Invalid bulk message",t)},J.prototype._reset=function(){this.agent=null},J.prototype._setState=function(n,t){if(this.state!==n){if(n==="connecting"&&this.state!=="disconnected"&&this.state!=="stopped"&&this.state!=="closed"||n==="connected"&&this.state!=="connecting"){var e=new Or(Xi.ERR_CONNECTION_STATE_TRANSITION_INVALID,"Cannot transition directly from "+this.state+" to "+n);return this.emit("error",e)}this.state=n,this.canSend=n==="connected",(n==="disconnected"||n==="stopped"||n==="closed")&&this._reset(),this.startBulk();for(var o in this.queries){var r=this.queries[o];r._onConnectionStateChanged()}for(var i in this.collections){var s=this.collections[i];for(var o in s)s[o]._onConnectionStateChanged()}for(var l in this._presences)this._presences[l]._onConnectionStateChanged();for(var o in this._snapshotRequests){var c=this._snapshotRequests[o];c._onConnectionStateChanged()}this.endBulk(),this.emit(n,t),this.emit("state",n,t)}},J.prototype.startBulk=function(){this.bulk||(this.bulk={})},J.prototype.endBulk=function(){if(this.bulk)for(var n in this.bulk){var t=this.bulk[n];this._sendBulk("f",n,t.f),this._sendBulk("s",n,t.s),this._sendBulk("u",n,t.u)}this.bulk=null},J.prototype._sendBulk=function(n,t,e){if(!!e){var o=[],r={},i=0,s;for(var l in e){var c=e[l];c==null?o.push(l):(r[l]=c,s=l,i++)}if(o.length===1){var l=o[0];this.send({a:n,c:t,d:l})}else o.length&&this.send({a:"b"+n,c:t,b:o});if(i===1){var a=r[s];this.send({a:n,c:t,d:s,v:a})}else i&&this.send({a:"b"+n,c:t,b:r})}},J.prototype._sendActions=function(n,t,e){if(this._addDoc(t),this.bulk){var o=this.bulk[t.collection]||(this.bulk[t.collection]={}),r=o[n]||(o[n]={}),i=r.hasOwnProperty(t.id);return r[t.id]=e,i}else{var s={a:n,c:t.collection,d:t.id,v:e};this.send(s)}},J.prototype.sendFetch=function(n){return this._sendActions(pt.fetch,n,n.version)},J.prototype.sendSubscribe=function(n){return this._sendActions(pt.subscribe,n,n.version)},J.prototype.sendUnsubscribe=function(n){return this._sendActions(pt.unsubscribe,n)},J.prototype.sendOp=function(n,t){this._addDoc(n);var e={a:pt.op,c:n.collection,d:n.id,v:n.version,src:t.src,seq:t.seq,x:{}};"op"in t&&(e.op=t.op),t.create&&(e.create=t.create),t.del&&(e.del=t.del),n.submitSource&&(e.x.source=t.source),this.send(e)},J.prototype.send=function(n){this.debug&&Ji.info("SEND",JSON.stringify(n)),this.emit("send",n),this.socket.send(JSON.stringify(n))},J.prototype.ping=function(){if(!this.canSend)throw new Or(Xi.ERR_CANNOT_PING_OFFLINE,"Socket must be CONNECTED to ping");var n={a:pt.pingPong};this.send(n)},J.prototype.close=function(){this.socket.close()},J.prototype.getExisting=function(n,t){if(this.collections[n])return this.collections[n][t]},J.prototype.get=function(n,t){var e=this.collections[n]||(this.collections[n]={}),o=e[t];return o||(o=e[t]=new nw(this,n,t),this.emit("doc",o)),o._wantsDestroy=!1,o},J.prototype._destroyDoc=function(n){!n._wantsDestroy||(on.digAndRemove(this.collections,n.collection,n.id),n.emit("destroy"))},J.prototype._addDoc=function(n){var t=this.collections[n.collection];t||(t=this.collections[n.collection]={}),t[n.id]!==n&&(t[n.id]=n)},J.prototype._createQuery=function(n,t,e,o,r){var i=this.nextQueryId++,s=new ow(n,this,i,t,e,o,r);return this.queries[i]=s,s.send(),s},J.prototype._destroyQuery=function(n){delete this.queries[n.id]},J.prototype.createFetchQuery=function(n,t,e,o){return this._createQuery(pt.queryFetch,n,t,e,o)},J.prototype.createSubscribeQuery=function(n,t,e,o){return this._createQuery(pt.querySubscribe,n,t,e,o)},J.prototype.hasPending=function(){return!!(this._firstDoc(Jl)||this._firstQuery(Jl)||this._firstSnapshotRequest())};function Jl(n){return n.hasPending()}J.prototype.hasWritePending=function(){return!!this._firstDoc(cw)};function cw(n){return n.hasWritePending()}J.prototype.whenNothingPending=function(n){var t=this._firstDoc(Jl);if(t){t.once("nothing pending",this._nothingPendingRetry(n));return}var e=this._firstQuery(Jl);if(e){e.once("ready",this._nothingPendingRetry(n));return}var o=this._firstSnapshotRequest();if(o){o.once("ready",this._nothingPendingRetry(n));return}on.nextTick(n)},J.prototype._nothingPendingRetry=function(n){var t=this;return function(){on.nextTick(function(){t.whenNothingPending(n)})}},J.prototype._firstDoc=function(n){for(var t in this.collections){var e=this.collections[t];for(var o in e){var r=e[o];if(n(r))return r}}},J.prototype._firstQuery=function(n){for(var t in this.queries){var e=this.queries[t];if(n(e))return e}},J.prototype._firstSnapshotRequest=function(){for(var n in this._snapshotRequests)return this._snapshotRequests[n]},J.prototype.fetchSnapshot=function(n,t,e,o){typeof e=="function"&&(o=e,e=null);var r=this.nextSnapshotRequestId++,i=new iw(this,r,n,t,e,o);this._snapshotRequests[i.requestId]=i,i.send()},J.prototype.fetchSnapshotByTimestamp=function(n,t,e,o){typeof e=="function"&&(o=e,e=null);var r=this.nextSnapshotRequestId++,i=new sw(this,r,n,t,e,o);this._snapshotRequests[i.requestId]=i,i.send()},J.prototype._handleSnapshotFetch=function(n,t){var e=this._snapshotRequests[t.id];!e||(delete this._snapshotRequests[t.id],e._handleResponse(n,t))},J.prototype._handleLegacyInit=function(n){if(n.protocolMinor)return this._initializeHandshake();this._initialize(n)},J.prototype._initializeHandshake=function(){this.send({a:pt.handshake,id:this.id})},J.prototype._handleHandshake=function(n,t){if(n)return this.emit("error",n);this._initialize(t)},J.prototype._handlePingPong=function(n){if(n)return this.emit("error",n);this.emit("pong")},J.prototype._initialize=function(n){if(this.state==="connecting"){if(n.protocol!==1)return this.emit("error",new Or(Xi.ERR_PROTOCOL_VERSION_NOT_SUPPORTED,"Unsupported protocol version: "+n.protocol));if(K0.map[n.type]!==K0.defaultType)return this.emit("error",new Or(Xi.ERR_DEFAULT_TYPE_MISMATCH,n.type+" does not match the server default type"));if(typeof n.id!="string")return this.emit("error",new Or(Xi.ERR_CLIENT_ID_BADLY_FORMED,"Client id must be a string"));this.id=n.id,this._setState("connected")}},J.prototype.getPresence=function(n){var t=this,e=on.digOrCreate(this._presences,n,function(){return new rw(t,n)});return e._wantsDestroy=!1,e},J.prototype.getDocPresence=function(n,t){var e=Y0.channel(n,t),o=this,r=on.digOrCreate(this._presences,e,function(){return new Y0(o,n,t)});return r._wantsDestroy=!1,r},J.prototype._sendPresenceAction=function(n,t,e){this._addPresence(e);var o={a:n,ch:e.channel,seq:t};return this.send(o),o.seq},J.prototype._addPresence=function(n){on.digOrCreate(this._presences,n.channel,function(){return n})},J.prototype._handlePresenceSubscribe=function(n,t){var e=on.dig(this._presences,t.ch);e&&e._handleSubscribe(n,t.seq)},J.prototype._handlePresenceUnsubscribe=function(n,t){var e=on.dig(this._presences,t.ch);e&&e._handleUnsubscribe(n,t.seq)},J.prototype._handlePresence=function(n,t){var e=on.dig(this._presences,t.ch);e&&e._receiveUpdate(n,t)},J.prototype._handlePresenceRequest=function(n,t){var e=on.dig(this._presences,t.ch);e&&e._broadcastAllLocalPresence(n,t)};var t5=lw,aw=Wi;const Xl={err:1001,msg:"user auth error",name:"AuthError"},dw={err:1002,msg:"you don't have required permission",name:"PermissionError"},Pd={err:1003,msg:"Too many user connected",name:"MaxUserError"},ts={err:1004,msg:"document server changed, reload it",name:"RequestReloadError"},uw={err:1005,msg:"app id must be at least 2 chars, doc id must be at least 5 chars",name:"DocIdError"},hw={err:1028,msg:"upload file ext not allowed",name:"FileExtError"},es="x-live-editor-token",tc="x-live-editor-base-url",ae=y("auth-connection");function fw(n){try{n()}catch(t){ae.error(t)}}class mw{constructor(t,e){h(this,"connection");h(this,"ws");h(this,"retryCount");h(this,"events",new Mf.EventEmitter);h(this,"token",null);h(this,"resourceToken",null);this.url=t,this.reAuthFunc=e,this.retryCount=0}getBaseURL(){const t=new URL(this.url);return`${t.protocol==="wss:"?"https:":"http:"}//${t.host}${t.pathname}`}getBase64BaseURL(){return Lo(this.getBaseURL())}async auth(t){d(ae,t.token,"no auth token");const e=`${this.getBaseURL()}/auth`,o=await window.fetch(e,{method:"GET",headers:{[es]:t.token,[tc]:this.getBase64BaseURL()},credentials:"include"});if(o.status!==200)throw new Error("http auth error");return this.token=t.token,await o.json()}async logout(){if(!this.token)return;const t=`${this.getBaseURL()}/logout`;await window.fetch(t,{method:"GET",headers:{[tc]:Lo(this.getBaseURL())}})}async init(t){const e=await this.auth(t);this.resourceToken=e.read,this.ws=new a8.default(this.url,void 0,{maxReconnectionDelay:2500,minReconnectionDelay:1e3}),this.connection=Object.create(t5.prototype),d(ae,this.connection,"no this.connection"),this.ws,this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:t})};const o=this.connection.handleMessage.bind(this.connection);this.connection.handleMessage=r=>{var s;const i=r;if(this.connection&&(this.connection.lastReceiveTime=Date.now()),"err"in i||i.a==="pong")this.handleMessage(i);else{Object.prototype.hasOwnProperty.call(i,"a")&&i.a!=="init"&&i.a!=="hs"&&(this.retryCount=0);try{o(i)}catch(l){if((l==null?void 0:l.type)==="writeConflict"){this.emitWriteConflictError(l);return}if((s=l==null?void 0:l.message)!=null&&s.startsWith("Cannot invert subtype")){this.emitWriteConflictError(l);return}throw l}}},t5.apply(this.connection,[this.ws])}async handleAuthError(){if(this.reAuthFunc&&this.retryCount<5){this.retryCount+=1,ae.info(`retrying re-auth attempt no. ${this.retryCount}`);try{if(this.connection){const t=await this.reAuthFunc();await this.auth(t),this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:t})}}}catch(t){ae.error(t),setTimeout(()=>this.handleAuthError(),0)}}else ae.error("auth error, cannot retry anymore"),this.emitAuthError(),this.end(!1)}emitAuthError(){const t=new Error(Xl.msg);t.code=Xl.err,this.events.emit("error",t)}emitRequestReloadError(){const t=new Error(ts.msg);t.code=ts.err,this.events.emit("requestReloadError",t)}emitWriteConflictError(t){this.events.emit("writeConflictError",t)}emitMaxUsersError(){this.events.emit("maxUsersError"),this.end(!1)}handleMessage(t){const e=t;if(e.a==="pong")return;const o=e.err;if(o===Xl.err)ae.warn("auth error"),this.handleAuthError();else if(o===Pd.err)ae.warn(Pd.msg),this.emitMaxUsersError();else if(o===ts.err){ae.warn(ts.msg);try{this.emitRequestReloadError()}catch(r){ae.error(`error occurred while process reload error: ${JSON.stringify(r)}`)}finally{this.end(!1)}}else ae.error(`unknown message received: ${JSON.stringify(e)}`),this.emitAuthError()}get(t,e){return d(ae,this.connection,"no this.connection"),this.connection.get(t,e)}addEventListener(t,e){t==="error"?this.events.addListener(t,e):(d(ae,this.ws,"no this.ws"),this.ws.addEventListener(t,e))}onWriteConflictError(t){this.events.addListener("writeConflictError",t)}onMaxUsersError(t){d(ae,this.events.listenerCount("maxUsersError")===0,"too many maxUserError listener"),this.events.addListener("maxUsersError",t)}onRequestReloadError(t){d(ae,this.events.listenerCount("requestReloadError")===0,"to many requestReloadError listener"),this.events.addListener("requestReloadError",t)}end(t){var e;this.reAuthFunc=void 0,this.events.removeAllListeners(),fw(()=>{var o;return(o=this.connection)==null?void 0:o.close()}),this.connection=void 0,(e=this.ws)==null||e.close(),this.ws=void 0,t&&this.logout()}}y("utils/file");function gw(){function n(){return new Promise(t=>{const e=new FileReader;e.onload=()=>{t(e.result)},e.readAsArrayBuffer(this)})}File.prototype.arrayBuffer=File.prototype.arrayBuffer||n,Blob.prototype.arrayBuffer=Blob.prototype.arrayBuffer||n}gw();async function pw(n){const e=n.size,o=Math.floor((e+102400-1)/102400),r=new d8.Hash;for(let s=0;s<o;s++){const l=s*102400;let c=l+102400;c>e&&(c=e);const u=await n.slice(l,c,n.type).arrayBuffer();r.update(new Uint8Array(u))}const i=r.digest();return Lo(i)}const vn=y("sharedb-doc/client");class Cw{constructor(t,e,o){h(this,"connection");h(this,"auth");h(this,"doc",null);h(this,"reAuthFunc");h(this,"clientId",N());h(this,"getDoc",async()=>{const t=o=>new Promise((r,i)=>{o.fetch(s=>{s?i(s):r()})});d(vn,!this.doc,"This websocket has opened a doc."),await this.connection.init(this.auth);const e=this.connection.get(this.auth.appId,this.auth.docId);return this.doc=e,await t(e),vn.debug(e),e});this.auth=t;const r=`${e}/${this.auth.appId}/${this.auth.docId}`;aw.register(Ys.type),this.connection=new mw(r,o),this.reAuthFunc=o}editorServer(){const t=this.apiServer(),e=`/${this.auth.appId}/${this.auth.docId}`;return d(vn,t.endsWith(e),`invalid api server: ${t}, ${e}`),t.substr(0,t.length-e.length)}close(t){this.connection.end(t),this.doc=null}on(t,e){this.connection.addEventListener(t,o=>{(t==="error"||this.doc)&&e(o)})}onWriteConflictError(t){this.connection.onWriteConflictError(t)}onMaxUsersError(t){this.connection.onMaxUsersError(t)}onRequestReloadError(t){this.connection.onRequestReloadError(t)}async authOnly(){await this.connection.auth(this.auth)}getResourceToken(){return this.connection.resourceToken}hasDocContainer(){return!!this.doc}apiServer(){const t=this.connection.url;if(t.startsWith("ws://"))return`http://${t.substring(5)}`;if(t.startsWith("wss://"))return`https://${t.substring(6)}`;throw new Error(`invalid server url: ${t}`)}async getFileUrlByHash(t,e,o,r,i){try{const s=`${t}/${e}`,l=await this.request(s,{method:"post",headers:{...i},data:{name:o,size:r}});return l.data&&Array.isArray(l.data)&&l.data.length===1?l.data[0]:""}catch{return""}}async getFileUrlsByHashes(t){const o=`${this.apiServer()}/resources`;let r=[];t.forEach(l=>{const c=l.split("|");r.push(...c)}),r=Array.from(new Set(r));const i=r.map(l=>this.getFileUrlByHash(o,l,"",0,{[es]:this.connection.token}));return await Promise.all(i)}async uploadFile(t,e,o,r,i){let s=e.size;if(s===0)throw new Error("file is empty");s+=500;const l=C=>{vn.info(`on progress: ${C.loaded}`);let v=C.loaded*100/s;v>100&&(v=100),r(v)},c=await pw(e),a=await this.getFileUrlByHash(t,c,e.name,e.size,o);if(a)return r(-1),a;let u=t;i!=null&&i.thumbnail&&(u+="/thumbnail");const f=new FormData;f.append("file-size",`${e.size}`),f.append("file-hash",c),f.append("file",e,e.name);const m=await this.request(u,{method:"post",data:f,withCredentials:!0,headers:{...o},onUploadProgress:l});return vn.info(m),r(100),Array.isArray(m.data)?m.data[0]:m.data}async uploadResource(t,e=()=>{},o){const i=`${this.apiServer()}/resources`;d(vn,this.connection.token,"no connection token");const s=await this.uploadFile(i,t,{[es]:this.connection.token},e,o);return d(vn,s,"no result"),s}async request(t,e){var i,s;let o=this.connection.token,r;for(let l=0;l<2;l++){const c=e||{};c.url=t,c.headers||(c.headers={}),d(vn,o,"no token"),c.headers={...c.headers,[es]:o,[tc]:this.connection.getBase64BaseURL()};try{return await l8.default(t,c)}catch(a){if(r=a,((i=a==null?void 0:a.response)==null?void 0:i.status)===403&&this.reAuthFunc){const u=await this.reAuthFunc();if(await this.connection.auth(u),!u.token)throw a;o=u.token;continue}throw(s=a.response)!=null&&s.data&&(a.responseData=a.response.data),a}}throw d(vn,r,"no error"),r}async getVersions(){const e=`${this.apiServer()}/versions`,o=await this.request(e),r=o.data.versions,i=o.data.latest;return i&&r.findIndex(s=>s.version===i)===-1&&r.unshift({version:-1,tag:"",published:!1}),r}async getVersion(t){const o=`${this.apiServer()}/versions/${t}`,r=await this.request(o);return JSON.parse(r.data.data)}async getLatestVersion(){const e=`${this.apiServer()}/versions/latest`,o=await this.request(e);return JSON.parse(o.data.data)}async getVersionOps(t,e){let r=`${this.apiServer()}/versions/before/${t}?withOp=true`;e!==void 0&&e!==0&&(r+=`&from=${e}`);const i=await this.request(r),s=i.data.ops,l=c8.default(s,u=>!!u.create);let c=null;l!==-1&&(c=s[l],s.splice(0,l+1));let a;return c?(d(vn,c.create,"no createDoc.create"),a=c.create.data):a=JSON.parse(i.data.data),a.blocks||(a.blocks=[]),{doc:a,ops:i.data.ops}}async revertVersion(t){const o=`${this.apiServer()}/versions/revert/${t}`;await this.request(o,{method:"post",data:{}})}async createVersion(t,e){const r=`${this.apiServer()}/versions`;return(await this.request(r,{method:"post",data:{publish:e,tag:t}})).data}async recognizeLink(t){const o=`${this.apiServer()}/resources/external/${Lo(t)}`;return(await this.request(o)).data}buildResourceUrl(t,e){if(!t)return"";if(t.startsWith("https:")||t.startsWith("http:")||t.startsWith("file:")||t.startsWith("data:")||t.startsWith("blob:"))return t;let r=`${this.apiServer()}/resources/${encodeURIComponent(t)}`;const i=[];if(e!=null&&e.withToken&&i.push(`token=${this.getResourceToken()}`),e!=null&&e.downloadFileName&&i.push(`&fileName=${encodeURIComponent(e.downloadFileName)}`),i.length>0){const s=i.join("&");r+=`?${s}`}return r}}function bw(){return{blocks:[{id:N(),type:"text",text:[]}],comments:{},meta:{}}}const $d=y("block-ids");class vw{constructor(){h(this,"ids",new Map)}onInsertBlock(t){const e=Array.from(this.ids.keys()).sort((r,i)=>i-r);for(let r=0;r<e.length;r++){const i=e[r];if(i>=t){const s=this.ids.get(i);d($d,s!==void 0,"old id is not exists"),this.ids.delete(i),this.ids.set(i+1,s)}}const o=N();this.ids.set(t,o)}onDeleteBlock(t){this.ids.delete(t);const e=Array.from(this.ids.keys()).sort((o,r)=>o-r);for(let o=0;o<e.length;o++){const r=e[o];if(r>t){const i=this.ids.get(r);d($d,i!==void 0,"old id is not exists"),this.ids.delete(r),this.ids.set(r-1,i)}}}getId(t){let e=this.ids.get(t);return e||(e=N(),this.ids.set(t,e)),e}getById(t){return Array.from(this.ids.entries()).find(([,e])=>e===t)}}class kw{constructor(){h(this,"ids",new Map)}getContainerIds(t){let e=this.ids.get(t);return e||(e=new vw,this.ids.set(t,e)),e}onInsertBlock(t,e){this.getContainerIds(t).onInsertBlock(e)}onDeleteBlock(t,e){this.getContainerIds(t).onDeleteBlock(e)}getBlockId(t,e){return this.getContainerIds(t).getId(e)}getBlockIndexById(t){const e=Array.from(this.ids.entries());for(let o=0;o<e.length;o++){const r=e[o],i=r[1].getById(t);if(i)return{containerId:r[0],blockIndex:i[0]}}return d($d,!1,"fault error: failed to get block index"),{containerId:"error",blockIndex:-1}}}class e5{constructor(t=new Set,e=new Map){this.deletedKeys=t,this.insertedValues=e}insert(t,e){this.insertedValues.set(t,e)}delete(t){this.deletedKeys.add(t)}toDocBlockDelta(){const t={};return this.insertedValues.forEach((e,o)=>{t[o]=e}),{insert:t,delete:Array.from(this.deletedKeys)}}}const Nt=y("op-parser");function _r(n){return n==="blocks"?"root":n}class yw{constructor(t,e){h(this,"updatingBlockDataDeltaMap",new Map);h(this,"blockIds",new kw);this.handler=t,this.local=e}onDeleteBlock(t,e){const o=this.blockIds.getBlockId(t,e);this.blockIds.onDeleteBlock(t,e);const r=this.updatingBlockDataDeltaMap.get(o);r&&(Nt.debug(`ignore update object data before delete block: ${JSON.stringify(r)}`),this.updatingBlockDataDeltaMap.delete(o)),this.handler.onDeleteBlock(_r(t),e,this.local)}onInsertBlock(t,e,o){this.blockIds.onInsertBlock(t,e),this.handler.onInsertBlock(_r(t),e,o,this.local)}onUpdateBlockText(t,e,o){this.handler.onUpdateBlockText(_r(t),e,o,this.local)}onDeleteBlockData(t,e,o){const r=this.blockIds.getBlockId(t,e);let i=this.updatingBlockDataDeltaMap.get(r);i||(i=new e5,this.updatingBlockDataDeltaMap.set(r,i)),i.delete(o)}onInsertBlockData(t,e,o,r){const i=this.blockIds.getBlockId(t,e);let s=this.updatingBlockDataDeltaMap.get(i);s||(s=new e5,this.updatingBlockDataDeltaMap.set(i,s)),s.insert(o,r)}executeUpdateBlockDataActions(){Array.from(this.updatingBlockDataDeltaMap.entries()).forEach(([t,e])=>{const{containerId:o,blockIndex:r}=this.blockIds.getBlockIndexById(t);this.handler.onUpdateBlockData(_r(o),r,e.toDocBlockDelta(),this.local)})}}class n5{}class Hd{constructor(t){h(this,"key");this.key=t}}function ww(n,t,e){const o=t.concat(),r=o[0];if(typeof r!="number"||(o.shift(),o.length===1))return!1;const i=o[0];if(typeof i!="object"||!i.i||Object.keys(i).length!==1)return!1;for(let l=1;l<o.length;l++){const c=o[l];if(!Array.isArray(c)||c.length!==2||typeof c[0]!="string")return!1;const u=c[1];if(typeof u!="object"||u.i===void 0||Object.keys(u).length!==1)return!1}const s=i.i;d(Nt,s.id,"block id is required"),d(Nt,s.type,"block type is required");for(let l=1;l<o.length;l++){const c=o[l],a=c[0],u=c[1];s[a]=u.i}return e.onInsertBlock(n,r,s),!0}function jd(n,t,e,o){if(e==="upsert"&&ww(n,t,o))return;d(Nt,Array.isArray(t),`invalid block op: ${n}, ${JSON.stringify(t)}`);const r=t.concat(),i=r[0];r.shift();const s=[];for(;r.length>0;){const l=r[0];if(l==="text"){const c=r[1];if(d(Nt,typeof c=="object",`invalid block op: ${n}, ${JSON.stringify(t)}`),d(Nt,c.et==="rich-text",`invalid block op: ${n}, ${JSON.stringify(t)}`),r.splice(0,2),e==="upsert"){const u=c.e;o.onUpdateBlockText(n,i,u)}d(Nt,r.length===0,`invalid block ops.length !== 0, ${JSON.stringify(r)}`)}else if(Array.isArray(l)){d(Nt,l.length===2,`invalid block op: data.length !== 2, ${JSON.stringify(l)}`);const c=l[0];d(Nt,typeof c=="string",`invalid block op: key ${JSON.stringify(c)}`);const a=l[1];if(c==="text"){if(d(Nt,typeof a=="object",`invalid opData type, ${JSON.stringify(a)}`),a.i&&e==="upsert"&&o.onInsertBlockData(n,i,c,a.i),a.r&&e==="remove"&&o.onDeleteBlockData(n,i,c),a.et==="rich-text"&&e==="upsert"){const f=a.e;o.onUpdateBlockText(n,i,f)}}else e==="remove"&&a.r&&s.push(new Hd(c)),e==="upsert"&&a.i&&o.onInsertBlockData(n,i,c,a.i);r.shift()}else if(typeof l=="object"){const c=l;e==="remove"&&c.r&&s.push(new n5),e==="upsert"&&c.i&&o.onInsertBlock(n,i,c.i),r.shift()}else{d(Nt,typeof l=="string","data is not string"),d(Nt,l!=="text","data !== 'text'"),d(Nt,r.length===2,`invalid block op: ops.length !== 2, ${JSON.stringify(r)}`);const c=l,a=r[1];e==="remove"&&a.r&&s.push(new Hd(c)),e==="upsert"&&a.i&&o.onInsertBlockData(n,i,c,a.i),r.splice(0,2)}}s.reverse(),s.forEach(l=>{l instanceof n5?o.onDeleteBlock(n,i):l instanceof Hd?o.onDeleteBlockData(n,i,l.key):d(Nt,!1,`invalid action type: ${typeof l}, ${JSON.stringify(l)}`)})}function Bw(n,t,e,o){Nt.warn(`unsupported meta op, ${JSON.stringify(n)}`)}function Ew(n,t,e,o){const r=n[1],i=n[2];d(Nt,r,`invalid comment op, no commentId: ${JSON.stringify(n)}`),d(Nt,i,`invalid comment op, no actions: ${JSON.stringify(n)}`),typeof i=="string"?Nt.error(`unknown comment op, ${JSON.stringify(n)}`):i.i&&i.r?t==="upsert"&&o.onUpdateComment(r,e.local):i.i?t==="upsert"&&o.onCreateComment(r,e.local):i.r?t==="remove"&&o.onDeleteComment(r,e.local):Nt.error(`unknown comment op, ${JSON.stringify(n)}`)}function Fd(n,t,e,o){const r=n[0];if(Array.isArray(r)){r.forEach(l=>{Fd(l,t,e,o)});return}const i=r;if(d(Nt,typeof i=="string",`invalid container id: ${JSON.stringify(n)}`),i==="meta"){Bw(n);return}if(i==="comments"){Ew(n,t,e,o);return}const s=i;if(Array.isArray(n[1]))t==="remove"?n.slice(1).reverse().forEach(l=>{jd(s,l,t,e)}):n.slice(1).forEach(l=>{jd(s,l,t,e)});else if(typeof n[1]=="object"){const l=n[1];l.r&&t==="remove"&&o.onDeleteContainer(_r(s),e.local),l.i&&t==="upsert"&&o.onCreateContainer(_r(s),l.i,e.local)}else d(Nt,typeof n[1]=="number",`invalid ops[1], not a number: ${JSON.stringify(n)}`),jd(s,n.slice(1),t,e)}function o5(n,t,e){const o=new yw(t,e);for(let r=0;r<2;r++){const i=r===0?"remove":"upsert",s=Y.default(n),l=s[0];Array.isArray(l)?s.forEach(c=>{Fd(c,i,o,t)}):Fd(s,i,o,t)}o.executeUpdateBlockDataActions()}const Iw=y("sharedb-comments");function xw(n){if(n.doc)return Y.default(n.doc);const t=n.blocks;d(Iw,t,"no comment blocks");const e={blocks:{root:t},meta:{},comments:{}};return Object.entries(n).forEach(([o,r])=>{Array.isArray(r)&&(e.blocks[o]=r)}),Y.default(e)}function Sw(n){const{id:t,groupId:e,userId:o,displayName:r,avatarUrl:i,abstract:s,created:l,modified:c}=n;return{id:t,groupId:e,userId:o,displayName:r,avatarUrl:i,abstract:s,created:l,modified:c}}function r5(n,t){const e={...n,doc:t};return delete e.blocks,Y.default(e)}const Dt=y("sharedb-doc/doc-container"),i5="ot-json1";Ys.type.registerSubtype(dy.type),Ys.type.name=i5,Ys.type.invert=null;class ec extends ki{constructor(e,o){super();h(this,"doc");h(this,"client");h(this,"localPresence");h(this,"remoteCaretHandler",new cy);h(this,"batching",0);h(this,"status","clean");h(this,"handleNothingPending",()=>{this.setStatus("clean")});h(this,"handleCreate",()=>{this.callbacks.forEach(e=>{var o;return(o=e.onRequestReload)==null?void 0:o.call(e,"doc created")})});h(this,"handleDel",()=>{});h(this,"insertObject",async(e,o,r)=>{const i=[e,o,{i:r}];return this.submitOp(i)});h(this,"deleteObject",async(e,o)=>{const r=[e,o,{r:!0}];return this.submitOp(r)});h(this,"replaceObject",async(e,o,r)=>{const i=[e,o,{r:!0,i:r}];return this.submitOp(i)});h(this,"updateObject",async(e,o,r)=>{const i=this.data()[e][o],s=[e,o];return Object.entries(r).forEach(([l,c])=>{if(!Zs.default(i[l],c))if(i[l]===void 0){if(c!=null){const a={i:c};s.push([l,a])}}else if(c==null){const a={r:!0};s.push([l,a])}else{const a={r:!0,i:c};s.push([l,a])}}),Object.entries(i).forEach(([l,c])=>{if((r[l]===void 0||r[l]===null)&&c!==void 0){const a={r:!0};s.push([l,a])}}),s.length<=2?Promise.resolve():this.submitOp(s)});h(this,"broadcastMessage",async e=>{const o={type:"custom",data:e,clientId:this.client.clientId};this.localPresence&&this.localPresence.submit(o)});h(this,"data",()=>this.doc.data);h(this,"submitOp",async e=>new Promise((o,r)=>{this.setStatus("dirty"),this.doc.submitOp(e,{},i=>{i?(Dt.error(`invalid op, ${i.message}, ${JSON.stringify(e)}`),r(i)):o()}),d(Dt,this.doc.data,"no data after submit op, may be the submitted op is invalid")}));h(this,"createDoc",async e=>new Promise((o,r)=>{this.doc.create(e,i5,i=>{i?r(i):o()})}));h(this,"submitInsertChildContainer",async(e,o)=>{const r=[lo(e),{i:o}];return this.submitOp(r)});h(this,"submitDeleteChildContainer",async e=>{const o=[lo(e),{r:!0}];return this.submitOp(o)});h(this,"submitInsertBlock",async(e,o,r)=>{const i=[lo(e),o,{i:r}];return this.submitOp(i)});h(this,"submitDeleteBlock",async(e,o)=>{const r=[lo(e),o,{r:!0}];return this.submitOp(r)});h(this,"submitUpdateBlockData",async(e,o,r)=>{if(r.delete.length===0&&Object.keys(r.insert).length===0)return Promise.resolve();const i=[lo(e),o],s=new Set(r.delete);Object.entries(r.insert).forEach(([c,a])=>{if(s.has(c)){const u={r:!0,i:a};i.push([c,u])}});const l=new Set(Object.keys(r.insert));return r.delete.forEach(c=>{if(l.has(c))return;const a={r:!0};i.push([c,a])}),Object.entries(r.insert).forEach(([c,a])=>{if(s.has(c))return;const u={i:a};i.push([c,u])}),this.submitOp(i)});h(this,"submitUpdateRichText",async(e,o,r)=>{const i=[lo(e),o,"text",{e:r,et:"rich-text"}];return this.submitOp(i)});h(this,"handleOp",(e,o,r)=>{o5(e,this,!!o)});this.client=e,this.doc=o,this.doc.preventCompose=!0,this.registerCallback(this.remoteCaretHandler)}beginBatchUpdate(){return this.doc.preventCompose=!1,this.batching++,this.batching}endBatchUpdate(){return this.batching--,d(Dt,this.batching>=0,"invalid call beginBatchUpdate/endBatchUpdate"),this.batching===0&&(this.doc.preventCompose=!0),this.batching}static async load(e){try{const o=new Cw(e.auth,e.serverUrl,e.reAuthFunc),r=await o.getDoc(),i=new ec(o,r);if(r.type===null){if(e.autoCreateDoc===!1){const s=new Error("doc not exists");throw s.code="DocNotExists",s}await i.createDoc(e.templateData||bw())}return await i.initPresence(),await i.subscribe(),i.initEvents(),i}catch(o){throw Dt.error(o),Dt.error(`failed to load doc: ${JSON.stringify(o)}`),o}}setStatus(e){this.status!==e&&(this.status=e,this.callbacks.forEach(o=>{var r;return(r=o.onStatusChanged)==null?void 0:r.call(o,e)}))}initEvents(){this.doc.on("nothing pending",this.handleNothingPending),this.doc.on("create",this.handleCreate),this.doc.on("del",()=>this.handleDel)}clearEvents(){this.doc.off("nothing pending",this.handleNothingPending),this.doc.off("create",this.handleCreate),this.doc.off("del",()=>this.handleDel)}initPresence(){return new Promise((e,o)=>{if(this.localPresence)e();else{const r=this.doc.connection.getPresence(`${this.doc.collection}:${this.doc.id}`);r.on("receive",(i,s)=>{this.onCustomMessage(s)}),r.subscribe(i=>{i?o(i):(this.localPresence=r.create(N()),e())})}})}subscribe(){return new Promise((e,o)=>{this.doc.subscribe(r=>{r?o(r):(this.doc.on("op",this.handleOp),e())})})}toJSON(){return Vi(this.data())}getContainerBlocks(e){const o=this.data();d(Dt,o,"no doc data");const r=o[lo(e)];return d(Dt,r,`no container data: ${e}`),Y.default(r)}getBlockData(e,o){const r=lo(e),i=this.getContainerBlocks(r);d(Dt,i,`no container data: ${r}`);const s=i[o];return d(Dt,s,`no block data: ${o}`),s}localInsertBlock(e,o,r){return this.submitInsertBlock(e,o,r),this.getBlockData(e,o)}localDeleteBlock(e,o){const r=this.getBlockData(e,o);return this.submitDeleteBlock(e,o),r}localUpdateBlockText(e,o,r){const i=this.getBlockData(e,o);d(Dt,i.text,"no block text");const s=Y.default(i.text);this.submitUpdateRichText(e,o,r);const l=ne.apply(s,r);return d(Dt,l,"no block text"),l}localUpdateBlockData(e,o,r){const i=Y.default(this.getBlockData(e,o));return this.submitUpdateBlockData(e,o,r),i}localInsertChildContainer(e,o){this.submitInsertChildContainer(e,o)}localDeleteChildContainers(e){this.beginBatchUpdate(),e.forEach(o=>{this.submitDeleteChildContainer(o)}),this.endBatchUpdate()}getComments(){return Object.values(this.data().comments).map(o=>Sw(o))}getComment(e){return this.data().comments[e]}getCommentDoc(e){const o=this.data().comments[e];return xw(o)}localCreateComment(e,o){const r=r5(e,o),s=["comments",r.id,{i:r}];return this.submitOp(s)}localDeleteComment(e){const o=["comments",e,{r:!0}];return this.submitOp(o)}localUpdateComment(e,o){const r=r5(e,o),i=["comments",e.id,{r:!0,i:r}];return this.submitOp(i)}destroy(){var e;this.clearEvents(),this.clearCallbacks(),this.doc.destroy(),(e=this.localPresence)==null||e.destroy(),this.client.close(!1),this.remoteCaretHandler.destroy()}onDeleteBlock(e,o,r){d(Dt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var s;return(s=i.onDeleteBlock)==null?void 0:s.call(i,Rr(e),o,r)})}onInsertBlock(e,o,r,i){d(Dt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onInsertBlock)==null?void 0:l.call(s,Rr(e),o,r,i)})}onUpdateBlockData(e,o,r,i){d(Dt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,Rr(e),o,r,i)})}onUpdateBlockText(e,o,r,i){d(Dt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockText)==null?void 0:l.call(s,Rr(e),o,r,i)})}onDeleteContainer(e,o){d(Dt,this.callbacks.length>0,"no callbacks"),d(Dt,e!=="root","should not delete root container in doc"),this.callbacks.forEach(r=>{var i;return(i=r.onDeleteChildContainer)==null?void 0:i.call(r,Rr(e),o)})}onCreateContainer(e,o,r){d(Dt,this.callbacks.length>0,"no callbacks"),d(Dt,e!=="root","should not create root container in doc"),this.callbacks.forEach(i=>{var s;return(s=i.onInsertChildContainer)==null?void 0:s.call(i,Rr(e),o,r)})}onDeleteComment(e,o){d(Dt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onDeleteComment)==null?void 0:i.call(r,e,o)})}onCreateComment(e,o){d(Dt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onCreateComment)==null?void 0:i.call(r,e,o)})}onUpdateComment(e,o){d(Dt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onUpdateComment)==null?void 0:i.call(r,e,o)})}onCustomMessage(e){const o=e;(o==null?void 0:o.type)==="custom"&&(o==null?void 0:o.clientId)!==this.client.clientId?this.callbacks.forEach(r=>{var i;return(i=r.onCustomMessage)==null?void 0:i.call(r,o.data)}):(o==null?void 0:o.type)==="onlineUsers"&&setTimeout(()=>{const r={type:"custom",data:e,clientId:"-"};this.onCustomMessage(r)})}async addResources(e){return await this.client.getFileUrlsByHashes(e)}async uploadResource(e,o){var i;return{resourceId:await this.client.uploadResource(e,(i=o==null?void 0:o.onProgress)!=null?i:()=>{})}}buildResourceUrl(e,o){return this.client.buildResourceUrl(e,o)}request(e,o){return this.client.request(e,o)}getUser(){const e=this.client.clientId,{permission:o,userId:r,displayName:i,avatarUrl:s}=this.client.auth;return{permission:o,clientId:e,userId:r,displayName:i,avatarUrl:s,rainbowIndex:0}}getRemoteUsers(){return this.remoteCaretHandler.remoteUsers}getVersionHelper(){return this}getVersions(){return this.client.getVersions()}async getVersion(e){const o=await this.client.getVersion(e);return Vi(o)}async getLatestVersion(){const e=await this.client.getLatestVersion();return Vi(e)}async getHistoryData(e,o){const{doc:r,ops:i}=await this.client.getVersionOps(e,o),s=i.map(l=>({user:l.meta.createdBy,data:l}));return{doc:Vi(r),historyData:s}}async getVersionData(e,o){const{doc:r,ops:i}=await this.client.getVersionOps(e,o);return{doc:Vi(r),versionData:i}}revertVersion(e){return this.client.revertVersion(e)}createVersion(e,o){return this.client.createVersion(e,o)}async recognizeLink(e){return this.client.recognizeLink(e)}parseHistoryData(e,o){o5(e.data.op,o,!0)}getServerMeta(){return{appId:this.client.auth.appId,docId:this.client.auth.docId,serverId:this.client.apiServer()}}}y("remote-cursor");class s5{constructor(t){h(this,"handleDocSelectionChange",()=>{this.broadcastCaretPos()});h(this,"broadcastCaretPos",ie.default(()=>{const t={type:"caret",userId:this.editor.doc.getUser().userId,range:this.editor.selection.range.toDocRange()};this.editor.doc.broadcastMessage(t)},300));h(this,"handleRemoteCaretsChanged",t=>{t.forEach(e=>{const o=this.editor.findBlockById(e);o&&this.editor.reloadBlock(o)})});this.editor=t,this.editor.addListener("selectionChanged",this.handleDocSelectionChange),this.editor.doc.getRemoteUsers().addListener("remote-carets-change",this.handleRemoteCaretsChanged)}destroy(){this.editor.removeListener("selectionChanged",this.handleDocSelectionChange),this.editor.doc.getRemoteUsers().removeListener("remote-carets-change",this.handleRemoteCaretsChanged)}}const l5=y("remote-cursor-decorator");class zd{decorateText(t,e,o){const r=t.doc.getRemoteUsers();if(!r)return{};const i=new Map,{containerId:s,blockIndex:l}=e[e.length-1];d(l5,typeof s=="string","invalid path containerId"),d(l5,typeof l=="number","invalid path blockIndex");const c=t.doc.getBlockData(s,l),a=ce(o);return r.getSimpleCursors(c.id).forEach((f,m)=>{m>a&&(m=a);const C=f.map(w=>({id:N(),type:"remote-cursor",name:w.user.displayName,time:w.time,rainbowIndex:w.user.rainbowIndex})),v=i.get(m);v?v.push(...C):i.set(m,C)}),{insertions:i}}}class c5 extends Wt.TypedEmitter{constructor(t){super(),this.editor=t,this.editor.doc.registerCallback(this)}handleChild(t,e,o){if(Ct(br(this.editor,t)))return;const r=this.editor.getBlockByIndex(t,e),i=z(this.editor.getContainerById(t));i&&this.emit("change",this.editor,i,r,o)}onUpdateBlockData(t,e){this.handleChild(t,e,"data-change")}onUpdateBlockText(t,e){this.handleChild(t,e,"text-change")}destroy(){this.editor.doc.unregisterCallback(this)}}function Tw(n,t){n.addCustom("child-block-tracker",()=>new c5(n)).addListener("change",t)}function Dw(n,t){n.addCustom("child-block-tracker",()=>new c5(n)).removeListener("change",t)}const dF="",Lw={colorPalette:{colorDesc:"\u5B57\u4F53\u989C\u8272",backgroundDesc:"\u80CC\u666F\u989C\u8272",reset:"\u6062\u590D\u9ED8\u8BA4"},search:{emptyTips:"\u6682\u65E0\u641C\u7D22\u7ED3\u679C"}},Mw={colorPalette:{colorDesc:"Text Color",backgroundDesc:"Background Color",reset:"Reset"},search:{emptyTips:"\u6682\u65E0\u641C\u7D22\u7ED3\u679C"}};S.mergeLang({"zh-CN":Lw,"en-US":Mw});const uF="",Rw=y("button");function Aw(n){const t=n.getAttribute("data-button-id");return t||d(Rw,!1,"unknown button id"),t}function Ow(n){var e;if(!(n instanceof Node))return null;const t=n.parentElement;return t?n instanceof HTMLButtonElement&&n.classList.contains("editor-button")?n:(e=t.closest("button.editor-button"))!=null?e:null:null}function kn(n,t,e,o,r){const i=b("button",["editor-button"],null);return i.setAttribute("data-button-id",n),r&&i.setAttribute(`data-editor-tooltip-${r}`,t),e?typeof e=="string"?e.startsWith("<")?i.innerHTML=e:i.innerText=e:i.appendChild(e):i.innerText=t,o&&(o.indexOf("checked")!==-1&&M(i,"checked"),o.indexOf("disabled")!==-1&&(i.disabled=!0)),i}function Ud(n,t,e){e?n.setAttribute(`data-editor-tooltip-${e}`,t):n.innerText=t}function _w(n){return b("span",["editor-separator",n],null)}const uo=y("filterable-list");function Nw(n){var e;const t=b("div",["list-item"],null);return t.setAttribute("data-id",n.id),t.appendChild(b("div",["list-item-text"],null,n.name)),(e=n.states)!=null&&e.includes("selected")&&M(t,"selected"),t}function a5(n){const t=b("div",["list-root"],null);return n.forEach(e=>{t.appendChild(Nw(e))}),t}function d5(n,t){let e=n;return t&&(e=n.map(o=>({...o,states:o.id===t?["selected"]:void 0}))),e}function Pw(n,t){const e=b("div",["filterable-list"],null),o=b("div",["filter"],e),r=b("div",["filter-container"],o),i=b("input",["filter-input"],r);t&&t.placeholder&&(i.placeholder=t.placeholder);const s=b("div",["list"],e),l=a5(d5(n,t==null?void 0:t.initialSelectedId));return s.appendChild(l),e}function u5(n,t,e){const o=n.querySelector(".list");d(uo,o,"no list root");const r=a5(d5(t,e)),i=o.querySelector(".list-root");if(d(uo,i,"no exists menu"),xi(i,r),e){const s=o.querySelector(".list-item.selected");s&&(d(uo,s,"no selected menu item"),s.scrollIntoView({block:"nearest"}))}}class h5{constructor(t,e){h(this,"root");h(this,"visibleItems");h(this,"selectedId");h(this,"filter","");h(this,"onSelected",null);h(this,"handleKeydown",t=>{this.processKeyDown(t)});h(this,"handleInputChanged",()=>{const t=this.root.querySelector(".filter-input");d(uo,t,"no input");const e=t.value.toLocaleLowerCase();this.setFilter(e)});h(this,"handleClick",t=>{this.processClick(t)});var o;this.items=t,this.options=e,this.root=Pw(t,e),this.bindEvents(),this.selectedId=(o=e==null?void 0:e.initialSelectedId)!=null?o:"",this.visibleItems=t}bindEvents(){const t=this.root.querySelector(".filter-input");d(uo,t,"no input"),t.addEventListener("keyup",this.handleInputChanged),t.addEventListener("keydown",this.handleKeydown),this.root.addEventListener("click",this.handleClick)}unbindEvents(){const t=this.root.querySelector(".filter-input");d(uo,t,"no input"),t.removeEventListener("keyup",this.handleInputChanged),t.removeEventListener("keydown",this.handleKeydown),this.root.removeEventListener("click",this.handleClick)}destroy(){this.unbindEvents(),this.onSelected=null}getSelectedIndex(){return this.selectedId?this.visibleItems.findIndex(t=>t.id===this.selectedId):-1}setSelectedId(t){this.selectedId=t,u5(this.root,this.visibleItems,t)}focus(){const t=this.root.querySelector(".filter-input");d(uo,t,"no input"),t.focus()}reset(){this.setFilter("");const t=this.root.querySelector(".filter-input");d(uo,t,"no input"),t.value=""}setFilter(t){this.filter!==t&&(this.filter=t,this.visibleItems=this.items.filter(e=>e.name.toLocaleLowerCase().includes(t)),u5(this.root,this.visibleItems,this.selectedId))}processClick(t){var s,l;const e=t.target;if(!(e instanceof HTMLElement))return;const o=e.closest(".list-item");if(!o)return;const r=(s=o.getAttribute("data-id"))!=null?s:"",i=(l=this.visibleItems.find(c=>c.id===r))!=null?l:null;this.onSelected&&this.onSelected(this,i)}processKeyDown(t){var e;if(t.key==="ArrowUp"){let o=this.getSelectedIndex();o===-1?o=this.visibleItems.length-1:o>0&&(o-=1);let r="";o!==-1&&(r=this.visibleItems[o].id),this.setSelectedId(r);return}if(t.key==="ArrowDown"){let o=this.getSelectedIndex();o===-1?o=0:o<this.visibleItems.length-1&&(o+=1);let r="";o!==-1&&(r=this.visibleItems[o].id),this.setSelectedId(r);return}if(t.key==="Enter"){const o=(e=this.visibleItems.find(r=>r.id===this.selectedId))!=null?e:null;this.onSelected&&this.onSelected(this,o)}}}class f5 extends h5{constructor(e,o,r){super(e,r);h(this,"tippyInstance");h(this,"onShow",null);h(this,"onHide",null);h(this,"custom",null);h(this,"handleShow",()=>{this.onShow&&this.onShow(this)});h(this,"handleHide",()=>{this.onHide&&this.onHide(this)});h(this,"handleShown",()=>{this.focus()});this.tippyInstance=za.default(o,{interactive:!0,content:this.root,trigger:"manual",triggerTarget:null,hideOnClick:!0,arrow:!1,theme:"dropdown-list",offset:[0,0],onHide:this.handleHide,onShow:this.handleShow,onShown:this.handleShown})}destroy(){super.destroy(),this.onShow=null,this.onHide=null}show(e){this.tippyInstance.setProps({getReferenceClientRect:()=>e.getBoundingClientRect()}),this.reset(),this.tippyInstance.show(),this.focus()}processKeyDown(e){super.processKeyDown(e),(e.key==="Esc"||e.key==="Enter")&&this.tippyInstance.hide()}processClick(e){super.processClick(e);const o=e.target;!(o instanceof HTMLElement)||!o.closest(".list-item")||this.tippyInstance.hide()}}const hF="",fF="";function m5(n,t){const e=document.createElement("div");e.classList.add("toast","show"),t!=null&&t.theme&&e.setAttribute("data-theme",t.theme),t!=null&&t.id&&e.setAttribute("data-id",t.id),t!=null&&t.html?e.innerHTML=n:e.textContent=n,t!=null&&t.position&&(e.style.left=`${t.position.x}px`,e.style.top=`${t.position.y}px`,e.classList.add("positioned")),document.body.appendChild(e),setTimeout(()=>{e.classList.remove("show"),setTimeout(()=>{e.remove()},500)},(t==null?void 0:t.duration)||3e3)}const mF="",Nr=y("ui-command-bar-base"),$w={itemElementTag:"div",tippyArrow:!1},df=class extends Wt.TypedEmitter{constructor(e,o,r){var i,s;super();h(this,"content");h(this,"items");h(this,"subBar",null);h(this,"parentItem",null);h(this,"closeable",null);h(this,"options");h(this,"id");h(this,"handleDocumentKeydown",e=>{if(!!this.isVisible){if(this.subBar){this.subBar.handleDocumentKeydown(e);return}if(this.items.length!==0){if(e.key==="Escape"){this.close();return}if(e.key==="ArrowUp"){const o=this.getPrevItemIndex(this.getSelectedItemIndex());this.selectItem(this.items[o].id)}else if(e.key==="ArrowDown"){const o=this.getNextItemIndex(this.getSelectedItemIndex());this.selectItem(this.items[o].id)}else if(e.key==="ArrowRight"){const o=this.getSelectedItem();o&&o.children&&this.showSubCommandBar(o.childrenMenuId)}else if(e.key==="ArrowLeft")this.parentItem&&this.close();else if(e.key==="Enter"){const o=this.getSelectedItemIndex();if(o===-1)return;const r=this.items[o],i=this.getItemElementById(r.id);i&&this.emit("click",this,r,i)}}}});h(this,"handleDocumentMouseDown",e=>{e.target instanceof Element&&(this.isInCommandBar(e.target)||this.close())});h(this,"handleHidden",()=>{this.close(),this.emit("close",this),um(this.id)});h(this,"handleShow",()=>{this.popper&&(this.popper.setAttribute("data-command-bar-id",this.id),this.options.classes&&M(this.popper,...this.options.classes)),this.emit("show",this),this.options.disablePageScroll&&dm(this.id)});h(this,"handleItemMouseEnter",e=>{const o=this.getParentCommandItemElement(e.target);if(!o)return;const r=this.getItemElementId(o),i=this.getItemById(r);if(this.selectItem(r),i.manualShowChildren)return;const s=i.childrenMenuId||"";this.showSubCommandBar(s)});h(this,"handleItemMouseLeave",e=>{var r,i;const o=this.getParentCommandItemElement(e.target);!o||((i=(r=this.subBar)==null?void 0:r.parentItem)==null?void 0:i.id)!==this.getItemElementId(o)&&(F(o,"selected"),this.emit("selectionChange",this,""))});h(this,"handleItemClick",e=>{const o=this.getParentCommandItemElement(e.target);if(!o)return;const r=this.getItemElementId(o),i=this.items.find(s=>s.id===r);if(!!i&&!(i.states&&i.states.indexOf("disabled")!==-1)){if(i.children&&i.children.length>0&&i.manualShowChildren){this.showSubCommandBar(i.childrenMenuId);return}i.element||(this.emit("click",this,i,o),this.options.autoClose&&this.close())}});h(this,"handleWheel",e=>{if(!this.options.disablePageScroll&&!document.querySelector(".editor-disable-scroll"))return;const o=e.target;if(!o||!(o instanceof Node))return;const r=o instanceof HTMLElement?o:o.parentElement;if(!r)return;const i=Nn(r);if(!vt(this.content,i)){e.stopPropagation(),e.preventDefault();return}e.deltaY<0?i.scrollTop===0&&(e.stopPropagation(),e.preventDefault()):e.deltaY>0&&i.scrollTop+i.clientHeight>=i.scrollHeight&&(e.stopPropagation(),e.preventDefault())});this.id=(i=r==null?void 0:r.id)!=null?i:N(),this.options={...$w,...r},this.items=e,this.parentItem=(s=r==null?void 0:r.parentItem)!=null?s:null,this.closeable=o!=null?o:null,this.content=this.createCommandBarContent(e)}close(){this.subBar&&this.subBar.close(),document.removeEventListener("keydown",this.handleDocumentKeydown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}click(e,o){this.emit("click",this,e,o)}destroy(){var e;this.close(),this.removeAllListeners(),(e=this.subBar)==null||e.destroy(),this.subBar=null,this.closeable=null,this.content.removeEventListener("wheel",this.handleWheel)}get isSubCommandBar(){return!!this.parentItem}updateItems(e){var r;this.subBar&&e.findIndex(s=>{var l,c;return s.id===((c=(l=this.subBar)==null?void 0:l.parentItem)==null?void 0:c.id)})===-1&&((r=this.subBar)==null||r.destroy(),this.subBar=null),this.items=e;const o=this.createCommandBarContent(e);this.content.innerHTML="",Array.from(o.children).forEach(i=>{this.content.appendChild(i)})}get popper(){return this.content.closest("[data-tippy-root]")}getSelectedItemIndex(){const e=this.getSelectedItem();return e?this.items.indexOf(e):-1}getPrevItemIndex(e){if(e<=0)return this.items.length-1;let o=e-1;for(;;){const r=this.items[o].type;if(r!=="separator"&&r!=="section")return o;if(o-=1,o<=0)return this.items.length-1}}getNextItemIndex(e){let o=e+1;for(;;){if(!this.items[o])return this.getNextItemIndex(-1);const r=this.items[o].type;if(r!=="separator"&&r!=="section")return o;if(o+=1,o>this.items.length-1)return 0}}clearSelectedItem(){const e=this.getSelectedItem();if(!e)return;const o=this.getItemElementById(e.id);o&&F(o,"selected")}selectItem(e){const o=this.getSelectedItem();if(o){if(o.id===e)return;const i=o.id,s=this.getItemElementById(i);s&&F(s,"selected")}const r=this.getItemElementById(e);r?(M(r,"selected"),this.emit("selectionChange",this,r.getAttribute("data-id")||""),r.scrollIntoView({block:"nearest"})):this.emit("selectionChange",this,"")}showSubCommandBar(e){var s,l;const o=this.getSelectedItem();if(!o)return;if(this.subBar){if(((s=this.subBar.parentItem)==null?void 0:s.id)===o.id){o.manualShowChildren&&this.subBar.close();return}this.subBar.destroy(),this.subBar=null}if(!o.children)return;const r=this.getItemElementById(o.id);if(!r)return;const i=df.createSubCommandBar(o,(l=this.closeable)!=null?l:this,e?{id:e}:{});this.subBar=i,this.subBar.on("click",(c,a,u)=>{this.emit("click",c,a,u)}),this.subBar.on("close",()=>{var c;(c=this.subBar)==null||c.destroy(),this.subBar=null,F(r,"active")}),o.beforePopup&&o.beforePopup(i),this.subBar.manualShow(r,this.getSubBarOptions(o)),M(r,"active")}isInCommandBar(e){if(!e||!(e instanceof Node))return!1;const o=this.getCommandBarRoot();return o&&vt(o,e)||vt(this.content,e)?!0:this.subBar?this.subBar.isInCommandBar(e):!1}createCommandItem(e){var i,s,l,c;let o=(i=this.options.itemElementTag)!=null?i:"div";e.element&&(o="div");const r=b(o,["command-item"],null);return r.setAttribute("data-id",e.id),e.type==="separator"?r.classList.add("separator"):e.type==="section"?r.classList.add("section","text"):((s=e.states)!=null&&s.includes("selected")&&r.classList.add("selected"),(l=e.states)!=null&&l.includes("checked")&&r.classList.add("checked"),(c=e.states)!=null&&c.includes("disabled")&&r.classList.add("disabled"),r.onclick=this.handleItemClick,r.onmouseenter=this.handleItemMouseEnter,r.onmouseleave=this.handleItemMouseLeave,e.element?typeof e.element=="function"?r.appendChild(e.element(e)):r.appendChild(e.element):r.classList.add("standard")),this.initItemElement(e,r),r}getItemById(e){const o=this.items.find(r=>r.id===e);return d(Nr,o,`can not find command item for id: ${e}`),o}getSelectedItem(){const e=this.content.querySelector(":scope >.editor-command-bar >.command-item.selected");if(e){const o=this.getItemElementId(e),r=this.items.find(i=>i.id===o);return d(Nr,r,`can not find command item for id: ${o}`),r}return null}getItemElementId(e){const o=e.getAttribute("data-id");return d(Nr,o,"no data-id attribute"),o}getItemElementById(e){const o=this.content.querySelector(`:scope >.editor-command-bar > .command-item[data-id="${e}"]`);return d(Nr,o,`no exists command item, id=${e}`),o}getParentCommandItemElement(e){if(!e||!(e instanceof Element))return null;if(lt(e,"command-item"))return e;const o=e.closest(".command-item");return o||null}createCommandBarContent(e){const o=b("div",["editor-command-bar-root"],null),r=b("div",["editor-command-bar"],o);return e.forEach(i=>{var l;const s=this.createCommandItem(i);r.appendChild(s),i.element&&i.setCloseable&&i.setCloseable((l=this.closeable)!=null?l:this)}),this.initCommandBarElement(r),o.addEventListener("wheel",this.handleWheel),o}getSubBarOptions(e){var o;return{placement:(o=e.childrenPlacement)!=null?o:"right-start"}}static registerManualCommandBar(e,o){this.commandBarCreators.set(e,o)}static createSubCommandBar(e,o,r){var l;d(Nr,e.children&&e.children.length>0,"no item children");const i=(l=e.childrenType)!=null?l:"menu",s=this.commandBarCreators.get(i);return d(Nr,s,`no creator for command type: ${i}`),s(e,o,r)}static hasExistsCommandBar(){return!!document.querySelector("[data-command-bar-id]")}};let ho=df;h(ho,"commandBarCreators",new Map),y("ui-command-bar");class nc extends ho{constructor(){super(...arguments);h(this,"tippyInstance",null)}manualShow(e,o){var r,i;if(!this.isVisible){if(this.tippyInstance&&(this.tippyInstance.destroy(),this.tippyInstance=null),this.tippyInstance=za.default(e,{interactive:!0,content:this.content,trigger:"manual",triggerTarget:null,hideOnClick:!1,placement:(r=o==null?void 0:o.placement)!=null?r:"bottom-start",maxWidth:650,arrow:this.options.tippyArrow,appendTo:document.body,onShow:this.handleShow,onHidden:this.handleHidden,theme:o==null?void 0:o.theme,getReferenceClientRect:o==null?void 0:o.getReferenceClientRect,offset:(i=o==null?void 0:o.offset)!=null?i:[0,0]}),o!=null&&o.point){const{x:s,y:l}=o.point;this.tippyInstance.setProps({getReferenceClientRect:()=>new DOMRect(s,l,0,0)})}this.clearSelectedItem(),this.tippyInstance.show(),this.parentItem||(document.addEventListener("keydown",this.handleDocumentKeydown),document.addEventListener("mousedown",this.handleDocumentMouseDown)),this.popper&&this.options.id&&this.popper.setAttribute("data-command-bar-id",this.options.id)}}close(){var e;super.close(),this.isVisible&&((e=this.tippyInstance)==null||e.hide())}destroy(){var e;(e=this.tippyInstance)==null||e.destroy(),this.tippyInstance=null,super.destroy()}getCommandBarRoot(){return this.content.closest("[data-tippy-root]")}get isVisible(){var e,o;return(o=(e=this.tippyInstance)==null?void 0:e.state.isVisible)!=null?o:!1}get popper(){return this.content.closest("[data-tippy-root]")}}function Hw(){const n={};for(let t=1;t<=8;t++)n[`heading-${t}`]={shortcut:`/h${t}`};return n}const g5={"insert-hr":{shortcut:"/hr"},"insert-uml":{shortcut:"/uml"},"insert-table":{shortcut:"/table"},"insert-image":{shortcut:"/image"},"insert-code":{shortcut:"/code"},"insert-link":{shortcut:"/link"},"insert-drawio":{shortcut:"/uml"},"insert-video":{shortcut:"/video"},"insert-audio":{shortcut:"/audio"},"insert-math":{shortcut:"/math"},"insert-webPage":{shortcut:"/web"},"insert-bilibili":{shortcut:"/bilibili"},"insert-youku":{shortcut:"/youku"},"insert-figma":{shortcut:"/figma"},"insert-modao":{shortcut:"/modao"},"insert-tencent":{shortcut:"/tencent"},"insert-unordered":{shortcut:"/bl"},"insert-ordered":{shortcut:"/nu"},"insert-checkbox":{shortcut:"/todo"},"insert-quote":{shortcut:"/quote"},...Hw()};function Vd(n){var t,e,o;return(o=(e=n.shortcut)!=null?e:(t=g5[n.id])==null?void 0:t.shortcut)!=null?o:""}function jw(n){var t,e;return(e=(t=g5[n.id])==null?void 0:t.markdown)!=null?e:""}const qd=`<?xml version="1.0" ?>
27
27
  <svg
28
28
  fill="currentColor"
29
29
  xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
@@ -53,7 +53,7 @@ xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
53
53
  <path d="M0 0h24v24H0z" fill="none"/><path d="M10 6L8.59 7.41 13.17 12l-4.58 4.59L10 18l6-6z"/>
54
54
  </svg>`,Yd=`<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
55
55
  <path d="M3,6 L19,6 L19,11 L3,11 L3,6 Z M19.4077072,12.4579597 L20.5390781,13.5893306 L18.6313708,15.4957574 L20.5420403,17.4077072 L19.4106694,18.5390781 L17.5,16.6271282 L15.5893306,18.5390781 L14.4579597,17.4077072 L16.3686292,15.4957574 L14.4609219,13.5893306 L15.5922928,12.4579597 L17.5,14.3643865 L19.4077072,12.4579597 Z M13,13 L13,18 L3,18 L3,13 L13,13 Z M12,14 L4,14 L4,17 L12,17 L12,14 Z M18,7 L18,10 L4,10 L4,7 L18,7 Z"></path>
56
- </svg>`,Vw=`<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
56
+ </svg>`,Uw=`<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
57
57
  <path d="M6,3 L11,3 L11,19 L6,19 L6,3 Z M17.4077072,14.466172 L18.5390781,15.5975429 L16.6313708,17.5039696 L18.5420403,19.4159195 L17.4106694,20.5472903 L15.5,18.6353405 L13.5893306,20.5472903 L12.4579597,19.4159195 L14.3686292,17.5039696 L12.4609219,15.5975429 L13.5922928,14.466172 L15.5,16.3725988 L17.4077072,14.466172 Z M10,4 L10,18 L7,18 L7,4 L10,4 Z M18,3.00821228 L18,13.0082123 L13,13.0082123 L13,3.00821228 L18,3.00821228 Z M17,4.00821228 L14,4.00821228 L14,12.0082123 L17,12.0082123 L17,4.00821228 Z"></path>
58
58
  </svg>`,b5=`<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
59
59
  <g>
@@ -95,7 +95,7 @@ xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
95
95
  `,ou=`<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
96
96
  <path fill-rule="evenodd" clip-rule="evenodd" d="M5.75 6C5.33579 6 5 6.33579 5 6.75V17.25C5 17.6642 5.33579 18 5.75 18C6.16421 18 6.5 17.6642 6.5 17.25V12.6333H11.2222V17.25C11.2222 17.6642 11.558 18 11.9722 18C12.3864 18 12.7222 17.6642 12.7222 17.25V6.75C12.7222 6.33579 12.3864 6 11.9722 6C11.558 6 11.2222 6.33579 11.2222 6.75V11.1333H6.5V6.75C6.5 6.33579 6.16421 6 5.75 6ZM14.8299 17.2994C15.3904 17.7665 16.1198 18 17.018 18C17.9377 18 18.6778 17.7665 19.2383 17.2994C19.806 16.8251 20.0898 16.2072 20.0898 15.4455C20.0898 14.9138 19.9353 14.4503 19.6263 14.0551C19.3174 13.6527 18.8826 13.3976 18.3222 13.2898V13.2251C18.7892 13.0958 19.1485 12.8587 19.4 12.5138C19.6515 12.1689 19.7772 11.7629 19.7772 11.2958C19.7772 10.6275 19.5222 10.0778 19.012 9.64671C18.5018 9.21557 17.8443 9 17.0395 9C16.2347 9 15.5772 9.21557 15.0671 9.64671C14.5641 10.0778 14.3126 10.6275 14.3126 11.2958C14.3126 11.7629 14.4347 12.1689 14.679 12.5138C14.9234 12.8515 15.2826 13.0886 15.7569 13.2251V13.2898C15.2036 13.3976 14.7725 13.6527 14.4635 14.0551C14.1545 14.4503 14 14.9138 14 15.4455C14 16.2144 14.2766 16.8323 14.8299 17.2994ZM18.2144 16.4263C17.9054 16.7066 17.5174 16.8467 17.0503 16.8467C16.5832 16.8467 16.1952 16.7066 15.8862 16.4263C15.5844 16.1461 15.4335 15.7868 15.4335 15.3485C15.4335 14.9246 15.5844 14.5725 15.8862 14.2922C16.1952 14.0048 16.5832 13.8611 17.0503 13.8611C17.5317 13.8611 17.9234 14.0012 18.2252 14.2814C18.5269 14.5617 18.6778 14.9174 18.6778 15.3485C18.6778 15.7868 18.5234 16.1461 18.2144 16.4263ZM17.988 12.3952C17.7437 12.6467 17.4275 12.7725 17.0395 12.7725C16.6515 12.7725 16.3353 12.6467 16.091 12.3952C15.8467 12.1437 15.7246 11.8275 15.7246 11.4467C15.7246 11.0731 15.8467 10.7677 16.091 10.5305C16.3353 10.2862 16.6515 10.1641 17.0395 10.1641C17.4275 10.1641 17.7437 10.2862 17.988 10.5305C18.2395 10.7677 18.3653 11.0731 18.3653 11.4467C18.3653 11.8275 18.2395 12.1437 17.988 12.3952Z"/>
97
97
  </svg>
98
- `,Uw=`<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
98
+ `,Vw=`<svg width="24" height="24" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
99
99
  <path fill-rule="evenodd" clip-rule="evenodd" d="M5.75 6C5.33579 6 5 6.33579 5 6.75V17.25C5 17.6642 5.33579 18 5.75 18C6.16421 18 6.5 17.6642 6.5 17.25V12.6333H11.2222V17.25C11.2222 17.6642 11.558 18 11.9722 18C12.3864 18 12.7222 17.6642 12.7222 17.25V6.75C12.7222 6.33579 12.3864 6 11.9722 6C11.558 6 11.2222 6.33579 11.2222 6.75V11.1333H6.5V6.75C6.5 6.33579 6.16421 6 5.75 6ZM14.7286 18C14.9389 18 15.1229 17.9211 15.254 17.7815C15.3847 17.6424 15.4572 17.4488 15.4572 17.2279V13.3327C15.4572 12.714 15.6451 12.2098 15.968 11.8612C16.2903 11.5134 16.7547 11.3122 17.3254 11.3122C17.8869 11.3122 18.2904 11.4731 18.555 11.766C18.8213 12.0607 18.9615 12.5049 18.9615 13.1006V17.2279C18.9615 17.4488 19.034 17.6424 19.1647 17.7815C19.2958 17.9211 19.4798 18 19.6901 18C19.9004 18 20.0844 17.9211 20.2155 17.7815C20.3461 17.6424 20.4187 17.4488 20.4187 17.2279V12.8757C20.4187 12.0021 20.1742 11.2814 19.7072 10.7783C19.2392 10.2742 18.5585 10 17.7099 10C16.6377 10 15.853 10.4302 15.3847 11.1253V10.7359C15.3847 10.5259 15.3158 10.3414 15.1916 10.2086C15.0669 10.0754 14.8919 10 14.6924 10C14.4928 10 14.3178 10.0754 14.1931 10.2086C14.0689 10.3414 14 10.5259 14 10.7359V17.2279C14 17.4488 14.0726 17.6424 14.2032 17.7815C14.3343 17.9211 14.5184 18 14.7286 18Z"/>
100
100
  </svg>
101
101
  `,y5=`<svg width="16" height="16" viewBox="0 0 16 16" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
@@ -270,7 +270,7 @@ xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
270
270
  <rect x="1.5" y="2.5" width="13" height="11" stroke="#606060"/>
271
271
  <path d="M9.75115 7.50077C10.1074 7.73826 10.1074 8.26174 9.75115 8.49923L7.68282 9.87812C7.28409 10.1439 6.75 9.85811 6.75 9.37889L6.75 6.62111C6.75 6.14189 7.28409 5.85606 7.68282 6.12188L9.75115 7.50077Z" fill="#606060"/>
272
272
  </svg>
273
- `,V5=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
273
+ `,U5=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
274
274
  <rect x="9" y="6" width="6" height="3" stroke="#606060"/>
275
275
  <rect x="4" y="6" width="3" height="3" transform="rotate(45 4 6)" stroke="#606060"/>
276
276
  <rect x="9" y="12" width="6" height="3" stroke="#606060"/>
@@ -280,7 +280,7 @@ xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
280
280
  <path d="M4 7L4 4" stroke="#606060"/>
281
281
  <rect x="2.5" y="1" width="3" height="3" rx="1.5" stroke="#606060"/>
282
282
  </svg>
283
- `,U5=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
283
+ `,V5=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
284
284
  <line x1="1" y1="1.5" x2="15" y2="1.5" stroke="#606060"/>
285
285
  <line x1="1" y1="13.5" x2="15" y2="13.5" stroke="#606060"/>
286
286
  <line x1="1" y1="7.5" x2="5" y2="7.5" stroke="#606060"/>
@@ -412,14 +412,14 @@ xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
412
412
  <path d="M5.27137 5.61819C6.60787 5.61819 7.69131 4.53475 7.69131 3.19825C7.69131 1.86176 6.60787 0.77832 5.27137 0.77832C3.93488 0.77832 2.85144 1.86176 2.85144 3.19825C2.85144 4.53475 3.93488 5.61819 5.27137 5.61819Z" stroke="#999999" stroke-linejoin="round" fill="none"/>
413
413
  <path d="M9.07413 10.8036H13.2226M11.1484 8.91895V13.1009V8.91895Z" stroke="#999999" stroke-linecap="square" fill="none"/>
414
414
  <path d="M8.03712 8.38281H5.20234C3.65344 8.38281 2.87899 8.38281 2.28739 8.68423C1.76699 8.94939 1.3439 9.3725 1.07875 9.89289C0.777313 10.4845 0.777313 11.2589 0.777313 12.8078V13.2227H8.03712" stroke="#999999" stroke-linecap="square" stroke-linejoin="round" fill="none"/>
415
- </svg>`;function rp(n,t){var e;if(M(t,"menu-item"),!n.element){if(n.type==="section"){const o=b("div",["section-name"],null,n.name);t.appendChild(o)}else if(n.type!=="separator"){if(n.icon){const i=b("div",["menu-item-icon"],null);n.icon&&(i.innerHTML=n.icon),t.appendChild(i)}const o=b("div",["menu-item-name"],null,n.name);t.appendChild(o);const r=Ud(n);if(r&&b("div",["item-shortcut","text"],t,r),n.children&&!n.element){const i=b("div",["menu-item-sub-indicator"],null);i.innerHTML=Zd,t.appendChild(i)}if((e=n.states)!=null&&e.includes("checked")){const i=b("div",["menu-item-checked-icon"],null);i.innerHTML=O5,t.appendChild(i)}}}}class Wo extends nc{constructor(t,e,o){super(t,e,{autoClose:!0,disablePageScroll:!0,...o})}manualShow(t,e){const o={theme:"menu",...e};super.manualShow(t,o)}initCommandBarElement(t){M(t,"menu")}initItemElement(t,e){rp(t,e)}}function lB(n,t,e){var o;return new Wo((o=n.children)!=null?o:[],t,{...e,parentItem:n})}class os extends nc{constructor(t,e,o){super(t,e,{itemElementTag:"button",tippyArrow:!1,...o})}getSubBarOptions(t){var r,i;const e=()=>{const s=this.getItemElementById(t.id),c=this.content.getBoundingClientRect(),a=s.getBoundingClientRect();return new DOMRect(a.left,c.top,a.width,c.height)};return{placement:(r=t.childrenPlacement)!=null?r:"top",getReferenceClientRect:e,offset:(i=t.childrenOffset)!=null?i:[0,4]}}manualShow(t,e){const o={theme:"toolbar",...e};super.manualShow(t,o)}initCommandBarElement(t){M(t,"toolbar")}initItemElement(t,e){e.setAttribute("data-button-id",t.id),(!t.children||t.children.length===0)&&this.options.tooltipId&&(e.setAttribute(`data-editor-tooltip-${this.options.tooltipId}`,t.name),t.desc&&e.setAttribute(`data-editor-tooltip-desc-${this.options.tooltipId}`,t.desc));const o=e;if(!t.element)if(t.icon){const r=b("span",["toolbar-item-icon-container"],o);t.icon.startsWith("<")?r.innerHTML=t.icon:r.innerText=t.icon}else{const r=b("span",["toolbar-item-name-container"],o);r.innerText=t.name}if(t.dropdown){e.setAttribute("data-dropdown","true");const r=b("span",["toolbar-item-dropdown-container"],o);r.innerHTML=oc}t.states&&(t.states.indexOf("checked")!==-1&&M(o,"checked"),t.states.indexOf("disabled")!==-1&&(o.disabled=!0))}}function cB(n,t,e){var o;return new os((o=n.children)!=null?o:[],t,{...e,parentItem:n})}class aB extends ho{constructor(){super(...arguments);h(this,"tippyInstance",null)}create(e,o){var r;if(this.tippyInstance&&(this.tippyInstance.destroy(),this.tippyInstance=null),this.tippyInstance=za.default(e,{interactive:!0,content:this.content,hideOnClick:!1,placement:(r=o==null?void 0:o.placement)!=null?r:"bottom-start",maxWidth:500,arrow:this.options.tippyArrow,appendTo:document.body,onShow:this.handleShow,onHidden:this.handleHidden,delay:o==null?void 0:o.delay}),o!=null&&o.point){const{x:i,y:s}=o.point;this.tippyInstance.setProps({getReferenceClientRect:()=>new DOMRect(i,s,0,0)})}this.parentItem||(document.addEventListener("keydown",this.handleDocumentKeydown),document.addEventListener("mousedown",this.handleDocumentMouseDown))}close(){var e;super.close(),this.isVisible&&((e=this.tippyInstance)==null||e.hide())}destroy(){var e;(e=this.tippyInstance)==null||e.destroy(),this.tippyInstance=null,super.destroy()}getCommandBarRoot(){return this.content.closest("[data-tippy-root]")}get isVisible(){var e,o;return(o=(e=this.tippyInstance)==null?void 0:e.state.isVisible)!=null?o:!1}}class dB extends aB{constructor(t,e,o){super(t,e,{autoClose:!0,disablePageScroll:!0,...o})}initCommandBarElement(t){M(t,"menu")}initItemElement(t,e){rp(t,e)}}const gF="";ho.registerManualCommandBar("menu",lB),ho.registerManualCommandBar("toolbar",cB);const ip=y("ui-base");class lc extends nc{constructor(t,e){var i;const r=[{id:(i=e==null?void 0:e.id)!=null?i:`popup-${N()}`,name:"",element:t}];super(r)}initCommandBarElement(t){M(t,"popper")}initItemElement(t,e){}get popupContent(){const t=this.items[0];d(ip,t,"no dialog item");const e=typeof t.element=="function"?t.element(t):t.element;return d(ip,e,"no item element"),e}}const pF="",sp=y("ui-base");class rs extends nc{constructor(e,o){super(rs.getCommandItems(e,o),void 0,{disablePageScroll:!0,...o});h(this,"handleDocumentMouseDown",e=>{})}initCommandBarElement(e){M(e,"dialog","manual")}initItemElement(e,o){}show(e,o){this.manualShow(e,{...o,theme:"light"})}get dialogContent(){const e=this.items[0];d(sp,e,"no dialog item");const o=e.element;return d(sp,o,"no item element"),o}static getCommandItems(e,o){var s;return[{id:(s=o==null?void 0:o.id)!=null?s:`manual-dialog-${N()}`,name:"",element:e}]}}const uB=[-1,6,0,1,2,3,4,5],hB=[-1,6,0,1,2,3,4,5,14,13,7,8,9,10,11,12],lp=y("color-palette");function cp(n,t,e,o){d(lp,n>0,"no color in palette");const r=t||1;d(lp,r>0,`invalid palette rows: ${r}`);const i=n/r,s=b("div",["palette-container",o],null);for(let l=0;l<r;l++){const c=b("div",["palette-container-row"],s);for(let a=0;a<i;a++){const u=e(l*i+a);c.appendChild(u)}}return s}function fB(n){const t=b("button",["color-button"],null),e=uB[n];return t.setAttribute("data-color-index",`${e}`),t.innerHTML=Gd,t}function mB(n){const t=b("button",["background-color-button"],null),e=hB[n];return t.setAttribute("data-color-index",`${e}`),t}function gB(){const n=b("div",["clear-button-container"],null),t=b("button",["clear-button"],n);return t.innerText=S.t("colorPalette.reset"),n}function pB(n){const t=b("div",["color-palette"],null);return n.color!==!1&&(b("div",["bar-desc"],t,S.t("colorPalette.colorDesc")),t.appendChild(cp(8,1,fB,"color"))),n.backgroundColor!==!1&&(b("div",["bar-desc"],t,S.t("colorPalette.backgroundDesc")),t.appendChild(cp(16,2,mB,"background-color"))),n.clearColorButton!==!1&&t.appendChild(gB()),t}function CB(n,t,e){const o=t==="color"?"color":"background-color",r=n.querySelector(`.${o} button.selected`);r&&F(r,"selected"),e===null&&(e=-1);const i=n.querySelector(`.${o} button[data-color-index="${e}"]`);i&&M(i,"selected")}const CF="",bB={};class ap extends Wt.TypedEmitter{constructor(e=bB){super();h(this,"root");h(this,"handleClick",e=>{const o=e.target;if(!o||!(o instanceof Element))return;const r=o.closest("button");if(!r)return;if(lt(r,"clear-button")){this.setColor("backgroundColor",null),this.setColor("color",null),this.emit("onClick","clearColor",0);return}const i=r.getAttribute("data-color-index");if(!i)return;const s=Number.parseInt(i,10);Number.isNaN(s)||(lt(r,"color-button")?s===-1?(this.setColor("color",null),this.emit("onClick","clearColor",1)):(this.setColor("color",s),this.emit("onClick","color",s)):s===-1?(this.setColor("backgroundColor",null),this.emit("onClick","clearColor",2)):(this.setColor("backgroundColor",s),this.emit("onClick","backgroundColor",s)))});this.options=e,this.root=pB(e),this.root.addEventListener("click",this.handleClick)}destroy(){this.removeAllListeners(),this.root.removeEventListener("click",this.handleClick)}setColor(e,o){CB(this.root,e,o)}}class cu{constructor(t,e){h(this,"name","Color Palette");h(this,"element");h(this,"palette");h(this,"closeable",null);this.id=t,this.palette=new ap(e),this.element=this.palette.root}setCloseable(t){this.closeable=t}destroy(){this.palette.destroy(),this.closeable=null}}function vB(){const n=b("button",["color-button"],null);return n.innerHTML=Gd,n}function au(n,t){const[e,o]=t;e===null?n.removeAttribute("data-color"):n.setAttribute("data-color",`${e}`),o===null?n.removeAttribute("data-background-color"):n.setAttribute("data-background-color",`${o}`)}class dp extends Wt.TypedEmitter{constructor(e){super();h(this,"id","text-color-item");h(this,"name","Text color");h(this,"dropdown",!0);h(this,"manualShowChildren",!0);h(this,"children",[]);h(this,"element");h(this,"colorPaletteItem");h(this,"latestColors",[null,null]);h(this,"handlePaletteClick",(e,o)=>{this.emit("onClick",e,o),e==="color"||e==="backgroundColor"?e==="color"?this.latestColors[0]=o:this.latestColors[1]=o:this.latestColors=[null,null],au(this.element,this.latestColors)});h(this,"beforePopup",()=>{this.emit("beforePopup")});this.editor=e,this.colorPaletteItem=new cu("text-color-palette-item"),this.colorPaletteItem.palette.addListener("onClick",this.handlePaletteClick),this.children.push(this.colorPaletteItem),this.element=vB()}destroy(){this.colorPaletteItem.destroy()}updatePaletteColor(e){this.colorPaletteItem.palette.setColor("color",e[0]),this.colorPaletteItem.palette.setColor("backgroundColor",e[1]),this.latestColors=e,au(this.element,this.latestColors)}updateButtonColor(e){this.latestColors=e,au(this.element,this.latestColors)}}const bF="";function cc(n,t){const e=b("div",["editor-input-wrap"],n);t!=null&&t.className&&M(e,t==null?void 0:t.className);const o=b("div",["editor-input-label"],e);b("span",[],o,t.label),t.required&&M(o,"required");const r=b("div",["editor-input-container"],e),i=b("input",["editor-input"],r);t.placeholder&&(i.placeholder=t.placeholder),t.defaultValue&&(i.value=t.defaultValue);const s=b("div",["editor-input-error"],e);return i.addEventListener("input",l=>{var c;(c=t.onChange)==null||c.call(t,l),F(e,"error")}),i.addEventListener("keydown",l=>{var c;(c=t.onKeyDown)==null||c.call(t,l)}),{getField:()=>i,getInputValue:()=>i.value,setFieldError:l=>{M(e,"error"),s.innerText=l}}}const kB=y("ui-base");class yB{constructor(t,e){h(this,"menu");h(this,"currentText","");h(this,"handleClick",(t,e)=>{this.options.onClickItem(this,e)});h(this,"handleClose",()=>{this.editor.focus()});h(this,"handleKeydown",t=>{this.menu.handleDocumentKeydown(t)});this.editor=t,this.options=e,this.menu=new Wo([],void 0,{id:e.id}),this.menu.addListener("click",this.handleClick),this.menu.addListener("close",this.handleClose)}setItems(t){if(this.menu.updateItems(t),t.length>0){const e=t.find(o=>o.type!=="section"&&o.type!=="separator");e&&this.menu.selectItem(e.id)}}async popup(t,e,o){var a,u;if(((u=(a=this.options).onShow)==null?void 0:u.call(a,this,t,e,o))===!1)return;this.options.showLoading&&this.showLoading();const r=this.editor.getBlockByIndex(t,e);if(!vt(this.editor.rootContainer,r)||Z(this.editor,r)<o)return;const i=Ao(this.editor,r,Ot(this.editor,r,o));if(i.length===0)return;const s=i[0],l=_o(this.editor,r,"editor-auto-suggest-menu",s);this.menu.manualShow(l),this.options.placeholder&&this.showPlaceholder();const c=await this.options.queryItems(this,"");this.highlightText(""),this.setItems(c)}showLoading(){!this.options.showLoading||this.setItems([{id:"loading",name:"loading",states:["disabled"]}])}showPlaceholder(){this.setItems([{id:"placeholder",name:"enter text to search",states:["disabled"]}])}showNoResultMessage(t){this.setItems([{id:"placeholder",name:S.t("search.emptyTips"),states:["disabled"]}])}close(){this.menu.close()}get isVisible(){return this.menu.isVisible}destroy(){this.menu.close(),this.menu.removeAllListeners(),this.menu.destroy()}async handleSearchText(t){this.currentText=t;const e="auto-suggest";try{await Rn.lock(e),this.showLoading();const o=this.currentText,r=await this.options.queryItems(this,o);if(this.currentText===o&&(this.currentText=""),r.length===0){this.showNoResultMessage(t);return}this.setItems(r),this.options.highlight&&this.highlightText(o)}finally{Rn.release(e)}}highlightText(t){kB.debug(`highlight menu text: ${t}`);const e=this.menu.content,o=(i,s)=>{if(!s)return i;let l="";const c=s.length,a=s.toLocaleLowerCase();let u=0;for(u=0;u<=i.length-c;u){const f=i.substring(u,u+c);f.toLocaleLowerCase()===a?(l+=`<span class="highlight">${f}</span>`,u+=c):(l+=i.charAt(u),u++)}return u<i.length&&(l+=i.substring(u)),l},r=i=>{if(lt(i,"text")){const s=i.textContent;if(!s)return;const l=o(s,t);i.innerHTML=l;return}Array.from(i.children).forEach(r)};r(e)}}const du=y("auto-suggest-menu");class uu{constructor(t,e){h(this,"menu");h(this,"anchor",null);h(this,"handleSelectionChanged",t=>{var o,r;if(!((o=this.menu)!=null&&o.isVisible))return;const e=t.selection.range.start;if(e.isSimple()&&e.blockId===((r=this.anchor)==null?void 0:r.blockId)&&e.offset>=this.anchor.offset){const i=t.getBlockById(e.blockId);if(Tt(Ae(ke(t,i),e.offset).left).startsWith(this.anchor.leftText))return}this.menu.close()});h(this,"deleteTrigger",()=>{const t=this.editor,e=t.selection.range.start;if(!e.isSimple()||!this.anchor)return!1;const{blockId:o,offset:r}=e,i=t.getBlockById(o),s=Tt(Ml(t,i,r));if(d(du,this.anchor,"no anchor"),!s.startsWith(this.anchor.leftText))return!1;const l=this.anchor.offset-this.anchor.trigger.length,c=r-l;return t.selection.selectBlock(i,l),c&&(t.deleteTextFromBlock(i,l,c),this.anchor.offset-=this.anchor.trigger.length),this.anchor.trigger.length||this.menu.close(),!0});h(this,"onShow",(t,e,o,r)=>{var i;if((i=this.options)!=null&&i.onShow)return this.options.onShow(this,e,o,r)});h(this,"onClickItem",(t,e)=>{!this.anchor||(this.options.autoDeleteTrigger&&this.deleteTrigger(),this.options.onClickItem(this,e,this.anchor))});h(this,"queryItems",(t,e)=>this.options.queryItems(this,e));h(this,"renderMenuItem",(t,e)=>{var r,i;return(i=(r=this.options).renderMenuItem)==null?void 0:i.call(r,this,e)});this.editor=t,this.options=e,this.menu=new yB(t,{id:e.id,showLoading:e.showLoading,loadingElement:e.loadingElement,placeholder:e.placeholder,noResultMessage:e.noResultMessage,highlight:e.highlight,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems,renderMenuItem:this.renderMenuItem}),t.input.addHandler(this),t.addListener("selectionChanged",this.handleSelectionChanged)}handleBeforeKeyDown(t,e){var o;return!((o=this.menu)!=null&&o.isVisible)||Ka(e.key)?!1:sm(e)&&!Do(e)?(setTimeout(()=>{this.resetItems()}),!1):Ja(e)?(this.menu.close(),!0):(this.menu.handleKeydown(e),!0)}popup(t,e,o,r){this.anchor={blockId:G(t),offset:e,leftText:o,trigger:r};const i=V(H(t)),s=K(t);this.menu.popup(i,s,e)}handleAfterInsertText(t,e,o,r,i){var u;const s=t.selection.range.start;if(!s.isSimple())return!1;const{blockId:l,offset:c}=s,a=t.getBlockByIndex(e,o);if(G(a)!==l)return!1;if((u=this.menu)!=null&&u.isVisible)this.resetItems();else if(this.options.trigger.indexOf(i)!==-1){if(r>0&&this.options.needSpaceBeforeTrigger&&t.getBlockString(a)[r-1]!==" ")return!1;const f=Tt(Ml(t,a,c));this.popup(a,c,f,i)}return!1}handleUpdateCompositionText(t,e,o,r,i){var a;const s=t.selection.range.start;if(!s.isSimple())return!1;const{blockId:l}=s,c=t.getBlockByIndex(e,o);return G(c)!==l||(a=this.menu)!=null&&a.isVisible&&this.resetItems(),!1}resetItems(){var l;if(!((l=this.menu)!=null&&l.isVisible))return;const t=this.editor,e=t.selection.range.start;if(!e.isSimple())return;const{blockId:o,offset:r}=e,i=t.getBlockById(o),s=Tt(Ml(t,i,r));if(d(du,this.anchor,"no anchor"),s.startsWith(this.anchor.leftText)){const c=s.substring(this.anchor.leftText.length);du.debug(`search text: ${c}`),this.menu.handleSearchText(c)}}destroy(){var t;this.editor.input.removeHandler(this),this.editor.removeListener("selectionChanged",this.handleSelectionChanged),(t=this.menu)==null||t.destroy()}}const up=Object.freeze(Object.defineProperty({__proto__:null,getButtonId:Aw,getParentButton:Ow,createButton:kn,changeButtonName:Vd,createSeparator:_w,DropdownFilterableList:f5,FilterableList:h5,showToast:m5,ManualMenu:Wo,ManualToolbar:os,HoveringMenu:dB,CommandBar:ho,Popup:lc,ManualCloseDialog:rs,CloseIcon:qd,PrevIcon:p5,NextIcon:C5,MoreIcon:Wd,TextColorIcon:Gd,ArrowDownIcon:oc,ArrowUpIcon:Fw,ArrowLeftIcon:zw,ArrowRightIcon:Zd,DeleteRowIcon:Yd,DeleteColIcon:Vw,MergeCellIcon:b5,SplitCellIcon:v5,DeleteTableIcon:k5,Heading1Icon:Qd,Heading2Icon:Kd,Heading3Icon:Jd,Heading4Icon:Xd,Heading5Icon:tu,Heading6Icon:eu,Heading7Icon:nu,Heading8Icon:ou,HeadingNIcon:Uw,OrderedListIcon:y5,UnorderedListIcon:w5,CheckListIcon:B5,BlockquoteIcon:E5,AlignCenterIcon:ic,AlignLeftIcon:Pr,AlignRightIcon:rc,ImageIcon:I5,ImageMenuIcon:x5,ImageErrorIcon:iu,ImageEmptyIcon:T5,LinkIcon:lu,LinkOffIcon:D5,WarningIcon:ru,PasteSpecialIcon:S5,LaunchIcon:su,CodeIcon:q5,AudioIcon:F5,GraphIcon:qw,VideoIcon:z5,FileIcon:Ww,MathIcon:Qw,MathMenuIcon:L5,TableIcon:Kw,TableMenuIcon:M5,LineIcon:Gw,BilibiliIcon:_5,YoukuIcon:N5,ModaoIcon:$5,FigmaIcon:P5,WebIcon:Zw,EditIcon:sc,CommentIcon:$r,RefreshIcon:R5,HelpIcon:A5,CheckMarkIcon:O5,TextIcon:ns,RightArrowIcon:Yw,TencentVideoIcon:H5,WebPageIcon:j5,UmlIcon:V5,DividingLineIcon:U5,HeadingH1Icon:Jw,HeadingH2Icon:Xw,HeadingH3Icon:tB,HeadingH4Icon:eB,HeadingH5Icon:nB,HeadingH6Icon:oB,HeadingH7Icon:rB,HeadingH8Icon:iB,CheckboxIcon:W5,QuoteIcon:G5,LinkHrefIcon:sB,OrderedIcon:Y5,UnorderedIcon:Z5,CopyIcon:Q5,CutIcon:K5,DeleteIcon:J5,LockBlockIcon:X5,UnLockBlockIcon:tp,CollapseUpIcon:ep,CollapseDownIcon:np,MentionIcon:op,ColorPalette:ap,ColorPaletteItem:cu,TextColorItem:dp,createInput:cc,OnesEditorAutoSuggest:uu,getItemShortcut:Ud,getItemMarkdown:jw},Symbol.toStringTag,{value:"Module"})),yn=y("table-dom");function fo(n){return`${G(n)}_scroll`}function $t(n){const t=n.querySelector("div[data-type=table-content] >table");return d(yn,t instanceof HTMLTableElement,"invalid table"),t}function wn(n,t){const o=n.getCustom(fo(t)).contentElement.firstElementChild;d(yn,o instanceof HTMLElement,"invalid table content");let r=o.querySelector(":scope >div[data-type=table-tools]");return r||(r=b("div",[],o),r.setAttribute("data-type","table-tools")),d(yn,r,"no table tools"),r}function hp(n){const t=[];return Array.from(n.rows).forEach(e=>{t.push(...Array.from(e.cells))}),t}function is(n){const t=n.querySelector(":scope div[data-type=editor-container]");return d(yn,t,"no child container in cell"),t}function wB(n){const o=hp(n).map(r=>{const i=is(r),s=V(i),l=r.colSpan,c=r.rowSpan;return`${s}/${l}/${c}`}).join();return Ci.default(o)}function Ht(n){return it(n)==="table"}function hu(n){const t=H(n);if(Ct(t))return null;const e=z(t);return d(yn,e,"no parent block"),Ht(e)?t:hu(e)}function we(n){if(Ht(n))return n;const t=H(n);if(Ct(t))return null;const e=z(t);return d(yn,e,"no parent block"),Ht(e)?e:we(e)}function BB(n,t){const e=n.querySelector("colgroup");d(yn,e,"no colgroup");const o=e.children[t];return d(yn,o,"no col"),d(yn,o instanceof HTMLTableColElement,`invalid col: ${o.tagName}`),o}function fp(n){try{return $t(n),!0}catch{return!1}}function EB(n){return At(n).querySelector(":scope > .block-helper")}function IB(n){const t=z(n.contentElement);d(yn,t,"no block");const e=EB(t);if(e){const o=Math.min(n.contentElement.offsetLeft,n.rootElement.scrollLeft),r=t.getBoundingClientRect().width;e.style.right=`${o+r}px`}}const Be=y("doc-table-grid");class xB{constructor(t){h(this,"_cells",[]);for(let e=0;e<t;e++)this._cells.push(void 0)}cols(){return this._cells.length}setCell(t,e){d(Be,t>=0&&t<this.cols(),`set cell, invalid col: ${t}`),this._cells[t]=e}getCell(t){d(Be,t>=0&&t<this.cols(),`get cell, invalid col: ${t}`);const e=this._cells[t];return d(Be,e,"get cell, no cell"),e}getCellAllowEmpty(t){return d(Be,t>=0&&t<this.cols(),`get cell, invalid col, ${t}`),this._cells[t]}getNextNonVirtualCell(t){return this._cells.slice(t+1).find(e=>!e.virtual)}forEach(t){this._cells.forEach(t)}}class fu{constructor(t){h(this,"_data");h(this,"_rows");this._data=t,this._rows=[];for(let e=0;e<this.rowCount;e++)this._rows.push(new xB(this.colCount));this.fillGrid(),d(Be,t.colsWidth,"no colsWidth"),d(Be,this.colCount===t.colsWidth.length,"invalid col count")}get rowCount(){return this._data.rows}get colCount(){return this._data.cols}getNextEmptyCell(t,e){let o=t,r=e;for(;;){if(o+=1,o===this.colCount&&(o=0,r+=1),r>=this.rowCount)return null;if(this._rows[r].getCellAllowEmpty(o)===void 0)return{col:o,row:r}}}fillGrid(){const t=this._data.children;d(Be,t,"no children");let e=0,o=0;t.forEach((r,i)=>{const s=this._data[`${r}_colSpan`]||1,l=this._data[`${r}_rowSpan`]||1;for(let a=0;a<l;a++)for(let u=0;u<s;u++)this._rows[o+a].setCell(e+u,{col:e,row:o,containerId:r,virtual:u!==0||a!==0,colSpan:s,rowSpan:l});const c=this.getNextEmptyCell(e,o);c?(e=c.col,o=c.row):d(Be,i===t.length-1,`invalid table data, no next empty cell: ${JSON.stringify(this._data)}`)}),this._rows.forEach(r=>{r.forEach(i=>{d(Be,i,"no cell"),d(Be,i.containerId,"no containerId")})})}getCell(t){const{col:e,row:o}=t,r=this._rows[o];d(Be,r,`get cell, no row: ${o}`);const i=r.getCell(e);return d(Be,i,`get cell, no cell: ${e}`),i}getRow(t){const e=this._rows[t];return d(Be,e,`get row, no row: ${t}`),e}forEach(t){this._rows.forEach(t)}}const ac=y("table-data");function SB(n){const t=n.firstElementChild;return d(ac,t,"no child element for cell"),d(ac,fn(t),"cell first child is not a container"),d(ac,qe(t),"cell first child is not a container"),t}function TB(n){const t=z(n);d(ac,t,"no parent block for table");const e=[],o={};Array.from(n.rows).forEach(l=>{Array.from(l.cells).forEach(c=>{const a=SB(c),u=V(a);e.push(u),(c.colSpan>1||c.rowSpan>1)&&(o[`${u}_colSpan`]=c.colSpan,o[`${u}_rowSpan`]=c.rowSpan)})});const r=n.rows.length,i=Array.from(n.rows[0].cells).map(l=>l.colSpan).reduce((l,c)=>l+c,0);return{id:G(t),type:it(t),rows:r,cols:i,children:e,colsWidth:Array(i).fill(100),...o}}function Go(n){return new fu(n)}function DB(n){return Go(TB(n))}const qt=y("table-grid"),LB=60;class MB{constructor(t,e){h(this,"containerId");h(this,"row");h(this,"col");h(this,"colSpan");h(this,"rowSpan");h(this,"virtual");h(this,"table");this.table=t,this.containerId=e.containerId,this.row=e.row,this.col=e.col,this.colSpan=e.colSpan,this.rowSpan=e.rowSpan,this.virtual=e.virtual}get cell(){const e=this.container.closest("td");return d(qt,e,"no parent cell for child container"),e}get container(){const t=this.table.querySelectorAll(`[data-container-id=${this.containerId}]`);d(qt,t.length===1,"containers !== 1"),d(qt,fn(t[0]),"not a container");const e=t[0];return d(qt,qe(e),"not a child container"),e}}class RB{constructor(t,e){h(this,"_cells",[]);e.forEach(o=>{this._cells.push(new MB(t,o))})}get cells(){return this._cells}getCell(t){return d(qt,t<this._cells.length,"get cell, invalid col"),this._cells[t]}getNextNonVirtualCell(t){return this._cells.slice(t+1).find(e=>!e.virtual)}getSpannedCell(){return this._cells.find(t=>t.virtual||t.colSpan>1||t.rowSpan>1)}}const uf=class{constructor(t){h(this,"_rows",[]);this.table=t,DB(t).forEach(r=>{this._rows.push(new RB(t,r))});const o=this.colCount;this._rows.forEach(r=>{d(qt,r.cells.length===o,"row.cells.length !== colCount")})}get rowCount(){return this._rows.length}get colCount(){return this._rows.length===0?0:(d(qt,this.rowCount>0,"rowCount <= 0"),this.getRow(0).cells.length)}getRow(t){return this._rows[t]}getCell(t){const e=this.getRow(t.row);return d(qt,e,"no row"),e.getCell(t.col)}getCellContainer(t){return this.getCell(t).container}getFirstCellContainer(){return this.getCellContainer({row:0,col:0})}getLastCellContainer(){const t=this.rowCount-1,e=this.colCount-1;return this.getCellContainer({row:t,col:e})}getColumnCells(t){d(qt,t>=0&&t<this.colCount,"colIndex out of range");const e=this.rowCount,o=[];for(let r=0;r<e;r++){const i=this.getCell({row:r,col:t});o.push(i)}return o}toRealCells(t){const e=[];return t.forEach(o=>{const r=this.getRealCell(o);e.findIndex(i=>i.containerId===r.containerId)===-1&&e.push(r)}),e}getColumnRealCells(t){const e=this.getColumnCells(t);return this.toRealCells(e)}getRowRealCells(t){const e=this.getRow(t).cells;return this.toRealCells(e)}getFirstSpannedCell(t){d(qt,t>=0&&t<this.colCount,"colIndex out of range");const e=this.rowCount;for(let o=0;o<e;o++){const r=this.getCell({row:o,col:t});if(r.virtual||r.colSpan>1||r.rowSpan>1)return r}}getRealCell(t){const e=this.getCell(t);if(!e.virtual)return e;const o=this.getCellById(e.containerId);return d(qt,!o.virtual,"found a virtual cell"),o}getColumnSpannedRange(t){const e=this.getColumnRealCells(t);let o=1e5,r=-1;return e.forEach(i=>{o=Math.min(i.col,o),r=Math.max(i.col+i.colSpan-1,r)}),d(qt,o<=r,"min > max"),d(qt,o>=0,"min < 0"),d(qt,r<this.colCount,"max >= colCount"),[o,r]}getRowSpannedRange(t){const e=this.getRowRealCells(t);let o=1e5,r=-1;return e.forEach(i=>{o=Math.min(i.row,o),r=Math.max(i.row+i.rowSpan-1,r)}),d(qt,o<=r,"min > max"),d(qt,o>=0,"min < 0"),d(qt,r<this.rowCount,"max >= rowCount"),[o,r]}getSpannedRange(t,e){const o=Math.min(t.row,e.row),r=Math.max(t.row,e.row),i=Math.min(t.col,e.col),s=Math.max(t.col,e.col),l=[];for(let C=o;C<=r;C++)for(let v=i;v<=s;v++)l.push(this.getCell({row:C,col:v}));const c=this.toRealCells(l);let a=1e4,u=1e4,f=-1,m=-1;return c.forEach(C=>{u=Math.min(C.col,u),a=Math.min(C.row,a),m=Math.max(C.col+C.colSpan-1,m),f=Math.max(C.row+C.rowSpan-1,f)}),[{row:a,col:u},{row:f,col:m}]}getAllCells(){return this.getCells({col:0,row:0},{col:this.colCount-1,row:this.rowCount-1})}sub(t,e){const o=[];for(let r=t.row;r<=e.row;r++){const i=[];for(let s=t.col;s<=e.col;s++){const l=this.getCell({row:r,col:s});i.push(l)}o.push(i)}return o}getAllContainers(){return this.getAllCells().map(e=>e.container)}getCells(t,e){const o=[],r=this.getSpannedRange(t,e),i=r[0],s=r[1],l=Math.min(i.row,s.row),c=Math.max(i.row,s.row),a=Math.min(i.col,s.col),u=Math.max(i.col,s.col);for(let f=l;f<=c;f++)for(let m=a;m<=u;m++){const C=this.getCell({row:f,col:m});C.virtual||o.push(C)}return o}map(t){const e=[];for(let o=0;o<this.rowCount;o++){const r=[];for(let i=0;i<this.colCount;i++){const s=this.getCell({row:o,col:i});r.push(t(s))}e.push(r)}return e}getBottomCell(t){const e=this.rowCount;let o=t,r=t.row;for(;o.containerId===t.containerId;){if(r+=1,r>=e)return null;o=this.getCell({row:r,col:t.col})}return this.getRealCell(o)}getTopCell(t){let e=t,o=t.row;for(;e.containerId===t.containerId;){if(o-=1,o<0)return null;e=this.getCell({row:o,col:t.col})}return this.getRealCell(e)}get cells(){let t=[];return this._rows.forEach(e=>{t=t.concat(e.cells)}),t}getVirtualCellContainersGrid(){return this.map(t=>t.containerId)}static virtualCellContainersGridToChildren(t){const e=t,o=[];return e.forEach(r=>{r.forEach(i=>{o.indexOf(i)===-1&&o.push(i)})}),o}getCellById(t){const o=this.cells.find(r=>r.containerId===t);return d(qt,o,"cell not found"),o}getCellByCellElement(t){const e=is(t);return this.getCellByContainerId(V(e))}getCellByContainerId(t){return this.getCellById(t)}static fromTable(t){const e=wB(t),o=this.caches.getSync(e,()=>(qt.debug("create table grid"),new uf(t)));return o.table!==t?(this.caches.delete(e),this.fromTable(t)):o}static fromBlock(t){return this.fromTable($t(t))}};let nt=uf;h(nt,"caches",new Hf(LB));function dc(n,t){Object.entries(n).forEach(([e])=>{e.startsWith(`${t}/`)&&delete n[e]})}const AB=y("table-selection-range");function rn(n,t,e){var x,A,O,P;const o=nt.fromBlock(n),r=t,i=e,s=o.getCellByContainerId(r.childContainerId),l=o.getCellByContainerId(i.childContainerId),c=r.custom,a=i.custom,u=(x=c==null?void 0:c.rowIndex)!=null?x:s.row,f=(A=c==null?void 0:c.colIndex)!=null?A:s.col,m=(O=a==null?void 0:a.rowIndex)!=null?O:l.row+l.rowSpan-1,C=(P=a==null?void 0:a.colIndex)!=null?P:l.col+l.colSpan-1,v=Math.min(u,m),w=Math.max(u,m),E=Math.min(f,C),L=Math.max(f,C);return{fromRow:v,toRow:w,fromCol:E,toCol:L}}function mu(n,t){const e=new Set,o=new Set,r=n.selection.range;if(!r.isSimple()&&r.start.blockId===G(t)){const i=nt.fromBlock(t),{start:s,end:l}=r;d(AB,!s.isSimple()&&!l.isSimple(),"invalid range");const{fromCol:c,toCol:a,fromRow:u,toRow:f}=rn(t,s,l);if(u===0&&f===i.rowCount-1)for(let m=c;m<=a;m++)o.add(m);if(c===0&&a===i.colCount-1)for(let m=u;m<=f;m++)e.add(m)}return{selectedRows:e,selectedColumns:o}}const Hr=y("delete-columns");function mp(n,t,e){const{start:o,end:r}=e;if(o.blockId!==r.blockId||e.isSimple()||n.getBlockById(o.blockId)!==t||it(t)!=="table")return!1;const{fromRow:s,toRow:l}=rn(t,e.start,e.end),c=nt.fromBlock(t);return s===0&&l===c.rowCount-1}function gu(n){var A;const t=n.getEditor(),e=t.getBlockById(n.start.blockId);if(!mp(t,e,n))return;if(n.isSimple()){t.deleteBlock(e);return}const{fromCol:o,toCol:r}=rn(e,n.start,n.end),i=nt.fromBlock(e);if(o===0&&r===i.colCount-1){t.deleteBlock(e);return}const s=new Set,l=i.map(O=>O.containerId);for(let O=0;O<l.length;O++){const P=l[O];for(let U=o;U<=r;U++){const tt=P[U];s.add(tt)}P.splice(o,r-o+1)}const c=new Set(l.flat()),a=new Set(Array.from(s).filter(O=>!c.has(O))),u=r-o+1,f=new Map,m=new Map;s.forEach(O=>{if(a.has(O))return;const P=i.getCellByContainerId(O);if(d(Hr,P.colSpan>1,"invalid effected cell, colSpan === 1"),P.col<o){d(Hr,c.has(O),"invalid effected cell, not exists");let yt=P.col+P.colSpan-1;yt>r&&(yt=r);const oe=yt-o+1,Jn=P.colSpan-oe;f.set(O,Jn);return}d(Hr,P.col<=r,"invalid effected cell, col > endCol");const U=P.col,tt=P.col+P.colSpan-1,ot=P.col-o,ut=tt-U+1-u+ot;d(Hr,ut>0,"invalid effected cell, newSpanned <= 0");const dt=pn(t.doc);m.set(O,{newContainerId:dt,colSpan:ut})});for(let O=0;O<l.length;O++){const P=l[O];for(let U=o;U<P.length;U++){const tt=P[U],ot=m.get(tt);ot&&(P[U]=ot.newContainerId)}}const C=Y.default(t.getBlockData(e));C.colsWidth.splice(o,r-o+1),a.forEach(O=>{dc(C,O)}),f.forEach((O,P)=>{d(Hr,O>=1,"invalid modified colSpan, colSpan < 1"),O===1?delete C[`${P}_colSpan`]:C[`${P}_colSpan`]=O}),m.forEach((O,P)=>{dc(C,P);const{newContainerId:U,colSpan:tt}=O;d(Hr,tt>=1,"invalid newContainerData, colSpan < 1"),tt>1&&(C[`${U}_colSpan`]=tt);const ot=i.getCellByContainerId(P).rowSpan;ot>1&&(C[`${U}_rowSpan`]=ot)});const w=(A=l[0][o])!=null?A:l[0][o-1],E=t.getChildContainerData(w)[0],L=nt.virtualCellContainersGridToChildren(l),x={...C,cols:C.cols-u,children:L};Go(x),t.updateBlockData(e,x,Ot(t,E.id,0)),t.deleteChildContainers(Array.from(a)),t.deleteChildContainers(Array.from(m.keys()))}const jr=y("delete-rows");function gp(n,t,e){const{start:o,end:r}=e;if(o.blockId!==r.blockId||e.isSimple()||n.getBlockById(o.blockId)!==t||it(t)!=="table")return!1;const{fromCol:s,toCol:l}=rn(t,e.start,e.end),c=nt.fromBlock(t);return s===0&&l===c.colCount-1}function pu(n){const t=n.getEditor(),e=t.getBlockById(n.start.blockId);if(!gp(t,e,n))return;if(n.isSimple()){t.deleteBlock(e);return}const{fromRow:o,toRow:r}=rn(e,n.start,n.end),i=nt.fromBlock(e);if(o===0&&r===i.rowCount-1){t.deleteBlock(e);return}const s=new Set,l=i.map(x=>x.containerId);for(let x=r;x>=o;x--)l[x].forEach(O=>s.add(O)),l.splice(x,1);const c=new Set(l.flat()),a=new Set(Array.from(s).filter(x=>!c.has(x))),u=r-o+1,f=new Map,m=new Map;s.forEach(x=>{if(a.has(x))return;const A=i.getCellByContainerId(x);if(d(jr,A.rowSpan>1,"invalid effected cell, rowSpan === 1"),A.row<o){d(jr,c.has(x),"invalid effected cell, not exists");let ut=A.row+A.rowSpan-1;ut>r&&(ut=r);const dt=ut-o+1,yt=A.rowSpan-dt;f.set(x,yt);return}d(jr,A.row<=r,"invalid effected cell, col > endCol");const O=A.row,P=A.row+A.rowSpan-1,U=A.row-o,tt=P-O+1-u+U;d(jr,tt>0,"invalid effected cell, newSpanned <= 0");const ot=pn(t.doc);m.set(x,{newContainerId:ot,rowSpan:tt})});for(let x=o;x<l.length;x++){const A=l[x];for(let O=0;O<A.length;O++){const P=A[O],U=m.get(P);U&&(A[O]=U.newContainerId)}}const C=Y.default(t.getBlockData(e));a.forEach(x=>{dc(C,x)}),f.forEach((x,A)=>{d(jr,x>=1,"invalid modified rowSpan, rowSpan < 1"),x===1?delete C[`${A}_rowSpan`]:C[`${A}_rowSpan`]=x}),m.forEach((x,A)=>{dc(C,A);const{newContainerId:O,rowSpan:P}=x;d(jr,P>=1,"invalid newContainerData, rowSpan < 1"),P>1&&(C[`${O}_rowSpan`]=P);const U=i.getCellByContainerId(A).colSpan;U>1&&(C[`${O}_colSpan`]=U)});const v=l[o]?l[o][0]:l[o-1][0],w=t.getChildContainerData(v)[0],E=nt.virtualCellContainersGridToChildren(l),L={...C,rows:C.rows-u,children:E};Go(L),t.updateBlockData(e,L,Ot(t,w.id,0)),t.deleteChildContainers(Array.from(a)),t.deleteChildContainers(Array.from(m.keys()))}const ss=y("table-range");function uc(n){d(ss,!n.isSimple(),"must be complex selection range");const{anchor:t,focus:e}=n;d(ss,!t.isSimple(),"invalid start pos type"),d(ss,!e.isSimple(),"invalid end pos type");const o=n.getEditor();d(ss,t.blockId===e.blockId,"invalid range, not same block");const r=o.getBlockById(t.blockId);d(ss,it(r)==="table","invalid block type, not a table block");const i=$t(r),s=nt.fromTable(i),l=s.getCellByContainerId(t.childContainerId),c=s.getCellByContainerId(e.childContainerId),a=Math.min(l.row,c.row),u=Math.max(l.row,c.row),f=Math.min(l.col,c.col),m=Math.max(l.col,c.col),C=s.getCell({row:a,col:f}),v=s.getCell({row:u,col:m});return{editor:o,block:r,table:i,startCell:C,endCell:v,startRow:a,startCol:f,endRow:u,endCol:m}}const Cu=y("split-cell");function bu(n,t,e){const o=nt.fromBlock(t),r=o.getRealCell(e);d(Cu,!r.virtual,"should not split virtual cell"),d(Cu,r.colSpan>1||r.rowSpan>1,"cell does not has span data");const i=o.getVirtualCellContainersGrid();for(let f=0;f<r.rowSpan;f++)for(let m=0;m<r.colSpan;m++){if(f===0&&m===0)continue;const C=f+r.row,v=m+r.col,w=pn(n.doc);i[C][v]=w}const s=n.getBlockData(t),l=Y.default(s);l[`${r.containerId}_colSpan`]=null,l[`${r.containerId}_rowSpan`]=null,l.children=nt.virtualCellContainersGridToChildren(i);const a=n.getChildContainerData(r.containerId)[0];d(Cu,a,"no child block");const u=Ot(n,a.id,0);Go(l),n.updateBlockData(t,l,u)}function OB(n,t,e){e.forEach(o=>{const r=nt.fromBlock(t).getCell(o);(r.virtual||r.colSpan>1||r.rowSpan>1)&&bu(n,t,o)})}function pp(n,t,e){if(e.isSimple())return!1;const{start:o,end:r}=e;if(o.blockId!==r.blockId||n.getBlockById(o.blockId)!==t||it(t)!=="table")return!1;const{startCell:s,endCell:l}=uc(e);return!(s.cell!==l.cell||s.colSpan===1&&s.rowSpan===1)}function vu(n){const{editor:t,block:e,startRow:o,startCol:r,endRow:i,endCol:s}=uc(n),l=[];for(let c=o;c<=i;c++)for(let a=r;a<=s;a++)l.push({row:c,col:a});return OB(t,e,l),!0}const Fr=y("merge-cells");function Cp(n,t,e){if(e.isSimple())return!1;const{start:o,end:r}=e;if(o.blockId!==r.blockId||n.getBlockById(o.blockId)!==t||it(t)!=="table")return!1;const{startCell:s,endCell:l}=uc(e);return s.cell!==l.cell}function bp(n){const t=uc(n),e=t.endCell,o=e.row+e.rowSpan-1,r=e.col+e.colSpan-1,i=G(t.block),s=t.editor;vu(n);const l=s.getBlockById(i),c=$t(l),{startRow:a,startCol:u}=t,f=Y.default(s.getBlockData(l));d(Fr,f.children,"no table children");const m=nt.fromTable(c),C=[];for(let ut=a;ut<=o;ut++)for(let dt=u;dt<=r;dt++){const yt=m.getCell({row:ut,col:dt});d(Fr,!yt.virtual,"cell is virtual"),C.push(yt)}d(Fr,C.length>0,"no selected cells");const v=C[0],w=C.slice(1),E=m.getCellByContainerId(v.containerId).container,L=[];w.forEach(ut=>{const dt=m.getCellByContainerId(ut.containerId).container,yt=V(dt);if(!g1(s,dt)){const oe=od(s,yt);s.insertDocAt(E,Ve(E),oe)}L.push(yt)});const x=V(E),A=r-u+1,O=o-a+1;f[`${x}_colSpan`]=A,f[`${x}_rowSpan`]=O,L.forEach(ut=>{d(Fr,f.children,"no table children");const dt=f.children.indexOf(ut);d(Fr,dt>0,"no deleted container"),f.children.splice(dt,1)});const P=f,tt=s.getChildContainerData(x)[0];d(Fr,tt,"no child block");const ot=Ot(s,tt.id,0);Go(P),s.updateBlockData(l,P,ot),s.deleteChildContainers(L)}const ku=10,_B=["table/merge-cells","table/split-cell","table/insert-column","table/insert-row","table/delete-rows","table/delete-columns","table/delete"];class yu{constructor(){h(this,"id","TableBlockCommandProvider")}getAvailableCommands(t,e,o){if(it(e)!=="table")return[];const r={blockId:G(e),blockKind:We(t,e),blockType:it(e)},i=[];Cp(t,e,o)&&i.push({id:"table/merge-cells",name:"merge cells",icon:b5,groupIndex:ku,...r}),pp(t,e,o)&&i.push({id:"table/split-cell",name:"split cell",icon:v5,groupIndex:ku,...r});const s=mp(t,e,o),l=gp(t,e,o);return s&&l&&i.push({id:"table/delete",name:"delete tables",icon:k5,groupIndex:ku,...r}),i}executeCommand(t,e,o,r,i,s){return it(e)!=="table"||!new Set(_B).has(r.id)?!1:r.id==="table/merge-cells"?(bp(o),!0):r.id==="table/split-cell"?(vu(o),!0):r.id==="table/delete-columns"?(gu(o),!0):r.id==="table/delete-rows"?(pu(o),!0):r.id==="table/delete"?(t.deleteBlock(e),!0):!1}}var vp=(n=>(n.COL_TITLE_TABLE="col-title-table",n.COL_TITLE_ITEM="col-title-item",n.STRIPE_STYLE_TABLE="stripe-style-table",n.NO_BORDER="table-no-border",n))(vp||{});const wu=6,ls=20;function NB(n,t){if(!n.isBlockWritable(t))return;const o={...Y.default(n.getBlockData(t)),hasColTitle:!0};n.updateBlockData(t,o)}function PB(n,t){if(!n.isBlockWritable(t))return;const o={...Y.default(n.getBlockData(t)),hasColTitle:!1};n.updateBlockData(t,o)}function $B(n,t){if(!n.isBlockWritable(t))return;const o={...Y.default(n.getBlockData(t)),hasRowTitle:!0};n.updateBlockData(t,o)}function HB(n,t){if(!n.isBlockWritable(t))return;const o={...Y.default(n.getBlockData(t)),hasRowTitle:!1};n.updateBlockData(t,o)}function jB(n,t){if(!n.isBlockWritable(t))return;const o={...Y.default(n.getBlockData(t)),isStripeStyle:!0};n.updateBlockData(t,o)}function FB(n,t){if(!n.isBlockWritable(t))return;const o={...Y.default(n.getBlockData(t)),isStripeStyle:!1};n.updateBlockData(t,o)}function zB(n,t,e){if(!n.isBlockWritable(t))return;const r={...Y.default(n.getBlockData(t)),noBorder:!e};n.updateBlockData(t,r)}const Bu=y("get-selected-containers");function Eu(n,t,e,o){d(Bu,e.blockId===o.blockId,"only allow select in single table block"),d(Bu,G(t)===e.blockId,"only allow select in single table block");const r=nt.fromBlock(t),i=r.getCellByContainerId(e.childContainerId),s=r.getCellByContainerId(o.childContainerId);if(e.custom===void 0||o.custom===void 0)return r.getCells(i,s).map(E=>r.getCellContainer(E));const{fromCol:l,toCol:c,fromRow:a,toRow:u}=rn(t,e,o),f=new Set,m=[];return r.sub({row:a,col:l},{row:u,col:c}).forEach(v=>{v.forEach(w=>{const E=r.getCellByContainerId(w.containerId);E.col<l||E.row<a||E.col+E.colSpan-1>c||E.row+E.rowSpan-1>u||f.has(w.containerId)||(f.add(w.containerId),m.push(E.container))})}),m}function VB(n,t,e){d(Bu,t.blockId===e.blockId,"only allow select in single table block");const o=n.getBlockById(t.blockId);return Eu(n,o,t,e)}const Zo=y("table-cell-dom");function UB(n,t,e){let o=n.getBlockById(e);for(;o;){const r=o.closest("td");d(Zo,r,"no parent cell");const i=z(r);if(d(Zo,i,"no parent block"),i===t)return r;o=i}return d(Zo,!1,"filed to get cell by child block id"),null}function Un(n,t,e){if(n.getBlockById(e.blockId)===t&&!e.isSimple())return d(Zo,e.childContainerId,"block position must have childContainerId attribute"),e;const r=UB(n,t,e.blockId),i=V(is(r));return bt(t,i)}function Iu(n,t){const e=n.selection.range,o=Un(n,t,e.start),r=Un(n,t,e.end);return rn(t,o,r)}function kp(n,t,e,o){d(Zo,Ht(t),"invalid table block");const r=wn(n,t),i=()=>{const l=r.querySelector(".table-border-bar-container.top");d(Zo,l,"no top border bar container"),l.querySelectorAll(".table-border-bar-cell.top").forEach(a=>{const u=parseInt(a.getAttribute("data-top-index")||"0",10);o.includes(u)?M(a,"danger"):F(a,"danger")})},s=()=>{const l=r.querySelector(".table-border-bar-container.left");d(Zo,l,"no left border bar container"),l.querySelectorAll(".table-border-bar-cell.left").forEach(a=>{const u=parseInt(a.getAttribute("data-left-index")||"0",10);e.includes(u)?M(a,"danger"):F(a,"danger")})};i(),s()}function zr(n,t,e=!0,o){const i=nt.fromBlock(t).map(u=>u),{fromCol:s,toCol:l,fromRow:c,toRow:a}=Iu(n,t);for(let u=0;u<i.length;u++){const f=i[u];for(let m=0;m<f.length;m++){const C=f[m],v=o?m>=s&&m+C.colSpan-1<=l:u>=c&&u+C.rowSpan-1<=a;e&&v?C.virtual||M(C.cell,"danger"):C.virtual||F(C.cell,"danger")}}}function Vr(n,t,e=!0,o){const r=new Set,i=new Set;if(!e){kp(n,t,Array.from(r),Array.from(i));return}const{fromCol:s,toCol:l,fromRow:c,toRow:a}=Iu(n,t);if(o)for(let u=s;u<=l;u++)i.add(u);else for(let u=c;u<=a;u++)r.add(u);kp(n,t,Array.from(r),Array.from(i))}function yp(n,t,e){const{fromCol:o,toCol:r,fromRow:i,toRow:s}=Iu(n,t),l=nt.fromBlock(t);let c=null,a=null;return e?(c=l.getCell({col:o,row:0}),a=l.getCell({col:r,row:l.rowCount-1}),Ut(n,{anchor:bt(t,c.containerId,{colIndex:o,rowIndex:0}),focus:bt(t,a.containerId,{colIndex:r,rowIndex:l.rowCount-1})})):(c=l.getCell({col:0,row:i}),a=l.getCell({col:l.colCount-1,row:s}),Ut(n,{anchor:bt(t,c.containerId,{colIndex:0,rowIndex:i}),focus:bt(t,a.containerId,{colIndex:l.colCount-1,rowIndex:s})}))}function qB(n,t){const e=n.selection.range,o=Un(n,t,e.start),r=Un(n,t,e.end);return Eu(n,t,o,r)}const wp=["style-bg-color-0","style-bg-color-1","style-bg-color-2","style-bg-color-3","style-bg-color-4","style-bg-color-5","style-bg-color-6","style-bg-color-7","style-bg-color-8","style-bg-color-9","style-bg-color-10","style-bg-color-11","style-bg-color-12","style-bg-color-13"];function Bp(n){return`style-bg-color-${n}`}function cs(n){return`${n}_background`}function WB(n,t,e){const o=$t(n),s=(e!=null?e:nt.fromTable(o)).getCell(t).cell;for(let l=0;l<wp.length;l++){const c=wp[l];if(lt(s,c))return c}}function Ep(n,t,e){if(!n.isBlockWritable(t))return;const o=n.selection.range,i={...Y.default(n.getBlockData(t))},s=Un(n,t,o.start),l=Un(n,t,o.end);if(o.isSimple()){const c=s.childContainerId;e===-1?i[cs(c)]=void 0:i[cs(c)]=Bp(e)}else{const c=nt.fromBlock(t),a=rn(t,s,l),u=new Set;for(let f=a.fromRow;f<=a.toRow;f++)for(let m=a.fromCol;m<=a.toCol;m++){const C=c.getCell({row:f,col:m});!u.has(C.containerId)&&C.col>=a.fromCol&&C.row>=a.fromRow&&C.col+C.colSpan-1<=a.toCol&&C.row+C.rowSpan-1<=a.toRow&&(u.add(C.containerId),e===-1?i[cs(C.containerId)]=void 0:i[cs(C.containerId)]=Bp(e))}}n.updateBlockData(t,i)}function GB(n,t,e){if(!n.isBlockWritable(t))return;const r={...Y.default(n.getBlockData(t)),chart:e};n.updateBlockData(t,r)}const Ip=y("table-chart");function ZB(n,t){const e=wn(n,t);if(e){const o=e.querySelector(".editor-table-chart");if(o){const r=o.chartObject;r&&r.destroy(),o.remove()}}}async function YB(n,t){if(!n.isBlockWritable(t))return;if(!!!n.getBlockData(t).chart){ZB(n,t);return}const r=[],i=nt.fromBlock(t),s=["line","bar","pie","radar"];let l=i.getCell({row:0,col:0}).container.innerText.trim().toLowerCase();new Set(s).has(l)||(l=s[0]);const c=[];for(let w=1;w<i.colCount;w++)c.push(i.getCell({row:0,col:w}).container.innerText);for(let w=1;w<i.rowCount;w++){const E=i.getCell({row:w,col:0}),x=E.container.innerText,A=[];for(let oe=1;oe<i.colCount;oe++){const Jn=i.getCell({row:w,col:oe}).container.innerText,Xt=Number.parseFloat(Jn)||0;A.push(Xt)}let O;const P=WB(t,E,i);P?O=window.getComputedStyle(n.rootElement).getPropertyValue(`--${P}`).trim():O=window.getComputedStyle(n.rootElement).getPropertyValue("--background-color").trim();let[U,tt,ot,ut]=O?$a.fromString(O).toRgbaArray():[];if(!U&&!tt&&!ot&&!ut){const oe=(w-1)%n.options.colors.length;O=n.options.colors[oe],[U,tt,ot,ut]=$a.fromString(O).toRgbaArray()}const dt=O,yt=$a.fromRgba([U,tt,ot,ut/3]).toHexString();r.push({label:x,data:A,borderColor:dt,backgroundColor:yt,borderWidth:2})}const a=wn(n,t);let u=null,f=a.querySelector(".editor-table-chart");f?u=f.chartObject:f=b("div",["editor-table-chart"],a);const m=f;d(Ip,m,"no chart container");const C=n.getComponentOptions("table"),v=(C==null?void 0:C.chartCdn)||"https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.min.js";try{await So(v,"editor-chartjs"),u&&l!==u.config.type&&(u.destroy(),u=null,Array.from(f.querySelectorAll(".editor-chartjs-canvas")).forEach(L=>{L.remove()}));const w=ja.default({},{type:l,data:{datasets:r,labels:c},options:{onClick:()=>{n.selection.selectBlock(t,0,0)}}});if(u)ja.default(u.config,w),u.update();else{const L=b("canvas",["editor-chartjs-canvas"],m).getContext("2d");u=new window.Chart(L,w),f.chartObject=u}}catch(w){Ip.error(`failed to resolve chart cdn: ${JSON.stringify(w)}`)}}async function xp(n,t){await Rn.lock("updateTableChart");try{await YB(n,t)}finally{Rn.release("updateTableChart")}}const Sp=ie.default(xp,1e3);let Tp=null;function xu(n,t,e){if(Tp!==t&&(Sp.flush(),Tp=t),e.updateNow){xp(n,t);return}Sp(n,t)}function Su(n,t){Ht(t)&&xu(n,t,{updateNow:!1})}function QB(n,t){Ht(t)&&xu(n,t,{updateNow:!0})}const $e={SCROLL:"container-scroll-tool",COMMON:"container-border-shadow",RIGHT:"container-right-border-shadow",LEFT:"container-left-border-shadow",LAYOUT_SIGN:"container-layout-border-shadow",ACTIVE:"active"},hc={SCROLL_BAR:"container-scrollbar",FIXED:"fixed"},mo={SCROLL_CONTAINER:"scroll-container",TOOL:"container-scroll-tool",CONTAINER:"scroll-container-root",MAC:"mac",SCROLL_AREA:"scroll-area"};function fc(n,t){return n.containers.get(t)}function Dp(n){return n.closest(`.${mo.SCROLL_CONTAINER}`)}function sn(n){return n.firstElementChild}function Ee(n){return n.closest(`.${mo.CONTAINER}`)}function as(n){const t=Ee(n);let e=t.querySelector(`:scope >.${mo.TOOL}`);return e||(e=b("div",[mo.TOOL],t)),e}function KB(n){return Ee(n).firstElementChild}function ds(n){const t=window.getComputedStyle(n);return{paddingBottom:parseFloat(t.paddingBottom),paddingTop:parseFloat(t.paddingTop),paddingLeft:parseFloat(t.paddingLeft),paddingRight:parseFloat(t.paddingRight)}}function Tu(n,t){const e=Ee(t),o=fc(n,e),r=(o==null?void 0:o.safeRightSpace)||0,i=(o==null?void 0:o.safeLeftSpace)||0,l=(o==null?void 0:o.locatingContainer).getBoundingClientRect(),c=e.getBoundingClientRect(),a=c.width;let u=Math.floor(c.left-l.left-i);u<0&&(u=0);let f=l.right;f-=r;let m=f-c.right;return m<0&&(m=0),u=Math.round(u),m=Math.round(m),{originWidth:a,maxLeft:u,maxRight:m}}function JB(n,t){const e=Tu(n,t),{maxLeft:o}=e;t.style.marginLeft=`${0-o}px`,t.style.paddingLeft=`${o}px`}function XB(n,t){const e=Tu(n,t);t.style.marginRight=`${0-e.maxRight}px`}function tE(n){if(n!==document.documentElement&&n!==document.body)return n.getBoundingClientRect();const t=0,e=0,o=document.documentElement.clientWidth,r=document.documentElement.clientHeight;return new DOMRect(t,e,o,r)}const Lp=y("scroll-bar-handle"),eE=2;function Ur(n){const t=as(n);let e=t.querySelector(`.${hc.SCROLL_BAR}`);return e||(e=b("div",[hc.SCROLL_BAR],t)),d(Lp,e instanceof HTMLDivElement,"invalid child for container tools"),e.firstElementChild||b("div",[],e),e}function mc(n,t){const e=Dp(t),o=Ur(e),{paddingLeft:r,paddingRight:i}=ds(t);e.style.marginLeft="",e.style.paddingLeft="",e.style.marginRight="";const s=Tu(n,e),{originWidth:l,maxRight:c}=s;XB(n,e),JB(n,e);const a=e.scrollWidth-e.clientWidth;d(Lp,o.firstElementChild instanceof HTMLDivElement,"invalid child for scroll bar"),o.style.width=`${l+c-r-i}px`,o.firstElementChild.style.width=`${l+c+a-r-i}px`}function nE(n,t){const e=sn(n),{paddingLeft:o}=ds(e);if(lt(t,"fixed")){const i=Ee(n).getBoundingClientRect();t.style.left=`${i.left+o}px`}else t.style.left=`${o}px`}function qr(n,t){const e=n.getParentScrollContainer(),o=tE(e),r=t.getBoundingClientRect(),i=Ur(t),s=i.getBoundingClientRect(),l=fc(n,Ee(t)),c=(l==null?void 0:l.barFloatWindowBottom)||0,a=sn(t),{paddingTop:u,paddingBottom:f}=ds(a),m=document.documentElement.clientHeight-c,C=o.top+e.clientHeight-m,v=m+Math.min(0,C);if(t.scrollWidth>t.clientWidth&&r.top+u<v-s.height&&r.bottom>v-s.height+f){M(i,hc.FIXED);const E=C>0?c:0;i.style.bottom=`${Math.max(document.documentElement.clientHeight-o.bottom,0)+eE+E}px`}else F(i,hc.FIXED),i.style.bottom=`${f-s.height}px`;nE(t,i)}class oE{constructor(t,e){h(this,"intersectionObserver");h(this,"handleIntersection",t=>{t.forEach(e=>{this.containers.get(Ee(e.target))?(this.handleIntersectionEntry(e),this.callback(e)):this.intersectionObserver.unobserve(e.target)})});h(this,"handleIntersectionEntry",t=>{const e=t.target;qr(this.scrollCore,e);const o=sn(e);mc(this.scrollCore,o)});this.scrollCore=t,this.callback=e;const r={root:this.scrollCore.getParentScrollContainer(),rootMargin:"20px",threshold:0};this.intersectionObserver=new IntersectionObserver(this.handleIntersection,r)}get containers(){return this.scrollCore.containers}bind(t){this.unbind(t),this.intersectionObserver.observe(t)}unbind(t){this.intersectionObserver.unobserve(t)}destroy(){this.intersectionObserver.disconnect()}}const Yo=y("container-scroll-shadow");function Mp(n,t,e){const o=n,r=t.getBoundingClientRect(),i=e.getBoundingClientRect(),{paddingTop:s,paddingBottom:l}=ds(e);o.style.top=`${i.top-r.top+s}px`,o.style.bottom=`${r.bottom-i.bottom+l}px`}function Rp(n,t){const e=n;t<24?e.style.width=`${(t/3).toFixed(2)}px`:e.style.width=""}function rE(n){const t=as(n);d(Yo,t,"no container tools");let e=t.querySelector(`.${$e.LEFT}`);if(!e){const l=sn(n),c=[$e.COMMON,$e.LEFT];e=b("div",c,t),d(Yo,e instanceof HTMLDivElement,"invalid child for container tools"),Mp(e,n,l)}d(Yo,e instanceof HTMLElement,"invalid child for container tools");const r=Ee(n).getBoundingClientRect(),i=n.getBoundingClientRect();e.style.left=`${i.left-r.left}px`;const s=n.scrollLeft;d(Yo,e instanceof HTMLDivElement,"invalid child for container tools"),Rp(e,s),M(e,$e.ACTIVE)}function iE(n){const t=as(n);let e=t.querySelector(`.${$e.RIGHT}`);if(!e){const l=sn(n),c=[$e.COMMON,$e.RIGHT];e=b("div",c,t),d(Yo,e instanceof HTMLDivElement,"no div, create shadow failed"),Mp(e,n,l)}d(Yo,e instanceof HTMLElement,"");const r=Ee(n).getBoundingClientRect(),i=n.getBoundingClientRect();e.style.right=`${r.right-i.right}px`;const s=n.scrollWidth-n.scrollLeft-n.clientWidth;d(Yo,e instanceof HTMLDivElement,"no shadow element"),Rp(e,s),M(e,$e.ACTIVE)}function sE(n){const e=as(n).querySelector(`.${$e.LEFT}`);e&&F(e,$e.ACTIVE)}function lE(n){const e=as(n).querySelector(`.${$e.RIGHT}`);e&&F(e,$e.ACTIVE)}function us(n){const t=Math.round(n.scrollLeft),e=sn(n),{paddingLeft:o,paddingRight:r}=ds(e);n.scrollWidth-o<=n.clientWidth-r||n.scrollWidth-o<=t+n.clientWidth-r?lE(n):iE(n),e&&n.scrollLeft>=e.offsetLeft+o?rE(n):sE(n)}class cE{constructor(t){h(this,"resizeObserver");h(this,"handleResizeEntry",t=>{const e=t.target,o=sn(e);us(e),mc(this.scrollCore,o),qr(this.scrollCore,e)});h(this,"handleContentResize",t=>{t.forEach(e=>{this.containers.get(Ee(e.target))?this.handleResizeEntry(e):this.unbind(e.target)})});this.scrollCore=t,this.resizeObserver=new ResizeObserver(this.handleContentResize)}get containers(){return this.scrollCore.containers}bind(t){this.unbind(t),this.resizeObserver.observe(t)}unbind(t){this.resizeObserver.unobserve(t)}destroy(){this.resizeObserver.disconnect()}}const Ap=y("container-scroll-observer");class aE{constructor(t,e){h(this,"handleContentScroll",t=>{const e=t.target;d(Ap,e instanceof Element,"invalid target for scroll event");const o=Ur(e);o.removeEventListener("scroll",this.handleScroll);const r=!0;this.fixScrollXPos(e,e.scrollLeft,r),this.bind(o),us(e),this.callback(e)});h(this,"handleScroll",t=>{const e=t.target;d(Ap,e instanceof HTMLElement,"");const o=e.scrollLeft,r=!1,i=KB(e);this.unbindContentScroll(i),this.fixScrollXPos(i,o,r),this.bindContentScroll(i),us(i),this.callback(i)});h(this,"handlePrevent",t=>{t.stopPropagation()});h(this,"bindContentScrollCore",t=>{this.unbindContentScroll(t),t.addEventListener("scroll",this.handleContentScroll)});h(this,"unbindContentScroll",t=>{t.removeEventListener("scroll",this.handleContentScroll)});h(this,"bindContentScroll",ie.default(this.bindContentScrollCore,300));h(this,"bind",ie.default(this.bindCore,200));this.scrollCore=t,this.callback=e}fixScrollXPos(t,e,o){const r=Ur(t);o||(t.scrollLeft=e),o&&r.scrollLeft!==e&&(r.scrollLeft=e)}bindCore(t){this.unbind(t),t.addEventListener("scroll",this.handleScroll),t.addEventListener("mousedown",this.handlePrevent)}unbind(t){t.removeEventListener("scroll",this.handleScroll),t.removeEventListener("mousedown",this.handlePrevent)}}class dE{constructor(t){h(this,"scrollContainers",new Set);h(this,"handleParentContainerScroll",()=>{this.scrollContainers.forEach(t=>{qr(this.scrollCore,t)})});h(this,"bindScrollContainer",t=>{const e=this.scrollContainers.size===0;this.scrollContainers.add(t),e&&this.eventTarget.addEventListener("scroll",this.handleParentContainerScroll)});h(this,"unbindScrollContainer",t=>{let e=!1;this.scrollContainers.has(t)&&(this.scrollContainers.delete(t),e=this.scrollContainers.size===0),e&&this.eventTarget.removeEventListener("scroll",this.handleParentContainerScroll)});this.scrollCore=t}get eventTarget(){const t=this.scrollCore.getParentScrollContainer();return t===document.documentElement?document:t}destroy(){this.eventTarget.removeEventListener("scroll",this.handleParentContainerScroll),this.scrollContainers.clear()}}const uE=y("scroll-wrap-resize-observer");class hE{constructor(t){h(this,"resizeObserver");h(this,"handleScrollWrapResize",t=>{t.forEach(e=>{this.containers.get(Ee(e.target))?this.handleScrollWrapResizeEntry(e):this.unbind(e.target)})});h(this,"handleScrollWrapResizeEntry",t=>{const e=t.target;d(uE,e instanceof HTMLElement,"invalid target for observer entry");const o=Dp(e);mc(this.scrollCore,e),us(o),qr(this.scrollCore,o)});this.scrollCore=t,this.resizeObserver=new ResizeObserver(this.handleScrollWrapResize)}get containers(){return this.scrollCore.containers}bind(t){this.unbind(t),this.resizeObserver.observe(t)}unbind(t){this.resizeObserver.unobserve(t)}destroy(){this.resizeObserver.disconnect()}}class fE{constructor(t){h(this,"resizeObserver");h(this,"scrollContainersMap",new Map);h(this,"handleResizeEntry",t=>{t==null||t.forEach(e=>{const o=sn(e);us(e),mc(this.scrollCore,o),qr(this.scrollCore,e)})});h(this,"handleResize",t=>{t.forEach(e=>{const o=this.scrollContainersMap.get(e.target);o!=null&&o.length&&this.handleResizeEntry(o)})});this.scrollCore=t,this.resizeObserver=new ResizeObserver(this.handleResize)}bind(t){var r,i;const e=Ee(t),o=(r=fc(this.scrollCore,e))==null?void 0:r.locatingContainer;this.scrollContainersMap.has(o)?(i=this.scrollContainersMap.get(o))==null||i.push(t):(this.scrollContainersMap.set(o,[t]),this.resizeObserver.observe(o))}unbind(t){var i,s;const e=Ee(t),o=(i=fc(this.scrollCore,e))==null?void 0:i.locatingContainer;if(!o)return;const r=this.scrollContainersMap.get(o);this.scrollContainersMap.set(o,(r==null?void 0:r.filter(l=>l!==t))||[]),(s=this.scrollContainersMap.get(o))!=null&&s.length||(this.resizeObserver.unobserve(o),this.scrollContainersMap.delete(o))}destroy(){this.scrollContainersMap.clear(),this.resizeObserver.disconnect()}}const vF="";class mE extends Wt.TypedEmitter{constructor(e){super();h(this,"containerIntersectionObserver",null);h(this,"containerResizeObserver",null);h(this,"containerScrollObserver",null);h(this,"parentContainerScrollObserver",null);h(this,"scrollWrapResizeObserve",null);h(this,"locatingContainerResizeObserver",null);h(this,"isWindowEventBind",!1);h(this,"containers",new Map);h(this,"handleScrollContainerScroll",e=>{this.emit("scroll",this,e)});h(this,"handleIntersection",e=>{const o=e.target,r=sn(o);e.isIntersecting?(this.load(),this.bindCore(o,r)):this.unbindCore(o,r)});h(this,"handleWindowEffect",()=>{var e;(e=this.getScrollContainerInViewable())==null||e.forEach(o=>{qr(this,o)})});this.parentContainer=e}load(){this.containerResizeObserver||(this.containerResizeObserver=new cE(this)),this.containerScrollObserver||(this.containerScrollObserver=new aE(this,this.handleScrollContainerScroll)),this.parentContainerScrollObserver||(this.parentContainerScrollObserver=new dE(this)),this.scrollWrapResizeObserve||(this.scrollWrapResizeObserve=new hE(this)),this.locatingContainerResizeObserver||(this.locatingContainerResizeObserver=new fE(this)),this.isWindowEventBind||(window.addEventListener("resize",this.handleWindowEffect),this.getParentScrollContainer()!==document.documentElement&&window.addEventListener("scroll",this.handleWindowEffect))}getParentScrollContainer(){return this.parentContainer}getScrollContainerInViewable(){var e;return(e=this.parentContainerScrollObserver)==null?void 0:e.scrollContainers}unbindCore(e,o){var i,s,l,c,a,u;const r=Ur(e);(i=this.containerScrollObserver)==null||i.unbindContentScroll(e),(s=this.containerScrollObserver)==null||s.unbind(r),(l=this.scrollWrapResizeObserve)==null||l.unbind(o),(c=this.containerResizeObserver)==null||c.unbind(e),(a=this.parentContainerScrollObserver)==null||a.unbindScrollContainer(e),(u=this.locatingContainerResizeObserver)==null||u.unbind(e)}bindCore(e,o){var i,s,l,c,a,u;if(this.unbindCore(e,o),!e.closest("body"))return;const r=Ur(e);(i=this.containerScrollObserver)==null||i.bindContentScrollCore(e),(s=this.containerScrollObserver)==null||s.bindCore(r),(l=this.scrollWrapResizeObserve)==null||l.bind(o),(c=this.containerResizeObserver)==null||c.bind(e),(a=this.parentContainerScrollObserver)==null||a.bindScrollContainer(e),(u=this.locatingContainerResizeObserver)==null||u.bind(e)}bind(e,o){this.containers.set(e,o);const r=e.firstElementChild;this.containerIntersectionObserver||(this.containerIntersectionObserver=new oE(this,this.handleIntersection)),this.containerIntersectionObserver.bind(r)}unbind(e){var i;const o=e.firstElementChild,r=sn(o);this.unbindCore(o,r),this.containers.delete(e),(i=this.containerIntersectionObserver)==null||i.unbind(o),this.containers.size||this.destroy()}destroy(){var e,o,r,i,s;this.containers.forEach((l,c)=>{this.unbind(c)}),this.containers.clear(),(e=this.parentContainerScrollObserver)==null||e.destroy(),(o=this.containerIntersectionObserver)==null||o.destroy(),(r=this.containerResizeObserver)==null||r.destroy(),(i=this.scrollWrapResizeObserve)==null||i.destroy(),(s=this.locatingContainerResizeObserver)==null||s.destroy(),window.removeEventListener("resize",this.handleWindowEffect),window.removeEventListener("scroll",this.handleWindowEffect)}}const gc=new Map;class gE extends Wt.TypedEmitter{constructor(e){super();h(this,"scrollListener");h(this,"scrollContainerElement");h(this,"handleContainerScroll",(e,o)=>{o===this.scrollContainerElement&&this.emit("scroll",this)});this.options=e;const o=b("div",[mo.CONTAINER],e.parentElement);It.isMac&&M(o,mo.MAC);const r=b("div",[mo.SCROLL_CONTAINER],o),i=b("div",[mo.SCROLL_AREA],r);i.style.paddingLeft=e.paddingLeft?`${e.paddingLeft}px`:"",i.style.paddingTop=e.paddingTop?`${e.paddingTop}px`:"",i.style.paddingBottom=e.paddingBottom?`${e.paddingBottom}px`:"",i.style.paddingRight=e.paddingRight?`${e.paddingRight}px`:"",i.appendChild(e.childElement);const s=e.parentContainer;this.scrollListener=gc.get(s),this.scrollListener||(this.scrollListener=new mE(s),gc.set(s,this.scrollListener)),this.scrollListener.unbind(o),this.scrollListener.bind(o,e),this.scrollListener.on("scroll",this.handleContainerScroll),this.scrollContainerElement=r}get rootElement(){return this.scrollContainerElement}get contentElement(){return sn(this.scrollContainerElement)}get scrollOptions(){return{...this.options}}handleBaseListenerDestroy(e){e.destroy()}destroy(){this.scrollListener.off("scroll",this.handleContainerScroll);const e=Ee(this.contentElement);e&&gc.forEach((o,r)=>{o.unbind(e),o.containers.size===0&&(this.handleBaseListenerDestroy(o),gc.delete(r))})}}function pE(n){return new gE(n)}const Du=y("column-width");function CE(n,t,e){BB(n,t).style.width=`${e}px`}function bE(n){const e=Array.from(n.querySelector("colgroup").children).map(c=>c.getBoundingClientRect().width);if(e[0]!==0)return e;const o=nt.fromTable(n),r=Array(o.colCount).fill(-1),i=n.getBoundingClientRect().left;o.toRealCells(o.cells).forEach(c=>{const a=c.col+c.colSpan-1;r[a]===-1&&(r[a]=c.cell.getBoundingClientRect().right-i)}),Du.debug(`cellRightOffsets1: ${r.join()}`);for(let c=0;c<r.length;c++){const a=r[c];if(a===-1||c===0)continue;let u=c-1;for(;r[u]===-1&&(u--,u!==-1););const f=u===-1?0:r[u],C=(a-f)/(c-u);for(let v=u+1;v<c;v++)r[v]=f+C*(v-u)}Du.debug(`cellRightOffsets2: ${r.join()}`);const s=[];let l=0;for(let c=0;c<r.length;c++){const a=r[c];s.push(a-l),l=a}return Du.debug(`widths: ${s.join()}`),s}function hs(n){return Array.from(n.querySelector("colgroup").children).map(o=>o.getBoundingClientRect().width||Number.parseInt(o.style.width,10)||100)}const Lu=100,vE=40,kE=y("table-resize-gripper"),Op=7,Mu=(Op-1)/2,yE=3;function wE(n,t,e){const{rows:o}=n;for(let r=0;r<o.length;r++){const i=o[r],s=Array.from(i.cells);for(let l=0;l<s.length;l++){const c=s[l],a=c.getBoundingClientRect(),u=Math.round(a.right);if(Math.abs(t-u)<=Mu&&a.top<=e&&e<=a.bottom)return c}}return null}function BE(n){return!!n.rootContainer.querySelector(".table-resize-gripper")}function Ru(n,t){return wn(n,t).querySelector(".table-resize-gripper")}function _p(n,t){const e=Ru(n,t);d(kE,!e,"resize gripper has already exists");const o=wn(n,t),r=b("div",["table-resize-gripper","table-indicator"],o);return b("div",["table-resize-gripper-indicator"],r),r}function Np(n,t,e){let o=Ru(n,t);o||(o=_p(n,t));const i=$t(t).getBoundingClientRect(),s=e.getBoundingClientRect(),l=0,c=i.height,a=n.getCustom(fo(t)).contentElement.getBoundingClientRect(),u=s.right-a.left;o.style.left=`${u-Mu-wu-ls}px`,o.style.top=`${l}px`,o.style.height=`${c}px`,o.style.width=`${Op}px`}function Au(n){n.rootContainer.querySelectorAll(".table-resize-gripper").forEach(t=>{t.remove()})}function EE(n,t,e){const r={...n.getBlockData(t),colsWidth:e};n.updateBlockData(t,r)}function IE(n,t,e,o){const r=t,i=nt.fromTable(e),s=i.getCellByCellElement(r),l=s.col+s.colSpan-1,c=hs(e);let a=o;const u=(m,C)=>{const v=C+1,w=m.col+m.colSpan;return c.slice(v,w).reduce((L,x)=>L+x,0)},f=new Set;for(let m=0;m<i.rowCount;m++){const C=i.getCell({row:m,col:l});if(f.has(C.cell))continue;f.add(C.cell);const v=C.cell,w=v.getBoundingClientRect();let E=o-w.left+Mu-yE;const L=is(v),x=m1(n,L)||vE*C.colSpan,A=u(C,l),O=x-A;E<O&&(E=O);const P=w.left+E;a=Math.max(a,P)}return a}const xE=y("table-resize-drag-drop");class SE{constructor(t,e,o,r){h(this,"cursor","col-resize");this.editor=t,this.elem=e,this.data=o,this.onEnd=r}onDragStart(t,e,o){}onDragging(t,e,o,r,i){const{table:s,block:l,draggingRefCell:c}=t.data,u=IE(this.editor,c,s,e.x-t.dragOffsetX)-s.getBoundingClientRect().left;d(xE,c,"no dragging cell");const m=nt.fromTable(s).getCellByCellElement(c),C=m.col+m.colSpan-1,w=hs(s).slice(0,C).reduce((L,x)=>L+x,0),E=u-w;CE(s,C,E),Np(this.editor,l,c),this.editor.selection.caret.update()}onDragEnd(t,e,o,r,i){const s=hs(t.data.table);EE(this.editor,t.data.block,s),Au(this.editor),this.onEnd&&(this.onEnd(e),this.onEnd=null)}}function TE(n,t){const e=document.elementFromPoint(t.x,t.y);if(!e)return null;const o=z(e);return!o||!n.contains(o)||!Ht(o)?null:o}y("table-resize");class DE{constructor(t){h(this,"draggingRefCell",null);h(this,"handleMouseMove",(t,e)=>{if(t.readonly||t.selectionHandler.isSelecting()&&!this.draggingRefCell||this.draggingRefCell)return;const o=e.target;if(!(o instanceof Element)||o.closest(".table-indicator"))return;const i=e,s=TE(t,i);if(!s||!fp(s)){Au(t);return}this.updateGripper(s,i.x,i.y)});this.editor=t,t.domEvents.addEventListener(document,"mousemove",this.handleMouseMove)}destroy(){this.editor.domEvents.removeEventListener(document,"mousemove",this.handleMouseMove)}updateGripper(t,e,o){const r=$t(t),i=wE(r,e,o);if(i){if(!Ru(this.editor,t)){if(BE(this.editor))return;const l=_p(this.editor,t),c={block:t,table:r,draggingRefCell:i};Za(new SE(this.editor,l,c,a=>{this.updateGripper(t,a.x,a.y)}))}Np(this.editor,t,i)}else Au(this.editor)}}function Pp(n){n.addCustom("table-mouse-event-handler",t=>new DE(t))}const $p=y("table-insert-column");function Hp(n,t,e){const o=$t(t),r=nt.fromTable(o),i=r.colCount;d($p,e>=0&&e<=i,`insert index ${e} is out of range [0, ${i}]`);const s=r.map(m=>m.containerId),l=new Set;n.doc.beginBatchUpdate();for(let m=0;m<s.length;m++){const C=s[m],v=C[e-1],w=C[e];if(e===0||e===C.length||v!==w){const E=pn(n.doc);C.splice(e,0,E)}else C.splice(e,0,v),l.add(v)}n.doc.endBatchUpdate();const c=Y.default(n.getBlockData(t));l.forEach(m=>{const C=`${m}_colSpan`,v=c[C];d($p,typeof v=="number"&&v>1,`no colSpan for containerId ${m}, ${v}`),c[C]=v+1});const a=c.colsWidth.concat();a.splice(e,0,Lu);const u=nt.virtualCellContainersGridToChildren(s),f={...c,cols:c.cols+1,children:u,colsWidth:a};Go(f),n.updateBlockData(t,f)}const pc=y("table-insert-row");function jp(n,t,e){const o=$t(t),r=nt.fromTable(o),i=r.rowCount;d(pc,e>=0&&e<=i,`insert index ${e} is out of range [0, ${i}]`);const s=r.map(m=>m.containerId),l=new Set;n.doc.beginBatchUpdate();const c=[];for(let m=0;m<r.colCount;m++){const C=e>0&&s[e-1][m],v=e<r.rowCount&&s[e][m];if(d(pc,C||v,"no top and bottom cell"),e===0||e===r.rowCount||C!==v){const w=pn(n.doc);c.push(w)}else d(pc,C,"no top cell"),c.push(C),l.add(C)}n.doc.endBatchUpdate(),s.splice(e,0,c);const a=Y.default(n.getBlockData(t));l.forEach(m=>{const C=`${m}_rowSpan`,v=a[C];d(pc,typeof v=="number"&&v>1,`no rowSpan for containerId ${m}, ${v}`),a[C]=v+1});const u=nt.virtualCellContainersGridToChildren(s),f={...a,rows:a.rows+1,children:u};Go(f),n.updateBlockData(t,f)}const Ou=y("paste-table-in-table-block");function LE(n,t,e,o){let r=nt.fromBlock(e);const i=t.blocks.root[0];d(Ou,i,"no table data"),d(Ou,i.type==="table",`table data type is not table, but ${i.type}`);const s=i,l=r.getCellByCellElement(o),c=s.cols,a=s.rows,u=l.col,f=l.row,m=u+c,C=f+a,v=[];for(let w=u;w<m&&w<r.colCount;w++)for(let E=f;E<C&&E<r.rowCount;E++){const L=r.getCell({col:w,row:E});L.virtual?L.virtual&&v.push({col:w,row:E}):(L.colSpan>1||L.rowSpan>1)&&v.push({col:w,row:E})}n.undoManager.runInGroup(()=>{if(v.forEach(x=>{const A=nt.fromBlock(e).getCell(x);(A.colSpan>1||A.rowSpan>1)&&bu(n,e,x)}),m>r.colCount)for(let x=r.colCount;x<m;x++)Hp(n,e,x);if(C>r.rowCount)for(let x=r.rowCount;x<C;x++)jp(n,e,x);r=nt.fromBlock(e);const w=new fu(s);let E;for(let x=0;x<w.colCount;x++)for(let A=0;A<w.rowCount;A++){const O=w.getCell({col:x,row:A});if(!O.virtual){const P=K1(n.editorBlocks,t,O.containerId),U=u+x,tt=f+A,ot={col:U,row:tt},ut=r.getCellContainer(ot);w2(n,ut,P),E=ut}}d(Ou,E,"no last container");const L=Gt(E);n.selection.selectBlock(L,Z(n,L))})}const Fp=y("paste-in-table-block");class ME{constructor(t){this.editor=t,setTimeout(()=>{t.input.addHandler(this)})}destroy(){}async handleBeforePasteDoc(t,e){if(!t.selection.range.isSimple()||t.selection.range.start.offset!==0)return!1;const r=t.selection.startBlock,i=H(r);if(Ct(i)||!g1(t,i))return!1;const s=z(i);if(d(Fp,s,"no parent block"),!Ht(s)||e.blocks.root.length!==1||e.blocks.root[0].type!=="table")return!1;Fp.debug("paste child table in table");const a=nt.fromBlock(s).getCellByContainerId(V(i)).cell;return LE(t,e,s,a),!0}}function zp(n){n.addCustom("table-block-paste-event",t=>new ME(t))}const _u=y("table-select-columns");function RE(n,t,e,o,r){d(_u,Ht(t),"is not a table block");const i=nt.fromBlock(t);d(_u,e>=0&&e<i.colCount,"invalid from"),d(_u,o>0&&e+o<=i.colCount,"invalid count");const s=i.getCell({row:0,col:e}),l=i.getCell({row:i.rowCount-1,col:e+o-1}),c=bt(t,s.containerId,{colIndex:e,rowIndex:0}),a=bt(t,l.containerId,{colIndex:e+o-1,rowIndex:i.rowCount-1});r!=null&&r.reverse?n.selection.setSelection(a,c):n.selection.setSelection(c,a)}const Nu=y("table-select-columns");function AE(n,t,e,o,r){d(Nu,Ht(t),"is not a table block");const i=nt.fromBlock(t);d(Nu,e>=0&&e<i.rowCount,"invalid from"),d(Nu,o>0&&e+o<=i.rowCount,"invalid count");const s=i.getCell({row:e,col:0}),l=i.getCell({row:e+o-1,col:i.colCount-1}),c=bt(t,s.containerId,{rowIndex:e,colIndex:0}),a=bt(t,l.containerId,{rowIndex:e+o-1,colIndex:i.colCount-1});r!=null&&r.reverse?n.selection.setSelection(a,c):n.selection.setSelection(c,a)}const kF="",Vp=y("get-toolbar-reference-client");function OE(n,t){const e=n.selection.range;if(!e.isSimple()){d(Vp,e.start.blockId===e.end.blockId,"invalid selection range");const s=n.getBlockById(e.start.blockId);d(Vp,ct(n,s),"not a complex block");const l=kt(n,s);if(l.getTextToolbarReferenceClient){const c=l.getTextToolbarReferenceClient(n,s);if(c)return c}}const o=e.isReverse()?t.start:t.end,r=Ut(n,{anchor:o,focus:o}),i=Ao(n,t.block,r);if(i.length!==0)return i[0]}function _E(n){var t,e;if(n.children){let o=!1;const r=[];for(const i of n.children){if((t=i.states)!=null&&t.includes("checked")){o=!0;break}(e=n.defaultCheckedChildren)!=null&&e.includes(i.id)&&r.push(i)}if(!o&&(r==null?void 0:r.length))for(const i of r)Array.isArray(i.states)?i.states.push("checked"):i.states=["checked"]}}function Cc(n){const t=(r,i)=>{const s=r.findIndex(c=>c.id===i.id);if(s===-1){r.push(i);return}const l=r[s];if(l.value!==i.value&&delete l.value,!!l.states){if(!i.states){l.states=[];return}l.states=Fa.default(l.states,i.states)}},e=[],o=new Map;return n.forEach(r=>{var i,s;(i=r.children)!=null&&i.length&&(o.has(r.id)?(s=o.get(r.id))==null||s.push(...r.children):o.set(r.id,[...r.children])),t(e,r)}),o.forEach((r,i)=>{const s=e.find(l=>l.id===i);s&&(s.children=Cc(r),_E(s))}),e}function bc(n){return n.getCustom("toolbar-handler")}const yF="";class NE{constructor(){h(this,"linkPopup",null);h(this,"form",{});h(this,"onFinished",null);h(this,"onClose",null);h(this,"handleOk",async()=>{var t;try{await this.checkValue();const{linkText:e,linkUrl:o}=this.form;(t=this.onFinished)==null||t.call(this,e.getInputValue()||o.getInputValue(),o.getInputValue()),this._destroy()}catch{}});h(this,"handleClose",()=>{var t;(t=this.onClose)==null||t.call(this),this._destroy()});h(this,"onShow",()=>{setTimeout(()=>{var t;(t=this.form.linkText)==null||t.getField().focus()},400)});h(this,"onChange",()=>{var e;const t=(e=this.linkPopup)==null?void 0:e.content.querySelector(".submit-button");t.disabled=!1});h(this,"handleTextKeyboard",t=>{var e;if(!t.isComposing){if(t.key==="Enter"){(e=this.form.linkUrl)==null||e.getField().focus(),t.stopPropagation();return}t.key==="Escape"&&this.handleClose()}});h(this,"handleUrlKeyboard",t=>{if(!t.isComposing){if(t.key==="Enter"){this.handleOk(),t.preventDefault();return}t.key==="Escape"&&this.handleClose()}})}async checkValue(){const{linkUrl:t}=this.form;if(!t.getInputValue())throw t.setFieldError(S.t("link.urlPlaceholder")),new Error(S.t("link.urlPlaceholder"))}editLink(t){var u,f;const{target:e,linkText:o,linkUrl:r,onFinished:i,onClose:s,placement:l="bottom-start"}=t;this.linkPopup=new lc(this.createPopupContent(o,r)),this.linkPopup.addListener("show",this.onShow),this.linkPopup.manualShow(e,{theme:"light",placement:l}),this.onFinished=i,s&&(this.onClose=s);const c=(u=this.linkPopup)==null?void 0:u.content.querySelector(".submit-button"),a=(f=this.linkPopup)==null?void 0:f.content.querySelector(".cancel-button");c==null||c.addEventListener("click",this.handleOk),a==null||a.addEventListener("click",this.handleClose)}createPopupContent(t,e){const o=b("div",["link-popup-content"],null);this.form.linkText=cc(o,{label:S.t("link.textLabel"),required:!1,placeholder:S.t("link.textPlaceholder"),defaultValue:t,onChange:this.onChange,onKeyDown:this.handleTextKeyboard}),this.form.linkUrl=cc(o,{className:"link-popup-gap",label:S.t("link.urlLabel"),required:!0,placeholder:S.t("link.urlPlaceholder"),defaultValue:e,onChange:this.onChange,onKeyDown:this.handleUrlKeyboard});const r=b("div",["link-popup-footer"],o);b("button",["cancel-button"],r,S.t("link.cancelText"));const i=b("button",["submit-button"],r,S.t("link.submitText"));return i.disabled=!0,o}_destroy(){var o,r,i,s;const t=(o=this.linkPopup)==null?void 0:o.content.querySelector(".submit-button"),e=(r=this.linkPopup)==null?void 0:r.content.querySelector(".cancel-button");t==null||t.removeEventListener("click",this.handleOk),e==null||e.removeEventListener("click",this.handleClose),this.onFinished=null,this.onClose=null,this.form={},(i=this.linkPopup)==null||i.removeAllListeners(),(s=this.linkPopup)==null||s.destroy()}destroy(){this._destroy()}}function vc(n,t){n.addCustom("link-editor",()=>new NE).editLink(t)}const PE=y("link-popup");function $E(n){return lt(n,"link")}function kc(n){var t,e;return(e=(t=n.getAttribute("link"))!=null?t:n.textContent)!=null?e:""}function HE(n,t,e){var r,i,s,l;if(n.isBlockWritable(t)&&e&&Me(e)){const c=e,a=(i=(r=n.editorBoxes.getBoxClass(Si(c))).getBoxProperties)==null?void 0:i.call(r,n,c);return a!=null&&a.boxCommands?(l=(s=a.boxCommands["hovering-toolbar"])==null?void 0:s.commands)!=null?l:[]:[]}return n.isWritable()&&e&&j(n,t)&&$E(e)?[{id:"link-text",name:kc(e),element:b("span",["link-href-button"],null,kc(e))},{id:"edit-link",name:"Edit",icon:sc},{id:"remove-link",name:"Remove link",icon:D5}]:Jm(n,t,"hovering-toolbar")}function jE(n,t,e){var c;const o=Er(t,e);n.selection.selectBlock(t,o.start,o.end);const r=(c=e.textContent)!=null?c:"",i=kc(e);vc(n,{target:e,linkText:r,linkUrl:i,onFinished:(a,u)=>{try{const f=n.getBlockText(t),m=R1(f,o.start,o.end-o.start),C=xr(m,o.start,a,{link:u});n.setBlockText(t,C),n.selection.selectBlock(t,o.start+a.length),n.focus()}catch(f){PE.error(f)}},onClose:()=>{n.selection.selectBlock(t,o.end),n.focus()}})}function FE(n,t,e){const o=Er(t,e),r=n.getBlockText(t),i=kc(e),s=Sr(o.start,o.end-o.start,r,"link",i);n.setBlockText(t,s),n.selection.selectBlock(t,o.end)}function zE(n,t,e,o){var s,l,c;if(e){if(n.isBlockWritable(t)&&Me(e)){const u=e,f=(l=(s=n.editorBoxes.getBoxClass(Si(u))).getBoxProperties)==null?void 0:l.call(s,n,u);if(f!=null&&f.boxCommands){f.boxCommands["hovering-toolbar"].executeCommand(n,t,u,o);return}return}const a=bc(n);a.disableTextToolbar(),a.hide(),setTimeout(()=>{a.enableTextToolbar()},1e4),o.id==="edit-link"?jE(n,t,e):o.id==="remove-link"&&FE(n,t,e);return}const r=Km(n,t);if(!r)return;const i=(c=r.blockCommands)==null?void 0:c["hovering-toolbar"];!i||i.executeCommand(n,t,o)}const VE=[Qd,Kd,Jd,Xd,tu,eu,nu,ou];class UE{constructor(t){h(this,"id","BlockTurnIntoCommandProvider");this.editor=t}getHeadingIndex(){return 6}getAvailableCommands(t,e,o){if(j(t,e)){const r=G(e),i=it(e),s=We(t,e),c=t.getBlockData(e).heading,a=[];for(let f=0;f<this.getHeadingIndex();f++)a.push({id:`heading-${f+1}`,name:S.t("commands.heading",{name:`${f+1}`}),icon:VE[f],states:c===f+1?["checked"]:[],value:`${f+1}`});return[{id:"turn-into",name:"",blockId:r,blockType:i,blockKind:s,element:f=>{var C;const m=b("span",["toolbar-item-name-container"],null);for(const v of f.children)if((C=v.states)!=null&&C.includes("checked"))return m.innerHTML=v.icon||ns,m;return m.innerHTML=ns,m},groupIndex:200,dropdown:!0,manualShowChildren:!0,childrenPlacement:"bottom-start",defaultCheckedChildren:["text"],children:[{id:"text",name:S.t("commands.text"),icon:ns,states:c?[]:["checked"]},...a],childrenType:"menu"}]}return[]}applyHeadingStyle(t,e,o){t.updateBlockData(e,{heading:o})}executeCommand(t,e,o,r){if(j(t,e)&&(r.id.startsWith("heading-")||r.id==="text")){const i=r.value?Number(r.value):null;return this.applyHeadingStyle(t,e,i),!0}return!1}}const yc=y("list-block");function at(n){return it(n)==="list"}function jt(n){d(yc,at(n),"not a list block")}function He(n){jt(n);const t=n.getAttribute("data-list-type");return d(yc,t,"no list type"),t}function wc(n){return at(n)&&He(n)==="text-only"}function Ie(n){var t,e;return jt(n),(e=Number.parseInt((t=n.getAttribute("data-list-start"))!=null?t:"1",10))!=null?e:1}function xe(n){var t,e;return jt(n),(e=Number.parseInt((t=n.getAttribute("data-list-level"))!=null?t:"1",10))!=null?e:1}function Qo(n){jt(n);const t=n.getAttribute("data-list-group-id");return d(yc,t,"no group id"),t}function go(n){var i,s,l,c,a;jt(n);const t=(i=n.getAttribute("data-list-type"))!=null?i:"ordered",e=(l=Number.parseInt((s=n.getAttribute("data-list-start"))!=null?s:"1",10))!=null?l:1,o=(a=Number.parseInt((c=n.getAttribute("data-list-level"))!=null?c:"1",10))!=null?a:1,r=n.getAttribute("data-list-group-id");return d(yc,r,"no group id"),{type:t,start:e,level:o,groupId:r}}function Bc(n){switch(n){case"ordered":return{ordered:!0,checkbox:null,textOnly:null};case"unordered":return{ordered:!1,checkbox:null,textOnly:null};case"checked":return{checkbox:"checked",ordered:!1,textOnly:null};case"unchecked":return{checkbox:"unchecked",ordered:!1,textOnly:null};case"text-only":return{checkbox:null,ordered:!1,textOnly:!0};default:return{checkbox:null,ordered:!0,textOnly:!1}}}function qn(n){jt(n);const{level:t,groupId:e,type:o}=go(n);let r=gt(n);for(;r;){if(!at(r))return null;const{level:i,groupId:s,type:l}=go(r);if(i<t)return null;if(t===i&&e===s&&(l==="text-only"||o==="text-only"||o===l))return r;r=gt(r)}return null}function Ko(n){jt(n);const{level:t,groupId:e,type:o}=go(n);let r=ht(n);for(;r;){if(at(r)){const{level:i,groupId:s,type:l}=go(r);if(t===i&&e===s&&(l==="text-only"||o==="text-only"||o===l))return r;if(i<t)return null}r=ht(r)}return null}function Up(n){jt(n);const t=[];let e=qn(n);for(;e;)t.unshift(e),e=qn(e);return t}function Ec(n){jt(n);const t=[];let e=Ko(n);for(;e;)t.push(e),e=Ko(e);return t}function fs(n){jt(n);let t=qn(n);for(;t;){const e=qn(t);if(!e)return t;t=e}return n}function qE(n){jt(n);let t=Ko(n);for(;t;){const e=Ko(t);if(!e)return t;t=e}return null}function WE(n,t){const e=Up(n),o=Ec(n);return t.withSelf?[...e,n,...o]:[...e,...o]}function Ic(n,t,e,o){var i;const r=(i=o==null?void 0:o.groupId)!=null?i:N();t.forEach(s=>{const l=n.getBlockData(s);if(l.start!==e||(o==null?void 0:o.resetGroupId)){const c={...l,start:e};o!=null&&o.resetGroupId&&(c.groupId=r),n.updateBlockData(s,c)}l.textOnly||(e+=1)})}function Pu(n,t,e,o){const r=WE(t,{withSelf:!0});r.length!==0&&Ic(n,r,e,o)}function GE(n){const t={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1};let e="",o=n;return Object.entries(t).forEach(([r,i])=>{for(;o>=i;)e+=r,o-=i}),e.toLowerCase()}const ZE="abcdefghijklmnopqrstuvwxyz";function qp(n){if(n<=0)return`${n}`;const t=(n-1)%26,e=Math.floor((n-1)/26),o=ZE[t];return e?qp(e)+o:o}function YE(n){return`${n}`}const Wp=[YE,qp,GE];function QE(n,t){const e=Wp[(n-1)%Wp.length];return e(t)}function KE(n){return["\u2022","\u25E6","\u25AA"][(n-1)%3]}class Jo{constructor(t,e,o){h(this,"listStart");h(this,"listBrother",null);this.editor=t,this.options=o;const r=fs(e),i=Ie(r);this.listStart=i,this.listBrother=r,o!=null&&o.resetStart&&(this.listStart=1)}fix(){!this.listBrother||Pu(this.editor,this.listBrother,this.listStart,this.options)}}function JE(n,t,e=1){if(!t)return null;let o=gt(n);for(;o;){const r=o.getAttribute("data-style-heading"),i=Number(o.getAttribute("data-list-level"));if(r){if(r<t)return null;if(r===t&&i===e)return at(o)?o:null}o=gt(o)}return null}function Gp(n,t){const e=n.getAttribute("data-style-heading"),o=JE(n,e);if(o)return o;const r=gt(n);if(r&&at(r)&&He(r)===t)return r;const i=ht(n);return i&&at(i)&&He(i)===t?i:null}function XE(n,t,e){var E,L,x;const o=(E=e.data)!=null?E:{},r=1,i=(L=o.listType)!=null?L:"ordered";if(i==="text-only")return null;const s=n.getBlockData(t);let l=(x=s.text)!=null?x:[];const c=n.selection.range.focus;if(!c.isSimple())return null;let u=Tt(l);const f=c.offset;f<=ce(l)&&(l=Ae(l,f).right,u=u.substring(0,f));let m=1;i==="ordered"&&(m=Number.parseInt(u,10)||1);let C=N();const v=Gp(t,i);if(v){if(K(t)>K(v))m=Ie(v)+1;else{const A=Ie(v);A>1&&(m=A-1)}C=Qo(v)}const w={id:N(),type:"list",level:r,start:m,groupId:C,ordered:!1,text:l};return s.quoted&&(w.quoted=!0),s.heading&&(w.heading=s.heading),i==="ordered"?w.ordered=!0:(i==="checked"||i==="unchecked")&&(w.checkbox=i),{blockData:w,onConverted:(A,O)=>{new Jo(A,O).fix()}}}const tI=8,Lt=y("list-block");class xc{constructor(t,e){h(this,"listStart",0);h(this,"listBrother",null);if(this.editor=t,wc(e))return;const o=fs(e),r=Ie(o);this.listStart=r,o===e?this.listBrother=Ko(o):this.listBrother=o}fix(){!this.listBrother||Pu(this.editor,this.listBrother,this.listStart)}}function eI(n,t,e){n.getBlockData(t).quoted&&(e.quoted=!0)}function $u(n,t,e,o){if(Lt.debug("drag a block on a list block"),!j(n,t))return!1;d(Lt,at(e),"target is not a list block");const{type:r,start:i,level:s,groupId:l}=go(e),c=o==="after"?i+1:i,a=n.getBlockData(t),u={id:N(),type:"list",groupId:l,level:s,start:c,text:a.text,...Bc(r)};eI(n,e,u);let f=K(e);const m=H(e);o==="after"&&(f+=1);let C=null;at(t)&&(C=new xc(n,t));const v=n.insertBlock(V(m),f,u,Tl(u.id,0));return n.deleteBlock(t),new Jo(n,v).fix(),C==null||C.fix(),!0}function nI(n,t,e,o){if(Lt.debug("drag a list between text blocks"),o==="after"){const a=ht(e);if(a&&at(a))return $u(n,t,a,"before")}if(o==="before"){const a=gt(e);if(a&&at(a))return $u(n,t,a,"after")}const i={...n.getBlockData(t),groupId:N(),start:1,level:1};let s=K(e);const l=H(e);o==="after"&&(s+=1),n.insertBlock(V(l),s,i,Tl(i.id,0));const c=new xc(n,t);return n.deleteBlock(t),c.fix(),!0}function oI(n,t,e,o,r){if(sl(e))return!1;const{blockId:i}=e,s=n.getBlockById(i);d(Lt,s,"no dragged block");const{isSourceBlock:l,targetBlock:c}=r;return!l&&c?(d(Lt,t===c,"block !== target block"),d(Lt,at(c),"target is not a list block"),$u(n,s,c,o)):nI(n,s,c,o)}function Zp(n){return n.textOnly?"text-only":n.checkbox?n.checkbox:n.ordered?"ordered":"unordered"}function rI(n){var e,o;if(n.checkbox||n.textOnly)return"";const t=(e=n.level)!=null?e:1;return n.ordered?`${QE(t,(o=n.start)!=null?o:1)}.`:KE(t)}const iI=`<?xml version="1.0" ?>
415
+ </svg>`;function rp(n,t){var e;if(M(t,"menu-item"),!n.element){if(n.type==="section"){const o=b("div",["section-name"],null,n.name);t.appendChild(o)}else if(n.type!=="separator"){if(n.icon){const i=b("div",["menu-item-icon"],null);n.icon&&(i.innerHTML=n.icon),t.appendChild(i)}const o=b("div",["menu-item-name"],null,n.name);t.appendChild(o);const r=Vd(n);if(r&&b("div",["item-shortcut","text"],t,r),n.children&&!n.element){const i=b("div",["menu-item-sub-indicator"],null);i.innerHTML=Zd,t.appendChild(i)}if((e=n.states)!=null&&e.includes("checked")){const i=b("div",["menu-item-checked-icon"],null);i.innerHTML=O5,t.appendChild(i)}}}}class Wo extends nc{constructor(t,e,o){super(t,e,{autoClose:!0,disablePageScroll:!0,...o})}manualShow(t,e){const o={theme:"menu",...e};super.manualShow(t,o)}initCommandBarElement(t){M(t,"menu")}initItemElement(t,e){rp(t,e)}}function lB(n,t,e){var o;return new Wo((o=n.children)!=null?o:[],t,{...e,parentItem:n})}class os extends nc{constructor(t,e,o){super(t,e,{itemElementTag:"button",tippyArrow:!1,...o})}getSubBarOptions(t){var r,i;const e=()=>{const s=this.getItemElementById(t.id),c=this.content.getBoundingClientRect(),a=s.getBoundingClientRect();return new DOMRect(a.left,c.top,a.width,c.height)};return{placement:(r=t.childrenPlacement)!=null?r:"top",getReferenceClientRect:e,offset:(i=t.childrenOffset)!=null?i:[0,4]}}manualShow(t,e){const o={theme:"toolbar",...e};super.manualShow(t,o)}initCommandBarElement(t){M(t,"toolbar")}initItemElement(t,e){e.setAttribute("data-button-id",t.id),(!t.children||t.children.length===0)&&this.options.tooltipId&&(e.setAttribute(`data-editor-tooltip-${this.options.tooltipId}`,t.name),t.desc&&e.setAttribute(`data-editor-tooltip-desc-${this.options.tooltipId}`,t.desc));const o=e;if(!t.element)if(t.icon){const r=b("span",["toolbar-item-icon-container"],o);t.icon.startsWith("<")?r.innerHTML=t.icon:r.innerText=t.icon}else{const r=b("span",["toolbar-item-name-container"],o);r.innerText=t.name}if(t.dropdown){e.setAttribute("data-dropdown","true");const r=b("span",["toolbar-item-dropdown-container"],o);r.innerHTML=oc}t.states&&(t.states.indexOf("checked")!==-1&&M(o,"checked"),t.states.indexOf("disabled")!==-1&&(o.disabled=!0))}}function cB(n,t,e){var o;return new os((o=n.children)!=null?o:[],t,{...e,parentItem:n})}class aB extends ho{constructor(){super(...arguments);h(this,"tippyInstance",null)}create(e,o){var r;if(this.tippyInstance&&(this.tippyInstance.destroy(),this.tippyInstance=null),this.tippyInstance=za.default(e,{interactive:!0,content:this.content,hideOnClick:!1,placement:(r=o==null?void 0:o.placement)!=null?r:"bottom-start",maxWidth:500,arrow:this.options.tippyArrow,appendTo:document.body,onShow:this.handleShow,onHidden:this.handleHidden,delay:o==null?void 0:o.delay}),o!=null&&o.point){const{x:i,y:s}=o.point;this.tippyInstance.setProps({getReferenceClientRect:()=>new DOMRect(i,s,0,0)})}this.parentItem||(document.addEventListener("keydown",this.handleDocumentKeydown),document.addEventListener("mousedown",this.handleDocumentMouseDown))}close(){var e;super.close(),this.isVisible&&((e=this.tippyInstance)==null||e.hide())}destroy(){var e;(e=this.tippyInstance)==null||e.destroy(),this.tippyInstance=null,super.destroy()}getCommandBarRoot(){return this.content.closest("[data-tippy-root]")}get isVisible(){var e,o;return(o=(e=this.tippyInstance)==null?void 0:e.state.isVisible)!=null?o:!1}}class dB extends aB{constructor(t,e,o){super(t,e,{autoClose:!0,disablePageScroll:!0,...o})}initCommandBarElement(t){M(t,"menu")}initItemElement(t,e){rp(t,e)}}const gF="";ho.registerManualCommandBar("menu",lB),ho.registerManualCommandBar("toolbar",cB);const ip=y("ui-base");class lc extends nc{constructor(t,e){var i;const r=[{id:(i=e==null?void 0:e.id)!=null?i:`popup-${N()}`,name:"",element:t}];super(r)}initCommandBarElement(t){M(t,"popper")}initItemElement(t,e){}get popupContent(){const t=this.items[0];d(ip,t,"no dialog item");const e=typeof t.element=="function"?t.element(t):t.element;return d(ip,e,"no item element"),e}}const pF="",sp=y("ui-base");class rs extends nc{constructor(e,o){super(rs.getCommandItems(e,o),void 0,{disablePageScroll:!0,...o});h(this,"handleDocumentMouseDown",e=>{})}initCommandBarElement(e){M(e,"dialog","manual")}initItemElement(e,o){}show(e,o){this.manualShow(e,{...o,theme:"light"})}get dialogContent(){const e=this.items[0];d(sp,e,"no dialog item");const o=e.element;return d(sp,o,"no item element"),o}static getCommandItems(e,o){var s;return[{id:(s=o==null?void 0:o.id)!=null?s:`manual-dialog-${N()}`,name:"",element:e}]}}const uB=[-1,6,0,1,2,3,4,5],hB=[-1,6,0,1,2,3,4,5,14,13,7,8,9,10,11,12],lp=y("color-palette");function cp(n,t,e,o){d(lp,n>0,"no color in palette");const r=t||1;d(lp,r>0,`invalid palette rows: ${r}`);const i=n/r,s=b("div",["palette-container",o],null);for(let l=0;l<r;l++){const c=b("div",["palette-container-row"],s);for(let a=0;a<i;a++){const u=e(l*i+a);c.appendChild(u)}}return s}function fB(n){const t=b("button",["color-button"],null),e=uB[n];return t.setAttribute("data-color-index",`${e}`),t.innerHTML=Gd,t}function mB(n){const t=b("button",["background-color-button"],null),e=hB[n];return t.setAttribute("data-color-index",`${e}`),t}function gB(){const n=b("div",["clear-button-container"],null),t=b("button",["clear-button"],n);return t.innerText=S.t("colorPalette.reset"),n}function pB(n){const t=b("div",["color-palette"],null);return n.color!==!1&&(b("div",["bar-desc"],t,S.t("colorPalette.colorDesc")),t.appendChild(cp(8,1,fB,"color"))),n.backgroundColor!==!1&&(b("div",["bar-desc"],t,S.t("colorPalette.backgroundDesc")),t.appendChild(cp(16,2,mB,"background-color"))),n.clearColorButton!==!1&&t.appendChild(gB()),t}function CB(n,t,e){const o=t==="color"?"color":"background-color",r=n.querySelector(`.${o} button.selected`);r&&F(r,"selected"),e===null&&(e=-1);const i=n.querySelector(`.${o} button[data-color-index="${e}"]`);i&&M(i,"selected")}const CF="",bB={};class ap extends Wt.TypedEmitter{constructor(e=bB){super();h(this,"root");h(this,"handleClick",e=>{const o=e.target;if(!o||!(o instanceof Element))return;const r=o.closest("button");if(!r)return;if(lt(r,"clear-button")){this.setColor("backgroundColor",null),this.setColor("color",null),this.emit("onClick","clearColor",0);return}const i=r.getAttribute("data-color-index");if(!i)return;const s=Number.parseInt(i,10);Number.isNaN(s)||(lt(r,"color-button")?s===-1?(this.setColor("color",null),this.emit("onClick","clearColor",1)):(this.setColor("color",s),this.emit("onClick","color",s)):s===-1?(this.setColor("backgroundColor",null),this.emit("onClick","clearColor",2)):(this.setColor("backgroundColor",s),this.emit("onClick","backgroundColor",s)))});this.options=e,this.root=pB(e),this.root.addEventListener("click",this.handleClick)}destroy(){this.removeAllListeners(),this.root.removeEventListener("click",this.handleClick)}setColor(e,o){CB(this.root,e,o)}}class cu{constructor(t,e){h(this,"name","Color Palette");h(this,"element");h(this,"palette");h(this,"closeable",null);this.id=t,this.palette=new ap(e),this.element=this.palette.root}setCloseable(t){this.closeable=t}destroy(){this.palette.destroy(),this.closeable=null}}function vB(){const n=b("button",["color-button"],null);return n.innerHTML=Gd,n}function au(n,t){const[e,o]=t;e===null?n.removeAttribute("data-color"):n.setAttribute("data-color",`${e}`),o===null?n.removeAttribute("data-background-color"):n.setAttribute("data-background-color",`${o}`)}class dp extends Wt.TypedEmitter{constructor(e){super();h(this,"id","text-color-item");h(this,"name","Text color");h(this,"dropdown",!0);h(this,"manualShowChildren",!0);h(this,"children",[]);h(this,"element");h(this,"colorPaletteItem");h(this,"latestColors",[null,null]);h(this,"handlePaletteClick",(e,o)=>{this.emit("onClick",e,o),e==="color"||e==="backgroundColor"?e==="color"?this.latestColors[0]=o:this.latestColors[1]=o:this.latestColors=[null,null],au(this.element,this.latestColors)});h(this,"beforePopup",()=>{this.emit("beforePopup")});this.editor=e,this.colorPaletteItem=new cu("text-color-palette-item"),this.colorPaletteItem.palette.addListener("onClick",this.handlePaletteClick),this.children.push(this.colorPaletteItem),this.element=vB()}destroy(){this.colorPaletteItem.destroy()}updatePaletteColor(e){this.colorPaletteItem.palette.setColor("color",e[0]),this.colorPaletteItem.palette.setColor("backgroundColor",e[1]),this.latestColors=e,au(this.element,this.latestColors)}updateButtonColor(e){this.latestColors=e,au(this.element,this.latestColors)}}const bF="";function cc(n,t){const e=b("div",["editor-input-wrap"],n);t!=null&&t.className&&M(e,t==null?void 0:t.className);const o=b("div",["editor-input-label"],e);b("span",[],o,t.label),t.required&&M(o,"required");const r=b("div",["editor-input-container"],e),i=b("input",["editor-input"],r);t.placeholder&&(i.placeholder=t.placeholder),t.defaultValue&&(i.value=t.defaultValue);const s=b("div",["editor-input-error"],e);return i.addEventListener("input",l=>{var c;(c=t.onChange)==null||c.call(t,l),F(e,"error")}),i.addEventListener("keydown",l=>{var c;(c=t.onKeyDown)==null||c.call(t,l)}),{getField:()=>i,getInputValue:()=>i.value,setFieldError:l=>{M(e,"error"),s.innerText=l}}}const kB=y("ui-base");class yB{constructor(t,e){h(this,"menu");h(this,"currentText","");h(this,"handleClick",(t,e)=>{this.options.onClickItem(this,e)});h(this,"handleClose",()=>{this.editor.focus()});h(this,"handleKeydown",t=>{this.menu.handleDocumentKeydown(t)});this.editor=t,this.options=e,this.menu=new Wo([],void 0,{id:e.id}),this.menu.addListener("click",this.handleClick),this.menu.addListener("close",this.handleClose)}setItems(t){if(this.menu.updateItems(t),t.length>0){const e=t.find(o=>o.type!=="section"&&o.type!=="separator");e&&this.menu.selectItem(e.id)}}async popup(t,e,o){var a,u;if(((u=(a=this.options).onShow)==null?void 0:u.call(a,this,t,e,o))===!1)return;this.options.showLoading&&this.showLoading();const r=this.editor.getBlockByIndex(t,e);if(!vt(this.editor.rootContainer,r)||Z(this.editor,r)<o)return;const i=Ao(this.editor,r,Ot(this.editor,r,o));if(i.length===0)return;const s=i[0],l=_o(this.editor,r,"editor-auto-suggest-menu",s);this.menu.manualShow(l),this.options.placeholder&&this.showPlaceholder();const c=await this.options.queryItems(this,"");this.highlightText(""),this.setItems(c)}showLoading(){!this.options.showLoading||this.setItems([{id:"loading",name:"loading",states:["disabled"]}])}showPlaceholder(){this.setItems([{id:"placeholder",name:"enter text to search",states:["disabled"]}])}showNoResultMessage(t){this.setItems([{id:"placeholder",name:S.t("search.emptyTips"),states:["disabled"]}])}close(){this.menu.close()}get isVisible(){return this.menu.isVisible}destroy(){this.menu.close(),this.menu.removeAllListeners(),this.menu.destroy()}async handleSearchText(t){this.currentText=t;const e="auto-suggest";try{await Rn.lock(e),this.showLoading();const o=this.currentText,r=await this.options.queryItems(this,o);if(this.currentText===o&&(this.currentText=""),r.length===0){this.showNoResultMessage(t);return}this.setItems(r),this.options.highlight&&this.highlightText(o)}finally{Rn.release(e)}}highlightText(t){kB.debug(`highlight menu text: ${t}`);const e=this.menu.content,o=(i,s)=>{if(!s)return i;let l="";const c=s.length,a=s.toLocaleLowerCase();let u=0;for(u=0;u<=i.length-c;u){const f=i.substring(u,u+c);f.toLocaleLowerCase()===a?(l+=`<span class="highlight">${f}</span>`,u+=c):(l+=i.charAt(u),u++)}return u<i.length&&(l+=i.substring(u)),l},r=i=>{if(lt(i,"text")){const s=i.textContent;if(!s)return;const l=o(s,t);i.innerHTML=l;return}Array.from(i.children).forEach(r)};r(e)}}const du=y("auto-suggest-menu");class uu{constructor(t,e){h(this,"menu");h(this,"anchor",null);h(this,"handleSelectionChanged",t=>{var o,r;if(!((o=this.menu)!=null&&o.isVisible))return;const e=t.selection.range.start;if(e.isSimple()&&e.blockId===((r=this.anchor)==null?void 0:r.blockId)&&e.offset>=this.anchor.offset){const i=t.getBlockById(e.blockId);if(Tt(Ae(ke(t,i),e.offset).left).startsWith(this.anchor.leftText))return}this.menu.close()});h(this,"deleteTrigger",()=>{const t=this.editor,e=t.selection.range.start;if(!e.isSimple()||!this.anchor)return!1;const{blockId:o,offset:r}=e,i=t.getBlockById(o),s=Tt(Ml(t,i,r));if(d(du,this.anchor,"no anchor"),!s.startsWith(this.anchor.leftText))return!1;const l=this.anchor.offset-this.anchor.trigger.length,c=r-l;return t.selection.selectBlock(i,l),c&&(t.deleteTextFromBlock(i,l,c),this.anchor.offset-=this.anchor.trigger.length),this.anchor.trigger.length||this.menu.close(),!0});h(this,"onShow",(t,e,o,r)=>{var i;if((i=this.options)!=null&&i.onShow)return this.options.onShow(this,e,o,r)});h(this,"onClickItem",(t,e)=>{!this.anchor||(this.options.autoDeleteTrigger&&this.deleteTrigger(),this.options.onClickItem(this,e,this.anchor))});h(this,"queryItems",(t,e)=>this.options.queryItems(this,e));h(this,"renderMenuItem",(t,e)=>{var r,i;return(i=(r=this.options).renderMenuItem)==null?void 0:i.call(r,this,e)});this.editor=t,this.options=e,this.menu=new yB(t,{id:e.id,showLoading:e.showLoading,loadingElement:e.loadingElement,placeholder:e.placeholder,noResultMessage:e.noResultMessage,highlight:e.highlight,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems,renderMenuItem:this.renderMenuItem}),t.input.addHandler(this),t.addListener("selectionChanged",this.handleSelectionChanged)}handleBeforeKeyDown(t,e){var o;return!((o=this.menu)!=null&&o.isVisible)||Ka(e.key)?!1:sm(e)&&!Do(e)?(setTimeout(()=>{this.resetItems()}),!1):Ja(e)?(this.menu.close(),!0):(this.menu.handleKeydown(e),!0)}popup(t,e,o,r){this.anchor={blockId:G(t),offset:e,leftText:o,trigger:r};const i=U(H(t)),s=K(t);this.menu.popup(i,s,e)}handleAfterInsertText(t,e,o,r,i){var u;const s=t.selection.range.start;if(!s.isSimple())return!1;const{blockId:l,offset:c}=s,a=t.getBlockByIndex(e,o);if(G(a)!==l)return!1;if((u=this.menu)!=null&&u.isVisible)this.resetItems();else if(this.options.trigger.indexOf(i)!==-1){if(r>0&&this.options.needSpaceBeforeTrigger&&t.getBlockString(a)[r-1]!==" ")return!1;const f=Tt(Ml(t,a,c));this.popup(a,c,f,i)}return!1}handleUpdateCompositionText(t,e,o,r,i){var a;const s=t.selection.range.start;if(!s.isSimple())return!1;const{blockId:l}=s,c=t.getBlockByIndex(e,o);return G(c)!==l||(a=this.menu)!=null&&a.isVisible&&this.resetItems(),!1}resetItems(){var l;if(!((l=this.menu)!=null&&l.isVisible))return;const t=this.editor,e=t.selection.range.start;if(!e.isSimple())return;const{blockId:o,offset:r}=e,i=t.getBlockById(o),s=Tt(Ml(t,i,r));if(d(du,this.anchor,"no anchor"),s.startsWith(this.anchor.leftText)){const c=s.substring(this.anchor.leftText.length);du.debug(`search text: ${c}`),this.menu.handleSearchText(c)}}destroy(){var t;this.editor.input.removeHandler(this),this.editor.removeListener("selectionChanged",this.handleSelectionChanged),(t=this.menu)==null||t.destroy()}}const up=Object.freeze(Object.defineProperty({__proto__:null,getButtonId:Aw,getParentButton:Ow,createButton:kn,changeButtonName:Ud,createSeparator:_w,DropdownFilterableList:f5,FilterableList:h5,showToast:m5,ManualMenu:Wo,ManualToolbar:os,HoveringMenu:dB,CommandBar:ho,Popup:lc,ManualCloseDialog:rs,CloseIcon:qd,PrevIcon:p5,NextIcon:C5,MoreIcon:Wd,TextColorIcon:Gd,ArrowDownIcon:oc,ArrowUpIcon:Fw,ArrowLeftIcon:zw,ArrowRightIcon:Zd,DeleteRowIcon:Yd,DeleteColIcon:Uw,MergeCellIcon:b5,SplitCellIcon:v5,DeleteTableIcon:k5,Heading1Icon:Qd,Heading2Icon:Kd,Heading3Icon:Jd,Heading4Icon:Xd,Heading5Icon:tu,Heading6Icon:eu,Heading7Icon:nu,Heading8Icon:ou,HeadingNIcon:Vw,OrderedListIcon:y5,UnorderedListIcon:w5,CheckListIcon:B5,BlockquoteIcon:E5,AlignCenterIcon:ic,AlignLeftIcon:Pr,AlignRightIcon:rc,ImageIcon:I5,ImageMenuIcon:x5,ImageErrorIcon:iu,ImageEmptyIcon:T5,LinkIcon:lu,LinkOffIcon:D5,WarningIcon:ru,PasteSpecialIcon:S5,LaunchIcon:su,CodeIcon:q5,AudioIcon:F5,GraphIcon:qw,VideoIcon:z5,FileIcon:Ww,MathIcon:Qw,MathMenuIcon:L5,TableIcon:Kw,TableMenuIcon:M5,LineIcon:Gw,BilibiliIcon:_5,YoukuIcon:N5,ModaoIcon:$5,FigmaIcon:P5,WebIcon:Zw,EditIcon:sc,CommentIcon:$r,RefreshIcon:R5,HelpIcon:A5,CheckMarkIcon:O5,TextIcon:ns,RightArrowIcon:Yw,TencentVideoIcon:H5,WebPageIcon:j5,UmlIcon:U5,DividingLineIcon:V5,HeadingH1Icon:Jw,HeadingH2Icon:Xw,HeadingH3Icon:tB,HeadingH4Icon:eB,HeadingH5Icon:nB,HeadingH6Icon:oB,HeadingH7Icon:rB,HeadingH8Icon:iB,CheckboxIcon:W5,QuoteIcon:G5,LinkHrefIcon:sB,OrderedIcon:Y5,UnorderedIcon:Z5,CopyIcon:Q5,CutIcon:K5,DeleteIcon:J5,LockBlockIcon:X5,UnLockBlockIcon:tp,CollapseUpIcon:ep,CollapseDownIcon:np,MentionIcon:op,ColorPalette:ap,ColorPaletteItem:cu,TextColorItem:dp,createInput:cc,OnesEditorAutoSuggest:uu,getItemShortcut:Vd,getItemMarkdown:jw},Symbol.toStringTag,{value:"Module"})),yn=y("table-dom");function fo(n){return`${G(n)}_scroll`}function $t(n){const t=n.querySelector("div[data-type=table-content] >table");return d(yn,t instanceof HTMLTableElement,"invalid table"),t}function wn(n,t){const o=n.getCustom(fo(t)).contentElement.firstElementChild;d(yn,o instanceof HTMLElement,"invalid table content");let r=o.querySelector(":scope >div[data-type=table-tools]");return r||(r=b("div",[],o),r.setAttribute("data-type","table-tools")),d(yn,r,"no table tools"),r}function hp(n){const t=[];return Array.from(n.rows).forEach(e=>{t.push(...Array.from(e.cells))}),t}function is(n){const t=n.querySelector(":scope div[data-type=editor-container]");return d(yn,t,"no child container in cell"),t}function wB(n){const o=hp(n).map(r=>{const i=is(r),s=U(i),l=r.colSpan,c=r.rowSpan;return`${s}/${l}/${c}`}).join();return Ci.default(o)}function Ht(n){return it(n)==="table"}function hu(n){const t=H(n);if(Ct(t))return null;const e=z(t);return d(yn,e,"no parent block"),Ht(e)?t:hu(e)}function we(n){if(Ht(n))return n;const t=H(n);if(Ct(t))return null;const e=z(t);return d(yn,e,"no parent block"),Ht(e)?e:we(e)}function BB(n,t){const e=n.querySelector("colgroup");d(yn,e,"no colgroup");const o=e.children[t];return d(yn,o,"no col"),d(yn,o instanceof HTMLTableColElement,`invalid col: ${o.tagName}`),o}function fp(n){try{return $t(n),!0}catch{return!1}}function EB(n){return At(n).querySelector(":scope > .block-helper")}function IB(n){const t=z(n.contentElement);d(yn,t,"no block");const e=EB(t);if(e){const o=Math.min(n.contentElement.offsetLeft,n.rootElement.scrollLeft),r=t.getBoundingClientRect().width;e.style.right=`${o+r}px`}}const Be=y("doc-table-grid");class xB{constructor(t){h(this,"_cells",[]);for(let e=0;e<t;e++)this._cells.push(void 0)}cols(){return this._cells.length}setCell(t,e){d(Be,t>=0&&t<this.cols(),`set cell, invalid col: ${t}`),this._cells[t]=e}getCell(t){d(Be,t>=0&&t<this.cols(),`get cell, invalid col: ${t}`);const e=this._cells[t];return d(Be,e,"get cell, no cell"),e}getCellAllowEmpty(t){return d(Be,t>=0&&t<this.cols(),`get cell, invalid col, ${t}`),this._cells[t]}getNextNonVirtualCell(t){return this._cells.slice(t+1).find(e=>!e.virtual)}forEach(t){this._cells.forEach(t)}}class fu{constructor(t){h(this,"_data");h(this,"_rows");this._data=t,this._rows=[];for(let e=0;e<this.rowCount;e++)this._rows.push(new xB(this.colCount));this.fillGrid(),d(Be,t.colsWidth,"no colsWidth"),d(Be,this.colCount===t.colsWidth.length,"invalid col count")}get rowCount(){return this._data.rows}get colCount(){return this._data.cols}getNextEmptyCell(t,e){let o=t,r=e;for(;;){if(o+=1,o===this.colCount&&(o=0,r+=1),r>=this.rowCount)return null;if(this._rows[r].getCellAllowEmpty(o)===void 0)return{col:o,row:r}}}fillGrid(){const t=this._data.children;d(Be,t,"no children");let e=0,o=0;t.forEach((r,i)=>{const s=this._data[`${r}_colSpan`]||1,l=this._data[`${r}_rowSpan`]||1;for(let a=0;a<l;a++)for(let u=0;u<s;u++)this._rows[o+a].setCell(e+u,{col:e,row:o,containerId:r,virtual:u!==0||a!==0,colSpan:s,rowSpan:l});const c=this.getNextEmptyCell(e,o);c?(e=c.col,o=c.row):d(Be,i===t.length-1,`invalid table data, no next empty cell: ${JSON.stringify(this._data)}`)}),this._rows.forEach(r=>{r.forEach(i=>{d(Be,i,"no cell"),d(Be,i.containerId,"no containerId")})})}getCell(t){const{col:e,row:o}=t,r=this._rows[o];d(Be,r,`get cell, no row: ${o}`);const i=r.getCell(e);return d(Be,i,`get cell, no cell: ${e}`),i}getRow(t){const e=this._rows[t];return d(Be,e,`get row, no row: ${t}`),e}forEach(t){this._rows.forEach(t)}}const ac=y("table-data");function SB(n){const t=n.firstElementChild;return d(ac,t,"no child element for cell"),d(ac,fn(t),"cell first child is not a container"),d(ac,qe(t),"cell first child is not a container"),t}function TB(n){const t=z(n);d(ac,t,"no parent block for table");const e=[],o={};Array.from(n.rows).forEach(l=>{Array.from(l.cells).forEach(c=>{const a=SB(c),u=U(a);e.push(u),(c.colSpan>1||c.rowSpan>1)&&(o[`${u}_colSpan`]=c.colSpan,o[`${u}_rowSpan`]=c.rowSpan)})});const r=n.rows.length,i=Array.from(n.rows[0].cells).map(l=>l.colSpan).reduce((l,c)=>l+c,0);return{id:G(t),type:it(t),rows:r,cols:i,children:e,colsWidth:Array(i).fill(100),...o}}function Go(n){return new fu(n)}function DB(n){return Go(TB(n))}const qt=y("table-grid"),LB=60;class MB{constructor(t,e){h(this,"containerId");h(this,"row");h(this,"col");h(this,"colSpan");h(this,"rowSpan");h(this,"virtual");h(this,"table");this.table=t,this.containerId=e.containerId,this.row=e.row,this.col=e.col,this.colSpan=e.colSpan,this.rowSpan=e.rowSpan,this.virtual=e.virtual}get cell(){const e=this.container.closest("td");return d(qt,e,"no parent cell for child container"),e}get container(){const t=this.table.querySelectorAll(`[data-container-id=${this.containerId}]`);d(qt,t.length===1,"containers !== 1"),d(qt,fn(t[0]),"not a container");const e=t[0];return d(qt,qe(e),"not a child container"),e}}class RB{constructor(t,e){h(this,"_cells",[]);e.forEach(o=>{this._cells.push(new MB(t,o))})}get cells(){return this._cells}getCell(t){return d(qt,t<this._cells.length,"get cell, invalid col"),this._cells[t]}getNextNonVirtualCell(t){return this._cells.slice(t+1).find(e=>!e.virtual)}getSpannedCell(){return this._cells.find(t=>t.virtual||t.colSpan>1||t.rowSpan>1)}}const uf=class{constructor(t){h(this,"_rows",[]);this.table=t,DB(t).forEach(r=>{this._rows.push(new RB(t,r))});const o=this.colCount;this._rows.forEach(r=>{d(qt,r.cells.length===o,"row.cells.length !== colCount")})}get rowCount(){return this._rows.length}get colCount(){return this._rows.length===0?0:(d(qt,this.rowCount>0,"rowCount <= 0"),this.getRow(0).cells.length)}getRow(t){return this._rows[t]}getCell(t){const e=this.getRow(t.row);return d(qt,e,"no row"),e.getCell(t.col)}getCellContainer(t){return this.getCell(t).container}getFirstCellContainer(){return this.getCellContainer({row:0,col:0})}getLastCellContainer(){const t=this.rowCount-1,e=this.colCount-1;return this.getCellContainer({row:t,col:e})}getColumnCells(t){d(qt,t>=0&&t<this.colCount,"colIndex out of range");const e=this.rowCount,o=[];for(let r=0;r<e;r++){const i=this.getCell({row:r,col:t});o.push(i)}return o}toRealCells(t){const e=[];return t.forEach(o=>{const r=this.getRealCell(o);e.findIndex(i=>i.containerId===r.containerId)===-1&&e.push(r)}),e}getColumnRealCells(t){const e=this.getColumnCells(t);return this.toRealCells(e)}getRowRealCells(t){const e=this.getRow(t).cells;return this.toRealCells(e)}getFirstSpannedCell(t){d(qt,t>=0&&t<this.colCount,"colIndex out of range");const e=this.rowCount;for(let o=0;o<e;o++){const r=this.getCell({row:o,col:t});if(r.virtual||r.colSpan>1||r.rowSpan>1)return r}}getRealCell(t){const e=this.getCell(t);if(!e.virtual)return e;const o=this.getCellById(e.containerId);return d(qt,!o.virtual,"found a virtual cell"),o}getColumnSpannedRange(t){const e=this.getColumnRealCells(t);let o=1e5,r=-1;return e.forEach(i=>{o=Math.min(i.col,o),r=Math.max(i.col+i.colSpan-1,r)}),d(qt,o<=r,"min > max"),d(qt,o>=0,"min < 0"),d(qt,r<this.colCount,"max >= colCount"),[o,r]}getRowSpannedRange(t){const e=this.getRowRealCells(t);let o=1e5,r=-1;return e.forEach(i=>{o=Math.min(i.row,o),r=Math.max(i.row+i.rowSpan-1,r)}),d(qt,o<=r,"min > max"),d(qt,o>=0,"min < 0"),d(qt,r<this.rowCount,"max >= rowCount"),[o,r]}getSpannedRange(t,e){const o=Math.min(t.row,e.row),r=Math.max(t.row,e.row),i=Math.min(t.col,e.col),s=Math.max(t.col,e.col),l=[];for(let C=o;C<=r;C++)for(let v=i;v<=s;v++)l.push(this.getCell({row:C,col:v}));const c=this.toRealCells(l);let a=1e4,u=1e4,f=-1,m=-1;return c.forEach(C=>{u=Math.min(C.col,u),a=Math.min(C.row,a),m=Math.max(C.col+C.colSpan-1,m),f=Math.max(C.row+C.rowSpan-1,f)}),[{row:a,col:u},{row:f,col:m}]}getAllCells(){return this.getCells({col:0,row:0},{col:this.colCount-1,row:this.rowCount-1})}sub(t,e){const o=[];for(let r=t.row;r<=e.row;r++){const i=[];for(let s=t.col;s<=e.col;s++){const l=this.getCell({row:r,col:s});i.push(l)}o.push(i)}return o}getAllContainers(){return this.getAllCells().map(e=>e.container)}getCells(t,e){const o=[],r=this.getSpannedRange(t,e),i=r[0],s=r[1],l=Math.min(i.row,s.row),c=Math.max(i.row,s.row),a=Math.min(i.col,s.col),u=Math.max(i.col,s.col);for(let f=l;f<=c;f++)for(let m=a;m<=u;m++){const C=this.getCell({row:f,col:m});C.virtual||o.push(C)}return o}map(t){const e=[];for(let o=0;o<this.rowCount;o++){const r=[];for(let i=0;i<this.colCount;i++){const s=this.getCell({row:o,col:i});r.push(t(s))}e.push(r)}return e}getBottomCell(t){const e=this.rowCount;let o=t,r=t.row;for(;o.containerId===t.containerId;){if(r+=1,r>=e)return null;o=this.getCell({row:r,col:t.col})}return this.getRealCell(o)}getTopCell(t){let e=t,o=t.row;for(;e.containerId===t.containerId;){if(o-=1,o<0)return null;e=this.getCell({row:o,col:t.col})}return this.getRealCell(e)}get cells(){let t=[];return this._rows.forEach(e=>{t=t.concat(e.cells)}),t}getVirtualCellContainersGrid(){return this.map(t=>t.containerId)}static virtualCellContainersGridToChildren(t){const e=t,o=[];return e.forEach(r=>{r.forEach(i=>{o.indexOf(i)===-1&&o.push(i)})}),o}getCellById(t){const o=this.cells.find(r=>r.containerId===t);return d(qt,o,"cell not found"),o}getCellByCellElement(t){const e=is(t);return this.getCellByContainerId(U(e))}getCellByContainerId(t){return this.getCellById(t)}static fromTable(t){const e=wB(t),o=this.caches.getSync(e,()=>(qt.debug("create table grid"),new uf(t)));return o.table!==t?(this.caches.delete(e),this.fromTable(t)):o}static fromBlock(t){return this.fromTable($t(t))}};let nt=uf;h(nt,"caches",new Hf(LB));function dc(n,t){Object.entries(n).forEach(([e])=>{e.startsWith(`${t}/`)&&delete n[e]})}const AB=y("table-selection-range");function rn(n,t,e){var x,A,O,P;const o=nt.fromBlock(n),r=t,i=e,s=o.getCellByContainerId(r.childContainerId),l=o.getCellByContainerId(i.childContainerId),c=r.custom,a=i.custom,u=(x=c==null?void 0:c.rowIndex)!=null?x:s.row,f=(A=c==null?void 0:c.colIndex)!=null?A:s.col,m=(O=a==null?void 0:a.rowIndex)!=null?O:l.row+l.rowSpan-1,C=(P=a==null?void 0:a.colIndex)!=null?P:l.col+l.colSpan-1,v=Math.min(u,m),w=Math.max(u,m),E=Math.min(f,C),L=Math.max(f,C);return{fromRow:v,toRow:w,fromCol:E,toCol:L}}function mu(n,t){const e=new Set,o=new Set,r=n.selection.range;if(!r.isSimple()&&r.start.blockId===G(t)){const i=nt.fromBlock(t),{start:s,end:l}=r;d(AB,!s.isSimple()&&!l.isSimple(),"invalid range");const{fromCol:c,toCol:a,fromRow:u,toRow:f}=rn(t,s,l);if(u===0&&f===i.rowCount-1)for(let m=c;m<=a;m++)o.add(m);if(c===0&&a===i.colCount-1)for(let m=u;m<=f;m++)e.add(m)}return{selectedRows:e,selectedColumns:o}}const Hr=y("delete-columns");function mp(n,t,e){const{start:o,end:r}=e;if(o.blockId!==r.blockId||e.isSimple()||n.getBlockById(o.blockId)!==t||it(t)!=="table")return!1;const{fromRow:s,toRow:l}=rn(t,e.start,e.end),c=nt.fromBlock(t);return s===0&&l===c.rowCount-1}function gu(n){var A;const t=n.getEditor(),e=t.getBlockById(n.start.blockId);if(!mp(t,e,n))return;if(n.isSimple()){t.deleteBlock(e);return}const{fromCol:o,toCol:r}=rn(e,n.start,n.end),i=nt.fromBlock(e);if(o===0&&r===i.colCount-1){t.deleteBlock(e);return}const s=new Set,l=i.map(O=>O.containerId);for(let O=0;O<l.length;O++){const P=l[O];for(let V=o;V<=r;V++){const tt=P[V];s.add(tt)}P.splice(o,r-o+1)}const c=new Set(l.flat()),a=new Set(Array.from(s).filter(O=>!c.has(O))),u=r-o+1,f=new Map,m=new Map;s.forEach(O=>{if(a.has(O))return;const P=i.getCellByContainerId(O);if(d(Hr,P.colSpan>1,"invalid effected cell, colSpan === 1"),P.col<o){d(Hr,c.has(O),"invalid effected cell, not exists");let yt=P.col+P.colSpan-1;yt>r&&(yt=r);const oe=yt-o+1,Jn=P.colSpan-oe;f.set(O,Jn);return}d(Hr,P.col<=r,"invalid effected cell, col > endCol");const V=P.col,tt=P.col+P.colSpan-1,ot=P.col-o,ut=tt-V+1-u+ot;d(Hr,ut>0,"invalid effected cell, newSpanned <= 0");const dt=pn(t.doc);m.set(O,{newContainerId:dt,colSpan:ut})});for(let O=0;O<l.length;O++){const P=l[O];for(let V=o;V<P.length;V++){const tt=P[V],ot=m.get(tt);ot&&(P[V]=ot.newContainerId)}}const C=Y.default(t.getBlockData(e));C.colsWidth.splice(o,r-o+1),a.forEach(O=>{dc(C,O)}),f.forEach((O,P)=>{d(Hr,O>=1,"invalid modified colSpan, colSpan < 1"),O===1?delete C[`${P}_colSpan`]:C[`${P}_colSpan`]=O}),m.forEach((O,P)=>{dc(C,P);const{newContainerId:V,colSpan:tt}=O;d(Hr,tt>=1,"invalid newContainerData, colSpan < 1"),tt>1&&(C[`${V}_colSpan`]=tt);const ot=i.getCellByContainerId(P).rowSpan;ot>1&&(C[`${V}_rowSpan`]=ot)});const w=(A=l[0][o])!=null?A:l[0][o-1],E=t.getChildContainerData(w)[0],L=nt.virtualCellContainersGridToChildren(l),x={...C,cols:C.cols-u,children:L};Go(x),t.updateBlockData(e,x,Ot(t,E.id,0)),t.deleteChildContainers(Array.from(a)),t.deleteChildContainers(Array.from(m.keys()))}const jr=y("delete-rows");function gp(n,t,e){const{start:o,end:r}=e;if(o.blockId!==r.blockId||e.isSimple()||n.getBlockById(o.blockId)!==t||it(t)!=="table")return!1;const{fromCol:s,toCol:l}=rn(t,e.start,e.end),c=nt.fromBlock(t);return s===0&&l===c.colCount-1}function pu(n){const t=n.getEditor(),e=t.getBlockById(n.start.blockId);if(!gp(t,e,n))return;if(n.isSimple()){t.deleteBlock(e);return}const{fromRow:o,toRow:r}=rn(e,n.start,n.end),i=nt.fromBlock(e);if(o===0&&r===i.rowCount-1){t.deleteBlock(e);return}const s=new Set,l=i.map(x=>x.containerId);for(let x=r;x>=o;x--)l[x].forEach(O=>s.add(O)),l.splice(x,1);const c=new Set(l.flat()),a=new Set(Array.from(s).filter(x=>!c.has(x))),u=r-o+1,f=new Map,m=new Map;s.forEach(x=>{if(a.has(x))return;const A=i.getCellByContainerId(x);if(d(jr,A.rowSpan>1,"invalid effected cell, rowSpan === 1"),A.row<o){d(jr,c.has(x),"invalid effected cell, not exists");let ut=A.row+A.rowSpan-1;ut>r&&(ut=r);const dt=ut-o+1,yt=A.rowSpan-dt;f.set(x,yt);return}d(jr,A.row<=r,"invalid effected cell, col > endCol");const O=A.row,P=A.row+A.rowSpan-1,V=A.row-o,tt=P-O+1-u+V;d(jr,tt>0,"invalid effected cell, newSpanned <= 0");const ot=pn(t.doc);m.set(x,{newContainerId:ot,rowSpan:tt})});for(let x=o;x<l.length;x++){const A=l[x];for(let O=0;O<A.length;O++){const P=A[O],V=m.get(P);V&&(A[O]=V.newContainerId)}}const C=Y.default(t.getBlockData(e));a.forEach(x=>{dc(C,x)}),f.forEach((x,A)=>{d(jr,x>=1,"invalid modified rowSpan, rowSpan < 1"),x===1?delete C[`${A}_rowSpan`]:C[`${A}_rowSpan`]=x}),m.forEach((x,A)=>{dc(C,A);const{newContainerId:O,rowSpan:P}=x;d(jr,P>=1,"invalid newContainerData, rowSpan < 1"),P>1&&(C[`${O}_rowSpan`]=P);const V=i.getCellByContainerId(A).colSpan;V>1&&(C[`${O}_colSpan`]=V)});const v=l[o]?l[o][0]:l[o-1][0],w=t.getChildContainerData(v)[0],E=nt.virtualCellContainersGridToChildren(l),L={...C,rows:C.rows-u,children:E};Go(L),t.updateBlockData(e,L,Ot(t,w.id,0)),t.deleteChildContainers(Array.from(a)),t.deleteChildContainers(Array.from(m.keys()))}const ss=y("table-range");function uc(n){d(ss,!n.isSimple(),"must be complex selection range");const{anchor:t,focus:e}=n;d(ss,!t.isSimple(),"invalid start pos type"),d(ss,!e.isSimple(),"invalid end pos type");const o=n.getEditor();d(ss,t.blockId===e.blockId,"invalid range, not same block");const r=o.getBlockById(t.blockId);d(ss,it(r)==="table","invalid block type, not a table block");const i=$t(r),s=nt.fromTable(i),l=s.getCellByContainerId(t.childContainerId),c=s.getCellByContainerId(e.childContainerId),a=Math.min(l.row,c.row),u=Math.max(l.row,c.row),f=Math.min(l.col,c.col),m=Math.max(l.col,c.col),C=s.getCell({row:a,col:f}),v=s.getCell({row:u,col:m});return{editor:o,block:r,table:i,startCell:C,endCell:v,startRow:a,startCol:f,endRow:u,endCol:m}}const Cu=y("split-cell");function bu(n,t,e){const o=nt.fromBlock(t),r=o.getRealCell(e);d(Cu,!r.virtual,"should not split virtual cell"),d(Cu,r.colSpan>1||r.rowSpan>1,"cell does not has span data");const i=o.getVirtualCellContainersGrid();for(let f=0;f<r.rowSpan;f++)for(let m=0;m<r.colSpan;m++){if(f===0&&m===0)continue;const C=f+r.row,v=m+r.col,w=pn(n.doc);i[C][v]=w}const s=n.getBlockData(t),l=Y.default(s);l[`${r.containerId}_colSpan`]=null,l[`${r.containerId}_rowSpan`]=null,l.children=nt.virtualCellContainersGridToChildren(i);const a=n.getChildContainerData(r.containerId)[0];d(Cu,a,"no child block");const u=Ot(n,a.id,0);Go(l),n.updateBlockData(t,l,u)}function OB(n,t,e){e.forEach(o=>{const r=nt.fromBlock(t).getCell(o);(r.virtual||r.colSpan>1||r.rowSpan>1)&&bu(n,t,o)})}function pp(n,t,e){if(e.isSimple())return!1;const{start:o,end:r}=e;if(o.blockId!==r.blockId||n.getBlockById(o.blockId)!==t||it(t)!=="table")return!1;const{startCell:s,endCell:l}=uc(e);return!(s.cell!==l.cell||s.colSpan===1&&s.rowSpan===1)}function vu(n){const{editor:t,block:e,startRow:o,startCol:r,endRow:i,endCol:s}=uc(n),l=[];for(let c=o;c<=i;c++)for(let a=r;a<=s;a++)l.push({row:c,col:a});return OB(t,e,l),!0}const Fr=y("merge-cells");function Cp(n,t,e){if(e.isSimple())return!1;const{start:o,end:r}=e;if(o.blockId!==r.blockId||n.getBlockById(o.blockId)!==t||it(t)!=="table")return!1;const{startCell:s,endCell:l}=uc(e);return s.cell!==l.cell}function bp(n){const t=uc(n),e=t.endCell,o=e.row+e.rowSpan-1,r=e.col+e.colSpan-1,i=G(t.block),s=t.editor;vu(n);const l=s.getBlockById(i),c=$t(l),{startRow:a,startCol:u}=t,f=Y.default(s.getBlockData(l));d(Fr,f.children,"no table children");const m=nt.fromTable(c),C=[];for(let ut=a;ut<=o;ut++)for(let dt=u;dt<=r;dt++){const yt=m.getCell({row:ut,col:dt});d(Fr,!yt.virtual,"cell is virtual"),C.push(yt)}d(Fr,C.length>0,"no selected cells");const v=C[0],w=C.slice(1),E=m.getCellByContainerId(v.containerId).container,L=[];w.forEach(ut=>{const dt=m.getCellByContainerId(ut.containerId).container,yt=U(dt);if(!g1(s,dt)){const oe=od(s,yt);s.insertDocAt(E,Ue(E),oe)}L.push(yt)});const x=U(E),A=r-u+1,O=o-a+1;f[`${x}_colSpan`]=A,f[`${x}_rowSpan`]=O,L.forEach(ut=>{d(Fr,f.children,"no table children");const dt=f.children.indexOf(ut);d(Fr,dt>0,"no deleted container"),f.children.splice(dt,1)});const P=f,tt=s.getChildContainerData(x)[0];d(Fr,tt,"no child block");const ot=Ot(s,tt.id,0);Go(P),s.updateBlockData(l,P,ot),s.deleteChildContainers(L)}const ku=10,_B=["table/merge-cells","table/split-cell","table/insert-column","table/insert-row","table/delete-rows","table/delete-columns","table/delete"];class yu{constructor(){h(this,"id","TableBlockCommandProvider")}getAvailableCommands(t,e,o){if(it(e)!=="table")return[];const r={blockId:G(e),blockKind:We(t,e),blockType:it(e)},i=[];Cp(t,e,o)&&i.push({id:"table/merge-cells",name:"merge cells",icon:b5,groupIndex:ku,...r}),pp(t,e,o)&&i.push({id:"table/split-cell",name:"split cell",icon:v5,groupIndex:ku,...r});const s=mp(t,e,o),l=gp(t,e,o);return s&&l&&i.push({id:"table/delete",name:"delete tables",icon:k5,groupIndex:ku,...r}),i}executeCommand(t,e,o,r,i,s){return it(e)!=="table"||!new Set(_B).has(r.id)?!1:r.id==="table/merge-cells"?(bp(o),!0):r.id==="table/split-cell"?(vu(o),!0):r.id==="table/delete-columns"?(gu(o),!0):r.id==="table/delete-rows"?(pu(o),!0):r.id==="table/delete"?(t.deleteBlock(e),!0):!1}}var vp=(n=>(n.COL_TITLE_TABLE="col-title-table",n.COL_TITLE_ITEM="col-title-item",n.STRIPE_STYLE_TABLE="stripe-style-table",n.NO_BORDER="table-no-border",n))(vp||{});const wu=6,ls=20;function NB(n,t){if(!n.isBlockWritable(t))return;const o={...Y.default(n.getBlockData(t)),hasColTitle:!0};n.updateBlockData(t,o)}function PB(n,t){if(!n.isBlockWritable(t))return;const o={...Y.default(n.getBlockData(t)),hasColTitle:!1};n.updateBlockData(t,o)}function $B(n,t){if(!n.isBlockWritable(t))return;const o={...Y.default(n.getBlockData(t)),hasRowTitle:!0};n.updateBlockData(t,o)}function HB(n,t){if(!n.isBlockWritable(t))return;const o={...Y.default(n.getBlockData(t)),hasRowTitle:!1};n.updateBlockData(t,o)}function jB(n,t){if(!n.isBlockWritable(t))return;const o={...Y.default(n.getBlockData(t)),isStripeStyle:!0};n.updateBlockData(t,o)}function FB(n,t){if(!n.isBlockWritable(t))return;const o={...Y.default(n.getBlockData(t)),isStripeStyle:!1};n.updateBlockData(t,o)}function zB(n,t,e){if(!n.isBlockWritable(t))return;const r={...Y.default(n.getBlockData(t)),noBorder:!e};n.updateBlockData(t,r)}const Bu=y("get-selected-containers");function Eu(n,t,e,o){d(Bu,e.blockId===o.blockId,"only allow select in single table block"),d(Bu,G(t)===e.blockId,"only allow select in single table block");const r=nt.fromBlock(t),i=r.getCellByContainerId(e.childContainerId),s=r.getCellByContainerId(o.childContainerId);if(e.custom===void 0||o.custom===void 0)return r.getCells(i,s).map(E=>r.getCellContainer(E));const{fromCol:l,toCol:c,fromRow:a,toRow:u}=rn(t,e,o),f=new Set,m=[];return r.sub({row:a,col:l},{row:u,col:c}).forEach(v=>{v.forEach(w=>{const E=r.getCellByContainerId(w.containerId);E.col<l||E.row<a||E.col+E.colSpan-1>c||E.row+E.rowSpan-1>u||f.has(w.containerId)||(f.add(w.containerId),m.push(E.container))})}),m}function UB(n,t,e){d(Bu,t.blockId===e.blockId,"only allow select in single table block");const o=n.getBlockById(t.blockId);return Eu(n,o,t,e)}const Zo=y("table-cell-dom");function VB(n,t,e){let o=n.getBlockById(e);for(;o;){const r=o.closest("td");d(Zo,r,"no parent cell");const i=z(r);if(d(Zo,i,"no parent block"),i===t)return r;o=i}return d(Zo,!1,"filed to get cell by child block id"),null}function Vn(n,t,e){if(n.getBlockById(e.blockId)===t&&!e.isSimple())return d(Zo,e.childContainerId,"block position must have childContainerId attribute"),e;const r=VB(n,t,e.blockId),i=U(is(r));return bt(t,i)}function Iu(n,t){const e=n.selection.range,o=Vn(n,t,e.start),r=Vn(n,t,e.end);return rn(t,o,r)}function kp(n,t,e,o){d(Zo,Ht(t),"invalid table block");const r=wn(n,t),i=()=>{const l=r.querySelector(".table-border-bar-container.top");d(Zo,l,"no top border bar container"),l.querySelectorAll(".table-border-bar-cell.top").forEach(a=>{const u=parseInt(a.getAttribute("data-top-index")||"0",10);o.includes(u)?M(a,"danger"):F(a,"danger")})},s=()=>{const l=r.querySelector(".table-border-bar-container.left");d(Zo,l,"no left border bar container"),l.querySelectorAll(".table-border-bar-cell.left").forEach(a=>{const u=parseInt(a.getAttribute("data-left-index")||"0",10);e.includes(u)?M(a,"danger"):F(a,"danger")})};i(),s()}function zr(n,t,e=!0,o){const i=nt.fromBlock(t).map(u=>u),{fromCol:s,toCol:l,fromRow:c,toRow:a}=Iu(n,t);for(let u=0;u<i.length;u++){const f=i[u];for(let m=0;m<f.length;m++){const C=f[m],v=o?m>=s&&m+C.colSpan-1<=l:u>=c&&u+C.rowSpan-1<=a;e&&v?C.virtual||M(C.cell,"danger"):C.virtual||F(C.cell,"danger")}}}function Ur(n,t,e=!0,o){const r=new Set,i=new Set;if(!e){kp(n,t,Array.from(r),Array.from(i));return}const{fromCol:s,toCol:l,fromRow:c,toRow:a}=Iu(n,t);if(o)for(let u=s;u<=l;u++)i.add(u);else for(let u=c;u<=a;u++)r.add(u);kp(n,t,Array.from(r),Array.from(i))}function yp(n,t,e){const{fromCol:o,toCol:r,fromRow:i,toRow:s}=Iu(n,t),l=nt.fromBlock(t);let c=null,a=null;return e?(c=l.getCell({col:o,row:0}),a=l.getCell({col:r,row:l.rowCount-1}),Vt(n,{anchor:bt(t,c.containerId,{colIndex:o,rowIndex:0}),focus:bt(t,a.containerId,{colIndex:r,rowIndex:l.rowCount-1})})):(c=l.getCell({col:0,row:i}),a=l.getCell({col:l.colCount-1,row:s}),Vt(n,{anchor:bt(t,c.containerId,{colIndex:0,rowIndex:i}),focus:bt(t,a.containerId,{colIndex:l.colCount-1,rowIndex:s})}))}function qB(n,t){const e=n.selection.range,o=Vn(n,t,e.start),r=Vn(n,t,e.end);return Eu(n,t,o,r)}const wp=["style-bg-color-0","style-bg-color-1","style-bg-color-2","style-bg-color-3","style-bg-color-4","style-bg-color-5","style-bg-color-6","style-bg-color-7","style-bg-color-8","style-bg-color-9","style-bg-color-10","style-bg-color-11","style-bg-color-12","style-bg-color-13"];function Bp(n){return`style-bg-color-${n}`}function cs(n){return`${n}_background`}function WB(n,t,e){const o=$t(n),s=(e!=null?e:nt.fromTable(o)).getCell(t).cell;for(let l=0;l<wp.length;l++){const c=wp[l];if(lt(s,c))return c}}function Ep(n,t,e){if(!n.isBlockWritable(t))return;const o=n.selection.range,i={...Y.default(n.getBlockData(t))},s=Vn(n,t,o.start),l=Vn(n,t,o.end);if(o.isSimple()){const c=s.childContainerId;e===-1?i[cs(c)]=void 0:i[cs(c)]=Bp(e)}else{const c=nt.fromBlock(t),a=rn(t,s,l),u=new Set;for(let f=a.fromRow;f<=a.toRow;f++)for(let m=a.fromCol;m<=a.toCol;m++){const C=c.getCell({row:f,col:m});!u.has(C.containerId)&&C.col>=a.fromCol&&C.row>=a.fromRow&&C.col+C.colSpan-1<=a.toCol&&C.row+C.rowSpan-1<=a.toRow&&(u.add(C.containerId),e===-1?i[cs(C.containerId)]=void 0:i[cs(C.containerId)]=Bp(e))}}n.updateBlockData(t,i)}function GB(n,t,e){if(!n.isBlockWritable(t))return;const r={...Y.default(n.getBlockData(t)),chart:e};n.updateBlockData(t,r)}const Ip=y("table-chart");function ZB(n,t){const e=wn(n,t);if(e){const o=e.querySelector(".editor-table-chart");if(o){const r=o.chartObject;r&&r.destroy(),o.remove()}}}async function YB(n,t){if(!n.isBlockWritable(t))return;if(!!!n.getBlockData(t).chart){ZB(n,t);return}const r=[],i=nt.fromBlock(t),s=["line","bar","pie","radar"];let l=i.getCell({row:0,col:0}).container.innerText.trim().toLowerCase();new Set(s).has(l)||(l=s[0]);const c=[];for(let w=1;w<i.colCount;w++)c.push(i.getCell({row:0,col:w}).container.innerText);for(let w=1;w<i.rowCount;w++){const E=i.getCell({row:w,col:0}),x=E.container.innerText,A=[];for(let oe=1;oe<i.colCount;oe++){const Jn=i.getCell({row:w,col:oe}).container.innerText,Xt=Number.parseFloat(Jn)||0;A.push(Xt)}let O;const P=WB(t,E,i);P?O=window.getComputedStyle(n.rootElement).getPropertyValue(`--${P}`).trim():O=window.getComputedStyle(n.rootElement).getPropertyValue("--background-color").trim();let[V,tt,ot,ut]=O?$a.fromString(O).toRgbaArray():[];if(!V&&!tt&&!ot&&!ut){const oe=(w-1)%n.options.colors.length;O=n.options.colors[oe],[V,tt,ot,ut]=$a.fromString(O).toRgbaArray()}const dt=O,yt=$a.fromRgba([V,tt,ot,ut/3]).toHexString();r.push({label:x,data:A,borderColor:dt,backgroundColor:yt,borderWidth:2})}const a=wn(n,t);let u=null,f=a.querySelector(".editor-table-chart");f?u=f.chartObject:f=b("div",["editor-table-chart"],a);const m=f;d(Ip,m,"no chart container");const C=n.getComponentOptions("table"),v=(C==null?void 0:C.chartCdn)||"https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.min.js";try{await So(v,"editor-chartjs"),u&&l!==u.config.type&&(u.destroy(),u=null,Array.from(f.querySelectorAll(".editor-chartjs-canvas")).forEach(L=>{L.remove()}));const w=ja.default({},{type:l,data:{datasets:r,labels:c},options:{onClick:()=>{n.selection.selectBlock(t,0,0)}}});if(u)ja.default(u.config,w),u.update();else{const L=b("canvas",["editor-chartjs-canvas"],m).getContext("2d");u=new window.Chart(L,w),f.chartObject=u}}catch(w){Ip.error(`failed to resolve chart cdn: ${JSON.stringify(w)}`)}}async function xp(n,t){await Rn.lock("updateTableChart");try{await YB(n,t)}finally{Rn.release("updateTableChart")}}const Sp=ie.default(xp,1e3);let Tp=null;function xu(n,t,e){if(Tp!==t&&(Sp.flush(),Tp=t),e.updateNow){xp(n,t);return}Sp(n,t)}function Su(n,t){Ht(t)&&xu(n,t,{updateNow:!1})}function QB(n,t){Ht(t)&&xu(n,t,{updateNow:!0})}const $e={SCROLL:"container-scroll-tool",COMMON:"container-border-shadow",RIGHT:"container-right-border-shadow",LEFT:"container-left-border-shadow",LAYOUT_SIGN:"container-layout-border-shadow",ACTIVE:"active"},hc={SCROLL_BAR:"container-scrollbar",FIXED:"fixed"},mo={SCROLL_CONTAINER:"scroll-container",TOOL:"container-scroll-tool",CONTAINER:"scroll-container-root",MAC:"mac",SCROLL_AREA:"scroll-area"};function fc(n,t){return n.containers.get(t)}function Dp(n){return n.closest(`.${mo.SCROLL_CONTAINER}`)}function sn(n){return n.firstElementChild}function Ee(n){return n.closest(`.${mo.CONTAINER}`)}function as(n){const t=Ee(n);let e=t.querySelector(`:scope >.${mo.TOOL}`);return e||(e=b("div",[mo.TOOL],t)),e}function KB(n){return Ee(n).firstElementChild}function ds(n){const t=window.getComputedStyle(n);return{paddingBottom:parseFloat(t.paddingBottom),paddingTop:parseFloat(t.paddingTop),paddingLeft:parseFloat(t.paddingLeft),paddingRight:parseFloat(t.paddingRight)}}function Tu(n,t){const e=Ee(t),o=fc(n,e),r=(o==null?void 0:o.safeRightSpace)||0,i=(o==null?void 0:o.safeLeftSpace)||0,l=(o==null?void 0:o.locatingContainer).getBoundingClientRect(),c=e.getBoundingClientRect(),a=c.width;let u=Math.floor(c.left-l.left-i);u<0&&(u=0);let f=l.right;f-=r;let m=f-c.right;return m<0&&(m=0),u=Math.round(u),m=Math.round(m),{originWidth:a,maxLeft:u,maxRight:m}}function JB(n,t){const e=Tu(n,t),{maxLeft:o}=e;t.style.marginLeft=`${0-o}px`,t.style.paddingLeft=`${o}px`}function XB(n,t){const e=Tu(n,t);t.style.marginRight=`${0-e.maxRight}px`}function tE(n){if(n!==document.documentElement&&n!==document.body)return n.getBoundingClientRect();const t=0,e=0,o=document.documentElement.clientWidth,r=document.documentElement.clientHeight;return new DOMRect(t,e,o,r)}const Lp=y("scroll-bar-handle"),eE=2;function Vr(n){const t=as(n);let e=t.querySelector(`.${hc.SCROLL_BAR}`);return e||(e=b("div",[hc.SCROLL_BAR],t)),d(Lp,e instanceof HTMLDivElement,"invalid child for container tools"),e.firstElementChild||b("div",[],e),e}function mc(n,t){const e=Dp(t),o=Vr(e),{paddingLeft:r,paddingRight:i}=ds(t);e.style.marginLeft="",e.style.paddingLeft="",e.style.marginRight="";const s=Tu(n,e),{originWidth:l,maxRight:c}=s;XB(n,e),JB(n,e);const a=e.scrollWidth-e.clientWidth;d(Lp,o.firstElementChild instanceof HTMLDivElement,"invalid child for scroll bar"),o.style.width=`${l+c-r-i}px`,o.firstElementChild.style.width=`${l+c+a-r-i}px`}function nE(n,t){const e=sn(n),{paddingLeft:o}=ds(e);if(lt(t,"fixed")){const i=Ee(n).getBoundingClientRect();t.style.left=`${i.left+o}px`}else t.style.left=`${o}px`}function qr(n,t){const e=n.getParentScrollContainer(),o=tE(e),r=t.getBoundingClientRect(),i=Vr(t),s=i.getBoundingClientRect(),l=fc(n,Ee(t)),c=(l==null?void 0:l.barFloatWindowBottom)||0,a=sn(t),{paddingTop:u,paddingBottom:f}=ds(a),m=document.documentElement.clientHeight-c,C=o.top+e.clientHeight-m,v=m+Math.min(0,C);if(t.scrollWidth>t.clientWidth&&r.top+u<v-s.height&&r.bottom>v-s.height+f){M(i,hc.FIXED);const E=C>0?c:0;i.style.bottom=`${Math.max(document.documentElement.clientHeight-o.bottom,0)+eE+E}px`}else F(i,hc.FIXED),i.style.bottom=`${f-s.height}px`;nE(t,i)}class oE{constructor(t,e){h(this,"intersectionObserver");h(this,"handleIntersection",t=>{t.forEach(e=>{this.containers.get(Ee(e.target))?(this.handleIntersectionEntry(e),this.callback(e)):this.intersectionObserver.unobserve(e.target)})});h(this,"handleIntersectionEntry",t=>{const e=t.target;qr(this.scrollCore,e);const o=sn(e);mc(this.scrollCore,o)});this.scrollCore=t,this.callback=e;const r={root:this.scrollCore.getParentScrollContainer(),rootMargin:"20px",threshold:0};this.intersectionObserver=new IntersectionObserver(this.handleIntersection,r)}get containers(){return this.scrollCore.containers}bind(t){this.unbind(t),this.intersectionObserver.observe(t)}unbind(t){this.intersectionObserver.unobserve(t)}destroy(){this.intersectionObserver.disconnect()}}const Yo=y("container-scroll-shadow");function Mp(n,t,e){const o=n,r=t.getBoundingClientRect(),i=e.getBoundingClientRect(),{paddingTop:s,paddingBottom:l}=ds(e);o.style.top=`${i.top-r.top+s}px`,o.style.bottom=`${r.bottom-i.bottom+l}px`}function Rp(n,t){const e=n;t<24?e.style.width=`${(t/3).toFixed(2)}px`:e.style.width=""}function rE(n){const t=as(n);d(Yo,t,"no container tools");let e=t.querySelector(`.${$e.LEFT}`);if(!e){const l=sn(n),c=[$e.COMMON,$e.LEFT];e=b("div",c,t),d(Yo,e instanceof HTMLDivElement,"invalid child for container tools"),Mp(e,n,l)}d(Yo,e instanceof HTMLElement,"invalid child for container tools");const r=Ee(n).getBoundingClientRect(),i=n.getBoundingClientRect();e.style.left=`${i.left-r.left}px`;const s=n.scrollLeft;d(Yo,e instanceof HTMLDivElement,"invalid child for container tools"),Rp(e,s),M(e,$e.ACTIVE)}function iE(n){const t=as(n);let e=t.querySelector(`.${$e.RIGHT}`);if(!e){const l=sn(n),c=[$e.COMMON,$e.RIGHT];e=b("div",c,t),d(Yo,e instanceof HTMLDivElement,"no div, create shadow failed"),Mp(e,n,l)}d(Yo,e instanceof HTMLElement,"");const r=Ee(n).getBoundingClientRect(),i=n.getBoundingClientRect();e.style.right=`${r.right-i.right}px`;const s=n.scrollWidth-n.scrollLeft-n.clientWidth;d(Yo,e instanceof HTMLDivElement,"no shadow element"),Rp(e,s),M(e,$e.ACTIVE)}function sE(n){const e=as(n).querySelector(`.${$e.LEFT}`);e&&F(e,$e.ACTIVE)}function lE(n){const e=as(n).querySelector(`.${$e.RIGHT}`);e&&F(e,$e.ACTIVE)}function us(n){const t=Math.round(n.scrollLeft),e=sn(n),{paddingLeft:o,paddingRight:r}=ds(e);n.scrollWidth-o<=n.clientWidth-r||n.scrollWidth-o<=t+n.clientWidth-r?lE(n):iE(n),e&&n.scrollLeft>=e.offsetLeft+o?rE(n):sE(n)}class cE{constructor(t){h(this,"resizeObserver");h(this,"handleResizeEntry",t=>{const e=t.target,o=sn(e);us(e),mc(this.scrollCore,o),qr(this.scrollCore,e)});h(this,"handleContentResize",t=>{t.forEach(e=>{this.containers.get(Ee(e.target))?this.handleResizeEntry(e):this.unbind(e.target)})});this.scrollCore=t,this.resizeObserver=new ResizeObserver(this.handleContentResize)}get containers(){return this.scrollCore.containers}bind(t){this.unbind(t),this.resizeObserver.observe(t)}unbind(t){this.resizeObserver.unobserve(t)}destroy(){this.resizeObserver.disconnect()}}const Ap=y("container-scroll-observer");class aE{constructor(t,e){h(this,"handleContentScroll",t=>{const e=t.target;d(Ap,e instanceof Element,"invalid target for scroll event");const o=Vr(e);o.removeEventListener("scroll",this.handleScroll);const r=!0;this.fixScrollXPos(e,e.scrollLeft,r),this.bind(o),us(e),this.callback(e)});h(this,"handleScroll",t=>{const e=t.target;d(Ap,e instanceof HTMLElement,"");const o=e.scrollLeft,r=!1,i=KB(e);this.unbindContentScroll(i),this.fixScrollXPos(i,o,r),this.bindContentScroll(i),us(i),this.callback(i)});h(this,"handlePrevent",t=>{t.stopPropagation()});h(this,"bindContentScrollCore",t=>{this.unbindContentScroll(t),t.addEventListener("scroll",this.handleContentScroll)});h(this,"unbindContentScroll",t=>{t.removeEventListener("scroll",this.handleContentScroll)});h(this,"bindContentScroll",ie.default(this.bindContentScrollCore,300));h(this,"bind",ie.default(this.bindCore,200));this.scrollCore=t,this.callback=e}fixScrollXPos(t,e,o){const r=Vr(t);o||(t.scrollLeft=e),o&&r.scrollLeft!==e&&(r.scrollLeft=e)}bindCore(t){this.unbind(t),t.addEventListener("scroll",this.handleScroll),t.addEventListener("mousedown",this.handlePrevent)}unbind(t){t.removeEventListener("scroll",this.handleScroll),t.removeEventListener("mousedown",this.handlePrevent)}}class dE{constructor(t){h(this,"scrollContainers",new Set);h(this,"handleParentContainerScroll",()=>{this.scrollContainers.forEach(t=>{qr(this.scrollCore,t)})});h(this,"bindScrollContainer",t=>{const e=this.scrollContainers.size===0;this.scrollContainers.add(t),e&&this.eventTarget.addEventListener("scroll",this.handleParentContainerScroll)});h(this,"unbindScrollContainer",t=>{let e=!1;this.scrollContainers.has(t)&&(this.scrollContainers.delete(t),e=this.scrollContainers.size===0),e&&this.eventTarget.removeEventListener("scroll",this.handleParentContainerScroll)});this.scrollCore=t}get eventTarget(){const t=this.scrollCore.getParentScrollContainer();return t===document.documentElement?document:t}destroy(){this.eventTarget.removeEventListener("scroll",this.handleParentContainerScroll),this.scrollContainers.clear()}}const uE=y("scroll-wrap-resize-observer");class hE{constructor(t){h(this,"resizeObserver");h(this,"handleScrollWrapResize",t=>{t.forEach(e=>{this.containers.get(Ee(e.target))?this.handleScrollWrapResizeEntry(e):this.unbind(e.target)})});h(this,"handleScrollWrapResizeEntry",t=>{const e=t.target;d(uE,e instanceof HTMLElement,"invalid target for observer entry");const o=Dp(e);mc(this.scrollCore,e),us(o),qr(this.scrollCore,o)});this.scrollCore=t,this.resizeObserver=new ResizeObserver(this.handleScrollWrapResize)}get containers(){return this.scrollCore.containers}bind(t){this.unbind(t),this.resizeObserver.observe(t)}unbind(t){this.resizeObserver.unobserve(t)}destroy(){this.resizeObserver.disconnect()}}class fE{constructor(t){h(this,"resizeObserver");h(this,"scrollContainersMap",new Map);h(this,"handleResizeEntry",t=>{t==null||t.forEach(e=>{const o=sn(e);us(e),mc(this.scrollCore,o),qr(this.scrollCore,e)})});h(this,"handleResize",t=>{t.forEach(e=>{const o=this.scrollContainersMap.get(e.target);o!=null&&o.length&&this.handleResizeEntry(o)})});this.scrollCore=t,this.resizeObserver=new ResizeObserver(this.handleResize)}bind(t){var r,i;const e=Ee(t),o=(r=fc(this.scrollCore,e))==null?void 0:r.locatingContainer;this.scrollContainersMap.has(o)?(i=this.scrollContainersMap.get(o))==null||i.push(t):(this.scrollContainersMap.set(o,[t]),this.resizeObserver.observe(o))}unbind(t){var i,s;const e=Ee(t),o=(i=fc(this.scrollCore,e))==null?void 0:i.locatingContainer;if(!o)return;const r=this.scrollContainersMap.get(o);this.scrollContainersMap.set(o,(r==null?void 0:r.filter(l=>l!==t))||[]),(s=this.scrollContainersMap.get(o))!=null&&s.length||(this.resizeObserver.unobserve(o),this.scrollContainersMap.delete(o))}destroy(){this.scrollContainersMap.clear(),this.resizeObserver.disconnect()}}const vF="";class mE extends Wt.TypedEmitter{constructor(e){super();h(this,"containerIntersectionObserver",null);h(this,"containerResizeObserver",null);h(this,"containerScrollObserver",null);h(this,"parentContainerScrollObserver",null);h(this,"scrollWrapResizeObserve",null);h(this,"locatingContainerResizeObserver",null);h(this,"isWindowEventBind",!1);h(this,"containers",new Map);h(this,"handleScrollContainerScroll",e=>{this.emit("scroll",this,e)});h(this,"handleIntersection",e=>{const o=e.target,r=sn(o);e.isIntersecting?(this.load(),this.bindCore(o,r)):this.unbindCore(o,r)});h(this,"handleWindowEffect",()=>{var e;(e=this.getScrollContainerInViewable())==null||e.forEach(o=>{qr(this,o)})});this.parentContainer=e}load(){this.containerResizeObserver||(this.containerResizeObserver=new cE(this)),this.containerScrollObserver||(this.containerScrollObserver=new aE(this,this.handleScrollContainerScroll)),this.parentContainerScrollObserver||(this.parentContainerScrollObserver=new dE(this)),this.scrollWrapResizeObserve||(this.scrollWrapResizeObserve=new hE(this)),this.locatingContainerResizeObserver||(this.locatingContainerResizeObserver=new fE(this)),this.isWindowEventBind||(window.addEventListener("resize",this.handleWindowEffect),this.getParentScrollContainer()!==document.documentElement&&window.addEventListener("scroll",this.handleWindowEffect))}getParentScrollContainer(){return this.parentContainer}getScrollContainerInViewable(){var e;return(e=this.parentContainerScrollObserver)==null?void 0:e.scrollContainers}unbindCore(e,o){var i,s,l,c,a,u;const r=Vr(e);(i=this.containerScrollObserver)==null||i.unbindContentScroll(e),(s=this.containerScrollObserver)==null||s.unbind(r),(l=this.scrollWrapResizeObserve)==null||l.unbind(o),(c=this.containerResizeObserver)==null||c.unbind(e),(a=this.parentContainerScrollObserver)==null||a.unbindScrollContainer(e),(u=this.locatingContainerResizeObserver)==null||u.unbind(e)}bindCore(e,o){var i,s,l,c,a,u;if(this.unbindCore(e,o),!e.closest("body"))return;const r=Vr(e);(i=this.containerScrollObserver)==null||i.bindContentScrollCore(e),(s=this.containerScrollObserver)==null||s.bindCore(r),(l=this.scrollWrapResizeObserve)==null||l.bind(o),(c=this.containerResizeObserver)==null||c.bind(e),(a=this.parentContainerScrollObserver)==null||a.bindScrollContainer(e),(u=this.locatingContainerResizeObserver)==null||u.bind(e)}bind(e,o){this.containers.set(e,o);const r=e.firstElementChild;this.containerIntersectionObserver||(this.containerIntersectionObserver=new oE(this,this.handleIntersection)),this.containerIntersectionObserver.bind(r)}unbind(e){var i;const o=e.firstElementChild,r=sn(o);this.unbindCore(o,r),this.containers.delete(e),(i=this.containerIntersectionObserver)==null||i.unbind(o),this.containers.size||this.destroy()}destroy(){var e,o,r,i,s;this.containers.forEach((l,c)=>{this.unbind(c)}),this.containers.clear(),(e=this.parentContainerScrollObserver)==null||e.destroy(),(o=this.containerIntersectionObserver)==null||o.destroy(),(r=this.containerResizeObserver)==null||r.destroy(),(i=this.scrollWrapResizeObserve)==null||i.destroy(),(s=this.locatingContainerResizeObserver)==null||s.destroy(),window.removeEventListener("resize",this.handleWindowEffect),window.removeEventListener("scroll",this.handleWindowEffect)}}const gc=new Map;class gE extends Wt.TypedEmitter{constructor(e){super();h(this,"scrollListener");h(this,"scrollContainerElement");h(this,"handleContainerScroll",(e,o)=>{o===this.scrollContainerElement&&this.emit("scroll",this)});this.options=e;const o=b("div",[mo.CONTAINER],e.parentElement);It.isMac&&M(o,mo.MAC);const r=b("div",[mo.SCROLL_CONTAINER],o),i=b("div",[mo.SCROLL_AREA],r);i.style.paddingLeft=e.paddingLeft?`${e.paddingLeft}px`:"",i.style.paddingTop=e.paddingTop?`${e.paddingTop}px`:"",i.style.paddingBottom=e.paddingBottom?`${e.paddingBottom}px`:"",i.style.paddingRight=e.paddingRight?`${e.paddingRight}px`:"",i.appendChild(e.childElement);const s=e.parentContainer;this.scrollListener=gc.get(s),this.scrollListener||(this.scrollListener=new mE(s),gc.set(s,this.scrollListener)),this.scrollListener.unbind(o),this.scrollListener.bind(o,e),this.scrollListener.on("scroll",this.handleContainerScroll),this.scrollContainerElement=r}get rootElement(){return this.scrollContainerElement}get contentElement(){return sn(this.scrollContainerElement)}get scrollOptions(){return{...this.options}}handleBaseListenerDestroy(e){e.destroy()}destroy(){this.scrollListener.off("scroll",this.handleContainerScroll);const e=Ee(this.contentElement);e&&gc.forEach((o,r)=>{o.unbind(e),o.containers.size===0&&(this.handleBaseListenerDestroy(o),gc.delete(r))})}}function pE(n){return new gE(n)}const Du=y("column-width");function CE(n,t,e){BB(n,t).style.width=`${e}px`}function bE(n){const e=Array.from(n.querySelector("colgroup").children).map(c=>c.getBoundingClientRect().width);if(e[0]!==0)return e;const o=nt.fromTable(n),r=Array(o.colCount).fill(-1),i=n.getBoundingClientRect().left;o.toRealCells(o.cells).forEach(c=>{const a=c.col+c.colSpan-1;r[a]===-1&&(r[a]=c.cell.getBoundingClientRect().right-i)}),Du.debug(`cellRightOffsets1: ${r.join()}`);for(let c=0;c<r.length;c++){const a=r[c];if(a===-1||c===0)continue;let u=c-1;for(;r[u]===-1&&(u--,u!==-1););const f=u===-1?0:r[u],C=(a-f)/(c-u);for(let v=u+1;v<c;v++)r[v]=f+C*(v-u)}Du.debug(`cellRightOffsets2: ${r.join()}`);const s=[];let l=0;for(let c=0;c<r.length;c++){const a=r[c];s.push(a-l),l=a}return Du.debug(`widths: ${s.join()}`),s}function hs(n){return Array.from(n.querySelector("colgroup").children).map(o=>o.getBoundingClientRect().width||Number.parseInt(o.style.width,10)||100)}const Lu=100,vE=40,kE=y("table-resize-gripper"),Op=7,Mu=(Op-1)/2,yE=3;function wE(n,t,e){const{rows:o}=n;for(let r=0;r<o.length;r++){const i=o[r],s=Array.from(i.cells);for(let l=0;l<s.length;l++){const c=s[l],a=c.getBoundingClientRect(),u=Math.round(a.right);if(Math.abs(t-u)<=Mu&&a.top<=e&&e<=a.bottom)return c}}return null}function BE(n){return!!n.rootContainer.querySelector(".table-resize-gripper")}function Ru(n,t){return wn(n,t).querySelector(".table-resize-gripper")}function _p(n,t){const e=Ru(n,t);d(kE,!e,"resize gripper has already exists");const o=wn(n,t),r=b("div",["table-resize-gripper","table-indicator"],o);return b("div",["table-resize-gripper-indicator"],r),r}function Np(n,t,e){let o=Ru(n,t);o||(o=_p(n,t));const i=$t(t).getBoundingClientRect(),s=e.getBoundingClientRect(),l=0,c=i.height,a=n.getCustom(fo(t)).contentElement.getBoundingClientRect(),u=s.right-a.left;o.style.left=`${u-Mu-wu-ls}px`,o.style.top=`${l}px`,o.style.height=`${c}px`,o.style.width=`${Op}px`}function Au(n){n.rootContainer.querySelectorAll(".table-resize-gripper").forEach(t=>{t.remove()})}function EE(n,t,e){const r={...n.getBlockData(t),colsWidth:e};n.updateBlockData(t,r)}function IE(n,t,e,o){const r=t,i=nt.fromTable(e),s=i.getCellByCellElement(r),l=s.col+s.colSpan-1,c=hs(e);let a=o;const u=(m,C)=>{const v=C+1,w=m.col+m.colSpan;return c.slice(v,w).reduce((L,x)=>L+x,0)},f=new Set;for(let m=0;m<i.rowCount;m++){const C=i.getCell({row:m,col:l});if(f.has(C.cell))continue;f.add(C.cell);const v=C.cell,w=v.getBoundingClientRect();let E=o-w.left+Mu-yE;const L=is(v),x=m1(n,L)||vE*C.colSpan,A=u(C,l),O=x-A;E<O&&(E=O);const P=w.left+E;a=Math.max(a,P)}return a}const xE=y("table-resize-drag-drop");class SE{constructor(t,e,o,r){h(this,"cursor","col-resize");this.editor=t,this.elem=e,this.data=o,this.onEnd=r}onDragStart(t,e,o){}onDragging(t,e,o,r,i){const{table:s,block:l,draggingRefCell:c}=t.data,u=IE(this.editor,c,s,e.x-t.dragOffsetX)-s.getBoundingClientRect().left;d(xE,c,"no dragging cell");const m=nt.fromTable(s).getCellByCellElement(c),C=m.col+m.colSpan-1,w=hs(s).slice(0,C).reduce((L,x)=>L+x,0),E=u-w;CE(s,C,E),Np(this.editor,l,c),this.editor.selection.caret.update()}onDragEnd(t,e,o,r,i){const s=hs(t.data.table);EE(this.editor,t.data.block,s),Au(this.editor),this.onEnd&&(this.onEnd(e),this.onEnd=null)}}function TE(n,t){const e=document.elementFromPoint(t.x,t.y);if(!e)return null;const o=z(e);return!o||!n.contains(o)||!Ht(o)?null:o}y("table-resize");class DE{constructor(t){h(this,"draggingRefCell",null);h(this,"handleMouseMove",(t,e)=>{if(t.readonly||t.selectionHandler.isSelecting()&&!this.draggingRefCell||this.draggingRefCell)return;const o=e.target;if(!(o instanceof Element)||o.closest(".table-indicator"))return;const i=e,s=TE(t,i);if(!s||!fp(s)){Au(t);return}this.updateGripper(s,i.x,i.y)});this.editor=t,t.domEvents.addEventListener(document,"mousemove",this.handleMouseMove)}destroy(){this.editor.domEvents.removeEventListener(document,"mousemove",this.handleMouseMove)}updateGripper(t,e,o){const r=$t(t),i=wE(r,e,o);if(i){if(!Ru(this.editor,t)){if(BE(this.editor))return;const l=_p(this.editor,t),c={block:t,table:r,draggingRefCell:i};Za(new SE(this.editor,l,c,a=>{this.updateGripper(t,a.x,a.y)}))}Np(this.editor,t,i)}else Au(this.editor)}}function Pp(n){n.addCustom("table-mouse-event-handler",t=>new DE(t))}const $p=y("table-insert-column");function Hp(n,t,e){const o=$t(t),r=nt.fromTable(o),i=r.colCount;d($p,e>=0&&e<=i,`insert index ${e} is out of range [0, ${i}]`);const s=r.map(m=>m.containerId),l=new Set;n.doc.beginBatchUpdate();for(let m=0;m<s.length;m++){const C=s[m],v=C[e-1],w=C[e];if(e===0||e===C.length||v!==w){const E=pn(n.doc);C.splice(e,0,E)}else C.splice(e,0,v),l.add(v)}n.doc.endBatchUpdate();const c=Y.default(n.getBlockData(t));l.forEach(m=>{const C=`${m}_colSpan`,v=c[C];d($p,typeof v=="number"&&v>1,`no colSpan for containerId ${m}, ${v}`),c[C]=v+1});const a=c.colsWidth.concat();a.splice(e,0,Lu);const u=nt.virtualCellContainersGridToChildren(s),f={...c,cols:c.cols+1,children:u,colsWidth:a};Go(f),n.updateBlockData(t,f)}const pc=y("table-insert-row");function jp(n,t,e){const o=$t(t),r=nt.fromTable(o),i=r.rowCount;d(pc,e>=0&&e<=i,`insert index ${e} is out of range [0, ${i}]`);const s=r.map(m=>m.containerId),l=new Set;n.doc.beginBatchUpdate();const c=[];for(let m=0;m<r.colCount;m++){const C=e>0&&s[e-1][m],v=e<r.rowCount&&s[e][m];if(d(pc,C||v,"no top and bottom cell"),e===0||e===r.rowCount||C!==v){const w=pn(n.doc);c.push(w)}else d(pc,C,"no top cell"),c.push(C),l.add(C)}n.doc.endBatchUpdate(),s.splice(e,0,c);const a=Y.default(n.getBlockData(t));l.forEach(m=>{const C=`${m}_rowSpan`,v=a[C];d(pc,typeof v=="number"&&v>1,`no rowSpan for containerId ${m}, ${v}`),a[C]=v+1});const u=nt.virtualCellContainersGridToChildren(s),f={...a,rows:a.rows+1,children:u};Go(f),n.updateBlockData(t,f)}const Ou=y("paste-table-in-table-block");function LE(n,t,e,o){let r=nt.fromBlock(e);const i=t.blocks.root[0];d(Ou,i,"no table data"),d(Ou,i.type==="table",`table data type is not table, but ${i.type}`);const s=i,l=r.getCellByCellElement(o),c=s.cols,a=s.rows,u=l.col,f=l.row,m=u+c,C=f+a,v=[];for(let w=u;w<m&&w<r.colCount;w++)for(let E=f;E<C&&E<r.rowCount;E++){const L=r.getCell({col:w,row:E});L.virtual?L.virtual&&v.push({col:w,row:E}):(L.colSpan>1||L.rowSpan>1)&&v.push({col:w,row:E})}n.undoManager.runInGroup(()=>{if(v.forEach(x=>{const A=nt.fromBlock(e).getCell(x);(A.colSpan>1||A.rowSpan>1)&&bu(n,e,x)}),m>r.colCount)for(let x=r.colCount;x<m;x++)Hp(n,e,x);if(C>r.rowCount)for(let x=r.rowCount;x<C;x++)jp(n,e,x);r=nt.fromBlock(e);const w=new fu(s);let E;for(let x=0;x<w.colCount;x++)for(let A=0;A<w.rowCount;A++){const O=w.getCell({col:x,row:A});if(!O.virtual){const P=K1(n.editorBlocks,t,O.containerId),V=u+x,tt=f+A,ot={col:V,row:tt},ut=r.getCellContainer(ot);w2(n,ut,P),E=ut}}d(Ou,E,"no last container");const L=Gt(E);n.selection.selectBlock(L,Z(n,L))})}const Fp=y("paste-in-table-block");class ME{constructor(t){this.editor=t,setTimeout(()=>{t.input.addHandler(this)})}destroy(){}async handleBeforePasteDoc(t,e){if(!t.selection.range.isSimple()||t.selection.range.start.offset!==0)return!1;const r=t.selection.startBlock,i=H(r);if(Ct(i)||!g1(t,i))return!1;const s=z(i);if(d(Fp,s,"no parent block"),!Ht(s)||e.blocks.root.length!==1||e.blocks.root[0].type!=="table")return!1;Fp.debug("paste child table in table");const a=nt.fromBlock(s).getCellByContainerId(U(i)).cell;return LE(t,e,s,a),!0}}function zp(n){n.addCustom("table-block-paste-event",t=>new ME(t))}const _u=y("table-select-columns");function RE(n,t,e,o,r){d(_u,Ht(t),"is not a table block");const i=nt.fromBlock(t);d(_u,e>=0&&e<i.colCount,"invalid from"),d(_u,o>0&&e+o<=i.colCount,"invalid count");const s=i.getCell({row:0,col:e}),l=i.getCell({row:i.rowCount-1,col:e+o-1}),c=bt(t,s.containerId,{colIndex:e,rowIndex:0}),a=bt(t,l.containerId,{colIndex:e+o-1,rowIndex:i.rowCount-1});r!=null&&r.reverse?n.selection.setSelection(a,c):n.selection.setSelection(c,a)}const Nu=y("table-select-columns");function AE(n,t,e,o,r){d(Nu,Ht(t),"is not a table block");const i=nt.fromBlock(t);d(Nu,e>=0&&e<i.rowCount,"invalid from"),d(Nu,o>0&&e+o<=i.rowCount,"invalid count");const s=i.getCell({row:e,col:0}),l=i.getCell({row:e+o-1,col:i.colCount-1}),c=bt(t,s.containerId,{rowIndex:e,colIndex:0}),a=bt(t,l.containerId,{rowIndex:e+o-1,colIndex:i.colCount-1});r!=null&&r.reverse?n.selection.setSelection(a,c):n.selection.setSelection(c,a)}const kF="",Up=y("get-toolbar-reference-client");function OE(n,t){const e=n.selection.range;if(!e.isSimple()){d(Up,e.start.blockId===e.end.blockId,"invalid selection range");const s=n.getBlockById(e.start.blockId);d(Up,ct(n,s),"not a complex block");const l=kt(n,s);if(l.getTextToolbarReferenceClient){const c=l.getTextToolbarReferenceClient(n,s);if(c)return c}}const o=e.isReverse()?t.start:t.end,r=Vt(n,{anchor:o,focus:o}),i=Ao(n,t.block,r);if(i.length!==0)return i[0]}function _E(n){var t,e;if(n.children){let o=!1;const r=[];for(const i of n.children){if((t=i.states)!=null&&t.includes("checked")){o=!0;break}(e=n.defaultCheckedChildren)!=null&&e.includes(i.id)&&r.push(i)}if(!o&&(r==null?void 0:r.length))for(const i of r)Array.isArray(i.states)?i.states.push("checked"):i.states=["checked"]}}function Cc(n){const t=(r,i)=>{const s=r.findIndex(c=>c.id===i.id);if(s===-1){r.push(i);return}const l=r[s];if(l.value!==i.value&&delete l.value,!!l.states){if(!i.states){l.states=[];return}l.states=Fa.default(l.states,i.states)}},e=[],o=new Map;return n.forEach(r=>{var i,s;(i=r.children)!=null&&i.length&&(o.has(r.id)?(s=o.get(r.id))==null||s.push(...r.children):o.set(r.id,[...r.children])),t(e,r)}),o.forEach((r,i)=>{const s=e.find(l=>l.id===i);s&&(s.children=Cc(r),_E(s))}),e}function bc(n){return n.getCustom("toolbar-handler")}const yF="";class NE{constructor(){h(this,"linkPopup",null);h(this,"form",{});h(this,"onFinished",null);h(this,"onClose",null);h(this,"handleOk",async()=>{var t;try{await this.checkValue();const{linkText:e,linkUrl:o}=this.form;(t=this.onFinished)==null||t.call(this,e.getInputValue()||o.getInputValue(),o.getInputValue()),this._destroy()}catch{}});h(this,"handleClose",()=>{var t;(t=this.onClose)==null||t.call(this),this._destroy()});h(this,"onShow",()=>{setTimeout(()=>{var t;(t=this.form.linkText)==null||t.getField().focus()},400)});h(this,"onChange",()=>{var e;const t=(e=this.linkPopup)==null?void 0:e.content.querySelector(".submit-button");t.disabled=!1});h(this,"handleTextKeyboard",t=>{var e;if(!t.isComposing){if(t.key==="Enter"){(e=this.form.linkUrl)==null||e.getField().focus(),t.stopPropagation();return}t.key==="Escape"&&this.handleClose()}});h(this,"handleUrlKeyboard",t=>{if(!t.isComposing){if(t.key==="Enter"){this.handleOk(),t.preventDefault();return}t.key==="Escape"&&this.handleClose()}})}async checkValue(){const{linkUrl:t}=this.form;if(!t.getInputValue())throw t.setFieldError(S.t("link.urlPlaceholder")),new Error(S.t("link.urlPlaceholder"))}editLink(t){var u,f;const{target:e,linkText:o,linkUrl:r,onFinished:i,onClose:s,placement:l="bottom-start"}=t;this.linkPopup=new lc(this.createPopupContent(o,r)),this.linkPopup.addListener("show",this.onShow),this.linkPopup.manualShow(e,{theme:"light",placement:l}),this.onFinished=i,s&&(this.onClose=s);const c=(u=this.linkPopup)==null?void 0:u.content.querySelector(".submit-button"),a=(f=this.linkPopup)==null?void 0:f.content.querySelector(".cancel-button");c==null||c.addEventListener("click",this.handleOk),a==null||a.addEventListener("click",this.handleClose)}createPopupContent(t,e){const o=b("div",["link-popup-content"],null);this.form.linkText=cc(o,{label:S.t("link.textLabel"),required:!1,placeholder:S.t("link.textPlaceholder"),defaultValue:t,onChange:this.onChange,onKeyDown:this.handleTextKeyboard}),this.form.linkUrl=cc(o,{className:"link-popup-gap",label:S.t("link.urlLabel"),required:!0,placeholder:S.t("link.urlPlaceholder"),defaultValue:e,onChange:this.onChange,onKeyDown:this.handleUrlKeyboard});const r=b("div",["link-popup-footer"],o);b("button",["cancel-button"],r,S.t("link.cancelText"));const i=b("button",["submit-button"],r,S.t("link.submitText"));return i.disabled=!0,o}_destroy(){var o,r,i,s;const t=(o=this.linkPopup)==null?void 0:o.content.querySelector(".submit-button"),e=(r=this.linkPopup)==null?void 0:r.content.querySelector(".cancel-button");t==null||t.removeEventListener("click",this.handleOk),e==null||e.removeEventListener("click",this.handleClose),this.onFinished=null,this.onClose=null,this.form={},(i=this.linkPopup)==null||i.removeAllListeners(),(s=this.linkPopup)==null||s.destroy()}destroy(){this._destroy()}}function vc(n,t){n.addCustom("link-editor",()=>new NE).editLink(t)}const PE=y("link-popup");function $E(n){return lt(n,"link")}function kc(n){var t,e;return(e=(t=n.getAttribute("link"))!=null?t:n.textContent)!=null?e:""}function HE(n,t,e){var r,i,s,l;if(n.isBlockWritable(t)&&e&&Me(e)){const c=e,a=(i=(r=n.editorBoxes.getBoxClass(Si(c))).getBoxProperties)==null?void 0:i.call(r,n,c);return a!=null&&a.boxCommands?(l=(s=a.boxCommands["hovering-toolbar"])==null?void 0:s.commands)!=null?l:[]:[]}return n.isWritable()&&e&&j(n,t)&&$E(e)?[{id:"link-text",name:kc(e),element:b("span",["link-href-button"],null,kc(e))},{id:"edit-link",name:"Edit",icon:sc},{id:"remove-link",name:"Remove link",icon:D5}]:Jm(n,t,"hovering-toolbar")}function jE(n,t,e){var c;const o=Er(t,e);n.selection.selectBlock(t,o.start,o.end);const r=(c=e.textContent)!=null?c:"",i=kc(e);vc(n,{target:e,linkText:r,linkUrl:i,onFinished:(a,u)=>{try{const f=n.getBlockText(t),m=R1(f,o.start,o.end-o.start),C=xr(m,o.start,a,{link:u});n.setBlockText(t,C),n.selection.selectBlock(t,o.start+a.length),n.focus()}catch(f){PE.error(f)}},onClose:()=>{n.selection.selectBlock(t,o.end),n.focus()}})}function FE(n,t,e){const o=Er(t,e),r=n.getBlockText(t),i=kc(e),s=Sr(o.start,o.end-o.start,r,"link",i);n.setBlockText(t,s),n.selection.selectBlock(t,o.end)}function zE(n,t,e,o){var s,l,c;if(e){if(n.isBlockWritable(t)&&Me(e)){const u=e,f=(l=(s=n.editorBoxes.getBoxClass(Si(u))).getBoxProperties)==null?void 0:l.call(s,n,u);if(f!=null&&f.boxCommands){f.boxCommands["hovering-toolbar"].executeCommand(n,t,u,o);return}return}const a=bc(n);a.disableTextToolbar(),a.hide(),setTimeout(()=>{a.enableTextToolbar()},1e4),o.id==="edit-link"?jE(n,t,e):o.id==="remove-link"&&FE(n,t,e);return}const r=Km(n,t);if(!r)return;const i=(c=r.blockCommands)==null?void 0:c["hovering-toolbar"];!i||i.executeCommand(n,t,o)}const UE=[Qd,Kd,Jd,Xd,tu,eu,nu,ou];class VE{constructor(t){h(this,"id","BlockTurnIntoCommandProvider");this.editor=t}getHeadingIndex(){return 6}getAvailableCommands(t,e,o){if(j(t,e)){const r=G(e),i=it(e),s=We(t,e),c=t.getBlockData(e).heading,a=[];for(let f=0;f<this.getHeadingIndex();f++)a.push({id:`heading-${f+1}`,name:S.t("commands.heading",{name:`${f+1}`}),icon:UE[f],states:c===f+1?["checked"]:[],value:`${f+1}`});return[{id:"turn-into",name:"",blockId:r,blockType:i,blockKind:s,element:f=>{var C;const m=b("span",["toolbar-item-name-container"],null);for(const v of f.children)if((C=v.states)!=null&&C.includes("checked"))return m.innerHTML=v.icon||ns,m;return m.innerHTML=ns,m},groupIndex:200,dropdown:!0,manualShowChildren:!0,childrenPlacement:"bottom-start",defaultCheckedChildren:["text"],children:[{id:"text",name:S.t("commands.text"),icon:ns,states:c?[]:["checked"]},...a],childrenType:"menu"}]}return[]}applyHeadingStyle(t,e,o){t.updateBlockData(e,{heading:o})}executeCommand(t,e,o,r){if(j(t,e)&&(r.id.startsWith("heading-")||r.id==="text")){const i=r.value?Number(r.value):null;return this.applyHeadingStyle(t,e,i),!0}return!1}}const yc=y("list-block");function at(n){return it(n)==="list"}function jt(n){d(yc,at(n),"not a list block")}function He(n){jt(n);const t=n.getAttribute("data-list-type");return d(yc,t,"no list type"),t}function wc(n){return at(n)&&He(n)==="text-only"}function Ie(n){var t,e;return jt(n),(e=Number.parseInt((t=n.getAttribute("data-list-start"))!=null?t:"1",10))!=null?e:1}function xe(n){var t,e;return jt(n),(e=Number.parseInt((t=n.getAttribute("data-list-level"))!=null?t:"1",10))!=null?e:1}function Qo(n){jt(n);const t=n.getAttribute("data-list-group-id");return d(yc,t,"no group id"),t}function go(n){var i,s,l,c,a;jt(n);const t=(i=n.getAttribute("data-list-type"))!=null?i:"ordered",e=(l=Number.parseInt((s=n.getAttribute("data-list-start"))!=null?s:"1",10))!=null?l:1,o=(a=Number.parseInt((c=n.getAttribute("data-list-level"))!=null?c:"1",10))!=null?a:1,r=n.getAttribute("data-list-group-id");return d(yc,r,"no group id"),{type:t,start:e,level:o,groupId:r}}function Bc(n){switch(n){case"ordered":return{ordered:!0,checkbox:null,textOnly:null};case"unordered":return{ordered:!1,checkbox:null,textOnly:null};case"checked":return{checkbox:"checked",ordered:!1,textOnly:null};case"unchecked":return{checkbox:"unchecked",ordered:!1,textOnly:null};case"text-only":return{checkbox:null,ordered:!1,textOnly:!0};default:return{checkbox:null,ordered:!0,textOnly:!1}}}function qn(n){jt(n);const{level:t,groupId:e,type:o}=go(n);let r=gt(n);for(;r;){if(!at(r))return null;const{level:i,groupId:s,type:l}=go(r);if(i<t)return null;if(t===i&&e===s&&(l==="text-only"||o==="text-only"||o===l))return r;r=gt(r)}return null}function Ko(n){jt(n);const{level:t,groupId:e,type:o}=go(n);let r=ht(n);for(;r;){if(at(r)){const{level:i,groupId:s,type:l}=go(r);if(t===i&&e===s&&(l==="text-only"||o==="text-only"||o===l))return r;if(i<t)return null}r=ht(r)}return null}function Vp(n){jt(n);const t=[];let e=qn(n);for(;e;)t.unshift(e),e=qn(e);return t}function Ec(n){jt(n);const t=[];let e=Ko(n);for(;e;)t.push(e),e=Ko(e);return t}function fs(n){jt(n);let t=qn(n);for(;t;){const e=qn(t);if(!e)return t;t=e}return n}function qE(n){jt(n);let t=Ko(n);for(;t;){const e=Ko(t);if(!e)return t;t=e}return null}function WE(n,t){const e=Vp(n),o=Ec(n);return t.withSelf?[...e,n,...o]:[...e,...o]}function Ic(n,t,e,o){var i;const r=(i=o==null?void 0:o.groupId)!=null?i:N();t.forEach(s=>{const l=n.getBlockData(s);if(l.start!==e||(o==null?void 0:o.resetGroupId)){const c={...l,start:e};o!=null&&o.resetGroupId&&(c.groupId=r),n.updateBlockData(s,c)}l.textOnly||(e+=1)})}function Pu(n,t,e,o){const r=WE(t,{withSelf:!0});r.length!==0&&Ic(n,r,e,o)}function GE(n){const t={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1};let e="",o=n;return Object.entries(t).forEach(([r,i])=>{for(;o>=i;)e+=r,o-=i}),e.toLowerCase()}const ZE="abcdefghijklmnopqrstuvwxyz";function qp(n){if(n<=0)return`${n}`;const t=(n-1)%26,e=Math.floor((n-1)/26),o=ZE[t];return e?qp(e)+o:o}function YE(n){return`${n}`}const Wp=[YE,qp,GE];function QE(n,t){const e=Wp[(n-1)%Wp.length];return e(t)}function KE(n){return["\u2022","\u25E6","\u25AA"][(n-1)%3]}class Jo{constructor(t,e,o){h(this,"listStart");h(this,"listBrother",null);this.editor=t,this.options=o;const r=fs(e),i=Ie(r);this.listStart=i,this.listBrother=r,o!=null&&o.resetStart&&(this.listStart=1)}fix(){!this.listBrother||Pu(this.editor,this.listBrother,this.listStart,this.options)}}function JE(n,t,e=1){if(!t)return null;let o=gt(n);for(;o;){const r=o.getAttribute("data-style-heading"),i=Number(o.getAttribute("data-list-level"));if(r){if(r<t)return null;if(r===t&&i===e)return at(o)?o:null}o=gt(o)}return null}function Gp(n,t){const e=n.getAttribute("data-style-heading"),o=JE(n,e);if(o)return o;const r=gt(n);if(r&&at(r)&&He(r)===t)return r;const i=ht(n);return i&&at(i)&&He(i)===t?i:null}function XE(n,t,e){var E,L,x;const o=(E=e.data)!=null?E:{},r=1,i=(L=o.listType)!=null?L:"ordered";if(i==="text-only")return null;const s=n.getBlockData(t);let l=(x=s.text)!=null?x:[];const c=n.selection.range.focus;if(!c.isSimple())return null;let u=Tt(l);const f=c.offset;f<=ce(l)&&(l=Ae(l,f).right,u=u.substring(0,f));let m=1;i==="ordered"&&(m=Number.parseInt(u,10)||1);let C=N();const v=Gp(t,i);if(v){if(K(t)>K(v))m=Ie(v)+1;else{const A=Ie(v);A>1&&(m=A-1)}C=Qo(v)}const w={id:N(),type:"list",level:r,start:m,groupId:C,ordered:!1,text:l};return s.quoted&&(w.quoted=!0),s.heading&&(w.heading=s.heading),i==="ordered"?w.ordered=!0:(i==="checked"||i==="unchecked")&&(w.checkbox=i),{blockData:w,onConverted:(A,O)=>{new Jo(A,O).fix()}}}const tI=8,Lt=y("list-block");class xc{constructor(t,e){h(this,"listStart",0);h(this,"listBrother",null);if(this.editor=t,wc(e))return;const o=fs(e),r=Ie(o);this.listStart=r,o===e?this.listBrother=Ko(o):this.listBrother=o}fix(){!this.listBrother||Pu(this.editor,this.listBrother,this.listStart)}}function eI(n,t,e){n.getBlockData(t).quoted&&(e.quoted=!0)}function $u(n,t,e,o){if(Lt.debug("drag a block on a list block"),!j(n,t))return!1;d(Lt,at(e),"target is not a list block");const{type:r,start:i,level:s,groupId:l}=go(e),c=o==="after"?i+1:i,a=n.getBlockData(t),u={id:N(),type:"list",groupId:l,level:s,start:c,text:a.text,...Bc(r)};eI(n,e,u);let f=K(e);const m=H(e);o==="after"&&(f+=1);let C=null;at(t)&&(C=new xc(n,t));const v=n.insertBlock(U(m),f,u,Tl(u.id,0));return n.deleteBlock(t),new Jo(n,v).fix(),C==null||C.fix(),!0}function nI(n,t,e,o){if(Lt.debug("drag a list between text blocks"),o==="after"){const a=ht(e);if(a&&at(a))return $u(n,t,a,"before")}if(o==="before"){const a=gt(e);if(a&&at(a))return $u(n,t,a,"after")}const i={...n.getBlockData(t),groupId:N(),start:1,level:1};let s=K(e);const l=H(e);o==="after"&&(s+=1),n.insertBlock(U(l),s,i,Tl(i.id,0));const c=new xc(n,t);return n.deleteBlock(t),c.fix(),!0}function oI(n,t,e,o,r){if(sl(e))return!1;const{blockId:i}=e,s=n.getBlockById(i);d(Lt,s,"no dragged block");const{isSourceBlock:l,targetBlock:c}=r;return!l&&c?(d(Lt,t===c,"block !== target block"),d(Lt,at(c),"target is not a list block"),$u(n,s,c,o)):nI(n,s,c,o)}function Zp(n){return n.textOnly?"text-only":n.checkbox?n.checkbox:n.ordered?"ordered":"unordered"}function rI(n){var e,o;if(n.checkbox||n.textOnly)return"";const t=(e=n.level)!=null?e:1;return n.ordered?`${QE(t,(o=n.start)!=null?o:1)}.`:KE(t)}const iI=`<?xml version="1.0" ?>
416
416
  <svg t="1666868766077" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3547" width="16" height="16">
417
417
  <path d="M864 128H160c-17.6 0-32 14.4-32 32v704c0 17.6 14.4 32 32 32h704c17.6 0 32-14.4 32-32V160c0-17.6-14.4-32-32-32zM428 718.4l-45.6 45.6-45.6-45.6-116-117.6 45.6-45.6L383.2 672l367.2-367.2 45.6 45.6-368 368z" p-id="3548" fill="#1296db"></path>
418
418
  </svg>
419
419
  `,sI=`<?xml version="1.0" ?>
420
420
  <svg t="1666868691722" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="3301" width="16" height="16">
421
421
  <path d="M832 192v640H192V192h640m32-64H160c-17.6 0-32 14.4-32 32v704c0 17.6 14.4 32 32 32h704c17.6 0 32-14.4 32-32V160c0-17.6-14.4-32-32-32z" p-id="3302" fill="#dbdbdb"></path>
422
- </svg>`;function lI(n,t){const e=Zp(t);if(e!=="text-only"){if(e==="checked"){n.innerHTML=iI;return}if(e==="unchecked"){n.innerHTML=sI;return}n.innerText=rI(t)}}function cI(n){const t=b("div",["list-container"],null),e=b("button",["list-marker"],t);return lI(e,n),t}function Hu(n){jt(n);let t=n;const e=Up(n);e.length>0&&(t=e[0]);const o=gt(t);return!o||!at(o)?null:xe(o)<xe(t)?o:null}function aI(n){let t=fs(n);for(;;){const e=Hu(t);if(!e)return t;t=fs(e)}}class dI{constructor(){h(this,"nodeMap",new Map);h(this,"rootNodes",[])}addNode(t,e){const o={block:e,children:[]};if(this.nodeMap.set(e,o),t){const r=this.nodeMap.get(t);d(Lt,r,"no parent node"),r.children.push(o)}else this.rootNodes.push(o)}}function Yp(n,t){const e=aI(t),o=new dI;o.addNode(null,e);let r=ht(e);for(;r&&at(r);){if(wc(r)){o.addNode(null,r),r=ht(r);continue}if(xe(r)===0&&He(r)!==He(e))break;const s=Hu(r);o.addNode(s,r),r=ht(r)}return o.rootNodes}const uI=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
422
+ </svg>`;function lI(n,t){const e=Zp(t);if(e!=="text-only"){if(e==="checked"){n.innerHTML=iI;return}if(e==="unchecked"){n.innerHTML=sI;return}n.innerText=rI(t)}}function cI(n){const t=b("div",["list-container"],null),e=b("button",["list-marker"],t);return lI(e,n),t}function Hu(n){jt(n);let t=n;const e=Vp(n);e.length>0&&(t=e[0]);const o=gt(t);return!o||!at(o)?null:xe(o)<xe(t)?o:null}function aI(n){let t=fs(n);for(;;){const e=Hu(t);if(!e)return t;t=fs(e)}}class dI{constructor(){h(this,"nodeMap",new Map);h(this,"rootNodes",[])}addNode(t,e){const o={block:e,children:[]};if(this.nodeMap.set(e,o),t){const r=this.nodeMap.get(t);d(Lt,r,"no parent node"),r.children.push(o)}else this.rootNodes.push(o)}}function Yp(n,t){const e=aI(t),o=new dI;o.addNode(null,e);let r=ht(e);for(;r&&at(r);){if(wc(r)){o.addNode(null,r),r=ht(r);continue}if(xe(r)===0&&He(r)!==He(e))break;const s=Hu(r);o.addNode(s,r),r=ht(r)}return o.rootNodes}const uI=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
423
423
  <path fill-rule="evenodd" clip-rule="evenodd" d="M3.59414 14L2 12.4059L6.40586 8L2 3.59414L3.59414 2L8 6.40586L12.4059 2L14 3.59414L9.59414 8L14 12.4059L12.4059 14L8 9.59414L3.59414 14Z" fill="currentColor"/>
424
424
  </svg>`,hI=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
425
425
  <path d="M2 6V2H14V14H10M2 8H8V14H2V8Z" stroke="currentColor" stroke-width="2"/>
@@ -433,7 +433,7 @@ xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
433
433
  <path d="M9.99978 5.99611L14.5 1.49609" stroke="currentColor" stroke-width="2"/>
434
434
  <path d="M1 10.0039H5.99738L5.99608 15" stroke="currentColor" stroke-width="2"/>
435
435
  <path d="M14.9971 5.99611H9.99969L10.001 1" stroke="currentColor" stroke-width="2"/>
436
- </svg>`;async function pI(n,t,e){const o=At(t),r=o.querySelector('[data-button-id="mindmap-fullscreen"]');d(Lt,r,"no full screen button");const i=()=>{setTimeout(()=>{e.toMindmap(n,t,{},{reset:!0,mindmapTools:e})},300)},s=()=>{F(o,"fullscreen"),r.innerHTML=Qp,Vd(r,"Full screen",n.clientId),Jp(t)&&setTimeout(()=>{i()},300)};if(document.fullscreenElement===o){try{await Kp()}catch(l){Lt.error(l)}s()}else{try{M(o,"fullscreen"),await fI(o),i()}catch(l){Lt.error(l)}r.innerHTML=gI,Vd(r,S.t("mindmap.exitFullscreen"),n.clientId)}o.onfullscreenchange=()=>{document.fullscreenElement||s()}}function ju(n,t,e,o,r){if(t.querySelector(`[data-button-id="${e}"]`))return null;const s=kn(e,o,r,[],n.clientId);return M(s,"mindmap-button"),t.appendChild(s),s}function Fu(n,t){return n.querySelector(`[data-button-id="${t}"]`)}function CI(n){return Fu(n,"mindmap-fullscreen")}function bI(n){return Fu(n,"mindmap-fit")}function vI(n){return Fu(n,"mindmap-close")}function kI(n,t,e,o){const r=ju(n,t,"mindmap-close",S.t("mindmap.close"),uI);!r||n.domEvents.addEventListener(r,"click",()=>{o.closeMindmap(n,e)})}function yI(n,t,e,o){const r=ju(n,t,"mindmap-fit",S.t("mindmap.autoFit"),hI);!r||n.domEvents.addEventListener(r,"click",()=>{o.fitMindmap(n,e)})}function wI(n,t,e,o){if(navigator.userAgent.includes("Mobile")&&!navigator.userAgent.includes("iPad"))return;const i=ju(n,t,"mindmap-fullscreen",S.t("mindmap.fullScreen"),Qp);!i||n.domEvents.addEventListener(i,"click",()=>{pI(n,e,o)})}function BI(n,t){const e=al(t);if(!e)return;const o=bI(e);o&&(o.remove(),n.domEvents.removeAllListeners(o));const r=vI(e);r&&(r.remove(),n.domEvents.removeAllListeners(r));const i=CI(e);i&&(i.remove(),n.domEvents.removeAllListeners(i))}const Wr=new Map;function zu(n,t,e){const o=(s,l)=>{s.forEach(c=>{l?M(c.block,"to-mindmap-highlight"):F(c.block,"to-mindmap-highlight"),o(c.children,l)})},r=Yp(n,t);if(r.length===0)return;const i=r[0].block;if(e){const s=Wr.get(i);s&&(s.forEach(l=>l.cancel()),Wr.delete(i)),o(r,!0)}else{const s=setTimeout(()=>{o(r,!1),Wr.delete(i)},300),l=()=>{clearTimeout(s),Wr.delete(i)},c=Wr.get(i);c?c.push({cancel:l}):Wr.set(i,[{cancel:l}])}}const{Markmap:EI}=u8;function II(n,t){jt(t);const e=Yp(n,t),o=e[0].block,r=a=>({t:"text",v:rt(a.block).textContent,d:1,c:a.children.length>0?a.children.map(f=>r(f)):void 0});let i=null;e.length>1?i={t:"root",v:"root",d:0,c:e.length>0?e.map(a=>r(a)):void 0}:i=r(e[0]);const l=a=>{if(a.length===0)return null;const u=a[a.length-1];return u.children&&u.children.length>0?l(u.children):u},c=l(e);return{root:i,block:o,nodes:e,last:c}}function Vu(n,t,e,o){const{root:r,block:i,last:s}=II(n,t);o.selectBlock&&n.selection.selectBlock(i,0,0),zu(n,i,!1),o.saveData&&n.updateBlockData(i,{viewAsMindmap:!0});const l=At(i);let c=l.querySelector(".editor-mindmap-svg");if(o.reset&&(c&&c.remove(),c=null),c)c.innerHTML="";else{const L="http://www.w3.org/2000/svg",x=l.getBoundingClientRect(),A=document.fullscreenElement===l,O=A?`${x.width}`:`${t.getBoundingClientRect().width}`,P=A?`${x.height}`:"600",U=document.createElementNS(L,"svg");U.setAttributeNS(null,"viewBox",`0 0 ${O} ${P}`),U.setAttributeNS(null,"width","100%"),U.setAttributeNS(null,"height",P),U.style.display="block",U.style.width="100%",U.style.height=`${P}px`,U.classList.add("editor-mindmap-svg"),l.appendChild(U),c=U}const a=i,f=`editor-mindmap-root-${G(i)}`;M(a,"editor-in-mindmap-first",f,"readonly"),a.contentEditable="false";const m=ht(i);m&&K(m)<=K(s.block)&&mI(m,s.block,["block-hidden",f]);const C=(L,x)=>{if(x.length>0){const A=x[0].parentElement;A&&(A.style.width="100vw",A.style.maxWidth="200px")}x.forEach(A=>{M(A,"editor-mindmap-node")})},v=new EI(c,{...e,autoFit:!0});v.viewHooks.transformHtml.tap(C),v.setData(r),v.fit();const w=At(i);let E=w.querySelector(".mindmap-toolbar");E||(E=b("div",["mindmap-toolbar"],w)),yI(n,E,a,o.mindmapTools),wI(n,E,a,o.mindmapTools),kI(n,E,a,o.mindmapTools),n.domEvents.addEventListener(c,"click",()=>{n.selection.selectBlock(i,0),n.input.focus()}),a.mindMap=v}function xI(n){const t=n.classList,e="editor-mindmap-root-";return Array.from(t).find(r=>{if(r.startsWith(e))return r})}async function Xp(n,t){const e=xI(t);if(!e)return;n.updateBlockData(t,{viewAsMindmap:null});const o=H(t);Rt(o).forEach(l=>{lt(l,e)&&F(l,e,"editor-in-mindmap-first","block-hidden")});const i=At(t);document.fullscreenElement===i&&await Kp();const s=i.querySelector(".editor-mindmap-svg");d(Lt,s,"no mindmap svg"),s.remove(),n.domEvents.removeAllListeners(s),t.contentEditable="inherit",BI(n,t),n.selection.selectBlock(t,0)}function SI(n,t){const e=t.mindMap;e&&e.fit()}const t4={toMindmap:Vu,closeMindmap:Xp,fitMindmap:SI};function e4(n){let t=ht(n);if(!t)return null;const e=Ko(n);for(;t!==e;){if(d(Lt,t,"no next block"),at(t))return xe(t)>xe(n)?t:null;if(t=ht(t),!t)return null}return null}function Uu(n){const t=[];let e=e4(n);if(!e)return t;for(;e;){const o=Ko(e);t.push({block:e,children:Uu(e)}),e=o}return t}function TI(n){const t=(o,r)=>{r.push(o.block),o.children.forEach(i=>t(i,r))},e=[];return n.forEach(o=>t(o,e)),e}function DI(n,t){return xe(t)!==1}function n4(n,t,e){t.forEach(o=>{const r=n.getBlockData(o.block);n.updateBlockData(o.block,{...r,groupId:e,level:r.level-1}),o.children.length&&n4(n,o.children,r.groupId)})}function o4(n,t){if(!DI(n,t))return!1;const e=xe(t);if(e===1)return!1;let o=N(),r=1,i=He(t);const s=e-1,l=Hu(t);l&&(o=Qo(l),r=Ie(l)+1,i!=="text-only"&&(i=He(l)));const c=Uu(t),a=n.getBlockData(t),u={...a,groupId:o,level:s,start:r,...Bc(i)};n.updateBlockData(t,u),n.doc.beginBatchUpdate(),n4(n,c,a.groupId),n.doc.endBatchUpdate(),new Jo(n,t).fix();const m=e4(t);return m&&new Jo(n,m,{resetStart:!0,resetGroupId:!0}).fix(),!0}function ms(n,t){jt(t);const e=n.getBlockData(t),o={id:N(),type:"text",text:e.text};e.heading&&(o.heading=e.heading),e.heading&&(o.heading=e.heading);const r=new xc(n,t),i=H(t),s=K(t);n.deleteBlock(t);const l=Tl(o.id,0);n.insertBlock(V(i),s,o,l),r.fix()}function LI(n){if(!n.selection.range.isCollapsed())return!1;const t=n.selection.focusedBlock;if(!at(t))return!1;const e=n.selection.range.focus;return!e.isSimple()||e.offset!==0?!1:xe(t)===1?(ms(n,t),!0):(o4(n,t),!0)}const MI=y("list-block");function RI(n,t,e){d(MI,at(t),"not a list block");const o={...n.getBlockData(t),id:N()};return e!=null&&e.level&&(o.level=e.level),e!=null&&e.start&&(o.start=e.start),e!=null&&e.keepText||delete o.text,o}function AI(n){if(jt(n),!wc(n))return n;let t=qn(n);for(;t;){if(!wc(t))return t;t=qn(t)}return null}function OI(n,t,e,o){const r=new Jo(n,o),i=Ie(o)+1;Pi(n,t,e,{forceInsertAfter:!0,newBlockData:RI(n,o,{start:i})}),r.fix()}function _I(n){var s;if(n.selection.range.isCollapsed()){const l=n.selection.focusedBlock;if(at(l)&&Z(n,l)===0)return ms(n,l),!0}n.clearSelectedContents();const t=n.selection.focusedBlock;if(!at(t))return!1;const e=n.selection.range.focus;if(!e.isSimple())return!1;const o=e.offset,i=(s=o===Z(n,t)?AI(t):t)!=null?s:t;return OI(n,t,o,i),!0}function r4(n){d(Lt,at(n),"not a list block");const{level:t}=go(n);let e=gt(n);for(;e;){if(at(e)){const{level:o}=go(e);if(t===o)return e;if(o<t)return null}e=gt(e)}return null}function NI(n,t){return jt(t),r4(t)?xe(t)<tI:!1}function PI(n,t,e){let o=gt(t);d(Lt,o,"no prev brother");const r=xe(e);for(;o;){if(o===e)return null;if(at(o)&&xe(o)===r+1)return o;o=gt(o)}return null}function $I(n,t){if(!NI(n,t))return!1;jt(t);const e=r4(t);d(Lt,e,"no list prev brother");const o=e,r=PI(n,t,o),i=xe(o)+1;let s=N(),l=1,c=He(t);r&&(s=Qo(r),l=Ie(r)+1,c=He(r));const a=Uu(t),f={...n.getBlockData(t),groupId:s,level:i,start:l,...Bc(c)};return n.updateBlockData(t,f),n.doc.beginBatchUpdate(),TI(a).forEach(C=>{const v=n.getBlockData(C);n.updateBlockData(C,{...v,level:v.level+1})}),n.doc.endBatchUpdate(),!0}function HI(n,t){return $I(n,t)}function jI(n,t){return o4(n,t)}function FI(n){const t=n.selection.range.getSelectedBlocks();if(t.length>1)return!0;const e=t[0].block;if(!at(e))return!1;const o=new xc(n,e);return HI(n,e)&&(o.fix(),new Jo(n,e).fix()),!0}function zI(n){const t=n.selection.range.getSelectedBlocks();if(t.length>1)return!0;const e=t[0].block;return at(e)?(jI(n,e),!0):!1}class VI{constructor(t){this.editor=t}handleBeforeKeyDown(t,e){const o=t.selection.range.getSelectedBlocks();if(o.length===0||!o.some(i=>at(i.block)))return!1;switch(e.key){case"Enter":return this.handleEnter(e);case"Backspace":return this.handleBackspace();case"Tab":return this.handleTab(e);default:return!1}}handleEnter(t){const e=this.editor.selection.range.getSelectedBlocks()[0];return!e.block||!at(e.block)||_n(t,"Shift+Enter")?!1:this.editor.undoManager.runInGroup(()=>_I(this.editor))}handleBackspace(){return this.editor.undoManager.runInGroup(()=>LI(this.editor))}handleTab(t){return _n(t,"Shift+Tab")?this.editor.undoManager.runInGroup(()=>zI(this.editor)):this.editor.undoManager.runInGroup(()=>FI(this.editor))}}class UI{constructor(t){h(this,"effectedBlockIds",new Map);h(this,"handleBeforeClearSelection",()=>{this.effectedBlockIds.clear();const t=this.editor.selection.range.getSelectedBlocks();if(t.length===0)return;const e=new Set;t.forEach(r=>{const i=r.block;at(i)&&e.add(i)});const o=new Map;Array.from(e.values()).forEach(r=>{var c;const i=fs(r),{start:s}=go(i);o.set(G(i),s);const l=(c=qE(r))!=null?c:r;o.set(G(l),s)}),this.effectedBlockIds=o});h(this,"handleAfterClearSelection",()=>{Array.from(this.effectedBlockIds.entries()).forEach(([t,e])=>{const o=this.editor.findBlockById(t);!o||Pu(this.editor,o,e)}),this.effectedBlockIds.clear()});this.editor=t,this.editor.addListener("beforeClearSelection",this.handleBeforeClearSelection),this.editor.addListener("afterClearSelection",this.handleAfterClearSelection)}destroy(){this.editor.removeListener("beforeClearSelection",this.handleBeforeClearSelection),this.editor.removeListener("afterClearSelection",this.handleAfterClearSelection)}}const qI=y("customize-list-start-menu");class WI{constructor(t){h(this,"popup");h(this,"block",null);h(this,"show",(t,e)=>{const o=e.querySelector("div.list-container");d(qI,o,"list-block mark does not exist"),this.block=e,this.popup.manualShow(o,{theme:"light"})});h(this,"createDialogContent",()=>{const t=b("div",["customize-start-panel"],null);b("span",["customize-start-panel-title"],t,S.t("list.numberLabel"));const e=b("input",["customize-start-panel-input"],t);e.type="number",e.setAttribute("min","1");const o=b("button",["customize-start-panel-button"],t,S.t("list.confirm"));return this.editor.domEvents.addEventListener(t,"keydown",this.handleKeydown),this.editor.domEvents.addEventListener(o,"click",this.handleOk),t});h(this,"handleDialogShow",()=>{const t=this.block;if(!t)return;const e=this.popup.popupContent,o=e.querySelector("button.customize-start-panel-button"),r=e.querySelector("input.customize-start-panel-input"),i=Ie(t);!o||!r||requestAnimationFrame(()=>{r.focus(),r.value=String(i)})});h(this,"handleOk",()=>{const e=this.popup.popupContent.querySelector("input.customize-start-panel-input"),o=this.block;if(!o)return;const r=Number(e.value);!r||(this.editor.undoManager.runInGroup(()=>{Ic(this.editor,[o,...Ec(o)],r,{resetGroupId:!0})}),this.popup.close())});h(this,"handleKeydown",(t,e)=>{const o=e;o.isComposing||o.key==="Escape"&&this.popup.close()});this.editor=t,this.popup=new lc(this.createDialogContent()),this.popup.on("show",this.handleDialogShow)}destroy(){this.popup.destroy()}}function GI(n,t){return Qo(n)===Qo(t)}function ZI(n,t){const e=qn(t),o=gt(t);return!e&&!o||!o||!at(o)?!1:at(o)&&GI(o,t)?Ie(o)!==Ie(t)-1:!0}function YI(n,t){return!!qn(t)}function QI(n,t){jt(t);const e=[{id:"continue-numbering",name:S.t("list.continueList")},{id:"start-new-list",name:S.t("list.restartList")},{id:"set-numbering-value",name:S.t("list.changeNumber")}];return ZI(n,t)||(e[0].states=["disabled"]),YI(n,t)||(e[1].states=["disabled"]),e}function KI(n,t,e){var o,r;if(jt(t),e.id==="continue-numbering"){const i=gt(t),s=qn(t)||(i&&at(i)?i:null);s&&Ic(n,[t,...Ec(t)],Ie(s)+1,{resetGroupId:!0,groupId:Qo(s)})}if(e.id==="start-new-list"&&n.undoManager.runInGroup(()=>{Ic(n,[t,...Ec(t)],1,{resetGroupId:!0})}),e.id==="set-numbering-value"){const i=(o=n.options.componentsOptions)==null?void 0:o.list;if((r=i==null?void 0:i.onChangeStart)!=null&&r.call(i,n,t,e))return;n.addCustom("list-customize-start-dialog",()=>new WI(n)).show(n,t)}}class JI{constructor(t){h(this,"menu");h(this,"handleClick",(t,e)=>{const o=Bi(e,"div.list-container");if(o&&this.editor.isWritable()){const r=z(o);d(Lt,r,"no parent block"),jt(r);const i=t.getBlockData(r);if(i&&i.checkbox){t.updateBlockData(r,{...i,checkbox:i.checkbox==="checked"?"unchecked":"checked"});return}this.menu.updateItems(this.getCommandItems(r)),this.menu.manualShow(o),this.activeList(o,!0)}});h(this,"handleMenuClose",()=>{var e;const t=(e=this.menu.tippyInstance)==null?void 0:e.reference;t&&this.activeList(t,!1)});h(this,"handleMenuClick",(t,e)=>{var r;const o=(r=this.menu.tippyInstance)==null?void 0:r.reference;if(o){const i=z(o);i&&KI(this.editor,i,e)}});this.editor=t,this.editor.addListener("click",this.handleClick),this.menu=new Wo([]),this.menu.addListener("close",this.handleMenuClose),this.menu.addListener("click",this.handleMenuClick)}destroy(){this.editor.removeListener("click",this.handleClick),this.menu.removeListener("close",this.handleMenuClose)}getCommandItems(t){return QI(this.editor,t)}activeList(t,e){const o=z(t);!o||(e?(M(t,"active"),M(o,"active")):(F(t,"active"),F(o,"active")))}}class XI{constructor(t){this.editor=t}handleBeforeKeyDown(t,e){const o=t.selection.range.getSelectedBlocks();if(o.length===0)return!1;const r=o[0].block;if(!at(r)||!Jp(r))return!1;if(e.key==="ArrowUp"||e.key==="ArrowLeft"){const i=pr(r);return i&&t.selection.selectBlock(i,Z(t,i)),!0}if(e.key==="ArrowDown"||e.key==="ArrowRight"){const i=Cr(r);return i&&t.selection.selectBlock(i,0),!0}return(e.key==="Delete"||e.key==="Backspace"||e.key==="Escape")&&Xp(t,r),!0}}function tx(n,t,e,o,r){xd(n,"list-block-init",()=>{setTimeout(()=>{n.input.addHandler(new XI(n)),n.input.addHandler(new VI(n)),n.addCustom("list-clear-selection-handler",()=>new UI(n)),n.addCustom("list-marker-menu",()=>new JI(n))})});const i=_i.createBlockContent(n,t,e,o,r),s=r,{level:l,start:c,groupId:a}=s,u=Zp(s);o.setAttribute("data-list-level",`${l}`),o.setAttribute("data-list-start",`${c||1}`),o.setAttribute("data-list-group-id",`${a}`),o.setAttribute("data-list-type",u);const f=cI(s);return o.insertBefore(f,i),s.viewAsMindmap&&setTimeout(()=>{const m=n.getBlockById(r.id);m&&Vu(n,m,{},{mindmapTools:t4,saveData:!1})}),i}const ex=`<svg focusable="false" viewBox="0 0 1024 1024" aria-hidden="true" width="24" height="24">
436
+ </svg>`;async function pI(n,t,e){const o=At(t),r=o.querySelector('[data-button-id="mindmap-fullscreen"]');d(Lt,r,"no full screen button");const i=()=>{setTimeout(()=>{e.toMindmap(n,t,{},{reset:!0,mindmapTools:e})},300)},s=()=>{F(o,"fullscreen"),r.innerHTML=Qp,Ud(r,"Full screen",n.clientId),Jp(t)&&setTimeout(()=>{i()},300)};if(document.fullscreenElement===o){try{await Kp()}catch(l){Lt.error(l)}s()}else{try{M(o,"fullscreen"),await fI(o),i()}catch(l){Lt.error(l)}r.innerHTML=gI,Ud(r,S.t("mindmap.exitFullscreen"),n.clientId)}o.onfullscreenchange=()=>{document.fullscreenElement||s()}}function ju(n,t,e,o,r){if(t.querySelector(`[data-button-id="${e}"]`))return null;const s=kn(e,o,r,[],n.clientId);return M(s,"mindmap-button"),t.appendChild(s),s}function Fu(n,t){return n.querySelector(`[data-button-id="${t}"]`)}function CI(n){return Fu(n,"mindmap-fullscreen")}function bI(n){return Fu(n,"mindmap-fit")}function vI(n){return Fu(n,"mindmap-close")}function kI(n,t,e,o){const r=ju(n,t,"mindmap-close",S.t("mindmap.close"),uI);!r||n.domEvents.addEventListener(r,"click",()=>{o.closeMindmap(n,e)})}function yI(n,t,e,o){const r=ju(n,t,"mindmap-fit",S.t("mindmap.autoFit"),hI);!r||n.domEvents.addEventListener(r,"click",()=>{o.fitMindmap(n,e)})}function wI(n,t,e,o){if(navigator.userAgent.includes("Mobile")&&!navigator.userAgent.includes("iPad"))return;const i=ju(n,t,"mindmap-fullscreen",S.t("mindmap.fullScreen"),Qp);!i||n.domEvents.addEventListener(i,"click",()=>{pI(n,e,o)})}function BI(n,t){const e=al(t);if(!e)return;const o=bI(e);o&&(o.remove(),n.domEvents.removeAllListeners(o));const r=vI(e);r&&(r.remove(),n.domEvents.removeAllListeners(r));const i=CI(e);i&&(i.remove(),n.domEvents.removeAllListeners(i))}const Wr=new Map;function zu(n,t,e){const o=(s,l)=>{s.forEach(c=>{l?M(c.block,"to-mindmap-highlight"):F(c.block,"to-mindmap-highlight"),o(c.children,l)})},r=Yp(n,t);if(r.length===0)return;const i=r[0].block;if(e){const s=Wr.get(i);s&&(s.forEach(l=>l.cancel()),Wr.delete(i)),o(r,!0)}else{const s=setTimeout(()=>{o(r,!1),Wr.delete(i)},300),l=()=>{clearTimeout(s),Wr.delete(i)},c=Wr.get(i);c?c.push({cancel:l}):Wr.set(i,[{cancel:l}])}}const{Markmap:EI}=u8;function II(n,t){jt(t);const e=Yp(n,t),o=e[0].block,r=a=>({t:"text",v:rt(a.block).textContent,d:1,c:a.children.length>0?a.children.map(f=>r(f)):void 0});let i=null;e.length>1?i={t:"root",v:"root",d:0,c:e.length>0?e.map(a=>r(a)):void 0}:i=r(e[0]);const l=a=>{if(a.length===0)return null;const u=a[a.length-1];return u.children&&u.children.length>0?l(u.children):u},c=l(e);return{root:i,block:o,nodes:e,last:c}}function Uu(n,t,e,o){const{root:r,block:i,last:s}=II(n,t);o.selectBlock&&n.selection.selectBlock(i,0,0),zu(n,i,!1),o.saveData&&n.updateBlockData(i,{viewAsMindmap:!0});const l=At(i);let c=l.querySelector(".editor-mindmap-svg");if(o.reset&&(c&&c.remove(),c=null),c)c.innerHTML="";else{const L="http://www.w3.org/2000/svg",x=l.getBoundingClientRect(),A=document.fullscreenElement===l,O=A?`${x.width}`:`${t.getBoundingClientRect().width}`,P=A?`${x.height}`:"600",V=document.createElementNS(L,"svg");V.setAttributeNS(null,"viewBox",`0 0 ${O} ${P}`),V.setAttributeNS(null,"width","100%"),V.setAttributeNS(null,"height",P),V.style.display="block",V.style.width="100%",V.style.height=`${P}px`,V.classList.add("editor-mindmap-svg"),l.appendChild(V),c=V}const a=i,f=`editor-mindmap-root-${G(i)}`;M(a,"editor-in-mindmap-first",f,"readonly"),a.contentEditable="false";const m=ht(i);m&&K(m)<=K(s.block)&&mI(m,s.block,["block-hidden",f]);const C=(L,x)=>{if(x.length>0){const A=x[0].parentElement;A&&(A.style.width="100vw",A.style.maxWidth="200px")}x.forEach(A=>{M(A,"editor-mindmap-node")})},v=new EI(c,{...e,autoFit:!0});v.viewHooks.transformHtml.tap(C),v.setData(r),v.fit();const w=At(i);let E=w.querySelector(".mindmap-toolbar");E||(E=b("div",["mindmap-toolbar"],w)),yI(n,E,a,o.mindmapTools),wI(n,E,a,o.mindmapTools),kI(n,E,a,o.mindmapTools),n.domEvents.addEventListener(c,"click",()=>{n.selection.selectBlock(i,0),n.input.focus()}),a.mindMap=v}function xI(n){const t=n.classList,e="editor-mindmap-root-";return Array.from(t).find(r=>{if(r.startsWith(e))return r})}async function Xp(n,t){const e=xI(t);if(!e)return;n.updateBlockData(t,{viewAsMindmap:null});const o=H(t);Rt(o).forEach(l=>{lt(l,e)&&F(l,e,"editor-in-mindmap-first","block-hidden")});const i=At(t);document.fullscreenElement===i&&await Kp();const s=i.querySelector(".editor-mindmap-svg");d(Lt,s,"no mindmap svg"),s.remove(),n.domEvents.removeAllListeners(s),t.contentEditable="inherit",BI(n,t),n.selection.selectBlock(t,0)}function SI(n,t){const e=t.mindMap;e&&e.fit()}const t4={toMindmap:Uu,closeMindmap:Xp,fitMindmap:SI};function e4(n){let t=ht(n);if(!t)return null;const e=Ko(n);for(;t!==e;){if(d(Lt,t,"no next block"),at(t))return xe(t)>xe(n)?t:null;if(t=ht(t),!t)return null}return null}function Vu(n){const t=[];let e=e4(n);if(!e)return t;for(;e;){const o=Ko(e);t.push({block:e,children:Vu(e)}),e=o}return t}function TI(n){const t=(o,r)=>{r.push(o.block),o.children.forEach(i=>t(i,r))},e=[];return n.forEach(o=>t(o,e)),e}function DI(n,t){return xe(t)!==1}function n4(n,t,e){t.forEach(o=>{const r=n.getBlockData(o.block);n.updateBlockData(o.block,{...r,groupId:e,level:r.level-1}),o.children.length&&n4(n,o.children,r.groupId)})}function o4(n,t){if(!DI(n,t))return!1;const e=xe(t);if(e===1)return!1;let o=N(),r=1,i=He(t);const s=e-1,l=Hu(t);l&&(o=Qo(l),r=Ie(l)+1,i!=="text-only"&&(i=He(l)));const c=Vu(t),a=n.getBlockData(t),u={...a,groupId:o,level:s,start:r,...Bc(i)};n.updateBlockData(t,u),n.doc.beginBatchUpdate(),n4(n,c,a.groupId),n.doc.endBatchUpdate(),new Jo(n,t).fix();const m=e4(t);return m&&new Jo(n,m,{resetStart:!0,resetGroupId:!0}).fix(),!0}function ms(n,t){jt(t);const e=n.getBlockData(t),o={id:N(),type:"text",text:e.text};e.heading&&(o.heading=e.heading),e.heading&&(o.heading=e.heading);const r=new xc(n,t),i=H(t),s=K(t);n.deleteBlock(t);const l=Tl(o.id,0);n.insertBlock(U(i),s,o,l),r.fix()}function LI(n){if(!n.selection.range.isCollapsed())return!1;const t=n.selection.focusedBlock;if(!at(t))return!1;const e=n.selection.range.focus;return!e.isSimple()||e.offset!==0?!1:xe(t)===1?(ms(n,t),!0):(o4(n,t),!0)}const MI=y("list-block");function RI(n,t,e){d(MI,at(t),"not a list block");const o={...n.getBlockData(t),id:N()};return e!=null&&e.level&&(o.level=e.level),e!=null&&e.start&&(o.start=e.start),e!=null&&e.keepText||delete o.text,o}function AI(n){if(jt(n),!wc(n))return n;let t=qn(n);for(;t;){if(!wc(t))return t;t=qn(t)}return null}function OI(n,t,e,o){const r=new Jo(n,o),i=Ie(o)+1;Pi(n,t,e,{forceInsertAfter:!0,newBlockData:RI(n,o,{start:i})}),r.fix()}function _I(n){var s;if(n.selection.range.isCollapsed()){const l=n.selection.focusedBlock;if(at(l)&&Z(n,l)===0)return ms(n,l),!0}n.clearSelectedContents();const t=n.selection.focusedBlock;if(!at(t))return!1;const e=n.selection.range.focus;if(!e.isSimple())return!1;const o=e.offset,i=(s=o===Z(n,t)?AI(t):t)!=null?s:t;return OI(n,t,o,i),!0}function r4(n){d(Lt,at(n),"not a list block");const{level:t}=go(n);let e=gt(n);for(;e;){if(at(e)){const{level:o}=go(e);if(t===o)return e;if(o<t)return null}e=gt(e)}return null}function NI(n,t){return jt(t),r4(t)?xe(t)<tI:!1}function PI(n,t,e){let o=gt(t);d(Lt,o,"no prev brother");const r=xe(e);for(;o;){if(o===e)return null;if(at(o)&&xe(o)===r+1)return o;o=gt(o)}return null}function $I(n,t){if(!NI(n,t))return!1;jt(t);const e=r4(t);d(Lt,e,"no list prev brother");const o=e,r=PI(n,t,o),i=xe(o)+1;let s=N(),l=1,c=He(t);r&&(s=Qo(r),l=Ie(r)+1,c=He(r));const a=Vu(t),f={...n.getBlockData(t),groupId:s,level:i,start:l,...Bc(c)};return n.updateBlockData(t,f),n.doc.beginBatchUpdate(),TI(a).forEach(C=>{const v=n.getBlockData(C);n.updateBlockData(C,{...v,level:v.level+1})}),n.doc.endBatchUpdate(),!0}function HI(n,t){return $I(n,t)}function jI(n,t){return o4(n,t)}function FI(n){const t=n.selection.range.getSelectedBlocks();if(t.length>1)return!0;const e=t[0].block;if(!at(e))return!1;const o=new xc(n,e);return HI(n,e)&&(o.fix(),new Jo(n,e).fix()),!0}function zI(n){const t=n.selection.range.getSelectedBlocks();if(t.length>1)return!0;const e=t[0].block;return at(e)?(jI(n,e),!0):!1}class UI{constructor(t){this.editor=t}handleBeforeKeyDown(t,e){const o=t.selection.range.getSelectedBlocks();if(o.length===0||!o.some(i=>at(i.block)))return!1;switch(e.key){case"Enter":return this.handleEnter(e);case"Backspace":return this.handleBackspace();case"Tab":return this.handleTab(e);default:return!1}}handleEnter(t){const e=this.editor.selection.range.getSelectedBlocks()[0];return!e.block||!at(e.block)||_n(t,"Shift+Enter")?!1:this.editor.undoManager.runInGroup(()=>_I(this.editor))}handleBackspace(){return this.editor.undoManager.runInGroup(()=>LI(this.editor))}handleTab(t){return _n(t,"Shift+Tab")?this.editor.undoManager.runInGroup(()=>zI(this.editor)):this.editor.undoManager.runInGroup(()=>FI(this.editor))}}class VI{constructor(t){h(this,"effectedBlockIds",new Map);h(this,"handleBeforeClearSelection",()=>{this.effectedBlockIds.clear();const t=this.editor.selection.range.getSelectedBlocks();if(t.length===0)return;const e=new Set;t.forEach(r=>{const i=r.block;at(i)&&e.add(i)});const o=new Map;Array.from(e.values()).forEach(r=>{var c;const i=fs(r),{start:s}=go(i);o.set(G(i),s);const l=(c=qE(r))!=null?c:r;o.set(G(l),s)}),this.effectedBlockIds=o});h(this,"handleAfterClearSelection",()=>{Array.from(this.effectedBlockIds.entries()).forEach(([t,e])=>{const o=this.editor.findBlockById(t);!o||Pu(this.editor,o,e)}),this.effectedBlockIds.clear()});this.editor=t,this.editor.addListener("beforeClearSelection",this.handleBeforeClearSelection),this.editor.addListener("afterClearSelection",this.handleAfterClearSelection)}destroy(){this.editor.removeListener("beforeClearSelection",this.handleBeforeClearSelection),this.editor.removeListener("afterClearSelection",this.handleAfterClearSelection)}}const qI=y("customize-list-start-menu");class WI{constructor(t){h(this,"popup");h(this,"block",null);h(this,"show",(t,e)=>{const o=e.querySelector("div.list-container");d(qI,o,"list-block mark does not exist"),this.block=e,this.popup.manualShow(o,{theme:"light"})});h(this,"createDialogContent",()=>{const t=b("div",["customize-start-panel"],null);b("span",["customize-start-panel-title"],t,S.t("list.numberLabel"));const e=b("input",["customize-start-panel-input"],t);e.type="number",e.setAttribute("min","1");const o=b("button",["customize-start-panel-button"],t,S.t("list.confirm"));return this.editor.domEvents.addEventListener(t,"keydown",this.handleKeydown),this.editor.domEvents.addEventListener(o,"click",this.handleOk),t});h(this,"handleDialogShow",()=>{const t=this.block;if(!t)return;const e=this.popup.popupContent,o=e.querySelector("button.customize-start-panel-button"),r=e.querySelector("input.customize-start-panel-input"),i=Ie(t);!o||!r||requestAnimationFrame(()=>{r.focus(),r.value=String(i)})});h(this,"handleOk",()=>{const e=this.popup.popupContent.querySelector("input.customize-start-panel-input"),o=this.block;if(!o)return;const r=Number(e.value);!r||(this.editor.undoManager.runInGroup(()=>{Ic(this.editor,[o,...Ec(o)],r,{resetGroupId:!0})}),this.popup.close())});h(this,"handleKeydown",(t,e)=>{const o=e;o.isComposing||o.key==="Escape"&&this.popup.close()});this.editor=t,this.popup=new lc(this.createDialogContent()),this.popup.on("show",this.handleDialogShow)}destroy(){this.popup.destroy()}}function GI(n,t){return Qo(n)===Qo(t)}function ZI(n,t){const e=qn(t),o=gt(t);return!e&&!o||!o||!at(o)?!1:at(o)&&GI(o,t)?Ie(o)!==Ie(t)-1:!0}function YI(n,t){return!!qn(t)}function QI(n,t){jt(t);const e=[{id:"continue-numbering",name:S.t("list.continueList")},{id:"start-new-list",name:S.t("list.restartList")},{id:"set-numbering-value",name:S.t("list.changeNumber")}];return ZI(n,t)||(e[0].states=["disabled"]),YI(n,t)||(e[1].states=["disabled"]),e}function KI(n,t,e){var o,r;if(jt(t),e.id==="continue-numbering"){const i=gt(t),s=qn(t)||(i&&at(i)?i:null);s&&Ic(n,[t,...Ec(t)],Ie(s)+1,{resetGroupId:!0,groupId:Qo(s)})}if(e.id==="start-new-list"&&n.undoManager.runInGroup(()=>{Ic(n,[t,...Ec(t)],1,{resetGroupId:!0})}),e.id==="set-numbering-value"){const i=(o=n.options.componentsOptions)==null?void 0:o.list;if((r=i==null?void 0:i.onChangeStart)!=null&&r.call(i,n,t,e))return;n.addCustom("list-customize-start-dialog",()=>new WI(n)).show(n,t)}}class JI{constructor(t){h(this,"menu");h(this,"handleClick",(t,e)=>{const o=Bi(e,"div.list-container");if(o&&this.editor.isWritable()){const r=z(o);d(Lt,r,"no parent block"),jt(r);const i=t.getBlockData(r);if(i&&i.checkbox){t.updateBlockData(r,{...i,checkbox:i.checkbox==="checked"?"unchecked":"checked"});return}this.menu.updateItems(this.getCommandItems(r)),this.menu.manualShow(o),this.activeList(o,!0)}});h(this,"handleMenuClose",()=>{var e;const t=(e=this.menu.tippyInstance)==null?void 0:e.reference;t&&this.activeList(t,!1)});h(this,"handleMenuClick",(t,e)=>{var r;const o=(r=this.menu.tippyInstance)==null?void 0:r.reference;if(o){const i=z(o);i&&KI(this.editor,i,e)}});this.editor=t,this.editor.addListener("click",this.handleClick),this.menu=new Wo([]),this.menu.addListener("close",this.handleMenuClose),this.menu.addListener("click",this.handleMenuClick)}destroy(){this.editor.removeListener("click",this.handleClick),this.menu.removeListener("close",this.handleMenuClose)}getCommandItems(t){return QI(this.editor,t)}activeList(t,e){const o=z(t);!o||(e?(M(t,"active"),M(o,"active")):(F(t,"active"),F(o,"active")))}}class XI{constructor(t){this.editor=t}handleBeforeKeyDown(t,e){const o=t.selection.range.getSelectedBlocks();if(o.length===0)return!1;const r=o[0].block;if(!at(r)||!Jp(r))return!1;if(e.key==="ArrowUp"||e.key==="ArrowLeft"){const i=pr(r);return i&&t.selection.selectBlock(i,Z(t,i)),!0}if(e.key==="ArrowDown"||e.key==="ArrowRight"){const i=Cr(r);return i&&t.selection.selectBlock(i,0),!0}return(e.key==="Delete"||e.key==="Backspace"||e.key==="Escape")&&Xp(t,r),!0}}function tx(n,t,e,o,r){xd(n,"list-block-init",()=>{setTimeout(()=>{n.input.addHandler(new XI(n)),n.input.addHandler(new UI(n)),n.addCustom("list-clear-selection-handler",()=>new VI(n)),n.addCustom("list-marker-menu",()=>new JI(n))})});const i=_i.createBlockContent(n,t,e,o,r),s=r,{level:l,start:c,groupId:a}=s,u=Zp(s);o.setAttribute("data-list-level",`${l}`),o.setAttribute("data-list-start",`${c||1}`),o.setAttribute("data-list-group-id",`${a}`),o.setAttribute("data-list-type",u);const f=cI(s);return o.insertBefore(f,i),s.viewAsMindmap&&setTimeout(()=>{const m=n.getBlockById(r.id);m&&Uu(n,m,{},{mindmapTools:t4,saveData:!1})}),i}const ex=`<svg focusable="false" viewBox="0 0 1024 1024" aria-hidden="true" width="24" height="24">
437
437
  <g>
438
438
  <path d="M612,212c0,27.6,22.4,50,50,50h200c27.6,0,50-22.4,50-50v-50c0-27.6-22.4-50-50-50H662c-27.6,0-50,22.4-50,50
439
439
  c-176.3,0-322.2,130.4-346.5,300H162c-27.6,0-50,22.4-50,50v50c0,27.6,22.4,50,50,50h114.5c43,144.6,177,250,335.5,250
@@ -441,12 +441,12 @@ c0,27.6,22.4,50,50,50h200c27.6,0,50-22.4,50-50v-50c0-27.6-22.4-50-50-50H662c-27.
441
441
  c-130.6,0-241.7-83.5-282.9-200H362c27.6,0,50-22.4,50-50h200c0,27.6,22.4,50,50,50h200c27.6,0,50-22.4,50-50v-50
442
442
  c0-27.6-22.4-50-50-50H662c-27.6,0-50,22.4-50,50H412c0-27.6-22.4-50-50-50h-45.8C340,320.1,463.4,212,612,212z"></path>
443
443
  </g>
444
- </svg>`;function nx(n){return kn("list-to-mindmap",S.t("mindmap.viewAsMindMap"),ex,[],n.clientId)}const wF="";class Sc{constructor(t){h(this,"toMindmapButton");h(this,"currentBlock",null);h(this,"handleHoveringBlock",t=>{!this.editor.isWritable()||(t&&at(t)&&He(t)!=="unchecked"&&He(t)!=="checked"?At(t).appendChild(this.toMindmapButton):this.toMindmapButton.remove())});h(this,"handleMouseEnter",()=>{const t=z(this.toMindmapButton);d(Lt,t&&at(t),"no parent list"),zu(this.editor,t,!0),this.currentBlock=t});h(this,"handleMouseLeave",()=>{this.currentBlock&&(zu(this.editor,this.currentBlock,!1),this.currentBlock=null)});h(this,"handleClick",()=>{const t=z(this.toMindmapButton);d(Lt,t&&at(t),"no parent list"),Vu(this.editor,t,{},{saveData:!0,selectBlock:!0,mindmapTools:t4})});this.editor=t,_t.get(this.editor).addListener("change",this.handleHoveringBlock),this.toMindmapButton=nx(t),t.domEvents.addEventListener(this.toMindmapButton,"mouseenter",this.handleMouseEnter),t.domEvents.addEventListener(this.toMindmapButton,"mouseleave",this.handleMouseLeave),t.domEvents.addEventListener(this.toMindmapButton,"click",this.handleClick)}static get(t){return t.findCustomByType(Sc)}destroy(){_t.get(this.editor).removeListener("change",this.handleHoveringBlock)}hide(){this.currentBlock&&(this.currentBlock=null),this.toMindmapButton.remove()}}const ox={list:{confirm:"\u786E\u5B9A",setStart:"\u8BBE\u7F6E\u7F16\u53F7",continueList:"\u7EE7\u7EED\u7F16\u53F7",restartList:"\u5F00\u59CB\u65B0\u5217\u8868",changeNumber:"\u4FEE\u6539\u7F16\u53F7\u503C",numberLabel:"\u7F16\u53F7\u987A\u5E8F",mention:{tooltip:"\u63D0\u53CA\u4EBA\u5458\u5E76\u901A\u77E5"}},mindmap:{viewAsMindMap:"\u663E\u793A\u4E3A\u8111\u56FE",autoFit:"\u81EA\u52A8\u7F29\u653E",fullScreen:"\u5168\u5C4F\u67E5\u770B",close:"\u5173\u95ED",exitFullscreen:"\u9000\u51FA\u5168\u5C4F"}},rx={list:{confirm:"OK",setStart:"Set the number",continueList:"Continue numbering",restartList:"Start a new list",changeNumber:"Set numbering value",numberLabel:"Numbering order",mention:{tooltip:"@Mention someone"}},mindmap:{viewAsMindMap:"View as MindMap",autoFit:"Auto fit",fullScreen:"Fullscreen",close:"Close",exitFullscreen:"Exit fullscreen"}};S.mergeLang({"zh-CN":ox,"en-US":rx});const BF="";function ix(n,t,e){var o;t==="beginDrag"&&((o=Sc.get(n))==null||o.hide())}function Tc(n){const t=n.getAttribute("block-padding-level");return t?Number(t):null}function sx(n,t){let e;const o=Tc(t);if(!o)e=1;else{if(o>=12)return e=12,!1;e=o+1}return n.updateBlockData(t,{...n.getBlockData(t),padding:e}),!0}function i4(n,t){const e=Tc(t);if(!e)return!1;const o=n.getBlockData(t);return e>1?(n.updateBlockData(t,{...o,padding:e-1}),!0):(n.updateBlockData(t,{...o,padding:null}),!0)}function qu(n){return n.readonly||!n.isWritable()}function lx(n){return n.selection.range.getSelectedBlocks().forEach(e=>{const o=e.block;j(n,o)&&sx(n,o)}),!0}function cx(n){return n.selection.range.getSelectedBlocks().forEach(e=>{const o=e.block;j(n,o)&&i4(n,o)}),!0}function ax(n){return qu(n)?!1:n.undoManager.runInGroup(()=>(lx(n),!0))}function dx(n){return qu(n)?!1:n.undoManager.runInGroup(()=>(cx(n),!0))}function ux(n){if(qu(n))return!1;if(!n.selection.range.isCollapsed())return;const t=n.selection.focusedBlock;if(!j(n,t))return;const e=n.selection.range.focus;if(!(!e.isSimple()||e.offset!==0||!Tc(t)))return i4(n,t),!0}class hx{renderBlock(t,e,o){const{padding:r}=o;return r?{attributes:{"block-padding-level":r}}:{}}}const EF="",fx={Tab:ax,"Shift+Tab":dx,Backspace:ux};function Wu(n,t,e){let o=1,r=1,i=N();if(at(t))o=xe(t);else{const a=Tc(t);a&&(o=a+1),o>8&&(o=8)}const s=Gp(t,e);if(s){if(K(t)>K(s))r=Ie(s)+1;else{const a=Ie(s);a>1&&(r=a-1)}i=Qo(s)}const c={...n.getBlockData(t),level:o,start:r,groupId:i,type:"list",...Bc(e)};n.undoManager.runInGroup(()=>{const a=K(t),u=V(H(t));n.deleteBlock(t);const f=n.insertBlock(u,a,c);new Jo(n,f).fix()})}const s4={..._i,blockType:"list",createBlockContent:tx,convertFrom:XE,handleDrop:oI,notify:ix},Gu=y("paragraph");class mx{constructor(t){h(this,"id","BlockParagraphProvider");this.editor=t}isChecked(t,e){return!!(t[e]||t.level&&(t.ordered===!0&&!t.checkbox&&e==="ordered-list"||t.ordered===!1&&!t.checkbox&&e==="unordered-list")||e==="check-list"&&t.checkbox)}getAvailableCommands(t,e){const o=[],r={"unordered-list":[S.t("commands.unordered"),It.isMac?S.t("commandDesc.mac.unordered"):S.t("commandDesc.window.unordered"),w5],"ordered-list":[S.t("commands.ordered"),It.isMac?S.t("commandDesc.mac.ordered"):S.t("commandDesc.window.ordered"),y5],"check-list":[S.t("commands.check"),void 0,B5],link:[S.t("commands.link"),It.isMac?S.t("commandDesc.mac.link"):S.t("commandDesc.window.link"),lu],quoted:[S.t("commands.quote"),void 0,E5]};if(j(t,e)){const i=G(e),s=it(e),l=We(t,e),c=t.getBlockData(e);Object.entries(r).forEach(([a,[u,f,m]])=>{const C=[];if(this.isChecked(c,a)&&C.push("checked"),a==="link"){if(!t.selection.range.isSimple())return;t.selection.range.getSelectedBlocks().length!==1&&C.push("disabled")}o.push({blockId:i,blockType:s,blockKind:l,id:a,name:u,desc:f,states:C,icon:m,groupIndex:600})})}return o}convertLink(t,e,o){d(Gu,kr(e.start),""),d(Gu,kr(e.start),"");const r="bottom-start",i=e.start.offset,s=e.end.offset,l=(C,v)=>{t.undoManager.runInGroup(()=>{try{let w=El(t.getBlockText(o),i,s,C);w=wl(i,C.length,w,"link",v),t.setBlockText(o,w),t.selection.selectBlock(o,i+C.length),t.focus()}catch(w){Gu.error(w)}})},c=()=>{t.focus()},a=Ao(t,o,e)[0];if(!a)return;const u=_o(t,o,"link-button-anchor",a),f=t.getBlockText(o),m=Bl(f,i);vc(t,{target:u,linkText:t.getSelectedText(),linkUrl:(m==null?void 0:m.link)||"",onFinished:l,onClose:c,placement:r})}executeCommand(t,e,o,r){var c;if(!j(t,e))return!1;const i=r.id,s=(c=r.states)==null?void 0:c.includes("checked");let l=!1;if(i==="unordered-list"&&(s?ms(t,e):Wu(t,e,"unordered"),l=!0),i==="ordered-list"&&(s?ms(t,e):Wu(t,e,"ordered"),l=!0),i==="check-list"&&(s?ms(t,e):Wu(t,e,"unchecked"),l=!0),i==="quoted"){const u=t.getBlockData(e).quoted;t.updateBlockData(e,{quoted:u?void 0:!0}),l=!0}if(i==="link"){const a=bc(t);a.disableTextToolbar(),a.hide(),setTimeout(()=>{a.enableTextToolbar()},1e3),this.convertLink(t,o,e),l=!0}return l}}const gx={left:Pr,right:rc,center:ic};class px{constructor(t){h(this,"id","BlockAlignProvider");this.editor=t}applyAlignStyle(t,e,o){Object.keys(gx).includes(o)?t.updateBlockData(e,{align:o}):t.updateBlockData(e,{align:null})}isChecked(t,e){return t.align===e}getAvailableCommands(t,e,o){const r=G(e),i=it(e),s=We(t,e),l=t.getBlockData(e);return[{id:"align",name:"",blockId:r,blockType:i,blockKind:s,groupIndex:700,dropdown:!0,element:a=>{var f;const u=b("span",["toolbar-item-name-container"],null);for(const m of a.children)if((f=m.states)!=null&&f.includes("checked"))return u.innerHTML=m.icon||Pr,u;return u.innerHTML=Pr,u},manualShowChildren:!0,childrenPlacement:"bottom-start",defaultCheckedChildren:["align-left"],children:[{id:"align-left",name:S.t("commands.alignLeft"),icon:Pr,states:this.isChecked(l,"left")?["checked"]:[]},{id:"align-center",name:S.t("commands.alignCenter"),icon:ic,states:this.isChecked(l,"center")?["checked"]:[]},{id:"align-right",name:S.t("commands.alignRight"),icon:rc,states:this.isChecked(l,"right")?["checked"]:[]}],childrenType:"menu"}]}executeCommand(t,e,o,r){if(r.id.startsWith("align")){const i=r.id.replace(/^align-/,"");return this.applyAlignStyle(t,e,i),!0}return!1}}const Cx=y("toolbar-handler"),bx={id:"",name:"",type:"separator"};class Gr{constructor(t){h(this,"toolbar");h(this,"toolbarType","object");h(this,"mouseDown",!1);h(this,"oldRange",null);h(this,"hoveringBlock",null);h(this,"hoveringTextChild",null);h(this,"_disableTextToolbar",!1);h(this,"handleButtonClick",(t,e)=>{this.toolbarType==="text"?(this.editor.editorCommandProviders.executeCommand(this.editor.selection.range,e,{}),this.showTextToolbar()):this.hoveringBlock&&zE(this.editor,this.hoveringBlock,this.hoveringTextChild,e)});h(this,"handleClose",()=>{this.editor.focus()});h(this,"handleDocumentMouseDown",t=>{t.button===0&&(document.addEventListener("mouseup",this.handleDocumentMouseUp),this.mouseDown=!0)});h(this,"handleDocumentMouseUp",()=>{document.removeEventListener("mouseup",this.handleDocumentMouseUp),this.mouseDown=!1,this.handleSelectionChange(this.editor)});h(this,"handleHoveringBlockChildChange",(t,e,o,r)=>{if(!(this.hoveringBlock===t&&this.hoveringTextChild===e)&&(this.hoveringBlock=t,this.hoveringTextChild=e,!(this.toolbar.isVisible&&this.toolbarType==="text"))){if(!t){this.toolbar.close();return}this.showObjectToolbar()}});h(this,"handleSelectionChange",ie.default(t=>{if(d(Cx,t===this.editor,"editor mismatch"),t.selection.range.isCollapsed()||this.mouseDown){this.toolbar.close(),this.oldRange=null;return}if(t.selection.range.getSelectedBlocks().length===0){this.toolbar.close(),this.oldRange=null;return}this.oldRange&&this.oldRange.isEqual(t.selection.range)||(this.oldRange=t.selection.range,this.showTextToolbar())},50));this.editor=t,this.toolbar=new os([],void 0,{tooltipId:t.clientId,id:"editor-toolbar"}),this.toolbar.on("click",this.handleButtonClick),this.toolbar.on("close",this.handleClose),this.bindEvents(),t.addListener("selectionChanged",this.handleSelectionChange),_t.get(t).addListener("childChange",this.handleHoveringBlockChildChange),_t.get(t).addFilter(this),t.editorCommandProviders.registerCommandProvider(new UE(t)),t.editorCommandProviders.registerCommandProvider(new mx(t)),t.editorCommandProviders.registerCommandProvider(new px(t))}disableTextToolbar(){this._disableTextToolbar=!0}enableTextToolbar(){this._disableTextToolbar=!1}hide(){this.toolbar.close()}destroy(){this.unbindEvents(),this.toolbar.destroy(),this.editor.removeListener("selectionChanged",this.handleSelectionChange),_t.get(this.editor).removeListener("childChange",this.handleHoveringBlockChildChange)}isInBlock(t,e){return t!==this.hoveringBlock?!1:!!(e.target&&e.target instanceof Node&&this.toolbar.popper&&vt(this.toolbar.popper,e.target))}bindEvents(){document.addEventListener("mousedown",this.handleDocumentMouseDown)}unbindEvents(){document.removeEventListener("mousedown",this.handleDocumentMouseDown)}update(){this.showTextToolbar()}showTextToolbar(){if(this._disableTextToolbar||!this.editor.isWritable())return;const e=this.editor.selection.range.getSelectedBlocks();if(e.length===0)return;const o=e[0];if(!o)return;if(e.length===1&&Te(o.block)){this.showObjectToolbar();return}const r=this.editor.editorCommandProviders.getCommands(this.editor.selection.range),i=new Map;r.forEach(a=>{const u=a.groupIndex,f=i.get(u);f?f.push(a):i.set(u,[a])});const s=[[]],l=Array.from(i.entries()).sort((a,u)=>a[0]-u[0]);for(let a=0;a<l.length;a++){const[,u]=l[a];if(u.length===0)continue;let f=s[s.length-1];f.length>0&&f[f.length-1].groupIndex!==u[u.length-1].groupIndex&&(f=[],s.push(f)),f.push(...Cc(u))}if(s.length===0){this.toolbar.close();return}this.toolbarType="text";const c=[];if(s.forEach((a,u)=>{const f=a.sort((m,C)=>{var v,w;return((v=m.order)!=null?v:0)-((w=C.order)!=null?w:0)});c.push(...f),u!==s.length-1&&c.push(bx)}),this.toolbar.updateItems(c),!this.toolbar.isVisible){const a=e[e.length-1],u=!this.editor.selection.range.isReverse()&&a!==o,f=u?a:o,m=OE(this.editor,f),C=_o(this.editor,f.block,"editor-quick-menu",m);this.toolbar.manualShow(C,{placement:u?"bottom":"top"})}}showObjectToolbar(){if(!this.hoveringBlock)return;const t=this.hoveringBlock,e=this.hoveringTextChild,o=HE(this.editor,t,e);this.toolbarType="object",o.length===0?this.toolbar.close():(this.toolbar.updateItems(o),this.toolbar.isVisible||this.toolbar.manualShow(e||rt(t),{placement:e?"bottom":"top"}))}static register(t){return t.addCustom("toolbar-handler",e=>new Gr(e))}static get(t){return t.getCustom("toolbar-handler")}}function Zu(){let n=8;for(;n>0&&!document.querySelector(`div[data-style-heading='${n}']`);)n--;return n}function gs(n,t){const e=n;e.blockOptions=t,e.itemType="insert-block",n.children&&n.children.forEach(o=>gs(o,t))}function vx(n,t,e){n.getBlockData(t).heading===e?n.updateBlockData(t,{heading:null}):n.updateBlockData(t,{heading:e})}async function kx(n,t){const{containerId:e,blockIndex:o,item:r}=t,{value:i,id:s}=r,l=n.insertTextBlock("",e,o);if(s.startsWith("heading-"))vx(n,l,i||"1");else if(i==="ordered"||i==="unordered"||i==="checkbox"){const c=n.selection.range.focus;if(!c.isSimple())return null;const a=hl(n,l,"list",{offset:c.offset,data:{listType:i==="checkbox"?"unchecked":i}});a&&(n.deleteBlock(l),n.insertBlock(e,o,a.blockData))}else i==="quote"&&n.updateBlockData(l,{quoted:!0});return null}const l4=(n,t)=>n.undoManager.runInGroup(()=>kx(n,t));function Dc(n=1){var i;const t={name:"basic",insertBlockCommandItems:[]};let e=Zu();e<=4?e=5:e<8&&(e+=1);let o=n;const r=up;for(;o<=e;)(i=t.insertBlockCommandItems)==null||i.push({id:`heading-${o}`,icon:r[`HeadingH${o}Icon`],name:S.t("quickMenu.basic.heading.title",{heading:String(o)}),order:o,group:"basics",value:String(o)}),o++;return t}function yx(){const n={name:"basic",insertBlockCommandItems:[]},t=up;return["Unordered","Ordered","Checkbox","Quote"].forEach((o,r)=>{var i;(i=n.insertBlockCommandItems)==null||i.push({id:`insert-${o.toLocaleLowerCase()}`,name:S.t(`quickMenu.basic.${o.toLocaleLowerCase()}`),icon:t[`${o}Icon`],value:o.toLocaleLowerCase(),group:"basics",order:10+r})}),n}function wx(){var e;const t={name:"basic",insertBlockCommandItems:[...Dc().insertBlockCommandItems||[]],handleInsertEmptyBlock:l4};return(e=t.insertBlockCommandItems)==null||e.forEach(o=>{gs(o,t)}),t}function Bx(){const n=Dc(),t=yx();return{name:"basic",insertBlockCommandItems:[...n.insertBlockCommandItems||[],...t.insertBlockCommandItems||[]],handleInsertEmptyBlock:l4}}class c4{constructor(){h(this,"dataUrl","");h(this,"error",null)}destroy(){}setDataUrl(t){this.dataUrl=t}setError(t){this.error=t}}const Ex=y("mathjax-converter"),Ix="MathJax-script";async function xx(n){var o;window.MathJax||(window.MathJax={options:{skipHtmlTags:["script","noscript","style","textarea","pre","code","annotation","annotation-xml","body"]}});const t=n.getComponentOptions("mathjax"),e=((o=t==null?void 0:t.cdn)==null?void 0:o.mathjax)||"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js";await So(e,Ix)}function Sx(){try{window.MathJax&&window.MathJax.texReset()}catch{}}async function a4(n,t){const e="mathjax2Svg";try{await Rn.lock(e),Sx(),await xx(n);const o=await window.MathJax.tex2svgPromise(t),r=o.querySelector("merror");if(r)throw new Error(r.textContent);return o.querySelector("svg").outerHTML}catch(o){throw Ex.error(o),o}finally{Rn.release(e)}}async function d4(n,t){const e=await a4(n,t);return e?await am(e,"image/svg+xml"):""}async function Yu(n,t){const o=await a4(n,t),r=new File([o],"math.svg");return(await n.doc.uploadResource(r)).resourceId}const u4=y("edit-mathjax");class Tx{constructor(){h(this,"editMathjaxPopup",null);h(this,"onFinished",null);h(this,"tex","");h(this,"handleShow",()=>{setTimeout(()=>{this.getTextarea().focus()})});h(this,"handleClose",t=>{var o;const e=t.content.querySelector("textarea");if(e){const r=e.value;r!==this.tex&&((o=this.onFinished)==null||o.call(this,r))}});h(this,"handleKeydown",t=>{var e;t.isComposing||t.key==="Escape"&&((e=this.editMathjaxPopup)==null||e.close())})}editMathjax(t,e,o){if(!this.editMathjaxPopup)this.editMathjaxPopup=new lc(this.createPopupContent(e));else{const r=this.getTextarea();r.value=e}this.tex=e,this.editMathjaxPopup.addListener("show",this.handleShow),this.editMathjaxPopup.manualShow(t,{theme:"light"}),this.editMathjaxPopup.removeAllListeners("close"),this.editMathjaxPopup.addListener("close",this.handleClose),this.onFinished=o}createPopupContent(t){const e=b("textarea",["mathjax-editor-textarea"],null);return e.value=t,e.addEventListener("keydown",this.handleKeydown),e}getTextarea(){d(u4,this.editMathjaxPopup,"no exists mathjax editor popup");const t=this.editMathjaxPopup.content.querySelector("textarea");return d(u4,t,"no textarea"),t}destroy(){var t;this.onFinished=null,(t=this.editMathjaxPopup)==null||t.removeAllListeners()}}function h4(n,t,e,o){n.addCustom("mathjax-editor",()=>new Tx).editMathjax(t,e,o)}function Dx(){return{insert:" ",attributes:{id:N(),box:!0,type:"math",tex:S.t("mathjax.emptyText"),src:"",created:Date.now()}}}function f4(n,t){const e=n.getBoxData(t);h4(n,t,e.tex,async o=>{const r=await Yu(n,o);n.updateBoxData({...e,tex:o,src:r})})}const Lx=y("mathjax-box");async function Mx(n,t,e){try{const o=await d4(n,t.tex),r=n.findBoxById(t.id);if(!r)return;const i=c1(r);i.innerHTML="";const s=b("img",["mathjax"],i);s.src=o,e.setDataUrl(o)}catch(o){e.setError(o)}}function Rx(n,t,e,o){const r=o,i=n.addCustom(`mathjax-box-${r.id}`,()=>new c4);if(r.src||i.dataUrl){const s=b("img",["mathjax"],e);s.src=n.doc.buildResourceUrl(r.src||i.dataUrl);return}i.error,b("span",["mathjax-tex-text"],e,r.tex),Mx(n,r,i)}function Ax(n,t){const e={id:N(),box:!0,type:"math",tex:t,src:"",created:Date.now()};return Yu(n,t).then(o=>{if(!n.findBoxById(e.id))return;const i={...e,src:o};n.updateBoxData(i)}).catch(o=>{Lx.error(`failed to convert and upload mathjax: ${JSON.stringify(o)}`)}),e}function Ox(n,t,e){f4(n,t)}const Lc={boxType:"math",updateBoxContent:Rx,convertFrom:Ax,handleClickBox:Ox};async function _x(n,t,e){try{const o=t.embedData,r=await d4(n,o.mathjaxText),i=n.findBlockById(t.id);if(!i)return;const s=rt(i);s.innerHTML="";const l=b("img",["mathjax"],s);l.src=r,e.setDataUrl(r)}catch(o){e.setError(o)}}function Nx(n,t){if(n.readonly||!t.target||!(t.target instanceof Node))return;const e=z(t.target);if(!e||!Te(e)||De(e)!=="math")return;const o=rt(e),r=o.querySelector("img")||o.querySelector("span.mathjax-tex-text");if(!r||!vt(r,t.target))return;const s=n.getBlockData(e).embedData;h4(n,r,s.mathjaxText,async l=>{const c=await Yu(n,l),a={mathjaxText:l,src:c};n.updateEmbedData(e,a)})}function Px(n,t,e){const o=e.embedData,r=n.addCustom(`mathjax-block-${e.id}`,()=>new c4);if(n.domEvents.addEventListener(t,"click",Nx),o.src||r.dataUrl){const i=b("img",["mathjax"],t);i.src=n.doc.buildResourceUrl(o.src||r.dataUrl);return}r.error,b("span",["mathjax-tex-text"],t,o.mathjaxText),_x(n,e,r)}function $x(n,t,e){if(!j(n,t))return null;const o=n.getBlockString(t).trim();if(!o||!o.startsWith("$$")||!o.endsWith("$$"))return null;const r=Ya(o,"$");if(!r)return null;const i={mathjaxText:r,src:""};return{blockData:{id:N(),type:"embed",embedType:"math",embedData:i}}}function Hx(n){return{name:"Mathjax"}}function jx(n,t){const e=rt(t);n.domEvents.removeAllListeners(e)}const Qu={embedType:"math",createEmbedContent:Px,getOptions:Hx,convertFrom:$x,handleDeleteBlock:jx},IF="",Fx={mathjax:{emptyText:"\u7A7A\u7684\u516C\u5F0F",abstract:"\u516C\u5F0F"}},zx={mathjax:{emptyText:"Empty Tex",abstract:"TeX"}};S.mergeLang({"zh-CN":Fx,"en-US":zx});const Vx=y("inline-box-items");function Ux(n,t,e){return n.undoManager.runInGroup(()=>{var s;let o=n.getBlockByIndex(t,e);wt(n,o)||(o=n.insertTextBlock([],t,e));const r=Dx();n.setBlockText(o,[r]);const i=n.getBoxById((s=r.attributes)==null?void 0:s.id);return f4(n,i),o})}function qx(n,t,e){let o=n.getBlockByIndex(t,e),r="bottom-start";return wt(n,o)||(r="top-start"),vc(n,{target:o,linkText:"",linkUrl:"",onFinished:(l,c)=>{n.undoManager.runInGroup(()=>{try{wt(n,o)||(o=n.insertTextBlock([],t,e));const a=_e(l,{link:c}),u=_e(" ",null),f=[a,u];n.insertTextToBlock(o,0,f),n.selection.selectBlock(o,ce(f)),n.focus()}catch(a){Vx.error(a)}})},onClose:()=>{n.focus()},placement:r}),o}async function Wx(n,t){switch(t.item.id){case"insert-math":return Ux(n,t.containerId,t.blockIndex);case"insert-link":return qx(n,t.containerId,t.blockIndex);default:return null}}function Gx(){return{name:"text",insertBlockCommandItems:[{id:"insert-math",name:S.t("quickMenu.inlineBox.math"),icon:L5,order:900,group:"common"},{id:"insert-link",name:S.t("quickMenu.inlineBox.link"),icon:lu,order:400,group:"common"}],handleInsertEmptyBlock:Wx}}const m4={basics:100,system:200,common:300,thirdParty:400};function Zx(n){var o,r;const t=(r=(o=n.options.componentsOptions)==null?void 0:o.quickMenu)==null?void 0:r.commandProviders;if(!t)return[];const e=[];return t.forEach(i=>{const s=i.getCommands(n);e.push(...s.map(l=>({...l,itemType:"insert-block",commandProvider:i})))}),e}function Yx(n){var r;const t=[];n.editorBlocks.forEach(i=>{if(!i.getOptions)return;const s=i.getOptions(n);!s.insertBlockCommandItems||(s.insertBlockCommandItems.forEach(l=>{gs(l,s)}),t.push(...s.insertBlockCommandItems))});const e=Gx(),o=Bx();return e.insertBlockCommandItems.forEach(i=>{gs(i,e)}),(r=o.insertBlockCommandItems)==null||r.forEach(i=>{gs(i,o)}),t.push(...e.insertBlockCommandItems),t.push(...o.insertBlockCommandItems),t.push(...Zx(n)),t}function Ku(n){const t=Yx(n),e=new Map;t.forEach(i=>{var c;const s=(c=i.group)!=null?c:"";let l=e.get(s);l?l.items.push(i):(l={group:s,order:i.groupOrder||m4[s]||1e3,items:[i]},e.set(s,l))});const o=Array.from(e.values());o.sort((i,s)=>i.order-s.order),o.forEach(i=>{i.items.sort((s,l)=>{var c,a;return((c=s.order)!=null?c:0)-((a=l.order)!=null?a:0)})});const r=[];return o.forEach((i,s)=>{const l=i.group||"common",a=l in m4?S.t(`blockMenu.section.${l}`):l;r.push({id:`section-${s}`,name:a,type:"section",group:i.group,itemType:"insert-block"}),r.push(...i.items.map(u=>({...u})))}),r}function Qx(n,t,e){const o=n.getFocusedBlock();if(!o)return;const r=n.getParentContainer(o),i=V(r);let l=n.getBlockIndex(o);if(wt(n,o)||(l+=1),t.commandProvider){t.commandProvider.executeCommand(n,t,{from:"quick-menu",...e});return}!t.blockOptions||!t.blockOptions.handleInsertEmptyBlock||t.blockOptions.handleInsertEmptyBlock(n,{containerId:i,blockIndex:l,item:t})}const g4=y("quick-menu"),Kx={id:"quick-menu",trigger:["/"]};class Mc{constructor(t,e=Kx){h(this,"suggest");h(this,"items");h(this,"maxHeading");h(this,"queryItems",async(t,e)=>{if(this.items.length===0?this.initMenuItems():this.refreshMenuItems(),e){const o=new Set,r=e.toLocaleLowerCase();return this.items.filter(i=>{var s;return i.type==="section"?!0:i.name.toLocaleLowerCase().indexOf(r)!==-1||Ud(i).toLocaleLowerCase().indexOf(r)!==-1||i.group&&((s=i.group)==null?void 0:s.toLocaleLowerCase().indexOf(r))!==-1?(o.add(i.group),!0):!1}).filter(i=>i.type==="section"?o.has(i.group):!0)}return this.items});h(this,"onShow",(t,e,o,r)=>{const i=this.editor.getBlockByIndex(e,o);if(!Vo(i)){const s=z(H(i));if(s&&it(s)==="code")return!1}return!0});h(this,"onClickItem",(t,e)=>{const o=e;o.itemType==="insert-block"&&(d(g4,o.blockOptions||o.commandProvider,"invalid quick item, no block options or command provider"),d(g4,this.suggest.anchor,"invalid suggest, no anchor"),Qx(this.editor,o,this.suggest.anchor))});this.editor=t,this.options=e,this.items=[],this.maxHeading=Zu(),this.suggest=new uu(t,{id:e.id||"quick-menu",trigger:e.trigger,needSpaceBeforeTrigger:!0,autoDeleteTrigger:!0,highlight:!0,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems})}get menu(){return this.suggest.menu.menu}destroy(){this.suggest.destroy()}initMenuItems(){const t=Ku(this.editor);this.items=t}refreshMenuItems(){let t=null,e=0;const o=i=>{const{id:s}=i;return s.startsWith("heading-")},r=Zu();if(r!==this.maxHeading){const i=wx().insertBlockCommandItems;for(let s=0;s<this.items.length;s++){const l=this.items[s];o(l)&&(t||(t=s),e++)}t&&e&&this.items.splice(t,e,...i),this.maxHeading=r}}}class Ju{constructor(t){h(this,"instance");h(this,"mousedown",!1);h(this,"currentInstance",null);h(this,"attributeName","");h(this,"attributeDesc","");h(this,"createContent",t=>{var i;const e=(i=t.getAttribute(this.attributeName))!=null?i:"",o=t.getAttribute(this.attributeDesc);if(!o)return e;const r=b("div",[],null);return b("span",[],r,e),o&&b("span",["editor-tooltip-desc"],r,o),r});h(this,"handleDocumentMouseDown",()=>{this.mousedown=!0,this.editor.domEvents.addEventListener(document,"mouseup",this.handleDocumentMouseUp)});h(this,"handleDocumentMouseUp",()=>{this.mousedown=!1,this.editor.domEvents.removeEventListener(document,"mouseup",this.handleDocumentMouseUp)});h(this,"handleShown",t=>{this.currentInstance=t});h(this,"handleHidden",()=>{this.currentInstance=null});h(this,"handleShow",t=>{var r;const e=t.reference;if(!e||!vt(document.body,e)||window.isDragging||this.mousedown)return!1;const o=Number.parseInt((r=e.getAttribute("data-tooltip-hide-at"))!=null?r:"",10);return!(o&&Date.now()-o<1e3)});this.editor=t;const e=t.clientId;this.attributeName=`data-editor-tooltip-${e}`,this.attributeDesc=`data-editor-tooltip-desc-${e}`,this.instance=Rf.delegate(document.body,{delay:300,target:`[${this.attributeName}]`,content:this.createContent,onShow:this.handleShow,onShown:this.handleShown,onHidden:this.handleHidden}),t.domEvents.addEventListener(document,"mousedown",this.handleDocumentMouseDown)}visible(){var t;return(t=this.currentInstance)==null?void 0:t.state.isVisible}hide(){var t;(t=this.currentInstance)!=null&&t.state.isVisible&&this.currentInstance.hide()}destroy(){this.instance.destroy(),this.editor.domEvents.removeEventListener(document,"mousedown",this.handleDocumentMouseDown),this.editor.domEvents.removeEventListener(document,"mouseup",this.handleDocumentMouseUp)}}const Jx={"text/style-bold":"bold","text/style-italic":"italic","text/style-underline":"underline","text/style-line-through":"line-through","text/style-code":"code","text/style-subscript":"subscript","text/style-superscript":"superscript"};function Xx(n,t){const e=new Set(Object.keys(Jx)),o=t.filter(i=>e.has(i.id));return Cc(o)}function Rc(n,t){if(!n.isWritable())return!1;const e=n.selection.range,o=n.editorCommandProviders.getCommands(e),i=Xx(n,o).find(s=>s.id===`text/${t}`);return i?(n.editorCommandProviders.executeCommand(e,i,{}),Gr.get(n).update(),!0):!1}const Xu={"CtrlOrCmd+B":n=>Rc(n,"style-bold"),"CtrlOrCmd+I":n=>Rc(n,"style-italic"),"CtrlOrCmd+U":n=>Rc(n,"style-underline"),"CtrlOrCmd+D":n=>Rc(n,"style-line-through")},tS={quickMenu:{basic:{heading:{title:"\u6807\u9898 {heading}",space:"{markdown}\u7A7A\u683C"},unordered:"\u65E0\u5E8F\u5217\u8868",ordered:"\u6709\u5E8F\u5217\u8868",checkbox:"\u5F85\u529E\u4E8B\u9879",quote:"\u5F15\u7528"},inlineBox:{math:"\u516C\u5F0F",link:"\u94FE\u63A5"}},link:{textLabel:"\u6587\u672C",urlLabel:"\u94FE\u63A5\u5730\u5740",textPlaceholder:"\u8BF7\u8F93\u5165\u6587\u672C",urlPlaceholder:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740",submitText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88"},commands:{unordered:"\u65E0\u5E8F\u5217\u8868",ordered:"\u6709\u5E8F\u5217\u8868",check:"\u5F85\u529E\u5217\u8868",link:"\u94FE\u63A5",quote:"\u5F15\u7528",alignLeft:"\u5DE6\u5BF9\u9F50",alignRight:"\u53F3\u5BF9\u9F50",alignCenter:"\u5C45\u4E2D\u5BF9\u9F50",heading:"\u6807\u9898 {name}",text:"\u6B63\u6587"},commandDesc:{mac:{unordered:"\u2318+\u21E7+L",ordered:"\u2318+\u21E7+U",link:"\u2318+K"},window:{unordered:"Ctrl+Shift+L",ordered:"Ctrl+Shift+U",link:"Ctrl+K"}}},eS={quickMenu:{basic:{heading:{title:"Heading {heading}",space:"{markdown}space"},unordered:"Bulleted list",ordered:"Numbered list",checkbox:"Todo list",quote:"Quote"},inlineBox:{math:"Math",link:"Link"},link:{textLabel:"Text",urlLabel:"Link Address",textPlaceholder:"Please enter text",urlPlaceholder:"Please enter the link address",submitText:"Ok",cancelText:"Cancel"}},commands:{unordered:"Bulleted list",ordered:"Numberer list",check:"Todo list",link:"Link",quote:"Quote",alignLeft:"Align left",alignRight:"Align right",alignCenter:"Align center",heading:"Heading {name}",text:"Text"},commandDesc:{mac:{unordered:"\u2318+\u21E7+L",ordered:"\u2318+\u21E7+U",link:"\u2318+K"},window:{unordered:"Ctrl+Shift+L",ordered:"Ctrl+Shift+U",link:"Ctrl+K"}}};S.mergeLang({"zh-CN":tS,"en-US":eS});const xF="";function Xo(n,...t){const e=kn(...t);return e.classList.remove("editor-button"),e.classList.add("editor-text-button"),n.append(e),e}function p4(n){bc(n).hide();const e=n.getCustom("table-border-bar");e==null||e.closeToolbar()}function nS(n){return b("div",["insert-column-button","drop-marker"],n)}const C4=y("row-height");function b4(n){const t=nt.fromTable(n),e=n.rows;d(C4,e.length===t.rowCount,"row count mismatch");const o=Array(t.rowCount).fill(0);for(let r=0;r<e.length;){let i=1,l=e[r].getBoundingClientRect().height,c=r+1;for(;c<e.length;){const a=e[c];if(a.cells.length!==0)break;i++,c++,l+=a.getBoundingClientRect().height}for(let a=0;a<i;a++)o[r+a]=l/i;r=c}return C4.debug("heights",o.join(", ")),o}const po=y("table-border-bar-dom");function ps(n,t){d(po,Ht(t),"invalid table block");const e=$t(t),o=wn(n,t),r=(a,u,f)=>{const m=b("div",["button-root",u],a),C=b("div",["button-container",u],m);m.setAttribute(`data-${u}-index`,`${f}`),b("span",["insert-indicator"],C),nS(C)},{selectedRows:i,selectedColumns:s}=mu(n,t),l=()=>{const a=o.querySelector(".table-border-bar-container.top");d(po,a,"no top border bar container");const u=b("div",["table-border-bar-container","top"],null),f=b("div",["table-border-bar","top"],u),m=bE(e);b("span",["table-border-bar-cell","corner"],f);const v=nt.fromTable(e).colCount;n.selection.range.isSimple()&&r(f,"top",0);for(let w=0;w<v;w++){const E=w===v-1?m[w]+2:m[w],L=b("span",["table-border-bar-cell","top"],f);s.has(w)&&L.classList.add("selected"),L.setAttribute("data-top-index",`${w}`),L.style.width=`${E}px`,n.selection.range.isSimple()&&r(f,"top",w+1)}xi(a,u)},c=()=>{const a=o.querySelector(".table-border-bar-container.left");d(po,a,"no left border bar container");const u=b("div",["table-border-bar-container","left"],null),f=b("div",["table-border-bar","left"],u),m=b4(e);n.selection.range.isSimple()&&r(f,"left",0),Array.from(e.rows).forEach((C,v,w)=>{const E=b("span",["table-border-bar-cell","left"],f);i.has(v)&&E.classList.add("selected"),E.setAttribute("data-left-index",`${v}`);const L=v===w.length-1?m[v]+2:m[v];E.style.height=`${L}px`,n.selection.range.isSimple()&&r(f,"left",v+1)}),xi(a,u)};l(),c()}function v4(n,t){const e=t.target;if(!(e instanceof Element))return;const o=z(e);d(po,o&&Ht(o),"invalid table block"),ps(n,o),n.selection.caret.update()}function th(n,t){const e=t.target;if(!(e instanceof Element))return;const o=z(e);d(po,o&&Ht(o),"invalid table block");const r=e.closest(".button-root");if(r){if(r.classList.contains("top")){const s=parseInt(r.getAttribute("data-top-index")||"0",10);Hp(n,o,s),ps(n,o)}else if(r.classList.contains("left")){const s=parseInt(r.getAttribute("data-left-index")||"0",10);jp(n,o,s),ps(n,o)}return}const i=e.closest(".table-border-bar-cell");if(i){if(i.classList.contains("top")){const s=parseInt(i.getAttribute("data-top-index")||"0",10);RE(n,o,s,1,{reverse:!0})}else if(i.classList.contains("left")){const s=parseInt(i.getAttribute("data-left-index")||"0",10);AE(n,o,s,1,{reverse:!0})}}}function eh(n,t){p4(n),t.preventDefault(),t.stopPropagation()}function oS(n,t){d(po,Ht(t),"invalid table block");const e=wn(n,t),o=b("div",["table-border-bar-container","top"],e),r=b("div",["table-border-bar-container","left"],e);ps(n,t),n.domEvents.addEventListener(rt(t),"scroll",v4),n.domEvents.addEventListener(o,"click",th),n.domEvents.addEventListener(r,"click",th),n.domEvents.addEventListener(o,"mousedown",eh),n.domEvents.addEventListener(r,"mousedown",eh)}function k4(n,t){if(!n.isWritable())return;if(wn(n,t).querySelector(".table-border-bar-container")){ps(n,t);return}oS(n,t)}function y4(n,t){d(po,Ht(t),"invalid table block"),wn(n,t).querySelectorAll(".table-border-bar-container").forEach(r=>{n.domEvents.removeEventListener(r,"click",th),n.domEvents.removeEventListener(r,"mousedown",eh),r.remove()}),n.domEvents.removeEventListener(rt(t),"scroll",v4)}function rS(n,t){d(po,Ht(t),"invalid table block");const o=wn(n,t).querySelector(".table-border-bar-container.top");return o?o.getBoundingClientRect().height:0}class iS{constructor(t,e){h(this,"toolbar");h(this,"handleSelectionChange",(t,e)=>{e==="delete-columns"?(zr(this.editor,this.tableBlock,!0,!0),Vr(this.editor,this.tableBlock,!0,!0)):e==="delete-rows"?(zr(this.editor,this.tableBlock,!0,!1),Vr(this.editor,this.tableBlock,!0,!1)):(zr(this.editor,this.tableBlock,!1),Vr(this.editor,this.tableBlock,!1))});h(this,"handleClick",(t,e,o)=>{e.id==="delete-columns"?gu(this.editor.selection.range):e.id==="delete-rows"&&pu(this.editor.selection.range)});this.editor=t,this.tableBlock=e,this.toolbar=new os([]),this.toolbar.addListener("selectionChange",this.handleSelectionChange),this.toolbar.addListener("click",this.handleClick)}close(){this.toolbar.close()}update(){const{selectedColumns:t,selectedRows:e}=mu(this.editor,this.tableBlock);if(!this.editor.isWritable())return;if(t.size>0&&e.size>0){this.toolbar.close();return}if(t.size===0&&e.size===0){this.toolbar.close();return}const o=Ao(this.editor,this.tableBlock,this.editor.selection.range)[0];if(!o){this.toolbar.close();return}if(t.size>0){const r={id:"delete-columns",name:"Delete columns",icon:Yd};this.toolbar.updateItems([r]);const i=_o(this.editor,this.tableBlock,"editor-quick-menu",o);this.toolbar.manualShow(i,{placement:"top"})}else{const r={id:"delete-rows",name:"Delete rows",icon:Yd};this.toolbar.updateItems([r]);const i=new DOMRect(o.left-15,o.top,o.width,o.height),s=_o(this.editor,this.tableBlock,"editor-quick-menu",i);this.toolbar.manualShow(s,{placement:"left"})}}destroy(){this.toolbar.destroy(),this.toolbar.removeAllListeners()}}const Ac=y("table-border-bar");class sS{constructor(t,e){h(this,"toolbar");h(this,"resizeObserver");h(this,"handleReadonlyChanged",t=>{t.isWritable()?this.update():y4(this.editor,this.tableBlock)});h(this,"handleBlockUpdated",()=>{this.resizeObserver.disconnect(),setTimeout(()=>{const t=this.editor.getBlockById(G(this.tableBlock));this.resizeObserver.observe($t(t))})});h(this,"handleTableResize",()=>{!this.editor.isWritable()||(console.log("resize"),this.update())});this.editor=t,this.tableBlock=e,d(Ac,this.tableBlock,"no table block"),Ac.debug("create table border bar"),k4(this.editor,this.tableBlock),this.resizeObserver=new ResizeObserver(this.handleTableResize),this.resizeObserver.observe($t(this.tableBlock)),this.toolbar=new iS(this.editor,this.tableBlock),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}close(){this.toolbar.close()}destroy(){Ac.debug("destroy table border bar"),this.resizeObserver.disconnect(),y4(this.editor,this.tableBlock),this.toolbar.destroy(),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged)}update(){Ac.debug("update table border bar"),k4(this.editor,this.tableBlock),this.toolbar.update()}}const lS=y("table-border-bar");class cS{constructor(t){h(this,"activeTableBar",null);h(this,"handleBlockDeleted",(t,e)=>{!this.activeTableBar||(e===this.activeTableBar.tableBlock||vt(e,this.activeTableBar.tableBlock))&&(this.activeTableBar.destroy(),this.activeTableBar=null)});h(this,"handleSelectionChanged",t=>{var r;const e=t.selection.range;let o=null;if(e.isCollapsed()&&e.isSimple()){const i=t.getBlockById(e.start.blockId);if(Ht(i)){const s=H(i),l=z(s);l&&(o=we(l))}else o=we(i)}else{const i=t.getBlockById(e.start.blockId),s=we(i),l=t.getBlockById(e.end.blockId),c=we(l);s===c&&(o=s)}((r=this.activeTableBar)==null?void 0:r.tableBlock)!==o&&this.activeTableBar&&this.hide(),o&&this.show(o)});this.editor=t,this.editor.addListener("blockDeleted",this.handleBlockDeleted),this.editor.addListener("selectionChanged",this.handleSelectionChanged)}destroy(){this.editor.removeListener("blockDeleted",this.handleBlockDeleted),this.editor.removeListener("selectionChanged",this.handleSelectionChanged)}show(t){this.activeTableBar?(this.activeTableBar.tableBlock!==t&&this.hide(),this.activeTableBar.update()):this.activeTableBar=new sS(this.editor,t)}update(){var t;(t=this.activeTableBar)==null||t.handleBlockUpdated()}closeToolbar(){var t;(t=this.activeTableBar)==null||t.close()}hide(){!this.activeTableBar||(d(lS,this.activeTableBar,"no active table bar"),this.activeTableBar.destroy(),this.activeTableBar=null)}}function w4(n,t){const e=n.addCustom("table-border-bar",o=>new cS(o));t==="update"&&e.update()}const Ce=y("table-cell-menu"),aS="style-bg-color-";class dS{constructor(t){h(this,"activeTableBlock",null);h(this,"targetButton",null);h(this,"manualMenu",null);h(this,"colorPaletteItem",null);h(this,"handlePrevent",(t,e)=>{e.stopPropagation()});h(this,"handleReadonlyChanged",t=>{t.isWritable()||this.hide()});h(this,"handleSelectionChanged",t=>{const e=t.selection.range;let o=null;if(e.isCollapsed()&&e.isSimple()){const r=t.getBlockById(e.start.blockId);if(Ht(r)){const i=H(r),s=z(i);s&&(o=we(s))}else o=we(r)}else{const r=t.getBlockById(e.start.blockId),i=we(r),s=t.getBlockById(e.end.blockId),l=we(s);i===l&&(o=i)}if(this.hide(),this.activeTableBlock!==o&&(this.activeTableBlock=o),this.activeTableBlock){const r=nt.fromBlock(this.activeTableBlock),{end:i}=e;let s=null;e.isCollapsed()?s=this.getCellByChildBlockId(r,i.blockId):i instanceof Ze&&(t.getBlockById(i.blockId)===this.activeTableBlock?s=r.getCellByContainerId(i.childContainerId):s=this.getCellByChildBlockId(r,i.blockId)),s&&this.editor.isWritable()&&this.showCellMenuButton(s)}});h(this,"handleBeforePopupPalette",()=>{var e;const t=this.getSelectedBkgColorIndex();(e=this.colorPaletteItem)==null||e.palette.setColor("backgroundColor",t)});h(this,"createBkgColorItem",()=>{const t=b("div",["cell-background-color-item"],null);b("span",[],t,S.t("table.cellBackground"));const e=this.getSelectedBkgColorIndex();b("button",["item-button"],t).setAttribute("data-color-index",`${e}`);const r=b("span",["item-sub-indicator"],t);return r.innerHTML=Zd,t});h(this,"handleCommand",t=>{var r;d(Ce,this.activeTableBlock,"no target table block");const e=((r=t.states)==null?void 0:r.includes("checked"))||!1,o=t.value;switch(t.id){case"delete-select-row":pu(yp(this.editor,this.activeTableBlock,!1));break;case"delete-select-col":gu(yp(this.editor,this.activeTableBlock,!0));break;case"merge-cell":bp(this.editor.selection.range);break;case"split-cell":this.handleSplitCell();break;case"row-title":this.handleRowTitle(e);break;case"col-title":this.handleColTitle(e);break;case"stripe-style":this.handleStripeStyle(e);break;case"hide-border":zB(this.editor,this.activeTableBlock,o==="show-border");break;case"show-chart":GB(this.editor,this.activeTableBlock,o==="show-chart"),xu(this.editor,this.activeTableBlock,{updateNow:!0});break}});h(this,"handleSelectionChange",(t,e)=>{d(Ce,this.activeTableBlock,"no target table block"),e==="cell-background-color"&&this.handleBeforePopupPalette(),e==="delete-select-row"?(zr(this.editor,this.activeTableBlock,!0,!1),Vr(this.editor,this.activeTableBlock,!0,!1)):e==="delete-select-col"?(zr(this.editor,this.activeTableBlock,!0,!0),Vr(this.editor,this.activeTableBlock,!0,!0)):(zr(this.editor,this.activeTableBlock,!1),Vr(this.editor,this.activeTableBlock,!1))});h(this,"handleClick",()=>{var t;d(Ce,this.activeTableBlock,"no target table block"),d(Ce,this.targetButton,"no target button"),p4(this.editor),lt(this.targetButton,"active")?(F(this.targetButton,"active"),(t=this.manualMenu)==null||t.close()):(M(this.targetButton,"active"),this.manualMenu?this.manualMenu.updateItems(this.createCommandMenu()):(this.manualMenu=new Wo(this.createCommandMenu()),this.manualMenu.on("click",(e,o)=>{var r;this.handleCommand(o),(r=this.manualMenu)==null||r.close()}),this.manualMenu.on("selectionChange",this.handleSelectionChange),this.manualMenu.on("close",()=>{this.targetButton&&F(this.targetButton,"active")})),this.manualMenu.manualShow(this.targetButton,{placement:"right-start"}))});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChanged),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}destroy(){var t,e;this.activeTableBlock=null,this.targetButton=null,this.editor.removeListener("selectionChanged",this.handleSelectionChanged),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged),(t=this.manualMenu)==null||t.destroy(),(e=this.colorPaletteItem)==null||e.destroy()}hide(){var t;(t=this.manualMenu)==null||t.close(),this.targetButton&&(F(this.targetButton,"active"),this.targetButton.style.display="none")}getCellByChildBlockId(t,e){let o=this.editor.getBlockById(e);for(;o;){const r=o.closest("td");d(Ce,r,"no parent cell");const i=z(r);if(d(Ce,i,"no parent block"),$t(i)===t.table)return t.getCellByCellElement(r);o=i}return d(Ce,!1,"filed to get cell by child block id"),null}createTargetButton(t){this.targetButton?t.querySelector(":scope > .table-cell-menu-btn")||t.appendChild(this.targetButton):(this.targetButton=b("button",["table-cell-menu-btn"],t),this.targetButton.innerHTML=oc,this.editor.domEvents.addEventListener(this.targetButton,"click",this.handleClick),this.editor.domEvents.addEventListener(this.targetButton,"mousedown",this.handlePrevent))}showCellMenuButton(t){this.createTargetButton(t.cell),d(Ce,this.targetButton,"no target button"),this.targetButton.style.display="inline-block"}handleSplitCell(){if(this.activeTableBlock){const t=nt.fromBlock(this.activeTableBlock),e=this.editor.selection.range;if(e.isSimple()){const{col:o,row:r}=this.getCellByChildBlockId(t,e.start.blockId);bu(this.editor,this.activeTableBlock,{col:o,row:r})}else vu(this.editor.selection.range)}}getSelectedBkgColorIndex(){var r;d(Ce,this.activeTableBlock,"no target table block");const t=qB(this.editor,this.activeTableBlock),e=this.editor.getBlockData(this.activeTableBlock),o=new Set;for(const i of t){if(o.size>1)break;const s=V(i),l=e[`${s}_background`];if(l)o.add(Number.parseInt((r=l.substring(aS.length))!=null?r:"0",10));else{o.add(-1);break}}return o.size===1&&[...o][0]!==-1?[...o][0]:-1}createCommandMenu(){d(Ce,this.activeTableBlock,"no target table block");const t=this.editor.getBlockData(this.activeTableBlock),e=Cp(this.editor,this.activeTableBlock,this.editor.selection.range);let o=this.editor.selection.range;if(o.isSimple()){const u=Un(this.editor,this.activeTableBlock,o.start);o=Ut(this.editor,{anchor:u,focus:u})}const r=pp(this.editor,this.activeTableBlock,o),i=t.hasRowTitle,s=t.hasColTitle,l=t.isStripeStyle,c=t.noBorder,a=t.chart;return this.colorPaletteItem=new cu("cell-background-color",{color:!1}),this.colorPaletteItem.palette.on("onClick",(u,f)=>{var m;switch(d(Ce,this.activeTableBlock,"no target table block"),u){case"clearColor":Ep(this.editor,this.activeTableBlock,-1);break;case"backgroundColor":Ep(this.editor,this.activeTableBlock,f);break}(m=this.manualMenu)==null||m.close()}),[{id:"cell-background-color",name:S.t("table.cellBackground"),element:this.createBkgColorItem(),children:[this.colorPaletteItem]},{id:"separator",name:"",type:"separator"},{id:"merge-cell",name:S.t("table.mergeCell"),states:e?[]:["disabled"]},{id:"split-cell",name:S.t("table.splitCell"),states:r?[]:["disabled"]},{id:"separator",name:"",type:"separator"},{id:"delete-select-row",name:S.t("table.deleteSelectRow")},{id:"delete-select-col",name:S.t("table.deleteSelectCol")},{id:"separator",name:"",type:"separator"},{id:"table-config",name:S.t("table.tableConfigKey"),children:[{id:"row-title",name:S.t("table.tableConfig.rowTitle"),states:i?["checked"]:[]},{id:"col-title",name:S.t("table.tableConfig.colTitle"),states:s?["checked"]:[]},{id:"stripe-style",name:S.t("table.tableConfig.stripeStyle"),states:l?["checked"]:[]},{id:"hide-border",name:c?S.t("table.tableConfig.showBorder"):S.t("table.tableConfig.hideBorder"),value:c?"show-border":"hide-border"},{id:"show-chart",name:a?S.t("table.tableConfig.hideChart"):S.t("table.tableConfig.showChart"),value:a?"hide-chart":"show-chart"}]}]}handleRowTitle(t){d(Ce,this.activeTableBlock,"no target table block"),t?HB(this.editor,this.activeTableBlock):$B(this.editor,this.activeTableBlock)}handleColTitle(t){d(Ce,this.activeTableBlock,"no target table block"),t?PB(this.editor,this.activeTableBlock):NB(this.editor,this.activeTableBlock)}handleStripeStyle(t){d(Ce,this.activeTableBlock,"no target table block"),t?FB(this.editor,this.activeTableBlock):jB(this.editor,this.activeTableBlock)}}function B4(n){n.addCustom("table-cell-menu",t=>new dS(t))}const Oc=y("table-container");function nh(n){const t=n.closest("td");return d(Oc,t,"no parent cell for a table cell container"),t}function E4(n){const t=$t(n);return Array.from(t.querySelectorAll(':scope > tbody > tr > td > [data-type="editor-container"].child'))}function oh(n,t,e,o){const r=nt.fromBlock(n),i=r.getCellByContainerId(V(t));if(e==="ArrowDown"){const s=r.getBottomCell(i);return s?s.container:null}if(e==="ArrowUp"){const s=r.getTopCell(i);return s?s.container:null}if(e==="ArrowLeft"){const s=r.getAllContainers(),l=s.indexOf(t);if(d(Oc,l>=0,"not a valid child container"),l===0)return null;const c=s[l-1];return o!=null&&o.noWrap&&r.getCellByContainerId(V(c)).row!==i.row?null:c}if(e==="ArrowRight"){const s=r.getAllContainers(),l=s.indexOf(t);if(d(Oc,l>=0,"not a valid child container"),l===s.length-1)return null;const c=s[l+1];return o!=null&&o.noWrap&&r.getCellByContainerId(V(c)).row!==i.row?null:c}d(Oc,!1,`invalid navigation type: ${e}`)}const uS=12,hS=90,_c=23,I4=2;class fS{constructor(t){h(this,"scrollTableBlock",null);h(this,"autoScrollDir",null);h(this,"autoScrollTimer",null);h(this,"handleMouseDown",t=>{const e=document.elementFromPoint(t.clientX,t.clientY);if(e&&e instanceof HTMLElement){const o=z(e);if(o&&vt(this.editor.rootContainer,o)){const r=we(o);r&&(this.scrollTableBlock=r,document.addEventListener("mousemove",this.handleAutoScroll))}}});h(this,"handleAutoScroll",h8.default(t=>{if(this.scrollTableBlock){const e=this.editor.getCustom(fo(this.scrollTableBlock)),o=e.rootElement,r=e.scrollOptions.parentContainer,i=o.getBoundingClientRect(),s=window.innerHeight-(e.scrollOptions.barFloatWindowBottom||0),l=r.getBoundingClientRect(),c=Math.min(l.bottom,s),a=Math.max(l.top,0);i.bottom>c&&t.clientY>=c?this.setAutoScroll("bottom"):i.top<a&&t.clientY<=a?this.setAutoScroll("top"):o.scrollLeft>0&&t.clientX<i.left?this.setAutoScroll("left"):o.scrollLeft<o.scrollWidth-o.offsetWidth&&t.clientX>i.right?this.setAutoScroll("right"):this.clearAutoScroll()}},15));h(this,"handleMouseUp",()=>{document.removeEventListener("mousemove",this.handleAutoScroll),setTimeout(()=>{this.scrollTableBlock=null})});h(this,"handleSelectionChanged",t=>{const e=t.selection.range;if(e.isCollapsed()&&e.isSimple()){const o=t.getBlockById(e.start.blockId),r=we(o);if(r){const i=t.getCustom(fo(r)),s=i.rootElement.getBoundingClientRect(),l=Ge(t,o,e.start);if(s.left>l.left){const c=e.start.offset===0?uS:I4;i.rootElement.scrollLeft-=s.left-l.left+c}else if(l.right>s.right){const c=e.start.offset===0?hS:I4;i.rootElement.scrollLeft+=l.right-s.right+c}}}else{const o=t.getBlockById(e.start.blockId),r=we(o),i=t.getBlockById(e.end.blockId),s=we(i);if(r&&r===s){const l=t.getCustom(fo(r)),c=l.rootElement.getBoundingClientRect();let a=null;if(e.isSimple())a=e.isReverse()?Ge(t,o,e.start):Ge(t,i,e.end);else{const u=nh(br(t,e.start.childContainerId)),f=nh(br(t,e.end.childContainerId));a=e.isReverse()?u.getBoundingClientRect():f.getBoundingClientRect()}c.left>a.left&&e.isReverse()?l.rootElement.scrollLeft-=c.left-a.left:c.right<a.right&&!e.isReverse()&&(l.rootElement.scrollLeft+=a.right-c.right)}}});h(this,"handleScroll",t=>{IB(t),this.editor.selection.caret.update()});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChanged),document.addEventListener("mousedown",this.handleMouseDown),document.addEventListener("mouseup",this.handleMouseUp)}clearAutoScroll(){this.autoScrollTimer&&(clearInterval(this.autoScrollTimer),this.autoScrollTimer=null,this.autoScrollDir=null)}setAutoScroll(t){this.autoScrollDir&&this.autoScrollDir!==t&&this.clearAutoScroll(),this.autoScrollTimer||(this.autoScrollDir=t,this.autoScrollTimer=window.setInterval(()=>{if(this.scrollTableBlock){const e=this.editor.getCustom(fo(this.scrollTableBlock)),o=e.rootElement,r=e.scrollOptions.parentContainer,i=o.getBoundingClientRect(),s=r===document.documentElement?window.innerHeight:r.offsetHeight,l=window.innerHeight-(e.scrollOptions.barFloatWindowBottom||0),c=r.getBoundingClientRect(),a=Math.min(c.bottom,l),u=Math.max(c.top,0);this.autoScrollDir==="left"&&(o.scrollLeft-=_c,o.scrollLeft<=0&&this.clearAutoScroll()),this.autoScrollDir==="right"&&(o.scrollLeft+=_c,o.scrollLeft>=o.scrollWidth-o.offsetWidth&&this.clearAutoScroll()),this.autoScrollDir==="bottom"&&(r.scrollTop+=_c,(r.scrollTop>=r.scrollHeight-s||i.bottom<=a)&&this.clearAutoScroll()),this.autoScrollDir==="top"&&(r.scrollTop-=_c,(r.scrollTop<=0||i.top>=u)&&this.clearAutoScroll())}},100))}destroy(){document.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mouseup",this.handleMouseUp),this.editor.removeListener("selectionChanged",this.handleSelectionChanged)}}function x4(n){return n.addCustom("table-scroll-events",t=>new fS(t))}const Bn=y("create-content");function S4(n,t,e){const o=new fu(e),r=e.rows,i=e.cols;d(Bn,r>=1,`invalid rows: ${r}`),d(Bn,i>=1,`invalid cols: ${i}`),d(Bn,e.children,"no table children");const s=b("table",[],null),l=e.colsWidth,c=b("colgroup",[],s);for(let f=0;f<o.colCount;f++){const m=b("col",[],c);m.style.width=`${l[f]}px`}const a=b("tbody",[],s);let u=0;for(let f=0;f<r;f++){const m=b("tr",[],a);for(let C=0;C<i;C++){const v=o.getCell({col:C,row:f});if(v.virtual)d(Bn,v.colSpan>1||v.rowSpan>1,"virtual cell should have colSpan or rowSpan");else{const w=e.children[u],E=b("td",[],m);v.colSpan>1&&(E.colSpan=v.colSpan),v.rowSpan>1&&(E.rowSpan=v.rowSpan);const L=e[cs(w)];L&&M(E,L),C===0&&e.hasColTitle&&M(E,vp.COL_TITLE_ITEM),n.createChildContainer(t,E,w),u+=1}}}return d(Bn,u===e.children.length,"container count mismatch"),e.noBorder&&M(s,"no-border"),e.chart&&M(s,"editor-table-chart"),e.isStripeStyle&&M(s,"stripe"),e.hasRowTitle&&M(s,"row-title"),e.hasColTitle&&M(s,"col-title"),s}function mS(n,t,e,o,r){d(Bn,r.type==="table","not table data"),d(Bn,V(e)===t[t.length-1].containerId,"invalid path");const i=r,s=eo(o,"div");try{const l=b("div",[],s);l.setAttribute("data-type","table-content");const c=S4(n,t,i);c.classList.add("drag-preview-element"),l.appendChild(c),Pp(n),zp(n),w4(n,"create"),B4(n),Tw(n,Su);const a=n.getComponentOptions("table"),u=n.addCustom(fo(o),()=>pE({parentElement:s,childElement:l,safeRightSpace:40,safeLeftSpace:40,parentContainer:Ct(e)?n.scrollContainer:e,locatingContainer:Ct(e)?(a==null?void 0:a.locatingContainer)||n.parent:e,paddingLeft:wu+ls,paddingTop:wu+ls,paddingBottom:ls/2,paddingRight:ls/2})),f=x4(n);u.on("scroll",f.handleScroll),setTimeout(()=>{QB(n,o)})}catch{const c=`invalid table data: ${JSON.stringify(i)}`;Bn.error(c);const a=b("div",["error"],s);a.innerText=c}return s}function gS(n,t,e){d(Bn,e.type==="table","not table data");const o=e,r=rt(t);try{const i=$t(t),s=Ro(t),l=S4(n,s,o);l.classList.add("drag-preview-element"),i.insertAdjacentElement("afterend",l),i.remove(),Pp(n),zp(n),w4(n,"update"),B4(n),Su(n,t)}catch{const s=`invalid table data: ${JSON.stringify(o)}`;Bn.error(s);const l=b("div",["error"],r);l.innerText=s}}function pS(n,t){const o=Ya(t,"|").split("|");if(o.length<2)return null;const i=3,s=o.length,l=[];for(let m=0;m<3;m++)o.forEach(C=>{l.push(pn(n.doc,m===0?C:""))});const c=Array(s).fill(Lu),a=l[s],u=n.doc.getContainerBlocks(a)[0].id;return{blockData:{id:N(),type:"table",rows:i,cols:s,children:l,colsWidth:c},focusBlockId:u}}function CS(n,t){const e=t.rows,o=t.cols;if(e<1||o<1)return null;const r=[];for(let a=0;a<e;a++)for(let u=0;u<o;u++)r.push(pn(n.doc));const i=Array(o).fill(Lu),s=r[0],l=n.doc.getContainerBlocks(s)[0].id;return{blockData:{id:N(),type:"table",rows:e,cols:o,children:r,colsWidth:i},focusBlockId:l}}const rh=y("table-selection-to-doc");function T4(n,t){const{start:e,end:o,block:r}=t,i=it(r);d(rh,i==="table",`invalid block type: ${i}`);const s=n.getBlockData(r);if(e.isSimple()&&o.isSimple()){const U=s.children;d(rh,U,"no table children");const tt=U[0],ot=U[U.length-1],ut=bt(r,tt),dt=bt(r,ot);return T4(n,{block:t.block,start:ut,end:dt})}d(rh,!e.isSimple()&&!o.isSimple(),"invalid block pos type");const l=nt.fromBlock(r),{fromCol:c,toCol:a,fromRow:u,toRow:f}=rn(r,e,o),m={},C=[],v=n.doc.toJSON();let w={};l.sub({row:u,col:c},{row:f,col:a}).forEach((U,tt)=>{U.forEach((ot,ut)=>{const dt=ot.containerId;if(C.indexOf(dt)!==-1)return;C.push(dt);let yt;if(ot.virtual){const Xt=l.getCellByContainerId(ot.containerId),Fe=c+ut;let vo=Xt.col+Xt.colSpan-1;vo>a&&(vo=a);const ar=vo-Fe+1;ar>1&&(m[`${dt}_colSpan`]=ar);const dr=u+tt;let ko=Xt.row+Xt.rowSpan-1;ko>f&&(ko=f);const ma=ko-dr+1;ma>1&&(m[`${dt}_rowSpan`]=ma),yt=oo()}else{if(yt=K1(n.editorBlocks,v,dt),ot.col+ot.colSpan>a+1){const Xt=a-ot.col+1;Xt>1&&(m[`${dt}_colSpan`]=Xt)}else ot.colSpan>1&&(m[`${dt}_colSpan`]=ot.colSpan);if(ot.row+ot.rowSpan>f+1){const Xt=f-ot.row+1;Xt>1&&(m[`${dt}_rowSpan`]=Xt)}else ot.rowSpan>1&&(m[`${dt}_rowSpan`]=ot.rowSpan)}const{root:oe,...Jn}=yt.blocks;w={...w,...Jn,[dt]:oe}})});const L=hs($t(r)).slice(c,a+1);return{blocks:{root:[{id:N(),type:i,children:C,colsWidth:L,rows:f-u+1,cols:a-c+1,...m}],...w},meta:{},comments:{}}}function bS(n,t){if(t.top===0)return!0;for(let e=t.left;e<=t.right;e++)if(n[t.top-1][e]===n[t.top][e])return!1;return!0}function vS(n,t){if(t.left===0)return!0;for(let e=t.top;e<=t.bottom;e++)if(n[e][t.left-1]===n[e][t.left])return!1;return!0}function kS(n,t){if(t.bottom===n.length-1)return!0;for(let e=t.left;e<=t.right;e++)if(n[t.bottom][e]===n[t.bottom+1][e])return!1;return!0}function yS(n,t){if(t.right===n[0].length-1)return!0;for(let e=t.top;e<=t.bottom;e++)if(n[e][t.right]===n[e][t.right+1])return!1;return!0}function wS(n,t,e){const o=t.col,r=t.row,i=e.col,s=e.row,l={left:o,top:r,right:i,bottom:s};let c=!1;do{if(c=!1,!bS(n,l)){l.top--,c=!0;continue}if(!vS(n,l)){l.left--,c=!0;continue}if(!kS(n,l)){l.bottom++,c=!0;continue}if(!yS(n,l)){l.right++,c=!0;continue}}while(c);return l}function BS(n,t,e,o){if(e.custom!==void 0||o.custom!==void 0)return{anchor:e,focus:o};const r=nt.fromBlock(t),i=r.map(A=>A.containerId),s=r.getCellByContainerId(e.childContainerId),l=r.getCellByContainerId(o.childContainerId),c=Math.min(s.row,l.row),a=Math.max(s.row,l.row),u=Math.min(s.col,l.col),f=Math.max(s.col,l.col),m=wS(i,{row:c,col:u},{row:a,col:f}),C=r.getCell({row:m.top,col:m.left}),v=r.getCell({row:m.bottom,col:m.right}),w=r.getCell({row:m.top,col:m.right}),E=r.getCell({row:m.bottom,col:m.left});let L,x;return s.row<=l.row?s.col<=l.col?(L=C,x=v):(L=w,x=E):s.col<l.col?(L=E,x=w):(L=v,x=C),console.log(`move ${L.col}, ${L.row}, -> ${x.col}, ${x.row}`),{anchor:bt(t,L.containerId),focus:bt(t,x.containerId)}}function D4(n,t,e){if(e.isSimple())return[$t(t).getBoundingClientRect()];const o=$t(t),r=o.getBoundingClientRect(),{fromCol:i,fromRow:s,toCol:l,toRow:c}=rn(t,e.start,e.end),a=hs(o),u=a.slice(0,i).reduce((w,E)=>w+E,0),f=u+a.slice(i,l+1).reduce((w,E)=>w+E,0),m=b4(o);let C=m.slice(0,s).reduce((w,E)=>w+E,0);const v=C+m.slice(s,c+1).reduce((w,E)=>w+E,0);if(s===0){const w=rS(n,t);C-=w}return[new DOMRect(r.left+u,r.top+C,f-u,v-C)]}y("table-size");const ES=40;function Nc(n){const t=n.querySelector("td");if(!t)return 0;const e=window.getComputedStyle(t),o=Number.parseInt(e.borderLeft,10),r=Number.parseInt(e.borderRight,10);return(o+r)/2}function IS(n,t,e){const o=m1(n,e.container);return o!==void 0?o+Nc(t):ES*e.colSpan-Nc(t)}function xS(n,t,e,o){let r=0;const i=e.colCount;for(let s=0;s<i;s++){const l=e.getRealCell({col:s,row:o});if(l.virtual)continue;let c=IS(n,t,l);const a=Qm(l.container,{withPadding:!0});a&&a>c&&(c=a),r+=c+Nc(t)}return r}function SS(n,t){const e=$t(t),o=nt.fromTable(e);let r=0;for(let s=0;s<o.rowCount;s++)r=Math.max(r,xS(n,e,o,s));const i=Nc(e);return r+=i,r}const Wn=y("table-creator");async function TS(n,t){return n.undoManager.runInGroup(()=>{var c,a;const e=t.item,o=(c=e.colCount)!=null?c:5,r=(a=e.rowCount)!=null?a:3,i=CS(n,{cols:o,rows:r});if(!i)return null;const{blockData:s,focusBlockId:l}=i;return n.insertBlock(t.containerId,t.blockIndex,s,Ot(n,l,0))})}class DS{constructor(){h(this,"id","insert-table");h(this,"name","Create table");h(this,"element");h(this,"closeable",null);h(this,"colCount");h(this,"rowCount");h(this,"setCloseable",t=>{this.closeable=t});h(this,"destroy",()=>{this.closeable=null});h(this,"getTableCreatorCellId",(t,e)=>`table-creator-cell-${t}-${e}`);h(this,"handleTableCreatorClick",t=>{var m,C;t.preventDefault(),t.stopPropagation();const e=t.target;d(Wn,e instanceof HTMLElement,"invalid event target");const o=e.closest(".table-creator");d(Wn,o,"no table creator");const r=o.querySelectorAll(".active");if(r.length===0)return;const s=r[r.length-1].id;d(Wn,s,"no cell id");const l="table-creator-cell-";if(!s.startsWith(l))return;const a=s.substring(l.length).split("-");d(Wn,a.length===2,"invalid cell id");const u=Number.parseInt(a[0],10)+1,f=Number.parseInt(a[1],10)+1;Wn.debug(`${u}, ${f}`),this.colCount=f,this.rowCount=u,(m=this.closeable)==null||m.click(this,this.element),(C=this.closeable)==null||C.close(),this.handleTableCreatorLeave()});h(this,"handleTableCreatorLeave",()=>{for(let t=0;t<9;t++)for(let e=0;e<9;e++){const o=this.getTableCreatorCellId(t,e),r=document.getElementById(o);r&&F(r,"active")}});h(this,"handleTableCreatorCellEnter",t=>{const e=t.target;d(Wn,e instanceof HTMLElement,"invalid event target");const o=e.id,r="table-creator-cell-";d(Wn,o.startsWith(r),"invalid cell id");const s=o.substring(r.length).split("-");d(Wn,s.length===2,"invalid cell id");let l=Number.parseInt(s[0],10),c=Number.parseInt(s[1],10);l===0&&c===0&&(l=-1,c=-1);for(let a=0;a<9;a++)for(let u=0;u<9;u++){const f=this.getTableCreatorCellId(a,u),m=document.getElementById(f);d(Wn,m,"no cell"),a<=l&&u<=c?M(m,"active"):F(m,"active")}});this.element=this.createTableCreatorElement()}createTableCreatorElement(){const t=b("div",["table-creator"],null),e=(o,r,i)=>{const s=b("div",["table-creator-cell"],o);return s.id=this.getTableCreatorCellId(r,i),s};t.addEventListener("click",this.handleTableCreatorClick),t.addEventListener("mouseleave",this.handleTableCreatorLeave);for(let o=0;o<9;o++){const r=b("div",["table-creator-row"],t);for(let i=0;i<9;i++)e(r,o,i).addEventListener("mouseenter",this.handleTableCreatorCellEnter)}return t}}function LS(n){return n.addCustom("table-creator-item",()=>new DS)}const Pc=y("table-block");function MS(n){return 1}function RS(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t))return null;if(r instanceof HTMLTableCellElement){const l=$t(t);if(hp(l).indexOf(r)!==-1){const a=is(r),u=bt(t,V(a));return new Ye(n,{anchor:u,focus:u})}}if(!fn(r))return null;const i=r;if(E4(t).indexOf(i)===-1)return null;const s=bt(t,V(i));return new Ye(n,{anchor:s,focus:s})}function AS(n,t,e,o){return null}function OS(n,t){return n.getBoundingClientRect()}function L4(n,t,e,o){if(e.isSimple()){d(Pc,o.isSimple(),"from is simple position but to is not simple position"),Pc.debug("full select table"),M(t,"full-selected");return}d(Pc,!o.isSimple(),"from is complex position but end is simple position");const r=Un(n,t,e),i=Un(n,t,o);d(Pc,r.blockId===i.blockId,"only allow update one table selection"),VB(n,r,i).forEach(l=>{const c=nh(l);M(c,"selected")})}function _S(n){n.rootContainer.querySelectorAll('[data-type="editor-block"][data-block-type="table"]').forEach(t=>{F(t,"full-selected"),t.querySelectorAll("td.selected").forEach(e=>{F(e,"selected")})})}function NS(n,t){return fp(t)?E4(t):[]}function PS(n,t,e,o,r){return oh(t,e,o,r)}function $S(n,t){return SS(n,t)}function HS(n,t){return j(n,t)?pS(n,n.getBlockString(t).trim()):null}function jS(n){return{name:"TableBlock",insertBlockCommandItems:[{id:"insert-table",name:S.t("table.title"),order:200,icon:M5,children:[LS(n)],group:"common"}],handleInsertEmptyBlock:TS}}function FS(n,t,e){return gS(n,t,e),setTimeout(()=>{const o=n.selection.range;o.isSimple()?n.selection.caret.update():L4(n,t,o.start,o.end)}),!0}function zS(n,t){let e=0;const{selectedColumns:o}=mu(n,t);if(o.size>0){const{fromCol:i,toCol:s}=rn(t,n.selection.range.start,n.selection.range.end),l=nt.fromBlock(t);(i!==0||s!==l.colCount-1)&&(e=60)}const r=D4(n,t,n.selection.range)[0];return new DOMRect(r.left,r.top+e,r.width,r.height-e)}function VS(n,t){Dw(n,Su);const e=n.findCustom(fo(t));if(e){const o=x4(n);e.off("scroll",o.handleScroll),e.destroy()}}function US(){return{abstract:`[${S.t("table.abstract")}]`}}const Cs={blockType:"table",blockKind:"complex",enableKeyboardSelect:!0,createBlockContent:mS,getBlockTextLength:MS,getRangeFromPoint:RS,moveCaret:AS,getCaretRect:OS,updateSelection:L4,clearSelection:_S,getChildContainers:NS,getNextContainer:PS,getMinWidth:$S,getSelectedContainers:Eu,convertFrom:HS,adjustSelectionPos:BS,getClientRects:D4,selectionToDoc:T4,getOptions:jS,getTextToolbarReferenceClient:zS,handleUpdateBlock:FS,handleDeleteBlock:VS,getBlockProperties:US},qS={table:{cellBackground:"\u5355\u5143\u683C\u80CC\u666F\u8272",deleteSelectRow:"\u5220\u9664\u6240\u9009\u884C",deleteSelectCol:"\u5220\u9664\u6240\u9009\u5217",mergeCell:"\u5408\u5E76\u5355\u5143\u683C",splitCell:"\u62C6\u5206\u5355\u5143\u683C",tableConfigKey:"\u8868\u683C\u8BBE\u7F6E",tableConfig:{rowTitle:"\u884C\u6807\u9898",colTitle:"\u5217\u6807\u9898",stripeStyle:"\u6761\u7EB9\u6837\u5F0F",hideBorder:"\u9690\u85CF\u8868\u683C\u7EBF",showBorder:"\u663E\u793A\u8868\u683C\u7EBF",showChart:"\u663E\u793A\u56FE\u8868",hideChart:"\u9690\u85CF\u56FE\u8868"},title:"\u8868\u683C",abstract:"\u8868\u683C"}},WS={table:{cellBackground:"Cell background",deleteSelectRow:"Delete rows",deleteSelectCol:"Delete columns",mergeCell:"Merge cells",splitCell:"Split cell",tableConfigKey:"Table setting",tableConfig:{rowTitle:"Row Title",colTitle:"Col Title",stripeStyle:"Stripe style",hideBorder:"Hide border",showBorder:"Show border",showChart:"Show chart",hideChart:"Hide chart"},title:"Table",abstract:"Table"}};S.mergeLang({"zh-CN":qS,"en-US":WS});const TF="",M4=y("table");function R4(n,t){const e=hu(t);if(!e)return;const o=z(e);d(M4,o&&Ht(o),"not a table block");const r=oh(o,e,"ArrowRight");if(!r){const s=ht(o);return s?(n.selection.selectBlock(s,0),!0):R4(n,o)}const i=Qt(r);return n.selection.selectBlock(i,0),!0}function GS(n){if(!n.isWritable())return!1;const t=n.getFocusedBlock();if(!!t)return R4(n,t)}function A4(n,t){const e=hu(t);if(!e)return;const o=z(e);d(M4,o&&Ht(o),"not a table block");const r=oh(o,e,"ArrowLeft");if(!r){const s=gt(o);return s?(n.selection.selectBlock(s,Z(n,s)),!0):A4(n,o)}const i=Gt(r);return n.selection.selectBlock(i,Z(n,i)),!0}function ZS(n){if(!n.isWritable())return!1;const t=n.getFocusedBlock();if(!!t)return A4(n,t)}const ih={Tab:GS,"Shift+Tab":ZS},YS=`<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
444
+ </svg>`;function nx(n){return kn("list-to-mindmap",S.t("mindmap.viewAsMindMap"),ex,[],n.clientId)}const wF="";class Sc{constructor(t){h(this,"toMindmapButton");h(this,"currentBlock",null);h(this,"handleHoveringBlock",t=>{!this.editor.isWritable()||(t&&at(t)&&He(t)!=="unchecked"&&He(t)!=="checked"?At(t).appendChild(this.toMindmapButton):this.toMindmapButton.remove())});h(this,"handleMouseEnter",()=>{const t=z(this.toMindmapButton);d(Lt,t&&at(t),"no parent list"),zu(this.editor,t,!0),this.currentBlock=t});h(this,"handleMouseLeave",()=>{this.currentBlock&&(zu(this.editor,this.currentBlock,!1),this.currentBlock=null)});h(this,"handleClick",()=>{const t=z(this.toMindmapButton);d(Lt,t&&at(t),"no parent list"),Uu(this.editor,t,{},{saveData:!0,selectBlock:!0,mindmapTools:t4})});this.editor=t,_t.get(this.editor).addListener("change",this.handleHoveringBlock),this.toMindmapButton=nx(t),t.domEvents.addEventListener(this.toMindmapButton,"mouseenter",this.handleMouseEnter),t.domEvents.addEventListener(this.toMindmapButton,"mouseleave",this.handleMouseLeave),t.domEvents.addEventListener(this.toMindmapButton,"click",this.handleClick)}static get(t){return t.findCustomByType(Sc)}destroy(){_t.get(this.editor).removeListener("change",this.handleHoveringBlock)}hide(){this.currentBlock&&(this.currentBlock=null),this.toMindmapButton.remove()}}const ox={list:{confirm:"\u786E\u5B9A",setStart:"\u8BBE\u7F6E\u7F16\u53F7",continueList:"\u7EE7\u7EED\u7F16\u53F7",restartList:"\u5F00\u59CB\u65B0\u5217\u8868",changeNumber:"\u4FEE\u6539\u7F16\u53F7\u503C",numberLabel:"\u7F16\u53F7\u987A\u5E8F",mention:{tooltip:"\u63D0\u53CA\u4EBA\u5458\u5E76\u901A\u77E5"}},mindmap:{viewAsMindMap:"\u663E\u793A\u4E3A\u8111\u56FE",autoFit:"\u81EA\u52A8\u7F29\u653E",fullScreen:"\u5168\u5C4F\u67E5\u770B",close:"\u5173\u95ED",exitFullscreen:"\u9000\u51FA\u5168\u5C4F"}},rx={list:{confirm:"OK",setStart:"Set the number",continueList:"Continue numbering",restartList:"Start a new list",changeNumber:"Set numbering value",numberLabel:"Numbering order",mention:{tooltip:"@Mention someone"}},mindmap:{viewAsMindMap:"View as MindMap",autoFit:"Auto fit",fullScreen:"Fullscreen",close:"Close",exitFullscreen:"Exit fullscreen"}};S.mergeLang({"zh-CN":ox,"en-US":rx});const BF="";function ix(n,t,e){var o;t==="beginDrag"&&((o=Sc.get(n))==null||o.hide())}function Tc(n){const t=n.getAttribute("block-padding-level");return t?Number(t):null}function sx(n,t){let e;const o=Tc(t);if(!o)e=1;else{if(o>=12)return e=12,!1;e=o+1}return n.updateBlockData(t,{...n.getBlockData(t),padding:e}),!0}function i4(n,t){const e=Tc(t);if(!e)return!1;const o=n.getBlockData(t);return e>1?(n.updateBlockData(t,{...o,padding:e-1}),!0):(n.updateBlockData(t,{...o,padding:null}),!0)}function qu(n){return n.readonly||!n.isWritable()}function lx(n){return n.selection.range.getSelectedBlocks().forEach(e=>{const o=e.block;j(n,o)&&sx(n,o)}),!0}function cx(n){return n.selection.range.getSelectedBlocks().forEach(e=>{const o=e.block;j(n,o)&&i4(n,o)}),!0}function ax(n){return qu(n)?!1:n.undoManager.runInGroup(()=>(lx(n),!0))}function dx(n){return qu(n)?!1:n.undoManager.runInGroup(()=>(cx(n),!0))}function ux(n){if(qu(n))return!1;if(!n.selection.range.isCollapsed())return;const t=n.selection.focusedBlock;if(!j(n,t))return;const e=n.selection.range.focus;if(!(!e.isSimple()||e.offset!==0||!Tc(t)))return i4(n,t),!0}class hx{renderBlock(t,e,o){const{padding:r}=o;return r?{attributes:{"block-padding-level":r}}:{}}}const EF="",fx={Tab:ax,"Shift+Tab":dx,Backspace:ux};function Wu(n,t,e){let o=1,r=1,i=N();if(at(t))o=xe(t);else{const a=Tc(t);a&&(o=a+1),o>8&&(o=8)}const s=Gp(t,e);if(s){if(K(t)>K(s))r=Ie(s)+1;else{const a=Ie(s);a>1&&(r=a-1)}i=Qo(s)}const c={...n.getBlockData(t),level:o,start:r,groupId:i,type:"list",...Bc(e)};n.undoManager.runInGroup(()=>{const a=K(t),u=U(H(t));n.deleteBlock(t);const f=n.insertBlock(u,a,c);new Jo(n,f).fix()})}const s4={..._i,blockType:"list",createBlockContent:tx,convertFrom:XE,handleDrop:oI,notify:ix},Gu=y("paragraph");class mx{constructor(t){h(this,"id","BlockParagraphProvider");this.editor=t}isChecked(t,e){return!!(t[e]||t.level&&(t.ordered===!0&&!t.checkbox&&e==="ordered-list"||t.ordered===!1&&!t.checkbox&&e==="unordered-list")||e==="check-list"&&t.checkbox)}getAvailableCommands(t,e){const o=[],r={"unordered-list":[S.t("commands.unordered"),It.isMac?S.t("commandDesc.mac.unordered"):S.t("commandDesc.window.unordered"),w5],"ordered-list":[S.t("commands.ordered"),It.isMac?S.t("commandDesc.mac.ordered"):S.t("commandDesc.window.ordered"),y5],"check-list":[S.t("commands.check"),void 0,B5],link:[S.t("commands.link"),It.isMac?S.t("commandDesc.mac.link"):S.t("commandDesc.window.link"),lu],quoted:[S.t("commands.quote"),void 0,E5]};if(j(t,e)){const i=G(e),s=it(e),l=We(t,e),c=t.getBlockData(e);Object.entries(r).forEach(([a,[u,f,m]])=>{const C=[];if(this.isChecked(c,a)&&C.push("checked"),a==="link"){if(!t.selection.range.isSimple())return;t.selection.range.getSelectedBlocks().length!==1&&C.push("disabled")}o.push({blockId:i,blockType:s,blockKind:l,id:a,name:u,desc:f,states:C,icon:m,groupIndex:600})})}return o}convertLink(t,e,o){d(Gu,kr(e.start),""),d(Gu,kr(e.start),"");const r="bottom-start",i=e.start.offset,s=e.end.offset,l=(C,v)=>{t.undoManager.runInGroup(()=>{try{let w=El(t.getBlockText(o),i,s,C);w=wl(i,C.length,w,"link",v),t.setBlockText(o,w),t.selection.selectBlock(o,i+C.length),t.focus()}catch(w){Gu.error(w)}})},c=()=>{t.focus()},a=Ao(t,o,e)[0];if(!a)return;const u=_o(t,o,"link-button-anchor",a),f=t.getBlockText(o),m=Bl(f,i);vc(t,{target:u,linkText:t.getSelectedText(),linkUrl:(m==null?void 0:m.link)||"",onFinished:l,onClose:c,placement:r})}executeCommand(t,e,o,r){var c;if(!j(t,e))return!1;const i=r.id,s=(c=r.states)==null?void 0:c.includes("checked");let l=!1;if(i==="unordered-list"&&(s?ms(t,e):Wu(t,e,"unordered"),l=!0),i==="ordered-list"&&(s?ms(t,e):Wu(t,e,"ordered"),l=!0),i==="check-list"&&(s?ms(t,e):Wu(t,e,"unchecked"),l=!0),i==="quoted"){const u=t.getBlockData(e).quoted;t.updateBlockData(e,{quoted:u?void 0:!0}),l=!0}if(i==="link"){const a=bc(t);a.disableTextToolbar(),a.hide(),setTimeout(()=>{a.enableTextToolbar()},1e3),this.convertLink(t,o,e),l=!0}return l}}const gx={left:Pr,right:rc,center:ic};class px{constructor(t){h(this,"id","BlockAlignProvider");this.editor=t}applyAlignStyle(t,e,o){Object.keys(gx).includes(o)?t.updateBlockData(e,{align:o}):t.updateBlockData(e,{align:null})}isChecked(t,e){return t.align===e}getAvailableCommands(t,e,o){const r=G(e),i=it(e),s=We(t,e),l=t.getBlockData(e);return[{id:"align",name:"",blockId:r,blockType:i,blockKind:s,groupIndex:700,dropdown:!0,element:a=>{var f;const u=b("span",["toolbar-item-name-container"],null);for(const m of a.children)if((f=m.states)!=null&&f.includes("checked"))return u.innerHTML=m.icon||Pr,u;return u.innerHTML=Pr,u},manualShowChildren:!0,childrenPlacement:"bottom-start",defaultCheckedChildren:["align-left"],children:[{id:"align-left",name:S.t("commands.alignLeft"),icon:Pr,states:this.isChecked(l,"left")?["checked"]:[]},{id:"align-center",name:S.t("commands.alignCenter"),icon:ic,states:this.isChecked(l,"center")?["checked"]:[]},{id:"align-right",name:S.t("commands.alignRight"),icon:rc,states:this.isChecked(l,"right")?["checked"]:[]}],childrenType:"menu"}]}executeCommand(t,e,o,r){if(r.id.startsWith("align")){const i=r.id.replace(/^align-/,"");return this.applyAlignStyle(t,e,i),!0}return!1}}const Cx=y("toolbar-handler"),bx={id:"",name:"",type:"separator"};class Gr{constructor(t){h(this,"toolbar");h(this,"toolbarType","object");h(this,"mouseDown",!1);h(this,"oldRange",null);h(this,"hoveringBlock",null);h(this,"hoveringTextChild",null);h(this,"_disableTextToolbar",!1);h(this,"handleButtonClick",(t,e)=>{this.toolbarType==="text"?(this.editor.editorCommandProviders.executeCommand(this.editor.selection.range,e,{}),this.showTextToolbar()):this.hoveringBlock&&zE(this.editor,this.hoveringBlock,this.hoveringTextChild,e)});h(this,"handleClose",()=>{this.editor.focus()});h(this,"handleDocumentMouseDown",t=>{t.button===0&&(document.addEventListener("mouseup",this.handleDocumentMouseUp),this.mouseDown=!0)});h(this,"handleDocumentMouseUp",()=>{document.removeEventListener("mouseup",this.handleDocumentMouseUp),this.mouseDown=!1,this.handleSelectionChange(this.editor)});h(this,"handleHoveringBlockChildChange",(t,e,o,r)=>{if(!(this.hoveringBlock===t&&this.hoveringTextChild===e)&&(this.hoveringBlock=t,this.hoveringTextChild=e,!(this.toolbar.isVisible&&this.toolbarType==="text"))){if(!t){this.toolbar.close();return}this.showObjectToolbar()}});h(this,"handleSelectionChange",ie.default(t=>{if(d(Cx,t===this.editor,"editor mismatch"),t.selection.range.isCollapsed()||this.mouseDown){this.toolbar.close(),this.oldRange=null;return}if(t.selection.range.getSelectedBlocks().length===0){this.toolbar.close(),this.oldRange=null;return}this.oldRange&&this.oldRange.isEqual(t.selection.range)||(this.oldRange=t.selection.range,this.showTextToolbar())},50));this.editor=t,this.toolbar=new os([],void 0,{tooltipId:t.clientId,id:"editor-toolbar"}),this.toolbar.on("click",this.handleButtonClick),this.toolbar.on("close",this.handleClose),this.bindEvents(),t.addListener("selectionChanged",this.handleSelectionChange),_t.get(t).addListener("childChange",this.handleHoveringBlockChildChange),_t.get(t).addFilter(this),t.editorCommandProviders.registerCommandProvider(new VE(t)),t.editorCommandProviders.registerCommandProvider(new mx(t)),t.editorCommandProviders.registerCommandProvider(new px(t))}disableTextToolbar(){this._disableTextToolbar=!0}enableTextToolbar(){this._disableTextToolbar=!1}hide(){this.toolbar.close()}destroy(){this.unbindEvents(),this.toolbar.destroy(),this.editor.removeListener("selectionChanged",this.handleSelectionChange),_t.get(this.editor).removeListener("childChange",this.handleHoveringBlockChildChange)}isInBlock(t,e){return t!==this.hoveringBlock?!1:!!(e.target&&e.target instanceof Node&&this.toolbar.popper&&vt(this.toolbar.popper,e.target))}bindEvents(){document.addEventListener("mousedown",this.handleDocumentMouseDown)}unbindEvents(){document.removeEventListener("mousedown",this.handleDocumentMouseDown)}update(){this.showTextToolbar()}showTextToolbar(){if(this._disableTextToolbar||!this.editor.isWritable())return;const e=this.editor.selection.range.getSelectedBlocks();if(e.length===0)return;const o=e[0];if(!o)return;if(e.length===1&&Te(o.block)){this.showObjectToolbar();return}const r=this.editor.editorCommandProviders.getCommands(this.editor.selection.range),i=new Map;r.forEach(a=>{const u=a.groupIndex,f=i.get(u);f?f.push(a):i.set(u,[a])});const s=[[]],l=Array.from(i.entries()).sort((a,u)=>a[0]-u[0]);for(let a=0;a<l.length;a++){const[,u]=l[a];if(u.length===0)continue;let f=s[s.length-1];f.length>0&&f[f.length-1].groupIndex!==u[u.length-1].groupIndex&&(f=[],s.push(f)),f.push(...Cc(u))}if(s.length===0){this.toolbar.close();return}this.toolbarType="text";const c=[];if(s.forEach((a,u)=>{const f=a.sort((m,C)=>{var v,w;return((v=m.order)!=null?v:0)-((w=C.order)!=null?w:0)});c.push(...f),u!==s.length-1&&c.push(bx)}),this.toolbar.updateItems(c),!this.toolbar.isVisible){const a=e[e.length-1],u=!this.editor.selection.range.isReverse()&&a!==o,f=u?a:o,m=OE(this.editor,f),C=_o(this.editor,f.block,"editor-quick-menu",m);this.toolbar.manualShow(C,{placement:u?"bottom":"top"})}}showObjectToolbar(){if(!this.hoveringBlock)return;const t=this.hoveringBlock,e=this.hoveringTextChild,o=HE(this.editor,t,e);this.toolbarType="object",o.length===0?this.toolbar.close():(this.toolbar.updateItems(o),this.toolbar.isVisible||this.toolbar.manualShow(e||rt(t),{placement:e?"bottom":"top"}))}static register(t){return t.addCustom("toolbar-handler",e=>new Gr(e))}static get(t){return t.getCustom("toolbar-handler")}}function Zu(){let n=8;for(;n>0&&!document.querySelector(`div[data-style-heading='${n}']`);)n--;return n}function gs(n,t){const e=n;e.blockOptions=t,e.itemType="insert-block",n.children&&n.children.forEach(o=>gs(o,t))}function vx(n,t,e){n.getBlockData(t).heading===e?n.updateBlockData(t,{heading:null}):n.updateBlockData(t,{heading:e})}async function kx(n,t){const{containerId:e,blockIndex:o,item:r}=t,{value:i,id:s}=r,l=n.insertTextBlock("",e,o);if(s.startsWith("heading-"))vx(n,l,i||"1");else if(i==="ordered"||i==="unordered"||i==="checkbox"){const c=n.selection.range.focus;if(!c.isSimple())return null;const a=hl(n,l,"list",{offset:c.offset,data:{listType:i==="checkbox"?"unchecked":i}});a&&(n.deleteBlock(l),n.insertBlock(e,o,a.blockData))}else i==="quote"&&n.updateBlockData(l,{quoted:!0});return null}const l4=(n,t)=>n.undoManager.runInGroup(()=>kx(n,t));function Dc(n=1){var i;const t={name:"basic",insertBlockCommandItems:[]};let e=Zu();e<=4?e=5:e<8&&(e+=1);let o=n;const r=up;for(;o<=e;)(i=t.insertBlockCommandItems)==null||i.push({id:`heading-${o}`,icon:r[`HeadingH${o}Icon`],name:S.t("quickMenu.basic.heading.title",{heading:String(o)}),order:o,group:"basics",value:String(o)}),o++;return t}function yx(){const n={name:"basic",insertBlockCommandItems:[]},t=up;return["Unordered","Ordered","Checkbox","Quote"].forEach((o,r)=>{var i;(i=n.insertBlockCommandItems)==null||i.push({id:`insert-${o.toLocaleLowerCase()}`,name:S.t(`quickMenu.basic.${o.toLocaleLowerCase()}`),icon:t[`${o}Icon`],value:o.toLocaleLowerCase(),group:"basics",order:10+r})}),n}function wx(){var e;const t={name:"basic",insertBlockCommandItems:[...Dc().insertBlockCommandItems||[]],handleInsertEmptyBlock:l4};return(e=t.insertBlockCommandItems)==null||e.forEach(o=>{gs(o,t)}),t}function Bx(){const n=Dc(),t=yx();return{name:"basic",insertBlockCommandItems:[...n.insertBlockCommandItems||[],...t.insertBlockCommandItems||[]],handleInsertEmptyBlock:l4}}class c4{constructor(){h(this,"dataUrl","");h(this,"error",null)}destroy(){}setDataUrl(t){this.dataUrl=t}setError(t){this.error=t}}const Ex=y("mathjax-converter"),Ix="MathJax-script";async function xx(n){var o;window.MathJax||(window.MathJax={options:{skipHtmlTags:["script","noscript","style","textarea","pre","code","annotation","annotation-xml","body"]}});const t=n.getComponentOptions("mathjax"),e=((o=t==null?void 0:t.cdn)==null?void 0:o.mathjax)||"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js";await So(e,Ix)}function Sx(){try{window.MathJax&&window.MathJax.texReset()}catch{}}async function a4(n,t){const e="mathjax2Svg";try{await Rn.lock(e),Sx(),await xx(n);const o=await window.MathJax.tex2svgPromise(t),r=o.querySelector("merror");if(r)throw new Error(r.textContent);return o.querySelector("svg").outerHTML}catch(o){throw Ex.error(o),o}finally{Rn.release(e)}}async function d4(n,t){const e=await a4(n,t);return e?await am(e,"image/svg+xml"):""}async function Yu(n,t){const o=await a4(n,t),r=new File([o],"math.svg");return(await n.doc.uploadResource(r)).resourceId}const u4=y("edit-mathjax");class Tx{constructor(){h(this,"editMathjaxPopup",null);h(this,"onFinished",null);h(this,"tex","");h(this,"handleShow",()=>{setTimeout(()=>{this.getTextarea().focus()})});h(this,"handleClose",t=>{var o;const e=t.content.querySelector("textarea");if(e){const r=e.value;r!==this.tex&&((o=this.onFinished)==null||o.call(this,r))}});h(this,"handleKeydown",t=>{var e;t.isComposing||t.key==="Escape"&&((e=this.editMathjaxPopup)==null||e.close())})}editMathjax(t,e,o){if(!this.editMathjaxPopup)this.editMathjaxPopup=new lc(this.createPopupContent(e));else{const r=this.getTextarea();r.value=e}this.tex=e,this.editMathjaxPopup.addListener("show",this.handleShow),this.editMathjaxPopup.manualShow(t,{theme:"light"}),this.editMathjaxPopup.removeAllListeners("close"),this.editMathjaxPopup.addListener("close",this.handleClose),this.onFinished=o}createPopupContent(t){const e=b("textarea",["mathjax-editor-textarea"],null);return e.value=t,e.addEventListener("keydown",this.handleKeydown),e}getTextarea(){d(u4,this.editMathjaxPopup,"no exists mathjax editor popup");const t=this.editMathjaxPopup.content.querySelector("textarea");return d(u4,t,"no textarea"),t}destroy(){var t;this.onFinished=null,(t=this.editMathjaxPopup)==null||t.removeAllListeners()}}function h4(n,t,e,o){n.addCustom("mathjax-editor",()=>new Tx).editMathjax(t,e,o)}function Dx(){return{insert:" ",attributes:{id:N(),box:!0,type:"math",tex:S.t("mathjax.emptyText"),src:"",created:Date.now()}}}function f4(n,t){const e=n.getBoxData(t);h4(n,t,e.tex,async o=>{const r=await Yu(n,o);n.updateBoxData({...e,tex:o,src:r})})}const Lx=y("mathjax-box");async function Mx(n,t,e){try{const o=await d4(n,t.tex),r=n.findBoxById(t.id);if(!r)return;const i=c1(r);i.innerHTML="";const s=b("img",["mathjax"],i);s.src=o,e.setDataUrl(o)}catch(o){e.setError(o)}}function Rx(n,t,e,o){const r=o,i=n.addCustom(`mathjax-box-${r.id}`,()=>new c4);if(r.src||i.dataUrl){const s=b("img",["mathjax"],e);s.src=n.doc.buildResourceUrl(r.src||i.dataUrl);return}i.error,b("span",["mathjax-tex-text"],e,r.tex),Mx(n,r,i)}function Ax(n,t){const e={id:N(),box:!0,type:"math",tex:t,src:"",created:Date.now()};return Yu(n,t).then(o=>{if(!n.findBoxById(e.id))return;const i={...e,src:o};n.updateBoxData(i)}).catch(o=>{Lx.error(`failed to convert and upload mathjax: ${JSON.stringify(o)}`)}),e}function Ox(n,t,e){f4(n,t)}const Lc={boxType:"math",updateBoxContent:Rx,convertFrom:Ax,handleClickBox:Ox};async function _x(n,t,e){try{const o=t.embedData,r=await d4(n,o.mathjaxText),i=n.findBlockById(t.id);if(!i)return;const s=rt(i);s.innerHTML="";const l=b("img",["mathjax"],s);l.src=r,e.setDataUrl(r)}catch(o){e.setError(o)}}function Nx(n,t){if(n.readonly||!t.target||!(t.target instanceof Node))return;const e=z(t.target);if(!e||!Te(e)||De(e)!=="math")return;const o=rt(e),r=o.querySelector("img")||o.querySelector("span.mathjax-tex-text");if(!r||!vt(r,t.target))return;const s=n.getBlockData(e).embedData;h4(n,r,s.mathjaxText,async l=>{const c=await Yu(n,l),a={mathjaxText:l,src:c};n.updateEmbedData(e,a)})}function Px(n,t,e){const o=e.embedData,r=n.addCustom(`mathjax-block-${e.id}`,()=>new c4);if(n.domEvents.addEventListener(t,"click",Nx),o.src||r.dataUrl){const i=b("img",["mathjax"],t);i.src=n.doc.buildResourceUrl(o.src||r.dataUrl);return}r.error,b("span",["mathjax-tex-text"],t,o.mathjaxText),_x(n,e,r)}function $x(n,t,e){if(!j(n,t))return null;const o=n.getBlockString(t).trim();if(!o||!o.startsWith("$$")||!o.endsWith("$$"))return null;const r=Ya(o,"$");if(!r)return null;const i={mathjaxText:r,src:""};return{blockData:{id:N(),type:"embed",embedType:"math",embedData:i}}}function Hx(n){return{name:"Mathjax"}}function jx(n,t){const e=rt(t);n.domEvents.removeAllListeners(e)}const Qu={embedType:"math",createEmbedContent:Px,getOptions:Hx,convertFrom:$x,handleDeleteBlock:jx},IF="",Fx={mathjax:{emptyText:"\u7A7A\u7684\u516C\u5F0F",abstract:"\u516C\u5F0F"}},zx={mathjax:{emptyText:"Empty Tex",abstract:"TeX"}};S.mergeLang({"zh-CN":Fx,"en-US":zx});const Ux=y("inline-box-items");function Vx(n,t,e){return n.undoManager.runInGroup(()=>{var s;let o=n.getBlockByIndex(t,e);wt(n,o)||(o=n.insertTextBlock([],t,e));const r=Dx();n.setBlockText(o,[r]);const i=n.getBoxById((s=r.attributes)==null?void 0:s.id);return f4(n,i),o})}function qx(n,t,e){let o=n.getBlockByIndex(t,e),r="bottom-start";return wt(n,o)||(r="top-start"),vc(n,{target:o,linkText:"",linkUrl:"",onFinished:(l,c)=>{n.undoManager.runInGroup(()=>{try{wt(n,o)||(o=n.insertTextBlock([],t,e));const a=_e(l,{link:c}),u=_e(" ",null),f=[a,u];n.insertTextToBlock(o,0,f),n.selection.selectBlock(o,ce(f)),n.focus()}catch(a){Ux.error(a)}})},onClose:()=>{n.focus()},placement:r}),o}async function Wx(n,t){switch(t.item.id){case"insert-math":return Vx(n,t.containerId,t.blockIndex);case"insert-link":return qx(n,t.containerId,t.blockIndex);default:return null}}function Gx(){return{name:"text",insertBlockCommandItems:[{id:"insert-math",name:S.t("quickMenu.inlineBox.math"),icon:L5,order:900,group:"common"},{id:"insert-link",name:S.t("quickMenu.inlineBox.link"),icon:lu,order:400,group:"common"}],handleInsertEmptyBlock:Wx}}const m4={basics:100,system:200,common:300,thirdParty:400};function Zx(n){var o,r;const t=(r=(o=n.options.componentsOptions)==null?void 0:o.quickMenu)==null?void 0:r.commandProviders;if(!t)return[];const e=[];return t.forEach(i=>{const s=i.getCommands(n);e.push(...s.map(l=>({...l,itemType:"insert-block",commandProvider:i})))}),e}function Yx(n){var r;const t=[];n.editorBlocks.forEach(i=>{if(!i.getOptions)return;const s=i.getOptions(n);!s.insertBlockCommandItems||(s.insertBlockCommandItems.forEach(l=>{gs(l,s)}),t.push(...s.insertBlockCommandItems))});const e=Gx(),o=Bx();return e.insertBlockCommandItems.forEach(i=>{gs(i,e)}),(r=o.insertBlockCommandItems)==null||r.forEach(i=>{gs(i,o)}),t.push(...e.insertBlockCommandItems),t.push(...o.insertBlockCommandItems),t.push(...Zx(n)),t}function Ku(n){const t=Yx(n),e=new Map;t.forEach(i=>{var c;const s=(c=i.group)!=null?c:"";let l=e.get(s);l?l.items.push(i):(l={group:s,order:i.groupOrder||m4[s]||1e3,items:[i]},e.set(s,l))});const o=Array.from(e.values());o.sort((i,s)=>i.order-s.order),o.forEach(i=>{i.items.sort((s,l)=>{var c,a;return((c=s.order)!=null?c:0)-((a=l.order)!=null?a:0)})});const r=[];return o.forEach((i,s)=>{const l=i.group||"common",a=l in m4?S.t(`blockMenu.section.${l}`):l;r.push({id:`section-${s}`,name:a,type:"section",group:i.group,itemType:"insert-block"}),r.push(...i.items.map(u=>({...u})))}),r}function Qx(n,t,e){const o=n.getFocusedBlock();if(!o)return;const r=n.getParentContainer(o),i=U(r);let l=n.getBlockIndex(o);if(wt(n,o)||(l+=1),t.commandProvider){t.commandProvider.executeCommand(n,t,{from:"quick-menu",...e});return}!t.blockOptions||!t.blockOptions.handleInsertEmptyBlock||t.blockOptions.handleInsertEmptyBlock(n,{containerId:i,blockIndex:l,item:t})}const g4=y("quick-menu"),Kx={id:"quick-menu",trigger:["/"]};class Mc{constructor(t,e=Kx){h(this,"suggest");h(this,"items");h(this,"maxHeading");h(this,"queryItems",async(t,e)=>{if(this.items.length===0?this.initMenuItems():this.refreshMenuItems(),e){const o=new Set,r=e.toLocaleLowerCase();return this.items.filter(i=>{var s;return i.type==="section"?!0:i.name.toLocaleLowerCase().indexOf(r)!==-1||Vd(i).toLocaleLowerCase().indexOf(r)!==-1||i.group&&((s=i.group)==null?void 0:s.toLocaleLowerCase().indexOf(r))!==-1?(o.add(i.group),!0):!1}).filter(i=>i.type==="section"?o.has(i.group):!0)}return this.items});h(this,"onShow",(t,e,o,r)=>{const i=this.editor.getBlockByIndex(e,o);if(!Uo(i)){const s=z(H(i));if(s&&it(s)==="code")return!1}return!0});h(this,"onClickItem",(t,e)=>{const o=e;o.itemType==="insert-block"&&(d(g4,o.blockOptions||o.commandProvider,"invalid quick item, no block options or command provider"),d(g4,this.suggest.anchor,"invalid suggest, no anchor"),Qx(this.editor,o,this.suggest.anchor))});this.editor=t,this.options=e,this.items=[],this.maxHeading=Zu(),this.suggest=new uu(t,{id:e.id||"quick-menu",trigger:e.trigger,needSpaceBeforeTrigger:!0,autoDeleteTrigger:!0,highlight:!0,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems})}get menu(){return this.suggest.menu.menu}destroy(){this.suggest.destroy()}initMenuItems(){const t=Ku(this.editor);this.items=t}refreshMenuItems(){let t=null,e=0;const o=i=>{const{id:s}=i;return s.startsWith("heading-")},r=Zu();if(r!==this.maxHeading){const i=wx().insertBlockCommandItems;for(let s=0;s<this.items.length;s++){const l=this.items[s];o(l)&&(t||(t=s),e++)}t&&e&&this.items.splice(t,e,...i),this.maxHeading=r}}}class Ju{constructor(t){h(this,"instance");h(this,"mousedown",!1);h(this,"currentInstance",null);h(this,"attributeName","");h(this,"attributeDesc","");h(this,"createContent",t=>{var i;const e=(i=t.getAttribute(this.attributeName))!=null?i:"",o=t.getAttribute(this.attributeDesc);if(!o)return e;const r=b("div",[],null);return b("span",[],r,e),o&&b("span",["editor-tooltip-desc"],r,o),r});h(this,"handleDocumentMouseDown",()=>{this.mousedown=!0,this.editor.domEvents.addEventListener(document,"mouseup",this.handleDocumentMouseUp)});h(this,"handleDocumentMouseUp",()=>{this.mousedown=!1,this.editor.domEvents.removeEventListener(document,"mouseup",this.handleDocumentMouseUp)});h(this,"handleShown",t=>{this.currentInstance=t});h(this,"handleHidden",()=>{this.currentInstance=null});h(this,"handleShow",t=>{var r;const e=t.reference;if(!e||!vt(document.body,e)||window.isDragging||this.mousedown)return!1;const o=Number.parseInt((r=e.getAttribute("data-tooltip-hide-at"))!=null?r:"",10);return!(o&&Date.now()-o<1e3)});this.editor=t;const e=t.clientId;this.attributeName=`data-editor-tooltip-${e}`,this.attributeDesc=`data-editor-tooltip-desc-${e}`,this.instance=Rf.delegate(document.body,{delay:300,target:`[${this.attributeName}]`,content:this.createContent,onShow:this.handleShow,onShown:this.handleShown,onHidden:this.handleHidden}),t.domEvents.addEventListener(document,"mousedown",this.handleDocumentMouseDown)}visible(){var t;return(t=this.currentInstance)==null?void 0:t.state.isVisible}hide(){var t;(t=this.currentInstance)!=null&&t.state.isVisible&&this.currentInstance.hide()}destroy(){this.instance.destroy(),this.editor.domEvents.removeEventListener(document,"mousedown",this.handleDocumentMouseDown),this.editor.domEvents.removeEventListener(document,"mouseup",this.handleDocumentMouseUp)}}const Jx={"text/style-bold":"bold","text/style-italic":"italic","text/style-underline":"underline","text/style-line-through":"line-through","text/style-code":"code","text/style-subscript":"subscript","text/style-superscript":"superscript"};function Xx(n,t){const e=new Set(Object.keys(Jx)),o=t.filter(i=>e.has(i.id));return Cc(o)}function Rc(n,t){if(!n.isWritable())return!1;const e=n.selection.range,o=n.editorCommandProviders.getCommands(e),i=Xx(n,o).find(s=>s.id===`text/${t}`);return i?(n.editorCommandProviders.executeCommand(e,i,{}),Gr.get(n).update(),!0):!1}const Xu={"CtrlOrCmd+B":n=>Rc(n,"style-bold"),"CtrlOrCmd+I":n=>Rc(n,"style-italic"),"CtrlOrCmd+U":n=>Rc(n,"style-underline"),"CtrlOrCmd+D":n=>Rc(n,"style-line-through")},tS={quickMenu:{basic:{heading:{title:"\u6807\u9898 {heading}",space:"{markdown}\u7A7A\u683C"},unordered:"\u65E0\u5E8F\u5217\u8868",ordered:"\u6709\u5E8F\u5217\u8868",checkbox:"\u5F85\u529E\u4E8B\u9879",quote:"\u5F15\u7528"},inlineBox:{math:"\u516C\u5F0F",link:"\u94FE\u63A5"}},link:{textLabel:"\u6587\u672C",urlLabel:"\u94FE\u63A5\u5730\u5740",textPlaceholder:"\u8BF7\u8F93\u5165\u6587\u672C",urlPlaceholder:"\u8BF7\u8F93\u5165\u94FE\u63A5\u5730\u5740",submitText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88"},commands:{unordered:"\u65E0\u5E8F\u5217\u8868",ordered:"\u6709\u5E8F\u5217\u8868",check:"\u5F85\u529E\u5217\u8868",link:"\u94FE\u63A5",quote:"\u5F15\u7528",alignLeft:"\u5DE6\u5BF9\u9F50",alignRight:"\u53F3\u5BF9\u9F50",alignCenter:"\u5C45\u4E2D\u5BF9\u9F50",heading:"\u6807\u9898 {name}",text:"\u6B63\u6587"},commandDesc:{mac:{unordered:"\u2318+\u21E7+L",ordered:"\u2318+\u21E7+U",link:"\u2318+K"},window:{unordered:"Ctrl+Shift+L",ordered:"Ctrl+Shift+U",link:"Ctrl+K"}}},eS={quickMenu:{basic:{heading:{title:"Heading {heading}",space:"{markdown}space"},unordered:"Bulleted list",ordered:"Numbered list",checkbox:"Todo list",quote:"Quote"},inlineBox:{math:"Math",link:"Link"},link:{textLabel:"Text",urlLabel:"Link Address",textPlaceholder:"Please enter text",urlPlaceholder:"Please enter the link address",submitText:"Ok",cancelText:"Cancel"}},commands:{unordered:"Bulleted list",ordered:"Numberer list",check:"Todo list",link:"Link",quote:"Quote",alignLeft:"Align left",alignRight:"Align right",alignCenter:"Align center",heading:"Heading {name}",text:"Text"},commandDesc:{mac:{unordered:"\u2318+\u21E7+L",ordered:"\u2318+\u21E7+U",link:"\u2318+K"},window:{unordered:"Ctrl+Shift+L",ordered:"Ctrl+Shift+U",link:"Ctrl+K"}}};S.mergeLang({"zh-CN":tS,"en-US":eS});const xF="";function Xo(n,...t){const e=kn(...t);return e.classList.remove("editor-button"),e.classList.add("editor-text-button"),n.append(e),e}function p4(n){bc(n).hide();const e=n.getCustom("table-border-bar");e==null||e.closeToolbar()}function nS(n){return b("div",["insert-column-button","drop-marker"],n)}const C4=y("row-height");function b4(n){const t=nt.fromTable(n),e=n.rows;d(C4,e.length===t.rowCount,"row count mismatch");const o=Array(t.rowCount).fill(0);for(let r=0;r<e.length;){let i=1,l=e[r].getBoundingClientRect().height,c=r+1;for(;c<e.length;){const a=e[c];if(a.cells.length!==0)break;i++,c++,l+=a.getBoundingClientRect().height}for(let a=0;a<i;a++)o[r+a]=l/i;r=c}return C4.debug("heights",o.join(", ")),o}const po=y("table-border-bar-dom");function ps(n,t){d(po,Ht(t),"invalid table block");const e=$t(t),o=wn(n,t),r=(a,u,f)=>{const m=b("div",["button-root",u],a),C=b("div",["button-container",u],m);m.setAttribute(`data-${u}-index`,`${f}`),b("span",["insert-indicator"],C),nS(C)},{selectedRows:i,selectedColumns:s}=mu(n,t),l=()=>{const a=o.querySelector(".table-border-bar-container.top");d(po,a,"no top border bar container");const u=b("div",["table-border-bar-container","top"],null),f=b("div",["table-border-bar","top"],u),m=bE(e);b("span",["table-border-bar-cell","corner"],f);const v=nt.fromTable(e).colCount;n.selection.range.isSimple()&&r(f,"top",0);for(let w=0;w<v;w++){const E=w===v-1?m[w]+2:m[w],L=b("span",["table-border-bar-cell","top"],f);s.has(w)&&L.classList.add("selected"),L.setAttribute("data-top-index",`${w}`),L.style.width=`${E}px`,n.selection.range.isSimple()&&r(f,"top",w+1)}xi(a,u)},c=()=>{const a=o.querySelector(".table-border-bar-container.left");d(po,a,"no left border bar container");const u=b("div",["table-border-bar-container","left"],null),f=b("div",["table-border-bar","left"],u),m=b4(e);n.selection.range.isSimple()&&r(f,"left",0),Array.from(e.rows).forEach((C,v,w)=>{const E=b("span",["table-border-bar-cell","left"],f);i.has(v)&&E.classList.add("selected"),E.setAttribute("data-left-index",`${v}`);const L=v===w.length-1?m[v]+2:m[v];E.style.height=`${L}px`,n.selection.range.isSimple()&&r(f,"left",v+1)}),xi(a,u)};l(),c()}function v4(n,t){const e=t.target;if(!(e instanceof Element))return;const o=z(e);d(po,o&&Ht(o),"invalid table block"),ps(n,o),n.selection.caret.update()}function th(n,t){const e=t.target;if(!(e instanceof Element))return;const o=z(e);d(po,o&&Ht(o),"invalid table block");const r=e.closest(".button-root");if(r){if(r.classList.contains("top")){const s=parseInt(r.getAttribute("data-top-index")||"0",10);Hp(n,o,s),ps(n,o)}else if(r.classList.contains("left")){const s=parseInt(r.getAttribute("data-left-index")||"0",10);jp(n,o,s),ps(n,o)}return}const i=e.closest(".table-border-bar-cell");if(i){if(i.classList.contains("top")){const s=parseInt(i.getAttribute("data-top-index")||"0",10);RE(n,o,s,1,{reverse:!0})}else if(i.classList.contains("left")){const s=parseInt(i.getAttribute("data-left-index")||"0",10);AE(n,o,s,1,{reverse:!0})}}}function eh(n,t){p4(n),t.preventDefault(),t.stopPropagation()}function oS(n,t){d(po,Ht(t),"invalid table block");const e=wn(n,t),o=b("div",["table-border-bar-container","top"],e),r=b("div",["table-border-bar-container","left"],e);ps(n,t),n.domEvents.addEventListener(rt(t),"scroll",v4),n.domEvents.addEventListener(o,"click",th),n.domEvents.addEventListener(r,"click",th),n.domEvents.addEventListener(o,"mousedown",eh),n.domEvents.addEventListener(r,"mousedown",eh)}function k4(n,t){if(!n.isWritable())return;if(wn(n,t).querySelector(".table-border-bar-container")){ps(n,t);return}oS(n,t)}function y4(n,t){d(po,Ht(t),"invalid table block"),wn(n,t).querySelectorAll(".table-border-bar-container").forEach(r=>{n.domEvents.removeEventListener(r,"click",th),n.domEvents.removeEventListener(r,"mousedown",eh),r.remove()}),n.domEvents.removeEventListener(rt(t),"scroll",v4)}function rS(n,t){d(po,Ht(t),"invalid table block");const o=wn(n,t).querySelector(".table-border-bar-container.top");return o?o.getBoundingClientRect().height:0}class iS{constructor(t,e){h(this,"toolbar");h(this,"handleSelectionChange",(t,e)=>{e==="delete-columns"?(zr(this.editor,this.tableBlock,!0,!0),Ur(this.editor,this.tableBlock,!0,!0)):e==="delete-rows"?(zr(this.editor,this.tableBlock,!0,!1),Ur(this.editor,this.tableBlock,!0,!1)):(zr(this.editor,this.tableBlock,!1),Ur(this.editor,this.tableBlock,!1))});h(this,"handleClick",(t,e,o)=>{e.id==="delete-columns"?gu(this.editor.selection.range):e.id==="delete-rows"&&pu(this.editor.selection.range)});this.editor=t,this.tableBlock=e,this.toolbar=new os([]),this.toolbar.addListener("selectionChange",this.handleSelectionChange),this.toolbar.addListener("click",this.handleClick)}close(){this.toolbar.close()}update(){const{selectedColumns:t,selectedRows:e}=mu(this.editor,this.tableBlock);if(!this.editor.isWritable())return;if(t.size>0&&e.size>0){this.toolbar.close();return}if(t.size===0&&e.size===0){this.toolbar.close();return}const o=Ao(this.editor,this.tableBlock,this.editor.selection.range)[0];if(!o){this.toolbar.close();return}if(t.size>0){const r={id:"delete-columns",name:"Delete columns",icon:Yd};this.toolbar.updateItems([r]);const i=_o(this.editor,this.tableBlock,"editor-quick-menu",o);this.toolbar.manualShow(i,{placement:"top"})}else{const r={id:"delete-rows",name:"Delete rows",icon:Yd};this.toolbar.updateItems([r]);const i=new DOMRect(o.left-15,o.top,o.width,o.height),s=_o(this.editor,this.tableBlock,"editor-quick-menu",i);this.toolbar.manualShow(s,{placement:"left"})}}destroy(){this.toolbar.destroy(),this.toolbar.removeAllListeners()}}const Ac=y("table-border-bar");class sS{constructor(t,e){h(this,"toolbar");h(this,"resizeObserver");h(this,"handleReadonlyChanged",t=>{t.isWritable()?this.update():y4(this.editor,this.tableBlock)});h(this,"handleBlockUpdated",()=>{this.resizeObserver.disconnect(),setTimeout(()=>{const t=this.editor.getBlockById(G(this.tableBlock));this.resizeObserver.observe($t(t))})});h(this,"handleTableResize",()=>{!this.editor.isWritable()||(console.log("resize"),this.update())});this.editor=t,this.tableBlock=e,d(Ac,this.tableBlock,"no table block"),Ac.debug("create table border bar"),k4(this.editor,this.tableBlock),this.resizeObserver=new ResizeObserver(this.handleTableResize),this.resizeObserver.observe($t(this.tableBlock)),this.toolbar=new iS(this.editor,this.tableBlock),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}close(){this.toolbar.close()}destroy(){Ac.debug("destroy table border bar"),this.resizeObserver.disconnect(),y4(this.editor,this.tableBlock),this.toolbar.destroy(),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged)}update(){Ac.debug("update table border bar"),k4(this.editor,this.tableBlock),this.toolbar.update()}}const lS=y("table-border-bar");class cS{constructor(t){h(this,"activeTableBar",null);h(this,"handleBlockDeleted",(t,e)=>{!this.activeTableBar||(e===this.activeTableBar.tableBlock||vt(e,this.activeTableBar.tableBlock))&&(this.activeTableBar.destroy(),this.activeTableBar=null)});h(this,"handleSelectionChanged",t=>{var r;const e=t.selection.range;let o=null;if(e.isCollapsed()&&e.isSimple()){const i=t.getBlockById(e.start.blockId);if(Ht(i)){const s=H(i),l=z(s);l&&(o=we(l))}else o=we(i)}else{const i=t.getBlockById(e.start.blockId),s=we(i),l=t.getBlockById(e.end.blockId),c=we(l);s===c&&(o=s)}((r=this.activeTableBar)==null?void 0:r.tableBlock)!==o&&this.activeTableBar&&this.hide(),o&&this.show(o)});this.editor=t,this.editor.addListener("blockDeleted",this.handleBlockDeleted),this.editor.addListener("selectionChanged",this.handleSelectionChanged)}destroy(){this.editor.removeListener("blockDeleted",this.handleBlockDeleted),this.editor.removeListener("selectionChanged",this.handleSelectionChanged)}show(t){this.activeTableBar?(this.activeTableBar.tableBlock!==t&&this.hide(),this.activeTableBar.update()):this.activeTableBar=new sS(this.editor,t)}update(){var t;(t=this.activeTableBar)==null||t.handleBlockUpdated()}closeToolbar(){var t;(t=this.activeTableBar)==null||t.close()}hide(){!this.activeTableBar||(d(lS,this.activeTableBar,"no active table bar"),this.activeTableBar.destroy(),this.activeTableBar=null)}}function w4(n,t){const e=n.addCustom("table-border-bar",o=>new cS(o));t==="update"&&e.update()}const Ce=y("table-cell-menu"),aS="style-bg-color-";class dS{constructor(t){h(this,"activeTableBlock",null);h(this,"targetButton",null);h(this,"manualMenu",null);h(this,"colorPaletteItem",null);h(this,"handlePrevent",(t,e)=>{e.stopPropagation()});h(this,"handleReadonlyChanged",t=>{t.isWritable()||this.hide()});h(this,"handleSelectionChanged",t=>{const e=t.selection.range;let o=null;if(e.isCollapsed()&&e.isSimple()){const r=t.getBlockById(e.start.blockId);if(Ht(r)){const i=H(r),s=z(i);s&&(o=we(s))}else o=we(r)}else{const r=t.getBlockById(e.start.blockId),i=we(r),s=t.getBlockById(e.end.blockId),l=we(s);i===l&&(o=i)}if(this.hide(),this.activeTableBlock!==o&&(this.activeTableBlock=o),this.activeTableBlock){const r=nt.fromBlock(this.activeTableBlock),{end:i}=e;let s=null;e.isCollapsed()?s=this.getCellByChildBlockId(r,i.blockId):i instanceof Ze&&(t.getBlockById(i.blockId)===this.activeTableBlock?s=r.getCellByContainerId(i.childContainerId):s=this.getCellByChildBlockId(r,i.blockId)),s&&this.editor.isWritable()&&this.showCellMenuButton(s)}});h(this,"handleBeforePopupPalette",()=>{var e;const t=this.getSelectedBkgColorIndex();(e=this.colorPaletteItem)==null||e.palette.setColor("backgroundColor",t)});h(this,"createBkgColorItem",()=>{const t=b("div",["cell-background-color-item"],null);b("span",[],t,S.t("table.cellBackground"));const e=this.getSelectedBkgColorIndex();b("button",["item-button"],t).setAttribute("data-color-index",`${e}`);const r=b("span",["item-sub-indicator"],t);return r.innerHTML=Zd,t});h(this,"handleCommand",t=>{var r;d(Ce,this.activeTableBlock,"no target table block");const e=((r=t.states)==null?void 0:r.includes("checked"))||!1,o=t.value;switch(t.id){case"delete-select-row":pu(yp(this.editor,this.activeTableBlock,!1));break;case"delete-select-col":gu(yp(this.editor,this.activeTableBlock,!0));break;case"merge-cell":bp(this.editor.selection.range);break;case"split-cell":this.handleSplitCell();break;case"row-title":this.handleRowTitle(e);break;case"col-title":this.handleColTitle(e);break;case"stripe-style":this.handleStripeStyle(e);break;case"hide-border":zB(this.editor,this.activeTableBlock,o==="show-border");break;case"show-chart":GB(this.editor,this.activeTableBlock,o==="show-chart"),xu(this.editor,this.activeTableBlock,{updateNow:!0});break}});h(this,"handleSelectionChange",(t,e)=>{d(Ce,this.activeTableBlock,"no target table block"),e==="cell-background-color"&&this.handleBeforePopupPalette(),e==="delete-select-row"?(zr(this.editor,this.activeTableBlock,!0,!1),Ur(this.editor,this.activeTableBlock,!0,!1)):e==="delete-select-col"?(zr(this.editor,this.activeTableBlock,!0,!0),Ur(this.editor,this.activeTableBlock,!0,!0)):(zr(this.editor,this.activeTableBlock,!1),Ur(this.editor,this.activeTableBlock,!1))});h(this,"handleClick",()=>{var t;d(Ce,this.activeTableBlock,"no target table block"),d(Ce,this.targetButton,"no target button"),p4(this.editor),lt(this.targetButton,"active")?(F(this.targetButton,"active"),(t=this.manualMenu)==null||t.close()):(M(this.targetButton,"active"),this.manualMenu?this.manualMenu.updateItems(this.createCommandMenu()):(this.manualMenu=new Wo(this.createCommandMenu()),this.manualMenu.on("click",(e,o)=>{var r;this.handleCommand(o),(r=this.manualMenu)==null||r.close()}),this.manualMenu.on("selectionChange",this.handleSelectionChange),this.manualMenu.on("close",()=>{this.targetButton&&F(this.targetButton,"active")})),this.manualMenu.manualShow(this.targetButton,{placement:"right-start"}))});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChanged),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}destroy(){var t,e;this.activeTableBlock=null,this.targetButton=null,this.editor.removeListener("selectionChanged",this.handleSelectionChanged),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged),(t=this.manualMenu)==null||t.destroy(),(e=this.colorPaletteItem)==null||e.destroy()}hide(){var t;(t=this.manualMenu)==null||t.close(),this.targetButton&&(F(this.targetButton,"active"),this.targetButton.style.display="none")}getCellByChildBlockId(t,e){let o=this.editor.getBlockById(e);for(;o;){const r=o.closest("td");d(Ce,r,"no parent cell");const i=z(r);if(d(Ce,i,"no parent block"),$t(i)===t.table)return t.getCellByCellElement(r);o=i}return d(Ce,!1,"filed to get cell by child block id"),null}createTargetButton(t){this.targetButton?t.querySelector(":scope > .table-cell-menu-btn")||t.appendChild(this.targetButton):(this.targetButton=b("button",["table-cell-menu-btn"],t),this.targetButton.innerHTML=oc,this.editor.domEvents.addEventListener(this.targetButton,"click",this.handleClick),this.editor.domEvents.addEventListener(this.targetButton,"mousedown",this.handlePrevent))}showCellMenuButton(t){this.createTargetButton(t.cell),d(Ce,this.targetButton,"no target button"),this.targetButton.style.display="inline-block"}handleSplitCell(){if(this.activeTableBlock){const t=nt.fromBlock(this.activeTableBlock),e=this.editor.selection.range;if(e.isSimple()){const{col:o,row:r}=this.getCellByChildBlockId(t,e.start.blockId);bu(this.editor,this.activeTableBlock,{col:o,row:r})}else vu(this.editor.selection.range)}}getSelectedBkgColorIndex(){var r;d(Ce,this.activeTableBlock,"no target table block");const t=qB(this.editor,this.activeTableBlock),e=this.editor.getBlockData(this.activeTableBlock),o=new Set;for(const i of t){if(o.size>1)break;const s=U(i),l=e[`${s}_background`];if(l)o.add(Number.parseInt((r=l.substring(aS.length))!=null?r:"0",10));else{o.add(-1);break}}return o.size===1&&[...o][0]!==-1?[...o][0]:-1}createCommandMenu(){d(Ce,this.activeTableBlock,"no target table block");const t=this.editor.getBlockData(this.activeTableBlock),e=Cp(this.editor,this.activeTableBlock,this.editor.selection.range);let o=this.editor.selection.range;if(o.isSimple()){const u=Vn(this.editor,this.activeTableBlock,o.start);o=Vt(this.editor,{anchor:u,focus:u})}const r=pp(this.editor,this.activeTableBlock,o),i=t.hasRowTitle,s=t.hasColTitle,l=t.isStripeStyle,c=t.noBorder,a=t.chart;return this.colorPaletteItem=new cu("cell-background-color",{color:!1}),this.colorPaletteItem.palette.on("onClick",(u,f)=>{var m;switch(d(Ce,this.activeTableBlock,"no target table block"),u){case"clearColor":Ep(this.editor,this.activeTableBlock,-1);break;case"backgroundColor":Ep(this.editor,this.activeTableBlock,f);break}(m=this.manualMenu)==null||m.close()}),[{id:"cell-background-color",name:S.t("table.cellBackground"),element:this.createBkgColorItem(),children:[this.colorPaletteItem]},{id:"separator",name:"",type:"separator"},{id:"merge-cell",name:S.t("table.mergeCell"),states:e?[]:["disabled"]},{id:"split-cell",name:S.t("table.splitCell"),states:r?[]:["disabled"]},{id:"separator",name:"",type:"separator"},{id:"delete-select-row",name:S.t("table.deleteSelectRow")},{id:"delete-select-col",name:S.t("table.deleteSelectCol")},{id:"separator",name:"",type:"separator"},{id:"table-config",name:S.t("table.tableConfigKey"),children:[{id:"row-title",name:S.t("table.tableConfig.rowTitle"),states:i?["checked"]:[]},{id:"col-title",name:S.t("table.tableConfig.colTitle"),states:s?["checked"]:[]},{id:"stripe-style",name:S.t("table.tableConfig.stripeStyle"),states:l?["checked"]:[]},{id:"hide-border",name:c?S.t("table.tableConfig.showBorder"):S.t("table.tableConfig.hideBorder"),value:c?"show-border":"hide-border"},{id:"show-chart",name:a?S.t("table.tableConfig.hideChart"):S.t("table.tableConfig.showChart"),value:a?"hide-chart":"show-chart"}]}]}handleRowTitle(t){d(Ce,this.activeTableBlock,"no target table block"),t?HB(this.editor,this.activeTableBlock):$B(this.editor,this.activeTableBlock)}handleColTitle(t){d(Ce,this.activeTableBlock,"no target table block"),t?PB(this.editor,this.activeTableBlock):NB(this.editor,this.activeTableBlock)}handleStripeStyle(t){d(Ce,this.activeTableBlock,"no target table block"),t?FB(this.editor,this.activeTableBlock):jB(this.editor,this.activeTableBlock)}}function B4(n){n.addCustom("table-cell-menu",t=>new dS(t))}const Oc=y("table-container");function nh(n){const t=n.closest("td");return d(Oc,t,"no parent cell for a table cell container"),t}function E4(n){const t=$t(n);return Array.from(t.querySelectorAll(':scope > tbody > tr > td > [data-type="editor-container"].child'))}function oh(n,t,e,o){const r=nt.fromBlock(n),i=r.getCellByContainerId(U(t));if(e==="ArrowDown"){const s=r.getBottomCell(i);return s?s.container:null}if(e==="ArrowUp"){const s=r.getTopCell(i);return s?s.container:null}if(e==="ArrowLeft"){const s=r.getAllContainers(),l=s.indexOf(t);if(d(Oc,l>=0,"not a valid child container"),l===0)return null;const c=s[l-1];return o!=null&&o.noWrap&&r.getCellByContainerId(U(c)).row!==i.row?null:c}if(e==="ArrowRight"){const s=r.getAllContainers(),l=s.indexOf(t);if(d(Oc,l>=0,"not a valid child container"),l===s.length-1)return null;const c=s[l+1];return o!=null&&o.noWrap&&r.getCellByContainerId(U(c)).row!==i.row?null:c}d(Oc,!1,`invalid navigation type: ${e}`)}const uS=12,hS=90,_c=23,I4=2;class fS{constructor(t){h(this,"scrollTableBlock",null);h(this,"autoScrollDir",null);h(this,"autoScrollTimer",null);h(this,"handleMouseDown",t=>{const e=document.elementFromPoint(t.clientX,t.clientY);if(e&&e instanceof HTMLElement){const o=z(e);if(o&&vt(this.editor.rootContainer,o)){const r=we(o);r&&(this.scrollTableBlock=r,document.addEventListener("mousemove",this.handleAutoScroll))}}});h(this,"handleAutoScroll",h8.default(t=>{if(this.scrollTableBlock){const e=this.editor.getCustom(fo(this.scrollTableBlock)),o=e.rootElement,r=e.scrollOptions.parentContainer,i=o.getBoundingClientRect(),s=window.innerHeight-(e.scrollOptions.barFloatWindowBottom||0),l=r.getBoundingClientRect(),c=Math.min(l.bottom,s),a=Math.max(l.top,0);i.bottom>c&&t.clientY>=c?this.setAutoScroll("bottom"):i.top<a&&t.clientY<=a?this.setAutoScroll("top"):o.scrollLeft>0&&t.clientX<i.left?this.setAutoScroll("left"):o.scrollLeft<o.scrollWidth-o.offsetWidth&&t.clientX>i.right?this.setAutoScroll("right"):this.clearAutoScroll()}},15));h(this,"handleMouseUp",()=>{document.removeEventListener("mousemove",this.handleAutoScroll),setTimeout(()=>{this.scrollTableBlock=null})});h(this,"handleSelectionChanged",t=>{const e=t.selection.range;if(e.isCollapsed()&&e.isSimple()){const o=t.getBlockById(e.start.blockId),r=we(o);if(r){const i=t.getCustom(fo(r)),s=i.rootElement.getBoundingClientRect(),l=Ge(t,o,e.start);if(s.left>l.left){const c=e.start.offset===0?uS:I4;i.rootElement.scrollLeft-=s.left-l.left+c}else if(l.right>s.right){const c=e.start.offset===0?hS:I4;i.rootElement.scrollLeft+=l.right-s.right+c}}}else{const o=t.getBlockById(e.start.blockId),r=we(o),i=t.getBlockById(e.end.blockId),s=we(i);if(r&&r===s){const l=t.getCustom(fo(r)),c=l.rootElement.getBoundingClientRect();let a=null;if(e.isSimple())a=e.isReverse()?Ge(t,o,e.start):Ge(t,i,e.end);else{const u=nh(br(t,e.start.childContainerId)),f=nh(br(t,e.end.childContainerId));a=e.isReverse()?u.getBoundingClientRect():f.getBoundingClientRect()}c.left>a.left&&e.isReverse()?l.rootElement.scrollLeft-=c.left-a.left:c.right<a.right&&!e.isReverse()&&(l.rootElement.scrollLeft+=a.right-c.right)}}});h(this,"handleScroll",t=>{IB(t),this.editor.selection.caret.update()});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChanged),document.addEventListener("mousedown",this.handleMouseDown),document.addEventListener("mouseup",this.handleMouseUp)}clearAutoScroll(){this.autoScrollTimer&&(clearInterval(this.autoScrollTimer),this.autoScrollTimer=null,this.autoScrollDir=null)}setAutoScroll(t){this.autoScrollDir&&this.autoScrollDir!==t&&this.clearAutoScroll(),this.autoScrollTimer||(this.autoScrollDir=t,this.autoScrollTimer=window.setInterval(()=>{if(this.scrollTableBlock){const e=this.editor.getCustom(fo(this.scrollTableBlock)),o=e.rootElement,r=e.scrollOptions.parentContainer,i=o.getBoundingClientRect(),s=r===document.documentElement?window.innerHeight:r.offsetHeight,l=window.innerHeight-(e.scrollOptions.barFloatWindowBottom||0),c=r.getBoundingClientRect(),a=Math.min(c.bottom,l),u=Math.max(c.top,0);this.autoScrollDir==="left"&&(o.scrollLeft-=_c,o.scrollLeft<=0&&this.clearAutoScroll()),this.autoScrollDir==="right"&&(o.scrollLeft+=_c,o.scrollLeft>=o.scrollWidth-o.offsetWidth&&this.clearAutoScroll()),this.autoScrollDir==="bottom"&&(r.scrollTop+=_c,(r.scrollTop>=r.scrollHeight-s||i.bottom<=a)&&this.clearAutoScroll()),this.autoScrollDir==="top"&&(r.scrollTop-=_c,(r.scrollTop<=0||i.top>=u)&&this.clearAutoScroll())}},100))}destroy(){document.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mouseup",this.handleMouseUp),this.editor.removeListener("selectionChanged",this.handleSelectionChanged)}}function x4(n){return n.addCustom("table-scroll-events",t=>new fS(t))}const Bn=y("create-content");function S4(n,t,e){const o=new fu(e),r=e.rows,i=e.cols;d(Bn,r>=1,`invalid rows: ${r}`),d(Bn,i>=1,`invalid cols: ${i}`),d(Bn,e.children,"no table children");const s=b("table",[],null),l=e.colsWidth,c=b("colgroup",[],s);for(let f=0;f<o.colCount;f++){const m=b("col",[],c);m.style.width=`${l[f]}px`}const a=b("tbody",[],s);let u=0;for(let f=0;f<r;f++){const m=b("tr",[],a);for(let C=0;C<i;C++){const v=o.getCell({col:C,row:f});if(v.virtual)d(Bn,v.colSpan>1||v.rowSpan>1,"virtual cell should have colSpan or rowSpan");else{const w=e.children[u],E=b("td",[],m);v.colSpan>1&&(E.colSpan=v.colSpan),v.rowSpan>1&&(E.rowSpan=v.rowSpan);const L=e[cs(w)];L&&M(E,L),C===0&&e.hasColTitle&&M(E,vp.COL_TITLE_ITEM),n.createChildContainer(t,E,w),u+=1}}}return d(Bn,u===e.children.length,"container count mismatch"),e.noBorder&&M(s,"no-border"),e.chart&&M(s,"editor-table-chart"),e.isStripeStyle&&M(s,"stripe"),e.hasRowTitle&&M(s,"row-title"),e.hasColTitle&&M(s,"col-title"),s}function mS(n,t,e,o,r){d(Bn,r.type==="table","not table data"),d(Bn,U(e)===t[t.length-1].containerId,"invalid path");const i=r,s=eo(o,"div");try{const l=b("div",[],s);l.setAttribute("data-type","table-content");const c=S4(n,t,i);c.classList.add("drag-preview-element"),l.appendChild(c),Pp(n),zp(n),w4(n,"create"),B4(n),Tw(n,Su);const a=n.getComponentOptions("table"),u=n.addCustom(fo(o),()=>pE({parentElement:s,childElement:l,safeRightSpace:40,safeLeftSpace:40,parentContainer:Ct(e)?n.scrollContainer:e,locatingContainer:Ct(e)?(a==null?void 0:a.locatingContainer)||n.parent:e,paddingLeft:wu+ls,paddingTop:wu+ls,paddingBottom:ls/2,paddingRight:ls/2})),f=x4(n);u.on("scroll",f.handleScroll),setTimeout(()=>{QB(n,o)})}catch{const c=`invalid table data: ${JSON.stringify(i)}`;Bn.error(c);const a=b("div",["error"],s);a.innerText=c}return s}function gS(n,t,e){d(Bn,e.type==="table","not table data");const o=e,r=rt(t);try{const i=$t(t),s=Ro(t),l=S4(n,s,o);l.classList.add("drag-preview-element"),i.insertAdjacentElement("afterend",l),i.remove(),Pp(n),zp(n),w4(n,"update"),B4(n),Su(n,t)}catch{const s=`invalid table data: ${JSON.stringify(o)}`;Bn.error(s);const l=b("div",["error"],r);l.innerText=s}}function pS(n,t){const o=Ya(t,"|").split("|");if(o.length<2)return null;const i=3,s=o.length,l=[];for(let m=0;m<3;m++)o.forEach(C=>{l.push(pn(n.doc,m===0?C:""))});const c=Array(s).fill(Lu),a=l[s],u=n.doc.getContainerBlocks(a)[0].id;return{blockData:{id:N(),type:"table",rows:i,cols:s,children:l,colsWidth:c},focusBlockId:u}}function CS(n,t){const e=t.rows,o=t.cols;if(e<1||o<1)return null;const r=[];for(let a=0;a<e;a++)for(let u=0;u<o;u++)r.push(pn(n.doc));const i=Array(o).fill(Lu),s=r[0],l=n.doc.getContainerBlocks(s)[0].id;return{blockData:{id:N(),type:"table",rows:e,cols:o,children:r,colsWidth:i},focusBlockId:l}}const rh=y("table-selection-to-doc");function T4(n,t){const{start:e,end:o,block:r}=t,i=it(r);d(rh,i==="table",`invalid block type: ${i}`);const s=n.getBlockData(r);if(e.isSimple()&&o.isSimple()){const V=s.children;d(rh,V,"no table children");const tt=V[0],ot=V[V.length-1],ut=bt(r,tt),dt=bt(r,ot);return T4(n,{block:t.block,start:ut,end:dt})}d(rh,!e.isSimple()&&!o.isSimple(),"invalid block pos type");const l=nt.fromBlock(r),{fromCol:c,toCol:a,fromRow:u,toRow:f}=rn(r,e,o),m={},C=[],v=n.doc.toJSON();let w={};l.sub({row:u,col:c},{row:f,col:a}).forEach((V,tt)=>{V.forEach((ot,ut)=>{const dt=ot.containerId;if(C.indexOf(dt)!==-1)return;C.push(dt);let yt;if(ot.virtual){const Xt=l.getCellByContainerId(ot.containerId),Fe=c+ut;let vo=Xt.col+Xt.colSpan-1;vo>a&&(vo=a);const ar=vo-Fe+1;ar>1&&(m[`${dt}_colSpan`]=ar);const dr=u+tt;let ko=Xt.row+Xt.rowSpan-1;ko>f&&(ko=f);const ma=ko-dr+1;ma>1&&(m[`${dt}_rowSpan`]=ma),yt=oo()}else{if(yt=K1(n.editorBlocks,v,dt),ot.col+ot.colSpan>a+1){const Xt=a-ot.col+1;Xt>1&&(m[`${dt}_colSpan`]=Xt)}else ot.colSpan>1&&(m[`${dt}_colSpan`]=ot.colSpan);if(ot.row+ot.rowSpan>f+1){const Xt=f-ot.row+1;Xt>1&&(m[`${dt}_rowSpan`]=Xt)}else ot.rowSpan>1&&(m[`${dt}_rowSpan`]=ot.rowSpan)}const{root:oe,...Jn}=yt.blocks;w={...w,...Jn,[dt]:oe}})});const L=hs($t(r)).slice(c,a+1);return{blocks:{root:[{id:N(),type:i,children:C,colsWidth:L,rows:f-u+1,cols:a-c+1,...m}],...w},meta:{},comments:{}}}function bS(n,t){if(t.top===0)return!0;for(let e=t.left;e<=t.right;e++)if(n[t.top-1][e]===n[t.top][e])return!1;return!0}function vS(n,t){if(t.left===0)return!0;for(let e=t.top;e<=t.bottom;e++)if(n[e][t.left-1]===n[e][t.left])return!1;return!0}function kS(n,t){if(t.bottom===n.length-1)return!0;for(let e=t.left;e<=t.right;e++)if(n[t.bottom][e]===n[t.bottom+1][e])return!1;return!0}function yS(n,t){if(t.right===n[0].length-1)return!0;for(let e=t.top;e<=t.bottom;e++)if(n[e][t.right]===n[e][t.right+1])return!1;return!0}function wS(n,t,e){const o=t.col,r=t.row,i=e.col,s=e.row,l={left:o,top:r,right:i,bottom:s};let c=!1;do{if(c=!1,!bS(n,l)){l.top--,c=!0;continue}if(!vS(n,l)){l.left--,c=!0;continue}if(!kS(n,l)){l.bottom++,c=!0;continue}if(!yS(n,l)){l.right++,c=!0;continue}}while(c);return l}function BS(n,t,e,o){if(e.custom!==void 0||o.custom!==void 0)return{anchor:e,focus:o};const r=nt.fromBlock(t),i=r.map(A=>A.containerId),s=r.getCellByContainerId(e.childContainerId),l=r.getCellByContainerId(o.childContainerId),c=Math.min(s.row,l.row),a=Math.max(s.row,l.row),u=Math.min(s.col,l.col),f=Math.max(s.col,l.col),m=wS(i,{row:c,col:u},{row:a,col:f}),C=r.getCell({row:m.top,col:m.left}),v=r.getCell({row:m.bottom,col:m.right}),w=r.getCell({row:m.top,col:m.right}),E=r.getCell({row:m.bottom,col:m.left});let L,x;return s.row<=l.row?s.col<=l.col?(L=C,x=v):(L=w,x=E):s.col<l.col?(L=E,x=w):(L=v,x=C),console.log(`move ${L.col}, ${L.row}, -> ${x.col}, ${x.row}`),{anchor:bt(t,L.containerId),focus:bt(t,x.containerId)}}function D4(n,t,e){if(e.isSimple())return[$t(t).getBoundingClientRect()];const o=$t(t),r=o.getBoundingClientRect(),{fromCol:i,fromRow:s,toCol:l,toRow:c}=rn(t,e.start,e.end),a=hs(o),u=a.slice(0,i).reduce((w,E)=>w+E,0),f=u+a.slice(i,l+1).reduce((w,E)=>w+E,0),m=b4(o);let C=m.slice(0,s).reduce((w,E)=>w+E,0);const v=C+m.slice(s,c+1).reduce((w,E)=>w+E,0);if(s===0){const w=rS(n,t);C-=w}return[new DOMRect(r.left+u,r.top+C,f-u,v-C)]}y("table-size");const ES=40;function Nc(n){const t=n.querySelector("td");if(!t)return 0;const e=window.getComputedStyle(t),o=Number.parseInt(e.borderLeft,10),r=Number.parseInt(e.borderRight,10);return(o+r)/2}function IS(n,t,e){const o=m1(n,e.container);return o!==void 0?o+Nc(t):ES*e.colSpan-Nc(t)}function xS(n,t,e,o){let r=0;const i=e.colCount;for(let s=0;s<i;s++){const l=e.getRealCell({col:s,row:o});if(l.virtual)continue;let c=IS(n,t,l);const a=Qm(l.container,{withPadding:!0});a&&a>c&&(c=a),r+=c+Nc(t)}return r}function SS(n,t){const e=$t(t),o=nt.fromTable(e);let r=0;for(let s=0;s<o.rowCount;s++)r=Math.max(r,xS(n,e,o,s));const i=Nc(e);return r+=i,r}const Wn=y("table-creator");async function TS(n,t){return n.undoManager.runInGroup(()=>{var c,a;const e=t.item,o=(c=e.colCount)!=null?c:5,r=(a=e.rowCount)!=null?a:3,i=CS(n,{cols:o,rows:r});if(!i)return null;const{blockData:s,focusBlockId:l}=i;return n.insertBlock(t.containerId,t.blockIndex,s,Ot(n,l,0))})}class DS{constructor(){h(this,"id","insert-table");h(this,"name","Create table");h(this,"element");h(this,"closeable",null);h(this,"colCount");h(this,"rowCount");h(this,"setCloseable",t=>{this.closeable=t});h(this,"destroy",()=>{this.closeable=null});h(this,"getTableCreatorCellId",(t,e)=>`table-creator-cell-${t}-${e}`);h(this,"handleTableCreatorClick",t=>{var m,C;t.preventDefault(),t.stopPropagation();const e=t.target;d(Wn,e instanceof HTMLElement,"invalid event target");const o=e.closest(".table-creator");d(Wn,o,"no table creator");const r=o.querySelectorAll(".active");if(r.length===0)return;const s=r[r.length-1].id;d(Wn,s,"no cell id");const l="table-creator-cell-";if(!s.startsWith(l))return;const a=s.substring(l.length).split("-");d(Wn,a.length===2,"invalid cell id");const u=Number.parseInt(a[0],10)+1,f=Number.parseInt(a[1],10)+1;Wn.debug(`${u}, ${f}`),this.colCount=f,this.rowCount=u,(m=this.closeable)==null||m.click(this,this.element),(C=this.closeable)==null||C.close(),this.handleTableCreatorLeave()});h(this,"handleTableCreatorLeave",()=>{for(let t=0;t<9;t++)for(let e=0;e<9;e++){const o=this.getTableCreatorCellId(t,e),r=document.getElementById(o);r&&F(r,"active")}});h(this,"handleTableCreatorCellEnter",t=>{const e=t.target;d(Wn,e instanceof HTMLElement,"invalid event target");const o=e.id,r="table-creator-cell-";d(Wn,o.startsWith(r),"invalid cell id");const s=o.substring(r.length).split("-");d(Wn,s.length===2,"invalid cell id");let l=Number.parseInt(s[0],10),c=Number.parseInt(s[1],10);l===0&&c===0&&(l=-1,c=-1);for(let a=0;a<9;a++)for(let u=0;u<9;u++){const f=this.getTableCreatorCellId(a,u),m=document.getElementById(f);d(Wn,m,"no cell"),a<=l&&u<=c?M(m,"active"):F(m,"active")}});this.element=this.createTableCreatorElement()}createTableCreatorElement(){const t=b("div",["table-creator"],null),e=(o,r,i)=>{const s=b("div",["table-creator-cell"],o);return s.id=this.getTableCreatorCellId(r,i),s};t.addEventListener("click",this.handleTableCreatorClick),t.addEventListener("mouseleave",this.handleTableCreatorLeave);for(let o=0;o<9;o++){const r=b("div",["table-creator-row"],t);for(let i=0;i<9;i++)e(r,o,i).addEventListener("mouseenter",this.handleTableCreatorCellEnter)}return t}}function LS(n){return n.addCustom("table-creator-item",()=>new DS)}const Pc=y("table-block");function MS(n){return 1}function RS(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t))return null;if(r instanceof HTMLTableCellElement){const l=$t(t);if(hp(l).indexOf(r)!==-1){const a=is(r),u=bt(t,U(a));return new Ye(n,{anchor:u,focus:u})}}if(!fn(r))return null;const i=r;if(E4(t).indexOf(i)===-1)return null;const s=bt(t,U(i));return new Ye(n,{anchor:s,focus:s})}function AS(n,t,e,o){return null}function OS(n,t){return n.getBoundingClientRect()}function L4(n,t,e,o){if(e.isSimple()){d(Pc,o.isSimple(),"from is simple position but to is not simple position"),Pc.debug("full select table"),M(t,"full-selected");return}d(Pc,!o.isSimple(),"from is complex position but end is simple position");const r=Vn(n,t,e),i=Vn(n,t,o);d(Pc,r.blockId===i.blockId,"only allow update one table selection"),UB(n,r,i).forEach(l=>{const c=nh(l);M(c,"selected")})}function _S(n){n.rootContainer.querySelectorAll('[data-type="editor-block"][data-block-type="table"]').forEach(t=>{F(t,"full-selected"),t.querySelectorAll("td.selected").forEach(e=>{F(e,"selected")})})}function NS(n,t){return fp(t)?E4(t):[]}function PS(n,t,e,o,r){return oh(t,e,o,r)}function $S(n,t){return SS(n,t)}function HS(n,t){return j(n,t)?pS(n,n.getBlockString(t).trim()):null}function jS(n){return{name:"TableBlock",insertBlockCommandItems:[{id:"insert-table",name:S.t("table.title"),order:200,icon:M5,children:[LS(n)],group:"common"}],handleInsertEmptyBlock:TS}}function FS(n,t,e){return gS(n,t,e),setTimeout(()=>{const o=n.selection.range;o.isSimple()?n.selection.caret.update():L4(n,t,o.start,o.end)}),!0}function zS(n,t){let e=0;const{selectedColumns:o}=mu(n,t);if(o.size>0){const{fromCol:i,toCol:s}=rn(t,n.selection.range.start,n.selection.range.end),l=nt.fromBlock(t);(i!==0||s!==l.colCount-1)&&(e=60)}const r=D4(n,t,n.selection.range)[0];return new DOMRect(r.left,r.top+e,r.width,r.height-e)}function US(n,t){Dw(n,Su);const e=n.findCustom(fo(t));if(e){const o=x4(n);e.off("scroll",o.handleScroll),e.destroy()}}function VS(){return{abstract:`[${S.t("table.abstract")}]`}}const Cs={blockType:"table",blockKind:"complex",enableKeyboardSelect:!0,createBlockContent:mS,getBlockTextLength:MS,getRangeFromPoint:RS,moveCaret:AS,getCaretRect:OS,updateSelection:L4,clearSelection:_S,getChildContainers:NS,getNextContainer:PS,getMinWidth:$S,getSelectedContainers:Eu,convertFrom:HS,adjustSelectionPos:BS,getClientRects:D4,selectionToDoc:T4,getOptions:jS,getTextToolbarReferenceClient:zS,handleUpdateBlock:FS,handleDeleteBlock:US,getBlockProperties:VS},qS={table:{cellBackground:"\u5355\u5143\u683C\u80CC\u666F\u8272",deleteSelectRow:"\u5220\u9664\u6240\u9009\u884C",deleteSelectCol:"\u5220\u9664\u6240\u9009\u5217",mergeCell:"\u5408\u5E76\u5355\u5143\u683C",splitCell:"\u62C6\u5206\u5355\u5143\u683C",tableConfigKey:"\u8868\u683C\u8BBE\u7F6E",tableConfig:{rowTitle:"\u884C\u6807\u9898",colTitle:"\u5217\u6807\u9898",stripeStyle:"\u6761\u7EB9\u6837\u5F0F",hideBorder:"\u9690\u85CF\u8868\u683C\u7EBF",showBorder:"\u663E\u793A\u8868\u683C\u7EBF",showChart:"\u663E\u793A\u56FE\u8868",hideChart:"\u9690\u85CF\u56FE\u8868"},title:"\u8868\u683C",abstract:"\u8868\u683C"}},WS={table:{cellBackground:"Cell background",deleteSelectRow:"Delete rows",deleteSelectCol:"Delete columns",mergeCell:"Merge cells",splitCell:"Split cell",tableConfigKey:"Table setting",tableConfig:{rowTitle:"Row Title",colTitle:"Col Title",stripeStyle:"Stripe style",hideBorder:"Hide border",showBorder:"Show border",showChart:"Show chart",hideChart:"Hide chart"},title:"Table",abstract:"Table"}};S.mergeLang({"zh-CN":qS,"en-US":WS});const TF="",M4=y("table");function R4(n,t){const e=hu(t);if(!e)return;const o=z(e);d(M4,o&&Ht(o),"not a table block");const r=oh(o,e,"ArrowRight");if(!r){const s=ht(o);return s?(n.selection.selectBlock(s,0),!0):R4(n,o)}const i=Qt(r);return n.selection.selectBlock(i,0),!0}function GS(n){if(!n.isWritable())return!1;const t=n.getFocusedBlock();if(!!t)return R4(n,t)}function A4(n,t){const e=hu(t);if(!e)return;const o=z(e);d(M4,o&&Ht(o),"not a table block");const r=oh(o,e,"ArrowLeft");if(!r){const s=gt(o);return s?(n.selection.selectBlock(s,Z(n,s)),!0):A4(n,o)}const i=Gt(r);return n.selection.selectBlock(i,Z(n,i)),!0}function ZS(n){if(!n.isWritable())return!1;const t=n.getFocusedBlock();if(!!t)return A4(n,t)}const ih={Tab:GS,"Shift+Tab":ZS},YS=`<svg width="24" height="25" viewBox="0 0 24 25" fill="none" xmlns="http://www.w3.org/2000/svg">
445
445
  <g>
446
446
  <path fill-rule="evenodd" clip-rule="evenodd" d="M12 7.61719C11.4477 7.61719 11 7.16947 11 6.61719V3.61719C11 3.0649 11.4477 2.61719 12 2.61719C12.5523 2.61719 13 3.0649 13 3.61719V6.61719C13 7.16947 12.5523 7.61719 12 7.61719ZM4.92893 5.54612C5.31946 5.15559 5.95262 5.1556 6.34315 5.54612L8.46447 7.66744C8.85499 8.05796 8.85499 8.69113 8.46447 9.08165C8.07394 9.47218 7.44078 9.47218 7.05025 9.08165L4.92893 6.96033C4.53841 6.56981 4.53841 5.93664 4.92893 5.54612ZM15.5355 9.08165C15.145 8.69113 15.145 8.05796 15.5355 7.66744L17.6569 5.54612C18.0474 5.1556 18.6805 5.1556 19.0711 5.54612C19.4616 5.93664 19.4616 6.56981 19.0711 6.96033L16.9497 9.08165C16.5592 9.47218 15.9261 9.47218 15.5355 9.08165ZM2 12.6172C2 12.0649 2.44772 11.6172 3 11.6172L6 11.6172C6.55229 11.6172 7 12.0649 7 12.6172C7 13.1695 6.55228 13.6172 6 13.6172L3 13.6172C2.44772 13.6172 2 13.1695 2 12.6172ZM17 12.6172C17 12.0649 17.4477 11.6172 18 11.6172L21 11.6172C21.5523 11.6172 22 12.0649 22 12.6172C22 13.1695 21.5523 13.6172 21 13.6172L18 13.6172C17.4477 13.6172 17 13.1695 17 12.6172ZM15.5355 16.1527C15.9261 15.7622 16.5592 15.7622 16.9497 16.1527L19.0711 18.274C19.4616 18.6646 19.4616 19.2977 19.0711 19.6883C18.6805 20.0788 18.0474 20.0788 17.6569 19.6883L15.5355 17.5669C15.145 17.1764 15.145 16.5432 15.5355 16.1527ZM4.92893 19.6883C4.53841 19.2977 4.53841 18.6646 4.92893 18.274L7.05025 16.1527C7.44078 15.7622 8.07394 15.7622 8.46447 16.1527C8.85499 16.5432 8.85499 17.1764 8.46447 17.5669L6.34315 19.6883C5.95262 20.0788 5.31946 20.0788 4.92893 19.6883ZM12 22.6172C11.4477 22.6172 11 22.1695 11 21.6172V18.6172C11 18.0649 11.4477 17.6172 12 17.6172C12.5523 17.6172 13 18.0649 13 18.6172V21.6172C13 22.1695 12.5523 22.6172 12 22.6172Z" fill="#5587F0"/>
447
447
  <animateTransform attributeType="xml" attributeName="transform" type="rotate" values="0 12 12.5;360 12 12.5" dur="2s" repeatCount="indefinite" />
448
448
  </g>
449
- </svg>`,sh=y("webpage");class QS{constructor(t,e){h(this,"currentSrc","");h(this,"loading",null);h(this,"handleMaskMouseMove",(t,e)=>{if(e.target&&e.target instanceof Element){const o=e.target.closest("webpage-mask");o&&(o.style.display="none")}t.domEvents.addEventListener(document,"mousemove",this.handleDocumentMouseMove)});h(this,"handleDocumentMouseMove",(t,e)=>{if(!e.target||!(e.target instanceof Element))return;const o=this.editor.findBlockById(this.blockData.id);if(o){const r=this.getExistsMask(o);if(r){if(vt(o,e.target)){r.style.display="none";return}r.style.display=""}}});this.editor=t,this.blockData=e}create(t,e,o,r){const i=e.src,s=b("div",["editor-embed"],null),l=b("iframe",["editor-preview-iframe"],s);this.loading=this.createLoading(s);const c=()=>{d(sh,this.loading,"not created"),this.loading.hide(),this.currentSrc=i};t.domEvents.addEventListener(l,"load",c),l.src=i,this.loading.show(),o.append(s),this.createMask(t,r)}update(t,e,o){if(d(sh,this.loading,"not created"),this.currentSrc===o.src)return;const r=e.querySelector(".editor-preview-iframe");d(sh,r,"no exists iframe"),this.loading.show(),r.src=o.src,this.createMask(t,e)}createLoading(t){const e=b("div",["editor-preview-iframe-loading"],null),o=b("span",[],e);return o.innerHTML=YS,{show(){t.append(e)},hide(){const r=t.querySelector(":scope > .editor-preview-iframe-loading");!r||r.remove()}}}getExistsMask(t){return At(t).querySelector(".webpage-mask")}createMask(t,e){const o=At(e);let r=this.getExistsMask(e);if(r){r.style.display="";return}r=b("div",["webpage-mask"],o),t.domEvents.addEventListener(r,"mousemove",this.handleMaskMouseMove)}destroy(){const t=this.editor.findBlockById(this.blockData.id);if(t){const e=this.getExistsMask(t);e&&(this.editor.domEvents.removeEventListener(e,"mousemove",this.handleMaskMouseMove),this.editor.domEvents.removeEventListener(document,"mousemove",this.handleDocumentMouseMove))}}}function KS(n,t){b("div",["resize-gripper",t],n).setAttribute("data-resize-type",t)}function lh(n){return At(n).querySelector(".block-resizer")}function JS(n){const t=lh(n);t&&F(t,"active")}function O4(n,t,e){const o=n.getBoundingClientRect(),r=t.getBoundingClientRect(),i=r.top-o.top,s=r.left-o.left,l=r.width,c=r.height;e.style.top=`${i}px`,e.style.left=`${s}px`,e.style.width=`${l}px`,e.style.height=`${c}px`}function XS(n,t,e,o){const r=lh(n);if(r)return M(r,"active"),O4(n,t,r),r;const i=At(n),s=b("div",["block-resizer"],i);return O4(n,t,s),e.resize.forEach(l=>{KS(s,l)}),s.addEventListener("mousedown",o),M(s,"active"),s}function _4(n,t){const e=lh(n);if(!e)return;const o=n.getBoundingClientRect(),r=t.getBoundingClientRect(),i=r.top-o.top,s=r.left-o.left,l=r.width,c=r.height;e.style.top=`${i}px`,e.style.left=`${s}px`,e.style.width=`${l}px`,e.style.height=`${c}px`}const DF="",tT=y("block-resizer");class $c extends Wt.TypedEmitter{constructor(e,o){super();h(this,"resizableElement");h(this,"block",null);h(this,"startRect",null);h(this,"startPos",null);h(this,"resizeType",null);h(this,"enabled",!1);h(this,"handleMouseDown",e=>{const o=this.getResizableElement();if(!o||e.button!==0)return;const r=e.target;if(!r||!(r instanceof HTMLElement))return;const i=r.getAttribute("data-resize-type");!i||(this.bindEvents(),this.startRect=o.getBoundingClientRect(),this.startPos=e,this.resizeType=i,Ii(window.getComputedStyle(r).cursor))});h(this,"handleMouseMove",e=>{if(!this.startPos||!this.startRect||!this.resizeType)return;const o=this.getResizableElement();if(!o||!this.block)return;const r=e.x-this.startPos.x,i=e.y-this.startPos.y,s=this.startRect;let{top:l,left:c,right:a,bottom:u}=s;(this.resizeType==="bottom"||this.resizeType==="bottom-left"||this.resizeType==="bottom-right")&&(u+=i),(this.resizeType==="top"||this.resizeType==="top-left"||this.resizeType==="top-right")&&(l+=i),(this.resizeType==="left"||this.resizeType==="top-left"||this.resizeType==="bottom-left")&&(c+=r),(this.resizeType==="right"||this.resizeType==="top-right"||this.resizeType==="bottom-right")&&(a+=r);const f=a>c?a-c:0,m=u>l?u-l:0,C=new DOMRect(c,l,f,m);this.emit("resizing",this,C),_4(this.block,o)});h(this,"handleMouseUp",e=>{if(e.button!==0)return;Ii(""),this.unbindEvents(),this.emit("resized",this);const o=this.getResizableElement();!o||!this.block||_4(this.block,o)});this.editor=e,this.options=o}enableResize(e,o){this.block=e,this.resizableElement=o,this.createResizer(),this.enabled=!0}disableResize(){!this.block||(JS(this.block),this.enabled=!1)}update(e,o){this.block=e,this.resizableElement=o,this.getResizableElement()&&this.enabled&&this.createResizer()}getBlock(){return this.block}destroy(){}getResizableElement(){return this.resizableElement?this.resizableElement:this.block?rt(this.block):null}createResizer(){const e=this.getResizableElement();!e||!this.block||(d(tT,vt(this.block,e),"not a block child element"),XS(this.block,e,this.options,this.handleMouseDown))}bindEvents(){document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}unbindEvents(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}function N4(n){return n&&Te(n)&&De(n)==="webpage"}const eT=1e3,nT=100;class oT{constructor(t){h(this,"currentBlockElement",null);h(this,"resizing",!1);h(this,"handleHoveringBlockChange",(t,e)=>{this.resizing||!this.editor.isWritable()||(e&&N4(e)&&this.disableBlockResize(e),t&&N4(t)&&this.enableBlockResize(t))});h(this,"handleResizing",(t,e)=>{this.resizing=!0;const o=t.getBlock();if(!o)return;const r=Math.max(Math.min(e.height,eT),nT);o.style.height=`${r}px`,M(o,"resizing")});h(this,"handleResized",t=>{this.resizing=!1;const e=t.getBlock();if(!e)return;F(e,"resizing");const o=this.editor.getBlockData(e),r=e.getBoundingClientRect().height;this.editor.updateBlockData(e,{...o,height:r})});this.editor=t,_t.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){this.currentBlockElement=null,_t.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}disableBlockResize(t){const e=this.editor.findCustom(`${G(t)}-resizer`);e&&e.disableResize()}enableBlockResize(t){const e=this.editor.addCustom(`${G(t)}-resizer`,()=>new $c(this.editor,{resize:["bottom"]}));e.enableResize(t),e.removeListener("resizing",this.handleResizing),e.removeListener("resized",this.handleResized),e.addListener("resizing",this.handleResizing),e.addListener("resized",this.handleResized),this.currentBlockElement=t}}const LF="",rT=y("editor-dialog");function iT(n,t){const e=b("div",["editor-dialog-container"],null),o=b("div",["dialog-header"],e);b("span",["dialog-header-title"],o,t.title);const r=b("span",["close-icon"],o);r.innerHTML=qd,b("div",["dialog-content"],e).appendChild(n);const s=b("div",["dialog-footer"],e);return b("button",["cancel-button"],s,"Cancel"),b("button",["submit-button"],s,"Ok"),e}class sT extends rs{constructor(e,o){super(iT(e,o),o);h(this,"_options");h(this,"getReferenceClientRect",()=>{const e=document.documentElement.clientHeight/2,o=document.documentElement.clientWidth/2,r=this.getCommandBarRoot();d(rT,r,"no command bar root");const{width:i,height:s}=r.getBoundingClientRect();return new DOMRect(Math.max(o-i/2,0),Math.max(e-s/2,0),0,0)});h(this,"onOk",async()=>{var e,o;try{await((o=(e=this._options).onOk)==null?void 0:o.call(e)),this.destroy()}catch{}});h(this,"onClose",()=>{var e,o;(o=(e=this._options).onClose)==null||o.call(e),this.destroy()});const r=this.content.querySelector(".submit-button"),i=this.content.querySelector(".cancel-button"),s=this.content.querySelector(".close-icon");r==null||r.addEventListener("click",this.onOk),s==null||s.addEventListener("click",this.onClose),i==null||i.addEventListener("click",this.onClose),this._options=o}show(){super.show(document.documentElement,{getReferenceClientRect:this.getReferenceClientRect})}destroy(){const e=this.content.querySelector(".submit-button"),o=this.content.querySelector(".cancel-button"),r=this.content.querySelector(".close-icon");e==null||e.removeEventListener("click",this.onOk),o==null||o.removeEventListener("click",this.onClose),r==null||r.removeEventListener("click",this.onClose),super.destroy()}}const P4=()=>[{name:S.t("webpage.bilibili"),id:"insert-bilibili",icon:_5,group:"thirdParty"},{name:S.t("webpage.youku"),id:"insert-youku",icon:N5,group:"thirdParty"},{name:S.t("webpage.figma"),id:"insert-figma",icon:P5,group:"thirdParty"},{name:S.t("webpage.modao"),id:"insert-modao",icon:$5,group:"thirdParty"},{name:S.t("webpage.tencent"),id:"insert-tencent",icon:H5,group:"thirdParty"},{id:"insert-webPage",name:S.t("webpage.title"),icon:j5,group:"common",order:1e3}];function ch(n){return n==="insert-webPage"}async function lT(n,t){return n.doc.externalDoc.recognizeLink?n.doc.externalDoc.recognizeLink(t):null}function cT(n){return n&&!n.startsWith("http://")&&!n.startsWith("https://")&&!n.startsWith("//")?`//${n}`:n}async function aT(n){if(!n)throw new Error(S.t("webpage.dialog.errorEnterUrl"));let t=n;t.startsWith("//")&&(t=`http:${t}`);try{new URL(t)}catch{throw new Error(S.t("webpage.dialog.unsupportedUrl"))}}async function dT(n,t){const e=t.item.id,o=P4().find(l=>l.id===e),r=b("div",["webpage-content"],null);if(ch(e)){const l=b("div",["help-container"],r),c=b("div",["help-content"],l),a=b("span",["help-icon"],c);a.innerHTML=ru,b("span",[],c,S.t("webpage.dialog.helpContent"))}const{getInputValue:i,setFieldError:s}=cc(r,{required:!0,label:S.t("webpage.dialog.label"),placeholder:S.t("webpage.dialog.placeholder")});if(!ch(e)){const l=b("div",["help-link-container"],r),c=b("a",["help-link-content"],l);b("span",[],c,S.t("webpage.dialog.helpLink"));const a=b("span",["help-link-icon"],c);a.innerHTML=su;const u=n.getComponentOptions("webpage");c.href=(u==null?void 0:u.helpLink)||"",c.target="_blank"}try{const l=await new Promise(a=>{new sT(r,{title:S.t("webpage.dialog.title",{name:(o==null?void 0:o.name)||""}),async onOk(){var m;const f=cT(i());try{await aT(f);const C=await lT(n,f);a((C==null?void 0:C.url)||"")}catch(C){if(((m=C==null?void 0:C.responseData)==null?void 0:m.statusCode)===415)if(ch(e))a(f);else throw s(S.t("webpage.dialog.unsupportedUrl")),C;else throw s(C.message||""),C}}}).show()}),c={id:N(),type:"embed",embedType:"webpage",embedData:{src:l}};return n.insertBlock(t.containerId,t.blockIndex,c)}catch{return null}}const $4=y("embed-block-properties");function ah(n,t){var e;for(const o of n.blockHooks){const r=(e=o.commands)==null?void 0:e.call(o,n,t);if(!!r&&r.group==="block-comment-actions")return r.executeCommand(n,t,r.commands[0]),!0}return!1}class dh{constructor(t,e){h(this,"group","hovering-toolbar");h(this,"_commands",[{id:"edit",name:"Edit",icon:sc},{id:"add-comment",name:"Add Comment",icon:$r}]);this.editor=t,this.properties=e}get commands(){var e,o,r;if(!this.editor.isWritable())return[];const t=(e=this.properties)!=null&&e.presetIds?this._commands.filter(i=>{var s,l;return(l=(s=this.properties)==null?void 0:s.presetIds)==null?void 0:l.includes(i.id)}):[...this._commands];return(r=(o=this.properties)==null?void 0:o.extCommands)!=null&&r.length&&(t.push({id:N(),type:"separator",name:""}),t.push(...this.properties.extCommands)),t}executeCommand(t,e,o){var r,i;if(!((i=(r=this.properties)==null?void 0:r.handleExecuteCommand)!=null&&i.call(r,t,e,o))){if(o.id==="add-comment"){ah(t,e)||$4.error("failed to add comment to block");return}$4.error(`unknown command: ${JSON.stringify(o)}`),alert(o.id)}}}function uh(n,t,e){return{blockCommands:{"hovering-toolbar":new dh(n,e)}}}function uT(n){const t=n.querySelector(".editor-preview-iframe"),e=t.src;t.src="about:blank";const o=setTimeout(()=>{t.src=e,clearTimeout(o)},300);return!0}function hT(n,t){const e=n.getBlockData(t),{embedData:o}=e,r=o.src;return window.open(r,"_blank"),!0}function fT(n,t){const e=uh(n,t,{presetIds:["add-comment"],extCommands:[{id:"refresh",name:"Refresh page",icon:R5},{id:"open-page",name:"Open the original page",icon:su}],handleExecuteCommand:(r,i,s)=>{switch(s.id){case"refresh":return uT(i);case"open-page":return hT(r,i)}return!1}}),o=`[${S.t("webpage.abstract")}]`;return{...e,abstract:o}}const mT=y("webpage-embed");function gT(n,t,e,o,r,i){const{embedData:s,id:l}=e,{src:c}=s,a=n.addCustom(`webpage-${l}`,()=>new QS(n,e));d(mT,c,"The src from blockData is invalid "),a.create(n,s,t,i),n.addCustom("webpage-resizer",()=>new oT(n)),e.height&&(i.style.height=`${e.height}px`)}function pT(n,t,e){const{embedData:o,id:r}=e;return n.getCustom(`webpage-${r}`).update(n,t,o),e.height&&(t.style.height=`${e.height}px`),!0}function CT(){return{name:"WebPage",insertEmbedCommandItems:P4(),handleInsertEmptyEmbed:dT}}const hh={embedType:"webpage",createEmbedContent:gT,getBlockProperties:fT,getOptions:CT,handleUpdateBlock:pT},bT={webpage:{title:"\u7F51\u9875",youku:"\u4F18\u9177\u89C6\u9891",modao:"\u58A8\u5200",tencent:"\u817E\u8BAF\u89C6\u9891",bilibili:"Bilibili",figma:"Figma",dialog:{helpContent:"\u56E0\u76EE\u6807\u7F51\u9875\u7684\u9650\u5236\uFF0C\u90E8\u5206\u7F51\u9875\u53EF\u80FD\u65E0\u6CD5\u6210\u529F\u9884\u89C8\u3002",helpLink:"\u5982\u4F55\u83B7\u53D6\u94FE\u63A5",label:"\u7F51\u9875\u5730\u5740",placeholder:"\u8BF7\u8F93\u5165",title:"\u63D2\u5165{name}",errorEnterUrl:"\u8BF7\u8F93\u5165\u7F51\u9875\u5730\u5740",unsupportedUrl:"\u6682\u4E0D\u652F\u6301\u63D2\u5165\u8BE5\u94FE\u63A5\u5185\u5BB9"},abstract:"\u7F51\u9875"}},vT={webpage:{title:"Webpage",youku:"Youku",modao:"Modao",tencent:"Tencent Video",bilibili:"Bilibili",figma:"Figma",dialog:{helpContent:"Due to the limitation of the landing page, some pages may not be previewed successfully.",helpLink:"How to get the URL link",label:"Please enter webpage address",placeholder:"Please enter url",title:"Insert {name}",errorEnterUrl:"Please enter the webpage address",unsupportedUrl:"Unsupported url"},abstract:"Webpage"}};S.mergeLang({"zh-CN":bT,"en-US":vT});const MF="",kT={mermaid:{blockType:"embed",reg:/^```mermaid$/,data:{embedType:"mermaid"}},flowchart:{blockType:"embed",reg:/^```flowchart$/,data:{embedType:"flowchart"}},plantuml:{blockType:"embed",reg:/^```plantuml$/,data:{embedType:"plantuml"}},code:{blockType:"code",reg:/^```\S+$/},code2:{blockType:"code",reg:/^```$/},table:{blockType:"table",reg:/^\|.+\|.+\|$/},math:{blockType:"embed",reg:/^\$\$.+\$\$$/},image:{blockType:"embed",reg:/^!\[[^\]]*\]\((?<filename>.*?)(?="|\))(?<optionalPart>".*")?\)/,data:{embedType:"image"}},dividing:{blockType:"embed",reg:/^-{3,}$/,data:{embedType:"dividing-line"}},toc:{blockType:"embed",reg:/^\[toc\]/,data:{embedType:"toc"}}},yT={orderedList:{reg:/^(\d)+(\.|。)$/,blockType:"list",data:{listType:"ordered"}},unorderedList1:{reg:/^\*$/,blockType:"list",data:{listType:"unordered"}},unorderedList2:{reg:/^-$/,blockType:"list",data:{listType:"unordered"}},checkList1:{reg:/^\[\s?\]$/,blockType:"list",data:{listType:"unchecked"}},checkList2:{reg:/^\[X\]$/i,blockType:"list",data:{listType:"checked"}},image:{blockType:"embed",reg:/^!\[[^\]]*\]\((?<filename>.*?)(?="|\))(?<optionalPart>".*")?\)/,data:{embedType:"image"}}};function H4(n,t,e,o,r){const i=n.getBlockByIndex(t,e),s=Tt(Ae(n.getBlockText(i),o).left).trim(),l=r==="enter"?kT:yT;for(const[,c]of Object.entries(l)){if(!s.match(c.reg))continue;return!!n.undoManager.runInGroup(()=>{var v;const u=hl(n,i,c.blockType,{offset:o,data:c.data});if(!u)return null;const{blockData:f,focusBlockId:m}=u;if(!f)return null;const C=n.insertBlock(t,e,f,Ot(n,m!=null?m:f.id,0));return n.deleteBlock(i),(v=u.onConverted)==null||v.call(u,n,C),{newBlock:C,focusBlockId:m}})}return!1}function wT(n,t,e,o){const r=n.getBlockByIndex(t,e);return n.getBlockString(r,{boxReplacement:" "}).substring(0,o)!==">"?!1:(n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,0,o+1),n.updateBlockData(r,{quoted:!0},Ot(n,r,0))}),!0)}const BT={"#":1,"##":2,"###":3,"####":4,"#####":5,"######":6,"#######":7,"########":8};function ET(n,t,e,o){const r=n.getBlockByIndex(t,e),i=n.getBlockString(r,{boxReplacement:" "}).substring(0,o),s=BT[i];return s?(n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,0,o+1),n.updateBlockData(r,{heading:s},Ot(n,r,0))}),!0):!1}function IT(n,t,e,o){return!!(ET(n,t,e,o)||wT(n,t,e,o))}const xT=y("match-text-style");function ST(n){let t="";for(let e=n.length-1;e>=0;e--){const o=n[e];if(!o.attributes||Object.keys(o.attributes).length===0){t+=o.insert;continue}break}return t}function TT(n,t){if(n.length<t.length*2+1||!n.endsWith(t)||n.substring(0,n.length-1).endsWith(t))return-1;const e=n.substring(0,n.length-t.length),o=e.lastIndexOf(t);return o===-1?-1:o===0?0:e.substring(o-1).startsWith(t)?-1:o}const DT={"*":{type:"style",styles:["style-italic"],boxType:""},"**":{type:"style",styles:["style-bold"],boxType:""},"***":{type:"style",styles:["style-bold","style-italic"],boxType:""},"~~":{type:"style",styles:["style-line-through"],boxType:""},"`":{type:"style",styles:["style-code"],boxType:""},$$:{type:"box",styles:[],boxType:"math"}};function LT(n,t,e,o){var u,f;const r=n.getBlockByIndex(t,e),i=n.getBlockText(r),{left:s}=Ae(i,o),l=ST(s),c=ce(s)-l.length,a=Object.entries(DT);for(const[m,C]of a){const v=TT(l,m);if(v===-1)continue;const w=c+v,E=o,L=m.length,x=Tt(Kt(i,w+L,E-w-L*2).middle);if(C.type==="style"){const A={};C.styles.forEach(P=>{A[P]=!0});const O=Oi(x,A);n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,w,E-w),n.insertTextToBlock(r,w,O)})}else if(C.type==="box")try{const A=(f=(u=n.editorBoxes.getBoxClass(C.boxType)).convertFrom)==null?void 0:f.call(u,n,x);if(!A)continue;n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,w,E-w),n.insertBoxToBlock(r,w,A)})}catch(A){xT.warn(`failed to convert to box, ${A.message}`);continue}return!0}return!1}class Hc{handleAfterInsertText(t,e,o,r,i){return!!(i===" "&&(IT(t,e,o,r)||LT(t,e,o,r)))}handleBeforeKeyDown(t,e){if(!t.selection.range.isSimple())return!1;const{containerId:r,blockIndex:i,offset:s}=t.getTextPosition();if(j(t,t.getBlockByIndex(r,i))){if(_n(e,"Enter")){if(H4(t,r,i,s,"enter"))return!0}else if(_n(e,"Space")&&H4(t,r,i,s,"space"))return!0}return!1}}const MT={"en-US":{placeholder:{default:"Type \u2018/\u2019 for commands",heading:"Heading {heading}",list:"List",mention:"Quickly assign tasks @mention yourself or others",quote:"Quote"}},"zh-CN":{placeholder:{default:"\u8F93\u5165\u300C/\u300D\u5FEB\u901F\u63D2\u5165",heading:"\u6807\u9898{heading}",list:"\u5217\u8868",mention:"\u5FEB\u901F\u5206\u914D\u4EFB\u52A1\uFF0C@\u63D0\u53CA\u81EA\u5DF1\u6216\u4ED6\u4EBA",quote:"\u5F15\u7528"}}};S.mergeLang(MT);function bs(n,t){const e=ro(n,t);return!!(e.text&&ce(e.text)===0&&!t.querySelector(".inputting-insertion"))}function j4(n,t){var o;rt(t).removeAttribute("data-content-placeholder"),(o=t.querySelector("[data-type=block-tools] .block-placeholder-container"))==null||o.remove()}function jc(n,t,e){var r;if(!bs(n,t)){j4(n,t);return}const o=rt(t);if(typeof e=="string")o.setAttribute("data-content-placeholder",e);else{const i=At(t),s=(r=i.querySelector(".block-placeholder-container"))!=null?r:b("div",["block-placeholder-container"],i);s.innerHTML="",s.appendChild(e)}}function RT(n){const t=n.getAttribute("data-style-heading");return t?S.t("placeholder.heading",{heading:t}):n.getAttribute("data-style-quoted")?S.t("placeholder.quote"):null}function AT(n){const t=n.getAttribute("data-list-type");return t?t==="ordered"||t==="unordered"?S.t("placeholder.list"):S.t("placeholder.mention"):null}function F4(n){switch(it(n)){case"text":return RT(n);case"list":return AT(n);default:return null}}function OT(n){if(Vo(n))return!1;const t=z(H(n));return t?it(t)==="code":!1}function _T(n,t){var u,f;const e=it(n.selection.focusedBlock),o=t.contentPlaceholder||S.t("placeholder.default");let r=o;const i=n.selection.focusedBlock;if(e&&Di(n,e)&&i){if(OT(i))return;r=(u=F4(i))!=null?u:r}const s=n.getFirstBlock(),l=ht(s);if(!l)return;const c=ht(l);if(c&&!t.addPlaceholderToAllCurrentEmptyBlock)return;if(!c){bs(n,l)&&jc(n,l,(f=F4(l))!=null?f:o);return}const a=n.getFocusedBlock();!bs(n,a)||a!==s&&jc(n,a,r)}function NT(n,t){var r;const e=n.getFirstBlock(),o=rt(e);bs(n,e)?o.setAttribute("data-title-placeholder",(r=t.titlePlaceholder)!=null?r:"Enter document title"):o.removeAttribute("data-title-placeholder")}function PT(n){n.rootContainer.querySelectorAll("[data-content-placeholder").forEach(t=>{t.removeAttribute("data-content-placeholder")}),n.rootContainer.querySelectorAll("[data-type=block-tools] .block-placeholder-container").forEach(t=>{t.remove()})}function $T(n,t){PT(n),n.selection.range.isCollapsed()&&(NT(n,t),_T(n,t))}const OF="",HT=y("enforce-title");class vs{constructor(t,e={headingLevel:1}){h(this,"handleSelectionChange",t=>{this.applyPlaceholder(t)});this.options=e,this.handleChanged(t),this.applyPlaceholder(t),t.addListener("selectionChanged",this.handleSelectionChange)}destroy(t){t.removeListener("selectionChanged",this.handleSelectionChange)}handleBeforeKeyDown(t,e){if(!t.selection.range.isSimple())return!1;const{containerId:r,blockIndex:i,offset:s}=t.getTextPosition();if(!vs.isDocumentTitleBlock(r,i)||!_n(e,"Enter"))return!1;let l=!1,c=null;Ve(t.rootContainer)===2&&(c=mr(t.rootContainer,1),Z(t,c)===0&&(l=!0));const a=t.getFirstBlock();return t.undoManager.runInGroup(()=>{t.breakTextBlock(a,s,{forceInsertAfter:!0}),l&&c&&t.deleteBlock(c)}),!0}handleChanged(t){var e;try{const o=t.doc.getContainerBlocks(V(t.rootContainer));d(HT,o.length>0,"root container is empty");const r=o[0];if(r.type!=="text"||r.heading!==this.options.headingLevel){const i=jn("",{heading:(e=this.options.headingLevel)!=null?e:1});t.insertBlock(V(t.rootContainer),0,i);return}if(o.length>1)return;t.insertTextBlock("",V(t.rootContainer),1,{newRange:t.selection.range.toDocRange()})}finally{this.applyPlaceholder(t)}}handleRemoteChanged(t){setTimeout(()=>{this.applyPlaceholder(t)})}handleUpdateCompositionText(t){this.applyPlaceholder(t)}applyPlaceholder(t){var e,o;!((e=this.options)!=null&&e.titlePlaceholder)&&!((o=this.options)!=null&&o.contentPlaceholder)||$T(t,this.options)}static isDocumentTitleBlock(t,e){return t==="root"&&e===0}}const z4=y("code-dom");function tr(n){return it(n)==="code"}function V4(n,t,e){e.language?t.setAttribute("data-language",e.language):t.removeAttribute("data-language"),e.nowrap?F(t,"wrap"):M(t,"wrap")}function U4(n){const t=n.closest("div[data-type=editor-block][data-block-type=code]");return d(z4,t,"no parent code block"),d(z4,tr(t),"not a code block"),t}const Fc={plain:{name:"Plain Text",aliases:["txt","text"]},abap:{name:"ABAP",aliases:["abap"]},arduino:{name:"Arduino",aliases:["ino"]},bash:{name:"Bash",aliases:["sh","shell"]},basic:{name:"BASIC",aliases:["bas"]},c:{name:"C",aliases:["c"]},clojure:{name:"Clojure",aliases:["clj"]},cofeescript:{name:"CoffeeScript",aliases:["coffee"]},cpp:{name:"C++",aliases:["cpp","cxx"]},csharp:{name:"C#",aliases:["cs"]},css:{name:"CSS",aliases:["css"]},dart:{name:"Dart",aliases:["dart"]},diff:{name:"Diff",aliases:["diff","patch"]},docker:{name:"Docker",aliases:["dockerfile"]},elixir:{name:"Elixir",aliases:["ex","exs"]},elm:{name:"Elm",aliases:["elm"]},erlang:{name:"Erlang",aliases:["erl"]},flow:{name:"Flow",aliases:["flow"]},fortran:{name:"Fortran",aliases:["f","for","f77","f90"]},fsharp:{name:"F#",aliases:["fsharp"]},gherkin:{name:"Gherkin",aliases:["feature"]},glsl:{name:"GLSL",aliases:["glsl"]},go:{name:"Go",aliases:["go"]},graphql:{name:"GraphQL",aliases:["graphql"]},groovy:{name:"Groovy",aliases:["groovy"]},haskell:{name:"Haskell",aliases:["hs"]},java:{name:"Java",aliases:["java"]},js:{name:"JavaScript",aliases:["js","jsx"]},json:{name:"JSON",aliases:["json"]},julia:{name:"Julia",aliases:["jl"]},kotlin:{name:"Kotlin",aliases:["kt","ktm","kts"]},latex:{name:"LaTeX",aliases:["tex"]},less:{name:"LESS",aliases:["less"]},lisp:{name:"Lisp",aliases:["lisp"]},livescript:{name:"LiveScript",aliases:["ls"]},lua:{name:"Lua",aliases:["lua"]},makefile:{name:"Makefile",aliases:["mk","mak"]},markdown:{name:"Markdown",aliases:["md","mkdown","mkd"]},markup:{name:"HTML / XML",aliases:["html","htm","xml","xsd","xsl","xslt","wsdl"]},matlab:{name:"MATLAB",aliases:["matlab"]},mermaid:{name:"Mermaid",aliases:["mermaid"]},nix:{name:"Nix",aliases:["nix"]},objectivec:{name:"Objective-C",aliases:["m","mm"]},ocaml:{name:"OCaml",aliases:["ml"]},pascal:{name:"Pascal",aliases:["pas"]},perl:{name:"Perl",aliases:["pl","pm"]},php:{name:"PHP",aliases:["php"]},powershell:{name:"PowerShell",aliases:["ps","ps1"]},prolog:{name:"Prolog",aliases:["plg"]},protobuf:{name:"Protocol Buffers",aliases:["proto"]},python:{name:"Python",aliases:["py"]},r:{name:"R",aliases:["r"]},reason:{name:"Reason",aliases:["re","rei"]},ruby:{name:"Ruby",aliases:["rb"]},rust:{name:"Rust",aliases:["rs"]},sass:{name:"Sass",aliases:["sass"]},scala:{name:"Scala",aliases:["scala"]},scheme:{name:"Scheme",aliases:["scm","sm"]},scss:{name:"SCSS",aliases:["scss"]},solidity:{name:"Solidity",aliases:["sol"]},sql:{name:"SQL",aliases:["sql"]},swift:{name:"Swift",aliases:["swift"]},typescript:{name:"TypeScript",aliases:["ts","tsx"]},vbnet:{name:"VB.Net",aliases:["vbnet"]},verilog:{name:"Verilog",aliases:["v"]},vhdl:{name:"VHDL",aliases:["vhdl"]},"visual-basic":{name:"Visual Basic",aliases:["vb","vba"]},wasm:{name:"WebAssembly",aliases:["wasm"]},yaml:{name:"YAML",aliases:["yaml"]}};function jT(n){const t=n.toLocaleLowerCase();let e="plain";return Object.entries(Fc).forEach(([o,r])=>{(o===t||r.aliases.includes(t)||r.name.toLocaleLowerCase()===t)&&(e=o)}),e}const FT=y("convert-to-code");function zT(n,t){if(!j(n,t))return null;const e={id:N(),type:"text",text:[]},o=N();n.doc.localInsertChildContainer(o,[e]);const r=n.getBlockData(t).text;d(FT,r,"no text");let i=Tt(r);i.startsWith("```")&&(i=i.substring(3));const s=jT(i);return{blockData:{id:N(),type:"code",language:s,children:[o]},focusBlockId:e.id}}const _F="",fh=y("code-block-child-container");function Zr(n){d(fh,tr(n),"not a code block");const e=rt(n).querySelector(":scope > div.editor-code-root > div.code-text-root [data-type=editor-container].child");return d(fh,e,"no code text container"),e}function Yr(n){d(fh,tr(n),"not a code block");const e=rt(n).querySelector(":scope > div.editor-code-root > div.code-caption-root [data-type=editor-container].child");return e||null}function zc(n){const t=[Zr(n)],e=Yr(n);return e&&t.push(e),t}function Vc(n){const t=H(n),e=z(t);return e?tr(e)?t===Zr(e):it(n)==="code":!1}const mh=y("code-caption");function VT(n,t){if(n.readonly)return;const e=Yr(t);if(e){const c=Qt(e);n.selection.selectBlock(c,0);return}const o=pn(n.doc),r=n.getBlockData(t);d(mh,r.children.length===1,"code block should have only one child");const i={...r,children:[r.children[0],o]};n.updateBlockData(t,i);const s=n.getContainerById(o),l=Qt(s);n.selection.selectBlock(l,0)}function q4(n,t){const e=H(t);if(Ct(e))return!1;const o=z(e);if(d(mh,o,"no parent block"),!tr(o))return!1;const i=Yr(o);return e===i}function UT(n,t){if(n.readonly||!Yr(t))return;const o=Zr(t),r=Gt(o);n.selection.selectBlock(r,Z(n,r));const i=n.getBlockData(t);d(mh,i.children.length===2,"code block should have only one child");const s=i.children[1],l={...i,children:[i.children[0]]};n.updateBlockData(t,l),n.deleteChildContainers([s])}const qT=y("paste-in-table-block");class WT{constructor(t){this.editor=t,setTimeout(()=>{t.input.addHandler(this)})}destroy(){}async handleBeforePaste(t,e){if(!t.selection.range.isSimple())return!1;const o=t.selection.range.start,r=t.getBlockById(o.blockId),i=H(r);if(Ct(i))return!1;const s=z(i);if(d(qT,s,"no parent block"),!tr(s)||q4(t,r))return!1;if(!e.clipboardData)return!0;const l=e.clipboardData.getData("text/plain");if(!l)return!0;const c=oo(l);return t.undoManager.runInGroup(()=>{t.clearSelectedContents(),t.insertDoc(r,o.offset,c)}),!0}}function GT(n){n.addCustom("code-block-paste-event",t=>new WT(t))}class ZT{constructor(t){h(this,"id","CodeBlockCommandProvider");setTimeout(()=>{t.editorCommandProviders.registerCommandProvider(this)})}destroy(){}getAvailableCommands(){return[]}executeCommand(){return!1}filterCommands(t,e,o,r){if(Vc(e))return[]}beforeExecuteCommand(t,e,o,r,i){return!!Vc(e)}}function YT(n){n.addCustom("code-block-command-provider",t=>new ZT(t))}const QT=y("code-caption-input-handler");function gh(n){if(!n.selection.range.isSimple())return null;const t=n.selection.range.start;if(!t.isSimple())return null;const e=n.getBlockById(t.blockId);return q4(n,e)?e:null}function KT(n){const t=gh(n);if(!t)return!1;const e=U4(t),o=ht(e);return o?(n.selection.selectBlock(o,0),!0):(n.insertTextBlock("",V(H(e)),K(e)+1),!0)}function JT(n){const t=gh(n);if(!t)return!1;if(wt(n,t)){const e=U4(t);return UT(n,e),!0}return!1}class ph{constructor(t){setTimeout(()=>{t.input.addHandler(this)})}destroy(){}handleBeforeKeyDown(t,e){return e.key==="Enter"?KT(t):e.key==="Backspace"?JT(t):!1}async handleBeforePaste(t,e){const o=gh(t);if(!o)return!1;if(!e.clipboardData)return!0;const r=e.clipboardData.getData("text/plain");return r&&t.undoManager.runInGroup(()=>{t.clearSelectedContents();const i=t.selection.range.start;d(QT,i.isSimple(),"not simple position"),t.insertTextToBlock(o,i.offset,r)}),!0}static init(t){t.addCustom("code-block-caption-input-handler",e=>new ph(e))}}const XT=`
449
+ </svg>`,sh=y("webpage");class QS{constructor(t,e){h(this,"currentSrc","");h(this,"loading",null);h(this,"handleMaskMouseMove",(t,e)=>{if(e.target&&e.target instanceof Element){const o=e.target.closest("webpage-mask");o&&(o.style.display="none")}t.domEvents.addEventListener(document,"mousemove",this.handleDocumentMouseMove)});h(this,"handleDocumentMouseMove",(t,e)=>{if(!e.target||!(e.target instanceof Element))return;const o=this.editor.findBlockById(this.blockData.id);if(o){const r=this.getExistsMask(o);if(r){if(vt(o,e.target)){r.style.display="none";return}r.style.display=""}}});this.editor=t,this.blockData=e}create(t,e,o,r){const i=e.src,s=b("div",["editor-embed"],null),l=b("iframe",["editor-preview-iframe"],s);this.loading=this.createLoading(s);const c=()=>{d(sh,this.loading,"not created"),this.loading.hide(),this.currentSrc=i};t.domEvents.addEventListener(l,"load",c),l.src=i,this.loading.show(),o.append(s),this.createMask(t,r)}update(t,e,o){if(d(sh,this.loading,"not created"),this.currentSrc===o.src)return;const r=e.querySelector(".editor-preview-iframe");d(sh,r,"no exists iframe"),this.loading.show(),r.src=o.src,this.createMask(t,e)}createLoading(t){const e=b("div",["editor-preview-iframe-loading"],null),o=b("span",[],e);return o.innerHTML=YS,{show(){t.append(e)},hide(){const r=t.querySelector(":scope > .editor-preview-iframe-loading");!r||r.remove()}}}getExistsMask(t){return At(t).querySelector(".webpage-mask")}createMask(t,e){const o=At(e);let r=this.getExistsMask(e);if(r){r.style.display="";return}r=b("div",["webpage-mask"],o),t.domEvents.addEventListener(r,"mousemove",this.handleMaskMouseMove)}destroy(){const t=this.editor.findBlockById(this.blockData.id);if(t){const e=this.getExistsMask(t);e&&(this.editor.domEvents.removeEventListener(e,"mousemove",this.handleMaskMouseMove),this.editor.domEvents.removeEventListener(document,"mousemove",this.handleDocumentMouseMove))}}}function KS(n,t){b("div",["resize-gripper",t],n).setAttribute("data-resize-type",t)}function lh(n){return At(n).querySelector(".block-resizer")}function JS(n){const t=lh(n);t&&F(t,"active")}function O4(n,t,e){const o=n.getBoundingClientRect(),r=t.getBoundingClientRect(),i=r.top-o.top,s=r.left-o.left,l=r.width,c=r.height;e.style.top=`${i}px`,e.style.left=`${s}px`,e.style.width=`${l}px`,e.style.height=`${c}px`}function XS(n,t,e,o){const r=lh(n);if(r)return M(r,"active"),O4(n,t,r),r;const i=At(n),s=b("div",["block-resizer"],i);return O4(n,t,s),e.resize.forEach(l=>{KS(s,l)}),s.addEventListener("mousedown",o),M(s,"active"),s}function _4(n,t){const e=lh(n);if(!e)return;const o=n.getBoundingClientRect(),r=t.getBoundingClientRect(),i=r.top-o.top,s=r.left-o.left,l=r.width,c=r.height;e.style.top=`${i}px`,e.style.left=`${s}px`,e.style.width=`${l}px`,e.style.height=`${c}px`}const DF="",tT=y("block-resizer");class $c extends Wt.TypedEmitter{constructor(e,o){super();h(this,"resizableElement");h(this,"block",null);h(this,"startRect",null);h(this,"startPos",null);h(this,"resizeType",null);h(this,"enabled",!1);h(this,"handleMouseDown",e=>{const o=this.getResizableElement();if(!o||e.button!==0)return;const r=e.target;if(!r||!(r instanceof HTMLElement))return;const i=r.getAttribute("data-resize-type");!i||(this.bindEvents(),this.startRect=o.getBoundingClientRect(),this.startPos=e,this.resizeType=i,Ii(window.getComputedStyle(r).cursor))});h(this,"handleMouseMove",e=>{if(!this.startPos||!this.startRect||!this.resizeType)return;const o=this.getResizableElement();if(!o||!this.block)return;const r=e.x-this.startPos.x,i=e.y-this.startPos.y,s=this.startRect;let{top:l,left:c,right:a,bottom:u}=s;(this.resizeType==="bottom"||this.resizeType==="bottom-left"||this.resizeType==="bottom-right")&&(u+=i),(this.resizeType==="top"||this.resizeType==="top-left"||this.resizeType==="top-right")&&(l+=i),(this.resizeType==="left"||this.resizeType==="top-left"||this.resizeType==="bottom-left")&&(c+=r),(this.resizeType==="right"||this.resizeType==="top-right"||this.resizeType==="bottom-right")&&(a+=r);const f=a>c?a-c:0,m=u>l?u-l:0,C=new DOMRect(c,l,f,m);this.emit("resizing",this,C),_4(this.block,o)});h(this,"handleMouseUp",e=>{if(e.button!==0)return;Ii(""),this.unbindEvents(),this.emit("resized",this);const o=this.getResizableElement();!o||!this.block||_4(this.block,o)});this.editor=e,this.options=o}enableResize(e,o){this.block=e,this.resizableElement=o,this.createResizer(),this.enabled=!0}disableResize(){!this.block||(JS(this.block),this.enabled=!1)}update(e,o){this.block=e,this.resizableElement=o,this.getResizableElement()&&this.enabled&&this.createResizer()}getBlock(){return this.block}destroy(){}getResizableElement(){return this.resizableElement?this.resizableElement:this.block?rt(this.block):null}createResizer(){const e=this.getResizableElement();!e||!this.block||(d(tT,vt(this.block,e),"not a block child element"),XS(this.block,e,this.options,this.handleMouseDown))}bindEvents(){document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}unbindEvents(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}function N4(n){return n&&Te(n)&&De(n)==="webpage"}const eT=1e3,nT=100;class oT{constructor(t){h(this,"currentBlockElement",null);h(this,"resizing",!1);h(this,"handleHoveringBlockChange",(t,e)=>{this.resizing||!this.editor.isWritable()||(e&&N4(e)&&this.disableBlockResize(e),t&&N4(t)&&this.enableBlockResize(t))});h(this,"handleResizing",(t,e)=>{this.resizing=!0;const o=t.getBlock();if(!o)return;const r=Math.max(Math.min(e.height,eT),nT);o.style.height=`${r}px`,M(o,"resizing")});h(this,"handleResized",t=>{this.resizing=!1;const e=t.getBlock();if(!e)return;F(e,"resizing");const o=this.editor.getBlockData(e),r=e.getBoundingClientRect().height;this.editor.updateBlockData(e,{...o,height:r})});this.editor=t,_t.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){this.currentBlockElement=null,_t.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}disableBlockResize(t){const e=this.editor.findCustom(`${G(t)}-resizer`);e&&e.disableResize()}enableBlockResize(t){const e=this.editor.addCustom(`${G(t)}-resizer`,()=>new $c(this.editor,{resize:["bottom"]}));e.enableResize(t),e.removeListener("resizing",this.handleResizing),e.removeListener("resized",this.handleResized),e.addListener("resizing",this.handleResizing),e.addListener("resized",this.handleResized),this.currentBlockElement=t}}const LF="",rT=y("editor-dialog");function iT(n,t){const e=b("div",["editor-dialog-container"],null),o=b("div",["dialog-header"],e);b("span",["dialog-header-title"],o,t.title);const r=b("span",["close-icon"],o);r.innerHTML=qd,b("div",["dialog-content"],e).appendChild(n);const s=b("div",["dialog-footer"],e);return b("button",["cancel-button"],s,"Cancel"),b("button",["submit-button"],s,"Ok"),e}class sT extends rs{constructor(e,o){super(iT(e,o),o);h(this,"_options");h(this,"getReferenceClientRect",()=>{const e=document.documentElement.clientHeight/2,o=document.documentElement.clientWidth/2,r=this.getCommandBarRoot();d(rT,r,"no command bar root");const{width:i,height:s}=r.getBoundingClientRect();return new DOMRect(Math.max(o-i/2,0),Math.max(e-s/2,0),0,0)});h(this,"onOk",async()=>{var e,o;try{await((o=(e=this._options).onOk)==null?void 0:o.call(e)),this.destroy()}catch{}});h(this,"onClose",()=>{var e,o;(o=(e=this._options).onClose)==null||o.call(e),this.destroy()});const r=this.content.querySelector(".submit-button"),i=this.content.querySelector(".cancel-button"),s=this.content.querySelector(".close-icon");r==null||r.addEventListener("click",this.onOk),s==null||s.addEventListener("click",this.onClose),i==null||i.addEventListener("click",this.onClose),this._options=o}show(){super.show(document.documentElement,{getReferenceClientRect:this.getReferenceClientRect})}destroy(){const e=this.content.querySelector(".submit-button"),o=this.content.querySelector(".cancel-button"),r=this.content.querySelector(".close-icon");e==null||e.removeEventListener("click",this.onOk),o==null||o.removeEventListener("click",this.onClose),r==null||r.removeEventListener("click",this.onClose),super.destroy()}}const P4=()=>[{name:S.t("webpage.bilibili"),id:"insert-bilibili",icon:_5,group:"thirdParty"},{name:S.t("webpage.youku"),id:"insert-youku",icon:N5,group:"thirdParty"},{name:S.t("webpage.figma"),id:"insert-figma",icon:P5,group:"thirdParty"},{name:S.t("webpage.modao"),id:"insert-modao",icon:$5,group:"thirdParty"},{name:S.t("webpage.tencent"),id:"insert-tencent",icon:H5,group:"thirdParty"},{id:"insert-webPage",name:S.t("webpage.title"),icon:j5,group:"common",order:1e3}];function ch(n){return n==="insert-webPage"}async function lT(n,t){return n.doc.externalDoc.recognizeLink?n.doc.externalDoc.recognizeLink(t):null}function cT(n){return n&&!n.startsWith("http://")&&!n.startsWith("https://")&&!n.startsWith("//")?`//${n}`:n}async function aT(n){if(!n)throw new Error(S.t("webpage.dialog.errorEnterUrl"));let t=n;t.startsWith("//")&&(t=`http:${t}`);try{new URL(t)}catch{throw new Error(S.t("webpage.dialog.unsupportedUrl"))}}async function dT(n,t){const e=t.item.id,o=P4().find(l=>l.id===e),r=b("div",["webpage-content"],null);if(ch(e)){const l=b("div",["help-container"],r),c=b("div",["help-content"],l),a=b("span",["help-icon"],c);a.innerHTML=ru,b("span",[],c,S.t("webpage.dialog.helpContent"))}const{getInputValue:i,setFieldError:s}=cc(r,{required:!0,label:S.t("webpage.dialog.label"),placeholder:S.t("webpage.dialog.placeholder")});if(!ch(e)){const l=b("div",["help-link-container"],r),c=b("a",["help-link-content"],l);b("span",[],c,S.t("webpage.dialog.helpLink"));const a=b("span",["help-link-icon"],c);a.innerHTML=su;const u=n.getComponentOptions("webpage");c.href=(u==null?void 0:u.helpLink)||"",c.target="_blank"}try{const l=await new Promise(a=>{new sT(r,{title:S.t("webpage.dialog.title",{name:(o==null?void 0:o.name)||""}),async onOk(){var m;const f=cT(i());try{await aT(f);const C=await lT(n,f);a((C==null?void 0:C.url)||"")}catch(C){if(((m=C==null?void 0:C.responseData)==null?void 0:m.statusCode)===415)if(ch(e))a(f);else throw s(S.t("webpage.dialog.unsupportedUrl")),C;else throw s(C.message||""),C}}}).show()}),c={id:N(),type:"embed",embedType:"webpage",embedData:{src:l}};return n.insertBlock(t.containerId,t.blockIndex,c)}catch{return null}}const $4=y("embed-block-properties");function ah(n,t){var e;for(const o of n.blockHooks){const r=(e=o.commands)==null?void 0:e.call(o,n,t);if(!!r&&r.group==="block-comment-actions")return r.executeCommand(n,t,r.commands[0]),!0}return!1}class dh{constructor(t,e){h(this,"group","hovering-toolbar");h(this,"_commands",[{id:"edit",name:"Edit",icon:sc},{id:"add-comment",name:"Add Comment",icon:$r}]);this.editor=t,this.properties=e}get commands(){var e,o,r;if(!this.editor.isWritable())return[];const t=(e=this.properties)!=null&&e.presetIds?this._commands.filter(i=>{var s,l;return(l=(s=this.properties)==null?void 0:s.presetIds)==null?void 0:l.includes(i.id)}):[...this._commands];return(r=(o=this.properties)==null?void 0:o.extCommands)!=null&&r.length&&(t.push({id:N(),type:"separator",name:""}),t.push(...this.properties.extCommands)),t}executeCommand(t,e,o){var r,i;if(!((i=(r=this.properties)==null?void 0:r.handleExecuteCommand)!=null&&i.call(r,t,e,o))){if(o.id==="add-comment"){ah(t,e)||$4.error("failed to add comment to block");return}$4.error(`unknown command: ${JSON.stringify(o)}`),alert(o.id)}}}function uh(n,t,e){return{blockCommands:{"hovering-toolbar":new dh(n,e)}}}function uT(n){const t=n.querySelector(".editor-preview-iframe"),e=t.src;t.src="about:blank";const o=setTimeout(()=>{t.src=e,clearTimeout(o)},300);return!0}function hT(n,t){const e=n.getBlockData(t),{embedData:o}=e,r=o.src;return window.open(r,"_blank"),!0}function fT(n,t){const e=uh(n,t,{presetIds:["add-comment"],extCommands:[{id:"refresh",name:"Refresh page",icon:R5},{id:"open-page",name:"Open the original page",icon:su}],handleExecuteCommand:(r,i,s)=>{switch(s.id){case"refresh":return uT(i);case"open-page":return hT(r,i)}return!1}}),o=`[${S.t("webpage.abstract")}]`;return{...e,abstract:o}}const mT=y("webpage-embed");function gT(n,t,e,o,r,i){const{embedData:s,id:l}=e,{src:c}=s,a=n.addCustom(`webpage-${l}`,()=>new QS(n,e));d(mT,c,"The src from blockData is invalid "),a.create(n,s,t,i),n.addCustom("webpage-resizer",()=>new oT(n)),e.height&&(i.style.height=`${e.height}px`)}function pT(n,t,e){const{embedData:o,id:r}=e;return n.getCustom(`webpage-${r}`).update(n,t,o),e.height&&(t.style.height=`${e.height}px`),!0}function CT(){return{name:"WebPage",insertEmbedCommandItems:P4(),handleInsertEmptyEmbed:dT}}const hh={embedType:"webpage",createEmbedContent:gT,getBlockProperties:fT,getOptions:CT,handleUpdateBlock:pT},bT={webpage:{title:"\u7F51\u9875",youku:"\u4F18\u9177\u89C6\u9891",modao:"\u58A8\u5200",tencent:"\u817E\u8BAF\u89C6\u9891",bilibili:"Bilibili",figma:"Figma",dialog:{helpContent:"\u56E0\u76EE\u6807\u7F51\u9875\u7684\u9650\u5236\uFF0C\u90E8\u5206\u7F51\u9875\u53EF\u80FD\u65E0\u6CD5\u6210\u529F\u9884\u89C8\u3002",helpLink:"\u5982\u4F55\u83B7\u53D6\u94FE\u63A5",label:"\u7F51\u9875\u5730\u5740",placeholder:"\u8BF7\u8F93\u5165",title:"\u63D2\u5165{name}",errorEnterUrl:"\u8BF7\u8F93\u5165\u7F51\u9875\u5730\u5740",unsupportedUrl:"\u6682\u4E0D\u652F\u6301\u63D2\u5165\u8BE5\u94FE\u63A5\u5185\u5BB9"},abstract:"\u7F51\u9875"}},vT={webpage:{title:"Webpage",youku:"Youku",modao:"Modao",tencent:"Tencent Video",bilibili:"Bilibili",figma:"Figma",dialog:{helpContent:"Due to the limitation of the landing page, some pages may not be previewed successfully.",helpLink:"How to get the URL link",label:"Please enter webpage address",placeholder:"Please enter url",title:"Insert {name}",errorEnterUrl:"Please enter the webpage address",unsupportedUrl:"Unsupported url"},abstract:"Webpage"}};S.mergeLang({"zh-CN":bT,"en-US":vT});const MF="",kT={mermaid:{blockType:"embed",reg:/^```mermaid$/,data:{embedType:"mermaid"}},flowchart:{blockType:"embed",reg:/^```flowchart$/,data:{embedType:"flowchart"}},plantuml:{blockType:"embed",reg:/^```plantuml$/,data:{embedType:"plantuml"}},code:{blockType:"code",reg:/^```\S+$/},code2:{blockType:"code",reg:/^```$/},table:{blockType:"table",reg:/^\|.+\|.+\|$/},math:{blockType:"embed",reg:/^\$\$.+\$\$$/},image:{blockType:"embed",reg:/^!\[[^\]]*\]\((?<filename>.*?)(?="|\))(?<optionalPart>".*")?\)/,data:{embedType:"image"}},dividing:{blockType:"embed",reg:/^-{3,}$/,data:{embedType:"dividing-line"}},toc:{blockType:"embed",reg:/^\[toc\]/,data:{embedType:"toc"}}},yT={orderedList:{reg:/^(\d)+(\.|。)$/,blockType:"list",data:{listType:"ordered"}},unorderedList1:{reg:/^\*$/,blockType:"list",data:{listType:"unordered"}},unorderedList2:{reg:/^-$/,blockType:"list",data:{listType:"unordered"}},checkList1:{reg:/^\[\s?\]$/,blockType:"list",data:{listType:"unchecked"}},checkList2:{reg:/^\[X\]$/i,blockType:"list",data:{listType:"checked"}},image:{blockType:"embed",reg:/^!\[[^\]]*\]\((?<filename>.*?)(?="|\))(?<optionalPart>".*")?\)/,data:{embedType:"image"}}};function H4(n,t,e,o,r){const i=n.getBlockByIndex(t,e),s=Tt(Ae(n.getBlockText(i),o).left).trim(),l=r==="enter"?kT:yT;for(const[,c]of Object.entries(l)){if(!s.match(c.reg))continue;return!!n.undoManager.runInGroup(()=>{var v;const u=hl(n,i,c.blockType,{offset:o,data:c.data});if(!u)return null;const{blockData:f,focusBlockId:m}=u;if(!f)return null;const C=n.insertBlock(t,e,f,Ot(n,m!=null?m:f.id,0));return n.deleteBlock(i),(v=u.onConverted)==null||v.call(u,n,C),{newBlock:C,focusBlockId:m}})}return!1}function wT(n,t,e,o){const r=n.getBlockByIndex(t,e);return n.getBlockString(r,{boxReplacement:" "}).substring(0,o)!==">"?!1:(n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,0,o+1),n.updateBlockData(r,{quoted:!0},Ot(n,r,0))}),!0)}const BT={"#":1,"##":2,"###":3,"####":4,"#####":5,"######":6,"#######":7,"########":8};function ET(n,t,e,o){const r=n.getBlockByIndex(t,e),i=n.getBlockString(r,{boxReplacement:" "}).substring(0,o),s=BT[i];return s?(n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,0,o+1),n.updateBlockData(r,{heading:s},Ot(n,r,0))}),!0):!1}function IT(n,t,e,o){return!!(ET(n,t,e,o)||wT(n,t,e,o))}const xT=y("match-text-style");function ST(n){let t="";for(let e=n.length-1;e>=0;e--){const o=n[e];if(!o.attributes||Object.keys(o.attributes).length===0){t+=o.insert;continue}break}return t}function TT(n,t){if(n.length<t.length*2+1||!n.endsWith(t)||n.substring(0,n.length-1).endsWith(t))return-1;const e=n.substring(0,n.length-t.length),o=e.lastIndexOf(t);return o===-1?-1:o===0?0:e.substring(o-1).startsWith(t)?-1:o}const DT={"*":{type:"style",styles:["style-italic"],boxType:""},"**":{type:"style",styles:["style-bold"],boxType:""},"***":{type:"style",styles:["style-bold","style-italic"],boxType:""},"~~":{type:"style",styles:["style-line-through"],boxType:""},"`":{type:"style",styles:["style-code"],boxType:""},$$:{type:"box",styles:[],boxType:"math"}};function LT(n,t,e,o){var u,f;const r=n.getBlockByIndex(t,e),i=n.getBlockText(r),{left:s}=Ae(i,o),l=ST(s),c=ce(s)-l.length,a=Object.entries(DT);for(const[m,C]of a){const v=TT(l,m);if(v===-1)continue;const w=c+v,E=o,L=m.length,x=Tt(Kt(i,w+L,E-w-L*2).middle);if(C.type==="style"){const A={};C.styles.forEach(P=>{A[P]=!0});const O=Oi(x,A);n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,w,E-w),n.insertTextToBlock(r,w,O)})}else if(C.type==="box")try{const A=(f=(u=n.editorBoxes.getBoxClass(C.boxType)).convertFrom)==null?void 0:f.call(u,n,x);if(!A)continue;n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,w,E-w),n.insertBoxToBlock(r,w,A)})}catch(A){xT.warn(`failed to convert to box, ${A.message}`);continue}return!0}return!1}class Hc{handleAfterInsertText(t,e,o,r,i){return!!(i===" "&&(IT(t,e,o,r)||LT(t,e,o,r)))}handleBeforeKeyDown(t,e){if(!t.selection.range.isSimple())return!1;const{containerId:r,blockIndex:i,offset:s}=t.getTextPosition();if(j(t,t.getBlockByIndex(r,i))){if(_n(e,"Enter")){if(H4(t,r,i,s,"enter"))return!0}else if(_n(e,"Space")&&H4(t,r,i,s,"space"))return!0}return!1}}const MT={"en-US":{placeholder:{default:"Type \u2018/\u2019 for commands",heading:"Heading {heading}",list:"List",mention:"Quickly assign tasks @mention yourself or others",quote:"Quote"}},"zh-CN":{placeholder:{default:"\u8F93\u5165\u300C/\u300D\u5FEB\u901F\u63D2\u5165",heading:"\u6807\u9898{heading}",list:"\u5217\u8868",mention:"\u5FEB\u901F\u5206\u914D\u4EFB\u52A1\uFF0C@\u63D0\u53CA\u81EA\u5DF1\u6216\u4ED6\u4EBA",quote:"\u5F15\u7528"}}};S.mergeLang(MT);function bs(n,t){const e=ro(n,t);return!!(e.text&&ce(e.text)===0&&!t.querySelector(".inputting-insertion"))}function j4(n,t){var o;rt(t).removeAttribute("data-content-placeholder"),(o=t.querySelector("[data-type=block-tools] .block-placeholder-container"))==null||o.remove()}function jc(n,t,e){var r;if(!bs(n,t)){j4(n,t);return}const o=rt(t);if(typeof e=="string")o.setAttribute("data-content-placeholder",e);else{const i=At(t),s=(r=i.querySelector(".block-placeholder-container"))!=null?r:b("div",["block-placeholder-container"],i);s.innerHTML="",s.appendChild(e)}}function RT(n){const t=n.getAttribute("data-style-heading");return t?S.t("placeholder.heading",{heading:t}):n.getAttribute("data-style-quoted")?S.t("placeholder.quote"):null}function AT(n){const t=n.getAttribute("data-list-type");return t?t==="ordered"||t==="unordered"?S.t("placeholder.list"):S.t("placeholder.mention"):null}function F4(n){switch(it(n)){case"text":return RT(n);case"list":return AT(n);default:return null}}function OT(n){if(Uo(n))return!1;const t=z(H(n));return t?it(t)==="code":!1}function _T(n,t){var u,f;const e=it(n.selection.focusedBlock),o=t.contentPlaceholder||S.t("placeholder.default");let r=o;const i=n.selection.focusedBlock;if(e&&Di(n,e)&&i){if(OT(i))return;r=(u=F4(i))!=null?u:r}const s=n.getFirstBlock(),l=ht(s);if(!l)return;const c=ht(l);if(c&&!t.addPlaceholderToAllCurrentEmptyBlock)return;if(!c){bs(n,l)&&jc(n,l,(f=F4(l))!=null?f:o);return}const a=n.getFocusedBlock();!bs(n,a)||a!==s&&jc(n,a,r)}function NT(n,t){var r;const e=n.getFirstBlock(),o=rt(e);bs(n,e)?o.setAttribute("data-title-placeholder",(r=t.titlePlaceholder)!=null?r:"Enter document title"):o.removeAttribute("data-title-placeholder")}function PT(n){n.rootContainer.querySelectorAll("[data-content-placeholder").forEach(t=>{t.removeAttribute("data-content-placeholder")}),n.rootContainer.querySelectorAll("[data-type=block-tools] .block-placeholder-container").forEach(t=>{t.remove()})}function $T(n,t){PT(n),n.selection.range.isCollapsed()&&(NT(n,t),_T(n,t))}const OF="",HT=y("enforce-title");class vs{constructor(t,e={headingLevel:1}){h(this,"handleSelectionChange",t=>{this.applyPlaceholder(t)});this.options=e,this.handleChanged(t),this.applyPlaceholder(t),t.addListener("selectionChanged",this.handleSelectionChange)}destroy(t){t.removeListener("selectionChanged",this.handleSelectionChange)}handleBeforeKeyDown(t,e){if(!t.selection.range.isSimple())return!1;const{containerId:r,blockIndex:i,offset:s}=t.getTextPosition();if(!vs.isDocumentTitleBlock(r,i)||!_n(e,"Enter"))return!1;let l=!1,c=null;Ue(t.rootContainer)===2&&(c=mr(t.rootContainer,1),Z(t,c)===0&&(l=!0));const a=t.getFirstBlock();return t.undoManager.runInGroup(()=>{t.breakTextBlock(a,s,{forceInsertAfter:!0}),l&&c&&t.deleteBlock(c)}),!0}handleChanged(t){var e;try{const o=t.doc.getContainerBlocks(U(t.rootContainer));d(HT,o.length>0,"root container is empty");const r=o[0];if(r.type!=="text"||r.heading!==this.options.headingLevel){const i=jn("",{heading:(e=this.options.headingLevel)!=null?e:1});t.insertBlock(U(t.rootContainer),0,i);return}if(o.length>1)return;t.insertTextBlock("",U(t.rootContainer),1,{newRange:t.selection.range.toDocRange()})}finally{this.applyPlaceholder(t)}}handleRemoteChanged(t){setTimeout(()=>{this.applyPlaceholder(t)})}handleUpdateCompositionText(t){this.applyPlaceholder(t)}applyPlaceholder(t){var e,o;!((e=this.options)!=null&&e.titlePlaceholder)&&!((o=this.options)!=null&&o.contentPlaceholder)||$T(t,this.options)}static isDocumentTitleBlock(t,e){return t==="root"&&e===0}}const z4=y("code-dom");function tr(n){return it(n)==="code"}function U4(n,t,e){e.language?t.setAttribute("data-language",e.language):t.removeAttribute("data-language"),e.nowrap?F(t,"wrap"):M(t,"wrap")}function V4(n){const t=n.closest("div[data-type=editor-block][data-block-type=code]");return d(z4,t,"no parent code block"),d(z4,tr(t),"not a code block"),t}const Fc={plain:{name:"Plain Text",aliases:["txt","text"]},abap:{name:"ABAP",aliases:["abap"]},arduino:{name:"Arduino",aliases:["ino"]},bash:{name:"Bash",aliases:["sh","shell"]},basic:{name:"BASIC",aliases:["bas"]},c:{name:"C",aliases:["c"]},clojure:{name:"Clojure",aliases:["clj"]},cofeescript:{name:"CoffeeScript",aliases:["coffee"]},cpp:{name:"C++",aliases:["cpp","cxx"]},csharp:{name:"C#",aliases:["cs"]},css:{name:"CSS",aliases:["css"]},dart:{name:"Dart",aliases:["dart"]},diff:{name:"Diff",aliases:["diff","patch"]},docker:{name:"Docker",aliases:["dockerfile"]},elixir:{name:"Elixir",aliases:["ex","exs"]},elm:{name:"Elm",aliases:["elm"]},erlang:{name:"Erlang",aliases:["erl"]},flow:{name:"Flow",aliases:["flow"]},fortran:{name:"Fortran",aliases:["f","for","f77","f90"]},fsharp:{name:"F#",aliases:["fsharp"]},gherkin:{name:"Gherkin",aliases:["feature"]},glsl:{name:"GLSL",aliases:["glsl"]},go:{name:"Go",aliases:["go"]},graphql:{name:"GraphQL",aliases:["graphql"]},groovy:{name:"Groovy",aliases:["groovy"]},haskell:{name:"Haskell",aliases:["hs"]},java:{name:"Java",aliases:["java"]},js:{name:"JavaScript",aliases:["js","jsx"]},json:{name:"JSON",aliases:["json"]},julia:{name:"Julia",aliases:["jl"]},kotlin:{name:"Kotlin",aliases:["kt","ktm","kts"]},latex:{name:"LaTeX",aliases:["tex"]},less:{name:"LESS",aliases:["less"]},lisp:{name:"Lisp",aliases:["lisp"]},livescript:{name:"LiveScript",aliases:["ls"]},lua:{name:"Lua",aliases:["lua"]},makefile:{name:"Makefile",aliases:["mk","mak"]},markdown:{name:"Markdown",aliases:["md","mkdown","mkd"]},markup:{name:"HTML / XML",aliases:["html","htm","xml","xsd","xsl","xslt","wsdl"]},matlab:{name:"MATLAB",aliases:["matlab"]},mermaid:{name:"Mermaid",aliases:["mermaid"]},nix:{name:"Nix",aliases:["nix"]},objectivec:{name:"Objective-C",aliases:["m","mm"]},ocaml:{name:"OCaml",aliases:["ml"]},pascal:{name:"Pascal",aliases:["pas"]},perl:{name:"Perl",aliases:["pl","pm"]},php:{name:"PHP",aliases:["php"]},powershell:{name:"PowerShell",aliases:["ps","ps1"]},prolog:{name:"Prolog",aliases:["plg"]},protobuf:{name:"Protocol Buffers",aliases:["proto"]},python:{name:"Python",aliases:["py"]},r:{name:"R",aliases:["r"]},reason:{name:"Reason",aliases:["re","rei"]},ruby:{name:"Ruby",aliases:["rb"]},rust:{name:"Rust",aliases:["rs"]},sass:{name:"Sass",aliases:["sass"]},scala:{name:"Scala",aliases:["scala"]},scheme:{name:"Scheme",aliases:["scm","sm"]},scss:{name:"SCSS",aliases:["scss"]},solidity:{name:"Solidity",aliases:["sol"]},sql:{name:"SQL",aliases:["sql"]},swift:{name:"Swift",aliases:["swift"]},typescript:{name:"TypeScript",aliases:["ts","tsx"]},vbnet:{name:"VB.Net",aliases:["vbnet"]},verilog:{name:"Verilog",aliases:["v"]},vhdl:{name:"VHDL",aliases:["vhdl"]},"visual-basic":{name:"Visual Basic",aliases:["vb","vba"]},wasm:{name:"WebAssembly",aliases:["wasm"]},yaml:{name:"YAML",aliases:["yaml"]}};function jT(n){const t=n.toLocaleLowerCase();let e="plain";return Object.entries(Fc).forEach(([o,r])=>{(o===t||r.aliases.includes(t)||r.name.toLocaleLowerCase()===t)&&(e=o)}),e}const FT=y("convert-to-code");function zT(n,t){if(!j(n,t))return null;const e={id:N(),type:"text",text:[]},o=N();n.doc.localInsertChildContainer(o,[e]);const r=n.getBlockData(t).text;d(FT,r,"no text");let i=Tt(r);i.startsWith("```")&&(i=i.substring(3));const s=jT(i);return{blockData:{id:N(),type:"code",language:s,children:[o]},focusBlockId:e.id}}const _F="",fh=y("code-block-child-container");function Zr(n){d(fh,tr(n),"not a code block");const e=rt(n).querySelector(":scope > div.editor-code-root > div.code-text-root [data-type=editor-container].child");return d(fh,e,"no code text container"),e}function Yr(n){d(fh,tr(n),"not a code block");const e=rt(n).querySelector(":scope > div.editor-code-root > div.code-caption-root [data-type=editor-container].child");return e||null}function zc(n){const t=[Zr(n)],e=Yr(n);return e&&t.push(e),t}function Uc(n){const t=H(n),e=z(t);return e?tr(e)?t===Zr(e):it(n)==="code":!1}const mh=y("code-caption");function UT(n,t){if(n.readonly)return;const e=Yr(t);if(e){const c=Qt(e);n.selection.selectBlock(c,0);return}const o=pn(n.doc),r=n.getBlockData(t);d(mh,r.children.length===1,"code block should have only one child");const i={...r,children:[r.children[0],o]};n.updateBlockData(t,i);const s=n.getContainerById(o),l=Qt(s);n.selection.selectBlock(l,0)}function q4(n,t){const e=H(t);if(Ct(e))return!1;const o=z(e);if(d(mh,o,"no parent block"),!tr(o))return!1;const i=Yr(o);return e===i}function VT(n,t){if(n.readonly||!Yr(t))return;const o=Zr(t),r=Gt(o);n.selection.selectBlock(r,Z(n,r));const i=n.getBlockData(t);d(mh,i.children.length===2,"code block should have only one child");const s=i.children[1],l={...i,children:[i.children[0]]};n.updateBlockData(t,l),n.deleteChildContainers([s])}const qT=y("paste-in-table-block");class WT{constructor(t){this.editor=t,setTimeout(()=>{t.input.addHandler(this)})}destroy(){}async handleBeforePaste(t,e){if(!t.selection.range.isSimple())return!1;const o=t.selection.range.start,r=t.getBlockById(o.blockId),i=H(r);if(Ct(i))return!1;const s=z(i);if(d(qT,s,"no parent block"),!tr(s)||q4(t,r))return!1;if(!e.clipboardData)return!0;const l=e.clipboardData.getData("text/plain");if(!l)return!0;const c=oo(l);return t.undoManager.runInGroup(()=>{t.clearSelectedContents(),t.insertDoc(r,o.offset,c)}),!0}}function GT(n){n.addCustom("code-block-paste-event",t=>new WT(t))}class ZT{constructor(t){h(this,"id","CodeBlockCommandProvider");setTimeout(()=>{t.editorCommandProviders.registerCommandProvider(this)})}destroy(){}getAvailableCommands(){return[]}executeCommand(){return!1}filterCommands(t,e,o,r){if(Uc(e))return[]}beforeExecuteCommand(t,e,o,r,i){return!!Uc(e)}}function YT(n){n.addCustom("code-block-command-provider",t=>new ZT(t))}const QT=y("code-caption-input-handler");function gh(n){if(!n.selection.range.isSimple())return null;const t=n.selection.range.start;if(!t.isSimple())return null;const e=n.getBlockById(t.blockId);return q4(n,e)?e:null}function KT(n){const t=gh(n);if(!t)return!1;const e=V4(t),o=ht(e);return o?(n.selection.selectBlock(o,0),!0):(n.insertTextBlock("",U(H(e)),K(e)+1),!0)}function JT(n){const t=gh(n);if(!t)return!1;if(wt(n,t)){const e=V4(t);return VT(n,e),!0}return!1}class ph{constructor(t){setTimeout(()=>{t.input.addHandler(this)})}destroy(){}handleBeforeKeyDown(t,e){return e.key==="Enter"?KT(t):e.key==="Backspace"?JT(t):!1}async handleBeforePaste(t,e){const o=gh(t);if(!o)return!1;if(!e.clipboardData)return!0;const r=e.clipboardData.getData("text/plain");return r&&t.undoManager.runInGroup(()=>{t.clearSelectedContents();const i=t.selection.range.start;d(QT,i.isSimple(),"not simple position"),t.insertTextToBlock(o,i.offset,r)}),!0}static init(t){t.addCustom("code-block-caption-input-handler",e=>new ph(e))}}const XT=`
450
450
  <svg fill="currentColor" focusable="false" viewBox="0 0 24 24" aria-hidden="true" tabindex="-1">
451
451
  <path d="M8.12 9.29 12 13.17l3.88-3.88c.39-.39 1.02-.39 1.41 0 .39.39.39 1.02 0 1.41l-4.59 4.59c-.39.39-1.02.39-1.41 0L6.7 10.7a.9959.9959 0 0 1 0-1.41c.39-.38 1.03-.39 1.42 0z"></path>
452
452
  </svg>`,tD=`
@@ -457,7 +457,7 @@ c0-27.6-22.4-50-50-50H662c-27.6,0-50,22.4-50,50H412c0-27.6-22.4-50-50-50h-45.8C3
457
457
  <svg focusable="false" viewBox="0 0 24 24" aria-hidden="true" tabindex="-1">
458
458
  <path fill="currentColor" d="M4 19h6v-2H4v2zM20 5H4v2h16V5zm-3 6H4v2h13.25c1.1 0 2 .9 2 2s-.9 2-2 2H15v-2l-3 3 3 3v-2h2c2.21 0 4-1.79 4-4s-1.79-4-4-4z"></path>
459
459
  </svg>
460
- `;function nD(n,t,e){const r={...n.getBlockData(t),language:e};n.updateBlockData(t,r)}function oD(n,t,e){const r={...n.getBlockData(t),nowrap:e};n.updateBlockData(t,r)}const Qr=y("code-block-header"),rD=Object.entries(Fc).map(([n,t])=>({id:n,name:t.name,language:t}));function iD(n,t){if(t){const e=n,{editor:o,codeBlock:r}=e.custom;nD(o,r,t.id);const i=r.querySelector(".code-block-header .language-select .name-label");i.innerText=t.name}}function sD(n,t,e){n.addCustom("code-header-language-select-dropdown",i=>{const s=new f5(rD,i.rootElement,{placeholder:"Search for a language..."});return s.onSelected=iD,s});const o=b("div",["language-select"],null);b("span",["name-label"],o,e);const r=b("span",["arrow-icon"],o);return r.innerHTML=XT,n.domEvents.addEventListener(o,"click",(i,s)=>{const c=s.target.closest(".language-select"),a=z(c);d(Qr,a,"no parent block"),d(Qr,it(a)==="code","not a code block");const u=i.getBlockData(a),f=i.getCustom("code-header-language-select-dropdown");f.custom={codeBlock:a,editor:i},f.setSelectedId(u.language),f.show(c),M(t,"editing-language"),f.onHide=()=>{F(t,"editing-language")}}),o}function lD(){return b("div",["code-header-spacer"],null)}function cD(n,t){const e=t.target,o=e.closest(".code-header-button");d(Qr,o,"no button");const r=z(e);d(Qr,r,"no parent block");const i=o.getAttribute("data-id");if(d(Qr,it(r)==="code","not a code block"),i==="wrap"){const s=n.getBlockData(r);oD(n,r,!s.nowrap);return}if(i==="copy"){const s=Zr(r),l=od(n,V(s)),c=o2(n,l);navigator.clipboard.writeText(c).then(()=>{const a=o.getBoundingClientRect();m5("Copied to clipboard",{position:{x:a.x+a.width/2,y:a.bottom+30}})}).catch(a=>{Qr.error(a.message)});return}i==="caption"&&VT(n,r)}function Ch(n,t,e,o){const r=b("button",["code-header-button"],null);if(r.setAttribute("data-id",t),o){const i=b("span",["button-icon"],r);i.innerHTML=o}if(e){const i=b("span",["button-label"],r);i.innerHTML=e}return n.domEvents.addEventListener(r,"click",cD),r}function aD(n,t,e){const o=At(t),r=b("div",["code-block-header"],o),i=Fc[e.language]||Fc.plain;r.appendChild(sD(n,t,i.name)),r.appendChild(lD()),r.appendChild(Ch(n,"copy","Copy",tD)),r.appendChild(Ch(n,"wrap","Wrap",eD)),r.appendChild(Ch(n,"caption","Caption",null))}function dD(n,t,e,o){ph.init(n);const r=o.children,i=eo(e,"div");i.setAttribute("data-language",o.language||"text"),V4(n,e,o);const s=b("div",["editor-code-root"],i),l=b("div",["code-text-root"],s);if(n.createChildContainer(t,l,r[0]),r.length===2){const c=b("div",["code-caption-root"],s);n.createChildContainer(t,c,r[1])}return aD(n,e,o),i}function uD(n){const t={id:N(),type:"text",text:[]},e=N();return n.doc.localInsertChildContainer(e,[t]),{blockData:{id:N(),type:"code",language:"plain",children:[e]},focusBlockId:t.id}}const En=y("list-block");function hD(n,t,e,o,r){GT(n),YT(n),d(En,r.type==="code","invalid block data type");const i=r;return d(En,i.children,"invalid block data children"),d(En,i.children.length===1||i.children.length===2,"invalid block data children length"),M(o,"drag-preview-element"),dD(n,t,o,i)}function fD(n){return 1}function mD(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t)||!fn(r))return null;const i=zc(t);if(!fn(r))return null;const s=r;if(i.indexOf(s)===-1||Ve(s)>1)return null;const l=bt(t,V(s));return new Ye(n,{anchor:l,focus:l})}function gD(n,t,e,o){return null}function pD(n,t){return n.getBoundingClientRect()}function CD(n,t,e,o){if(e.isSimple()){d(En,o.isSimple(),"from is simple position but to is not simple position"),En.debug("full select list"),M(t,"full-selected");return}d(En,!o.isSimple(),"from is complex position but end is simple position");const r=e,i=o;d(En,r.blockId===i.blockId,"only allow update one table selection"),zc(t).forEach(l=>{const c=V(l);(c===r.childContainerId||c===i.childContainerId)&&M(l,"selected")})}function bD(n){n.rootContainer.querySelectorAll('[data-type="editor-block"][data-block-type="code"]').forEach(t=>{F(t,"full-selected"),t.querySelectorAll("div[data-type=editor-container].child.selected").forEach(e=>{F(e,"selected")})})}function vD(n,t){return zc(t)}function kD(n,t,e,o,r){if(o==="ArrowDown"||o==="ArrowRight"){if(e===Zr(t))return Yr(t)}else if(e===Yr(t))return Zr(t);return null}function yD(n,t,e,o){const r=zc(t),i=r.map(V),s=i.indexOf(e.childContainerId),l=i.indexOf(o.childContainerId);d(En,s!==-1,"invalid start pos"),d(En,l!==-1,"invalid end pos");const c=[r[s]];return s!==l&&c.push(r[l]),c}function wD(n,t,e){d(En,tr(t),"invalid block type"),V4(n,t,e)}async function BD(n,t){const e=uD(n);if(!e)return null;const{blockData:o,focusBlockId:r}=e;return n.insertBlock(t.containerId,t.blockIndex,o,Ot(n,r,0))}function ED(n){return{name:"CodeBlock",insertBlockCommandItems:[{id:"insert-code",name:S.t("code.title"),icon:q5,order:300,group:"common"}],handleInsertEmptyBlock:BD}}function ID(){return{abstract:`[${S.t("code.abstract")}]`}}const ks={blockType:"code",blockKind:"complex",createBlockContent:hD,getBlockTextLength:fD,getRangeFromPoint:mD,moveCaret:gD,getCaretRect:pD,updateSelection:CD,clearSelection:bD,getChildContainers:vD,getNextContainer:kD,getSelectedContainers:yD,convertFrom:zT,handleBlockElementUpdated:wD,getOptions:ED,getBlockProperties:ID},bh={..._i,blockType:"code-line"};function xD(n){if(!n.isWritable())return!1;const t=n.getFocusedBlock();if(!!Vc(t)){if(n.selection.range.isCollapsed()){const e=n.selection.range.start;return n.insertTextToBlock(t,e.offset," "),!0}return n.undoManager.runInGroup(()=>{Qe(n).forEach(o=>{n.insertTextToBlock(o.block,0," ")})}),!0}}function SD(n){if(!n.isWritable())return!1;const t=n.getFocusedBlock();if(!Vc(t))return;const e=[" "," "," "," "];return n.undoManager.runInGroup(()=>{Qe(n).forEach(r=>{const i=Tt(n.getBlockText(r.block));for(let s=0;s<e.length;s++){const l=e[s];if(i.startsWith(l)){n.deleteTextFromBlock(r.block,0,l.length);break}}})}),!0}const TD={Tab:xD,"Shift+Tab":SD},ys=y("code-text-decorate");class ws{decorateText(t,e,o){var C;if(d(ys,e.length>0,"invalid path"),e.length===1)return{};const r=e[e.length-2];if(t.doc.getBlockData(r.containerId,r.blockIndex).type!=="code")return{};const s=o;if(s.length===0)return{};const l=Tt(s),c=t.doc.getBlockData(r.containerId,r.blockIndex),a=bi.default.tokenize(l,(C=bi.default.languages[c.language])!=null?C:bi.default.languages.plain),u=(v,w)=>{if(d(ys,v,"no token"),typeof v=="string")return[{insert:v,attributes:Y.default(w)}];d(ys,v instanceof bi.default.Token,"invalid token type");const E=v.content,L=Y.default(w);return L[`style-code-${v.type}`]=!0,typeof E=="string"?[{insert:E,attributes:L}]:Array.isArray(E)?E.map(O=>u(O,L)).flat():(d(ys,E instanceof bi.default.Token,"invalid token"),u(E,L))},m=a.map(v=>u(v,{})).flat();return d(ys,ce(m)===ce(s),"failed to highlight code, text length mismatch"),{text:m}}}const DD={code:{title:"\u4EE3\u7801",abstract:"\u4EE3\u7801"}},LD={code:{title:"Code",abstract:"Code"}};S.mergeLang({"zh-CN":DD,"en-US":LD});const MD=y("image-data"),RD=1e3,AD=400,OD=10;function Bs(n){return n.src.startsWith("empty:")||!n.src}function _D(n){return n.src.startsWith("http:")||n.src.startsWith("https:")}function W4(n){return`${Ci.default(n)}_width`}function G4(n){return`${Ci.default(n)}_height`}function Z4(n){return`${n}_flex`}function Es(n){if(n.every(r=>typeof r.flex=="number"&&r.flex))return;const t=100,o=n.map(r=>r.width/(r.height/t)).reduce((r,i)=>r+i,0);n.forEach(r=>{const i=r.width/(r.height/t);r.flex=i/o})}function Kr(n){const t=(r,i)=>{r||(r=`empty:${i}`);const s=W4(r),l=G4(r),c=Z4(i);let a=n[s],u=n[l],f=n[c];return typeof a=="string"&&(a=Number.parseInt(a,10)),typeof u=="string"&&(u=Number.parseInt(u,10)),typeof f=="string"&&(f=Number.parseInt(f,10)),a&&u?{src:r,width:a,height:u,flex:f,virtualSize:!1}:(a=RD,u=AD,{src:r,width:a,height:u,flex:f,virtualSize:!0})};let e=[];const o=n.src;return Array.isArray(o)?e=o.map(t):typeof o=="string"&&(e=o.split("|").map(t)),Es(e),e}function ln(n){var o;const t=n.embedData;return Kr(n.embedData).length>1?100:(o=t.widthPercent)!=null?o:100}function ND(n,t){if(Kr(t.embedData).length>1)return"100%";const o=ln(t);return`${n.rootContainer.getBoundingClientRect().width*o/100}px`}function de(n,t){const o={src:n.map(r=>r.src).join("|"),widthPercent:t};return n.forEach((r,i)=>{if(r.width&&r.height&&!r.virtualSize){const l=r.src||`empty:${i}`,c=W4(l);o[c]=r.width;const a=G4(l);o[a]=r.height}d(MD,r.flex,"no image flex");const s=Z4(i);o[s]=r.flex}),o}function PD(n,t,e){const o=Kr(t.embedData),r=o.length===1?n.rootContainer:e,i=ln(t);let s=r.getBoundingClientRect().width*(i/100);if(s-=Number.parseFloat(window.getComputedStyle(r).paddingLeft)+Number.parseFloat(window.getComputedStyle(r).paddingRight),o.length===1){const a=o[0];return a.height/(a.width/s)}s-=(o.length-1)*OD;const l=o.reduce((a,u)=>a+u.flex,0);let c=0;for(const a of o){const f=s*a.flex/l/a.width*a.height;c=Math.max(f,c)}return c}function $D(n){return n.reduce((e,o)=>e+o.flex,0)}const HD=y("image-dom");function Y4(n){return n.querySelector(".uploading-progress-mask")}function jD(n){const t=Y4(n);if(t)return t;const e=b("div",["uploading-progress-mask"],n),o=b("div",["uploading-progress-bar"],e);return b("div",["uploading-progress-bar-value"],o),o}function FD(n){const e=jD(n).querySelector(".uploading-progress-bar-value");return d(HD,e,"no progress value"),e}function Q4(n,t){const e=FD(n);e.style.width=`${t}%`}function zD(n){var t;(t=Y4(n))==null||t.remove()}function VD(n){let t;return n.forEach((e,o)=>{o.toLocaleLowerCase()==="content-type"&&(t=e)}),t!=null?t:""}async function UD(n){try{const t=await fetch(n,{credentials:"same-origin"}),e=await t.blob(),o=VD(t.headers).toLocaleLowerCase();let r="";if(o){const s=Of.default[o].extensions;s&&s.length>0&&(r=s[0])}return new File([e],`${Date.now()}.${r}`,{type:o})}catch{return null}}function er(n,t){const e=typeof t=="string"?t:G(t);return n.getCustom(`image-${e}`)}function Uc(n,t){if(!t||!(t instanceof Node))return null;const e=z(t);return e?er(n,e):null}function Gn(n){return Array.from(n.querySelectorAll(".image-container"))}function qc(n,t,e,o){const r=e!=null?e:n.findBlockById(t.id);if(!r)return;const i=o||H(r),s=ND(n,t),l=PD(n,t,i),c=rt(r);c.style.width=s;const a=r.querySelector(".images");!a||(a.style.height=`${l}px`)}const vh=y("table-resize-drag-drop");class qD{constructor(t,e,o,r){h(this,"cursor","col-resize");h(this,"initWidths");this.editor=t,this.elem=e,this.data=o,this.mouseDownEvent=r;const i=this.data.block,l=er(this.editor,i).getImages(),c=this.data.splitterIndex;d(vh,c>=0&&c<l.length-1,`invalid splitter index: ${c}`);const u=Gn(i).map(f=>f.getBoundingClientRect().width);this.initWidths=u}onDragStart(t,e,o){if(!this.editor.isWritable())return;const r=this.data.block;er(this.editor,r).setResizing(!0)}onDragging(t,e,o,r,i){const s=this.data.block,l=er(this.editor,s),c=Y.default(l.getImages()),a=this.data.splitterIndex;d(vh,a>=0&&a<c.length-1,`invalid splitter index: ${a}`);const u=this.initWidths[a],f=this.initWidths[a+1];if(u+f<100)return;let m=r;u+m<50&&(m=50-u),f-m<50&&(m=f-50);const w=[...this.initWidths];w[a]+=m,w[a+1]-=m;const E=Gn(s);d(vh,E.length===c.length,"invalid image data");const L=w.reduce((O,P)=>O+P,0);for(let O=0;O<c.length;O++){const P=w[O]/L;c[O].flex=P,E[O].style.flexGrow=`${P}`}const x=Y.default(this.editor.getBlockData(s)),A=de(c,ln(x));x.embedData=A,qc(this.editor,x,s,null)}onDragEnd(t,e,o,r,i){const s=this.data.block,l=er(this.editor,s),a=Gn(s).map(u=>Number.parseFloat(u.style.flexGrow));l.updateFlex(a),l.setResizing(!1)}}function K4(n){var t;return!n||!(n instanceof HTMLElement)?null:lt(n,"image-splitter")?n:(t=n.closest(".image-splitter"))!=null?t:null}function WD(n,t){var s;const e=K4(t.target);if(!e)return;const o=z(e);if(!o)return;er(n,o).setSelectedIndex(-1),n.selection.selectBlock(o,0);const r=Number.parseInt((s=e.getAttribute("data-index"))!=null?s:"",10);if(Number.isNaN(r)||typeof r!="number")return;const i={block:o,splitterIndex:r};Za(new qD(n,e,i,t))}function GD(n,t){t.preventDefault(),t.stopPropagation();const e=K4(t.target);if(!e)return;const o=z(e);!o||er(n,o).resetFlex()}function ZD(n,t,e,o){const r=b("div",["image-splitter"],e);b("div",["image-splitter-indicator"],r),r.setAttribute("data-index",`${o}`),n.domEvents.addEventListener(r,"mousedown",WD),n.domEvents.addEventListener(r,"dblclick",GD)}const YD=y("image-item");function J4(n){return!n||!(n instanceof Node)?null:z(n)}function X4(n){const t=J4(n);return t?Gn(t):[]}function kh(n){if(!n||!(n instanceof Node))return null;const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest(".image-container");return e||null}function Is(n){const t=kh(n);return t?X4(n).indexOf(t):-1}async function QD(n,t){const e=Uc(n,t.target);if(!e)return;const o=Is(t.target);if(o===-1)return;const r=t.target;if(!(r instanceof HTMLImageElement))return;const i=e.getImages()[o];if(i.virtualSize&&e.fixImageSize(o,r),!i||!_D(i)||i.downloading)return;i.downloading=!0;const s=await UD(i.src);s?e.replaceImage(o,s):YD.warn(`failed to download image: ${i.src}`)}function KD(n,t,e){if(t.querySelector(".load-error"))return;const r=e.src.startsWith("http:")||e.src.startsWith("https:"),i=b("div",["load-error"],t),s=b("div",["error-icon"],i);s.innerHTML=iu;const l=b("div",["error-message"],i);r?(l.innerHTML=S.t("image.load.remote.failed"),n.domEvents.addEventListener(i,"click",(c,a)=>{a.preventDefault(),a.target instanceof HTMLElement&&a.target.tagName==="A"&&window.open(e.src,"_blank")})):(l.innerHTML=S.t("image.load.failed"),n.domEvents.addEventListener(i,"click",(c,a)=>{a.preventDefault(),a.target instanceof HTMLElement&&a.target.tagName==="A"&&eL(c,a.target)}))}function JD(n,t){const e=Uc(n,t.target);if(!e)return;const o=Is(t.target);if(o===-1)return;const r=e.getImages()[o];if(!r)return;const i=kh(t.target);!i||(M(i,"error","error-load"),KD(n,i,r))}function XD(n,t,e){if(t.querySelector(".upload-error"))return;const r=b("div",["upload-error"],t),i=b("div",["error-icon"],r);i.innerHTML=iu;const s=b("div",["error-message"],r);s.innerHTML=S.t("image.upload.failed"),n.domEvents.addEventListener(r,"click",(l,c)=>{if(c.preventDefault(),!c.target||!(c.target instanceof Element)||c.target.tagName!=="A")return;const a=Uc(l,c.target),u=Is(c.target);!a||u===-1||a.replaceImage(u,e)})}function t6(n,t,e,o,r){const i=Gn(t)[e];!i||(M(i,"error","error-upload"),XD(n,i,r))}function e6(n,t,e,o,r,i){const s=b("div",["image-container"],t);if(s.setAttribute("data-src",e.src),i.length>1&&(s.style.flexShrink=`${e.flex}`,s.style.flexGrow=`${e.flex}`),r===o&&M(s,"active"),Bs(e)){M(s,"empty");const c=b("div",["upload-image-icon"],s);return c.innerHTML=T5,s}const l=b("img",["editor-image"],s);if(l.src=n.doc.buildResourceUrl(e.src),l.draggable=!0,!Bs(e)&&!n.readonly&&n.domEvents.addEventListener(l,"load",QD),n.domEvents.addEventListener(l,"error",JD),e.src.startsWith("https:")||e.src.startsWith("http:")){const c=b("div",["image-warning"],s);c.innerHTML=ru,c.setAttribute(`data-editor-tooltip-${n.clientId}`,S.t("image.load.remote.tooltip"))}return s}function tL(n,t,e,o,r){const i=b("div",["images"],e);return o.forEach((s,l)=>{l>0&&ZD(n,t,i,l-1),e6(n,i,s,l,r,o)}),o.length>1&&M(t,"multi"),i}function n6(n,t,e,o,r,i){const l=Array.from(t.querySelectorAll(".image-container"))[o];if(!l)return;const c=e6(n,null,e,o,r,i);l.insertAdjacentElement("beforebegin",c),l.remove()}function xs(n,t){return Gn(n)[t]}function eL(n,t){const e=J4(t);if(!e)return;const o=Is(t);if(o===-1)return;const r=Uc(n,t);if(!r)return;const i=r.getImages()[o];n6(n,e,i,o,r.getSelectedIndex(),r.getImages())}function cn(n){return it(n)==="embed"&&De(n)==="image"}async function o6(n){return new Promise((t,e)=>{const o=new Image;o.onload=()=>{t({width:o.naturalWidth,height:o.naturalHeight})},o.onerror=e,o.src=n})}async function nL(n){const t=await nl(n);return o6(t)}const r6=y("image-object");class Ft{constructor(t,e){h(this,"images",[]);h(this,"selectedIndex",-1);h(this,"blockResizer");h(this,"resizing",!1);h(this,"parentContainerResizerObserver",null);h(this,"handleMouseDown",async(t,e)=>{const o=Is(e.target);if(o===-1)return;const r=this.images[o];Bs(r)||this.setSelectedIndex(o)});h(this,"handleEditorResize",()=>{if(this.isEmpty()||this.resizing)return;const t=this.editor.findBlockById(this.blockData.id);!t||qc(this.editor,this.blockData,t,null)});h(this,"handleResizing",(t,e)=>{const o=this.editor.findBlockById(this.blockData.id);if(!o)return;const i=this.editor.rootContainer.getBoundingClientRect().width,s=o.getBoundingClientRect();let l=e.width>s.width?s.width:e.width;l<50&&(l=50);const c=l*100/i;this.blockData.embedData.widthPercent=c,qc(this.editor,this.blockData,o,null)});h(this,"handleResized",t=>{const e=this.editor.findBlockById(this.blockData.id);if(!e)return;const o=de(this.images,ln(this.blockData));this.editor.updateEmbedData(e,o),this.blockResizer.enableResize(e)});h(this,"fixImageSizes",ie.default(()=>{const t=this.editor.findBlockById(this.blockData.id);if(!t)return;const e=de(this.images,ln(this.blockData));this.editor.updateEmbedData(t,e)},1e3));this.editor=t,this.blockData=e,this.blockResizer=new $c(this.editor,{resize:["top-left","top-right","bottom-left","bottom-right"]}),this.blockResizer.addListener("resizing",this.handleResizing),this.blockResizer.addListener("resized",this.handleResized),this.images=Kr(this.blockData.embedData)}destroy(){var t;this.blockResizer.removeAllListeners(),this.blockResizer.destroy(),this.editor.domEvents.removeEventListener(null,null,this.handleMouseDown),(t=this.parentContainerResizerObserver)==null||t.disconnect()}createContent(t,e,o){const r=tL(this.editor,e,o,this.images,this.selectedIndex);this.editor.domEvents.addEventListener(o,"mousedown",this.handleMouseDown),this.editor.addListener("resize",this.handleEditorResize),qe(t)&&(this.parentContainerResizerObserver=new ResizeObserver(this.handleEditorResize),this.parentContainerResizerObserver.observe(t)),this.isEmpty()?M(r,"empty"):qc(this.editor,this.blockData,e,t),setTimeout(()=>{const i=this.editor.findBlockById(this.blockData.id);i&&this.blockResizer.update(i)})}getImages(){return this.images}getWidthPercent(){return ln(this.blockData)}isEmpty(){return this.images.length===1&&Bs(this.images[0])}setResizing(t){this.resizing=t}getSelectedIndex(){return this.selectedIndex}getBlock(){return this.editor.findBlockById(this.blockData.id)}setSelectedIndex(t){const e=this.getBlock();if(!e||t===this.selectedIndex)return;if(this.selectedIndex!==-1){const r=xs(e,this.selectedIndex);r&&F(r,"active")}this.selectedIndex=t;const o=xs(e,t);o&&M(o,"active")}async requestUploadImage(t){const e=this.editor.findBlockById(this.blockData.id);if(!e)return;const o=xs(e,t);if(lt(o,"error"))return;const r=await fr("image/*");await this.replaceImage(t,r)}tryEnableResizer(){const t=this.editor.findBlockById(this.blockData.id);if(!t||!this.editor.isWritable())return;const e=xs(t,0);!this.isEmpty()&&this.images.length===1&&!lt(e,"error")&&this.blockResizer.enableResize(t)}disableResizer(){this.blockResizer.disableResize()}fixImageSize(t,e){const o=this.images[t];Bs(o)||(o.width=e.naturalWidth,o.height=e.naturalHeight,o.virtualSize=!1,this.fixImageSizes())}removeImage(t){const e=this.editor.findBlockById(this.blockData.id);if(!e||t===-1||t>=this.images.length)return!1;const o=Y.default(this.images);o.splice(t,1),o[0].flex=NaN,Es(o),this.selectedIndex>=o.length&&(this.selectedIndex=o.length-1);const r=de(o,ln(this.blockData));return this.editor.updateEmbedData(e,r),!0}async replaceImage(t,e){const o=this.editor.findBlockById(this.blockData.id);if(!o)return!1;try{const i=await nl(e),s=this.images[t];if(s.virtualSize){const{width:c,height:a}=await o6(i);s.width=c,s.height=a,s.virtualSize=!1;const u=de(this.images,ln(this.blockData));this.editor.updateEmbedData(o,u)}const l={...s,src:i};n6(this.editor,o,l,t,this.selectedIndex,this.images),setTimeout(()=>{this.blockResizer.update(o)})}catch(i){return t6(this.editor,o,t,i,e),!1}const r=xs(o,t);if(!r)return!1;M(r,"uploading"),Q4(r,0);try{const i=await this.editor.doc.uploadResource(e,{onProgress:c=>{Q4(r,c)}});F(r,"uploading"),this.images[t].src=i.resourceId;const s=this.editor.findBlockById(this.blockData.id);if(!s)return!1;const l=de(this.images,ln(this.blockData));return this.editor.updateEmbedData(s,l),!0}catch(i){r6.error(i);const s=this.editor.findBlockById(this.blockData.id);return s&&(F(r,"uploading"),zD(r),t6(this.editor,s,t,i,e)),!1}}updateFlex(t){const e=this.editor.findBlockById(this.blockData.id);if(!e)return;d(r6,t.length===this.images.length,"invalid flex");for(let r=0;r<this.images.length;r++)this.images[r].flex=t[r];const o=de(this.images,ln(this.blockData));this.editor.updateEmbedData(e,o)}resetFlex(){const t=this.editor.findBlockById(this.blockData.id);if(!t)return;const e=Y.default(this.images);e[0].flex=NaN,Es(e);const o=de(e,ln(this.blockData));this.editor.updateEmbedData(t,o)}setData(t){this.blockData=t,this.images=Kr(t.embedData)}static create(t,e){const o=t.addCustom(`image-${e.id}`,()=>new Ft(t,e));return o.setData(e),o}static getImageObject(t,e){let o;return typeof e=="string"?o=e:o=G(e),t.getCustom(`image-${o}`)}}const NF="";function i6(n,t,e){const o=Ft.getImageObject(n,t),r=Y.default(o.getImages());if(r.length===1){n.deleteBlock(t);return}if(e===-1||e>=r.length)return;const i=$D(r);if(r.splice(e,1),r.length===1){const l=r[0],c=100*(l.flex/i);l.flex=1;const a=de([l],c);n.updateEmbedData(t,a);return}r[0].flex=NaN,Es(r);const s=de(r,o.getWidthPercent());n.updateEmbedData(t,s)}function oL(n,t,e,o){if(t.length===0||o==="after"||o==="before")return!1;let r=o.data;const i=Ft.getImageObject(n,e),s=Y.default(i.getImages());return t.forEach(l=>{const c={src:"",flex:1,width:0,height:0,virtualSize:!0};s.splice(r,0,c);const a=de(s,i.getWidthPercent());n.updateEmbedData(e,a),i.replaceImage(r,l),r+=1}),!0}function rL(n,t,e,o,r){var s,l;if(sl(e))return oL(n,e,t,o);if(e.type!=="custom"||e.customType!=="image"||!e.data)return;const i=e.data;if(r.isSourceBlock){const c=r.targetBlock,a=H(c);let u=K(c);o==="after"&&(u+=1);const m=100*(i.boundingRect.width/n.rootContainer.getBoundingClientRect().width),C=de([i.image],m),v={id:N(),type:"embed",embedType:"image",embedData:C},w=(l=(s=n.options.componentsOptions)==null?void 0:s.image)==null?void 0:l.defaultAlign;w&&(v.align=w),n.insertBlock(V(a),u,v),i6(n,t,i.index)}else{if(typeof o=="string")return;const c=t;let a=o.data;const u=Ft.getImageObject(n,c),f=Y.default(u.getImages());a>f.length&&(a=f.length),n.undoManager.runInGroup(()=>{const m=n.getBlockById(e.blockId);if(m===c){const C=i.index,v=a,w=i.image;if(C===v||v===C+1)return;let E=v;C<v?(f.splice(v,0,w),f.splice(C,1),E-=1):(f.splice(C,1),f.splice(v,0,w));const L=de(f,u.getWidthPercent());n.updateEmbedData(c,L),u.setSelectedIndex(E)}else{f.splice(a,0,i.image),f[0].flex=NaN,Es(f);const C=de(f,u.getWidthPercent());n.updateEmbedData(c,C),i6(n,m,i.index)}})}return!0}const iL=2;function Wc(n,t,e){const o=Gn(t);if(e<=0){const s=o[0].getBoundingClientRect();return new DOMRect(s.left-4,s.top,2,s.height)}if(e===o.length){const s=o[e-1].getBoundingClientRect();return new DOMRect(s.right+2,s.top,2,s.height)}const r=o[e-1].getBoundingClientRect(),i=o[e].getBoundingClientRect();return new DOMRect((i.left+r.right)/2-1,r.top,iL,r.height)}function sL(n,t,e,o,r){for(let i=0;i<e.length;i++){const l=e[i].getBoundingClientRect();if(o<=l.right)return o<=l.left+l.width/2?{rect:Wc(n,t,i),data:i}:{rect:Wc(n,t,i+1),data:i+1}}return o>e[e.length-1].getBoundingClientRect().right?{rect:Wc(n,t,e.length),data:e.length}:{rect:Wc(n,t,e.length),data:0}}function lL(n,t,e,o,r){const i=Gn(t);if((e==null?void 0:e.type)!=="block"&&!(i.length>=6&&(e==null?void 0:e.blockId)!==G(t)))return sL(n,t,i,o)}const PF="";function Gc(n){const t=At(n);let e=t.querySelector(":scope > .block-helper");return e||(e=b("div",["block-helper"],t),b("span",["helper-sizer"],e,"A")),e}function yh(n,t,e){const o=Gc(n),i=Array.from(o.children).find(s=>{var c;return Number.parseInt((c=s.getAttribute("data-index"))!=null?c:"0",10)>e});o.insertBefore(t,i!=null?i:null)}const s6=40,cL=20;class aL{findTargetBlock(t,e){const o=e.target;if(o&&o instanceof Element){const c=z(o);if(c&&vt(t.rootContainer,c))return c}let r=e.clientX,i=e.clientY;const s=t.rootContainer.getBoundingClientRect().left;r<s&&s-r<s6&&(r+=s6);let l=document.elementFromPoint(r,i);if(l){const c=z(l);if(c&&vt(t.rootContainer,c))return c}if(i-=cL,l=document.elementFromPoint(r,i),l){const c=z(l);if(c&&vt(t.rootContainer,c))return c}return null}destroy(){}}class dL extends Mc{constructor(e){super(e,{trigger:[],id:"empty-block-menu"});h(this,"currentBlock",null)}get isVisible(){return this.suggest.menu.isVisible}isInMenu(e){return this.menu.isInCommandBar(e)}show(){const o=this.editor.selection.focusedBlock;this.suggest.popup(o,0,"","")}setBlock(e){this.currentBlock=e}}function uL(n,t){const e=p1(n,t);if(!e)return[];const o=[];return Object.values(e).forEach(r=>{o.push(...r.commands.map(i=>({...i,source:"block-command",blockMenuItemCustomData:r.group})))}),o}function hL(n){const t=Ku(n),e=o=>{o.forEach(r=>{r.source="insert-block",r.children&&e(r.children)})};return e(t),t}function fL(n,t,e,o=!1){var a,u;const r=H(t),i=K(t);let s=i;wt(n,t)||o||(s+=1);const l=V(r),c=e;return c.commandProvider?c.commandProvider.executeCommand(n,e,{from:"block-menu",containerId:l,blockIndex:i}):(u=(a=c.blockOptions)==null?void 0:a.handleInsertEmptyBlock)==null?void 0:u.call(a,n,{containerId:l,blockIndex:s,item:e})}function mL(n,t){const e=We(n,t),o=n.getBlockData(t);return!(e!=="text"||o.heading)}function l6(n,t,e){n.getBlockData(t).heading===e?n.updateBlockData(t,{heading:null}):n.updateBlockData(t,{heading:e})}function gL(n,t,e){["left","center","right"].includes(e)?n.updateBlockData(t,{align:e}):n.updateBlockData(t,{align:null})}function pL(n,t){const o=n.getBlockData(t).quoted;n.updateBlockData(t,{quoted:o?void 0:!0})}function CL(n,t,e){const o=n.selection.range.focus;if(!o.isSimple())return;let r;switch(e){case"unordered-list":r="unordered";break;case"ordered-list":r="ordered";break;case"check-list":r="checked";break}const i=hl(n,t,"list",{offset:o.offset,data:{listType:r}});i&&n.undoManager.runInGroup(()=>{const s=K(t),l=H(t);n.deleteBlock(t),n.insertBlock(V(l),s,i.blockData)})}class bL{constructor(t,e,o){h(this,"source","text-style");h(this,"id","text-style-item");h(this,"name","Text styles");h(this,"element");h(this,"createHeadingItemElement",(t,e,o)=>{var i;const r=Dc();this.createItem("text",ns,e,mL(this.editor,t)),(i=r.insertBlockCommandItems)==null||i.forEach(s=>{s.id&&s.icon&&this.createItem(s.id,s.icon,e,o?o===Number(s.value):!1)})});h(this,"createListItemElement",(t,e,o)=>{const{checkbox:r,ordered:i}=o,l=it(t)==="list",c=l&&i===!1&&!r,a=l&&i,u=l&&!!r;this.createItem("unordered-list",Z5,e,c),this.createItem("ordered-list",Y5,e,a),this.createItem("check-list",W5,e,u)});h(this,"handleClick",(t,e)=>{var l,c;if(!e.target||!(e.target instanceof Node))return;const o=e.target instanceof Element?e.target:e.target.parentElement;if(!o)return;const r=o.closest(".text-style-item");if(!r)return;const i=r.id,s="heading-";if(i==="text"&&l6(t,this.block,null),i.startsWith(s)){const a=Number.parseInt(i.substring(s.length),10);a&&l6(t,this.block,a)}if(i==="blockquote"&&pL(t,this.block),i.startsWith("align")){const a=i.replace(/^align-/,"");gL(t,this.block,a)}(i==="unordered-list"||i==="ordered-list"||i==="check-list")&&CL(t,this.block,i),(c=(l=this.options).onAfterStyleItemClick)==null||c.call(l)});this.editor=t,this.block=e,this.options=o,this.element=this.createItemElement(t,e),t.domEvents.addEventListener(this.element,"click",this.handleClick)}createItemElement(t,e){const o=b("div",["text-styles"],null),r=b("div",["text-style-section"],o),i=t.getBlockData(e),s=i.heading,l=i.quoted,c=i.align||"left";return this.createHeadingItemElement(e,r,s),this.createListItemElement(e,r,i),this.createItem("blockquote",G5,r,!!l),this.createItem("align-left",Pr,r,c==="left"),this.createItem("align-center",ic,r,c==="center"),this.createItem("align-right",rc,r,c==="right"),o}createItem(t,e,o,r=!1){const i=["style-icon","text-style-item"];r&&i.push("active");const s=hr(e,i,o);s.id=t}}function c6(){return{source:"separator",type:"separator",id:`section-${N()}`,name:""}}const a6={copy:Q5,cut:K5,delete:J5,"lock-block":X5,"unlock-block":tp,comment:$r};function vL(n,t,e){const o=[],r=j(n,t);if(r&&o.push(new bL(n,t,e)),!wt(n,t)){r&&o.push(c6());const s=uL(n,t);s.sort((l,c)=>{var a,u;return((a=l.order)!=null?a:0)-((u=c.order)!=null?u:0)}),s.forEach(l=>{l.id in a6&&(l.icon=a6[l.id])}),o.push(...s)}const i=hL(n);return wt(n,t)?o.push(...i):o.push(c6(),{id:"insert-block-before",icon:ep,name:S.t("blockMenu.command.insertAbove"),children:i.map(s=>({...s,source:"insert-block-before"})),childrenMenuId:"quick-menu",source:"insert-block-before"},{id:"insert-block-after",icon:np,name:S.t("blockMenu.command.insertAfter"),children:i,source:"insert-block",childrenMenuId:"quick-menu"}),o}function kL(n,t,e){if(e.source==="block-command"){const o=e.blockMenuItemCustomData;ng(n,t,o,e)}else(e.source==="insert-block"||e.source==="insert-block-before")&&fL(n,t,e,e.source==="insert-block-before")}function Zc(n,t){return n.getBlockData(t).lock}function wh(n,t){return!!Zc(n,t)}function Yc(n,t){const e=Zc(n,t);return e?e.userId===n.doc.getUser().userId:!1}function yL(n,t){const e=Zc(n,t);return e?e.userId!==n.doc.getUser().userId:!1}function wL(n,t){if(n.readonly||!n.isBlockWritable(t)||wh(n,t)&&!Yc(n,t))return;const e=n.doc.getUser(),o={userId:e.userId,displayName:e.displayName,locked:Date.now()},i={...n.getBlockData(t),lock:o};n.updateBlockData(t,i)}function BL(n,t){if(!Yc(n,t))return;const e={lock:null};n.updateBlockData(t,e)}class d6{constructor(){h(this,"executeCommand",(t,e,o)=>{const r=o.data;if(!r||!r.blockId)return;const i=t.getBlockById(r.blockId);r.type==="lock"?wL(t,i):r.type==="unlock"&&BL(t,i)})}create(t,e,o,r,i){const s=i.lock;s&&(s.userId!==t.doc.getUser().userId?M(r,"locked-by-others"):M(r,"locked-by-self"))}writable(t,e){if(yL(t,e))return!1}commands(t,e){const o=wh(t,e),r=Yc(t,e),i={blockId:G(e),type:"lock"},s={id:"lock-block",name:"",data:i,order:10};if(o)if(r)s.id="unlock-block",s.name=S.t("locker.unlock"),i.type="unlock";else{const l=Zc(t,e);s.name=S.t("locker.lockedBy",{name:(l==null?void 0:l.displayName)||""}),s.states=["disabled"]}else s.name=S.t("locker.lock");return{group:"block-locker",commands:[s],executeCommand:this.executeCommand}}}const $F="",EL={locker:{lock:"\u9501\u5B9A",unlock:"\u89E3\u9664\u9501\u5B9A",lockedBy:"\u88AB {name} \u9501\u5B9A"}},IL={locker:{lock:"Lock",unlock:"Unlock",lockedBy:"Locked by {name}"}};S.mergeLang({"zh-CN":EL,"en-US":IL});const xL=y("standard-block-actions");class SL{constructor(){h(this,"executeCommand",(t,e,o)=>{const r=o.data;try{const i=t.getBlockById(r);if(o.id==="delete"){t.deleteBlock(i);return}o.id==="copy"&&cd(t,i),o.id==="cut"&&(cd(t,i),t.deleteBlock(i))}catch(i){xL.error(`failed to execute block command: ${JSON.stringify(i)}`)}})}commands(t,e){const o=wh(t,e),r=o&&Yc(t,e),i=G(e);return{group:"standard-block-actions",commands:[{id:"copy",name:"Copy",data:i,order:1},{id:"cut",name:"Cut",data:i,order:2,states:o&&!r?["disabled"]:[]},{id:"delete",name:"Delete",data:i,order:3,states:o&&!r?["disabled"]:[]}],executeCommand:this.executeCommand}}}const u6=y("block-menu");class TL{constructor(t){h(this,"menu");h(this,"currentBlock",null);h(this,"commandBlock",null);h(this,"handleShow",()=>{d(u6,this.currentBlock,"no target block before show block menu");const t=vL(this.editor,this.currentBlock,{onAfterStyleItemClick:this.close});this.menu.updateItems(t),this.commandBlock=this.currentBlock});h(this,"handleClose",()=>{this.editor.focus()});h(this,"handleItemClick",(t,e)=>{d(u6,this.commandBlock,"no command block before show block menu"),kL(this.editor,this.commandBlock,e),!e.element&&!e.children&&this.close()});h(this,"close",()=>{this.menu.close()});this.editor=t,this.menu=new Wo([],void 0,{id:"block-menu"}),this.menu.on("show",this.handleShow),this.menu.on("close",this.handleClose),this.menu.on("click",this.handleItemClick),t.blockHooks.push(new SL)}show(t){this.menu.manualShow(t,{placement:"bottom-start"})}isInMenu(t){return this.menu.isInCommandBar(t)}setBlock(t){this.currentBlock=t}get isVisible(){return this.menu.isVisible}destroy(){this.menu.destroy()}}const h6=`<svg width="16" height="17" viewBox="0 0 16 17" fill="none" xmlns="http://www.w3.org/2000/svg">
460
+ `;function nD(n,t,e){const r={...n.getBlockData(t),language:e};n.updateBlockData(t,r)}function oD(n,t,e){const r={...n.getBlockData(t),nowrap:e};n.updateBlockData(t,r)}const Qr=y("code-block-header"),rD=Object.entries(Fc).map(([n,t])=>({id:n,name:t.name,language:t}));function iD(n,t){if(t){const e=n,{editor:o,codeBlock:r}=e.custom;nD(o,r,t.id);const i=r.querySelector(".code-block-header .language-select .name-label");i.innerText=t.name}}function sD(n,t,e){n.addCustom("code-header-language-select-dropdown",i=>{const s=new f5(rD,i.rootElement,{placeholder:"Search for a language..."});return s.onSelected=iD,s});const o=b("div",["language-select"],null);b("span",["name-label"],o,e);const r=b("span",["arrow-icon"],o);return r.innerHTML=XT,n.domEvents.addEventListener(o,"click",(i,s)=>{const c=s.target.closest(".language-select"),a=z(c);d(Qr,a,"no parent block"),d(Qr,it(a)==="code","not a code block");const u=i.getBlockData(a),f=i.getCustom("code-header-language-select-dropdown");f.custom={codeBlock:a,editor:i},f.setSelectedId(u.language),f.show(c),M(t,"editing-language"),f.onHide=()=>{F(t,"editing-language")}}),o}function lD(){return b("div",["code-header-spacer"],null)}function cD(n,t){const e=t.target,o=e.closest(".code-header-button");d(Qr,o,"no button");const r=z(e);d(Qr,r,"no parent block");const i=o.getAttribute("data-id");if(d(Qr,it(r)==="code","not a code block"),i==="wrap"){const s=n.getBlockData(r);oD(n,r,!s.nowrap);return}if(i==="copy"){const s=Zr(r),l=od(n,U(s)),c=o2(n,l);navigator.clipboard.writeText(c).then(()=>{const a=o.getBoundingClientRect();m5("Copied to clipboard",{position:{x:a.x+a.width/2,y:a.bottom+30}})}).catch(a=>{Qr.error(a.message)});return}i==="caption"&&UT(n,r)}function Ch(n,t,e,o){const r=b("button",["code-header-button"],null);if(r.setAttribute("data-id",t),o){const i=b("span",["button-icon"],r);i.innerHTML=o}if(e){const i=b("span",["button-label"],r);i.innerHTML=e}return n.domEvents.addEventListener(r,"click",cD),r}function aD(n,t,e){const o=At(t),r=b("div",["code-block-header"],o),i=Fc[e.language]||Fc.plain;r.appendChild(sD(n,t,i.name)),r.appendChild(lD()),r.appendChild(Ch(n,"copy","Copy",tD)),r.appendChild(Ch(n,"wrap","Wrap",eD)),r.appendChild(Ch(n,"caption","Caption",null))}function dD(n,t,e,o){ph.init(n);const r=o.children,i=eo(e,"div");i.setAttribute("data-language",o.language||"text"),U4(n,e,o);const s=b("div",["editor-code-root"],i),l=b("div",["code-text-root"],s);if(n.createChildContainer(t,l,r[0]),r.length===2){const c=b("div",["code-caption-root"],s);n.createChildContainer(t,c,r[1])}return aD(n,e,o),i}function uD(n){const t={id:N(),type:"text",text:[]},e=N();return n.doc.localInsertChildContainer(e,[t]),{blockData:{id:N(),type:"code",language:"plain",children:[e]},focusBlockId:t.id}}const En=y("list-block");function hD(n,t,e,o,r){GT(n),YT(n),d(En,r.type==="code","invalid block data type");const i=r;return d(En,i.children,"invalid block data children"),d(En,i.children.length===1||i.children.length===2,"invalid block data children length"),M(o,"drag-preview-element"),dD(n,t,o,i)}function fD(n){return 1}function mD(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t)||!fn(r))return null;const i=zc(t);if(!fn(r))return null;const s=r;if(i.indexOf(s)===-1||Ue(s)>1)return null;const l=bt(t,U(s));return new Ye(n,{anchor:l,focus:l})}function gD(n,t,e,o){return null}function pD(n,t){return n.getBoundingClientRect()}function CD(n,t,e,o){if(e.isSimple()){d(En,o.isSimple(),"from is simple position but to is not simple position"),En.debug("full select list"),M(t,"full-selected");return}d(En,!o.isSimple(),"from is complex position but end is simple position");const r=e,i=o;d(En,r.blockId===i.blockId,"only allow update one table selection"),zc(t).forEach(l=>{const c=U(l);(c===r.childContainerId||c===i.childContainerId)&&M(l,"selected")})}function bD(n){n.rootContainer.querySelectorAll('[data-type="editor-block"][data-block-type="code"]').forEach(t=>{F(t,"full-selected"),t.querySelectorAll("div[data-type=editor-container].child.selected").forEach(e=>{F(e,"selected")})})}function vD(n,t){return zc(t)}function kD(n,t,e,o,r){if(o==="ArrowDown"||o==="ArrowRight"){if(e===Zr(t))return Yr(t)}else if(e===Yr(t))return Zr(t);return null}function yD(n,t,e,o){const r=zc(t),i=r.map(U),s=i.indexOf(e.childContainerId),l=i.indexOf(o.childContainerId);d(En,s!==-1,"invalid start pos"),d(En,l!==-1,"invalid end pos");const c=[r[s]];return s!==l&&c.push(r[l]),c}function wD(n,t,e){d(En,tr(t),"invalid block type"),U4(n,t,e)}async function BD(n,t){const e=uD(n);if(!e)return null;const{blockData:o,focusBlockId:r}=e;return n.insertBlock(t.containerId,t.blockIndex,o,Ot(n,r,0))}function ED(n){return{name:"CodeBlock",insertBlockCommandItems:[{id:"insert-code",name:S.t("code.title"),icon:q5,order:300,group:"common"}],handleInsertEmptyBlock:BD}}function ID(){return{abstract:`[${S.t("code.abstract")}]`}}const ks={blockType:"code",blockKind:"complex",createBlockContent:hD,getBlockTextLength:fD,getRangeFromPoint:mD,moveCaret:gD,getCaretRect:pD,updateSelection:CD,clearSelection:bD,getChildContainers:vD,getNextContainer:kD,getSelectedContainers:yD,convertFrom:zT,handleBlockElementUpdated:wD,getOptions:ED,getBlockProperties:ID},bh={..._i,blockType:"code-line"};function xD(n){if(!n.isWritable())return!1;const t=n.getFocusedBlock();if(!!Uc(t)){if(n.selection.range.isCollapsed()){const e=n.selection.range.start;return n.insertTextToBlock(t,e.offset," "),!0}return n.undoManager.runInGroup(()=>{Qe(n).forEach(o=>{n.insertTextToBlock(o.block,0," ")})}),!0}}function SD(n){if(!n.isWritable())return!1;const t=n.getFocusedBlock();if(!Uc(t))return;const e=[" "," "," "," "];return n.undoManager.runInGroup(()=>{Qe(n).forEach(r=>{const i=Tt(n.getBlockText(r.block));for(let s=0;s<e.length;s++){const l=e[s];if(i.startsWith(l)){n.deleteTextFromBlock(r.block,0,l.length);break}}})}),!0}const TD={Tab:xD,"Shift+Tab":SD},ys=y("code-text-decorate");class ws{decorateText(t,e,o){var C;if(d(ys,e.length>0,"invalid path"),e.length===1)return{};const r=e[e.length-2];if(t.doc.getBlockData(r.containerId,r.blockIndex).type!=="code")return{};const s=o;if(s.length===0)return{};const l=Tt(s),c=t.doc.getBlockData(r.containerId,r.blockIndex),a=bi.default.tokenize(l,(C=bi.default.languages[c.language])!=null?C:bi.default.languages.plain),u=(v,w)=>{if(d(ys,v,"no token"),typeof v=="string")return[{insert:v,attributes:Y.default(w)}];d(ys,v instanceof bi.default.Token,"invalid token type");const E=v.content,L=Y.default(w);return L[`style-code-${v.type}`]=!0,typeof E=="string"?[{insert:E,attributes:L}]:Array.isArray(E)?E.map(O=>u(O,L)).flat():(d(ys,E instanceof bi.default.Token,"invalid token"),u(E,L))},m=a.map(v=>u(v,{})).flat();return d(ys,ce(m)===ce(s),"failed to highlight code, text length mismatch"),{text:m}}}const DD={code:{title:"\u4EE3\u7801",abstract:"\u4EE3\u7801"}},LD={code:{title:"Code",abstract:"Code"}};S.mergeLang({"zh-CN":DD,"en-US":LD});const MD=y("image-data"),RD=1e3,AD=400,OD=10;function Bs(n){return n.src.startsWith("empty:")||!n.src}function _D(n){return n.src.startsWith("http:")||n.src.startsWith("https:")}function W4(n){return`${Ci.default(n)}_width`}function G4(n){return`${Ci.default(n)}_height`}function Z4(n){return`${n}_flex`}function Es(n){if(n.every(r=>typeof r.flex=="number"&&r.flex))return;const t=100,o=n.map(r=>r.width/(r.height/t)).reduce((r,i)=>r+i,0);n.forEach(r=>{const i=r.width/(r.height/t);r.flex=i/o})}function Kr(n){const t=(r,i)=>{r||(r=`empty:${i}`);const s=W4(r),l=G4(r),c=Z4(i);let a=n[s],u=n[l],f=n[c];return typeof a=="string"&&(a=Number.parseInt(a,10)),typeof u=="string"&&(u=Number.parseInt(u,10)),typeof f=="string"&&(f=Number.parseInt(f,10)),a&&u?{src:r,width:a,height:u,flex:f,virtualSize:!1}:(a=RD,u=AD,{src:r,width:a,height:u,flex:f,virtualSize:!0})};let e=[];const o=n.src;return Array.isArray(o)?e=o.map(t):typeof o=="string"&&(e=o.split("|").map(t)),Es(e),e}function ln(n){var o;const t=n.embedData;return Kr(n.embedData).length>1?100:(o=t.widthPercent)!=null?o:100}function ND(n,t){if(Kr(t.embedData).length>1)return"100%";const o=ln(t);return`${n.rootContainer.getBoundingClientRect().width*o/100}px`}function de(n,t){const o={src:n.map(r=>r.src).join("|"),widthPercent:t};return n.forEach((r,i)=>{if(r.width&&r.height&&!r.virtualSize){const l=r.src||`empty:${i}`,c=W4(l);o[c]=r.width;const a=G4(l);o[a]=r.height}d(MD,r.flex,"no image flex");const s=Z4(i);o[s]=r.flex}),o}function PD(n,t,e){const o=Kr(t.embedData),r=o.length===1?n.rootContainer:e,i=ln(t);let s=r.getBoundingClientRect().width*(i/100);if(s-=Number.parseFloat(window.getComputedStyle(r).paddingLeft)+Number.parseFloat(window.getComputedStyle(r).paddingRight),o.length===1){const a=o[0];return a.height/(a.width/s)}s-=(o.length-1)*OD;const l=o.reduce((a,u)=>a+u.flex,0);let c=0;for(const a of o){const f=s*a.flex/l/a.width*a.height;c=Math.max(f,c)}return c}function $D(n){return n.reduce((e,o)=>e+o.flex,0)}const HD=y("image-dom");function Y4(n){return n.querySelector(".uploading-progress-mask")}function jD(n){const t=Y4(n);if(t)return t;const e=b("div",["uploading-progress-mask"],n),o=b("div",["uploading-progress-bar"],e);return b("div",["uploading-progress-bar-value"],o),o}function FD(n){const e=jD(n).querySelector(".uploading-progress-bar-value");return d(HD,e,"no progress value"),e}function Q4(n,t){const e=FD(n);e.style.width=`${t}%`}function zD(n){var t;(t=Y4(n))==null||t.remove()}function UD(n){let t;return n.forEach((e,o)=>{o.toLocaleLowerCase()==="content-type"&&(t=e)}),t!=null?t:""}async function VD(n){try{const t=await fetch(n,{credentials:"same-origin"}),e=await t.blob(),o=UD(t.headers).toLocaleLowerCase();let r="";if(o){const s=Of.default[o].extensions;s&&s.length>0&&(r=s[0])}return new File([e],`${Date.now()}.${r}`,{type:o})}catch{return null}}function er(n,t){const e=typeof t=="string"?t:G(t);return n.getCustom(`image-${e}`)}function Vc(n,t){if(!t||!(t instanceof Node))return null;const e=z(t);return e?er(n,e):null}function Gn(n){return Array.from(n.querySelectorAll(".image-container"))}function qc(n,t,e,o){const r=e!=null?e:n.findBlockById(t.id);if(!r)return;const i=o||H(r),s=ND(n,t),l=PD(n,t,i),c=rt(r);c.style.width=s;const a=r.querySelector(".images");!a||(a.style.height=`${l}px`)}const vh=y("table-resize-drag-drop");class qD{constructor(t,e,o,r){h(this,"cursor","col-resize");h(this,"initWidths");this.editor=t,this.elem=e,this.data=o,this.mouseDownEvent=r;const i=this.data.block,l=er(this.editor,i).getImages(),c=this.data.splitterIndex;d(vh,c>=0&&c<l.length-1,`invalid splitter index: ${c}`);const u=Gn(i).map(f=>f.getBoundingClientRect().width);this.initWidths=u}onDragStart(t,e,o){if(!this.editor.isWritable())return;const r=this.data.block;er(this.editor,r).setResizing(!0)}onDragging(t,e,o,r,i){const s=this.data.block,l=er(this.editor,s),c=Y.default(l.getImages()),a=this.data.splitterIndex;d(vh,a>=0&&a<c.length-1,`invalid splitter index: ${a}`);const u=this.initWidths[a],f=this.initWidths[a+1];if(u+f<100)return;let m=r;u+m<50&&(m=50-u),f-m<50&&(m=f-50);const w=[...this.initWidths];w[a]+=m,w[a+1]-=m;const E=Gn(s);d(vh,E.length===c.length,"invalid image data");const L=w.reduce((O,P)=>O+P,0);for(let O=0;O<c.length;O++){const P=w[O]/L;c[O].flex=P,E[O].style.flexGrow=`${P}`}const x=Y.default(this.editor.getBlockData(s)),A=de(c,ln(x));x.embedData=A,qc(this.editor,x,s,null)}onDragEnd(t,e,o,r,i){const s=this.data.block,l=er(this.editor,s),a=Gn(s).map(u=>Number.parseFloat(u.style.flexGrow));l.updateFlex(a),l.setResizing(!1)}}function K4(n){var t;return!n||!(n instanceof HTMLElement)?null:lt(n,"image-splitter")?n:(t=n.closest(".image-splitter"))!=null?t:null}function WD(n,t){var s;const e=K4(t.target);if(!e)return;const o=z(e);if(!o)return;er(n,o).setSelectedIndex(-1),n.selection.selectBlock(o,0);const r=Number.parseInt((s=e.getAttribute("data-index"))!=null?s:"",10);if(Number.isNaN(r)||typeof r!="number")return;const i={block:o,splitterIndex:r};Za(new qD(n,e,i,t))}function GD(n,t){t.preventDefault(),t.stopPropagation();const e=K4(t.target);if(!e)return;const o=z(e);!o||er(n,o).resetFlex()}function ZD(n,t,e,o){const r=b("div",["image-splitter"],e);b("div",["image-splitter-indicator"],r),r.setAttribute("data-index",`${o}`),n.domEvents.addEventListener(r,"mousedown",WD),n.domEvents.addEventListener(r,"dblclick",GD)}const YD=y("image-item");function J4(n){return!n||!(n instanceof Node)?null:z(n)}function X4(n){const t=J4(n);return t?Gn(t):[]}function kh(n){if(!n||!(n instanceof Node))return null;const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest(".image-container");return e||null}function Is(n){const t=kh(n);return t?X4(n).indexOf(t):-1}async function QD(n,t){const e=Vc(n,t.target);if(!e)return;const o=Is(t.target);if(o===-1)return;const r=t.target;if(!(r instanceof HTMLImageElement))return;const i=e.getImages()[o];if(i.virtualSize&&e.fixImageSize(o,r),!i||!_D(i)||i.downloading)return;i.downloading=!0;const s=await VD(i.src);s?e.replaceImage(o,s):YD.warn(`failed to download image: ${i.src}`)}function KD(n,t,e){if(t.querySelector(".load-error"))return;const r=e.src.startsWith("http:")||e.src.startsWith("https:"),i=b("div",["load-error"],t),s=b("div",["error-icon"],i);s.innerHTML=iu;const l=b("div",["error-message"],i);r?(l.innerHTML=S.t("image.load.remote.failed"),n.domEvents.addEventListener(i,"click",(c,a)=>{a.preventDefault(),a.target instanceof HTMLElement&&a.target.tagName==="A"&&window.open(e.src,"_blank")})):(l.innerHTML=S.t("image.load.failed"),n.domEvents.addEventListener(i,"click",(c,a)=>{a.preventDefault(),a.target instanceof HTMLElement&&a.target.tagName==="A"&&eL(c,a.target)}))}function JD(n,t){const e=Vc(n,t.target);if(!e)return;const o=Is(t.target);if(o===-1)return;const r=e.getImages()[o];if(!r)return;const i=kh(t.target);!i||(M(i,"error","error-load"),KD(n,i,r))}function XD(n,t,e){if(t.querySelector(".upload-error"))return;const r=b("div",["upload-error"],t),i=b("div",["error-icon"],r);i.innerHTML=iu;const s=b("div",["error-message"],r);s.innerHTML=S.t("image.upload.failed"),n.domEvents.addEventListener(r,"click",(l,c)=>{if(c.preventDefault(),!c.target||!(c.target instanceof Element)||c.target.tagName!=="A")return;const a=Vc(l,c.target),u=Is(c.target);!a||u===-1||a.replaceImage(u,e)})}function t6(n,t,e,o,r){const i=Gn(t)[e];!i||(M(i,"error","error-upload"),XD(n,i,r))}function e6(n,t,e,o,r,i){const s=b("div",["image-container"],t);if(s.setAttribute("data-src",e.src),i.length>1&&(s.style.flexShrink=`${e.flex}`,s.style.flexGrow=`${e.flex}`),r===o&&M(s,"active"),Bs(e)){M(s,"empty");const c=b("div",["upload-image-icon"],s);return c.innerHTML=T5,s}const l=b("img",["editor-image"],s);if(l.src=n.doc.buildResourceUrl(e.src),l.draggable=!0,!Bs(e)&&!n.readonly&&n.domEvents.addEventListener(l,"load",QD),n.domEvents.addEventListener(l,"error",JD),e.src.startsWith("https:")||e.src.startsWith("http:")){const c=b("div",["image-warning"],s);c.innerHTML=ru,c.setAttribute(`data-editor-tooltip-${n.clientId}`,S.t("image.load.remote.tooltip"))}return s}function tL(n,t,e,o,r){const i=b("div",["images"],e);return o.forEach((s,l)=>{l>0&&ZD(n,t,i,l-1),e6(n,i,s,l,r,o)}),o.length>1&&M(t,"multi"),i}function n6(n,t,e,o,r,i){const l=Array.from(t.querySelectorAll(".image-container"))[o];if(!l)return;const c=e6(n,null,e,o,r,i);l.insertAdjacentElement("beforebegin",c),l.remove()}function xs(n,t){return Gn(n)[t]}function eL(n,t){const e=J4(t);if(!e)return;const o=Is(t);if(o===-1)return;const r=Vc(n,t);if(!r)return;const i=r.getImages()[o];n6(n,e,i,o,r.getSelectedIndex(),r.getImages())}function cn(n){return it(n)==="embed"&&De(n)==="image"}async function o6(n){return new Promise((t,e)=>{const o=new Image;o.onload=()=>{t({width:o.naturalWidth,height:o.naturalHeight})},o.onerror=e,o.src=n})}async function nL(n){const t=await nl(n);return o6(t)}const r6=y("image-object");class Ft{constructor(t,e){h(this,"images",[]);h(this,"selectedIndex",-1);h(this,"blockResizer");h(this,"resizing",!1);h(this,"parentContainerResizerObserver",null);h(this,"handleMouseDown",async(t,e)=>{const o=Is(e.target);if(o===-1)return;const r=this.images[o];Bs(r)||this.setSelectedIndex(o)});h(this,"handleEditorResize",()=>{if(this.isEmpty()||this.resizing)return;const t=this.editor.findBlockById(this.blockData.id);!t||qc(this.editor,this.blockData,t,null)});h(this,"handleResizing",(t,e)=>{const o=this.editor.findBlockById(this.blockData.id);if(!o)return;const i=this.editor.rootContainer.getBoundingClientRect().width,s=o.getBoundingClientRect();let l=e.width>s.width?s.width:e.width;l<50&&(l=50);const c=l*100/i;this.blockData.embedData.widthPercent=c,qc(this.editor,this.blockData,o,null)});h(this,"handleResized",t=>{const e=this.editor.findBlockById(this.blockData.id);if(!e)return;const o=de(this.images,ln(this.blockData));this.editor.updateEmbedData(e,o),this.blockResizer.enableResize(e)});h(this,"fixImageSizes",ie.default(()=>{const t=this.editor.findBlockById(this.blockData.id);if(!t)return;const e=de(this.images,ln(this.blockData));this.editor.updateEmbedData(t,e)},1e3));this.editor=t,this.blockData=e,this.blockResizer=new $c(this.editor,{resize:["top-left","top-right","bottom-left","bottom-right"]}),this.blockResizer.addListener("resizing",this.handleResizing),this.blockResizer.addListener("resized",this.handleResized),this.images=Kr(this.blockData.embedData)}destroy(){var t;this.blockResizer.removeAllListeners(),this.blockResizer.destroy(),this.editor.domEvents.removeEventListener(null,null,this.handleMouseDown),(t=this.parentContainerResizerObserver)==null||t.disconnect()}createContent(t,e,o){const r=tL(this.editor,e,o,this.images,this.selectedIndex);this.editor.domEvents.addEventListener(o,"mousedown",this.handleMouseDown),this.editor.addListener("resize",this.handleEditorResize),qe(t)&&(this.parentContainerResizerObserver=new ResizeObserver(this.handleEditorResize),this.parentContainerResizerObserver.observe(t)),this.isEmpty()?M(r,"empty"):qc(this.editor,this.blockData,e,t),setTimeout(()=>{const i=this.editor.findBlockById(this.blockData.id);i&&this.blockResizer.update(i)})}getImages(){return this.images}getWidthPercent(){return ln(this.blockData)}isEmpty(){return this.images.length===1&&Bs(this.images[0])}setResizing(t){this.resizing=t}getSelectedIndex(){return this.selectedIndex}getBlock(){return this.editor.findBlockById(this.blockData.id)}setSelectedIndex(t){const e=this.getBlock();if(!e||t===this.selectedIndex)return;if(this.selectedIndex!==-1){const r=xs(e,this.selectedIndex);r&&F(r,"active")}this.selectedIndex=t;const o=xs(e,t);o&&M(o,"active")}async requestUploadImage(t){const e=this.editor.findBlockById(this.blockData.id);if(!e)return;const o=xs(e,t);if(lt(o,"error"))return;const r=await fr("image/*");await this.replaceImage(t,r)}tryEnableResizer(){const t=this.editor.findBlockById(this.blockData.id);if(!t||!this.editor.isWritable())return;const e=xs(t,0);!this.isEmpty()&&this.images.length===1&&!lt(e,"error")&&this.blockResizer.enableResize(t)}disableResizer(){this.blockResizer.disableResize()}fixImageSize(t,e){const o=this.images[t];Bs(o)||(o.width=e.naturalWidth,o.height=e.naturalHeight,o.virtualSize=!1,this.fixImageSizes())}removeImage(t){const e=this.editor.findBlockById(this.blockData.id);if(!e||t===-1||t>=this.images.length)return!1;const o=Y.default(this.images);o.splice(t,1),o[0].flex=NaN,Es(o),this.selectedIndex>=o.length&&(this.selectedIndex=o.length-1);const r=de(o,ln(this.blockData));return this.editor.updateEmbedData(e,r),!0}async replaceImage(t,e){const o=this.editor.findBlockById(this.blockData.id);if(!o)return!1;try{const i=await nl(e),s=this.images[t];if(s.virtualSize){const{width:c,height:a}=await o6(i);s.width=c,s.height=a,s.virtualSize=!1;const u=de(this.images,ln(this.blockData));this.editor.updateEmbedData(o,u)}const l={...s,src:i};n6(this.editor,o,l,t,this.selectedIndex,this.images),setTimeout(()=>{this.blockResizer.update(o)})}catch(i){return t6(this.editor,o,t,i,e),!1}const r=xs(o,t);if(!r)return!1;M(r,"uploading"),Q4(r,0);try{const i=await this.editor.doc.uploadResource(e,{onProgress:c=>{Q4(r,c)}});F(r,"uploading"),this.images[t].src=i.resourceId;const s=this.editor.findBlockById(this.blockData.id);if(!s)return!1;const l=de(this.images,ln(this.blockData));return this.editor.updateEmbedData(s,l),!0}catch(i){r6.error(i);const s=this.editor.findBlockById(this.blockData.id);return s&&(F(r,"uploading"),zD(r),t6(this.editor,s,t,i,e)),!1}}updateFlex(t){const e=this.editor.findBlockById(this.blockData.id);if(!e)return;d(r6,t.length===this.images.length,"invalid flex");for(let r=0;r<this.images.length;r++)this.images[r].flex=t[r];const o=de(this.images,ln(this.blockData));this.editor.updateEmbedData(e,o)}resetFlex(){const t=this.editor.findBlockById(this.blockData.id);if(!t)return;const e=Y.default(this.images);e[0].flex=NaN,Es(e);const o=de(e,ln(this.blockData));this.editor.updateEmbedData(t,o)}setData(t){this.blockData=t,this.images=Kr(t.embedData)}static create(t,e){const o=t.addCustom(`image-${e.id}`,()=>new Ft(t,e));return o.setData(e),o}static getImageObject(t,e){let o;return typeof e=="string"?o=e:o=G(e),t.getCustom(`image-${o}`)}}const NF="";function i6(n,t,e){const o=Ft.getImageObject(n,t),r=Y.default(o.getImages());if(r.length===1){n.deleteBlock(t);return}if(e===-1||e>=r.length)return;const i=$D(r);if(r.splice(e,1),r.length===1){const l=r[0],c=100*(l.flex/i);l.flex=1;const a=de([l],c);n.updateEmbedData(t,a);return}r[0].flex=NaN,Es(r);const s=de(r,o.getWidthPercent());n.updateEmbedData(t,s)}function oL(n,t,e,o){if(t.length===0||o==="after"||o==="before")return!1;let r=o.data;const i=Ft.getImageObject(n,e),s=Y.default(i.getImages());return t.forEach(l=>{const c={src:"",flex:1,width:0,height:0,virtualSize:!0};s.splice(r,0,c);const a=de(s,i.getWidthPercent());n.updateEmbedData(e,a),i.replaceImage(r,l),r+=1}),!0}function rL(n,t,e,o,r){var s,l;if(sl(e))return oL(n,e,t,o);if(e.type!=="custom"||e.customType!=="image"||!e.data)return;const i=e.data;if(r.isSourceBlock){const c=r.targetBlock,a=H(c);let u=K(c);o==="after"&&(u+=1);const m=100*(i.boundingRect.width/n.rootContainer.getBoundingClientRect().width),C=de([i.image],m),v={id:N(),type:"embed",embedType:"image",embedData:C},w=(l=(s=n.options.componentsOptions)==null?void 0:s.image)==null?void 0:l.defaultAlign;w&&(v.align=w),n.insertBlock(U(a),u,v),i6(n,t,i.index)}else{if(typeof o=="string")return;const c=t;let a=o.data;const u=Ft.getImageObject(n,c),f=Y.default(u.getImages());a>f.length&&(a=f.length),n.undoManager.runInGroup(()=>{const m=n.getBlockById(e.blockId);if(m===c){const C=i.index,v=a,w=i.image;if(C===v||v===C+1)return;let E=v;C<v?(f.splice(v,0,w),f.splice(C,1),E-=1):(f.splice(C,1),f.splice(v,0,w));const L=de(f,u.getWidthPercent());n.updateEmbedData(c,L),u.setSelectedIndex(E)}else{f.splice(a,0,i.image),f[0].flex=NaN,Es(f);const C=de(f,u.getWidthPercent());n.updateEmbedData(c,C),i6(n,m,i.index)}})}return!0}const iL=2;function Wc(n,t,e){const o=Gn(t);if(e<=0){const s=o[0].getBoundingClientRect();return new DOMRect(s.left-4,s.top,2,s.height)}if(e===o.length){const s=o[e-1].getBoundingClientRect();return new DOMRect(s.right+2,s.top,2,s.height)}const r=o[e-1].getBoundingClientRect(),i=o[e].getBoundingClientRect();return new DOMRect((i.left+r.right)/2-1,r.top,iL,r.height)}function sL(n,t,e,o,r){for(let i=0;i<e.length;i++){const l=e[i].getBoundingClientRect();if(o<=l.right)return o<=l.left+l.width/2?{rect:Wc(n,t,i),data:i}:{rect:Wc(n,t,i+1),data:i+1}}return o>e[e.length-1].getBoundingClientRect().right?{rect:Wc(n,t,e.length),data:e.length}:{rect:Wc(n,t,e.length),data:0}}function lL(n,t,e,o,r){const i=Gn(t);if((e==null?void 0:e.type)!=="block"&&!(i.length>=6&&(e==null?void 0:e.blockId)!==G(t)))return sL(n,t,i,o)}const PF="";function Gc(n){const t=At(n);let e=t.querySelector(":scope > .block-helper");return e||(e=b("div",["block-helper"],t),b("span",["helper-sizer"],e,"A")),e}function yh(n,t,e){const o=Gc(n),i=Array.from(o.children).find(s=>{var c;return Number.parseInt((c=s.getAttribute("data-index"))!=null?c:"0",10)>e});o.insertBefore(t,i!=null?i:null)}const s6=40,cL=20;class aL{findTargetBlock(t,e){const o=e.target;if(o&&o instanceof Element){const c=z(o);if(c&&vt(t.rootContainer,c))return c}let r=e.clientX,i=e.clientY;const s=t.rootContainer.getBoundingClientRect().left;r<s&&s-r<s6&&(r+=s6);let l=document.elementFromPoint(r,i);if(l){const c=z(l);if(c&&vt(t.rootContainer,c))return c}if(i-=cL,l=document.elementFromPoint(r,i),l){const c=z(l);if(c&&vt(t.rootContainer,c))return c}return null}destroy(){}}class dL extends Mc{constructor(e){super(e,{trigger:[],id:"empty-block-menu"});h(this,"currentBlock",null)}get isVisible(){return this.suggest.menu.isVisible}isInMenu(e){return this.menu.isInCommandBar(e)}show(){const o=this.editor.selection.focusedBlock;this.suggest.popup(o,0,"","")}setBlock(e){this.currentBlock=e}}function uL(n,t){const e=p1(n,t);if(!e)return[];const o=[];return Object.values(e).forEach(r=>{o.push(...r.commands.map(i=>({...i,source:"block-command",blockMenuItemCustomData:r.group})))}),o}function hL(n){const t=Ku(n),e=o=>{o.forEach(r=>{r.source="insert-block",r.children&&e(r.children)})};return e(t),t}function fL(n,t,e,o=!1){var a,u;const r=H(t),i=K(t);let s=i;wt(n,t)||o||(s+=1);const l=U(r),c=e;return c.commandProvider?c.commandProvider.executeCommand(n,e,{from:"block-menu",containerId:l,blockIndex:i}):(u=(a=c.blockOptions)==null?void 0:a.handleInsertEmptyBlock)==null?void 0:u.call(a,n,{containerId:l,blockIndex:s,item:e})}function mL(n,t){const e=We(n,t),o=n.getBlockData(t);return!(e!=="text"||o.heading)}function l6(n,t,e){n.getBlockData(t).heading===e?n.updateBlockData(t,{heading:null}):n.updateBlockData(t,{heading:e})}function gL(n,t,e){["left","center","right"].includes(e)?n.updateBlockData(t,{align:e}):n.updateBlockData(t,{align:null})}function pL(n,t){const o=n.getBlockData(t).quoted;n.updateBlockData(t,{quoted:o?void 0:!0})}function CL(n,t,e){const o=n.selection.range.focus;if(!o.isSimple())return;let r;switch(e){case"unordered-list":r="unordered";break;case"ordered-list":r="ordered";break;case"check-list":r="checked";break}const i=hl(n,t,"list",{offset:o.offset,data:{listType:r}});i&&n.undoManager.runInGroup(()=>{const s=K(t),l=H(t);n.deleteBlock(t),n.insertBlock(U(l),s,i.blockData)})}class bL{constructor(t,e,o){h(this,"source","text-style");h(this,"id","text-style-item");h(this,"name","Text styles");h(this,"element");h(this,"createHeadingItemElement",(t,e,o)=>{var i;const r=Dc();this.createItem("text",ns,e,mL(this.editor,t)),(i=r.insertBlockCommandItems)==null||i.forEach(s=>{s.id&&s.icon&&this.createItem(s.id,s.icon,e,o?o===Number(s.value):!1)})});h(this,"createListItemElement",(t,e,o)=>{const{checkbox:r,ordered:i}=o,l=it(t)==="list",c=l&&i===!1&&!r,a=l&&i,u=l&&!!r;this.createItem("unordered-list",Z5,e,c),this.createItem("ordered-list",Y5,e,a),this.createItem("check-list",W5,e,u)});h(this,"handleClick",(t,e)=>{var l,c;if(!e.target||!(e.target instanceof Node))return;const o=e.target instanceof Element?e.target:e.target.parentElement;if(!o)return;const r=o.closest(".text-style-item");if(!r)return;const i=r.id,s="heading-";if(i==="text"&&l6(t,this.block,null),i.startsWith(s)){const a=Number.parseInt(i.substring(s.length),10);a&&l6(t,this.block,a)}if(i==="blockquote"&&pL(t,this.block),i.startsWith("align")){const a=i.replace(/^align-/,"");gL(t,this.block,a)}(i==="unordered-list"||i==="ordered-list"||i==="check-list")&&CL(t,this.block,i),(c=(l=this.options).onAfterStyleItemClick)==null||c.call(l)});this.editor=t,this.block=e,this.options=o,this.element=this.createItemElement(t,e),t.domEvents.addEventListener(this.element,"click",this.handleClick)}createItemElement(t,e){const o=b("div",["text-styles"],null),r=b("div",["text-style-section"],o),i=t.getBlockData(e),s=i.heading,l=i.quoted,c=i.align||"left";return this.createHeadingItemElement(e,r,s),this.createListItemElement(e,r,i),this.createItem("blockquote",G5,r,!!l),this.createItem("align-left",Pr,r,c==="left"),this.createItem("align-center",ic,r,c==="center"),this.createItem("align-right",rc,r,c==="right"),o}createItem(t,e,o,r=!1){const i=["style-icon","text-style-item"];r&&i.push("active");const s=hr(e,i,o);s.id=t}}function c6(){return{source:"separator",type:"separator",id:`section-${N()}`,name:""}}const a6={copy:Q5,cut:K5,delete:J5,"lock-block":X5,"unlock-block":tp,comment:$r};function vL(n,t,e){const o=[],r=j(n,t);if(r&&o.push(new bL(n,t,e)),!wt(n,t)){r&&o.push(c6());const s=uL(n,t);s.sort((l,c)=>{var a,u;return((a=l.order)!=null?a:0)-((u=c.order)!=null?u:0)}),s.forEach(l=>{l.id in a6&&(l.icon=a6[l.id])}),o.push(...s)}const i=hL(n);return wt(n,t)?o.push(...i):o.push(c6(),{id:"insert-block-before",icon:ep,name:S.t("blockMenu.command.insertAbove"),children:i.map(s=>({...s,source:"insert-block-before"})),childrenMenuId:"quick-menu",source:"insert-block-before"},{id:"insert-block-after",icon:np,name:S.t("blockMenu.command.insertAfter"),children:i,source:"insert-block",childrenMenuId:"quick-menu"}),o}function kL(n,t,e){if(e.source==="block-command"){const o=e.blockMenuItemCustomData;ng(n,t,o,e)}else(e.source==="insert-block"||e.source==="insert-block-before")&&fL(n,t,e,e.source==="insert-block-before")}function Zc(n,t){return n.getBlockData(t).lock}function wh(n,t){return!!Zc(n,t)}function Yc(n,t){const e=Zc(n,t);return e?e.userId===n.doc.getUser().userId:!1}function yL(n,t){const e=Zc(n,t);return e?e.userId!==n.doc.getUser().userId:!1}function wL(n,t){if(n.readonly||!n.isBlockWritable(t)||wh(n,t)&&!Yc(n,t))return;const e=n.doc.getUser(),o={userId:e.userId,displayName:e.displayName,locked:Date.now()},i={...n.getBlockData(t),lock:o};n.updateBlockData(t,i)}function BL(n,t){if(!Yc(n,t))return;const e={lock:null};n.updateBlockData(t,e)}class d6{constructor(){h(this,"executeCommand",(t,e,o)=>{const r=o.data;if(!r||!r.blockId)return;const i=t.getBlockById(r.blockId);r.type==="lock"?wL(t,i):r.type==="unlock"&&BL(t,i)})}create(t,e,o,r,i){const s=i.lock;s&&(s.userId!==t.doc.getUser().userId?M(r,"locked-by-others"):M(r,"locked-by-self"))}writable(t,e){if(yL(t,e))return!1}commands(t,e){const o=wh(t,e),r=Yc(t,e),i={blockId:G(e),type:"lock"},s={id:"lock-block",name:"",data:i,order:10};if(o)if(r)s.id="unlock-block",s.name=S.t("locker.unlock"),i.type="unlock";else{const l=Zc(t,e);s.name=S.t("locker.lockedBy",{name:(l==null?void 0:l.displayName)||""}),s.states=["disabled"]}else s.name=S.t("locker.lock");return{group:"block-locker",commands:[s],executeCommand:this.executeCommand}}}const $F="",EL={locker:{lock:"\u9501\u5B9A",unlock:"\u89E3\u9664\u9501\u5B9A",lockedBy:"\u88AB {name} \u9501\u5B9A"}},IL={locker:{lock:"Lock",unlock:"Unlock",lockedBy:"Locked by {name}"}};S.mergeLang({"zh-CN":EL,"en-US":IL});const xL=y("standard-block-actions");class SL{constructor(){h(this,"executeCommand",(t,e,o)=>{const r=o.data;try{const i=t.getBlockById(r);if(o.id==="delete"){t.deleteBlock(i);return}o.id==="copy"&&cd(t,i),o.id==="cut"&&(cd(t,i),t.deleteBlock(i))}catch(i){xL.error(`failed to execute block command: ${JSON.stringify(i)}`)}})}commands(t,e){const o=wh(t,e),r=o&&Yc(t,e),i=G(e);return{group:"standard-block-actions",commands:[{id:"copy",name:"Copy",data:i,order:1},{id:"cut",name:"Cut",data:i,order:2,states:o&&!r?["disabled"]:[]},{id:"delete",name:"Delete",data:i,order:3,states:o&&!r?["disabled"]:[]}],executeCommand:this.executeCommand}}}const u6=y("block-menu");class TL{constructor(t){h(this,"menu");h(this,"currentBlock",null);h(this,"commandBlock",null);h(this,"handleShow",()=>{d(u6,this.currentBlock,"no target block before show block menu");const t=vL(this.editor,this.currentBlock,{onAfterStyleItemClick:this.close});this.menu.updateItems(t),this.commandBlock=this.currentBlock});h(this,"handleClose",()=>{this.editor.focus()});h(this,"handleItemClick",(t,e)=>{d(u6,this.commandBlock,"no command block before show block menu"),kL(this.editor,this.commandBlock,e),!e.element&&!e.children&&this.close()});h(this,"close",()=>{this.menu.close()});this.editor=t,this.menu=new Wo([],void 0,{id:"block-menu"}),this.menu.on("show",this.handleShow),this.menu.on("close",this.handleClose),this.menu.on("click",this.handleItemClick),t.blockHooks.push(new SL)}show(t){this.menu.manualShow(t,{placement:"bottom-start"})}isInMenu(t){return this.menu.isInCommandBar(t)}setBlock(t){this.currentBlock=t}get isVisible(){return this.menu.isVisible}destroy(){this.menu.destroy()}}const h6=`<svg width="16" height="17" viewBox="0 0 16 17" fill="none" xmlns="http://www.w3.org/2000/svg">
461
461
  <path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M6.33341 3.48568C6.33341 4.22204 5.73645 4.81901 5.00008 4.81901C4.26371 4.81901 3.66675 4.22204 3.66675 3.48568C3.66675 2.7493 4.26371 2.15234 5.00008 2.15234C5.73645 2.15234 6.33341 2.7493 6.33341 3.48568ZM5.00008 9.48568C5.73645 9.48568 6.33341 8.88871 6.33341 8.15234C6.33341 7.41598 5.73645 6.81901 5.00008 6.81901C4.26371 6.81901 3.66675 7.41598 3.66675 8.15234C3.66675 8.88871 4.26371 9.48568 5.00008 9.48568ZM5.00008 14.1523C5.73645 14.1523 6.33341 13.5554 6.33341 12.819C6.33341 12.0826 5.73645 11.4857 5.00008 11.4857C4.26371 11.4857 3.66675 12.0826 3.66675 12.819C3.66675 13.5554 4.26371 14.1523 5.00008 14.1523Z" />
462
462
  <path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M12.3334 3.48568C12.3334 4.22204 11.7364 4.81901 11.0001 4.81901C10.2637 4.81901 9.66675 4.22204 9.66675 3.48568C9.66675 2.7493 10.2637 2.15234 11.0001 2.15234C11.7364 2.15234 12.3334 2.7493 12.3334 3.48568ZM11.0001 9.48568C11.7364 9.48568 12.3334 8.88871 12.3334 8.15234C12.3334 7.41598 11.7364 6.81901 11.0001 6.81901C10.2637 6.81901 9.66675 7.41598 9.66675 8.15234C9.66675 8.88871 10.2637 9.48568 11.0001 9.48568ZM11.0001 14.1523C11.7364 14.1523 12.3334 13.5554 12.3334 12.819C12.3334 12.0826 11.7364 11.4857 11.0001 11.4857C10.2637 11.4857 9.66675 12.0826 9.66675 12.819C9.66675 13.5554 10.2637 14.1523 11.0001 14.1523Z" />
463
463
  </svg>
@@ -473,7 +473,7 @@ c0-27.6-22.4-50-50-50H662c-27.6,0-50,22.4-50,50H412c0-27.6-22.4-50-50-50h-45.8C3
473
473
  </g>
474
474
  </svg>`,ML=y("drag-preview-image");class RL{constructor(t){h(this,"startPosition",null);h(this,"dragContainer",null);h(this,"handleDragStart",async(t,e)=>{const o=t.target;d(ML,o instanceof HTMLButtonElement,`Invalid Drag target:${o}`);const{x:r,y:i}=t;this.startPosition={x:r,y:i};const s=b("div",["drag-image-container"],this.editor.rootContainer),l=b("img",["drag-image"],s),c=b("span",["drag-loading"],s);c.innerHTML=LL;const{x:a,width:u,height:f,y:m}=o.getBoundingClientRect();s.style.left=`${a+u}px`,s.style.top=`${m+f}px`,this.dragContainer=s;const C=await e;C?l.src=C:M(s,"drag-placeholder"),qa(s,{status:"loaded"})});h(this,"handleDrag",t=>{if(this.startPosition&&this.dragContainer){const{x:e,y:o}=t;if(e===0&&o===0){this.dragContainer.style.transition="transform 0.15s, opacity .15s",this.dragContainer.style.transform="",this.dragContainer.style.opacity="0";return}const{x:r,y:i}=this.startPosition,s=e-r,l=o-i;this.dragContainer.style.transform=`translate(${s}px, ${l}px)`}});h(this,"handleDragEnd",()=>{this.dragContainer&&(this.dragContainer.remove(),this.startPosition=null,this.dragContainer=null)});this.editor=t}}const AL=1e3;async function OL(n,t){const{width:e}=n.rootContainer.getBoundingClientRect(),o=t.getBoundingClientRect();return o.width>e||o.height>=AL?"":(await f8.default.toSvg(t)).replace(/margin-block:.*?;/,"").replace(/margin:.*?;/,"")}const f6="drag-preview-element";function _L(n){if(lt(n,f6))return n;const t=n.querySelector(`.${f6}`);return t||rt(n)}const Bh=y("block-menu-drag-handler");class NL{constructor(t,e){h(this,"dragPreview");h(this,"autoScroll");h(this,"oldPos",{x:0,y:0});h(this,"handleDragStart",t=>{var i,s;const e=t.dataTransfer;e&&(e.dropEffect="move");const o=this.button.blockMenu.currentBlock;d(Bh,o,"no dragged block"),(s=(i=kt(this.editor,o)).notify)==null||s.call(i,this.editor,"beginDrag"),jL(this.editor,t,o),window.isDragging=!0,this.button.buttonElement.style.opacity="0";const r=_L(o);this.dragPreview.handleDragStart(t,OL(this.editor,r)),this.autoScroll.active(),M(o,"dragging")});h(this,"handleDrag",t=>{const{target:e,x:o,y:r}=t;this.oldPos.x===o&&this.oldPos.y===r||(this.oldPos={x:o,y:r},d(Bh,e instanceof HTMLElement,"target is invalid"),o===0&&r===0&&this.autoScroll.inactive(),this.dragPreview.handleDrag(t))});h(this,"handleDragEnd",()=>{const t=this.button.blockMenu.currentBlock;d(Bh,t,"no dragged block"),window.isDragging=!1,this.button.buttonElement.style.opacity="1",this.dragPreview.handleDragEnd(),this.autoScroll.inactive(),F(t,"dragging")});this.editor=t,this.button=e;const o=this.button.buttonElement;o.draggable=!0,o.addEventListener("dragstart",this.handleDragStart),o.addEventListener("dragend",this.handleDragEnd),o.addEventListener("drag",this.handleDrag),this.dragPreview=new RL(t);const r=Nn(o);this.autoScroll=new bm({scrollElement:r,trackMouseEvent:"drag",edge:{top:50,bottom:50}})}destroy(){const t=this.button.buttonElement;t.removeEventListener("dragstart",this.handleDragStart),t.removeEventListener("dragend",this.handleDragEnd),t.removeEventListener("drag",this.handleDrag)}}class Ss{constructor(t){h(this,"highlightedBlockId","");h(this,"handleSelectionChange",()=>{this.clearHighlightedBlock()});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChange)}highlightBlock(t){this.clearHighlightedBlock(),this.highlightedBlockId=G(t),M(t,"highlighted")}clearHighlightedBlock(){if(this.highlightedBlockId){const t=this.editor.findBlockById(this.highlightedBlockId);t&&F(t,"highlighted"),this.highlightedBlockId=""}}destroy(){}static register(t){return t.addCustom("editor-block-highlighter",()=>new Ss(t))}static get(t){return t.getCustom("editor-block-highlighter")}}class m6{constructor(t){h(this,"buttonElement");h(this,"emptyBlockMenu");h(this,"blockMenu");h(this,"dragHandler");h(this,"handleHoverBlock",(t,e,o)=>{if(this.emptyBlockMenu.isVisible||this.blockMenu.isVisible||!this.editor.isWritable())return;const r=this.editor.getCustom("editor-tooltip");if(r&&r.visible()&&(r.hide(),this.buttonElement.setAttribute("data-tooltip-hide-at",`${Date.now()}`)),!t){this.buttonElement.parentElement&&(this.blockMenu.isInMenu(o.target)||this.buttonElement.remove());return}const i=ul(t);this.editor.getBlockIndex(i)===0&&this.editor.getBlockData(i).heading===1||(this.updateButton(i),yh(i,this.buttonElement,Number.MAX_SAFE_INTEGER))});h(this,"handleButtonClick",()=>{if(this.buttonElement.getAttribute("data-type")==="move"){const o=this.blockMenu.currentBlock;if(!o)return;this.editor.selection.selectBlock(o,0),this.blockMenu.show(this.buttonElement),setTimeout(()=>{Ss.get(this.editor).highlightBlock(o)});return}const e=this.emptyBlockMenu.currentBlock;!e||(this.editor.selection.selectBlock(e,0),setTimeout(()=>{this.editor.focus(),this.updatePlaceholder(e),this.emptyBlockMenu.show()}))});h(this,"updatePlaceholder",t=>{rt(t).setAttribute("data-content-placeholder",S.t("blockMenu.button.searchPlaceholder"))});h(this,"handleChanged",()=>{const t=this.emptyBlockMenu.currentBlock;if(!t)return;const e=wt(this.editor,t)?"insert":"move";this.buttonElement.getAttribute("data-type")!==e&&this.setButtonType(e)});this.editor=t,this.buttonElement=this.createButton(),this.emptyBlockMenu=new dL(t),this.blockMenu=new TL(t),this.editor.addListener("docChanged",this.handleChanged),this.buttonElement.addEventListener("click",this.handleButtonClick),this.dragHandler=new NL(this.editor,this);const e=_t.get(t);e.addListener("change",this.handleHoverBlock),e.addFinder(new aL),Ss.register(this.editor)}destroy(){_t.get(this.editor).removeListener("change",this.handleHoverBlock),this.buttonElement.removeEventListener("click",this.handleButtonClick),this.editor.removeListener("docChanged",this.handleChanged),this.emptyBlockMenu.destroy(),this.blockMenu.destroy(),this.buttonElement.remove(),this.dragHandler.destroy()}createButton(){const t=b("button",["block-button"],null);return t.setAttribute(`data-editor-tooltip-${this.editor.clientId}`,S.t("blockMenu.button.tips")),t.innerHTML=h6,t}setButtonType(t){this.buttonElement.setAttribute("data-type",t);const e=`data-editor-tooltip-${this.editor.clientId}`;t==="insert"?(this.buttonElement.innerHTML=DL,this.buttonElement.removeAttribute(e)):(this.buttonElement.innerHTML=h6,this.buttonElement.setAttribute(e,S.t("blockMenu.button.tips")))}updateButton(t){this.emptyBlockMenu.setBlock(t),this.blockMenu.setBlock(t),wt(this.editor,t)?this.setButtonType("insert"):this.setButtonType("move")}}const PL={blockMenu:{section:{basics:"\u57FA\u7840",system:"\u7CFB\u7EDF",styles:"\u6837\u5F0F",common:"\u901A\u7528",actions:"\u64CD\u4F5C",thirdParty:"\u7B2C\u4E09\u65B9\u5185\u5BB9"},command:{insertAbove:"Insert above",insertAfter:"Insert after"},button:{searchPlaceholder:"\u8F93\u5165\u5173\u952E\u8BCD\u641C\u7D22",tips:`\u957F\u6309\u62D6\u62FD
475
475
  \u70B9\u51FB\u6253\u5F00\u83DC\u5355`}}},$L={blockMenu:{section:{basics:"Basics",system:"System",styles:"Styles",common:"Common",actions:"Actions",thirdParty:"Third-party content"},command:{insertAbove:"Insert above",insertAfter:"Insert after"},button:{searchPlaceholder:"Type to filter",tips:`Long press drag
476
- Click to open the menu`}}};S.mergeLang({"zh-CN":PL,"en-US":$L});const HF="";class HL{constructor(){h(this,"dragObject",null)}setData(t){this.dragObject=t}getData(){return this.dragObject}clearData(){this.dragObject=null}destroy(){}}function Qc(n){return n.addCustom("drag-data",()=>new HL)}function Eh(n,t){if(!t)return null;const e=Qc(n).getData();return!e||e.editorId!==n.id?null:e}function g6(n,t){const e=Eh(n,t);return e?n.findBlockById(e.blockId):null}function jL(n,t,e){if(!t.dataTransfer)return;const r=H(e),i=V(r),s=G(e),l={type:"block",editorId:n.id,containerId:i,blockId:s};Qc(n).setData(l)}function FL(n,t,e,o,r){if(!t.dataTransfer)return;const s=H(e),l=V(s),c=G(e),a={type:"custom",customType:o,editorId:n.id,containerId:l,blockId:c,data:r};Qc(n).setData(a)}function p6(n){Qc(n).clearData()}const zL=y("drop-indicator"),Kc=2;class VL{constructor(t){h(this,"indicator");h(this,"target",null);this.editor=t,this.indicator=b("div",["editor-drop-indicator"],this.editor.contentElement)}show(t,e){const o=this.getIndicatorRect(t,e),r=this.editor.rootElement.getBoundingClientRect(),i=o.top-r.top,s=o.left-r.left;this.indicator.style.top=`${i}px`,this.indicator.style.left=`${s}px`,this.indicator.style.width=`${o.width}px`,this.indicator.style.height=`${o.height}px`,this.indicator.style.display="",this.target={block:t,insertPos:e}}hide(){this.indicator.style.display="none",this.target=null}getIndicatorRect(t,e){if(typeof e!="string")return e.rect;if(e==="before"){const s=pr(t);if(!s){d(zL,qe(H(t)),"block does not in a child container");const a=t.getBoundingClientRect();return new DOMRect(a.x,a.y,a.width,Kc)}const l=s.getBoundingClientRect(),c=t.getBoundingClientRect();return new DOMRect(l.x,(l.bottom+c.top)/2,l.width,Kc)}const o=Cr(t);if(!o){const s=t.getBoundingClientRect();return new DOMRect(s.x,s.bottom,s.width,Kc)}const r=t.getBoundingClientRect(),i=o.getBoundingClientRect();return new DOMRect(r.x,(r.bottom+i.top)/2,r.width,Kc)}}const UL=y("find-drop-target");function qL(n,t){const e=document.elementFromPoint(n,t);if(!e)return null;if(fn(e)&&qe(e))return e;const o=e.firstElementChild;return o&&fn(o)&&qe(o)?o:null}function WL(n,t){const s=t,l=n;for(let c=0;c<2;c++){const a=l+c*50;for(let u=0;u<5;u++){const f=s+u*8,m=document.elementFromPoint(a,f);if(m){const w=z(m);if(w)return w}if(u===0)continue;const C=s-u*8,v=document.elementFromPoint(a,C);if(v){const w=z(v);if(w)return w}}}return null}function GL(n,t,e){const o=document.elementFromPoint(t,e);if(o){const u=z(o);if(u&&!ct(n,u))return u}const r=new Set,i=qL(t,e);if(i){const u=i.getBoundingClientRect();e<u.top+u.height/2?r.add(Qt(i)):r.add(Gt(i))}const s=WL(t,e);s&&r.add(s);const l=Array.from(r),c=u=>{for(let f=0;f<l.length;f++){const m=l[f];if(u!==m&&vt(u,m))return!0}return!1},a=l.filter(u=>!c(u));return a.length>0?a[0]:null}function Ih(n,t){if(n.readonly)return!1;const e=H(t);if(Ct(e))return!0;const o=z(e);return d(UL,o,"no parent block"),n.isBlockWritable(o)?Ih(n,o):!1}const ZL=y("drop-target");class YL{constructor(t){h(this,"getEmbedClassByFile",t=>{let e={};return/image/.test(t.type)?e=this.editor.editorEmbeds.getEmbedClass("image"):/audio/.test(t.type)?e=this.editor.editorEmbeds.getEmbedClass("audio"):/video/.test(t.type)&&(e=this.editor.editorEmbeds.getEmbedClass("video")),d(ZL,e,`unSupport file type ${t.type}`),e});h(this,"handleDrop",(t,e,o,r)=>{if(Array.isArray(e)){const i=e;if(i.length>0){let s=r;return i.forEach(l=>{var u,f,m;const c=this.getEmbedClassByFile(l),a=V(o);(m=(u=c.getOptions)==null?void 0:(f=u.call(c,t)).handleInsertEmptyEmbed)==null||m.call(f,t,{containerId:a,blockIndex:s,data:{file:l}}),s+=1}),!0}}return!1});this.editor=t}}class Ts{constructor(t){h(this,"indicator");h(this,"lastDropOverResult");h(this,"handlers",[]);h(this,"handleDragOver",t=>{if(!this.editor.isWritable())return;const e=i=>{const s=Eh(this.editor,i.dataTransfer),l=g6(this.editor,i.dataTransfer),c=this.findTargetBlock(l,i.x,i.y);if(c&&vt(this.editor.rootContainer,c)){const a=this.findInsertPos(l,c,i.x,i.y,s);if(a)return this.indicator.show(c,a),"move"}return this.indicator.hide(),"none"},o=(i,s)=>{i.dataTransfer&&(i.dataTransfer.dropEffect=s),s==="move"&&i.preventDefault()};if(this.lastDropOverResult&&t.x===this.lastDropOverResult.x&&t.y===this.lastDropOverResult.y){const i=this.lastDropOverResult.dropEffect;o(t,i);return}const r=e(t);o(t,r),this.lastDropOverResult={x:t.x,y:t.y,dropEffect:r}});h(this,"handleDrop",t=>{var i,s;setTimeout(()=>{this.indicator.hide()});const e=Eh(this.editor,t.dataTransfer),o=Array.from((s=(i=t.dataTransfer)==null?void 0:i.files)!=null?s:[]);if(!e&&o.length===0){t.dataTransfer&&(t.dataTransfer.dropEffect="none");return}const r=this.indicator.target;if(r){const{block:l,insertPos:c}=r,a=g6(this.editor,t.dataTransfer);this.editor.undoManager.runInGroup(()=>{const u=kt(this.editor,l);if(u.handleDrop&&u.handleDrop(this.editor,l,e!=null?e:o,c,{isSourceBlock:!1,targetBlock:l})){t.preventDefault();return}if(a){const f=kt(this.editor,a);if(f.handleDrop&&f.handleDrop(this.editor,a,e!=null?e:o,c,{isSourceBlock:!0,targetBlock:l})){t.preventDefault();return}}if(typeof c=="string"){const f=H(l);let m=K(l);c==="after"&&(m+=1),t.preventDefault();for(let C=0;C<this.handlers.length;C++)if(this.handlers[C].handleDrop(this.editor,a!=null?a:o,f,m))return;if(a){const C=this.editor.getBlockData(a),v=Fo(this.editor.editorBlocks,this.editor.doc.toJSON(),C),[w]=this.editor.insertDocAt(f,m,v);this.editor.selection.selectBlock(w,0),Ss.get(this.editor).highlightBlock(w),this.editor.deleteBlock(a)}}}),p6(this.editor)}});this.editor=t,this.indicator=new VL(this.editor),this.handlers.push(new YL(this.editor)),this.editor.contentElement.addEventListener("dragover",this.handleDragOver),this.editor.contentElement.addEventListener("drop",this.handleDrop)}destroy(){this.editor.contentElement.removeEventListener("dragover",this.handleDragOver),this.editor.contentElement.removeEventListener("drop",this.handleDrop),this.handlers=[]}addHandler(t){this.handlers.push(t)}static register(t){return t.addCustom("drop-target",()=>new Ts(t))}static get(t){return t.getCustom("drop-target")}canInsertAfter(t,e){return t===null?!0:this.editor.readonly||Cr(e)===t?!1:Ih(this.editor,e)}canInsertBefore(t,e){return this.editor.readonly?!1:t===null?!0:!(pr(e)===t||!Ih(this.editor,e)||Ct(H(e))&&K(e)===0)}canDrop(t,e){return t===null||t===e?!0:!vt(t,e)}findTargetBlock(t,e,o){const r=GL(this.editor,e,o);return!r||!vt(this.editor.rootContainer,r)||!this.canDrop(t,r)?null:r}findInsertPos(t,e,o,r,i){const s=kt(this.editor,e);if(s.handleDropOver){const c=s.handleDropOver(this.editor,e,i,o,r);if(c)return c}if(t===e)return"";const l=e.getBoundingClientRect();if(l.top<=r&&r<=l.bottom){if(r<l.top+l.height/2){if(this.canInsertBefore(t,e))return"before";if(this.canInsertAfter(t,e))return"after"}else{if(this.canInsertAfter(t,e))return"after";if(this.canInsertBefore(t,e))return"before"}return""}return r<l.top&&this.canInsertBefore(t,e)?"before":l.bottom<r&&this.canInsertAfter(t,e)?"after":""}}class QL{constructor(t){h(this,"handleDragStart",async t=>{var f;const e=t.target;if(!e||!(e instanceof HTMLImageElement))return;const o=z(e);if(!o||!cn(o))return;const r=Ft.getImageObject(this.editor,o),i=kh(t.target);if(!i)return;const l=X4(t.target).indexOf(i);if(l===-1)return;const c=r.getImages()[l];if(!c)return;const a=t.dataTransfer;a&&(a.dropEffect="move");const u={image:c,index:l,boundingRect:i.getBoundingClientRect()};FL(this.editor,t,o,"image",u),(f=t.dataTransfer)==null||f.setDragImage(e,0,0),window.isDragging=!0});h(this,"handleDragEnd",()=>{p6(this.editor),window.isDragging=!1});this.editor=t,this.editor.rootContainer.addEventListener("dragstart",this.handleDragStart),this.editor.rootContainer.addEventListener("dragend",this.handleDragEnd)}destroy(){this.editor.rootContainer.removeEventListener("dragstart",this.handleDragStart),this.editor.rootContainer.removeEventListener("dragend",this.handleDragEnd)}}class KL{constructor(t){h(this,"handleFocusBlockChanged",(t,e,o)=>{const i=this.editor.getFocusedBlock();if(i&&cn(i)){const s=Ft.getImageObject(this.editor,i);s.getImages().length>0&&s.getSelectedIndex()===-1&&s.setSelectedIndex(0)}o&&cn(o)&&Ft.getImageObject(this.editor,o).blockResizer.disableResize()});this.editor=t,this.editor.addListener("focusBlockChanged",this.handleFocusBlockChanged)}destroy(){this.editor.removeListener("focusBlockChanged",this.handleFocusBlockChanged)}}class JL{constructor(t){h(this,"handleHoveringBlockChange",(t,e)=>{e&&cn(e)&&Ft.getImageObject(this.editor,e).disableResizer(),t&&cn(t)&&Ft.getImageObject(this.editor,t).tryEnableResizer()});this.editor=t,_t.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){_t.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}}const XL={image:{upload:{failed:'<div class="line-1">\u56FE\u7247\u4E0A\u4F20\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <a href="" class="retry-upload">\u91CD\u8BD5</a></div>'},load:{failed:'<div class="line-1">\u56FE\u7247\u52A0\u8F7D\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <a href="" class="retry-upload">\u91CD\u8BD5</a></div>',remote:{failed:'<div class="line-1">\u8BE5\u56FE\u7247\u6765\u81EA\u5916\u90E8\u94FE\u63A5\uFF0C\u5916\u90E8\u94FE\u63A5\u5DF2\u5931\u6548</div><div class="line-2">\u8BF7\u5C06\u539F\u56FE\u4FDD\u5B58\u5230\u672C\u5730\u540E\u4E0A\u4F20\uFF0C <a href="" class="retry-upload">\u6253\u5F00\u56FE\u7247\u94FE\u63A5</a></div>',tooltip:"\u8BE5\u56FE\u7247\u6765\u81EA\u5916\u90E8\u94FE\u63A5\uFF0C\u5982\u679C\u94FE\u63A5\u5931\u6548\u56FE\u7247\u5C06\u65E0\u6CD5\u67E5\u770B\uFF0C\u5EFA\u8BAE\u4FDD\u5B58\u5230\u672C\u5730\u540E\u6DFB\u52A0\u5230\u9875\u9762\u4E2D"}},abstract:"\u56FE\u7247"}},tM={image:{upload:{failed:'<div class="line-1">Image upload failed</div><div class="line-2">The network service is abnormal, you can <a href="" class="retry-upload">Try again</a></div>'},load:{failed:'<div class="line-1">Image failed to load</div><div class="line-2">The network service is abnormal, you can <a href="" class="retry-upload">Try again</a></div>',remote:{failed:'<div class="line-1">The picture comes from an external link, and the external link has expired</div><div class="line-2">Please save the original image locally and then upload it. <a href="" class="retry-upload">Open image link</a></div>',tooltip:"\u8BE5\u56FE\u7247\u6765\u81EA\u5916\u90E8\u94FE\u63A5\uFF0C\u5982\u679C\u94FE\u63A5\u5931\u6548\u56FE\u7247\u5C06\u65E0\u6CD5\u67E5\u770B\uFF0C\u5EFA\u8BAE\u4FDD\u5B58\u5230\u672C\u5730\u540E\u6DFB\u52A0\u5230\u9875\u9762\u4E2D"}},image:"Image"}};S.mergeLang({"zh-CN":XL,"en-US":tM});function eM(n){const t=n.getFocusedBlock(),e=Cr(t);if(e&&cn(e)){n.selection.selectBlock(e,0);const o=Ft.getImageObject(n,e);return o.getImages().length>0&&o.setSelectedIndex(0),!0}}function nM(n){const t=n.getFocusedBlock(),e=pr(t);if(e&&cn(e)){n.selection.selectBlock(e,0);const o=Ft.getImageObject(n,e);return o.getImages().length>0&&o.setSelectedIndex(0),!0}}function oM(n){const e=n.getFocusedBlock();if(e&&cn(e)){const o=Ft.getImageObject(n,e),r=o.getImages();if(r.length>0){const i=o.getSelectedIndex();if(i===-1)return o.setSelectedIndex(r.length-1),!0;if(i>0)return o.setSelectedIndex(i-1),!0}}}function rM(n){const e=n.getFocusedBlock();if(e&&cn(e)){const o=Ft.getImageObject(n,e),r=o.getImages();if(r.length>0){const i=o.getSelectedIndex();if(i===-1)return o.setSelectedIndex(0),!0;if(i<r.length-1)return o.setSelectedIndex(i+1),!0}}}function iM(n){const t=document.createElement("canvas");t.width=n.naturalWidth,t.height=n.naturalHeight;const e=t.getContext("2d");if(!e)return;e.drawImage(n,0,0,t.width,t.height);const r=t.toDataURL("image/png").replace(/^data:image\/(png|jpg);base64,/,""),i=cm(r),s=new File([i],`${Date.now()}.png`,{type:"image/png"});return il([{type:"image/png",data:s}]),!0}function C6(n){const e=n.getFocusedBlock();if(e&&cn(e)){const o=Ft.getImageObject(n,e);if(o.getImages().length>0){const i=o.getSelectedIndex();if(i!==-1){const l=Gn(e)[i].querySelector("img");if(l)return iM(l)}}}}function xh(n){const e=n.getFocusedBlock();if(e&&cn(e)){const o=Ft.getImageObject(n,e);if(o.getImages().length>1){const i=o.getSelectedIndex();if(i!==-1)return o.removeImage(i),!0}}}function sM(n){if(C6(n))return xh(n),!0}const lM={ArrowLeft:oM,ArrowRight:rM,ArrowUp:nM,ArrowDown:eM,"CtrlOrCmd+C":C6,"CtrlOrCmd+X":sM,Delete:xh,Backspace:xh};function cM(n,t,e,o,r,i){Ft.create(n,e).createContent(r,i,t),n.addCustom("image-select-handler",()=>new KL(n)),n.addCustom("image-resizer",()=>new JL(n)),setTimeout(()=>{n.addCustom("drag-handler",()=>new QL(n))})}function aM(n,t,e,o){const r=t.embedData,i=Kr(r);return o==="html"?i.map(s=>`<img src="${s.src}">`).join(""):o==="markdown"?i.map(s=>`![img](${s.src})`).join(`
476
+ Click to open the menu`}}};S.mergeLang({"zh-CN":PL,"en-US":$L});const HF="";class HL{constructor(){h(this,"dragObject",null)}setData(t){this.dragObject=t}getData(){return this.dragObject}clearData(){this.dragObject=null}destroy(){}}function Qc(n){return n.addCustom("drag-data",()=>new HL)}function Eh(n,t){if(!t)return null;const e=Qc(n).getData();return!e||e.editorId!==n.id?null:e}function g6(n,t){const e=Eh(n,t);return e?n.findBlockById(e.blockId):null}function jL(n,t,e){if(!t.dataTransfer)return;const r=H(e),i=U(r),s=G(e),l={type:"block",editorId:n.id,containerId:i,blockId:s};Qc(n).setData(l)}function FL(n,t,e,o,r){if(!t.dataTransfer)return;const s=H(e),l=U(s),c=G(e),a={type:"custom",customType:o,editorId:n.id,containerId:l,blockId:c,data:r};Qc(n).setData(a)}function p6(n){Qc(n).clearData()}const zL=y("drop-indicator"),Kc=2;class UL{constructor(t){h(this,"indicator");h(this,"target",null);this.editor=t,this.indicator=b("div",["editor-drop-indicator"],this.editor.contentElement)}show(t,e){const o=this.getIndicatorRect(t,e),r=this.editor.rootElement.getBoundingClientRect(),i=o.top-r.top,s=o.left-r.left;this.indicator.style.top=`${i}px`,this.indicator.style.left=`${s}px`,this.indicator.style.width=`${o.width}px`,this.indicator.style.height=`${o.height}px`,this.indicator.style.display="",this.target={block:t,insertPos:e}}hide(){this.indicator.style.display="none",this.target=null}getIndicatorRect(t,e){if(typeof e!="string")return e.rect;if(e==="before"){const s=pr(t);if(!s){d(zL,qe(H(t)),"block does not in a child container");const a=t.getBoundingClientRect();return new DOMRect(a.x,a.y,a.width,Kc)}const l=s.getBoundingClientRect(),c=t.getBoundingClientRect();return new DOMRect(l.x,(l.bottom+c.top)/2,l.width,Kc)}const o=Cr(t);if(!o){const s=t.getBoundingClientRect();return new DOMRect(s.x,s.bottom,s.width,Kc)}const r=t.getBoundingClientRect(),i=o.getBoundingClientRect();return new DOMRect(r.x,(r.bottom+i.top)/2,r.width,Kc)}}const VL=y("find-drop-target");function qL(n,t){const e=document.elementFromPoint(n,t);if(!e)return null;if(fn(e)&&qe(e))return e;const o=e.firstElementChild;return o&&fn(o)&&qe(o)?o:null}function WL(n,t){const s=t,l=n;for(let c=0;c<2;c++){const a=l+c*50;for(let u=0;u<5;u++){const f=s+u*8,m=document.elementFromPoint(a,f);if(m){const w=z(m);if(w)return w}if(u===0)continue;const C=s-u*8,v=document.elementFromPoint(a,C);if(v){const w=z(v);if(w)return w}}}return null}function GL(n,t,e){const o=document.elementFromPoint(t,e);if(o){const u=z(o);if(u&&!ct(n,u))return u}const r=new Set,i=qL(t,e);if(i){const u=i.getBoundingClientRect();e<u.top+u.height/2?r.add(Qt(i)):r.add(Gt(i))}const s=WL(t,e);s&&r.add(s);const l=Array.from(r),c=u=>{for(let f=0;f<l.length;f++){const m=l[f];if(u!==m&&vt(u,m))return!0}return!1},a=l.filter(u=>!c(u));return a.length>0?a[0]:null}function Ih(n,t){if(n.readonly)return!1;const e=H(t);if(Ct(e))return!0;const o=z(e);return d(VL,o,"no parent block"),n.isBlockWritable(o)?Ih(n,o):!1}const ZL=y("drop-target");class YL{constructor(t){h(this,"getEmbedClassByFile",t=>{let e={};return/image/.test(t.type)?e=this.editor.editorEmbeds.getEmbedClass("image"):/audio/.test(t.type)?e=this.editor.editorEmbeds.getEmbedClass("audio"):/video/.test(t.type)&&(e=this.editor.editorEmbeds.getEmbedClass("video")),d(ZL,e,`unSupport file type ${t.type}`),e});h(this,"handleDrop",(t,e,o,r)=>{if(Array.isArray(e)){const i=e;if(i.length>0){let s=r;return i.forEach(l=>{var u,f,m;const c=this.getEmbedClassByFile(l),a=U(o);(m=(u=c.getOptions)==null?void 0:(f=u.call(c,t)).handleInsertEmptyEmbed)==null||m.call(f,t,{containerId:a,blockIndex:s,data:{file:l}}),s+=1}),!0}}return!1});this.editor=t}}class Ts{constructor(t){h(this,"indicator");h(this,"lastDropOverResult");h(this,"handlers",[]);h(this,"handleDragOver",t=>{if(!this.editor.isWritable())return;const e=i=>{const s=Eh(this.editor,i.dataTransfer),l=g6(this.editor,i.dataTransfer),c=this.findTargetBlock(l,i.x,i.y);if(c&&vt(this.editor.rootContainer,c)){const a=this.findInsertPos(l,c,i.x,i.y,s);if(a)return this.indicator.show(c,a),"move"}return this.indicator.hide(),"none"},o=(i,s)=>{i.dataTransfer&&(i.dataTransfer.dropEffect=s),s==="move"&&i.preventDefault()};if(this.lastDropOverResult&&t.x===this.lastDropOverResult.x&&t.y===this.lastDropOverResult.y){const i=this.lastDropOverResult.dropEffect;o(t,i);return}const r=e(t);o(t,r),this.lastDropOverResult={x:t.x,y:t.y,dropEffect:r}});h(this,"handleDrop",t=>{var i,s;setTimeout(()=>{this.indicator.hide()});const e=Eh(this.editor,t.dataTransfer),o=Array.from((s=(i=t.dataTransfer)==null?void 0:i.files)!=null?s:[]);if(!e&&o.length===0){t.dataTransfer&&(t.dataTransfer.dropEffect="none");return}const r=this.indicator.target;if(r){const{block:l,insertPos:c}=r,a=g6(this.editor,t.dataTransfer);this.editor.undoManager.runInGroup(()=>{const u=kt(this.editor,l);if(u.handleDrop&&u.handleDrop(this.editor,l,e!=null?e:o,c,{isSourceBlock:!1,targetBlock:l})){t.preventDefault();return}if(a){const f=kt(this.editor,a);if(f.handleDrop&&f.handleDrop(this.editor,a,e!=null?e:o,c,{isSourceBlock:!0,targetBlock:l})){t.preventDefault();return}}if(typeof c=="string"){const f=H(l);let m=K(l);c==="after"&&(m+=1),t.preventDefault();for(let C=0;C<this.handlers.length;C++)if(this.handlers[C].handleDrop(this.editor,a!=null?a:o,f,m))return;if(a){const C=this.editor.getBlockData(a),v=Fo(this.editor.editorBlocks,this.editor.doc.toJSON(),C),[w]=this.editor.insertDocAt(f,m,v);this.editor.selection.selectBlock(w,0),Ss.get(this.editor).highlightBlock(w),this.editor.deleteBlock(a)}}}),p6(this.editor)}});this.editor=t,this.indicator=new UL(this.editor),this.handlers.push(new YL(this.editor)),this.editor.contentElement.addEventListener("dragover",this.handleDragOver),this.editor.contentElement.addEventListener("drop",this.handleDrop)}destroy(){this.editor.contentElement.removeEventListener("dragover",this.handleDragOver),this.editor.contentElement.removeEventListener("drop",this.handleDrop),this.handlers=[]}addHandler(t){this.handlers.push(t)}static register(t){return t.addCustom("drop-target",()=>new Ts(t))}static get(t){return t.getCustom("drop-target")}canInsertAfter(t,e){return t===null?!0:this.editor.readonly||Cr(e)===t?!1:Ih(this.editor,e)}canInsertBefore(t,e){return this.editor.readonly?!1:t===null?!0:!(pr(e)===t||!Ih(this.editor,e)||Ct(H(e))&&K(e)===0)}canDrop(t,e){return t===null||t===e?!0:!vt(t,e)}findTargetBlock(t,e,o){const r=GL(this.editor,e,o);return!r||!vt(this.editor.rootContainer,r)||!this.canDrop(t,r)?null:r}findInsertPos(t,e,o,r,i){const s=kt(this.editor,e);if(s.handleDropOver){const c=s.handleDropOver(this.editor,e,i,o,r);if(c)return c}if(t===e)return"";const l=e.getBoundingClientRect();if(l.top<=r&&r<=l.bottom){if(r<l.top+l.height/2){if(this.canInsertBefore(t,e))return"before";if(this.canInsertAfter(t,e))return"after"}else{if(this.canInsertAfter(t,e))return"after";if(this.canInsertBefore(t,e))return"before"}return""}return r<l.top&&this.canInsertBefore(t,e)?"before":l.bottom<r&&this.canInsertAfter(t,e)?"after":""}}class QL{constructor(t){h(this,"handleDragStart",async t=>{var f;const e=t.target;if(!e||!(e instanceof HTMLImageElement))return;const o=z(e);if(!o||!cn(o))return;const r=Ft.getImageObject(this.editor,o),i=kh(t.target);if(!i)return;const l=X4(t.target).indexOf(i);if(l===-1)return;const c=r.getImages()[l];if(!c)return;const a=t.dataTransfer;a&&(a.dropEffect="move");const u={image:c,index:l,boundingRect:i.getBoundingClientRect()};FL(this.editor,t,o,"image",u),(f=t.dataTransfer)==null||f.setDragImage(e,0,0),window.isDragging=!0});h(this,"handleDragEnd",()=>{p6(this.editor),window.isDragging=!1});this.editor=t,this.editor.rootContainer.addEventListener("dragstart",this.handleDragStart),this.editor.rootContainer.addEventListener("dragend",this.handleDragEnd)}destroy(){this.editor.rootContainer.removeEventListener("dragstart",this.handleDragStart),this.editor.rootContainer.removeEventListener("dragend",this.handleDragEnd)}}class KL{constructor(t){h(this,"handleFocusBlockChanged",(t,e,o)=>{const i=this.editor.getFocusedBlock();if(i&&cn(i)){const s=Ft.getImageObject(this.editor,i);s.getImages().length>0&&s.getSelectedIndex()===-1&&s.setSelectedIndex(0)}o&&cn(o)&&Ft.getImageObject(this.editor,o).blockResizer.disableResize()});this.editor=t,this.editor.addListener("focusBlockChanged",this.handleFocusBlockChanged)}destroy(){this.editor.removeListener("focusBlockChanged",this.handleFocusBlockChanged)}}class JL{constructor(t){h(this,"handleHoveringBlockChange",(t,e)=>{e&&cn(e)&&Ft.getImageObject(this.editor,e).disableResizer(),t&&cn(t)&&Ft.getImageObject(this.editor,t).tryEnableResizer()});this.editor=t,_t.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){_t.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}}const XL={image:{upload:{failed:'<div class="line-1">\u56FE\u7247\u4E0A\u4F20\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <a href="" class="retry-upload">\u91CD\u8BD5</a></div>'},load:{failed:'<div class="line-1">\u56FE\u7247\u52A0\u8F7D\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <a href="" class="retry-upload">\u91CD\u8BD5</a></div>',remote:{failed:'<div class="line-1">\u8BE5\u56FE\u7247\u6765\u81EA\u5916\u90E8\u94FE\u63A5\uFF0C\u5916\u90E8\u94FE\u63A5\u5DF2\u5931\u6548</div><div class="line-2">\u8BF7\u5C06\u539F\u56FE\u4FDD\u5B58\u5230\u672C\u5730\u540E\u4E0A\u4F20\uFF0C <a href="" class="retry-upload">\u6253\u5F00\u56FE\u7247\u94FE\u63A5</a></div>',tooltip:"\u8BE5\u56FE\u7247\u6765\u81EA\u5916\u90E8\u94FE\u63A5\uFF0C\u5982\u679C\u94FE\u63A5\u5931\u6548\u56FE\u7247\u5C06\u65E0\u6CD5\u67E5\u770B\uFF0C\u5EFA\u8BAE\u4FDD\u5B58\u5230\u672C\u5730\u540E\u6DFB\u52A0\u5230\u9875\u9762\u4E2D"}},abstract:"\u56FE\u7247"}},tM={image:{upload:{failed:'<div class="line-1">Image upload failed</div><div class="line-2">The network service is abnormal, you can <a href="" class="retry-upload">Try again</a></div>'},load:{failed:'<div class="line-1">Image failed to load</div><div class="line-2">The network service is abnormal, you can <a href="" class="retry-upload">Try again</a></div>',remote:{failed:'<div class="line-1">The picture comes from an external link, and the external link has expired</div><div class="line-2">Please save the original image locally and then upload it. <a href="" class="retry-upload">Open image link</a></div>',tooltip:"\u8BE5\u56FE\u7247\u6765\u81EA\u5916\u90E8\u94FE\u63A5\uFF0C\u5982\u679C\u94FE\u63A5\u5931\u6548\u56FE\u7247\u5C06\u65E0\u6CD5\u67E5\u770B\uFF0C\u5EFA\u8BAE\u4FDD\u5B58\u5230\u672C\u5730\u540E\u6DFB\u52A0\u5230\u9875\u9762\u4E2D"}},image:"Image"}};S.mergeLang({"zh-CN":XL,"en-US":tM});function eM(n){const t=n.getFocusedBlock(),e=Cr(t);if(e&&cn(e)){n.selection.selectBlock(e,0);const o=Ft.getImageObject(n,e);return o.getImages().length>0&&o.setSelectedIndex(0),!0}}function nM(n){const t=n.getFocusedBlock(),e=pr(t);if(e&&cn(e)){n.selection.selectBlock(e,0);const o=Ft.getImageObject(n,e);return o.getImages().length>0&&o.setSelectedIndex(0),!0}}function oM(n){const e=n.getFocusedBlock();if(e&&cn(e)){const o=Ft.getImageObject(n,e),r=o.getImages();if(r.length>0){const i=o.getSelectedIndex();if(i===-1)return o.setSelectedIndex(r.length-1),!0;if(i>0)return o.setSelectedIndex(i-1),!0}}}function rM(n){const e=n.getFocusedBlock();if(e&&cn(e)){const o=Ft.getImageObject(n,e),r=o.getImages();if(r.length>0){const i=o.getSelectedIndex();if(i===-1)return o.setSelectedIndex(0),!0;if(i<r.length-1)return o.setSelectedIndex(i+1),!0}}}function iM(n){const t=document.createElement("canvas");t.width=n.naturalWidth,t.height=n.naturalHeight;const e=t.getContext("2d");if(!e)return;e.drawImage(n,0,0,t.width,t.height);const r=t.toDataURL("image/png").replace(/^data:image\/(png|jpg);base64,/,""),i=cm(r),s=new File([i],`${Date.now()}.png`,{type:"image/png"});return il([{type:"image/png",data:s}]),!0}function C6(n){const e=n.getFocusedBlock();if(e&&cn(e)){const o=Ft.getImageObject(n,e);if(o.getImages().length>0){const i=o.getSelectedIndex();if(i!==-1){const l=Gn(e)[i].querySelector("img");if(l)return iM(l)}}}}function xh(n){const e=n.getFocusedBlock();if(e&&cn(e)){const o=Ft.getImageObject(n,e);if(o.getImages().length>1){const i=o.getSelectedIndex();if(i!==-1)return o.removeImage(i),!0}}}function sM(n){if(C6(n))return xh(n),!0}const lM={ArrowLeft:oM,ArrowRight:rM,ArrowUp:nM,ArrowDown:eM,"CtrlOrCmd+C":C6,"CtrlOrCmd+X":sM,Delete:xh,Backspace:xh};function cM(n,t,e,o,r,i){Ft.create(n,e).createContent(r,i,t),n.addCustom("image-select-handler",()=>new KL(n)),n.addCustom("image-resizer",()=>new JL(n)),setTimeout(()=>{n.addCustom("drag-handler",()=>new QL(n))})}function aM(n,t,e,o){const r=t.embedData,i=Kr(r);return o==="html"?i.map(s=>`<img src="${s.src}">`).join(""):o==="markdown"?i.map(s=>`![img](${s.src})`).join(`
477
477
  `):i.map(s=>s.src).join(`
478
478
  `)}class dM{constructor(){h(this,"group","image");h(this,"commands",[])}executeCommand(t,e,o){if(o.id==="replace-image"){const{block:r,image:i}=o.data;Ft.getImageObject(t,r).replaceImage(0,i)}}}function uM(){return{blockCommands:{image:new dM},abstract:`[${S.t("image.abstract")}]`}}function hM(){return{name:"Image",insertEmbedCommandItems:[{id:"insert-image",name:"Image",icon:x5,group:"common",shortcut:"/image",order:100}],handleInsertEmptyEmbed:async(n,t)=>{var u;let e;if((u=t.data)!=null&&u.file&&(e=t.data.file),e=e!=null?e:await fr("image/*",{}),!e)return null;const o=await nL(e),r={src:"",width:o.width,height:o.height,flex:1,virtualSize:!1},i=de([r],100),s={id:N(),type:"embed",embedType:"image",embedData:i},l=n.options.componentsOptions.image;l!=null&&l.defaultAlign&&(s.align=l.defaultAlign);const c=n.insertBlock(t.containerId,t.blockIndex,s);return Ft.getImageObject(n,c).replaceImage(0,e),c}}}function fM(n,t,e){var u;const{data:o}=e,r=n.getBlockString(t).trim();if(!o||o.embedType!=="image"||!j(n,t))return null;const i=r.match(/^!\[[^\]]*\]\((?<filename>.*?)(?="|\))(?<optionalPart>".*")?\)/),s=(u=i==null?void 0:i.groups)==null?void 0:u.filename;if(!s)return null;const l={src:s},c={id:N(),type:"embed",embedType:"image",embedData:l},a=n.options.componentsOptions.image.defaultAlign;return a&&(c.align=a),{blockData:c}}function mM(n,t){const e=G(t);n.destroyCustom(`image-${e}`)}const b6={embedType:"image",createEmbedContent:cM,convertTo:aM,convertFrom:fM,getBlockProperties:uM,getOptions:hM,handleDrop:rL,handleDropOver:lL,handleDeleteBlock:mM},v6={"en-US":{title:"UML",empty:"Empty Graph",loading:"Loading diagram editor...",abstract:"UML"},"zh-CN":{title:"\u6D41\u7A0B\u56FE/UML",empty:"\u7A7A\u56FE\u8868",loading:"\u52A0\u8F7D\u4E2D",abstract:"\u6D41\u7A0B\u56FE/UML"}};function gM(n,t){const e={};t&&Object.entries(v6).forEach(([o,r])=>{e[o]={[`${t}`]:r}}),S.mergeLang(e||n)}function pM(){gM(v6,"drawio")}class CM{constructor(){h(this,"isAlreadyInstalled",!1)}stamp(){this.isAlreadyInstalled=!0}isFirstInit(){return this.isAlreadyInstalled===!1}destroy(){}}function bM(n){const t=Object.entries(n);for(let e=0;e<t.length;e++){const[o,r]=t[e];if(o.toLocaleLowerCase()==="content-type")return r}return""}async function vM(n,t,e=!0){try{const o=await n.doc.request(t,{method:"get",responseType:"blob",withCredentials:e}),r=new FileReader,i=new Promise((u,f)=>{r.onload=u,r.onerror=f});r.readAsArrayBuffer(o.data),await i;const s=r.result,l=bM(o.headers).toLocaleLowerCase();let c="";if(l){const u=Of.default[l].extensions;u&&u.length>0&&(c=u[0])}return new File([s],`${Date.now()}.${c}`,{type:l})}catch{return null}}async function Sh(n,t){return await vM(n,t)}async function k6(n,t){const e=await Sh(n,t);return e?await e.text():null}const kM=n=>{const t=n.getBoundingClientRect();return t.width<=1&&t.height<=1},yM=n=>{var i,s;const t=(i=n.getAttribute("width"))!=null?i:"",e=(s=n.getAttribute("height"))!=null?s:"",o=Number.parseInt(t,10),r=Number.parseInt(e,10);return!o||!r||o<=1&&r<=1},wM=n=>n!=null?n[n.textContent===void 0?"text":"textContent"]:"",y6={"zh-CN":"zh","zh-TW":"zh-tw","js-JP":"zh"},BM="https://embed.diagrams.net/?embed=1",EM="https://www.draw.io/embed.js",IM="https://cdn.jsdelivr.net/npm/pako@2.0.3/dist/pako.es5.js",xM=`
479
479
  <mxStylesheet>
@@ -585,8 +585,8 @@ c0-27.6-22.4-50-50-50H662c-27.6,0-50,22.4-50,50H412c0-27.6-22.4-50-50-50h-45.8C3
585
585
  <add as="fillColor" value="#ffffff"/>
586
586
  </add>
587
587
  </mxStylesheet>
588
- `,w6=0,SM=30*1e3,B6="editor-empty-drawio",E6="show-full-screen-iframe",zt=y("embed-block-drawio");function Jr(n){return n.options.componentsOptions.drawIO||{}}function TM(n){const e=Jr(n).lang||"zh-CN";return y6[e]||y6["zh-CN"]}function DM(n){var r;const e=((r=(Jr(n)||{}).cdn)==null?void 0:r.drawioIframe)||BM,o=TM(n);return Xa(e,{spin:1,proto:"json",configure:1,lang:o})}function LM(n){const t=()=>{d(zt,n,"el does not exist");const o=document.body.clientWidth||document.documentElement.clientWidth,r=document.body.clientHeight||document.documentElement.clientHeight;n.setAttribute("width",`${o-2*w6}`),n.setAttribute("height",`${r-2*w6}`)},e=()=>{window.removeEventListener("resize",t)};return t(),window.addEventListener("resize",t),{disconnect:e}}async function MM(n){const e=(Jr(n)||{}).callbacks||{},{onCreateDrawIoFrame:o,onCloseDrawIoFrame:r}=e;let i=null,s;if(o)i=await o(n),d(zt,i,"iframe create failed"),s=()=>{d(zt,i,"iframe does not exist"),d(zt,r,"missing parameters: onCloseDrawIoFrame"),r(n,i)};else{const l=b("div",["editor-drawio-iframe-container","loading"],document.body);l.setAttribute("data-placeholder",S.t("drawio.loading")),i=b("iframe",["drawio-iframe-element"],l),i.setAttribute("frameborder","0"),M(l,E6);const{disconnect:c}=LM(i);s=()=>{d(zt,i,"iframe does not exist"),c(),document.body.removeChild(l),F(l,E6)}}return{drawioIframe:i,exit:s}}async function RM(n,t,e,o){var r,i;try{o&&zt.debug("auto saving drawio data");const s=new Blob([e]),l=new File([s],"drawio.svg",{type:"image/svg+xml"});try{const c=t.parentElement;d(zt,c,"targetBlock");const a=await n.doc.uploadResource(l),{resourceId:u}=a,m={...n.getBlockData(c),embedData:{src:u}};n.updateBlockData(c,m)}catch(c){const a=`failed to upload drawio data: ${c.message}`;zt.error(a)}}catch(s){const l=`failed to save drawio data: ${s.message}`,c=Jr(n);if((r=c.callbacks)!=null&&r.onError){const a=new Error(l);a.code="SaveDrawIo",(i=c.callbacks)==null||i.onError(n,a)}}}function AM(n,t,e,o,r,i,s){const l=()=>{window.removeEventListener("message",c),i()},c=async a=>{var u,f;if(d(zt,o.contentWindow,"iframe.contentWindow does not exist"),a.data.length>0){const m=JSON.parse(a.data),C=e.xmlSvg||e.xml,v=document.querySelectorAll(".editor-drawio-iframe-container");switch(m.event){case"configure":o.contentWindow.postMessage(JSON.stringify({action:"configure",config:{defaultFonts:["Humor Sans","Helvetica","Times New Roman"]}}),"*");break;case"init":C!=null&&o.contentWindow.postMessage(JSON.stringify({action:"load",saveAndExit:1,noSaveBtn:1,noExitBtn:0,xml:C}),"*"),r(),v.forEach(E=>{F(E,"loading")});break;case"export":const w=el(m.data.substring(m.data.indexOf(",")+1));RM(n,t,w,!!((u=m.message)!=null&&u.autoSave)),(f=m.message)!=null&&f.autoSave||l();break;case"save":o.contentWindow.postMessage(JSON.stringify({action:"export",format:"xmlsvg",spin:"Saving graph"}),"*");break;case"exit":l();break}}};window.addEventListener("message",c)}async function I6(n,t,e,o){if(o)return;o=!0;const r=Jr(n)||{},{callbacks:i}=r;let s;i&&(i==null?void 0:i.onBeginInitDrawIo)&&i.onBeginInitDrawIo(n,t);const{drawioIframe:l,exit:c}=await MM(n);if(e.src){const m=await k6(n,n.doc.buildResourceUrl(e.src));m&&(e.xmlSvg=m)}AM(n,t,e,l,()=>{s=setInterval(()=>{!l||!l.contentWindow||l.contentWindow.postMessage(JSON.stringify({action:"export",format:"xmlsvg",spin:"Saving graph",autoSave:!0}),"*")},SM)},()=>{c(),s&&clearInterval(s)});const f=DM(n);l.setAttribute("src",f)}async function OM(n){var r,i;const t=Jr(n),e=((r=t.cdn)==null?void 0:r.drawio)||EM,o=((i=t.cdn)==null?void 0:i.pako)||IM;await So(o,"editor-pako"),await So(e,"editor-drawio"),await new Promise(s=>{setTimeout(s,100)})}function x6(n){F(n,B6)}function Th(n){n.setAttribute("data-empty-drawio-content",S.t("drawio.empty")),M(n,B6)}function Dh(n,t){if(d(zt,t,"Required data is missing in setGraph"),"src"in t){n.setAttribute("data-src",t.src);return}if("xmlSvg"in t){n.setAttribute("data-xmlsvg",t.xmlSvg);return}if("graph"in t){const{xml:e,graph:o}=t;n.graph=o,n.setAttribute("data-mxfile",e)}}function _M(n,t,e){d(zt,n,"params error: src"),d(zt,e,"params error: editor");const o=t,r=e.doc.buildResourceUrl(n),i=document.createElement("img");o.innerHTML="",o.appendChild(i),i.src=r,Dh(o,{src:n}),i.onload=()=>{kM(i)?Th(t):x6(t)}}function NM(n,t,e){d(zt,e,"parameter missing"),OM(e).then(()=>{const{mxUtils:o,mxGraph:r,mxCodec:i}=window;d(zt,o,"External resource loading exception: mxUtils"),d(zt,r,"External resource loading exception: MxGraph"),d(zt,i,"External resource loading exception: MxCodec");const s=o.parseXml(n);t.innerHTML="";const l=s.documentElement;d(zt,l,"Resource parsing exception"),d(zt,l.nodeName==="mxfile","Resource parsing exception");const c=l.getElementsByTagName("diagram");d(zt,c.length>0,"Resource parsing exception");let a;const u=c[0];if(u.text||u.textContent){const w=wM(u),E=atob(w),L=window.pako;d(zt,L,"External resource loading exception: pako");const x=L.inflateRaw(Uint8Array.from(E,O=>O.charCodeAt(0)),{to:"string"}),A=decodeURIComponent(x);a=o.parseXml(A)}else{const w=new XMLSerializer().serializeToString(u.firstChild);a=o.parseXml(w)}const f=new r(t);f.resetViewOnRootChange=!1,f.foldingEnabled=!1,f.setTooltips(!1),f.setEnabled(!1),f.setHtmlLabels(!0);const m=o.parseXml(xM);new i(m).decode(m.documentElement,f.getStylesheet());const v=new i(a);v.decode(v.document.documentElement,f.getModel()),f.maxFitScale=1,f.fit(),f.center(!0,!1),Dh(t,{graph:f,xml:n})})}function PM(n,t){t.innerHTML=n,Dh(t,{xmlSvg:n});const e=t.querySelectorAll("svg");for(let o=0;o<e.length;o++){const r=e[o];if(!yM(r))return}Th(t)}function $M(n,t){return uh(n,t,{handleExecuteCommand:(o,r,i)=>{if(i.id==="edit"){const s=o.getBlockData(r).embedData;return I6(o,rt(r),s,!1),!0}return!1}})}const Ds=y("embed-block-drawio"),HM=!1;pM();function S6(n,t,e,o){d(Ds,e,`parameter missing: ${e}`),d(Ds,n,`parameter missing: ${n}`),I6(n,t,o,HM)}function jM(n,t,e){x6(t);const o=e;o.src?_M(o.src,t,n):o.xml?NM(o.xml,t,n):o.xmlSvg?PM(o.xmlSvg,t):Th(t)}function FM(n,t,e,o={isInit:!1}){const{isInit:r}=o,s=b("div",["editor-drawio-content","editor-embed"],null);t.appendChild(s),jM(n,s,e);const l=t.parentElement;d(Ds,l,"embedContainer parentElement node does not exist"),r&&!n.readonly&&n.domEvents.addEventListener(t,"dblclick",()=>{const c=n.getBlockData(l);S6(n,t,s,c.embedData)})}function zM(n,t,e,o,r,i){var a,u;console.log((u=(a=n.doc).getServerMeta)==null?void 0:u.call(a).serverId);debugger;const s=e.embedData,l=n.addCustom(`drawio-${e.id}`,()=>new CM),c=l.isFirstInit();c?Ds.log("create new embed block"):Ds.log("update exists embed block"),l.stamp(),FM(n,t,s,{isInit:c})}function VM(){return{name:"UML",insertEmbedCommandItems:[{id:"insert-drawio",name:S.t("drawio.title"),icon:V5,group:"common",order:600}],handleInsertEmptyEmbed:async(n,t)=>{const e={src:"",xml:"",xmlSvg:""},o=n.insertEmbed(t.containerId,t.blockIndex,"drawio",e);return setTimeout(()=>{const r=rt(o),i=r.querySelector(":scope > .editor-drawio-content"),s=n.getBlockData(o);S6(n,r,i,s.embedData)},100),o}}}const Jc={embedType:"drawio",getOptions:VM,createEmbedContent:zM,getBlockProperties:$M},zF="",VF="",UM=500,qM=300,Lh=y("code-editor");function WM(n){const t=n.closest(".embed-code-editor-container");return d(Lh,t,"code-editor-container non-existent"),t}function GM(n,t,e){const o=n.target;d(Lh,o,"Parameter error: textarea must be an element");const r=o.value;WM(o).remove(),F(t,"editing"),e(r),rt(t).style.removeProperty("margin-top")}function ZM(n,t){d(Lh,n,"Parameter Error: handleCodeUpdate[event]");const e=n.target.value;t(e)}const YM=ie.default(ZM,UM);function QM(n,t,e,o,r){n.domEvents.addEventListener(t,"blur",(i,s)=>{GM(s,e,r)}),n.domEvents.addEventListener(t,"keyup",(i,s)=>{const l=s.target;s.key==="Escape"&&l.blur()}),n.domEvents.addEventListener(t,"input",(i,s)=>{YM(s,o)})}function KM(n,t,e){const{height:o,codeValue:r,onChange:i,onEnd:s}=e,l=o||qM,c=rt(t),a=At(t),u=b("div",["embed-code-editor-container"],a),f=b("textarea",["embed-code-editor-textarea"],u);f.value=r||"",f.setAttribute("spellcheck","false"),u.style.height=`${l}px`,QM(n,f,t,i,s),c.style.marginTop=`${l}px`,M(t,"editing"),window.requestAnimationFrame(()=>{f.setSelectionRange(0,0),f.focus(),f.scrollTop=0})}const JM={mermaid:"https://mermaid-js.github.io/mermaid/",flowchart:"https://flowchart.js.org/",plantuml:"https://plantuml.com/"};class XM extends dh{constructor(e,o,r){super(e,r);h(this,"group","hovering-toolbar");h(this,"_commands",[{id:"edit",name:"Edit",icon:sc},{id:"help",name:"Help",icon:A5}]);this.editor=e,this.graphType=o,this.properties=r}executeCommand(e,o,r){var i,s;(s=(i=this.properties)==null?void 0:i.handleExecuteCommand)!=null&&s.call(i,e,o,r)||r.id==="edit"||r.id==="help"&&window.open(JM[this.graphType])}}function tR(n,t,e){return{blockCommands:{"hovering-toolbar":new XM(n,t,e)}}}class Mh{constructor(t,e,o){h(this,"editor");h(this,"logger");this.graphType=e,this.codeEmbedDataKey=o,this.editor=t,this.logger=y(`embed-block-${this.graphType}`)}i18nt(t,e){return S.t(`graph.${t}`,e||{})}getContent(t){d(this.logger,t,"embed-element does not exist");const e=t.parentElement;return d(this.logger,e,"content-element does not exist"),e}getEmbed(t){const e=t.childNodes[0];return d(this.logger,e,"embed-element does not exist"),e}async uploadResource(t){const e=new Blob([t]),o=new File([e],`${this.graphType}.svg`,{type:"image/svg+xml"});try{const r=await this.editor.doc.uploadResource(o);d(this.logger,r,"uploadResource failed");const{resourceId:i}=r;return this.editor.doc.buildResourceUrl(i)}catch(r){return this.logger.error(r),null}}createEmbedContent(t,e){const o=b("div",["graph-embed"],t);this.editor.domEvents.addEventListener(o,"dblclick",(c,a)=>{this.editGraph(t),a.preventDefault(),a.stopPropagation()});const{embedData:r}=e,i=r[`${this.codeEmbedDataKey}`],s=r.src,l=b("div",["embed-graph-img-content"],o);b("img",["graph-embed-image"],l),this.updateImage(o,i,s,null)}updateEmbedContent(t,e){const{embedData:o}=e,r=o[this.codeEmbedDataKey],i=o.src,s=t.querySelector(".graph-embed");this.updateImage(s,r,i,null)}async updateImage(t,e,o,r){const i=t.querySelector("img.graph-embed-image");let s=this.editor.doc.buildResourceUrl(o||"");if(!s&&!r&&e)try{s=await this.code2ObjectUrl(e)}catch(l){this.updateImage(t,e,o,l);return}this.updateClasses(t,e,r),s&&(i.src=s)}updateClasses(t,e,o){F(t,"empty-embed","invalid-code");const r=t.querySelector("img.graph-embed-image");if(o){r.src="",M(t,"invalid-code");const i=this.i18nt("invalid",{EmbedName:this.graphType,message:`${o.message}`||""});t.setAttribute("data-invalid-text",i);return}if(!e){r.src="";const i=this.i18nt("empty",{EmbedName:this.graphType});t.setAttribute("data-empty-tips",i),M(t,"empty-embed")}}editGraph(t){const e=z(t);d(this.logger,e,`${this.graphType} block does not exist`);const o=t.querySelector(".graph-embed"),r=l=>{this.updateImage(o,l,null,null)},i=async l=>{try{if(r(l),!this.hasChanged(e,l))return;const a={src:await this.code2ResourceId(l),[`${this.codeEmbedDataKey}`]:l};this.editor.updateEmbedData(e,a)}catch(c){this.updateClasses(o,l,c);const a={src:"",[`${this.codeEmbedDataKey}`]:l};this.editor.updateEmbedData(e,a)}},s=this.editor.getBlockData(e);KM(this.editor,e,{onChange:r,onEnd:i,codeValue:s.embedData[`${this.codeEmbedDataKey}`]})}getBlockProperties(t){return tR(this.editor,this.graphType,{handleExecuteCommand:(e,o,r)=>{if(r.id==="edit"){const i=rt(o);return this.editGraph(i),!0}return!1}})}hasChanged(t,e){return this.editor.getBlockData(t).embedData[`${this.codeEmbedDataKey}`]!==e}}const eR="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js",nR=["//cdnjs.cloudflare.com/ajax/libs/raphael/2.3.0/raphael.min.js","//cdnjs.cloudflare.com/ajax/libs/flowchart/1.15.0/flowchart.min.js"],oR="https://www.plantuml.com/plantuml/svg",rR=y("mermaid-helper"),iR="wiz-editor-mermaid";async function T6(n,t){var v;const o=((v=(n.getComponentOptions("mermaid")||{}).cdn)==null?void 0:v.mermaid)||eR;await So(o,iR);const r=window.mermaid;d(rR,r,"Resource load failed: Mermaid javaScript resource injection failed");const i=N(),l=await new Promise((w,E)=>{try{r.mermaidAPI.render(i,t,L=>{setTimeout(()=>{w(L)})})}catch(L){L.message=L.str,E(L)}}),u=new DOMParser().parseFromString(l,"image/svg+xml").firstChild,f=u.style.maxWidth;return f&&u.setAttribute("width",f),new XMLSerializer().serializeToString(u)}async function sR(n,t){const e=await T6(n,t);return t1(e,"image/svg+xml",`${N()}.svg`)}async function lR(n,t){const e=await T6(n,t),o=new Blob([e]),r=new File([o],`${N()}.svg`,{type:"image/svg+xml"});return(await n.doc.uploadResource(r)).resourceId}class Xr extends Mh{constructor(t){super(t,"mermaid","mermaidText")}static get(t,e){return t.addCustom(`mermaid-${e.id}`,()=>new Xr(t))}code2ObjectUrl(t){return sR(this.editor,t)}code2ResourceId(t){return lR(this.editor,t)}destroy(){}}const cR={graph:{invalid:"\u65E0\u6548\u7684 {EmbedName} \u5185\u5BB9\uFF1A{message}",empty:"\u7A7A\u7684 {EmbedName}",flowchart:{},mermaid:{},plantuml:{}}},aR={invalid:"Invalid {EmbedName} content: {message}",empty:"Empty {EmbedName}",flowchart:{},mermaid:{},plantuml:{}};S.mergeLang({"zh-CN":cR,"en-US":aR});function dR(n,t,e){Xr.get(n,e).createEmbedContent(t,e)}function uR(n,t,e){const o=Xr.get(n,n.getBlockData(t)),r=rt(t);return o.updateEmbedContent(r,e),!0}function hR(n,t,e){const{data:o}=e,r=n.getBlockString(t).trim();if(!o||o.embedType!=="mermaid"||r!=="```mermaid"||!j(n,t))return null;const i={src:"",mermaidText:""};return{blockData:{id:N(),type:"embed",embedType:"mermaid",embedData:i},onConverted:(c,a)=>{Xr.get(c,c.getBlockData(a)).editGraph(rt(a))}}}function fR(n,t){return Xr.get(n,n.getBlockData(t)).getBlockProperties()}const Rh={embedType:"mermaid",convertFrom:hR,handleUpdateBlock:uR,createEmbedContent:dR,getBlockProperties:fR},D6=y("flowchart-helper");async function mR(n){var o;const t=n.getComponentOptions("flowchart")||{},e=((o=t==null?void 0:t.cdn)==null?void 0:o.flowchart)||nR;for(let r=0;r<e.length;r+=1){const i=e[r];await So(i,`flowchart-scripts-${r}`)}}async function L6(n,t){const e=b("div",["flowchart-chart-container"],document.body);e.id=`flowchart-${N()}`,await mR(n);const o=window.flowchart;d(D6,o,"flowchart resource does not exist"),o.parse(t).drawSVG(e.id);const i=e.firstElementChild;d(D6,i,"svg element non-existent");const l=new XMLSerializer().serializeToString(i);return e.remove(),l}async function gR(n,t){const e=await L6(n,t);return t1(e,"image/svg+xml",`${Date.now()}.svg`)}async function pR(n,t){const e=await L6(n,t),o=new Blob([e]),r=new File([o],`${N()}.svg`,{type:"image/svg+xml"});return(await n.doc.uploadResource(r)).resourceId}class ti extends Mh{constructor(t){super(t,"flowchart","flowchartText")}static get(t,e){return t.addCustom(`flowchart-${e.id}`,()=>new ti(t))}code2ObjectUrl(t){return gR(this.editor,t)}code2ResourceId(t){return pR(this.editor,t)}destroy(){}}function CR(n,t,e){ti.get(n,e).createEmbedContent(t,e)}function bR(n,t,e){const o=ti.get(n,e),r=rt(t);return o.updateEmbedContent(r,e),!0}function vR(n,t,e){const{data:o}=e,r=n.getBlockString(t).trim();if(!o||o.embedType!=="flowchart"||r!=="```flowchart"||!j(n,t))return null;const i={src:"",flowchartText:""};return{blockData:{id:N(),type:"embed",embedType:"flowchart",embedData:i},onConverted:(c,a)=>{ti.get(c,c.getBlockData(a)).editGraph(rt(a))}}}function kR(n,t){return ti.get(n,n.getBlockData(t)).getBlockProperties()}const Ah={embedType:"flowchart",convertFrom:vR,handleUpdateBlock:bR,createEmbedContent:CR,getBlockProperties:kR},yR=y("plantuml-helper");function M6(n,t){var l;let o=((l=(n.getComponentOptions("plantuml")||{}).cdn)==null?void 0:l.plantuml)||oR;o.endsWith("/")||(o+="/");const r=m8.default.encode(t);d(yR,r,r),o+=r;const s=new URLSearchParams(document.location.search).get("doc");return Xa(o,{id:`${s}-${N()}`})}async function wR(n,t){const e=await Sh(n,t);return(await n.doc.uploadResource(e)).resourceId}class ei extends Mh{constructor(t){super(t,"plantuml","plantumlText")}static get(t,e){return t.addCustom(`plantuml-${e.id}`,()=>new ei(t))}code2ObjectUrl(t){return Promise.resolve(M6(this.editor,t))}code2ResourceId(t){const e=M6(this.editor,t);return wR(this.editor,e)}destroy(){}}function BR(n,t,e){ei.get(n,e).createEmbedContent(t,e)}function ER(n,t,e){const o=ei.get(n,e),r=rt(t);return o.updateEmbedContent(r,e),!0}function IR(n,t,e){const{data:o}=e,r=n.getBlockString(t).trim();if(!o||o.embedType!=="plantuml"||r!=="```plantuml"||!j(n,t))return null;const i={src:"",plantumlText:""};return{blockData:{id:N(),type:"embed",embedType:"plantuml",embedData:i},onConverted:(c,a)=>{ei.get(c,c.getBlockData(a)).editGraph(rt(a))}}}function xR(n,t){return ei.get(n,n.getBlockData(t)).getBlockProperties()}const Oh={embedType:"plantuml",convertFrom:IR,handleUpdateBlock:ER,createEmbedContent:BR,getBlockProperties:xR},UF="",SR="hr",TR={dividingLine:{type:"\u5206\u5272\u7EBF"}},DR={dividingLine:{type:"dividing-line"}};S.mergeLang({"zh-CN":TR,"en-US":DR});function LR(n,t){const e=b("div",["editor-embed-container"],t);b("hr",["editor-embed-hr"],e)}function MR(n,t,e,o){return o==="html"?"<hr />":o==="markdown"?"---":"------------"}function RR(){return{name:"hr",insertEmbedCommandItems:[{id:"insert-hr",name:S.t("dividingLine.type"),icon:U5,order:500,group:"common"}],handleInsertEmptyEmbed:async(n,t)=>{const{containerId:e,blockIndex:o}=t;return n.insertEmbed(e,o,SR,{})}}}function AR(n,t,e){const{data:o}=e;if(!o||o.embedType!=="dividing-line"||!j(n,t))return null;const r={};return{blockData:{id:N(),type:"embed",embedType:"hr",embedData:r}}}const _h={embedType:"hr",createEmbedContent:LR,convertTo:MR,getOptions:RR,convertFrom:AR},qF="";class OR{constructor(t,e){h(this,"toolbar");h(this,"anchor",null);h(this,"item");h(this,"docs",null);h(this,"checkedId");h(this,"handlePasteSpecial",(t,e)=>{!e.data||(this.checkedId===e.id?this.checkedId=void 0:this.checkedId=e.id,this.onPasteSpecial(e.data),setTimeout(()=>{this.docs&&this.show(this.docs),this.editor.focus()}))});h(this,"handleClose",()=>{this.editor.focus()});h(this,"handleSelectionChange",()=>{this.hide()});this.editor=t,this.onPasteSpecial=e,this.item={id:"paste-special",name:"Paste special",icon:S5,dropdown:!0,manualShowChildren:!0,childrenPlacement:"bottom-start",childrenOffset:[-4,4],children:[]},this.toolbar=new os([this.item],void 0,{id:"paste-special-button",tooltipId:this.editor.clientId}),this.toolbar.addListener("click",this.handlePasteSpecial),this.toolbar.addListener("close",this.handleClose),this.editor.addListener("selectionChanged",this.handleSelectionChange)}show(t){this.docs=t;const e=this.editor,o=e.selection.range;if(!o.isCollapsed())return;const r=e.getBlockById(o.start.blockId);if(!j(e,r))return;const i=Ao(e,r,o)[0];if(!i)return;this.anchor&&this.anchor.remove(),this.anchor=_o(e,r,"paste-special-button-anchor",i);const s=this.getCommandItems(t);this.item.children=s,this.toolbar.manualShow(this.anchor)}hide(){this.toolbar.close()}clearCheckedState(){this.checkedId=void 0}destroy(){this.toolbar.destroy(),this.editor.removeListener("selectionChanged",this.handleSelectionChange)}getCommandItems(t){const e=i=>({id:i,states:this.checkedId===i?["checked"]:void 0,name:"Keep origin formats",data:t[i]}),o=[];let r=!0;return t["text/x-ones-editor-doc"]?o.push(e("text/x-ones-editor-doc")):t["text/office-html"]?o.push(e("text/office-html")):t["text/html"]?o.push(e("text/html")):t["text/plain"]&&(o.push(e("text/plain")),r=!1),t["text/plain"]&&(r&&o.push({id:"text/plain",states:this.checkedId==="text/plain"?["checked"]:void 0,name:"Paste as plain text",data:t["text/plain"]}),o.push({id:"text/markdown",states:this.checkedId==="text/markdown"?["checked"]:void 0,name:"Paste as markdown",data:t["text/markdown"]})),o}}const _R=y("paste-special");class Nh{constructor(t){h(this,"button");h(this,"lastUndoAction",null);h(this,"event",null);h(this,"handlePasteSpecial",t=>{this.editor.undoManager.runInGroup(()=>{this.editor.undoManager.undoTo(this.lastUndoAction),this.editor.pasteDoc(t)})});this.editor=t,this.button=new OR(t,this.handlePasteSpecial)}destroy(){this.event=null,this.button.destroy()}handleChanged(t,e){this.event=null,this.button.hide()}async handleBeforePaste(t,e){return _R.debug("before paste"),this.lastUndoAction=t.undoManager.lastAction(),!1}async handleAfterPaste(t,e,o){if(Object.keys(o).length<=1)return!1;const r=t.selection.range;if(r.isCollapsed()){const i=t.getBlockById(r.start.blockId);if(!j(t,i))return!1;this.button.clearCheckedState(),this.button.show(o),this.event=e}return!1}}const WF="",NR=y("html-to-doc");function PR(n){const t="ones-editor-doc::",e="::ones-editor-doc";let o=n.indexOf(t);if(o!==-1){o+=t.length;const r=n.indexOf(e,o);if(r!==-1){const i=n.substr(o,r-o);try{const s=el(i);return JSON.parse(s)}catch(s){NR.error(`invalid doc data: ${s}, ${i}`)}}}return null}function nr(n){const t=n.type;if(t==="link")return!!n.tokens.some(nr);switch(t){case"code":case"table":case"hr":case"blockquote":case"list":case"list_item":case"image":case"paragraph":return!0;default:return!1}}function $R(n){return!nr(n)}function HR(n){if(n.length===0)return[];if(n.length===1)return[n];const t=[];let e=[n[0]],o=nr(n[0]);for(let r=1;r<n.length;r++){const i=n[r];o===nr(i)?e.push(i):(t.push(e),e=[i],o=nr(i))}return t.push(e),t}function jR(n,t,e){const o=n.href;let r=e.tokensToText(n.tokens,t,e);return r=yl(r,"link",o),r}function FR(n,t){const e=n.text;return[_e(e,{...t,"style-code":!0})]}let Ls;function R6(n){Ls||(Ls=document.createElement("textarea")),Ls.innerHTML=n;const t=Ls.childNodes.length===0?"":Ls.childNodes[0].nodeValue;return t!=null?t:""}function zR(n,t,e){const r=n.tokens;return r?e.tokensToText(r,t,e):L1(R6(n.text),t)}const VR=y("token-to-text");function Ph(n,t,e){return n.map(r=>r.type==="text"?zR(r,t,e):r.type==="strong"?e.tokensToText(r.tokens,{...t,"style-bold":!0},e):r.type==="em"?e.tokensToText(r.tokens,{...t,"style-italic":!0},e):r.type==="link"?jR(r,t,e):r.type==="codespan"?FR(r,t):r.type==="br"?[{insert:" ",attributes:{box:!0,type:"br"}}]:r.type==="escape"?L1(R6(r.text),t):(VR.warn(`unknown token in text: ${JSON.stringify(r)}`),[])).flat()}function UR(n,t){const e=Ph(n.tokens,{},t);return[{id:N(),type:"text",text:e,heading:n.depth}]}function qR(n,t){const{text:e,children:o}=t.tokensToTextWithChildren(n.tokens,t),r=[];return e.length>0&&r.push({id:N(),type:"text",text:e}),r.push(...o),r}function WR(n,t){const e=typeof n.start=="number"?n.start:1,o=n.ordered,r=N(),i=[];return n.items.forEach((l,c)=>{const a={...t,listLevel:t.listLevel+1},{text:u,children:f}=t.tokensToTextWithChildren(l.tokens,a),m={id:N(),type:"list",groupId:r,ordered:o,start:e+c,text:u,level:t.listLevel};i.push(m),i.push(...f)}),i}function GR(n,t){const e=t.tokensToBlocks(n.tokens,t);return e.forEach(o=>{o.quoted=!0}),e}const A6=100,ZR=20,YR=600;function QR(n,t){const e=t.text;if(e){const o=Tt(e);return Math.min(rl(o,n)+ZR,YR)}return A6}function O6(n,t){let e=A6;return t.forEach(o=>{e=Math.max(e,QR(n,o))}),e}function KR(n,t){var l,c;const e=n.header.length,o=n.rows.length+1,r=[],i=Array(e).fill(100);for(let a=0;a<o;a++){let u;a===0?u=n.header:u=n.rows[a-1];for(let f=0;f<e;f++){const m=u[f],C=(l=m==null?void 0:m.tokens)!=null?l:[],v=N();r.push(v);let w;if(C.length===0)w=[Il()];else if(nr(C[0]))w=t.tokensToBlocks(m.tokens,t),w.length===0&&w.push(Il());else{const{text:E,children:L}=t.tokensToTextWithChildren(m.tokens,t);w=[{id:N(),type:"text",text:E},...L]}t.doc.blocks[v]=w,i[f]=Math.max(i[f],O6((c=t.font)!=null?c:"",w))}}return[{id:N(),type:"table",cols:e,rows:o,colsWidth:i,children:r}]}function JR(n){return[{id:N(),type:"embed",embedType:"hr",embedData:{}}]}function XR(n,t){var c;const e=n.text;if(!e)return[];try{const a=n.text,u=el(a),f=JSON.parse(u);if(f){const{root:m,...C}=f.blocks;return t.doc.blocks={...t.doc.blocks,...C},m}}catch{}const o=(c=n.lang)!=null?c:"Plain Text";if(o==="mermaid")return[{id:N(),type:"embed",embedType:"mermaid",embedData:{mermaidText:e}}];if(o==="plantuml")return[{id:N(),type:"embed",embedType:"plantuml",embedData:{plantumlText:e}}];if(o==="flow"||o==="flowchart")return[{id:N(),type:"embed",embedType:"flowchart",embedData:{flowchartText:e}}];const i=e.split(`
589
- `).map(a=>({id:N(),type:"text",text:Oi(a)})),s=t.doc,l=N();return s.blocks[l]=i,[{id:N(),type:"code",language:o,children:[l]}]}function tA(n){return[{id:N(),type:"embed",embedType:"image",embedData:{src:n.href,title:n.title}}]}function eA(n,t){const{text:e,children:o}=t.tokensToTextWithChildren(n.tokens,t),r=[];return e.length>0&&r.push({id:N(),type:"text",text:e}),r.push(...o),r}const nA=y("markdown-to-doc");function oA(n,t){return n.type==="heading"?UR(n,t):n.type==="paragraph"?qR(n,t):n.type==="list"?WR(n,t):n.type==="blockquote"?GR(n,t):n.type==="table"?KR(n,t):n.type==="hr"?JR():n.type==="code"?XR(n,t):n.type==="image"?tA(n):n.type==="link"?eA(n,t):(nA.log(`unknown block token, ${JSON.stringify(n)}`),[])}function $h(n,t){const e=[];return n.forEach(o=>{const r=oA(o,t);e.push(...r)}),e}const rA=y("markdown-to-doc");function iA(n,t){const e={text:[],children:[]};return HR(n).forEach((r,i)=>{const s=r[0];if(i===0&&$R(s)){e.text=Ph(r,{},t);return}d(rA,nr(s),`not a block token: ${JSON.stringify(s)}`),e.children.push(...$h(r,t))}),e}function _6(n,t){const o=new o8.marked.Lexer().lex(n),r={blocks:{root:[]},meta:{},comments:{}},i={font:t==null?void 0:t.font,doc:r,tokensToText:Ph,tokensToBlocks:$h,tokensToTextWithChildren:iA,htmlToDoc:t==null?void 0:t.htmlToDoc,listLevel:1},s=$h(o,i);return s.length===0?null:(r.blocks.root.push(...s),r)}function sA(n){if(n.nodeName!=="DIV")return!1;const t=n;return Array.from(t.childNodes).every(e=>e.nodeName==="SPAN"||e instanceof Text)?!!t.querySelector(":scope > .hljs-function, :scope > .hljs-params, :scope > .hljs-string, :scope > .hljs-keyword, :scope > .hljs-attr"):!1}function N6(n){if(sA(n)){const t=n,e=t.parentNode,o=document.createElement("pre");Array.from(t.childNodes).forEach(r=>o.appendChild(r)),e==null||e.insertBefore(o,t);return}n.childNodes.forEach(t=>N6(t))}function Xc(n){var t;if(n instanceof HTMLBRElement){const e=document.createTextNode(`
588
+ `,w6=0,SM=30*1e3,B6="editor-empty-drawio",E6="show-full-screen-iframe",zt=y("embed-block-drawio");function Jr(n){return n.options.componentsOptions.drawIO||{}}function TM(n){const e=Jr(n).lang||"zh-CN";return y6[e]||y6["zh-CN"]}function DM(n){var r;const e=((r=(Jr(n)||{}).cdn)==null?void 0:r.drawioIframe)||BM,o=TM(n);return Xa(e,{spin:1,proto:"json",configure:1,lang:o})}function LM(n){const t=()=>{d(zt,n,"el does not exist");const o=document.body.clientWidth||document.documentElement.clientWidth,r=document.body.clientHeight||document.documentElement.clientHeight;n.setAttribute("width",`${o-2*w6}`),n.setAttribute("height",`${r-2*w6}`)},e=()=>{window.removeEventListener("resize",t)};return t(),window.addEventListener("resize",t),{disconnect:e}}async function MM(n){const e=(Jr(n)||{}).callbacks||{},{onCreateDrawIoFrame:o,onCloseDrawIoFrame:r}=e;let i=null,s;if(o)i=await o(n),d(zt,i,"iframe create failed"),s=()=>{d(zt,i,"iframe does not exist"),d(zt,r,"missing parameters: onCloseDrawIoFrame"),r(n,i)};else{const l=b("div",["editor-drawio-iframe-container","loading"],document.body);l.setAttribute("data-placeholder",S.t("drawio.loading")),i=b("iframe",["drawio-iframe-element"],l),i.setAttribute("frameborder","0"),M(l,E6);const{disconnect:c}=LM(i);s=()=>{d(zt,i,"iframe does not exist"),c(),document.body.removeChild(l),F(l,E6)}}return{drawioIframe:i,exit:s}}async function RM(n,t,e,o){var r,i;try{o&&zt.debug("auto saving drawio data");const s=new Blob([e]),l=new File([s],"drawio.svg",{type:"image/svg+xml"});try{const c=t.parentElement;d(zt,c,"targetBlock");const a=await n.doc.uploadResource(l),{resourceId:u}=a,m={...n.getBlockData(c),embedData:{src:u}};n.updateBlockData(c,m)}catch(c){const a=`failed to upload drawio data: ${c.message}`;zt.error(a)}}catch(s){const l=`failed to save drawio data: ${s.message}`,c=Jr(n);if((r=c.callbacks)!=null&&r.onError){const a=new Error(l);a.code="SaveDrawIo",(i=c.callbacks)==null||i.onError(n,a)}}}function AM(n,t,e,o,r,i,s){const l=()=>{window.removeEventListener("message",c),i()},c=async a=>{var u,f;if(d(zt,o.contentWindow,"iframe.contentWindow does not exist"),a.data.length>0){const m=JSON.parse(a.data),C=e.xmlSvg||e.xml,v=document.querySelectorAll(".editor-drawio-iframe-container");switch(m.event){case"configure":o.contentWindow.postMessage(JSON.stringify({action:"configure",config:{defaultFonts:["Humor Sans","Helvetica","Times New Roman"]}}),"*");break;case"init":C!=null&&o.contentWindow.postMessage(JSON.stringify({action:"load",saveAndExit:1,noSaveBtn:1,noExitBtn:0,xml:C}),"*"),r(),v.forEach(E=>{F(E,"loading")});break;case"export":const w=el(m.data.substring(m.data.indexOf(",")+1));RM(n,t,w,!!((u=m.message)!=null&&u.autoSave)),(f=m.message)!=null&&f.autoSave||l();break;case"save":o.contentWindow.postMessage(JSON.stringify({action:"export",format:"xmlsvg",spin:"Saving graph"}),"*");break;case"exit":l();break}}};window.addEventListener("message",c)}async function I6(n,t,e,o){if(o)return;o=!0;const r=Jr(n)||{},{callbacks:i}=r;let s;i&&(i==null?void 0:i.onBeginInitDrawIo)&&i.onBeginInitDrawIo(n,t);const{drawioIframe:l,exit:c}=await MM(n);if(e.src){const m=await k6(n,n.doc.buildResourceUrl(e.src));m&&(e.xmlSvg=m)}AM(n,t,e,l,()=>{s=setInterval(()=>{!l||!l.contentWindow||l.contentWindow.postMessage(JSON.stringify({action:"export",format:"xmlsvg",spin:"Saving graph",autoSave:!0}),"*")},SM)},()=>{c(),s&&clearInterval(s)});const f=DM(n);l.setAttribute("src",f)}async function OM(n){var r,i;const t=Jr(n),e=((r=t.cdn)==null?void 0:r.drawio)||EM,o=((i=t.cdn)==null?void 0:i.pako)||IM;await So(o,"editor-pako"),await So(e,"editor-drawio"),await new Promise(s=>{setTimeout(s,100)})}function x6(n){F(n,B6)}function Th(n){n.setAttribute("data-empty-drawio-content",S.t("drawio.empty")),M(n,B6)}function Dh(n,t){if(d(zt,t,"Required data is missing in setGraph"),"src"in t){n.setAttribute("data-src",t.src);return}if("xmlSvg"in t){n.setAttribute("data-xmlsvg",t.xmlSvg);return}if("graph"in t){const{xml:e,graph:o}=t;n.graph=o,n.setAttribute("data-mxfile",e)}}function _M(n,t,e){d(zt,n,"params error: src"),d(zt,e,"params error: editor");const o=t,r=e.doc.buildResourceUrl(n),i=document.createElement("img");o.innerHTML="",o.appendChild(i),i.src=r,Dh(o,{src:n}),i.onload=()=>{kM(i)?Th(t):x6(t)}}function NM(n,t,e){d(zt,e,"parameter missing"),OM(e).then(()=>{const{mxUtils:o,mxGraph:r,mxCodec:i}=window;d(zt,o,"External resource loading exception: mxUtils"),d(zt,r,"External resource loading exception: MxGraph"),d(zt,i,"External resource loading exception: MxCodec");const s=o.parseXml(n);t.innerHTML="";const l=s.documentElement;d(zt,l,"Resource parsing exception"),d(zt,l.nodeName==="mxfile","Resource parsing exception");const c=l.getElementsByTagName("diagram");d(zt,c.length>0,"Resource parsing exception");let a;const u=c[0];if(u.text||u.textContent){const w=wM(u),E=atob(w),L=window.pako;d(zt,L,"External resource loading exception: pako");const x=L.inflateRaw(Uint8Array.from(E,O=>O.charCodeAt(0)),{to:"string"}),A=decodeURIComponent(x);a=o.parseXml(A)}else{const w=new XMLSerializer().serializeToString(u.firstChild);a=o.parseXml(w)}const f=new r(t);f.resetViewOnRootChange=!1,f.foldingEnabled=!1,f.setTooltips(!1),f.setEnabled(!1),f.setHtmlLabels(!0);const m=o.parseXml(xM);new i(m).decode(m.documentElement,f.getStylesheet());const v=new i(a);v.decode(v.document.documentElement,f.getModel()),f.maxFitScale=1,f.fit(),f.center(!0,!1),Dh(t,{graph:f,xml:n})})}function PM(n,t){t.innerHTML=n,Dh(t,{xmlSvg:n});const e=t.querySelectorAll("svg");for(let o=0;o<e.length;o++){const r=e[o];if(!yM(r))return}Th(t)}function $M(n,t){return uh(n,t,{handleExecuteCommand:(o,r,i)=>{if(i.id==="edit"){const s=o.getBlockData(r).embedData;return I6(o,rt(r),s,!1),!0}return!1}})}const Ds=y("embed-block-drawio"),HM=!1;pM();function S6(n,t,e,o){d(Ds,e,`parameter missing: ${e}`),d(Ds,n,`parameter missing: ${n}`),I6(n,t,o,HM)}function jM(n,t,e){x6(t);const o=e;o.src?_M(o.src,t,n):o.xml?NM(o.xml,t,n):o.xmlSvg?PM(o.xmlSvg,t):Th(t)}function FM(n,t,e,o={isInit:!1}){const{isInit:r}=o,s=b("div",["editor-drawio-content","editor-embed"],null);t.appendChild(s),jM(n,s,e);const l=t.parentElement;d(Ds,l,"embedContainer parentElement node does not exist"),r&&!n.readonly&&n.domEvents.addEventListener(t,"dblclick",()=>{const c=n.getBlockData(l);S6(n,t,s,c.embedData)})}function zM(n,t,e,o,r,i){var a,u;console.log((u=(a=n.doc).getServerMeta)==null?void 0:u.call(a).serverId);debugger;const s=e.embedData,l=n.addCustom(`drawio-${e.id}`,()=>new CM),c=l.isFirstInit();c?Ds.log("create new embed block"):Ds.log("update exists embed block"),l.stamp(),FM(n,t,s,{isInit:c})}function UM(){return{name:"UML",insertEmbedCommandItems:[{id:"insert-drawio",name:S.t("drawio.title"),icon:U5,group:"common",order:600}],handleInsertEmptyEmbed:async(n,t)=>{const e={src:"",xml:"",xmlSvg:""},o=n.insertEmbed(t.containerId,t.blockIndex,"drawio",e);return setTimeout(()=>{const r=rt(o),i=r.querySelector(":scope > .editor-drawio-content"),s=n.getBlockData(o);S6(n,r,i,s.embedData)},100),o}}}const Jc={embedType:"drawio",getOptions:UM,createEmbedContent:zM,getBlockProperties:$M},zF="",UF="",VM=500,qM=300,Lh=y("code-editor");function WM(n){const t=n.closest(".embed-code-editor-container");return d(Lh,t,"code-editor-container non-existent"),t}function GM(n,t,e){const o=n.target;d(Lh,o,"Parameter error: textarea must be an element");const r=o.value;WM(o).remove(),F(t,"editing"),e(r),rt(t).style.removeProperty("margin-top")}function ZM(n,t){d(Lh,n,"Parameter Error: handleCodeUpdate[event]");const e=n.target.value;t(e)}const YM=ie.default(ZM,VM);function QM(n,t,e,o,r){n.domEvents.addEventListener(t,"blur",(i,s)=>{GM(s,e,r)}),n.domEvents.addEventListener(t,"keyup",(i,s)=>{const l=s.target;s.key==="Escape"&&l.blur()}),n.domEvents.addEventListener(t,"input",(i,s)=>{YM(s,o)})}function KM(n,t,e){const{height:o,codeValue:r,onChange:i,onEnd:s}=e,l=o||qM,c=rt(t),a=At(t),u=b("div",["embed-code-editor-container"],a),f=b("textarea",["embed-code-editor-textarea"],u);f.value=r||"",f.setAttribute("spellcheck","false"),u.style.height=`${l}px`,QM(n,f,t,i,s),c.style.marginTop=`${l}px`,M(t,"editing"),window.requestAnimationFrame(()=>{f.setSelectionRange(0,0),f.focus(),f.scrollTop=0})}const JM={mermaid:"https://mermaid-js.github.io/mermaid/",flowchart:"https://flowchart.js.org/",plantuml:"https://plantuml.com/"};class XM extends dh{constructor(e,o,r){super(e,r);h(this,"group","hovering-toolbar");h(this,"_commands",[{id:"edit",name:"Edit",icon:sc},{id:"help",name:"Help",icon:A5}]);this.editor=e,this.graphType=o,this.properties=r}executeCommand(e,o,r){var i,s;(s=(i=this.properties)==null?void 0:i.handleExecuteCommand)!=null&&s.call(i,e,o,r)||r.id==="edit"||r.id==="help"&&window.open(JM[this.graphType])}}function tR(n,t,e){return{blockCommands:{"hovering-toolbar":new XM(n,t,e)}}}class Mh{constructor(t,e,o){h(this,"editor");h(this,"logger");this.graphType=e,this.codeEmbedDataKey=o,this.editor=t,this.logger=y(`embed-block-${this.graphType}`)}i18nt(t,e){return S.t(`graph.${t}`,e||{})}getContent(t){d(this.logger,t,"embed-element does not exist");const e=t.parentElement;return d(this.logger,e,"content-element does not exist"),e}getEmbed(t){const e=t.childNodes[0];return d(this.logger,e,"embed-element does not exist"),e}async uploadResource(t){const e=new Blob([t]),o=new File([e],`${this.graphType}.svg`,{type:"image/svg+xml"});try{const r=await this.editor.doc.uploadResource(o);d(this.logger,r,"uploadResource failed");const{resourceId:i}=r;return this.editor.doc.buildResourceUrl(i)}catch(r){return this.logger.error(r),null}}createEmbedContent(t,e){const o=b("div",["graph-embed"],t);this.editor.domEvents.addEventListener(o,"dblclick",(c,a)=>{this.editGraph(t),a.preventDefault(),a.stopPropagation()});const{embedData:r}=e,i=r[`${this.codeEmbedDataKey}`],s=r.src,l=b("div",["embed-graph-img-content"],o);b("img",["graph-embed-image"],l),this.updateImage(o,i,s,null)}updateEmbedContent(t,e){const{embedData:o}=e,r=o[this.codeEmbedDataKey],i=o.src,s=t.querySelector(".graph-embed");this.updateImage(s,r,i,null)}async updateImage(t,e,o,r){const i=t.querySelector("img.graph-embed-image");let s=this.editor.doc.buildResourceUrl(o||"");if(!s&&!r&&e)try{s=await this.code2ObjectUrl(e)}catch(l){this.updateImage(t,e,o,l);return}this.updateClasses(t,e,r),s&&(i.src=s)}updateClasses(t,e,o){F(t,"empty-embed","invalid-code");const r=t.querySelector("img.graph-embed-image");if(o){r.src="",M(t,"invalid-code");const i=this.i18nt("invalid",{EmbedName:this.graphType,message:`${o.message}`||""});t.setAttribute("data-invalid-text",i);return}if(!e){r.src="";const i=this.i18nt("empty",{EmbedName:this.graphType});t.setAttribute("data-empty-tips",i),M(t,"empty-embed")}}editGraph(t){const e=z(t);d(this.logger,e,`${this.graphType} block does not exist`);const o=t.querySelector(".graph-embed"),r=l=>{this.updateImage(o,l,null,null)},i=async l=>{try{if(r(l),!this.hasChanged(e,l))return;const a={src:await this.code2ResourceId(l),[`${this.codeEmbedDataKey}`]:l};this.editor.updateEmbedData(e,a)}catch(c){this.updateClasses(o,l,c);const a={src:"",[`${this.codeEmbedDataKey}`]:l};this.editor.updateEmbedData(e,a)}},s=this.editor.getBlockData(e);KM(this.editor,e,{onChange:r,onEnd:i,codeValue:s.embedData[`${this.codeEmbedDataKey}`]})}getBlockProperties(t){return tR(this.editor,this.graphType,{handleExecuteCommand:(e,o,r)=>{if(r.id==="edit"){const i=rt(o);return this.editGraph(i),!0}return!1}})}hasChanged(t,e){return this.editor.getBlockData(t).embedData[`${this.codeEmbedDataKey}`]!==e}}const eR="https://cdn.jsdelivr.net/npm/mermaid/dist/mermaid.min.js",nR=["//cdnjs.cloudflare.com/ajax/libs/raphael/2.3.0/raphael.min.js","//cdnjs.cloudflare.com/ajax/libs/flowchart/1.15.0/flowchart.min.js"],oR="https://www.plantuml.com/plantuml/svg",rR=y("mermaid-helper"),iR="wiz-editor-mermaid";async function T6(n,t){var v;const o=((v=(n.getComponentOptions("mermaid")||{}).cdn)==null?void 0:v.mermaid)||eR;await So(o,iR);const r=window.mermaid;d(rR,r,"Resource load failed: Mermaid javaScript resource injection failed");const i=N(),l=await new Promise((w,E)=>{try{r.mermaidAPI.render(i,t,L=>{setTimeout(()=>{w(L)})})}catch(L){L.message=L.str,E(L)}}),u=new DOMParser().parseFromString(l,"image/svg+xml").firstChild,f=u.style.maxWidth;return f&&u.setAttribute("width",f),new XMLSerializer().serializeToString(u)}async function sR(n,t){const e=await T6(n,t);return t1(e,"image/svg+xml",`${N()}.svg`)}async function lR(n,t){const e=await T6(n,t),o=new Blob([e]),r=new File([o],`${N()}.svg`,{type:"image/svg+xml"});return(await n.doc.uploadResource(r)).resourceId}class Xr extends Mh{constructor(t){super(t,"mermaid","mermaidText")}static get(t,e){return t.addCustom(`mermaid-${e.id}`,()=>new Xr(t))}code2ObjectUrl(t){return sR(this.editor,t)}code2ResourceId(t){return lR(this.editor,t)}destroy(){}}const cR={graph:{invalid:"\u65E0\u6548\u7684 {EmbedName} \u5185\u5BB9\uFF1A{message}",empty:"\u7A7A\u7684 {EmbedName}",flowchart:{},mermaid:{},plantuml:{}}},aR={invalid:"Invalid {EmbedName} content: {message}",empty:"Empty {EmbedName}",flowchart:{},mermaid:{},plantuml:{}};S.mergeLang({"zh-CN":cR,"en-US":aR});function dR(n,t,e){Xr.get(n,e).createEmbedContent(t,e)}function uR(n,t,e){const o=Xr.get(n,n.getBlockData(t)),r=rt(t);return o.updateEmbedContent(r,e),!0}function hR(n,t,e){const{data:o}=e,r=n.getBlockString(t).trim();if(!o||o.embedType!=="mermaid"||r!=="```mermaid"||!j(n,t))return null;const i={src:"",mermaidText:""};return{blockData:{id:N(),type:"embed",embedType:"mermaid",embedData:i},onConverted:(c,a)=>{Xr.get(c,c.getBlockData(a)).editGraph(rt(a))}}}function fR(n,t){return Xr.get(n,n.getBlockData(t)).getBlockProperties()}const Rh={embedType:"mermaid",convertFrom:hR,handleUpdateBlock:uR,createEmbedContent:dR,getBlockProperties:fR},D6=y("flowchart-helper");async function mR(n){var o;const t=n.getComponentOptions("flowchart")||{},e=((o=t==null?void 0:t.cdn)==null?void 0:o.flowchart)||nR;for(let r=0;r<e.length;r+=1){const i=e[r];await So(i,`flowchart-scripts-${r}`)}}async function L6(n,t){const e=b("div",["flowchart-chart-container"],document.body);e.id=`flowchart-${N()}`,await mR(n);const o=window.flowchart;d(D6,o,"flowchart resource does not exist"),o.parse(t).drawSVG(e.id);const i=e.firstElementChild;d(D6,i,"svg element non-existent");const l=new XMLSerializer().serializeToString(i);return e.remove(),l}async function gR(n,t){const e=await L6(n,t);return t1(e,"image/svg+xml",`${Date.now()}.svg`)}async function pR(n,t){const e=await L6(n,t),o=new Blob([e]),r=new File([o],`${N()}.svg`,{type:"image/svg+xml"});return(await n.doc.uploadResource(r)).resourceId}class ti extends Mh{constructor(t){super(t,"flowchart","flowchartText")}static get(t,e){return t.addCustom(`flowchart-${e.id}`,()=>new ti(t))}code2ObjectUrl(t){return gR(this.editor,t)}code2ResourceId(t){return pR(this.editor,t)}destroy(){}}function CR(n,t,e){ti.get(n,e).createEmbedContent(t,e)}function bR(n,t,e){const o=ti.get(n,e),r=rt(t);return o.updateEmbedContent(r,e),!0}function vR(n,t,e){const{data:o}=e,r=n.getBlockString(t).trim();if(!o||o.embedType!=="flowchart"||r!=="```flowchart"||!j(n,t))return null;const i={src:"",flowchartText:""};return{blockData:{id:N(),type:"embed",embedType:"flowchart",embedData:i},onConverted:(c,a)=>{ti.get(c,c.getBlockData(a)).editGraph(rt(a))}}}function kR(n,t){return ti.get(n,n.getBlockData(t)).getBlockProperties()}const Ah={embedType:"flowchart",convertFrom:vR,handleUpdateBlock:bR,createEmbedContent:CR,getBlockProperties:kR},yR=y("plantuml-helper");function M6(n,t){var l;let o=((l=(n.getComponentOptions("plantuml")||{}).cdn)==null?void 0:l.plantuml)||oR;o.endsWith("/")||(o+="/");const r=m8.default.encode(t);d(yR,r,r),o+=r;const s=new URLSearchParams(document.location.search).get("doc");return Xa(o,{id:`${s}-${N()}`})}async function wR(n,t){const e=await Sh(n,t);return(await n.doc.uploadResource(e)).resourceId}class ei extends Mh{constructor(t){super(t,"plantuml","plantumlText")}static get(t,e){return t.addCustom(`plantuml-${e.id}`,()=>new ei(t))}code2ObjectUrl(t){return Promise.resolve(M6(this.editor,t))}code2ResourceId(t){const e=M6(this.editor,t);return wR(this.editor,e)}destroy(){}}function BR(n,t,e){ei.get(n,e).createEmbedContent(t,e)}function ER(n,t,e){const o=ei.get(n,e),r=rt(t);return o.updateEmbedContent(r,e),!0}function IR(n,t,e){const{data:o}=e,r=n.getBlockString(t).trim();if(!o||o.embedType!=="plantuml"||r!=="```plantuml"||!j(n,t))return null;const i={src:"",plantumlText:""};return{blockData:{id:N(),type:"embed",embedType:"plantuml",embedData:i},onConverted:(c,a)=>{ei.get(c,c.getBlockData(a)).editGraph(rt(a))}}}function xR(n,t){return ei.get(n,n.getBlockData(t)).getBlockProperties()}const Oh={embedType:"plantuml",convertFrom:IR,handleUpdateBlock:ER,createEmbedContent:BR,getBlockProperties:xR},VF="",SR="hr",TR={dividingLine:{type:"\u5206\u5272\u7EBF"}},DR={dividingLine:{type:"dividing-line"}};S.mergeLang({"zh-CN":TR,"en-US":DR});function LR(n,t){const e=b("div",["editor-embed-container"],t);b("hr",["editor-embed-hr"],e)}function MR(n,t,e,o){return o==="html"?"<hr />":o==="markdown"?"---":"------------"}function RR(){return{name:"hr",insertEmbedCommandItems:[{id:"insert-hr",name:S.t("dividingLine.type"),icon:V5,order:500,group:"common"}],handleInsertEmptyEmbed:async(n,t)=>{const{containerId:e,blockIndex:o}=t;return n.insertEmbed(e,o,SR,{})}}}function AR(n,t,e){const{data:o}=e;if(!o||o.embedType!=="dividing-line"||!j(n,t))return null;const r={};return{blockData:{id:N(),type:"embed",embedType:"hr",embedData:r}}}const _h={embedType:"hr",createEmbedContent:LR,convertTo:MR,getOptions:RR,convertFrom:AR},qF="";class OR{constructor(t,e){h(this,"toolbar");h(this,"anchor",null);h(this,"item");h(this,"docs",null);h(this,"checkedId");h(this,"handlePasteSpecial",(t,e)=>{!e.data||(this.checkedId===e.id?this.checkedId=void 0:this.checkedId=e.id,this.onPasteSpecial(e.data),setTimeout(()=>{this.docs&&this.show(this.docs),this.editor.focus()}))});h(this,"handleClose",()=>{this.editor.focus()});h(this,"handleSelectionChange",()=>{this.hide()});this.editor=t,this.onPasteSpecial=e,this.item={id:"paste-special",name:"Paste special",icon:S5,dropdown:!0,manualShowChildren:!0,childrenPlacement:"bottom-start",childrenOffset:[-4,4],children:[]},this.toolbar=new os([this.item],void 0,{id:"paste-special-button",tooltipId:this.editor.clientId}),this.toolbar.addListener("click",this.handlePasteSpecial),this.toolbar.addListener("close",this.handleClose),this.editor.addListener("selectionChanged",this.handleSelectionChange)}show(t){this.docs=t;const e=this.editor,o=e.selection.range;if(!o.isCollapsed())return;const r=e.getBlockById(o.start.blockId);if(!j(e,r))return;const i=Ao(e,r,o)[0];if(!i)return;this.anchor&&this.anchor.remove(),this.anchor=_o(e,r,"paste-special-button-anchor",i);const s=this.getCommandItems(t);this.item.children=s,this.toolbar.manualShow(this.anchor)}hide(){this.toolbar.close()}clearCheckedState(){this.checkedId=void 0}destroy(){this.toolbar.destroy(),this.editor.removeListener("selectionChanged",this.handleSelectionChange)}getCommandItems(t){const e=i=>({id:i,states:this.checkedId===i?["checked"]:void 0,name:"Keep origin formats",data:t[i]}),o=[];let r=!0;return t["text/x-ones-editor-doc"]?o.push(e("text/x-ones-editor-doc")):t["text/office-html"]?o.push(e("text/office-html")):t["text/html"]?o.push(e("text/html")):t["text/plain"]&&(o.push(e("text/plain")),r=!1),t["text/plain"]&&(r&&o.push({id:"text/plain",states:this.checkedId==="text/plain"?["checked"]:void 0,name:"Paste as plain text",data:t["text/plain"]}),o.push({id:"text/markdown",states:this.checkedId==="text/markdown"?["checked"]:void 0,name:"Paste as markdown",data:t["text/markdown"]})),o}}const _R=y("paste-special");class Nh{constructor(t){h(this,"button");h(this,"lastUndoAction",null);h(this,"event",null);h(this,"handlePasteSpecial",t=>{this.editor.undoManager.runInGroup(()=>{this.editor.undoManager.undoTo(this.lastUndoAction),this.editor.pasteDoc(t)})});this.editor=t,this.button=new OR(t,this.handlePasteSpecial)}destroy(){this.event=null,this.button.destroy()}handleChanged(t,e){this.event=null,this.button.hide()}async handleBeforePaste(t,e){return _R.debug("before paste"),this.lastUndoAction=t.undoManager.lastAction(),!1}async handleAfterPaste(t,e,o){if(Object.keys(o).length<=1)return!1;const r=t.selection.range;if(r.isCollapsed()){const i=t.getBlockById(r.start.blockId);if(!j(t,i))return!1;this.button.clearCheckedState(),this.button.show(o),this.event=e}return!1}}const WF="",NR=y("html-to-doc");function PR(n){const t="ones-editor-doc::",e="::ones-editor-doc";let o=n.indexOf(t);if(o!==-1){o+=t.length;const r=n.indexOf(e,o);if(r!==-1){const i=n.substr(o,r-o);try{const s=el(i);return JSON.parse(s)}catch(s){NR.error(`invalid doc data: ${s}, ${i}`)}}}return null}function nr(n){const t=n.type;if(t==="link")return!!n.tokens.some(nr);switch(t){case"code":case"table":case"hr":case"blockquote":case"list":case"list_item":case"image":case"paragraph":return!0;default:return!1}}function $R(n){return!nr(n)}function HR(n){if(n.length===0)return[];if(n.length===1)return[n];const t=[];let e=[n[0]],o=nr(n[0]);for(let r=1;r<n.length;r++){const i=n[r];o===nr(i)?e.push(i):(t.push(e),e=[i],o=nr(i))}return t.push(e),t}function jR(n,t,e){const o=n.href;let r=e.tokensToText(n.tokens,t,e);return r=yl(r,"link",o),r}function FR(n,t){const e=n.text;return[_e(e,{...t,"style-code":!0})]}let Ls;function R6(n){Ls||(Ls=document.createElement("textarea")),Ls.innerHTML=n;const t=Ls.childNodes.length===0?"":Ls.childNodes[0].nodeValue;return t!=null?t:""}function zR(n,t,e){const r=n.tokens;return r?e.tokensToText(r,t,e):L1(R6(n.text),t)}const UR=y("token-to-text");function Ph(n,t,e){return n.map(r=>r.type==="text"?zR(r,t,e):r.type==="strong"?e.tokensToText(r.tokens,{...t,"style-bold":!0},e):r.type==="em"?e.tokensToText(r.tokens,{...t,"style-italic":!0},e):r.type==="link"?jR(r,t,e):r.type==="codespan"?FR(r,t):r.type==="br"?[{insert:" ",attributes:{box:!0,type:"br"}}]:r.type==="escape"?L1(R6(r.text),t):(UR.warn(`unknown token in text: ${JSON.stringify(r)}`),[])).flat()}function VR(n,t){const e=Ph(n.tokens,{},t);return[{id:N(),type:"text",text:e,heading:n.depth}]}function qR(n,t){const{text:e,children:o}=t.tokensToTextWithChildren(n.tokens,t),r=[];return e.length>0&&r.push({id:N(),type:"text",text:e}),r.push(...o),r}function WR(n,t){const e=typeof n.start=="number"?n.start:1,o=n.ordered,r=N(),i=[];return n.items.forEach((l,c)=>{const a={...t,listLevel:t.listLevel+1},{text:u,children:f}=t.tokensToTextWithChildren(l.tokens,a),m={id:N(),type:"list",groupId:r,ordered:o,start:e+c,text:u,level:t.listLevel};i.push(m),i.push(...f)}),i}function GR(n,t){const e=t.tokensToBlocks(n.tokens,t);return e.forEach(o=>{o.quoted=!0}),e}const A6=100,ZR=20,YR=600;function QR(n,t){const e=t.text;if(e){const o=Tt(e);return Math.min(rl(o,n)+ZR,YR)}return A6}function O6(n,t){let e=A6;return t.forEach(o=>{e=Math.max(e,QR(n,o))}),e}function KR(n,t){var l,c;const e=n.header.length,o=n.rows.length+1,r=[],i=Array(e).fill(100);for(let a=0;a<o;a++){let u;a===0?u=n.header:u=n.rows[a-1];for(let f=0;f<e;f++){const m=u[f],C=(l=m==null?void 0:m.tokens)!=null?l:[],v=N();r.push(v);let w;if(C.length===0)w=[Il()];else if(nr(C[0]))w=t.tokensToBlocks(m.tokens,t),w.length===0&&w.push(Il());else{const{text:E,children:L}=t.tokensToTextWithChildren(m.tokens,t);w=[{id:N(),type:"text",text:E},...L]}t.doc.blocks[v]=w,i[f]=Math.max(i[f],O6((c=t.font)!=null?c:"",w))}}return[{id:N(),type:"table",cols:e,rows:o,colsWidth:i,children:r}]}function JR(n){return[{id:N(),type:"embed",embedType:"hr",embedData:{}}]}function XR(n,t){var c;const e=n.text;if(!e)return[];try{const a=n.text,u=el(a),f=JSON.parse(u);if(f){const{root:m,...C}=f.blocks;return t.doc.blocks={...t.doc.blocks,...C},m}}catch{}const o=(c=n.lang)!=null?c:"Plain Text";if(o==="mermaid")return[{id:N(),type:"embed",embedType:"mermaid",embedData:{mermaidText:e}}];if(o==="plantuml")return[{id:N(),type:"embed",embedType:"plantuml",embedData:{plantumlText:e}}];if(o==="flow"||o==="flowchart")return[{id:N(),type:"embed",embedType:"flowchart",embedData:{flowchartText:e}}];const i=e.split(`
589
+ `).map(a=>({id:N(),type:"text",text:Oi(a)})),s=t.doc,l=N();return s.blocks[l]=i,[{id:N(),type:"code",language:o,children:[l]}]}function tA(n){return[{id:N(),type:"embed",embedType:"image",embedData:{src:n.href,title:n.title}}]}function eA(n,t){const{text:e,children:o}=t.tokensToTextWithChildren(n.tokens,t),r=[];return e.length>0&&r.push({id:N(),type:"text",text:e}),r.push(...o),r}const nA=y("markdown-to-doc");function oA(n,t){return n.type==="heading"?VR(n,t):n.type==="paragraph"?qR(n,t):n.type==="list"?WR(n,t):n.type==="blockquote"?GR(n,t):n.type==="table"?KR(n,t):n.type==="hr"?JR():n.type==="code"?XR(n,t):n.type==="image"?tA(n):n.type==="link"?eA(n,t):(nA.log(`unknown block token, ${JSON.stringify(n)}`),[])}function $h(n,t){const e=[];return n.forEach(o=>{const r=oA(o,t);e.push(...r)}),e}const rA=y("markdown-to-doc");function iA(n,t){const e={text:[],children:[]};return HR(n).forEach((r,i)=>{const s=r[0];if(i===0&&$R(s)){e.text=Ph(r,{},t);return}d(rA,nr(s),`not a block token: ${JSON.stringify(s)}`),e.children.push(...$h(r,t))}),e}function _6(n,t){const o=new o8.marked.Lexer().lex(n),r={blocks:{root:[]},meta:{},comments:{}},i={font:t==null?void 0:t.font,doc:r,tokensToText:Ph,tokensToBlocks:$h,tokensToTextWithChildren:iA,htmlToDoc:t==null?void 0:t.htmlToDoc,listLevel:1},s=$h(o,i);return s.length===0?null:(r.blocks.root.push(...s),r)}function sA(n){if(n.nodeName!=="DIV")return!1;const t=n;return Array.from(t.childNodes).every(e=>e.nodeName==="SPAN"||e instanceof Text)?!!t.querySelector(":scope > .hljs-function, :scope > .hljs-params, :scope > .hljs-string, :scope > .hljs-keyword, :scope > .hljs-attr"):!1}function N6(n){if(sA(n)){const t=n,e=t.parentNode,o=document.createElement("pre");Array.from(t.childNodes).forEach(r=>o.appendChild(r)),e==null||e.insertBefore(o,t);return}n.childNodes.forEach(t=>N6(t))}function Xc(n){var t;if(n instanceof HTMLBRElement){const e=document.createTextNode(`
590
590
  `);(t=n.parentNode)==null||t.insertBefore(e,n),n.remove();return}n.childNodes.forEach(Xc)}function lA(n){n.addRule("preOnlyBlockToCode",{filter:t=>t.nodeName!=="PRE"?!1:Array.from(t.childNodes).every(e=>e.nodeName==="SPAN"||e instanceof Text||e.nodeName==="BR"),replacement:(t,e,o)=>{var r;return Xc(e),`
591
591
 
592
592
  `+o.fence+`
@@ -630,20 +630,20 @@ c0-27.6-22.4-50-50-50H662c-27.6,0-50,22.4-50,50H412c0-27.6-22.4-50-50-50h-45.8C3
630
630
 
631
631
  > ${o}
632
632
 
633
- `}})}class mA{constructor(t){h(this,"_grid",[]);h(this,"_needFixSpanData",!1);Array.from(t.rows).forEach((e,o)=>{Array.from(e.cells).forEach(r=>{this._addCell(o,r)})})}_addCell(t,e){const o=this._getNextColIndex(t),r=e.colSpan,i=e.rowSpan;for(let s=0;s<i;s++)for(let l=0;l<r;l++){const c=t+s,a=o+l;if(this._getCell({row:c,col:a})){this._needFixSpanData=!0,console.warn(`invalid table data, cell data already exists, ${c}, ${a}`);continue}this._setCell({row:c,col:a},{cell:e,virtual:!(l===0&&s===0)})}}_getNextColIndex(t){const e=this._grid[t];if(!e)return 0;let o=0;for(let r=0;r<e.length;r++)if(e[r])o+=1;else return o;return o}_setCell(t,e){if(!(e.cell.colSpan===0||e.cell.rowSpan===0)){for(;this._grid.length<=t.row;)this._grid.push([]);for(let o=0;o<this._grid.length;o++){const r=this._grid[o];for(;r.length<=t.col;)r.push(null)}this._grid[t.row][t.col]=e}}_getCell(t){var o;const e=this._grid[t.row];return e&&(o=e[t.col])!=null?o:null}get rowCount(){return this._grid.length}get colCount(){return this._grid[0].length}getCellData(t){const e=this._getCell(t);return e||null}getCellSpan(t){const e=this._getCell(t);if(!e)return{colSpan:1,rowSpan:1};if(e.virtual)return{colSpan:1,rowSpan:1};const o=()=>{let l=t.col+1;for(;;){const c=this._getCell({row:t.row,col:l});if(!c||c.cell!==e.cell)return l-t.col;l+=1}},r=()=>{let l=t.row+1;for(;;){const c=this._getCell({row:l,col:t.col});if(!c||c.cell!==e.cell)return l-t.row;l+=1}},i=o(),s=r();return i!==e.cell.colSpan&&console.warn(`invalid colSpan: ${i} -> ${e.cell.colSpan}`),s!==e.cell.rowSpan&&console.warn(`invalid rowSpan: ${s} -> ${e.cell.rowSpan}`),{colSpan:i,rowSpan:s}}getColumnWidth(t){const r=Array(this.rowCount).fill(0).map((s,l)=>{const c=this.getCellData({row:l,col:t});if(c&&!c.virtual){const a=c.cell.getAttribute("width")||c.cell.style.width;if(a){if(a.endsWith("%")){const f=a.substr(0,a.length-1),m=Number.parseInt(f,10);if(m>0&&m<=100)return Math.floor(720*m/100)}const u=Number.parseInt(a,10);if(u)return u}return c.cell.getBoundingClientRect().width}return 1e9}),i=Math.min(...r);return i===1e9||Number.isNaN(i)||i<30?0:i}}function gA(n){return new mA(n)}function P6(n,t){var c;const e=gA(n),o=[],r={},i=e.rowCount,s=e.colCount,l=Array(s).fill(100);for(let a=0;a<i;a++)for(let u=0;u<s;u++){let f;const m=e.getCellData({row:a,col:u});if(m&&m.virtual)continue;m&&!m.virtual&&(f=t.htmlToBlocks(m.cell.innerHTML,t)),(!f||f.length===0)&&(f=[{id:N(),type:"text",text:[]}]);const C=N();o.push(C);const{colSpan:v,rowSpan:w}=e.getCellSpan({row:a,col:u});w>1&&(r[`${C}_rowSpan`]=w),v>1&&(r[`${C}_colSpan`]=v),t.doc.blocks[C]=f,m&&!m.virtual&&(l[u]=Math.max(l[u],O6((c=t.font)!=null?c:"",f)))}for(let a=0;a<e.colCount;a++)l[a]=e.getColumnWidth(a)||l[a];return o.length===0?[]:[{cols:e.colCount,rows:e.rowCount,id:N(),type:"table",children:o,...r,colsWidth:l}]}function $6(n,t){var e;if(n.tagName==="TABLE"){const o={blocks:{root:[]},meta:{},comments:{}},r=P6(n,{doc:o,...t});if(r.length===0||((e=r[0].children)==null?void 0:e.length)===0)return;o.blocks.root=r;const i=JSON.stringify(o),s=Lo(i),l=document.createElement("div");l.classList.add("highlight-text-wizdoc");const c=document.createElement("pre");l.appendChild(c),c.innerText=s,n.insertAdjacentElement("beforebegin",l),n.remove();return}Array.from(n.children).forEach(o=>$6(o,t))}function H6(n){if(n instanceof HTMLStyleElement){n.remove();return}Array.from(n.children).forEach(H6)}function j6(n){if(n instanceof HTMLElement){if(n.style.display==="none"){n.remove();return}if(n.style.visibility==="hidden"){n.remove();return}}Array.from(n.children).forEach(j6)}function pA(n,t){const e=ol(n);return e.querySelectorAll("td.js-line-number").forEach(r=>r.remove()),e.querySelectorAll("div.copy-button").forEach(r=>r.remove()),e.querySelectorAll("div.code-copy-button").forEach(r=>r.remove()),e.querySelectorAll("noscript").forEach(r=>r.remove()),Array.from(e.children).forEach(j6),Array.from(e.children).forEach(r=>$6(r,t)),Array.from(e.children).forEach(H6),N6(e),hm(e)}const Zn=new g8.default;Zn.use(lA),Zn.use(cA),Zn.use(aA),Zn.use(dA),Zn.use(uA),Zn.use(hA),Zn.use(fA),Zn.use(e8.gfm);function CA(n,t){const e=F6(n,t);if(!e)return[];const{root:o,...r}=e.blocks;return t.doc.blocks={...t.doc.blocks,...r},o}function F6(n,t){const e=Zn.turndown(n);return _6(e,{htmlToDoc:o=>z6(o,t)})}function z6(n,t){const e=pA(n,{font:t==null?void 0:t.font,htmlToBlocks:CA});return F6(e)}function V6(n){return n.indexOf('xmlns:o="urn:schemas-microsoft-com:office:office"')!==-1}function ta(n){return["A","B","DEL","I","U","S","SPAN","SUB","SUP"].indexOf(n.tagName)!==-1}function bA(n){return["P","H1","H2","H3","H4","H5","H6","H7","H8","LI"].indexOf(n.tagName)!==-1}function U6(n){return n.replace(/\r\n/g," ").replace(/\n/g," ").replace(/\r/g," ")}function vA(n){if(!n.tagName)return!1;if(n.tagName.toLocaleLowerCase()==="img")return!0;const t=n.querySelectorAll("img");for(let e=0;e<t.length;e+=1){const o=t[e];if(!o.src||o.getAttribute("width")==="0"||o.getAttribute("height")==="0")return!1}return t.length}function kA(n){return(n.tagName.toLocaleLowerCase()==="img"?[n]:Array.from(n.querySelectorAll("img"))).map(r=>({id:N(),type:"embed",embedType:"image",embedData:{src:r.src,width:r.width,height:r.height}}))}function q6(n){var e;return Array.from(((e=n.getAttribute("style"))!=null?e:"").split(" ")).findIndex(o=>o.startsWith("level"))!==-1}function yA(n){var e;const t=Array.from(((e=n.getAttribute("style"))!=null?e:"").split(" "));for(let o=0;o<t.length;o++){const r=t[o];if(r.startsWith("mso-list:"))return r}return""}function W6(n){var e,o;const t=Array.from(((e=n.getAttribute("style"))!=null?e:"").split(" "));for(let r=0;r<t.length;r++){const i=t[r];if(i.startsWith("level")){const s=(o=Number.parseInt(i.substring(5),10))!=null?o:void 0;if(s)return s}}return 1}function wA(n,t){n.setAttribute("data-group-id",t)}function BA(n){const t={},e=r=>{Array.from(Object.keys(t)).forEach(i=>{Number.parseInt(i,10)>r&&delete t[i]})};let o="";Array.from(n.children).forEach(r=>{if(q6(r)){const i=yA(r);o!==i&&(e(0),o=i);const s=W6(r);e(s);let l=t[`${s}`];l||(l=N(),t[`${s}`]=l),wA(r,l)}})}function G6(n){if(!q6(n))return{};const t=W6(n),e=n.getAttribute("data-group-id")||N();return{start:1,level:t,groupId:e,ordered:!0,type:"list"}}const EA=y("office-list");function Z6(n){return n instanceof HTMLOListElement||n instanceof HTMLUListElement}function IA(n,t){d(EA,Z6(n),"not list group element");let e=!1,o=1;const r=N();n instanceof HTMLOListElement&&(e=!0,o=n.start);const i=n,s=[];let l;return Array.from(i.children).forEach(c=>{if(c instanceof HTMLLIElement){const u=G6(c),f=t.textElementToBlocks(c,t);l||(l=u.level);const m=f[0];s.push({...m,type:"list",ordered:e,level:l,groupId:r,start:o}),o+=1,s.push(...f.slice(1));return}const a=t.blockElementToBlocks(c,t);s.push(...a)}),s}function Y6(n,t){if(n.nodeName==="META")return[];if(n instanceof HTMLTableElement)return P6(n,t);if(Z6(n))return[...IA(n,t)];if(vA(n))return[...kA(n)];if(bA(n))return[...t.textElementToBlocks(n,t)];if(!n.children)return[];const e=[];return Array.from(n.children).forEach(o=>{const r=Y6(o,t);e.push(...r)}),e}function Q6(n,t){const e=[];return n.forEach(o=>{var r;if(o instanceof Element)if(ta(o)){const i=document.createElement("p");i.appendChild(o);const s=t.blockElementToBlocks(i,t);e.push(...s)}else{const i=t.blockElementToBlocks(o,t);e.push(...i)}else if(o instanceof Text){const i=jn(U6((r=o.textContent)!=null?r:""));e.push(i)}}),e}function xA(n){const t=Array.from(n.children);for(let e=0;e<t.length;e++){const o=t[e];if(!ta(o))continue;let r=e+1;for(;r<t.length&&ta(t[r]);)r+=1;const i=document.createElement("p");o.insertAdjacentElement("beforebegin",i);for(let s=e;s<r;s++)i.appendChild(t[s]);e=r-1}}function SA(n,t){const e=ol(n);return Q6(Array.from(e.childNodes),t)}function TA(n){if(!(n instanceof HTMLElement))return{};const t={};if(n.style.textAlign==="right"?t.align="right":n.style.textAlign==="center"&&(t.align="center"),n.style.marginLeft){const e=Math.ceil(Number.parseInt(n.style.marginLeft,10)/20);e>=1&&e<=12&&(t.padding=e)}return t}function DA(n,t){var o;const e=U6((o=n.nodeValue)!=null?o:" ");return t&&Object.keys(t).length>0?{insert:e,attributes:t}:{insert:e}}function LA(n,t){if(n.nodeName==="B")return{...t,"style-bold":!0};if(n.nodeName==="I")return{...t,"style-italic":!0};if(n.nodeName==="U")return{...t,"style-underline":!0};if(n.nodeName==="S"||n.nodeName==="DEL")return{...t,"style-strikethrough":!0};if(n.nodeName==="SUB")return{...t,"style-sub":!0};if(n.nodeName==="SUP")return{...t,"style-super":!0};if(n.nodeName==="A"&&n.href){const o=n.href;if(o.startsWith("http:")||o.startsWith("https:"))return{...t,link:n.href}}const e={...t};return n instanceof HTMLSpanElement?(n.style.backgroundColor&&(e["inline-style-background-color"]=n.style.backgroundColor),n.style.color&&(e["inline-style-color"]=n.style.color),n.style.fontSize&&(e["inline-style-font-size"]=n.style.fontSize),n.style.fontFamily&&(e["inline-style-font-family"]=n.style.fontFamily),e):t}function K6(n,t,e){if(n instanceof HTMLSpanElement&&n.getAttribute("style")==="mso-list:Ignore")return;const o=LA(n,t);if(n instanceof Text&&n.nodeValue){e.push(DA(n,o));return}n.childNodes.length>0&&Array.from(n.childNodes).forEach(r=>{K6(r,o,e)})}function J6(n){return n instanceof Element?ta(n):!0}function Hh(n){return!J6(n)}function MA(n){if(n.length===0)return[];if(n.length===1)return[n];const t=[];let e=[n[0]],o=Hh(n[0]);for(let r=1;r<n.length;r++){const i=n[r];o===Hh(i)?e.push(i):(t.push(e),e=[i],o=Hh(i))}return t.push(e),t}function RA(n,t){const e={};if(n.tagName.startsWith("H")){const i=Number.parseInt(n.tagName.substr(1),10);i>=1&&i<=8&&(e.heading=i)}const o=MA(Array.from(n.childNodes)),r=[];return o.forEach((i,s)=>{if(J6(i[0])){const l=[],c={};Array.from(n.childNodes).forEach(u=>{K6(u,c,l)});let a={};s===0&&(a=G6(n)),r.push({id:N(),type:"text",text:l,...a,...e,...TA(n)})}i.forEach(l=>{const c=t.blockElementToBlocks(l,t);r.push(...c)})}),r}function AA(n,t){const e=ol(n);BA(e),xA(e);const o={blocks:{root:[]},meta:{},comments:{}},r={font:t==null?void 0:t.font,doc:o,blockElementToBlocks:Y6,textElementToBlocks:RA,htmlToBlocks:SA},i=Q6(Array.from(e.children),r);if(i.length!==0)return o.blocks.root=i,o}const OA=y("html-to-doc");function X6(n,t){if(!n)return null;const e=PR(n);if(e)return e;if(V6(n)){const o=AA(n,t);if(o)return o}try{return z6(n,t)}catch(o){OA.error(o)}return null}class _A{async fromData(t,e){const o={},r=e.getData("text/html");if(r){const i=X6(r,{font:t.rootContainer});i&&(V6(r)?o["text/office-html"]=i:o["text/html"]=i)}return o}}class NA{async fromData(t,e){const o=e.getData("text/plain");if(!o)return;const r=_6(o,{font:t.rootContainer,htmlToDoc:X6});if(!!r)return{"text/markdown":r}}}function PA(n){return/^([\d\w\u4e00-\u9fa5\s]*[\u4e00-\u9fa5\s]{1}|)((https|http|ftp)?:\/\/)[^\s]+/.test(n)}function $A(n){const t=[],e=n.split(/https|http|ftp/)[0],o=n.substring(e.length).trim();if(e&&e.length){const i=_e(e,null);t.push(i,_e(" ",null))}const r=_e(o,{link:o});return t.push(r,_e(" ",null)),t}class HA{async fromData(t,e){const o={},r=e.getData("text/plain");if(r){const l={blocks:{root:r.replace(/\r\n/g,`
633
+ `}})}class mA{constructor(t){h(this,"_grid",[]);h(this,"_needFixSpanData",!1);Array.from(t.rows).forEach((e,o)=>{Array.from(e.cells).forEach(r=>{this._addCell(o,r)})})}_addCell(t,e){const o=this._getNextColIndex(t),r=e.colSpan,i=e.rowSpan;for(let s=0;s<i;s++)for(let l=0;l<r;l++){const c=t+s,a=o+l;if(this._getCell({row:c,col:a})){this._needFixSpanData=!0,console.warn(`invalid table data, cell data already exists, ${c}, ${a}`);continue}this._setCell({row:c,col:a},{cell:e,virtual:!(l===0&&s===0)})}}_getNextColIndex(t){const e=this._grid[t];if(!e)return 0;let o=0;for(let r=0;r<e.length;r++)if(e[r])o+=1;else return o;return o}_setCell(t,e){if(!(e.cell.colSpan===0||e.cell.rowSpan===0)){for(;this._grid.length<=t.row;)this._grid.push([]);for(let o=0;o<this._grid.length;o++){const r=this._grid[o];for(;r.length<=t.col;)r.push(null)}this._grid[t.row][t.col]=e}}_getCell(t){var o;const e=this._grid[t.row];return e&&(o=e[t.col])!=null?o:null}get rowCount(){return this._grid.length}get colCount(){return this._grid[0].length}getCellData(t){const e=this._getCell(t);return e||null}getCellSpan(t){const e=this._getCell(t);if(!e)return{colSpan:1,rowSpan:1};if(e.virtual)return{colSpan:1,rowSpan:1};const o=()=>{let l=t.col+1;for(;;){const c=this._getCell({row:t.row,col:l});if(!c||c.cell!==e.cell)return l-t.col;l+=1}},r=()=>{let l=t.row+1;for(;;){const c=this._getCell({row:l,col:t.col});if(!c||c.cell!==e.cell)return l-t.row;l+=1}},i=o(),s=r();return i!==e.cell.colSpan&&console.warn(`invalid colSpan: ${i} -> ${e.cell.colSpan}`),s!==e.cell.rowSpan&&console.warn(`invalid rowSpan: ${s} -> ${e.cell.rowSpan}`),{colSpan:i,rowSpan:s}}getColumnWidth(t){const r=Array(this.rowCount).fill(0).map((s,l)=>{const c=this.getCellData({row:l,col:t});if(c&&!c.virtual){const a=c.cell.getAttribute("width")||c.cell.style.width;if(a){if(a.endsWith("%")){const f=a.substr(0,a.length-1),m=Number.parseInt(f,10);if(m>0&&m<=100)return Math.floor(720*m/100)}const u=Number.parseInt(a,10);if(u)return u}return c.cell.getBoundingClientRect().width}return 1e9}),i=Math.min(...r);return i===1e9||Number.isNaN(i)||i<30?0:i}}function gA(n){return new mA(n)}function P6(n,t){var c;const e=gA(n),o=[],r={},i=e.rowCount,s=e.colCount,l=Array(s).fill(100);for(let a=0;a<i;a++)for(let u=0;u<s;u++){let f;const m=e.getCellData({row:a,col:u});if(m&&m.virtual)continue;m&&!m.virtual&&(f=t.htmlToBlocks(m.cell.innerHTML,t)),(!f||f.length===0)&&(f=[{id:N(),type:"text",text:[]}]);const C=N();o.push(C);const{colSpan:v,rowSpan:w}=e.getCellSpan({row:a,col:u});w>1&&(r[`${C}_rowSpan`]=w),v>1&&(r[`${C}_colSpan`]=v),t.doc.blocks[C]=f,m&&!m.virtual&&(l[u]=Math.max(l[u],O6((c=t.font)!=null?c:"",f)))}for(let a=0;a<e.colCount;a++)l[a]=e.getColumnWidth(a)||l[a];return o.length===0?[]:[{cols:e.colCount,rows:e.rowCount,id:N(),type:"table",children:o,...r,colsWidth:l}]}function $6(n,t){var e;if(n.tagName==="TABLE"){const o={blocks:{root:[]},meta:{},comments:{}},r=P6(n,{doc:o,...t});if(r.length===0||((e=r[0].children)==null?void 0:e.length)===0)return;o.blocks.root=r;const i=JSON.stringify(o),s=Lo(i),l=document.createElement("div");l.classList.add("highlight-text-wizdoc");const c=document.createElement("pre");l.appendChild(c),c.innerText=s,n.insertAdjacentElement("beforebegin",l),n.remove();return}Array.from(n.children).forEach(o=>$6(o,t))}function H6(n){if(n instanceof HTMLStyleElement){n.remove();return}Array.from(n.children).forEach(H6)}function j6(n){if(n instanceof HTMLElement){if(n.style.display==="none"){n.remove();return}if(n.style.visibility==="hidden"){n.remove();return}}Array.from(n.children).forEach(j6)}function pA(n,t){const e=ol(n);return e.querySelectorAll("td.js-line-number").forEach(r=>r.remove()),e.querySelectorAll("div.copy-button").forEach(r=>r.remove()),e.querySelectorAll("div.code-copy-button").forEach(r=>r.remove()),e.querySelectorAll("noscript").forEach(r=>r.remove()),Array.from(e.children).forEach(j6),Array.from(e.children).forEach(r=>$6(r,t)),Array.from(e.children).forEach(H6),N6(e),hm(e)}const Zn=new g8.default;Zn.use(lA),Zn.use(cA),Zn.use(aA),Zn.use(dA),Zn.use(uA),Zn.use(hA),Zn.use(fA),Zn.use(e8.gfm);function CA(n,t){const e=F6(n,t);if(!e)return[];const{root:o,...r}=e.blocks;return t.doc.blocks={...t.doc.blocks,...r},o}function F6(n,t){const e=Zn.turndown(n);return _6(e,{htmlToDoc:o=>z6(o,t)})}function z6(n,t){const e=pA(n,{font:t==null?void 0:t.font,htmlToBlocks:CA});return F6(e)}function U6(n){return n.indexOf('xmlns:o="urn:schemas-microsoft-com:office:office"')!==-1}function ta(n){return["A","B","DEL","I","U","S","SPAN","SUB","SUP"].indexOf(n.tagName)!==-1}function bA(n){return["P","H1","H2","H3","H4","H5","H6","H7","H8","LI"].indexOf(n.tagName)!==-1}function V6(n){return n.replace(/\r\n/g," ").replace(/\n/g," ").replace(/\r/g," ")}function vA(n){if(!n.tagName)return!1;if(n.tagName.toLocaleLowerCase()==="img")return!0;const t=n.querySelectorAll("img");for(let e=0;e<t.length;e+=1){const o=t[e];if(!o.src||o.getAttribute("width")==="0"||o.getAttribute("height")==="0")return!1}return t.length}function kA(n){return(n.tagName.toLocaleLowerCase()==="img"?[n]:Array.from(n.querySelectorAll("img"))).map(r=>({id:N(),type:"embed",embedType:"image",embedData:{src:r.src,width:r.width,height:r.height}}))}function q6(n){var e;return Array.from(((e=n.getAttribute("style"))!=null?e:"").split(" ")).findIndex(o=>o.startsWith("level"))!==-1}function yA(n){var e;const t=Array.from(((e=n.getAttribute("style"))!=null?e:"").split(" "));for(let o=0;o<t.length;o++){const r=t[o];if(r.startsWith("mso-list:"))return r}return""}function W6(n){var e,o;const t=Array.from(((e=n.getAttribute("style"))!=null?e:"").split(" "));for(let r=0;r<t.length;r++){const i=t[r];if(i.startsWith("level")){const s=(o=Number.parseInt(i.substring(5),10))!=null?o:void 0;if(s)return s}}return 1}function wA(n,t){n.setAttribute("data-group-id",t)}function BA(n){const t={},e=r=>{Array.from(Object.keys(t)).forEach(i=>{Number.parseInt(i,10)>r&&delete t[i]})};let o="";Array.from(n.children).forEach(r=>{if(q6(r)){const i=yA(r);o!==i&&(e(0),o=i);const s=W6(r);e(s);let l=t[`${s}`];l||(l=N(),t[`${s}`]=l),wA(r,l)}})}function G6(n){if(!q6(n))return{};const t=W6(n),e=n.getAttribute("data-group-id")||N();return{start:1,level:t,groupId:e,ordered:!0,type:"list"}}const EA=y("office-list");function Z6(n){return n instanceof HTMLOListElement||n instanceof HTMLUListElement}function IA(n,t){d(EA,Z6(n),"not list group element");let e=!1,o=1;const r=N();n instanceof HTMLOListElement&&(e=!0,o=n.start);const i=n,s=[];let l;return Array.from(i.children).forEach(c=>{if(c instanceof HTMLLIElement){const u=G6(c),f=t.textElementToBlocks(c,t);l||(l=u.level);const m=f[0];s.push({...m,type:"list",ordered:e,level:l,groupId:r,start:o}),o+=1,s.push(...f.slice(1));return}const a=t.blockElementToBlocks(c,t);s.push(...a)}),s}function Y6(n,t){if(n.nodeName==="META")return[];if(n instanceof HTMLTableElement)return P6(n,t);if(Z6(n))return[...IA(n,t)];if(vA(n))return[...kA(n)];if(bA(n))return[...t.textElementToBlocks(n,t)];if(!n.children)return[];const e=[];return Array.from(n.children).forEach(o=>{const r=Y6(o,t);e.push(...r)}),e}function Q6(n,t){const e=[];return n.forEach(o=>{var r;if(o instanceof Element)if(ta(o)){const i=document.createElement("p");i.appendChild(o);const s=t.blockElementToBlocks(i,t);e.push(...s)}else{const i=t.blockElementToBlocks(o,t);e.push(...i)}else if(o instanceof Text){const i=jn(V6((r=o.textContent)!=null?r:""));e.push(i)}}),e}function xA(n){const t=Array.from(n.children);for(let e=0;e<t.length;e++){const o=t[e];if(!ta(o))continue;let r=e+1;for(;r<t.length&&ta(t[r]);)r+=1;const i=document.createElement("p");o.insertAdjacentElement("beforebegin",i);for(let s=e;s<r;s++)i.appendChild(t[s]);e=r-1}}function SA(n,t){const e=ol(n);return Q6(Array.from(e.childNodes),t)}function TA(n){if(!(n instanceof HTMLElement))return{};const t={};if(n.style.textAlign==="right"?t.align="right":n.style.textAlign==="center"&&(t.align="center"),n.style.marginLeft){const e=Math.ceil(Number.parseInt(n.style.marginLeft,10)/20);e>=1&&e<=12&&(t.padding=e)}return t}function DA(n,t){var o;const e=V6((o=n.nodeValue)!=null?o:" ");return t&&Object.keys(t).length>0?{insert:e,attributes:t}:{insert:e}}function LA(n,t){if(n.nodeName==="B")return{...t,"style-bold":!0};if(n.nodeName==="I")return{...t,"style-italic":!0};if(n.nodeName==="U")return{...t,"style-underline":!0};if(n.nodeName==="S"||n.nodeName==="DEL")return{...t,"style-strikethrough":!0};if(n.nodeName==="SUB")return{...t,"style-sub":!0};if(n.nodeName==="SUP")return{...t,"style-super":!0};if(n.nodeName==="A"&&n.href){const o=n.href;if(o.startsWith("http:")||o.startsWith("https:"))return{...t,link:n.href}}const e={...t};return n instanceof HTMLSpanElement?(n.style.backgroundColor&&(e["inline-style-background-color"]=n.style.backgroundColor),n.style.color&&(e["inline-style-color"]=n.style.color),n.style.fontSize&&(e["inline-style-font-size"]=n.style.fontSize),n.style.fontFamily&&(e["inline-style-font-family"]=n.style.fontFamily),e):t}function K6(n,t,e){if(n instanceof HTMLSpanElement&&n.getAttribute("style")==="mso-list:Ignore")return;const o=LA(n,t);if(n instanceof Text&&n.nodeValue){e.push(DA(n,o));return}n.childNodes.length>0&&Array.from(n.childNodes).forEach(r=>{K6(r,o,e)})}function J6(n){return n instanceof Element?ta(n):!0}function Hh(n){return!J6(n)}function MA(n){if(n.length===0)return[];if(n.length===1)return[n];const t=[];let e=[n[0]],o=Hh(n[0]);for(let r=1;r<n.length;r++){const i=n[r];o===Hh(i)?e.push(i):(t.push(e),e=[i],o=Hh(i))}return t.push(e),t}function RA(n,t){const e={};if(n.tagName.startsWith("H")){const i=Number.parseInt(n.tagName.substr(1),10);i>=1&&i<=8&&(e.heading=i)}const o=MA(Array.from(n.childNodes)),r=[];return o.forEach((i,s)=>{if(J6(i[0])){const l=[],c={};Array.from(n.childNodes).forEach(u=>{K6(u,c,l)});let a={};s===0&&(a=G6(n)),r.push({id:N(),type:"text",text:l,...a,...e,...TA(n)})}i.forEach(l=>{const c=t.blockElementToBlocks(l,t);r.push(...c)})}),r}function AA(n,t){const e=ol(n);BA(e),xA(e);const o={blocks:{root:[]},meta:{},comments:{}},r={font:t==null?void 0:t.font,doc:o,blockElementToBlocks:Y6,textElementToBlocks:RA,htmlToBlocks:SA},i=Q6(Array.from(e.children),r);if(i.length!==0)return o.blocks.root=i,o}const OA=y("html-to-doc");function X6(n,t){if(!n)return null;const e=PR(n);if(e)return e;if(U6(n)){const o=AA(n,t);if(o)return o}try{return z6(n,t)}catch(o){OA.error(o)}return null}class _A{async fromData(t,e){const o={},r=e.getData("text/html");if(r){const i=X6(r,{font:t.rootContainer});i&&(U6(r)?o["text/office-html"]=i:o["text/html"]=i)}return o}}class NA{async fromData(t,e){const o=e.getData("text/plain");if(!o)return;const r=_6(o,{font:t.rootContainer,htmlToDoc:X6});if(!!r)return{"text/markdown":r}}}function PA(n){return/^([\d\w\u4e00-\u9fa5\s]*[\u4e00-\u9fa5\s]{1}|)((https|http|ftp)?:\/\/)[^\s]+/.test(n)}function $A(n){const t=[],e=n.split(/https|http|ftp/)[0],o=n.substring(e.length).trim();if(e&&e.length){const i=_e(e,null);t.push(i,_e(" ",null))}const r=_e(o,{link:o});return t.push(r,_e(" ",null)),t}class HA{async fromData(t,e){const o={},r=e.getData("text/plain");if(r){const l={blocks:{root:r.replace(/\r\n/g,`
634
634
  `).replace(/\r/g,`
635
635
  `).split(`
636
- `).map(c=>{const a={id:N(),type:"text"};if(PA(c))return a.text=$A(c),a;const u=c?[_e(c,null)]:[];return a.text=u,a})},meta:{},comments:{}};o["text/plain"]=l}return o}}function jA(n){const t=[];for(let e=0;e<n.length;e++){const o=n[e];o.type.toLocaleLowerCase().startsWith("image/")&&t.push(o)}return t}class t3{constructor(t){t.dataConverter.addConverter(new _A),t.dataConverter.addConverter(new HA),t.dataConverter.addConverter(new NA)}async handleBeforePaste(t,e,o){const r=e.clipboardData;if(r){const i=jA(r.files);if(i.length>0&&!o["text/office-html"])return await this.handleInsertImages(t,i),!0}return!1}async handleInsertImages(t,e){const o=t.selection.focusedBlock,r=H(o),i=K(o),s=V(r);let l=i;wt(t,o)||(l+=1);for(let c=0;c<e.length;c++){const a=e[c],u=await tg(t,"image",s,l+c,{file:a});u&&eg(t,u,"image",{id:"replace-image",name:"Replace image",data:{block:u,image:a}})}}}function e3(n){return It.isSafari&&!!n&&Date.now()-n<100}const n3=y("highlight-data");class ea{constructor(t){h(this,"data",new Map);this.editor=t}add(t,e,o){const r={id:N(),blockId:G(t),oldText:this.editor.getBlockText(t),start:e,end:o};return this.data.set(r.id,r),r}get(t){const e=this.data.get(t);return d(n3,e,`no highligh data: ${t}`),e}remove(t){this.data.delete(t)}clearBlockData(t){Array.from(this.data.values()).forEach(e=>{e.blockId===t&&this.data.delete(e.id)})}destroy(){}static getData(t){return t.addCustom("highligh-data",()=>new ea(t))}}function FA(n,t,e,o,r){const s=ea.getData(n).add(t,e,o);return r.setAttribute("data-highlight-id",s.id),s}function na(n,t){const e=t.getAttribute("data-highlight-id");return d(n3,e,"invalid highlight elem, no id"),ea.getData(n).get(e)}const Ms=y("highligh-dom");function zA(n){return lt(n,"editor-highlight")}function In(n){const t=n.rootContainer.querySelectorAll(".editor-highlight");return Array.from(t)}function VA(n){const t=n.rootContainer.querySelectorAll(".editor-replace-result-highlight");return Array.from(t)}function jh(n){const t=n.querySelectorAll(".editor-highlight");return Array.from(t)}function UA(n){jh(n).forEach(t=>{t.remove()})}function ni(n){return In(n).length}function qA(n,t){d(Ms,t>=0,`invalid highlight index: ${t}`);const e=In(n);return e.length===0?null:(d(Ms,t<e.length,`invalid highlight index: ${t}/${e.length}`),e[t])}function WA(n,t,{left:e,top:o,width:r,height:i},s){const l=["editor-highlight-child"];s&&l.push("editor-highlight-readonly");const c=b("div",l,n);c.style.top=`${o}px`,c.style.left=`${e}px`,c.style.width=`${r}px`,c.style.height=`${i}px`}function o3(n,t,e,o,r){d(Ms,o>0,`invalid end: ${o}`);const i=At(t),s=t.getBoundingClientRect(),l=Ao(n,t,Ot(n,t,e,o)),a=b("div",[r==="find"?"editor-highlight":"editor-replace-result-highlight"],i);l.forEach(u=>{WA(a,t,{left:u.left-s.left,width:u.width,top:u.top-s.top,height:u.height})}),FA(n,t,e,o,a)}function GA(n,t,e,o){return o3(n,t,e,o,"find")}function r3(n,t,e,o){return o3(n,t,e,o,"replace")}function oa(n,t){In(n).forEach(l=>{lt(l,"active")&&F(l,"active")}),M(t,"active"),d(Ms,t.firstChild instanceof HTMLElement,"invalid highligh dom, invalid elem child");const o=t.firstChild,r=o.getBoundingClientRect(),i=Nn(n.rootContainer);let s=r.y;s===0&&(s=o.getBoundingClientRect().y),Ei(i)}function Rs(n){const t=n.rootContainer.querySelector(".editor-highlight.active");return t||null}function i3(n){return d(Ms,n,"no highlight elem"),lt(n,"editor-highlight-readonly")}const or=y("highligh-text");function ZA(n){VA(n).forEach(e=>{e.remove()})}function Fh(n,t){In(n).forEach(o=>{o.remove()}),t!=null&&t.keepReplaceResult||ZA(n)}function s3(n){const t=Rs(n);if(!t)return-1;const o=In(n).indexOf(t);return d(or,o!==-1,`invalid highlight index: ${o}`),o}function YA(n){const t=In(n);if(t.length===0)return 0;const e=Rs(n);let o=e?t.indexOf(e):-1;!e||o===-1||o===t.length-1?o=0:o+=1;const r=t[o];return oa(n,r),o}function QA(n){const t=In(n);if(t.length===0)return 0;const e=Rs(n);let o=e?t.indexOf(e):-1;!e||o===-1||o===0?o=t.length-1:o-=1;const r=t[o];return oa(n,r),o}function KA(n,t){const e=In(n);e.length>0&&t<e.length&&oa(n,e[t])}function JA(n,t,e){const o=Rs(n);if(!o)return!1;const r=z(o);if(d(or,r,"no parent block"),!n.isBlockWritable(r))return!1;const i=ni(n);let s=s3(n);if(!i3(o)&&n.isBlockWritable(r)){const a=na(n,o),u=n.getBlockText(r),{start:f,end:m}=na(n,o),[C,v]=ne.transformOffset(a.oldText,u,[f,m]),w=pg(u,C,v-C);if(Tt(w).toLowerCase()!==t.toLowerCase())return!1;const E=El(u,C,v,e);n.setBlockText(r,E),UA(r),l3(n,r,t),e&&r3(n,r,C,C+e.length)}const l=ni(n);s>=l?s=0:l>i&&(s+=1);const c=qA(n,s);return c&&oa(n,c),!0}function XA(n,t,e,o){if(!j(n,t)||!n.isBlockWritable(t))return 0;const r=n.getBlockText(t);d(or,r,"no block text");const i={count:0},s=Hg(r,e,o,i);return Tt(r)===Tt(s)?0:(n.setBlockText(t,s),i.count)}function tO(n,t,e){if(d(or,zA(t),"not a highlight elem"),i3(t))return;d(or,e>0,"invalid highlight length");const o=na(n,t),r=z(t);d(or,r,"no parent block"),r3(n,r,o.start,o.start+e)}function eO(n,t){In(n).forEach(o=>{tO(n,o,t)})}function nO(n,t,e){if(n.readonly)return 0;const o=i=>{let s=0;return Rt(i).forEach(c=>{ct(n,c)?Le(n,c).forEach(u=>{s+=o(u)}):s+=XA(n,c,t,e)}),s},r=o(n.rootContainer);return e.length>0&&eO(n,e.length),r}function oO(n){const t=n.selection.range.end,e=n.getBlockById(t.blockId),o=t.isSimple()?t.offset:1,r=jh(e);for(let l=0;l<r.length;l++){const c=r[l],{end:a}=na(n,c);if(a>=o)return c}const i=B1(n,{simpleBlockOnly:!0}),s=i.indexOf(e);if(s===-1)return null;for(let l=s+1;l<i.length;l++){const c=i[l],a=jh(c);if(a.length>0)return a[0]}return null}function rO(n){const t=In(n),e=oO(n);return e?t.indexOf(e):0}function l3(n,t,e){if(!e)return;d(or,j(n,t),"not a text block");const o=n.getBlockText(t),r=$1(o,e);r.length>0&&r.forEach(({start:i,end:s})=>{GA(n,t,i,s)})}function iO(n,t){if(Fh(n),!t)return;B1(n,{simpleBlockOnly:!0}).forEach(o=>{l3(n,o,t)})}class sO{constructor(t){h(this,"dialog",null);h(this,"root");h(this,"oldText","");h(this,"_compositionEndTime",0);h(this,"components");h(this,"handleFindChanged",()=>{this.doSearch({keepReplaceResult:!1,gotoFirstSearchResult:!0})});h(this,"handleCompositionEnd",()=>{this._compositionEndTime=Date.now(),this.handleFindChanged()});h(this,"handleInput",t=>{if(t.isComposing||e3(this._compositionEndTime)){this.doSearch.cancel();return}this.handleFindChanged()});h(this,"handleFind",()=>{this.findNext({keepSearchResult:!1})});h(this,"handleReplace",()=>{const t=this.components.findInput.value;if(!t||!Rs(this.editor))return;const o=this.components.replaceInput.value;if(t===o)return;if(JA(this.editor,t,o)){const i=s3(this.editor),s=ni(this.editor);this.updateSearchStatus(i,s)}this.findNext({keepSearchResult:!0})});h(this,"handleReplaceAll",()=>{const t=this.components.findInput.value;if(!t)return;const e=this.components.replaceInput.value;if(t===e)return;nO(this.editor,t,e)>0&&(this.oldText="",this.doSearchNow({keepReplaceResult:!0,gotoFirstSearchResult:!0}),this.clearFind({keepReplaceResult:!0}))});h(this,"doSearch",ie.default(this.doSearchNow,300));this.editor=t;const e=b("div",["editor-find-dialog"],null),o=b("div",["editor-find-content"],e),r=b("div",["editor-find-dialog-row"],o),i=hr(qd,["editor-find-dialog-button-close"],e),s=b("label",["editor-find-dialog-label"],r,S.t("find.findLabel"));s.htmlFor="";const l=b("div",["editor-find-dialog-input-container"],r),c=b("input",["editor-find-dialog-input"],l);c.type="text",c.placeholder=S.t("find.findPlaceholder");const a=b("div",["editor-find-dialog-status"],l),u=hr(p5,["editor-find-dialog-icon-button"],a),f=b("div",["editor-find-dialog-curr"],a,"0/0"),m=hr(C5,["editor-find-dialog-icon-button"],a);let C;S.t("find.moreButton")?C=b("button",["editor-find-dialog-button"],r,S.t("find.moreButton")):C=hr(Wd,["editor-find-dialog-icon-button-border"],r);const v=b("div",["editor-find-dialog-row"],o),w=b("label",["editor-find-dialog-label"],v,S.t("find.replaceLabel"));w.htmlFor="";const E=b("div",["editor-find-dialog-input-container"],v),L=b("input",["editor-find-dialog-input"],E);L.type="text",L.placeholder=S.t("find.replacePlaceholder");const x=b("div",["editor-find-dialog-row"],o);b("div",["editor-find-dialog-space"],x);const A=b("button",["editor-find-dialog-button"],x,S.t("find.findButton")),O=b("button",["editor-find-dialog-button"],x,S.t("find.replaceButton")),P=b("button",["editor-find-dialog-button"],x,S.t("find.replaceAllButton"));C.onclick=()=>{this.showReplace()},i.onclick=()=>{this.hide()},c.onkeydown=U=>{if(U.isComposing||e3(this._compositionEndTime)){this.doSearch.cancel();return}im(U)?(this.doSearch.cancel(),this.doSearchNow({keepReplaceResult:!1,gotoFirstSearchResult:!0})):Ja(U)&&this.hide()},c.oninput=this.handleInput,c.onpaste=this.handleFindChanged,c.oncut=this.handleFindChanged,c.addEventListener("compositionend",this.handleCompositionEnd),c.maxLength=50,A.onclick=this.handleFind,O.onclick=this.handleReplace,P.onclick=this.handleReplaceAll,L.maxLength=50,m.onclick=()=>{this.gotoNext()},u.onclick=()=>{this.gotoPrev()},this.components={findInput:c,findPrev:u,findCurrent:f,findNext:m,replaceInput:L,findButton:A,replaceButton:O,replaceAllButton:P,closeButton:i,showReplaceButton:C,rowReplace:v,rowActions:x,statusContainer:a},this.root=e}findNext(t){this.doSearch.cancel(),this.doSearchNow({keepReplaceResult:t.keepSearchResult,gotoFirstSearchResult:!0})}doSearchNow(t){const e=this.components.findInput.value;if(e||this.clearFind(t),this.oldText===e){this.gotoNext();return}this.oldText=e,iO(this.editor,e);const o=ni(this.editor),r=rO(this.editor);t.gotoFirstSearchResult&&KA(this.editor,r),this.updateSearchStatus(r,o)}gotoNext(){const t=ni(this.editor),e=YA(this.editor);this.updateSearchStatus(e,t)}gotoPrev(){const t=ni(this.editor),e=QA(this.editor);this.updateSearchStatus(e,t)}updateSearchStatus(t,e){if(this.oldText?this.components.statusContainer.style.display="flex":this.components.statusContainer.style.display="none",e===0)this.components.findCurrent.innerText="0/0",this.components.replaceAllButton.disabled=!0,this.components.replaceButton.disabled=!0,this.components.findButton.disabled=!0;else{this.components.findCurrent.innerText=`${t+1}/${e}`;const o=this.editor.readonly;this.components.replaceAllButton.disabled=o,this.components.replaceButton.disabled=o,this.components.findButton.disabled=!1}}clearFind(t){Fh(this.editor),this.updateSearchStatus(0,0)}showFindOnly(){this.components.rowReplace.style.display="none",this.components.rowActions.style.display="none",this.components.showReplaceButton.style.display="flex"}showReplace(){this.components.rowReplace.style.display="flex",this.components.rowActions.style.display="flex",this.components.showReplaceButton.style.display="none",this.components.replaceInput.focus(),this.components.replaceInput.select()}hideSearchResult(){this.components.statusContainer.style.display="none"}showSearchResult(){this.components.statusContainer.style.display="flex"}show(t){const e=this.editor.getSelectedText();e.length>0&&e.length<50&&(this.components.findInput.value=e),this.root.style.display="flex",t!=null&&t.showFindAndReplace?(this.showReplace(),this.components.findInput.value&&setTimeout(()=>{this.components.replaceInput.focus()})):this.showFindOnly(),this.hideSearchResult(),this.oldText="",this.doSearchNow({keepReplaceResult:!1,gotoFirstSearchResult:!0});const o=this.editor.readonly;this.components.replaceButton.disabled=o,this.components.replaceAllButton.disabled=o,this.components.replaceInput.disabled=o,this.dialog||(this.dialog=new rs(this.root,{disablePageScroll:!1}));const r=this.editor.rootContainer,i=()=>{const s=r.getBoundingClientRect(),l=s.top<0?12:s.top+12,c=s.right-this.root.clientWidth-12;return new DOMRect(c,l,0,0)};this.dialog.show(r,{getReferenceClientRect:i}),setTimeout(()=>{this.components.findInput.focus(),this.components.findInput.select()},300)}hide(){var t;(t=this.dialog)==null||t.close(),Fh(this.editor)}isVisible(){return this.dialog&&this.dialog.isVisible}research(){this.oldText="",this.doSearch({keepReplaceResult:!0,gotoFirstSearchResult:!1})}destroy(){var t;(t=this.dialog)==null||t.destroy()}}const lO={find:{findLabel:"\u67E5\u627E:",replaceLabel:"\u66FF\u6362:",findButton:"\u67E5\u627E",replaceButton:"\u66FF\u6362",replaceAllButton:"\u5168\u90E8\u66FF\u6362",moreButton:"",findPlaceholder:"\u5728\u6587\u6863\u5185\u67E5\u627E",replacePlaceholder:"\u66FF\u6362\u4E3A"}},cO={find:{findLabel:"Find:",replaceLabel:"Replace:",findButton:"Find",replaceButton:"Replace",replaceAllButton:"Replace All",moreButton:"",findPlaceholder:"Find text in document",replacePlaceholder:"Replace to"}};S.mergeLang({"zh-CN":lO,"en-US":cO});function c3(n){return n.addCustom("find-dialog",()=>new sO(n)).show(),!0}const a3={"CtrlOrCmd+F":c3},GF="";function aO(n){c3(n)}function zh(n,t){return t.map(e=>{var i,s;const o=kt(n,e),r=(i=o.getBlockProperties)==null?void 0:i.call(o,n,e);return(s=r==null?void 0:r.abstract)!=null?s:""}).join(" ")}function ra(n){const{editor:t,commentGroupId:e,abstract:o="text"}=n,r=N(),i=t.doc.getUser(),s=Date.now(),l=e!=null?e:r;return{id:r,groupId:l,userId:i.userId,displayName:i.displayName,avatarUrl:i.avatarUrl,abstract:o,created:s,modified:s}}function d3(n,t,e){const o=e.id,i=n.getBlockData(t).comments;let s;i?s=[...i,o]:s=[o];const l={comments:s};n.updateBlockData(t,l)}function ia(n,t,e){const o=zh(n,[t]),r=ra({editor:n,abstract:o});d3(n,t,r);const i=oo();return e.localCreateComment(r,i),r}const dO=y("standard-block-actions");class uO{constructor(t,e){h(this,"executeCommand",(t,e,o)=>{const r=o.data;try{this.editorComments.showCommentList();const i=t.getBlockById(r);ia(t,i,this.provider)}catch(i){dO.error(`failed to execute block command: ${JSON.stringify(i)}`)}});this.provider=t,this.editorComments=e}commands(t,e){return{group:"block-comment-actions",commands:[{id:"comment",name:"Add comment",data:G(e),order:100}],executeCommand:this.executeCommand}}}function hO(n,t){let e=t.clientX;const o=t.clientY,r=n.rootContainer.getBoundingClientRect().right;if(e<r-100||e>r+100)return null;const i=t.target;if(i&&i instanceof Element){const l=z(i);if(l&&vt(n.rootContainer,l))return l}e>r&&(e=r-100);const s=document.elementFromPoint(e,o);if(s){const l=z(s);if(l&&vt(n.rootContainer,l))return l}return null}const{t:fO}=S;class mO{constructor(t,e,o){h(this,"buttonElement");h(this,"currentBlockId","");h(this,"handleDocumentMouseMove",t=>{const e=hO(this.editor,t);if(!e){this.buttonElement.parentElement&&this.buttonElement.remove();return}const o=ul(e);if(this.editor.getBlockIndex(o)===0&&this.editor.getBlockData(o).heading===1)return;this.updateButton(o),At(e).appendChild(this.buttonElement)});h(this,"handleButtonClick",t=>{if(!this.currentBlockId)return;const e=this.editor.getBlockById(this.currentBlockId);ia(this.editor,e,this.commentProvider),this.editorComments.showCommentList()});this.editor=t,this.commentProvider=e,this.editorComments=o,this.buttonElement=this.createButton(),document.addEventListener("mousemove",this.handleDocumentMouseMove),this.buttonElement.addEventListener("click",this.handleButtonClick)}destroy(){document.removeEventListener("mousemove",this.handleDocumentMouseMove),this.buttonElement.removeEventListener("click",this.handleButtonClick)}createButton(){const t=kn("block-comment-button",fO("comment.comment"),$r,void 0,this.editor.clientId);return t.classList.add("block-comment-button"),t}updateButton(t){wt(this.editor,t)||(this.currentBlockId=G(t))}}var mt=(n=>(n.SwitchUp="switch-up",n.SwitchDown="switch-down",n.CommentItemReply="comment-item-reply",n.CommentItemMore="comment-item-more",n.CommentItemOk="comment-item-ok",n.CommentItemCancel="comment-item-cancel",n.CommentItemDelete="comment-item-delete",n.CommentItemEdit="comment-item-edit",n.QuickReply="quick-reply",n.QuickReplyOk="quick-reply-ok",n.QuickReplyCancel="quick-reply-cancel",n))(mt||{});const Vh="group-item-action",u3="last-comment-item",Yn="disabled",h3=500;function rr(n){return n.id!==n.groupId}function f3(n,t=".comment-item-root"){return n.querySelectorAll(t).length}function gO(n){const t=n.closest(".comment-item-root");return t?t.id:null}function Qn(n,t){n.setAttribute(Vh,t)}function pO(n){return n.closest(`[${Vh}]`)}function CO(n){var t;return(t=n.getAttribute(Vh))!=null?t:""}function bO(n){return lt(n,Yn)}function m3(n,t){const e=n.rootContainer.querySelector(`[comment-${t.toLocaleLowerCase()}=${t}`);if(!e)return null;const o=e.closest('[data-type="editor-block"]');return o?o.id:null}function g3(n){return Array.from(n.attributes).map(e=>e.name).filter(e=>e.startsWith("comment-")).map(e=>e.replace("comment-",""))}const p3=y("doc-comments");function C3(n,t,e,o){if(t.comments){const i=t.comments;Array.isArray(i)&&i.forEach(s=>{o.has(s)||(o.add(s),e.push(s))})}t.text&&t.text.forEach(s=>{if(s.attributes){const l="comment-";Object.entries(s.attributes).forEach(([c,a])=>{if(c.startsWith(l)){const u=a;o.has(u)||(o.add(u),e.push(u))}})}});const r=t.children;!r||r.forEach(i=>{n.blocks[i].forEach(l=>{C3(n,l,e,o)})})}function vO(n){const t=[],e=new Set;n.blocks.root.forEach(r=>{C3(n,r,t,e)});const o=new Map;return t.forEach((r,i)=>o.set(r,i)),o}function kO(n){const t=new Map;n.forEach(r=>{if(rr(r)){const i=t.get(r.groupId);i?i.push(r):t.set(r.groupId,[r])}});const e=[];return n.forEach(r=>{var i;if(!rr(r)){const s=(i=t.get(r.id))!=null?i:[];t.delete(r.id);const l={...r,children:s};e.push(l)}}),Array.from(t.values()).forEach(r=>{const i=r[0],s=r.slice(1),l={...i,children:s};e.push(l)}),e}function Co(n,t){const e=n.doc.toJSON(),o=vO(e);return kO(t.getComments()).filter(s=>o.has(s.groupId)).sort((s,l)=>{const c=o.get(s.groupId),a=o.get(l.groupId);return d(p3,c!==void 0,`comment not exists in doc, ${s.groupId}`),d(p3,a!==void 0,`comment not exists in doc, ${l.groupId}`),c-a})}function Uh(n){const{children:t,...e}=n,o=[e];return t.forEach(r=>{o.push(r)}),o}function yO(n,t){return Co(n,t).map(Uh).reduce((r,i)=>i.length+r,0)}function qh(n,t){const e=[],o=n.getBlockById(t.blockId);if(j(n,o)){const i=t.blockId,s=t.offset,l=n.getBlockById(i),c=n.getBlockText(l),a=Bl(c,s);a&&Object.entries(a).forEach(([u,f])=>{u.startsWith("comment-")&&e.push(f)})}const r=o.attributes;for(let i=0;i<r.length;i++){const s=r[i];s.name.startsWith("comment-")&&e.push(s.value)}return e}function wO(n){const t=n.selection.range;if(!t.isSimple())return[];if(t.start.blockId!==t.end.blockId)return[];if(t.isCollapsed())return qh(n,t.start);const{start:e,end:o}=t,r=qh(n,e),i=qh(n,o);return Fa.default(r,i)}function b3(n,t){n.rootContainer.querySelectorAll(`span.text.comment[comment-${t}],[data-type=editor-block].comment[comment-${t}]`).forEach(o=>{F(o,"active")})}function v3(n,t){const e=n.rootContainer.querySelector("span.text.comment.active,[data-type=editor-block].comment.active");if(!t)e&&g3(e).forEach(r=>b3(n,r));else{const o=t.toLocaleLowerCase();if(e){const i=g3(e);if(i.length===1&&i[0]===o)return;i.forEach(s=>b3(n,s))}const r=n.rootContainer.querySelectorAll(`span.text.comment[comment-${o}],[data-type=editor-block].comment[comment-${o}]`);if(r){r.forEach(s=>{M(s,"active")});const i=r[0];Ei(i)}}}const ZF="";y("comment-editor");const{t:BO}=S,Wh="comment-editor-readonly",As="comment-editor-editing";class Gh{constructor(t,e,o){h(this,"root");h(this,"components");h(this,"handleEditorBlur",()=>{this.inactiveEditor()});h(this,"handleEditorFocus",()=>{this.editor.readonly||this.activeEditor()});h(this,"activeEditor",()=>{lt(this.root,As)||M(this.root,As)});h(this,"inactiveEditor",()=>{F(this.root,As)});h(this,"handleInsertImg",async()=>{const{editor:t}=this.components,e=V(t.rootContainer),o=await fr("image/*",{}),r={src:"",widthPercent:50},i={id:N(),type:"embed",embedType:"image",embedData:r},s=t.options.componentsOptions.image;s!=null&&s.defaultAlign&&(i.align=s.defaultAlign);const l=t.getFocusedBlock(),c=t.getBlockIndex(l),a=t.insertBlock(e,c+1,i);Ft.getImageObject(t,a).replaceImage(0,o)});h(this,"handleReadonlyChange",t=>{t.readonly?(F(this.root,As),M(this.root,Wh)):(M(this.root,As),F(this.root,Wh))});h(this,"setDoc",t=>{const{components:{editor:e}}=this;e.doc.externalDoc.setDoc(t)});h(this,"getDoc",()=>{const{components:{editor:t}}=this;return t.doc.toJSON()});h(this,"isEmpty",()=>xl(this.getDoc()));h(this,"edit",()=>{const{editor:t}=this.components;t.readonly=!1,S2(t),this.activeEditor()});h(this,"clear",()=>{const t=oo();this.setDoc(t)});h(this,"readonly",()=>{const{editor:t}=this.components;t.readonly=!0});h(this,"destroy",()=>{const{root:t,components:{editor:e,insertImgButton:o}}=this;o.onclick=null,e.destroy(),t.remove()});this.mainEditor=t,this.commentsProvider=e,this.doc=o,this.root=b("div",["comment-editor",Wh],null),this.components=this.createEditor()}createEditor(){const t=b("div",["comment-editor-root"],this.root),{commentsProvider:e,mainEditor:o}=this,r=e.createCommentEditor(t,new Id(this.doc));r.readonly=!0,r.addListener("readonlyChanged",this.handleReadonlyChange),r.addListener("focus",this.handleEditorFocus),r.addListener("blur",this.handleEditorBlur);const i=Xo(this.root,"comment-editor-img",BO("comment.image"),I5,void 0,o.clientId);return i.classList.add("comment-editor-img"),i.onclick=this.handleInsertImg,{editor:r,insertImgButton:i}}get editor(){return this.components.editor}}class EO{constructor(t){h(this,"handleBeforeKeyDown",(t,e)=>{if(_n(e,"Enter")){const{quickReply:o,updateLastCommentItem:r}=this.groupItem;return o.getReplyEditor().isEmpty()?(o.hideReplyEditor(),!0):(o.reply(),r(),!0)}return!1});this.groupItem=t}}class IO{constructor(t,e,o){h(this,"handleBeforeKeyDown",(t,e)=>{if(_n(e,"Enter")){const{quickReply:o}=this.groupItem,{comment:r,getCommentEditor:i}=this.commentItem,s=i();if(s.isEmpty())this.commentsProvider.localDeleteComment(r.id);else{const l=s.getDoc();this.commentsProvider.localUpdateComment(r,l),s.readonly()}return o.show(),!0}return!1});this.commentsProvider=t,this.groupItem=e,this.commentItem=o}}const xO=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
636
+ `).map(c=>{const a={id:N(),type:"text"};if(PA(c))return a.text=$A(c),a;const u=c?[_e(c,null)]:[];return a.text=u,a})},meta:{},comments:{}};o["text/plain"]=l}return o}}function jA(n){const t=[];for(let e=0;e<n.length;e++){const o=n[e];o.type.toLocaleLowerCase().startsWith("image/")&&t.push(o)}return t}class t3{constructor(t){t.dataConverter.addConverter(new _A),t.dataConverter.addConverter(new HA),t.dataConverter.addConverter(new NA)}async handleBeforePaste(t,e,o){const r=e.clipboardData;if(r){const i=jA(r.files);if(i.length>0&&!o["text/office-html"])return await this.handleInsertImages(t,i),!0}return!1}async handleInsertImages(t,e){const o=t.selection.focusedBlock,r=H(o),i=K(o),s=U(r);let l=i;wt(t,o)||(l+=1);for(let c=0;c<e.length;c++){const a=e[c],u=await tg(t,"image",s,l+c,{file:a});u&&eg(t,u,"image",{id:"replace-image",name:"Replace image",data:{block:u,image:a}})}}}function e3(n){return It.isSafari&&!!n&&Date.now()-n<100}const n3=y("highlight-data");class ea{constructor(t){h(this,"data",new Map);this.editor=t}add(t,e,o){const r={id:N(),blockId:G(t),oldText:this.editor.getBlockText(t),start:e,end:o};return this.data.set(r.id,r),r}get(t){const e=this.data.get(t);return d(n3,e,`no highligh data: ${t}`),e}remove(t){this.data.delete(t)}clearBlockData(t){Array.from(this.data.values()).forEach(e=>{e.blockId===t&&this.data.delete(e.id)})}destroy(){}static getData(t){return t.addCustom("highligh-data",()=>new ea(t))}}function FA(n,t,e,o,r){const s=ea.getData(n).add(t,e,o);return r.setAttribute("data-highlight-id",s.id),s}function na(n,t){const e=t.getAttribute("data-highlight-id");return d(n3,e,"invalid highlight elem, no id"),ea.getData(n).get(e)}const Ms=y("highligh-dom");function zA(n){return lt(n,"editor-highlight")}function In(n){const t=n.rootContainer.querySelectorAll(".editor-highlight");return Array.from(t)}function UA(n){const t=n.rootContainer.querySelectorAll(".editor-replace-result-highlight");return Array.from(t)}function jh(n){const t=n.querySelectorAll(".editor-highlight");return Array.from(t)}function VA(n){jh(n).forEach(t=>{t.remove()})}function ni(n){return In(n).length}function qA(n,t){d(Ms,t>=0,`invalid highlight index: ${t}`);const e=In(n);return e.length===0?null:(d(Ms,t<e.length,`invalid highlight index: ${t}/${e.length}`),e[t])}function WA(n,t,{left:e,top:o,width:r,height:i},s){const l=["editor-highlight-child"];s&&l.push("editor-highlight-readonly");const c=b("div",l,n);c.style.top=`${o}px`,c.style.left=`${e}px`,c.style.width=`${r}px`,c.style.height=`${i}px`}function o3(n,t,e,o,r){d(Ms,o>0,`invalid end: ${o}`);const i=At(t),s=t.getBoundingClientRect(),l=Ao(n,t,Ot(n,t,e,o)),a=b("div",[r==="find"?"editor-highlight":"editor-replace-result-highlight"],i);l.forEach(u=>{WA(a,t,{left:u.left-s.left,width:u.width,top:u.top-s.top,height:u.height})}),FA(n,t,e,o,a)}function GA(n,t,e,o){return o3(n,t,e,o,"find")}function r3(n,t,e,o){return o3(n,t,e,o,"replace")}function oa(n,t){In(n).forEach(l=>{lt(l,"active")&&F(l,"active")}),M(t,"active"),d(Ms,t.firstChild instanceof HTMLElement,"invalid highligh dom, invalid elem child");const o=t.firstChild,r=o.getBoundingClientRect(),i=Nn(n.rootContainer);let s=r.y;s===0&&(s=o.getBoundingClientRect().y),Ei(i)}function Rs(n){const t=n.rootContainer.querySelector(".editor-highlight.active");return t||null}function i3(n){return d(Ms,n,"no highlight elem"),lt(n,"editor-highlight-readonly")}const or=y("highligh-text");function ZA(n){UA(n).forEach(e=>{e.remove()})}function Fh(n,t){In(n).forEach(o=>{o.remove()}),t!=null&&t.keepReplaceResult||ZA(n)}function s3(n){const t=Rs(n);if(!t)return-1;const o=In(n).indexOf(t);return d(or,o!==-1,`invalid highlight index: ${o}`),o}function YA(n){const t=In(n);if(t.length===0)return 0;const e=Rs(n);let o=e?t.indexOf(e):-1;!e||o===-1||o===t.length-1?o=0:o+=1;const r=t[o];return oa(n,r),o}function QA(n){const t=In(n);if(t.length===0)return 0;const e=Rs(n);let o=e?t.indexOf(e):-1;!e||o===-1||o===0?o=t.length-1:o-=1;const r=t[o];return oa(n,r),o}function KA(n,t){const e=In(n);e.length>0&&t<e.length&&oa(n,e[t])}function JA(n,t,e){const o=Rs(n);if(!o)return!1;const r=z(o);if(d(or,r,"no parent block"),!n.isBlockWritable(r))return!1;const i=ni(n);let s=s3(n);if(!i3(o)&&n.isBlockWritable(r)){const a=na(n,o),u=n.getBlockText(r),{start:f,end:m}=na(n,o),[C,v]=ne.transformOffset(a.oldText,u,[f,m]),w=pg(u,C,v-C);if(Tt(w).toLowerCase()!==t.toLowerCase())return!1;const E=El(u,C,v,e);n.setBlockText(r,E),VA(r),l3(n,r,t),e&&r3(n,r,C,C+e.length)}const l=ni(n);s>=l?s=0:l>i&&(s+=1);const c=qA(n,s);return c&&oa(n,c),!0}function XA(n,t,e,o){if(!j(n,t)||!n.isBlockWritable(t))return 0;const r=n.getBlockText(t);d(or,r,"no block text");const i={count:0},s=Hg(r,e,o,i);return Tt(r)===Tt(s)?0:(n.setBlockText(t,s),i.count)}function tO(n,t,e){if(d(or,zA(t),"not a highlight elem"),i3(t))return;d(or,e>0,"invalid highlight length");const o=na(n,t),r=z(t);d(or,r,"no parent block"),r3(n,r,o.start,o.start+e)}function eO(n,t){In(n).forEach(o=>{tO(n,o,t)})}function nO(n,t,e){if(n.readonly)return 0;const o=i=>{let s=0;return Rt(i).forEach(c=>{ct(n,c)?Le(n,c).forEach(u=>{s+=o(u)}):s+=XA(n,c,t,e)}),s},r=o(n.rootContainer);return e.length>0&&eO(n,e.length),r}function oO(n){const t=n.selection.range.end,e=n.getBlockById(t.blockId),o=t.isSimple()?t.offset:1,r=jh(e);for(let l=0;l<r.length;l++){const c=r[l],{end:a}=na(n,c);if(a>=o)return c}const i=B1(n,{simpleBlockOnly:!0}),s=i.indexOf(e);if(s===-1)return null;for(let l=s+1;l<i.length;l++){const c=i[l],a=jh(c);if(a.length>0)return a[0]}return null}function rO(n){const t=In(n),e=oO(n);return e?t.indexOf(e):0}function l3(n,t,e){if(!e)return;d(or,j(n,t),"not a text block");const o=n.getBlockText(t),r=$1(o,e);r.length>0&&r.forEach(({start:i,end:s})=>{GA(n,t,i,s)})}function iO(n,t){if(Fh(n),!t)return;B1(n,{simpleBlockOnly:!0}).forEach(o=>{l3(n,o,t)})}class sO{constructor(t){h(this,"dialog",null);h(this,"root");h(this,"oldText","");h(this,"_compositionEndTime",0);h(this,"components");h(this,"handleFindChanged",()=>{this.doSearch({keepReplaceResult:!1,gotoFirstSearchResult:!0})});h(this,"handleCompositionEnd",()=>{this._compositionEndTime=Date.now(),this.handleFindChanged()});h(this,"handleInput",t=>{if(t.isComposing||e3(this._compositionEndTime)){this.doSearch.cancel();return}this.handleFindChanged()});h(this,"handleFind",()=>{this.findNext({keepSearchResult:!1})});h(this,"handleReplace",()=>{const t=this.components.findInput.value;if(!t||!Rs(this.editor))return;const o=this.components.replaceInput.value;if(t===o)return;if(JA(this.editor,t,o)){const i=s3(this.editor),s=ni(this.editor);this.updateSearchStatus(i,s)}this.findNext({keepSearchResult:!0})});h(this,"handleReplaceAll",()=>{const t=this.components.findInput.value;if(!t)return;const e=this.components.replaceInput.value;if(t===e)return;nO(this.editor,t,e)>0&&(this.oldText="",this.doSearchNow({keepReplaceResult:!0,gotoFirstSearchResult:!0}),this.clearFind({keepReplaceResult:!0}))});h(this,"doSearch",ie.default(this.doSearchNow,300));this.editor=t;const e=b("div",["editor-find-dialog"],null),o=b("div",["editor-find-content"],e),r=b("div",["editor-find-dialog-row"],o),i=hr(qd,["editor-find-dialog-button-close"],e),s=b("label",["editor-find-dialog-label"],r,S.t("find.findLabel"));s.htmlFor="";const l=b("div",["editor-find-dialog-input-container"],r),c=b("input",["editor-find-dialog-input"],l);c.type="text",c.placeholder=S.t("find.findPlaceholder");const a=b("div",["editor-find-dialog-status"],l),u=hr(p5,["editor-find-dialog-icon-button"],a),f=b("div",["editor-find-dialog-curr"],a,"0/0"),m=hr(C5,["editor-find-dialog-icon-button"],a);let C;S.t("find.moreButton")?C=b("button",["editor-find-dialog-button"],r,S.t("find.moreButton")):C=hr(Wd,["editor-find-dialog-icon-button-border"],r);const v=b("div",["editor-find-dialog-row"],o),w=b("label",["editor-find-dialog-label"],v,S.t("find.replaceLabel"));w.htmlFor="";const E=b("div",["editor-find-dialog-input-container"],v),L=b("input",["editor-find-dialog-input"],E);L.type="text",L.placeholder=S.t("find.replacePlaceholder");const x=b("div",["editor-find-dialog-row"],o);b("div",["editor-find-dialog-space"],x);const A=b("button",["editor-find-dialog-button"],x,S.t("find.findButton")),O=b("button",["editor-find-dialog-button"],x,S.t("find.replaceButton")),P=b("button",["editor-find-dialog-button"],x,S.t("find.replaceAllButton"));C.onclick=()=>{this.showReplace()},i.onclick=()=>{this.hide()},c.onkeydown=V=>{if(V.isComposing||e3(this._compositionEndTime)){this.doSearch.cancel();return}im(V)?(this.doSearch.cancel(),this.doSearchNow({keepReplaceResult:!1,gotoFirstSearchResult:!0})):Ja(V)&&this.hide()},c.oninput=this.handleInput,c.onpaste=this.handleFindChanged,c.oncut=this.handleFindChanged,c.addEventListener("compositionend",this.handleCompositionEnd),c.maxLength=50,A.onclick=this.handleFind,O.onclick=this.handleReplace,P.onclick=this.handleReplaceAll,L.maxLength=50,m.onclick=()=>{this.gotoNext()},u.onclick=()=>{this.gotoPrev()},this.components={findInput:c,findPrev:u,findCurrent:f,findNext:m,replaceInput:L,findButton:A,replaceButton:O,replaceAllButton:P,closeButton:i,showReplaceButton:C,rowReplace:v,rowActions:x,statusContainer:a},this.root=e}findNext(t){this.doSearch.cancel(),this.doSearchNow({keepReplaceResult:t.keepSearchResult,gotoFirstSearchResult:!0})}doSearchNow(t){const e=this.components.findInput.value;if(e||this.clearFind(t),this.oldText===e){this.gotoNext();return}this.oldText=e,iO(this.editor,e);const o=ni(this.editor),r=rO(this.editor);t.gotoFirstSearchResult&&KA(this.editor,r),this.updateSearchStatus(r,o)}gotoNext(){const t=ni(this.editor),e=YA(this.editor);this.updateSearchStatus(e,t)}gotoPrev(){const t=ni(this.editor),e=QA(this.editor);this.updateSearchStatus(e,t)}updateSearchStatus(t,e){if(this.oldText?this.components.statusContainer.style.display="flex":this.components.statusContainer.style.display="none",e===0)this.components.findCurrent.innerText="0/0",this.components.replaceAllButton.disabled=!0,this.components.replaceButton.disabled=!0,this.components.findButton.disabled=!0;else{this.components.findCurrent.innerText=`${t+1}/${e}`;const o=this.editor.readonly;this.components.replaceAllButton.disabled=o,this.components.replaceButton.disabled=o,this.components.findButton.disabled=!1}}clearFind(t){Fh(this.editor),this.updateSearchStatus(0,0)}showFindOnly(){this.components.rowReplace.style.display="none",this.components.rowActions.style.display="none",this.components.showReplaceButton.style.display="flex"}showReplace(){this.components.rowReplace.style.display="flex",this.components.rowActions.style.display="flex",this.components.showReplaceButton.style.display="none",this.components.replaceInput.focus(),this.components.replaceInput.select()}hideSearchResult(){this.components.statusContainer.style.display="none"}showSearchResult(){this.components.statusContainer.style.display="flex"}show(t){const e=this.editor.getSelectedText();e.length>0&&e.length<50&&(this.components.findInput.value=e),this.root.style.display="flex",t!=null&&t.showFindAndReplace?(this.showReplace(),this.components.findInput.value&&setTimeout(()=>{this.components.replaceInput.focus()})):this.showFindOnly(),this.hideSearchResult(),this.oldText="",this.doSearchNow({keepReplaceResult:!1,gotoFirstSearchResult:!0});const o=this.editor.readonly;this.components.replaceButton.disabled=o,this.components.replaceAllButton.disabled=o,this.components.replaceInput.disabled=o,this.dialog||(this.dialog=new rs(this.root,{disablePageScroll:!1}));const r=this.editor.rootContainer,i=()=>{const s=r.getBoundingClientRect(),l=s.top<0?12:s.top+12,c=s.right-this.root.clientWidth-12;return new DOMRect(c,l,0,0)};this.dialog.show(r,{getReferenceClientRect:i}),setTimeout(()=>{this.components.findInput.focus(),this.components.findInput.select()},300)}hide(){var t;(t=this.dialog)==null||t.close(),Fh(this.editor)}isVisible(){return this.dialog&&this.dialog.isVisible}research(){this.oldText="",this.doSearch({keepReplaceResult:!0,gotoFirstSearchResult:!1})}destroy(){var t;(t=this.dialog)==null||t.destroy()}}const lO={find:{findLabel:"\u67E5\u627E:",replaceLabel:"\u66FF\u6362:",findButton:"\u67E5\u627E",replaceButton:"\u66FF\u6362",replaceAllButton:"\u5168\u90E8\u66FF\u6362",moreButton:"",findPlaceholder:"\u5728\u6587\u6863\u5185\u67E5\u627E",replacePlaceholder:"\u66FF\u6362\u4E3A"}},cO={find:{findLabel:"Find:",replaceLabel:"Replace:",findButton:"Find",replaceButton:"Replace",replaceAllButton:"Replace All",moreButton:"",findPlaceholder:"Find text in document",replacePlaceholder:"Replace to"}};S.mergeLang({"zh-CN":lO,"en-US":cO});function c3(n){return n.addCustom("find-dialog",()=>new sO(n)).show(),!0}const a3={"CtrlOrCmd+F":c3},GF="";function aO(n){c3(n)}function zh(n,t){return t.map(e=>{var i,s;const o=kt(n,e),r=(i=o.getBlockProperties)==null?void 0:i.call(o,n,e);return(s=r==null?void 0:r.abstract)!=null?s:""}).join(" ")}function ra(n){const{editor:t,commentGroupId:e,abstract:o="text"}=n,r=N(),i=t.doc.getUser(),s=Date.now(),l=e!=null?e:r;return{id:r,groupId:l,userId:i.userId,displayName:i.displayName,avatarUrl:i.avatarUrl,abstract:o,created:s,modified:s}}function d3(n,t,e){const o=e.id,i=n.getBlockData(t).comments;let s;i?s=[...i,o]:s=[o];const l={comments:s};n.updateBlockData(t,l)}function ia(n,t,e){const o=zh(n,[t]),r=ra({editor:n,abstract:o});d3(n,t,r);const i=oo();return e.localCreateComment(r,i),r}const dO=y("standard-block-actions");class uO{constructor(t,e){h(this,"executeCommand",(t,e,o)=>{const r=o.data;try{this.editorComments.showCommentList();const i=t.getBlockById(r);ia(t,i,this.provider)}catch(i){dO.error(`failed to execute block command: ${JSON.stringify(i)}`)}});this.provider=t,this.editorComments=e}commands(t,e){return{group:"block-comment-actions",commands:[{id:"comment",name:"Add comment",data:G(e),order:100}],executeCommand:this.executeCommand}}}function hO(n,t){let e=t.clientX;const o=t.clientY,r=n.rootContainer.getBoundingClientRect().right;if(e<r-100||e>r+100)return null;const i=t.target;if(i&&i instanceof Element){const l=z(i);if(l&&vt(n.rootContainer,l))return l}e>r&&(e=r-100);const s=document.elementFromPoint(e,o);if(s){const l=z(s);if(l&&vt(n.rootContainer,l))return l}return null}const{t:fO}=S;class mO{constructor(t,e,o){h(this,"buttonElement");h(this,"currentBlockId","");h(this,"handleDocumentMouseMove",t=>{const e=hO(this.editor,t);if(!e){this.buttonElement.parentElement&&this.buttonElement.remove();return}const o=ul(e);if(this.editor.getBlockIndex(o)===0&&this.editor.getBlockData(o).heading===1)return;this.updateButton(o),At(e).appendChild(this.buttonElement)});h(this,"handleButtonClick",t=>{if(!this.currentBlockId)return;const e=this.editor.getBlockById(this.currentBlockId);ia(this.editor,e,this.commentProvider),this.editorComments.showCommentList()});this.editor=t,this.commentProvider=e,this.editorComments=o,this.buttonElement=this.createButton(),document.addEventListener("mousemove",this.handleDocumentMouseMove),this.buttonElement.addEventListener("click",this.handleButtonClick)}destroy(){document.removeEventListener("mousemove",this.handleDocumentMouseMove),this.buttonElement.removeEventListener("click",this.handleButtonClick)}createButton(){const t=kn("block-comment-button",fO("comment.comment"),$r,void 0,this.editor.clientId);return t.classList.add("block-comment-button"),t}updateButton(t){wt(this.editor,t)||(this.currentBlockId=G(t))}}var mt=(n=>(n.SwitchUp="switch-up",n.SwitchDown="switch-down",n.CommentItemReply="comment-item-reply",n.CommentItemMore="comment-item-more",n.CommentItemOk="comment-item-ok",n.CommentItemCancel="comment-item-cancel",n.CommentItemDelete="comment-item-delete",n.CommentItemEdit="comment-item-edit",n.QuickReply="quick-reply",n.QuickReplyOk="quick-reply-ok",n.QuickReplyCancel="quick-reply-cancel",n))(mt||{});const Uh="group-item-action",u3="last-comment-item",Yn="disabled",h3=500;function rr(n){return n.id!==n.groupId}function f3(n,t=".comment-item-root"){return n.querySelectorAll(t).length}function gO(n){const t=n.closest(".comment-item-root");return t?t.id:null}function Qn(n,t){n.setAttribute(Uh,t)}function pO(n){return n.closest(`[${Uh}]`)}function CO(n){var t;return(t=n.getAttribute(Uh))!=null?t:""}function bO(n){return lt(n,Yn)}function m3(n,t){const e=n.rootContainer.querySelector(`[comment-${t.toLocaleLowerCase()}=${t}`);if(!e)return null;const o=e.closest('[data-type="editor-block"]');return o?o.id:null}function g3(n){return Array.from(n.attributes).map(e=>e.name).filter(e=>e.startsWith("comment-")).map(e=>e.replace("comment-",""))}const p3=y("doc-comments");function C3(n,t,e,o){if(t.comments){const i=t.comments;Array.isArray(i)&&i.forEach(s=>{o.has(s)||(o.add(s),e.push(s))})}t.text&&t.text.forEach(s=>{if(s.attributes){const l="comment-";Object.entries(s.attributes).forEach(([c,a])=>{if(c.startsWith(l)){const u=a;o.has(u)||(o.add(u),e.push(u))}})}});const r=t.children;!r||r.forEach(i=>{n.blocks[i].forEach(l=>{C3(n,l,e,o)})})}function vO(n){const t=[],e=new Set;n.blocks.root.forEach(r=>{C3(n,r,t,e)});const o=new Map;return t.forEach((r,i)=>o.set(r,i)),o}function kO(n){const t=new Map;n.forEach(r=>{if(rr(r)){const i=t.get(r.groupId);i?i.push(r):t.set(r.groupId,[r])}});const e=[];return n.forEach(r=>{var i;if(!rr(r)){const s=(i=t.get(r.id))!=null?i:[];t.delete(r.id);const l={...r,children:s};e.push(l)}}),Array.from(t.values()).forEach(r=>{const i=r[0],s=r.slice(1),l={...i,children:s};e.push(l)}),e}function Co(n,t){const e=n.doc.toJSON(),o=vO(e);return kO(t.getComments()).filter(s=>o.has(s.groupId)).sort((s,l)=>{const c=o.get(s.groupId),a=o.get(l.groupId);return d(p3,c!==void 0,`comment not exists in doc, ${s.groupId}`),d(p3,a!==void 0,`comment not exists in doc, ${l.groupId}`),c-a})}function Vh(n){const{children:t,...e}=n,o=[e];return t.forEach(r=>{o.push(r)}),o}function yO(n,t){return Co(n,t).map(Vh).reduce((r,i)=>i.length+r,0)}function qh(n,t){const e=[],o=n.getBlockById(t.blockId);if(j(n,o)){const i=t.blockId,s=t.offset,l=n.getBlockById(i),c=n.getBlockText(l),a=Bl(c,s);a&&Object.entries(a).forEach(([u,f])=>{u.startsWith("comment-")&&e.push(f)})}const r=o.attributes;for(let i=0;i<r.length;i++){const s=r[i];s.name.startsWith("comment-")&&e.push(s.value)}return e}function wO(n){const t=n.selection.range;if(!t.isSimple())return[];if(t.start.blockId!==t.end.blockId)return[];if(t.isCollapsed())return qh(n,t.start);const{start:e,end:o}=t,r=qh(n,e),i=qh(n,o);return Fa.default(r,i)}function b3(n,t){n.rootContainer.querySelectorAll(`span.text.comment[comment-${t}],[data-type=editor-block].comment[comment-${t}]`).forEach(o=>{F(o,"active")})}function v3(n,t){const e=n.rootContainer.querySelector("span.text.comment.active,[data-type=editor-block].comment.active");if(!t)e&&g3(e).forEach(r=>b3(n,r));else{const o=t.toLocaleLowerCase();if(e){const i=g3(e);if(i.length===1&&i[0]===o)return;i.forEach(s=>b3(n,s))}const r=n.rootContainer.querySelectorAll(`span.text.comment[comment-${o}],[data-type=editor-block].comment[comment-${o}]`);if(r){r.forEach(s=>{M(s,"active")});const i=r[0];Ei(i)}}}const ZF="";y("comment-editor");const{t:BO}=S,Wh="comment-editor-readonly",As="comment-editor-editing";class Gh{constructor(t,e,o){h(this,"root");h(this,"components");h(this,"handleEditorBlur",()=>{this.inactiveEditor()});h(this,"handleEditorFocus",()=>{this.editor.readonly||this.activeEditor()});h(this,"activeEditor",()=>{lt(this.root,As)||M(this.root,As)});h(this,"inactiveEditor",()=>{F(this.root,As)});h(this,"handleInsertImg",async()=>{const{editor:t}=this.components,e=U(t.rootContainer),o=await fr("image/*",{}),r={src:"",widthPercent:50},i={id:N(),type:"embed",embedType:"image",embedData:r},s=t.options.componentsOptions.image;s!=null&&s.defaultAlign&&(i.align=s.defaultAlign);const l=t.getFocusedBlock(),c=t.getBlockIndex(l),a=t.insertBlock(e,c+1,i);Ft.getImageObject(t,a).replaceImage(0,o)});h(this,"handleReadonlyChange",t=>{t.readonly?(F(this.root,As),M(this.root,Wh)):(M(this.root,As),F(this.root,Wh))});h(this,"setDoc",t=>{const{components:{editor:e}}=this;e.doc.externalDoc.setDoc(t)});h(this,"getDoc",()=>{const{components:{editor:t}}=this;return t.doc.toJSON()});h(this,"isEmpty",()=>xl(this.getDoc()));h(this,"edit",()=>{const{editor:t}=this.components;t.readonly=!1,S2(t),this.activeEditor()});h(this,"clear",()=>{const t=oo();this.setDoc(t)});h(this,"readonly",()=>{const{editor:t}=this.components;t.readonly=!0});h(this,"destroy",()=>{const{root:t,components:{editor:e,insertImgButton:o}}=this;o.onclick=null,e.destroy(),t.remove()});this.mainEditor=t,this.commentsProvider=e,this.doc=o,this.root=b("div",["comment-editor",Wh],null),this.components=this.createEditor()}createEditor(){const t=b("div",["comment-editor-root"],this.root),{commentsProvider:e,mainEditor:o}=this,r=e.createCommentEditor(t,new Id(this.doc));r.readonly=!0,r.addListener("readonlyChanged",this.handleReadonlyChange),r.addListener("focus",this.handleEditorFocus),r.addListener("blur",this.handleEditorBlur);const i=Xo(this.root,"comment-editor-img",BO("comment.image"),I5,void 0,o.clientId);return i.classList.add("comment-editor-img"),i.onclick=this.handleInsertImg,{editor:r,insertImgButton:i}}get editor(){return this.components.editor}}class EO{constructor(t){h(this,"handleBeforeKeyDown",(t,e)=>{if(_n(e,"Enter")){const{quickReply:o,updateLastCommentItem:r}=this.groupItem;return o.getReplyEditor().isEmpty()?(o.hideReplyEditor(),!0):(o.reply(),r(),!0)}return!1});this.groupItem=t}}class IO{constructor(t,e,o){h(this,"handleBeforeKeyDown",(t,e)=>{if(_n(e,"Enter")){const{quickReply:o}=this.groupItem,{comment:r,getCommentEditor:i}=this.commentItem,s=i();if(s.isEmpty())this.commentsProvider.localDeleteComment(r.id);else{const l=s.getDoc();this.commentsProvider.localUpdateComment(r,l),s.readonly()}return o.show(),!0}return!1});this.commentsProvider=t,this.groupItem=e,this.commentItem=o}}const xO=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
637
637
  <path fill-rule="evenodd" clip-rule="evenodd" d="M3.65499 6.6665C3.09433 6.6665 2.66699 7.1275 2.66699 7.67617C2.66699 8.2255 3.02633 8.64284 3.65499 8.6645C4.23833 8.6645 4.66399 8.26917 4.66399 7.67617C4.66399 7.1275 4.23899 6.6665 3.65499 6.6665ZM12.9883 6.6665C12.4277 6.6665 12.0003 7.1275 12.0003 7.67617C12.0003 8.2255 12.3597 8.64284 12.9883 8.6645C13.5717 8.6645 13.9973 8.26917 13.9973 7.67617C13.9973 7.1275 13.5723 6.6665 12.9883 6.6665ZM8.32166 6.6665C7.76099 6.6665 7.33399 7.1275 7.33399 7.67617C7.33399 8.2255 7.69299 8.64284 8.32166 8.6645C8.90499 8.6645 9.33066 8.26917 9.33066 7.67617C9.33066 7.1275 8.90566 6.6665 8.32166 6.6665Z" fill="currentColor"></path>
638
638
  </svg>`,SO=`<svg
639
639
  fill="currentColor"
640
640
  width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
641
641
  <path fill-rule="evenodd" clip-rule="evenodd" d="M8.63999 19.5893C8.82172 19.5893 8.9891 19.5427 9.14214 19.4494C9.29518 19.3561 9.48169 19.2115 9.70168 19.0154L12.0403 16.9422H16.2512C16.9255 16.9422 17.497 16.8191 17.9657 16.5728C18.4343 16.3265 18.7906 15.969 19.0345 15.5003C19.2784 15.0317 19.4004 14.4626 19.4004 13.793V8.55629C19.4004 7.88675 19.2784 7.31765 19.0345 6.84897C18.7906 6.38029 18.4343 6.02161 17.9657 5.77293C17.497 5.52424 16.9255 5.3999 16.2512 5.3999H7.5496C6.88007 5.3999 6.31096 5.52305 5.84228 5.76934C5.37361 6.01564 5.01612 6.37432 4.76983 6.84538C4.52354 7.31645 4.40039 7.88675 4.40039 8.55629V13.793C4.40039 14.4626 4.52354 15.0329 4.76983 15.5039C5.01612 15.975 5.37241 16.3325 5.8387 16.5764C6.30498 16.8203 6.86811 16.9422 7.52808 16.9422H7.82937V18.6639C7.82937 18.9461 7.89991 19.1708 8.04099 19.3382C8.18207 19.5056 8.38174 19.5893 8.63999 19.5893ZM8.94845 18.1976V16.2536C8.94845 16.0623 8.90541 15.9248 8.81933 15.8411C8.73325 15.7574 8.59695 15.7155 8.41043 15.7155H7.5783C6.91832 15.7155 6.42932 15.5505 6.11129 15.2206C5.79326 14.8906 5.63425 14.4076 5.63425 13.7715V8.57781C5.63425 7.94175 5.79326 7.45992 6.11129 7.13233C6.42932 6.80473 6.91832 6.64094 7.5783 6.64094H16.2225C16.8825 6.64094 17.3715 6.80473 17.6895 7.13233C18.0075 7.45992 18.1665 7.94175 18.1665 8.57781V13.7715C18.1665 14.4076 18.0075 14.8906 17.6895 15.2206C17.3715 15.5505 16.8825 15.7155 16.2225 15.7155H11.9757C11.7749 15.7155 11.6146 15.7383 11.4951 15.7837C11.3755 15.8291 11.2464 15.9212 11.1077 16.0599L8.94845 18.1976ZM15.584 9.23419C15.5027 9.3131 15.4047 9.35256 15.2899 9.35256H8.42478C8.31479 9.35256 8.22033 9.3131 8.14142 9.23419C8.06251 9.15528 8.02306 9.05844 8.02306 8.94366C8.02306 8.83367 8.06251 8.73802 8.14142 8.65672C8.22033 8.57542 8.31479 8.53477 8.42478 8.53477H15.2899C15.4047 8.53477 15.5027 8.57542 15.584 8.65672C15.6653 8.73802 15.706 8.83367 15.706 8.94366C15.706 9.05844 15.6653 9.15528 15.584 9.23419ZM15.2899 11.5333C15.4047 11.5333 15.5027 11.4939 15.584 11.415C15.6653 11.3361 15.706 11.2392 15.706 11.1244C15.706 11.0097 15.6653 10.9116 15.584 10.8303C15.5027 10.749 15.4047 10.7084 15.2899 10.7084H8.42478C8.31479 10.7084 8.22033 10.749 8.14142 10.8303C8.06251 10.9116 8.02306 11.0097 8.02306 11.1244C8.02306 11.2392 8.06251 11.3361 8.14142 11.415C8.22033 11.4939 8.31479 11.5333 8.42478 11.5333H15.2899ZM13.1845 13.5957C13.1056 13.6747 13.0111 13.7141 12.9011 13.7141H8.42478C8.31479 13.7141 8.22033 13.6747 8.14142 13.5957C8.06251 13.5168 8.02306 13.4224 8.02306 13.3124C8.02306 13.1928 8.06251 13.0924 8.14142 13.0111C8.22033 12.9298 8.31479 12.8891 8.42478 12.8891H12.9011C13.0111 12.8891 13.1056 12.9298 13.1845 13.0111C13.2634 13.0924 13.3028 13.1928 13.3028 13.3124C13.3028 13.4224 13.2634 13.5168 13.1845 13.5957Z"></path>
642
- </svg>`,YF="";y("comment-item");const{t:oi}=S,k3="comment-item-editing",y3="active";class w3{constructor(t){h(this,"root");h(this,"moreMenu");h(this,"components");h(this,"createRoot",()=>{const t=b("div",["comment-item-root"],null);return t.id=this.comment.id,t});h(this,"handleMore",()=>{const{moreButton:t}=this.components;!t||this.moreMenu.manualShow(t,{placement:"bottom-start"})});h(this,"handleMoreMenuItemShow",()=>{const{headTools:t}=this.components;t.classList.add(y3)});h(this,"handleMoreMenuItemClose",()=>{const{headTools:t}=this.components;t.classList.remove(y3)});h(this,"handleMoreMenuItemClick",(t,e)=>{const o=this.options.groupList.groupItemHandlers,{id:r}=e;r==="edit"&&o.handleCommentItemEdit(this),r==="delete"&&o.handleCommentItemDelete(this)});h(this,"handleEditorReadonlyChange",t=>{const{components:{actions:e},root:o}=this;t.readonly?(o.classList.remove(k3),e.classList.add("hidden")):(o.classList.add(k3),e.classList.remove("hidden"))});h(this,"handleFocus",()=>{const{components:{commentEditor:t,okButton:e}}=this;t.isEmpty()?M(e,Yn):F(e,Yn)});h(this,"handleDocChanged",()=>{const{commentEditor:t,okButton:e}=this.components;t.isEmpty()?M(e,Yn):F(e,Yn)});h(this,"getCommentEditor",()=>this.components.commentEditor);this.options=t,this.root=this.createRoot(),this.components=this.createItem(),this.moreMenu=this.createMoreMenu()}get commentOptions(){return this.options.mainEditor.getComponentOptions("comment")}get comment(){return this.options.comment}get doc(){const{comment:t,commentsProvider:e}=this.options;return e.getCommentDoc(t.id)}createMoreMenu(){const t=new Wo([{id:"edit",name:oi("comment.edit")},{id:"delete",name:oi("comment.delete")}]);return t.on("click",this.handleMoreMenuItemClick),t.on("close",this.handleMoreMenuItemClose),t.on("show",this.handleMoreMenuItemShow),t}createItem(){var tt,ot;const{comment:t,commentsProvider:e,mainEditor:o,groupItem:r}=this.options,s=e.getAuth().userId===t.userId?"w":"r",l=!((tt=this.commentOptions)!=null&&tt.disableReply),a=!((ot=this.commentOptions)!=null&&ot.disableEdit)&&s==="w"&&l,u=b("div",["item-head"],this.root),f=b("img",["item-head-avatar"],u);f.src=t.avatarUrl;const m=b("span",["item-head-username"],u);m.innerText=t.displayName;const C=b("span",["item-head-modified"],u),v=new Date(t.modified);C.innerText=r1(v);const w=b("div",["item-head-tools"],u);let E=null;l&&(E=Xo(w,mt.CommentItemReply,oi("comment.reply"),SO,void 0,o.clientId),Qn(E,mt.CommentItemReply));let L=null;a&&(L=Xo(w,mt.CommentItemMore,oi("comment.more"),xO,void 0,o.clientId),Qn(L,mt.CommentItemMore),L.onclick=this.handleMore);const x=b("div",["item-editor"],this.root),A=new Gh(o,e,this.doc);A.editor.addListener("readonlyChanged",this.handleEditorReadonlyChange),A.editor.addListener("docChanged",this.handleDocChanged),A.editor.addListener("focus",this.handleFocus),A.editor.input.addHandler(new IO(e,r,this)),x.append(A.root);const O=b("div",["item-actions","hidden"],this.root),P=kn(mt.CommentItemCancel,oi("common.cancel"));Qn(P,mt.CommentItemCancel);const U=kn(mt.CommentItemOk,oi("comment.send"));return Qn(U,mt.CommentItemOk),O.append(P,U),{head:u,replyButton:E,moreButton:L,commentEditor:A,okButton:U,cancelButton:P,actions:O,headTools:w}}reloadDoc(){const{components:{commentEditor:t}}=this;t.setDoc(this.doc)}edit(){const{components:{commentEditor:t}}=this;t.edit()}destroy(){const{replyButton:t,moreButton:e,commentEditor:o,okButton:r,cancelButton:i}=this.components;e&&(e.onclick=null),t&&(t.onclick=null),r.onclick=null,i.onclick=null,o.destroy(),this.moreMenu.removeAllListeners(),this.moreMenu.destroy(),this.root.remove()}}const QF="";class B3{constructor(t,e,o){h(this,"root");h(this,"components");h(this,"reloadDoc",()=>{const{mobileCommentEditor:t}=this.components;t.setDoc(this.doc)});this.editor=t,this.commentsProvider=e,this.comment=o,this.root=b("div",["mobile-comment-item"],null),this.components=this.createItem()}get doc(){const{comment:t,commentsProvider:e}=this;return e.getCommentDoc(t.id)}createItem(){const{comment:t,editor:e,commentsProvider:o}=this,r=b("div",["item-head"],this.root),i=b("img",["item-head-avatar"],r);i.src=t.avatarUrl;const s=b("span",["item-head-username"],r);s.innerText=t.displayName;const l=b("span",["item-head-modified"],r),c=new Date(t.modified);l.innerText=r1(c);const a=b("div",["item-editor"],this.root),u=new Gh(e,o,this.doc);return a.append(u.root),{mobileCommentEditor:u}}destroy(){this.root.remove(),this.components.mobileCommentEditor.destroy()}}const KF="";class TO{constructor(t,e){h(this,"root");h(this,"countElement");h(this,"updateCount",t=>{this.countElement.textContent=`${t}`});this.root=b("div",["mini-comment-item"],e),this.root.id=t,this.countElement=b("span",["mini-comment-item-count"],this.root)}}class Os extends Wt.TypedEmitter{constructor(e,o,r,i,s){super();h(this,"_items");this.editor=e,this.commentsProvider=o,this.container=r,this.options=s,this._items=this.createList(i)}get items(){return this._items}createList(e){return e.map(r=>{const i=this.createItem(r,"init");return this.container.appendChild(i.root),i})}reloadList(e){this.container.innerHTML="",this.createList(e)}insertItem(e){const o=this.findInsertPos(e);if(o===-1)return null;const r=this.createItem(e,"insert");if(o===this.items.length)this.container.appendChild(r.root);else{const i=this.items[o];this.container.insertBefore(r.root,i.root)}return this.items.splice(o,0,r),r}deleteItem(e){const o=this.findItemIndex(e);if(o!==-1){const r=this.items[o];return this.items.splice(o,1),r.destroy(),!0}return!1}findItemIndex(e){return this.items.findIndex(o=>o.comment.id===e)}findItem(e){const o=this.findItemIndex(e);return o===-1?null:this.items[o]}destroy(){this._items.forEach(e=>e.destroy()),this._items=[]}}class DO extends Os{constructor(t){const{editor:e,comments:o,commentsProvider:r,parent:i}=t;super(e,r,i,o,t)}createItem(t){const{editor:e,commentsProvider:o,groupList:r,groupItem:i}=this.options;return new w3({mainEditor:e,commentsProvider:o,comment:t,groupList:r,groupItem:i})}findInsertPos(){return this.items.length}destroy(){this.items.forEach(t=>{t.destroy()})}}const LO=`<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg">
642
+ </svg>`,YF="";y("comment-item");const{t:oi}=S,k3="comment-item-editing",y3="active";class w3{constructor(t){h(this,"root");h(this,"moreMenu");h(this,"components");h(this,"createRoot",()=>{const t=b("div",["comment-item-root"],null);return t.id=this.comment.id,t});h(this,"handleMore",()=>{const{moreButton:t}=this.components;!t||this.moreMenu.manualShow(t,{placement:"bottom-start"})});h(this,"handleMoreMenuItemShow",()=>{const{headTools:t}=this.components;t.classList.add(y3)});h(this,"handleMoreMenuItemClose",()=>{const{headTools:t}=this.components;t.classList.remove(y3)});h(this,"handleMoreMenuItemClick",(t,e)=>{const o=this.options.groupList.groupItemHandlers,{id:r}=e;r==="edit"&&o.handleCommentItemEdit(this),r==="delete"&&o.handleCommentItemDelete(this)});h(this,"handleEditorReadonlyChange",t=>{const{components:{actions:e},root:o}=this;t.readonly?(o.classList.remove(k3),e.classList.add("hidden")):(o.classList.add(k3),e.classList.remove("hidden"))});h(this,"handleFocus",()=>{const{components:{commentEditor:t,okButton:e}}=this;t.isEmpty()?M(e,Yn):F(e,Yn)});h(this,"handleDocChanged",()=>{const{commentEditor:t,okButton:e}=this.components;t.isEmpty()?M(e,Yn):F(e,Yn)});h(this,"getCommentEditor",()=>this.components.commentEditor);this.options=t,this.root=this.createRoot(),this.components=this.createItem(),this.moreMenu=this.createMoreMenu()}get commentOptions(){return this.options.mainEditor.getComponentOptions("comment")}get comment(){return this.options.comment}get doc(){const{comment:t,commentsProvider:e}=this.options;return e.getCommentDoc(t.id)}createMoreMenu(){const t=new Wo([{id:"edit",name:oi("comment.edit")},{id:"delete",name:oi("comment.delete")}]);return t.on("click",this.handleMoreMenuItemClick),t.on("close",this.handleMoreMenuItemClose),t.on("show",this.handleMoreMenuItemShow),t}createItem(){var tt,ot;const{comment:t,commentsProvider:e,mainEditor:o,groupItem:r}=this.options,s=e.getAuth().userId===t.userId?"w":"r",l=!((tt=this.commentOptions)!=null&&tt.disableReply),a=!((ot=this.commentOptions)!=null&&ot.disableEdit)&&s==="w"&&l,u=b("div",["item-head"],this.root),f=b("img",["item-head-avatar"],u);f.src=t.avatarUrl;const m=b("span",["item-head-username"],u);m.innerText=t.displayName;const C=b("span",["item-head-modified"],u),v=new Date(t.modified);C.innerText=r1(v);const w=b("div",["item-head-tools"],u);let E=null;l&&(E=Xo(w,mt.CommentItemReply,oi("comment.reply"),SO,void 0,o.clientId),Qn(E,mt.CommentItemReply));let L=null;a&&(L=Xo(w,mt.CommentItemMore,oi("comment.more"),xO,void 0,o.clientId),Qn(L,mt.CommentItemMore),L.onclick=this.handleMore);const x=b("div",["item-editor"],this.root),A=new Gh(o,e,this.doc);A.editor.addListener("readonlyChanged",this.handleEditorReadonlyChange),A.editor.addListener("docChanged",this.handleDocChanged),A.editor.addListener("focus",this.handleFocus),A.editor.input.addHandler(new IO(e,r,this)),x.append(A.root);const O=b("div",["item-actions","hidden"],this.root),P=kn(mt.CommentItemCancel,oi("common.cancel"));Qn(P,mt.CommentItemCancel);const V=kn(mt.CommentItemOk,oi("comment.send"));return Qn(V,mt.CommentItemOk),O.append(P,V),{head:u,replyButton:E,moreButton:L,commentEditor:A,okButton:V,cancelButton:P,actions:O,headTools:w}}reloadDoc(){const{components:{commentEditor:t}}=this;t.setDoc(this.doc)}edit(){const{components:{commentEditor:t}}=this;t.edit()}destroy(){const{replyButton:t,moreButton:e,commentEditor:o,okButton:r,cancelButton:i}=this.components;e&&(e.onclick=null),t&&(t.onclick=null),r.onclick=null,i.onclick=null,o.destroy(),this.moreMenu.removeAllListeners(),this.moreMenu.destroy(),this.root.remove()}}const QF="";class B3{constructor(t,e,o){h(this,"root");h(this,"components");h(this,"reloadDoc",()=>{const{mobileCommentEditor:t}=this.components;t.setDoc(this.doc)});this.editor=t,this.commentsProvider=e,this.comment=o,this.root=b("div",["mobile-comment-item"],null),this.components=this.createItem()}get doc(){const{comment:t,commentsProvider:e}=this;return e.getCommentDoc(t.id)}createItem(){const{comment:t,editor:e,commentsProvider:o}=this,r=b("div",["item-head"],this.root),i=b("img",["item-head-avatar"],r);i.src=t.avatarUrl;const s=b("span",["item-head-username"],r);s.innerText=t.displayName;const l=b("span",["item-head-modified"],r),c=new Date(t.modified);l.innerText=r1(c);const a=b("div",["item-editor"],this.root),u=new Gh(e,o,this.doc);return a.append(u.root),{mobileCommentEditor:u}}destroy(){this.root.remove(),this.components.mobileCommentEditor.destroy()}}const KF="";class TO{constructor(t,e){h(this,"root");h(this,"countElement");h(this,"updateCount",t=>{this.countElement.textContent=`${t}`});this.root=b("div",["mini-comment-item"],e),this.root.id=t,this.countElement=b("span",["mini-comment-item-count"],this.root)}}class Os extends Wt.TypedEmitter{constructor(e,o,r,i,s){super();h(this,"_items");this.editor=e,this.commentsProvider=o,this.container=r,this.options=s,this._items=this.createList(i)}get items(){return this._items}createList(e){return e.map(r=>{const i=this.createItem(r,"init");return this.container.appendChild(i.root),i})}reloadList(e){this.container.innerHTML="",this.createList(e)}insertItem(e){const o=this.findInsertPos(e);if(o===-1)return null;const r=this.createItem(e,"insert");if(o===this.items.length)this.container.appendChild(r.root);else{const i=this.items[o];this.container.insertBefore(r.root,i.root)}return this.items.splice(o,0,r),r}deleteItem(e){const o=this.findItemIndex(e);if(o!==-1){const r=this.items[o];return this.items.splice(o,1),r.destroy(),!0}return!1}findItemIndex(e){return this.items.findIndex(o=>o.comment.id===e)}findItem(e){const o=this.findItemIndex(e);return o===-1?null:this.items[o]}destroy(){this._items.forEach(e=>e.destroy()),this._items=[]}}class DO extends Os{constructor(t){const{editor:e,comments:o,commentsProvider:r,parent:i}=t;super(e,r,i,o,t)}createItem(t){const{editor:e,commentsProvider:o,groupList:r,groupItem:i}=this.options;return new w3({mainEditor:e,commentsProvider:o,comment:t,groupList:r,groupItem:i})}findInsertPos(){return this.items.length}destroy(){this.items.forEach(t=>{t.destroy()})}}const LO=`<svg width="17" height="16" viewBox="0 0 17 16" fill="none" xmlns="http://www.w3.org/2000/svg">
643
643
  <path d="M2.00218 11.0005L8.00341 4.99923L14.0046 11.0005" stroke="currentColor" fill="transparent" stroke-width="1.5" stroke-linejoin="bevel"/>
644
644
  </svg>`,MO=`<svg width="17" height="16" viewBox="0 0 17 16" xmlns="http://www.w3.org/2000/svg">
645
645
  <path d="M14.0029 4.99933L8.00172 11.0006L2.00049 4.99933" stroke="currentColor" fill="transparent" stroke-width="1.5" stroke-linejoin="bevel"/>
646
- </svg>`,JF="",sa="reply-editor-editing",{t:Zh}=S;class RO{constructor(t,e,o,r){h(this,"root");h(this,"components");h(this,"handleFocus",()=>{const{replyEditor:t,okButton:e}=this.components;t.isEmpty()&&M(e,Yn)});h(this,"handleDocChange",()=>{const{replyEditor:t,okButton:e}=this.components,o=t.getDoc();xl(o)?M(e,Yn):F(e,Yn)});h(this,"getReplyEditor",()=>this.components.replyEditor);h(this,"showReplyEditor",()=>{lt(this.root,sa)||(M(this.root,sa),this.components.replyEditor.edit())});h(this,"hideReplyEditor",()=>{!lt(this.root,sa)||F(this.root,sa)});h(this,"reply",()=>{const{mainEditor:t,comment:e,components:{replyEditor:o},commentsProvider:r}=this,i=o.getDoc(),s=ra({editor:t,commentGroupId:e.groupId});r.localCreateComment(s,i),this.hideReplyEditor(),o.clear()});h(this,"cancel",()=>{const{replyEditor:t}=this.components;this.hideReplyEditor(),t.clear()});h(this,"hide",()=>{lt(this.root,"hidden")||M(this.root,"hidden")});h(this,"show",()=>{F(this.root,"hidden")});this.mainEditor=t,this.commentsProvider=e,this.comment=o,this.groupItem=r,this.root=b("div",["comment-quick-reply"],null),this.components=this.createQuickReply()}createQuickReply(){const{commentsProvider:t}=this,e=Xo(this.root,mt.QuickReply,Zh("comment.placeholder"));Qn(e,mt.QuickReply),e.classList.add("quick-reply-button");const o=b("div",["quick-reply-editor"],this.root),r=oo(),i=new Gh(this.mainEditor,t,r);i.editor.addListener("docChanged",this.handleDocChange),i.editor.addListener("focus",this.handleFocus),i.editor.input.addHandler(new EO(this.groupItem)),o.append(i.root);const s=b("div",["reply-editor-actions"],o),l=kn(mt.QuickReplyCancel,Zh("common.cancel"));Qn(l,mt.QuickReplyCancel);const c=kn(mt.QuickReplyOk,Zh("comment.send"));return Qn(c,mt.QuickReplyOk),M(c,Yn),s.append(l,c),this.hideReplyEditor(),{replyTextButton:e,replyEditor:i,replyEditorContainer:o,okButton:c}}}const Kn=y("comment-group-item");class AO extends Wt.TypedEmitter{constructor(e,o,r,i){super();h(this,"root");h(this,"header");h(this,"mainItem");h(this,"childrenList");h(this,"resizeObserver");h(this,"quickReply");h(this,"createRoot",()=>b("div",["comment-group-item-root"],null));h(this,"createChildrenList",()=>{const e=b("div",["comment-children-list-container"],this.root);return new DO({editor:this.editor,commentsProvider:this.commentsProvider,comments:this.comment.children,parent:e,groupList:this.groupList,groupItem:this})});h(this,"updateLastCommentItem",()=>{const e=Array.from(this.root.querySelectorAll(":scope .comment-item-root"));d(Kn,e.length!==0,"current group item not exist comment-item"),e.forEach(r=>{F(r,u3)});const o=e.at(-1);M(o,u3)});h(this,"updateSwitchButton",()=>{const e=this.root.querySelector(':scope .editor-text-button[group-item-action="switch-up"]'),o=this.root.querySelector(':scope .editor-text-button[group-item-action="switch-down"]');d(Kn,e,"switchUpButton not exist"),d(Kn,o,"switchDownButton not exist"),F(o,"disabled"),F(e,"disabled"),this.root.previousElementSibling===null&&M(e,"disabled"),this.root.nextElementSibling===null&&M(o,"disabled")});h(this,"handleResize",()=>{this.emit("resize")});this.editor=e,this.commentsProvider=o,this.comment=r,this.groupList=i,this.root=this.createRoot(),this.header=this.createHeader(),this.mainItem=this.createItem(),this.childrenList=this.createChildrenList(),this.quickReply=this.createQuickReply(),this.resizeObserver=new ResizeObserver(this.handleResize),this.resizeObserver.observe(this.root),this.updateLastCommentItem()}get commentCount(){return f3(this.root)}createQuickReply(){const{editor:e,commentsProvider:o,comment:r}=this,i=new RO(e,o,r,this);return this.root.append(i.root),i}createHeader(){const{comment:e}=this,o=b("div",["comment-item-head"],this.root),r=b("span",["item-head-quote"],o);r.innerText=e.abstract;const i=b("span",["item-head-switch"],o),s=Xo(i,mt.SwitchUp,"up",LO),l=Xo(i,mt.SwitchDown,"down",MO);return Qn(s,mt.SwitchUp),Qn(l,mt.SwitchDown),o}createItem(){const e=b("div",["comment-item-container"],this.root),{editor:o,commentsProvider:r,comment:i,groupList:s}=this,l=new w3({mainEditor:o,commentsProvider:r,comment:i,groupList:s,groupItem:this});return e.appendChild(l.root),l}findCommentItem(e){return e?e===this.mainItem.comment.id?this.mainItem:this.childrenList.items.find(o=>o.comment.id===e):null}handleCreateComment(e){return d(Kn,rr(e),"invalid comment, not a child comment"),d(Kn,e.groupId===this.comment.id,"invalid comment, not a child comment"),this.childrenList.createItem(e)}handleUpdateChildComment(e){d(Kn,e.groupId===this.mainItem.comment.id,"invalid child comment");const o=this.childrenList.findItem(e.id);if(!o){Kn.error(`can't find child comment item: ${e.id}`);return}o.reloadDoc()}handleUpdateMainComment(e){d(Kn,e.id===this.mainItem.comment.id,"invalid comment"),this.mainItem.reloadDoc()}deleteMainComment(e){d(Kn,e===this.mainItem.comment.id,"invalid comment"),this.mainItem.destroy()}edit(){this.mainItem.edit()}destroy(){this.mainItem.destroy(),this.childrenList.destroy(),this.root.remove(),this.resizeObserver.disconnect(),this.removeAllListeners()}}const E3=y("arrange=items"),la=20;function I3(n,t){const e=n.rootContainer.querySelector(`[comment-${t.toLocaleLowerCase()}=${t}`);if(!e)return-1;const o=n.scrollContainer.getBoundingClientRect(),i=e.getBoundingClientRect().top-o.top;return d(E3,i>=0,`invalid comment offset, ${i}`),i}function x3(n,t){return Number.parseInt(t.root.style.top,10)}function OO(n,t,e){let o=0;e&&(o=t.indexOf(e),o===-1&&(o=0));for(let r=o;r<t.length;r++){const i=t[r],s=i.comment,l=I3(n,s.groupId);if(r===o){i.root.style.top=`${l}px`;continue}const c=t[r-1],a=x3(n,c)+c.root.getBoundingClientRect().height;a>l?i.root.style.top=`${a+la}px`:i.root.style.top=`${l+la}px`}for(let r=o-1;r>=0;r--){const i=t[r],s=i.comment,l=I3(n,s.groupId),c=i.root.getBoundingClientRect(),a=l+c.height,u=t[r+1];d(E3,u,"no next item");const f=x3(n,u);f<a?i.root.style.top=`${f-c.height-la}px`:i.root.style.top=`${l-la}px`}}const ca=y("comment-group-item-handler");class _O{constructor(t,e){h(this,"handleSwitchUp",t=>{const e=Math.max(0,t-1);this.groupList.setActiveItem(e),this.groupList.updateItemsLayout()});h(this,"handleSwitchDown",t=>{const e=Math.min(t+1,this.groupList.items.length);this.groupList.setActiveItem(e),this.groupList.updateItemsLayout()});h(this,"handleQuickReply",t=>{const{quickReply:e}=t;e.showReplyEditor()});h(this,"handleQuickReplyOk",t=>{const{quickReply:e}=t;e.reply(),t.updateLastCommentItem()});h(this,"handleQuickReplyCancel",t=>{const{quickReply:e}=t;e.cancel()});h(this,"handleCommentItemReply",(t,e)=>{const o=t.findCommentItem(e);d(ca,o,`the commentItem: ${e} not exist `);const{quickReply:r}=t;r.show(),r.showReplyEditor();const{comment:i}=o,s=r.getReplyEditor(),l=s.editor.getFocusedBlock(),c={type:"mention",id:N(),box:!0,created:Date.now(),text:i.displayName,iconUrl:i.avatarUrl,mentionId:i.userId};s.editor.insertBoxToBlock(l,0,c)});h(this,"handleCommentItemMore",t=>{const{quickReply:e}=t;e.hideReplyEditor(),e.getReplyEditor().clear()});h(this,"handleCommentItemOk",(t,e)=>{const o=t.findCommentItem(e);d(ca,o,`the commentItem: ${e} not exist `);const{quickReply:r}=t,{comment:i,getCommentEditor:s}=o,l=s(),c=l.getDoc();this.commentsProvider.localUpdateComment(i,c),l.readonly(),r.show()});h(this,"handleCommentItemCancel",(t,e)=>{const o=t.findCommentItem(e);d(ca,o,`the commentItem: ${e} not exist `);const r=this.commentsProvider.getComment(o.comment.id);if(xl(r.doc)){this.commentsProvider.localDeleteComment(o.comment.id);return}const{quickReply:i}=t,s=o.getCommentEditor();s.setDoc(o.doc),s.readonly(),i.show()});h(this,"handleCommentItemEdit",t=>{const e=this.groupList.findItem(t.comment.groupId);if(!e)return;const{quickReply:o}=e;t.getCommentEditor().edit(),o.hide()});h(this,"handleCommentItemDelete",t=>{const e=this.groupList.findItem(t.comment.groupId);if(!e)return;const{quickReply:o}=e,{comment:r}=t;this.commentsProvider.localDeleteComment(r.id),o.show()});h(this,"execute",(t,e,o,r)=>{const i=pO(t);if(!i||bO(i))return;const s=CO(i);switch(s){case mt.SwitchUp:this.handleSwitchUp(r);break;case mt.SwitchDown:this.handleSwitchDown(r);break;case mt.CommentItemReply:this.handleCommentItemReply(e,o);break;case mt.CommentItemMore:this.handleCommentItemMore(e);break;case mt.CommentItemOk:this.handleCommentItemOk(e,o);break;case mt.CommentItemCancel:this.handleCommentItemCancel(e,o);break;case mt.CommentItemDelete:break;case mt.CommentItemEdit:break;case mt.QuickReply:this.handleQuickReply(e);break;case mt.QuickReplyOk:this.handleQuickReplyOk(e);break;case mt.QuickReplyCancel:this.handleQuickReplyCancel(e);break;default:const l=s;ca.debug(`not implement handler for ${l}`)}});this.groupList=t,this.commentsProvider=e}destroy(){}}const aa=y("comment-group-list");class NO extends Os{constructor(e,o,r){super(e,o,r,Co(e,o),{});h(this,"groupItemHandlers");h(this,"findGroupItem",e=>this.items.find(o=>o.comment.groupId===e));h(this,"handleContainerClick",e=>{if(!e.target||!(e.target instanceof Element))return;const o=e.target.closest(".comment-group-item-root");if(!o)return;const r=gO(e.target),i=this.items.findIndex(s=>s.root===o);if(i!==-1){this.setActiveItem(i);const{groupItemHandlers:s}=this;s.execute(e.target,this.items.at(i),r,i)}});h(this,"handleSelectionChanged",()=>{const e=wO(this.editor);if(e.length>0){const o=e[0],r=this.items.findIndex(i=>i.comment.groupId===o);this.setActiveItem(r),this.emit("selectionOnComment")}else this.setActiveItem(-1)});h(this,"handleEditorResize",()=>{this.updateItemsLayout()});h(this,"handleDocChanged",()=>{this.updateComments()});h(this,"handleItemResize",()=>{this.updateItemsLayout()});h(this,"updateGroupItemSwitch",()=>{const e=this.activeItem;d(aa,e,"invalid activeItem"),e.updateSwitchButton()});h(this,"updateComments",ie.default(()=>{const e=Co(this.editor,this.commentsProvider);let o=!1;for(let r=0;r<e.length;r++){const i=e[r];if(!this.findGroupItem(i.groupId)){this.handleCreateComment(i,!1),o=!0;continue}}for(let r=this.items.length-1;r>=0;r--){const i=this.items[r];e.findIndex(s=>s.groupId===i.comment.groupId)===-1&&(this.deleteItem(i.comment.id),o=!0)}o&&(this.updateItemsLayout(),this.emit("commentCountChanged"))},100));this.updateItemsLayout(),this.bindEvents(),this.editor.addListener("selectionChanged",this.handleSelectionChanged),this.editor.addListener("resize",this.handleEditorResize),this.editor.addListener("docChanged",this.handleDocChanged),this.items.forEach(i=>i.addListener("resize",this.handleItemResize)),this.groupItemHandlers=new _O(this,o)}destroy(){this.editor.removeListener("selectionChanged",this.handleSelectionChanged),this.editor.removeListener("resize",this.handleEditorResize),this.editor.removeListener("docChanged",this.handleDocChanged),super.destroy(),this.unbindEvents(),this.removeAllListeners()}updateItemsLayout(){OO(this.editor,this.items,this.activeItem)}bindEvents(){this.container.addEventListener("click",this.handleContainerClick)}unbindEvents(){this.container.removeEventListener("click",this.handleContainerClick)}createItem(e,o){const r=new AO(this.editor,this.commentsProvider,e,this);return o==="insert"&&(M(r.root,"no-animation"),r.root.style.opacity="0",setTimeout(()=>{F(r.root,"no-animation"),r.root.style.opacity="1"},150)),r}findInsertPos(e){const r=Co(this.editor,this.commentsProvider).findIndex(i=>i.id===e.id);return r===-1||r>this.items.length?-1:r}insertItem(e){const o=super.insertItem(e);return o?(this.setActiveItem(this.items.indexOf(o)),this.updateItemsLayout(),o.addListener("resize",this.handleItemResize),o):null}setActiveItem(e){if(d(aa,e>=-1&&e<this.items.length,`invalid index: ${e}`),e===this.activeIndex)return;const o=this.container.querySelector(".comment-group-item-root.active");if(o&&F(o,"active"),e!==-1){const r=this.items[e];M(r.root,"active"),this.updateItemsLayout(),this.updateGroupItemSwitch()}this.emit("activeItemChanged",e)}get activeIndex(){const e=this.container.querySelector(".comment-group-item-root.active");return e?this.items.findIndex(o=>o.root===e):-1}get activeItem(){const e=this.activeIndex;return e===-1?null:this.items[e]}handleCreateComment(e,o){if(rr(e)){const l=this.findGroupItem(e.groupId);l&&l.childrenList.insertItem(e)}const r=this.findItem(e.id);d(aa,!r,"comment group item has already exists");const i={children:[],...e};d(aa,i.children,"not a comment group");const s=this.insertItem(i);!s||o&&setTimeout(()=>{const l=this.items.indexOf(s);this.setActiveItem(l),s.edit(),s.quickReply.hide()})}handleDeleteComment(e){for(let o=0;o<this.items.length;o++){const r=this.items[o];if(r.comment.id===e){r.childrenList.items.length===0?this.deleteItem(r.comment.id):r.deleteMainComment(e);return}if(r.childrenList.deleteItem(e)){r.commentCount===0&&this.deleteItem(r.comment.id);return}}}handleUpdateComment(e){if(rr(e)){const r=this.commentsProvider.getComment(e.groupId),i=this.findItem(r.id);i&&i.handleUpdateChildComment(e);return}const o=this.findItem(e.id);o&&o.handleUpdateMainComment(e)}}const PO="comment-mini";y("comment-list");class $O extends Wt.TypedEmitter{constructor(e,o,r){super();h(this,"root");h(this,"groupsContainer");h(this,"list");h(this,"handleSelectionOnComment",()=>{this.emit("onSelectComment")});h(this,"updateCommentCount",()=>{var o,r;const e=yO(this.editor,this.commentsProvider);(r=(o=this.commentOptions)==null?void 0:o.onCommentCountChange)==null||r.call(o,e)});h(this,"handleActiveItemChanged",()=>{var o;const e=this.list.activeItem;e&&Ei(e.root),v3(this.editor,(o=e==null?void 0:e.comment.id)!=null?o:"")});h(this,"handleItemLayoutUpdated",()=>{var o,r;const e=lt(this.root,PO);(r=(o=this.commentOptions)==null?void 0:o.onUpdateLayout)==null||r.call(o,this.editor,{expand:e})});this.editor=e,this.commentsProvider=o,this.root=b("div",["editor-web-comment-root"],r),this.groupsContainer=b("div",["comment-groups-container"],this.root),this.list=this.createList(),this.commentsProvider.addListener(this),this.list.addListener("activeItemChanged",this.handleActiveItemChanged),this.list.addListener("itemLayoutUpdated",this.handleItemLayoutUpdated),this.list.addListener("selectionOnComment",this.handleSelectionOnComment),this.list.addListener("commentCountChanged",this.updateCommentCount),this.updateCommentCount()}get commentOptions(){return this.editor.getComponentOptions("comment")}destroy(){this.list.removeAllListeners(),this.commentsProvider.removeListener(this),this.list.destroy(),this.root.remove()}onCreateComment(e,o){const r=this.commentsProvider.getComment(e);this.list.handleCreateComment(r,o),this.updateCommentCount()}onDeleteComment(e,o){this.list.handleDeleteComment(e),this.updateCommentCount()}onUpdateComment(e,o){const r=this.commentsProvider.getComment(e);this.list.handleUpdateComment(r)}createList(){return new NO(this.editor,this.commentsProvider,this.groupsContainer)}show(e){var o;if(F(this.root,"hidden"),e){const r=this.list.findItemIndex(e);this.list.setActiveItem(r)}(o=this.commentOptions)==null||o.controller.showCommentList()}hide(){M(this.root,"hidden")}}class HO extends Os{constructor({editor:t,parent:e,commentsProvider:o,comments:r}){super(t,o,e,r,{})}findInsertPos(){return this.items.length}createItem(t){const{editor:e,commentsProvider:o}=this;return new B3(e,o,t)}destroy(){this.items.forEach(t=>{t.destroy()})}}const da=y("mobile-comment-group-item"),jO=20;class FO extends Wt.TypedEmitter{constructor(e,o,r){super();h(this,"root");h(this,"childrenList");h(this,"mainItem");h(this,"scroller");h(this,"createRoot",()=>b("div",["mobile-group-item-root"],null));h(this,"createMainItem",e=>{const{editor:o,commentsProvider:r,comment:i}=this,s=new B3(o,r,i);return e.append(s.root),s});h(this,"createChildrenList",e=>{const{editor:o,commentsProvider:r,comment:i}=this,s=b("div",["mobile-comment-children-list-container"],e);return new HO({editor:o,commentsProvider:r,comments:i.children,parent:s})});h(this,"handleTouchEnd",()=>{var i;const{scroller:e}=this,{pullThreshold:o=jO}=(i=this.editor.getComponentOptions("comment"))!=null?i:{};let r=null;if(e.y>e.minScrollY+o?(r=this.root.previousElementSibling,r||this.emit("onReachTop")):e.y<e.maxScrollY-o&&(r=this.root.nextElementSibling,r||this.emit("onReachBottom")),r){const s=r.id;this.emit("onSwitchGroup",s,h3)}});h(this,"refreshScroller",()=>{this.scroller.refresh()});this.editor=e,this.commentsProvider=o,this.comment=r,this.root=b("div",["mobile-group-item-root"],null),this.root.id=r.groupId;const i=b("div",["mobile-group-item"],this.root),s=b("div",["mobile-group-item-space"],null),l=b("div",["mobile-group-item-abstract"],null);l.textContent=r.abstract;const c=b("div",["mobile-group-item-list-container"],null);this.mainItem=this.createMainItem(c),this.childrenList=this.createChildrenList(c),i.append(s,l,c),this.scroller=new _f.default(this.root,{stopPropagation:!0,click:!0}),this.scroller.on("touchEnd",this.handleTouchEnd)}get commentCount(){return f3(this.root,".mobile-group-item")}handleUpdateChildComment(e){d(da,e.groupId===this.mainItem.comment.id,"invalid child comment");const o=this.childrenList.findItem(e.id);if(!o){da.error(`can't find child comment item: ${e.id}`);return}o.reloadDoc()}handleUpdateMainComment(e){d(da,e.id===this.mainItem.comment.id,"invalid comment"),this.mainItem.reloadDoc()}deleteMainComment(e){d(da,e===this.mainItem.comment.id,"invalid comment"),this.mainItem.destroy()}destroy(){this.mainItem.destroy(),this.childrenList.destroy(),this.scroller.off("touchEnd",this.handleTouchEnd),this.scroller.destroy(),this.root.remove(),this.removeAllListeners()}}const Yh=y("mobile-group-list");class zO extends Os{constructor(e,o,r,i){super(e,o,r,Co(e,o),{});h(this,"scroller");h(this,"deleteItem",e=>{if(this.items.length<=1)return super.deleteItem(e);const o=this.findItemIndex(e);let r=null;return o===0?r=this.items[o+1].root.id:r=this.items[o-1].root.id,super.deleteItem(e)?(this.scrollToGroup(r,h3),!0):!1});h(this,"setupGroupItem",e=>{e.on("onSwitchGroup",this.scrollToGroup),e.on("onReachBottom",this.handleReachBottom),e.on("onReachTop",this.handleReachTop),e.refreshScroller()});h(this,"handleReachBottom",()=>{this.emit("onReachBottom")});h(this,"handleReachTop",()=>{this.emit("onReachTop")});h(this,"scrollToGroup",(e,o=0)=>{const r=this.findGroupItem(e);d(Yh,r,"invalid scroll target"),this.scroller.scrollToElement(r.root,o,!1,!1),v3(this.editor,r.comment.id)});h(this,"findGroupItem",e=>this.items.find(o=>o.comment.groupId===e));h(this,"handleDocChanged",()=>{this.updateComments()});h(this,"updateComments",ie.default(()=>{const e=Co(this.editor,this.commentsProvider);for(let o=0;o<e.length;o++){const r=e[o];if(!this.findGroupItem(r.groupId)){this.handleCreateComment(r,!1);continue}}for(let o=this.items.length-1;o>=0;o--){const r=this.items[o];e.findIndex(i=>i.groupId===r.comment.groupId)===-1&&this.deleteItem(r.comment.id)}},100));this.scroller=new _f.default(i),this.scroller.disable(),this.editor.addListener("docChanged",this.handleDocChanged),this.items.forEach(this.setupGroupItem)}createItem(e){return new FO(this.editor,this.commentsProvider,e)}insertItem(e){const o=super.insertItem(e);return o?(this.setupGroupItem(o),o):null}findInsertPos(e){const r=Co(this.editor,this.commentsProvider).findIndex(i=>i.id===e.id);return r===-1||r>this.items.length?-1:r}setActiveItem(e){this.scrollToGroup(e)}handleCreateComment(e,o){if(rr(e)){const s=this.findGroupItem(e.groupId);s&&s.childrenList.insertItem(e)}const r=this.findItem(e.id);d(Yh,!r,"comment group item has already exists");const i={children:[],...e};d(Yh,i.children,"not a comment group"),this.insertItem(i),this.scroller.refresh()}handleDeleteComment(e){for(let o=0;o<this.items.length;o++){const r=this.items[o];if(r.comment.id===e){r.childrenList.items.length===0?this.deleteItem(r.comment.id):r.deleteMainComment(e);return}if(r.childrenList.deleteItem(e)){r.commentCount===0&&this.deleteItem(r.comment.id);return}}}handleUpdateComment(e){if(rr(e)){const r=this.commentsProvider.getComment(e.groupId),i=this.findItem(r.id);i&&i.handleUpdateChildComment(e);return}const o=this.findItem(e.id);o&&o.handleUpdateMainComment(e)}destroy(){this.editor.removeListener("docChanged",this.handleDocChanged),this.scroller.destroy(),this.items.forEach(e=>e.destroy())}}const VO=y("mobile-comment-list"),{t:S3}=S;class UO extends Wt.TypedEmitter{constructor(e,o,r){super();h(this,"root");h(this,"list");h(this,"mask");h(this,"pullInfoContainer");h(this,"handleRootClick",e=>{const o=e.target;d(VO,o instanceof Element,"invalid target"),!(o.closest(".mobile-group-item-abstract")||o.closest(".mobile-group-item-list-container"))&&(this.hide(),this.emit("onCommentListClose"))});h(this,"hidePullInfo",ie.default(()=>{F(this.pullInfoContainer,"active")},1e3*3));h(this,"handleReachBottom",()=>{this.showPullInfo("bottom")});h(this,"handleReachTop",()=>{this.showPullInfo("top")});h(this,"show",e=>{F(this.root,"hidden"),M(document.documentElement,"disabled-scroll"),e&&this.list.setActiveItem(e)});h(this,"hide",()=>{M(this.root,"hidden"),F(document.documentElement,"disabled-scroll")});this.editor=e,this.commentsProvider=o,this.root=b("div",["editor-mobile-comments-root"],r),this.mask=b("div",["mobile-comment-mask"],this.root);const i=b("div",["mobile-comment-groups-container"],this.root),s=b("div",["mobile-comment-groups-scroll-container"],i);this.list=new zO(this.editor,this.commentsProvider,s,i),this.pullInfoContainer=this.createPullInfo(),this.commentsProvider.addListener(this),this.list.on("onReachBottom",this.handleReachBottom),this.list.on("onReachTop",this.handleReachTop),this.root.onclick=this.handleRootClick}onCreateComment(e,o){const r=this.commentsProvider.getComment(e);this.list.handleCreateComment(r,o)}onDeleteComment(e,o){this.list.handleDeleteComment(e)}onUpdateComment(e,o){const r=this.commentsProvider.getComment(e);this.list.handleUpdateComment(r)}createPullInfo(){const e=b("div",["mobile-comment-pull-info-container"],this.root);return b("div",["mobile-comment-pull-info"],e),e}showPullInfo(e){const o=S3(e==="bottom"?"comment.isLast":"comment.isFirst");this.pullInfoContainer.firstElementChild.textContent=o,M(this.pullInfoContainer,"active"),this.hidePullInfo()}destroy(){this.list.removeAllListeners(),this.list.destroy(),this.root.onclick=null}}function T3(n,t){const e=Co(n,t),o=new Map;for(const r of e){const i=m3(n,r.groupId);if(!!i)if(o.has(i)){const s=o.get(i);Uh(r).forEach(c=>{s==null||s.commentIds.add(c.id)})}else{const s=Uh(r),l=new Set(s.map(c=>c.id));o.set(i,{commentIds:l,firstComment:r})}}return Array.from(o.entries()).map(([r,i])=>({blockId:r,...i}))}const qO=y("mini-group-item");class WO{constructor(t,e){h(this,"root");h(this,"blockId");h(this,"comment");h(this,"miniCommentItem");h(this,"updateCommentItemCount",()=>{this.miniCommentItem.updateCount(this.commentCount)});this.editor=t,this.commentGroup=e,this.root=b("div",["mini-group-item"],null),this.comment=e.firstComment,this.miniCommentItem=new TO(this.comment.id,this.root),this.blockId=this.getBlockId(),this.alignToBlock(),this.updateCommentItemCount()}getBlockId(){return m3(this.editor,this.comment.groupId)}get commentCount(){return this.commentGroup.commentIds.size}alignToBlock(){const t=this.getBlockId(),e=this.editor.getBlockById(t);d(qO,e,`The blockId: ${t} not exist in doc`);const o=this.editor.scrollContainer.getBoundingClientRect(),i=e.getBoundingClientRect().top-o.top;requestAnimationFrame(()=>{this.root.style.transform=`translateY(${i}px)`})}destroy(){this.root.remove()}}class GO extends Os{constructor(e,o,r){super(e,o,r,T3(e,o),{});h(this,"handleDocChanged",ie.default(()=>{this.updateMiniCommentsGroup()},100));h(this,"updateMiniCommentsGroup",()=>{const e=T3(this.editor,this.commentsProvider);this.reloadList(e)});this.editor=e,this.commentsProvider=o,this.editor.addListener("docChanged",this.handleDocChanged)}createItem(e){return new WO(this.editor,e)}findInsertPos(){return-1}handleCreateComment(e,o){this.updateMiniCommentsGroup()}handleDeleteComment(e){this.updateMiniCommentsGroup()}destroy(){this.editor.removeListener("docChanged",this.handleDocChanged),super.destroy(),this.removeAllListeners()}}const ZO=y("mini-comments-list");class YO extends Wt.TypedEmitter{constructor(e,o,r){super();h(this,"list");h(this,"root");h(this,"createList",()=>{const e=b("div",["comment-groups-container"],this.root);return this.editor.domEvents.addEventListener(e,"click",this.handleListContainerClick),new GO(this.editor,this.commentsProvider,e)});h(this,"handleListContainerClick",(e,o)=>{const r=o.target;d(ZO,r instanceof HTMLElement,"The target is not a valid html element");const i=r.closest(".mini-comment-item");i&&this.emit("onItemClick",i.id)});this.editor=e,this.commentsProvider=o,this.root=b("div",["editor-mini-comment-root"],r),this.list=this.createList(),this.commentsProvider.addListener(this)}onCreateComment(e,o){const r=this.commentsProvider.getComment(e);this.list.handleCreateComment(r,o)}onDeleteComment(e,o){this.list.handleDeleteComment(e)}onUpdateComment(e,o){}show(){F(this.root,"hidden")}hide(){M(this.root,"hidden")}destroy(){this.list.destroy(),this.removeAllListeners()}}function D3(n,t,e){if(!t.start.isSimple()||!t.end.isSimple())return;const o=t.block,r=Ot(n,o,t.start.offset,t.end.offset),i=`comment-${e.id.toLocaleLowerCase()}`,s=e.id;B2(n,o,r,i,s)}function QO(n,t,e){const o=Qe(n).map(s=>s.block),r=zh(n,o),i=ra({editor:n,abstract:r});return n.undoManager.runInGroup(()=>{Qe(n,{simpleBlockOnly:!0}).forEach(c=>{!j(n,c.block)||D3(n,c,i)});const l=oo();e.localCreateComment(i,l)}),i}class KO{constructor(t,e){h(this,"id","CommentsCommandProvider");this.provider=t,this.editorComments=e}getAvailableCommands(t,e,o){const r=t.selection.range;if(j(t,e)&&!o.isCollapsed()&&r.isSimple()){const i=G(e),s=it(e),l=We(t,e);return[{id:"add-comment",name:"Add comment",blockId:i,blockType:s,blockKind:l,groupIndex:1e3,icon:$r}]}return[]}executeRangeCommand(t,e,o,r,i){if(o.id==="add-comment"){this.editorComments.showCommentList();const s=QO(t,e,this.provider);return i["add-comment"]=s,!0}return!1}}class JO{constructor(t,e){h(this,"commentList",null);h(this,"mobileCommentList",null);h(this,"miniCommentList");h(this,"showComment",(t,e)=>{var o,r;t==="mini"&&this.miniCommentList.show(),t==="mobile"&&((o=this.mobileCommentList)==null||o.show(e)),t==="web"&&((r=this.commentList)==null||r.show(e))});h(this,"showCommentList",t=>{this.isMobile?this.showComment("mobile",t):this.showComment("web",t)});h(this,"handleCommentListClose",()=>{this.showComment("mini")});h(this,"handleOnSelectComment",()=>{this.showComment("web")});h(this,"handleMiniCommentItemClick",t=>{this.showCommentList(t)});this.editor=t,this.provider=e,t.editorCommandProviders.registerCommandProvider(new KO(e,this)),t.addCustom("block-comment-button",()=>new mO(t,e,this)),t.blockHooks.push(new uO(this.provider,this)),this.isMobile?(this.mobileCommentList=new UO(this.editor,this.provider,this.getCommentRoot("mobileContainer")),this.mobileCommentList.on("onCommentListClose",this.handleCommentListClose)):(this.commentList=new $O(this.editor,this.provider,this.getCommentRoot("container")),this.commentList.on("onSelectComment",this.handleOnSelectComment)),this.miniCommentList=new YO(this.editor,this.provider,this.getCommentRoot("miniContainer")),this.miniCommentList.on("onItemClick",this.handleMiniCommentItemClick)}get commentOptions(){return this.editor.getComponentOptions("comment")}get commentProvider(){return this.provider}get isMobile(){return It.isMobile}getCommentRoot(t){var e,o;return(o=(e=this.commentOptions)==null?void 0:e[t])!=null?o:document.body}destroy(){var t,e;(t=this.commentList)==null||t.destroy(),(e=this.mobileCommentList)==null||e.destroy(),this.miniCommentList.destroy()}}const XF="",XO={comment:{count:"\u6279\u6CE8 ({num})",hide:"\u9690\u85CF\u6279\u6CE8",show:"\u663E\u793A\u6279\u6CE8",reply:"\u56DE\u590D",quicklyReply:"\u56DE\u590D...",send:"\u786E\u8BA4",placeholder:"\u6DFB\u52A0\u6279\u6CE8...",replyPlaceholder:"\u56DE\u590D\u6216@\u4ED6\u4EBA",edit:"\u7F16\u8F91",delete:"\u5220\u9664",image:"\u56FE\u7247",sendTitle:"\u6309Enter\u53D1\u9001\u6279\u6CE8",replyTitle:"\u6309Enter\u56DE\u590D\u6279\u6CE8",isFirst:"\u5DF2\u7ECF\u662F\u7B2C\u4E00\u6761\u6279\u6CE8",isLast:"\u5DF2\u7ECF\u662F\u6700\u540E\u4E00\u6761\u6279\u6CE8",comment:"\u6279\u6CE8"}},t_={comment:{count:"Comments ({num})",hide:"Hide Comments",show:"Show Comments",reply:"Reply",quicklyReply:"Reply...",send:"OK",placeholder:"Add a comment...",replyPlaceholder:"Add Comments or @ others",edit:"Edit",delete:"Delete",image:"Image",sendTitle:"Press Enter to send comment",replyTitle:"Press Enter to reply comment",isFirst:"\u5DF2\u7ECF\u662F\u7B2C\u4E00\u6761\u6279\u6CE8",isLast:"\u5DF2\u7ECF\u662F\u6700\u540E\u4E00\u6761\u6279\u6CE8",more:"more",comment:"Comment"}},e_={comment:{count:"\u30B3\u30E1\u30F3\u30C8 ({num})",hide:"\u30B3\u30E1\u30F3\u30C8\u3092\u975E\u8868\u793A",show:"\u30B3\u30E1\u30F3\u30C8\u3092\u8868\u793A",reply:"\u8FD4\u4FE1",quicklyReply:"\u8FD4\u4FE1...",send:"\u9001\u4FE1",placeholder:"\u30B3\u30E1\u30F3\u30C8\u3092\u8FFD\u52A0...",replyPlaceholder:"\u8FD4\u4FE1\u307E\u305F\u306F\u30E1\u30F3\u30B7\u30E7\u30F3(@)",edit:"\u7DE8\u96C6",delete:"\u524A\u9664",image:"\u753B\u50CF",sendTitle:"Enter\u3092\u62BC\u3057\u3066\u30B3\u30E1\u30F3\u30C8\u3092\u9001\u4FE1",replyTitle:"Enter\u3092\u62BC\u3057\u3066\u30B3\u30E1\u30F3\u30C8\u3092\u8FD4\u4FE1",isFirst:"\u6700\u521D\u306E\u30B3\u30E1\u30F3\u30C8\u3067\u3059",isLast:"\u6700\u5F8C\u306E\u30B3\u30E1\u30F3\u30C8\u3067\u3059",comment:"\u30B3\u30E1\u30F3\u30C8\u3092"}};S.mergeLang({"zh-CN":XO,"en-US":t_,"ja-JP":e_});class L3{renderText(t,e,o){const r=[],i={};return Object.entries(o).forEach(([s,l])=>{s.startsWith("comment-")&&(r.push("comment"),i[s]=l)}),{classes:r,attributes:i}}renderBlock(t,e,o){const r=o.comments;if(!r||r.length===0)return{};const i=["comment"],s={};return r.forEach(l=>{s[`comment-${l.toLocaleLowerCase()}`]=l}),{classes:i,attributes:s}}updateBlock(t,e,o,r){const i=r.comments;F(o,"comment"),Array.from(o.attributes).forEach(s=>{s.name.startsWith("comment-")&&o.removeAttribute(s.name)}),!(!i||i.length===0)&&(M(o,"comment"),i.forEach(s=>{o.setAttribute(`comment-${s.toLocaleLowerCase()}`,s)}))}}class n_{constructor(t){h(this,"handleUpdateCompositionText",(t,e,o,r,i)=>{const s=t.getFocusedBlock(),l=t.getFirstBlock();s===l&&this.applyPlaceholder(t)});h(this,"handleSelectionChange",t=>{this.applyPlaceholder(t)});h(this,"applyPlaceholder",t=>{const e=t.getFirstBlock();jc(t,e,S.t("comment.replyPlaceholder"))});this.applyPlaceholder(t),t.addListener("selectionChanged",this.handleSelectionChange)}}function o_(n,t,e){const o=n.getBlockData(t),r=o.comments;if((r==null?void 0:r.indexOf(e))!==-1){const s=new Set(r);s.delete(e),n.updateBlockData(t,{comments:Array.from(s)})}const i=o.text;if(!!i&&j(n,t)){const s=N1(i,`comment-${e.toLocaleLowerCase()}`,e);n.setBlockText(t,s)}}const r_=y("editor-comment");function i_(n){const t=n.getCustom("editor-comments");if(d(r_,t,"the editor comment not exist"),t.showCommentList(),n.selection.range.isCollapsed()){const s=n.selection.startBlock,l=Ro(s);if(l.length>=2){const{containerId:c}=l.at(-1),a=z(br(n,c));if(a&&it(a)==="code"){ia(n,a,t.commentProvider);return}}ia(n,s,t.commentProvider);return}const e=Qe(n,{simpleBlockOnly:!0}),o=e.map(s=>s.block),r=zh(n,o),i=ra({editor:n,abstract:r});n.undoManager.runInGroup(()=>{e.forEach(l=>{j(n,l.block)?D3(n,l,i):d3(n,l.block,i)});const s=oo();t.commentProvider.localCreateComment(i,s)})}const Qh=y("text-styles");function s_(n){const t=o=>{if(!o.attributes)return new Map;const r=Object.entries(o.attributes).filter(([i])=>!!i.startsWith("style-"));return new Map(r)};if(n.length===0)return new Map;let e=t(n[0]);for(let o=1;o<n.length;o++){const r=t(n[o]);e=new Map(Array.from(e.entries()).filter(([i,s])=>r.get(i)===s))}return e}function l_(n,t,e,o,r){d(Qh,e.isSimple(),"invalid range");const{start:i,end:s}=e;d(Qh,i.blockId===s.blockId&&i.blockId===G(t),"invalid range"),d(Qh,o.startsWith("style-"),"invalid style");let c=n.getBlockText(t);return o==="style-subscript"?c=Sr(i.offset,s.offset-i.offset,c,"style-superscript",void 0,{ignoreValue:!0}):o==="style-superscript"&&(c=Sr(i.offset,s.offset-i.offset,c,"style-subscript",void 0,{ignoreValue:!0})),r===!1||r===void 0||r===null?c=Sr(i.offset,s.offset-i.offset,c,o,void 0,{ignoreValue:!0}):c=wl(i.offset,s.offset-i.offset,c,o,r),n.setBlockText(t,c),c}const c_=`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
646
+ </svg>`,JF="",sa="reply-editor-editing",{t:Zh}=S;class RO{constructor(t,e,o,r){h(this,"root");h(this,"components");h(this,"handleFocus",()=>{const{replyEditor:t,okButton:e}=this.components;t.isEmpty()&&M(e,Yn)});h(this,"handleDocChange",()=>{const{replyEditor:t,okButton:e}=this.components,o=t.getDoc();xl(o)?M(e,Yn):F(e,Yn)});h(this,"getReplyEditor",()=>this.components.replyEditor);h(this,"showReplyEditor",()=>{lt(this.root,sa)||(M(this.root,sa),this.components.replyEditor.edit())});h(this,"hideReplyEditor",()=>{!lt(this.root,sa)||F(this.root,sa)});h(this,"reply",()=>{const{mainEditor:t,comment:e,components:{replyEditor:o},commentsProvider:r}=this,i=o.getDoc(),s=ra({editor:t,commentGroupId:e.groupId});r.localCreateComment(s,i),this.hideReplyEditor(),o.clear()});h(this,"cancel",()=>{const{replyEditor:t}=this.components;this.hideReplyEditor(),t.clear()});h(this,"hide",()=>{lt(this.root,"hidden")||M(this.root,"hidden")});h(this,"show",()=>{F(this.root,"hidden")});this.mainEditor=t,this.commentsProvider=e,this.comment=o,this.groupItem=r,this.root=b("div",["comment-quick-reply"],null),this.components=this.createQuickReply()}createQuickReply(){const{commentsProvider:t}=this,e=Xo(this.root,mt.QuickReply,Zh("comment.placeholder"));Qn(e,mt.QuickReply),e.classList.add("quick-reply-button");const o=b("div",["quick-reply-editor"],this.root),r=oo(),i=new Gh(this.mainEditor,t,r);i.editor.addListener("docChanged",this.handleDocChange),i.editor.addListener("focus",this.handleFocus),i.editor.input.addHandler(new EO(this.groupItem)),o.append(i.root);const s=b("div",["reply-editor-actions"],o),l=kn(mt.QuickReplyCancel,Zh("common.cancel"));Qn(l,mt.QuickReplyCancel);const c=kn(mt.QuickReplyOk,Zh("comment.send"));return Qn(c,mt.QuickReplyOk),M(c,Yn),s.append(l,c),this.hideReplyEditor(),{replyTextButton:e,replyEditor:i,replyEditorContainer:o,okButton:c}}}const Kn=y("comment-group-item");class AO extends Wt.TypedEmitter{constructor(e,o,r,i){super();h(this,"root");h(this,"header");h(this,"mainItem");h(this,"childrenList");h(this,"resizeObserver");h(this,"quickReply");h(this,"createRoot",()=>b("div",["comment-group-item-root"],null));h(this,"createChildrenList",()=>{const e=b("div",["comment-children-list-container"],this.root);return new DO({editor:this.editor,commentsProvider:this.commentsProvider,comments:this.comment.children,parent:e,groupList:this.groupList,groupItem:this})});h(this,"updateLastCommentItem",()=>{const e=Array.from(this.root.querySelectorAll(":scope .comment-item-root"));d(Kn,e.length!==0,"current group item not exist comment-item"),e.forEach(r=>{F(r,u3)});const o=e.at(-1);M(o,u3)});h(this,"updateSwitchButton",()=>{const e=this.root.querySelector(':scope .editor-text-button[group-item-action="switch-up"]'),o=this.root.querySelector(':scope .editor-text-button[group-item-action="switch-down"]');d(Kn,e,"switchUpButton not exist"),d(Kn,o,"switchDownButton not exist"),F(o,"disabled"),F(e,"disabled"),this.root.previousElementSibling===null&&M(e,"disabled"),this.root.nextElementSibling===null&&M(o,"disabled")});h(this,"handleResize",()=>{this.emit("resize")});this.editor=e,this.commentsProvider=o,this.comment=r,this.groupList=i,this.root=this.createRoot(),this.header=this.createHeader(),this.mainItem=this.createItem(),this.childrenList=this.createChildrenList(),this.quickReply=this.createQuickReply(),this.resizeObserver=new ResizeObserver(this.handleResize),this.resizeObserver.observe(this.root),this.updateLastCommentItem()}get commentCount(){return f3(this.root)}createQuickReply(){const{editor:e,commentsProvider:o,comment:r}=this,i=new RO(e,o,r,this);return this.root.append(i.root),i}createHeader(){const{comment:e}=this,o=b("div",["comment-item-head"],this.root),r=b("span",["item-head-quote"],o);r.innerText=e.abstract;const i=b("span",["item-head-switch"],o),s=Xo(i,mt.SwitchUp,"up",LO),l=Xo(i,mt.SwitchDown,"down",MO);return Qn(s,mt.SwitchUp),Qn(l,mt.SwitchDown),o}createItem(){const e=b("div",["comment-item-container"],this.root),{editor:o,commentsProvider:r,comment:i,groupList:s}=this,l=new w3({mainEditor:o,commentsProvider:r,comment:i,groupList:s,groupItem:this});return e.appendChild(l.root),l}findCommentItem(e){return e?e===this.mainItem.comment.id?this.mainItem:this.childrenList.items.find(o=>o.comment.id===e):null}handleCreateComment(e){return d(Kn,rr(e),"invalid comment, not a child comment"),d(Kn,e.groupId===this.comment.id,"invalid comment, not a child comment"),this.childrenList.createItem(e)}handleUpdateChildComment(e){d(Kn,e.groupId===this.mainItem.comment.id,"invalid child comment");const o=this.childrenList.findItem(e.id);if(!o){Kn.error(`can't find child comment item: ${e.id}`);return}o.reloadDoc()}handleUpdateMainComment(e){d(Kn,e.id===this.mainItem.comment.id,"invalid comment"),this.mainItem.reloadDoc()}deleteMainComment(e){d(Kn,e===this.mainItem.comment.id,"invalid comment"),this.mainItem.destroy()}edit(){this.mainItem.edit()}destroy(){this.mainItem.destroy(),this.childrenList.destroy(),this.root.remove(),this.resizeObserver.disconnect(),this.removeAllListeners()}}const E3=y("arrange=items"),la=20;function I3(n,t){const e=n.rootContainer.querySelector(`[comment-${t.toLocaleLowerCase()}=${t}`);if(!e)return-1;const o=n.scrollContainer.getBoundingClientRect(),i=e.getBoundingClientRect().top-o.top;return d(E3,i>=0,`invalid comment offset, ${i}`),i}function x3(n,t){return Number.parseInt(t.root.style.top,10)}function OO(n,t,e){let o=0;e&&(o=t.indexOf(e),o===-1&&(o=0));for(let r=o;r<t.length;r++){const i=t[r],s=i.comment,l=I3(n,s.groupId);if(r===o){i.root.style.top=`${l}px`;continue}const c=t[r-1],a=x3(n,c)+c.root.getBoundingClientRect().height;a>l?i.root.style.top=`${a+la}px`:i.root.style.top=`${l+la}px`}for(let r=o-1;r>=0;r--){const i=t[r],s=i.comment,l=I3(n,s.groupId),c=i.root.getBoundingClientRect(),a=l+c.height,u=t[r+1];d(E3,u,"no next item");const f=x3(n,u);f<a?i.root.style.top=`${f-c.height-la}px`:i.root.style.top=`${l-la}px`}}const ca=y("comment-group-item-handler");class _O{constructor(t,e){h(this,"handleSwitchUp",t=>{const e=Math.max(0,t-1);this.groupList.setActiveItem(e),this.groupList.updateItemsLayout()});h(this,"handleSwitchDown",t=>{const e=Math.min(t+1,this.groupList.items.length);this.groupList.setActiveItem(e),this.groupList.updateItemsLayout()});h(this,"handleQuickReply",t=>{const{quickReply:e}=t;e.showReplyEditor()});h(this,"handleQuickReplyOk",t=>{const{quickReply:e}=t;e.reply(),t.updateLastCommentItem()});h(this,"handleQuickReplyCancel",t=>{const{quickReply:e}=t;e.cancel()});h(this,"handleCommentItemReply",(t,e)=>{const o=t.findCommentItem(e);d(ca,o,`the commentItem: ${e} not exist `);const{quickReply:r}=t;r.show(),r.showReplyEditor();const{comment:i}=o,s=r.getReplyEditor(),l=s.editor.getFocusedBlock(),c={type:"mention",id:N(),box:!0,created:Date.now(),text:i.displayName,iconUrl:i.avatarUrl,mentionId:i.userId};s.editor.insertBoxToBlock(l,0,c)});h(this,"handleCommentItemMore",t=>{const{quickReply:e}=t;e.hideReplyEditor(),e.getReplyEditor().clear()});h(this,"handleCommentItemOk",(t,e)=>{const o=t.findCommentItem(e);d(ca,o,`the commentItem: ${e} not exist `);const{quickReply:r}=t,{comment:i,getCommentEditor:s}=o,l=s(),c=l.getDoc();this.commentsProvider.localUpdateComment(i,c),l.readonly(),r.show()});h(this,"handleCommentItemCancel",(t,e)=>{const o=t.findCommentItem(e);d(ca,o,`the commentItem: ${e} not exist `);const r=this.commentsProvider.getComment(o.comment.id);if(xl(r.doc)){this.commentsProvider.localDeleteComment(o.comment.id);return}const{quickReply:i}=t,s=o.getCommentEditor();s.setDoc(o.doc),s.readonly(),i.show()});h(this,"handleCommentItemEdit",t=>{const e=this.groupList.findItem(t.comment.groupId);if(!e)return;const{quickReply:o}=e;t.getCommentEditor().edit(),o.hide()});h(this,"handleCommentItemDelete",t=>{const e=this.groupList.findItem(t.comment.groupId);if(!e)return;const{quickReply:o}=e,{comment:r}=t;this.commentsProvider.localDeleteComment(r.id),o.show()});h(this,"execute",(t,e,o,r)=>{const i=pO(t);if(!i||bO(i))return;const s=CO(i);switch(s){case mt.SwitchUp:this.handleSwitchUp(r);break;case mt.SwitchDown:this.handleSwitchDown(r);break;case mt.CommentItemReply:this.handleCommentItemReply(e,o);break;case mt.CommentItemMore:this.handleCommentItemMore(e);break;case mt.CommentItemOk:this.handleCommentItemOk(e,o);break;case mt.CommentItemCancel:this.handleCommentItemCancel(e,o);break;case mt.CommentItemDelete:break;case mt.CommentItemEdit:break;case mt.QuickReply:this.handleQuickReply(e);break;case mt.QuickReplyOk:this.handleQuickReplyOk(e);break;case mt.QuickReplyCancel:this.handleQuickReplyCancel(e);break;default:const l=s;ca.debug(`not implement handler for ${l}`)}});this.groupList=t,this.commentsProvider=e}destroy(){}}const aa=y("comment-group-list");class NO extends Os{constructor(e,o,r){super(e,o,r,Co(e,o),{});h(this,"groupItemHandlers");h(this,"findGroupItem",e=>this.items.find(o=>o.comment.groupId===e));h(this,"handleContainerClick",e=>{if(!e.target||!(e.target instanceof Element))return;const o=e.target.closest(".comment-group-item-root");if(!o)return;const r=gO(e.target),i=this.items.findIndex(s=>s.root===o);if(i!==-1){this.setActiveItem(i);const{groupItemHandlers:s}=this;s.execute(e.target,this.items.at(i),r,i)}});h(this,"handleSelectionChanged",()=>{const e=wO(this.editor);if(e.length>0){const o=e[0],r=this.items.findIndex(i=>i.comment.groupId===o);this.setActiveItem(r),this.emit("selectionOnComment")}else this.setActiveItem(-1)});h(this,"handleEditorResize",()=>{this.updateItemsLayout()});h(this,"handleDocChanged",()=>{this.updateComments()});h(this,"handleItemResize",()=>{this.updateItemsLayout()});h(this,"updateGroupItemSwitch",()=>{const e=this.activeItem;d(aa,e,"invalid activeItem"),e.updateSwitchButton()});h(this,"updateComments",ie.default(()=>{const e=Co(this.editor,this.commentsProvider);let o=!1;for(let r=0;r<e.length;r++){const i=e[r];if(!this.findGroupItem(i.groupId)){this.handleCreateComment(i,!1),o=!0;continue}}for(let r=this.items.length-1;r>=0;r--){const i=this.items[r];e.findIndex(s=>s.groupId===i.comment.groupId)===-1&&(this.deleteItem(i.comment.id),o=!0)}o&&(this.updateItemsLayout(),this.emit("commentCountChanged"))},100));this.updateItemsLayout(),this.bindEvents(),this.editor.addListener("selectionChanged",this.handleSelectionChanged),this.editor.addListener("resize",this.handleEditorResize),this.editor.addListener("docChanged",this.handleDocChanged),this.items.forEach(i=>i.addListener("resize",this.handleItemResize)),this.groupItemHandlers=new _O(this,o)}destroy(){this.editor.removeListener("selectionChanged",this.handleSelectionChanged),this.editor.removeListener("resize",this.handleEditorResize),this.editor.removeListener("docChanged",this.handleDocChanged),super.destroy(),this.unbindEvents(),this.removeAllListeners()}updateItemsLayout(){OO(this.editor,this.items,this.activeItem)}bindEvents(){this.container.addEventListener("click",this.handleContainerClick)}unbindEvents(){this.container.removeEventListener("click",this.handleContainerClick)}createItem(e,o){const r=new AO(this.editor,this.commentsProvider,e,this);return o==="insert"&&(M(r.root,"no-animation"),r.root.style.opacity="0",setTimeout(()=>{F(r.root,"no-animation"),r.root.style.opacity="1"},150)),r}findInsertPos(e){const r=Co(this.editor,this.commentsProvider).findIndex(i=>i.id===e.id);return r===-1||r>this.items.length?-1:r}insertItem(e){const o=super.insertItem(e);return o?(this.setActiveItem(this.items.indexOf(o)),this.updateItemsLayout(),o.addListener("resize",this.handleItemResize),o):null}setActiveItem(e){if(d(aa,e>=-1&&e<this.items.length,`invalid index: ${e}`),e===this.activeIndex)return;const o=this.container.querySelector(".comment-group-item-root.active");if(o&&F(o,"active"),e!==-1){const r=this.items[e];M(r.root,"active"),this.updateItemsLayout(),this.updateGroupItemSwitch()}this.emit("activeItemChanged",e)}get activeIndex(){const e=this.container.querySelector(".comment-group-item-root.active");return e?this.items.findIndex(o=>o.root===e):-1}get activeItem(){const e=this.activeIndex;return e===-1?null:this.items[e]}handleCreateComment(e,o){if(rr(e)){const l=this.findGroupItem(e.groupId);l&&l.childrenList.insertItem(e)}const r=this.findItem(e.id);d(aa,!r,"comment group item has already exists");const i={children:[],...e};d(aa,i.children,"not a comment group");const s=this.insertItem(i);!s||o&&setTimeout(()=>{const l=this.items.indexOf(s);this.setActiveItem(l),s.edit(),s.quickReply.hide()})}handleDeleteComment(e){for(let o=0;o<this.items.length;o++){const r=this.items[o];if(r.comment.id===e){r.childrenList.items.length===0?this.deleteItem(r.comment.id):r.deleteMainComment(e);return}if(r.childrenList.deleteItem(e)){r.commentCount===0&&this.deleteItem(r.comment.id);return}}}handleUpdateComment(e){if(rr(e)){const r=this.commentsProvider.getComment(e.groupId),i=this.findItem(r.id);i&&i.handleUpdateChildComment(e);return}const o=this.findItem(e.id);o&&o.handleUpdateMainComment(e)}}const PO="comment-mini";y("comment-list");class $O extends Wt.TypedEmitter{constructor(e,o,r){super();h(this,"root");h(this,"groupsContainer");h(this,"list");h(this,"handleSelectionOnComment",()=>{this.emit("onSelectComment")});h(this,"updateCommentCount",()=>{var o,r;const e=yO(this.editor,this.commentsProvider);(r=(o=this.commentOptions)==null?void 0:o.onCommentCountChange)==null||r.call(o,e)});h(this,"handleActiveItemChanged",()=>{var o;const e=this.list.activeItem;e&&Ei(e.root),v3(this.editor,(o=e==null?void 0:e.comment.id)!=null?o:"")});h(this,"handleItemLayoutUpdated",()=>{var o,r;const e=lt(this.root,PO);(r=(o=this.commentOptions)==null?void 0:o.onUpdateLayout)==null||r.call(o,this.editor,{expand:e})});this.editor=e,this.commentsProvider=o,this.root=b("div",["editor-web-comment-root"],r),this.groupsContainer=b("div",["comment-groups-container"],this.root),this.list=this.createList(),this.commentsProvider.addListener(this),this.list.addListener("activeItemChanged",this.handleActiveItemChanged),this.list.addListener("itemLayoutUpdated",this.handleItemLayoutUpdated),this.list.addListener("selectionOnComment",this.handleSelectionOnComment),this.list.addListener("commentCountChanged",this.updateCommentCount),this.updateCommentCount()}get commentOptions(){return this.editor.getComponentOptions("comment")}destroy(){this.list.removeAllListeners(),this.commentsProvider.removeListener(this),this.list.destroy(),this.root.remove()}onCreateComment(e,o){const r=this.commentsProvider.getComment(e);this.list.handleCreateComment(r,o),this.updateCommentCount()}onDeleteComment(e,o){this.list.handleDeleteComment(e),this.updateCommentCount()}onUpdateComment(e,o){const r=this.commentsProvider.getComment(e);this.list.handleUpdateComment(r)}createList(){return new NO(this.editor,this.commentsProvider,this.groupsContainer)}show(e){var o;if(F(this.root,"hidden"),e){const r=this.list.findItemIndex(e);this.list.setActiveItem(r)}(o=this.commentOptions)==null||o.controller.showCommentList()}hide(){M(this.root,"hidden")}}class HO extends Os{constructor({editor:t,parent:e,commentsProvider:o,comments:r}){super(t,o,e,r,{})}findInsertPos(){return this.items.length}createItem(t){const{editor:e,commentsProvider:o}=this;return new B3(e,o,t)}destroy(){this.items.forEach(t=>{t.destroy()})}}const da=y("mobile-comment-group-item"),jO=20;class FO extends Wt.TypedEmitter{constructor(e,o,r){super();h(this,"root");h(this,"childrenList");h(this,"mainItem");h(this,"scroller");h(this,"createRoot",()=>b("div",["mobile-group-item-root"],null));h(this,"createMainItem",e=>{const{editor:o,commentsProvider:r,comment:i}=this,s=new B3(o,r,i);return e.append(s.root),s});h(this,"createChildrenList",e=>{const{editor:o,commentsProvider:r,comment:i}=this,s=b("div",["mobile-comment-children-list-container"],e);return new HO({editor:o,commentsProvider:r,comments:i.children,parent:s})});h(this,"handleTouchEnd",()=>{var i;const{scroller:e}=this,{pullThreshold:o=jO}=(i=this.editor.getComponentOptions("comment"))!=null?i:{};let r=null;if(e.y>e.minScrollY+o?(r=this.root.previousElementSibling,r||this.emit("onReachTop")):e.y<e.maxScrollY-o&&(r=this.root.nextElementSibling,r||this.emit("onReachBottom")),r){const s=r.id;this.emit("onSwitchGroup",s,h3)}});h(this,"refreshScroller",()=>{this.scroller.refresh()});this.editor=e,this.commentsProvider=o,this.comment=r,this.root=b("div",["mobile-group-item-root"],null),this.root.id=r.groupId;const i=b("div",["mobile-group-item"],this.root),s=b("div",["mobile-group-item-space"],null),l=b("div",["mobile-group-item-abstract"],null);l.textContent=r.abstract;const c=b("div",["mobile-group-item-list-container"],null);this.mainItem=this.createMainItem(c),this.childrenList=this.createChildrenList(c),i.append(s,l,c),this.scroller=new _f.default(this.root,{stopPropagation:!0,click:!0}),this.scroller.on("touchEnd",this.handleTouchEnd)}get commentCount(){return f3(this.root,".mobile-group-item")}handleUpdateChildComment(e){d(da,e.groupId===this.mainItem.comment.id,"invalid child comment");const o=this.childrenList.findItem(e.id);if(!o){da.error(`can't find child comment item: ${e.id}`);return}o.reloadDoc()}handleUpdateMainComment(e){d(da,e.id===this.mainItem.comment.id,"invalid comment"),this.mainItem.reloadDoc()}deleteMainComment(e){d(da,e===this.mainItem.comment.id,"invalid comment"),this.mainItem.destroy()}destroy(){this.mainItem.destroy(),this.childrenList.destroy(),this.scroller.off("touchEnd",this.handleTouchEnd),this.scroller.destroy(),this.root.remove(),this.removeAllListeners()}}const Yh=y("mobile-group-list");class zO extends Os{constructor(e,o,r,i){super(e,o,r,Co(e,o),{});h(this,"scroller");h(this,"deleteItem",e=>{if(this.items.length<=1)return super.deleteItem(e);const o=this.findItemIndex(e);let r=null;return o===0?r=this.items[o+1].root.id:r=this.items[o-1].root.id,super.deleteItem(e)?(this.scrollToGroup(r,h3),!0):!1});h(this,"setupGroupItem",e=>{e.on("onSwitchGroup",this.scrollToGroup),e.on("onReachBottom",this.handleReachBottom),e.on("onReachTop",this.handleReachTop),e.refreshScroller()});h(this,"handleReachBottom",()=>{this.emit("onReachBottom")});h(this,"handleReachTop",()=>{this.emit("onReachTop")});h(this,"scrollToGroup",(e,o=0)=>{const r=this.findGroupItem(e);d(Yh,r,"invalid scroll target"),this.scroller.scrollToElement(r.root,o,!1,!1),v3(this.editor,r.comment.id)});h(this,"findGroupItem",e=>this.items.find(o=>o.comment.groupId===e));h(this,"handleDocChanged",()=>{this.updateComments()});h(this,"updateComments",ie.default(()=>{const e=Co(this.editor,this.commentsProvider);for(let o=0;o<e.length;o++){const r=e[o];if(!this.findGroupItem(r.groupId)){this.handleCreateComment(r,!1);continue}}for(let o=this.items.length-1;o>=0;o--){const r=this.items[o];e.findIndex(i=>i.groupId===r.comment.groupId)===-1&&this.deleteItem(r.comment.id)}},100));this.scroller=new _f.default(i),this.scroller.disable(),this.editor.addListener("docChanged",this.handleDocChanged),this.items.forEach(this.setupGroupItem)}createItem(e){return new FO(this.editor,this.commentsProvider,e)}insertItem(e){const o=super.insertItem(e);return o?(this.setupGroupItem(o),o):null}findInsertPos(e){const r=Co(this.editor,this.commentsProvider).findIndex(i=>i.id===e.id);return r===-1||r>this.items.length?-1:r}setActiveItem(e){this.scrollToGroup(e)}handleCreateComment(e,o){if(rr(e)){const s=this.findGroupItem(e.groupId);s&&s.childrenList.insertItem(e)}const r=this.findItem(e.id);d(Yh,!r,"comment group item has already exists");const i={children:[],...e};d(Yh,i.children,"not a comment group"),this.insertItem(i),this.scroller.refresh()}handleDeleteComment(e){for(let o=0;o<this.items.length;o++){const r=this.items[o];if(r.comment.id===e){r.childrenList.items.length===0?this.deleteItem(r.comment.id):r.deleteMainComment(e);return}if(r.childrenList.deleteItem(e)){r.commentCount===0&&this.deleteItem(r.comment.id);return}}}handleUpdateComment(e){if(rr(e)){const r=this.commentsProvider.getComment(e.groupId),i=this.findItem(r.id);i&&i.handleUpdateChildComment(e);return}const o=this.findItem(e.id);o&&o.handleUpdateMainComment(e)}destroy(){this.editor.removeListener("docChanged",this.handleDocChanged),this.scroller.destroy(),this.items.forEach(e=>e.destroy())}}const UO=y("mobile-comment-list"),{t:S3}=S;class VO extends Wt.TypedEmitter{constructor(e,o,r){super();h(this,"root");h(this,"list");h(this,"mask");h(this,"pullInfoContainer");h(this,"handleRootClick",e=>{const o=e.target;d(UO,o instanceof Element,"invalid target"),!(o.closest(".mobile-group-item-abstract")||o.closest(".mobile-group-item-list-container"))&&(this.hide(),this.emit("onCommentListClose"))});h(this,"hidePullInfo",ie.default(()=>{F(this.pullInfoContainer,"active")},1e3*3));h(this,"handleReachBottom",()=>{this.showPullInfo("bottom")});h(this,"handleReachTop",()=>{this.showPullInfo("top")});h(this,"show",e=>{F(this.root,"hidden"),M(document.documentElement,"disabled-scroll"),e&&this.list.setActiveItem(e)});h(this,"hide",()=>{M(this.root,"hidden"),F(document.documentElement,"disabled-scroll")});this.editor=e,this.commentsProvider=o,this.root=b("div",["editor-mobile-comments-root"],r),this.mask=b("div",["mobile-comment-mask"],this.root);const i=b("div",["mobile-comment-groups-container"],this.root),s=b("div",["mobile-comment-groups-scroll-container"],i);this.list=new zO(this.editor,this.commentsProvider,s,i),this.pullInfoContainer=this.createPullInfo(),this.commentsProvider.addListener(this),this.list.on("onReachBottom",this.handleReachBottom),this.list.on("onReachTop",this.handleReachTop),this.root.onclick=this.handleRootClick}onCreateComment(e,o){const r=this.commentsProvider.getComment(e);this.list.handleCreateComment(r,o)}onDeleteComment(e,o){this.list.handleDeleteComment(e)}onUpdateComment(e,o){const r=this.commentsProvider.getComment(e);this.list.handleUpdateComment(r)}createPullInfo(){const e=b("div",["mobile-comment-pull-info-container"],this.root);return b("div",["mobile-comment-pull-info"],e),e}showPullInfo(e){const o=S3(e==="bottom"?"comment.isLast":"comment.isFirst");this.pullInfoContainer.firstElementChild.textContent=o,M(this.pullInfoContainer,"active"),this.hidePullInfo()}destroy(){this.list.removeAllListeners(),this.list.destroy(),this.root.onclick=null}}function T3(n,t){const e=Co(n,t),o=new Map;for(const r of e){const i=m3(n,r.groupId);if(!!i)if(o.has(i)){const s=o.get(i);Vh(r).forEach(c=>{s==null||s.commentIds.add(c.id)})}else{const s=Vh(r),l=new Set(s.map(c=>c.id));o.set(i,{commentIds:l,firstComment:r})}}return Array.from(o.entries()).map(([r,i])=>({blockId:r,...i}))}const qO=y("mini-group-item");class WO{constructor(t,e){h(this,"root");h(this,"blockId");h(this,"comment");h(this,"miniCommentItem");h(this,"updateCommentItemCount",()=>{this.miniCommentItem.updateCount(this.commentCount)});this.editor=t,this.commentGroup=e,this.root=b("div",["mini-group-item"],null),this.comment=e.firstComment,this.miniCommentItem=new TO(this.comment.id,this.root),this.blockId=this.getBlockId(),this.alignToBlock(),this.updateCommentItemCount()}getBlockId(){return m3(this.editor,this.comment.groupId)}get commentCount(){return this.commentGroup.commentIds.size}alignToBlock(){const t=this.getBlockId(),e=this.editor.getBlockById(t);d(qO,e,`The blockId: ${t} not exist in doc`);const o=this.editor.scrollContainer.getBoundingClientRect(),i=e.getBoundingClientRect().top-o.top;requestAnimationFrame(()=>{this.root.style.transform=`translateY(${i}px)`})}destroy(){this.root.remove()}}class GO extends Os{constructor(e,o,r){super(e,o,r,T3(e,o),{});h(this,"handleDocChanged",ie.default(()=>{this.updateMiniCommentsGroup()},100));h(this,"updateMiniCommentsGroup",()=>{const e=T3(this.editor,this.commentsProvider);this.reloadList(e)});this.editor=e,this.commentsProvider=o,this.editor.addListener("docChanged",this.handleDocChanged)}createItem(e){return new WO(this.editor,e)}findInsertPos(){return-1}handleCreateComment(e,o){this.updateMiniCommentsGroup()}handleDeleteComment(e){this.updateMiniCommentsGroup()}destroy(){this.editor.removeListener("docChanged",this.handleDocChanged),super.destroy(),this.removeAllListeners()}}const ZO=y("mini-comments-list");class YO extends Wt.TypedEmitter{constructor(e,o,r){super();h(this,"list");h(this,"root");h(this,"createList",()=>{const e=b("div",["comment-groups-container"],this.root);return this.editor.domEvents.addEventListener(e,"click",this.handleListContainerClick),new GO(this.editor,this.commentsProvider,e)});h(this,"handleListContainerClick",(e,o)=>{const r=o.target;d(ZO,r instanceof HTMLElement,"The target is not a valid html element");const i=r.closest(".mini-comment-item");i&&this.emit("onItemClick",i.id)});this.editor=e,this.commentsProvider=o,this.root=b("div",["editor-mini-comment-root"],r),this.list=this.createList(),this.commentsProvider.addListener(this)}onCreateComment(e,o){const r=this.commentsProvider.getComment(e);this.list.handleCreateComment(r,o)}onDeleteComment(e,o){this.list.handleDeleteComment(e)}onUpdateComment(e,o){}show(){F(this.root,"hidden")}hide(){M(this.root,"hidden")}destroy(){this.list.destroy(),this.removeAllListeners()}}function D3(n,t,e){if(!t.start.isSimple()||!t.end.isSimple())return;const o=t.block,r=Ot(n,o,t.start.offset,t.end.offset),i=`comment-${e.id.toLocaleLowerCase()}`,s=e.id;B2(n,o,r,i,s)}function QO(n,t,e){const o=Qe(n).map(s=>s.block),r=zh(n,o),i=ra({editor:n,abstract:r});return n.undoManager.runInGroup(()=>{Qe(n,{simpleBlockOnly:!0}).forEach(c=>{!j(n,c.block)||D3(n,c,i)});const l=oo();e.localCreateComment(i,l)}),i}class KO{constructor(t,e){h(this,"id","CommentsCommandProvider");this.provider=t,this.editorComments=e}getAvailableCommands(t,e,o){const r=t.selection.range;if(j(t,e)&&!o.isCollapsed()&&r.isSimple()){const i=G(e),s=it(e),l=We(t,e);return[{id:"add-comment",name:"Add comment",blockId:i,blockType:s,blockKind:l,groupIndex:1e3,icon:$r}]}return[]}executeRangeCommand(t,e,o,r,i){if(o.id==="add-comment"){this.editorComments.showCommentList();const s=QO(t,e,this.provider);return i["add-comment"]=s,!0}return!1}}class JO{constructor(t,e){h(this,"commentList",null);h(this,"mobileCommentList",null);h(this,"miniCommentList");h(this,"showComment",(t,e)=>{var o,r;t==="mini"&&this.miniCommentList.show(),t==="mobile"&&((o=this.mobileCommentList)==null||o.show(e)),t==="web"&&((r=this.commentList)==null||r.show(e))});h(this,"showCommentList",t=>{this.isMobile?this.showComment("mobile",t):this.showComment("web",t)});h(this,"handleCommentListClose",()=>{this.showComment("mini")});h(this,"handleOnSelectComment",()=>{this.showComment("web")});h(this,"handleMiniCommentItemClick",t=>{this.showCommentList(t)});this.editor=t,this.provider=e,t.editorCommandProviders.registerCommandProvider(new KO(e,this)),t.addCustom("block-comment-button",()=>new mO(t,e,this)),t.blockHooks.push(new uO(this.provider,this)),this.isMobile?(this.mobileCommentList=new VO(this.editor,this.provider,this.getCommentRoot("mobileContainer")),this.mobileCommentList.on("onCommentListClose",this.handleCommentListClose)):(this.commentList=new $O(this.editor,this.provider,this.getCommentRoot("container")),this.commentList.on("onSelectComment",this.handleOnSelectComment)),this.miniCommentList=new YO(this.editor,this.provider,this.getCommentRoot("miniContainer")),this.miniCommentList.on("onItemClick",this.handleMiniCommentItemClick)}get commentOptions(){return this.editor.getComponentOptions("comment")}get commentProvider(){return this.provider}get isMobile(){return It.isMobile}getCommentRoot(t){var e,o;return(o=(e=this.commentOptions)==null?void 0:e[t])!=null?o:document.body}destroy(){var t,e;(t=this.commentList)==null||t.destroy(),(e=this.mobileCommentList)==null||e.destroy(),this.miniCommentList.destroy()}}const XF="",XO={comment:{count:"\u6279\u6CE8 ({num})",hide:"\u9690\u85CF\u6279\u6CE8",show:"\u663E\u793A\u6279\u6CE8",reply:"\u56DE\u590D",quicklyReply:"\u56DE\u590D...",send:"\u786E\u8BA4",placeholder:"\u6DFB\u52A0\u6279\u6CE8...",replyPlaceholder:"\u56DE\u590D\u6216@\u4ED6\u4EBA",edit:"\u7F16\u8F91",delete:"\u5220\u9664",image:"\u56FE\u7247",sendTitle:"\u6309Enter\u53D1\u9001\u6279\u6CE8",replyTitle:"\u6309Enter\u56DE\u590D\u6279\u6CE8",isFirst:"\u5DF2\u7ECF\u662F\u7B2C\u4E00\u6761\u6279\u6CE8",isLast:"\u5DF2\u7ECF\u662F\u6700\u540E\u4E00\u6761\u6279\u6CE8",comment:"\u6279\u6CE8"}},t_={comment:{count:"Comments ({num})",hide:"Hide Comments",show:"Show Comments",reply:"Reply",quicklyReply:"Reply...",send:"OK",placeholder:"Add a comment...",replyPlaceholder:"Add Comments or @ others",edit:"Edit",delete:"Delete",image:"Image",sendTitle:"Press Enter to send comment",replyTitle:"Press Enter to reply comment",isFirst:"\u5DF2\u7ECF\u662F\u7B2C\u4E00\u6761\u6279\u6CE8",isLast:"\u5DF2\u7ECF\u662F\u6700\u540E\u4E00\u6761\u6279\u6CE8",more:"more",comment:"Comment"}},e_={comment:{count:"\u30B3\u30E1\u30F3\u30C8 ({num})",hide:"\u30B3\u30E1\u30F3\u30C8\u3092\u975E\u8868\u793A",show:"\u30B3\u30E1\u30F3\u30C8\u3092\u8868\u793A",reply:"\u8FD4\u4FE1",quicklyReply:"\u8FD4\u4FE1...",send:"\u9001\u4FE1",placeholder:"\u30B3\u30E1\u30F3\u30C8\u3092\u8FFD\u52A0...",replyPlaceholder:"\u8FD4\u4FE1\u307E\u305F\u306F\u30E1\u30F3\u30B7\u30E7\u30F3(@)",edit:"\u7DE8\u96C6",delete:"\u524A\u9664",image:"\u753B\u50CF",sendTitle:"Enter\u3092\u62BC\u3057\u3066\u30B3\u30E1\u30F3\u30C8\u3092\u9001\u4FE1",replyTitle:"Enter\u3092\u62BC\u3057\u3066\u30B3\u30E1\u30F3\u30C8\u3092\u8FD4\u4FE1",isFirst:"\u6700\u521D\u306E\u30B3\u30E1\u30F3\u30C8\u3067\u3059",isLast:"\u6700\u5F8C\u306E\u30B3\u30E1\u30F3\u30C8\u3067\u3059",comment:"\u30B3\u30E1\u30F3\u30C8\u3092"}};S.mergeLang({"zh-CN":XO,"en-US":t_,"ja-JP":e_});class L3{renderText(t,e,o){const r=[],i={};return Object.entries(o).forEach(([s,l])=>{s.startsWith("comment-")&&(r.push("comment"),i[s]=l)}),{classes:r,attributes:i}}renderBlock(t,e,o){const r=o.comments;if(!r||r.length===0)return{};const i=["comment"],s={};return r.forEach(l=>{s[`comment-${l.toLocaleLowerCase()}`]=l}),{classes:i,attributes:s}}updateBlock(t,e,o,r){const i=r.comments;F(o,"comment"),Array.from(o.attributes).forEach(s=>{s.name.startsWith("comment-")&&o.removeAttribute(s.name)}),!(!i||i.length===0)&&(M(o,"comment"),i.forEach(s=>{o.setAttribute(`comment-${s.toLocaleLowerCase()}`,s)}))}}class n_{constructor(t){h(this,"handleUpdateCompositionText",(t,e,o,r,i)=>{const s=t.getFocusedBlock(),l=t.getFirstBlock();s===l&&this.applyPlaceholder(t)});h(this,"handleSelectionChange",t=>{this.applyPlaceholder(t)});h(this,"applyPlaceholder",t=>{const e=t.getFirstBlock();jc(t,e,S.t("comment.replyPlaceholder"))});this.applyPlaceholder(t),t.addListener("selectionChanged",this.handleSelectionChange)}}function o_(n,t,e){const o=n.getBlockData(t),r=o.comments;if((r==null?void 0:r.indexOf(e))!==-1){const s=new Set(r);s.delete(e),n.updateBlockData(t,{comments:Array.from(s)})}const i=o.text;if(!!i&&j(n,t)){const s=N1(i,`comment-${e.toLocaleLowerCase()}`,e);n.setBlockText(t,s)}}const r_=y("editor-comment");function i_(n){const t=n.getCustom("editor-comments");if(d(r_,t,"the editor comment not exist"),t.showCommentList(),n.selection.range.isCollapsed()){const s=n.selection.startBlock,l=Ro(s);if(l.length>=2){const{containerId:c}=l.at(-1),a=z(br(n,c));if(a&&it(a)==="code"){ia(n,a,t.commentProvider);return}}ia(n,s,t.commentProvider);return}const e=Qe(n,{simpleBlockOnly:!0}),o=e.map(s=>s.block),r=zh(n,o),i=ra({editor:n,abstract:r});n.undoManager.runInGroup(()=>{e.forEach(l=>{j(n,l.block)?D3(n,l,i):d3(n,l.block,i)});const s=oo();t.commentProvider.localCreateComment(i,s)})}const Qh=y("text-styles");function s_(n){const t=o=>{if(!o.attributes)return new Map;const r=Object.entries(o.attributes).filter(([i])=>!!i.startsWith("style-"));return new Map(r)};if(n.length===0)return new Map;let e=t(n[0]);for(let o=1;o<n.length;o++){const r=t(n[o]);e=new Map(Array.from(e.entries()).filter(([i,s])=>r.get(i)===s))}return e}function l_(n,t,e,o,r){d(Qh,e.isSimple(),"invalid range");const{start:i,end:s}=e;d(Qh,i.blockId===s.blockId&&i.blockId===G(t),"invalid range"),d(Qh,o.startsWith("style-"),"invalid style");let c=n.getBlockText(t);return o==="style-subscript"?c=Sr(i.offset,s.offset-i.offset,c,"style-superscript",void 0,{ignoreValue:!0}):o==="style-superscript"&&(c=Sr(i.offset,s.offset-i.offset,c,"style-subscript",void 0,{ignoreValue:!0})),r===!1||r===void 0||r===null?c=Sr(i.offset,s.offset-i.offset,c,o,void 0,{ignoreValue:!0}):c=wl(i.offset,s.offset-i.offset,c,o,r),n.setBlockText(t,c),c}const c_=`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
647
647
  <path fill="currentColor" fill-rule="evenodd" clip-rule="evenodd" d="M13.3236 18.5C14.2519 18.5 15.0547 18.3458 15.7318 18.0374C16.409 17.729 16.9352 17.2951 17.3103 16.7355C17.6855 16.176 17.8731 15.521 17.8731 14.7707C17.8731 14.1857 17.738 13.6628 17.4677 13.2018C17.1975 12.7408 16.8271 12.372 16.3566 12.0954C15.886 11.8188 15.3424 11.6646 14.7256 11.6328V11.5565C15.4823 11.4548 16.0959 11.1464 16.5664 10.6313C17.0369 10.1163 17.2722 9.49633 17.2722 8.77146C17.2722 7.76045 16.9082 6.96246 16.1801 6.37748C15.4521 5.79249 14.4522 5.5 13.1805 5.5H8.57373C8.07777 5.5 7.69149 5.63989 7.41489 5.91966C7.1383 6.19944 7 6.59367 7 7.10235V16.8977C7 17.4063 7.1383 17.8006 7.41489 18.0803C7.69149 18.3601 8.07777 18.5 8.57373 18.5H13.3236ZM12.0073 10.8793H10.1379V7.68415H12.2076C12.8308 7.68415 13.3172 7.82086 13.6669 8.09428C14.0166 8.36769 14.1915 8.74921 14.1915 9.23881C14.1915 9.75385 13.9976 10.156 13.6097 10.4453C13.2218 10.7347 12.6877 10.8793 12.0073 10.8793ZM10.1379 16.3349H12.3412C13.1042 16.3349 13.686 16.1839 14.0866 15.8819C14.4872 15.5798 14.6875 15.1363 14.6875 14.5514C14.6875 13.9791 14.4776 13.5435 14.058 13.2447C13.6383 12.9458 13.0406 12.7964 12.2649 12.7964H10.1379V16.3349Z" />
648
648
  </svg>`,a_=`<svg width="24" height="24" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
649
649
  <path fill="currentColor" d="M13.5668 18.5C13.8023 18.5 13.9979 18.4316 14.1538 18.2948C14.3097 18.158 14.3877 17.9687 14.3877 17.7269C14.3877 17.4978 14.3129 17.3149 14.1634 17.178C14.0138 17.0412 13.8182 16.9728 13.5764 16.9728H11.6483L13.7959 7.02717H15.7048C15.9466 7.02717 16.1439 6.95876 16.2966 6.82195C16.4493 6.68514 16.5257 6.49584 16.5257 6.25404C16.5257 6.0186 16.4509 5.83407 16.3014 5.70044C16.1519 5.56681 15.9562 5.5 15.7144 5.5H9.94934C9.7139 5.5 9.51982 5.56681 9.36711 5.70044C9.21439 5.83407 9.13803 6.0186 9.13803 6.25404C9.13803 6.49584 9.21598 6.68514 9.37188 6.82195C9.52778 6.95876 9.72345 7.02717 9.95888 7.02717H11.8869L9.73935 16.9728H7.81131C7.56951 16.9728 7.37384 17.0412 7.2243 17.178C7.07477 17.3149 7 17.4978 7 17.7269C7 17.9687 7.07636 18.158 7.22907 18.2948C7.38179 18.4316 7.57905 18.5 7.82085 18.5H13.5668Z" />
@@ -686,7 +686,7 @@ width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
686
686
  <g id="" stroke="none" stroke-width="1" fill-rule="evenodd">
687
687
  <path stroke="currentColor" d="M19.284802,16.9726267 C19.4891443,16.9726267 19.6594295,17.0421598 19.7956577,17.1812261 C19.9318859,17.3202923 20,17.4891585 20,17.6878246 C20,17.8921669 19.9318859,18.0624521 19.7956577,18.1986803 C19.6594295,18.3349085 19.4891443,18.4030226 19.284802,18.4030226 L19.284802,18.4030226 L4.71519796,18.4030226 C4.51653186,18.4030226 4.34766567,18.3349085 4.2085994,18.1986803 C4.06953313,18.0624521 4,17.8921669 4,17.6878246 C4,17.4891585 4.06953313,17.3202923 4.2085994,17.1812261 C4.34766567,17.0421598 4.51653186,16.9726267 4.71519796,16.9726267 L4.71519796,16.9726267 Z M18.2486798,8.56372925 C18.8324532,8.56372925 19.2702832,8.70711219 19.5621699,8.99387807 C19.8540566,9.28064395 20,9.71335319 20,10.2920058 L20,10.2920058 L20,13.1033356 C20,13.6819882 19.8540566,14.1159776 19.5621699,14.4053039 C19.2702832,14.6946302 18.8324532,14.8392933 18.2486798,14.8392933 L18.2486798,14.8392933 L5.75132021,14.8392933 C5.16754681,14.8392933 4.72971675,14.6946302 4.43783005,14.4053039 C4.14594335,14.1159776 4,13.6819882 4,13.1033356 L4,13.1033356 L4,10.2920058 C4,9.71335319 4.14594335,9.28064395 4.43783005,8.99387807 C4.72971675,8.70711219 5.16754681,8.56372925 5.75132021,8.56372925 L5.75132021,8.56372925 Z M18.1027364,9.81576957 L5.88958233,9.81576957 C5.68474956,9.81576957 5.52728437,9.86953818 5.41718675,9.97707538 C5.30708913,10.0846126 5.25204033,10.2459184 5.25204033,10.4609928 L5.25204033,10.4609928 L5.25204033,12.9343485 C5.25204033,13.149423 5.30708913,13.3107288 5.41718675,13.418266 C5.52728437,13.5258032 5.68474956,13.5795718 5.88958233,13.5795718 L5.88958233,13.5795718 L18.1027364,13.5795718 C18.3075692,13.5795718 18.4650344,13.5258032 18.575132,13.418266 C18.6852296,13.3107288 18.7402784,13.149423 18.7402784,12.9343485 L18.7402784,12.9343485 L18.7402784,10.4609928 C18.7402784,10.2459184 18.6852296,10.0846126 18.575132,9.97707538 C18.4650344,9.86953818 18.3075692,9.81576957 18.1027364,9.81576957 L18.1027364,9.81576957 Z M19.284802,5 C19.4891443,5 19.6594295,5.06953313 19.7956577,5.2085994 C19.9318859,5.34766567 20,5.51653186 20,5.71519796 C20,5.91954023 19.9318859,6.08982546 19.7956577,6.22605364 C19.6594295,6.36228182 19.4891443,6.43039591 19.284802,6.43039591 L19.284802,6.43039591 L4.71519796,6.43039591 C4.51653186,6.43039591 4.34766567,6.36228182 4.2085994,6.22605364 C4.06953313,6.08982546 4,5.91954023 4,5.71519796 C4,5.51653186 4.06953313,5.34766567 4.2085994,5.2085994 C4.34766567,5.06953313 4.51653186,5 4.71519796,5 L4.71519796,5 Z" fill-rule="nonzero"></path>
688
688
  </g>
689
- </svg>`,tz="";y("file-box");function _3(n,t){const e=n.getBoxData(t),o=n.doc.buildResourceUrl(e.src,{downloadFileName:e.fileName});ll(o,e.fileName)}class w_{constructor(){h(this,"group","file-box-commands");h(this,"commands",[{id:"download",name:"Download",icon:Kh},{id:"to-link",name:"To link",icon:A3,states:["checked"]},{id:"to-card",name:"To card",icon:O3}])}executeCommand(t,e,o,r){if(r.id==="to-card"){const i=H(e),s=V(i),l=K(e)+1,c=t.getBoxData(o),a=Er(e,o);t.undoManager.runInGroup(()=>{const u={src:c.src,previewType:R3.Card,fileName:c.fileName,fileSize:c.fileSize,fileType:c.fileType};a.start===0?Z(t,e)===1?(t.deleteBlock(e),t.insertEmbed(s,l-1,"office",u)):(t.deleteTextFromBlock(e,a.start,1),t.insertEmbed(s,l-1,"office",u)):a.start===Z(t,e)-1?(t.deleteTextFromBlock(e,a.start,1),t.insertEmbed(s,l,"office",u)):(t.deleteTextFromBlock(e,a.start,1),Pi(t,e,a.start,{forceInsertAfter:!0}),t.insertEmbed(s,l,"office",u))})}else r.id==="download"&&_3(t,o)}}function B_(n,t,e,o){const r=o,i=b("a",["file-container"],e),s=b("span",["file-icon"],i);s.innerHTML=y_,b("span",["file-name"],i,r.fileName),i.setAttribute("data-file-id",r.id),i.setAttribute("data-file-src",r.src)}function E_(n,t,e){const o=n.options.componentsOptions.file;if(o!=null&&o.onClick){o.onClick(n,t,e);return}_3(n,t)}function I_(n,t){return{boxCommands:{"hovering-toolbar":new w_}}}const N3={boxType:"file",updateBoxContent:B_,handleClickBox:E_,getBoxProperties:I_},x_=`<svg width="48" height="48" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
689
+ </svg>`,tz="";y("file-box");function _3(n,t){const e=n.getBoxData(t),o=n.doc.buildResourceUrl(e.src,{downloadFileName:e.fileName});ll(o,e.fileName)}class w_{constructor(){h(this,"group","file-box-commands");h(this,"commands",[{id:"download",name:"Download",icon:Kh},{id:"to-link",name:"To link",icon:A3,states:["checked"]},{id:"to-card",name:"To card",icon:O3}])}executeCommand(t,e,o,r){if(r.id==="to-card"){const i=H(e),s=U(i),l=K(e)+1,c=t.getBoxData(o),a=Er(e,o);t.undoManager.runInGroup(()=>{const u={src:c.src,previewType:R3.Card,fileName:c.fileName,fileSize:c.fileSize,fileType:c.fileType};a.start===0?Z(t,e)===1?(t.deleteBlock(e),t.insertEmbed(s,l-1,"office",u)):(t.deleteTextFromBlock(e,a.start,1),t.insertEmbed(s,l-1,"office",u)):a.start===Z(t,e)-1?(t.deleteTextFromBlock(e,a.start,1),t.insertEmbed(s,l,"office",u)):(t.deleteTextFromBlock(e,a.start,1),Pi(t,e,a.start,{forceInsertAfter:!0}),t.insertEmbed(s,l,"office",u))})}else r.id==="download"&&_3(t,o)}}function B_(n,t,e,o){const r=o,i=b("a",["file-container"],e),s=b("span",["file-icon"],i);s.innerHTML=y_,b("span",["file-name"],i,r.fileName),i.setAttribute("data-file-id",r.id),i.setAttribute("data-file-src",r.src)}function E_(n,t,e){const o=n.options.componentsOptions.file;if(o!=null&&o.onClick){o.onClick(n,t,e);return}_3(n,t)}function I_(n,t){return{boxCommands:{"hovering-toolbar":new w_}}}const N3={boxType:"file",updateBoxContent:B_,handleClickBox:E_,getBoxProperties:I_},x_=`<svg width="48" height="48" viewBox="0 0 18 18" fill="none" xmlns="http://www.w3.org/2000/svg">
690
690
  <path d="M12 1C13.5 2.5 14 3 16 5V15.6087C16 15.7914 15.9638 15.9723 15.8934 16.1411C15.8231 16.3099 15.7199 16.4633 15.5899 16.5925C15.4599 16.7217 15.3056 16.8242 15.1358 16.8941C14.9659 16.964 14.7838 17 14.6 17H3.4C3.21615 17 3.0341 16.964 2.86424 16.8941C2.69439 16.8242 2.54005 16.7217 2.41005 16.5925C2.28005 16.4633 2.17693 16.3099 2.10657 16.1411C2.03621 15.9723 2 15.7914 2 15.6087V2.3913C2 2.2086 2.03621 2.02768 2.10657 1.85888C2.17693 1.69007 2.28005 1.5367 2.41005 1.4075C2.54005 1.27831 2.69439 1.17583 2.86424 1.10591C3.0341 1.03599 3.21615 1 3.4 1H12Z" fill="#FFBE5A"/>
691
691
  <path fill-rule="evenodd" clip-rule="evenodd" d="M7.5 7.5V11.1H8.7C9.69411 11.1 10.5 10.2941 10.5 9.3C10.5 8.30589 9.69411 7.5 8.7 7.5H7.5ZM7 6C6.44772 6 6 6.44771 6 7V11.6C6 12.1523 6.44772 12.6 7 12.6H8.7C10.5225 12.6 12 11.1225 12 9.3C12 7.47746 10.5225 6 8.7 6H7Z" fill="white"/>
692
692
  <path d="M12 1L14 3L16 5H13.3333C12.9797 5 12.6406 4.84675 12.3905 4.57397C12.1405 4.30119 12 3.93122 12 3.54546V1Z" fill="#FFD89C"/>
@@ -739,6 +739,6 @@ width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
739
739
  <rect width="6" height="7" fill="white" transform="translate(6 6)"/>
740
740
  </clipPath>
741
741
  </defs>
742
- </svg>`,$3={dwg:[],rvt:[],skp:[],img:["image/png","image/jpg","image/jpeg","image/bmp","image/ico","image/icon","image/gif"],txt:["text/plain"],zip:["application/zip","application/x-rar-compressed","application/x-7z-compressed","application/x-tar","application/x-bzip2","application/java-archive"],ppt:["application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation"],excel:["application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],pdf:["application/pdf"],word:["application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"]},Jh={dwg:x_,rvt:S_,skp:T_,img:D_,txt:L_,zip:P3,rar:P3,ppt:M_,excel:R_,pdf:A_,word:O_};function N_(n,t){const e=Object.keys($3);for(let r=0;r<e.length;r+=1){const i=e[r];if($3[i].includes(t))return Jh[i]}const o=mm(n.toLowerCase());return Jh[o]?Jh[o]:__}function P_(n,t){const e=b("div",["card-root","embed-selected-content"],n),o=b("div",["file-icon"],e);o.innerHTML=N_(t.fileName,t.fileType);const r=b("div",["file-details"],e);b("div",["file-name"],r,t.fileName),b("div",["file-size"],r,vm(t.fileSize));const i=b("div",["file-actions"],e),s=b("button",["download"],i);return s.innerHTML=Kh,{card:e,downloadButton:s}}const ez="";function H3(n,t){const o=n.getBlockData(t).embedData,r=n.options.componentsOptions.file;if(r!=null&&r.onDownloadFile){r.onDownloadFile(n,o);return}const i=n.doc.buildResourceUrl(o.src,{downloadFileName:o.fileName});ll(i,o.fileName)}y("webpage-embed");function $_(n,t,e){const{embedData:o}=e,r=o,{card:i,downloadButton:s}=P_(t,r);n.domEvents.addEventListener(s,"click",(l,c)=>{if(!c.target)return;const a=z(c.target);!a||H3(l,a)}),n.domEvents.addEventListener(i,"click",(l,c)=>{if(!c.target)return;const a=z(c.target);if(!a||Bi(c,"button"))return;const u=l.options.componentsOptions.file;if(u!=null&&u.onClick){u.onClick(l,a,c);return}const m=l.getBlockData(a).embedData,C=l.doc.buildResourceUrl(m.src,{downloadFileName:m.fileName});ll(C,m.fileName)})}class H_{constructor(){h(this,"group","file-card");h(this,"commands",[{id:"download",name:"Download",icon:Kh},{id:"sep",name:"",type:"separator"},{id:"to-link",name:"To link",icon:A3},{id:"to-card",name:"To card",icon:O3,states:["checked"]},{id:"sep",name:"",type:"separator"},{id:"add-comment",name:"Add Comment",icon:$r}])}executeCommand(t,e,o){if(o.id==="to-link"){const r=H(e),i=V(r),s=K(e),l=t.getBlockData(e),{embedData:c}=l,a=c,u={id:N(),box:!0,type:"file",created:Date.now(),src:a.src,fileName:a.fileName,fileSize:a.fileSize,fileType:a.fileType};t.undoManager.runInGroup(()=>{t.deleteBlock(e);const f=[Tg(u)];t.insertTextBlock(f,i,s)})}else o.id==="download"?H3(t,e):o.id==="add-comment"&&ah(t,e)}}function j_(n,t){const e=n.getBlockData(t),{embedData:o,id:r}=e,i=o;return{blockCommands:{"hovering-toolbar":new H_},abstract:i.fileName}}const F_={embedType:"office",createEmbedContent:$_,getBlockProperties:j_},nz="",z_={media:{upload:{failed:'<div class="line-1">{name} \u4E0A\u4F20\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <a href="" class="retry-upload">\u91CD\u8BD5</a></div>'},load:{failed:'<div class="line-1">{name} \u52A0\u8F7D\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <a href="" class="retry-upload">\u91CD\u8BD5</a></div>'},audio:{menuItem:"\u97F3\u9891",abstract:"\u97F3\u9891"},video:{menuItem:"\u89C6\u9891",abstract:"\u89C6\u9891"}}},V_={media:{upload:{failed:'<div class="line-1">{name} upload failed</div><div class="line-2">The network service is abnormal, you can <a href="" class="retry-upload">Try again</a></div>'},load:{failed:'<div class="line-1">{name} loading failed</div><div class="line-2">The network service is abnormal, you can <a href="" class="retry-upload">Try again</a></div>'},audio:{menuItem:"Audio",abstract:"Audio"},video:{menuItem:"Video",abstract:"Video"}}};S.mergeLang({"zh-CN":z_,"en-US":V_});var an=(n=>(n.AUDIO="audio",n.VIDEO="video",n))(an||{}),_s=(n=>(n.Empty="empty",n.Progress="progress",n.Error="error",n))(_s||{});const j3=10*1024*1024,U_=["wav","mp3","aac","ogg","webm","flac"],q_=["ogg","mp4","webm"],W_=()=>{};function F3(n){var u,f,m,C,v,w;const t=(u=n.getComponentOptions("media"))!=null?u:{},{allowedMedias:e,maxSize:o,callbacks:r}=t,i=(f=e==null?void 0:e.audio)!=null?f:U_,s=(m=e==null?void 0:e.video)!=null?m:q_,l=(C=o==null?void 0:o.audio)!=null?C:j3,c=(v=o==null?void 0:o.video)!=null?v:j3,a=(w=r==null?void 0:r.onError)!=null?w:W_;return{allowedMedias:{audio:i,video:s},maxSize:{audio:l,video:c},callbacks:{onError:a}}}const G_=y("file-utils");function Z_(n){d(G_,n instanceof File,`The file: ${n} isn't instance of File`);const{name:t}=n;if(!t)return"";const e=t.lastIndexOf(".");return e===-1?"":t.slice(e+1)}function z3(n,t){const e=i=>i.map(s=>`.${s}`).join(","),{allowedMedias:o}=F3(n),r=o[t];return r?e(r):"*"}function Y_(n,t,e){const{maxSize:o,callbacks:r,allowedMedias:i}=F3(t),{[e]:s}=o,{[e]:l}=i;if(s&&n.size>s){const a=new Error("media is too large");return a.code=`MaxMediaSize-${e}`,r!=null&&r.onError&&(r==null||r.onError(t,a)),a}const c=Z_(n);if(l&&!l.includes(c)){const a=new Error(`media file is not allowed: ${c}`);return a.code="NotAllowedFile",r!=null&&r.onError&&(r==null||r.onError(t,a)),a}return!0}function Q_(n){return n===_s.Empty||n===_s.Error}const ue=y("media");class K_{constructor(t){h(this,"mediaContainer",null);h(this,"media",null);h(this,"abstract",null);h(this,"handleMediaLoadError",(t,e)=>{if(!e.target||!(e.target instanceof Node)||!(e.target instanceof Element?e.target:e.target.parentElement))return;const r=z(e.target);if(!r||!r.contains(this.mediaContainer))return;const i=this.renderError();this.updateMediaContent(i)});h(this,"handleRetry",async t=>{if(t.readonly)return;d(ue,this.abstract,"no abstract");const{mediaType:e}=this.abstract,o=z3(t,e),r=await fr(o);this.handleUploadFile(r)});h(this,"handleUploadFile",async t=>{d(ue,this.abstract,"no abstract"),d(ue,this.mediaContainer,"The media element not exist");const{editor:e}=this.options,{mediaType:o}=this.abstract,r=z(this.mediaContainer);d(ue,r,"The block element not exist");const i=e.getBlockData(r);if(!!Y_(t,e,o))try{const{resourceId:s}=await e.doc.uploadResource(t,{onProgress:f=>{this.renderProgress(f,t)}}),{name:l,type:c,size:a}=t,u={...i,embedData:{...i.embedData,src:s,fileName:l,fileSize:a,fileType:c}};e.updateBlockData(r,u)}catch{this.renderRetry()}});h(this,"destroy",()=>{this.mediaContainer=null});this.options=t}bindMediaEvent(){const{editor:t}=this.options;this.media&&t.domEvents.addEventListener(this.media,"error",this.handleMediaLoadError)}unbindMediaEvent(){const{editor:t}=this.options;this.media&&t.domEvents.removeEventListener(this.media,"error",this.handleMediaLoadError)}updateMediaContent(t){d(ue,this.mediaContainer,"The media element not exist"),this.mediaContainer.innerHTML="",this.mediaContainer.append(t)}renderError(){d(ue,this.abstract,"no abstract");const{editor:t,createMediaElement:e}=this.options,{mediaIcon:o,mediaName:r}=this.abstract;d(ue,this.mediaContainer,"The media element not exist");const i=z(this.mediaContainer);d(ue,i,"The block element not exist");const s=t.getBlockData(i),l=s.embedData.src,c=b("div",["media-error","embed-selected-content","embed-hover-content"],null),a=b("span",["media-error-icon"],c);a.innerHTML=o;const u=b("div",[],c);u.innerHTML=S.t("media.load.failed",{name:r}),c.appendChild(u);const f=u.querySelector("a");return d(ue,f,"The element not exist"),t.domEvents.addEventListener(f,"click",(m,C)=>{if(C.preventDefault(),C.target instanceof HTMLElement&&C.target.tagName==="A"){const v=b("div",["media-element"],null),w=this.getResourceUrl(l),E=e(m,v,s,w);this.unbindMediaEvent(),this.media=E,this.bindMediaEvent(),this.updateMediaContent(v)}}),c}renderRetry(){d(ue,this.abstract,"no abstract");const{editor:t}=this.options,{mediaIcon:e,mediaName:o}=this.abstract,r=b("div",["media-error","embed-selected-content","embed-hover-content"],null),i=b("span",["media-error-icon"],r);i.innerHTML=e;const s=b("div",[],r);s.innerHTML=S.t("media.upload.failed",{name:o}),r.appendChild(s);const l=s.querySelector("a");d(ue,l,"The element not exist"),t.domEvents.addEventListener(l,"click",this.handleRetry),this.updateMediaContent(r)}renderProgress(t,e){d(ue,this.mediaContainer,"The media element not exist");const o=this.mediaContainer.querySelector(":scope .media-progress"),r=t===-1||t===100?100:t;if(o){const{updateProgressElement:i}=this.options;i(o,r)}else{const{createProgressElement:i}=this.options,s=b("div",["media-progress"],null);i(s,r,e),this.updateMediaContent(s)}}renderMediaElement(t){d(ue,this.mediaContainer,"The media element not exist");const e=this.mediaContainer.querySelector(":scope > .media-element"),{createMediaElement:o,updateMediaElement:r,editor:i}=this.options,s=this.getResourceUrl(t.embedData.src);if(e){const l=r(i,e,t,s);this.unbindMediaEvent(),this.media=l,this.bindMediaEvent()}else{const l=b("div",["media-element"],null),c=o(i,l,t,s);this.unbindMediaEvent(),this.media=c,this.bindMediaEvent(),this.updateMediaContent(l)}}renderEmpty(){d(ue,this.abstract,"no abstract"),d(ue,this.mediaContainer,"The media element not exist");const t=b("div",["media-empty","embed-selected-content","embed-hover-content"],this.mediaContainer);t.innerHTML=this.abstract.mediaIcon,this.updateMediaContent(t)}getResourceUrl(t){const{editor:e}=this.options;return e.doc.buildResourceUrl(t)}render(t,e){const{src:o}=t.embedData;(!this.mediaContainer||!e.contains(this.mediaContainer))&&(this.mediaContainer=b("div",["media"],e)),Q_(o)?o===_s.Empty&&this.renderEmpty():this.renderMediaElement(t)}setAbstract(t){this.abstract=t}}y("media-embed");class V3{constructor(){h(this,"handleInsertEmptyEmbed",async(t,e)=>{var u;const{containerId:o,blockIndex:r}=e;let i;(u=e.data)!=null&&u.file&&(i=e.data.file);const s=z3(t,this.embedType);if(i=i!=null?i:await fr(s,{}),!i)return null;const l={id:N(),type:"embed",embedType:this.embedType,embedData:{src:_s.Empty}},c=t.insertBlock(o,r,l);return await this.getMedia(t,l.id).handleUploadFile(i),c})}getMedia(t,e){const o=t.addCustom(`media-${e}`,()=>new K_({editor:t,createMediaElement:this.createMediaElement,updateMediaElement:this.updateMediaElement,createProgressElement:this.createProgressElement,updateProgressElement:this.updateProgressElement}));return o.setAbstract({...this.abstract}),o}getOptions(){const{menuItem:t,mediaIcon:e,mediaName:o,order:r,group:i}=this.abstract;return{name:o,insertEmbedCommandItems:[{id:`insert-${this.embedType}`,name:t,icon:e,order:r,group:i}],handleInsertEmptyEmbed:this.handleInsertEmptyEmbed}}createEmbedContent(t,e,o){const{id:r}=o;this.getMedia(t,r).render(o,e)}handleUpdateBlock(t,e,o){const{id:r}=o,i=this.getMedia(t,r),s=rt(e);return i.render(o,s),!0}handleDeleteBlock(t,e){const o=e.id;this.getMedia(t,o).destroy()}}function U3(n,t){const e=b("div",["uploading-progress-mask"],n),o=b("div",["uploading-progress-bar"],e),r=b("div",["uploading-progress-bar-value"],o);r.style.width=`${t}%`}function q3(n,t){const e=n.querySelector(".uploading-progress-bar-value");e&&(e.style.width=`${t}%`)}const J_=y("media-audio");class X_ extends V3{constructor(){super(...arguments);h(this,"embedType",an.AUDIO);h(this,"abstract",{mediaIcon:F5,mediaName:S.t(`media.${an.AUDIO}.menuItem`),menuItem:S.t(`media.${an.AUDIO}.menuItem`),order:800,mediaType:an.AUDIO,group:"common"});h(this,"updateProgressElement",q3)}getBlockProperties(){return{abstract:`[${S.t(`media.${an.AUDIO}.abstract`)}]`}}createMediaElement(e,o,r,i){const s=b("div",["audio-container","embed-hover-content","embed-selected-content"],o),l=b("audio",[],s);return l.innerHTML="Your browser does not support the <code>audio</code> element.",l.controls=!0,l.src=i,l}updateMediaElement(e,o,r,i){const s=o.querySelector(":scope .audio-container > audio");return d(J_,s,"The media element not exist"),s.src!==i&&(s.src=i),s}createProgressElement(e,o){const r=b("audio",[],e);r.innerHTML="Your browser does not support the <code>audio</code> element.",r.controls=!0,r.src="about:blank",U3(e,o)}}const Xh=new X_;y("video-resizer");function W3(n){return n&&Te(n)&&De(n)==="video"}const tN=50;class eN{constructor(t){h(this,"currentResizableElement",null);h(this,"resizing",!1);h(this,"handleHoveringBlockChange",(t,e)=>{if(!this.resizing&&(e&&W3(e)&&this.disableBlockResize(e),t&&W3(t))){const o=this.getVideoElement(t);if(!o)return;this.enableBlockResize(t,o)}});h(this,"handleResizing",(t,e)=>{if(this.resizing=!0,!this.currentResizableElement)return;const o=t.getBlock();if(!o)return;const r=o.getBoundingClientRect().width,i=Math.min(Math.max(e.width,tN),r);this.currentResizableElement.style.width=`${i}px`});h(this,"handleResized",t=>{this.resizing=!1;const e=t.getBlock();if(!this.currentResizableElement||!e)return;const o=this.editor.getBlockData(e),{width:r}=this.currentResizableElement.getBoundingClientRect();this.editor.updateBlockData(e,{...o,width:r})});this.editor=t,_t.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){this.currentResizableElement=null,_t.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}getVideoElement(t){return rt(t).querySelector(":scope .video-container > video")}disableBlockResize(t){const e=this.editor.findCustom(`${G(t)}-resizer`);e&&e.disableResize()}enableBlockResize(t,e){const o=this.editor.addCustom(`${G(t)}-resizer`,()=>new $c(this.editor,{resize:["top-left","top-right","bottom-left","bottom-right"]}));o.enableResize(t,e),o.removeListener("resizing",this.handleResizing),o.removeListener("resized",this.handleResized),o.addListener("resizing",this.handleResizing),o.addListener("resized",this.handleResized),this.currentResizableElement=e}}const nN=y("video");class oN extends V3{constructor(){super(...arguments);h(this,"embedType",an.VIDEO);h(this,"abstract",{mediaName:S.t(`media.${an.VIDEO}.menuItem`),mediaIcon:z5,menuItem:S.t(`media.${an.VIDEO}.menuItem`),order:700,mediaType:an.VIDEO,group:"common"});h(this,"updateProgressElement",q3);h(this,"createProgressElement",(e,o,r)=>{const i=b("video",["progress-video"],e);i.innerHTML="Your browser does not support the <code>audio</code> element.",i.controls=!0,U3(e,o),nl(r).then(s=>{const l=e.querySelector(".progress-video");l&&d1(e)&&(l.src=s)})})}getBlockProperties(){return{abstract:`[${S.t(`media.${an.VIDEO}.abstract`)}]`}}createMediaElement(e,o,r,i){const s=b("div",["video-container","embed-selected-content","drag-preview-element"],o),l=b("video",[],s);return l.innerHTML="Your browser does not support the <code>video</code> element.",l.controls=!0,l.src=i,e.addCustom("video-resizer",()=>new eN(e)),r.width&&(l.style.width=`${r.width}px`),l}updateMediaElement(e,o,r,i){const s=o.querySelector(":scope .video-container > video");return d(nN,s,"The media element not exist"),s.src!==i&&(s.src=i),s}}const tf=new oN,oz="",rN={version:{latest:"\u5F53\u524D\u7248\u672C",insert:"{name} \u6DFB\u52A0",delete:"{name} \u5220\u9664",goBack:"\u8FD4\u56DE",revertVersion:"\u8FD8\u539F\u5185\u5BB9",play:"\u64AD\u653E\u5386\u53F2\u64CD\u4F5C",versionList:"\u5386\u53F2\u8BB0\u5F55 {count}",unknown:"\u672A\u77E5\u7248\u672C",restoreFrom:"\u56DE\u6EDA\u81EA\u7248\u672C {from}",restoreInfo:"\u56DE\u6EDA\u7684\u7248\u672C\u6682\u4E0D\u652F\u6301\u4E0E\u4E0A\u4E00\u7248\u672C\u5BF9\u6BD4"}},iN={version:{latest:"Latest",insert:"Added by {name}",delete:"Deleted by {name}",goBack:"Back",revertVersion:"Revert",play:"Play",versionList:"Versions ({count})",unknown:"Unknown version",restoreFrom:"Reverted from {from}",restoreInfo:"The rolled back version does not currently support comparison with the previous version."}};S.mergeLang({"zh-CN":rN,"en-US":iN});var G3=(n=>(n.NEW="history-new",n.NEW_CHILD="history-new-child",n.DELETED="history-deleted",n.UPDATED="history-updated",n.HISTORY="history",n))(G3||{});const ri="--op-color",ii="--op-selected-color",rz="";class sN{constructor(t){h(this,"root");this.content=t;const e=b("div",["dialog-root"],null);e.append(t),this.root=e}show(t=document.body){t.append(this.root)}hide(){this.root.remove()}destroy(){}}const{t:si}=S,Z3=y("version-list");class lN{constructor(t){h(this,"activeVersionElement");h(this,"versionsList");h(this,"versionsListHeader");h(this,"handleClickVersionItem",t=>{const o=t.target.closest(".dialog-version-list-item");if(this.isVersionElement(o)){this.toggleActiveVersionElement(o);const r=this.getVersionFromElement(o),{onSelectVersion:i}=this.options;i(r)}});this.options=t;const{versions:e,defaultSelectedIndex:o=0}=t,r=b("div",["version-dialog-list-header"],null,"count");r.innerText=si("version.versionList",{count:`${e.length}`});const i=b("div",["version-dialog-list"],null),s=this.convertVersionsToFragment(e);i.append(s);const l=i.children[o];M(l,"active"),this.activeVersionElement=l,this.versionsList=i,this.versionsListHeader=r,i.onclick=this.handleClickVersionItem}get isSelectedFirstVersion(){return!!this.activeVersionElement&&this.versionsList.firstChild===this.activeVersionElement}get isSelectedLastVersion(){return!!this.activeVersionElement&&this.versionsList.lastChild===this.activeVersionElement}get beforeVersion(){return d(Z3,this.activeVersionElement,"No active version element"),this.activeVersionElement.nextElementSibling?this.activeVersionElement.nextElementSibling.versionData:null}get beforeMajorVersion(){d(Z3,this.activeVersionElement,"No active version element");let t=this.activeVersionElement.nextElementSibling;for(;t;){if(t.versionData.type)return t.versionData;t=t.nextElementSibling}return null}convertVersionsToFragment(t){const e=document.createDocumentFragment(),o=i=>{var l;let s;if(i.version!==-1){const c=new Date((l=i.created)!=null?l:i.version);s=`${c.toLocaleDateString()} ${c.toLocaleTimeString()}`}else s=si("version.latest");return s},r=(i,s,l,c=!1)=>{var C;const a=b("div",["dialog-version-list-item"],e);a.versionData=i,s&&M(a,"child");const u=b("div",["dialog-version-list-item-title"],a);if(b("div",["dialog-version-list-item-date"],u,o(i)),c&&b("div",["dialog-version-list-item-now-ver"],u,si("version.latest")),typeof i.source=="object"&&((C=i.source)==null?void 0:C.restore)){const v=i.source.restore,w=l.find(O=>O.version==v),E=w?o(w):si("version.unknown"),L=si("version.restoreFrom",{from:E}),x=si("version.restoreInfo"),A=b("div",["dialog-version-item-from-container"],a);b("div",["dialog-version-item-from-main"],A,L),b("div",["dialog-version-item-from-info"],A,x)}const f=b("ul",["dialog-version-list-item-authors"],a),m=v=>{const w=b("li",["dialog-version-list-item-author"],f),E=b("span",["dialog-version-list-item-mark-author"],w);E.style.background=this.options.getMarkColor(v),b("span",["dialog-version-list-item-author-name"],w,v.displayName)};if(this.options.useCreatedBy)if(i.createdBy){const v=i.createdBy;m(v)}else i.authors&&i.authors.length>0&&i.authors.forEach(v=>{m(v)});else if(i.authors&&i.authors.length>0)i.authors.forEach(v=>{m(v)});else if(i.createdBy){const v=i.createdBy;m(v)}};return t.forEach((i,s)=>{r(i,!1,t,s===0),i.minorVersions&&i.minorVersions.length>0&&i.minorVersions.forEach(l=>{r(l,!0,t,!1)})}),e}isVersionElement(t){return t?lt(t,"dialog-version-list-item"):!1}getVersionFromElement(t){return t.versionData}get activeVersion(){return this.getVersionFromElement(this.activeVersionElement)}toggleActiveVersionElement(t){this.activeVersionElement!==t&&(F(this.activeVersionElement,"active"),M(t,"active"),this.activeVersionElement=t)}selectVersionByVersionNum(t){const e=Array.from(this.versionsList.children).find(o=>o.versionData.version===t);return this.isVersionElement(e)?(this.toggleActiveVersionElement(e),this.getVersionFromElement(e)):null}render(t){t.innerHTML="",t.append(this.versionsListHeader,this.versionsList)}destroy(){this.versionsList.onclick=null}}class cN{constructor(t,e){this.doc=t,this.user=e}onDeleteBlock(t,e){this.doc.onDeleteBlock(t,e,this.user)}onInsertBlock(t,e,o){this.doc.onInsertBlock(t,e,o,this.user)}onUpdateBlockText(t,e,o){this.doc.onUpdateBlockText(t,e,o,this.user)}onUpdateBlockData(t,e,o){this.doc.onUpdateBlockData(t,e,o,this.user)}onCreateContainer(t,e){this.doc.onCreateContainer(t,e,this.user)}onCreateComment(){}onDeleteComment(){}onDeleteContainer(){}onUpdateComment(){}}function aN(n){return new Promise(t=>{setTimeout(t,n)})}async function dN(n,t,e,o){for(const r of e){const i=new cN(n,r.user);t.parseHistoryData(r,i),o.play&&await aN(o.speed||150)}}const uN=`<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
742
+ </svg>`,$3={dwg:[],rvt:[],skp:[],img:["image/png","image/jpg","image/jpeg","image/bmp","image/ico","image/icon","image/gif"],txt:["text/plain"],zip:["application/zip","application/x-rar-compressed","application/x-7z-compressed","application/x-tar","application/x-bzip2","application/java-archive"],ppt:["application/vnd.ms-powerpoint","application/vnd.openxmlformats-officedocument.presentationml.presentation"],excel:["application/vnd.ms-excel","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"],pdf:["application/pdf"],word:["application/msword","application/vnd.openxmlformats-officedocument.wordprocessingml.document"]},Jh={dwg:x_,rvt:S_,skp:T_,img:D_,txt:L_,zip:P3,rar:P3,ppt:M_,excel:R_,pdf:A_,word:O_};function N_(n,t){const e=Object.keys($3);for(let r=0;r<e.length;r+=1){const i=e[r];if($3[i].includes(t))return Jh[i]}const o=mm(n.toLowerCase());return Jh[o]?Jh[o]:__}function P_(n,t){const e=b("div",["card-root","embed-selected-content"],n),o=b("div",["file-icon"],e);o.innerHTML=N_(t.fileName,t.fileType);const r=b("div",["file-details"],e);b("div",["file-name"],r,t.fileName),b("div",["file-size"],r,vm(t.fileSize));const i=b("div",["file-actions"],e),s=b("button",["download"],i);return s.innerHTML=Kh,{card:e,downloadButton:s}}const ez="";function H3(n,t){const o=n.getBlockData(t).embedData,r=n.options.componentsOptions.file;if(r!=null&&r.onDownloadFile){r.onDownloadFile(n,o);return}const i=n.doc.buildResourceUrl(o.src,{downloadFileName:o.fileName});ll(i,o.fileName)}y("webpage-embed");function $_(n,t,e){const{embedData:o}=e,r=o,{card:i,downloadButton:s}=P_(t,r);n.domEvents.addEventListener(s,"click",(l,c)=>{if(!c.target)return;const a=z(c.target);!a||H3(l,a)}),n.domEvents.addEventListener(i,"click",(l,c)=>{if(!c.target)return;const a=z(c.target);if(!a||Bi(c,"button"))return;const u=l.options.componentsOptions.file;if(u!=null&&u.onClick){u.onClick(l,a,c);return}const m=l.getBlockData(a).embedData,C=l.doc.buildResourceUrl(m.src,{downloadFileName:m.fileName});ll(C,m.fileName)})}class H_{constructor(){h(this,"group","file-card");h(this,"commands",[{id:"download",name:"Download",icon:Kh},{id:"sep",name:"",type:"separator"},{id:"to-link",name:"To link",icon:A3},{id:"to-card",name:"To card",icon:O3,states:["checked"]},{id:"sep",name:"",type:"separator"},{id:"add-comment",name:"Add Comment",icon:$r}])}executeCommand(t,e,o){if(o.id==="to-link"){const r=H(e),i=U(r),s=K(e),l=t.getBlockData(e),{embedData:c}=l,a=c,u={id:N(),box:!0,type:"file",created:Date.now(),src:a.src,fileName:a.fileName,fileSize:a.fileSize,fileType:a.fileType};t.undoManager.runInGroup(()=>{t.deleteBlock(e);const f=[Tg(u)];t.insertTextBlock(f,i,s)})}else o.id==="download"?H3(t,e):o.id==="add-comment"&&ah(t,e)}}function j_(n,t){const e=n.getBlockData(t),{embedData:o,id:r}=e,i=o;return{blockCommands:{"hovering-toolbar":new H_},abstract:i.fileName}}const F_={embedType:"office",createEmbedContent:$_,getBlockProperties:j_},nz="",z_={media:{upload:{failed:'<div class="line-1">{name} \u4E0A\u4F20\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <a href="" class="retry-upload">\u91CD\u8BD5</a></div>'},load:{failed:'<div class="line-1">{name} \u52A0\u8F7D\u5931\u8D25</div><div class="line-2">\u7F51\u7EDC\u670D\u52A1\u5F02\u5E38\uFF0C\u4F60\u53EF\u4EE5 <a href="" class="retry-upload">\u91CD\u8BD5</a></div>'},audio:{menuItem:"\u97F3\u9891",abstract:"\u97F3\u9891"},video:{menuItem:"\u89C6\u9891",abstract:"\u89C6\u9891"}}},U_={media:{upload:{failed:'<div class="line-1">{name} upload failed</div><div class="line-2">The network service is abnormal, you can <a href="" class="retry-upload">Try again</a></div>'},load:{failed:'<div class="line-1">{name} loading failed</div><div class="line-2">The network service is abnormal, you can <a href="" class="retry-upload">Try again</a></div>'},audio:{menuItem:"Audio",abstract:"Audio"},video:{menuItem:"Video",abstract:"Video"}}};S.mergeLang({"zh-CN":z_,"en-US":U_});var an=(n=>(n.AUDIO="audio",n.VIDEO="video",n))(an||{}),_s=(n=>(n.Empty="empty",n.Progress="progress",n.Error="error",n))(_s||{});const j3=10*1024*1024,V_=["wav","mp3","aac","ogg","webm","flac"],q_=["ogg","mp4","webm"],W_=()=>{};function F3(n){var u,f,m,C,v,w;const t=(u=n.getComponentOptions("media"))!=null?u:{},{allowedMedias:e,maxSize:o,callbacks:r}=t,i=(f=e==null?void 0:e.audio)!=null?f:V_,s=(m=e==null?void 0:e.video)!=null?m:q_,l=(C=o==null?void 0:o.audio)!=null?C:j3,c=(v=o==null?void 0:o.video)!=null?v:j3,a=(w=r==null?void 0:r.onError)!=null?w:W_;return{allowedMedias:{audio:i,video:s},maxSize:{audio:l,video:c},callbacks:{onError:a}}}const G_=y("file-utils");function Z_(n){d(G_,n instanceof File,`The file: ${n} isn't instance of File`);const{name:t}=n;if(!t)return"";const e=t.lastIndexOf(".");return e===-1?"":t.slice(e+1)}function z3(n,t){const e=i=>i.map(s=>`.${s}`).join(","),{allowedMedias:o}=F3(n),r=o[t];return r?e(r):"*"}function Y_(n,t,e){const{maxSize:o,callbacks:r,allowedMedias:i}=F3(t),{[e]:s}=o,{[e]:l}=i;if(s&&n.size>s){const a=new Error("media is too large");return a.code=`MaxMediaSize-${e}`,r!=null&&r.onError&&(r==null||r.onError(t,a)),a}const c=Z_(n);if(l&&!l.includes(c)){const a=new Error(`media file is not allowed: ${c}`);return a.code="NotAllowedFile",r!=null&&r.onError&&(r==null||r.onError(t,a)),a}return!0}function Q_(n){return n===_s.Empty||n===_s.Error}const ue=y("media");class K_{constructor(t){h(this,"mediaContainer",null);h(this,"media",null);h(this,"abstract",null);h(this,"handleMediaLoadError",(t,e)=>{if(!e.target||!(e.target instanceof Node)||!(e.target instanceof Element?e.target:e.target.parentElement))return;const r=z(e.target);if(!r||!r.contains(this.mediaContainer))return;const i=this.renderError();this.updateMediaContent(i)});h(this,"handleRetry",async t=>{if(t.readonly)return;d(ue,this.abstract,"no abstract");const{mediaType:e}=this.abstract,o=z3(t,e),r=await fr(o);this.handleUploadFile(r)});h(this,"handleUploadFile",async t=>{d(ue,this.abstract,"no abstract"),d(ue,this.mediaContainer,"The media element not exist");const{editor:e}=this.options,{mediaType:o}=this.abstract,r=z(this.mediaContainer);d(ue,r,"The block element not exist");const i=e.getBlockData(r);if(!!Y_(t,e,o))try{const{resourceId:s}=await e.doc.uploadResource(t,{onProgress:f=>{this.renderProgress(f,t)}}),{name:l,type:c,size:a}=t,u={...i,embedData:{...i.embedData,src:s,fileName:l,fileSize:a,fileType:c}};e.updateBlockData(r,u)}catch{this.renderRetry()}});h(this,"destroy",()=>{this.mediaContainer=null});this.options=t}bindMediaEvent(){const{editor:t}=this.options;this.media&&t.domEvents.addEventListener(this.media,"error",this.handleMediaLoadError)}unbindMediaEvent(){const{editor:t}=this.options;this.media&&t.domEvents.removeEventListener(this.media,"error",this.handleMediaLoadError)}updateMediaContent(t){d(ue,this.mediaContainer,"The media element not exist"),this.mediaContainer.innerHTML="",this.mediaContainer.append(t)}renderError(){d(ue,this.abstract,"no abstract");const{editor:t,createMediaElement:e}=this.options,{mediaIcon:o,mediaName:r}=this.abstract;d(ue,this.mediaContainer,"The media element not exist");const i=z(this.mediaContainer);d(ue,i,"The block element not exist");const s=t.getBlockData(i),l=s.embedData.src,c=b("div",["media-error","embed-selected-content","embed-hover-content"],null),a=b("span",["media-error-icon"],c);a.innerHTML=o;const u=b("div",[],c);u.innerHTML=S.t("media.load.failed",{name:r}),c.appendChild(u);const f=u.querySelector("a");return d(ue,f,"The element not exist"),t.domEvents.addEventListener(f,"click",(m,C)=>{if(C.preventDefault(),C.target instanceof HTMLElement&&C.target.tagName==="A"){const v=b("div",["media-element"],null),w=this.getResourceUrl(l),E=e(m,v,s,w);this.unbindMediaEvent(),this.media=E,this.bindMediaEvent(),this.updateMediaContent(v)}}),c}renderRetry(){d(ue,this.abstract,"no abstract");const{editor:t}=this.options,{mediaIcon:e,mediaName:o}=this.abstract,r=b("div",["media-error","embed-selected-content","embed-hover-content"],null),i=b("span",["media-error-icon"],r);i.innerHTML=e;const s=b("div",[],r);s.innerHTML=S.t("media.upload.failed",{name:o}),r.appendChild(s);const l=s.querySelector("a");d(ue,l,"The element not exist"),t.domEvents.addEventListener(l,"click",this.handleRetry),this.updateMediaContent(r)}renderProgress(t,e){d(ue,this.mediaContainer,"The media element not exist");const o=this.mediaContainer.querySelector(":scope .media-progress"),r=t===-1||t===100?100:t;if(o){const{updateProgressElement:i}=this.options;i(o,r)}else{const{createProgressElement:i}=this.options,s=b("div",["media-progress"],null);i(s,r,e),this.updateMediaContent(s)}}renderMediaElement(t){d(ue,this.mediaContainer,"The media element not exist");const e=this.mediaContainer.querySelector(":scope > .media-element"),{createMediaElement:o,updateMediaElement:r,editor:i}=this.options,s=this.getResourceUrl(t.embedData.src);if(e){const l=r(i,e,t,s);this.unbindMediaEvent(),this.media=l,this.bindMediaEvent()}else{const l=b("div",["media-element"],null),c=o(i,l,t,s);this.unbindMediaEvent(),this.media=c,this.bindMediaEvent(),this.updateMediaContent(l)}}renderEmpty(){d(ue,this.abstract,"no abstract"),d(ue,this.mediaContainer,"The media element not exist");const t=b("div",["media-empty","embed-selected-content","embed-hover-content"],this.mediaContainer);t.innerHTML=this.abstract.mediaIcon,this.updateMediaContent(t)}getResourceUrl(t){const{editor:e}=this.options;return e.doc.buildResourceUrl(t)}render(t,e){const{src:o}=t.embedData;(!this.mediaContainer||!e.contains(this.mediaContainer))&&(this.mediaContainer=b("div",["media"],e)),Q_(o)?o===_s.Empty&&this.renderEmpty():this.renderMediaElement(t)}setAbstract(t){this.abstract=t}}y("media-embed");class U3{constructor(){h(this,"handleInsertEmptyEmbed",async(t,e)=>{var u;const{containerId:o,blockIndex:r}=e;let i;(u=e.data)!=null&&u.file&&(i=e.data.file);const s=z3(t,this.embedType);if(i=i!=null?i:await fr(s,{}),!i)return null;const l={id:N(),type:"embed",embedType:this.embedType,embedData:{src:_s.Empty}},c=t.insertBlock(o,r,l);return await this.getMedia(t,l.id).handleUploadFile(i),c})}getMedia(t,e){const o=t.addCustom(`media-${e}`,()=>new K_({editor:t,createMediaElement:this.createMediaElement,updateMediaElement:this.updateMediaElement,createProgressElement:this.createProgressElement,updateProgressElement:this.updateProgressElement}));return o.setAbstract({...this.abstract}),o}getOptions(){const{menuItem:t,mediaIcon:e,mediaName:o,order:r,group:i}=this.abstract;return{name:o,insertEmbedCommandItems:[{id:`insert-${this.embedType}`,name:t,icon:e,order:r,group:i}],handleInsertEmptyEmbed:this.handleInsertEmptyEmbed}}createEmbedContent(t,e,o){const{id:r}=o;this.getMedia(t,r).render(o,e)}handleUpdateBlock(t,e,o){const{id:r}=o,i=this.getMedia(t,r),s=rt(e);return i.render(o,s),!0}handleDeleteBlock(t,e){const o=e.id;this.getMedia(t,o).destroy()}}function V3(n,t){const e=b("div",["uploading-progress-mask"],n),o=b("div",["uploading-progress-bar"],e),r=b("div",["uploading-progress-bar-value"],o);r.style.width=`${t}%`}function q3(n,t){const e=n.querySelector(".uploading-progress-bar-value");e&&(e.style.width=`${t}%`)}const J_=y("media-audio");class X_ extends U3{constructor(){super(...arguments);h(this,"embedType",an.AUDIO);h(this,"abstract",{mediaIcon:F5,mediaName:S.t(`media.${an.AUDIO}.menuItem`),menuItem:S.t(`media.${an.AUDIO}.menuItem`),order:800,mediaType:an.AUDIO,group:"common"});h(this,"updateProgressElement",q3)}getBlockProperties(){return{abstract:`[${S.t(`media.${an.AUDIO}.abstract`)}]`}}createMediaElement(e,o,r,i){const s=b("div",["audio-container","embed-hover-content","embed-selected-content"],o),l=b("audio",[],s);return l.innerHTML="Your browser does not support the <code>audio</code> element.",l.controls=!0,l.src=i,l}updateMediaElement(e,o,r,i){const s=o.querySelector(":scope .audio-container > audio");return d(J_,s,"The media element not exist"),s.src!==i&&(s.src=i),s}createProgressElement(e,o){const r=b("audio",[],e);r.innerHTML="Your browser does not support the <code>audio</code> element.",r.controls=!0,r.src="about:blank",V3(e,o)}}const Xh=new X_;y("video-resizer");function W3(n){return n&&Te(n)&&De(n)==="video"}const tN=50;class eN{constructor(t){h(this,"currentResizableElement",null);h(this,"resizing",!1);h(this,"handleHoveringBlockChange",(t,e)=>{if(!this.resizing&&(e&&W3(e)&&this.disableBlockResize(e),t&&W3(t))){const o=this.getVideoElement(t);if(!o)return;this.enableBlockResize(t,o)}});h(this,"handleResizing",(t,e)=>{if(this.resizing=!0,!this.currentResizableElement)return;const o=t.getBlock();if(!o)return;const r=o.getBoundingClientRect().width,i=Math.min(Math.max(e.width,tN),r);this.currentResizableElement.style.width=`${i}px`});h(this,"handleResized",t=>{this.resizing=!1;const e=t.getBlock();if(!this.currentResizableElement||!e)return;const o=this.editor.getBlockData(e),{width:r}=this.currentResizableElement.getBoundingClientRect();this.editor.updateBlockData(e,{...o,width:r})});this.editor=t,_t.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){this.currentResizableElement=null,_t.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}getVideoElement(t){return rt(t).querySelector(":scope .video-container > video")}disableBlockResize(t){const e=this.editor.findCustom(`${G(t)}-resizer`);e&&e.disableResize()}enableBlockResize(t,e){const o=this.editor.addCustom(`${G(t)}-resizer`,()=>new $c(this.editor,{resize:["top-left","top-right","bottom-left","bottom-right"]}));o.enableResize(t,e),o.removeListener("resizing",this.handleResizing),o.removeListener("resized",this.handleResized),o.addListener("resizing",this.handleResizing),o.addListener("resized",this.handleResized),this.currentResizableElement=e}}const nN=y("video");class oN extends U3{constructor(){super(...arguments);h(this,"embedType",an.VIDEO);h(this,"abstract",{mediaName:S.t(`media.${an.VIDEO}.menuItem`),mediaIcon:z5,menuItem:S.t(`media.${an.VIDEO}.menuItem`),order:700,mediaType:an.VIDEO,group:"common"});h(this,"updateProgressElement",q3);h(this,"createProgressElement",(e,o,r)=>{const i=b("video",["progress-video"],e);i.innerHTML="Your browser does not support the <code>audio</code> element.",i.controls=!0,V3(e,o),nl(r).then(s=>{const l=e.querySelector(".progress-video");l&&d1(e)&&(l.src=s)})})}getBlockProperties(){return{abstract:`[${S.t(`media.${an.VIDEO}.abstract`)}]`}}createMediaElement(e,o,r,i){const s=b("div",["video-container","embed-selected-content","drag-preview-element"],o),l=b("video",[],s);return l.innerHTML="Your browser does not support the <code>video</code> element.",l.controls=!0,l.src=i,e.addCustom("video-resizer",()=>new eN(e)),r.width&&(l.style.width=`${r.width}px`),l}updateMediaElement(e,o,r,i){const s=o.querySelector(":scope .video-container > video");return d(nN,s,"The media element not exist"),s.src!==i&&(s.src=i),s}}const tf=new oN,oz="",rN={version:{latest:"\u5F53\u524D\u7248\u672C",insert:"{name} \u6DFB\u52A0",delete:"{name} \u5220\u9664",goBack:"\u8FD4\u56DE",revertVersion:"\u8FD8\u539F\u5185\u5BB9",play:"\u64AD\u653E\u5386\u53F2\u64CD\u4F5C",versionList:"\u5386\u53F2\u8BB0\u5F55 {count}",unknown:"\u672A\u77E5\u7248\u672C",restoreFrom:"\u56DE\u6EDA\u81EA\u7248\u672C {from}",restoreInfo:"\u56DE\u6EDA\u7684\u7248\u672C\u6682\u4E0D\u652F\u6301\u4E0E\u4E0A\u4E00\u7248\u672C\u5BF9\u6BD4"}},iN={version:{latest:"Latest",insert:"Added by {name}",delete:"Deleted by {name}",goBack:"Back",revertVersion:"Revert",play:"Play",versionList:"Versions ({count})",unknown:"Unknown version",restoreFrom:"Reverted from {from}",restoreInfo:"The rolled back version does not currently support comparison with the previous version."}};S.mergeLang({"zh-CN":rN,"en-US":iN});var G3=(n=>(n.NEW="history-new",n.NEW_CHILD="history-new-child",n.DELETED="history-deleted",n.UPDATED="history-updated",n.HISTORY="history",n))(G3||{});const ri="--op-color",ii="--op-selected-color",rz="";class sN{constructor(t){h(this,"root");this.content=t;const e=b("div",["dialog-root"],null);e.append(t),this.root=e}show(t=document.body){t.append(this.root)}hide(){this.root.remove()}destroy(){}}const{t:si}=S,Z3=y("version-list");class lN{constructor(t){h(this,"activeVersionElement");h(this,"versionsList");h(this,"versionsListHeader");h(this,"handleClickVersionItem",t=>{const o=t.target.closest(".dialog-version-list-item");if(this.isVersionElement(o)){this.toggleActiveVersionElement(o);const r=this.getVersionFromElement(o),{onSelectVersion:i}=this.options;i(r)}});this.options=t;const{versions:e,defaultSelectedIndex:o=0}=t,r=b("div",["version-dialog-list-header"],null,"count");r.innerText=si("version.versionList",{count:`${e.length}`});const i=b("div",["version-dialog-list"],null),s=this.convertVersionsToFragment(e);i.append(s);const l=i.children[o];M(l,"active"),this.activeVersionElement=l,this.versionsList=i,this.versionsListHeader=r,i.onclick=this.handleClickVersionItem}get isSelectedFirstVersion(){return!!this.activeVersionElement&&this.versionsList.firstChild===this.activeVersionElement}get isSelectedLastVersion(){return!!this.activeVersionElement&&this.versionsList.lastChild===this.activeVersionElement}get beforeVersion(){return d(Z3,this.activeVersionElement,"No active version element"),this.activeVersionElement.nextElementSibling?this.activeVersionElement.nextElementSibling.versionData:null}get beforeMajorVersion(){d(Z3,this.activeVersionElement,"No active version element");let t=this.activeVersionElement.nextElementSibling;for(;t;){if(t.versionData.type)return t.versionData;t=t.nextElementSibling}return null}convertVersionsToFragment(t){const e=document.createDocumentFragment(),o=i=>{var l;let s;if(i.version!==-1){const c=new Date((l=i.created)!=null?l:i.version);s=`${c.toLocaleDateString()} ${c.toLocaleTimeString()}`}else s=si("version.latest");return s},r=(i,s,l,c=!1)=>{var C;const a=b("div",["dialog-version-list-item"],e);a.versionData=i,s&&M(a,"child");const u=b("div",["dialog-version-list-item-title"],a);if(b("div",["dialog-version-list-item-date"],u,o(i)),c&&b("div",["dialog-version-list-item-now-ver"],u,si("version.latest")),typeof i.source=="object"&&((C=i.source)==null?void 0:C.restore)){const v=i.source.restore,w=l.find(O=>O.version==v),E=w?o(w):si("version.unknown"),L=si("version.restoreFrom",{from:E}),x=si("version.restoreInfo"),A=b("div",["dialog-version-item-from-container"],a);b("div",["dialog-version-item-from-main"],A,L),b("div",["dialog-version-item-from-info"],A,x)}const f=b("ul",["dialog-version-list-item-authors"],a),m=v=>{const w=b("li",["dialog-version-list-item-author"],f),E=b("span",["dialog-version-list-item-mark-author"],w);E.style.background=this.options.getMarkColor(v),b("span",["dialog-version-list-item-author-name"],w,v.displayName)};if(this.options.useCreatedBy)if(i.createdBy){const v=i.createdBy;m(v)}else i.authors&&i.authors.length>0&&i.authors.forEach(v=>{m(v)});else if(i.authors&&i.authors.length>0)i.authors.forEach(v=>{m(v)});else if(i.createdBy){const v=i.createdBy;m(v)}};return t.forEach((i,s)=>{r(i,!1,t,s===0),i.minorVersions&&i.minorVersions.length>0&&i.minorVersions.forEach(l=>{r(l,!0,t,!1)})}),e}isVersionElement(t){return t?lt(t,"dialog-version-list-item"):!1}getVersionFromElement(t){return t.versionData}get activeVersion(){return this.getVersionFromElement(this.activeVersionElement)}toggleActiveVersionElement(t){this.activeVersionElement!==t&&(F(this.activeVersionElement,"active"),M(t,"active"),this.activeVersionElement=t)}selectVersionByVersionNum(t){const e=Array.from(this.versionsList.children).find(o=>o.versionData.version===t);return this.isVersionElement(e)?(this.toggleActiveVersionElement(e),this.getVersionFromElement(e)):null}render(t){t.innerHTML="",t.append(this.versionsListHeader,this.versionsList)}destroy(){this.versionsList.onclick=null}}class cN{constructor(t,e){this.doc=t,this.user=e}onDeleteBlock(t,e){this.doc.onDeleteBlock(t,e,this.user)}onInsertBlock(t,e,o){this.doc.onInsertBlock(t,e,o,this.user)}onUpdateBlockText(t,e,o){this.doc.onUpdateBlockText(t,e,o,this.user)}onUpdateBlockData(t,e,o){this.doc.onUpdateBlockData(t,e,o,this.user)}onCreateContainer(t,e){this.doc.onCreateContainer(t,e,this.user)}onCreateComment(){}onDeleteComment(){}onDeleteContainer(){}onUpdateComment(){}}function aN(n){return new Promise(t=>{setTimeout(t,n)})}async function dN(n,t,e,o){for(const r of e){const i=new cN(n,r.user);t.parseHistoryData(r,i),o.play&&await aN(o.speed||150)}}const uN=`<svg xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
743
743
  <path d="M0 0h24v24H0z" fill="none"/><path d="M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"/>
744
- </svg>`,{t:ef}=S;class hN{constructor(t){h(this,"goBackButton");h(this,"playButton");h(this,"revertButton");this.options=t;const e=b("button",["dialog-text-button"],null),o=b("span",["dialog-button-icon"],e);o.innerHTML=uN,b("span",["dialog-button-text"],e,ef("version.goBack"));const r=b("button",["dialog-version-button"],null,ef("version.play")),i=b("button",["dialog-version-button"],null,ef("version.revertVersion"));this.goBackButton=e,this.playButton=r,this.revertButton=i,this.bindEvent()}bindEvent(){const{onBack:t,onPlay:e,onRevert:o}=this.options;this.playButton.onclick=e,this.goBackButton.onclick=t,this.revertButton.onclick=o}disabledButton(){}render(t,e=!1){e||t.append(this.goBackButton,this.playButton,this.revertButton)}destroy(){this.playButton.onclick=null,this.goBackButton.onclick=null,this.revertButton.onclick=null}}const he=y("split-text-actions");function Y3(n){return n.length>2?!1:n.length===1?n[0].insert!==void 0:(d(he,n.length===2,`invalid text actions: ${JSON.stringify(n)}`),n[0].retain===void 0?!1:n[1].insert!==void 0)}function Q3(n){return n.length>2?!1:n.length===1?n[0].delete!==void 0:(d(he,n.length===2,`invalid text actions: ${JSON.stringify(n)}`),n[0].retain===void 0?!1:n[1].delete!==void 0)}function K3(n){return n.length>2?!1:n.length===1?n[0].insert===void 0&&n[0].delete===void 0&&n[0].attributes!==void 0:(d(he,n.length===2,`invalid text actions: ${JSON.stringify(n)}`),n[0].retain===void 0?!1:n[1].attributes!==void 0)}function fN(n){const t=[],e=Y.default(n);if(e.length===0)return[];if(e.length===1)return[n];if(e.length===2&&(Q3(n)||Y3(n)||K3(n)))return[n];const o=(i,s)=>i>0?[{retain:i},s]:[s];let r=0;for(;e.length>0;){const i=e[0];if(i.retain!==void 0&&i.attributes===void 0){d(he,i.retain>0,`invalid text op: ${JSON.stringify(i)}`),d(he,e.length>1,`invalid text op: ${JSON.stringify(i)}`);const s=e[1];d(he,s.delete||s.insert!==void 0||s.attributes!==void 0,`invalid next text op: ${JSON.stringify(s)}`),r+=i.retain,t.push(o(r,s)),s.delete!==void 0?r-=s.delete:s.insert!==void 0?r+=s.insert.length:(d(he,s.attributes!==void 0,`invalid next text op: ${JSON.stringify(s)}`),d(he,s.retain!==void 0,`invalid next text op: ${JSON.stringify(s)}`),r+=s.retain),e.splice(0,2)}else d(he,i.delete||i.insert!==void 0||i.attributes!==void 0,`invalid next text op: ${JSON.stringify(i)}`),t.push(o(r,i)),e.shift(),i.retain!==void 0&&(d(he,i.attributes!==void 0,`invalid next text op: ${JSON.stringify(i)}`),r+=i.retain),i.insert&&(r+=i.insert.length)}return t}function J3(n){if(d(he,n.length===1||n.length===2,`not a single action op: ${JSON.stringify(n)}`),n.length===1)return 0;const t=n[0].retain;return d(he,typeof t=="number"&&t>0,`invalid retain: ${JSON.stringify(n)}`),t}let X3=0;function mN(n,t,e){const o=X3;X3+=1;const r=Tt(n);return{insert:" ",attributes:{box:!0,id:N(),type:"history-deleted-box",user:e,created:Date.now(),text:r,deletedOffset:t,deletedOrder:o}}}function gN(n,t,e){const o=J3(t),r=t.length===1?t[0].delete:t[1].delete;d(he,typeof r=="number",`not a delete op: ${JSON.stringify(t)}`);const{left:i,middle:s,right:l}=Kt(n,o,r),c=mN(s,o,e);return[...i,c,...l]}function pN(n,t,e){const o=J3(t),r=t.length===1?t[0].insert:t[1].insert;d(he,typeof r=="string",`invalid insert op: ${JSON.stringify(t)}`);const i=t.length===1?t[0].attributes:t[1].attributes,l=yl([{insert:r,attributes:i}],"insertedBy",e);return xr(n,o,l,null)}function CN(n,t,e){const o=fN(t).reverse();let r=n;for(const i of o)Q3(i)?r=gN(r,i,e):Y3(i)?r=pN(r,i,e):(d(he,K3(i),`unknown op: ${JSON.stringify(i)}`),r=ne.apply(r,i));return r}const bN=y("history-update-block-text");function t9(n){const t=[],e=[];let o=0;return n.forEach(r=>{var i;if((i=r.attributes)!=null&&i.box){const s=r.attributes;if(s.type==="history-deleted-box"){t.push({boxData:s,offset:o});return}}e.push(r),o+=A1(r)}),t.sort((r,i)=>i.offset-r.offset),{deletedBoxes:t,newText:e}}function vN(n,t,e){let o=n;return t.forEach(r=>{const i=ne.transformCursor(r.offset,e,!1);o=xr(o,i,[{insert:" ",attributes:r.boxData}],null)}),o}function kN(n){n.sort((t,e)=>t.boxData.deletedOffset!==e.boxData.deletedOffset?t.boxData.deletedOffset-e.boxData.deletedOffset:t.boxData.deletedOrder-e.boxData.deletedOrder)}function yN(n){if(n.length<=1)return n;const t=n[0].offset;n.forEach(e=>{d(bN,e.offset===t,`invalid boxes group, ${JSON.stringify(n)}`)}),kN(n);for(let e=n.length-1;e>=1;e--){const o=n[e],r=n[e-1];o.boxData.user.userId===r.boxData.user.userId&&(r.boxData.text+=o.boxData.text,n.splice(e,1))}return n}function wN(n){let{newText:t,deletedBoxes:e}=t9(n);const o=new Map;return e.forEach(i=>{let s=o.get(i.offset);s||(s=[],o.set(i.offset,s)),s.push(i),s.sort((l,c)=>l.boxData.deletedOffset-c.boxData.deletedOffset)}),Array.from(o.values()).sort((i,s)=>s[0].offset-i[0].offset).forEach(i=>{const s=i[0].offset;yN(i).reverse().forEach(l=>{t=xr(t,s,[{insert:" ",attributes:l.boxData}],null)})}),t}function BN(n,t,e){let{newText:o,deletedBoxes:r}=t9(n);return o=CN(o,t,e),o=vN(o,r,t),o=wN(o),o}const Sn=y("history-doc");function Tn(n){d(Sn,!1,"no local actions for history doc")}class EN extends ki{constructor(e,o){super();h(this,"doc");h(this,"editor");this.doc=Y.default(e),this.editor=o}beginBatchUpdate(){return 0}endBatchUpdate(){return 0}toJSON(){return Y.default(this.doc)}getContainerBlocks(e){return this.doc.blocks[e]}getBlockData(e,o){const r=this.getContainerBlocks(e);d(Sn,r,`no container data: ${e}`);const i=r[o];return d(Sn,i,`no block data: ${o}`),i}localUpdateBlockText(){Tn()}localUpdateBlockData(){Tn()}localInsertBlock(){Tn()}localDeleteBlock(){Tn()}localInsertChildContainer(){Tn()}localDeleteChildContainers(){Tn()}uploadResource(){Tn()}async addResources(e){Tn()}getServerMeta(){var e,o,r;return(r=(o=(e=this.editor.doc.externalDoc).getServerMeta)==null?void 0:o.call(e))!=null?r:{}}buildResourceUrl(e){return this.editor.doc.externalDoc.buildResourceUrl(e)}request(){Tn()}broadcastMessage(){Tn()}getUser(){return{permission:"w",userId:"-",displayName:"-",avatarUrl:"-",rainbowIndex:0}}getRemoteUsers(){return new ql}destroy(){this.clearCallbacks()}transformBlockIndex(e,o,r){const i=this.doc.blocks[e];d(Sn,i,`no container blocks: ${e}`);let s=0;for(let l=0;l<i.length;l++)if(!i[l].deletedBy){if(s===o)return l;s++}return r?(d(Sn,!1,`invalid block index: ${o}, blocks: ${JSON.stringify(i)}`),-1):(d(Sn,s===o,`invalid block index: ${o}, blocks: ${JSON.stringify(i)}`),i.length)}onDeleteBlock(e,o,r){const i=this.transformBlockIndex(e,o,!0),l=this.doc.blocks[e][i];d(Sn,!l.deleted,`block has already deleted: ${e}/${o}`),l.deletedBy=r,this.callbacks.forEach(c=>{var a;return(a=c.onUpdateBlockData)==null?void 0:a.call(c,e,i,{insert:{},delete:[]},!0)})}onInsertBlock(e,o,r,i){const s=this.transformBlockIndex(e,o,!1),l=this.doc.blocks[e],c=Y.default(r);c.insertedBy=i,l.splice(s,0,c),this.callbacks.forEach(a=>{var u;return(u=a.onInsertBlock)==null?void 0:u.call(a,e,s,c,!0)})}onUpdateBlockText(e,o,r,i){const s=this.transformBlockIndex(e,o,!0),c=this.doc.blocks[e][s];d(Sn,!c.deleted,`block has already deleted: ${e}/${o}`);const a=c.text;d(Sn,a,`no text for block: ${JSON.stringify(c)}`);const u=BN(a,r,i);c.text=u,this.callbacks.forEach(f=>{var m;return(m=f.onUpdateBlockText)==null?void 0:m.call(f,e,o,r,!0)})}onUpdateBlockData(e,o,r,i){const s=this.transformBlockIndex(e,o,!0),l=this.doc.blocks[e],c=l[s];d(Sn,!c.deleted,`block has already deleted: ${e}/${o}`);const a=Y.default(c);a.updatedBy=i,r.delete.forEach(u=>delete a[u]),Object.entries(r.insert).forEach(([u,f])=>{a[u]=f}),l[s]=a,this.callbacks.forEach(u=>{var f;return(f=u.onUpdateBlockData)==null?void 0:f.call(u,e,s,r,!0)})}onCreateContainer(e,o,r){this.doc.blocks[e]=Y.default(o),this.callbacks.forEach(i=>{var s;return(s=i.onInsertChildContainer)==null?void 0:s.call(i,e,o,!0)})}}const{t:e9}=S;function li(n,t){return t==="insert"?e9("version.insert",{name:n.displayName}):e9("version.delete",{name:n.displayName})}function sr(n,t){const{userId:e}=t;return["flag","selection"].reduce((r,i)=>{const s=n.doc.getRemoteUsers().getFixedUserColor(e,i);return r[i]=s,r},{})}class IN{renderText(t,e,o){if(!o.box&&o.insertedBy){const r=o.insertedBy,{flag:i,selection:s}=sr(t,o.insertedBy);return{classes:["history-inserted-text"],attributes:{"history-inserted-by":r.displayName,"data-op-description":li(r,"insert")},styles:{[ri]:i,[ii]:s}}}return{}}renderBlock(t,e,o){if(o.deletedBy){const r=o.deletedBy,{flag:i,selection:s}=sr(t,r);return{classes:["history-deleted-block"],attributes:{"history-deleted-by":r.displayName,"data-op-description":li(r,"delete")},styles:{[ri]:i,[ii]:s}}}if(o.insertedBy){const r=o.insertedBy,{flag:i,selection:s}=sr(t,r);return{classes:["history-inserted-block"],attributes:{"history-inserted-by":r.displayName,"data-op-description":li(r,"insert")},styles:{[ri]:i,[ii]:s}}}return{}}updateBlock(t,e,o,r){if(r.deletedBy){const i=r.deletedBy,{flag:s,selection:l}=sr(t,i);M(o,"history-deleted-block"),Wa(o,{"history-inserted-by":i.displayName,"data-op-description":li(i,"delete")}),Ga(o,{[ri]:s,[ii]:l});return}if(r.insertedBy){const i=r.insertedBy,{flag:s,selection:l}=sr(t,i);M(o,"history-inserted-block"),Wa(o,{"history-inserted-by":i.displayName,"data-op-description":li(i,"insert")}),Ga(o,{[ri]:s,[ii]:l})}}}const n9=y("history-deleted-box");function xN(n,t,e,o){const r=o;d(n9,r.text,`no text for text box data: ${JSON.stringify(o)}`),d(n9,typeof r.text=="string",`invalid text type for text box data: ${JSON.stringify(o)}`);const i=b("span",["history-deleted-box"],e,r.text),s=r.user,{flag:l,selection:c}=sr(n,s);i.setAttribute("history-deleted-by",s.displayName),i.setAttribute("data-op-description",li(s,"delete")),i.style.setProperty(ri,l),i.style.setProperty(ii,c)}const SN={boxType:"history-deleted-box",updateBoxContent:xN},Se=y("version-dialog");class TN{constructor(t,e){h(this,"editor");h(this,"dialog",null);h(this,"oldViewer",null);h(this,"versionOptions",{});h(this,"versionList",null);h(this,"actionButtons",null);h(this,"provider");h(this,"components");h(this,"handleClose",()=>{var t;(t=this.dialog)==null||t.hide()});h(this,"handlePlay",()=>{var e;d(Se,this.versionList,"The versionList did not render");const t=(e=this.versionList)==null?void 0:e.activeVersion;d(Se,t,`The version: ${t} is invalid`),this.viewVersion(t,{play:!0,speed:150})});h(this,"handleRevert",async()=>{var e,o;d(Se,this.versionList,"The versionList did not render");const t=(e=this.versionList)==null?void 0:e.activeVersion;d(Se,t,`The version: ${t} is invalid`),await this.versionHelper.revertVersion(t.version),(o=this.dialog)==null||o.hide()});h(this,"handleSelectVersion",t=>{d(Se,t,`The version: ${t} is invalid`),this.viewVersion(t)});h(this,"viewVersion",async(t,e={play:!1,speed:1e3})=>{this.oldViewer&&(this.oldViewer.destroy(),this.oldViewer=null),d(Se,this.versionList,"The versionList did not render"),d(Se,this.actionButtons,"The actionButtons did not render");const o=t.type==="minor"?this.versionList.beforeVersion:this.versionList.beforeMajorVersion,r=o?o.version:0,i=this.versionList.isSelectedFirstVersion,s=this.versionList.isSelectedLastVersion;this.actionButtons.revertButton.disabled=i,this.actionButtons.playButton.disabled=i;let l=this.versionOptions.hideOps;if(this.versionOptions.onWillChangeVersion){const C=this.versionOptions.onWillChangeVersion(this.editor,t,i,s);C!=null&&C.hideOps&&(l=!0)}let c,a;if(l)c=await this.versionHelper.getVersion(t.version),a=[];else{const C=await this.versionHelper.getHistoryData(t.version,r);c=C.doc,a=C.historyData}const{editorElement:u}=this.components;u.innerHTML="";const f=new EN(c,this.editor),m=this.provider.createHistoryEditor(u,f);m.editorBlockRenders.registerRender(new IN),m.editorBoxes.registerBoxClass(SN),M(m.rootElement,G3.HISTORY);try{await dN(f,this.versionHelper,a,e)}finally{this.oldViewer=m}this.versionOptions.onVersionChanged&&this.versionOptions.onVersionChanged(this.editor,m,t,i,s)});this.editor=t,this.provider=e;const o=b("div",["version-dialog"],null),r=b("div",["version-dialog-note-viewer"],o),i=b("div",["version-dialog-action-container"],r),s=b("div",["version-dialog-editor"],r),l=b("div",["version-dialog-versions-list"],o);this.components={root:o,editorElement:s,actionContainer:i,versionsListContainer:l}}get versionHelper(){d(Se,this.editor.doc.getVersionHelper,"Can not get getVersionHelper from doc");const t=this.editor.doc.getVersionHelper();return d(Se,t,"current doc does not support version"),t}renderContent(t){const{actionContainer:e,versionsListContainer:o}=this.components;e.innerHTML="";const{hideActions:r}=this.versionOptions,i=new hN({onBack:this.handleClose,onPlay:this.handlePlay,onRevert:this.handleRevert});i.render(e,r),this.actionButtons=i,o.innerHTML="";const s=new lN({versions:t,useCreatedBy:this.versionOptions.useCreatedBy,onSelectVersion:this.handleSelectVersion,getMarkColor:l=>{const{flag:c}=sr(this.editor,l);return c}});s.render(o),this.versionList=s}initViewVersion(){if(this.versionOptions.initSelectedVersion){d(Se,this.versionList,"The versionList did not render");const{initSelectedVersion:t}=this.versionOptions,e=this.versionList.selectVersionByVersionNum(t);d(Se,e,`The version: ${e} is invalid`),this.viewVersion(e)}else{d(Se,this.versionList,"The versionList did not render");const t=this.versionList.activeVersion;d(Se,t,`The version: ${t} is invalid`),this.viewVersion(t)}}async show(t={}){this.versionOptions={...this.versionOptions,...t};const e=await this.versionHelper.getVersions();if(this.versionOptions.hideNonVersionedOps&&e.length&&e[0].version===-1&&e.shift(),this.versionOptions.onVersionsLoaded&&this.versionOptions.onVersionsLoaded(this.editor,e),this.renderContent(e),this.initViewVersion(),!this.dialog){const{root:o}=this.components;this.dialog=new sN(o)}this.dialog.show()}destroy(){var t,e,o;(t=this.dialog)==null||t.destroy(),(e=this.versionList)==null||e.destroy(),(o=this.actionButtons)==null||o.destroy()}}function DN(n,t,e){n.addCustom("version-dialog",()=>new TN(n,t)).show(e)}const iz="",LN=y("heading-collapse");function nf(n){var e;const t=Number.parseInt((e=n.getAttribute("data-style-heading"))!=null?e:"",10);return d(LN,t,"not a heading block"),t}function je(n){return!!n.getAttribute("data-style-heading")}function MN(n){return!lt(n,"heading-collapsed")}function lr(n){return lt(n,"heading-collapsed")}function o9(n){if(gt(n))return!1;const e=H(n);return Ct(e)}const RN=y("heading-collapse");function of(n){d(RN,je(n),"not a heading block");const t=[],e=nf(n);let o=ht(n);for(;o&&!(je(o)&&nf(o)<=e);)t.push(o),o=ht(o);return t}function r9(n,t){if(!Vo(t))return;n.selection.selectBlock(t,0),of(t).forEach(o=>{Em(o)}),M(t,"heading-collapsed")}function ci(n,t){of(t).forEach(o=>{Im(o)}),F(t,"heading-collapsed")}function AN(n,t){MN(t)?r9(n,t):ci(n,t)}const ON=[Qd,Kd,Jd,Xd,tu,eu,nu,ou];function _N(n){const t=b("button",["heading-collapse-button"],null);return t.setAttribute(`data-editor-tooltip-${n.clientId}`,"Collapse / Expand"),t.innerHTML=oc,t}function i9(n){return Gc(n).querySelector("button.heading-collapse-button")}function s9(n,t){i9(t)||o9(t)||!Vo(t)||yh(t,_N(n),-1)}function NN(n){var t;(t=i9(n))==null||t.remove()}function l9(n,t){Gc(t).querySelector("button.heading-collapse-button")||s9(n,t)}function PN(n){const t=nf(n),e=b("button",["heading-marker"],null);return e.innerHTML=ON[t-1],e}function c9(n){return Gc(n).querySelector("button.heading-marker")}function rf(n){c9(n)||o9(n)||!Vo(n)||yh(n,PN(n),1)}function a9(n){const t=c9(n);t==null||t.remove()}function d9(n){a9(n),je(n)&&rf(n)}class $N{handleDrop(t,e,o,r){if(sl(e)||!je(e)||!lr(e))return;const i=of(e);i.unshift(e);const s=i.reverse();let l=null;return t.doc.beginBatchUpdate(),s.forEach((c,a,u)=>{const f=t.getBlockData(c),m=Fo(t.editorBlocks,t.doc.toJSON(),f),C=t.insertDocAt(o,r,m)[0];a===u.length-1&&(l=C)}),t.doc.endBatchUpdate(),t.doc.beginBatchUpdate(),s.forEach(c=>{t.deleteBlock(c)}),t.doc.endBatchUpdate(),l&&r9(t,l),!0}}const HN=y("heading-collapse");class jN{constructor(t){h(this,"handleLoad",()=>{this.showCollapseButtons()});h(this,"handleHoverBlock",(t,e)=>{e&&(F(e,"hovering-heading"),je(e)&&Ct(H(e))&&(rf(e),lr(e)||NN(e))),t&&je(t)&&Ct(H(t))&&(M(t,"hovering-heading"),a9(t),s9(this.editor,t))});h(this,"handleClick",(t,e)=>{const o=Bi(e,"button.heading-collapse-button");if(!o)return;const r=z(o);!r||(d(HN,je(r),"not a heading block"),AN(this.editor,r),l9(this.editor,r))});this.editor=t,t.addListener("load",this.handleLoad),t.addListener("click",this.handleClick),_t.get(t).addListener("change",this.handleHoverBlock),this.showCollapseButtons(),setTimeout(()=>{Ts.get(t).addHandler(new $N)})}showCollapseButtons(){const t=Rt(this.editor.rootContainer).filter(je);t.length!==0&&(t[0]===Qt(this.editor.rootContainer)&&t.splice(0,1),t.forEach(rf))}destroy(){this.editor.removeListener("load",this.handleLoad),this.editor.removeListener("click",this.handleClick)}}function ua(n){const t=n.selection.range;if(t.isCollapsed()||t.start.blockId===t.end.blockId)return;const e=n.getBlockById(t.start.blockId),o=n.getBlockById(t.end.blockId);lr(e)&&ci(n,e),lr(o)&&ci(n,o)}function FN(n){ua(n);const t=n.getFocusedBlock();!je(t)||lr(t)&&ci(n,t)}function zN(n){ua(n);const t=n.getFocusedBlock();if(!je(t))return;const e=n.selection.range.focus;!e.isSimple()||e.offset===Z(n,t)&&lr(t)&&ci(n,t)}function VN(n){ua(n);const t=n.getFocusedBlock();if(!je(t))return;const e=n.selection.range.focus;!e.isSimple()||e.offset===0&&lr(t)&&ci(n,t)}class UN{handleBeforeKeyDown(t,e){return Ka(e.key)&&ua(t),e.key==="Enter"?(FN(t),!1):e.key==="Delete"?(zN(t),!1):(e.key==="Backspace"&&VN(t),!1)}}class qN{constructor(t){this.editor=t}onInsertBlock(t,e,o,r){this.updateBlockIfNeeded(o.id)}onUpdateBlockData(t,e,o,r){const i=this.editor.doc.getBlockData(t,e);this.updateBlockIfNeeded(i.id,o)}updateBlockIfNeeded(t,e){setTimeout(()=>{const o=this.editor.findBlockById(t);if(!!o){if(!je(o)){e&&e.delete.includes("heading")&&d9(o);return}lt(o,"hovering-heading")&&l9(this.editor,o),d9(o)}},100)}}function WN(n){return!!n.heading}function u9(n){var e;const t=n.heading;return(e=Number.parseInt(`${t}`,10))!=null?e:1}function h9(n,t){var e;return{parentNode:t,children:[],text:Tt((e=n.text)!=null?e:[]),level:u9(n),block:n}}class Ns{constructor(){h(this,"nodes",[])}appendBlock(t){const e=this.findParent(u9(t),this.nodes);e?e.children.push(h9(t,e)):this.nodes.push(h9(t,null))}findParent(t,e){const o=e[e.length-1];if(!o||t<=1)return null;if(o.level===t-1)return o;const r=this.findParent(t,o.children);return r||(o.level<t?o:null)}static buildToc(t){const e=new Ns,o=t.blocks.root;for(let r=0;r<o.length;r++){const i=o[r];WN(i)&&e.appendBlock(i)}return e}}class cr extends Wt.TypedEmitter{constructor(e){super();h(this,"toc",new Ns);h(this,"updateToc",ie.default(()=>{this.updateTocNow()},500));this.editor=e,e.doc.registerCallback(this),this.updateToc()}destroy(){this.editor.doc.unregisterCallback(this)}isHeadingBlock(e){return!!e.heading}onInsertBlock(e,o,r,i){e==="root"&&this.isHeadingBlock(r)&&this.updateToc()}onDeleteBlock(e,o,r){e==="root"&&this.updateToc()}onUpdateBlockText(e,o,r,i){if(e!=="root")return;const s=this.editor.doc.getBlockData(e,o);this.isHeadingBlock(s)&&this.updateToc()}onUpdateBlockData(e,o,r,i){if(e!=="root")return;const s=this.editor.doc.getBlockData(e,o);this.isHeadingBlock(s)&&this.updateToc()}static register(e){return e.addCustom("editor-toc",()=>new cr(e))}static get(e){return e.getCustom("editor-toc")}updateTocNow(){this.toc=Ns.buildToc(this.editor.doc.toJSON()),this.emit("change",this.editor,this.toc)}}const sz="";function GN(n){return n.nodes.length===0?!0:n.nodes.length>1?!1:n.nodes[0].children.length===0}function sf(n,t){t.forEach(e=>{const o=b("div",["toc-node"],n),r=b("div",["toc-title"],o);if(b("span",["toc-text"],r,e.text).setAttribute("data-block-id",e.block.id),e.children.length>0){const s=b("div",["toc-children"],o);sf(s,e.children)}})}function ZN(n,t){const e=Bi(t,".toc-text");if(!e)return;const o=e.getAttribute("data-block-id");if(!o)return;const r=n.findBlockById(o);!r||(t.preventDefault(),t.stopPropagation(),n.selection.selectBlock(r,0))}function f9(n,t,e){if(F(t,"loading"),t.innerHTML="",GN(e)){b("div",["toc-empty-message"],t,"No toc");return}e.nodes.length===1?sf(t,e.nodes[0].children):sf(t,e.nodes),xd(n,"toc-click-handler",()=>{n.addListener("click",ZN)})}class YN{constructor(t){h(this,"handleUpdateToc",(t,e)=>{Array.from(t.rootContainer.querySelectorAll('.embed-block[data-type="editor-block"][data-embed-type="toc"]')).forEach(r=>{const i=r.querySelector(".editor-toc-container");i&&f9(t,i,e)})});this.editor=t,cr.register(t).addListener("change",this.handleUpdateToc)}destroy(){cr.register(this.editor).removeListener("change",this.handleUpdateToc)}get toc(){return cr.register(this.editor).toc}}function QN(n,t){const e=b("div",["editor-toc-container"],t),r=n.addCustom("init-editor-toc",()=>new YN(n)).toc;r.nodes.length===0?M(e,"loading"):f9(n,e,r)}function KN(n,t,e,o){return o==="markdown"?"[toc]":""}function JN(n,t,e){const{data:o}=e;if(!o||o.embedType!=="toc"||!j(n,t))return null;const r={};return{blockData:{id:N(),type:"embed",embedType:"toc",embedData:r}}}const m9={embedType:"toc",createEmbedContent:QN,convertTo:KN,convertFrom:JN};function XN(n){return!!n.getAttribute("data-style-heading")}function lf(n,t){return XN(t)&&Z(n,t)>0}function tP(n){const t=Nn(n.rootElement);let e=0,o=0,r=0;if(t===document.documentElement){const i=n.rootContainer.getBoundingClientRect();e=i.left+i.width/2,o=10,r=t.offsetHeight}else{const i=t.getBoundingClientRect();e=i.left+i.width/2,o=i.top+10,r=i.bottom}for(;o<r;){const i=document.elementsFromPoint(e,o);for(let s=0;s<i.length;s++){const l=z(i[s]);if(l&&n.rootContainer.contains(l))return l}o+=10}return null}function cf(n,t){let e=t;for(;e&&!lf(n,e);)e=ht(e);return e}function g9(n){if(gt(n))return!1;const e=H(n);return Ct(e)}function ha(n,t){let e=t;for(;e&&!lf(n,e);)e=gt(e),e&&g9(e)&&(e=null);return e}const eP=.3;class nP extends Wt.TypedEmitter{constructor(e){super();h(this,"scrollContainer");h(this,"scrollEventTarget");h(this,"scrollStatus",{curHeadingBlock:null,previousHeadingBlock:null,nextHeadingBlock:null});h(this,"handleScroll",ie.default(()=>{const e={curHeadingBlock:null,previousHeadingBlock:null,nextHeadingBlock:null};let o=tP(this.editor);if(o&&(o=ul(o)),!o||!this.scrollContainer){this.setStatus(e);return}if(g9(o)&&(o=ht(o)),!o){this.setStatus(e);return}if(lf(this.editor,o)){e.curHeadingBlock=o,e.previousHeadingBlock=ha(this.editor,o),e.nextHeadingBlock=cf(this.editor,o),this.setStatus(e);return}const r=this.scrollContainer.getBoundingClientRect(),i=cf(this.editor,o);if(i){const l=i.getBoundingClientRect();if(l.top>r.top&&l.top<r.top+r.height*eP){e.curHeadingBlock=i,e.previousHeadingBlock=ha(this.editor,i),e.nextHeadingBlock=cf(this.editor,i),this.setStatus(e);return}e.nextHeadingBlock=i}const s=ha(this.editor,o);s&&(e.curHeadingBlock=s,e.previousHeadingBlock=ha(this.editor,s)),this.setStatus(e)},200));this.editor=e,setTimeout(()=>{this.start()},50)}setStatus(e){this.scrollStatus.previousHeadingBlock===e.previousHeadingBlock&&this.scrollStatus.nextHeadingBlock===e.nextHeadingBlock&&this.scrollStatus.previousHeadingBlock===e.previousHeadingBlock||(this.scrollStatus=e,this.emit("change",this.editor,e))}start(){this.stop(),this.scrollContainer=Nn(this.editor.rootElement),this.scrollEventTarget=this.scrollContainer===document.documentElement?document:this.scrollContainer,this.scrollEventTarget.addEventListener("scroll",this.handleScroll),this.handleScroll()}stop(){this.scrollEventTarget&&this.scrollEventTarget.removeEventListener("scroll",this.handleScroll)}destroy(){this.stop(),this.scrollEventTarget=void 0}}class oP{constructor(t,e){h(this,"suggest");h(this,"onShow",(t,e,o,r)=>{const i=this.editor.getBlockByIndex(e,o);if(!Vo(i)){const s=z(H(i));if(s&&it(s)==="code")return!1}return!0});h(this,"onClickItem",(t,e,o)=>{const r=e.data,i={id:N(),type:"mention",box:!0,created:Date.now(),iconUrl:r.avatarUrl,text:r.displayName,mentionId:r.userId},s=this.editor.selection.range;if(!s.isCollapsed()||!s.isSimple())return;const l=s.focus,c=this.editor.getBlockById(l.blockId);this.editor.insertBoxToBlock(c,l.offset,i)});h(this,"queryItems",async(t,e)=>(await this.options.queryUsers(this.editor,e)).map(i=>({id:i.userId,name:i.displayName,icon:`<img src="${i.avatarUrl}" class="mention-user-avatar">`,element:i.element,data:i})));this.editor=t,this.options=e,this.suggest=new uu(t,{id:"editor-mention",trigger:["@"],autoDeleteTrigger:!0,showLoading:!0,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems})}destroy(){}}y("mathjax-box");function rP(n,t,e,o){const r=o,i=b("a",["mention-container"],e);b("span",["mention-name"],i,`@${r.text}`),i.setAttribute("data-mention-id",r.mentionId)}function iP(n,t,e){}const p9={boxType:"mention",updateBoxContent:rP,handleClickBox:iP};function sP(n){return kn("list-block-mention",S.t("list.mention.tooltip"),op,[],n.clientId)}class lP{constructor(t){h(this,"mentionButton");h(this,"handleHoveringBlock",t=>{var e;!this.editor.isWritable()||(t&&this.shouldBlockShowMention(t)?At(t).appendChild(this.mentionButton):(e=this.mentionButton)==null||e.remove())});h(this,"handleMouseDown",(t,e)=>{e.preventDefault(),e.stopPropagation();const o=z(this.mentionButton);if(!o||!j(t,o))return;const r=t.selection.range.focus;if(!r.isSimple())return;let i;t.selection.focusedBlock!==o?i=Z(t,o):i=r.offset,setTimeout(()=>{const s=t.insertTextToBlock(o,i,"@");i+=1;const l=Tt(Ae(s,i).left);this.editor.selection.selectBlock(o,i),this.editor.focus(),t.getCustom("mention").suggest.popup(o,i,l,"@")})});h(this,"destroy",()=>{_t.get(this.editor).removeListener("change",this.handleHoveringBlock)});this.editor=t,this.mentionButton=sP(t),_t.get(this.editor).addListener("change",this.handleHoveringBlock),t.domEvents.addEventListener(this.mentionButton,"mousedown",this.handleMouseDown)}shouldBlockShowMention(t){if(!j(this.editor,t)||!at(t))return!1;const e=He(t);return!(e==="ordered"||e==="unordered")}}const lz="",cP={templates:{title:"\u9009\u62E9\u6A21\u677F\uFF0C\u5FEB\u901F\u521B\u5EFA",create:"\u65B0\u5EFA\u6A21\u677F",choose:"\u5168\u90E8\u6A21\u677F",customizedMark:"\u81EA\u5B9A\u4E49"}},aP={templates:{title:"Choose a template",create:"New template",choose:"All templates",customizedMark:"Custom"}};S.mergeLang({"zh-CN":cP,"en-US":aP});const cz="",az="",dP="data:image/svg+xml;base64,Cjxzdmcgd2lkdGg9IjEyMCIgaGVpZ2h0PSIxMjAiIHZpZXdCb3g9IjAgMCAxMjAgMTIwIiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cmVjdCB3aWR0aD0iMTIwIiBoZWlnaHQ9IjEyMCIgZmlsbD0id2hpdGUiLz4KPHBhdGggZD0iTTQ4IDU5QzQ4IDU0LjU4MTcgNTEuNTgxNyA1MSA1NiA1MUg5M0M5OC41MjI4IDUxIDEwMyA1NS40NzcyIDEwMyA2MVY4OEMxMDMgOTEuODY2IDk5Ljg2NiA5NSA5NiA5NUg1NkM1MS41ODE3IDk1IDQ4IDkxLjQxODMgNDggODdWNTlaIiBmaWxsPSIjRDZFOUZBIi8+CjxwYXRoIGQ9Ik0xOCA2NEMxOCA2Mi4zNDMxIDE5LjM0MzEgNjEgMjEgNjFINTZDNjAuNDE4MyA2MSA2NCA2NC41ODE3IDY0IDY5VjgzQzY0IDg1LjIwOTEgNjIuMjA5MSA4NyA2MCA4N0gyNkMyMS41ODE3IDg3IDE4IDgzLjQxODMgMTggNzlWNjRaIiBmaWxsPSIjRUFFNEY2Ii8+CjxyZWN0IHg9IjI0IiB5PSIzMSIgd2lkdGg9IjY1IiBoZWlnaHQ9IjUwIiByeD0iNSIgZmlsbD0iIzk5QzdGMiIvPgo8cmVjdCB4PSIzMy41IiB5PSI0MyIgd2lkdGg9IjQ2IiBoZWlnaHQ9IjUiIHJ4PSIyLjUiIGZpbGw9IndoaXRlIi8+CjxyZWN0IHg9IjMzLjUiIHk9IjU0IiB3aWR0aD0iNDYiIGhlaWdodD0iNSIgcng9IjIuNSIgZmlsbD0id2hpdGUiLz4KPHJlY3QgeD0iMjQiIHk9IjMxIiB3aWR0aD0iNjUiIGhlaWdodD0iNTAiIHJ4PSI1IiBzdHJva2U9IiNGOEY4RjgiLz4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01MCA4NS4yNjhDNTMuODI2MyA4My4wNTg5IDU1LjEzNzMgNzguMTY2MiA1Mi45MjgyIDc0LjMzOThMNjMuMzIwNSA2OC4zMzk4QzY4Ljg0MzMgNzcuOTA1NyA2NS41NjU4IDkwLjEzNzUgNTYgOTUuNjYwNEM0Ni40MzQxIDEwMS4xODMgMzQuMjAyMyA5Ny45MDU3IDI4LjY3OTQgODguMzM5OEwzOS4wNzE3IDgyLjMzOThDNDEuMjgwOSA4Ni4xNjYyIDQ2LjE3MzYgODcuNDc3MiA1MCA4NS4yNjhaIiBmaWxsPSIjQUI5M0RDIi8+CjxyZWN0IHg9IjU5IiB5PSI2NSIgd2lkdGg9IjQyIiBoZWlnaHQ9IjI4IiByeD0iNSIgZmlsbD0id2hpdGUiLz4KPHBhdGggZD0iTTYzIDg4VjczLjA4MDhDNjMgNzEuNzA5NiA2My4zNjE0IDcwLjY4NjcgNjQuMDg0MSA3MC4wMTJDNjQuODI4NyA2OS4zMzczIDY1Ljg1OCA2OSA2Ny4xNzIgNjlIOTIuODYwOUM5NS42MjAzIDY5IDk3IDcwLjM2MDMgOTcgNzMuMDgwOFY4OEg5My41MTc5TDg3LjM3NDkgODAuNjIyQzg3LjA5MDIgODAuMzE3MyA4Ni43NjE3IDgwLjA4ODggODYuMzg5NCA3OS45MzY0Qzg2LjAxNzEgNzkuNzg0MSA4NS42NDQ4IDc5LjcwNzkgODUuMjcyNSA3OS43MDc5Qzg0LjkwMDIgNzkuNzA3OSA4NC41Mjc5IDc5Ljc4NDEgODQuMTU1NiA3OS45MzY0QzgzLjgwNTIgODAuMDg4OCA4My40NTQ4IDgwLjMxNzMgODMuMTA0MyA4MC42MjJMNzYuNzMxNCA4Ni4yMzcxTDc0LjIwMTkgODMuOTUxOUM3My42MzI1IDgzLjQyOTYgNzMuMDA4NCA4My4xNjg0IDcyLjMyOTUgODMuMTY4NEM3MS42NTA2IDgzLjE2ODQgNzEuMDM3NCA4My40Mjk2IDcwLjQ4OTkgODMuOTUxOUw2Ni40NDkzIDg4SDYzWk03NC40NjQ3IDgwLjYyMkM3NS4zNjI2IDgwLjYyMiA3Ni4xNDAxIDgwLjI5NTUgNzYuNzk3MSA3OS42NDI2Qzc3LjQ3NiA3OC45ODk3IDc3LjgxNTUgNzguMjE3MSA3Ny44MTU1IDc3LjMyNDdDNzcuODE1NSA3Ni40MTA3IDc3LjQ3NiA3NS42MzggNzYuNzk3MSA3NS4wMDY5Qzc2LjE0MDEgNzQuMzU0IDc1LjM2MjYgNzQuMDE2NiA3NC40NjQ3IDczLjk5NDhDNzMuNTQ0OSA3My45NTEzIDcyLjc1NjUgNzQuMjY2OSA3Mi4wOTk1IDc0Ljk0MTZDNzEuNDQyNSA3NS42MTYzIDcxLjExNCA3Ni40MTA3IDcxLjExNCA3Ny4zMjQ3QzcxLjExNCA3OC4yMTcxIDcxLjQ0MjUgNzguOTg5NyA3Mi4wOTk1IDc5LjY0MjZDNzIuNzU2NSA4MC4yOTU1IDczLjU0NDkgODAuNjIyIDc0LjQ2NDcgODAuNjIyWiIgZmlsbD0iI0Y3RDA3RiIvPgo8Y2lyY2xlIGN4PSI5NSIgY3k9IjQyIiByPSIyIiBzdHJva2U9IiM1MEMzOTgiIHN0cm9rZS13aWR0aD0iMiIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTk0Ljc1MDEgMjQuNDY4N0wxMDAuNzgxIDI3LjkxNDlMOTQuNzE5IDMxLjQxNDlMOTQuNzUwMSAyNC40Njg3WiIgc3Ryb2tlPSIjNUNBNUVBIiBzdHJva2Utd2lkdGg9IjEuOCIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwNSAzOEMxMDUgMzguNTUyMyAxMDUuNDQ4IDM5IDEwNiAzOUMxMDYuNTUyIDM5IDEwNyAzOC41NTIzIDEwNyAzOFYzNkgxMDlDMTA5LjU1MiAzNiAxMTAgMzUuNTUyMyAxMTAgMzVDMTEwIDM0LjQ0NzcgMTA5LjU1MiAzNCAxMDkgMzRIMTA3VjMyQzEwNyAzMS40NDc3IDEwNi41NTIgMzEgMTA2IDMxQzEwNS40NDggMzEgMTA1IDMxLjQ0NzcgMTA1IDMyVjM0SDEwM0MxMDIuNDQ4IDM0IDEwMiAzNC40NDc3IDEwMiAzNUMxMDIgMzUuNTUyMyAxMDIuNDQ4IDM2IDEwMyAzNkgxMDVWMzhaIiBmaWxsPSIjQUI5M0RDIi8+Cjwvc3ZnPgo=",uP="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzcyIiBoZWlnaHQ9IjI3OSIgdmlld0JveD0iMCAwIDM3MiAyNzkiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMF8xMjU2XzM3MTY4KSI+CjxyZWN0IHdpZHRoPSIzNzIiIGhlaWdodD0iMjc5IiBmaWxsPSJ3aGl0ZSIvPgo8cmVjdCB4PSIzOS41NzQ1IiB5PSIzOS41NzQ3IiB3aWR0aD0iMTE4LjcyMyIgaGVpZ2h0PSIxNS44Mjk4IiByeD0iNy45MTQ4OSIgZmlsbD0iI0VBRjNGQyIvPgo8cmVjdCB4PSIzOS41NzQ1IiB5PSI3MS4yMzM5IiB3aWR0aD0iMjkyLjg1MSIgaGVpZ2h0PSI3LjkxNDg5IiByeD0iMy45NTc0NSIgZmlsbD0iI0VBRjNGQyIvPgo8cmVjdCB4PSIzOS41NzQ1IiB5PSI5MS4wMjE1IiB3aWR0aD0iMjkyLjg1MSIgaGVpZ2h0PSI3LjkxNDg5IiByeD0iMy45NTc0NSIgZmlsbD0iI0VBRjNGQyIvPgo8cmVjdCB4PSIzOS41NzQ1IiB5PSIxMTAuODA5IiB3aWR0aD0iMjkyLjg1MSIgaGVpZ2h0PSI3LjkxNDg5IiByeD0iMy45NTc0NSIgZmlsbD0iI0VBRjNGQyIvPgo8cmVjdCB4PSI0MC41NjM4IiB5PSIxMzUuNTQzIiB3aWR0aD0iMjkwLjg3MiIgaGVpZ2h0PSIxMDAuOTE1IiByeD0iMi45NjgwOSIgc3Ryb2tlPSIjRUFGM0ZDIiBzdHJva2Utd2lkdGg9IjEuOTc4NzIiLz4KPHBhdGggZD0iTTM5LjU3NDUgMTM4LjUxMUMzOS41NzQ1IDEzNi4zMjUgNDEuMzQ2MyAxMzQuNTUzIDQzLjUzMTkgMTM0LjU1M0gzMjguNDY4QzMzMC42NTQgMTM0LjU1MyAzMzIuNDI2IDEzNi4zMjUgMzMyLjQyNiAxMzguNTExVjE1Mi4zNjJIMzkuNTc0NVYxMzguNTExWiIgZmlsbD0iI0Q2RTlGQSIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTg3LjA2MzcgMTY5LjE4MUM4Ny4wNjM3IDE2Ny41NDIgODguMzkyNiAxNjYuMjEzIDkwLjAzMTggMTY2LjIxM0gzMTcuNTg1QzMxOS4yMjQgMTY2LjIxMyAzMjAuNTUzIDE2Ny41NDIgMzIwLjU1MyAxNjkuMTgxQzMyMC41NTMgMTcwLjgyIDMxOS4yMjQgMTcyLjE0OSAzMTcuNTg1IDE3Mi4xNDlIOTAuMDMxOEM4OC4zOTI2IDE3Mi4xNDkgODcuMDYzNyAxNzAuODIgODcuMDYzNyAxNjkuMTgxWk0xMDQuODcyIDE5Mi45MjZDMTA0Ljg3MiAxOTEuMjg2IDEwNi4yMDEgMTg5Ljk1NyAxMDcuODQgMTg5Ljk1N0gzMTcuNTg1QzMxOS4yMjQgMTg5Ljk1NyAzMjAuNTUzIDE5MS4yODYgMzIwLjU1MyAxOTIuOTI2QzMyMC41NTMgMTk0LjU2NSAzMTkuMjI0IDE5NS44OTQgMzE3LjU4NSAxOTUuODk0SDEwNy44NEMxMDYuMjAxIDE5NS44OTQgMTA0Ljg3MiAxOTQuNTY1IDEwNC44NzIgMTkyLjkyNlpNMTA3Ljg0IDIxMy43MDJDMTA2LjIwMSAyMTMuNzAyIDEwNC44NzIgMjE1LjAzMSAxMDQuODcyIDIxNi42N0MxMDQuODcyIDIxOC4zMDkgMTA2LjIwMSAyMTkuNjM4IDEwNy44NCAyMTkuNjM4SDMxNy41ODVDMzE5LjIyNCAyMTkuNjM4IDMyMC41NTMgMjE4LjMwOSAzMjAuNTUzIDIxNi42N0MzMjAuNTUzIDIxNS4wMzEgMzE5LjIyNCAyMTMuNzAyIDMxNy41ODUgMjEzLjcwMkgxMDcuODRaIiBmaWxsPSIjRDZFOUZBIi8+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNNTEuNDQ2OCAxNjkuMTgxQzUxLjQ0NjggMTY3LjU0MiA1Mi43NzU2IDE2Ni4yMTMgNTQuNDE0OSAxNjYuMjEzSDYwLjM1MUM2MS45OTAzIDE2Ni4yMTMgNjMuMzE5MSAxNjcuNTQyIDYzLjMxOTEgMTY5LjE4MUM2My4zMTkxIDE3MC44MiA2MS45OTAzIDE3Mi4xNDkgNjAuMzUxIDE3Mi4xNDlINTQuNDE0OUM1Mi43NzU2IDE3Mi4xNDkgNTEuNDQ2OCAxNzAuODIgNTEuNDQ2OCAxNjkuMTgxWk01MS40NDY4IDE5Mi45MjZDNTEuNDQ2OCAxOTEuMjg2IDUyLjc3NTcgMTg5Ljk1NyA1NC40MTQ5IDE4OS45NTdINjAuMzUxMUM2MS45OTAzIDE4OS45NTcgNjMuMzE5MSAxOTEuMjg2IDYzLjMxOTEgMTkyLjkyNkM2My4zMTkxIDE5NC41NjUgNjEuOTkwMyAxOTUuODk0IDYwLjM1MTEgMTk1Ljg5NEg1NC40MTQ5QzUyLjc3NTcgMTk1Ljg5NCA1MS40NDY4IDE5NC41NjUgNTEuNDQ2OCAxOTIuOTI2Wk01NC40MTQ5IDIxMy43MDJDNTIuNzc1NyAyMTMuNzAyIDUxLjQ0NjggMjE1LjAzMSA1MS40NDY4IDIxNi42N0M1MS40NDY4IDIxOC4zMDkgNTIuNzc1NyAyMTkuNjM4IDU0LjQxNDkgMjE5LjYzOEg2MC4zNTExQzYxLjk5MDMgMjE5LjYzOCA2My4zMTkxIDIxOC4zMDkgNjMuMzE5MSAyMTYuNjdDNjMuMzE5MSAyMTUuMDMxIDYxLjk5MDMgMjEzLjcwMiA2MC4zNTExIDIxMy43MDJINTQuNDE0OVoiIGZpbGw9IiM5OUM3RjIiLz4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik02OS4yNTU0IDE2OS4xODFDNjkuMjU1NCAxNjcuNTQyIDcwLjU4NDMgMTY2LjIxMyA3Mi4yMjM1IDE2Ni4yMTNINzguMTU5N0M3OS43OTg5IDE2Ni4yMTMgODEuMTI3OCAxNjcuNTQyIDgxLjEyNzggMTY5LjE4MUM4MS4xMjc4IDE3MC44MiA3OS43OTg5IDE3Mi4xNDkgNzguMTU5NyAxNzIuMTQ5SDcyLjIyMzVDNzAuNTg0MyAxNzIuMTQ5IDY5LjI1NTQgMTcwLjgyIDY5LjI1NTQgMTY5LjE4MVpNNjkuMjU1NCAxOTIuOTI2QzY5LjI1NTQgMTkxLjI4NiA3MC41ODQyIDE4OS45NTcgNzIuMjIzNSAxODkuOTU3SDc4LjE1OTZDNzkuNzk4OSAxODkuOTU3IDgxLjEyNzcgMTkxLjI4NiA4MS4xMjc3IDE5Mi45MjZDODEuMTI3NyAxOTQuNTY1IDc5Ljc5ODkgMTk1Ljg5NCA3OC4xNTk2IDE5NS44OTRINzIuMjIzNUM3MC41ODQyIDE5NS44OTQgNjkuMjU1NCAxOTQuNTY1IDY5LjI1NTQgMTkyLjkyNlpNNzIuMjIzNSAyMTMuNzAyQzcwLjU4NDIgMjEzLjcwMiA2OS4yNTU0IDIxNS4wMzEgNjkuMjU1NCAyMTYuNjdDNjkuMjU1NCAyMTguMzA5IDcwLjU4NDIgMjE5LjYzOCA3Mi4yMjM1IDIxOS42MzhINzguMTU5NkM3OS43OTg5IDIxOS42MzggODEuMTI3NyAyMTguMzA5IDgxLjEyNzcgMjE2LjY3QzgxLjEyNzcgMjE1LjAzMSA3OS43OTg5IDIxMy43MDIgNzguMTU5NiAyMTMuNzAySDcyLjIyMzVaIiBmaWxsPSIjRjdEMDdGIi8+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNOTAuMDMxOCAxODkuOTU4Qzg4LjM5MjYgMTg5Ljk1OCA4Ny4wNjM3IDE5MS4yODYgODcuMDYzNyAxOTIuOTI2Qzg3LjA2MzcgMTk0LjU2NSA4OC4zOTI2IDE5NS44OTQgOTAuMDMxOCAxOTUuODk0SDk1Ljk2OEM5Ny42MDcyIDE5NS44OTQgOTguOTM2MSAxOTQuNTY1IDk4LjkzNjEgMTkyLjkyNkM5OC45MzYxIDE5MS4yODYgOTcuNjA3MiAxODkuOTU4IDk1Ljk2OCAxODkuOTU4SDkwLjAzMThaTTkwLjAzMTkgMjEzLjcwMkM4OC4zOTI3IDIxMy43MDIgODcuMDYzOCAyMTUuMDMxIDg3LjA2MzggMjE2LjY3Qzg3LjA2MzggMjE4LjMwOSA4OC4zOTI3IDIxOS42MzggOTAuMDMxOSAyMTkuNjM4SDk1Ljk2ODFDOTcuNjA3MyAyMTkuNjM4IDk4LjkzNjIgMjE4LjMwOSA5OC45MzYyIDIxNi42N0M5OC45MzYyIDIxNS4wMzEgOTcuNjA3MyAyMTMuNzAyIDk1Ljk2ODEgMjEzLjcwMkg5MC4wMzE5WiIgZmlsbD0iIzkxRDlCRSIvPgo8L2c+CjxkZWZzPgo8Y2xpcFBhdGggaWQ9ImNsaXAwXzEyNTZfMzcxNjgiPgo8cmVjdCB3aWR0aD0iMzcyIiBoZWlnaHQ9IjI3OSIgZmlsbD0id2hpdGUiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4K",C9=y("templates");function af(n){const t=n.rootElement.querySelector(":scope .editor-templates");if(!t)return null;const e=t.querySelector(":scope .editor-templates-cards");return d(C9,e,"no card container"),{root:t,cardContainer:e}}function hP(n){const t=af(n);if(t)return t.cardContainer.innerHTML="",t;const e=b("div",["editor-templates"],n.rootElement);b("div",["editor-templates-title"],e,S.t("templates.title"));const o=b("div",["editor-templates-cards"],e);return{root:e,cardContainer:o}}function b9(n,t,e,o,r){var f;const i=(f=n.options.componentsOptions)==null?void 0:f.templates,s=b("div",["editor-template-card",...o],null),l=b("div",["editor-template-thumb-container"],s),c=b("img",["editor-template-thumb"],l);c.src=t,c.style.display="none",c.onerror=()=>{var C;const m=(C=i==null?void 0:i.placeHolderImageSrc)!=null?C:uP;c.src!==m&&(c.src=m)},c.onload=()=>{c.style.display=""};const a=b("div",["editor-template-name"],s),u=b("span",[],a,e);return i!=null&&i.showTemplateTitleAttr&&u.setAttribute("title",e),s.onclick=()=>r(s),s}function fP(n,t){return t.thumbnailUrl?t.thumbnailUrl:n.doc.buildResourceUrl("thumbnail.png")}function mP(n,t){const e=fP(n,t);return b9(n,e,t.name,[],async()=>{var r,i;const o=(r=n.options.componentsOptions)==null?void 0:r.templates;(i=o==null?void 0:o.onApplyTemplate)==null||i.call(o,n,t)})}function gP(n,t){return b9(n,t,S.t("templates.choose"),["more"],()=>{var o,r;const e=(o=n.options.componentsOptions)==null?void 0:o.templates;(r=e==null?void 0:e.onChooseTemplate)==null||r.call(e,n)})}function pP(n,t){var f,m;const e=(f=n.options.componentsOptions)==null?void 0:f.templates;if(!e)return;const r=Gt(n.rootContainer).getBoundingClientRect().width;let i=1;const s=dP,l=af(n);if(l){if(t!=null&&t.reset){const C=Array.from(l.cardContainer.children),v=l.cardContainer.firstElementChild;if(d(C9,v,"no first card"),lt(v,"new")||lt(v,"more"))return;const w=window.getComputedStyle(v),E=parseFloat(w.marginLeft),L=parseFloat(w.marginRight),x=v.getBoundingClientRect().width+E+L;i=Math.floor(r/x);const O=Math.max(1,i-1-1),P=C.length-2;C.forEach((U,tt)=>{tt>O&&tt<P?U.style.display="none":(tt>=P&&lt(U,"more"),U.style.display="")})}return}const c=e.templates,{cardContainer:a}=hP(n);c.forEach((C,v)=>{const w=mP(n,C);if(v>0&&v>=i&&(w.style.display="none"),a.appendChild(w),v===0){const E=window.getComputedStyle(w),L=parseFloat(E.marginLeft),x=parseFloat(E.marginRight),A=w.getBoundingClientRect().width+L+x;i=Math.floor(r/A)-1}});const u=gP(n,s);a.appendChild(u),(m=e==null?void 0:e.onTemplateChooserStatusChanged)==null||m.call(e,n,a,"visible")}const v9=ie.default(pP,50);function CP(n){var o,r;const t=af(n);if(!t)return;t.root.remove();const e=(o=n.options.componentsOptions)==null?void 0:o.templates;(r=e==null?void 0:e.onTemplateChooserStatusChanged)==null||r.call(e,n,null,"hide")}function bP(n){const t=n.blocks.root;if(t.length===0)return!0;if(t.length>5)return!1;const e=[...t];e[0].type==="text"&&e[0].heading&&e.splice(0,1);const o=r=>{var i;return r.type!=="text"&&r.type!=="list"?!1:r.text?((i=r.text)==null?void 0:i.length)===0:!0};return e.every(r=>o(r))}function k9(n,t){bP(n.doc.toJSON())?v9(n,t):(v9.cancel(),CP(n))}class Ps{constructor(t,e){h(this,"_decrypted",!1);this.editor=t,this.blockData=e}get decrypted(){return this._decrypted||this.blockData.owner===this.editor.doc.getUser().userId}setDecrypted(){this._decrypted=!0}destroy(){}static getState(t,e){return t.addCustom(`encrypted-block-${e.id}`,()=>new Ps(t,e))}}const dz="",bo=y("encrypted-block");function vP(n,t,e,o,r){const i=r,s=eo(o,"div"),l=Ps.getState(n,i);if(l.decrypted)n.createChildContainer(t,s,i.children[0]),M(o,"decrypted");else{M(o,"encrypted");const c=At(o),a=b("div",["password-container"],c),u=b("input",[],a);u.type="text",u.onkeydown=f=>{if(f.key==="Enter"){const m=u.value;if(i.password===Ci.default(`${i.owner}-${m}`)){l.setDecrypted(),n.reloadBlock(o);const C=y1(n,n.getBlockById(i.id));C&&(n.selection.selectBlock(C,0),n.focus())}}}}return s}function kP(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t)||!fn(r))return null;const i=r;if(n.getBlockData(t).children[0]!==V(i))return null;const l=bt(t,V(i));return new Ye(n,{anchor:l,focus:l})}function yP(n,t,e,o){if(Ps.getState(n,n.getBlockData(t)).decrypted)return null;if(o==="ArrowDown"||o==="ArrowRight"){const s=ht(t);return s?$(s,Z(n,s),"end"):$(t,1,"end")}const i=gt(t);return $(i||t,0,"home")}function wP(n,t){return n.getBoundingClientRect()}function BP(n,t,e,o){if(e.isSimple()){d(bo,o.isSimple(),"from is simple position but to is not simple position"),bo.debug("full select table"),M(t,"full-selected");return}d(bo,!o.isSimple(),"from is complex position but end is simple position");const r=e,i=o;d(bo,r.blockId===i.blockId,"only allow update one table selection"),d(bo,r.childContainerId===i.childContainerId,"only one container");const s=n.getBlockData(t),l=n.getContainerById(s.children[0]);M(l,"selected")}function EP(n){n.rootContainer.querySelectorAll('[data-type="editor-block"][data-block-type="encrypted"]').forEach(t=>{F(t,"full-selected"),t.querySelectorAll("selected").forEach(e=>{F(e,"selected")})})}function IP(n,t){const e=n.getBlockData(t);return Ps.getState(n,e).decrypted?[n.getContainerById(e.children[0])]:[]}function xP(n,t,e,o,r){return null}function SP(n,t,e,o){d(bo,e.blockId===o.blockId,"only allow select in single block"),d(bo,G(t)===e.blockId,"only allow select in single block");const r=n.getBlockData(t);return d(bo,e.childContainerId===r.children[0],"only one container"),[n.getContainerById(r.children[0])]}function TP(n){return{name:"EncryptedBlock",insertBlockCommandItems:[{id:"insert-encrypted-block",name:"Encrypted Block"}],async handleInsertEmptyBlock(t,e){const o=pn(t.doc),r={id:N(),type:"encrypted",children:[o],owner:t.doc.getUser().userId,ownerDisplayName:t.doc.getUser().displayName,password:Ci.default(`${t.doc.getUser().userId}-1234`)},i=t.doc.getContainerBlocks(o)[0];return t.insertBlock(e.containerId,e.blockIndex,r,Ot(t,i.id,0))}}}const DP={blockType:"encrypted",blockKind:"complex",enableKeyboardSelect:!0,createBlockContent:vP,getBlockTextLength:()=>1,getRangeFromPoint:kP,moveCaret:yP,getCaretRect:wP,updateSelection:BP,clearSelection:EP,getChildContainers:IP,getNextContainer:xP,getSelectedContainers:SP,getOptions:TP};function LP(n,t,e){const o=Vi(n,t,{components:{blocks:[Cs,ks,DP],decorators:[new ws],embeds:[Jc,hh,Rh,Ah,Oh,Qu,_h,tf,Xh],boxes:[Lc],options:{...e.componentsOptions}}});return o.readonly=!0,o}class MP{constructor(t){this.createOptions=t}createHistoryEditor(t,e){return LP(t,e,this.createOptions)}}y("create-editor");function RP({root:n,localDoc:t,rootEditorCreateOptions:e,shareDBDoc:o}){t.uploadResource=o.uploadResource.bind(o),t.buildResourceUrl=o.buildResourceUrl.bind(o);const r=Vi(n,t,{shortcuts:[Vl],components:{blocks:[Cs,ks],decorators:[new ws],embeds:[b6,Jc,hh,Rh,Ah,Oh,Qu,_h,tf,Xh],boxes:[Lc,p9],options:{...e.componentsOptions}}});return r.input.addHandler(new Hc),r.input.addHandler(new Nh(r)),r.input.addHandler(new n_(r)),r}function AP(n,t){const e=Array.from(n.rootContainer.querySelectorAll(`[comment-${t.toLocaleLowerCase()}="${t}"]`)),o=new Set;e.forEach(r=>{const i=z(r);i&&o.add(i)}),o.forEach(r=>{o_(n,r,t)})}class OP{constructor(t,e){h(this,"listeners",new Set);h(this,"doc");this.editor=t,this.rootEditorCreateOptions=e,this.doc=this.editor.doc.externalDoc,this.doc.registerCallback(this)}getAuth(){return this.doc.client.auth}getComments(){return this.doc.getComments()}getComment(t){return this.doc.getComment(t)}getCommentDoc(t){return this.doc.getCommentDoc(t)}localCreateComment(t,e){this.doc.localCreateComment(t,e)}localDeleteComment(t){const e=this.getComment(t);this.doc.localDeleteComment(t);const o=e.groupId;this.getComments().filter(i=>i.groupId===o).length===0&&AP(this.editor,o)}localUpdateComment(t,e){this.doc.localUpdateComment(t,e)}onCreateComment(t,e){Array.from(this.listeners.values()).forEach(o=>o.onCreateComment(t,e))}onDeleteComment(t,e){Array.from(this.listeners.values()).forEach(o=>o.onDeleteComment(t,e))}onUpdateComment(t,e){Array.from(this.listeners.values()).forEach(o=>o.onUpdateComment(t,e))}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}createCommentEditor(t,e){return RP({root:t,localDoc:e,rootEditorCreateOptions:this.rootEditorCreateOptions,shareDBDoc:this.doc})}}const y9=y("create-editor"),w9=[Jc,hh,Rh,Ah,Oh,Qu,_h,tf,Xh,b6,m9,F_];async function _P(n,t){var r,i,s,l,c,a,u,f,m;d(y9,n,"app does not exists");const e=await ec.load({auth:{appId:t.appId,docId:t.docId,userId:t.user.userId,permission:t.permission,token:t.token,displayName:t.user.displayName,avatarUrl:t.user.avatarUrl},serverUrl:t.serverUrl}),o=Vi(n,e,{id:t.id,components:{blocks:[Cs,ks,bh,s4],commandProviders:[new yu],decorators:[new ws,new zd],embeds:[...w9,...((r=t.components)==null?void 0:r.embeds)||[]],boxes:[Lc,p9,N3],insertions:[j1],blockHooks:[new d6],textRenders:[new L3,new hx],options:{...t.componentsOptions}},shortcuts:[TD,lM,ih,a3,fx,Xu,Vl]});if(o.editorCommandProviders.registerCommandProvider(new xn(o)),o.input.addHandler(new UN),o.input.addHandler(new Hc),o.input.addHandler(new vs(o,{headingLevel:1,titlePlaceholder:"Document title",addPlaceholderToAllCurrentEmptyBlock:!0})),o.input.addHandler(new Mc(o,(i=t.componentsOptions)==null?void 0:i.quickMenu)),o.input.addHandler(new Nh(o)),o.input.addHandler(new t3(o)),o.doc.registerCallback(new qN(o)),o.addCustom("remote-cursor",()=>new s5(o)),o.addCustom("block-menu",C=>new m6(C)),o.addCustom("editor-tooltip",()=>new Ju(o)),o.addCustom("editor-comments",C=>new JO(C,new OP(C,t))),o.addCustom("create-options",()=>new Pf(o,t)),o.addCustom("drop-target",()=>new Ts(o)),o.addCustom("list-to-mindmap",()=>new Sc(o)),o.addCustom("list-to-mention",()=>new lP(o)),(s=t.componentsOptions)!=null&&s.mention){const C=t.componentsOptions.mention;o.addCustom("mention",()=>new oP(o,C))}if(o.addCustom("heading-collapse",()=>new jN(o)),Gr.register(o),Ts.register(o),cr.register(o),(c=(l=t.componentsOptions)==null?void 0:l.remoteCarets)!=null&&c.onUserChanged){const C=(u=(a=t.componentsOptions)==null?void 0:a.remoteCarets)==null?void 0:u.onUserChanged;o.doc.getRemoteUsers().on("change",v=>{C(o,v)})}return(m=(f=t.componentsOptions)==null?void 0:f.templates)!=null&&m.templates.length&&(o.addListener("docChanged",()=>{k9(o)}),setTimeout(()=>{k9(o)},100)),o}async function NP(n,t,e){var i,s;d(y9,n,"app does not exists");const o=new Id(t),r=Vi(n,o,{id:e.id,components:{blocks:[Cs,ks,bh,s4],commandProviders:[new yu],decorators:[new ws,new zd],embeds:[...w9,...((i=e.components)==null?void 0:i.embeds)||[]],boxes:[Lc,N3],insertions:[j1],blockHooks:[new d6],textRenders:[new L3],options:{...e.componentsOptions}},shortcuts:[ih,a3,Xu,Vl]});return r.editorCommandProviders.registerCommandProvider(new xn(r)),r.input.addHandler(new Hc),r.input.addHandler(new vs(r,{headingLevel:1,titlePlaceholder:"Document title",contentPlaceholder:"Enter some text...",addPlaceholderToAllCurrentEmptyBlock:!0})),r.input.addHandler(new Mc(r,(s=e.componentsOptions)==null?void 0:s.quickMenu)),r.input.addHandler(new Nh(r)),r.input.addHandler(new t3(r)),r.addCustom("block-menu",l=>new m6(l)),r.addCustom("editor-tooltip",()=>new Ju(r)),Gr.register(r),r}function PP(n,t){var l;const e=n.doc;if(!((l=e.getVersionHelper)==null?void 0:l.call(e)))throw new Error("the editor does not support to show versions");const r=n.getCustom("create-options");if(!r)throw new Error("the editor does not support to show versions");const i=r.getData(),s=new MP(i);return DN(n,s,t)}g.AuthError=Xl,g.AuthHeader=es,g.AutoScroll=bm,g.BaseURLHeader=tc,g.BlockResizer=$c,g.BrBox=Zg,g.CodeBlock=ks,g.CodeLineBlock=bh,g.CodeTextDecorator=ws,g.DefaultShortcuts=Vl,g.DocIdError=uw,g.DragDrop=Kf,g.DrawioEmbed=Jc,g.EditorBlocks=og,g.EditorBoxes=Qg,g.EditorCommandProviders=k0,g.EditorComplexBlockPosition=Ze,g.EditorComplexSelectionRange=Ye,g.EditorDecorators=t2,g.EditorEmbeds=ig,g.EditorInsertions=Xg,g.EditorSimpleBlockPosition=Vt,g.EditorSimpleSelectionRange=se,g.EmbedBlock=lg,g.EnforceWithDocumentTitleHandler=vs,g.EventCallbacks=ki,g.FILL_CHAR=Eb,g.FileExtError=hw,g.HeadingBlockScrollListener=nP,g.InputtingInsertion=Kg,g.LocalDoc=Id,g.Logger=vi,g.MIN_DISTANCE_THRESHOLD=Yf,g.MarkdownInputHandler=Hc,g.MaxUserError=Pd,g.OnesEditorCustomDataWrapper=Pf,g.OnesEditorHoveringBlock=_t,g.OnesEditorQuickMenu=Mc,g.OnesEditorToc=Ns,g.OnesEditorTocProvider=cr,g.OnesEditorToolbar=Gr,g.OnesEditorTooltip=Ju,g.PermissionError=dw,g.RemoteCarets=s5,g.RemoteCaretsDecorator=zd,g.RemoteCaretsInsertion=j1,g.RemoteUsers=ql,g.RequestReloadError=ts,g.RichText=ne,g.ShareDBDoc=ec,g.SimpleCache=Hf,g.StandardEmbedBlockCommands=dh,g.TEXT_STYLE_BACKGROUND_COLOR_PREFIX=_1,g.TEXT_STYLE_COLOR_PREFIX=O1,g.TableBlock=Cs,g.TableBlockCommandProvider=yu,g.TableShortcuts=ih,g.TextBlock=_i,g.TextBox=Gg,g.TextStyleShortcuts=Xu,g.TocEmbed=m9,g.ZERO_WIDTH_SPACE_CHAR=yi,g.addAttribute=yl,g.addClass=M,g.addCommentToBlock=ah,g.addDays=tC,g.addMonths=X8,g.animateScrollTo=Ei,g.applyPlaceholderToBlock=jc,g.assert=d,g.blockToDoc=nd,g.blockToHtml=F1,g.blockToMarkdown=e2,g.blockToText=Dl,g.blocksToDoc=tv,g.clearAllSelection=Wm,g.clientType=It,g.cloneBlock=Fo,g.cloneChildContainer=K1,g.cloneDoc=J1,g.cloneText=Pg,g.compareElement=Xs,g.comparePosition=v1,g.complexBlockAdjustSelectionPos=ml,g.complexBlockFindNearestChildBlock=ug,g.complexBlockGeFirstSimpleChild=y1,g.complexBlockGetAllChildContainers=Le,g.complexBlockGetBottomChildContainers=dg,g.complexBlockGetLastSimpleChild=wr,g.complexBlockGetSelectedContainers=yr,g.complexBlockGetTopChildContainers=ag,g.containerToDoc=od,g.continuousScroll=Cm,g.convertBlockFrom=hl,g.copyBlockAttributes=d2,g.createBlockAnchor=_o,g.createBlockContentElement=eo,g.createBlockElement=Sm,g.createBlockSimpleDocRange=Tl,g.createBlockSimpleRange=Ot,g.createBoxContentElement=Lm,g.createBoxElement=Tm,g.createBoxOp=Tg,g.createChildContainer=Vm,g.createComplexBlockPosition=bt,g.createComplexDocPos=Ug,g.createComplexDocRange=xb,g.createContainer=jg,g.createContainerElement=u1,g.createDeleteOps=Eg,g.createEditor=Vi,g.createEditorSelectionRange=Ut,g.createElement=b,g.createEmptyContainer=pn,g.createEmptyDoc=oo,g.createEmptyTextBlockData=Il,g.createExpandedRange=Ks,g.createIconButton=hr,g.createImage=jf,g.createInsertOps=kl,g.createInsertionContentElement=Am,g.createInsertionElement=Mm,g.createLocalEditor=NP,g.createOnesEditor=_P,g.createRange=Ff,g.createRichText=Oi,g.createRootContainer=zm,g.createSimpleBlockPosition=$,g.createSimpleDocPos=Vg,g.createTextBlockData=jn,g.createTextButton=Xo,g.createTextOp=_e,g.createTextWithReplaceSoftReturn=L1,g.daysAfter=n1,g.deleteText=R1,g.diffDays=eC,g.disablePageScroll=dm,g.docToHtml=jb,g.docToHtmlFragment=n2,g.docToMarkdown=Fb,g.docToText=o2,g.downloadObjectToFile=Sh,g.downloadSvgToString=k6,g.editLink=vc,g.editorAddComment=i_,g.editorAddTextAttribute=B2,g.editorAutoInsertBlock=u2,g.editorBreakTextBlock=Pi,g.editorClearCompositionText=a2,g.editorClearSelectedContents=Y1,g.editorCopyBlock=cd,g.editorDeleteBlock=G1,g.editorDeleteBlockText=U1,g.editorDeleteBlockWithoutChildren=W1,g.editorDeleteChildContainer=Yb,g.editorDeleteChildContainers=m2,g.editorFocusToBlock=Q1,g.editorFocusToEnd=S2,g.editorGetBlockData=ro,g.editorGetBlockText=ke,g.editorGetBlockTextEx=Ml,g.editorGetBoxData=r2,g.editorHandleKeyboardEvent=e0,g.editorInsertBlock=Dr,g.editorInsertBoxToBlock=l2,g.editorInsertDoc=y2,g.editorInsertDocAt=X1,g.editorInsertText=V1,g.editorInsertTextToBlock=s2,g.editorInsertTextToBlockEx=z1,g.editorMergeTextBlock=g2,g.editorRangeClearColor=I2,g.editorRangeGetColor=td,g.editorRangeSetColor=E2,g.editorRemoveTextAttribute=Jb,g.editorReplaceBlockText=Nl,g.editorReplaceContainer=w2,g.editorRunOnce=xd,g.editorSelectEnd=x2,g.editorSetTextColor=Lr,g.editorShowFindDialog=aO,g.editorUpdateBlockData=Pl,g.editorUpdateCompositionText=c2,g.editorUpdateEmbedData=v2,g.enablePageScroll=um,g.escapeHtmlText=Wf,g.escapeRegExp=i1,g.escapeSpace=N8,g.executeBlockCommand=ng,g.executeEmbedBlockCommand=eg,g.executeRangeCommand=v0,g.fileToDataUrl=nl,g.findAllText=$1,g.findInsertionById=Rm,g.findPrevSimpleBlockBeforeChildContainer=cg,g.findTarget=Bi,g.format=e1,g.formatBytes=vm,g.formatDate=wm,g.fragmentToHtml=hm,g.fromBase64=el,g.fromBase64ToBlob=cm,g.fromBase64ToUint8Array=Z8,g.fromDocRange=no,g.fromNowString=r1,g.genId=N,g.getAllChildBlocks=B1,g.getAllQuickMenuItems=Ku,g.getAllSelectedBlocks=Qe,g.getAttributesAt=Bl,g.getBlockBackground=xm,g.getBlockByIndex=mr,g.getBlockCaretRect=Ge,g.getBlockClass=kt,g.getBlockClassByType=vr,g.getBlockClientRects=Ao,g.getBlockCommandsWithHook=p1,g.getBlockContent=rt,g.getBlockId=G,g.getBlockIndex=K,g.getBlockKind=We,g.getBlockMinWidth=Zm,g.getBlockOptions=uC,g.getBlockPath=Ro,g.getBlockProperties=Km,g.getBlockStyles=aC,g.getBlockTextLength=Z,g.getBlockTools=At,g.getBlockType=it,g.getBoxContent=c1,g.getBoxId=Dm,g.getBoxTypeFromElement=Si,g.getChildBlockCount=Ve,g.getChildBlocks=Rt,g.getChildOffset=Er,g.getColorFromAttributes=P1,g.getComplexBlockClass=ve,g.getContainerBlockPath=Hm,g.getContainerBlocks=Pm,g.getContainerBlocksElement=dl,g.getContainerById=br,g.getContainerId=V,g.getContainerMinWidth=m1,g.getContainerToolsElement=rC,g.getContainerWidth=Qm,g.getDistanceSquare=hn,g.getElementOffset=wi,g.getEmbedType=De,g.getExistsBlockTools=al,g.getExistsContainerById=_m,g.getFileExt=mm,g.getFirstChildBlock=Qt,g.getFirstClientRect=Js,g.getHeadingMenuOptions=Dc,g.getHorizontalPadding=Ua,g.getInsertionContent=a1,g.getLastChildBlock=Gt,g.getLastClientRect=xo,g.getLogger=y,g.getNextBlock=ht,g.getNextValidOffset=Ir,g.getNextVisibleBlock=Cr,g.getOpAt=Lg,g.getOpLength=A1,g.getParentBlock=z,g.getParentBox=l1,g.getParentContainer=H,g.getPrevBlock=gt,g.getPrevValidOffset=Po,g.getPrevVisibleBlock=pr,g.getRangeCommands=C0,g.getRootBlock=ul,g.getScrollContainer=Nn,g.getSpecialBlockCommands=Jm,g.getStandardEmbedBlockProperties=uh,g.getTextBlockChild=gl,g.getTextBlockClass=qm,g.getTextBlockContentChildTextLength=Re,g.getTextBlockContentChildType=hg,g.getTextBlockContentChildren=Hn,g.getTextLength=ce,g.getTextOpLength=I1,g.getTextWidth=rl,g.getToolbar=bc,g.handleBlockElementUpdated=Ym,g.hasAltOnly=z8,g.hasClass=lt,g.hasCtrlOrCmd=rm,g.hasCtrlOrCmdOnly=F8,g.hideBlock=Em,g.htmlToFragment=ol,g.i18n=S,g.injectStyle=Zf,g.insertEmptyBlock=fC,g.insertEmptyEmbedBlock=tg,g.insertText=xr,g.intersectionCommands=iy,g.isBackspace=sm,g.isBlock=gr,g.isBox=s1,g.isCJK=em,g.isChildContainer=qe,g.isChildNode=vt,g.isCollapsedRange=zg,g.isComplexBlockPosition=b1,g.isComplexKindBlock=ct,g.isContainer=fn,g.isControlEvent=Do,g.isDelete=U8,g.isDraggingFiles=sl,g.isEmbedBlock=Te,g.isEmptyContainer=g1,g.isEmptyDoc=xl,g.isEmptyTextBlock=wt,g.isEmptyTextBlockWithoutCompositionText=bs,g.isEnterOnly=im,g.isEscape=Ja,g.isFirefox=Qa,g.isFirstChildBlockInComplexBlock=jC,g.isHighSurrogate=L8,g.isInBlock=d1,g.isInBlockTools=Ti,g.isLetter=tm,g.isLowSurrogate=Va,g.isMatchShortcut=_n,g.isMoveForward=H8,g.isNavigationEvent=$8,g.isNavigationKey=om,g.isNodeRemoved=Vf,g.isNumber=Xf,g.isPrintableKey=Ka,g.isRootBlock=Vo,g.isRootContainer=Ct,g.isSafari=nm,g.isSameDay=o1,g.isShiftEnter=V8,g.isShiftTab=W8,g.isShortcutEvent=j8,g.isSimpleBlock=dC,g.isSimpleBlockPosition=kr,g.isSimplePos=Fg,g.isSimpleRange=Sl,g.isSpace=tl,g.isTab=q8,g.isTextBlockContentBoxChild=Me,g.isTextBlockContentChild=Li,g.isTextBlockContentInsertionChild=$n,g.isTextBlockContentTextChild=Mi,g.isTextKindBlock=j,g.isTextKindBlockType=Di,g.isToday=km,g.isValidOffset=fe,g.isVisibleBlock=cl,g.isYesterday=ym,g.loadJs=Uf,g.loadJsPromise=So,g.lockers=Rn,g.mergeCommands=Cc,g.mergeDocs=jo,g.mergeOps=M1,g.mergeText=kb,g.multiSplitText=gg,g.parseShortcut=lm,g.patchNode=xi,g.pointInRect=To,g.rangeAddAttribute=wl,g.rangeGetTextColor=Ng,g.rangeRemoveAttribute=Sr,g.rangeSetTextColor=Ag,g.rangeTransformText=Mg,g.registerDragDrop=Za,g.removeAttribute=N1,g.removeClass=F,g.removeLastBr=pb,g.removePlaceholderFromBlock=j4,g.removeStyle=Gf,g.replaceAll=nC,g.replaceAllCaseInsensitive=oC,g.replaceAllText=Hg,g.replaceText=El,g.requestDownload=ll,g.scrollable=pm,g.selectFile=fr,g.selectedBlockToDoc=Hl,g.selectionToDoc=jl,g.setAttributes=Wa,g.setClipboardData=il,g.setClipboardDataByEvent=J8,g.setColorToAttributes=Og,g.setDataset=qa,g.setDefaultCursor=Ii,g.setStyles=Ga,g.shortcutToDisplayText=G8,g.showBlock=Im,g.showDocVersions=PP,g.splitText=Ae,g.splitToThree=Kt,g.stringToDataUrl=am,g.stringToObjectUrl=t1,g.subText=pg,g.textNodeOffsetFromPoint=zf,g.toBase64URL=Lo,g.toPlainText=Tt,g.trimChar=Ya,g.unicodeLength=M8,g.unicodeSubstr=R8,g.updateBlockSelection=Gm,g.updateOpAttributes=$g,g.updateTextBlockContent=Mb,g.updateUrl=Xa,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
744
+ </svg>`,{t:ef}=S;class hN{constructor(t){h(this,"goBackButton");h(this,"playButton");h(this,"revertButton");this.options=t;const e=b("button",["dialog-text-button"],null),o=b("span",["dialog-button-icon"],e);o.innerHTML=uN,b("span",["dialog-button-text"],e,ef("version.goBack"));const r=b("button",["dialog-version-button"],null,ef("version.play")),i=b("button",["dialog-version-button"],null,ef("version.revertVersion"));this.goBackButton=e,this.playButton=r,this.revertButton=i,this.bindEvent()}bindEvent(){const{onBack:t,onPlay:e,onRevert:o}=this.options;this.playButton.onclick=e,this.goBackButton.onclick=t,this.revertButton.onclick=o}disabledButton(){}render(t,e=!1){e||t.append(this.goBackButton,this.playButton,this.revertButton)}destroy(){this.playButton.onclick=null,this.goBackButton.onclick=null,this.revertButton.onclick=null}}const he=y("split-text-actions");function Y3(n){return n.length>2?!1:n.length===1?n[0].insert!==void 0:(d(he,n.length===2,`invalid text actions: ${JSON.stringify(n)}`),n[0].retain===void 0?!1:n[1].insert!==void 0)}function Q3(n){return n.length>2?!1:n.length===1?n[0].delete!==void 0:(d(he,n.length===2,`invalid text actions: ${JSON.stringify(n)}`),n[0].retain===void 0?!1:n[1].delete!==void 0)}function K3(n){return n.length>2?!1:n.length===1?n[0].insert===void 0&&n[0].delete===void 0&&n[0].attributes!==void 0:(d(he,n.length===2,`invalid text actions: ${JSON.stringify(n)}`),n[0].retain===void 0?!1:n[1].attributes!==void 0)}function fN(n){const t=[],e=Y.default(n);if(e.length===0)return[];if(e.length===1)return[n];if(e.length===2&&(Q3(n)||Y3(n)||K3(n)))return[n];const o=(i,s)=>i>0?[{retain:i},s]:[s];let r=0;for(;e.length>0;){const i=e[0];if(i.retain!==void 0&&i.attributes===void 0){d(he,i.retain>0,`invalid text op: ${JSON.stringify(i)}`),d(he,e.length>1,`invalid text op: ${JSON.stringify(i)}`);const s=e[1];d(he,s.delete||s.insert!==void 0||s.attributes!==void 0,`invalid next text op: ${JSON.stringify(s)}`),r+=i.retain,t.push(o(r,s)),s.delete!==void 0?r-=s.delete:s.insert!==void 0?r+=s.insert.length:(d(he,s.attributes!==void 0,`invalid next text op: ${JSON.stringify(s)}`),d(he,s.retain!==void 0,`invalid next text op: ${JSON.stringify(s)}`),r+=s.retain),e.splice(0,2)}else d(he,i.delete||i.insert!==void 0||i.attributes!==void 0,`invalid next text op: ${JSON.stringify(i)}`),t.push(o(r,i)),e.shift(),i.retain!==void 0&&(d(he,i.attributes!==void 0,`invalid next text op: ${JSON.stringify(i)}`),r+=i.retain),i.insert&&(r+=i.insert.length)}return t}function J3(n){if(d(he,n.length===1||n.length===2,`not a single action op: ${JSON.stringify(n)}`),n.length===1)return 0;const t=n[0].retain;return d(he,typeof t=="number"&&t>0,`invalid retain: ${JSON.stringify(n)}`),t}let X3=0;function mN(n,t,e){const o=X3;X3+=1;const r=Tt(n);return{insert:" ",attributes:{box:!0,id:N(),type:"history-deleted-box",user:e,created:Date.now(),text:r,deletedOffset:t,deletedOrder:o}}}function gN(n,t,e){const o=J3(t),r=t.length===1?t[0].delete:t[1].delete;d(he,typeof r=="number",`not a delete op: ${JSON.stringify(t)}`);const{left:i,middle:s,right:l}=Kt(n,o,r),c=mN(s,o,e);return[...i,c,...l]}function pN(n,t,e){const o=J3(t),r=t.length===1?t[0].insert:t[1].insert;d(he,typeof r=="string",`invalid insert op: ${JSON.stringify(t)}`);const i=t.length===1?t[0].attributes:t[1].attributes,l=yl([{insert:r,attributes:i}],"insertedBy",e);return xr(n,o,l,null)}function CN(n,t,e){const o=fN(t).reverse();let r=n;for(const i of o)Q3(i)?r=gN(r,i,e):Y3(i)?r=pN(r,i,e):(d(he,K3(i),`unknown op: ${JSON.stringify(i)}`),r=ne.apply(r,i));return r}const bN=y("history-update-block-text");function t9(n){const t=[],e=[];let o=0;return n.forEach(r=>{var i;if((i=r.attributes)!=null&&i.box){const s=r.attributes;if(s.type==="history-deleted-box"){t.push({boxData:s,offset:o});return}}e.push(r),o+=A1(r)}),t.sort((r,i)=>i.offset-r.offset),{deletedBoxes:t,newText:e}}function vN(n,t,e){let o=n;return t.forEach(r=>{const i=ne.transformCursor(r.offset,e,!1);o=xr(o,i,[{insert:" ",attributes:r.boxData}],null)}),o}function kN(n){n.sort((t,e)=>t.boxData.deletedOffset!==e.boxData.deletedOffset?t.boxData.deletedOffset-e.boxData.deletedOffset:t.boxData.deletedOrder-e.boxData.deletedOrder)}function yN(n){if(n.length<=1)return n;const t=n[0].offset;n.forEach(e=>{d(bN,e.offset===t,`invalid boxes group, ${JSON.stringify(n)}`)}),kN(n);for(let e=n.length-1;e>=1;e--){const o=n[e],r=n[e-1];o.boxData.user.userId===r.boxData.user.userId&&(r.boxData.text+=o.boxData.text,n.splice(e,1))}return n}function wN(n){let{newText:t,deletedBoxes:e}=t9(n);const o=new Map;return e.forEach(i=>{let s=o.get(i.offset);s||(s=[],o.set(i.offset,s)),s.push(i),s.sort((l,c)=>l.boxData.deletedOffset-c.boxData.deletedOffset)}),Array.from(o.values()).sort((i,s)=>s[0].offset-i[0].offset).forEach(i=>{const s=i[0].offset;yN(i).reverse().forEach(l=>{t=xr(t,s,[{insert:" ",attributes:l.boxData}],null)})}),t}function BN(n,t,e){let{newText:o,deletedBoxes:r}=t9(n);return o=CN(o,t,e),o=vN(o,r,t),o=wN(o),o}const Sn=y("history-doc");function Tn(n){d(Sn,!1,"no local actions for history doc")}class EN extends ki{constructor(e,o){super();h(this,"doc");h(this,"editor");this.doc=Y.default(e),this.editor=o}beginBatchUpdate(){return 0}endBatchUpdate(){return 0}toJSON(){return Y.default(this.doc)}getContainerBlocks(e){return this.doc.blocks[e]}getBlockData(e,o){const r=this.getContainerBlocks(e);d(Sn,r,`no container data: ${e}`);const i=r[o];return d(Sn,i,`no block data: ${o}`),i}localUpdateBlockText(){Tn()}localUpdateBlockData(){Tn()}localInsertBlock(){Tn()}localDeleteBlock(){Tn()}localInsertChildContainer(){Tn()}localDeleteChildContainers(){Tn()}uploadResource(){Tn()}async addResources(e){Tn()}getServerMeta(){var e,o,r;return(r=(o=(e=this.editor.doc.externalDoc).getServerMeta)==null?void 0:o.call(e))!=null?r:{}}buildResourceUrl(e){return this.editor.doc.externalDoc.buildResourceUrl(e)}request(){Tn()}broadcastMessage(){Tn()}getUser(){return{permission:"w",userId:"-",displayName:"-",avatarUrl:"-",rainbowIndex:0}}getRemoteUsers(){return new ql}destroy(){this.clearCallbacks()}transformBlockIndex(e,o,r){const i=this.doc.blocks[e];d(Sn,i,`no container blocks: ${e}`);let s=0;for(let l=0;l<i.length;l++)if(!i[l].deletedBy){if(s===o)return l;s++}return r&&d(Sn,!1,`invalid block index: ${o}, blocks: ${JSON.stringify(i)}`),d(Sn,s===o,`invalid block index: ${o}, blocks: ${JSON.stringify(i)}`),i.length}onDeleteBlock(e,o,r){const i=this.transformBlockIndex(e,o,!0),l=this.doc.blocks[e][i];d(Sn,!l.deleted,`block has already deleted: ${e}/${o}`),l.deletedBy=r,this.callbacks.forEach(c=>{var a;return(a=c.onUpdateBlockData)==null?void 0:a.call(c,e,i,{insert:{},delete:[]},!0)})}onInsertBlock(e,o,r,i){const s=this.transformBlockIndex(e,o,!1),l=this.doc.blocks[e],c=Y.default(r);c.insertedBy=i,l.splice(s,0,c),this.callbacks.forEach(a=>{var u;return(u=a.onInsertBlock)==null?void 0:u.call(a,e,s,c,!0)})}onUpdateBlockText(e,o,r,i){const s=this.transformBlockIndex(e,o,!0),c=this.doc.blocks[e][s];d(Sn,!c.deleted,`block has already deleted: ${e}/${o}`);const a=c.text;d(Sn,a,`no text for block: ${JSON.stringify(c)}`);const u=BN(a,r,i);c.text=u,this.callbacks.forEach(f=>{var m;return(m=f.onUpdateBlockText)==null?void 0:m.call(f,e,o,r,!0)})}onUpdateBlockData(e,o,r,i){const s=this.transformBlockIndex(e,o,!0),l=this.doc.blocks[e],c=l[s];d(Sn,!c.deleted,`block has already deleted: ${e}/${o}`);const a=Y.default(c);a.updatedBy=i,r.delete.forEach(u=>delete a[u]),Object.entries(r.insert).forEach(([u,f])=>{a[u]=f}),l[s]=a,this.callbacks.forEach(u=>{var f;return(f=u.onUpdateBlockData)==null?void 0:f.call(u,e,s,r,!0)})}onCreateContainer(e,o,r){this.doc.blocks[e]=Y.default(o),this.callbacks.forEach(i=>{var s;return(s=i.onInsertChildContainer)==null?void 0:s.call(i,e,o,!0)})}}const{t:e9}=S;function li(n,t){return t==="insert"?e9("version.insert",{name:n.displayName}):e9("version.delete",{name:n.displayName})}function sr(n,t){const{userId:e}=t;return["flag","selection"].reduce((r,i)=>{const s=n.doc.getRemoteUsers().getFixedUserColor(e,i);return r[i]=s,r},{})}class IN{renderText(t,e,o){if(!o.box&&o.insertedBy){const r=o.insertedBy,{flag:i,selection:s}=sr(t,o.insertedBy);return{classes:["history-inserted-text"],attributes:{"history-inserted-by":r.displayName,"data-op-description":li(r,"insert")},styles:{[ri]:i,[ii]:s}}}return{}}renderBlock(t,e,o){if(o.deletedBy){const r=o.deletedBy,{flag:i,selection:s}=sr(t,r);return{classes:["history-deleted-block"],attributes:{"history-deleted-by":r.displayName,"data-op-description":li(r,"delete")},styles:{[ri]:i,[ii]:s}}}if(o.insertedBy){const r=o.insertedBy,{flag:i,selection:s}=sr(t,r);return{classes:["history-inserted-block"],attributes:{"history-inserted-by":r.displayName,"data-op-description":li(r,"insert")},styles:{[ri]:i,[ii]:s}}}return{}}updateBlock(t,e,o,r){if(r.deletedBy){const i=r.deletedBy,{flag:s,selection:l}=sr(t,i);M(o,"history-deleted-block"),Wa(o,{"history-inserted-by":i.displayName,"data-op-description":li(i,"delete")}),Ga(o,{[ri]:s,[ii]:l});return}if(r.insertedBy){const i=r.insertedBy,{flag:s,selection:l}=sr(t,i);M(o,"history-inserted-block"),Wa(o,{"history-inserted-by":i.displayName,"data-op-description":li(i,"insert")}),Ga(o,{[ri]:s,[ii]:l})}}}const n9=y("history-deleted-box");function xN(n,t,e,o){const r=o;d(n9,r.text,`no text for text box data: ${JSON.stringify(o)}`),d(n9,typeof r.text=="string",`invalid text type for text box data: ${JSON.stringify(o)}`);const i=b("span",["history-deleted-box"],e,r.text),s=r.user,{flag:l,selection:c}=sr(n,s);i.setAttribute("history-deleted-by",s.displayName),i.setAttribute("data-op-description",li(s,"delete")),i.style.setProperty(ri,l),i.style.setProperty(ii,c)}const SN={boxType:"history-deleted-box",updateBoxContent:xN},Se=y("version-dialog");class TN{constructor(t,e){h(this,"editor");h(this,"dialog",null);h(this,"oldViewer",null);h(this,"versionOptions",{});h(this,"versionList",null);h(this,"actionButtons",null);h(this,"provider");h(this,"components");h(this,"handleClose",()=>{var t;(t=this.dialog)==null||t.hide()});h(this,"handlePlay",()=>{var e;d(Se,this.versionList,"The versionList did not render");const t=(e=this.versionList)==null?void 0:e.activeVersion;d(Se,t,`The version: ${t} is invalid`),this.viewVersion(t,{play:!0,speed:150})});h(this,"handleRevert",async()=>{var e,o;d(Se,this.versionList,"The versionList did not render");const t=(e=this.versionList)==null?void 0:e.activeVersion;d(Se,t,`The version: ${t} is invalid`),await this.versionHelper.revertVersion(t.version),(o=this.dialog)==null||o.hide()});h(this,"handleSelectVersion",t=>{d(Se,t,`The version: ${t} is invalid`),this.viewVersion(t)});h(this,"viewVersion",async(t,e={play:!1,speed:1e3})=>{this.oldViewer&&(this.oldViewer.destroy(),this.oldViewer=null),d(Se,this.versionList,"The versionList did not render"),d(Se,this.actionButtons,"The actionButtons did not render");const o=t.type==="minor"?this.versionList.beforeVersion:this.versionList.beforeMajorVersion,r=o?o.version:0,i=this.versionList.isSelectedFirstVersion,s=this.versionList.isSelectedLastVersion;this.actionButtons.revertButton.disabled=i,this.actionButtons.playButton.disabled=i;let l=this.versionOptions.hideOps;if(this.versionOptions.onWillChangeVersion){const C=this.versionOptions.onWillChangeVersion(this.editor,t,i,s);C!=null&&C.hideOps&&(l=!0)}let c,a;if(l)c=await this.versionHelper.getVersion(t.version),a=[];else{const C=await this.versionHelper.getHistoryData(t.version,r);c=C.doc,a=C.historyData}const{editorElement:u}=this.components;u.innerHTML="";const f=new EN(c,this.editor),m=this.provider.createHistoryEditor(u,f);m.editorBlockRenders.registerRender(new IN),m.editorBoxes.registerBoxClass(SN),M(m.rootElement,G3.HISTORY);try{await dN(f,this.versionHelper,a,e)}finally{this.oldViewer=m}this.versionOptions.onVersionChanged&&this.versionOptions.onVersionChanged(this.editor,m,t,i,s)});this.editor=t,this.provider=e;const o=b("div",["version-dialog"],null),r=b("div",["version-dialog-note-viewer"],o),i=b("div",["version-dialog-action-container"],r),s=b("div",["version-dialog-editor"],r),l=b("div",["version-dialog-versions-list"],o);this.components={root:o,editorElement:s,actionContainer:i,versionsListContainer:l}}get versionHelper(){d(Se,this.editor.doc.getVersionHelper,"Can not get getVersionHelper from doc");const t=this.editor.doc.getVersionHelper();return d(Se,t,"current doc does not support version"),t}renderContent(t){const{actionContainer:e,versionsListContainer:o}=this.components;e.innerHTML="";const{hideActions:r}=this.versionOptions,i=new hN({onBack:this.handleClose,onPlay:this.handlePlay,onRevert:this.handleRevert});i.render(e,r),this.actionButtons=i,o.innerHTML="";const s=new lN({versions:t,useCreatedBy:this.versionOptions.useCreatedBy,onSelectVersion:this.handleSelectVersion,getMarkColor:l=>{const{flag:c}=sr(this.editor,l);return c}});s.render(o),this.versionList=s}initViewVersion(){if(this.versionOptions.initSelectedVersion){d(Se,this.versionList,"The versionList did not render");const{initSelectedVersion:t}=this.versionOptions,e=this.versionList.selectVersionByVersionNum(t);d(Se,e,`The version: ${e} is invalid`),this.viewVersion(e)}else{d(Se,this.versionList,"The versionList did not render");const t=this.versionList.activeVersion;d(Se,t,`The version: ${t} is invalid`),this.viewVersion(t)}}async show(t={}){this.versionOptions={...this.versionOptions,...t};const e=await this.versionHelper.getVersions();if(this.versionOptions.hideNonVersionedOps&&e.length&&e[0].version===-1&&e.shift(),this.versionOptions.onVersionsLoaded&&this.versionOptions.onVersionsLoaded(this.editor,e),this.renderContent(e),this.initViewVersion(),!this.dialog){const{root:o}=this.components;this.dialog=new sN(o)}this.dialog.show()}destroy(){var t,e,o;(t=this.dialog)==null||t.destroy(),(e=this.versionList)==null||e.destroy(),(o=this.actionButtons)==null||o.destroy()}}function DN(n,t,e){n.addCustom("version-dialog",()=>new TN(n,t)).show(e)}const iz="",LN=y("heading-collapse");function nf(n){var e;const t=Number.parseInt((e=n.getAttribute("data-style-heading"))!=null?e:"",10);return d(LN,t,"not a heading block"),t}function je(n){return!!n.getAttribute("data-style-heading")}function MN(n){return!lt(n,"heading-collapsed")}function lr(n){return lt(n,"heading-collapsed")}function o9(n){if(gt(n))return!1;const e=H(n);return Ct(e)}const RN=y("heading-collapse");function of(n){d(RN,je(n),"not a heading block");const t=[],e=nf(n);let o=ht(n);for(;o&&!(je(o)&&nf(o)<=e);)t.push(o),o=ht(o);return t}function r9(n,t){if(!Uo(t))return;n.selection.selectBlock(t,0),of(t).forEach(o=>{Em(o)}),M(t,"heading-collapsed")}function ci(n,t){of(t).forEach(o=>{Im(o)}),F(t,"heading-collapsed")}function AN(n,t){MN(t)?r9(n,t):ci(n,t)}const ON=[Qd,Kd,Jd,Xd,tu,eu,nu,ou];function _N(n){const t=b("button",["heading-collapse-button"],null);return t.setAttribute(`data-editor-tooltip-${n.clientId}`,"Collapse / Expand"),t.innerHTML=oc,t}function i9(n){return Gc(n).querySelector("button.heading-collapse-button")}function s9(n,t){i9(t)||o9(t)||!Uo(t)||yh(t,_N(n),-1)}function NN(n){var t;(t=i9(n))==null||t.remove()}function l9(n,t){Gc(t).querySelector("button.heading-collapse-button")||s9(n,t)}function PN(n){const t=nf(n),e=b("button",["heading-marker"],null);return e.innerHTML=ON[t-1],e}function c9(n){return Gc(n).querySelector("button.heading-marker")}function rf(n){c9(n)||o9(n)||!Uo(n)||yh(n,PN(n),1)}function a9(n){const t=c9(n);t==null||t.remove()}function d9(n){a9(n),je(n)&&rf(n)}class $N{handleDrop(t,e,o,r){if(sl(e)||!je(e)||!lr(e))return;const i=of(e);i.unshift(e);const s=i.reverse();let l=null;return t.doc.beginBatchUpdate(),s.forEach((c,a,u)=>{const f=t.getBlockData(c),m=Fo(t.editorBlocks,t.doc.toJSON(),f),C=t.insertDocAt(o,r,m)[0];a===u.length-1&&(l=C)}),t.doc.endBatchUpdate(),t.doc.beginBatchUpdate(),s.forEach(c=>{t.deleteBlock(c)}),t.doc.endBatchUpdate(),l&&r9(t,l),!0}}const HN=y("heading-collapse");class jN{constructor(t){h(this,"handleLoad",()=>{this.showCollapseButtons()});h(this,"handleHoverBlock",(t,e)=>{e&&(F(e,"hovering-heading"),je(e)&&Ct(H(e))&&(rf(e),lr(e)||NN(e))),t&&je(t)&&Ct(H(t))&&(M(t,"hovering-heading"),a9(t),s9(this.editor,t))});h(this,"handleClick",(t,e)=>{const o=Bi(e,"button.heading-collapse-button");if(!o)return;const r=z(o);!r||(d(HN,je(r),"not a heading block"),AN(this.editor,r),l9(this.editor,r))});this.editor=t,t.addListener("load",this.handleLoad),t.addListener("click",this.handleClick),_t.get(t).addListener("change",this.handleHoverBlock),this.showCollapseButtons(),setTimeout(()=>{Ts.get(t).addHandler(new $N)})}showCollapseButtons(){const t=Rt(this.editor.rootContainer).filter(je);t.length!==0&&(t[0]===Qt(this.editor.rootContainer)&&t.splice(0,1),t.forEach(rf))}destroy(){this.editor.removeListener("load",this.handleLoad),this.editor.removeListener("click",this.handleClick)}}function ua(n){const t=n.selection.range;if(t.isCollapsed()||t.start.blockId===t.end.blockId)return;const e=n.getBlockById(t.start.blockId),o=n.getBlockById(t.end.blockId);lr(e)&&ci(n,e),lr(o)&&ci(n,o)}function FN(n){ua(n);const t=n.getFocusedBlock();!je(t)||lr(t)&&ci(n,t)}function zN(n){ua(n);const t=n.getFocusedBlock();if(!je(t))return;const e=n.selection.range.focus;!e.isSimple()||e.offset===Z(n,t)&&lr(t)&&ci(n,t)}function UN(n){ua(n);const t=n.getFocusedBlock();if(!je(t))return;const e=n.selection.range.focus;!e.isSimple()||e.offset===0&&lr(t)&&ci(n,t)}class VN{handleBeforeKeyDown(t,e){return Ka(e.key)&&ua(t),e.key==="Enter"?(FN(t),!1):e.key==="Delete"?(zN(t),!1):(e.key==="Backspace"&&UN(t),!1)}}class qN{constructor(t){this.editor=t}onInsertBlock(t,e,o,r){this.updateBlockIfNeeded(o.id)}onUpdateBlockData(t,e,o,r){const i=this.editor.doc.getBlockData(t,e);this.updateBlockIfNeeded(i.id,o)}updateBlockIfNeeded(t,e){setTimeout(()=>{const o=this.editor.findBlockById(t);if(!!o){if(!je(o)){e&&e.delete.includes("heading")&&d9(o);return}lt(o,"hovering-heading")&&l9(this.editor,o),d9(o)}},100)}}function WN(n){return!!n.heading}function u9(n){var e;const t=n.heading;return(e=Number.parseInt(`${t}`,10))!=null?e:1}function h9(n,t){var e;return{parentNode:t,children:[],text:Tt((e=n.text)!=null?e:[]),level:u9(n),block:n}}class Ns{constructor(){h(this,"nodes",[])}appendBlock(t){const e=this.findParent(u9(t),this.nodes);e?e.children.push(h9(t,e)):this.nodes.push(h9(t,null))}findParent(t,e){const o=e[e.length-1];if(!o||t<=1)return null;if(o.level===t-1)return o;const r=this.findParent(t,o.children);return r||(o.level<t?o:null)}static buildToc(t){const e=new Ns,o=t.blocks.root;for(let r=0;r<o.length;r++){const i=o[r];WN(i)&&e.appendBlock(i)}return e}}class cr extends Wt.TypedEmitter{constructor(e){super();h(this,"toc",new Ns);h(this,"updateToc",ie.default(()=>{this.updateTocNow()},500));this.editor=e,e.doc.registerCallback(this),this.updateToc()}destroy(){this.editor.doc.unregisterCallback(this)}isHeadingBlock(e){return!!e.heading}onInsertBlock(e,o,r,i){e==="root"&&this.isHeadingBlock(r)&&this.updateToc()}onDeleteBlock(e,o,r){e==="root"&&this.updateToc()}onUpdateBlockText(e,o,r,i){if(e!=="root")return;const s=this.editor.doc.getBlockData(e,o);this.isHeadingBlock(s)&&this.updateToc()}onUpdateBlockData(e,o,r,i){if(e!=="root")return;const s=this.editor.doc.getBlockData(e,o);this.isHeadingBlock(s)&&this.updateToc()}static register(e){return e.addCustom("editor-toc",()=>new cr(e))}static get(e){return e.getCustom("editor-toc")}updateTocNow(){this.toc=Ns.buildToc(this.editor.doc.toJSON()),this.emit("change",this.editor,this.toc)}}const sz="";function GN(n){return n.nodes.length===0?!0:n.nodes.length>1?!1:n.nodes[0].children.length===0}function sf(n,t){t.forEach(e=>{const o=b("div",["toc-node"],n),r=b("div",["toc-title"],o);if(b("span",["toc-text"],r,e.text).setAttribute("data-block-id",e.block.id),e.children.length>0){const s=b("div",["toc-children"],o);sf(s,e.children)}})}function ZN(n,t){const e=Bi(t,".toc-text");if(!e)return;const o=e.getAttribute("data-block-id");if(!o)return;const r=n.findBlockById(o);!r||(t.preventDefault(),t.stopPropagation(),n.selection.selectBlock(r,0))}function f9(n,t,e){if(F(t,"loading"),t.innerHTML="",GN(e)){b("div",["toc-empty-message"],t,"No toc");return}e.nodes.length===1?sf(t,e.nodes[0].children):sf(t,e.nodes),xd(n,"toc-click-handler",()=>{n.addListener("click",ZN)})}class YN{constructor(t){h(this,"handleUpdateToc",(t,e)=>{Array.from(t.rootContainer.querySelectorAll('.embed-block[data-type="editor-block"][data-embed-type="toc"]')).forEach(r=>{const i=r.querySelector(".editor-toc-container");i&&f9(t,i,e)})});this.editor=t,cr.register(t).addListener("change",this.handleUpdateToc)}destroy(){cr.register(this.editor).removeListener("change",this.handleUpdateToc)}get toc(){return cr.register(this.editor).toc}}function QN(n,t){const e=b("div",["editor-toc-container"],t),r=n.addCustom("init-editor-toc",()=>new YN(n)).toc;r.nodes.length===0?M(e,"loading"):f9(n,e,r)}function KN(n,t,e,o){return o==="markdown"?"[toc]":""}function JN(n,t,e){const{data:o}=e;if(!o||o.embedType!=="toc"||!j(n,t))return null;const r={};return{blockData:{id:N(),type:"embed",embedType:"toc",embedData:r}}}const m9={embedType:"toc",createEmbedContent:QN,convertTo:KN,convertFrom:JN};function XN(n){return!!n.getAttribute("data-style-heading")}function lf(n,t){return XN(t)&&Z(n,t)>0}function tP(n){const t=Nn(n.rootElement);let e=0,o=0,r=0;if(t===document.documentElement){const i=n.rootContainer.getBoundingClientRect();e=i.left+i.width/2,o=10,r=t.offsetHeight}else{const i=t.getBoundingClientRect();e=i.left+i.width/2,o=i.top+10,r=i.bottom}for(;o<r;){const i=document.elementsFromPoint(e,o);for(let s=0;s<i.length;s++){const l=z(i[s]);if(l&&n.rootContainer.contains(l))return l}o+=10}return null}function cf(n,t){let e=t;for(;e&&!lf(n,e);)e=ht(e);return e}function g9(n){if(gt(n))return!1;const e=H(n);return Ct(e)}function ha(n,t){let e=t;for(;e&&!lf(n,e);)e=gt(e),e&&g9(e)&&(e=null);return e}const eP=.3;class nP extends Wt.TypedEmitter{constructor(e){super();h(this,"scrollContainer");h(this,"scrollEventTarget");h(this,"scrollStatus",{curHeadingBlock:null,previousHeadingBlock:null,nextHeadingBlock:null});h(this,"handleScroll",ie.default(()=>{const e={curHeadingBlock:null,previousHeadingBlock:null,nextHeadingBlock:null};let o=tP(this.editor);if(o&&(o=ul(o)),!o||!this.scrollContainer){this.setStatus(e);return}if(g9(o)&&(o=ht(o)),!o){this.setStatus(e);return}if(lf(this.editor,o)){e.curHeadingBlock=o,e.previousHeadingBlock=ha(this.editor,o),e.nextHeadingBlock=cf(this.editor,o),this.setStatus(e);return}const r=this.scrollContainer.getBoundingClientRect(),i=cf(this.editor,o);if(i){const l=i.getBoundingClientRect();if(l.top>r.top&&l.top<r.top+r.height*eP){e.curHeadingBlock=i,e.previousHeadingBlock=ha(this.editor,i),e.nextHeadingBlock=cf(this.editor,i),this.setStatus(e);return}e.nextHeadingBlock=i}const s=ha(this.editor,o);s&&(e.curHeadingBlock=s,e.previousHeadingBlock=ha(this.editor,s)),this.setStatus(e)},200));this.editor=e,setTimeout(()=>{this.start()},50)}setStatus(e){this.scrollStatus.previousHeadingBlock===e.previousHeadingBlock&&this.scrollStatus.nextHeadingBlock===e.nextHeadingBlock&&this.scrollStatus.previousHeadingBlock===e.previousHeadingBlock||(this.scrollStatus=e,this.emit("change",this.editor,e))}start(){this.stop(),this.scrollContainer=Nn(this.editor.rootElement),this.scrollEventTarget=this.scrollContainer===document.documentElement?document:this.scrollContainer,this.scrollEventTarget.addEventListener("scroll",this.handleScroll),this.handleScroll()}stop(){this.scrollEventTarget&&this.scrollEventTarget.removeEventListener("scroll",this.handleScroll)}destroy(){this.stop(),this.scrollEventTarget=void 0}}class oP{constructor(t,e){h(this,"suggest");h(this,"onShow",(t,e,o,r)=>{const i=this.editor.getBlockByIndex(e,o);if(!Uo(i)){const s=z(H(i));if(s&&it(s)==="code")return!1}return!0});h(this,"onClickItem",(t,e,o)=>{const r=e.data,i={id:N(),type:"mention",box:!0,created:Date.now(),iconUrl:r.avatarUrl,text:r.displayName,mentionId:r.userId},s=this.editor.selection.range;if(!s.isCollapsed()||!s.isSimple())return;const l=s.focus,c=this.editor.getBlockById(l.blockId);this.editor.insertBoxToBlock(c,l.offset,i)});h(this,"queryItems",async(t,e)=>(await this.options.queryUsers(this.editor,e)).map(i=>({id:i.userId,name:i.displayName,icon:`<img src="${i.avatarUrl}" class="mention-user-avatar">`,element:i.element,data:i})));this.editor=t,this.options=e,this.suggest=new uu(t,{id:"editor-mention",trigger:["@"],autoDeleteTrigger:!0,showLoading:!0,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems})}destroy(){}}y("mathjax-box");function rP(n,t,e,o){const r=o,i=b("a",["mention-container"],e);b("span",["mention-name"],i,`@${r.text}`),i.setAttribute("data-mention-id",r.mentionId)}function iP(n,t,e){}const p9={boxType:"mention",updateBoxContent:rP,handleClickBox:iP};function sP(n){return kn("list-block-mention",S.t("list.mention.tooltip"),op,[],n.clientId)}class lP{constructor(t){h(this,"mentionButton");h(this,"handleHoveringBlock",t=>{var e;!this.editor.isWritable()||(t&&this.shouldBlockShowMention(t)?At(t).appendChild(this.mentionButton):(e=this.mentionButton)==null||e.remove())});h(this,"handleMouseDown",(t,e)=>{e.preventDefault(),e.stopPropagation();const o=z(this.mentionButton);if(!o||!j(t,o))return;const r=t.selection.range.focus;if(!r.isSimple())return;let i;t.selection.focusedBlock!==o?i=Z(t,o):i=r.offset,setTimeout(()=>{const s=t.insertTextToBlock(o,i,"@");i+=1;const l=Tt(Ae(s,i).left);this.editor.selection.selectBlock(o,i),this.editor.focus(),t.getCustom("mention").suggest.popup(o,i,l,"@")})});h(this,"destroy",()=>{_t.get(this.editor).removeListener("change",this.handleHoveringBlock)});this.editor=t,this.mentionButton=sP(t),_t.get(this.editor).addListener("change",this.handleHoveringBlock),t.domEvents.addEventListener(this.mentionButton,"mousedown",this.handleMouseDown)}shouldBlockShowMention(t){if(!j(this.editor,t)||!at(t))return!1;const e=He(t);return!(e==="ordered"||e==="unordered")}}const lz="",cP={templates:{title:"\u9009\u62E9\u6A21\u677F\uFF0C\u5FEB\u901F\u521B\u5EFA",create:"\u65B0\u5EFA\u6A21\u677F",choose:"\u5168\u90E8\u6A21\u677F",customizedMark:"\u81EA\u5B9A\u4E49"}},aP={templates:{title:"Choose a template",create:"New template",choose:"All templates",customizedMark:"Custom"}};S.mergeLang({"zh-CN":cP,"en-US":aP});const cz="",az="",dP="data:image/svg+xml;base64,Cjxzdmcgd2lkdGg9IjEyMCIgaGVpZ2h0PSIxMjAiIHZpZXdCb3g9IjAgMCAxMjAgMTIwIiBmaWxsPSJub25lIiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cmVjdCB3aWR0aD0iMTIwIiBoZWlnaHQ9IjEyMCIgZmlsbD0id2hpdGUiLz4KPHBhdGggZD0iTTQ4IDU5QzQ4IDU0LjU4MTcgNTEuNTgxNyA1MSA1NiA1MUg5M0M5OC41MjI4IDUxIDEwMyA1NS40NzcyIDEwMyA2MVY4OEMxMDMgOTEuODY2IDk5Ljg2NiA5NSA5NiA5NUg1NkM1MS41ODE3IDk1IDQ4IDkxLjQxODMgNDggODdWNTlaIiBmaWxsPSIjRDZFOUZBIi8+CjxwYXRoIGQ9Ik0xOCA2NEMxOCA2Mi4zNDMxIDE5LjM0MzEgNjEgMjEgNjFINTZDNjAuNDE4MyA2MSA2NCA2NC41ODE3IDY0IDY5VjgzQzY0IDg1LjIwOTEgNjIuMjA5MSA4NyA2MCA4N0gyNkMyMS41ODE3IDg3IDE4IDgzLjQxODMgMTggNzlWNjRaIiBmaWxsPSIjRUFFNEY2Ii8+CjxyZWN0IHg9IjI0IiB5PSIzMSIgd2lkdGg9IjY1IiBoZWlnaHQ9IjUwIiByeD0iNSIgZmlsbD0iIzk5QzdGMiIvPgo8cmVjdCB4PSIzMy41IiB5PSI0MyIgd2lkdGg9IjQ2IiBoZWlnaHQ9IjUiIHJ4PSIyLjUiIGZpbGw9IndoaXRlIi8+CjxyZWN0IHg9IjMzLjUiIHk9IjU0IiB3aWR0aD0iNDYiIGhlaWdodD0iNSIgcng9IjIuNSIgZmlsbD0id2hpdGUiLz4KPHJlY3QgeD0iMjQiIHk9IjMxIiB3aWR0aD0iNjUiIGhlaWdodD0iNTAiIHJ4PSI1IiBzdHJva2U9IiNGOEY4RjgiLz4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik01MCA4NS4yNjhDNTMuODI2MyA4My4wNTg5IDU1LjEzNzMgNzguMTY2MiA1Mi45MjgyIDc0LjMzOThMNjMuMzIwNSA2OC4zMzk4QzY4Ljg0MzMgNzcuOTA1NyA2NS41NjU4IDkwLjEzNzUgNTYgOTUuNjYwNEM0Ni40MzQxIDEwMS4xODMgMzQuMjAyMyA5Ny45MDU3IDI4LjY3OTQgODguMzM5OEwzOS4wNzE3IDgyLjMzOThDNDEuMjgwOSA4Ni4xNjYyIDQ2LjE3MzYgODcuNDc3MiA1MCA4NS4yNjhaIiBmaWxsPSIjQUI5M0RDIi8+CjxyZWN0IHg9IjU5IiB5PSI2NSIgd2lkdGg9IjQyIiBoZWlnaHQ9IjI4IiByeD0iNSIgZmlsbD0id2hpdGUiLz4KPHBhdGggZD0iTTYzIDg4VjczLjA4MDhDNjMgNzEuNzA5NiA2My4zNjE0IDcwLjY4NjcgNjQuMDg0MSA3MC4wMTJDNjQuODI4NyA2OS4zMzczIDY1Ljg1OCA2OSA2Ny4xNzIgNjlIOTIuODYwOUM5NS42MjAzIDY5IDk3IDcwLjM2MDMgOTcgNzMuMDgwOFY4OEg5My41MTc5TDg3LjM3NDkgODAuNjIyQzg3LjA5MDIgODAuMzE3MyA4Ni43NjE3IDgwLjA4ODggODYuMzg5NCA3OS45MzY0Qzg2LjAxNzEgNzkuNzg0MSA4NS42NDQ4IDc5LjcwNzkgODUuMjcyNSA3OS43MDc5Qzg0LjkwMDIgNzkuNzA3OSA4NC41Mjc5IDc5Ljc4NDEgODQuMTU1NiA3OS45MzY0QzgzLjgwNTIgODAuMDg4OCA4My40NTQ4IDgwLjMxNzMgODMuMTA0MyA4MC42MjJMNzYuNzMxNCA4Ni4yMzcxTDc0LjIwMTkgODMuOTUxOUM3My42MzI1IDgzLjQyOTYgNzMuMDA4NCA4My4xNjg0IDcyLjMyOTUgODMuMTY4NEM3MS42NTA2IDgzLjE2ODQgNzEuMDM3NCA4My40Mjk2IDcwLjQ4OTkgODMuOTUxOUw2Ni40NDkzIDg4SDYzWk03NC40NjQ3IDgwLjYyMkM3NS4zNjI2IDgwLjYyMiA3Ni4xNDAxIDgwLjI5NTUgNzYuNzk3MSA3OS42NDI2Qzc3LjQ3NiA3OC45ODk3IDc3LjgxNTUgNzguMjE3MSA3Ny44MTU1IDc3LjMyNDdDNzcuODE1NSA3Ni40MTA3IDc3LjQ3NiA3NS42MzggNzYuNzk3MSA3NS4wMDY5Qzc2LjE0MDEgNzQuMzU0IDc1LjM2MjYgNzQuMDE2NiA3NC40NjQ3IDczLjk5NDhDNzMuNTQ0OSA3My45NTEzIDcyLjc1NjUgNzQuMjY2OSA3Mi4wOTk1IDc0Ljk0MTZDNzEuNDQyNSA3NS42MTYzIDcxLjExNCA3Ni40MTA3IDcxLjExNCA3Ny4zMjQ3QzcxLjExNCA3OC4yMTcxIDcxLjQ0MjUgNzguOTg5NyA3Mi4wOTk1IDc5LjY0MjZDNzIuNzU2NSA4MC4yOTU1IDczLjU0NDkgODAuNjIyIDc0LjQ2NDcgODAuNjIyWiIgZmlsbD0iI0Y3RDA3RiIvPgo8Y2lyY2xlIGN4PSI5NSIgY3k9IjQyIiByPSIyIiBzdHJva2U9IiM1MEMzOTgiIHN0cm9rZS13aWR0aD0iMiIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTk0Ljc1MDEgMjQuNDY4N0wxMDAuNzgxIDI3LjkxNDlMOTQuNzE5IDMxLjQxNDlMOTQuNzUwMSAyNC40Njg3WiIgc3Ryb2tlPSIjNUNBNUVBIiBzdHJva2Utd2lkdGg9IjEuOCIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTEwNSAzOEMxMDUgMzguNTUyMyAxMDUuNDQ4IDM5IDEwNiAzOUMxMDYuNTUyIDM5IDEwNyAzOC41NTIzIDEwNyAzOFYzNkgxMDlDMTA5LjU1MiAzNiAxMTAgMzUuNTUyMyAxMTAgMzVDMTEwIDM0LjQ0NzcgMTA5LjU1MiAzNCAxMDkgMzRIMTA3VjMyQzEwNyAzMS40NDc3IDEwNi41NTIgMzEgMTA2IDMxQzEwNS40NDggMzEgMTA1IDMxLjQ0NzcgMTA1IDMyVjM0SDEwM0MxMDIuNDQ4IDM0IDEwMiAzNC40NDc3IDEwMiAzNUMxMDIgMzUuNTUyMyAxMDIuNDQ4IDM2IDEwMyAzNkgxMDVWMzhaIiBmaWxsPSIjQUI5M0RDIi8+Cjwvc3ZnPgo=",uP="data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMzcyIiBoZWlnaHQ9IjI3OSIgdmlld0JveD0iMCAwIDM3MiAyNzkiIGZpbGw9Im5vbmUiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyI+CjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMF8xMjU2XzM3MTY4KSI+CjxyZWN0IHdpZHRoPSIzNzIiIGhlaWdodD0iMjc5IiBmaWxsPSJ3aGl0ZSIvPgo8cmVjdCB4PSIzOS41NzQ1IiB5PSIzOS41NzQ3IiB3aWR0aD0iMTE4LjcyMyIgaGVpZ2h0PSIxNS44Mjk4IiByeD0iNy45MTQ4OSIgZmlsbD0iI0VBRjNGQyIvPgo8cmVjdCB4PSIzOS41NzQ1IiB5PSI3MS4yMzM5IiB3aWR0aD0iMjkyLjg1MSIgaGVpZ2h0PSI3LjkxNDg5IiByeD0iMy45NTc0NSIgZmlsbD0iI0VBRjNGQyIvPgo8cmVjdCB4PSIzOS41NzQ1IiB5PSI5MS4wMjE1IiB3aWR0aD0iMjkyLjg1MSIgaGVpZ2h0PSI3LjkxNDg5IiByeD0iMy45NTc0NSIgZmlsbD0iI0VBRjNGQyIvPgo8cmVjdCB4PSIzOS41NzQ1IiB5PSIxMTAuODA5IiB3aWR0aD0iMjkyLjg1MSIgaGVpZ2h0PSI3LjkxNDg5IiByeD0iMy45NTc0NSIgZmlsbD0iI0VBRjNGQyIvPgo8cmVjdCB4PSI0MC41NjM4IiB5PSIxMzUuNTQzIiB3aWR0aD0iMjkwLjg3MiIgaGVpZ2h0PSIxMDAuOTE1IiByeD0iMi45NjgwOSIgc3Ryb2tlPSIjRUFGM0ZDIiBzdHJva2Utd2lkdGg9IjEuOTc4NzIiLz4KPHBhdGggZD0iTTM5LjU3NDUgMTM4LjUxMUMzOS41NzQ1IDEzNi4zMjUgNDEuMzQ2MyAxMzQuNTUzIDQzLjUzMTkgMTM0LjU1M0gzMjguNDY4QzMzMC42NTQgMTM0LjU1MyAzMzIuNDI2IDEzNi4zMjUgMzMyLjQyNiAxMzguNTExVjE1Mi4zNjJIMzkuNTc0NVYxMzguNTExWiIgZmlsbD0iI0Q2RTlGQSIvPgo8cGF0aCBmaWxsLXJ1bGU9ImV2ZW5vZGQiIGNsaXAtcnVsZT0iZXZlbm9kZCIgZD0iTTg3LjA2MzcgMTY5LjE4MUM4Ny4wNjM3IDE2Ny41NDIgODguMzkyNiAxNjYuMjEzIDkwLjAzMTggMTY2LjIxM0gzMTcuNTg1QzMxOS4yMjQgMTY2LjIxMyAzMjAuNTUzIDE2Ny41NDIgMzIwLjU1MyAxNjkuMTgxQzMyMC41NTMgMTcwLjgyIDMxOS4yMjQgMTcyLjE0OSAzMTcuNTg1IDE3Mi4xNDlIOTAuMDMxOEM4OC4zOTI2IDE3Mi4xNDkgODcuMDYzNyAxNzAuODIgODcuMDYzNyAxNjkuMTgxWk0xMDQuODcyIDE5Mi45MjZDMTA0Ljg3MiAxOTEuMjg2IDEwNi4yMDEgMTg5Ljk1NyAxMDcuODQgMTg5Ljk1N0gzMTcuNTg1QzMxOS4yMjQgMTg5Ljk1NyAzMjAuNTUzIDE5MS4yODYgMzIwLjU1MyAxOTIuOTI2QzMyMC41NTMgMTk0LjU2NSAzMTkuMjI0IDE5NS44OTQgMzE3LjU4NSAxOTUuODk0SDEwNy44NEMxMDYuMjAxIDE5NS44OTQgMTA0Ljg3MiAxOTQuNTY1IDEwNC44NzIgMTkyLjkyNlpNMTA3Ljg0IDIxMy43MDJDMTA2LjIwMSAyMTMuNzAyIDEwNC44NzIgMjE1LjAzMSAxMDQuODcyIDIxNi42N0MxMDQuODcyIDIxOC4zMDkgMTA2LjIwMSAyMTkuNjM4IDEwNy44NCAyMTkuNjM4SDMxNy41ODVDMzE5LjIyNCAyMTkuNjM4IDMyMC41NTMgMjE4LjMwOSAzMjAuNTUzIDIxNi42N0MzMjAuNTUzIDIxNS4wMzEgMzE5LjIyNCAyMTMuNzAyIDMxNy41ODUgMjEzLjcwMkgxMDcuODRaIiBmaWxsPSIjRDZFOUZBIi8+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNNTEuNDQ2OCAxNjkuMTgxQzUxLjQ0NjggMTY3LjU0MiA1Mi43NzU2IDE2Ni4yMTMgNTQuNDE0OSAxNjYuMjEzSDYwLjM1MUM2MS45OTAzIDE2Ni4yMTMgNjMuMzE5MSAxNjcuNTQyIDYzLjMxOTEgMTY5LjE4MUM2My4zMTkxIDE3MC44MiA2MS45OTAzIDE3Mi4xNDkgNjAuMzUxIDE3Mi4xNDlINTQuNDE0OUM1Mi43NzU2IDE3Mi4xNDkgNTEuNDQ2OCAxNzAuODIgNTEuNDQ2OCAxNjkuMTgxWk01MS40NDY4IDE5Mi45MjZDNTEuNDQ2OCAxOTEuMjg2IDUyLjc3NTcgMTg5Ljk1NyA1NC40MTQ5IDE4OS45NTdINjAuMzUxMUM2MS45OTAzIDE4OS45NTcgNjMuMzE5MSAxOTEuMjg2IDYzLjMxOTEgMTkyLjkyNkM2My4zMTkxIDE5NC41NjUgNjEuOTkwMyAxOTUuODk0IDYwLjM1MTEgMTk1Ljg5NEg1NC40MTQ5QzUyLjc3NTcgMTk1Ljg5NCA1MS40NDY4IDE5NC41NjUgNTEuNDQ2OCAxOTIuOTI2Wk01NC40MTQ5IDIxMy43MDJDNTIuNzc1NyAyMTMuNzAyIDUxLjQ0NjggMjE1LjAzMSA1MS40NDY4IDIxNi42N0M1MS40NDY4IDIxOC4zMDkgNTIuNzc1NyAyMTkuNjM4IDU0LjQxNDkgMjE5LjYzOEg2MC4zNTExQzYxLjk5MDMgMjE5LjYzOCA2My4zMTkxIDIxOC4zMDkgNjMuMzE5MSAyMTYuNjdDNjMuMzE5MSAyMTUuMDMxIDYxLjk5MDMgMjEzLjcwMiA2MC4zNTExIDIxMy43MDJINTQuNDE0OVoiIGZpbGw9IiM5OUM3RjIiLz4KPHBhdGggZmlsbC1ydWxlPSJldmVub2RkIiBjbGlwLXJ1bGU9ImV2ZW5vZGQiIGQ9Ik02OS4yNTU0IDE2OS4xODFDNjkuMjU1NCAxNjcuNTQyIDcwLjU4NDMgMTY2LjIxMyA3Mi4yMjM1IDE2Ni4yMTNINzguMTU5N0M3OS43OTg5IDE2Ni4yMTMgODEuMTI3OCAxNjcuNTQyIDgxLjEyNzggMTY5LjE4MUM4MS4xMjc4IDE3MC44MiA3OS43OTg5IDE3Mi4xNDkgNzguMTU5NyAxNzIuMTQ5SDcyLjIyMzVDNzAuNTg0MyAxNzIuMTQ5IDY5LjI1NTQgMTcwLjgyIDY5LjI1NTQgMTY5LjE4MVpNNjkuMjU1NCAxOTIuOTI2QzY5LjI1NTQgMTkxLjI4NiA3MC41ODQyIDE4OS45NTcgNzIuMjIzNSAxODkuOTU3SDc4LjE1OTZDNzkuNzk4OSAxODkuOTU3IDgxLjEyNzcgMTkxLjI4NiA4MS4xMjc3IDE5Mi45MjZDODEuMTI3NyAxOTQuNTY1IDc5Ljc5ODkgMTk1Ljg5NCA3OC4xNTk2IDE5NS44OTRINzIuMjIzNUM3MC41ODQyIDE5NS44OTQgNjkuMjU1NCAxOTQuNTY1IDY5LjI1NTQgMTkyLjkyNlpNNzIuMjIzNSAyMTMuNzAyQzcwLjU4NDIgMjEzLjcwMiA2OS4yNTU0IDIxNS4wMzEgNjkuMjU1NCAyMTYuNjdDNjkuMjU1NCAyMTguMzA5IDcwLjU4NDIgMjE5LjYzOCA3Mi4yMjM1IDIxOS42MzhINzguMTU5NkM3OS43OTg5IDIxOS42MzggODEuMTI3NyAyMTguMzA5IDgxLjEyNzcgMjE2LjY3QzgxLjEyNzcgMjE1LjAzMSA3OS43OTg5IDIxMy43MDIgNzguMTU5NiAyMTMuNzAySDcyLjIyMzVaIiBmaWxsPSIjRjdEMDdGIi8+CjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgY2xpcC1ydWxlPSJldmVub2RkIiBkPSJNOTAuMDMxOCAxODkuOTU4Qzg4LjM5MjYgMTg5Ljk1OCA4Ny4wNjM3IDE5MS4yODYgODcuMDYzNyAxOTIuOTI2Qzg3LjA2MzcgMTk0LjU2NSA4OC4zOTI2IDE5NS44OTQgOTAuMDMxOCAxOTUuODk0SDk1Ljk2OEM5Ny42MDcyIDE5NS44OTQgOTguOTM2MSAxOTQuNTY1IDk4LjkzNjEgMTkyLjkyNkM5OC45MzYxIDE5MS4yODYgOTcuNjA3MiAxODkuOTU4IDk1Ljk2OCAxODkuOTU4SDkwLjAzMThaTTkwLjAzMTkgMjEzLjcwMkM4OC4zOTI3IDIxMy43MDIgODcuMDYzOCAyMTUuMDMxIDg3LjA2MzggMjE2LjY3Qzg3LjA2MzggMjE4LjMwOSA4OC4zOTI3IDIxOS42MzggOTAuMDMxOSAyMTkuNjM4SDk1Ljk2ODFDOTcuNjA3MyAyMTkuNjM4IDk4LjkzNjIgMjE4LjMwOSA5OC45MzYyIDIxNi42N0M5OC45MzYyIDIxNS4wMzEgOTcuNjA3MyAyMTMuNzAyIDk1Ljk2ODEgMjEzLjcwMkg5MC4wMzE5WiIgZmlsbD0iIzkxRDlCRSIvPgo8L2c+CjxkZWZzPgo8Y2xpcFBhdGggaWQ9ImNsaXAwXzEyNTZfMzcxNjgiPgo8cmVjdCB3aWR0aD0iMzcyIiBoZWlnaHQ9IjI3OSIgZmlsbD0id2hpdGUiLz4KPC9jbGlwUGF0aD4KPC9kZWZzPgo8L3N2Zz4K",C9=y("templates");function af(n){const t=n.rootElement.querySelector(":scope .editor-templates");if(!t)return null;const e=t.querySelector(":scope .editor-templates-cards");return d(C9,e,"no card container"),{root:t,cardContainer:e}}function hP(n){const t=af(n);if(t)return t.cardContainer.innerHTML="",t;const e=b("div",["editor-templates"],n.rootElement);b("div",["editor-templates-title"],e,S.t("templates.title"));const o=b("div",["editor-templates-cards"],e);return{root:e,cardContainer:o}}function b9(n,t,e,o,r){var f;const i=(f=n.options.componentsOptions)==null?void 0:f.templates,s=b("div",["editor-template-card",...o],null),l=b("div",["editor-template-thumb-container"],s),c=b("img",["editor-template-thumb"],l);c.src=t,c.style.display="none",c.onerror=()=>{var C;const m=(C=i==null?void 0:i.placeHolderImageSrc)!=null?C:uP;c.src!==m&&(c.src=m)},c.onload=()=>{c.style.display=""};const a=b("div",["editor-template-name"],s),u=b("span",[],a,e);return i!=null&&i.showTemplateTitleAttr&&u.setAttribute("title",e),s.onclick=()=>r(s),s}function fP(n,t){return t.thumbnailUrl?t.thumbnailUrl:n.doc.buildResourceUrl("thumbnail.png")}function mP(n,t){const e=fP(n,t);return b9(n,e,t.name,[],async()=>{var r,i;const o=(r=n.options.componentsOptions)==null?void 0:r.templates;(i=o==null?void 0:o.onApplyTemplate)==null||i.call(o,n,t)})}function gP(n,t){return b9(n,t,S.t("templates.choose"),["more"],()=>{var o,r;const e=(o=n.options.componentsOptions)==null?void 0:o.templates;(r=e==null?void 0:e.onChooseTemplate)==null||r.call(e,n)})}function pP(n,t){var f,m;const e=(f=n.options.componentsOptions)==null?void 0:f.templates;if(!e)return;const r=Gt(n.rootContainer).getBoundingClientRect().width;let i=1;const s=dP,l=af(n);if(l){if(t!=null&&t.reset){const C=Array.from(l.cardContainer.children),v=l.cardContainer.firstElementChild;if(d(C9,v,"no first card"),lt(v,"new")||lt(v,"more"))return;const w=window.getComputedStyle(v),E=parseFloat(w.marginLeft),L=parseFloat(w.marginRight),x=v.getBoundingClientRect().width+E+L;i=Math.floor(r/x);const O=Math.max(1,i-1-1),P=C.length-2;C.forEach((V,tt)=>{tt>O&&tt<P?V.style.display="none":(tt>=P&&lt(V,"more"),V.style.display="")})}return}const c=e.templates,{cardContainer:a}=hP(n);c.forEach((C,v)=>{const w=mP(n,C);if(v>0&&v>=i&&(w.style.display="none"),a.appendChild(w),v===0){const E=window.getComputedStyle(w),L=parseFloat(E.marginLeft),x=parseFloat(E.marginRight),A=w.getBoundingClientRect().width+L+x;i=Math.floor(r/A)-1}});const u=gP(n,s);a.appendChild(u),(m=e==null?void 0:e.onTemplateChooserStatusChanged)==null||m.call(e,n,a,"visible")}const v9=ie.default(pP,50);function CP(n){var o,r;const t=af(n);if(!t)return;t.root.remove();const e=(o=n.options.componentsOptions)==null?void 0:o.templates;(r=e==null?void 0:e.onTemplateChooserStatusChanged)==null||r.call(e,n,null,"hide")}function bP(n){const t=n.blocks.root;if(t.length===0)return!0;if(t.length>5)return!1;const e=[...t];e[0].type==="text"&&e[0].heading&&e.splice(0,1);const o=r=>{var i;return r.type!=="text"&&r.type!=="list"?!1:r.text?((i=r.text)==null?void 0:i.length)===0:!0};return e.every(r=>o(r))}function k9(n,t){bP(n.doc.toJSON())?v9(n,t):(v9.cancel(),CP(n))}class Ps{constructor(t,e){h(this,"_decrypted",!1);this.editor=t,this.blockData=e}get decrypted(){return this._decrypted||this.blockData.owner===this.editor.doc.getUser().userId}setDecrypted(){this._decrypted=!0}destroy(){}static getState(t,e){return t.addCustom(`encrypted-block-${e.id}`,()=>new Ps(t,e))}}const dz="",bo=y("encrypted-block");function vP(n,t,e,o,r){const i=r,s=eo(o,"div"),l=Ps.getState(n,i);if(l.decrypted)n.createChildContainer(t,s,i.children[0]),M(o,"decrypted");else{M(o,"encrypted");const c=At(o),a=b("div",["password-container"],c),u=b("input",[],a);u.type="text",u.onkeydown=f=>{if(f.key==="Enter"){const m=u.value;if(i.password===Ci.default(`${i.owner}-${m}`)){l.setDecrypted(),n.reloadBlock(o);const C=y1(n,n.getBlockById(i.id));C&&(n.selection.selectBlock(C,0),n.focus())}}}}return s}function kP(n,t,e,o){const r=document.elementsFromPoint(e,o)[0];if(!r||!t.contains(r)||!n.contains(t)||!fn(r))return null;const i=r;if(n.getBlockData(t).children[0]!==U(i))return null;const l=bt(t,U(i));return new Ye(n,{anchor:l,focus:l})}function yP(n,t,e,o){if(Ps.getState(n,n.getBlockData(t)).decrypted)return null;if(o==="ArrowDown"||o==="ArrowRight"){const s=ht(t);return s?$(s,Z(n,s),"end"):$(t,1,"end")}const i=gt(t);return $(i||t,0,"home")}function wP(n,t){return n.getBoundingClientRect()}function BP(n,t,e,o){if(e.isSimple()){d(bo,o.isSimple(),"from is simple position but to is not simple position"),bo.debug("full select table"),M(t,"full-selected");return}d(bo,!o.isSimple(),"from is complex position but end is simple position");const r=e,i=o;d(bo,r.blockId===i.blockId,"only allow update one table selection"),d(bo,r.childContainerId===i.childContainerId,"only one container");const s=n.getBlockData(t),l=n.getContainerById(s.children[0]);M(l,"selected")}function EP(n){n.rootContainer.querySelectorAll('[data-type="editor-block"][data-block-type="encrypted"]').forEach(t=>{F(t,"full-selected"),t.querySelectorAll("selected").forEach(e=>{F(e,"selected")})})}function IP(n,t){const e=n.getBlockData(t);return Ps.getState(n,e).decrypted?[n.getContainerById(e.children[0])]:[]}function xP(n,t,e,o,r){return null}function SP(n,t,e,o){d(bo,e.blockId===o.blockId,"only allow select in single block"),d(bo,G(t)===e.blockId,"only allow select in single block");const r=n.getBlockData(t);return d(bo,e.childContainerId===r.children[0],"only one container"),[n.getContainerById(r.children[0])]}function TP(n){return{name:"EncryptedBlock",insertBlockCommandItems:[{id:"insert-encrypted-block",name:"Encrypted Block"}],async handleInsertEmptyBlock(t,e){const o=pn(t.doc),r={id:N(),type:"encrypted",children:[o],owner:t.doc.getUser().userId,ownerDisplayName:t.doc.getUser().displayName,password:Ci.default(`${t.doc.getUser().userId}-1234`)},i=t.doc.getContainerBlocks(o)[0];return t.insertBlock(e.containerId,e.blockIndex,r,Ot(t,i.id,0))}}}const DP={blockType:"encrypted",blockKind:"complex",enableKeyboardSelect:!0,createBlockContent:vP,getBlockTextLength:()=>1,getRangeFromPoint:kP,moveCaret:yP,getCaretRect:wP,updateSelection:BP,clearSelection:EP,getChildContainers:IP,getNextContainer:xP,getSelectedContainers:SP,getOptions:TP};function LP(n,t,e){const o=Ui(n,t,{components:{blocks:[Cs,ks,DP],decorators:[new ws],embeds:[Jc,hh,Rh,Ah,Oh,Qu,_h,tf,Xh],boxes:[Lc],options:{...e.componentsOptions}}});return o.readonly=!0,o}class MP{constructor(t){this.createOptions=t}createHistoryEditor(t,e){return LP(t,e,this.createOptions)}}y("create-editor");function RP({root:n,localDoc:t,rootEditorCreateOptions:e,shareDBDoc:o}){t.uploadResource=o.uploadResource.bind(o),t.buildResourceUrl=o.buildResourceUrl.bind(o);const r=Ui(n,t,{shortcuts:[Ul],components:{blocks:[Cs,ks],decorators:[new ws],embeds:[b6,Jc,hh,Rh,Ah,Oh,Qu,_h,tf,Xh],boxes:[Lc,p9],options:{...e.componentsOptions}}});return r.input.addHandler(new Hc),r.input.addHandler(new Nh(r)),r.input.addHandler(new n_(r)),r}function AP(n,t){const e=Array.from(n.rootContainer.querySelectorAll(`[comment-${t.toLocaleLowerCase()}="${t}"]`)),o=new Set;e.forEach(r=>{const i=z(r);i&&o.add(i)}),o.forEach(r=>{o_(n,r,t)})}class OP{constructor(t,e){h(this,"listeners",new Set);h(this,"doc");this.editor=t,this.rootEditorCreateOptions=e,this.doc=this.editor.doc.externalDoc,this.doc.registerCallback(this)}getAuth(){return this.doc.client.auth}getComments(){return this.doc.getComments()}getComment(t){return this.doc.getComment(t)}getCommentDoc(t){return this.doc.getCommentDoc(t)}localCreateComment(t,e){this.doc.localCreateComment(t,e)}localDeleteComment(t){const e=this.getComment(t);this.doc.localDeleteComment(t);const o=e.groupId;this.getComments().filter(i=>i.groupId===o).length===0&&AP(this.editor,o)}localUpdateComment(t,e){this.doc.localUpdateComment(t,e)}onCreateComment(t,e){Array.from(this.listeners.values()).forEach(o=>o.onCreateComment(t,e))}onDeleteComment(t,e){Array.from(this.listeners.values()).forEach(o=>o.onDeleteComment(t,e))}onUpdateComment(t,e){Array.from(this.listeners.values()).forEach(o=>o.onUpdateComment(t,e))}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}createCommentEditor(t,e){return RP({root:t,localDoc:e,rootEditorCreateOptions:this.rootEditorCreateOptions,shareDBDoc:this.doc})}}const y9=y("create-editor"),w9=[Jc,hh,Rh,Ah,Oh,Qu,_h,tf,Xh,b6,m9,F_];async function _P(n,t){var r,i,s,l,c,a,u,f,m;d(y9,n,"app does not exists");const e=await ec.load({auth:{appId:t.appId,docId:t.docId,userId:t.user.userId,permission:t.permission,token:t.token,displayName:t.user.displayName,avatarUrl:t.user.avatarUrl},serverUrl:t.serverUrl}),o=Ui(n,e,{id:t.id,components:{blocks:[Cs,ks,bh,s4],commandProviders:[new yu],decorators:[new ws,new zd],embeds:[...w9,...((r=t.components)==null?void 0:r.embeds)||[]],boxes:[Lc,p9,N3],insertions:[j1],blockHooks:[new d6],textRenders:[new L3,new hx],options:{...t.componentsOptions}},shortcuts:[TD,lM,ih,a3,fx,Xu,Ul]});if(o.editorCommandProviders.registerCommandProvider(new xn(o)),o.input.addHandler(new VN),o.input.addHandler(new Hc),o.input.addHandler(new vs(o,{headingLevel:1,titlePlaceholder:"Document title",addPlaceholderToAllCurrentEmptyBlock:!0})),o.input.addHandler(new Mc(o,(i=t.componentsOptions)==null?void 0:i.quickMenu)),o.input.addHandler(new Nh(o)),o.input.addHandler(new t3(o)),o.doc.registerCallback(new qN(o)),o.addCustom("remote-cursor",()=>new s5(o)),o.addCustom("block-menu",C=>new m6(C)),o.addCustom("editor-tooltip",()=>new Ju(o)),o.addCustom("editor-comments",C=>new JO(C,new OP(C,t))),o.addCustom("create-options",()=>new Pf(o,t)),o.addCustom("drop-target",()=>new Ts(o)),o.addCustom("list-to-mindmap",()=>new Sc(o)),o.addCustom("list-to-mention",()=>new lP(o)),(s=t.componentsOptions)!=null&&s.mention){const C=t.componentsOptions.mention;o.addCustom("mention",()=>new oP(o,C))}if(o.addCustom("heading-collapse",()=>new jN(o)),Gr.register(o),Ts.register(o),cr.register(o),(c=(l=t.componentsOptions)==null?void 0:l.remoteCarets)!=null&&c.onUserChanged){const C=(u=(a=t.componentsOptions)==null?void 0:a.remoteCarets)==null?void 0:u.onUserChanged;o.doc.getRemoteUsers().on("change",v=>{C(o,v)})}return(m=(f=t.componentsOptions)==null?void 0:f.templates)!=null&&m.templates.length&&(o.addListener("docChanged",()=>{k9(o)}),setTimeout(()=>{k9(o)},100)),o}async function NP(n,t,e){var i,s;d(y9,n,"app does not exists");const o=new Id(t,{serverUrl:e.serverUrl||""}),r=Ui(n,o,{id:e.id,components:{blocks:[Cs,ks,bh,s4],commandProviders:[new yu],decorators:[new ws,new zd],embeds:[...w9,...((i=e.components)==null?void 0:i.embeds)||[]],boxes:[Lc,N3],insertions:[j1],blockHooks:[new d6],textRenders:[new L3],options:{...e.componentsOptions}},shortcuts:[ih,a3,Xu,Ul]});return r.editorCommandProviders.registerCommandProvider(new xn(r)),r.input.addHandler(new Hc),r.input.addHandler(new vs(r,{headingLevel:1,titlePlaceholder:"Document title",contentPlaceholder:"Enter some text...",addPlaceholderToAllCurrentEmptyBlock:!0})),r.input.addHandler(new Mc(r,(s=e.componentsOptions)==null?void 0:s.quickMenu)),r.input.addHandler(new Nh(r)),r.input.addHandler(new t3(r)),r.addCustom("block-menu",l=>new m6(l)),r.addCustom("editor-tooltip",()=>new Ju(r)),Gr.register(r),r}function PP(n,t){var l;const e=n.doc;if(!((l=e.getVersionHelper)==null?void 0:l.call(e)))throw new Error("the editor does not support to show versions");const r=n.getCustom("create-options");if(!r)throw new Error("the editor does not support to show versions");const i=r.getData(),s=new MP(i);return DN(n,s,t)}g.AuthError=Xl,g.AuthHeader=es,g.AutoScroll=bm,g.BaseURLHeader=tc,g.BlockResizer=$c,g.BrBox=Zg,g.CodeBlock=ks,g.CodeLineBlock=bh,g.CodeTextDecorator=ws,g.DefaultShortcuts=Ul,g.DocIdError=uw,g.DragDrop=Kf,g.DrawioEmbed=Jc,g.EditorBlocks=og,g.EditorBoxes=Qg,g.EditorCommandProviders=k0,g.EditorComplexBlockPosition=Ze,g.EditorComplexSelectionRange=Ye,g.EditorDecorators=t2,g.EditorEmbeds=ig,g.EditorInsertions=Xg,g.EditorSimpleBlockPosition=Ut,g.EditorSimpleSelectionRange=se,g.EmbedBlock=lg,g.EnforceWithDocumentTitleHandler=vs,g.EventCallbacks=ki,g.FILL_CHAR=Eb,g.FileExtError=hw,g.HeadingBlockScrollListener=nP,g.InputtingInsertion=Kg,g.LocalDoc=Id,g.Logger=vi,g.MIN_DISTANCE_THRESHOLD=Yf,g.MarkdownInputHandler=Hc,g.MaxUserError=Pd,g.OnesEditorCustomDataWrapper=Pf,g.OnesEditorHoveringBlock=_t,g.OnesEditorQuickMenu=Mc,g.OnesEditorToc=Ns,g.OnesEditorTocProvider=cr,g.OnesEditorToolbar=Gr,g.OnesEditorTooltip=Ju,g.PermissionError=dw,g.RemoteCarets=s5,g.RemoteCaretsDecorator=zd,g.RemoteCaretsInsertion=j1,g.RemoteUsers=ql,g.RequestReloadError=ts,g.RichText=ne,g.ShareDBDoc=ec,g.SimpleCache=Hf,g.StandardEmbedBlockCommands=dh,g.TEXT_STYLE_BACKGROUND_COLOR_PREFIX=_1,g.TEXT_STYLE_COLOR_PREFIX=O1,g.TableBlock=Cs,g.TableBlockCommandProvider=yu,g.TableShortcuts=ih,g.TextBlock=_i,g.TextBox=Gg,g.TextStyleShortcuts=Xu,g.TocEmbed=m9,g.ZERO_WIDTH_SPACE_CHAR=yi,g.addAttribute=yl,g.addClass=M,g.addCommentToBlock=ah,g.addDays=tC,g.addMonths=X8,g.animateScrollTo=Ei,g.applyPlaceholderToBlock=jc,g.assert=d,g.blockToDoc=nd,g.blockToHtml=F1,g.blockToMarkdown=e2,g.blockToText=Dl,g.blocksToDoc=tv,g.clearAllSelection=Wm,g.clientType=It,g.cloneBlock=Fo,g.cloneChildContainer=K1,g.cloneDoc=J1,g.cloneText=Pg,g.compareElement=Xs,g.comparePosition=v1,g.complexBlockAdjustSelectionPos=ml,g.complexBlockFindNearestChildBlock=ug,g.complexBlockGeFirstSimpleChild=y1,g.complexBlockGetAllChildContainers=Le,g.complexBlockGetBottomChildContainers=dg,g.complexBlockGetLastSimpleChild=wr,g.complexBlockGetSelectedContainers=yr,g.complexBlockGetTopChildContainers=ag,g.containerToDoc=od,g.continuousScroll=Cm,g.convertBlockFrom=hl,g.copyBlockAttributes=d2,g.createBlockAnchor=_o,g.createBlockContentElement=eo,g.createBlockElement=Sm,g.createBlockSimpleDocRange=Tl,g.createBlockSimpleRange=Ot,g.createBoxContentElement=Lm,g.createBoxElement=Tm,g.createBoxOp=Tg,g.createChildContainer=Um,g.createComplexBlockPosition=bt,g.createComplexDocPos=Vg,g.createComplexDocRange=xb,g.createContainer=jg,g.createContainerElement=u1,g.createDeleteOps=Eg,g.createEditor=Ui,g.createEditorSelectionRange=Vt,g.createElement=b,g.createEmptyContainer=pn,g.createEmptyDoc=oo,g.createEmptyTextBlockData=Il,g.createExpandedRange=Ks,g.createIconButton=hr,g.createImage=jf,g.createInsertOps=kl,g.createInsertionContentElement=Am,g.createInsertionElement=Mm,g.createLocalEditor=NP,g.createOnesEditor=_P,g.createRange=Ff,g.createRichText=Oi,g.createRootContainer=zm,g.createSimpleBlockPosition=$,g.createSimpleDocPos=Ug,g.createTextBlockData=jn,g.createTextButton=Xo,g.createTextOp=_e,g.createTextWithReplaceSoftReturn=L1,g.daysAfter=n1,g.deleteText=R1,g.diffDays=eC,g.disablePageScroll=dm,g.docToHtml=jb,g.docToHtmlFragment=n2,g.docToMarkdown=Fb,g.docToText=o2,g.downloadObjectToFile=Sh,g.downloadSvgToString=k6,g.editLink=vc,g.editorAddComment=i_,g.editorAddTextAttribute=B2,g.editorAutoInsertBlock=u2,g.editorBreakTextBlock=Pi,g.editorClearCompositionText=a2,g.editorClearSelectedContents=Y1,g.editorCopyBlock=cd,g.editorDeleteBlock=G1,g.editorDeleteBlockText=V1,g.editorDeleteBlockWithoutChildren=W1,g.editorDeleteChildContainer=Yb,g.editorDeleteChildContainers=m2,g.editorFocusToBlock=Q1,g.editorFocusToEnd=S2,g.editorGetBlockData=ro,g.editorGetBlockText=ke,g.editorGetBlockTextEx=Ml,g.editorGetBoxData=r2,g.editorHandleKeyboardEvent=e0,g.editorInsertBlock=Dr,g.editorInsertBoxToBlock=l2,g.editorInsertDoc=y2,g.editorInsertDocAt=X1,g.editorInsertText=U1,g.editorInsertTextToBlock=s2,g.editorInsertTextToBlockEx=z1,g.editorMergeTextBlock=g2,g.editorRangeClearColor=I2,g.editorRangeGetColor=td,g.editorRangeSetColor=E2,g.editorRemoveTextAttribute=Jb,g.editorReplaceBlockText=Nl,g.editorReplaceContainer=w2,g.editorRunOnce=xd,g.editorSelectEnd=x2,g.editorSetTextColor=Lr,g.editorShowFindDialog=aO,g.editorUpdateBlockData=Pl,g.editorUpdateCompositionText=c2,g.editorUpdateEmbedData=v2,g.enablePageScroll=um,g.escapeHtmlText=Wf,g.escapeRegExp=i1,g.escapeSpace=N8,g.executeBlockCommand=ng,g.executeEmbedBlockCommand=eg,g.executeRangeCommand=v0,g.fileToDataUrl=nl,g.findAllText=$1,g.findInsertionById=Rm,g.findPrevSimpleBlockBeforeChildContainer=cg,g.findTarget=Bi,g.format=e1,g.formatBytes=vm,g.formatDate=wm,g.fragmentToHtml=hm,g.fromBase64=el,g.fromBase64ToBlob=cm,g.fromBase64ToUint8Array=Z8,g.fromDocRange=no,g.fromNowString=r1,g.genId=N,g.getAllChildBlocks=B1,g.getAllQuickMenuItems=Ku,g.getAllSelectedBlocks=Qe,g.getAttributesAt=Bl,g.getBlockBackground=xm,g.getBlockByIndex=mr,g.getBlockCaretRect=Ge,g.getBlockClass=kt,g.getBlockClassByType=vr,g.getBlockClientRects=Ao,g.getBlockCommandsWithHook=p1,g.getBlockContent=rt,g.getBlockId=G,g.getBlockIndex=K,g.getBlockKind=We,g.getBlockMinWidth=Zm,g.getBlockOptions=uC,g.getBlockPath=Ro,g.getBlockProperties=Km,g.getBlockStyles=aC,g.getBlockTextLength=Z,g.getBlockTools=At,g.getBlockType=it,g.getBoxContent=c1,g.getBoxId=Dm,g.getBoxTypeFromElement=Si,g.getChildBlockCount=Ue,g.getChildBlocks=Rt,g.getChildOffset=Er,g.getColorFromAttributes=P1,g.getComplexBlockClass=ve,g.getContainerBlockPath=Hm,g.getContainerBlocks=Pm,g.getContainerBlocksElement=dl,g.getContainerById=br,g.getContainerId=U,g.getContainerMinWidth=m1,g.getContainerToolsElement=rC,g.getContainerWidth=Qm,g.getDistanceSquare=hn,g.getElementOffset=wi,g.getEmbedType=De,g.getExistsBlockTools=al,g.getExistsContainerById=_m,g.getFileExt=mm,g.getFirstChildBlock=Qt,g.getFirstClientRect=Js,g.getHeadingMenuOptions=Dc,g.getHorizontalPadding=Va,g.getInsertionContent=a1,g.getLastChildBlock=Gt,g.getLastClientRect=xo,g.getLogger=y,g.getNextBlock=ht,g.getNextValidOffset=Ir,g.getNextVisibleBlock=Cr,g.getOpAt=Lg,g.getOpLength=A1,g.getParentBlock=z,g.getParentBox=l1,g.getParentContainer=H,g.getPrevBlock=gt,g.getPrevValidOffset=Po,g.getPrevVisibleBlock=pr,g.getRangeCommands=C0,g.getRootBlock=ul,g.getScrollContainer=Nn,g.getSpecialBlockCommands=Jm,g.getStandardEmbedBlockProperties=uh,g.getTextBlockChild=gl,g.getTextBlockClass=qm,g.getTextBlockContentChildTextLength=Re,g.getTextBlockContentChildType=hg,g.getTextBlockContentChildren=Hn,g.getTextLength=ce,g.getTextOpLength=I1,g.getTextWidth=rl,g.getToolbar=bc,g.handleBlockElementUpdated=Ym,g.hasAltOnly=z8,g.hasClass=lt,g.hasCtrlOrCmd=rm,g.hasCtrlOrCmdOnly=F8,g.hideBlock=Em,g.htmlToFragment=ol,g.i18n=S,g.injectStyle=Zf,g.insertEmptyBlock=fC,g.insertEmptyEmbedBlock=tg,g.insertText=xr,g.intersectionCommands=iy,g.isBackspace=sm,g.isBlock=gr,g.isBox=s1,g.isCJK=em,g.isChildContainer=qe,g.isChildNode=vt,g.isCollapsedRange=zg,g.isComplexBlockPosition=b1,g.isComplexKindBlock=ct,g.isContainer=fn,g.isControlEvent=Do,g.isDelete=V8,g.isDraggingFiles=sl,g.isEmbedBlock=Te,g.isEmptyContainer=g1,g.isEmptyDoc=xl,g.isEmptyTextBlock=wt,g.isEmptyTextBlockWithoutCompositionText=bs,g.isEnterOnly=im,g.isEscape=Ja,g.isFirefox=Qa,g.isFirstChildBlockInComplexBlock=jC,g.isHighSurrogate=L8,g.isInBlock=d1,g.isInBlockTools=Ti,g.isLetter=tm,g.isLowSurrogate=Ua,g.isMatchShortcut=_n,g.isMoveForward=H8,g.isNavigationEvent=$8,g.isNavigationKey=om,g.isNodeRemoved=Uf,g.isNumber=Xf,g.isPrintableKey=Ka,g.isRootBlock=Uo,g.isRootContainer=Ct,g.isSafari=nm,g.isSameDay=o1,g.isShiftEnter=U8,g.isShiftTab=W8,g.isShortcutEvent=j8,g.isSimpleBlock=dC,g.isSimpleBlockPosition=kr,g.isSimplePos=Fg,g.isSimpleRange=Sl,g.isSpace=tl,g.isTab=q8,g.isTextBlockContentBoxChild=Me,g.isTextBlockContentChild=Li,g.isTextBlockContentInsertionChild=$n,g.isTextBlockContentTextChild=Mi,g.isTextKindBlock=j,g.isTextKindBlockType=Di,g.isToday=km,g.isValidOffset=fe,g.isVisibleBlock=cl,g.isYesterday=ym,g.loadJs=Vf,g.loadJsPromise=So,g.lockers=Rn,g.mergeCommands=Cc,g.mergeDocs=jo,g.mergeOps=M1,g.mergeText=kb,g.multiSplitText=gg,g.parseShortcut=lm,g.patchNode=xi,g.pointInRect=To,g.rangeAddAttribute=wl,g.rangeGetTextColor=Ng,g.rangeRemoveAttribute=Sr,g.rangeSetTextColor=Ag,g.rangeTransformText=Mg,g.registerDragDrop=Za,g.removeAttribute=N1,g.removeClass=F,g.removeLastBr=pb,g.removePlaceholderFromBlock=j4,g.removeStyle=Gf,g.replaceAll=nC,g.replaceAllCaseInsensitive=oC,g.replaceAllText=Hg,g.replaceText=El,g.requestDownload=ll,g.scrollable=pm,g.selectFile=fr,g.selectedBlockToDoc=Hl,g.selectionToDoc=jl,g.setAttributes=Wa,g.setClipboardData=il,g.setClipboardDataByEvent=J8,g.setColorToAttributes=Og,g.setDataset=qa,g.setDefaultCursor=Ii,g.setStyles=Ga,g.shortcutToDisplayText=G8,g.showBlock=Im,g.showDocVersions=PP,g.splitText=Ae,g.splitToThree=Kt,g.stringToDataUrl=am,g.stringToObjectUrl=t1,g.subText=pg,g.textNodeOffsetFromPoint=zf,g.toBase64URL=Lo,g.toPlainText=Tt,g.trimChar=Ya,g.unicodeLength=M8,g.unicodeSubstr=R8,g.updateBlockSelection=Gm,g.updateOpAttributes=$g,g.updateTextBlockContent=Mb,g.updateUrl=Xa,Object.defineProperties(g,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});