@ones-editor/editor 0.0.3-beta.164 → 0.0.3-beta.165

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(`@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: #cdcdcd40}div.editor-root{color:var(--text-color);position:relative;box-sizing:border-box;min-height:100%;width:100%;z-index:1}div.editor-root.readonly div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content] span.text.link{cursor:pointer}div.editor-root *{box-sizing:border-box;font-family:var(--font-family)}div.editor-root button{outline:none}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;transition:top .1s ease-in,left .1s linear;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;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>.container-blocks>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>.container-blocks>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].root.select-all>.container-blocks>div[data-type=editor-block].embed-block>div[data-type=block-content]:before,div.editor-root div.editor-content div[data-type=editor-container].root.select-all>.container-blocks>div[data-type=editor-block].embed-block .embed-selected-content:before{display:none}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}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block]{font-size:var(--font-size);line-height:var(--line-height);position:relative;--font-size: 15px;--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{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.link.style-strikethrough:hover{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-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-strikethrough{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-strikethrough{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-sub{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-super{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;background-color:transparent;border:none}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-content] span[data-type=editor-box][data-box-type=image].image-box span[data-type=box-content]{user-select:none;margin-left:0;margin-right:0}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>div[data-type=block-content],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>div[data-type=block-content]:before,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;margin-top:24px}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;margin-top:24px}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;margin-top:20px}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;margin-top:20px}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;margin-top:16px}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;margin-top:16px}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}div:not(.comment-editor-root)>div.editor-root>div.editor-content>div[data-type=editor-container]>div.container-blocks>div[data-type=editor-block]:first-of-type{font-size:30px;line-height:1.3}div.editor-root div.editor-content>div[data-type=editor-container]>div.container-blocks :first-child{margin-top:0}.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}.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}[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}[data-theme=dropdown-list] .tippy-content{padding:0;background:white;color:#303030}[data-theme=dropdown-list] .tippy-content .editor-command-bar{max-height:50vh}[data-theme=dropdown-list] .filterable-list{min-width:100px;max-width:300px;display:flex;flex-direction:column;max-height:100%}[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}[data-theme=dropdown-list] .filterable-list .list .list-item.disabled{color:#c1c1c1}::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}}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}div.tippy-box[data-theme=menu] .tippy-content .editor-command-bar-root,div.tippy-box[data-theme=toolbar] .tippy-content .editor-command-bar-root{box-shadow:0 0 1px #30303040,0 12px 24px #30303026}div.tippy-box button{outline:none}.editor-command-bar-root{display:flex;flex-direction:column;align-items:flex-start;background:#ffffff;border-radius:2px;max-height:50vh;overflow:auto}.editor-command-bar-root.scrollable-bar>.editor-command-bar.menu{overflow-y:scroll}.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.fixed.toolbar{box-shadow:none}.editor-command-bar.menu{flex:1;width:100%;display:flex;flex-direction:column;align-items:flex-start;padding:5px 0}.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-subtext{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:not(.disabled){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}.editor-command-bar.footer{width:100%}.reference-hidden .tippy-box[data-reference-hidden]{opacity:0;pointer-events:none;transition:none}.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}.editor-dropdown{display:flex;align-items:center;border:1px solid #f0f0f0;border-radius:3px;font-size:14px;width:200px;height:30px}.editor-dropdown *{box-sizing:border-box;font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif}.editor-dropdown .dropdown-text,.editor-dropdown .dropdown-input{flex-grow:1;padding:2px 8px;border:none;outline:none;background:transparent;font-size:14px;color:#333;min-width:0;flex-shrink:1}.editor-dropdown .dropdown-text{margin-right:4.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;height:100%;cursor:text;display:flex;align-items:center}.editor-dropdown:hover{border-color:#338fe5}.editor-dropdown.active{border-color:#338fe5;box-shadow:0 0 0 2px #338fe533}.editor-dropdown.active .dropdown-text{display:none}.editor-dropdown:not(.active) .dropdown-input{display:none}.editor-dropdown .dropdown-labels{display:flex;align-items:center;flex-shrink:0}.editor-dropdown .dropdown-labels .dropdown-label{color:#338fe5;background-color:#eaf3fc;height:20px;padding:0 5px;border-radius:3px;display:flex;align-items:center}.editor-dropdown .dropdown-labels .dropdown-label+.dropdown-label{margin-left:5px}.editor-dropdown .dropdown-clear-icon,.editor-dropdown .dropdown-icon{flex-shrink:0;width:16px;height:16px;margin-left:4px;display:flex;align-items:center;justify-content:center;cursor:pointer}.editor-dropdown .dropdown-clear-icon{color:#909090}.editor-dropdown.empty .dropdown-clear-icon,.editor-dropdown:not(:hover) .dropdown-clear-icon{display:none}.editor-dropdown.empty .dropdown-text{color:#909090}.editor-dropdown .dropdown-icon{margin-right:4px}.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]{height:32px;width:unset}[data-command-bar-id=editor-toolbar] .command-item[data-id=link-text].selected:hover{background-color:transparent}[data-command-bar-id=editor-toolbar] .command-item[data-id=link-text] .link-href-button{max-width:275px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;color:#303030;text-decoration:none}[data-command-bar-id=editor-toolbar] .command-item[data-id=link-text] .link-href-button:hover{text-decoration:underline}[data-command-bar-id=editor-toolbar] .command-item[data-id=edit-link],[data-command-bar-id=editor-toolbar] .command-item[data-id=remove-link]{height:32px}[data-command-bar-id=editor-toolbar] .command-item[data-id=edit-link] svg,[data-command-bar-id=editor-toolbar] .command-item[data-id=remove-link] svg{stroke-width:2}[data-command-bar-id=editor-toolbar] .command-item[data-id=edit-link].selected:hover,[data-command-bar-id=editor-toolbar] .command-item[data-id=remove-link].selected:hover{background-color:transparent;color:#338fe5}[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-subtext,[data-command-bar-id=empty-block-menu] .command-item.menu-item .quick-menu-item .quick-menu-item-content .item-line-1 .item-subtext{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[data-theme=editor-tooltip]{background-color:#303030;opacity:.8;font-size:12px;border-radius:3px}div.tippy-box[data-theme=editor-tooltip] .editor-tooltip-desc{display:block;margin-top:2px;color:#a8a9ab}div.tippy-box[data-theme=editor-tooltip]>.tippy-arrow:before{transform:scale(.8)}div.tippy-box[data-theme=editor-tooltip]>.tippy-content{padding:4px 10px;text-align:justify}.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 .list-to-mindmap-wrap,.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block .mention-button-wrap{position:absolute;right:0;top:2px;display:flex;align-items:center;height:calc(var(--font-size) * var(--line-height))}.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=mention-button]{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;color:#07142a}.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=mention-button] 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=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-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-list-type=unordered] .list-container .list-marker{font-family:PingFangSC-Regular,PingFang SC;justify-content:space-around}.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 [data-type=editor-container].root div[data-type=editor-block].list-block div[data-type=block-tools] .block-helper{top:2px}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block[data-style-align=center]{justify-content:center}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block[data-style-align=center]>div[data-type=block-content]{flex-grow:initial}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block[data-style-align=right]{justify-content:flex-end}.editor-root [data-type=editor-container].root div[data-type=editor-block].list-block[data-style-align=right]>div[data-type=block-content]{flex-grow:initial}.editor-root.readonly button[data-button-id=mindmap-close]{display:none}.editor-root:not(.readonly) div[data-type=editor-block].list-block.active,.editor-root:not(.readonly) div[data-type=editor-block].list-block.hover{background-color:#f8f8f8}.editor-root:not(.readonly) div[data-type=editor-block].list-block.active .list-container,.editor-root:not(.readonly) div[data-type=editor-block].list-block.hover .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]):not([data-list-type=unordered]) .list-container:hover{background-color:var(--background-selection)}.editor-root:not(.readonly) div[data-type=editor-block].list-block[data-list-type=unordered] .list-container:hover .list-marker{cursor:initial}.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:not(.readonly) div.editor-content div[data-type=editor-container] div[data-type=editor-block].list-block [data-type=block-content][data-content-placeholder]:before{left:2px}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.math-box{display:inline-flex}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block] div[data-type=block-content]>span.math-box .mathjax-tex-text.mathjax-error{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] img.mathjax{max-width:100%}div.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-embed-type=math]>div[data-type=block-content]{align-items:center;justify-content:center;min-height:40px}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 div[data-type=block-tools] .table-resize-gripper,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=block-tools] .table-resize-gripper>.table-resize-gripper-indicator,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=block-tools] .table-border-bar-container,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=block-tools] .table-border-bar-container.top,div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container.top{left:0;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=block-tools] .table-border-bar-container.left,div[data-type=editor-block].table-block div[data-type=table-tools] .table-border-bar-container.left{top:20px;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=block-tools] .table-border-bar-container .table-border-bar,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=block-tools] .table-border-bar-container .table-border-bar.left,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=block-tools] .table-border-bar-container .table-border-bar .table-border-bar-cell,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:#e8e8e8;position:relative;flex-grow:0;flex-shrink:0}div[data-type=editor-block].table-block div[data-type=block-tools] .table-border-bar-container .table-border-bar .table-border-bar-cell.corner,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);height:var(--table-bar-width)}div[data-type=editor-block].table-block div[data-type=block-tools] .table-border-bar-container .table-border-bar .table-border-bar-cell.top,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=block-tools] .table-border-bar-container .table-border-bar .table-border-bar-cell:hover,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:#dedede}div[data-type=editor-block].table-block div[data-type=block-tools] .table-border-bar-container .table-border-bar .table-border-bar-cell.selected,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=block-tools] .table-border-bar-container .table-border-bar .table-border-bar-cell.danger,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=block-tools] .table-border-bar-container .table-border-bar .button-root,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=block-tools] .table-border-bar-container .table-border-bar .button-root.top,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=block-tools] .table-border-bar-container .table-border-bar .button-root.top:last-child,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=block-tools] .table-border-bar-container .table-border-bar .button-root.left,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=block-tools] .table-border-bar-container .table-border-bar .button-root.left:last-child,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=block-tools] .table-border-bar-container .table-border-bar .button-root .button-container,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=block-tools] .table-border-bar-container .table-border-bar .button-root .button-container.top,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=block-tools] .table-border-bar-container .table-border-bar .button-root .button-container.left,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=block-tools] .table-border-bar-container .table-border-bar .button-root .button-container .insert-indicator,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:#e8e8e8;border-radius:50%;margin-top:6px}div[data-type=editor-block].table-block div[data-type=block-tools] .table-border-bar-container .table-border-bar .button-root .button-container:hover .insert-indicator,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=block-tools] .table-border-bar-container .table-border-bar .button-root .button-container:hover .insert-column-button,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=block-tools] .table-border-bar-container .table-border-bar .button-root .button-container:hover .insert-column-button span.icon,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=block-tools] .table-border-bar-container .table-border-bar .button-root .button-container:hover .drop-marker,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=block-tools] .table-border-bar-container .table-border-bar .button-root .button-container .drop-marker,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=block-tools] .table-border-bar-container .table-border-bar .button-root .button-container .drop-marker:after,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=block-tools] .table-border-bar-container .table-border-bar .button-root .button-container .drop-marker:before,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=block-tools] .editor-table-chart,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 #c7c7c7;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;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]>.container-blocks>*+*{margin-top:5px}div[data-type=editor-block].table-block div[data-type=table-content] .child{padding:8px}div[data-type=editor-block].table-block div[data-type=table-content] .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] .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=block-content]>.scroll-container-root>.scroll-container>.scroll-area>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-container].root.select-all>.container-blocks>div[data-type=editor-block][data-block-type=table]{background-color:transparent}div.editor-root div.editor-content div[data-type=editor-container].root.select-all>.container-blocks>div[data-type=editor-block][data-block-type=table] table.row-title>tbody>tr:first-child>td,div.editor-root div.editor-content div[data-type=editor-container].root.select-all>.container-blocks>div[data-type=editor-block][data-block-type=table] table.col-title td.col-title-item{background-color:transparent}div.editor-root div.editor-content div[data-type=editor-container].root.select-all>.container-blocks>div[data-type=editor-block][data-block-type=table] table.stripe:not(.row-title)>tbody>tr:nth-of-type(2n),div.editor-root div.editor-content div[data-type=editor-container].root.select-all>.container-blocks>div[data-type=editor-block][data-block-type=table] table.stripe.row-title>tbody>tr:nth-of-type(2n + 1){background-color:transparent}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-block-type=table].comment,div.editor-root div.editor-content div[data-type=editor-container].child div[data-type=editor-block][data-block-type=table].comment{box-shadow:none}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-block-type=table].comment table,div.editor-root div.editor-content div[data-type=editor-container].child div[data-type=editor-block][data-block-type=table].comment table{box-shadow:0 2px #f8e6ab}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-block-type=table].comment table table,div.editor-root div.editor-content div[data-type=editor-container].child div[data-type=editor-block][data-block-type=table].comment table table{box-shadow:none}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-block-type=table].comment.active,div.editor-root div.editor-content div[data-type=editor-container].child div[data-type=editor-block][data-block-type=table].comment.active{outline:none}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-block-type=table].comment.active table,div.editor-root div.editor-content div[data-type=editor-container].child div[data-type=editor-block][data-block-type=table].comment.active table{border-bottom:none;outline:4px solid #f8e6ab}div.editor-root div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-block-type=table].comment.active table table,div.editor-root div.editor-content div[data-type=editor-container].child div[data-type=editor-block][data-block-type=table].comment.active table table{box-shadow:none;outline:none}div.editor-root:not(.readonly) div[data-type=editor-block].table-block.locked-by-self>[data-type=block-content]:after,div.editor-root:not(.readonly) div[data-type=editor-block].table-block.locked-by-others>[data-type=block-content]:after{display:none}div.editor-root:not(.readonly) div[data-type=editor-block].table-block.locked-by-self>[data-type=block-content] div[data-type=table-content],div.editor-root:not(.readonly) div[data-type=editor-block].table-block.locked-by-others>[data-type=block-content] div[data-type=table-content]{position:relative}div.editor-root:not(.readonly) div[data-type=editor-block].table-block.locked-by-self>[data-type=block-content] div[data-type=table-content]:after,div.editor-root:not(.readonly) 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.editor-root:not(.readonly) div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-align=center] [data-type=block-content][data-content-placeholder]:before{justify-content:center}div.editor-root:not(.readonly) div.editor-content div[data-type=editor-container] div[data-type=editor-block][data-style-align=right] [data-type=block-content][data-content-placeholder]:before{justify-content:right}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:#c7c7c7}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:#c7c7c7;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}div.editor-root.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-readonly);color:#c7c7c7}.editor-root [data-type=editor-container].root div[data-type=editor-block].code-block{min-width:360px;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;white-space:pre}.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,.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.inputting-insertion{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;border:none;border-radius:2px;margin-left:4px;padding:0;background:none;outline:none;color:#c1c1c1}.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:not(.disabled){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:not(.disabled):hover{color:#5587f0}.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.disabled{cursor:not-allowed}.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[data-id=caption]{margin-right:4px}.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{height:24px;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-icon>svg{width:24px;height:24px}.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;border-radius: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].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:-4px;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}div.editor-root.readonly .container-blocks div[data-block-type=code] div[data-type=block-tools] .code-block-header .code-header-button[data-id=wrap],div.editor-root.readonly .container-blocks div[data-block-type=code] div[data-type=block-tools] .code-block-header .code-header-button[data-id=caption]{display:none}div.editor-root.readonly .container-blocks div[data-block-type=code] div[data-type=block-tools] .code-block-header .language-select{cursor:default!important}div.editor-root.readonly .container-blocks div[data-block-type=code] div[data-type=block-tools] .code-block-header .language-select .arrow-icon{display:none}div.editor-root div.editor-content div[data-type=editor-container].root.select-all div[data-type=block-content]>div.editor-code-root>div.code-text-root{background-color:unset}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}div.editor-root.readonly div.editor-content div[data-type=editor-block]>[data-type=block-tools] .block-resizer{display:none}.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].block-hidden{display:none}.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=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-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]:before{display:none}.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].selected [data-type=block-content] .images .image-container.active .image-warning{opacity:0;z-index:-1}.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;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 img{max-width:100%;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{display:flex;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{display:flex;flex:1;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{display:flex;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:#333;width:24px;height:24px;display:flex;align-items:center;justify-content:center;border-radius:3px;z-index:2;transition:opacity linear .2s;opacity:.7}.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;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-container.empty svg{width:48px;height:48px}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-tools] .drag-container{display:flex;box-sizing:content-box;pointer-events:none;position:fixed;z-index:100;background-color:#fff;border:1px solid #338FE5}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image] [data-type=block-tools] .drag-container .drag-target{width:100%}.editor-root[readonly=true] .image-splitter{visibility:hidden}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image].comment{box-shadow:none}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image].comment [data-type=block-content]{box-shadow:0 2px #f8e6ab}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image].comment.active{outline:none}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=image].comment.active [data-type=block-content]{box-shadow:none;outline:4px solid #f8e6ab}.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:5px;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].block-exclusive:after{content:attr(data-exclusive-tips);position:absolute;top:0px;left:0px;width:100%;background:#f8f8f8;border-radius:var(--editor-border-radius);white-space:nowrap;text-overflow:ellipsis;overflow:hidden;font-size:14px;line-height:22px;color:#909090;text-align:center;padding:9px 0;z-index:1000}.editor-root:not(.readonly) div[data-type=editor-block].locked-by-self>[data-type=block-content],.editor-root:not(.readonly) div[data-type=editor-block].locked-by-others>[data-type=block-content]{position:relative}.editor-root:not(.readonly) div[data-type=editor-block].locked-by-self>[data-type=block-content]:after,.editor-root:not(.readonly) div[data-type=editor-block].locked-by-others>[data-type=block-content]:after{content:" ";position:absolute;left:0;top:0;right:0;bottom:0;z-index:1;background-color:#303030;opacity:.1}.editor-root:not(.readonly) div[data-type=editor-block].locked-by-self.text-block>[data-type=block-content]:after,.editor-root:not(.readonly) div[data-type=editor-block].locked-by-self.locked-by-self>[data-type=block-content]:after,.editor-root:not(.readonly) div[data-type=editor-block].locked-by-others.text-block>[data-type=block-content]:after,.editor-root:not(.readonly) div[data-type=editor-block].locked-by-others.locked-by-self>[data-type=block-content]:after{pointer-events:none}.editor-root:not(.readonly) div[data-type=editor-block].locked-by-self.text-block>[data-type=block-content]:after,.editor-root:not(.readonly) 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.dragging *{cursor:grabbing!important}.editor-root .editor-content.dragging div[data-type=editor-block] iframe{pointer-events:none}.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;color:#909090}.drag-image-container{position:fixed;z-index:100;box-shadow:0 3px 20px #00000026;background-color:#fff;opacity:.4}.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: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}.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:5px;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-root .editor-root .editor-content>[data-type=editor-container].root>.container-blocks>*+*{margin-top:0}.comment-editor-img{float:right;color:#c1c1c1;padding:0;width:24px;height:24px;justify-content:center}.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-avatar-string{display:flex;align-items:center;justify-content:center;font-size:12px;color:#fff;background-color:var(--comment-avatar-color);flex-shrink:0}.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}.comment-item-root.readonly .item-head-tools{display:none}.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;--editor-comment-group-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{box-shadow:none}.editor-root .editor-content div[data-type=editor-block].text-block.comment>div[data-type=block-content]>span{border-bottom:2px solid #f8e6ab}.editor-root .editor-content div[data-type=editor-block].text-block.comment.active{box-shadow:none;outline:none}.editor-root .editor-content div[data-type=editor-block].text-block.comment.active>div[data-type=block-content] 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:#faf1d1}.editor-root .editor-content div[data-type=editor-block].comment{box-shadow:0 2px #f8e6ab}.editor-root .editor-content div[data-type=editor-block].comment.active{box-shadow:none;outline:4px solid #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%);background-color:var(--editor-comment-group-bg-color);border-radius:2px;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{box-sizing:content-box;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-web-comment-root .comment-groups-container .comment-group-item-root.readonly .comment-quick-reply{display:none}.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)}:is(.editor-web-comment-root,.editor-mobile-comments-root,.editor-mini-comment-root).hidden{display:none}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]{max-width:360px;min-width:360px;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;max-width:185px;display:flex;flex-direction:row;align-items:center;white-space:nowrap}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-details .file-name-pre{text-overflow:ellipsis;overflow:hidden}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{--editor-version-button-border: black;--editor-bg-color: #ffffff;--editor-version-list-bg-color: white;--editor-version-select-bg-color: #F8F8F8}.version-dialog{display:flex;background-color:var(--editor-bg-color);width:100%;height:100%;color:var(--editor-color)}.version-dialog *{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Oxygen,Ubuntu,Cantarell,Fira Sans,Droid Sans,Helvetica Neue,sans-serif;box-sizing:border-box}.version-dialog .version-item-latest{color:#338fe5;background-color:#eaf3fc;height:20px;padding:0 5px;border-radius:3px;display:inline-flex;align-items:center;font-size:12px;font-weight:400;margin-left:10px}.version-dialog .version-viewer{flex:1;display:flex;flex-direction:column;width:0;padding:0}.version-dialog .version-viewer .version-dialog-editor{flex-grow:1;overflow-y:auto}.version-dialog .version-viewer .version-info-container{height:50px;border-bottom:#E8E8E8 1px solid;display:flex;align-items:center;flex-shrink:0;padding-left:20px;font-size:14px;color:#303030}.version-dialog .version-viewer .version-info-container .version-info-right .text-3,.version-dialog .version-viewer .version-info-container .version-info-left .text-1,.version-dialog .version-viewer .version-info-container .version-info-left .text-2{color:#909090}.version-dialog .version-viewer .version-info-container .version-info-left .name{font-weight:500}.version-dialog .version-viewer .version-info-container .version-info-left .name .version-item-latest{margin-left:5px}.version-dialog .version-viewer .version-info-container .editor-dropdown{margin-left:10px;margin-right:10px}.version-dialog .version-viewer .version-info-container .command-item[data-id=current-version]{min-width:200px;border:1px solid #f0f0f0}.version-dialog .version-viewer .version-info-container .command-item[data-id=current-version] .toolbar-item-name-container{flex-grow:1}.version-dialog .version-viewer .dialog-button-text{margin-top:1px;margin-left:-4px}.version-dialog .version-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}.version-dialog .version-viewer .dialog-text-button .dialog-button-icon{margin-right:0;width:24px;height:24px}.version-dialog .version-viewer .dialog-text-button .dialog-button-icon svg{fill:currentColor}.editor-root.history .root-container .editor-block .text-element .inline-plugin.editor-box-loading{display:none}.editor-root.history .editor-content{padding:30px 75px}.editor-root.history .history-inserted-block[data-type=editor-block] [data-type=block-content]{border:4px solid var(--op-selected-color)}.editor-root.history .history-inserted-block[data-type=editor-block]{position:relative}.editor-root.history .history-inserted-block[data-type=editor-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-inserted-block[data-type=editor-block].table-block:hover:after{top:0}.editor-root.history .history-deleted-block [data-type=block-content]{border:4px solid var(--op-selected-color)}.editor-root.history .history-deleted-block [data-type=block-content]{position:relative}.editor-root.history .history-deleted-block [data-type=block-content]:after,.editor-root.history .history-deleted-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=block-content]:before{transform:rotate(135deg)}.editor-root.history .history-deleted-block{position:relative}.editor-root.history .history-deleted-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 .history-deleted-box{background-color:unset!important;text-decoration:unset!important}.editor-root.history .history-deleted-block .history-deleted-box:hover:after{opacity:0}.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}.editor-dialog-root{position:absolute;left:0;top:0;bottom:0;right:0;background-color:#639;z-index:100}.size-limit-textarea{display:inline-block;position:relative}.size-limit-textarea .size-limit-textarea-input{width:100%;resize:none;overflow:hidden;color:#303030;outline:none;border:1px solid #f0f0f0;border-radius:3px}.size-limit-textarea .size-limit-textarea-input:focus,.size-limit-textarea .size-limit-textarea-input:hover{border-color:#338fe5}.size-limit-textarea .size-limit-textarea-input:focus{box-shadow:0 0 0 2px #338fe533}.size-limit-textarea .size-limit-textarea-warning{position:absolute;right:0;bottom:10px;color:#909090;z-index:1;font-size:12px;pointer-events:none}.version-list-root{width:320px;background:var(--editor-version-list-bg-color);overflow-y:auto;padding:0;border-left:#E8E8E8 1px solid;display:flex;flex-direction:column}.version-list-root .version-list-header{padding:0 20px;font-size:14px;display:flex;align-items:center;margin-top:8px;margin-bottom:8px;flex-shrink:0;color:#909090}.version-list-root .version-list-header .version-count{flex-grow:1}.version-list-root .version-list-empty{height:100%;display:flex;align-items:center;justify-content:center;font-size:14px;color:#909090}.version-list-root .version-list-content{flex-grow:1;overflow-y:auto}.version-list-root .version-list-content .version-item{padding:15px 10px;cursor:pointer}.version-list-root .version-list-content .version-item.child{padding-left:32px}.version-list-root .version-list-content .version-item:not(.active):hover{background:rgba(112,132,164,.1)}.version-list-root .version-list-content .version-item.active{background-color:var(--editor-version-select-bg-color)}.version-list-root .version-list-content .version-item.active .version-item-title .version-actions{display:flex}.version-list-root .version-list-content .version-item.editing .version-item-memo{display:none}.version-list-root .version-list-content .version-item.active .version-item-memo{cursor:text}.version-list-root .version-list-content .version-item.active .version-item-memo:hover{outline:1px solid #338FE5}.version-list-root .version-list-content .version-item .version-item-restore-from{color:#909090;font-size:12px;line-height:1.5em;height:20px;padding:0 10px 10px}.version-list-root .version-list-content .version-item .version-item-restore-from:empty{display:none}.version-list-root .version-list-content .version-item .memo-input.size-limit-textarea{width:100%;min-height:60px}.version-list-root .version-list-content .version-item .memo-input.size-limit-textarea textarea{padding:5px 10px 10px;box-sizing:border-box;font-size:14px}.version-list-root .version-list-content .version-item .version-item-title{display:flex;align-items:center;padding-bottom:10px;padding-left:10px;padding-right:10px;height:24px}.version-list-root .version-list-content .version-item .version-item-title .version-item-date{font-size:14px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden;color:#303030}.version-list-root .version-list-content .version-item .version-item-title .spacer{flex-grow:1}.version-list-root .version-list-content .version-item .version-item-title .version-actions{display:none}.version-list-root .version-list-content .version-item .version-item-title .version-actions button{display:flex;align-items:center;justify-content:center;height:16px;cursor:pointer;border:none;outline:none;background:transparent;padding:0 0 0 5px;color:#909090}.version-list-root .version-list-content .version-item .version-item-title .version-actions button:hover{color:#338fe5}.version-list-root .version-list-content .version-item .version-item-title .version-actions button.disabled,.version-list-root .version-list-content .version-item .version-item-title .version-actions button.disabled:hover{color:#c7c7c7}.version-list-root .version-list-content .version-item .version-item-title .version-actions .revert-button{border-left:1px solid #E8E8E8;margin-left:5px}.version-list-root .version-list-content .version-item .version-item-authors{list-style:none;margin:0;font-size:12px;padding-left:10px}.version-list-root .version-list-content .version-item .version-item-author{display:flex;align-items:center;margin-top:10px;color:#606060}.version-list-root .version-list-content .version-item .version-item-author-mark{width:6px;height:6px;border-radius:3px;margin-right:5px}.version-list-root .version-list-content .version-item .version-item-memo{font-size:14px;color:#303030;padding:5px 10px 10px;border-radius:3px}.version-list-root .version-list-content .version-item .version-item-memo:empty{display:none}.versions-dropdown-header{color:var(--text-color);padding:10px;border-bottom:1px solid #f0f0f0}.versions-dropdown-header .versions-dropdown-header-info{color:#909090}.versions-dropdown-header .versions-dropdown-header-icon{vertical-align:middle;padding-left:5px;padding-right:5px;cursor:pointer;color:#909090}.editor-command-bar.menu .command-item.standard[data-id=prev-version]{height:44px}[data-command-bar-id=versions-dropdown-popup]{width:320px}[data-command-bar-id=versions-dropdown-popup] .tippy-box{color:var(--text-color)}[data-command-bar-id=versions-dropdown-popup] .tippy-box .version-item-empty{width:100%}[data-command-bar-id=versions-dropdown-popup] .tippy-box .version-item-name{color:var(--text-color)}[data-command-bar-id=versions-dropdown-popup] .tippy-box .editor-command-bar.menu .command-item.standard.disabled{color:#909090}[data-command-bar-id=versions-dropdown-popup] .tippy-box .editor-command-bar{--text-color: #303030}[data-command-bar-id=versions-dropdown-popup] *{box-sizing:border-box}[data-command-bar-id=versions-dropdown-popup] .editor-command-bar-header{width:100%;margin-bottom:5px}[data-command-bar-id=versions-dropdown-popup] .command-item{width:100%;cursor:pointer}[data-command-bar-id=versions-dropdown-popup] .command-item .version-item-container{padding:6px 10px;width:100%}[data-command-bar-id=versions-dropdown-popup] .command-item .version-item-container .version-item-memo{font-size:12px;color:#909090;line-height:20px;white-space:nowrap;text-overflow:ellipsis;overflow:hidden}[data-command-bar-id=versions-dropdown-popup] .command-item .version-item-container .version-item-line1{line-height:22px;display:flex;align-items:center;text-overflow:ellipsis;overflow:hidden;white-space:nowrap}[data-command-bar-id=versions-dropdown-popup] .command-item .version-item-container .version-item-line1 .version-item-latest{color:#338fe5;background-color:#eaf3fc;height:20px;padding:0 5px;margin-left:10px;border-radius:3px;font-size:12px;display:inline-flex;align-items:center}[data-command-bar-id=versions-dropdown-popup] .command-item .version-item-empty{display:flex;height:34px;color:#909090;padding-left:10px;justify-content:left;align-items:center}[data-command-bar-id=versions-dropdown-popup] .command-item .filter-memoed-version-item{width:100%}[data-command-bar-id=versions-dropdown-popup] .command-item .filter-memoed-version-item .filter-item-info{height:24px;color:#909090;display:flex;align-items:center;padding-left:10px;background-color:#f8f8f8;width:100%;box-sizing:border-box;margin:5px 0}[data-command-bar-id=versions-dropdown-popup] .command-item .filter-memoed-version-item .filter-item-input-container{height:34px;display:flex;align-items:center;padding-left:10px;color:#303030}[data-command-bar-id=versions-dropdown-popup] .command-item .filter-memoed-version-item .filter-item-input-container .filter-item-input{position:relative;top:-2px;left:-2px;cursor:pointer;accent-color:#338FE5}[data-command-bar-id=versions-dropdown-popup] .command-item .filter-memoed-version-item .filter-item-input-container .filter-item-label{user-select:none;cursor:pointer;line-height:1em}.editor-root.readonly .editor-content div[data-type=editor-block].focused div[data-type=block-tools] .block-helper .heading-marker,.editor-root.readonly .editor-content div[data-type=editor-block].highlighted div[data-type=block-tools] .block-helper .heading-marker{display:flex}.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:20px;height:20px;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%}[data-command-bar-id=editor-mention] .editor-command-bar.menu .command-item.menu-item .menu-item-icon .mention-user-avatar-string{align-items:center;display:flex;justify-content:center;overflow:hidden;height:100%;width:100%;font-size:12px;color:#fff;flex-shrink:0}[data-command-bar-id=editor-mention] .editor-command-bar.menu .command-item.menu-item .menu-item-name{flex-grow:0;margin-right:5px}.editor-root .editor-templates{position:fixed;bottom:26px;height:256px;width:auto;max-width:100%;padding-left:30px;padding-right:44px;overflow:hidden}.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;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{display:flex;align-items:center;height:40px;width:100%;border-top:1px solid #dedede;padding-left:20px;padding-right:20px;flex:0 0 50px;font-size:14px;font-weight:500;line-height:22px;color:#303030}.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{border-top:none}.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;padding:16px 39px 14px}.editor-root .editor-templates .editor-templates-cards .editor-template-card.more .editor-template-thumb-container>img{width:110px;height:112px;max-width:revert}.editor-root .editor-templates .editor-templates-cards .editor-template-card .editor-template-thumb-container{flex:1;position:relative;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%}:root div[data-command-bar-id=webpage]>div.tippy-box{max-width:500px}:root div[data-command-bar-id=webpage]>div.tippy-box div.tippy-content{width:500px;padding:0}.editor-dialog-container{width:500px}.editor-dialog-container .dialog-header{display:flex;flex-direction:row;align-items:center;justify-content:space-between;padding:0 20px;height:50px;border-bottom:1px solid #e8e8e8;margin-bottom:20px}.editor-dialog-container .dialog-header .close-icon{display:flex;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:0 20px 20px;border-bottom:1px solid #e8e8e8}.editor-dialog-container .dialog-footer{margin:10px 0;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}.editor-disable-scroll.editor-disable-scroll-dark{background-color:#00000080}.embed-block[data-embed-type=webpage]{height:400px;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]>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{display:flex;align-items:center;height:20px;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 div.editor-content div[data-type=editor-container].root.select-all>.container-blocks>div[data-type=editor-block][data-embed-type=webpage]>div[data-type=block-content]:before{display:block}: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:1000}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}.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%;max-height:100%}.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[data-embed-type=mermaid] div[data-type=block-content] .graph-embed,.embed-block[data-embed-type=flowchart] div[data-type=block-content] .graph-embed,.embed-block[data-embed-type=plantuml] div[data-type=block-content] .graph-embed,.embed-block[data-embed-type=mermaid] div[data-type=block-content] .invalid-code:not(.empty-embed),.embed-block[data-embed-type=flowchart] div[data-type=block-content] .invalid-code:not(.empty-embed),.embed-block[data-embed-type=plantuml] div[data-type=block-content] .invalid-code:not(.empty-embed),.embed-block[data-embed-type=mermaid] div[data-type=block-content] .empty-embed:after,.embed-block[data-embed-type=flowchart] div[data-type=block-content] .empty-embed:after,.embed-block[data-embed-type=plantuml] div[data-type=block-content] .empty-embed:after,.embed-block[data-embed-type=mermaid],.embed-block[data-embed-type=flowchart],.embed-block[data-embed-type=plantuml]{display:flex;flex-direction:row;align-items:center;justify-content:center}.embed-block[data-embed-type=mermaid] div[data-type=block-content],.embed-block[data-embed-type=flowchart] div[data-type=block-content],.embed-block[data-embed-type=plantuml] div[data-type=block-content]{width:100%;position:relative;border:1px solid #e5e5e5;border-radius:3px}.embed-block[data-embed-type=mermaid] div[data-type=block-content] .empty-embed,.embed-block[data-embed-type=flowchart] div[data-type=block-content] .empty-embed,.embed-block[data-embed-type=plantuml] div[data-type=block-content] .empty-embed{width:100%;min-height:106px;background-color:#cdcdcd40}.embed-block[data-embed-type=mermaid] div[data-type=block-content] .empty-embed:after,.embed-block[data-embed-type=flowchart] div[data-type=block-content] .empty-embed:after,.embed-block[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[data-embed-type=mermaid] div[data-type=block-content] .invalid-code:not(.empty-embed),.embed-block[data-embed-type=flowchart] div[data-type=block-content] .invalid-code:not(.empty-embed),.embed-block[data-embed-type=plantuml] div[data-type=block-content] .invalid-code:not(.empty-embed){width:100%;height:100px}.embed-block[data-embed-type=mermaid] div[data-type=block-content] .invalid-code:not(.empty-embed) img,.embed-block[data-embed-type=flowchart] div[data-type=block-content] .invalid-code:not(.empty-embed) img,.embed-block[data-embed-type=plantuml] div[data-type=block-content] .invalid-code:not(.empty-embed) img{display:none}.embed-block[data-embed-type=mermaid] div[data-type=block-content] .invalid-code:not(.empty-embed):after,.embed-block[data-embed-type=flowchart] div[data-type=block-content] .invalid-code:not(.empty-embed):after,.embed-block[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[data-embed-type=mermaid] div[data-type=block-content] .embed-img-content,.embed-block[data-embed-type=flowchart] div[data-type=block-content] .embed-img-content,.embed-block[data-embed-type=plantuml] div[data-type=block-content] .embed-img-content{width:100%;text-align:center}.embed-block[data-embed-type=mermaid] div[data-type=block-content] .mermaid-embed-img,.embed-block[data-embed-type=flowchart] div[data-type=block-content] .mermaid-embed-img,.embed-block[data-embed-type=plantuml] div[data-type=block-content] .mermaid-embed-img{max-width:100%;min-width:200px}.embed-block[data-embed-type=mermaid] div[data-type=block-content] .editor-plantuml-img,.embed-block[data-embed-type=flowchart] div[data-type=block-content] .editor-plantuml-img,.embed-block[data-embed-type=plantuml] div[data-type=block-content] .editor-plantuml-img{max-width:100%}.embed-block[data-embed-type=mermaid] div[data-type=block-content] .embed-graph-img-content,.embed-block[data-embed-type=flowchart] div[data-type=block-content] .embed-graph-img-content,.embed-block[data-embed-type=plantuml] div[data-type=block-content] .embed-graph-img-content{width:100%;text-align:center;padding:10px}.embed-block[data-embed-type=mermaid] div[data-type=block-content] .embed-graph-img-content img,.embed-block[data-embed-type=flowchart] div[data-type=block-content] .embed-graph-img-content img,.embed-block[data-embed-type=plantuml] div[data-type=block-content] .embed-graph-img-content img{max-width:100%}.embed-block[data-embed-type=mermaid] div[data-type=block-content] .graph-embed,.embed-block[data-embed-type=flowchart] div[data-type=block-content] .graph-embed,.embed-block[data-embed-type=plantuml] div[data-type=block-content] .graph-embed{width:100%}.hr-transition,.embed-block[data-type=editor-block][data-embed-type=hr] div[data-type=block-content] .editor-embed-container .editor-embed-hr{transition:border-top ease-in-out .4s}.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]: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{display:flex;align-items:center;width:100%;height:24px}.embed-block[data-type=editor-block][data-embed-type=hr] 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[data-type=editor-block][data-embed-type=hr] div[data-type=block-tools]>div.block-helper{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=audio]>div[data-type=block-content] .media-empty .media-error-icon,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-error .media-error-icon{display:flex}.editor-root .editor-content div[data-type=editor-block].embed-block.media-block-uploading div[data-type=block-tools] .block-helper{display:none}.embed-block[data-embed-type=video]{display:flex}.embed-block[data-embed-type=video][data-style-align=left]>div[data-type=block-content]{justify-content:flex-start}.embed-block[data-embed-type=video][data-style-align=center]>div[data-type=block-content]{justify-content:center}.embed-block[data-embed-type=video][data-style-align=right]>div[data-type=block-content]{justify-content:flex-end}.embed-block[data-embed-type=video]>div[data-type=block-content]{border:none}.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]>div[data-type=block-content] .media-empty .media-error-icon,.embed-block[data-embed-type=video]>div[data-type=block-content] .media-error .media-error-icon{display:flex}.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].selected>div[data-type=block-content]:before,.embed-block[data-embed-type=audio].selected>div[data-type=block-content]:before{display:none}.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;width:100%}.embed-block[data-embed-type=video]>div[data-type=block-content] .media.full-screen,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media.full-screen{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{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;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 .retry-upload,.embed-block[data-embed-type=audio]>div[data-type=block-content] .media-error .retry-upload{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%}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=video].comment,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=audio].comment{box-shadow:none}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=video].comment .media,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=audio].comment .media{box-shadow:0 2px #f8e6ab}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=video].comment.active,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=audio].comment.active{outline:none}.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=video].comment.active .media,.editor-root div.editor-content div[data-type=editor-container] .embed-block[data-type=editor-block][data-embed-type=audio].comment.active .media{box-shadow:none;outline:4px solid #f8e6ab}.editor-root:not(.readonly) .embed-block[data-embed-type=video].locked-by-self>[data-type=block-content]:after,.editor-root:not(.readonly) .embed-block[data-embed-type=video].locked-by-others>[data-type=block-content]:after,.editor-root:not(.readonly) .embed-block[data-embed-type=audio].locked-by-self>[data-type=block-content]:after,.editor-root:not(.readonly) .embed-block[data-embed-type=audio].locked-by-others>[data-type=block-content]:after{display:none}.editor-root:not(.readonly) .embed-block[data-embed-type=video].locked-by-self>[data-type=block-content] .media,.editor-root:not(.readonly) .embed-block[data-embed-type=video].locked-by-others>[data-type=block-content] .media,.editor-root:not(.readonly) .embed-block[data-embed-type=audio].locked-by-self>[data-type=block-content] .media,.editor-root:not(.readonly) .embed-block[data-embed-type=audio].locked-by-others>[data-type=block-content] .media{position:relative}.editor-root:not(.readonly) .embed-block[data-embed-type=video].locked-by-self>[data-type=block-content] .media:after,.editor-root:not(.readonly) .embed-block[data-embed-type=video].locked-by-others>[data-type=block-content] .media:after,.editor-root:not(.readonly) .embed-block[data-embed-type=audio].locked-by-self>[data-type=block-content] .media:after,.editor-root:not(.readonly) .embed-block[data-embed-type=audio].locked-by-others>[data-type=block-content] .media:after{content:" ";position:absolute;left:0;top:0;right:0;bottom:0;pointer-events:none;z-index:1;background-color:#303030;opacity:.1}`)),document.head.appendChild(t)}}catch(o){console.error("vite-plugin-css-injected-by-js",o)}})();
2
- (function(b,Hn){typeof exports=="object"&&typeof module<"u"?Hn(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("@guyplusplus/turndown-plugin-gfm"),require("turndown"),require("marked"),require("@better-scroll/core"),require("plantuml-encoder"),require("docx")):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","@guyplusplus/turndown-plugin-gfm","turndown","marked","@better-scroll/core","plantuml-encoder","docx"],Hn):(b=typeof globalThis<"u"?globalThis:b||self,Hn(b["oneseditor-editor"]={},b.KiwiIntl,b.merge,b.stringFormat,b.nanoid$1,b.events,b.queryString,b.jsBase64,b.snabbdom,b.cloneDeep,b.isEqual,b.Delta,b.tinyTypedEmitter,b.intersection,b.json1,b.axios,b.findLastIndex,b.ReconnectingWebSocket,b.sha256,b.debounce,b.tippy$1,b.md5,b.cssColorConverter,b.markmap,b.throttle,b.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,b.mime,b.domToImage,b.turndownPluginGfm,b.TurndownService,b.marked,b.BetterScroll,b.plantumlEncoder,b.docx))})(this,function(b,Hn,Cs,fB,mB,W5,gB,aa,xi,pB,CB,AB,bt,bB,vB,yB,kB,wB,BB,EB,um,xB,dm,IB,TB,DB,$ee,Hee,jee,Uee,zee,Vee,Wee,qee,Gee,Zee,Qee,Yee,Jee,Kee,Xee,ete,tte,nte,ote,rte,ite,ste,lte,cte,ate,ute,dte,hte,fte,mte,gte,pte,Cte,Ate,bte,vte,yte,kte,wte,Bte,Ete,xte,Ite,Tte,Dte,Ste,Lte,Mte,Rte,Ote,_te,Fte,Pte,Nte,$te,Hte,jte,Ute,zte,Vte,Wte,qte,Gte,Zte,Qte,Yte,Jte,Kte,SB,LB,MB,RB,q5,OB,_B,ge){"use strict";var Pee=Object.defineProperty;var Nee=(b,Hn,Cs)=>Hn in b?Pee(b,Hn,{enumerable:!0,configurable:!0,writable:!0,value:Cs}):b[Hn]=Cs;var m=(b,Hn,Cs)=>(Nee(b,typeof Hn!="symbol"?Hn+"":Hn,Cs),Cs);const xt=n=>n&&typeof n=="object"&&"default"in n?n:{default:n};function _d(n){if(n&&n.__esModule)return n;const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,o.get?o:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const FB=xt(Hn),hm=xt(Cs),PB=xt(fB),G5=xt(W5),me=xt(pB),ua=xt(CB),on=xt(AB),fm=xt(bB),Fd=_d(vB),NB=xt(yB),$B=xt(kB),HB=xt(wB),jB=_d(BB),Ht=xt(EB),UB=xt(um),zB=_d(um),Pd=xt(xB),VB=_d(IB),WB=xt(TB),da=xt(DB),mm=xt(SB),Z5=xt(LB),qB=xt(RB),Q5=xt(OB),GB=xt(_B);function ZB(n){const e=o=>o<10?`0${String(o)}`:String(o),t=o=>o<10?`00${String(o)}`:o<100?`0${String(o)}`:String(o);return`${n.getFullYear()}-${e(n.getMonth()+1)}-${e(n.getDate())} ${e(n.getHours())}:${e(n.getMinutes())}:${e(n.getSeconds())}.${t(n.getMilliseconds())}`}var ha=(n=>(n.DEBUG="DEBUG",n.INFO="INFO ",n.WARN="WARN ",n.ERROR="ERROR",n))(ha||{});const Y5=new Map,Fc=class{constructor(e){m(this,"times",new Map);this.category=e}shouldLog(e){const t=Object.values(ha).indexOf(e),o=Object.values(ha).indexOf(Fc.level);return t>=o}_log(e,t,o,r){var B;if(!this.shouldLog(e))return;const i=typeof process>"u"?{}:process;let s="";if(typeof t=="object")try{s="message"in t?t.message:JSON.stringify(t,null,4)}catch{s=""}else typeof t=="string"?t&&(s=t):s=JSON.stringify(t);s=r?`${s} - ${r}`:s;const l=`${this.category}`;let a=console.log;e==="WARN "&&(a=console.warn),e==="ERROR"&&(a=console.error);const d=`${ZB(new Date)}`,h=e,p=l,A=Fc.extParams?"[{date}] {level}: [{module} {extParams}] - {msg}":"[{date}] {level}: [{module}] - {msg}",v=[PB.default(((B=i.env)==null?void 0:B.LOG_TEMPLATE)||A,{date:d,level:h,module:p,msg:s,extParams:Fc.extParams})];if(typeof t=="object"){const D=t.stack;D&&v.push(D)}if(a===console.error&&Fc.debugMode){const D=new Error().stack;D&&v.push(D)}a(...v),o&&this._log(e,o)}log(e,t){this._log("INFO ",e,void 0,t)}debug(e,t){this._log("DEBUG",e,void 0,t)}info(e,t){this._log("INFO ",e,void 0,t)}warn(e,t,o){this._log("WARN ",e,t,o)}error(e,t,o){this._log("ERROR",e,t,o)}time(e){this.times.set(e,Date.now())}timeEnd(e){this.timeLog(e),this.times.delete(e)}timeLog(e){const t=this.times.get(e);if(!t){this.warn(`no time label: ${e}`);return}this.debug(`${e}: ${Date.now()-t}`)}static setExtParams(e){this.extParams=e}};let Ii=Fc;m(Ii,"debugMode",!1),m(Ii,"level","DEBUG"),m(Ii,"extParams","");function S(n){const e=Y5.get(n);if(e)return e;const t=new Ii(n);return Y5.set(n,t),t}const QB={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"},docx:{imageExportFailed:"Failed to load image"}},YB={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"},docx:{imageExportFailed:"\u56FE\u7247\u52A0\u8F7D\u5931\u8D25"}},JB={name:"Ones Editor",date:{dateFromFuture:"\u672A\u6765\u304B\u3089",dateJustNow:"\u305F\u3060\u4ECA",dateYesterday:"\u6628\u65E5",dateMinutesAgo:"{num}\u5206\u524D",date1HourAgo:"1\u6642\u9593\u524D",dateHoursAgo:"{num}\u6642\u9593\u524D",dateDaysAgo:"{num}\u65E5\u524D",dateWeeksAgo:"{num}\u9031\u524D"},common:{cancel:"\u30AD\u30E3\u30F3\u30BB\u30EB"},docx:{imageExportFailed:"\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F"}},KB=S("i18n"),XB={"en-US":QB,"zh-CN":YB,"ja-JP":JB},Nd=FB.default.init("en-US",XB);function eE(n=void 0){Nd.setLang&&Nd.setLang(n||"en-US")}function tE(n){hm.default(Nd.__metas__,n)}function nE(n,e){const t=Nd.get(n,e);return t===n&&KB.warn(`no locale value for key ${n}`),t}const R=Object.freeze(Object.defineProperty({__proto__:null,setLang:eE,mergeLang:tE,t:nE},Symbol.toStringTag,{value:"Module"})),Xte="";class J5{constructor(e,t){this.editor=e,this.data=t}getData(){return this.data}getEditor(){return this.editor}destroy(){}}class oE extends Error{constructor(e){if(super(e),this.code="Assert",this.stack){const t=this.stack.split(`
2
+ (function(b,Hn){typeof exports=="object"&&typeof module<"u"?Hn(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("@guyplusplus/turndown-plugin-gfm"),require("turndown"),require("marked"),require("@better-scroll/core"),require("plantuml-encoder"),require("docx")):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","@guyplusplus/turndown-plugin-gfm","turndown","marked","@better-scroll/core","plantuml-encoder","docx"],Hn):(b=typeof globalThis<"u"?globalThis:b||self,Hn(b["oneseditor-editor"]={},b.KiwiIntl,b.merge,b.stringFormat,b.nanoid$1,b.events,b.queryString,b.jsBase64,b.snabbdom,b.cloneDeep,b.isEqual,b.Delta,b.tinyTypedEmitter,b.intersection,b.json1,b.axios,b.findLastIndex,b.ReconnectingWebSocket,b.sha256,b.debounce,b.tippy$1,b.md5,b.cssColorConverter,b.markmap,b.throttle,b.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,b.mime,b.domToImage,b.turndownPluginGfm,b.TurndownService,b.marked,b.BetterScroll,b.plantumlEncoder,b.docx))})(this,function(b,Hn,Cs,fB,mB,W5,gB,aa,xi,pB,CB,AB,bt,bB,vB,yB,kB,wB,BB,EB,um,xB,dm,IB,TB,DB,$ee,Hee,jee,Uee,zee,Vee,Wee,qee,Gee,Zee,Qee,Yee,Jee,Kee,Xee,ete,tte,nte,ote,rte,ite,ste,lte,cte,ate,ute,dte,hte,fte,mte,gte,pte,Cte,Ate,bte,vte,yte,kte,wte,Bte,Ete,xte,Ite,Tte,Dte,Ste,Lte,Mte,Rte,Ote,_te,Fte,Pte,Nte,$te,Hte,jte,Ute,zte,Vte,Wte,qte,Gte,Zte,Qte,Yte,Jte,Kte,SB,LB,MB,RB,q5,OB,_B,ge){"use strict";var Pee=Object.defineProperty;var Nee=(b,Hn,Cs)=>Hn in b?Pee(b,Hn,{enumerable:!0,configurable:!0,writable:!0,value:Cs}):b[Hn]=Cs;var m=(b,Hn,Cs)=>(Nee(b,typeof Hn!="symbol"?Hn+"":Hn,Cs),Cs);const xt=n=>n&&typeof n=="object"&&"default"in n?n:{default:n};function _d(n){if(n&&n.__esModule)return n;const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(n){for(const t in n)if(t!=="default"){const o=Object.getOwnPropertyDescriptor(n,t);Object.defineProperty(e,t,o.get?o:{enumerable:!0,get:()=>n[t]})}}return e.default=n,Object.freeze(e)}const FB=xt(Hn),hm=xt(Cs),PB=xt(fB),G5=xt(W5),me=xt(pB),ua=xt(CB),on=xt(AB),fm=xt(bB),Fd=_d(vB),NB=xt(yB),$B=xt(kB),HB=xt(wB),jB=_d(BB),Ht=xt(EB),UB=xt(um),zB=_d(um),Pd=xt(xB),VB=_d(IB),WB=xt(TB),da=xt(DB),mm=xt(SB),Z5=xt(LB),qB=xt(RB),Q5=xt(OB),GB=xt(_B);function ZB(n){const e=o=>o<10?`0${String(o)}`:String(o),t=o=>o<10?`00${String(o)}`:o<100?`0${String(o)}`:String(o);return`${n.getFullYear()}-${e(n.getMonth()+1)}-${e(n.getDate())} ${e(n.getHours())}:${e(n.getMinutes())}:${e(n.getSeconds())}.${t(n.getMilliseconds())}`}var ha=(n=>(n.DEBUG="DEBUG",n.INFO="INFO ",n.WARN="WARN ",n.ERROR="ERROR",n))(ha||{});const Y5=new Map,Fc=class{constructor(e){m(this,"times",new Map);this.category=e}shouldLog(e){const t=Object.values(ha).indexOf(e),o=Object.values(ha).indexOf(Fc.level);return t>=o}_log(e,t,o,r){var B;if(!this.shouldLog(e))return;const i=typeof process>"u"?{}:process;let s="";if(typeof t=="object")try{s="message"in t?t.message:JSON.stringify(t,null,4)}catch{s=""}else typeof t=="string"?t&&(s=t):s=JSON.stringify(t);s=r?`${s} - ${r}`:s;const l=`${this.category}`;let a=console.log;e==="WARN "&&(a=console.warn),e==="ERROR"&&(a=console.error);const d=`${ZB(new Date)}`,h=e,p=l,A=Fc.extParams?"[{date}] {level}: [{module} {extParams}] - {msg}":"[{date}] {level}: [{module}] - {msg}",v=[PB.default(((B=i.env)==null?void 0:B.LOG_TEMPLATE)||A,{date:d,level:h,module:p,msg:s,extParams:Fc.extParams})];if(typeof t=="object"){const D=t.stack;D&&v.push(D)}if(a===console.error&&Fc.debugMode){const D=new Error().stack;D&&v.push(D)}a(...v),o&&this._log(e,o)}log(e,t){this._log("INFO ",e,void 0,t)}debug(e,t){this._log("DEBUG",e,void 0,t)}info(e,t){this._log("INFO ",e,void 0,t)}warn(e,t,o){this._log("WARN ",e,t,o)}error(e,t,o){this._log("ERROR",e,t,o)}time(e){this.times.set(e,Date.now())}timeEnd(e){this.timeLog(e),this.times.delete(e)}timeLog(e){const t=this.times.get(e);if(!t){this.warn(`no time label: ${e}`);return}this.debug(`${e}: ${Date.now()-t}`)}static setExtParams(e){this.extParams=e}};let Ii=Fc;m(Ii,"debugMode",!1),m(Ii,"level","DEBUG"),m(Ii,"extParams","");function S(n){const e=Y5.get(n);if(e)return e;const t=new Ii(n);return Y5.set(n,t),t}const QB={name:"ONES Editor",date:{dateFromFuture:"From the 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"},docx:{imageExportFailed:"Failed to load image"}},YB={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"},docx:{imageExportFailed:"\u56FE\u7247\u52A0\u8F7D\u5931\u8D25"}},JB={name:"ONES \u30A8\u30C7\u30A3\u30BF\u30FC",date:{dateFromFuture:"\u672A\u6765\u304B\u3089",dateJustNow:"\u305F\u3060\u4ECA",dateYesterday:"\u6628\u65E5",dateMinutesAgo:"{num}\u5206\u524D",date1HourAgo:"1\u6642\u9593\u524D",dateHoursAgo:"{num}\u6642\u9593\u524D",dateDaysAgo:"{num}\u65E5\u524D",dateWeeksAgo:"{num}\u9031\u524D"},common:{cancel:"\u30AD\u30E3\u30F3\u30BB\u30EB"},docx:{imageExportFailed:"\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F"}},KB=S("i18n"),XB={"en-US":QB,"zh-CN":YB,"ja-JP":JB},Nd=FB.default.init("en-US",XB);function eE(n=void 0){Nd.setLang&&Nd.setLang(n||"en-US")}function tE(n){hm.default(Nd.__metas__,n)}function nE(n,e){const t=Nd.get(n,e);return t===n&&KB.warn(`no locale value for key ${n}`),t}const R=Object.freeze(Object.defineProperty({__proto__:null,setLang:eE,mergeLang:tE,t:nE},Symbol.toStringTag,{value:"Module"})),Xte="";class J5{constructor(e,t){this.editor=e,this.data=t}getData(){return this.data}getEditor(){return this.editor}destroy(){}}class oE extends Error{constructor(e){if(super(e),this.code="Assert",this.stack){const t=this.stack.split(`
3
3
  `);if(t.length>1)if(this.lineNumber&&this.columnNumber){const o=t[1].match(/(.*)@(.*):(\d+):(\d+)/);o&&(this.lineNumber=+o[3],this.columnNumber=+o[4],this.fileName=o[2]),t.splice(0,1)}else t.splice(1,1);this.stack=t.join(`
4
4
  `)}}}function g(n,e,t){if(!e)throw n.error(`assert failed: ${t}`),new oE(t)}const rE=mB.customAlphabet("1234567890abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_",8),K5="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";function iE(){return K5[Date.now()%K5.length]}const K=()=>`${iE()}${rE()}`;class X5 extends G5.default.EventEmitter{constructor(t=60){super();m(this,"cache",new Map);m(this,"expiredSeconds");this.expiredSeconds=t,this.startAutoClear()}delete(t){const o=this.cache.get(t);o&&this.emit("delete",o.data),this.cache.delete(t)}getSync(t,o){const r=this.cache.get(t),i=Date.now();if(r&&(i-r.lastRead)/1e3<this.expiredSeconds)return r.lastRead=i,r.data;const s=o(t);return this.cache.set(t,{lastRead:i,data:s}),s}async get(t,o){const r=this.cache.get(t),i=Date.now();if(r&&(i-r.lastRead)/1e3<this.expiredSeconds)return r.lastRead=i,r.data;const s=await o(t);return this.cache.set(t,{lastRead:i,data:s}),s}startAutoClear(){setInterval(()=>{const t=Date.now();Array.from(this.cache.entries()).forEach(([o,r])=>{(t-r.lastRead)/1e3>this.expiredSeconds&&this.delete(o)})},10*1e3)}}class fa{constructor(){m(this,"_callbacks",new Set)}get callbacks(){return Array.from(this._callbacks)}registerCallback(e){this._callbacks.add(e)}unregisterCallback(e){this._callbacks.delete(e)}clearCallbacks(){this._callbacks.clear()}}const sE=S("await-locker");class lE{constructor(){m(this,"_acquired",!1);m(this,"_waitingResolvers",[]);this._acquired=!1,this._waitingResolvers=[]}acquireAsync(e){return this._acquired?new Promise((t,o)=>{this._waitingResolvers.push(t),e&&e>0&&setTimeout(()=>{const r=this._waitingResolvers.indexOf(t);if(r!==-1){this._waitingResolvers.splice(r,1);const i=new Error(`lock timeout: ${e}, waiting resolves: ${this._waitingResolvers.length}`);o(i)}},e)}):(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 e=this._waitingResolvers.shift();g(sE,e,"Resolver missing"),e(void 0)}else this._acquired=!1}acquired(){return this._acquired}debug(){const e=this._waitingResolvers.length;return console.log(`waiting resolves: ${e}`),{waitingCount:e}}}class cE{constructor(){m(this,"_map");this._map=new Map}getLocker(e){let t=this._map.get(e);return t||(t=new lE,this._map.set(e,t)),t}async lock(e,t){await this.getLocker(e).acquireAsync(t)}release(e){this.getLocker(e).release()}remove(e){this.isLocking(e)||this._map.delete(e)}isLocking(e){return this._map.has(e)?this.getLocker(e).acquired():!1}}const wo=new cE;/**
5
5
  * @name string-character-is-astral-surrogate
@@ -24,7 +24,7 @@ Available method signatures are:
24
24
  `:""}const m6={boxType:"br",updateBoxContent:FI,convertTo:PI},g6=S("editor-boxes");class p6{constructor(e){m(this,"boxes",new Map);this.editor=e}registerBoxClass(e){const t=e.boxType,o=this.boxes.get(t);g(g6,!o,`duplicated box type: ${t}`),this.boxes.set(t,e)}getBoxClass(e){const t=this.boxes.get(e);return g(g6,t,`unknown box type: ${e}`),t}createBox(e,t){const o=WC(t),r=GC(o);return this.getBoxClass(t.type).updateBoxContent(this.editor,o,r,t),o}}function NI(n,e,t,o){const r=o,{width:i,height:s,src:l}=r,a=["editor-box-image"];r.link&&a.push("editor-box-image-link");const d=w("img",a,t);i&&(d.style.width=`${i}px`),s&&(d.style.height=`${s}px`),d.src=n.doc.buildResourceUrl(l)}const C6={boxType:"image",updateBoxContent:NI},$I="data:image/svg+xml;base64,Cjxzdmcgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiB2aWV3Qm94PSIwIDAgMjQgMjQiIGZpbGw9InJnYigxNzgsIDE4OCwgMjA1KSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0ibTE3IDE1IDEuNTUgMS41NWMtLjk2IDEuNjktMy4zMyAzLjA0LTUuNTUgMy4zN1YxMWgzVjloLTNWNy44MkMxNC4xNiA3LjQgMTUgNi4zIDE1IDVjMC0xLjY1LTEuMzUtMy0zLTNTOSAzLjM1IDkgNWMwIDEuMy44NCAyLjQgMiAyLjgyVjlIOHYyaDN2OC45MmMtMi4yMi0uMzMtNC41OS0xLjY4LTUuNTUtMy4zN0w3IDE1bC00LTN2M2MwIDMuODggNC45MiA3IDkgN3M5LTMuMTIgOS03di0zbC00IDN6TTEyIDRjLjU1IDAgMSAuNDUgMSAxcy0uNDUgMS0xIDEtMS0uNDUtMS0xIC40NS0xIDEtMXoiPjwvcGF0aD4KPC9zdmc+Cg==";function HI(n,e,t){W(t,"editor-box-anchor"),pm($I,[],t)}const A6={boxType:"anchor",updateBoxContent:HI};function jI(n,e,t,o){w("span",[],t,o.text)}const b6={insertionType:"inputting",updateInsertionContent:jI},v6=S("editor-insertion");class y6{constructor(e){m(this,"insertions",new Map);this.editor=e}registerInsertionClass(e){const t=e.insertionType,o=this.insertions.get(t);g(v6,!o,`duplicated insertion type: ${t}`),this.insertions.set(t,e)}getInsertionClass(e){const t=this.insertions.get(e);return g(v6,t,`unknown insertion type: ${e}`),t}createInsertion(e,t){const o=ZC(t.type,t.id),r=YC(o);return this.getInsertionClass(t.type).updateInsertionContent(this.editor,o,r,t),o}}class UI{constructor(e){m(this,"cursors",new Map);m(this,"timer");this.editor=e,this.timer=this.startTimer()}add(e,t){this.cursors.set(e,t)}startTimer(){return setInterval(()=>{const e=Date.now();Array.from(this.cursors).forEach(([t,o])=>{if(e-o>3e3){const r=QC(this.editor,t);r&&te(r,"active"),this.cursors.delete(t)}})},1e3)}destroy(){clearInterval(this.timer)}}function zI(n,e,t,o){var l;const r=o;Date.now()-r.time<5*1e3&&(n.addCustom("active-cursors",d=>new UI(d)).add(r.id,r.time),W(e,"active")),w("span",[],t,"|").setAttribute("data-cursor-name",r.name),e.style.setProperty("--cursor-color",n.getColor((l=r.rainbowIndex)!=null?l:0))}const wg={insertionType:"remote-cursor",updateInsertionContent:zI};class k6{constructor(e){m(this,"decorators",[]);this.editor=e}registerDecorator(e){this.decorators.push(e)}decorateBlock(e,t){let o=t;return this.decorators.forEach(r=>{if(r.decorateBlock){const i=r.decorateBlock(this.editor,e,t);i&&(o=me.default(i))}}),o}decorateText(e,t){let o=t;const r=new Map;return this.decorators.forEach(i=>{if(i.decorateText){const s=i.decorateText(this.editor,e,t);if(s){const{insertions:l,text:a}=s;l&&Array.from(l.entries()).forEach(([d,h])=>{const p=r.get(d);p?p.push(...h):r.set(d,h)}),a&&(o=me.default(a))}}}),{insertions:r,text:o}}}const Bg=S("editor-input");class VI{constructor(e,t){m(this,"editor");m(this,"composing",!1);m(this,"callbacks");m(this,"inputElement");m(this,"handleDocumentClick",e=>{const t=this.editor.rootContainer,o=e.target;if(o&&t.contains(o)&&!Ls(o)){this.editor.emit("focus",this.editor),this.callbacks.onFocus(),this.editor.input.focus();return}this.editor.emit("blur",this.editor),this.callbacks.onBlur()});m(this,"handleDocumentSelectionChange",()=>{setTimeout(()=>{var t;const e=(t=document.getSelection())==null?void 0:t.focusNode;e&&this.editor.contains(e)&&!Ls(e)||(this.editor.emit("blur",this.editor),this.callbacks.onBlur())},100)});m(this,"handleEditorSelectionChanged",()=>{const t=!this.editor.isWritable();this.inputElement.readOnly=t});m(this,"handleReadonlyChanged",()=>{this.handleEditorSelectionChanged()});m(this,"handleCompositionstart",e=>{!this.editor.isWritable()||(this.composing=!0,this.callbacks.onCompositionStart(e))});m(this,"handleCompositionend",e=>{this.composing=!1,this.callbacks.onUpdateCompositionText(e,this.inputElement.value,!0),this.inputElement.value=""});m(this,"handleInput",e=>{if(e instanceof InputEvent&&!!e.data){if(this.editor.readonly||!this.editor.isWritable()){this.inputElement.value="";return}this.composing?this.callbacks.onUpdateCompositionText(e,e.data,!1):(this.callbacks.onInsertText(e,e.data),this.inputElement.value="")}});m(this,"handleKeyDown",e=>{if(!this.composing){if(this.callbacks.onKeyDown(e)){e.preventDefault(),e.stopPropagation();return}!this.editor.isWritable()||setTimeout(()=>{this.composing||(this.inputElement.value="")})}});m(this,"handleCopy",e=>{this.callbacks.onCopy(e)});m(this,"handleCut",e=>{if(this.editor.readonly){e.stopPropagation(),e.preventDefault();return}this.callbacks.onCut(e),Bg.debug("on cut")});m(this,"handlePaste",e=>{if(this.editor.readonly){e.stopPropagation(),e.preventDefault();return}this.callbacks.onPaste(e)});m(this,"handlePasteText",(e,t)=>{this.callbacks.onPasteText(e,t)});this.editor=e,this.callbacks=t;const o=w("input",["editor-input"],e.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("click",this.handleDocumentClick),document.addEventListener("selectionchange",this.handleDocumentSelectionChange),this.editor.addListener("selectionChanged",this.handleEditorSelectionChanged),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}destroy(){this.callbacks.destroy(),document.removeEventListener("click",this.handleDocumentClick),document.removeEventListener("selectionchange",this.handleDocumentSelectionChange),this.editor.removeListener("selectionChanged",this.handleEditorSelectionChanged),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged);const e=this.inputElement;e.removeEventListener("compositionstart",this.handleCompositionstart),e.removeEventListener("compositionend",this.handleCompositionend),e.onkeydown=null,e.oninput=null,e.oncopy=null,e.onpaste=null,e.oncut=null}getInput(){return this.inputElement}focus(){this.editor.selection.caret.visible()||this.editor.selection.caret.update(),Kt.isMobileSafari?this.inputElement.focus():setTimeout(()=>{this.inputElement.focus()})}handleChanged(e){this.callbacks.onChanged(e)}handleRemoteChanged(e){this.callbacks.onRemoteChanged(e)}addHandler(e){this.callbacks.addHandler(e)}removeHandler(e){this.callbacks.removeHandler(e)}defaultInsertText(e,t,o,r,i){g(Bg,e===this.editor,"invalid editor"),this.callbacks.defaultInsertText(e,t,o,r,i)}defaultHandleKeydown(e,t){return g(Bg,e===this.editor,"invalid editor"),this.callbacks.defaultHandleKeydown(e,t)}}function w6(n){const e=n.rootElement,t=e.getBoundingClientRect(),o=ys(e),r=window.innerWidth,i=window.innerHeight,s=t.left<0?0:t.left,l=t.top<0?0:t.top,a=t.right>r?r:t.right,d=t.bottom>i?i:t.bottom,h=(s+a)/2,p=(l+d)/2,A=0-t.left+h,v=0-t.top+p,B=n.input.inputElement;B.style.left=`${A/o}px`,B.style.top=`${v/o}px`}const Eg=S("editor-caret");class WI{constructor(e){m(this,"editor");m(this,"caretElem");m(this,"handleReadOnlyChanged",()=>{this.update()});this.editor=e,this.caretElem=w("div",["editor-cursor"],this.editor.contentElement),this.editor.on("readonlyChanged",this.handleReadOnlyChanged)}destroy(){this.editor.off("readonlyChanged",this.handleReadOnlyChanged)}visible(){const e=window.getComputedStyle(this.caretElem);return e.display!=="none"&&e.opacity!=="0"}hasCaret(){if(this.editor.readonly||!this.editor.selection.range.isCollapsed())return!1;const e=this.editor.selection.range.start;if(!(e instanceof jt))return!1;const t=this.editor.getBlockById(e.blockId);return!!ee(this.editor,t)}update(){if(nC(this.editor.rootElement))return;const e=this.caretElem;if(this.hasCaret())e.style.display="";else{e.style.display="none",w6(this.editor);return}const{range:t}=this.editor.selection;g(Eg,t.isCollapsed,"range is not collapsed");const o=t.start;g(Eg,o instanceof jt,"only simple block position can has caret");const r=this.editor.getBlockById(o.blockId);g(Eg,ee(this.editor,r),"only text kind block can has caret");let i;const s=r.querySelector("span.inputting-insertion");s?(i=bs(s),i=new DOMRect(i.right,i.top,1,i.height)):i=zn(r,o);const l=this.editor.contentElement.getBoundingClientRect(),a=i.left-l.left,d=i.top-l.top;e.style.left=`${a}px`,e.style.top=`${d}px`,e.style.height=`${i.height}px`;const h=this.editor.input.inputElement;h.style.left=`${a}px`,h.style.top=`${d+i.height-24}px`,Kt.isMobileSafari&&(h.style.left=`${a-4}px`,h.style.height=`${i.height}px`);const A=oo(r,{horizontal:!0}).getBoundingClientRect(),v=A.left-l.left,B=v+A.width;a<v||a>B?(w6(this.editor),e.style.display="none"):e.style.display=""}}function qI(n){t4(n),n.selection.range.getSelectedBlocks().forEach(e=>n4(n,e.block,e.start,e.end))}const GI=S("editor-dom");function B6(n){return oo(n.rootContainer).clientHeight}function ZI(n){return n.getFirstBlock().getBoundingClientRect().top}function QI(n){return n.getLastBlock().getBoundingClientRect().bottom}function xg(n){const t=oo(n.rootContainer).getBoundingClientRect(),o=t.x<0?0:t.x,r=t.y<0?0:t.y,i=t.right>window.innerWidth?window.innerWidth:t.right,s=t.bottom>window.innerHeight?window.innerHeight:t.bottom;return new DOMRect(o,r,i-o,s-r)}function YI(n,e){const t=xg(n),o=n.getBlockById(e.blockId),i=To(n,o,e);return ks(t,i.x,i.y)&&ks(t,i.right,i.bottom)}function E6(n,e){const t=xg(n),o=e.getBoundingClientRect();return o.top>=t.top&&o.top<=t.bottom||o.bottom<=t.bottom&&o.bottom>=t.top}function JI(n,e){const t=xg(n),o=e.getBoundingClientRect();return ks(t,o.x,o.y)||ks(t,o.right,o.bottom)}function KI(n){if(!ym(n.rootContainer)){GI.warn("editorScrollIntoView: editor is not visible");return}const e=n.rootContainer.getBoundingClientRect();if(e.height<1&&e.width<1)return;const t=n.selection,o=t.range.focus;if(!o.isSimple()){const h=o,p=n.getContainerById(h.childContainerId);JI(n,p)||p.scrollIntoView();return}if(t.range.start.blockId===t.range.end.blockId){const h=n.getBlockById(t.range.start.blockId);if(Lt(h)&&E6(n,h)||Le(n,h)&&E6(n,h))return}const r=o,i=n.getBlockById(r.blockId);if(YI(n,r))return;const s=To(n,i,r),l=i.getBoundingClientRect(),a=lt(i),d=w("div",["editor-block-anchor"],a);d.style.top=`${s.top-l.top}px`,km(d,{elementToScroll:oo(n.rootContainer)}),setTimeout(()=>{d.remove()},200)}function XI(n,e){if(e.isCollapsed())return!1;const t=St(n.rootContainer),o=Gt(n.rootContainer),{start:r,end:i}=e;return r.blockId===ie(t)&&r.offset===0&&i.blockId===ie(o)&&i.offset===ue(n,o)}const x6=S("range-in-block");function I6(n,e){const t=e.getEditor(),o=t.getBlockById(e.start.blockId),r=t.getBlockById(e.end.blockId),i=o===n||Ke(n,o),s=r===n||Ke(n,r);return!!(i||s)}function T6(n,e){const t=n.doc.toJSON(),o=new Set(Object.values(t.blocks).map(s=>s.map(l=>l.id)).flat());let r,i=ct(e);if(i){for(;i&&!o.has(ie(i));)i=ct(i);g(x6,i,"no prev block while deleting a block"),r=yt(n,i,ue(n,i))}else{const s=Ze(e);g(x6,s,"no prev and next block while deleting a block"),r=yt(n,s,0)}return r}const eT=S("block-to-html");function Ig(n,e,t,o){const r=Ms(n,e.type);if(r.convertTo)return r.convertTo(n,e,t,"html",o);if(r.blockKind!=="text")return`[${e.type}]`;g(eT,e.text,"no text");const i=rt(e.text);return`<div>${sC(i)}</div>`}const D6=S("block-to-text");function tT(n,e,t){let o="";return e.forEach(r=>{if(g(D6,typeof r.insert=="string","invalid op"),r.attributes&&r.attributes.box===!0){const i=r.attributes,s=n.editorBoxes.getBoxClass(i.type);if(s!=null&&s.convertTo){o+=s.convertTo(n,i,t,"text");return}if(r.attributes.text){o+=r.attributes.text;return}o+=`[${i.type}]`}o+=r.insert}),o}function bh(n,e,t,o){const r=Ms(n,e.type);return r.convertTo?r.convertTo(n,e,t,"text",o):r.blockKind!=="text"?`[${e.type}]`:(g(D6,e.text,"no text"),tT(n,e.text,t))}function Tg(n,e,t,o){const r=Ms(n,e.type);return r.convertTo?r.convertTo(n,e,t,"markdown",o):bh(n,e,t,o)}function vh(n,e){return e.blocks.root.map((r,i)=>Ig(n,r,e,[{containerId:"root",blockIndex:i}])).join(`
25
25
  `)}function S6(n,e){return`<!doctype html><html><head><meta charset="utf8" /></head><body>${vh(n,e)}</body></html>`}function La(n,e){return e.blocks.root.map((r,i)=>bh(n,r,e,[{containerId:"root",blockIndex:i}])).join(`
26
26
  `)}function Ma(n,e){const t=e.blocks.root.map((r,i)=>Tg(n,r,e,[{containerId:"root",blockIndex:i}]));return t[t.length-1]=t[t.length-1].trimEnd(),t.join(`
27
- `)}const nT=S("get-text-position");function Gl(n,e){const t=e!=null?e:n.selection.range.start;t instanceof jt||g(nT,!1,`invalid insert pos type: ${typeof t}`);const{blockId:o}=t,r=n.getBlockById(o),i=be(r),s=ne(r),l=ae(s),{offset:a}=t;return{block:r,container:s,containerId:l,blockIndex:i,offset:a}}const Zl=S("insert-text");function Dg(n,e,t,o){var s;const r=n.doc.getBlockData(e,t);if(g(Zl,r,"no block data"),g(Zl,r.text,"no block text"),rn(r.text)===0)return g(Zl,o===0,"invalid text offset"),n.editorCommandProviders.getEmptyBlockTextAttributes(n,r.id);if(o===0)return;const i=zt(r.text,o-1,1).middle;if(!((s=i[0].attributes)!=null&&s.box))return i[0].attributes}function oT(n,e,t){const o=ne(e),r=ae(o),i=be(e);return Dg(n,r,i,t)}function L6(n,e,t,o,r){const i=ne(e),s=ae(i),l=be(e),a=oT(n,e,t),d=ah(t,o,a!=null?a:null);return n.doc.localUpdateBlockText(s,l,d,r),mn(n,e)}function M6(n,e,t,o){const r=ne(e),i=ae(r),s=be(e),l=ah(t," ",o);return n.doc.localUpdateBlockText(i,s,l),mn(n,e)}function rT(n,e,t){let o=0;if(e===0)return!1;for(let r=0;r<n.length;r++){const i=n[r];g(Zl,typeof i.insert=="string","invalid text op, no insert");const s=o+uh(i);if(s===e||s===t)return!1;if(s>e&&s>t)return!0;o=s}return!1}function Sg(n,e,t,o,r){const i=n.doc.getBlockData(t,o);g(Zl,i,"no block data"),g(Zl,i.text,"no block text");const s=Dg(n,t,o,r);s&&Object.keys(s).includes("link")&&(rT(i.text,r,r)||delete s.link);const l=ah(r,e,s!=null?s:null);return n.doc.localUpdateBlockText(t,o,l),mn(n,n.getBlockById(i.id))}function Lg(n,e){n.selection.range.isCollapsed()||n.clearSelectedContents();const{containerId:t,blockIndex:o,offset:r}=Gl(n);Sg(n,e,t,o,r)}const yh=S("update-composition-text");function R6(n){const e=n.selection.range.start;e instanceof jt||g(yh,!1,`invalid insert pos type: ${typeof e}`);const{blockId:t}=e,o=n.getBlockById(t);g(yh,ee(n,o),"not a text kind block");const r=ne(o),i=ae(r),s=be(o),l=n.doc.getBlockData(i,s);g(yh,l,"no block data in doc"),g(yh,l.text,"no text data in text block");const a=Re(o);ih(n,Di(o),t,a,l.text)}function O6(n){_x(n)}function Ql(n,e,t,o,r,i){return n.doc.localInsertBlock(e,t,o,r,i),n.getBlockById(o.id)}const Ra=S("delete-block-text");function Mg(n,e,t,o,r){if(!n.isBlockWritable(e))return Ra.error("block is not writable"),0;g(Ra,ee(n,e),"block is not a text kind block");const i=ne(e),s=ae(i),l=be(e),a=n.doc.getBlockData(s,l);g(Ra,a,"no block data in doc"),g(Ra,a.text,"no text data in text block");let d=t;sn(e,t)||(d=Ri(e,d));let h=t+o;g(Ra,h<=ue(n,e),`invalid offset and count: ${t}, ${o}`),sn(e,h)||(h=Fs(e,h));const p=h-d,A=V4(d,p);return n.doc.localUpdateBlockText(s,l,A,r),p}const Rg=S("break-text-block");function _6(n,e){const o=n.getBlockData(e).quoted;return o?{quoted:o}:{}}function Yl(n,e,t,o){g(Rg,ee(n,e),`block is not a text kind block: ${De(e)}`),g(Rg,t>=0&&t<=ue(n,e),`invalid offset: ${t}`);const r=ne(e),i=ae(r),s=be(e),l=o!=null&&o.copyBlockAttributes?_6(n,e):{};if(!(o!=null&&o.forceInsertAfter)&&(t===0||t===ue(n,e))){const v=t===0?s:s+1,B={...sr(""),...l,...o==null?void 0:o.newBlockData},D=yt(n,e.id,0),I=Ql(n,i,v,B,D);return{block:e,newBlock:I}}g(Rg,sn(e,t),"not a valid offset");const a=mn(n,e),{right:d}=xn(a,t),h=rn(d);h>0&&Mg(n,e,t,h);const p={...sr(d),...l,...o==null?void 0:o.newBlockData},A=Ql(n,i,s+1,p,yt(n,p.id,0));return{block:e,newBlock:A}}const iT=S("prepare-insert-new-block");function sT(n,e,t){if(e&&t!==void 0&&t!==null){const d=n.getContainerById(e),h=vt(d);return g(iT,t>=0&&t<=h.length,`invalid blockIndex: ${t}`),{containerId:e,blockIndex:t}}const o=n.selection.range.start;if(!o.isSimple())return null;const r=n.getBlockById(o.blockId);if(e=ae(ne(r)),t=be(r),!ee(n,r))return{containerId:e,blockIndex:t+1};const s=o.offset;if(s===0||s===ue(n,r))return{containerId:e,blockIndex:s===0?t:t+1};const a=Yl(n,r,s).newBlock;return{containerId:e,blockIndex:be(a)}}const lT=S("auto-insert-block");function F6(n,e,t,o,r,i){const s=sT(n,t,o);g(lT,s,`not an valid insert position: ${n.selection.range}`);const l={blockId:e.id,offset:0},a={anchor:l,focus:l};return Ql(n,s.containerId,s.blockIndex,e,r!=null?r:a,i)}const cT=S("delete-block");function kh(n,e,t){e.children&&(t.push(...e.children),e.children.forEach(o=>{n.getChildContainerData(o).forEach(i=>{kh(n,i,t)})}))}function wh(n,e,t){const o=ne(e),r=ae(o),i=be(e),s=n.doc.getBlockData(r,i);return g(cT,s,"no block data in doc"),n.doc.localDeleteBlock(r,i,Ut(n,{anchor:t.start,focus:t.end})),s}function Og(n,e,t){return n.undoManager.runInGroup(()=>{const o=ne(e);Eo(o)===1&&n.insertTextBlock("",ae(o),0);let r=t?Si(n,t):null;if(!r){const l=n.selection.range;I6(e,l)?r=T6(n,e):r=l}const i=wh(n,e,r),s=[];return kh(n,i,s),s.length>0&&n.doc.localDeleteChildContainers(s),i})}function aT(n,e){const t=[e];n.doc.getContainerBlocks(e).forEach(r=>{kh(n,r,t)}),n.doc.localDeleteChildContainers(t)}function P6(n,e){const t=[...e];e.forEach(o=>{n.doc.getContainerBlocks(o).forEach(i=>{kh(n,i,t)})}),n.doc.localDeleteChildContainers(t)}const _g=S("merge-text-block");function N6(n,e,t){g(_g,ee(n,e),"only text block can be merged"),g(_g,ee(n,t),"only text block can be merged");const o=_i(n,e),r=_i(n,t),i=o.text,s=r.text;g(_g,i&&s,"block data has no text");const l=ne(e),a=ae(l),d=be(e),h=ue(n,e),p=Sg(n,s,a,d,h),A=yt(n,e,rn(i));return Og(n,t,A),p}const lr=S("clear-selected-contents");function Bh(n,e){g(lr,ee(n,e.block),"not a text kind block");const{start:t,end:o}=e;g(lr,t.isSimple(),"not a simple block position"),g(lr,o.isSimple(),"not a simple block position");const r=t.offset,i=o.offset;g(lr,r<=i,`invalid delete text offset: ${r}, ${i}`),r!==i&&n.deleteTextFromBlock(e.block,r,i-r)}function $6(n,e,t){const o=ae(e),r=vt(e),i=t.focus?void 0:n.selection.range.toDocRange(),s=n.insertTextBlock("",o,0,{newRange:i});t.focus&&n.selection.selectBlock(s,0),r.reverse().forEach(l=>{n.deleteBlock(l)})}function uT(n,e){const{block:t,start:o,end:r}=e;if(ee(n,t)){Bh(n,e);return}if(Lt(t)||o.isSimple()){g(lr,r.isSimple(),"invalid range");const s=ne(t),l=be(t),a=n.insertTextBlock("",ae(s),l);n.selection.selectBlock(a,0),n.deleteBlock(t);return}g(lr,Le(n,t),"invalid block kind"),g(lr,!o.isSimple()&&!r.isSimple(),"invalid range"),Os(n,t,o,r),n.selection.range.getSelectedContainers().forEach((s,l)=>{$6(n,s,{focus:l===0})})}function dT(n){if(!n.isWritable())return;const e=n.selection.range;if(e.isCollapsed())return;const t=e.getSelectedBlocks();if(g(lr,t.length>0,"no selected block"),t.length===1){uT(n,t[0]);return}const o=t[0],r=o.block,i=ne(r);g(lr,t.length>1,"no selected block");const s=t[t.length-1],l=s.block;if(ee(n,r)){Bh(n,o);const h=yt(n,o.block,o.start.offset);if(t.slice(1,t.length-1).reverse().forEach(A=>n.deleteBlock(A.block)),ee(n,l)){Bh(n,s),n.mergeTextBlock(r,l,{focus:!0}),n.selection.setRange(h);return}n.deleteBlock(l),n.selection.setRange(h);return}if(ee(n,l)){Bh(n,s),t.slice(0,t.length-1).reverse().forEach(h=>n.deleteBlock(h.block)),n.selection.selectBlock(s.block,0);return}if(t.length===Eo(i)){$6(n,i,{focus:!0});return}const a=ct(r),d=Ze(l);g(lr,a||d,"no prev or next block"),t.forEach(h=>n.deleteBlock(h.block))}function Fg(n){n.selection.range.isCollapsed()||n.undoManager.runInGroup(()=>{n.emit("beforeClearSelection",n);try{n.doc.beginBatchUpdate(),dT(n)}finally{n.doc.endBatchUpdate()}n.emit("afterClearSelection",n)})}const hT=S("core");function H6(n,e,t){const o=ne(e),r=ae(o),i=be(e);return n.doc.localUpdateBlockText(r,i,t),setTimeout(()=>{n.selection.updateSelection(null)}),mn(n,e)}function j6(n,e,t){if(!n.isBlockWritable(e)){hT.error("block is not writable");return}const o=n.getBlockText(e),r=ln.diff(o,t);H6(n,e,r)}function Eh(n,e,t){const o=mn(n,e),r=typeof t=="string"?Oi(t):t,i=ln.diff(o,r);return H6(n,e,i)}const Oa=S("update-block-data");function xh(n,e,t,o){const r=ne(e),i=ae(r),s=be(e),l=n.doc.getBlockData(i,s),a={insert:{},delete:[]},d=new Set(Object.keys(l)),h=new Set(Object.keys(t));return d.forEach(A=>{if(!h.has(A)){if(A==="id"||A==="type"||A==="text")return;Oa.debug(`delete key: ${A}`),a.delete.push(A)}}),Object.entries(t).forEach(([A,v])=>{g(Oa,A!=="id"&&A!=="type",`invalid block data delta, ${A}`);const B=l[A];if(v==null){B!=null&&(Oa.debug(`delete key: ${A}`),a.delete.push(A));return}B!==v&&(ua.default(B,v)||A==="text"&&ln.diff(B,v).length===0||(d.has(A)?(Oa.debug(`replace key: ${A}`),a.delete.push(A)):Oa.debug(`insert key: ${A}`),a.insert[A]=v))}),n.doc.localUpdateBlockData(i,s,a,o),_i(n,e)}function U6(n,e,t,o){const i={...n.getBlockData(e),embedData:t};return n.updateBlockData(e,i,o)}function Pg(n,e,t){if(!Le(n,e)||!(t!=null&&t.tryFocusToChildSimpleBlock)){n.selection.selectBlock(e,0);return}const r=jn(n,e).getChildContainers(n,e)[0],i=St(r);Pg(n,i,t)}function $s(n){const e=[];let t={};return n.forEach(o=>{e.push(...o.blocks.root);const{root:r,...i}=o.blocks;t={...t,...i}}),{blocks:{...t,root:e},meta:{},comments:{}}}const _a=S("clone-block");function Fi(n,e,t,o){const r=n.getBlockClass(t.type);if(r.blockToDoc)return r.blockToDoc(e,t,(h,p)=>(g(_a,t!==p,"invalid child block"),Fi(n,h,t,o)));let i={};const s=new Map,l=me.default(t);l.children&&(l.children=l.children.map(h=>{const p=K(),A=e.blocks[h];g(_a,Array.isArray(A),"invalid child blocks");const v=A.map(_=>Fi(n,e,_,o)),B=$s(v),{root:D,...I}=B.blocks;return i={...i,...I},i[p]=B.blocks.root,s.set(h,p),p}));const a=Array.from(s.entries()),d=h=>{for(const p of a){const[A,v]=p;{const B=`${A}/`;if(h.startsWith(B)){const D=h.substring(B.length),I=`${v}/${D}`;return _a.debug(`replace key: ${h} -> ${I}`),I}}{const B=`${A}_`;if(h.startsWith(B)){const D=h.substring(B.length),I=`${v}_${D}`;return _a.debug(`replace key: ${h} -> ${I}`),I}}}return h};return Array.from(Object.entries(l)).forEach(([h,p])=>{const A=d(h);A!==h&&delete l.key,l[A]=p}),l.id=K(),o&&(o.blockIdMap.set(t.id,l.id),s.forEach((h,p)=>o.containerIdMap.set(p,h))),{blocks:{root:[l],...i},meta:{},comments:{}}}function Ng(n,e,t,o){const r=e.blocks[t];g(_a,Array.isArray(r),"invalid child blocks");const i=r.map(l=>Fi(n,e,l,o));return $s(i)}function $g(n,e,t){const o=e.blocks.root.map(r=>Fi(n.editorBlocks,e,r,t));return me.default($s(o))}const z6=S("insert-doc");function V6(n,e,t,o,r){if(Le(n,e)){z6.warn("failed to insert doc into a complex block");return}const i=$g(n,o,r),s=ne(e),l=be(e),a=ae(s);n.doc.beginBatchUpdate(),n.undoManager.runInGroup(()=>{var M,H,z;Object.entries(i.blocks).forEach(([q,re])=>{q!=="root"&&n.doc.localInsertChildContainer(q,re)});const d=i.blocks.root;if(Lt(e)){n.deleteBlock(e);let q;d.reverse().forEach(re=>{const fe=n.insertBlock(a,l,re);q||(q=fe)}),q&&n.selection.selectBlock(q,ue(n,q));return}if(g(z6,ee(n,e),"not a text block"),ht(n,e)){const q=a==="root"&&n.getBlockByIndex(a,0)===e,re=be(e);let fe;d.forEach((Be,je)=>{const Ue=n.insertBlock(a,re+je,Be);je===d.length-1&&(fe=Ue)}),fe&&n.selection.selectBlock(fe,ue(n,fe)),q&&n.deleteBlock(e);return}if(d.length===1){const q=d[0];if(ya(n,q.type)){n.insertTextToBlock(e,t,(M=q.text)!=null?M:[]);return}n.breakTextBlock(e,t),n.insertBlock(a,l+1,q);return}const h=t===ue(n,e),p=t===0,A=d[0],v=d[d.length-1];let B;!h&&!p?B=n.breakTextBlock(e,t,{forceInsertAfter:!0}):B=e;const D=p?l:l+1;h?(B=n.insertBlock(a,l+1,v),n.selection.selectBlock(B,ue(n,B))):(n.selection.selectBlock(B,0),ya(n,v.type)?n.insertTextToBlock(B,0,(H=v.text)!=null?H:[]):n.insertBlock(a,D,v));const I=n.selection.range;let _=D;ya(n,A.type)?p?(n.insertBlock(a,D,A),_+=1):n.insertTextToBlock(e,t,(z=A.text)!=null?z:[]):(n.insertBlock(a,D,A),_+=1),d.slice(1,d.length-1).reverse().forEach(q=>{n.insertBlock(a,_,q)}),n.selection.setRange(I)}),n.doc.endBatchUpdate()}function Hg(n,e,t,o,r){const i=$g(n,o,r),s=ae(e),l=[];return n.undoManager.runInGroup(()=>{Object.entries(i.blocks).forEach(([d,h])=>{d!=="root"&&n.doc.localInsertChildContainer(d,h)}),i.blocks.root.reverse().forEach(d=>{const h=n.insertBlock(s,t,d);l.push(h)})}),l}function W6(n,e,t){const o=Eo(e);Hg(n,e,o,t);for(let r=0;r<o;r++){const i=St(e);n.deleteBlock(i)}}const Fa=S("add-text-attribute");function fT(n,e,t,o){const{start:r,end:i}=t;g(Fa,r.blockId===i.blockId&&r.blockId===ie(e),"invalid range"),g(Fa,o,"invalid attribute name");const s=n.getBlockText(e),l=ql(r.offset,i.offset-r.offset,s,o,void 0,{ignoreValue:!0});return n.setBlockText(e,l),l}function q6(n,e,t,o,r){const{start:i,end:s}=t;g(Fa,i.blockId===s.blockId&&i.blockId===ie(e),"invalid range"),g(Fa,o,"invalid attribute name");const l=n.getBlockText(e),a=Ia(i.offset,s.offset-i.offset,l,o,r);return n.setBlockText(e,a),a}function Jl(n,e,t,o,r){const{start:i,end:s}=t;g(Fa,i.blockId===s.blockId&&i.blockId===ie(e),"invalid range");const l=n.getBlockText(e),a=X4(i.offset,s.offset-i.offset,l,o,r);return n.setBlockText(e,a),a}function G6(n,e,t,o){const r=Lo(n,{simpleBlockOnly:!0});n.undoManager.runInGroup(()=>{r.forEach(i=>{const{block:s,start:l,end:a}=i;if(!ee(n,s))return;if(ht(n,s)){o(n,ie(s),e,t);return}const d=Ut(n,{anchor:l,focus:a});e==="color"||e==="backgroundColor"?Jl(n,s,d,e,t):(Jl(n,s,d,"color",null),Jl(n,s,d,"backgroundColor",null))})})}function Z6(n,e,t){const o=Lo(n,{simpleBlockOnly:!0});n.undoManager.runInGroup(()=>{o.forEach(r=>{const{block:i,start:s,end:l}=r;if(!ee(n,i))return;if(ht(n,i)){(e==="clearColor"||e==="clearAll")&&t(n,ie(i),"color",null),(e==="clearBackground"||e==="clearAll")&&t(n,ie(i),"backgroundColor",null);return}const a=Ut(n,{anchor:s,focus:l});(e==="clearColor"||e==="clearAll")&&Jl(n,i,a,"color",null),(e==="clearBackground"||e==="clearAll")&&Jl(n,i,a,"backgroundColor",null)})})}function jg(n,e){const t=Lo(n,{simpleBlockOnly:!0}).filter(s=>ee(n,s.block));if(t.length===0)return[null,null];const o=s=>{if(ue(n,s.block)===0)return e(n,ie(s.block));const l=s.start,a=s.end,d=n.getBlockText(s.block);return n6(l.offset,a.offset-l.offset,d)};let[r,i]=o(t[0]);return r===null&&i===null?[r,i]:(t.forEach(s=>{const[l,a]=o(s);l===null||r===null?r=null:r=l===r?r:null,a===null||i===null?i=null:i=a===i?i:null}),[r,i])}const Vn=S("adjust-selection-pos");function Q6(n){const e=[];for(;n;){const t=ne(n);if(e.unshift(t),Xe(t))return e;const o=oe(t);g(Vn,o,"child container has not parent container"),n=o}g(Vn,!1,"should not come here: getParentContainers")}function Y6(n,e){for(;e;){const t=ne(e);if(t===n)return e;const o=oe(t);g(Vn,o,"could not find parent block for a child container"),e=o}g(Vn,!1,"no parent block in specified container")}function mT(n,e){const t=Q6(n),o=Q6(e);g(Vn,t.length>0&&o.length>0,"block has not parent container"),g(Vn,t[0]===o[0],"root container does not equal");let r=t[0];for(let l=1;l<t.length||o.length;l++)if(t[l]!==o[l]){r=t[l-1];break}const i=Y6(r,n),s=Y6(r,e);return{parentContainer:r,newBlock1:i,newBlock2:s}}function J6(n,e){let t=oe(e);for(g(Vn,t,"element is not in a block");t;){const o=ne(t);g(Vn,Do(o),"not a child container");const r=oe(o);if(g(Vn,r,"child container has not parent block"),r===n)return o;t=r}g(Vn,!1,"failed to find parent container in complex block")}function Ih(n,e,t){const o=n.getBlockById(e.blockId),r=n.getBlockById(t.blockId);if(o===r)return e instanceof jt&&t instanceof jt?{anchor:e,focus:t}:e instanceof So&&t instanceof So?oh(n,o,e,t):null;const i=ne(o),s=ne(r);if(i===s)return e instanceof So&&(e=se(o,0,"home")),t instanceof So&&(t=se(r,ue(n,r),"end")),g(Vn,e instanceof jt,"not valid position type"),g(Vn,t instanceof jt,"not valid position type"),{anchor:e,focus:t};if(o.contains(s))return null;if(r.contains(i)){if(e instanceof jt&&t instanceof So){const B=n.getContainerById(t.childContainerId);if(B===i)return{anchor:t,focus:t};const D=oe(i);if(D&&D===oe(B)){const I=ft(D,ae(i)),_=ft(D,ae(B));return oh(n,D,I,_)}}return null}const l=jd(o,r)>0,{newBlock1:a,newBlock2:d}=mT(o,r);if(a===d){const B=a,D=J6(B,o),I=J6(B,r);return e=ft(a,ae(D)),t=ft(a,ae(I)),Vn.debug(`select in complex block: ${D.id}, ${I.id}`),oh(n,B,e,t)}let h=l?ue(n,a):0;a===o&&e instanceof jt&&(h=e.offset);let A=l?0:ue(n,d);return d===r&&t instanceof jt&&(A=t.offset),e=se(a,h,l?"end":"home"),t=se(d,A,l?"home":"end"),{anchor:e,focus:t}}const gT=S("move-complex-block-position");function pT(n,e,t){const o=n.getBlockById(e.blockId);g(gT,Le(n,o),"is not a complex block");const r=jn(n,o),i=n.getContainerById(e.childContainerId),s=r.getNextContainer(n,o,i,t,{noWrap:!0});return s?ft(o,ae(s)):null}const Pa=S("move-simple-block-position");function K6(n,e){const t=En(n,e,{visibleOnly:!0});g(Pa,t.length>0,"complex block has not any child container");const o=t[0];return St(o)}function X6(n,e){const t=En(n,e,{visibleOnly:!0});g(Pa,t.length>0,"complex block has not any child container");const o=t[t.length-1];return Gt(o)}function eA(n,e,t){const o=t?K6(n,e):X6(n,e);return Le(n,o)?eA(n,o,t):o}function CT(n,e){const t=n.getBlockById(e.blockId);return Le(n,t)&&e.offset===0?K6(n,t):Ss(t)}function AT(n,e){const t=n.getBlockById(e.blockId);return Le(n,t)&&e.offset===1?X6(n,t):Ds(t)}function Ug(n){return n==="ArrowLeft"||n==="ArrowUp"}function zg(n,e,t){const o=ne(e);if(Xe(o))return null;const r=oe(o);g(Pa,r,"child container has not parent block"),g(Pa,Le(n,r),"is not a complex block");const i=jn(n,r).getNextContainer(n,r,o,t);return i?Ug(t)?Gt(i):St(i):zg(n,r,t)}function bT(n,e,t){const o=ne(e);if(Xe(o))return null;const r=oe(o);if(g(Pa,r,"child container has not parent block"),Ug(t)){const l=ct(r);if(l)return l}else{const l=Ze(r);if(l)return l}const i=zg(n,r,t);if(i)return i;let s=r;for(;!Xe(ne(s));)s=oe(ne(s));return Ug(t)?ct(s):Ze(s)}function vT(n,e,t){return!Le(n,e)||jn(n,e).enableKeyboardSelect?e:eA(n,e,t==="ArrowDown"||t==="ArrowRight")}function yT(n,e,t){const o=n.getBlockById(e.blockId),i=Qe(n,o).moveCaret(n,o,e,t);if(i)return i;let s=t==="ArrowDown"||t==="ArrowRight"?CT(n,e):AT(n,e);if(s||(s=zg(n,o,t),s||(s=bT(n,o,t))),!s){if(t==="ArrowDown"||t==="ArrowRight"){if(n.readonly||!Xe(ne(o)))return null;const l=n.insertTextBlock("",ae(n.rootContainer),Eo(n.rootContainer));return se(l,0,"home")}return null}if(s=vT(n,s,t),ee(n,s)){const l=n.selection.getSuggestedCaretX();if(t==="ArrowDown")return Gx(n,s,o,e,l);if(t==="ArrowUp")return qx(n,s,o,e,l)}return t==="ArrowLeft"||t==="ArrowUp"?se(s,ue(n,s),"end"):t==="ArrowRight"||t==="ArrowDown"?se(s,0,"home"):null}function kT(n,e,t){if(e==="ArrowLeft")return t.start;const o=t.end,r=n.getBlockById(o.blockId);if(ee(n,r))return o;const i=Ze(r);if(i)return se(i,0,"home");if(!Xe(ne(r))||n.readonly)return o;const s=n.insertTextBlock("",ae(n.rootContainer),Eo(n.rootContainer));return se(s,0,"home")}function wT(n,e,t){const o=n.selection.range;let r;if(o instanceof Zt)t==="move"&&!o.isCollapsed()&&(e==="ArrowLeft"||e==="ArrowRight")?r=kT(n,e,o):r=yT(n,o.getFocusedPos(),e);else if(r=pT(n,o.focus,e),t==="move"){const i=r!=null?r:o.focus,s=n.getContainerById(i.childContainerId);if(e==="ArrowLeft"||e==="ArrowUp"){const l=Gt(s);r=se(l,0,"home")}else{const l=St(s);r=se(l,ue(n,l),"end")}}return r?t==="move"?{anchor:r,focus:r}:Ih(n,o.anchor,r):null}function Pi(n,e,t){const o=wT(n,e,t);if(!o)return!1;const{anchor:r,focus:i}=o;return n.selection.setSelection(r,i),(e==="ArrowLeft"||e==="ArrowRight")&&n.selection.updateLastCaretRect(),!0}function tA(n){return Pi(n,"ArrowLeft","move"),!0}function nA(n){return Pi(n,"ArrowRight","move"),!0}function oA(n){return Pi(n,"ArrowUp","move"),!0}function rA(n){if(Pi(n,"ArrowDown","move")||n.readonly)return!0;const e=n.getFocusedBlock(),t=ne(e);if(Xe(t)||Gt(t)!==e)return!0;const o=n.rootContainer;return n.insertTextBlock("",ae(o),Eo(o)),!0}function iA(n){return Pi(n,"ArrowDown","select"),!0}function sA(n){return Pi(n,"ArrowLeft","select"),!0}function lA(n){return Pi(n,"ArrowRight","select"),!0}function cA(n){return Pi(n,"ArrowUp","select"),!0}const aA=S("word-offset");function Vg(n,e){const t=n.selection.range.focus;g(aA,t.isSimple(),"invalid range type");const o=n.getBlockById(t.blockId);if(ht(n,o))return se(o,0,"home");if(t.offset===0||!ee(n,o)){const s=ct(o);if(!s)return null;const l=se(s,ue(n,s),"end");if(e==="select"&&ee(n,s)){const a=yg(n,s,l.offset);return se(s,a,"normal")}return l}const r=yg(n,o,t.offset);return se(o,r,"normal")}function Wg(n,e){const t=n.selection.range.focus;g(aA,t.isSimple(),"invalid range type");const o=n.getBlockById(t.blockId);if(ht(n,o))return se(o,0,"end");if(t.offset===ue(n,o)||!ee(n,o)){const s=Ze(o);if(!s)return null;const l=se(s,0,"home");if(e==="select"&&ee(n,s)){const a=kg(n,s,l.offset);return se(s,a,"end")}return l}const r=kg(n,o,t.offset);return se(o,r,"normal")}function uA(n){if(!n.selection.range.focus.isSimple())return!1;const t=Vg(n,"move");return t?(n.selection.setSelection(t),n.selection.updateLastCaretRect(),!0):!1}function dA(n){if(!n.selection.range.focus.isSimple())return!1;const t=Wg(n,"move");return t?(n.selection.setSelection(t),n.selection.updateLastCaretRect(),!0):!1}function hA(n){if(!n.selection.range.focus.isSimple())return!1;const t=Vg(n,"select");return t?(n.selection.setSelection(n.selection.getAnchorPos(),t),n.selection.updateLastCaretRect(),!0):!1}function fA(n){if(!n.selection.range.focus.isSimple())return!1;const t=Wg(n,"select");return t?(n.selection.setSelection(n.selection.range.anchor,t),n.selection.updateLastCaretRect(),!0):!1}S("find-block");function qg(n,e){if(!Le(n,e))return e;const o=jn(n,e).getChildContainers(n,e)[0],i=vt(o)[0];return qg(n,i)}function Gg(n,e){if(!Le(n,e))return e;const t=jn(n,e).getChildContainers(n,e),o=t[t.length-1],r=vt(o),i=r[r.length-1];return Gg(n,i)}function mA(n){const e=Gg(n,Gt(n.rootContainer)),t=se(e,ue(n,e),"end");return n.selection.setSelection(t),!0}function gA(n){const e=qg(n,n.getFirstBlock()),t=se(e,0,"home");return n.selection.setSelection(t),!0}function pA(n){const e=qg(n,n.getFirstBlock()),t=se(e,0,"home");return n.selection.setSelection(n.selection.getAnchorPos(),t),!0}function Zg(n){const e=Gg(n,Gt(n.rootContainer)),t=se(e,ue(n,e),"end");return n.selection.setSelection(n.selection.getAnchorPos(),t),!0}const CA=S("line-offset");function AA(n){const e=n.selection.range.focus;g(CA,e.isSimple(),"invalid range type");const t=n.getBlockById(e.blockId);if(e.offset===0||!ee(n,t))return se(t,0,"home");let r=$4(t,e).start;const{next:i}=eh(t,r);return i&&io(i)&&va(i)==="br"&&(r+=1),se(t,r,"home")}function bA(n){const e=n.selection.range.focus;g(CA,e.isSimple(),"invalid range type");const t=n.getBlockById(e.blockId);if(e.offset===ue(n,t)||!ee(n,t))return se(t,ue(n,t),"end");const o=$4(t,e);return se(t,o.end,"end")}function vA(n){if(!n.selection.range.focus.isSimple())return!1;const t=AA(n);return t?(n.selection.setSelection(n.selection.getAnchorPos(),t),n.selection.updateLastCaretRect(),!0):!1}function yA(n){if(!n.selection.range.focus.isSimple())return!1;const t=bA(n);return t?(n.selection.setSelection(n.selection.getAnchorPos(),t),n.selection.updateLastCaretRect(),!0):!1}function kA(n){if(!n.selection.range.focus.isSimple())return!1;const t=AA(n);return t?(n.selection.setSelection(t),n.selection.updateLastCaretRect(),!0):!1}function wA(n){if(!n.selection.range.focus.isSimple())return!1;const t=bA(n);return t?(n.selection.setSelection(t),n.selection.updateLastCaretRect(),!0):!1}const BA=S("find-block-position");function BT(n,e,t,o){g(BA,Le(n,e),"is not a complex block");const r=jn(n,e).getChildContainers(n,e);g(BA,r.length>0,"complex block has not any child container");const i=To(n,t,o),s=i.left+i.width/2,l=i.top+i.height/2,a=T4(n,e,s,l);return Qg(n,a,t,o)}function Qg(n,e,t,o){if(Le(n,e))return BT(n,e,t,o);const r=ie(e);let i=Number.MAX_SAFE_INTEGER;const s=To(n,t,o),l=s.left+s.width/2,a=s.top+s.height/2;let d=se(r,0,"home");const h=ue(n,e);for(let p=0;p<=h;p++){const A=se(r,p,"normal"),v=To(n,e,A),B=tr(v,l,a);B<i&&(i=B,d=A)}return d}const EA=S("page-offset");function ET(n,e){const t=B6(n)*.9,r=e.getBoundingClientRect().bottom-t;if(r<ZI(n))return n.getFirstBlock();const i=ct(e);if(!i)return n.getFirstBlock();let s=i;for(;s;){if(s.getBoundingClientRect().y<r)return s;s=ct(s)}return n.getFirstBlock()}function xT(n,e){const t=B6(n)*.9,o=e.getBoundingClientRect(),r=QI(n),i=o.top+t;if(i>r)return n.getLastBlock();const s=Ze(e);if(!s)return n.getLastBlock();let l=s;for(;l;){if(l.getBoundingClientRect().bottom>i)return l;l=Ze(l)}return n.getLastBlock()}function xA(n){const e=n.selection.range.focus;g(EA,e.isSimple(),"invalid range type");const t=n.getBlockById(e.blockId),o=ET(n,t);let r;return o===n.getFirstBlock()?r=se(o,0,"home"):r=Qg(n,o,t,e),r}function IA(n){const e=n.selection.range.focus;g(EA,e.isSimple(),"invalid range type");const t=n.getBlockById(e.blockId),o=xT(n,t);let r;return o===n.getLastBlock()?r=se(o,ue(n,o),"end"):r=Qg(n,o,t,e),r}function TA(n){if(!n.selection.range.focus.isSimple())return!1;const t=xA(n);return t?(n.selection.setSelection(t),n.selection.updateLastCaretRect(),!0):!1}function DA(n){if(!n.selection.range.focus.isSimple())return!1;const t=IA(n);return t?(n.selection.setSelection(t),n.selection.updateLastCaretRect(),!0):!1}function SA(n){if(!n.selection.range.focus.isSimple())return!1;const t=xA(n);if(!t)return!1;const o=Ih(n,n.selection.getAnchorPos(),t);if(!o)return!1;const{anchor:r,focus:i}=o;return n.selection.setSelection(r,i),n.selection.updateLastCaretRect(),!0}function LA(n){if(!n.selection.range.focus.isSimple())return!1;const t=IA(n);if(!t)return!1;const o=Ih(n,n.selection.getAnchorPos(),t);if(!o)return!1;const{anchor:r,focus:i}=o;return n.selection.setSelection(r,i),n.selection.updateLastCaretRect(),!0}const Na=S("select-all");function MA(n,e){const t=St(n),o=Gt(n);return e.start.offset===0&&e.start.blockId===ie(t)&&e.end.offset===ue(e.getEditor(),o)&&e.end.blockId===ie(o)}function IT(n,e){const t=e.getEditor(),o=jn(t,n).getChildContainers(t,n),r=o[0],i=o[o.length-1],s=ie(n);return e.start.blockId===s&&e.start.childContainerId===ae(r)&&e.end.blockId===s&&e.end.childContainerId===ae(i)}function TT(n,e){g(Na,e,"no parent block"),g(Na,Le(n,e),"not a complex block");const t=jn(n,e).getChildContainers(n,e),o=t[0],r=t[t.length-1];n.selection.setRange(Ut(n,{anchor:ft(e,ae(o)),focus:ft(e,ae(r))}))}function RA(n,e){const t=ne(e);Yg(n,t)}function OA(n){const e=n.getFocusedBlock(),t=n.selection.range;if(t.start.isSimple()){if(t.start.blockId===t.end.blockId&&ee(n,e)){const r=t.start,i=t.end,s=ue(n,e);if(r.offset>0||i.offset<s)return n.selection.selectBlock(e,0,s),!1}return W(n.rootContainer,"select-all"),RA(n,St(n.rootContainer)),!1}return g(Na,!t.isSimple(),"invalid range type"),IT(e,t)?(RA(n,e),!1):(g(Na,e,"no parent block"),g(Na,Le(n,e),"not a complex block"),TT(n,e),!0)}function Yg(n,e){const t=vt(e),o=t[0],r=t[t.length-1],i=se(o,0,"home"),s=se(r,ue(n,r),"end");n.selection.setSelection(i,s,{noScroll:!0})}function _A(n){Zg(n),n.focus()}const Jg=S("selected-block-to-doc");function FA(n,e,t){!e.children||e.children.forEach(o=>{const r=n.getChildContainerData(o);r.forEach(i=>{FA(n,i,t)}),t.blocks[o]=me.default(r)})}function Th(n,e){const t=Qe(n,e.block);if(t.selectionToDoc)return t.selectionToDoc(n,e);const o=me.default(_i(n,e.block));if(ee(n,e.block)){const i=e.start,s=e.end;if(g(Jg,o.text,"no block text"),i.offset===s.offset)return{blocks:{root:[{...o,text:[]}]},meta:{},comments:{}};const{middle:l}=zt(o.text,i.offset,s.offset-i.offset);return{blocks:{root:[{...o,text:l}]},meta:{},comments:{}}}if(Lt(e.block))return{blocks:{root:[o]},meta:{},comments:{}};g(Jg,Le(n,e.block),"not complex block"),g(Jg,o.children,"no children");const r={blocks:{root:[o]},meta:{},comments:{}};return FA(n,o,r),r}function Kg(n,e){const t=se(e,0,"normal"),o=se(e,ue(n,e),"end");return Th(n,{block:e,start:t,end:o})}const DT=S("block-to-doc");function ST(n,e){g(DT,e.length>0,"invalid params, no blocks");const t=e.map(o=>Kg(n,o));return $s(t)}function Dh(n){const t=n.selection.range.getSelectedBlocks().map(o=>Th(n,o));return $s(t)}function PA(n,e){const t=n.getContainerById(e),i=vt(t).map(s=>({start:se(s,0,"home"),end:se(s,ue(n,s),"end"),block:s})).map(s=>Th(n,s));return $s(i)}const Sh=S("editor-selection");class LT{constructor(e){m(this,"editor");m(this,"caret");m(this,"_range");m(this,"lastCaretRect");m(this,"handleBlockDelete",(e,t,o,r)=>{if(o||r.child)return;const i=this.range;if(I6(t,i)){Sh.debug("adjust selection because remote deleted current block");const s=T6(e,t);this.setRange(s,{noScroll:!0})}});this.editor=e;const t=e.getFirstBlock(),o=ie(t);this.caret=new WI(e);const r=se(o,0,"normal");this._range=Ut(e,{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 e=this.range.focus;return this.editor.getBlockById(e.blockId)}getStartBlock(){const e=this.range.start;return this.editor.getBlockById(e.blockId)}getEndBlock(){const e=this.range.end;return this.editor.getBlockById(e.blockId)}selectBlock(e,t,o){const r=se(e,t,"normal");let i;o&&(i=se(e,o,"normal")),this.setSelection(r,i)}setSelection(e,t,o){if(t||(t=e),this.verifyPos(e),this.verifyPos(t),!this.selectionChanging(e,t))return this.range;const r=Ut(this.editor,{anchor:e,focus:t});if(this.range.isEqual(r))return this.range;const i=this._range;return this._range=r,this.selectionChanged(),this.updateFocusedBlock(i),xe(this.editor.rootContainer,"select-all")&&(!r.isSimple()||!XI(this.editor,r))&&te(this.editor.rootContainer,"select-all"),o!=null&&o.noScroll||this.scrollIntoView(),this.range}setRange(e,t){return this.setSelection(e.anchor,e.focus,t)}updateSelection(){this.caret.update(),qI(this.editor)}getFocusedPos(){return this.range.focus}getAnchorPos(){return this.range.anchor}selectionChanging(e,t){return!0}selectionChanged(){this.updateSelection(),this.editor.emit("selectionChanged",this.editor)}updateLastCaretRect(){const e=this.range.focus;if(!Hr(e))return;const t=this.editor.getBlockById(e.blockId);this.lastCaretRect=To(this.editor,t,e)}getSuggestedCaretX(){var e;return(e=this.lastCaretRect)==null?void 0:e.x}scrollIntoView(){KI(this.editor)}verifyPos(e){const t=this.editor.getBlockById(e.blockId);if(e.isSimple())e.offset>=0&&e.offset<=ue(this.editor,t)||g(Sh,!1,"invalid block position, out of range");else{const o=e.childContainerId;!!this.editor.getContainerById(o)||g(Sh,!1,"invalid complex block position, no container found")}}updateFocusedBlock(e){if(e&&this.range.start.blockId===e.start.blockId)return;let t;e&&e.start.blockId===e.end.blockId&&(t=this.editor.findBlockById(e.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;t&&xe(t,"focused")&&(te(t,"focused"),r=!0),this.removeAllBlockFocusedClass(),o&&this.setBlockFocused(o)&&(r=!0),r&&this.editor.emit("focusBlockChanged",this.editor,o!=null?o:null,t!=null?t:null)}verify(){this.verifyPos(this._range.start),this.verifyPos(this._range.end)}to(e){const t=Dh(this.editor);return e==="text"?La(this.editor,t):e==="markdown"?Ma(this.editor,t):S6(this.editor,t)}removeAllBlockFocusedClass(){this.editor.rootContainer.querySelectorAll('div[data-type="editor-block"].focused, div[data-type="editor-block"].child-focused').forEach(e=>{te(e,"focused"),te(e,"child-focused")})}setBlockFocused(e){if(xe(e,"focused"))return!1;W(e,"focused");let t=ne(e);for(;Do(t);){const o=oe(t);g(Sh,o,"parent block not found"),W(o,"child-focused"),t=ne(o)}return!0}}function MT(n){const e=n.selection.range.focus;if(!e.isSimple())return;const t=n.findBlockById(e.blockId);!t||n.selection.selectBlock(t,0,ue(n,t))}function RT(n){const e=n.selection.range.focus;if(!e.isSimple())return;const t=n.findBlockById(e.blockId);if(!t||!ee(n,t))return;let o=Vg(n,"select"),r=Wg(n,"select");if(!o||!r)return;const i=e.blockId;o.blockId!==i&&(o=se(t,0,"home")),r.blockId!==i&&(r=se(t,ue(n,t),"end")),n.selection.setSelection(o,r)}class OT{constructor(e){m(this,"editor");m(this,"startPos",null);m(this,"lastCaretRect");m(this,"mouseDownEvent",null);m(this,"autoScroll",null);m(this,"handleMouseDown",e=>{this.mouseDownEvent=e;const t=L4(this.editor,e.x,e.y);if(t){if(t instanceof or)return;if(!this.autoScroll){const r=t.getSelectedBlocks(),i=oo(r[0].block);this.autoScroll=new Zd({scrollElement:i,edge:{top:50,bottom:50}})}const o=this.editor.selection.range;if(e.shiftKey&&o.isSimple()){const r=o.anchor;this.editor.selection.setSelection(r,t.focus),this.startPos=t.start}else this.editor.selection.setSelection(t.anchor,t.focus),this.startPos=t.start;this.editor.selection.updateLastCaretRect(),this.autoScroll.active()}});m(this,"handleMouseMove",e=>{if(!this.startPos||!this.mouseDownEvent||Math.abs(this.mouseDownEvent.x-e.x)<3&&Math.abs(this.mouseDownEvent.y-e.y)<3)return;const t=rh(this.editor,e.x,e.y);if(!t)return;const o=Ih(this.editor,this.startPos,t.end);if(!o)return;const{anchor:r,focus:i}=o;this.editor.selection.setSelection(r,i)});m(this,"handleMouseUp",e=>{var t;(t=this.autoScroll)==null||t.inactive(),this.startPos=null});this.editor=e,this.startPos=null,this.lastCaretRect=new DOMRect}isSelecting(){return this.startPos!==null}stopSelection(){this.startPos=null}handleDblClick(e){RT(this.editor)}handleTripleClick(e){MT(this.editor)}}function _T(n){return n.readonly||!n.isWritable()?!1:(n.undoManager.undo(),!0)}function FT(n){return n.readonly||!n.isWritable()?!1:(n.undoManager.redo(),!0)}const NA=S("delete-text");function $A(n,e,t,o){const r=o!=null?o:n.selection.range.start;r instanceof jt||g(NA,!1,`invalid insert pos type: ${typeof r}`);const{blockId:i}=r,s=n.getBlockById(i);g(NA,ee(n,s),"block is not a text kind block");let{offset:l}=r;if(e==="backward"){if(l-t<0)return 0;if(!sn(s,l-t)){const a=Ri(s,l);t=l-a}}else if(e==="forward"&&l+t>ue(n,s))return 0;return e==="backward"&&(l-=t),n.deleteTextFromBlock(s,l,t)}function HA(n,e){if(n.getBlockData(e).quoted){const t={quoted:null};return n.updateBlockData(e,t),!0}return!1}const PT=S("handle-backspace");function Xg(n,e){if(!ht(n,e))return;const t=ne(e);Eo(t)!==1&&n.deleteBlock(e)}function NT(n,e){if(!n.selection.range.isCollapsed()){n.clearSelectedContents();return}const t=n.selection.range.start,o=n.getBlockById(t.blockId);if(ee(n,o))if(t.offset===0){if(HA(n,o))return;const r=ct(o);if(r){if(!n.isBlockWritable(r))return;if(ee(n,r))n.mergeTextBlock(r,o,{focus:!0});else if(Le(n,r)){Xg(n,o);const i=Vl(n,r);i?n.selection.selectBlock(i,ue(n,i)):n.selection.selectBlock(r,0,ue(n,r))}else Xg(n,o),g(PT,Lt(r),"prev block is not embed block"),n.selection.selectBlock(r,1)}else{const i=ne(o);if(Do(i)){const s=E4(n,i);if(s){if(!n.isBlockWritable(s))return;Xg(n,o),n.selection.selectBlock(s,ue(n,s))}}}}else $A(n,"backward",1,null),n.selection.updateLastCaretRect();else{const r=be(o),i=ne(o);n.insertTextBlock("",ae(i),r),n.deleteBlock(o)}}function $T(n,e){if(!n.selection.range.isCollapsed()){n.clearSelectedContents();return}const t=n.selection.range.start,o=n.getBlockById(t.blockId);if(ee(n,o))if(t.offset===ue(n,o)){const r=Ze(o);if(r){if(!n.isBlockWritable(r))return;ee(n,r)?n.mergeTextBlock(o,r,{focus:!0}):ht(n,o)?n.deleteBlock(o,yt(n,r,0)):n.deleteBlock(r)}}else $A(n,"forward",1,null);else{const r=be(o),i=ne(o);n.insertTextBlock("",ae(i),r),n.deleteBlock(o)}}function HT(n){const{range:e}=n.selection,{start:t,end:o}=e,r=n.getBlockById(t.blockId),i=n.getBlockById(o.blockId);if(r!==i||!Le(n,r))return!1;if(Hr(t))return!0;const s=Os(n,r,t,o),l=En(n,r);return s.length===l.length}function jT(n,e){if(HT(n)){const o=n.getFocusedBlock(),r=be(o),i=ae(ne(o));n.insertTextBlock("",i,r+1);return}n.selection.range.isCollapsed()||n.clearSelectedContents();const t=n.getFocusedBlock();if(ee(n,t)){if(ht(n,t)&&HA(n,t))return;const o=n.selection.range.start,r=n.breakTextBlock(t,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 UT(n,e){const t=n.selection.range.getSelectedBlocks()[0],{block:o}=t;if(!ee(n,o))return!1;const r=t.end;return n.insertBoxToBlock(o,r.offset,{type:"br",id:K(),box:!0,created:Date.now()}),!0}const zT=S("input-handler-actions");function VT(n,e){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(jT(n),!0))}function WT(n,e){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>($T(n),!0))}function qT(n,e){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(NT(n),!0))}function GT(n,e){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(UT(n),!0))}function ZT(n){return n.readonly||!n.isWritable()||!window.isSecureContext?!1:(navigator.clipboard.readText().then(e=>{n.input.handlePasteText(e,{toPlainText:!0})}).catch(e=>{zT.error(e)}),!0)}const Lh={ArrowDown:rA,ArrowUp:oA,ArrowLeft:tA,ArrowRight:nA,"Shift+ArrowDown":iA,"Shift+ArrowUp":cA,"Shift+ArrowLeft":sA,"Shift+ArrowRight":lA,"CtrlOrCmd+ArrowLeft":uA,"CtrlOrCmd+ArrowRight":dA,"CtrlOrCmd+Shift+ArrowLeft":hA,"CtrlOrCmd+Shift+ArrowRight":fA,"CtrlOrCmd+ArrowUp":gA,"CtrlOrCmd+ArrowDown":mA,"CtrlOrCmd+Shift+ArrowUp":pA,"CtrlOrCmd+Shift+ArrowDown":Zg,"CtrlOrCmd+A":OA,Home:kA,End:wA,"Shift+Home":vA,"Shift+End":yA,PageUp:TA,PageDown:DA,"Shift+PageUp":SA,"Shift+PageDown":LA,"CtrlOrCmd+Z":_T,"CtrlOrCmd+Shift+Z":FT,Enter:VT,Delete:WT,Backspace:qT,"Shift+Enter":GT,"CtrlOrCmd+Shift+V":ZT};function jA(n,e){return n.shortcuts.handleKeyboardEvents(n,e)!==void 0}function UA(n,e,t){if(e.type==="embed"){const i=e.embedData,s=i.src;if(s&&typeof s=="string"){const l=t.get(s);l&&(i.src=l)}return}const o=e.text;o&&o.forEach(i=>{if(i.attributes&&i.attributes.src&&typeof i.attributes.src=="string"){const s=t.get(i.attributes.src);s&&(i.attributes.src=s)}});const r=e.children;r&&r.forEach(i=>{n.blocks[i].forEach(l=>{UA(n,l,t)})})}function zA(n,e,t){if(t.size===0)return;e.blocks.root.forEach(r=>{const i=n.editorBlocks.getBlockClass(r.type);i.replaceResources?i.replaceResources(r,t):UA(e,r,t)})}async function QT(n,e){const t=e.filter(i=>i.indexOf(":")===-1),o=await n.doc.addResources(t),r=new Map;if(t.length!==o.length)return r;for(let i=0;i<t.length;i++)r.set(t[i],o[i]);return r}function YT(n,e){var i,s;const o=e.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 JT(n,e){const o=e.meta.resources;if(!o||Object.keys(o).length===0)return;let r=new Map;if(YT(n,e)){const s=Array.from(Object.keys(o));r=await QT(n,s),zA(n,e,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&&zA(n,e,i)}async function KT(n,e,t){await JT(n,e),n.undoManager.runInGroup(()=>{const{start:o,end:r}=n.selection.range,i=n.getBlockById(o.blockId);if(o.blockId===r.blockId&&Lt(i)){const s=ne(i),l=n.getBlockIndex(i),[a]=n.insertDocAt(s,l+1,e,t);a&&n.selection.selectBlock(a,ue(n,a))}else{n.clearSelectedContents();const{block:s,offset:l}=Gl(n);n.insertDoc(s,l,e,t)}})}const XT=["text/x-ones-editor-doc","image/*","text/office-html","text/html","text/plain","text/markdown","*"];function eD(n){let e;for(const t of XT)if(e=n[t],e)break;return e||null}function VA(n,e,t){if(e.type==="embed"){const s=e.embedData.src;if(s&&typeof s=="string")for(const l of s.split("|"))t.add(l);return}const o=e.text;o&&o.forEach(i=>{i.attributes&&i.attributes.src&&typeof i.attributes.src=="string"&&t.add(i.attributes.src)});const r=e.children;r&&r.forEach(i=>{n.blocks[i].forEach(l=>{VA(n,l,t)})})}function tD(n,e){const t=new Set;return e.blocks.root.forEach(r=>{const i=n.editorBlocks.getBlockClass(r.type);i.getResources?i.getResources(r).forEach(s=>{t.add(s)}):VA(e,r,t)}),Array.from(t)}function Mh(n,e){return`<!doctype html><html><head><meta charset="utf8" />${`<meta charset="utf-8"><ones-editor-doc data-source="ones-editor-doc::${Bs(JSON.stringify(e))}::ones-editor-doc" />`}</head><body>${n}</body></html>`}function Rh(n,e){var i,s,l;const t=(l=(s=(i=n.doc).getServerMeta)==null?void 0:s.call(i))!=null?l:{},o=tD(n,e),r={};o.forEach(a=>{const d=n.doc.buildResourceUrl(a,{withToken:!0});r[a]=d}),e.meta={...t,resources:r}}function nD(n,e,t){if(e.preventDefault(),e.stopPropagation(),!e.clipboardData)return;let o=Dh(n);const r=t==null?void 0:t(n,e,o);if(r===!0)return;typeof r=="object"&&r!==null&&(o=r),Rh(n,o);const i=vh(n,o),s=Ma(n,o),l=Mh(i,o);e.clipboardData.setData("text/html",l),e.clipboardData.setData("text/plain",s),e.clipboardData.setData("text/x-ones-editor-doc",JSON.stringify(o))}async function Oh(n,e){const t=Kg(n,e);Rh(n,t);const o=vh(n,t),r=Ma(n,t),i=Mh(o,t);return Mm([{type:"text/plain",data:new Blob([r],{type:"text/plain"})},{type:"text/html",data:new Blob([i],{type:"text/html"})}])}class oD{constructor(e){m(this,"editor");m(this,"handlers",[]);m(this,"onPasteText",async(e,t)=>{const o=new DataTransfer;o.setData("text/plain",e);const r=await this.editor.dataConverter.fromData(this.editor,o,t);r&&this.pasteDocs(r,null)});this.editor=e}onInsertText(e,t){if(!ee(this.editor,this.editor.getFocusedBlock()))return;const{containerId:o,blockIndex:r,offset:i}=Gl(this.editor);this.handleBeforeInsertText(o,r,i,t)||(this.defaultInsertText(this.editor,o,r,i,t),this.handleAfterInsertText(o,r,i,t),this.editor.selection.updateLastCaretRect())}onKeyDown(e){if(this.handleBeforeKeyDown(e))return!0;const t=this.defaultHandleKeydown(this.editor,e);return this.handleAfterKeyDown(e)?!0:t}onChanged(e){for(let t=0;t<this.handlers.length;t++){const o=this.handlers[t];o.handleChanged&&o.handleChanged(this.editor,e)}}onRemoteChanged(e){for(let t=0;t<this.handlers.length;t++){const o=this.handlers[t];o.handleRemoteChanged&&o.handleRemoteChanged(this.editor,e)}}onCompositionStart(e){this.editor.updateCompositionText("",!1);const{containerId:t,blockIndex:o,offset:r}=Gl(this.editor);for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];s.handleCompositionStart&&s.handleCompositionStart(this.editor,t,o,r)}}onUpdateCompositionText(e,t,o){this.editor.updateCompositionText(t,o),this.editor.selection.caret.update();const{containerId:r,blockIndex:i,offset:s}=Gl(this.editor);for(let l=0;l<this.handlers.length;l++){const a=this.handlers[l];a.handleUpdateCompositionText&&a.handleUpdateCompositionText(this.editor,r,i,s,o)}this.editor.selection.updateLastCaretRect()}onCopy(e){nD(this.editor,e,(t,o,r)=>{for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];if(s.handleBeforeCopy){const l=s.handleBeforeCopy(this.editor,o,r);if(l===!0)return!0;if(typeof l=="object"&&l!=null)return l}}})}onCut(e){for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleBeforeCut&&r.handleBeforeCut(this.editor,e)===!0)return}if(this.onCopy(e),this.editor.selection.range.isCollapsed()){const o=this.editor.selection.focusedBlock;Lt(o)&&this.editor.deleteBlock(o)}else Fg(this.editor)}onPaste(e){if(e.preventDefault(),e.stopPropagation(),!e.clipboardData)return;this.editor.dataConverter.fromData(this.editor,e.clipboardData).then(async o=>{o&&this.pasteDocs(o,e)})}onFocus(){W(this.editor.rootElement,"active")}onBlur(){te(this.editor.rootElement,"active")}addHandler(e){this.handlers.push(e)}removeHandler(e){const t=this.handlers.indexOf(e);t!==-1&&this.handlers.splice(t)}handleBeforeInsertText(e,t,o,r){for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];if(s.handleBeforeInsertText&&s.handleBeforeInsertText(this.editor,e,t,o,r))return!0}return!1}handleAfterInsertText(e,t,o,r){for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];if(s.handleAfterInsertText&&s.handleAfterInsertText(this.editor,e,t,o,r))return!0}return!1}handleBeforeKeyDown(e){for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleBeforeKeyDown&&r.handleBeforeKeyDown(this.editor,e))return!0}const t=this.defaultHandleKeydown(this.editor,e);for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleAfterKeyDown&&r.handleAfterKeyDown(this.editor,e))return!0}return t}handleAfterKeyDown(e){for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleBeforeKeyDown&&r.handleBeforeKeyDown(this.editor,e))return!0}const t=this.defaultHandleKeydown(this.editor,e);for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleAfterKeyDown&&r.handleAfterKeyDown(this.editor,e))return!0}return t}defaultInsertText(e,t,o,r,i){Lg(this.editor,i)}defaultHandleKeydown(e,t){return jA(this.editor,t)?(t.preventDefault(),t.stopPropagation(),!0):!1}async pasteDoc(e){for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleBeforePasteDoc&&await r.handleBeforePasteDoc(this.editor,e))return}const t={blockIdMap:new Map,containerIdMap:new Map};await KT(this.editor,e,t);for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleAfterPasteDoc&&await r.handleAfterPasteDoc(this.editor,e,t))return}}async pasteDocs(e,t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforePaste&&await i.handleBeforePaste(this.editor,t,e))return}const o=eD(e);if(!!o){await this.pasteDoc(o);for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleAfterPaste&&await i.handleAfterPaste(this.editor,t,e))return}}}destroy(){this.handlers.forEach(e=>{var t;(t=e.destroy)==null||t.call(e,this.editor)}),this.handlers=[]}}function rD(n,e,t){const o=_r(e,t);return o.remove(),o}S("copy-dom-attributes");const WA=["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 iD(n,e){for(let l=0;l<WA.length;l++){const a=WA[l];e[a]=n[a]}const t=n.attributes,o=e.attributes,r=[],i=[];for(let l=0;l<t.length;l++){const a=t[l],d=o.getNamedItem(a.name);d?d.value!==a.value&&(d.value=a.value,i.push(a)):r.push(a)}const s=[];for(let l=0;l<o.length;l++){const a=o[l];t.getNamedItem(a.name)||s.push(a)}r.forEach(l=>{e.setAttribute(l.name,l.value)}),i.forEach(l=>{e.setAttribute(l.name,l.value)}),s.forEach(l=>{e.removeAttribute(l.name)})}function qA(n){const e=Array.from(n.childNodes).filter(t=>!HC(t));return e.forEach(t=>{t.remove()}),e}function GA(n,e,t){var d;const o=n.getContainerById(e),r=_r(o,t),i=Di(r),s=n.doc.getBlockData(e,t),l=Qe(n,r);if((d=l==null?void 0:l.handleUpdateBlock)==null?void 0:d.call(l,n,r,s))n.editorBlockRenders.updateBlock(n,i,r,s);else{const h=n.editorBlocks.createBlock(i,o,s),p=qA(h);qA(r),p.forEach(v=>{r.appendChild(v)});const A=Kd(h);if(A){const v=Kd(r);v&&v.remove(),r.appendChild(A)}iD(h,r)}r4(n,r,s),n.blockHooks.forEach(h=>{var p;(p=h.update)==null||p.call(h,n,i,o,r,s)}),setTimeout(()=>{n.selection.updateSelection(null)})}const sD=S("transform-selection");function ZA(n,e,t,o){const{range:r}=n.selection,{anchor:i,focus:s}=r;if(i.blockId!==e&&s.blockId!==e)return r;g(sD,i.isSimple()&&s.isSimple(),"invalid text pos type");let l=i;if(i.blockId===e){const d=ln.transformCursor(i.offset,t,o);l=se(e,d,"normal")}let a=s;if(s.blockId===e){const d=ln.transformCursor(s.offset,t,o);a=se(e,d,"normal")}return Ut(n,{anchor:l,focus:a})}const lD=S("handle-block-text-changed");function cD(n,e,t,o,r){const i=n.getContainerById(e),s=_r(i,t),l=n.doc.getBlockData(e,t);if(g(lD,l.text,"no block text"),KC(n,s).setBlockText(n,s,l.text),!r){const a=ZA(n,l.id,o,r);n.selection.setRange(a,{noScroll:!0})}}function aD(n,e){const t=me.default(n);return e.delete.forEach(r=>{delete t[r]}),{...t,...e.insert}}function QA(n,e,t,o){const r=Qe(n,e);r.handleDeleteBlock&&r.handleDeleteBlock(n,e,t,o),n.emit("blockDeleted",n,e,t,o)}function uD(n,e,t,o){const r=n.getBlockByIndex(e,t);r.querySelectorAll('[data-type="editor-block"]').forEach(i=>{QA(n,i,o,{child:!0})}),QA(n,r,o,{child:!1})}const Ro=S("editor-doc");class dD extends fa{constructor(t,o,r){super();m(this,"localEvents",[]);this.editor=t,this.externalDoc=o,this.externalDoc.registerCallback(this),this.registerLocalEvents(r)}beginBatchUpdate(){return this.externalDoc.beginBatchUpdate()}endBatchUpdate(){return this.externalDoc.endBatchUpdate()}registerLocalEvents(t){this.localEvents.push(t)}toJSON(){return this.externalDoc.toJSON()}getVersionHelper(){var o,r;return(r=(o=this.externalDoc).getVersionHelper)==null?void 0:r.call(o)}getContainerBlocks(t){return this.externalDoc.getContainerBlocks(t)}getBlockData(t,o){return this.externalDoc.getBlockData(t,o)}verifyBlockWritable(t,o){const r=this.editor.getBlockByIndex(t,o);g(Ro,this.editor.isBlockWritable(r),`block is not writable, ${t}, ${o}`)}localUpdateBlockText(t,o,r,i){g(Ro,!this.editor.readonly,"editor is readonly"),this.verifyBlockWritable(t,o);const s=this.getBlockData(t,o),l=s.text;g(Ro,l,`no text, ${t}, ${o}`);const a=ZA(this.editor,s.id,r,!0),d=ln.apply(l,r);this.localEvents.forEach(p=>p.onBeforeUpdateBlockText(t,s.id,l,d,a.toDocRange()));const h=this.externalDoc.localUpdateBlockText(t,o,r);return this.editor.selection.setRange(a,i),h}localUpdateBlockData(t,o,r,i){g(Ro,!this.editor.readonly,"editor is readonly");const s=this.editor.getBlockByIndex(t,o);if(!this.editor.isBlockWritable(s)){const h=Array.from(r.delete).filter(A=>A!=="comments"),p=Object.keys(r.insert).filter(A=>A!=="comments");(h.length>0||p.length>0)&&g(Ro,!1,`block is not writable, comment supported only, ${JSON.stringify(r)}}`)}const l=me.default(this.getBlockData(t,o)),a=me.default(aD(l,r));this.localEvents.forEach(h=>h.onBeforeUpdateBlockData(t,l.id,l,a,i));const d=this.externalDoc.localUpdateBlockData(t,o,r,i);return this.editor.selection.setRange(Si(this.editor,i)),d}localInsertBlock(t,o,r,i,s){g(Ro,!this.editor.readonly,"editor is readonly"),this.localEvents.forEach(a=>a.onBeforeInsertBlock(t,o,r,i));const l=this.externalDoc.localInsertBlock(t,o,r,i);return this.editor.selection.setRange(Si(this.editor,i),s),l}localDeleteBlock(t,o,r){g(Ro,!this.editor.readonly,"editor is readonly"),this.verifyBlockWritable(t,o);const i=me.default(this.getBlockData(t,o));this.localEvents.forEach(l=>l.onBeforeDeleteBlock(t,o,i,r));const s=this.externalDoc.localDeleteBlock(t,o,r);return this.editor.selection.setRange(Si(this.editor,r)),s}localDeleteChildContainers(t){return g(Ro,!this.editor.readonly,"editor is readonly"),t.forEach(o=>{const r=me.default(this.getContainerBlocks(o));this.localEvents.forEach(i=>i.onBeforeDeleteChildContainer(o,r))}),this.externalDoc.localDeleteChildContainers(t)}localInsertChildContainer(t,o){return g(Ro,!this.editor.readonly,"editor is readonly"),this.localEvents.forEach(r=>r.onBeforeInsertChildContainer(t,me.default(o))),this.externalDoc.localInsertChildContainer(t,o)}onRequestReload(t){Ro.debug(`reload doc: ${t}`),this.editor.reload(),this.callbacks.forEach(r=>{var i;return(i=r.onRequestReload)==null?void 0:i.call(r,t)});const o=!1;this.editor.emit("docChanged",this.editor,o)}onUpdateBlockText(t,o,r,i){this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockText)==null?void 0:l.call(s,t,o,r,i)}),cD(this.editor,t,o,r,i),this.editor.emit("docChanged",this.editor,i)}onUpdateBlockData(t,o,r,i){this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,t,o,r,i)}),GA(this.editor,t,o),this.editor.emit("docChanged",this.editor,i)}onInsertBlock(t,o,r,i){this.callbacks.forEach(l=>{var a;return(a=l.onInsertBlock)==null?void 0:a.call(l,t,o,r,i)});const s=this.editor.getContainerById(t);KE(this.editor,s,o,r),this.editor.emit("docChanged",this.editor,i)}onDeleteBlock(t,o,r){uD(this.editor,t,o,r),this.callbacks.forEach(s=>{var l;return(l=s.onDeleteBlock)==null?void 0:l.call(s,t,o,r)});const i=this.editor.getContainerById(t);rD(this.editor,i,o),this.editor.emit("docChanged",this.editor,r)}onInsertChildContainer(t,o,r){this.callbacks.forEach(i=>{var s;return(s=i.onInsertChildContainer)==null?void 0:s.call(i,t,o,r)})}onDeleteChildContainer(t,o){this.callbacks.forEach(r=>{var i;return(i=r.onDeleteChildContainer)==null?void 0:i.call(r,t,o)})}onCustomMessage(t){this.callbacks.forEach(o=>{var r;return(r=o.onCustomMessage)==null?void 0:r.call(o,t)})}onStatusChanged(t){this.callbacks.forEach(o=>{var r;return(r=o.onStatusChanged)==null?void 0:r.call(o,t)})}onError(t){this.callbacks.forEach(o=>{var r;return(r=o.onError)==null?void 0:r.call(o,t)})}uploadResource(t,o){return this.externalDoc.uploadResource(t,o)}addResources(t){return this.externalDoc.addResources(t)}buildResourceUrl(t,o){return this.externalDoc.buildResourceUrl(t,o)}request(t,o){return this.externalDoc.request(t,o)}broadcastMessage(t){return this.externalDoc.broadcastMessage(t)}getUser(){return this.externalDoc.getUser()}getRemoteUsers(){return this.externalDoc.getRemoteUsers()}destroy(){this.externalDoc.destroy(),this.clearCallbacks()}getServerMeta(){var t,o,r;return(r=(o=(t=this.externalDoc).getServerMeta)==null?void 0:o.call(t))!=null?r:{}}reset(t){Ro.log("reset doc"),this.externalDoc=t,this.externalDoc.registerCallback(this),this.editor.reload()}}function YA(n,e){if(n.length===0){n.push(e);return}const t=n[n.length-1];if(!t.combinable(e)){n.push(e);return}t.combine(e)}const ep=S("undo-action");class Kl{constructor(e,t,o){m(this,"beforeRange");m(this,"afterRange");this.containerId=t,this.beforeRange=e.selection.range.clone().toDocRange(),this.afterRange=o}undo(e){return!1}redo(e){return!1}combinable(e){return g(ep,e,"no other action"),!1}combine(e){g(ep,!1,"no other")}setAfterRange(e){this.afterRange&&ep.warn("after range has already set"),this.afterRange=e}}const hD=S("block-action");class JA extends Kl{constructor(t,o,r,i,s){super(t,o,s);m(this,"blockData");m(this,"blockIndex");this.blockData=me.default(i),this.blockIndex=r}deleteBlock(t,o){if(!t.getContainerById(this.containerId))return!1;const i=t.getBlockById(this.blockData.id);return i?(g(hD,this.blockIndex===be(i),"invalid block index"),wh(t,i,Si(t,o)),!0):!1}insertBlock(t,o){return Ql(t,this.containerId,this.blockIndex,me.default(this.blockData),o),!0}}class fD extends JA{undo(e){return this.deleteBlock(e,this.beforeRange)}redo(e){return this.insertBlock(e,this.afterRange)}}class mD extends JA{undo(e){return this.insertBlock(e,this.beforeRange)}redo(e){return this.deleteBlock(e,this.afterRange)}}class gD extends Kl{constructor(t){super(t,ae(t.rootContainer),t.selection.range.toDocRange());m(this,"actions",[])}addAction(t){YA(this.actions,t),this.afterRange=t.afterRange}undo(t){let o=!1;return this.actions.concat().reverse().forEach(r=>{r.undo(t)&&(o=!0)}),o}redo(t){let o=!1;return this.actions.forEach(r=>{r.redo(t)&&(o=!0)}),o}setAfterRange(t){this.afterRange=t;const o=this.actions[this.actions.length-1];!o||o instanceof Kl&&(o.afterRange||o.setAfterRange(t))}}const Hs=S("update-block-data-action");class _h extends Kl{constructor(t,o,r,i,s,l){super(t,o,l);m(this,"beforeBlockData");m(this,"afterBlockData");m(this,"blockId");this.blockId=r,g(Hs,this.blockId===i.id,"invalid block id"),g(Hs,this.blockId===s.id,"invalid block id"),this.beforeBlockData=me.default(i),this.afterBlockData=me.default(s),g(Hs,this.beforeBlockData.type===this.afterBlockData.type,"invalid block type")}undo(t){g(Hs,t,"no editor");const o=t.getBlockById(this.blockId);if(!o)return!1;const r=t.getContainerById(this.containerId);return g(Hs,r,"no container"),xh(t,o,_h.toAttributes(this.beforeBlockData),this.beforeRange),!0}redo(t){g(Hs,t,"no editor");const o=t.getBlockById(this.blockId);if(!o)return!1;const r=t.getContainerById(this.containerId);return g(Hs,r,"no container"),xh(t,o,_h.toAttributes(this.afterBlockData),this.afterRange),!0}static toAttributes(t){const o=me.default(t);return delete o.id,delete o.type,o}}const tp=S("update-block-text-action");class $a extends Kl{constructor(t,o,r,i,s,l){super(t,o,l);m(this,"beforeRichTextData");m(this,"afterRichTextData");m(this,"blockId");m(this,"type");this.blockId=r,this.beforeRichTextData=me.default(i),this.afterRichTextData=me.default(s),this.type=$a.calType(i,s)}static calType(t,o){g(tp,t,"no old data"),g(tp,o,"no new data");const i=ln.diff(t,o),s=new Set;let l=!1;const a=h=>gC(h)?`cjk_${h}`:fC(h)?"number":Ud(h)?"space":mC(h)?"letter":"unknown";let d=!1;return i.forEach(h=>{h.insert?h.insert===" "?s.add("insert_letter"):typeof h.insert=="string"&&h.insert.startsWith(" ")&&h.insert.length>1?(l=!0,d=!0,s.add(`insert_${a(h.insert.substr(1))}`)):s.add(`insert_${a(h.insert)}`):h.delete&&(l?l=!1:s.add("delete"))}),{textType:Array.from(s).join("|"),begin:d}}undo(t){if(!t.getContainerById(this.containerId))return!1;const r=t.getBlockById(this.blockId);return r?(Eh(t,r,this.beforeRichTextData),!0):!1}redo(t){if(!t.getContainerById(this.containerId))return!1;const r=t.getBlockById(this.blockId);return r?(Eh(t,r,this.afterRichTextData),!0):!1}combinable(t){if(!(t instanceof $a)||t.type.begin||this.type.textType!==t.type.textType||t.blockId!==this.blockId)return!1;const o=t.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(t){g(tp,t instanceof $a,"invalid action type");const o=t;this.afterRichTextData=o.afterRichTextData,this.afterRange=t.afterRange}}class KA extends Kl{constructor(e,t,o){super(e,t,e.selection.range.toDocRange()),this.blocks=o}deleteChildContainer(e){return e.doc.localDeleteChildContainers([this.containerId]),!0}insertChildContainer(e){return e.doc.localInsertChildContainer(this.containerId,me.default(this.blocks)),!0}}class pD extends KA{undo(e){return this.deleteChildContainer(e)}redo(e){return this.insertChildContainer(e)}}class CD extends KA{undo(e){return this.insertChildContainer(e)}redo(e){return this.deleteChildContainer(e)}}const Oo=S("undo");class AD{constructor(e){m(this,"editor");m(this,"actions",[]);m(this,"undoCursor");m(this,"currentGroup",null);m(this,"groupCounter",0);m(this,"undoRedoing",!1);m(this,"handleSelectionChange",e=>{if(this.currentGroup){this.currentGroup.setAfterRange(e.selection.range.toDocRange());return}const t=this.actions[this.actions.length-1];!t||t.afterRange||t.setAfterRange(e.selection.range.toDocRange())});this.editor=e,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(e){this.currentGroup?this.currentGroup.addAction(e):(YA(this.actions,e),setTimeout(()=>{this.editor.input.handleChanged(e)}))}beginGroup(){this.groupCounter===0?(g(Oo,!this.currentGroup,"current group already exists"),this.currentGroup=new gD(this.editor),this.groupCounter=1):(g(Oo,this.currentGroup,"current group not exists"),this.groupCounter+=1)}endGroup(){g(Oo,this.currentGroup,"current group not exists"),g(Oo,this.groupCounter>0,"group counter === 0"),this.groupCounter-=1,this.groupCounter===0&&(this.currentGroup.actions.length===0?Oo.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(e){this.beginGroup();try{const t=e();return setTimeout(()=>this.editor.selection.caret.update()),t}catch(t){throw Oo.error(`failed to run action: ${t.message}`),t}finally{this.endGroup()}}undo(){this.undoCursor===-1&&(this.undoCursor=this.actions.length);try{for(this.undoRedoing=!0;this.undoCursor>0;){this.undoCursor-=1;const e=this.actions[this.undoCursor];if(e.undo(this.editor)){try{this.editor.selection.setRange(Si(this.editor,e.beforeRange))}catch(t){Oo.error(`undo: failed to restore caret pos: ${t.message}`)}return this.editor.input.handleChanged(e),!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 e=this.actions[this.undoCursor];if(this.undoCursor+=1,e.redo(this.editor)){try{const t=e.afterRange;t?this.editor.selection.setRange(Si(this.editor,t)):Oo.warn("no after range")}catch(t){Oo.error(`redo: failed to set caret pos after redo: ${t.message}`)}return this.editor.input.handleChanged(e),!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 t;const e=this.undoCursor===-1?this.actions.length-1:this.undoCursor-1;return(t=this.actions[e])!=null?t:null}undoTo(e){for(;;){const t=this.lastAction();if(!t||t===e)return!0;if(!this.undo())return!1}}onBeforeUpdateBlockText(e,t,o,r,i){this.undoRedoing||(this.prepareSaveUndoState(),ln.diff(o,r).length!==0&&this.addAction(new $a(this.editor,e,t,o,r,i)))}onBeforeUpdateBlockData(e,t,o,r,i){if(this.undoRedoing)return;this.prepareSaveUndoState();const s=new _h(this.editor,e,t,o,r,i);this.addAction(s)}onBeforeInsertBlock(e,t,o,r){this.undoRedoing||(this.prepareSaveUndoState(),g(Oo,t>=0,"invalid block index"),g(Oo,o,"no block data"),this.addAction(new fD(this.editor,e,t,o,r)))}onBeforeDeleteBlock(e,t,o,r){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new mD(this.editor,e,t,o,r)))}onBeforeInsertChildContainer(e,t){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new pD(this.editor,e,t)))}onBeforeDeleteChildContainer(e,t){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new CD(this.editor,e,t)))}}class bD{async fromData(e,t){const o=t.getData("text/x-ones-editor-doc");if(o)return{"text/x-ones-editor-doc":JSON.parse(o)}}}class vD{constructor(){m(this,"converters",[]);this.addConverter(new bD)}async fromData(e,t,o){let r={};for(const i of this.converters){const s=await i.fromData(e,t,o);s&&(r={...r,...s})}return r}addConverter(e){this.converters.push(e)}}class yD{constructor(e){m(this,"renders",[]);this.editor=e}registerRender(e){this.renders.push(e)}renderText(e,t){const o={classes:[],attributes:{},styles:{}};return this.renders.forEach(r=>{if(r.renderText){const i=r.renderText(this.editor,e,t);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(e,t,o){const r={classes:[],attributes:{},styles:{}};return this.renders.forEach(i=>{if(i.renderBlock){const s=i.renderBlock(this.editor,t,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(e,t,o,r){this.renders.forEach(i=>{var s;(s=i.updateBlock)==null||s.call(i,e,t,o,r)})}}class pt extends bt.TypedEmitter{constructor(t){super();m(this,"hoveringBlock",null);m(this,"hoveringTextChild",null);m(this,"filters",[]);m(this,"finders",[]);m(this,"handleDocumentMouseMove",t=>{if(this.hoveringBlock){for(const s of this.filters)if(s.isInBlock(this.hoveringBlock,t))return}const o=document.elementFromPoint(t.x,t.y);if(!o){this.setHoveringBlock(null,t,null);return}let r=oe(o);if((!r||!Ke(this.editor.rootContainer,r))&&(r=this.findBlockByFinders(t),!r)){this.setHoveringBlock(null,t,null);return}const i=this.getParentTextContentChild(r,o);this.setHoveringBlock(r,t,i)});this.editor=t,document.addEventListener("mousemove",this.handleDocumentMouseMove)}destroy(){document.removeEventListener("mousemove",this.handleDocumentMouseMove),this.filters.forEach(t=>t.destroy()),this.filters=[],this.finders.forEach(t=>t.destroy()),this.finders=[]}addFilter(t){this.filters.push(t)}addFinder(t){this.finders.push(t)}hoveringBlockId(){return this.hoveringBlock?ie(this.hoveringBlock):""}findBlockByFinders(t){for(let o=0;o<this.finders.length;o++){const i=this.finders[o].findTargetBlock(this.editor,t);if(i)return i}return null}setHoveringBlock(t,o,r){if(this.hoveringBlock===t&&this.hoveringTextChild===r)return;if(this.hoveringBlock!==t){const s=this.hoveringBlock&&Ke(this.editor.rootContainer,this.hoveringBlock)?this.hoveringBlock:null;s&&te(s,"hover"),t&&W(t,"hover"),this.hoveringBlock=t,this.emit("change",this.hoveringBlock,s,o)}const i=this.hoveringTextChild;this.hoveringTextChild=r,this.emit("childChange",this.hoveringBlock,r,i,o)}static get(t){return t.addCustom("standard-hovering-block",()=>new pt(t))}getParentTextContentChild(t,o){if(!ee(this.editor,t))return null;const r=Re(t);return o.parentElement===r?o:$m(o)}}const XA="style-color-",eb="style-bg-color-";class kD{renderText(e,t,o){const r=[],i={},s={};return Object.entries(o).forEach(([l,a])=>{a===!0?l.startsWith(XA)?i["data-style-color"]=l.substring(XA.length):l.startsWith(eb)?i["data-style-bg-color"]=l.substring(eb.length):l.startsWith("style")&&r.push(l):typeof a=="string"&&(l==="link"&&(r.push("link"),i.link=a),l==="inline-style-color"&&(s.color=a))}),{classes:r,attributes:i,styles:s}}renderBlock(e,t,o){var l,a;const r={};Object.entries(o).filter(d=>d[0].startsWith("style-")).forEach(([d,h])=>{r[`data-${d}`]=`${h}`});const s=[];return((a=(l=e.selection)==null?void 0:l.range)==null?void 0:a.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"),pt.get(e).hoveringBlockId()===o.id&&s.push("hover"),{attributes:r,classes:s}}updateBlock(e,t,o,r){var s,l;Array.from(o.attributes).forEach(a=>{a.name.startsWith("data-style-")&&o.removeAttribute(a.name)}),Object.entries(r).filter(a=>a[0].startsWith("style-")||a[0]==="align").forEach(([a,d])=>{a==="align"&&o.setAttribute(a.startsWith("style-")?`data-${a}`:`data-style-${a}`,`${d}`)}),((l=(s=e.selection)==null?void 0:s.range)==null?void 0:l.start.blockId)===r.id&&W(o,"focused"),pt.get(e).hoveringBlockId()===r.id&&W(o,"hover")}}function wD(n){n.editorBlocks.registerBlockClass(In),n.editorBlocks.registerBlockClass(B4),n.editorBoxes.registerBoxClass(f6),n.editorBoxes.registerBoxClass(m6),n.editorBoxes.registerBoxClass(C6),n.editorBoxes.registerBoxClass(A6),n.editorInsertions.registerInsertionClass(b6),n.editorBlockRenders.registerRender(new kD)}function BD(n,e){wD(n),e!=null&&e.blocks&&e.blocks.forEach(t=>n.editorBlocks.registerBlockClass(t)),e!=null&&e.boxes&&e.boxes.forEach(t=>n.editorBoxes.registerBoxClass(t)),e!=null&&e.embeds&&e.embeds.forEach(t=>n.editorEmbeds.registerEmbedClass(t)),e!=null&&e.insertions&&e.insertions.forEach(t=>n.editorInsertions.registerInsertionClass(t)),e!=null&&e.decorators&&e.decorators.forEach(t=>n.editorDecorators.registerDecorator(t)),e!=null&&e.dataConverters&&e.dataConverters.forEach(t=>n.dataConverter.addConverter(t)),e!=null&&e.commandProviders&&e.commandProviders.forEach(t=>n.editorCommandProviders.registerCommandProvider(t)),e!=null&&e.textRenders&&e.textRenders.forEach(t=>n.editorBlockRenders.registerRender(t))}const tb=S("range-commands");function nb(n,e){n.forEach(t=>{t.source=e,t.children&&nb(t.children,e)})}function ob(n,e,t){const o=ie(e);g(tb,o===t.start.blockId,"invalid start range"),g(tb,o===t.end.blockId,"invalid end range");const r=n.editorCommandProviders.getCommandProviders();let i=[];return r.forEach(s=>{const l=s.getAvailableCommands(n,e,t);nb(l,s.id),i.push(...l)}),r.forEach(s=>{if(s.filterCommands){const l=s.filterCommands(n,e,t,i);l&&(i=l)}}),Le(n,e)&&Os(n,e,t.start,t.end).forEach(l=>{vt(l).forEach(d=>{const h=ue(n,d),p=Ut(n,{anchor:se(d,0,"home"),focus:se(d,h,"end")}),A=ob(n,d,p);i.push(...A)})}),i}function rb(n){const e=n.getEditor(),t=n.getSelectedBlocks(),o=[];return t.forEach(r=>{const i=Ut(e,{anchor:r.start,focus:r.end});ob(e,r.block,i).forEach(l=>{o.push(l)})}),o}function ib(n,e,t,o,r,i){var h;const s=n.editorCommandProviders.getCommandProviders();for(let p=0;p<s.length;p++){const A=s[p];if(A.beforeExecuteCommand&&A.beforeExecuteCommand(n,e,t,o,r))return!1}const l=n.editorCommandProviders.getCommandProvider(o.source),a={};if((h=l.executeCommand)!=null&&h.call(l,n,e,t,o,r,{}))return i[ie(e)]=a,!0;let d=!1;return Le(n,e)&&Os(n,e,t.start,t.end).forEach(A=>{vt(A).forEach(B=>{const D=ue(n,B),I=Ut(n,{anchor:se(B,0,"home"),focus:se(B,D,"end")});ib(n,B,I,o,r,i)&&(d=!0)})}),s.forEach(p=>{p.afterExecuteCommand&&p.afterExecuteCommand(n,e,t,o,r,i)}),d}function sb(n,e,t){const o=n.getEditor(),r={},i=o.editorCommandProviders.getCommandProvider(e.source);return i.executeRangeCommand&&i.executeRangeCommand(o,n,e,t,r)||n.getSelectedBlocks().forEach(l=>{const a=Ut(o,{anchor:l.start,focus:l.end});ib(o,l.block,a,e,t,r)}),r}const ED=S("command-providers");class lb{constructor(e){m(this,"providers",[]);this.editor=e}registerCommandProvider(e){this.providers.push(e)}getCommandProviders(){return this.providers}getCommandProvider(e){const t=this.providers.find(o=>o.id===e);return g(ED,t,`no command provider, id=${e}`),t}getCommands(e){return rb(e)}executeCommand(e,t,o){return this.editor.undoManager.runInGroup(()=>sb(e,t,o))}getEmptyBlockTextAttributes(e,t){let o={};if(this.providers.forEach(r=>{var s;const i=(s=r.getEmptyBlockTextAttributes)==null?void 0:s.call(r,e,t);i&&(o={...o,...i})}),Object.keys(o).length!==0)return o}}function xD(n,e){const t=ne(e),o=ae(t),r=be(e);GA(n,o,r)}const ID=S("table-scroll");class cb{constructor(e,t,o,r,i){m(this,"handleEvent",e=>{this.handler(this.editor,e,this.data)});this.editor=e,this.dom=t,this.name=o,this.handler=r,this.data=i,t.addEventListener(o,this.handleEvent)}destroy(){this.dom.removeEventListener(this.name,this.handleEvent)}}class TD{constructor(e){m(this,"handlers",new Map);this.editor=e}destroy(){Array.from(this.handlers.entries()).forEach(([e,t])=>{t.forEach(o=>o.destroy()),this.handlers.delete(e)})}addEventListener(e,t,o,r){const i=this.handlers.get(e);if(i){if(i.find(s=>s.handler===o&&s.name===t)){ID.warn(`event has already registered: ${t}`);return}i.push(new cb(this.editor,e,t,o,r))}else{const s=new cb(this.editor,e,t,o,r);this.handlers.set(e,[s])}}removeEventListener(e,t,o){if(!e){for(const[i,s]of Array.from(this.handlers.entries()))for(let l=s.length-1;l>=0;l--){const a=s[l];if(t)t===a.name&&o===a.handler&&s.splice(l,1);else if(o===a.handler){s.splice(l,1),a.destroy(),s.length===0&&this.handlers.delete(i);continue}}return}const r=this.handlers.get(e);if(r){const i=r.findIndex(s=>s.handler===o&&s.name===t);if(i!==-1){const s=r[i];r.splice(i,1),s.destroy(),r.length===0&&this.handlers.delete(e)}}}removeAllListeners(e,t){const o=this.handlers.get(e);if(o)if(t)for(let r=0;r<o.length;r++){const i=o[r];i.name===t&&(o.splice(r,1),i.destroy())}else o.forEach(r=>{r.destroy()}),this.handlers.delete(e)}}const ab=S("update-block-text");function DD(n,e){const t=n.getBoxById(e.id),o=oe(t);g(ab,o,"no parent block"),g(ab,ee(n,o),"not a text block");const r=n.getBlockText(o),i=r6(r,"id",e.id,e);j6(n,o,i)}function SD(n,e){for(const t of n.blockHooks)if(t.writable){const o=t.writable(n,e);if(typeof o=="boolean")return o}return!0}function LD(n){return n.readonly?!1:!Lo(n).find(o=>!n.isBlockWritable(o.block))}class MD{constructor(e){this.editor=e}getKey(e){return`${this.editor.id}-${e}`}getItem(e){return window.localStorage.getItem(this.getKey(e))}setItem(e,t){if(!t){this.removeItem(e);return}window.localStorage.setItem(this.getKey(e),t)}removeItem(e){window.localStorage.removeItem(this.getKey(e))}}class RD{constructor(){m(this,"shortcuts",[])}handleKeyboardEvents(e,t){const o=this.shortcuts;for(const r of o){const i=Object.entries(r);for(const[s,l]of i)if(Or(t,s)){const a=l(e,t);if(a!==void 0)return a}}}}const Vr=S("editor");class OD extends bt.TypedEmitter{constructor(t,o,r){var i,s,l,a,d,h,p;super();m(this,"parent");m(this,"rootElement");m(this,"contentElement");m(this,"rootContainerObject");m(this,"rootContainer");m(this,"input");m(this,"selection");m(this,"selectionHandler");m(this,"doc");m(this,"id");m(this,"clientId");m(this,"compositingText","");m(this,"undoManager");m(this,"shortcuts",new RD);m(this,"dataConverter",new vD);m(this,"editorBlocks",new v4(this));m(this,"editorBoxes",new p6(this));m(this,"editorInsertions",new y6(this));m(this,"editorEmbeds",new k4(this));m(this,"editorDecorators",new k6(this));m(this,"editorCommandProviders",new lb(this));m(this,"editorBlockRenders",new yD(this));m(this,"blockHooks",[]);m(this,"domEvents",new TD(this));m(this,"customs",new Map);m(this,"options");m(this,"inputHandlers",new oD(this));m(this,"settingsProvider");m(this,"_readonly",!1);Vr.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=(a=r==null?void 0:r.settingsProvider)!=null?a:new MD(this),BD(this,r==null?void 0:r.components),this.blockHooks.push(...(h=(d=r==null?void 0:r.components)==null?void 0:d.blockHooks)!=null?h:[]),this.id=(p=r==null?void 0:r.id)!=null?p:K(),this.clientId=K(),this.undoManager=new AD(this),this.doc=new dD(this,o,this.undoManager),this.parent=t,this.rootElement=w("div",["editor-root"],this.parent),this.rootElement.setAttribute("data-editor-client-id",this.clientId),this.contentElement=w("div",["editor-content"],this.rootElement),this.rootContainerObject=C4(this),this.rootContainer=this.rootContainerObject.rootContainer,this.input=new VI(this,this.inputHandlers),this.selection=new LT(this),this.selectionHandler=new OT(this),r!=null&&r.shortcuts&&this.shortcuts.shortcuts.push(...r.shortcuts),Kt.isMobile&&W(this.rootElement,"mobile"),Kt.isSafari&&W(this.rootElement,"safari"),this._readonly&&W(this.rootElement,"readonly"),this.emit("load",this,!1)}get readonly(){return this._readonly}set readonly(t){this._readonly=t,t?W(this.rootElement,"readonly"):te(this.rootElement,"readonly"),this.emit("readonlyChanged",this)}get scrollContainer(){return this.options.scrollContainer?this.options.scrollContainer:oo(this.rootContainer)}addCustom(t,o){const r=this.customs.get(t);if(r)return r;const i=o(this);return this.customs.set(t,i),i}getCustom(t){const o=this.customs.get(t);return g(Vr,o,`${t} does not exists`),o}replaceCustom(t,o){const r=this.customs.get(t);return r&&r.destroy(),this.customs.set(t,o),o}findCustom(t){return this.customs.get(t)}findCustomByType(t){const o=this.customs.values();for(const r of o)if(r instanceof t)return r;return null}destroyCustom(t){const o=this.customs.get(t);o&&(this.customs.delete(t),o.destroy())}getComponentOptions(t){return this.options.componentsOptions[t]}registerLocalEvents(t){this.doc.registerLocalEvents(t)}reload(){this.rootContainerObject.reload(),this.emit("load",this,!0)}createBlock(t,o,r){return this.editorBlocks.createBlock(t,o,r)}createBox(t,o){return this.editorBoxes.createBox(t,o)}createInsertion(t,o){return this.editorInsertions.createInsertion(t,o)}destroy(){Vr.debug("destroy editor"),this.emit("destroy",this),this.input.destroy(),this.rootContainerObject.destroy(),this.rootElement.remove(),this.doc.destroy(),this.customs.forEach(t=>t.destroy()),this.customs.clear(),this.selection.destroy(),this.domEvents.destroy(),this.removeAllListeners(),this.inputHandlers.destroy()}focus(){this.input.focus()}focusToBlock(t,o){Pg(this,t,o)}isWritable(){return LD(this)}isBlockWritable(t){return SD(this,t)}getChildContainerData(t){const o=this.doc.getContainerBlocks(t);return g(Vr,o,`no child container data: ${t}, ${JSON.stringify(this.doc)}`),g(Vr,Array.isArray(o),`container data is not an array: ${JSON.stringify(o)}`),o}createChildContainer(t,o,r){return A4(this,t,o,r)}getFirstBlock(){return this.rootContainer.querySelector("[data-type=editor-block]")}getLastBlock(){const t=Array.from(this.rootContainer.querySelectorAll(":scope [data-type=editor-block]"));return t[t.length-1]}getFocusedBlock(){return this.selection.getFocusedBlock()}findBlockById(t){const o=this.rootContainer.querySelector(`#${t}`);return o&&g(Vr,xs(o),"not an valid block element"),o!=null?o:null}findBoxById(t){const o=this.rootContainer.querySelector(`#${t}`);return o&&g(Vr,Nm(o),"not an valid box element"),o!=null?o:null}getBlockById(t){const o=this.findBlockById(t);return g(Vr,o,`no block, id=${t}`),o}getBoxById(t){const o=this.findBoxById(t);return g(Vr,o,`no box, id=${t}`),o}getBlockByIndex(t,o){const r=this.getContainerById(t);return _r(r,o)}getBlockIndex(t){if(typeof t=="string"){const o=this.getBlockById(t);return be(o)}return be(t)}getContainerById(t){return $r(this,t)}getParentContainer(t){return ne(t)}reloadBlock(t){xD(this,t)}contains(t){const o=t instanceof Element?t:t.parentElement;return o?o.closest("div.editor-root")===this.rootElement:!1}insertBlock(t,o,r,i,s){const l={blockId:r.id,offset:0},a={anchor:l,focus:l};return Ql(this,t,o,r,i!=null?i:a,s)}insertEmbed(t,o,r,i,s){const l={id:K(),type:"embed",embedType:r,embedData:i};return this.insertBlock(t,o,l,s)}deleteBlock(t,o){Og(this,t,o)}mergeTextBlock(t,o){return N6(this,t,o)}breakTextBlock(t,o,r){return Yl(this,t,o,r).newBlock}getTextPosition(){return Gl(this)}getBlockString(t,o){const r=this.getBlockText(t);return rt(r,o)}getBlockData(t){return _i(this,t)}getBoxData(t){return d6(this,t)}getBlockText(t){return mn(this,t)}setBlockText(t,o){j6(this,t,o)}deleteTextFromBlock(t,o,r,i){return Mg(this,t,o,r,i)}insertTextToBlock(t,o,r,i){return L6(this,t,o,r,i)}insertBoxToBlock(t,o,r){return M6(this,t,o,r)}pasteDoc(t){return this.inputHandlers.pasteDoc(t)}insertDoc(t,o,r,i){V6(this,t,o,r,i)}insertDocAt(t,o,r,i){return Hg(this,t,o,r,i)}deleteChildContainers(t){P6(this,t)}replaceBlockText(t,o){return Eh(this,t,o)}updateBlockData(t,o,r){const i={...this.getBlockData(t),...o},{id:s,type:l,...a}=i;return xh(this,t,a,(r!=null?r:this.selection.range).toDocRange())}updateEmbedData(t,o,r){return U6(this,t,o,r)}updateBoxData(t){DD(this,t)}getSelectedText(){const t=Dh(this);return La(this,t)}clearSelectedContents(){Fg(this)}insertTextBlock(t,o,r,i){const s=sr(t!=null?t:"");return F6(this,s,o,r,i==null?void 0:i.newRange,i==null?void 0:i.insertBlockOptions)}updateCompositionText(t,o){if(t&&!o&&(this.selection.range.isCollapsed()||this.clearSelectedContents()),!t&&!o){O6(this);return}o?(this.compositingText="",Em()||Lg(this,t)):(this.compositingText=t,R6(this))}getColor(t){const o=this.options.colors;return o.length===0?"#FF1A75":o[t%o.length]}}function Ha(n,e,t){return new OD(n,e,t)}function _D(n){const e=(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=fm.default(s.states,r.states)}},t=[];return n.forEach(o=>{o.forEach(r=>{e(t,r)})}),t}const FD=["#FBBFBD","#FFDDB6","#FFF897","#C5F0C1","#CEDDFE","#DCC9FC","#E5E6E8","#F76964","#FFA53D","#FFE928","#63D156","#A0BBFE","#C4A5FB","#BBBFC3"];class Fh extends bt.TypedEmitter{constructor(t){super();m(this,"users",new Map);m(this,"cursors",new Map);m(this,"addingUser",!1);m(this,"colors");this.colors=t&&t.length>0?t:FD}setCursor(t){this.addUser(t.user);const o=this.cursors.get(t.user.userId);if(o&&ua.default(o,t))return;this.cursors.set(t.user.userId,t);const r=new Set([t.range.anchor.blockId,t.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(t){this.addingUser=!0,t.forEach(o=>this.addUser(o)),this.addingUser=!1,this.emit("change",Array.from(this.users.values()))}addUser(t){this.users.set(t.userId,t),this.addingUser||this.emit("change",Array.from(this.users.values()))}findUser(t){var o;return(o=this.users.get(t))!=null?o:null}removeUser(t){this.users.delete(t),this.cursors.delete(t),this.emit("change",Array.from(this.users.values()))}updateUsers(t){this.users.clear(),this.addingUser=!0;try{t.forEach(o=>{this.addUser(o)})}finally{this.addingUser=!1}setTimeout(()=>{this.emit("change",Array.from(this.users.values()))},300)}getSimpleCursors(t){const o=new Map;return Array.from(this.cursors.values()).filter(r=>r.range.anchor.blockId===t&&mh(r.range)).forEach(r=>{const i=r.range.focus.offset;let s=o.get(i);s||(s=[],o.set(i,s)),s.push(r)}),o}getCursors(t){return Array.from(this.cursors.values()).filter(o=>o.range.anchor.blockId===t||o.range.focus.blockId===t)}onUpdateBlockText(t,o,r){if(!t.text)return;this.getCursors(t.id).forEach(l=>{if(mh(l.range)){const{anchor:a,focus:d}=l.range;a.blockId===t.id&&(a.offset=ln.transformCursor(a.offset,o,r)),d.blockId===t.id&&(d.offset=ln.transformCursor(d.offset,o,r))}})}getFixedUserColor(t,o){let r=0;Array.from(t).forEach(s=>{r+=s.charCodeAt(0)});const i=r%this.colors.length;return this.colors[i]}destroy(){this.removeAllListeners()}}const Xt=S("local-doc");class np extends fa{constructor(t,o){super();m(this,"doc");m(this,"serviceUrl");t?this.doc=t:this.doc={meta:{},comments:{},blocks:{root:[sr("")]}},this.serviceUrl=(o==null?void 0:o.serverUrl)||""}beginBatchUpdate(){return 0}endBatchUpdate(){return 0}toJSON(){return me.default(this.doc)}getContainerBlocks(t){return this.doc.blocks[t]}getBlockData(t,o){const r=this.getContainerBlocks(t);g(Xt,r,`no container data: ${t}`);const i=r[o];return g(Xt,i,`no block data: ${o}`),i}localUpdateBlockText(t,o,r){const i=this.getBlockData(t,o);g(Xt,i.text,"no text for data");const s=ln.apply(i.text,r);return i.text=s,g(Xt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(l=>{var a;return(a=l.onUpdateBlockText)==null?void 0:a.call(l,t,o,r,!0)}),s}localUpdateBlockData(t,o,r){const i=this.getBlockData(t,o);return r.delete.forEach(s=>delete i[s]),Object.entries(r.insert).forEach(([s,l])=>{i[s]=l}),g(Xt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,t,o,r,!0)}),i}localInsertBlock(t,o,r){const i=this.getContainerBlocks(t);return g(Xt,i,`no container data: ${t}`),g(Xt,o>=0&&o<=i.length,`invalid block index: ${o}, ${i.length}`),i.splice(o,0,r),g(Xt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onInsertBlock)==null?void 0:l.call(s,t,o,r,!0)}),r}localDeleteBlock(t,o){const r=this.getContainerBlocks(t);g(Xt,r,`no container data: ${t}`),g(Xt,o>=0&&o<=r.length,`invalid block index: ${o}, ${r.length}`);const i=r[o];return r.splice(o,1),g(Xt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onDeleteBlock)==null?void 0:l.call(s,t,o,!0)}),i}localInsertChildContainer(t,o){this.doc.blocks[t]=o,g(Xt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onInsertChildContainer)==null?void 0:i.call(r,t,o,!0)})}localDeleteChildContainers(t){Xt.debug(`delete child containers: ${t}`),t.forEach(o=>{g(Xt,this.doc.blocks[o],`no child container: ${o}`),delete this.doc.blocks[o]}),t.forEach(o=>{g(Xt,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(t,o){g(Xt,!1,"not implemented")}async addResources(t){return t}buildResourceUrl(t){return t}request(t,o){g(Xt,!1,"not implemented")}broadcastMessage(t){}getServerMeta(){return{serverId:this.serviceUrl}}getUser(){return{permission:"w",userId:"-",displayName:"-",avatarUrl:"-",rainbowIndex:0}}getRemoteUsers(){return new Fh}setDoc(t){this.doc=me.default(t),this.callbacks.forEach(o=>{var r;return(r=o.onRequestReload)==null?void 0:r.call(o,"change doc")})}destroy(){this.clearCallbacks()}}class PD{constructor(e){this.cleanup=e}destroy(){var e;(e=this.cleanup)==null||e.call(this)}}function op(n,e,t){n.addCustom(e,()=>{var i;const o=(i=t())!=null?i:void 0;return new PD(o)})}const ub=S("find-block");function db(n,e){const t=Ds(e);if(!t){if(ro(e))return null;const o=Is(e);return g(ub,o,"no parent block"),db(n,o)}return Le(n,t)?Vl(n,t,{visibleOnly:!0}):t}function hb(n,e){const t=Ss(e);if(!t){if(ro(e))return null;const o=Is(e);return g(ub,o,"no parent block"),hb(n,o)}return Le(n,t)?tg(n,t,{visibleOnly:!0}):t}const ND=S("remote-cursor");class $D{constructor(){m(this,"remoteUsers",new Fh)}onCustomMessage(e){const t=e;if(t.type==="onlineUsers"){const o=t;this.handleUpdateUsers(o.users)}else t.type==="caret"?this.handleUpdateCaret(t):ND.debug(`unknown remote message received: ${e}`)}handleUpdateUsers(e){this.remoteUsers.updateUsers(e)}handleUpdateCaret(e){const t=this.remoteUsers.findUser(e.userId);!t||this.remoteUsers.setCursor({oneseditor:"cursor",user:t,range:e.range,time:Date.now()})}destroy(){this.remoteUsers.destroy()}}function HD(n){const{blocks:e,meta:t,comments:o,...r}=n;return{rootBlocks:e,meta:t,comments:o,childBlocks:r}}function jD(n){const{blocks:e,meta:t,comments:o}=n,{root:r,...i}=e;return{blocks:r,meta:t,comments:o,...i}}function ja(n){const{childBlocks:e,meta:t,comments:o,rootBlocks:r}=HD(me.default(n));return{blocks:{root:r,...e},meta:t,comments:o}}function Ni(n){return n==="root"?"blocks":n}function Xl(n){return n==="blocks"?"root":n}const UD={type:{name:"rich-text",uri:"http://sharejs.org/types/rich-text/v1",create(n){return new on.default(n)},apply(n,e){const t=new on.default(n),o=new on.default(e);return t.compose(o).ops},compose(n,e){const t=new on.default(n),o=new on.default(e);return t.compose(o).ops},diff(n,e){const t=new on.default(n),o=new on.default(e);return t.diff(o).ops},transform(n,e,t){const o=new on.default(n);return new on.default(e).transform(o,t==="left").ops},transformCursor(n,e,t){return e.transformPosition(n,!t)},normalize(n){return n},serialize(n){return n.ops},deserialize(n){return n},transformPresence(n,e,t){if(!n)return null;const o=new on.default(e),r=this.transformCursor(n.index,o,t),i=this.transformCursor(n.index+n.length,o,t);return{...n,index:r,length:i-r}}}};var cr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},$i={},rp=G5.default.EventEmitter;$i.EventEmitter=rp,$i.mixin=zD;function zD(n){for(var e in rp.prototype)n.prototype[e]=rp.prototype[e]}var fb=["info","warn","error"];function mb(){var n={};fb.forEach(function(e){n[e]=console[e].bind(console)}),this.setMethods(n)}var VD=mb;mb.prototype.setMethods=function(n){n=n||{};var e=this;fb.forEach(function(t){typeof n[t]=="function"&&(e[t]=n[t])})};var WD=VD,qD=new WD,gb=qD;function js(n,e){this.code=n,this.message=e||"",Error.captureStackTrace?Error.captureStackTrace(this,js):this.stack=new Error().stack}js.prototype=Object.create(Error.prototype),js.prototype.constructor=js,js.prototype.name="ShareDBError",js.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 Ph=js,Ua={},pb=GD;function GD(n,e,t,o){var r=function(s,l,a,d){e(a,s,l,"left"),e(d,l,s,"right")},i=n.transformX=function(s,l){t(s),t(l);for(var a=[],d=0;d<l.length;d++){for(var h=l[d],p=[],A=0;A<s.length;){var v=[];if(r(s[A],h,p,v),A++,v.length===1)h=v[0];else if(v.length===0){for(var B=A;B<s.length;B++)o(p,s[B]);h=null;break}else{for(var D=i(s.slice(A),v),I=0;I<D[0].length;I++)o(p,D[0][I]);for(var _=0;_<D[1].length;_++)o(a,D[1][_]);h=null;break}}h!=null&&o(a,h),s=p}return[s,a]};n.transform=function(s,l,a){if(!(a==="left"||a==="right"))throw new Error("type must be 'left' or 'right'");return l.length===0?s:s.length===1&&l.length===1?e([],s[0],l[0],a):a==="left"?i(s,l)[0]:i(l,s)[1]}}var Cb={exports:{}},Hi=Cb.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||""}},ip=function(n,e,t){return n.slice(0,e)+t+n.slice(e)},sp=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")},Nh=function(n){for(var e=0;e<n.length;e++)sp(n[e])};Hi.apply=function(n,e){var t;Nh(e);for(var o=0;o<e.length;o++){var r=e[o];if(r.i!=null)n=ip(n,r.p,r.i);else{if(t=n.slice(r.p,r.p+r.d.length),r.d!==t)throw new Error("Delete component '"+r.d+"' does not match deleted text '"+t+"'");n=n.slice(0,r.p)+n.slice(r.p+r.d.length)}}return n};var Wr=Hi._append=function(n,e){if(!(e.i===""||e.d===""))if(n.length===0)n.push(e);else{var t=n[n.length-1];t.i!=null&&e.i!=null&&t.p<=e.p&&e.p<=t.p+t.i.length?n[n.length-1]={i:ip(t.i,e.p-t.p,e.i),p:t.p}:t.d!=null&&e.d!=null&&e.p<=t.p&&t.p<=e.p+e.d.length?n[n.length-1]={d:ip(e.d,t.p-e.p,t.d),p:e.p}:n.push(e)}};Hi.compose=function(n,e){Nh(n),Nh(e);for(var t=n.slice(),o=0;o<e.length;o++)Wr(t,e[o]);return t},Hi.normalize=function(n){var e=[];(n.i!=null||n.p!=null)&&(n=[n]);for(var t=0;t<n.length;t++){var o=n[t];o.p==null&&(o.p=0),Wr(e,o)}return e};var lp=function(n,e,t){return e.i!=null?e.p<n||e.p===n&&t?n+e.i.length:n:n<=e.p?n:n<=e.p+e.d.length?e.p:n-e.d.length};Hi.transformCursor=function(n,e,t){for(var o=t==="right",r=0;r<e.length;r++)n=lp(n,e[r],o);return n};var ZD=Hi._tc=function(n,e,t,o){if(sp(e),sp(t),e.i!=null)Wr(n,{i:e.i,p:lp(e.p,t,o==="right")});else if(t.i!=null){var r=e.d;e.p<t.p&&(Wr(n,{d:r.slice(0,t.p-e.p),p:e.p}),r=r.slice(t.p-e.p)),r!==""&&Wr(n,{d:r,p:e.p+t.i.length})}else if(e.p>=t.p+t.d.length)Wr(n,{d:e.d,p:e.p-t.d.length});else if(e.p+e.d.length<=t.p)Wr(n,e);else{var i={d:"",p:e.p};e.p<t.p&&(i.d=e.d.slice(0,t.p-e.p)),e.p+e.d.length>t.p+t.d.length&&(i.d+=e.d.slice(t.p+t.d.length-e.p));var s=Math.max(e.p,t.p),l=Math.min(e.p+e.d.length,t.p+t.d.length),a=e.d.slice(s-e.p,l-e.p),d=t.d.slice(s-t.p,l-t.p);if(a!==d)throw new Error("Delete ops delete different text in the same region of the document");i.d!==""&&(i.p=lp(i.p,t),Wr(n,i))}return n},QD=function(n){return n.i!=null?{d:n.i,p:n.p}:{i:n.d,p:n.p}};Hi.invert=function(n){n=n.slice().reverse();for(var e=0;e<n.length;e++)n[e]=QD(n[e]);return n},pb(Hi,ZD,Nh,Wr);var $h=function(n){return Object.prototype.toString.call(n)=="[object Array]"},YD=function(n){return!!n&&n.constructor===Object},_o=function(n){return JSON.parse(JSON.stringify(n))},Ie={name:"json0",uri:"http://sharejs.org/types/JSONv0"},qr={};Ie.registerSubtype=function(n){qr[n.name]=n},Ie.create=function(n){return n===void 0?null:_o(n)},Ie.invertComponent=function(n){var e={p:n.p};return n.t&&qr[n.t]&&(e.t=n.t,e.o=qr[n.t].invert(n.o)),n.si!==void 0&&(e.sd=n.si),n.sd!==void 0&&(e.si=n.sd),n.oi!==void 0&&(e.od=n.oi),n.od!==void 0&&(e.oi=n.od),n.li!==void 0&&(e.ld=n.li),n.ld!==void 0&&(e.li=n.ld),n.na!==void 0&&(e.na=-n.na),n.lm!==void 0&&(e.lm=n.p[n.p.length-1],e.p=n.p.slice(0,n.p.length-1).concat([n.lm])),e},Ie.invert=function(n){for(var e=n.slice().reverse(),t=[],o=0;o<e.length;o++)t.push(Ie.invertComponent(e[o]));return t},Ie.checkValidOp=function(n){for(var e=0;e<n.length;e++)if(!$h(n[e].p))throw new Error("Missing path")},Ie.checkList=function(n){if(!$h(n))throw new Error("Referenced element not a list")},Ie.checkObj=function(n){if(!YD(n))throw new Error("Referenced element not an object (it was "+JSON.stringify(n)+")")};function za(n){n.t="text0";var e={p:n.p.pop()};n.si!=null&&(e.i=n.si),n.sd!=null&&(e.d=n.sd),n.o=[e]}function Va(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}Ie.apply=function(n,e){Ie.checkValidOp(e),e=_o(e);for(var t={data:n},o=0;o<e.length;o++){var r=e[o];(r.si!=null||r.sd!=null)&&za(r);for(var i=null,s=t,l="data",a=0;a<r.p.length;a++){var d=r.p[a];if(i=s,s=s[l],l=d,i==null)throw new Error("Path invalid")}if(r.t&&r.o!==void 0&&qr[r.t])s[l]=qr[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)Ie.checkList(s),s[l]=r.li;else if(r.li!==void 0)Ie.checkList(s),s.splice(l,0,r.li);else if(r.ld!==void 0)Ie.checkList(s),s.splice(l,1);else if(r.lm!==void 0){if(Ie.checkList(s),r.lm!=l){var h=s[l];s.splice(l,1),s.splice(r.lm,0,h)}}else if(r.oi!==void 0)Ie.checkObj(s),s[l]=r.oi;else if(r.od!==void 0)Ie.checkObj(s),delete s[l];else throw new Error("invalid / missing instruction in op")}return t.data},Ie.shatter=function(n){for(var e=[],t=0;t<n.length;t++)e.push([n[t]]);return e},Ie.incrementalApply=function(n,e,t){for(var o=0;o<e.length;o++){var r=[e[o]];n=Ie.apply(n,r),t(r,n)}return n};var JD=Ie.pathMatches=function(n,e,t){if(n.length!=e.length)return!1;for(var o=0;o<n.length;o++)if(n[o]!==e[o]&&(!t||o!==n.length-1))return!1;return!0};Ie.append=function(n,e){if(e=_o(e),n.length===0){n.push(e);return}var t=n[n.length-1];if((e.si!=null||e.sd!=null)&&(t.si!=null||t.sd!=null)&&(za(e),za(t)),JD(e.p,t.p))if(e.t&&t.t&&e.t===t.t&&qr[e.t]){if(t.o=qr[e.t].compose(t.o,e.o),e.si!=null||e.sd!=null){for(var o=e.p,r=0;r<t.o.length-1;r++)e.o=[t.o.pop()],e.p=o.slice(),Va(e),n.push(e);Va(t)}}else t.na!=null&&e.na!=null?n[n.length-1]={p:t.p,na:t.na+e.na}:t.li!==void 0&&e.li===void 0&&e.ld===t.li?t.ld!==void 0?delete t.li:n.pop():t.od!==void 0&&t.oi===void 0&&e.oi!==void 0&&e.od===void 0?t.oi=e.oi:t.oi!==void 0&&e.od!==void 0?e.oi!==void 0?t.oi=e.oi:t.od!==void 0?delete t.oi:n.pop():e.lm!==void 0&&e.p[e.p.length-1]===e.lm||n.push(e);else(e.si!=null||e.sd!=null)&&(t.si!=null||t.sd!=null)&&(Va(e),Va(t)),n.push(e)},Ie.compose=function(n,e){Ie.checkValidOp(n),Ie.checkValidOp(e);for(var t=_o(n),o=0;o<e.length;o++)Ie.append(t,e[o]);return t},Ie.normalize=function(n){var e=[];n=$h(n)?n:[n];for(var t=0;t<n.length;t++){var o=n[t];o.p==null&&(o.p=[]),Ie.append(e,o)}return e},Ie.commonLengthForOps=function(n,e){var t=n.p.length,o=e.p.length;if((n.na!=null||n.t)&&t++,(e.na!=null||e.t)&&o++,t===0)return-1;if(o===0)return null;t--,o--;for(var r=0;r<t;r++){var i=n.p[r];if(r>=o||i!==e.p[r])return null}return t},Ie.canOpAffectPath=function(n,e){return Ie.commonLengthForOps({p:e},n)!=null},Ie.transformComponent=function(n,e,t,o){e=_o(e);var r=Ie.commonLengthForOps(t,e),i=Ie.commonLengthForOps(e,t),s=e.p.length,l=t.p.length;if((e.na!=null||e.t)&&s++,(t.na!=null||t.t)&&l++,i!=null&&l>s&&e.p[i]==t.p[i]){if(e.ld!==void 0){var a=_o(t);a.p=a.p.slice(s),e.ld=Ie.apply(_o(e.ld),[a])}else if(e.od!==void 0){var a=_o(t);a.p=a.p.slice(s),e.od=Ie.apply(_o(e.od),[a])}}if(r!=null){var d=s==l,a=t;if((e.si!=null||e.sd!=null)&&(t.si!=null||t.sd!=null)&&(za(e),a=_o(t),za(a)),a.t&&qr[a.t]){if(e.t&&e.t===a.t){var h=qr[e.t].transform(e.o,a.o,o);if(e.si!=null||e.sd!=null)for(var p=e.p,A=0;A<h.length;A++)e.o=[h[A]],e.p=p.slice(),Va(e),Ie.append(n,e);else(!$h(h)||h.length>0)&&(e.o=h,Ie.append(n,e));return n}}else if(t.na===void 0){if(t.li!==void 0&&t.ld!==void 0){if(t.p[r]===e.p[r])if(d){if(e.ld!==void 0)if(e.li!==void 0&&o==="left")e.ld=_o(t.li);else return n}else return n}else if(t.li!==void 0)e.li!==void 0&&e.ld===void 0&&d&&e.p[r]===t.p[r]?o==="right"&&e.p[r]++:t.p[r]<=e.p[r]&&e.p[r]++,e.lm!==void 0&&d&&t.p[r]<=e.lm&&e.lm++;else if(t.ld!==void 0){if(e.lm!==void 0&&d){if(t.p[r]===e.p[r])return n;var p=t.p[r],v=e.p[r],B=e.lm;(p<B||p===B&&v<B)&&e.lm--}if(t.p[r]<e.p[r])e.p[r]--;else if(t.p[r]===e.p[r]){if(l<s)return n;if(e.ld!==void 0)if(e.li!==void 0)delete e.ld;else return n}}else if(t.lm!==void 0)if(e.lm!==void 0&&s===l){var v=e.p[r],B=e.lm,D=t.p[r],I=t.lm;if(D!==I)if(v===D)if(o==="left")e.p[r]=I,v===B&&(e.lm=I);else return n;else v>D&&e.p[r]--,v>I?e.p[r]++:v===I&&D>I&&(e.p[r]++,v===B&&e.lm++),(B>D||B===D&&B>v)&&e.lm--,B>I?e.lm++:B===I&&(I>D&&B>v||I<D&&B<v?o==="right"&&e.lm++:B>v?e.lm++:B===D&&e.lm--)}else if(e.li!==void 0&&e.ld===void 0&&d){var v=t.p[r],B=t.lm;p=e.p[r],p>v&&e.p[r]--,p>B&&e.p[r]++}else{var v=t.p[r],B=t.lm;p=e.p[r],p===v?e.p[r]=B:(p>v&&e.p[r]--,(p>B||p===B&&v>B)&&e.p[r]++)}else if(t.oi!==void 0&&t.od!==void 0){if(e.p[r]===t.p[r])if(e.oi!==void 0&&d){if(o==="right")return n;e.od=t.oi}else return n}else if(t.oi!==void 0){if(e.oi!==void 0&&e.p[r]===t.p[r])if(o==="left")Ie.append(n,{p:e.p,od:t.oi});else return n}else if(t.od!==void 0&&e.p[r]==t.p[r]){if(!d)return n;if(e.oi!==void 0)delete e.od;else return n}}}return Ie.append(n,e),n},pb(Ie,Ie.transformComponent,Ie.checkValidOp,Ie.append);var KD=Cb.exports;Ie.registerSubtype(KD);var XD=Ie,eS={type:XD};(function(n){n.defaultType=eS.type,n.map={},n.register=function(e){e.name&&(n.map[e.name]=e),e.uri&&(n.map[e.uri]=e)},n.register(n.defaultType)})(Ua);var Fo={};(function(n){n.doNothing=e;function e(){}n.hasKeys=function(t){for(var o in t)return!0;return!1},n.isInteger=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t},n.isValidVersion=function(t){return t===null?!0:n.isInteger(t)&&t>=0},n.isValidTimestamp=function(t){return n.isValidVersion(t)},n.MAX_SAFE_INTEGER=9007199254740991,n.dig=function(){for(var t=arguments[0],o=1;o<arguments.length;o++){var r=arguments[o];t=t[r]||(o===arguments.length-1?void 0:{})}return t},n.digOrCreate=function(){for(var t=arguments[0],o=arguments[arguments.length-1],r=1;r<arguments.length-1;r++){var i=arguments[r];t=t[i]||(t[i]=r===arguments.length-2?o():{})}return t},n.digAndRemove=function(){for(var t=arguments[0],o=[t],r=1;r<arguments.length-1;r++){var i=arguments[r];if(!t.hasOwnProperty(i))break;t=t[i],o.push(t)}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(t){return t&&typeof t.transformPresence=="function"},n.callEach=function(t,o){var r=!1;return t.forEach(function(i){i&&(i(o),r=!0)}),r},n.truthy=function(t){return!!t},n.nextTick=function(t){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(){t.apply(null,o)})},n.clone=function(t){return t===void 0?void 0:JSON.parse(JSON.stringify(t))}})(Fo);var Ab=Array.isArray,bb=Object.keys,tS=Object.prototype.hasOwnProperty,nS=function n(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){var o=Ab(e),r=Ab(t),i,s,l;if(o&&r){if(s=e.length,s!=t.length)return!1;for(i=s;i--!==0;)if(!n(e[i],t[i]))return!1;return!0}if(o!=r)return!1;var a=e instanceof Date,d=t instanceof Date;if(a!=d)return!1;if(a&&d)return e.getTime()==t.getTime();var h=e instanceof RegExp,p=t instanceof RegExp;if(h!=p)return!1;if(h&&p)return e.toString()==t.toString();var A=bb(e);if(s=A.length,s!==bb(t).length)return!1;for(i=s;i--!==0;)if(!tS.call(t,A[i]))return!1;for(i=s;i--!==0;)if(l=A[i],!n(e[l],t[l]))return!1;return!0}return e!==e&&t!==t},vb=$i,oS=gb,Wn=Ph,Hh=Ua,Po=Fo,rS=Po.clone,iS=nS,Tn=Wn.CODES,sS=Fe;function Fe(n,e,t){vb.EventEmitter.call(this),this.connection=n,this.collection=e,this.id=t,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}vb.mixin(Fe),Fe.prototype.destroy=function(n){this._wantsDestroy=!0;var e=this;e.whenNothingPending(function(){e.wantSubscribe?e.unsubscribe(function(t){if(t)return n?n(t):e.emit("error",t);e.connection._destroyDoc(e),n&&n()}):(e.connection._destroyDoc(e),n&&n())})},Fe.prototype._setType=function(n){if(typeof n=="string"&&(n=Hh.map[n]),n)this.type=n;else if(n===null)this.type=n,this._setData(void 0);else{var e=new Wn(Tn.ERR_DOC_TYPE_NOT_RECOGNIZED,"Missing type "+n);return this.emit("error",e)}},Fe.prototype._setData=function(n){this.data=n,this._dataStateVersion++},Fe.prototype.ingestSnapshot=function(n,e){if(!n)return e&&e();if(typeof n.v!="number"){var t=new Wn(Tn.ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION,"Missing version in ingested snapshot. "+this.collection+"."+this.id);return e?e(t):this.emit("error",t)}if(this.type||this.hasWritePending()){if(this.version==null){if(this.hasWritePending())return e&&this.once("no write pending",e);var t=new Wn(Tn.ERR_DOC_MISSING_VERSION,"Cannot ingest snapshot in doc with null version. "+this.collection+"."+this.id);return e?e(t):this.emit("error",t)}return n.v>this.version?this.fetch(e):e&&e()}if(this.version>n.v)return e&&e();this.version=n.v;var o=n.type===void 0?Hh.defaultType:n.type;this._setType(o),this._setData(this.type&&this.type.deserialize?this.type.deserialize(n.data):n.data),this.emit("load"),e&&e()},Fe.prototype.whenNothingPending=function(n){var e=this;Po.nextTick(function(){if(e.hasPending()){e.once("nothing pending",n);return}n()})},Fe.prototype.hasPending=function(){return!!(this.inflightOp||this.pendingOps.length||this.inflightFetch.length||this.inflightSubscribe||this.pendingFetch.length||this.pendingSubscribe.length)},Fe.prototype.hasWritePending=function(){return!!(this.inflightOp||this.pendingOps.length)},Fe.prototype._emitNothingPending=function(){this.hasWritePending()||(this.emit("no write pending"),!this.hasPending()&&this.emit("nothing pending"))},Fe.prototype._emitResponseError=function(n,e){if(n&&n.code===Tn.ERR_SNAPSHOT_READ_SILENT_REJECTION){this.wantSubscribe=!1,e&&e(),this._emitNothingPending();return}if(e){e(n),this._emitNothingPending();return}this._emitNothingPending(),this.emit("error",n)},Fe.prototype._handleFetch=function(n,e){var t=this.pendingFetch;this.pendingFetch=[];var o=this.inflightFetch.shift();if(o&&t.push(o),t.length&&(o=function(r){Po.callEach(t,r)}),n)return this._emitResponseError(n,o);this.ingestSnapshot(e,o),this._emitNothingPending()},Fe.prototype._handleSubscribe=function(n,e){var t=this.inflightSubscribe;this.inflightSubscribe=null;var o=this.pendingFetch;this.pendingFetch=[],t.callback&&o.push(t.callback);var r;if(o.length&&(r=function(i){Po.callEach(o,i)}),n)return this._emitResponseError(n,r);this.subscribed=t.wantSubscribe,this.subscribed?this.ingestSnapshot(e,r):r&&r(),this._emitNothingPending(),this._flushSubscribe()},Fe.prototype._handleOp=function(n,e){if(n)return this.inflightOp?(n.code===Tn.ERR_OP_SUBMIT_REJECTED&&(n=null),this._rollback(n)):this.emit("error",n);if(this.inflightOp&&e.src===this.inflightOp.src&&e.seq===this.inflightOp.seq){this._opAcknowledged(e);return}if(this.version==null||e.v>this.version){this.fetch();return}if(!(e.v<this.version)){if(this.inflightOp){var t=jh(this.inflightOp,e);if(t)return this._hardRollback(t)}for(var o=0;o<this.pendingOps.length;o++){var t=jh(this.pendingOps[o],e);if(t)return this._hardRollback(t)}this.version++;try{this._otApply(e,!1)}catch(r){return this._hardRollback(r)}}},Fe.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))},Fe.prototype._resubscribe=function(){if(!this.pendingSubscribe.length&&this.wantSubscribe)return this.subscribe();var n=this.pendingSubscribe.some(function(e){return e.wantSubscribe});!n&&this.pendingFetch.length&&this.fetch(),this._flushSubscribe()},Fe.prototype.fetch=function(n){if(this.connection.canSend){var e=this.connection.sendFetch(this);lS(this.inflightFetch,e,n);return}this.pendingFetch.push(n)},Fe.prototype.subscribe=function(n){var e=!0;this._queueSubscribe(e,n)},Fe.prototype.unsubscribe=function(n){var e=!1;this._queueSubscribe(e,n)},Fe.prototype._queueSubscribe=function(n,e){var t=this.pendingSubscribe[this.pendingSubscribe.length-1]||this.inflightSubscribe,o=t&&t.wantSubscribe===n;if(o){t.callback=cS([t.callback,e]);return}this.pendingSubscribe.push({wantSubscribe:!!n,callback:e}),this._flushSubscribe()},Fe.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;Po.nextTick(function(){n._handleSubscribe()})}}};function lS(n,e,t){if(e){var o=n.pop();n.push(function(r){o&&o(r),t&&t(r)})}else n.push(t)}function cS(n){return n=n.filter(Po.truthy),n.length?function(e){Po.callEach(n,e)}:null}Fe.prototype.flush=function(){!this.connection.canSend||this.inflightOp||!this.paused&&this.pendingOps.length&&this._sendOp()};function aS(n){delete n.op,delete n.create,delete n.del}function jh(n,e){if(n.del)return aS(e);if(e.del)return new Wn(Tn.ERR_DOC_WAS_DELETED,"Document was deleted");if(e.create)return new Wn(Tn.ERR_DOC_ALREADY_CREATED,"Document already created");if("op"in e){if(n.create)return new Wn(Tn.ERR_DOC_ALREADY_CREATED,"Document already created");if(n.type.transformX){var t=n.type.transformX(n.op,e.op);n.op=t[0],e.op=t[1]}else{var o=n.type.transform(n.op,e.op,"left"),r=n.type.transform(e.op,n.op,"right");n.op=o,e.op=r}}}Fe.prototype._otApply=function(n,e){if("op"in n){if(!this.type)throw new Wn(Tn.ERR_DOC_DOES_NOT_EXIST,"Cannot apply op to uncreated document. "+this.collection+"."+this.id);if(this.emit("before op batch",n.op,e),!e&&this.type===Hh.defaultType&&n.op.length>1){this.applyStack||(this.applyStack=[]);for(var t=this.applyStack.length,o=0;o<n.op.length;o++){var r=n.op[o],i={op:[r]};this.emit("before op",i.op,e,n.src);for(var s=t;s<this.applyStack.length;s++){var l=jh(this.applyStack[s],i);if(l)return this._hardRollback(l)}this._setData(this.type.apply(this.data,i.op)),this.emit("op",i.op,e,n.src)}this.emit("op batch",n.op,e),this._popApplyStack(t);return}this.emit("before op",n.op,e,n.src),this._setData(this.type.apply(this.data,n.op)),this.emit("op",n.op,e,n.src),this.emit("op batch",n.op,e);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",e);return}if(n.del){var a=this.data;this._setType(null),this.emit("del",a,e);return}},Fe.prototype._sendOp=function(){if(!!this.connection.canSend){var n=this.connection.id;this.inflightOp||(this.inflightOp=this.pendingOps.shift());var e=this.inflightOp;if(!e){var t=new Wn(Tn.ERR_INFLIGHT_OP_MISSING,"No op to send on call to _sendOp");return this.emit("error",t)}if(e.sentAt=Date.now(),e.retries=e.retries==null?0:e.retries+1,e.seq==null){if(this.connection.seq>=Po.MAX_SAFE_INTEGER)return this.emit("error",new Wn(Tn.ERR_CONNECTION_SEQ_INTEGER_OVERFLOW,"Connection seq has exceeded the max safe integer, maybe from being open for too long"));e.seq=this.connection.seq++}this.connection.sendOp(this,e),e.src==null&&(e.src=n)}},Fe.prototype._submit=function(n,e,t){if(e||(e=!0),"op"in n){if(!this.type){var o=new Wn(Tn.ERR_DOC_DOES_NOT_EXIST,"Cannot submit op. Document has not been created. "+this.collection+"."+this.id);return t?t(o):this.emit("error",o)}this.type.normalize&&(n.op=this.type.normalize(n.op))}try{this._pushOp(n,e,t),this._otApply(n,e)}catch(i){return this._hardRollback(i)}var r=this;Po.nextTick(function(){r.flush()})},Fe.prototype._pushOp=function(n,e,t){if(n.source=e,this.applyStack)this.applyStack.push(n);else{var o=this._tryCompose(n);if(o){o.callbacks.push(t);return}}n.type=this.type,n.callbacks=[t],this.pendingOps.push(n)},Fe.prototype._popApplyStack=function(n){if(n>0){this.applyStack.length=n;return}var e=this.applyStack[0];if(this.applyStack=null,!!e){var t=this.pendingOps.indexOf(e);if(t!==-1)for(var o=this.pendingOps.splice(t),t=0;t<o.length;t++){var e=o[t],r=this._tryCompose(e);r?r.callbacks=r.callbacks.concat(e.callbacks):this.pendingOps.push(e)}}},Fe.prototype._tryCompose=function(n){if(!this.preventCompose){var e=this.pendingOps[this.pendingOps.length-1];if(!(!e||e.sentAt)&&!(this.submitSource&&!iS(n.source,e.source))){if(e.create&&"op"in n)return e.create.data=this.type.apply(e.create.data,n.op),e;if("op"in e&&"op"in n&&this.type.compose)return e.op=this.type.compose(e.op,n.op),e}}},Fe.prototype.submitOp=function(n,e,t){typeof e=="function"&&(t=e,e=null);var o={op:n},r=e&&e.source;this._submit(o,r,t)},Fe.prototype.create=function(n,e,t,o){if(typeof e=="function"?(o=e,t=null,e=null):typeof t=="function"&&(o=t,t=null),e||(e=Hh.defaultType.uri),this.type){var r=new Wn(Tn.ERR_DOC_ALREADY_CREATED,"Document already exists");return o?o(r):this.emit("error",r)}var i={create:{type:e,data:n}},s=t&&t.source;this._submit(i,s,o)},Fe.prototype.del=function(n,e){if(typeof n=="function"&&(e=n,n=null),!this.type){var t=new Wn(Tn.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");return e?e(t):this.emit("error",t)}var o={del:!0},r=n&&n.source;this._submit(o,r,e)},Fe.prototype.pause=function(){this.paused=!0},Fe.prototype.resume=function(){this.paused=!1,this.flush()},Fe.prototype.toSnapshot=function(){return{v:this.version,data:rS(this.data),type:this.type.uri}},Fe.prototype._opAcknowledged=function(n){if(this.inflightOp.create)this.version=n.v;else if(n.v!==this.version)return oS.warn("Invalid version from server. Expected: "+this.version+" Received: "+n.v,n),this.fetch();this.version++,this._clearInflightOp()},Fe.prototype._rollback=function(n){var e=this.inflightOp;if("op"in e&&e.type.invert){try{e.op=e.type.invert(e.op)}catch{return this._hardRollback(n)}for(var t=0;t<this.pendingOps.length;t++){var o=jh(this.pendingOps[t],e);if(o)return this._hardRollback(o)}try{this._otApply(e,!1)}catch(r){return this._hardRollback(r)}this._clearInflightOp(n);return}this._hardRollback(n)},Fe.prototype._hardRollback=function(n){var e=[];this.inflightOp&&e.push(this.inflightOp),e=e.concat(this.pendingOps),this._setType(null),this.version=null,this.inflightOp=null,this.pendingOps=[];var t=this;this.fetch(function(){for(var o=!!e.length,r=0;r<e.length;r++)o=Po.callEach(e[r].callbacks,n)&&o;if(n&&!o)return t.emit("error",n)})},Fe.prototype._clearInflightOp=function(n){var e=this.inflightOp;this.inflightOp=null;var t=Po.callEach(e.callbacks,n);if(this.flush(),this._emitNothingPending(),n&&!t)return this.emit("error",n)};var Us={};Us.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 yb=$i,kb=Us.ACTIONS,uS=Fo,dS=Dn;function Dn(n,e,t,o,r,i,s){yb.EventEmitter.call(this),this.action=n,this.connection=e,this.id=t,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}yb.mixin(Dn),Dn.prototype.hasPending=function(){return!this.ready},Dn.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 e=[],t=0;t<this.results.length;t++){var o=this.results[t];e.push([o.id,o.version])}n.r=e}this.connection.send(n),this.sent=!0}},Dn.prototype.destroy=function(n){this.connection.canSend&&this.action===kb.querySubscribe&&this.connection.send({a:kb.queryUnsubscribe,id:this.id}),this.connection._destroyQuery(this),n&&uS.nextTick(n)},Dn.prototype._onConnectionStateChanged=function(){this.connection.canSend&&!this.sent?this.send():this.sent=!1},Dn.prototype._handleFetch=function(n,e,t){this.connection._destroyQuery(this),this._handleResponse(n,e,t)},Dn.prototype._handleSubscribe=function(n,e,t){this._handleResponse(n,e,t)},Dn.prototype._handleResponse=function(n,e,t){var o=this.callback;if(this.callback=null,n)return this._finishResponse(n,o);if(!e)return this._finishResponse(null,o);var r=this,i=1,s=function(h){if(h)return r._finishResponse(h,o);--i||r._finishResponse(null,o)};if(Array.isArray(e))i+=e.length,this.results=this._ingestSnapshots(e,s),this.extra=t;else for(var l in e){i++;var a=e[l],d=this.connection.get(a.c||this.collection,l);d.ingestSnapshot(a,s)}s()},Dn.prototype._ingestSnapshots=function(n,e){for(var t=[],o=0;o<n.length;o++){var r=n[o],i=this.connection.get(r.c||this.collection,r.d);i.ingestSnapshot(r,e),t.push(i)}return t},Dn.prototype._finishResponse=function(n,e){if(this.emit("ready"),this.ready=!0,n)return this.connection._destroyQuery(this),e?e(n):this.emit("error",n);e&&e(null,this.results,this.extra)},Dn.prototype._handleError=function(n){this.emit("error",n)},Dn.prototype._handleDiff=function(n){for(var e=0;e<n.length;e++){var t=n[e];t.type==="insert"&&(t.values=this._ingestSnapshots(t.values))}for(var e=0;e<n.length;e++){var t=n[e];switch(t.type){case"insert":var o=t.values;Array.prototype.splice.apply(this.results,[t.index,0].concat(o)),this.emit("insert",o,t.index);break;case"remove":var i=t.howMany||1,r=this.results.splice(t.index,i);this.emit("remove",r,t.index);break;case"move":var i=t.howMany||1,s=this.results.splice(t.from,i);Array.prototype.splice.apply(this.results,[t.to,0].concat(s)),this.emit("move",s,t.from,t.to);break}}this.emit("changed",this.results)},Dn.prototype._handleExtra=function(n){this.extra=n,this.emit("extra",n)};var wb=$i,hS=Us.ACTIONS,fS=Fo,Bb=ar;function ar(n,e){if(wb.EventEmitter.call(this),!e||typeof e!="string")throw new Error("LocalPresence presenceId must be a string");this.presence=n,this.presenceId=e,this.connection=n.connection,this.presenceVersion=0,this.value=null,this._pendingMessages=[],this._callbacksByPresenceVersion={}}wb.mixin(ar),ar.prototype.submit=function(n,e){this.value=n,this.send(e)},ar.prototype.send=function(n){var e=this._message();this._pendingMessages.push(e),this._callbacksByPresenceVersion[e.pv]=n,this._sendPending()},ar.prototype.destroy=function(n){var e=this;this.submit(null,function(t){if(t)return e._callbackOrEmit(t,n);delete e.presence.localPresences[e.presenceId],n&&n()})},ar.prototype._sendPending=function(){if(!!this.connection.canSend){var n=this;this._pendingMessages.forEach(function(e){n.connection.send(e)}),this._pendingMessages=[]}},ar.prototype._ack=function(n,e){var t=this._getCallback(e);this._callbackOrEmit(n,t)},ar.prototype._message=function(){return{a:hS.presence,ch:this.presence.channel,id:this.presenceId,p:this.value,pv:this.presenceVersion++}},ar.prototype._getCallback=function(n){var e=this._callbacksByPresenceVersion[n];return delete this._callbacksByPresenceVersion[n],e},ar.prototype._callbackOrEmit=function(n,e){if(e)return fS.nextTick(e,n);n&&this.emit("error",n)};var mS=Fo,Eb=cp;function cp(n,e){this.presence=n,this.presenceId=e,this.connection=this.presence.connection,this.value=null,this.presenceVersion=0}cp.prototype.receiveUpdate=function(n){n.pv<this.presenceVersion||(this.value=n.p,this.presenceVersion=n.pv,this.presence._updateRemotePresence(this))},cp.prototype.destroy=function(n){delete this.presence._remotePresenceInstances[this.presenceId],delete this.presence.remotePresences[this.presenceId],n&&mS.nextTick(n)};var ap={exports:{}};(function(n,e){(function(t,o){o(e)})(cr,function(t){function o(k,T){T=T|0;for(var L=Math.max(k.length-T,0),F=Array(L),U=0;U<L;U++)F[U]=k[T+U];return F}var r=function(k){var T=o(arguments,1);return function(){var L=o(arguments);return k.apply(null,T.concat(L))}},i=function(k){return function(){var T=o(arguments),L=T.pop();k.call(this,T,L)}};function s(k){var T=typeof k;return k!=null&&(T=="object"||T=="function")}var l=typeof setImmediate=="function"&&setImmediate,a=typeof process=="object"&&typeof process.nextTick=="function";function d(k){setTimeout(k,0)}function h(k){return function(T){var L=o(arguments,1);k(function(){T.apply(null,L)})}}var p;l?p=setImmediate:a?p=process.nextTick:p=d;var A=h(p);function v(k){return i(function(T,L){var F;try{F=k.apply(this,T)}catch(U){return L(U)}s(F)&&typeof F.then=="function"?F.then(function(U){B(L,null,U)},function(U){B(L,U.message?U:new Error(U))}):L(null,F)})}function B(k,T,L){try{k(T,L)}catch(F){A(D,F)}}function D(k){throw k}var I=typeof Symbol=="function";function _(k){return I&&k[Symbol.toStringTag]==="AsyncFunction"}function M(k){return _(k)?v(k):k}function H(k){return function(T){var L=o(arguments,1),F=i(function(U,j){var Z=this;return k(T,function(J,le){M(J).apply(Z,U.concat(le))},j)});return L.length?F.apply(this,L):F}}var z=typeof cr=="object"&&cr&&cr.Object===Object&&cr,q=typeof self=="object"&&self&&self.Object===Object&&self,re=z||q||Function("return this")(),fe=re.Symbol,Be=Object.prototype,je=Be.hasOwnProperty,Ue=Be.toString,tt=fe?fe.toStringTag:void 0;function Yt(k){var T=je.call(k,tt),L=k[tt];try{k[tt]=void 0;var F=!0}catch{}var U=Ue.call(k);return F&&(T?k[tt]=L:delete k[tt]),U}var Wo=Object.prototype,Nt=Wo.toString;function Ln(k){return Nt.call(k)}var yr="[object Null]",bn="[object Undefined]",an=fe?fe.toStringTag:void 0;function kr(k){return k==null?k===void 0?bn:yr:an&&an in Object(k)?Yt(k):Ln(k)}var ti="[object AsyncFunction]",mo="[object Function]",X2="[object GeneratorFunction]",e3="[object Proxy]";function t3(k){if(!s(k))return!1;var T=kr(k);return T==mo||T==X2||T==ti||T==e3}var ns=9007199254740991;function ol(k){return typeof k=="number"&&k>-1&&k%1==0&&k<=ns}function rl(k){return k!=null&&ol(k.length)&&!t3(k)}var ni={};function Ne(){}function wr(k){return function(){if(k!==null){var T=k;k=null,T.apply(this,arguments)}}}var os=typeof Symbol=="function"&&Symbol.iterator,Pc=function(k){return os&&k[os]&&k[os]()};function s1(k,T){for(var L=-1,F=Array(k);++L<k;)F[L]=T(L);return F}function un(k){return k!=null&&typeof k=="object"}var il="[object Arguments]";function l1(k){return un(k)&&kr(k)==il}var go=Object.prototype,c1=go.hasOwnProperty,n3=go.propertyIsEnumerable,sl=l1(function(){return arguments}())?l1:function(k){return un(k)&&c1.call(k,"callee")&&!n3.call(k,"callee")},Ct=Array.isArray;function ll(){return!1}var cl=typeof t=="object"&&t&&!t.nodeType&&t,a1=cl&&!0&&n&&!n.nodeType&&n,al=a1&&a1.exports===cl,u1=al?re.Buffer:void 0,ul=u1?u1.isBuffer:void 0,rs=ul||ll,ju=9007199254740991,Uu=/^(?:0|[1-9]\d*)$/;function zu(k,T){var L=typeof k;return T=T==null?ju:T,!!T&&(L=="number"||L!="symbol"&&Uu.test(k))&&k>-1&&k%1==0&&k<T}var Vu="[object Arguments]",Wu="[object Array]",qu="[object Boolean]",Gu="[object Date]",Zu="[object Error]",Qu="[object Function]",o3="[object Map]",r3="[object Number]",i3="[object Object]",d1="[object RegExp]",h1="[object Set]",s3="[object String]",l3="[object WeakMap]",c3="[object ArrayBuffer]",a3="[object DataView]",f1="[object Float32Array]",u3="[object Float64Array]",d3="[object Int8Array]",h3="[object Int16Array]",Yu="[object Int32Array]",f3="[object Uint8Array]",Ju="[object Uint8ClampedArray]",m3="[object Uint16Array]",g3="[object Uint32Array]",it={};it[f1]=it[u3]=it[d3]=it[h3]=it[Yu]=it[f3]=it[Ju]=it[m3]=it[g3]=!0,it[Vu]=it[Wu]=it[c3]=it[qu]=it[a3]=it[Gu]=it[Zu]=it[Qu]=it[o3]=it[r3]=it[i3]=it[d1]=it[h1]=it[s3]=it[l3]=!1;function p3(k){return un(k)&&ol(k.length)&&!!it[kr(k)]}function C3(k){return function(T){return k(T)}}var m1=typeof t=="object"&&t&&!t.nodeType&&t,dl=m1&&!0&&n&&!n.nodeType&&n,A3=dl&&dl.exports===m1,Nc=A3&&z.process,g1=function(){try{var k=dl&&dl.require&&dl.require("util").types;return k||Nc&&Nc.binding&&Nc.binding("util")}catch{}}(),p1=g1&&g1.isTypedArray,b3=p1?C3(p1):p3,v3=Object.prototype,y3=v3.hasOwnProperty;function k3(k,T){var L=Ct(k),F=!L&&sl(k),U=!L&&!F&&rs(k),j=!L&&!F&&!U&&b3(k),Z=L||F||U||j,J=Z?s1(k.length,String):[],le=J.length;for(var pe in k)(T||y3.call(k,pe))&&!(Z&&(pe=="length"||U&&(pe=="offset"||pe=="parent")||j&&(pe=="buffer"||pe=="byteLength"||pe=="byteOffset")||zu(pe,le)))&&J.push(pe);return J}var $c=Object.prototype;function w3(k){var T=k&&k.constructor,L=typeof T=="function"&&T.prototype||$c;return k===L}function Hc(k,T){return function(L){return k(T(L))}}var B3=Hc(Object.keys,Object),E3=Object.prototype,x3=E3.hasOwnProperty;function C1(k){if(!w3(k))return B3(k);var T=[];for(var L in Object(k))x3.call(k,L)&&L!="constructor"&&T.push(L);return T}function jc(k){return rl(k)?k3(k):C1(k)}function A1(k){var T=-1,L=k.length;return function(){return++T<L?{value:k[T],key:T}:null}}function I3(k){var T=-1;return function(){var F=k.next();return F.done?null:(T++,{value:F.value,key:T})}}function T3(k){var T=jc(k),L=-1,F=T.length;return function U(){var j=T[++L];return j==="__proto__"?U():L<F?{value:k[j],key:j}:null}}function D3(k){if(rl(k))return A1(k);var T=Pc(k);return T?I3(T):T3(k)}function po(k){return function(){if(k===null)throw new Error("Callback was already called.");var T=k;k=null,T.apply(this,arguments)}}function hl(k){return function(T,L,F){if(F=wr(F||Ne),k<=0||!T)return F(null);var U=D3(T),j=!1,Z=0,J=!1;function le(ce,Ae){if(Z-=1,ce)j=!0,F(ce);else{if(Ae===ni||j&&Z<=0)return j=!0,F(null);J||pe()}}function pe(){for(J=!0;Z<k&&!j;){var ce=U();if(ce===null){j=!0,Z<=0&&F(null);return}Z+=1,L(ce.value,ce.key,po(le))}J=!1}pe()}}function Br(k,T,L,F){hl(T)(k,M(L),F)}function $t(k,T){return function(L,F,U){return k(L,T,F,U)}}function Ku(k,T,L){L=wr(L||Ne);var F=0,U=0,j=k.length;j===0&&L(null);function Z(J,le){J?L(J):(++U===j||le===ni)&&L(null)}for(;F<j;F++)T(k[F],F,po(Z))}var S3=$t(Br,1/0),qo=function(k,T,L){var F=rl(k)?Ku:S3;F(k,M(T),L)};function Go(k){return function(T,L,F){return k(qo,T,M(L),F)}}function Xu(k,T,L,F){F=F||Ne,T=T||[];var U=[],j=0,Z=M(L);k(T,function(J,le,pe){var ce=j++;Z(J,function(Ae,Ge){U[ce]=Ge,pe(Ae)})},function(J){F(J,U)})}var Uc=Go(Xu),ed=H(Uc);function oi(k){return function(T,L,F,U){return k(hl(L),T,M(F),U)}}var Er=oi(Xu),td=$t(Er,1),nd=H(td);function is(k,T){for(var L=-1,F=k==null?0:k.length;++L<F&&T(k[L],L,k)!==!1;);return k}function od(k){return function(T,L,F){for(var U=-1,j=Object(T),Z=F(T),J=Z.length;J--;){var le=Z[k?J:++U];if(L(j[le],le,j)===!1)break}return T}}var ss=od();function ls(k,T){return k&&ss(k,T,jc)}function b1(k,T,L,F){for(var U=k.length,j=L+(F?1:-1);F?j--:++j<U;)if(T(k[j],j,k))return j;return-1}function L3(k){return k!==k}function v1(k,T,L){for(var F=L-1,U=k.length;++F<U;)if(k[F]===T)return F;return-1}function fl(k,T,L){return T===T?v1(k,T,L):b1(k,L3,L)}var zc=function(k,T,L){typeof T=="function"&&(L=T,T=null),L=wr(L||Ne);var F=jc(k),U=F.length;if(!U)return L(null);T||(T=U);var j={},Z=0,J=!1,le=Object.create(null),pe=[],ce=[],Ae={};ls(k,function(dt,ot){if(!Ct(dt)){Ge(ot,[dt]),ce.push(ot);return}var gt=dt.slice(0,dt.length-1),Ao=gt.length;if(Ao===0){Ge(ot,dt),ce.push(ot);return}Ae[ot]=Ao,is(gt,function(E){if(!k[E])throw new Error("async.auto task `"+ot+"` has a non-existent dependency `"+E+"` in "+gt.join(", "));tn(E,function(){Ao--,Ao===0&&Ge(ot,dt)})})}),X3(),It();function Ge(dt,ot){pe.push(function(){Co(dt,ot)})}function It(){if(pe.length===0&&Z===0)return L(null,j);for(;pe.length&&Z<T;){var dt=pe.shift();dt()}}function tn(dt,ot){var gt=le[dt];gt||(gt=le[dt]=[]),gt.push(ot)}function On(dt){var ot=le[dt]||[];is(ot,function(gt){gt()}),It()}function Co(dt,ot){if(!J){var gt=po(function(E,Tr){if(Z--,arguments.length>2&&(Tr=o(arguments,1)),E){var ds={};ls(j,function(_n,Pe){ds[Pe]=_n}),ds[dt]=Tr,J=!0,le=Object.create(null),L(E,ds)}else j[dt]=Tr,On(dt)});Z++;var Ao=M(ot[ot.length-1]);ot.length>1?Ao(j,gt):Ao(gt)}}function X3(){for(var dt,ot=0;ce.length;)dt=ce.pop(),ot++,is(e5(dt),function(gt){--Ae[gt]===0&&ce.push(gt)});if(ot!==U)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function e5(dt){var ot=[];return ls(k,function(gt,Ao){Ct(gt)&&fl(gt,dt,0)>=0&&ot.push(Ao)}),ot}};function ri(k,T){for(var L=-1,F=k==null?0:k.length,U=Array(F);++L<F;)U[L]=T(k[L],L,k);return U}var M3="[object Symbol]";function R3(k){return typeof k=="symbol"||un(k)&&kr(k)==M3}var O3=1/0,rd=fe?fe.prototype:void 0,y1=rd?rd.toString:void 0;function id(k){if(typeof k=="string")return k;if(Ct(k))return ri(k,id)+"";if(R3(k))return y1?y1.call(k):"";var T=k+"";return T=="0"&&1/k==-O3?"-0":T}function _3(k,T,L){var F=-1,U=k.length;T<0&&(T=-T>U?0:U+T),L=L>U?U:L,L<0&&(L+=U),U=T>L?0:L-T>>>0,T>>>=0;for(var j=Array(U);++F<U;)j[F]=k[F+T];return j}function F3(k,T,L){var F=k.length;return L=L===void 0?F:L,!T&&L>=F?k:_3(k,T,L)}function sd(k,T){for(var L=k.length;L--&&fl(T,k[L],0)>-1;);return L}function P3(k,T){for(var L=-1,F=k.length;++L<F&&fl(T,k[L],0)>-1;);return L}function N3(k){return k.split("")}var $3="\\ud800-\\udfff",H3="\\u0300-\\u036f",j3="\\ufe20-\\ufe2f",st="\\u20d0-\\u20ff",nt=H3+j3+st,U3="\\ufe0e\\ufe0f",z3="\\u200d",V3=RegExp("["+z3+$3+nt+U3+"]");function W3(k){return V3.test(k)}var k1="\\ud800-\\udfff",q3="\\u0300-\\u036f",w1="\\ufe20-\\ufe2f",G3="\\u20d0-\\u20ff",qt=q3+w1+G3,ld="\\ufe0e\\ufe0f",ii="["+k1+"]",Vc="["+qt+"]",ml="\\ud83c[\\udffb-\\udfff]",Mn="(?:"+Vc+"|"+ml+")",cd="[^"+k1+"]",ad="(?:\\ud83c[\\udde6-\\uddff]){2}",ud="[\\ud800-\\udbff][\\udc00-\\udfff]",B1="\\u200d",dd=Mn+"?",hd="["+ld+"]?",vn="(?:"+B1+"(?:"+[cd,ad,ud].join("|")+")"+hd+dd+")*",Z3=hd+dd+vn,Rn="(?:"+[cd+Vc+"?",Vc,ad,ud,ii].join("|")+")",Q3=RegExp(ml+"(?="+ml+")|"+Rn+Z3,"g");function E1(k){return k.match(Q3)||[]}function Zo(k){return W3(k)?E1(k):N3(k)}function Wc(k){return k==null?"":id(k)}var fd=/^\s+|\s+$/g;function ut(k,T,L){if(k=Wc(k),k&&(L||T===void 0))return k.replace(fd,"");if(!k||!(T=id(T)))return k;var F=Zo(k),U=Zo(T),j=P3(F,U),Z=sd(F,U)+1;return F3(F,j,Z).join("")}var xr=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,md=/,/,Y3=/(=.+)?(\s*)$/,gd=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;function J3(k){return k=k.toString().replace(gd,""),k=k.match(xr)[2].replace(" ",""),k=k?k.split(md):[],k=k.map(function(T){return ut(T.replace(Y3,""))}),k}function x1(k,T){var L={};ls(k,function(F,U){var j,Z=_(F),J=!Z&&F.length===1||Z&&F.length===0;if(Ct(F))j=F.slice(0,-1),F=F[F.length-1],L[U]=j.concat(j.length>0?le:F);else if(J)L[U]=F;else{if(j=J3(F),F.length===0&&!Z&&j.length===0)throw new Error("autoInject task functions require explicit parameters.");Z||j.pop(),L[U]=j.concat(le)}function le(pe,ce){var Ae=ri(j,function(Ge){return pe[Ge]});Ae.push(ce),M(F).apply(null,Ae)}}),zc(L,T)}function Yn(){this.head=this.tail=null,this.length=0}function pd(k,T){k.length=1,k.head=k.tail=T}Yn.prototype.removeLink=function(k){return k.prev?k.prev.next=k.next:this.head=k.next,k.next?k.next.prev=k.prev:this.tail=k.prev,k.prev=k.next=null,this.length-=1,k},Yn.prototype.empty=function(){for(;this.head;)this.shift();return this},Yn.prototype.insertAfter=function(k,T){T.prev=k,T.next=k.next,k.next?k.next.prev=T:this.tail=T,k.next=T,this.length+=1},Yn.prototype.insertBefore=function(k,T){T.prev=k.prev,T.next=k,k.prev?k.prev.next=T:this.head=T,k.prev=T,this.length+=1},Yn.prototype.unshift=function(k){this.head?this.insertBefore(this.head,k):pd(this,k)},Yn.prototype.push=function(k){this.tail?this.insertAfter(this.tail,k):pd(this,k)},Yn.prototype.shift=function(){return this.head&&this.removeLink(this.head)},Yn.prototype.pop=function(){return this.tail&&this.removeLink(this.tail)},Yn.prototype.toArray=function(){for(var k=Array(this.length),T=this.head,L=0;L<this.length;L++)k[L]=T.data,T=T.next;return k},Yn.prototype.remove=function(k){for(var T=this.head;T;){var L=T.next;k(T)&&this.removeLink(T),T=L}return this};function gl(k,T,L){if(T==null)T=1;else if(T===0)throw new Error("Concurrency must not be zero");var F=M(k),U=0,j=[],Z=!1;function J(Ae,Ge,It){if(It!=null&&typeof It!="function")throw new Error("task callback must be a function");if(ce.started=!0,Ct(Ae)||(Ae=[Ae]),Ae.length===0&&ce.idle())return A(function(){ce.drain()});for(var tn=0,On=Ae.length;tn<On;tn++){var Co={data:Ae[tn],callback:It||Ne};Ge?ce._tasks.unshift(Co):ce._tasks.push(Co)}Z||(Z=!0,A(function(){Z=!1,ce.process()}))}function le(Ae){return function(Ge){U-=1;for(var It=0,tn=Ae.length;It<tn;It++){var On=Ae[It],Co=fl(j,On,0);Co===0?j.shift():Co>0&&j.splice(Co,1),On.callback.apply(On,arguments),Ge!=null&&ce.error(Ge,On.data)}U<=ce.concurrency-ce.buffer&&ce.unsaturated(),ce.idle()&&ce.drain(),ce.process()}}var pe=!1,ce={_tasks:new Yn,concurrency:T,payload:L,saturated:Ne,unsaturated:Ne,buffer:T/4,empty:Ne,drain:Ne,error:Ne,started:!1,paused:!1,push:function(Ae,Ge){J(Ae,!1,Ge)},kill:function(){ce.drain=Ne,ce._tasks.empty()},unshift:function(Ae,Ge){J(Ae,!0,Ge)},remove:function(Ae){ce._tasks.remove(Ae)},process:function(){if(!pe){for(pe=!0;!ce.paused&&U<ce.concurrency&&ce._tasks.length;){var Ae=[],Ge=[],It=ce._tasks.length;ce.payload&&(It=Math.min(It,ce.payload));for(var tn=0;tn<It;tn++){var On=ce._tasks.shift();Ae.push(On),j.push(On),Ge.push(On.data)}U+=1,ce._tasks.length===0&&ce.empty(),U===ce.concurrency&&ce.saturated();var Co=po(le(Ae));F(Ge,Co)}pe=!1}},length:function(){return ce._tasks.length},running:function(){return U},workersList:function(){return j},idle:function(){return ce._tasks.length+U===0},pause:function(){ce.paused=!0},resume:function(){ce.paused!==!1&&(ce.paused=!1,A(ce.process))}};return ce}function si(k,T){return gl(k,1,T)}var cs=$t(Br,1);function Qo(k,T,L,F){F=wr(F||Ne);var U=M(L);cs(k,function(j,Z,J){U(T,j,function(le,pe){T=pe,J(le)})},function(j){F(j,T)})}function qc(){var k=ri(arguments,M);return function(){var T=o(arguments),L=this,F=T[T.length-1];typeof F=="function"?T.pop():F=Ne,Qo(k,T,function(U,j,Z){j.apply(L,U.concat(function(J){var le=o(arguments,1);Z(J,le)}))},function(U,j){F.apply(L,[U].concat(j))})}}var Gc=function(){return qc.apply(null,o(arguments).reverse())},Cd=Array.prototype.concat,pl=function(k,T,L,F){F=F||Ne;var U=M(L);Er(k,T,function(j,Z){U(j,function(J){return J?Z(J):Z(null,o(arguments,1))})},function(j,Z){for(var J=[],le=0;le<Z.length;le++)Z[le]&&(J=Cd.apply(J,Z[le]));return F(j,J)})},I1=$t(pl,1/0),Zc=$t(pl,1),Qc=function(){var k=o(arguments),T=[null].concat(k);return function(){var L=arguments[arguments.length-1];return L.apply(this,T)}};function Cl(k){return k}function li(k,T){return function(L,F,U,j){j=j||Ne;var Z=!1,J;L(F,function(le,pe,ce){U(le,function(Ae,Ge){Ae?ce(Ae):k(Ge)&&!J?(Z=!0,J=T(!0,le),ce(null,ni)):ce()})},function(le){le?j(le):j(null,Z?J:T(!1))})}}function dn(k,T){return T}var as=Go(li(Cl,dn)),Yo=oi(li(Cl,dn)),Al=$t(Yo,1);function Ad(k){return function(T){var L=o(arguments,1);L.push(function(F){var U=o(arguments,1);typeof console=="object"&&(F?console.error&&console.error(F):console[k]&&is(U,function(j){console[k](j)}))}),M(T).apply(null,L)}}var T1=Ad("dir");function D1(k,T,L){L=po(L||Ne);var F=M(k),U=M(T);function j(J){if(J)return L(J);var le=o(arguments,1);le.push(Z),U.apply(this,le)}function Z(J,le){if(J)return L(J);if(!le)return L(null);F(j)}Z(null,!0)}function bd(k,T,L){L=po(L||Ne);var F=M(k),U=function(j){if(j)return L(j);var Z=o(arguments,1);if(T.apply(this,Z))return F(U);L.apply(null,[null].concat(Z))};F(U)}function S1(k,T,L){bd(k,function(){return!T.apply(this,arguments)},L)}function L1(k,T,L){L=po(L||Ne);var F=M(T),U=M(k);function j(J){if(J)return L(J);U(Z)}function Z(J,le){if(J)return L(J);if(!le)return L(null);F(j)}U(Z)}function ci(k){return function(T,L,F){return k(T,F)}}function Yc(k,T,L){qo(k,ci(M(T)),L)}function bl(k,T,L,F){hl(T)(k,ci(M(L)),F)}var ai=$t(bl,1);function Jc(k){return _(k)?k:i(function(T,L){var F=!0;T.push(function(){var U=arguments;F?A(function(){L.apply(null,U)}):L.apply(null,U)}),k.apply(this,T),F=!1})}function Jn(k){return!k}var ui=Go(li(Jn,Jn)),vl=oi(li(Jn,Jn)),Kc=$t(vl,1);function M1(k){return function(T){return T==null?void 0:T[k]}}function us(k,T,L,F){var U=new Array(T.length);k(T,function(j,Z,J){L(j,function(le,pe){U[Z]=!!pe,J(le)})},function(j){if(j)return F(j);for(var Z=[],J=0;J<T.length;J++)U[J]&&Z.push(T[J]);F(null,Z)})}function Kn(k,T,L,F){var U=[];k(T,function(j,Z,J){L(j,function(le,pe){le?J(le):(pe&&U.push({index:Z,value:j}),J())})},function(j){j?F(j):F(null,ri(U.sort(function(Z,J){return Z.index-J.index}),M1("value")))})}function Xc(k,T,L,F){var U=rl(T)?us:Kn;U(k,T,M(L),F||Ne)}var ea=Go(Xc),yl=oi(Xc),ta=$t(yl,1);function R1(k,T){var L=po(T||Ne),F=M(Jc(k));function U(j){if(j)return L(j);F(U)}U()}var na=function(k,T,L,F){F=F||Ne;var U=M(L);Er(k,T,function(j,Z){U(j,function(J,le){return J?Z(J):Z(null,{key:le,val:j})})},function(j,Z){for(var J={},le=Object.prototype.hasOwnProperty,pe=0;pe<Z.length;pe++)if(Z[pe]){var ce=Z[pe].key,Ae=Z[pe].val;le.call(J,ce)?J[ce].push(Ae):J[ce]=[Ae]}return F(j,J)})},di=$t(na,1/0),N=$t(na,1),G=Ad("log");function V(k,T,L,F){F=wr(F||Ne);var U={},j=M(L);Br(k,T,function(Z,J,le){j(Z,J,function(pe,ce){if(pe)return le(pe);U[J]=ce,le()})},function(Z){F(Z,U)})}var he=$t(V,1/0),Ee=$t(V,1);function Ve(k,T){return T in k}function Bt(k,T){var L=Object.create(null),F=Object.create(null);T=T||Cl;var U=M(k),j=i(function(J,le){var pe=T.apply(null,J);Ve(L,pe)?A(function(){le.apply(null,L[pe])}):Ve(F,pe)?F[pe].push(le):(F[pe]=[le],U.apply(null,J.concat(function(){var ce=o(arguments);L[pe]=ce;var Ae=F[pe];delete F[pe];for(var Ge=0,It=Ae.length;Ge<It;Ge++)Ae[Ge].apply(null,ce)})))});return j.memo=L,j.unmemoized=k,j}var qe;a?qe=process.nextTick:l?qe=setImmediate:qe=d;var oa=h(qe);function vd(k,T,L){L=L||Ne;var F=rl(T)?[]:{};k(T,function(U,j,Z){M(U)(function(J,le){arguments.length>2&&(le=o(arguments,1)),F[j]=le,Z(J)})},function(U){L(U,F)})}function yn(k,T){vd(qo,k,T)}function kl(k,T,L){vd(hl(T),k,L)}var yd=function(k,T){var L=M(k);return gl(function(F,U){L(F[0],U)},T,1)},hi=function(k,T){var L=yd(k,T);return L.push=function(F,U,j){if(j==null&&(j=Ne),typeof j!="function")throw new Error("task callback must be a function");if(L.started=!0,Ct(F)||(F=[F]),F.length===0)return A(function(){L.drain()});U=U||0;for(var Z=L._tasks.head;Z&&U>=Z.priority;)Z=Z.next;for(var J=0,le=F.length;J<le;J++){var pe={data:F[J],priority:U,callback:j};Z?L._tasks.insertBefore(Z,pe):L._tasks.push(pe)}A(L.process)},delete L.unshift,L};function wl(k,T){if(T=wr(T||Ne),!Ct(k))return T(new TypeError("First argument to race must be an array of functions"));if(!k.length)return T();for(var L=0,F=k.length;L<F;L++)M(k[L])(T)}function fi(k,T,L,F){var U=o(k).reverse();Qo(U,T,L,F)}function We(k){var T=M(k);return i(function(F,U){return F.push(function(Z,J){if(Z)U(null,{error:Z});else{var le;arguments.length<=2?le=J:le=o(arguments,1),U(null,{value:le})}}),T.apply(this,F)})}function O1(k){var T;return Ct(k)?T=ri(k,We):(T={},ls(k,function(L,F){T[F]=We.call(this,L)})),T}function kd(k,T,L,F){Xc(k,T,function(U,j){L(U,function(Z,J){j(Z,!J)})},F)}var Bl=Go(kd),wd=oi(kd),_1=$t(wd,1);function F1(k){return function(){return k}}function mi(k,T,L){var F=5,U=0,j={times:F,intervalFunc:F1(U)};function Z(ce,Ae){if(typeof Ae=="object")ce.times=+Ae.times||F,ce.intervalFunc=typeof Ae.interval=="function"?Ae.interval:F1(+Ae.interval||U),ce.errorFilter=Ae.errorFilter;else if(typeof Ae=="number"||typeof Ae=="string")ce.times=+Ae||F;else throw new Error("Invalid arguments for async.retry")}if(arguments.length<3&&typeof k=="function"?(L=T||Ne,T=k):(Z(j,k),L=L||Ne),typeof T!="function")throw new Error("Invalid arguments for async.retry");var J=M(T),le=1;function pe(){J(function(ce){ce&&le++<j.times&&(typeof j.errorFilter!="function"||j.errorFilter(ce))?setTimeout(pe,j.intervalFunc(le)):L.apply(null,arguments)})}pe()}var Jo=function(k,T){T||(T=k,k=null);var L=M(T);return i(function(F,U){function j(Z){L.apply(null,F.concat(Z))}k?mi(k,j,U):mi(j,U)})};function El(k,T){vd(cs,k,T)}var xl=Go(li(Boolean,Cl)),Ir=oi(li(Boolean,Cl)),Il=$t(Ir,1);function Bd(k,T,L){var F=M(T);Uc(k,function(j,Z){F(j,function(J,le){if(J)return Z(J);Z(null,{value:j,criteria:le})})},function(j,Z){if(j)return L(j);L(null,ri(Z.sort(U),M1("value")))});function U(j,Z){var J=j.criteria,le=Z.criteria;return J<le?-1:J>le?1:0}}function Tl(k,T,L){var F=M(k);return i(function(U,j){var Z=!1,J;function le(){var pe=k.name||"anonymous",ce=new Error('Callback function "'+pe+'" timed out.');ce.code="ETIMEDOUT",L&&(ce.info=L),Z=!0,j(ce)}U.push(function(){Z||(j.apply(null,arguments),clearTimeout(J))}),J=setTimeout(le,T),F.apply(null,U)})}var P1=Math.ceil,Dl=Math.max;function gi(k,T,L,F){for(var U=-1,j=Dl(P1((T-k)/(L||1)),0),Z=Array(j);j--;)Z[F?j:++U]=k,k+=L;return Z}function pi(k,T,L,F){var U=M(L);Er(gi(0,k,1),T,U,F)}var N1=$t(pi,1/0),$1=$t(pi,1);function H1(k,T,L,F){arguments.length<=3&&(F=L,L=T,T=Ct(k)?[]:{}),F=wr(F||Ne);var U=M(L);qo(k,function(j,Z,J){U(T,j,Z,J)},function(j){F(j,T)})}function Sl(k,T){var L=null,F;T=T||Ne,ai(k,function(U,j){M(U)(function(Z,J){arguments.length>2?F=o(arguments,1):F=J,L=Z,j(!Z)})},function(){T(L,F)})}function Ll(k){return function(){return(k.unmemoized||k).apply(null,arguments)}}function Ml(k,T,L){L=po(L||Ne);var F=M(T);if(!k())return L(null);var U=function(j){if(j)return L(j);if(k())return F(U);var Z=o(arguments,1);L.apply(null,[null].concat(Z))};F(U)}function j1(k,T,L){Ml(function(){return!k.apply(this,arguments)},T,L)}var Ed=function(k,T){if(T=wr(T||Ne),!Ct(k))return T(new Error("First argument to waterfall must be an array of functions"));if(!k.length)return T();var L=0;function F(j){var Z=M(k[L++]);j.push(po(U)),Z.apply(null,j)}function U(j){if(j||L===k.length)return T.apply(null,arguments);F(o(arguments,1))}F([])},K3={apply:r,applyEach:ed,applyEachSeries:nd,asyncify:v,auto:zc,autoInject:x1,cargo:si,compose:Gc,concat:I1,concatLimit:pl,concatSeries:Zc,constant:Qc,detect:as,detectLimit:Yo,detectSeries:Al,dir:T1,doDuring:D1,doUntil:S1,doWhilst:bd,during:L1,each:Yc,eachLimit:bl,eachOf:qo,eachOfLimit:Br,eachOfSeries:cs,eachSeries:ai,ensureAsync:Jc,every:ui,everyLimit:vl,everySeries:Kc,filter:ea,filterLimit:yl,filterSeries:ta,forever:R1,groupBy:di,groupByLimit:na,groupBySeries:N,log:G,map:Uc,mapLimit:Er,mapSeries:td,mapValues:he,mapValuesLimit:V,mapValuesSeries:Ee,memoize:Bt,nextTick:oa,parallel:yn,parallelLimit:kl,priorityQueue:hi,queue:yd,race:wl,reduce:Qo,reduceRight:fi,reflect:We,reflectAll:O1,reject:Bl,rejectLimit:wd,rejectSeries:_1,retry:mi,retryable:Jo,seq:qc,series:El,setImmediate:A,some:xl,someLimit:Ir,someSeries:Il,sortBy:Bd,timeout:Tl,times:N1,timesLimit:pi,timesSeries:$1,transform:H1,tryEach:Sl,unmemoize:Ll,until:j1,waterfall:Ed,whilst:Ml,all:ui,allLimit:vl,allSeries:Kc,any:xl,anyLimit:Ir,anySeries:Il,find:as,findLimit:Yo,findSeries:Al,forEach:Yc,forEachSeries:ai,forEachLimit:bl,forEachOf:qo,forEachOfSeries:cs,forEachOfLimit:Br,inject:Qo,foldl:Qo,foldr:fi,select:ea,selectLimit:yl,selectSeries:ta,wrapSync:v};t.default=K3,t.apply=r,t.applyEach=ed,t.applyEachSeries=nd,t.asyncify=v,t.auto=zc,t.autoInject=x1,t.cargo=si,t.compose=Gc,t.concat=I1,t.concatLimit=pl,t.concatSeries=Zc,t.constant=Qc,t.detect=as,t.detectLimit=Yo,t.detectSeries=Al,t.dir=T1,t.doDuring=D1,t.doUntil=S1,t.doWhilst=bd,t.during=L1,t.each=Yc,t.eachLimit=bl,t.eachOf=qo,t.eachOfLimit=Br,t.eachOfSeries=cs,t.eachSeries=ai,t.ensureAsync=Jc,t.every=ui,t.everyLimit=vl,t.everySeries=Kc,t.filter=ea,t.filterLimit=yl,t.filterSeries=ta,t.forever=R1,t.groupBy=di,t.groupByLimit=na,t.groupBySeries=N,t.log=G,t.map=Uc,t.mapLimit=Er,t.mapSeries=td,t.mapValues=he,t.mapValuesLimit=V,t.mapValuesSeries=Ee,t.memoize=Bt,t.nextTick=oa,t.parallel=yn,t.parallelLimit=kl,t.priorityQueue=hi,t.queue=yd,t.race=wl,t.reduce=Qo,t.reduceRight=fi,t.reflect=We,t.reflectAll=O1,t.reject=Bl,t.rejectLimit=wd,t.rejectSeries=_1,t.retry=mi,t.retryable=Jo,t.seq=qc,t.series=El,t.setImmediate=A,t.some=xl,t.someLimit=Ir,t.someSeries=Il,t.sortBy=Bd,t.timeout=Tl,t.times=N1,t.timesLimit=pi,t.timesSeries=$1,t.transform=H1,t.tryEach=Sl,t.unmemoize=Ll,t.until=j1,t.waterfall=Ed,t.whilst=Ml,t.all=ui,t.allLimit=vl,t.allSeries=Kc,t.any=xl,t.anyLimit=Ir,t.anySeries=Il,t.find=as,t.findLimit=Yo,t.findSeries=Al,t.forEach=Yc,t.forEachSeries=ai,t.forEachLimit=bl,t.forEachOf=qo,t.forEachOfSeries=cs,t.forEachOfLimit=Br,t.inject=Qo,t.foldl=Qo,t.foldr=fi,t.select=ea,t.selectLimit=yl,t.selectSeries=ta,t.wrapSync=v,Object.defineProperty(t,"__esModule",{value:!0})})})(ap,ap.exports);var xb={exports:{}},up=xb.exports=function(n,e){if(e||(e=16),n===void 0&&(n=128),n<=0)return"0";for(var t=Math.log(Math.pow(2,n))/Math.log(e),o=2;t===1/0;o*=2)t=Math.log(Math.pow(2,n/o))/Math.log(e)*o;for(var r=t-Math.floor(t),i="",o=0;o<Math.floor(t);o++){var s=Math.floor(Math.random()*e).toString(e);i=s+i}if(r){var l=Math.pow(e,r),s=Math.floor(Math.random()*l).toString(e);i=s+i}var a=parseInt(i,e);return a!==1/0&&a>=Math.pow(2,n)?up(n,e):i};up.rack=function(n,e,t){var o=function(i){var s=0;do{if(s++>10)if(t)n+=t;else throw new Error("too many ID collisions, use more bits");var l=up(n,e)}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=e||16,o};var Ib=$i,gS=Bb,pS=Eb,Uh=Fo,dp=ap.exports,CS=xb.exports,Tb=Us.ACTIONS,Db=Mt;function Mt(n,e){if(Ib.EventEmitter.call(this),!e||typeof e!="string")throw new Error("Presence channel must be provided");this.connection=n,this.channel=e,this.wantSubscribe=!1,this.subscribed=!1,this.remotePresences={},this.localPresences={},this._remotePresenceInstances={},this._subscriptionCallbacksBySeq={},this._wantsDestroy=!1}Ib.mixin(Mt),Mt.prototype.subscribe=function(n){this._sendSubscriptionAction(!0,n)},Mt.prototype.unsubscribe=function(n){this._sendSubscriptionAction(!1,n)},Mt.prototype.create=function(n){if(this._wantsDestroy)throw new Error("Presence is being destroyed");n=n||CS();var e=this._createLocalPresence(n);return this.localPresences[n]=e,e},Mt.prototype.destroy=function(n){this._wantsDestroy=!0;var e=this,t=Object.keys(e.localPresences);this.unsubscribe(function(o){if(o)return e._callbackOrEmit(o,n);var r=Object.keys(e._remotePresenceInstances);dp.parallel([function(i){dp.each(t,function(s,l){e.localPresences[s].destroy(l)},i)},function(i){if(!e._wantsDestroy)return i();dp.each(r,function(s,l){e._remotePresenceInstances[s].destroy(l)},i)}],function(i){e._wantsDestroy&&delete e.connection._presences[e.channel],e._callbackOrEmit(i,n)})})},Mt.prototype._sendSubscriptionAction=function(n,e){this.wantSubscribe=!!n;var t=this.wantSubscribe?Tb.presenceSubscribe:Tb.presenceUnsubscribe,o=this.connection._presenceSeq++;this._subscriptionCallbacksBySeq[o]=e,this.connection.canSend&&this.connection._sendPresenceAction(t,o,this)},Mt.prototype._handleSubscribe=function(n,e){this.wantSubscribe&&(this.subscribed=!0);var t=this._subscriptionCallback(e);this._callbackOrEmit(n,t)},Mt.prototype._handleUnsubscribe=function(n,e){this.subscribed=!1;var t=this._subscriptionCallback(e);this._callbackOrEmit(n,t)},Mt.prototype._receiveUpdate=function(n,e){var t=Uh.dig(this.localPresences,e.id);if(t)return t._ack(n,e.pv);if(n)return this.emit("error",n);var o=this,r=Uh.digOrCreate(this._remotePresenceInstances,e.id,function(){return o._createRemotePresence(e.id)});r.receiveUpdate(e)},Mt.prototype._updateRemotePresence=function(n){this.remotePresences[n.presenceId]=n.value,n.value===null&&this._removeRemotePresence(n.presenceId),this.emit("receive",n.presenceId,n.value)},Mt.prototype._broadcastAllLocalPresence=function(n){if(n)return this.emit("error",n);for(var e in this.localPresences){var t=this.localPresences[e];t.value!==null&&t.send()}},Mt.prototype._removeRemotePresence=function(n){this._remotePresenceInstances[n].destroy(),delete this._remotePresenceInstances[n],delete this.remotePresences[n]},Mt.prototype._onConnectionStateChanged=function(){if(!!this.connection.canSend){this._resubscribe();for(var n in this.localPresences)this.localPresences[n]._sendPending()}},Mt.prototype._resubscribe=function(){var n=[];for(var e in this._subscriptionCallbacksBySeq){var t=this._subscriptionCallback(e);n.push(t)}if(!this.wantSubscribe)return this._callEachOrEmit(n);var o=this;this.subscribe(function(r){o._callEachOrEmit(n,r)})},Mt.prototype._subscriptionCallback=function(n){var e=this._subscriptionCallbacksBySeq[n];return delete this._subscriptionCallbacksBySeq[n],e},Mt.prototype._callbackOrEmit=function(n,e){if(e)return Uh.nextTick(e,n);n&&this.emit("error",n)},Mt.prototype._createLocalPresence=function(n){return new gS(this,n)},Mt.prototype._createRemotePresence=function(n){return new pS(this,n)},Mt.prototype._callEachOrEmit=function(n,e){var t=Uh.callEach(n,e);!t&&e&&this.emit("error",e)};var Wa=Bb,Sb=Ph,AS=Fo,Lb=Sb.CODES,bS=No;function No(n,e){Wa.call(this,n,e),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()}No.prototype=Object.create(Wa.prototype),No.prototype.submit=function(n,e){if(!this._doc.type){if(n===null)return this._callbackOrEmit(null,e);var t={code:Lb.ERR_DOC_DOES_NOT_EXIST,message:"Cannot submit presence. Document has not been created"};return this._callbackOrEmit(t,e)}this._docDataVersionByPresenceVersion[this.presenceVersion]=this._doc._dataStateVersion,Wa.prototype.submit.call(this,n,e)},No.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),Wa.prototype.destroy.call(this,n)},No.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(e){e.t=n._doc.type.uri,e.v=n._doc.version,n.connection.send(e)}),n._pendingMessages=[],n._docDataVersionByPresenceVersion={})})}},No.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)},No.prototype._transformAgainstOp=function(n,e){var t=this,o=this._doc._dataStateVersion;this._pendingMessages.forEach(function(r){var i=t._docDataVersionByPresenceVersion[r.pv];if(!(i>=o))try{r.p=t._transformPresence(r.p,n,e),t._docDataVersionByPresenceVersion[r.pv]=o}catch(l){var s=t._getCallback(r.pv);t._callbackOrEmit(l,s)}});try{this.value=this._transformPresence(this.value,n,e)}catch(r){this.emit("error",r)}},No.prototype._handleCreateOrDel=function(){this._pendingMessages.forEach(function(n){n.p=null}),this.value=null},No.prototype._handleLoad=function(){this.value=null,this._pendingMessages=[],this._docDataVersionByPresenceVersion={}},No.prototype._message=function(){var n=Wa.prototype._message.call(this);return n.c=this.collection,n.d=this.id,n.v=null,n.t=null,n},No.prototype._transformPresence=function(n,e,t){var o=this._doc.type;if(!AS.supportsPresence(o))throw new Sb(Lb.ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE,"Type does not support presence: "+o.name);return o.transformPresence(n,e,t)};var Mb={};(function(n){var e=Ua,t=Ph,o=Fo,r=t.CODES;n.checkOp=function(l){if(l==null||typeof l!="object")return new t(r.ERR_OT_OP_BADLY_FORMED,"Op must be an object");if(l.create!=null){if(typeof l.create!="object")return new t(r.ERR_OT_OP_BADLY_FORMED,"Create data must be an object");var a=l.create.type;if(typeof a!="string")return new t(r.ERR_OT_OP_BADLY_FORMED,"Missing create type");var d=e.map[a];if(d==null||typeof d!="object")return new t(r.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type")}else if(l.del!=null){if(l.del!==!0)return new t(r.ERR_OT_OP_BADLY_FORMED,"del value must be true")}else if(!("op"in l))return new t(r.ERR_OT_OP_BADLY_FORMED,"Missing op, create, or del");if(l.src!=null&&typeof l.src!="string")return new t(r.ERR_OT_OP_BADLY_FORMED,"src must be a string");if(l.seq!=null&&typeof l.seq!="number")return new t(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 t(r.ERR_OT_OP_BADLY_FORMED,"Both src and seq must be set together");if(l.m!=null&&typeof l.m!="object")return new t(r.ERR_OT_OP_BADLY_FORMED,"op.m must be an object or null")},n.normalizeType=function(l){return e.map[l]&&e.map[l].uri},n.apply=function(l,a){if(typeof l!="object")return new t(r.ERR_APPLY_SNAPSHOT_NOT_PROVIDED,"Missing snapshot");if(l.v!=null&&a.v!=null&&l.v!==a.v)return new t(r.ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT,"Version mismatch");if(a.create){if(l.type)return new t(r.ERR_DOC_ALREADY_CREATED,"Document already exists");var d=a.create,h=e.map[d.type];if(!h)return new t(r.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{l.data=h.create(d.data),l.type=h.uri,l.v++}catch(A){return A}}else if(a.del)l.data=void 0,l.type=null,l.v++;else if("op"in a){var p=i(l,a.op);if(p)return p;l.v++}else l.v++};function i(l,a){if(!l.type)return new t(r.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");if(a===void 0)return new t(r.ERR_OT_OP_NOT_PROVIDED,"Missing op");var d=e.map[l.type];if(!d)return new t(r.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{l.data=d.apply(l.data,a)}catch(h){return new t(r.ERR_OT_OP_NOT_APPLIED,h.message)}}n.transform=function(l,a,d){if(a.v!=null&&a.v!==d.v)return new t(r.ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM,"Version mismatch");if(d.del){if(a.create||"op"in a)return new t(r.ERR_DOC_WAS_DELETED,"Document was deleted")}else{if(d.create&&("op"in a||a.create||a.del)||"op"in d&&a.create)return new t(r.ERR_DOC_ALREADY_CREATED,"Document was created remotely");if("op"in d&&"op"in a){if(!l)return new t(r.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");if(typeof l=="string"&&(l=e.map[l],!l))return new t(r.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{a.op=l.transform(a.op,d.op,"left")}catch(h){return h}}}a.v!=null&&a.v++},n.applyOps=function(l,a,d){d=d||{};for(var h=0;h<a.length;h++){var p=a[h];if(d._normalizeLegacyJson0Ops)try{s(l,p)}catch{return new t(r.ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED,"Cannot normalize legacy json0 op")}l.v=p.v;var A=n.apply(l,p);if(A)return A}},n.transformPresence=function(l,a,d){var h=this.checkOp(a);if(h)return h;var p=l.t;if(typeof p=="string"&&(p=e.map[p]),!p)return{code:r.ERR_DOC_TYPE_NOT_RECOGNIZED,message:"Unknown type"};if(!o.supportsPresence(p))return{code:r.ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE,message:"Type does not support presence"};if(a.create||a.del){l.p=null,l.v++;return}try{l.p=l.p===null?null:p.transformPresence(l.p,a.op,d)}catch(A){return{code:r.ERR_PRESENCE_TRANSFORM_FAILED,message:A.message||A}}l.v++};function s(l,a){if(l.type===e.defaultType.uri){var d=a.op;if(!!d){var h=l.data;d.length>1&&(h=o.clone(h));for(var p=0;p<d.length;p++){var A=d[p];typeof A.lm=="string"&&(A.lm=+A.lm);for(var v=A.p,B=h,D=0;D<v.length;D++){var I=v[D];Object.prototype.toString.call(B)=="[object Array]"?v[D]=+I:B.constructor===Object&&(v[D]=I.toString()),B=B[I]}p<d.length-1&&(h=e.defaultType.apply(h,[A]))}}}}})(Mb);var qa=Eb,vS=Mb,yS=co;function co(n,e){qa.call(this,n,e),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()}co.prototype=Object.create(qa.prototype),co.prototype.receiveUpdate=function(n){this._pending&&n.pv<this._pending.pv||(this.src=n.src,this._pending=n,this._setPendingPresence())},co.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),qa.prototype.destroy.call(this,n)},co.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)},co.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))}})}},co.prototype._handleOp=function(n,e,t){var o=t===this.src;this._transformAgainstOp(n,o),this._cacheOp(n,o),this._setPendingPresence()},qa.prototype._handleCreateDel=function(){this._cacheOp(null),this._setPendingPresence()},qa.prototype._handleLoad=function(){this.value=null,this._pending=null,this._opCache=null,this.presence._updateRemotePresence(this)},co.prototype._transformAgainstOp=function(n,e){if(!!this.value){try{this.value=this._doc.type.transformPresence(this.value,n,e)}catch(t){return this.presence.emit("error",t)}this.presence._updateRemotePresence(this)}},co.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],e=n.op,t=n.isOwnOp;e===null?(this._pending.p=null,this._pending.v++):vS.transformPresence(this._pending,e,t)}var o=this._pending.v>=this._doc.version;return o&&this._stopCachingOps(),o},co.prototype._startCachingOps=function(){this._opCache=[]},co.prototype._stopCachingOps=function(){this._opCache=null},co.prototype._cacheOp=function(n,e){this._opCache&&(n=n?{op:n}:null,this._opCache[this._doc.version-1]={op:n,isOwnOp:e})};var Rb=Db,kS=bS,wS=yS;function ec(n,e,t){var o=ec.channel(e,t);Rb.call(this,n,o),this.collection=e,this.id=t}var BS=ec;ec.prototype=Object.create(Rb.prototype),ec.channel=function(n,e){return n+"."+e},ec.prototype._createLocalPresence=function(n){return new kS(this,n)},ec.prototype._createRemotePresence=function(n){return new wS(this,n)};var ES=xS;function xS(n,e,t,o,r){this.id=n,this.v=e,this.type=t,this.data=o,this.m=r}var IS=ES,Ob=$i,_b=Ga;function Ga(n,e,t,o,r){if(Ob.EventEmitter.call(this),typeof r!="function")throw new Error("Callback is required for SnapshotRequest");this.requestId=e,this.connection=n,this.id=o,this.collection=t,this.callback=r,this.sent=!1}Ob.mixin(Ga),Ga.prototype.send=function(){!this.connection.canSend||(this.connection.send(this._message()),this.sent=!0)},Ga.prototype._onConnectionStateChanged=function(){this.connection.canSend?this.sent||this.send():this.sent=!1},Ga.prototype._handleResponse=function(n,e){if(this.emit("ready"),n)return this.callback(n);var t=e.meta?e.meta:null,o=new IS(this.id,e.v,e.type,e.data,t);this.callback(null,o)};var Fb=_b,TS=Fo,DS=Us.ACTIONS,SS=hp;function hp(n,e,t,o,r,i){if(Fb.call(this,n,e,t,o,i),!TS.isValidVersion(r))throw new Error("Snapshot version must be a positive integer or null");this.version=r}hp.prototype=Object.create(Fb.prototype),hp.prototype._message=function(){return{a:DS.snapshotFetch,id:this.requestId,c:this.collection,d:this.id,v:this.version}};var Pb=_b,LS=Fo,MS=Us.ACTIONS,RS=fp;function fp(n,e,t,o,r,i){if(Pb.call(this,n,e,t,o,i),!LS.isValidTimestamp(r))throw new Error("Snapshot timestamp must be a positive integer or null");this.timestamp=r}fp.prototype=Object.create(Pb.prototype),fp.prototype._message=function(){return{a:MS.snapshotFetchByTimestamp,id:this.requestId,c:this.collection,d:this.id,ts:this.timestamp}};var OS=sS,_S=dS,FS=Db,Nb=BS,PS=SS,NS=RS,$b=$i,tc=Ph,et=Us.ACTIONS,Hb=Ua,$o=Fo,Za=gb,Qa=tc.CODES;function jb(n){return n.readyState===0||n.readyState===1?"connecting":"disconnected"}var $S=we;function we(n){$b.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=jb(n),this.bindToSocket(n)}$b.mixin(we),we.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 e=jb(n);this._setState(e),this.canSend=!1;var t=this;n.onmessage=function(o){try{var r=typeof o.data=="string"?JSON.parse(o.data):o.data}catch{Za.warn("Failed to parse message",o);return}t.debug&&Za.info("RECV",JSON.stringify(r));var i={data:r};if(t.emit("receive",i),!!i.data)try{t.handleMessage(i.data)}catch(s){$o.nextTick(function(){t.emit("error",s)})}},n.readyState===1&&t._initializeHandshake(),n.onopen=function(){t._setState("connecting"),t._initializeHandshake()},n.onerror=function(o){t.emit("connection error",o)},n.onclose=function(o){o==="closed"||o==="Closed"?t._setState("closed",o):o==="stopped"||o==="Stopped by server"?t._setState("stopped",o):t._setState("disconnected",o)}},we.prototype.handleMessage=function(n){var e=null;switch(n.error&&(e=Ub(n.error,n),delete n.error),n.a){case et.initLegacy:return this._handleLegacyInit(n);case et.handshake:return this._handleHandshake(e,n);case et.queryFetch:var t=this.queries[n.id];t&&t._handleFetch(e,n.data,n.extra);return;case et.querySubscribe:var t=this.queries[n.id];t&&t._handleSubscribe(e,n.data,n.extra);return;case et.queryUnsubscribe:return;case et.queryUpdate:var t=this.queries[n.id];if(!t)return;if(e)return t._handleError(e);n.diff&&t._handleDiff(n.diff),n.hasOwnProperty("extra")&&t._handleExtra(n.extra);return;case et.bulkFetch:return this._handleBulkMessage(e,n,"_handleFetch");case et.bulkSubscribe:case et.bulkUnsubscribe:return this._handleBulkMessage(e,n,"_handleSubscribe");case et.snapshotFetch:case et.snapshotFetchByTimestamp:return this._handleSnapshotFetch(e,n);case et.fetch:var o=this.getExisting(n.c,n.d);o&&o._handleFetch(e,n.data);return;case et.subscribe:case et.unsubscribe:var o=this.getExisting(n.c,n.d);o&&o._handleSubscribe(e,n.data);return;case et.op:var o=this.getExisting(n.c,n.d);o&&o._handleOp(e,n);return;case et.presence:return this._handlePresence(e,n);case et.presenceSubscribe:return this._handlePresenceSubscribe(e,n);case et.presenceUnsubscribe:return this._handlePresenceUnsubscribe(e,n);case et.presenceRequest:return this._handlePresenceRequest(e,n);case et.pingPong:return this._handlePingPong(e);default:Za.warn("Ignoring unrecognized message",n)}};function Ub(n,e){var t=new Error(n.message);return t.code=n.code,e&&(t.data=e),t}we.prototype._handleBulkMessage=function(n,e,t){if(e.data)for(var o in e.data){var r=e.data[o],i=this.getExisting(e.c,o);i&&(n?i[t](n):r.error?i[t](Ub(r.error)):i[t](null,r))}else if(Array.isArray(e.b))for(var s=0;s<e.b.length;s++){var o=e.b[s],i=this.getExisting(e.c,o);i&&i[t](n)}else if(e.b)for(var o in e.b){var i=this.getExisting(e.c,o);i&&i[t](n)}else Za.error("Invalid bulk message",e)},we.prototype._reset=function(){this.agent=null},we.prototype._setState=function(n,e){if(this.state!==n){if(n==="connecting"&&this.state!=="disconnected"&&this.state!=="stopped"&&this.state!=="closed"||n==="connected"&&this.state!=="connecting"){var t=new tc(Qa.ERR_CONNECTION_STATE_TRANSITION_INVALID,"Cannot transition directly from "+this.state+" to "+n);return this.emit("error",t)}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 a=this._snapshotRequests[o];a._onConnectionStateChanged()}this.endBulk(),this.emit(n,e),this.emit("state",n,e)}},we.prototype.startBulk=function(){this.bulk||(this.bulk={})},we.prototype.endBulk=function(){if(this.bulk)for(var n in this.bulk){var e=this.bulk[n];this._sendBulk("f",n,e.f),this._sendBulk("s",n,e.s),this._sendBulk("u",n,e.u)}this.bulk=null},we.prototype._sendBulk=function(n,e,t){if(!!t){var o=[],r={},i=0,s;for(var l in t){var a=t[l];a==null?o.push(l):(r[l]=a,s=l,i++)}if(o.length===1){var l=o[0];this.send({a:n,c:e,d:l})}else o.length&&this.send({a:"b"+n,c:e,b:o});if(i===1){var d=r[s];this.send({a:n,c:e,d:s,v:d})}else i&&this.send({a:"b"+n,c:e,b:r})}},we.prototype._sendActions=function(n,e,t){if(this._addDoc(e),this.bulk){var o=this.bulk[e.collection]||(this.bulk[e.collection]={}),r=o[n]||(o[n]={}),i=r.hasOwnProperty(e.id);return r[e.id]=t,i}else{var s={a:n,c:e.collection,d:e.id,v:t};this.send(s)}},we.prototype.sendFetch=function(n){return this._sendActions(et.fetch,n,n.version)},we.prototype.sendSubscribe=function(n){return this._sendActions(et.subscribe,n,n.version)},we.prototype.sendUnsubscribe=function(n){return this._sendActions(et.unsubscribe,n)},we.prototype.sendOp=function(n,e){this._addDoc(n);var t={a:et.op,c:n.collection,d:n.id,v:n.version,src:e.src,seq:e.seq,x:{}};"op"in e&&(t.op=e.op),e.create&&(t.create=e.create),e.del&&(t.del=e.del),n.submitSource&&(t.x.source=e.source),this.send(t)},we.prototype.send=function(n){this.debug&&Za.info("SEND",JSON.stringify(n)),this.emit("send",n),this.socket.send(JSON.stringify(n))},we.prototype.ping=function(){if(!this.canSend)throw new tc(Qa.ERR_CANNOT_PING_OFFLINE,"Socket must be CONNECTED to ping");var n={a:et.pingPong};this.send(n)},we.prototype.close=function(){this.socket.close()},we.prototype.getExisting=function(n,e){if(this.collections[n])return this.collections[n][e]},we.prototype.get=function(n,e){var t=this.collections[n]||(this.collections[n]={}),o=t[e];return o||(o=t[e]=new OS(this,n,e),this.emit("doc",o)),o._wantsDestroy=!1,o},we.prototype._destroyDoc=function(n){!n._wantsDestroy||($o.digAndRemove(this.collections,n.collection,n.id),n.emit("destroy"))},we.prototype._addDoc=function(n){var e=this.collections[n.collection];e||(e=this.collections[n.collection]={}),e[n.id]!==n&&(e[n.id]=n)},we.prototype._createQuery=function(n,e,t,o,r){var i=this.nextQueryId++,s=new _S(n,this,i,e,t,o,r);return this.queries[i]=s,s.send(),s},we.prototype._destroyQuery=function(n){delete this.queries[n.id]},we.prototype.createFetchQuery=function(n,e,t,o){return this._createQuery(et.queryFetch,n,e,t,o)},we.prototype.createSubscribeQuery=function(n,e,t,o){return this._createQuery(et.querySubscribe,n,e,t,o)},we.prototype.hasPending=function(){return!!(this._firstDoc(zh)||this._firstQuery(zh)||this._firstSnapshotRequest())};function zh(n){return n.hasPending()}we.prototype.hasWritePending=function(){return!!this._firstDoc(HS)};function HS(n){return n.hasWritePending()}we.prototype.whenNothingPending=function(n){var e=this._firstDoc(zh);if(e){e.once("nothing pending",this._nothingPendingRetry(n));return}var t=this._firstQuery(zh);if(t){t.once("ready",this._nothingPendingRetry(n));return}var o=this._firstSnapshotRequest();if(o){o.once("ready",this._nothingPendingRetry(n));return}$o.nextTick(n)},we.prototype._nothingPendingRetry=function(n){var e=this;return function(){$o.nextTick(function(){e.whenNothingPending(n)})}},we.prototype._firstDoc=function(n){for(var e in this.collections){var t=this.collections[e];for(var o in t){var r=t[o];if(n(r))return r}}},we.prototype._firstQuery=function(n){for(var e in this.queries){var t=this.queries[e];if(n(t))return t}},we.prototype._firstSnapshotRequest=function(){for(var n in this._snapshotRequests)return this._snapshotRequests[n]},we.prototype.fetchSnapshot=function(n,e,t,o){typeof t=="function"&&(o=t,t=null);var r=this.nextSnapshotRequestId++,i=new PS(this,r,n,e,t,o);this._snapshotRequests[i.requestId]=i,i.send()},we.prototype.fetchSnapshotByTimestamp=function(n,e,t,o){typeof t=="function"&&(o=t,t=null);var r=this.nextSnapshotRequestId++,i=new NS(this,r,n,e,t,o);this._snapshotRequests[i.requestId]=i,i.send()},we.prototype._handleSnapshotFetch=function(n,e){var t=this._snapshotRequests[e.id];!t||(delete this._snapshotRequests[e.id],t._handleResponse(n,e))},we.prototype._handleLegacyInit=function(n){if(n.protocolMinor)return this._initializeHandshake();this._initialize(n)},we.prototype._initializeHandshake=function(){this.send({a:et.handshake,id:this.id})},we.prototype._handleHandshake=function(n,e){if(n)return this.emit("error",n);this._initialize(e)},we.prototype._handlePingPong=function(n){if(n)return this.emit("error",n);this.emit("pong")},we.prototype._initialize=function(n){if(this.state==="connecting"){if(n.protocol!==1)return this.emit("error",new tc(Qa.ERR_PROTOCOL_VERSION_NOT_SUPPORTED,"Unsupported protocol version: "+n.protocol));if(Hb.map[n.type]!==Hb.defaultType)return this.emit("error",new tc(Qa.ERR_DEFAULT_TYPE_MISMATCH,n.type+" does not match the server default type"));if(typeof n.id!="string")return this.emit("error",new tc(Qa.ERR_CLIENT_ID_BADLY_FORMED,"Client id must be a string"));this.id=n.id,this._setState("connected")}},we.prototype.getPresence=function(n){var e=this,t=$o.digOrCreate(this._presences,n,function(){return new FS(e,n)});return t._wantsDestroy=!1,t},we.prototype.getDocPresence=function(n,e){var t=Nb.channel(n,e),o=this,r=$o.digOrCreate(this._presences,t,function(){return new Nb(o,n,e)});return r._wantsDestroy=!1,r},we.prototype._sendPresenceAction=function(n,e,t){this._addPresence(t);var o={a:n,ch:t.channel,seq:e};return this.send(o),o.seq},we.prototype._addPresence=function(n){$o.digOrCreate(this._presences,n.channel,function(){return n})},we.prototype._handlePresenceSubscribe=function(n,e){var t=$o.dig(this._presences,e.ch);t&&t._handleSubscribe(n,e.seq)},we.prototype._handlePresenceUnsubscribe=function(n,e){var t=$o.dig(this._presences,e.ch);t&&t._handleUnsubscribe(n,e.seq)},we.prototype._handlePresence=function(n,e){var t=$o.dig(this._presences,e.ch);t&&t._receiveUpdate(n,e)},we.prototype._handlePresenceRequest=function(n,e){var t=$o.dig(this._presences,e.ch);t&&t._broadcastAllLocalPresence(n,e)};var zb=$S,jS=Ua;const Vh={err:1001,msg:"user auth error",name:"AuthError"},US={err:1002,msg:"you don't have required permission",name:"PermissionError"},mp={err:1003,msg:"Too many user connected",name:"MaxUserError"},Ya={err:1004,msg:"document server changed, reload it",name:"RequestReloadError"},zS={err:1005,msg:"app id must be at least 2 chars, doc id must be at least 5 chars",name:"DocIdError"},VS={err:1028,msg:"upload file ext not allowed",name:"FileExtError"},Ja="x-live-editor-token",Wh="x-live-editor-base-url",gn=S("auth-connection");function WS(n){try{n()}catch(e){gn.error(e)}}class qS{constructor(e,t){m(this,"connection");m(this,"ws");m(this,"retryCount");m(this,"events",new W5.EventEmitter);m(this,"token",null);m(this,"resourceToken",null);this.url=e,this.reauthFunc=t,this.retryCount=0}getBaseURL(){const e=new URL(this.url);return`${e.protocol==="wss:"?"https:":"http:"}//${e.host}${e.pathname}`}getBase64BaseURL(){return Bs(this.getBaseURL())}async auth(e){g(gn,e.token,"no auth token");const t=`${this.getBaseURL()}/auth`,o=await window.fetch(t,{method:"GET",headers:{[Ja]:e.token,[Wh]:this.getBase64BaseURL()},credentials:"include"});if(o.status!==200)throw new Error("http auth error");return this.token=e.token,await o.json()}async logout(){if(!this.token)return;const e=`${this.getBaseURL()}/logout`;await window.fetch(e,{method:"GET",headers:{[Wh]:Bs(this.getBaseURL())}})}async init(e){const t=await this.auth(e);this.resourceToken=t.read,this.ws=new HB.default(this.url,void 0,{maxReconnectionDelay:2500,minReconnectionDelay:1e3}),this.connection=Object.create(zb.prototype),g(gn,this.connection,"no this.connection"),this.ws,this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:e})};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,i);return}if((s=l==null?void 0:l.message)!=null&&s.startsWith("Cannot invert subtype")){this.emitWriteConflictError(l,i);return}throw l}}},zb.apply(this.connection,[this.ws])}async handleAuthError(){if(this.reauthFunc&&this.retryCount<5){this.retryCount+=1,gn.info(`retrying re-auth attempt no. ${this.retryCount}`);try{if(this.connection){const e=await this.reauthFunc();await this.auth(e),this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:e})}}}catch(e){gn.error(e),setTimeout(()=>this.handleAuthError(),0)}}else gn.error("auth error, cannot retry anymore"),this.emitAuthError(),this.end(!1)}emitAuthError(){const e=new Error(Vh.msg);e.code=Vh.err,this.events.emit("error",e)}emitRequestReloadError(){const e=new Error(Ya.msg);e.code=Ya.err,this.events.emit("requestReloadError",e)}emitWriteConflictError(e,t){e.orgMsg=t,this.events.emit("writeConflictError",e)}emitMaxUsersError(){this.events.emit("maxUsersError"),this.end(!1)}handleMessage(e){const t=e;if(t.a==="pong")return;const o=t.err;if(o===Vh.err)gn.warn("auth error"),this.handleAuthError();else if(o===mp.err)gn.warn(mp.msg),this.emitMaxUsersError();else if(o===Ya.err){gn.warn(Ya.msg);try{this.emitRequestReloadError()}catch(r){gn.error(`error occurred while process reload error: ${JSON.stringify(r)}`)}finally{this.end(!1)}}else gn.error(`unknown message received: ${JSON.stringify(t)}`),this.emitAuthError()}get(e,t){return g(gn,this.connection,"no this.connection"),this.connection.get(e,t)}addEventListener(e,t){e==="error"?this.events.addListener(e,t):(g(gn,this.ws,"no this.ws"),this.ws.addEventListener(e,t))}onWriteConflictError(e){this.events.addListener("writeConflictError",e)}onMaxUsersError(e){g(gn,this.events.listenerCount("maxUsersError")===0,"too many maxUserError listener"),this.events.addListener("maxUsersError",e)}onRequestReloadError(e){g(gn,this.events.listenerCount("requestReloadError")===0,"to many requestReloadError listener"),this.events.addListener("requestReloadError",e)}end(e){var t;this.reauthFunc=void 0,this.events.removeAllListeners(),WS(()=>{var o;return(o=this.connection)==null?void 0:o.close()}),this.connection=void 0,(t=this.ws)==null||t.close(),this.ws=void 0,e&&this.logout()}}S("utils/file");function GS(){function n(){return new Promise(e=>{const t=new FileReader;t.onload=()=>{e(t.result)},t.readAsArrayBuffer(this)})}File.prototype.arrayBuffer=File.prototype.arrayBuffer||n,Blob.prototype.arrayBuffer=Blob.prototype.arrayBuffer||n}GS();async function ZS(n){const t=n.size,o=Math.floor((t+102400-1)/102400),r=new jB.Hash;for(let s=0;s<o;s++){const l=s*102400;let a=l+102400;a>t&&(a=t);const h=await n.slice(l,a,n.type).arrayBuffer();r.update(new Uint8Array(h))}const i=r.digest();return Bs(i)}const ur=S("sharedb-doc/client");class QS{constructor(e,t,o){m(this,"connection");m(this,"auth");m(this,"doc",null);m(this,"reauthFunc");m(this,"clientId",K());m(this,"getDoc",async()=>{const e=o=>new Promise((r,i)=>{o.fetch(s=>{s?i(s):r()})});g(ur,!this.doc,"This websocket has opened a doc."),await this.connection.init(this.auth);const t=this.connection.get(this.auth.appId,this.auth.docId);return this.doc=t,await e(t),ur.debug(t),t});this.auth=e;const r=`${t}/${this.auth.appId}/${this.auth.docId}`;jS.register(Fd.type),this.connection=new qS(r,o),this.reauthFunc=o}editorServer(){const e=this.apiServer(),t=`/${this.auth.appId}/${this.auth.docId}`;return g(ur,e.endsWith(t),`invalid api server: ${e}, ${t}`),e.substr(0,e.length-t.length)}close(e){this.connection.end(e),this.doc=null}on(e,t){this.connection.addEventListener(e,o=>{(e==="error"||this.doc)&&t(o)})}onWriteConflictError(e){this.connection.onWriteConflictError(e)}onMaxUsersError(e){this.connection.onMaxUsersError(e)}onRequestReloadError(e){this.connection.onRequestReloadError(e)}async authOnly(){await this.connection.auth(this.auth)}getResourceToken(){return this.connection.resourceToken}hasDocContainer(){return!!this.doc}apiServer(){const e=this.connection.url;if(e.startsWith("ws://"))return`http://${e.substring(5)}`;if(e.startsWith("wss://"))return`https://${e.substring(6)}`;throw new Error(`invalid server url: ${e}`)}async getFileUrlByHash(e,t,o,r,i){try{const s=`${e}/${t}`,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(e){const o=`${this.apiServer()}/resources`;let r=[];e.forEach(l=>{const a=l.split("|");r.push(...a)}),r=Array.from(new Set(r));const i=r.map(l=>this.getFileUrlByHash(o,l,"",0,{[Ja]:this.connection.token}));return await Promise.all(i)}async uploadFile(e,t,o,r,i){let s=t.size;if(s===0)throw new Error("file is empty");s+=500;const l=v=>{ur.info(`on progress: ${v.loaded}`);let B=v.loaded*100/s;B>100&&(B=100),r(B)},a=await ZS(t),d=await this.getFileUrlByHash(e,a,t.name,t.size,o);if(d)return r(-1),d;let h=e;i!=null&&i.thumbnail&&(h+="/thumbnail");const p=new FormData;p.append("file-size",`${t.size}`),p.append("file-hash",a),p.append("file",t,t.name);const A=await this.request(h,{method:"post",data:p,withCredentials:!0,headers:{...o},onUploadProgress:l});return ur.info(A),r(100),Array.isArray(A.data)?A.data[0]:A.data}async uploadResource(e,t=()=>{},o){const i=`${this.apiServer()}/resources`;g(ur,this.connection.token,"no connection token");const s=await this.uploadFile(i,e,{[Ja]:this.connection.token},t,o);return g(ur,s,"no result"),s}async request(e,t){var i,s;let o=this.connection.token,r;for(let l=0;l<2;l++){const a=t||{};a.url=e,a.headers||(a.headers={}),g(ur,o,"no token"),a.headers={...a.headers,[Ja]:o,[Wh]:this.connection.getBase64BaseURL()};try{return await NB.default(e,a)}catch(d){if(r=d,((i=d==null?void 0:d.response)==null?void 0:i.status)===403&&this.reauthFunc){const h=await this.reauthFunc();if(await this.connection.auth(h),!h.token)throw d;o=h.token;continue}throw(s=d.response)!=null&&s.data&&(d.responseData=d.response.data),d}}throw g(ur,r,"no error"),r}async getVersions(){const t=`${this.apiServer()}/versions?withExtra=true`,r=(await this.request(t)).data.versions;return r.forEach(i=>{i.extra&&(i.extra=JSON.parse(i.extra))}),r}async getVersion(e){const o=`${this.apiServer()}/versions/${e}`,r=await this.request(o);return JSON.parse(r.data.data)}async getLatestVersion(){const t=`${this.apiServer()}/versions/latest`,o=await this.request(t);return JSON.parse(o.data.data)}async getVersionOps(e,t){let r=`${this.apiServer()}/versions/before/${e}?withOp=true`;t!==void 0&&t!==0&&(r+=`&from=${t}`);const i=await this.request(r),s=i.data.ops,l=$B.default(s,h=>!!h.create);let a=null;l!==-1&&(a=s[l],s.splice(0,l+1));let d;return a?(g(ur,a.create,"no createDoc.create"),d=a.create.data):d=JSON.parse(i.data.data),d.blocks||(d.blocks=[]),{doc:d,ops:i.data.ops}}async updateVersionExtra(e,t,o){const i=`${this.apiServer()}/versions/${e}/tags/${t}`;await this.request(i,{method:"post",data:{extra:JSON.stringify(o)}})}async revertVersion(e){const o=`${this.apiServer()}/versions/revert/${e}`;await this.request(o,{method:"post",data:{}})}async createVersion(e,t){const r=`${this.apiServer()}/versions`;return(await this.request(r,{method:"post",data:{publish:t,tag:e}})).data}async recognizeLink(e){const o=`${this.apiServer()}/resources/external/${Bs(e)}`;return(await this.request(o)).data}buildResourceUrl(e,t){if(!e)return"";if(e.startsWith("https:")||e.startsWith("http:")||e.startsWith("file:")||e.startsWith("data:")||e.startsWith("blob:"))return e;let r=`${this.apiServer()}/resources/${encodeURIComponent(e)}`;const i=[];if(t!=null&&t.withToken&&i.push(`token=${this.getResourceToken()}`),t!=null&&t.downloadFileName&&i.push(`&fileName=${encodeURIComponent(t.downloadFileName)}`),i.length>0){const s=i.join("&");r+=`?${s}`}return r}}function YS(){return{blocks:[{id:K(),type:"text",text:[]}],comments:{},meta:{}}}const gp=S("block-ids");class JS{constructor(){m(this,"ids",new Map)}onInsertBlock(e){const t=Array.from(this.ids.keys()).sort((r,i)=>i-r);for(let r=0;r<t.length;r++){const i=t[r];if(i>=e){const s=this.ids.get(i);g(gp,s!==void 0,"old id is not exists"),this.ids.delete(i),this.ids.set(i+1,s)}}const o=K();this.ids.set(e,o)}onDeleteBlock(e){this.ids.delete(e);const t=Array.from(this.ids.keys()).sort((o,r)=>o-r);for(let o=0;o<t.length;o++){const r=t[o];if(r>e){const i=this.ids.get(r);g(gp,i!==void 0,"old id is not exists"),this.ids.delete(r),this.ids.set(r-1,i)}}}getId(e){let t=this.ids.get(e);return t||(t=K(),this.ids.set(e,t)),t}getById(e){return Array.from(this.ids.entries()).find(([,t])=>t===e)}}class KS{constructor(){m(this,"ids",new Map)}getContainerIds(e){let t=this.ids.get(e);return t||(t=new JS,this.ids.set(e,t)),t}onInsertBlock(e,t){this.getContainerIds(e).onInsertBlock(t)}onDeleteBlock(e,t){this.getContainerIds(e).onDeleteBlock(t)}getBlockId(e,t){return this.getContainerIds(e).getId(t)}getBlockIndexById(e){const t=Array.from(this.ids.entries());for(let o=0;o<t.length;o++){const r=t[o],i=r[1].getById(e);if(i)return{containerId:r[0],blockIndex:i[0]}}return g(gp,!1,"fault error: failed to get block index"),{containerId:"error",blockIndex:-1}}}class Vb{constructor(e=new Set,t=new Map){this.deletedKeys=e,this.insertedValues=t}insert(e,t){this.insertedValues.set(e,t)}delete(e){this.deletedKeys.add(e)}toDocBlockDelta(){const e={};return this.insertedValues.forEach((t,o)=>{e[o]=t}),{insert:e,delete:Array.from(this.deletedKeys)}}}const qh=S("op-parse-handler");class XS{constructor(e,t){m(this,"actions",[]);this.outerHandler=e,this.local=t}pushActions(e){if(!e.containerId){this.actions.push(e);return}const o={...e,containerId:(r=>r==="blocks"?"root":r)(e.containerId)};this.actions.push(o)}onDeleteBlock(e,t){this.pushActions({type:"deleteBlock",containerId:e,blockIndex:t})}onInsertBlock(e,t,o){this.pushActions({type:"insertBlock",containerId:e,blockIndex:t,data:o})}onDeleteBlockData(e,t,o){this.pushActions({type:"deleteBlockData",containerId:e,blockIndex:t,key:o})}onInsertBlockData(e,t,o,r){this.pushActions({type:"insertBlockData",containerId:e,blockIndex:t,key:o,value:r})}onUpdateBlockText(e,t,o){this.pushActions({type:"updateBlockText",containerId:e,blockIndex:t,richTextData:o})}onDeleteContainer(e){this.pushActions({type:"deleteContainer",containerId:e})}onCreateContainer(e,t){this.pushActions({type:"createContainer",containerId:e,data:t})}onDeleteComment(e){this.pushActions({type:"deleteComment",commentId:e})}onCreateComment(e){this.pushActions({type:"createComment",commentId:e})}onUpdateComment(e){this.pushActions({type:"updateComment",commentId:e})}end(){const e=this.actions,t=new Set,o=new Map,r=new KS,i=e.filter(s=>s.type==="deleteBlock"||s.type==="deleteBlockData");for(const s of i)if(s.type==="deleteBlock"){const l=s,a=r.getBlockId(l.containerId,l.blockIndex);r.onDeleteBlock(l.containerId,l.blockIndex);const d=o.get(a);d&&(qh.debug(`ignore update object data before delete block: ${JSON.stringify(d)}`),o.delete(a));const h=`${l.containerId}-${l.blockIndex}`;t.add(h),this.outerHandler.onDeleteBlock(l.containerId,l.blockIndex,this.local)}else if(s.type==="deleteBlockData"){const l=s,a=`${l.containerId}-${l.blockIndex}`;if(t.has(a)){qh.warn("delete block data after delete block, ignore it");continue}const d=r.getBlockId(l.containerId,l.blockIndex);let h=o.get(d);h||(h=new Vb,o.set(d,h)),h.delete(l.key)}else g(qh,!1,`invalid action type, ${s.type}`);this.actions.forEach(s=>{if(s.type==="deleteContainer"){const l=s;this.outerHandler.onDeleteContainer(l.containerId,this.local)}else if(s.type==="deleteComment"){const l=s;this.outerHandler.onDeleteComment(l.commentId,this.local)}}),this.actions.forEach(s=>{if(s.type==="createContainer"){const l=s;this.outerHandler.onCreateContainer(l.containerId,l.data,this.local)}}),this.actions.forEach(s=>{if(s.type==="insertBlock"){const l=s;this.outerHandler.onInsertBlock(l.containerId,l.blockIndex,l.data,this.local)}else if(s.type==="insertBlockData"){const l=s,a=r.getBlockId(l.containerId,l.blockIndex);let d=o.get(a);d||(d=new Vb,o.set(a,d)),d.insert(l.key,l.value)}else if(s.type==="updateBlockText"){const l=s;this.outerHandler.onUpdateBlockText(l.containerId,l.blockIndex,l.richTextData,this.local)}else if(s.type==="createComment"){const l=s;this.outerHandler.onCreateComment(l.commentId,this.local)}else if(s.type==="updateComment"){const l=s;this.outerHandler.onUpdateComment(l.commentId,this.local)}}),Array.from(o.entries()).forEach(([s,l])=>{const{containerId:a,blockIndex:d}=r.getBlockIndexById(s);qh.debug(`update block data: ${a}, ${d}, ${JSON.stringify(l.toDocBlockDelta())}`),this.outerHandler.onUpdateBlockData(a,d,l.toDocBlockDelta(),this.local)})}}const Rt=S("op-parser");class Wb{}class pp{constructor(e){m(this,"key");this.key=e}}function eL(n,e,t){const o=e.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 a=o[l];if(!Array.isArray(a)||a.length!==2||typeof a[0]!="string")return!1;const h=a[1];if(typeof h!="object"||h.i===void 0||Object.keys(h).length!==1)return!1}const s=i.i;g(Rt,s.id,"block id is required"),g(Rt,s.type,"block type is required");for(let l=1;l<o.length;l++){const a=o[l],d=a[0],h=a[1];s[d]=h.i}return t.onInsertBlock(n,r,s),!0}function Cp(n,e,t,o){if(t==="upsert"&&eL(n,e,o))return;g(Rt,Array.isArray(e),`invalid block op: ${n}, ${JSON.stringify(e)}`);const r=e.concat(),i=r[0];r.shift();const s=[];for(;r.length>0;){const l=r[0];if(l==="text"){const a=r[1];if(g(Rt,typeof a=="object",`invalid block op: ${n}, ${JSON.stringify(e)}`),g(Rt,a.et==="rich-text",`invalid block op: ${n}, ${JSON.stringify(e)}`),r.splice(0,2),t==="upsert"){const h=a.e;o.onUpdateBlockText(n,i,h)}g(Rt,r.length===0,`invalid block ops.length !== 0, ${JSON.stringify(r)}`)}else if(Array.isArray(l)){g(Rt,l.length===2,`invalid block op: data.length !== 2, ${JSON.stringify(l)}`);const a=l[0];g(Rt,typeof a=="string",`invalid block op: key ${JSON.stringify(a)}`);const d=l[1];if(a==="text"){if(g(Rt,typeof d=="object",`invalid opData type, ${JSON.stringify(d)}`),d.i&&t==="upsert"&&o.onInsertBlockData(n,i,a,d.i),d.r&&t==="remove"&&o.onDeleteBlockData(n,i,a),d.et==="rich-text"&&t==="upsert"){const p=d.e;o.onUpdateBlockText(n,i,p)}}else t==="remove"&&d.r&&s.push(new pp(a)),t==="upsert"&&d.i&&o.onInsertBlockData(n,i,a,d.i);r.shift()}else if(typeof l=="object"){const a=l;t==="remove"&&a.r&&s.push(new Wb),t==="upsert"&&a.i&&o.onInsertBlock(n,i,a.i),r.shift()}else{g(Rt,typeof l=="string","data is not string"),g(Rt,l!=="text","data !== 'text'"),g(Rt,r.length===2,`invalid block op: ops.length !== 2, ${JSON.stringify(r)}`);const a=l,d=r[1];t==="remove"&&d.r&&s.push(new pp(a)),t==="upsert"&&d.i&&o.onInsertBlockData(n,i,a,d.i),r.splice(0,2)}}s.reverse(),s.forEach(l=>{l instanceof Wb?o.onDeleteBlock(n,i):l instanceof pp?o.onDeleteBlockData(n,i,l.key):g(Rt,!1,`invalid action type: ${typeof l}, ${JSON.stringify(l)}`)})}function tL(n,e,t){Rt.warn(`unsupported meta op, ${JSON.stringify(n)}`)}function nL(n,e,t){const o=n[1],r=n[2];g(Rt,o,`invalid comment op, no commentId: ${JSON.stringify(n)}`),g(Rt,r,`invalid comment op, no actions: ${JSON.stringify(n)}`),typeof r=="string"?Rt.error(`unknown comment op, ${JSON.stringify(n)}`):r.i&&r.r?e==="upsert"&&t.onUpdateComment(o):r.i?e==="upsert"&&t.onCreateComment(o):r.r?e==="remove"&&t.onDeleteComment(o):Rt.error(`unknown comment op, ${JSON.stringify(n)}`)}function Ap(n,e,t){const o=n[0];if(Array.isArray(o)){o.forEach(s=>{Ap(s,e,t)});return}const r=o;if(g(Rt,typeof r=="string",`invalid container id: ${JSON.stringify(n)}`),r==="meta"){tL(n);return}if(r==="comments"){nL(n,e,t);return}const i=r;if(Array.isArray(n[1]))e==="remove"?n.slice(1).reverse().forEach(s=>{Cp(i,s,e,t)}):n.slice(1).forEach(s=>{Cp(i,s,e,t)});else if(typeof n[1]=="object"){const s=n[1];s.r&&e==="remove"&&t.onDeleteContainer(i),s.i&&e==="upsert"&&t.onCreateContainer(i,s.i)}else g(Rt,typeof n[1]=="number",`invalid ops[1], not a number: ${JSON.stringify(n)}`),Cp(i,n.slice(1),e,t)}function qb(n,e,t){const o=new XS(e,t);for(let r=0;r<2;r++){const i=r===0?"remove":"upsert",s=me.default(n),l=s[0];Array.isArray(l)?s.forEach(a=>{Ap(a,i,o)}):Ap(s,i,o)}o.end()}const oL=S("sharedb-comments");function bp(n){const e=n.blocks;g(oL,e,"no comment blocks");const t={blocks:{root:e},meta:{},comments:{}};return Object.entries(n).forEach(([o,r])=>{Array.isArray(r)&&(t.blocks[o]=r)}),me.default(t)}function Gb(n){const{id:e,groupId:t,userId:o,displayName:r,avatarUrl:i,abstract:s,created:l,modified:a}=n;return{id:e,groupId:t,userId:o,displayName:r,avatarUrl:i,abstract:s,created:l,modified:a}}function vp(n,e){const t=jD(e),{comments:o,meta:r,blocks:i,...s}=t,l={...n,blocks:i,...s},a=me.default(l);return delete a.children,a}const at=S("sharedb-doc/doc-container"),Zb="ot-json1";Fd.type.registerSubtype(UD.type),Fd.type.name=Zb,Fd.type.invert=null;class Ka extends fa{constructor(t,o,r=!0){super();m(this,"doc");m(this,"client");m(this,"localPresence");m(this,"remoteCaretHandler",new $D);m(this,"batching",0);m(this,"status","clean");m(this,"disableLogout");m(this,"destroyed",!1);m(this,"handleNothingPending",()=>{this.setStatus("clean")});m(this,"handleCreate",()=>{this.handleReload("doc created")});m(this,"handleDel",()=>{});m(this,"handleReload",t=>{this.callbacks.forEach(o=>{var r;return(r=o.onRequestReload)==null?void 0:r.call(o,t)})});m(this,"handleReset",async t=>{const o=new Error(`reset doc: ${t}`);o.code="ResetDoc",this.callbacks.forEach(r=>{var i;return(i=r.onError)==null?void 0:i.call(r,o)}),this.destroy()});m(this,"handleWriteConflictError",t=>{this.handleReset(`write conflict: ${t.message}, ${JSON.stringify(t.orgMsg)}`)});m(this,"insertObject",async(t,o,r)=>{const i=[t,o,{i:r}];return this.submitOp(i)});m(this,"deleteObject",async(t,o)=>{const r=[t,o,{r:!0}];return this.submitOp(r)});m(this,"replaceObject",async(t,o,r)=>{const i=[t,o,{r:!0,i:r}];return this.submitOp(i)});m(this,"updateObject",async(t,o,r)=>{const i=this.data()[t][o],s=[t,o];return Object.entries(r).forEach(([l,a])=>{if(!ua.default(i[l],a))if(i[l]===void 0){if(a!=null){const d={i:a};s.push([l,d])}}else if(a==null){const d={r:!0};s.push([l,d])}else{const d={r:!0,i:a};s.push([l,d])}}),Object.entries(i).forEach(([l,a])=>{if((r[l]===void 0||r[l]===null)&&a!==void 0){const d={r:!0};s.push([l,d])}}),s.length<=2?Promise.resolve():this.submitOp(s)});m(this,"broadcastMessage",async t=>{const o={type:"custom",data:t,clientId:this.client.clientId};this.localPresence&&this.localPresence.submit(o)});m(this,"data",()=>this.doc.data);m(this,"submitOp",async t=>new Promise((o,r)=>{if(this.destroyed){at.warn("submit op after destroyed");return}this.setStatus("dirty"),this.doc.submitOp(t,{},i=>{i?(at.error(`invalid op, ${i.message}, ${JSON.stringify(t)}`),r(i),at.error("Transform detected write conflict, reload editor"),this.handleReset("write conflict")):o()}),this.doc.data||(at.error("no data after submit op, may be the submitted op is invalid"),this.handleReset(`invalid op, ${JSON.stringify(t)}`))}));m(this,"createDoc",async t=>new Promise((o,r)=>{this.doc.create(t,Zb,i=>{i?r(i):o()})}));m(this,"submitInsertChildContainer",async(t,o)=>{const r=[Ni(t),{i:o}];return this.submitOp(r)});m(this,"submitDeleteChildContainer",async t=>{const o=[Ni(t),{r:!0}];return this.submitOp(o)});m(this,"submitInsertBlock",async(t,o,r)=>{const i=[Ni(t),o,{i:r}];return this.submitOp(i)});m(this,"submitDeleteBlock",async(t,o)=>{const r=[Ni(t),o,{r:!0}];return this.submitOp(r)});m(this,"submitUpdateBlockData",async(t,o,r)=>{if(r.delete.length===0&&Object.keys(r.insert).length===0)return Promise.resolve();const i=[Ni(t),o],s=new Set(r.delete);Object.entries(r.insert).forEach(([a,d])=>{if(s.has(a)){const h={r:!0,i:d};i.push([a,h])}});const l=new Set(Object.keys(r.insert));return r.delete.forEach(a=>{if(l.has(a))return;const d={r:!0};i.push([a,d])}),Object.entries(r.insert).forEach(([a,d])=>{if(s.has(a))return;const h={i:d};i.push([a,h])}),this.submitOp(i)});m(this,"submitUpdateRichText",async(t,o,r)=>{const i=[Ni(t),o,"text",{e:r,et:"rich-text"}];return this.submitOp(i)});m(this,"handleOp",(t,o,r)=>{if(this.destroyed){at.warn("handleOp: destroyed");return}qb(t,this,!!o)});this.client=t,this.doc=o,this.doc.preventCompose=!0,this.disableLogout=r,this.registerCallback(this.remoteCaretHandler)}beginBatchUpdate(){return this.doc.preventCompose=!1,this.batching++,this.batching}endBatchUpdate(){return this.batching--,g(at,this.batching>=0,"invalid call beginBatchUpdate/endBatchUpdate"),this.batching===0&&(this.doc.preventCompose=!0),this.batching}static async load(t){try{const o=new QS(t.auth,t.serverUrl,t.reauthFunc),r=await o.getDoc(),i=new Ka(o,r,t.disableLogout);if(r.type===null){if(t.autoCreateDoc===!1){const s=new Error("doc not exists");throw s.code="DocNotExists",s}await i.createDoc(t.templateData||YS())}return await i.initPresence(),await i.subscribe(),i.initEvents(),i}catch(o){throw at.error(o),at.error(`failed to load doc: ${JSON.stringify(o)}`),o}}setStatus(t){this.status!==t&&(this.status=t,this.callbacks.forEach(o=>{var r;return(r=o.onStatusChanged)==null?void 0:r.call(o,t)}))}initEvents(){this.doc.on("nothing pending",this.handleNothingPending),this.doc.on("create",this.handleCreate),this.doc.on("del",this.handleDel),this.client.onWriteConflictError(this.handleWriteConflictError)}clearEvents(){this.doc.off("nothing pending",this.handleNothingPending),this.doc.off("create",this.handleCreate),this.doc.off("del",this.handleDel)}initPresence(){return new Promise((t,o)=>{if(this.localPresence)t();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(K()),t())})}})}subscribe(){return new Promise((t,o)=>{this.doc.subscribe(r=>{r?o(r):(this.doc.on("op",this.handleOp),t())})})}toJSON(){return ja(this.data())}getContainerBlocks(t){const o=this.data();g(at,o,"no doc data");const r=o[Ni(t)];return g(at,r,`no container data: ${t}`),me.default(r)}getBlockData(t,o){const r=this.data();g(at,r,"no doc data");const i=r[Ni(t)];g(at,i,`no container data: ${t}`);const s=i[o];return g(at,s,`no block data: ${o}`),me.default(s)}localInsertBlock(t,o,r){return this.submitInsertBlock(t,o,r),this.getBlockData(t,o)}localDeleteBlock(t,o){const r=this.getBlockData(t,o);return this.submitDeleteBlock(t,o),r}localUpdateBlockText(t,o,r){const i=this.getBlockData(t,o);g(at,i.text,"no block text");const s=me.default(i.text);this.submitUpdateRichText(t,o,r);const l=ln.apply(s,r);return g(at,l,"no block text"),l}localUpdateBlockData(t,o,r){const i=me.default(this.getBlockData(t,o));return this.submitUpdateBlockData(t,o,r),i}localInsertChildContainer(t,o){this.submitInsertChildContainer(t,o)}localDeleteChildContainers(t){this.beginBatchUpdate(),t.forEach(o=>{this.submitDeleteChildContainer(o)}),this.endBatchUpdate()}getComments(){return Object.values(this.data().comments).map(o=>Gb(o))}getComment(t){return this.data().comments[t]}getCommentDoc(t){const o=this.data().comments[t];return bp(o)}localCreateComment(t,o){const r=vp(t,o),s=["comments",r.id,{i:r}];return this.submitOp(s)}localDeleteComment(t){const o=["comments",t,{r:!0}];return this.submitOp(o)}localUpdateComment(t,o){const r=vp(t,o),i=["comments",t.id,{r:!0,i:r}];return this.submitOp(i)}destroy(){var t;this.destroyed=!0,this.clearEvents(),this.clearCallbacks(),this.doc.destroy(),(t=this.localPresence)==null||t.destroy(),this.client.close(!this.disableLogout),this.remoteCaretHandler.destroy()}onDeleteBlock(t,o,r){g(at,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var s;return(s=i.onDeleteBlock)==null?void 0:s.call(i,Xl(t),o,r)})}onInsertBlock(t,o,r,i){g(at,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onInsertBlock)==null?void 0:l.call(s,Xl(t),o,r,i)})}onUpdateBlockData(t,o,r,i){g(at,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,Xl(t),o,r,i)})}onUpdateBlockText(t,o,r,i){g(at,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockText)==null?void 0:l.call(s,Xl(t),o,r,i)})}onDeleteContainer(t,o){g(at,this.callbacks.length>0,"no callbacks"),g(at,t!=="root","should not delete root container in doc"),this.callbacks.forEach(r=>{var i;return(i=r.onDeleteChildContainer)==null?void 0:i.call(r,Xl(t),o)})}onCreateContainer(t,o,r){g(at,this.callbacks.length>0,"no callbacks"),g(at,t!=="root","should not create root container in doc"),this.callbacks.forEach(i=>{var s;return(s=i.onInsertChildContainer)==null?void 0:s.call(i,Xl(t),o,r)})}onDeleteComment(t,o){g(at,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onDeleteComment)==null?void 0:i.call(r,t,o)})}onCreateComment(t,o){g(at,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onCreateComment)==null?void 0:i.call(r,t,o)})}onUpdateComment(t,o){g(at,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onUpdateComment)==null?void 0:i.call(r,t,o)})}onCustomMessage(t){const o=t;(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:t,clientId:"-"};this.onCustomMessage(r)})}async addResources(t){return await this.client.getFileUrlsByHashes(t)}async uploadResource(t,o){var i;return{resourceId:await this.client.uploadResource(t,(i=o==null?void 0:o.onProgress)!=null?i:()=>{})}}buildResourceUrl(t,o){return this.client.buildResourceUrl(t,o)}request(t,o){return this.client.request(t,o)}getUser(){const t=this.client.clientId,{permission:o,userId:r,displayName:i,avatarUrl:s}=this.client.auth;return{permission:o,clientId:t,userId:r,displayName:i,avatarUrl:s,rainbowIndex:0}}getRemoteUsers(){return this.remoteCaretHandler.remoteUsers}getVersionHelper(){return this}getVersions(){return this.client.getVersions()}async getVersion(t){const o=await this.client.getVersion(t);return ja(o)}async getLatestVersion(){const t=await this.client.getLatestVersion();return ja(t)}async getHistoryData(t,o){const{doc:r,ops:i}=await this.client.getVersionOps(t,o),s=i.map(l=>({user:l.meta.createdBy,data:l}));return{doc:ja(r),historyData:s}}async getVersionData(t,o){const{doc:r,ops:i}=await this.client.getVersionOps(t,o);return{doc:ja(r),versionData:i}}async updateVersionExtra(t,o,r){await this.client.updateVersionExtra(t,o,r)}revertVersion(t){return this.client.revertVersion(t)}createVersion(t,o){return this.client.createVersion(t,o)}async recognizeLink(t){return this.client.recognizeLink(t)}parseHistoryData(t,o){qb(t.data.op,o,!0)}getServerMeta(){return{appId:this.client.auth.appId,docId:this.client.auth.docId,serverId:this.client.apiServer()}}}S("remote-cursor");class Qb{constructor(e){m(this,"handleDocSelectionChange",()=>{this.broadcastCaretPos()});m(this,"broadcastCaretPos",Ht.default(()=>{const e={type:"caret",userId:this.editor.doc.getUser().userId,range:this.editor.selection.range.toDocRange()};this.editor.doc.broadcastMessage(e)},300));m(this,"handleRemoteCaretsChanged",e=>{e.forEach(t=>{const o=this.editor.findBlockById(t);o&&this.editor.reloadBlock(o)})});this.editor=e,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 Yb=S("remote-cursor-decorator");class yp{decorateText(e,t,o){const r=e.doc.getRemoteUsers();if(!r)return{};const i=new Map,{containerId:s,blockIndex:l}=t[t.length-1];g(Yb,typeof s=="string","invalid path containerId"),g(Yb,typeof l=="number","invalid path blockIndex");const a=e.doc.getBlockData(s,l),d=rn(o);return r.getSimpleCursors(a.id).forEach((p,A)=>{A>d&&(A=d);const v=p.map(D=>({id:K(),type:"remote-cursor",name:D.user.displayName,time:D.time,rainbowIndex:D.user.rainbowIndex})),B=i.get(A);B?B.push(...v):i.set(A,v)}),{insertions:i}}}class Jb extends bt.TypedEmitter{constructor(e){super(),this.editor=e,this.editor.doc.registerCallback(this)}handleChild(e,t,o){if(Xe($r(this.editor,e)))return;const r=this.editor.getBlockByIndex(e,t),i=oe(this.editor.getContainerById(e));i&&this.emit("change",this.editor,i,r,o)}onUpdateBlockData(e,t){this.handleChild(e,t,"data-change")}onUpdateBlockText(e,t){this.handleChild(e,t,"text-change")}destroy(){this.editor.doc.unregisterCallback(this)}}function rL(n,e){n.addCustom("child-block-tracker",()=>new Jb(n)).addListener("change",e)}function iL(n,e){n.addCustom("child-block-tracker",()=>new Jb(n)).removeListener("change",e)}const tne="",sL={colorPalette:{colorDesc:"\u5B57\u4F53\u989C\u8272",backgroundDesc:"\u80CC\u666F\u989C\u8272",reset:"\u6062\u590D\u9ED8\u8BA4",name:"\u6587\u672C\u989C\u8272"},search:{emptyTips:"\u6682\u65E0\u641C\u7D22\u7ED3\u679C"}},lL={colorPalette:{colorDesc:"Text Color",name:"Text Color",backgroundDesc:"Background Color",reset:"Reset"},search:{emptyTips:"\u6682\u65E0\u641C\u7D22\u7ED3\u679C"}},cL={colorPalette:{colorDesc:"\u30D5\u30A9\u30F3\u30C8\u306E\u8272",backgroundDesc:"\u80CC\u666F\u8272",reset:"\u30C7\u30D5\u30A9\u30EB\u30C8\u306B\u623B\u3059",name:"\u30C6\u30AD\u30B9\u30C8\u306E\u8272"},search:{emptyTips:"\u691C\u7D22\u7D50\u679C\u304C\u3042\u308A\u307E\u305B\u3093"}};R.mergeLang({"zh-CN":sL,"en-US":lL,"js-JP":cL});const nne="";S("button");function ji(n,e,t,o,r){const i=w("button",["editor-button"],null);return i.setAttribute("data-button-id",n),r&&i.setAttribute(`data-editor-tooltip-${r}`,e),t?typeof t=="string"?t.startsWith("<")?i.innerHTML=t:i.innerText=t:i.appendChild(t):i.innerText=e,o&&(o.indexOf("checked")!==-1&&W(i,"checked"),o.indexOf("disabled")!==-1&&(i.disabled=!0)),i}function Kb(n,e,t){t?n.setAttribute(`data-editor-tooltip-${t}`,e):n.innerText=e}const one="",nc=S("ui-command-bar-base"),aL={itemElementTag:"div",tippyArrow:!1},J2=class extends bt.TypedEmitter{constructor(t,o,r){var i,s;super();m(this,"content");m(this,"items");m(this,"subBar",null);m(this,"parentItem",null);m(this,"closeable",null);m(this,"closeReason",null);m(this,"options");m(this,"id");m(this,"header",null);m(this,"footer",null);m(this,"handleDocumentKeydown",t=>{if(!!this.isVisible&&!t.isComposing&&!Ls(t.target)){if(this.subBar){this.subBar.handleDocumentKeydown(t);return}if(this.items.length!==0){if(t.key==="Escape"){this.close("cancelBar");return}if(t.key==="ArrowUp"){const o=this.getPrevItemIndex(this.getSelectedItemIndex());this.startPauseMouseEnter(),this.selectItem(this.items[o].id),t.preventDefault(),t.stopPropagation()}else if(t.key==="ArrowDown"){const o=this.getNextItemIndex(this.getSelectedItemIndex());this.startPauseMouseEnter(),this.selectItem(this.items[o].id),t.preventDefault(),t.stopPropagation()}else if(t.key==="ArrowRight"){const o=this.getSelectedItem();o&&o.children&&this.showSubCommandBar(o.childrenMenuId)}else if(t.key==="ArrowLeft")this.parentItem&&this.close("switchItem");else if(t.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)}}}});m(this,"handleDocumentMouseDown",t=>{if(t.target instanceof Element&&!this.isInCommandBar(t.target)){const o=this.listeners("closing");for(let r=0;r<o.length;r++)if(o[r](this,t)===!1)return;this.close("clickBackground")}});m(this,"handleHidden",()=>{this.closeReason!=="fromHover"&&this.emit("close",this),this.close(null),BC(this.id)});m(this,"handleShow",()=>{this.popper&&(this.popper.setAttribute("data-command-bar-id",this.id),this.options.classes&&W(this.popper,...this.options.classes),this.options.refuseOverflow&&this.popper.classList.add("reference-hidden")),this.emit("show",this),this.options.disablePageScroll&&wC(this.id)});m(this,"lastEnterPauseTime",0);m(this,"startPauseMouseEnter",()=>{this.lastEnterPauseTime=Date.now()});m(this,"handleItemMouseEnter",t=>{if(Date.now()-this.lastEnterPauseTime<100)return;const o=this.getParentCommandItemElement(t.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)});m(this,"handleItemMouseLeave",t=>{var r,i;const o=this.getParentCommandItemElement(t.target);!o||((i=(r=this.subBar)==null?void 0:r.parentItem)==null?void 0:i.id)!==this.getItemElementId(o)&&(te(o,"selected"),this.emit("selectionChange",this,""))});m(this,"handleItemClick",t=>{const o=this.getParentCommandItemElement(t.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("clickItem"))}});m(this,"handleWheel",t=>{if(!this.options.disablePageScroll&&!document.querySelector(".editor-disable-scroll"))return;const o=t.target;if(!o||!(o instanceof Node))return;const r=o instanceof HTMLElement?o:o.parentElement;if(!r)return;const i=oo(r);if(!Ke(this.content,i)){t.stopPropagation(),t.preventDefault();return}t.deltaY<0?i.scrollTop===0&&(t.stopPropagation(),t.preventDefault()):t.deltaY>0&&i.scrollTop+i.clientHeight>=i.scrollHeight&&(t.stopPropagation(),t.preventDefault())});this.id=(i=r==null?void 0:r.id)!=null?i:K(),this.options={...aL,...r},this.items=t,this.parentItem=(s=r==null?void 0:r.parentItem)!=null?s:null,this.closeable=o!=null?o:null,this.content=this.createCommandBarContent(t)}close(t){this.closeReason=t,this.subBar&&this.subBar.close(t),document.removeEventListener("keydown",this.handleDocumentKeydown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}click(t,o){this.emit("click",this,t,o)}createPopperOptions(){var r,i;const t={modifiers:[]},o=this.options.overflowBoundary;return o&&((r=t==null?void 0:t.modifiers)==null||r.push({name:"flip",options:{boundary:o,fallbackPlacements:["top","bottom"]}})),this.options.padding&&((i=t==null?void 0:t.modifiers)==null||i.push({name:"preventOverflow",options:{padding:this.options.padding}})),t}destroy(){var t;this.close(null),this.removeAllListeners(),(t=this.subBar)==null||t.destroy(),this.subBar=null,this.closeable=null,this.content.removeEventListener("wheel",this.handleWheel)}get isSubCommandBar(){return!!this.parentItem}updateItems(t){var r;this.subBar&&t.findIndex(s=>{var l,a;return s.id===((a=(l=this.subBar)==null?void 0:l.parentItem)==null?void 0:a.id)})===-1&&((r=this.subBar)==null||r.destroy(),this.subBar=null),this.items=t;const o=this.createCommandBarContent(t);this.content.innerHTML="",Array.from(o.children).forEach(i=>{this.content.appendChild(i)})}get popper(){return this.content.closest("[data-tippy-root]")}getSelectedItemIndex(){const t=this.getSelectedItem();return t?this.items.indexOf(t):-1}getPrevItemIndex(t){if(t<=0)return this.items.length-1;let o=t-1;for(;;){const r=this.items[o],i=r.type,l=!(r.states&&r.states.indexOf("disabled")!==-1);if(i!=="separator"&&i!=="section"&&l)return o;if(o-=1,o<=0)return this.items.length-1}}getNextItemIndex(t){let o=t+1;for(;;){if(!this.items[o])return this.getNextItemIndex(-1);const r=this.items[o],i=r.type,l=!(r.states&&r.states.indexOf("disabled")!==-1);if(i!=="separator"&&i!=="section"&&l)return o;if(o+=1,o>this.items.length-1)return 0}}clearSelectedItem(){const t=this.getSelectedItem();if(!t)return;const o=this.getItemElementById(t.id);o&&te(o,"selected")}selectItem(t){const o=this.getSelectedItem();if(o){if(o.id===t)return;const i=o.id,s=this.getItemElementById(i);s&&te(s,"selected")}const r=this.getItemElementById(t);r?(W(r,"selected"),this.emit("selectionChange",this,r.getAttribute("data-id")||""),r.scrollIntoView({block:"nearest"})):this.emit("selectionChange",this,"")}showSubCommandBar(t){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("switchItem");return}this.subBar.destroy(),this.subBar=null}if(!o.children)return;const r=this.getItemElementById(o.id);if(!r)return;const i=J2.createSubCommandBar(o,(l=this.closeable)!=null?l:this,t?{id:t}:{});this.subBar=i,this.subBar.on("click",(a,d,h)=>{this.emit("click",a,d,h)}),this.subBar.on("close",()=>{var a;(a=this.subBar)==null||a.destroy(),this.subBar=null,te(r,"active")}),o.beforePopup&&o.beforePopup(i),this.subBar.manualShow(r,this.getSubBarOptions(o)),W(r,"active")}isInCommandBar(t){if(!t||!(t instanceof Node))return!1;const o=this.getCommandBarRoot();return o&&Ke(o,t)||Ke(this.content,t)?!0:this.subBar?this.subBar.isInCommandBar(t):!1}createCommandItem(t){var i,s,l,a;let o=(i=this.options.itemElementTag)!=null?i:"div";t.element&&(o="div");const r=w(o,["command-item"],null);return r.setAttribute("data-id",t.id),t.type==="separator"?r.classList.add("separator"):t.type==="section"?(r.classList.add("section","text"),t.element&&(typeof t.element=="function"?r.appendChild(t.element(t)):r.appendChild(t.element))):((s=t.states)!=null&&s.includes("selected")&&r.classList.add("selected"),(l=t.states)!=null&&l.includes("checked")&&r.classList.add("checked"),(a=t.states)!=null&&a.includes("disabled")&&r.classList.add("disabled"),r.onclick=this.handleItemClick,r.onmouseenter=this.handleItemMouseEnter,r.onmouseleave=this.handleItemMouseLeave,t.element?typeof t.element=="function"?r.appendChild(t.element(t)):r.appendChild(t.element):r.classList.add("standard")),this.initItemElement(t,r),r}getItemById(t){const o=this.items.find(r=>r.id===t);return g(nc,o,`can not find command item for id: ${t}`),o}getSelectedItem(){const t=this.content.querySelector(":scope >.editor-command-bar >.command-item.selected");if(t){const o=this.getItemElementId(t),r=this.items.find(i=>i.id===o);return g(nc,r,`can not find command item for id: ${o}`),r}return null}getItemElementId(t){const o=t.getAttribute("data-id");return g(nc,o,"no data-id attribute"),o}getItemElementById(t){const o=this.content.querySelector(`:scope >.editor-command-bar > .command-item[data-id="${t}"]`);return g(nc,o,`no exists command item, id=${t}`),o}getParentCommandItemElement(t){if(!t||!(t instanceof Element))return null;if(xe(t,"command-item"))return t;const o=t.closest(".command-item");return o||null}createCommandBarContent(t){this.content&&this.content.removeEventListener("wheel",this.handleWheel);const o=w("div",["editor-command-bar-root"],null);if(this.options.header){const i=w("div",["editor-command-bar-header"],null);if(this.options.header instanceof Function){const s=this.options.header();s&&i.appendChild(s)}else i.appendChild(this.options.header);this.header=i,this.header&&o.appendChild(this.header)}const r=w("div",["editor-command-bar"],o);if(t.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.options.footer){const i=w("div",["menu-item","editor-command-bar","footer"],null);if(this.options.footer instanceof Function){const s=this.options.footer();s&&i.appendChild(s)}else i.appendChild(this.options.footer);this.footer=i,this.footer&&o.appendChild(this.footer)}return(this.options.header||this.options.footer)&&W(o,"scrollable-bar"),this.initCommandBarElement(r),o.addEventListener("wheel",this.handleWheel,{passive:!1}),o}getSubBarOptions(t){var o;return{placement:(o=t.childrenPlacement)!=null?o:"right-start"}}static registerManualCommandBar(t,o){this.commandBarCreators.set(t,o)}static createSubCommandBar(t,o,r){var l;g(nc,t.children&&t.children.length>0,"no item children");const i=(l=t.childrenType)!=null?l:"menu",s=this.commandBarCreators.get(i);return g(nc,s,`no creator for command type: ${i}`),s(t,o,r)}static hasExistsCommandBar(){return!!document.querySelector("[data-command-bar-id]")}};let Ui=J2;m(Ui,"commandBarCreators",new Map),S("ui-command-bar");class Gh extends Ui{constructor(){super(...arguments);m(this,"tippyInstance",null)}manualShow(t,o){var r,i;if(!this.isVisible){if(this.tippyInstance&&(this.tippyInstance.destroy(),this.tippyInstance=null),this.tippyInstance=UB.default(t,{sticky:!0,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],popperOptions:this.createPopperOptions()}),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(t){var o;super.close(t),this.isVisible&&((o=this.tippyInstance)==null||o.hide())}destroy(){var t;(t=this.tippyInstance)==null||t.destroy(),this.tippyInstance=null,super.destroy()}getCommandBarRoot(){return this.content.closest("[data-tippy-root]")}get isVisible(){var t,o;return(o=(t=this.tippyInstance)==null?void 0:t.state.isVisible)!=null?o:!1}get popper(){return this.content.closest("[data-tippy-root]")}}const Xb=S("ui-base");class Xa extends Gh{constructor(e,t){var i;const r=[{id:(i=t==null?void 0:t.id)!=null?i:`popup-${K()}`,name:"",element:e}];super(r,void 0,{disablePageScroll:!0})}initCommandBarElement(e){W(e,"popper")}initItemElement(e,t){}get popupContent(){const e=this.items[0];g(Xb,e,"no dialog item");const t=typeof e.element=="function"?e.element(e):e.element;return g(Xb,t,"no item element"),t}}const zi=S("filterable-list");function ev(n){var t,o;const e=w("div",["list-item"],null);return e.setAttribute("data-id",n.id),e.appendChild(w("div",["list-item-text"],null,n.name)),(t=n.states)!=null&&t.includes("selected")&&W(e,"selected"),(o=n.states)!=null&&o.includes("disabled")&&W(e,"disabled"),e}function tv(n){const e=w("div",["list-root"],null);return n.forEach(t=>{e.appendChild(ev(t))}),n.length||e.appendChild(ev({id:"placeholder",states:["disabled"],name:R.t("search.emptyTips")})),e}function nv(n,e){let t=n;return e&&(t=n.map(o=>({...o,states:o.id===e?["selected"]:void 0}))),t}function uL(n,e){const t=w("div",["filterable-list"],null),o=w("div",["filter"],t),r=w("div",["filter-container"],o),i=w("input",["filter-input"],r);e&&e.placeholder&&(i.placeholder=e.placeholder);const s=w("div",["list"],t),l=tv(nv(n,e==null?void 0:e.initialSelectedId));return s.appendChild(l),t}function ov(n,e,t){const o=n.querySelector(".list");g(zi,o,"no list root");const r=tv(nv(e,t)),i=o.querySelector(".list-root");if(g(zi,i,"no exists menu"),Ca(i,r),t){const s=o.querySelector(".list-item.selected");s&&(g(zi,s,"no selected menu item"),s.scrollIntoView({block:"nearest"}))}}class dL{constructor(e,t){m(this,"root");m(this,"visibleItems");m(this,"selectedId");m(this,"filter","");m(this,"onSelected",null);m(this,"handleKeydown",e=>{this.processKeyDown(e)});m(this,"handleInputChanged",()=>{const e=this.root.querySelector(".filter-input");g(zi,e,"no input");const t=e.value.toLocaleLowerCase();this.setFilter(t)});m(this,"handleClick",e=>{this.processClick(e)});var o;this.items=e,this.options=t,this.root=uL(e,t),this.bindEvents(),this.selectedId=(o=t==null?void 0:t.initialSelectedId)!=null?o:"",this.visibleItems=e}bindEvents(){const e=this.root.querySelector(".filter-input");g(zi,e,"no input"),e.addEventListener("keyup",this.handleInputChanged),e.addEventListener("keydown",this.handleKeydown),this.root.addEventListener("click",this.handleClick)}unbindEvents(){const e=this.root.querySelector(".filter-input");g(zi,e,"no input"),e.removeEventListener("keyup",this.handleInputChanged),e.removeEventListener("keydown",this.handleKeydown),this.root.removeEventListener("click",this.handleClick)}destroy(){this.unbindEvents(),this.onSelected=null}getSelectedIndex(){return this.selectedId?this.visibleItems.findIndex(e=>e.id===this.selectedId):-1}setSelectedId(e){this.selectedId=e,ov(this.root,this.visibleItems,e)}focus(){const e=this.root.querySelector(".filter-input");g(zi,e,"no input"),e.focus()}reset(){this.setFilter("");const e=this.root.querySelector(".filter-input");g(zi,e,"no input"),e.value=""}setFilter(e){this.filter!==e&&(this.filter=e,this.visibleItems=this.items.filter(t=>t.name.toLocaleLowerCase().includes(e)),ov(this.root,this.visibleItems,this.selectedId))}processClick(e){var s,l;const t=e.target;if(!(t instanceof HTMLElement))return;const o=t.closest(".list-item");if(!o)return;const r=(s=o.getAttribute("data-id"))!=null?s:"",i=(l=this.visibleItems.find(a=>a.id===r))!=null?l:null;this.onSelected&&this.onSelected(this,i)}processKeyDown(e){var t;if(e.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(e.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(e.key==="Enter"){const o=(t=this.visibleItems.find(r=>r.id===this.selectedId))!=null?t:null;this.onSelected&&this.onSelected(this,o)}}}class hL extends dL{constructor(t,o,r){super(t,r);m(this,"popup");m(this,"onShow",null);m(this,"onHide",null);m(this,"custom",null);m(this,"handleShow",()=>{this.onShow&&this.onShow(this)});m(this,"handleHide",()=>{this.onHide&&this.onHide(this)});m(this,"handleShown",()=>{this.focus()});this.popup=new Xa(this.root)}destroy(){super.destroy(),this.onShow=null,this.onHide=null}show(t){this.reset(),this.popup.manualShow(t,{theme:"dropdown-list"}),this.focus()}processKeyDown(t){super.processKeyDown(t),(t.key==="Esc"||t.key==="Enter")&&this.popup.close("cancelBar")}processClick(t){super.processClick(t);const o=t.target;!(o instanceof HTMLElement)||!o.closest(".list-item")||this.popup.close("clickItem")}}const rne="",ine="";function fL(n,e){const t=document.createElement("div");t.classList.add("toast","show"),e!=null&&e.theme&&t.setAttribute("data-theme",e.theme),e!=null&&e.id&&t.setAttribute("data-id",e.id),e!=null&&e.html?t.innerHTML=n:t.textContent=n,e!=null&&e.position&&(t.style.left=`${e.position.x}px`,t.style.top=`${e.position.y}px`,t.classList.add("positioned")),document.body.appendChild(t),setTimeout(()=>{t.classList.remove("show"),setTimeout(()=>{t.remove()},500)},(e==null?void 0:e.duration)||3e3)}const rv=`<?xml version="1.0" ?>
27
+ `)}const nT=S("get-text-position");function Gl(n,e){const t=e!=null?e:n.selection.range.start;t instanceof jt||g(nT,!1,`invalid insert pos type: ${typeof t}`);const{blockId:o}=t,r=n.getBlockById(o),i=be(r),s=ne(r),l=ae(s),{offset:a}=t;return{block:r,container:s,containerId:l,blockIndex:i,offset:a}}const Zl=S("insert-text");function Dg(n,e,t,o){var s;const r=n.doc.getBlockData(e,t);if(g(Zl,r,"no block data"),g(Zl,r.text,"no block text"),rn(r.text)===0)return g(Zl,o===0,"invalid text offset"),n.editorCommandProviders.getEmptyBlockTextAttributes(n,r.id);if(o===0)return;const i=zt(r.text,o-1,1).middle;if(!((s=i[0].attributes)!=null&&s.box))return i[0].attributes}function oT(n,e,t){const o=ne(e),r=ae(o),i=be(e);return Dg(n,r,i,t)}function L6(n,e,t,o,r){const i=ne(e),s=ae(i),l=be(e),a=oT(n,e,t),d=ah(t,o,a!=null?a:null);return n.doc.localUpdateBlockText(s,l,d,r),mn(n,e)}function M6(n,e,t,o){const r=ne(e),i=ae(r),s=be(e),l=ah(t," ",o);return n.doc.localUpdateBlockText(i,s,l),mn(n,e)}function rT(n,e,t){let o=0;if(e===0)return!1;for(let r=0;r<n.length;r++){const i=n[r];g(Zl,typeof i.insert=="string","invalid text op, no insert");const s=o+uh(i);if(s===e||s===t)return!1;if(s>e&&s>t)return!0;o=s}return!1}function Sg(n,e,t,o,r){const i=n.doc.getBlockData(t,o);g(Zl,i,"no block data"),g(Zl,i.text,"no block text");const s=Dg(n,t,o,r);s&&Object.keys(s).includes("link")&&(rT(i.text,r,r)||delete s.link);const l=ah(r,e,s!=null?s:null);return n.doc.localUpdateBlockText(t,o,l),mn(n,n.getBlockById(i.id))}function Lg(n,e){n.selection.range.isCollapsed()||n.clearSelectedContents();const{containerId:t,blockIndex:o,offset:r}=Gl(n);Sg(n,e,t,o,r)}const yh=S("update-composition-text");function R6(n){const e=n.selection.range.start;e instanceof jt||g(yh,!1,`invalid insert pos type: ${typeof e}`);const{blockId:t}=e,o=n.getBlockById(t);g(yh,ee(n,o),"not a text kind block");const r=ne(o),i=ae(r),s=be(o),l=n.doc.getBlockData(i,s);g(yh,l,"no block data in doc"),g(yh,l.text,"no text data in text block");const a=Re(o);ih(n,Di(o),t,a,l.text)}function O6(n){_x(n)}function Ql(n,e,t,o,r,i){return n.doc.localInsertBlock(e,t,o,r,i),n.getBlockById(o.id)}const Ra=S("delete-block-text");function Mg(n,e,t,o,r){if(!n.isBlockWritable(e))return Ra.error("block is not writable"),0;g(Ra,ee(n,e),"block is not a text kind block");const i=ne(e),s=ae(i),l=be(e),a=n.doc.getBlockData(s,l);g(Ra,a,"no block data in doc"),g(Ra,a.text,"no text data in text block");let d=t;sn(e,t)||(d=Ri(e,d));let h=t+o;g(Ra,h<=ue(n,e),`invalid offset and count: ${t}, ${o}`),sn(e,h)||(h=Fs(e,h));const p=h-d,A=V4(d,p);return n.doc.localUpdateBlockText(s,l,A,r),p}const Rg=S("break-text-block");function _6(n,e){const o=n.getBlockData(e).quoted;return o?{quoted:o}:{}}function Yl(n,e,t,o){g(Rg,ee(n,e),`block is not a text kind block: ${De(e)}`),g(Rg,t>=0&&t<=ue(n,e),`invalid offset: ${t}`);const r=ne(e),i=ae(r),s=be(e),l=o!=null&&o.copyBlockAttributes?_6(n,e):{};if(!(o!=null&&o.forceInsertAfter)&&(t===0||t===ue(n,e))){const v=t===0?s:s+1,B={...sr(""),...l,...o==null?void 0:o.newBlockData},D=yt(n,e.id,0),I=Ql(n,i,v,B,D);return{block:e,newBlock:I}}g(Rg,sn(e,t),"not a valid offset");const a=mn(n,e),{right:d}=xn(a,t),h=rn(d);h>0&&Mg(n,e,t,h);const p={...sr(d),...l,...o==null?void 0:o.newBlockData},A=Ql(n,i,s+1,p,yt(n,p.id,0));return{block:e,newBlock:A}}const iT=S("prepare-insert-new-block");function sT(n,e,t){if(e&&t!==void 0&&t!==null){const d=n.getContainerById(e),h=vt(d);return g(iT,t>=0&&t<=h.length,`invalid blockIndex: ${t}`),{containerId:e,blockIndex:t}}const o=n.selection.range.start;if(!o.isSimple())return null;const r=n.getBlockById(o.blockId);if(e=ae(ne(r)),t=be(r),!ee(n,r))return{containerId:e,blockIndex:t+1};const s=o.offset;if(s===0||s===ue(n,r))return{containerId:e,blockIndex:s===0?t:t+1};const a=Yl(n,r,s).newBlock;return{containerId:e,blockIndex:be(a)}}const lT=S("auto-insert-block");function F6(n,e,t,o,r,i){const s=sT(n,t,o);g(lT,s,`not an valid insert position: ${n.selection.range}`);const l={blockId:e.id,offset:0},a={anchor:l,focus:l};return Ql(n,s.containerId,s.blockIndex,e,r!=null?r:a,i)}const cT=S("delete-block");function kh(n,e,t){e.children&&(t.push(...e.children),e.children.forEach(o=>{n.getChildContainerData(o).forEach(i=>{kh(n,i,t)})}))}function wh(n,e,t){const o=ne(e),r=ae(o),i=be(e),s=n.doc.getBlockData(r,i);return g(cT,s,"no block data in doc"),n.doc.localDeleteBlock(r,i,Ut(n,{anchor:t.start,focus:t.end})),s}function Og(n,e,t){return n.undoManager.runInGroup(()=>{const o=ne(e);Eo(o)===1&&n.insertTextBlock("",ae(o),0);let r=t?Si(n,t):null;if(!r){const l=n.selection.range;I6(e,l)?r=T6(n,e):r=l}const i=wh(n,e,r),s=[];return kh(n,i,s),s.length>0&&n.doc.localDeleteChildContainers(s),i})}function aT(n,e){const t=[e];n.doc.getContainerBlocks(e).forEach(r=>{kh(n,r,t)}),n.doc.localDeleteChildContainers(t)}function P6(n,e){const t=[...e];e.forEach(o=>{n.doc.getContainerBlocks(o).forEach(i=>{kh(n,i,t)})}),n.doc.localDeleteChildContainers(t)}const _g=S("merge-text-block");function N6(n,e,t){g(_g,ee(n,e),"only text block can be merged"),g(_g,ee(n,t),"only text block can be merged");const o=_i(n,e),r=_i(n,t),i=o.text,s=r.text;g(_g,i&&s,"block data has no text");const l=ne(e),a=ae(l),d=be(e),h=ue(n,e),p=Sg(n,s,a,d,h),A=yt(n,e,rn(i));return Og(n,t,A),p}const lr=S("clear-selected-contents");function Bh(n,e){g(lr,ee(n,e.block),"not a text kind block");const{start:t,end:o}=e;g(lr,t.isSimple(),"not a simple block position"),g(lr,o.isSimple(),"not a simple block position");const r=t.offset,i=o.offset;g(lr,r<=i,`invalid delete text offset: ${r}, ${i}`),r!==i&&n.deleteTextFromBlock(e.block,r,i-r)}function $6(n,e,t){const o=ae(e),r=vt(e),i=t.focus?void 0:n.selection.range.toDocRange(),s=n.insertTextBlock("",o,0,{newRange:i});t.focus&&n.selection.selectBlock(s,0),r.reverse().forEach(l=>{n.deleteBlock(l)})}function uT(n,e){const{block:t,start:o,end:r}=e;if(ee(n,t)){Bh(n,e);return}if(Lt(t)||o.isSimple()){g(lr,r.isSimple(),"invalid range");const s=ne(t),l=be(t),a=n.insertTextBlock("",ae(s),l);n.selection.selectBlock(a,0),n.deleteBlock(t);return}g(lr,Le(n,t),"invalid block kind"),g(lr,!o.isSimple()&&!r.isSimple(),"invalid range"),Os(n,t,o,r),n.selection.range.getSelectedContainers().forEach((s,l)=>{$6(n,s,{focus:l===0})})}function dT(n){if(!n.isWritable())return;const e=n.selection.range;if(e.isCollapsed())return;const t=e.getSelectedBlocks();if(g(lr,t.length>0,"no selected block"),t.length===1){uT(n,t[0]);return}const o=t[0],r=o.block,i=ne(r);g(lr,t.length>1,"no selected block");const s=t[t.length-1],l=s.block;if(ee(n,r)){Bh(n,o);const h=yt(n,o.block,o.start.offset);if(t.slice(1,t.length-1).reverse().forEach(A=>n.deleteBlock(A.block)),ee(n,l)){Bh(n,s),n.mergeTextBlock(r,l,{focus:!0}),n.selection.setRange(h);return}n.deleteBlock(l),n.selection.setRange(h);return}if(ee(n,l)){Bh(n,s),t.slice(0,t.length-1).reverse().forEach(h=>n.deleteBlock(h.block)),n.selection.selectBlock(s.block,0);return}if(t.length===Eo(i)){$6(n,i,{focus:!0});return}const a=ct(r),d=Ze(l);g(lr,a||d,"no prev or next block"),t.forEach(h=>n.deleteBlock(h.block))}function Fg(n){n.selection.range.isCollapsed()||n.undoManager.runInGroup(()=>{n.emit("beforeClearSelection",n);try{n.doc.beginBatchUpdate(),dT(n)}finally{n.doc.endBatchUpdate()}n.emit("afterClearSelection",n)})}const hT=S("core");function H6(n,e,t){const o=ne(e),r=ae(o),i=be(e);return n.doc.localUpdateBlockText(r,i,t),setTimeout(()=>{n.selection.updateSelection(null)}),mn(n,e)}function j6(n,e,t){if(!n.isBlockWritable(e)){hT.error("block is not writable");return}const o=n.getBlockText(e),r=ln.diff(o,t);H6(n,e,r)}function Eh(n,e,t){const o=mn(n,e),r=typeof t=="string"?Oi(t):t,i=ln.diff(o,r);return H6(n,e,i)}const Oa=S("update-block-data");function xh(n,e,t,o){const r=ne(e),i=ae(r),s=be(e),l=n.doc.getBlockData(i,s),a={insert:{},delete:[]},d=new Set(Object.keys(l)),h=new Set(Object.keys(t));return d.forEach(A=>{if(!h.has(A)){if(A==="id"||A==="type"||A==="text")return;Oa.debug(`delete key: ${A}`),a.delete.push(A)}}),Object.entries(t).forEach(([A,v])=>{g(Oa,A!=="id"&&A!=="type",`invalid block data delta, ${A}`);const B=l[A];if(v==null){B!=null&&(Oa.debug(`delete key: ${A}`),a.delete.push(A));return}B!==v&&(ua.default(B,v)||A==="text"&&ln.diff(B,v).length===0||(d.has(A)?(Oa.debug(`replace key: ${A}`),a.delete.push(A)):Oa.debug(`insert key: ${A}`),a.insert[A]=v))}),n.doc.localUpdateBlockData(i,s,a,o),_i(n,e)}function U6(n,e,t,o){const i={...n.getBlockData(e),embedData:t};return n.updateBlockData(e,i,o)}function Pg(n,e,t){if(!Le(n,e)||!(t!=null&&t.tryFocusToChildSimpleBlock)){n.selection.selectBlock(e,0);return}const r=jn(n,e).getChildContainers(n,e)[0],i=St(r);Pg(n,i,t)}function $s(n){const e=[];let t={};return n.forEach(o=>{e.push(...o.blocks.root);const{root:r,...i}=o.blocks;t={...t,...i}}),{blocks:{...t,root:e},meta:{},comments:{}}}const _a=S("clone-block");function Fi(n,e,t,o){const r=n.getBlockClass(t.type);if(r.blockToDoc)return r.blockToDoc(e,t,(h,p)=>(g(_a,t!==p,"invalid child block"),Fi(n,h,t,o)));let i={};const s=new Map,l=me.default(t);l.children&&(l.children=l.children.map(h=>{const p=K(),A=e.blocks[h];g(_a,Array.isArray(A),"invalid child blocks");const v=A.map(_=>Fi(n,e,_,o)),B=$s(v),{root:D,...I}=B.blocks;return i={...i,...I},i[p]=B.blocks.root,s.set(h,p),p}));const a=Array.from(s.entries()),d=h=>{for(const p of a){const[A,v]=p;{const B=`${A}/`;if(h.startsWith(B)){const D=h.substring(B.length),I=`${v}/${D}`;return _a.debug(`replace key: ${h} -> ${I}`),I}}{const B=`${A}_`;if(h.startsWith(B)){const D=h.substring(B.length),I=`${v}_${D}`;return _a.debug(`replace key: ${h} -> ${I}`),I}}}return h};return Array.from(Object.entries(l)).forEach(([h,p])=>{const A=d(h);A!==h&&delete l.key,l[A]=p}),l.id=K(),o&&(o.blockIdMap.set(t.id,l.id),s.forEach((h,p)=>o.containerIdMap.set(p,h))),{blocks:{root:[l],...i},meta:{},comments:{}}}function Ng(n,e,t,o){const r=e.blocks[t];g(_a,Array.isArray(r),"invalid child blocks");const i=r.map(l=>Fi(n,e,l,o));return $s(i)}function $g(n,e,t){const o=e.blocks.root.map(r=>Fi(n.editorBlocks,e,r,t));return me.default($s(o))}const z6=S("insert-doc");function V6(n,e,t,o,r){if(Le(n,e)){z6.warn("failed to insert doc into a complex block");return}const i=$g(n,o,r),s=ne(e),l=be(e),a=ae(s);n.doc.beginBatchUpdate(),n.undoManager.runInGroup(()=>{var M,H,z;Object.entries(i.blocks).forEach(([q,re])=>{q!=="root"&&n.doc.localInsertChildContainer(q,re)});const d=i.blocks.root;if(Lt(e)){n.deleteBlock(e);let q;d.reverse().forEach(re=>{const fe=n.insertBlock(a,l,re);q||(q=fe)}),q&&n.selection.selectBlock(q,ue(n,q));return}if(g(z6,ee(n,e),"not a text block"),ht(n,e)){const q=a==="root"&&n.getBlockByIndex(a,0)===e,re=be(e);let fe;d.forEach((Be,je)=>{const Ue=n.insertBlock(a,re+je,Be);je===d.length-1&&(fe=Ue)}),fe&&n.selection.selectBlock(fe,ue(n,fe)),q&&n.deleteBlock(e);return}if(d.length===1){const q=d[0];if(ya(n,q.type)){n.insertTextToBlock(e,t,(M=q.text)!=null?M:[]);return}n.breakTextBlock(e,t),n.insertBlock(a,l+1,q);return}const h=t===ue(n,e),p=t===0,A=d[0],v=d[d.length-1];let B;!h&&!p?B=n.breakTextBlock(e,t,{forceInsertAfter:!0}):B=e;const D=p?l:l+1;h?(B=n.insertBlock(a,l+1,v),n.selection.selectBlock(B,ue(n,B))):(n.selection.selectBlock(B,0),ya(n,v.type)?n.insertTextToBlock(B,0,(H=v.text)!=null?H:[]):n.insertBlock(a,D,v));const I=n.selection.range;let _=D;ya(n,A.type)?p?(n.insertBlock(a,D,A),_+=1):n.insertTextToBlock(e,t,(z=A.text)!=null?z:[]):(n.insertBlock(a,D,A),_+=1),d.slice(1,d.length-1).reverse().forEach(q=>{n.insertBlock(a,_,q)}),n.selection.setRange(I)}),n.doc.endBatchUpdate()}function Hg(n,e,t,o,r){const i=$g(n,o,r),s=ae(e),l=[];return n.undoManager.runInGroup(()=>{Object.entries(i.blocks).forEach(([d,h])=>{d!=="root"&&n.doc.localInsertChildContainer(d,h)}),i.blocks.root.reverse().forEach(d=>{const h=n.insertBlock(s,t,d);l.push(h)})}),l}function W6(n,e,t){const o=Eo(e);Hg(n,e,o,t);for(let r=0;r<o;r++){const i=St(e);n.deleteBlock(i)}}const Fa=S("add-text-attribute");function fT(n,e,t,o){const{start:r,end:i}=t;g(Fa,r.blockId===i.blockId&&r.blockId===ie(e),"invalid range"),g(Fa,o,"invalid attribute name");const s=n.getBlockText(e),l=ql(r.offset,i.offset-r.offset,s,o,void 0,{ignoreValue:!0});return n.setBlockText(e,l),l}function q6(n,e,t,o,r){const{start:i,end:s}=t;g(Fa,i.blockId===s.blockId&&i.blockId===ie(e),"invalid range"),g(Fa,o,"invalid attribute name");const l=n.getBlockText(e),a=Ia(i.offset,s.offset-i.offset,l,o,r);return n.setBlockText(e,a),a}function Jl(n,e,t,o,r){const{start:i,end:s}=t;g(Fa,i.blockId===s.blockId&&i.blockId===ie(e),"invalid range");const l=n.getBlockText(e),a=X4(i.offset,s.offset-i.offset,l,o,r);return n.setBlockText(e,a),a}function G6(n,e,t,o){const r=Lo(n,{simpleBlockOnly:!0});n.undoManager.runInGroup(()=>{r.forEach(i=>{const{block:s,start:l,end:a}=i;if(!ee(n,s))return;if(ht(n,s)){o(n,ie(s),e,t);return}const d=Ut(n,{anchor:l,focus:a});e==="color"||e==="backgroundColor"?Jl(n,s,d,e,t):(Jl(n,s,d,"color",null),Jl(n,s,d,"backgroundColor",null))})})}function Z6(n,e,t){const o=Lo(n,{simpleBlockOnly:!0});n.undoManager.runInGroup(()=>{o.forEach(r=>{const{block:i,start:s,end:l}=r;if(!ee(n,i))return;if(ht(n,i)){(e==="clearColor"||e==="clearAll")&&t(n,ie(i),"color",null),(e==="clearBackground"||e==="clearAll")&&t(n,ie(i),"backgroundColor",null);return}const a=Ut(n,{anchor:s,focus:l});(e==="clearColor"||e==="clearAll")&&Jl(n,i,a,"color",null),(e==="clearBackground"||e==="clearAll")&&Jl(n,i,a,"backgroundColor",null)})})}function jg(n,e){const t=Lo(n,{simpleBlockOnly:!0}).filter(s=>ee(n,s.block));if(t.length===0)return[null,null];const o=s=>{if(ue(n,s.block)===0)return e(n,ie(s.block));const l=s.start,a=s.end,d=n.getBlockText(s.block);return n6(l.offset,a.offset-l.offset,d)};let[r,i]=o(t[0]);return r===null&&i===null?[r,i]:(t.forEach(s=>{const[l,a]=o(s);l===null||r===null?r=null:r=l===r?r:null,a===null||i===null?i=null:i=a===i?i:null}),[r,i])}const Vn=S("adjust-selection-pos");function Q6(n){const e=[];for(;n;){const t=ne(n);if(e.unshift(t),Xe(t))return e;const o=oe(t);g(Vn,o,"child container has not parent container"),n=o}g(Vn,!1,"should not come here: getParentContainers")}function Y6(n,e){for(;e;){const t=ne(e);if(t===n)return e;const o=oe(t);g(Vn,o,"could not find parent block for a child container"),e=o}g(Vn,!1,"no parent block in specified container")}function mT(n,e){const t=Q6(n),o=Q6(e);g(Vn,t.length>0&&o.length>0,"block has not parent container"),g(Vn,t[0]===o[0],"root container does not equal");let r=t[0];for(let l=1;l<t.length||o.length;l++)if(t[l]!==o[l]){r=t[l-1];break}const i=Y6(r,n),s=Y6(r,e);return{parentContainer:r,newBlock1:i,newBlock2:s}}function J6(n,e){let t=oe(e);for(g(Vn,t,"element is not in a block");t;){const o=ne(t);g(Vn,Do(o),"not a child container");const r=oe(o);if(g(Vn,r,"child container has not parent block"),r===n)return o;t=r}g(Vn,!1,"failed to find parent container in complex block")}function Ih(n,e,t){const o=n.getBlockById(e.blockId),r=n.getBlockById(t.blockId);if(o===r)return e instanceof jt&&t instanceof jt?{anchor:e,focus:t}:e instanceof So&&t instanceof So?oh(n,o,e,t):null;const i=ne(o),s=ne(r);if(i===s)return e instanceof So&&(e=se(o,0,"home")),t instanceof So&&(t=se(r,ue(n,r),"end")),g(Vn,e instanceof jt,"not valid position type"),g(Vn,t instanceof jt,"not valid position type"),{anchor:e,focus:t};if(o.contains(s))return null;if(r.contains(i)){if(e instanceof jt&&t instanceof So){const B=n.getContainerById(t.childContainerId);if(B===i)return{anchor:t,focus:t};const D=oe(i);if(D&&D===oe(B)){const I=ft(D,ae(i)),_=ft(D,ae(B));return oh(n,D,I,_)}}return null}const l=jd(o,r)>0,{newBlock1:a,newBlock2:d}=mT(o,r);if(a===d){const B=a,D=J6(B,o),I=J6(B,r);return e=ft(a,ae(D)),t=ft(a,ae(I)),Vn.debug(`select in complex block: ${D.id}, ${I.id}`),oh(n,B,e,t)}let h=l?ue(n,a):0;a===o&&e instanceof jt&&(h=e.offset);let A=l?0:ue(n,d);return d===r&&t instanceof jt&&(A=t.offset),e=se(a,h,l?"end":"home"),t=se(d,A,l?"home":"end"),{anchor:e,focus:t}}const gT=S("move-complex-block-position");function pT(n,e,t){const o=n.getBlockById(e.blockId);g(gT,Le(n,o),"is not a complex block");const r=jn(n,o),i=n.getContainerById(e.childContainerId),s=r.getNextContainer(n,o,i,t,{noWrap:!0});return s?ft(o,ae(s)):null}const Pa=S("move-simple-block-position");function K6(n,e){const t=En(n,e,{visibleOnly:!0});g(Pa,t.length>0,"complex block has not any child container");const o=t[0];return St(o)}function X6(n,e){const t=En(n,e,{visibleOnly:!0});g(Pa,t.length>0,"complex block has not any child container");const o=t[t.length-1];return Gt(o)}function eA(n,e,t){const o=t?K6(n,e):X6(n,e);return Le(n,o)?eA(n,o,t):o}function CT(n,e){const t=n.getBlockById(e.blockId);return Le(n,t)&&e.offset===0?K6(n,t):Ss(t)}function AT(n,e){const t=n.getBlockById(e.blockId);return Le(n,t)&&e.offset===1?X6(n,t):Ds(t)}function Ug(n){return n==="ArrowLeft"||n==="ArrowUp"}function zg(n,e,t){const o=ne(e);if(Xe(o))return null;const r=oe(o);g(Pa,r,"child container has not parent block"),g(Pa,Le(n,r),"is not a complex block");const i=jn(n,r).getNextContainer(n,r,o,t);return i?Ug(t)?Gt(i):St(i):zg(n,r,t)}function bT(n,e,t){const o=ne(e);if(Xe(o))return null;const r=oe(o);if(g(Pa,r,"child container has not parent block"),Ug(t)){const l=ct(r);if(l)return l}else{const l=Ze(r);if(l)return l}const i=zg(n,r,t);if(i)return i;let s=r;for(;!Xe(ne(s));)s=oe(ne(s));return Ug(t)?ct(s):Ze(s)}function vT(n,e,t){return!Le(n,e)||jn(n,e).enableKeyboardSelect?e:eA(n,e,t==="ArrowDown"||t==="ArrowRight")}function yT(n,e,t){const o=n.getBlockById(e.blockId),i=Qe(n,o).moveCaret(n,o,e,t);if(i)return i;let s=t==="ArrowDown"||t==="ArrowRight"?CT(n,e):AT(n,e);if(s||(s=zg(n,o,t),s||(s=bT(n,o,t))),!s){if(t==="ArrowDown"||t==="ArrowRight"){if(n.readonly||!Xe(ne(o)))return null;const l=n.insertTextBlock("",ae(n.rootContainer),Eo(n.rootContainer));return se(l,0,"home")}return null}if(s=vT(n,s,t),ee(n,s)){const l=n.selection.getSuggestedCaretX();if(t==="ArrowDown")return Gx(n,s,o,e,l);if(t==="ArrowUp")return qx(n,s,o,e,l)}return t==="ArrowLeft"||t==="ArrowUp"?se(s,ue(n,s),"end"):t==="ArrowRight"||t==="ArrowDown"?se(s,0,"home"):null}function kT(n,e,t){if(e==="ArrowLeft")return t.start;const o=t.end,r=n.getBlockById(o.blockId);if(ee(n,r))return o;const i=Ze(r);if(i)return se(i,0,"home");if(!Xe(ne(r))||n.readonly)return o;const s=n.insertTextBlock("",ae(n.rootContainer),Eo(n.rootContainer));return se(s,0,"home")}function wT(n,e,t){const o=n.selection.range;let r;if(o instanceof Zt)t==="move"&&!o.isCollapsed()&&(e==="ArrowLeft"||e==="ArrowRight")?r=kT(n,e,o):r=yT(n,o.getFocusedPos(),e);else if(r=pT(n,o.focus,e),t==="move"){const i=r!=null?r:o.focus,s=n.getContainerById(i.childContainerId);if(e==="ArrowLeft"||e==="ArrowUp"){const l=Gt(s);r=se(l,0,"home")}else{const l=St(s);r=se(l,ue(n,l),"end")}}return r?t==="move"?{anchor:r,focus:r}:Ih(n,o.anchor,r):null}function Pi(n,e,t){const o=wT(n,e,t);if(!o)return!1;const{anchor:r,focus:i}=o;return n.selection.setSelection(r,i),(e==="ArrowLeft"||e==="ArrowRight")&&n.selection.updateLastCaretRect(),!0}function tA(n){return Pi(n,"ArrowLeft","move"),!0}function nA(n){return Pi(n,"ArrowRight","move"),!0}function oA(n){return Pi(n,"ArrowUp","move"),!0}function rA(n){if(Pi(n,"ArrowDown","move")||n.readonly)return!0;const e=n.getFocusedBlock(),t=ne(e);if(Xe(t)||Gt(t)!==e)return!0;const o=n.rootContainer;return n.insertTextBlock("",ae(o),Eo(o)),!0}function iA(n){return Pi(n,"ArrowDown","select"),!0}function sA(n){return Pi(n,"ArrowLeft","select"),!0}function lA(n){return Pi(n,"ArrowRight","select"),!0}function cA(n){return Pi(n,"ArrowUp","select"),!0}const aA=S("word-offset");function Vg(n,e){const t=n.selection.range.focus;g(aA,t.isSimple(),"invalid range type");const o=n.getBlockById(t.blockId);if(ht(n,o))return se(o,0,"home");if(t.offset===0||!ee(n,o)){const s=ct(o);if(!s)return null;const l=se(s,ue(n,s),"end");if(e==="select"&&ee(n,s)){const a=yg(n,s,l.offset);return se(s,a,"normal")}return l}const r=yg(n,o,t.offset);return se(o,r,"normal")}function Wg(n,e){const t=n.selection.range.focus;g(aA,t.isSimple(),"invalid range type");const o=n.getBlockById(t.blockId);if(ht(n,o))return se(o,0,"end");if(t.offset===ue(n,o)||!ee(n,o)){const s=Ze(o);if(!s)return null;const l=se(s,0,"home");if(e==="select"&&ee(n,s)){const a=kg(n,s,l.offset);return se(s,a,"end")}return l}const r=kg(n,o,t.offset);return se(o,r,"normal")}function uA(n){if(!n.selection.range.focus.isSimple())return!1;const t=Vg(n,"move");return t?(n.selection.setSelection(t),n.selection.updateLastCaretRect(),!0):!1}function dA(n){if(!n.selection.range.focus.isSimple())return!1;const t=Wg(n,"move");return t?(n.selection.setSelection(t),n.selection.updateLastCaretRect(),!0):!1}function hA(n){if(!n.selection.range.focus.isSimple())return!1;const t=Vg(n,"select");return t?(n.selection.setSelection(n.selection.getAnchorPos(),t),n.selection.updateLastCaretRect(),!0):!1}function fA(n){if(!n.selection.range.focus.isSimple())return!1;const t=Wg(n,"select");return t?(n.selection.setSelection(n.selection.range.anchor,t),n.selection.updateLastCaretRect(),!0):!1}S("find-block");function qg(n,e){if(!Le(n,e))return e;const o=jn(n,e).getChildContainers(n,e)[0],i=vt(o)[0];return qg(n,i)}function Gg(n,e){if(!Le(n,e))return e;const t=jn(n,e).getChildContainers(n,e),o=t[t.length-1],r=vt(o),i=r[r.length-1];return Gg(n,i)}function mA(n){const e=Gg(n,Gt(n.rootContainer)),t=se(e,ue(n,e),"end");return n.selection.setSelection(t),!0}function gA(n){const e=qg(n,n.getFirstBlock()),t=se(e,0,"home");return n.selection.setSelection(t),!0}function pA(n){const e=qg(n,n.getFirstBlock()),t=se(e,0,"home");return n.selection.setSelection(n.selection.getAnchorPos(),t),!0}function Zg(n){const e=Gg(n,Gt(n.rootContainer)),t=se(e,ue(n,e),"end");return n.selection.setSelection(n.selection.getAnchorPos(),t),!0}const CA=S("line-offset");function AA(n){const e=n.selection.range.focus;g(CA,e.isSimple(),"invalid range type");const t=n.getBlockById(e.blockId);if(e.offset===0||!ee(n,t))return se(t,0,"home");let r=$4(t,e).start;const{next:i}=eh(t,r);return i&&io(i)&&va(i)==="br"&&(r+=1),se(t,r,"home")}function bA(n){const e=n.selection.range.focus;g(CA,e.isSimple(),"invalid range type");const t=n.getBlockById(e.blockId);if(e.offset===ue(n,t)||!ee(n,t))return se(t,ue(n,t),"end");const o=$4(t,e);return se(t,o.end,"end")}function vA(n){if(!n.selection.range.focus.isSimple())return!1;const t=AA(n);return t?(n.selection.setSelection(n.selection.getAnchorPos(),t),n.selection.updateLastCaretRect(),!0):!1}function yA(n){if(!n.selection.range.focus.isSimple())return!1;const t=bA(n);return t?(n.selection.setSelection(n.selection.getAnchorPos(),t),n.selection.updateLastCaretRect(),!0):!1}function kA(n){if(!n.selection.range.focus.isSimple())return!1;const t=AA(n);return t?(n.selection.setSelection(t),n.selection.updateLastCaretRect(),!0):!1}function wA(n){if(!n.selection.range.focus.isSimple())return!1;const t=bA(n);return t?(n.selection.setSelection(t),n.selection.updateLastCaretRect(),!0):!1}const BA=S("find-block-position");function BT(n,e,t,o){g(BA,Le(n,e),"is not a complex block");const r=jn(n,e).getChildContainers(n,e);g(BA,r.length>0,"complex block has not any child container");const i=To(n,t,o),s=i.left+i.width/2,l=i.top+i.height/2,a=T4(n,e,s,l);return Qg(n,a,t,o)}function Qg(n,e,t,o){if(Le(n,e))return BT(n,e,t,o);const r=ie(e);let i=Number.MAX_SAFE_INTEGER;const s=To(n,t,o),l=s.left+s.width/2,a=s.top+s.height/2;let d=se(r,0,"home");const h=ue(n,e);for(let p=0;p<=h;p++){const A=se(r,p,"normal"),v=To(n,e,A),B=tr(v,l,a);B<i&&(i=B,d=A)}return d}const EA=S("page-offset");function ET(n,e){const t=B6(n)*.9,r=e.getBoundingClientRect().bottom-t;if(r<ZI(n))return n.getFirstBlock();const i=ct(e);if(!i)return n.getFirstBlock();let s=i;for(;s;){if(s.getBoundingClientRect().y<r)return s;s=ct(s)}return n.getFirstBlock()}function xT(n,e){const t=B6(n)*.9,o=e.getBoundingClientRect(),r=QI(n),i=o.top+t;if(i>r)return n.getLastBlock();const s=Ze(e);if(!s)return n.getLastBlock();let l=s;for(;l;){if(l.getBoundingClientRect().bottom>i)return l;l=Ze(l)}return n.getLastBlock()}function xA(n){const e=n.selection.range.focus;g(EA,e.isSimple(),"invalid range type");const t=n.getBlockById(e.blockId),o=ET(n,t);let r;return o===n.getFirstBlock()?r=se(o,0,"home"):r=Qg(n,o,t,e),r}function IA(n){const e=n.selection.range.focus;g(EA,e.isSimple(),"invalid range type");const t=n.getBlockById(e.blockId),o=xT(n,t);let r;return o===n.getLastBlock()?r=se(o,ue(n,o),"end"):r=Qg(n,o,t,e),r}function TA(n){if(!n.selection.range.focus.isSimple())return!1;const t=xA(n);return t?(n.selection.setSelection(t),n.selection.updateLastCaretRect(),!0):!1}function DA(n){if(!n.selection.range.focus.isSimple())return!1;const t=IA(n);return t?(n.selection.setSelection(t),n.selection.updateLastCaretRect(),!0):!1}function SA(n){if(!n.selection.range.focus.isSimple())return!1;const t=xA(n);if(!t)return!1;const o=Ih(n,n.selection.getAnchorPos(),t);if(!o)return!1;const{anchor:r,focus:i}=o;return n.selection.setSelection(r,i),n.selection.updateLastCaretRect(),!0}function LA(n){if(!n.selection.range.focus.isSimple())return!1;const t=IA(n);if(!t)return!1;const o=Ih(n,n.selection.getAnchorPos(),t);if(!o)return!1;const{anchor:r,focus:i}=o;return n.selection.setSelection(r,i),n.selection.updateLastCaretRect(),!0}const Na=S("select-all");function MA(n,e){const t=St(n),o=Gt(n);return e.start.offset===0&&e.start.blockId===ie(t)&&e.end.offset===ue(e.getEditor(),o)&&e.end.blockId===ie(o)}function IT(n,e){const t=e.getEditor(),o=jn(t,n).getChildContainers(t,n),r=o[0],i=o[o.length-1],s=ie(n);return e.start.blockId===s&&e.start.childContainerId===ae(r)&&e.end.blockId===s&&e.end.childContainerId===ae(i)}function TT(n,e){g(Na,e,"no parent block"),g(Na,Le(n,e),"not a complex block");const t=jn(n,e).getChildContainers(n,e),o=t[0],r=t[t.length-1];n.selection.setRange(Ut(n,{anchor:ft(e,ae(o)),focus:ft(e,ae(r))}))}function RA(n,e){const t=ne(e);Yg(n,t)}function OA(n){const e=n.getFocusedBlock(),t=n.selection.range;if(t.start.isSimple()){if(t.start.blockId===t.end.blockId&&ee(n,e)){const r=t.start,i=t.end,s=ue(n,e);if(r.offset>0||i.offset<s)return n.selection.selectBlock(e,0,s),!1}return W(n.rootContainer,"select-all"),RA(n,St(n.rootContainer)),!1}return g(Na,!t.isSimple(),"invalid range type"),IT(e,t)?(RA(n,e),!1):(g(Na,e,"no parent block"),g(Na,Le(n,e),"not a complex block"),TT(n,e),!0)}function Yg(n,e){const t=vt(e),o=t[0],r=t[t.length-1],i=se(o,0,"home"),s=se(r,ue(n,r),"end");n.selection.setSelection(i,s,{noScroll:!0})}function _A(n){Zg(n),n.focus()}const Jg=S("selected-block-to-doc");function FA(n,e,t){!e.children||e.children.forEach(o=>{const r=n.getChildContainerData(o);r.forEach(i=>{FA(n,i,t)}),t.blocks[o]=me.default(r)})}function Th(n,e){const t=Qe(n,e.block);if(t.selectionToDoc)return t.selectionToDoc(n,e);const o=me.default(_i(n,e.block));if(ee(n,e.block)){const i=e.start,s=e.end;if(g(Jg,o.text,"no block text"),i.offset===s.offset)return{blocks:{root:[{...o,text:[]}]},meta:{},comments:{}};const{middle:l}=zt(o.text,i.offset,s.offset-i.offset);return{blocks:{root:[{...o,text:l}]},meta:{},comments:{}}}if(Lt(e.block))return{blocks:{root:[o]},meta:{},comments:{}};g(Jg,Le(n,e.block),"not complex block"),g(Jg,o.children,"no children");const r={blocks:{root:[o]},meta:{},comments:{}};return FA(n,o,r),r}function Kg(n,e){const t=se(e,0,"normal"),o=se(e,ue(n,e),"end");return Th(n,{block:e,start:t,end:o})}const DT=S("block-to-doc");function ST(n,e){g(DT,e.length>0,"invalid params, no blocks");const t=e.map(o=>Kg(n,o));return $s(t)}function Dh(n){const t=n.selection.range.getSelectedBlocks().map(o=>Th(n,o));return $s(t)}function PA(n,e){const t=n.getContainerById(e),i=vt(t).map(s=>({start:se(s,0,"home"),end:se(s,ue(n,s),"end"),block:s})).map(s=>Th(n,s));return $s(i)}const Sh=S("editor-selection");class LT{constructor(e){m(this,"editor");m(this,"caret");m(this,"_range");m(this,"lastCaretRect");m(this,"handleBlockDelete",(e,t,o,r)=>{if(o||r.child)return;const i=this.range;if(I6(t,i)){Sh.debug("adjust selection because remote deleted current block");const s=T6(e,t);this.setRange(s,{noScroll:!0})}});this.editor=e;const t=e.getFirstBlock(),o=ie(t);this.caret=new WI(e);const r=se(o,0,"normal");this._range=Ut(e,{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 e=this.range.focus;return this.editor.getBlockById(e.blockId)}getStartBlock(){const e=this.range.start;return this.editor.getBlockById(e.blockId)}getEndBlock(){const e=this.range.end;return this.editor.getBlockById(e.blockId)}selectBlock(e,t,o){const r=se(e,t,"normal");let i;o&&(i=se(e,o,"normal")),this.setSelection(r,i)}setSelection(e,t,o){if(t||(t=e),this.verifyPos(e),this.verifyPos(t),!this.selectionChanging(e,t))return this.range;const r=Ut(this.editor,{anchor:e,focus:t});if(this.range.isEqual(r))return this.range;const i=this._range;return this._range=r,this.selectionChanged(),this.updateFocusedBlock(i),xe(this.editor.rootContainer,"select-all")&&(!r.isSimple()||!XI(this.editor,r))&&te(this.editor.rootContainer,"select-all"),o!=null&&o.noScroll||this.scrollIntoView(),this.range}setRange(e,t){return this.setSelection(e.anchor,e.focus,t)}updateSelection(){this.caret.update(),qI(this.editor)}getFocusedPos(){return this.range.focus}getAnchorPos(){return this.range.anchor}selectionChanging(e,t){return!0}selectionChanged(){this.updateSelection(),this.editor.emit("selectionChanged",this.editor)}updateLastCaretRect(){const e=this.range.focus;if(!Hr(e))return;const t=this.editor.getBlockById(e.blockId);this.lastCaretRect=To(this.editor,t,e)}getSuggestedCaretX(){var e;return(e=this.lastCaretRect)==null?void 0:e.x}scrollIntoView(){KI(this.editor)}verifyPos(e){const t=this.editor.getBlockById(e.blockId);if(e.isSimple())e.offset>=0&&e.offset<=ue(this.editor,t)||g(Sh,!1,"invalid block position, out of range");else{const o=e.childContainerId;!!this.editor.getContainerById(o)||g(Sh,!1,"invalid complex block position, no container found")}}updateFocusedBlock(e){if(e&&this.range.start.blockId===e.start.blockId)return;let t;e&&e.start.blockId===e.end.blockId&&(t=this.editor.findBlockById(e.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;t&&xe(t,"focused")&&(te(t,"focused"),r=!0),this.removeAllBlockFocusedClass(),o&&this.setBlockFocused(o)&&(r=!0),r&&this.editor.emit("focusBlockChanged",this.editor,o!=null?o:null,t!=null?t:null)}verify(){this.verifyPos(this._range.start),this.verifyPos(this._range.end)}to(e){const t=Dh(this.editor);return e==="text"?La(this.editor,t):e==="markdown"?Ma(this.editor,t):S6(this.editor,t)}removeAllBlockFocusedClass(){this.editor.rootContainer.querySelectorAll('div[data-type="editor-block"].focused, div[data-type="editor-block"].child-focused').forEach(e=>{te(e,"focused"),te(e,"child-focused")})}setBlockFocused(e){if(xe(e,"focused"))return!1;W(e,"focused");let t=ne(e);for(;Do(t);){const o=oe(t);g(Sh,o,"parent block not found"),W(o,"child-focused"),t=ne(o)}return!0}}function MT(n){const e=n.selection.range.focus;if(!e.isSimple())return;const t=n.findBlockById(e.blockId);!t||n.selection.selectBlock(t,0,ue(n,t))}function RT(n){const e=n.selection.range.focus;if(!e.isSimple())return;const t=n.findBlockById(e.blockId);if(!t||!ee(n,t))return;let o=Vg(n,"select"),r=Wg(n,"select");if(!o||!r)return;const i=e.blockId;o.blockId!==i&&(o=se(t,0,"home")),r.blockId!==i&&(r=se(t,ue(n,t),"end")),n.selection.setSelection(o,r)}class OT{constructor(e){m(this,"editor");m(this,"startPos",null);m(this,"lastCaretRect");m(this,"mouseDownEvent",null);m(this,"autoScroll",null);m(this,"handleMouseDown",e=>{this.mouseDownEvent=e;const t=L4(this.editor,e.x,e.y);if(t){if(t instanceof or)return;if(!this.autoScroll){const r=t.getSelectedBlocks(),i=oo(r[0].block);this.autoScroll=new Zd({scrollElement:i,edge:{top:50,bottom:50}})}const o=this.editor.selection.range;if(e.shiftKey&&o.isSimple()){const r=o.anchor;this.editor.selection.setSelection(r,t.focus),this.startPos=t.start}else this.editor.selection.setSelection(t.anchor,t.focus),this.startPos=t.start;this.editor.selection.updateLastCaretRect(),this.autoScroll.active()}});m(this,"handleMouseMove",e=>{if(!this.startPos||!this.mouseDownEvent||Math.abs(this.mouseDownEvent.x-e.x)<3&&Math.abs(this.mouseDownEvent.y-e.y)<3)return;const t=rh(this.editor,e.x,e.y);if(!t)return;const o=Ih(this.editor,this.startPos,t.end);if(!o)return;const{anchor:r,focus:i}=o;this.editor.selection.setSelection(r,i)});m(this,"handleMouseUp",e=>{var t;(t=this.autoScroll)==null||t.inactive(),this.startPos=null});this.editor=e,this.startPos=null,this.lastCaretRect=new DOMRect}isSelecting(){return this.startPos!==null}stopSelection(){this.startPos=null}handleDblClick(e){RT(this.editor)}handleTripleClick(e){MT(this.editor)}}function _T(n){return n.readonly||!n.isWritable()?!1:(n.undoManager.undo(),!0)}function FT(n){return n.readonly||!n.isWritable()?!1:(n.undoManager.redo(),!0)}const NA=S("delete-text");function $A(n,e,t,o){const r=o!=null?o:n.selection.range.start;r instanceof jt||g(NA,!1,`invalid insert pos type: ${typeof r}`);const{blockId:i}=r,s=n.getBlockById(i);g(NA,ee(n,s),"block is not a text kind block");let{offset:l}=r;if(e==="backward"){if(l-t<0)return 0;if(!sn(s,l-t)){const a=Ri(s,l);t=l-a}}else if(e==="forward"&&l+t>ue(n,s))return 0;return e==="backward"&&(l-=t),n.deleteTextFromBlock(s,l,t)}function HA(n,e){if(n.getBlockData(e).quoted){const t={quoted:null};return n.updateBlockData(e,t),!0}return!1}const PT=S("handle-backspace");function Xg(n,e){if(!ht(n,e))return;const t=ne(e);Eo(t)!==1&&n.deleteBlock(e)}function NT(n,e){if(!n.selection.range.isCollapsed()){n.clearSelectedContents();return}const t=n.selection.range.start,o=n.getBlockById(t.blockId);if(ee(n,o))if(t.offset===0){if(HA(n,o))return;const r=ct(o);if(r){if(!n.isBlockWritable(r))return;if(ee(n,r))n.mergeTextBlock(r,o,{focus:!0});else if(Le(n,r)){Xg(n,o);const i=Vl(n,r);i?n.selection.selectBlock(i,ue(n,i)):n.selection.selectBlock(r,0,ue(n,r))}else Xg(n,o),g(PT,Lt(r),"prev block is not embed block"),n.selection.selectBlock(r,1)}else{const i=ne(o);if(Do(i)){const s=E4(n,i);if(s){if(!n.isBlockWritable(s))return;Xg(n,o),n.selection.selectBlock(s,ue(n,s))}}}}else $A(n,"backward",1,null),n.selection.updateLastCaretRect();else{const r=be(o),i=ne(o);n.insertTextBlock("",ae(i),r),n.deleteBlock(o)}}function $T(n,e){if(!n.selection.range.isCollapsed()){n.clearSelectedContents();return}const t=n.selection.range.start,o=n.getBlockById(t.blockId);if(ee(n,o))if(t.offset===ue(n,o)){const r=Ze(o);if(r){if(!n.isBlockWritable(r))return;ee(n,r)?n.mergeTextBlock(o,r,{focus:!0}):ht(n,o)?n.deleteBlock(o,yt(n,r,0)):n.deleteBlock(r)}}else $A(n,"forward",1,null);else{const r=be(o),i=ne(o);n.insertTextBlock("",ae(i),r),n.deleteBlock(o)}}function HT(n){const{range:e}=n.selection,{start:t,end:o}=e,r=n.getBlockById(t.blockId),i=n.getBlockById(o.blockId);if(r!==i||!Le(n,r))return!1;if(Hr(t))return!0;const s=Os(n,r,t,o),l=En(n,r);return s.length===l.length}function jT(n,e){if(HT(n)){const o=n.getFocusedBlock(),r=be(o),i=ae(ne(o));n.insertTextBlock("",i,r+1);return}n.selection.range.isCollapsed()||n.clearSelectedContents();const t=n.getFocusedBlock();if(ee(n,t)){if(ht(n,t)&&HA(n,t))return;const o=n.selection.range.start,r=n.breakTextBlock(t,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 UT(n,e){const t=n.selection.range.getSelectedBlocks()[0],{block:o}=t;if(!ee(n,o))return!1;const r=t.end;return n.insertBoxToBlock(o,r.offset,{type:"br",id:K(),box:!0,created:Date.now()}),!0}const zT=S("input-handler-actions");function VT(n,e){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(jT(n),!0))}function WT(n,e){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>($T(n),!0))}function qT(n,e){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(NT(n),!0))}function GT(n,e){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(UT(n),!0))}function ZT(n){return n.readonly||!n.isWritable()||!window.isSecureContext?!1:(navigator.clipboard.readText().then(e=>{n.input.handlePasteText(e,{toPlainText:!0})}).catch(e=>{zT.error(e)}),!0)}const Lh={ArrowDown:rA,ArrowUp:oA,ArrowLeft:tA,ArrowRight:nA,"Shift+ArrowDown":iA,"Shift+ArrowUp":cA,"Shift+ArrowLeft":sA,"Shift+ArrowRight":lA,"CtrlOrCmd+ArrowLeft":uA,"CtrlOrCmd+ArrowRight":dA,"CtrlOrCmd+Shift+ArrowLeft":hA,"CtrlOrCmd+Shift+ArrowRight":fA,"CtrlOrCmd+ArrowUp":gA,"CtrlOrCmd+ArrowDown":mA,"CtrlOrCmd+Shift+ArrowUp":pA,"CtrlOrCmd+Shift+ArrowDown":Zg,"CtrlOrCmd+A":OA,Home:kA,End:wA,"Shift+Home":vA,"Shift+End":yA,PageUp:TA,PageDown:DA,"Shift+PageUp":SA,"Shift+PageDown":LA,"CtrlOrCmd+Z":_T,"CtrlOrCmd+Shift+Z":FT,Enter:VT,Delete:WT,Backspace:qT,"Shift+Enter":GT,"CtrlOrCmd+Shift+V":ZT};function jA(n,e){return n.shortcuts.handleKeyboardEvents(n,e)!==void 0}function UA(n,e,t){if(e.type==="embed"){const i=e.embedData,s=i.src;if(s&&typeof s=="string"){const l=t.get(s);l&&(i.src=l)}return}const o=e.text;o&&o.forEach(i=>{if(i.attributes&&i.attributes.src&&typeof i.attributes.src=="string"){const s=t.get(i.attributes.src);s&&(i.attributes.src=s)}});const r=e.children;r&&r.forEach(i=>{n.blocks[i].forEach(l=>{UA(n,l,t)})})}function zA(n,e,t){if(t.size===0)return;e.blocks.root.forEach(r=>{const i=n.editorBlocks.getBlockClass(r.type);i.replaceResources?i.replaceResources(r,t):UA(e,r,t)})}async function QT(n,e){const t=e.filter(i=>i.indexOf(":")===-1),o=await n.doc.addResources(t),r=new Map;if(t.length!==o.length)return r;for(let i=0;i<t.length;i++)r.set(t[i],o[i]);return r}function YT(n,e){var i,s;const o=e.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 JT(n,e){const o=e.meta.resources;if(!o||Object.keys(o).length===0)return;let r=new Map;if(YT(n,e)){const s=Array.from(Object.keys(o));r=await QT(n,s),zA(n,e,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&&zA(n,e,i)}async function KT(n,e,t){await JT(n,e),n.undoManager.runInGroup(()=>{const{start:o,end:r}=n.selection.range,i=n.getBlockById(o.blockId);if(o.blockId===r.blockId&&Lt(i)){const s=ne(i),l=n.getBlockIndex(i),[a]=n.insertDocAt(s,l+1,e,t);a&&n.selection.selectBlock(a,ue(n,a))}else{n.clearSelectedContents();const{block:s,offset:l}=Gl(n);n.insertDoc(s,l,e,t)}})}const XT=["text/x-ones-editor-doc","image/*","text/office-html","text/html","text/plain","text/markdown","*"];function eD(n){let e;for(const t of XT)if(e=n[t],e)break;return e||null}function VA(n,e,t){if(e.type==="embed"){const s=e.embedData.src;if(s&&typeof s=="string")for(const l of s.split("|"))t.add(l);return}const o=e.text;o&&o.forEach(i=>{i.attributes&&i.attributes.src&&typeof i.attributes.src=="string"&&t.add(i.attributes.src)});const r=e.children;r&&r.forEach(i=>{n.blocks[i].forEach(l=>{VA(n,l,t)})})}function tD(n,e){const t=new Set;return e.blocks.root.forEach(r=>{const i=n.editorBlocks.getBlockClass(r.type);i.getResources?i.getResources(r).forEach(s=>{t.add(s)}):VA(e,r,t)}),Array.from(t)}function Mh(n,e){return`<!doctype html><html><head><meta charset="utf8" />${`<meta charset="utf-8"><ones-editor-doc data-source="ones-editor-doc::${Bs(JSON.stringify(e))}::ones-editor-doc" />`}</head><body>${n}</body></html>`}function Rh(n,e){var i,s,l;const t=(l=(s=(i=n.doc).getServerMeta)==null?void 0:s.call(i))!=null?l:{},o=tD(n,e),r={};o.forEach(a=>{const d=n.doc.buildResourceUrl(a,{withToken:!0});r[a]=d}),e.meta={...t,resources:r}}function nD(n,e,t){if(e.preventDefault(),e.stopPropagation(),!e.clipboardData)return;let o=Dh(n);const r=t==null?void 0:t(n,e,o);if(r===!0)return;typeof r=="object"&&r!==null&&(o=r),Rh(n,o);const i=vh(n,o),s=Ma(n,o),l=Mh(i,o);e.clipboardData.setData("text/html",l),e.clipboardData.setData("text/plain",s),e.clipboardData.setData("text/x-ones-editor-doc",JSON.stringify(o))}async function Oh(n,e){const t=Kg(n,e);Rh(n,t);const o=vh(n,t),r=Ma(n,t),i=Mh(o,t);return Mm([{type:"text/plain",data:new Blob([r],{type:"text/plain"})},{type:"text/html",data:new Blob([i],{type:"text/html"})}])}class oD{constructor(e){m(this,"editor");m(this,"handlers",[]);m(this,"onPasteText",async(e,t)=>{const o=new DataTransfer;o.setData("text/plain",e);const r=await this.editor.dataConverter.fromData(this.editor,o,t);r&&this.pasteDocs(r,null)});this.editor=e}onInsertText(e,t){if(!ee(this.editor,this.editor.getFocusedBlock()))return;const{containerId:o,blockIndex:r,offset:i}=Gl(this.editor);this.handleBeforeInsertText(o,r,i,t)||(this.defaultInsertText(this.editor,o,r,i,t),this.handleAfterInsertText(o,r,i,t),this.editor.selection.updateLastCaretRect())}onKeyDown(e){if(this.handleBeforeKeyDown(e))return!0;const t=this.defaultHandleKeydown(this.editor,e);return this.handleAfterKeyDown(e)?!0:t}onChanged(e){for(let t=0;t<this.handlers.length;t++){const o=this.handlers[t];o.handleChanged&&o.handleChanged(this.editor,e)}}onRemoteChanged(e){for(let t=0;t<this.handlers.length;t++){const o=this.handlers[t];o.handleRemoteChanged&&o.handleRemoteChanged(this.editor,e)}}onCompositionStart(e){this.editor.updateCompositionText("",!1);const{containerId:t,blockIndex:o,offset:r}=Gl(this.editor);for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];s.handleCompositionStart&&s.handleCompositionStart(this.editor,t,o,r)}}onUpdateCompositionText(e,t,o){this.editor.updateCompositionText(t,o),this.editor.selection.caret.update();const{containerId:r,blockIndex:i,offset:s}=Gl(this.editor);for(let l=0;l<this.handlers.length;l++){const a=this.handlers[l];a.handleUpdateCompositionText&&a.handleUpdateCompositionText(this.editor,r,i,s,o)}this.editor.selection.updateLastCaretRect()}onCopy(e){nD(this.editor,e,(t,o,r)=>{for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];if(s.handleBeforeCopy){const l=s.handleBeforeCopy(this.editor,o,r);if(l===!0)return!0;if(typeof l=="object"&&l!=null)return l}}})}onCut(e){for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleBeforeCut&&r.handleBeforeCut(this.editor,e)===!0)return}if(this.onCopy(e),this.editor.selection.range.isCollapsed()){const o=this.editor.selection.focusedBlock;Lt(o)&&this.editor.deleteBlock(o)}else Fg(this.editor)}onPaste(e){if(e.preventDefault(),e.stopPropagation(),!e.clipboardData)return;this.editor.dataConverter.fromData(this.editor,e.clipboardData).then(async o=>{o&&this.pasteDocs(o,e)})}onFocus(){W(this.editor.rootElement,"active")}onBlur(){te(this.editor.rootElement,"active")}addHandler(e){this.handlers.push(e)}removeHandler(e){const t=this.handlers.indexOf(e);t!==-1&&this.handlers.splice(t)}handleBeforeInsertText(e,t,o,r){for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];if(s.handleBeforeInsertText&&s.handleBeforeInsertText(this.editor,e,t,o,r))return!0}return!1}handleAfterInsertText(e,t,o,r){for(let i=0;i<this.handlers.length;i++){const s=this.handlers[i];if(s.handleAfterInsertText&&s.handleAfterInsertText(this.editor,e,t,o,r))return!0}return!1}handleBeforeKeyDown(e){for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleBeforeKeyDown&&r.handleBeforeKeyDown(this.editor,e))return!0}const t=this.defaultHandleKeydown(this.editor,e);for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleAfterKeyDown&&r.handleAfterKeyDown(this.editor,e))return!0}return t}handleAfterKeyDown(e){for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleBeforeKeyDown&&r.handleBeforeKeyDown(this.editor,e))return!0}const t=this.defaultHandleKeydown(this.editor,e);for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleAfterKeyDown&&r.handleAfterKeyDown(this.editor,e))return!0}return t}defaultInsertText(e,t,o,r,i){Lg(this.editor,i)}defaultHandleKeydown(e,t){return jA(this.editor,t)?(t.preventDefault(),t.stopPropagation(),!0):!1}async pasteDoc(e){for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleBeforePasteDoc&&await r.handleBeforePasteDoc(this.editor,e))return}const t={blockIdMap:new Map,containerIdMap:new Map};await KT(this.editor,e,t);for(let o=0;o<this.handlers.length;o++){const r=this.handlers[o];if(r.handleAfterPasteDoc&&await r.handleAfterPasteDoc(this.editor,e,t))return}}async pasteDocs(e,t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforePaste&&await i.handleBeforePaste(this.editor,t,e))return}const o=eD(e);if(!!o){await this.pasteDoc(o);for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleAfterPaste&&await i.handleAfterPaste(this.editor,t,e))return}}}destroy(){this.handlers.forEach(e=>{var t;(t=e.destroy)==null||t.call(e,this.editor)}),this.handlers=[]}}function rD(n,e,t){const o=_r(e,t);return o.remove(),o}S("copy-dom-attributes");const WA=["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 iD(n,e){for(let l=0;l<WA.length;l++){const a=WA[l];e[a]=n[a]}const t=n.attributes,o=e.attributes,r=[],i=[];for(let l=0;l<t.length;l++){const a=t[l],d=o.getNamedItem(a.name);d?d.value!==a.value&&(d.value=a.value,i.push(a)):r.push(a)}const s=[];for(let l=0;l<o.length;l++){const a=o[l];t.getNamedItem(a.name)||s.push(a)}r.forEach(l=>{e.setAttribute(l.name,l.value)}),i.forEach(l=>{e.setAttribute(l.name,l.value)}),s.forEach(l=>{e.removeAttribute(l.name)})}function qA(n){const e=Array.from(n.childNodes).filter(t=>!HC(t));return e.forEach(t=>{t.remove()}),e}function GA(n,e,t){var d;const o=n.getContainerById(e),r=_r(o,t),i=Di(r),s=n.doc.getBlockData(e,t),l=Qe(n,r);if((d=l==null?void 0:l.handleUpdateBlock)==null?void 0:d.call(l,n,r,s))n.editorBlockRenders.updateBlock(n,i,r,s);else{const h=n.editorBlocks.createBlock(i,o,s),p=qA(h);qA(r),p.forEach(v=>{r.appendChild(v)});const A=Kd(h);if(A){const v=Kd(r);v&&v.remove(),r.appendChild(A)}iD(h,r)}r4(n,r,s),n.blockHooks.forEach(h=>{var p;(p=h.update)==null||p.call(h,n,i,o,r,s)}),setTimeout(()=>{n.selection.updateSelection(null)})}const sD=S("transform-selection");function ZA(n,e,t,o){const{range:r}=n.selection,{anchor:i,focus:s}=r;if(i.blockId!==e&&s.blockId!==e)return r;g(sD,i.isSimple()&&s.isSimple(),"invalid text pos type");let l=i;if(i.blockId===e){const d=ln.transformCursor(i.offset,t,o);l=se(e,d,"normal")}let a=s;if(s.blockId===e){const d=ln.transformCursor(s.offset,t,o);a=se(e,d,"normal")}return Ut(n,{anchor:l,focus:a})}const lD=S("handle-block-text-changed");function cD(n,e,t,o,r){const i=n.getContainerById(e),s=_r(i,t),l=n.doc.getBlockData(e,t);if(g(lD,l.text,"no block text"),KC(n,s).setBlockText(n,s,l.text),!r){const a=ZA(n,l.id,o,r);n.selection.setRange(a,{noScroll:!0})}}function aD(n,e){const t=me.default(n);return e.delete.forEach(r=>{delete t[r]}),{...t,...e.insert}}function QA(n,e,t,o){const r=Qe(n,e);r.handleDeleteBlock&&r.handleDeleteBlock(n,e,t,o),n.emit("blockDeleted",n,e,t,o)}function uD(n,e,t,o){const r=n.getBlockByIndex(e,t);r.querySelectorAll('[data-type="editor-block"]').forEach(i=>{QA(n,i,o,{child:!0})}),QA(n,r,o,{child:!1})}const Ro=S("editor-doc");class dD extends fa{constructor(t,o,r){super();m(this,"localEvents",[]);this.editor=t,this.externalDoc=o,this.externalDoc.registerCallback(this),this.registerLocalEvents(r)}beginBatchUpdate(){return this.externalDoc.beginBatchUpdate()}endBatchUpdate(){return this.externalDoc.endBatchUpdate()}registerLocalEvents(t){this.localEvents.push(t)}toJSON(){return this.externalDoc.toJSON()}getVersionHelper(){var o,r;return(r=(o=this.externalDoc).getVersionHelper)==null?void 0:r.call(o)}getContainerBlocks(t){return this.externalDoc.getContainerBlocks(t)}getBlockData(t,o){return this.externalDoc.getBlockData(t,o)}verifyBlockWritable(t,o){const r=this.editor.getBlockByIndex(t,o);g(Ro,this.editor.isBlockWritable(r),`block is not writable, ${t}, ${o}`)}localUpdateBlockText(t,o,r,i){g(Ro,!this.editor.readonly,"editor is readonly"),this.verifyBlockWritable(t,o);const s=this.getBlockData(t,o),l=s.text;g(Ro,l,`no text, ${t}, ${o}`);const a=ZA(this.editor,s.id,r,!0),d=ln.apply(l,r);this.localEvents.forEach(p=>p.onBeforeUpdateBlockText(t,s.id,l,d,a.toDocRange()));const h=this.externalDoc.localUpdateBlockText(t,o,r);return this.editor.selection.setRange(a,i),h}localUpdateBlockData(t,o,r,i){g(Ro,!this.editor.readonly,"editor is readonly");const s=this.editor.getBlockByIndex(t,o);if(!this.editor.isBlockWritable(s)){const h=Array.from(r.delete).filter(A=>A!=="comments"),p=Object.keys(r.insert).filter(A=>A!=="comments");(h.length>0||p.length>0)&&g(Ro,!1,`block is not writable, comment supported only, ${JSON.stringify(r)}}`)}const l=me.default(this.getBlockData(t,o)),a=me.default(aD(l,r));this.localEvents.forEach(h=>h.onBeforeUpdateBlockData(t,l.id,l,a,i));const d=this.externalDoc.localUpdateBlockData(t,o,r,i);return this.editor.selection.setRange(Si(this.editor,i)),d}localInsertBlock(t,o,r,i,s){g(Ro,!this.editor.readonly,"editor is readonly"),this.localEvents.forEach(a=>a.onBeforeInsertBlock(t,o,r,i));const l=this.externalDoc.localInsertBlock(t,o,r,i);return this.editor.selection.setRange(Si(this.editor,i),s),l}localDeleteBlock(t,o,r){g(Ro,!this.editor.readonly,"editor is readonly"),this.verifyBlockWritable(t,o);const i=me.default(this.getBlockData(t,o));this.localEvents.forEach(l=>l.onBeforeDeleteBlock(t,o,i,r));const s=this.externalDoc.localDeleteBlock(t,o,r);return this.editor.selection.setRange(Si(this.editor,r)),s}localDeleteChildContainers(t){return g(Ro,!this.editor.readonly,"editor is readonly"),t.forEach(o=>{const r=me.default(this.getContainerBlocks(o));this.localEvents.forEach(i=>i.onBeforeDeleteChildContainer(o,r))}),this.externalDoc.localDeleteChildContainers(t)}localInsertChildContainer(t,o){return g(Ro,!this.editor.readonly,"editor is readonly"),this.localEvents.forEach(r=>r.onBeforeInsertChildContainer(t,me.default(o))),this.externalDoc.localInsertChildContainer(t,o)}onRequestReload(t){Ro.debug(`reload doc: ${t}`),this.editor.reload(),this.callbacks.forEach(r=>{var i;return(i=r.onRequestReload)==null?void 0:i.call(r,t)});const o=!1;this.editor.emit("docChanged",this.editor,o)}onUpdateBlockText(t,o,r,i){this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockText)==null?void 0:l.call(s,t,o,r,i)}),cD(this.editor,t,o,r,i),this.editor.emit("docChanged",this.editor,i)}onUpdateBlockData(t,o,r,i){this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,t,o,r,i)}),GA(this.editor,t,o),this.editor.emit("docChanged",this.editor,i)}onInsertBlock(t,o,r,i){this.callbacks.forEach(l=>{var a;return(a=l.onInsertBlock)==null?void 0:a.call(l,t,o,r,i)});const s=this.editor.getContainerById(t);KE(this.editor,s,o,r),this.editor.emit("docChanged",this.editor,i)}onDeleteBlock(t,o,r){uD(this.editor,t,o,r),this.callbacks.forEach(s=>{var l;return(l=s.onDeleteBlock)==null?void 0:l.call(s,t,o,r)});const i=this.editor.getContainerById(t);rD(this.editor,i,o),this.editor.emit("docChanged",this.editor,r)}onInsertChildContainer(t,o,r){this.callbacks.forEach(i=>{var s;return(s=i.onInsertChildContainer)==null?void 0:s.call(i,t,o,r)})}onDeleteChildContainer(t,o){this.callbacks.forEach(r=>{var i;return(i=r.onDeleteChildContainer)==null?void 0:i.call(r,t,o)})}onCustomMessage(t){this.callbacks.forEach(o=>{var r;return(r=o.onCustomMessage)==null?void 0:r.call(o,t)})}onStatusChanged(t){this.callbacks.forEach(o=>{var r;return(r=o.onStatusChanged)==null?void 0:r.call(o,t)})}onError(t){this.callbacks.forEach(o=>{var r;return(r=o.onError)==null?void 0:r.call(o,t)})}uploadResource(t,o){return this.externalDoc.uploadResource(t,o)}addResources(t){return this.externalDoc.addResources(t)}buildResourceUrl(t,o){return this.externalDoc.buildResourceUrl(t,o)}request(t,o){return this.externalDoc.request(t,o)}broadcastMessage(t){return this.externalDoc.broadcastMessage(t)}getUser(){return this.externalDoc.getUser()}getRemoteUsers(){return this.externalDoc.getRemoteUsers()}destroy(){this.externalDoc.destroy(),this.clearCallbacks()}getServerMeta(){var t,o,r;return(r=(o=(t=this.externalDoc).getServerMeta)==null?void 0:o.call(t))!=null?r:{}}reset(t){Ro.log("reset doc"),this.externalDoc=t,this.externalDoc.registerCallback(this),this.editor.reload()}}function YA(n,e){if(n.length===0){n.push(e);return}const t=n[n.length-1];if(!t.combinable(e)){n.push(e);return}t.combine(e)}const ep=S("undo-action");class Kl{constructor(e,t,o){m(this,"beforeRange");m(this,"afterRange");this.containerId=t,this.beforeRange=e.selection.range.clone().toDocRange(),this.afterRange=o}undo(e){return!1}redo(e){return!1}combinable(e){return g(ep,e,"no other action"),!1}combine(e){g(ep,!1,"no other")}setAfterRange(e){this.afterRange&&ep.warn("after range has already set"),this.afterRange=e}}const hD=S("block-action");class JA extends Kl{constructor(t,o,r,i,s){super(t,o,s);m(this,"blockData");m(this,"blockIndex");this.blockData=me.default(i),this.blockIndex=r}deleteBlock(t,o){if(!t.getContainerById(this.containerId))return!1;const i=t.getBlockById(this.blockData.id);return i?(g(hD,this.blockIndex===be(i),"invalid block index"),wh(t,i,Si(t,o)),!0):!1}insertBlock(t,o){return Ql(t,this.containerId,this.blockIndex,me.default(this.blockData),o),!0}}class fD extends JA{undo(e){return this.deleteBlock(e,this.beforeRange)}redo(e){return this.insertBlock(e,this.afterRange)}}class mD extends JA{undo(e){return this.insertBlock(e,this.beforeRange)}redo(e){return this.deleteBlock(e,this.afterRange)}}class gD extends Kl{constructor(t){super(t,ae(t.rootContainer),t.selection.range.toDocRange());m(this,"actions",[])}addAction(t){YA(this.actions,t),this.afterRange=t.afterRange}undo(t){let o=!1;return this.actions.concat().reverse().forEach(r=>{r.undo(t)&&(o=!0)}),o}redo(t){let o=!1;return this.actions.forEach(r=>{r.redo(t)&&(o=!0)}),o}setAfterRange(t){this.afterRange=t;const o=this.actions[this.actions.length-1];!o||o instanceof Kl&&(o.afterRange||o.setAfterRange(t))}}const Hs=S("update-block-data-action");class _h extends Kl{constructor(t,o,r,i,s,l){super(t,o,l);m(this,"beforeBlockData");m(this,"afterBlockData");m(this,"blockId");this.blockId=r,g(Hs,this.blockId===i.id,"invalid block id"),g(Hs,this.blockId===s.id,"invalid block id"),this.beforeBlockData=me.default(i),this.afterBlockData=me.default(s),g(Hs,this.beforeBlockData.type===this.afterBlockData.type,"invalid block type")}undo(t){g(Hs,t,"no editor");const o=t.getBlockById(this.blockId);if(!o)return!1;const r=t.getContainerById(this.containerId);return g(Hs,r,"no container"),xh(t,o,_h.toAttributes(this.beforeBlockData),this.beforeRange),!0}redo(t){g(Hs,t,"no editor");const o=t.getBlockById(this.blockId);if(!o)return!1;const r=t.getContainerById(this.containerId);return g(Hs,r,"no container"),xh(t,o,_h.toAttributes(this.afterBlockData),this.afterRange),!0}static toAttributes(t){const o=me.default(t);return delete o.id,delete o.type,o}}const tp=S("update-block-text-action");class $a extends Kl{constructor(t,o,r,i,s,l){super(t,o,l);m(this,"beforeRichTextData");m(this,"afterRichTextData");m(this,"blockId");m(this,"type");this.blockId=r,this.beforeRichTextData=me.default(i),this.afterRichTextData=me.default(s),this.type=$a.calType(i,s)}static calType(t,o){g(tp,t,"no old data"),g(tp,o,"no new data");const i=ln.diff(t,o),s=new Set;let l=!1;const a=h=>gC(h)?`cjk_${h}`:fC(h)?"number":Ud(h)?"space":mC(h)?"letter":"unknown";let d=!1;return i.forEach(h=>{h.insert?h.insert===" "?s.add("insert_letter"):typeof h.insert=="string"&&h.insert.startsWith(" ")&&h.insert.length>1?(l=!0,d=!0,s.add(`insert_${a(h.insert.substr(1))}`)):s.add(`insert_${a(h.insert)}`):h.delete&&(l?l=!1:s.add("delete"))}),{textType:Array.from(s).join("|"),begin:d}}undo(t){if(!t.getContainerById(this.containerId))return!1;const r=t.getBlockById(this.blockId);return r?(Eh(t,r,this.beforeRichTextData),!0):!1}redo(t){if(!t.getContainerById(this.containerId))return!1;const r=t.getBlockById(this.blockId);return r?(Eh(t,r,this.afterRichTextData),!0):!1}combinable(t){if(!(t instanceof $a)||t.type.begin||this.type.textType!==t.type.textType||t.blockId!==this.blockId)return!1;const o=t.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(t){g(tp,t instanceof $a,"invalid action type");const o=t;this.afterRichTextData=o.afterRichTextData,this.afterRange=t.afterRange}}class KA extends Kl{constructor(e,t,o){super(e,t,e.selection.range.toDocRange()),this.blocks=o}deleteChildContainer(e){return e.doc.localDeleteChildContainers([this.containerId]),!0}insertChildContainer(e){return e.doc.localInsertChildContainer(this.containerId,me.default(this.blocks)),!0}}class pD extends KA{undo(e){return this.deleteChildContainer(e)}redo(e){return this.insertChildContainer(e)}}class CD extends KA{undo(e){return this.insertChildContainer(e)}redo(e){return this.deleteChildContainer(e)}}const Oo=S("undo");class AD{constructor(e){m(this,"editor");m(this,"actions",[]);m(this,"undoCursor");m(this,"currentGroup",null);m(this,"groupCounter",0);m(this,"undoRedoing",!1);m(this,"handleSelectionChange",e=>{if(this.currentGroup){this.currentGroup.setAfterRange(e.selection.range.toDocRange());return}const t=this.actions[this.actions.length-1];!t||t.afterRange||t.setAfterRange(e.selection.range.toDocRange())});this.editor=e,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(e){this.currentGroup?this.currentGroup.addAction(e):(YA(this.actions,e),setTimeout(()=>{this.editor.input.handleChanged(e)}))}beginGroup(){this.groupCounter===0?(g(Oo,!this.currentGroup,"current group already exists"),this.currentGroup=new gD(this.editor),this.groupCounter=1):(g(Oo,this.currentGroup,"current group not exists"),this.groupCounter+=1)}endGroup(){g(Oo,this.currentGroup,"current group not exists"),g(Oo,this.groupCounter>0,"group counter === 0"),this.groupCounter-=1,this.groupCounter===0&&(this.currentGroup.actions.length===0?Oo.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(e){this.beginGroup();try{const t=e();return setTimeout(()=>this.editor.selection.caret.update()),t}catch(t){throw Oo.error(`failed to run action: ${t.message}`),t}finally{this.endGroup()}}undo(){this.undoCursor===-1&&(this.undoCursor=this.actions.length);try{for(this.undoRedoing=!0;this.undoCursor>0;){this.undoCursor-=1;const e=this.actions[this.undoCursor];if(e.undo(this.editor)){try{this.editor.selection.setRange(Si(this.editor,e.beforeRange))}catch(t){Oo.error(`undo: failed to restore caret pos: ${t.message}`)}return this.editor.input.handleChanged(e),!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 e=this.actions[this.undoCursor];if(this.undoCursor+=1,e.redo(this.editor)){try{const t=e.afterRange;t?this.editor.selection.setRange(Si(this.editor,t)):Oo.warn("no after range")}catch(t){Oo.error(`redo: failed to set caret pos after redo: ${t.message}`)}return this.editor.input.handleChanged(e),!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 t;const e=this.undoCursor===-1?this.actions.length-1:this.undoCursor-1;return(t=this.actions[e])!=null?t:null}undoTo(e){for(;;){const t=this.lastAction();if(!t||t===e)return!0;if(!this.undo())return!1}}onBeforeUpdateBlockText(e,t,o,r,i){this.undoRedoing||(this.prepareSaveUndoState(),ln.diff(o,r).length!==0&&this.addAction(new $a(this.editor,e,t,o,r,i)))}onBeforeUpdateBlockData(e,t,o,r,i){if(this.undoRedoing)return;this.prepareSaveUndoState();const s=new _h(this.editor,e,t,o,r,i);this.addAction(s)}onBeforeInsertBlock(e,t,o,r){this.undoRedoing||(this.prepareSaveUndoState(),g(Oo,t>=0,"invalid block index"),g(Oo,o,"no block data"),this.addAction(new fD(this.editor,e,t,o,r)))}onBeforeDeleteBlock(e,t,o,r){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new mD(this.editor,e,t,o,r)))}onBeforeInsertChildContainer(e,t){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new pD(this.editor,e,t)))}onBeforeDeleteChildContainer(e,t){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new CD(this.editor,e,t)))}}class bD{async fromData(e,t){const o=t.getData("text/x-ones-editor-doc");if(o)return{"text/x-ones-editor-doc":JSON.parse(o)}}}class vD{constructor(){m(this,"converters",[]);this.addConverter(new bD)}async fromData(e,t,o){let r={};for(const i of this.converters){const s=await i.fromData(e,t,o);s&&(r={...r,...s})}return r}addConverter(e){this.converters.push(e)}}class yD{constructor(e){m(this,"renders",[]);this.editor=e}registerRender(e){this.renders.push(e)}renderText(e,t){const o={classes:[],attributes:{},styles:{}};return this.renders.forEach(r=>{if(r.renderText){const i=r.renderText(this.editor,e,t);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(e,t,o){const r={classes:[],attributes:{},styles:{}};return this.renders.forEach(i=>{if(i.renderBlock){const s=i.renderBlock(this.editor,t,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(e,t,o,r){this.renders.forEach(i=>{var s;(s=i.updateBlock)==null||s.call(i,e,t,o,r)})}}class pt extends bt.TypedEmitter{constructor(t){super();m(this,"hoveringBlock",null);m(this,"hoveringTextChild",null);m(this,"filters",[]);m(this,"finders",[]);m(this,"handleDocumentMouseMove",t=>{if(this.hoveringBlock){for(const s of this.filters)if(s.isInBlock(this.hoveringBlock,t))return}const o=document.elementFromPoint(t.x,t.y);if(!o){this.setHoveringBlock(null,t,null);return}let r=oe(o);if((!r||!Ke(this.editor.rootContainer,r))&&(r=this.findBlockByFinders(t),!r)){this.setHoveringBlock(null,t,null);return}const i=this.getParentTextContentChild(r,o);this.setHoveringBlock(r,t,i)});this.editor=t,document.addEventListener("mousemove",this.handleDocumentMouseMove)}destroy(){document.removeEventListener("mousemove",this.handleDocumentMouseMove),this.filters.forEach(t=>t.destroy()),this.filters=[],this.finders.forEach(t=>t.destroy()),this.finders=[]}addFilter(t){this.filters.push(t)}addFinder(t){this.finders.push(t)}hoveringBlockId(){return this.hoveringBlock?ie(this.hoveringBlock):""}findBlockByFinders(t){for(let o=0;o<this.finders.length;o++){const i=this.finders[o].findTargetBlock(this.editor,t);if(i)return i}return null}setHoveringBlock(t,o,r){if(this.hoveringBlock===t&&this.hoveringTextChild===r)return;if(this.hoveringBlock!==t){const s=this.hoveringBlock&&Ke(this.editor.rootContainer,this.hoveringBlock)?this.hoveringBlock:null;s&&te(s,"hover"),t&&W(t,"hover"),this.hoveringBlock=t,this.emit("change",this.hoveringBlock,s,o)}const i=this.hoveringTextChild;this.hoveringTextChild=r,this.emit("childChange",this.hoveringBlock,r,i,o)}static get(t){return t.addCustom("standard-hovering-block",()=>new pt(t))}getParentTextContentChild(t,o){if(!ee(this.editor,t))return null;const r=Re(t);return o.parentElement===r?o:$m(o)}}const XA="style-color-",eb="style-bg-color-";class kD{renderText(e,t,o){const r=[],i={},s={};return Object.entries(o).forEach(([l,a])=>{a===!0?l.startsWith(XA)?i["data-style-color"]=l.substring(XA.length):l.startsWith(eb)?i["data-style-bg-color"]=l.substring(eb.length):l.startsWith("style")&&r.push(l):typeof a=="string"&&(l==="link"&&(r.push("link"),i.link=a),l==="inline-style-color"&&(s.color=a))}),{classes:r,attributes:i,styles:s}}renderBlock(e,t,o){var l,a;const r={};Object.entries(o).filter(d=>d[0].startsWith("style-")).forEach(([d,h])=>{r[`data-${d}`]=`${h}`});const s=[];return((a=(l=e.selection)==null?void 0:l.range)==null?void 0:a.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"),pt.get(e).hoveringBlockId()===o.id&&s.push("hover"),{attributes:r,classes:s}}updateBlock(e,t,o,r){var s,l;Array.from(o.attributes).forEach(a=>{a.name.startsWith("data-style-")&&o.removeAttribute(a.name)}),Object.entries(r).filter(a=>a[0].startsWith("style-")||a[0]==="align").forEach(([a,d])=>{a==="align"&&o.setAttribute(a.startsWith("style-")?`data-${a}`:`data-style-${a}`,`${d}`)}),((l=(s=e.selection)==null?void 0:s.range)==null?void 0:l.start.blockId)===r.id&&W(o,"focused"),pt.get(e).hoveringBlockId()===r.id&&W(o,"hover")}}function wD(n){n.editorBlocks.registerBlockClass(In),n.editorBlocks.registerBlockClass(B4),n.editorBoxes.registerBoxClass(f6),n.editorBoxes.registerBoxClass(m6),n.editorBoxes.registerBoxClass(C6),n.editorBoxes.registerBoxClass(A6),n.editorInsertions.registerInsertionClass(b6),n.editorBlockRenders.registerRender(new kD)}function BD(n,e){wD(n),e!=null&&e.blocks&&e.blocks.forEach(t=>n.editorBlocks.registerBlockClass(t)),e!=null&&e.boxes&&e.boxes.forEach(t=>n.editorBoxes.registerBoxClass(t)),e!=null&&e.embeds&&e.embeds.forEach(t=>n.editorEmbeds.registerEmbedClass(t)),e!=null&&e.insertions&&e.insertions.forEach(t=>n.editorInsertions.registerInsertionClass(t)),e!=null&&e.decorators&&e.decorators.forEach(t=>n.editorDecorators.registerDecorator(t)),e!=null&&e.dataConverters&&e.dataConverters.forEach(t=>n.dataConverter.addConverter(t)),e!=null&&e.commandProviders&&e.commandProviders.forEach(t=>n.editorCommandProviders.registerCommandProvider(t)),e!=null&&e.textRenders&&e.textRenders.forEach(t=>n.editorBlockRenders.registerRender(t))}const tb=S("range-commands");function nb(n,e){n.forEach(t=>{t.source=e,t.children&&nb(t.children,e)})}function ob(n,e,t){const o=ie(e);g(tb,o===t.start.blockId,"invalid start range"),g(tb,o===t.end.blockId,"invalid end range");const r=n.editorCommandProviders.getCommandProviders();let i=[];return r.forEach(s=>{const l=s.getAvailableCommands(n,e,t);nb(l,s.id),i.push(...l)}),r.forEach(s=>{if(s.filterCommands){const l=s.filterCommands(n,e,t,i);l&&(i=l)}}),Le(n,e)&&Os(n,e,t.start,t.end).forEach(l=>{vt(l).forEach(d=>{const h=ue(n,d),p=Ut(n,{anchor:se(d,0,"home"),focus:se(d,h,"end")}),A=ob(n,d,p);i.push(...A)})}),i}function rb(n){const e=n.getEditor(),t=n.getSelectedBlocks(),o=[];return t.forEach(r=>{const i=Ut(e,{anchor:r.start,focus:r.end});ob(e,r.block,i).forEach(l=>{o.push(l)})}),o}function ib(n,e,t,o,r,i){var h;const s=n.editorCommandProviders.getCommandProviders();for(let p=0;p<s.length;p++){const A=s[p];if(A.beforeExecuteCommand&&A.beforeExecuteCommand(n,e,t,o,r))return!1}const l=n.editorCommandProviders.getCommandProvider(o.source),a={};if((h=l.executeCommand)!=null&&h.call(l,n,e,t,o,r,{}))return i[ie(e)]=a,!0;let d=!1;return Le(n,e)&&Os(n,e,t.start,t.end).forEach(A=>{vt(A).forEach(B=>{const D=ue(n,B),I=Ut(n,{anchor:se(B,0,"home"),focus:se(B,D,"end")});ib(n,B,I,o,r,i)&&(d=!0)})}),s.forEach(p=>{p.afterExecuteCommand&&p.afterExecuteCommand(n,e,t,o,r,i)}),d}function sb(n,e,t){const o=n.getEditor(),r={},i=o.editorCommandProviders.getCommandProvider(e.source);return i.executeRangeCommand&&i.executeRangeCommand(o,n,e,t,r)||n.getSelectedBlocks().forEach(l=>{const a=Ut(o,{anchor:l.start,focus:l.end});ib(o,l.block,a,e,t,r)}),r}const ED=S("command-providers");class lb{constructor(e){m(this,"providers",[]);this.editor=e}registerCommandProvider(e){this.providers.push(e)}getCommandProviders(){return this.providers}getCommandProvider(e){const t=this.providers.find(o=>o.id===e);return g(ED,t,`no command provider, id=${e}`),t}getCommands(e){return rb(e)}executeCommand(e,t,o){return this.editor.undoManager.runInGroup(()=>sb(e,t,o))}getEmptyBlockTextAttributes(e,t){let o={};if(this.providers.forEach(r=>{var s;const i=(s=r.getEmptyBlockTextAttributes)==null?void 0:s.call(r,e,t);i&&(o={...o,...i})}),Object.keys(o).length!==0)return o}}function xD(n,e){const t=ne(e),o=ae(t),r=be(e);GA(n,o,r)}const ID=S("table-scroll");class cb{constructor(e,t,o,r,i){m(this,"handleEvent",e=>{this.handler(this.editor,e,this.data)});this.editor=e,this.dom=t,this.name=o,this.handler=r,this.data=i,t.addEventListener(o,this.handleEvent)}destroy(){this.dom.removeEventListener(this.name,this.handleEvent)}}class TD{constructor(e){m(this,"handlers",new Map);this.editor=e}destroy(){Array.from(this.handlers.entries()).forEach(([e,t])=>{t.forEach(o=>o.destroy()),this.handlers.delete(e)})}addEventListener(e,t,o,r){const i=this.handlers.get(e);if(i){if(i.find(s=>s.handler===o&&s.name===t)){ID.warn(`event has already registered: ${t}`);return}i.push(new cb(this.editor,e,t,o,r))}else{const s=new cb(this.editor,e,t,o,r);this.handlers.set(e,[s])}}removeEventListener(e,t,o){if(!e){for(const[i,s]of Array.from(this.handlers.entries()))for(let l=s.length-1;l>=0;l--){const a=s[l];if(t)t===a.name&&o===a.handler&&s.splice(l,1);else if(o===a.handler){s.splice(l,1),a.destroy(),s.length===0&&this.handlers.delete(i);continue}}return}const r=this.handlers.get(e);if(r){const i=r.findIndex(s=>s.handler===o&&s.name===t);if(i!==-1){const s=r[i];r.splice(i,1),s.destroy(),r.length===0&&this.handlers.delete(e)}}}removeAllListeners(e,t){const o=this.handlers.get(e);if(o)if(t)for(let r=0;r<o.length;r++){const i=o[r];i.name===t&&(o.splice(r,1),i.destroy())}else o.forEach(r=>{r.destroy()}),this.handlers.delete(e)}}const ab=S("update-block-text");function DD(n,e){const t=n.getBoxById(e.id),o=oe(t);g(ab,o,"no parent block"),g(ab,ee(n,o),"not a text block");const r=n.getBlockText(o),i=r6(r,"id",e.id,e);j6(n,o,i)}function SD(n,e){for(const t of n.blockHooks)if(t.writable){const o=t.writable(n,e);if(typeof o=="boolean")return o}return!0}function LD(n){return n.readonly?!1:!Lo(n).find(o=>!n.isBlockWritable(o.block))}class MD{constructor(e){this.editor=e}getKey(e){return`${this.editor.id}-${e}`}getItem(e){return window.localStorage.getItem(this.getKey(e))}setItem(e,t){if(!t){this.removeItem(e);return}window.localStorage.setItem(this.getKey(e),t)}removeItem(e){window.localStorage.removeItem(this.getKey(e))}}class RD{constructor(){m(this,"shortcuts",[])}handleKeyboardEvents(e,t){const o=this.shortcuts;for(const r of o){const i=Object.entries(r);for(const[s,l]of i)if(Or(t,s)){const a=l(e,t);if(a!==void 0)return a}}}}const Vr=S("editor");class OD extends bt.TypedEmitter{constructor(t,o,r){var i,s,l,a,d,h,p;super();m(this,"parent");m(this,"rootElement");m(this,"contentElement");m(this,"rootContainerObject");m(this,"rootContainer");m(this,"input");m(this,"selection");m(this,"selectionHandler");m(this,"doc");m(this,"id");m(this,"clientId");m(this,"compositingText","");m(this,"undoManager");m(this,"shortcuts",new RD);m(this,"dataConverter",new vD);m(this,"editorBlocks",new v4(this));m(this,"editorBoxes",new p6(this));m(this,"editorInsertions",new y6(this));m(this,"editorEmbeds",new k4(this));m(this,"editorDecorators",new k6(this));m(this,"editorCommandProviders",new lb(this));m(this,"editorBlockRenders",new yD(this));m(this,"blockHooks",[]);m(this,"domEvents",new TD(this));m(this,"customs",new Map);m(this,"options");m(this,"inputHandlers",new oD(this));m(this,"settingsProvider");m(this,"_readonly",!1);Vr.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=(a=r==null?void 0:r.settingsProvider)!=null?a:new MD(this),BD(this,r==null?void 0:r.components),this.blockHooks.push(...(h=(d=r==null?void 0:r.components)==null?void 0:d.blockHooks)!=null?h:[]),this.id=(p=r==null?void 0:r.id)!=null?p:K(),this.clientId=K(),this.undoManager=new AD(this),this.doc=new dD(this,o,this.undoManager),this.parent=t,this.rootElement=w("div",["editor-root"],this.parent),this.rootElement.setAttribute("data-editor-client-id",this.clientId),this.contentElement=w("div",["editor-content"],this.rootElement),this.rootContainerObject=C4(this),this.rootContainer=this.rootContainerObject.rootContainer,this.input=new VI(this,this.inputHandlers),this.selection=new LT(this),this.selectionHandler=new OT(this),r!=null&&r.shortcuts&&this.shortcuts.shortcuts.push(...r.shortcuts),Kt.isMobile&&W(this.rootElement,"mobile"),Kt.isSafari&&W(this.rootElement,"safari"),this._readonly&&W(this.rootElement,"readonly"),this.emit("load",this,!1)}get readonly(){return this._readonly}set readonly(t){this._readonly=t,t?W(this.rootElement,"readonly"):te(this.rootElement,"readonly"),this.emit("readonlyChanged",this)}get scrollContainer(){return this.options.scrollContainer?this.options.scrollContainer:oo(this.rootContainer)}addCustom(t,o){const r=this.customs.get(t);if(r)return r;const i=o(this);return this.customs.set(t,i),i}getCustom(t){const o=this.customs.get(t);return g(Vr,o,`${t} does not exists`),o}replaceCustom(t,o){const r=this.customs.get(t);return r&&r.destroy(),this.customs.set(t,o),o}findCustom(t){return this.customs.get(t)}findCustomByType(t){const o=this.customs.values();for(const r of o)if(r instanceof t)return r;return null}destroyCustom(t){const o=this.customs.get(t);o&&(this.customs.delete(t),o.destroy())}getComponentOptions(t){return this.options.componentsOptions[t]}registerLocalEvents(t){this.doc.registerLocalEvents(t)}reload(){this.rootContainerObject.reload(),this.emit("load",this,!0)}createBlock(t,o,r){return this.editorBlocks.createBlock(t,o,r)}createBox(t,o){return this.editorBoxes.createBox(t,o)}createInsertion(t,o){return this.editorInsertions.createInsertion(t,o)}destroy(){Vr.debug("destroy editor"),this.emit("destroy",this),this.input.destroy(),this.rootContainerObject.destroy(),this.rootElement.remove(),this.doc.destroy(),this.customs.forEach(t=>t.destroy()),this.customs.clear(),this.selection.destroy(),this.domEvents.destroy(),this.removeAllListeners(),this.inputHandlers.destroy()}focus(){this.input.focus()}focusToBlock(t,o){Pg(this,t,o)}isWritable(){return LD(this)}isBlockWritable(t){return SD(this,t)}getChildContainerData(t){const o=this.doc.getContainerBlocks(t);return g(Vr,o,`no child container data: ${t}, ${JSON.stringify(this.doc)}`),g(Vr,Array.isArray(o),`container data is not an array: ${JSON.stringify(o)}`),o}createChildContainer(t,o,r){return A4(this,t,o,r)}getFirstBlock(){return this.rootContainer.querySelector("[data-type=editor-block]")}getLastBlock(){const t=Array.from(this.rootContainer.querySelectorAll(":scope [data-type=editor-block]"));return t[t.length-1]}getFocusedBlock(){return this.selection.getFocusedBlock()}findBlockById(t){const o=this.rootContainer.querySelector(`#${t}`);return o&&g(Vr,xs(o),"not an valid block element"),o!=null?o:null}findBoxById(t){const o=this.rootContainer.querySelector(`#${t}`);return o&&g(Vr,Nm(o),"not an valid box element"),o!=null?o:null}getBlockById(t){const o=this.findBlockById(t);return g(Vr,o,`no block, id=${t}`),o}getBoxById(t){const o=this.findBoxById(t);return g(Vr,o,`no box, id=${t}`),o}getBlockByIndex(t,o){const r=this.getContainerById(t);return _r(r,o)}getBlockIndex(t){if(typeof t=="string"){const o=this.getBlockById(t);return be(o)}return be(t)}getContainerById(t){return $r(this,t)}getParentContainer(t){return ne(t)}reloadBlock(t){xD(this,t)}contains(t){const o=t instanceof Element?t:t.parentElement;return o?o.closest("div.editor-root")===this.rootElement:!1}insertBlock(t,o,r,i,s){const l={blockId:r.id,offset:0},a={anchor:l,focus:l};return Ql(this,t,o,r,i!=null?i:a,s)}insertEmbed(t,o,r,i,s){const l={id:K(),type:"embed",embedType:r,embedData:i};return this.insertBlock(t,o,l,s)}deleteBlock(t,o){Og(this,t,o)}mergeTextBlock(t,o){return N6(this,t,o)}breakTextBlock(t,o,r){return Yl(this,t,o,r).newBlock}getTextPosition(){return Gl(this)}getBlockString(t,o){const r=this.getBlockText(t);return rt(r,o)}getBlockData(t){return _i(this,t)}getBoxData(t){return d6(this,t)}getBlockText(t){return mn(this,t)}setBlockText(t,o){j6(this,t,o)}deleteTextFromBlock(t,o,r,i){return Mg(this,t,o,r,i)}insertTextToBlock(t,o,r,i){return L6(this,t,o,r,i)}insertBoxToBlock(t,o,r){return M6(this,t,o,r)}pasteDoc(t){return this.inputHandlers.pasteDoc(t)}insertDoc(t,o,r,i){V6(this,t,o,r,i)}insertDocAt(t,o,r,i){return Hg(this,t,o,r,i)}deleteChildContainers(t){P6(this,t)}replaceBlockText(t,o){return Eh(this,t,o)}updateBlockData(t,o,r){const i={...this.getBlockData(t),...o},{id:s,type:l,...a}=i;return xh(this,t,a,(r!=null?r:this.selection.range).toDocRange())}updateEmbedData(t,o,r){return U6(this,t,o,r)}updateBoxData(t){DD(this,t)}getSelectedText(){const t=Dh(this);return La(this,t)}clearSelectedContents(){Fg(this)}insertTextBlock(t,o,r,i){const s=sr(t!=null?t:"");return F6(this,s,o,r,i==null?void 0:i.newRange,i==null?void 0:i.insertBlockOptions)}updateCompositionText(t,o){if(t&&!o&&(this.selection.range.isCollapsed()||this.clearSelectedContents()),!t&&!o){O6(this);return}o?(this.compositingText="",Em()||Lg(this,t)):(this.compositingText=t,R6(this))}getColor(t){const o=this.options.colors;return o.length===0?"#FF1A75":o[t%o.length]}}function Ha(n,e,t){return new OD(n,e,t)}function _D(n){const e=(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=fm.default(s.states,r.states)}},t=[];return n.forEach(o=>{o.forEach(r=>{e(t,r)})}),t}const FD=["#FBBFBD","#FFDDB6","#FFF897","#C5F0C1","#CEDDFE","#DCC9FC","#E5E6E8","#F76964","#FFA53D","#FFE928","#63D156","#A0BBFE","#C4A5FB","#BBBFC3"];class Fh extends bt.TypedEmitter{constructor(t){super();m(this,"users",new Map);m(this,"cursors",new Map);m(this,"addingUser",!1);m(this,"colors");this.colors=t&&t.length>0?t:FD}setCursor(t){this.addUser(t.user);const o=this.cursors.get(t.user.userId);if(o&&ua.default(o,t))return;this.cursors.set(t.user.userId,t);const r=new Set([t.range.anchor.blockId,t.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(t){this.addingUser=!0,t.forEach(o=>this.addUser(o)),this.addingUser=!1,this.emit("change",Array.from(this.users.values()))}addUser(t){this.users.set(t.userId,t),this.addingUser||this.emit("change",Array.from(this.users.values()))}findUser(t){var o;return(o=this.users.get(t))!=null?o:null}removeUser(t){this.users.delete(t),this.cursors.delete(t),this.emit("change",Array.from(this.users.values()))}updateUsers(t){this.users.clear(),this.addingUser=!0;try{t.forEach(o=>{this.addUser(o)})}finally{this.addingUser=!1}setTimeout(()=>{this.emit("change",Array.from(this.users.values()))},300)}getSimpleCursors(t){const o=new Map;return Array.from(this.cursors.values()).filter(r=>r.range.anchor.blockId===t&&mh(r.range)).forEach(r=>{const i=r.range.focus.offset;let s=o.get(i);s||(s=[],o.set(i,s)),s.push(r)}),o}getCursors(t){return Array.from(this.cursors.values()).filter(o=>o.range.anchor.blockId===t||o.range.focus.blockId===t)}onUpdateBlockText(t,o,r){if(!t.text)return;this.getCursors(t.id).forEach(l=>{if(mh(l.range)){const{anchor:a,focus:d}=l.range;a.blockId===t.id&&(a.offset=ln.transformCursor(a.offset,o,r)),d.blockId===t.id&&(d.offset=ln.transformCursor(d.offset,o,r))}})}getFixedUserColor(t,o){let r=0;Array.from(t).forEach(s=>{r+=s.charCodeAt(0)});const i=r%this.colors.length;return this.colors[i]}destroy(){this.removeAllListeners()}}const Xt=S("local-doc");class np extends fa{constructor(t,o){super();m(this,"doc");m(this,"serviceUrl");t?this.doc=t:this.doc={meta:{},comments:{},blocks:{root:[sr("")]}},this.serviceUrl=(o==null?void 0:o.serverUrl)||""}beginBatchUpdate(){return 0}endBatchUpdate(){return 0}toJSON(){return me.default(this.doc)}getContainerBlocks(t){return this.doc.blocks[t]}getBlockData(t,o){const r=this.getContainerBlocks(t);g(Xt,r,`no container data: ${t}`);const i=r[o];return g(Xt,i,`no block data: ${o}`),i}localUpdateBlockText(t,o,r){const i=this.getBlockData(t,o);g(Xt,i.text,"no text for data");const s=ln.apply(i.text,r);return i.text=s,g(Xt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(l=>{var a;return(a=l.onUpdateBlockText)==null?void 0:a.call(l,t,o,r,!0)}),s}localUpdateBlockData(t,o,r){const i=this.getBlockData(t,o);return r.delete.forEach(s=>delete i[s]),Object.entries(r.insert).forEach(([s,l])=>{i[s]=l}),g(Xt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,t,o,r,!0)}),i}localInsertBlock(t,o,r){const i=this.getContainerBlocks(t);return g(Xt,i,`no container data: ${t}`),g(Xt,o>=0&&o<=i.length,`invalid block index: ${o}, ${i.length}`),i.splice(o,0,r),g(Xt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onInsertBlock)==null?void 0:l.call(s,t,o,r,!0)}),r}localDeleteBlock(t,o){const r=this.getContainerBlocks(t);g(Xt,r,`no container data: ${t}`),g(Xt,o>=0&&o<=r.length,`invalid block index: ${o}, ${r.length}`);const i=r[o];return r.splice(o,1),g(Xt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onDeleteBlock)==null?void 0:l.call(s,t,o,!0)}),i}localInsertChildContainer(t,o){this.doc.blocks[t]=o,g(Xt,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onInsertChildContainer)==null?void 0:i.call(r,t,o,!0)})}localDeleteChildContainers(t){Xt.debug(`delete child containers: ${t}`),t.forEach(o=>{g(Xt,this.doc.blocks[o],`no child container: ${o}`),delete this.doc.blocks[o]}),t.forEach(o=>{g(Xt,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(t,o){g(Xt,!1,"not implemented")}async addResources(t){return t}buildResourceUrl(t){return t}request(t,o){g(Xt,!1,"not implemented")}broadcastMessage(t){}getServerMeta(){return{serverId:this.serviceUrl}}getUser(){return{permission:"w",userId:"-",displayName:"-",avatarUrl:"-",rainbowIndex:0}}getRemoteUsers(){return new Fh}setDoc(t){this.doc=me.default(t),this.callbacks.forEach(o=>{var r;return(r=o.onRequestReload)==null?void 0:r.call(o,"change doc")})}destroy(){this.clearCallbacks()}}class PD{constructor(e){this.cleanup=e}destroy(){var e;(e=this.cleanup)==null||e.call(this)}}function op(n,e,t){n.addCustom(e,()=>{var i;const o=(i=t())!=null?i:void 0;return new PD(o)})}const ub=S("find-block");function db(n,e){const t=Ds(e);if(!t){if(ro(e))return null;const o=Is(e);return g(ub,o,"no parent block"),db(n,o)}return Le(n,t)?Vl(n,t,{visibleOnly:!0}):t}function hb(n,e){const t=Ss(e);if(!t){if(ro(e))return null;const o=Is(e);return g(ub,o,"no parent block"),hb(n,o)}return Le(n,t)?tg(n,t,{visibleOnly:!0}):t}const ND=S("remote-cursor");class $D{constructor(){m(this,"remoteUsers",new Fh)}onCustomMessage(e){const t=e;if(t.type==="onlineUsers"){const o=t;this.handleUpdateUsers(o.users)}else t.type==="caret"?this.handleUpdateCaret(t):ND.debug(`unknown remote message received: ${e}`)}handleUpdateUsers(e){this.remoteUsers.updateUsers(e)}handleUpdateCaret(e){const t=this.remoteUsers.findUser(e.userId);!t||this.remoteUsers.setCursor({oneseditor:"cursor",user:t,range:e.range,time:Date.now()})}destroy(){this.remoteUsers.destroy()}}function HD(n){const{blocks:e,meta:t,comments:o,...r}=n;return{rootBlocks:e,meta:t,comments:o,childBlocks:r}}function jD(n){const{blocks:e,meta:t,comments:o}=n,{root:r,...i}=e;return{blocks:r,meta:t,comments:o,...i}}function ja(n){const{childBlocks:e,meta:t,comments:o,rootBlocks:r}=HD(me.default(n));return{blocks:{root:r,...e},meta:t,comments:o}}function Ni(n){return n==="root"?"blocks":n}function Xl(n){return n==="blocks"?"root":n}const UD={type:{name:"rich-text",uri:"http://sharejs.org/types/rich-text/v1",create(n){return new on.default(n)},apply(n,e){const t=new on.default(n),o=new on.default(e);return t.compose(o).ops},compose(n,e){const t=new on.default(n),o=new on.default(e);return t.compose(o).ops},diff(n,e){const t=new on.default(n),o=new on.default(e);return t.diff(o).ops},transform(n,e,t){const o=new on.default(n);return new on.default(e).transform(o,t==="left").ops},transformCursor(n,e,t){return e.transformPosition(n,!t)},normalize(n){return n},serialize(n){return n.ops},deserialize(n){return n},transformPresence(n,e,t){if(!n)return null;const o=new on.default(e),r=this.transformCursor(n.index,o,t),i=this.transformCursor(n.index+n.length,o,t);return{...n,index:r,length:i-r}}}};var cr=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},$i={},rp=G5.default.EventEmitter;$i.EventEmitter=rp,$i.mixin=zD;function zD(n){for(var e in rp.prototype)n.prototype[e]=rp.prototype[e]}var fb=["info","warn","error"];function mb(){var n={};fb.forEach(function(e){n[e]=console[e].bind(console)}),this.setMethods(n)}var VD=mb;mb.prototype.setMethods=function(n){n=n||{};var e=this;fb.forEach(function(t){typeof n[t]=="function"&&(e[t]=n[t])})};var WD=VD,qD=new WD,gb=qD;function js(n,e){this.code=n,this.message=e||"",Error.captureStackTrace?Error.captureStackTrace(this,js):this.stack=new Error().stack}js.prototype=Object.create(Error.prototype),js.prototype.constructor=js,js.prototype.name="ShareDBError",js.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 Ph=js,Ua={},pb=GD;function GD(n,e,t,o){var r=function(s,l,a,d){e(a,s,l,"left"),e(d,l,s,"right")},i=n.transformX=function(s,l){t(s),t(l);for(var a=[],d=0;d<l.length;d++){for(var h=l[d],p=[],A=0;A<s.length;){var v=[];if(r(s[A],h,p,v),A++,v.length===1)h=v[0];else if(v.length===0){for(var B=A;B<s.length;B++)o(p,s[B]);h=null;break}else{for(var D=i(s.slice(A),v),I=0;I<D[0].length;I++)o(p,D[0][I]);for(var _=0;_<D[1].length;_++)o(a,D[1][_]);h=null;break}}h!=null&&o(a,h),s=p}return[s,a]};n.transform=function(s,l,a){if(!(a==="left"||a==="right"))throw new Error("type must be 'left' or 'right'");return l.length===0?s:s.length===1&&l.length===1?e([],s[0],l[0],a):a==="left"?i(s,l)[0]:i(l,s)[1]}}var Cb={exports:{}},Hi=Cb.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||""}},ip=function(n,e,t){return n.slice(0,e)+t+n.slice(e)},sp=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")},Nh=function(n){for(var e=0;e<n.length;e++)sp(n[e])};Hi.apply=function(n,e){var t;Nh(e);for(var o=0;o<e.length;o++){var r=e[o];if(r.i!=null)n=ip(n,r.p,r.i);else{if(t=n.slice(r.p,r.p+r.d.length),r.d!==t)throw new Error("Delete component '"+r.d+"' does not match deleted text '"+t+"'");n=n.slice(0,r.p)+n.slice(r.p+r.d.length)}}return n};var Wr=Hi._append=function(n,e){if(!(e.i===""||e.d===""))if(n.length===0)n.push(e);else{var t=n[n.length-1];t.i!=null&&e.i!=null&&t.p<=e.p&&e.p<=t.p+t.i.length?n[n.length-1]={i:ip(t.i,e.p-t.p,e.i),p:t.p}:t.d!=null&&e.d!=null&&e.p<=t.p&&t.p<=e.p+e.d.length?n[n.length-1]={d:ip(e.d,t.p-e.p,t.d),p:e.p}:n.push(e)}};Hi.compose=function(n,e){Nh(n),Nh(e);for(var t=n.slice(),o=0;o<e.length;o++)Wr(t,e[o]);return t},Hi.normalize=function(n){var e=[];(n.i!=null||n.p!=null)&&(n=[n]);for(var t=0;t<n.length;t++){var o=n[t];o.p==null&&(o.p=0),Wr(e,o)}return e};var lp=function(n,e,t){return e.i!=null?e.p<n||e.p===n&&t?n+e.i.length:n:n<=e.p?n:n<=e.p+e.d.length?e.p:n-e.d.length};Hi.transformCursor=function(n,e,t){for(var o=t==="right",r=0;r<e.length;r++)n=lp(n,e[r],o);return n};var ZD=Hi._tc=function(n,e,t,o){if(sp(e),sp(t),e.i!=null)Wr(n,{i:e.i,p:lp(e.p,t,o==="right")});else if(t.i!=null){var r=e.d;e.p<t.p&&(Wr(n,{d:r.slice(0,t.p-e.p),p:e.p}),r=r.slice(t.p-e.p)),r!==""&&Wr(n,{d:r,p:e.p+t.i.length})}else if(e.p>=t.p+t.d.length)Wr(n,{d:e.d,p:e.p-t.d.length});else if(e.p+e.d.length<=t.p)Wr(n,e);else{var i={d:"",p:e.p};e.p<t.p&&(i.d=e.d.slice(0,t.p-e.p)),e.p+e.d.length>t.p+t.d.length&&(i.d+=e.d.slice(t.p+t.d.length-e.p));var s=Math.max(e.p,t.p),l=Math.min(e.p+e.d.length,t.p+t.d.length),a=e.d.slice(s-e.p,l-e.p),d=t.d.slice(s-t.p,l-t.p);if(a!==d)throw new Error("Delete ops delete different text in the same region of the document");i.d!==""&&(i.p=lp(i.p,t),Wr(n,i))}return n},QD=function(n){return n.i!=null?{d:n.i,p:n.p}:{i:n.d,p:n.p}};Hi.invert=function(n){n=n.slice().reverse();for(var e=0;e<n.length;e++)n[e]=QD(n[e]);return n},pb(Hi,ZD,Nh,Wr);var $h=function(n){return Object.prototype.toString.call(n)=="[object Array]"},YD=function(n){return!!n&&n.constructor===Object},_o=function(n){return JSON.parse(JSON.stringify(n))},Ie={name:"json0",uri:"http://sharejs.org/types/JSONv0"},qr={};Ie.registerSubtype=function(n){qr[n.name]=n},Ie.create=function(n){return n===void 0?null:_o(n)},Ie.invertComponent=function(n){var e={p:n.p};return n.t&&qr[n.t]&&(e.t=n.t,e.o=qr[n.t].invert(n.o)),n.si!==void 0&&(e.sd=n.si),n.sd!==void 0&&(e.si=n.sd),n.oi!==void 0&&(e.od=n.oi),n.od!==void 0&&(e.oi=n.od),n.li!==void 0&&(e.ld=n.li),n.ld!==void 0&&(e.li=n.ld),n.na!==void 0&&(e.na=-n.na),n.lm!==void 0&&(e.lm=n.p[n.p.length-1],e.p=n.p.slice(0,n.p.length-1).concat([n.lm])),e},Ie.invert=function(n){for(var e=n.slice().reverse(),t=[],o=0;o<e.length;o++)t.push(Ie.invertComponent(e[o]));return t},Ie.checkValidOp=function(n){for(var e=0;e<n.length;e++)if(!$h(n[e].p))throw new Error("Missing path")},Ie.checkList=function(n){if(!$h(n))throw new Error("Referenced element not a list")},Ie.checkObj=function(n){if(!YD(n))throw new Error("Referenced element not an object (it was "+JSON.stringify(n)+")")};function za(n){n.t="text0";var e={p:n.p.pop()};n.si!=null&&(e.i=n.si),n.sd!=null&&(e.d=n.sd),n.o=[e]}function Va(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}Ie.apply=function(n,e){Ie.checkValidOp(e),e=_o(e);for(var t={data:n},o=0;o<e.length;o++){var r=e[o];(r.si!=null||r.sd!=null)&&za(r);for(var i=null,s=t,l="data",a=0;a<r.p.length;a++){var d=r.p[a];if(i=s,s=s[l],l=d,i==null)throw new Error("Path invalid")}if(r.t&&r.o!==void 0&&qr[r.t])s[l]=qr[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)Ie.checkList(s),s[l]=r.li;else if(r.li!==void 0)Ie.checkList(s),s.splice(l,0,r.li);else if(r.ld!==void 0)Ie.checkList(s),s.splice(l,1);else if(r.lm!==void 0){if(Ie.checkList(s),r.lm!=l){var h=s[l];s.splice(l,1),s.splice(r.lm,0,h)}}else if(r.oi!==void 0)Ie.checkObj(s),s[l]=r.oi;else if(r.od!==void 0)Ie.checkObj(s),delete s[l];else throw new Error("invalid / missing instruction in op")}return t.data},Ie.shatter=function(n){for(var e=[],t=0;t<n.length;t++)e.push([n[t]]);return e},Ie.incrementalApply=function(n,e,t){for(var o=0;o<e.length;o++){var r=[e[o]];n=Ie.apply(n,r),t(r,n)}return n};var JD=Ie.pathMatches=function(n,e,t){if(n.length!=e.length)return!1;for(var o=0;o<n.length;o++)if(n[o]!==e[o]&&(!t||o!==n.length-1))return!1;return!0};Ie.append=function(n,e){if(e=_o(e),n.length===0){n.push(e);return}var t=n[n.length-1];if((e.si!=null||e.sd!=null)&&(t.si!=null||t.sd!=null)&&(za(e),za(t)),JD(e.p,t.p))if(e.t&&t.t&&e.t===t.t&&qr[e.t]){if(t.o=qr[e.t].compose(t.o,e.o),e.si!=null||e.sd!=null){for(var o=e.p,r=0;r<t.o.length-1;r++)e.o=[t.o.pop()],e.p=o.slice(),Va(e),n.push(e);Va(t)}}else t.na!=null&&e.na!=null?n[n.length-1]={p:t.p,na:t.na+e.na}:t.li!==void 0&&e.li===void 0&&e.ld===t.li?t.ld!==void 0?delete t.li:n.pop():t.od!==void 0&&t.oi===void 0&&e.oi!==void 0&&e.od===void 0?t.oi=e.oi:t.oi!==void 0&&e.od!==void 0?e.oi!==void 0?t.oi=e.oi:t.od!==void 0?delete t.oi:n.pop():e.lm!==void 0&&e.p[e.p.length-1]===e.lm||n.push(e);else(e.si!=null||e.sd!=null)&&(t.si!=null||t.sd!=null)&&(Va(e),Va(t)),n.push(e)},Ie.compose=function(n,e){Ie.checkValidOp(n),Ie.checkValidOp(e);for(var t=_o(n),o=0;o<e.length;o++)Ie.append(t,e[o]);return t},Ie.normalize=function(n){var e=[];n=$h(n)?n:[n];for(var t=0;t<n.length;t++){var o=n[t];o.p==null&&(o.p=[]),Ie.append(e,o)}return e},Ie.commonLengthForOps=function(n,e){var t=n.p.length,o=e.p.length;if((n.na!=null||n.t)&&t++,(e.na!=null||e.t)&&o++,t===0)return-1;if(o===0)return null;t--,o--;for(var r=0;r<t;r++){var i=n.p[r];if(r>=o||i!==e.p[r])return null}return t},Ie.canOpAffectPath=function(n,e){return Ie.commonLengthForOps({p:e},n)!=null},Ie.transformComponent=function(n,e,t,o){e=_o(e);var r=Ie.commonLengthForOps(t,e),i=Ie.commonLengthForOps(e,t),s=e.p.length,l=t.p.length;if((e.na!=null||e.t)&&s++,(t.na!=null||t.t)&&l++,i!=null&&l>s&&e.p[i]==t.p[i]){if(e.ld!==void 0){var a=_o(t);a.p=a.p.slice(s),e.ld=Ie.apply(_o(e.ld),[a])}else if(e.od!==void 0){var a=_o(t);a.p=a.p.slice(s),e.od=Ie.apply(_o(e.od),[a])}}if(r!=null){var d=s==l,a=t;if((e.si!=null||e.sd!=null)&&(t.si!=null||t.sd!=null)&&(za(e),a=_o(t),za(a)),a.t&&qr[a.t]){if(e.t&&e.t===a.t){var h=qr[e.t].transform(e.o,a.o,o);if(e.si!=null||e.sd!=null)for(var p=e.p,A=0;A<h.length;A++)e.o=[h[A]],e.p=p.slice(),Va(e),Ie.append(n,e);else(!$h(h)||h.length>0)&&(e.o=h,Ie.append(n,e));return n}}else if(t.na===void 0){if(t.li!==void 0&&t.ld!==void 0){if(t.p[r]===e.p[r])if(d){if(e.ld!==void 0)if(e.li!==void 0&&o==="left")e.ld=_o(t.li);else return n}else return n}else if(t.li!==void 0)e.li!==void 0&&e.ld===void 0&&d&&e.p[r]===t.p[r]?o==="right"&&e.p[r]++:t.p[r]<=e.p[r]&&e.p[r]++,e.lm!==void 0&&d&&t.p[r]<=e.lm&&e.lm++;else if(t.ld!==void 0){if(e.lm!==void 0&&d){if(t.p[r]===e.p[r])return n;var p=t.p[r],v=e.p[r],B=e.lm;(p<B||p===B&&v<B)&&e.lm--}if(t.p[r]<e.p[r])e.p[r]--;else if(t.p[r]===e.p[r]){if(l<s)return n;if(e.ld!==void 0)if(e.li!==void 0)delete e.ld;else return n}}else if(t.lm!==void 0)if(e.lm!==void 0&&s===l){var v=e.p[r],B=e.lm,D=t.p[r],I=t.lm;if(D!==I)if(v===D)if(o==="left")e.p[r]=I,v===B&&(e.lm=I);else return n;else v>D&&e.p[r]--,v>I?e.p[r]++:v===I&&D>I&&(e.p[r]++,v===B&&e.lm++),(B>D||B===D&&B>v)&&e.lm--,B>I?e.lm++:B===I&&(I>D&&B>v||I<D&&B<v?o==="right"&&e.lm++:B>v?e.lm++:B===D&&e.lm--)}else if(e.li!==void 0&&e.ld===void 0&&d){var v=t.p[r],B=t.lm;p=e.p[r],p>v&&e.p[r]--,p>B&&e.p[r]++}else{var v=t.p[r],B=t.lm;p=e.p[r],p===v?e.p[r]=B:(p>v&&e.p[r]--,(p>B||p===B&&v>B)&&e.p[r]++)}else if(t.oi!==void 0&&t.od!==void 0){if(e.p[r]===t.p[r])if(e.oi!==void 0&&d){if(o==="right")return n;e.od=t.oi}else return n}else if(t.oi!==void 0){if(e.oi!==void 0&&e.p[r]===t.p[r])if(o==="left")Ie.append(n,{p:e.p,od:t.oi});else return n}else if(t.od!==void 0&&e.p[r]==t.p[r]){if(!d)return n;if(e.oi!==void 0)delete e.od;else return n}}}return Ie.append(n,e),n},pb(Ie,Ie.transformComponent,Ie.checkValidOp,Ie.append);var KD=Cb.exports;Ie.registerSubtype(KD);var XD=Ie,eS={type:XD};(function(n){n.defaultType=eS.type,n.map={},n.register=function(e){e.name&&(n.map[e.name]=e),e.uri&&(n.map[e.uri]=e)},n.register(n.defaultType)})(Ua);var Fo={};(function(n){n.doNothing=e;function e(){}n.hasKeys=function(t){for(var o in t)return!0;return!1},n.isInteger=Number.isInteger||function(t){return typeof t=="number"&&isFinite(t)&&Math.floor(t)===t},n.isValidVersion=function(t){return t===null?!0:n.isInteger(t)&&t>=0},n.isValidTimestamp=function(t){return n.isValidVersion(t)},n.MAX_SAFE_INTEGER=9007199254740991,n.dig=function(){for(var t=arguments[0],o=1;o<arguments.length;o++){var r=arguments[o];t=t[r]||(o===arguments.length-1?void 0:{})}return t},n.digOrCreate=function(){for(var t=arguments[0],o=arguments[arguments.length-1],r=1;r<arguments.length-1;r++){var i=arguments[r];t=t[i]||(t[i]=r===arguments.length-2?o():{})}return t},n.digAndRemove=function(){for(var t=arguments[0],o=[t],r=1;r<arguments.length-1;r++){var i=arguments[r];if(!t.hasOwnProperty(i))break;t=t[i],o.push(t)}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(t){return t&&typeof t.transformPresence=="function"},n.callEach=function(t,o){var r=!1;return t.forEach(function(i){i&&(i(o),r=!0)}),r},n.truthy=function(t){return!!t},n.nextTick=function(t){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(){t.apply(null,o)})},n.clone=function(t){return t===void 0?void 0:JSON.parse(JSON.stringify(t))}})(Fo);var Ab=Array.isArray,bb=Object.keys,tS=Object.prototype.hasOwnProperty,nS=function n(e,t){if(e===t)return!0;if(e&&t&&typeof e=="object"&&typeof t=="object"){var o=Ab(e),r=Ab(t),i,s,l;if(o&&r){if(s=e.length,s!=t.length)return!1;for(i=s;i--!==0;)if(!n(e[i],t[i]))return!1;return!0}if(o!=r)return!1;var a=e instanceof Date,d=t instanceof Date;if(a!=d)return!1;if(a&&d)return e.getTime()==t.getTime();var h=e instanceof RegExp,p=t instanceof RegExp;if(h!=p)return!1;if(h&&p)return e.toString()==t.toString();var A=bb(e);if(s=A.length,s!==bb(t).length)return!1;for(i=s;i--!==0;)if(!tS.call(t,A[i]))return!1;for(i=s;i--!==0;)if(l=A[i],!n(e[l],t[l]))return!1;return!0}return e!==e&&t!==t},vb=$i,oS=gb,Wn=Ph,Hh=Ua,Po=Fo,rS=Po.clone,iS=nS,Tn=Wn.CODES,sS=Fe;function Fe(n,e,t){vb.EventEmitter.call(this),this.connection=n,this.collection=e,this.id=t,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}vb.mixin(Fe),Fe.prototype.destroy=function(n){this._wantsDestroy=!0;var e=this;e.whenNothingPending(function(){e.wantSubscribe?e.unsubscribe(function(t){if(t)return n?n(t):e.emit("error",t);e.connection._destroyDoc(e),n&&n()}):(e.connection._destroyDoc(e),n&&n())})},Fe.prototype._setType=function(n){if(typeof n=="string"&&(n=Hh.map[n]),n)this.type=n;else if(n===null)this.type=n,this._setData(void 0);else{var e=new Wn(Tn.ERR_DOC_TYPE_NOT_RECOGNIZED,"Missing type "+n);return this.emit("error",e)}},Fe.prototype._setData=function(n){this.data=n,this._dataStateVersion++},Fe.prototype.ingestSnapshot=function(n,e){if(!n)return e&&e();if(typeof n.v!="number"){var t=new Wn(Tn.ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION,"Missing version in ingested snapshot. "+this.collection+"."+this.id);return e?e(t):this.emit("error",t)}if(this.type||this.hasWritePending()){if(this.version==null){if(this.hasWritePending())return e&&this.once("no write pending",e);var t=new Wn(Tn.ERR_DOC_MISSING_VERSION,"Cannot ingest snapshot in doc with null version. "+this.collection+"."+this.id);return e?e(t):this.emit("error",t)}return n.v>this.version?this.fetch(e):e&&e()}if(this.version>n.v)return e&&e();this.version=n.v;var o=n.type===void 0?Hh.defaultType:n.type;this._setType(o),this._setData(this.type&&this.type.deserialize?this.type.deserialize(n.data):n.data),this.emit("load"),e&&e()},Fe.prototype.whenNothingPending=function(n){var e=this;Po.nextTick(function(){if(e.hasPending()){e.once("nothing pending",n);return}n()})},Fe.prototype.hasPending=function(){return!!(this.inflightOp||this.pendingOps.length||this.inflightFetch.length||this.inflightSubscribe||this.pendingFetch.length||this.pendingSubscribe.length)},Fe.prototype.hasWritePending=function(){return!!(this.inflightOp||this.pendingOps.length)},Fe.prototype._emitNothingPending=function(){this.hasWritePending()||(this.emit("no write pending"),!this.hasPending()&&this.emit("nothing pending"))},Fe.prototype._emitResponseError=function(n,e){if(n&&n.code===Tn.ERR_SNAPSHOT_READ_SILENT_REJECTION){this.wantSubscribe=!1,e&&e(),this._emitNothingPending();return}if(e){e(n),this._emitNothingPending();return}this._emitNothingPending(),this.emit("error",n)},Fe.prototype._handleFetch=function(n,e){var t=this.pendingFetch;this.pendingFetch=[];var o=this.inflightFetch.shift();if(o&&t.push(o),t.length&&(o=function(r){Po.callEach(t,r)}),n)return this._emitResponseError(n,o);this.ingestSnapshot(e,o),this._emitNothingPending()},Fe.prototype._handleSubscribe=function(n,e){var t=this.inflightSubscribe;this.inflightSubscribe=null;var o=this.pendingFetch;this.pendingFetch=[],t.callback&&o.push(t.callback);var r;if(o.length&&(r=function(i){Po.callEach(o,i)}),n)return this._emitResponseError(n,r);this.subscribed=t.wantSubscribe,this.subscribed?this.ingestSnapshot(e,r):r&&r(),this._emitNothingPending(),this._flushSubscribe()},Fe.prototype._handleOp=function(n,e){if(n)return this.inflightOp?(n.code===Tn.ERR_OP_SUBMIT_REJECTED&&(n=null),this._rollback(n)):this.emit("error",n);if(this.inflightOp&&e.src===this.inflightOp.src&&e.seq===this.inflightOp.seq){this._opAcknowledged(e);return}if(this.version==null||e.v>this.version){this.fetch();return}if(!(e.v<this.version)){if(this.inflightOp){var t=jh(this.inflightOp,e);if(t)return this._hardRollback(t)}for(var o=0;o<this.pendingOps.length;o++){var t=jh(this.pendingOps[o],e);if(t)return this._hardRollback(t)}this.version++;try{this._otApply(e,!1)}catch(r){return this._hardRollback(r)}}},Fe.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))},Fe.prototype._resubscribe=function(){if(!this.pendingSubscribe.length&&this.wantSubscribe)return this.subscribe();var n=this.pendingSubscribe.some(function(e){return e.wantSubscribe});!n&&this.pendingFetch.length&&this.fetch(),this._flushSubscribe()},Fe.prototype.fetch=function(n){if(this.connection.canSend){var e=this.connection.sendFetch(this);lS(this.inflightFetch,e,n);return}this.pendingFetch.push(n)},Fe.prototype.subscribe=function(n){var e=!0;this._queueSubscribe(e,n)},Fe.prototype.unsubscribe=function(n){var e=!1;this._queueSubscribe(e,n)},Fe.prototype._queueSubscribe=function(n,e){var t=this.pendingSubscribe[this.pendingSubscribe.length-1]||this.inflightSubscribe,o=t&&t.wantSubscribe===n;if(o){t.callback=cS([t.callback,e]);return}this.pendingSubscribe.push({wantSubscribe:!!n,callback:e}),this._flushSubscribe()},Fe.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;Po.nextTick(function(){n._handleSubscribe()})}}};function lS(n,e,t){if(e){var o=n.pop();n.push(function(r){o&&o(r),t&&t(r)})}else n.push(t)}function cS(n){return n=n.filter(Po.truthy),n.length?function(e){Po.callEach(n,e)}:null}Fe.prototype.flush=function(){!this.connection.canSend||this.inflightOp||!this.paused&&this.pendingOps.length&&this._sendOp()};function aS(n){delete n.op,delete n.create,delete n.del}function jh(n,e){if(n.del)return aS(e);if(e.del)return new Wn(Tn.ERR_DOC_WAS_DELETED,"Document was deleted");if(e.create)return new Wn(Tn.ERR_DOC_ALREADY_CREATED,"Document already created");if("op"in e){if(n.create)return new Wn(Tn.ERR_DOC_ALREADY_CREATED,"Document already created");if(n.type.transformX){var t=n.type.transformX(n.op,e.op);n.op=t[0],e.op=t[1]}else{var o=n.type.transform(n.op,e.op,"left"),r=n.type.transform(e.op,n.op,"right");n.op=o,e.op=r}}}Fe.prototype._otApply=function(n,e){if("op"in n){if(!this.type)throw new Wn(Tn.ERR_DOC_DOES_NOT_EXIST,"Cannot apply op to uncreated document. "+this.collection+"."+this.id);if(this.emit("before op batch",n.op,e),!e&&this.type===Hh.defaultType&&n.op.length>1){this.applyStack||(this.applyStack=[]);for(var t=this.applyStack.length,o=0;o<n.op.length;o++){var r=n.op[o],i={op:[r]};this.emit("before op",i.op,e,n.src);for(var s=t;s<this.applyStack.length;s++){var l=jh(this.applyStack[s],i);if(l)return this._hardRollback(l)}this._setData(this.type.apply(this.data,i.op)),this.emit("op",i.op,e,n.src)}this.emit("op batch",n.op,e),this._popApplyStack(t);return}this.emit("before op",n.op,e,n.src),this._setData(this.type.apply(this.data,n.op)),this.emit("op",n.op,e,n.src),this.emit("op batch",n.op,e);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",e);return}if(n.del){var a=this.data;this._setType(null),this.emit("del",a,e);return}},Fe.prototype._sendOp=function(){if(!!this.connection.canSend){var n=this.connection.id;this.inflightOp||(this.inflightOp=this.pendingOps.shift());var e=this.inflightOp;if(!e){var t=new Wn(Tn.ERR_INFLIGHT_OP_MISSING,"No op to send on call to _sendOp");return this.emit("error",t)}if(e.sentAt=Date.now(),e.retries=e.retries==null?0:e.retries+1,e.seq==null){if(this.connection.seq>=Po.MAX_SAFE_INTEGER)return this.emit("error",new Wn(Tn.ERR_CONNECTION_SEQ_INTEGER_OVERFLOW,"Connection seq has exceeded the max safe integer, maybe from being open for too long"));e.seq=this.connection.seq++}this.connection.sendOp(this,e),e.src==null&&(e.src=n)}},Fe.prototype._submit=function(n,e,t){if(e||(e=!0),"op"in n){if(!this.type){var o=new Wn(Tn.ERR_DOC_DOES_NOT_EXIST,"Cannot submit op. Document has not been created. "+this.collection+"."+this.id);return t?t(o):this.emit("error",o)}this.type.normalize&&(n.op=this.type.normalize(n.op))}try{this._pushOp(n,e,t),this._otApply(n,e)}catch(i){return this._hardRollback(i)}var r=this;Po.nextTick(function(){r.flush()})},Fe.prototype._pushOp=function(n,e,t){if(n.source=e,this.applyStack)this.applyStack.push(n);else{var o=this._tryCompose(n);if(o){o.callbacks.push(t);return}}n.type=this.type,n.callbacks=[t],this.pendingOps.push(n)},Fe.prototype._popApplyStack=function(n){if(n>0){this.applyStack.length=n;return}var e=this.applyStack[0];if(this.applyStack=null,!!e){var t=this.pendingOps.indexOf(e);if(t!==-1)for(var o=this.pendingOps.splice(t),t=0;t<o.length;t++){var e=o[t],r=this._tryCompose(e);r?r.callbacks=r.callbacks.concat(e.callbacks):this.pendingOps.push(e)}}},Fe.prototype._tryCompose=function(n){if(!this.preventCompose){var e=this.pendingOps[this.pendingOps.length-1];if(!(!e||e.sentAt)&&!(this.submitSource&&!iS(n.source,e.source))){if(e.create&&"op"in n)return e.create.data=this.type.apply(e.create.data,n.op),e;if("op"in e&&"op"in n&&this.type.compose)return e.op=this.type.compose(e.op,n.op),e}}},Fe.prototype.submitOp=function(n,e,t){typeof e=="function"&&(t=e,e=null);var o={op:n},r=e&&e.source;this._submit(o,r,t)},Fe.prototype.create=function(n,e,t,o){if(typeof e=="function"?(o=e,t=null,e=null):typeof t=="function"&&(o=t,t=null),e||(e=Hh.defaultType.uri),this.type){var r=new Wn(Tn.ERR_DOC_ALREADY_CREATED,"Document already exists");return o?o(r):this.emit("error",r)}var i={create:{type:e,data:n}},s=t&&t.source;this._submit(i,s,o)},Fe.prototype.del=function(n,e){if(typeof n=="function"&&(e=n,n=null),!this.type){var t=new Wn(Tn.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");return e?e(t):this.emit("error",t)}var o={del:!0},r=n&&n.source;this._submit(o,r,e)},Fe.prototype.pause=function(){this.paused=!0},Fe.prototype.resume=function(){this.paused=!1,this.flush()},Fe.prototype.toSnapshot=function(){return{v:this.version,data:rS(this.data),type:this.type.uri}},Fe.prototype._opAcknowledged=function(n){if(this.inflightOp.create)this.version=n.v;else if(n.v!==this.version)return oS.warn("Invalid version from server. Expected: "+this.version+" Received: "+n.v,n),this.fetch();this.version++,this._clearInflightOp()},Fe.prototype._rollback=function(n){var e=this.inflightOp;if("op"in e&&e.type.invert){try{e.op=e.type.invert(e.op)}catch{return this._hardRollback(n)}for(var t=0;t<this.pendingOps.length;t++){var o=jh(this.pendingOps[t],e);if(o)return this._hardRollback(o)}try{this._otApply(e,!1)}catch(r){return this._hardRollback(r)}this._clearInflightOp(n);return}this._hardRollback(n)},Fe.prototype._hardRollback=function(n){var e=[];this.inflightOp&&e.push(this.inflightOp),e=e.concat(this.pendingOps),this._setType(null),this.version=null,this.inflightOp=null,this.pendingOps=[];var t=this;this.fetch(function(){for(var o=!!e.length,r=0;r<e.length;r++)o=Po.callEach(e[r].callbacks,n)&&o;if(n&&!o)return t.emit("error",n)})},Fe.prototype._clearInflightOp=function(n){var e=this.inflightOp;this.inflightOp=null;var t=Po.callEach(e.callbacks,n);if(this.flush(),this._emitNothingPending(),n&&!t)return this.emit("error",n)};var Us={};Us.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 yb=$i,kb=Us.ACTIONS,uS=Fo,dS=Dn;function Dn(n,e,t,o,r,i,s){yb.EventEmitter.call(this),this.action=n,this.connection=e,this.id=t,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}yb.mixin(Dn),Dn.prototype.hasPending=function(){return!this.ready},Dn.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 e=[],t=0;t<this.results.length;t++){var o=this.results[t];e.push([o.id,o.version])}n.r=e}this.connection.send(n),this.sent=!0}},Dn.prototype.destroy=function(n){this.connection.canSend&&this.action===kb.querySubscribe&&this.connection.send({a:kb.queryUnsubscribe,id:this.id}),this.connection._destroyQuery(this),n&&uS.nextTick(n)},Dn.prototype._onConnectionStateChanged=function(){this.connection.canSend&&!this.sent?this.send():this.sent=!1},Dn.prototype._handleFetch=function(n,e,t){this.connection._destroyQuery(this),this._handleResponse(n,e,t)},Dn.prototype._handleSubscribe=function(n,e,t){this._handleResponse(n,e,t)},Dn.prototype._handleResponse=function(n,e,t){var o=this.callback;if(this.callback=null,n)return this._finishResponse(n,o);if(!e)return this._finishResponse(null,o);var r=this,i=1,s=function(h){if(h)return r._finishResponse(h,o);--i||r._finishResponse(null,o)};if(Array.isArray(e))i+=e.length,this.results=this._ingestSnapshots(e,s),this.extra=t;else for(var l in e){i++;var a=e[l],d=this.connection.get(a.c||this.collection,l);d.ingestSnapshot(a,s)}s()},Dn.prototype._ingestSnapshots=function(n,e){for(var t=[],o=0;o<n.length;o++){var r=n[o],i=this.connection.get(r.c||this.collection,r.d);i.ingestSnapshot(r,e),t.push(i)}return t},Dn.prototype._finishResponse=function(n,e){if(this.emit("ready"),this.ready=!0,n)return this.connection._destroyQuery(this),e?e(n):this.emit("error",n);e&&e(null,this.results,this.extra)},Dn.prototype._handleError=function(n){this.emit("error",n)},Dn.prototype._handleDiff=function(n){for(var e=0;e<n.length;e++){var t=n[e];t.type==="insert"&&(t.values=this._ingestSnapshots(t.values))}for(var e=0;e<n.length;e++){var t=n[e];switch(t.type){case"insert":var o=t.values;Array.prototype.splice.apply(this.results,[t.index,0].concat(o)),this.emit("insert",o,t.index);break;case"remove":var i=t.howMany||1,r=this.results.splice(t.index,i);this.emit("remove",r,t.index);break;case"move":var i=t.howMany||1,s=this.results.splice(t.from,i);Array.prototype.splice.apply(this.results,[t.to,0].concat(s)),this.emit("move",s,t.from,t.to);break}}this.emit("changed",this.results)},Dn.prototype._handleExtra=function(n){this.extra=n,this.emit("extra",n)};var wb=$i,hS=Us.ACTIONS,fS=Fo,Bb=ar;function ar(n,e){if(wb.EventEmitter.call(this),!e||typeof e!="string")throw new Error("LocalPresence presenceId must be a string");this.presence=n,this.presenceId=e,this.connection=n.connection,this.presenceVersion=0,this.value=null,this._pendingMessages=[],this._callbacksByPresenceVersion={}}wb.mixin(ar),ar.prototype.submit=function(n,e){this.value=n,this.send(e)},ar.prototype.send=function(n){var e=this._message();this._pendingMessages.push(e),this._callbacksByPresenceVersion[e.pv]=n,this._sendPending()},ar.prototype.destroy=function(n){var e=this;this.submit(null,function(t){if(t)return e._callbackOrEmit(t,n);delete e.presence.localPresences[e.presenceId],n&&n()})},ar.prototype._sendPending=function(){if(!!this.connection.canSend){var n=this;this._pendingMessages.forEach(function(e){n.connection.send(e)}),this._pendingMessages=[]}},ar.prototype._ack=function(n,e){var t=this._getCallback(e);this._callbackOrEmit(n,t)},ar.prototype._message=function(){return{a:hS.presence,ch:this.presence.channel,id:this.presenceId,p:this.value,pv:this.presenceVersion++}},ar.prototype._getCallback=function(n){var e=this._callbacksByPresenceVersion[n];return delete this._callbacksByPresenceVersion[n],e},ar.prototype._callbackOrEmit=function(n,e){if(e)return fS.nextTick(e,n);n&&this.emit("error",n)};var mS=Fo,Eb=cp;function cp(n,e){this.presence=n,this.presenceId=e,this.connection=this.presence.connection,this.value=null,this.presenceVersion=0}cp.prototype.receiveUpdate=function(n){n.pv<this.presenceVersion||(this.value=n.p,this.presenceVersion=n.pv,this.presence._updateRemotePresence(this))},cp.prototype.destroy=function(n){delete this.presence._remotePresenceInstances[this.presenceId],delete this.presence.remotePresences[this.presenceId],n&&mS.nextTick(n)};var ap={exports:{}};(function(n,e){(function(t,o){o(e)})(cr,function(t){function o(k,T){T=T|0;for(var L=Math.max(k.length-T,0),F=Array(L),U=0;U<L;U++)F[U]=k[T+U];return F}var r=function(k){var T=o(arguments,1);return function(){var L=o(arguments);return k.apply(null,T.concat(L))}},i=function(k){return function(){var T=o(arguments),L=T.pop();k.call(this,T,L)}};function s(k){var T=typeof k;return k!=null&&(T=="object"||T=="function")}var l=typeof setImmediate=="function"&&setImmediate,a=typeof process=="object"&&typeof process.nextTick=="function";function d(k){setTimeout(k,0)}function h(k){return function(T){var L=o(arguments,1);k(function(){T.apply(null,L)})}}var p;l?p=setImmediate:a?p=process.nextTick:p=d;var A=h(p);function v(k){return i(function(T,L){var F;try{F=k.apply(this,T)}catch(U){return L(U)}s(F)&&typeof F.then=="function"?F.then(function(U){B(L,null,U)},function(U){B(L,U.message?U:new Error(U))}):L(null,F)})}function B(k,T,L){try{k(T,L)}catch(F){A(D,F)}}function D(k){throw k}var I=typeof Symbol=="function";function _(k){return I&&k[Symbol.toStringTag]==="AsyncFunction"}function M(k){return _(k)?v(k):k}function H(k){return function(T){var L=o(arguments,1),F=i(function(U,j){var Z=this;return k(T,function(J,le){M(J).apply(Z,U.concat(le))},j)});return L.length?F.apply(this,L):F}}var z=typeof cr=="object"&&cr&&cr.Object===Object&&cr,q=typeof self=="object"&&self&&self.Object===Object&&self,re=z||q||Function("return this")(),fe=re.Symbol,Be=Object.prototype,je=Be.hasOwnProperty,Ue=Be.toString,tt=fe?fe.toStringTag:void 0;function Yt(k){var T=je.call(k,tt),L=k[tt];try{k[tt]=void 0;var F=!0}catch{}var U=Ue.call(k);return F&&(T?k[tt]=L:delete k[tt]),U}var Wo=Object.prototype,Nt=Wo.toString;function Ln(k){return Nt.call(k)}var yr="[object Null]",bn="[object Undefined]",an=fe?fe.toStringTag:void 0;function kr(k){return k==null?k===void 0?bn:yr:an&&an in Object(k)?Yt(k):Ln(k)}var ti="[object AsyncFunction]",mo="[object Function]",X2="[object GeneratorFunction]",e3="[object Proxy]";function t3(k){if(!s(k))return!1;var T=kr(k);return T==mo||T==X2||T==ti||T==e3}var ns=9007199254740991;function ol(k){return typeof k=="number"&&k>-1&&k%1==0&&k<=ns}function rl(k){return k!=null&&ol(k.length)&&!t3(k)}var ni={};function Ne(){}function wr(k){return function(){if(k!==null){var T=k;k=null,T.apply(this,arguments)}}}var os=typeof Symbol=="function"&&Symbol.iterator,Pc=function(k){return os&&k[os]&&k[os]()};function s1(k,T){for(var L=-1,F=Array(k);++L<k;)F[L]=T(L);return F}function un(k){return k!=null&&typeof k=="object"}var il="[object Arguments]";function l1(k){return un(k)&&kr(k)==il}var go=Object.prototype,c1=go.hasOwnProperty,n3=go.propertyIsEnumerable,sl=l1(function(){return arguments}())?l1:function(k){return un(k)&&c1.call(k,"callee")&&!n3.call(k,"callee")},Ct=Array.isArray;function ll(){return!1}var cl=typeof t=="object"&&t&&!t.nodeType&&t,a1=cl&&!0&&n&&!n.nodeType&&n,al=a1&&a1.exports===cl,u1=al?re.Buffer:void 0,ul=u1?u1.isBuffer:void 0,rs=ul||ll,ju=9007199254740991,Uu=/^(?:0|[1-9]\d*)$/;function zu(k,T){var L=typeof k;return T=T==null?ju:T,!!T&&(L=="number"||L!="symbol"&&Uu.test(k))&&k>-1&&k%1==0&&k<T}var Vu="[object Arguments]",Wu="[object Array]",qu="[object Boolean]",Gu="[object Date]",Zu="[object Error]",Qu="[object Function]",o3="[object Map]",r3="[object Number]",i3="[object Object]",d1="[object RegExp]",h1="[object Set]",s3="[object String]",l3="[object WeakMap]",c3="[object ArrayBuffer]",a3="[object DataView]",f1="[object Float32Array]",u3="[object Float64Array]",d3="[object Int8Array]",h3="[object Int16Array]",Yu="[object Int32Array]",f3="[object Uint8Array]",Ju="[object Uint8ClampedArray]",m3="[object Uint16Array]",g3="[object Uint32Array]",it={};it[f1]=it[u3]=it[d3]=it[h3]=it[Yu]=it[f3]=it[Ju]=it[m3]=it[g3]=!0,it[Vu]=it[Wu]=it[c3]=it[qu]=it[a3]=it[Gu]=it[Zu]=it[Qu]=it[o3]=it[r3]=it[i3]=it[d1]=it[h1]=it[s3]=it[l3]=!1;function p3(k){return un(k)&&ol(k.length)&&!!it[kr(k)]}function C3(k){return function(T){return k(T)}}var m1=typeof t=="object"&&t&&!t.nodeType&&t,dl=m1&&!0&&n&&!n.nodeType&&n,A3=dl&&dl.exports===m1,Nc=A3&&z.process,g1=function(){try{var k=dl&&dl.require&&dl.require("util").types;return k||Nc&&Nc.binding&&Nc.binding("util")}catch{}}(),p1=g1&&g1.isTypedArray,b3=p1?C3(p1):p3,v3=Object.prototype,y3=v3.hasOwnProperty;function k3(k,T){var L=Ct(k),F=!L&&sl(k),U=!L&&!F&&rs(k),j=!L&&!F&&!U&&b3(k),Z=L||F||U||j,J=Z?s1(k.length,String):[],le=J.length;for(var pe in k)(T||y3.call(k,pe))&&!(Z&&(pe=="length"||U&&(pe=="offset"||pe=="parent")||j&&(pe=="buffer"||pe=="byteLength"||pe=="byteOffset")||zu(pe,le)))&&J.push(pe);return J}var $c=Object.prototype;function w3(k){var T=k&&k.constructor,L=typeof T=="function"&&T.prototype||$c;return k===L}function Hc(k,T){return function(L){return k(T(L))}}var B3=Hc(Object.keys,Object),E3=Object.prototype,x3=E3.hasOwnProperty;function C1(k){if(!w3(k))return B3(k);var T=[];for(var L in Object(k))x3.call(k,L)&&L!="constructor"&&T.push(L);return T}function jc(k){return rl(k)?k3(k):C1(k)}function A1(k){var T=-1,L=k.length;return function(){return++T<L?{value:k[T],key:T}:null}}function I3(k){var T=-1;return function(){var F=k.next();return F.done?null:(T++,{value:F.value,key:T})}}function T3(k){var T=jc(k),L=-1,F=T.length;return function U(){var j=T[++L];return j==="__proto__"?U():L<F?{value:k[j],key:j}:null}}function D3(k){if(rl(k))return A1(k);var T=Pc(k);return T?I3(T):T3(k)}function po(k){return function(){if(k===null)throw new Error("Callback was already called.");var T=k;k=null,T.apply(this,arguments)}}function hl(k){return function(T,L,F){if(F=wr(F||Ne),k<=0||!T)return F(null);var U=D3(T),j=!1,Z=0,J=!1;function le(ce,Ae){if(Z-=1,ce)j=!0,F(ce);else{if(Ae===ni||j&&Z<=0)return j=!0,F(null);J||pe()}}function pe(){for(J=!0;Z<k&&!j;){var ce=U();if(ce===null){j=!0,Z<=0&&F(null);return}Z+=1,L(ce.value,ce.key,po(le))}J=!1}pe()}}function Br(k,T,L,F){hl(T)(k,M(L),F)}function $t(k,T){return function(L,F,U){return k(L,T,F,U)}}function Ku(k,T,L){L=wr(L||Ne);var F=0,U=0,j=k.length;j===0&&L(null);function Z(J,le){J?L(J):(++U===j||le===ni)&&L(null)}for(;F<j;F++)T(k[F],F,po(Z))}var S3=$t(Br,1/0),qo=function(k,T,L){var F=rl(k)?Ku:S3;F(k,M(T),L)};function Go(k){return function(T,L,F){return k(qo,T,M(L),F)}}function Xu(k,T,L,F){F=F||Ne,T=T||[];var U=[],j=0,Z=M(L);k(T,function(J,le,pe){var ce=j++;Z(J,function(Ae,Ge){U[ce]=Ge,pe(Ae)})},function(J){F(J,U)})}var Uc=Go(Xu),ed=H(Uc);function oi(k){return function(T,L,F,U){return k(hl(L),T,M(F),U)}}var Er=oi(Xu),td=$t(Er,1),nd=H(td);function is(k,T){for(var L=-1,F=k==null?0:k.length;++L<F&&T(k[L],L,k)!==!1;);return k}function od(k){return function(T,L,F){for(var U=-1,j=Object(T),Z=F(T),J=Z.length;J--;){var le=Z[k?J:++U];if(L(j[le],le,j)===!1)break}return T}}var ss=od();function ls(k,T){return k&&ss(k,T,jc)}function b1(k,T,L,F){for(var U=k.length,j=L+(F?1:-1);F?j--:++j<U;)if(T(k[j],j,k))return j;return-1}function L3(k){return k!==k}function v1(k,T,L){for(var F=L-1,U=k.length;++F<U;)if(k[F]===T)return F;return-1}function fl(k,T,L){return T===T?v1(k,T,L):b1(k,L3,L)}var zc=function(k,T,L){typeof T=="function"&&(L=T,T=null),L=wr(L||Ne);var F=jc(k),U=F.length;if(!U)return L(null);T||(T=U);var j={},Z=0,J=!1,le=Object.create(null),pe=[],ce=[],Ae={};ls(k,function(dt,ot){if(!Ct(dt)){Ge(ot,[dt]),ce.push(ot);return}var gt=dt.slice(0,dt.length-1),Ao=gt.length;if(Ao===0){Ge(ot,dt),ce.push(ot);return}Ae[ot]=Ao,is(gt,function(E){if(!k[E])throw new Error("async.auto task `"+ot+"` has a non-existent dependency `"+E+"` in "+gt.join(", "));tn(E,function(){Ao--,Ao===0&&Ge(ot,dt)})})}),X3(),It();function Ge(dt,ot){pe.push(function(){Co(dt,ot)})}function It(){if(pe.length===0&&Z===0)return L(null,j);for(;pe.length&&Z<T;){var dt=pe.shift();dt()}}function tn(dt,ot){var gt=le[dt];gt||(gt=le[dt]=[]),gt.push(ot)}function On(dt){var ot=le[dt]||[];is(ot,function(gt){gt()}),It()}function Co(dt,ot){if(!J){var gt=po(function(E,Tr){if(Z--,arguments.length>2&&(Tr=o(arguments,1)),E){var ds={};ls(j,function(_n,Pe){ds[Pe]=_n}),ds[dt]=Tr,J=!0,le=Object.create(null),L(E,ds)}else j[dt]=Tr,On(dt)});Z++;var Ao=M(ot[ot.length-1]);ot.length>1?Ao(j,gt):Ao(gt)}}function X3(){for(var dt,ot=0;ce.length;)dt=ce.pop(),ot++,is(e5(dt),function(gt){--Ae[gt]===0&&ce.push(gt)});if(ot!==U)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function e5(dt){var ot=[];return ls(k,function(gt,Ao){Ct(gt)&&fl(gt,dt,0)>=0&&ot.push(Ao)}),ot}};function ri(k,T){for(var L=-1,F=k==null?0:k.length,U=Array(F);++L<F;)U[L]=T(k[L],L,k);return U}var M3="[object Symbol]";function R3(k){return typeof k=="symbol"||un(k)&&kr(k)==M3}var O3=1/0,rd=fe?fe.prototype:void 0,y1=rd?rd.toString:void 0;function id(k){if(typeof k=="string")return k;if(Ct(k))return ri(k,id)+"";if(R3(k))return y1?y1.call(k):"";var T=k+"";return T=="0"&&1/k==-O3?"-0":T}function _3(k,T,L){var F=-1,U=k.length;T<0&&(T=-T>U?0:U+T),L=L>U?U:L,L<0&&(L+=U),U=T>L?0:L-T>>>0,T>>>=0;for(var j=Array(U);++F<U;)j[F]=k[F+T];return j}function F3(k,T,L){var F=k.length;return L=L===void 0?F:L,!T&&L>=F?k:_3(k,T,L)}function sd(k,T){for(var L=k.length;L--&&fl(T,k[L],0)>-1;);return L}function P3(k,T){for(var L=-1,F=k.length;++L<F&&fl(T,k[L],0)>-1;);return L}function N3(k){return k.split("")}var $3="\\ud800-\\udfff",H3="\\u0300-\\u036f",j3="\\ufe20-\\ufe2f",st="\\u20d0-\\u20ff",nt=H3+j3+st,U3="\\ufe0e\\ufe0f",z3="\\u200d",V3=RegExp("["+z3+$3+nt+U3+"]");function W3(k){return V3.test(k)}var k1="\\ud800-\\udfff",q3="\\u0300-\\u036f",w1="\\ufe20-\\ufe2f",G3="\\u20d0-\\u20ff",qt=q3+w1+G3,ld="\\ufe0e\\ufe0f",ii="["+k1+"]",Vc="["+qt+"]",ml="\\ud83c[\\udffb-\\udfff]",Mn="(?:"+Vc+"|"+ml+")",cd="[^"+k1+"]",ad="(?:\\ud83c[\\udde6-\\uddff]){2}",ud="[\\ud800-\\udbff][\\udc00-\\udfff]",B1="\\u200d",dd=Mn+"?",hd="["+ld+"]?",vn="(?:"+B1+"(?:"+[cd,ad,ud].join("|")+")"+hd+dd+")*",Z3=hd+dd+vn,Rn="(?:"+[cd+Vc+"?",Vc,ad,ud,ii].join("|")+")",Q3=RegExp(ml+"(?="+ml+")|"+Rn+Z3,"g");function E1(k){return k.match(Q3)||[]}function Zo(k){return W3(k)?E1(k):N3(k)}function Wc(k){return k==null?"":id(k)}var fd=/^\s+|\s+$/g;function ut(k,T,L){if(k=Wc(k),k&&(L||T===void 0))return k.replace(fd,"");if(!k||!(T=id(T)))return k;var F=Zo(k),U=Zo(T),j=P3(F,U),Z=sd(F,U)+1;return F3(F,j,Z).join("")}var xr=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,md=/,/,Y3=/(=.+)?(\s*)$/,gd=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;function J3(k){return k=k.toString().replace(gd,""),k=k.match(xr)[2].replace(" ",""),k=k?k.split(md):[],k=k.map(function(T){return ut(T.replace(Y3,""))}),k}function x1(k,T){var L={};ls(k,function(F,U){var j,Z=_(F),J=!Z&&F.length===1||Z&&F.length===0;if(Ct(F))j=F.slice(0,-1),F=F[F.length-1],L[U]=j.concat(j.length>0?le:F);else if(J)L[U]=F;else{if(j=J3(F),F.length===0&&!Z&&j.length===0)throw new Error("autoInject task functions require explicit parameters.");Z||j.pop(),L[U]=j.concat(le)}function le(pe,ce){var Ae=ri(j,function(Ge){return pe[Ge]});Ae.push(ce),M(F).apply(null,Ae)}}),zc(L,T)}function Yn(){this.head=this.tail=null,this.length=0}function pd(k,T){k.length=1,k.head=k.tail=T}Yn.prototype.removeLink=function(k){return k.prev?k.prev.next=k.next:this.head=k.next,k.next?k.next.prev=k.prev:this.tail=k.prev,k.prev=k.next=null,this.length-=1,k},Yn.prototype.empty=function(){for(;this.head;)this.shift();return this},Yn.prototype.insertAfter=function(k,T){T.prev=k,T.next=k.next,k.next?k.next.prev=T:this.tail=T,k.next=T,this.length+=1},Yn.prototype.insertBefore=function(k,T){T.prev=k.prev,T.next=k,k.prev?k.prev.next=T:this.head=T,k.prev=T,this.length+=1},Yn.prototype.unshift=function(k){this.head?this.insertBefore(this.head,k):pd(this,k)},Yn.prototype.push=function(k){this.tail?this.insertAfter(this.tail,k):pd(this,k)},Yn.prototype.shift=function(){return this.head&&this.removeLink(this.head)},Yn.prototype.pop=function(){return this.tail&&this.removeLink(this.tail)},Yn.prototype.toArray=function(){for(var k=Array(this.length),T=this.head,L=0;L<this.length;L++)k[L]=T.data,T=T.next;return k},Yn.prototype.remove=function(k){for(var T=this.head;T;){var L=T.next;k(T)&&this.removeLink(T),T=L}return this};function gl(k,T,L){if(T==null)T=1;else if(T===0)throw new Error("Concurrency must not be zero");var F=M(k),U=0,j=[],Z=!1;function J(Ae,Ge,It){if(It!=null&&typeof It!="function")throw new Error("task callback must be a function");if(ce.started=!0,Ct(Ae)||(Ae=[Ae]),Ae.length===0&&ce.idle())return A(function(){ce.drain()});for(var tn=0,On=Ae.length;tn<On;tn++){var Co={data:Ae[tn],callback:It||Ne};Ge?ce._tasks.unshift(Co):ce._tasks.push(Co)}Z||(Z=!0,A(function(){Z=!1,ce.process()}))}function le(Ae){return function(Ge){U-=1;for(var It=0,tn=Ae.length;It<tn;It++){var On=Ae[It],Co=fl(j,On,0);Co===0?j.shift():Co>0&&j.splice(Co,1),On.callback.apply(On,arguments),Ge!=null&&ce.error(Ge,On.data)}U<=ce.concurrency-ce.buffer&&ce.unsaturated(),ce.idle()&&ce.drain(),ce.process()}}var pe=!1,ce={_tasks:new Yn,concurrency:T,payload:L,saturated:Ne,unsaturated:Ne,buffer:T/4,empty:Ne,drain:Ne,error:Ne,started:!1,paused:!1,push:function(Ae,Ge){J(Ae,!1,Ge)},kill:function(){ce.drain=Ne,ce._tasks.empty()},unshift:function(Ae,Ge){J(Ae,!0,Ge)},remove:function(Ae){ce._tasks.remove(Ae)},process:function(){if(!pe){for(pe=!0;!ce.paused&&U<ce.concurrency&&ce._tasks.length;){var Ae=[],Ge=[],It=ce._tasks.length;ce.payload&&(It=Math.min(It,ce.payload));for(var tn=0;tn<It;tn++){var On=ce._tasks.shift();Ae.push(On),j.push(On),Ge.push(On.data)}U+=1,ce._tasks.length===0&&ce.empty(),U===ce.concurrency&&ce.saturated();var Co=po(le(Ae));F(Ge,Co)}pe=!1}},length:function(){return ce._tasks.length},running:function(){return U},workersList:function(){return j},idle:function(){return ce._tasks.length+U===0},pause:function(){ce.paused=!0},resume:function(){ce.paused!==!1&&(ce.paused=!1,A(ce.process))}};return ce}function si(k,T){return gl(k,1,T)}var cs=$t(Br,1);function Qo(k,T,L,F){F=wr(F||Ne);var U=M(L);cs(k,function(j,Z,J){U(T,j,function(le,pe){T=pe,J(le)})},function(j){F(j,T)})}function qc(){var k=ri(arguments,M);return function(){var T=o(arguments),L=this,F=T[T.length-1];typeof F=="function"?T.pop():F=Ne,Qo(k,T,function(U,j,Z){j.apply(L,U.concat(function(J){var le=o(arguments,1);Z(J,le)}))},function(U,j){F.apply(L,[U].concat(j))})}}var Gc=function(){return qc.apply(null,o(arguments).reverse())},Cd=Array.prototype.concat,pl=function(k,T,L,F){F=F||Ne;var U=M(L);Er(k,T,function(j,Z){U(j,function(J){return J?Z(J):Z(null,o(arguments,1))})},function(j,Z){for(var J=[],le=0;le<Z.length;le++)Z[le]&&(J=Cd.apply(J,Z[le]));return F(j,J)})},I1=$t(pl,1/0),Zc=$t(pl,1),Qc=function(){var k=o(arguments),T=[null].concat(k);return function(){var L=arguments[arguments.length-1];return L.apply(this,T)}};function Cl(k){return k}function li(k,T){return function(L,F,U,j){j=j||Ne;var Z=!1,J;L(F,function(le,pe,ce){U(le,function(Ae,Ge){Ae?ce(Ae):k(Ge)&&!J?(Z=!0,J=T(!0,le),ce(null,ni)):ce()})},function(le){le?j(le):j(null,Z?J:T(!1))})}}function dn(k,T){return T}var as=Go(li(Cl,dn)),Yo=oi(li(Cl,dn)),Al=$t(Yo,1);function Ad(k){return function(T){var L=o(arguments,1);L.push(function(F){var U=o(arguments,1);typeof console=="object"&&(F?console.error&&console.error(F):console[k]&&is(U,function(j){console[k](j)}))}),M(T).apply(null,L)}}var T1=Ad("dir");function D1(k,T,L){L=po(L||Ne);var F=M(k),U=M(T);function j(J){if(J)return L(J);var le=o(arguments,1);le.push(Z),U.apply(this,le)}function Z(J,le){if(J)return L(J);if(!le)return L(null);F(j)}Z(null,!0)}function bd(k,T,L){L=po(L||Ne);var F=M(k),U=function(j){if(j)return L(j);var Z=o(arguments,1);if(T.apply(this,Z))return F(U);L.apply(null,[null].concat(Z))};F(U)}function S1(k,T,L){bd(k,function(){return!T.apply(this,arguments)},L)}function L1(k,T,L){L=po(L||Ne);var F=M(T),U=M(k);function j(J){if(J)return L(J);U(Z)}function Z(J,le){if(J)return L(J);if(!le)return L(null);F(j)}U(Z)}function ci(k){return function(T,L,F){return k(T,F)}}function Yc(k,T,L){qo(k,ci(M(T)),L)}function bl(k,T,L,F){hl(T)(k,ci(M(L)),F)}var ai=$t(bl,1);function Jc(k){return _(k)?k:i(function(T,L){var F=!0;T.push(function(){var U=arguments;F?A(function(){L.apply(null,U)}):L.apply(null,U)}),k.apply(this,T),F=!1})}function Jn(k){return!k}var ui=Go(li(Jn,Jn)),vl=oi(li(Jn,Jn)),Kc=$t(vl,1);function M1(k){return function(T){return T==null?void 0:T[k]}}function us(k,T,L,F){var U=new Array(T.length);k(T,function(j,Z,J){L(j,function(le,pe){U[Z]=!!pe,J(le)})},function(j){if(j)return F(j);for(var Z=[],J=0;J<T.length;J++)U[J]&&Z.push(T[J]);F(null,Z)})}function Kn(k,T,L,F){var U=[];k(T,function(j,Z,J){L(j,function(le,pe){le?J(le):(pe&&U.push({index:Z,value:j}),J())})},function(j){j?F(j):F(null,ri(U.sort(function(Z,J){return Z.index-J.index}),M1("value")))})}function Xc(k,T,L,F){var U=rl(T)?us:Kn;U(k,T,M(L),F||Ne)}var ea=Go(Xc),yl=oi(Xc),ta=$t(yl,1);function R1(k,T){var L=po(T||Ne),F=M(Jc(k));function U(j){if(j)return L(j);F(U)}U()}var na=function(k,T,L,F){F=F||Ne;var U=M(L);Er(k,T,function(j,Z){U(j,function(J,le){return J?Z(J):Z(null,{key:le,val:j})})},function(j,Z){for(var J={},le=Object.prototype.hasOwnProperty,pe=0;pe<Z.length;pe++)if(Z[pe]){var ce=Z[pe].key,Ae=Z[pe].val;le.call(J,ce)?J[ce].push(Ae):J[ce]=[Ae]}return F(j,J)})},di=$t(na,1/0),N=$t(na,1),G=Ad("log");function V(k,T,L,F){F=wr(F||Ne);var U={},j=M(L);Br(k,T,function(Z,J,le){j(Z,J,function(pe,ce){if(pe)return le(pe);U[J]=ce,le()})},function(Z){F(Z,U)})}var he=$t(V,1/0),Ee=$t(V,1);function Ve(k,T){return T in k}function Bt(k,T){var L=Object.create(null),F=Object.create(null);T=T||Cl;var U=M(k),j=i(function(J,le){var pe=T.apply(null,J);Ve(L,pe)?A(function(){le.apply(null,L[pe])}):Ve(F,pe)?F[pe].push(le):(F[pe]=[le],U.apply(null,J.concat(function(){var ce=o(arguments);L[pe]=ce;var Ae=F[pe];delete F[pe];for(var Ge=0,It=Ae.length;Ge<It;Ge++)Ae[Ge].apply(null,ce)})))});return j.memo=L,j.unmemoized=k,j}var qe;a?qe=process.nextTick:l?qe=setImmediate:qe=d;var oa=h(qe);function vd(k,T,L){L=L||Ne;var F=rl(T)?[]:{};k(T,function(U,j,Z){M(U)(function(J,le){arguments.length>2&&(le=o(arguments,1)),F[j]=le,Z(J)})},function(U){L(U,F)})}function yn(k,T){vd(qo,k,T)}function kl(k,T,L){vd(hl(T),k,L)}var yd=function(k,T){var L=M(k);return gl(function(F,U){L(F[0],U)},T,1)},hi=function(k,T){var L=yd(k,T);return L.push=function(F,U,j){if(j==null&&(j=Ne),typeof j!="function")throw new Error("task callback must be a function");if(L.started=!0,Ct(F)||(F=[F]),F.length===0)return A(function(){L.drain()});U=U||0;for(var Z=L._tasks.head;Z&&U>=Z.priority;)Z=Z.next;for(var J=0,le=F.length;J<le;J++){var pe={data:F[J],priority:U,callback:j};Z?L._tasks.insertBefore(Z,pe):L._tasks.push(pe)}A(L.process)},delete L.unshift,L};function wl(k,T){if(T=wr(T||Ne),!Ct(k))return T(new TypeError("First argument to race must be an array of functions"));if(!k.length)return T();for(var L=0,F=k.length;L<F;L++)M(k[L])(T)}function fi(k,T,L,F){var U=o(k).reverse();Qo(U,T,L,F)}function We(k){var T=M(k);return i(function(F,U){return F.push(function(Z,J){if(Z)U(null,{error:Z});else{var le;arguments.length<=2?le=J:le=o(arguments,1),U(null,{value:le})}}),T.apply(this,F)})}function O1(k){var T;return Ct(k)?T=ri(k,We):(T={},ls(k,function(L,F){T[F]=We.call(this,L)})),T}function kd(k,T,L,F){Xc(k,T,function(U,j){L(U,function(Z,J){j(Z,!J)})},F)}var Bl=Go(kd),wd=oi(kd),_1=$t(wd,1);function F1(k){return function(){return k}}function mi(k,T,L){var F=5,U=0,j={times:F,intervalFunc:F1(U)};function Z(ce,Ae){if(typeof Ae=="object")ce.times=+Ae.times||F,ce.intervalFunc=typeof Ae.interval=="function"?Ae.interval:F1(+Ae.interval||U),ce.errorFilter=Ae.errorFilter;else if(typeof Ae=="number"||typeof Ae=="string")ce.times=+Ae||F;else throw new Error("Invalid arguments for async.retry")}if(arguments.length<3&&typeof k=="function"?(L=T||Ne,T=k):(Z(j,k),L=L||Ne),typeof T!="function")throw new Error("Invalid arguments for async.retry");var J=M(T),le=1;function pe(){J(function(ce){ce&&le++<j.times&&(typeof j.errorFilter!="function"||j.errorFilter(ce))?setTimeout(pe,j.intervalFunc(le)):L.apply(null,arguments)})}pe()}var Jo=function(k,T){T||(T=k,k=null);var L=M(T);return i(function(F,U){function j(Z){L.apply(null,F.concat(Z))}k?mi(k,j,U):mi(j,U)})};function El(k,T){vd(cs,k,T)}var xl=Go(li(Boolean,Cl)),Ir=oi(li(Boolean,Cl)),Il=$t(Ir,1);function Bd(k,T,L){var F=M(T);Uc(k,function(j,Z){F(j,function(J,le){if(J)return Z(J);Z(null,{value:j,criteria:le})})},function(j,Z){if(j)return L(j);L(null,ri(Z.sort(U),M1("value")))});function U(j,Z){var J=j.criteria,le=Z.criteria;return J<le?-1:J>le?1:0}}function Tl(k,T,L){var F=M(k);return i(function(U,j){var Z=!1,J;function le(){var pe=k.name||"anonymous",ce=new Error('Callback function "'+pe+'" timed out.');ce.code="ETIMEDOUT",L&&(ce.info=L),Z=!0,j(ce)}U.push(function(){Z||(j.apply(null,arguments),clearTimeout(J))}),J=setTimeout(le,T),F.apply(null,U)})}var P1=Math.ceil,Dl=Math.max;function gi(k,T,L,F){for(var U=-1,j=Dl(P1((T-k)/(L||1)),0),Z=Array(j);j--;)Z[F?j:++U]=k,k+=L;return Z}function pi(k,T,L,F){var U=M(L);Er(gi(0,k,1),T,U,F)}var N1=$t(pi,1/0),$1=$t(pi,1);function H1(k,T,L,F){arguments.length<=3&&(F=L,L=T,T=Ct(k)?[]:{}),F=wr(F||Ne);var U=M(L);qo(k,function(j,Z,J){U(T,j,Z,J)},function(j){F(j,T)})}function Sl(k,T){var L=null,F;T=T||Ne,ai(k,function(U,j){M(U)(function(Z,J){arguments.length>2?F=o(arguments,1):F=J,L=Z,j(!Z)})},function(){T(L,F)})}function Ll(k){return function(){return(k.unmemoized||k).apply(null,arguments)}}function Ml(k,T,L){L=po(L||Ne);var F=M(T);if(!k())return L(null);var U=function(j){if(j)return L(j);if(k())return F(U);var Z=o(arguments,1);L.apply(null,[null].concat(Z))};F(U)}function j1(k,T,L){Ml(function(){return!k.apply(this,arguments)},T,L)}var Ed=function(k,T){if(T=wr(T||Ne),!Ct(k))return T(new Error("First argument to waterfall must be an array of functions"));if(!k.length)return T();var L=0;function F(j){var Z=M(k[L++]);j.push(po(U)),Z.apply(null,j)}function U(j){if(j||L===k.length)return T.apply(null,arguments);F(o(arguments,1))}F([])},K3={apply:r,applyEach:ed,applyEachSeries:nd,asyncify:v,auto:zc,autoInject:x1,cargo:si,compose:Gc,concat:I1,concatLimit:pl,concatSeries:Zc,constant:Qc,detect:as,detectLimit:Yo,detectSeries:Al,dir:T1,doDuring:D1,doUntil:S1,doWhilst:bd,during:L1,each:Yc,eachLimit:bl,eachOf:qo,eachOfLimit:Br,eachOfSeries:cs,eachSeries:ai,ensureAsync:Jc,every:ui,everyLimit:vl,everySeries:Kc,filter:ea,filterLimit:yl,filterSeries:ta,forever:R1,groupBy:di,groupByLimit:na,groupBySeries:N,log:G,map:Uc,mapLimit:Er,mapSeries:td,mapValues:he,mapValuesLimit:V,mapValuesSeries:Ee,memoize:Bt,nextTick:oa,parallel:yn,parallelLimit:kl,priorityQueue:hi,queue:yd,race:wl,reduce:Qo,reduceRight:fi,reflect:We,reflectAll:O1,reject:Bl,rejectLimit:wd,rejectSeries:_1,retry:mi,retryable:Jo,seq:qc,series:El,setImmediate:A,some:xl,someLimit:Ir,someSeries:Il,sortBy:Bd,timeout:Tl,times:N1,timesLimit:pi,timesSeries:$1,transform:H1,tryEach:Sl,unmemoize:Ll,until:j1,waterfall:Ed,whilst:Ml,all:ui,allLimit:vl,allSeries:Kc,any:xl,anyLimit:Ir,anySeries:Il,find:as,findLimit:Yo,findSeries:Al,forEach:Yc,forEachSeries:ai,forEachLimit:bl,forEachOf:qo,forEachOfSeries:cs,forEachOfLimit:Br,inject:Qo,foldl:Qo,foldr:fi,select:ea,selectLimit:yl,selectSeries:ta,wrapSync:v};t.default=K3,t.apply=r,t.applyEach=ed,t.applyEachSeries=nd,t.asyncify=v,t.auto=zc,t.autoInject=x1,t.cargo=si,t.compose=Gc,t.concat=I1,t.concatLimit=pl,t.concatSeries=Zc,t.constant=Qc,t.detect=as,t.detectLimit=Yo,t.detectSeries=Al,t.dir=T1,t.doDuring=D1,t.doUntil=S1,t.doWhilst=bd,t.during=L1,t.each=Yc,t.eachLimit=bl,t.eachOf=qo,t.eachOfLimit=Br,t.eachOfSeries=cs,t.eachSeries=ai,t.ensureAsync=Jc,t.every=ui,t.everyLimit=vl,t.everySeries=Kc,t.filter=ea,t.filterLimit=yl,t.filterSeries=ta,t.forever=R1,t.groupBy=di,t.groupByLimit=na,t.groupBySeries=N,t.log=G,t.map=Uc,t.mapLimit=Er,t.mapSeries=td,t.mapValues=he,t.mapValuesLimit=V,t.mapValuesSeries=Ee,t.memoize=Bt,t.nextTick=oa,t.parallel=yn,t.parallelLimit=kl,t.priorityQueue=hi,t.queue=yd,t.race=wl,t.reduce=Qo,t.reduceRight=fi,t.reflect=We,t.reflectAll=O1,t.reject=Bl,t.rejectLimit=wd,t.rejectSeries=_1,t.retry=mi,t.retryable=Jo,t.seq=qc,t.series=El,t.setImmediate=A,t.some=xl,t.someLimit=Ir,t.someSeries=Il,t.sortBy=Bd,t.timeout=Tl,t.times=N1,t.timesLimit=pi,t.timesSeries=$1,t.transform=H1,t.tryEach=Sl,t.unmemoize=Ll,t.until=j1,t.waterfall=Ed,t.whilst=Ml,t.all=ui,t.allLimit=vl,t.allSeries=Kc,t.any=xl,t.anyLimit=Ir,t.anySeries=Il,t.find=as,t.findLimit=Yo,t.findSeries=Al,t.forEach=Yc,t.forEachSeries=ai,t.forEachLimit=bl,t.forEachOf=qo,t.forEachOfSeries=cs,t.forEachOfLimit=Br,t.inject=Qo,t.foldl=Qo,t.foldr=fi,t.select=ea,t.selectLimit=yl,t.selectSeries=ta,t.wrapSync=v,Object.defineProperty(t,"__esModule",{value:!0})})})(ap,ap.exports);var xb={exports:{}},up=xb.exports=function(n,e){if(e||(e=16),n===void 0&&(n=128),n<=0)return"0";for(var t=Math.log(Math.pow(2,n))/Math.log(e),o=2;t===1/0;o*=2)t=Math.log(Math.pow(2,n/o))/Math.log(e)*o;for(var r=t-Math.floor(t),i="",o=0;o<Math.floor(t);o++){var s=Math.floor(Math.random()*e).toString(e);i=s+i}if(r){var l=Math.pow(e,r),s=Math.floor(Math.random()*l).toString(e);i=s+i}var a=parseInt(i,e);return a!==1/0&&a>=Math.pow(2,n)?up(n,e):i};up.rack=function(n,e,t){var o=function(i){var s=0;do{if(s++>10)if(t)n+=t;else throw new Error("too many ID collisions, use more bits");var l=up(n,e)}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=e||16,o};var Ib=$i,gS=Bb,pS=Eb,Uh=Fo,dp=ap.exports,CS=xb.exports,Tb=Us.ACTIONS,Db=Mt;function Mt(n,e){if(Ib.EventEmitter.call(this),!e||typeof e!="string")throw new Error("Presence channel must be provided");this.connection=n,this.channel=e,this.wantSubscribe=!1,this.subscribed=!1,this.remotePresences={},this.localPresences={},this._remotePresenceInstances={},this._subscriptionCallbacksBySeq={},this._wantsDestroy=!1}Ib.mixin(Mt),Mt.prototype.subscribe=function(n){this._sendSubscriptionAction(!0,n)},Mt.prototype.unsubscribe=function(n){this._sendSubscriptionAction(!1,n)},Mt.prototype.create=function(n){if(this._wantsDestroy)throw new Error("Presence is being destroyed");n=n||CS();var e=this._createLocalPresence(n);return this.localPresences[n]=e,e},Mt.prototype.destroy=function(n){this._wantsDestroy=!0;var e=this,t=Object.keys(e.localPresences);this.unsubscribe(function(o){if(o)return e._callbackOrEmit(o,n);var r=Object.keys(e._remotePresenceInstances);dp.parallel([function(i){dp.each(t,function(s,l){e.localPresences[s].destroy(l)},i)},function(i){if(!e._wantsDestroy)return i();dp.each(r,function(s,l){e._remotePresenceInstances[s].destroy(l)},i)}],function(i){e._wantsDestroy&&delete e.connection._presences[e.channel],e._callbackOrEmit(i,n)})})},Mt.prototype._sendSubscriptionAction=function(n,e){this.wantSubscribe=!!n;var t=this.wantSubscribe?Tb.presenceSubscribe:Tb.presenceUnsubscribe,o=this.connection._presenceSeq++;this._subscriptionCallbacksBySeq[o]=e,this.connection.canSend&&this.connection._sendPresenceAction(t,o,this)},Mt.prototype._handleSubscribe=function(n,e){this.wantSubscribe&&(this.subscribed=!0);var t=this._subscriptionCallback(e);this._callbackOrEmit(n,t)},Mt.prototype._handleUnsubscribe=function(n,e){this.subscribed=!1;var t=this._subscriptionCallback(e);this._callbackOrEmit(n,t)},Mt.prototype._receiveUpdate=function(n,e){var t=Uh.dig(this.localPresences,e.id);if(t)return t._ack(n,e.pv);if(n)return this.emit("error",n);var o=this,r=Uh.digOrCreate(this._remotePresenceInstances,e.id,function(){return o._createRemotePresence(e.id)});r.receiveUpdate(e)},Mt.prototype._updateRemotePresence=function(n){this.remotePresences[n.presenceId]=n.value,n.value===null&&this._removeRemotePresence(n.presenceId),this.emit("receive",n.presenceId,n.value)},Mt.prototype._broadcastAllLocalPresence=function(n){if(n)return this.emit("error",n);for(var e in this.localPresences){var t=this.localPresences[e];t.value!==null&&t.send()}},Mt.prototype._removeRemotePresence=function(n){this._remotePresenceInstances[n].destroy(),delete this._remotePresenceInstances[n],delete this.remotePresences[n]},Mt.prototype._onConnectionStateChanged=function(){if(!!this.connection.canSend){this._resubscribe();for(var n in this.localPresences)this.localPresences[n]._sendPending()}},Mt.prototype._resubscribe=function(){var n=[];for(var e in this._subscriptionCallbacksBySeq){var t=this._subscriptionCallback(e);n.push(t)}if(!this.wantSubscribe)return this._callEachOrEmit(n);var o=this;this.subscribe(function(r){o._callEachOrEmit(n,r)})},Mt.prototype._subscriptionCallback=function(n){var e=this._subscriptionCallbacksBySeq[n];return delete this._subscriptionCallbacksBySeq[n],e},Mt.prototype._callbackOrEmit=function(n,e){if(e)return Uh.nextTick(e,n);n&&this.emit("error",n)},Mt.prototype._createLocalPresence=function(n){return new gS(this,n)},Mt.prototype._createRemotePresence=function(n){return new pS(this,n)},Mt.prototype._callEachOrEmit=function(n,e){var t=Uh.callEach(n,e);!t&&e&&this.emit("error",e)};var Wa=Bb,Sb=Ph,AS=Fo,Lb=Sb.CODES,bS=No;function No(n,e){Wa.call(this,n,e),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()}No.prototype=Object.create(Wa.prototype),No.prototype.submit=function(n,e){if(!this._doc.type){if(n===null)return this._callbackOrEmit(null,e);var t={code:Lb.ERR_DOC_DOES_NOT_EXIST,message:"Cannot submit presence. Document has not been created"};return this._callbackOrEmit(t,e)}this._docDataVersionByPresenceVersion[this.presenceVersion]=this._doc._dataStateVersion,Wa.prototype.submit.call(this,n,e)},No.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),Wa.prototype.destroy.call(this,n)},No.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(e){e.t=n._doc.type.uri,e.v=n._doc.version,n.connection.send(e)}),n._pendingMessages=[],n._docDataVersionByPresenceVersion={})})}},No.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)},No.prototype._transformAgainstOp=function(n,e){var t=this,o=this._doc._dataStateVersion;this._pendingMessages.forEach(function(r){var i=t._docDataVersionByPresenceVersion[r.pv];if(!(i>=o))try{r.p=t._transformPresence(r.p,n,e),t._docDataVersionByPresenceVersion[r.pv]=o}catch(l){var s=t._getCallback(r.pv);t._callbackOrEmit(l,s)}});try{this.value=this._transformPresence(this.value,n,e)}catch(r){this.emit("error",r)}},No.prototype._handleCreateOrDel=function(){this._pendingMessages.forEach(function(n){n.p=null}),this.value=null},No.prototype._handleLoad=function(){this.value=null,this._pendingMessages=[],this._docDataVersionByPresenceVersion={}},No.prototype._message=function(){var n=Wa.prototype._message.call(this);return n.c=this.collection,n.d=this.id,n.v=null,n.t=null,n},No.prototype._transformPresence=function(n,e,t){var o=this._doc.type;if(!AS.supportsPresence(o))throw new Sb(Lb.ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE,"Type does not support presence: "+o.name);return o.transformPresence(n,e,t)};var Mb={};(function(n){var e=Ua,t=Ph,o=Fo,r=t.CODES;n.checkOp=function(l){if(l==null||typeof l!="object")return new t(r.ERR_OT_OP_BADLY_FORMED,"Op must be an object");if(l.create!=null){if(typeof l.create!="object")return new t(r.ERR_OT_OP_BADLY_FORMED,"Create data must be an object");var a=l.create.type;if(typeof a!="string")return new t(r.ERR_OT_OP_BADLY_FORMED,"Missing create type");var d=e.map[a];if(d==null||typeof d!="object")return new t(r.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type")}else if(l.del!=null){if(l.del!==!0)return new t(r.ERR_OT_OP_BADLY_FORMED,"del value must be true")}else if(!("op"in l))return new t(r.ERR_OT_OP_BADLY_FORMED,"Missing op, create, or del");if(l.src!=null&&typeof l.src!="string")return new t(r.ERR_OT_OP_BADLY_FORMED,"src must be a string");if(l.seq!=null&&typeof l.seq!="number")return new t(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 t(r.ERR_OT_OP_BADLY_FORMED,"Both src and seq must be set together");if(l.m!=null&&typeof l.m!="object")return new t(r.ERR_OT_OP_BADLY_FORMED,"op.m must be an object or null")},n.normalizeType=function(l){return e.map[l]&&e.map[l].uri},n.apply=function(l,a){if(typeof l!="object")return new t(r.ERR_APPLY_SNAPSHOT_NOT_PROVIDED,"Missing snapshot");if(l.v!=null&&a.v!=null&&l.v!==a.v)return new t(r.ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT,"Version mismatch");if(a.create){if(l.type)return new t(r.ERR_DOC_ALREADY_CREATED,"Document already exists");var d=a.create,h=e.map[d.type];if(!h)return new t(r.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{l.data=h.create(d.data),l.type=h.uri,l.v++}catch(A){return A}}else if(a.del)l.data=void 0,l.type=null,l.v++;else if("op"in a){var p=i(l,a.op);if(p)return p;l.v++}else l.v++};function i(l,a){if(!l.type)return new t(r.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");if(a===void 0)return new t(r.ERR_OT_OP_NOT_PROVIDED,"Missing op");var d=e.map[l.type];if(!d)return new t(r.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{l.data=d.apply(l.data,a)}catch(h){return new t(r.ERR_OT_OP_NOT_APPLIED,h.message)}}n.transform=function(l,a,d){if(a.v!=null&&a.v!==d.v)return new t(r.ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM,"Version mismatch");if(d.del){if(a.create||"op"in a)return new t(r.ERR_DOC_WAS_DELETED,"Document was deleted")}else{if(d.create&&("op"in a||a.create||a.del)||"op"in d&&a.create)return new t(r.ERR_DOC_ALREADY_CREATED,"Document was created remotely");if("op"in d&&"op"in a){if(!l)return new t(r.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");if(typeof l=="string"&&(l=e.map[l],!l))return new t(r.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{a.op=l.transform(a.op,d.op,"left")}catch(h){return h}}}a.v!=null&&a.v++},n.applyOps=function(l,a,d){d=d||{};for(var h=0;h<a.length;h++){var p=a[h];if(d._normalizeLegacyJson0Ops)try{s(l,p)}catch{return new t(r.ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED,"Cannot normalize legacy json0 op")}l.v=p.v;var A=n.apply(l,p);if(A)return A}},n.transformPresence=function(l,a,d){var h=this.checkOp(a);if(h)return h;var p=l.t;if(typeof p=="string"&&(p=e.map[p]),!p)return{code:r.ERR_DOC_TYPE_NOT_RECOGNIZED,message:"Unknown type"};if(!o.supportsPresence(p))return{code:r.ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE,message:"Type does not support presence"};if(a.create||a.del){l.p=null,l.v++;return}try{l.p=l.p===null?null:p.transformPresence(l.p,a.op,d)}catch(A){return{code:r.ERR_PRESENCE_TRANSFORM_FAILED,message:A.message||A}}l.v++};function s(l,a){if(l.type===e.defaultType.uri){var d=a.op;if(!!d){var h=l.data;d.length>1&&(h=o.clone(h));for(var p=0;p<d.length;p++){var A=d[p];typeof A.lm=="string"&&(A.lm=+A.lm);for(var v=A.p,B=h,D=0;D<v.length;D++){var I=v[D];Object.prototype.toString.call(B)=="[object Array]"?v[D]=+I:B.constructor===Object&&(v[D]=I.toString()),B=B[I]}p<d.length-1&&(h=e.defaultType.apply(h,[A]))}}}}})(Mb);var qa=Eb,vS=Mb,yS=co;function co(n,e){qa.call(this,n,e),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()}co.prototype=Object.create(qa.prototype),co.prototype.receiveUpdate=function(n){this._pending&&n.pv<this._pending.pv||(this.src=n.src,this._pending=n,this._setPendingPresence())},co.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),qa.prototype.destroy.call(this,n)},co.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)},co.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))}})}},co.prototype._handleOp=function(n,e,t){var o=t===this.src;this._transformAgainstOp(n,o),this._cacheOp(n,o),this._setPendingPresence()},qa.prototype._handleCreateDel=function(){this._cacheOp(null),this._setPendingPresence()},qa.prototype._handleLoad=function(){this.value=null,this._pending=null,this._opCache=null,this.presence._updateRemotePresence(this)},co.prototype._transformAgainstOp=function(n,e){if(!!this.value){try{this.value=this._doc.type.transformPresence(this.value,n,e)}catch(t){return this.presence.emit("error",t)}this.presence._updateRemotePresence(this)}},co.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],e=n.op,t=n.isOwnOp;e===null?(this._pending.p=null,this._pending.v++):vS.transformPresence(this._pending,e,t)}var o=this._pending.v>=this._doc.version;return o&&this._stopCachingOps(),o},co.prototype._startCachingOps=function(){this._opCache=[]},co.prototype._stopCachingOps=function(){this._opCache=null},co.prototype._cacheOp=function(n,e){this._opCache&&(n=n?{op:n}:null,this._opCache[this._doc.version-1]={op:n,isOwnOp:e})};var Rb=Db,kS=bS,wS=yS;function ec(n,e,t){var o=ec.channel(e,t);Rb.call(this,n,o),this.collection=e,this.id=t}var BS=ec;ec.prototype=Object.create(Rb.prototype),ec.channel=function(n,e){return n+"."+e},ec.prototype._createLocalPresence=function(n){return new kS(this,n)},ec.prototype._createRemotePresence=function(n){return new wS(this,n)};var ES=xS;function xS(n,e,t,o,r){this.id=n,this.v=e,this.type=t,this.data=o,this.m=r}var IS=ES,Ob=$i,_b=Ga;function Ga(n,e,t,o,r){if(Ob.EventEmitter.call(this),typeof r!="function")throw new Error("Callback is required for SnapshotRequest");this.requestId=e,this.connection=n,this.id=o,this.collection=t,this.callback=r,this.sent=!1}Ob.mixin(Ga),Ga.prototype.send=function(){!this.connection.canSend||(this.connection.send(this._message()),this.sent=!0)},Ga.prototype._onConnectionStateChanged=function(){this.connection.canSend?this.sent||this.send():this.sent=!1},Ga.prototype._handleResponse=function(n,e){if(this.emit("ready"),n)return this.callback(n);var t=e.meta?e.meta:null,o=new IS(this.id,e.v,e.type,e.data,t);this.callback(null,o)};var Fb=_b,TS=Fo,DS=Us.ACTIONS,SS=hp;function hp(n,e,t,o,r,i){if(Fb.call(this,n,e,t,o,i),!TS.isValidVersion(r))throw new Error("Snapshot version must be a positive integer or null");this.version=r}hp.prototype=Object.create(Fb.prototype),hp.prototype._message=function(){return{a:DS.snapshotFetch,id:this.requestId,c:this.collection,d:this.id,v:this.version}};var Pb=_b,LS=Fo,MS=Us.ACTIONS,RS=fp;function fp(n,e,t,o,r,i){if(Pb.call(this,n,e,t,o,i),!LS.isValidTimestamp(r))throw new Error("Snapshot timestamp must be a positive integer or null");this.timestamp=r}fp.prototype=Object.create(Pb.prototype),fp.prototype._message=function(){return{a:MS.snapshotFetchByTimestamp,id:this.requestId,c:this.collection,d:this.id,ts:this.timestamp}};var OS=sS,_S=dS,FS=Db,Nb=BS,PS=SS,NS=RS,$b=$i,tc=Ph,et=Us.ACTIONS,Hb=Ua,$o=Fo,Za=gb,Qa=tc.CODES;function jb(n){return n.readyState===0||n.readyState===1?"connecting":"disconnected"}var $S=we;function we(n){$b.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=jb(n),this.bindToSocket(n)}$b.mixin(we),we.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 e=jb(n);this._setState(e),this.canSend=!1;var t=this;n.onmessage=function(o){try{var r=typeof o.data=="string"?JSON.parse(o.data):o.data}catch{Za.warn("Failed to parse message",o);return}t.debug&&Za.info("RECV",JSON.stringify(r));var i={data:r};if(t.emit("receive",i),!!i.data)try{t.handleMessage(i.data)}catch(s){$o.nextTick(function(){t.emit("error",s)})}},n.readyState===1&&t._initializeHandshake(),n.onopen=function(){t._setState("connecting"),t._initializeHandshake()},n.onerror=function(o){t.emit("connection error",o)},n.onclose=function(o){o==="closed"||o==="Closed"?t._setState("closed",o):o==="stopped"||o==="Stopped by server"?t._setState("stopped",o):t._setState("disconnected",o)}},we.prototype.handleMessage=function(n){var e=null;switch(n.error&&(e=Ub(n.error,n),delete n.error),n.a){case et.initLegacy:return this._handleLegacyInit(n);case et.handshake:return this._handleHandshake(e,n);case et.queryFetch:var t=this.queries[n.id];t&&t._handleFetch(e,n.data,n.extra);return;case et.querySubscribe:var t=this.queries[n.id];t&&t._handleSubscribe(e,n.data,n.extra);return;case et.queryUnsubscribe:return;case et.queryUpdate:var t=this.queries[n.id];if(!t)return;if(e)return t._handleError(e);n.diff&&t._handleDiff(n.diff),n.hasOwnProperty("extra")&&t._handleExtra(n.extra);return;case et.bulkFetch:return this._handleBulkMessage(e,n,"_handleFetch");case et.bulkSubscribe:case et.bulkUnsubscribe:return this._handleBulkMessage(e,n,"_handleSubscribe");case et.snapshotFetch:case et.snapshotFetchByTimestamp:return this._handleSnapshotFetch(e,n);case et.fetch:var o=this.getExisting(n.c,n.d);o&&o._handleFetch(e,n.data);return;case et.subscribe:case et.unsubscribe:var o=this.getExisting(n.c,n.d);o&&o._handleSubscribe(e,n.data);return;case et.op:var o=this.getExisting(n.c,n.d);o&&o._handleOp(e,n);return;case et.presence:return this._handlePresence(e,n);case et.presenceSubscribe:return this._handlePresenceSubscribe(e,n);case et.presenceUnsubscribe:return this._handlePresenceUnsubscribe(e,n);case et.presenceRequest:return this._handlePresenceRequest(e,n);case et.pingPong:return this._handlePingPong(e);default:Za.warn("Ignoring unrecognized message",n)}};function Ub(n,e){var t=new Error(n.message);return t.code=n.code,e&&(t.data=e),t}we.prototype._handleBulkMessage=function(n,e,t){if(e.data)for(var o in e.data){var r=e.data[o],i=this.getExisting(e.c,o);i&&(n?i[t](n):r.error?i[t](Ub(r.error)):i[t](null,r))}else if(Array.isArray(e.b))for(var s=0;s<e.b.length;s++){var o=e.b[s],i=this.getExisting(e.c,o);i&&i[t](n)}else if(e.b)for(var o in e.b){var i=this.getExisting(e.c,o);i&&i[t](n)}else Za.error("Invalid bulk message",e)},we.prototype._reset=function(){this.agent=null},we.prototype._setState=function(n,e){if(this.state!==n){if(n==="connecting"&&this.state!=="disconnected"&&this.state!=="stopped"&&this.state!=="closed"||n==="connected"&&this.state!=="connecting"){var t=new tc(Qa.ERR_CONNECTION_STATE_TRANSITION_INVALID,"Cannot transition directly from "+this.state+" to "+n);return this.emit("error",t)}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 a=this._snapshotRequests[o];a._onConnectionStateChanged()}this.endBulk(),this.emit(n,e),this.emit("state",n,e)}},we.prototype.startBulk=function(){this.bulk||(this.bulk={})},we.prototype.endBulk=function(){if(this.bulk)for(var n in this.bulk){var e=this.bulk[n];this._sendBulk("f",n,e.f),this._sendBulk("s",n,e.s),this._sendBulk("u",n,e.u)}this.bulk=null},we.prototype._sendBulk=function(n,e,t){if(!!t){var o=[],r={},i=0,s;for(var l in t){var a=t[l];a==null?o.push(l):(r[l]=a,s=l,i++)}if(o.length===1){var l=o[0];this.send({a:n,c:e,d:l})}else o.length&&this.send({a:"b"+n,c:e,b:o});if(i===1){var d=r[s];this.send({a:n,c:e,d:s,v:d})}else i&&this.send({a:"b"+n,c:e,b:r})}},we.prototype._sendActions=function(n,e,t){if(this._addDoc(e),this.bulk){var o=this.bulk[e.collection]||(this.bulk[e.collection]={}),r=o[n]||(o[n]={}),i=r.hasOwnProperty(e.id);return r[e.id]=t,i}else{var s={a:n,c:e.collection,d:e.id,v:t};this.send(s)}},we.prototype.sendFetch=function(n){return this._sendActions(et.fetch,n,n.version)},we.prototype.sendSubscribe=function(n){return this._sendActions(et.subscribe,n,n.version)},we.prototype.sendUnsubscribe=function(n){return this._sendActions(et.unsubscribe,n)},we.prototype.sendOp=function(n,e){this._addDoc(n);var t={a:et.op,c:n.collection,d:n.id,v:n.version,src:e.src,seq:e.seq,x:{}};"op"in e&&(t.op=e.op),e.create&&(t.create=e.create),e.del&&(t.del=e.del),n.submitSource&&(t.x.source=e.source),this.send(t)},we.prototype.send=function(n){this.debug&&Za.info("SEND",JSON.stringify(n)),this.emit("send",n),this.socket.send(JSON.stringify(n))},we.prototype.ping=function(){if(!this.canSend)throw new tc(Qa.ERR_CANNOT_PING_OFFLINE,"Socket must be CONNECTED to ping");var n={a:et.pingPong};this.send(n)},we.prototype.close=function(){this.socket.close()},we.prototype.getExisting=function(n,e){if(this.collections[n])return this.collections[n][e]},we.prototype.get=function(n,e){var t=this.collections[n]||(this.collections[n]={}),o=t[e];return o||(o=t[e]=new OS(this,n,e),this.emit("doc",o)),o._wantsDestroy=!1,o},we.prototype._destroyDoc=function(n){!n._wantsDestroy||($o.digAndRemove(this.collections,n.collection,n.id),n.emit("destroy"))},we.prototype._addDoc=function(n){var e=this.collections[n.collection];e||(e=this.collections[n.collection]={}),e[n.id]!==n&&(e[n.id]=n)},we.prototype._createQuery=function(n,e,t,o,r){var i=this.nextQueryId++,s=new _S(n,this,i,e,t,o,r);return this.queries[i]=s,s.send(),s},we.prototype._destroyQuery=function(n){delete this.queries[n.id]},we.prototype.createFetchQuery=function(n,e,t,o){return this._createQuery(et.queryFetch,n,e,t,o)},we.prototype.createSubscribeQuery=function(n,e,t,o){return this._createQuery(et.querySubscribe,n,e,t,o)},we.prototype.hasPending=function(){return!!(this._firstDoc(zh)||this._firstQuery(zh)||this._firstSnapshotRequest())};function zh(n){return n.hasPending()}we.prototype.hasWritePending=function(){return!!this._firstDoc(HS)};function HS(n){return n.hasWritePending()}we.prototype.whenNothingPending=function(n){var e=this._firstDoc(zh);if(e){e.once("nothing pending",this._nothingPendingRetry(n));return}var t=this._firstQuery(zh);if(t){t.once("ready",this._nothingPendingRetry(n));return}var o=this._firstSnapshotRequest();if(o){o.once("ready",this._nothingPendingRetry(n));return}$o.nextTick(n)},we.prototype._nothingPendingRetry=function(n){var e=this;return function(){$o.nextTick(function(){e.whenNothingPending(n)})}},we.prototype._firstDoc=function(n){for(var e in this.collections){var t=this.collections[e];for(var o in t){var r=t[o];if(n(r))return r}}},we.prototype._firstQuery=function(n){for(var e in this.queries){var t=this.queries[e];if(n(t))return t}},we.prototype._firstSnapshotRequest=function(){for(var n in this._snapshotRequests)return this._snapshotRequests[n]},we.prototype.fetchSnapshot=function(n,e,t,o){typeof t=="function"&&(o=t,t=null);var r=this.nextSnapshotRequestId++,i=new PS(this,r,n,e,t,o);this._snapshotRequests[i.requestId]=i,i.send()},we.prototype.fetchSnapshotByTimestamp=function(n,e,t,o){typeof t=="function"&&(o=t,t=null);var r=this.nextSnapshotRequestId++,i=new NS(this,r,n,e,t,o);this._snapshotRequests[i.requestId]=i,i.send()},we.prototype._handleSnapshotFetch=function(n,e){var t=this._snapshotRequests[e.id];!t||(delete this._snapshotRequests[e.id],t._handleResponse(n,e))},we.prototype._handleLegacyInit=function(n){if(n.protocolMinor)return this._initializeHandshake();this._initialize(n)},we.prototype._initializeHandshake=function(){this.send({a:et.handshake,id:this.id})},we.prototype._handleHandshake=function(n,e){if(n)return this.emit("error",n);this._initialize(e)},we.prototype._handlePingPong=function(n){if(n)return this.emit("error",n);this.emit("pong")},we.prototype._initialize=function(n){if(this.state==="connecting"){if(n.protocol!==1)return this.emit("error",new tc(Qa.ERR_PROTOCOL_VERSION_NOT_SUPPORTED,"Unsupported protocol version: "+n.protocol));if(Hb.map[n.type]!==Hb.defaultType)return this.emit("error",new tc(Qa.ERR_DEFAULT_TYPE_MISMATCH,n.type+" does not match the server default type"));if(typeof n.id!="string")return this.emit("error",new tc(Qa.ERR_CLIENT_ID_BADLY_FORMED,"Client id must be a string"));this.id=n.id,this._setState("connected")}},we.prototype.getPresence=function(n){var e=this,t=$o.digOrCreate(this._presences,n,function(){return new FS(e,n)});return t._wantsDestroy=!1,t},we.prototype.getDocPresence=function(n,e){var t=Nb.channel(n,e),o=this,r=$o.digOrCreate(this._presences,t,function(){return new Nb(o,n,e)});return r._wantsDestroy=!1,r},we.prototype._sendPresenceAction=function(n,e,t){this._addPresence(t);var o={a:n,ch:t.channel,seq:e};return this.send(o),o.seq},we.prototype._addPresence=function(n){$o.digOrCreate(this._presences,n.channel,function(){return n})},we.prototype._handlePresenceSubscribe=function(n,e){var t=$o.dig(this._presences,e.ch);t&&t._handleSubscribe(n,e.seq)},we.prototype._handlePresenceUnsubscribe=function(n,e){var t=$o.dig(this._presences,e.ch);t&&t._handleUnsubscribe(n,e.seq)},we.prototype._handlePresence=function(n,e){var t=$o.dig(this._presences,e.ch);t&&t._receiveUpdate(n,e)},we.prototype._handlePresenceRequest=function(n,e){var t=$o.dig(this._presences,e.ch);t&&t._broadcastAllLocalPresence(n,e)};var zb=$S,jS=Ua;const Vh={err:1001,msg:"user auth error",name:"AuthError"},US={err:1002,msg:"you don't have required permission",name:"PermissionError"},mp={err:1003,msg:"Too many user connected",name:"MaxUserError"},Ya={err:1004,msg:"document server changed, reload it",name:"RequestReloadError"},zS={err:1005,msg:"app id must be at least 2 chars, doc id must be at least 5 chars",name:"DocIdError"},VS={err:1028,msg:"upload file ext not allowed",name:"FileExtError"},Ja="x-live-editor-token",Wh="x-live-editor-base-url",gn=S("auth-connection");function WS(n){try{n()}catch(e){gn.error(e)}}class qS{constructor(e,t){m(this,"connection");m(this,"ws");m(this,"retryCount");m(this,"events",new W5.EventEmitter);m(this,"token",null);m(this,"resourceToken",null);this.url=e,this.reauthFunc=t,this.retryCount=0}getBaseURL(){const e=new URL(this.url);return`${e.protocol==="wss:"?"https:":"http:"}//${e.host}${e.pathname}`}getBase64BaseURL(){return Bs(this.getBaseURL())}async auth(e){g(gn,e.token,"no auth token");const t=`${this.getBaseURL()}/auth`,o=await window.fetch(t,{method:"GET",headers:{[Ja]:e.token,[Wh]:this.getBase64BaseURL()},credentials:"include"});if(o.status!==200)throw new Error("http auth error");return this.token=e.token,await o.json()}async logout(){if(!this.token)return;const e=`${this.getBaseURL()}/logout`;await window.fetch(e,{method:"GET",headers:{[Wh]:Bs(this.getBaseURL())}})}async init(e){const t=await this.auth(e);this.resourceToken=t.read,this.ws=new HB.default(this.url,void 0,{maxReconnectionDelay:2500,minReconnectionDelay:1e3}),this.connection=Object.create(zb.prototype),g(gn,this.connection,"no this.connection"),this.ws,this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:e})};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,i);return}if((s=l==null?void 0:l.message)!=null&&s.startsWith("Cannot invert subtype")){this.emitWriteConflictError(l,i);return}throw l}}},zb.apply(this.connection,[this.ws])}async handleAuthError(){if(this.reauthFunc&&this.retryCount<5){this.retryCount+=1,gn.info(`retrying re-auth attempt no. ${this.retryCount}`);try{if(this.connection){const e=await this.reauthFunc();await this.auth(e),this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:e})}}}catch(e){gn.error(e),setTimeout(()=>this.handleAuthError(),0)}}else gn.error("auth error, cannot retry anymore"),this.emitAuthError(),this.end(!1)}emitAuthError(){const e=new Error(Vh.msg);e.code=Vh.err,this.events.emit("error",e)}emitRequestReloadError(){const e=new Error(Ya.msg);e.code=Ya.err,this.events.emit("requestReloadError",e)}emitWriteConflictError(e,t){e.orgMsg=t,this.events.emit("writeConflictError",e)}emitMaxUsersError(){this.events.emit("maxUsersError"),this.end(!1)}handleMessage(e){const t=e;if(t.a==="pong")return;const o=t.err;if(o===Vh.err)gn.warn("auth error"),this.handleAuthError();else if(o===mp.err)gn.warn(mp.msg),this.emitMaxUsersError();else if(o===Ya.err){gn.warn(Ya.msg);try{this.emitRequestReloadError()}catch(r){gn.error(`error occurred while process reload error: ${JSON.stringify(r)}`)}finally{this.end(!1)}}else gn.error(`unknown message received: ${JSON.stringify(t)}`),this.emitAuthError()}get(e,t){return g(gn,this.connection,"no this.connection"),this.connection.get(e,t)}addEventListener(e,t){e==="error"?this.events.addListener(e,t):(g(gn,this.ws,"no this.ws"),this.ws.addEventListener(e,t))}onWriteConflictError(e){this.events.addListener("writeConflictError",e)}onMaxUsersError(e){g(gn,this.events.listenerCount("maxUsersError")===0,"too many maxUserError listener"),this.events.addListener("maxUsersError",e)}onRequestReloadError(e){g(gn,this.events.listenerCount("requestReloadError")===0,"to many requestReloadError listener"),this.events.addListener("requestReloadError",e)}end(e){var t;this.reauthFunc=void 0,this.events.removeAllListeners(),WS(()=>{var o;return(o=this.connection)==null?void 0:o.close()}),this.connection=void 0,(t=this.ws)==null||t.close(),this.ws=void 0,e&&this.logout()}}S("utils/file");function GS(){function n(){return new Promise(e=>{const t=new FileReader;t.onload=()=>{e(t.result)},t.readAsArrayBuffer(this)})}File.prototype.arrayBuffer=File.prototype.arrayBuffer||n,Blob.prototype.arrayBuffer=Blob.prototype.arrayBuffer||n}GS();async function ZS(n){const t=n.size,o=Math.floor((t+102400-1)/102400),r=new jB.Hash;for(let s=0;s<o;s++){const l=s*102400;let a=l+102400;a>t&&(a=t);const h=await n.slice(l,a,n.type).arrayBuffer();r.update(new Uint8Array(h))}const i=r.digest();return Bs(i)}const ur=S("sharedb-doc/client");class QS{constructor(e,t,o){m(this,"connection");m(this,"auth");m(this,"doc",null);m(this,"reauthFunc");m(this,"clientId",K());m(this,"getDoc",async()=>{const e=o=>new Promise((r,i)=>{o.fetch(s=>{s?i(s):r()})});g(ur,!this.doc,"This websocket has opened a doc."),await this.connection.init(this.auth);const t=this.connection.get(this.auth.appId,this.auth.docId);return this.doc=t,await e(t),ur.debug(t),t});this.auth=e;const r=`${t}/${this.auth.appId}/${this.auth.docId}`;jS.register(Fd.type),this.connection=new qS(r,o),this.reauthFunc=o}editorServer(){const e=this.apiServer(),t=`/${this.auth.appId}/${this.auth.docId}`;return g(ur,e.endsWith(t),`invalid api server: ${e}, ${t}`),e.substr(0,e.length-t.length)}close(e){this.connection.end(e),this.doc=null}on(e,t){this.connection.addEventListener(e,o=>{(e==="error"||this.doc)&&t(o)})}onWriteConflictError(e){this.connection.onWriteConflictError(e)}onMaxUsersError(e){this.connection.onMaxUsersError(e)}onRequestReloadError(e){this.connection.onRequestReloadError(e)}async authOnly(){await this.connection.auth(this.auth)}getResourceToken(){return this.connection.resourceToken}hasDocContainer(){return!!this.doc}apiServer(){const e=this.connection.url;if(e.startsWith("ws://"))return`http://${e.substring(5)}`;if(e.startsWith("wss://"))return`https://${e.substring(6)}`;throw new Error(`invalid server url: ${e}`)}async getFileUrlByHash(e,t,o,r,i){try{const s=`${e}/${t}`,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(e){const o=`${this.apiServer()}/resources`;let r=[];e.forEach(l=>{const a=l.split("|");r.push(...a)}),r=Array.from(new Set(r));const i=r.map(l=>this.getFileUrlByHash(o,l,"",0,{[Ja]:this.connection.token}));return await Promise.all(i)}async uploadFile(e,t,o,r,i){let s=t.size;if(s===0)throw new Error("file is empty");s+=500;const l=v=>{ur.info(`on progress: ${v.loaded}`);let B=v.loaded*100/s;B>100&&(B=100),r(B)},a=await ZS(t),d=await this.getFileUrlByHash(e,a,t.name,t.size,o);if(d)return r(-1),d;let h=e;i!=null&&i.thumbnail&&(h+="/thumbnail");const p=new FormData;p.append("file-size",`${t.size}`),p.append("file-hash",a),p.append("file",t,t.name);const A=await this.request(h,{method:"post",data:p,withCredentials:!0,headers:{...o},onUploadProgress:l});return ur.info(A),r(100),Array.isArray(A.data)?A.data[0]:A.data}async uploadResource(e,t=()=>{},o){const i=`${this.apiServer()}/resources`;g(ur,this.connection.token,"no connection token");const s=await this.uploadFile(i,e,{[Ja]:this.connection.token},t,o);return g(ur,s,"no result"),s}async request(e,t){var i,s;let o=this.connection.token,r;for(let l=0;l<2;l++){const a=t||{};a.url=e,a.headers||(a.headers={}),g(ur,o,"no token"),a.headers={...a.headers,[Ja]:o,[Wh]:this.connection.getBase64BaseURL()};try{return await NB.default(e,a)}catch(d){if(r=d,((i=d==null?void 0:d.response)==null?void 0:i.status)===403&&this.reauthFunc){const h=await this.reauthFunc();if(await this.connection.auth(h),!h.token)throw d;o=h.token;continue}throw(s=d.response)!=null&&s.data&&(d.responseData=d.response.data),d}}throw g(ur,r,"no error"),r}async getVersions(){const t=`${this.apiServer()}/versions?withExtra=true`,r=(await this.request(t)).data.versions;return r.forEach(i=>{i.extra&&(i.extra=JSON.parse(i.extra))}),r}async getVersion(e){const o=`${this.apiServer()}/versions/${e}`,r=await this.request(o);return JSON.parse(r.data.data)}async getLatestVersion(){const t=`${this.apiServer()}/versions/latest`,o=await this.request(t);return JSON.parse(o.data.data)}async getVersionOps(e,t){let r=`${this.apiServer()}/versions/before/${e}?withOp=true`;t!==void 0&&t!==0&&(r+=`&from=${t}`);const i=await this.request(r),s=i.data.ops,l=$B.default(s,h=>!!h.create);let a=null;l!==-1&&(a=s[l],s.splice(0,l+1));let d;return a?(g(ur,a.create,"no createDoc.create"),d=a.create.data):d=JSON.parse(i.data.data),d.blocks||(d.blocks=[]),{doc:d,ops:i.data.ops}}async updateVersionExtra(e,t,o){const i=`${this.apiServer()}/versions/${e}/tags/${t}`;await this.request(i,{method:"post",data:{extra:JSON.stringify(o)}})}async revertVersion(e){const o=`${this.apiServer()}/versions/revert/${e}`;await this.request(o,{method:"post",data:{}})}async createVersion(e,t){const r=`${this.apiServer()}/versions`;return(await this.request(r,{method:"post",data:{publish:t,tag:e}})).data}async recognizeLink(e){const o=`${this.apiServer()}/resources/external/${Bs(e)}`;return(await this.request(o)).data}buildResourceUrl(e,t){if(!e)return"";if(e.startsWith("https:")||e.startsWith("http:")||e.startsWith("file:")||e.startsWith("data:")||e.startsWith("blob:"))return e;let r=`${this.apiServer()}/resources/${encodeURIComponent(e)}`;const i=[];if(t!=null&&t.withToken&&i.push(`token=${this.getResourceToken()}`),t!=null&&t.downloadFileName&&i.push(`&fileName=${encodeURIComponent(t.downloadFileName)}`),i.length>0){const s=i.join("&");r+=`?${s}`}return r}}function YS(){return{blocks:[{id:K(),type:"text",text:[]}],comments:{},meta:{}}}const gp=S("block-ids");class JS{constructor(){m(this,"ids",new Map)}onInsertBlock(e){const t=Array.from(this.ids.keys()).sort((r,i)=>i-r);for(let r=0;r<t.length;r++){const i=t[r];if(i>=e){const s=this.ids.get(i);g(gp,s!==void 0,"old id is not exists"),this.ids.delete(i),this.ids.set(i+1,s)}}const o=K();this.ids.set(e,o)}onDeleteBlock(e){this.ids.delete(e);const t=Array.from(this.ids.keys()).sort((o,r)=>o-r);for(let o=0;o<t.length;o++){const r=t[o];if(r>e){const i=this.ids.get(r);g(gp,i!==void 0,"old id is not exists"),this.ids.delete(r),this.ids.set(r-1,i)}}}getId(e){let t=this.ids.get(e);return t||(t=K(),this.ids.set(e,t)),t}getById(e){return Array.from(this.ids.entries()).find(([,t])=>t===e)}}class KS{constructor(){m(this,"ids",new Map)}getContainerIds(e){let t=this.ids.get(e);return t||(t=new JS,this.ids.set(e,t)),t}onInsertBlock(e,t){this.getContainerIds(e).onInsertBlock(t)}onDeleteBlock(e,t){this.getContainerIds(e).onDeleteBlock(t)}getBlockId(e,t){return this.getContainerIds(e).getId(t)}getBlockIndexById(e){const t=Array.from(this.ids.entries());for(let o=0;o<t.length;o++){const r=t[o],i=r[1].getById(e);if(i)return{containerId:r[0],blockIndex:i[0]}}return g(gp,!1,"fault error: failed to get block index"),{containerId:"error",blockIndex:-1}}}class Vb{constructor(e=new Set,t=new Map){this.deletedKeys=e,this.insertedValues=t}insert(e,t){this.insertedValues.set(e,t)}delete(e){this.deletedKeys.add(e)}toDocBlockDelta(){const e={};return this.insertedValues.forEach((t,o)=>{e[o]=t}),{insert:e,delete:Array.from(this.deletedKeys)}}}const qh=S("op-parse-handler");class XS{constructor(e,t){m(this,"actions",[]);this.outerHandler=e,this.local=t}pushActions(e){if(!e.containerId){this.actions.push(e);return}const o={...e,containerId:(r=>r==="blocks"?"root":r)(e.containerId)};this.actions.push(o)}onDeleteBlock(e,t){this.pushActions({type:"deleteBlock",containerId:e,blockIndex:t})}onInsertBlock(e,t,o){this.pushActions({type:"insertBlock",containerId:e,blockIndex:t,data:o})}onDeleteBlockData(e,t,o){this.pushActions({type:"deleteBlockData",containerId:e,blockIndex:t,key:o})}onInsertBlockData(e,t,o,r){this.pushActions({type:"insertBlockData",containerId:e,blockIndex:t,key:o,value:r})}onUpdateBlockText(e,t,o){this.pushActions({type:"updateBlockText",containerId:e,blockIndex:t,richTextData:o})}onDeleteContainer(e){this.pushActions({type:"deleteContainer",containerId:e})}onCreateContainer(e,t){this.pushActions({type:"createContainer",containerId:e,data:t})}onDeleteComment(e){this.pushActions({type:"deleteComment",commentId:e})}onCreateComment(e){this.pushActions({type:"createComment",commentId:e})}onUpdateComment(e){this.pushActions({type:"updateComment",commentId:e})}end(){const e=this.actions,t=new Set,o=new Map,r=new KS,i=e.filter(s=>s.type==="deleteBlock"||s.type==="deleteBlockData");for(const s of i)if(s.type==="deleteBlock"){const l=s,a=r.getBlockId(l.containerId,l.blockIndex);r.onDeleteBlock(l.containerId,l.blockIndex);const d=o.get(a);d&&(qh.debug(`ignore update object data before delete block: ${JSON.stringify(d)}`),o.delete(a));const h=`${l.containerId}-${l.blockIndex}`;t.add(h),this.outerHandler.onDeleteBlock(l.containerId,l.blockIndex,this.local)}else if(s.type==="deleteBlockData"){const l=s,a=`${l.containerId}-${l.blockIndex}`;if(t.has(a)){qh.warn("delete block data after delete block, ignore it");continue}const d=r.getBlockId(l.containerId,l.blockIndex);let h=o.get(d);h||(h=new Vb,o.set(d,h)),h.delete(l.key)}else g(qh,!1,`invalid action type, ${s.type}`);this.actions.forEach(s=>{if(s.type==="deleteContainer"){const l=s;this.outerHandler.onDeleteContainer(l.containerId,this.local)}else if(s.type==="deleteComment"){const l=s;this.outerHandler.onDeleteComment(l.commentId,this.local)}}),this.actions.forEach(s=>{if(s.type==="createContainer"){const l=s;this.outerHandler.onCreateContainer(l.containerId,l.data,this.local)}}),this.actions.forEach(s=>{if(s.type==="insertBlock"){const l=s;this.outerHandler.onInsertBlock(l.containerId,l.blockIndex,l.data,this.local)}else if(s.type==="insertBlockData"){const l=s,a=r.getBlockId(l.containerId,l.blockIndex);let d=o.get(a);d||(d=new Vb,o.set(a,d)),d.insert(l.key,l.value)}else if(s.type==="updateBlockText"){const l=s;this.outerHandler.onUpdateBlockText(l.containerId,l.blockIndex,l.richTextData,this.local)}else if(s.type==="createComment"){const l=s;this.outerHandler.onCreateComment(l.commentId,this.local)}else if(s.type==="updateComment"){const l=s;this.outerHandler.onUpdateComment(l.commentId,this.local)}}),Array.from(o.entries()).forEach(([s,l])=>{const{containerId:a,blockIndex:d}=r.getBlockIndexById(s);qh.debug(`update block data: ${a}, ${d}, ${JSON.stringify(l.toDocBlockDelta())}`),this.outerHandler.onUpdateBlockData(a,d,l.toDocBlockDelta(),this.local)})}}const Rt=S("op-parser");class Wb{}class pp{constructor(e){m(this,"key");this.key=e}}function eL(n,e,t){const o=e.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 a=o[l];if(!Array.isArray(a)||a.length!==2||typeof a[0]!="string")return!1;const h=a[1];if(typeof h!="object"||h.i===void 0||Object.keys(h).length!==1)return!1}const s=i.i;g(Rt,s.id,"block id is required"),g(Rt,s.type,"block type is required");for(let l=1;l<o.length;l++){const a=o[l],d=a[0],h=a[1];s[d]=h.i}return t.onInsertBlock(n,r,s),!0}function Cp(n,e,t,o){if(t==="upsert"&&eL(n,e,o))return;g(Rt,Array.isArray(e),`invalid block op: ${n}, ${JSON.stringify(e)}`);const r=e.concat(),i=r[0];r.shift();const s=[];for(;r.length>0;){const l=r[0];if(l==="text"){const a=r[1];if(g(Rt,typeof a=="object",`invalid block op: ${n}, ${JSON.stringify(e)}`),g(Rt,a.et==="rich-text",`invalid block op: ${n}, ${JSON.stringify(e)}`),r.splice(0,2),t==="upsert"){const h=a.e;o.onUpdateBlockText(n,i,h)}g(Rt,r.length===0,`invalid block ops.length !== 0, ${JSON.stringify(r)}`)}else if(Array.isArray(l)){g(Rt,l.length===2,`invalid block op: data.length !== 2, ${JSON.stringify(l)}`);const a=l[0];g(Rt,typeof a=="string",`invalid block op: key ${JSON.stringify(a)}`);const d=l[1];if(a==="text"){if(g(Rt,typeof d=="object",`invalid opData type, ${JSON.stringify(d)}`),d.i&&t==="upsert"&&o.onInsertBlockData(n,i,a,d.i),d.r&&t==="remove"&&o.onDeleteBlockData(n,i,a),d.et==="rich-text"&&t==="upsert"){const p=d.e;o.onUpdateBlockText(n,i,p)}}else t==="remove"&&d.r&&s.push(new pp(a)),t==="upsert"&&d.i&&o.onInsertBlockData(n,i,a,d.i);r.shift()}else if(typeof l=="object"){const a=l;t==="remove"&&a.r&&s.push(new Wb),t==="upsert"&&a.i&&o.onInsertBlock(n,i,a.i),r.shift()}else{g(Rt,typeof l=="string","data is not string"),g(Rt,l!=="text","data !== 'text'"),g(Rt,r.length===2,`invalid block op: ops.length !== 2, ${JSON.stringify(r)}`);const a=l,d=r[1];t==="remove"&&d.r&&s.push(new pp(a)),t==="upsert"&&d.i&&o.onInsertBlockData(n,i,a,d.i),r.splice(0,2)}}s.reverse(),s.forEach(l=>{l instanceof Wb?o.onDeleteBlock(n,i):l instanceof pp?o.onDeleteBlockData(n,i,l.key):g(Rt,!1,`invalid action type: ${typeof l}, ${JSON.stringify(l)}`)})}function tL(n,e,t){Rt.warn(`unsupported meta op, ${JSON.stringify(n)}`)}function nL(n,e,t){const o=n[1],r=n[2];g(Rt,o,`invalid comment op, no commentId: ${JSON.stringify(n)}`),g(Rt,r,`invalid comment op, no actions: ${JSON.stringify(n)}`),typeof r=="string"?Rt.error(`unknown comment op, ${JSON.stringify(n)}`):r.i&&r.r?e==="upsert"&&t.onUpdateComment(o):r.i?e==="upsert"&&t.onCreateComment(o):r.r?e==="remove"&&t.onDeleteComment(o):Rt.error(`unknown comment op, ${JSON.stringify(n)}`)}function Ap(n,e,t){const o=n[0];if(Array.isArray(o)){o.forEach(s=>{Ap(s,e,t)});return}const r=o;if(g(Rt,typeof r=="string",`invalid container id: ${JSON.stringify(n)}`),r==="meta"){tL(n);return}if(r==="comments"){nL(n,e,t);return}const i=r;if(Array.isArray(n[1]))e==="remove"?n.slice(1).reverse().forEach(s=>{Cp(i,s,e,t)}):n.slice(1).forEach(s=>{Cp(i,s,e,t)});else if(typeof n[1]=="object"){const s=n[1];s.r&&e==="remove"&&t.onDeleteContainer(i),s.i&&e==="upsert"&&t.onCreateContainer(i,s.i)}else g(Rt,typeof n[1]=="number",`invalid ops[1], not a number: ${JSON.stringify(n)}`),Cp(i,n.slice(1),e,t)}function qb(n,e,t){const o=new XS(e,t);for(let r=0;r<2;r++){const i=r===0?"remove":"upsert",s=me.default(n),l=s[0];Array.isArray(l)?s.forEach(a=>{Ap(a,i,o)}):Ap(s,i,o)}o.end()}const oL=S("sharedb-comments");function bp(n){const e=n.blocks;g(oL,e,"no comment blocks");const t={blocks:{root:e},meta:{},comments:{}};return Object.entries(n).forEach(([o,r])=>{Array.isArray(r)&&(t.blocks[o]=r)}),me.default(t)}function Gb(n){const{id:e,groupId:t,userId:o,displayName:r,avatarUrl:i,abstract:s,created:l,modified:a}=n;return{id:e,groupId:t,userId:o,displayName:r,avatarUrl:i,abstract:s,created:l,modified:a}}function vp(n,e){const t=jD(e),{comments:o,meta:r,blocks:i,...s}=t,l={...n,blocks:i,...s},a=me.default(l);return delete a.children,a}const at=S("sharedb-doc/doc-container"),Zb="ot-json1";Fd.type.registerSubtype(UD.type),Fd.type.name=Zb,Fd.type.invert=null;class Ka extends fa{constructor(t,o,r=!0){super();m(this,"doc");m(this,"client");m(this,"localPresence");m(this,"remoteCaretHandler",new $D);m(this,"batching",0);m(this,"status","clean");m(this,"disableLogout");m(this,"destroyed",!1);m(this,"handleNothingPending",()=>{this.setStatus("clean")});m(this,"handleCreate",()=>{this.handleReload("doc created")});m(this,"handleDel",()=>{});m(this,"handleReload",t=>{this.callbacks.forEach(o=>{var r;return(r=o.onRequestReload)==null?void 0:r.call(o,t)})});m(this,"handleReset",async t=>{const o=new Error(`reset doc: ${t}`);o.code="ResetDoc",this.callbacks.forEach(r=>{var i;return(i=r.onError)==null?void 0:i.call(r,o)}),this.destroy()});m(this,"handleWriteConflictError",t=>{this.handleReset(`write conflict: ${t.message}, ${JSON.stringify(t.orgMsg)}`)});m(this,"insertObject",async(t,o,r)=>{const i=[t,o,{i:r}];return this.submitOp(i)});m(this,"deleteObject",async(t,o)=>{const r=[t,o,{r:!0}];return this.submitOp(r)});m(this,"replaceObject",async(t,o,r)=>{const i=[t,o,{r:!0,i:r}];return this.submitOp(i)});m(this,"updateObject",async(t,o,r)=>{const i=this.data()[t][o],s=[t,o];return Object.entries(r).forEach(([l,a])=>{if(!ua.default(i[l],a))if(i[l]===void 0){if(a!=null){const d={i:a};s.push([l,d])}}else if(a==null){const d={r:!0};s.push([l,d])}else{const d={r:!0,i:a};s.push([l,d])}}),Object.entries(i).forEach(([l,a])=>{if((r[l]===void 0||r[l]===null)&&a!==void 0){const d={r:!0};s.push([l,d])}}),s.length<=2?Promise.resolve():this.submitOp(s)});m(this,"broadcastMessage",async t=>{const o={type:"custom",data:t,clientId:this.client.clientId};this.localPresence&&this.localPresence.submit(o)});m(this,"data",()=>this.doc.data);m(this,"submitOp",async t=>new Promise((o,r)=>{if(this.destroyed){at.warn("submit op after destroyed");return}this.setStatus("dirty"),this.doc.submitOp(t,{},i=>{i?(at.error(`invalid op, ${i.message}, ${JSON.stringify(t)}`),r(i),at.error("Transform detected write conflict, reload editor"),this.handleReset("write conflict")):o()}),this.doc.data||(at.error("no data after submit op, may be the submitted op is invalid"),this.handleReset(`invalid op, ${JSON.stringify(t)}`))}));m(this,"createDoc",async t=>new Promise((o,r)=>{this.doc.create(t,Zb,i=>{i?r(i):o()})}));m(this,"submitInsertChildContainer",async(t,o)=>{const r=[Ni(t),{i:o}];return this.submitOp(r)});m(this,"submitDeleteChildContainer",async t=>{const o=[Ni(t),{r:!0}];return this.submitOp(o)});m(this,"submitInsertBlock",async(t,o,r)=>{const i=[Ni(t),o,{i:r}];return this.submitOp(i)});m(this,"submitDeleteBlock",async(t,o)=>{const r=[Ni(t),o,{r:!0}];return this.submitOp(r)});m(this,"submitUpdateBlockData",async(t,o,r)=>{if(r.delete.length===0&&Object.keys(r.insert).length===0)return Promise.resolve();const i=[Ni(t),o],s=new Set(r.delete);Object.entries(r.insert).forEach(([a,d])=>{if(s.has(a)){const h={r:!0,i:d};i.push([a,h])}});const l=new Set(Object.keys(r.insert));return r.delete.forEach(a=>{if(l.has(a))return;const d={r:!0};i.push([a,d])}),Object.entries(r.insert).forEach(([a,d])=>{if(s.has(a))return;const h={i:d};i.push([a,h])}),this.submitOp(i)});m(this,"submitUpdateRichText",async(t,o,r)=>{const i=[Ni(t),o,"text",{e:r,et:"rich-text"}];return this.submitOp(i)});m(this,"handleOp",(t,o,r)=>{if(this.destroyed){at.warn("handleOp: destroyed");return}qb(t,this,!!o)});this.client=t,this.doc=o,this.doc.preventCompose=!0,this.disableLogout=r,this.registerCallback(this.remoteCaretHandler)}beginBatchUpdate(){return this.doc.preventCompose=!1,this.batching++,this.batching}endBatchUpdate(){return this.batching--,g(at,this.batching>=0,"invalid call beginBatchUpdate/endBatchUpdate"),this.batching===0&&(this.doc.preventCompose=!0),this.batching}static async load(t){try{const o=new QS(t.auth,t.serverUrl,t.reauthFunc),r=await o.getDoc(),i=new Ka(o,r,t.disableLogout);if(r.type===null){if(t.autoCreateDoc===!1){const s=new Error("doc not exists");throw s.code="DocNotExists",s}await i.createDoc(t.templateData||YS())}return await i.initPresence(),await i.subscribe(),i.initEvents(),i}catch(o){throw at.error(o),at.error(`failed to load doc: ${JSON.stringify(o)}`),o}}setStatus(t){this.status!==t&&(this.status=t,this.callbacks.forEach(o=>{var r;return(r=o.onStatusChanged)==null?void 0:r.call(o,t)}))}initEvents(){this.doc.on("nothing pending",this.handleNothingPending),this.doc.on("create",this.handleCreate),this.doc.on("del",this.handleDel),this.client.onWriteConflictError(this.handleWriteConflictError)}clearEvents(){this.doc.off("nothing pending",this.handleNothingPending),this.doc.off("create",this.handleCreate),this.doc.off("del",this.handleDel)}initPresence(){return new Promise((t,o)=>{if(this.localPresence)t();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(K()),t())})}})}subscribe(){return new Promise((t,o)=>{this.doc.subscribe(r=>{r?o(r):(this.doc.on("op",this.handleOp),t())})})}toJSON(){return ja(this.data())}getContainerBlocks(t){const o=this.data();g(at,o,"no doc data");const r=o[Ni(t)];return g(at,r,`no container data: ${t}`),me.default(r)}getBlockData(t,o){const r=this.data();g(at,r,"no doc data");const i=r[Ni(t)];g(at,i,`no container data: ${t}`);const s=i[o];return g(at,s,`no block data: ${o}`),me.default(s)}localInsertBlock(t,o,r){return this.submitInsertBlock(t,o,r),this.getBlockData(t,o)}localDeleteBlock(t,o){const r=this.getBlockData(t,o);return this.submitDeleteBlock(t,o),r}localUpdateBlockText(t,o,r){const i=this.getBlockData(t,o);g(at,i.text,"no block text");const s=me.default(i.text);this.submitUpdateRichText(t,o,r);const l=ln.apply(s,r);return g(at,l,"no block text"),l}localUpdateBlockData(t,o,r){const i=me.default(this.getBlockData(t,o));return this.submitUpdateBlockData(t,o,r),i}localInsertChildContainer(t,o){this.submitInsertChildContainer(t,o)}localDeleteChildContainers(t){this.beginBatchUpdate(),t.forEach(o=>{this.submitDeleteChildContainer(o)}),this.endBatchUpdate()}getComments(){return Object.values(this.data().comments).map(o=>Gb(o))}getComment(t){return this.data().comments[t]}getCommentDoc(t){const o=this.data().comments[t];return bp(o)}localCreateComment(t,o){const r=vp(t,o),s=["comments",r.id,{i:r}];return this.submitOp(s)}localDeleteComment(t){const o=["comments",t,{r:!0}];return this.submitOp(o)}localUpdateComment(t,o){const r=vp(t,o),i=["comments",t.id,{r:!0,i:r}];return this.submitOp(i)}destroy(){var t;this.destroyed=!0,this.clearEvents(),this.clearCallbacks(),this.doc.destroy(),(t=this.localPresence)==null||t.destroy(),this.client.close(!this.disableLogout),this.remoteCaretHandler.destroy()}onDeleteBlock(t,o,r){g(at,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var s;return(s=i.onDeleteBlock)==null?void 0:s.call(i,Xl(t),o,r)})}onInsertBlock(t,o,r,i){g(at,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onInsertBlock)==null?void 0:l.call(s,Xl(t),o,r,i)})}onUpdateBlockData(t,o,r,i){g(at,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,Xl(t),o,r,i)})}onUpdateBlockText(t,o,r,i){g(at,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockText)==null?void 0:l.call(s,Xl(t),o,r,i)})}onDeleteContainer(t,o){g(at,this.callbacks.length>0,"no callbacks"),g(at,t!=="root","should not delete root container in doc"),this.callbacks.forEach(r=>{var i;return(i=r.onDeleteChildContainer)==null?void 0:i.call(r,Xl(t),o)})}onCreateContainer(t,o,r){g(at,this.callbacks.length>0,"no callbacks"),g(at,t!=="root","should not create root container in doc"),this.callbacks.forEach(i=>{var s;return(s=i.onInsertChildContainer)==null?void 0:s.call(i,Xl(t),o,r)})}onDeleteComment(t,o){g(at,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onDeleteComment)==null?void 0:i.call(r,t,o)})}onCreateComment(t,o){g(at,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onCreateComment)==null?void 0:i.call(r,t,o)})}onUpdateComment(t,o){g(at,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(r=>{var i;return(i=r.onUpdateComment)==null?void 0:i.call(r,t,o)})}onCustomMessage(t){const o=t;(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:t,clientId:"-"};this.onCustomMessage(r)})}async addResources(t){return await this.client.getFileUrlsByHashes(t)}async uploadResource(t,o){var i;return{resourceId:await this.client.uploadResource(t,(i=o==null?void 0:o.onProgress)!=null?i:()=>{})}}buildResourceUrl(t,o){return this.client.buildResourceUrl(t,o)}request(t,o){return this.client.request(t,o)}getUser(){const t=this.client.clientId,{permission:o,userId:r,displayName:i,avatarUrl:s}=this.client.auth;return{permission:o,clientId:t,userId:r,displayName:i,avatarUrl:s,rainbowIndex:0}}getRemoteUsers(){return this.remoteCaretHandler.remoteUsers}getVersionHelper(){return this}getVersions(){return this.client.getVersions()}async getVersion(t){const o=await this.client.getVersion(t);return ja(o)}async getLatestVersion(){const t=await this.client.getLatestVersion();return ja(t)}async getHistoryData(t,o){const{doc:r,ops:i}=await this.client.getVersionOps(t,o),s=i.map(l=>({user:l.meta.createdBy,data:l}));return{doc:ja(r),historyData:s}}async getVersionData(t,o){const{doc:r,ops:i}=await this.client.getVersionOps(t,o);return{doc:ja(r),versionData:i}}async updateVersionExtra(t,o,r){await this.client.updateVersionExtra(t,o,r)}revertVersion(t){return this.client.revertVersion(t)}createVersion(t,o){return this.client.createVersion(t,o)}async recognizeLink(t){return this.client.recognizeLink(t)}parseHistoryData(t,o){qb(t.data.op,o,!0)}getServerMeta(){return{appId:this.client.auth.appId,docId:this.client.auth.docId,serverId:this.client.apiServer()}}}S("remote-cursor");class Qb{constructor(e){m(this,"handleDocSelectionChange",()=>{this.broadcastCaretPos()});m(this,"broadcastCaretPos",Ht.default(()=>{const e={type:"caret",userId:this.editor.doc.getUser().userId,range:this.editor.selection.range.toDocRange()};this.editor.doc.broadcastMessage(e)},300));m(this,"handleRemoteCaretsChanged",e=>{e.forEach(t=>{const o=this.editor.findBlockById(t);o&&this.editor.reloadBlock(o)})});this.editor=e,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 Yb=S("remote-cursor-decorator");class yp{decorateText(e,t,o){const r=e.doc.getRemoteUsers();if(!r)return{};const i=new Map,{containerId:s,blockIndex:l}=t[t.length-1];g(Yb,typeof s=="string","invalid path containerId"),g(Yb,typeof l=="number","invalid path blockIndex");const a=e.doc.getBlockData(s,l),d=rn(o);return r.getSimpleCursors(a.id).forEach((p,A)=>{A>d&&(A=d);const v=p.map(D=>({id:K(),type:"remote-cursor",name:D.user.displayName,time:D.time,rainbowIndex:D.user.rainbowIndex})),B=i.get(A);B?B.push(...v):i.set(A,v)}),{insertions:i}}}class Jb extends bt.TypedEmitter{constructor(e){super(),this.editor=e,this.editor.doc.registerCallback(this)}handleChild(e,t,o){if(Xe($r(this.editor,e)))return;const r=this.editor.getBlockByIndex(e,t),i=oe(this.editor.getContainerById(e));i&&this.emit("change",this.editor,i,r,o)}onUpdateBlockData(e,t){this.handleChild(e,t,"data-change")}onUpdateBlockText(e,t){this.handleChild(e,t,"text-change")}destroy(){this.editor.doc.unregisterCallback(this)}}function rL(n,e){n.addCustom("child-block-tracker",()=>new Jb(n)).addListener("change",e)}function iL(n,e){n.addCustom("child-block-tracker",()=>new Jb(n)).removeListener("change",e)}const tne="",sL={colorPalette:{colorDesc:"\u5B57\u4F53\u989C\u8272",name:"\u6587\u672C\u989C\u8272",backgroundDesc:"\u80CC\u666F\u989C\u8272",reset:"\u6062\u590D\u9ED8\u8BA4"},search:{emptyTips:"\u6682\u65E0\u641C\u7D22\u7ED3\u679C"}},lL={colorPalette:{colorDesc:"Text color",name:"Text color",backgroundDesc:"Background color",reset:"Restore default values"},search:{emptyTips:"No results found"}},cL={colorPalette:{colorDesc:"\u30D5\u30A9\u30F3\u30C8\u306E\u8272",name:"\u30C6\u30AD\u30B9\u30C8\u306E\u8272",backgroundDesc:"\u80CC\u666F\u8272",reset:"\u30C7\u30D5\u30A9\u30EB\u30C8\u306B\u623B\u3059"},search:{emptyTips:"\u691C\u7D22\u7D50\u679C\u304C\u3042\u308A\u307E\u305B\u3093"}};R.mergeLang({"zh-CN":sL,"en-US":lL,"js-JP":cL});const nne="";S("button");function ji(n,e,t,o,r){const i=w("button",["editor-button"],null);return i.setAttribute("data-button-id",n),r&&i.setAttribute(`data-editor-tooltip-${r}`,e),t?typeof t=="string"?t.startsWith("<")?i.innerHTML=t:i.innerText=t:i.appendChild(t):i.innerText=e,o&&(o.indexOf("checked")!==-1&&W(i,"checked"),o.indexOf("disabled")!==-1&&(i.disabled=!0)),i}function Kb(n,e,t){t?n.setAttribute(`data-editor-tooltip-${t}`,e):n.innerText=e}const one="",nc=S("ui-command-bar-base"),aL={itemElementTag:"div",tippyArrow:!1},J2=class extends bt.TypedEmitter{constructor(t,o,r){var i,s;super();m(this,"content");m(this,"items");m(this,"subBar",null);m(this,"parentItem",null);m(this,"closeable",null);m(this,"closeReason",null);m(this,"options");m(this,"id");m(this,"header",null);m(this,"footer",null);m(this,"handleDocumentKeydown",t=>{if(!!this.isVisible&&!t.isComposing&&!Ls(t.target)){if(this.subBar){this.subBar.handleDocumentKeydown(t);return}if(this.items.length!==0){if(t.key==="Escape"){this.close("cancelBar");return}if(t.key==="ArrowUp"){const o=this.getPrevItemIndex(this.getSelectedItemIndex());this.startPauseMouseEnter(),this.selectItem(this.items[o].id),t.preventDefault(),t.stopPropagation()}else if(t.key==="ArrowDown"){const o=this.getNextItemIndex(this.getSelectedItemIndex());this.startPauseMouseEnter(),this.selectItem(this.items[o].id),t.preventDefault(),t.stopPropagation()}else if(t.key==="ArrowRight"){const o=this.getSelectedItem();o&&o.children&&this.showSubCommandBar(o.childrenMenuId)}else if(t.key==="ArrowLeft")this.parentItem&&this.close("switchItem");else if(t.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)}}}});m(this,"handleDocumentMouseDown",t=>{if(t.target instanceof Element&&!this.isInCommandBar(t.target)){const o=this.listeners("closing");for(let r=0;r<o.length;r++)if(o[r](this,t)===!1)return;this.close("clickBackground")}});m(this,"handleHidden",()=>{this.closeReason!=="fromHover"&&this.emit("close",this),this.close(null),BC(this.id)});m(this,"handleShow",()=>{this.popper&&(this.popper.setAttribute("data-command-bar-id",this.id),this.options.classes&&W(this.popper,...this.options.classes),this.options.refuseOverflow&&this.popper.classList.add("reference-hidden")),this.emit("show",this),this.options.disablePageScroll&&wC(this.id)});m(this,"lastEnterPauseTime",0);m(this,"startPauseMouseEnter",()=>{this.lastEnterPauseTime=Date.now()});m(this,"handleItemMouseEnter",t=>{if(Date.now()-this.lastEnterPauseTime<100)return;const o=this.getParentCommandItemElement(t.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)});m(this,"handleItemMouseLeave",t=>{var r,i;const o=this.getParentCommandItemElement(t.target);!o||((i=(r=this.subBar)==null?void 0:r.parentItem)==null?void 0:i.id)!==this.getItemElementId(o)&&(te(o,"selected"),this.emit("selectionChange",this,""))});m(this,"handleItemClick",t=>{const o=this.getParentCommandItemElement(t.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("clickItem"))}});m(this,"handleWheel",t=>{if(!this.options.disablePageScroll&&!document.querySelector(".editor-disable-scroll"))return;const o=t.target;if(!o||!(o instanceof Node))return;const r=o instanceof HTMLElement?o:o.parentElement;if(!r)return;const i=oo(r);if(!Ke(this.content,i)){t.stopPropagation(),t.preventDefault();return}t.deltaY<0?i.scrollTop===0&&(t.stopPropagation(),t.preventDefault()):t.deltaY>0&&i.scrollTop+i.clientHeight>=i.scrollHeight&&(t.stopPropagation(),t.preventDefault())});this.id=(i=r==null?void 0:r.id)!=null?i:K(),this.options={...aL,...r},this.items=t,this.parentItem=(s=r==null?void 0:r.parentItem)!=null?s:null,this.closeable=o!=null?o:null,this.content=this.createCommandBarContent(t)}close(t){this.closeReason=t,this.subBar&&this.subBar.close(t),document.removeEventListener("keydown",this.handleDocumentKeydown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}click(t,o){this.emit("click",this,t,o)}createPopperOptions(){var r,i;const t={modifiers:[]},o=this.options.overflowBoundary;return o&&((r=t==null?void 0:t.modifiers)==null||r.push({name:"flip",options:{boundary:o,fallbackPlacements:["top","bottom"]}})),this.options.padding&&((i=t==null?void 0:t.modifiers)==null||i.push({name:"preventOverflow",options:{padding:this.options.padding}})),t}destroy(){var t;this.close(null),this.removeAllListeners(),(t=this.subBar)==null||t.destroy(),this.subBar=null,this.closeable=null,this.content.removeEventListener("wheel",this.handleWheel)}get isSubCommandBar(){return!!this.parentItem}updateItems(t){var r;this.subBar&&t.findIndex(s=>{var l,a;return s.id===((a=(l=this.subBar)==null?void 0:l.parentItem)==null?void 0:a.id)})===-1&&((r=this.subBar)==null||r.destroy(),this.subBar=null),this.items=t;const o=this.createCommandBarContent(t);this.content.innerHTML="",Array.from(o.children).forEach(i=>{this.content.appendChild(i)})}get popper(){return this.content.closest("[data-tippy-root]")}getSelectedItemIndex(){const t=this.getSelectedItem();return t?this.items.indexOf(t):-1}getPrevItemIndex(t){if(t<=0)return this.items.length-1;let o=t-1;for(;;){const r=this.items[o],i=r.type,l=!(r.states&&r.states.indexOf("disabled")!==-1);if(i!=="separator"&&i!=="section"&&l)return o;if(o-=1,o<=0)return this.items.length-1}}getNextItemIndex(t){let o=t+1;for(;;){if(!this.items[o])return this.getNextItemIndex(-1);const r=this.items[o],i=r.type,l=!(r.states&&r.states.indexOf("disabled")!==-1);if(i!=="separator"&&i!=="section"&&l)return o;if(o+=1,o>this.items.length-1)return 0}}clearSelectedItem(){const t=this.getSelectedItem();if(!t)return;const o=this.getItemElementById(t.id);o&&te(o,"selected")}selectItem(t){const o=this.getSelectedItem();if(o){if(o.id===t)return;const i=o.id,s=this.getItemElementById(i);s&&te(s,"selected")}const r=this.getItemElementById(t);r?(W(r,"selected"),this.emit("selectionChange",this,r.getAttribute("data-id")||""),r.scrollIntoView({block:"nearest"})):this.emit("selectionChange",this,"")}showSubCommandBar(t){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("switchItem");return}this.subBar.destroy(),this.subBar=null}if(!o.children)return;const r=this.getItemElementById(o.id);if(!r)return;const i=J2.createSubCommandBar(o,(l=this.closeable)!=null?l:this,t?{id:t}:{});this.subBar=i,this.subBar.on("click",(a,d,h)=>{this.emit("click",a,d,h)}),this.subBar.on("close",()=>{var a;(a=this.subBar)==null||a.destroy(),this.subBar=null,te(r,"active")}),o.beforePopup&&o.beforePopup(i),this.subBar.manualShow(r,this.getSubBarOptions(o)),W(r,"active")}isInCommandBar(t){if(!t||!(t instanceof Node))return!1;const o=this.getCommandBarRoot();return o&&Ke(o,t)||Ke(this.content,t)?!0:this.subBar?this.subBar.isInCommandBar(t):!1}createCommandItem(t){var i,s,l,a;let o=(i=this.options.itemElementTag)!=null?i:"div";t.element&&(o="div");const r=w(o,["command-item"],null);return r.setAttribute("data-id",t.id),t.type==="separator"?r.classList.add("separator"):t.type==="section"?(r.classList.add("section","text"),t.element&&(typeof t.element=="function"?r.appendChild(t.element(t)):r.appendChild(t.element))):((s=t.states)!=null&&s.includes("selected")&&r.classList.add("selected"),(l=t.states)!=null&&l.includes("checked")&&r.classList.add("checked"),(a=t.states)!=null&&a.includes("disabled")&&r.classList.add("disabled"),r.onclick=this.handleItemClick,r.onmouseenter=this.handleItemMouseEnter,r.onmouseleave=this.handleItemMouseLeave,t.element?typeof t.element=="function"?r.appendChild(t.element(t)):r.appendChild(t.element):r.classList.add("standard")),this.initItemElement(t,r),r}getItemById(t){const o=this.items.find(r=>r.id===t);return g(nc,o,`can not find command item for id: ${t}`),o}getSelectedItem(){const t=this.content.querySelector(":scope >.editor-command-bar >.command-item.selected");if(t){const o=this.getItemElementId(t),r=this.items.find(i=>i.id===o);return g(nc,r,`can not find command item for id: ${o}`),r}return null}getItemElementId(t){const o=t.getAttribute("data-id");return g(nc,o,"no data-id attribute"),o}getItemElementById(t){const o=this.content.querySelector(`:scope >.editor-command-bar > .command-item[data-id="${t}"]`);return g(nc,o,`no exists command item, id=${t}`),o}getParentCommandItemElement(t){if(!t||!(t instanceof Element))return null;if(xe(t,"command-item"))return t;const o=t.closest(".command-item");return o||null}createCommandBarContent(t){this.content&&this.content.removeEventListener("wheel",this.handleWheel);const o=w("div",["editor-command-bar-root"],null);if(this.options.header){const i=w("div",["editor-command-bar-header"],null);if(this.options.header instanceof Function){const s=this.options.header();s&&i.appendChild(s)}else i.appendChild(this.options.header);this.header=i,this.header&&o.appendChild(this.header)}const r=w("div",["editor-command-bar"],o);if(t.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.options.footer){const i=w("div",["menu-item","editor-command-bar","footer"],null);if(this.options.footer instanceof Function){const s=this.options.footer();s&&i.appendChild(s)}else i.appendChild(this.options.footer);this.footer=i,this.footer&&o.appendChild(this.footer)}return(this.options.header||this.options.footer)&&W(o,"scrollable-bar"),this.initCommandBarElement(r),o.addEventListener("wheel",this.handleWheel,{passive:!1}),o}getSubBarOptions(t){var o;return{placement:(o=t.childrenPlacement)!=null?o:"right-start"}}static registerManualCommandBar(t,o){this.commandBarCreators.set(t,o)}static createSubCommandBar(t,o,r){var l;g(nc,t.children&&t.children.length>0,"no item children");const i=(l=t.childrenType)!=null?l:"menu",s=this.commandBarCreators.get(i);return g(nc,s,`no creator for command type: ${i}`),s(t,o,r)}static hasExistsCommandBar(){return!!document.querySelector("[data-command-bar-id]")}};let Ui=J2;m(Ui,"commandBarCreators",new Map),S("ui-command-bar");class Gh extends Ui{constructor(){super(...arguments);m(this,"tippyInstance",null)}manualShow(t,o){var r,i;if(!this.isVisible){if(this.tippyInstance&&(this.tippyInstance.destroy(),this.tippyInstance=null),this.tippyInstance=UB.default(t,{sticky:!0,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],popperOptions:this.createPopperOptions()}),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(t){var o;super.close(t),this.isVisible&&((o=this.tippyInstance)==null||o.hide())}destroy(){var t;(t=this.tippyInstance)==null||t.destroy(),this.tippyInstance=null,super.destroy()}getCommandBarRoot(){return this.content.closest("[data-tippy-root]")}get isVisible(){var t,o;return(o=(t=this.tippyInstance)==null?void 0:t.state.isVisible)!=null?o:!1}get popper(){return this.content.closest("[data-tippy-root]")}}const Xb=S("ui-base");class Xa extends Gh{constructor(e,t){var i;const r=[{id:(i=t==null?void 0:t.id)!=null?i:`popup-${K()}`,name:"",element:e}];super(r,void 0,{disablePageScroll:!0})}initCommandBarElement(e){W(e,"popper")}initItemElement(e,t){}get popupContent(){const e=this.items[0];g(Xb,e,"no dialog item");const t=typeof e.element=="function"?e.element(e):e.element;return g(Xb,t,"no item element"),t}}const zi=S("filterable-list");function ev(n){var t,o;const e=w("div",["list-item"],null);return e.setAttribute("data-id",n.id),e.appendChild(w("div",["list-item-text"],null,n.name)),(t=n.states)!=null&&t.includes("selected")&&W(e,"selected"),(o=n.states)!=null&&o.includes("disabled")&&W(e,"disabled"),e}function tv(n){const e=w("div",["list-root"],null);return n.forEach(t=>{e.appendChild(ev(t))}),n.length||e.appendChild(ev({id:"placeholder",states:["disabled"],name:R.t("search.emptyTips")})),e}function nv(n,e){let t=n;return e&&(t=n.map(o=>({...o,states:o.id===e?["selected"]:void 0}))),t}function uL(n,e){const t=w("div",["filterable-list"],null),o=w("div",["filter"],t),r=w("div",["filter-container"],o),i=w("input",["filter-input"],r);e&&e.placeholder&&(i.placeholder=e.placeholder);const s=w("div",["list"],t),l=tv(nv(n,e==null?void 0:e.initialSelectedId));return s.appendChild(l),t}function ov(n,e,t){const o=n.querySelector(".list");g(zi,o,"no list root");const r=tv(nv(e,t)),i=o.querySelector(".list-root");if(g(zi,i,"no exists menu"),Ca(i,r),t){const s=o.querySelector(".list-item.selected");s&&(g(zi,s,"no selected menu item"),s.scrollIntoView({block:"nearest"}))}}class dL{constructor(e,t){m(this,"root");m(this,"visibleItems");m(this,"selectedId");m(this,"filter","");m(this,"onSelected",null);m(this,"handleKeydown",e=>{this.processKeyDown(e)});m(this,"handleInputChanged",()=>{const e=this.root.querySelector(".filter-input");g(zi,e,"no input");const t=e.value.toLocaleLowerCase();this.setFilter(t)});m(this,"handleClick",e=>{this.processClick(e)});var o;this.items=e,this.options=t,this.root=uL(e,t),this.bindEvents(),this.selectedId=(o=t==null?void 0:t.initialSelectedId)!=null?o:"",this.visibleItems=e}bindEvents(){const e=this.root.querySelector(".filter-input");g(zi,e,"no input"),e.addEventListener("keyup",this.handleInputChanged),e.addEventListener("keydown",this.handleKeydown),this.root.addEventListener("click",this.handleClick)}unbindEvents(){const e=this.root.querySelector(".filter-input");g(zi,e,"no input"),e.removeEventListener("keyup",this.handleInputChanged),e.removeEventListener("keydown",this.handleKeydown),this.root.removeEventListener("click",this.handleClick)}destroy(){this.unbindEvents(),this.onSelected=null}getSelectedIndex(){return this.selectedId?this.visibleItems.findIndex(e=>e.id===this.selectedId):-1}setSelectedId(e){this.selectedId=e,ov(this.root,this.visibleItems,e)}focus(){const e=this.root.querySelector(".filter-input");g(zi,e,"no input"),e.focus()}reset(){this.setFilter("");const e=this.root.querySelector(".filter-input");g(zi,e,"no input"),e.value=""}setFilter(e){this.filter!==e&&(this.filter=e,this.visibleItems=this.items.filter(t=>t.name.toLocaleLowerCase().includes(e)),ov(this.root,this.visibleItems,this.selectedId))}processClick(e){var s,l;const t=e.target;if(!(t instanceof HTMLElement))return;const o=t.closest(".list-item");if(!o)return;const r=(s=o.getAttribute("data-id"))!=null?s:"",i=(l=this.visibleItems.find(a=>a.id===r))!=null?l:null;this.onSelected&&this.onSelected(this,i)}processKeyDown(e){var t;if(e.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(e.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(e.key==="Enter"){const o=(t=this.visibleItems.find(r=>r.id===this.selectedId))!=null?t:null;this.onSelected&&this.onSelected(this,o)}}}class hL extends dL{constructor(t,o,r){super(t,r);m(this,"popup");m(this,"onShow",null);m(this,"onHide",null);m(this,"custom",null);m(this,"handleShow",()=>{this.onShow&&this.onShow(this)});m(this,"handleHide",()=>{this.onHide&&this.onHide(this)});m(this,"handleShown",()=>{this.focus()});this.popup=new Xa(this.root)}destroy(){super.destroy(),this.onShow=null,this.onHide=null}show(t){this.reset(),this.popup.manualShow(t,{theme:"dropdown-list"}),this.focus()}processKeyDown(t){super.processKeyDown(t),(t.key==="Esc"||t.key==="Enter")&&this.popup.close("cancelBar")}processClick(t){super.processClick(t);const o=t.target;!(o instanceof HTMLElement)||!o.closest(".list-item")||this.popup.close("clickItem")}}const rne="",ine="";function fL(n,e){const t=document.createElement("div");t.classList.add("toast","show"),e!=null&&e.theme&&t.setAttribute("data-theme",e.theme),e!=null&&e.id&&t.setAttribute("data-id",e.id),e!=null&&e.html?t.innerHTML=n:t.textContent=n,e!=null&&e.position&&(t.style.left=`${e.position.x}px`,t.style.top=`${e.position.y}px`,t.classList.add("positioned")),document.body.appendChild(t),setTimeout(()=>{t.classList.remove("show"),setTimeout(()=>{t.remove()},500)},(e==null?void 0:e.duration)||3e3)}const rv=`<?xml version="1.0" ?>
28
28
  <svg
29
29
  fill="currentColor"
30
30
  xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
@@ -391,13 +391,13 @@ xmlns="http://www.w3.org/2000/svg" height="24" viewBox="0 0 24 24" width="24">
391
391
  `,NO=`<?xml version="1.0" ?>
392
392
  <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">
393
393
  <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>
394
- </svg>`;function $O(n,e){const t=mc(e);if(t!=="text-only"){if(t==="checked"){n.innerHTML=PO;return}if(t==="unchecked"){n.innerHTML=NO;return}n.innerText=_O(e)}}function HO(n){const e=w("div",["list-container"],null),t=w("button",["list-marker"],e);return $O(t,n),e}function A9(n){let e=Ze(n);if(!e)return null;const t=Gs(n);for(;e!==t;){if(g(kt,e,"no next block"),He(e))return Cn(e)>Cn(n)?e:null;if(e=Ze(e),!e)return null}return null}function A0(n){const e=[];let t=A9(n);if(!t)return e;for(;t;){const o=Gs(t);e.push({block:t,children:A0(t)}),t=o}return e}function jO(n){const e=(o,r)=>{r.push(o.block),o.children.forEach(i=>e(i,r))},t=[];return n.forEach(o=>e(o,t)),t}function b9(n,e){return Cn(e)!==1}function v9(n,e,t){e.forEach(o=>{const r=n.getBlockData(o.block);n.updateBlockData(o.block,{...r,groupId:t,level:r.level-1}),o.children.length&&v9(n,o.children,r.groupId)})}function b0(n,e){if(!b9(n,e))return!1;const t=Cn(e);if(t===1)return!1;let o=K(),r=1,i=Zn(e);const s=t-1,l=a0(e);l&&(o=uc(l),r=ho(l)+1,i!=="text-only"&&(i=Zn(l)));const a=A0(e),d=n.getBlockData(e),h={...d,groupId:o,level:s,start:r,...c0(i)};n.updateBlockData(e,h),n.doc.beginBatchUpdate(),v9(n,a,d.groupId),n.doc.endBatchUpdate(),new Zs(n,e).fix();const A=A9(e);return A&&new Zs(n,A,{resetStart:!0,resetGroupId:!0}).fix(),!0}function gc(n,e){_t(e);const t=n.getBlockData(e),o={id:K(),type:"text",text:t.text};t.heading&&(o.heading=t.heading),t.heading&&(o.heading=t.heading);const r=new ff(n,e),i=ne(e),s=be(e);n.deleteBlock(e);const l=gh(o.id,0);n.insertBlock(ae(i),s,o,l),r.fix()}function UO(n){if(!n.selection.range.isCollapsed())return!1;const e=n.selection.focusedBlock;if(!He(e))return!1;const t=n.selection.range.focus;return!t.isSimple()||t.offset!==0?!1:Cn(e)===1?(gc(n,e),!0):(b0(n,e),!0)}const zO=S("list-block");function VO(n,e,t){g(zO,He(e),"not a list block");const o={...n.getBlockData(e),id:K()};return t!=null&&t.level&&(o.level=t.level),t!=null&&t.start&&(o.start=t.start),t!=null&&t.keepText||delete o.text,(o==null?void 0:o.checkbox)==="checked"&&(o.checkbox="unchecked"),o}function WO(n){if(_t(n),!uf(n))return n;let e=Qi(n);for(;e;){if(!uf(e))return e;e=Qi(e)}return null}function qO(n,e,t,o){const r=new Zs(n,o),i=ho(o)+1;Yl(n,e,t,{forceInsertAfter:!0,newBlockData:VO(n,o,{start:i})}),r.fix()}function GO(n){var s;if(n.selection.range.isCollapsed()){const l=n.selection.focusedBlock;if(He(l)&&ue(n,l)===0)return gc(n,l),!0}n.clearSelectedContents();const e=n.selection.focusedBlock;if(!He(e))return!1;const t=n.selection.range.focus;if(!t.isSimple())return!1;const o=t.offset,i=(s=o===ue(n,e)?WO(e):e)!=null?s:e;return qO(n,e,o,i),!0}function y9(n){g(kt,He(n),"not a list block");const{level:e}=Zi(n);let t=ct(n);for(;t;){if(He(t)){const{level:o}=Zi(t);if(e===o)return t;if(o<e)return null}t=ct(t)}return null}function k9(n,e){return _t(e),y9(e)?Cn(e)<GR:!1}function ZO(n,e,t){let o=ct(e);g(kt,o,"no prev brother");const r=Cn(t);for(;o;){if(o===t)return null;if(He(o)&&Cn(o)===r+1)return o;o=ct(o)}return null}function w9(n,e){if(!k9(n,e))return!1;_t(e);const t=y9(e);g(kt,t,"no list prev brother");const o=t,r=ZO(n,e,o),i=Cn(o)+1;let s=K(),l=1,a=Zn(e);r&&(s=uc(r),l=ho(r)+1,a=Zn(r));const d=A0(e),p={...n.getBlockData(e),groupId:s,level:i,start:l,...c0(a)};return n.updateBlockData(e,p),n.doc.beginBatchUpdate(),jO(d).forEach(v=>{const B=n.getBlockData(v);n.updateBlockData(v,{...B,level:B.level+1})}),n.doc.endBatchUpdate(),!0}function QO(n,e,t){return e.length===0||!e.every(o=>He(o.block))?!1:t==="increase"?k9(n,e[0].block):b9(n,e[0].block)}function B9(n,e,t){if(!QO(n,e,t))return!1;const o=e[0].block,r=Cn(o),i=e.filter(d=>Cn(d.block)<=r),s=c9(o,{withSelf:!1}),l=new Set(i.map(d=>d.block)),a=s.filter(d=>!l.has(d));return n.undoManager.runInGroup(()=>{let d=null;a.length>0&&(d=new Zs(n,a[0])),i.forEach(h=>{t==="increase"?w9(n,h.block):b0(n,h.block)}),d==null||d.fix()}),!0}function YO(n,e){return w9(n,e)}function JO(n,e){return b0(n,e)}function KO(n){const e=n.selection.range.getSelectedBlocks();if(e.length>1)return B9(n,e,"increase"),!0;const t=e[0].block;if(!He(t))return!1;const o=new ff(n,t);return YO(n,t)&&(o.fix(),new Zs(n,t).fix()),!0}function XO(n){const e=n.selection.range.getSelectedBlocks();if(e.length>1)return B9(n,e,"decrease"),!0;const t=e[0].block;return He(t)?(JO(n,t),!0):!1}class e_{constructor(e){this.editor=e}handleBeforeKeyDown(e,t){const o=e.selection.range.getSelectedBlocks();if(o.length===0||!o.some(i=>He(i.block)))return!1;switch(t.key){case"Enter":return this.handleEnter(t);case"Backspace":return this.handleBackspace();case"Tab":return this.handleTab(t);default:return!1}}handleEnter(e){const t=this.editor.selection.range.getSelectedBlocks()[0];return!t.block||!He(t.block)||Or(e,"Shift+Enter")?!1:this.editor.undoManager.runInGroup(()=>GO(this.editor))}handleBackspace(){return this.editor.undoManager.runInGroup(()=>UO(this.editor))}handleTab(e){return Or(e,"Shift+Tab")?this.editor.undoManager.runInGroup(()=>XO(this.editor)):this.editor.undoManager.runInGroup(()=>KO(this.editor))}}class t_{constructor(e){m(this,"effectedBlockIds",new Map);m(this,"handleBeforeClearSelection",()=>{this.effectedBlockIds.clear();const e=this.editor.selection.range.getSelectedBlocks();if(e.length===0)return;const t=new Set;e.forEach(r=>{const i=r.block;He(i)&&t.add(i)});const o=new Map;Array.from(t.values()).forEach(r=>{var a;const i=gu(r),{start:s}=Zi(i);o.set(ie(i),s);const l=(a=XR(r))!=null?a:r;o.set(ie(l),s)}),this.effectedBlockIds=o});m(this,"handleAfterClearSelection",()=>{Array.from(this.effectedBlockIds.entries()).forEach(([e,t])=>{const o=this.editor.findBlockById(e);!o||m0(this.editor,o,t)}),this.effectedBlockIds.clear()});this.editor=e,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 n_=S("customize-list-start-menu");class o_{constructor(e){m(this,"popup");m(this,"block",null);m(this,"show",(e,t)=>{const o=t.querySelector("div.list-container");g(n_,o,"list-block mark does not exist"),this.block=t,this.popup.manualShow(o,{theme:"light"})});m(this,"createDialogContent",()=>{const e=w("div",["customize-start-panel"],null);w("span",["customize-start-panel-title"],e,R.t("list.numberLabel"));const t=this.createNumericInput();e.appendChild(t);const o=w("button",["customize-start-panel-button"],e,R.t("list.confirm"));return this.editor.domEvents.addEventListener(e,"keydown",this.handleKeydown),this.editor.domEvents.addEventListener(o,"click",this.handleOk),e});m(this,"handleDialogShow",()=>{const e=this.block;if(!e)return;const t=this.popup.popupContent,o=t.querySelector("button.customize-start-panel-button"),r=t.querySelector("input.customize-start-panel-input"),i=ho(e);!o||!r||requestAnimationFrame(()=>{r.focus(),r.value=String(i)})});m(this,"handleOk",()=>{const t=this.popup.popupContent.querySelector("input.customize-start-panel-input"),o=this.block;if(!o)return;const r=Number(t.value);!r||(this.editor.undoManager.runInGroup(()=>{fc(this.editor,[o,...dc(o)],r,{resetGroupId:!0})}),this.popup.close("clickItem"))});m(this,"handleKeydown",(e,t)=>{const o=t;o.isComposing||(o.key==="Escape"?this.popup.close("cancelBar"):o.key==="Enter"&&this.handleOk())});this.editor=e,this.popup=new Xa(this.createDialogContent()),this.popup.on("show",this.handleDialogShow)}destroy(){this.popup.destroy()}createNumericInput(){const e=w("input",["customize-start-panel-input"],null);e.type="number",e.min="1";const t=()=>{const r=e.value.replace(/[^\d]/g,"").replace(/^0+/,""),i=parseInt(r,10);i<=0||Number.isNaN(i)?e.value="":e.value=r};return this.editor.domEvents.addEventListener(e,"input",t),e}}function r_(n,e){return uc(n)===uc(e)}function i_(n,e){const t=s9(e);return t?r_(t,e)?ho(t)!==ho(e)-1:!0:!1}function s_(n,e){return Qi(e)?!0:ho(e)!==1}function l_(n,e){return _t(e),[{id:"continue-numbering",name:R.t("list.continueList"),states:i_(n,e)?[]:["disabled"]},{id:"start-new-list",name:R.t("list.restartList"),states:s_(n,e)?[]:["disabled"]},{id:"set-numbering-value",name:R.t("list.changeNumber")}]}function c_(n,e,t){var o,r;if(_t(e),t.id==="continue-numbering"){const i=s9(e);i&&fc(n,[e,...dc(e)],ho(i)+1,{resetGroupId:!0,groupId:uc(i)})}if(t.id==="start-new-list"&&n.undoManager.runInGroup(()=>{fc(n,[e,...dc(e)],1,{resetGroupId:!0})}),t.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,e,t))return;n.addCustom("list-customize-start-dialog",()=>new o_(n)).show(n,e)}}class a_{constructor(e){m(this,"menu");m(this,"handleClick",(e,t)=>{const o=jl(t,"div.list-container");if(o&&this.editor.isWritable()){const r=oe(o);g(kt,r,"no parent block"),_t(r);const i=e.getBlockData(r);if(i&&i.checkbox){e.updateBlockData(r,{...i,checkbox:i.checkbox==="checked"?"unchecked":"checked"});return}if(Zn(r)==="unordered")return;this.menu.updateItems(this.getCommandItems(r)),this.menu.manualShow(o),this.activeList(o,!0)}});m(this,"handleMenuClose",()=>{var t;const e=(t=this.menu.tippyInstance)==null?void 0:t.reference;e&&this.activeList(e,!1)});m(this,"handleMenuClick",(e,t)=>{var r;const o=(r=this.menu.tippyInstance)==null?void 0:r.reference;if(o){const i=oe(o);i&&c_(this.editor,i,t)}});this.editor=e,this.editor.addListener("click",this.handleClick),this.menu=new zs([]),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(e){return l_(this.editor,e)}activeList(e,t){const o=oe(e);!o||(t?(W(e,"active"),W(o,"active")):(te(e,"active"),te(o,"active")))}}class u_{constructor(e){this.editor=e}handleBeforeKeyDown(e,t){const o=e.selection.range.getSelectedBlocks();if(o.length===0)return!1;const r=o[0].block;if(!He(r)||!h9(r))return!1;if(t.key==="ArrowUp"||t.key==="ArrowLeft"){const i=Ds(r);return i&&e.selection.selectBlock(i,ue(e,i)),!0}if(t.key==="ArrowDown"||t.key==="ArrowRight"){const i=Ss(r);return i&&e.selection.selectBlock(i,0),!0}return(t.key==="Delete"||t.key==="Backspace"||t.key==="Escape")&&m9(e,r),!0}}function d_(n,e,t,o,r){op(n,"list-block-init",()=>{setTimeout(()=>{n.input.addHandler(new u_(n)),n.input.addHandler(new e_(n)),n.addCustom("list-clear-selection-handler",()=>new t_(n)),n.addCustom("list-marker-menu",()=>new a_(n))})});const i=In.createBlockContent(n,e,t,o,r),s=r,{level:l,start:a,groupId:d}=s,h=mc(s);o.setAttribute("data-list-level",`${l}`),o.setAttribute("data-list-start",`${a||1}`),o.setAttribute("data-list-group-id",`${d}`),o.setAttribute("data-list-type",h);const p=HO(s);return o.insertBefore(p,i),s.viewAsMindmap?setTimeout(()=>{const A=n.getBlockById(r.id);A&&df(n,A,{},{mindmapTools:f0,saveData:!1})}):setTimeout(()=>{const A=n.getBlockById(r.id);A&&f9(n,A)}),i}const h_={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"}},f_={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"}},m_={list:{confirm:"OK",setStart:"\u756A\u53F7\u3092\u8A2D\u5B9A",continueList:"\u9023\u756A\u3092\u8A2D\u5B9A",restartList:"\u65B0\u3057\u3044\u30EA\u30B9\u30C8\u3092\u4F5C\u6210",changeNumber:"\u756A\u53F7\u3092\u7DE8\u96C6",numberLabel:"\u756A\u53F7",mention:{tooltip:"\u30E1\u30F3\u30B7\u30E7\u30F3\u304A\u3088\u3073\u901A\u77E5"}},mindmap:{viewAsMindMap:"\u30DE\u30A4\u30F3\u30C9\u30DE\u30C3\u30D7\u3067\u8868\u793A",autoFit:"\u81EA\u52D5\u30D5\u30A3\u30C3\u30C8",fullScreen:"\u5168\u753B\u9762\u8868\u793A\u306E\u30AA\u30F3",close:"\u9589\u3058\u308B",exitFullscreen:"\u5168\u753B\u9762\u8868\u793A\u306E\u30AA\u30D5"}};R.mergeLang({"zh-CN":h_,"en-US":f_,"ja-JP":m_});const pne="",E9={...In,blockType:"list",createBlockContent:d_,convertFrom:OO,convertTo:FO,handleDrop:BO,notify:vO},v0=S("paragraph");class g_{constructor(e){m(this,"id","BlockParagraphProvider");this.editor=e}isChecked(e,t){return!!(e[t]||e.level&&(e.ordered===!0&&!e.checkbox&&t==="ordered-list"||e.ordered===!1&&!e.checkbox&&t==="unordered-list")||t==="check-list"&&e.checkbox)}getAvailableCommands(e,t){const o=[],r={"unordered-list":[R.t("commands.unordered"),Bo("CtrlOrCmd+Shift+L"),kL],"ordered-list":[R.t("commands.ordered"),Bo("CtrlOrCmd+Shift+U"),yL],"check-list":[R.t("commands.check"),void 0,wL],link:[R.t("commands.link"),Bo("CtrlOrCmd+K"),hv],quoted:[R.t("commands.quote"),void 0,BL]};if(ee(e,t)){const i=ie(t),s=De(t),l=Io(e,t),a=e.getBlockData(t);Object.entries(r).forEach(([d,[h,p,A]])=>{const v=[];if(this.isChecked(a,d)&&v.push("checked"),d==="link"){if(!e.selection.range.isSimple())return;e.selection.range.getSelectedBlocks().length!==1&&v.push("disabled")}o.push({blockId:i,blockType:s,blockKind:l,id:d,name:h,desc:p,states:v,icon:A,groupIndex:600})})}return o}convertLink(e,t,o){g(v0,Hr(t.start),""),g(v0,Hr(t.start),"");const r="bottom-start",i=t.start.offset,s=t.end.offset,l=(v,B)=>{e.undoManager.runInGroup(()=>{try{const D=e.selection.range.isCollapsed();let I;if(D){I=jr(e.getBlockText(o),s,v,{link:B}),e.setBlockText(o,I);return}I=hh(e.getBlockText(o),i,s,v),I=Ia(i,v.length,I,"link",B),e.setBlockText(o,I),e.selection.selectBlock(o,i+v.length),e.focus()}catch(D){v0.error(D)}})},a=()=>{e.selection.selectBlock(o,s),e.focus()},d=Ti(e,o,t)[0];if(!d)return;const h=Li(e,o,"link-button-anchor",d),p=e.getBlockText(o),A=Ta(p,i);fu(e,{target:h,linkText:e.getSelectedText(),linkUrl:(A==null?void 0:A.link)||"",onFinished:l,onClose:a,placement:r})}convertToList(e,t,o){const r=Xd(e,t,"list",{offset:0,data:{listType:o}});r&&e.undoManager.runInGroup(()=>{const i=be(t),s=ne(t);e.insertBlock(ae(s),i,r.blockData),e.deleteBlock(t)})}executeCommand(e,t,o,r){var a;if(!ee(e,t))return!1;const i=r.id,s=(a=r.states)==null?void 0:a.includes("checked");let l=!1;if(i==="unordered-list"&&(s?gc(e,t):this.convertToList(e,t,"unordered"),l=!0),i==="ordered-list"&&(s?gc(e,t):this.convertToList(e,t,"ordered"),l=!0),i==="check-list"&&(s?gc(e,t):this.convertToList(e,t,"unchecked"),l=!0),i==="quoted"){const h=e.getBlockData(t).quoted;e.updateBlockData(t,{quoted:h?void 0:!0}),e.focus(),l=!0}if(i==="link"){const d=lf(e);d.disableTextToolbar(),d.hide(),setTimeout(()=>{d.enableTextToolbar()},1e3),this.convertLink(e,o,t),l=!0}return l}}const p_={left:eu,right:Sp,center:Lp};class C_{constructor(e){m(this,"id","BlockAlignProvider");this.editor=e}applyAlignStyle(e,t,o){Object.keys(p_).includes(o)?e.updateBlockData(t,{align:o}):e.updateBlockData(t,{align:null})}isChecked(e,t){return e.align===t}getAvailableCommands(e,t,o){if(ee(e,t)){const r=ie(t),i=De(t),s=Io(e,t),l=e.getBlockData(t),a=d=>{var p;const h=w("span",["toolbar-item-name-container"],null);for(const A of d.children)if((p=A.states)!=null&&p.includes("checked"))return h.innerHTML=A.icon||eu,h;return h.innerHTML=eu,h};return[{id:"align",name:R.t("commands.alignGroup"),blockId:r,blockType:i,blockKind:s,groupIndex:700,dropdown:!0,element:a,manualShowChildren:!0,childrenPlacement:"bottom-start",defaultCheckedChildren:["align-left"],children:[{id:"align-left",name:R.t("commands.alignLeft"),icon:eu,states:this.isChecked(l,"left")?["checked"]:[]},{id:"align-center",name:R.t("commands.alignCenter"),icon:Lp,states:this.isChecked(l,"center")?["checked"]:[]},{id:"align-right",name:R.t("commands.alignRight"),icon:Sp,states:this.isChecked(l,"right")?["checked"]:[]}],childrenType:"menu"}]}return[]}executeCommand(e,t,o,r){if(!ee(e,t))return!1;if(r.id.startsWith("align")){const i=r.id.replace(/^align-/,"");return this.applyAlignStyle(e,t,i),this.editor.focus(),!0}return!1}}function A_(n){const t=n.selection.range;if(t.isCollapsed()||t.start.blockId!==t.end.blockId||!t.start.isSimple()||!t.end.isSimple()||t.end.offset-t.start.offset!==1)return!1;const o=n.getBlockById(t.start.blockId);return Sa(n,o,t.start.offset).charType==="box"}const b_=S("toolbar-handler"),v_={id:"",name:"",type:"separator"};class pc{constructor(e){m(this,"toolbar");m(this,"toolbarType","object");m(this,"mouseDown",!1);m(this,"oldRange",null);m(this,"hoveringBlock",null);m(this,"hoveringTextChild",null);m(this,"_disableTextToolbar",!1);m(this,"handleButtonClick",(e,t)=>{this.toolbarType==="text"?(this.editor.editorCommandProviders.executeCommand(this.editor.selection.range,t,{}),this.showTextToolbar("click")):this.hoveringBlock&&zR(this.editor,this.hoveringBlock,this.hoveringTextChild,t)});m(this,"handleClose",()=>{Fp(this.editor)&&this.editor.focus()});m(this,"handleClosing",(e,t)=>{if(this.toolbarType==="object"){const o=rC(t);if(this.hoveringBlock===o)return!1}return!0});m(this,"handleDocumentMouseDown",e=>{e.button===0&&(document.addEventListener("mouseup",this.handleDocumentMouseUp),this.mouseDown=!0)});m(this,"handleDocumentMouseUp",()=>{document.removeEventListener("mouseup",this.handleDocumentMouseUp),this.mouseDown=!1,this.handleSelectionChange(this.editor)});m(this,"handleHoveringBlockChildChange",(e,t,o,r)=>{if(!(this.hoveringBlock===e&&this.hoveringTextChild===t)&&(this.hoveringBlock=e,this.hoveringTextChild=t,!(this.toolbar.isVisible&&this.toolbarType==="text"))){if(!e){this.toolbar.close("fromHover");return}this.showObjectToolbar(r)}});m(this,"handleSelectionChange",Ht.default(e=>{var o;if(g(b_,e===this.editor,"editor mismatch"),e.selection.range.isCollapsed()||this.mouseDown){if(this.toolbarType==="object"){const r=(o=this.toolbar.tippyInstance)==null?void 0:o.reference,i=this.editor.selection.focusedBlock;if(r&&Ke(r,i))return}this.toolbar.close("selectionChange"),this.oldRange=null;return}if(!this.editor.isWritable()){this.toolbar.close("selectionChange"),this.oldRange=null;return}if(e.selection.range.getSelectedBlocks().length===0){this.toolbar.close("selectionChange"),this.oldRange=null;return}this.oldRange&&this.oldRange.isEqual(e.selection.range)||(this.oldRange=e.selection.range,this.showTextToolbar("selectionChange"))},50));this.editor=e;const t=e.options.componentsOptions.popover;this.toolbar=new ou([],void 0,{tooltipId:e.clientId,id:"editor-toolbar",overflowBoundary:t==null?void 0:t.overflowBoundary,refuseOverflow:!0,padding:20}),this.toolbar.on("click",this.handleButtonClick),this.toolbar.on("close",this.handleClose),this.toolbar.on("closing",this.handleClosing),this.bindEvents(),e.addListener("selectionChanged",this.handleSelectionChange),pt.get(e).addListener("childChange",this.handleHoveringBlockChildChange),pt.get(e).addFilter(this),e.editorCommandProviders.registerCommandProvider(new WR(e)),e.editorCommandProviders.registerCommandProvider(new g_(e)),e.editorCommandProviders.registerCommandProvider(new C_(e))}disableTextToolbar(){this._disableTextToolbar=!0}enableTextToolbar(){this._disableTextToolbar=!1}hide(){this.toolbar.close("selectionChange")}destroy(){this.unbindEvents(),this.toolbar.destroy(),this.editor.removeListener("selectionChanged",this.handleSelectionChange),pt.get(this.editor).removeListener("childChange",this.handleHoveringBlockChildChange)}isInBlock(e,t){return e!==this.hoveringBlock?!1:!!(t.target&&t.target instanceof Node&&this.toolbar.popper&&Ke(this.toolbar.popper,t.target))}bindEvents(){document.addEventListener("mousedown",this.handleDocumentMouseDown)}unbindEvents(){document.removeEventListener("mousedown",this.handleDocumentMouseDown)}update(e){this.showTextToolbar(e)}showTextToolbar(e){var D,I;if(this._disableTextToolbar||!this.editor.isWritable())return;const o=this.editor.selection.range.getSelectedBlocks();if(o.length===0)return;const r=o[0];if(!r)return;if(o.length===1&&Lt(r.block)){e==="click"&&this.showObjectToolbar(null);return}if(A_(this.editor))return;if(ne(r.block)===this.editor.rootContainer&&be(r.block)===0){this.toolbar.close("selectionChange");return}const i=this.editor.editorCommandProviders.getCommands(this.editor.selection.range),s=new Map;i.forEach(_=>{const M=_.groupIndex,H=s.get(M);H?H.push(_):s.set(M,[_])});const l=[[]],a=Array.from(s.entries()).sort((_,M)=>_[0]-M[0]);for(let _=0;_<a.length;_++){const[,M]=a[_];if(M.length===0)continue;let H=l[l.length-1];H.length>0&&H[H.length-1].groupIndex!==M[M.length-1].groupIndex&&(H=[],l.push(H)),H.push(...sf(M))}if(l.length===0){this.toolbar.close("selectionChange");return}this.toolbarType="text";const d=[];if(l.forEach((_,M)=>{const H=_.sort((z,q)=>{var re,fe;return((re=z.order)!=null?re:0)-((fe=q.order)!=null?fe:0)});d.push(...H),M!==l.length-1&&d.push(v_)}),d.length===0){this.toolbar.close("selectionChange");return}this.toolbar.updateItems(d);const h=o[o.length-1],p=!this.editor.selection.range.isReverse()&&h!==r,A=p?h:r,v=_R(this.editor,A),B=Li(this.editor,A.block,"editor-quick-menu",v);this.toolbar.manualShow(B,{placement:p?"bottom":"top"}),(I=(D=this.toolbar.tippyInstance)==null?void 0:D.popperInstance)==null||I.update()}showObjectToolbar(e){var l,a;if(!this.hoveringBlock||this.mouseDown)return;const t=this.hoveringBlock,o=this.hoveringTextChild,{commands:r,element:i}=HR(this.editor,t,o);if(!r.length||!i){this.toolbar.close("fromHover");return}this.toolbarType="object",this.toolbar.isVisible&&((a=(l=this.toolbar)==null?void 0:l.tippyInstance)==null?void 0:a.reference)!==i&&this.toolbar.close("fromHover");const s=()=>{let d;const h=i.getClientRects();if(h.length>1){if(d=o?h[h.length-1]:h[0],e)for(let p=0;p<h.length;p++){const A=h[p],v=new DOMRect(A.x-4,A.y-4,A.width+8,A.height+8);if(v.x<e.clientX&&e.clientX<v.right&&v.y<e.clientY&&e.clientY<v.bottom){d=A;break}}}else{if(d=i.getBoundingClientRect(),o){const p=o.getBoundingClientRect();return new DOMRect(p.x,p.y,p.width,p.height)}return new DOMRect(h[0].x,h[0].y,h[0].width,h[0].height)}if(e){const p=d.y,A=e.clientX;return new DOMRect(A,p,10,d.height)}return d};this.toolbar.updateItems(r),this.toolbar.isVisible||this.toolbar.manualShow(i,{placement:o?"bottom":"top",getReferenceClientRect:s})}static register(e){return e.addCustom("toolbar-handler",t=>new pc(t))}static get(e){return e.getCustom("toolbar-handler")}}function pf(n,e,t){n.getBlockData(e).heading===t?n.updateBlockData(e,{heading:null}):n.updateBlockData(e,{heading:t})}function x9(n,e,t){["left","center","right"].includes(t)?n.updateBlockData(e,{align:t}):n.updateBlockData(e,{align:null})}function y0(n,e){const o=n.getBlockData(e).quoted;n.updateBlockData(e,{quoted:o?void 0:!0})}function k0(n,e){return!!(n[e]||n.level&&(n.ordered===!0&&!n.checkbox&&e==="ordered-list"||n.ordered===!1&&!n.checkbox&&e==="unordered-list")||e==="check-list"&&n.checkbox)}function w0(n,e,t){if(!n.selection.range.focus.isSimple())return;const r=n.getBlockData(e);let i;switch(t){case"unordered-list":i=k0(r,"unordered-list")?void 0:"unordered";break;case"ordered-list":i=k0(r,"ordered-list")?void 0:"ordered";break;case"check-list":i=k0(r,"check-list")?void 0:"unchecked";break}if(i){const s=Xd(n,e,"list",{offset:0,data:{listType:i}});s&&n.undoManager.runInGroup(()=>{const l=be(e),a=ne(e);n.deleteBlock(e),n.insertBlock(ae(a),l,s.blockData)})}else gc(n,e)}const y_=Object.freeze(Object.defineProperty({__proto__:null,applyHeadingStyle:pf,applyAlignStyle:x9,applyQuoteStyle:y0,applyList:w0},Symbol.toStringTag,{value:"Module"})),k_=[kp,wp,Bp,Ep,xp,Ip,Tp,Dp],w_={Unordered:gv,Ordered:pv,Checkbox:fv,Quote:mv};function I9(n,e){const t=n;t.blockOptions=e,t.itemType="insert-block",n.children&&n.children.forEach(o=>I9(o,e))}function B_(){return{name:"basic",insertBlockCommandItems:[{id:"text",icon:nu,name:R.t("commands.text"),order:0,group:"basics",value:"text"}]}}function B0(n=1){var r;const e={name:"basic",insertBlockCommandItems:[]};let t=cf();t<=4?t=5:t<8&&(t+=1);let o=n;for(;o<=t;){const i=`heading-${o}`;(r=e.insertBlockCommandItems)==null||r.push({id:i,icon:k_[o-1],name:R.t("quickMenu.basic.heading.title",{heading:String(o)}),order:o,group:"basics",value:String(o),subText:pn(i)}),o++}return e}function E_(){const n={name:"basic",insertBlockCommandItems:[]};return["Unordered","Ordered","Checkbox","Quote"].forEach((t,o)=>{var i;const r=`insert-${t.toLocaleLowerCase()}`;(i=n.insertBlockCommandItems)==null||i.push({id:r,name:R.t(`quickMenu.basic.${t.toLocaleLowerCase()}`),icon:w_[t],value:t.toLocaleLowerCase(),group:"basics",order:10+o,subText:pn(r)})}),n}class T9{constructor(e){this.withPlainText=e}getCommands(){const e=B_(),t=B0(),o=E_();return[...this.withPlainText?e.insertBlockCommandItems||[]:[],...t.insertBlockCommandItems||[],...o.insertBlockCommandItems||[]]}updateBlock(e,t,o,r){const{value:i,id:s}=r;return s.startsWith("heading-")?pf(e,o,Number.parseInt(i!=null?i:"1",10)||1):i==="ordered"||i==="unordered"||i==="checkbox"?w0(e,o,{ordered:"ordered-list",unordered:"unordered-list",checkbox:"check-list"}[i]):i==="quote"&&y0(e,o),null}async handleUpdateBlockCore(e,t){const o=e.getBlockByIndex(t.containerId,t.blockIndex);return this.updateBlock(e,t.containerId,o,t.item)}async handleInsertEmptyBlockCore(e,t){const{containerId:o,blockIndex:r}=t,i=e.insertTextBlock(void 0,o,r);return this.updateBlock(e,t.containerId,i,t.item)}async executeCommand(e,t,o){if(o.from==="quick-menu"){const r=e.getBlockById(o.blockId),i=e.getParentContainer(r),s=ae(i),l=e.getBlockIndex(r);e.undoManager.runInGroup(()=>this.handleUpdateBlockCore(e,{item:t,containerId:s,blockIndex:l})),e.focus()}else o.from==="block-menu"&&(e.undoManager.runInGroup(()=>this.handleInsertEmptyBlockCore(e,{item:t,containerId:o.containerId,blockIndex:o.blockIndex})),e.focus());return null}}const D9={basics:100,system:200,common:300,thirdParty:400};class E0{constructor(){m(this,"dataUrl","");m(this,"error",null)}destroy(){}setDataUrl(e){this.error=null,this.dataUrl=e}setError(e){this.dataUrl="",this.error=e}}const x_=S("mathjax-converter"),I_="MathJax-script";async function T_(n){var o;window.MathJax||(window.MathJax={options:{skipHtmlTags:["script","noscript","style","textarea","pre","code","annotation","annotation-xml","body"]}});const e=n.getComponentOptions("mathjax"),t=((o=e==null?void 0:e.cdn)==null?void 0:o.mathjax)||"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js";await vs(t,I_)}function D_(){try{window.MathJax&&window.MathJax.texReset()}catch{}}async function S9(n,e){const t="mathjax2Svg";try{await wo.lock(t),D_(),await T_(n);const o=await window.MathJax.tex2svgPromise(e),r=o.querySelector("merror");if(r)throw new Error(r.textContent);return o.querySelector("svg").outerHTML}catch(o){throw x_.error(o),o}finally{wo.release(t)}}async function L9(n,e){const t=await S9(n,e);return t?await Sm(t,"image/svg+xml"):""}async function x0(n,e){const o=await S9(n,e),r=new File([o],"math.svg");return(await n.doc.uploadResource(r)).resourceId}const M9=S("edit-mathjax");class S_{constructor(){m(this,"editMathjaxPopup",null);m(this,"onChange",null);m(this,"tex","");m(this,"handleShow",()=>{setTimeout(()=>{this.getTextarea().focus()})});m(this,"handleClose",e=>{var o;const t=e.content.querySelector("textarea");if(t){const r=t.value;r!==this.tex&&((o=this.onChange)==null||o.call(this,r,!0))}});m(this,"handleKeyup",e=>{var t;e.isComposing||(e.key==="Escape"&&((t=this.editMathjaxPopup)==null||t.close("cancelBar")),this.handleChange(e.target.value))});m(this,"handleChange",Ht.default(e=>{var t;(t=this.onChange)==null||t.call(this,e,!1)},300))}editMathjax(e,t,o){if(!this.editMathjaxPopup)this.editMathjaxPopup=new Xa(this.createPopupContent(t));else{const r=this.getTextarea();r.value=t}this.tex=t,this.editMathjaxPopup.addListener("show",this.handleShow),this.editMathjaxPopup.manualShow(e,{theme:"light"}),this.editMathjaxPopup.removeAllListeners("close"),this.editMathjaxPopup.addListener("close",this.handleClose),this.onChange=o}createPopupContent(e){const t=w("textarea",["mathjax-editor-textarea"],null);return t.value=e,t.addEventListener("keyup",this.handleKeyup),t}getTextarea(){g(M9,this.editMathjaxPopup,"no exists mathjax editor popup");const e=this.editMathjaxPopup.content.querySelector("textarea");return g(M9,e,"no textarea"),e}destroy(){var e;this.onChange=null,(e=this.editMathjaxPopup)==null||e.removeAllListeners()}}function R9(n,e,t,o){n.addCustom("mathjax-editor",()=>new S_).editMathjax(e,t.trim(),o)}function O9(){return{insert:" ",attributes:{id:K(),box:!0,type:"math",tex:" ",src:"",created:Date.now()}}}function Cf(n,e){const t=n.getBoxData(e),o=oe(e);if(!o)return;const r=Mi(o,e);n.selection.selectBlock(o,r.start,r.end);const i=async(s,l)=>{if(!s.trim()){n.updateBoxData({...t,tex:s,src:null});return}try{await wo.lock("convertAndUploadMathjax");const a=await x0(n,s);n.updateBoxData({...t,tex:s,src:a})}catch(a){const d=n.getBoxData(e);n.addCustom(`mathjax-box-${d.id}`,()=>new E0).setError(a),n.updateBoxData({...t,tex:s,src:""})}finally{wo.release("convertAndUploadMathjax"),l&&n.focus()}};R9(n,e,t.tex,i)}const _9=S("mathjax-box");function I0(n,e){n.selection.updateSelection(null);const t=e.target;!t||!(t instanceof HTMLElement)||n.domEvents.removeEventListener(t,null,I0)}async function L_(n,e,t){try{if(!e.tex.trim())return;const o=await L9(n,e.tex),r=n.findBoxById(e.id);if(!r)return;const i=Hm(r);i.innerHTML="";const s=w("img",["mathjax"],i);s.src=o,t.setDataUrl(o),n.domEvents.addEventListener(s,"load",I0)}catch(o){t.setError(o);const r=n.findBoxById(e.id);if(!r)return;const i=r.querySelector(".mathjax-tex-text");W(i,"mathjax-error"),i.innerText=o.message,n.selection.updateSelection(null)}}function M_(n,e,t,o){const r=o,i=n.addCustom(`mathjax-box-${r.id}`,()=>new E0);if(r.src||i.dataUrl){const a=w("img",["mathjax"],t);a.src=n.doc.buildResourceUrl(r.src||i.dataUrl),n.domEvents.addEventListener(a,"load",I0);return}const s=["mathjax-tex-text"];let l=r.tex;l.trim()?i.error&&(l=i.error.message,s.push("mathjax-error")):l=R.t("mathjax.emptyText"),w("span",s,t,l),L_(n,r,i)}function R_(n,e){const t={id:K(),box:!0,type:"math",tex:e,src:"",created:Date.now()};return x0(n,e).then(o=>{if(!n.findBoxById(t.id))return;const i={...t,src:o};n.updateBoxData(i)}).catch(o=>{_9.error(`failed to convert and upload mathjax: ${JSON.stringify(o)}`)}),t}function O_(n,e,t,o){const r=e;return o==="text"?r.tex:o==="markdown"?` $${r.tex}$ `:r.src?`<img src="${n.doc.buildResourceUrl(r.src,{withToken:!0})}" />`:`<code>$${r.tex}$</code>`}function __(n,e,t){const o=oe(e);g(_9,o,"failed to get block"),!(n.readonly||!n.isBlockWritable(o))&&Cf(n,e)}function F_(){return{abstract:R.t("mathjax.abstract")}}const T0={boxType:"math",updateBoxContent:M_,convertFrom:R_,convertTo:O_,handleClickBox:__,getBoxProperties:F_};async function P_(n,e,t){try{const o=e.embedData,r=await L9(n,o.mathjaxText),i=n.findBlockById(e.id);if(!i)return;const s=Re(i);s.innerHTML="";const l=w("img",["mathjax"],s);l.src=r,t.setDataUrl(r)}catch(o){t.setError(o)}}function N_(n,e){if(n.readonly||!e.target||!(e.target instanceof Node))return;const t=oe(e.target);if(!t||!Lt(t)||Un(t)!=="math")return;const o=Re(t),r=o.querySelector("img")||o.querySelector("span.mathjax-tex-text");if(!r||!Ke(r,e.target))return;const s=n.getBlockData(t).embedData;R9(n,r,s.mathjaxText,async l=>{const a=await x0(n,l),d={mathjaxText:l,src:a};n.updateEmbedData(t,d)})}function $_(n,e,t){const o=t.embedData,r=n.addCustom(`mathjax-block-${t.id}`,()=>new E0);if(n.domEvents.addEventListener(e,"click",N_),o.src||r.dataUrl){const i=w("img",["mathjax"],e);i.src=n.doc.buildResourceUrl(o.src||r.dataUrl);return}r.error,w("span",["mathjax-tex-text"],e,o.mathjaxText),P_(n,t,r)}function H_(n,e,t){if(!ee(n,e))return null;const o=n.getBlockString(e).trim();if(!o||!o.startsWith("$$")||!o.endsWith("$$"))return null;const r=Bm(o,"$");if(!r)return null;const i={mathjaxText:r,src:""};return{blockData:{id:K(),type:"embed",embedType:"math",embedData:i}}}function j_(n){return{name:"Mathjax"}}function U_(n,e){const t=Re(e);n.domEvents.removeAllListeners(t)}function z_(n,e,t,o){const r=e.embedData;return o==="html"?`<img src="${n.doc.buildResourceUrl(r.src,{withToken:!0})}" />`:o==="markdown"?`
394
+ </svg>`;function $O(n,e){const t=mc(e);if(t!=="text-only"){if(t==="checked"){n.innerHTML=PO;return}if(t==="unchecked"){n.innerHTML=NO;return}n.innerText=_O(e)}}function HO(n){const e=w("div",["list-container"],null),t=w("button",["list-marker"],e);return $O(t,n),e}function A9(n){let e=Ze(n);if(!e)return null;const t=Gs(n);for(;e!==t;){if(g(kt,e,"no next block"),He(e))return Cn(e)>Cn(n)?e:null;if(e=Ze(e),!e)return null}return null}function A0(n){const e=[];let t=A9(n);if(!t)return e;for(;t;){const o=Gs(t);e.push({block:t,children:A0(t)}),t=o}return e}function jO(n){const e=(o,r)=>{r.push(o.block),o.children.forEach(i=>e(i,r))},t=[];return n.forEach(o=>e(o,t)),t}function b9(n,e){return Cn(e)!==1}function v9(n,e,t){e.forEach(o=>{const r=n.getBlockData(o.block);n.updateBlockData(o.block,{...r,groupId:t,level:r.level-1}),o.children.length&&v9(n,o.children,r.groupId)})}function b0(n,e){if(!b9(n,e))return!1;const t=Cn(e);if(t===1)return!1;let o=K(),r=1,i=Zn(e);const s=t-1,l=a0(e);l&&(o=uc(l),r=ho(l)+1,i!=="text-only"&&(i=Zn(l)));const a=A0(e),d=n.getBlockData(e),h={...d,groupId:o,level:s,start:r,...c0(i)};n.updateBlockData(e,h),n.doc.beginBatchUpdate(),v9(n,a,d.groupId),n.doc.endBatchUpdate(),new Zs(n,e).fix();const A=A9(e);return A&&new Zs(n,A,{resetStart:!0,resetGroupId:!0}).fix(),!0}function gc(n,e){_t(e);const t=n.getBlockData(e),o={id:K(),type:"text",text:t.text};t.heading&&(o.heading=t.heading),t.heading&&(o.heading=t.heading);const r=new ff(n,e),i=ne(e),s=be(e);n.deleteBlock(e);const l=gh(o.id,0);n.insertBlock(ae(i),s,o,l),r.fix()}function UO(n){if(!n.selection.range.isCollapsed())return!1;const e=n.selection.focusedBlock;if(!He(e))return!1;const t=n.selection.range.focus;return!t.isSimple()||t.offset!==0?!1:Cn(e)===1?(gc(n,e),!0):(b0(n,e),!0)}const zO=S("list-block");function VO(n,e,t){g(zO,He(e),"not a list block");const o={...n.getBlockData(e),id:K()};return t!=null&&t.level&&(o.level=t.level),t!=null&&t.start&&(o.start=t.start),t!=null&&t.keepText||delete o.text,(o==null?void 0:o.checkbox)==="checked"&&(o.checkbox="unchecked"),o}function WO(n){if(_t(n),!uf(n))return n;let e=Qi(n);for(;e;){if(!uf(e))return e;e=Qi(e)}return null}function qO(n,e,t,o){const r=new Zs(n,o),i=ho(o)+1;Yl(n,e,t,{forceInsertAfter:!0,newBlockData:VO(n,o,{start:i})}),r.fix()}function GO(n){var s;if(n.selection.range.isCollapsed()){const l=n.selection.focusedBlock;if(He(l)&&ue(n,l)===0)return gc(n,l),!0}n.clearSelectedContents();const e=n.selection.focusedBlock;if(!He(e))return!1;const t=n.selection.range.focus;if(!t.isSimple())return!1;const o=t.offset,i=(s=o===ue(n,e)?WO(e):e)!=null?s:e;return qO(n,e,o,i),!0}function y9(n){g(kt,He(n),"not a list block");const{level:e}=Zi(n);let t=ct(n);for(;t;){if(He(t)){const{level:o}=Zi(t);if(e===o)return t;if(o<e)return null}t=ct(t)}return null}function k9(n,e){return _t(e),y9(e)?Cn(e)<GR:!1}function ZO(n,e,t){let o=ct(e);g(kt,o,"no prev brother");const r=Cn(t);for(;o;){if(o===t)return null;if(He(o)&&Cn(o)===r+1)return o;o=ct(o)}return null}function w9(n,e){if(!k9(n,e))return!1;_t(e);const t=y9(e);g(kt,t,"no list prev brother");const o=t,r=ZO(n,e,o),i=Cn(o)+1;let s=K(),l=1,a=Zn(e);r&&(s=uc(r),l=ho(r)+1,a=Zn(r));const d=A0(e),p={...n.getBlockData(e),groupId:s,level:i,start:l,...c0(a)};return n.updateBlockData(e,p),n.doc.beginBatchUpdate(),jO(d).forEach(v=>{const B=n.getBlockData(v);n.updateBlockData(v,{...B,level:B.level+1})}),n.doc.endBatchUpdate(),!0}function QO(n,e,t){return e.length===0||!e.every(o=>He(o.block))?!1:t==="increase"?k9(n,e[0].block):b9(n,e[0].block)}function B9(n,e,t){if(!QO(n,e,t))return!1;const o=e[0].block,r=Cn(o),i=e.filter(d=>Cn(d.block)<=r),s=c9(o,{withSelf:!1}),l=new Set(i.map(d=>d.block)),a=s.filter(d=>!l.has(d));return n.undoManager.runInGroup(()=>{let d=null;a.length>0&&(d=new Zs(n,a[0])),i.forEach(h=>{t==="increase"?w9(n,h.block):b0(n,h.block)}),d==null||d.fix()}),!0}function YO(n,e){return w9(n,e)}function JO(n,e){return b0(n,e)}function KO(n){const e=n.selection.range.getSelectedBlocks();if(e.length>1)return B9(n,e,"increase"),!0;const t=e[0].block;if(!He(t))return!1;const o=new ff(n,t);return YO(n,t)&&(o.fix(),new Zs(n,t).fix()),!0}function XO(n){const e=n.selection.range.getSelectedBlocks();if(e.length>1)return B9(n,e,"decrease"),!0;const t=e[0].block;return He(t)?(JO(n,t),!0):!1}class e_{constructor(e){this.editor=e}handleBeforeKeyDown(e,t){const o=e.selection.range.getSelectedBlocks();if(o.length===0||!o.some(i=>He(i.block)))return!1;switch(t.key){case"Enter":return this.handleEnter(t);case"Backspace":return this.handleBackspace();case"Tab":return this.handleTab(t);default:return!1}}handleEnter(e){const t=this.editor.selection.range.getSelectedBlocks()[0];return!t.block||!He(t.block)||Or(e,"Shift+Enter")?!1:this.editor.undoManager.runInGroup(()=>GO(this.editor))}handleBackspace(){return this.editor.undoManager.runInGroup(()=>UO(this.editor))}handleTab(e){return Or(e,"Shift+Tab")?this.editor.undoManager.runInGroup(()=>XO(this.editor)):this.editor.undoManager.runInGroup(()=>KO(this.editor))}}class t_{constructor(e){m(this,"effectedBlockIds",new Map);m(this,"handleBeforeClearSelection",()=>{this.effectedBlockIds.clear();const e=this.editor.selection.range.getSelectedBlocks();if(e.length===0)return;const t=new Set;e.forEach(r=>{const i=r.block;He(i)&&t.add(i)});const o=new Map;Array.from(t.values()).forEach(r=>{var a;const i=gu(r),{start:s}=Zi(i);o.set(ie(i),s);const l=(a=XR(r))!=null?a:r;o.set(ie(l),s)}),this.effectedBlockIds=o});m(this,"handleAfterClearSelection",()=>{Array.from(this.effectedBlockIds.entries()).forEach(([e,t])=>{const o=this.editor.findBlockById(e);!o||m0(this.editor,o,t)}),this.effectedBlockIds.clear()});this.editor=e,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 n_=S("customize-list-start-menu");class o_{constructor(e){m(this,"popup");m(this,"block",null);m(this,"show",(e,t)=>{const o=t.querySelector("div.list-container");g(n_,o,"list-block mark does not exist"),this.block=t,this.popup.manualShow(o,{theme:"light"})});m(this,"createDialogContent",()=>{const e=w("div",["customize-start-panel"],null);w("span",["customize-start-panel-title"],e,R.t("list.numberLabel"));const t=this.createNumericInput();e.appendChild(t);const o=w("button",["customize-start-panel-button"],e,R.t("list.confirm"));return this.editor.domEvents.addEventListener(e,"keydown",this.handleKeydown),this.editor.domEvents.addEventListener(o,"click",this.handleOk),e});m(this,"handleDialogShow",()=>{const e=this.block;if(!e)return;const t=this.popup.popupContent,o=t.querySelector("button.customize-start-panel-button"),r=t.querySelector("input.customize-start-panel-input"),i=ho(e);!o||!r||requestAnimationFrame(()=>{r.focus(),r.value=String(i)})});m(this,"handleOk",()=>{const t=this.popup.popupContent.querySelector("input.customize-start-panel-input"),o=this.block;if(!o)return;const r=Number(t.value);!r||(this.editor.undoManager.runInGroup(()=>{fc(this.editor,[o,...dc(o)],r,{resetGroupId:!0})}),this.popup.close("clickItem"))});m(this,"handleKeydown",(e,t)=>{const o=t;o.isComposing||(o.key==="Escape"?this.popup.close("cancelBar"):o.key==="Enter"&&this.handleOk())});this.editor=e,this.popup=new Xa(this.createDialogContent()),this.popup.on("show",this.handleDialogShow)}destroy(){this.popup.destroy()}createNumericInput(){const e=w("input",["customize-start-panel-input"],null);e.type="number",e.min="1";const t=()=>{const r=e.value.replace(/[^\d]/g,"").replace(/^0+/,""),i=parseInt(r,10);i<=0||Number.isNaN(i)?e.value="":e.value=r};return this.editor.domEvents.addEventListener(e,"input",t),e}}function r_(n,e){return uc(n)===uc(e)}function i_(n,e){const t=s9(e);return t?r_(t,e)?ho(t)!==ho(e)-1:!0:!1}function s_(n,e){return Qi(e)?!0:ho(e)!==1}function l_(n,e){return _t(e),[{id:"continue-numbering",name:R.t("list.continueList"),states:i_(n,e)?[]:["disabled"]},{id:"start-new-list",name:R.t("list.restartList"),states:s_(n,e)?[]:["disabled"]},{id:"set-numbering-value",name:R.t("list.changeNumber")}]}function c_(n,e,t){var o,r;if(_t(e),t.id==="continue-numbering"){const i=s9(e);i&&fc(n,[e,...dc(e)],ho(i)+1,{resetGroupId:!0,groupId:uc(i)})}if(t.id==="start-new-list"&&n.undoManager.runInGroup(()=>{fc(n,[e,...dc(e)],1,{resetGroupId:!0})}),t.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,e,t))return;n.addCustom("list-customize-start-dialog",()=>new o_(n)).show(n,e)}}class a_{constructor(e){m(this,"menu");m(this,"handleClick",(e,t)=>{const o=jl(t,"div.list-container");if(o&&this.editor.isWritable()){const r=oe(o);g(kt,r,"no parent block"),_t(r);const i=e.getBlockData(r);if(i&&i.checkbox){e.updateBlockData(r,{...i,checkbox:i.checkbox==="checked"?"unchecked":"checked"});return}if(Zn(r)==="unordered")return;this.menu.updateItems(this.getCommandItems(r)),this.menu.manualShow(o),this.activeList(o,!0)}});m(this,"handleMenuClose",()=>{var t;const e=(t=this.menu.tippyInstance)==null?void 0:t.reference;e&&this.activeList(e,!1)});m(this,"handleMenuClick",(e,t)=>{var r;const o=(r=this.menu.tippyInstance)==null?void 0:r.reference;if(o){const i=oe(o);i&&c_(this.editor,i,t)}});this.editor=e,this.editor.addListener("click",this.handleClick),this.menu=new zs([]),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(e){return l_(this.editor,e)}activeList(e,t){const o=oe(e);!o||(t?(W(e,"active"),W(o,"active")):(te(e,"active"),te(o,"active")))}}class u_{constructor(e){this.editor=e}handleBeforeKeyDown(e,t){const o=e.selection.range.getSelectedBlocks();if(o.length===0)return!1;const r=o[0].block;if(!He(r)||!h9(r))return!1;if(t.key==="ArrowUp"||t.key==="ArrowLeft"){const i=Ds(r);return i&&e.selection.selectBlock(i,ue(e,i)),!0}if(t.key==="ArrowDown"||t.key==="ArrowRight"){const i=Ss(r);return i&&e.selection.selectBlock(i,0),!0}return(t.key==="Delete"||t.key==="Backspace"||t.key==="Escape")&&m9(e,r),!0}}function d_(n,e,t,o,r){op(n,"list-block-init",()=>{setTimeout(()=>{n.input.addHandler(new u_(n)),n.input.addHandler(new e_(n)),n.addCustom("list-clear-selection-handler",()=>new t_(n)),n.addCustom("list-marker-menu",()=>new a_(n))})});const i=In.createBlockContent(n,e,t,o,r),s=r,{level:l,start:a,groupId:d}=s,h=mc(s);o.setAttribute("data-list-level",`${l}`),o.setAttribute("data-list-start",`${a||1}`),o.setAttribute("data-list-group-id",`${d}`),o.setAttribute("data-list-type",h);const p=HO(s);return o.insertBefore(p,i),s.viewAsMindmap?setTimeout(()=>{const A=n.getBlockById(r.id);A&&df(n,A,{},{mindmapTools:f0,saveData:!1})}):setTimeout(()=>{const A=n.getBlockById(r.id);A&&f9(n,A)}),i}const h_={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"}},f_={list:{confirm:"Confirm",setStart:"Set number",continueList:"Continue numbering",restartList:"Start a new list",changeNumber:"Set numbering value",numberLabel:"Numbering order",mention:{tooltip:"Mention and notify users"}},mindmap:{viewAsMindMap:"View as MindMap",autoFit:"Auto zoom",fullScreen:"Full screen",close:"Close",exitFullscreen:"Exit full screen"}},m_={list:{confirm:"OK",setStart:"\u756A\u53F7\u3092\u8A2D\u5B9A",continueList:"\u9023\u756A\u3092\u8A2D\u5B9A",restartList:"\u65B0\u3057\u3044\u30EA\u30B9\u30C8\u3092\u4F5C\u6210",changeNumber:"\u756A\u53F7\u3092\u7DE8\u96C6",numberLabel:"\u756A\u53F7",mention:{tooltip:"\u30E1\u30F3\u30B7\u30E7\u30F3\u304A\u3088\u3073\u901A\u77E5"}},mindmap:{viewAsMindMap:"\u30DE\u30A4\u30F3\u30C9\u30DE\u30C3\u30D7\u3067\u8868\u793A",autoFit:"\u81EA\u52D5\u30D5\u30A3\u30C3\u30C8",fullScreen:"\u5168\u753B\u9762\u8868\u793A\u306E\u30AA\u30F3",close:"\u9589\u3058\u308B",exitFullscreen:"\u5168\u753B\u9762\u8868\u793A\u306E\u30AA\u30D5"}};R.mergeLang({"zh-CN":h_,"en-US":f_,"ja-JP":m_});const pne="",E9={...In,blockType:"list",createBlockContent:d_,convertFrom:OO,convertTo:FO,handleDrop:BO,notify:vO},v0=S("paragraph");class g_{constructor(e){m(this,"id","BlockParagraphProvider");this.editor=e}isChecked(e,t){return!!(e[t]||e.level&&(e.ordered===!0&&!e.checkbox&&t==="ordered-list"||e.ordered===!1&&!e.checkbox&&t==="unordered-list")||t==="check-list"&&e.checkbox)}getAvailableCommands(e,t){const o=[],r={"unordered-list":[R.t("commands.unordered"),Bo("CtrlOrCmd+Shift+L"),kL],"ordered-list":[R.t("commands.ordered"),Bo("CtrlOrCmd+Shift+U"),yL],"check-list":[R.t("commands.check"),void 0,wL],link:[R.t("commands.link"),Bo("CtrlOrCmd+K"),hv],quoted:[R.t("commands.quote"),void 0,BL]};if(ee(e,t)){const i=ie(t),s=De(t),l=Io(e,t),a=e.getBlockData(t);Object.entries(r).forEach(([d,[h,p,A]])=>{const v=[];if(this.isChecked(a,d)&&v.push("checked"),d==="link"){if(!e.selection.range.isSimple())return;e.selection.range.getSelectedBlocks().length!==1&&v.push("disabled")}o.push({blockId:i,blockType:s,blockKind:l,id:d,name:h,desc:p,states:v,icon:A,groupIndex:600})})}return o}convertLink(e,t,o){g(v0,Hr(t.start),""),g(v0,Hr(t.start),"");const r="bottom-start",i=t.start.offset,s=t.end.offset,l=(v,B)=>{e.undoManager.runInGroup(()=>{try{const D=e.selection.range.isCollapsed();let I;if(D){I=jr(e.getBlockText(o),s,v,{link:B}),e.setBlockText(o,I);return}I=hh(e.getBlockText(o),i,s,v),I=Ia(i,v.length,I,"link",B),e.setBlockText(o,I),e.selection.selectBlock(o,i+v.length),e.focus()}catch(D){v0.error(D)}})},a=()=>{e.selection.selectBlock(o,s),e.focus()},d=Ti(e,o,t)[0];if(!d)return;const h=Li(e,o,"link-button-anchor",d),p=e.getBlockText(o),A=Ta(p,i);fu(e,{target:h,linkText:e.getSelectedText(),linkUrl:(A==null?void 0:A.link)||"",onFinished:l,onClose:a,placement:r})}convertToList(e,t,o){const r=Xd(e,t,"list",{offset:0,data:{listType:o}});r&&e.undoManager.runInGroup(()=>{const i=be(t),s=ne(t);e.insertBlock(ae(s),i,r.blockData),e.deleteBlock(t)})}executeCommand(e,t,o,r){var a;if(!ee(e,t))return!1;const i=r.id,s=(a=r.states)==null?void 0:a.includes("checked");let l=!1;if(i==="unordered-list"&&(s?gc(e,t):this.convertToList(e,t,"unordered"),l=!0),i==="ordered-list"&&(s?gc(e,t):this.convertToList(e,t,"ordered"),l=!0),i==="check-list"&&(s?gc(e,t):this.convertToList(e,t,"unchecked"),l=!0),i==="quoted"){const h=e.getBlockData(t).quoted;e.updateBlockData(t,{quoted:h?void 0:!0}),e.focus(),l=!0}if(i==="link"){const d=lf(e);d.disableTextToolbar(),d.hide(),setTimeout(()=>{d.enableTextToolbar()},1e3),this.convertLink(e,o,t),l=!0}return l}}const p_={left:eu,right:Sp,center:Lp};class C_{constructor(e){m(this,"id","BlockAlignProvider");this.editor=e}applyAlignStyle(e,t,o){Object.keys(p_).includes(o)?e.updateBlockData(t,{align:o}):e.updateBlockData(t,{align:null})}isChecked(e,t){return e.align===t}getAvailableCommands(e,t,o){if(ee(e,t)){const r=ie(t),i=De(t),s=Io(e,t),l=e.getBlockData(t),a=d=>{var p;const h=w("span",["toolbar-item-name-container"],null);for(const A of d.children)if((p=A.states)!=null&&p.includes("checked"))return h.innerHTML=A.icon||eu,h;return h.innerHTML=eu,h};return[{id:"align",name:R.t("commands.alignGroup"),blockId:r,blockType:i,blockKind:s,groupIndex:700,dropdown:!0,element:a,manualShowChildren:!0,childrenPlacement:"bottom-start",defaultCheckedChildren:["align-left"],children:[{id:"align-left",name:R.t("commands.alignLeft"),icon:eu,states:this.isChecked(l,"left")?["checked"]:[]},{id:"align-center",name:R.t("commands.alignCenter"),icon:Lp,states:this.isChecked(l,"center")?["checked"]:[]},{id:"align-right",name:R.t("commands.alignRight"),icon:Sp,states:this.isChecked(l,"right")?["checked"]:[]}],childrenType:"menu"}]}return[]}executeCommand(e,t,o,r){if(!ee(e,t))return!1;if(r.id.startsWith("align")){const i=r.id.replace(/^align-/,"");return this.applyAlignStyle(e,t,i),this.editor.focus(),!0}return!1}}function A_(n){const t=n.selection.range;if(t.isCollapsed()||t.start.blockId!==t.end.blockId||!t.start.isSimple()||!t.end.isSimple()||t.end.offset-t.start.offset!==1)return!1;const o=n.getBlockById(t.start.blockId);return Sa(n,o,t.start.offset).charType==="box"}const b_=S("toolbar-handler"),v_={id:"",name:"",type:"separator"};class pc{constructor(e){m(this,"toolbar");m(this,"toolbarType","object");m(this,"mouseDown",!1);m(this,"oldRange",null);m(this,"hoveringBlock",null);m(this,"hoveringTextChild",null);m(this,"_disableTextToolbar",!1);m(this,"handleButtonClick",(e,t)=>{this.toolbarType==="text"?(this.editor.editorCommandProviders.executeCommand(this.editor.selection.range,t,{}),this.showTextToolbar("click")):this.hoveringBlock&&zR(this.editor,this.hoveringBlock,this.hoveringTextChild,t)});m(this,"handleClose",()=>{Fp(this.editor)&&this.editor.focus()});m(this,"handleClosing",(e,t)=>{if(this.toolbarType==="object"){const o=rC(t);if(this.hoveringBlock===o)return!1}return!0});m(this,"handleDocumentMouseDown",e=>{e.button===0&&(document.addEventListener("mouseup",this.handleDocumentMouseUp),this.mouseDown=!0)});m(this,"handleDocumentMouseUp",()=>{document.removeEventListener("mouseup",this.handleDocumentMouseUp),this.mouseDown=!1,this.handleSelectionChange(this.editor)});m(this,"handleHoveringBlockChildChange",(e,t,o,r)=>{if(!(this.hoveringBlock===e&&this.hoveringTextChild===t)&&(this.hoveringBlock=e,this.hoveringTextChild=t,!(this.toolbar.isVisible&&this.toolbarType==="text"))){if(!e){this.toolbar.close("fromHover");return}this.showObjectToolbar(r)}});m(this,"handleSelectionChange",Ht.default(e=>{var o;if(g(b_,e===this.editor,"editor mismatch"),e.selection.range.isCollapsed()||this.mouseDown){if(this.toolbarType==="object"){const r=(o=this.toolbar.tippyInstance)==null?void 0:o.reference,i=this.editor.selection.focusedBlock;if(r&&Ke(r,i))return}this.toolbar.close("selectionChange"),this.oldRange=null;return}if(!this.editor.isWritable()){this.toolbar.close("selectionChange"),this.oldRange=null;return}if(e.selection.range.getSelectedBlocks().length===0){this.toolbar.close("selectionChange"),this.oldRange=null;return}this.oldRange&&this.oldRange.isEqual(e.selection.range)||(this.oldRange=e.selection.range,this.showTextToolbar("selectionChange"))},50));this.editor=e;const t=e.options.componentsOptions.popover;this.toolbar=new ou([],void 0,{tooltipId:e.clientId,id:"editor-toolbar",overflowBoundary:t==null?void 0:t.overflowBoundary,refuseOverflow:!0,padding:20}),this.toolbar.on("click",this.handleButtonClick),this.toolbar.on("close",this.handleClose),this.toolbar.on("closing",this.handleClosing),this.bindEvents(),e.addListener("selectionChanged",this.handleSelectionChange),pt.get(e).addListener("childChange",this.handleHoveringBlockChildChange),pt.get(e).addFilter(this),e.editorCommandProviders.registerCommandProvider(new WR(e)),e.editorCommandProviders.registerCommandProvider(new g_(e)),e.editorCommandProviders.registerCommandProvider(new C_(e))}disableTextToolbar(){this._disableTextToolbar=!0}enableTextToolbar(){this._disableTextToolbar=!1}hide(){this.toolbar.close("selectionChange")}destroy(){this.unbindEvents(),this.toolbar.destroy(),this.editor.removeListener("selectionChanged",this.handleSelectionChange),pt.get(this.editor).removeListener("childChange",this.handleHoveringBlockChildChange)}isInBlock(e,t){return e!==this.hoveringBlock?!1:!!(t.target&&t.target instanceof Node&&this.toolbar.popper&&Ke(this.toolbar.popper,t.target))}bindEvents(){document.addEventListener("mousedown",this.handleDocumentMouseDown)}unbindEvents(){document.removeEventListener("mousedown",this.handleDocumentMouseDown)}update(e){this.showTextToolbar(e)}showTextToolbar(e){var D,I;if(this._disableTextToolbar||!this.editor.isWritable())return;const o=this.editor.selection.range.getSelectedBlocks();if(o.length===0)return;const r=o[0];if(!r)return;if(o.length===1&&Lt(r.block)){e==="click"&&this.showObjectToolbar(null);return}if(A_(this.editor))return;if(ne(r.block)===this.editor.rootContainer&&be(r.block)===0){this.toolbar.close("selectionChange");return}const i=this.editor.editorCommandProviders.getCommands(this.editor.selection.range),s=new Map;i.forEach(_=>{const M=_.groupIndex,H=s.get(M);H?H.push(_):s.set(M,[_])});const l=[[]],a=Array.from(s.entries()).sort((_,M)=>_[0]-M[0]);for(let _=0;_<a.length;_++){const[,M]=a[_];if(M.length===0)continue;let H=l[l.length-1];H.length>0&&H[H.length-1].groupIndex!==M[M.length-1].groupIndex&&(H=[],l.push(H)),H.push(...sf(M))}if(l.length===0){this.toolbar.close("selectionChange");return}this.toolbarType="text";const d=[];if(l.forEach((_,M)=>{const H=_.sort((z,q)=>{var re,fe;return((re=z.order)!=null?re:0)-((fe=q.order)!=null?fe:0)});d.push(...H),M!==l.length-1&&d.push(v_)}),d.length===0){this.toolbar.close("selectionChange");return}this.toolbar.updateItems(d);const h=o[o.length-1],p=!this.editor.selection.range.isReverse()&&h!==r,A=p?h:r,v=_R(this.editor,A),B=Li(this.editor,A.block,"editor-quick-menu",v);this.toolbar.manualShow(B,{placement:p?"bottom":"top"}),(I=(D=this.toolbar.tippyInstance)==null?void 0:D.popperInstance)==null||I.update()}showObjectToolbar(e){var l,a;if(!this.hoveringBlock||this.mouseDown)return;const t=this.hoveringBlock,o=this.hoveringTextChild,{commands:r,element:i}=HR(this.editor,t,o);if(!r.length||!i){this.toolbar.close("fromHover");return}this.toolbarType="object",this.toolbar.isVisible&&((a=(l=this.toolbar)==null?void 0:l.tippyInstance)==null?void 0:a.reference)!==i&&this.toolbar.close("fromHover");const s=()=>{let d;const h=i.getClientRects();if(h.length>1){if(d=o?h[h.length-1]:h[0],e)for(let p=0;p<h.length;p++){const A=h[p],v=new DOMRect(A.x-4,A.y-4,A.width+8,A.height+8);if(v.x<e.clientX&&e.clientX<v.right&&v.y<e.clientY&&e.clientY<v.bottom){d=A;break}}}else{if(d=i.getBoundingClientRect(),o){const p=o.getBoundingClientRect();return new DOMRect(p.x,p.y,p.width,p.height)}return new DOMRect(h[0].x,h[0].y,h[0].width,h[0].height)}if(e){const p=d.y,A=e.clientX;return new DOMRect(A,p,10,d.height)}return d};this.toolbar.updateItems(r),this.toolbar.isVisible||this.toolbar.manualShow(i,{placement:o?"bottom":"top",getReferenceClientRect:s})}static register(e){return e.addCustom("toolbar-handler",t=>new pc(t))}static get(e){return e.getCustom("toolbar-handler")}}function pf(n,e,t){n.getBlockData(e).heading===t?n.updateBlockData(e,{heading:null}):n.updateBlockData(e,{heading:t})}function x9(n,e,t){["left","center","right"].includes(t)?n.updateBlockData(e,{align:t}):n.updateBlockData(e,{align:null})}function y0(n,e){const o=n.getBlockData(e).quoted;n.updateBlockData(e,{quoted:o?void 0:!0})}function k0(n,e){return!!(n[e]||n.level&&(n.ordered===!0&&!n.checkbox&&e==="ordered-list"||n.ordered===!1&&!n.checkbox&&e==="unordered-list")||e==="check-list"&&n.checkbox)}function w0(n,e,t){if(!n.selection.range.focus.isSimple())return;const r=n.getBlockData(e);let i;switch(t){case"unordered-list":i=k0(r,"unordered-list")?void 0:"unordered";break;case"ordered-list":i=k0(r,"ordered-list")?void 0:"ordered";break;case"check-list":i=k0(r,"check-list")?void 0:"unchecked";break}if(i){const s=Xd(n,e,"list",{offset:0,data:{listType:i}});s&&n.undoManager.runInGroup(()=>{const l=be(e),a=ne(e);n.deleteBlock(e),n.insertBlock(ae(a),l,s.blockData)})}else gc(n,e)}const y_=Object.freeze(Object.defineProperty({__proto__:null,applyHeadingStyle:pf,applyAlignStyle:x9,applyQuoteStyle:y0,applyList:w0},Symbol.toStringTag,{value:"Module"})),k_=[kp,wp,Bp,Ep,xp,Ip,Tp,Dp],w_={Unordered:gv,Ordered:pv,Checkbox:fv,Quote:mv};function I9(n,e){const t=n;t.blockOptions=e,t.itemType="insert-block",n.children&&n.children.forEach(o=>I9(o,e))}function B_(){return{name:"basic",insertBlockCommandItems:[{id:"text",icon:nu,name:R.t("commands.text"),order:0,group:"basics",value:"text"}]}}function B0(n=1){var r;const e={name:"basic",insertBlockCommandItems:[]};let t=cf();t<=4?t=5:t<8&&(t+=1);let o=n;for(;o<=t;){const i=`heading-${o}`;(r=e.insertBlockCommandItems)==null||r.push({id:i,icon:k_[o-1],name:R.t("quickMenu.basic.heading.title",{heading:String(o)}),order:o,group:"basics",value:String(o),subText:pn(i)}),o++}return e}function E_(){const n={name:"basic",insertBlockCommandItems:[]};return["Unordered","Ordered","Checkbox","Quote"].forEach((t,o)=>{var i;const r=`insert-${t.toLocaleLowerCase()}`;(i=n.insertBlockCommandItems)==null||i.push({id:r,name:R.t(`quickMenu.basic.${t.toLocaleLowerCase()}`),icon:w_[t],value:t.toLocaleLowerCase(),group:"basics",order:10+o,subText:pn(r)})}),n}class T9{constructor(e){this.withPlainText=e}getCommands(){const e=B_(),t=B0(),o=E_();return[...this.withPlainText?e.insertBlockCommandItems||[]:[],...t.insertBlockCommandItems||[],...o.insertBlockCommandItems||[]]}updateBlock(e,t,o,r){const{value:i,id:s}=r;return s.startsWith("heading-")?pf(e,o,Number.parseInt(i!=null?i:"1",10)||1):i==="ordered"||i==="unordered"||i==="checkbox"?w0(e,o,{ordered:"ordered-list",unordered:"unordered-list",checkbox:"check-list"}[i]):i==="quote"&&y0(e,o),null}async handleUpdateBlockCore(e,t){const o=e.getBlockByIndex(t.containerId,t.blockIndex);return this.updateBlock(e,t.containerId,o,t.item)}async handleInsertEmptyBlockCore(e,t){const{containerId:o,blockIndex:r}=t,i=e.insertTextBlock(void 0,o,r);return this.updateBlock(e,t.containerId,i,t.item)}async executeCommand(e,t,o){if(o.from==="quick-menu"){const r=e.getBlockById(o.blockId),i=e.getParentContainer(r),s=ae(i),l=e.getBlockIndex(r);e.undoManager.runInGroup(()=>this.handleUpdateBlockCore(e,{item:t,containerId:s,blockIndex:l})),e.focus()}else o.from==="block-menu"&&(e.undoManager.runInGroup(()=>this.handleInsertEmptyBlockCore(e,{item:t,containerId:o.containerId,blockIndex:o.blockIndex})),e.focus());return null}}const D9={basics:100,system:200,common:300,thirdParty:400};class E0{constructor(){m(this,"dataUrl","");m(this,"error",null)}destroy(){}setDataUrl(e){this.error=null,this.dataUrl=e}setError(e){this.dataUrl="",this.error=e}}const x_=S("mathjax-converter"),I_="MathJax-script";async function T_(n){var o;window.MathJax||(window.MathJax={options:{skipHtmlTags:["script","noscript","style","textarea","pre","code","annotation","annotation-xml","body"]}});const e=n.getComponentOptions("mathjax"),t=((o=e==null?void 0:e.cdn)==null?void 0:o.mathjax)||"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js";await vs(t,I_)}function D_(){try{window.MathJax&&window.MathJax.texReset()}catch{}}async function S9(n,e){const t="mathjax2Svg";try{await wo.lock(t),D_(),await T_(n);const o=await window.MathJax.tex2svgPromise(e),r=o.querySelector("merror");if(r)throw new Error(r.textContent);return o.querySelector("svg").outerHTML}catch(o){throw x_.error(o),o}finally{wo.release(t)}}async function L9(n,e){const t=await S9(n,e);return t?await Sm(t,"image/svg+xml"):""}async function x0(n,e){const o=await S9(n,e),r=new File([o],"math.svg");return(await n.doc.uploadResource(r)).resourceId}const M9=S("edit-mathjax");class S_{constructor(){m(this,"editMathjaxPopup",null);m(this,"onChange",null);m(this,"tex","");m(this,"handleShow",()=>{setTimeout(()=>{this.getTextarea().focus()})});m(this,"handleClose",e=>{var o;const t=e.content.querySelector("textarea");if(t){const r=t.value;r!==this.tex&&((o=this.onChange)==null||o.call(this,r,!0))}});m(this,"handleKeyup",e=>{var t;e.isComposing||(e.key==="Escape"&&((t=this.editMathjaxPopup)==null||t.close("cancelBar")),this.handleChange(e.target.value))});m(this,"handleChange",Ht.default(e=>{var t;(t=this.onChange)==null||t.call(this,e,!1)},300))}editMathjax(e,t,o){if(!this.editMathjaxPopup)this.editMathjaxPopup=new Xa(this.createPopupContent(t));else{const r=this.getTextarea();r.value=t}this.tex=t,this.editMathjaxPopup.addListener("show",this.handleShow),this.editMathjaxPopup.manualShow(e,{theme:"light"}),this.editMathjaxPopup.removeAllListeners("close"),this.editMathjaxPopup.addListener("close",this.handleClose),this.onChange=o}createPopupContent(e){const t=w("textarea",["mathjax-editor-textarea"],null);return t.value=e,t.addEventListener("keyup",this.handleKeyup),t}getTextarea(){g(M9,this.editMathjaxPopup,"no exists mathjax editor popup");const e=this.editMathjaxPopup.content.querySelector("textarea");return g(M9,e,"no textarea"),e}destroy(){var e;this.onChange=null,(e=this.editMathjaxPopup)==null||e.removeAllListeners()}}function R9(n,e,t,o){n.addCustom("mathjax-editor",()=>new S_).editMathjax(e,t.trim(),o)}function O9(){return{insert:" ",attributes:{id:K(),box:!0,type:"math",tex:" ",src:"",created:Date.now()}}}function Cf(n,e){const t=n.getBoxData(e),o=oe(e);if(!o)return;const r=Mi(o,e);n.selection.selectBlock(o,r.start,r.end);const i=async(s,l)=>{if(!s.trim()){n.updateBoxData({...t,tex:s,src:null});return}try{await wo.lock("convertAndUploadMathjax");const a=await x0(n,s);n.updateBoxData({...t,tex:s,src:a})}catch(a){const d=n.getBoxData(e);n.addCustom(`mathjax-box-${d.id}`,()=>new E0).setError(a),n.updateBoxData({...t,tex:s,src:""})}finally{wo.release("convertAndUploadMathjax"),l&&n.focus()}};R9(n,e,t.tex,i)}const _9=S("mathjax-box");function I0(n,e){n.selection.updateSelection(null);const t=e.target;!t||!(t instanceof HTMLElement)||n.domEvents.removeEventListener(t,null,I0)}async function L_(n,e,t){try{if(!e.tex.trim())return;const o=await L9(n,e.tex),r=n.findBoxById(e.id);if(!r)return;const i=Hm(r);i.innerHTML="";const s=w("img",["mathjax"],i);s.src=o,t.setDataUrl(o),n.domEvents.addEventListener(s,"load",I0)}catch(o){t.setError(o);const r=n.findBoxById(e.id);if(!r)return;const i=r.querySelector(".mathjax-tex-text");W(i,"mathjax-error"),i.innerText=o.message,n.selection.updateSelection(null)}}function M_(n,e,t,o){const r=o,i=n.addCustom(`mathjax-box-${r.id}`,()=>new E0);if(r.src||i.dataUrl){const a=w("img",["mathjax"],t);a.src=n.doc.buildResourceUrl(r.src||i.dataUrl),n.domEvents.addEventListener(a,"load",I0);return}const s=["mathjax-tex-text"];let l=r.tex;l.trim()?i.error&&(l=i.error.message,s.push("mathjax-error")):l=R.t("mathjax.emptyText"),w("span",s,t,l),L_(n,r,i)}function R_(n,e){const t={id:K(),box:!0,type:"math",tex:e,src:"",created:Date.now()};return x0(n,e).then(o=>{if(!n.findBoxById(t.id))return;const i={...t,src:o};n.updateBoxData(i)}).catch(o=>{_9.error(`failed to convert and upload mathjax: ${JSON.stringify(o)}`)}),t}function O_(n,e,t,o){const r=e;return o==="text"?r.tex:o==="markdown"?` $${r.tex}$ `:r.src?`<img src="${n.doc.buildResourceUrl(r.src,{withToken:!0})}" />`:`<code>$${r.tex}$</code>`}function __(n,e,t){const o=oe(e);g(_9,o,"failed to get block"),!(n.readonly||!n.isBlockWritable(o))&&Cf(n,e)}function F_(){return{abstract:R.t("mathjax.abstract")}}const T0={boxType:"math",updateBoxContent:M_,convertFrom:R_,convertTo:O_,handleClickBox:__,getBoxProperties:F_};async function P_(n,e,t){try{const o=e.embedData,r=await L9(n,o.mathjaxText),i=n.findBlockById(e.id);if(!i)return;const s=Re(i);s.innerHTML="";const l=w("img",["mathjax"],s);l.src=r,t.setDataUrl(r)}catch(o){t.setError(o)}}function N_(n,e){if(n.readonly||!e.target||!(e.target instanceof Node))return;const t=oe(e.target);if(!t||!Lt(t)||Un(t)!=="math")return;const o=Re(t),r=o.querySelector("img")||o.querySelector("span.mathjax-tex-text");if(!r||!Ke(r,e.target))return;const s=n.getBlockData(t).embedData;R9(n,r,s.mathjaxText,async l=>{const a=await x0(n,l),d={mathjaxText:l,src:a};n.updateEmbedData(t,d)})}function $_(n,e,t){const o=t.embedData,r=n.addCustom(`mathjax-block-${t.id}`,()=>new E0);if(n.domEvents.addEventListener(e,"click",N_),o.src||r.dataUrl){const i=w("img",["mathjax"],e);i.src=n.doc.buildResourceUrl(o.src||r.dataUrl);return}r.error,w("span",["mathjax-tex-text"],e,o.mathjaxText),P_(n,t,r)}function H_(n,e,t){if(!ee(n,e))return null;const o=n.getBlockString(e).trim();if(!o||!o.startsWith("$$")||!o.endsWith("$$"))return null;const r=Bm(o,"$");if(!r)return null;const i={mathjaxText:r,src:""};return{blockData:{id:K(),type:"embed",embedType:"math",embedData:i}}}function j_(n){return{name:"Mathjax"}}function U_(n,e){const t=Re(e);n.domEvents.removeAllListeners(t)}function z_(n,e,t,o){const r=e.embedData;return o==="html"?`<img src="${n.doc.buildResourceUrl(r.src,{withToken:!0})}" />`:o==="markdown"?`
395
395
  $$${r.mathjaxText}$$
396
- `:r.mathjaxText}function V_(){return{abstract:R.t("mathjax.abstract")}}const F9={embedType:"math",createEmbedContent:$_,getOptions:j_,convertFrom:H_,handleDeleteBlock:U_,convertTo:z_,getBlockProperties:V_},Cne="",W_={mathjax:{emptyText:"\u7A7A\u7684\u516C\u5F0F",abstract:"\u516C\u5F0F"}},q_={mathjax:{emptyText:"Empty Tex",abstract:"TeX"}},G_={mathjax:{emptyText:"\u6570\u5F0F\u306A\u3057",abstract:"\u6570\u5F0F"}};R.mergeLang({"zh-CN":W_,"en-US":q_,"ja-JP":G_});function Z_(n,e,t,o){const r=n.getBlockByIndex(e,t),i=n.getBlockText(r),{left:s}=xn(i,o);if(!rt(s).endsWith("$$$$"))return!1;const a=o-4,d=o,h={id:K(),box:!0,type:"math",tex:" ",src:"",created:Date.now()};return n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,a,d-a),n.insertBoxToBlock(r,a,h),setTimeout(()=>{const p=n.getBoxById(h.id);Cf(n,p)})}),!0}class Q_{handleAfterInsertText(e,t,o,r,i){return!!(i===" "&&Z_(e,t,o,r))}}const Cc=S("inline-box-items");function Y_(n,e,t){return n.undoManager.runInGroup(()=>{var s;let o=n.getBlockByIndex(e,t);ht(n,o)||(o=n.insertTextBlock([],e,t));const r=O9();n.setBlockText(o,[r]);const i=(s=r.attributes)==null?void 0:s.id;return g(Cc,i,"mathjax box id is empty"),setTimeout(()=>{const l=n.getBoxById(i);Cf(n,l)},100),o})}function J_(n,e,t){let o=n.getBlockByIndex(e,t),r="bottom-start";return ht(n,o)||(r="top-start"),fu(n,{target:o,linkText:"",linkUrl:"",onFinished:(l,a)=>{n.undoManager.runInGroup(()=>{try{ht(n,o)||(o=n.insertTextBlock([],e,t));const d=lo(l,{link:a}),h=lo(" ",null),p=[d,h];n.insertTextToBlock(o,0,p),n.selection.selectBlock(o,rn(p)),n.focus()}catch(d){Cc.error(d)}})},onClose:()=>{n.focus()},placement:r}),o}function K_(n,e,t){return n.undoManager.runInGroup(()=>{var l;const o=n.getBlockByIndex(e,t),r=n.selection.range;g(Cc,Hr(r.start),"invalid block position");const i=O9();n.insertBoxToBlock(o,r.start.offset,i.attributes);const s=(l=i.attributes)==null?void 0:l.id;return g(Cc,s,"mathjax box id is empty"),setTimeout(()=>{const a=n.getBoxById(s);Cf(n,a)},100),o})}function X_(n,e,t){const o=n.getBlockByIndex(e,t),r=n.selection.range;g(Cc,Hr(r.start),"invalid block position");const i=Ti(n,o,r);if(i.length===0)return;const s=i[0],l=Li(n,o,"quick-menu-inline-link",s);fu(n,{target:l,linkText:"",linkUrl:"",onFinished:(h,p)=>{n.undoManager.runInGroup(()=>{try{const A=n.getBlockText(o),v=jr(A,r.start.offset,h,{link:p});n.setBlockText(o,v),n.selection.selectBlock(o,r.start.offset+h.length),n.focus()}catch(A){Cc.error(A)}})},onClose:()=>{n.focus()},placement:"bottom-start"})}class P9{getCommands(){return[{id:"insert-math",name:R.t("quickMenu.inlineBox.math"),icon:SL,order:900,group:"common",subText:pn("insert-math")},{id:"insert-link",name:R.t("quickMenu.inlineBox.link"),icon:hv,order:400,group:"common",subText:pn("insert-link")}]}async handleUpdateBlockCore(e,t){switch(t.item.id){case"insert-math":return K_(e,t.containerId,t.blockIndex);case"insert-link":return X_(e,t.containerId,t.blockIndex);default:return null}}async handleInsertEmptyBlockCore(e,t){switch(t.item.id){case"insert-math":return Y_(e,t.containerId,t.blockIndex);case"insert-link":return J_(e,t.containerId,t.blockIndex);default:return null}}async executeCommand(e,t,o){if(o.from==="quick-menu"){const r=e.getBlockById(o.blockId),i=e.getParentContainer(r),s=ae(i),l=e.getBlockIndex(r);e.undoManager.runInGroup(()=>this.handleUpdateBlockCore(e,{item:t,containerId:s,blockIndex:l}))}else o.from==="block-menu"&&e.undoManager.runInGroup(()=>this.handleInsertEmptyBlockCore(e,{item:t,containerId:o.containerId,blockIndex:o.blockIndex}));return null}}function eF(n,e={withPlainText:!1}){var i,s;const{withPlainText:t}=e,o=(s=(i=n.options.componentsOptions)==null?void 0:i.quickMenu)==null?void 0:s.commandProviders;if(!o)return[];const r=[];return[...o,new T9(t),new P9].forEach(l=>{const a=l.getCommands(n);r.push(...a.map(d=>({...d,itemType:"insert-block",commandProvider:l})))}),r}function tF(n,e={withPlainText:!1}){const t=[];return n.editorBlocks.forEach(o=>{if(!o.getOptions)return;const r=o.getOptions(n);!r.insertBlockCommandItems||(r.insertBlockCommandItems.forEach(i=>{I9(i,r)}),t.push(...r.insertBlockCommandItems))}),t.push(...eF(n,e)),t}function D0(n,e={withPlainText:!1}){const t=tF(n,e),o=new Map;t.forEach(s=>{var d;const l=(d=s.group)!=null?d:"";let a=o.get(l);a?a.items.push(s):(a={group:l,order:s.groupOrder||D9[l]||1e3,items:[s]},o.set(l,a))});const r=Array.from(o.values());r.sort((s,l)=>s.order-l.order),r.forEach(s=>{s.items.sort((l,a)=>{var d,h;return((d=l.order)!=null?d:0)-((h=a.order)!=null?h:0)})});const i=[];return r.forEach((s,l)=>{const a=`blockMenu.section.${s.group||"common"}`,d=R.t(a),h=d===a?s.group:d;i.push({id:`section-${l}`,name:h,type:"section",group:s.group,itemType:"insert-block"}),i.push(...s.items.map(p=>({...p})))}),i}function nF(n,e,t){const o=n.getFocusedBlock();if(!o)return;const r=n.getParentContainer(o),i=ae(r);let l=n.getBlockIndex(o);if(ht(n,o)||(l+=1),e.commandProvider){e.commandProvider.executeCommand(n,e,{from:"quick-menu",...t});return}!e.blockOptions||!e.blockOptions.handleInsertEmptyBlock||e.blockOptions.handleInsertEmptyBlock(n,{containerId:i,blockIndex:l,item:e})}const N9=S("quick-menu"),oF={id:"quick-menu",trigger:["/"]},rF=5;class Af{constructor(e,t=oF){m(this,"suggest");m(this,"items");m(this,"maxHeading");m(this,"firstEmptyOffset",-1);m(this,"queryItems",async(e,t)=>{if(this.items.length===0?this.initMenuItems():this.refreshMenuItems(),t){const o=new Set,r=t.toLocaleLowerCase().replace(/^\s+|\s+$/g,""),i=this.items.filter(s=>{if(s.type==="section")return!0;if(s.name.toLocaleLowerCase().indexOf(r)!==-1||yM(s).toLocaleLowerCase().indexOf(r)!==-1)return o.add(s.group),!0;const l=`blockMenu.section.${s.group||"common"}`,a=R.t(l),d=a===l?s.group:a;return(d==null?void 0:d.toLocaleLowerCase().indexOf(r))!==-1?(o.add(s.group),!0):!1}).filter(s=>s.type==="section"?o.has(s.group):!0);return i.length?this.firstEmptyOffset=-1:this.handleEmptySearch(),i}return this.items});m(this,"onClose",()=>{this.firstEmptyOffset=-1});m(this,"onShow",(e,t,o,r)=>{const i=this.editor.getBlockByIndex(t,o);if(!ro(i)){const s=oe(ne(i));if(s&&De(s)==="code")return!1}return!0});m(this,"onClickItem",(e,t)=>{const o=t;o.itemType==="insert-block"&&(g(N9,o.blockOptions||o.commandProvider,"invalid quick item, no block options or command provider"),g(N9,this.suggest.anchor,"invalid suggest, no anchor"),this.options.id==="empty-block-menu"&&this.editor.focus(),nF(this.editor,o,this.suggest.anchor))});this.editor=e,this.options=t,this.items=[],this.maxHeading=cf(),this.suggest=new Np(e,{id:t.id||"quick-menu",trigger:t.trigger,needSpaceBeforeTrigger:!0,autoDeleteTrigger:!0,highlight:!0,onClose:this.onClose,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems})}get menu(){return this.suggest.menu.menu}destroy(){this.suggest.destroy()}initMenuItems(){const e=D0(this.editor);this.items=e}refreshMenuItems(){let e=null,t=0;const o=cf();if(o!==this.maxHeading){const r=new T9,s=r.getCommands().map(l=>({...l,itemType:"insert-block",commandProvider:r}));for(let l=0;l<this.items.length;l++)this.items[l].group==="basics"&&(e||(e=l),e&&t++);e&&t&&this.items.splice(e,t,...s),this.maxHeading=o}}handleEmptySearch(){const e=this.editor.selection.getFocusedPos();if(this.firstEmptyOffset===-1){if(e.isSimple()){const{offset:t}=e;this.firstEmptyOffset=t-1}}else if(e.isSimple()){const{offset:t}=e;t-this.firstEmptyOffset>rF&&(this.suggest.close(),this.firstEmptyOffset=-1)}}}class bf{constructor(e){m(this,"instance");m(this,"mousedown",!1);m(this,"currentInstance",null);m(this,"attributeName",[]);m(this,"attributeDesc","");m(this,"observer",null);m(this,"observerCallback",null);m(this,"createContent",e=>{let t="",o=0;for(;o<this.attributeName.length&&!t;)e.hasAttribute(this.attributeName[o])&&(t=e.getAttribute(this.attributeName[o])||""),o++;const r=e.getAttribute(this.attributeDesc);if(!r)return t;const i=w("div",[],null);return w("span",[],i,t),r&&w("span",["editor-tooltip-desc"],i,r),i});m(this,"handleDocumentMouseDown",()=>{this.mousedown=!0,this.editor.domEvents.addEventListener(document,"mouseup",this.handleDocumentMouseUp)});m(this,"handleDocumentMouseUp",()=>{this.mousedown=!1,this.editor.domEvents.removeEventListener(document,"mouseup",this.handleDocumentMouseUp)});m(this,"handleShown",e=>{this.currentInstance&&this.hide(),this.currentInstance=e,this.createObserver()});m(this,"handleHidden",()=>{this.destroyObserver(),this.currentInstance=null});m(this,"handleShow",e=>{var r;const t=e.reference;if(!t||!Ke(document.body,t)||window.isDragging||this.mousedown)return!1;const o=Number.parseInt((r=t.getAttribute("data-tooltip-hide-at"))!=null?r:"",10);if(o&&Date.now()-o<1e3)return!1;if(e.reference){const i={};if(e.reference.hasAttribute("data-editor-tooltip-placement")&&(i.placement=e.reference.getAttribute("data-editor-tooltip-placement")||"top"),e.reference.hasAttribute("data-editor-tooltip-offset-x")||e.reference.hasAttribute("data-editor-tooltip-offset-y")){const s=e.reference.getAttribute("data-editor-tooltip-offset-x"),l=e.reference.getAttribute("data-editor-tooltip-offset-y");i.offset=[s?Number.parseInt(s,10):0,l?Number.parseInt(l,10):0]}if(e.reference.hasAttribute("data-editor-tooltip-maxwidth")&&(i.maxWidth=Number.parseInt(e.reference.getAttribute("data-editor-tooltip-maxwidth")||"350",10)),e.reference.hasAttribute("data-editor-tooltip-allow-markdown")&&(i.allowHTML=!0),Object.keys(i).length&&e.setProps(i),e.reference.hasAttribute(`data-editor-tooltip-${this.editor.clientId}-dynamic`)){const s=e.reference.getAttribute(`data-editor-tooltip-${this.editor.clientId}-dynamic`);e.setContent(s||"")}}return!0});this.editor=e;const t=e.clientId;this.attributeName=[`data-editor-tooltip-${t}`,`data-editor-tooltip-${t}-dynamic`,"data-editor-tooltip-common"],this.attributeDesc=`data-editor-tooltip-desc-${t}`,this.instance=um.delegate(document.body,{theme:"editor-tooltip",maxWidth:400,delay:200,target:this.attributeName.map(o=>`[${o}]`).join(","),content:this.createContent,onShow:this.handleShow,onShown:this.handleShown,onHide:this.handleHidden}),e.domEvents.addEventListener(document,"mousedown",this.handleDocumentMouseDown)}visible(){var e;return(e=this.currentInstance)==null?void 0:e.state.isVisible}hide(){var e;(e=this.currentInstance)!=null&&e.state.isVisible&&this.currentInstance.hide()}destroy(){this.destroyObserver(),this.instance.destroy(),this.editor.domEvents.removeEventListener(document,"mousedown",this.handleDocumentMouseDown),this.editor.domEvents.removeEventListener(document,"mouseup",this.handleDocumentMouseUp)}createObserver(){this.destroyObserver();const e=this.currentInstance;if(!e||!e.reference)return;this.observerCallback=Ht.default(()=>{e.reference.closest("body")||(e.hide(),this.destroyObserver())},200),this.observer=new MutationObserver(this.observerCallback);const t=document.body,o={childList:!0,attributes:!1,subtree:!0};this.observer.observe(t,o)}destroyObserver(){this.observer&&(this.observer.disconnect(),this.observer=null),this.observerCallback&&(this.observerCallback.cancel(),this.observerCallback=null)}}const iF={"text/style-bold":"bold","text/style-italic":"italic","text/style-underline":"underline","text/style-strikethrough":"line-through","text/style-code":"code","text/style-sub":"subscript","text/style-super":"superscript"};function sF(n,e){const t=new Set(Object.keys(iF)),o=e.filter(i=>t.has(i.id));return sf(o)}function vf(n,e){if(!n.isWritable())return!1;const t=n.selection.range,o=n.editorCommandProviders.getCommands(t),i=sF(n,o).find(s=>s.id===`text/${e}`);return i?(n.editorCommandProviders.executeCommand(t,i,{}),pc.get(n).update("selectionChange"),!0):!1}const S0={"CtrlOrCmd+B":n=>vf(n,"style-bold"),"CtrlOrCmd+I":n=>vf(n,"style-italic"),"CtrlOrCmd+U":n=>vf(n,"style-underline"),"CtrlOrCmd+D":n=>vf(n,"style-strikethrough")},lF={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",edit:"\u7F16\u8F91",remove:"\u53D6\u6D88\u94FE\u63A5"},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",alignGroup:"\u5BF9\u9F50\u65B9\u5F0F",heading:"\u6807\u9898 {name}",headingGroup:"\u6807\u9898\u6837\u5F0F",text:"\u6B63\u6587"}},cF={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",edit:"Edit",remove:"Remove link"}},commands:{unordered:"Bulleted list",ordered:"Numberer list",check:"Todo list",link:"Link",quote:"Quote",alignLeft:"Align left",alignRight:"Align right",alignCenter:"Align center",alignGroup:"Alignment",heading:"Heading {name}",headingGroup:"Text style",text:"Text"}},aF={quickMenu:{basic:{heading:{title:"\u898B\u51FA\u3057{heading}",space:"{markdown}\u30B9\u30DA\u30FC\u30B9"},unordered:"\u7B87\u6761\u66F8\u304D\u30EA\u30B9\u30C8",ordered:"\u756A\u53F7\u4ED8\u304D\u30EA\u30B9\u30C8",checkbox:"\u30D0\u30C3\u30AF\u30ED\u30B0",quote:"\u5F15\u7528"},inlineBox:{math:"\u6570\u5F0F",link:"URL"}},link:{textLabel:"\u6587\u672C",urlLabel:"URL",textPlaceholder:"\u30C6\u30AD\u30B9\u30C8\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",urlPlaceholder:"URL \u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",submitText:"OK",cancelText:"\u30AD\u30E3\u30F3\u30BB\u30EB",edit:"\u7DE8\u96C6",remove:"\u30EA\u30F3\u30AF\u3092\u89E3\u9664"},commands:{unordered:"\u7B87\u6761\u66F8\u304D\u30EA\u30B9\u30C8",ordered:"\u756A\u53F7\u4ED8\u304D\u30EA\u30B9\u30C8",check:"\u30D0\u30C3\u30AF\u30ED\u30B0",link:"URL",quote:"\u5F15\u7528",alignLeft:"\u5DE6\u63C3\u3048",alignRight:"\u53F3\u63C3\u3048",alignCenter:"\u4E2D\u592E\u63C3\u3048",alignGroup:"\u5BF9\u9F50\u65B9\u5F0F",heading:"\u898B\u51FA\u3057{name}",headingGroup:"\u30BF\u30A4\u30C8\u30EB\u30B9\u30BF\u30A4\u30EB",text:"\u672C\u6587"}};R.mergeLang({"zh-CN":lF,"en-US":cF,"ja-JP":aF});const Ane="";function Qs(n,...e){const t=ji(...e);return t.classList.remove("editor-button"),t.classList.add("editor-text-button"),n.append(t),t}function $9(n){lf(n).hide();const t=n.getCustom("table-border-bar");t==null||t.closeToolbar()}function uF(n){return w("div",["insert-column-button","drop-marker"],n)}const dF=S("row-height");function H9(n){const e=Te.fromTable(n),t=n.rows;g(dF,t.length===e.rowCount,"row count mismatch");const o=Array(e.rowCount).fill(0);for(let r=0;r<t.length;){let i=1,l=t[r].getBoundingClientRect().height,a=r+1;for(;a<t.length;){const d=t[a];if(d.cells.length!==0)break;i++,a++,l+=d.getBoundingClientRect().height}for(let d=0;d<i;d++)o[r+d]=l/i;r=a}return o}const hF=S("table-border-bar-dom"),fF=Vi+sc+Vi;function pu(n){const e=oe(n.contentElement);g(hF,e,"no block");const o=lt(e).querySelector(".table-border-bar-container.left"),r=Math.min(n.contentElement.offsetLeft+fF,n.rootElement.scrollLeft+Vi);o&&(o.style.left=`${-r}px`)}const Yi=S("table-border-bar-dom");function Ac(n,e){g(Yi,Vt(e),"invalid table block");const t=Ot(e),o=fr(n,e),r=lt(e),i=(p,A,v)=>{const B=w("div",["button-root",A],p),D=w("div",["button-container",A],B);B.setAttribute(`data-${A}-index`,`${v}`),D.setAttribute(`data-editor-tooltip-${n.clientId}`,A==="left"?R.t("table.insertRow"):R.t("table.insertCol")),w("span",["insert-indicator"],D),uF(D)},{selectedRows:s,selectedColumns:l}=Hp(n,e),a=()=>{const p=o.querySelector(".table-border-bar-container.top");g(Yi,p,"no top border bar container");const A=w("div",["table-border-bar-container","top"],null),v=w("div",["table-border-bar","top"],A),B=vR(t),I=Te.fromTable(t).colCount;n.selection.range.isSimple()&&i(v,"top",0);for(let _=0;_<I;_++){const M=_===I-1?B[_]+2:B[_],H=w("span",["table-border-bar-cell","top"],v);l.has(_)&&H.classList.add("selected"),H.setAttribute("data-top-index",`${_}`),H.style.width=`${M}px`,n.selection.range.isSimple()&&i(v,"top",_+1)}Ca(p,A)},d=()=>{const p=r.querySelector(".table-border-bar-container.left");g(Yi,p,"no left border bar container");const A=w("div",["table-border-bar-container","left"],null),v=w("div",["table-border-bar","left"],A);w("span",["table-border-bar-cell","corner"],v);const B=H9(t);n.selection.range.isSimple()&&i(v,"left",0),Array.from(t.rows).forEach((D,I,_)=>{const M=w("span",["table-border-bar-cell","left"],v);s.has(I)&&M.classList.add("selected"),M.setAttribute("data-left-index",`${I}`);const H=I===_.length-1?B[I]+2:B[I];M.style.height=`${H}px`,n.selection.range.isSimple()&&i(v,"left",I+1)}),Ca(p,A)};a(),d();const h=n.findCustom(hr(e));h&&pu(h)}function j9(n,e){const t=e.target;if(!(t instanceof Element))return;const o=oe(t);g(Yi,o&&Vt(o),"invalid table block"),Ac(n,o),n.selection.caret.update()}function yf(n,e){const t=e.target;if(!(t instanceof Element))return;const o=oe(t);g(Yi,o&&Vt(o),"invalid table block");const r=t.closest(".button-root");if(r){if(r.classList.contains("top")){const i=parseInt(r.getAttribute("data-top-index")||"0",10);Xv(n,o,i),Ac(n,o)}else if(r.classList.contains("left")){const i=parseInt(r.getAttribute("data-left-index")||"0",10);e9(n,o,i),Ac(n,o)}}}function kf(n,e){var s;$9(n),e.preventDefault(),e.stopPropagation();let t=null,o,r;const i=l=>{var a;if(l.target instanceof HTMLElement&&o&&t&&r!==void 0){const d=oe(l.target),h=l.target.closest(".table-border-bar");if(d===t&&h){const p=parseInt((a=l.target.getAttribute(`data-${o}-index`))!=null?a:"0",10),A=Math.min(r,p),v=Math.abs(r-p)+1;xe(l.target,"top")&&o==="top"?RR(n,d,A,v,{reverse:!0}):xe(l.target,"left")&&o==="left"&&OR(n,d,A,v,{reverse:!0})}}l.type==="mouseup"&&(t=null,r=void 0,o=void 0,document.body.removeEventListener("mousemove",i),document.body.removeEventListener("mouseup",i))};e.target instanceof HTMLElement&&xe(e.target,"table-border-bar-cell")&&(t=oe(e.target),xe(e.target,"top")?o="top":xe(e.target,"left")&&(o="left"),o&&t&&(r=parseInt((s=e.target.getAttribute(`data-${o}-index`))!=null?s:"0",10),document.body.addEventListener("mousemove",i),document.body.addEventListener("mouseup",i)))}function U9(n){const e=n.selection.range,t=su(n,e);t&&Ac(n,t)}function mF(n,e){g(Yi,Vt(e),"invalid table block");const t=fr(n,e),o=lt(e),r=w("div",["table-border-bar-container","top"],t),i=w("div",["table-border-bar-container","left"],o);Ac(n,e),n.domEvents.addEventListener(Re(e),"scroll",j9),n.domEvents.addEventListener(r,"click",yf),n.domEvents.addEventListener(i,"click",yf),n.domEvents.addEventListener(r,"mousedown",kf),n.domEvents.addEventListener(i,"mousedown",kf),n.addListener("afterClearSelection",U9)}function z9(n,e){if(!n.isWritable())return;if(fr(n,e).querySelector(".table-border-bar-container")){Ac(n,e);return}mF(n,e)}function V9(n,e){g(Yi,Vt(e),"invalid table block");const t=fr(n,e),o=lt(e),r=t.querySelectorAll(".table-border-bar-container"),i=o.querySelectorAll(".table-border-bar-container");r.forEach(s=>{n.domEvents.removeEventListener(s,"click",yf),n.domEvents.removeEventListener(s,"mousedown",kf),s.remove()}),i.forEach(s=>{n.domEvents.removeEventListener(s,"click",yf),n.domEvents.removeEventListener(s,"mousedown",kf),s.remove()}),n.domEvents.removeEventListener(Re(e),"scroll",j9),n.addListener("afterClearSelection",U9)}function gF(n,e){g(Yi,Vt(e),"invalid table block");const o=fr(n,e).querySelector(".table-border-bar-container.top");return o?o.getBoundingClientRect().height:0}class pF{constructor(e,t){m(this,"toolbar");m(this,"handleSelectionChange",(e,t)=>{!e.isVisible||(t==="delete-columns"?(Wi(this.editor,this.tableBlock,!0,!0),qi(this.editor,this.tableBlock,!0,!0)):t==="delete-rows"?(Wi(this.editor,this.tableBlock,!0,!1),qi(this.editor,this.tableBlock,!0,!1)):(Wi(this.editor,this.tableBlock,!1),qi(this.editor,this.tableBlock,!1)))});m(this,"handleClick",(e,t,o)=>{t.id==="delete-columns"?jp(this.editor.selection.range):t.id==="delete-rows"&&Up(this.editor.selection.range)});m(this,"handleToolbarClose",()=>{this.tableBlock&&su(this.editor,this.editor.selection.range)===this.tableBlock&&(Wi(this.editor,this.tableBlock,!1),qi(this.editor,this.tableBlock,!1))});this.editor=e,this.tableBlock=t;const o=e.options.componentsOptions.popover;this.toolbar=new ou([],void 0,{overflowBoundary:o==null?void 0:o.overflowBoundary,refuseOverflow:!0,tooltipId:this.editor.clientId}),this.toolbar.addListener("selectionChange",this.handleSelectionChange),this.toolbar.addListener("click",this.handleClick),this.toolbar.addListener("close",this.handleToolbarClose)}close(){this.toolbar.close("cancelBar")}update(){var r,i,s,l;const{selectedColumns:e,selectedRows:t}=Hp(this.editor,this.tableBlock);if(!this.editor.isWritable())return;if(e.size>0&&t.size>0){this.toolbar.close("cancelBar");return}if(e.size===0&&t.size===0){this.toolbar.close("cancelBar");return}const o=Ti(this.editor,this.tableBlock,this.editor.selection.range)[0];if(!o){this.toolbar.close("cancelBar");return}if(e.size>0){const a={id:"delete-columns",name:R.t("table.deleteCol"),icon:CL};this.toolbar.updateItems([a]);const d=Li(this.editor,this.tableBlock,"table-row-column-delete",o);this.toolbar.manualShow(d,{placement:"top"})}else{const a={id:"delete-rows",name:R.t("table.deleteRow"),icon:pL};this.toolbar.updateItems([a]);const d=new DOMRect(o.left-Vi,o.top,Vi,o.height),h=Li(this.editor,this.tableBlock,"table-row-column-delete",d);this.toolbar.manualShow(h,{placement:"left"});const p={modifiers:[]},A=this.editor.options.componentsOptions.popover;(r=p==null?void 0:p.modifiers)==null||r.push({name:"flip",options:{boundary:A==null?void 0:A.overflowBoundary,fallbackPlacements:["left","right"]}}),(i=this.toolbar.tippyInstance)==null||i.setProps({popperOptions:p})}(l=(s=this.toolbar.tippyInstance)==null?void 0:s.popperInstance)==null||l.update()}destroy(){this.toolbar.destroy(),this.toolbar.removeAllListeners()}}const L0=S("table-border-bar");class CF{constructor(e,t){m(this,"toolbar");m(this,"resizeObserver");m(this,"handleReadonlyChanged",e=>{e.isWritable()?this.update():V9(this.editor,this.tableBlock)});m(this,"handleBlockUpdated",()=>{this.resizeObserver.disconnect(),setTimeout(()=>{const e=this.editor.getBlockById(ie(this.tableBlock));this.resizeObserver.observe(Ot(e))})});m(this,"handleTableResize",()=>{!this.editor.isWritable()||(console.log("resize"),this.update())});this.editor=e,this.tableBlock=t,g(L0,this.tableBlock,"no table block"),L0.debug("create table border bar"),z9(this.editor,this.tableBlock),this.resizeObserver=new ResizeObserver(this.handleTableResize),this.resizeObserver.observe(Ot(this.tableBlock)),this.toolbar=new pF(this.editor,this.tableBlock),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}close(){this.toolbar.close()}destroy(){L0.debug("destroy table border bar"),this.resizeObserver.disconnect(),V9(this.editor,this.tableBlock),this.toolbar.destroy(),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged)}update(){z9(this.editor,this.tableBlock),this.toolbar.update()}}const AF=S("table-border-bar");class bF{constructor(e){m(this,"activeTableBar",null);m(this,"handleBlockDeleted",(e,t)=>{!this.activeTableBar||(t===this.activeTableBar.tableBlock||Ke(t,this.activeTableBar.tableBlock))&&(this.activeTableBar.destroy(),this.activeTableBar=null)});m(this,"handleSelectionChanged",e=>{var r;const t=e.selection.range,o=su(e,t);((r=this.activeTableBar)==null?void 0:r.tableBlock)!==o&&this.activeTableBar&&this.hide(),o&&this.show(o)});this.editor=e,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(e){this.activeTableBar?(this.activeTableBar.tableBlock!==e&&this.hide(),this.activeTableBar.update()):this.activeTableBar=new CF(this.editor,e)}update(){var e;(e=this.activeTableBar)==null||e.handleBlockUpdated()}closeToolbar(){var e;(e=this.activeTableBar)==null||e.close()}hide(){!this.activeTableBar||(g(AF,this.activeTableBar,"no active table bar"),this.activeTableBar.destroy(),this.activeTableBar=null)}}function W9(n,e){const t=n.addCustom("table-border-bar",o=>new bF(o));e==="update"&&t.update()}const Sn=S("table-cell-menu"),vF="style-bg-color-";class yF{constructor(e){m(this,"activeTableBlock",null);m(this,"targetButton",null);m(this,"manualMenu",null);m(this,"colorPaletteItem",null);m(this,"handlePrevent",(e,t)=>{t.stopPropagation()});m(this,"handleReadonlyChanged",e=>{e.isWritable()||this.hide()});m(this,"handleSelectionChanged",e=>{const t=e.selection.range,o=su(e,t);if(this.hide(),this.activeTableBlock!==o&&(this.activeTableBlock=o),this.activeTableBlock){const r=Te.fromBlock(this.activeTableBlock),i=t.isReverse()?t.start:t.end;let s=null;i instanceof So?e.getBlockById(i.blockId)===this.activeTableBlock?s=r.getCellByContainerId(i.childContainerId):s=this.getCellByChildBlockId(r,i.blockId):s=this.getCellByChildBlockId(r,i.blockId),s&&this.editor.isWritable()&&this.showCellMenuButton(s)}});m(this,"handleBeforePopupPalette",()=>{var t;const e=this.getSelectedBkgColorIndex();(t=this.colorPaletteItem)==null||t.palette.setColor("backgroundColor",e)});m(this,"createBkgColorItem",()=>{const e=w("div",["cell-background-color-item"],null);w("span",[],e,R.t("table.cellBackground"));const t=this.getSelectedBkgColorIndex();w("button",["item-button"],e).setAttribute("data-color-index",`${t}`);const r=w("span",["item-sub-indicator"],e);return r.innerHTML=lv,e});m(this,"handleCommand",e=>{var r;g(Sn,this.activeTableBlock,"no target table block");const t=((r=e.states)==null?void 0:r.includes("checked"))||!1,o=e.value;switch(e.id){case"delete-select-row":Up(Ov(this.editor,this.activeTableBlock,!1));break;case"delete-select-col":jp(Ov(this.editor,this.activeTableBlock,!0));break;case"merge-cell":Lv(this.editor.selection.range);break;case"split-cell":this.handleSplitCell();break;case"row-title":this.handleRowTitle(t);break;case"col-title":this.handleColTitle(t);break;case"stripe-style":this.handleStripeStyle(t);break;case"hide-border":UM(this.editor,this.activeTableBlock,o==="show-border");break;case"show-chart":GM(this.editor,this.activeTableBlock,o==="show-chart"),Kp(this.editor,this.activeTableBlock,{updateNow:!0});break}});m(this,"handleToolbarClose",()=>{this.targetButton&&te(this.targetButton,"active"),this.activeTableBlock&&su(this.editor,this.editor.selection.range)===this.activeTableBlock&&(Wi(this.editor,this.activeTableBlock,!1),qi(this.editor,this.activeTableBlock,!1)),this.editor.focus()});m(this,"handleSelectionChange",(e,t)=>{!e.isVisible||(g(Sn,this.activeTableBlock,"no target table block"),t==="cell-background-color"&&this.handleBeforePopupPalette(),t==="delete-select-row"?(Wi(this.editor,this.activeTableBlock,!0,!1),qi(this.editor,this.activeTableBlock,!0,!1)):t==="delete-select-col"?(Wi(this.editor,this.activeTableBlock,!0,!0),qi(this.editor,this.activeTableBlock,!0,!0)):(Wi(this.editor,this.activeTableBlock,!1),qi(this.editor,this.activeTableBlock,!1)))});m(this,"handleClick",(e,t)=>{var o;g(Sn,this.activeTableBlock,"no target table block"),g(Sn,this.targetButton,"no target button"),$9(this.editor),xe(this.targetButton,"active")?(te(this.targetButton,"active"),(o=this.manualMenu)==null||o.close("clickItem")):(W(this.targetButton,"active"),this.manualMenu?this.manualMenu.updateItems(this.createCommandMenu()):(this.manualMenu=new zs(this.createCommandMenu()),this.manualMenu.on("click",(r,i)=>{var s;this.handleCommand(i),(s=this.manualMenu)==null||s.close("clickItem")}),this.manualMenu.on("selectionChange",this.handleSelectionChange),this.manualMenu.on("close",this.handleToolbarClose)),this.manualMenu.manualShow(this.targetButton,{placement:"right-start"})),t.stopPropagation()});this.editor=e,this.editor.addListener("selectionChanged",this.handleSelectionChanged),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}destroy(){var e,t;this.activeTableBlock=null,this.targetButton=null,this.editor.removeListener("selectionChanged",this.handleSelectionChanged),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged),(e=this.manualMenu)==null||e.destroy(),(t=this.colorPaletteItem)==null||t.destroy()}hide(){var e;(e=this.manualMenu)==null||e.close("cancelBar"),this.targetButton&&(te(this.targetButton,"active"),this.targetButton.style.display="none")}getCellByChildBlockId(e,t){let o=this.editor.getBlockById(t);for(;o;){const r=o.closest("td");g(Sn,r,"no parent cell");const i=oe(r);if(g(Sn,i,"no parent block"),Ot(i)===e.table)return e.getCellByCellElement(r);o=i}return g(Sn,!1,"filed to get cell by child block id"),null}createTargetButton(e){this.targetButton?e.querySelector(`:scope > .${Zp}`)||e.appendChild(this.targetButton):(this.targetButton=w("button",[Zp],e),this.targetButton.innerHTML=Zh,this.editor.domEvents.addEventListener(this.targetButton,"click",this.handleClick),this.editor.domEvents.addEventListener(this.targetButton,"mousedown",this.handlePrevent),this.editor.domEvents.addEventListener(this.targetButton,"dblclick",this.handlePrevent))}showCellMenuButton(e){this.createTargetButton(e.cell),g(Sn,this.targetButton,"no target button"),this.targetButton.style.display="inline-block"}handleSplitCell(){if(this.activeTableBlock){const e=Te.fromBlock(this.activeTableBlock),t=this.editor.selection.range;if(t.isSimple()){const{col:o,row:r}=this.getCellByChildBlockId(e,t.start.blockId);Vp(this.editor,this.activeTableBlock,{col:o,row:r})}else Wp(this.editor.selection.range)}}getSelectedBkgColorIndex(){var r;g(Sn,this.activeTableBlock,"no target table block");const e=WM(this.editor,this.activeTableBlock),t=this.editor.getBlockData(this.activeTableBlock),o=new Set;for(const i of e){if(o.size>1)break;const s=ae(i),l=t[`${s}_background`];if(l)o.add(Number.parseInt((r=l.substring(vF.length))!=null?r:"0",10));else{o.add(-1);break}}return o.size===1&&[...o][0]!==-1?[...o][0]:-1}createCommandMenu(){g(Sn,this.activeTableBlock,"no target table block");const e=this.editor.getBlockData(this.activeTableBlock),t=Sv(this.editor,this.activeTableBlock,this.editor.selection.range);let o=this.editor.selection.range;if(o.isSimple()){const h=Zr(this.editor,this.activeTableBlock,o.start);o=Ut(this.editor,{anchor:h,focus:h})}const r=Dv(this.editor,this.activeTableBlock,o),i=e.hasRowTitle,s=e.hasColTitle,l=e.isStripeStyle,a=e.noBorder,d=e.chart;return this.colorPaletteItem=new wv("cell-background-color",{color:!1}),this.colorPaletteItem.palette.on("onClick",(h,p)=>{var A;switch(g(Sn,this.activeTableBlock,"no target table block"),h){case"clearColor":Pv(this.editor,this.activeTableBlock,-1);break;case"backgroundColor":Pv(this.editor,this.activeTableBlock,p);break}(A=this.manualMenu)==null||A.close("clickItem")}),[{id:"cell-background-color",name:R.t("table.cellBackground"),element:this.createBkgColorItem(),children:[this.colorPaletteItem]},{id:"separator",name:"",type:"separator"},{id:"merge-cell",name:R.t("table.mergeCell"),states:t?[]:["disabled"]},{id:"split-cell",name:R.t("table.splitCell"),states:r?[]:["disabled"]},{id:"separator",name:"",type:"separator"},{id:"delete-select-row",name:R.t("table.deleteSelectRow")},{id:"delete-select-col",name:R.t("table.deleteSelectCol")},{id:"separator",name:"",type:"separator"},{id:"table-config",name:R.t("table.tableConfigKey"),children:[{id:"row-title",name:R.t("table.tableConfig.rowTitle"),states:i?["checked"]:[]},{id:"col-title",name:R.t("table.tableConfig.colTitle"),states:s?["checked"]:[]},{id:"stripe-style",name:R.t("table.tableConfig.stripeStyle"),states:l?["checked"]:[]},{id:"hide-border",name:a?R.t("table.tableConfig.showBorder"):R.t("table.tableConfig.hideBorder"),value:a?"show-border":"hide-border"},{id:"show-chart",name:d?R.t("table.tableConfig.hideChart"):R.t("table.tableConfig.showChart"),value:d?"hide-chart":"show-chart"}]}]}handleRowTitle(e){g(Sn,this.activeTableBlock,"no target table block"),e?$M(this.editor,this.activeTableBlock):NM(this.editor,this.activeTableBlock)}handleColTitle(e){g(Sn,this.activeTableBlock,"no target table block"),e?PM(this.editor,this.activeTableBlock):FM(this.editor,this.activeTableBlock)}handleStripeStyle(e){g(Sn,this.activeTableBlock,"no target table block"),e?jM(this.editor,this.activeTableBlock):HM(this.editor,this.activeTableBlock)}}function q9(n){n.addCustom("table-cell-menu",e=>new yF(e))}const wf=S("table-container");function M0(n){const e=n.closest("td");return g(wf,e,"no parent cell for a table cell container"),e}function G9(n){const e=Ot(n);return Array.from(e.querySelectorAll(':scope > tbody > tr > td > [data-type="editor-container"].child'))}function R0(n,e,t,o){const r=Te.fromBlock(n),i=r.getCellByContainerId(ae(e));if(t==="ArrowDown"){const s=r.getBottomCell(i);return s?s.container:null}if(t==="ArrowUp"){const s=r.getTopCell(i);return s?s.container:null}if(t==="ArrowLeft"){const s=r.getAllContainers(),l=s.indexOf(e);if(g(wf,l>=0,"not a valid child container"),l===0)return null;const a=s[l-1];return o!=null&&o.noWrap&&r.getCellByContainerId(ae(a)).row!==i.row?null:a}if(t==="ArrowRight"){const s=r.getAllContainers(),l=s.indexOf(e);if(g(wf,l>=0,"not a valid child container"),l===s.length-1)return null;const a=s[l+1];return o!=null&&o.noWrap&&r.getCellByContainerId(ae(a)).row!==i.row?null:a}g(wf,!1,`invalid navigation type: ${t}`)}const kF=12,wF=90,Bf=23,Z9=2;class BF{constructor(e){m(this,"scrollTableBlock",null);m(this,"autoScrollDir",null);m(this,"autoScrollTimer",null);m(this,"handleMouseDown",e=>{const t=document.elementFromPoint(e.clientX,e.clientY);if(t&&t instanceof HTMLElement){const o=oe(t);if(o&&Ke(this.editor.rootContainer,o)){const r=Gr(o);r&&(this.scrollTableBlock=r,document.addEventListener("mousemove",this.handleAutoScroll))}}});m(this,"handleAutoScroll",WB.default(e=>{if(this.scrollTableBlock){const t=this.editor.getCustom(hr(this.scrollTableBlock)),o=t.rootElement,r=t.scrollOptions.parentContainer,i=o.getBoundingClientRect(),s=window.innerHeight-(t.scrollOptions.barFloatWindowBottom||0),l=r.getBoundingClientRect(),a=Math.min(l.bottom,s),d=Math.max(l.top,0);i.bottom>a&&e.clientY>=a?this.setAutoScroll("bottom"):i.top<d&&e.clientY<=d?this.setAutoScroll("top"):o.scrollLeft>0&&e.clientX<i.left?this.setAutoScroll("left"):o.scrollLeft<o.scrollWidth-o.offsetWidth&&e.clientX>i.right?this.setAutoScroll("right"):this.clearAutoScroll()}},15));m(this,"handleMouseUp",()=>{document.removeEventListener("mousemove",this.handleAutoScroll),setTimeout(()=>{this.scrollTableBlock=null})});m(this,"handleSelectionChanged",e=>{const t=e.selection.range;if(t.isCollapsed()&&t.isSimple()){const o=e.getBlockById(t.start.blockId),r=Gr(o);if(r){const i=e.getCustom(hr(r)),s=i.rootElement.getBoundingClientRect(),l=To(e,o,t.start);if(s.left>l.left){const a=t.start.offset===0?kF:Z9;i.rootElement.scrollLeft-=s.left-l.left+a}else if(l.right>s.right){const a=t.start.offset===0?wF:Z9;i.rootElement.scrollLeft+=l.right-s.right+a}}}else{const o=e.getBlockById(t.start.blockId),r=Gr(o),i=e.getBlockById(t.end.blockId),s=Gr(i);if(r&&r===s){const l=e.getCustom(hr(r)),a=l.rootElement.getBoundingClientRect();let d=null;if(t.isSimple())d=t.isReverse()?To(e,o,t.start):To(e,i,t.end);else{const h=M0($r(e,t.start.childContainerId)),p=M0($r(e,t.end.childContainerId));d=t.isReverse()?h.getBoundingClientRect():p.getBoundingClientRect()}a.left>d.left&&t.isReverse()?l.rootElement.scrollLeft-=a.left-d.left:a.right<d.right&&!t.isReverse()&&(l.rootElement.scrollLeft+=d.right-a.right)}}});m(this,"handleScroll",e=>{xv(e),this.editor.selection.caret.update()});m(this,"handleReset",e=>{xv(e),this.editor.selection.caret.update()});this.editor=e,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(e){this.autoScrollDir&&this.autoScrollDir!==e&&this.clearAutoScroll(),this.autoScrollTimer||(this.autoScrollDir=e,this.autoScrollTimer=window.setInterval(()=>{if(this.scrollTableBlock){const t=this.editor.getCustom(hr(this.scrollTableBlock)),o=t.rootElement,r=t.scrollOptions.parentContainer,i=o.getBoundingClientRect(),s=r===document.documentElement?window.innerHeight:r.offsetHeight,l=window.innerHeight-(t.scrollOptions.barFloatWindowBottom||0),a=r.getBoundingClientRect(),d=Math.min(a.bottom,l),h=Math.max(a.top,0);this.autoScrollDir==="left"&&(o.scrollLeft-=Bf,o.scrollLeft<=0&&this.clearAutoScroll()),this.autoScrollDir==="right"&&(o.scrollLeft+=Bf,o.scrollLeft>=o.scrollWidth-o.offsetWidth&&this.clearAutoScroll()),this.autoScrollDir==="bottom"&&(r.scrollTop+=Bf,(r.scrollTop>=r.scrollHeight-s||i.bottom<=d)&&this.clearAutoScroll()),this.autoScrollDir==="top"&&(r.scrollTop-=Bf,(r.scrollTop<=0||i.top>=h)&&this.clearAutoScroll())}},100))}destroy(){document.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mouseup",this.handleMouseUp),this.editor.removeListener("selectionChanged",this.handleSelectionChanged)}}function Q9(n){return n.addCustom("table-scroll-events",e=>new BF(e))}const mr=S("create-content");function Y9(n,e,t){const o=new Qh(t),r=t.rows,i=t.cols;g(mr,r>=1,`invalid rows: ${r}`),g(mr,i>=1,`invalid cols: ${i}`),g(mr,t.children,"no table children");const s=w("table",[],null),l=t.colsWidth,a=w("colgroup",[],s);for(let p=0;p<o.colCount;p++){const A=w("col",[],a);A.style.width=`${l[p]||of}px`}const d=w("tbody",[],s);let h=0;for(let p=0;p<r;p++){const A=w("tr",[],d);for(let v=0;v<i;v++){const B=o.getCell({col:v,row:p});if(B.virtual)g(mr,B.colSpan>1||B.rowSpan>1,"virtual cell should have colSpan or rowSpan");else{const D=t.children[h],I=w("td",[],A);B.colSpan>1&&(I.colSpan=B.colSpan),B.rowSpan>1&&(I.rowSpan=B.rowSpan);const _=t[cu(D)];_&&W(I,_),v===0&&t.hasColTitle&&W(I,Mv.COL_TITLE_ITEM),n.createChildContainer(e,I,D),h+=1}}}return g(mr,h===t.children.length,"container count mismatch"),t.noBorder&&W(s,"no-border"),t.chart&&W(s,"editor-table-chart"),t.isStripeStyle&&W(s,"stripe"),t.hasRowTitle&&W(s,"row-title"),t.hasColTitle&&W(s,"col-title"),s}function EF(n,e,t,o,r){g(mr,r.type==="table","not table data"),g(mr,ae(t)===e[e.length-1].containerId,"invalid path");const i=r,s=Ts(o,"div");try{const l=w("div",[],null);l.setAttribute("data-type","table-content");const a=Y9(n,e,i);a.classList.add("drag-preview-element"),l.appendChild(a),Jv(n),n9(n),W9(n,"create"),q9(n),rL(n,Xp);const d=n.getComponentOptions("table"),h=n.addCustom(hr(o),()=>CR());h.init({parentElement:s,childElement:l,safeRightSpace:50,safeLeftSpace:40,parentContainer:Xe(t)?n.scrollContainer:t,locatingContainer:Xe(t)?(d==null?void 0:d.locatingContainer)||n.parent:t,paddingLeft:Vi+sc,paddingTop:Vi+sc,paddingBottom:sc/2,paddingRight:sc/2,barFloatWindowBottom:d==null?void 0:d.barFloatWindowBottom,isSetScale:d==null?void 0:d.isSetScale});const p=Q9(n);h.on("scroll",p.handleReset),h.on("resize",p.handleReset),h.on("resize",pu),h.on("scroll",pu),setTimeout(()=>{YM(n,o)})}catch{const a=`invalid table data: ${JSON.stringify(i)}`;mr.error(a);const d=w("div",["error"],s);d.innerText=a}return s}function xF(n,e,t){g(mr,t.type==="table","not table data");const o=t,r=Re(e);try{const i=Ot(e),s=Di(e),l=Y9(n,s,o);l.classList.add("drag-preview-element"),i.insertAdjacentElement("afterend",l),i.remove(),Jv(n),n9(n),W9(n,"update"),q9(n),Xp(n,e)}catch{const s=`invalid table data: ${JSON.stringify(o)}`;mr.error(s);const l=w("div",["error"],r);l.innerText=s}}function IF(n,e){let t,o,r=!1;if([...e].every(A=>A==="|")?(o=e.length,t=Array(o).fill(""),r=!0):(t=Bm(e,"|").split("|"),o=t.length),o<2)return null;const i=3,s=o,l=[];for(let A=0;A<3;A++)t.forEach(v=>{l.push(zr(n.doc,A===0?v:""))});const a=Array(s).fill(of),d=l[r?0:s],h=n.doc.getContainerBlocks(d)[0].id;return{blockData:{id:K(),type:"table",rows:i,cols:s,children:l,colsWidth:a},focusBlockId:h}}function TF(n,e){const t=e.rows,o=e.cols;if(t<1||o<1)return null;const r=[];for(let d=0;d<t;d++)for(let h=0;h<o;h++)r.push(zr(n.doc));const i=Array(o).fill(of),s=r[0],l=n.doc.getContainerBlocks(s)[0].id;return{blockData:{id:K(),type:"table",rows:t,cols:o,children:r,colsWidth:i},focusBlockId:l}}const J9=S("table-selection-to-doc");function DF(n,e){const{start:t,end:o,block:r}=e,i=De(r);g(J9,i==="table",`invalid block type: ${i}`);const s=n.getBlockData(r);if(t.isSimple()&&o.isSimple())return Fi(n.editorBlocks,n.doc.toJSON(),s);g(J9,!t.isSimple()&&!o.isSimple(),"invalid block pos type");const l=Te.fromBlock(r),{fromCol:a,toCol:d,fromRow:h,toRow:p}=Ho(r,t,o),A={},v=[],B=n.doc.toJSON();let D={};l.sub({row:h,col:a},{row:p,col:d}).forEach((re,fe)=>{re.forEach((Be,je)=>{const Ue=Be.containerId;if(v.indexOf(Ue)!==-1)return;v.push(Ue);let tt;if(Be.virtual){const Nt=l.getCellByContainerId(Be.containerId),Ln=a+je;let yr=Nt.col+Nt.colSpan-1;yr>d&&(yr=d);const bn=yr-Ln+1;bn>1&&(A[`${Ue}_colSpan`]=bn);const an=h+fe;let kr=Nt.row+Nt.rowSpan-1;kr>p&&(kr=p);const ti=kr-an+1;ti>1&&(A[`${Ue}_rowSpan`]=ti),tt=Ur()}else{if(tt=Ng(n.editorBlocks,B,Ue),Be.col+Be.colSpan>d+1){const Nt=d-Be.col+1;Nt>1&&(A[`${Ue}_colSpan`]=Nt)}else Be.colSpan>1&&(A[`${Ue}_colSpan`]=Be.colSpan);if(Be.row+Be.rowSpan>p+1){const Nt=p-Be.row+1;Nt>1&&(A[`${Ue}_rowSpan`]=Nt)}else Be.rowSpan>1&&(A[`${Ue}_rowSpan`]=Be.rowSpan)}const{root:Yt,...Wo}=tt.blocks;D={...D,...Wo,[Ue]:Yt}})});const _=hu(Ot(r)).slice(a,d+1);return{blocks:{root:[{id:K(),type:i,children:v,colsWidth:_,rows:p-h+1,cols:d-a+1,...A}],...D},meta:{},comments:{}}}function SF(n,e){if(e.top===0)return!0;for(let t=e.left;t<=e.right;t++)if(n[e.top-1][t]===n[e.top][t])return!1;return!0}function LF(n,e){if(e.left===0)return!0;for(let t=e.top;t<=e.bottom;t++)if(n[t][e.left-1]===n[t][e.left])return!1;return!0}function MF(n,e){if(e.bottom===n.length-1)return!0;for(let t=e.left;t<=e.right;t++)if(n[e.bottom][t]===n[e.bottom+1][t])return!1;return!0}function RF(n,e){if(e.right===n[0].length-1)return!0;for(let t=e.top;t<=e.bottom;t++)if(n[t][e.right]===n[t][e.right+1])return!1;return!0}function OF(n,e,t){const o=e.col,r=e.row,i=t.col,s=t.row,l={left:o,top:r,right:i,bottom:s};let a=!1;do{if(a=!1,!SF(n,l)){l.top--,a=!0;continue}if(!LF(n,l)){l.left--,a=!0;continue}if(!MF(n,l)){l.bottom++,a=!0;continue}if(!RF(n,l)){l.right++,a=!0;continue}}while(a);return l}function _F(n,e,t,o){if(t.custom!==void 0||o.custom!==void 0)return{anchor:t,focus:o};const r=Te.fromBlock(e),i=r.map(H=>H.containerId),s=r.getCellByContainerId(t.childContainerId),l=r.getCellByContainerId(o.childContainerId),a=Math.min(s.row,l.row),d=Math.max(s.row,l.row),h=Math.min(s.col,l.col),p=Math.max(s.col,l.col),A=OF(i,{row:a,col:h},{row:d,col:p}),v=r.getCell({row:A.top,col:A.left}),B=r.getCell({row:A.bottom,col:A.right}),D=r.getCell({row:A.top,col:A.right}),I=r.getCell({row:A.bottom,col:A.left});let _,M;return s.row<=l.row?s.col<=l.col?(_=v,M=B):(_=D,M=I):s.col<l.col?(_=I,M=D):(_=B,M=v),console.log(`move ${_.col}, ${_.row}, -> ${M.col}, ${M.row}`),{anchor:ft(e,_.containerId),focus:ft(e,M.containerId)}}function K9(n,e,t){if(t.isSimple())return[Ot(e).getBoundingClientRect()];const o=Ot(e),r=o.getBoundingClientRect(),{fromCol:i,fromRow:s,toCol:l,toRow:a}=Ho(e,t.start,t.end),d=hu(o),h=d.slice(0,i).reduce((D,I)=>D+I,0),p=h+d.slice(i,l+1).reduce((D,I)=>D+I,0),A=H9(o);let v=A.slice(0,s).reduce((D,I)=>D+I,0);const B=v+A.slice(s,a+1).reduce((D,I)=>D+I,0);if(s===0){const D=gF(n,e);v-=D}return[new DOMRect(r.left+h,r.top+v,p-h,B-v)]}S("table-size");const FF=40;function Ef(n){const e=n.querySelector("td");if(!e)return 0;const t=window.getComputedStyle(e),o=Number.parseInt(t.borderLeft,10),r=Number.parseInt(t.borderRight,10);return(o+r)/2}function PF(n,e,t){const o=Qm(n,t.container);return o!==void 0?o+Ef(e):FF*t.colSpan-Ef(e)}function NF(n,e,t,o){let r=0;const i=t.colCount;for(let s=0;s<i;s++){const l=t.getRealCell({col:s,row:o});if(l.virtual)continue;let a=PF(n,e,l);const d=b4(l.container,{withPadding:!0});d&&d>a&&(a=d),r+=a+Ef(e)}return r}function $F(n,e){const t=Ot(e),o=Te.fromTable(t);let r=0;for(let s=0;s<o.rowCount;s++)r=Math.max(r,NF(n,t,o,s));const i=Ef(t);return r+=i,r}const Qr=S("table-creator");async function HF(n,e){return n.undoManager.runInGroup(()=>{var a,d;const t=e.item,o=(a=t.colCount)!=null?a:5,r=(d=t.rowCount)!=null?d:3,i=TF(n,{cols:o,rows:r});if(!i)return null;const{blockData:s,focusBlockId:l}=i;return n.insertBlock(e.containerId,e.blockIndex,s,yt(n,l,0))})}class jF{constructor(){m(this,"id","insert-table");m(this,"name","Create table");m(this,"element");m(this,"closeable",null);m(this,"colCount");m(this,"rowCount");m(this,"setCloseable",e=>{this.closeable=e});m(this,"destroy",()=>{this.closeable=null});m(this,"getTableCreatorCellId",(e,t)=>`table-creator-cell-${e}-${t}`);m(this,"handleTableCreatorClick",e=>{var A,v;e.preventDefault(),e.stopPropagation();const t=e.target;g(Qr,t instanceof HTMLElement,"invalid event target");const o=t.closest(".table-creator");g(Qr,o,"no table creator");const r=o.querySelectorAll(".active");if(r.length===0)return;const s=r[r.length-1].id;g(Qr,s,"no cell id");const l="table-creator-cell-";if(!s.startsWith(l))return;const d=s.substring(l.length).split("-");g(Qr,d.length===2,"invalid cell id");const h=Number.parseInt(d[0],10)+1,p=Number.parseInt(d[1],10)+1;Qr.debug(`${h}, ${p}`),this.colCount=p,this.rowCount=h,(A=this.closeable)==null||A.click(this,this.element),(v=this.closeable)==null||v.close("clickItem"),this.handleTableCreatorLeave()});m(this,"handleTableCreatorLeave",()=>{for(let e=0;e<9;e++)for(let t=0;t<9;t++){const o=this.getTableCreatorCellId(e,t),r=document.getElementById(o);r&&te(r,"active")}});m(this,"handleTableCreatorCellEnter",e=>{const t=e.target;g(Qr,t instanceof HTMLElement,"invalid event target");const o=t.id,r="table-creator-cell-";g(Qr,o.startsWith(r),"invalid cell id");const s=o.substring(r.length).split("-");g(Qr,s.length===2,"invalid cell id");let l=Number.parseInt(s[0],10),a=Number.parseInt(s[1],10);l===0&&a===0&&(l=-1,a=-1);for(let d=0;d<9;d++)for(let h=0;h<9;h++){const p=this.getTableCreatorCellId(d,h),A=document.getElementById(p);g(Qr,A,"no cell"),d<=l&&h<=a?W(A,"active"):te(A,"active")}});this.element=this.createTableCreatorElement()}createTableCreatorElement(){const e=w("div",["table-creator"],null),t=(o,r,i)=>{const s=w("div",["table-creator-cell"],o);return s.id=this.getTableCreatorCellId(r,i),s};e.addEventListener("click",this.handleTableCreatorClick),e.addEventListener("mouseleave",this.handleTableCreatorLeave);for(let o=0;o<9;o++){const r=w("div",["table-creator-row"],e);for(let i=0;i<9;i++)t(r,o,i).addEventListener("mouseenter",this.handleTableCreatorCellEnter)}return e}}function UF(){return new jF}function zF(n){const e=/[\u4e00-\u9fff\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g,t=n.match(e);return t?t.length:0}function X9(n){const e=zF(n);return n.length+e}function VF(n,e){const t=X9(n),o=e-t;return o>0?n+" ".repeat(o):n}function WF(n,e,t,o,r){const i=e,s=new Qh(i);if(o==="markdown"||o==="text"){const l=I=>t.blocks[I].map((H,z)=>o==="markdown"?Tg(n,H,t,[...r,{containerId:I,blockIndex:z}]):bh(n,H,t,[...r,{containerId:I,blockIndex:z}])),a=I=>l(I).join(" ").replace(/\n/g," ").trim(),d=new Map,h=new Map;for(let I=0;I<s.colCount;I++){let _=0;for(let M=0;M<s.rowCount;M++){const H=s.getCell({row:M,col:I});let z="";H.virtual||(z=a(H.containerId)),d.set(`${M},${I}`,z),_=Math.max(_,X9(z))}h.set(I,_)}const p=I=>{const _=d.get(`${I.row},${I.col}`)||"",M=h.get(I.col)||0;return VF(_,M)},A=[];let v="|",B="|";for(let I=0;I<s.colCount;I++){const _=p({row:0,col:I});v+=` ${_} |`;const M="-".repeat((h.get(I)||0)+2);B+=`${M}|`}A.push(v),A.push(B);for(let I=1;I<s.rowCount;I++){let _="|";for(let M=0;M<s.colCount;M++){const H=p({row:I,col:M});_+=` ${H} |`}A.push(_)}return`${A.join(`
396
+ `:r.mathjaxText}function V_(){return{abstract:R.t("mathjax.abstract")}}const F9={embedType:"math",createEmbedContent:$_,getOptions:j_,convertFrom:H_,handleDeleteBlock:U_,convertTo:z_,getBlockProperties:V_},Cne="",W_={mathjax:{emptyText:"\u7A7A\u7684\u516C\u5F0F",abstract:"\u516C\u5F0F"}},q_={mathjax:{emptyText:"Empty formula",abstract:"Formula"}},G_={mathjax:{emptyText:"\u6570\u5F0F\u306A\u3057",abstract:"\u6570\u5F0F"}};R.mergeLang({"zh-CN":W_,"en-US":q_,"ja-JP":G_});function Z_(n,e,t,o){const r=n.getBlockByIndex(e,t),i=n.getBlockText(r),{left:s}=xn(i,o);if(!rt(s).endsWith("$$$$"))return!1;const a=o-4,d=o,h={id:K(),box:!0,type:"math",tex:" ",src:"",created:Date.now()};return n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,a,d-a),n.insertBoxToBlock(r,a,h),setTimeout(()=>{const p=n.getBoxById(h.id);Cf(n,p)})}),!0}class Q_{handleAfterInsertText(e,t,o,r,i){return!!(i===" "&&Z_(e,t,o,r))}}const Cc=S("inline-box-items");function Y_(n,e,t){return n.undoManager.runInGroup(()=>{var s;let o=n.getBlockByIndex(e,t);ht(n,o)||(o=n.insertTextBlock([],e,t));const r=O9();n.setBlockText(o,[r]);const i=(s=r.attributes)==null?void 0:s.id;return g(Cc,i,"mathjax box id is empty"),setTimeout(()=>{const l=n.getBoxById(i);Cf(n,l)},100),o})}function J_(n,e,t){let o=n.getBlockByIndex(e,t),r="bottom-start";return ht(n,o)||(r="top-start"),fu(n,{target:o,linkText:"",linkUrl:"",onFinished:(l,a)=>{n.undoManager.runInGroup(()=>{try{ht(n,o)||(o=n.insertTextBlock([],e,t));const d=lo(l,{link:a}),h=lo(" ",null),p=[d,h];n.insertTextToBlock(o,0,p),n.selection.selectBlock(o,rn(p)),n.focus()}catch(d){Cc.error(d)}})},onClose:()=>{n.focus()},placement:r}),o}function K_(n,e,t){return n.undoManager.runInGroup(()=>{var l;const o=n.getBlockByIndex(e,t),r=n.selection.range;g(Cc,Hr(r.start),"invalid block position");const i=O9();n.insertBoxToBlock(o,r.start.offset,i.attributes);const s=(l=i.attributes)==null?void 0:l.id;return g(Cc,s,"mathjax box id is empty"),setTimeout(()=>{const a=n.getBoxById(s);Cf(n,a)},100),o})}function X_(n,e,t){const o=n.getBlockByIndex(e,t),r=n.selection.range;g(Cc,Hr(r.start),"invalid block position");const i=Ti(n,o,r);if(i.length===0)return;const s=i[0],l=Li(n,o,"quick-menu-inline-link",s);fu(n,{target:l,linkText:"",linkUrl:"",onFinished:(h,p)=>{n.undoManager.runInGroup(()=>{try{const A=n.getBlockText(o),v=jr(A,r.start.offset,h,{link:p});n.setBlockText(o,v),n.selection.selectBlock(o,r.start.offset+h.length),n.focus()}catch(A){Cc.error(A)}})},onClose:()=>{n.focus()},placement:"bottom-start"})}class P9{getCommands(){return[{id:"insert-math",name:R.t("quickMenu.inlineBox.math"),icon:SL,order:900,group:"common",subText:pn("insert-math")},{id:"insert-link",name:R.t("quickMenu.inlineBox.link"),icon:hv,order:400,group:"common",subText:pn("insert-link")}]}async handleUpdateBlockCore(e,t){switch(t.item.id){case"insert-math":return K_(e,t.containerId,t.blockIndex);case"insert-link":return X_(e,t.containerId,t.blockIndex);default:return null}}async handleInsertEmptyBlockCore(e,t){switch(t.item.id){case"insert-math":return Y_(e,t.containerId,t.blockIndex);case"insert-link":return J_(e,t.containerId,t.blockIndex);default:return null}}async executeCommand(e,t,o){if(o.from==="quick-menu"){const r=e.getBlockById(o.blockId),i=e.getParentContainer(r),s=ae(i),l=e.getBlockIndex(r);e.undoManager.runInGroup(()=>this.handleUpdateBlockCore(e,{item:t,containerId:s,blockIndex:l}))}else o.from==="block-menu"&&e.undoManager.runInGroup(()=>this.handleInsertEmptyBlockCore(e,{item:t,containerId:o.containerId,blockIndex:o.blockIndex}));return null}}function eF(n,e={withPlainText:!1}){var i,s;const{withPlainText:t}=e,o=(s=(i=n.options.componentsOptions)==null?void 0:i.quickMenu)==null?void 0:s.commandProviders;if(!o)return[];const r=[];return[...o,new T9(t),new P9].forEach(l=>{const a=l.getCommands(n);r.push(...a.map(d=>({...d,itemType:"insert-block",commandProvider:l})))}),r}function tF(n,e={withPlainText:!1}){const t=[];return n.editorBlocks.forEach(o=>{if(!o.getOptions)return;const r=o.getOptions(n);!r.insertBlockCommandItems||(r.insertBlockCommandItems.forEach(i=>{I9(i,r)}),t.push(...r.insertBlockCommandItems))}),t.push(...eF(n,e)),t}function D0(n,e={withPlainText:!1}){const t=tF(n,e),o=new Map;t.forEach(s=>{var d;const l=(d=s.group)!=null?d:"";let a=o.get(l);a?a.items.push(s):(a={group:l,order:s.groupOrder||D9[l]||1e3,items:[s]},o.set(l,a))});const r=Array.from(o.values());r.sort((s,l)=>s.order-l.order),r.forEach(s=>{s.items.sort((l,a)=>{var d,h;return((d=l.order)!=null?d:0)-((h=a.order)!=null?h:0)})});const i=[];return r.forEach((s,l)=>{const a=`blockMenu.section.${s.group||"common"}`,d=R.t(a),h=d===a?s.group:d;i.push({id:`section-${l}`,name:h,type:"section",group:s.group,itemType:"insert-block"}),i.push(...s.items.map(p=>({...p})))}),i}function nF(n,e,t){const o=n.getFocusedBlock();if(!o)return;const r=n.getParentContainer(o),i=ae(r);let l=n.getBlockIndex(o);if(ht(n,o)||(l+=1),e.commandProvider){e.commandProvider.executeCommand(n,e,{from:"quick-menu",...t});return}!e.blockOptions||!e.blockOptions.handleInsertEmptyBlock||e.blockOptions.handleInsertEmptyBlock(n,{containerId:i,blockIndex:l,item:e})}const N9=S("quick-menu"),oF={id:"quick-menu",trigger:["/"]},rF=5;class Af{constructor(e,t=oF){m(this,"suggest");m(this,"items");m(this,"maxHeading");m(this,"firstEmptyOffset",-1);m(this,"queryItems",async(e,t)=>{if(this.items.length===0?this.initMenuItems():this.refreshMenuItems(),t){const o=new Set,r=t.toLocaleLowerCase().replace(/^\s+|\s+$/g,""),i=this.items.filter(s=>{if(s.type==="section")return!0;if(s.name.toLocaleLowerCase().indexOf(r)!==-1||yM(s).toLocaleLowerCase().indexOf(r)!==-1)return o.add(s.group),!0;const l=`blockMenu.section.${s.group||"common"}`,a=R.t(l),d=a===l?s.group:a;return(d==null?void 0:d.toLocaleLowerCase().indexOf(r))!==-1?(o.add(s.group),!0):!1}).filter(s=>s.type==="section"?o.has(s.group):!0);return i.length?this.firstEmptyOffset=-1:this.handleEmptySearch(),i}return this.items});m(this,"onClose",()=>{this.firstEmptyOffset=-1});m(this,"onShow",(e,t,o,r)=>{const i=this.editor.getBlockByIndex(t,o);if(!ro(i)){const s=oe(ne(i));if(s&&De(s)==="code")return!1}return!0});m(this,"onClickItem",(e,t)=>{const o=t;o.itemType==="insert-block"&&(g(N9,o.blockOptions||o.commandProvider,"invalid quick item, no block options or command provider"),g(N9,this.suggest.anchor,"invalid suggest, no anchor"),this.options.id==="empty-block-menu"&&this.editor.focus(),nF(this.editor,o,this.suggest.anchor))});this.editor=e,this.options=t,this.items=[],this.maxHeading=cf(),this.suggest=new Np(e,{id:t.id||"quick-menu",trigger:t.trigger,needSpaceBeforeTrigger:!0,autoDeleteTrigger:!0,highlight:!0,onClose:this.onClose,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems})}get menu(){return this.suggest.menu.menu}destroy(){this.suggest.destroy()}initMenuItems(){const e=D0(this.editor);this.items=e}refreshMenuItems(){let e=null,t=0;const o=cf();if(o!==this.maxHeading){const r=new T9,s=r.getCommands().map(l=>({...l,itemType:"insert-block",commandProvider:r}));for(let l=0;l<this.items.length;l++)this.items[l].group==="basics"&&(e||(e=l),e&&t++);e&&t&&this.items.splice(e,t,...s),this.maxHeading=o}}handleEmptySearch(){const e=this.editor.selection.getFocusedPos();if(this.firstEmptyOffset===-1){if(e.isSimple()){const{offset:t}=e;this.firstEmptyOffset=t-1}}else if(e.isSimple()){const{offset:t}=e;t-this.firstEmptyOffset>rF&&(this.suggest.close(),this.firstEmptyOffset=-1)}}}class bf{constructor(e){m(this,"instance");m(this,"mousedown",!1);m(this,"currentInstance",null);m(this,"attributeName",[]);m(this,"attributeDesc","");m(this,"observer",null);m(this,"observerCallback",null);m(this,"createContent",e=>{let t="",o=0;for(;o<this.attributeName.length&&!t;)e.hasAttribute(this.attributeName[o])&&(t=e.getAttribute(this.attributeName[o])||""),o++;const r=e.getAttribute(this.attributeDesc);if(!r)return t;const i=w("div",[],null);return w("span",[],i,t),r&&w("span",["editor-tooltip-desc"],i,r),i});m(this,"handleDocumentMouseDown",()=>{this.mousedown=!0,this.editor.domEvents.addEventListener(document,"mouseup",this.handleDocumentMouseUp)});m(this,"handleDocumentMouseUp",()=>{this.mousedown=!1,this.editor.domEvents.removeEventListener(document,"mouseup",this.handleDocumentMouseUp)});m(this,"handleShown",e=>{this.currentInstance&&this.hide(),this.currentInstance=e,this.createObserver()});m(this,"handleHidden",()=>{this.destroyObserver(),this.currentInstance=null});m(this,"handleShow",e=>{var r;const t=e.reference;if(!t||!Ke(document.body,t)||window.isDragging||this.mousedown)return!1;const o=Number.parseInt((r=t.getAttribute("data-tooltip-hide-at"))!=null?r:"",10);if(o&&Date.now()-o<1e3)return!1;if(e.reference){const i={};if(e.reference.hasAttribute("data-editor-tooltip-placement")&&(i.placement=e.reference.getAttribute("data-editor-tooltip-placement")||"top"),e.reference.hasAttribute("data-editor-tooltip-offset-x")||e.reference.hasAttribute("data-editor-tooltip-offset-y")){const s=e.reference.getAttribute("data-editor-tooltip-offset-x"),l=e.reference.getAttribute("data-editor-tooltip-offset-y");i.offset=[s?Number.parseInt(s,10):0,l?Number.parseInt(l,10):0]}if(e.reference.hasAttribute("data-editor-tooltip-maxwidth")&&(i.maxWidth=Number.parseInt(e.reference.getAttribute("data-editor-tooltip-maxwidth")||"350",10)),e.reference.hasAttribute("data-editor-tooltip-allow-markdown")&&(i.allowHTML=!0),Object.keys(i).length&&e.setProps(i),e.reference.hasAttribute(`data-editor-tooltip-${this.editor.clientId}-dynamic`)){const s=e.reference.getAttribute(`data-editor-tooltip-${this.editor.clientId}-dynamic`);e.setContent(s||"")}}return!0});this.editor=e;const t=e.clientId;this.attributeName=[`data-editor-tooltip-${t}`,`data-editor-tooltip-${t}-dynamic`,"data-editor-tooltip-common"],this.attributeDesc=`data-editor-tooltip-desc-${t}`,this.instance=um.delegate(document.body,{theme:"editor-tooltip",maxWidth:400,delay:200,target:this.attributeName.map(o=>`[${o}]`).join(","),content:this.createContent,onShow:this.handleShow,onShown:this.handleShown,onHide:this.handleHidden}),e.domEvents.addEventListener(document,"mousedown",this.handleDocumentMouseDown)}visible(){var e;return(e=this.currentInstance)==null?void 0:e.state.isVisible}hide(){var e;(e=this.currentInstance)!=null&&e.state.isVisible&&this.currentInstance.hide()}destroy(){this.destroyObserver(),this.instance.destroy(),this.editor.domEvents.removeEventListener(document,"mousedown",this.handleDocumentMouseDown),this.editor.domEvents.removeEventListener(document,"mouseup",this.handleDocumentMouseUp)}createObserver(){this.destroyObserver();const e=this.currentInstance;if(!e||!e.reference)return;this.observerCallback=Ht.default(()=>{e.reference.closest("body")||(e.hide(),this.destroyObserver())},200),this.observer=new MutationObserver(this.observerCallback);const t=document.body,o={childList:!0,attributes:!1,subtree:!0};this.observer.observe(t,o)}destroyObserver(){this.observer&&(this.observer.disconnect(),this.observer=null),this.observerCallback&&(this.observerCallback.cancel(),this.observerCallback=null)}}const iF={"text/style-bold":"bold","text/style-italic":"italic","text/style-underline":"underline","text/style-strikethrough":"line-through","text/style-code":"code","text/style-sub":"subscript","text/style-super":"superscript"};function sF(n,e){const t=new Set(Object.keys(iF)),o=e.filter(i=>t.has(i.id));return sf(o)}function vf(n,e){if(!n.isWritable())return!1;const t=n.selection.range,o=n.editorCommandProviders.getCommands(t),i=sF(n,o).find(s=>s.id===`text/${e}`);return i?(n.editorCommandProviders.executeCommand(t,i,{}),pc.get(n).update("selectionChange"),!0):!1}const S0={"CtrlOrCmd+B":n=>vf(n,"style-bold"),"CtrlOrCmd+I":n=>vf(n,"style-italic"),"CtrlOrCmd+U":n=>vf(n,"style-underline"),"CtrlOrCmd+D":n=>vf(n,"style-strikethrough")},lF={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",edit:"\u7F16\u8F91",remove:"\u53D6\u6D88\u94FE\u63A5"},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",alignGroup:"\u5BF9\u9F50\u65B9\u5F0F",heading:"\u6807\u9898 {name}",headingGroup:"\u6807\u9898\u6837\u5F0F",text:"\u6B63\u6587"}},cF={quickMenu:{basic:{heading:{title:"Title {heading}",space:"{markdown}space"},unordered:"Bulleted list",ordered:"Numbered list",checkbox:"To-do list",quote:"Quote"},inlineBox:{math:"Formula",link:"Link"}},link:{textLabel:"Text",urlLabel:"Link address",textPlaceholder:"Please enter text",urlPlaceholder:"Please enter link",submitText:"Confirm",cancelText:"Cancel",edit:"Edit",remove:"Remove link"},commands:{unordered:"Bulleted list",ordered:"Numberer list",check:"To-do list",link:"Link",quote:"Quote",alignLeft:"Align left",alignRight:"Align right",alignCenter:"Center text",alignGroup:"Alignment",heading:"Title {name}",headingGroup:"Text style",text:"Text"}},aF={quickMenu:{basic:{heading:{title:"\u898B\u51FA\u3057{heading}",space:"{markdown}\u30B9\u30DA\u30FC\u30B9"},unordered:"\u7B87\u6761\u66F8\u304D\u30EA\u30B9\u30C8",ordered:"\u756A\u53F7\u4ED8\u304D\u30EA\u30B9\u30C8",checkbox:"\u30D0\u30C3\u30AF\u30ED\u30B0",quote:"\u5F15\u7528"},inlineBox:{math:"\u6570\u5F0F",link:"URL"}},link:{textLabel:"\u30C6\u30AD\u30B9\u30C8",urlLabel:"URL",textPlaceholder:"\u30C6\u30AD\u30B9\u30C8\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",urlPlaceholder:"URL \u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",submitText:"OK",cancelText:"\u30AD\u30E3\u30F3\u30BB\u30EB",edit:"\u7DE8\u96C6",remove:"\u30EA\u30F3\u30AF\u3092\u89E3\u9664"},commands:{unordered:"\u7B87\u6761\u66F8\u304D\u30EA\u30B9\u30C8",ordered:"\u756A\u53F7\u4ED8\u304D\u30EA\u30B9\u30C8",check:"\u30D0\u30C3\u30AF\u30ED\u30B0",link:"URL",quote:"\u5F15\u7528",alignLeft:"\u5DE6\u63C3\u3048",alignRight:"\u53F3\u63C3\u3048",alignCenter:"\u4E2D\u592E\u63C3\u3048",alignGroup:"\u5BF9\u9F50\u65B9\u5F0F",heading:"\u898B\u51FA\u3057{name}",headingGroup:"\u30BF\u30A4\u30C8\u30EB\u30B9\u30BF\u30A4\u30EB",text:"\u672C\u6587"}};R.mergeLang({"zh-CN":lF,"en-US":cF,"ja-JP":aF});const Ane="";function Qs(n,...e){const t=ji(...e);return t.classList.remove("editor-button"),t.classList.add("editor-text-button"),n.append(t),t}function $9(n){lf(n).hide();const t=n.getCustom("table-border-bar");t==null||t.closeToolbar()}function uF(n){return w("div",["insert-column-button","drop-marker"],n)}const dF=S("row-height");function H9(n){const e=Te.fromTable(n),t=n.rows;g(dF,t.length===e.rowCount,"row count mismatch");const o=Array(e.rowCount).fill(0);for(let r=0;r<t.length;){let i=1,l=t[r].getBoundingClientRect().height,a=r+1;for(;a<t.length;){const d=t[a];if(d.cells.length!==0)break;i++,a++,l+=d.getBoundingClientRect().height}for(let d=0;d<i;d++)o[r+d]=l/i;r=a}return o}const hF=S("table-border-bar-dom"),fF=Vi+sc+Vi;function pu(n){const e=oe(n.contentElement);g(hF,e,"no block");const o=lt(e).querySelector(".table-border-bar-container.left"),r=Math.min(n.contentElement.offsetLeft+fF,n.rootElement.scrollLeft+Vi);o&&(o.style.left=`${-r}px`)}const Yi=S("table-border-bar-dom");function Ac(n,e){g(Yi,Vt(e),"invalid table block");const t=Ot(e),o=fr(n,e),r=lt(e),i=(p,A,v)=>{const B=w("div",["button-root",A],p),D=w("div",["button-container",A],B);B.setAttribute(`data-${A}-index`,`${v}`),D.setAttribute(`data-editor-tooltip-${n.clientId}`,A==="left"?R.t("table.insertRow"):R.t("table.insertCol")),w("span",["insert-indicator"],D),uF(D)},{selectedRows:s,selectedColumns:l}=Hp(n,e),a=()=>{const p=o.querySelector(".table-border-bar-container.top");g(Yi,p,"no top border bar container");const A=w("div",["table-border-bar-container","top"],null),v=w("div",["table-border-bar","top"],A),B=vR(t),I=Te.fromTable(t).colCount;n.selection.range.isSimple()&&i(v,"top",0);for(let _=0;_<I;_++){const M=_===I-1?B[_]+2:B[_],H=w("span",["table-border-bar-cell","top"],v);l.has(_)&&H.classList.add("selected"),H.setAttribute("data-top-index",`${_}`),H.style.width=`${M}px`,n.selection.range.isSimple()&&i(v,"top",_+1)}Ca(p,A)},d=()=>{const p=r.querySelector(".table-border-bar-container.left");g(Yi,p,"no left border bar container");const A=w("div",["table-border-bar-container","left"],null),v=w("div",["table-border-bar","left"],A);w("span",["table-border-bar-cell","corner"],v);const B=H9(t);n.selection.range.isSimple()&&i(v,"left",0),Array.from(t.rows).forEach((D,I,_)=>{const M=w("span",["table-border-bar-cell","left"],v);s.has(I)&&M.classList.add("selected"),M.setAttribute("data-left-index",`${I}`);const H=I===_.length-1?B[I]+2:B[I];M.style.height=`${H}px`,n.selection.range.isSimple()&&i(v,"left",I+1)}),Ca(p,A)};a(),d();const h=n.findCustom(hr(e));h&&pu(h)}function j9(n,e){const t=e.target;if(!(t instanceof Element))return;const o=oe(t);g(Yi,o&&Vt(o),"invalid table block"),Ac(n,o),n.selection.caret.update()}function yf(n,e){const t=e.target;if(!(t instanceof Element))return;const o=oe(t);g(Yi,o&&Vt(o),"invalid table block");const r=t.closest(".button-root");if(r){if(r.classList.contains("top")){const i=parseInt(r.getAttribute("data-top-index")||"0",10);Xv(n,o,i),Ac(n,o)}else if(r.classList.contains("left")){const i=parseInt(r.getAttribute("data-left-index")||"0",10);e9(n,o,i),Ac(n,o)}}}function kf(n,e){var s;$9(n),e.preventDefault(),e.stopPropagation();let t=null,o,r;const i=l=>{var a;if(l.target instanceof HTMLElement&&o&&t&&r!==void 0){const d=oe(l.target),h=l.target.closest(".table-border-bar");if(d===t&&h){const p=parseInt((a=l.target.getAttribute(`data-${o}-index`))!=null?a:"0",10),A=Math.min(r,p),v=Math.abs(r-p)+1;xe(l.target,"top")&&o==="top"?RR(n,d,A,v,{reverse:!0}):xe(l.target,"left")&&o==="left"&&OR(n,d,A,v,{reverse:!0})}}l.type==="mouseup"&&(t=null,r=void 0,o=void 0,document.body.removeEventListener("mousemove",i),document.body.removeEventListener("mouseup",i))};e.target instanceof HTMLElement&&xe(e.target,"table-border-bar-cell")&&(t=oe(e.target),xe(e.target,"top")?o="top":xe(e.target,"left")&&(o="left"),o&&t&&(r=parseInt((s=e.target.getAttribute(`data-${o}-index`))!=null?s:"0",10),document.body.addEventListener("mousemove",i),document.body.addEventListener("mouseup",i)))}function U9(n){const e=n.selection.range,t=su(n,e);t&&Ac(n,t)}function mF(n,e){g(Yi,Vt(e),"invalid table block");const t=fr(n,e),o=lt(e),r=w("div",["table-border-bar-container","top"],t),i=w("div",["table-border-bar-container","left"],o);Ac(n,e),n.domEvents.addEventListener(Re(e),"scroll",j9),n.domEvents.addEventListener(r,"click",yf),n.domEvents.addEventListener(i,"click",yf),n.domEvents.addEventListener(r,"mousedown",kf),n.domEvents.addEventListener(i,"mousedown",kf),n.addListener("afterClearSelection",U9)}function z9(n,e){if(!n.isWritable())return;if(fr(n,e).querySelector(".table-border-bar-container")){Ac(n,e);return}mF(n,e)}function V9(n,e){g(Yi,Vt(e),"invalid table block");const t=fr(n,e),o=lt(e),r=t.querySelectorAll(".table-border-bar-container"),i=o.querySelectorAll(".table-border-bar-container");r.forEach(s=>{n.domEvents.removeEventListener(s,"click",yf),n.domEvents.removeEventListener(s,"mousedown",kf),s.remove()}),i.forEach(s=>{n.domEvents.removeEventListener(s,"click",yf),n.domEvents.removeEventListener(s,"mousedown",kf),s.remove()}),n.domEvents.removeEventListener(Re(e),"scroll",j9),n.addListener("afterClearSelection",U9)}function gF(n,e){g(Yi,Vt(e),"invalid table block");const o=fr(n,e).querySelector(".table-border-bar-container.top");return o?o.getBoundingClientRect().height:0}class pF{constructor(e,t){m(this,"toolbar");m(this,"handleSelectionChange",(e,t)=>{!e.isVisible||(t==="delete-columns"?(Wi(this.editor,this.tableBlock,!0,!0),qi(this.editor,this.tableBlock,!0,!0)):t==="delete-rows"?(Wi(this.editor,this.tableBlock,!0,!1),qi(this.editor,this.tableBlock,!0,!1)):(Wi(this.editor,this.tableBlock,!1),qi(this.editor,this.tableBlock,!1)))});m(this,"handleClick",(e,t,o)=>{t.id==="delete-columns"?jp(this.editor.selection.range):t.id==="delete-rows"&&Up(this.editor.selection.range)});m(this,"handleToolbarClose",()=>{this.tableBlock&&su(this.editor,this.editor.selection.range)===this.tableBlock&&(Wi(this.editor,this.tableBlock,!1),qi(this.editor,this.tableBlock,!1))});this.editor=e,this.tableBlock=t;const o=e.options.componentsOptions.popover;this.toolbar=new ou([],void 0,{overflowBoundary:o==null?void 0:o.overflowBoundary,refuseOverflow:!0,tooltipId:this.editor.clientId}),this.toolbar.addListener("selectionChange",this.handleSelectionChange),this.toolbar.addListener("click",this.handleClick),this.toolbar.addListener("close",this.handleToolbarClose)}close(){this.toolbar.close("cancelBar")}update(){var r,i,s,l;const{selectedColumns:e,selectedRows:t}=Hp(this.editor,this.tableBlock);if(!this.editor.isWritable())return;if(e.size>0&&t.size>0){this.toolbar.close("cancelBar");return}if(e.size===0&&t.size===0){this.toolbar.close("cancelBar");return}const o=Ti(this.editor,this.tableBlock,this.editor.selection.range)[0];if(!o){this.toolbar.close("cancelBar");return}if(e.size>0){const a={id:"delete-columns",name:R.t("table.deleteCol"),icon:CL};this.toolbar.updateItems([a]);const d=Li(this.editor,this.tableBlock,"table-row-column-delete",o);this.toolbar.manualShow(d,{placement:"top"})}else{const a={id:"delete-rows",name:R.t("table.deleteRow"),icon:pL};this.toolbar.updateItems([a]);const d=new DOMRect(o.left-Vi,o.top,Vi,o.height),h=Li(this.editor,this.tableBlock,"table-row-column-delete",d);this.toolbar.manualShow(h,{placement:"left"});const p={modifiers:[]},A=this.editor.options.componentsOptions.popover;(r=p==null?void 0:p.modifiers)==null||r.push({name:"flip",options:{boundary:A==null?void 0:A.overflowBoundary,fallbackPlacements:["left","right"]}}),(i=this.toolbar.tippyInstance)==null||i.setProps({popperOptions:p})}(l=(s=this.toolbar.tippyInstance)==null?void 0:s.popperInstance)==null||l.update()}destroy(){this.toolbar.destroy(),this.toolbar.removeAllListeners()}}const L0=S("table-border-bar");class CF{constructor(e,t){m(this,"toolbar");m(this,"resizeObserver");m(this,"handleReadonlyChanged",e=>{e.isWritable()?this.update():V9(this.editor,this.tableBlock)});m(this,"handleBlockUpdated",()=>{this.resizeObserver.disconnect(),setTimeout(()=>{const e=this.editor.getBlockById(ie(this.tableBlock));this.resizeObserver.observe(Ot(e))})});m(this,"handleTableResize",()=>{!this.editor.isWritable()||(console.log("resize"),this.update())});this.editor=e,this.tableBlock=t,g(L0,this.tableBlock,"no table block"),L0.debug("create table border bar"),z9(this.editor,this.tableBlock),this.resizeObserver=new ResizeObserver(this.handleTableResize),this.resizeObserver.observe(Ot(this.tableBlock)),this.toolbar=new pF(this.editor,this.tableBlock),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}close(){this.toolbar.close()}destroy(){L0.debug("destroy table border bar"),this.resizeObserver.disconnect(),V9(this.editor,this.tableBlock),this.toolbar.destroy(),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged)}update(){z9(this.editor,this.tableBlock),this.toolbar.update()}}const AF=S("table-border-bar");class bF{constructor(e){m(this,"activeTableBar",null);m(this,"handleBlockDeleted",(e,t)=>{!this.activeTableBar||(t===this.activeTableBar.tableBlock||Ke(t,this.activeTableBar.tableBlock))&&(this.activeTableBar.destroy(),this.activeTableBar=null)});m(this,"handleSelectionChanged",e=>{var r;const t=e.selection.range,o=su(e,t);((r=this.activeTableBar)==null?void 0:r.tableBlock)!==o&&this.activeTableBar&&this.hide(),o&&this.show(o)});this.editor=e,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(e){this.activeTableBar?(this.activeTableBar.tableBlock!==e&&this.hide(),this.activeTableBar.update()):this.activeTableBar=new CF(this.editor,e)}update(){var e;(e=this.activeTableBar)==null||e.handleBlockUpdated()}closeToolbar(){var e;(e=this.activeTableBar)==null||e.close()}hide(){!this.activeTableBar||(g(AF,this.activeTableBar,"no active table bar"),this.activeTableBar.destroy(),this.activeTableBar=null)}}function W9(n,e){const t=n.addCustom("table-border-bar",o=>new bF(o));e==="update"&&t.update()}const Sn=S("table-cell-menu"),vF="style-bg-color-";class yF{constructor(e){m(this,"activeTableBlock",null);m(this,"targetButton",null);m(this,"manualMenu",null);m(this,"colorPaletteItem",null);m(this,"handlePrevent",(e,t)=>{t.stopPropagation()});m(this,"handleReadonlyChanged",e=>{e.isWritable()||this.hide()});m(this,"handleSelectionChanged",e=>{const t=e.selection.range,o=su(e,t);if(this.hide(),this.activeTableBlock!==o&&(this.activeTableBlock=o),this.activeTableBlock){const r=Te.fromBlock(this.activeTableBlock),i=t.isReverse()?t.start:t.end;let s=null;i instanceof So?e.getBlockById(i.blockId)===this.activeTableBlock?s=r.getCellByContainerId(i.childContainerId):s=this.getCellByChildBlockId(r,i.blockId):s=this.getCellByChildBlockId(r,i.blockId),s&&this.editor.isWritable()&&this.showCellMenuButton(s)}});m(this,"handleBeforePopupPalette",()=>{var t;const e=this.getSelectedBkgColorIndex();(t=this.colorPaletteItem)==null||t.palette.setColor("backgroundColor",e)});m(this,"createBkgColorItem",()=>{const e=w("div",["cell-background-color-item"],null);w("span",[],e,R.t("table.cellBackground"));const t=this.getSelectedBkgColorIndex();w("button",["item-button"],e).setAttribute("data-color-index",`${t}`);const r=w("span",["item-sub-indicator"],e);return r.innerHTML=lv,e});m(this,"handleCommand",e=>{var r;g(Sn,this.activeTableBlock,"no target table block");const t=((r=e.states)==null?void 0:r.includes("checked"))||!1,o=e.value;switch(e.id){case"delete-select-row":Up(Ov(this.editor,this.activeTableBlock,!1));break;case"delete-select-col":jp(Ov(this.editor,this.activeTableBlock,!0));break;case"merge-cell":Lv(this.editor.selection.range);break;case"split-cell":this.handleSplitCell();break;case"row-title":this.handleRowTitle(t);break;case"col-title":this.handleColTitle(t);break;case"stripe-style":this.handleStripeStyle(t);break;case"hide-border":UM(this.editor,this.activeTableBlock,o==="show-border");break;case"show-chart":GM(this.editor,this.activeTableBlock,o==="show-chart"),Kp(this.editor,this.activeTableBlock,{updateNow:!0});break}});m(this,"handleToolbarClose",()=>{this.targetButton&&te(this.targetButton,"active"),this.activeTableBlock&&su(this.editor,this.editor.selection.range)===this.activeTableBlock&&(Wi(this.editor,this.activeTableBlock,!1),qi(this.editor,this.activeTableBlock,!1)),this.editor.focus()});m(this,"handleSelectionChange",(e,t)=>{!e.isVisible||(g(Sn,this.activeTableBlock,"no target table block"),t==="cell-background-color"&&this.handleBeforePopupPalette(),t==="delete-select-row"?(Wi(this.editor,this.activeTableBlock,!0,!1),qi(this.editor,this.activeTableBlock,!0,!1)):t==="delete-select-col"?(Wi(this.editor,this.activeTableBlock,!0,!0),qi(this.editor,this.activeTableBlock,!0,!0)):(Wi(this.editor,this.activeTableBlock,!1),qi(this.editor,this.activeTableBlock,!1)))});m(this,"handleClick",(e,t)=>{var o;g(Sn,this.activeTableBlock,"no target table block"),g(Sn,this.targetButton,"no target button"),$9(this.editor),xe(this.targetButton,"active")?(te(this.targetButton,"active"),(o=this.manualMenu)==null||o.close("clickItem")):(W(this.targetButton,"active"),this.manualMenu?this.manualMenu.updateItems(this.createCommandMenu()):(this.manualMenu=new zs(this.createCommandMenu()),this.manualMenu.on("click",(r,i)=>{var s;this.handleCommand(i),(s=this.manualMenu)==null||s.close("clickItem")}),this.manualMenu.on("selectionChange",this.handleSelectionChange),this.manualMenu.on("close",this.handleToolbarClose)),this.manualMenu.manualShow(this.targetButton,{placement:"right-start"})),t.stopPropagation()});this.editor=e,this.editor.addListener("selectionChanged",this.handleSelectionChanged),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}destroy(){var e,t;this.activeTableBlock=null,this.targetButton=null,this.editor.removeListener("selectionChanged",this.handleSelectionChanged),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged),(e=this.manualMenu)==null||e.destroy(),(t=this.colorPaletteItem)==null||t.destroy()}hide(){var e;(e=this.manualMenu)==null||e.close("cancelBar"),this.targetButton&&(te(this.targetButton,"active"),this.targetButton.style.display="none")}getCellByChildBlockId(e,t){let o=this.editor.getBlockById(t);for(;o;){const r=o.closest("td");g(Sn,r,"no parent cell");const i=oe(r);if(g(Sn,i,"no parent block"),Ot(i)===e.table)return e.getCellByCellElement(r);o=i}return g(Sn,!1,"filed to get cell by child block id"),null}createTargetButton(e){this.targetButton?e.querySelector(`:scope > .${Zp}`)||e.appendChild(this.targetButton):(this.targetButton=w("button",[Zp],e),this.targetButton.innerHTML=Zh,this.editor.domEvents.addEventListener(this.targetButton,"click",this.handleClick),this.editor.domEvents.addEventListener(this.targetButton,"mousedown",this.handlePrevent),this.editor.domEvents.addEventListener(this.targetButton,"dblclick",this.handlePrevent))}showCellMenuButton(e){this.createTargetButton(e.cell),g(Sn,this.targetButton,"no target button"),this.targetButton.style.display="inline-block"}handleSplitCell(){if(this.activeTableBlock){const e=Te.fromBlock(this.activeTableBlock),t=this.editor.selection.range;if(t.isSimple()){const{col:o,row:r}=this.getCellByChildBlockId(e,t.start.blockId);Vp(this.editor,this.activeTableBlock,{col:o,row:r})}else Wp(this.editor.selection.range)}}getSelectedBkgColorIndex(){var r;g(Sn,this.activeTableBlock,"no target table block");const e=WM(this.editor,this.activeTableBlock),t=this.editor.getBlockData(this.activeTableBlock),o=new Set;for(const i of e){if(o.size>1)break;const s=ae(i),l=t[`${s}_background`];if(l)o.add(Number.parseInt((r=l.substring(vF.length))!=null?r:"0",10));else{o.add(-1);break}}return o.size===1&&[...o][0]!==-1?[...o][0]:-1}createCommandMenu(){g(Sn,this.activeTableBlock,"no target table block");const e=this.editor.getBlockData(this.activeTableBlock),t=Sv(this.editor,this.activeTableBlock,this.editor.selection.range);let o=this.editor.selection.range;if(o.isSimple()){const h=Zr(this.editor,this.activeTableBlock,o.start);o=Ut(this.editor,{anchor:h,focus:h})}const r=Dv(this.editor,this.activeTableBlock,o),i=e.hasRowTitle,s=e.hasColTitle,l=e.isStripeStyle,a=e.noBorder,d=e.chart;return this.colorPaletteItem=new wv("cell-background-color",{color:!1}),this.colorPaletteItem.palette.on("onClick",(h,p)=>{var A;switch(g(Sn,this.activeTableBlock,"no target table block"),h){case"clearColor":Pv(this.editor,this.activeTableBlock,-1);break;case"backgroundColor":Pv(this.editor,this.activeTableBlock,p);break}(A=this.manualMenu)==null||A.close("clickItem")}),[{id:"cell-background-color",name:R.t("table.cellBackground"),element:this.createBkgColorItem(),children:[this.colorPaletteItem]},{id:"separator",name:"",type:"separator"},{id:"merge-cell",name:R.t("table.mergeCell"),states:t?[]:["disabled"]},{id:"split-cell",name:R.t("table.splitCell"),states:r?[]:["disabled"]},{id:"separator",name:"",type:"separator"},{id:"delete-select-row",name:R.t("table.deleteSelectRow")},{id:"delete-select-col",name:R.t("table.deleteSelectCol")},{id:"separator",name:"",type:"separator"},{id:"table-config",name:R.t("table.tableConfigKey"),children:[{id:"row-title",name:R.t("table.tableConfig.rowTitle"),states:i?["checked"]:[]},{id:"col-title",name:R.t("table.tableConfig.colTitle"),states:s?["checked"]:[]},{id:"stripe-style",name:R.t("table.tableConfig.stripeStyle"),states:l?["checked"]:[]},{id:"hide-border",name:a?R.t("table.tableConfig.showBorder"):R.t("table.tableConfig.hideBorder"),value:a?"show-border":"hide-border"},{id:"show-chart",name:d?R.t("table.tableConfig.hideChart"):R.t("table.tableConfig.showChart"),value:d?"hide-chart":"show-chart"}]}]}handleRowTitle(e){g(Sn,this.activeTableBlock,"no target table block"),e?$M(this.editor,this.activeTableBlock):NM(this.editor,this.activeTableBlock)}handleColTitle(e){g(Sn,this.activeTableBlock,"no target table block"),e?PM(this.editor,this.activeTableBlock):FM(this.editor,this.activeTableBlock)}handleStripeStyle(e){g(Sn,this.activeTableBlock,"no target table block"),e?jM(this.editor,this.activeTableBlock):HM(this.editor,this.activeTableBlock)}}function q9(n){n.addCustom("table-cell-menu",e=>new yF(e))}const wf=S("table-container");function M0(n){const e=n.closest("td");return g(wf,e,"no parent cell for a table cell container"),e}function G9(n){const e=Ot(n);return Array.from(e.querySelectorAll(':scope > tbody > tr > td > [data-type="editor-container"].child'))}function R0(n,e,t,o){const r=Te.fromBlock(n),i=r.getCellByContainerId(ae(e));if(t==="ArrowDown"){const s=r.getBottomCell(i);return s?s.container:null}if(t==="ArrowUp"){const s=r.getTopCell(i);return s?s.container:null}if(t==="ArrowLeft"){const s=r.getAllContainers(),l=s.indexOf(e);if(g(wf,l>=0,"not a valid child container"),l===0)return null;const a=s[l-1];return o!=null&&o.noWrap&&r.getCellByContainerId(ae(a)).row!==i.row?null:a}if(t==="ArrowRight"){const s=r.getAllContainers(),l=s.indexOf(e);if(g(wf,l>=0,"not a valid child container"),l===s.length-1)return null;const a=s[l+1];return o!=null&&o.noWrap&&r.getCellByContainerId(ae(a)).row!==i.row?null:a}g(wf,!1,`invalid navigation type: ${t}`)}const kF=12,wF=90,Bf=23,Z9=2;class BF{constructor(e){m(this,"scrollTableBlock",null);m(this,"autoScrollDir",null);m(this,"autoScrollTimer",null);m(this,"handleMouseDown",e=>{const t=document.elementFromPoint(e.clientX,e.clientY);if(t&&t instanceof HTMLElement){const o=oe(t);if(o&&Ke(this.editor.rootContainer,o)){const r=Gr(o);r&&(this.scrollTableBlock=r,document.addEventListener("mousemove",this.handleAutoScroll))}}});m(this,"handleAutoScroll",WB.default(e=>{if(this.scrollTableBlock){const t=this.editor.getCustom(hr(this.scrollTableBlock)),o=t.rootElement,r=t.scrollOptions.parentContainer,i=o.getBoundingClientRect(),s=window.innerHeight-(t.scrollOptions.barFloatWindowBottom||0),l=r.getBoundingClientRect(),a=Math.min(l.bottom,s),d=Math.max(l.top,0);i.bottom>a&&e.clientY>=a?this.setAutoScroll("bottom"):i.top<d&&e.clientY<=d?this.setAutoScroll("top"):o.scrollLeft>0&&e.clientX<i.left?this.setAutoScroll("left"):o.scrollLeft<o.scrollWidth-o.offsetWidth&&e.clientX>i.right?this.setAutoScroll("right"):this.clearAutoScroll()}},15));m(this,"handleMouseUp",()=>{document.removeEventListener("mousemove",this.handleAutoScroll),setTimeout(()=>{this.scrollTableBlock=null})});m(this,"handleSelectionChanged",e=>{const t=e.selection.range;if(t.isCollapsed()&&t.isSimple()){const o=e.getBlockById(t.start.blockId),r=Gr(o);if(r){const i=e.getCustom(hr(r)),s=i.rootElement.getBoundingClientRect(),l=To(e,o,t.start);if(s.left>l.left){const a=t.start.offset===0?kF:Z9;i.rootElement.scrollLeft-=s.left-l.left+a}else if(l.right>s.right){const a=t.start.offset===0?wF:Z9;i.rootElement.scrollLeft+=l.right-s.right+a}}}else{const o=e.getBlockById(t.start.blockId),r=Gr(o),i=e.getBlockById(t.end.blockId),s=Gr(i);if(r&&r===s){const l=e.getCustom(hr(r)),a=l.rootElement.getBoundingClientRect();let d=null;if(t.isSimple())d=t.isReverse()?To(e,o,t.start):To(e,i,t.end);else{const h=M0($r(e,t.start.childContainerId)),p=M0($r(e,t.end.childContainerId));d=t.isReverse()?h.getBoundingClientRect():p.getBoundingClientRect()}a.left>d.left&&t.isReverse()?l.rootElement.scrollLeft-=a.left-d.left:a.right<d.right&&!t.isReverse()&&(l.rootElement.scrollLeft+=d.right-a.right)}}});m(this,"handleScroll",e=>{xv(e),this.editor.selection.caret.update()});m(this,"handleReset",e=>{xv(e),this.editor.selection.caret.update()});this.editor=e,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(e){this.autoScrollDir&&this.autoScrollDir!==e&&this.clearAutoScroll(),this.autoScrollTimer||(this.autoScrollDir=e,this.autoScrollTimer=window.setInterval(()=>{if(this.scrollTableBlock){const t=this.editor.getCustom(hr(this.scrollTableBlock)),o=t.rootElement,r=t.scrollOptions.parentContainer,i=o.getBoundingClientRect(),s=r===document.documentElement?window.innerHeight:r.offsetHeight,l=window.innerHeight-(t.scrollOptions.barFloatWindowBottom||0),a=r.getBoundingClientRect(),d=Math.min(a.bottom,l),h=Math.max(a.top,0);this.autoScrollDir==="left"&&(o.scrollLeft-=Bf,o.scrollLeft<=0&&this.clearAutoScroll()),this.autoScrollDir==="right"&&(o.scrollLeft+=Bf,o.scrollLeft>=o.scrollWidth-o.offsetWidth&&this.clearAutoScroll()),this.autoScrollDir==="bottom"&&(r.scrollTop+=Bf,(r.scrollTop>=r.scrollHeight-s||i.bottom<=d)&&this.clearAutoScroll()),this.autoScrollDir==="top"&&(r.scrollTop-=Bf,(r.scrollTop<=0||i.top>=h)&&this.clearAutoScroll())}},100))}destroy(){document.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mouseup",this.handleMouseUp),this.editor.removeListener("selectionChanged",this.handleSelectionChanged)}}function Q9(n){return n.addCustom("table-scroll-events",e=>new BF(e))}const mr=S("create-content");function Y9(n,e,t){const o=new Qh(t),r=t.rows,i=t.cols;g(mr,r>=1,`invalid rows: ${r}`),g(mr,i>=1,`invalid cols: ${i}`),g(mr,t.children,"no table children");const s=w("table",[],null),l=t.colsWidth,a=w("colgroup",[],s);for(let p=0;p<o.colCount;p++){const A=w("col",[],a);A.style.width=`${l[p]||of}px`}const d=w("tbody",[],s);let h=0;for(let p=0;p<r;p++){const A=w("tr",[],d);for(let v=0;v<i;v++){const B=o.getCell({col:v,row:p});if(B.virtual)g(mr,B.colSpan>1||B.rowSpan>1,"virtual cell should have colSpan or rowSpan");else{const D=t.children[h],I=w("td",[],A);B.colSpan>1&&(I.colSpan=B.colSpan),B.rowSpan>1&&(I.rowSpan=B.rowSpan);const _=t[cu(D)];_&&W(I,_),v===0&&t.hasColTitle&&W(I,Mv.COL_TITLE_ITEM),n.createChildContainer(e,I,D),h+=1}}}return g(mr,h===t.children.length,"container count mismatch"),t.noBorder&&W(s,"no-border"),t.chart&&W(s,"editor-table-chart"),t.isStripeStyle&&W(s,"stripe"),t.hasRowTitle&&W(s,"row-title"),t.hasColTitle&&W(s,"col-title"),s}function EF(n,e,t,o,r){g(mr,r.type==="table","not table data"),g(mr,ae(t)===e[e.length-1].containerId,"invalid path");const i=r,s=Ts(o,"div");try{const l=w("div",[],null);l.setAttribute("data-type","table-content");const a=Y9(n,e,i);a.classList.add("drag-preview-element"),l.appendChild(a),Jv(n),n9(n),W9(n,"create"),q9(n),rL(n,Xp);const d=n.getComponentOptions("table"),h=n.addCustom(hr(o),()=>CR());h.init({parentElement:s,childElement:l,safeRightSpace:50,safeLeftSpace:40,parentContainer:Xe(t)?n.scrollContainer:t,locatingContainer:Xe(t)?(d==null?void 0:d.locatingContainer)||n.parent:t,paddingLeft:Vi+sc,paddingTop:Vi+sc,paddingBottom:sc/2,paddingRight:sc/2,barFloatWindowBottom:d==null?void 0:d.barFloatWindowBottom,isSetScale:d==null?void 0:d.isSetScale});const p=Q9(n);h.on("scroll",p.handleReset),h.on("resize",p.handleReset),h.on("resize",pu),h.on("scroll",pu),setTimeout(()=>{YM(n,o)})}catch{const a=`invalid table data: ${JSON.stringify(i)}`;mr.error(a);const d=w("div",["error"],s);d.innerText=a}return s}function xF(n,e,t){g(mr,t.type==="table","not table data");const o=t,r=Re(e);try{const i=Ot(e),s=Di(e),l=Y9(n,s,o);l.classList.add("drag-preview-element"),i.insertAdjacentElement("afterend",l),i.remove(),Jv(n),n9(n),W9(n,"update"),q9(n),Xp(n,e)}catch{const s=`invalid table data: ${JSON.stringify(o)}`;mr.error(s);const l=w("div",["error"],r);l.innerText=s}}function IF(n,e){let t,o,r=!1;if([...e].every(A=>A==="|")?(o=e.length,t=Array(o).fill(""),r=!0):(t=Bm(e,"|").split("|"),o=t.length),o<2)return null;const i=3,s=o,l=[];for(let A=0;A<3;A++)t.forEach(v=>{l.push(zr(n.doc,A===0?v:""))});const a=Array(s).fill(of),d=l[r?0:s],h=n.doc.getContainerBlocks(d)[0].id;return{blockData:{id:K(),type:"table",rows:i,cols:s,children:l,colsWidth:a},focusBlockId:h}}function TF(n,e){const t=e.rows,o=e.cols;if(t<1||o<1)return null;const r=[];for(let d=0;d<t;d++)for(let h=0;h<o;h++)r.push(zr(n.doc));const i=Array(o).fill(of),s=r[0],l=n.doc.getContainerBlocks(s)[0].id;return{blockData:{id:K(),type:"table",rows:t,cols:o,children:r,colsWidth:i},focusBlockId:l}}const J9=S("table-selection-to-doc");function DF(n,e){const{start:t,end:o,block:r}=e,i=De(r);g(J9,i==="table",`invalid block type: ${i}`);const s=n.getBlockData(r);if(t.isSimple()&&o.isSimple())return Fi(n.editorBlocks,n.doc.toJSON(),s);g(J9,!t.isSimple()&&!o.isSimple(),"invalid block pos type");const l=Te.fromBlock(r),{fromCol:a,toCol:d,fromRow:h,toRow:p}=Ho(r,t,o),A={},v=[],B=n.doc.toJSON();let D={};l.sub({row:h,col:a},{row:p,col:d}).forEach((re,fe)=>{re.forEach((Be,je)=>{const Ue=Be.containerId;if(v.indexOf(Ue)!==-1)return;v.push(Ue);let tt;if(Be.virtual){const Nt=l.getCellByContainerId(Be.containerId),Ln=a+je;let yr=Nt.col+Nt.colSpan-1;yr>d&&(yr=d);const bn=yr-Ln+1;bn>1&&(A[`${Ue}_colSpan`]=bn);const an=h+fe;let kr=Nt.row+Nt.rowSpan-1;kr>p&&(kr=p);const ti=kr-an+1;ti>1&&(A[`${Ue}_rowSpan`]=ti),tt=Ur()}else{if(tt=Ng(n.editorBlocks,B,Ue),Be.col+Be.colSpan>d+1){const Nt=d-Be.col+1;Nt>1&&(A[`${Ue}_colSpan`]=Nt)}else Be.colSpan>1&&(A[`${Ue}_colSpan`]=Be.colSpan);if(Be.row+Be.rowSpan>p+1){const Nt=p-Be.row+1;Nt>1&&(A[`${Ue}_rowSpan`]=Nt)}else Be.rowSpan>1&&(A[`${Ue}_rowSpan`]=Be.rowSpan)}const{root:Yt,...Wo}=tt.blocks;D={...D,...Wo,[Ue]:Yt}})});const _=hu(Ot(r)).slice(a,d+1);return{blocks:{root:[{id:K(),type:i,children:v,colsWidth:_,rows:p-h+1,cols:d-a+1,...A}],...D},meta:{},comments:{}}}function SF(n,e){if(e.top===0)return!0;for(let t=e.left;t<=e.right;t++)if(n[e.top-1][t]===n[e.top][t])return!1;return!0}function LF(n,e){if(e.left===0)return!0;for(let t=e.top;t<=e.bottom;t++)if(n[t][e.left-1]===n[t][e.left])return!1;return!0}function MF(n,e){if(e.bottom===n.length-1)return!0;for(let t=e.left;t<=e.right;t++)if(n[e.bottom][t]===n[e.bottom+1][t])return!1;return!0}function RF(n,e){if(e.right===n[0].length-1)return!0;for(let t=e.top;t<=e.bottom;t++)if(n[t][e.right]===n[t][e.right+1])return!1;return!0}function OF(n,e,t){const o=e.col,r=e.row,i=t.col,s=t.row,l={left:o,top:r,right:i,bottom:s};let a=!1;do{if(a=!1,!SF(n,l)){l.top--,a=!0;continue}if(!LF(n,l)){l.left--,a=!0;continue}if(!MF(n,l)){l.bottom++,a=!0;continue}if(!RF(n,l)){l.right++,a=!0;continue}}while(a);return l}function _F(n,e,t,o){if(t.custom!==void 0||o.custom!==void 0)return{anchor:t,focus:o};const r=Te.fromBlock(e),i=r.map(H=>H.containerId),s=r.getCellByContainerId(t.childContainerId),l=r.getCellByContainerId(o.childContainerId),a=Math.min(s.row,l.row),d=Math.max(s.row,l.row),h=Math.min(s.col,l.col),p=Math.max(s.col,l.col),A=OF(i,{row:a,col:h},{row:d,col:p}),v=r.getCell({row:A.top,col:A.left}),B=r.getCell({row:A.bottom,col:A.right}),D=r.getCell({row:A.top,col:A.right}),I=r.getCell({row:A.bottom,col:A.left});let _,M;return s.row<=l.row?s.col<=l.col?(_=v,M=B):(_=D,M=I):s.col<l.col?(_=I,M=D):(_=B,M=v),console.log(`move ${_.col}, ${_.row}, -> ${M.col}, ${M.row}`),{anchor:ft(e,_.containerId),focus:ft(e,M.containerId)}}function K9(n,e,t){if(t.isSimple())return[Ot(e).getBoundingClientRect()];const o=Ot(e),r=o.getBoundingClientRect(),{fromCol:i,fromRow:s,toCol:l,toRow:a}=Ho(e,t.start,t.end),d=hu(o),h=d.slice(0,i).reduce((D,I)=>D+I,0),p=h+d.slice(i,l+1).reduce((D,I)=>D+I,0),A=H9(o);let v=A.slice(0,s).reduce((D,I)=>D+I,0);const B=v+A.slice(s,a+1).reduce((D,I)=>D+I,0);if(s===0){const D=gF(n,e);v-=D}return[new DOMRect(r.left+h,r.top+v,p-h,B-v)]}S("table-size");const FF=40;function Ef(n){const e=n.querySelector("td");if(!e)return 0;const t=window.getComputedStyle(e),o=Number.parseInt(t.borderLeft,10),r=Number.parseInt(t.borderRight,10);return(o+r)/2}function PF(n,e,t){const o=Qm(n,t.container);return o!==void 0?o+Ef(e):FF*t.colSpan-Ef(e)}function NF(n,e,t,o){let r=0;const i=t.colCount;for(let s=0;s<i;s++){const l=t.getRealCell({col:s,row:o});if(l.virtual)continue;let a=PF(n,e,l);const d=b4(l.container,{withPadding:!0});d&&d>a&&(a=d),r+=a+Ef(e)}return r}function $F(n,e){const t=Ot(e),o=Te.fromTable(t);let r=0;for(let s=0;s<o.rowCount;s++)r=Math.max(r,NF(n,t,o,s));const i=Ef(t);return r+=i,r}const Qr=S("table-creator");async function HF(n,e){return n.undoManager.runInGroup(()=>{var a,d;const t=e.item,o=(a=t.colCount)!=null?a:5,r=(d=t.rowCount)!=null?d:3,i=TF(n,{cols:o,rows:r});if(!i)return null;const{blockData:s,focusBlockId:l}=i;return n.insertBlock(e.containerId,e.blockIndex,s,yt(n,l,0))})}class jF{constructor(){m(this,"id","insert-table");m(this,"name","Create table");m(this,"element");m(this,"closeable",null);m(this,"colCount");m(this,"rowCount");m(this,"setCloseable",e=>{this.closeable=e});m(this,"destroy",()=>{this.closeable=null});m(this,"getTableCreatorCellId",(e,t)=>`table-creator-cell-${e}-${t}`);m(this,"handleTableCreatorClick",e=>{var A,v;e.preventDefault(),e.stopPropagation();const t=e.target;g(Qr,t instanceof HTMLElement,"invalid event target");const o=t.closest(".table-creator");g(Qr,o,"no table creator");const r=o.querySelectorAll(".active");if(r.length===0)return;const s=r[r.length-1].id;g(Qr,s,"no cell id");const l="table-creator-cell-";if(!s.startsWith(l))return;const d=s.substring(l.length).split("-");g(Qr,d.length===2,"invalid cell id");const h=Number.parseInt(d[0],10)+1,p=Number.parseInt(d[1],10)+1;Qr.debug(`${h}, ${p}`),this.colCount=p,this.rowCount=h,(A=this.closeable)==null||A.click(this,this.element),(v=this.closeable)==null||v.close("clickItem"),this.handleTableCreatorLeave()});m(this,"handleTableCreatorLeave",()=>{for(let e=0;e<9;e++)for(let t=0;t<9;t++){const o=this.getTableCreatorCellId(e,t),r=document.getElementById(o);r&&te(r,"active")}});m(this,"handleTableCreatorCellEnter",e=>{const t=e.target;g(Qr,t instanceof HTMLElement,"invalid event target");const o=t.id,r="table-creator-cell-";g(Qr,o.startsWith(r),"invalid cell id");const s=o.substring(r.length).split("-");g(Qr,s.length===2,"invalid cell id");let l=Number.parseInt(s[0],10),a=Number.parseInt(s[1],10);l===0&&a===0&&(l=-1,a=-1);for(let d=0;d<9;d++)for(let h=0;h<9;h++){const p=this.getTableCreatorCellId(d,h),A=document.getElementById(p);g(Qr,A,"no cell"),d<=l&&h<=a?W(A,"active"):te(A,"active")}});this.element=this.createTableCreatorElement()}createTableCreatorElement(){const e=w("div",["table-creator"],null),t=(o,r,i)=>{const s=w("div",["table-creator-cell"],o);return s.id=this.getTableCreatorCellId(r,i),s};e.addEventListener("click",this.handleTableCreatorClick),e.addEventListener("mouseleave",this.handleTableCreatorLeave);for(let o=0;o<9;o++){const r=w("div",["table-creator-row"],e);for(let i=0;i<9;i++)t(r,o,i).addEventListener("mouseenter",this.handleTableCreatorCellEnter)}return e}}function UF(){return new jF}function zF(n){const e=/[\u4e00-\u9fff\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g,t=n.match(e);return t?t.length:0}function X9(n){const e=zF(n);return n.length+e}function VF(n,e){const t=X9(n),o=e-t;return o>0?n+" ".repeat(o):n}function WF(n,e,t,o,r){const i=e,s=new Qh(i);if(o==="markdown"||o==="text"){const l=I=>t.blocks[I].map((H,z)=>o==="markdown"?Tg(n,H,t,[...r,{containerId:I,blockIndex:z}]):bh(n,H,t,[...r,{containerId:I,blockIndex:z}])),a=I=>l(I).join(" ").replace(/\n/g," ").trim(),d=new Map,h=new Map;for(let I=0;I<s.colCount;I++){let _=0;for(let M=0;M<s.rowCount;M++){const H=s.getCell({row:M,col:I});let z="";H.virtual||(z=a(H.containerId)),d.set(`${M},${I}`,z),_=Math.max(_,X9(z))}h.set(I,_)}const p=I=>{const _=d.get(`${I.row},${I.col}`)||"",M=h.get(I.col)||0;return VF(_,M)},A=[];let v="|",B="|";for(let I=0;I<s.colCount;I++){const _=p({row:0,col:I});v+=` ${_} |`;const M="-".repeat((h.get(I)||0)+2);B+=`${M}|`}A.push(v),A.push(B);for(let I=1;I<s.rowCount;I++){let _="|";for(let M=0;M<s.colCount;M++){const H=p({row:I,col:M});_+=` ${H} |`}A.push(_)}return`${A.join(`
397
397
  `)}
398
398
  `}if(o==="html"){const l=d=>t.blocks[d].map((A,v)=>Ig(n,A,t,[...r,{containerId:d,blockIndex:v}])).join(`
399
399
  `),a=[];a.push("<table>");for(let d=0;d<s.rowCount;d++){let h="<tr>";for(let p=0;p<s.colCount;p++){const A=s.getCell({row:d,col:p});if(!A.virtual){const v=l(A.containerId);h+=`<td colSpan="${A.colSpan}" rowSpan="${A.rowSpan}">${v}</td>`}}h+="</tr>",a.push(h)}return a.push("</table>"),a.join(`
400
- `)}return""}const Cu=S("table-block");function qF(n){return 1}function GF(n){return!!n.closest(`.${Zp}`)}function ZF(n,e,t,o){const r=document.elementsFromPoint(t,o)[0];if(!r||!e.contains(r)||!n.contains(e))return null;let i=r;if(GF(r)&&(i=r.closest("td"),g(Cu,i instanceof HTMLTableCellElement,"invalid element")),i instanceof HTMLTableCellElement){const a=Ot(e);if(Bv(a).indexOf(i)!==-1){const h=iu(i),p=ft(e,ae(h));return new or(n,{anchor:p,focus:p})}}if(!Fr(r))return null;const s=r;if(G9(e).indexOf(s)===-1)return null;const l=ft(e,ae(s));return new or(n,{anchor:l,focus:l})}function QF(n,e,t,o){return null}function YF(n,e){return n.getBoundingClientRect()}function e7(n,e,t,o){if(t.isSimple()){g(Cu,o.isSimple(),"from is simple position but to is not simple position"),Cu.debug("full select table"),W(e,"full-selected");return}g(Cu,!o.isSimple(),"from is complex position but end is simple position");const r=Zr(n,e,t),i=Zr(n,e,o);g(Cu,r.blockId===i.blockId,"only allow update one table selection"),zM(n,r,i).forEach(l=>{const a=M0(l);W(a,"selected")})}function JF(n){n.rootContainer.querySelectorAll('[data-type="editor-block"][data-block-type="table"]').forEach(e=>{te(e,"full-selected"),e.querySelectorAll("td.selected").forEach(t=>{te(t,"selected")})})}function KF(n,e){return Ev(e)?G9(e):[]}function XF(n,e,t,o,r){return R0(e,t,o,r)}function eP(n,e){return $F(n,e)}function tP(n,e){return ee(n,e)?IF(n,n.getBlockString(e).trim()):null}function nP(n){return{name:"TableBlock",insertBlockCommandItems:[{id:"insert-table",name:R.t("table.title"),order:200,icon:LL,children:[UF()],group:"common",subText:pn("insert-table")}],handleInsertEmptyBlock:HF}}function oP(n,e,t){return xF(n,e,t),setTimeout(()=>{const o=n.selection.range;o.isSimple()?n.selection.caret.update():e7(n,e,o.start,o.end)}),!0}function rP(n,e){let t=0;const{selectedColumns:o}=Hp(n,e);if(o.size>0){const{fromCol:i,toCol:s}=Ho(e,n.selection.range.start,n.selection.range.end),l=Te.fromBlock(e);(i!==0||s!==l.colCount-1)&&(t=60)}const r=K9(n,e,n.selection.range)[0];return new DOMRect(r.left,r.top+t,r.width,Math.max(r.height-t*2,0))}function iP(n,e){iL(n,Xp);const t=n.findCustom(hr(e));if(t){const o=Q9(n);t.off("scroll",o.handleReset),t.off("resize",o.handleReset),t.off("scroll",pu),t.off("resize",pu),t.destroy()}}function sP(){return{abstract:`${R.t("table.abstract")}`}}const xf={blockType:"table",blockKind:"complex",enableKeyboardSelect:!0,createBlockContent:EF,getBlockTextLength:qF,getRangeFromPoint:ZF,moveCaret:QF,getCaretRect:YF,updateSelection:e7,clearSelection:JF,getChildContainers:KF,getNextContainer:XF,getMinWidth:eP,getSelectedContainers:Yp,convertFrom:tP,convertTo:WF,adjustSelectionPos:_F,getClientRects:K9,selectionToDoc:DF,getOptions:nP,getTextToolbarReferenceClient:rP,handleUpdateBlock:oP,handleDeleteBlock:iP,getBlockProperties:sP},lP={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",deleteTable:"\u5220\u9664\u8868\u683C",insertCol:"\u63D2\u5165\u5217",insertRow:"\u63D2\u5165\u884C",deleteCol:"\u5220\u9664\u5217",deleteRow:"\u5220\u9664\u884C",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"}},cP={table:{cellBackground:"Cell background",deleteSelectRow:"Delete rows",deleteSelectCol:"Delete columns",mergeCell:"Merge cells",splitCell:"Split cell",tableConfigKey:"Table setting",deleteTable:"Delete table",insertCol:"Insert column",insertRow:"Insert row",deleteCol:"Delete column",deleteRow:"Delete row",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"}},aP={table:{cellBackground:"\u30BB\u30EB\u306E\u80CC\u666F\u8272",deleteSelectRow:"\u9078\u629E\u3057\u305F\u884C\u3092\u524A\u9664",deleteSelectCol:"\u9078\u629E\u3057\u305F\u5217\u3092\u524A\u9664",mergeCell:"\u30BB\u30EB\u3092\u7D50\u5408",splitCell:"\u30BB\u30EB\u306E\u7D50\u5408\u3092\u89E3\u9664",tableConfigKey:"\u30C6\u30FC\u30D6\u30EB\u8A2D\u5B9A",deleteTable:"\u30C6\u30FC\u30D6\u30EB\u3092\u524A\u9664",insertCol:"\u5217\u3092\u633F\u5165",insertRow:"\u884C\u3092\u633F\u5165",deleteCol:"\u5217\u3092\u524A\u9664",deleteRow:"\u884C\u3092\u524A\u9664",tableConfig:{rowTitle:"\u884C\u898B\u51FA\u3057",colTitle:"\u5217\u898B\u51FA\u3057",stripeStyle:"\u7E1E\u6A21\u69D8",hideBorder:"\u67A0\u7DDA\u3092\u975E\u8868\u793A",showBorder:"\u67A0\u7DDA\u3092\u8868\u793A",showChart:"\u30B0\u30E9\u30D5\u3092\u8868\u793A",hideChart:"\u30B0\u30E9\u30D5\u3092\u975E\u8868\u793A"},title:"\u30C6\u30FC\u30D6\u30EB",abstract:"\u30C6\u30FC\u30D6\u30EB"}};R.mergeLang({"zh-CN":lP,"en-US":cP,"ja-JP":aP});const vne="",t7=S("table");function n7(n,e){const t=$p(e);if(!t)return;const o=oe(t);g(t7,o&&Vt(o),"not a table block");const r=R0(o,t,"ArrowRight");if(!r){const s=Ze(o);return s?(n.selection.selectBlock(s,0),!0):n7(n,o)}const i=St(r);return n.selection.selectBlock(i,0),!0}function uP(n){if(!n.isWritable())return!1;const e=n.getFocusedBlock();if(!!e)return n7(n,e)}function o7(n,e){const t=$p(e);if(!t)return;const o=oe(t);g(t7,o&&Vt(o),"not a table block");const r=R0(o,t,"ArrowLeft");if(!r){const s=ct(o);return s?(n.selection.selectBlock(s,ue(n,s)),!0):o7(n,o)}const i=Gt(r);return n.selection.selectBlock(i,ue(n,i)),!0}function dP(n){if(!n.isWritable())return!1;const e=n.getFocusedBlock();if(!!e)return o7(n,e)}const O0={Tab:uP,"Shift+Tab":dP};function hP(n,e,t,o){const r=n.getBlockByIndex(e,t);if(ue(n,r)!==o)return!1;const i=rt(n.getBlockText(r));if(![...i].every(h=>h==="|")||i.length<3||!n.editorBlocks.hasBlock("table"))return!1;const s=n.editorBlocks.getBlockClass("table");if(!s.convertFrom)return!1;const l=s.convertFrom(n,r,{offset:o});if(!l)return!1;const{blockData:a,focusBlockId:d}=l;return a?(n.undoManager.runInGroup(()=>{var p;const h=n.insertBlock(e,t,a,yt(n,d!=null?d:a.id,0));n.deleteBlock(r),(p=l.onConverted)==null||p.call(l,n,h)}),!0):!1}const fP={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"}}},mP={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 r7(n,e,t,o,r){if(r==="enter"&&hP(n,e,t,o))return!0;const i=n.getBlockByIndex(e,t),s=rt(xn(n.getBlockText(i),o).left).trim(),l=r==="enter"?fP:mP;for(const[,a]of Object.entries(l)){if(!s.match(a.reg))continue;return!!n.undoManager.runInGroup(()=>{var B;const h=Xd(n,i,a.blockType,{offset:o,data:a.data});if(!h)return null;const{blockData:p,focusBlockId:A}=h;if(!p)return null;const v=n.insertBlock(e,t,p,yt(n,A!=null?A:p.id,0));return n.deleteBlock(i),(B=h.onConverted)==null||B.call(h,n,v),{newBlock:v,focusBlockId:A}})}return!1}function gP(n,e,t,o){const r=n.getBlockByIndex(e,t);return n.getBlockString(r,{boxReplacement:" "}).substring(0,o)!==">"?!1:(n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,0,o+1),n.updateBlockData(r,{quoted:!0},yt(n,r,0))}),!0)}const pP={"#":1,"##":2,"###":3,"####":4,"#####":5,"######":6,"#######":7,"########":8};function CP(n,e,t,o){const r=n.getBlockByIndex(e,t),i=n.getBlockString(r,{boxReplacement:" "}).substring(0,o);let s=pP[i];if(!s)return!1;const l=n.getBlockData(r).heading;return l&&l==s&&(s=null),n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,0,o+1),n.updateBlockData(r,{heading:s},yt(n,r,0))}),!0}function AP(n,e,t,o){return!!(CP(n,e,t,o)||gP(n,e,t,o))}const bP=S("match-text-style");function vP(n,e){if(n.length<e.length*2+1||!n.endsWith(e)||n.substring(0,n.length-1).endsWith(e))return-1;const t=n.substring(0,n.length-e.length),o=t.lastIndexOf(e);return o===-1?-1:o===0?0:t.substring(o-1).startsWith(e)?-1:o}const yP={"*":{type:"style",styles:["style-italic"],boxType:""},"**":{type:"style",styles:["style-bold"],boxType:""},"***":{type:"style",styles:["style-bold","style-italic"],boxType:""},"~~":{type:"style",styles:["style-strikethrough"],boxType:""},"`":{type:"style",styles:["style-code"],boxType:""},$$:{type:"box",styles:[],boxType:"math"}};function kP(n,e,t,o){var A,v;const r=n.getBlockByIndex(e,t),i=n.getBlockText(r),{left:s}=xn(i,o),l=pg(s),a=rn(s)-l.length,d=Object.entries(yP);for(const[B,D]of d){const I=vP(l,B);if(I===-1)continue;const _=a+I,M=o,H=B.length,z=rt(zt(i,_+H,M-_-H*2).middle);if(D.type==="style"){const q={};D.styles.forEach(fe=>{q[fe]=!0});const re=Oi(z,q);n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,_,M-_),n.insertTextToBlock(r,_,re)})}else if(D.type==="box")try{const q=(v=(A=n.editorBoxes.getBoxClass(D.boxType)).convertFrom)==null?void 0:v.call(A,n,z);if(!q)continue;n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,_,M-_),n.insertBoxToBlock(r,_,q)})}catch(q){bP.warn(`failed to convert to box, ${q.message}`);continue}return!0}const h=/\[([^\]]+)\]\((https?:\/\/\S+)\)\s*$/,p=l.match(h);if(p){const B=p.index,D=p[1],I=p[2],_=B,M=o,z={...Ta(i,_),link:I};return n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,_,M-_),n.insertTextToBlock(r,_,Oi(D,z))}),!0}return!1}class If{handleAfterInsertText(e,t,o,r,i){return!!(i===" "&&(AP(e,t,o,r)||kP(e,t,o,r)))}handleBeforeKeyDown(e,t){if(!e.selection.range.isSimple())return!1;const{containerId:r,blockIndex:i,offset:s}=e.getTextPosition();if(ee(e,e.getBlockByIndex(r,i))){if(Or(t,"Enter")){if(r7(e,r,i,s,"enter"))return!0}else if(Or(t,"Space")&&r7(e,r,i,s,"space"))return!0}return!1}}const wP={"en-US":{placeholder:{default:"Type \u2018/\u2019 for commands",heading:"Heading {heading}",list:"List",mention:"Quickly assign tasks @mention yourself or others",quote:"Quote",title:"Enter document title"}},"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",title:"\u8BF7\u8F93\u5165\u6587\u6863\u6807\u9898"}},"ja-JP":{placeholder:{default:"\u300C/\u300D\u3092\u5165\u529B\u3057\u3066\u7D20\u65E9\u304F\u633F\u5165\u3059\u308B",heading:"\u898B\u51FA\u3057{heading}",list:"\u30EA\u30B9\u30C8",mention:"\u81EA\u5206\u3084\u30E1\u30F3\u30D0\u30FC\u3092\uFF20\u3057\u3001\u30BF\u30B9\u30AF\u3092\u7D20\u65E9\u304F\u5272\u308A\u5F53\u3066\u307E\u3059",quote:"\u5F15\u7528",title:"\u30BF\u30A4\u30C8\u30EB\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}}};R.mergeLang(wP);function Au(n,e){const t=_i(n,e);return!!(t.text&&rn(t.text)===0&&!e.querySelector(".inputting-insertion"))}function i7(n,e){var o;Re(e).removeAttribute("data-content-placeholder"),(o=e.querySelector("[data-type=block-tools] .block-placeholder-container"))==null||o.remove()}function Tf(n,e,t){var r;if(!Au(n,e)){i7(n,e);return}const o=Re(e);if(typeof t=="string")o.setAttribute("data-content-placeholder",t);else{const i=lt(e),s=(r=i.querySelector(".block-placeholder-container"))!=null?r:w("div",["block-placeholder-container"],i);s.innerHTML="",s.appendChild(t)}}function BP(n){const e=n.getAttribute("data-style-heading");return e?R.t("placeholder.heading",{heading:e}):n.getAttribute("data-style-quoted")?R.t("placeholder.quote"):null}function EP(n){const e=n.getAttribute("data-list-type");return e?e==="ordered"||e==="unordered"?R.t("placeholder.list"):R.t("placeholder.mention"):null}function s7(n){switch(De(n)){case"text":return BP(n);case"list":return EP(n);default:return null}}function xP(n){if(ro(n))return!1;const e=oe(ne(n));return e?De(e)==="code":!1}function IP(n){return!ro(n)}function TP(n,e){var h,p;const t=n.selection.focusedBlock,o=De(t),r=e.contentPlaceholder||R.t("placeholder.default");let i=r;if(o&&ya(n,o)&&t){if(!n.isBlockWritable(t)||xP(t))return;IP(t)&&(i=R.t("placeholder.common.contentInTable")),i=(h=s7(t))!=null?h:i}const s=n.getFirstBlock(),l=Ze(s);if(!l)return;const a=Ze(l);if(a&&!e.addPlaceholderToAllCurrentEmptyBlock)return;if(!a&&Au(n,l)){Tf(n,l,(p=s7(l))!=null?p:r);return}const d=n.getFocusedBlock();!Au(n,d)||d!==s&&Tf(n,d,i)}function DP(n,e){var r,i;const t=n.getFirstBlock(),o=Re(t);Au(n,t)?(o.setAttribute("data-title-placeholder",(r=e.titlePlaceholder)!=null?r:R.t("placeholder.title")),o.setAttribute("data-title-placeholder-readonly",(i=e.readonlyTitlePlaceholder)!=null?i:"")):(o.removeAttribute("data-title-placeholder"),o.removeAttribute("data-title-placeholder-readonly"))}function SP(n){n.rootContainer.querySelectorAll("[data-content-placeholder").forEach(e=>{e.removeAttribute("data-content-placeholder")}),n.rootContainer.querySelectorAll("[data-type=block-tools] .block-placeholder-container").forEach(e=>{e.remove()})}function LP(n,e){SP(n),n.selection.range.isCollapsed()&&(DP(n,e),TP(n,e))}const Bne="";function MP(n){for(let e=1;e<n.length;e++){const t=n[e];if(t.attributes&&Object.keys(t.attributes).length)return!0}return!1}const l7=S("enforce-title");class bu{constructor(e,t={headingLevel:1}){m(this,"handleSelectionChange",e=>{setTimeout(()=>{this.applyPlaceholder(e)})});this.options=t,this.handleChanged(e),this.applyPlaceholder(e),e.addListener("selectionChanged",this.handleSelectionChange)}destroy(e){e.removeListener("selectionChanged",this.handleSelectionChange)}handleBeforeKeyDown(e,t){if(!e.selection.range.isSimple())return!1;const{containerId:r,blockIndex:i,offset:s}=e.getTextPosition();if(!bu.isDocumentTitleBlock(r,i)||!Or(t,"Enter"))return!1;let l=!1,a=null;Eo(e.rootContainer)===2&&(a=_r(e.rootContainer,1),ue(e,a)===0&&(l=!0));const d=e.getFirstBlock();return e.undoManager.runInGroup(()=>{e.breakTextBlock(d,s,{forceInsertAfter:!0}),l&&a&&e.deleteBlock(a)}),!0}handleChanged(e){var t,o;try{const r=e.doc.getContainerBlocks(ae(e.rootContainer));g(l7,r.length>0,"root container is empty");const i=r[0];if(i.type!=="text"){const s=sr("",{heading:(t=this.options.headingLevel)!=null?t:1});e.insertBlock(ae(e.rootContainer),0,s,e.selection.range.toDocRange());return}if(g(l7,i.text,"invalid text block"),MP(i.text)||i.quoted||i.heading!==this.options.headingLevel){const s=e.getBlockById(i.id),l=e.getBlockString(s),a=sr(l,{heading:(o=this.options.headingLevel)!=null?o:1,quoted:!1}),d=e.selection.focusedBlock;let h=e.selection.range;const p=e.insertBlock(ae(e.rootContainer),0,a);d===s&&(h=yt(e,a.id,ue(e,p))),wh(e,s,h)}if(r.length>1)return;e.insertTextBlock("",ae(e.rootContainer),1,{newRange:e.selection.range.toDocRange()})}finally{this.applyPlaceholder(e)}}handleRemoteChanged(e){setTimeout(()=>{this.applyPlaceholder(e)})}handleUpdateCompositionText(e){this.applyPlaceholder(e)}applyPlaceholder(e){var t,o;!((t=this.options)!=null&&t.titlePlaceholder)&&!((o=this.options)!=null&&o.contentPlaceholder)||LP(e,this.options)}static isDocumentTitleBlock(e,t){return e==="root"&&t===0}}const c7=S("code-dom");function Ji(n){return De(n)==="code"}function a7(n,e,t){t.language?e.setAttribute("data-language",t.language):e.removeAttribute("data-language"),t.nowrap?te(e,"wrap"):W(e,"wrap")}function _0(n){const e=n.closest("div[data-type=editor-block][data-block-type=code]");return g(c7,e,"no parent code block"),g(c7,Ji(e),"not a code block"),e}const vu={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 u7(n){const e=n.toLocaleLowerCase();let t="";return Object.entries(vu).forEach(([o,r])=>{(o===e||r.aliases.includes(e)||r.name.toLocaleLowerCase()===e)&&(t=o)}),t}function d7(n){const e=n.settingsProvider.getItem("editor-code-lang");return e!=null?e:"plain"}function RP(n,e){return n.settingsProvider.setItem("editor-code-lang",e)}const OP=S("convert-to-code");function _P(n,e){if(!ee(n,e))return null;const t={id:K(),type:"text",text:[]},o=K();n.doc.localInsertChildContainer(o,[t]);const r=n.getBlockData(e).text;g(OP,r,"no text");let i=rt(r);i.startsWith("```")&&(i=i.substring(3));const s=u7(i)||d7(n)||"plain";return{blockData:{id:K(),type:"code",language:s,children:[o]},focusBlockId:t.id}}const Ene="",F0=S("code-block-child-container");function bc(n){g(F0,Ji(n),"not a code block");const t=Re(n).querySelector(":scope > div.editor-code-root > div.code-text-root [data-type=editor-container].child");return g(F0,t,"no code text container"),t}function vc(n){g(F0,Ji(n),"not a code block");const t=Re(n).querySelector(":scope > div.editor-code-root > div.code-caption-root [data-type=editor-container].child");return t||null}function Df(n){const e=[bc(n)],t=vc(n);return t&&e.push(t),e}function yc(n,e){if(!ee(n,e))return!1;const t=ne(e),o=oe(t);return o?Ji(o)?t===bc(o):De(e)==="code":!1}const P0=S("code-caption");function FP(n,e){if(n.readonly)return;const t=vc(e);if(t){const a=St(t);n.selection.selectBlock(a,0);return}const o=zr(n.doc),r=n.getBlockData(e);g(P0,r.children.length===1,"code block should have only one child");const i={...r,children:[r.children[0],o]};n.updateBlockData(e,i);const s=n.getContainerById(o),l=St(s);n.selection.selectBlock(l,0)}function h7(n,e){const t=ne(e);if(Xe(t))return!1;const o=oe(t);if(g(P0,o,"no parent block"),!Ji(o))return!1;const i=vc(o);return t===i}function PP(n,e){if(n.readonly||!vc(e))return;const o=bc(e),r=Gt(o);n.selection.selectBlock(r,ue(n,r));const i=n.getBlockData(e);g(P0,i.children.length===2,"code block should have only one child");const s=i.children[1],l={...i,children:[i.children[0]]};n.updateBlockData(e,l),n.deleteChildContainers([s])}const NP=S("paste-in-table-block");class $P{constructor(e){this.editor=e,setTimeout(()=>{e.input.addHandler(this)})}destroy(){}async handleBeforePaste(e,t,o){if(!e.selection.range.isSimple())return!1;const r=e.selection.range.start,i=e.getBlockById(r.blockId),s=ne(i);if(Xe(s))return!1;const l=oe(s);if(g(NP,l,"no parent block"),!Ji(l)||h7(e,i))return!1;const a=o["text/x-ones-editor-doc"];let d=null;if(a){const p=La(e,a);d=Ur(p)}else d=o["text/plain"];if(!d)return!0;const h=d;return e.undoManager.runInGroup(()=>{e.clearSelectedContents(),e.insertDoc(i,r.offset,h)}),!0}}function HP(n){n.addCustom("code-block-paste-event",e=>new $P(e))}class jP{constructor(e){m(this,"id","CodeBlockCommandProvider");setTimeout(()=>{e.editorCommandProviders.registerCommandProvider(this)})}destroy(){}getAvailableCommands(){return[]}executeCommand(){return!1}filterCommands(e,t,o,r){if(yc(e,t))return[]}beforeExecuteCommand(e,t,o,r,i){return!!yc(e,t)}}function UP(n){n.addCustom("code-block-command-provider",e=>new jP(e))}const zP=S("code-caption-input-handler");function N0(n){if(!n.selection.range.isSimple())return null;const e=n.selection.range.start;if(!e.isSimple())return null;const t=n.getBlockById(e.blockId);return h7(n,t)?t:null}function VP(n){const e=N0(n);if(!e)return!1;const t=_0(e),o=Ze(t);return o?(n.selection.selectBlock(o,0),!0):(n.insertTextBlock("",ae(ne(t)),be(t)+1),!0)}function WP(n){const e=N0(n);if(!e)return!1;if(ht(n,e)){const t=_0(e);return PP(n,t),!0}return!1}class $0{constructor(e){setTimeout(()=>{e.input.addHandler(this)})}destroy(){}handleBeforeKeyDown(e,t){return t.key==="Enter"?VP(e):t.key==="Backspace"?WP(e):!1}async handleBeforePaste(e,t,o){const r=N0(e);if(!r)return!1;const i=o["text/plain"];if(!i)return!0;const s=La(e,i);return s&&e.undoManager.runInGroup(()=>{e.clearSelectedContents();const l=e.selection.range.start;g(zP,l.isSimple(),"not simple position"),e.insertTextToBlock(r,l.offset,s)}),!0}static init(e){e.addCustom("code-block-caption-input-handler",t=>new $0(t))}}function qP(n){const o=new DOMParser().parseFromString(n,"text/html").querySelector("svg");if(!o)return null;const r=o.getAttribute("viewBox");if(!r)return null;const i=r.split(" ");if(i.length===4){const s=i[2],l=i[3];return o.setAttribute("width",s),o.setAttribute("height",l),o.outerHTML}return null}function H0(n,e,t=!0){const o=new Image,r=document.createElement("canvas"),i=r.getContext("2d");if(!i){e(new Error("failed to get context"),null);return}o.onload=()=>{if(r.width=o.naturalWidth,r.height=o.naturalHeight,t&&(r.width===0||r.height===0)){const s=n.substring(26);if(s){const l=atob(s),a=qP(l);if(a){Sm(a,"image/svg+xml").then(d=>{H0(d,e,!1)});return}}e(null,null);return}i.drawImage(o,0,0),r.toBlob(s=>{e(null,s)},"image/png")},o.src=n}function GP(n){return new Promise((e,t)=>{H0(n,(o,r)=>{if(o){t(o);return}if(!r){t(new Error("Failed to get image blob"));return}e(r)})})}async function f7(n){const e=await Ul(n);return new Promise((t,o)=>{H0(e,(r,i)=>{if(r){o(r);return}if(!i){o(new Error("Failed to get image blob"));return}t(i)})})}const m7="Untitled";function g7(n){const e=St(n.rootContainer);return!e||!ee(n,e)?m7:n.getBlockString(e)||m7}function j0(){return Object.prototype.hasOwnProperty.bind(window,"isSecureContext")?window.isSecureContext:window.location.protocol==="https:"||window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"}function ZP(n){let e;return n.forEach((t,o)=>{o.toLocaleLowerCase()==="content-type"&&(e=t)}),e!=null?e:""}async function p7(n){try{const e=await fetch(n,{credentials:"same-origin"}),t=await e.blob(),o=ZP(e.headers).toLocaleLowerCase();let r="";if(o){const s=mm.default[o].extensions;s&&s.length>0&&(r=s[0])}return new File([t],`${Date.now()}.${r}`,{type:o})}catch{return null}}const QP=`
400
+ `)}return""}const Cu=S("table-block");function qF(n){return 1}function GF(n){return!!n.closest(`.${Zp}`)}function ZF(n,e,t,o){const r=document.elementsFromPoint(t,o)[0];if(!r||!e.contains(r)||!n.contains(e))return null;let i=r;if(GF(r)&&(i=r.closest("td"),g(Cu,i instanceof HTMLTableCellElement,"invalid element")),i instanceof HTMLTableCellElement){const a=Ot(e);if(Bv(a).indexOf(i)!==-1){const h=iu(i),p=ft(e,ae(h));return new or(n,{anchor:p,focus:p})}}if(!Fr(r))return null;const s=r;if(G9(e).indexOf(s)===-1)return null;const l=ft(e,ae(s));return new or(n,{anchor:l,focus:l})}function QF(n,e,t,o){return null}function YF(n,e){return n.getBoundingClientRect()}function e7(n,e,t,o){if(t.isSimple()){g(Cu,o.isSimple(),"from is simple position but to is not simple position"),Cu.debug("full select table"),W(e,"full-selected");return}g(Cu,!o.isSimple(),"from is complex position but end is simple position");const r=Zr(n,e,t),i=Zr(n,e,o);g(Cu,r.blockId===i.blockId,"only allow update one table selection"),zM(n,r,i).forEach(l=>{const a=M0(l);W(a,"selected")})}function JF(n){n.rootContainer.querySelectorAll('[data-type="editor-block"][data-block-type="table"]').forEach(e=>{te(e,"full-selected"),e.querySelectorAll("td.selected").forEach(t=>{te(t,"selected")})})}function KF(n,e){return Ev(e)?G9(e):[]}function XF(n,e,t,o,r){return R0(e,t,o,r)}function eP(n,e){return $F(n,e)}function tP(n,e){return ee(n,e)?IF(n,n.getBlockString(e).trim()):null}function nP(n){return{name:"TableBlock",insertBlockCommandItems:[{id:"insert-table",name:R.t("table.title"),order:200,icon:LL,children:[UF()],group:"common",subText:pn("insert-table")}],handleInsertEmptyBlock:HF}}function oP(n,e,t){return xF(n,e,t),setTimeout(()=>{const o=n.selection.range;o.isSimple()?n.selection.caret.update():e7(n,e,o.start,o.end)}),!0}function rP(n,e){let t=0;const{selectedColumns:o}=Hp(n,e);if(o.size>0){const{fromCol:i,toCol:s}=Ho(e,n.selection.range.start,n.selection.range.end),l=Te.fromBlock(e);(i!==0||s!==l.colCount-1)&&(t=60)}const r=K9(n,e,n.selection.range)[0];return new DOMRect(r.left,r.top+t,r.width,Math.max(r.height-t*2,0))}function iP(n,e){iL(n,Xp);const t=n.findCustom(hr(e));if(t){const o=Q9(n);t.off("scroll",o.handleReset),t.off("resize",o.handleReset),t.off("scroll",pu),t.off("resize",pu),t.destroy()}}function sP(){return{abstract:`${R.t("table.abstract")}`}}const xf={blockType:"table",blockKind:"complex",enableKeyboardSelect:!0,createBlockContent:EF,getBlockTextLength:qF,getRangeFromPoint:ZF,moveCaret:QF,getCaretRect:YF,updateSelection:e7,clearSelection:JF,getChildContainers:KF,getNextContainer:XF,getMinWidth:eP,getSelectedContainers:Yp,convertFrom:tP,convertTo:WF,adjustSelectionPos:_F,getClientRects:K9,selectionToDoc:DF,getOptions:nP,getTextToolbarReferenceClient:rP,handleUpdateBlock:oP,handleDeleteBlock:iP,getBlockProperties:sP},lP={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",deleteTable:"\u5220\u9664\u8868\u683C",insertCol:"\u63D2\u5165\u5217",insertRow:"\u63D2\u5165\u884C",deleteCol:"\u5220\u9664\u5217",deleteRow:"\u5220\u9664\u884C",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"}},cP={table:{cellBackground:"Cell background color",deleteSelectRow:"Delete selected rows",deleteSelectCol:"Delete selected columns",mergeCell:"Merge cells",splitCell:"Split cell",tableConfigKey:"Table settings",deleteTable:"Delete table",insertCol:"Insert column",insertRow:"Insert row",deleteCol:"Delete column",deleteRow:"Delete row",tableConfig:{rowTitle:"Row header",colTitle:"Column header",stripeStyle:"Stripe style",hideBorder:"Hide border",showBorder:"Show border",showChart:"Show chart",hideChart:"Hide chart"},title:"Table",abstract:"Table"}},aP={table:{cellBackground:"\u30BB\u30EB\u306E\u80CC\u666F\u8272",deleteSelectRow:"\u9078\u629E\u3057\u305F\u884C\u3092\u524A\u9664",deleteSelectCol:"\u9078\u629E\u3057\u305F\u5217\u3092\u524A\u9664",mergeCell:"\u30BB\u30EB\u3092\u7D50\u5408",splitCell:"\u30BB\u30EB\u306E\u7D50\u5408\u3092\u89E3\u9664",tableConfigKey:"\u30C6\u30FC\u30D6\u30EB\u8A2D\u5B9A",deleteTable:"\u30C6\u30FC\u30D6\u30EB\u3092\u524A\u9664",insertCol:"\u5217\u3092\u633F\u5165",insertRow:"\u884C\u3092\u633F\u5165",deleteCol:"\u5217\u3092\u524A\u9664",deleteRow:"\u884C\u3092\u524A\u9664",tableConfig:{rowTitle:"\u884C\u898B\u51FA\u3057",colTitle:"\u5217\u898B\u51FA\u3057",stripeStyle:"\u7E1E\u6A21\u69D8",hideBorder:"\u67A0\u7DDA\u3092\u975E\u8868\u793A",showBorder:"\u67A0\u7DDA\u3092\u8868\u793A",showChart:"\u30B0\u30E9\u30D5\u3092\u8868\u793A",hideChart:"\u30B0\u30E9\u30D5\u3092\u975E\u8868\u793A"},title:"\u30C6\u30FC\u30D6\u30EB",abstract:"\u30C6\u30FC\u30D6\u30EB"}};R.mergeLang({"zh-CN":lP,"en-US":cP,"ja-JP":aP});const vne="",t7=S("table");function n7(n,e){const t=$p(e);if(!t)return;const o=oe(t);g(t7,o&&Vt(o),"not a table block");const r=R0(o,t,"ArrowRight");if(!r){const s=Ze(o);return s?(n.selection.selectBlock(s,0),!0):n7(n,o)}const i=St(r);return n.selection.selectBlock(i,0),!0}function uP(n){if(!n.isWritable())return!1;const e=n.getFocusedBlock();if(!!e)return n7(n,e)}function o7(n,e){const t=$p(e);if(!t)return;const o=oe(t);g(t7,o&&Vt(o),"not a table block");const r=R0(o,t,"ArrowLeft");if(!r){const s=ct(o);return s?(n.selection.selectBlock(s,ue(n,s)),!0):o7(n,o)}const i=Gt(r);return n.selection.selectBlock(i,ue(n,i)),!0}function dP(n){if(!n.isWritable())return!1;const e=n.getFocusedBlock();if(!!e)return o7(n,e)}const O0={Tab:uP,"Shift+Tab":dP};function hP(n,e,t,o){const r=n.getBlockByIndex(e,t);if(ue(n,r)!==o)return!1;const i=rt(n.getBlockText(r));if(![...i].every(h=>h==="|")||i.length<3||!n.editorBlocks.hasBlock("table"))return!1;const s=n.editorBlocks.getBlockClass("table");if(!s.convertFrom)return!1;const l=s.convertFrom(n,r,{offset:o});if(!l)return!1;const{blockData:a,focusBlockId:d}=l;return a?(n.undoManager.runInGroup(()=>{var p;const h=n.insertBlock(e,t,a,yt(n,d!=null?d:a.id,0));n.deleteBlock(r),(p=l.onConverted)==null||p.call(l,n,h)}),!0):!1}const fP={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"}}},mP={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 r7(n,e,t,o,r){if(r==="enter"&&hP(n,e,t,o))return!0;const i=n.getBlockByIndex(e,t),s=rt(xn(n.getBlockText(i),o).left).trim(),l=r==="enter"?fP:mP;for(const[,a]of Object.entries(l)){if(!s.match(a.reg))continue;return!!n.undoManager.runInGroup(()=>{var B;const h=Xd(n,i,a.blockType,{offset:o,data:a.data});if(!h)return null;const{blockData:p,focusBlockId:A}=h;if(!p)return null;const v=n.insertBlock(e,t,p,yt(n,A!=null?A:p.id,0));return n.deleteBlock(i),(B=h.onConverted)==null||B.call(h,n,v),{newBlock:v,focusBlockId:A}})}return!1}function gP(n,e,t,o){const r=n.getBlockByIndex(e,t);return n.getBlockString(r,{boxReplacement:" "}).substring(0,o)!==">"?!1:(n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,0,o+1),n.updateBlockData(r,{quoted:!0},yt(n,r,0))}),!0)}const pP={"#":1,"##":2,"###":3,"####":4,"#####":5,"######":6,"#######":7,"########":8};function CP(n,e,t,o){const r=n.getBlockByIndex(e,t),i=n.getBlockString(r,{boxReplacement:" "}).substring(0,o);let s=pP[i];if(!s)return!1;const l=n.getBlockData(r).heading;return l&&l==s&&(s=null),n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,0,o+1),n.updateBlockData(r,{heading:s},yt(n,r,0))}),!0}function AP(n,e,t,o){return!!(CP(n,e,t,o)||gP(n,e,t,o))}const bP=S("match-text-style");function vP(n,e){if(n.length<e.length*2+1||!n.endsWith(e)||n.substring(0,n.length-1).endsWith(e))return-1;const t=n.substring(0,n.length-e.length),o=t.lastIndexOf(e);return o===-1?-1:o===0?0:t.substring(o-1).startsWith(e)?-1:o}const yP={"*":{type:"style",styles:["style-italic"],boxType:""},"**":{type:"style",styles:["style-bold"],boxType:""},"***":{type:"style",styles:["style-bold","style-italic"],boxType:""},"~~":{type:"style",styles:["style-strikethrough"],boxType:""},"`":{type:"style",styles:["style-code"],boxType:""},$$:{type:"box",styles:[],boxType:"math"}};function kP(n,e,t,o){var A,v;const r=n.getBlockByIndex(e,t),i=n.getBlockText(r),{left:s}=xn(i,o),l=pg(s),a=rn(s)-l.length,d=Object.entries(yP);for(const[B,D]of d){const I=vP(l,B);if(I===-1)continue;const _=a+I,M=o,H=B.length,z=rt(zt(i,_+H,M-_-H*2).middle);if(D.type==="style"){const q={};D.styles.forEach(fe=>{q[fe]=!0});const re=Oi(z,q);n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,_,M-_),n.insertTextToBlock(r,_,re)})}else if(D.type==="box")try{const q=(v=(A=n.editorBoxes.getBoxClass(D.boxType)).convertFrom)==null?void 0:v.call(A,n,z);if(!q)continue;n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,_,M-_),n.insertBoxToBlock(r,_,q)})}catch(q){bP.warn(`failed to convert to box, ${q.message}`);continue}return!0}const h=/\[([^\]]+)\]\((https?:\/\/\S+)\)\s*$/,p=l.match(h);if(p){const B=p.index,D=p[1],I=p[2],_=B,M=o,z={...Ta(i,_),link:I};return n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,_,M-_),n.insertTextToBlock(r,_,Oi(D,z))}),!0}return!1}class If{handleAfterInsertText(e,t,o,r,i){return!!(i===" "&&(AP(e,t,o,r)||kP(e,t,o,r)))}handleBeforeKeyDown(e,t){if(!e.selection.range.isSimple())return!1;const{containerId:r,blockIndex:i,offset:s}=e.getTextPosition();if(ee(e,e.getBlockByIndex(r,i))){if(Or(t,"Enter")){if(r7(e,r,i,s,"enter"))return!0}else if(Or(t,"Space")&&r7(e,r,i,s,"space"))return!0}return!1}}const wP={"en-US":{placeholder:{default:"Type / for commands",heading:"Title {heading}",list:"List",mention:"Quickly assign tasks and use @ to mention yourself or others",quote:"Quote",title:"Enter document title"}},"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",title:"\u8BF7\u8F93\u5165\u6587\u6863\u6807\u9898"}},"ja-JP":{placeholder:{default:"\u300C/\u300D\u3092\u5165\u529B\u3057\u3066\u7D20\u65E9\u304F\u633F\u5165\u3059\u308B",heading:"\u898B\u51FA\u3057{heading}",list:"\u30EA\u30B9\u30C8",mention:"\u81EA\u5206\u3084\u30E1\u30F3\u30D0\u30FC\u3092\uFF20\u3057\u3001\u30BF\u30B9\u30AF\u3092\u7D20\u65E9\u304F\u5272\u308A\u5F53\u3066\u307E\u3059",quote:"\u5F15\u7528",title:"\u30BF\u30A4\u30C8\u30EB\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044"}}};R.mergeLang(wP);function Au(n,e){const t=_i(n,e);return!!(t.text&&rn(t.text)===0&&!e.querySelector(".inputting-insertion"))}function i7(n,e){var o;Re(e).removeAttribute("data-content-placeholder"),(o=e.querySelector("[data-type=block-tools] .block-placeholder-container"))==null||o.remove()}function Tf(n,e,t){var r;if(!Au(n,e)){i7(n,e);return}const o=Re(e);if(typeof t=="string")o.setAttribute("data-content-placeholder",t);else{const i=lt(e),s=(r=i.querySelector(".block-placeholder-container"))!=null?r:w("div",["block-placeholder-container"],i);s.innerHTML="",s.appendChild(t)}}function BP(n){const e=n.getAttribute("data-style-heading");return e?R.t("placeholder.heading",{heading:e}):n.getAttribute("data-style-quoted")?R.t("placeholder.quote"):null}function EP(n){const e=n.getAttribute("data-list-type");return e?e==="ordered"||e==="unordered"?R.t("placeholder.list"):R.t("placeholder.mention"):null}function s7(n){switch(De(n)){case"text":return BP(n);case"list":return EP(n);default:return null}}function xP(n){if(ro(n))return!1;const e=oe(ne(n));return e?De(e)==="code":!1}function IP(n){return!ro(n)}function TP(n,e){var h,p;const t=n.selection.focusedBlock,o=De(t),r=e.contentPlaceholder||R.t("placeholder.default");let i=r;if(o&&ya(n,o)&&t){if(!n.isBlockWritable(t)||xP(t))return;IP(t)&&(i=R.t("placeholder.common.contentInTable")),i=(h=s7(t))!=null?h:i}const s=n.getFirstBlock(),l=Ze(s);if(!l)return;const a=Ze(l);if(a&&!e.addPlaceholderToAllCurrentEmptyBlock)return;if(!a&&Au(n,l)){Tf(n,l,(p=s7(l))!=null?p:r);return}const d=n.getFocusedBlock();!Au(n,d)||d!==s&&Tf(n,d,i)}function DP(n,e){var r,i;const t=n.getFirstBlock(),o=Re(t);Au(n,t)?(o.setAttribute("data-title-placeholder",(r=e.titlePlaceholder)!=null?r:R.t("placeholder.title")),o.setAttribute("data-title-placeholder-readonly",(i=e.readonlyTitlePlaceholder)!=null?i:"")):(o.removeAttribute("data-title-placeholder"),o.removeAttribute("data-title-placeholder-readonly"))}function SP(n){n.rootContainer.querySelectorAll("[data-content-placeholder").forEach(e=>{e.removeAttribute("data-content-placeholder")}),n.rootContainer.querySelectorAll("[data-type=block-tools] .block-placeholder-container").forEach(e=>{e.remove()})}function LP(n,e){SP(n),n.selection.range.isCollapsed()&&(DP(n,e),TP(n,e))}const Bne="";function MP(n){for(let e=1;e<n.length;e++){const t=n[e];if(t.attributes&&Object.keys(t.attributes).length)return!0}return!1}const l7=S("enforce-title");class bu{constructor(e,t={headingLevel:1}){m(this,"handleSelectionChange",e=>{setTimeout(()=>{this.applyPlaceholder(e)})});this.options=t,this.handleChanged(e),this.applyPlaceholder(e),e.addListener("selectionChanged",this.handleSelectionChange)}destroy(e){e.removeListener("selectionChanged",this.handleSelectionChange)}handleBeforeKeyDown(e,t){if(!e.selection.range.isSimple())return!1;const{containerId:r,blockIndex:i,offset:s}=e.getTextPosition();if(!bu.isDocumentTitleBlock(r,i)||!Or(t,"Enter"))return!1;let l=!1,a=null;Eo(e.rootContainer)===2&&(a=_r(e.rootContainer,1),ue(e,a)===0&&(l=!0));const d=e.getFirstBlock();return e.undoManager.runInGroup(()=>{e.breakTextBlock(d,s,{forceInsertAfter:!0}),l&&a&&e.deleteBlock(a)}),!0}handleChanged(e){var t,o;try{const r=e.doc.getContainerBlocks(ae(e.rootContainer));g(l7,r.length>0,"root container is empty");const i=r[0];if(i.type!=="text"){const s=sr("",{heading:(t=this.options.headingLevel)!=null?t:1});e.insertBlock(ae(e.rootContainer),0,s,e.selection.range.toDocRange());return}if(g(l7,i.text,"invalid text block"),MP(i.text)||i.quoted||i.heading!==this.options.headingLevel){const s=e.getBlockById(i.id),l=e.getBlockString(s),a=sr(l,{heading:(o=this.options.headingLevel)!=null?o:1,quoted:!1}),d=e.selection.focusedBlock;let h=e.selection.range;const p=e.insertBlock(ae(e.rootContainer),0,a);d===s&&(h=yt(e,a.id,ue(e,p))),wh(e,s,h)}if(r.length>1)return;e.insertTextBlock("",ae(e.rootContainer),1,{newRange:e.selection.range.toDocRange()})}finally{this.applyPlaceholder(e)}}handleRemoteChanged(e){setTimeout(()=>{this.applyPlaceholder(e)})}handleUpdateCompositionText(e){this.applyPlaceholder(e)}applyPlaceholder(e){var t,o;!((t=this.options)!=null&&t.titlePlaceholder)&&!((o=this.options)!=null&&o.contentPlaceholder)||LP(e,this.options)}static isDocumentTitleBlock(e,t){return e==="root"&&t===0}}const c7=S("code-dom");function Ji(n){return De(n)==="code"}function a7(n,e,t){t.language?e.setAttribute("data-language",t.language):e.removeAttribute("data-language"),t.nowrap?te(e,"wrap"):W(e,"wrap")}function _0(n){const e=n.closest("div[data-type=editor-block][data-block-type=code]");return g(c7,e,"no parent code block"),g(c7,Ji(e),"not a code block"),e}const vu={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 u7(n){const e=n.toLocaleLowerCase();let t="";return Object.entries(vu).forEach(([o,r])=>{(o===e||r.aliases.includes(e)||r.name.toLocaleLowerCase()===e)&&(t=o)}),t}function d7(n){const e=n.settingsProvider.getItem("editor-code-lang");return e!=null?e:"plain"}function RP(n,e){return n.settingsProvider.setItem("editor-code-lang",e)}const OP=S("convert-to-code");function _P(n,e){if(!ee(n,e))return null;const t={id:K(),type:"text",text:[]},o=K();n.doc.localInsertChildContainer(o,[t]);const r=n.getBlockData(e).text;g(OP,r,"no text");let i=rt(r);i.startsWith("```")&&(i=i.substring(3));const s=u7(i)||d7(n)||"plain";return{blockData:{id:K(),type:"code",language:s,children:[o]},focusBlockId:t.id}}const Ene="",F0=S("code-block-child-container");function bc(n){g(F0,Ji(n),"not a code block");const t=Re(n).querySelector(":scope > div.editor-code-root > div.code-text-root [data-type=editor-container].child");return g(F0,t,"no code text container"),t}function vc(n){g(F0,Ji(n),"not a code block");const t=Re(n).querySelector(":scope > div.editor-code-root > div.code-caption-root [data-type=editor-container].child");return t||null}function Df(n){const e=[bc(n)],t=vc(n);return t&&e.push(t),e}function yc(n,e){if(!ee(n,e))return!1;const t=ne(e),o=oe(t);return o?Ji(o)?t===bc(o):De(e)==="code":!1}const P0=S("code-caption");function FP(n,e){if(n.readonly)return;const t=vc(e);if(t){const a=St(t);n.selection.selectBlock(a,0);return}const o=zr(n.doc),r=n.getBlockData(e);g(P0,r.children.length===1,"code block should have only one child");const i={...r,children:[r.children[0],o]};n.updateBlockData(e,i);const s=n.getContainerById(o),l=St(s);n.selection.selectBlock(l,0)}function h7(n,e){const t=ne(e);if(Xe(t))return!1;const o=oe(t);if(g(P0,o,"no parent block"),!Ji(o))return!1;const i=vc(o);return t===i}function PP(n,e){if(n.readonly||!vc(e))return;const o=bc(e),r=Gt(o);n.selection.selectBlock(r,ue(n,r));const i=n.getBlockData(e);g(P0,i.children.length===2,"code block should have only one child");const s=i.children[1],l={...i,children:[i.children[0]]};n.updateBlockData(e,l),n.deleteChildContainers([s])}const NP=S("paste-in-table-block");class $P{constructor(e){this.editor=e,setTimeout(()=>{e.input.addHandler(this)})}destroy(){}async handleBeforePaste(e,t,o){if(!e.selection.range.isSimple())return!1;const r=e.selection.range.start,i=e.getBlockById(r.blockId),s=ne(i);if(Xe(s))return!1;const l=oe(s);if(g(NP,l,"no parent block"),!Ji(l)||h7(e,i))return!1;const a=o["text/x-ones-editor-doc"];let d=null;if(a){const p=La(e,a);d=Ur(p)}else d=o["text/plain"];if(!d)return!0;const h=d;return e.undoManager.runInGroup(()=>{e.clearSelectedContents(),e.insertDoc(i,r.offset,h)}),!0}}function HP(n){n.addCustom("code-block-paste-event",e=>new $P(e))}class jP{constructor(e){m(this,"id","CodeBlockCommandProvider");setTimeout(()=>{e.editorCommandProviders.registerCommandProvider(this)})}destroy(){}getAvailableCommands(){return[]}executeCommand(){return!1}filterCommands(e,t,o,r){if(yc(e,t))return[]}beforeExecuteCommand(e,t,o,r,i){return!!yc(e,t)}}function UP(n){n.addCustom("code-block-command-provider",e=>new jP(e))}const zP=S("code-caption-input-handler");function N0(n){if(!n.selection.range.isSimple())return null;const e=n.selection.range.start;if(!e.isSimple())return null;const t=n.getBlockById(e.blockId);return h7(n,t)?t:null}function VP(n){const e=N0(n);if(!e)return!1;const t=_0(e),o=Ze(t);return o?(n.selection.selectBlock(o,0),!0):(n.insertTextBlock("",ae(ne(t)),be(t)+1),!0)}function WP(n){const e=N0(n);if(!e)return!1;if(ht(n,e)){const t=_0(e);return PP(n,t),!0}return!1}class $0{constructor(e){setTimeout(()=>{e.input.addHandler(this)})}destroy(){}handleBeforeKeyDown(e,t){return t.key==="Enter"?VP(e):t.key==="Backspace"?WP(e):!1}async handleBeforePaste(e,t,o){const r=N0(e);if(!r)return!1;const i=o["text/plain"];if(!i)return!0;const s=La(e,i);return s&&e.undoManager.runInGroup(()=>{e.clearSelectedContents();const l=e.selection.range.start;g(zP,l.isSimple(),"not simple position"),e.insertTextToBlock(r,l.offset,s)}),!0}static init(e){e.addCustom("code-block-caption-input-handler",t=>new $0(t))}}function qP(n){const o=new DOMParser().parseFromString(n,"text/html").querySelector("svg");if(!o)return null;const r=o.getAttribute("viewBox");if(!r)return null;const i=r.split(" ");if(i.length===4){const s=i[2],l=i[3];return o.setAttribute("width",s),o.setAttribute("height",l),o.outerHTML}return null}function H0(n,e,t=!0){const o=new Image,r=document.createElement("canvas"),i=r.getContext("2d");if(!i){e(new Error("failed to get context"),null);return}o.onload=()=>{if(r.width=o.naturalWidth,r.height=o.naturalHeight,t&&(r.width===0||r.height===0)){const s=n.substring(26);if(s){const l=atob(s),a=qP(l);if(a){Sm(a,"image/svg+xml").then(d=>{H0(d,e,!1)});return}}e(null,null);return}i.drawImage(o,0,0),r.toBlob(s=>{e(null,s)},"image/png")},o.src=n}function GP(n){return new Promise((e,t)=>{H0(n,(o,r)=>{if(o){t(o);return}if(!r){t(new Error("Failed to get image blob"));return}e(r)})})}async function f7(n){const e=await Ul(n);return new Promise((t,o)=>{H0(e,(r,i)=>{if(r){o(r);return}if(!i){o(new Error("Failed to get image blob"));return}t(i)})})}const m7="Untitled";function g7(n){const e=St(n.rootContainer);return!e||!ee(n,e)?m7:n.getBlockString(e)||m7}function j0(){return Object.prototype.hasOwnProperty.bind(window,"isSecureContext")?window.isSecureContext:window.location.protocol==="https:"||window.location.hostname==="localhost"||window.location.hostname==="127.0.0.1"}function ZP(n){let e;return n.forEach((t,o)=>{o.toLocaleLowerCase()==="content-type"&&(e=t)}),e!=null?e:""}async function p7(n){try{const e=await fetch(n,{credentials:"same-origin"}),t=await e.blob(),o=ZP(e.headers).toLocaleLowerCase();let r="";if(o){const s=mm.default[o].extensions;s&&s.length>0&&(r=s[0])}return new File([t],`${Date.now()}.${r}`,{type:o})}catch{return null}}const QP=`
401
401
  <svg fill="currentColor" focusable="false" viewBox="0 0 24 24" aria-hidden="true" tabindex="-1">
402
402
  <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>
403
403
  </svg>`,YP=`
@@ -415,9 +415,9 @@ ${s}
415
415
  \`\`\`
416
416
  ${l}`:`<p><pre><code>${s}</code></pre></p>
417
417
  <p>${l}</p>`}const Sf={blockType:"code",blockKind:"complex",createBlockContent:aN,getBlockTextLength:uN,getRangeFromPoint:dN,moveCaret:hN,getCaretRect:fN,updateSelection:mN,clearSelection:gN,getChildContainers:pN,getNextContainer:CN,getSelectedContainers:AN,convertFrom:_P,handleBlockElementUpdated:bN,getOptions:yN,getBlockProperties:kN,convertTo:wN},U0={...In,blockType:"code-line"};class BN{constructor(e){m(this,"handleSelectionChange",()=>{const e=this.editor.selection;if(!e.range.isCollapsed())return;const t=e.focusedBlock;if(!yc(this.editor,t))return;const o=t,r=e.range.focus.offset,i=M4(this.editor,o,r,"code-caret");i.scrollIntoView({block:"nearest"}),setTimeout(()=>{i.remove(),this.editor.selection.caret.update()})});this.editor=e,e.addListener("selectionChanged",this.handleSelectionChange)}destroy(){this.editor.removeListener("selectionChanged",this.handleSelectionChange)}}function b7(n,e){const t=n.split(`
418
- `).map(s=>({id:K(),type:"text",text:Oi(s)})),o=K();return{blocks:{root:[{children:[o],type:"code",id:K(),...e}],[o]:t},meta:{},comments:{}}}class EN{handleBeforeCopy(e,t,o){const r=e.getFocusedBlock();if(!yc(e,r))return;const i=_0(r),s=e.getBlockData(i),{language:l,nowrap:a}=s;if(e.selection.range.isCollapsed()){const h=e.getBlockString(r);return b7(h,{language:l,nowrap:a})}const d=e.getSelectedText();return b7(d,{language:l,nowrap:a})}}function xN(n){if(!n.isWritable())return!1;const e=n.getFocusedBlock();if(!!yc(n,e)){if(n.selection.range.isCollapsed()){const t=n.selection.range.start;return n.insertTextToBlock(e,t.offset," "),!0}return n.undoManager.runInGroup(()=>{Lo(n).forEach(o=>{n.insertTextToBlock(o.block,0," ")})}),!0}}function IN(n){if(!n.isWritable())return!1;const e=n.getFocusedBlock();if(!yc(n,e))return;const t=[" "," "];return n.undoManager.runInGroup(()=>{Lo(n).forEach(r=>{const i=rt(n.getBlockText(r.block));for(let s=0;s<t.length;s++){const l=t[s];if(i.startsWith(l)){n.deleteTextFromBlock(r.block,0,l.length);break}}})}),!0}function TN(n){const e=n.getFocusedBlock(),t=ne(e);if(Xe(t))return;const o=oe(t);if(!o||De(o)!=="code")return;const r=n.selection.range;if(!!r.isSimple()&&!MA(t,r))return Yg(n,t),!0}const DN={Tab:xN,"Shift+Tab":IN,"CtrlOrCmd+A":TN},yu=S("code-text-decorate");class Lf{decorateText(e,t,o){var v;if(g(yu,t.length>0,"invalid path"),t.length===1)return{};const r=t[t.length-2];if(e.doc.getBlockData(r.containerId,r.blockIndex).type!=="code")return{};const s=o;if(s.length===0)return{};const l=rt(s),a=e.doc.getBlockData(r.containerId,r.blockIndex),d=da.default.tokenize(l,(v=da.default.languages[a.language])!=null?v:da.default.languages.plain),h=(B,D)=>{if(g(yu,B,"no token"),typeof B=="string")return[{insert:B,attributes:me.default(D)}];g(yu,B instanceof da.default.Token,"invalid token type");const I=B.content,_=me.default(D);return _[`style-code-${B.type}`]=!0,typeof I=="string"?[{insert:I,attributes:_}]:Array.isArray(I)?I.map(z=>h(z,_)).flat():(g(yu,I instanceof da.default.Token,"invalid token"),h(I,_))},A=d.map(B=>h(B,{})).flat();return g(yu,rn(A)===rn(s),"failed to highlight code, text length mismatch"),{text:A}}}const SN={code:{title:"\u4EE3\u7801",abstract:"\u4EE3\u7801",wrap:"\u6362\u884C",copy:"\u590D\u5236",caption:"\u8BF4\u660E",search:"\u8F93\u5165\u5173\u952E\u8BCD\u641C\u7D22",copySuccess:"\u590D\u5236\u6210\u529F"}},LN={code:{title:"Code",abstract:"Code",wrap:"Wrap",copy:"Copy",caption:"Caption",search:"Search",copySuccess:"Copied successfully"}},MN={code:{title:"\u30B3\u30FC\u30C9",abstract:"\u30B3\u30FC\u30C9",wrap:"\u6298\u308A\u8FD4\u3059",copy:"\u30B3\u30D4\u30FC",caption:"\u4F8B\u8A3C\u3059\u308B",search:"\u30AD\u30FC\u30EF\u30FC\u30C9\u3067\u691C\u7D22",copySuccess:"\u30B3\u30D4\u30FC\u3055\u308C\u307E\u3057\u305F"}};R.mergeLang({"zh-CN":SN,"en-US":LN,"ja-JP":MN});const RN=S("image-data"),v7=1e3,z0=400,ON=10;function kc(n){return n.src.startsWith("empty:")||!n.src}function _N(n){return n.src.startsWith("http:")||n.src.startsWith("https:")}function y7(n){return`${Pd.default(n)}_width`}function k7(n){return`${Pd.default(n)}_height`}function w7(n){return`${n}_flex`}function B7(n){let e=n.getBoundingClientRect().width;return e-=Number.parseFloat(window.getComputedStyle(n).paddingLeft)+Number.parseFloat(window.getComputedStyle(n).paddingRight),e}function ku(n){if(n.every(r=>typeof r.flex=="number"&&r.flex))return;const e=100,o=n.map(r=>{const i=r.height==="auto"?r.width/e:r.height/e;return r.width/i}).reduce((r,i)=>r+i,0);n.forEach(r=>{const i=r.height==="auto"?r.width/e:r.height/e,s=r.width/i;r.flex=s/o})}function wc(n){const e=(r,i)=>{r||(r=`empty:${i}`);const s=y7(r),l=k7(r),a=w7(i);let d=n[s],h=n[l],p=n[a];return typeof d=="string"&&(d=Number.parseInt(d,10)),typeof h=="string"&&(h=Number.parseInt(h,10)),typeof p=="string"&&(p=Number.parseInt(p,10)),d&&h?{src:r,width:d,height:h,flex:p,virtualSize:!1}:d&&!h?{src:r,width:d,height:"auto",flex:p,virtualSize:!1}:(d=v7,h=z0,{src:r,width:d,height:h,flex:p,virtualSize:!0})};let t=[];const o=n.src;return Array.isArray(o)?t=o.map(e):typeof o=="string"&&(t=o.split("|").map(e)),ku(t),t}function Uo(n){const e=n.embedData;return wc(n.embedData).length>1?100:e.widthPercent}function FN(n,e,t,o){const r=wc(e.embedData);if(r.length>1||o)return"100%";const i=Uo(e),s=n.rootContainer.getBoundingClientRect().width;if(i){const l=B7(t);return`${Math.min(s*i/100,l)}px`}return r[0].width?`${r[0].width}px`:"auto"}function cn(n,e){const o={src:n.map(r=>r.src).join("|"),widthPercent:e};return n.forEach((r,i)=>{if(r.width&&r.height&&!r.virtualSize){const l=r.src||`empty:${i}`,a=y7(l);o[a]=r.width;const d=k7(l);r.height!=="auto"&&(o[d]=r.height)}g(RN,r.flex,"no image flex");const s=w7(i);o[s]=r.flex}),o}function PN(n,e,t,o){const r=wc(e.embedData),i=r.length===1?n.rootContainer:t;if(r.length===1&&o)return`${z0}px`;if(r.some(h=>h.height==="auto"))return"auto";const s=Uo(e);if(!s)return"";let l=i.getBoundingClientRect().width*(s/100);if(l-=Number.parseFloat(window.getComputedStyle(i).paddingLeft)+Number.parseFloat(window.getComputedStyle(i).paddingRight),i===n.rootContainer&&i!==t&&(l=Math.min(l,B7(t))),r.length===1){const h=r[0];return h.virtualSize?"":`${h.height/(h.width/l)}px`}l-=(r.length-1)*ON;const a=r.reduce((h,p)=>h+p.flex,0);let d=0;for(const h of r){const A=l*h.flex/a/h.width*h.height;d=Math.max(A,d)}return`${d}px`}function NN(n){return n.reduce((t,o)=>t+o.flex,0)}function $N(n,e){w("div",["resize-gripper",e],n).setAttribute("data-resize-type",e)}function V0(n){return lt(n).querySelector(".block-resizer")}function HN(n){const e=V0(n);e&&te(e,"active")}function E7(n,e,t){const o=n.getBoundingClientRect(),r=e.getBoundingClientRect(),i=r.top-o.top,s=r.left-o.left,l=r.width,a=r.height;t.style.top=`${i}px`,t.style.left=`${s}px`,t.style.width=`${l}px`,t.style.height=`${a}px`}function jN(n,e,t,o){const r=V0(n);if(r)return W(r,"active"),E7(n,e,r),r;const i=lt(n),s=w("div",["block-resizer"],i);return E7(n,e,s),t.resize.forEach(l=>{$N(s,l)}),s.addEventListener("mousedown",o),W(s,"active"),s}function W0(n,e){const t=V0(n);if(!t||!Ke(n,e))return;const o=n.getBoundingClientRect(),r=e.getBoundingClientRect(),i=r.top-o.top,s=r.left-o.left,l=r.width,a=r.height;t.style.top=`${i}px`,t.style.left=`${s}px`,t.style.width=`${l}px`,t.style.height=`${a}px`}const xne="",UN=S("block-resizer");class wu extends bt.TypedEmitter{constructor(t,o){super();m(this,"resizableElement");m(this,"block",null);m(this,"startRect",null);m(this,"startPos",null);m(this,"resizeType",null);m(this,"enabled",!1);m(this,"handleMouseDown",t=>{t.preventDefault(),t.stopPropagation();const o=this.getResizableElement();if(!o||t.button!==0)return;const r=t.target;if(!r||!(r instanceof HTMLElement))return;const i=r.getAttribute("data-resize-type");!i||(this.bindEvents(),this.startRect=o.getBoundingClientRect(),this.startPos=t,this.resizeType=i,pa(window.getComputedStyle(r).cursor),this.block&&this.editor.selection.selectBlock(this.block,0))});m(this,"handleMouseMove",t=>{if(!this.startPos||!this.startRect||!this.resizeType||!this.getResizableElement()||!this.block)return;const r=t.x-this.startPos.x,i=t.y-this.startPos.y,s=this.startRect;let{top:l,left:a,right:d,bottom:h}=s;(this.resizeType==="bottom"||this.resizeType==="bottom-left"||this.resizeType==="bottom-right")&&(h+=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")&&(a+=r),(this.resizeType==="right"||this.resizeType==="top-right"||this.resizeType==="bottom-right")&&(d+=r);const p=d>a?d-a:0,A=h>l?h-l:0,v=new DOMRect(a,l,p,A);this.emit("resizing",this,v);const B=this.getResizableElement();B&&W0(this.block,B)});m(this,"handleMouseUp",t=>{if(t.button!==0)return;pa(""),this.unbindEvents(),this.emit("resized",this);const o=this.getResizableElement();!o||!this.block||W0(this.block,o)});this.editor=t,this.options=o}enableResize(t,o){this.block=t,this.resizableElement=o,this.createResizer(),this.enabled=!0}disableResize(){!this.block||(HN(this.block),this.enabled=!1)}update(t,o){this.block=t,this.resizableElement=o,this.getResizableElement()&&this.enabled&&this.createResizer()}updateResizer(){const t=this.getResizableElement();t&&this.block&&W0(this.block,t)}getBlock(){return this.block}destroy(){}getResizableElement(){return this.resizableElement?this.resizableElement:this.block?Re(this.block):null}createResizer(){const t=this.getResizableElement();!t||!this.block||(g(UN,Ke(this.block,t),"not a block child element"),jN(this.block,t,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)}}const zN=S("image-dom");function x7(n){return n.querySelector(".uploading-progress-mask")}function VN(n){const e=x7(n);if(e)return e;const t=w("div",["uploading-progress-mask"],n),o=w("div",["uploading-progress-bar"],t);return w("div",["uploading-progress-bar-value"],o),o}function WN(n){const t=VN(n).querySelector(".uploading-progress-bar-value");return g(zN,t,"no progress value"),t}function I7(n,e){const t=WN(n);t.style.width=`${e}%`}function qN(n){var e;(e=x7(n))==null||e.remove()}function Bu(n,e,t,o){const r=t!=null?t:n.findBlockById(e.id);if(!r)return;const i=o||ne(r),s=!!r.querySelector(".images > .image-container.error, .images > .image-container.empty "),l=FN(n,e,i,s),a=PN(n,e,i,s),d=Re(r);l==="auto"?d.style.width=l:(d.style.maxWidth=l,d.style.width="100%");const h=r.querySelector(".images");!h||(h.style.height=a||"none")}function GN(n){let e;return n.forEach((t,o)=>{o.toLocaleLowerCase()==="content-type"&&(e=t)}),e!=null?e:""}async function ZN(n){try{const e=await fetch(n,{credentials:"same-origin"}),t=await e.blob(),o=GN(e.headers).toLocaleLowerCase();let r="";if(o){const s=mm.default[o].extensions;s&&s.length>0&&(r=s[0])}return new File([t],`${Date.now()}.${r}`,{type:o})}catch{return null}}function Ki(n,e){const t=typeof e=="string"?e:ie(e);return n.getCustom(`image-${t}`)}function Mf(n,e){if(!e||!(e instanceof Node))return null;const t=oe(e);return t?Ki(n,t):null}function pr(n){return Array.from(n.querySelectorAll(".image-container"))}const q0=S("table-resize-drag-drop");class QN{constructor(e,t,o,r){m(this,"cursor","col-resize");m(this,"initWidths");this.editor=e,this.elem=t,this.data=o,this.mouseDownEvent=r;const i=this.data.block,l=Ki(this.editor,i).getImages(),a=this.data.splitterIndex;g(q0,a>=0&&a<l.length-1,`invalid splitter index: ${a}`);const h=pr(i).map(p=>p.getBoundingClientRect().width);this.initWidths=h}onDragStart(e,t,o){if(!this.editor.isWritable())return;const r=this.data.block;Ki(this.editor,r).setResizing(!0)}onDragging(e,t,o,r,i){const s=this.data.block,l=Ki(this.editor,s),a=me.default(l.getImages()),d=this.data.splitterIndex;g(q0,d>=0&&d<a.length-1,`invalid splitter index: ${d}`);const h=this.initWidths[d],p=this.initWidths[d+1];if(h+p<100)return;let A=r;h+A<50&&(A=50-h),p-A<50&&(A=p-50);const D=[...this.initWidths];D[d]+=A,D[d+1]-=A;const I=pr(s);g(q0,I.length===a.length,"invalid image data");const _=D.reduce((z,q)=>z+q,0);for(let z=0;z<a.length;z++){const q=D[z]/_;a[z].flex=q,I[z].style.flexGrow=`${q}`}const M=me.default(this.editor.getBlockData(s)),H=cn(a,Uo(M));M.embedData=H,Bu(this.editor,M,s,null)}onDragEnd(e,t,o,r,i){const s=this.data.block,l=Ki(this.editor,s),d=pr(s).map(h=>Number.parseFloat(h.style.flexGrow));l.updateFlex(d),l.setResizing(!1)}}function T7(n){var e;return!n||!(n instanceof HTMLElement)?null:xe(n,"image-splitter")?n:(e=n.closest(".image-splitter"))!=null?e:null}function YN(n,e){var s;const t=T7(e.target);if(!t)return;const o=oe(t);if(!o)return;Ki(n,o).setSelectedIndex(-1),n.selection.selectBlock(o,0);const r=Number.parseInt((s=t.getAttribute("data-index"))!=null?s:"",10);if(Number.isNaN(r)||typeof r!="number")return;const i={block:o,splitterIndex:r};wm(new QN(n,t,i,e))}function JN(n,e){e.preventDefault(),e.stopPropagation();const t=T7(e.target);if(!t)return;const o=oe(t);!o||Ki(n,o).resetFlex()}function KN(n,e,t,o){const r=w("div",["image-splitter"],t);w("div",["image-splitter-indicator"],r),r.setAttribute("data-index",`${o}`),n.domEvents.addEventListener(r,"mousedown",YN),n.domEvents.addEventListener(r,"dblclick",JN)}const XN=S("image-item");function D7(n){return!n||!(n instanceof Node)?null:oe(n)}function S7(n){const e=D7(n);return e?pr(e):[]}function G0(n){if(!n||!(n instanceof Node))return null;const e=n instanceof Element?n:n.parentElement;if(!e)return null;const t=e.closest(".image-container");return t||null}function Eu(n){const e=G0(n);return e?S7(n).indexOf(e):-1}async function e$(n,e){const t=Mf(n,e.target);if(!t)return;const o=Eu(e.target);if(o===-1)return;const r=e.target;if(!(r instanceof HTMLImageElement))return;const i=t.getImages()[o];if(kc(i)||n.readonly||!t.isAutoFix()||(setTimeout(()=>{t.setAutoFix(!1)},400),i.height==="auto"&&t.fixImageSize(o,r),i.virtualSize&&t.fixImageSize(o,r),!i||!_N(i)||i.downloading))return;i.downloading=!0;const s=await ZN(i.src);s?t.replaceImage(o,s):XN.warn(`failed to download image: ${i.src}`)}function t$(n,e,t){if(e.querySelector(".load-error"))return;const r=t.src.startsWith("http:")||t.src.startsWith("https:"),i=w("div",["load-error"],e),s=w("div",["error-icon"],i);s.innerHTML=av;const l=w("div",["error-message"],i);r?(l.innerHTML=R.t("image.load.remote.failed"),n.domEvents.addEventListener(i,"click",(a,d)=>{d.preventDefault(),d.target instanceof HTMLElement&&d.target.tagName==="A"&&window.open(t.src,"_blank")})):(l.innerHTML=R.t("image.load.failed"),n.domEvents.addEventListener(i,"click",(a,d)=>{d.preventDefault(),d.stopPropagation(),d.target instanceof HTMLElement&&d.target.tagName==="A"&&i$(a,d.target)}))}function Z0(n,e){setTimeout(()=>{if(Ke(n.rootContainer,e)){const t=n.getBlockData(e);Bu(n,t,null,null)}})}function n$(n,e){const t=Mf(n,e.target);if(!t)return;const o=Eu(e.target);if(o===-1)return;const r=t.getImages()[o];if(!r)return;const i=G0(e.target);if(!i)return;W(i,"error","error-load");const s=oe(i);s&&Z0(n,s),i.innerHTML="",t$(n,i,r)}function o$(n,e,t){if(e.querySelector(".upload-error"))return;const r=w("div",["upload-error"],e),i=w("div",["error-icon"],r);i.innerHTML=av;const s=w("div",["error-message"],r);s.innerHTML=R.t("image.upload.failed"),n.domEvents.addEventListener(r,"click",(l,a)=>{if(a.preventDefault(),!a.target||!(a.target instanceof Element)||a.target.tagName!=="A")return;const d=Mf(l,a.target),h=Eu(a.target);!d||h===-1||d.replaceImage(h,t)})}function L7(n,e,t,o,r){const i=pr(e)[t];!i||(W(i,"error","error-upload"),Z0(n,e),i.innerHTML="",o$(n,i,r))}function M7(n,e,t,o,r,i,s){const l=w("div",["image-container"],t);if(l.setAttribute("data-src",o.src),s.length>1&&(l.style.flexShrink=`${o.flex}`,l.style.flexGrow=`${o.flex}`),i===r&&W(l,"active"),kc(o)){W(l,"empty");const d=w("div",["upload-image-icon"],l);return d.innerHTML=TL,l}const a=w("img",["editor-image"],l);if(a.src=n.doc.buildResourceUrl(o.src),n.domEvents.addEventListener(a,"load",e$),n.domEvents.addEventListener(a,"error",n$),o.src.startsWith("https:")||o.src.startsWith("http:")){const d=w("div",["image-warning"],l);d.innerHTML=cv,d.setAttribute(`data-editor-tooltip-${n.clientId}`,R.t("image.load.remote.tooltip"))}return l}function r$(n,e,t,o,r){const i=w("div",["images"],t);return o.forEach((s,l)=>{l>0&&KN(n,e,i,l-1),M7(n,e,i,s,l,r,o)}),o.length>1&&W(e,"multi"),i}function R7(n,e,t,o,r,i){const l=Array.from(e.querySelectorAll(".image-container"))[o];if(!l)return;const a=M7(n,e,null,t,o,r,i);l.insertAdjacentElement("beforebegin",a),l.remove(),Z0(n,e)}function xu(n,e){return pr(n)[e]}function i$(n,e){const t=D7(e);if(!t)return;const o=Eu(e);if(o===-1)return;const r=Mf(n,e);if(!r)return;const i=r.getImages()[o];R7(n,t,i,o,r.getSelectedIndex(),r.getImages())}function zo(n){return De(n)==="embed"&&Un(n)==="image"}async function O7(n){return new Promise((e,t)=>{const o=new Image;o.onload=()=>{e({width:o.naturalWidth,height:o.naturalHeight})},o.onerror=t,o.src=n})}async function s$(n){const e=await Ul(n);return O7(e)}function _7(n){var o;let e="image/*";const t=(o=n.getComponentOptions("image"))==null?void 0:o.allowedMedias;return t&&(e=t.map(r=>`.${r}`).join(",")),e}function F7(n,e){var s;const{maxSize:t,allowedMedias:o,callbacks:r}=(s=n.getComponentOptions("image"))!=null?s:{};if(t&&e.size>t){const l=new Error("image is too large");throw l.code="MaxMediaSize",r!=null&&r.onError&&(r==null||r.onError(n,l)),l}const i=Aa(e.name);if(o&&!o.includes(i)){const l=new Error(`media file is not allowed: ${i}`);throw l.code="NotAllowedFile",r!=null&&r.onError&&(r==null||r.onError(n,l)),l}}function P7(n){return n.startsWith("image/")}const N7=S("image-object");class wt{constructor(e,t){m(this,"images",[]);m(this,"selectedIndex",-1);m(this,"blockResizer");m(this,"resizing",!1);m(this,"parentContainerResizerObserver",null);m(this,"autoFix",!1);m(this,"handleMouseDown",async(e,t)=>{const o=Eu(t.target);if(o===-1)return;const r=this.images[o];kc(r)||this.setSelectedIndex(o)});m(this,"handleRootContainerResize",()=>{this.handleEditorResize(this.editor.rootContainer)});m(this,"handleEditorResize",e=>{if(this.isEmpty()||this.resizing)return;const t=this.editor.findBlockById(this.blockData.id);!t||ne(t)===e&&Bu(this.editor,this.blockData,t,null)});m(this,"handleResizing",(e,t)=>{const o=this.editor.findBlockById(this.blockData.id);if(!o)return;this.autoFix||this.setAutoFix(!0);const i=this.editor.rootContainer.getBoundingClientRect().width,s=o.getBoundingClientRect();let l=t.width>s.width?s.width:t.width;l<50&&(l=50);const a=l*100/i;this.blockData.embedData.widthPercent=a,Bu(this.editor,this.blockData,o,null)});m(this,"handleResized",e=>{const t=this.editor.findBlockById(this.blockData.id);if(!t)return;const o=cn(this.images,Uo(this.blockData));this.editor.updateEmbedData(t,o),this.blockResizer.enableResize(t)});m(this,"fixImageSizes",Ht.default(()=>{const e=this.editor.findBlockById(this.blockData.id);if(!e)return;const t=cn(this.images,Uo(this.blockData));this.editor.updateEmbedData(e,t)},1e3));this.editor=e,this.blockData=t,this.blockResizer=new wu(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=wc(this.blockData.embedData)}destroy(){var e;this.blockResizer.removeAllListeners(),this.blockResizer.destroy(),this.editor.domEvents.removeEventListener(null,null,this.handleMouseDown),(e=this.parentContainerResizerObserver)==null||e.disconnect()}setAutoFix(e){this.autoFix=e}isAutoFix(){return this.autoFix}createContent(e,t,o){const r=r$(this.editor,t,o,this.images,this.selectedIndex);if(this.editor.domEvents.addEventListener(o,"mousedown",this.handleMouseDown),this.editor.addListener("resize",this.handleRootContainerResize),Do(e)){const s=()=>{this.handleEditorResize(e)};this.parentContainerResizerObserver=new ResizeObserver(s),this.parentContainerResizerObserver.observe(e)}const i=()=>!!(this.images.length===1&&this.images[0].virtualSize);this.isEmpty()&&i()&&W(r,"empty"),Bu(this.editor,this.blockData,t,e),setTimeout(()=>{const s=this.editor.findBlockById(this.blockData.id);s&&this.blockResizer.update(s)})}getImages(){return this.images}getWidthPercent(){return Uo(this.blockData)}isEmpty(){return this.images.length===1&&kc(this.images[0])}setResizing(e){this.resizing=e}getSelectedIndex(){return this.selectedIndex}getBlock(){return this.editor.findBlockById(this.blockData.id)}setSelectedIndex(e){const t=this.getBlock();if(!t||e===this.selectedIndex)return;if(this.selectedIndex!==-1){const r=xu(t,this.selectedIndex);r&&te(r,"active")}this.selectedIndex=e;const o=xu(t,e);o&&W(o,"active")}async requestUploadImage(e){const t=this.editor.findBlockById(this.blockData.id);if(!t)return;const o=xu(t,e);if(xe(o,"error"))return;const r=_7(this.editor),i=await zl(r);await this.replaceImage(e,i)}tryEnableResizer(){const e=this.editor.findBlockById(this.blockData.id);if(!e||!this.editor.isWritable())return;const t=xu(e,0);!this.isEmpty()&&this.images.length===1&&!xe(t,"error")&&this.blockResizer.enableResize(e)}disableResizer(){this.blockResizer.disableResize()}fixImageSize(e,t){const o=this.images[e];kc(o)||(o.height==="auto"&&(o.height=t.height),o.width=t.naturalWidth,o.height=t.naturalHeight,o.virtualSize=!1,this.fixImageSizes())}removeImage(e){const t=this.editor.findBlockById(this.blockData.id);if(!t||e===-1||e>=this.images.length)return!1;const o=me.default(this.images);if(o.splice(e,1),o.length===0)return this.editor.deleteBlock(t),!0;o[0].flex=NaN,ku(o),this.selectedIndex>=o.length&&(this.selectedIndex=o.length-1);const r=cn(o,Uo(this.blockData));return this.editor.updateEmbedData(t,r),!0}async replaceImage(e,t){const o=this.editor.findBlockById(this.blockData.id);if(!o)return!1;try{const i=await Ul(t),s=this.images[e];if(s.virtualSize){const{width:a,height:d}=await O7(i);s.width=a,s.height=d,s.virtualSize=!1;const h=cn(this.images,Uo(this.blockData));this.editor.updateEmbedData(o,h)}const l={...s,src:i};R7(this.editor,o,l,e,this.selectedIndex,this.images),setTimeout(()=>{this.blockResizer.update(o)})}catch(i){return L7(this.editor,o,e,i,t),!1}const r=xu(o,e);if(!r)return!1;W(r,"uploading"),I7(r,0),W(o,"media-block-uploading");try{const i=await this.editor.doc.uploadResource(t,{onProgress:a=>{I7(r,a)}});te(r,"uploading"),this.images[e].src=i.resourceId;const s=this.editor.findBlockById(this.blockData.id);if(!s)return!1;te(s,"media-block-uploading");const l=cn(this.images,Uo(this.blockData));return this.editor.updateEmbedData(s,l),!0}catch(i){N7.error(i);const s=this.editor.findBlockById(this.blockData.id);return s&&(te(r,"uploading"),qN(r),L7(this.editor,s,e,i,t),te(s,"media-block-uploading")),!1}}updateFlex(e){const t=this.editor.findBlockById(this.blockData.id);if(!t)return;g(N7,e.length===this.images.length,"invalid flex");for(let r=0;r<this.images.length;r++)this.images[r].flex=e[r];const o=cn(this.images,Uo(this.blockData));this.editor.updateEmbedData(t,o)}resetFlex(){const e=this.editor.findBlockById(this.blockData.id);if(!e)return;const t=me.default(this.images);t[0].flex=NaN,ku(t);const o=cn(t,Uo(this.blockData));this.editor.updateEmbedData(e,o)}setData(e){this.blockData=e,this.images=wc(e.embedData)}static create(e,t){const o=e.addCustom(`image-${t.id}`,()=>new wt(e,t));return o.setData(t),o}static getImageObject(e,t){let o;return typeof t=="string"?o=t:o=ie(t),e.getCustom(`image-${o}`)}}const Ine="",Tne="";function Rf(n){const e=lt(n);let t=e.querySelector(":scope > .block-helper");return t||(t=w("div",["block-helper"],e),w("span",["helper-sizer"],t,"A")),t}function Q0(n,e,t){const o=Rf(n),i=Array.from(o.children).find(s=>{var a;return Number.parseInt((a=s.getAttribute("data-index"))!=null?a:"0",10)>t});o.insertBefore(e,i!=null?i:null)}const $7=40,l$=20;class c${findTargetBlock(e,t){const o=t.target;if(o&&o instanceof Element){const a=oe(o);if(a&&Ke(e.rootContainer,a))return a}let r=t.clientX,i=t.clientY;const s=e.rootContainer.getBoundingClientRect().left;r<s&&s-r<$7&&(r+=$7);let l=document.elementFromPoint(r,i);if(l){const a=oe(l);if(a&&Ke(e.rootContainer,a))return a}if(i-=l$,l=document.elementFromPoint(r,i),l){const a=oe(l);if(a&&Ke(e.rootContainer,a))return a}return null}destroy(){}}class a$ extends Af{constructor(t){super(t,{trigger:[],id:"empty-block-menu"});m(this,"currentBlock",null)}get isVisible(){return this.suggest.menu.isVisible}isInMenu(t){return this.menu.isInCommandBar(t)}show(){const o=this.editor.selection.focusedBlock;this.suggest.popup(o,0,"","")}setBlock(t){this.currentBlock=t}}function u$(n,e,t){const o=Wm(n,e);if(!o)return[];const r=[];return Object.values(o).forEach(i=>{t!=null&&t.has(i.group)||r.push(...i.commands.map(s=>({...s,source:"block-command",blockMenuItemCustomData:i.group})))}),r}function Y0(n,e,t={withPlainText:!1}){const o=D0(n,t),r=i=>{i.forEach(s=>{s.source=e,s.children&&r(s.children)})};return r(o),o}function d$(n,e,t,o=!1){var d,h;const r=ne(e);let s=be(e);ht(n,e)||o||(s+=1);const l=ae(r),a=t;return a.commandProvider?a.commandProvider.executeCommand(n,t,{from:"block-menu",containerId:l,blockIndex:s}):(h=(d=a.blockOptions)==null?void 0:d.handleInsertEmptyBlock)==null?void 0:h.call(d,n,{containerId:l,blockIndex:s,item:t})}function h$(n,e){const t=Io(n,e),o=n.getBlockData(e);return!(t!=="text"||o.heading)}class H7{constructor(e,t,o){m(this,"source","text-style");m(this,"id","text-style-item");m(this,"name","Text styles");m(this,"element");m(this,"createHeadingItemElement",(e,t,o)=>{var i;const r=B0();this.createItem("text",nu,t,h$(this.editor,e)),(i=r.insertBlockCommandItems)==null||i.forEach(s=>{s.id&&s.icon&&this.createItem(s.id,s.icon,t,o?o===Number(s.value):!1)})});m(this,"createListItemElement",(e,t,o)=>{const{checkbox:r,ordered:i}=o,l=De(e)==="list",a=l&&i===!1&&!r,d=l&&i,h=l&&!!r;this.createItem("unordered-list",gv,t,a),this.createItem("ordered-list",pv,t,d),this.createItem("check-list",fv,t,h)});m(this,"handleClick",(e,t)=>{var l,a;if(!t.target||!(t.target instanceof Node))return;const o=t.target instanceof Element?t.target:t.target.parentElement;if(!o)return;const r=o.closest(".text-style-item");if(!r)return;const i=r.id,s="heading-";if(i==="text"&&pf(e,this.block,null),i.startsWith(s)){const d=Number.parseInt(i.substring(s.length),10);d&&pf(e,this.block,d)}if(i==="blockquote"&&y0(e,this.block),i.startsWith("align")){const d=i.replace(/^align-/,"");x9(e,this.block,d)}(i==="unordered-list"||i==="ordered-list"||i==="check-list")&&w0(e,this.block,i),(a=(l=this.options).onAfterStyleItemClick)==null||a.call(l)});this.editor=e,this.block=t,this.options=o,this.element=this.createItemElement(e,t),e.domEvents.addEventListener(this.element,"click",this.handleClick)}createItemElement(e,t){const o=w("div",["text-styles"],null),r=w("div",["text-style-section"],o),i=e.getBlockData(t);if(!this.options.fromEmbed){const l=i.heading,a=i.quoted;this.createHeadingItemElement(t,r,l),this.createListItemElement(t,r,i),this.createItem("blockquote",mv,r,!!a)}const s=i.align||"left";return this.createItem("align-left",eu,r,s==="left"),this.createItem("align-center",Lp,r,s==="center"),this.createItem("align-right",Sp,r,s==="right"),o}createItem(e,t,o,r=!1){const i=["style-icon","text-style-item"];r&&i.push("active");const s=Hl(t,i,o);s.id=e}}function j7(){return{source:"separator",type:"separator",id:`section-${K()}`,name:""}}const U7={copy:WL,cut:qL,delete:GL,"lock-block":ZL,"unlock-block":QL,comment:tu},f$=["image","video"];function m$(n,e,t){const o=[],r=ee(n,e),i=Lt(e)&&f$.includes(Un(e));if(r?o.push(new H7(n,e,t)):i&&o.push(new H7(n,e,{...t,fromEmbed:!0})),!ht(n,e)){(r||i)&&o.push(j7());const s=u$(n,e,new Set(["hovering-toolbar"]));s.sort((l,a)=>{var d,h;return((d=l.order)!=null?d:0)-((h=a.order)!=null?h:0)}),s.forEach(l=>{l.id in U7&&(l.icon=U7[l.id])}),o.push(...s)}return ht(n,e)?o.push(...Y0(n,"insert-block")):o.push(j7(),{id:"insert-block-before",icon:YL,name:R.t("blockMenu.command.insertAbove"),children:Y0(n,"insert-block-before",{withPlainText:!0}),childrenMenuId:"quick-menu",source:"insert-block-before"},{id:"insert-block-after",icon:JL,name:R.t("blockMenu.command.insertAfter"),children:Y0(n,"insert-block",{withPlainText:!0}),source:"insert-block",childrenMenuId:"quick-menu"}),o}function g$(n,e,t){if(t.source==="block-command"){const o=t.blockMenuItemCustomData;u4(n,e,o,t)}else(t.source==="insert-block"||t.source==="insert-block-before")&&d$(n,e,t,t.source==="insert-block-before")}const p$=S("exclusive-block");function J0(n,e,t,o){var l;W(e,"block-exclusive");const r=Qe(n,e),i=(l=r.getBlockProperties)==null?void 0:l.call(r,n,e),{abstract:s}=i||{};e.setAttribute("data-user-name",o),e.setAttribute("data-user-id",t),e.setAttribute("data-exclusive-tips",R.t("exclusive.tips",{editor:o,embedType:s||R.t("exclusive.fallbackAbstract")}))}function z7(n){te(n,"block-exclusive"),n.removeAttribute("data-user-name"),n.removeAttribute("data-user-id"),n.removeAttribute("data-exclusive-tips")}function C$(n,e,t,o,r){p$.debug(`block ${ie(e)} ${t?"exclusive":"unexclusive"}, ${o}, ${r}`),t?J0(n,e,o,r):z7(e)}function Of(n){return n.classList.contains("block-exclusive")}function V7(n,e){e.blockIds.forEach(t=>{const o=n.findBlockById(t);o&&C$(n,o,e.exclusive,e.userId,e.displayName)})}class Xi{constructor(e){m(this,"exclusiveBlockIds",new Set);m(this,"exclusiveBlockTimer",0);m(this,"remoteExclusiveBlockIds",new Map);m(this,"handleUserChanged",e=>{const t=new Set(e.map(r=>r.userId));Array.from(this.remoteExclusiveBlockIds.entries()).forEach(([r,i])=>{if(!t.has(i.userId)){this.remoteExclusiveBlockIds.delete(r);const s={...i,exclusive:!1};V7(this.editor,s)}});const o=Array.from(this.exclusiveBlockIds).map(r=>this.editor.findBlockById(r)).filter(r=>!!r);o.length>0&&this.broadcastExclusiveBlockMessage(o,!0)});this.editor=e,e.doc.registerCallback(this),e.doc.getRemoteUsers().addListener("change",this.handleUserChanged)}destroy(){this.stopExclusiveBlockTimer(),this.editor.doc.unregisterCallback(this),this.editor.doc.getRemoteUsers().addListener("change",this.handleUserChanged)}onCustomMessage(e){if(e.type==="exclusiveBlock"){const t=e;V7(this.editor,t),t.blockIds.forEach(o=>{t.exclusive?this.remoteExclusiveBlockIds.set(o,t):this.remoteExclusiveBlockIds.delete(o)})}}getExclusiveMessage(e){return this.remoteExclusiveBlockIds.get(e)}broadcastExclusiveBlockMessage(e,t){if(this.editor.readonly||e.length===0)return;const o=this.editor.doc.getUser(),r={type:"exclusiveBlock",userId:o.userId,displayName:o.displayName,blockIds:e.map(i=>ie(i)),exclusive:t};this.editor.doc.broadcastMessage(r)}exclusiveBlock(e){this.exclusiveBlockIds.has(ie(e))||(this.broadcastExclusiveBlockMessage([e],!0),this.exclusiveBlockIds.add(ie(e)),this.exclusiveBlockIds.size===1&&this.startExclusiveBlockTimer())}unexclusiveBlock(e){!this.exclusiveBlockIds.has(ie(e))||(this.exclusiveBlockIds.delete(ie(e)),this.broadcastExclusiveBlockMessage([e],!1),this.exclusiveBlockIds.size===0&&this.stopExclusiveBlockTimer())}startExclusiveBlockTimer(){this.exclusiveBlockTimer=window.setInterval(()=>{Array.from(this.exclusiveBlockIds.keys()).forEach(e=>{this.broadcastExclusiveBlockMessage([this.editor.getBlockById(e)],!0)})},30*1e3)}stopExclusiveBlockTimer(){clearInterval(this.exclusiveBlockTimer),this.exclusiveBlockTimer=0}static get(e){return e.addCustom("exclusiveBlock",()=>new Xi(e))}static register(e){return this.get(e)}}function K0(n,e){Xi.get(n).exclusiveBlock(e)}function X0(n,e){Xi.get(n).unexclusiveBlock(e)}class W7{writable(e,t){if(Of(t))return!1}create(e,t,o,r,i){const s=Xi.get(e).getExclusiveMessage(i.id);s&&J0(e,r,s.userId,s.displayName)}update(e,t,o,r,i){const s=Xi.get(e).getExclusiveMessage(i.id);s?J0(e,r,s.userId,s.displayName):z7(r)}}const Dne="",A$={exclusive:{tips:"\u300C{editor}\u300D\u6B63\u5728\u7F16\u8F91\uFF0C\u300C{embedType}\u300D\u4E0D\u652F\u6301\u591A\u4EBA\u7F16\u8F91",fallbackAbstract:"\u8BE5 Block"}},b$={exclusive:{tips:"\u300C{editor}\u300Dis editing\uFF0C\u300C{embedType}\u300Ddoes not support multi-person editing",fallbackAbstract:"This Block"}},v$={exclusive:{tips:"\u300C{editor}\u300D\u306F\u7DE8\u96C6\u4E2D\u3067\u3059\u3002\u300C{embedType}\u300D\u306F\u8907\u6570\u4EBA\u3067\u540C\u6642\u7DE8\u96C6\u3067\u304D\u307E\u305B\u3093",fallbackAbstract:"\u3053\u306E\u8981\u7D20"}};R.mergeLang({"zh-CN":A$,"en-US":b$,"ja-JP":v$});function Iu(n,e){return n.getBlockData(e).lock}function _f(n,e){return!!Iu(n,e)}function Tu(n,e){const t=Iu(n,e);return t?t.userId===n.doc.getUser().userId:!1}function e2(n,e){const t=Iu(n,e);return t?t.userId!==n.doc.getUser().userId:!1}function y$(n,e){if(n.readonly||!n.isBlockWritable(e)||_f(n,e)&&!Tu(n,e))return;const t=n.doc.getUser(),o={userId:t.userId,displayName:t.displayName,locked:Date.now()},i={...n.getBlockData(e),lock:o};n.updateBlockData(e,i)}function k$(n,e){if(!Tu(n,e))return;const t={lock:null};n.updateBlockData(e,t)}const w$=10,B$=80;class t2{constructor(){m(this,"executeCommand",(e,t,o)=>{const r=o.data;if(!r||!r.blockId)return;const i=e.getBlockById(r.blockId);r.type==="lock"?y$(e,i):r.type==="unlock"&&k$(e,i)})}create(e,t,o,r,i){const s=i.lock;s&&(s.userId!==e.doc.getUser().userId?W(r,"locked-by-others"):W(r,"locked-by-self"))}update(e,t,o,r,i){const s=i.lock;if(s)if(s.userId!==e.doc.getUser().userId){W(r,"locked-by-others");const l=e.selection.focusedBlock;(l===r||Ke(r,l))&&(ee(e,r)||De(r)==="code")&&e.insertTextBlock("",ae(o),be(r)+1)}else W(r,"locked-by-self");else te(r,"locked-by-others"),te(r,"locked-by-self")}writable(e,t){if(e2(e,t))return!1;if(ro(t))return;let o=Is(t);for(;o;){if(e2(e,o))return!1;o=Is(o)}}commands(e,t){const o=_f(e,t),r=Tu(e,t),i=Of(t),s={blockId:ie(t),type:"lock"},l={id:"lock-block",name:"",data:s,order:10};if(o)if(r)l.id="unlock-block",l.name=R.t("locker.unlock"),s.type="unlock";else{const a=Iu(e,t);let d=(a==null?void 0:a.displayName)||"";const h=RC(d,w$,B$);(h==null?void 0:h.length)!==d.length&&(l.ellipsisTooltip=a==null?void 0:a.displayName,d=h||""),l.name=R.t("locker.lockedBy",{name:d}),l.states=["disabled"]}else i?(l.name=R.t("locker.lock"),l.states=["disabled"]):l.name=R.t("locker.lock");return{group:"block-locker",commands:[l],executeCommand:this.executeCommand}}}const Sne="",E$={locker:{lock:"\u9501\u5B9A",unlock:"\u89E3\u9664\u9501\u5B9A",lockedBy:"\u88AB {name} \u9501\u5B9A"}},x$={locker:{lock:"Lock",unlock:"Unlock",lockedBy:"Locked by {name}"}},I$={locker:{lock:"\u30ED\u30C3\u30AF",unlock:"\u30ED\u30C3\u30AF\u89E3\u9664",lockedBy:"{name}\u304C\u30ED\u30C3\u30AF\u3057\u307E\u3057\u305F"}};R.mergeLang({"zh-CN":E$,"en-US":x$,"ja-JP":I$});class Ff{async handleBeforePasteDoc(e,t){return Object.values(t.blocks).forEach(o=>{o.forEach(r=>{delete r.lock})}),!1}}const T$=S("standard-block-actions");class D${constructor(){m(this,"executeCommand",(e,t,o)=>{const r=o.data;try{const i=e.getBlockById(r);if(o.id==="delete"){e.deleteBlock(i);return}o.id==="copy"&&Oh(e,i),o.id==="cut"&&(Oh(e,i),e.deleteBlock(i))}catch(i){T$.error(`failed to execute block command: ${JSON.stringify(i)}`)}})}commands(e,t){const o=_f(e,t),r=o&&Tu(e,t),i=ie(t),s=j0(),l=Of(t),a={id:"copy",name:R.t("blockMenu.command.copy"),data:i,order:1,states:s?[]:["disabled"],disableReason:s?void 0:R.t("copyCutProperty.unsafeEnvTips",{shortCut:Bo("CtrlOrCmd+C"),operation:R.t("copyCutProperty.copy")})},d={id:"cut",name:R.t("blockMenu.command.cut"),data:i,order:2,states:o&&!r||!s||l?["disabled"]:[],disableReason:s?void 0:R.t("copyCutProperty.unsafeEnvTips",{shortCut:Bo("CtrlOrCmd+X"),operation:R.t("copyCutProperty.cut")})},h={id:"delete",name:R.t("blockMenu.command.delete"),data:i,order:3,states:o&&!r||l?["disabled"]:[]};return{group:"standard-block-actions",commands:[a,d,h],executeCommand:this.executeCommand}}}const q7=S("block-menu");class S${constructor(e){m(this,"menu");m(this,"currentBlock",null);m(this,"commandBlock",null);m(this,"handleShow",()=>{g(q7,this.currentBlock,"no target block before show block menu");const e=m$(this.editor,this.currentBlock,{onAfterStyleItemClick:this.close});this.menu.updateItems(e),this.commandBlock=this.currentBlock});m(this,"handleClose",()=>{Fp(this.editor)&&this.editor.focus()});m(this,"handleItemClick",(e,t)=>{g(q7,this.commandBlock,"no command block before show block menu"),g$(this.editor,this.commandBlock,t),t.element||this.close()});m(this,"close",()=>{this.menu.close("clickItem")});this.editor=e,this.menu=new zs([],void 0,{id:"block-menu"}),this.menu.on("show",this.handleShow),this.menu.on("close",this.handleClose),this.menu.on("click",this.handleItemClick),e.blockHooks.push(new D$)}show(e,t){this.menu.manualShow(e,{placement:"bottom-start",...t})}isInMenu(e){return this.menu.isInCommandBar(e)}setBlock(e){this.currentBlock=e}get isVisible(){return this.menu.isVisible}destroy(){this.menu.destroy()}}const L$=1e3;async function M$(n,e){const{width:t}=n.rootContainer.getBoundingClientRect(),o=e.getBoundingClientRect();return o.width>t||o.height>=L$?"":(await Z5.default.toSvg(e)).replace(/margin-block:.*?;/,"").replace(/margin:.*?;/,"")}const R$=S("drag-preview-image");class O${constructor(e){m(this,"startPosition",null);m(this,"dragContainer",null);m(this,"handleDragStart",async(e,t)=>{const o=e.target;g(R$,o instanceof Element,`Invalid Drag target:${o}`);const{x:r,y:i}=e;this.startPosition={x:r,y:i};const s=w("div",["drag-image-container"],this.editor.rootContainer),l=w("img",["drag-image"],s),a=w("span",["drag-loading"],s);a.innerHTML=tM;const{x:d,width:h,height:p,y:A}=o.getBoundingClientRect(),v=this.editor.rootContainer.getBoundingClientRect(),B=t.getBoundingClientRect();s.style.left=`${d+h}px`,s.style.top=`${A+p}px`,s.style.width=`${Math.min(v.width/2,B.width)}px`,this.dragContainer=s;const I=await M$(this.editor,t);I?l.src=I:W(s,"drag-placeholder"),Am(s,{status:"loaded"})});m(this,"handleDrag",e=>{if(this.startPosition&&this.dragContainer){const{x:t,y:o}=e;if(t===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=t-r,l=o-i;this.dragContainer.style.transform=`translate(${s}px, ${l}px)`}});m(this,"handleDragEnd",()=>{this.dragContainer&&(this.dragContainer.remove(),this.startPosition=null,this.dragContainer=null)});this.editor=e}}const G7="drag-preview-element";function _$(n){if(xe(n,G7))return n;const e=n.querySelector(`.${G7}`);return e||(Lt(n)?Re(n):n)}const Pf=S("block-menu-drag-handler");function n2(n,e){return new DragEvent(e,{bubbles:!0,cancelable:!0,view:window,screenX:n.screenX,screenY:n.screenY,dataTransfer:new DataTransfer,clientX:n.clientX,clientY:n.clientY})}class F${constructor(e,t){m(this,"dragPreview");m(this,"autoScroll");m(this,"oldPos",{x:0,y:0});m(this,"handleMouseDown",e=>{const t=this.button.blockMenu.currentBlock;g(Pf,t,"no dragged block"),this.editor.isBlockWritable(t)||(e.preventDefault(),e.stopPropagation());const{x:o,y:r}=e;this.oldPos={x:o,y:r},document.addEventListener("mouseup",this.handleDragEnd),this.editor.contentElement.addEventListener("mousemove",this.handleDrag)});m(this,"handleDragStart",e=>{var s,l;const t=oo(this.button.buttonElement);this.autoScroll||(this.autoScroll=new Zd({scrollElement:t,trackMouseEvent:"mousemove",edge:{top:50,bottom:50}}));const o=this.button.blockMenu.currentBlock;g(Pf,o,"no dragged block"),(l=(s=Qe(this.editor,o)).notify)==null||l.call(s,this.editor,"beginDrag");const r=n2(e,"dragstart");j$(this.editor,r,o),window.isDragging=!0,this.button.buttonElement.style.opacity="0";const i=_$(o);this.dragPreview.handleDragStart(e,i),this.autoScroll.active(),W(o,"dragging"),W(this.editor.contentElement,"dragging")});m(this,"handleDrag",e=>{const{target:t,x:o,y:r}=e;if(this.oldPos.x===o&&this.oldPos.y===r)return;window.isDragging||this.handleDragStart(e),this.oldPos={x:o,y:r},g(Pf,t instanceof Element,"target is invalid"),this.dragPreview.handleDrag(e);const i=n2(e,"dragover");this.editor.contentElement.dispatchEvent(i)});m(this,"handleDragEnd",e=>{var r;const t=this.button.blockMenu.currentBlock;g(Pf,t,"no dragged block"),window.isDragging=!1,this.button.buttonElement.style.opacity="1",this.dragPreview.handleDragEnd(),(r=this.autoScroll)==null||r.inactive(),te(t,"dragging"),te(this.editor.contentElement,"dragging"),document.removeEventListener("mouseup",this.handleDragEnd),this.editor.contentElement.removeEventListener("mousemove",this.handleDrag);const o=n2(e,"drop");this.editor.contentElement.dispatchEvent(o)});this.editor=e,this.button=t,this.button.buttonElement.addEventListener("mousedown",this.handleMouseDown),this.dragPreview=new O$(e)}destroy(){this.button.buttonElement.removeEventListener("mousedown",this.handleMouseDown)}}class Du{constructor(e){m(this,"highlightedBlockId","");m(this,"handleSelectionChange",()=>{this.clearHighlightedBlock()});this.editor=e,this.editor.addListener("selectionChanged",this.handleSelectionChange)}highlightBlock(e){this.clearHighlightedBlock(),this.highlightedBlockId=ie(e),W(e,"highlighted")}clearHighlightedBlock(){if(this.highlightedBlockId){const e=this.editor.findBlockById(this.highlightedBlockId);e&&te(e,"highlighted"),this.highlightedBlockId=""}}destroy(){}static register(e){return e.addCustom("editor-block-highlighter",()=>new Du(e))}static get(e){return e.getCustom("editor-block-highlighter")}}class Z7{constructor(e){m(this,"buttonElement");m(this,"emptyBlockMenu");m(this,"blockMenu");m(this,"dragHandler");m(this,"handleHoverBlock",(e,t,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()}`)),!e){this.buttonElement.parentElement&&(this.blockMenu.isInMenu(o.target)||this.buttonElement.remove());return}const i=Vm(e);this.editor.getBlockIndex(i)===0&&this.editor.getBlockData(i).heading===1||(this.updateButton(i),Q0(i,this.buttonElement,Number.MAX_SAFE_INTEGER))});m(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,{placement:"bottom-end"}),setTimeout(()=>{Du.get(this.editor).highlightBlock(o)});return}const t=this.emptyBlockMenu.currentBlock;!t||(this.editor.selection.selectBlock(t,0),setTimeout(()=>{this.editor.focus(),this.updatePlaceholder(t),this.emptyBlockMenu.show()}))});m(this,"updatePlaceholder",e=>{Re(e).setAttribute("data-content-placeholder",R.t("blockMenu.button.searchPlaceholder"))});m(this,"handleChanged",()=>{const e=this.emptyBlockMenu.currentBlock;if(!e)return;const t=ht(this.editor,e)?"insert":"move";this.buttonElement.getAttribute("data-type")!==t&&this.setButtonType(t)});this.editor=e,this.buttonElement=this.createButton(),this.emptyBlockMenu=new a$(e),this.blockMenu=new S$(e),this.editor.addListener("docChanged",this.handleChanged),this.buttonElement.addEventListener("click",this.handleButtonClick),this.dragHandler=new F$(this.editor,this);const t=pt.get(e);t.addListener("change",this.handleHoverBlock),t.addFinder(new c$),Du.register(this.editor)}destroy(){pt.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 e=w("button",["block-button"],null);return e.setAttribute(`data-editor-tooltip-${this.editor.clientId}`,R.t("blockMenu.button.tips")),e.innerHTML=Cv,e}setButtonType(e){this.buttonElement.setAttribute("data-type",e);const t=`data-editor-tooltip-${this.editor.clientId}-dynamic`;this.buttonElement.hasAttribute(t)&&this.buttonElement.removeAttribute(t),e==="insert"?(this.buttonElement.innerHTML=eM,this.buttonElement.setAttribute(t,R.t("blockMenu.button.insertTips"))):(this.buttonElement.innerHTML=Cv,this.buttonElement.setAttribute(t,R.t("blockMenu.button.tips")))}updateButton(e){this.emptyBlockMenu.setBlock(e),this.blockMenu.setBlock(e),ht(this.editor,e)?this.setButtonType("insert"):this.setButtonType("move")}}const P$={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:"\u5728\u4E0A\u65B9\u6DFB\u52A0",insertAfter:"\u5728\u4E0B\u65B9\u6DFB\u52A0",copy:"\u590D\u5236",cut:"\u526A\u5207",delete:"\u5220\u9664"},button:{searchPlaceholder:"\u8F93\u5165\u5173\u952E\u8BCD\u641C\u7D22",tips:`\u957F\u6309\u62D6\u62FD
419
- \u70B9\u51FB\u6253\u5F00\u83DC\u5355`,insertTips:"\u70B9\u51FB\u6DFB\u52A0\u533A\u5757"}}},N$={blockMenu:{section:{basics:"Basics",system:"System",styles:"Styles",common:"Common",actions:"Actions",thirdParty:"Third-party content"},command:{insertAbove:"Insert above",insertAfter:"Insert after",copy:"Copy",cut:"Cut",delete:"Delete"},button:{searchPlaceholder:"Type to filter",tips:`Long press drag
420
- Click to open the menu`,insertTips:"\u70B9\u51FB\u6DFB\u52A0\u533A\u5757"}}},$$={blockMenu:{section:{basics:"\u4E00\u822C",system:"\u30B7\u30B9\u30C6\u30E0",styles:"\u30B9\u30BF\u30A4\u30EB",common:"\u4E00\u822C",actions:"\u64CD\u4F5C",thirdParty:"\u5916\u90E8\u30B3\u30F3\u30C6\u30F3\u30C4"},command:{insertAbove:"\u4E0A\u306B\u633F\u5165",insertAfter:"\u4E0B\u306B\u633F\u5165",copy:"\u30B3\u30D4\u30FC",cut:"\u5207\u308B",delete:"\u524A\u9664"},button:{searchPlaceholder:"\u30AD\u30FC\u30EF\u30FC\u30C9\u3067\u691C\u7D22",tips:"\u3092\u30C9\u30E9\u30C3\u30B0\u3057\u3066\u30AF\u30EA\u30C3\u30AF\u3067\u30E1\u30CB\u30E5\u30FC\u3092\u8868\u793A",insertTips:"\u70B9\u51FB\u6DFB\u52A0\u533A\u5757"}}};R.mergeLang({"zh-CN":P$,"en-US":N$,"ja-JP":$$});const Lne="";class H${constructor(){m(this,"dragObject",null)}setData(e){this.dragObject=e}getData(){return this.dragObject}clearData(){this.dragObject=null}destroy(){}}function Nf(n){return n.addCustom("drag-data",()=>new H$)}function o2(n,e){if(!e)return null;const t=Nf(n).getData();return!t||t.editorId!==n.id?null:t}function Q7(n,e){const t=o2(n,e);return t?n.findBlockById(t.blockId):null}function j$(n,e,t){if(!e.dataTransfer)return;const r=ne(t),i=ae(r),s=ie(t),l={type:"block",editorId:n.id,containerId:i,blockId:s};Nf(n).setData(l)}function U$(n,e,t,o,r){if(!e.dataTransfer)return;const s=ne(t),l=ae(s),a=ie(t),d={type:"custom",customType:o,editorId:n.id,containerId:l,blockId:a,data:r};Nf(n).setData(d)}function z$(n){Nf(n).clearData()}const V$=S("drop-indicator"),$f=2;class W${constructor(e){m(this,"indicator");m(this,"target",null);this.editor=e,this.indicator=w("div",["editor-drop-indicator"],this.editor.contentElement)}show(e,t){const o=this.getIndicatorRect(e,t),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:e,insertPos:t}}hide(){this.indicator.style.display="none",this.target=null}getIndicatorRect(e,t){if(typeof t!="string")return t.rect;if(t==="before"){const s=Ds(e);if(!s){g(V$,Do(ne(e)),"block does not in a child container");const d=e.getBoundingClientRect();return new DOMRect(d.x,d.y,d.width,$f)}const l=s.getBoundingClientRect(),a=e.getBoundingClientRect();return new DOMRect(l.x,(l.bottom+a.top)/2,l.width,$f)}const o=Ss(e);if(!o){const s=e.getBoundingClientRect();return new DOMRect(s.x,s.bottom,s.width,$f)}const r=e.getBoundingClientRect(),i=o.getBoundingClientRect();return new DOMRect(r.x,(r.bottom+i.top)/2,r.width,$f)}}const q$=S("find-drop-target");function G$(n,e){const t=document.elementFromPoint(n,e);if(!t)return null;if(Fr(t)&&Do(t))return t;const o=t.firstElementChild;return o&&Fr(o)&&Do(o)?o:null}function Z$(n,e){const s=e,l=n;for(let a=0;a<2;a++){const d=l+a*50;for(let h=0;h<5;h++){const p=s+h*8,A=document.elementFromPoint(d,p);if(A){const D=oe(A);if(D)return D}if(h===0)continue;const v=s-h*8,B=document.elementFromPoint(d,v);if(B){const D=oe(B);if(D)return D}}}return null}function Q$(n,e,t){const o=document.elementFromPoint(e,t);if(o){const h=oe(o);if(h&&!Le(n,h))return h}const r=new Set,i=G$(e,t);if(i){const h=i.getBoundingClientRect();t<h.top+h.height/2?r.add(St(i)):r.add(Gt(i))}const s=Z$(e,t);s&&r.add(s);const l=Array.from(r),a=h=>{for(let p=0;p<l.length;p++){const A=l[p];if(h!==A&&Ke(h,A))return!0}return!1},d=l.filter(h=>!a(h));return d.length>0?d[0]:null}function r2(n,e){if(n.readonly)return!1;const t=ne(e);if(Xe(t))return!0;const o=oe(t);return g(q$,o,"no parent block"),n.isBlockWritable(o)?r2(n,o):!1}const Y$=S("drop-target");function J$(n,e){let t={};return/image/.test(e.type)?t=n.editorEmbeds.getEmbedClass("image"):/audio/.test(e.type)?t=n.editorEmbeds.getEmbedClass("audio"):/video/.test(e.type)&&(t=n.editorEmbeds.getEmbedClass("video")),g(Y$,t,`unSupport file type ${e.type}`),t}async function Y7(n,e,t,o){var i,s;let r=o;for(const l of e){const a=J$(n,l);a.getOptions&&await((s=(i=a.getOptions(n)).handleInsertEmptyEmbed)==null?void 0:s.call(i,n,{containerId:t,blockIndex:r,data:{file:l}}))&&(r+=1)}}class K${constructor(e){m(this,"handleDrop",(e,t,o,r)=>{if(Array.isArray(t)){const i=t;if(i.length>0){const s=ae(o);return Y7(e,i,s,r),!0}}return!1});this.editor=e}}class Su{constructor(e){m(this,"indicator");m(this,"lastDropOverResult");m(this,"handlers",[]);m(this,"handleDragOver",e=>{if(!this.editor.isWritable())return;const t=i=>{var d,h;const s=o2(this.editor,i.dataTransfer),l=Q7(this.editor,i.dataTransfer),a=this.findTargetBlock(l,i.x,i.y);if(a&&Ke(this.editor.rootContainer,a)){const p=this.findInsertPos(l,a,i.x,i.y,(h=s!=null?s:(d=i.dataTransfer)==null?void 0:d.items)!=null?h:null);if(p)return this.indicator.show(a,p),"move"}return this.indicator.hide(),"none"},o=(i,s)=>{i.dataTransfer&&(i.dataTransfer.dropEffect=s),s==="move"&&i.preventDefault()};if(this.lastDropOverResult&&e.x===this.lastDropOverResult.x&&e.y===this.lastDropOverResult.y){const i=this.lastDropOverResult.dropEffect;o(e,i);return}const r=t(e);o(e,r),this.lastDropOverResult={x:e.x,y:e.y,dropEffect:r}});m(this,"handleDrop",e=>{var i,s;e.stopPropagation(),setTimeout(()=>{this.indicator.hide()});const t=o2(this.editor,e.dataTransfer),o=Array.from((s=(i=e.dataTransfer)==null?void 0:i.files)!=null?s:[]);if(!t&&o.length===0){e.dataTransfer&&(e.dataTransfer.dropEffect="none");return}const r=this.indicator.target;if(r){const{block:l,insertPos:a}=r,d=Q7(this.editor,e.dataTransfer);this.editor.undoManager.runInGroup(()=>{const h=Qe(this.editor,l);if(h.handleDrop&&h.handleDrop(this.editor,l,t!=null?t:o,a,{isSourceBlock:!1,targetBlock:l})){e.preventDefault(),this.editor.focus();return}if(d){const p=Qe(this.editor,d);if(p.handleDrop&&p.handleDrop(this.editor,d,t!=null?t:o,a,{isSourceBlock:!0,targetBlock:l})){e.preventDefault(),this.editor.focus();return}}if(typeof a=="string"){const p=ne(l);let A=be(l);a==="after"&&(A+=1),e.preventDefault();for(let v=0;v<this.handlers.length;v++)if(this.handlers[v].handleDrop(this.editor,d!=null?d:o,p,A)){this.editor.focus();return}if(d){const v=this.editor.getBlockData(d),B=Fi(this.editor.editorBlocks,this.editor.doc.toJSON(),v),[D]=this.editor.insertDocAt(p,A,B);this.editor.selection.selectBlock(D,0),Du.get(this.editor).highlightBlock(D),this.editor.deleteBlock(d),this.editor.focus()}}}),z$(this.editor)}});m(this,"handleDragLeave",()=>{this.indicator.hide()});this.editor=e,this.indicator=new W$(this.editor),this.handlers.push(new K$(this.editor)),this.editor.contentElement.addEventListener("dragover",this.handleDragOver),this.editor.contentElement.addEventListener("dragleave",this.handleDragLeave),this.editor.contentElement.addEventListener("drop",this.handleDrop)}destroy(){this.editor.contentElement.removeEventListener("dragover",this.handleDragOver),this.editor.contentElement.removeEventListener("dragleave",this.handleDragLeave),this.editor.contentElement.removeEventListener("drop",this.handleDrop),this.handlers=[]}addHandler(e){this.handlers.push(e)}static register(e){return e.addCustom("drop-target",()=>new Su(e))}static get(e){return e.getCustom("drop-target")}static find(e){return e.findCustom("drop-target")}canInsertAfter(e,t){return!(this.editor.readonly||Ss(t)===e&&e||!r2(this.editor,t))}canInsertBefore(e,t){return!(this.editor.readonly||Ds(t)===e&&e||!r2(this.editor,t)||Xe(ne(t))&&be(t)===0)}canDrop(e,t){return e===null||e===t?!0:!Ke(e,t)}findTargetBlock(e,t,o){let r=Q$(this.editor,t,o);if(!r||!Ke(this.editor.rootContainer,r))return null;const i=ne(r),s=oe(i);return s&&De(s)==="code"&&(r=s),this.canDrop(e,r)?r:null}findInsertPos(e,t,o,r,i){let s=t;for(;s;){const a=Qe(this.editor,s);if(a.handleDropOver){const d=a.handleDropOver(this.editor,s,i,o,r);if(d)return d;if(d===!1)return null}s=Is(s)}if(e===t)return"";const l=t.getBoundingClientRect();if(l.top<=r&&r<=l.bottom){if(r<l.top+l.height/2){if(this.canInsertBefore(e,t))return"before";if(this.canInsertAfter(e,t))return"after"}else{if(this.canInsertAfter(e,t))return"after";if(this.canInsertBefore(e,t))return"before"}return""}return r<l.top&&this.canInsertBefore(e,t)?"before":l.bottom<r&&this.canInsertAfter(e,t)?"after":""}}function J7(n,e,t){const o=wt.getImageObject(n,e),r=me.default(o.getImages());if(r.length===1){n.deleteBlock(e);return}if(t===-1||t>=r.length)return;const i=NN(r);if(r.splice(t,1),r.length===1){const l=r[0],a=100*(l.flex/i);l.flex=1;const d=cn([l],a);n.updateEmbedData(e,d);return}r[0].flex=NaN,ku(r);const s=cn(r,o.getWidthPercent());n.updateEmbedData(e,s)}function X$(n,e,t,o){if(e.length===0||o==="after"||o==="before")return!1;let r=o.data;const i=wt.getImageObject(n,t),s=me.default(i.getImages()),l=[],a=[];e.forEach(p=>{P7(p.type)&&s.length+l.length<6?l.push(p):a.push(p)}),l.forEach(p=>{try{F7(n,p)}catch{return}const A={src:"",flex:1,width:0,height:0,virtualSize:!0};s.splice(r,0,A);const v=cn(s,i.getWidthPercent());n.updateEmbedData(t,v),i.replaceImage(r,p),r+=1});const d=n.getBlockIndex(t)+1,h=ae(ne(t));return Y7(n,a,h,d),!0}function eH(n,e,t,o,r){var s,l,a;if(qd(t))return X$(n,t,e,o);if(t.type!=="custom"||t.customType!=="image"||!t.data)return;const i=t.data;if(r.isSourceBlock){const d=r.targetBlock,h=ne(d);let p=be(d);o==="after"&&(p+=1);const v=100*(i.boundingRect.width/n.rootContainer.getBoundingClientRect().width),B=cn([i.image],v),D={id:K(),type:"embed",embedType:"image",embedData:B},I=(l=(s=n.options.componentsOptions)==null?void 0:s.image)==null?void 0:l.defaultAlign;I&&(D.align=I),n.insertBlock(ae(h),p,D),J7(n,e,i.index),(a=n.findCustom("drag-handler"))==null||a.handleDragEnd()}else{if(typeof o=="string")return;const d=e;let h=o.data;const p=wt.getImageObject(n,d),A=me.default(p.getImages());h>A.length&&(h=A.length),n.undoManager.runInGroup(()=>{var B,D;p.setAutoFix(!0);const v=n.getBlockById(t.blockId);if(v===d){const I=i.index,_=h,M=i.image;if(I===_||_===I+1)return;let H=_;I<_?(A.splice(_,0,M),A.splice(I,1),H-=1):(A.splice(I,1),A.splice(_,0,M));const z=cn(A,p.getWidthPercent());n.updateEmbedData(d,z),p.setSelectedIndex(H),(B=n.findCustom("drag-handler"))==null||B.handleDragEnd()}else{A.splice(h,0,i.image),A[0].flex=NaN,ku(A);const I=cn(A,p.getWidthPercent());n.updateEmbedData(d,I),J7(n,v,i.index),(D=n.findCustom("drag-handler"))==null||D.handleDragEnd(),p.setSelectedIndex(h),n.selection.selectBlock(d,0)}})}return!0}const tH=2;function Hf(n,e,t){const o=pr(e);if(t<=0){const s=o[0].getBoundingClientRect();return new DOMRect(s.left-4,s.top,2,s.height)}if(t===o.length){const s=o[t-1].getBoundingClientRect();return new DOMRect(s.right+2,s.top,2,s.height)}const r=o[t-1].getBoundingClientRect(),i=o[t].getBoundingClientRect();return new DOMRect((i.left+r.right)/2-1,r.top,tH,r.height)}function nH(n,e,t,o,r){for(let i=0;i<t.length;i++){const l=t[i].getBoundingClientRect();if(o<=l.right)return o<=l.left+l.width/2?{rect:Hf(n,e,i),data:i}:{rect:Hf(n,e,i+1),data:i+1}}return o>t[t.length-1].getBoundingClientRect().right?{rect:Hf(n,e,t.length),data:t.length}:{rect:Hf(n,e,t.length),data:0}}function oH(n,e,t,o,r){const i=pr(e);if(t instanceof DataTransferItemList){if(!Array.from(t).some(s=>P7(s.type))||i.length>=6)return}else{if((t==null?void 0:t.type)==="block"||i.length>=6&&(t==null?void 0:t.blockId)!==ie(e))return;const s=ie(e);if(i.length===1&&s===(t==null?void 0:t.blockId))return}return nH(n,e,i,o)}async function rH(n){return await Z5.default.toSvg(n)}function i2(n,e){return new DragEvent(e,{bubbles:!0,cancelable:!0,view:window,screenX:n.screenX,screenY:n.screenY,dataTransfer:new DataTransfer,clientX:n.clientX,clientY:n.clientY})}class iH{constructor(e){m(this,"img");m(this,"dragContainer",null);m(this,"autoScroll",null);m(this,"imageContainer",null);m(this,"startPosition",null);m(this,"handleMouseDown",e=>{const t=e.target;if(!t||!(t instanceof HTMLImageElement))return;const o=oe(t);if(!o||!zo(o))return;this.editor.isBlockWritable(o)||(e.preventDefault(),e.stopPropagation());const r=wt.getImageObject(this.editor,o);if(this.imageContainer=G0(e.target),!this.imageContainer)return;const s=S7(e.target).indexOf(this.imageContainer);if(s===-1)return;const l=r.getImages()[s];if(!l)return;const{x:a,y:d}=e;this.startPosition={x:a,y:d};const h={image:l,index:s,boundingRect:this.imageContainer.getBoundingClientRect()},p=i2(e,"dragstart");U$(this.editor,p,o,"image",h),document.addEventListener("mouseup",this.handleDragEnd),this.editor.contentElement.addEventListener("mousemove",this.handleDrag),e.preventDefault()});m(this,"handleDragStart",async e=>{if(!this.imageContainer)return;const t=oe(this.imageContainer);if(!t)return;const o=wt.getImageObject(this.editor,t),i=pr(t).indexOf(this.imageContainer);if(i===-1||!o.getImages()[i])return;const{x:l,y:a}=e,{width:d,height:h}=e.target.getBoundingClientRect(),p=lt(t),A=w("div",["drag-container"],p);A.style.left=`${l-d/4}px`,A.style.top=`${a-h/4}px`,A.style.width=`${Math.max(d/2,16)}px`,A.style.height=`${h/2}px`,this.dragContainer=A;const v=w("img",["drag-target"],A),D=await rH(this.imageContainer);D&&(v.src=D),W(this.editor.contentElement,"dragging");const I=oo(t);this.autoScroll=new Zd({scrollElement:I,trackMouseEvent:"mousemove",edge:{top:50,bottom:50}}),this.autoScroll.active()});m(this,"handleDrag",e=>{var s;const{target:t,x:o,y:r}=e;if(((s=this.startPosition)==null?void 0:s.x)===o&&this.startPosition.y===r)return;if(window.isDragging||(window.isDragging=!0,this.handleDragStart(e)),this.startPosition&&this.dragContainer){const{x:l,y:a}=e;if(l===0&&a===0){this.dragContainer.style.transform="",this.dragContainer.style.opacity="0";return}const{x:d,y:h}=this.startPosition,p=l-d,A=a-h;this.dragContainer.style.transform=`translate(${p}px, ${A}px)`,this.dragContainer.style.opacity="0.5"}const i=i2(e,"dragover");this.editor.contentElement.dispatchEvent(i)});m(this,"handleDragEnd",e=>{var t;if(window.isDragging=!1,this.dragContainer&&this.dragContainer.remove(),this.dragContainer=null,this.startPosition=null,this.imageContainer=null,(t=this.autoScroll)==null||t.inactive(),te(this.editor.contentElement,"dragging"),document.removeEventListener("mouseup",this.handleDragEnd),this.editor.contentElement.removeEventListener("mousemove",this.handleDrag),e){const o=i2(e,"drop");this.editor.contentElement.dispatchEvent(o)}});this.editor=e,this.editor.rootContainer.addEventListener("mousedown",this.handleMouseDown),this.img=new Image,this.img.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"}destroy(){this.editor.rootContainer.removeEventListener("mousedown",this.handleMouseDown)}}class sH{constructor(e){m(this,"handleFocusBlockChanged",(e,t,o)=>{const i=this.editor.getFocusedBlock();if(i&&zo(i)){const s=wt.getImageObject(this.editor,i);s.getImages().length>0&&s.getSelectedIndex()===-1&&s.setSelectedIndex(0)}o&&zo(o)&&wt.getImageObject(this.editor,o).blockResizer.disableResize()});this.editor=e,this.editor.addListener("focusBlockChanged",this.handleFocusBlockChanged)}destroy(){this.editor.removeListener("focusBlockChanged",this.handleFocusBlockChanged)}}class lH{constructor(e){m(this,"currentResizer",null);m(this,"handleHoveringBlockChange",(e,t)=>{t&&this.disable(t),e&&(this.currentResizer=e,this.enable(e))});this.editor=e,pt.get(e).addListener("change",this.handleHoveringBlockChange)}destroy(){pt.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}disable(e){zo(e)&&wt.getImageObject(this.editor,e).disableResizer()}enable(e){if(zo(e)){const t=wt.getImageObject(this.editor,e);this.editor.isBlockWritable(e)&&t.tryEnableResizer()}}}const cH={image:{title:"\u56FE\u7247",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">\u56FE\u7247\u52A0\u8F7D\u5931\u8D25</div><div class="line-2">\u8BE5\u56FE\u7247\u6765\u81EA\u5916\u90E8\u94FE\u63A5\uFF0C\u5916\u90E8\u94FE\u63A5\u5DF2\u5931\u6548</div><div class="line-3">\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"}},aH={image:{title:"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">Image failed to load</div><div class="line-2">The picture comes from an external link, and the external link has expired</div><div class="line-3">Please save the original image locally and then upload it. <a href="" class="retry-upload">Open image link</a></div>',tooltip:"This picture is from an external link. If the link expires, the picture will not be available. It's recommended to save it to local drives and add it to the page."}},abstract:"Image"}},uH={image:{title:"\u753B\u50CF",upload:{failed:'<div class="line-1">\u753B\u50CF\u3092\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F</div><div class="line-2">\u304A\u4F7F\u3044\u306E\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u306B\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u6B21\u306E\u64CD\u4F5C\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002 <a href="" class="retry-upload">\u518D\u8A66\u884C</a></div>'},load:{failed:'<div class="line-1">\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F</div><div class="line-2">\u304A\u4F7F\u3044\u306E\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u306B\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u6B21\u306E\u64CD\u4F5C\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002 <a href="" class="retry-upload">\u518D\u8A66\u884C</a></div>',remote:{failed:'<div class="line-1">\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F</div><div class="line-2">\u3053\u306E\u753B\u50CF\u306B\u30EA\u30F3\u30AF\u3057\u3066\u3044\u308B URL \u304C\u7121\u52B9\u306B\u306A\u3063\u3066\u3044\u307E\u3059\u306E\u3067\u3001\u8868\u793A\u3067\u304D\u307E\u305B\u3093</div><div class="line-3">\u753B\u50CF\u3092\u30ED\u30FC\u30AB\u30EB\u306B\u4FDD\u5B58\u3057\u3066\u30A2\u30C3\u30D7\u30ED\u30FC\u30C0\u3057\u3066\u304F\u3060\u3055\u3044 <a href="" class="retry-upload">\u753B\u50CF\u30EA\u30F3\u30AF\u3092\u958B\u304F</a></div>',tooltip:"\u3053\u306E\u753B\u50CF\u306F\u5916\u90E8\u306B\u30EA\u30F3\u30AF\u3057\u3066\u3044\u308B\u305F\u3081\u3001\u30EA\u30F3\u30AF\u304C\u7121\u52B9\u306B\u306A\u308B\u3068\u3001\u8868\u793A\u3067\u304D\u306A\u304F\u306A\u308A\u307E\u3059\u306E\u3067\u3001\u30ED\u30FC\u30AB\u30EB\u306B\u4FDD\u5B58\u3057\u3001\u30DA\u30FC\u30B8\u306B\u633F\u5165\u3059\u308B\u3053\u3068\u3092\u304A\u52E7\u3081\u3057\u307E\u3059"}},abstract:"\u753B\u50CF"}};R.mergeLang({"zh-CN":cH,"en-US":aH,"ja-JP":uH});function dH(n,e,t,o){const r=n.getBlockByIndex(e,t),i=n.getBlockText(r),{left:s}=xn(i,o),l=rt(s);let a=o;if(l.endsWith("![]()"))a-=5;else if(l.endsWith("![]"))a-=3;else return!1;const d=o;return zl("image/*").then(h=>{n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,a,d-a);let p=t+1;rt(n.getBlockText(r)).trim()?(Yl(n,r,a,{forceInsertAfter:!0}),a===0&&(n.deleteBlock(r),p--)):(n.deleteBlock(r),p--),qm(n,"image",e,p,{file:h})})}),!0}class hH{handleAfterInsertText(e,t,o,r,i){return!!(i===" "&&dH(e,t,o,r))}}function fH(n){const e=n.getFocusedBlock(),t=Ss(e);if(t&&zo(t)){n.selection.selectBlock(t,0);const o=wt.getImageObject(n,t);return o.getImages().length>0&&o.setSelectedIndex(0),!0}}function mH(n){const e=n.getFocusedBlock(),t=Ds(e);if(t&&zo(t)){n.selection.selectBlock(t,0);const o=wt.getImageObject(n,t);return o.getImages().length>0&&o.setSelectedIndex(0),!0}}function gH(n){const t=n.getFocusedBlock();if(t&&zo(t)){const o=wt.getImageObject(n,t),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 pH(n){const t=n.getFocusedBlock();if(t&&zo(t)){const o=wt.getImageObject(n,t),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 s2(n){const t=n.getFocusedBlock();if(t&&zo(t)){const o=wt.getImageObject(n,t);if(o.getImages().length>0){const i=o.getSelectedIndex();if(i!==-1)return o.removeImage(i),!0}}}const CH={ArrowLeft:gH,ArrowRight:pH,ArrowUp:mH,ArrowDown:fH,Delete:s2,Backspace:s2},AH=S("copy-image");function bH(n,e,t,o){const r=t.getImages()[o],i=t.getImages().length===1?t.getWidthPercent():r.flex*100,s=cn([r],i),l={id:K(),type:"embed",embedType:"image",embedData:s},a=n.options.componentsOptions.image;a!=null&&a.defaultAlign&&(l.align=a.defaultAlign);const d={blocks:{root:[l]},comments:{},meta:{}},h=document.createElement("canvas");h.width=e.naturalWidth,h.height=e.naturalHeight;const p=h.getContext("2d");if(!p)return;const A={},v={};try{p.drawImage(e,0,0,h.width,h.height);const z=h.toDataURL("image/png").replace(/^data:image\/(png|jpg);base64,/,""),q=Dm(z),re=new File([q],`${Date.now()}.png`,{type:"image/png"});A["image/png"]=re}catch(H){AH.error(H)}Rh(n,d);const D=`<img src="${n.doc.buildResourceUrl(r.src,{withToken:!0})}" />`,I=Mh(D,d),_=Ma(n,d);A["text/plain"]=new Blob([_],{type:"text/plain"}),v["text/plain"]=_;const M=new Blob([I],{type:"text/html"});return A["text/html"]=M,v["text/html"]=I,[A,v]}function vH(n,e,t,o,r){const i=bH(n,e,t,o);if(!i)return;const[s,l]=i;if(s){const a=Object.entries(s).map(([d,h])=>({type:d,data:h}));return Mm(a).then(d=>{if(!d&&r){const h=r.clipboardData;h&&(h.setData("text/plain",l["text/plain"]),h.setData("text/html",l["text/html"]))}}),!0}}function K7(n,e){const t=n.selection.range;if(t.start.blockId!==t.end.blockId)return;const r=n.getFocusedBlock();if(r&&zo(r)){const i=wt.getImageObject(n,r);if(i.getImages().length>0){const l=i.getSelectedIndex();if(l!==-1){const d=pr(r)[l].querySelector("img");if(d)return vH(n,d,i,l,e)}}}}class yH{constructor(e){this.editor=e,setTimeout(()=>{this.editor.input.addHandler(this)})}handleBeforeCopy(e,t,o){if(K7(e,t))return!0}handleBeforeCut(e,t){if(K7(e,t))return s2(e),!0}destroy(){}}class l2{constructor(e){this.editor=e,setTimeout(()=>{this.editor.input.addHandler(this)})}async handleAfterPasteDoc(e,t,o){return Object.values(t.blocks).forEach(r=>{r.forEach(i=>{if(i.type==="embed"&&i.embedType==="image"){const s=i.embedData;if(Array.isArray(s.src))return;if(s.src.startsWith("https:")||s.src.startsWith("http:")){const l=o.blockIdMap.get(i.id);l&&Ki(e,l).setAutoFix(!0)}}})}),!1}destroy(){}}const kH=S("image-embed");function wH(n,e,t,o,r,i){wt.create(n,t).createContent(r,i,e),n.addCustom("image-select-handler",()=>new sH(n)),n.addCustom("image-copy-handler",()=>new yH(n)),setTimeout(()=>{n.addCustom("drag-handler",()=>new iH(n));const l=n.addCustom("image-resizer",()=>new lH(n)),a=t.embedData;kc(a)?l.disable(i):l.currentResizer===i&&l.enable(i)})}function BH(n,e,t,o){const r=e.embedData,i=wc(r);return o==="html"?i.map(s=>`<img src="${n.doc.buildResourceUrl(s.src,{withToken:!0})}">`).join(""):o==="markdown"?`${i.map(l=>`![img](${n.doc.buildResourceUrl(l.src,{withToken:!0})})`).join(`
418
+ `).map(s=>({id:K(),type:"text",text:Oi(s)})),o=K();return{blocks:{root:[{children:[o],type:"code",id:K(),...e}],[o]:t},meta:{},comments:{}}}class EN{handleBeforeCopy(e,t,o){const r=e.getFocusedBlock();if(!yc(e,r))return;const i=_0(r),s=e.getBlockData(i),{language:l,nowrap:a}=s;if(e.selection.range.isCollapsed()){const h=e.getBlockString(r);return b7(h,{language:l,nowrap:a})}const d=e.getSelectedText();return b7(d,{language:l,nowrap:a})}}function xN(n){if(!n.isWritable())return!1;const e=n.getFocusedBlock();if(!!yc(n,e)){if(n.selection.range.isCollapsed()){const t=n.selection.range.start;return n.insertTextToBlock(e,t.offset," "),!0}return n.undoManager.runInGroup(()=>{Lo(n).forEach(o=>{n.insertTextToBlock(o.block,0," ")})}),!0}}function IN(n){if(!n.isWritable())return!1;const e=n.getFocusedBlock();if(!yc(n,e))return;const t=[" "," "];return n.undoManager.runInGroup(()=>{Lo(n).forEach(r=>{const i=rt(n.getBlockText(r.block));for(let s=0;s<t.length;s++){const l=t[s];if(i.startsWith(l)){n.deleteTextFromBlock(r.block,0,l.length);break}}})}),!0}function TN(n){const e=n.getFocusedBlock(),t=ne(e);if(Xe(t))return;const o=oe(t);if(!o||De(o)!=="code")return;const r=n.selection.range;if(!!r.isSimple()&&!MA(t,r))return Yg(n,t),!0}const DN={Tab:xN,"Shift+Tab":IN,"CtrlOrCmd+A":TN},yu=S("code-text-decorate");class Lf{decorateText(e,t,o){var v;if(g(yu,t.length>0,"invalid path"),t.length===1)return{};const r=t[t.length-2];if(e.doc.getBlockData(r.containerId,r.blockIndex).type!=="code")return{};const s=o;if(s.length===0)return{};const l=rt(s),a=e.doc.getBlockData(r.containerId,r.blockIndex),d=da.default.tokenize(l,(v=da.default.languages[a.language])!=null?v:da.default.languages.plain),h=(B,D)=>{if(g(yu,B,"no token"),typeof B=="string")return[{insert:B,attributes:me.default(D)}];g(yu,B instanceof da.default.Token,"invalid token type");const I=B.content,_=me.default(D);return _[`style-code-${B.type}`]=!0,typeof I=="string"?[{insert:I,attributes:_}]:Array.isArray(I)?I.map(z=>h(z,_)).flat():(g(yu,I instanceof da.default.Token,"invalid token"),h(I,_))},A=d.map(B=>h(B,{})).flat();return g(yu,rn(A)===rn(s),"failed to highlight code, text length mismatch"),{text:A}}}const SN={code:{title:"\u4EE3\u7801",abstract:"\u4EE3\u7801",wrap:"\u6362\u884C",copy:"\u590D\u5236",caption:"\u8BF4\u660E",search:"\u8F93\u5165\u5173\u952E\u8BCD\u641C\u7D22",copySuccess:"\u590D\u5236\u6210\u529F"}},LN={code:{title:"Code",abstract:"Code",wrap:"Wrap",copy:"Copy",caption:"Caption",search:"Search",copySuccess:"Copied successfully"}},MN={code:{title:"\u30B3\u30FC\u30C9",abstract:"\u30B3\u30FC\u30C9",wrap:"\u6298\u308A\u8FD4\u3059",copy:"\u30B3\u30D4\u30FC",caption:"\u4F8B\u8A3C\u3059\u308B",search:"\u30AD\u30FC\u30EF\u30FC\u30C9\u3067\u691C\u7D22",copySuccess:"\u30B3\u30D4\u30FC\u3055\u308C\u307E\u3057\u305F"}};R.mergeLang({"zh-CN":SN,"en-US":LN,"ja-JP":MN});const RN=S("image-data"),v7=1e3,z0=400,ON=10;function kc(n){return n.src.startsWith("empty:")||!n.src}function _N(n){return n.src.startsWith("http:")||n.src.startsWith("https:")}function y7(n){return`${Pd.default(n)}_width`}function k7(n){return`${Pd.default(n)}_height`}function w7(n){return`${n}_flex`}function B7(n){let e=n.getBoundingClientRect().width;return e-=Number.parseFloat(window.getComputedStyle(n).paddingLeft)+Number.parseFloat(window.getComputedStyle(n).paddingRight),e}function ku(n){if(n.every(r=>typeof r.flex=="number"&&r.flex))return;const e=100,o=n.map(r=>{const i=r.height==="auto"?r.width/e:r.height/e;return r.width/i}).reduce((r,i)=>r+i,0);n.forEach(r=>{const i=r.height==="auto"?r.width/e:r.height/e,s=r.width/i;r.flex=s/o})}function wc(n){const e=(r,i)=>{r||(r=`empty:${i}`);const s=y7(r),l=k7(r),a=w7(i);let d=n[s],h=n[l],p=n[a];return typeof d=="string"&&(d=Number.parseInt(d,10)),typeof h=="string"&&(h=Number.parseInt(h,10)),typeof p=="string"&&(p=Number.parseInt(p,10)),d&&h?{src:r,width:d,height:h,flex:p,virtualSize:!1}:d&&!h?{src:r,width:d,height:"auto",flex:p,virtualSize:!1}:(d=v7,h=z0,{src:r,width:d,height:h,flex:p,virtualSize:!0})};let t=[];const o=n.src;return Array.isArray(o)?t=o.map(e):typeof o=="string"&&(t=o.split("|").map(e)),ku(t),t}function Uo(n){const e=n.embedData;return wc(n.embedData).length>1?100:e.widthPercent}function FN(n,e,t,o){const r=wc(e.embedData);if(r.length>1||o)return"100%";const i=Uo(e),s=n.rootContainer.getBoundingClientRect().width;if(i){const l=B7(t);return`${Math.min(s*i/100,l)}px`}return r[0].width?`${r[0].width}px`:"auto"}function cn(n,e){const o={src:n.map(r=>r.src).join("|"),widthPercent:e};return n.forEach((r,i)=>{if(r.width&&r.height&&!r.virtualSize){const l=r.src||`empty:${i}`,a=y7(l);o[a]=r.width;const d=k7(l);r.height!=="auto"&&(o[d]=r.height)}g(RN,r.flex,"no image flex");const s=w7(i);o[s]=r.flex}),o}function PN(n,e,t,o){const r=wc(e.embedData),i=r.length===1?n.rootContainer:t;if(r.length===1&&o)return`${z0}px`;if(r.some(h=>h.height==="auto"))return"auto";const s=Uo(e);if(!s)return"";let l=i.getBoundingClientRect().width*(s/100);if(l-=Number.parseFloat(window.getComputedStyle(i).paddingLeft)+Number.parseFloat(window.getComputedStyle(i).paddingRight),i===n.rootContainer&&i!==t&&(l=Math.min(l,B7(t))),r.length===1){const h=r[0];return h.virtualSize?"":`${h.height/(h.width/l)}px`}l-=(r.length-1)*ON;const a=r.reduce((h,p)=>h+p.flex,0);let d=0;for(const h of r){const A=l*h.flex/a/h.width*h.height;d=Math.max(A,d)}return`${d}px`}function NN(n){return n.reduce((t,o)=>t+o.flex,0)}function $N(n,e){w("div",["resize-gripper",e],n).setAttribute("data-resize-type",e)}function V0(n){return lt(n).querySelector(".block-resizer")}function HN(n){const e=V0(n);e&&te(e,"active")}function E7(n,e,t){const o=n.getBoundingClientRect(),r=e.getBoundingClientRect(),i=r.top-o.top,s=r.left-o.left,l=r.width,a=r.height;t.style.top=`${i}px`,t.style.left=`${s}px`,t.style.width=`${l}px`,t.style.height=`${a}px`}function jN(n,e,t,o){const r=V0(n);if(r)return W(r,"active"),E7(n,e,r),r;const i=lt(n),s=w("div",["block-resizer"],i);return E7(n,e,s),t.resize.forEach(l=>{$N(s,l)}),s.addEventListener("mousedown",o),W(s,"active"),s}function W0(n,e){const t=V0(n);if(!t||!Ke(n,e))return;const o=n.getBoundingClientRect(),r=e.getBoundingClientRect(),i=r.top-o.top,s=r.left-o.left,l=r.width,a=r.height;t.style.top=`${i}px`,t.style.left=`${s}px`,t.style.width=`${l}px`,t.style.height=`${a}px`}const xne="",UN=S("block-resizer");class wu extends bt.TypedEmitter{constructor(t,o){super();m(this,"resizableElement");m(this,"block",null);m(this,"startRect",null);m(this,"startPos",null);m(this,"resizeType",null);m(this,"enabled",!1);m(this,"handleMouseDown",t=>{t.preventDefault(),t.stopPropagation();const o=this.getResizableElement();if(!o||t.button!==0)return;const r=t.target;if(!r||!(r instanceof HTMLElement))return;const i=r.getAttribute("data-resize-type");!i||(this.bindEvents(),this.startRect=o.getBoundingClientRect(),this.startPos=t,this.resizeType=i,pa(window.getComputedStyle(r).cursor),this.block&&this.editor.selection.selectBlock(this.block,0))});m(this,"handleMouseMove",t=>{if(!this.startPos||!this.startRect||!this.resizeType||!this.getResizableElement()||!this.block)return;const r=t.x-this.startPos.x,i=t.y-this.startPos.y,s=this.startRect;let{top:l,left:a,right:d,bottom:h}=s;(this.resizeType==="bottom"||this.resizeType==="bottom-left"||this.resizeType==="bottom-right")&&(h+=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")&&(a+=r),(this.resizeType==="right"||this.resizeType==="top-right"||this.resizeType==="bottom-right")&&(d+=r);const p=d>a?d-a:0,A=h>l?h-l:0,v=new DOMRect(a,l,p,A);this.emit("resizing",this,v);const B=this.getResizableElement();B&&W0(this.block,B)});m(this,"handleMouseUp",t=>{if(t.button!==0)return;pa(""),this.unbindEvents(),this.emit("resized",this);const o=this.getResizableElement();!o||!this.block||W0(this.block,o)});this.editor=t,this.options=o}enableResize(t,o){this.block=t,this.resizableElement=o,this.createResizer(),this.enabled=!0}disableResize(){!this.block||(HN(this.block),this.enabled=!1)}update(t,o){this.block=t,this.resizableElement=o,this.getResizableElement()&&this.enabled&&this.createResizer()}updateResizer(){const t=this.getResizableElement();t&&this.block&&W0(this.block,t)}getBlock(){return this.block}destroy(){}getResizableElement(){return this.resizableElement?this.resizableElement:this.block?Re(this.block):null}createResizer(){const t=this.getResizableElement();!t||!this.block||(g(UN,Ke(this.block,t),"not a block child element"),jN(this.block,t,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)}}const zN=S("image-dom");function x7(n){return n.querySelector(".uploading-progress-mask")}function VN(n){const e=x7(n);if(e)return e;const t=w("div",["uploading-progress-mask"],n),o=w("div",["uploading-progress-bar"],t);return w("div",["uploading-progress-bar-value"],o),o}function WN(n){const t=VN(n).querySelector(".uploading-progress-bar-value");return g(zN,t,"no progress value"),t}function I7(n,e){const t=WN(n);t.style.width=`${e}%`}function qN(n){var e;(e=x7(n))==null||e.remove()}function Bu(n,e,t,o){const r=t!=null?t:n.findBlockById(e.id);if(!r)return;const i=o||ne(r),s=!!r.querySelector(".images > .image-container.error, .images > .image-container.empty "),l=FN(n,e,i,s),a=PN(n,e,i,s),d=Re(r);l==="auto"?d.style.width=l:(d.style.maxWidth=l,d.style.width="100%");const h=r.querySelector(".images");!h||(h.style.height=a||"none")}function GN(n){let e;return n.forEach((t,o)=>{o.toLocaleLowerCase()==="content-type"&&(e=t)}),e!=null?e:""}async function ZN(n){try{const e=await fetch(n,{credentials:"same-origin"}),t=await e.blob(),o=GN(e.headers).toLocaleLowerCase();let r="";if(o){const s=mm.default[o].extensions;s&&s.length>0&&(r=s[0])}return new File([t],`${Date.now()}.${r}`,{type:o})}catch{return null}}function Ki(n,e){const t=typeof e=="string"?e:ie(e);return n.getCustom(`image-${t}`)}function Mf(n,e){if(!e||!(e instanceof Node))return null;const t=oe(e);return t?Ki(n,t):null}function pr(n){return Array.from(n.querySelectorAll(".image-container"))}const q0=S("table-resize-drag-drop");class QN{constructor(e,t,o,r){m(this,"cursor","col-resize");m(this,"initWidths");this.editor=e,this.elem=t,this.data=o,this.mouseDownEvent=r;const i=this.data.block,l=Ki(this.editor,i).getImages(),a=this.data.splitterIndex;g(q0,a>=0&&a<l.length-1,`invalid splitter index: ${a}`);const h=pr(i).map(p=>p.getBoundingClientRect().width);this.initWidths=h}onDragStart(e,t,o){if(!this.editor.isWritable())return;const r=this.data.block;Ki(this.editor,r).setResizing(!0)}onDragging(e,t,o,r,i){const s=this.data.block,l=Ki(this.editor,s),a=me.default(l.getImages()),d=this.data.splitterIndex;g(q0,d>=0&&d<a.length-1,`invalid splitter index: ${d}`);const h=this.initWidths[d],p=this.initWidths[d+1];if(h+p<100)return;let A=r;h+A<50&&(A=50-h),p-A<50&&(A=p-50);const D=[...this.initWidths];D[d]+=A,D[d+1]-=A;const I=pr(s);g(q0,I.length===a.length,"invalid image data");const _=D.reduce((z,q)=>z+q,0);for(let z=0;z<a.length;z++){const q=D[z]/_;a[z].flex=q,I[z].style.flexGrow=`${q}`}const M=me.default(this.editor.getBlockData(s)),H=cn(a,Uo(M));M.embedData=H,Bu(this.editor,M,s,null)}onDragEnd(e,t,o,r,i){const s=this.data.block,l=Ki(this.editor,s),d=pr(s).map(h=>Number.parseFloat(h.style.flexGrow));l.updateFlex(d),l.setResizing(!1)}}function T7(n){var e;return!n||!(n instanceof HTMLElement)?null:xe(n,"image-splitter")?n:(e=n.closest(".image-splitter"))!=null?e:null}function YN(n,e){var s;const t=T7(e.target);if(!t)return;const o=oe(t);if(!o)return;Ki(n,o).setSelectedIndex(-1),n.selection.selectBlock(o,0);const r=Number.parseInt((s=t.getAttribute("data-index"))!=null?s:"",10);if(Number.isNaN(r)||typeof r!="number")return;const i={block:o,splitterIndex:r};wm(new QN(n,t,i,e))}function JN(n,e){e.preventDefault(),e.stopPropagation();const t=T7(e.target);if(!t)return;const o=oe(t);!o||Ki(n,o).resetFlex()}function KN(n,e,t,o){const r=w("div",["image-splitter"],t);w("div",["image-splitter-indicator"],r),r.setAttribute("data-index",`${o}`),n.domEvents.addEventListener(r,"mousedown",YN),n.domEvents.addEventListener(r,"dblclick",JN)}const XN=S("image-item");function D7(n){return!n||!(n instanceof Node)?null:oe(n)}function S7(n){const e=D7(n);return e?pr(e):[]}function G0(n){if(!n||!(n instanceof Node))return null;const e=n instanceof Element?n:n.parentElement;if(!e)return null;const t=e.closest(".image-container");return t||null}function Eu(n){const e=G0(n);return e?S7(n).indexOf(e):-1}async function e$(n,e){const t=Mf(n,e.target);if(!t)return;const o=Eu(e.target);if(o===-1)return;const r=e.target;if(!(r instanceof HTMLImageElement))return;const i=t.getImages()[o];if(kc(i)||n.readonly||!t.isAutoFix()||(setTimeout(()=>{t.setAutoFix(!1)},400),i.height==="auto"&&t.fixImageSize(o,r),i.virtualSize&&t.fixImageSize(o,r),!i||!_N(i)||i.downloading))return;i.downloading=!0;const s=await ZN(i.src);s?t.replaceImage(o,s):XN.warn(`failed to download image: ${i.src}`)}function t$(n,e,t){if(e.querySelector(".load-error"))return;const r=t.src.startsWith("http:")||t.src.startsWith("https:"),i=w("div",["load-error"],e),s=w("div",["error-icon"],i);s.innerHTML=av;const l=w("div",["error-message"],i);r?(l.innerHTML=R.t("image.load.remote.failed"),n.domEvents.addEventListener(i,"click",(a,d)=>{d.preventDefault(),d.target instanceof HTMLElement&&d.target.tagName==="A"&&window.open(t.src,"_blank")})):(l.innerHTML=R.t("image.load.failed"),n.domEvents.addEventListener(i,"click",(a,d)=>{d.preventDefault(),d.stopPropagation(),d.target instanceof HTMLElement&&d.target.tagName==="A"&&i$(a,d.target)}))}function Z0(n,e){setTimeout(()=>{if(Ke(n.rootContainer,e)){const t=n.getBlockData(e);Bu(n,t,null,null)}})}function n$(n,e){const t=Mf(n,e.target);if(!t)return;const o=Eu(e.target);if(o===-1)return;const r=t.getImages()[o];if(!r)return;const i=G0(e.target);if(!i)return;W(i,"error","error-load");const s=oe(i);s&&Z0(n,s),i.innerHTML="",t$(n,i,r)}function o$(n,e,t){if(e.querySelector(".upload-error"))return;const r=w("div",["upload-error"],e),i=w("div",["error-icon"],r);i.innerHTML=av;const s=w("div",["error-message"],r);s.innerHTML=R.t("image.upload.failed"),n.domEvents.addEventListener(r,"click",(l,a)=>{if(a.preventDefault(),!a.target||!(a.target instanceof Element)||a.target.tagName!=="A")return;const d=Mf(l,a.target),h=Eu(a.target);!d||h===-1||d.replaceImage(h,t)})}function L7(n,e,t,o,r){const i=pr(e)[t];!i||(W(i,"error","error-upload"),Z0(n,e),i.innerHTML="",o$(n,i,r))}function M7(n,e,t,o,r,i,s){const l=w("div",["image-container"],t);if(l.setAttribute("data-src",o.src),s.length>1&&(l.style.flexShrink=`${o.flex}`,l.style.flexGrow=`${o.flex}`),i===r&&W(l,"active"),kc(o)){W(l,"empty");const d=w("div",["upload-image-icon"],l);return d.innerHTML=TL,l}const a=w("img",["editor-image"],l);if(a.src=n.doc.buildResourceUrl(o.src),n.domEvents.addEventListener(a,"load",e$),n.domEvents.addEventListener(a,"error",n$),o.src.startsWith("https:")||o.src.startsWith("http:")){const d=w("div",["image-warning"],l);d.innerHTML=cv,d.setAttribute(`data-editor-tooltip-${n.clientId}`,R.t("image.load.remote.tooltip"))}return l}function r$(n,e,t,o,r){const i=w("div",["images"],t);return o.forEach((s,l)=>{l>0&&KN(n,e,i,l-1),M7(n,e,i,s,l,r,o)}),o.length>1&&W(e,"multi"),i}function R7(n,e,t,o,r,i){const l=Array.from(e.querySelectorAll(".image-container"))[o];if(!l)return;const a=M7(n,e,null,t,o,r,i);l.insertAdjacentElement("beforebegin",a),l.remove(),Z0(n,e)}function xu(n,e){return pr(n)[e]}function i$(n,e){const t=D7(e);if(!t)return;const o=Eu(e);if(o===-1)return;const r=Mf(n,e);if(!r)return;const i=r.getImages()[o];R7(n,t,i,o,r.getSelectedIndex(),r.getImages())}function zo(n){return De(n)==="embed"&&Un(n)==="image"}async function O7(n){return new Promise((e,t)=>{const o=new Image;o.onload=()=>{e({width:o.naturalWidth,height:o.naturalHeight})},o.onerror=t,o.src=n})}async function s$(n){const e=await Ul(n);return O7(e)}function _7(n){var o;let e="image/*";const t=(o=n.getComponentOptions("image"))==null?void 0:o.allowedMedias;return t&&(e=t.map(r=>`.${r}`).join(",")),e}function F7(n,e){var s;const{maxSize:t,allowedMedias:o,callbacks:r}=(s=n.getComponentOptions("image"))!=null?s:{};if(t&&e.size>t){const l=new Error("image is too large");throw l.code="MaxMediaSize",r!=null&&r.onError&&(r==null||r.onError(n,l)),l}const i=Aa(e.name);if(o&&!o.includes(i)){const l=new Error(`media file is not allowed: ${i}`);throw l.code="NotAllowedFile",r!=null&&r.onError&&(r==null||r.onError(n,l)),l}}function P7(n){return n.startsWith("image/")}const N7=S("image-object");class wt{constructor(e,t){m(this,"images",[]);m(this,"selectedIndex",-1);m(this,"blockResizer");m(this,"resizing",!1);m(this,"parentContainerResizerObserver",null);m(this,"autoFix",!1);m(this,"handleMouseDown",async(e,t)=>{const o=Eu(t.target);if(o===-1)return;const r=this.images[o];kc(r)||this.setSelectedIndex(o)});m(this,"handleRootContainerResize",()=>{this.handleEditorResize(this.editor.rootContainer)});m(this,"handleEditorResize",e=>{if(this.isEmpty()||this.resizing)return;const t=this.editor.findBlockById(this.blockData.id);!t||ne(t)===e&&Bu(this.editor,this.blockData,t,null)});m(this,"handleResizing",(e,t)=>{const o=this.editor.findBlockById(this.blockData.id);if(!o)return;this.autoFix||this.setAutoFix(!0);const i=this.editor.rootContainer.getBoundingClientRect().width,s=o.getBoundingClientRect();let l=t.width>s.width?s.width:t.width;l<50&&(l=50);const a=l*100/i;this.blockData.embedData.widthPercent=a,Bu(this.editor,this.blockData,o,null)});m(this,"handleResized",e=>{const t=this.editor.findBlockById(this.blockData.id);if(!t)return;const o=cn(this.images,Uo(this.blockData));this.editor.updateEmbedData(t,o),this.blockResizer.enableResize(t)});m(this,"fixImageSizes",Ht.default(()=>{const e=this.editor.findBlockById(this.blockData.id);if(!e)return;const t=cn(this.images,Uo(this.blockData));this.editor.updateEmbedData(e,t)},1e3));this.editor=e,this.blockData=t,this.blockResizer=new wu(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=wc(this.blockData.embedData)}destroy(){var e;this.blockResizer.removeAllListeners(),this.blockResizer.destroy(),this.editor.domEvents.removeEventListener(null,null,this.handleMouseDown),(e=this.parentContainerResizerObserver)==null||e.disconnect()}setAutoFix(e){this.autoFix=e}isAutoFix(){return this.autoFix}createContent(e,t,o){const r=r$(this.editor,t,o,this.images,this.selectedIndex);if(this.editor.domEvents.addEventListener(o,"mousedown",this.handleMouseDown),this.editor.addListener("resize",this.handleRootContainerResize),Do(e)){const s=()=>{this.handleEditorResize(e)};this.parentContainerResizerObserver=new ResizeObserver(s),this.parentContainerResizerObserver.observe(e)}const i=()=>!!(this.images.length===1&&this.images[0].virtualSize);this.isEmpty()&&i()&&W(r,"empty"),Bu(this.editor,this.blockData,t,e),setTimeout(()=>{const s=this.editor.findBlockById(this.blockData.id);s&&this.blockResizer.update(s)})}getImages(){return this.images}getWidthPercent(){return Uo(this.blockData)}isEmpty(){return this.images.length===1&&kc(this.images[0])}setResizing(e){this.resizing=e}getSelectedIndex(){return this.selectedIndex}getBlock(){return this.editor.findBlockById(this.blockData.id)}setSelectedIndex(e){const t=this.getBlock();if(!t||e===this.selectedIndex)return;if(this.selectedIndex!==-1){const r=xu(t,this.selectedIndex);r&&te(r,"active")}this.selectedIndex=e;const o=xu(t,e);o&&W(o,"active")}async requestUploadImage(e){const t=this.editor.findBlockById(this.blockData.id);if(!t)return;const o=xu(t,e);if(xe(o,"error"))return;const r=_7(this.editor),i=await zl(r);await this.replaceImage(e,i)}tryEnableResizer(){const e=this.editor.findBlockById(this.blockData.id);if(!e||!this.editor.isWritable())return;const t=xu(e,0);!this.isEmpty()&&this.images.length===1&&!xe(t,"error")&&this.blockResizer.enableResize(e)}disableResizer(){this.blockResizer.disableResize()}fixImageSize(e,t){const o=this.images[e];kc(o)||(o.height==="auto"&&(o.height=t.height),o.width=t.naturalWidth,o.height=t.naturalHeight,o.virtualSize=!1,this.fixImageSizes())}removeImage(e){const t=this.editor.findBlockById(this.blockData.id);if(!t||e===-1||e>=this.images.length)return!1;const o=me.default(this.images);if(o.splice(e,1),o.length===0)return this.editor.deleteBlock(t),!0;o[0].flex=NaN,ku(o),this.selectedIndex>=o.length&&(this.selectedIndex=o.length-1);const r=cn(o,Uo(this.blockData));return this.editor.updateEmbedData(t,r),!0}async replaceImage(e,t){const o=this.editor.findBlockById(this.blockData.id);if(!o)return!1;try{const i=await Ul(t),s=this.images[e];if(s.virtualSize){const{width:a,height:d}=await O7(i);s.width=a,s.height=d,s.virtualSize=!1;const h=cn(this.images,Uo(this.blockData));this.editor.updateEmbedData(o,h)}const l={...s,src:i};R7(this.editor,o,l,e,this.selectedIndex,this.images),setTimeout(()=>{this.blockResizer.update(o)})}catch(i){return L7(this.editor,o,e,i,t),!1}const r=xu(o,e);if(!r)return!1;W(r,"uploading"),I7(r,0),W(o,"media-block-uploading");try{const i=await this.editor.doc.uploadResource(t,{onProgress:a=>{I7(r,a)}});te(r,"uploading"),this.images[e].src=i.resourceId;const s=this.editor.findBlockById(this.blockData.id);if(!s)return!1;te(s,"media-block-uploading");const l=cn(this.images,Uo(this.blockData));return this.editor.updateEmbedData(s,l),!0}catch(i){N7.error(i);const s=this.editor.findBlockById(this.blockData.id);return s&&(te(r,"uploading"),qN(r),L7(this.editor,s,e,i,t),te(s,"media-block-uploading")),!1}}updateFlex(e){const t=this.editor.findBlockById(this.blockData.id);if(!t)return;g(N7,e.length===this.images.length,"invalid flex");for(let r=0;r<this.images.length;r++)this.images[r].flex=e[r];const o=cn(this.images,Uo(this.blockData));this.editor.updateEmbedData(t,o)}resetFlex(){const e=this.editor.findBlockById(this.blockData.id);if(!e)return;const t=me.default(this.images);t[0].flex=NaN,ku(t);const o=cn(t,Uo(this.blockData));this.editor.updateEmbedData(e,o)}setData(e){this.blockData=e,this.images=wc(e.embedData)}static create(e,t){const o=e.addCustom(`image-${t.id}`,()=>new wt(e,t));return o.setData(t),o}static getImageObject(e,t){let o;return typeof t=="string"?o=t:o=ie(t),e.getCustom(`image-${o}`)}}const Ine="",Tne="";function Rf(n){const e=lt(n);let t=e.querySelector(":scope > .block-helper");return t||(t=w("div",["block-helper"],e),w("span",["helper-sizer"],t,"A")),t}function Q0(n,e,t){const o=Rf(n),i=Array.from(o.children).find(s=>{var a;return Number.parseInt((a=s.getAttribute("data-index"))!=null?a:"0",10)>t});o.insertBefore(e,i!=null?i:null)}const $7=40,l$=20;class c${findTargetBlock(e,t){const o=t.target;if(o&&o instanceof Element){const a=oe(o);if(a&&Ke(e.rootContainer,a))return a}let r=t.clientX,i=t.clientY;const s=e.rootContainer.getBoundingClientRect().left;r<s&&s-r<$7&&(r+=$7);let l=document.elementFromPoint(r,i);if(l){const a=oe(l);if(a&&Ke(e.rootContainer,a))return a}if(i-=l$,l=document.elementFromPoint(r,i),l){const a=oe(l);if(a&&Ke(e.rootContainer,a))return a}return null}destroy(){}}class a$ extends Af{constructor(t){super(t,{trigger:[],id:"empty-block-menu"});m(this,"currentBlock",null)}get isVisible(){return this.suggest.menu.isVisible}isInMenu(t){return this.menu.isInCommandBar(t)}show(){const o=this.editor.selection.focusedBlock;this.suggest.popup(o,0,"","")}setBlock(t){this.currentBlock=t}}function u$(n,e,t){const o=Wm(n,e);if(!o)return[];const r=[];return Object.values(o).forEach(i=>{t!=null&&t.has(i.group)||r.push(...i.commands.map(s=>({...s,source:"block-command",blockMenuItemCustomData:i.group})))}),r}function Y0(n,e,t={withPlainText:!1}){const o=D0(n,t),r=i=>{i.forEach(s=>{s.source=e,s.children&&r(s.children)})};return r(o),o}function d$(n,e,t,o=!1){var d,h;const r=ne(e);let s=be(e);ht(n,e)||o||(s+=1);const l=ae(r),a=t;return a.commandProvider?a.commandProvider.executeCommand(n,t,{from:"block-menu",containerId:l,blockIndex:s}):(h=(d=a.blockOptions)==null?void 0:d.handleInsertEmptyBlock)==null?void 0:h.call(d,n,{containerId:l,blockIndex:s,item:t})}function h$(n,e){const t=Io(n,e),o=n.getBlockData(e);return!(t!=="text"||o.heading)}class H7{constructor(e,t,o){m(this,"source","text-style");m(this,"id","text-style-item");m(this,"name","Text styles");m(this,"element");m(this,"createHeadingItemElement",(e,t,o)=>{var i;const r=B0();this.createItem("text",nu,t,h$(this.editor,e)),(i=r.insertBlockCommandItems)==null||i.forEach(s=>{s.id&&s.icon&&this.createItem(s.id,s.icon,t,o?o===Number(s.value):!1)})});m(this,"createListItemElement",(e,t,o)=>{const{checkbox:r,ordered:i}=o,l=De(e)==="list",a=l&&i===!1&&!r,d=l&&i,h=l&&!!r;this.createItem("unordered-list",gv,t,a),this.createItem("ordered-list",pv,t,d),this.createItem("check-list",fv,t,h)});m(this,"handleClick",(e,t)=>{var l,a;if(!t.target||!(t.target instanceof Node))return;const o=t.target instanceof Element?t.target:t.target.parentElement;if(!o)return;const r=o.closest(".text-style-item");if(!r)return;const i=r.id,s="heading-";if(i==="text"&&pf(e,this.block,null),i.startsWith(s)){const d=Number.parseInt(i.substring(s.length),10);d&&pf(e,this.block,d)}if(i==="blockquote"&&y0(e,this.block),i.startsWith("align")){const d=i.replace(/^align-/,"");x9(e,this.block,d)}(i==="unordered-list"||i==="ordered-list"||i==="check-list")&&w0(e,this.block,i),(a=(l=this.options).onAfterStyleItemClick)==null||a.call(l)});this.editor=e,this.block=t,this.options=o,this.element=this.createItemElement(e,t),e.domEvents.addEventListener(this.element,"click",this.handleClick)}createItemElement(e,t){const o=w("div",["text-styles"],null),r=w("div",["text-style-section"],o),i=e.getBlockData(t);if(!this.options.fromEmbed){const l=i.heading,a=i.quoted;this.createHeadingItemElement(t,r,l),this.createListItemElement(t,r,i),this.createItem("blockquote",mv,r,!!a)}const s=i.align||"left";return this.createItem("align-left",eu,r,s==="left"),this.createItem("align-center",Lp,r,s==="center"),this.createItem("align-right",Sp,r,s==="right"),o}createItem(e,t,o,r=!1){const i=["style-icon","text-style-item"];r&&i.push("active");const s=Hl(t,i,o);s.id=e}}function j7(){return{source:"separator",type:"separator",id:`section-${K()}`,name:""}}const U7={copy:WL,cut:qL,delete:GL,"lock-block":ZL,"unlock-block":QL,comment:tu},f$=["image","video"];function m$(n,e,t){const o=[],r=ee(n,e),i=Lt(e)&&f$.includes(Un(e));if(r?o.push(new H7(n,e,t)):i&&o.push(new H7(n,e,{...t,fromEmbed:!0})),!ht(n,e)){(r||i)&&o.push(j7());const s=u$(n,e,new Set(["hovering-toolbar"]));s.sort((l,a)=>{var d,h;return((d=l.order)!=null?d:0)-((h=a.order)!=null?h:0)}),s.forEach(l=>{l.id in U7&&(l.icon=U7[l.id])}),o.push(...s)}return ht(n,e)?o.push(...Y0(n,"insert-block")):o.push(j7(),{id:"insert-block-before",icon:YL,name:R.t("blockMenu.command.insertAbove"),children:Y0(n,"insert-block-before",{withPlainText:!0}),childrenMenuId:"quick-menu",source:"insert-block-before"},{id:"insert-block-after",icon:JL,name:R.t("blockMenu.command.insertAfter"),children:Y0(n,"insert-block",{withPlainText:!0}),source:"insert-block",childrenMenuId:"quick-menu"}),o}function g$(n,e,t){if(t.source==="block-command"){const o=t.blockMenuItemCustomData;u4(n,e,o,t)}else(t.source==="insert-block"||t.source==="insert-block-before")&&d$(n,e,t,t.source==="insert-block-before")}const p$=S("exclusive-block");function J0(n,e,t,o){var l;W(e,"block-exclusive");const r=Qe(n,e),i=(l=r.getBlockProperties)==null?void 0:l.call(r,n,e),{abstract:s}=i||{};e.setAttribute("data-user-name",o),e.setAttribute("data-user-id",t),e.setAttribute("data-exclusive-tips",R.t("exclusive.tips",{editor:o,embedType:s||R.t("exclusive.fallbackAbstract")}))}function z7(n){te(n,"block-exclusive"),n.removeAttribute("data-user-name"),n.removeAttribute("data-user-id"),n.removeAttribute("data-exclusive-tips")}function C$(n,e,t,o,r){p$.debug(`block ${ie(e)} ${t?"exclusive":"unexclusive"}, ${o}, ${r}`),t?J0(n,e,o,r):z7(e)}function Of(n){return n.classList.contains("block-exclusive")}function V7(n,e){e.blockIds.forEach(t=>{const o=n.findBlockById(t);o&&C$(n,o,e.exclusive,e.userId,e.displayName)})}class Xi{constructor(e){m(this,"exclusiveBlockIds",new Set);m(this,"exclusiveBlockTimer",0);m(this,"remoteExclusiveBlockIds",new Map);m(this,"handleUserChanged",e=>{const t=new Set(e.map(r=>r.userId));Array.from(this.remoteExclusiveBlockIds.entries()).forEach(([r,i])=>{if(!t.has(i.userId)){this.remoteExclusiveBlockIds.delete(r);const s={...i,exclusive:!1};V7(this.editor,s)}});const o=Array.from(this.exclusiveBlockIds).map(r=>this.editor.findBlockById(r)).filter(r=>!!r);o.length>0&&this.broadcastExclusiveBlockMessage(o,!0)});this.editor=e,e.doc.registerCallback(this),e.doc.getRemoteUsers().addListener("change",this.handleUserChanged)}destroy(){this.stopExclusiveBlockTimer(),this.editor.doc.unregisterCallback(this),this.editor.doc.getRemoteUsers().addListener("change",this.handleUserChanged)}onCustomMessage(e){if(e.type==="exclusiveBlock"){const t=e;V7(this.editor,t),t.blockIds.forEach(o=>{t.exclusive?this.remoteExclusiveBlockIds.set(o,t):this.remoteExclusiveBlockIds.delete(o)})}}getExclusiveMessage(e){return this.remoteExclusiveBlockIds.get(e)}broadcastExclusiveBlockMessage(e,t){if(this.editor.readonly||e.length===0)return;const o=this.editor.doc.getUser(),r={type:"exclusiveBlock",userId:o.userId,displayName:o.displayName,blockIds:e.map(i=>ie(i)),exclusive:t};this.editor.doc.broadcastMessage(r)}exclusiveBlock(e){this.exclusiveBlockIds.has(ie(e))||(this.broadcastExclusiveBlockMessage([e],!0),this.exclusiveBlockIds.add(ie(e)),this.exclusiveBlockIds.size===1&&this.startExclusiveBlockTimer())}unexclusiveBlock(e){!this.exclusiveBlockIds.has(ie(e))||(this.exclusiveBlockIds.delete(ie(e)),this.broadcastExclusiveBlockMessage([e],!1),this.exclusiveBlockIds.size===0&&this.stopExclusiveBlockTimer())}startExclusiveBlockTimer(){this.exclusiveBlockTimer=window.setInterval(()=>{Array.from(this.exclusiveBlockIds.keys()).forEach(e=>{this.broadcastExclusiveBlockMessage([this.editor.getBlockById(e)],!0)})},30*1e3)}stopExclusiveBlockTimer(){clearInterval(this.exclusiveBlockTimer),this.exclusiveBlockTimer=0}static get(e){return e.addCustom("exclusiveBlock",()=>new Xi(e))}static register(e){return this.get(e)}}function K0(n,e){Xi.get(n).exclusiveBlock(e)}function X0(n,e){Xi.get(n).unexclusiveBlock(e)}class W7{writable(e,t){if(Of(t))return!1}create(e,t,o,r,i){const s=Xi.get(e).getExclusiveMessage(i.id);s&&J0(e,r,s.userId,s.displayName)}update(e,t,o,r,i){const s=Xi.get(e).getExclusiveMessage(i.id);s?J0(e,r,s.userId,s.displayName):z7(r)}}const Dne="",A$={exclusive:{tips:"\u300C{editor}\u300D\u6B63\u5728\u7F16\u8F91\uFF0C\u300C{embedType}\u300D\u4E0D\u652F\u6301\u591A\u4EBA\u7F16\u8F91",fallbackAbstract:"\u8BE5 Block"}},b$={exclusive:{tips:"\u300C{editor}\u300Dis editing\uFF0C\u300C{embedType}\u300Ddoes not support multi-person editing",fallbackAbstract:"This Block"}},v$={exclusive:{tips:"\u300C{editor}\u300D\u306F\u7DE8\u96C6\u4E2D\u3067\u3059\u3002\u300C{embedType}\u300D\u306F\u8907\u6570\u4EBA\u3067\u540C\u6642\u7DE8\u96C6\u3067\u304D\u307E\u305B\u3093",fallbackAbstract:"\u3053\u306E\u8981\u7D20"}};R.mergeLang({"zh-CN":A$,"en-US":b$,"ja-JP":v$});function Iu(n,e){return n.getBlockData(e).lock}function _f(n,e){return!!Iu(n,e)}function Tu(n,e){const t=Iu(n,e);return t?t.userId===n.doc.getUser().userId:!1}function e2(n,e){const t=Iu(n,e);return t?t.userId!==n.doc.getUser().userId:!1}function y$(n,e){if(n.readonly||!n.isBlockWritable(e)||_f(n,e)&&!Tu(n,e))return;const t=n.doc.getUser(),o={userId:t.userId,displayName:t.displayName,locked:Date.now()},i={...n.getBlockData(e),lock:o};n.updateBlockData(e,i)}function k$(n,e){if(!Tu(n,e))return;const t={lock:null};n.updateBlockData(e,t)}const w$=10,B$=80;class t2{constructor(){m(this,"executeCommand",(e,t,o)=>{const r=o.data;if(!r||!r.blockId)return;const i=e.getBlockById(r.blockId);r.type==="lock"?y$(e,i):r.type==="unlock"&&k$(e,i)})}create(e,t,o,r,i){const s=i.lock;s&&(s.userId!==e.doc.getUser().userId?W(r,"locked-by-others"):W(r,"locked-by-self"))}update(e,t,o,r,i){const s=i.lock;if(s)if(s.userId!==e.doc.getUser().userId){W(r,"locked-by-others");const l=e.selection.focusedBlock;(l===r||Ke(r,l))&&(ee(e,r)||De(r)==="code")&&e.insertTextBlock("",ae(o),be(r)+1)}else W(r,"locked-by-self");else te(r,"locked-by-others"),te(r,"locked-by-self")}writable(e,t){if(e2(e,t))return!1;if(ro(t))return;let o=Is(t);for(;o;){if(e2(e,o))return!1;o=Is(o)}}commands(e,t){const o=_f(e,t),r=Tu(e,t),i=Of(t),s={blockId:ie(t),type:"lock"},l={id:"lock-block",name:"",data:s,order:10};if(o)if(r)l.id="unlock-block",l.name=R.t("locker.unlock"),s.type="unlock";else{const a=Iu(e,t);let d=(a==null?void 0:a.displayName)||"";const h=RC(d,w$,B$);(h==null?void 0:h.length)!==d.length&&(l.ellipsisTooltip=a==null?void 0:a.displayName,d=h||""),l.name=R.t("locker.lockedBy",{name:d}),l.states=["disabled"]}else i?(l.name=R.t("locker.lock"),l.states=["disabled"]):l.name=R.t("locker.lock");return{group:"block-locker",commands:[l],executeCommand:this.executeCommand}}}const Sne="",E$={locker:{lock:"\u9501\u5B9A",unlock:"\u89E3\u9664\u9501\u5B9A",lockedBy:"\u88AB {name} \u9501\u5B9A"}},x$={locker:{lock:"Lock",unlock:"Unlock",lockedBy:"Locked by {name}"}},I$={locker:{lock:"\u30ED\u30C3\u30AF",unlock:"\u30ED\u30C3\u30AF\u89E3\u9664",lockedBy:"{name}\u304C\u30ED\u30C3\u30AF\u3057\u307E\u3057\u305F"}};R.mergeLang({"zh-CN":E$,"en-US":x$,"ja-JP":I$});class Ff{async handleBeforePasteDoc(e,t){return Object.values(t.blocks).forEach(o=>{o.forEach(r=>{delete r.lock})}),!1}}const T$=S("standard-block-actions");class D${constructor(){m(this,"executeCommand",(e,t,o)=>{const r=o.data;try{const i=e.getBlockById(r);if(o.id==="delete"){e.deleteBlock(i);return}o.id==="copy"&&Oh(e,i),o.id==="cut"&&(Oh(e,i),e.deleteBlock(i))}catch(i){T$.error(`failed to execute block command: ${JSON.stringify(i)}`)}})}commands(e,t){const o=_f(e,t),r=o&&Tu(e,t),i=ie(t),s=j0(),l=Of(t),a={id:"copy",name:R.t("blockMenu.command.copy"),data:i,order:1,states:s?[]:["disabled"],disableReason:s?void 0:R.t("copyCutProperty.unsafeEnvTips",{shortCut:Bo("CtrlOrCmd+C"),operation:R.t("copyCutProperty.copy")})},d={id:"cut",name:R.t("blockMenu.command.cut"),data:i,order:2,states:o&&!r||!s||l?["disabled"]:[],disableReason:s?void 0:R.t("copyCutProperty.unsafeEnvTips",{shortCut:Bo("CtrlOrCmd+X"),operation:R.t("copyCutProperty.cut")})},h={id:"delete",name:R.t("blockMenu.command.delete"),data:i,order:3,states:o&&!r||l?["disabled"]:[]};return{group:"standard-block-actions",commands:[a,d,h],executeCommand:this.executeCommand}}}const q7=S("block-menu");class S${constructor(e){m(this,"menu");m(this,"currentBlock",null);m(this,"commandBlock",null);m(this,"handleShow",()=>{g(q7,this.currentBlock,"no target block before show block menu");const e=m$(this.editor,this.currentBlock,{onAfterStyleItemClick:this.close});this.menu.updateItems(e),this.commandBlock=this.currentBlock});m(this,"handleClose",()=>{Fp(this.editor)&&this.editor.focus()});m(this,"handleItemClick",(e,t)=>{g(q7,this.commandBlock,"no command block before show block menu"),g$(this.editor,this.commandBlock,t),t.element||this.close()});m(this,"close",()=>{this.menu.close("clickItem")});this.editor=e,this.menu=new zs([],void 0,{id:"block-menu"}),this.menu.on("show",this.handleShow),this.menu.on("close",this.handleClose),this.menu.on("click",this.handleItemClick),e.blockHooks.push(new D$)}show(e,t){this.menu.manualShow(e,{placement:"bottom-start",...t})}isInMenu(e){return this.menu.isInCommandBar(e)}setBlock(e){this.currentBlock=e}get isVisible(){return this.menu.isVisible}destroy(){this.menu.destroy()}}const L$=1e3;async function M$(n,e){const{width:t}=n.rootContainer.getBoundingClientRect(),o=e.getBoundingClientRect();return o.width>t||o.height>=L$?"":(await Z5.default.toSvg(e)).replace(/margin-block:.*?;/,"").replace(/margin:.*?;/,"")}const R$=S("drag-preview-image");class O${constructor(e){m(this,"startPosition",null);m(this,"dragContainer",null);m(this,"handleDragStart",async(e,t)=>{const o=e.target;g(R$,o instanceof Element,`Invalid Drag target:${o}`);const{x:r,y:i}=e;this.startPosition={x:r,y:i};const s=w("div",["drag-image-container"],this.editor.rootContainer),l=w("img",["drag-image"],s),a=w("span",["drag-loading"],s);a.innerHTML=tM;const{x:d,width:h,height:p,y:A}=o.getBoundingClientRect(),v=this.editor.rootContainer.getBoundingClientRect(),B=t.getBoundingClientRect();s.style.left=`${d+h}px`,s.style.top=`${A+p}px`,s.style.width=`${Math.min(v.width/2,B.width)}px`,this.dragContainer=s;const I=await M$(this.editor,t);I?l.src=I:W(s,"drag-placeholder"),Am(s,{status:"loaded"})});m(this,"handleDrag",e=>{if(this.startPosition&&this.dragContainer){const{x:t,y:o}=e;if(t===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=t-r,l=o-i;this.dragContainer.style.transform=`translate(${s}px, ${l}px)`}});m(this,"handleDragEnd",()=>{this.dragContainer&&(this.dragContainer.remove(),this.startPosition=null,this.dragContainer=null)});this.editor=e}}const G7="drag-preview-element";function _$(n){if(xe(n,G7))return n;const e=n.querySelector(`.${G7}`);return e||(Lt(n)?Re(n):n)}const Pf=S("block-menu-drag-handler");function n2(n,e){return new DragEvent(e,{bubbles:!0,cancelable:!0,view:window,screenX:n.screenX,screenY:n.screenY,dataTransfer:new DataTransfer,clientX:n.clientX,clientY:n.clientY})}class F${constructor(e,t){m(this,"dragPreview");m(this,"autoScroll");m(this,"oldPos",{x:0,y:0});m(this,"handleMouseDown",e=>{const t=this.button.blockMenu.currentBlock;g(Pf,t,"no dragged block"),this.editor.isBlockWritable(t)||(e.preventDefault(),e.stopPropagation());const{x:o,y:r}=e;this.oldPos={x:o,y:r},document.addEventListener("mouseup",this.handleDragEnd),this.editor.contentElement.addEventListener("mousemove",this.handleDrag)});m(this,"handleDragStart",e=>{var s,l;const t=oo(this.button.buttonElement);this.autoScroll||(this.autoScroll=new Zd({scrollElement:t,trackMouseEvent:"mousemove",edge:{top:50,bottom:50}}));const o=this.button.blockMenu.currentBlock;g(Pf,o,"no dragged block"),(l=(s=Qe(this.editor,o)).notify)==null||l.call(s,this.editor,"beginDrag");const r=n2(e,"dragstart");j$(this.editor,r,o),window.isDragging=!0,this.button.buttonElement.style.opacity="0";const i=_$(o);this.dragPreview.handleDragStart(e,i),this.autoScroll.active(),W(o,"dragging"),W(this.editor.contentElement,"dragging")});m(this,"handleDrag",e=>{const{target:t,x:o,y:r}=e;if(this.oldPos.x===o&&this.oldPos.y===r)return;window.isDragging||this.handleDragStart(e),this.oldPos={x:o,y:r},g(Pf,t instanceof Element,"target is invalid"),this.dragPreview.handleDrag(e);const i=n2(e,"dragover");this.editor.contentElement.dispatchEvent(i)});m(this,"handleDragEnd",e=>{var r;const t=this.button.blockMenu.currentBlock;g(Pf,t,"no dragged block"),window.isDragging=!1,this.button.buttonElement.style.opacity="1",this.dragPreview.handleDragEnd(),(r=this.autoScroll)==null||r.inactive(),te(t,"dragging"),te(this.editor.contentElement,"dragging"),document.removeEventListener("mouseup",this.handleDragEnd),this.editor.contentElement.removeEventListener("mousemove",this.handleDrag);const o=n2(e,"drop");this.editor.contentElement.dispatchEvent(o)});this.editor=e,this.button=t,this.button.buttonElement.addEventListener("mousedown",this.handleMouseDown),this.dragPreview=new O$(e)}destroy(){this.button.buttonElement.removeEventListener("mousedown",this.handleMouseDown)}}class Du{constructor(e){m(this,"highlightedBlockId","");m(this,"handleSelectionChange",()=>{this.clearHighlightedBlock()});this.editor=e,this.editor.addListener("selectionChanged",this.handleSelectionChange)}highlightBlock(e){this.clearHighlightedBlock(),this.highlightedBlockId=ie(e),W(e,"highlighted")}clearHighlightedBlock(){if(this.highlightedBlockId){const e=this.editor.findBlockById(this.highlightedBlockId);e&&te(e,"highlighted"),this.highlightedBlockId=""}}destroy(){}static register(e){return e.addCustom("editor-block-highlighter",()=>new Du(e))}static get(e){return e.getCustom("editor-block-highlighter")}}class Z7{constructor(e){m(this,"buttonElement");m(this,"emptyBlockMenu");m(this,"blockMenu");m(this,"dragHandler");m(this,"handleHoverBlock",(e,t,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()}`)),!e){this.buttonElement.parentElement&&(this.blockMenu.isInMenu(o.target)||this.buttonElement.remove());return}const i=Vm(e);this.editor.getBlockIndex(i)===0&&this.editor.getBlockData(i).heading===1||(this.updateButton(i),Q0(i,this.buttonElement,Number.MAX_SAFE_INTEGER))});m(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,{placement:"bottom-end"}),setTimeout(()=>{Du.get(this.editor).highlightBlock(o)});return}const t=this.emptyBlockMenu.currentBlock;!t||(this.editor.selection.selectBlock(t,0),setTimeout(()=>{this.editor.focus(),this.updatePlaceholder(t),this.emptyBlockMenu.show()}))});m(this,"updatePlaceholder",e=>{Re(e).setAttribute("data-content-placeholder",R.t("blockMenu.button.searchPlaceholder"))});m(this,"handleChanged",()=>{const e=this.emptyBlockMenu.currentBlock;if(!e)return;const t=ht(this.editor,e)?"insert":"move";this.buttonElement.getAttribute("data-type")!==t&&this.setButtonType(t)});this.editor=e,this.buttonElement=this.createButton(),this.emptyBlockMenu=new a$(e),this.blockMenu=new S$(e),this.editor.addListener("docChanged",this.handleChanged),this.buttonElement.addEventListener("click",this.handleButtonClick),this.dragHandler=new F$(this.editor,this);const t=pt.get(e);t.addListener("change",this.handleHoverBlock),t.addFinder(new c$),Du.register(this.editor)}destroy(){pt.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 e=w("button",["block-button"],null);return e.setAttribute(`data-editor-tooltip-${this.editor.clientId}`,R.t("blockMenu.button.tips")),e.innerHTML=Cv,e}setButtonType(e){this.buttonElement.setAttribute("data-type",e);const t=`data-editor-tooltip-${this.editor.clientId}-dynamic`;this.buttonElement.hasAttribute(t)&&this.buttonElement.removeAttribute(t),e==="insert"?(this.buttonElement.innerHTML=eM,this.buttonElement.setAttribute(t,R.t("blockMenu.button.insertTips"))):(this.buttonElement.innerHTML=Cv,this.buttonElement.setAttribute(t,R.t("blockMenu.button.tips")))}updateButton(e){this.emptyBlockMenu.setBlock(e),this.blockMenu.setBlock(e),ht(this.editor,e)?this.setButtonType("insert"):this.setButtonType("move")}}const P$={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:"\u5728\u4E0A\u65B9\u63D2\u5165",insertAfter:"\u5728\u4E0B\u65B9\u63D2\u5165",copy:"\u590D\u5236",cut:"\u526A\u5207",delete:"\u5220\u9664"},button:{searchPlaceholder:"\u8F93\u5165\u5173\u952E\u8BCD\u641C\u7D22",tips:`\u957F\u6309\u62D6\u62FD
419
+ \u70B9\u51FB\u6253\u5F00\u83DC\u5355`,insertTips:"\u70B9\u51FB\u6DFB\u52A0\u533A\u5757"}}},N$={blockMenu:{section:{basics:"Basic",system:"System",styles:"Styles",common:"Common",actions:"Actions",thirdParty:"Third-party content"},command:{insertAbove:"Insert above",insertAfter:"Insert below",copy:"Copy",cut:"Cut",delete:"Delete"},button:{searchPlaceholder:"Search",tips:`Hold to drag
420
+ Click to open the menu`,insertTips:"Click to add block"}}},$$={blockMenu:{section:{basics:"\u4E00\u822C",system:"\u30B7\u30B9\u30C6\u30E0",styles:"\u30B9\u30BF\u30A4\u30EB",common:"\u4E00\u822C",actions:"\u64CD\u4F5C",thirdParty:"\u5916\u90E8\u30B3\u30F3\u30C6\u30F3\u30C4"},command:{insertAbove:"\u4E0A\u306B\u633F\u5165",insertAfter:"\u4E0B\u306B\u633F\u5165",copy:"\u30B3\u30D4\u30FC",cut:"\u5207\u308B",delete:"\u524A\u9664"},button:{searchPlaceholder:"\u30AD\u30FC\u30EF\u30FC\u30C9\u3067\u691C\u7D22",tips:"\u3092\u30C9\u30E9\u30C3\u30B0\u3057\u3066\u30AF\u30EA\u30C3\u30AF\u3067\u30E1\u30CB\u30E5\u30FC\u3092\u8868\u793A",insertTips:"\u30AF\u30EA\u30C3\u30AF\u3057\u3066\u30D6\u30ED\u30C3\u30AF\u3092\u8FFD\u52A0"}}};R.mergeLang({"zh-CN":P$,"en-US":N$,"ja-JP":$$});const Lne="";class H${constructor(){m(this,"dragObject",null)}setData(e){this.dragObject=e}getData(){return this.dragObject}clearData(){this.dragObject=null}destroy(){}}function Nf(n){return n.addCustom("drag-data",()=>new H$)}function o2(n,e){if(!e)return null;const t=Nf(n).getData();return!t||t.editorId!==n.id?null:t}function Q7(n,e){const t=o2(n,e);return t?n.findBlockById(t.blockId):null}function j$(n,e,t){if(!e.dataTransfer)return;const r=ne(t),i=ae(r),s=ie(t),l={type:"block",editorId:n.id,containerId:i,blockId:s};Nf(n).setData(l)}function U$(n,e,t,o,r){if(!e.dataTransfer)return;const s=ne(t),l=ae(s),a=ie(t),d={type:"custom",customType:o,editorId:n.id,containerId:l,blockId:a,data:r};Nf(n).setData(d)}function z$(n){Nf(n).clearData()}const V$=S("drop-indicator"),$f=2;class W${constructor(e){m(this,"indicator");m(this,"target",null);this.editor=e,this.indicator=w("div",["editor-drop-indicator"],this.editor.contentElement)}show(e,t){const o=this.getIndicatorRect(e,t),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:e,insertPos:t}}hide(){this.indicator.style.display="none",this.target=null}getIndicatorRect(e,t){if(typeof t!="string")return t.rect;if(t==="before"){const s=Ds(e);if(!s){g(V$,Do(ne(e)),"block does not in a child container");const d=e.getBoundingClientRect();return new DOMRect(d.x,d.y,d.width,$f)}const l=s.getBoundingClientRect(),a=e.getBoundingClientRect();return new DOMRect(l.x,(l.bottom+a.top)/2,l.width,$f)}const o=Ss(e);if(!o){const s=e.getBoundingClientRect();return new DOMRect(s.x,s.bottom,s.width,$f)}const r=e.getBoundingClientRect(),i=o.getBoundingClientRect();return new DOMRect(r.x,(r.bottom+i.top)/2,r.width,$f)}}const q$=S("find-drop-target");function G$(n,e){const t=document.elementFromPoint(n,e);if(!t)return null;if(Fr(t)&&Do(t))return t;const o=t.firstElementChild;return o&&Fr(o)&&Do(o)?o:null}function Z$(n,e){const s=e,l=n;for(let a=0;a<2;a++){const d=l+a*50;for(let h=0;h<5;h++){const p=s+h*8,A=document.elementFromPoint(d,p);if(A){const D=oe(A);if(D)return D}if(h===0)continue;const v=s-h*8,B=document.elementFromPoint(d,v);if(B){const D=oe(B);if(D)return D}}}return null}function Q$(n,e,t){const o=document.elementFromPoint(e,t);if(o){const h=oe(o);if(h&&!Le(n,h))return h}const r=new Set,i=G$(e,t);if(i){const h=i.getBoundingClientRect();t<h.top+h.height/2?r.add(St(i)):r.add(Gt(i))}const s=Z$(e,t);s&&r.add(s);const l=Array.from(r),a=h=>{for(let p=0;p<l.length;p++){const A=l[p];if(h!==A&&Ke(h,A))return!0}return!1},d=l.filter(h=>!a(h));return d.length>0?d[0]:null}function r2(n,e){if(n.readonly)return!1;const t=ne(e);if(Xe(t))return!0;const o=oe(t);return g(q$,o,"no parent block"),n.isBlockWritable(o)?r2(n,o):!1}const Y$=S("drop-target");function J$(n,e){let t={};return/image/.test(e.type)?t=n.editorEmbeds.getEmbedClass("image"):/audio/.test(e.type)?t=n.editorEmbeds.getEmbedClass("audio"):/video/.test(e.type)&&(t=n.editorEmbeds.getEmbedClass("video")),g(Y$,t,`unSupport file type ${e.type}`),t}async function Y7(n,e,t,o){var i,s;let r=o;for(const l of e){const a=J$(n,l);a.getOptions&&await((s=(i=a.getOptions(n)).handleInsertEmptyEmbed)==null?void 0:s.call(i,n,{containerId:t,blockIndex:r,data:{file:l}}))&&(r+=1)}}class K${constructor(e){m(this,"handleDrop",(e,t,o,r)=>{if(Array.isArray(t)){const i=t;if(i.length>0){const s=ae(o);return Y7(e,i,s,r),!0}}return!1});this.editor=e}}class Su{constructor(e){m(this,"indicator");m(this,"lastDropOverResult");m(this,"handlers",[]);m(this,"handleDragOver",e=>{if(!this.editor.isWritable())return;const t=i=>{var d,h;const s=o2(this.editor,i.dataTransfer),l=Q7(this.editor,i.dataTransfer),a=this.findTargetBlock(l,i.x,i.y);if(a&&Ke(this.editor.rootContainer,a)){const p=this.findInsertPos(l,a,i.x,i.y,(h=s!=null?s:(d=i.dataTransfer)==null?void 0:d.items)!=null?h:null);if(p)return this.indicator.show(a,p),"move"}return this.indicator.hide(),"none"},o=(i,s)=>{i.dataTransfer&&(i.dataTransfer.dropEffect=s),s==="move"&&i.preventDefault()};if(this.lastDropOverResult&&e.x===this.lastDropOverResult.x&&e.y===this.lastDropOverResult.y){const i=this.lastDropOverResult.dropEffect;o(e,i);return}const r=t(e);o(e,r),this.lastDropOverResult={x:e.x,y:e.y,dropEffect:r}});m(this,"handleDrop",e=>{var i,s;e.stopPropagation(),setTimeout(()=>{this.indicator.hide()});const t=o2(this.editor,e.dataTransfer),o=Array.from((s=(i=e.dataTransfer)==null?void 0:i.files)!=null?s:[]);if(!t&&o.length===0){e.dataTransfer&&(e.dataTransfer.dropEffect="none");return}const r=this.indicator.target;if(r){const{block:l,insertPos:a}=r,d=Q7(this.editor,e.dataTransfer);this.editor.undoManager.runInGroup(()=>{const h=Qe(this.editor,l);if(h.handleDrop&&h.handleDrop(this.editor,l,t!=null?t:o,a,{isSourceBlock:!1,targetBlock:l})){e.preventDefault(),this.editor.focus();return}if(d){const p=Qe(this.editor,d);if(p.handleDrop&&p.handleDrop(this.editor,d,t!=null?t:o,a,{isSourceBlock:!0,targetBlock:l})){e.preventDefault(),this.editor.focus();return}}if(typeof a=="string"){const p=ne(l);let A=be(l);a==="after"&&(A+=1),e.preventDefault();for(let v=0;v<this.handlers.length;v++)if(this.handlers[v].handleDrop(this.editor,d!=null?d:o,p,A)){this.editor.focus();return}if(d){const v=this.editor.getBlockData(d),B=Fi(this.editor.editorBlocks,this.editor.doc.toJSON(),v),[D]=this.editor.insertDocAt(p,A,B);this.editor.selection.selectBlock(D,0),Du.get(this.editor).highlightBlock(D),this.editor.deleteBlock(d),this.editor.focus()}}}),z$(this.editor)}});m(this,"handleDragLeave",()=>{this.indicator.hide()});this.editor=e,this.indicator=new W$(this.editor),this.handlers.push(new K$(this.editor)),this.editor.contentElement.addEventListener("dragover",this.handleDragOver),this.editor.contentElement.addEventListener("dragleave",this.handleDragLeave),this.editor.contentElement.addEventListener("drop",this.handleDrop)}destroy(){this.editor.contentElement.removeEventListener("dragover",this.handleDragOver),this.editor.contentElement.removeEventListener("dragleave",this.handleDragLeave),this.editor.contentElement.removeEventListener("drop",this.handleDrop),this.handlers=[]}addHandler(e){this.handlers.push(e)}static register(e){return e.addCustom("drop-target",()=>new Su(e))}static get(e){return e.getCustom("drop-target")}static find(e){return e.findCustom("drop-target")}canInsertAfter(e,t){return!(this.editor.readonly||Ss(t)===e&&e||!r2(this.editor,t))}canInsertBefore(e,t){return!(this.editor.readonly||Ds(t)===e&&e||!r2(this.editor,t)||Xe(ne(t))&&be(t)===0)}canDrop(e,t){return e===null||e===t?!0:!Ke(e,t)}findTargetBlock(e,t,o){let r=Q$(this.editor,t,o);if(!r||!Ke(this.editor.rootContainer,r))return null;const i=ne(r),s=oe(i);return s&&De(s)==="code"&&(r=s),this.canDrop(e,r)?r:null}findInsertPos(e,t,o,r,i){let s=t;for(;s;){const a=Qe(this.editor,s);if(a.handleDropOver){const d=a.handleDropOver(this.editor,s,i,o,r);if(d)return d;if(d===!1)return null}s=Is(s)}if(e===t)return"";const l=t.getBoundingClientRect();if(l.top<=r&&r<=l.bottom){if(r<l.top+l.height/2){if(this.canInsertBefore(e,t))return"before";if(this.canInsertAfter(e,t))return"after"}else{if(this.canInsertAfter(e,t))return"after";if(this.canInsertBefore(e,t))return"before"}return""}return r<l.top&&this.canInsertBefore(e,t)?"before":l.bottom<r&&this.canInsertAfter(e,t)?"after":""}}function J7(n,e,t){const o=wt.getImageObject(n,e),r=me.default(o.getImages());if(r.length===1){n.deleteBlock(e);return}if(t===-1||t>=r.length)return;const i=NN(r);if(r.splice(t,1),r.length===1){const l=r[0],a=100*(l.flex/i);l.flex=1;const d=cn([l],a);n.updateEmbedData(e,d);return}r[0].flex=NaN,ku(r);const s=cn(r,o.getWidthPercent());n.updateEmbedData(e,s)}function X$(n,e,t,o){if(e.length===0||o==="after"||o==="before")return!1;let r=o.data;const i=wt.getImageObject(n,t),s=me.default(i.getImages()),l=[],a=[];e.forEach(p=>{P7(p.type)&&s.length+l.length<6?l.push(p):a.push(p)}),l.forEach(p=>{try{F7(n,p)}catch{return}const A={src:"",flex:1,width:0,height:0,virtualSize:!0};s.splice(r,0,A);const v=cn(s,i.getWidthPercent());n.updateEmbedData(t,v),i.replaceImage(r,p),r+=1});const d=n.getBlockIndex(t)+1,h=ae(ne(t));return Y7(n,a,h,d),!0}function eH(n,e,t,o,r){var s,l,a;if(qd(t))return X$(n,t,e,o);if(t.type!=="custom"||t.customType!=="image"||!t.data)return;const i=t.data;if(r.isSourceBlock){const d=r.targetBlock,h=ne(d);let p=be(d);o==="after"&&(p+=1);const v=100*(i.boundingRect.width/n.rootContainer.getBoundingClientRect().width),B=cn([i.image],v),D={id:K(),type:"embed",embedType:"image",embedData:B},I=(l=(s=n.options.componentsOptions)==null?void 0:s.image)==null?void 0:l.defaultAlign;I&&(D.align=I),n.insertBlock(ae(h),p,D),J7(n,e,i.index),(a=n.findCustom("drag-handler"))==null||a.handleDragEnd()}else{if(typeof o=="string")return;const d=e;let h=o.data;const p=wt.getImageObject(n,d),A=me.default(p.getImages());h>A.length&&(h=A.length),n.undoManager.runInGroup(()=>{var B,D;p.setAutoFix(!0);const v=n.getBlockById(t.blockId);if(v===d){const I=i.index,_=h,M=i.image;if(I===_||_===I+1)return;let H=_;I<_?(A.splice(_,0,M),A.splice(I,1),H-=1):(A.splice(I,1),A.splice(_,0,M));const z=cn(A,p.getWidthPercent());n.updateEmbedData(d,z),p.setSelectedIndex(H),(B=n.findCustom("drag-handler"))==null||B.handleDragEnd()}else{A.splice(h,0,i.image),A[0].flex=NaN,ku(A);const I=cn(A,p.getWidthPercent());n.updateEmbedData(d,I),J7(n,v,i.index),(D=n.findCustom("drag-handler"))==null||D.handleDragEnd(),p.setSelectedIndex(h),n.selection.selectBlock(d,0)}})}return!0}const tH=2;function Hf(n,e,t){const o=pr(e);if(t<=0){const s=o[0].getBoundingClientRect();return new DOMRect(s.left-4,s.top,2,s.height)}if(t===o.length){const s=o[t-1].getBoundingClientRect();return new DOMRect(s.right+2,s.top,2,s.height)}const r=o[t-1].getBoundingClientRect(),i=o[t].getBoundingClientRect();return new DOMRect((i.left+r.right)/2-1,r.top,tH,r.height)}function nH(n,e,t,o,r){for(let i=0;i<t.length;i++){const l=t[i].getBoundingClientRect();if(o<=l.right)return o<=l.left+l.width/2?{rect:Hf(n,e,i),data:i}:{rect:Hf(n,e,i+1),data:i+1}}return o>t[t.length-1].getBoundingClientRect().right?{rect:Hf(n,e,t.length),data:t.length}:{rect:Hf(n,e,t.length),data:0}}function oH(n,e,t,o,r){const i=pr(e);if(t instanceof DataTransferItemList){if(!Array.from(t).some(s=>P7(s.type))||i.length>=6)return}else{if((t==null?void 0:t.type)==="block"||i.length>=6&&(t==null?void 0:t.blockId)!==ie(e))return;const s=ie(e);if(i.length===1&&s===(t==null?void 0:t.blockId))return}return nH(n,e,i,o)}async function rH(n){return await Z5.default.toSvg(n)}function i2(n,e){return new DragEvent(e,{bubbles:!0,cancelable:!0,view:window,screenX:n.screenX,screenY:n.screenY,dataTransfer:new DataTransfer,clientX:n.clientX,clientY:n.clientY})}class iH{constructor(e){m(this,"img");m(this,"dragContainer",null);m(this,"autoScroll",null);m(this,"imageContainer",null);m(this,"startPosition",null);m(this,"handleMouseDown",e=>{const t=e.target;if(!t||!(t instanceof HTMLImageElement))return;const o=oe(t);if(!o||!zo(o))return;this.editor.isBlockWritable(o)||(e.preventDefault(),e.stopPropagation());const r=wt.getImageObject(this.editor,o);if(this.imageContainer=G0(e.target),!this.imageContainer)return;const s=S7(e.target).indexOf(this.imageContainer);if(s===-1)return;const l=r.getImages()[s];if(!l)return;const{x:a,y:d}=e;this.startPosition={x:a,y:d};const h={image:l,index:s,boundingRect:this.imageContainer.getBoundingClientRect()},p=i2(e,"dragstart");U$(this.editor,p,o,"image",h),document.addEventListener("mouseup",this.handleDragEnd),this.editor.contentElement.addEventListener("mousemove",this.handleDrag),e.preventDefault()});m(this,"handleDragStart",async e=>{if(!this.imageContainer)return;const t=oe(this.imageContainer);if(!t)return;const o=wt.getImageObject(this.editor,t),i=pr(t).indexOf(this.imageContainer);if(i===-1||!o.getImages()[i])return;const{x:l,y:a}=e,{width:d,height:h}=e.target.getBoundingClientRect(),p=lt(t),A=w("div",["drag-container"],p);A.style.left=`${l-d/4}px`,A.style.top=`${a-h/4}px`,A.style.width=`${Math.max(d/2,16)}px`,A.style.height=`${h/2}px`,this.dragContainer=A;const v=w("img",["drag-target"],A),D=await rH(this.imageContainer);D&&(v.src=D),W(this.editor.contentElement,"dragging");const I=oo(t);this.autoScroll=new Zd({scrollElement:I,trackMouseEvent:"mousemove",edge:{top:50,bottom:50}}),this.autoScroll.active()});m(this,"handleDrag",e=>{var s;const{target:t,x:o,y:r}=e;if(((s=this.startPosition)==null?void 0:s.x)===o&&this.startPosition.y===r)return;if(window.isDragging||(window.isDragging=!0,this.handleDragStart(e)),this.startPosition&&this.dragContainer){const{x:l,y:a}=e;if(l===0&&a===0){this.dragContainer.style.transform="",this.dragContainer.style.opacity="0";return}const{x:d,y:h}=this.startPosition,p=l-d,A=a-h;this.dragContainer.style.transform=`translate(${p}px, ${A}px)`,this.dragContainer.style.opacity="0.5"}const i=i2(e,"dragover");this.editor.contentElement.dispatchEvent(i)});m(this,"handleDragEnd",e=>{var t;if(window.isDragging=!1,this.dragContainer&&this.dragContainer.remove(),this.dragContainer=null,this.startPosition=null,this.imageContainer=null,(t=this.autoScroll)==null||t.inactive(),te(this.editor.contentElement,"dragging"),document.removeEventListener("mouseup",this.handleDragEnd),this.editor.contentElement.removeEventListener("mousemove",this.handleDrag),e){const o=i2(e,"drop");this.editor.contentElement.dispatchEvent(o)}});this.editor=e,this.editor.rootContainer.addEventListener("mousedown",this.handleMouseDown),this.img=new Image,this.img.src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7"}destroy(){this.editor.rootContainer.removeEventListener("mousedown",this.handleMouseDown)}}class sH{constructor(e){m(this,"handleFocusBlockChanged",(e,t,o)=>{const i=this.editor.getFocusedBlock();if(i&&zo(i)){const s=wt.getImageObject(this.editor,i);s.getImages().length>0&&s.getSelectedIndex()===-1&&s.setSelectedIndex(0)}o&&zo(o)&&wt.getImageObject(this.editor,o).blockResizer.disableResize()});this.editor=e,this.editor.addListener("focusBlockChanged",this.handleFocusBlockChanged)}destroy(){this.editor.removeListener("focusBlockChanged",this.handleFocusBlockChanged)}}class lH{constructor(e){m(this,"currentResizer",null);m(this,"handleHoveringBlockChange",(e,t)=>{t&&this.disable(t),e&&(this.currentResizer=e,this.enable(e))});this.editor=e,pt.get(e).addListener("change",this.handleHoveringBlockChange)}destroy(){pt.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}disable(e){zo(e)&&wt.getImageObject(this.editor,e).disableResizer()}enable(e){if(zo(e)){const t=wt.getImageObject(this.editor,e);this.editor.isBlockWritable(e)&&t.tryEnableResizer()}}}const cH={image:{title:"\u56FE\u7247",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">\u56FE\u7247\u52A0\u8F7D\u5931\u8D25</div><div class="line-2">\u8BE5\u56FE\u7247\u6765\u81EA\u5916\u90E8\u94FE\u63A5\uFF0C\u5916\u90E8\u94FE\u63A5\u5DF2\u5931\u6548</div><div class="line-3">\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"}},aH={image:{title:"Image",upload:{failed:'<div class="line-1">Image upload failed</div><div class="line-2">Network error, you can <a href="" class="retry-upload">Retry</a></div>'},load:{failed:'<div class="line-1">Image failed to load</div><div class="line-2">Network error, you can <a href="" class="retry-upload">Retry</a></div>',remote:{failed:'<div class="line-1">Failed to load image</div><div class="line-2">This picture is from an expired external link</div><div class="line-3">Please save the original image to local drives and upload it. <a href="" class="retry-upload">Open image link</a></div>',tooltip:"This picture is from an external link. If the link expires, the picture will not be available. It's recommended to save it to local drives and add it to the page."}},abstract:"Image"}},uH={image:{title:"\u753B\u50CF",upload:{failed:'<div class="line-1">\u753B\u50CF\u3092\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u3067\u304D\u307E\u305B\u3093\u3067\u3057\u305F</div><div class="line-2">\u304A\u4F7F\u3044\u306E\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u306B\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u6B21\u306E\u64CD\u4F5C\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002 <a href="" class="retry-upload">\u518D\u8A66\u884C</a></div>'},load:{failed:'<div class="line-1">\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F</div><div class="line-2">\u304A\u4F7F\u3044\u306E\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u306B\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u6B21\u306E\u64CD\u4F5C\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002 <a href="" class="retry-upload">\u518D\u8A66\u884C</a></div>',remote:{failed:'<div class="line-1">\u753B\u50CF\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F</div><div class="line-2">\u3053\u306E\u753B\u50CF\u306B\u30EA\u30F3\u30AF\u3057\u3066\u3044\u308B URL \u304C\u7121\u52B9\u306B\u306A\u3063\u3066\u3044\u307E\u3059\u306E\u3067\u3001\u8868\u793A\u3067\u304D\u307E\u305B\u3093</div><div class="line-3">\u753B\u50CF\u3092\u30ED\u30FC\u30AB\u30EB\u306B\u4FDD\u5B58\u3057\u3066\u30A2\u30C3\u30D7\u30ED\u30FC\u30C0\u3057\u3066\u304F\u3060\u3055\u3044 <a href="" class="retry-upload">\u753B\u50CF\u30EA\u30F3\u30AF\u3092\u958B\u304F</a></div>',tooltip:"\u3053\u306E\u753B\u50CF\u306F\u5916\u90E8\u306B\u30EA\u30F3\u30AF\u3057\u3066\u3044\u308B\u305F\u3081\u3001\u30EA\u30F3\u30AF\u304C\u7121\u52B9\u306B\u306A\u308B\u3068\u3001\u8868\u793A\u3067\u304D\u306A\u304F\u306A\u308A\u307E\u3059\u306E\u3067\u3001\u30ED\u30FC\u30AB\u30EB\u306B\u4FDD\u5B58\u3057\u3001\u30DA\u30FC\u30B8\u306B\u633F\u5165\u3059\u308B\u3053\u3068\u3092\u304A\u52E7\u3081\u3057\u307E\u3059"}},abstract:"\u753B\u50CF"}};R.mergeLang({"zh-CN":cH,"en-US":aH,"ja-JP":uH});function dH(n,e,t,o){const r=n.getBlockByIndex(e,t),i=n.getBlockText(r),{left:s}=xn(i,o),l=rt(s);let a=o;if(l.endsWith("![]()"))a-=5;else if(l.endsWith("![]"))a-=3;else return!1;const d=o;return zl("image/*").then(h=>{n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(r,a,d-a);let p=t+1;rt(n.getBlockText(r)).trim()?(Yl(n,r,a,{forceInsertAfter:!0}),a===0&&(n.deleteBlock(r),p--)):(n.deleteBlock(r),p--),qm(n,"image",e,p,{file:h})})}),!0}class hH{handleAfterInsertText(e,t,o,r,i){return!!(i===" "&&dH(e,t,o,r))}}function fH(n){const e=n.getFocusedBlock(),t=Ss(e);if(t&&zo(t)){n.selection.selectBlock(t,0);const o=wt.getImageObject(n,t);return o.getImages().length>0&&o.setSelectedIndex(0),!0}}function mH(n){const e=n.getFocusedBlock(),t=Ds(e);if(t&&zo(t)){n.selection.selectBlock(t,0);const o=wt.getImageObject(n,t);return o.getImages().length>0&&o.setSelectedIndex(0),!0}}function gH(n){const t=n.getFocusedBlock();if(t&&zo(t)){const o=wt.getImageObject(n,t),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 pH(n){const t=n.getFocusedBlock();if(t&&zo(t)){const o=wt.getImageObject(n,t),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 s2(n){const t=n.getFocusedBlock();if(t&&zo(t)){const o=wt.getImageObject(n,t);if(o.getImages().length>0){const i=o.getSelectedIndex();if(i!==-1)return o.removeImage(i),!0}}}const CH={ArrowLeft:gH,ArrowRight:pH,ArrowUp:mH,ArrowDown:fH,Delete:s2,Backspace:s2},AH=S("copy-image");function bH(n,e,t,o){const r=t.getImages()[o],i=t.getImages().length===1?t.getWidthPercent():r.flex*100,s=cn([r],i),l={id:K(),type:"embed",embedType:"image",embedData:s},a=n.options.componentsOptions.image;a!=null&&a.defaultAlign&&(l.align=a.defaultAlign);const d={blocks:{root:[l]},comments:{},meta:{}},h=document.createElement("canvas");h.width=e.naturalWidth,h.height=e.naturalHeight;const p=h.getContext("2d");if(!p)return;const A={},v={};try{p.drawImage(e,0,0,h.width,h.height);const z=h.toDataURL("image/png").replace(/^data:image\/(png|jpg);base64,/,""),q=Dm(z),re=new File([q],`${Date.now()}.png`,{type:"image/png"});A["image/png"]=re}catch(H){AH.error(H)}Rh(n,d);const D=`<img src="${n.doc.buildResourceUrl(r.src,{withToken:!0})}" />`,I=Mh(D,d),_=Ma(n,d);A["text/plain"]=new Blob([_],{type:"text/plain"}),v["text/plain"]=_;const M=new Blob([I],{type:"text/html"});return A["text/html"]=M,v["text/html"]=I,[A,v]}function vH(n,e,t,o,r){const i=bH(n,e,t,o);if(!i)return;const[s,l]=i;if(s){const a=Object.entries(s).map(([d,h])=>({type:d,data:h}));return Mm(a).then(d=>{if(!d&&r){const h=r.clipboardData;h&&(h.setData("text/plain",l["text/plain"]),h.setData("text/html",l["text/html"]))}}),!0}}function K7(n,e){const t=n.selection.range;if(t.start.blockId!==t.end.blockId)return;const r=n.getFocusedBlock();if(r&&zo(r)){const i=wt.getImageObject(n,r);if(i.getImages().length>0){const l=i.getSelectedIndex();if(l!==-1){const d=pr(r)[l].querySelector("img");if(d)return vH(n,d,i,l,e)}}}}class yH{constructor(e){this.editor=e,setTimeout(()=>{this.editor.input.addHandler(this)})}handleBeforeCopy(e,t,o){if(K7(e,t))return!0}handleBeforeCut(e,t){if(K7(e,t))return s2(e),!0}destroy(){}}class l2{constructor(e){this.editor=e,setTimeout(()=>{this.editor.input.addHandler(this)})}async handleAfterPasteDoc(e,t,o){return Object.values(t.blocks).forEach(r=>{r.forEach(i=>{if(i.type==="embed"&&i.embedType==="image"){const s=i.embedData;if(Array.isArray(s.src))return;if(s.src.startsWith("https:")||s.src.startsWith("http:")){const l=o.blockIdMap.get(i.id);l&&Ki(e,l).setAutoFix(!0)}}})}),!1}destroy(){}}const kH=S("image-embed");function wH(n,e,t,o,r,i){wt.create(n,t).createContent(r,i,e),n.addCustom("image-select-handler",()=>new sH(n)),n.addCustom("image-copy-handler",()=>new yH(n)),setTimeout(()=>{n.addCustom("drag-handler",()=>new iH(n));const l=n.addCustom("image-resizer",()=>new lH(n)),a=t.embedData;kc(a)?l.disable(i):l.currentResizer===i&&l.enable(i)})}function BH(n,e,t,o){const r=e.embedData,i=wc(r);return o==="html"?i.map(s=>`<img src="${n.doc.buildResourceUrl(s.src,{withToken:!0})}">`).join(""):o==="markdown"?`${i.map(l=>`![img](${n.doc.buildResourceUrl(l.src,{withToken:!0})})`).join(`
421
421
  `)}
422
422
  `:i.map(s=>n.doc.buildResourceUrl(s.src,{withToken:!0})).join(`
423
423
  `)}class EH{constructor(){m(this,"group","image");m(this,"commands",[])}executeCommand(e,t,o){if(o.id==="replace-image"){const{block:r,image:i}=o.data;wt.getImageObject(e,r).replaceImage(0,i)}}}function xH(){return{blockCommands:{image:new EH},abstract:`${R.t("image.abstract")}`}}function IH(){return{name:"Image",insertEmbedCommandItems:[{id:"insert-image",name:R.t("image.abstract"),icon:xL,group:"common",subText:"/image",order:100}],handleInsertEmptyEmbed:async(n,e)=>{var v;let t;(v=e.data)!=null&&v.file&&(t=e.data.file);const o=_7(n);if(t=t!=null?t:await zl(o),!t)return null;try{F7(n,t)}catch{return null}let r={width:v7,height:z0};try{r=await s$(t)}catch(B){kH.error(B)}const i=n.rootContainer.clientWidth,s=r.width<i?Math.min(100,r.width/i*100):100,l={src:"",width:r.width,height:r.height,flex:1,virtualSize:!1},a=cn([l],s),d={id:K(),type:"embed",embedType:"image",embedData:a},h=n.options.componentsOptions.image;h!=null&&h.defaultAlign&&(d.align=h.defaultAlign);const p=n.insertBlock(e.containerId,e.blockIndex,d);return wt.getImageObject(n,p).replaceImage(0,t),p}}}function TH(n,e,t){var h;const{data:o}=t,r=n.getBlockString(e).trim();if(!o||o.embedType!=="image"||!ee(n,e))return null;const i=r.match(/^!\[[^\]]*\]\((?<filename>.*?)(?="|\))(?<optionalPart>".*")?\)/),s=(h=i==null?void 0:i.groups)==null?void 0:h.filename;if(!s)return null;const l={src:s},a={id:K(),type:"embed",embedType:"image",embedData:l};wt.create(n,a).setAutoFix(!0);const d=n.options.componentsOptions.image.defaultAlign;return d&&(a.align=d),{blockData:a}}function DH(n,e){const t=ie(e);n.destroyCustom(`image-${t}`)}const X7={embedType:"image",createEmbedContent:wH,convertTo:BH,convertFrom:TH,getBlockProperties:xH,getOptions:IH,handleDrop:eH,handleDropOver:oH,handleDeleteBlock:DH};class SH{constructor(e,t){m(this,"toolbar");m(this,"anchor",null);m(this,"item");m(this,"docs",null);m(this,"checkedId");m(this,"handlePasteSpecial",(e,t)=>{!t.data||(this.checkedId===t.id?this.checkedId=void 0:this.checkedId=t.id,this.onPasteSpecial(t.data),setTimeout(()=>{this.docs&&this.show(this.docs),this.editor.focus()}))});m(this,"handleClose",()=>{this.editor.focus()});m(this,"handleSelectionChange",()=>{this.hide()});this.editor=e,this.onPasteSpecial=t,this.item={id:"paste-special",name:"",icon:IL,dropdown:!0,manualShowChildren:!0,childrenPlacement:"bottom-start",childrenOffset:[-4,4],children:[]},this.toolbar=new ou([this.item],void 0,{id:"paste-special-button",tooltipId:this.editor.clientId,refuseOverflow:!0}),this.toolbar.addListener("click",this.handlePasteSpecial),this.toolbar.addListener("close",this.handleClose),this.editor.addListener("selectionChanged",this.handleSelectionChange)}show(e){this.docs=e;const t=this.editor,o=t.selection.range;if(!o.isCollapsed())return;const r=t.getBlockById(o.start.blockId);if(!ee(t,r))return;const i=Ti(t,r,o)[0];if(!i)return;this.anchor&&this.anchor.remove(),this.anchor=Li(t,r,"paste-special-button-anchor",i);const s=this.getCommandItems(e);this.item.children=s,this.toolbar.manualShow(this.anchor)}hide(){this.toolbar.close("selectionChange")}clearCheckedState(){this.checkedId=void 0}destroy(){this.toolbar.destroy(),this.editor.removeListener("selectionChanged",this.handleSelectionChange)}getCommandItems(e){const t=i=>({id:i,states:this.checkedId===i?["checked"]:void 0,name:R.t("pasteSpecial.originFormats"),data:e[i]}),o=[];let r=!0;return e["text/x-ones-editor-doc"]?o.push(t("text/x-ones-editor-doc")):e["text/office-html"]?o.push(t("text/office-html")):e["text/html"]?o.push(t("text/html")):e["text/plain"]&&(o.push(t("text/plain")),r=!1),e["text/plain"]&&(r&&o.push({id:"text/plain",states:this.checkedId==="text/plain"?["checked"]:void 0,name:R.t("pasteSpecial.plainText"),data:e["text/plain"]}),o.push({id:"text/markdown",states:this.checkedId==="text/markdown"?["checked"]:void 0,name:R.t("pasteSpecial.markdown"),data:e["text/markdown"]})),o}}const LH=S("paste-special");class c2{constructor(e){m(this,"button");m(this,"lastUndoAction",null);m(this,"event",null);m(this,"handlePasteSpecial",e=>{this.editor.undoManager.runInGroup(()=>{this.editor.undoManager.undoTo(this.lastUndoAction),this.editor.pasteDoc(e)})});this.editor=e,this.button=new SH(e,this.handlePasteSpecial)}destroy(){this.event=null,this.button.destroy()}handleChanged(e,t){this.event=null,this.button.hide()}async handleBeforePaste(e,t){return LH.debug("before paste"),this.lastUndoAction=e.undoManager.lastAction(),!1}async handleAfterPaste(e,t,o){if(Object.keys(o).length<=1)return!1;const r=e.selection.range;if(r.isCollapsed()){const i=e.getBlockById(r.start.blockId);if(!ee(e,i))return!1;this.button.clearCheckedState(),this.button.show(o),this.event=t}return!1}}const MH={pasteSpecial:{originFormats:"\u4FDD\u6301\u539F\u6837\u5F0F",plainText:"\u7C98\u8D34\u7EAF\u6587\u672C",markdown:"\u7C98\u8D34\u4E3A Markdown"}},RH={pasteSpecial:{originFormats:"Keep origin formats",plainText:"Paste as plain text",markdown:"Paste as markdown"}},OH={pasteSpecial:{originFormats:"\u5143\u306E\u30B9\u30BF\u30A4\u30EB\u3092\u7DAD\u6301\u3059\u308B",plainText:"\u30D7\u30EC\u30FC\u30F3\u30C6\u30AD\u30B9\u30C8\u3092\u8CBC\u308A\u4ED8\u3051\u308B",markdown:"Markdown \u3068\u3057\u3066\u8CBC\u308A\u4ED8\u3051"}};R.mergeLang({"zh-CN":MH,"en-US":RH,"ja-JP":OH});const Mne="",_H=S("html-to-doc");function FH(n){const e="ones-editor-doc::",t="::ones-editor-doc";let o=n.indexOf(e);if(o!==-1){o+=e.length;const r=n.indexOf(t,o);if(r!==-1){const i=n.substr(o,r-o);try{const s=zd(i);return JSON.parse(s)}catch(s){_H.error(`invalid doc data: ${s}, ${i}`)}}}return null}const ey="latex-b172fea480b",PH=n=>({name:"latex-block",level:"block",start(e){var t,o;return(o=(t=e.match(/\$\$[^\$]/))==null?void 0:t.index)!=null?o:-1},tokenizer(e,t){const o=/^\$\$([^\$]+)\$\$/.exec(e);return o?{type:"latex-block",raw:o[0],formula:o[1]}:void 0},renderer(e){return n.lazy?`<span class="${ey}" block>${e.formula}</span>`:n.render(e.formula,!0)}}),NH=n=>({name:"latex",level:"inline",start(e){var t,o;return(o=(t=e.match(/\$[^\$]/))==null?void 0:t.index)!=null?o:-1},tokenizer(e,t){const o=/^\$([^\$]+)\$/.exec(e);return o?{type:"latex",raw:o[0],formula:o[1]}:void 0},renderer(e){return n.lazy?`<span class="${ey}">${e.formula}</span>`:n.render(e.formula,!1)}});var $H=(n={})=>(n.lazy&&n.env!=="test"&&new IntersectionObserver((e,t)=>{for(const o of e){if(!o.isIntersecting)continue;const r=o.target;t.unobserve(r),Promise.resolve(n.render(r.innerText,r.hasAttribute("block"))).then(i=>{r.innerHTML=i}),r.classList.add("latex-rendered")}},{threshold:1}),{extensions:[PH(n),NH(n)]});function Bc(n){const e=n.type;if(e==="link")return!!n.tokens.some(Bc);switch(e){case"code":case"table":case"hr":case"blockquote":case"list":case"list_item":case"image":case"paragraph":return!0;default:return!1}}function HH(n){return!Bc(n)}function jH(n){if(n.length===0)return[];if(n.length===1)return[n];const e=[];let t=[n[0]],o=Bc(n[0]);for(let r=1;r<n.length;r++){const i=n[r];o===Bc(i)?t.push(i):(e.push(t),t=[i],o=Bc(i))}return e.push(t),e}function UH(n,e,t){const o=n.href;let r=t.tokensToText(n.tokens,e,t);return r.length===0&&(r=Oi(o,e)),r=dh(r,"link",o),r}let Lu;function a2(n){Lu||(Lu=document.createElement("textarea")),Lu.innerHTML=n;const e=Lu.childNodes.length===0?"":Lu.childNodes[0].nodeValue;return e!=null?e:""}function zH(n,e){const t=a2(n.text);return[lo(t,{...e,"style-code":!0})]}function VH(n,e,t){const r=n.tokens;return r?t.tokensToText(r,e,t):ag(a2(n.text),e)}const WH=S("token-to-text");function u2(n,e,t){return n.map(r=>r.type==="text"?VH(r,e,t):r.type==="strong"?t.tokensToText(r.tokens,{...e,"style-bold":!0},t):r.type==="em"?t.tokensToText(r.tokens,{...e,"style-italic":!0},t):r.type==="del"?t.tokensToText(r.tokens,{...e,"style-strikethrough":!0},t):r.type==="link"?UH(r,e,t):r.type==="codespan"?zH(r,e):r.type==="br"?[{insert:" ",attributes:{id:K(),created:Date.now(),box:!0,type:"br"}}]:r.type==="escape"?ag(a2(r.text),e):r.type==="latex"?[{insert:" ",attributes:{id:K(),created:Date.now(),box:!0,type:"math",tex:r.formula}}]:(WH.warn(`unknown token in text: ${JSON.stringify(r)}`),[])).flat()}function qH(n,e){const t=u2(n.tokens,{},e);return[{id:K(),type:"text",text:t,heading:n.depth}]}function GH(n,e){const{text:t,children:o}=e.tokensToTextWithChildren(n.tokens,e),r=[];return t.length>0&&r.push({id:K(),type:"text",text:t}),r.push(...o),r}function ZH(n,e){const{text:t,children:o}=e.tokensToTextWithChildren([n],e),r=[];return t.length>0&&r.push({id:K(),type:"text",text:t}),r.push(...o),r}function QH(n,e){const t=typeof n.start=="number"?n.start:1,o=n.ordered,r=K(),i=[];return n.items.forEach((l,a)=>{const d={...e,listLevel:e.listLevel+1},{text:h,children:p}=e.tokensToTextWithChildren(l.tokens,d);let A;typeof l.checked=="boolean"&&(A=l.checked?"checked":"unchecked");const v={id:K(),type:"list",groupId:r,ordered:o,checkbox:A,start:t+a,text:h,level:e.listLevel};i.push(v),i.push(...p)}),i}function YH(n,e){const t=e.tokensToBlocks(n.tokens,e);return t.forEach(o=>{o.quoted=!0}),t}const ty=100,JH=20,KH=600;function XH(n,e){const t=e.text;if(t){const o=rt(t);return Math.min(Wd(o,n)+JH,KH)}return ty}function ny(n,e){let t=ty;return e.forEach(o=>{t=Math.max(t,XH(n,o))}),t}function ej(n,e){var l,a;const t=n.header.length,o=n.rows.length+1,r=[],i=Array(t).fill(100);for(let d=0;d<o;d++){let h;d===0?h=n.header:h=n.rows[d-1];for(let p=0;p<t;p++){const A=h[p],v=(l=A==null?void 0:A.tokens)!=null?l:[],B=K();r.push(B);let D;if(v.length===0)D=[fh()];else if(Bc(v[0]))D=e.tokensToBlocks(A.tokens,e),D.length===0&&D.push(fh());else{const{text:I,children:_}=e.tokensToTextWithChildren(A.tokens,e);D=[{id:K(),type:"text",text:I},..._]}e.doc.blocks[B]=D,i[p]=Math.max(i[p],ny((a=e.font)!=null?a:"",D))}}return[{id:K(),type:"table",cols:t,rows:o,colsWidth:i,children:r}]}function tj(n){return[{id:K(),type:"embed",embedType:"hr",embedData:{}}]}function nj(n,e){var a;const t=n.text;if(!t)return[];try{const d=n.text,h=zd(d),p=JSON.parse(h);if(p){const{root:A,...v}=p.blocks;return e.doc.blocks={...e.doc.blocks,...v},A}}catch{}const o=(a=n.lang)!=null?a:"Plain Text";if(o==="mermaid")return[{id:K(),type:"embed",embedType:"mermaid",embedData:{mermaidText:t}}];if(o==="plantuml")return[{id:K(),type:"embed",embedType:"plantuml",embedData:{plantumlText:t}}];if(o==="flow"||o==="flowchart")return[{id:K(),type:"embed",embedType:"flowchart",embedData:{flowchartText:t}}];const i=t.split(`
@@ -469,7 +469,7 @@ ${s}
469
469
  `}})}class Cj{constructor(e){m(this,"_grid",[]);m(this,"_needFixSpanData",!1);Array.from(e.rows).forEach((t,o)=>{Array.from(t.cells).forEach(r=>{this._addCell(o,r)})})}_addCell(e,t){const o=this._getNextColIndex(e),r=t.colSpan,i=t.rowSpan;for(let s=0;s<i;s++)for(let l=0;l<r;l++){const a=e+s,d=o+l;if(this._getCell({row:a,col:d})){this._needFixSpanData=!0,console.warn(`invalid table data, cell data already exists, ${a}, ${d}`);continue}this._setCell({row:a,col:d},{cell:t,virtual:!(l===0&&s===0)})}}_getNextColIndex(e){const t=this._grid[e];if(!t)return 0;let o=0;for(let r=0;r<t.length;r++)if(t[r])o+=1;else return o;return o}_setCell(e,t){if(!(t.cell.colSpan===0||t.cell.rowSpan===0)){for(;this._grid.length<=e.row;)this._grid.push([]);for(let o=0;o<this._grid.length;o++){const r=this._grid[o];for(;r.length<=e.col;)r.push(null)}this._grid[e.row][e.col]=t}}_getCell(e){var o;const t=this._grid[e.row];return t&&(o=t[e.col])!=null?o:null}get rowCount(){return this._grid.length}get colCount(){return this._grid[0].length}getCellData(e){const t=this._getCell(e);return t||null}getCellSpan(e){const t=this._getCell(e);if(!t)return{colSpan:1,rowSpan:1};if(t.virtual)return{colSpan:1,rowSpan:1};const o=()=>{let l=e.col+1;for(;;){const a=this._getCell({row:e.row,col:l});if(!a||a.cell!==t.cell)return l-e.col;l+=1}},r=()=>{let l=e.row+1;for(;;){const a=this._getCell({row:l,col:e.col});if(!a||a.cell!==t.cell)return l-e.row;l+=1}},i=o(),s=r();return i!==t.cell.colSpan&&console.warn(`invalid colSpan: ${i} -> ${t.cell.colSpan}`),s!==t.cell.rowSpan&&console.warn(`invalid rowSpan: ${s} -> ${t.cell.rowSpan}`),{colSpan:i,rowSpan:s}}getColumnWidth(e){const r=Array(this.rowCount).fill(0).map((s,l)=>{const a=this.getCellData({row:l,col:e});if(a&&!a.virtual){const d=a.cell.getAttribute("width")||a.cell.style.width;if(d){if(d.endsWith("%")){const p=d.substr(0,d.length-1),A=Number.parseInt(p,10);if(A>0&&A<=100)return Math.floor(720*A/100)}const h=Number.parseInt(d,10);if(h)return h}return a.cell.getBoundingClientRect().width}return 1e9}),i=Math.min(...r);return i===1e9||Number.isNaN(i)||i<30?0:i}}function Aj(n){return new Cj(n)}function sy(n,e){var a;const t=Aj(n),o=[],r={},i=t.rowCount,s=t.colCount,l=Array(s).fill(100);for(let d=0;d<i;d++)for(let h=0;h<s;h++){let p;const A=t.getCellData({row:d,col:h});if(A&&A.virtual)continue;A&&!A.virtual&&(p=e.htmlToBlocks(A.cell.innerHTML,e)),(!p||p.length===0)&&(p=[{id:K(),type:"text",text:[]}]);const v=K();o.push(v);const{colSpan:B,rowSpan:D}=t.getCellSpan({row:d,col:h});D>1&&(r[`${v}_rowSpan`]=D),B>1&&(r[`${v}_colSpan`]=B),e.doc.blocks[v]=p,A&&!A.virtual&&(l[h]=Math.max(l[h],ny((a=e.font)!=null?a:"",p)))}for(let d=0;d<t.colCount;d++)l[d]=t.getColumnWidth(d)||l[d];return o.length===0?[]:[{cols:t.colCount,rows:t.rowCount,id:K(),type:"table",children:o,...r,colsWidth:l}]}function ly(n,e){var t;if(n.tagName==="TABLE"){const o={blocks:{root:[]},meta:{},comments:{}},r=sy(n,{doc:o,...e});if(r.length===0||((t=r[0].children)==null?void 0:t.length)===0)return;o.blocks.root=r;const i=JSON.stringify(o),s=Bs(i),l=document.createElement("div");l.classList.add("highlight-text-wizdoc");const a=document.createElement("pre");l.appendChild(a),a.innerText=s,n.insertAdjacentElement("beforebegin",l),n.remove();return}Array.from(n.children).forEach(o=>ly(o,e))}function cy(n){if(n instanceof HTMLStyleElement){n.remove();return}Array.from(n.children).forEach(cy)}function ay(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(ay)}function bj(n,e){const t=Vd(n);return t.querySelectorAll("td.js-line-number").forEach(r=>r.remove()),t.querySelectorAll("div.copy-button").forEach(r=>r.remove()),t.querySelectorAll("div.code-copy-button").forEach(r=>r.remove()),t.querySelectorAll("noscript").forEach(r=>r.remove()),Array.from(t.children).forEach(ay),Array.from(t.children).forEach(r=>ly(r,e)),Array.from(t.children).forEach(cy),iy(t),EC(t)}const Yr=new qB.default;Yr.use(uj),Yr.use(dj),Yr.use(hj),Yr.use(fj),Yr.use(mj),Yr.use(gj),Yr.use(pj),Yr.use(MB.gfm);function vj(n,e){const t=uy(n,e);if(!t)return[];const{root:o,...r}=t.blocks;return e.doc.blocks={...e.doc.blocks,...r},o}function uy(n,e){const t=Yr.turndown(n);return ry(t,{htmlToDoc:o=>dy(o,e)})}function dy(n,e){const t=bj(n,{font:e==null?void 0:e.font,htmlToBlocks:vj});return uy(t)}function hy(n){return n.indexOf('xmlns:o="urn:schemas-microsoft-com:office:office"')!==-1}function Uf(n){return["A","B","DEL","I","U","S","SPAN","SUB","SUP","FONT","BR"].indexOf(n.tagName)!==-1}function yj(n){return["P","H1","H2","H3","H4","H5","H6","H7","H8","LI"].indexOf(n.tagName)!==-1}function fy(n){return n.replace(/\r\n\s*/g,"").replace(/\n\s*/g,"").replace(/\r\s*/g,"")}function kj(n){if(!n.tagName)return!1;if(n.tagName.toLocaleLowerCase()==="img")return!0;const e=n.querySelectorAll("img");for(let t=0;t<e.length;t+=1){const o=e[t];if(!o.src||o.getAttribute("width")==="0"||o.getAttribute("height")==="0")return!1}return e.length}function wj(n){return(n.tagName.toLocaleLowerCase()==="img"?[n]:Array.from(n.querySelectorAll("img"))).map(r=>({id:K(),type:"embed",embedType:"image",embedData:{src:r.src,width:r.width,height:r.height}}))}function my(n){var t;return Array.from(((t=n.getAttribute("style"))!=null?t:"").split(" ")).findIndex(o=>o.startsWith("level"))!==-1}function Bj(n){var t;const e=Array.from(((t=n.getAttribute("style"))!=null?t:"").split(" "));for(let o=0;o<e.length;o++){const r=e[o];if(r.startsWith("mso-list:"))return r}return""}function gy(n){var t,o;const e=Array.from(((t=n.getAttribute("style"))!=null?t:"").split(" "));for(let r=0;r<e.length;r++){const i=e[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 Ej(n,e){n.setAttribute("data-group-id",e)}function xj(n){const e={},t=r=>{Array.from(Object.keys(e)).forEach(i=>{Number.parseInt(i,10)>r&&delete e[i]})};let o="";Array.from(n.children).forEach(r=>{if(my(r)){const i=Bj(r);o!==i&&(t(0),o=i);const s=gy(r);t(s);let l=e[`${s}`];l||(l=K(),e[`${s}`]=l),Ej(r,l)}})}function py(n){if(!my(n))return{};const e=gy(n),t=n.getAttribute("data-group-id")||K();return{start:1,level:e,groupId:t,ordered:!0,type:"list"}}const Ij=S("office-list");function Cy(n){return n instanceof HTMLOListElement||n instanceof HTMLUListElement}function Tj(n,e){g(Ij,Cy(n),"not list group element");let t=!1,o=1;const r=K();n instanceof HTMLOListElement&&(t=!0,o=n.start);const i=n,s=[];let l;return Array.from(i.children).forEach(a=>{if(a instanceof HTMLLIElement){const h=py(a),p=e.textElementToBlocks(a,e);l||(l=h.level);const A=p[0];s.push({...A,type:"list",ordered:t,level:l,groupId:r,start:o}),o+=1,s.push(...p.slice(1));return}const d=e.blockElementToBlocks(a,e);s.push(...d)}),s}function Ay(n,e){if(n.nodeName==="META")return[];if(n instanceof HTMLTableElement)return sy(n,e);if(Cy(n))return[...Tj(n,e)];if(kj(n))return[...wj(n)];if(yj(n))return[...e.textElementToBlocks(n,e)];if(!n.children)return[];const t=[];return Array.from(n.children).forEach(o=>{const r=Ay(o,e);t.push(...r)}),t}function by(n,e){const t=[];return n.forEach(o=>{var r;if(o instanceof Element)if(Uf(o)){const i=document.createElement("p");i.appendChild(o);const s=e.blockElementToBlocks(i,e);t.push(...s)}else{const i=e.blockElementToBlocks(o,e);t.push(...i)}else if(o instanceof Text){const i=sr(fy((r=o.textContent)!=null?r:""));t.push(i)}}),t}function vy(n){const e=Array.from(n.children);for(let t=0;t<e.length;t++){const o=e[t];if(!Uf(o))continue;let r=t+1;for(;r<e.length&&Uf(e[r]);)r+=1;const i=document.createElement("p");o.insertAdjacentElement("beforebegin",i);for(let s=t;s<r;s++)i.appendChild(e[s]);t=r-1}}function Dj(n,e){const t=Vd(n);return vy(t),by(Array.from(t.childNodes),e)}function Sj(n){if(!(n instanceof HTMLElement))return{};const e={};if(n.style.textAlign==="right"?e.align="right":n.style.textAlign==="center"&&(e.align="center"),n.style.marginLeft){const t=Math.ceil(Number.parseInt(n.style.marginLeft,10)/20);t>=1&&t<=12&&(e.padding=t)}return e}function Lj(n,e){return e&&Object.keys(e).length>0?{insert:n,attributes:e}:{insert:n}}function Mj(n,e){if(n.nodeName==="B")return{...e,"style-bold":!0};if(n.nodeName==="I")return{...e,"style-italic":!0};if(n.nodeName==="U")return{...e,"style-underline":!0};if(n.nodeName==="S"||n.nodeName==="DEL")return{...e,"style-strikethrough":!0};if(n.nodeName==="SUB")return{...e,"style-sub":!0};if(n.nodeName==="SUP")return{...e,"style-super":!0};if(n.nodeName==="BR")return{...e,created:Date.now(),id:K(),box:!0,type:"br"};if(n.nodeName==="A"&&n.href){const o=n.href;if(o.startsWith("http:")||o.startsWith("https:"))return{...e,link:n.href}}const t={...e};return n instanceof HTMLSpanElement?(n.style.backgroundColor&&(t["inline-style-background-color"]=n.style.backgroundColor),n.style.color&&(t["inline-style-color"]=n.style.color),n.style.fontSize&&(t["inline-style-font-size"]=n.style.fontSize),n.style.fontFamily&&(t["inline-style-font-family"]=n.style.fontFamily),t):e}function yy(n,e,t){var r;if(n instanceof HTMLSpanElement&&n.getAttribute("style")==="mso-list:Ignore")return;const o=Mj(n,e);if(n instanceof Text&&n.nodeValue||n.nodeName==="BR"){const i=fy((r=n.nodeValue)!=null?r:" ");i&&t.push(Lj(i,o));return}n.childNodes.length>0&&Array.from(n.childNodes).forEach(i=>{yy(i,o,t)})}function ky(n){return n instanceof Element?Uf(n):!0}function h2(n){return!ky(n)}function Rj(n){if(n.length===0)return[];if(n.length===1)return[n];const e=[];let t=[n[0]],o=h2(n[0]);for(let r=1;r<n.length;r++){const i=n[r];o===h2(i)?t.push(i):(e.push(t),t=[i],o=h2(i))}return e.push(t),e}function Oj(n,e){const t={};if(n.tagName.startsWith("H")){const i=Number.parseInt(n.tagName.substr(1),10);i>=1&&i<=8&&(t.heading=i)}const o=Rj(Array.from(n.childNodes)),r=[];return o.forEach((i,s)=>{if(ky(i[0])){const l=[],a={};Array.from(n.childNodes).forEach(h=>{yy(h,a,l)});let d={};s===0&&(d=py(n)),r.push({id:K(),type:"text",text:l,...d,...t,...Sj(n)})}i.forEach(l=>{const a=e.blockElementToBlocks(l,e);r.push(...a)})}),r}function _j(n,e){const t=Vd(n);xj(t),vy(t);const o={blocks:{root:[]},meta:{},comments:{}},r={font:e==null?void 0:e.font,doc:o,blockElementToBlocks:Ay,textElementToBlocks:Oj,htmlToBlocks:Dj},i=by(Array.from(t.children),r);if(i.length!==0)return o.blocks.root=i,o}const Fj=S("html-to-doc");function wy(n,e){if(!n)return null;const t=FH(n);if(t)return t;if(hy(n)){const o=_j(n,e);if(o)return o}try{return dy(n,e)}catch(o){Fj.error(o)}return null}class Pj{async fromData(e,t){const o={},r=t.getData("text/html");if(r){const i=wy(r,{font:e.rootContainer});i&&(hy(r)?o["text/office-html"]=i:o["text/html"]=i)}return o}}class Nj{async fromData(e,t){const o=t.getData("text/plain");if(!o)return;const r=ry(o,{font:e.rootContainer,htmlToDoc:wy});if(!!r)return{"text/markdown":r}}}function $j(n){return/^([\d\w\u4e00-\u9fa5\s]*[\u4e00-\u9fa5\s]{1}|)((https|http|ftp)?:\/\/)[^\s]+/.test(n)}function Hj(n){const e=[],t=n.split(/https|http|ftp/)[0],o=n.substring(t.length).trim();if(t&&t.length){const i=lo(t,null);e.push(i,lo(" ",null))}const r=lo(o,{link:o});return e.push(r,lo(" ",null)),e}class jj{async fromData(e,t,o){const{toPlainText:r=!1}=o||{},i={},s=t.getData("text/plain");if(s){const d={blocks:{root:s.replace(/\r\n/g,`
470
470
  `).replace(/\r/g,`
471
471
  `).split(`
472
- `).map(h=>{const p={id:K(),type:"text"};if($j(h)&&!r)return p.text=Hj(h),p;const A=h?[lo(h,null)]:[];return p.text=A,p})},meta:{},comments:{}};i["text/plain"]=d}return i}}function Uj(n){const e=[];for(let t=0;t<n.length;t++){const o=n[t];o.type.toLocaleLowerCase().startsWith("image/")&&e.push(o)}return e}class f2{constructor(e){e.dataConverter.addConverter(new Pj),e.dataConverter.addConverter(new jj),e.dataConverter.addConverter(new Nj)}async handleBeforePaste(e,t,o){if(!t)return!1;const r=t.clipboardData;if(r){if(r.getData("text/html").indexOf("<ones-editor-doc")>0)return!1;const s=Uj(r.files);if(s.length>0&&!o["text/office-html"])return await this.handleInsertImages(e,s),!0}return!1}async handleInsertImages(e,t){const{start:o,end:r}=e.selection.range,i=e.selection.focusedBlock;let s=ne(i),a=be(i);const d=oe(s);if(d&&De(d)==="code")return;if(o.blockId===r.blockId&&Lt(i))a+=1;else{e.clearSelectedContents();const{blockId:p}=e.selection.range.start,A=e.getBlockById(p);a=be(A),s=ne(A),ht(e,A)||(a+=1),Xe(s)&&a===0&&(a+=1)}const h=ae(s);for(let p=0;p<t.length;p++){const A=t[p],v=await qm(e,"image",h,a+p,{file:A});v&&a4(e,v,"image",{id:"replace-image",name:"Replace image",data:{block:v,image:A}})}}}class zj extends bt.TypedEmitter{constructor(e){super(),this.editor=e}onUpdateBlockText(e,t,o){const r=this.editor.getCustom("find-dialog");if(!r||!r.isVisible())return;const i=_r($r(this.editor,e),t);!ee(this.editor,i)||!o.some(l=>l.insert||l.delete)||this.emit("onDocChanged",i)}onInsertBlock(e,t,o,r){_r($r(this.editor,e),t),this.emit("onDocInserted")}onDeleteBlock(e,t,o){const r=_r($r(this.editor,e),t);this.emit("onDocDeleted",r)}}function By(n){return Kt.isSafari&&!!n&&Date.now()-n<100}const Ey=S("highlight-data");class zf{constructor(e){m(this,"data",new Map);this.editor=e}add(e,t,o){const r={id:K(),blockId:ie(e),oldText:this.editor.getBlockText(e),start:t,end:o};return this.data.set(r.id,r),r}get(e){const t=this.data.get(e);return g(Ey,t,`no highligh data: ${e}`),t}remove(e){this.data.delete(e)}clearBlockData(e){Array.from(this.data.values()).forEach(t=>{t.blockId===e&&this.data.delete(t.id)})}destroy(){}static getData(e){return e.addCustom("highligh-data",()=>new zf(e))}}function Vj(n,e,t,o,r){const s=zf.getData(n).add(e,t,o);return r.setAttribute("data-highlight-id",s.id),s}function Vf(n,e){const t=e.getAttribute("data-highlight-id");return g(Ey,t,"invalid highlight elem, no id"),zf.getData(n).get(t)}const Ec=S("highligh-dom");function Wj(n){return xe(n,"editor-highlight")}function Cr(n){const e=n.rootContainer.querySelectorAll(".editor-highlight");return Array.from(e)}function qj(n,e){g(Ec,e,"invalid block");const t=e.querySelectorAll(".editor-highlight");return Array.from(t)}function Gj(n){const e=n.rootContainer.querySelectorAll(".editor-replace-result-highlight");return Array.from(e)}function Wf(n){const e=n.querySelectorAll(".editor-highlight");return Array.from(e)}function Zj(n){Wf(n).forEach(e=>{e.remove()})}function Jr(n){return Cr(n).length}function Qj(n,e){g(Ec,e>=0,`invalid highlight index: ${e}`);const t=Cr(n);return t.length===0?null:(g(Ec,e<t.length,`invalid highlight index: ${e}/${t.length}`),t[e])}function Yj(n,e,{left:t,top:o,width:r,height:i},s){const l=["editor-highlight-child"];s&&l.push("editor-highlight-readonly");const a=w("div",l,n);a.style.top=`${o}px`,a.style.left=`${t}px`,a.style.width=`${r}px`,a.style.height=`${i}px`}function xy(n,e,t,o,r){g(Ec,o>0,`invalid end: ${o}`);const i=lt(e),s=e.getBoundingClientRect(),l=Ti(n,e,yt(n,e,t,o)),d=w("div",[r==="find"?"editor-highlight":"editor-replace-result-highlight"],i);l.forEach(h=>{Yj(d,e,{left:h.left-s.left,width:h.width,top:h.top-s.top,height:h.height})}),Vj(n,e,t,o,d)}function Jj(n,e,t,o){return xy(n,e,t,o,"find")}function Iy(n,e,t,o){return xy(n,e,t,o,"replace")}function qf(n,e){Cr(n).forEach(s=>{xe(s,"active")&&te(s,"active")}),W(e,"active"),g(Ec,e.firstChild instanceof HTMLElement,"invalid highligh dom, invalid elem child");const o=e.firstChild;let i=o.getBoundingClientRect().y;i===0&&(i=o.getBoundingClientRect().y),km(o,{elementToScroll:n.scrollContainer})}function Mu(n){const e=n.rootContainer.querySelector(".editor-highlight.active");return e||null}function Ty(n){return g(Ec,n,"no highlight elem"),xe(n,"editor-highlight-readonly")}const xc=S("highligh-text");function Dy(n){Gj(n).forEach(t=>{t.remove()})}function Gf(n,e){Cr(n).forEach(o=>{o.remove()}),e!=null&&e.keepReplaceResult||Dy(n)}function Sy(n,e,t){qj(n,e).forEach(r=>{r.remove()}),t!=null&&t.keepReplaceResult||Dy(n)}function Ru(n){const e=Mu(n);if(!e)return-1;const o=Cr(n).indexOf(e);return g(xc,o!==-1,`invalid highlight index: ${o}`),o}function Kj(n){const e=Cr(n);if(e.length===0)return 0;const t=Mu(n);let o=t?e.indexOf(t):-1;!t||o===-1||o===e.length-1?o=0:o+=1;const r=e[o];return qf(n,r),o}function Xj(n){const e=Cr(n);if(e.length===0)return 0;const t=Mu(n);let o=t?e.indexOf(t):-1;!t||o===-1||o===0?o=e.length-1:o-=1;const r=e[o];return qf(n,r),o}function m2(n,e){const t=Cr(n);t.length>0&&e<t.length&&qf(n,t[e])}function eU(n,e,t){const o=Mu(n);if(!o)return!1;const r=oe(o);if(g(xc,r,"no parent block"),!n.isBlockWritable(r))return!1;const i=Jr(n);let s=Ru(n);if(!Ty(o)&&n.isBlockWritable(r)){const d=Vf(n,o),h=n.getBlockText(r),{start:p,end:A}=Vf(n,o),[v,B]=ln.transformOffset(d.oldText,h,[p,A]),D=F4(h,v,B-v);if(rt(D).toLowerCase()!==e.toLowerCase())return!1;const I=hh(h,v,B,t);n.setBlockText(r,I),Zj(r),g2(n,r,e),t&&Iy(n,r,v,v+t.length)}const l=Jr(n);s>=l?s=0:l>i&&(s+=1);const a=Qj(n,s);return a&&qf(n,a),!0}function tU(n,e,t,o){if(!ee(n,e)||!n.isBlockWritable(e))return 0;const r=n.getBlockText(e);g(xc,r,"no block text");const i={count:0},s=i6(r,t,o,i);return rt(r)===rt(s)?0:(n.setBlockText(e,s),i.count)}function nU(n,e,t){if(g(xc,Wj(e),"not a highlight elem"),Ty(e))return;g(xc,t>0,"invalid highlight length");const o=Vf(n,e),r=oe(e);g(xc,r,"no parent block"),Iy(n,r,o.start,o.start+t)}function oU(n,e){Cr(n).forEach(o=>{nU(n,o,e)})}function rU(n,e,t){if(n.readonly)return 0;const o=i=>{let s=0;return vt(i).forEach(a=>{Le(n,a)?En(n,a).forEach(h=>{s+=o(h)}):s+=tU(n,a,e,t)}),s},r=o(n.rootContainer);return t.length>0&&oU(n,t.length),r}function iU(n){const e=n.selection.range.end,t=n.getBlockById(e.blockId),o=e.isSimple()?e.offset:1,r=Wf(t);for(let l=0;l<r.length;l++){const a=r[l],{end:d}=Vf(n,a);if(d>=o)return a}const i=og(n,{simpleBlockOnly:!0}),s=i.indexOf(t);if(s===-1)return null;for(let l=s+1;l<i.length;l++){const a=i[l],d=Wf(a);if(d.length>0)return d[0]}return null}function sU(n){const e=Cr(n),t=iU(n);return t?e.indexOf(t):0}function g2(n,e,t){if(!!t&&ee(n,e)){const o=n.getBlockText(e),r=Cg(o,t);r.length>0&&r.forEach(({start:i,end:s})=>{Jj(n,e,i,s)})}}function Ly(n,e){if(Gf(n),!e)return;og(n,{simpleBlockOnly:!0}).forEach(o=>{g2(n,o,e)})}class lU{constructor(e){m(this,"dialog",null);m(this,"root");m(this,"oldText","");m(this,"_compositionEndTime",0);m(this,"components");m(this,"handleFindChanged",()=>{this.doSearch({keepReplaceResult:!1,gotoFirstSearchResult:!0})});m(this,"handleCompositionEnd",()=>{this._compositionEndTime=Date.now(),this.handleFindChanged()});m(this,"handleDocChanged",e=>{setTimeout(()=>{Sy(this.editor,e),g2(this.editor,e,this.components.findInput.value);const t=Jr(this.editor);e.querySelectorAll(".editor-highlight").length===t&&m2(this.editor,0);const o=Ru(this.editor);this.updateSearchStatus(o,t)})});m(this,"handleDocInserted",()=>{const e=setTimeout(()=>{clearTimeout(e),Gf(this.editor,{keepReplaceResult:!0}),Ly(this.editor,this.components.findInput.value);const t=Jr(this.editor),o=Ru(this.editor);this.updateSearchStatus(o,t),m2(this.editor,o)})});m(this,"handleDocDeleted",e=>{const t=setTimeout(()=>{if(!Wf(e).length){clearTimeout(t);return}Sy(this.editor,e);const r=Jr(this.editor),i=Ru(this.editor);this.updateSearchStatus(i,r)})});m(this,"handleInput",e=>{if(e.isComposing||By(this._compositionEndTime)){this.doSearch.cancel();return}this.handleFindChanged()});m(this,"handleFind",()=>{this.findNext({keepSearchResult:!1})});m(this,"handleReplace",()=>{const e=this.components.findInput.value;if(!e||!Mu(this.editor))return;const o=this.components.replaceInput.value;if(e===o)return;if(eU(this.editor,e,o)){const i=Ru(this.editor),s=Jr(this.editor);this.updateSearchStatus(i,s)}this.findNext({keepSearchResult:!0})});m(this,"handleReplaceAll",()=>{const e=this.components.findInput.value;if(!e)return;const t=this.components.replaceInput.value;if(e===t)return;rU(this.editor,e,t)>0&&(this.oldText="",this.doSearchNow({keepReplaceResult:!0,gotoFirstSearchResult:!0}),this.clearFind({keepReplaceResult:!0}))});m(this,"doSearch",Ht.default(this.doSearchNow,300));this.editor=e;const t=w("div",["editor-find-dialog"],null),o=w("div",["editor-find-content"],t),r=w("div",["editor-find-dialog-row"],o),i=Hl(rv,["editor-find-dialog-button-close"],t),s=w("label",["editor-find-dialog-label"],r,R.t("find.findLabel"));s.htmlFor="";const l=w("div",["editor-find-dialog-input-container"],r),a=w("input",["editor-find-dialog-input"],l);a.type="text",a.placeholder=R.t("find.findPlaceholder");const d=w("div",["editor-find-dialog-status"],l),h=Hl(mL,["editor-find-dialog-icon-button"],d),p=w("div",["editor-find-dialog-curr"],d,"0/0"),A=Hl(gL,["editor-find-dialog-icon-button"],d);let v;R.t("find.moreButton")?v=w("button",["editor-find-dialog-button"],r,R.t("find.moreButton")):v=Hl(iv,["editor-find-dialog-icon-button-border"],r);const B=w("div",["editor-find-dialog-row"],o),D=w("label",["editor-find-dialog-label"],B,R.t("find.replaceLabel"));D.htmlFor="";const I=w("div",["editor-find-dialog-input-container"],B),_=w("input",["editor-find-dialog-input"],I);_.type="text",_.placeholder=R.t("find.replacePlaceholder");const M=w("div",["editor-find-dialog-row"],o);w("div",["editor-find-dialog-space"],M);const H=w("button",["editor-find-dialog-button"],M,R.t("find.findButton")),z=w("button",["editor-find-dialog-button"],M,R.t("find.replaceButton")),q=w("button",["editor-find-dialog-button"],M,R.t("find.replaceAllButton"));v.onclick=()=>{this.showReplace()},i.onclick=()=>{this.hide()},a.onkeydown=fe=>{if(fe.isComposing||By(this._compositionEndTime)){this.doSearch.cancel();return}bC(fe)?(this.doSearch.cancel(),this.doSearchNow({keepReplaceResult:!1,gotoFirstSearchResult:!0})):Im(fe)&&this.hide()},a.oninput=this.handleInput,a.onpaste=this.handleFindChanged,a.oncut=this.handleFindChanged,a.addEventListener("compositionend",this.handleCompositionEnd),a.maxLength=50,H.onclick=this.handleFind,z.onclick=this.handleReplace,q.onclick=this.handleReplaceAll,_.maxLength=50,A.onclick=()=>{this.gotoNext()},h.onclick=()=>{this.gotoPrev()},this.components={findInput:a,findPrev:h,findCurrent:p,findNext:A,replaceInput:_,findButton:H,replaceButton:z,replaceAllButton:q,closeButton:i,showReplaceButton:v,rowReplace:B,rowActions:M,statusContainer:d},this.root=t;const re=new zj(e);e.doc.registerCallback(re),re.addListener("onDocChanged",this.handleDocChanged),re.addListener("onDocInserted",this.handleDocInserted),re.addListener("onDocDeleted",this.handleDocDeleted)}findNext(e){this.doSearch.cancel(),this.doSearchNow({keepReplaceResult:e.keepSearchResult,gotoFirstSearchResult:!0})}doSearchNow(e){const t=this.components.findInput.value;if(t||this.clearFind(e),this.oldText===t){this.gotoNext();return}this.oldText=t,Ly(this.editor,t);const o=Jr(this.editor),r=sU(this.editor);e.gotoFirstSearchResult&&m2(this.editor,r),this.updateSearchStatus(r,o)}gotoNext(){const e=Jr(this.editor),t=Kj(this.editor);this.updateSearchStatus(t,e)}gotoPrev(){const e=Jr(this.editor),t=Xj(this.editor);this.updateSearchStatus(t,e)}updateSearchStatus(e,t){if(this.oldText?this.components.statusContainer.style.display="flex":this.components.statusContainer.style.display="none",t===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=`${e+1}/${t}`;const o=this.editor.readonly;this.components.replaceAllButton.disabled=o,this.components.replaceButton.disabled=o,this.components.findButton.disabled=!1}}clearFind(e){Gf(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(e){const t=this.editor.getSelectedText();t.length>0&&t.length<50&&(this.components.findInput.value=t),this.root.style.display="flex",e!=null&&e.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 ru(this.root,{disablePageScroll:!1}));const r=this.editor.options.componentsOptions.findDialog,i=(r==null?void 0:r.popoverTarget)||this.editor.rootContainer,s=()=>{var p,A,v,B;const l=r==null?void 0:r.getReferenceClientRect;if(l&&((A=(p=this.dialog)==null?void 0:p.tippyInstance)==null?void 0:A.popper))return l(i,(B=(v=this.dialog)==null?void 0:v.tippyInstance)==null?void 0:B.popper);const a=i.getBoundingClientRect(),d=a.top<0?12:a.top+12,h=a.right-this.root.clientWidth-12;return new DOMRect(h,d,0,0)};this.dialog.show(i,{getReferenceClientRect:s}),setTimeout(()=>{this.components.findInput.focus(),this.components.findInput.select()},300)}hide(){var e;(e=this.dialog)==null||e.close("cancelBar"),Gf(this.editor)}isVisible(){return this.dialog&&this.dialog.isVisible}research(){this.oldText="",this.doSearch({keepReplaceResult:!0,gotoFirstSearchResult:!1})}destroy(){var e;(e=this.dialog)==null||e.destroy()}}const cU={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"}},aU={find:{findLabel:"Find:",replaceLabel:"Replace:",findButton:"Find",replaceButton:"Replace",replaceAllButton:"Replace All",moreButton:"",findPlaceholder:"Find text in document",replacePlaceholder:"Replace to"}},uU={find:{findLabel:"\u691C\u7D22\uFF1A",replaceLabel:"\u7F6E\u63DB\uFF1A",findButton:"\u691C\u7D22",replaceButton:"\u7F6E\u63DB",replaceAllButton:"\u3059\u3079\u3066\u3092\u7F6E\u63DB",moreButton:"",findPlaceholder:"\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u691C\u7D22",replacePlaceholder:"\u306B\u7F6E\u63DB"}};R.mergeLang({"zh-CN":cU,"en-US":aU,"ja-JP":uU});function My(n){return n.addCustom("find-dialog",()=>new lU(n)).show(),!0}const Ry={"CtrlOrCmd+F":My},Rne="";function dU(n){My(n)}function p2(n,e){return e.map(t=>{var i,s;const o=Qe(n,t),r=(i=o.getBlockProperties)==null?void 0:i.call(o,n,t);return Lt(t)||Le(n,t)?r!=null&&r.abstract?`[${r.abstract}]`:"":(s=r==null?void 0:r.abstract)!=null?s:""}).join(" ")}function Zf(n){const{editor:e,commentGroupId:t,abstract:o="text"}=n,r=K(),i=e.doc.getUser(),s=Date.now(),l=t!=null?t:r;return{id:r,groupId:l,userId:i.userId,displayName:i.displayName,avatarUrl:i.avatarUrl,abstract:o,created:s,modified:s}}function Oy(n,e,t){const o=t.id,i=n.getBlockData(e).comments;let s;i?s=[...i,o]:s=[o];const l={comments:s};n.updateBlockData(e,l)}function C2(n,e,t){const o=p2(n,[e]),r=Zf({editor:n,abstract:o});Oy(n,e,r);const i=Ur();return t.localCreateComment(r,i),r}const hU=S("standard-block-actions");class fU{constructor(e,t){m(this,"executeCommand",(e,t,o)=>{const r=o.data;try{this.editorComments.showCommentList();const i=e.getBlockById(r);C2(e,i,this.provider)}catch(i){hU.error(`failed to execute block command: ${JSON.stringify(i)}`)}});this.provider=e,this.editorComments=t}commands(e,t){const o=ie(t);return{group:"block-comment-actions",commands:[{id:"comment",name:R.t("comment.quickMenuCommand"),data:o,order:100,states:e.readonly?["disabled"]:[]}],executeCommand:this.executeCommand}}}class mU{async handleBeforePasteDoc(e,t){return Object.values(t.blocks).forEach(o=>{o.forEach(r=>{delete r.comments,r.text&&r.text.forEach(i=>{if(i.attributes){const s=i.attributes;Object.keys(s).forEach(l=>{l.startsWith("comment-")&&delete s[l]})}})})}),!1}}var Ye=(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))(Ye||{});const A2="group-item-action",_y="last-comment-item",Kr="disabled",Fy=500;function Js(n){return n.id!==n.groupId}function Py(n,e=".comment-item-root"){return n.querySelectorAll(e).length}function gU(n){const e=n.closest(".comment-item-root");return e?e.id:null}function Xr(n,e){n.setAttribute(A2,e)}function pU(n){return n.closest(`[${A2}]`)}function CU(n){var e;return(e=n.getAttribute(A2))!=null?e:""}function AU(n){return xe(n,Kr)}function Ny(n,e){const t=n.rootContainer.querySelector(`[comment-${e.toLocaleLowerCase()}=${e}`);if(!t)return null;const o=t.closest('[data-type="editor-block"]');return o?o.id:null}function $y(n){return Array.from(n.attributes).map(t=>t.name).filter(t=>t.startsWith("comment-")).map(t=>t.replace("comment-",""))}const Hy=S("doc-comments");function jy(n,e,t,o){if(e.comments){const i=e.comments;Array.isArray(i)&&i.forEach(s=>{o.has(s)||(o.add(s),t.push(s))})}e.text&&e.text.forEach(s=>{if(s.attributes){const l="comment-";Object.entries(s.attributes).forEach(([a,d])=>{if(a.startsWith(l)){const h=d;o.has(h)||(o.add(h),t.push(h))}})}});const r=e.children;!r||r.forEach(i=>{n.blocks[i].forEach(l=>{jy(n,l,t,o)})})}function bU(n){const e=[],t=new Set;n.blocks.root.forEach(r=>{jy(n,r,e,t)});const o=new Map;return e.forEach((r,i)=>o.set(r,i)),o}function vU(n){const e=new Map;n.forEach(r=>{if(Js(r)){const i=e.get(r.groupId);i?i.push(r):e.set(r.groupId,[r])}});const t=[];return n.forEach(r=>{var i;if(!Js(r)){const s=(i=e.get(r.id))!=null?i:[];e.delete(r.id);const l={...r,children:s};t.push(l)}}),Array.from(e.values()).forEach(r=>{const i=r[0],s=r.slice(1),l={...i,children:s};t.push(l)}),t}function es(n,e){const t=n.doc.toJSON(),o=bU(t);return vU(e.getComments()).filter(s=>o.has(s.groupId)).sort((s,l)=>{const a=o.get(s.groupId),d=o.get(l.groupId);return g(Hy,a!==void 0,`comment not exists in doc, ${s.groupId}`),g(Hy,d!==void 0,`comment not exists in doc, ${l.groupId}`),a-d})}function b2(n){const{children:e,...t}=n,o=[t];return e.forEach(r=>{o.push(r)}),o}function yU(n,e){return es(n,e).map(b2).reduce((r,i)=>i.length+r,0)}function v2(n,e){const t=[],o=n.getBlockById(e.blockId);if(ee(n,o)){const i=e.blockId,s=e.offset,l=n.getBlockById(i),a=n.getBlockText(l),d=Ta(a,s);d&&Object.entries(d).forEach(([h,p])=>{h.startsWith("comment-")&&t.push(p)})}const r=o.attributes;for(let i=0;i<r.length;i++){const s=r[i];s.name.startsWith("comment-")&&t.push(s.value)}return t}function Uy(n){const e=n.selection.range;if(!e.isSimple())return[];if(e.start.blockId!==e.end.blockId)return[];if(e.isCollapsed())return v2(n,e.start);const{start:t,end:o}=e,r=v2(n,t),i=v2(n,o);return fm.default(r,i)}const kU=S("active-comments");function zy(n,e){n.rootContainer.querySelectorAll(`span.text.comment[comment-${e}],[data-type=editor-block].comment[comment-${e}]`).forEach(o=>{te(o,"active")})}function Vy(n,e){const t=n.rootContainer.querySelector("span.text.comment.active,[data-type=editor-block].comment.active");if(!e)t&&$y(t).forEach(r=>zy(n,r));else{const o=e.toLocaleLowerCase();if(t){const i=$y(t);if(i.length===1&&i[0]===o)return;i.forEach(s=>zy(n,s))}const r=n.rootContainer.querySelectorAll(`span.text.comment[comment-${o}],[data-type=editor-block].comment[comment-${o}]`);if(r){r.forEach(s=>{W(s,"active")});const i=r[0];if(xs(i))n.selection.selectBlock(i,0);else if(Uy(n).indexOf(e)===-1){const l=oe(i);g(kU,l,"block not found");const a=Mi(l,i);n.selection.selectBlock(l,a.start)}n.focus()}}}const One="";S("comment-editor");const{t:wU}=R,y2="comment-editor-readonly",Ou="comment-editor-editing";class k2{constructor(e,t,o){m(this,"root");m(this,"components");m(this,"handleEditorBlur",()=>{this.inactiveEditor()});m(this,"handleEditorFocus",()=>{this.editor.readonly||this.activeEditor()});m(this,"activeEditor",()=>{xe(this.root,Ou)||W(this.root,Ou)});m(this,"inactiveEditor",()=>{te(this.root,Ou)});m(this,"handleInsertImg",async()=>{const{editor:e}=this.components,t=ae(e.rootContainer),o=await zl("image/*",{}),r={src:"",widthPercent:50},i={id:K(),type:"embed",embedType:"image",embedData:r},s=e.options.componentsOptions.image;s!=null&&s.defaultAlign&&(i.align=s.defaultAlign);const l=e.getFocusedBlock(),a=e.getBlockIndex(l),d=e.insertBlock(t,a+1,i);wt.getImageObject(e,d).replaceImage(0,o)});m(this,"handleReadonlyChange",e=>{e.readonly?(te(this.root,Ou),W(this.root,y2)):(W(this.root,Ou),te(this.root,y2))});m(this,"setDoc",e=>{const{components:{editor:t}}=this;t.doc.externalDoc.setDoc(e)});m(this,"getDoc",()=>{const{components:{editor:e}}=this;return e.doc.toJSON()});m(this,"isEmpty",()=>Ag(this.getDoc()));m(this,"edit",()=>{const{editor:e}=this.components;e.readonly=!1,_A(e),this.activeEditor()});m(this,"clear",()=>{const e=Ur();this.setDoc(e)});m(this,"readonly",()=>{const{editor:e}=this.components;e.readonly=!0});m(this,"destroy",()=>{const{root:e,components:{editor:t,insertImgButton:o}}=this;o.onclick=null,t.destroy(),e.remove()});this.mainEditor=e,this.commentsProvider=t,this.doc=o,this.root=w("div",["comment-editor",y2],null),this.components=this.createEditor()}createEditor(){const e=w("div",["comment-editor-root"],this.root),{commentsProvider:t,mainEditor:o}=this,r=t.createCommentEditor(e,new np(this.doc));r.readonly=!0,r.addListener("readonlyChanged",this.handleReadonlyChange),r.addListener("focus",this.handleEditorFocus),r.addListener("blur",this.handleEditorBlur);const i=Qs(this.root,"comment-editor-img",wU("comment.image"),EL,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 BU{constructor(e){m(this,"handleBeforeKeyDown",(e,t)=>{if(Or(t,"Enter")){const{quickReply:o,updateLastCommentItem:r}=this.groupItem;return o.getReplyEditor().isEmpty()?(o.hideReplyEditor(),!0):(o.reply(),r(),!0)}return!1});this.groupItem=e}}class EU{constructor(e,t,o){m(this,"handleBeforeKeyDown",(e,t)=>{if(Or(t,"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=e,this.groupItem=t,this.commentItem=o}}const xU=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
472
+ `).map(h=>{const p={id:K(),type:"text"};if($j(h)&&!r)return p.text=Hj(h),p;const A=h?[lo(h,null)]:[];return p.text=A,p})},meta:{},comments:{}};i["text/plain"]=d}return i}}function Uj(n){const e=[];for(let t=0;t<n.length;t++){const o=n[t];o.type.toLocaleLowerCase().startsWith("image/")&&e.push(o)}return e}class f2{constructor(e){e.dataConverter.addConverter(new Pj),e.dataConverter.addConverter(new jj),e.dataConverter.addConverter(new Nj)}async handleBeforePaste(e,t,o){if(!t)return!1;const r=t.clipboardData;if(r){if(r.getData("text/html").indexOf("<ones-editor-doc")>0)return!1;const s=Uj(r.files);if(s.length>0&&!o["text/office-html"])return await this.handleInsertImages(e,s),!0}return!1}async handleInsertImages(e,t){const{start:o,end:r}=e.selection.range,i=e.selection.focusedBlock;let s=ne(i),a=be(i);const d=oe(s);if(d&&De(d)==="code")return;if(o.blockId===r.blockId&&Lt(i))a+=1;else{e.clearSelectedContents();const{blockId:p}=e.selection.range.start,A=e.getBlockById(p);a=be(A),s=ne(A),ht(e,A)||(a+=1),Xe(s)&&a===0&&(a+=1)}const h=ae(s);for(let p=0;p<t.length;p++){const A=t[p],v=await qm(e,"image",h,a+p,{file:A});v&&a4(e,v,"image",{id:"replace-image",name:"Replace image",data:{block:v,image:A}})}}}class zj extends bt.TypedEmitter{constructor(e){super(),this.editor=e}onUpdateBlockText(e,t,o){const r=this.editor.getCustom("find-dialog");if(!r||!r.isVisible())return;const i=_r($r(this.editor,e),t);!ee(this.editor,i)||!o.some(l=>l.insert||l.delete)||this.emit("onDocChanged",i)}onInsertBlock(e,t,o,r){_r($r(this.editor,e),t),this.emit("onDocInserted")}onDeleteBlock(e,t,o){const r=_r($r(this.editor,e),t);this.emit("onDocDeleted",r)}}function By(n){return Kt.isSafari&&!!n&&Date.now()-n<100}const Ey=S("highlight-data");class zf{constructor(e){m(this,"data",new Map);this.editor=e}add(e,t,o){const r={id:K(),blockId:ie(e),oldText:this.editor.getBlockText(e),start:t,end:o};return this.data.set(r.id,r),r}get(e){const t=this.data.get(e);return g(Ey,t,`no highligh data: ${e}`),t}remove(e){this.data.delete(e)}clearBlockData(e){Array.from(this.data.values()).forEach(t=>{t.blockId===e&&this.data.delete(t.id)})}destroy(){}static getData(e){return e.addCustom("highligh-data",()=>new zf(e))}}function Vj(n,e,t,o,r){const s=zf.getData(n).add(e,t,o);return r.setAttribute("data-highlight-id",s.id),s}function Vf(n,e){const t=e.getAttribute("data-highlight-id");return g(Ey,t,"invalid highlight elem, no id"),zf.getData(n).get(t)}const Ec=S("highligh-dom");function Wj(n){return xe(n,"editor-highlight")}function Cr(n){const e=n.rootContainer.querySelectorAll(".editor-highlight");return Array.from(e)}function qj(n,e){g(Ec,e,"invalid block");const t=e.querySelectorAll(".editor-highlight");return Array.from(t)}function Gj(n){const e=n.rootContainer.querySelectorAll(".editor-replace-result-highlight");return Array.from(e)}function Wf(n){const e=n.querySelectorAll(".editor-highlight");return Array.from(e)}function Zj(n){Wf(n).forEach(e=>{e.remove()})}function Jr(n){return Cr(n).length}function Qj(n,e){g(Ec,e>=0,`invalid highlight index: ${e}`);const t=Cr(n);return t.length===0?null:(g(Ec,e<t.length,`invalid highlight index: ${e}/${t.length}`),t[e])}function Yj(n,e,{left:t,top:o,width:r,height:i},s){const l=["editor-highlight-child"];s&&l.push("editor-highlight-readonly");const a=w("div",l,n);a.style.top=`${o}px`,a.style.left=`${t}px`,a.style.width=`${r}px`,a.style.height=`${i}px`}function xy(n,e,t,o,r){g(Ec,o>0,`invalid end: ${o}`);const i=lt(e),s=e.getBoundingClientRect(),l=Ti(n,e,yt(n,e,t,o)),d=w("div",[r==="find"?"editor-highlight":"editor-replace-result-highlight"],i);l.forEach(h=>{Yj(d,e,{left:h.left-s.left,width:h.width,top:h.top-s.top,height:h.height})}),Vj(n,e,t,o,d)}function Jj(n,e,t,o){return xy(n,e,t,o,"find")}function Iy(n,e,t,o){return xy(n,e,t,o,"replace")}function qf(n,e){Cr(n).forEach(s=>{xe(s,"active")&&te(s,"active")}),W(e,"active"),g(Ec,e.firstChild instanceof HTMLElement,"invalid highligh dom, invalid elem child");const o=e.firstChild;let i=o.getBoundingClientRect().y;i===0&&(i=o.getBoundingClientRect().y),km(o,{elementToScroll:n.scrollContainer})}function Mu(n){const e=n.rootContainer.querySelector(".editor-highlight.active");return e||null}function Ty(n){return g(Ec,n,"no highlight elem"),xe(n,"editor-highlight-readonly")}const xc=S("highligh-text");function Dy(n){Gj(n).forEach(t=>{t.remove()})}function Gf(n,e){Cr(n).forEach(o=>{o.remove()}),e!=null&&e.keepReplaceResult||Dy(n)}function Sy(n,e,t){qj(n,e).forEach(r=>{r.remove()}),t!=null&&t.keepReplaceResult||Dy(n)}function Ru(n){const e=Mu(n);if(!e)return-1;const o=Cr(n).indexOf(e);return g(xc,o!==-1,`invalid highlight index: ${o}`),o}function Kj(n){const e=Cr(n);if(e.length===0)return 0;const t=Mu(n);let o=t?e.indexOf(t):-1;!t||o===-1||o===e.length-1?o=0:o+=1;const r=e[o];return qf(n,r),o}function Xj(n){const e=Cr(n);if(e.length===0)return 0;const t=Mu(n);let o=t?e.indexOf(t):-1;!t||o===-1||o===0?o=e.length-1:o-=1;const r=e[o];return qf(n,r),o}function m2(n,e){const t=Cr(n);t.length>0&&e<t.length&&qf(n,t[e])}function eU(n,e,t){const o=Mu(n);if(!o)return!1;const r=oe(o);if(g(xc,r,"no parent block"),!n.isBlockWritable(r))return!1;const i=Jr(n);let s=Ru(n);if(!Ty(o)&&n.isBlockWritable(r)){const d=Vf(n,o),h=n.getBlockText(r),{start:p,end:A}=Vf(n,o),[v,B]=ln.transformOffset(d.oldText,h,[p,A]),D=F4(h,v,B-v);if(rt(D).toLowerCase()!==e.toLowerCase())return!1;const I=hh(h,v,B,t);n.setBlockText(r,I),Zj(r),g2(n,r,e),t&&Iy(n,r,v,v+t.length)}const l=Jr(n);s>=l?s=0:l>i&&(s+=1);const a=Qj(n,s);return a&&qf(n,a),!0}function tU(n,e,t,o){if(!ee(n,e)||!n.isBlockWritable(e))return 0;const r=n.getBlockText(e);g(xc,r,"no block text");const i={count:0},s=i6(r,t,o,i);return rt(r)===rt(s)?0:(n.setBlockText(e,s),i.count)}function nU(n,e,t){if(g(xc,Wj(e),"not a highlight elem"),Ty(e))return;g(xc,t>0,"invalid highlight length");const o=Vf(n,e),r=oe(e);g(xc,r,"no parent block"),Iy(n,r,o.start,o.start+t)}function oU(n,e){Cr(n).forEach(o=>{nU(n,o,e)})}function rU(n,e,t){if(n.readonly)return 0;const o=i=>{let s=0;return vt(i).forEach(a=>{Le(n,a)?En(n,a).forEach(h=>{s+=o(h)}):s+=tU(n,a,e,t)}),s},r=o(n.rootContainer);return t.length>0&&oU(n,t.length),r}function iU(n){const e=n.selection.range.end,t=n.getBlockById(e.blockId),o=e.isSimple()?e.offset:1,r=Wf(t);for(let l=0;l<r.length;l++){const a=r[l],{end:d}=Vf(n,a);if(d>=o)return a}const i=og(n,{simpleBlockOnly:!0}),s=i.indexOf(t);if(s===-1)return null;for(let l=s+1;l<i.length;l++){const a=i[l],d=Wf(a);if(d.length>0)return d[0]}return null}function sU(n){const e=Cr(n),t=iU(n);return t?e.indexOf(t):0}function g2(n,e,t){if(!!t&&ee(n,e)){const o=n.getBlockText(e),r=Cg(o,t);r.length>0&&r.forEach(({start:i,end:s})=>{Jj(n,e,i,s)})}}function Ly(n,e){if(Gf(n),!e)return;og(n,{simpleBlockOnly:!0}).forEach(o=>{g2(n,o,e)})}class lU{constructor(e){m(this,"dialog",null);m(this,"root");m(this,"oldText","");m(this,"_compositionEndTime",0);m(this,"components");m(this,"handleFindChanged",()=>{this.doSearch({keepReplaceResult:!1,gotoFirstSearchResult:!0})});m(this,"handleCompositionEnd",()=>{this._compositionEndTime=Date.now(),this.handleFindChanged()});m(this,"handleDocChanged",e=>{setTimeout(()=>{Sy(this.editor,e),g2(this.editor,e,this.components.findInput.value);const t=Jr(this.editor);e.querySelectorAll(".editor-highlight").length===t&&m2(this.editor,0);const o=Ru(this.editor);this.updateSearchStatus(o,t)})});m(this,"handleDocInserted",()=>{const e=setTimeout(()=>{clearTimeout(e),Gf(this.editor,{keepReplaceResult:!0}),Ly(this.editor,this.components.findInput.value);const t=Jr(this.editor),o=Ru(this.editor);this.updateSearchStatus(o,t),m2(this.editor,o)})});m(this,"handleDocDeleted",e=>{const t=setTimeout(()=>{if(!Wf(e).length){clearTimeout(t);return}Sy(this.editor,e);const r=Jr(this.editor),i=Ru(this.editor);this.updateSearchStatus(i,r)})});m(this,"handleInput",e=>{if(e.isComposing||By(this._compositionEndTime)){this.doSearch.cancel();return}this.handleFindChanged()});m(this,"handleFind",()=>{this.findNext({keepSearchResult:!1})});m(this,"handleReplace",()=>{const e=this.components.findInput.value;if(!e||!Mu(this.editor))return;const o=this.components.replaceInput.value;if(e===o)return;if(eU(this.editor,e,o)){const i=Ru(this.editor),s=Jr(this.editor);this.updateSearchStatus(i,s)}this.findNext({keepSearchResult:!0})});m(this,"handleReplaceAll",()=>{const e=this.components.findInput.value;if(!e)return;const t=this.components.replaceInput.value;if(e===t)return;rU(this.editor,e,t)>0&&(this.oldText="",this.doSearchNow({keepReplaceResult:!0,gotoFirstSearchResult:!0}),this.clearFind({keepReplaceResult:!0}))});m(this,"doSearch",Ht.default(this.doSearchNow,300));this.editor=e;const t=w("div",["editor-find-dialog"],null),o=w("div",["editor-find-content"],t),r=w("div",["editor-find-dialog-row"],o),i=Hl(rv,["editor-find-dialog-button-close"],t),s=w("label",["editor-find-dialog-label"],r,R.t("find.findLabel"));s.htmlFor="";const l=w("div",["editor-find-dialog-input-container"],r),a=w("input",["editor-find-dialog-input"],l);a.type="text",a.placeholder=R.t("find.findPlaceholder");const d=w("div",["editor-find-dialog-status"],l),h=Hl(mL,["editor-find-dialog-icon-button"],d),p=w("div",["editor-find-dialog-curr"],d,"0/0"),A=Hl(gL,["editor-find-dialog-icon-button"],d);let v;R.t("find.moreButton")?v=w("button",["editor-find-dialog-button"],r,R.t("find.moreButton")):v=Hl(iv,["editor-find-dialog-icon-button-border"],r);const B=w("div",["editor-find-dialog-row"],o),D=w("label",["editor-find-dialog-label"],B,R.t("find.replaceLabel"));D.htmlFor="";const I=w("div",["editor-find-dialog-input-container"],B),_=w("input",["editor-find-dialog-input"],I);_.type="text",_.placeholder=R.t("find.replacePlaceholder");const M=w("div",["editor-find-dialog-row"],o);w("div",["editor-find-dialog-space"],M);const H=w("button",["editor-find-dialog-button"],M,R.t("find.findButton")),z=w("button",["editor-find-dialog-button"],M,R.t("find.replaceButton")),q=w("button",["editor-find-dialog-button"],M,R.t("find.replaceAllButton"));v.onclick=()=>{this.showReplace()},i.onclick=()=>{this.hide()},a.onkeydown=fe=>{if(fe.isComposing||By(this._compositionEndTime)){this.doSearch.cancel();return}bC(fe)?(this.doSearch.cancel(),this.doSearchNow({keepReplaceResult:!1,gotoFirstSearchResult:!0})):Im(fe)&&this.hide()},a.oninput=this.handleInput,a.onpaste=this.handleFindChanged,a.oncut=this.handleFindChanged,a.addEventListener("compositionend",this.handleCompositionEnd),a.maxLength=50,H.onclick=this.handleFind,z.onclick=this.handleReplace,q.onclick=this.handleReplaceAll,_.maxLength=50,A.onclick=()=>{this.gotoNext()},h.onclick=()=>{this.gotoPrev()},this.components={findInput:a,findPrev:h,findCurrent:p,findNext:A,replaceInput:_,findButton:H,replaceButton:z,replaceAllButton:q,closeButton:i,showReplaceButton:v,rowReplace:B,rowActions:M,statusContainer:d},this.root=t;const re=new zj(e);e.doc.registerCallback(re),re.addListener("onDocChanged",this.handleDocChanged),re.addListener("onDocInserted",this.handleDocInserted),re.addListener("onDocDeleted",this.handleDocDeleted)}findNext(e){this.doSearch.cancel(),this.doSearchNow({keepReplaceResult:e.keepSearchResult,gotoFirstSearchResult:!0})}doSearchNow(e){const t=this.components.findInput.value;if(t||this.clearFind(e),this.oldText===t){this.gotoNext();return}this.oldText=t,Ly(this.editor,t);const o=Jr(this.editor),r=sU(this.editor);e.gotoFirstSearchResult&&m2(this.editor,r),this.updateSearchStatus(r,o)}gotoNext(){const e=Jr(this.editor),t=Kj(this.editor);this.updateSearchStatus(t,e)}gotoPrev(){const e=Jr(this.editor),t=Xj(this.editor);this.updateSearchStatus(t,e)}updateSearchStatus(e,t){if(this.oldText?this.components.statusContainer.style.display="flex":this.components.statusContainer.style.display="none",t===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=`${e+1}/${t}`;const o=this.editor.readonly;this.components.replaceAllButton.disabled=o,this.components.replaceButton.disabled=o,this.components.findButton.disabled=!1}}clearFind(e){Gf(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(e){const t=this.editor.getSelectedText();t.length>0&&t.length<50&&(this.components.findInput.value=t),this.root.style.display="flex",e!=null&&e.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 ru(this.root,{disablePageScroll:!1}));const r=this.editor.options.componentsOptions.findDialog,i=(r==null?void 0:r.popoverTarget)||this.editor.rootContainer,s=()=>{var p,A,v,B;const l=r==null?void 0:r.getReferenceClientRect;if(l&&((A=(p=this.dialog)==null?void 0:p.tippyInstance)==null?void 0:A.popper))return l(i,(B=(v=this.dialog)==null?void 0:v.tippyInstance)==null?void 0:B.popper);const a=i.getBoundingClientRect(),d=a.top<0?12:a.top+12,h=a.right-this.root.clientWidth-12;return new DOMRect(h,d,0,0)};this.dialog.show(i,{getReferenceClientRect:s}),setTimeout(()=>{this.components.findInput.focus(),this.components.findInput.select()},300)}hide(){var e;(e=this.dialog)==null||e.close("cancelBar"),Gf(this.editor)}isVisible(){return this.dialog&&this.dialog.isVisible}research(){this.oldText="",this.doSearch({keepReplaceResult:!0,gotoFirstSearchResult:!1})}destroy(){var e;(e=this.dialog)==null||e.destroy()}}const cU={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"}},aU={find:{findLabel:"Search:",replaceLabel:"Replace:",findButton:"Search",replaceButton:"Replace",replaceAllButton:"Replace all",moreButton:"",findPlaceholder:"Search text in document",replacePlaceholder:"Replace with"}},uU={find:{findLabel:"\u691C\u7D22\uFF1A",replaceLabel:"\u7F6E\u63DB\uFF1A",findButton:"\u691C\u7D22",replaceButton:"\u7F6E\u63DB",replaceAllButton:"\u3059\u3079\u3066\u3092\u7F6E\u63DB",moreButton:"",findPlaceholder:"\u30C9\u30AD\u30E5\u30E1\u30F3\u30C8\u3092\u691C\u7D22",replacePlaceholder:"\u306B\u7F6E\u63DB"}};R.mergeLang({"zh-CN":cU,"en-US":aU,"ja-JP":uU});function My(n){return n.addCustom("find-dialog",()=>new lU(n)).show(),!0}const Ry={"CtrlOrCmd+F":My},Rne="";function dU(n){My(n)}function p2(n,e){return e.map(t=>{var i,s;const o=Qe(n,t),r=(i=o.getBlockProperties)==null?void 0:i.call(o,n,t);return Lt(t)||Le(n,t)?r!=null&&r.abstract?`[${r.abstract}]`:"":(s=r==null?void 0:r.abstract)!=null?s:""}).join(" ")}function Zf(n){const{editor:e,commentGroupId:t,abstract:o="text"}=n,r=K(),i=e.doc.getUser(),s=Date.now(),l=t!=null?t:r;return{id:r,groupId:l,userId:i.userId,displayName:i.displayName,avatarUrl:i.avatarUrl,abstract:o,created:s,modified:s}}function Oy(n,e,t){const o=t.id,i=n.getBlockData(e).comments;let s;i?s=[...i,o]:s=[o];const l={comments:s};n.updateBlockData(e,l)}function C2(n,e,t){const o=p2(n,[e]),r=Zf({editor:n,abstract:o});Oy(n,e,r);const i=Ur();return t.localCreateComment(r,i),r}const hU=S("standard-block-actions");class fU{constructor(e,t){m(this,"executeCommand",(e,t,o)=>{const r=o.data;try{this.editorComments.showCommentList();const i=e.getBlockById(r);C2(e,i,this.provider)}catch(i){hU.error(`failed to execute block command: ${JSON.stringify(i)}`)}});this.provider=e,this.editorComments=t}commands(e,t){const o=ie(t);return{group:"block-comment-actions",commands:[{id:"comment",name:R.t("comment.quickMenuCommand"),data:o,order:100,states:e.readonly?["disabled"]:[]}],executeCommand:this.executeCommand}}}class mU{async handleBeforePasteDoc(e,t){return Object.values(t.blocks).forEach(o=>{o.forEach(r=>{delete r.comments,r.text&&r.text.forEach(i=>{if(i.attributes){const s=i.attributes;Object.keys(s).forEach(l=>{l.startsWith("comment-")&&delete s[l]})}})})}),!1}}var Ye=(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))(Ye||{});const A2="group-item-action",_y="last-comment-item",Kr="disabled",Fy=500;function Js(n){return n.id!==n.groupId}function Py(n,e=".comment-item-root"){return n.querySelectorAll(e).length}function gU(n){const e=n.closest(".comment-item-root");return e?e.id:null}function Xr(n,e){n.setAttribute(A2,e)}function pU(n){return n.closest(`[${A2}]`)}function CU(n){var e;return(e=n.getAttribute(A2))!=null?e:""}function AU(n){return xe(n,Kr)}function Ny(n,e){const t=n.rootContainer.querySelector(`[comment-${e.toLocaleLowerCase()}=${e}`);if(!t)return null;const o=t.closest('[data-type="editor-block"]');return o?o.id:null}function $y(n){return Array.from(n.attributes).map(t=>t.name).filter(t=>t.startsWith("comment-")).map(t=>t.replace("comment-",""))}const Hy=S("doc-comments");function jy(n,e,t,o){if(e.comments){const i=e.comments;Array.isArray(i)&&i.forEach(s=>{o.has(s)||(o.add(s),t.push(s))})}e.text&&e.text.forEach(s=>{if(s.attributes){const l="comment-";Object.entries(s.attributes).forEach(([a,d])=>{if(a.startsWith(l)){const h=d;o.has(h)||(o.add(h),t.push(h))}})}});const r=e.children;!r||r.forEach(i=>{n.blocks[i].forEach(l=>{jy(n,l,t,o)})})}function bU(n){const e=[],t=new Set;n.blocks.root.forEach(r=>{jy(n,r,e,t)});const o=new Map;return e.forEach((r,i)=>o.set(r,i)),o}function vU(n){const e=new Map;n.forEach(r=>{if(Js(r)){const i=e.get(r.groupId);i?i.push(r):e.set(r.groupId,[r])}});const t=[];return n.forEach(r=>{var i;if(!Js(r)){const s=(i=e.get(r.id))!=null?i:[];e.delete(r.id);const l={...r,children:s};t.push(l)}}),Array.from(e.values()).forEach(r=>{const i=r[0],s=r.slice(1),l={...i,children:s};t.push(l)}),t}function es(n,e){const t=n.doc.toJSON(),o=bU(t);return vU(e.getComments()).filter(s=>o.has(s.groupId)).sort((s,l)=>{const a=o.get(s.groupId),d=o.get(l.groupId);return g(Hy,a!==void 0,`comment not exists in doc, ${s.groupId}`),g(Hy,d!==void 0,`comment not exists in doc, ${l.groupId}`),a-d})}function b2(n){const{children:e,...t}=n,o=[t];return e.forEach(r=>{o.push(r)}),o}function yU(n,e){return es(n,e).map(b2).reduce((r,i)=>i.length+r,0)}function v2(n,e){const t=[],o=n.getBlockById(e.blockId);if(ee(n,o)){const i=e.blockId,s=e.offset,l=n.getBlockById(i),a=n.getBlockText(l),d=Ta(a,s);d&&Object.entries(d).forEach(([h,p])=>{h.startsWith("comment-")&&t.push(p)})}const r=o.attributes;for(let i=0;i<r.length;i++){const s=r[i];s.name.startsWith("comment-")&&t.push(s.value)}return t}function Uy(n){const e=n.selection.range;if(!e.isSimple())return[];if(e.start.blockId!==e.end.blockId)return[];if(e.isCollapsed())return v2(n,e.start);const{start:t,end:o}=e,r=v2(n,t),i=v2(n,o);return fm.default(r,i)}const kU=S("active-comments");function zy(n,e){n.rootContainer.querySelectorAll(`span.text.comment[comment-${e}],[data-type=editor-block].comment[comment-${e}]`).forEach(o=>{te(o,"active")})}function Vy(n,e){const t=n.rootContainer.querySelector("span.text.comment.active,[data-type=editor-block].comment.active");if(!e)t&&$y(t).forEach(r=>zy(n,r));else{const o=e.toLocaleLowerCase();if(t){const i=$y(t);if(i.length===1&&i[0]===o)return;i.forEach(s=>zy(n,s))}const r=n.rootContainer.querySelectorAll(`span.text.comment[comment-${o}],[data-type=editor-block].comment[comment-${o}]`);if(r){r.forEach(s=>{W(s,"active")});const i=r[0];if(xs(i))n.selection.selectBlock(i,0);else if(Uy(n).indexOf(e)===-1){const l=oe(i);g(kU,l,"block not found");const a=Mi(l,i);n.selection.selectBlock(l,a.start)}n.focus()}}}const One="";S("comment-editor");const{t:wU}=R,y2="comment-editor-readonly",Ou="comment-editor-editing";class k2{constructor(e,t,o){m(this,"root");m(this,"components");m(this,"handleEditorBlur",()=>{this.inactiveEditor()});m(this,"handleEditorFocus",()=>{this.editor.readonly||this.activeEditor()});m(this,"activeEditor",()=>{xe(this.root,Ou)||W(this.root,Ou)});m(this,"inactiveEditor",()=>{te(this.root,Ou)});m(this,"handleInsertImg",async()=>{const{editor:e}=this.components,t=ae(e.rootContainer),o=await zl("image/*",{}),r={src:"",widthPercent:50},i={id:K(),type:"embed",embedType:"image",embedData:r},s=e.options.componentsOptions.image;s!=null&&s.defaultAlign&&(i.align=s.defaultAlign);const l=e.getFocusedBlock(),a=e.getBlockIndex(l),d=e.insertBlock(t,a+1,i);wt.getImageObject(e,d).replaceImage(0,o)});m(this,"handleReadonlyChange",e=>{e.readonly?(te(this.root,Ou),W(this.root,y2)):(W(this.root,Ou),te(this.root,y2))});m(this,"setDoc",e=>{const{components:{editor:t}}=this;t.doc.externalDoc.setDoc(e)});m(this,"getDoc",()=>{const{components:{editor:e}}=this;return e.doc.toJSON()});m(this,"isEmpty",()=>Ag(this.getDoc()));m(this,"edit",()=>{const{editor:e}=this.components;e.readonly=!1,_A(e),this.activeEditor()});m(this,"clear",()=>{const e=Ur();this.setDoc(e)});m(this,"readonly",()=>{const{editor:e}=this.components;e.readonly=!0});m(this,"destroy",()=>{const{root:e,components:{editor:t,insertImgButton:o}}=this;o.onclick=null,t.destroy(),e.remove()});this.mainEditor=e,this.commentsProvider=t,this.doc=o,this.root=w("div",["comment-editor",y2],null),this.components=this.createEditor()}createEditor(){const e=w("div",["comment-editor-root"],this.root),{commentsProvider:t,mainEditor:o}=this,r=t.createCommentEditor(e,new np(this.doc));r.readonly=!0,r.addListener("readonlyChanged",this.handleReadonlyChange),r.addListener("focus",this.handleEditorFocus),r.addListener("blur",this.handleEditorBlur);const i=Qs(this.root,"comment-editor-img",wU("comment.image"),EL,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 BU{constructor(e){m(this,"handleBeforeKeyDown",(e,t)=>{if(Or(t,"Enter")){const{quickReply:o,updateLastCommentItem:r}=this.groupItem;return o.getReplyEditor().isEmpty()?(o.hideReplyEditor(),!0):(o.reply(),r(),!0)}return!1});this.groupItem=e}}class EU{constructor(e,t,o){m(this,"handleBeforeKeyDown",(e,t)=>{if(Or(t,"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=e,this.groupItem=t,this.commentItem=o}}const xU=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
473
473
  <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>
474
474
  </svg>`,IU=`<svg
475
475
  fill="currentColor"
@@ -479,7 +479,7 @@ width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
479
479
  <path d="M2.00218 11.0005L8.00341 4.99923L14.0046 11.0005" stroke="currentColor" fill="transparent" stroke-width="1.5" stroke-linejoin="bevel"/>
480
480
  </svg>`,LU=`<svg width="17" height="16" viewBox="0 0 17 16" xmlns="http://www.w3.org/2000/svg">
481
481
  <path d="M14.0029 4.99933L8.00172 11.0006L2.00049 4.99933" stroke="currentColor" fill="transparent" stroke-width="1.5" stroke-linejoin="bevel"/>
482
- </svg>`,Nne="",Qf="reply-editor-editing",{t:w2}=R;class MU{constructor(e,t,o,r){m(this,"root");m(this,"components");m(this,"handleFocus",()=>{const{replyEditor:e,okButton:t}=this.components;e.isEmpty()&&W(t,Kr)});m(this,"handleDocChange",()=>{const{replyEditor:e,okButton:t}=this.components,o=e.getDoc();Ag(o)?W(t,Kr):te(t,Kr)});m(this,"getReplyEditor",()=>this.components.replyEditor);m(this,"showReplyEditor",()=>{xe(this.root,Qf)||(W(this.root,Qf),this.components.replyEditor.edit())});m(this,"hideReplyEditor",()=>{!xe(this.root,Qf)||te(this.root,Qf)});m(this,"reply",()=>{const{mainEditor:e,comment:t,components:{replyEditor:o},commentsProvider:r}=this,i=o.getDoc(),s=Zf({editor:e,commentGroupId:t.groupId});r.localCreateComment(s,i),this.hideReplyEditor(),o.clear()});m(this,"cancel",()=>{const{replyEditor:e}=this.components;this.hideReplyEditor(),e.clear()});m(this,"hide",()=>{xe(this.root,"hidden")||W(this.root,"hidden")});m(this,"show",()=>{te(this.root,"hidden")});this.mainEditor=e,this.commentsProvider=t,this.comment=o,this.groupItem=r,this.root=w("div",["comment-quick-reply"],null),this.components=this.createQuickReply()}createQuickReply(){const{commentsProvider:e}=this,t=Qs(this.root,Ye.QuickReply,w2("comment.placeholder"));Xr(t,Ye.QuickReply),t.classList.add("quick-reply-button");const o=w("div",["quick-reply-editor"],this.root),r=Ur(),i=new k2(this.mainEditor,e,r);i.editor.addListener("docChanged",this.handleDocChange),i.editor.addListener("focus",this.handleFocus),i.editor.input.addHandler(new BU(this.groupItem)),o.append(i.root);const s=w("div",["reply-editor-actions"],o),l=ji(Ye.QuickReplyCancel,w2("common.cancel"));Xr(l,Ye.QuickReplyCancel);const a=ji(Ye.QuickReplyOk,w2("comment.send"));return Xr(a,Ye.QuickReplyOk),W(a,Kr),s.append(l,a),this.hideReplyEditor(),{replyTextButton:t,replyEditor:i,replyEditorContainer:o,okButton:a}}}const ei=S("comment-group-item");class RU extends bt.TypedEmitter{constructor(t,o,r,i){super();m(this,"root");m(this,"header");m(this,"mainItem");m(this,"childrenList");m(this,"resizeObserver");m(this,"quickReply");m(this,"createRoot",()=>w("div",["comment-group-item-root"],null));m(this,"createChildrenList",()=>{const t=w("div",["comment-children-list-container"],this.root);return new DU({editor:this.editor,commentsProvider:this.commentsProvider,comments:this.comment.children,parent:t,groupList:this.groupList,groupItem:this})});m(this,"updateLastCommentItem",()=>{const t=Array.from(this.root.querySelectorAll(":scope .comment-item-root"));g(ei,t.length!==0,"current group item not exist comment-item"),t.forEach(r=>{te(r,_y)});const o=t.at(-1);W(o,_y)});m(this,"updateSwitchButton",()=>{const t=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"]');g(ei,t,"switchUpButton not exist"),g(ei,o,"switchDownButton not exist"),te(o,"disabled"),te(t,"disabled"),this.root.previousElementSibling===null&&W(t,"disabled"),this.root.nextElementSibling===null&&W(o,"disabled")});m(this,"handleReadonlyChanged",t=>{t.readonly?W(this.root,"readonly"):te(this.root,"readonly")});m(this,"handleResize",()=>{this.emit("resize")});this.editor=t,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.editor.on("readonlyChanged",this.handleReadonlyChanged),this.resizeObserver=new ResizeObserver(this.handleResize),this.resizeObserver.observe(this.root),this.updateLastCommentItem()}get commentCount(){return Py(this.root)}createQuickReply(){const{editor:t,commentsProvider:o,comment:r}=this,i=new MU(t,o,r,this);return this.root.append(i.root),i}createHeader(){const{comment:t}=this,o=w("div",["comment-item-head"],this.root),r=w("span",["item-head-quote"],o);r.innerText=t.abstract;const i=w("span",["item-head-switch"],o),s=Qs(i,Ye.SwitchUp,"up",SU),l=Qs(i,Ye.SwitchDown,"down",LU);return Xr(s,Ye.SwitchUp),Xr(l,Ye.SwitchDown),o}createItem(){const t=w("div",["comment-item-container"],this.root),{editor:o,commentsProvider:r,comment:i,groupList:s}=this,l=new Gy({mainEditor:o,commentsProvider:r,comment:i,groupList:s,groupItem:this});return t.appendChild(l.root),l}findCommentItem(t){return t?t===this.mainItem.comment.id?this.mainItem:this.childrenList.items.find(o=>o.comment.id===t):null}handleCreateComment(t){return g(ei,Js(t),"invalid comment, not a child comment"),g(ei,t.groupId===this.comment.id,"invalid comment, not a child comment"),this.childrenList.createItem(t)}handleUpdateChildComment(t){g(ei,t.groupId===this.mainItem.comment.id,"invalid child comment");const o=this.childrenList.findItem(t.id);if(!o){ei.error(`can't find child comment item: ${t.id}`);return}o.reloadDoc()}handleUpdateMainComment(t){g(ei,t.id===this.mainItem.comment.id,"invalid comment"),this.mainItem.reloadDoc()}deleteMainComment(t){g(ei,t===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(),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged)}}const OU=S("arrange=items"),Qy=20;function Yy(n,e){const t=n.rootContainer.querySelector(`[comment-${e.toLocaleLowerCase()}=${e}`);if(!t)return-1;const o=n.scrollContainer.getBoundingClientRect(),r=n.scrollContainer.scrollTop;return t.getBoundingClientRect().top-o.top+r}function Jy(n,e){return Number.parseInt(e.root.style.top,10)}function Ky(n,e,t,o){let r=0;t&&(r=e.indexOf(t),r===-1&&(r=0));for(let i=r;i<e.length;i++){const s=e[i],l=s.comment,a=Yy(n,l.groupId);if(s.root.setAttribute("data-target-top",a.toString()),i===r){if(o!==void 0){const p=e[0];p.root.style.top=`${o}px`}else s.root.style.top=`${a}px`;continue}const d=e[i-1],h=Jy(n,d)+d.root.getBoundingClientRect().height;h>a?s.root.style.top=`${h+Qy}px`:s.root.style.top=`${a}px`}for(let i=r-1;i>=0;i--){const s=e[i],l=s.comment,a=Yy(n,l.groupId);s.root.setAttribute("data-target-top",a.toString());const d=s.root.getBoundingClientRect(),h=a+d.height,p=e[i+1];g(OU,p,"no next item");const A=Jy(n,p);A<h?s.root.style.top=`${A-d.height-Qy}px`:s.root.style.top=`${a}px`}setTimeout(()=>{n.scrollContainer.dispatchEvent(new Event("scroll"))},350)}const Yf=S("comment-group-item-handler");class _U{constructor(e,t){m(this,"handleSwitchUp",e=>{const t=Math.max(0,e-1);this.groupList.setActiveItem(t),this.groupList.updateItemsLayout()});m(this,"handleSwitchDown",e=>{const t=Math.min(e+1,this.groupList.items.length);this.groupList.setActiveItem(t),this.groupList.updateItemsLayout()});m(this,"handleQuickReply",e=>{const{quickReply:t}=e;t.showReplyEditor()});m(this,"handleQuickReplyOk",e=>{const{quickReply:t}=e;t.reply(),e.updateLastCommentItem()});m(this,"handleQuickReplyCancel",e=>{const{quickReply:t}=e;t.cancel()});m(this,"handleCommentItemReply",(e,t)=>{const o=e.findCommentItem(t);g(Yf,o,`the commentItem: ${t} not exist `);const{quickReply:r}=e;r.show(),r.showReplyEditor();const{comment:i}=o,s=r.getReplyEditor(),l=s.editor.getFocusedBlock(),a={type:"mention",id:K(),box:!0,created:Date.now(),text:i.displayName,iconUrl:i.avatarUrl,mentionId:i.userId};s.editor.insertBoxToBlock(l,0,a)});m(this,"handleCommentItemMore",e=>{const{quickReply:t}=e;t.hideReplyEditor(),t.getReplyEditor().clear()});m(this,"handleCommentItemOk",(e,t)=>{const o=e.findCommentItem(t);g(Yf,o,`the commentItem: ${t} not exist `);const{quickReply:r}=e,{comment:i,getCommentEditor:s}=o,l=s(),a=l.getDoc();this.commentsProvider.localUpdateComment(i,a),l.readonly(),r.show()});m(this,"handleCommentItemCancel",(e,t)=>{var a,d;const o=e.findCommentItem(t);g(Yf,o,`the commentItem: ${t} not exist `);const r=this.commentsProvider.getComment(o.comment.id);let i=!1;if((a=r.blocks)!=null&&a.length||(i=!0),((d=r.blocks)==null?void 0:d.length)===1){const h=r.blocks[0];i=!!h.text&&rn(h.text)===0}if(i){this.commentsProvider.localDeleteComment(o.comment.id);return}const{quickReply:s}=e,l=o.getCommentEditor();l.setDoc(o.doc),l.readonly(),s.show()});m(this,"handleCommentItemEdit",e=>{const t=this.groupList.findItem(e.comment.groupId);if(!t)return;const{quickReply:o}=t;e.getCommentEditor().edit(),o.hide()});m(this,"handleCommentItemDelete",e=>{const t=this.groupList.findItem(e.comment.groupId);if(!t)return;const{quickReply:o}=t,{comment:r}=e;this.commentsProvider.localDeleteComment(r.id),o.show()});m(this,"execute",(e,t,o,r)=>{const i=pU(e);if(!i||AU(i))return;const s=CU(i);switch(s){case Ye.SwitchUp:this.handleSwitchUp(r);break;case Ye.SwitchDown:this.handleSwitchDown(r);break;case Ye.CommentItemReply:this.handleCommentItemReply(t,o);break;case Ye.CommentItemMore:this.handleCommentItemMore(t);break;case Ye.CommentItemOk:this.handleCommentItemOk(t,o);break;case Ye.CommentItemCancel:this.handleCommentItemCancel(t,o);break;case Ye.CommentItemDelete:break;case Ye.CommentItemEdit:break;case Ye.QuickReply:this.handleQuickReply(t);break;case Ye.QuickReplyOk:this.handleQuickReplyOk(t);break;case Ye.QuickReplyCancel:this.handleQuickReplyCancel(t);break;default:const l=s;Yf.debug(`not implement handler for ${l}`)}});this.groupList=e,this.commentsProvider=t}destroy(){}}const Jf=S("comment-group-list");class FU extends _u{constructor(t,o,r){super(t,o,r,es(t,o),{});m(this,"groupItemHandlers");m(this,"findGroupItem",t=>this.items.find(o=>o.comment.groupId===t));m(this,"handleContainerClick",t=>{if(!t.target||!(t.target instanceof Element))return;const o=t.target.closest(".comment-group-item-root");if(!o)return;const r=gU(t.target),i=this.items.findIndex(s=>s.root===o);if(i!==-1){this.setActiveItem(i);const{groupItemHandlers:s}=this;s.execute(t.target,this.items.at(i),r,i)}});m(this,"handleSelectionChanged",()=>{var o;const t=Uy(this.editor);if(t.length>0){if(((o=this.activeItem)==null?void 0:o.comment.id)&&t.includes(this.activeItem.comment.id))return;const r=t[0],i=this.items.findIndex(s=>s.comment.groupId===r);this.setActiveItem(i),this.emit("selectionOnComment")}else this.setActiveItem(-1)});m(this,"handleEditorResize",()=>{this.updateItemsLayout()});m(this,"handleDocChanged",()=>{this.updateComments()});m(this,"handleItemResize",()=>{this.updateItemsLayout()});m(this,"handleScroll",t=>{if(t.deltaY>=0||this.editor.scrollContainer.scrollTop!==0)return;const o=document.elementFromPoint(t.clientX,t.clientY);if(!o||!(o instanceof HTMLElement)||!this.editor.scrollContainer.contains(o))return;const r=this.container.querySelector(".comment-group-item-root");if(!r)return;const i=Number.parseFloat(r.style.top),s=Number.parseFloat(r.getAttribute("data-target-top")||"0");!Number.isNaN(i)&&!Number.isNaN(s)&&i<s&&Ky(this.editor,this.items,null,Math.min(i+(0-t.deltaY)*3,s))});m(this,"updateGroupItemSwitch",()=>{const t=this.activeItem;g(Jf,t,"invalid activeItem"),t.updateSwitchButton()});m(this,"updateComments",Ht.default(()=>{const t=es(this.editor,this.commentsProvider);let o=!1;for(let r=0;r<t.length;r++){const i=t[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];t.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.editor.scrollContainer.addEventListener("wheel",this.handleScroll,{passive:!1}),this.items.forEach(i=>i.addListener("resize",this.handleItemResize)),this.groupItemHandlers=new _U(this,o)}destroy(){this.editor.removeListener("selectionChanged",this.handleSelectionChanged),this.editor.removeListener("resize",this.handleEditorResize),this.editor.removeListener("docChanged",this.handleDocChanged),this.editor.scrollContainer.removeEventListener("wheel",this.handleScroll),super.destroy(),this.unbindEvents(),this.removeAllListeners()}updateItemsLayout(){Ky(this.editor,this.items,this.activeItem)}bindEvents(){this.container.addEventListener("click",this.handleContainerClick)}unbindEvents(){this.container.removeEventListener("click",this.handleContainerClick)}createItem(t,o){const r=new RU(this.editor,this.commentsProvider,t,this);return o==="insert"&&(W(r.root,"no-animation"),r.root.style.opacity="0",setTimeout(()=>{te(r.root,"no-animation"),r.root.style.opacity="1"},150)),r}findInsertPos(t){const r=es(this.editor,this.commentsProvider).findIndex(i=>i.id===t.id);return r===-1||r>this.items.length?-1:r}insertItem(t,o){const r=super.insertItem(t);return r?(o!=null&&o.active&&this.setActiveItem(this.items.indexOf(r)),this.updateItemsLayout(),r.addListener("resize",this.handleItemResize),r):null}setActiveItem(t){if(g(Jf,t>=-1&&t<this.items.length,`invalid index: ${t}`),t===this.activeIndex)return;const o=this.container.querySelector(".comment-group-item-root.active");if(o&&te(o,"active"),t!==-1){const r=this.items[t];W(r.root,"active"),this.updateItemsLayout(),this.updateGroupItemSwitch()}this.emit("activeItemChanged",t)}get activeIndex(){const t=this.container.querySelector(".comment-group-item-root.active");return t?this.items.findIndex(o=>o.root===t):-1}get activeItem(){const t=this.activeIndex;return t===-1?null:this.items[t]}handleCreateComment(t,o){if(Js(t)){const l=this.findGroupItem(t.groupId);l&&l.childrenList.insertItem(t)}const r=this.findItem(t.id);g(Jf,!r,"comment group item has already exists");const i={children:[],...t};g(Jf,i.children,"not a comment group");const s=this.insertItem(i,{active:o});!s||o&&setTimeout(()=>{const l=this.items.indexOf(s);this.setActiveItem(l),s.edit(),s.quickReply.hide()})}handleDeleteComment(t){for(let o=0;o<this.items.length;o++){const r=this.items[o];if(r.comment.id===t){r.childrenList.items.length===0?(this.deleteItem(r.comment.id),this.updateItemsLayout()):r.deleteMainComment(t);return}if(r.childrenList.deleteItem(t)){r.commentCount===0&&(this.deleteItem(r.comment.id),this.updateItemsLayout());return}}}handleUpdateComment(t){if(Js(t)){const r=this.commentsProvider.getComment(t.groupId),i=this.findItem(r.id);i&&i.handleUpdateChildComment(t);return}const o=this.findItem(t.id);o&&o.handleUpdateMainComment(t)}}const PU="comment-mini";S("comment-list");class NU extends bt.TypedEmitter{constructor(t,o){super();m(this,"root");m(this,"groupsContainer");m(this,"list");m(this,"handleSelectionOnComment",()=>{this.emit("onSelectComment")});m(this,"updateCommentCount",()=>{var o,r;const t=yU(this.editor,this.commentsProvider);(r=(o=this.commentOptions)==null?void 0:o.onCommentCountChange)==null||r.call(o,t)});m(this,"handleActiveItemChanged",()=>{var o;const t=this.list.activeItem;Vy(this.editor,(o=t==null?void 0:t.comment.id)!=null?o:"")});m(this,"handleItemLayoutUpdated",()=>{var o,r;const t=xe(this.root,PU);(r=(o=this.commentOptions)==null?void 0:o.onUpdateLayout)==null||r.call(o,this.editor,{expand:t})});this.editor=t,this.commentsProvider=o,this.root=w("div",["editor-web-comment-root"],null),this.groupsContainer=w("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(t,o){const r=this.commentsProvider.getComment(t);this.list.handleCreateComment(r,o),this.updateCommentCount()}onDeleteComment(t,o){this.list.handleDeleteComment(t),this.updateCommentCount()}onUpdateComment(t,o){const r=this.commentsProvider.getComment(t);this.list.handleUpdateComment(r)}createList(){return new FU(this.editor,this.commentsProvider,this.groupsContainer)}show(t){var o;if(te(this.root,"hidden"),t){const r=this.list.findItemIndex(t);this.list.setActiveItem(r)}(o=this.commentOptions)==null||o.controller.showCommentList()}hide(){W(this.root,"hidden")}}class $U extends _u{constructor({editor:e,parent:t,commentsProvider:o,comments:r}){super(e,o,t,r,{})}findInsertPos(){return this.items.length}createItem(e){const{editor:t,commentsProvider:o}=this;return new Zy(t,o,e)}destroy(){this.items.forEach(e=>{e.destroy()})}}const Kf=S("mobile-comment-group-item"),HU=20;class jU extends bt.TypedEmitter{constructor(t,o,r){super();m(this,"root");m(this,"childrenList");m(this,"mainItem");m(this,"scroller");m(this,"createRoot",()=>w("div",["mobile-group-item-root"],null));m(this,"createMainItem",t=>{const{editor:o,commentsProvider:r,comment:i}=this,s=new Zy(o,r,i);return t.append(s.root),s});m(this,"createChildrenList",t=>{const{editor:o,commentsProvider:r,comment:i}=this,s=w("div",["mobile-comment-children-list-container"],t);return new $U({editor:o,commentsProvider:r,comments:i.children,parent:s})});m(this,"handleTouchEnd",()=>{var i;const{scroller:t}=this,{pullThreshold:o=HU}=(i=this.editor.getComponentOptions("comment"))!=null?i:{};let r=null;if(t.y>t.minScrollY+o?(r=this.root.previousElementSibling,r||this.emit("onReachTop")):t.y<t.maxScrollY-o&&(r=this.root.nextElementSibling,r||this.emit("onReachBottom")),r){const s=r.id;this.emit("onSwitchGroup",s,Fy)}});m(this,"refreshScroller",()=>{this.scroller.refresh()});this.editor=t,this.commentsProvider=o,this.comment=r,this.root=w("div",["mobile-group-item-root"],null),this.root.id=r.groupId;const i=w("div",["mobile-group-item"],this.root),s=w("div",["mobile-group-item-space"],null),l=w("div",["mobile-group-item-abstract"],null);l.textContent=r.abstract;const a=w("div",["mobile-group-item-list-container"],null);this.mainItem=this.createMainItem(a),this.childrenList=this.createChildrenList(a),i.append(s,l,a),this.scroller=new Q5.default(this.root,{stopPropagation:!0,click:!0}),this.scroller.on("touchEnd",this.handleTouchEnd)}get commentCount(){return Py(this.root,".mobile-group-item")}handleUpdateChildComment(t){g(Kf,t.groupId===this.mainItem.comment.id,"invalid child comment");const o=this.childrenList.findItem(t.id);if(!o){Kf.error(`can't find child comment item: ${t.id}`);return}o.reloadDoc()}handleUpdateMainComment(t){g(Kf,t.id===this.mainItem.comment.id,"invalid comment"),this.mainItem.reloadDoc()}deleteMainComment(t){g(Kf,t===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 B2=S("mobile-group-list");class UU extends _u{constructor(t,o,r,i){super(t,o,r,es(t,o),{});m(this,"scroller");m(this,"refreshScroller",()=>{this.scroller.refresh(),this.items.forEach(t=>{t.refreshScroller()})});m(this,"deleteItem",t=>{if(this.items.length<=1)return super.deleteItem(t);const o=this.findItemIndex(t);let r=null;return o===0?r=this.items[o+1].root.id:r=this.items[o-1].root.id,super.deleteItem(t)?(this.scrollToGroup(r,Fy),!0):!1});m(this,"setupGroupItem",t=>{t.on("onSwitchGroup",this.scrollToGroup),t.on("onReachBottom",this.handleReachBottom),t.on("onReachTop",this.handleReachTop),t.refreshScroller()});m(this,"handleReachBottom",()=>{this.emit("onReachBottom")});m(this,"handleReachTop",()=>{this.emit("onReachTop")});m(this,"scrollToGroup",(t,o=0)=>{const r=this.findGroupItem(t);g(B2,r,"invalid scroll target"),this.scroller.scrollToElement(r.root,o,!1,!1),Vy(this.editor,r.comment.id)});m(this,"findGroupItem",t=>this.items.find(o=>o.comment.groupId===t));m(this,"handleDocChanged",()=>{this.updateComments()});m(this,"updateComments",Ht.default(()=>{const t=es(this.editor,this.commentsProvider);for(let o=0;o<t.length;o++){const r=t[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];t.findIndex(i=>i.groupId===r.comment.groupId)===-1&&this.deleteItem(r.comment.id)}},100));this.scroller=new Q5.default(i),this.scroller.disable(),this.editor.addListener("docChanged",this.handleDocChanged),this.items.forEach(this.setupGroupItem)}createItem(t){return new jU(this.editor,this.commentsProvider,t)}insertItem(t){const o=super.insertItem(t);return o?(this.setupGroupItem(o),o):null}findInsertPos(t){const r=es(this.editor,this.commentsProvider).findIndex(i=>i.id===t.id);return r===-1||r>this.items.length?-1:r}setActiveItem(t){this.scrollToGroup(t)}handleCreateComment(t,o){if(Js(t)){const s=this.findGroupItem(t.groupId);s&&s.childrenList.insertItem(t)}const r=this.findItem(t.id);g(B2,!r,"comment group item has already exists");const i={children:[],...t};g(B2,i.children,"not a comment group"),this.insertItem(i),this.scroller.refresh()}handleDeleteComment(t){for(let o=0;o<this.items.length;o++){const r=this.items[o];if(r.comment.id===t){r.childrenList.items.length===0?this.deleteItem(r.comment.id):r.deleteMainComment(t);return}if(r.childrenList.deleteItem(t)){r.commentCount===0&&this.deleteItem(r.comment.id);return}}}handleUpdateComment(t){if(Js(t)){const r=this.commentsProvider.getComment(t.groupId),i=this.findItem(r.id);i&&i.handleUpdateChildComment(t);return}const o=this.findItem(t.id);o&&o.handleUpdateMainComment(t)}destroy(){this.editor.removeListener("docChanged",this.handleDocChanged),this.scroller.destroy(),this.items.forEach(t=>t.destroy())}}const zU=S("mobile-comment-list"),{t:Xy}=R;class VU extends bt.TypedEmitter{constructor(t,o){super();m(this,"root");m(this,"list");m(this,"mask");m(this,"pullInfoContainer");m(this,"handleRootClick",t=>{const o=t.target;g(zU,o instanceof Element,"invalid target"),!(o.closest(".mobile-group-item-abstract")||o.closest(".mobile-group-item-list-container"))&&(this.hide(),this.emit("onCommentListClose"))});m(this,"hidePullInfo",Ht.default(()=>{te(this.pullInfoContainer,"active")},1e3*3));m(this,"handleReachBottom",()=>{this.showPullInfo("bottom")});m(this,"handleReachTop",()=>{this.showPullInfo("top")});m(this,"show",t=>{var o;te(this.root,"hidden"),W(document.documentElement,"disabled-scroll"),(o=this.commentOptions)==null||o.controller.showCommentList(),queueMicrotask(()=>{this.list.refreshScroller(),t&&this.list.setActiveItem(t)})});m(this,"hide",()=>{W(this.root,"hidden"),te(document.documentElement,"disabled-scroll")});this.editor=t,this.commentsProvider=o,this.root=w("div",["editor-mobile-comments-root"],null),this.mask=w("div",["mobile-comment-mask"],this.root);const r=w("div",["mobile-comment-groups-container"],this.root),i=w("div",["mobile-comment-groups-scroll-container"],r);this.list=new UU(this.editor,this.commentsProvider,i,r),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(t,o){const r=this.commentsProvider.getComment(t);this.list.handleCreateComment(r,o)}onDeleteComment(t,o){this.list.handleDeleteComment(t)}onUpdateComment(t,o){const r=this.commentsProvider.getComment(t);this.list.handleUpdateComment(r)}get commentOptions(){return this.editor.getComponentOptions("comment")}createPullInfo(){const t=w("div",["mobile-comment-pull-info-container"],this.root);return w("div",["mobile-comment-pull-info"],t),t}showPullInfo(t){const o=Xy(t==="bottom"?"comment.isLast":"comment.isFirst");this.pullInfoContainer.firstElementChild.textContent=o,W(this.pullInfoContainer,"active"),this.hidePullInfo()}destroy(){this.list.removeAllListeners(),this.list.destroy(),this.root.onclick=null}}function e8(n,e){const t=es(n,e),o=new Map;for(const r of t){const i=Ny(n,r.groupId);if(!!i)if(o.has(i)){const s=o.get(i);b2(r).forEach(a=>{s==null||s.commentIds.add(a.id)})}else{const s=b2(r),l=new Set(s.map(a=>a.id));o.set(i,{commentIds:l,firstComment:r})}}return Array.from(o.entries()).map(([r,i])=>({blockId:r,...i}))}const WU=S("mini-group-item");class qU{constructor(e,t){m(this,"root");m(this,"blockId");m(this,"comment");m(this,"miniCommentItem");m(this,"updateCommentItemCount",()=>{this.miniCommentItem.updateCount(this.commentCount)});this.editor=e,this.commentGroup=t,this.root=w("div",["mini-group-item"],null),this.comment=t.firstComment,this.miniCommentItem=new TU(this.comment.id,this.root),this.blockId=this.getBlockId(),this.alignToBlock(),this.updateCommentItemCount()}getBlockId(){return Ny(this.editor,this.comment.groupId)}get commentCount(){return this.commentGroup.commentIds.size}alignToBlock(){const e=this.getBlockId(),t=this.editor.getBlockById(e);g(WU,t,`The blockId: ${e} not exist in doc`);const o=this.editor.scrollContainer.getBoundingClientRect(),r=this.editor.scrollContainer.scrollTop,s=t.getBoundingClientRect().top-o.top+r;requestAnimationFrame(()=>{this.root.style.transform=`translateY(${s}px)`})}destroy(){this.root.remove()}}class GU extends _u{constructor(t,o,r){super(t,o,r,e8(t,o),{});m(this,"fixListOps",Ht.default(()=>{this.items.forEach(t=>{t.alignToBlock()})},100));m(this,"handleDocChanged",Ht.default(()=>{this.updateMiniCommentsGroup()},100));m(this,"updateMiniCommentsGroup",()=>{const t=e8(this.editor,this.commentsProvider);this.reloadList(t)});this.editor=t,this.commentsProvider=o,this.editor.addListener("docChanged",this.handleDocChanged),this.editor.addListener("resize",this.fixListOps)}createItem(t){return new qU(this.editor,t)}findInsertPos(){return-1}handleCreateComment(t,o){this.updateMiniCommentsGroup()}handleDeleteComment(t){this.updateMiniCommentsGroup()}destroy(){this.editor.removeListener("docChanged",this.handleDocChanged),super.destroy(),this.removeAllListeners()}}const ZU=S("mini-comments-list");class QU extends bt.TypedEmitter{constructor(t,o){super();m(this,"list");m(this,"root");m(this,"createList",()=>{const t=w("div",["comment-groups-container"],this.root);return this.editor.domEvents.addEventListener(t,"click",this.handleListContainerClick),new GU(this.editor,this.commentsProvider,t)});m(this,"handleListContainerClick",(t,o)=>{const r=o.target;g(ZU,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=t,this.commentsProvider=o,this.root=w("div",["editor-mini-comment-root"],null),this.list=this.createList(),this.commentsProvider.addListener(this)}onCreateComment(t,o){const r=this.commentsProvider.getComment(t);this.list.handleCreateComment(r,o)}onDeleteComment(t,o){this.list.handleDeleteComment(t)}onUpdateComment(t,o){}show(){te(this.root,"hidden")}hide(){W(this.root,"hidden")}destroy(){this.list.destroy(),this.removeAllListeners()}}function t8(n,e,t){if(!e.start.isSimple()||!e.end.isSimple())return;const o=e.block,r=yt(n,o,e.start.offset,e.end.offset),i=`comment-${t.id.toLocaleLowerCase()}`,s=t.id;q6(n,o,r,i,s)}function YU(n,e,t){const o=Lo(n).map(s=>s.block),r=p2(n,o),i=Zf({editor:n,abstract:r});return n.undoManager.runInGroup(()=>{Lo(n,{simpleBlockOnly:!0}).forEach(a=>{!ee(n,a.block)||t8(n,a,i)});const l=Ur();t.localCreateComment(i,l)}),i}class JU{constructor(e,t){m(this,"id","CommentsCommandProvider");this.provider=e,this.editorComments=t}getAvailableCommands(e,t,o){const r=e.selection.range;if(ee(e,t)&&!o.isCollapsed()&&r.isSimple()){const i=ie(t),s=De(t),l=Io(e,t);return[{id:"add-comment",name:R.t("comment.command"),blockId:i,blockType:s,blockKind:l,groupIndex:1e3,icon:tu}]}return[]}executeRangeCommand(e,t,o,r,i){if(o.id==="add-comment"){this.editorComments.showCommentList();const s=YU(e,t,this.provider);return i["add-comment"]=s,!0}return!1}}class n8{constructor(e,t){m(this,"commentList",null);m(this,"mobileCommentList",null);m(this,"miniCommentList");m(this,"showComment",(e,t)=>{var o,r;e==="mini"&&this.miniCommentList.show(),e==="mobile"&&((o=this.mobileCommentList)==null||o.show(t)),e==="web"&&((r=this.commentList)==null||r.show(t))});m(this,"showCommentList",e=>{this.isMobile?this.showComment("mobile",e):this.showComment("web",e)});m(this,"handleCommentListClose",()=>{this.showComment("mini")});m(this,"handleOnSelectComment",()=>{this.showComment("web")});m(this,"handleMiniCommentItemClick",e=>{this.showCommentList(e)});this.editor=e,this.provider=t,e.editorCommandProviders.registerCommandProvider(new JU(t,this)),e.blockHooks.push(new fU(this.provider,this)),this.isMobile?(this.mobileCommentList=new VU(this.editor,this.provider),this.mobileCommentList.on("onCommentListClose",this.handleCommentListClose)):(this.commentList=new NU(this.editor,this.provider),this.commentList.on("onSelectComment",this.handleOnSelectComment)),this.miniCommentList=new QU(this.editor,this.provider),this.miniCommentList.on("onItemClick",this.handleMiniCommentItemClick),this.editor.input.addHandler(new mU)}get commentProvider(){return this.provider}get isMobile(){return Kt.isMobile}destroy(){var e,t;(e=this.commentList)==null||e.destroy(),(t=this.mobileCommentList)==null||t.destroy(),this.miniCommentList.destroy()}mount(e){var t;e.container&&this.commentList&&e.container.append((t=this.commentList)==null?void 0:t.root),e.miniContainer&&e.miniContainer.append(this.miniCommentList.root),e.mobileContainer&&this.mobileCommentList&&e.mobileContainer.append(this.mobileCommentList.root)}}const $ne="",KU={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",more:"\u66F4\u591A",comment:"\u6279\u6CE8",command:"\u6279\u6CE8",quickMenuCommand:"\u6DFB\u52A0\u6279\u6CE8"}},XU={comment:{count:"Annotations ({num})",hide:"Hide Annotations",show:"Show Annotations",reply:"Reply",quicklyReply:"Reply...",send:"OK",placeholder:"Add a annotation...",replyPlaceholder:"Add Annotations or @ others",edit:"Edit",delete:"Delete",image:"Image",sendTitle:"Press Enter to send annotation",replyTitle:"Press Enter to reply annotation",isFirst:"\u5DF2\u7ECF\u662F\u7B2C\u4E00\u6761\u6279\u6CE8",isLast:"\u5DF2\u7ECF\u662F\u6700\u540E\u4E00\u6761\u6279\u6CE8",more:"More",comment:"Annotation",command:"Annotation",quickMenuCommand:"Add annotation"}},ez={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",more:"\u3082\u3063\u3068\u8A73\u3057\u304F",comment:"\u30B3\u30E1\u30F3\u30C8\u3092",command:"\u30B3\u30E1\u30F3\u30C8\u3092",quickMenuCommand:"\u6CE8\u91C8\u3092\u8FFD\u52A0"}};R.mergeLang({"zh-CN":KU,"en-US":XU,"ja-JP":ez});class o8{renderText(e,t,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(e,t,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(e,t,o,r){const i=r.comments;te(o,"comment"),Array.from(o.attributes).forEach(s=>{s.name.startsWith("comment-")&&o.removeAttribute(s.name)}),!(!i||i.length===0)&&(W(o,"comment"),i.forEach(s=>{o.setAttribute(`comment-${s.toLocaleLowerCase()}`,s)}))}}class tz{constructor(e){m(this,"handleUpdateCompositionText",(e,t,o,r,i)=>{const s=e.getFocusedBlock(),l=e.getFirstBlock();s===l&&this.applyPlaceholder(e)});m(this,"handleSelectionChange",e=>{this.applyPlaceholder(e)});m(this,"applyPlaceholder",e=>{const t=e.getFirstBlock();Tf(e,t,R.t("comment.replyPlaceholder"))});this.applyPlaceholder(e),e.addListener("selectionChanged",this.handleSelectionChange)}}function nz(n,e,t){const o=n.getBlockData(e),r=o.comments;if((r==null?void 0:r.indexOf(t))!==-1){const s=new Set(r);s.delete(t),n.updateBlockData(e,{comments:Array.from(s)})}const i=o.text;if(!!i&&ee(n,e)){const s=mg(i,`comment-${t.toLocaleLowerCase()}`,t);ua.default(i,s)||n.setBlockText(e,s)}}const oz=S("editor-comment");function rz(n){const e=n.getCustom("editor-comments");if(g(oz,e,"the editor comment not exist"),e.showCommentList(),n.selection.range.isCollapsed()){const s=n.selection.startBlock,l=Di(s);if(l.length>=2){const{containerId:a}=l.at(-1),d=oe($r(n,a));if(d&&De(d)==="code"){C2(n,d,e.commentProvider);return}}C2(n,s,e.commentProvider);return}const t=Lo(n,{simpleBlockOnly:!0}),o=t.map(s=>s.block),r=p2(n,o),i=Zf({editor:n,abstract:r});n.undoManager.runInGroup(()=>{t.forEach(l=>{ee(n,l.block)?t8(n,l,i):Oy(n,l.block,i)});const s=Ur();e.commentProvider.localCreateComment(i,s)})}const E2=S("text-styles");function iz(n){const e=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 t=e(n[0]);for(let o=1;o<n.length;o++){const r=e(n[o]);t=new Map(Array.from(t.entries()).filter(([i,s])=>r.get(i)===s))}return t}function sz(n,e,t,o,r){g(E2,t.isSimple(),"invalid range");const{start:i,end:s}=t;g(E2,i.blockId===s.blockId&&i.blockId===ie(e),"invalid range"),g(E2,o.startsWith("style-"),"invalid style");let a=n.getBlockText(e);return o==="style-sub"?a=ql(i.offset,s.offset-i.offset,a,"style-super",void 0,{ignoreValue:!0}):o==="style-super"&&(a=ql(i.offset,s.offset-i.offset,a,"style-sub",void 0,{ignoreValue:!0})),r===!1||r===void 0||r===null?a=ql(i.offset,s.offset-i.offset,a,o,void 0,{ignoreValue:!0}):a=Ia(i.offset,s.offset-i.offset,a,o,r),n.setBlockText(e,a),a}const lz=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
482
+ </svg>`,Nne="",Qf="reply-editor-editing",{t:w2}=R;class MU{constructor(e,t,o,r){m(this,"root");m(this,"components");m(this,"handleFocus",()=>{const{replyEditor:e,okButton:t}=this.components;e.isEmpty()&&W(t,Kr)});m(this,"handleDocChange",()=>{const{replyEditor:e,okButton:t}=this.components,o=e.getDoc();Ag(o)?W(t,Kr):te(t,Kr)});m(this,"getReplyEditor",()=>this.components.replyEditor);m(this,"showReplyEditor",()=>{xe(this.root,Qf)||(W(this.root,Qf),this.components.replyEditor.edit())});m(this,"hideReplyEditor",()=>{!xe(this.root,Qf)||te(this.root,Qf)});m(this,"reply",()=>{const{mainEditor:e,comment:t,components:{replyEditor:o},commentsProvider:r}=this,i=o.getDoc(),s=Zf({editor:e,commentGroupId:t.groupId});r.localCreateComment(s,i),this.hideReplyEditor(),o.clear()});m(this,"cancel",()=>{const{replyEditor:e}=this.components;this.hideReplyEditor(),e.clear()});m(this,"hide",()=>{xe(this.root,"hidden")||W(this.root,"hidden")});m(this,"show",()=>{te(this.root,"hidden")});this.mainEditor=e,this.commentsProvider=t,this.comment=o,this.groupItem=r,this.root=w("div",["comment-quick-reply"],null),this.components=this.createQuickReply()}createQuickReply(){const{commentsProvider:e}=this,t=Qs(this.root,Ye.QuickReply,w2("comment.placeholder"));Xr(t,Ye.QuickReply),t.classList.add("quick-reply-button");const o=w("div",["quick-reply-editor"],this.root),r=Ur(),i=new k2(this.mainEditor,e,r);i.editor.addListener("docChanged",this.handleDocChange),i.editor.addListener("focus",this.handleFocus),i.editor.input.addHandler(new BU(this.groupItem)),o.append(i.root);const s=w("div",["reply-editor-actions"],o),l=ji(Ye.QuickReplyCancel,w2("common.cancel"));Xr(l,Ye.QuickReplyCancel);const a=ji(Ye.QuickReplyOk,w2("comment.send"));return Xr(a,Ye.QuickReplyOk),W(a,Kr),s.append(l,a),this.hideReplyEditor(),{replyTextButton:t,replyEditor:i,replyEditorContainer:o,okButton:a}}}const ei=S("comment-group-item");class RU extends bt.TypedEmitter{constructor(t,o,r,i){super();m(this,"root");m(this,"header");m(this,"mainItem");m(this,"childrenList");m(this,"resizeObserver");m(this,"quickReply");m(this,"createRoot",()=>w("div",["comment-group-item-root"],null));m(this,"createChildrenList",()=>{const t=w("div",["comment-children-list-container"],this.root);return new DU({editor:this.editor,commentsProvider:this.commentsProvider,comments:this.comment.children,parent:t,groupList:this.groupList,groupItem:this})});m(this,"updateLastCommentItem",()=>{const t=Array.from(this.root.querySelectorAll(":scope .comment-item-root"));g(ei,t.length!==0,"current group item not exist comment-item"),t.forEach(r=>{te(r,_y)});const o=t.at(-1);W(o,_y)});m(this,"updateSwitchButton",()=>{const t=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"]');g(ei,t,"switchUpButton not exist"),g(ei,o,"switchDownButton not exist"),te(o,"disabled"),te(t,"disabled"),this.root.previousElementSibling===null&&W(t,"disabled"),this.root.nextElementSibling===null&&W(o,"disabled")});m(this,"handleReadonlyChanged",t=>{t.readonly?W(this.root,"readonly"):te(this.root,"readonly")});m(this,"handleResize",()=>{this.emit("resize")});this.editor=t,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.editor.on("readonlyChanged",this.handleReadonlyChanged),this.resizeObserver=new ResizeObserver(this.handleResize),this.resizeObserver.observe(this.root),this.updateLastCommentItem()}get commentCount(){return Py(this.root)}createQuickReply(){const{editor:t,commentsProvider:o,comment:r}=this,i=new MU(t,o,r,this);return this.root.append(i.root),i}createHeader(){const{comment:t}=this,o=w("div",["comment-item-head"],this.root),r=w("span",["item-head-quote"],o);r.innerText=t.abstract;const i=w("span",["item-head-switch"],o),s=Qs(i,Ye.SwitchUp,"up",SU),l=Qs(i,Ye.SwitchDown,"down",LU);return Xr(s,Ye.SwitchUp),Xr(l,Ye.SwitchDown),o}createItem(){const t=w("div",["comment-item-container"],this.root),{editor:o,commentsProvider:r,comment:i,groupList:s}=this,l=new Gy({mainEditor:o,commentsProvider:r,comment:i,groupList:s,groupItem:this});return t.appendChild(l.root),l}findCommentItem(t){return t?t===this.mainItem.comment.id?this.mainItem:this.childrenList.items.find(o=>o.comment.id===t):null}handleCreateComment(t){return g(ei,Js(t),"invalid comment, not a child comment"),g(ei,t.groupId===this.comment.id,"invalid comment, not a child comment"),this.childrenList.createItem(t)}handleUpdateChildComment(t){g(ei,t.groupId===this.mainItem.comment.id,"invalid child comment");const o=this.childrenList.findItem(t.id);if(!o){ei.error(`can't find child comment item: ${t.id}`);return}o.reloadDoc()}handleUpdateMainComment(t){g(ei,t.id===this.mainItem.comment.id,"invalid comment"),this.mainItem.reloadDoc()}deleteMainComment(t){g(ei,t===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(),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged)}}const OU=S("arrange=items"),Qy=20;function Yy(n,e){const t=n.rootContainer.querySelector(`[comment-${e.toLocaleLowerCase()}=${e}`);if(!t)return-1;const o=n.scrollContainer.getBoundingClientRect(),r=n.scrollContainer.scrollTop;return t.getBoundingClientRect().top-o.top+r}function Jy(n,e){return Number.parseInt(e.root.style.top,10)}function Ky(n,e,t,o){let r=0;t&&(r=e.indexOf(t),r===-1&&(r=0));for(let i=r;i<e.length;i++){const s=e[i],l=s.comment,a=Yy(n,l.groupId);if(s.root.setAttribute("data-target-top",a.toString()),i===r){if(o!==void 0){const p=e[0];p.root.style.top=`${o}px`}else s.root.style.top=`${a}px`;continue}const d=e[i-1],h=Jy(n,d)+d.root.getBoundingClientRect().height;h>a?s.root.style.top=`${h+Qy}px`:s.root.style.top=`${a}px`}for(let i=r-1;i>=0;i--){const s=e[i],l=s.comment,a=Yy(n,l.groupId);s.root.setAttribute("data-target-top",a.toString());const d=s.root.getBoundingClientRect(),h=a+d.height,p=e[i+1];g(OU,p,"no next item");const A=Jy(n,p);A<h?s.root.style.top=`${A-d.height-Qy}px`:s.root.style.top=`${a}px`}setTimeout(()=>{n.scrollContainer.dispatchEvent(new Event("scroll"))},350)}const Yf=S("comment-group-item-handler");class _U{constructor(e,t){m(this,"handleSwitchUp",e=>{const t=Math.max(0,e-1);this.groupList.setActiveItem(t),this.groupList.updateItemsLayout()});m(this,"handleSwitchDown",e=>{const t=Math.min(e+1,this.groupList.items.length);this.groupList.setActiveItem(t),this.groupList.updateItemsLayout()});m(this,"handleQuickReply",e=>{const{quickReply:t}=e;t.showReplyEditor()});m(this,"handleQuickReplyOk",e=>{const{quickReply:t}=e;t.reply(),e.updateLastCommentItem()});m(this,"handleQuickReplyCancel",e=>{const{quickReply:t}=e;t.cancel()});m(this,"handleCommentItemReply",(e,t)=>{const o=e.findCommentItem(t);g(Yf,o,`the commentItem: ${t} not exist `);const{quickReply:r}=e;r.show(),r.showReplyEditor();const{comment:i}=o,s=r.getReplyEditor(),l=s.editor.getFocusedBlock(),a={type:"mention",id:K(),box:!0,created:Date.now(),text:i.displayName,iconUrl:i.avatarUrl,mentionId:i.userId};s.editor.insertBoxToBlock(l,0,a)});m(this,"handleCommentItemMore",e=>{const{quickReply:t}=e;t.hideReplyEditor(),t.getReplyEditor().clear()});m(this,"handleCommentItemOk",(e,t)=>{const o=e.findCommentItem(t);g(Yf,o,`the commentItem: ${t} not exist `);const{quickReply:r}=e,{comment:i,getCommentEditor:s}=o,l=s(),a=l.getDoc();this.commentsProvider.localUpdateComment(i,a),l.readonly(),r.show()});m(this,"handleCommentItemCancel",(e,t)=>{var a,d;const o=e.findCommentItem(t);g(Yf,o,`the commentItem: ${t} not exist `);const r=this.commentsProvider.getComment(o.comment.id);let i=!1;if((a=r.blocks)!=null&&a.length||(i=!0),((d=r.blocks)==null?void 0:d.length)===1){const h=r.blocks[0];i=!!h.text&&rn(h.text)===0}if(i){this.commentsProvider.localDeleteComment(o.comment.id);return}const{quickReply:s}=e,l=o.getCommentEditor();l.setDoc(o.doc),l.readonly(),s.show()});m(this,"handleCommentItemEdit",e=>{const t=this.groupList.findItem(e.comment.groupId);if(!t)return;const{quickReply:o}=t;e.getCommentEditor().edit(),o.hide()});m(this,"handleCommentItemDelete",e=>{const t=this.groupList.findItem(e.comment.groupId);if(!t)return;const{quickReply:o}=t,{comment:r}=e;this.commentsProvider.localDeleteComment(r.id),o.show()});m(this,"execute",(e,t,o,r)=>{const i=pU(e);if(!i||AU(i))return;const s=CU(i);switch(s){case Ye.SwitchUp:this.handleSwitchUp(r);break;case Ye.SwitchDown:this.handleSwitchDown(r);break;case Ye.CommentItemReply:this.handleCommentItemReply(t,o);break;case Ye.CommentItemMore:this.handleCommentItemMore(t);break;case Ye.CommentItemOk:this.handleCommentItemOk(t,o);break;case Ye.CommentItemCancel:this.handleCommentItemCancel(t,o);break;case Ye.CommentItemDelete:break;case Ye.CommentItemEdit:break;case Ye.QuickReply:this.handleQuickReply(t);break;case Ye.QuickReplyOk:this.handleQuickReplyOk(t);break;case Ye.QuickReplyCancel:this.handleQuickReplyCancel(t);break;default:const l=s;Yf.debug(`not implement handler for ${l}`)}});this.groupList=e,this.commentsProvider=t}destroy(){}}const Jf=S("comment-group-list");class FU extends _u{constructor(t,o,r){super(t,o,r,es(t,o),{});m(this,"groupItemHandlers");m(this,"findGroupItem",t=>this.items.find(o=>o.comment.groupId===t));m(this,"handleContainerClick",t=>{if(!t.target||!(t.target instanceof Element))return;const o=t.target.closest(".comment-group-item-root");if(!o)return;const r=gU(t.target),i=this.items.findIndex(s=>s.root===o);if(i!==-1){this.setActiveItem(i);const{groupItemHandlers:s}=this;s.execute(t.target,this.items.at(i),r,i)}});m(this,"handleSelectionChanged",()=>{var o;const t=Uy(this.editor);if(t.length>0){if(((o=this.activeItem)==null?void 0:o.comment.id)&&t.includes(this.activeItem.comment.id))return;const r=t[0],i=this.items.findIndex(s=>s.comment.groupId===r);this.setActiveItem(i),this.emit("selectionOnComment")}else this.setActiveItem(-1)});m(this,"handleEditorResize",()=>{this.updateItemsLayout()});m(this,"handleDocChanged",()=>{this.updateComments()});m(this,"handleItemResize",()=>{this.updateItemsLayout()});m(this,"handleScroll",t=>{if(t.deltaY>=0||this.editor.scrollContainer.scrollTop!==0)return;const o=document.elementFromPoint(t.clientX,t.clientY);if(!o||!(o instanceof HTMLElement)||!this.editor.scrollContainer.contains(o))return;const r=this.container.querySelector(".comment-group-item-root");if(!r)return;const i=Number.parseFloat(r.style.top),s=Number.parseFloat(r.getAttribute("data-target-top")||"0");!Number.isNaN(i)&&!Number.isNaN(s)&&i<s&&Ky(this.editor,this.items,null,Math.min(i+(0-t.deltaY)*3,s))});m(this,"updateGroupItemSwitch",()=>{const t=this.activeItem;g(Jf,t,"invalid activeItem"),t.updateSwitchButton()});m(this,"updateComments",Ht.default(()=>{const t=es(this.editor,this.commentsProvider);let o=!1;for(let r=0;r<t.length;r++){const i=t[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];t.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.editor.scrollContainer.addEventListener("wheel",this.handleScroll,{passive:!1}),this.items.forEach(i=>i.addListener("resize",this.handleItemResize)),this.groupItemHandlers=new _U(this,o)}destroy(){this.editor.removeListener("selectionChanged",this.handleSelectionChanged),this.editor.removeListener("resize",this.handleEditorResize),this.editor.removeListener("docChanged",this.handleDocChanged),this.editor.scrollContainer.removeEventListener("wheel",this.handleScroll),super.destroy(),this.unbindEvents(),this.removeAllListeners()}updateItemsLayout(){Ky(this.editor,this.items,this.activeItem)}bindEvents(){this.container.addEventListener("click",this.handleContainerClick)}unbindEvents(){this.container.removeEventListener("click",this.handleContainerClick)}createItem(t,o){const r=new RU(this.editor,this.commentsProvider,t,this);return o==="insert"&&(W(r.root,"no-animation"),r.root.style.opacity="0",setTimeout(()=>{te(r.root,"no-animation"),r.root.style.opacity="1"},150)),r}findInsertPos(t){const r=es(this.editor,this.commentsProvider).findIndex(i=>i.id===t.id);return r===-1||r>this.items.length?-1:r}insertItem(t,o){const r=super.insertItem(t);return r?(o!=null&&o.active&&this.setActiveItem(this.items.indexOf(r)),this.updateItemsLayout(),r.addListener("resize",this.handleItemResize),r):null}setActiveItem(t){if(g(Jf,t>=-1&&t<this.items.length,`invalid index: ${t}`),t===this.activeIndex)return;const o=this.container.querySelector(".comment-group-item-root.active");if(o&&te(o,"active"),t!==-1){const r=this.items[t];W(r.root,"active"),this.updateItemsLayout(),this.updateGroupItemSwitch()}this.emit("activeItemChanged",t)}get activeIndex(){const t=this.container.querySelector(".comment-group-item-root.active");return t?this.items.findIndex(o=>o.root===t):-1}get activeItem(){const t=this.activeIndex;return t===-1?null:this.items[t]}handleCreateComment(t,o){if(Js(t)){const l=this.findGroupItem(t.groupId);l&&l.childrenList.insertItem(t)}const r=this.findItem(t.id);g(Jf,!r,"comment group item has already exists");const i={children:[],...t};g(Jf,i.children,"not a comment group");const s=this.insertItem(i,{active:o});!s||o&&setTimeout(()=>{const l=this.items.indexOf(s);this.setActiveItem(l),s.edit(),s.quickReply.hide()})}handleDeleteComment(t){for(let o=0;o<this.items.length;o++){const r=this.items[o];if(r.comment.id===t){r.childrenList.items.length===0?(this.deleteItem(r.comment.id),this.updateItemsLayout()):r.deleteMainComment(t);return}if(r.childrenList.deleteItem(t)){r.commentCount===0&&(this.deleteItem(r.comment.id),this.updateItemsLayout());return}}}handleUpdateComment(t){if(Js(t)){const r=this.commentsProvider.getComment(t.groupId),i=this.findItem(r.id);i&&i.handleUpdateChildComment(t);return}const o=this.findItem(t.id);o&&o.handleUpdateMainComment(t)}}const PU="comment-mini";S("comment-list");class NU extends bt.TypedEmitter{constructor(t,o){super();m(this,"root");m(this,"groupsContainer");m(this,"list");m(this,"handleSelectionOnComment",()=>{this.emit("onSelectComment")});m(this,"updateCommentCount",()=>{var o,r;const t=yU(this.editor,this.commentsProvider);(r=(o=this.commentOptions)==null?void 0:o.onCommentCountChange)==null||r.call(o,t)});m(this,"handleActiveItemChanged",()=>{var o;const t=this.list.activeItem;Vy(this.editor,(o=t==null?void 0:t.comment.id)!=null?o:"")});m(this,"handleItemLayoutUpdated",()=>{var o,r;const t=xe(this.root,PU);(r=(o=this.commentOptions)==null?void 0:o.onUpdateLayout)==null||r.call(o,this.editor,{expand:t})});this.editor=t,this.commentsProvider=o,this.root=w("div",["editor-web-comment-root"],null),this.groupsContainer=w("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(t,o){const r=this.commentsProvider.getComment(t);this.list.handleCreateComment(r,o),this.updateCommentCount()}onDeleteComment(t,o){this.list.handleDeleteComment(t),this.updateCommentCount()}onUpdateComment(t,o){const r=this.commentsProvider.getComment(t);this.list.handleUpdateComment(r)}createList(){return new FU(this.editor,this.commentsProvider,this.groupsContainer)}show(t){var o;if(te(this.root,"hidden"),t){const r=this.list.findItemIndex(t);this.list.setActiveItem(r)}(o=this.commentOptions)==null||o.controller.showCommentList()}hide(){W(this.root,"hidden")}}class $U extends _u{constructor({editor:e,parent:t,commentsProvider:o,comments:r}){super(e,o,t,r,{})}findInsertPos(){return this.items.length}createItem(e){const{editor:t,commentsProvider:o}=this;return new Zy(t,o,e)}destroy(){this.items.forEach(e=>{e.destroy()})}}const Kf=S("mobile-comment-group-item"),HU=20;class jU extends bt.TypedEmitter{constructor(t,o,r){super();m(this,"root");m(this,"childrenList");m(this,"mainItem");m(this,"scroller");m(this,"createRoot",()=>w("div",["mobile-group-item-root"],null));m(this,"createMainItem",t=>{const{editor:o,commentsProvider:r,comment:i}=this,s=new Zy(o,r,i);return t.append(s.root),s});m(this,"createChildrenList",t=>{const{editor:o,commentsProvider:r,comment:i}=this,s=w("div",["mobile-comment-children-list-container"],t);return new $U({editor:o,commentsProvider:r,comments:i.children,parent:s})});m(this,"handleTouchEnd",()=>{var i;const{scroller:t}=this,{pullThreshold:o=HU}=(i=this.editor.getComponentOptions("comment"))!=null?i:{};let r=null;if(t.y>t.minScrollY+o?(r=this.root.previousElementSibling,r||this.emit("onReachTop")):t.y<t.maxScrollY-o&&(r=this.root.nextElementSibling,r||this.emit("onReachBottom")),r){const s=r.id;this.emit("onSwitchGroup",s,Fy)}});m(this,"refreshScroller",()=>{this.scroller.refresh()});this.editor=t,this.commentsProvider=o,this.comment=r,this.root=w("div",["mobile-group-item-root"],null),this.root.id=r.groupId;const i=w("div",["mobile-group-item"],this.root),s=w("div",["mobile-group-item-space"],null),l=w("div",["mobile-group-item-abstract"],null);l.textContent=r.abstract;const a=w("div",["mobile-group-item-list-container"],null);this.mainItem=this.createMainItem(a),this.childrenList=this.createChildrenList(a),i.append(s,l,a),this.scroller=new Q5.default(this.root,{stopPropagation:!0,click:!0}),this.scroller.on("touchEnd",this.handleTouchEnd)}get commentCount(){return Py(this.root,".mobile-group-item")}handleUpdateChildComment(t){g(Kf,t.groupId===this.mainItem.comment.id,"invalid child comment");const o=this.childrenList.findItem(t.id);if(!o){Kf.error(`can't find child comment item: ${t.id}`);return}o.reloadDoc()}handleUpdateMainComment(t){g(Kf,t.id===this.mainItem.comment.id,"invalid comment"),this.mainItem.reloadDoc()}deleteMainComment(t){g(Kf,t===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 B2=S("mobile-group-list");class UU extends _u{constructor(t,o,r,i){super(t,o,r,es(t,o),{});m(this,"scroller");m(this,"refreshScroller",()=>{this.scroller.refresh(),this.items.forEach(t=>{t.refreshScroller()})});m(this,"deleteItem",t=>{if(this.items.length<=1)return super.deleteItem(t);const o=this.findItemIndex(t);let r=null;return o===0?r=this.items[o+1].root.id:r=this.items[o-1].root.id,super.deleteItem(t)?(this.scrollToGroup(r,Fy),!0):!1});m(this,"setupGroupItem",t=>{t.on("onSwitchGroup",this.scrollToGroup),t.on("onReachBottom",this.handleReachBottom),t.on("onReachTop",this.handleReachTop),t.refreshScroller()});m(this,"handleReachBottom",()=>{this.emit("onReachBottom")});m(this,"handleReachTop",()=>{this.emit("onReachTop")});m(this,"scrollToGroup",(t,o=0)=>{const r=this.findGroupItem(t);g(B2,r,"invalid scroll target"),this.scroller.scrollToElement(r.root,o,!1,!1),Vy(this.editor,r.comment.id)});m(this,"findGroupItem",t=>this.items.find(o=>o.comment.groupId===t));m(this,"handleDocChanged",()=>{this.updateComments()});m(this,"updateComments",Ht.default(()=>{const t=es(this.editor,this.commentsProvider);for(let o=0;o<t.length;o++){const r=t[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];t.findIndex(i=>i.groupId===r.comment.groupId)===-1&&this.deleteItem(r.comment.id)}},100));this.scroller=new Q5.default(i),this.scroller.disable(),this.editor.addListener("docChanged",this.handleDocChanged),this.items.forEach(this.setupGroupItem)}createItem(t){return new jU(this.editor,this.commentsProvider,t)}insertItem(t){const o=super.insertItem(t);return o?(this.setupGroupItem(o),o):null}findInsertPos(t){const r=es(this.editor,this.commentsProvider).findIndex(i=>i.id===t.id);return r===-1||r>this.items.length?-1:r}setActiveItem(t){this.scrollToGroup(t)}handleCreateComment(t,o){if(Js(t)){const s=this.findGroupItem(t.groupId);s&&s.childrenList.insertItem(t)}const r=this.findItem(t.id);g(B2,!r,"comment group item has already exists");const i={children:[],...t};g(B2,i.children,"not a comment group"),this.insertItem(i),this.scroller.refresh()}handleDeleteComment(t){for(let o=0;o<this.items.length;o++){const r=this.items[o];if(r.comment.id===t){r.childrenList.items.length===0?this.deleteItem(r.comment.id):r.deleteMainComment(t);return}if(r.childrenList.deleteItem(t)){r.commentCount===0&&this.deleteItem(r.comment.id);return}}}handleUpdateComment(t){if(Js(t)){const r=this.commentsProvider.getComment(t.groupId),i=this.findItem(r.id);i&&i.handleUpdateChildComment(t);return}const o=this.findItem(t.id);o&&o.handleUpdateMainComment(t)}destroy(){this.editor.removeListener("docChanged",this.handleDocChanged),this.scroller.destroy(),this.items.forEach(t=>t.destroy())}}const zU=S("mobile-comment-list"),{t:Xy}=R;class VU extends bt.TypedEmitter{constructor(t,o){super();m(this,"root");m(this,"list");m(this,"mask");m(this,"pullInfoContainer");m(this,"handleRootClick",t=>{const o=t.target;g(zU,o instanceof Element,"invalid target"),!(o.closest(".mobile-group-item-abstract")||o.closest(".mobile-group-item-list-container"))&&(this.hide(),this.emit("onCommentListClose"))});m(this,"hidePullInfo",Ht.default(()=>{te(this.pullInfoContainer,"active")},1e3*3));m(this,"handleReachBottom",()=>{this.showPullInfo("bottom")});m(this,"handleReachTop",()=>{this.showPullInfo("top")});m(this,"show",t=>{var o;te(this.root,"hidden"),W(document.documentElement,"disabled-scroll"),(o=this.commentOptions)==null||o.controller.showCommentList(),queueMicrotask(()=>{this.list.refreshScroller(),t&&this.list.setActiveItem(t)})});m(this,"hide",()=>{W(this.root,"hidden"),te(document.documentElement,"disabled-scroll")});this.editor=t,this.commentsProvider=o,this.root=w("div",["editor-mobile-comments-root"],null),this.mask=w("div",["mobile-comment-mask"],this.root);const r=w("div",["mobile-comment-groups-container"],this.root),i=w("div",["mobile-comment-groups-scroll-container"],r);this.list=new UU(this.editor,this.commentsProvider,i,r),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(t,o){const r=this.commentsProvider.getComment(t);this.list.handleCreateComment(r,o)}onDeleteComment(t,o){this.list.handleDeleteComment(t)}onUpdateComment(t,o){const r=this.commentsProvider.getComment(t);this.list.handleUpdateComment(r)}get commentOptions(){return this.editor.getComponentOptions("comment")}createPullInfo(){const t=w("div",["mobile-comment-pull-info-container"],this.root);return w("div",["mobile-comment-pull-info"],t),t}showPullInfo(t){const o=Xy(t==="bottom"?"comment.isLast":"comment.isFirst");this.pullInfoContainer.firstElementChild.textContent=o,W(this.pullInfoContainer,"active"),this.hidePullInfo()}destroy(){this.list.removeAllListeners(),this.list.destroy(),this.root.onclick=null}}function e8(n,e){const t=es(n,e),o=new Map;for(const r of t){const i=Ny(n,r.groupId);if(!!i)if(o.has(i)){const s=o.get(i);b2(r).forEach(a=>{s==null||s.commentIds.add(a.id)})}else{const s=b2(r),l=new Set(s.map(a=>a.id));o.set(i,{commentIds:l,firstComment:r})}}return Array.from(o.entries()).map(([r,i])=>({blockId:r,...i}))}const WU=S("mini-group-item");class qU{constructor(e,t){m(this,"root");m(this,"blockId");m(this,"comment");m(this,"miniCommentItem");m(this,"updateCommentItemCount",()=>{this.miniCommentItem.updateCount(this.commentCount)});this.editor=e,this.commentGroup=t,this.root=w("div",["mini-group-item"],null),this.comment=t.firstComment,this.miniCommentItem=new TU(this.comment.id,this.root),this.blockId=this.getBlockId(),this.alignToBlock(),this.updateCommentItemCount()}getBlockId(){return Ny(this.editor,this.comment.groupId)}get commentCount(){return this.commentGroup.commentIds.size}alignToBlock(){const e=this.getBlockId(),t=this.editor.getBlockById(e);g(WU,t,`The blockId: ${e} not exist in doc`);const o=this.editor.scrollContainer.getBoundingClientRect(),r=this.editor.scrollContainer.scrollTop,s=t.getBoundingClientRect().top-o.top+r;requestAnimationFrame(()=>{this.root.style.transform=`translateY(${s}px)`})}destroy(){this.root.remove()}}class GU extends _u{constructor(t,o,r){super(t,o,r,e8(t,o),{});m(this,"fixListOps",Ht.default(()=>{this.items.forEach(t=>{t.alignToBlock()})},100));m(this,"handleDocChanged",Ht.default(()=>{this.updateMiniCommentsGroup()},100));m(this,"updateMiniCommentsGroup",()=>{const t=e8(this.editor,this.commentsProvider);this.reloadList(t)});this.editor=t,this.commentsProvider=o,this.editor.addListener("docChanged",this.handleDocChanged),this.editor.addListener("resize",this.fixListOps)}createItem(t){return new qU(this.editor,t)}findInsertPos(){return-1}handleCreateComment(t,o){this.updateMiniCommentsGroup()}handleDeleteComment(t){this.updateMiniCommentsGroup()}destroy(){this.editor.removeListener("docChanged",this.handleDocChanged),super.destroy(),this.removeAllListeners()}}const ZU=S("mini-comments-list");class QU extends bt.TypedEmitter{constructor(t,o){super();m(this,"list");m(this,"root");m(this,"createList",()=>{const t=w("div",["comment-groups-container"],this.root);return this.editor.domEvents.addEventListener(t,"click",this.handleListContainerClick),new GU(this.editor,this.commentsProvider,t)});m(this,"handleListContainerClick",(t,o)=>{const r=o.target;g(ZU,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=t,this.commentsProvider=o,this.root=w("div",["editor-mini-comment-root"],null),this.list=this.createList(),this.commentsProvider.addListener(this)}onCreateComment(t,o){const r=this.commentsProvider.getComment(t);this.list.handleCreateComment(r,o)}onDeleteComment(t,o){this.list.handleDeleteComment(t)}onUpdateComment(t,o){}show(){te(this.root,"hidden")}hide(){W(this.root,"hidden")}destroy(){this.list.destroy(),this.removeAllListeners()}}function t8(n,e,t){if(!e.start.isSimple()||!e.end.isSimple())return;const o=e.block,r=yt(n,o,e.start.offset,e.end.offset),i=`comment-${t.id.toLocaleLowerCase()}`,s=t.id;q6(n,o,r,i,s)}function YU(n,e,t){const o=Lo(n).map(s=>s.block),r=p2(n,o),i=Zf({editor:n,abstract:r});return n.undoManager.runInGroup(()=>{Lo(n,{simpleBlockOnly:!0}).forEach(a=>{!ee(n,a.block)||t8(n,a,i)});const l=Ur();t.localCreateComment(i,l)}),i}class JU{constructor(e,t){m(this,"id","CommentsCommandProvider");this.provider=e,this.editorComments=t}getAvailableCommands(e,t,o){const r=e.selection.range;if(ee(e,t)&&!o.isCollapsed()&&r.isSimple()){const i=ie(t),s=De(t),l=Io(e,t);return[{id:"add-comment",name:R.t("comment.command"),blockId:i,blockType:s,blockKind:l,groupIndex:1e3,icon:tu}]}return[]}executeRangeCommand(e,t,o,r,i){if(o.id==="add-comment"){this.editorComments.showCommentList();const s=YU(e,t,this.provider);return i["add-comment"]=s,!0}return!1}}class n8{constructor(e,t){m(this,"commentList",null);m(this,"mobileCommentList",null);m(this,"miniCommentList");m(this,"showComment",(e,t)=>{var o,r;e==="mini"&&this.miniCommentList.show(),e==="mobile"&&((o=this.mobileCommentList)==null||o.show(t)),e==="web"&&((r=this.commentList)==null||r.show(t))});m(this,"showCommentList",e=>{this.isMobile?this.showComment("mobile",e):this.showComment("web",e)});m(this,"handleCommentListClose",()=>{this.showComment("mini")});m(this,"handleOnSelectComment",()=>{this.showComment("web")});m(this,"handleMiniCommentItemClick",e=>{this.showCommentList(e)});this.editor=e,this.provider=t,e.editorCommandProviders.registerCommandProvider(new JU(t,this)),e.blockHooks.push(new fU(this.provider,this)),this.isMobile?(this.mobileCommentList=new VU(this.editor,this.provider),this.mobileCommentList.on("onCommentListClose",this.handleCommentListClose)):(this.commentList=new NU(this.editor,this.provider),this.commentList.on("onSelectComment",this.handleOnSelectComment)),this.miniCommentList=new QU(this.editor,this.provider),this.miniCommentList.on("onItemClick",this.handleMiniCommentItemClick),this.editor.input.addHandler(new mU)}get commentProvider(){return this.provider}get isMobile(){return Kt.isMobile}destroy(){var e,t;(e=this.commentList)==null||e.destroy(),(t=this.mobileCommentList)==null||t.destroy(),this.miniCommentList.destroy()}mount(e){var t;e.container&&this.commentList&&e.container.append((t=this.commentList)==null?void 0:t.root),e.miniContainer&&e.miniContainer.append(this.miniCommentList.root),e.mobileContainer&&this.mobileCommentList&&e.mobileContainer.append(this.mobileCommentList.root)}}const $ne="",KU={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",more:"\u66F4\u591A",comment:"\u6279\u6CE8",command:"\u6279\u6CE8",quickMenuCommand:"\u6DFB\u52A0\u6279\u6CE8"}},XU={comment:{count:"Annotations ({num})",hide:"Hide Annotations",show:"Show Annotations",reply:"Reply",quicklyReply:"Reply...",send:"Confirm",placeholder:"Add a annotation...",replyPlaceholder:"Add Annotations or @ others",edit:"Edit",delete:"Delete",image:"Image",sendTitle:"Press Enter to post annotation",replyTitle:"Press Enter to reply to annotation",isFirst:"This is already the first comment",isLast:"This is already the last comment",more:"More",comment:"Annotation",command:"Annotation",quickMenuCommand:"Add annotation"}},ez={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:"\u78BA\u8A8D",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",more:"\u305D\u306E\u4ED6",comment:"\u30B3\u30E1\u30F3\u30C8\u3092",command:"\u30B3\u30E1\u30F3\u30C8\u3092",quickMenuCommand:"\u6CE8\u91C8\u3092\u8FFD\u52A0"}};R.mergeLang({"zh-CN":KU,"en-US":XU,"ja-JP":ez});class o8{renderText(e,t,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(e,t,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(e,t,o,r){const i=r.comments;te(o,"comment"),Array.from(o.attributes).forEach(s=>{s.name.startsWith("comment-")&&o.removeAttribute(s.name)}),!(!i||i.length===0)&&(W(o,"comment"),i.forEach(s=>{o.setAttribute(`comment-${s.toLocaleLowerCase()}`,s)}))}}class tz{constructor(e){m(this,"handleUpdateCompositionText",(e,t,o,r,i)=>{const s=e.getFocusedBlock(),l=e.getFirstBlock();s===l&&this.applyPlaceholder(e)});m(this,"handleSelectionChange",e=>{this.applyPlaceholder(e)});m(this,"applyPlaceholder",e=>{const t=e.getFirstBlock();Tf(e,t,R.t("comment.replyPlaceholder"))});this.applyPlaceholder(e),e.addListener("selectionChanged",this.handleSelectionChange)}}function nz(n,e,t){const o=n.getBlockData(e),r=o.comments;if((r==null?void 0:r.indexOf(t))!==-1){const s=new Set(r);s.delete(t),n.updateBlockData(e,{comments:Array.from(s)})}const i=o.text;if(!!i&&ee(n,e)){const s=mg(i,`comment-${t.toLocaleLowerCase()}`,t);ua.default(i,s)||n.setBlockText(e,s)}}const oz=S("editor-comment");function rz(n){const e=n.getCustom("editor-comments");if(g(oz,e,"the editor comment not exist"),e.showCommentList(),n.selection.range.isCollapsed()){const s=n.selection.startBlock,l=Di(s);if(l.length>=2){const{containerId:a}=l.at(-1),d=oe($r(n,a));if(d&&De(d)==="code"){C2(n,d,e.commentProvider);return}}C2(n,s,e.commentProvider);return}const t=Lo(n,{simpleBlockOnly:!0}),o=t.map(s=>s.block),r=p2(n,o),i=Zf({editor:n,abstract:r});n.undoManager.runInGroup(()=>{t.forEach(l=>{ee(n,l.block)?t8(n,l,i):Oy(n,l.block,i)});const s=Ur();e.commentProvider.localCreateComment(i,s)})}const E2=S("text-styles");function iz(n){const e=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 t=e(n[0]);for(let o=1;o<n.length;o++){const r=e(n[o]);t=new Map(Array.from(t.entries()).filter(([i,s])=>r.get(i)===s))}return t}function sz(n,e,t,o,r){g(E2,t.isSimple(),"invalid range");const{start:i,end:s}=t;g(E2,i.blockId===s.blockId&&i.blockId===ie(e),"invalid range"),g(E2,o.startsWith("style-"),"invalid style");let a=n.getBlockText(e);return o==="style-sub"?a=ql(i.offset,s.offset-i.offset,a,"style-super",void 0,{ignoreValue:!0}):o==="style-super"&&(a=ql(i.offset,s.offset-i.offset,a,"style-sub",void 0,{ignoreValue:!0})),r===!1||r===void 0||r===null?a=ql(i.offset,s.offset-i.offset,a,o,void 0,{ignoreValue:!0}):a=Ia(i.offset,s.offset-i.offset,a,o,r),n.setBlockText(e,a),a}const lz=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
483
483
  <line x1="3.5" y1="0.5" x2="3.5" y2="15.5" stroke="currentColor"/>
484
484
  <path d="M4 8L7.5 8C9.433 8 11 6.433 11 4.5V4.5C11 2.567 9.433 1 7.5 1L4 1" stroke="currentColor"/>
485
485
  <path d="M4 15L9.5 15C11.433 15 13 13.433 13 11.5V11.5C13 9.567 11.433 8 9.5 8L4 8" stroke="currentColor"/>
@@ -506,7 +506,7 @@ width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
506
506
  <path d="M1.00098 12.9985L10.9995 2.99998" stroke="currentColor"/>
507
507
  <path d="M11.9113 6.16809L13.7433 3.79209C13.946 3.52009 14.0473 3.26142 14.0473 3.01609V2.90409C14.0473 2.71209 13.994 2.56009 13.8873 2.44809C13.786 2.33609 13.6473 2.28009 13.4713 2.28009C13.2953 2.28009 13.1567 2.33876 13.0553 2.45609C12.954 2.57342 12.9033 2.73609 12.9033 2.94409V3.07209H11.8873V2.88009C11.8873 2.59209 11.9513 2.33609 12.0793 2.11209C12.2127 1.88809 12.402 1.71209 12.6473 1.58409C12.8927 1.45609 13.1807 1.39209 13.5113 1.39209C13.8313 1.39209 14.1113 1.45876 14.3513 1.59209C14.5967 1.72542 14.7833 1.90409 14.9113 2.12809C15.0447 2.35209 15.1113 2.60009 15.1113 2.87209V3.00809C15.1113 3.24809 15.0687 3.46942 14.9833 3.67209C14.898 3.87476 14.7727 4.08276 14.6073 4.29609L13.2313 6.08009H15.1113V7.00009H11.9113V6.16809Z" fill="currentColor"/>
508
508
  </svg>
509
- `,Ks=S("text-commands");function r8(n){const e={id:"more",name:R.t("commands.more"),icon:iv,childrenType:"menu",childrenPlacement:"bottom-start",manualShowChildren:!0,children:[]},t={"style-bold":[R.t("commands.bold"),Bo("CtrlOrCmd+B"),lz],"style-italic":[R.t("commands.italic"),Bo("CtrlOrCmd+I"),cz],"style-underline":[R.t("commands.underline"),Bo("CtrlOrCmd+U"),az],"style-strikethrough":[R.t("commands.strikethrough"),Bo("CtrlOrCmd+D"),uz],"style-code":[R.t("commands.code"),void 0,dz]},o={"style-super":[R.t("commands.superscript"),void 0,fz],"style-sub":[R.t("commands.subscript"),void 0,hz]};if(rn(n)===0){const l=Object.entries(t).map(([a,[d,h,p]])=>({id:a,name:d,icon:p,desc:h}));return e.children=Object.entries(o).map(([a,[d,h,p]])=>({id:a,name:d,icon:p,desc:h})),l.concat(e)}const r=iz(n);function i([l,[a,d,h]]){const p=r.get(l);return p!==void 0?{id:l,name:a,value:p,states:p===!0?["checked"]:void 0,icon:h,desc:d}:{id:l,name:a,icon:h,desc:d}}const s=Object.entries(t).map(i);return e.children=Object.entries(o).map(i),s.concat(e)}function mz(n,e){const t=ie(e),o=De(e),r=Io(n,e);return r8([]).map(i=>({blockId:t,blockType:o,blockKind:r,...i,groupIndex:500}))}function gz(n,e,t){g(Ks,t.isSimple(),"nor a simple range");const{start:o,end:r}=t;g(Ks,o.isSimple(),"is not a simple block position"),g(Ks,r.isSimple(),"is not a simple block position"),g(Ks,ee(n,e),"invalid block type, not a text kind block");const i=ie(e);g(Ks,o.blockId===i&&r.blockId===i,"invalid range");const s=n.getBlockText(e);let l=[];o.offset===r.offset?o.offset!==0&&(l=zt(s,o.offset-1,1).middle):l=zt(s,o.offset,r.offset-o.offset).middle;const a=De(e),d=Io(n,e);return r8(l).map((h,p)=>({blockId:i,blockType:a,blockKind:d,...h,groupIndex:500,order:p*100}))}function pz(n,e,t,o,r,i){if(!ee(n,e))return!1;if(!o.startsWith("style-"))return Ks.warn(`unknown command: ${o}`),!1;const s=r==null?void 0:r.value,l=typeof s;if(l!=="string"&&l!=="number"&&l!=="boolean"&&l!=="undefined")return Ks.warn(`invalid value type, accept string | number | boolean | undefined, current is ${l}`),!1;const a=sz(n,e,t,o,s);return n.focus(),i.result=a,!0}const Cz=S("text-command-provider");class Ar{constructor(e){m(this,"id","TextCommandProvider");m(this,"emptyTextBlockAttributes",new Map);m(this,"colorItem");m(this,"updateButtonColor",()=>{const e=jg(this.editor,this.getEmptyTextBlockColor);this.colorItem.updateButtonColor(e)});m(this,"handleChangeColor",(e,t)=>{if(e==="color"||e==="backgroundColor")G6(this.editor,e,t,this.setEmptyTextBlockColor);else{const o=["clearAll","clearColor","clearBackground"];Z6(this.editor,o[t],this.setEmptyTextBlockColor)}this.editor.focus()});m(this,"handleBeforePopupPalette",()=>{const e=jg(this.editor,this.getEmptyTextBlockColor);this.colorItem.updatePaletteColor(e)});m(this,"getEmptyTextBlockColor",(e,t)=>{const o=this.getEmptyBlockTextAttributes(e,t);return gg(o)});m(this,"setEmptyTextBlockColor",(e,t,o,r)=>{var s;const i=(s=this.emptyTextBlockAttributes.get(t))!=null?s:{};e6(i,o,r),this.emptyTextBlockAttributes.set(t,i)});this.editor=e,this.colorItem=e.addCustom("text-color-item",()=>new CM(e)),this.colorItem.addListener("onClick",this.handleChangeColor),this.colorItem.addListener("beforePopup",this.handleBeforePopupPalette)}destroy(){this.colorItem.destroy()}getAvailableCommands(e,t,o){if(!ee(e,t))return[];let r;ue(e,t)===0?r=this.getCommandsOnEmptyText(e,t).map(Ar.toTextCommand):r=gz(e,t,o).map(Ar.toTextCommand),this.updateButtonColor();const s={...this.colorItem,blockId:ie(t),blockKind:Io(e,t),blockType:De(t),groupIndex:500,order:350};return r.push(s),r}executeCommand(e,t,o,r,i,s){if(!ee(e,t))return!1;let l=i.value;l===void 0&&(l=!r.value);const a=Ar.fromTextCommandId(r.id);if(a.startsWith("style-")){if(a==="style-font")return this.handleChangeColor(i.type,l),!0;if(ue(e,t)===0)return this.executeCommandOnEmptyText(t,r,{value:l})}return pz(e,t,o,a,{value:l},s)}executeCommandOnEmptyText(e,t,o){let r=this.emptyTextBlockAttributes.get(ie(e));r||(r={},this.emptyTextBlockAttributes.set(ie(e),r));const i=Ar.fromTextCommandId(t.id),s=o.value;return s==null||s===!1?(delete r[i],!0):(r[i]=o.value,!0)}getCommandsOnEmptyText(e,t){const o=mz(e,t);return this.setCommandsStates(o,t)}setCommandsStates(e,t){var i;const o=ie(t),r=(i=this.emptyTextBlockAttributes.get(o))!=null?i:{};return e.map(s=>{const l=r[s.id],a=l?["checked"]:void 0;return s.children&&(s.children=this.setCommandsStates(s.children,t)),{...s,value:l,states:a}})}getEmptyBlockTextAttributes(e,t){var r;const o=me.default((r=this.emptyTextBlockAttributes.get(t))!=null?r:{});if(Array.from(Object.entries(o)).forEach(([i,s])=>{s||delete o[i]}),Object.keys(o).length!==0)return o}static toTextCommand(e){return e.children&&(e.children=e.children.map(Ar.toTextCommand)),{...e,id:`text/${e.id}`}}static fromTextCommandId(e){const t="text/";return g(Cz,e.startsWith(t),`invalid item id: ${e}`),e.substring(t.length)}static fromTextCommand(e){return{...e,id:this.fromTextCommandId(e.id)}}static toTextCommands(e){return e.map(Ar.toTextCommand)}static fromTextCommands(e){return e.map(Ar.fromTextCommand)}}function i8(n){const e=n.getCustom("toolbar-handler");e.disableTextToolbar(),e.hide(),setTimeout(()=>{e.enableTextToolbar()},300)}function Az(n){n.undoManager.canUndo()&&i8(n)}function bz(n){n.undoManager.canRedo()&&i8(n)}const vz={"CtrlOrCmd+Z":Az,"CtrlOrCmd+Shift+Z":bz},yz={commands:{bold:"\u7C97\u4F53",italic:"\u659C\u4F53",underline:"\u4E0B\u5212\u7EBF",strikethrough:"\u5220\u9664\u7EBF",code:"\u884C\u5185\u4EE3\u7801",subscript:"\u4E0B\u6807",superscript:"\u4E0A\u6807",more:"\u66F4\u591A"}},kz={commands:{bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",code:"Inline Code",subscript:"Subscript",superscript:"Superscript",more:"More"}},wz={commands:{bold:"\u592A\u5B57",italic:"\u659C\u4F53",underline:"\u4E0B\u7DDA",strikethrough:"\u53D6\u308A\u6D88\u3057\u7DDA",code:"\u30A4\u30F3\u30E9\u30A4\u30F3\u30B3\u30FC\u30C9",subscript:"\u4E0B\u4ED8\u304D\u6587\u5B57",superscript:"\u4E0A\u4ED8\u304D\u6587\u5B57",more:"\u305D\u306E\u4ED6"}};R.mergeLang({"zh-CN":yz,"en-US":kz,"ja-JP":wz});var s8=(n=>(n.Card="card",n.Preview="preview",n))(s8||{});const Bz=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none">
509
+ `,Ks=S("text-commands");function r8(n){const e={id:"more",name:R.t("commands.more"),icon:iv,childrenType:"menu",childrenPlacement:"bottom-start",manualShowChildren:!0,children:[]},t={"style-bold":[R.t("commands.bold"),Bo("CtrlOrCmd+B"),lz],"style-italic":[R.t("commands.italic"),Bo("CtrlOrCmd+I"),cz],"style-underline":[R.t("commands.underline"),Bo("CtrlOrCmd+U"),az],"style-strikethrough":[R.t("commands.strikethrough"),Bo("CtrlOrCmd+D"),uz],"style-code":[R.t("commands.code"),void 0,dz]},o={"style-super":[R.t("commands.superscript"),void 0,fz],"style-sub":[R.t("commands.subscript"),void 0,hz]};if(rn(n)===0){const l=Object.entries(t).map(([a,[d,h,p]])=>({id:a,name:d,icon:p,desc:h}));return e.children=Object.entries(o).map(([a,[d,h,p]])=>({id:a,name:d,icon:p,desc:h})),l.concat(e)}const r=iz(n);function i([l,[a,d,h]]){const p=r.get(l);return p!==void 0?{id:l,name:a,value:p,states:p===!0?["checked"]:void 0,icon:h,desc:d}:{id:l,name:a,icon:h,desc:d}}const s=Object.entries(t).map(i);return e.children=Object.entries(o).map(i),s.concat(e)}function mz(n,e){const t=ie(e),o=De(e),r=Io(n,e);return r8([]).map(i=>({blockId:t,blockType:o,blockKind:r,...i,groupIndex:500}))}function gz(n,e,t){g(Ks,t.isSimple(),"nor a simple range");const{start:o,end:r}=t;g(Ks,o.isSimple(),"is not a simple block position"),g(Ks,r.isSimple(),"is not a simple block position"),g(Ks,ee(n,e),"invalid block type, not a text kind block");const i=ie(e);g(Ks,o.blockId===i&&r.blockId===i,"invalid range");const s=n.getBlockText(e);let l=[];o.offset===r.offset?o.offset!==0&&(l=zt(s,o.offset-1,1).middle):l=zt(s,o.offset,r.offset-o.offset).middle;const a=De(e),d=Io(n,e);return r8(l).map((h,p)=>({blockId:i,blockType:a,blockKind:d,...h,groupIndex:500,order:p*100}))}function pz(n,e,t,o,r,i){if(!ee(n,e))return!1;if(!o.startsWith("style-"))return Ks.warn(`unknown command: ${o}`),!1;const s=r==null?void 0:r.value,l=typeof s;if(l!=="string"&&l!=="number"&&l!=="boolean"&&l!=="undefined")return Ks.warn(`invalid value type, accept string | number | boolean | undefined, current is ${l}`),!1;const a=sz(n,e,t,o,s);return n.focus(),i.result=a,!0}const Cz=S("text-command-provider");class Ar{constructor(e){m(this,"id","TextCommandProvider");m(this,"emptyTextBlockAttributes",new Map);m(this,"colorItem");m(this,"updateButtonColor",()=>{const e=jg(this.editor,this.getEmptyTextBlockColor);this.colorItem.updateButtonColor(e)});m(this,"handleChangeColor",(e,t)=>{if(e==="color"||e==="backgroundColor")G6(this.editor,e,t,this.setEmptyTextBlockColor);else{const o=["clearAll","clearColor","clearBackground"];Z6(this.editor,o[t],this.setEmptyTextBlockColor)}this.editor.focus()});m(this,"handleBeforePopupPalette",()=>{const e=jg(this.editor,this.getEmptyTextBlockColor);this.colorItem.updatePaletteColor(e)});m(this,"getEmptyTextBlockColor",(e,t)=>{const o=this.getEmptyBlockTextAttributes(e,t);return gg(o)});m(this,"setEmptyTextBlockColor",(e,t,o,r)=>{var s;const i=(s=this.emptyTextBlockAttributes.get(t))!=null?s:{};e6(i,o,r),this.emptyTextBlockAttributes.set(t,i)});this.editor=e,this.colorItem=e.addCustom("text-color-item",()=>new CM(e)),this.colorItem.addListener("onClick",this.handleChangeColor),this.colorItem.addListener("beforePopup",this.handleBeforePopupPalette)}destroy(){this.colorItem.destroy()}getAvailableCommands(e,t,o){if(!ee(e,t))return[];let r;ue(e,t)===0?r=this.getCommandsOnEmptyText(e,t).map(Ar.toTextCommand):r=gz(e,t,o).map(Ar.toTextCommand),this.updateButtonColor();const s={...this.colorItem,blockId:ie(t),blockKind:Io(e,t),blockType:De(t),groupIndex:500,order:350};return r.push(s),r}executeCommand(e,t,o,r,i,s){if(!ee(e,t))return!1;let l=i.value;l===void 0&&(l=!r.value);const a=Ar.fromTextCommandId(r.id);if(a.startsWith("style-")){if(a==="style-font")return this.handleChangeColor(i.type,l),!0;if(ue(e,t)===0)return this.executeCommandOnEmptyText(t,r,{value:l})}return pz(e,t,o,a,{value:l},s)}executeCommandOnEmptyText(e,t,o){let r=this.emptyTextBlockAttributes.get(ie(e));r||(r={},this.emptyTextBlockAttributes.set(ie(e),r));const i=Ar.fromTextCommandId(t.id),s=o.value;return s==null||s===!1?(delete r[i],!0):(r[i]=o.value,!0)}getCommandsOnEmptyText(e,t){const o=mz(e,t);return this.setCommandsStates(o,t)}setCommandsStates(e,t){var i;const o=ie(t),r=(i=this.emptyTextBlockAttributes.get(o))!=null?i:{};return e.map(s=>{const l=r[s.id],a=l?["checked"]:void 0;return s.children&&(s.children=this.setCommandsStates(s.children,t)),{...s,value:l,states:a}})}getEmptyBlockTextAttributes(e,t){var r;const o=me.default((r=this.emptyTextBlockAttributes.get(t))!=null?r:{});if(Array.from(Object.entries(o)).forEach(([i,s])=>{s||delete o[i]}),Object.keys(o).length!==0)return o}static toTextCommand(e){return e.children&&(e.children=e.children.map(Ar.toTextCommand)),{...e,id:`text/${e.id}`}}static fromTextCommandId(e){const t="text/";return g(Cz,e.startsWith(t),`invalid item id: ${e}`),e.substring(t.length)}static fromTextCommand(e){return{...e,id:this.fromTextCommandId(e.id)}}static toTextCommands(e){return e.map(Ar.toTextCommand)}static fromTextCommands(e){return e.map(Ar.fromTextCommand)}}function i8(n){const e=n.getCustom("toolbar-handler");e.disableTextToolbar(),e.hide(),setTimeout(()=>{e.enableTextToolbar()},300)}function Az(n){n.undoManager.canUndo()&&i8(n)}function bz(n){n.undoManager.canRedo()&&i8(n)}const vz={"CtrlOrCmd+Z":Az,"CtrlOrCmd+Shift+Z":bz},yz={commands:{bold:"\u7C97\u4F53",italic:"\u659C\u4F53",underline:"\u4E0B\u5212\u7EBF",strikethrough:"\u5220\u9664\u7EBF",code:"\u884C\u5185\u4EE3\u7801",subscript:"\u4E0B\u6807",superscript:"\u4E0A\u6807",more:"\u66F4\u591A"}},kz={commands:{bold:"Bold",italic:"Italic",underline:"Underline",strikethrough:"Strikethrough",code:"Inline code",subscript:"Subscript",superscript:"Superscript",more:"More"}},wz={commands:{bold:"\u592A\u5B57",italic:"\u659C\u4F53",underline:"\u4E0B\u7DDA",strikethrough:"\u53D6\u308A\u6D88\u3057\u7DDA",code:"\u30A4\u30F3\u30E9\u30A4\u30F3\u30B3\u30FC\u30C9",subscript:"\u4E0B\u4ED8\u304D\u6587\u5B57",superscript:"\u4E0A\u4ED8\u304D\u6587\u5B57",more:"\u305D\u306E\u4ED6"}};R.mergeLang({"zh-CN":yz,"en-US":kz,"ja-JP":wz});var s8=(n=>(n.Card="card",n.Preview="preview",n))(s8||{});const Bz=`<svg xmlns="http://www.w3.org/2000/svg" width="18" height="18" viewBox="0 0 18 18" fill="none">
510
510
  <g clip-path="url(#clip0)">
511
511
  <path d="M6.01 10.4886C5.85 10.4886 5.7 10.4286 5.58 10.3086L3.98 8.71859C3.35 8.07859 3 7.23859 3 6.34859C3 5.45859 3.35 4.60859 3.98 3.97859C5.29 2.66859 7.41 2.66859 8.72 3.97859L10.31 5.56859C10.55 5.80859 10.55 6.18859 10.31 6.42859C10.07 6.66859 9.69 6.66859 9.45 6.42859L7.86 4.83859C7.03 4.00859 5.68 4.00859 4.85 4.83859C4.45 5.23859 4.23 5.77859 4.23 6.34859C4.23 6.91859 4.45 7.44859 4.85 7.85859L6.44 9.44859C6.68 9.68859 6.68 10.0686 6.44 10.3086C6.32 10.4286 6.16 10.4886 6.01 10.4886ZM11.65 14.9986C10.79 14.9986 9.93 14.6686 9.28 14.0186L7.4 12.1386C7.16 11.8986 7.16 11.5186 7.4 11.2786C7.64 11.0386 8.02 11.0386 8.26 11.2786L10.14 13.1586C10.97 13.9886 12.32 13.9886 13.15 13.1586C13.55 12.7586 13.77 12.2186 13.77 11.6486C13.77 11.0786 13.55 10.5486 13.15 10.1386L11.28 8.25859C11.04 8.01859 11.04 7.63859 11.28 7.39859C11.52 7.15859 11.9 7.15859 12.14 7.39859L14.02 9.27859C14.65 9.90859 15 10.7486 15 11.6486C15 12.5386 14.65 13.3886 14.02 14.0186C13.37 14.6686 12.51 14.9986 11.65 14.9986Z" fill="#5587F0"/>
512
512
  <path d="M10.88 10.8604C10.67 11.0704 10.32 11.0704 10.1 10.8604L7.64004 8.40039C7.43004 8.19039 7.43004 7.84039 7.64004 7.62039C7.85004 7.41039 8.20004 7.41039 8.42004 7.62039L10.88 10.0804C11.1 10.3004 11.1 10.6404 10.88 10.8604Z" fill="#5587F0"/>
@@ -595,7 +595,7 @@ width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
595
595
  <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"/>
596
596
  <animateTransform attributeType="xml" attributeName="transform" type="rotate" values="0 12 12.5;360 12 12.5" dur="2s" repeatCount="indefinite" />
597
597
  </g>
598
- </svg>`,N2=S("webpage");class MW{constructor(e,t){m(this,"currentSrc","");m(this,"loading",null);m(this,"handleMaskMouseMove",(e,t)=>{if(!window.isDragging){if(t.target&&t.target instanceof Element){const o=t.target.closest("webpage-mask");o&&(o.style.display="none")}e.domEvents.addEventListener(document,"mousemove",this.handleDocumentMouseMove)}});m(this,"handleDocumentMouseMove",(e,t)=>{if(!t.target||!(t.target instanceof Element))return;const o=this.editor.findBlockById(this.blockData.id);if(o){const r=this.getExistsMask(o);if(r){if(Ke(o,t.target)){r.style.display="none";return}r.style.display=""}}});this.editor=e,this.blockData=t}create(e,t,o,r){const i=t.src,s=w("div",["editor-embed"],null),l=w("iframe",["editor-preview-iframe"],s);this.loading=this.createLoading(s);const a=()=>{g(N2,this.loading,"not created"),this.loading.hide(),this.currentSrc=i};e.domEvents.addEventListener(l,"load",a),l.src=i,this.loading.show(),o.append(s),this.createMask(e,r)}update(e,t,o){if(g(N2,this.loading,"not created"),this.currentSrc===o.src)return;const r=t.querySelector(".editor-preview-iframe");g(N2,r,"no exists iframe"),this.loading.show(),r.src=o.src,this.createMask(e,t)}createLoading(e){const t=w("div",["editor-preview-iframe-loading"],null),o=w("span",[],t);return o.innerHTML=LW,{show(){e.append(t)},hide(){const r=e.querySelector(":scope > .editor-preview-iframe-loading");!r||r.remove()}}}getExistsMask(e){return lt(e).querySelector(".webpage-mask")}createMask(e,t){const o=lt(t);let r=this.getExistsMask(t);if(r){r.style.display="";return}r=w("div",["webpage-mask"],o),e.domEvents.addEventListener(r,"mousemove",this.handleMaskMouseMove)}destroy(){const e=this.editor.findBlockById(this.blockData.id);if(e){const t=this.getExistsMask(e);t&&(this.editor.domEvents.removeEventListener(t,"mousemove",this.handleMaskMouseMove),this.editor.domEvents.removeEventListener(document,"mousemove",this.handleDocumentMouseMove))}}}function q8(n){return n&&Lt(n)&&Un(n)==="webpage"}const RW=1e3,OW=100;class _W{constructor(e){m(this,"currentBlockElement",null);m(this,"resizing",!1);m(this,"handleHoveringBlockChange",(e,t)=>{this.resizing||!this.editor.isWritable()||(t&&q8(t)&&this.disableBlockResize(t),e&&q8(e)&&this.enableBlockResize(e))});m(this,"handleResizing",(e,t)=>{this.resizing=!0;const o=e.getBlock();if(!o)return;const r=Math.max(Math.min(t.height,RW),OW);o.style.height=`${r}px`,W(o,"resizing")});m(this,"handleResized",e=>{this.resizing=!1;const t=e.getBlock();if(!t)return;te(t,"resizing");const o=this.editor.getBlockData(t),r=t.getBoundingClientRect().height;this.editor.updateBlockData(t,{...o,height:r})});this.editor=e,pt.get(e).addListener("change",this.handleHoveringBlockChange)}destroy(){this.currentBlockElement=null,pt.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}disableBlockResize(e){const t=this.editor.findCustom(`${ie(e)}-resizer`);t&&t.disableResize()}enableBlockResize(e){const t=this.editor.addCustom(`${ie(e)}-resizer`,()=>new wu(this.editor,{resize:["bottom"]}));t.enableResize(e),t.removeListener("resizing",this.handleResizing),t.removeListener("resized",this.handleResized),t.addListener("resizing",this.handleResizing),t.addListener("resized",this.handleResized),this.currentBlockElement=e}}const Jne="",FW=S("editor-dialog");function PW(n,e){const t=w("div",["editor-dialog-container"],null),o=w("div",["dialog-header"],t);w("span",["dialog-header-title"],o,e.title);const r=w("span",["close-icon"],o);r.innerHTML=rv,w("div",["dialog-content"],t).appendChild(n);const s=w("div",["dialog-footer"],t);return w("button",["cancel-button"],s,R.t("webpage.dialog.cancelText")),w("button",["submit-button"],s,R.t("webpage.dialog.okText")),t}class NW extends ru{constructor(t,o){super(PW(t,o),o);m(this,"_options");m(this,"getReferenceClientRect",()=>{const t=document.documentElement.clientHeight/2,o=document.documentElement.clientWidth/2,r=this.getCommandBarRoot();g(FW,r,"no command bar root");const{width:i,height:s}=r.getBoundingClientRect();return new DOMRect(Math.max(o-i/2,0),Math.max(t-s/2,0),0,0)});m(this,"handleOk",async()=>{var t,o;try{await((o=(t=this._options).onOk)==null?void 0:o.call(t)),this.destroy()}catch{}});m(this,"handleClose",()=>{var t,o;(o=(t=this._options).onClose)==null||o.call(t),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.handleOk),s==null||s.addEventListener("click",this.handleClose),i==null||i.addEventListener("click",this.handleClose),this._options=o}show(){super.show(document.documentElement,{getReferenceClientRect:this.getReferenceClientRect}),setTimeout(()=>{const t=document.querySelector(`.editor-disable-scroll[data-scroll-id="${this.id}"]`);t&&W(t,"editor-disable-scroll-dark")})}destroy(){const t=this.content.querySelector(".submit-button"),o=this.content.querySelector(".cancel-button"),r=this.content.querySelector(".close-icon");t==null||t.removeEventListener("click",this.handleOk),o==null||o.removeEventListener("click",this.handleClose),r==null||r.removeEventListener("click",this.handleClose),super.destroy()}}const $W=()=>[{name:R.t("webpage.bilibili"),id:"insert-bilibili",icon:OL,group:"thirdParty",subText:pn("insert-bilibili"),value:"bilibili"},{name:R.t("webpage.youku"),id:"insert-youku",icon:_L,group:"thirdParty",subText:pn("insert-youku"),value:"youku"},{name:R.t("webpage.figma"),id:"insert-figma",icon:FL,group:"thirdParty",subText:pn("insert-figma"),value:"figma"},{name:R.t("webpage.modao"),id:"insert-modao",icon:PL,group:"thirdParty",subText:pn("insert-modao"),value:"modao"},{name:R.t("webpage.tencent"),id:"insert-tencent",icon:NL,group:"thirdParty",subText:pn("insert-tencent"),value:"qqVideo"},{id:"insert-webPage",name:R.t("webpage.title"),icon:$L,group:"common",order:1e3,subText:pn("insert-webPage"),value:"url"}];function G8(n){let e=$W();const t=n.getComponentOptions("webpage");return t!=null&&t.getAllowedWebPages&&(e=t.getAllowedWebPages(e)),e}function $2(n){return n==="insert-webPage"}async function HW(n,e){return n.doc.externalDoc.recognizeLink?n.doc.externalDoc.recognizeLink(e):null}function jW(n){return n&&!n.startsWith("http://")&&!n.startsWith("https://")&&!n.startsWith("//")?`${window.location.protocol}//${n}`:n}async function UW(n){if(!n)throw new Error(R.t("webpage.dialog.errorEnterUrl"));const e=n;try{new URL(e)}catch{throw new Error(R.t("webpage.dialog.unsupportedUrl"))}}async function zW(n,e){const t=e.item.id,o=G8(n).find(h=>h.id===t),r=w("div",["webpage-content"],null);if($2(t)){const h=w("div",["help-container"],r),p=w("div",["help-content"],h),A=w("span",["help-icon"],p);A.innerHTML=cv,w("span",[],p,R.t("webpage.dialog.helpContent"))}const{getInputValue:i,setFieldError:s,focus:l,getField:a}=_p(r,{required:!0,label:R.t("webpage.dialog.label"),placeholder:R.t("webpage.dialog.placeholder")}),d=n.getComponentOptions("webpage");if(!$2(t)&&!(d!=null&&d.hideHelpLink)){const h=w("div",["help-link-container"],r),p=w("a",["help-link-content"],h);w("span",[],p,R.t("webpage.dialog.helpLink"));const A=w("span",["help-link-icon"],p);A.innerHTML=uv,p.href=(d==null?void 0:d.helpLink)||"",p.target="_blank"}try{const h=await new Promise((v,B)=>{const D=new NW(r,{id:"webpage",title:R.t("webpage.dialog.title",{name:(o==null?void 0:o.name)||""}),async onOk(){var M;const _=jW(i());try{await UW(_);const H=await HW(n,_);v((H==null?void 0:H.url)||"")}catch(H){if(((M=H==null?void 0:H.responseData)==null?void 0:M.statusCode)===415)if($2(t))v(_);else throw s(R.t("webpage.dialog.unsupportedUrl")),H;else throw s(H.message||""),H}},onClose(){n.focus(),B()}});D.addListener("show",l),D.show(),a().addEventListener("keydown",async _=>{if(!_.isComposing){if(_.key==="Enter"){await D.handleOk(),_.preventDefault();return}_.key==="Escape"&&D.handleClose()}})}),p={id:K(),type:"embed",embedType:"webpage",embedData:{src:h}},A=n.insertBlock(e.containerId,e.blockIndex,p);return n.focus(),A}catch{return null}}function VW(n){const e=n.querySelector(".editor-preview-iframe"),t=e.src;e.src="about:blank";const o=setTimeout(()=>{e.src=t,clearTimeout(o)},300);return!0}function WW(n,e){const t=n.getBlockData(e),{embedData:o}=t,r=o.src;return window.open(r,"_blank"),!0}function qW(n,e){const t=T2(n,e,{presetIds:["add-comment"],extCommands:[{id:"refresh",name:R.t("webpage.command.refresh"),icon:ML},{id:"open-page",name:R.t("webpage.command.openPage"),icon:uv}],handleExecuteCommand:(r,i,s)=>{switch(s.id){case"refresh":return VW(i);case"open-page":return WW(r,i)}return!1}}),o=`${R.t("webpage.abstract")}`;return{...t,abstract:o}}const GW=S("webpage-embed");function ZW(n,e,t,o,r,i){const{embedData:s,id:l}=t,{src:a}=s,d=n.addCustom(`webpage-${l}`,()=>new MW(n,t));g(GW,a,"The src from blockData is invalid "),d.create(n,s,e,i),setTimeout(()=>{n.isBlockWritable(i)&&n.addCustom("webpage-resizer",()=>new _W(n))}),t.height&&(i.style.height=`${t.height}px`)}function QW(n,e,t){const{embedData:o,id:r}=t;return n.getCustom(`webpage-${r}`).update(n,e,o),t.height&&(e.style.height=`${t.height}px`),!0}function YW(n){return{name:"WebPage",insertEmbedCommandItems:G8(n),handleInsertEmptyEmbed:zW}}function JW(n,e,t,o){const i=e.embedData.src;return o==="html"?`<iframe src="${i}" ></iframe>`:o==="markdown"?`[${i}](${i})`:i}const Z8={embedType:"webpage",createEmbedContent:ZW,getBlockProperties:qW,getOptions:YW,handleUpdateBlock:QW,convertTo:JW},KW={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",okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88"},abstract:"\u7F51\u9875",command:{refresh:"\u5237\u65B0\u9875\u9762",openPage:"\u6253\u5F00\u539F\u59CB\u9875\u9762"}}},XW={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",okText:"Ok",cancelText:"Cancel"},abstract:"Webpage",command:{refresh:"Refresh Page",openPage:"Open the original page"}}},eq={webpage:{title:"Web \u30DA\u30FC\u30B8",youku:"Youku \u52D5\u753B",modao:"Modao",tencent:"Tencent \u52D5\u753B",bilibili:"Bilibili",figma:"Figma",dialog:{helpContent:"\u30A2\u30AF\u30BB\u30B9\u5148\u306E\u5236\u9650\u306B\u3088\u308A\u3001\u4E00\u90E8\u306E\u30DA\u30FC\u30B8\u304C\u8868\u793A\u3067\u304D\u306A\u3044\u5834\u5408\u304C\u3042\u308A\u307E\u3059\u3002",helpLink:"URL \u3092\u53D6\u5F97\u3059\u308B\u65B9\u6CD5",label:"URL",placeholder:"\u5165\u529B",title:"{name}\u3092\u633F\u5165",errorEnterUrl:"URL \u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",unsupportedUrl:"\u3053\u306E URL \u306F\u633F\u5165\u3067\u304D\u307E\u305B\u3093",okText:"OK",cancelText:"\u30AD\u30E3\u30F3\u30BB\u30EB"},abstract:"Web \u30DA\u30FC\u30B8",command:{refresh:"\u30DA\u30FC\u30B8\u3092\u518D\u8AAD\u307F\u8FBC\u3080",openPage:"URL\u3092\u958B\u304F"}}};R.mergeLang({"zh-CN":KW,"en-US":XW,"ja-JP":eq});const Kne="";class tq{constructor(){m(this,"isAlreadyInstalled",!1)}stamp(){this.isAlreadyInstalled=!0}isFirstInit(){return this.isAlreadyInstalled===!1}destroy(){}}function nq(n){const e=Object.entries(n);for(let t=0;t<e.length;t++){const[o,r]=e[t];if(o.toLocaleLowerCase()==="content-type")return r}return""}async function oq(n,e,t=!0){try{const o=await n.doc.request(e,{method:"get",responseType:"blob",withCredentials:t}),r=new FileReader,i=new Promise((h,p)=>{r.onload=h,r.onerror=p});r.readAsArrayBuffer(o.data),await i;const s=r.result,l=nq(o.headers).toLocaleLowerCase();let a="";if(l){const h=mm.default[l].extensions;h&&h.length>0&&(a=h[0])}return new File([s],`${Date.now()}.${a}`,{type:l})}catch{return null}}async function H2(n,e){return await oq(n,e)}async function Q8(n,e){const t=await H2(n,e);return t?await t.text():null}const rq=n=>{const e=n.getBoundingClientRect();return e.width<=1&&e.height<=1?(n.style.width="100%",n.style.height="100%",!0):!1},iq=n=>{var i,s;const e=(i=n.getAttribute("width"))!=null?i:"",t=(s=n.getAttribute("height"))!=null?s:"",o=Number.parseInt(e,10),r=Number.parseInt(t,10);return!o||!r||o<=1&&r<=1},sq=n=>n!=null?n[n.textContent===void 0?"text":"textContent"]:"",Y8={"zh-CN":"zh","zh-TW":"zh-tw","js-JP":"zh"},lq="https://embed.diagrams.net/?embed=1",cq="https://www.draw.io/embed.js",aq="https://cdn.jsdelivr.net/npm/pako@2.0.3/dist/pako.es5.js",uq=`
598
+ </svg>`,N2=S("webpage");class MW{constructor(e,t){m(this,"currentSrc","");m(this,"loading",null);m(this,"handleMaskMouseMove",(e,t)=>{if(!window.isDragging){if(t.target&&t.target instanceof Element){const o=t.target.closest("webpage-mask");o&&(o.style.display="none")}e.domEvents.addEventListener(document,"mousemove",this.handleDocumentMouseMove)}});m(this,"handleDocumentMouseMove",(e,t)=>{if(!t.target||!(t.target instanceof Element))return;const o=this.editor.findBlockById(this.blockData.id);if(o){const r=this.getExistsMask(o);if(r){if(Ke(o,t.target)){r.style.display="none";return}r.style.display=""}}});this.editor=e,this.blockData=t}create(e,t,o,r){const i=t.src,s=w("div",["editor-embed"],null),l=w("iframe",["editor-preview-iframe"],s);this.loading=this.createLoading(s);const a=()=>{g(N2,this.loading,"not created"),this.loading.hide(),this.currentSrc=i};e.domEvents.addEventListener(l,"load",a),l.src=i,this.loading.show(),o.append(s),this.createMask(e,r)}update(e,t,o){if(g(N2,this.loading,"not created"),this.currentSrc===o.src)return;const r=t.querySelector(".editor-preview-iframe");g(N2,r,"no exists iframe"),this.loading.show(),r.src=o.src,this.createMask(e,t)}createLoading(e){const t=w("div",["editor-preview-iframe-loading"],null),o=w("span",[],t);return o.innerHTML=LW,{show(){e.append(t)},hide(){const r=e.querySelector(":scope > .editor-preview-iframe-loading");!r||r.remove()}}}getExistsMask(e){return lt(e).querySelector(".webpage-mask")}createMask(e,t){const o=lt(t);let r=this.getExistsMask(t);if(r){r.style.display="";return}r=w("div",["webpage-mask"],o),e.domEvents.addEventListener(r,"mousemove",this.handleMaskMouseMove)}destroy(){const e=this.editor.findBlockById(this.blockData.id);if(e){const t=this.getExistsMask(e);t&&(this.editor.domEvents.removeEventListener(t,"mousemove",this.handleMaskMouseMove),this.editor.domEvents.removeEventListener(document,"mousemove",this.handleDocumentMouseMove))}}}function q8(n){return n&&Lt(n)&&Un(n)==="webpage"}const RW=1e3,OW=100;class _W{constructor(e){m(this,"currentBlockElement",null);m(this,"resizing",!1);m(this,"handleHoveringBlockChange",(e,t)=>{this.resizing||!this.editor.isWritable()||(t&&q8(t)&&this.disableBlockResize(t),e&&q8(e)&&this.enableBlockResize(e))});m(this,"handleResizing",(e,t)=>{this.resizing=!0;const o=e.getBlock();if(!o)return;const r=Math.max(Math.min(t.height,RW),OW);o.style.height=`${r}px`,W(o,"resizing")});m(this,"handleResized",e=>{this.resizing=!1;const t=e.getBlock();if(!t)return;te(t,"resizing");const o=this.editor.getBlockData(t),r=t.getBoundingClientRect().height;this.editor.updateBlockData(t,{...o,height:r})});this.editor=e,pt.get(e).addListener("change",this.handleHoveringBlockChange)}destroy(){this.currentBlockElement=null,pt.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}disableBlockResize(e){const t=this.editor.findCustom(`${ie(e)}-resizer`);t&&t.disableResize()}enableBlockResize(e){const t=this.editor.addCustom(`${ie(e)}-resizer`,()=>new wu(this.editor,{resize:["bottom"]}));t.enableResize(e),t.removeListener("resizing",this.handleResizing),t.removeListener("resized",this.handleResized),t.addListener("resizing",this.handleResizing),t.addListener("resized",this.handleResized),this.currentBlockElement=e}}const Jne="",FW=S("editor-dialog");function PW(n,e){const t=w("div",["editor-dialog-container"],null),o=w("div",["dialog-header"],t);w("span",["dialog-header-title"],o,e.title);const r=w("span",["close-icon"],o);r.innerHTML=rv,w("div",["dialog-content"],t).appendChild(n);const s=w("div",["dialog-footer"],t);return w("button",["cancel-button"],s,R.t("webpage.dialog.cancelText")),w("button",["submit-button"],s,R.t("webpage.dialog.okText")),t}class NW extends ru{constructor(t,o){super(PW(t,o),o);m(this,"_options");m(this,"getReferenceClientRect",()=>{const t=document.documentElement.clientHeight/2,o=document.documentElement.clientWidth/2,r=this.getCommandBarRoot();g(FW,r,"no command bar root");const{width:i,height:s}=r.getBoundingClientRect();return new DOMRect(Math.max(o-i/2,0),Math.max(t-s/2,0),0,0)});m(this,"handleOk",async()=>{var t,o;try{await((o=(t=this._options).onOk)==null?void 0:o.call(t)),this.destroy()}catch{}});m(this,"handleClose",()=>{var t,o;(o=(t=this._options).onClose)==null||o.call(t),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.handleOk),s==null||s.addEventListener("click",this.handleClose),i==null||i.addEventListener("click",this.handleClose),this._options=o}show(){super.show(document.documentElement,{getReferenceClientRect:this.getReferenceClientRect}),setTimeout(()=>{const t=document.querySelector(`.editor-disable-scroll[data-scroll-id="${this.id}"]`);t&&W(t,"editor-disable-scroll-dark")})}destroy(){const t=this.content.querySelector(".submit-button"),o=this.content.querySelector(".cancel-button"),r=this.content.querySelector(".close-icon");t==null||t.removeEventListener("click",this.handleOk),o==null||o.removeEventListener("click",this.handleClose),r==null||r.removeEventListener("click",this.handleClose),super.destroy()}}const $W=()=>[{name:R.t("webpage.bilibili"),id:"insert-bilibili",icon:OL,group:"thirdParty",subText:pn("insert-bilibili"),value:"bilibili"},{name:R.t("webpage.youku"),id:"insert-youku",icon:_L,group:"thirdParty",subText:pn("insert-youku"),value:"youku"},{name:R.t("webpage.figma"),id:"insert-figma",icon:FL,group:"thirdParty",subText:pn("insert-figma"),value:"figma"},{name:R.t("webpage.modao"),id:"insert-modao",icon:PL,group:"thirdParty",subText:pn("insert-modao"),value:"modao"},{name:R.t("webpage.tencent"),id:"insert-tencent",icon:NL,group:"thirdParty",subText:pn("insert-tencent"),value:"qqVideo"},{id:"insert-webPage",name:R.t("webpage.title"),icon:$L,group:"common",order:1e3,subText:pn("insert-webPage"),value:"url"}];function G8(n){let e=$W();const t=n.getComponentOptions("webpage");return t!=null&&t.getAllowedWebPages&&(e=t.getAllowedWebPages(e)),e}function $2(n){return n==="insert-webPage"}async function HW(n,e){return n.doc.externalDoc.recognizeLink?n.doc.externalDoc.recognizeLink(e):null}function jW(n){return n&&!n.startsWith("http://")&&!n.startsWith("https://")&&!n.startsWith("//")?`${window.location.protocol}//${n}`:n}async function UW(n){if(!n)throw new Error(R.t("webpage.dialog.errorEnterUrl"));const e=n;try{new URL(e)}catch{throw new Error(R.t("webpage.dialog.unsupportedUrl"))}}async function zW(n,e){const t=e.item.id,o=G8(n).find(h=>h.id===t),r=w("div",["webpage-content"],null);if($2(t)){const h=w("div",["help-container"],r),p=w("div",["help-content"],h),A=w("span",["help-icon"],p);A.innerHTML=cv,w("span",[],p,R.t("webpage.dialog.helpContent"))}const{getInputValue:i,setFieldError:s,focus:l,getField:a}=_p(r,{required:!0,label:R.t("webpage.dialog.label"),placeholder:R.t("webpage.dialog.placeholder")}),d=n.getComponentOptions("webpage");if(!$2(t)&&!(d!=null&&d.hideHelpLink)){const h=w("div",["help-link-container"],r),p=w("a",["help-link-content"],h);w("span",[],p,R.t("webpage.dialog.helpLink"));const A=w("span",["help-link-icon"],p);A.innerHTML=uv,p.href=(d==null?void 0:d.helpLink)||"",p.target="_blank"}try{const h=await new Promise((v,B)=>{const D=new NW(r,{id:"webpage",title:R.t("webpage.dialog.title",{name:(o==null?void 0:o.name)||""}),async onOk(){var M;const _=jW(i());try{await UW(_);const H=await HW(n,_);v((H==null?void 0:H.url)||"")}catch(H){if(((M=H==null?void 0:H.responseData)==null?void 0:M.statusCode)===415)if($2(t))v(_);else throw s(R.t("webpage.dialog.unsupportedUrl")),H;else throw s(H.message||""),H}},onClose(){n.focus(),B()}});D.addListener("show",l),D.show(),a().addEventListener("keydown",async _=>{if(!_.isComposing){if(_.key==="Enter"){await D.handleOk(),_.preventDefault();return}_.key==="Escape"&&D.handleClose()}})}),p={id:K(),type:"embed",embedType:"webpage",embedData:{src:h}},A=n.insertBlock(e.containerId,e.blockIndex,p);return n.focus(),A}catch{return null}}function VW(n){const e=n.querySelector(".editor-preview-iframe"),t=e.src;e.src="about:blank";const o=setTimeout(()=>{e.src=t,clearTimeout(o)},300);return!0}function WW(n,e){const t=n.getBlockData(e),{embedData:o}=t,r=o.src;return window.open(r,"_blank"),!0}function qW(n,e){const t=T2(n,e,{presetIds:["add-comment"],extCommands:[{id:"refresh",name:R.t("webpage.command.refresh"),icon:ML},{id:"open-page",name:R.t("webpage.command.openPage"),icon:uv}],handleExecuteCommand:(r,i,s)=>{switch(s.id){case"refresh":return VW(i);case"open-page":return WW(r,i)}return!1}}),o=`${R.t("webpage.abstract")}`;return{...t,abstract:o}}const GW=S("webpage-embed");function ZW(n,e,t,o,r,i){const{embedData:s,id:l}=t,{src:a}=s,d=n.addCustom(`webpage-${l}`,()=>new MW(n,t));g(GW,a,"The src from blockData is invalid "),d.create(n,s,e,i),setTimeout(()=>{n.isBlockWritable(i)&&n.addCustom("webpage-resizer",()=>new _W(n))}),t.height&&(i.style.height=`${t.height}px`)}function QW(n,e,t){const{embedData:o,id:r}=t;return n.getCustom(`webpage-${r}`).update(n,e,o),t.height&&(e.style.height=`${t.height}px`),!0}function YW(n){return{name:"WebPage",insertEmbedCommandItems:G8(n),handleInsertEmptyEmbed:zW}}function JW(n,e,t,o){const i=e.embedData.src;return o==="html"?`<iframe src="${i}" ></iframe>`:o==="markdown"?`[${i}](${i})`:i}const Z8={embedType:"webpage",createEmbedContent:ZW,getBlockProperties:qW,getOptions:YW,handleUpdateBlock:QW,convertTo:JW},KW={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",okText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88"},abstract:"\u7F51\u9875",command:{refresh:"\u5237\u65B0\u9875\u9762",openPage:"\u6253\u5F00\u539F\u59CB\u9875\u9762"}}},XW={webpage:{title:"Webpage",youku:"Youku",modao:"Modao",tencent:"Tencent Video",bilibili:"Bilibili",figma:"Figma",dialog:{helpContent:"Due to landing page limitations, some pages may not be properly displayed during preview.",helpLink:"How to get the URL link",label:"Website address",placeholder:"Please enter",title:"Insert {name}",errorEnterUrl:"Please enter website address",unsupportedUrl:"Unsupported URL",okText:"Confirm",cancelText:"Cancel"},abstract:"Webpage",command:{refresh:"Refresh page",openPage:"Open the original page"}}},eq={webpage:{title:"Web \u30DA\u30FC\u30B8",youku:"Youku \u52D5\u753B",modao:"Modao",tencent:"Tencent \u52D5\u753B",bilibili:"Bilibili",figma:"Figma",dialog:{helpContent:"\u30A2\u30AF\u30BB\u30B9\u5148\u306E\u5236\u9650\u306B\u3088\u308A\u3001\u4E00\u90E8\u306E\u30DA\u30FC\u30B8\u304C\u8868\u793A\u3067\u304D\u306A\u3044\u5834\u5408\u304C\u3042\u308A\u307E\u3059\u3002",helpLink:"URL \u3092\u53D6\u5F97\u3059\u308B\u65B9\u6CD5",label:"URL",placeholder:"\u5165\u529B",title:"{name}\u3092\u633F\u5165",errorEnterUrl:"URL \u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",unsupportedUrl:"\u3053\u306E URL \u306F\u633F\u5165\u3067\u304D\u307E\u305B\u3093",okText:"OK",cancelText:"\u30AD\u30E3\u30F3\u30BB\u30EB"},abstract:"Web \u30DA\u30FC\u30B8",command:{refresh:"\u30DA\u30FC\u30B8\u3092\u518D\u8AAD\u307F\u8FBC\u3080",openPage:"URL\u3092\u958B\u304F"}}};R.mergeLang({"zh-CN":KW,"en-US":XW,"ja-JP":eq});const Kne="";class tq{constructor(){m(this,"isAlreadyInstalled",!1)}stamp(){this.isAlreadyInstalled=!0}isFirstInit(){return this.isAlreadyInstalled===!1}destroy(){}}function nq(n){const e=Object.entries(n);for(let t=0;t<e.length;t++){const[o,r]=e[t];if(o.toLocaleLowerCase()==="content-type")return r}return""}async function oq(n,e,t=!0){try{const o=await n.doc.request(e,{method:"get",responseType:"blob",withCredentials:t}),r=new FileReader,i=new Promise((h,p)=>{r.onload=h,r.onerror=p});r.readAsArrayBuffer(o.data),await i;const s=r.result,l=nq(o.headers).toLocaleLowerCase();let a="";if(l){const h=mm.default[l].extensions;h&&h.length>0&&(a=h[0])}return new File([s],`${Date.now()}.${a}`,{type:l})}catch{return null}}async function H2(n,e){return await oq(n,e)}async function Q8(n,e){const t=await H2(n,e);return t?await t.text():null}const rq=n=>{const e=n.getBoundingClientRect();return e.width<=1&&e.height<=1?(n.style.width="100%",n.style.height="100%",!0):!1},iq=n=>{var i,s;const e=(i=n.getAttribute("width"))!=null?i:"",t=(s=n.getAttribute("height"))!=null?s:"",o=Number.parseInt(e,10),r=Number.parseInt(t,10);return!o||!r||o<=1&&r<=1},sq=n=>n!=null?n[n.textContent===void 0?"text":"textContent"]:"",Y8={"zh-CN":"zh","zh-TW":"zh-tw","js-JP":"zh"},lq="https://embed.diagrams.net/?embed=1",cq="https://www.draw.io/embed.js",aq="https://cdn.jsdelivr.net/npm/pako@2.0.3/dist/pako.es5.js",uq=`
599
599
  <mxStylesheet>
600
600
  <add as="defaultVertex">
601
601
  <add as="shape" value="label"/>
@@ -705,7 +705,7 @@ width="24" height="24" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
705
705
  <add as="fillColor" value="#ffffff"/>
706
706
  </add>
707
707
  </mxStylesheet>
708
- `,J8=0,dq=30*1e3,K8="editor-empty-drawio",X8="show-full-screen-iframe",Ft=S("embed-block-drawio");function Mc(n){return n.options.componentsOptions.drawIO||{}}function hq(n){const t=Mc(n).lang||"zh-CN";return Y8[t]||Y8["zh-CN"]}function fq(n){var r;const t=((r=(Mc(n)||{}).cdn)==null?void 0:r.drawioIframe)||lq,o=hq(n);return Tm(t,{spin:1,proto:"json",configure:1,lang:o})}function mq(n){const e=()=>{g(Ft,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*J8}`),n.setAttribute("height",`${r-2*J8}`)},t=()=>{window.removeEventListener("resize",e)};return e(),window.addEventListener("resize",e),{disconnect:t}}async function gq(n){const t=(Mc(n)||{}).callbacks||{},{onCreateDrawIoFrame:o,onCloseDrawIoFrame:r}=t;let i=null,s;if(o)i=await o(n),g(Ft,i,"iframe create failed"),s=()=>{g(Ft,i,"iframe does not exist"),g(Ft,r,"missing parameters: onCloseDrawIoFrame"),r(n,i)};else{const l=w("div",["editor-drawio-iframe-container","loading"],document.body);l.setAttribute("data-placeholder",R.t("drawio.loading")),i=w("iframe",["drawio-iframe-element"],l),i.setAttribute("frameborder","0"),W(l,X8);const{disconnect:a}=mq(i);s=()=>{g(Ft,i,"iframe does not exist"),a(),document.body.removeChild(l),te(l,X8)}}return{drawioIframe:i,exit:s}}async function pq(n,e,t,o){var r,i;try{o&&Ft.debug("auto saving drawio data");const s=new Blob([t]),l=new File([s],"drawio.svg",{type:"image/svg+xml"});try{const a=n.findBlockById(ie(e));if(a){const d=await n.doc.uploadResource(l),{resourceId:h}=d,A=n.getBlockData(a).embedData,v={src:h,height:A==null?void 0:A.height};n.updateEmbedData(a,v)}else Ft.error("block has been deleted")}catch(a){const d=`failed to upload drawio data: ${a.message}`;Ft.error(d)}}catch(s){const l=`failed to save drawio data: ${s.message}`,a=Mc(n);if((r=a.callbacks)!=null&&r.onError){const d=new Error(l);d.code="SaveDrawIo",(i=a.callbacks)==null||i.onError(n,d)}}}function Cq(n,e,t,o,r,i,s){const l=()=>{window.removeEventListener("message",a),i()},a=async d=>{var h,p;if(g(Ft,o.contentWindow,"iframe.contentWindow does not exist"),d.data.length>0){const A=JSON.parse(d.data),v=t.xmlSvg||t.xml,B=document.querySelectorAll(".editor-drawio-iframe-container");switch(A.event){case"configure":o.contentWindow.postMessage(JSON.stringify({action:"configure",config:{defaultFonts:["Humor Sans","Helvetica","Times New Roman"]}}),"*");break;case"init":v!=null&&o.contentWindow.postMessage(JSON.stringify({action:"load",saveAndExit:1,noSaveBtn:1,noExitBtn:0,xml:v}),"*"),r(),B.forEach(I=>{te(I,"loading")});break;case"export":const D=zd(A.data.substring(A.data.indexOf(",")+1));pq(n,e,D,!!((h=A.message)!=null&&h.autoSave)),(p=A.message)!=null&&p.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",a)}async function ek(n,e,t,o){if(o)return;o=!0;const r=Mc(n)||{},{callbacks:i}=r;let s;i&&(i==null?void 0:i.onBeginInitDrawIo)&&i.onBeginInitDrawIo(n,e);const{drawioIframe:l,exit:a}=await gq(n);if(K0(n,e),t.src){const A=await Q8(n,n.doc.buildResourceUrl(t.src));A&&(t.xmlSvg=A)}Cq(n,e,t,l,()=>{s=setInterval(()=>{!l||!l.contentWindow||l.contentWindow.postMessage(JSON.stringify({action:"export",format:"xmlsvg",spin:"Saving graph",autoSave:!0}),"*")},dq)},()=>{a(),s&&clearInterval(s);const A=n.findBlockById(ie(e));A&&X0(n,A)});const p=fq(n);l.setAttribute("src",p)}async function Aq(n){var r,i;const e=Mc(n),t=((r=e.cdn)==null?void 0:r.drawio)||cq,o=((i=e.cdn)==null?void 0:i.pako)||aq;await vs(o,"editor-pako"),await vs(t,"editor-drawio"),await new Promise(s=>{setTimeout(s,100)})}function tk(n){te(n,K8)}function j2(n){n.setAttribute("data-empty-drawio-content",R.t("drawio.empty")),W(n,K8)}function U2(n,e){if(g(Ft,e,"Required data is missing in setGraph"),"src"in e){n.setAttribute("data-src",e.src);return}if("xmlSvg"in e){n.setAttribute("data-xmlsvg",e.xmlSvg);return}if("graph"in e){const{xml:t,graph:o}=e;n.graph=o,n.setAttribute("data-mxfile",t)}}function bq(n,e,t){g(Ft,n,"params error: src"),g(Ft,t,"params error: editor");const o=e,r=t.doc.buildResourceUrl(n),i=document.createElement("img");o.innerHTML="",o.appendChild(i),i.src=r,i.draggable=!1,U2(o,{src:n}),i.onload=()=>{rq(i)?j2(e):(i.style.width="100%",i.style.height="100%",tk(e))}}function vq(n,e,t){g(Ft,t,"parameter missing"),Aq(t).then(()=>{const{mxUtils:o,mxGraph:r,mxCodec:i}=window;g(Ft,o,"External resource loading exception: mxUtils"),g(Ft,r,"External resource loading exception: MxGraph"),g(Ft,i,"External resource loading exception: MxCodec");const s=o.parseXml(n);e.innerHTML="";const l=s.documentElement;g(Ft,l,"Resource parsing exception"),g(Ft,l.nodeName==="mxfile","Resource parsing exception");const a=l.getElementsByTagName("diagram");g(Ft,a.length>0,"Resource parsing exception");let d;const h=a[0];if(h.text||h.textContent){const D=sq(h),I=atob(D),_=window.pako;g(Ft,_,"External resource loading exception: pako");const M=_.inflateRaw(Uint8Array.from(I,z=>z.charCodeAt(0)),{to:"string"}),H=decodeURIComponent(M);d=o.parseXml(H)}else{const D=new XMLSerializer().serializeToString(h.firstChild);d=o.parseXml(D)}const p=new r(e);p.resetViewOnRootChange=!1,p.foldingEnabled=!1,p.setTooltips(!1),p.setEnabled(!1),p.setHtmlLabels(!0);const A=o.parseXml(uq);new i(A).decode(A.documentElement,p.getStylesheet());const B=new i(d);B.decode(B.document.documentElement,p.getModel()),p.maxFitScale=1,p.fit(),p.center(!0,!1),U2(e,{graph:p,xml:n})})}function yq(n,e){e.innerHTML=n,U2(e,{xmlSvg:n});const t=e.querySelectorAll("svg");for(let o=0;o<t.length;o++){const r=t[o];if(!iq(r))return}j2(e)}function kq(n,e){return{...T2(n,e,{handleExecuteCommand:(o,r,i)=>{if(i.id==="edit"){const s=o.getBlockData(r).embedData;return ek(o,r,s,!1),!0}return!1}}),abstract:R.t("drawio.abstract")}}const wq={"en-US":{drawio:{title:"UML",empty:"Empty Graph",loading:"Loading diagram editor...",abstract:"UML"}},"zh-CN":{drawio:{title:"\u6D41\u7A0B\u56FE/UML",empty:"\u7A7A\u56FE\u8868",loading:"\u52A0\u8F7D\u4E2D",abstract:"\u6D41\u7A0B\u56FE/UML"}},"ja-JP":{drawio:{title:"\u30D5\u30ED\u30FC\u30C1\u30E3\u30FC\u30C8/UML",empty:"\u30B0\u30E9\u30D5\u30C7\u30FC\u30BF\u306A\u3057",loading:"\u8AAD\u8FBC\u4E2D",abstract:"\u30D5\u30ED\u30FC\u30C1\u30E3\u30FC\u30C8/UML"}}};R.mergeLang(wq);const Nu=S("embed-block-drawio"),Bq=!1;function nk(n,e,t,o){g(Nu,t,`parameter missing: ${t}`),g(Nu,n,`parameter missing: ${n}`),ek(n,e,o,Bq)}function Eq(n,e,t){tk(e);const o=t;o.src?bq(o.src,e,n):o.xml?vq(o.xml,e,n):o.xmlSvg?yq(o.xmlSvg,e):j2(e)}function xq(n,e,t,o={isInit:!1}){const{isInit:r}=o,s=w("div",["editor-drawio-content","editor-embed"],null),l=Re(e);l.appendChild(s),Eq(n,s,t),g(Nu,e,"embedContainer parentElement node does not exist"),r&&!n.readonly&&n.domEvents.addEventListener(l,"dblclick",()=>{const a=n.getBlockData(e);nk(n,e,s,a.embedData)}),t.height&&(s.style.height=`${t.height-20}px`)}function Iq(n,e,t,o,r,i){const s=t.embedData,l=n.addCustom(`drawio-${t.id}`,()=>new tq),a=l.isFirstInit();a?Nu.log("create new embed block"):Nu.log("update exists embed block"),l.stamp(),xq(n,i,s,{isInit:a}),s.height&&(e.style.height=`${s.height}px`),Fu.register(n,i)}function Tq(){return{name:"UML",insertEmbedCommandItems:[{id:"insert-drawio",name:R.t("drawio.title"),icon:UL,group:"common",order:600,subText:pn("insert-drawio")}],handleInsertEmptyEmbed:async(n,e)=>{const t={src:"",xml:"",xmlSvg:""},o=n.insertEmbed(e.containerId,e.blockIndex,"drawio",t);return setTimeout(()=>{const i=Re(o).querySelector(":scope > .editor-drawio-content"),s=n.getBlockData(o);nk(n,o,i,s.embedData)},100),o}}}function Dq(n,e,t,o){const{embedData:r}=e,i=r;return o==="html"?i.src?`<img src="${n.doc.buildResourceUrl(i.src,{withToken:!0})}" />`:i.xmlSvg?i.xmlSvg:"<p>[drawio]</p>":o==="markdown"?i.src?`![drawio](${n.doc.buildResourceUrl(i.src,{withToken:!0})})`:i.xmlSvg?i.xmlSvg:"[drawio]":i.src?`[drawio](${n.doc.buildResourceUrl(i.src,{withToken:!0})})`:"[drawio]"}const z2={embedType:"drawio",getOptions:Tq,createEmbedContent:Iq,getBlockProperties:kq,convertTo:Dq},noe="",ooe="",Sq=500,Lq=300,V2=S("code-editor");function Mq(n){const e=n.closest(".embed-code-editor-container");return g(V2,e,"code-editor-container non-existent"),e}function Rq(n,e,t){const o=n.target;g(V2,o,"Parameter error: textarea must be an element");const r=o.value;Mq(o).remove(),te(e,"editing"),t(r),Re(e).style.removeProperty("margin-top")}function Oq(n,e){g(V2,n,"Parameter Error: handleCodeUpdate[event]");const t=n.target.value;e(t)}const _q=Ht.default(Oq,Sq);function Fq(n,e,t,o,r){n.domEvents.addEventListener(e,"blur",(i,s)=>{Rq(s,t,r)}),n.domEvents.addEventListener(e,"keyup",(i,s)=>{const l=s.target;s.key==="Escape"&&l.blur()}),n.domEvents.addEventListener(e,"input",(i,s)=>{_q(s,o)})}function Pq(n,e,t){const{height:o,codeValue:r,onChange:i,onEnd:s}=t,l=o||Lq,a=Re(e),d=lt(e),h=w("div",["embed-code-editor-container"],d),p=w("textarea",["embed-code-editor-textarea"],h);p.value=r||"",p.setAttribute("spellcheck","false"),h.style.height=`${l}px`,Fq(n,p,e,i,s),a.style.marginTop=`${l}px`,W(e,"editing"),window.requestAnimationFrame(()=>{p.setSelectionRange(0,0),p.focus(),p.scrollTop=0})}var W2={exports:{}};/**
708
+ `,J8=0,dq=30*1e3,K8="editor-empty-drawio",X8="show-full-screen-iframe",Ft=S("embed-block-drawio");function Mc(n){return n.options.componentsOptions.drawIO||{}}function hq(n){const t=Mc(n).lang||"zh-CN";return Y8[t]||Y8["zh-CN"]}function fq(n){var r;const t=((r=(Mc(n)||{}).cdn)==null?void 0:r.drawioIframe)||lq,o=hq(n);return Tm(t,{spin:1,proto:"json",configure:1,lang:o})}function mq(n){const e=()=>{g(Ft,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*J8}`),n.setAttribute("height",`${r-2*J8}`)},t=()=>{window.removeEventListener("resize",e)};return e(),window.addEventListener("resize",e),{disconnect:t}}async function gq(n){const t=(Mc(n)||{}).callbacks||{},{onCreateDrawIoFrame:o,onCloseDrawIoFrame:r}=t;let i=null,s;if(o)i=await o(n),g(Ft,i,"iframe create failed"),s=()=>{g(Ft,i,"iframe does not exist"),g(Ft,r,"missing parameters: onCloseDrawIoFrame"),r(n,i)};else{const l=w("div",["editor-drawio-iframe-container","loading"],document.body);l.setAttribute("data-placeholder",R.t("drawio.loading")),i=w("iframe",["drawio-iframe-element"],l),i.setAttribute("frameborder","0"),W(l,X8);const{disconnect:a}=mq(i);s=()=>{g(Ft,i,"iframe does not exist"),a(),document.body.removeChild(l),te(l,X8)}}return{drawioIframe:i,exit:s}}async function pq(n,e,t,o){var r,i;try{o&&Ft.debug("auto saving drawio data");const s=new Blob([t]),l=new File([s],"drawio.svg",{type:"image/svg+xml"});try{const a=n.findBlockById(ie(e));if(a){const d=await n.doc.uploadResource(l),{resourceId:h}=d,A=n.getBlockData(a).embedData,v={src:h,height:A==null?void 0:A.height};n.updateEmbedData(a,v)}else Ft.error("block has been deleted")}catch(a){const d=`failed to upload drawio data: ${a.message}`;Ft.error(d)}}catch(s){const l=`failed to save drawio data: ${s.message}`,a=Mc(n);if((r=a.callbacks)!=null&&r.onError){const d=new Error(l);d.code="SaveDrawIo",(i=a.callbacks)==null||i.onError(n,d)}}}function Cq(n,e,t,o,r,i,s){const l=()=>{window.removeEventListener("message",a),i()},a=async d=>{var h,p;if(g(Ft,o.contentWindow,"iframe.contentWindow does not exist"),d.data.length>0){const A=JSON.parse(d.data),v=t.xmlSvg||t.xml,B=document.querySelectorAll(".editor-drawio-iframe-container");switch(A.event){case"configure":o.contentWindow.postMessage(JSON.stringify({action:"configure",config:{defaultFonts:["Humor Sans","Helvetica","Times New Roman"]}}),"*");break;case"init":v!=null&&o.contentWindow.postMessage(JSON.stringify({action:"load",saveAndExit:1,noSaveBtn:1,noExitBtn:0,xml:v}),"*"),r(),B.forEach(I=>{te(I,"loading")});break;case"export":const D=zd(A.data.substring(A.data.indexOf(",")+1));pq(n,e,D,!!((h=A.message)!=null&&h.autoSave)),(p=A.message)!=null&&p.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",a)}async function ek(n,e,t,o){if(o)return;o=!0;const r=Mc(n)||{},{callbacks:i}=r;let s;i&&(i==null?void 0:i.onBeginInitDrawIo)&&i.onBeginInitDrawIo(n,e);const{drawioIframe:l,exit:a}=await gq(n);if(K0(n,e),t.src){const A=await Q8(n,n.doc.buildResourceUrl(t.src));A&&(t.xmlSvg=A)}Cq(n,e,t,l,()=>{s=setInterval(()=>{!l||!l.contentWindow||l.contentWindow.postMessage(JSON.stringify({action:"export",format:"xmlsvg",spin:"Saving graph",autoSave:!0}),"*")},dq)},()=>{a(),s&&clearInterval(s);const A=n.findBlockById(ie(e));A&&X0(n,A)});const p=fq(n);l.setAttribute("src",p)}async function Aq(n){var r,i;const e=Mc(n),t=((r=e.cdn)==null?void 0:r.drawio)||cq,o=((i=e.cdn)==null?void 0:i.pako)||aq;await vs(o,"editor-pako"),await vs(t,"editor-drawio"),await new Promise(s=>{setTimeout(s,100)})}function tk(n){te(n,K8)}function j2(n){n.setAttribute("data-empty-drawio-content",R.t("drawio.empty")),W(n,K8)}function U2(n,e){if(g(Ft,e,"Required data is missing in setGraph"),"src"in e){n.setAttribute("data-src",e.src);return}if("xmlSvg"in e){n.setAttribute("data-xmlsvg",e.xmlSvg);return}if("graph"in e){const{xml:t,graph:o}=e;n.graph=o,n.setAttribute("data-mxfile",t)}}function bq(n,e,t){g(Ft,n,"params error: src"),g(Ft,t,"params error: editor");const o=e,r=t.doc.buildResourceUrl(n),i=document.createElement("img");o.innerHTML="",o.appendChild(i),i.src=r,i.draggable=!1,U2(o,{src:n}),i.onload=()=>{rq(i)?j2(e):(i.style.width="100%",i.style.height="100%",tk(e))}}function vq(n,e,t){g(Ft,t,"parameter missing"),Aq(t).then(()=>{const{mxUtils:o,mxGraph:r,mxCodec:i}=window;g(Ft,o,"External resource loading exception: mxUtils"),g(Ft,r,"External resource loading exception: MxGraph"),g(Ft,i,"External resource loading exception: MxCodec");const s=o.parseXml(n);e.innerHTML="";const l=s.documentElement;g(Ft,l,"Resource parsing exception"),g(Ft,l.nodeName==="mxfile","Resource parsing exception");const a=l.getElementsByTagName("diagram");g(Ft,a.length>0,"Resource parsing exception");let d;const h=a[0];if(h.text||h.textContent){const D=sq(h),I=atob(D),_=window.pako;g(Ft,_,"External resource loading exception: pako");const M=_.inflateRaw(Uint8Array.from(I,z=>z.charCodeAt(0)),{to:"string"}),H=decodeURIComponent(M);d=o.parseXml(H)}else{const D=new XMLSerializer().serializeToString(h.firstChild);d=o.parseXml(D)}const p=new r(e);p.resetViewOnRootChange=!1,p.foldingEnabled=!1,p.setTooltips(!1),p.setEnabled(!1),p.setHtmlLabels(!0);const A=o.parseXml(uq);new i(A).decode(A.documentElement,p.getStylesheet());const B=new i(d);B.decode(B.document.documentElement,p.getModel()),p.maxFitScale=1,p.fit(),p.center(!0,!1),U2(e,{graph:p,xml:n})})}function yq(n,e){e.innerHTML=n,U2(e,{xmlSvg:n});const t=e.querySelectorAll("svg");for(let o=0;o<t.length;o++){const r=t[o];if(!iq(r))return}j2(e)}function kq(n,e){return{...T2(n,e,{handleExecuteCommand:(o,r,i)=>{if(i.id==="edit"){const s=o.getBlockData(r).embedData;return ek(o,r,s,!1),!0}return!1}}),abstract:R.t("drawio.abstract")}}const wq={"en-US":{drawio:{title:"Flowchart/UML",empty:"Empty graph",loading:"Loading",abstract:"Flowchart/UML"}},"zh-CN":{drawio:{title:"\u6D41\u7A0B\u56FE/UML",empty:"\u7A7A\u56FE\u8868",loading:"\u52A0\u8F7D\u4E2D",abstract:"\u6D41\u7A0B\u56FE/UML"}},"ja-JP":{drawio:{title:"\u30D5\u30ED\u30FC\u30C1\u30E3\u30FC\u30C8/UML",empty:"\u30B0\u30E9\u30D5\u30C7\u30FC\u30BF\u306A\u3057",loading:"\u8AAD\u8FBC\u4E2D",abstract:"\u30D5\u30ED\u30FC\u30C1\u30E3\u30FC\u30C8/UML"}}};R.mergeLang(wq);const Nu=S("embed-block-drawio"),Bq=!1;function nk(n,e,t,o){g(Nu,t,`parameter missing: ${t}`),g(Nu,n,`parameter missing: ${n}`),ek(n,e,o,Bq)}function Eq(n,e,t){tk(e);const o=t;o.src?bq(o.src,e,n):o.xml?vq(o.xml,e,n):o.xmlSvg?yq(o.xmlSvg,e):j2(e)}function xq(n,e,t,o={isInit:!1}){const{isInit:r}=o,s=w("div",["editor-drawio-content","editor-embed"],null),l=Re(e);l.appendChild(s),Eq(n,s,t),g(Nu,e,"embedContainer parentElement node does not exist"),r&&!n.readonly&&n.domEvents.addEventListener(l,"dblclick",()=>{const a=n.getBlockData(e);nk(n,e,s,a.embedData)}),t.height&&(s.style.height=`${t.height-20}px`)}function Iq(n,e,t,o,r,i){const s=t.embedData,l=n.addCustom(`drawio-${t.id}`,()=>new tq),a=l.isFirstInit();a?Nu.log("create new embed block"):Nu.log("update exists embed block"),l.stamp(),xq(n,i,s,{isInit:a}),s.height&&(e.style.height=`${s.height}px`),Fu.register(n,i)}function Tq(){return{name:"UML",insertEmbedCommandItems:[{id:"insert-drawio",name:R.t("drawio.title"),icon:UL,group:"common",order:600,subText:pn("insert-drawio")}],handleInsertEmptyEmbed:async(n,e)=>{const t={src:"",xml:"",xmlSvg:""},o=n.insertEmbed(e.containerId,e.blockIndex,"drawio",t);return setTimeout(()=>{const i=Re(o).querySelector(":scope > .editor-drawio-content"),s=n.getBlockData(o);nk(n,o,i,s.embedData)},100),o}}}function Dq(n,e,t,o){const{embedData:r}=e,i=r;return o==="html"?i.src?`<img src="${n.doc.buildResourceUrl(i.src,{withToken:!0})}" />`:i.xmlSvg?i.xmlSvg:"<p>[drawio]</p>":o==="markdown"?i.src?`![drawio](${n.doc.buildResourceUrl(i.src,{withToken:!0})})`:i.xmlSvg?i.xmlSvg:"[drawio]":i.src?`[drawio](${n.doc.buildResourceUrl(i.src,{withToken:!0})})`:"[drawio]"}const z2={embedType:"drawio",getOptions:Tq,createEmbedContent:Iq,getBlockProperties:kq,convertTo:Dq},noe="",ooe="",Sq=500,Lq=300,V2=S("code-editor");function Mq(n){const e=n.closest(".embed-code-editor-container");return g(V2,e,"code-editor-container non-existent"),e}function Rq(n,e,t){const o=n.target;g(V2,o,"Parameter error: textarea must be an element");const r=o.value;Mq(o).remove(),te(e,"editing"),t(r),Re(e).style.removeProperty("margin-top")}function Oq(n,e){g(V2,n,"Parameter Error: handleCodeUpdate[event]");const t=n.target.value;e(t)}const _q=Ht.default(Oq,Sq);function Fq(n,e,t,o,r){n.domEvents.addEventListener(e,"blur",(i,s)=>{Rq(s,t,r)}),n.domEvents.addEventListener(e,"keyup",(i,s)=>{const l=s.target;s.key==="Escape"&&l.blur()}),n.domEvents.addEventListener(e,"input",(i,s)=>{_q(s,o)})}function Pq(n,e,t){const{height:o,codeValue:r,onChange:i,onEnd:s}=t,l=o||Lq,a=Re(e),d=lt(e),h=w("div",["embed-code-editor-container"],d),p=w("textarea",["embed-code-editor-textarea"],h);p.value=r||"",p.setAttribute("spellcheck","false"),h.style.height=`${l}px`,Fq(n,p,e,i,s),a.style.marginTop=`${l}px`,W(e,"editing"),window.requestAnimationFrame(()=>{p.setSelectionRange(0,0),p.focus(),p.scrollTop=0})}var W2={exports:{}};/**
709
709
  * @license
710
710
  * Lodash <https://lodash.com/>
711
711
  * Copyright OpenJS Foundation and other contributors <https://openjsf.org/>
@@ -737,4 +737,4 @@ ${i.mermaidText}
737
737
  ${i.flowchartText}
738
738
  \`\`\`\`\`\``}return"[flowchart]"}const lk={embedType:"flowchart",convertFrom:lG,handleUpdateBlock:sG,createEmbedContent:iG,getBlockProperties:cG,convertTo:aG},uG=S("plantuml-helper");function ck(n,e){var l;let o=((l=(n.getComponentOptions("plantuml")||{}).cdn)==null?void 0:l.plantuml)||zq;o.endsWith("/")||(o+="/");const r=GB.default.encode(e);g(uG,r,r),o+=r;const s=new URLSearchParams(document.location.search).get("doc");return Tm(o,{id:`${s}-${K()}`})}async function dG(n,e){try{const t=await H2(n,e);return(await n.doc.uploadResource(t)).resourceId}catch{return Promise.resolve(e)}}class _c extends q2{constructor(e){super(e,"plantuml","plantumlText")}static get(e,t){return e.addCustom(`plantuml-${t.id}`,()=>new _c(e))}code2ObjectUrl(e){return Promise.resolve(ck(this.editor,e))}code2ResourceId(e){const t=ck(this.editor,e);return dG(this.editor,t)}destroy(){}}function hG(n,e,t){_c.get(n,t).createEmbedContent(e,t)}function fG(n,e,t){const o=_c.get(n,t),r=Re(e);return o.updateEmbedContent(r,t),!0}function mG(n,e,t){const{data:o}=t,r=n.getBlockString(e).trim();if(!o||o.embedType!=="plantuml"||r!=="```plantuml"||!ee(n,e))return null;const i={src:"",plantumlText:""};return{blockData:{id:K(),type:"embed",embedType:"plantuml",embedData:i},onConverted:(a,d)=>{_c.get(a,a.getBlockData(d)).editGraph(Re(d))}}}function gG(n,e){return _c.get(n,n.getBlockData(e)).getBlockProperties(e)}function pG(n,e,t,o){const{embedData:r}=e,i=r;if(o==="html")return i.src?`<img src="${n.doc.buildResourceUrl(i.src,{withToken:!0})}" />`:i.flowchartText?`<div>${i.flowchartText}</div>`:"<p>[plantuml]</p>";if(o==="markdown"){if(i.src)return`![plantuml](${n.doc.buildResourceUrl(i.src,{withToken:!0})})`;if(i.flowchartText)return`\`\`\`plantuml\`\`\`
739
739
  ${i.flowchartText}
740
- \`\`\`\`\`\``}return"[plantuml]"}const ak={embedType:"plantuml",convertFrom:mG,handleUpdateBlock:fG,createEmbedContent:hG,getBlockProperties:gG,convertTo:pG},roe="",CG="hr",AG={dividingLine:{type:"\u5206\u5272\u7EBF",abstract:"\u5206\u5272\u7EBF"}},bG={dividingLine:{type:"Separation line",abstract:"Line"}},vG={dividingLine:{type:"\u533A\u5207\u308A\u7DDA",abstract:"\u533A\u5207\u308A\u7DDA"}};R.mergeLang({"zh-CN":AG,"en-US":bG,"ja-JP":vG});function yG(n,e){const t=w("div",["editor-embed-container"],e);w("hr",["editor-embed-hr"],t)}function kG(n,e,t,o){return o==="html"?"<hr />":o==="markdown"?"---":"------------"}function wG(){return{name:"hr",insertEmbedCommandItems:[{id:"insert-hr",name:R.t("dividingLine.type"),icon:zL,order:500,group:"common",subText:pn("insert-hr")}],handleInsertEmptyEmbed:async(n,e)=>{const{containerId:t,blockIndex:o}=e;return n.insertEmbed(t,o,CG,{})}}}function BG(n,e,t){const{data:o}=t;if(!o||o.embedType!=="dividing-line"||!ee(n,e))return null;const r={};return{blockData:{id:K(),type:"embed",embedType:"hr",embedData:r}}}function EG(){return{abstract:R.t("dividingLine.abstract")}}const uk={embedType:"hr",createEmbedContent:yG,convertTo:kG,getOptions:wG,convertFrom:BG,getBlockProperties:EG},ioe="",soe="",xG={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 <span class="retry-upload">\u91CD\u8BD5</span></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 <span class="retry-upload">\u91CD\u8BD5</span></div>'},audio:{menuItem:"\u97F3\u9891",abstract:"\u97F3\u9891"},video:{menuItem:"\u89C6\u9891",abstract:"\u89C6\u9891"}}},IG={media:{upload:{failed:'<div class="line-1">{name} upload failed</div><div class="line-2">The network service is abnormal, you can <span class="retry-upload">Try again</span></div>'},load:{failed:'<div class="line-1">{name} loading failed</div><div class="line-2">The network service is abnormal, you can <span class="retry-upload">Try again</span></div>'},audio:{menuItem:"Audio",abstract:"Audio"},video:{menuItem:"Video",abstract:"Video"}}},TG={media:{upload:{failed:'<div class="line-1">{name}\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F</div><div class="line-2">\u304A\u4F7F\u3044\u306E\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u306B\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u6B21\u306E\u64CD\u4F5C\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002 <span class="retry-upload">\u518D\u8A66\u884C</span></div>'},load:{failed:'<div class="line-1">{name}\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F</div><div class="line-2">\u304A\u4F7F\u3044\u306E\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u306B\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u6B21\u306E\u64CD\u4F5C\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002 <span class="retry-upload">\u518D\u8A66\u884C</span></div>'},audio:{menuItem:"\u97F3\u58F0",abstract:"\u97F3\u58F0"},video:{menuItem:"\u52D5\u753B",abstract:"\u52D5\u753B"}}};R.mergeLang({"zh-CN":xG,"en-US":IG,"ja-JP":TG});var Vo=(n=>(n.AUDIO="audio",n.VIDEO="video",n))(Vo||{}),$u=(n=>(n.Empty="empty",n.Progress="progress",n.Error="error",n))($u||{});const dk=10*1024*1024,DG=["wav","mp3","aac","ogg","webm","flac"],SG=["ogg","mp4","webm"],LG=()=>{};function hk(n){var h,p,A,v,B,D;const e=(h=n.getComponentOptions("media"))!=null?h:{},{allowedMedias:t,maxSize:o,callbacks:r}=e,i=(p=t==null?void 0:t.audio)!=null?p:DG,s=(A=t==null?void 0:t.video)!=null?A:SG,l=(v=o==null?void 0:o.audio)!=null?v:dk,a=(B=o==null?void 0:o.video)!=null?B:dk,d=(D=r==null?void 0:r.onError)!=null?D:LG;return{allowedMedias:{audio:i,video:s},maxSize:{audio:l,video:a},callbacks:{onError:d}}}function MG(n,e){const t=i=>i.map(s=>`.${s}`).join(","),{allowedMedias:o}=hk(n),r=o[e];return r?t(r):"*"}function RG(n,e,t){const{maxSize:o,callbacks:r,allowedMedias:i}=hk(e),{[t]:s}=o,{[t]:l}=i;if(s&&n.size>s){const d=new Error("media is too large");throw d.code=`MaxMediaSize-${t}`,r!=null&&r.onError&&(r==null||r.onError(e,d)),d}const a=Aa(n.name);if(l&&!l.includes(a)){const d=new Error(`media file is not allowed: ${a}`);throw d.code="NotAllowedFile",r!=null&&r.onError&&(r==null||r.onError(e,d)),d}}function OG(n){return n===$u.Empty||n===$u.Error}const Pt=S("media");class _G extends bt.TypedEmitter{constructor(t){super();m(this,"mediaContainer",null);m(this,"media",null);m(this,"abstract",null);m(this,"handleMediaLoadError",(t,o)=>{if(!o.target||!(o.target instanceof Node)||!(o.target instanceof Element?o.target:o.target.parentElement))return;const i=oe(o.target);if(!i||!i.contains(this.mediaContainer))return;const s=this.renderError();this.updateMediaContent(s),this.emit("mediaError",t,"load_error",ie(i))});m(this,"handleUploadFile",async t=>{g(Pt,this.abstract,"no abstract"),g(Pt,this.mediaContainer,"The media element not exist");const{editor:o}=this.options,r=oe(this.mediaContainer);g(Pt,r,"The block element not exist");const i=o.getBlockData(r);try{const{resourceId:s}=await o.doc.uploadResource(t,{onProgress:p=>{this.renderProgress(p,t)}}),{name:l,type:a,size:d}=t,h={...i,embedData:{...i.embedData,src:s,fileName:l,fileSize:d,fileType:a}};o.updateBlockData(r,h)}catch(s){Pt.error(s),this.emit("mediaError",o,"upload_error",i.id),this.renderRetry(t)}te(r,"media-block-uploading")});m(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){g(Pt,this.mediaContainer,"The media element not exist"),this.mediaContainer.innerHTML="",this.mediaContainer.append(t)}renderError(){g(Pt,this.abstract,"no abstract");const{editor:t,createMediaElement:o}=this.options,{mediaIcon:r,mediaName:i}=this.abstract;g(Pt,this.mediaContainer,"The media element not exist");const s=oe(this.mediaContainer);g(Pt,s,"The block element not exist");const l=t.getBlockData(s),a=l.embedData.src,d=w("div",["media-error","embed-selected-content","embed-hover-content"],null),h=w("span",["media-error-icon"],d);h.innerHTML=r;const p=w("div",[],d);p.innerHTML=R.t("media.load.failed",{name:i}),d.appendChild(p);const A=p.querySelector(".retry-upload");return g(Pt,A,"The element not exist"),t.domEvents.addEventListener(A,"click",(v,B)=>{const D=w("div",["media-element"],null),I=this.getResourceUrl(a),_=o(v,D,l,I);this.unbindMediaEvent(),this.media=_,this.bindMediaEvent(),this.updateMediaContent(D)}),this.setFullScreen(),d}renderRetry(t){g(Pt,this.abstract,"no abstract");const{editor:o}=this.options,{mediaIcon:r,mediaName:i}=this.abstract,s=w("div",["media-error","embed-selected-content","embed-hover-content"],null),l=w("span",["media-error-icon"],s);l.innerHTML=r;const a=w("div",[],s);a.innerHTML=R.t("media.upload.failed",{name:i}),s.appendChild(a);const d=a.querySelector(".retry-upload");g(Pt,d,"The element not exist"),o.domEvents.addEventListener(d,"click",()=>{o.readonly||(g(Pt,this.abstract,"no abstract"),this.handleUploadFile(t))}),this.updateMediaContent(s),this.setFullScreen()}renderProgress(t,o){g(Pt,this.mediaContainer,"The media element not exist");const r=this.mediaContainer.querySelector(":scope .media-progress"),i=t===-1||t===100?100:t;if(r){const{updateProgressElement:s}=this.options;s(r,i)}else{const{createProgressElement:s}=this.options,l=oe(this.mediaContainer);g(Pt,l,"The element not exist"),W(l,"media-block-uploading");const a=w("div",["media-progress"],null);s(a,i,o),this.updateMediaContent(a)}this.setFullScreen()}renderMediaElement(t){g(Pt,this.mediaContainer,"The media element not exist");const o=this.mediaContainer.querySelector(":scope > .media-element"),{createMediaElement:r,updateMediaElement:i,editor:s}=this.options,l=this.getResourceUrl(t.embedData.src);if(o){const a=i(s,o,t,l);this.unbindMediaEvent(),this.media=a,this.bindMediaEvent()}else{const a=w("div",["media-element"],null),d=r(s,a,t,l);this.unbindMediaEvent(),this.media=d,this.bindMediaEvent(),this.updateMediaContent(a)}}renderEmpty(t){g(Pt,this.abstract,"no abstract"),g(Pt,this.mediaContainer,"The media element not exist");const o=w("div",["media-empty","embed-selected-content","embed-hover-content"],this.mediaContainer);o.innerHTML=this.abstract.mediaIcon,this.updateMediaContent(o);const{editor:r}=this.options;r.findBlockById(t.id)&&this.emit("mediaError",r,"empty",t.id),this.setFullScreen()}getResourceUrl(t){const{editor:o}=this.options;return o.doc.buildResourceUrl(t)}setFullScreen(){g(Pt,this.mediaContainer,"The media element not exist"),W(this.mediaContainer,"full-screen")}removeFullScreen(){g(Pt,this.mediaContainer,"The media element not exist"),te(this.mediaContainer,"full-screen")}updateBlockAlign(t,o){const r=oe(o);g(Pt,r,"The block element not exist");const{align:i}=t;t.embedType==="video"&&(r.hasAttribute("data-style-align")&&r.removeAttribute("data-style-align"),r.setAttribute("data-style-align",i))}render(t,o){const{src:r}=t.embedData;(!this.mediaContainer||!o.contains(this.mediaContainer))&&(this.mediaContainer=w("div",["media"],o)),this.updateBlockAlign(t,o),OG(r)?r===$u.Empty&&this.renderEmpty(t):this.renderMediaElement(t)}setAbstract(t){this.abstract=t}}S("media-embed");const FG="left";class fk{constructor(){m(this,"handleInsertEmptyEmbed",async(e,t)=>{var p;const{containerId:o,blockIndex:r}=t;let i;(p=t.data)!=null&&p.file&&(i=t.data.file);const s=MG(e,this.embedType);if(i=i!=null?i:await zl(s,{}),!i)return null;const{mediaType:l}=this.getAbstract();try{RG(i,e,l)}catch{return null}const a={id:K(),type:"embed",embedType:this.embedType,embedData:{src:$u.Empty}};l==="video"&&(a.align=FG);const d=e.insertBlock(o,r,a);return await this.getMedia(e,a.id).handleUploadFile(i),d})}getMedia(e,t){const o=e.addCustom(`media-${t}`,()=>new _G({editor:e,createMediaElement:this.createMediaElement,updateMediaElement:this.updateMediaElement,createProgressElement:this.createProgressElement,updateProgressElement:this.updateProgressElement}));return o.setAbstract({...this.getAbstract()}),o}getOptions(){const{menuItem:e,mediaIcon:t,mediaName:o,order:r,group:i}=this.getAbstract();return{name:o,insertEmbedCommandItems:[{id:`insert-${this.embedType}`,name:e,icon:t,order:r,group:i,subText:pn(`insert-${this.embedType}`)}],handleInsertEmptyEmbed:this.handleInsertEmptyEmbed}}createEmbedContent(e,t,o){const{id:r}=o;this.getMedia(e,r).render(o,t)}handleUpdateBlock(e,t,o){const{id:r}=o,i=this.getMedia(e,r),s=Re(t);return i.render(o,s),!0}handleDeleteBlock(e,t){const o=t.id,r=this.getMedia(e,o);r.removeAllListeners(),r.destroy()}convertTo(e,t,o,r){const i=t.embedData,s=e.doc.buildResourceUrl(i.src,{withToken:!0});return r==="html"?`<${i.type} src="${s}" />`:r==="markdown"?`![${i.src}](${s})`:s}}function mk(n,e){const t=w("div",["uploading-progress-mask"],n),o=w("div",["uploading-progress-bar"],t),r=w("div",["uploading-progress-bar-value"],o);r.style.width=`${e}%`}function gk(n,e){const t=n.querySelector(".uploading-progress-bar-value");t&&(t.style.width=`${e}%`)}const PG=S("media-audio");class NG extends fk{constructor(){super(...arguments);m(this,"embedType",Vo.AUDIO);m(this,"updateProgressElement",gk);m(this,"createMediaElement",(t,o,r,i)=>{const s=w("div",["audio-container","embed-hover-content","embed-selected-content"],o),l=w("audio",[],s);return l.innerHTML="Your browser does not support the <code>audio</code> element.",l.controls=!0,l.src=i,setTimeout(()=>{this.getMedia(t,r.id).setFullScreen()}),l})}getAbstract(){return{mediaIcon:HL,mediaName:R.t(`media.${Vo.AUDIO}.menuItem`),menuItem:R.t(`media.${Vo.AUDIO}.menuItem`),order:800,mediaType:Vo.AUDIO,group:"common"}}getBlockProperties(){return{abstract:`${R.t(`media.${Vo.AUDIO}.abstract`)}`}}updateMediaElement(t,o,r,i){const s=o.querySelector(":scope .audio-container > audio");return g(PG,s,"The media element not exist"),s.src!==i&&(s.src=i),s}createProgressElement(t,o){const r=w("audio",[],t);r.innerHTML="Your browser does not support the <code>audio</code> element.",r.controls=!0,r.src="about:blank",mk(t,o)}}const pk=new NG;S("video-resizer");function Ck(n){return n&&Lt(n)&&Un(n)==="video"}const $G=50;class G2{constructor(e){m(this,"currentResizableElement",null);m(this,"resizing",!1);m(this,"handleHoveringBlockChange",(e,t)=>{if(!this.resizing&&(t&&Ck(t)&&this.disableBlockResize(t),e&&Ck(e))){const o=this.getVideoElement(e);if(!o)return;this.enableBlockResize(e,o)}});m(this,"handleResizing",(e,t)=>{if(this.resizing=!0,!this.currentResizableElement)return;const o=e.getBlock();if(!o)return;const r=o.getBoundingClientRect().width,i=Math.min(Math.max(t.width,$G),r);this.currentResizableElement.style.width=`${i}px`});m(this,"handleResized",e=>{this.resizing=!1;const t=e.getBlock();if(!this.currentResizableElement||!t)return;const o=this.editor.getBlockData(t),{width:r}=this.currentResizableElement.getBoundingClientRect();this.editor.updateBlockData(t,{...o,width:r})});this.editor=e,pt.get(e).addListener("change",this.handleHoveringBlockChange)}destroy(){this.currentResizableElement=null,pt.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}getVideoElement(e){return Re(e).querySelector(":scope .video-container > video")}updateResizer(e){const t=this.editor.findCustom(`${ie(e)}-resizer`);t&&t.updateResizer()}disableBlockResize(e){const t=this.editor.findCustom(`${ie(e)}-resizer`);t&&t.disableResize()}enableBlockResize(e,t){const o=this.editor.addCustom(`${ie(e)}-resizer`,()=>new wu(this.editor,{resize:["top-left","top-right","bottom-left","bottom-right"]}));o.enableResize(e,t),o.removeListener("resizing",this.handleResizing),o.removeListener("resized",this.handleResized),o.addListener("resizing",this.handleResizing),o.addListener("resized",this.handleResized),this.currentResizableElement=t}}const HG=S("video");class jG extends fk{constructor(){super(...arguments);m(this,"embedType",Vo.VIDEO);m(this,"updateProgressElement",gk);m(this,"createMediaElement",(t,o,r,i)=>{const s=w("div",["video-container","embed-selected-content","drag-preview-element"],o),l=w("video",[],s);return l.innerHTML="Your browser does not support the <code>video</code> element.",l.controls=!0,l.src=i,l.addEventListener("canplay",()=>{t.addCustom("video-resizer",()=>new G2(t)),this.getMedia(t,r.id).removeListener("mediaError",this.handleMediaError),this.getMedia(t,r.id).addListener("mediaError",this.handleMediaError),this.getMedia(t,r.id).removeFullScreen()}),r.width&&(l.style.width=`${r.width}px`),l});m(this,"createProgressElement",(t,o,r)=>{const i=w("video",["progress-video"],t);i.innerHTML="Your browser does not support the <code>audio</code> element.",i.controls=!0,mk(t,o),Ul(r).then(s=>{const l=t.querySelector(".progress-video");l&&Um(t)&&(l.src=s)})})}getAbstract(){return{mediaName:R.t(`media.${Vo.VIDEO}.menuItem`),mediaIcon:jL,menuItem:R.t(`media.${Vo.VIDEO}.menuItem`),order:700,mediaType:Vo.VIDEO,group:"common"}}getBlockProperties(){return{abstract:`[${R.t(`media.${Vo.VIDEO}.abstract`)}]`}}handleMediaError(t,o,r){const i=t.addCustom("video-resizer",()=>new G2(t)),s=t.getBlockById(r);i.disableBlockResize(s)}updateMediaElement(t,o,r,i){const s=o.querySelector(":scope .video-container > video");g(HG,s,"The media element not exist"),s.src!==i&&(s.src=i),r.width?s.style.width=`${r.width}px`:s.style.width="";const l=t.getBlockById(r.id);return setTimeout(()=>{t.addCustom("video-resizer",()=>new G2(t)).updateResizer(l)}),s}}const Ak=new jG,bk=[xf,Sf,U0,E9],Z2=[z2,Z8,rk,lk,ak,F9,uk,Ak,pk,X7,j8,Yz],vk=[T0,F2,u8];function UG(n,e,t){var r,i,s;const o=Ha(n,e,{components:{blocks:[...bk,...((r=t==null?void 0:t.components)==null?void 0:r.blocks)||[]],embeds:[...Z2,...((i=t.components)==null?void 0:i.embeds)||[]],boxes:[...vk,...((s=t.components)==null?void 0:s.boxes)||[]],textRenders:[new C0],options:{...t.componentsOptions}}});return o.readonly=!0,o.addCustom("heading-collapse",()=>new F8(o)),o.addCustom("editor-tooltip",()=>new bf(o)),o.addListener("clickLink",(l,a,d)=>{var p;if((p=t==null?void 0:t.events)!=null&&p.onClickLink){t.events.onClickLink(l,a,d);return}const h=d.getAttribute("link");h&&(l.readonly||a.ctrlKey||a.metaKey)&&window.open(h,"_blank")}),o}class yk{constructor(e){this.createOptions=e,e.lang&&R.setLang(e.lang)}createHistoryEditor(e,t){return UG(e,t,this.createOptions)}}S("create-editor");function kk({root:n,childDoc:e,doc:t}){e.uploadResource=t.uploadResource.bind(t),e.buildResourceUrl=t.buildResourceUrl.bind(t);const o=Ha(n,e,{shortcuts:[Lh],components:{blocks:[xf,Sf],decorators:[new Lf],embeds:[X7,z2,Z8,rk,lk,ak,F9,uk,Ak,pk],boxes:[T0,F2],options:{image:{defaultAlign:"left"}}}});return o.input.addHandler(new If),o.input.addHandler(new c2(o)),o.input.addHandler(new f2(o)),o.input.addHandler(new tz(o)),o.input.addHandler(new Ff),o.addCustom("image-paste-handler",()=>new l2(o)),o}function zG(n,e){const t=Array.from(n.rootContainer.querySelectorAll(`[comment-${e.toLocaleLowerCase()}="${e}"]`)),o=new Set;t.forEach(r=>{const i=oe(r);i&&o.add(i)}),o.forEach(r=>{nz(n,r,e)})}class VG{constructor(e){m(this,"listeners",new Set);m(this,"doc");this.editor=e,this.doc=this.editor.doc.externalDoc,this.doc.registerCallback(this)}getComments(){return this.doc.getComments()}getComment(e){return this.doc.getComment(e)}getCommentDoc(e){return this.doc.getCommentDoc(e)}localCreateComment(e,t){this.doc.localCreateComment(e,t)}localDeleteComment(e){const t=this.getComment(e);this.doc.localDeleteComment(e);const o=t.groupId;this.getComments().filter(i=>i.groupId===o).length===0&&zG(this.editor,o)}localUpdateComment(e,t){this.doc.localUpdateComment(e,t)}onCreateComment(e,t){Array.from(this.listeners.values()).forEach(o=>o.onCreateComment(e,t))}onDeleteComment(e,t){Array.from(this.listeners.values()).forEach(o=>o.onDeleteComment(e,t))}onUpdateComment(e,t){Array.from(this.listeners.values()).forEach(o=>o.onUpdateComment(e,t))}addListener(e){this.listeners.add(e)}removeListener(e){this.listeners.delete(e)}createCommentEditor(e,t){var r,i;const o=kk({root:e,childDoc:t,doc:this.doc});if((r=this.editor.options.componentsOptions)!=null&&r.mention){const s=this.editor.options.componentsOptions.mention;o.addCustom("mention",()=>new _2(o,{...s,enableFirstBlock:!0}))}if((i=this.editor.options.componentsOptions)!=null&&i.comment){const s=this.editor.options.componentsOptions.comment;s.onCommentEditorClick&&o.addListener("click",s.onCommentEditorClick)}return o}allowEdit(e){return e.userId===this.doc.getUser().userId}}class WG{constructor(e,t){m(this,"listeners",new Set);this.editor=e,this.localDoc=t}get doc(){return this.localDoc.toJSON()}getComments(){return Object.values(this.doc.comments)}getComment(e){return this.doc.comments[e]}getCommentDoc(e){const t=this.doc.comments[e];return bp(t)}addListener(e){this.listeners.add(e)}removeListener(e){this.listeners.delete(e)}localCreateComment(e,t){}localDeleteComment(e){}localUpdateComment(e,t){}createCommentEditor(e,t){var r,i;const o=kk({root:e,childDoc:t,doc:this.localDoc});if((r=this.editor.options.componentsOptions)!=null&&r.mention){const s=this.editor.options.componentsOptions.mention;o.addCustom("mention",()=>new _2(o,{...s,enableFirstBlock:!0}))}if((i=this.editor.options.componentsOptions)!=null&&i.comment){const s=this.editor.options.componentsOptions.comment;s.onCommentEditorClick&&o.addListener("click",s.onCommentEditorClick)}return o}allowEdit(e){return e.userId===this.localDoc.getUser().userId}}const qG={placeholder:{common:{title:"\u8BF7\u8F93\u5165\u6807\u9898",readonlyTitle:"\u8BF7\u8F93\u5165\u6807\u9898",content:"\u70B9\u51FB + \uFF0C\u6216\u8F93\u5165 / \u5FEB\u6377\u63D2\u5165\u7EC4\u4EF6",contentInTable:"\u8F93\u5165 / \u5FEB\u6377\u63D2\u5165\u7EC4\u4EF6"},local:{readonlyTitle:"\u672A\u547D\u540D"}},copyCutProperty:{copy:"\u590D\u5236",cut:"\u526A\u5207",unsafeEnvTips:"\u7531\u4E8E\u5F53\u524D http \u8BBF\u95EE\u73AF\u5883\u4E0B\u7684\u9650\u5236\uFF0C\u8BF7\u4F7F\u7528\u5FEB\u6377\u952E({shortCut}) {operation}"}},GG={placeholder:{common:{title:"Enter a title",readonlyTitle:"Enter a title",content:'Click "+", or enter "/" to insert components quickly',contentInTable:'Enter "/" to insert components quickly'},local:{readonlyTitle:"Untitled"}},copyCutProperty:{copy:"copy",cut:"cut",unsafeEnvTips:"Due to the limitations of the current http access environment, please use the shortcut ({shortCut}) {operation}"}},ZG={placeholder:{common:{title:"\u30BF\u30A4\u30C8\u30EB\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",readonlyTitle:"\u30BF\u30A4\u30C8\u30EB\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",content:"\u300C+\u300D\u3092\u30AF\u30EA\u30C3\u30AF\u3059\u308B\u304B\u3001\u300C/\u300D\u3092\u5165\u529B\u3059\u308B\u3068\u3001\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u304C\u7D20\u65E9\u304F\u633F\u5165\u3067\u304D\u307E\u3059",contentInTable:"\u300C/\u300D\u3092\u5165\u529B\u3059\u308B\u3068\u3001\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u304C\u7D20\u65E9\u304F\u633F\u5165\u3067\u304D\u307E\u3059"},local:{readonlyTitle:"\u7121\u984C"}},copyCutProperty:{copy:"\u8907\u88FD",cut:"\u5207\u308B",unsafeEnvTips:"HTTP\u74B0\u5883\u306E\u5236\u7D04\u306B\u3088\u308A\u3001{operation}\u3059\u308B\u306B\u306F\u3001\u30B7\u30E7\u30FC\u30C8\u30AB\u30C3\u30C8({shortCut}) \u3092\u3054\u4F7F\u7528\u304F\u3060\u3055\u3044"}};R.mergeLang({"zh-CN":qG,"en-US":GG,"ja-JP":ZG});const QG="UEsDBBQABgAIAAAAIQBk9WPugQEAACkGAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC0lMtqwzAQRfeF/oPRtsRKuiilxMmij2UbaArdKvI4EdULaZzH33fsJKYUJy5NsjHIM/feowHNcLw2OllCiMrZjA3SPkvASpcrO8/Yx/Sld8+SiMLmQjsLGdtAZOPR9dVwuvEQE1LbmLEFon/gPMoFGBFT58FSpXDBCKRjmHMv5JeYA7/t9++4dBbBYg8rDzYaPkEhSo3J85p+b0kC6MiSx21jlZUx4b1WUiDV+dLmv1J6u4SUlHVPXCgfb6iB8daEqnI4YKd7o9EElUMyEQFfhaEuvnIh57mTpSFletymhdMVhZLQ6Cs3H5yEGGnmRqcIxtMNIDVC2T1/G4csIzrzaTRXpJkE5+PgZJzGtPKDgAqaGR6chS3NDALRn38YjXUnRMSNhnh+gq1vdzwgkuASADvnToQVzN4vRvHDvBOkoNypmGk4P0Zj3QmBtIpg+z39VdQ2xyKps36AtNrCP669312Vuuf/9PKaRLI++X5QrcUc8pZsXi/60TcAAAD//wMAUEsDBBQABgAIAAAAIQAekRq37wAAAE4CAAALAAgCX3JlbHMvLnJlbHMgogQCKKAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAArJLBasMwDEDvg/2D0b1R2sEYo04vY9DbGNkHCFtJTBPb2GrX/v082NgCXelhR8vS05PQenOcRnXglF3wGpZVDYq9Cdb5XsNb+7x4AJWFvKUxeNZw4gyb5vZm/cojSSnKg4tZFYrPGgaR+IiYzcAT5SpE9uWnC2kiKc/UYySzo55xVdf3mH4zoJkx1dZqSFt7B6o9Rb6GHbrOGX4KZj+xlzMtkI/C3rJdxFTqk7gyjWop9SwabDAvJZyRYqwKGvC80ep6o7+nxYmFLAmhCYkv+3xmXBJa/ueK5hk/Nu8hWbRf4W8bnF1B8wEAAP//AwBQSwMEFAAGAAgAAAAhADPCW79BAQAA5wQAABwACAF3b3JkL19yZWxzL2RvY3VtZW50LnhtbC5yZWxzIKIEASigAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAArJQxT8MwEIV3JP5D5B07LVAQatoFkDqwQJFYneSSWI3tyL6Q9t9zojRNRYkYPN6z7r1P57Pny62uo09wXlmTsAmPWQQms7kyZcLe189X9yzyKE0ua2sgYTvwbLm4vJi/Qi2RmnylGh+Ri/EJqxCbByF8VoGWntsGDJ0U1mmJVLpSNDLbyBLENI5nwg092OLEM1rlCXOrnPLXuwb+422LQmXwaLNWg8EzEQKpF8hQuhIwYd/lXpxwMmPiPMN1SAaPu5qG2EPs67H4u5DxhTW4lmk9GEMvjUFMQ0KYVqfgaMeOEL00BjEJCZG1Hq3+oLQegvOjKhSCHl2LWUiaipxcrczmSPNj23UdT6XKW55ZLQ7HLzan5KctgjPyT8TbkIgdpG+ASHc0WN+BODarm6BP6BfFQTkgiJPvafEFAAD//wMAUEsDBBQABgAIAAAAIQBOMo6QFgYAAKYkAAARAAAAd29yZC9kb2N1bWVudC54bWzUWttu40QYvkfiHSJfLRKtz4eYTVeOD7uVQKoo+wCuPUmstT3WeNI0XC0XC1wguOBiuWClLgjBE4AEiIdZ0T28BTM+JM6h7cTZkm0vEnv+mW+++eb7/0yc3r13lsSdU4DyCKY9TtwXuA5IAxhG6bDHPfzM2zO4To79NPRjmIIeNwU5d+/g/ffuTswQBuMEpLhDINLcnGRBjxthnJk8nwcjkPj5fhIFCOZwgPcDmPBwMIgCwE8gCnlJEIXiKkMwAHlO5rP99NTPuQouOGNDC5E/IYMpoMIHIx9hcDbHEDcGUfkub6wCSS2AyAolcRVK3hhK4ymrFSClFRBhtYKktkNaszitHZK0iqS3Q5JXkYx2SCt2SlYNDjOQkuAAosTH5BYN+cRHj8bZHgHOfBydRHGEpwRT0GoYP0oftWBERs0QEjncGEHnExiCWA5rFNjjxig1q/F7s/GUulmOr97qEYhl/eUQpyoOxcp5BGKiBUzzUZTNMjxpi0aCoxrk9KpFnCZx3W+SiYzpcll5ckop54As9Cv9k7hkfjWiKDDsCIWYjWChsDhnzSQhLpxP3EqahrgiYwGpAaQVAC0AjAW/xjAqDD6YZyjFiRhTo8Ypd4XiRHNhRcY6tkymAZCDzSDUmkc+TRoryobb2fY+guNsjhZth3Y4L0ITehzYAKuyfzMl8+3IHI/8jNSmJDAPhylE/klMGBEzd4gfO8UO0FeyrfStuARnHVoIuANyfDmB4ZS+ZySimJmP/EPiHEV2dE+3La5oJcUf01a9+iOtJjkqhZ/2OEEQJE1z5FmTAwb+OMY04nUVRRfryFGjqZjwCBVvx3gaE4bmqR/3uAfAp2cukeNpDJVdYj8d1h1AuvfwmEb5KszPkMqX6tqDKc7JoFGUEi7Az7GVR35z4MTEBy/Pv3rz0w+0CZeBZZwrp6ajxIXBlMwaMT2l6wh9lUHMRcnejpjSDYrJoND2GksMGquOY+iu7exIY/m2ayyzaKwaqi4YNNd3obFy2zVWGDTW+7Il296uaoX6LmisMugkKIpouJqwI5202+5FjUFjTfQ8S7OMHWms33aNdQaNJd3qqoq8q5pq3HaNDRaNNcFzRafLoLGtaF2JdlzReDFSaFw1NTTeRMf1XBVLNcSux+KHnXOVBddQLEm6DVxVSxf6nubdPNfFPLNhCCqWdRxBOHARIj3wNCNf1YbIT46xj3CVi6WxA5jmMAb7MRzeWUqQtQhuGi6Mf/H4xxGIY/hhh3xbjMMXj5998BFDrsiSZnuiYjPoZLiC7fV3rVM+zTFI9uEY72eI1KA4baPWnZZyiYYu2oLFlK6u2C3OzqtyLURaytXME8Zvv//+9fOr8y8unj1lWKjqeroraMpWvliMFAutmoq9WDp9aJohGzrLN7o2M7asLrVj6MMbM8/8gBgqQyAH6BRwB5RlZ8l/1HgFrSO0NH29Wws7e5jGUQoa+zvbLgwuQ26YiBGX2SOvn39z8eWT0ik3tbAzvIzMuiuXbkRndSfW+1rRlb7nKExng00SeDuXXcK1qwiWJi99hmme4uiaRfNkJ1wXt2u78+Dr35+8+vPXJTeMSNVGxDuPOsiMyILRYahR/qMoxxBNSREuTbdox+vy4UGNem06MPB+8/0/L7/9ZdluM+JvV6SX539c/P0dg7eFru3alrhUs1VH6kuqPD/gULUcRVAdd51fFiM35m21L3ueJNOJGlwFQ1FFxZ0beQ3Xcrs3WkDV1FjA4qfrx8RZR4QYOSlko3JX0nFS9ozi07juJ8xih2HdVjy65mcDGlmyljCbK5rbf/H109fPf7u6FjfA2R5Rq47sCZq2JL/ueo5o2VfK//8oXf0g8K4rvcf0c4DrGX25v3TElmzV1foiLe47tfrGZf16xWbiLMlTh/yTCmauWA4CfDST+jopimUNjz8nwQnxhSQp9LmgOSLXqqFUWZoNP/EpIoYZaVfKLigajvD89gRiDJP5fQwGjegI+CEg8+oCfSRmDiDEjdvhGBe31XQBjKle1cmE9imaQxjcR/SnOJOeho4iHBCWslYM4ut1F5flD3P8/B+MDv4DAAD//wMAUEsDBBQABgAIAAAAIQC29GeY0gYAAMkgAAAVAAAAd29yZC90aGVtZS90aGVtZTEueG1s7FlLixtHEL4H8h+Guct6zehhrDXSSPJr1zbetYOPvVJrpq2eadHd2rUwhmCfcgkEnJBDDLnlEEIMMcTkkh9jsEmcH5HqHkkzLfXEj12DCbuCVT++qv66qrq6NHPh4v2YOkeYC8KSjls9V3EdnIzYmCRhx719MCy1XEdIlIwRZQnuuAss3Is7n392AZ2XEY6xA/KJOI86biTl7Hy5LEYwjMQ5NsMJzE0Yj5GELg/LY46OQW9My7VKpVGOEUlcJ0ExqL0xmZARdg6USndnpXxA4V8ihRoYUb6vVGNDQmPH06r6EgsRUO4cIdpxYZ0xOz7A96XrUCQkTHTciv5zyzsXymshKgtkc3JD/beUWwqMpzUtx8PDtaDn+V6ju9avAVRu4wbNQWPQWOvTADQawU5TLqbOZi3wltgcKG1adPeb/XrVwOf017fwXV99DLwGpU1vCz8cBpkNc6C06W/h/V671zf1a1DabGzhm5Vu32saeA2KKEmmW+iK36gHq92uIRNGL1vhbd8bNmtLeIYq56IrlU9kUazF6B7jQwBo5yJJEkcuZniCRoALECWHnDi7JIwg8GYoYQKGK7XKsFKH/+rj6Zb2KDqPUU46HRqJrSHFxxEjTmay414FrW4O8urFi5ePnr989PvLx49fPvp1ufa23GWUhHm5Nz9988/TL52/f/vxzZNv7XiRx7/+5avXf/z5X+qlQeu7Z6+fP3v1/dd//fzEAu9ydJiHH5AYC+c6PnZusRg2aFkAH/L3kziIEMlLdJNQoAQpGQt6ICMDfX2BKLLgeti04x0O6cIGvDS/ZxDej/hcEgvwWhQbwD3GaI9x656uqbXyVpgnoX1xPs/jbiF0ZFs72PDyYD6DuCc2lUGEDZo3KbgchTjB0lFzbIqxRewuIYZd98iIM8Em0rlLnB4iVpMckEMjmjKhyyQGvyxsBMHfhm327jg9Rm3q+/jIRMLZQNSmElPDjJfQXKLYyhjFNI/cRTKykdxf8JFhcCHB0yGmzBmMsRA2mRt8YdC9BmnG7vY9uohNJJdkakPuIsbyyD6bBhGKZ1bOJIny2CtiCiGKnJtMWkkw84SoPvgBJYXuvkOw4e63n+3bkIbsAaJm5tx2JDAzz+OCThC2Ke/y2EixXU6s0dGbh0Zo72JM0TEaY+zcvmLDs5lh84z01QiyymVss81VZMaq6idYQK2kihuLY4kwQnYfh6yAz95iI/EsUBIjXqT5+tQMmQFcdbE1XuloaqRSwtWhtZO4IWJjf4Vab0bICCvVF/Z4XXDDf+9yxkDm3gfI4PeWgcT+zrY5QNRYIAuYAwRVhi3dgojh/kxEHSctNrfKTcxDm7mhvFH0xCR5awW0Ufv4H6/2gQrj1Q9PLdjTqXfswJNUOkXJZLO+KcJtVjUB42Py6Rc1fTRPbmK4RyzQs5rmrKb539c0Ref5rJI5q2TOKhm7yEeoZLLiRT8CWj3o0Vriwqc+E0LpvlxQvCt02SPg7I+HMKg7Wmj9kGkWQXO5nIELOdJthzP5BZHRfoRmsExVrxCKpepQODMmoHDSw1bdaoLO4z02Tker1dVzTRBAMhuHwms1DmWaTEcbzewB3lq97oX6QeuKgJJ9HxK5xUwSdQuJ5mrwLST0zk6FRdvCoqXUF7LQX0uvwOXkIPVI3PdSRhBuENJj5adUfuXdU/d0kTHNbdcs22srrqfjaYNELtxMErkwjODy2Bw+ZV+3M5ca9JQptmk0Wx/D1yqJbOQGmpg95xjOXN0HNSM067gT+MkEzXgG+oTKVIiGSccdyaWhPySzzLiQfSSiFKan0v3HRGLuUBJDrOfdQJOMW7XWVHv8RMm1K5+e5fRX3sl4MsEjWTCSdWEuVWKdPSFYddgcSO9H42PnkM75LQSG8ptVZcAxEXJtzTHhueDOrLiRrpZH0Xjfkh1RRGcRWt4o+WSewnV7TSe3D810c1dmf7mZw1A56cS37tuF1EQuaRZcIOrWtOePj3fJ51hled9glabuzVzXXuW6olvi5BdCjlq2mEFNMbZQy0ZNaqdYEOSWW4dm0R1x2rfBZtSqC2JVV+re1ottdngPIr8P1eqcSqGpwq8WjoLVK8k0E+jRVXa5L505Jx33QcXvekHND0qVlj8oeXWvUmr53Xqp6/v16sCvVvq92kMwioziqp+uPYQf+3SxfG+vx7fe3cerUvvciMVlpuvgshbW7+6rteJ39w4Byzxo1IbtervXKLXr3WHJ6/dapXbQ6JX6jaDZH/YDv9UePnSdIw32uvXAawxapUY1CEpeo6Lot9qlplerdb1mtzXwug+Xtoadr75X5tW8dv4FAAD//wMAUEsDBBQABgAIAAAAIQDlI7CA9QMAAKALAAARAAAAd29yZC9zZXR0aW5ncy54bWy0Vttu2zgQfV9g/8HQ8zq6WHZsoU4R3zYp4nZRebHPlETZRHgRSMqu8/U7pETLu3ELp0VeEmrOzJkh53DoDx+/MdrbY6mI4FMvvAm8Hua5KAjfTr2/N6v+2OspjXiBqOB46h2x8j7e/f7bh0OisNbgpnpAwVXC8qm307pKfF/lO8yQuhEV5gCWQjKk4VNufYbkc131c8EqpElGKNFHPwqCkdfSiKlXS560FH1GcimUKLUJSURZkhy3/1yEvCZvE7IQec0w1zajLzGFGgRXO1Ipx8Z+lg3AnSPZ/2gTe0ad3yEMrtjuQcjiFHFNeSagkiLHSkGDGHUFEt4ljl8RnXLfQO52i5YKwsPArs4rH76NIHpFMMrxt7dxjFsOHyLPeUjxNp7RiYd0BxuOfq6YMwKF30YxdHWoI+t2pOg1PW6gJ5JJJJsb1DaY5cnjlguJMgrlQKN70Kuerc78hS2bf3YJOe/gIr8IwXqHpMIyBzXDFAgCzzdABtXBaFiIz0KntZSi5sUDRmD7LrwSQrcwKFCUqUYa8iZbiRjc/amXU4x4Q1/gEtVUb1CWalGB0x7B1m+jNnu+QxLlwJZWKAcdzwXXUlDnV5i0c5gjEmTeRtipYla1wqvlEzqKWp8haTOxgIEjBofznym0FgWMFAiV5PoumgBbTTg8L+H/iQRMWEkKvDFNSfWR4hVsJiUv+J4Xn2qlCTDaWfQLFfyoAMxN5i8go82xwiuMdA3H9k7JbGdWlFRrAqKQj7wAWb1bMlKWWEICAkJbg5yIFAd7zo1S3ysvKOwfcIZbPNiATJ9nQmvBHo7VDs761zpp9e+fyxme50K5xVe4YifXYBEHw8WyqdSgHRJEo9FicAkJV9Eyvr+EjJfBfDW7hMxm0WB+ewmZx6NJNLmILMPJ+GIFCyhiPL+IfHc/q0kc39qe+KcTYYl5dv+SbmWuVY81EXPEMklQb20eZt94ZPJ5RrjDMwzzFJ8jaZ05sN9vAMUQpStosANsc1hSEFUtcGnXdI3ktuNtPeRFK8y8TycuM26x/BMGZ9WgB4mq5ro4lzCO20jC9RNhzq7qLHVRHF6AMwim8Je9tOfUHc8h0SA/O3aekJWx9cW8P/9shIeR0veKoKn3sjOmRvlUpka1eI2qqhF/tg2nHiXbnQ5NmIavAn7S2Y9sG7VYZLGowewHys1mwbtddLbI2c78Bs426Gyxs8Wdbehsw842craRse1g3ElK+DPcQ7c09lJQKg64eOjwVyb3SuUERJAeWdY9PjcNRomCwVDBO6WFdNgfFgvjpBD5o3ls48Y+nIwXy8mg0XY4tO+btrMDjvYrLmdI4aJRt/tpffcvAAAA//8DAFBLAwQUAAYACAAAACEAQMH/8TkBAAAjAwAAFAAAAHdvcmQvd2ViU2V0dGluZ3MueG1snNJfT8IwEADwdxO/w9J36CCykIVBYgzGF2OifoDS3aCx7S294sBP720CYnhhvvT//XLXdrbYOZt8QiCDvhCjYSoS8BpL49eFeH9bDqYioah8qSx6KMQeSCzmtzezJm9g9Qox8klKWPGUO12ITYx1LiXpDThFQ6zB82aFwanI07CWToWPbT3Q6GoVzcpYE/dynKaZODDhGgWrymh4QL114GMXLwNYFtHTxtR01JprtAZDWQfUQMT1OPvjOWX8iRndXUDO6ICEVRxyMYeMOorDR2k3cvYXmPQDxhdApmHXz5geDMmR544p+znZyTHlmfO/ZM4Agn7E5JgH7V1bkdP509pjUCvLEr9RwtecdHDbcrZt1w35+Jx/LdbROPMFSwz3ARuCINtlZS02L8+PPJF/vvb8GwAA//8DAFBLAwQUAAYACAAAACEAOdtFTLkFAAAnWgAAEgAAAHdvcmQvbnVtYmVyaW5nLnhtbOyczW7qRhiG95V6D8j7xP8/oEOOwECV6rQ60knV9WAGsGKPrbGB0FV7Ke266q430EvpDfQWOuOxzZ9DbIMw5MwmDuP5Xs/3zjfDk0nCh48vvtdaQhy5AeoK8r0ktCBygomLZl3hp6fRnSW0ohigCfACBLvCGkbCx4dvv/mw6qCFP4aYdGwRDRR1VqHTFeZxHHZEMXLm0AfRve86OIiCaXzvBL4YTKeuA8VVgCeiIslS8l2IAwdGEdGxAVqCSEjlnJdyahMMViSYCmqiMwc4hi8bDbmyiC62RetQSKkhRDJU5EMptbKUIdJRHQhptYTIqA6U9HpKBckZ9ZSUQyWznpJ6qGTVUzooJ/+wwIMQInJzGmAfxOQlnok+wM+L8I4IhyB2x67nxmuiKRmZDHDRc40RkahcwVcnlRVM0Q8m0FMnmUrQFRYYddL4uzyeDr3D4tNLFoHL5M9CBoGz8CGKk8xFDD3iRYCiuRvmK9yvq0ZuzjOR5bEklr6X9VuFcsnl8tr2NGBWbgTLDD/13/fYyI8rylKJGaESeUSZIew+MxuJT6pw8+Ba1myZK5fcQDIB5UDAcGDJDT/TsFIN0dmsUKrjllwamQ6bFarjboyVS+5j+4PZEohgNQk9G0e09rcyCmenle13OFiEGzX3NLXHzSa0ojxQQSst/+0lGZ02mC9zEJK9yXc6jzMUYDD2yIhIMbdIPbaSGaBfybTSS/ItfGnRjUB4IPwCxlGMgRP/uPBbO68eSQERDiIiHQwJ/GDayFCnN40h7mMInmkXqoIiKt9ZAo+0jJS+ItuKINI7/sKL3U9wCb2ndQizPkmrR1tZr9gPveyeatvSUJE0dsdb0hsuuWTPSsaSdZZZL0JhIz9vHC88D8Z5/BN8yW/9++sfefv3TtbqwWnaPfyM6cVFNB3a3BU0hdrQmQM0S3iQviZ9xbwzTi+jAMURNTFyXFJgP5PelCCjJLpHLNpvcxGRn8ApIG6wx4+Tr25uJWuNfskalCRfMX2mmKSx75J8ukv//F7VJEu7nEkbO2T9bTuU0+3477e/q/ohK8alDDmevnqO9P+snL5hXUf6bJM7Mf2/qqavyNJ1pK83UvyKfrEt83j6RiPFr7QvthkeT99spPhV9Uq2PquR4lfNxrY+cQfg6DOO0p1ch+4Uua1LumWw/KvTXbsvGX1LS+O3p+sMdJc+r/xkXRPblYEZznY7dnC2Oz19znbV0udsx9mOsx1nuwunX5HtlDpsp2rKSB5ItdlOaxu2aitWbms+Xfzk7kIndzXW9OXwjsMchzkOc4Xpc5hroPg5zHGYuwWYU2vBXNvWTcsasvyLYW6+HmN38sMRpDN7pqbpmpabm09a4l0cek5XsI2BNVRNu8Y0hl/itZeP55MbxZ8BBjMMwnnhPH8FJ3y5rZakS0N5dAZ2fl9nfrlBw/5Is4b9s7x5XDM4VrWI7hepRZImtSVJYlUFUQxidwnP9JPGLcPmvkHMsjMbdMs4um8QazmzQbcMrPsGXccSuyKk3TfoOpbYFUHvvkHXscRuB4vpLl4HiwdqXxqw/KufcQ7aQ0Oib/2ZrfmEvv8zTn6ayU8z+WkmP818M31+mtlA8fPTTH6aeQvYRjG3Mrbplq0aZttm+VfHNsM2FG3YTk9Dt6frDNhWY7FybOPYtsmeYxvHNo5tHNsaTZ9jWwPFfzvYRk+8K2ObOVBHqmFpLP/q2NYb9CRTVtL47el679jGIe317DmkNVD6HNI4pHFI45DWaPoc0o5DGv2te3VIG/ZNc9QbsPyrQxrZGwzLlL/Kf/vgZ2sc2zi2cWx7M32ObQ0UP8c2jm1Xgm0owTWUffIKbdphtywjNZVDBWHsDbQwLPmf3VfC2BtPYVj2x+RFYQefD7gJM4+EsY2uMEw7EsY2iMKw5JMEXwljC6swLJvrojBWkIVhGcYlYezKIPrhfwAAAP//AwBQSwMEFAAGAAgAAAAhAPiVyO/8DgAA85kAAA8AAAB3b3JkL3N0eWxlcy54bWzsXd9zo0YSfr+q+x8oPSUPG/+QLTtbcVJr2T67btdxVt5L3eMIRhZnYHSA1uv89TczDAjUDKKHjuu8m6RqLQH9MczXX890A5qffvkSR95nnmahSM5GBz/sjzye+CIIk4ez0af7qzenIy/LWRKwSCT8bPTMs9EvP//9bz89vc3y54hnngRIsrexfzZa5vnq7d5e5i95zLIfxIoncudCpDHL5df0YS9m6eN69cYX8Yrl4TyMwvx573B/fzIyMGkfFLFYhD6/EP465kmu7fdSHklEkWTLcJWVaE990J5EGqxS4fMskxcdRwVezMKkgjk4AkBx6KciE4v8B3kxpkUaSpof7OtPcbQBOMYBHAKAic+/4DBODcaetKzjhAEOZ1LhhEENx60xNYCM4yCOy3Zkz7G6oth/e/OQiJTNI4kkOfJkN3saWP0rW6v+6I/y8J+lwwbCv+ALto7yTH1N71Lz1XzTf65Ekmfe01uW+WF4L9slweNQnuf6XZKFI7mHsyx/l4WsvvPSbFP7l+rAVks/y2ubz8MgHO2pk2Z/yJ2fWXQ2Ojwqt0xVIxrbIpY8lNt48mZ6W2/M2eiPpdk0l7hnI5a+mb1Thnvm2oq/tSteVd+Ko7a6R+pJqmtWiFzu5Yv3wn/kwSyXO85G++pUcuOnm7s0FKkU8tnoxx/NxhmPw+swCHhSOzBZhgH/fcmTTxkPNtt/u9JiNBt8sU7k5/HJRFMWZcHlF5+vlLTl3oSp3rtVBpE6eh1uTq7N/1uCHZg+a7Nfcqbim3ewDaGbj4I4VBZZ7WrbMddb166PQp1o/FInOnqpEx2/1IkmL3Wik5c60elLnUjD/JknCpOAfymECE8DUHfhWNSIxrGIDY1j0RIaxyIVNI5FCWgci6OjcSx+jMaxuCkCJxe+zQtrzj62eHs37u4xwg1395Dghrt7BHDD3R3w3XB3x3c33N3h3A13d/R2w90drPG4xVTLu5EyS/LBKlsIkSci517OvwxHY4nE0kkfDZ4a9HhKcpEEMEVkMwPxYDSf6e+7PUSL1H08z1U25omFtwgf1inPBjecJ595JLN2jwWBxCMETHm+Ti094uLTKV/wlCc+p3RsOtAoTLiXrOM5gW+u2AMZFk8C4u4rEUmCQuXQbJ0vlUhCAqeOmZ+K4U0TjCw+vA+z4X2lQLzzdRRxIqxbGhfTWMNzAw0zPDXQMMMzAw0zPDGocUbVRQaNqKcMGlGHGTSifiv8k6rfDBpRvxk0on4zaMP77T7MIx3i67OOg/61u2kkVJl+cDtm4UPC5ARg+HBjaqbeHUvZQ8pWS0+VkNth69eMPc+5CJ69e4oxrUKimtdrF5nKqw6T9fAObaBRiavCI5JXhUcksApvuMQ+yGmymqBd0+Qzs/U8bxWtRuol2hmL1sWEdrjaWD7cwzYCuArTjEwG7bAEHnyrprOKTorIt2nl8IZtsIbLajsqkTbPQBK0MhL+I00Yvn5e8VSmZY+Dka5EFIknHtAhzvJUFL5Wl/yhpqSX5C/j1ZJloc6VGhD9h/ryBr/3ga0GX9BdxMKEhrfLNzELI49uBnF9/+G9dy9WKs1UHUMDeC7yXMRkmKYS+N3vfP49TQPfySQ4eSa62ndE5SENNg0JBpkCSQRESHKaGSYhyRiq8f7Jn+eCpQEN2l3Ki2dqck6EOGPxqph0EGhLxsUnGX8IZkMa718sDVVdiEpU9yRgtbJhtp7/h/vDQ92t8EgqQ7+uc11/1FNdbU0HN3ya0IAbPkXQbMrhQfkvwcU24IZfbAOO6mKnEcuy0HoL1RmP6nJLPOrrHZ78GTwRiXSxjug6sAQk68ESkKwLRbSOk4zyijUe4QVrPOrrJXQZjUdQktN4/0jDgIwMDUbFhAajokGDUXGgwUgJGP6ETg1s+GM6NbDhz+oUYERTgBoYlZ+RDv9Ed3lqYFR+psGo/EyDUfmZBqPys/GFxxcLOQmmG2JqkFQ+V4OkG2iSnMcrkbL0mQjyMuIPjKBAWqDdpWKhXrYQSfEQNwGkqlFHhJPtAo6K5N/5nKxpCouyXQQVURZFQhDV1jYDjrZsPru2y0y/czG4CXcR8/lSRAFPLddkt5X58mzFfFOmB7f7epU934cPy9ybLatqfx1msr/TskzYG2a7T9jW55PDDrMPPAjXcdlQ+DLFZNzfWHt0w7h856XDeDOTaFge97SE55zsttzMkhuWJz0t4TlPe1pqnTYsu/RwwdLHVkc46fKfKsezON9JlxdVxq2n7XKkyrLNBU+6vKghFe+d76u7BZCdfpqx2/cTj90eoyI7CkZOdpTeurJDdAnsI/8cqpEdEzT1+aqnJ0Dc15PoXpHzt7Uo6vaNG079X+q6kROnJONeK864/42rRpSx92PvcGOH6B137BC9A5AdolckspqjQpIdpXdsskP0DlJ2CHS0giMCLlpBe1y0gvYu0QqiuESrAbMAO0Tv6YAdAi1UCIEW6oCZgh0CJVRg7iRUiIIWKoRACxVCoIUKJ2A4oUJ7nFChvYtQIYqLUCEKWqgQAi1UCIEWKoRACxVCoIXqOLe3mjsJFaKghQoh0EKFEGih6vniAKFCe5xQob2LUCGKi1AhClqoEAItVAiBFiqEQAsVQqCFCiFQQgXmTkKFKGihQgi0UCEEWqjFq4buQoX2OKFCexehQhQXoUIUtFAhBFqoEAItVAiBFiqEQAsVQqCECsydhApR0EKFEGihQgi0UPXNwgFChfY4oUJ7F6FCFBehQhS0UCEEWqgQAi1UCIEWKoRACxVCoIQKzJ2EClHQQoUQaKFCiC7/NLcobY/ZH+CrntYn9vvfujKN+lh/lbsONe4PVbbKjtX/XYRzIR691hcPxzrf6AcSzqNQ6BK15bZ6HVc/EoG68fnrtPsNnzr6wB9dMu9C6HumAPyoryWoqRx1uXzdEiR5R12eXrcEs86jruhbtwTD4FFX0NW6LB9KkcMRMO4KMzXjA4t5V7SumcMu7orRNUPYw12RuWYIO7grHtcMjz0VnLetj3v206R6vhQgdLljDeHEjtDllpCrMhxDYfQlzY7Qlz07Ql8a7QgoPq0weGLtUGiG7VBuVEOZYal2F6odAUs1RHCiGsC4Uw2hnKmGUG5Uw8CIpRoiYKl2D852BCeqAYw71RDKmWoI5UY1HMqwVEMELNUQAUv1wAHZCuNONYRyphpCuVENJ3dYqiEClmqIgKUaIjhRDWDcqYZQzlRDKDeqQZaMphoiYKmGCFiqIYIT1QDGnWoI5Uw1hOqiWldRGlSjGK6Z4yZhNUPcgFwzxAXnmqFDtlSzdsyWagiO2RLkquQcly3VSbMj9GXPjtCXRjsCik8rDJ5YOxSaYTuUG9W4bKmNaneh2hGwVOOyJSvVuGypk2pcttRJNS5bslONy5baqMZlS21UuwdnO4IT1bhsqZNqXLbUSTUuW7JTjcuW2qjGZUttVOOypTaqBw7IVhh3qnHZUifVuGzJTjUuW2qjGpcttVGNy5baqMZlS1aqcdlSJ9W4bKmTaly2ZKcaly21UY3LltqoxmVLbVTjsiUr1bhsqZNqXLbUSTUuW/ogTUKCn4CaxSzNPbrfi7tm2TJnw3+c8FOS8kxEn3ng0V7qe9RV7j01lr9S2Hq1O3l8LvtM/QJ67XWloPgFWAOoD7wJqmWqlLFqiWeW7jKbdYPN7Vr9Oc1kTm2O2d8/Pz8cT43UVsXSZFnxZqk8Rv1a0dloPNGvJKkvH9dqDTS2zoVpvTbZM43Z0fyqweb+8wFo8mbBLN2eOZM99avqYXBBifqxxZbtysnK7eVppkuWFns37l8eYwRu75+Lo/3ji8tG/zxyvrqV59fb1BfJOc/0t03XzdXvlHG1qJoRvyh+/On956gCr/ehZWE4qcRyrTrv3+yaNxaGa92pV4Vr3eNnZ6P7MOaZd8ufvI8iZon3nemkzJvOvje9rv/1VfjYdIP6T2HodeV0aDkbqd+9N0xtFpYrb5TXF5Yb60hTWx/OxVsOrd5i4hiNtxz28JamlP9kB7L7TxlBvir/GZuJQ2NhQr1toP+Mrf5jHgqh8Z/x6/GfUpVfl/9QxJojq6+Y6EbjK0evx1e0Rv5ffSWcFhfk7DPlSDzEZ46tPmMeAKPxmePX4zNaK19DfBnoGcUKs22eYcY6Gs+YvB7P0Ir4yzMeTqyeYTIyGs84eT2eUc70vppxZqCHnFo9xBS3aDzk9PV4iFbGq4gdhyfq/3bPKDfeh2oV8gtDZiPp6ek+vmSO+eYnxy0VIrN0UPXbN3rhoG3HsqwvZHGKchJVlbnafcTe7lzVKTvarOuYnaWtotRp9VrjtrtaKNszjwonkh9uEuXET2aV96KlwRdWQMn9Ux5FH1hxtFjZD434QmlP7j3Y1780ubV/XiyaYLVPdXXdCrDXbEzxtdtPimUUw+K1D2slUZWQW7pbv4M0tKd7+rC/zmTXzNQB2+1rVPS2W2l2egfeJphtRcdWHdhiovFwazy0B7y/KnlIQouim43QQyJCTZ3wmyV0SGkNSWhRBbMROiYi1BTuvl1C/xw1FmUpG3lHROSZ6PLqyXup4hOSxKJOZCPxmIhEU9r6phRITlVRuLFRNSGiygT/v6gaQlVRSbFRdUJElSn+fJOhkZyyorRho+yUiDKTwH9d6nqZAkaj/tXBp17ibptHvbGNvX5Pv5xe7k+vzoujTEFpdR7U0nt9nFoI2qyb9oe6raE+rJhftlD32eapmCr532GrPwPbqjDgdOaybOBwalVSM5eeLasu8iPOCqHVjpZfF2Ek916eXE4u9YNl2heu9MY58x8fUrFOgn43mKciyUTE9O+BbFx8FsaztX4oy3h2/bBWl9aLsFbuHDFdT9QXwZM3n2a0weUmUWXJVpes7cKFFWuRrZ//EnVv0eagCgKJSCof0mHb+JD+DByQ1HVoWNwMCNVTiNuUbfYMZayshbWUGZvMTS8Pfjw1CaxhrjlMHk/G002YNbF32WzoujzaSH1A52weiCyfh9zupJZHJql6a3eNFtd5k/3jy+Mp1iMPLq4uLhzGrKoPVZF08/vy2/2nn87d7G7ru/qgBXtrbFJm1F2XZB0XH8Jo68kfve+msi5Ha2MAwnZPKZafsp//BwAA//8DAFBLAwQUAAYACAAAACEAzJJQVH0BAADxAgAAEQAIAWRvY1Byb3BzL2NvcmUueG1sIKIEASigAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAjJLLTsMwEEX3SPxD5H1qJ+WlKE3FQ6yoQKIViJ2xJ60hsS17IPTvcZI2JYgFO4/n+GRy7Xz+VVfRJzivjJ6RZMJIBFoYqfR6RlbL2/iCRB65lrwyGmZkC57Mi+OjXNhMGAcPzlhwqMBHwaR9JuyMbBBtRqkXG6i5nwRCh2ZpXM0xlG5NLRfvfA00ZeyM1oBccuS0FcZ2MJKdUopBaT9c1QmkoFBBDRo9TSYJPbAIrvZ/Hug6P8ha4dbCn+i+OdBfXg1g0zSTZtqhYf6EPi/uHrtfjZVusxJAilyKDBVWUOT0sAwr//H6BgL77aEIa+GAo3HFQglnvCkxui9LJSBaeXAdvSfa7N9h2xgnffCMqoBJ8MIpi+FG+6+MNgJdcY+LcMWlAnm1LS5Pz9OzTvOr0bIOPlX7NoqkI4Yy3wXdDwUyCgFlfZz7ztP0+mZ5S4qUpUnMTuIpW7I0O00zxl7auUbnD8J6N8A/jdOMnYyNe0EfzfiRFt8AAAD//wMAUEsDBBQABgAIAAAAIQAiURHx1QEAAN4DAAAQAAgBZG9jUHJvcHMvYXBwLnhtbCCiBAEooAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJxTwW7bMAy9D9g/GLo3crKh6AJFxZBi6GFDA8Rtz5xMJ8JsSZDYINnXj7YTT9l2mk/vkfTTE0mp+2PXFgeMyXq3EvNZKQp0xtfW7VbiufpycyeKROBqaL3DlThhEvf6/Tu1iT5gJIupYAmXVmJPFJZSJrPHDtKM044zjY8dENO4k75prMEHb946dCQXZXkr8UjoaqxvwiQoRsXlgf5XtPam95deqlNgPa0q7EILhJrOYFZ7Oio5xVXlCdrKdqjnJccnpjaww6TnSo5AvfpYJ724U3JEar2HCIa4h3p++0HJjKvPIbTWAHF39Tdrok++oeJpsFz0/yuZlyi+xhbNW7R00mwjp+qrdaOREbCxCLsIYX92NzG1NdDimhugG2gTKvk7oB4R+uFuwPb+DrQ8oCEfi2R/8ngXovgOCfu2rcQBogVHYiwbyYDbkCjqylLL2hMfYF6WY/uxNzmC68KBDB4YX7sbTkhPDd+N/mF2npsdPIxWMzu5s8sZf6iufRfAcX/lhLjBP9JzqPxDvxrnHl4Hs6m/WtpvA5h+OJ/KfP5ZRm05ijUPdJrJFFCPfIPY9vr8r9thfan5O9Fv1Mv4XHnbZiV/wwpdYrwI0zvSvwAAAP//AwBQSwMEFAAGAAgAAAAhAIg/pb/hAAAAVQEAABgAKABjdXN0b21YbWwvaXRlbVByb3BzMS54bWwgoiQAKKAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAnJDBasMwEETvhf6D2bsiObFdEyyHuE4g19JCroq8tgWWZCS5tJT+e2V6So89LbPDzhu2OnzoKXlH55U1HNINgwSNtJ0yA4e31zMpIfFBmE5M1iAHY+FQPz5Und93IggfrMNLQJ3EhYrz0nL4ykvW5E87Rsr2nJLilDXkmKUNKTKWt8fnU8pY8Q1JRJsY4zmMIcx7Sr0cUQu/sTOaaPbWaRGidAO1fa8ktlYuGk2g25hA5RLx+qonqNc+v9cv2Pt7uVZbnPov5aZuk7KDE/P4CbSu6B/Uqu9eUf8AAAD//wMAUEsDBBQABgAIAAAAIQDBJ8sItgAAACEBAAATACgAY3VzdG9tWG1sL2l0ZW0xLnhtbCCiJAAooCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACskE0OgjAQRq9CegCKLlgQfmKiWzEhcV/KAE3aGdIOBm5v1egJXE7mfS/zTdlsziYP8MEQVuKQZiIJrHBQlhAqgSSauuyLjlavISSRxlD0lZiZl0LKoGdwKqS0AMbdSN4pjqOfJI2j0XAmvTpAlscsy2Vvemto8mqZd/GR/UfVgQXNMHS823i2PN1Ondl4vgyGY7P2LWjRGoR0CzYGXuBVuQhHViT37wtyUZfyV7h+AgAA//8DAFBLAwQUAAYACAAAACEAdD85esIAAAAoAQAAHgAIAWN1c3RvbVhtbC9fcmVscy9pdGVtMS54bWwucmVscyCiBAEooAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIzPsYrDMAwG4P3g3sFob5zcUMoRp0spdDtKDroaR0lMY8tYamnfvuamK3ToKIn/+1G7vYVFXTGzp2igqWpQGB0NPk4Gfvv9agOKxcbBLhTRwB0Ztt3nR3vExUoJ8ewTq6JENjCLpG+t2c0YLFeUMJbLSDlYKWOedLLubCfUX3W91vm/Ad2TqQ6DgXwYGlD9PeE7No2jd7gjdwkY5UWFdhcWCqew/GQqjaq3eUIx4AXD36qpigm6a/XTf90DAAD//wMAUEsDBBQABgAIAAAAIQDrgGBMUwMAAI8OAAASAAAAd29yZC9mb250VGFibGUueG1szJbPb9MwFMfvSPwPUU7jwJqkXZdV66Y2WzQk2IEVAUc3cVqL2I7itF3/AA6IE+LI38C4gwb/DNPYf8FznLRZm25LQbBGzY9n+5vnT57f8+7+KQ21MY4F4aytm5uGrmHmcZ+wQVt/0XMf27omEsR8FHKG2/oUC31/7+GD3Ukr4CwRGoxnokW9tj5MkqhVqwlviCkSmzzCDBoDHlOUwGM8qFEUvxlFjz1OI5SQPglJMq1ZhtHUM5n4Lio8CIiHD7g3opgl6fhajENQ5EwMSSRytcld1CY89qOYe1gImDMNlR5FhM1kzMaSECVezAUPkk2YTOZRKgXDTSO9o+FcYKuagLUk0PTwaTUNO9OowciiDvGr6TRnOsQv6KznTEFA4GoSW7kfYkrljKjXejJgPEb9EJTgG2mAWUuF5Rm8lZf0FrrvZfGqTVoMURjwEj62DHKRNkWIcYFNaB2jsK0bW8bST6/Jjt4QxQJLmbRj40CZA0RJOM2tPvbAr4SMsWqNSOIN88Yxion0WTUJMoCGkegb8Fb1q+vKYsJyzN+tLNasT26pX7d4qY6tDGZmMQt94J01BWIJSI9QLLRjPNGec4pYKRYLjqZRBzwN+Ftw1yjFktO6jiVOdasQgaVoWB17e04km9syEfsmIoqH61Yj4qCQ9GOygoSbEpBHAzhYlUiICRGiEomOdNY6TGegSDSkwdjuVosN9bxTkcQBZoNXJAsKFCbHYM19vvz87vLrj2wyS5RMiBcIabhmRyklu1lGCY0SvgakbgFS3XbcbcftLEIym7dAknQrQnqWZy/tNTrCKmwWWF18P/t1/uXq09urbx9WEetCXMl4knGVnisQqx5X6XqyiivM6jhu3dmy1kFmVkS2kHO0jSOM0qSsOSePygAuJqmVDJsZvWyF/oUs5eMAjcLkxoQB+w8eovKSorzaWTNjUO7juMytgJxif/m7HsrSYamMN88XrjOzzPPFzu2Zs2q+OCH0ZFSaLS7O3v88/3gvskU2j0K5tWzbzadfOVv8WbnVNrrcn96PsGc86cUj3JtGeK1lkFcL7SkZDJPVNSNrvw+x8H8rR7bRKPAq226oovBvthuHEkenmD4caWmUbDfukD5u3XhlN2LvNwAAAP//AwBQSwECLQAUAAYACAAAACEAZPVj7oEBAAApBgAAEwAAAAAAAAAAAAAAAAAAAAAAW0NvbnRlbnRfVHlwZXNdLnhtbFBLAQItABQABgAIAAAAIQAekRq37wAAAE4CAAALAAAAAAAAAAAAAAAAALoDAABfcmVscy8ucmVsc1BLAQItABQABgAIAAAAIQAzwlu/QQEAAOcEAAAcAAAAAAAAAAAAAAAAANoGAAB3b3JkL19yZWxzL2RvY3VtZW50LnhtbC5yZWxzUEsBAi0AFAAGAAgAAAAhAE4yjpAWBgAApiQAABEAAAAAAAAAAAAAAAAAXQkAAHdvcmQvZG9jdW1lbnQueG1sUEsBAi0AFAAGAAgAAAAhALb0Z5jSBgAAySAAABUAAAAAAAAAAAAAAAAAog8AAHdvcmQvdGhlbWUvdGhlbWUxLnhtbFBLAQItABQABgAIAAAAIQDlI7CA9QMAAKALAAARAAAAAAAAAAAAAAAAAKcWAAB3b3JkL3NldHRpbmdzLnhtbFBLAQItABQABgAIAAAAIQBAwf/xOQEAACMDAAAUAAAAAAAAAAAAAAAAAMsaAAB3b3JkL3dlYlNldHRpbmdzLnhtbFBLAQItABQABgAIAAAAIQA520VMuQUAACdaAAASAAAAAAAAAAAAAAAAADYcAAB3b3JkL251bWJlcmluZy54bWxQSwECLQAUAAYACAAAACEA+JXI7/wOAADzmQAADwAAAAAAAAAAAAAAAAAfIgAAd29yZC9zdHlsZXMueG1sUEsBAi0AFAAGAAgAAAAhAMySUFR9AQAA8QIAABEAAAAAAAAAAAAAAAAASDEAAGRvY1Byb3BzL2NvcmUueG1sUEsBAi0AFAAGAAgAAAAhACJREfHVAQAA3gMAABAAAAAAAAAAAAAAAAAA/DMAAGRvY1Byb3BzL2FwcC54bWxQSwECLQAUAAYACAAAACEAiD+lv+EAAABVAQAAGAAAAAAAAAAAAAAAAAAHNwAAY3VzdG9tWG1sL2l0ZW1Qcm9wczEueG1sUEsBAi0AFAAGAAgAAAAhAMEnywi2AAAAIQEAABMAAAAAAAAAAAAAAAAARjgAAGN1c3RvbVhtbC9pdGVtMS54bWxQSwECLQAUAAYACAAAACEAdD85esIAAAAoAQAAHgAAAAAAAAAAAAAAAABVOQAAY3VzdG9tWG1sL19yZWxzL2l0ZW0xLnhtbC5yZWxzUEsBAi0AFAAGAAgAAAAhAOuAYExTAwAAjw4AABIAAAAAAAAAAAAAAAAAWzsAAHdvcmQvZm9udFRhYmxlLnhtbFBLBQYAAAAADwAPANQDAADePgAAAAA=",YG=()=>Dm(QG);async function JG(n){return new Promise((e,t)=>{const o=new Image;o.onload=()=>{e({width:o.naturalWidth,height:o.naturalHeight})},o.onerror=t,o.src=n})}async function wk(n,e){if(n.width&&n.height)return{width:n.width,height:n.height,buffer:e};const t=await Ul(new File([e],"",{})),o=await JG(t);return o.width===void 0||o.height===void 0?{width:345,height:230,buffer:e}:n.width||n.height?{width:n.width||o.width*n.height/o.height,height:n.height||o.height*n.width/o.width,buffer:e}:{width:o.width,height:o.height,buffer:e}}function KG(n,e){let t=n.filter(s=>s!=null);const o=e-(t.length-1)*20,r=.87,i=t.reduce((s,l)=>s+l.width,0);return i>o&&(t=t.map(s=>({width:s.width*o/i,height:s.height*o/i,buffer:s.buffer}))),t.map(s=>({width:s.width*r,height:s.height*r,buffer:s.buffer}))}function Bk(n=[0,1,2,3,4,5,6,7],e=1){return n.map(t=>{let o;switch(t%3){case 0:o=ge.LevelFormat.DECIMAL;break;case 1:o=ge.LevelFormat.LOWER_LETTER;break;default:o=ge.LevelFormat.LOWER_ROMAN;break}return{level:t,format:o,text:`%${t+1}. `,alignment:ge.AlignmentType.START,start:e,style:{paragraph:{indent:{left:ge.convertInchesToTwip(.3*(t+1)),hanging:ge.convertInchesToTwip(.2)}}}}})}function XG(){return[0,1,2,3,4,5,6,7].map(n=>{let e;switch(n%3){case 0:e="\u2022";break;case 1:e="\u25E6";break;default:e="\u25AA";break}return{level:n,format:ge.LevelFormat.BULLET,text:e,alignment:ge.AlignmentType.START,style:{paragraph:{indent:{left:ge.convertInchesToTwip(.3*(n+1)),hanging:ge.convertInchesToTwip(.2)}}}}})}function eZ(){return[0,1,2,3,4,5,6,7].map(n=>({level:n,format:ge.LevelFormat.BULLET,text:"\u2611",alignment:ge.AlignmentType.START,style:{paragraph:{indent:{left:ge.convertInchesToTwip(.3*(n+1)),hanging:ge.convertInchesToTwip(.2)}}}}))}function tZ(){return[0,1,2,3,4,5,6,7].map(n=>({level:n,format:ge.LevelFormat.BULLET,text:"\u2610",alignment:ge.AlignmentType.START,style:{paragraph:{indent:{left:ge.convertInchesToTwip(.3*(n+1)),hanging:ge.convertInchesToTwip(.2)}}}}))}var Hu=(n=>(n.NUMBERING="number-numbering-reference",n.BULLET="number-bullet-reference",n.CHECKED="checked-bullet-reference",n.UNCHECKED="unchecked-bullet-reference",n))(Hu||{});const nZ=[{levels:Bk(),reference:"number-numbering-reference"},{levels:XG(),reference:"number-bullet-reference"},{levels:eZ(),reference:"checked-bullet-reference"},{levels:tZ(),reference:"unchecked-bullet-reference"}];function oZ(n){switch(n){case"style-color-0":return"d83931";case"style-color-1":return"de7802";case"style-color-2":return"dc9b04";case"style-color-3":return"2ea121";case"style-color-4":return"245bdb";case"style-color-5":return"6425d0";case"style-color-6":return"8f959e";default:return}}function rZ(n){switch(n){case"style-bg-color-1":case"style-bg-color-2":case"style-bg-color-8":case"style-bg-color-9":return"yellow";case"style-bg-color-0":case"style-bg-color-5":return"magenta";case"style-bg-color-3":return"green";case"style-bg-color-4":case"style-bg-color-11":return"blue";case"style-bg-color-6":return"lightGray";case"style-bg-color-7":return"red";case"style-bg-color-10":return"darkGreen";case"style-bg-color-12":return"darkMagenta";case"style-bg-color-13":return"darkGray";default:return}}function iZ(n){switch(n){case"style-bg-color-0":return"fbbab6";case"style-bg-color-1":return"ffdcb0";case"style-bg-color-2":return"fff7a0";case"style-bg-color-3":return"ceefc5";case"style-bg-color-4":return"d1ddfb";case"style-bg-color-5":return"d9cbf8";case"style-bg-color-6":return"eaeaea";case"style-bg-color-7":return"fe837c";case"style-bg-color-8":return"ffbd6a";case"style-bg-color-9":return"ffe662";case"style-bg-color-10":return"a8f393";case"style-bg-color-11":return"98b5ff";case"style-bg-color-12":return"b394f8";case"style-bg-color-13":return"b1b1b1";default:return}}const sZ=/rgb\((\d+),\s*(\d+),\s*(\d+)\)/;function Ek(n){if(typeof n=="string"&&n.length>0){if(n[0]==="#")return n.substring(1);const e=n.match(sZ);if(e){const t=s=>{let l=Number(s).toString(16);return l.length<2&&(l=`0${l}`),l},o=t(e[1]),r=t(e[2]),i=t(e[3]);return`${o}${r}${i}`}if(n==="red")return"FF0000";if(n==="green")return"00FF00";if(n==="blue")return"0000FF"}}function en(n,e){if(n&&n.attributes&&n.attributes[e])return n.attributes[e];if(n&&n.attributes&&n.attributes.box&&n.attributes.inputType&&e==="style-underline")return!0}function xk(n,e,t){for(let o=0;o<=t;++o){const r=`${e}${o}`;if(en(n,r))return r}}function r1(n,e,t){n.attributes=n.attributes||{},n.attributes[e]=t}function Q2(n){return n==="image"||n==="drawio"||n==="plantuml"||n==="mermaid"||n==="flowchart"}function Ik(n){return n&&n.startsWith("//")?`https:${n}`:n&&!n.startsWith("http://")&&!n.startsWith("https://")?`https://${n}`:n}function lZ(n){const e=en(n,"inlineStyle");if(e==null)return;const t=e.split(";");for(const o of t){const r=o.split(":");if(r.length!==2)continue;const i=r[0].trim().toLowerCase(),s=r[1].trim().toLowerCase();i==="font-size"&&r1(n,"inline-style-font-size",s),i==="color"&&r1(n,"inline-style-color",s),i==="background-color"&&r1(n,"inline-style-background-color",s),i==="font-family"&&r1(n,"inline-style-font-family",s)}}function cZ(n,e){if(e==null)return n==null?void 0:n.normal;if(n)return n[`heading${e}`]}function aZ(n){const e=`${en(n,"inline-style-font-size")}`;if(e&&e.indexOf("px")>0)return+e.replace(/px/g,"")}function uZ(n){if(n.attributes&&n.attributes.box&&n.attributes.text)return` ${n.attributes.text} `;if(n.attributes&&n.attributes.box&&n.attributes.inputType)return n.attributes.value?`${n.attributes.value}`:" "}function dZ(n){if(n.attributes&&n.attributes.box&&n.attributes.text)return` @${n.attributes.text} `}function hZ(n){return en(n,"inline-style-font-family")}function fZ(n){const e=en(n,"inline-style-background-color");return Ek(e)}function mZ(n){const e=en(n,"inline-style-color");return Ek(e)}function gZ(n){lZ(n);const e=en(n,"type")==="mention";return{box:n.attributes&&n.attributes.box?n.attributes:void 0,inlineCode:!!en(n,"style-code"),link:Ik(en(n,"link")),size:aZ(n),text:e?dZ(n):uZ(n)||n.insert,bold:!!en(n,"style-bold"),underline:!!en(n,"style-underline"),italics:!!en(n,"style-italic"),strike:!!en(n,"style-strikethrough"),superScript:!!en(n,"style-super"),subScript:!!en(n,"style-sub"),math:en(n,"type")==="math"?en(n,"src"):void 0,mention:e,fontFamily:hZ(n),background:fZ(n),color:e?"338fe5":oZ(xk(n,"style-color-",6))||mZ(n),highlight:xk(n,"style-bg-color-",13)}}function pZ(){return[new ge.Paragraph({border:{top:{color:"auto",style:ge.BorderStyle.DASHED,size:4,space:1}},spacing:{before:300}}),new ge.Paragraph({spacing:{line:0}})]}function CZ(){return new ge.Paragraph({children:[new ge.TextRun({text:"[\u89C6\u9891\u6682\u4E0D\u652F\u6301\u5BFC\u51FA]",shading:{type:ge.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}})]})}function AZ(){return new ge.Paragraph({children:[new ge.TextRun({text:"[\u97F3\u9891\u6682\u4E0D\u652F\u6301\u5BFC\u51FA]",shading:{type:ge.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}})]})}function bZ(n,e){return new ge.Paragraph({children:[new ge.ExternalHyperlink({children:[new ge.TextRun({style:"Hyperlink",text:e||n})],link:n})]})}function Tk(n){if(n.heading!=null)return`Heading${n.heading}`}function Dk(n){if(n.alignment!=null){if(n.alignment==="center")return ge.AlignmentType.CENTER;if(n.alignment==="right")return ge.AlignmentType.RIGHT;if(n.alignment==="left")return ge.AlignmentType.LEFT}}function vZ(n){if(n.indent)return{left:ge.convertInchesToTwip(.3*n.indent-.2)};if(n.padding)return{left:ge.convertInchesToTwip(.3*n.padding)}}function yZ(n){return{type:ge.ShadingType.CLEAR,color:"FFFFFF",fill:n}}function kZ(n){const e=n.split(",");if(e.length!==0)return e[0].trim()}function Sk(n,e){let t;t=n.inlineCode?"InlineCode":void 0,t=n.link?"Hyperlink":t;const o=n.size||e,r=o!=null?Math.floor(o*1.5+.5):void 0;return new ge.TextRun({text:n.text,bold:n.bold||void 0,underline:n.underline?{type:ge.UnderlineType.SINGLE}:void 0,italics:n.italics||void 0,strike:n.strike||void 0,superScript:n.superScript||void 0,subScript:n.subScript||void 0,size:r,style:t,font:n.fontFamily?kZ(n.fontFamily):void 0,shading:n.background?yZ(n.background):void 0,color:n.color,highlight:rZ(n.highlight)})}function wZ(n,e){if(n.link)return new ge.ExternalHyperlink({children:[Sk(n,e)],link:n.link})}async function Lk(n,e,t,o,r){const i=await r(n,e,t);if(i==null)return;const s=await wk({width:o||0,height:0,src:t},i);return new ge.ImageRun({data:i,transformation:{width:s.width||100,height:s.height||20}})}function BZ(n){if(n.heading||n.heading)return n.heading}function EZ(n){if(n.align&&(n.align==="center"||n.align==="right"||n.align==="left"))return n.align}function xZ(n){if(n.textOnly===!0&&n.level!=null)return n.level}async function IZ(n,e){var o;const t=[];if(n.text&&Array.isArray(n.text)){for(let r=0;r<n.text.length;r++){const i=n.text[r];if(((o=i.attributes)==null?void 0:o.box)===!0&&e){const s=await e(i);if(s){n.text.splice(r+1,0,...s);continue}}t.push(gZ(i))}return t}}function TZ(n){if(n.type==="list"&&n.textOnly!==!0)return{checkbox:n.checkbox,groupId:n.groupId,ordered:!!n.ordered,level:n.level||1,start:n.start||0}}function DZ(n,e){if(n.type==="embed"&&n.embedType&&Q2(n.embedType)&&n.embedData&&n.embedData.src)return n.embedData.src.split("|").map(o=>{const r=e(o),i=n.embedData[`${r}_width`],s=n.embedData[`${r}_height`];return{src:o,width:i,height:s}})}function SZ(n){if(n.padding)return n.padding}function LZ(n){return!!(n.type==="embed"&&n.embedType&&Q2(n.embedType)&&n.embedData&&n.embedData.src)}async function i1(n,e,t){return{quoted:!!n.quoted,heading:BZ(n),alignment:EZ(n),indent:xZ(n),padding:SZ(n),texts:await IZ(n,t),list:TZ(n),images:DZ(n,e),border:LZ(n)}}async function MZ(n,e,t,o){const r=[];if(!n.children)return[];for(const i of n.children){const s=[];for(const l of e.blocks[i])s.push(await i1(l,t,o));r.push(s)}return r}const RZ=S("to-docx");function OZ(n,e){return Array(n).fill(0).map(()=>Array(e).fill(0).map(()=>({cellId:void 0,color:void 0,from:void 0,rowSpan:1,colSpan:1,width:0,originalWidth:void 0,align:void 0})))}function _Z(n,e,t,o){const r=!!n.hasColTitle,i=!!n.hasRowTitle,s=!!n.isStripeStyle,l="F5F8FB";for(let a=0;a<e;a++)for(let d=0;d<t;d++)(r&&d===0||i&&a===0||s&&a%2===1)&&(o[a][d].color=l)}function FZ(n){g(RZ,n.children,"no table children");const e=n.rows,t=n.cols,o=n.colsWidth;if(o)for(let s=0;s<o.length;s++)o[s]===0&&(o[s]=100);const r=OZ(e,t);let i=0;for(let s=0;s<e;++s)for(let l=0;l<t;++l){if(r[s][l].originalWidth=o?o[l]:void 0,r[s][l].from!==void 0)continue;const a=n.children[i];i+=1,r[s][l].cellId=a,r[s][l].color=iZ(n[`${a}_background`]),r[s][l].width=o?o[l]:100,r[s][l].align=n[`${a}_align`];const d=n[`${a}_rowSpan`]||1,h=n[`${a}_colSpan`]||1;if(r[s][l].rowSpan=d,r[s][l].colSpan=h,d>1||h>1){let p=0;for(let A=0;A<d;A++)for(let v=0;v<h;v++)A===0&&(p+=o?o[l+v]:80),!(A===0&&v===0)&&(r[s+A][l+v].from=[s,l]);r[s][l].width=p}}return _Z(n,e,t,r),r}async function PZ(n,e,t,o,r,i,s,l,a,d){async function h(v){if(l){const B=await l(r,i,v);if(B){await o.addDoc(n,B,d);return}}if(v.type==="text"||v.textOnly===!0){const B=await i1(v,s,a);await o.addTextBlock(B);return}if(v.type==="code"){const B=await MZ(v,t,s,a);await o.addCodeBlockObject(B);return}if(v.type==="list"&&v.textOnly!==!0){const B=await i1(v,s,a);await o.addListBlockObject(n,B);return}if(v.type==="embed"&&v.embedType){const B=v,D=B.embedData,I=B.embedType;if(Q2(I)){const _=await i1(v,s,a);await o.addImagesBlockObject(v,_,d)}else v.embedType==="hr"?o.addSeparatorBlock():v.embedType==="video"?o.addVideoPlaceholder():v.embedType==="audio"?o.addAudioPlaceholder():v.embedType==="webpage"?o.addHyperlinkParagraph(Ik(D.src),D.title):o.addOtherEmbedBlock(I,v.embedData);return}if(v.type==="table"){let B=[];if(v.colsWidth)B=v.colsWidth;else{const I=v.cols;B=new Array(I);for(let _=0;_<B.length;_++)B[_]=100;v.colsWidth=B}const D=FZ(v);await o.addTableMatrix(B,D,t),o.addEmptyParagraph()}}function p(v){const B=[];for(const{type:D,data:I}of v.embedData.exportSpec){if(D==="text"){const _={id:K(),text:[{insert:I}],type:"text"};B.push(_);continue}if(D==="image"){const _={id:K(),type:"embed",embedType:"image",align:"left",embedData:{src:I}};B.push(_);continue}if(D==="link"){const _={id:K(),type:"embed",embedType:"webpage",embedData:{src:I.url,title:I.title}};B.push(_);continue}}return B}function A(v){var B;return(B=v==null?void 0:v.embedData)!=null&&B.exportSpec?p(v):[v]}for(const v of e)for(const B of A(v))await h(B)}function NZ(){return{listMaxInst:1,listInstMap:{},listRefMap:{},levelConfigs:[]}}const $Z=S("to-docx");class HZ{constructor(e,t,o,r,i,s){m(this,"paragraphs");this.appId=e,this.docId=t,this.state=o,this.readImageFunc=r,this.convertBlocksFunc=i,this.defaultFontSize=s,this.paragraphs=[]}async addTextBlock(e){this.paragraphs.push(new ge.Paragraph({heading:Tk(e),alignment:Dk(e),children:await this.paragraphsFromBlockTexts(e),indent:vZ(e)}))}async addEmptyImagePlaceHolder(){this.paragraphs.push(new ge.Paragraph({text:`[${R.t("docx.imageExportFailed")}]`,shading:{type:ge.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}}))}async paragraphsFromBlockTexts(e){if(e.texts==null)return;const t=cZ(this.defaultFontSize,e.heading),o=[];for(const r of e.texts){if(r.link){const i=wZ(r,t);i&&o.push(i);continue}if(r.box&&r.box.type&&r.box.type==="br"){o.push(new ge.TextRun({text:"",break:1}));continue}if(r.box&&r.box.type&&r.box.type==="image"){const i=await Lk(this.appId,this.docId,r.box.src,r.box.width,this.readImageFunc);i&&o.push(i);continue}if(r.math){const i=await Lk(this.appId,this.docId,r.math,0,this.readImageFunc);i&&o.push(i);continue}o.push(Sk(r,t))}return o}async addCodeBlockObject(e){for(const t of e)for(const o of t){const r={style:ge.BorderStyle.SINGLE,color:"#DEDEDE"};this.paragraphs.push(new ge.Paragraph({style:"Code",border:{left:{...r},right:{...r},top:{...r},bottom:{...r}},children:await this.paragraphsFromBlockTexts(o)}))}}async addListBlockObject(e,t){if(t.list==null)return;let o;const r=t.list.checkbox?`${e}-${t.list.groupId}-${t.list.checkbox}`:`${e}-${t.list.groupId}`;if(this.state.listInstMap[r])o=this.state.listInstMap[r];else if(o=this.state.listMaxInst,this.state.listMaxInst+=1,this.state.listInstMap[r]=o,t.list.start>0&&t.list.ordered){const s=`number-numbering-reference-${o}`,l=Bk([t.list.level-1],t.list.start);this.state.levelConfigs.push({levels:l,reference:s,inst:o}),this.state.listRefMap[r]=s}else t.list.ordered?this.state.listRefMap[r]=Hu.NUMBERING:t.list.checkbox&&t.list.checkbox==="checked"?this.state.listRefMap[r]=Hu.CHECKED:t.list.checkbox&&t.list.checkbox==="unchecked"?this.state.listRefMap[r]=Hu.UNCHECKED:this.state.listRefMap[r]=Hu.BULLET;const i=Tk(t);t.texts&&this.paragraphs.push(new ge.Paragraph({heading:i,children:await this.paragraphsFromBlockTexts(t),numbering:{reference:this.state.listRefMap[r],level:t.list.level-1,instance:o}}))}imageDimWithBufferToImageRun(e){return new ge.ImageRun({data:e.buffer,transformation:{width:e.width,height:e.height}})}async addImagesBlockObject(e,t,o){if(t.images==null){if(e.type==="embed"&&e.embedType==="image"){const{src:a}=e.embedData;a||this.addEmptyImagePlaceHolder()}return}const r=[],i=await Promise.all(t.images.map(async a=>{const d=await this.readImageFunc(this.appId,this.docId,a.src);if(d)return wk(a,d);r.push(a.src)})),s=KG(i,o),l={style:ge.BorderStyle.SINGLE,color:"#DEDEDE"};s.length&&this.paragraphs.push(new ge.Paragraph({border:t.border?{left:{...l},right:{...l},top:{...l},bottom:{...l}}:void 0,alignment:Dk(t)||ge.AlignmentType.CENTER,children:s.map(a=>this.imageDimWithBufferToImageRun(a)).flatMap((a,d,h)=>a==null?[]:h.length-1!==d?[a,new ge.TextRun({text:" "})]:a)})),r.forEach(a=>{this.addHyperlinkParagraph(a)})}addSeparatorBlock(){pZ().forEach(e=>this.paragraphs.push(e))}addEmptyParagraph(){this.paragraphs.push(new ge.Paragraph(""))}addVideoPlaceholder(){this.paragraphs.push(CZ())}addAudioPlaceholder(){this.paragraphs.push(AZ())}addHyperlinkParagraph(e,t){e!=null&&this.paragraphs.push(bZ(e,t))}async addTableMatrix(e,t,o){const r=e.map(i=>i!==0?i*15:1500);this.paragraphs.push(new ge.Table({rows:await this.generateTableRows(t,o),columnWidths:r}))}async generateRowCells(e,t){const o=[];for(const r of e){const i=r.cellId;if(i===void 0)continue;const s=r.width*.9;o.push(new ge.TableCell({children:await this.convertBlocksFunc(i,t.blocks[i],t,this.appId,this.docId,this.state,s),columnSpan:r.colSpan,rowSpan:r.rowSpan,width:{type:ge.WidthType.DXA,size:r.width*15},shading:r.color?{fill:r.color,type:ge.ShadingType.CLEAR,color:"auto"}:void 0}))}return o}async generateTableRows(e,t){const o=[];for(const r of e)o.push(new ge.TableRow({children:await this.generateRowCells(r,t)}));return o}async addDoc(e,t,o){const r=await this.convertBlocksFunc(e,t.blocks.root,t,this.appId,this.docId,this.state,o);r&&(this.paragraphs=this.paragraphs.concat(r))}async addOtherEmbedBlock(){}}class jZ{constructor(e,t,o,r,i,s,l,a){m(this,"convertBlocks",async(e,t,o,r,i,s,l=720)=>{const a=new HZ(r,i,s,this.readImage,this.convertBlocks,this.defaultFontSize);return await PZ(e,t,o,a,r,i,this.md5HexFunc,this.getDocByBlock,this.getTextsByBox,l||720),a.paragraphs});this.templateData=e,this.docData=t,this.md5HexFunc=o,this.readImage=r,this.defaultFontSize=i,this.getDocByBlock=s,this.getTextsByBox=l,this.backgroundImageOptions=a}async convert(e,t){return this.snapshot2docx(this.docData,e,t)}async snapshot2docx(e,t,o){const r=new ge.ImportDotx,i=this.templateData?await r.extract(this.templateData):void 0,s=e.blocks.root;g($Z,s,"data must have blocks");const l=NZ(),a=await this.convertBlocks("blocks",s,e,t,o,l),d=this.backgroundImageOptions?{default:new ge.Header({children:[new ge.Paragraph({children:[new ge.ImageRun(this.backgroundImageOptions)]})]})}:{},h=new ge.Document({numbering:{config:[...nZ,...l.levelConfigs]},sections:[{headers:d,children:a,properties:{page:{size:{width:12240,height:15840},margin:{top:1440,bottom:1440,left:1440,right:1440}}}}]},{template:i});return ge.Packer.toBlob(h)}}async function UZ(n,e,t,o){const r=n.doc.buildResourceUrl(o,{withToken:!0});let i=await p7(r);if(!i)return;if(i.type.indexOf("/svg")!==-1){const l=await f7(i);l&&(i=new File([l],i.name))}return await i.arrayBuffer()}async function zZ(n,e,t){const o=n.editorBlocks.getBlockClass(t.type);if(o.toStandardDoc)return o.toStandardDoc(n,t,e)}async function VZ(n,e){const t=e.attributes,o=n.editorBoxes.getBoxClass(t.type);if(o.toStandardText)return o.toStandardText(n,t)}async function WZ(n,e){let{template:t,download:o,backgroundImageOptions:r}=e!=null?e:{};t||(t=YG());const i=n.doc.toJSON(),s=(p,A,v)=>UZ(n,p,A,v),l=async(p,A,v)=>zZ(n,i,v),a=async p=>VZ(n,p),h=await new jZ(t,i,Pd.default,s,void 0,l,a,r).convert("_appId","_docId");if(o){const p=URL.createObjectURL(h),A=document.createElement("a");A.setAttribute("download",`${g7(n)}.docx`),A.setAttribute("href",`${p}`),A.click(),A.remove()}return h}const Y2=S("create-editor");async function qZ(n,e){var s,l,a,d,h,p,A,v,B,D,I,_,M,H;g(Y2,n,"app does not exists"),e.lang&&R.setLang(e.lang),Ii.level=(s=e.logLevel)!=null?s:ha.DEBUG;const t=e.onReauth?async()=>{var fe;const z=e.user.userId,q=e.docId,re=await((fe=e.onReauth)==null?void 0:fe.call(e,z,q,e.permission));return{userId:z,docId:q,permission:e.permission,appId:e.appId,token:re,displayName:e.user.displayName,avatarUrl:e.user.avatarUrl}}:void 0,o={auth:{appId:e.appId,docId:e.docId,userId:e.user.userId,permission:e.permission,token:e.token,displayName:e.user.displayName,avatarUrl:e.user.avatarUrl},serverUrl:e.serverUrl,reauthFunc:t,disableLogout:e.disableLogout},r=await Ka.load(o),i=Ha(n,r,{id:e.id,scrollContainer:e==null?void 0:e.scrollContainer,enableComments:e==null?void 0:e.enableComments,components:{blocks:[...bk,...((l=e==null?void 0:e.components)==null?void 0:l.blocks)||[]],embeds:[...Z2,...((a=e.components)==null?void 0:a.embeds)||[]],boxes:[...vk,...((d=e.components)==null?void 0:d.boxes)||[]],commandProviders:[new Gp,...((h=e.components)==null?void 0:h.commandProviders)||[]],decorators:[new Lf,new yp],insertions:[wg],blockHooks:[new t2,new W7,...((p=e.components)==null?void 0:p.blockHooks)||[]],textRenders:[new o8,new C0],options:{...e.componentsOptions}},shortcuts:[vz,DN,CH,O0,Ry,LO,S0,nV,Lh,...e.shortcuts||[]],colors:["#338FE5","#24B47E","#F0A100","#E52727","#9678D3","#2CB2AE","#EB6414","#8AAB3F"]});if(i.editorCommandProviders.registerCommandProvider(new Ar(i)),i.input.addHandler(new qV),i.input.addHandler(new If),i.input.addHandler(new Q_),i.input.addHandler(new hH),i.input.addHandler(new bu(i,{headingLevel:1,titlePlaceholder:R.t("placeholder.common.title"),contentPlaceholder:R.t("placeholder.common.content"),readonlyTitlePlaceholder:R.t("placeholder.common.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0})),i.input.addHandler(new Af(i,(A=e.componentsOptions)==null?void 0:A.quickMenu)),i.input.addHandler(new c2(i)),i.input.addHandler(new f2(i)),i.input.addHandler(new EN),i.input.addHandler(new Ff),i.doc.registerCallback(new GV(i)),i.addCustom("remote-cursor",()=>new Qb(i)),i.addCustom("block-menu",z=>new Z7(z)),i.addCustom("editor-tooltip",()=>new bf(i)),e!=null&&e.enableComments&&i.addCustom("editor-comments",z=>new n8(z,new VG(z))),i.addCustom("create-options",()=>new J5(i,e)),i.addCustom("drop-target",()=>new Su(i)),i.addCustom("list-to-mindmap",()=>new hf(i)),i.addCustom("list-to-mention",()=>new fW(i)),i.addCustom("mobile-helper",()=>new SW(i)),i.addCustom("code-caret",()=>new BN(i)),i.addCustom("image-paste-handler",()=>new l2(i)),(v=e.componentsOptions)!=null&&v.mention){const z=e.componentsOptions.mention;i.addCustom("mention",()=>new _2(i,z))}if(i.addCustom("heading-collapse",()=>new F8(i)),pc.register(i),Su.register(i),nl.register(i),Xi.register(i),i.addListener("clickLink",(z,q,re)=>{var Be;if((Be=e==null?void 0:e.events)!=null&&Be.onClickLink){e.events.onClickLink(z,q,re);return}const fe=re.getAttribute("link");fe&&(z.readonly||q.ctrlKey||q.metaKey)&&window.open(fe,"_blank")}),(D=(B=e.componentsOptions)==null?void 0:B.remoteCarets)!=null&&D.onUserChanged){const z=(_=(I=e.componentsOptions)==null?void 0:I.remoteCarets)==null?void 0:_.onUserChanged;i.doc.getRemoteUsers().on("change",q=>{z(i,q)})}return(H=(M=e.componentsOptions)==null?void 0:M.templates)!=null&&H.templates.length&&(i.addListener("docChanged",()=>{o1(i)}),i.addListener("resize",()=>{o1(i,{reset:!0})}),setTimeout(()=>{o1(i)},100)),i.doc.registerCallback({onError:async z=>{if(z.code==="ResetDoc"){Y2.error(`reset doc: ${z.message}`);const q=await Ka.load(o);i.doc.reset(q)}}}),i}function GZ(n){return n.toJSON!==void 0}async function ZZ(n,e,t){var i,s,l,a,d;g(Y2,n,"app does not exists");const o=GZ(e)?e:new np(e,{serverUrl:t.serverUrl||""});t.lang&&R.setLang(t.lang);const r=Ha(n,o,{id:t.id,scrollContainer:t==null?void 0:t.scrollContainer,components:{blocks:[xf,Sf,U0,E9],commandProviders:[new Gp],decorators:[new Lf,new yp],embeds:[...Z2,...((i=t.components)==null?void 0:i.embeds)||[]],boxes:[T0,F2,u8,...((s=t.components)==null?void 0:s.boxes)||[]],insertions:[wg],blockHooks:[new t2,...((l=t.components)==null?void 0:l.blockHooks)||[]],textRenders:[new o8,new C0,...((a=t.components)==null?void 0:a.textRenders)||[]],options:{...t.componentsOptions}},shortcuts:[O0,Ry,S0,Lh]});return r.editorCommandProviders.registerCommandProvider(new Ar(r)),r.input.addHandler(new If),r.input.addHandler(new bu(r,{headingLevel:1,titlePlaceholder:R.t("placeholder.common.title"),contentPlaceholder:R.t("placeholder.common.content"),readonlyTitlePlaceholder:R.t("placeholder.local.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0})),r.input.addHandler(new Af(r,(d=t.componentsOptions)==null?void 0:d.quickMenu)),r.input.addHandler(new c2(r)),r.input.addHandler(new f2(r)),r.input.addHandler(new Ff),r.addCustom("block-menu",h=>new Z7(h)),r.addCustom("editor-tooltip",()=>new bf(r)),r.addCustom("image-paste-handler",()=>new l2(r)),t!=null&&t.enableComments&&r.addCustom("editor-comments",h=>new n8(h,new WG(h,o))),r.addListener("clickLink",(h,p,A)=>{var B;if((B=t==null?void 0:t.events)!=null&&B.onClickLink){t.events.onClickLink(h,p,A);return}const v=A.getAttribute("link");v&&(h.readonly||p.ctrlKey||p.metaKey)&&window.open(v,"_blank")}),pc.register(r),r}function QZ(n,e){var a;const t=n.doc;if(!((a=t.getVersionHelper)==null?void 0:a.call(t)))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 yk(i),l=n.addCustom("version-dialog",()=>new I8(n.doc,s));return l.show(e),l}b.tippy=zB,b.AnchorBox=A6,b.AuthError=Vh,b.AuthHeader=Ja,b.AutoScroll=Zd,b.BaseURLHeader=Wh,b.BasicCommands=y_,b.BlockExclusiveHook=W7,b.BlockLockerHook=t2,b.BlockLockerPasteHandler=Ff,b.BlockResizer=wu,b.BrBox=m6,b.CodeBlock=Sf,b.CodeLineBlock=U0,b.CodeTextDecorator=Lf,b.DefaultShortcuts=Lh,b.DocIdError=zS,b.DragDrop=dC,b.DrawioEmbed=z2,b.EditorBlocks=v4,b.EditorBoxes=p6,b.EditorCommandProviders=lb,b.EditorComplexBlockPosition=So,b.EditorComplexSelectionRange=or,b.EditorDecorators=k6,b.EditorEmbeds=k4,b.EditorInsertions=y6,b.EditorSimpleBlockPosition=jt,b.EditorSimpleSelectionRange=Zt,b.EmbedBlock=B4,b.EmbedBlockResizer=Fu,b.EnforceWithDocumentTitleHandler=bu,b.EventCallbacks=fa,b.FILL_CHAR=hI,b.FileExtError=VS,b.GroupOrder=D9,b.HeadingBlockScrollListener=lW,b.ImageBox=C6,b.InlineBoxCommandProvider=P9,b.InputtingInsertion=b6,b.LocalDoc=np,b.LogLevel=ha,b.Logger=Ii,b.MIN_DISTANCE_THRESHOLD=aC,b.ManualCloseDialog=ru,b.ManualMenu=zs,b.ManualToolbar=ou,b.MarkdownInputHandler=If,b.MaxUserError=mp,b.Mindmap=f0,b.OnesEditorAutoSuggest=Np,b.OnesEditorCustomDataWrapper=J5,b.OnesEditorExclusiveBlock=Xi,b.OnesEditorHoveringBlock=pt,b.OnesEditorQuickMenu=Af,b.OnesEditorToc=Pu,b.OnesEditorTocProvider=nl,b.OnesEditorToolbar=pc,b.OnesEditorTooltip=bf,b.OnesEditorVersionsDialog=I8,b.PermissionError=US,b.Popup=Xa,b.RemoteCarets=Qb,b.RemoteCaretsDecorator=yp,b.RemoteCaretsInsertion=wg,b.RemoteUsers=Fh,b.RequestReloadError=Ya,b.RichText=ln,b.ShareDBDoc=Ka,b.ShareDBDocVersionsProvider=yk,b.SimpleCache=X5,b.StandardEmbedBlockCommands=I2,b.TEXT_STYLE_BACKGROUND_COLOR_PREFIX=fg,b.TEXT_STYLE_COLOR_PREFIX=hg,b.TableBlock=xf,b.TableBlockCommandProvider=Gp,b.TableShortcuts=O0,b.TextBlock=In,b.TextBox=f6,b.TextStyleShortcuts=S0,b.TocEmbed=j8,b.ZERO_WIDTH_SPACE_CHAR=ma,b.abbreviation=Qd,b.addAttribute=dh,b.addClass=W,b.addCommentToBlock=Xf,b.addDays=ME,b.addMetaToDoc=Rh,b.addMonths=LE,b.animateScrollTo=km,b.applyPlaceholderToBlock=Tf,b.assert=g,b.autoShowHideTemplates=o1,b.blockToDoc=Kg,b.blockToHtml=Ig,b.blockToMarkdown=Tg,b.blockToText=bh,b.blocksToDoc=ST,b.clearAllSelection=t4,b.clientType=Kt,b.cloneBlock=Fi,b.cloneChildContainer=Ng,b.cloneDoc=$g,b.cloneText=o6,b.commentToShareDbComment=vp,b.compareElement=jd,b.comparePosition=Xm,b.complexBlockAdjustSelectionPos=oh,b.complexBlockFindNearestChildBlock=T4,b.complexBlockGeFirstSimpleChild=tg,b.complexBlockGetAllChildContainers=En,b.complexBlockGetBottomChildContainers=I4,b.complexBlockGetLastSimpleChild=Vl,b.complexBlockGetSelectedContainers=Os,b.complexBlockGetTopChildContainers=x4,b.containerToDoc=PA,b.continuousScroll=DC,b.convertBlockFrom=Xd,b.convertImageFileToPng=f7,b.convertImageSrcToPng=GP,b.copyBlockAttributes=_6,b.createBlockAnchor=Li,b.createBlockCaretAnchor=M4,b.createBlockContentElement=Ts,b.createBlockElement=VC,b.createBlockSimpleDocRange=gh,b.createBlockSimpleRange=yt,b.createBoxContentElement=GC,b.createBoxElement=WC,b.createBoxOp=Z4,b.createChildContainer=A4,b.createComplexBlockPosition=ft,b.createComplexDocPos=a6,b.createComplexDocRange=gI,b.createContainer=s6,b.createContainerElement=Gm,b.createDeleteOps=V4,b.createEditor=Ha,b.createEditorSelectionRange=Ut,b.createElement=w,b.createEmptyContainer=zr,b.createEmptyDoc=Ur,b.createEmptyTextBlockData=fh,b.createExpandedRange=$d,b.createIconButton=Hl,b.createImage=pm,b.createInsertOps=ah,b.createInsertionContentElement=YC,b.createInsertionElement=ZC,b.createLocalEditor=ZZ,b.createOnesEditor=qZ,b.createRange=eC,b.createRichText=Oi,b.createRootContainer=C4,b.createSimpleBlockPosition=se,b.createSimpleDocPos=c6,b.createTextBlockData=sr,b.createTextButton=Qs,b.createTextOp=lo,b.createTextWithReplaceSoftReturn=ag,b.daysAfter=Rm,b.deleteText=dg,b.diffDays=RE,b.disablePageScroll=wC,b.docToHtml=S6,b.docToHtmlFragment=vh,b.docToMarkdown=Ma,b.docToText=La,b.downloadImageToFile=p7,b.downloadObjectToFile=H2,b.downloadSvgToString=Q8,b.editLink=fu,b.editorAddComment=rz,b.editorAddTextAttribute=q6,b.editorAutoInsertBlock=F6,b.editorBreakTextBlock=Yl,b.editorClearCompositionText=O6,b.editorClearSelectedContents=Fg,b.editorCopyBlock=Oh,b.editorDeleteBlock=Og,b.editorDeleteBlockText=Mg,b.editorDeleteBlockWithoutChildren=wh,b.editorDeleteChildContainer=aT,b.editorDeleteChildContainers=P6,b.editorFocusToBlock=Pg,b.editorFocusToEnd=_A,b.editorGetBlockData=_i,b.editorGetBlockText=mn,b.editorGetBlockTextEx=Ch,b.editorGetBoxData=d6,b.editorHandleKeyboardEvent=jA,b.editorInsertBlock=Ql,b.editorInsertBoxToBlock=M6,b.editorInsertDoc=V6,b.editorInsertDocAt=Hg,b.editorInsertText=Lg,b.editorInsertTextToBlock=L6,b.editorInsertTextToBlockEx=Sg,b.editorMergeTextBlock=N6,b.editorMoveDown=rA,b.editorMoveEnd=mA,b.editorMoveHome=gA,b.editorMoveLeft=tA,b.editorMoveLineEnd=wA,b.editorMoveLineHome=kA,b.editorMovePageDown=DA,b.editorMovePageUp=TA,b.editorMoveRight=nA,b.editorMoveUp=oA,b.editorMoveWordEnd=dA,b.editorMoveWordLeft=uA,b.editorRangeClearColor=Z6,b.editorRangeGetColor=jg,b.editorRangeSetColor=G6,b.editorRemoveTextAttribute=fT,b.editorReplaceBlockText=Eh,b.editorReplaceContainer=W6,b.editorRunOnce=op,b.editorSelectAll=OA,b.editorSelectContainer=Yg,b.editorSelectDown=iA,b.editorSelectEnd=Zg,b.editorSelectHome=pA,b.editorSelectLeft=sA,b.editorSelectLineEnd=yA,b.editorSelectLineHome=vA,b.editorSelectPageDown=LA,b.editorSelectPageUp=SA,b.editorSelectRight=lA,b.editorSelectUp=cA,b.editorSelectWordEnd=fA,b.editorSelectWordLeft=hA,b.editorSetTextColor=Jl,b.editorShowFindDialog=dU,b.editorToDocx=WZ,b.editorUpdateBlockData=xh,b.editorUpdateCompositionText=R6,b.editorUpdateEmbedData=U6,b.enablePageScroll=BC,b.escapeHtmlText=sC,b.escapeRegExp=Pm,b.escapeSpace=gE,b.exclusiveBlock=K0,b.executeBlockCommand=u4,b.executeEmbedBlockCommand=a4,b.executeRangeCommand=sb,b.fileToDataUrl=Ul,b.findAfterOffsetNotType=vg,b.findAllText=Cg,b.findEventTargetBlock=rC,b.findInsertionById=QC,b.findNextOffset=MI,b.findNextVisibleSimpleBlock=hb,b.findPrevOffset=LI,b.findPrevOffsetNotType=bg,b.findPrevSimpleBlockBeforeChildContainer=E4,b.findPrevVisibleSimpleBlock=db,b.findTarget=jl,b.findWordEnd=kg,b.findWordLeft=yg,b.format=ba,b.formatBytes=SC,b.formatDate=_m,b.fragmentToHtml=EC,b.fromBase64=zd,b.fromBase64ToBlob=Dm,b.fromBase64ToUint8Array=xE,b.fromDocRange=Si,b.fromNowString=Fm,b.genId=K,b.getAllChildBlocks=og,b.getAllQuickMenuItems=D0,b.getAllSelectedBlocks=Lo,b.getAttributesAt=Ta,b.getBlockBackground=zC,b.getBlockByIndex=_r,b.getBlockCaretRect=To,b.getBlockClass=Qe,b.getBlockClassByType=Ms,b.getBlockClientRects=Ti,b.getBlockCommandsWithHook=Wm,b.getBlockContent=Re,b.getBlockId=ie,b.getBlockIndex=be,b.getBlockInfo=Iu,b.getBlockKind=Io,b.getBlockMinWidth=o4,b.getBlockNearestRangeFromPoint=L4,b.getBlockOptions=VE,b.getBlockPath=Di,b.getBlockProperties=s4,b.getBlockRangeFromPoint=rh,b.getBlockStyles=zE,b.getBlockTextLength=ue,b.getBlockTools=lt,b.getBlockType=De,b.getBoxContent=Hm,b.getBoxId=qC,b.getBoxTypeFromElement=va,b.getChildBlockCount=Eo,b.getChildBlocks=vt,b.getChildOffset=Mi,b.getColorFromAttributes=gg,b.getColorFromContent=Yd,b.getComplexBlockClass=jn,b.getContainerBlockPath=m4,b.getContainerBlocks=e4,b.getContainerBlocksElement=th,b.getContainerById=$r,b.getContainerId=ae,b.getContainerMinWidth=Qm,b.getContainerToolsElement=QE,b.getContainerWidth=b4,b.getDistanceSquare=tr,b.getElementOffset=ga,b.getElementScale=ys,b.getEmbedType=Un,b.getExistsBlockTools=Kd,b.getExistsContainerById=f4,b.getFileExt=Aa,b.getFirstChildBlock=St,b.getFirstClientRect=Hd,b.getHeadingMenuOptions=B0,b.getHorizontalPadding=Cm,b.getInsertionContent=jm,b.getLastChildBlock=Gt,b.getLastClientRect=bs,b.getListAllNextBrothers=dc,b.getLogger=S,b.getNextBlock=Ze,b.getNextValidOffset=Fs,b.getNextVisibleBlock=Ss,b.getOffsetInfoAfter=Sa,b.getOffsetInfoBefore=Ah,b.getOpAt=Y4,b.getOpLength=uh,b.getParentBlock=oe,b.getParentBlockExcludeSelf=Is,b.getParentBox=$m,b.getParentContainer=ne,b.getPrevBlock=ct,b.getPrevValidOffset=Ri,b.getPrevVisibleBlock=Ds,b.getRangeCommands=rb,b.getRootBlock=Vm,b.getScrollContainer=oo,b.getSpecialBlockCommands=l4,b.getStandardEmbedBlockProperties=T2,b.getTextAfterOffset=DI,b.getTextAttributes=Dg,b.getTextBeforeOffset=SI,b.getTextBlockChild=eh,b.getTextBlockClass=KC,b.getTextBlockContentChildTextLength=so,b.getTextBlockContentChildType=d4,b.getTextBlockContentChildren=nr,b.getTextLength=rn,b.getTextOpLength=rg,b.getTextWidth=Wd,b.getToolbar=lf,b.handleBlockElementUpdated=r4,b.hasAltOnly=yE,b.hasClass=xe,b.hasCtrlOrCmd=AC,b.hasCtrlOrCmdOnly=vE,b.hashCode=PC,b.hideBlock=jC,b.htmlToFragment=Vd,b.i18n=R,b.injectDocToHtmlFragment=Mh,b.injectStyle=cC,b.insertEmptyBlock=GE,b.insertEmptyEmbedBlock=qm,b.insertText=jr,b.intersectionCommands=_D,b.isBackspace=vC,b.isBlock=xs,b.isBlockLocked=_f,b.isBlockLockedByOthers=e2,b.isBlockLockedBySelf=Tu,b.isBlockTools=HC,b.isBox=Nm,b.isCJK=gC,b.isChildContainer=Do,b.isChildNode=Ke,b.isCollapsedRange=mI,b.isComplexBlockPosition=Km,b.isComplexKindBlock=Le,b.isContainer=Fr,b.isContainerSelectedAllChildBlocks=MA,b.isControlEvent=ws,b.isDelete=wE,b.isDraggingFiles=qd,b.isElementVisible=ym,b.isEmbedBlock=Lt,b.isEmptyContainer=Ym,b.isEmptyDoc=Ag,b.isEmptyTextBlock=ht,b.isEmptyTextBlockWithoutCompositionText=Au,b.isEnterOnly=bC,b.isEscape=Im,b.isExclusiveBlock=Of,b.isFirefox=Em,b.isFirstChildBlockInComplexBlock=Ix,b.isHighSurrogate=aE,b.isInBlock=Um,b.isInBlockTools=Ls,b.isLetter=mC,b.isLowSurrogate=gm,b.isMatchShortcut=Or,b.isMoveForward=AE,b.isNavigationEvent=CE,b.isNavigationKey=CC,b.isNodeRemoved=nC,b.isNumber=fC,b.isPrintableKey=xm,b.isRootBlock=ro,b.isRootContainer=Xe,b.isSafari=pC,b.isSameDay=Om,b.isSecureEnv=j0,b.isShiftEnter=kE,b.isShiftTab=EE,b.isShortcutEvent=bE,b.isSimpleBlock=UE,b.isSimpleBlockPosition=Hr,b.isSimplePos=l6,b.isSimpleRange=mh,b.isSpace=Ud,b.isTab=BE,b.isTextBlockContentBoxChild=io,b.isTextBlockContentChild=ka,b.isTextBlockContentInsertionChild=Nr,b.isTextBlockContentTextChild=wa,b.isTextKindBlock=ee,b.isTextKindBlockType=ya,b.isToday=LC,b.isValidOffset=sn,b.isVisibleBlock=Jd,b.isYesterday=MC,b.loadJs=oC,b.loadJsPromise=vs,b.lockers=wo,b.mergeCommands=sf,b.mergeDocs=$s,b.mergeOps=ug,b.mergeText=cI,b.multiSplitText=_4,b.overflowText=RC,b.parseShortcut=yC,b.patchNode=Ca,b.pointInRect=ks,b.rangeAddAttribute=Ia,b.rangeGetTextColor=n6,b.rangeRemoveAttribute=ql,b.rangeSetTextColor=X4,b.rangeTransformText=J4,b.registerDragDrop=wm,b.removeAttribute=mg,b.removeClass=te,b.removeLastBr=rI,b.removePlaceholderFromBlock=i7,b.removeStyle=lC,b.replaceAll=OE,b.replaceAllCaseInsensitive=_E,b.replaceAllText=i6,b.replaceText=hh,b.requestDownload=Gd,b.resetListStart=fc,b.scrollable=TC,b.selectFile=zl,b.selectedBlockToDoc=Th,b.selectionToDoc=Dh,b.setAttributes=bm,b.setClipboardData=Mm,b.setClipboardDataByEvent=SE,b.setColorToAttributes=e6,b.setDataset=Am,b.setDefaultCursor=pa,b.setStyles=vm,b.shareDBCommentToDocObject=bp,b.shareDBDocCommentToComment=Gb,b.shortcutToDisplayText=Bo,b.showBlock=UC,b.showDocVersions=QZ,b.splitText=xn,b.splitToThree=zt,b.stringToDataUrl=Sm,b.stringToObjectUrl=Lm,b.subText=F4,b.textNodeOffsetFromPoint=tC,b.titleFromEditor=g7,b.toBase64URL=Bs,b.toMindmap=df,b.toPlainText=rt,b.toPlainTextKeepLength=pg,b.trimChar=Bm,b.unexclusiveBlock=X0,b.unicodeLength=uE,b.unicodeSubstr=dE,b.updateBlockSelection=n4,b.updateOpAttributes=r6,b.updateTextBlockContent=TI,b.updateUrl=Tm;for(const n in bt)n!=="default"&&!b.hasOwnProperty(n)&&Object.defineProperty(b,n,{enumerable:!0,get:()=>bt[n]});Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
740
+ \`\`\`\`\`\``}return"[plantuml]"}const ak={embedType:"plantuml",convertFrom:mG,handleUpdateBlock:fG,createEmbedContent:hG,getBlockProperties:gG,convertTo:pG},roe="",CG="hr",AG={dividingLine:{type:"\u5206\u5272\u7EBF",abstract:"\u5206\u5272\u7EBF"}},bG={dividingLine:{type:"Separation line",abstract:"Separation line"}},vG={dividingLine:{type:"\u533A\u5207\u308A\u7DDA",abstract:"\u533A\u5207\u308A\u7DDA"}};R.mergeLang({"zh-CN":AG,"en-US":bG,"ja-JP":vG});function yG(n,e){const t=w("div",["editor-embed-container"],e);w("hr",["editor-embed-hr"],t)}function kG(n,e,t,o){return o==="html"?"<hr />":o==="markdown"?"---":"------------"}function wG(){return{name:"hr",insertEmbedCommandItems:[{id:"insert-hr",name:R.t("dividingLine.type"),icon:zL,order:500,group:"common",subText:pn("insert-hr")}],handleInsertEmptyEmbed:async(n,e)=>{const{containerId:t,blockIndex:o}=e;return n.insertEmbed(t,o,CG,{})}}}function BG(n,e,t){const{data:o}=t;if(!o||o.embedType!=="dividing-line"||!ee(n,e))return null;const r={};return{blockData:{id:K(),type:"embed",embedType:"hr",embedData:r}}}function EG(){return{abstract:R.t("dividingLine.abstract")}}const uk={embedType:"hr",createEmbedContent:yG,convertTo:kG,getOptions:wG,convertFrom:BG,getBlockProperties:EG},ioe="",soe="",xG={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 <span class="retry-upload">\u91CD\u8BD5</span></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 <span class="retry-upload">\u91CD\u8BD5</span></div>'},audio:{menuItem:"\u97F3\u9891",abstract:"\u97F3\u9891"},video:{menuItem:"\u89C6\u9891",abstract:"\u89C6\u9891"}}},IG={media:{upload:{failed:'<div class="line-1">{name} upload failed</div><div class="line-2">Network error, you can <span class="retry-upload">Retry</span></div>'},load:{failed:'<div class="line-1">{name} loading failed</div><div class="line-2">Network error, you can <span class="retry-upload">Retry</span></div>'},audio:{menuItem:"Audio",abstract:"Audio"},video:{menuItem:"Video",abstract:"Video"}}},TG={media:{upload:{failed:'<div class="line-1">{name}\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F</div><div class="line-2">\u304A\u4F7F\u3044\u306E\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u306B\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u6B21\u306E\u64CD\u4F5C\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002 <span class="retry-upload">\u518D\u8A66\u884C</span></div>'},load:{failed:'<div class="line-1">{name}\u3092\u8AAD\u307F\u8FBC\u3081\u307E\u305B\u3093\u3067\u3057\u305F</div><div class="line-2">\u304A\u4F7F\u3044\u306E\u30CD\u30C3\u30C8\u30EF\u30FC\u30AF\u63A5\u7D9A\u306B\u554F\u984C\u304C\u767A\u751F\u3057\u307E\u3057\u305F\u3002\u6B21\u306E\u64CD\u4F5C\u3092\u884C\u3063\u3066\u304F\u3060\u3055\u3044\u3002 <span class="retry-upload">\u518D\u8A66\u884C</span></div>'},audio:{menuItem:"\u97F3\u58F0",abstract:"\u97F3\u58F0"},video:{menuItem:"\u52D5\u753B",abstract:"\u52D5\u753B"}}};R.mergeLang({"zh-CN":xG,"en-US":IG,"ja-JP":TG});var Vo=(n=>(n.AUDIO="audio",n.VIDEO="video",n))(Vo||{}),$u=(n=>(n.Empty="empty",n.Progress="progress",n.Error="error",n))($u||{});const dk=10*1024*1024,DG=["wav","mp3","aac","ogg","webm","flac"],SG=["ogg","mp4","webm"],LG=()=>{};function hk(n){var h,p,A,v,B,D;const e=(h=n.getComponentOptions("media"))!=null?h:{},{allowedMedias:t,maxSize:o,callbacks:r}=e,i=(p=t==null?void 0:t.audio)!=null?p:DG,s=(A=t==null?void 0:t.video)!=null?A:SG,l=(v=o==null?void 0:o.audio)!=null?v:dk,a=(B=o==null?void 0:o.video)!=null?B:dk,d=(D=r==null?void 0:r.onError)!=null?D:LG;return{allowedMedias:{audio:i,video:s},maxSize:{audio:l,video:a},callbacks:{onError:d}}}function MG(n,e){const t=i=>i.map(s=>`.${s}`).join(","),{allowedMedias:o}=hk(n),r=o[e];return r?t(r):"*"}function RG(n,e,t){const{maxSize:o,callbacks:r,allowedMedias:i}=hk(e),{[t]:s}=o,{[t]:l}=i;if(s&&n.size>s){const d=new Error("media is too large");throw d.code=`MaxMediaSize-${t}`,r!=null&&r.onError&&(r==null||r.onError(e,d)),d}const a=Aa(n.name);if(l&&!l.includes(a)){const d=new Error(`media file is not allowed: ${a}`);throw d.code="NotAllowedFile",r!=null&&r.onError&&(r==null||r.onError(e,d)),d}}function OG(n){return n===$u.Empty||n===$u.Error}const Pt=S("media");class _G extends bt.TypedEmitter{constructor(t){super();m(this,"mediaContainer",null);m(this,"media",null);m(this,"abstract",null);m(this,"handleMediaLoadError",(t,o)=>{if(!o.target||!(o.target instanceof Node)||!(o.target instanceof Element?o.target:o.target.parentElement))return;const i=oe(o.target);if(!i||!i.contains(this.mediaContainer))return;const s=this.renderError();this.updateMediaContent(s),this.emit("mediaError",t,"load_error",ie(i))});m(this,"handleUploadFile",async t=>{g(Pt,this.abstract,"no abstract"),g(Pt,this.mediaContainer,"The media element not exist");const{editor:o}=this.options,r=oe(this.mediaContainer);g(Pt,r,"The block element not exist");const i=o.getBlockData(r);try{const{resourceId:s}=await o.doc.uploadResource(t,{onProgress:p=>{this.renderProgress(p,t)}}),{name:l,type:a,size:d}=t,h={...i,embedData:{...i.embedData,src:s,fileName:l,fileSize:d,fileType:a}};o.updateBlockData(r,h)}catch(s){Pt.error(s),this.emit("mediaError",o,"upload_error",i.id),this.renderRetry(t)}te(r,"media-block-uploading")});m(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){g(Pt,this.mediaContainer,"The media element not exist"),this.mediaContainer.innerHTML="",this.mediaContainer.append(t)}renderError(){g(Pt,this.abstract,"no abstract");const{editor:t,createMediaElement:o}=this.options,{mediaIcon:r,mediaName:i}=this.abstract;g(Pt,this.mediaContainer,"The media element not exist");const s=oe(this.mediaContainer);g(Pt,s,"The block element not exist");const l=t.getBlockData(s),a=l.embedData.src,d=w("div",["media-error","embed-selected-content","embed-hover-content"],null),h=w("span",["media-error-icon"],d);h.innerHTML=r;const p=w("div",[],d);p.innerHTML=R.t("media.load.failed",{name:i}),d.appendChild(p);const A=p.querySelector(".retry-upload");return g(Pt,A,"The element not exist"),t.domEvents.addEventListener(A,"click",(v,B)=>{const D=w("div",["media-element"],null),I=this.getResourceUrl(a),_=o(v,D,l,I);this.unbindMediaEvent(),this.media=_,this.bindMediaEvent(),this.updateMediaContent(D)}),this.setFullScreen(),d}renderRetry(t){g(Pt,this.abstract,"no abstract");const{editor:o}=this.options,{mediaIcon:r,mediaName:i}=this.abstract,s=w("div",["media-error","embed-selected-content","embed-hover-content"],null),l=w("span",["media-error-icon"],s);l.innerHTML=r;const a=w("div",[],s);a.innerHTML=R.t("media.upload.failed",{name:i}),s.appendChild(a);const d=a.querySelector(".retry-upload");g(Pt,d,"The element not exist"),o.domEvents.addEventListener(d,"click",()=>{o.readonly||(g(Pt,this.abstract,"no abstract"),this.handleUploadFile(t))}),this.updateMediaContent(s),this.setFullScreen()}renderProgress(t,o){g(Pt,this.mediaContainer,"The media element not exist");const r=this.mediaContainer.querySelector(":scope .media-progress"),i=t===-1||t===100?100:t;if(r){const{updateProgressElement:s}=this.options;s(r,i)}else{const{createProgressElement:s}=this.options,l=oe(this.mediaContainer);g(Pt,l,"The element not exist"),W(l,"media-block-uploading");const a=w("div",["media-progress"],null);s(a,i,o),this.updateMediaContent(a)}this.setFullScreen()}renderMediaElement(t){g(Pt,this.mediaContainer,"The media element not exist");const o=this.mediaContainer.querySelector(":scope > .media-element"),{createMediaElement:r,updateMediaElement:i,editor:s}=this.options,l=this.getResourceUrl(t.embedData.src);if(o){const a=i(s,o,t,l);this.unbindMediaEvent(),this.media=a,this.bindMediaEvent()}else{const a=w("div",["media-element"],null),d=r(s,a,t,l);this.unbindMediaEvent(),this.media=d,this.bindMediaEvent(),this.updateMediaContent(a)}}renderEmpty(t){g(Pt,this.abstract,"no abstract"),g(Pt,this.mediaContainer,"The media element not exist");const o=w("div",["media-empty","embed-selected-content","embed-hover-content"],this.mediaContainer);o.innerHTML=this.abstract.mediaIcon,this.updateMediaContent(o);const{editor:r}=this.options;r.findBlockById(t.id)&&this.emit("mediaError",r,"empty",t.id),this.setFullScreen()}getResourceUrl(t){const{editor:o}=this.options;return o.doc.buildResourceUrl(t)}setFullScreen(){g(Pt,this.mediaContainer,"The media element not exist"),W(this.mediaContainer,"full-screen")}removeFullScreen(){g(Pt,this.mediaContainer,"The media element not exist"),te(this.mediaContainer,"full-screen")}updateBlockAlign(t,o){const r=oe(o);g(Pt,r,"The block element not exist");const{align:i}=t;t.embedType==="video"&&(r.hasAttribute("data-style-align")&&r.removeAttribute("data-style-align"),r.setAttribute("data-style-align",i))}render(t,o){const{src:r}=t.embedData;(!this.mediaContainer||!o.contains(this.mediaContainer))&&(this.mediaContainer=w("div",["media"],o)),this.updateBlockAlign(t,o),OG(r)?r===$u.Empty&&this.renderEmpty(t):this.renderMediaElement(t)}setAbstract(t){this.abstract=t}}S("media-embed");const FG="left";class fk{constructor(){m(this,"handleInsertEmptyEmbed",async(e,t)=>{var p;const{containerId:o,blockIndex:r}=t;let i;(p=t.data)!=null&&p.file&&(i=t.data.file);const s=MG(e,this.embedType);if(i=i!=null?i:await zl(s,{}),!i)return null;const{mediaType:l}=this.getAbstract();try{RG(i,e,l)}catch{return null}const a={id:K(),type:"embed",embedType:this.embedType,embedData:{src:$u.Empty}};l==="video"&&(a.align=FG);const d=e.insertBlock(o,r,a);return await this.getMedia(e,a.id).handleUploadFile(i),d})}getMedia(e,t){const o=e.addCustom(`media-${t}`,()=>new _G({editor:e,createMediaElement:this.createMediaElement,updateMediaElement:this.updateMediaElement,createProgressElement:this.createProgressElement,updateProgressElement:this.updateProgressElement}));return o.setAbstract({...this.getAbstract()}),o}getOptions(){const{menuItem:e,mediaIcon:t,mediaName:o,order:r,group:i}=this.getAbstract();return{name:o,insertEmbedCommandItems:[{id:`insert-${this.embedType}`,name:e,icon:t,order:r,group:i,subText:pn(`insert-${this.embedType}`)}],handleInsertEmptyEmbed:this.handleInsertEmptyEmbed}}createEmbedContent(e,t,o){const{id:r}=o;this.getMedia(e,r).render(o,t)}handleUpdateBlock(e,t,o){const{id:r}=o,i=this.getMedia(e,r),s=Re(t);return i.render(o,s),!0}handleDeleteBlock(e,t){const o=t.id,r=this.getMedia(e,o);r.removeAllListeners(),r.destroy()}convertTo(e,t,o,r){const i=t.embedData,s=e.doc.buildResourceUrl(i.src,{withToken:!0});return r==="html"?`<${i.type} src="${s}" />`:r==="markdown"?`![${i.src}](${s})`:s}}function mk(n,e){const t=w("div",["uploading-progress-mask"],n),o=w("div",["uploading-progress-bar"],t),r=w("div",["uploading-progress-bar-value"],o);r.style.width=`${e}%`}function gk(n,e){const t=n.querySelector(".uploading-progress-bar-value");t&&(t.style.width=`${e}%`)}const PG=S("media-audio");class NG extends fk{constructor(){super(...arguments);m(this,"embedType",Vo.AUDIO);m(this,"updateProgressElement",gk);m(this,"createMediaElement",(t,o,r,i)=>{const s=w("div",["audio-container","embed-hover-content","embed-selected-content"],o),l=w("audio",[],s);return l.innerHTML="Your browser does not support the <code>audio</code> element.",l.controls=!0,l.src=i,setTimeout(()=>{this.getMedia(t,r.id).setFullScreen()}),l})}getAbstract(){return{mediaIcon:HL,mediaName:R.t(`media.${Vo.AUDIO}.menuItem`),menuItem:R.t(`media.${Vo.AUDIO}.menuItem`),order:800,mediaType:Vo.AUDIO,group:"common"}}getBlockProperties(){return{abstract:`${R.t(`media.${Vo.AUDIO}.abstract`)}`}}updateMediaElement(t,o,r,i){const s=o.querySelector(":scope .audio-container > audio");return g(PG,s,"The media element not exist"),s.src!==i&&(s.src=i),s}createProgressElement(t,o){const r=w("audio",[],t);r.innerHTML="Your browser does not support the <code>audio</code> element.",r.controls=!0,r.src="about:blank",mk(t,o)}}const pk=new NG;S("video-resizer");function Ck(n){return n&&Lt(n)&&Un(n)==="video"}const $G=50;class G2{constructor(e){m(this,"currentResizableElement",null);m(this,"resizing",!1);m(this,"handleHoveringBlockChange",(e,t)=>{if(!this.resizing&&(t&&Ck(t)&&this.disableBlockResize(t),e&&Ck(e))){const o=this.getVideoElement(e);if(!o)return;this.enableBlockResize(e,o)}});m(this,"handleResizing",(e,t)=>{if(this.resizing=!0,!this.currentResizableElement)return;const o=e.getBlock();if(!o)return;const r=o.getBoundingClientRect().width,i=Math.min(Math.max(t.width,$G),r);this.currentResizableElement.style.width=`${i}px`});m(this,"handleResized",e=>{this.resizing=!1;const t=e.getBlock();if(!this.currentResizableElement||!t)return;const o=this.editor.getBlockData(t),{width:r}=this.currentResizableElement.getBoundingClientRect();this.editor.updateBlockData(t,{...o,width:r})});this.editor=e,pt.get(e).addListener("change",this.handleHoveringBlockChange)}destroy(){this.currentResizableElement=null,pt.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}getVideoElement(e){return Re(e).querySelector(":scope .video-container > video")}updateResizer(e){const t=this.editor.findCustom(`${ie(e)}-resizer`);t&&t.updateResizer()}disableBlockResize(e){const t=this.editor.findCustom(`${ie(e)}-resizer`);t&&t.disableResize()}enableBlockResize(e,t){const o=this.editor.addCustom(`${ie(e)}-resizer`,()=>new wu(this.editor,{resize:["top-left","top-right","bottom-left","bottom-right"]}));o.enableResize(e,t),o.removeListener("resizing",this.handleResizing),o.removeListener("resized",this.handleResized),o.addListener("resizing",this.handleResizing),o.addListener("resized",this.handleResized),this.currentResizableElement=t}}const HG=S("video");class jG extends fk{constructor(){super(...arguments);m(this,"embedType",Vo.VIDEO);m(this,"updateProgressElement",gk);m(this,"createMediaElement",(t,o,r,i)=>{const s=w("div",["video-container","embed-selected-content","drag-preview-element"],o),l=w("video",[],s);return l.innerHTML="Your browser does not support the <code>video</code> element.",l.controls=!0,l.src=i,l.addEventListener("canplay",()=>{t.addCustom("video-resizer",()=>new G2(t)),this.getMedia(t,r.id).removeListener("mediaError",this.handleMediaError),this.getMedia(t,r.id).addListener("mediaError",this.handleMediaError),this.getMedia(t,r.id).removeFullScreen()}),r.width&&(l.style.width=`${r.width}px`),l});m(this,"createProgressElement",(t,o,r)=>{const i=w("video",["progress-video"],t);i.innerHTML="Your browser does not support the <code>audio</code> element.",i.controls=!0,mk(t,o),Ul(r).then(s=>{const l=t.querySelector(".progress-video");l&&Um(t)&&(l.src=s)})})}getAbstract(){return{mediaName:R.t(`media.${Vo.VIDEO}.menuItem`),mediaIcon:jL,menuItem:R.t(`media.${Vo.VIDEO}.menuItem`),order:700,mediaType:Vo.VIDEO,group:"common"}}getBlockProperties(){return{abstract:`[${R.t(`media.${Vo.VIDEO}.abstract`)}]`}}handleMediaError(t,o,r){const i=t.addCustom("video-resizer",()=>new G2(t)),s=t.getBlockById(r);i.disableBlockResize(s)}updateMediaElement(t,o,r,i){const s=o.querySelector(":scope .video-container > video");g(HG,s,"The media element not exist"),s.src!==i&&(s.src=i),r.width?s.style.width=`${r.width}px`:s.style.width="";const l=t.getBlockById(r.id);return setTimeout(()=>{t.addCustom("video-resizer",()=>new G2(t)).updateResizer(l)}),s}}const Ak=new jG,bk=[xf,Sf,U0,E9],Z2=[z2,Z8,rk,lk,ak,F9,uk,Ak,pk,X7,j8,Yz],vk=[T0,F2,u8];function UG(n,e,t){var r,i,s;const o=Ha(n,e,{components:{blocks:[...bk,...((r=t==null?void 0:t.components)==null?void 0:r.blocks)||[]],embeds:[...Z2,...((i=t.components)==null?void 0:i.embeds)||[]],boxes:[...vk,...((s=t.components)==null?void 0:s.boxes)||[]],textRenders:[new C0],options:{...t.componentsOptions}}});return o.readonly=!0,o.addCustom("heading-collapse",()=>new F8(o)),o.addCustom("editor-tooltip",()=>new bf(o)),o.addListener("clickLink",(l,a,d)=>{var p;if((p=t==null?void 0:t.events)!=null&&p.onClickLink){t.events.onClickLink(l,a,d);return}const h=d.getAttribute("link");h&&(l.readonly||a.ctrlKey||a.metaKey)&&window.open(h,"_blank")}),o}class yk{constructor(e){this.createOptions=e,e.lang&&R.setLang(e.lang)}createHistoryEditor(e,t){return UG(e,t,this.createOptions)}}S("create-editor");function kk({root:n,childDoc:e,doc:t}){e.uploadResource=t.uploadResource.bind(t),e.buildResourceUrl=t.buildResourceUrl.bind(t);const o=Ha(n,e,{shortcuts:[Lh],components:{blocks:[xf,Sf],decorators:[new Lf],embeds:[X7,z2,Z8,rk,lk,ak,F9,uk,Ak,pk],boxes:[T0,F2],options:{image:{defaultAlign:"left"}}}});return o.input.addHandler(new If),o.input.addHandler(new c2(o)),o.input.addHandler(new f2(o)),o.input.addHandler(new tz(o)),o.input.addHandler(new Ff),o.addCustom("image-paste-handler",()=>new l2(o)),o}function zG(n,e){const t=Array.from(n.rootContainer.querySelectorAll(`[comment-${e.toLocaleLowerCase()}="${e}"]`)),o=new Set;t.forEach(r=>{const i=oe(r);i&&o.add(i)}),o.forEach(r=>{nz(n,r,e)})}class VG{constructor(e){m(this,"listeners",new Set);m(this,"doc");this.editor=e,this.doc=this.editor.doc.externalDoc,this.doc.registerCallback(this)}getComments(){return this.doc.getComments()}getComment(e){return this.doc.getComment(e)}getCommentDoc(e){return this.doc.getCommentDoc(e)}localCreateComment(e,t){this.doc.localCreateComment(e,t)}localDeleteComment(e){const t=this.getComment(e);this.doc.localDeleteComment(e);const o=t.groupId;this.getComments().filter(i=>i.groupId===o).length===0&&zG(this.editor,o)}localUpdateComment(e,t){this.doc.localUpdateComment(e,t)}onCreateComment(e,t){Array.from(this.listeners.values()).forEach(o=>o.onCreateComment(e,t))}onDeleteComment(e,t){Array.from(this.listeners.values()).forEach(o=>o.onDeleteComment(e,t))}onUpdateComment(e,t){Array.from(this.listeners.values()).forEach(o=>o.onUpdateComment(e,t))}addListener(e){this.listeners.add(e)}removeListener(e){this.listeners.delete(e)}createCommentEditor(e,t){var r,i;const o=kk({root:e,childDoc:t,doc:this.doc});if((r=this.editor.options.componentsOptions)!=null&&r.mention){const s=this.editor.options.componentsOptions.mention;o.addCustom("mention",()=>new _2(o,{...s,enableFirstBlock:!0}))}if((i=this.editor.options.componentsOptions)!=null&&i.comment){const s=this.editor.options.componentsOptions.comment;s.onCommentEditorClick&&o.addListener("click",s.onCommentEditorClick)}return o}allowEdit(e){return e.userId===this.doc.getUser().userId}}class WG{constructor(e,t){m(this,"listeners",new Set);this.editor=e,this.localDoc=t}get doc(){return this.localDoc.toJSON()}getComments(){return Object.values(this.doc.comments)}getComment(e){return this.doc.comments[e]}getCommentDoc(e){const t=this.doc.comments[e];return bp(t)}addListener(e){this.listeners.add(e)}removeListener(e){this.listeners.delete(e)}localCreateComment(e,t){}localDeleteComment(e){}localUpdateComment(e,t){}createCommentEditor(e,t){var r,i;const o=kk({root:e,childDoc:t,doc:this.localDoc});if((r=this.editor.options.componentsOptions)!=null&&r.mention){const s=this.editor.options.componentsOptions.mention;o.addCustom("mention",()=>new _2(o,{...s,enableFirstBlock:!0}))}if((i=this.editor.options.componentsOptions)!=null&&i.comment){const s=this.editor.options.componentsOptions.comment;s.onCommentEditorClick&&o.addListener("click",s.onCommentEditorClick)}return o}allowEdit(e){return e.userId===this.localDoc.getUser().userId}}const qG={placeholder:{common:{title:"\u8BF7\u8F93\u5165\u6807\u9898",readonlyTitle:"\u8BF7\u8F93\u5165\u6807\u9898",content:"\u70B9\u51FB + \uFF0C\u6216\u8F93\u5165 / \u5FEB\u6377\u63D2\u5165\u7EC4\u4EF6",contentInTable:"\u8F93\u5165 / \u5FEB\u6377\u63D2\u5165\u7EC4\u4EF6"},local:{readonlyTitle:"\u672A\u547D\u540D"}},copyCutProperty:{copy:"\u590D\u5236",cut:"\u526A\u5207",unsafeEnvTips:"\u7531\u4E8E\u5F53\u524D http \u8BBF\u95EE\u73AF\u5883\u4E0B\u7684\u9650\u5236\uFF0C\u8BF7\u4F7F\u7528\u5FEB\u6377\u952E({shortCut}) {operation}"}},GG={placeholder:{common:{title:"Enter a title",readonlyTitle:"Enter a title",content:"Click + or enter / to insert components quickly",contentInTable:"Enter / to insert components quickly"},local:{readonlyTitle:"Untitled"}},copyCutProperty:{copy:"Copy",cut:"Cut",unsafeEnvTips:"Due to the limitations of the current http access environment, please use the shortcut ({shortCut}) {operation}"}},ZG={placeholder:{common:{title:"\u30BF\u30A4\u30C8\u30EB\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",readonlyTitle:"\u30BF\u30A4\u30C8\u30EB\u3092\u5165\u529B\u3057\u3066\u304F\u3060\u3055\u3044",content:"\u300C+\u300D\u3092\u30AF\u30EA\u30C3\u30AF\u3059\u308B\u304B\u3001\u300C/\u300D\u3092\u5165\u529B\u3059\u308B\u3068\u3001\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u304C\u7D20\u65E9\u304F\u633F\u5165\u3067\u304D\u307E\u3059",contentInTable:"\u300C/\u300D\u3092\u5165\u529B\u3059\u308B\u3068\u3001\u30B3\u30F3\u30DD\u30FC\u30CD\u30F3\u30C8\u304C\u7D20\u65E9\u304F\u633F\u5165\u3067\u304D\u307E\u3059"},local:{readonlyTitle:"\u7121\u984C"}},copyCutProperty:{copy:"\u8907\u88FD",cut:"\u5207\u308B",unsafeEnvTips:"HTTP\u74B0\u5883\u306E\u5236\u7D04\u306B\u3088\u308A\u3001{operation}\u3059\u308B\u306B\u306F\u3001\u30B7\u30E7\u30FC\u30C8\u30AB\u30C3\u30C8({shortCut}) \u3092\u3054\u4F7F\u7528\u304F\u3060\u3055\u3044"}};R.mergeLang({"zh-CN":qG,"en-US":GG,"ja-JP":ZG});const QG="UEsDBBQABgAIAAAAIQBk9WPugQEAACkGAAATAAgCW0NvbnRlbnRfVHlwZXNdLnhtbCCiBAIooAACAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAC0lMtqwzAQRfeF/oPRtsRKuiilxMmij2UbaArdKvI4EdULaZzH33fsJKYUJy5NsjHIM/feowHNcLw2OllCiMrZjA3SPkvASpcrO8/Yx/Sld8+SiMLmQjsLGdtAZOPR9dVwuvEQE1LbmLEFon/gPMoFGBFT58FSpXDBCKRjmHMv5JeYA7/t9++4dBbBYg8rDzYaPkEhSo3J85p+b0kC6MiSx21jlZUx4b1WUiDV+dLmv1J6u4SUlHVPXCgfb6iB8daEqnI4YKd7o9EElUMyEQFfhaEuvnIh57mTpSFletymhdMVhZLQ6Cs3H5yEGGnmRqcIxtMNIDVC2T1/G4csIzrzaTRXpJkE5+PgZJzGtPKDgAqaGR6chS3NDALRn38YjXUnRMSNhnh+gq1vdzwgkuASADvnToQVzN4vRvHDvBOkoNypmGk4P0Zj3QmBtIpg+z39VdQ2xyKps36AtNrCP669312Vuuf/9PKaRLI++X5QrcUc8pZsXi/60TcAAAD//wMAUEsDBBQABgAIAAAAIQAekRq37wAAAE4CAAALAAgCX3JlbHMvLnJlbHMgogQCKKAAAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAArJLBasMwDEDvg/2D0b1R2sEYo04vY9DbGNkHCFtJTBPb2GrX/v082NgCXelhR8vS05PQenOcRnXglF3wGpZVDYq9Cdb5XsNb+7x4AJWFvKUxeNZw4gyb5vZm/cojSSnKg4tZFYrPGgaR+IiYzcAT5SpE9uWnC2kiKc/UYySzo55xVdf3mH4zoJkx1dZqSFt7B6o9Rb6GHbrOGX4KZj+xlzMtkI/C3rJdxFTqk7gyjWop9SwabDAvJZyRYqwKGvC80ep6o7+nxYmFLAmhCYkv+3xmXBJa/ueK5hk/Nu8hWbRf4W8bnF1B8wEAAP//AwBQSwMEFAAGAAgAAAAhADPCW79BAQAA5wQAABwACAF3b3JkL19yZWxzL2RvY3VtZW50LnhtbC5yZWxzIKIEASigAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAArJQxT8MwEIV3JP5D5B07LVAQatoFkDqwQJFYneSSWI3tyL6Q9t9zojRNRYkYPN6z7r1P57Pny62uo09wXlmTsAmPWQQms7kyZcLe189X9yzyKE0ua2sgYTvwbLm4vJi/Qi2RmnylGh+Ri/EJqxCbByF8VoGWntsGDJ0U1mmJVLpSNDLbyBLENI5nwg092OLEM1rlCXOrnPLXuwb+422LQmXwaLNWg8EzEQKpF8hQuhIwYd/lXpxwMmPiPMN1SAaPu5qG2EPs67H4u5DxhTW4lmk9GEMvjUFMQ0KYVqfgaMeOEL00BjEJCZG1Hq3+oLQegvOjKhSCHl2LWUiaipxcrczmSPNj23UdT6XKW55ZLQ7HLzan5KctgjPyT8TbkIgdpG+ASHc0WN+BODarm6BP6BfFQTkgiJPvafEFAAD//wMAUEsDBBQABgAIAAAAIQBOMo6QFgYAAKYkAAARAAAAd29yZC9kb2N1bWVudC54bWzUWttu40QYvkfiHSJfLRKtz4eYTVeOD7uVQKoo+wCuPUmstT3WeNI0XC0XC1wguOBiuWClLgjBE4AEiIdZ0T28BTM+JM6h7cTZkm0vEnv+mW+++eb7/0yc3r13lsSdU4DyCKY9TtwXuA5IAxhG6bDHPfzM2zO4To79NPRjmIIeNwU5d+/g/ffuTswQBuMEpLhDINLcnGRBjxthnJk8nwcjkPj5fhIFCOZwgPcDmPBwMIgCwE8gCnlJEIXiKkMwAHlO5rP99NTPuQouOGNDC5E/IYMpoMIHIx9hcDbHEDcGUfkub6wCSS2AyAolcRVK3hhK4ymrFSClFRBhtYKktkNaszitHZK0iqS3Q5JXkYx2SCt2SlYNDjOQkuAAosTH5BYN+cRHj8bZHgHOfBydRHGEpwRT0GoYP0oftWBERs0QEjncGEHnExiCWA5rFNjjxig1q/F7s/GUulmOr97qEYhl/eUQpyoOxcp5BGKiBUzzUZTNMjxpi0aCoxrk9KpFnCZx3W+SiYzpcll5ckop54As9Cv9k7hkfjWiKDDsCIWYjWChsDhnzSQhLpxP3EqahrgiYwGpAaQVAC0AjAW/xjAqDD6YZyjFiRhTo8Ypd4XiRHNhRcY6tkymAZCDzSDUmkc+TRoryobb2fY+guNsjhZth3Y4L0ITehzYAKuyfzMl8+3IHI/8jNSmJDAPhylE/klMGBEzd4gfO8UO0FeyrfStuARnHVoIuANyfDmB4ZS+ZySimJmP/EPiHEV2dE+3La5oJcUf01a9+iOtJjkqhZ/2OEEQJE1z5FmTAwb+OMY04nUVRRfryFGjqZjwCBVvx3gaE4bmqR/3uAfAp2cukeNpDJVdYj8d1h1AuvfwmEb5KszPkMqX6tqDKc7JoFGUEi7Az7GVR35z4MTEBy/Pv3rz0w+0CZeBZZwrp6ajxIXBlMwaMT2l6wh9lUHMRcnejpjSDYrJoND2GksMGquOY+iu7exIY/m2ayyzaKwaqi4YNNd3obFy2zVWGDTW+7Il296uaoX6LmisMugkKIpouJqwI5202+5FjUFjTfQ8S7OMHWms33aNdQaNJd3qqoq8q5pq3HaNDRaNNcFzRafLoLGtaF2JdlzReDFSaFw1NTTeRMf1XBVLNcSux+KHnXOVBddQLEm6DVxVSxf6nubdPNfFPLNhCCqWdRxBOHARIj3wNCNf1YbIT46xj3CVi6WxA5jmMAb7MRzeWUqQtQhuGi6Mf/H4xxGIY/hhh3xbjMMXj5998BFDrsiSZnuiYjPoZLiC7fV3rVM+zTFI9uEY72eI1KA4baPWnZZyiYYu2oLFlK6u2C3OzqtyLURaytXME8Zvv//+9fOr8y8unj1lWKjqeroraMpWvliMFAutmoq9WDp9aJohGzrLN7o2M7asLrVj6MMbM8/8gBgqQyAH6BRwB5RlZ8l/1HgFrSO0NH29Wws7e5jGUQoa+zvbLgwuQ26YiBGX2SOvn39z8eWT0ik3tbAzvIzMuiuXbkRndSfW+1rRlb7nKExng00SeDuXXcK1qwiWJi99hmme4uiaRfNkJ1wXt2u78+Dr35+8+vPXJTeMSNVGxDuPOsiMyILRYahR/qMoxxBNSREuTbdox+vy4UGNem06MPB+8/0/L7/9ZdluM+JvV6SX539c/P0dg7eFru3alrhUs1VH6kuqPD/gULUcRVAdd51fFiM35m21L3ueJNOJGlwFQ1FFxZ0beQ3Xcrs3WkDV1FjA4qfrx8RZR4QYOSlko3JX0nFS9ozi07juJ8xih2HdVjy65mcDGlmyljCbK5rbf/H109fPf7u6FjfA2R5Rq47sCZq2JL/ueo5o2VfK//8oXf0g8K4rvcf0c4DrGX25v3TElmzV1foiLe47tfrGZf16xWbiLMlTh/yTCmauWA4CfDST+jopimUNjz8nwQnxhSQp9LmgOSLXqqFUWZoNP/EpIoYZaVfKLigajvD89gRiDJP5fQwGjegI+CEg8+oCfSRmDiDEjdvhGBe31XQBjKle1cmE9imaQxjcR/SnOJOeho4iHBCWslYM4ut1F5flD3P8/B+MDv4DAAD//wMAUEsDBBQABgAIAAAAIQC29GeY0gYAAMkgAAAVAAAAd29yZC90aGVtZS90aGVtZTEueG1s7FlLixtHEL4H8h+Guct6zehhrDXSSPJr1zbetYOPvVJrpq2eadHd2rUwhmCfcgkEnJBDDLnlEEIMMcTkkh9jsEmcH5HqHkkzLfXEj12DCbuCVT++qv66qrq6NHPh4v2YOkeYC8KSjls9V3EdnIzYmCRhx719MCy1XEdIlIwRZQnuuAss3Is7n392AZ2XEY6xA/KJOI86biTl7Hy5LEYwjMQ5NsMJzE0Yj5GELg/LY46OQW9My7VKpVGOEUlcJ0ExqL0xmZARdg6USndnpXxA4V8ihRoYUb6vVGNDQmPH06r6EgsRUO4cIdpxYZ0xOz7A96XrUCQkTHTciv5zyzsXymshKgtkc3JD/beUWwqMpzUtx8PDtaDn+V6ju9avAVRu4wbNQWPQWOvTADQawU5TLqbOZi3wltgcKG1adPeb/XrVwOf017fwXV99DLwGpU1vCz8cBpkNc6C06W/h/V671zf1a1DabGzhm5Vu32saeA2KKEmmW+iK36gHq92uIRNGL1vhbd8bNmtLeIYq56IrlU9kUazF6B7jQwBo5yJJEkcuZniCRoALECWHnDi7JIwg8GYoYQKGK7XKsFKH/+rj6Zb2KDqPUU46HRqJrSHFxxEjTmay414FrW4O8urFi5ePnr989PvLx49fPvp1ufa23GWUhHm5Nz9988/TL52/f/vxzZNv7XiRx7/+5avXf/z5X+qlQeu7Z6+fP3v1/dd//fzEAu9ydJiHH5AYC+c6PnZusRg2aFkAH/L3kziIEMlLdJNQoAQpGQt6ICMDfX2BKLLgeti04x0O6cIGvDS/ZxDej/hcEgvwWhQbwD3GaI9x656uqbXyVpgnoX1xPs/jbiF0ZFs72PDyYD6DuCc2lUGEDZo3KbgchTjB0lFzbIqxRewuIYZd98iIM8Em0rlLnB4iVpMckEMjmjKhyyQGvyxsBMHfhm327jg9Rm3q+/jIRMLZQNSmElPDjJfQXKLYyhjFNI/cRTKykdxf8JFhcCHB0yGmzBmMsRA2mRt8YdC9BmnG7vY9uohNJJdkakPuIsbyyD6bBhGKZ1bOJIny2CtiCiGKnJtMWkkw84SoPvgBJYXuvkOw4e63n+3bkIbsAaJm5tx2JDAzz+OCThC2Ke/y2EixXU6s0dGbh0Zo72JM0TEaY+zcvmLDs5lh84z01QiyymVss81VZMaq6idYQK2kihuLY4kwQnYfh6yAz95iI/EsUBIjXqT5+tQMmQFcdbE1XuloaqRSwtWhtZO4IWJjf4Vab0bICCvVF/Z4XXDDf+9yxkDm3gfI4PeWgcT+zrY5QNRYIAuYAwRVhi3dgojh/kxEHSctNrfKTcxDm7mhvFH0xCR5awW0Ufv4H6/2gQrj1Q9PLdjTqXfswJNUOkXJZLO+KcJtVjUB42Py6Rc1fTRPbmK4RyzQs5rmrKb539c0Ref5rJI5q2TOKhm7yEeoZLLiRT8CWj3o0Vriwqc+E0LpvlxQvCt02SPg7I+HMKg7Wmj9kGkWQXO5nIELOdJthzP5BZHRfoRmsExVrxCKpepQODMmoHDSw1bdaoLO4z02Tker1dVzTRBAMhuHwms1DmWaTEcbzewB3lq97oX6QeuKgJJ9HxK5xUwSdQuJ5mrwLST0zk6FRdvCoqXUF7LQX0uvwOXkIPVI3PdSRhBuENJj5adUfuXdU/d0kTHNbdcs22srrqfjaYNELtxMErkwjODy2Bw+ZV+3M5ca9JQptmk0Wx/D1yqJbOQGmpg95xjOXN0HNSM067gT+MkEzXgG+oTKVIiGSccdyaWhPySzzLiQfSSiFKan0v3HRGLuUBJDrOfdQJOMW7XWVHv8RMm1K5+e5fRX3sl4MsEjWTCSdWEuVWKdPSFYddgcSO9H42PnkM75LQSG8ptVZcAxEXJtzTHhueDOrLiRrpZH0Xjfkh1RRGcRWt4o+WSewnV7TSe3D810c1dmf7mZw1A56cS37tuF1EQuaRZcIOrWtOePj3fJ51hled9glabuzVzXXuW6olvi5BdCjlq2mEFNMbZQy0ZNaqdYEOSWW4dm0R1x2rfBZtSqC2JVV+re1ottdngPIr8P1eqcSqGpwq8WjoLVK8k0E+jRVXa5L505Jx33QcXvekHND0qVlj8oeXWvUmr53Xqp6/v16sCvVvq92kMwioziqp+uPYQf+3SxfG+vx7fe3cerUvvciMVlpuvgshbW7+6rteJ39w4Byzxo1IbtervXKLXr3WHJ6/dapXbQ6JX6jaDZH/YDv9UePnSdIw32uvXAawxapUY1CEpeo6Lot9qlplerdb1mtzXwug+Xtoadr75X5tW8dv4FAAD//wMAUEsDBBQABgAIAAAAIQDlI7CA9QMAAKALAAARAAAAd29yZC9zZXR0aW5ncy54bWy0Vttu2zgQfV9g/8HQ8zq6WHZsoU4R3zYp4nZRebHPlETZRHgRSMqu8/U7pETLu3ELp0VeEmrOzJkh53DoDx+/MdrbY6mI4FMvvAm8Hua5KAjfTr2/N6v+2OspjXiBqOB46h2x8j7e/f7bh0OisNbgpnpAwVXC8qm307pKfF/lO8yQuhEV5gCWQjKk4VNufYbkc131c8EqpElGKNFHPwqCkdfSiKlXS560FH1GcimUKLUJSURZkhy3/1yEvCZvE7IQec0w1zajLzGFGgRXO1Ipx8Z+lg3AnSPZ/2gTe0ad3yEMrtjuQcjiFHFNeSagkiLHSkGDGHUFEt4ljl8RnXLfQO52i5YKwsPArs4rH76NIHpFMMrxt7dxjFsOHyLPeUjxNp7RiYd0BxuOfq6YMwKF30YxdHWoI+t2pOg1PW6gJ5JJJJsb1DaY5cnjlguJMgrlQKN70Kuerc78hS2bf3YJOe/gIr8IwXqHpMIyBzXDFAgCzzdABtXBaFiIz0KntZSi5sUDRmD7LrwSQrcwKFCUqUYa8iZbiRjc/amXU4x4Q1/gEtVUb1CWalGB0x7B1m+jNnu+QxLlwJZWKAcdzwXXUlDnV5i0c5gjEmTeRtipYla1wqvlEzqKWp8haTOxgIEjBofznym0FgWMFAiV5PoumgBbTTg8L+H/iQRMWEkKvDFNSfWR4hVsJiUv+J4Xn2qlCTDaWfQLFfyoAMxN5i8go82xwiuMdA3H9k7JbGdWlFRrAqKQj7wAWb1bMlKWWEICAkJbg5yIFAd7zo1S3ysvKOwfcIZbPNiATJ9nQmvBHo7VDs761zpp9e+fyxme50K5xVe4YifXYBEHw8WyqdSgHRJEo9FicAkJV9Eyvr+EjJfBfDW7hMxm0WB+ewmZx6NJNLmILMPJ+GIFCyhiPL+IfHc/q0kc39qe+KcTYYl5dv+SbmWuVY81EXPEMklQb20eZt94ZPJ5RrjDMwzzFJ8jaZ05sN9vAMUQpStosANsc1hSEFUtcGnXdI3ktuNtPeRFK8y8TycuM26x/BMGZ9WgB4mq5ro4lzCO20jC9RNhzq7qLHVRHF6AMwim8Je9tOfUHc8h0SA/O3aekJWx9cW8P/9shIeR0veKoKn3sjOmRvlUpka1eI2qqhF/tg2nHiXbnQ5NmIavAn7S2Y9sG7VYZLGowewHys1mwbtddLbI2c78Bs426Gyxs8Wdbehsw842craRse1g3ElK+DPcQ7c09lJQKg64eOjwVyb3SuUERJAeWdY9PjcNRomCwVDBO6WFdNgfFgvjpBD5o3ls48Y+nIwXy8mg0XY4tO+btrMDjvYrLmdI4aJRt/tpffcvAAAA//8DAFBLAwQUAAYACAAAACEAQMH/8TkBAAAjAwAAFAAAAHdvcmQvd2ViU2V0dGluZ3MueG1snNJfT8IwEADwdxO/w9J36CCykIVBYgzGF2OifoDS3aCx7S294sBP720CYnhhvvT//XLXdrbYOZt8QiCDvhCjYSoS8BpL49eFeH9bDqYioah8qSx6KMQeSCzmtzezJm9g9Qox8klKWPGUO12ITYx1LiXpDThFQ6zB82aFwanI07CWToWPbT3Q6GoVzcpYE/dynKaZODDhGgWrymh4QL114GMXLwNYFtHTxtR01JprtAZDWQfUQMT1OPvjOWX8iRndXUDO6ICEVRxyMYeMOorDR2k3cvYXmPQDxhdApmHXz5geDMmR544p+znZyTHlmfO/ZM4Agn7E5JgH7V1bkdP509pjUCvLEr9RwtecdHDbcrZt1w35+Jx/LdbROPMFSwz3ARuCINtlZS02L8+PPJF/vvb8GwAA//8DAFBLAwQUAAYACAAAACEAOdtFTLkFAAAnWgAAEgAAAHdvcmQvbnVtYmVyaW5nLnhtbOyczW7qRhiG95V6D8j7xP8/oEOOwECV6rQ60knV9WAGsGKPrbGB0FV7Ke266q430EvpDfQWOuOxzZ9DbIMw5MwmDuP5Xs/3zjfDk0nCh48vvtdaQhy5AeoK8r0ktCBygomLZl3hp6fRnSW0ohigCfACBLvCGkbCx4dvv/mw6qCFP4aYdGwRDRR1VqHTFeZxHHZEMXLm0AfRve86OIiCaXzvBL4YTKeuA8VVgCeiIslS8l2IAwdGEdGxAVqCSEjlnJdyahMMViSYCmqiMwc4hi8bDbmyiC62RetQSKkhRDJU5EMptbKUIdJRHQhptYTIqA6U9HpKBckZ9ZSUQyWznpJ6qGTVUzooJ/+wwIMQInJzGmAfxOQlnok+wM+L8I4IhyB2x67nxmuiKRmZDHDRc40RkahcwVcnlRVM0Q8m0FMnmUrQFRYYddL4uzyeDr3D4tNLFoHL5M9CBoGz8CGKk8xFDD3iRYCiuRvmK9yvq0ZuzjOR5bEklr6X9VuFcsnl8tr2NGBWbgTLDD/13/fYyI8rylKJGaESeUSZIew+MxuJT6pw8+Ba1myZK5fcQDIB5UDAcGDJDT/TsFIN0dmsUKrjllwamQ6bFarjboyVS+5j+4PZEohgNQk9G0e09rcyCmenle13OFiEGzX3NLXHzSa0ojxQQSst/+0lGZ02mC9zEJK9yXc6jzMUYDD2yIhIMbdIPbaSGaBfybTSS/ItfGnRjUB4IPwCxlGMgRP/uPBbO68eSQERDiIiHQwJ/GDayFCnN40h7mMInmkXqoIiKt9ZAo+0jJS+ItuKINI7/sKL3U9wCb2ndQizPkmrR1tZr9gPveyeatvSUJE0dsdb0hsuuWTPSsaSdZZZL0JhIz9vHC88D8Z5/BN8yW/9++sfefv3TtbqwWnaPfyM6cVFNB3a3BU0hdrQmQM0S3iQviZ9xbwzTi+jAMURNTFyXFJgP5PelCCjJLpHLNpvcxGRn8ApIG6wx4+Tr25uJWuNfskalCRfMX2mmKSx75J8ukv//F7VJEu7nEkbO2T9bTuU0+3477e/q/ohK8alDDmevnqO9P+snL5hXUf6bJM7Mf2/qqavyNJ1pK83UvyKfrEt83j6RiPFr7QvthkeT99spPhV9Uq2PquR4lfNxrY+cQfg6DOO0p1ch+4Uua1LumWw/KvTXbsvGX1LS+O3p+sMdJc+r/xkXRPblYEZznY7dnC2Oz19znbV0udsx9mOsx1nuwunX5HtlDpsp2rKSB5ItdlOaxu2aitWbms+Xfzk7kIndzXW9OXwjsMchzkOc4Xpc5hroPg5zHGYuwWYU2vBXNvWTcsasvyLYW6+HmN38sMRpDN7pqbpmpabm09a4l0cek5XsI2BNVRNu8Y0hl/itZeP55MbxZ8BBjMMwnnhPH8FJ3y5rZakS0N5dAZ2fl9nfrlBw/5Is4b9s7x5XDM4VrWI7hepRZImtSVJYlUFUQxidwnP9JPGLcPmvkHMsjMbdMs4um8QazmzQbcMrPsGXccSuyKk3TfoOpbYFUHvvkHXscRuB4vpLl4HiwdqXxqw/KufcQ7aQ0Oib/2ZrfmEvv8zTn6ayU8z+WkmP818M31+mtlA8fPTTH6aeQvYRjG3Mrbplq0aZttm+VfHNsM2FG3YTk9Dt6frDNhWY7FybOPYtsmeYxvHNo5tHNsaTZ9jWwPFfzvYRk+8K2ObOVBHqmFpLP/q2NYb9CRTVtL47el679jGIe317DmkNVD6HNI4pHFI45DWaPoc0o5DGv2te3VIG/ZNc9QbsPyrQxrZGwzLlL/Kf/vgZ2sc2zi2cWx7M32ObQ0UP8c2jm1Xgm0owTWUffIKbdphtywjNZVDBWHsDbQwLPmf3VfC2BtPYVj2x+RFYQefD7gJM4+EsY2uMEw7EsY2iMKw5JMEXwljC6swLJvrojBWkIVhGcYlYezKIPrhfwAAAP//AwBQSwMEFAAGAAgAAAAhAPiVyO/8DgAA85kAAA8AAAB3b3JkL3N0eWxlcy54bWzsXd9zo0YSfr+q+x8oPSUPG/+QLTtbcVJr2T67btdxVt5L3eMIRhZnYHSA1uv89TczDAjUDKKHjuu8m6RqLQH9MczXX890A5qffvkSR95nnmahSM5GBz/sjzye+CIIk4ez0af7qzenIy/LWRKwSCT8bPTMs9EvP//9bz89vc3y54hnngRIsrexfzZa5vnq7d5e5i95zLIfxIoncudCpDHL5df0YS9m6eN69cYX8Yrl4TyMwvx573B/fzIyMGkfFLFYhD6/EP465kmu7fdSHklEkWTLcJWVaE990J5EGqxS4fMskxcdRwVezMKkgjk4AkBx6KciE4v8B3kxpkUaSpof7OtPcbQBOMYBHAKAic+/4DBODcaetKzjhAEOZ1LhhEENx60xNYCM4yCOy3Zkz7G6oth/e/OQiJTNI4kkOfJkN3saWP0rW6v+6I/y8J+lwwbCv+ALto7yTH1N71Lz1XzTf65Ekmfe01uW+WF4L9slweNQnuf6XZKFI7mHsyx/l4WsvvPSbFP7l+rAVks/y2ubz8MgHO2pk2Z/yJ2fWXQ2Ojwqt0xVIxrbIpY8lNt48mZ6W2/M2eiPpdk0l7hnI5a+mb1Thnvm2oq/tSteVd+Ko7a6R+pJqmtWiFzu5Yv3wn/kwSyXO85G++pUcuOnm7s0FKkU8tnoxx/NxhmPw+swCHhSOzBZhgH/fcmTTxkPNtt/u9JiNBt8sU7k5/HJRFMWZcHlF5+vlLTl3oSp3rtVBpE6eh1uTq7N/1uCHZg+a7Nfcqbim3ewDaGbj4I4VBZZ7WrbMddb166PQp1o/FInOnqpEx2/1IkmL3Wik5c60elLnUjD/JknCpOAfymECE8DUHfhWNSIxrGIDY1j0RIaxyIVNI5FCWgci6OjcSx+jMaxuCkCJxe+zQtrzj62eHs37u4xwg1395Dghrt7BHDD3R3w3XB3x3c33N3h3A13d/R2w90drPG4xVTLu5EyS/LBKlsIkSci517OvwxHY4nE0kkfDZ4a9HhKcpEEMEVkMwPxYDSf6e+7PUSL1H08z1U25omFtwgf1inPBjecJ595JLN2jwWBxCMETHm+Ti094uLTKV/wlCc+p3RsOtAoTLiXrOM5gW+u2AMZFk8C4u4rEUmCQuXQbJ0vlUhCAqeOmZ+K4U0TjCw+vA+z4X2lQLzzdRRxIqxbGhfTWMNzAw0zPDXQMMMzAw0zPDGocUbVRQaNqKcMGlGHGTSifiv8k6rfDBpRvxk0on4zaMP77T7MIx3i67OOg/61u2kkVJl+cDtm4UPC5ARg+HBjaqbeHUvZQ8pWS0+VkNth69eMPc+5CJ69e4oxrUKimtdrF5nKqw6T9fAObaBRiavCI5JXhUcksApvuMQ+yGmymqBd0+Qzs/U8bxWtRuol2hmL1sWEdrjaWD7cwzYCuArTjEwG7bAEHnyrprOKTorIt2nl8IZtsIbLajsqkTbPQBK0MhL+I00Yvn5e8VSmZY+Dka5EFIknHtAhzvJUFL5Wl/yhpqSX5C/j1ZJloc6VGhD9h/ryBr/3ga0GX9BdxMKEhrfLNzELI49uBnF9/+G9dy9WKs1UHUMDeC7yXMRkmKYS+N3vfP49TQPfySQ4eSa62ndE5SENNg0JBpkCSQRESHKaGSYhyRiq8f7Jn+eCpQEN2l3Ki2dqck6EOGPxqph0EGhLxsUnGX8IZkMa718sDVVdiEpU9yRgtbJhtp7/h/vDQ92t8EgqQ7+uc11/1FNdbU0HN3ya0IAbPkXQbMrhQfkvwcU24IZfbAOO6mKnEcuy0HoL1RmP6nJLPOrrHZ78GTwRiXSxjug6sAQk68ESkKwLRbSOk4zyijUe4QVrPOrrJXQZjUdQktN4/0jDgIwMDUbFhAajokGDUXGgwUgJGP6ETg1s+GM6NbDhz+oUYERTgBoYlZ+RDv9Ed3lqYFR+psGo/EyDUfmZBqPys/GFxxcLOQmmG2JqkFQ+V4OkG2iSnMcrkbL0mQjyMuIPjKBAWqDdpWKhXrYQSfEQNwGkqlFHhJPtAo6K5N/5nKxpCouyXQQVURZFQhDV1jYDjrZsPru2y0y/czG4CXcR8/lSRAFPLddkt5X58mzFfFOmB7f7epU934cPy9ybLatqfx1msr/TskzYG2a7T9jW55PDDrMPPAjXcdlQ+DLFZNzfWHt0w7h856XDeDOTaFge97SE55zsttzMkhuWJz0t4TlPe1pqnTYsu/RwwdLHVkc46fKfKsezON9JlxdVxq2n7XKkyrLNBU+6vKghFe+d76u7BZCdfpqx2/cTj90eoyI7CkZOdpTeurJDdAnsI/8cqpEdEzT1+aqnJ0Dc15PoXpHzt7Uo6vaNG079X+q6kROnJONeK864/42rRpSx92PvcGOH6B137BC9A5AdolckspqjQpIdpXdsskP0DlJ2CHS0giMCLlpBe1y0gvYu0QqiuESrAbMAO0Tv6YAdAi1UCIEW6oCZgh0CJVRg7iRUiIIWKoRACxVCoIUKJ2A4oUJ7nFChvYtQIYqLUCEKWqgQAi1UCIEWKoRACxVCoIXqOLe3mjsJFaKghQoh0EKFEGih6vniAKFCe5xQob2LUCGKi1AhClqoEAItVAiBFiqEQAsVQqCFCiFQQgXmTkKFKGihQgi0UCEEWqjFq4buQoX2OKFCexehQhQXoUIUtFAhBFqoEAItVAiBFiqEQAsVQqCECsydhApR0EKFEGihQgi0UPXNwgFChfY4oUJ7F6FCFBehQhS0UCEEWqgQAi1UCIEWKoRACxVCoIQKzJ2EClHQQoUQaKFCiC7/NLcobY/ZH+CrntYn9vvfujKN+lh/lbsONe4PVbbKjtX/XYRzIR691hcPxzrf6AcSzqNQ6BK15bZ6HVc/EoG68fnrtPsNnzr6wB9dMu9C6HumAPyoryWoqRx1uXzdEiR5R12eXrcEs86jruhbtwTD4FFX0NW6LB9KkcMRMO4KMzXjA4t5V7SumcMu7orRNUPYw12RuWYIO7grHtcMjz0VnLetj3v206R6vhQgdLljDeHEjtDllpCrMhxDYfQlzY7Qlz07Ql8a7QgoPq0weGLtUGiG7VBuVEOZYal2F6odAUs1RHCiGsC4Uw2hnKmGUG5Uw8CIpRoiYKl2D852BCeqAYw71RDKmWoI5UY1HMqwVEMELNUQAUv1wAHZCuNONYRyphpCuVENJ3dYqiEClmqIgKUaIjhRDWDcqYZQzlRDKDeqQZaMphoiYKmGCFiqIYIT1QDGnWoI5Uw1hOqiWldRGlSjGK6Z4yZhNUPcgFwzxAXnmqFDtlSzdsyWagiO2RLkquQcly3VSbMj9GXPjtCXRjsCik8rDJ5YOxSaYTuUG9W4bKmNaneh2hGwVOOyJSvVuGypk2pcttRJNS5bslONy5baqMZlS21UuwdnO4IT1bhsqZNqXLbUSTUuW7JTjcuW2qjGZUttVOOypTaqBw7IVhh3qnHZUifVuGzJTjUuW2qjGpcttVGNy5baqMZlS1aqcdlSJ9W4bKmTaly2ZKcaly21UY3LltqoxmVLbVTjsiUr1bhsqZNqXLbUSTUuW/ogTUKCn4CaxSzNPbrfi7tm2TJnw3+c8FOS8kxEn3ng0V7qe9RV7j01lr9S2Hq1O3l8LvtM/QJ67XWloPgFWAOoD7wJqmWqlLFqiWeW7jKbdYPN7Vr9Oc1kTm2O2d8/Pz8cT43UVsXSZFnxZqk8Rv1a0dloPNGvJKkvH9dqDTS2zoVpvTbZM43Z0fyqweb+8wFo8mbBLN2eOZM99avqYXBBifqxxZbtysnK7eVppkuWFns37l8eYwRu75+Lo/3ji8tG/zxyvrqV59fb1BfJOc/0t03XzdXvlHG1qJoRvyh+/On956gCr/ehZWE4qcRyrTrv3+yaNxaGa92pV4Vr3eNnZ6P7MOaZd8ufvI8iZon3nemkzJvOvje9rv/1VfjYdIP6T2HodeV0aDkbqd+9N0xtFpYrb5TXF5Yb60hTWx/OxVsOrd5i4hiNtxz28JamlP9kB7L7TxlBvir/GZuJQ2NhQr1toP+Mrf5jHgqh8Z/x6/GfUpVfl/9QxJojq6+Y6EbjK0evx1e0Rv5ffSWcFhfk7DPlSDzEZ46tPmMeAKPxmePX4zNaK19DfBnoGcUKs22eYcY6Gs+YvB7P0Ir4yzMeTqyeYTIyGs84eT2eUc70vppxZqCHnFo9xBS3aDzk9PV4iFbGq4gdhyfq/3bPKDfeh2oV8gtDZiPp6ek+vmSO+eYnxy0VIrN0UPXbN3rhoG3HsqwvZHGKchJVlbnafcTe7lzVKTvarOuYnaWtotRp9VrjtrtaKNszjwonkh9uEuXET2aV96KlwRdWQMn9Ux5FH1hxtFjZD434QmlP7j3Y1780ubV/XiyaYLVPdXXdCrDXbEzxtdtPimUUw+K1D2slUZWQW7pbv4M0tKd7+rC/zmTXzNQB2+1rVPS2W2l2egfeJphtRcdWHdhiovFwazy0B7y/KnlIQouim43QQyJCTZ3wmyV0SGkNSWhRBbMROiYi1BTuvl1C/xw1FmUpG3lHROSZ6PLqyXup4hOSxKJOZCPxmIhEU9r6phRITlVRuLFRNSGiygT/v6gaQlVRSbFRdUJElSn+fJOhkZyyorRho+yUiDKTwH9d6nqZAkaj/tXBp17ibptHvbGNvX5Pv5xe7k+vzoujTEFpdR7U0nt9nFoI2qyb9oe6raE+rJhftlD32eapmCr532GrPwPbqjDgdOaybOBwalVSM5eeLasu8iPOCqHVjpZfF2Ek916eXE4u9YNl2heu9MY58x8fUrFOgn43mKciyUTE9O+BbFx8FsaztX4oy3h2/bBWl9aLsFbuHDFdT9QXwZM3n2a0weUmUWXJVpes7cKFFWuRrZ//EnVv0eagCgKJSCof0mHb+JD+DByQ1HVoWNwMCNVTiNuUbfYMZayshbWUGZvMTS8Pfjw1CaxhrjlMHk/G002YNbF32WzoujzaSH1A52weiCyfh9zupJZHJql6a3eNFtd5k/3jy+Mp1iMPLq4uLhzGrKoPVZF08/vy2/2nn87d7G7ru/qgBXtrbFJm1F2XZB0XH8Jo68kfve+msi5Ha2MAwnZPKZafsp//BwAA//8DAFBLAwQUAAYACAAAACEAzJJQVH0BAADxAgAAEQAIAWRvY1Byb3BzL2NvcmUueG1sIKIEASigAAEAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAjJLLTsMwEEX3SPxD5H1qJ+WlKE3FQ6yoQKIViJ2xJ60hsS17IPTvcZI2JYgFO4/n+GRy7Xz+VVfRJzivjJ6RZMJIBFoYqfR6RlbL2/iCRB65lrwyGmZkC57Mi+OjXNhMGAcPzlhwqMBHwaR9JuyMbBBtRqkXG6i5nwRCh2ZpXM0xlG5NLRfvfA00ZeyM1oBccuS0FcZ2MJKdUopBaT9c1QmkoFBBDRo9TSYJPbAIrvZ/Hug6P8ha4dbCn+i+OdBfXg1g0zSTZtqhYf6EPi/uHrtfjZVusxJAilyKDBVWUOT0sAwr//H6BgL77aEIa+GAo3HFQglnvCkxui9LJSBaeXAdvSfa7N9h2xgnffCMqoBJ8MIpi+FG+6+MNgJdcY+LcMWlAnm1LS5Pz9OzTvOr0bIOPlX7NoqkI4Yy3wXdDwUyCgFlfZz7ztP0+mZ5S4qUpUnMTuIpW7I0O00zxl7auUbnD8J6N8A/jdOMnYyNe0EfzfiRFt8AAAD//wMAUEsDBBQABgAIAAAAIQAiURHx1QEAAN4DAAAQAAgBZG9jUHJvcHMvYXBwLnhtbCCiBAEooAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJxTwW7bMAy9D9g/GLo3crKh6AJFxZBi6GFDA8Rtz5xMJ8JsSZDYINnXj7YTT9l2mk/vkfTTE0mp+2PXFgeMyXq3EvNZKQp0xtfW7VbiufpycyeKROBqaL3DlThhEvf6/Tu1iT5gJIupYAmXVmJPFJZSJrPHDtKM044zjY8dENO4k75prMEHb946dCQXZXkr8UjoaqxvwiQoRsXlgf5XtPam95deqlNgPa0q7EILhJrOYFZ7Oio5xVXlCdrKdqjnJccnpjaww6TnSo5AvfpYJ724U3JEar2HCIa4h3p++0HJjKvPIbTWAHF39Tdrok++oeJpsFz0/yuZlyi+xhbNW7R00mwjp+qrdaOREbCxCLsIYX92NzG1NdDimhugG2gTKvk7oB4R+uFuwPb+DrQ8oCEfi2R/8ngXovgOCfu2rcQBogVHYiwbyYDbkCjqylLL2hMfYF6WY/uxNzmC68KBDB4YX7sbTkhPDd+N/mF2npsdPIxWMzu5s8sZf6iufRfAcX/lhLjBP9JzqPxDvxrnHl4Hs6m/WtpvA5h+OJ/KfP5ZRm05ijUPdJrJFFCPfIPY9vr8r9thfan5O9Fv1Mv4XHnbZiV/wwpdYrwI0zvSvwAAAP//AwBQSwMEFAAGAAgAAAAhAIg/pb/hAAAAVQEAABgAKABjdXN0b21YbWwvaXRlbVByb3BzMS54bWwgoiQAKKAgAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAnJDBasMwEETvhf6D2bsiObFdEyyHuE4g19JCroq8tgWWZCS5tJT+e2V6So89LbPDzhu2OnzoKXlH55U1HNINgwSNtJ0yA4e31zMpIfFBmE5M1iAHY+FQPz5Und93IggfrMNLQJ3EhYrz0nL4ykvW5E87Rsr2nJLilDXkmKUNKTKWt8fnU8pY8Q1JRJsY4zmMIcx7Sr0cUQu/sTOaaPbWaRGidAO1fa8ktlYuGk2g25hA5RLx+qonqNc+v9cv2Pt7uVZbnPov5aZuk7KDE/P4CbSu6B/Uqu9eUf8AAAD//wMAUEsDBBQABgAIAAAAIQDBJ8sItgAAACEBAAATACgAY3VzdG9tWG1sL2l0ZW0xLnhtbCCiJAAooCAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACskE0OgjAQRq9CegCKLlgQfmKiWzEhcV/KAE3aGdIOBm5v1egJXE7mfS/zTdlsziYP8MEQVuKQZiIJrHBQlhAqgSSauuyLjlavISSRxlD0lZiZl0LKoGdwKqS0AMbdSN4pjqOfJI2j0XAmvTpAlscsy2Vvemto8mqZd/GR/UfVgQXNMHS823i2PN1Ondl4vgyGY7P2LWjRGoR0CzYGXuBVuQhHViT37wtyUZfyV7h+AgAA//8DAFBLAwQUAAYACAAAACEAdD85esIAAAAoAQAAHgAIAWN1c3RvbVhtbC9fcmVscy9pdGVtMS54bWwucmVscyCiBAEooAABAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAIzPsYrDMAwG4P3g3sFob5zcUMoRp0spdDtKDroaR0lMY8tYamnfvuamK3ToKIn/+1G7vYVFXTGzp2igqWpQGB0NPk4Gfvv9agOKxcbBLhTRwB0Ztt3nR3vExUoJ8ewTq6JENjCLpG+t2c0YLFeUMJbLSDlYKWOedLLubCfUX3W91vm/Ad2TqQ6DgXwYGlD9PeE7No2jd7gjdwkY5UWFdhcWCqew/GQqjaq3eUIx4AXD36qpigm6a/XTf90DAAD//wMAUEsDBBQABgAIAAAAIQDrgGBMUwMAAI8OAAASAAAAd29yZC9mb250VGFibGUueG1szJbPb9MwFMfvSPwPUU7jwJqkXZdV66Y2WzQk2IEVAUc3cVqL2I7itF3/AA6IE+LI38C4gwb/DNPYf8FznLRZm25LQbBGzY9n+5vnT57f8+7+KQ21MY4F4aytm5uGrmHmcZ+wQVt/0XMf27omEsR8FHKG2/oUC31/7+GD3Ukr4CwRGoxnokW9tj5MkqhVqwlviCkSmzzCDBoDHlOUwGM8qFEUvxlFjz1OI5SQPglJMq1ZhtHUM5n4Lio8CIiHD7g3opgl6fhajENQ5EwMSSRytcld1CY89qOYe1gImDMNlR5FhM1kzMaSECVezAUPkk2YTOZRKgXDTSO9o+FcYKuagLUk0PTwaTUNO9OowciiDvGr6TRnOsQv6KznTEFA4GoSW7kfYkrljKjXejJgPEb9EJTgG2mAWUuF5Rm8lZf0FrrvZfGqTVoMURjwEj62DHKRNkWIcYFNaB2jsK0bW8bST6/Jjt4QxQJLmbRj40CZA0RJOM2tPvbAr4SMsWqNSOIN88Yxion0WTUJMoCGkegb8Fb1q+vKYsJyzN+tLNasT26pX7d4qY6tDGZmMQt94J01BWIJSI9QLLRjPNGec4pYKRYLjqZRBzwN+Ftw1yjFktO6jiVOdasQgaVoWB17e04km9syEfsmIoqH61Yj4qCQ9GOygoSbEpBHAzhYlUiICRGiEomOdNY6TGegSDSkwdjuVosN9bxTkcQBZoNXJAsKFCbHYM19vvz87vLrj2wyS5RMiBcIabhmRyklu1lGCY0SvgakbgFS3XbcbcftLEIym7dAknQrQnqWZy/tNTrCKmwWWF18P/t1/uXq09urbx9WEetCXMl4knGVnisQqx5X6XqyiivM6jhu3dmy1kFmVkS2kHO0jSOM0qSsOSePygAuJqmVDJsZvWyF/oUs5eMAjcLkxoQB+w8eovKSorzaWTNjUO7juMytgJxif/m7HsrSYamMN88XrjOzzPPFzu2Zs2q+OCH0ZFSaLS7O3v88/3gvskU2j0K5tWzbzadfOVv8WbnVNrrcn96PsGc86cUj3JtGeK1lkFcL7SkZDJPVNSNrvw+x8H8rR7bRKPAq226oovBvthuHEkenmD4caWmUbDfukD5u3XhlN2LvNwAAAP//AwBQSwECLQAUAAYACAAAACEAZPVj7oEBAAApBgAAEwAAAAAAAAAAAAAAAAAAAAAAW0NvbnRlbnRfVHlwZXNdLnhtbFBLAQItABQABgAIAAAAIQAekRq37wAAAE4CAAALAAAAAAAAAAAAAAAAALoDAABfcmVscy8ucmVsc1BLAQItABQABgAIAAAAIQAzwlu/QQEAAOcEAAAcAAAAAAAAAAAAAAAAANoGAAB3b3JkL19yZWxzL2RvY3VtZW50LnhtbC5yZWxzUEsBAi0AFAAGAAgAAAAhAE4yjpAWBgAApiQAABEAAAAAAAAAAAAAAAAAXQkAAHdvcmQvZG9jdW1lbnQueG1sUEsBAi0AFAAGAAgAAAAhALb0Z5jSBgAAySAAABUAAAAAAAAAAAAAAAAAog8AAHdvcmQvdGhlbWUvdGhlbWUxLnhtbFBLAQItABQABgAIAAAAIQDlI7CA9QMAAKALAAARAAAAAAAAAAAAAAAAAKcWAAB3b3JkL3NldHRpbmdzLnhtbFBLAQItABQABgAIAAAAIQBAwf/xOQEAACMDAAAUAAAAAAAAAAAAAAAAAMsaAAB3b3JkL3dlYlNldHRpbmdzLnhtbFBLAQItABQABgAIAAAAIQA520VMuQUAACdaAAASAAAAAAAAAAAAAAAAADYcAAB3b3JkL251bWJlcmluZy54bWxQSwECLQAUAAYACAAAACEA+JXI7/wOAADzmQAADwAAAAAAAAAAAAAAAAAfIgAAd29yZC9zdHlsZXMueG1sUEsBAi0AFAAGAAgAAAAhAMySUFR9AQAA8QIAABEAAAAAAAAAAAAAAAAASDEAAGRvY1Byb3BzL2NvcmUueG1sUEsBAi0AFAAGAAgAAAAhACJREfHVAQAA3gMAABAAAAAAAAAAAAAAAAAA/DMAAGRvY1Byb3BzL2FwcC54bWxQSwECLQAUAAYACAAAACEAiD+lv+EAAABVAQAAGAAAAAAAAAAAAAAAAAAHNwAAY3VzdG9tWG1sL2l0ZW1Qcm9wczEueG1sUEsBAi0AFAAGAAgAAAAhAMEnywi2AAAAIQEAABMAAAAAAAAAAAAAAAAARjgAAGN1c3RvbVhtbC9pdGVtMS54bWxQSwECLQAUAAYACAAAACEAdD85esIAAAAoAQAAHgAAAAAAAAAAAAAAAABVOQAAY3VzdG9tWG1sL19yZWxzL2l0ZW0xLnhtbC5yZWxzUEsBAi0AFAAGAAgAAAAhAOuAYExTAwAAjw4AABIAAAAAAAAAAAAAAAAAWzsAAHdvcmQvZm9udFRhYmxlLnhtbFBLBQYAAAAADwAPANQDAADePgAAAAA=",YG=()=>Dm(QG);async function JG(n){return new Promise((e,t)=>{const o=new Image;o.onload=()=>{e({width:o.naturalWidth,height:o.naturalHeight})},o.onerror=t,o.src=n})}async function wk(n,e){if(n.width&&n.height)return{width:n.width,height:n.height,buffer:e};const t=await Ul(new File([e],"",{})),o=await JG(t);return o.width===void 0||o.height===void 0?{width:345,height:230,buffer:e}:n.width||n.height?{width:n.width||o.width*n.height/o.height,height:n.height||o.height*n.width/o.width,buffer:e}:{width:o.width,height:o.height,buffer:e}}function KG(n,e){let t=n.filter(s=>s!=null);const o=e-(t.length-1)*20,r=.87,i=t.reduce((s,l)=>s+l.width,0);return i>o&&(t=t.map(s=>({width:s.width*o/i,height:s.height*o/i,buffer:s.buffer}))),t.map(s=>({width:s.width*r,height:s.height*r,buffer:s.buffer}))}function Bk(n=[0,1,2,3,4,5,6,7],e=1){return n.map(t=>{let o;switch(t%3){case 0:o=ge.LevelFormat.DECIMAL;break;case 1:o=ge.LevelFormat.LOWER_LETTER;break;default:o=ge.LevelFormat.LOWER_ROMAN;break}return{level:t,format:o,text:`%${t+1}. `,alignment:ge.AlignmentType.START,start:e,style:{paragraph:{indent:{left:ge.convertInchesToTwip(.3*(t+1)),hanging:ge.convertInchesToTwip(.2)}}}}})}function XG(){return[0,1,2,3,4,5,6,7].map(n=>{let e;switch(n%3){case 0:e="\u2022";break;case 1:e="\u25E6";break;default:e="\u25AA";break}return{level:n,format:ge.LevelFormat.BULLET,text:e,alignment:ge.AlignmentType.START,style:{paragraph:{indent:{left:ge.convertInchesToTwip(.3*(n+1)),hanging:ge.convertInchesToTwip(.2)}}}}})}function eZ(){return[0,1,2,3,4,5,6,7].map(n=>({level:n,format:ge.LevelFormat.BULLET,text:"\u2611",alignment:ge.AlignmentType.START,style:{paragraph:{indent:{left:ge.convertInchesToTwip(.3*(n+1)),hanging:ge.convertInchesToTwip(.2)}}}}))}function tZ(){return[0,1,2,3,4,5,6,7].map(n=>({level:n,format:ge.LevelFormat.BULLET,text:"\u2610",alignment:ge.AlignmentType.START,style:{paragraph:{indent:{left:ge.convertInchesToTwip(.3*(n+1)),hanging:ge.convertInchesToTwip(.2)}}}}))}var Hu=(n=>(n.NUMBERING="number-numbering-reference",n.BULLET="number-bullet-reference",n.CHECKED="checked-bullet-reference",n.UNCHECKED="unchecked-bullet-reference",n))(Hu||{});const nZ=[{levels:Bk(),reference:"number-numbering-reference"},{levels:XG(),reference:"number-bullet-reference"},{levels:eZ(),reference:"checked-bullet-reference"},{levels:tZ(),reference:"unchecked-bullet-reference"}];function oZ(n){switch(n){case"style-color-0":return"d83931";case"style-color-1":return"de7802";case"style-color-2":return"dc9b04";case"style-color-3":return"2ea121";case"style-color-4":return"245bdb";case"style-color-5":return"6425d0";case"style-color-6":return"8f959e";default:return}}function rZ(n){switch(n){case"style-bg-color-1":case"style-bg-color-2":case"style-bg-color-8":case"style-bg-color-9":return"yellow";case"style-bg-color-0":case"style-bg-color-5":return"magenta";case"style-bg-color-3":return"green";case"style-bg-color-4":case"style-bg-color-11":return"blue";case"style-bg-color-6":return"lightGray";case"style-bg-color-7":return"red";case"style-bg-color-10":return"darkGreen";case"style-bg-color-12":return"darkMagenta";case"style-bg-color-13":return"darkGray";default:return}}function iZ(n){switch(n){case"style-bg-color-0":return"fbbab6";case"style-bg-color-1":return"ffdcb0";case"style-bg-color-2":return"fff7a0";case"style-bg-color-3":return"ceefc5";case"style-bg-color-4":return"d1ddfb";case"style-bg-color-5":return"d9cbf8";case"style-bg-color-6":return"eaeaea";case"style-bg-color-7":return"fe837c";case"style-bg-color-8":return"ffbd6a";case"style-bg-color-9":return"ffe662";case"style-bg-color-10":return"a8f393";case"style-bg-color-11":return"98b5ff";case"style-bg-color-12":return"b394f8";case"style-bg-color-13":return"b1b1b1";default:return}}const sZ=/rgb\((\d+),\s*(\d+),\s*(\d+)\)/;function Ek(n){if(typeof n=="string"&&n.length>0){if(n[0]==="#")return n.substring(1);const e=n.match(sZ);if(e){const t=s=>{let l=Number(s).toString(16);return l.length<2&&(l=`0${l}`),l},o=t(e[1]),r=t(e[2]),i=t(e[3]);return`${o}${r}${i}`}if(n==="red")return"FF0000";if(n==="green")return"00FF00";if(n==="blue")return"0000FF"}}function en(n,e){if(n&&n.attributes&&n.attributes[e])return n.attributes[e];if(n&&n.attributes&&n.attributes.box&&n.attributes.inputType&&e==="style-underline")return!0}function xk(n,e,t){for(let o=0;o<=t;++o){const r=`${e}${o}`;if(en(n,r))return r}}function r1(n,e,t){n.attributes=n.attributes||{},n.attributes[e]=t}function Q2(n){return n==="image"||n==="drawio"||n==="plantuml"||n==="mermaid"||n==="flowchart"}function Ik(n){return n&&n.startsWith("//")?`https:${n}`:n&&!n.startsWith("http://")&&!n.startsWith("https://")?`https://${n}`:n}function lZ(n){const e=en(n,"inlineStyle");if(e==null)return;const t=e.split(";");for(const o of t){const r=o.split(":");if(r.length!==2)continue;const i=r[0].trim().toLowerCase(),s=r[1].trim().toLowerCase();i==="font-size"&&r1(n,"inline-style-font-size",s),i==="color"&&r1(n,"inline-style-color",s),i==="background-color"&&r1(n,"inline-style-background-color",s),i==="font-family"&&r1(n,"inline-style-font-family",s)}}function cZ(n,e){if(e==null)return n==null?void 0:n.normal;if(n)return n[`heading${e}`]}function aZ(n){const e=`${en(n,"inline-style-font-size")}`;if(e&&e.indexOf("px")>0)return+e.replace(/px/g,"")}function uZ(n){if(n.attributes&&n.attributes.box&&n.attributes.text)return` ${n.attributes.text} `;if(n.attributes&&n.attributes.box&&n.attributes.inputType)return n.attributes.value?`${n.attributes.value}`:" "}function dZ(n){if(n.attributes&&n.attributes.box&&n.attributes.text)return` @${n.attributes.text} `}function hZ(n){return en(n,"inline-style-font-family")}function fZ(n){const e=en(n,"inline-style-background-color");return Ek(e)}function mZ(n){const e=en(n,"inline-style-color");return Ek(e)}function gZ(n){lZ(n);const e=en(n,"type")==="mention";return{box:n.attributes&&n.attributes.box?n.attributes:void 0,inlineCode:!!en(n,"style-code"),link:Ik(en(n,"link")),size:aZ(n),text:e?dZ(n):uZ(n)||n.insert,bold:!!en(n,"style-bold"),underline:!!en(n,"style-underline"),italics:!!en(n,"style-italic"),strike:!!en(n,"style-strikethrough"),superScript:!!en(n,"style-super"),subScript:!!en(n,"style-sub"),math:en(n,"type")==="math"?en(n,"src"):void 0,mention:e,fontFamily:hZ(n),background:fZ(n),color:e?"338fe5":oZ(xk(n,"style-color-",6))||mZ(n),highlight:xk(n,"style-bg-color-",13)}}function pZ(){return[new ge.Paragraph({border:{top:{color:"auto",style:ge.BorderStyle.DASHED,size:4,space:1}},spacing:{before:300}}),new ge.Paragraph({spacing:{line:0}})]}function CZ(){return new ge.Paragraph({children:[new ge.TextRun({text:"[\u89C6\u9891\u6682\u4E0D\u652F\u6301\u5BFC\u51FA]",shading:{type:ge.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}})]})}function AZ(){return new ge.Paragraph({children:[new ge.TextRun({text:"[\u97F3\u9891\u6682\u4E0D\u652F\u6301\u5BFC\u51FA]",shading:{type:ge.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}})]})}function bZ(n,e){return new ge.Paragraph({children:[new ge.ExternalHyperlink({children:[new ge.TextRun({style:"Hyperlink",text:e||n})],link:n})]})}function Tk(n){if(n.heading!=null)return`Heading${n.heading}`}function Dk(n){if(n.alignment!=null){if(n.alignment==="center")return ge.AlignmentType.CENTER;if(n.alignment==="right")return ge.AlignmentType.RIGHT;if(n.alignment==="left")return ge.AlignmentType.LEFT}}function vZ(n){if(n.indent)return{left:ge.convertInchesToTwip(.3*n.indent-.2)};if(n.padding)return{left:ge.convertInchesToTwip(.3*n.padding)}}function yZ(n){return{type:ge.ShadingType.CLEAR,color:"FFFFFF",fill:n}}function kZ(n){const e=n.split(",");if(e.length!==0)return e[0].trim()}function Sk(n,e){let t;t=n.inlineCode?"InlineCode":void 0,t=n.link?"Hyperlink":t;const o=n.size||e,r=o!=null?Math.floor(o*1.5+.5):void 0;return new ge.TextRun({text:n.text,bold:n.bold||void 0,underline:n.underline?{type:ge.UnderlineType.SINGLE}:void 0,italics:n.italics||void 0,strike:n.strike||void 0,superScript:n.superScript||void 0,subScript:n.subScript||void 0,size:r,style:t,font:n.fontFamily?kZ(n.fontFamily):void 0,shading:n.background?yZ(n.background):void 0,color:n.color,highlight:rZ(n.highlight)})}function wZ(n,e){if(n.link)return new ge.ExternalHyperlink({children:[Sk(n,e)],link:n.link})}async function Lk(n,e,t,o,r){const i=await r(n,e,t);if(i==null)return;const s=await wk({width:o||0,height:0,src:t},i);return new ge.ImageRun({data:i,transformation:{width:s.width||100,height:s.height||20}})}function BZ(n){if(n.heading||n.heading)return n.heading}function EZ(n){if(n.align&&(n.align==="center"||n.align==="right"||n.align==="left"))return n.align}function xZ(n){if(n.textOnly===!0&&n.level!=null)return n.level}async function IZ(n,e){var o;const t=[];if(n.text&&Array.isArray(n.text)){for(let r=0;r<n.text.length;r++){const i=n.text[r];if(((o=i.attributes)==null?void 0:o.box)===!0&&e){const s=await e(i);if(s){n.text.splice(r+1,0,...s);continue}}t.push(gZ(i))}return t}}function TZ(n){if(n.type==="list"&&n.textOnly!==!0)return{checkbox:n.checkbox,groupId:n.groupId,ordered:!!n.ordered,level:n.level||1,start:n.start||0}}function DZ(n,e){if(n.type==="embed"&&n.embedType&&Q2(n.embedType)&&n.embedData&&n.embedData.src)return n.embedData.src.split("|").map(o=>{const r=e(o),i=n.embedData[`${r}_width`],s=n.embedData[`${r}_height`];return{src:o,width:i,height:s}})}function SZ(n){if(n.padding)return n.padding}function LZ(n){return!!(n.type==="embed"&&n.embedType&&Q2(n.embedType)&&n.embedData&&n.embedData.src)}async function i1(n,e,t){return{quoted:!!n.quoted,heading:BZ(n),alignment:EZ(n),indent:xZ(n),padding:SZ(n),texts:await IZ(n,t),list:TZ(n),images:DZ(n,e),border:LZ(n)}}async function MZ(n,e,t,o){const r=[];if(!n.children)return[];for(const i of n.children){const s=[];for(const l of e.blocks[i])s.push(await i1(l,t,o));r.push(s)}return r}const RZ=S("to-docx");function OZ(n,e){return Array(n).fill(0).map(()=>Array(e).fill(0).map(()=>({cellId:void 0,color:void 0,from:void 0,rowSpan:1,colSpan:1,width:0,originalWidth:void 0,align:void 0})))}function _Z(n,e,t,o){const r=!!n.hasColTitle,i=!!n.hasRowTitle,s=!!n.isStripeStyle,l="F5F8FB";for(let a=0;a<e;a++)for(let d=0;d<t;d++)(r&&d===0||i&&a===0||s&&a%2===1)&&(o[a][d].color=l)}function FZ(n){g(RZ,n.children,"no table children");const e=n.rows,t=n.cols,o=n.colsWidth;if(o)for(let s=0;s<o.length;s++)o[s]===0&&(o[s]=100);const r=OZ(e,t);let i=0;for(let s=0;s<e;++s)for(let l=0;l<t;++l){if(r[s][l].originalWidth=o?o[l]:void 0,r[s][l].from!==void 0)continue;const a=n.children[i];i+=1,r[s][l].cellId=a,r[s][l].color=iZ(n[`${a}_background`]),r[s][l].width=o?o[l]:100,r[s][l].align=n[`${a}_align`];const d=n[`${a}_rowSpan`]||1,h=n[`${a}_colSpan`]||1;if(r[s][l].rowSpan=d,r[s][l].colSpan=h,d>1||h>1){let p=0;for(let A=0;A<d;A++)for(let v=0;v<h;v++)A===0&&(p+=o?o[l+v]:80),!(A===0&&v===0)&&(r[s+A][l+v].from=[s,l]);r[s][l].width=p}}return _Z(n,e,t,r),r}async function PZ(n,e,t,o,r,i,s,l,a,d){async function h(v){if(l){const B=await l(r,i,v);if(B){await o.addDoc(n,B,d);return}}if(v.type==="text"||v.textOnly===!0){const B=await i1(v,s,a);await o.addTextBlock(B);return}if(v.type==="code"){const B=await MZ(v,t,s,a);await o.addCodeBlockObject(B);return}if(v.type==="list"&&v.textOnly!==!0){const B=await i1(v,s,a);await o.addListBlockObject(n,B);return}if(v.type==="embed"&&v.embedType){const B=v,D=B.embedData,I=B.embedType;if(Q2(I)){const _=await i1(v,s,a);await o.addImagesBlockObject(v,_,d)}else v.embedType==="hr"?o.addSeparatorBlock():v.embedType==="video"?o.addVideoPlaceholder():v.embedType==="audio"?o.addAudioPlaceholder():v.embedType==="webpage"?o.addHyperlinkParagraph(Ik(D.src),D.title):o.addOtherEmbedBlock(I,v.embedData);return}if(v.type==="table"){let B=[];if(v.colsWidth)B=v.colsWidth;else{const I=v.cols;B=new Array(I);for(let _=0;_<B.length;_++)B[_]=100;v.colsWidth=B}const D=FZ(v);await o.addTableMatrix(B,D,t),o.addEmptyParagraph()}}function p(v){const B=[];for(const{type:D,data:I}of v.embedData.exportSpec){if(D==="text"){const _={id:K(),text:[{insert:I}],type:"text"};B.push(_);continue}if(D==="image"){const _={id:K(),type:"embed",embedType:"image",align:"left",embedData:{src:I}};B.push(_);continue}if(D==="link"){const _={id:K(),type:"embed",embedType:"webpage",embedData:{src:I.url,title:I.title}};B.push(_);continue}}return B}function A(v){var B;return(B=v==null?void 0:v.embedData)!=null&&B.exportSpec?p(v):[v]}for(const v of e)for(const B of A(v))await h(B)}function NZ(){return{listMaxInst:1,listInstMap:{},listRefMap:{},levelConfigs:[]}}const $Z=S("to-docx");class HZ{constructor(e,t,o,r,i,s){m(this,"paragraphs");this.appId=e,this.docId=t,this.state=o,this.readImageFunc=r,this.convertBlocksFunc=i,this.defaultFontSize=s,this.paragraphs=[]}async addTextBlock(e){this.paragraphs.push(new ge.Paragraph({heading:Tk(e),alignment:Dk(e),children:await this.paragraphsFromBlockTexts(e),indent:vZ(e)}))}async addEmptyImagePlaceHolder(){this.paragraphs.push(new ge.Paragraph({text:`[${R.t("docx.imageExportFailed")}]`,shading:{type:ge.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}}))}async paragraphsFromBlockTexts(e){if(e.texts==null)return;const t=cZ(this.defaultFontSize,e.heading),o=[];for(const r of e.texts){if(r.link){const i=wZ(r,t);i&&o.push(i);continue}if(r.box&&r.box.type&&r.box.type==="br"){o.push(new ge.TextRun({text:"",break:1}));continue}if(r.box&&r.box.type&&r.box.type==="image"){const i=await Lk(this.appId,this.docId,r.box.src,r.box.width,this.readImageFunc);i&&o.push(i);continue}if(r.math){const i=await Lk(this.appId,this.docId,r.math,0,this.readImageFunc);i&&o.push(i);continue}o.push(Sk(r,t))}return o}async addCodeBlockObject(e){for(const t of e)for(const o of t){const r={style:ge.BorderStyle.SINGLE,color:"#DEDEDE"};this.paragraphs.push(new ge.Paragraph({style:"Code",border:{left:{...r},right:{...r},top:{...r},bottom:{...r}},children:await this.paragraphsFromBlockTexts(o)}))}}async addListBlockObject(e,t){if(t.list==null)return;let o;const r=t.list.checkbox?`${e}-${t.list.groupId}-${t.list.checkbox}`:`${e}-${t.list.groupId}`;if(this.state.listInstMap[r])o=this.state.listInstMap[r];else if(o=this.state.listMaxInst,this.state.listMaxInst+=1,this.state.listInstMap[r]=o,t.list.start>0&&t.list.ordered){const s=`number-numbering-reference-${o}`,l=Bk([t.list.level-1],t.list.start);this.state.levelConfigs.push({levels:l,reference:s,inst:o}),this.state.listRefMap[r]=s}else t.list.ordered?this.state.listRefMap[r]=Hu.NUMBERING:t.list.checkbox&&t.list.checkbox==="checked"?this.state.listRefMap[r]=Hu.CHECKED:t.list.checkbox&&t.list.checkbox==="unchecked"?this.state.listRefMap[r]=Hu.UNCHECKED:this.state.listRefMap[r]=Hu.BULLET;const i=Tk(t);t.texts&&this.paragraphs.push(new ge.Paragraph({heading:i,children:await this.paragraphsFromBlockTexts(t),numbering:{reference:this.state.listRefMap[r],level:t.list.level-1,instance:o}}))}imageDimWithBufferToImageRun(e){return new ge.ImageRun({data:e.buffer,transformation:{width:e.width,height:e.height}})}async addImagesBlockObject(e,t,o){if(t.images==null){if(e.type==="embed"&&e.embedType==="image"){const{src:a}=e.embedData;a||this.addEmptyImagePlaceHolder()}return}const r=[],i=await Promise.all(t.images.map(async a=>{const d=await this.readImageFunc(this.appId,this.docId,a.src);if(d)return wk(a,d);r.push(a.src)})),s=KG(i,o),l={style:ge.BorderStyle.SINGLE,color:"#DEDEDE"};s.length&&this.paragraphs.push(new ge.Paragraph({border:t.border?{left:{...l},right:{...l},top:{...l},bottom:{...l}}:void 0,alignment:Dk(t)||ge.AlignmentType.CENTER,children:s.map(a=>this.imageDimWithBufferToImageRun(a)).flatMap((a,d,h)=>a==null?[]:h.length-1!==d?[a,new ge.TextRun({text:" "})]:a)})),r.forEach(a=>{this.addHyperlinkParagraph(a)})}addSeparatorBlock(){pZ().forEach(e=>this.paragraphs.push(e))}addEmptyParagraph(){this.paragraphs.push(new ge.Paragraph(""))}addVideoPlaceholder(){this.paragraphs.push(CZ())}addAudioPlaceholder(){this.paragraphs.push(AZ())}addHyperlinkParagraph(e,t){e!=null&&this.paragraphs.push(bZ(e,t))}async addTableMatrix(e,t,o){const r=e.map(i=>i!==0?i*15:1500);this.paragraphs.push(new ge.Table({rows:await this.generateTableRows(t,o),columnWidths:r}))}async generateRowCells(e,t){const o=[];for(const r of e){const i=r.cellId;if(i===void 0)continue;const s=r.width*.9;o.push(new ge.TableCell({children:await this.convertBlocksFunc(i,t.blocks[i],t,this.appId,this.docId,this.state,s),columnSpan:r.colSpan,rowSpan:r.rowSpan,width:{type:ge.WidthType.DXA,size:r.width*15},shading:r.color?{fill:r.color,type:ge.ShadingType.CLEAR,color:"auto"}:void 0}))}return o}async generateTableRows(e,t){const o=[];for(const r of e)o.push(new ge.TableRow({children:await this.generateRowCells(r,t)}));return o}async addDoc(e,t,o){const r=await this.convertBlocksFunc(e,t.blocks.root,t,this.appId,this.docId,this.state,o);r&&(this.paragraphs=this.paragraphs.concat(r))}async addOtherEmbedBlock(){}}class jZ{constructor(e,t,o,r,i,s,l,a){m(this,"convertBlocks",async(e,t,o,r,i,s,l=720)=>{const a=new HZ(r,i,s,this.readImage,this.convertBlocks,this.defaultFontSize);return await PZ(e,t,o,a,r,i,this.md5HexFunc,this.getDocByBlock,this.getTextsByBox,l||720),a.paragraphs});this.templateData=e,this.docData=t,this.md5HexFunc=o,this.readImage=r,this.defaultFontSize=i,this.getDocByBlock=s,this.getTextsByBox=l,this.backgroundImageOptions=a}async convert(e,t){return this.snapshot2docx(this.docData,e,t)}async snapshot2docx(e,t,o){const r=new ge.ImportDotx,i=this.templateData?await r.extract(this.templateData):void 0,s=e.blocks.root;g($Z,s,"data must have blocks");const l=NZ(),a=await this.convertBlocks("blocks",s,e,t,o,l),d=this.backgroundImageOptions?{default:new ge.Header({children:[new ge.Paragraph({children:[new ge.ImageRun(this.backgroundImageOptions)]})]})}:{},h=new ge.Document({numbering:{config:[...nZ,...l.levelConfigs]},sections:[{headers:d,children:a,properties:{page:{size:{width:12240,height:15840},margin:{top:1440,bottom:1440,left:1440,right:1440}}}}]},{template:i});return ge.Packer.toBlob(h)}}async function UZ(n,e,t,o){const r=n.doc.buildResourceUrl(o,{withToken:!0});let i=await p7(r);if(!i)return;if(i.type.indexOf("/svg")!==-1){const l=await f7(i);l&&(i=new File([l],i.name))}return await i.arrayBuffer()}async function zZ(n,e,t){const o=n.editorBlocks.getBlockClass(t.type);if(o.toStandardDoc)return o.toStandardDoc(n,t,e)}async function VZ(n,e){const t=e.attributes,o=n.editorBoxes.getBoxClass(t.type);if(o.toStandardText)return o.toStandardText(n,t)}async function WZ(n,e){let{template:t,download:o,backgroundImageOptions:r}=e!=null?e:{};t||(t=YG());const i=n.doc.toJSON(),s=(p,A,v)=>UZ(n,p,A,v),l=async(p,A,v)=>zZ(n,i,v),a=async p=>VZ(n,p),h=await new jZ(t,i,Pd.default,s,void 0,l,a,r).convert("_appId","_docId");if(o){const p=URL.createObjectURL(h),A=document.createElement("a");A.setAttribute("download",`${g7(n)}.docx`),A.setAttribute("href",`${p}`),A.click(),A.remove()}return h}const Y2=S("create-editor");async function qZ(n,e){var s,l,a,d,h,p,A,v,B,D,I,_,M,H;g(Y2,n,"app does not exists"),e.lang&&R.setLang(e.lang),Ii.level=(s=e.logLevel)!=null?s:ha.DEBUG;const t=e.onReauth?async()=>{var fe;const z=e.user.userId,q=e.docId,re=await((fe=e.onReauth)==null?void 0:fe.call(e,z,q,e.permission));return{userId:z,docId:q,permission:e.permission,appId:e.appId,token:re,displayName:e.user.displayName,avatarUrl:e.user.avatarUrl}}:void 0,o={auth:{appId:e.appId,docId:e.docId,userId:e.user.userId,permission:e.permission,token:e.token,displayName:e.user.displayName,avatarUrl:e.user.avatarUrl},serverUrl:e.serverUrl,reauthFunc:t,disableLogout:e.disableLogout},r=await Ka.load(o),i=Ha(n,r,{id:e.id,scrollContainer:e==null?void 0:e.scrollContainer,enableComments:e==null?void 0:e.enableComments,components:{blocks:[...bk,...((l=e==null?void 0:e.components)==null?void 0:l.blocks)||[]],embeds:[...Z2,...((a=e.components)==null?void 0:a.embeds)||[]],boxes:[...vk,...((d=e.components)==null?void 0:d.boxes)||[]],commandProviders:[new Gp,...((h=e.components)==null?void 0:h.commandProviders)||[]],decorators:[new Lf,new yp],insertions:[wg],blockHooks:[new t2,new W7,...((p=e.components)==null?void 0:p.blockHooks)||[]],textRenders:[new o8,new C0],options:{...e.componentsOptions}},shortcuts:[vz,DN,CH,O0,Ry,LO,S0,nV,Lh,...e.shortcuts||[]],colors:["#338FE5","#24B47E","#F0A100","#E52727","#9678D3","#2CB2AE","#EB6414","#8AAB3F"]});if(i.editorCommandProviders.registerCommandProvider(new Ar(i)),i.input.addHandler(new qV),i.input.addHandler(new If),i.input.addHandler(new Q_),i.input.addHandler(new hH),i.input.addHandler(new bu(i,{headingLevel:1,titlePlaceholder:R.t("placeholder.common.title"),contentPlaceholder:R.t("placeholder.common.content"),readonlyTitlePlaceholder:R.t("placeholder.common.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0})),i.input.addHandler(new Af(i,(A=e.componentsOptions)==null?void 0:A.quickMenu)),i.input.addHandler(new c2(i)),i.input.addHandler(new f2(i)),i.input.addHandler(new EN),i.input.addHandler(new Ff),i.doc.registerCallback(new GV(i)),i.addCustom("remote-cursor",()=>new Qb(i)),i.addCustom("block-menu",z=>new Z7(z)),i.addCustom("editor-tooltip",()=>new bf(i)),e!=null&&e.enableComments&&i.addCustom("editor-comments",z=>new n8(z,new VG(z))),i.addCustom("create-options",()=>new J5(i,e)),i.addCustom("drop-target",()=>new Su(i)),i.addCustom("list-to-mindmap",()=>new hf(i)),i.addCustom("list-to-mention",()=>new fW(i)),i.addCustom("mobile-helper",()=>new SW(i)),i.addCustom("code-caret",()=>new BN(i)),i.addCustom("image-paste-handler",()=>new l2(i)),(v=e.componentsOptions)!=null&&v.mention){const z=e.componentsOptions.mention;i.addCustom("mention",()=>new _2(i,z))}if(i.addCustom("heading-collapse",()=>new F8(i)),pc.register(i),Su.register(i),nl.register(i),Xi.register(i),i.addListener("clickLink",(z,q,re)=>{var Be;if((Be=e==null?void 0:e.events)!=null&&Be.onClickLink){e.events.onClickLink(z,q,re);return}const fe=re.getAttribute("link");fe&&(z.readonly||q.ctrlKey||q.metaKey)&&window.open(fe,"_blank")}),(D=(B=e.componentsOptions)==null?void 0:B.remoteCarets)!=null&&D.onUserChanged){const z=(_=(I=e.componentsOptions)==null?void 0:I.remoteCarets)==null?void 0:_.onUserChanged;i.doc.getRemoteUsers().on("change",q=>{z(i,q)})}return(H=(M=e.componentsOptions)==null?void 0:M.templates)!=null&&H.templates.length&&(i.addListener("docChanged",()=>{o1(i)}),i.addListener("resize",()=>{o1(i,{reset:!0})}),setTimeout(()=>{o1(i)},100)),i.doc.registerCallback({onError:async z=>{if(z.code==="ResetDoc"){Y2.error(`reset doc: ${z.message}`);const q=await Ka.load(o);i.doc.reset(q)}}}),i}function GZ(n){return n.toJSON!==void 0}async function ZZ(n,e,t){var i,s,l,a,d;g(Y2,n,"app does not exists");const o=GZ(e)?e:new np(e,{serverUrl:t.serverUrl||""});t.lang&&R.setLang(t.lang);const r=Ha(n,o,{id:t.id,scrollContainer:t==null?void 0:t.scrollContainer,components:{blocks:[xf,Sf,U0,E9],commandProviders:[new Gp],decorators:[new Lf,new yp],embeds:[...Z2,...((i=t.components)==null?void 0:i.embeds)||[]],boxes:[T0,F2,u8,...((s=t.components)==null?void 0:s.boxes)||[]],insertions:[wg],blockHooks:[new t2,...((l=t.components)==null?void 0:l.blockHooks)||[]],textRenders:[new o8,new C0,...((a=t.components)==null?void 0:a.textRenders)||[]],options:{...t.componentsOptions}},shortcuts:[O0,Ry,S0,Lh]});return r.editorCommandProviders.registerCommandProvider(new Ar(r)),r.input.addHandler(new If),r.input.addHandler(new bu(r,{headingLevel:1,titlePlaceholder:R.t("placeholder.common.title"),contentPlaceholder:R.t("placeholder.common.content"),readonlyTitlePlaceholder:R.t("placeholder.local.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0})),r.input.addHandler(new Af(r,(d=t.componentsOptions)==null?void 0:d.quickMenu)),r.input.addHandler(new c2(r)),r.input.addHandler(new f2(r)),r.input.addHandler(new Ff),r.addCustom("block-menu",h=>new Z7(h)),r.addCustom("editor-tooltip",()=>new bf(r)),r.addCustom("image-paste-handler",()=>new l2(r)),t!=null&&t.enableComments&&r.addCustom("editor-comments",h=>new n8(h,new WG(h,o))),r.addListener("clickLink",(h,p,A)=>{var B;if((B=t==null?void 0:t.events)!=null&&B.onClickLink){t.events.onClickLink(h,p,A);return}const v=A.getAttribute("link");v&&(h.readonly||p.ctrlKey||p.metaKey)&&window.open(v,"_blank")}),pc.register(r),r}function QZ(n,e){var a;const t=n.doc;if(!((a=t.getVersionHelper)==null?void 0:a.call(t)))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 yk(i),l=n.addCustom("version-dialog",()=>new I8(n.doc,s));return l.show(e),l}b.tippy=zB,b.AnchorBox=A6,b.AuthError=Vh,b.AuthHeader=Ja,b.AutoScroll=Zd,b.BaseURLHeader=Wh,b.BasicCommands=y_,b.BlockExclusiveHook=W7,b.BlockLockerHook=t2,b.BlockLockerPasteHandler=Ff,b.BlockResizer=wu,b.BrBox=m6,b.CodeBlock=Sf,b.CodeLineBlock=U0,b.CodeTextDecorator=Lf,b.DefaultShortcuts=Lh,b.DocIdError=zS,b.DragDrop=dC,b.DrawioEmbed=z2,b.EditorBlocks=v4,b.EditorBoxes=p6,b.EditorCommandProviders=lb,b.EditorComplexBlockPosition=So,b.EditorComplexSelectionRange=or,b.EditorDecorators=k6,b.EditorEmbeds=k4,b.EditorInsertions=y6,b.EditorSimpleBlockPosition=jt,b.EditorSimpleSelectionRange=Zt,b.EmbedBlock=B4,b.EmbedBlockResizer=Fu,b.EnforceWithDocumentTitleHandler=bu,b.EventCallbacks=fa,b.FILL_CHAR=hI,b.FileExtError=VS,b.GroupOrder=D9,b.HeadingBlockScrollListener=lW,b.ImageBox=C6,b.InlineBoxCommandProvider=P9,b.InputtingInsertion=b6,b.LocalDoc=np,b.LogLevel=ha,b.Logger=Ii,b.MIN_DISTANCE_THRESHOLD=aC,b.ManualCloseDialog=ru,b.ManualMenu=zs,b.ManualToolbar=ou,b.MarkdownInputHandler=If,b.MaxUserError=mp,b.Mindmap=f0,b.OnesEditorAutoSuggest=Np,b.OnesEditorCustomDataWrapper=J5,b.OnesEditorExclusiveBlock=Xi,b.OnesEditorHoveringBlock=pt,b.OnesEditorQuickMenu=Af,b.OnesEditorToc=Pu,b.OnesEditorTocProvider=nl,b.OnesEditorToolbar=pc,b.OnesEditorTooltip=bf,b.OnesEditorVersionsDialog=I8,b.PermissionError=US,b.Popup=Xa,b.RemoteCarets=Qb,b.RemoteCaretsDecorator=yp,b.RemoteCaretsInsertion=wg,b.RemoteUsers=Fh,b.RequestReloadError=Ya,b.RichText=ln,b.ShareDBDoc=Ka,b.ShareDBDocVersionsProvider=yk,b.SimpleCache=X5,b.StandardEmbedBlockCommands=I2,b.TEXT_STYLE_BACKGROUND_COLOR_PREFIX=fg,b.TEXT_STYLE_COLOR_PREFIX=hg,b.TableBlock=xf,b.TableBlockCommandProvider=Gp,b.TableShortcuts=O0,b.TextBlock=In,b.TextBox=f6,b.TextStyleShortcuts=S0,b.TocEmbed=j8,b.ZERO_WIDTH_SPACE_CHAR=ma,b.abbreviation=Qd,b.addAttribute=dh,b.addClass=W,b.addCommentToBlock=Xf,b.addDays=ME,b.addMetaToDoc=Rh,b.addMonths=LE,b.animateScrollTo=km,b.applyPlaceholderToBlock=Tf,b.assert=g,b.autoShowHideTemplates=o1,b.blockToDoc=Kg,b.blockToHtml=Ig,b.blockToMarkdown=Tg,b.blockToText=bh,b.blocksToDoc=ST,b.clearAllSelection=t4,b.clientType=Kt,b.cloneBlock=Fi,b.cloneChildContainer=Ng,b.cloneDoc=$g,b.cloneText=o6,b.commentToShareDbComment=vp,b.compareElement=jd,b.comparePosition=Xm,b.complexBlockAdjustSelectionPos=oh,b.complexBlockFindNearestChildBlock=T4,b.complexBlockGeFirstSimpleChild=tg,b.complexBlockGetAllChildContainers=En,b.complexBlockGetBottomChildContainers=I4,b.complexBlockGetLastSimpleChild=Vl,b.complexBlockGetSelectedContainers=Os,b.complexBlockGetTopChildContainers=x4,b.containerToDoc=PA,b.continuousScroll=DC,b.convertBlockFrom=Xd,b.convertImageFileToPng=f7,b.convertImageSrcToPng=GP,b.copyBlockAttributes=_6,b.createBlockAnchor=Li,b.createBlockCaretAnchor=M4,b.createBlockContentElement=Ts,b.createBlockElement=VC,b.createBlockSimpleDocRange=gh,b.createBlockSimpleRange=yt,b.createBoxContentElement=GC,b.createBoxElement=WC,b.createBoxOp=Z4,b.createChildContainer=A4,b.createComplexBlockPosition=ft,b.createComplexDocPos=a6,b.createComplexDocRange=gI,b.createContainer=s6,b.createContainerElement=Gm,b.createDeleteOps=V4,b.createEditor=Ha,b.createEditorSelectionRange=Ut,b.createElement=w,b.createEmptyContainer=zr,b.createEmptyDoc=Ur,b.createEmptyTextBlockData=fh,b.createExpandedRange=$d,b.createIconButton=Hl,b.createImage=pm,b.createInsertOps=ah,b.createInsertionContentElement=YC,b.createInsertionElement=ZC,b.createLocalEditor=ZZ,b.createOnesEditor=qZ,b.createRange=eC,b.createRichText=Oi,b.createRootContainer=C4,b.createSimpleBlockPosition=se,b.createSimpleDocPos=c6,b.createTextBlockData=sr,b.createTextButton=Qs,b.createTextOp=lo,b.createTextWithReplaceSoftReturn=ag,b.daysAfter=Rm,b.deleteText=dg,b.diffDays=RE,b.disablePageScroll=wC,b.docToHtml=S6,b.docToHtmlFragment=vh,b.docToMarkdown=Ma,b.docToText=La,b.downloadImageToFile=p7,b.downloadObjectToFile=H2,b.downloadSvgToString=Q8,b.editLink=fu,b.editorAddComment=rz,b.editorAddTextAttribute=q6,b.editorAutoInsertBlock=F6,b.editorBreakTextBlock=Yl,b.editorClearCompositionText=O6,b.editorClearSelectedContents=Fg,b.editorCopyBlock=Oh,b.editorDeleteBlock=Og,b.editorDeleteBlockText=Mg,b.editorDeleteBlockWithoutChildren=wh,b.editorDeleteChildContainer=aT,b.editorDeleteChildContainers=P6,b.editorFocusToBlock=Pg,b.editorFocusToEnd=_A,b.editorGetBlockData=_i,b.editorGetBlockText=mn,b.editorGetBlockTextEx=Ch,b.editorGetBoxData=d6,b.editorHandleKeyboardEvent=jA,b.editorInsertBlock=Ql,b.editorInsertBoxToBlock=M6,b.editorInsertDoc=V6,b.editorInsertDocAt=Hg,b.editorInsertText=Lg,b.editorInsertTextToBlock=L6,b.editorInsertTextToBlockEx=Sg,b.editorMergeTextBlock=N6,b.editorMoveDown=rA,b.editorMoveEnd=mA,b.editorMoveHome=gA,b.editorMoveLeft=tA,b.editorMoveLineEnd=wA,b.editorMoveLineHome=kA,b.editorMovePageDown=DA,b.editorMovePageUp=TA,b.editorMoveRight=nA,b.editorMoveUp=oA,b.editorMoveWordEnd=dA,b.editorMoveWordLeft=uA,b.editorRangeClearColor=Z6,b.editorRangeGetColor=jg,b.editorRangeSetColor=G6,b.editorRemoveTextAttribute=fT,b.editorReplaceBlockText=Eh,b.editorReplaceContainer=W6,b.editorRunOnce=op,b.editorSelectAll=OA,b.editorSelectContainer=Yg,b.editorSelectDown=iA,b.editorSelectEnd=Zg,b.editorSelectHome=pA,b.editorSelectLeft=sA,b.editorSelectLineEnd=yA,b.editorSelectLineHome=vA,b.editorSelectPageDown=LA,b.editorSelectPageUp=SA,b.editorSelectRight=lA,b.editorSelectUp=cA,b.editorSelectWordEnd=fA,b.editorSelectWordLeft=hA,b.editorSetTextColor=Jl,b.editorShowFindDialog=dU,b.editorToDocx=WZ,b.editorUpdateBlockData=xh,b.editorUpdateCompositionText=R6,b.editorUpdateEmbedData=U6,b.enablePageScroll=BC,b.escapeHtmlText=sC,b.escapeRegExp=Pm,b.escapeSpace=gE,b.exclusiveBlock=K0,b.executeBlockCommand=u4,b.executeEmbedBlockCommand=a4,b.executeRangeCommand=sb,b.fileToDataUrl=Ul,b.findAfterOffsetNotType=vg,b.findAllText=Cg,b.findEventTargetBlock=rC,b.findInsertionById=QC,b.findNextOffset=MI,b.findNextVisibleSimpleBlock=hb,b.findPrevOffset=LI,b.findPrevOffsetNotType=bg,b.findPrevSimpleBlockBeforeChildContainer=E4,b.findPrevVisibleSimpleBlock=db,b.findTarget=jl,b.findWordEnd=kg,b.findWordLeft=yg,b.format=ba,b.formatBytes=SC,b.formatDate=_m,b.fragmentToHtml=EC,b.fromBase64=zd,b.fromBase64ToBlob=Dm,b.fromBase64ToUint8Array=xE,b.fromDocRange=Si,b.fromNowString=Fm,b.genId=K,b.getAllChildBlocks=og,b.getAllQuickMenuItems=D0,b.getAllSelectedBlocks=Lo,b.getAttributesAt=Ta,b.getBlockBackground=zC,b.getBlockByIndex=_r,b.getBlockCaretRect=To,b.getBlockClass=Qe,b.getBlockClassByType=Ms,b.getBlockClientRects=Ti,b.getBlockCommandsWithHook=Wm,b.getBlockContent=Re,b.getBlockId=ie,b.getBlockIndex=be,b.getBlockInfo=Iu,b.getBlockKind=Io,b.getBlockMinWidth=o4,b.getBlockNearestRangeFromPoint=L4,b.getBlockOptions=VE,b.getBlockPath=Di,b.getBlockProperties=s4,b.getBlockRangeFromPoint=rh,b.getBlockStyles=zE,b.getBlockTextLength=ue,b.getBlockTools=lt,b.getBlockType=De,b.getBoxContent=Hm,b.getBoxId=qC,b.getBoxTypeFromElement=va,b.getChildBlockCount=Eo,b.getChildBlocks=vt,b.getChildOffset=Mi,b.getColorFromAttributes=gg,b.getColorFromContent=Yd,b.getComplexBlockClass=jn,b.getContainerBlockPath=m4,b.getContainerBlocks=e4,b.getContainerBlocksElement=th,b.getContainerById=$r,b.getContainerId=ae,b.getContainerMinWidth=Qm,b.getContainerToolsElement=QE,b.getContainerWidth=b4,b.getDistanceSquare=tr,b.getElementOffset=ga,b.getElementScale=ys,b.getEmbedType=Un,b.getExistsBlockTools=Kd,b.getExistsContainerById=f4,b.getFileExt=Aa,b.getFirstChildBlock=St,b.getFirstClientRect=Hd,b.getHeadingMenuOptions=B0,b.getHorizontalPadding=Cm,b.getInsertionContent=jm,b.getLastChildBlock=Gt,b.getLastClientRect=bs,b.getListAllNextBrothers=dc,b.getLogger=S,b.getNextBlock=Ze,b.getNextValidOffset=Fs,b.getNextVisibleBlock=Ss,b.getOffsetInfoAfter=Sa,b.getOffsetInfoBefore=Ah,b.getOpAt=Y4,b.getOpLength=uh,b.getParentBlock=oe,b.getParentBlockExcludeSelf=Is,b.getParentBox=$m,b.getParentContainer=ne,b.getPrevBlock=ct,b.getPrevValidOffset=Ri,b.getPrevVisibleBlock=Ds,b.getRangeCommands=rb,b.getRootBlock=Vm,b.getScrollContainer=oo,b.getSpecialBlockCommands=l4,b.getStandardEmbedBlockProperties=T2,b.getTextAfterOffset=DI,b.getTextAttributes=Dg,b.getTextBeforeOffset=SI,b.getTextBlockChild=eh,b.getTextBlockClass=KC,b.getTextBlockContentChildTextLength=so,b.getTextBlockContentChildType=d4,b.getTextBlockContentChildren=nr,b.getTextLength=rn,b.getTextOpLength=rg,b.getTextWidth=Wd,b.getToolbar=lf,b.handleBlockElementUpdated=r4,b.hasAltOnly=yE,b.hasClass=xe,b.hasCtrlOrCmd=AC,b.hasCtrlOrCmdOnly=vE,b.hashCode=PC,b.hideBlock=jC,b.htmlToFragment=Vd,b.i18n=R,b.injectDocToHtmlFragment=Mh,b.injectStyle=cC,b.insertEmptyBlock=GE,b.insertEmptyEmbedBlock=qm,b.insertText=jr,b.intersectionCommands=_D,b.isBackspace=vC,b.isBlock=xs,b.isBlockLocked=_f,b.isBlockLockedByOthers=e2,b.isBlockLockedBySelf=Tu,b.isBlockTools=HC,b.isBox=Nm,b.isCJK=gC,b.isChildContainer=Do,b.isChildNode=Ke,b.isCollapsedRange=mI,b.isComplexBlockPosition=Km,b.isComplexKindBlock=Le,b.isContainer=Fr,b.isContainerSelectedAllChildBlocks=MA,b.isControlEvent=ws,b.isDelete=wE,b.isDraggingFiles=qd,b.isElementVisible=ym,b.isEmbedBlock=Lt,b.isEmptyContainer=Ym,b.isEmptyDoc=Ag,b.isEmptyTextBlock=ht,b.isEmptyTextBlockWithoutCompositionText=Au,b.isEnterOnly=bC,b.isEscape=Im,b.isExclusiveBlock=Of,b.isFirefox=Em,b.isFirstChildBlockInComplexBlock=Ix,b.isHighSurrogate=aE,b.isInBlock=Um,b.isInBlockTools=Ls,b.isLetter=mC,b.isLowSurrogate=gm,b.isMatchShortcut=Or,b.isMoveForward=AE,b.isNavigationEvent=CE,b.isNavigationKey=CC,b.isNodeRemoved=nC,b.isNumber=fC,b.isPrintableKey=xm,b.isRootBlock=ro,b.isRootContainer=Xe,b.isSafari=pC,b.isSameDay=Om,b.isSecureEnv=j0,b.isShiftEnter=kE,b.isShiftTab=EE,b.isShortcutEvent=bE,b.isSimpleBlock=UE,b.isSimpleBlockPosition=Hr,b.isSimplePos=l6,b.isSimpleRange=mh,b.isSpace=Ud,b.isTab=BE,b.isTextBlockContentBoxChild=io,b.isTextBlockContentChild=ka,b.isTextBlockContentInsertionChild=Nr,b.isTextBlockContentTextChild=wa,b.isTextKindBlock=ee,b.isTextKindBlockType=ya,b.isToday=LC,b.isValidOffset=sn,b.isVisibleBlock=Jd,b.isYesterday=MC,b.loadJs=oC,b.loadJsPromise=vs,b.lockers=wo,b.mergeCommands=sf,b.mergeDocs=$s,b.mergeOps=ug,b.mergeText=cI,b.multiSplitText=_4,b.overflowText=RC,b.parseShortcut=yC,b.patchNode=Ca,b.pointInRect=ks,b.rangeAddAttribute=Ia,b.rangeGetTextColor=n6,b.rangeRemoveAttribute=ql,b.rangeSetTextColor=X4,b.rangeTransformText=J4,b.registerDragDrop=wm,b.removeAttribute=mg,b.removeClass=te,b.removeLastBr=rI,b.removePlaceholderFromBlock=i7,b.removeStyle=lC,b.replaceAll=OE,b.replaceAllCaseInsensitive=_E,b.replaceAllText=i6,b.replaceText=hh,b.requestDownload=Gd,b.resetListStart=fc,b.scrollable=TC,b.selectFile=zl,b.selectedBlockToDoc=Th,b.selectionToDoc=Dh,b.setAttributes=bm,b.setClipboardData=Mm,b.setClipboardDataByEvent=SE,b.setColorToAttributes=e6,b.setDataset=Am,b.setDefaultCursor=pa,b.setStyles=vm,b.shareDBCommentToDocObject=bp,b.shareDBDocCommentToComment=Gb,b.shortcutToDisplayText=Bo,b.showBlock=UC,b.showDocVersions=QZ,b.splitText=xn,b.splitToThree=zt,b.stringToDataUrl=Sm,b.stringToObjectUrl=Lm,b.subText=F4,b.textNodeOffsetFromPoint=tC,b.titleFromEditor=g7,b.toBase64URL=Bs,b.toMindmap=df,b.toPlainText=rt,b.toPlainTextKeepLength=pg,b.trimChar=Bm,b.unexclusiveBlock=X0,b.unicodeLength=uE,b.unicodeSubstr=dE,b.updateBlockSelection=n4,b.updateOpAttributes=r6,b.updateTextBlockContent=TI,b.updateUrl=Tm;for(const n in bt)n!=="default"&&!b.hasOwnProperty(n)&&Object.defineProperty(b,n,{enumerable:!0,get:()=>bt[n]});Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});