@ones-editor/editor 1.1.0-beta.12 → 1.1.0-beta.13
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/@ones-editor/tsconfig.tsbuildinfo +1 -1
- package/dist/index.js +12 -12
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -12,7 +12,7 @@ Available method signatures are:
|
|
|
12
12
|
* @author Roy Revelt, Codsen Ltd
|
|
13
13
|
* @license MIT
|
|
14
14
|
* {@link https://codsen.com/os/string-character-is-astral-surrogate/}
|
|
15
|
-
*/function F9(n){if(typeof n=="string")return n.length===0?!1:n.charCodeAt(0)>=55296&&n.charCodeAt(0)<=56319;if(n===void 0)return!1;throw new TypeError(`string-character-is-astral-surrogate/isHighSurrogate(): the input is not string but ${typeof n}`)}function K9(n){if(typeof n=="string")return n.length===0?!1:n.charCodeAt(0)>=56320&&n.charCodeAt(0)<=57343;if(n===void 0)return!1;throw new TypeError(`string-character-is-astral-surrogate/isLowSurrogate(): the input is not string but ${typeof n}`)}const Qc="\u200B";function V9(n){return[...n].length}function $9(n,t,e){const i=[...n];let o;return e===void 0?o=i.length:o=t+e,i.slice(t,o).join("")}function H9(n){const t="\xA0";if(!n)return"";if(n===" ")return t;let e=n;return e.startsWith(" ")&&(e=t+e.substr(1)),e.endsWith(" ")&&(e=e.substr(0,e.length-1)+t),e=e.replace(/ {2}/g,` ${t}`),e}function Ud(n){if(!/["'&<>]/.exec(n))return n;const r={'"':""","'":"'","&":"&","<":"<",">":">"};return n.split("").map(l=>r[l]||l).join("")}function Fb(n){const t=document.getElementById(n);t&&t.remove()}function Kb(n,t){const e=document.getElementById(t);if(e)return e.textContent=n,e;const r=document.createElement("style");return r.id=t,r.textContent=n,document.head.append(r),r}function Yc(n){const t="custom-cursor-style";if(n){const e=`body * { cursor: ${n} !important}`;Kb(e,t)}else Fb(t)}const Vb=3,$b=I("drag-drop");class Hb{constructor(t){m(this,"dragStarted",!1);m(this,"mouseDownEvent",null);m(this,"_dragOffsetX",0);m(this,"_dragOffsetY",0);m(this,"handleMouseDown",t=>{t.preventDefault(),t.stopPropagation(),this.mouseDownEvent=t;const e=this.options.elem.getBoundingClientRect();this._dragOffsetX=this.mouseDownEvent.x-e.left,this._dragOffsetY=this.mouseDownEvent.y-e.top,this.bindEvents()});m(this,"handleMouseMove",t=>{var o;t.preventDefault(),t.stopPropagation(),p($b,this.mouseDownEvent,"no mouse down event");const e=t.x-this.mouseDownEvent.x,r=t.y-this.mouseDownEvent.y;if(this.dragStarted){this.onDragging(t,e,r);return}const i=(o=this.options.minThreshold)!=null?o:Vb;(Math.abs(e)>=i||Math.abs(r)>=i)&&this.onDragStart(this.mouseDownEvent)});m(this,"handleMouseUp",t=>{if(t.button===0){p($b,this.mouseDownEvent,"no mouse down event");const e=t.x-this.mouseDownEvent.x,r=t.y-this.mouseDownEvent.y;this.onDragEnd(t,e,r),t.preventDefault(),t.stopPropagation()}});this.options=t,this.options.mouseDownEvent?this.handleMouseDown(this.options.mouseDownEvent):this.trackEvents()}get data(){return this.options.data}get dragOffsetX(){return this._dragOffsetX}get dragOffsetY(){return this._dragOffsetY}get dragOffset(){return{x:this._dragOffsetX,y:this._dragOffsetY}}trackEvents(){this.options.elem.addEventListener("mousedown",this.handleMouseDown)}untrackEvents(){this.options.elem.removeEventListener("mousedown",this.handleMouseDown)}bindEvents(){document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}unbindEvents(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}onDragStart(t){this.dragStarted=!0,this.options.cursor&&Yc(this.options.cursor),this.options.onDragStart(this,t,this.options.elem)}onDragging(t,e,r){this.options.onDragging(this,t,this.options.elem,e,r)}onDragEnd(t,e,r){this.options.cursor&&Yc(null),this.dragStarted&&this.options.onDragEnd(this,t,this.options.elem,e,r),this.unbindEvents(),this.dragStarted=!1}destroy(){this.unbindEvents(),this.untrackEvents()}}function _g(n){return new Hb(n)}const j9=I("character");function jb(n,t){for(let e=0;e<t.length;e++){const r=t[e][0],i=t[e].length>1?t[e][1]:null;if(i===null&&n===r||i!==null&&n>=r&&n<=i)return!0}return!1}function zb(n){const t=n.charAt(0);return t>="0"&&t<="9"}function Gb(n){const t=n.charAt(0);return t>="a"&&t<="z"||t>="A"&&t<="Z"||t.toUpperCase()!==t.toLowerCase()?!0:RegExp(/^\p{L}/,"u").test(t)}function Od(n){const t=[[9,13],[32],[160]];return jb(n.charCodeAt(0),t)}function Wb(n){const t=[[12352,12687],[13056,13183],[13312,15661],[19968,40959],[63744,64255],[44032,55215]];return jb(n.charCodeAt(0),t)}function Mg(n,t){let e=t;return p(j9,e.length===1,"invalid char length"),e==="]"&&(e="\\]"),e==="\\"&&(e="\\\\"),n.replace(new RegExp(`^[${e}]+|[${e}]+$`,"g"),"")}const ji=navigator.userAgent;function ua(){const n=navigator.userAgent.toLowerCase();return n.indexOf("safari")!==-1&&!(n.indexOf("chrome")>-1)}function Jc(){return navigator.userAgent.toLowerCase().indexOf("firefox")>-1}const me={isAndroid:!!ji.match(/Android/i),isIOS:!!ji.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/i),isIPad:!!ji.match(/iPad/i),isIPhone:!!ji.match(/iPhone/i),isLinux:!!ji.match(/Linux/i),isMac:!!ji.match(/Macintosh/i),isMobile:!!ji.match(/AppleWebKit.*Mobile.*/i),isWindows:!!ji.match(/Window/i),isIe:!!ji.match(/msie|trident/i),isSafari:ua(),isFirefox:Jc(),isMobileSafari:!1};me.isMobileSafari=me.isMobile&&me.isSafari;function Ug(n){return n?n.length===1||n==="Process"||n==="Unidentified"&&me.isAndroid:!1}function qb(n){switch(n){case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":case"End":case"Home":case"PageDown":case"PageUp":return!0;default:return!1}}function z9(n){return qb(n.key)}function G9(n){switch(n){case"ArrowUp":case"ArrowLeft":case"Home":case"PageUp":return!0;default:return!1}}function Ps(n){return n.ctrlKey||n.altKey||n.shiftKey||n.metaKey}function W9(n){return n.key?!!(n.ctrlKey||n.metaKey||n.altKey):!1}function Xb(n){return me.isMac?n.metaKey&&!n.ctrlKey:!n.metaKey&&n.ctrlKey}function q9(n){return Xb(n)&&!n.altKey&&!n.shiftKey}function X9(n){return!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&n.altKey}function Qb(n){return!Ps(n)&&n.key==="Enter"}function Q9(n){return n.key==="Enter"&&n.shiftKey&&!n.altKey&&!n.ctrlKey&&!n.metaKey}function Og(n){return!Ps(n)&&n.key==="Escape"}function Y9(n){return!Ps(n)&&n.key==="Delete"}function Yb(n){return!Ps(n)&&n.key==="Backspace"}function J9(n){return!Ps(n)&&n.key==="Tab"}function Z9(n){return n.shiftKey&&n.key==="Tab"&&!n.ctrlKey&&!n.metaKey}function ze(n){if(!n)return"";if(me.isMac){const t=n.replace("CtrlOrCmd","\u2318").replace("Shift","\u21E7").replace("Ctrl","\u2303").replace("Alt","\u2325").replace(/\+(?!$)/gm,""),e={"\u2318":4,"\u21E7":3,"\u2325":2,"\u2303":1};return t.split(/(?=[\s\S])/u).sort((i,o)=>{var c,d;const s=(c=e[i])!=null?c:5,l=(d=e[o])!=null?d:5;return s-l}).map(i=>i in e?`${i}+`:i).join("")}return n.replace("CtrlOrCmd","Ctrl")}function Jb(n){const t={ctrl:!1,alt:!1,shift:!1,cmd:!1,key:""},e=n.toLocaleUpperCase().split("+");for(let r=0;r<e.length;r++){const i=e[r];i==="CTRL"||i==="CONTROL"?t.ctrl=!0:i==="ALT"||i==="OPTION"?t.alt=!0:i==="SHIFT"?t.shift=!0:i==="CMD"||i==="COMMAND"?t.cmd=!0:i==="CMDORCTRL"||i==="CTRLORCMD"?me.isMac?t.cmd=!0:t.ctrl=!0:i==="SPACE"?t.key=" ":t.key=i.substring(0,1)+i.substring(1).toLocaleLowerCase()}return t}function ai(n,t){const e=Jb(t);return e.ctrl!==n.ctrlKey||e.alt!==n.altKey||e.shift!==n.shiftKey||me.isMac&&e.cmd!==n.metaKey?!1:e.key.length===1?e.key===n.key.toUpperCase():e.key.toUpperCase()===n.key.toUpperCase()}function Ng(n,t){return k6.stringifyUrl({url:n,query:t})}function ci(n){return typeof n=="string"?Wc.Base64.encode(n,!0):Wc.Base64.fromUint8Array(n,!0)}function Zc(n){return Wc.Base64.decode(n)}function tI(n){return Wc.Base64.toUint8Array(n)}function Pg(n){return new Blob([Wc.Base64.toUint8Array(n)])}const eI=Ko.init([Ko.classModule,Ko.styleModule,Ko.datasetModule,Ko.attributesModule,Ko.propsModule]);function tu(n,t){const e=Ko.toVNode(n),r=Ko.toVNode(t);eI(e,r)}async function Fg(n,t){const e=new FileReader,r=new Promise((o,s)=>{e.onload=o,e.onerror=s});return e.readAsDataURL(new Blob([n],{type:t})),await r,e.result}async function fa(n){const t=new FileReader,e=new Promise((i,o)=>{t.onload=i,t.onerror=o});return t.readAsDataURL(n),await e,t.result}function nI(n,...t){const e=n.tagName.toLowerCase();for(let r=0,i=t.length;r<i;r++)if(e===t[r].toLowerCase())return!0;return!1}function En(n,t){let e=n;for(;e;){const r=window.getComputedStyle(e);if(t!=null&&t.horizontal){if(/auto|scroll/i.test(r.overflowX))break}else if(/auto|scroll/i.test(r.overflowY))break;e=e.parentElement}return(!e||nI(e,"body"))&&(e=document.documentElement),e}function Zb(n){n.preventDefault(),n.stopPropagation()}function tv(n){if(document.querySelector(`.editor-disable-scroll[data-scroll-id="${n}"]`))return;const t=B("div",["editor-disable-scroll"],null);t.setAttribute("data-scroll-id",n),t.addEventListener("wheel",Zb,{passive:!1}),document.body.appendChild(t)}function ev(n){const t=document.querySelector(`.editor-disable-scroll[data-scroll-id="${n}"]`);t&&(t.removeEventListener("wheel",Zb),t.remove())}function Kg(n,t,e){const r=new Blob([n]),i=new File([r],e,{type:t});return URL.createObjectURL(i)}function Nd(n){const t=document.createElement("template");if("content"in t)return t.innerHTML=n,document.importNode(t.content,!0);const e=document.createDocumentFragment(),r=document.createElement("div");for(r.innerHTML=n;r.firstChild;)e.appendChild(r.firstChild);return e}function nv(n){const t=document.createElement("div");return t.appendChild(n),t.innerHTML}function rv(n){let t=n.getPropertyValue("font");if(t)return t;const e=n.getPropertyValue("font-style"),r=n.getPropertyValue("font-variant"),i=n.getPropertyValue("font-weight"),o=n.getPropertyValue("font-size"),s=n.getPropertyValue("font-family");return t=`${e} ${r} ${i} ${o} ${s}`.replace(/ +/g," ").trim(),t}function Pd(n,t){const r=(Pd.canvas||(Pd.canvas=document.createElement("canvas"))).getContext("2d");return r?(typeof t=="string"?t?r.font=t:r.font=rv(window.getComputedStyle(document.body)):t instanceof Element&&(r.font=rv(window.getComputedStyle(t))),r.measureText(n).width+4):200}const rI=I("editor-clipboard");async function iI(n,t){if(t.clipboardData){const e=t.clipboardData;for(const r of n)e.setData(r.type,r.data);return!0}return!1}async function da(n){try{const t={};n.forEach(r=>{t[r.type]=r.data});const e=new ClipboardItem(t);return await navigator.clipboard.write([e]),!0}catch(t){return rI.error(t),!1}}function ha(n,t){return new Promise((e,r)=>{const i=document.createElement("input");i.type="file",i.style.display="none",t!=null&&t.multiple&&(i.multiple=!0),i.accept=n,i.onchange=()=>{const o=i.files;if(o){const s=t!=null&&t.multiple?Array.from(o):o[0];e(s)}i.remove()},i.onerror=o=>{r(o),i.remove()},i.click()})}function Fd(n){return Array.isArray(n)?n.every(t=>t instanceof File):!1}function eu(n){const t=n;if(!t)return"";const e=t.lastIndexOf(".");return e===-1?"":t.slice(e+1)}function Kd(n,t){const e=document.createElement("a");e.setAttribute("download",`${t||""}`),e.setAttribute("href",`${n}`),e.click(),e.remove()}const iv=I("auto-scroll");function ov(n,t){return!(n.scrollHeight===n.clientHeight||t==="top"&&n.scrollTop===0||t==="bottom"&&n.scrollTop+n.clientHeight===n.scrollHeight||t==="left"&&n.scrollLeft===0||t==="right"&&n.scrollLeft+n.clientWidth===n.scrollWidth)}function sv(n,{direction:t,step:e}){let r=null;const i=t==="left"||t==="right",o=()=>ov(n,t)?(i?t==="left"?n.scrollLeft=Math.max(n.scrollLeft-e,0):n.scrollLeft=Math.min(n.scrollLeft+e,n.scrollWidth):t==="top"?n.scrollTop=Math.max(n.scrollTop-e,0):n.scrollTop=Math.min(n.scrollTop+e,n.scrollHeight),r=requestAnimationFrame(o),r):(iv.debug("No need for scroll"),null);return r=requestAnimationFrame(o),()=>{r&&cancelAnimationFrame(r)}}class Vd{constructor(t){m(this,"cancelScroll",null);m(this,"options");m(this,"scrollDomInfo");m(this,"scrolling",!1);m(this,"getScrollingDirection",t=>{const{x:e,y:r}=t,{top:i,bottom:o,left:s,right:l}=this.scrollDomInfo,{edge:c}=this.options;return c.top&&r<=c.top+i?"top":c.bottom&&r>=o-c.bottom?"bottom":c.left&&e<=s+c.left?"left":c.right&&e>=l-c.right?"right":null});m(this,"handleMouseMove",t=>{var s;const{scrollElement:e,step:r=10,onDirectionChange:i}=this.options,o=this.getScrollingDirection(t);if(o){if(this.scrolling)return;iv.debug(`scroll direction: ${o}`),this.cancelScroll=sv(e,{direction:o,step:r}),i==null||i(o),this.scrolling=!0}else(s=this.cancelScroll)==null||s.call(this),this.scrolling=!1});this.options=t,this.scrollDomInfo=this.getScrollDomInfo()}getScrollDomInfo(){const{scrollElement:t}=this.options,e=t.getBoundingClientRect(),r=e.top,i=e.left,o=e.bottom,s=e.right;return{left:i,top:r,right:s,bottom:o}}active(){const{trackMouseEvent:t="mousemove"}=this.options;window.addEventListener(t,this.handleMouseMove,!0)}inactive(){var e;const{trackMouseEvent:t="mousemove"}=this.options;window.removeEventListener(t,this.handleMouseMove,!0),(e=this.cancelScroll)==null||e.call(this),this.scrolling=!1}}function lv(n,t){if(n===0)return"0 Bytes";const e=1024,r=t||2,i=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],o=Math.floor(Math.log(n)/Math.log(e));return`${parseFloat((n/e**o).toFixed(r))} ${i[o]}`}function nu(n,t){let e=`${n}`;const r=t-e.length;for(let i=0;i<r;i++)e=`0${e}`;return e}const{t:Fs}=D;function Vg(n,t){const e=new Date(n).getTime()+864e5*t;return new Date(e)}function oI(n,t){const e=n,r=Math.floor(t/12),i=t-r*12;return r&&e.setFullYear(e.getFullYear()+r),i&&e.setMonth(e.getMonth()+i),e}function sI(n,t){return Vg(n,t)}function $g(n,t){const e=new Date(n),r=new Date(t);return e.getDate()===r.getDate()&&e.getMonth()===r.getMonth()&&e.getFullYear()===r.getFullYear()}function av(n){const t=new Date,e=new Date(n);return $g(t,e)}function cv(n){const t=Vg(new Date,-1);return $g(t,n)}function lI(n,t){return Math.round((n.getTime()-t.getTime())/864e5)}function Hg(n,t){const e=new Date(n);if(t){const r=e.getFullYear(),i=e.getMonth()+1,o=e.getDate(),s=e.getHours(),l=e.getMinutes();let c=t;return c=c.replace("YYYY",`${r}`),c=c.replace("MM",nu(i,2)),c=c.replace("DD",nu(o,2)),c=c.replace("M",`${i}`),c=c.replace("D",`${o}`),c=c.replace("hh",nu(s,2)),c=c.replace("mm",nu(l,2)),c=c.replace("h",`${s}`),c=c.replace("m",`${l}`),c}return n.toLocaleDateString()}function jg(n,t){const e=new Date(n),r=new Date;if(e.getTime()-r.getTime()>10*1e3)return D.t("date.dateFromFuture");if(av(e)){const o=(r.getTime()-n.getTime())/1e3;if(o<10*60)return Fs("date.dateJustNow");if(o<60*60)return Fs("date.dateMinutesAgo",{num:`${Math.floor(o/60)}`});const s=Math.floor(o/60/60);return s===1?Fs("date.date1HourAgo"):Fs("date.dateHoursAgo",{num:`${s}`})}if(cv(n))return Fs("date.dateYesterday");const i=Math.floor((r.getTime()-n.getTime())/1e3/24/60/60)+1;return i<14?Fs("date.dateDaysAgo",{num:`${i}`}):i<28?Fs("date.dateWeeksAgo",{num:`${Math.round(i/7)}`}):Hg(n,t)}function zg(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function aI(n,t,e){return n.replace(new RegExp(zg(t),"g"),e)}function cI(n,t,e){return n.replace(new RegExp(zg(t),"gi"),e)}function uv(n,t,e){const i=document.createElement("canvas").getContext("2d");if(!i)return null;if(i.font=String(t),i.measureText(n).width>e){let s=0,l=0;for(;l<e;)l=i.measureText(n.slice(0,s)).width,s++;return`${n.slice(0,s-2)}...`}return n}const fv=/[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff66-\uff9f\uAC00-\uD7AF]/,dv=" -\x7F0-9!-/:-@[-`{-~\u0370-\u03FF\u0400-\u04FF",uI=new RegExp(`[${dv}]`),fI=new RegExp(`([^(${dv})])`,"g"),hv=/(\ud83c[\udf00-\udfff])|(\ud83d[\udc00-\ude4f\ude80-\udeff])|[\u2600-\u2B55]/;function mv(n){return n.length===0?0:n.split("").reduce((t,e)=>{const r=(t<<5)-t+e.charCodeAt(0);return r&r},0)}function dI(n,t=1){var r,i;return(i=((r=Array.from(n))==null?void 0:r.filter(o=>fv.test(o))).slice(-t))==null?void 0:i.join("")}function hI(n,t=1){var i;const e=Array.from((i=n==null?void 0:n.replace(fI,""))==null?void 0:i.split(/\s/));return e.reduce((o,s,l)=>{var c,d;return l===e.length-1&&o.length<t?`${o}${(c=s==null?void 0:s.slice(0,t-o.length))!=null?c:""}`:`${o}${(d=s[0])!=null?d:""}`},"").slice(0,t)}function mI(n,t=1){var r,i;return(i=((r=Array.from(n))==null?void 0:r.filter(o=>hv.test(o))).slice(-t))==null?void 0:i.join("")}function gI(n,t=1){var e,r;return(r=(e=Array.from(n))==null?void 0:e.slice(0,t))==null?void 0:r.join("")}function $d(n,t=1){if(!n||n.length===0)return"";const e=fv.test(n),r=uI.test(n),i=hv.test(n);switch(!0){case e:return dI(n,t);case r:return hI(n,t);case i:return mI(n,t);default:return gI(n,t)}}var gv=(n=>(n.blue="#0064FF",n.cyan="#34AFDE",n.teal="#2CB2AE",n.green="#24B47E",n.kelly="#8AAB3F",n.yellow="#F0A100",n.orange="#EB6414",n.red="#E52727",n.fuchsia="#BE507D",n.purple="#9678D3",n))(gv||{});function Hd(n){const t=Object.values(gv),e=Math.abs(typeof n=="string"&&n.trim()?mv(n.trim()):0)%t.length;return t[e]}const pv=I("element");function Gg(n,t,e){const r=B("div",[t],n);return r.setAttribute("data-type","editor-container"),r.setAttribute("data-container-id",e),B("div",["container-blocks"],r),r}function ui(n,t){const e=n.rootElement.querySelector(`[data-container-id=${t}]`);return p(pv,e,`no container: ${t}`),e}function jd(n,t){return n.rootElement.querySelector(`[data-container-id=${t}]`)}function ru(n){const t=n.querySelector(":scope > .container-blocks");return p(pv,t,"no container blocks element"),t}function pI(n){let t=n.querySelector(":scope > .container-tools");return t||(t=B("div",["container-tools"],n)),t}const Wg=I("container-children");function ue(n){const t=ru(n),e=Array.from(t.children);return p(Wg,e.length>0,"container have not any child block"),e}function we(n){const t=n.querySelector(":scope > .container-blocks > div[data-type=editor-block]");return p(Wg,t,"container have not any child block"),t}function Ze(n){const t=ue(n);return t[t.length-1]}function Lr(n){return ue(n).length}function zi(n,t){const e=ue(n)[t];return p(Wg,e,`container have not block at index ${t}`),e}function Cv(n,t){var e;return(e=ue(n)[t])!=null?e:null}class CI{constructor(t){m(this,"renders",[]);this.editor=t}registerRender(t){this.renders.push(t)}renderBox(t,e){const r={classes:[],attributes:{},styles:{}};return this.renders.forEach(i=>{if(i.renderBox){const o=i.renderBox(this.editor,t,e);o.classes&&r.classes.push(...o.classes),o.attributes&&(r.attributes={...r.attributes,...o.attributes}),o.styles&&(r.styles={...r.styles,...o.styles})}}),r}renderText(t,e){const r={classes:[],attributes:{},styles:{}};return this.renders.forEach(i=>{if(i.renderText){const o=i.renderText(this.editor,t,e);o.classes&&r.classes.push(...o.classes),o.attributes&&(r.attributes={...r.attributes,...o.attributes}),o.styles&&(r.styles={...r.styles,...o.styles})}}),r}renderBlock(t,e,r){const i={classes:[],attributes:{},styles:{}};return this.renders.forEach(o=>{if(o.renderBlock){const s=o.renderBlock(this.editor,e,r);s.classes&&i.classes.push(...s.classes),s.attributes&&(i.attributes={...i.attributes,...s.attributes}),s.styles&&(i.styles={...i.styles,...s.styles})}}),i}updateBlock(t,e,r,i){this.renders.forEach(o=>{var s;(s=o.updateBlock)==null||s.call(o,t,e,r,i)})}}const Ev=I("block-class");function Yt(n,t){return n.editorBlocks.getBlockClass(St(t))}function xv(n,t){const e=n.editorBlocks.getBlockClass(St(t));return p(Ev,e.blockKind==="text",`is not a text block, ${e.blockType}`),e}function Qn(n,t){const e=n.editorBlocks.getBlockClass(St(t));return p(Ev,e.blockKind==="complex",`is not a text block, ${e.blockType}`),e}function Ks(n,t){return n.editorBlocks.getBlockClass(t)}function nt(n,t){return Yt(n,t).blockKind==="text"}function iu(n,t){return n.editorBlocks.getBlockClass(t).blockKind==="text"}function _t(n,t){return Yt(n,t).blockKind==="complex"}function EI(n,t){return!_t(n,t)}function Ir(n,t){return Yt(n,t).blockKind}class Be extends Re.TypedEmitter{constructor(e){super();m(this,"hoveringBlock",null);m(this,"hoveringTextChild",null);m(this,"filters",[]);m(this,"finders",[]);m(this,"handleDocumentMouseMove",e=>{if(this.hoveringBlock){for(const s of this.filters)if(s.isInBlock(this.hoveringBlock,e))return}const r=document.elementFromPoint(e.x,e.y);if(!r){this.setHoveringBlock(null,e,null);return}let i=et(r);if((!i||!ne(this.editor.rootContainer,i))&&(i=this.findBlockByFinders(e),!i)){this.setHoveringBlock(null,e,null);return}const o=this.getParentTextContentChild(i,r);this.setHoveringBlock(i,e,o)});this.editor=e,document.addEventListener("mousemove",this.handleDocumentMouseMove)}destroy(){document.removeEventListener("mousemove",this.handleDocumentMouseMove),this.filters.forEach(e=>e.destroy()),this.filters=[],this.finders.forEach(e=>e.destroy()),this.finders=[]}addFilter(e){this.filters.push(e)}addFinder(e){this.finders.push(e)}hoveringBlockId(){return this.hoveringBlock?st(this.hoveringBlock):""}findBlockByFinders(e){for(let r=0;r<this.finders.length;r++){const o=this.finders[r].findTargetBlock(this.editor,e);if(o)return o}return null}setHoveringBlock(e,r,i){if(this.hoveringBlock===e&&this.hoveringTextChild===i)return;if(this.hoveringBlock!==e){const s=this.hoveringBlock&&ne(this.editor.rootContainer,this.hoveringBlock)?this.hoveringBlock:null;s&&ot(s,"hover"),e&&z(e,"hover"),this.hoveringBlock=e,this.emit("change",this.hoveringBlock,s,r)}const o=this.hoveringTextChild;this.hoveringTextChild=i,this.emit("childChange",this.hoveringBlock,i,o,r)}static get(e){return e.addCustom("standard-hovering-block",()=>new Be(e))}getParentTextContentChild(e,r){if(!nt(this.editor,e))return null;const i=Ot(e);return r.parentElement===i?r:qg(r)}}const Av="style-color-",bv="style-bg-color-";class vv{renderText(t,e,r){return this.generateCSSCustomProperties(r)}renderBlock(t,e,r){var l,c;const i={};Object.entries(r).filter(d=>d[0].startsWith("style-")).forEach(([d,h])=>{i[`data-${d}`]=`${h}`});const s=[];return((c=(l=t.selection)==null?void 0:l.range)==null?void 0:c.start.blockId)===r.id&&s.push("focused"),typeof r.align=="string"&&r.align&&(i["data-style-align"]=r.align),r.heading&&(i["data-style-heading"]=String(r.heading)),r.quoted&&(i["data-style-quoted"]="true"),Be.get(t).hoveringBlockId()===r.id&&s.push("hover"),{attributes:i,classes:s}}updateBlock(t,e,r,i){var s,l;Array.from(r.attributes).forEach(c=>{c.name.startsWith("data-style-")&&r.removeAttribute(c.name)}),Object.entries(i).filter(c=>c[0].startsWith("style-")||c[0]==="align").forEach(([c,d])=>{c==="align"&&r.setAttribute(c.startsWith("style-")?`data-${c}`:`data-style-${c}`,`${d}`)}),((l=(s=t.selection)==null?void 0:s.range)==null?void 0:l.start.blockId)===i.id&&z(r,"focused"),Be.get(t).hoveringBlockId()===i.id&&z(r,"hover")}generateCSSCustomProperties(t){const e=[],r={},i={};return Object.entries(t).forEach(([o,s])=>{s===!0?o.startsWith(Av)?r["data-style-color"]=o.substring(Av.length):o.startsWith(bv)?r["data-style-bg-color"]=o.substring(bv.length):o.startsWith("style")&&e.push(o):typeof s=="string"&&(o==="link"&&(e.push("link"),r.link=s),o==="inline-style-color"&&(i.color=s),o==="inline-style-background-color"&&(i.backgroundColor=s))}),{classes:e,attributes:r,styles:i}}}const Dr=I("block-dom");function Vs(n){return n instanceof HTMLDivElement?n.getAttribute("data-type")==="editor-block":!1}function Bv(n){return n instanceof HTMLElement&&n.getAttribute("data-type")==="block-tools"}function Tv(n){z(n,"block-hidden")}function yv(n){ot(n,"block-hidden")}function ou(n){return!Rt(n,"block-hidden")}function st(n){const{id:t}=n;return p(Dr,t,"no block id"),t}function St(n){const t=n.getAttribute("data-block-type");return p(Dr,t,"invalid block dom, no data-type"),t}function et(n){const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest("div[data-type=editor-block]");return e||null}function $s(n){const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest("div[data-type=editor-block]:not(:scope)");return e||null}function rt(n){const t=n.closest("div[data-type=editor-container]");return p(Dr,t,"failed to get block container"),t}function Ot(n){const t=n.querySelector(":scope >div[data-type=block-content]");return p(Dr,t,"no block content"),t}function re(n){let t=n.querySelector(":scope >div[data-type=block-tools]");return t||(t=B("div",[],n),t.setAttribute("data-type","block-tools")),p(Dr,t,"no block tools"),t}function zd(n){const t=n.querySelector(":scope >div[data-type=block-tools]");return t||null}function kv(n){let t=n.querySelector(":scope > div[data-type=block-background]");return t||(t=B("div",[],n),t.setAttribute("data-type","block-background")),t}function Rv(n,t,e){const r=n.editorDecorators.decorateBlock(t,e),{id:i,type:o}=r;p(Dr,i,"no block id");const s=B("div",[`${o}-block`],null);s.id=i,s.setAttribute("data-type","editor-block"),s.setAttribute("data-block-type",o);const l=n.editorBlockRenders.renderBlock(n,t,e);return l.classes&&z(s,...l.classes),l.attributes&&Object.entries(l.attributes).forEach(([c,d])=>{s.setAttribute(c,d)}),l.styles&&Object.entries(l.styles).forEach(([c,d])=>{s.style.setProperty(c,d)}),s}function Hs(n,t){const e=B(t,[],null);return e.setAttribute("data-type","block-content"),n&&n.appendChild(e),e}function wv(n){const t=B("span",[`${n.type}-box`],null);return t.setAttribute("data-type","editor-box"),t.setAttribute("data-box-type",n.type),t.id=n.id,t}function su(n){const t=n.getAttribute("data-box-type");return p(Dr,t,"not a valid box element, no type"),t}function Gd(n){return n instanceof HTMLSpanElement?n.getAttribute("data-type")==="editor-box":!1}function Sv(n){const{id:t}=n;return p(Dr,t,"no box id"),t}function qg(n){const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest("span[data-type=editor-box]");return e||null}function Lv(n){n.innerHTML="",B("span",["box-space-start"],n,Qc);const t=B("span",[],n);return t.setAttribute("data-type","box-content"),B("span",["box-space-start"],n,Qc),t}function lu(n){const t=n.querySelector("span[data-type=box-content]");return p(Dr,t,"invalid box dom, no content"),t}function Iv(n,t,e){const r=B("span",[`${n}-insertion`],null);if(r.setAttribute("data-type","editor-insertion"),r.setAttribute("data-insertion-id",t),e){const i=new vv,{attributes:o}=i.generateCSSCustomProperties(e);o&&[...Object.entries(o)].forEach(s=>{const[l,c]=s;r.setAttribute(l,c)})}return r}function Dv(n,t){return n.rootContainer.querySelector(`[data-insertion-id=${t}]`)}function _v(n){n.innerHTML="",B("span",["insertion-space-start"],n,Qc);const t=B("span",[],n);return t.setAttribute("data-type","insertion-content"),B("span",["insertion-space-start"],n,Qc),t}function Xg(n){const t=n.querySelector("span[data-type=insertion-content]");return p(Dr,t,"invalid insertion-child dom, no content"),t}function ge(n){let t=n.previousElementSibling;for(;t;){if(Vs(t))return t;t=t.nextElementSibling}return null}function qt(n){let t=n.nextElementSibling;for(;t;){if(Vs(t))return t;t=t.nextElementSibling}return null}function js(n){let t=n.previousElementSibling;for(;t;){if(Vs(t)&&ou(t))return t;t=t.previousElementSibling}return null}function zs(n){let t=n.nextElementSibling;for(;t;){if(Vs(t)&&ou(t))return t;t=t.nextElementSibling}return null}function bt(n){const t=rt(n),r=ue(t).indexOf(n);return p(Dr,r!==-1,"invalid block & container dom, failed to get block index"),r}function Qg(n){return!n||!(n instanceof Node)?!1:!!et(n)}function Gs(n){if(!Qg(n))return!1;const t=n,e=t instanceof Element?t:t.parentElement;return e?!!e.closest("div[data-type=block-tools]"):!1}function Gi(n){return n.hasAttribute("data-document-title")}function _r(n,t,e){return Yt(n,t).getCaretRect(t,e)}const Mv=I("container");function Wi(n){return n.getAttribute("data-type")==="editor-container"}function Xt(n){return Rt(n,"root")}function Mr(n){return Rt(n,"child")}function ft(n){const t=n.getAttribute("data-container-id");return p(Mv,t,"no id for container"),Xt(n)&&p(Mv,t==="root",`invalid root container id, : ${t}`),t}function Uv(n,t){const e=ft(n);return t.getContainerBlocks(e)}const Yg=I("block");function dt(n,t){return Yt(n,t).getBlockTextLength(t)}function Ov(n){n.editorBlocks.forEach(t=>{t.clearSelection(n)})}function Nv(n,t,e,r){Yt(n,t).updateSelection(n,t,e,r)}function Jg(n){for(;;){const t=rt(n);if(Xt(t))return n;const e=et(t);p(Yg,e,"no parent block exists for child container"),n=e}}function Pv(n,t){const e=Yt(n,t);if(!!e.getMinWidth)return e.getMinWidth(n,t)}function Fv(n,t,e){const r=Yt(n,t);r.handleBlockElementUpdated&&r.handleBlockElementUpdated(n,t,e)}function Wd(n,t,e,r){try{const i=Ks(n,e).convertFrom;return i?i(n,t,r):null}catch{return Yg.debug(`unsupported block type: ${e}`),null}}function qi(n,t,e){const r=Yt(n,t);return r.getClientRects?r.getClientRects(n,t,e):[t.getBoundingClientRect()]}function xI(n,t){const e=Yt(n,t);if(e.getBlockStyles)return e.getBlockStyles(n,t);const r=n.getBlockData(t),i=Object.fromEntries(Object.entries(r).filter(([o])=>o.startsWith("style-")));return Object.entries(i).forEach(([,o])=>{const s=typeof o;p(Yg,s==="string"||s==="number"||s==="boolean","invalid style value")}),i}function ie(n,t){return Ir(n,t)==="text"?dt(n,t)===0:!1}const Kv=I("block-path");function Vo(n){const t=[];let e=n;for(;e;){const r=rt(e);if(t.unshift({containerId:ft(r),blockIndex:bt(e)}),Xt(r))return t;const i=et(r);p(Kv,i,"no parent block"),e=i}return p(Kv,!1,"no parent block"),[]}function AI(n,t){var i,o;const e=Yt(n,t);return(o=(i=e.getOptions)==null?void 0:i.call(e,n))!=null?o:{name:St(t)}}function dr(n){return Xt(rt(n))}function Vv(n,t){var i;const e=Yt(n,t);return(i=e.getBlockProperties)==null?void 0:i.call(e,n,t)}function Zg(n,t){var o,s;const e=Yt(n,t),r=(o=e.getBlockProperties)==null?void 0:o.call(e,n,t);let i={};r!=null&&r.blockCommands&&(i={...r.blockCommands});for(const l of n.blockHooks){const c=(s=l.commands)==null?void 0:s.call(l,n,t);c&&(i[c.group]=c)}return i}function bI(n,t,e){var s,l,c,d;const r=Yt(n,t),i=(s=r.getBlockProperties)==null?void 0:s.call(r,n,t);let o={};i!=null&&i.blockCommands&&(o={...i.blockCommands});for(const h of n.blockHooks){const C=(l=h.commands)==null?void 0:l.call(h,n,t);C&&(o[C.group]=C)}return(d=(c=o[e])==null?void 0:c.commands)!=null?d:[]}function $v(n,t,e){let r=t;for(;r;){const i=bI(n,r,e);if(i.length>0)return{element:Ot(r),commands:i};if(dr(r))break;r=$s(r)}return{element:null,commands:[]}}const Hv=I("embed-block-common");function pe(n){return St(n)==="embed"}function Ge(n){p(Hv,pe(n),"not an embed block");const t=n.getAttribute("data-embed-type");return p(Hv,t,"no embed data type"),t}function vI(n,t){return n.editorEmbeds.getEmbedClass(Ge(t))}function Ws(n,t){return n.editorEmbeds.getEmbedClass(t)}async function t1(n,t,e,r,i){const o=Ws(n,t);if(!o.getOptions)return null;const s=o.getOptions(n);if(!s.insertEmbedCommandItems||!s.insertEmbedCommandItems||s.insertEmbedCommandItems.length===0||!s.handleInsertEmptyEmbed)return null;const l=s.insertEmbedCommandItems[0];return s.handleInsertEmptyEmbed(n,{item:l,containerId:e,blockIndex:r,data:i})}function BI(n,t,e,r,i){var l,c;const o=(c=(l=Ks(n,t)).getOptions)==null?void 0:c.call(l,n);if(!o||!o.insertBlockCommandItems||o.insertBlockCommandItems.length===0||!o.handleInsertEmptyBlock)return null;const s=o.insertBlockCommandItems[0];return o.handleInsertEmptyBlock(n,{item:s,containerId:e,blockIndex:r,data:i})}const TI=I("execute-block-command");function jv(n,t,e,r){var d;p(TI,pe(t),"not a embed block");const i=Ge(t),o=Ws(n,i);if(!o.getOptions)return;const s=(d=o.getBlockProperties)==null?void 0:d.call(o,n,t),l=s==null?void 0:s.blockCommands;if(!l)return;const c=Object.entries(l);for(const h of c)if(h[0]===e)return h[1].executeCommand(n,t,r)}function zv(n,t,e,r){const i=Zg(n,t);if(!i)return;const o=Object.entries(i);for(const s of o)if(s[0]===e)return s[1].executeCommand(n,t,r)}const Xi=I("text-block-child");function au(n){return n.tagName==="SPAN"}function hr(n){return p(Xi,au(n),"not a valid text child"),n.getAttribute("data-type")==="editor-box"}function Qi(n){return p(Xi,au(n),"not a valid text child"),n.getAttribute("data-type")==="editor-insertion"}function cu(n){return!hr(n)&&!Qi(n)}function Gv(n){return p(Xi,au(n),"not a valid text child"),hr(n)?"box":Qi(n)?"insertion":"text"}function mr(n){const t=Gv(n);return t==="insertion"?0:t==="box"?1:(p(Xi,n.textContent!==null,"text block content is undefined"),p(Xi,n.textContent.length>=0,"text block content length is negative"),n.textContent.length)}function fi(n){const t=Ot(n),e=Array.from(t.children);return e.forEach(r=>{p(Xi,au(r),"not a valid text child")}),e}function qd(n,t){const e=fi(n);let r=0;for(let i=0;i<e.length;i++){const o=e[i],s=mr(o);if(r+s<t){r+=s;continue}if(r===t)return{prev:e[i-1],next:o,offset:0};if(r+s===t)return{prev:o,next:e[i+1],offset:0};const l=t-r;return p(Xi,l>0,"invalid offset value"),p(Xi,!hr(o),"invalid box child"),{prev:o,next:o,offset:l}}p(Xi,!1,`invalid block child at position: ${t}`)}const yI=I("child-container-path");function Wv(n){if(Xt(n))return[];const t=et(n);return p(yI,t,"no parent block"),Vo(t)}const qv=I("load-blocks");function e1(n,t,e){const r=ft(t),i=Uv(t,n.doc);p(qv,i.length>0,"no blocks in container");const o=document.createDocumentFragment();i.forEach((l,c)=>{const d=n.editorBlocks.createBlock([...e,{containerId:r,blockIndex:c}],t,l);o.appendChild(d)}),ru(t).appendChild(o)}function kI(n,t,e){const r=ru(n);if(t===0)return r.insertBefore(e,r.firstChild),e;const i=ue(n);return p(qv,t>=0&&t<=i.length,"invalid block index"),t===i.length?r.appendChild(e):r.insertBefore(e,i[t]),e}function RI(n,t,e,r){const i=Wv(t);i.push({containerId:ft(t),blockIndex:e});const o=n.editorBlocks.createBlock(i,t,r);return kI(t,e,o),o}const Xv=I("root-container");class wI{constructor(t,e){m(this,"resizeObserver");m(this,"isMoved",!1);m(this,"handleContextMenu",t=>{if(me.isSafari){const e=document.getSelection();e&&!e.isCollapsed&&e.collapseToStart()}});m(this,"handleResize",()=>{try{this.editor.selection.updateSelection(null),this.editor.emit("resize",this.editor)}catch(t){Xv.warn(`failed to update selection while container resizing: ${t.message}`)}});m(this,"handleClick",t=>{this.editor.emit("click",this.editor,t);const e=t.target;if(!Gs(e)&&(t.detail===1&&this.editor.input.focus(),t.detail===3&&this.editor.selectionHandler.handleTripleClick(t),t.detail===1&&t.button===0)){const r=document.elementFromPoint(t.clientX,t.clientY);if(r&&ne(this.rootContainer,r)){const i=et(r);i&&ne(i,r)&&this.handleBlockClick(t,i,r)}}});m(this,"handleBlockClick",(t,e,r)=>{var s,l;if(!nt(this.editor,e))return;const i=qg(r);if(i){const c=et(i);p(Xv,c,"no parent block"),(l=(s=this.editor.editorBoxes.getBoxClass(su(i)))==null?void 0:s.handleClickBox)==null||l.call(s,this.editor,i,t);return}const o=r.closest("span.text.link");o&&fi(e).indexOf(o)!==-1&&this.editor.emit("clickLink",this.editor,t,o)});m(this,"handleDblClick",t=>{Gs(t.target)||this.editor.selectionHandler.handleDblClick(t)});m(this,"handleMouseDown",t=>{this.isMoved=!1;const e=t.target;if(!!e&&e instanceof Node&&!Gs(e)){if(e instanceof HTMLElement&&e.draggable){this.editor.selectionHandler.handleMouseDown(t,{autoScroll:!1}),this.editor.selectionHandler.stopSelection(),this.editor.input.focus();return}t.button===0&&(document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),this.editor.selectionHandler.handleMouseDown(t,{autoScroll:!0})),me.isMobileSafari||this.editor.input.focus(),t.button===2&&t.stopPropagation()}});m(this,"handleMouseMove",t=>{this.editor.selectionHandler.handleMouseMove(t),this.isMoved=!0});m(this,"handleMouseUp",t=>{t.button===0&&(this.editor.selectionHandler.handleMouseUp(t),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)),this.isMoved&&(document.addEventListener("click",this.handleCaptureClick,!0),document.addEventListener("dblclick",this.handleCaptureDbClick,!0)),this.isMoved=!1});m(this,"handleCaptureClick",t=>{document.removeEventListener("click",this.handleCaptureClick,!0),t.stopPropagation()});m(this,"handleCaptureDbClick",t=>{document.removeEventListener("dblclick",this.handleCaptureDbClick,!0),t.stopPropagation()});this.editor=t,this.rootContainer=e,this.editor=t,this.resizeObserver=new _s(this.handleResize),this.bindEvents(e)}bindEvents(t){this.resizeObserver.observe(t);const e=this.editor.rootElement;e.onmousedown=this.handleMouseDown,e.ondblclick=this.handleDblClick,e.onclick=this.handleClick,e.oncontextmenu=this.handleContextMenu}unbindEvents(){this.resizeObserver.disconnect();const t=this.editor.rootElement;t.onmousedown=null,t.ondblclick=null,t.onclick=null,t.oncontextmenu=null}destroy(){this.unbindEvents()}reload(){const t=this.editor.selection.range,e=ru(this.rootContainer);e.innerHTML="",e1(this.editor,this.rootContainer,[]);const r=this.editor.findBlockById(t.start.blockId);if(r)this.editor.selection.selectBlock(r,0);else{const i=we(this.rootContainer);this.editor.selection.selectBlock(i,0)}}}function Qv(n){const t=Gg(n.contentElement,"root","root");return n.rootContainer=t,e1(n,t,[]),new wI(n,t)}function Yv(n,t,e,r){const i=jd(n,r);if(i)return e.appendChild(i),setTimeout(()=>{n.emit("containerRemount",n,r)}),i;const o=Gg(e,"child",r);return e1(n,o,t),o}function Jv(n,t){const e=n.getBoundingClientRect().width;return t.withPadding?e:e-Sg(n)}function n1(n,t){let e=Number.MAX_SAFE_INTEGER;const r=ue(t);for(let o=0;o<r.length;o++){const s=r[o],l=Pv(n,s);l&&(e=Math.min(e,l))}return e===Number.MAX_SAFE_INTEGER?void 0:e+Sg(t)}function uu(n,t){const e=ue(t);return e.length!==1?!1:ie(n,e[0])}const SI=I("complex-block-position");class Ur{constructor(t,e,r){m(this,"blockId");m(this,"childContainerId");m(this,"custom");t instanceof HTMLElement?this.blockId=st(t):(p(SI,typeof t=="string",`not a valid block id: ${t}`),this.blockId=t),this.childContainerId=e,r!==void 0&&(this.custom=r)}isSimple(){return!1}}const LI=I("simple-block-position");class We{constructor(t,e,r){m(this,"blockId");m(this,"offset");m(this,"type");t instanceof HTMLElement?this.blockId=st(t):(p(LI,typeof t=="string",`not a valid block id: ${t}`),this.blockId=t),this.offset=e,this.type=r}isSimple(){return!0}}const r1=I("editor-position");function lt(n,t,e){return new We(n,t,e)}function xe(n,t,e){return new Ur(n,t,e)}function Or(n){return n instanceof We}function ma(n){return n instanceof Ur}function i1(n,t,e){if(Or(t)&&Or(e)){const r=t,i=e;if(r.blockId===i.blockId)return r.offset-i.offset;const o=n.getBlockById(t.blockId),s=n.getBlockById(e.blockId);return p(r1,o!==s,"comparePosition: blocks are the same"),_d(o,s)}if(ma(t)&&ma(e)){const r=t,i=e;if(r.childContainerId===i.childContainerId)return 0;const o=n.getContainerById(r.childContainerId),s=n.getContainerById(i.childContainerId);return p(r1,o!==s,"comparePosition: containers are the same"),_d(o,s)}return p(r1,!1,"invalid "),0}const Xd=I("simple-range");class tn{constructor(t,e){m(this,"editor");m(this,"_anchor");m(this,"_focus");m(this,"reverse");this.editor=t,this._anchor=e.anchor,this._focus=e.focus,this.reverse=i1(this.editor,this._anchor,this._focus)>0}isCollapsed(){return this.start.blockId===this.end.blockId&&this.start.offset===this.end.offset}isEqual(t){if(!(t instanceof tn))return!1;const e=t,{start:r,end:i}=e;return this.start.blockId===r.blockId&&this.start.offset===r.offset&&this.start.type===r.type&&this.end.blockId===i.blockId&&this.end.offset===i.offset&&this.end.type===i.type}isSimple(){return!0}isReverse(){return this.reverse}getEditor(){return this.editor}get start(){return this.reverse?this._focus:this._anchor}get end(){return this.reverse?this._anchor:this._focus}get anchor(){return this._anchor}get focus(){return this._focus}getSelectedBlocks(){const{editor:t}=this,e=t.getBlockById(this.start.blockId),r=t.getBlockById(this.end.blockId);p(Xd,e,"no start block"),p(Xd,r,"no end block");const i=rt(e),o=rt(r);p(Xd,i===o,"invalid range");const s=[];if(e===r)s.push({block:e,start:this.start,end:this.end});else{const l=bt(e),c=bt(r);p(Xd,l<c,"invalid range, start > index"),s.push({block:e,start:this.start,end:lt(e,dt(this.editor,e),"end")});const d=ue(i);for(let h=l+1;h<c;h+=1){const C=d[h];s.push({block:C,start:lt(C,0,"home"),end:lt(C,dt(this.editor,C),"end")})}s.push({block:r,start:lt(r,0,"home"),end:this.end})}return s}getSelectedContainers(){return[]}getAnchorPos(){return this.isReverse()?this.end:this.start}getFocusedPos(){return this.isReverse()?this.start:this.end}clone(){return new tn(this.editor,this)}toDocRange(){return{anchor:this.anchor,focus:this.focus}}static from(t,e){return new tn(t,e)}}I("unknown-block");function II(n,t,e,r,i){z(r,"unknown-block");const o=Hs(r,"div");return o.innerText=`unknown block (${i.type}): ${JSON.stringify(i)}`,o}function DI(n){return 1}function _I(n,t,e,r){return null}function MI(n,t,e,r){const i=document.elementsFromPoint(e,r)[0];if(!i||!t.contains(i)||!n.contains(t))return null;const o=st(t),s=lt(o,0,"home"),l=lt(o,1,"end");return new tn(n,{anchor:s,focus:l})}function UI(n,t){const r=Ot(n).getBoundingClientRect();return new DOMRect(r.left+r.width/2,r.top,1,r.height)}function OI(n,t,e,r){z(t,"selected")}function NI(n){n.rootContainer.querySelectorAll("div.unknown-block[data-type=editor-block]").forEach(t=>{ot(t,"selected")})}function PI(n,t,e,r){return`[unknown block, ${t.type}]`}const FI={blockType:"unknown-block",blockKind:"embed",createBlockContent:II,getBlockTextLength:DI,getRangeFromPoint:MI,moveCaret:_I,getCaretRect:UI,updateSelection:OI,clearSelection:NI,convertTo:PI},o1=I("editor-blocks");class Zv{constructor(t){m(this,"blocks",new Map);this.editor=t}registerBlockClass(t){const e=t.blockType,r=this.blocks.get(e);p(o1,!r,`duplicated block type: ${e}`),this.blocks.set(e,t)}getBlockClass(t){const e=this.blocks.get(t);return p(o1,e,`unknown block type: ${t}`),e}hasBlock(t){return this.blocks.has(t)}createBlock(t,e,r){const i=Rv(this.editor,t,r);let o;this.hasBlock(r.type)?o=this.getBlockClass(r.type):o=this.registerUnknownBlock(r.type);const s=o.createBlockContent(this.editor,t,e,i,r);return s.parentElement!==i&&(o1.warn("content parent is not block"),i.appendChild(s)),this.editor.blockHooks.forEach(l=>{var c;(c=l.create)==null||c.call(l,this.editor,t,e,i,r)}),i}forEach(t){this.blocks.forEach(t)}registerUnknownBlock(t){const e={...FI,blockType:t};return this.editor.editorBlocks.registerBlockClass(e),e}}const t3=I("editor-embeds");class e3{constructor(t){m(this,"objects",new Map);this.editor=t}registerEmbedClass(t){const e=t.embedType,r=this.objects.get(e);p(t3,!r,`duplicated embed object type: ${e}`),this.objects.set(e,t)}getEmbedClass(t){const e=this.objects.get(t);return p(t3,e,`unknown embed type: ${t}`),e}getEmbedClassFromBlock(t){return this.getEmbedClass(Ge(t))}forEach(t){this.objects.forEach(t)}}const n3=I("embed-block");function KI(n,t,e,r,i){const o=Hs(r,"div");p(n3,i.type==="embed",`not an embed data: ${JSON.stringify(i)}`);const s=i;return p(n3,s.embedType&&s.embedData,`not an embed data: ${JSON.stringify(s)}`),n.editorEmbeds.getEmbedClass(s.embedType).createEmbedContent(n,o,s,t,e,r),r.setAttribute("data-embed-type",s.embedType),o}function VI(n){return 1}function $I(n,t,e,r){return null}function HI(n,t,e,r){const i=document.elementsFromPoint(e,r)[0];if(!i||!t.contains(i)||!n.contains(t))return null;const o=st(t),s=lt(o,0,"home"),l=lt(o,1,"end");return new tn(n,{anchor:s,focus:l})}function jI(n,t){const r=Ot(n).getBoundingClientRect();return new DOMRect(r.left+r.width/2,r.top,1,r.height)}function zI(n,t,e,r){z(t,"selected")}function GI(n){n.rootContainer.querySelectorAll("div.embed-block[data-type=editor-block][data-block-type=embed]").forEach(t=>{ot(t,"selected")})}function WI(n,t,e){let r=null;return n.editorEmbeds.forEach(i=>{var s,l;const o=(l=(s=i.convertFrom)==null?void 0:s.call(i,n,t,e))!=null?l:null;o&&(r=o)}),r}function qI(n,t,e,r){const i=Ws(n,t.embedType);return i.convertTo?i.convertTo(n,t,e,r):""}function XI(n,t){const e=vI(n,t);return e.getBlockProperties?e.getBlockProperties(n,t):{}}function QI(n){const t=new Map,e=[];return n.editorEmbeds.forEach(r=>{if(r.getOptions){const i=r.getOptions(n);i.insertEmbedCommandItems&&i.insertEmbedCommandItems.forEach(o=>{e.push(o),t.set(o.id,r)})}}),{name:"EmbedBlock",insertBlockCommandItems:e,async handleInsertEmptyBlock(r,i){const o=t.get(i.item.id);if(!o||!o.getOptions)return null;const s=o.getOptions(r);return s.handleInsertEmptyEmbed?s.handleInsertEmptyEmbed(r,i):null}}}function YI(n,t,e,r){const i=Ge(t),o=Ws(n,i);!o.handleDeleteBlock||o.handleDeleteBlock(n,t,e,r)}function JI(n,t,e){const r=Ge(t),i=Ws(n,r);return i.handleUpdateBlock?i.handleUpdateBlock(n,t,e):!1}function ZI(n,t,e,r,i){const o=Ge(t),s=Ws(n,o);if(s.handleDropOver)return s.handleDropOver(n,t,e,r,i)}function t7(n,t,e,r,i){const o=Ge(t),s=Ws(n,o);if(s.handleDrop&&n.isWritable())return s.handleDrop(n,t,e,r,i)}async function e7(n,t,e){const r=t.embedType,i=n.editorEmbeds.getEmbedClass(r);if(i.toStandardDoc){const o=n.getBlockById(t.id),s=Vo(o);return i.toStandardDoc(n,t,e,s)}}function n7(n,t){const e=t.embedType,r=n.editorEmbeds.getEmbedClass(e);return r.getResources?r.getResources(n,t):null}const r3={blockType:"embed",blockKind:"embed",createBlockContent:KI,getBlockTextLength:VI,getRangeFromPoint:HI,moveCaret:$I,getCaretRect:jI,updateSelection:zI,clearSelection:GI,convertFrom:WI,convertTo:qI,getBlockProperties:XI,getOptions:QI,handleDeleteBlock:YI,handleUpdateBlock:JI,handleDropOver:ZI,handleDrop:t7,toStandardDoc:e7,getResources:n7},xn=I("complex-block-helper");function An(n,t,e){return Qn(n,t).getChildContainers(n,t,e)}function ga(n,t,e,r){return e.isSimple()?(p(xn,r.isSimple(),"invalid start and end position"),An(n,t)):(p(xn,!e.isSimple(),"invalid start pos"),p(xn,!r.isSimple(),"invalid end pos"),Qn(n,t).getSelectedContainers(n,t,e,r))}function r7(n,t){if(bt(t)!==0)return!1;const e=et(rt(t));if(!e)return!1;p(xn,_t(n,e),"not a complex block");const r=rt(t),o=An(n,e).indexOf(r);return p(xn,o>=0,"not valid child container"),o===0}function s1(n,t,e){const r=An(n,t,e);if(r.length===0)return null;const i=r[0];if(!i)return null;const o=we(i);return _t(n,o)?s1(n,o,e):o}function pa(n,t,e){const r=An(n,t,e);if(r.length===0)return null;const i=r[r.length-1];if(!i)return null;const o=Ze(i);return _t(n,o)?pa(n,o,e):o}function i3(n,t){p(xn,Mr(t),"not a child container");const e=et(t);p(xn,e,"no parent block"),p(xn,_t(n,e),"not a complex block");const r=An(n,e),i=r.indexOf(t);if(p(xn,i!==-1,"child container not found"),i===0){const l=ge(e);return l?_t(n,l)?pa(n,l):l:null}const o=r[i-1],s=Ze(o);return _t(n,s)?pa(n,s):s}function o3(n,t){p(xn,_t(n,t),"not a complex block");const e=An(n,t);if(p(xn,e.length>0,"no child container"),e.length===1)return e;const r=e[0],i=r.getBoundingClientRect();let o=i.left,s=i.right;const l=[r];for(let c=1;c<e.length;c++){const d=e[c],h=d.getBoundingClientRect();if(h.right<=o){l.push(d),o=h.left;continue}if(h.left>=s){s=h.right;continue}}return l}function s3(n,t){p(xn,_t(n,t),"not a complex block");const e=An(n,t);if(p(xn,e.length>0,"no child container"),e.length===1)return e;const r=e[e.length-1],i=r.getBoundingClientRect();let o=i.left,s=i.right;const l=[r];for(let c=e.length-2;c>=0;c--){const d=e[c],h=d.getBoundingClientRect();if(h.right<=o){l.push(d),o=h.left;continue}if(h.left>=s){s=h.right;continue}}return l}function l3(n,t,e,r){const i=t.getBoundingClientRect(),o=r<i.top,s=o?o3(n,t):s3(n,t);let l=s[0],c=$i(l.getBoundingClientRect(),e,r);for(let d=1;d<s.length;d++){const h=s[d],C=h.getBoundingClientRect(),E=$i(C,e,r);E<c&&(l=h,c=E)}return o?we(l):Ze(l)}function Qd(n,t,e,r){const i=st(t);p(xn,i===e.blockId,"invalid start pos"),p(xn,i===r.blockId,"invalid end pos");const o=Qn(n,t);return o.adjustSelectionPos?o.adjustSelectionPos(n,t,e,r):{anchor:e,focus:r}}class di{constructor(t,e){m(this,"editor");m(this,"reverse");m(this,"_anchor");m(this,"_focus");this.editor=t,this._anchor=e.anchor,this._focus=e.focus,this.reverse=i1(this.editor,this._anchor,this._focus)>0}isCollapsed(){return!1}isEqual(t){if(!(t instanceof di))return!1;const e=t,{anchor:r,focus:i}=e;return this._anchor.blockId===r.blockId&&this._anchor.childContainerId===r.childContainerId&&this._focus.blockId===i.blockId&&this._focus.childContainerId===i.childContainerId&&this._anchor.custom===r.custom&&this._focus.custom===i.custom}isReverse(){return this.reverse}isSimple(){return!1}getEditor(){return this.editor}get anchor(){return this._anchor}get focus(){return this._focus}get start(){return this.reverse?this._focus:this._anchor}get end(){return this.reverse?this._anchor:this._focus}getSelectedBlocks(){const t=this.start,e=this.end;return[{block:this.editor.getBlockById(t.blockId),start:t,end:e}]}getAnchorPos(){return this._anchor}getFocusedPos(){return this._focus}getSelectedContainers(){const t=this.editor.getBlockById(this._anchor.blockId);return ga(this.editor,t,this.start,this.end)}clone(){return new di(this.editor,this)}toDocRange(){return{anchor:this._anchor,focus:this._focus}}}const i7=I("selection-range");function qe(n,t){const{anchor:e,focus:r}=t;return e instanceof We&&r instanceof We?new tn(n,{anchor:e,focus:r}):(p(i7,e instanceof Ur&&r instanceof Ur,"start position type does not math end type"),new di(n,{anchor:e,focus:r}))}function Te(n,t,e,r){const i=new We(t,e,"normal"),o=new We(t,r!=null?r:e,"normal");return qe(n,{anchor:i,focus:o})}function o7(n){return!!n.anchor.childContainerId}function $o(n,t){var i,o;if(o7(t)){const s=xe(t.anchor.blockId,t.anchor.childContainerId,(i=t.anchor)==null?void 0:i.custom),l=xe(t.focus.blockId,t.focus.childContainerId,(o=t.focus)==null?void 0:o.custom);return qe(n,{anchor:s,focus:l})}const e=lt(t.anchor.blockId,t.anchor.offset,"normal"),r=lt(t.focus.blockId,t.focus.offset,"normal");return qe(n,{anchor:e,focus:r})}const a3=I("range-from-point");function Yd(n,t,e){const r=[0,-12,12];let i=t;const o=e;let s=document.elementsFromPoint(i,o)[0],l=et(s);if(!l&&n.contentElement.contains(s)){const c=n.rootContainer.getBoundingClientRect(),d=c.left+c.width/2;s=document.elementsFromPoint(d,o)[0],l=et(s);let h=c;l&&(h=l.getBoundingClientRect()),t<h.left?i=h.left:t>h.right&&(i=h.right-5)}for(let c=0;c<r.length;c++){const d=document.elementsFromPoint(i,o+r[c])[0];if(!d)continue;const h=d.getBoundingClientRect();if(d.clientWidth&&d.clientHeight&&c===0&&(h.left+d.clientWidth<i||h.top+d.clientHeight<o))return a3.debug("click on scrollbar, out of element rect"),null;if(c===0&&!n.rootContainer.contains(d)&&(i=n.rootContainer.getBoundingClientRect().left),!n.rootContainer.contains(d))continue;const C=et(d);if(!C||!n.contains(C))continue;const E=Yt(n,C).getRangeFromPoint(n,C,i,o+r[c]);if(E)return E}return null}function c3(n,t,e,r){const i=t.getBoundingClientRect();if(r<=i.top){const c=we(t),d=Yt(n,c).getRangeFromPoint(n,c,e,c.getBoundingClientRect().top+4);if(d!=null&&d.isSimple())return tn.from(n,d);const h=lt(c,0,"home");return new tn(n,{anchor:h,focus:h})}const o=Ze(t),s=Yt(n,o).getRangeFromPoint(n,o,e,o.getBoundingClientRect().bottom-4);if(s!=null&&s.isSimple())return tn.from(n,s);const l=lt(o,dt(n,o),"end");return new tn(n,{anchor:l,focus:l})}function l1(n,t,e){const r=Yd(n,t,e);if(r){if(r instanceof tn)return r;p(a3,r instanceof di,`invalid range type: ${typeof r}`);const c=r,d=n.getContainerById(c.start.childContainerId);return c3(n,d,t,e)}const i=document.elementsFromPoint(t,e)[0];if(!i)return null;const{children:o}=i,s=Array.from(o).filter(c=>Wi(c));if(s.length===0)return null;const l=s.reduce((c,d)=>{const h=c.getBoundingClientRect(),C=d.getBoundingClientRect();return $i(h,t,e)>$i(C,t,e)?d:c});return c3(n,l,t,e)}function a1(n,t){const e=[];return ue(t).forEach(i=>{e.push(i),_t(n,i)&&An(n,i).forEach(s=>{e.push(...a1(n,s))})}),e}function c1(n,t){let e=a1(n,n.rootContainer);return t!=null&&t.simpleBlockOnly&&(e=e.filter(r=>!_t(n,r))),e}function hi(n,t){const e=n.selection.range.getSelectedBlocks(),r=[];for(const i of e)r.push(i),_t(n,i.block)&&ga(n,i.block,i.start,i.end).forEach(s=>{const c=a1(n,s).map(d=>({block:d,start:lt(d,0,"home"),end:lt(d,dt(n,d),"home")}));r.push(...c)});return t!=null&&t.simpleBlockOnly?r.filter(i=>!_t(n,i.block)):r}const oct="",en=I("text-range");function s7(n,t){const e=(o,s)=>{if(Qi(o))return p(en,s===0,`invalid offset for insertion child: ${s}`),{child:o,container:o,offset:2};if(hr(o))return p(en,s===0||s===1,`invalid offset for box: ${s}`),{child:o,container:o,offset:s===0?1:2};const l=o.firstChild;return p(en,l,"no child node for text child"),p(en,l instanceof Text||l instanceof HTMLBRElement,`invalid child for text child, ${l.nodeName}`),l instanceof HTMLBRElement?(p(en,s>=0&&s<=0,"invalid offset for text child"),{child:o,container:l,offset:s}):(p(en,s>=0&&s<=l.data.length,"invalid offset for text child"),{child:o,container:l,offset:s})};let r=0;const i=fi(n);for(let o=0;o<i.length;o++){const s=i[o],l=mr(s);if(t===r)return[e(s,0)];if(t<r+l)return[e(s,t-r)];if(t===r+l){const c=[];c.push(e(s,mr(s)));const d=i[o+1];return d&&c.push(e(d,0)),c}r+=l}p(en,!1,"failed to get range info")}function l7(n,t,e){if(t===e?p(en,Qi(n),"only insertion child can be zero offset"):p(en,t<e,`invalid start & end: ${t}, ${e}`),Qi(n)){p(en,t===e,`invalid insertion child range offset: ${t}, ${e}`),p(en,t===0,`invalid insertion child range start: ${t}`);const o=n;return p(en,o.children.length===3,`invalid insertion dom, children.length = ${o.children.length}`),Id(o,1,o,2)}if(hr(n)){p(en,t+1===e,`invalid box child range offset: ${t}, ${e}`),p(en,t===0,`invalid box child range start: ${t}`);const o=n;return p(en,o.children.length===3,`invalid box dom, children.length = ${o.children.length}`),Id(o,1,o,2)}const r=mr(n);p(en,e<=r,`invalid child end: ${e}, ${r}`);const i=n.firstChild;return p(en,i instanceof Text,"invalid block text child"),p(en,i.data.length>=e,`invalid range end: ${e}, ${i.data.length}`),Id(i,t,i,e)}const Nr=I("caret-rect");function a7(n,t){if(Gd(t)){const e=t,r=lu(e);if(e.getAttribute("data-box-type")==="br"){const i=Ot(n),o=Number.parseFloat(window.getComputedStyle(i).lineHeight)||r.getBoundingClientRect().height,s=Array.from(r.getClientRects());p(Nr,s.length>0,"no box client rects");const l=i.getBoundingClientRect(),c=s[0],d=new DOMRect(l.left,c.bottom,1,o);return s.push(d),s}return r.getClientRects()}return Xg(t).getClientRects()}function Yn(n,t){var l,c,d;const e=s7(n,t.offset);if(e[1]&&e[0].child!==((l=e[1])==null?void 0:l.child)){if(t.type==="end"){const C=Us(e[0].child);return new DOMRect(C.right,C.top,1,C.height)}p(Nr,e[1],"invalid ranges");const h=Dd(e[1].child);return new DOMRect(h.left,h.top,1,h.height)}let i=e[0];if(p(Nr,e.length>=1,"failed to get block range"),e.length===1)i=e[0];else{if(p(Nr,e.length>=2,`invalid range info length: ${e.length}`),Qi(e[e.length-1].child)){i=e[e.length-1];const h=i.child,E=Xg(h).getClientRects();p(Nr,E.length>=1,"no client rects for box content");const A=E[E.length-1];return new DOMRect(A.right,A.y,1,A.height)}t.type==="home"?i=e[1]:t.type==="end"||cu(e[0].child)?i=e[0]:cu(e[1].child)&&(i=e[1])}if(i.container instanceof HTMLBRElement){p(Nr,t.offset===0,"invalid offset for empty block text");const h=i.container.parentElement;p(Nr,h,"invalid br parent");const C=h.getBoundingClientRect();return new DOMRect(C.left,C.top,1,C.height)}const o=_b(i.container,i.offset),s=Array.from(o.getClientRects());if(s.length===0){p(Nr,!cu(i.child),"only box or insertion child range has zero client rect"),p(Nr,i.offset===1||i.offset===2,"invalid offset for box or insertion child");const h=i.child,C=a7(n,h);if(p(Nr,C.length>=1,"no client rects for box content"),i.offset===1){const A=C[0];return new DOMRect(A.x,A.y,1,A.height)}const E=C[C.length-1];if(t.type==="end"||i.offset===2){if(Gd(h)&&h.getAttribute("data-box-type")==="br"){const A=h.lastChild.getBoundingClientRect();return new DOMRect(E.right,A.top,1,A.height)}return new DOMRect(E.right,E.y,1,E.height)}return new DOMRect(E.x,E.y,1,E.height)}if(Jc()||ua()){const h=document.createRange();h.selectNodeContents(i.container);const C=h.getClientRects();if(i.container.nodeType===Node.TEXT_NODE&&i.offset<((d=(c=i.container.textContent)==null?void 0:c.length)!=null?d:0)){const E=document.createRange();E.setStart(i.container,i.offset+1);const A=E.getClientRects();Array.from(C).forEach((v,R)=>{if(Math.floor(A[0].top)!==Math.floor(s[0].top)&&Math.floor(A[0].top)===Math.floor(v.top)){const{x:L,y:M,height:U}=C[R];s.length===1&&t.type==="home"&&s.push(new DOMRect(L,M,0,U))}})}if(i.container.nodeType===Node.TEXT_NODE&&i.offset>0){const E=document.createRange();E.setStart(i.container,i.offset-1);const A=E.getClientRects();Array.from(C).forEach((v,R)=>{if(Math.floor(A[0].top)!==Math.floor(s[0].top)&&Math.floor(A[0].top)===Math.floor(v.top)){const{y:L,height:M,right:U}=C[R];s.length===1&&t.type==="end"&&s.unshift(new DOMRect(U,L,0,M))}})}}return p(Nr,s.length>0,"no client rects for range"),t.type==="home"?s[s.length-1]:s[0]}const c7=I("core");function Yi(n,t,e,r){const i=re(t);let o=i.querySelector(`.block-anchor[data-id=${e}]`);o||(o=B("div",["block-anchor"],i),o.setAttribute("data-id",e));const s=r!=null?r:t.getBoundingClientRect(),l=t.getBoundingClientRect(),c=new DOMRect(s.left-l.left,s.top-l.top,s.width,s.height);return o.style.left=`${c.left}px`,o.style.top=`${c.top}px`,o.style.width=`${c.width}px`,o.style.height=`${c.height}px`,o}function u3(n,t,e,r){p(c7,nt(n,t),"not a text kind block");const i=Yn(t,lt(t,e,"normal")),o=t.getBoundingClientRect(),s=re(t);let l=s.querySelector(`.block-anchor[data-id=${r}]`);l||(l=B("div",["block-anchor"],s),l.setAttribute("data-id",r));const c=new DOMRect(i.left-o.left,i.top-o.top,i.width,i.height);return l.style.left=`${c.left}px`,l.style.top=`${c.top}px`,l.style.width=`${c.width}px`,l.style.height=`${c.height}px`,l}function fu(n){const t=fi(n);let e=0;return t.forEach(r=>{e+=mr(r)}),e}var u7=typeof global=="object"&&global&&global.Object===Object&&global;const f7=u7;var d7=typeof self=="object"&&self&&self.Object===Object&&self,h7=f7||d7||Function("return this")();const u1=h7;var m7=u1.Symbol;const Ho=m7;var f3=Object.prototype,g7=f3.hasOwnProperty,p7=f3.toString,du=Ho?Ho.toStringTag:void 0;function C7(n){var t=g7.call(n,du),e=n[du];try{n[du]=void 0;var r=!0}catch{}var i=p7.call(n);return r&&(t?n[du]=e:delete n[du]),i}var E7=Object.prototype,x7=E7.toString;function A7(n){return x7.call(n)}var b7="[object Null]",v7="[object Undefined]",d3=Ho?Ho.toStringTag:void 0;function f1(n){return n==null?n===void 0?v7:b7:d3&&d3 in Object(n)?C7(n):A7(n)}function d1(n){return n!=null&&typeof n=="object"}var B7="[object Symbol]";function h1(n){return typeof n=="symbol"||d1(n)&&f1(n)==B7}function T7(n,t){for(var e=-1,r=n==null?0:n.length,i=Array(r);++e<r;)i[e]=t(n[e],e,n);return i}var y7=Array.isArray;const hu=y7;var k7=1/0,h3=Ho?Ho.prototype:void 0,m3=h3?h3.toString:void 0;function g3(n){if(typeof n=="string")return n;if(hu(n))return T7(n,g3)+"";if(h1(n))return m3?m3.call(n):"";var t=n+"";return t=="0"&&1/n==-k7?"-0":t}function Jd(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}function R7(n){return n}var w7="[object AsyncFunction]",S7="[object Function]",L7="[object GeneratorFunction]",I7="[object Proxy]";function D7(n){if(!Jd(n))return!1;var t=f1(n);return t==S7||t==L7||t==w7||t==I7}var _7=u1["__core-js_shared__"];const m1=_7;var p3=function(){var n=/[^.]+$/.exec(m1&&m1.keys&&m1.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function M7(n){return!!p3&&p3 in n}var U7=Function.prototype,O7=U7.toString;function N7(n){if(n!=null){try{return O7.call(n)}catch{}try{return n+""}catch{}}return""}var P7=/[\\^$.*+?()[\]{}|]/g,F7=/^\[object .+?Constructor\]$/,K7=Function.prototype,V7=Object.prototype,$7=K7.toString,H7=V7.hasOwnProperty,j7=RegExp("^"+$7.call(H7).replace(P7,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function z7(n){if(!Jd(n)||M7(n))return!1;var t=D7(n)?j7:F7;return t.test(N7(n))}function G7(n,t){return n==null?void 0:n[t]}function g1(n,t){var e=G7(n,t);return z7(e)?e:void 0}function W7(n,t,e){switch(e.length){case 0:return n.call(t);case 1:return n.call(t,e[0]);case 2:return n.call(t,e[0],e[1]);case 3:return n.call(t,e[0],e[1],e[2])}return n.apply(t,e)}var q7=800,X7=16,Q7=Date.now;function Y7(n){var t=0,e=0;return function(){var r=Q7(),i=X7-(r-e);if(e=r,i>0){if(++t>=q7)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}function J7(n){return function(){return n}}var Z7=function(){try{var n=g1(Object,"defineProperty");return n({},"",{}),n}catch{}}();const Zd=Z7;var tD=Zd?function(n,t){return Zd(n,"toString",{configurable:!0,enumerable:!1,value:J7(t),writable:!0})}:R7,eD=Y7(tD);const nD=eD;var rD=9007199254740991,iD=/^(?:0|[1-9]\d*)$/;function C3(n,t){var e=typeof n;return t=t==null?rD:t,!!t&&(e=="number"||e!="symbol"&&iD.test(n))&&n>-1&&n%1==0&&n<t}function oD(n,t,e){t=="__proto__"&&Zd?Zd(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}function E3(n,t){return n===t||n!==n&&t!==t}var sD=Object.prototype,lD=sD.hasOwnProperty;function aD(n,t,e){var r=n[t];(!(lD.call(n,t)&&E3(r,e))||e===void 0&&!(t in n))&&oD(n,t,e)}var x3=Math.max;function cD(n,t,e){return t=x3(t===void 0?n.length-1:t,0),function(){for(var r=arguments,i=-1,o=x3(r.length-t,0),s=Array(o);++i<o;)s[i]=r[t+i];i=-1;for(var l=Array(t+1);++i<t;)l[i]=r[i];return l[t]=e(s),W7(n,this,l)}}var uD=9007199254740991;function fD(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=uD}var dD="[object Arguments]";function A3(n){return d1(n)&&f1(n)==dD}var b3=Object.prototype,hD=b3.hasOwnProperty,mD=b3.propertyIsEnumerable,gD=A3(function(){return arguments}())?A3:function(n){return d1(n)&&hD.call(n,"callee")&&!mD.call(n,"callee")};const v3=gD;var pD=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,CD=/^\w*$/;function ED(n,t){if(hu(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||h1(n)?!0:CD.test(n)||!pD.test(n)||t!=null&&n in Object(t)}var xD=g1(Object,"create");const mu=xD;function AD(){this.__data__=mu?mu(null):{},this.size=0}function bD(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}var vD="__lodash_hash_undefined__",BD=Object.prototype,TD=BD.hasOwnProperty;function yD(n){var t=this.__data__;if(mu){var e=t[n];return e===vD?void 0:e}return TD.call(t,n)?t[n]:void 0}var kD=Object.prototype,RD=kD.hasOwnProperty;function wD(n){var t=this.__data__;return mu?t[n]!==void 0:RD.call(t,n)}var SD="__lodash_hash_undefined__";function LD(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=mu&&t===void 0?SD:t,this}function qs(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}qs.prototype.clear=AD,qs.prototype.delete=bD,qs.prototype.get=yD,qs.prototype.has=wD,qs.prototype.set=LD;function ID(){this.__data__=[],this.size=0}function th(n,t){for(var e=n.length;e--;)if(E3(n[e][0],t))return e;return-1}var DD=Array.prototype,_D=DD.splice;function MD(n){var t=this.__data__,e=th(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():_D.call(t,e,1),--this.size,!0}function UD(n){var t=this.__data__,e=th(t,n);return e<0?void 0:t[e][1]}function OD(n){return th(this.__data__,n)>-1}function ND(n,t){var e=this.__data__,r=th(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}function Ca(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Ca.prototype.clear=ID,Ca.prototype.delete=MD,Ca.prototype.get=UD,Ca.prototype.has=OD,Ca.prototype.set=ND;var PD=g1(u1,"Map");const FD=PD;function KD(){this.size=0,this.__data__={hash:new qs,map:new(FD||Ca),string:new qs}}function VD(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}function eh(n,t){var e=n.__data__;return VD(t)?e[typeof t=="string"?"string":"hash"]:e.map}function $D(n){var t=eh(this,n).delete(n);return this.size-=t?1:0,t}function HD(n){return eh(this,n).get(n)}function jD(n){return eh(this,n).has(n)}function zD(n,t){var e=eh(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}function Xs(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Xs.prototype.clear=KD,Xs.prototype.delete=$D,Xs.prototype.get=HD,Xs.prototype.has=jD,Xs.prototype.set=zD;var GD="Expected a function";function p1(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new TypeError(GD);var e=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=e.cache;if(o.has(i))return o.get(i);var s=n.apply(this,r);return e.cache=o.set(i,s)||o,s};return e.cache=new(p1.Cache||Xs),e}p1.Cache=Xs;var WD=500;function qD(n){var t=p1(n,function(r){return e.size===WD&&e.clear(),r}),e=t.cache;return t}var XD=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,QD=/\\(\\)?/g,YD=qD(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(XD,function(e,r,i,o){t.push(i?o.replace(QD,"$1"):r||e)}),t});const JD=YD;function C1(n){return n==null?"":g3(n)}function nh(n,t){return hu(n)?n:ED(n,t)?[n]:JD(C1(n))}var ZD=1/0;function E1(n){if(typeof n=="string"||h1(n))return n;var t=n+"";return t=="0"&&1/n==-ZD?"-0":t}function t8(n,t){t=nh(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[E1(t[e++])];return e&&e==r?n:void 0}function e8(n,t){for(var e=-1,r=t.length,i=n.length;++e<r;)n[i+e]=t[e];return n}var B3=Ho?Ho.isConcatSpreadable:void 0;function n8(n){return hu(n)||v3(n)||!!(B3&&n&&n[B3])}function T3(n,t,e,r,i){var o=-1,s=n.length;for(e||(e=n8),i||(i=[]);++o<s;){var l=n[o];t>0&&e(l)?t>1?T3(l,t-1,e,r,i):e8(i,l):r||(i[i.length]=l)}return i}function r8(n){var t=n==null?0:n.length;return t?T3(n,1):[]}function i8(n){return nD(cD(n,void 0,r8),n+"")}function o8(n,t,e,r){var i=-1,o=n==null?0:n.length;for(r&&o&&(e=n[++i]);++i<o;)e=t(e,n[i],i,n);return e}function s8(n){return function(t){return n==null?void 0:n[t]}}var l8={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},a8=s8(l8);const c8=a8;var u8=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,f8="\\u0300-\\u036f",d8="\\ufe20-\\ufe2f",h8="\\u20d0-\\u20ff",m8=f8+d8+h8,g8="["+m8+"]",p8=RegExp(g8,"g");function C8(n){return n=C1(n),n&&n.replace(u8,c8).replace(p8,"")}var E8=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function x8(n){return n.match(E8)||[]}var A8=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function b8(n){return A8.test(n)}var y3="\\ud800-\\udfff",v8="\\u0300-\\u036f",B8="\\ufe20-\\ufe2f",T8="\\u20d0-\\u20ff",y8=v8+B8+T8,k3="\\u2700-\\u27bf",R3="a-z\\xdf-\\xf6\\xf8-\\xff",k8="\\xac\\xb1\\xd7\\xf7",R8="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",w8="\\u2000-\\u206f",S8=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",w3="A-Z\\xc0-\\xd6\\xd8-\\xde",L8="\\ufe0e\\ufe0f",S3=k8+R8+w8+S8,L3="['\u2019]",I3="["+S3+"]",I8="["+y8+"]",D3="\\d+",D8="["+k3+"]",_3="["+R3+"]",M3="[^"+y3+S3+D3+k3+R3+w3+"]",_8="\\ud83c[\\udffb-\\udfff]",M8="(?:"+I8+"|"+_8+")",U8="[^"+y3+"]",U3="(?:\\ud83c[\\udde6-\\uddff]){2}",O3="[\\ud800-\\udbff][\\udc00-\\udfff]",Ea="["+w3+"]",O8="\\u200d",N3="(?:"+_3+"|"+M3+")",N8="(?:"+Ea+"|"+M3+")",P3="(?:"+L3+"(?:d|ll|m|re|s|t|ve))?",F3="(?:"+L3+"(?:D|LL|M|RE|S|T|VE))?",K3=M8+"?",V3="["+L8+"]?",P8="(?:"+O8+"(?:"+[U8,U3,O3].join("|")+")"+V3+K3+")*",F8="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",K8="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",V8=V3+K3+P8,$8="(?:"+[D8,U3,O3].join("|")+")"+V8,H8=RegExp([Ea+"?"+_3+"+"+P3+"(?="+[I3,Ea,"$"].join("|")+")",N8+"+"+F3+"(?="+[I3,Ea+N3,"$"].join("|")+")",Ea+"?"+N3+"+"+P3,Ea+"+"+F3,K8,F8,D3,$8].join("|"),"g");function j8(n){return n.match(H8)||[]}function z8(n,t,e){return n=C1(n),t=e?void 0:t,t===void 0?b8(n)?j8(n):x8(n):n.match(t)||[]}var G8="['\u2019]",W8=RegExp(G8,"g");function q8(n){return function(t){return o8(z8(C8(t).replace(W8,"")),n,"")}}function X8(n,t){return n!=null&&t in Object(n)}function Q8(n,t,e){t=nh(t,n);for(var r=-1,i=t.length,o=!1;++r<i;){var s=E1(t[r]);if(!(o=n!=null&&e(n,s)))break;n=n[s]}return o||++r!=i?o:(i=n==null?0:n.length,!!i&&fD(i)&&C3(s,i)&&(hu(n)||v3(n)))}function Y8(n,t){return n!=null&&Q8(n,t,X8)}var J8=q8(function(n,t,e){return n+(e?"-":"")+t.toLowerCase()});const Z8=J8;function t_(n,t,e,r){if(!Jd(n))return n;t=nh(t,n);for(var i=-1,o=t.length,s=o-1,l=n;l!=null&&++i<o;){var c=E1(t[i]),d=e;if(c==="__proto__"||c==="constructor"||c==="prototype")return n;if(i!=s){var h=l[c];d=r?r(h,c,l):void 0,d===void 0&&(d=Jd(h)?h:C3(t[i+1])?[]:{})}aD(l,c,d),l=l[c]}return n}function e_(n,t,e){for(var r=-1,i=t.length,o={};++r<i;){var s=t[r],l=t8(n,s);e(l,s)&&t_(o,nh(s,n),l)}return o}function n_(n,t){return e_(n,t,function(e,r){return Y8(n,r)})}var r_=i8(function(n,t){return n==null?{}:n_(n,t)});const i_=r_,$3=I("box");function jo(n){return!n.attributes||!n.attributes.box?!1:(p($3,typeof n.attributes.box=="string"&&n.attributes.box==="true"||n.attributes.box===!0,`invalid op attribute box property, ${n.attributes.box}`),p($3,n.attributes.type,`no box type: ${JSON.stringify(n)}`),!0)}const H3=I("text-op");function rh(n){return p(H3,typeof n.insert=="string","invalid op, no insert"),n.insert.length}function j3(n,t){const e=n;let r=0;for(let i=0;i<e.length;i++){const o=e[i];p(H3,typeof o.insert=="string","invalid text op, no insert");const s=r+rh(o);if(s>t)return[o];if(s===t){const l=[o];return i<e.length-1&&l.push(e[i+1]),l}r=s}return[]}const z3=I("rich-text-length");function x1(n){return p(z3,typeof n.insert=="string","op.insert is not string"),n.insert.length}function un(n){let t=0;return n.forEach(e=>{e.insert&&(p(z3,typeof e.insert=="string","op.insert is not string"),t+=x1(e))}),t}const mi=I("split-text");function _n(n,t,e){if(n=gt.default(n),t===0)return{left:[],right:n};if(t===-1)return{left:n,right:[]};let r=0;for(let i=0;i<n.length;i++){const o=n[i];p(mi,typeof o=="object",`invalid op type, ${typeof o}`),p(mi,typeof o.insert=="string",`invalid op.insert type, ${typeof o.insert}`);const s=x1(o);if(r+s<t)r+=s;else{if(r+s===t)return{left:n.slice(0,i+1),right:n.slice(i+1)};{p(mi,r+s>t,`invalid offset, ${r}, ${s}, ${t}`);const l=t-r,c=gt.default(o);p(mi,c.insert,"no copied.insert"),p(mi,typeof c.insert=="string","invalid copied.insert type"),c.insert=c.insert.substr(0,l),o.insert=o.insert.substr(l),c.insert===""&&p(mi,!1,"invalid copied.insert, is empty string"),o.insert===""&&p(mi,!1,"invalid op.insert, is empty string");const d=[o,...n.slice(i+1)],h=[...n.splice(0,i),c];return e&&(e.sourceOp=o),{left:h,right:d}}}}throw new Error(`invalid split offset: ${t}, ${JSON.stringify(n)}`)}function Xe(n,t,e){p(mi,t>=0,"invalid offset, < 0"),p(mi,e>0,"invalid length, <= 0"),p(mi,t+e<=un(n),"invalid offset + length < text length");const{left:r,right:i}=_n(n,t+e),{left:o,right:s}=_n(r,t);return{left:o,middle:s,right:i}}function G3(n,t){const e=Array.from(new Set(t)).sort((o,s)=>o-s),r=[];let i=n;for(let o=e.length-1;o>=0;o--){const s=e[o],{left:l,right:c}=_n(i,s);i=l,r.unshift(c)}return i.length>0&&r.unshift(i),r}function W3(n,t,e){return Xe(n,t,e).middle}const A1="style-color-",b1="style-bg-color-";function ih(n,t,e){const r=gt.default(n);return r.forEach(i=>{if(!(i.attributes&&i.attributes.box===!0))if(e===void 0){if(!i.attributes||i.attributes[t]===void 0)return;delete i.attributes[t],Object.keys(i.attributes).length===0&&delete i.attributes}else i.attributes||(i.attributes={}),i.attributes[t]=e}),r}function v1(n,t,e,r){const i=gt.default(n);return i.forEach(o=>{o.attributes&&o.attributes.box===!0||o.attributes&&((r==null?void 0:r.ignoreValue)||o.attributes[t]===e)&&(delete o.attributes[t],Object.keys(o.attributes).length===0&&delete o.attributes)}),i}function gu(n,t,e,r,i){if(t===0)return e;const o=Xe(e,n,t);return[...o.left,...ih(o.middle,r,i),...o.right]}function xa(n,t,e,r,i,o){if(t===0)return e;const s=Xe(e,n,t);return[...s.left,...v1(s.middle,r,i,o),...s.right]}function Aa(n,t){const e=j3(n,t);if(e.length===1)return e[0].attributes;if(e.length===2)return e[1].attributes}function q3(n,t,e,r){if(t===0)return e;const i=Xe(e,n,t),o=i.middle.map(s=>r(s));return[...i.left,...o,...i.right]}function X3(n,t){t==="color"?Object.keys(n).forEach(e=>{(e.startsWith("style-color-")||e==="inline-style-color")&&delete n[e]}):t==="backgroundColor"&&Object.keys(n).forEach(e=>{e.startsWith("style-bg-color-")&&delete n[e]})}function o_(n,t){if(!n.attributes||n.attributes.box)return;const e=n.attributes;X3(e,t),Object.keys(e).length===0&&delete n.attributes}function s_(n,t,e){n.attributes||(n.attributes={}),!n.attributes.box&&(t==="color"?n.attributes[`style-color-${e}`]=!0:n.attributes[`style-bg-color-${e}`]=!0)}function Q3(n,t,e,r,i){const o=gt.default(e);return q3(n,t,o,l=>(o_(l,r),i!==null&&s_(l,r,i),l))}function B1(n){var i,o;if(!n||n.box)return[null,null];const t=Array.from(Object.keys(n));let e=null,r=null;for(let s=0;s<t.length;s++){const l=t[s];l.startsWith(A1)?e=(i=Number.parseInt(l.substring(A1.length),10))!=null?i:null:l.startsWith(b1)&&(r=(o=Number.parseInt(l.substring(b1.length),10))!=null?o:null)}return[e,r]}function Y3(n,t,e){X3(n,t),t==="color"?n[`style-color-${e}`]=!0:n[`style-bg-color-${e}`]=!0}function J3(n){return n.attributes?n.attributes.box?[null,null]:B1(n.attributes):[null,null]}function Z3(n,t,e){let r=[];if(t===0?n!==0&&(r=Xe(e,n-1,1).middle):r=Xe(e,n,t).middle,r.length===0)return[null,null];let[i,o]=J3(r[0]);if(i===null&&o===null)return[i,o];for(let s=1;s<r.length;s++){const l=r[s];if(!l.attributes)return[null,null];if(l.attributes.box)continue;const[c,d]=J3(l);c===null||i===null?i=null:i=c===i?i:null,d===null||o===null?o=null:o=d===o?o:null}return[i,o]}const ba=I("text-block-content");function l_(n,t,e,r,i){if(p(ba,r,"no text for block"),r.length===0&&(!i||i.size===0)){e.innerHTML="<span><br></span>";return}const o=[];i&&o.push(...i.keys());const s=C=>n.editorInsertions.createInsertion(e,C),l=(C,E)=>{const A=i==null?void 0:i.get(E);A&&(A.forEach(v=>{C.appendChild(s(v))}),i==null||i.delete(E))},c=document.createDocumentFragment();let d=0;const h=G3(r,o);for(let C=0;C<h.length;C++){l(c,d);const E=h[C];d+=un(E);for(let A=0;A<E.length;A++){const v=E[A];if(jo(v)){p(ba,v.attributes,`op is not an valid box: ${JSON.stringify(v)}`);const L=n.editorBoxes.createBox(e,v.attributes);p(ba,L instanceof HTMLSpanElement,`invalid box element: ${L.tagName}`);const M=n.editorBlockRenders.renderBox(t,v.attributes);M.classes&&z(L,...M.classes),M.attributes&&Object.entries(M.attributes).forEach(([U,F])=>{L.setAttribute(U,F)}),M.styles&&Object.entries(M.styles).forEach(([U,F])=>{L.style.setProperty(U,F)}),c.appendChild(L);continue}p(ba,v.insert,`no insert in op: ${JSON.stringify(v)}`);const R=B("span",["text"],c,v.insert);if(v.attributes){const L=n.editorBlockRenders.renderText(t,v.attributes);L.classes&&z(R,...L.classes),L.attributes&&Object.entries(L.attributes).forEach(([M,U])=>{R.setAttribute(M,U)}),L.styles&&Object.entries(L.styles).forEach(([M,U])=>{R.style.setProperty(Z8(M),U)})}c.appendChild(R)}}l(c,d),e.innerHTML="",e.appendChild(c)}function oh(n,t,e,r,i){const{text:o,insertions:s}=n.editorDecorators.decorateText(t,i),l=n.compositingText;if(l){const c=n.selection.range.start;if(p(ba,c.isSimple(),"not an simple position while compositing"),c.blockId===e){const d=Aa(o,0);s.set(c.offset,[{type:"inputting",id:Z(),text:l,attributes:d}])}}return l_(n,t,r,o,s)}function a_(n){const t=n.rootContainer.querySelectorAll('span[data-type="editor-insertion"].inputting-insertion');t.length&&ba.debug(`remove ${t.length} temp composition span`),Array.from(t).forEach(e=>e.remove())}const gi=I("client-rects");function c_(n){const t=fi(n);let e=0;const r=[];for(let i=0;i<t.length;i++){const o=t[i],s=mr(o);r.push({child:o,startBlockOffset:e,endBlockOffset:e+s}),e+=s}return r}function u_(n,t,e,r){p(gi,e<r,`invalid from & to: ${e}, ${r}`);const i=dt(n,t);p(gi,e>=0&&r>=0&&e<=i&&r<=i,`invalid offset: ${e}, ${r}, length: ${i}`);const o=c_(t),s=o.findIndex(A=>A.startBlockOffset<=e&&e<A.endBlockOffset),l=o.findIndex(A=>A.startBlockOffset<r&&r<=A.endBlockOffset);if(p(gi,s!==-1,"failed to find start child"),p(gi,l!==-1,"failed to find end child"),p(gi,s<=l,`invalid start index & end index: ${s}, ${l}`),s===l){const A=o[s];return[{child:A.child,startChildOffset:e-A.startBlockOffset,endChildOffset:r-A.startBlockOffset}]}const c=[],d=o[s],h={child:d.child,startChildOffset:e-d.startBlockOffset,endChildOffset:mr(d.child)};c.push(h);for(let A=s+1;A<l;A++){const v=o[A],R={child:v.child,startChildOffset:0,endChildOffset:v.endBlockOffset-v.startBlockOffset};c.push(R)}const C=o[l],E={child:C.child,startChildOffset:0,endChildOffset:r-C.startBlockOffset};return c.push(E),c}function f_(n){const t=(r,i)=>r.left<=i.left&&r.top<=i.top&&r.right>=i.right&&r.bottom>=i.bottom&&(r.width!==i.width||r.height!==i.height);n=n.filter(r=>!n.find(o=>t(r,o)));const e=[];return n=n.filter(r=>e.find(i=>i.left===r.left&&i.top===r.top&&i.width===r.width&&i.height===r.height)?!1:(e.push(r),!0)),n}function tB(n,t,e,r){if(dt(n,t)===0){const h=Ot(t).getBoundingClientRect();return[new DOMRect(h.left,h.top,4,h.height)]}const i=e.offset,o=r.offset;if(i===o)return[Yn(t,e)];const l=u_(n,t,i,o).map(d=>l7(d.child,d.startChildOffset,d.endChildOffset)),c=[];return l.forEach(d=>{const h=f_(Array.from(d.getClientRects()));c.push(...h)}),c}function d_(n,t,e){p(gi,e instanceof tn,"invalid range");const r=e.start,i=e.end;return p(gi,r.isSimple(),"text block only allow simple position"),p(gi,i.isSimple(),"text block only allow simple position"),p(gi,r.blockId===i.blockId,"only allow update one text block selection"),p(gi,r.blockId===st(t),"only allow update one text block selection"),tB(n,t,r,i)}const T1=I("selection-background");function h_(n,t,e,r){p(T1,e.isSimple(),"text block only allow simple position"),p(T1,r.isSimple(),"text block only allow simple position"),p(T1,e.blockId===r.blockId,"only allow update one text block selection");const i=e.offset,o=r.offset;if(i===o&&(dt(n,t)!==0||n.selection.range.isCollapsed()))return;const s=tB(n,t,e,r),l=t.getBoundingClientRect(),c=fr(t),d=kv(t);Array.from(d.children).forEach((h,C)=>{if(C<s.length){const E=s[C],A=h;A.style.left=`${(E.left-l.left-t.clientLeft)/c}px`,A.style.top=`${(E.top-l.top-t.clientTop)/c}px`,A.style.width=`${E.width/c}px`,A.style.height=`${E.height/c}px`}else h.remove()}),s.slice(d.children.length).forEach(h=>{const C=B("div",["editor-selection-background"],d);C.style.left=`${(h.left-l.left-t.clientLeft)/c}px`,C.style.top=`${(h.top-l.top-t.clientTop)/c}px`,C.style.width=`${h.width/c}px`,C.style.height=`${h.height/c}px`})}function m_(n){const t=n.selection.range.getSelectedBlocks(),e=n.selection.range.isCollapsed();n.rootContainer.querySelectorAll("div[data-type=block-background]").forEach(r=>{const i=et(r);i&&nt(n,i)&&(!t.find(o=>o.block===i)||e)&&r.remove()})}const pu=I("line-breaker");function eB(n){const t=[];let e=null;for(let r=0;r<n.length;r++){let i=n[r];!!e&&i.top===e.top?(i=new DOMRect(e.left,e.top,e.width+i.width,i.height),t.splice(t.length-1,1,i)):t.push(i),e=i}return t}function g_(n){const t=document.createRange();return t.setStart(n,0),t.setEnd(n,n.data.length),eB(t.getClientRects())}function Cu(n){const t=l=>{if(!l)return!1;const c=Dd(l);return Us(l).top>c.top+c.height/2},e=(l,c)=>{const d=Us(l),h=Dd(c);return Math.floor(h.left)<Math.floor(d.right)},r=(l,c)=>{const d=Us(l),h=Us(c);return h.top+h.height/2>d.bottom},i=[];let o=0;const s=fi(n);for(let l=0;l<s.length;l++){const c=s[l];if(Qi(c)){const v=c,R=s[l+1];if(!R)break;const L=s[l-1];if(L&&r(L,v)&&i.push({offset:o,type:"betweenChild",childInfo:{prevChild:L,nextChild:v,wrap:"nextWrapped",prevWrapped:t(L),nextWrapped:t(v)}}),e(v,R)){i.push({offset:o,type:"betweenChild",childInfo:{prevChild:L,nextChild:v,wrap:"nowrap",prevWrapped:t(L),nextWrapped:t(v)}});continue}continue}if(hr(c)){const v=c,R=s[l+1];if(!R)break;const L=s[l-1];if(L&&r(L,v)&&i.push({offset:o,type:"betweenChild",childInfo:{prevChild:L,nextChild:v,wrap:"nextWrapped",prevWrapped:t(L),nextWrapped:t(v)}}),e(v,R)){o+=1,i.push({offset:o,type:"betweenChild",childInfo:{prevChild:L,nextChild:c,wrap:"nowrap",prevWrapped:t(L),nextWrapped:t(c)}});continue}o+=1;continue}const d=c,h=eB(d.getClientRects());if(p(pu,h.length>0,"invalid text child dom"),h.length===1){const v=s[l+1];if(!v)break;if(e(d,v)){o+=mr(d),i.push({offset:o,type:"betweenChild",childInfo:{prevChild:d,nextChild:v,wrap:"nowrap",prevWrapped:t(d),nextWrapped:t(v)}});continue}o+=mr(d);continue}const C=d.firstChild;p(pu,C,"invalid text child, no text node"),p(pu,C instanceof Text,`invalid text child, not a valid text node: ${typeof C}`);const E=mr(d);p(pu,C.data.length===E,"text node data length not equal child text length");const A=g_(C);for(let v=0;v<A.length-1;v++){const R=A[v],L=wg(R.right,R.top);L.offset>-1&&L.textNode===C&&i.push({offset:o+L.offset,type:"textBreakWord",childInfo:{prevChild:c,nextChild:c,wrap:"nowrap",prevWrapped:t(c),nextWrapped:t(c)}})}o+=E}return i}function y1(n,t){const e=Cu(n);for(let r=0;r<e.length;r++){const{offset:i}=e[r];if(t.offset<i)return{lineIndex:r,lineBreaks:e};if(t.offset===i&&t.type==="end")return{lineIndex:r,lineBreaks:e}}return p(pu,t.offset<=fu(n),"invalid position, offset > block length"),{lineIndex:e.length,lineBreaks:e}}var Mn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},nB={},k1={},R1={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.EXTENDED_PICTOGRAPHIC=n.CLUSTER_BREAK=void 0,function(t){t[t.CR=0]="CR",t[t.LF=1]="LF",t[t.CONTROL=2]="CONTROL",t[t.EXTEND=3]="EXTEND",t[t.REGIONAL_INDICATOR=4]="REGIONAL_INDICATOR",t[t.SPACINGMARK=5]="SPACINGMARK",t[t.L=6]="L",t[t.V=7]="V",t[t.T=8]="T",t[t.LV=9]="LV",t[t.LVT=10]="LVT",t[t.OTHER=11]="OTHER",t[t.PREPEND=12]="PREPEND",t[t.E_BASE=13]="E_BASE",t[t.E_MODIFIER=14]="E_MODIFIER",t[t.ZWJ=15]="ZWJ",t[t.GLUE_AFTER_ZWJ=16]="GLUE_AFTER_ZWJ",t[t.E_BASE_GAZ=17]="E_BASE_GAZ"}(n.CLUSTER_BREAK||(n.CLUSTER_BREAK={})),n.EXTENDED_PICTOGRAPHIC=101})(R1);var w1={};Object.defineProperty(w1,"__esModule",{value:!0});const $t=R1,Ji=0,S1=1,p_=2,C_=3,E_=4;class x_{static isSurrogate(t,e){return 55296<=t.charCodeAt(e)&&t.charCodeAt(e)<=56319&&56320<=t.charCodeAt(e+1)&&t.charCodeAt(e+1)<=57343}static codePointAt(t,e){e===void 0&&(e=0);const r=t.charCodeAt(e);if(55296<=r&&r<=56319&&e<t.length-1){const i=r,o=t.charCodeAt(e+1);return 56320<=o&&o<=57343?(i-55296)*1024+(o-56320)+65536:i}if(56320<=r&&r<=57343&&e>=1){const i=t.charCodeAt(e-1),o=r;return 55296<=i&&i<=56319?(i-55296)*1024+(o-56320)+65536:o}return r}static shouldBreak(t,e,r,i,o,s){const l=[t].concat(e).concat([r]),c=[i].concat(o).concat([s]),d=l[l.length-2],h=r,C=s,E=l.lastIndexOf($t.CLUSTER_BREAK.REGIONAL_INDICATOR);if(E>0&&l.slice(1,E).every(function(v){return v===$t.CLUSTER_BREAK.REGIONAL_INDICATOR})&&[$t.CLUSTER_BREAK.PREPEND,$t.CLUSTER_BREAK.REGIONAL_INDICATOR].indexOf(d)===-1)return l.filter(function(v){return v===$t.CLUSTER_BREAK.REGIONAL_INDICATOR}).length%2===1?C_:E_;if(d===$t.CLUSTER_BREAK.CR&&h===$t.CLUSTER_BREAK.LF)return Ji;if(d===$t.CLUSTER_BREAK.CONTROL||d===$t.CLUSTER_BREAK.CR||d===$t.CLUSTER_BREAK.LF)return S1;if(h===$t.CLUSTER_BREAK.CONTROL||h===$t.CLUSTER_BREAK.CR||h===$t.CLUSTER_BREAK.LF)return S1;if(d===$t.CLUSTER_BREAK.L&&(h===$t.CLUSTER_BREAK.L||h===$t.CLUSTER_BREAK.V||h===$t.CLUSTER_BREAK.LV||h===$t.CLUSTER_BREAK.LVT))return Ji;if((d===$t.CLUSTER_BREAK.LV||d===$t.CLUSTER_BREAK.V)&&(h===$t.CLUSTER_BREAK.V||h===$t.CLUSTER_BREAK.T))return Ji;if((d===$t.CLUSTER_BREAK.LVT||d===$t.CLUSTER_BREAK.T)&&h===$t.CLUSTER_BREAK.T)return Ji;if(h===$t.CLUSTER_BREAK.EXTEND||h===$t.CLUSTER_BREAK.ZWJ)return Ji;if(h===$t.CLUSTER_BREAK.SPACINGMARK)return Ji;if(d===$t.CLUSTER_BREAK.PREPEND)return Ji;const A=c.slice(0,-1).lastIndexOf($t.EXTENDED_PICTOGRAPHIC);return A!==-1&&c[A]===$t.EXTENDED_PICTOGRAPHIC&&l.slice(A+1,-2).every(function(v){return v===$t.CLUSTER_BREAK.EXTEND})&&d===$t.CLUSTER_BREAK.ZWJ&&C===$t.EXTENDED_PICTOGRAPHIC?Ji:e.indexOf($t.CLUSTER_BREAK.REGIONAL_INDICATOR)!==-1?p_:d===$t.CLUSTER_BREAK.REGIONAL_INDICATOR&&h===$t.CLUSTER_BREAK.REGIONAL_INDICATOR?Ji:S1}}w1.default=x_;var L1={};Object.defineProperty(L1,"__esModule",{value:!0});class A_{constructor(t,e){this._index=0,this._str=t,this._nextBreak=e}[Symbol.iterator](){return this}next(){let t;if((t=this._nextBreak(this._str,this._index))<this._str.length){const e=this._str.slice(this._index,t);return this._index=t,{value:e,done:!1}}if(this._index<this._str.length){const e=this._str.slice(this._index);return this._index=this._str.length,{value:e,done:!1}}return{value:void 0,done:!0}}}L1.default=A_;var rB=Mn&&Mn.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(k1,"__esModule",{value:!0});const f=R1,sh=rB(w1),b_=rB(L1);class Zi{static nextBreak(t,e){if(e===void 0&&(e=0),e<0)return 0;if(e>=t.length-1)return t.length;const r=sh.default.codePointAt(t,e),i=Zi.getGraphemeBreakProperty(r),o=Zi.getEmojiProperty(r),s=[],l=[];for(let c=e+1;c<t.length;c++){if(sh.default.isSurrogate(t,c-1))continue;const d=sh.default.codePointAt(t,c),h=Zi.getGraphemeBreakProperty(d),C=Zi.getEmojiProperty(d);if(sh.default.shouldBreak(i,s,h,o,l,C))return c;s.push(h),l.push(C)}return t.length}splitGraphemes(t){const e=[];let r=0,i;for(;(i=Zi.nextBreak(t,r))<t.length;)e.push(t.slice(r,i)),r=i;return r<t.length&&e.push(t.slice(r)),e}iterateGraphemes(t){return new b_.default(t,Zi.nextBreak)}countGraphemes(t){let e=0,r=0,i;for(;(i=Zi.nextBreak(t,r))<t.length;)r=i,e++;return r<t.length&&e++,e}static getGraphemeBreakProperty(t){if(t<48905){if(t<44116){if(t<4141){if(t<2818){if(t<2363)if(t<1759){if(t<1471){if(t<127){if(t<11){if(t<10){if(0<=t&&t<=9)return f.CLUSTER_BREAK.CONTROL}else if(t===10)return f.CLUSTER_BREAK.LF}else if(t<13){if(11<=t&&t<=12)return f.CLUSTER_BREAK.CONTROL}else if(t<14){if(t===13)return f.CLUSTER_BREAK.CR}else if(14<=t&&t<=31)return f.CLUSTER_BREAK.CONTROL}else if(t<768){if(t<173){if(127<=t&&t<=159)return f.CLUSTER_BREAK.CONTROL}else if(t===173)return f.CLUSTER_BREAK.CONTROL}else if(t<1155){if(768<=t&&t<=879)return f.CLUSTER_BREAK.EXTEND}else if(t<1425){if(1155<=t&&t<=1161)return f.CLUSTER_BREAK.EXTEND}else if(1425<=t&&t<=1469)return f.CLUSTER_BREAK.EXTEND}else if(t<1552){if(t<1476){if(t<1473){if(t===1471)return f.CLUSTER_BREAK.EXTEND}else if(1473<=t&&t<=1474)return f.CLUSTER_BREAK.EXTEND}else if(t<1479){if(1476<=t&&t<=1477)return f.CLUSTER_BREAK.EXTEND}else if(t<1536){if(t===1479)return f.CLUSTER_BREAK.EXTEND}else if(1536<=t&&t<=1541)return f.CLUSTER_BREAK.PREPEND}else if(t<1648){if(t<1564){if(1552<=t&&t<=1562)return f.CLUSTER_BREAK.EXTEND}else if(t<1611){if(t===1564)return f.CLUSTER_BREAK.CONTROL}else if(1611<=t&&t<=1631)return f.CLUSTER_BREAK.EXTEND}else if(t<1750){if(t===1648)return f.CLUSTER_BREAK.EXTEND}else if(t<1757){if(1750<=t&&t<=1756)return f.CLUSTER_BREAK.EXTEND}else if(t===1757)return f.CLUSTER_BREAK.PREPEND}else if(t<2075){if(t<1840)if(t<1770){if(t<1767){if(1759<=t&&t<=1764)return f.CLUSTER_BREAK.EXTEND}else if(1767<=t&&t<=1768)return f.CLUSTER_BREAK.EXTEND}else if(t<1807){if(1770<=t&&t<=1773)return f.CLUSTER_BREAK.EXTEND}else{if(t===1807)return f.CLUSTER_BREAK.PREPEND;if(t===1809)return f.CLUSTER_BREAK.EXTEND}else if(t<2027){if(t<1958){if(1840<=t&&t<=1866)return f.CLUSTER_BREAK.EXTEND}else if(1958<=t&&t<=1968)return f.CLUSTER_BREAK.EXTEND}else if(t<2045){if(2027<=t&&t<=2035)return f.CLUSTER_BREAK.EXTEND}else if(t<2070){if(t===2045)return f.CLUSTER_BREAK.EXTEND}else if(2070<=t&&t<=2073)return f.CLUSTER_BREAK.EXTEND}else if(t<2200){if(t<2089){if(t<2085){if(2075<=t&&t<=2083)return f.CLUSTER_BREAK.EXTEND}else if(2085<=t&&t<=2087)return f.CLUSTER_BREAK.EXTEND}else if(t<2137){if(2089<=t&&t<=2093)return f.CLUSTER_BREAK.EXTEND}else if(t<2192){if(2137<=t&&t<=2139)return f.CLUSTER_BREAK.EXTEND}else if(2192<=t&&t<=2193)return f.CLUSTER_BREAK.PREPEND}else if(t<2275){if(t<2250){if(2200<=t&&t<=2207)return f.CLUSTER_BREAK.EXTEND}else if(t<2274){if(2250<=t&&t<=2273)return f.CLUSTER_BREAK.EXTEND}else if(t===2274)return f.CLUSTER_BREAK.PREPEND}else if(t<2307){if(2275<=t&&t<=2306)return f.CLUSTER_BREAK.EXTEND}else{if(t===2307)return f.CLUSTER_BREAK.SPACINGMARK;if(t===2362)return f.CLUSTER_BREAK.EXTEND}else if(t<2561){if(t<2434){if(t<2381){if(t<2366){if(t===2363)return f.CLUSTER_BREAK.SPACINGMARK;if(t===2364)return f.CLUSTER_BREAK.EXTEND}else if(t<2369){if(2366<=t&&t<=2368)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2377){if(2369<=t&&t<=2376)return f.CLUSTER_BREAK.EXTEND}else if(2377<=t&&t<=2380)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2385){if(t<2382){if(t===2381)return f.CLUSTER_BREAK.EXTEND}else if(2382<=t&&t<=2383)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2402){if(2385<=t&&t<=2391)return f.CLUSTER_BREAK.EXTEND}else if(t<2433){if(2402<=t&&t<=2403)return f.CLUSTER_BREAK.EXTEND}else if(t===2433)return f.CLUSTER_BREAK.EXTEND}else if(t<2503){if(t<2494){if(t<2492){if(2434<=t&&t<=2435)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===2492)return f.CLUSTER_BREAK.EXTEND}else if(t<2495){if(t===2494)return f.CLUSTER_BREAK.EXTEND}else if(t<2497){if(2495<=t&&t<=2496)return f.CLUSTER_BREAK.SPACINGMARK}else if(2497<=t&&t<=2500)return f.CLUSTER_BREAK.EXTEND}else if(t<2519){if(t<2507){if(2503<=t&&t<=2504)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2509){if(2507<=t&&t<=2508)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===2509)return f.CLUSTER_BREAK.EXTEND}else if(t<2530){if(t===2519)return f.CLUSTER_BREAK.EXTEND}else if(t<2558){if(2530<=t&&t<=2531)return f.CLUSTER_BREAK.EXTEND}else if(t===2558)return f.CLUSTER_BREAK.EXTEND}else if(t<2691){if(t<2631){if(t<2620){if(t<2563){if(2561<=t&&t<=2562)return f.CLUSTER_BREAK.EXTEND}else if(t===2563)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2622){if(t===2620)return f.CLUSTER_BREAK.EXTEND}else if(t<2625){if(2622<=t&&t<=2624)return f.CLUSTER_BREAK.SPACINGMARK}else if(2625<=t&&t<=2626)return f.CLUSTER_BREAK.EXTEND}else if(t<2672){if(t<2635){if(2631<=t&&t<=2632)return f.CLUSTER_BREAK.EXTEND}else if(t<2641){if(2635<=t&&t<=2637)return f.CLUSTER_BREAK.EXTEND}else if(t===2641)return f.CLUSTER_BREAK.EXTEND}else if(t<2677){if(2672<=t&&t<=2673)return f.CLUSTER_BREAK.EXTEND}else if(t<2689){if(t===2677)return f.CLUSTER_BREAK.EXTEND}else if(2689<=t&&t<=2690)return f.CLUSTER_BREAK.EXTEND}else if(t<2761){if(t<2750){if(t===2691)return f.CLUSTER_BREAK.SPACINGMARK;if(t===2748)return f.CLUSTER_BREAK.EXTEND}else if(t<2753){if(2750<=t&&t<=2752)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2759){if(2753<=t&&t<=2757)return f.CLUSTER_BREAK.EXTEND}else if(2759<=t&&t<=2760)return f.CLUSTER_BREAK.EXTEND}else if(t<2786){if(t<2763){if(t===2761)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2765){if(2763<=t&&t<=2764)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===2765)return f.CLUSTER_BREAK.EXTEND}else if(t<2810){if(2786<=t&&t<=2787)return f.CLUSTER_BREAK.EXTEND}else if(t<2817){if(2810<=t&&t<=2815)return f.CLUSTER_BREAK.EXTEND}else if(t===2817)return f.CLUSTER_BREAK.EXTEND}else if(t<3315){if(t<3076){if(t<2946){if(t<2887){if(t<2878){if(t<2876){if(2818<=t&&t<=2819)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===2876)return f.CLUSTER_BREAK.EXTEND}else if(t<2880){if(2878<=t&&t<=2879)return f.CLUSTER_BREAK.EXTEND}else if(t<2881){if(t===2880)return f.CLUSTER_BREAK.SPACINGMARK}else if(2881<=t&&t<=2884)return f.CLUSTER_BREAK.EXTEND}else if(t<2893){if(t<2891){if(2887<=t&&t<=2888)return f.CLUSTER_BREAK.SPACINGMARK}else if(2891<=t&&t<=2892)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2901){if(t===2893)return f.CLUSTER_BREAK.EXTEND}else if(t<2914){if(2901<=t&&t<=2903)return f.CLUSTER_BREAK.EXTEND}else if(2914<=t&&t<=2915)return f.CLUSTER_BREAK.EXTEND}else if(t<3014){if(t<3007){if(t===2946||t===3006)return f.CLUSTER_BREAK.EXTEND}else if(t<3008){if(t===3007)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3009){if(t===3008)return f.CLUSTER_BREAK.EXTEND}else if(3009<=t&&t<=3010)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3031){if(t<3018){if(3014<=t&&t<=3016)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3021){if(3018<=t&&t<=3020)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===3021)return f.CLUSTER_BREAK.EXTEND}else if(t<3072){if(t===3031)return f.CLUSTER_BREAK.EXTEND}else if(t<3073){if(t===3072)return f.CLUSTER_BREAK.EXTEND}else if(3073<=t&&t<=3075)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3262){if(t<3146){if(t<3134){if(t===3076||t===3132)return f.CLUSTER_BREAK.EXTEND}else if(t<3137){if(3134<=t&&t<=3136)return f.CLUSTER_BREAK.EXTEND}else if(t<3142){if(3137<=t&&t<=3140)return f.CLUSTER_BREAK.SPACINGMARK}else if(3142<=t&&t<=3144)return f.CLUSTER_BREAK.EXTEND}else if(t<3201){if(t<3157){if(3146<=t&&t<=3149)return f.CLUSTER_BREAK.EXTEND}else if(t<3170){if(3157<=t&&t<=3158)return f.CLUSTER_BREAK.EXTEND}else if(3170<=t&&t<=3171)return f.CLUSTER_BREAK.EXTEND}else if(t<3202){if(t===3201)return f.CLUSTER_BREAK.EXTEND}else if(t<3260){if(3202<=t&&t<=3203)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===3260)return f.CLUSTER_BREAK.EXTEND}else if(t<3270){if(t<3264){if(t===3262)return f.CLUSTER_BREAK.SPACINGMARK;if(t===3263)return f.CLUSTER_BREAK.EXTEND}else if(t<3266){if(3264<=t&&t<=3265)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3267){if(t===3266)return f.CLUSTER_BREAK.EXTEND}else if(3267<=t&&t<=3268)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3276){if(t<3271){if(t===3270)return f.CLUSTER_BREAK.EXTEND}else if(t<3274){if(3271<=t&&t<=3272)return f.CLUSTER_BREAK.SPACINGMARK}else if(3274<=t&&t<=3275)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3285){if(3276<=t&&t<=3277)return f.CLUSTER_BREAK.EXTEND}else if(t<3298){if(3285<=t&&t<=3286)return f.CLUSTER_BREAK.EXTEND}else if(3298<=t&&t<=3299)return f.CLUSTER_BREAK.EXTEND}else if(t<3551){if(t<3406){if(t<3391){if(t<3330){if(t<3328){if(t===3315)return f.CLUSTER_BREAK.SPACINGMARK}else if(3328<=t&&t<=3329)return f.CLUSTER_BREAK.EXTEND}else if(t<3387){if(3330<=t&&t<=3331)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3390){if(3387<=t&&t<=3388)return f.CLUSTER_BREAK.EXTEND}else if(t===3390)return f.CLUSTER_BREAK.EXTEND}else if(t<3398){if(t<3393){if(3391<=t&&t<=3392)return f.CLUSTER_BREAK.SPACINGMARK}else if(3393<=t&&t<=3396)return f.CLUSTER_BREAK.EXTEND}else if(t<3402){if(3398<=t&&t<=3400)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3405){if(3402<=t&&t<=3404)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===3405)return f.CLUSTER_BREAK.EXTEND}else if(t<3530){if(t<3426){if(t===3406)return f.CLUSTER_BREAK.PREPEND;if(t===3415)return f.CLUSTER_BREAK.EXTEND}else if(t<3457){if(3426<=t&&t<=3427)return f.CLUSTER_BREAK.EXTEND}else if(t<3458){if(t===3457)return f.CLUSTER_BREAK.EXTEND}else if(3458<=t&&t<=3459)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3538){if(t<3535){if(t===3530)return f.CLUSTER_BREAK.EXTEND}else if(t<3536){if(t===3535)return f.CLUSTER_BREAK.EXTEND}else if(3536<=t&&t<=3537)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3542){if(3538<=t&&t<=3540)return f.CLUSTER_BREAK.EXTEND}else if(t<3544){if(t===3542)return f.CLUSTER_BREAK.EXTEND}else if(3544<=t&&t<=3550)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3893){if(t<3655){if(t<3633){if(t<3570){if(t===3551)return f.CLUSTER_BREAK.EXTEND}else if(3570<=t&&t<=3571)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3635){if(t===3633)return f.CLUSTER_BREAK.EXTEND}else if(t<3636){if(t===3635)return f.CLUSTER_BREAK.SPACINGMARK}else if(3636<=t&&t<=3642)return f.CLUSTER_BREAK.EXTEND}else if(t<3764)if(t<3761){if(3655<=t&&t<=3662)return f.CLUSTER_BREAK.EXTEND}else{if(t===3761)return f.CLUSTER_BREAK.EXTEND;if(t===3763)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3784){if(3764<=t&&t<=3772)return f.CLUSTER_BREAK.EXTEND}else if(t<3864){if(3784<=t&&t<=3790)return f.CLUSTER_BREAK.EXTEND}else if(3864<=t&&t<=3865)return f.CLUSTER_BREAK.EXTEND}else if(t<3967){if(t<3897){if(t===3893||t===3895)return f.CLUSTER_BREAK.EXTEND}else if(t<3902){if(t===3897)return f.CLUSTER_BREAK.EXTEND}else if(t<3953){if(3902<=t&&t<=3903)return f.CLUSTER_BREAK.SPACINGMARK}else if(3953<=t&&t<=3966)return f.CLUSTER_BREAK.EXTEND}else if(t<3981){if(t<3968){if(t===3967)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3974){if(3968<=t&&t<=3972)return f.CLUSTER_BREAK.EXTEND}else if(3974<=t&&t<=3975)return f.CLUSTER_BREAK.EXTEND}else if(t<3993){if(3981<=t&&t<=3991)return f.CLUSTER_BREAK.EXTEND}else if(t<4038){if(3993<=t&&t<=4028)return f.CLUSTER_BREAK.EXTEND}else if(t===4038)return f.CLUSTER_BREAK.EXTEND}else if(t<7204){if(t<6448){if(t<5938){if(t<4226){if(t<4157){if(t<4146){if(t<4145){if(4141<=t&&t<=4144)return f.CLUSTER_BREAK.EXTEND}else if(t===4145)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<4153){if(4146<=t&&t<=4151)return f.CLUSTER_BREAK.EXTEND}else if(t<4155){if(4153<=t&&t<=4154)return f.CLUSTER_BREAK.EXTEND}else if(4155<=t&&t<=4156)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<4184){if(t<4182){if(4157<=t&&t<=4158)return f.CLUSTER_BREAK.EXTEND}else if(4182<=t&&t<=4183)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<4190){if(4184<=t&&t<=4185)return f.CLUSTER_BREAK.EXTEND}else if(t<4209){if(4190<=t&&t<=4192)return f.CLUSTER_BREAK.EXTEND}else if(4209<=t&&t<=4212)return f.CLUSTER_BREAK.EXTEND}else if(t<4352){if(t<4229){if(t===4226)return f.CLUSTER_BREAK.EXTEND;if(t===4228)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<4237){if(4229<=t&&t<=4230)return f.CLUSTER_BREAK.EXTEND}else if(t===4237||t===4253)return f.CLUSTER_BREAK.EXTEND}else if(t<4957){if(t<4448){if(4352<=t&&t<=4447)return f.CLUSTER_BREAK.L}else if(t<4520){if(4448<=t&&t<=4519)return f.CLUSTER_BREAK.V}else if(4520<=t&&t<=4607)return f.CLUSTER_BREAK.T}else if(t<5906){if(4957<=t&&t<=4959)return f.CLUSTER_BREAK.EXTEND}else if(t<5909){if(5906<=t&&t<=5908)return f.CLUSTER_BREAK.EXTEND}else if(t===5909)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6089){if(t<6070){if(t<5970){if(t<5940){if(5938<=t&&t<=5939)return f.CLUSTER_BREAK.EXTEND}else if(t===5940)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6002){if(5970<=t&&t<=5971)return f.CLUSTER_BREAK.EXTEND}else if(t<6068){if(6002<=t&&t<=6003)return f.CLUSTER_BREAK.EXTEND}else if(6068<=t&&t<=6069)return f.CLUSTER_BREAK.EXTEND}else if(t<6078){if(t<6071){if(t===6070)return f.CLUSTER_BREAK.SPACINGMARK}else if(6071<=t&&t<=6077)return f.CLUSTER_BREAK.EXTEND}else if(t<6086){if(6078<=t&&t<=6085)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6087){if(t===6086)return f.CLUSTER_BREAK.EXTEND}else if(6087<=t&&t<=6088)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6277)if(t<6155){if(t<6109){if(6089<=t&&t<=6099)return f.CLUSTER_BREAK.EXTEND}else if(t===6109)return f.CLUSTER_BREAK.EXTEND}else if(t<6158){if(6155<=t&&t<=6157)return f.CLUSTER_BREAK.EXTEND}else{if(t===6158)return f.CLUSTER_BREAK.CONTROL;if(t===6159)return f.CLUSTER_BREAK.EXTEND}else if(t<6435){if(t<6313){if(6277<=t&&t<=6278)return f.CLUSTER_BREAK.EXTEND}else if(t<6432){if(t===6313)return f.CLUSTER_BREAK.EXTEND}else if(6432<=t&&t<=6434)return f.CLUSTER_BREAK.EXTEND}else if(t<6439){if(6435<=t&&t<=6438)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6441){if(6439<=t&&t<=6440)return f.CLUSTER_BREAK.EXTEND}else if(6441<=t&&t<=6443)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6971){if(t<6744)if(t<6681){if(t<6451){if(t<6450){if(6448<=t&&t<=6449)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===6450)return f.CLUSTER_BREAK.EXTEND}else if(t<6457){if(6451<=t&&t<=6456)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6679){if(6457<=t&&t<=6459)return f.CLUSTER_BREAK.EXTEND}else if(6679<=t&&t<=6680)return f.CLUSTER_BREAK.EXTEND}else if(t<6741){if(t<6683){if(6681<=t&&t<=6682)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===6683)return f.CLUSTER_BREAK.EXTEND}else if(t<6742){if(t===6741)return f.CLUSTER_BREAK.SPACINGMARK}else{if(t===6742)return f.CLUSTER_BREAK.EXTEND;if(t===6743)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6771){if(t<6754){if(t<6752){if(6744<=t&&t<=6750)return f.CLUSTER_BREAK.EXTEND}else if(t===6752)return f.CLUSTER_BREAK.EXTEND}else if(t<6757){if(t===6754)return f.CLUSTER_BREAK.EXTEND}else if(t<6765){if(6757<=t&&t<=6764)return f.CLUSTER_BREAK.EXTEND}else if(6765<=t&&t<=6770)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6912){if(t<6783){if(6771<=t&&t<=6780)return f.CLUSTER_BREAK.EXTEND}else if(t<6832){if(t===6783)return f.CLUSTER_BREAK.EXTEND}else if(6832<=t&&t<=6862)return f.CLUSTER_BREAK.EXTEND}else if(t<6916){if(6912<=t&&t<=6915)return f.CLUSTER_BREAK.EXTEND}else if(t<6964){if(t===6916)return f.CLUSTER_BREAK.SPACINGMARK}else if(6964<=t&&t<=6970)return f.CLUSTER_BREAK.EXTEND}else if(t<7080){if(t<7019){if(t<6973){if(t===6971)return f.CLUSTER_BREAK.SPACINGMARK;if(t===6972)return f.CLUSTER_BREAK.EXTEND}else if(t<6978){if(6973<=t&&t<=6977)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6979){if(t===6978)return f.CLUSTER_BREAK.EXTEND}else if(6979<=t&&t<=6980)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7073){if(t<7040){if(7019<=t&&t<=7027)return f.CLUSTER_BREAK.EXTEND}else if(t<7042){if(7040<=t&&t<=7041)return f.CLUSTER_BREAK.EXTEND}else if(t===7042)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7074){if(t===7073)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7078){if(7074<=t&&t<=7077)return f.CLUSTER_BREAK.EXTEND}else if(7078<=t&&t<=7079)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7144)if(t<7083){if(t<7082){if(7080<=t&&t<=7081)return f.CLUSTER_BREAK.EXTEND}else if(t===7082)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7142){if(7083<=t&&t<=7085)return f.CLUSTER_BREAK.EXTEND}else{if(t===7142)return f.CLUSTER_BREAK.EXTEND;if(t===7143)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7150){if(t<7146){if(7144<=t&&t<=7145)return f.CLUSTER_BREAK.EXTEND}else if(t<7149){if(7146<=t&&t<=7148)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===7149)return f.CLUSTER_BREAK.EXTEND}else if(t<7151){if(t===7150)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7154){if(7151<=t&&t<=7153)return f.CLUSTER_BREAK.EXTEND}else if(7154<=t&&t<=7155)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43346){if(t<11647){if(t<7415){if(t<7380){if(t<7220){if(t<7212){if(7204<=t&&t<=7211)return f.CLUSTER_BREAK.SPACINGMARK}else if(7212<=t&&t<=7219)return f.CLUSTER_BREAK.EXTEND}else if(t<7222){if(7220<=t&&t<=7221)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7376){if(7222<=t&&t<=7223)return f.CLUSTER_BREAK.EXTEND}else if(7376<=t&&t<=7378)return f.CLUSTER_BREAK.EXTEND}else if(t<7394){if(t<7393){if(7380<=t&&t<=7392)return f.CLUSTER_BREAK.EXTEND}else if(t===7393)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7405){if(7394<=t&&t<=7400)return f.CLUSTER_BREAK.EXTEND}else if(t===7405||t===7412)return f.CLUSTER_BREAK.EXTEND}else if(t<8205)if(t<7616){if(t<7416){if(t===7415)return f.CLUSTER_BREAK.SPACINGMARK}else if(7416<=t&&t<=7417)return f.CLUSTER_BREAK.EXTEND}else if(t<8203){if(7616<=t&&t<=7679)return f.CLUSTER_BREAK.EXTEND}else{if(t===8203)return f.CLUSTER_BREAK.CONTROL;if(t===8204)return f.CLUSTER_BREAK.EXTEND}else if(t<8288){if(t<8206){if(t===8205)return f.CLUSTER_BREAK.ZWJ}else if(t<8232){if(8206<=t&&t<=8207)return f.CLUSTER_BREAK.CONTROL}else if(8232<=t&&t<=8238)return f.CLUSTER_BREAK.CONTROL}else if(t<8400){if(8288<=t&&t<=8303)return f.CLUSTER_BREAK.CONTROL}else if(t<11503){if(8400<=t&&t<=8432)return f.CLUSTER_BREAK.EXTEND}else if(11503<=t&&t<=11505)return f.CLUSTER_BREAK.EXTEND}else if(t<43043){if(t<42612){if(t<12330){if(t<11744){if(t===11647)return f.CLUSTER_BREAK.EXTEND}else if(11744<=t&&t<=11775)return f.CLUSTER_BREAK.EXTEND}else if(t<12441){if(12330<=t&&t<=12335)return f.CLUSTER_BREAK.EXTEND}else if(t<42607){if(12441<=t&&t<=12442)return f.CLUSTER_BREAK.EXTEND}else if(42607<=t&&t<=42610)return f.CLUSTER_BREAK.EXTEND}else if(t<43010){if(t<42654){if(42612<=t&&t<=42621)return f.CLUSTER_BREAK.EXTEND}else if(t<42736){if(42654<=t&&t<=42655)return f.CLUSTER_BREAK.EXTEND}else if(42736<=t&&t<=42737)return f.CLUSTER_BREAK.EXTEND}else if(t<43014){if(t===43010)return f.CLUSTER_BREAK.EXTEND}else if(t===43014||t===43019)return f.CLUSTER_BREAK.EXTEND}else if(t<43188){if(t<43047){if(t<43045){if(43043<=t&&t<=43044)return f.CLUSTER_BREAK.SPACINGMARK}else if(43045<=t&&t<=43046)return f.CLUSTER_BREAK.EXTEND}else if(t<43052){if(t===43047)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43136){if(t===43052)return f.CLUSTER_BREAK.EXTEND}else if(43136<=t&&t<=43137)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43263){if(t<43204){if(43188<=t&&t<=43203)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43232){if(43204<=t&&t<=43205)return f.CLUSTER_BREAK.EXTEND}else if(43232<=t&&t<=43249)return f.CLUSTER_BREAK.EXTEND}else if(t<43302){if(t===43263)return f.CLUSTER_BREAK.EXTEND}else if(t<43335){if(43302<=t&&t<=43309)return f.CLUSTER_BREAK.EXTEND}else if(43335<=t&&t<=43345)return f.CLUSTER_BREAK.EXTEND}else if(t<43698){if(t<43493){if(t<43444)if(t<43392){if(t<43360){if(43346<=t&&t<=43347)return f.CLUSTER_BREAK.SPACINGMARK}else if(43360<=t&&t<=43388)return f.CLUSTER_BREAK.L}else if(t<43395){if(43392<=t&&t<=43394)return f.CLUSTER_BREAK.EXTEND}else{if(t===43395)return f.CLUSTER_BREAK.SPACINGMARK;if(t===43443)return f.CLUSTER_BREAK.EXTEND}else if(t<43450){if(t<43446){if(43444<=t&&t<=43445)return f.CLUSTER_BREAK.SPACINGMARK}else if(43446<=t&&t<=43449)return f.CLUSTER_BREAK.EXTEND}else if(t<43452){if(43450<=t&&t<=43451)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43454){if(43452<=t&&t<=43453)return f.CLUSTER_BREAK.EXTEND}else if(43454<=t&&t<=43456)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43573){if(t<43567){if(t<43561){if(t===43493)return f.CLUSTER_BREAK.EXTEND}else if(43561<=t&&t<=43566)return f.CLUSTER_BREAK.EXTEND}else if(t<43569){if(43567<=t&&t<=43568)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43571){if(43569<=t&&t<=43570)return f.CLUSTER_BREAK.EXTEND}else if(43571<=t&&t<=43572)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43597){if(t<43587){if(43573<=t&&t<=43574)return f.CLUSTER_BREAK.EXTEND}else if(t===43587||t===43596)return f.CLUSTER_BREAK.EXTEND}else if(t<43644){if(t===43597)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===43644||t===43696)return f.CLUSTER_BREAK.EXTEND}else if(t<44006){if(t<43756)if(t<43710){if(t<43703){if(43698<=t&&t<=43700)return f.CLUSTER_BREAK.EXTEND}else if(43703<=t&&t<=43704)return f.CLUSTER_BREAK.EXTEND}else if(t<43713){if(43710<=t&&t<=43711)return f.CLUSTER_BREAK.EXTEND}else{if(t===43713)return f.CLUSTER_BREAK.EXTEND;if(t===43755)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43766){if(t<43758){if(43756<=t&&t<=43757)return f.CLUSTER_BREAK.EXTEND}else if(t<43765){if(43758<=t&&t<=43759)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===43765)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<44003){if(t===43766)return f.CLUSTER_BREAK.EXTEND}else if(t<44005){if(44003<=t&&t<=44004)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===44005)return f.CLUSTER_BREAK.EXTEND}else if(t<44032)if(t<44009){if(t<44008){if(44006<=t&&t<=44007)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===44008)return f.CLUSTER_BREAK.EXTEND}else if(t<44012){if(44009<=t&&t<=44010)return f.CLUSTER_BREAK.SPACINGMARK}else{if(t===44012)return f.CLUSTER_BREAK.SPACINGMARK;if(t===44013)return f.CLUSTER_BREAK.EXTEND}else if(t<44061){if(t<44033){if(t===44032)return f.CLUSTER_BREAK.LV}else if(t<44060){if(44033<=t&&t<=44059)return f.CLUSTER_BREAK.LVT}else if(t===44060)return f.CLUSTER_BREAK.LV}else if(t<44088){if(44061<=t&&t<=44087)return f.CLUSTER_BREAK.LVT}else if(t<44089){if(t===44088)return f.CLUSTER_BREAK.LV}else if(44089<=t&&t<=44115)return f.CLUSTER_BREAK.LVT}else if(t<46497){if(t<45293){if(t<44704){if(t<44397){if(t<44256){if(t<44173){if(t<44144){if(t<44117){if(t===44116)return f.CLUSTER_BREAK.LV}else if(44117<=t&&t<=44143)return f.CLUSTER_BREAK.LVT}else if(t<44145){if(t===44144)return f.CLUSTER_BREAK.LV}else if(t<44172){if(44145<=t&&t<=44171)return f.CLUSTER_BREAK.LVT}else if(t===44172)return f.CLUSTER_BREAK.LV}else if(t<44201){if(t<44200){if(44173<=t&&t<=44199)return f.CLUSTER_BREAK.LVT}else if(t===44200)return f.CLUSTER_BREAK.LV}else if(t<44228){if(44201<=t&&t<=44227)return f.CLUSTER_BREAK.LVT}else if(t<44229){if(t===44228)return f.CLUSTER_BREAK.LV}else if(44229<=t&&t<=44255)return f.CLUSTER_BREAK.LVT}else if(t<44313){if(t<44284){if(t<44257){if(t===44256)return f.CLUSTER_BREAK.LV}else if(44257<=t&&t<=44283)return f.CLUSTER_BREAK.LVT}else if(t<44285){if(t===44284)return f.CLUSTER_BREAK.LV}else if(t<44312){if(44285<=t&&t<=44311)return f.CLUSTER_BREAK.LVT}else if(t===44312)return f.CLUSTER_BREAK.LV}else if(t<44368){if(t<44340){if(44313<=t&&t<=44339)return f.CLUSTER_BREAK.LVT}else if(t<44341){if(t===44340)return f.CLUSTER_BREAK.LV}else if(44341<=t&&t<=44367)return f.CLUSTER_BREAK.LVT}else if(t<44369){if(t===44368)return f.CLUSTER_BREAK.LV}else if(t<44396){if(44369<=t&&t<=44395)return f.CLUSTER_BREAK.LVT}else if(t===44396)return f.CLUSTER_BREAK.LV}else if(t<44537){if(t<44480){if(t<44425){if(t<44424){if(44397<=t&&t<=44423)return f.CLUSTER_BREAK.LVT}else if(t===44424)return f.CLUSTER_BREAK.LV}else if(t<44452){if(44425<=t&&t<=44451)return f.CLUSTER_BREAK.LVT}else if(t<44453){if(t===44452)return f.CLUSTER_BREAK.LV}else if(44453<=t&&t<=44479)return f.CLUSTER_BREAK.LVT}else if(t<44508){if(t<44481){if(t===44480)return f.CLUSTER_BREAK.LV}else if(44481<=t&&t<=44507)return f.CLUSTER_BREAK.LVT}else if(t<44509){if(t===44508)return f.CLUSTER_BREAK.LV}else if(t<44536){if(44509<=t&&t<=44535)return f.CLUSTER_BREAK.LVT}else if(t===44536)return f.CLUSTER_BREAK.LV}else if(t<44620){if(t<44565){if(t<44564){if(44537<=t&&t<=44563)return f.CLUSTER_BREAK.LVT}else if(t===44564)return f.CLUSTER_BREAK.LV}else if(t<44592){if(44565<=t&&t<=44591)return f.CLUSTER_BREAK.LVT}else if(t<44593){if(t===44592)return f.CLUSTER_BREAK.LV}else if(44593<=t&&t<=44619)return f.CLUSTER_BREAK.LVT}else if(t<44649){if(t<44621){if(t===44620)return f.CLUSTER_BREAK.LV}else if(t<44648){if(44621<=t&&t<=44647)return f.CLUSTER_BREAK.LVT}else if(t===44648)return f.CLUSTER_BREAK.LV}else if(t<44676){if(44649<=t&&t<=44675)return f.CLUSTER_BREAK.LVT}else if(t<44677){if(t===44676)return f.CLUSTER_BREAK.LV}else if(44677<=t&&t<=44703)return f.CLUSTER_BREAK.LVT}else if(t<44985){if(t<44844){if(t<44761){if(t<44732){if(t<44705){if(t===44704)return f.CLUSTER_BREAK.LV}else if(44705<=t&&t<=44731)return f.CLUSTER_BREAK.LVT}else if(t<44733){if(t===44732)return f.CLUSTER_BREAK.LV}else if(t<44760){if(44733<=t&&t<=44759)return f.CLUSTER_BREAK.LVT}else if(t===44760)return f.CLUSTER_BREAK.LV}else if(t<44789){if(t<44788){if(44761<=t&&t<=44787)return f.CLUSTER_BREAK.LVT}else if(t===44788)return f.CLUSTER_BREAK.LV}else if(t<44816){if(44789<=t&&t<=44815)return f.CLUSTER_BREAK.LVT}else if(t<44817){if(t===44816)return f.CLUSTER_BREAK.LV}else if(44817<=t&&t<=44843)return f.CLUSTER_BREAK.LVT}else if(t<44901){if(t<44872){if(t<44845){if(t===44844)return f.CLUSTER_BREAK.LV}else if(44845<=t&&t<=44871)return f.CLUSTER_BREAK.LVT}else if(t<44873){if(t===44872)return f.CLUSTER_BREAK.LV}else if(t<44900){if(44873<=t&&t<=44899)return f.CLUSTER_BREAK.LVT}else if(t===44900)return f.CLUSTER_BREAK.LV}else if(t<44956){if(t<44928){if(44901<=t&&t<=44927)return f.CLUSTER_BREAK.LVT}else if(t<44929){if(t===44928)return f.CLUSTER_BREAK.LV}else if(44929<=t&&t<=44955)return f.CLUSTER_BREAK.LVT}else if(t<44957){if(t===44956)return f.CLUSTER_BREAK.LV}else if(t<44984){if(44957<=t&&t<=44983)return f.CLUSTER_BREAK.LVT}else if(t===44984)return f.CLUSTER_BREAK.LV}else if(t<45152){if(t<45068){if(t<45013){if(t<45012){if(44985<=t&&t<=45011)return f.CLUSTER_BREAK.LVT}else if(t===45012)return f.CLUSTER_BREAK.LV}else if(t<45040){if(45013<=t&&t<=45039)return f.CLUSTER_BREAK.LVT}else if(t<45041){if(t===45040)return f.CLUSTER_BREAK.LV}else if(45041<=t&&t<=45067)return f.CLUSTER_BREAK.LVT}else if(t<45097){if(t<45069){if(t===45068)return f.CLUSTER_BREAK.LV}else if(t<45096){if(45069<=t&&t<=45095)return f.CLUSTER_BREAK.LVT}else if(t===45096)return f.CLUSTER_BREAK.LV}else if(t<45124){if(45097<=t&&t<=45123)return f.CLUSTER_BREAK.LVT}else if(t<45125){if(t===45124)return f.CLUSTER_BREAK.LV}else if(45125<=t&&t<=45151)return f.CLUSTER_BREAK.LVT}else if(t<45209){if(t<45180){if(t<45153){if(t===45152)return f.CLUSTER_BREAK.LV}else if(45153<=t&&t<=45179)return f.CLUSTER_BREAK.LVT}else if(t<45181){if(t===45180)return f.CLUSTER_BREAK.LV}else if(t<45208){if(45181<=t&&t<=45207)return f.CLUSTER_BREAK.LVT}else if(t===45208)return f.CLUSTER_BREAK.LV}else if(t<45264){if(t<45236){if(45209<=t&&t<=45235)return f.CLUSTER_BREAK.LVT}else if(t<45237){if(t===45236)return f.CLUSTER_BREAK.LV}else if(45237<=t&&t<=45263)return f.CLUSTER_BREAK.LVT}else if(t<45265){if(t===45264)return f.CLUSTER_BREAK.LV}else if(t<45292){if(45265<=t&&t<=45291)return f.CLUSTER_BREAK.LVT}else if(t===45292)return f.CLUSTER_BREAK.LV}else if(t<45908){if(t<45600){if(t<45433){if(t<45376){if(t<45321){if(t<45320){if(45293<=t&&t<=45319)return f.CLUSTER_BREAK.LVT}else if(t===45320)return f.CLUSTER_BREAK.LV}else if(t<45348){if(45321<=t&&t<=45347)return f.CLUSTER_BREAK.LVT}else if(t<45349){if(t===45348)return f.CLUSTER_BREAK.LV}else if(45349<=t&&t<=45375)return f.CLUSTER_BREAK.LVT}else if(t<45404){if(t<45377){if(t===45376)return f.CLUSTER_BREAK.LV}else if(45377<=t&&t<=45403)return f.CLUSTER_BREAK.LVT}else if(t<45405){if(t===45404)return f.CLUSTER_BREAK.LV}else if(t<45432){if(45405<=t&&t<=45431)return f.CLUSTER_BREAK.LVT}else if(t===45432)return f.CLUSTER_BREAK.LV}else if(t<45516){if(t<45461){if(t<45460){if(45433<=t&&t<=45459)return f.CLUSTER_BREAK.LVT}else if(t===45460)return f.CLUSTER_BREAK.LV}else if(t<45488){if(45461<=t&&t<=45487)return f.CLUSTER_BREAK.LVT}else if(t<45489){if(t===45488)return f.CLUSTER_BREAK.LV}else if(45489<=t&&t<=45515)return f.CLUSTER_BREAK.LVT}else if(t<45545){if(t<45517){if(t===45516)return f.CLUSTER_BREAK.LV}else if(t<45544){if(45517<=t&&t<=45543)return f.CLUSTER_BREAK.LVT}else if(t===45544)return f.CLUSTER_BREAK.LV}else if(t<45572){if(45545<=t&&t<=45571)return f.CLUSTER_BREAK.LVT}else if(t<45573){if(t===45572)return f.CLUSTER_BREAK.LV}else if(45573<=t&&t<=45599)return f.CLUSTER_BREAK.LVT}else if(t<45741){if(t<45657){if(t<45628){if(t<45601){if(t===45600)return f.CLUSTER_BREAK.LV}else if(45601<=t&&t<=45627)return f.CLUSTER_BREAK.LVT}else if(t<45629){if(t===45628)return f.CLUSTER_BREAK.LV}else if(t<45656){if(45629<=t&&t<=45655)return f.CLUSTER_BREAK.LVT}else if(t===45656)return f.CLUSTER_BREAK.LV}else if(t<45712){if(t<45684){if(45657<=t&&t<=45683)return f.CLUSTER_BREAK.LVT}else if(t<45685){if(t===45684)return f.CLUSTER_BREAK.LV}else if(45685<=t&&t<=45711)return f.CLUSTER_BREAK.LVT}else if(t<45713){if(t===45712)return f.CLUSTER_BREAK.LV}else if(t<45740){if(45713<=t&&t<=45739)return f.CLUSTER_BREAK.LVT}else if(t===45740)return f.CLUSTER_BREAK.LV}else if(t<45824){if(t<45769){if(t<45768){if(45741<=t&&t<=45767)return f.CLUSTER_BREAK.LVT}else if(t===45768)return f.CLUSTER_BREAK.LV}else if(t<45796){if(45769<=t&&t<=45795)return f.CLUSTER_BREAK.LVT}else if(t<45797){if(t===45796)return f.CLUSTER_BREAK.LV}else if(45797<=t&&t<=45823)return f.CLUSTER_BREAK.LVT}else if(t<45853){if(t<45825){if(t===45824)return f.CLUSTER_BREAK.LV}else if(t<45852){if(45825<=t&&t<=45851)return f.CLUSTER_BREAK.LVT}else if(t===45852)return f.CLUSTER_BREAK.LV}else if(t<45880){if(45853<=t&&t<=45879)return f.CLUSTER_BREAK.LVT}else if(t<45881){if(t===45880)return f.CLUSTER_BREAK.LV}else if(45881<=t&&t<=45907)return f.CLUSTER_BREAK.LVT}else if(t<46189){if(t<46048){if(t<45965){if(t<45936){if(t<45909){if(t===45908)return f.CLUSTER_BREAK.LV}else if(45909<=t&&t<=45935)return f.CLUSTER_BREAK.LVT}else if(t<45937){if(t===45936)return f.CLUSTER_BREAK.LV}else if(t<45964){if(45937<=t&&t<=45963)return f.CLUSTER_BREAK.LVT}else if(t===45964)return f.CLUSTER_BREAK.LV}else if(t<45993){if(t<45992){if(45965<=t&&t<=45991)return f.CLUSTER_BREAK.LVT}else if(t===45992)return f.CLUSTER_BREAK.LV}else if(t<46020){if(45993<=t&&t<=46019)return f.CLUSTER_BREAK.LVT}else if(t<46021){if(t===46020)return f.CLUSTER_BREAK.LV}else if(46021<=t&&t<=46047)return f.CLUSTER_BREAK.LVT}else if(t<46105){if(t<46076){if(t<46049){if(t===46048)return f.CLUSTER_BREAK.LV}else if(46049<=t&&t<=46075)return f.CLUSTER_BREAK.LVT}else if(t<46077){if(t===46076)return f.CLUSTER_BREAK.LV}else if(t<46104){if(46077<=t&&t<=46103)return f.CLUSTER_BREAK.LVT}else if(t===46104)return f.CLUSTER_BREAK.LV}else if(t<46160){if(t<46132){if(46105<=t&&t<=46131)return f.CLUSTER_BREAK.LVT}else if(t<46133){if(t===46132)return f.CLUSTER_BREAK.LV}else if(46133<=t&&t<=46159)return f.CLUSTER_BREAK.LVT}else if(t<46161){if(t===46160)return f.CLUSTER_BREAK.LV}else if(t<46188){if(46161<=t&&t<=46187)return f.CLUSTER_BREAK.LVT}else if(t===46188)return f.CLUSTER_BREAK.LV}else if(t<46356){if(t<46272){if(t<46217){if(t<46216){if(46189<=t&&t<=46215)return f.CLUSTER_BREAK.LVT}else if(t===46216)return f.CLUSTER_BREAK.LV}else if(t<46244){if(46217<=t&&t<=46243)return f.CLUSTER_BREAK.LVT}else if(t<46245){if(t===46244)return f.CLUSTER_BREAK.LV}else if(46245<=t&&t<=46271)return f.CLUSTER_BREAK.LVT}else if(t<46301){if(t<46273){if(t===46272)return f.CLUSTER_BREAK.LV}else if(t<46300){if(46273<=t&&t<=46299)return f.CLUSTER_BREAK.LVT}else if(t===46300)return f.CLUSTER_BREAK.LV}else if(t<46328){if(46301<=t&&t<=46327)return f.CLUSTER_BREAK.LVT}else if(t<46329){if(t===46328)return f.CLUSTER_BREAK.LV}else if(46329<=t&&t<=46355)return f.CLUSTER_BREAK.LVT}else if(t<46413){if(t<46384){if(t<46357){if(t===46356)return f.CLUSTER_BREAK.LV}else if(46357<=t&&t<=46383)return f.CLUSTER_BREAK.LVT}else if(t<46385){if(t===46384)return f.CLUSTER_BREAK.LV}else if(t<46412){if(46385<=t&&t<=46411)return f.CLUSTER_BREAK.LVT}else if(t===46412)return f.CLUSTER_BREAK.LV}else if(t<46468){if(t<46440){if(46413<=t&&t<=46439)return f.CLUSTER_BREAK.LVT}else if(t<46441){if(t===46440)return f.CLUSTER_BREAK.LV}else if(46441<=t&&t<=46467)return f.CLUSTER_BREAK.LVT}else if(t<46469){if(t===46468)return f.CLUSTER_BREAK.LV}else if(t<46496){if(46469<=t&&t<=46495)return f.CLUSTER_BREAK.LVT}else if(t===46496)return f.CLUSTER_BREAK.LV}else if(t<47701){if(t<47112){if(t<46804){if(t<46637){if(t<46580){if(t<46525){if(t<46524){if(46497<=t&&t<=46523)return f.CLUSTER_BREAK.LVT}else if(t===46524)return f.CLUSTER_BREAK.LV}else if(t<46552){if(46525<=t&&t<=46551)return f.CLUSTER_BREAK.LVT}else if(t<46553){if(t===46552)return f.CLUSTER_BREAK.LV}else if(46553<=t&&t<=46579)return f.CLUSTER_BREAK.LVT}else if(t<46608){if(t<46581){if(t===46580)return f.CLUSTER_BREAK.LV}else if(46581<=t&&t<=46607)return f.CLUSTER_BREAK.LVT}else if(t<46609){if(t===46608)return f.CLUSTER_BREAK.LV}else if(t<46636){if(46609<=t&&t<=46635)return f.CLUSTER_BREAK.LVT}else if(t===46636)return f.CLUSTER_BREAK.LV}else if(t<46720){if(t<46665){if(t<46664){if(46637<=t&&t<=46663)return f.CLUSTER_BREAK.LVT}else if(t===46664)return f.CLUSTER_BREAK.LV}else if(t<46692){if(46665<=t&&t<=46691)return f.CLUSTER_BREAK.LVT}else if(t<46693){if(t===46692)return f.CLUSTER_BREAK.LV}else if(46693<=t&&t<=46719)return f.CLUSTER_BREAK.LVT}else if(t<46749){if(t<46721){if(t===46720)return f.CLUSTER_BREAK.LV}else if(t<46748){if(46721<=t&&t<=46747)return f.CLUSTER_BREAK.LVT}else if(t===46748)return f.CLUSTER_BREAK.LV}else if(t<46776){if(46749<=t&&t<=46775)return f.CLUSTER_BREAK.LVT}else if(t<46777){if(t===46776)return f.CLUSTER_BREAK.LV}else if(46777<=t&&t<=46803)return f.CLUSTER_BREAK.LVT}else if(t<46945){if(t<46861){if(t<46832){if(t<46805){if(t===46804)return f.CLUSTER_BREAK.LV}else if(46805<=t&&t<=46831)return f.CLUSTER_BREAK.LVT}else if(t<46833){if(t===46832)return f.CLUSTER_BREAK.LV}else if(t<46860){if(46833<=t&&t<=46859)return f.CLUSTER_BREAK.LVT}else if(t===46860)return f.CLUSTER_BREAK.LV}else if(t<46916){if(t<46888){if(46861<=t&&t<=46887)return f.CLUSTER_BREAK.LVT}else if(t<46889){if(t===46888)return f.CLUSTER_BREAK.LV}else if(46889<=t&&t<=46915)return f.CLUSTER_BREAK.LVT}else if(t<46917){if(t===46916)return f.CLUSTER_BREAK.LV}else if(t<46944){if(46917<=t&&t<=46943)return f.CLUSTER_BREAK.LVT}else if(t===46944)return f.CLUSTER_BREAK.LV}else if(t<47028){if(t<46973){if(t<46972){if(46945<=t&&t<=46971)return f.CLUSTER_BREAK.LVT}else if(t===46972)return f.CLUSTER_BREAK.LV}else if(t<47e3){if(46973<=t&&t<=46999)return f.CLUSTER_BREAK.LVT}else if(t<47001){if(t===47e3)return f.CLUSTER_BREAK.LV}else if(47001<=t&&t<=47027)return f.CLUSTER_BREAK.LVT}else if(t<47057){if(t<47029){if(t===47028)return f.CLUSTER_BREAK.LV}else if(t<47056){if(47029<=t&&t<=47055)return f.CLUSTER_BREAK.LVT}else if(t===47056)return f.CLUSTER_BREAK.LV}else if(t<47084){if(47057<=t&&t<=47083)return f.CLUSTER_BREAK.LVT}else if(t<47085){if(t===47084)return f.CLUSTER_BREAK.LV}else if(47085<=t&&t<=47111)return f.CLUSTER_BREAK.LVT}else if(t<47393){if(t<47252){if(t<47169){if(t<47140){if(t<47113){if(t===47112)return f.CLUSTER_BREAK.LV}else if(47113<=t&&t<=47139)return f.CLUSTER_BREAK.LVT}else if(t<47141){if(t===47140)return f.CLUSTER_BREAK.LV}else if(t<47168){if(47141<=t&&t<=47167)return f.CLUSTER_BREAK.LVT}else if(t===47168)return f.CLUSTER_BREAK.LV}else if(t<47197){if(t<47196){if(47169<=t&&t<=47195)return f.CLUSTER_BREAK.LVT}else if(t===47196)return f.CLUSTER_BREAK.LV}else if(t<47224){if(47197<=t&&t<=47223)return f.CLUSTER_BREAK.LVT}else if(t<47225){if(t===47224)return f.CLUSTER_BREAK.LV}else if(47225<=t&&t<=47251)return f.CLUSTER_BREAK.LVT}else if(t<47309){if(t<47280){if(t<47253){if(t===47252)return f.CLUSTER_BREAK.LV}else if(47253<=t&&t<=47279)return f.CLUSTER_BREAK.LVT}else if(t<47281){if(t===47280)return f.CLUSTER_BREAK.LV}else if(t<47308){if(47281<=t&&t<=47307)return f.CLUSTER_BREAK.LVT}else if(t===47308)return f.CLUSTER_BREAK.LV}else if(t<47364){if(t<47336){if(47309<=t&&t<=47335)return f.CLUSTER_BREAK.LVT}else if(t<47337){if(t===47336)return f.CLUSTER_BREAK.LV}else if(47337<=t&&t<=47363)return f.CLUSTER_BREAK.LVT}else if(t<47365){if(t===47364)return f.CLUSTER_BREAK.LV}else if(t<47392){if(47365<=t&&t<=47391)return f.CLUSTER_BREAK.LVT}else if(t===47392)return f.CLUSTER_BREAK.LV}else if(t<47560){if(t<47476){if(t<47421){if(t<47420){if(47393<=t&&t<=47419)return f.CLUSTER_BREAK.LVT}else if(t===47420)return f.CLUSTER_BREAK.LV}else if(t<47448){if(47421<=t&&t<=47447)return f.CLUSTER_BREAK.LVT}else if(t<47449){if(t===47448)return f.CLUSTER_BREAK.LV}else if(47449<=t&&t<=47475)return f.CLUSTER_BREAK.LVT}else if(t<47505){if(t<47477){if(t===47476)return f.CLUSTER_BREAK.LV}else if(t<47504){if(47477<=t&&t<=47503)return f.CLUSTER_BREAK.LVT}else if(t===47504)return f.CLUSTER_BREAK.LV}else if(t<47532){if(47505<=t&&t<=47531)return f.CLUSTER_BREAK.LVT}else if(t<47533){if(t===47532)return f.CLUSTER_BREAK.LV}else if(47533<=t&&t<=47559)return f.CLUSTER_BREAK.LVT}else if(t<47617){if(t<47588){if(t<47561){if(t===47560)return f.CLUSTER_BREAK.LV}else if(47561<=t&&t<=47587)return f.CLUSTER_BREAK.LVT}else if(t<47589){if(t===47588)return f.CLUSTER_BREAK.LV}else if(t<47616){if(47589<=t&&t<=47615)return f.CLUSTER_BREAK.LVT}else if(t===47616)return f.CLUSTER_BREAK.LV}else if(t<47672){if(t<47644){if(47617<=t&&t<=47643)return f.CLUSTER_BREAK.LVT}else if(t<47645){if(t===47644)return f.CLUSTER_BREAK.LV}else if(47645<=t&&t<=47671)return f.CLUSTER_BREAK.LVT}else if(t<47673){if(t===47672)return f.CLUSTER_BREAK.LV}else if(t<47700){if(47673<=t&&t<=47699)return f.CLUSTER_BREAK.LVT}else if(t===47700)return f.CLUSTER_BREAK.LV}else if(t<48316){if(t<48008){if(t<47841){if(t<47784){if(t<47729){if(t<47728){if(47701<=t&&t<=47727)return f.CLUSTER_BREAK.LVT}else if(t===47728)return f.CLUSTER_BREAK.LV}else if(t<47756){if(47729<=t&&t<=47755)return f.CLUSTER_BREAK.LVT}else if(t<47757){if(t===47756)return f.CLUSTER_BREAK.LV}else if(47757<=t&&t<=47783)return f.CLUSTER_BREAK.LVT}else if(t<47812){if(t<47785){if(t===47784)return f.CLUSTER_BREAK.LV}else if(47785<=t&&t<=47811)return f.CLUSTER_BREAK.LVT}else if(t<47813){if(t===47812)return f.CLUSTER_BREAK.LV}else if(t<47840){if(47813<=t&&t<=47839)return f.CLUSTER_BREAK.LVT}else if(t===47840)return f.CLUSTER_BREAK.LV}else if(t<47924){if(t<47869){if(t<47868){if(47841<=t&&t<=47867)return f.CLUSTER_BREAK.LVT}else if(t===47868)return f.CLUSTER_BREAK.LV}else if(t<47896){if(47869<=t&&t<=47895)return f.CLUSTER_BREAK.LVT}else if(t<47897){if(t===47896)return f.CLUSTER_BREAK.LV}else if(47897<=t&&t<=47923)return f.CLUSTER_BREAK.LVT}else if(t<47953){if(t<47925){if(t===47924)return f.CLUSTER_BREAK.LV}else if(t<47952){if(47925<=t&&t<=47951)return f.CLUSTER_BREAK.LVT}else if(t===47952)return f.CLUSTER_BREAK.LV}else if(t<47980){if(47953<=t&&t<=47979)return f.CLUSTER_BREAK.LVT}else if(t<47981){if(t===47980)return f.CLUSTER_BREAK.LV}else if(47981<=t&&t<=48007)return f.CLUSTER_BREAK.LVT}else if(t<48149){if(t<48065){if(t<48036){if(t<48009){if(t===48008)return f.CLUSTER_BREAK.LV}else if(48009<=t&&t<=48035)return f.CLUSTER_BREAK.LVT}else if(t<48037){if(t===48036)return f.CLUSTER_BREAK.LV}else if(t<48064){if(48037<=t&&t<=48063)return f.CLUSTER_BREAK.LVT}else if(t===48064)return f.CLUSTER_BREAK.LV}else if(t<48120){if(t<48092){if(48065<=t&&t<=48091)return f.CLUSTER_BREAK.LVT}else if(t<48093){if(t===48092)return f.CLUSTER_BREAK.LV}else if(48093<=t&&t<=48119)return f.CLUSTER_BREAK.LVT}else if(t<48121){if(t===48120)return f.CLUSTER_BREAK.LV}else if(t<48148){if(48121<=t&&t<=48147)return f.CLUSTER_BREAK.LVT}else if(t===48148)return f.CLUSTER_BREAK.LV}else if(t<48232){if(t<48177){if(t<48176){if(48149<=t&&t<=48175)return f.CLUSTER_BREAK.LVT}else if(t===48176)return f.CLUSTER_BREAK.LV}else if(t<48204){if(48177<=t&&t<=48203)return f.CLUSTER_BREAK.LVT}else if(t<48205){if(t===48204)return f.CLUSTER_BREAK.LV}else if(48205<=t&&t<=48231)return f.CLUSTER_BREAK.LVT}else if(t<48261){if(t<48233){if(t===48232)return f.CLUSTER_BREAK.LV}else if(t<48260){if(48233<=t&&t<=48259)return f.CLUSTER_BREAK.LVT}else if(t===48260)return f.CLUSTER_BREAK.LV}else if(t<48288){if(48261<=t&&t<=48287)return f.CLUSTER_BREAK.LVT}else if(t<48289){if(t===48288)return f.CLUSTER_BREAK.LV}else if(48289<=t&&t<=48315)return f.CLUSTER_BREAK.LVT}else if(t<48597){if(t<48456){if(t<48373){if(t<48344){if(t<48317){if(t===48316)return f.CLUSTER_BREAK.LV}else if(48317<=t&&t<=48343)return f.CLUSTER_BREAK.LVT}else if(t<48345){if(t===48344)return f.CLUSTER_BREAK.LV}else if(t<48372){if(48345<=t&&t<=48371)return f.CLUSTER_BREAK.LVT}else if(t===48372)return f.CLUSTER_BREAK.LV}else if(t<48401){if(t<48400){if(48373<=t&&t<=48399)return f.CLUSTER_BREAK.LVT}else if(t===48400)return f.CLUSTER_BREAK.LV}else if(t<48428){if(48401<=t&&t<=48427)return f.CLUSTER_BREAK.LVT}else if(t<48429){if(t===48428)return f.CLUSTER_BREAK.LV}else if(48429<=t&&t<=48455)return f.CLUSTER_BREAK.LVT}else if(t<48513){if(t<48484){if(t<48457){if(t===48456)return f.CLUSTER_BREAK.LV}else if(48457<=t&&t<=48483)return f.CLUSTER_BREAK.LVT}else if(t<48485){if(t===48484)return f.CLUSTER_BREAK.LV}else if(t<48512){if(48485<=t&&t<=48511)return f.CLUSTER_BREAK.LVT}else if(t===48512)return f.CLUSTER_BREAK.LV}else if(t<48568){if(t<48540){if(48513<=t&&t<=48539)return f.CLUSTER_BREAK.LVT}else if(t<48541){if(t===48540)return f.CLUSTER_BREAK.LV}else if(48541<=t&&t<=48567)return f.CLUSTER_BREAK.LVT}else if(t<48569){if(t===48568)return f.CLUSTER_BREAK.LV}else if(t<48596){if(48569<=t&&t<=48595)return f.CLUSTER_BREAK.LVT}else if(t===48596)return f.CLUSTER_BREAK.LV}else if(t<48764){if(t<48680){if(t<48625){if(t<48624){if(48597<=t&&t<=48623)return f.CLUSTER_BREAK.LVT}else if(t===48624)return f.CLUSTER_BREAK.LV}else if(t<48652){if(48625<=t&&t<=48651)return f.CLUSTER_BREAK.LVT}else if(t<48653){if(t===48652)return f.CLUSTER_BREAK.LV}else if(48653<=t&&t<=48679)return f.CLUSTER_BREAK.LVT}else if(t<48709){if(t<48681){if(t===48680)return f.CLUSTER_BREAK.LV}else if(t<48708){if(48681<=t&&t<=48707)return f.CLUSTER_BREAK.LVT}else if(t===48708)return f.CLUSTER_BREAK.LV}else if(t<48736){if(48709<=t&&t<=48735)return f.CLUSTER_BREAK.LVT}else if(t<48737){if(t===48736)return f.CLUSTER_BREAK.LV}else if(48737<=t&&t<=48763)return f.CLUSTER_BREAK.LVT}else if(t<48821){if(t<48792){if(t<48765){if(t===48764)return f.CLUSTER_BREAK.LV}else if(48765<=t&&t<=48791)return f.CLUSTER_BREAK.LVT}else if(t<48793){if(t===48792)return f.CLUSTER_BREAK.LV}else if(t<48820){if(48793<=t&&t<=48819)return f.CLUSTER_BREAK.LVT}else if(t===48820)return f.CLUSTER_BREAK.LV}else if(t<48876){if(t<48848){if(48821<=t&&t<=48847)return f.CLUSTER_BREAK.LVT}else if(t<48849){if(t===48848)return f.CLUSTER_BREAK.LV}else if(48849<=t&&t<=48875)return f.CLUSTER_BREAK.LVT}else if(t<48877){if(t===48876)return f.CLUSTER_BREAK.LV}else if(t<48904){if(48877<=t&&t<=48903)return f.CLUSTER_BREAK.LVT}else if(t===48904)return f.CLUSTER_BREAK.LV}else if(t<53720){if(t<51312){if(t<50108){if(t<49493){if(t<49212){if(t<49045){if(t<48988){if(t<48933){if(t<48932){if(48905<=t&&t<=48931)return f.CLUSTER_BREAK.LVT}else if(t===48932)return f.CLUSTER_BREAK.LV}else if(t<48960){if(48933<=t&&t<=48959)return f.CLUSTER_BREAK.LVT}else if(t<48961){if(t===48960)return f.CLUSTER_BREAK.LV}else if(48961<=t&&t<=48987)return f.CLUSTER_BREAK.LVT}else if(t<49016){if(t<48989){if(t===48988)return f.CLUSTER_BREAK.LV}else if(48989<=t&&t<=49015)return f.CLUSTER_BREAK.LVT}else if(t<49017){if(t===49016)return f.CLUSTER_BREAK.LV}else if(t<49044){if(49017<=t&&t<=49043)return f.CLUSTER_BREAK.LVT}else if(t===49044)return f.CLUSTER_BREAK.LV}else if(t<49128){if(t<49073){if(t<49072){if(49045<=t&&t<=49071)return f.CLUSTER_BREAK.LVT}else if(t===49072)return f.CLUSTER_BREAK.LV}else if(t<49100){if(49073<=t&&t<=49099)return f.CLUSTER_BREAK.LVT}else if(t<49101){if(t===49100)return f.CLUSTER_BREAK.LV}else if(49101<=t&&t<=49127)return f.CLUSTER_BREAK.LVT}else if(t<49157){if(t<49129){if(t===49128)return f.CLUSTER_BREAK.LV}else if(t<49156){if(49129<=t&&t<=49155)return f.CLUSTER_BREAK.LVT}else if(t===49156)return f.CLUSTER_BREAK.LV}else if(t<49184){if(49157<=t&&t<=49183)return f.CLUSTER_BREAK.LVT}else if(t<49185){if(t===49184)return f.CLUSTER_BREAK.LV}else if(49185<=t&&t<=49211)return f.CLUSTER_BREAK.LVT}else if(t<49352){if(t<49269){if(t<49240){if(t<49213){if(t===49212)return f.CLUSTER_BREAK.LV}else if(49213<=t&&t<=49239)return f.CLUSTER_BREAK.LVT}else if(t<49241){if(t===49240)return f.CLUSTER_BREAK.LV}else if(t<49268){if(49241<=t&&t<=49267)return f.CLUSTER_BREAK.LVT}else if(t===49268)return f.CLUSTER_BREAK.LV}else if(t<49297){if(t<49296){if(49269<=t&&t<=49295)return f.CLUSTER_BREAK.LVT}else if(t===49296)return f.CLUSTER_BREAK.LV}else if(t<49324){if(49297<=t&&t<=49323)return f.CLUSTER_BREAK.LVT}else if(t<49325){if(t===49324)return f.CLUSTER_BREAK.LV}else if(49325<=t&&t<=49351)return f.CLUSTER_BREAK.LVT}else if(t<49409){if(t<49380){if(t<49353){if(t===49352)return f.CLUSTER_BREAK.LV}else if(49353<=t&&t<=49379)return f.CLUSTER_BREAK.LVT}else if(t<49381){if(t===49380)return f.CLUSTER_BREAK.LV}else if(t<49408){if(49381<=t&&t<=49407)return f.CLUSTER_BREAK.LVT}else if(t===49408)return f.CLUSTER_BREAK.LV}else if(t<49464){if(t<49436){if(49409<=t&&t<=49435)return f.CLUSTER_BREAK.LVT}else if(t<49437){if(t===49436)return f.CLUSTER_BREAK.LV}else if(49437<=t&&t<=49463)return f.CLUSTER_BREAK.LVT}else if(t<49465){if(t===49464)return f.CLUSTER_BREAK.LV}else if(t<49492){if(49465<=t&&t<=49491)return f.CLUSTER_BREAK.LVT}else if(t===49492)return f.CLUSTER_BREAK.LV}else if(t<49800){if(t<49633){if(t<49576){if(t<49521){if(t<49520){if(49493<=t&&t<=49519)return f.CLUSTER_BREAK.LVT}else if(t===49520)return f.CLUSTER_BREAK.LV}else if(t<49548){if(49521<=t&&t<=49547)return f.CLUSTER_BREAK.LVT}else if(t<49549){if(t===49548)return f.CLUSTER_BREAK.LV}else if(49549<=t&&t<=49575)return f.CLUSTER_BREAK.LVT}else if(t<49604){if(t<49577){if(t===49576)return f.CLUSTER_BREAK.LV}else if(49577<=t&&t<=49603)return f.CLUSTER_BREAK.LVT}else if(t<49605){if(t===49604)return f.CLUSTER_BREAK.LV}else if(t<49632){if(49605<=t&&t<=49631)return f.CLUSTER_BREAK.LVT}else if(t===49632)return f.CLUSTER_BREAK.LV}else if(t<49716){if(t<49661){if(t<49660){if(49633<=t&&t<=49659)return f.CLUSTER_BREAK.LVT}else if(t===49660)return f.CLUSTER_BREAK.LV}else if(t<49688){if(49661<=t&&t<=49687)return f.CLUSTER_BREAK.LVT}else if(t<49689){if(t===49688)return f.CLUSTER_BREAK.LV}else if(49689<=t&&t<=49715)return f.CLUSTER_BREAK.LVT}else if(t<49745){if(t<49717){if(t===49716)return f.CLUSTER_BREAK.LV}else if(t<49744){if(49717<=t&&t<=49743)return f.CLUSTER_BREAK.LVT}else if(t===49744)return f.CLUSTER_BREAK.LV}else if(t<49772){if(49745<=t&&t<=49771)return f.CLUSTER_BREAK.LVT}else if(t<49773){if(t===49772)return f.CLUSTER_BREAK.LV}else if(49773<=t&&t<=49799)return f.CLUSTER_BREAK.LVT}else if(t<49941){if(t<49857){if(t<49828){if(t<49801){if(t===49800)return f.CLUSTER_BREAK.LV}else if(49801<=t&&t<=49827)return f.CLUSTER_BREAK.LVT}else if(t<49829){if(t===49828)return f.CLUSTER_BREAK.LV}else if(t<49856){if(49829<=t&&t<=49855)return f.CLUSTER_BREAK.LVT}else if(t===49856)return f.CLUSTER_BREAK.LV}else if(t<49912){if(t<49884){if(49857<=t&&t<=49883)return f.CLUSTER_BREAK.LVT}else if(t<49885){if(t===49884)return f.CLUSTER_BREAK.LV}else if(49885<=t&&t<=49911)return f.CLUSTER_BREAK.LVT}else if(t<49913){if(t===49912)return f.CLUSTER_BREAK.LV}else if(t<49940){if(49913<=t&&t<=49939)return f.CLUSTER_BREAK.LVT}else if(t===49940)return f.CLUSTER_BREAK.LV}else if(t<50024){if(t<49969){if(t<49968){if(49941<=t&&t<=49967)return f.CLUSTER_BREAK.LVT}else if(t===49968)return f.CLUSTER_BREAK.LV}else if(t<49996){if(49969<=t&&t<=49995)return f.CLUSTER_BREAK.LVT}else if(t<49997){if(t===49996)return f.CLUSTER_BREAK.LV}else if(49997<=t&&t<=50023)return f.CLUSTER_BREAK.LVT}else if(t<50053){if(t<50025){if(t===50024)return f.CLUSTER_BREAK.LV}else if(t<50052){if(50025<=t&&t<=50051)return f.CLUSTER_BREAK.LVT}else if(t===50052)return f.CLUSTER_BREAK.LV}else if(t<50080){if(50053<=t&&t<=50079)return f.CLUSTER_BREAK.LVT}else if(t<50081){if(t===50080)return f.CLUSTER_BREAK.LV}else if(50081<=t&&t<=50107)return f.CLUSTER_BREAK.LVT}else if(t<50697){if(t<50389){if(t<50248){if(t<50165){if(t<50136){if(t<50109){if(t===50108)return f.CLUSTER_BREAK.LV}else if(50109<=t&&t<=50135)return f.CLUSTER_BREAK.LVT}else if(t<50137){if(t===50136)return f.CLUSTER_BREAK.LV}else if(t<50164){if(50137<=t&&t<=50163)return f.CLUSTER_BREAK.LVT}else if(t===50164)return f.CLUSTER_BREAK.LV}else if(t<50193){if(t<50192){if(50165<=t&&t<=50191)return f.CLUSTER_BREAK.LVT}else if(t===50192)return f.CLUSTER_BREAK.LV}else if(t<50220){if(50193<=t&&t<=50219)return f.CLUSTER_BREAK.LVT}else if(t<50221){if(t===50220)return f.CLUSTER_BREAK.LV}else if(50221<=t&&t<=50247)return f.CLUSTER_BREAK.LVT}else if(t<50305){if(t<50276){if(t<50249){if(t===50248)return f.CLUSTER_BREAK.LV}else if(50249<=t&&t<=50275)return f.CLUSTER_BREAK.LVT}else if(t<50277){if(t===50276)return f.CLUSTER_BREAK.LV}else if(t<50304){if(50277<=t&&t<=50303)return f.CLUSTER_BREAK.LVT}else if(t===50304)return f.CLUSTER_BREAK.LV}else if(t<50360){if(t<50332){if(50305<=t&&t<=50331)return f.CLUSTER_BREAK.LVT}else if(t<50333){if(t===50332)return f.CLUSTER_BREAK.LV}else if(50333<=t&&t<=50359)return f.CLUSTER_BREAK.LVT}else if(t<50361){if(t===50360)return f.CLUSTER_BREAK.LV}else if(t<50388){if(50361<=t&&t<=50387)return f.CLUSTER_BREAK.LVT}else if(t===50388)return f.CLUSTER_BREAK.LV}else if(t<50556){if(t<50472){if(t<50417){if(t<50416){if(50389<=t&&t<=50415)return f.CLUSTER_BREAK.LVT}else if(t===50416)return f.CLUSTER_BREAK.LV}else if(t<50444){if(50417<=t&&t<=50443)return f.CLUSTER_BREAK.LVT}else if(t<50445){if(t===50444)return f.CLUSTER_BREAK.LV}else if(50445<=t&&t<=50471)return f.CLUSTER_BREAK.LVT}else if(t<50501){if(t<50473){if(t===50472)return f.CLUSTER_BREAK.LV}else if(t<50500){if(50473<=t&&t<=50499)return f.CLUSTER_BREAK.LVT}else if(t===50500)return f.CLUSTER_BREAK.LV}else if(t<50528){if(50501<=t&&t<=50527)return f.CLUSTER_BREAK.LVT}else if(t<50529){if(t===50528)return f.CLUSTER_BREAK.LV}else if(50529<=t&&t<=50555)return f.CLUSTER_BREAK.LVT}else if(t<50613){if(t<50584){if(t<50557){if(t===50556)return f.CLUSTER_BREAK.LV}else if(50557<=t&&t<=50583)return f.CLUSTER_BREAK.LVT}else if(t<50585){if(t===50584)return f.CLUSTER_BREAK.LV}else if(t<50612){if(50585<=t&&t<=50611)return f.CLUSTER_BREAK.LVT}else if(t===50612)return f.CLUSTER_BREAK.LV}else if(t<50668){if(t<50640){if(50613<=t&&t<=50639)return f.CLUSTER_BREAK.LVT}else if(t<50641){if(t===50640)return f.CLUSTER_BREAK.LV}else if(50641<=t&&t<=50667)return f.CLUSTER_BREAK.LVT}else if(t<50669){if(t===50668)return f.CLUSTER_BREAK.LV}else if(t<50696){if(50669<=t&&t<=50695)return f.CLUSTER_BREAK.LVT}else if(t===50696)return f.CLUSTER_BREAK.LV}else if(t<51004){if(t<50837){if(t<50780){if(t<50725){if(t<50724){if(50697<=t&&t<=50723)return f.CLUSTER_BREAK.LVT}else if(t===50724)return f.CLUSTER_BREAK.LV}else if(t<50752){if(50725<=t&&t<=50751)return f.CLUSTER_BREAK.LVT}else if(t<50753){if(t===50752)return f.CLUSTER_BREAK.LV}else if(50753<=t&&t<=50779)return f.CLUSTER_BREAK.LVT}else if(t<50808){if(t<50781){if(t===50780)return f.CLUSTER_BREAK.LV}else if(50781<=t&&t<=50807)return f.CLUSTER_BREAK.LVT}else if(t<50809){if(t===50808)return f.CLUSTER_BREAK.LV}else if(t<50836){if(50809<=t&&t<=50835)return f.CLUSTER_BREAK.LVT}else if(t===50836)return f.CLUSTER_BREAK.LV}else if(t<50920){if(t<50865){if(t<50864){if(50837<=t&&t<=50863)return f.CLUSTER_BREAK.LVT}else if(t===50864)return f.CLUSTER_BREAK.LV}else if(t<50892){if(50865<=t&&t<=50891)return f.CLUSTER_BREAK.LVT}else if(t<50893){if(t===50892)return f.CLUSTER_BREAK.LV}else if(50893<=t&&t<=50919)return f.CLUSTER_BREAK.LVT}else if(t<50949){if(t<50921){if(t===50920)return f.CLUSTER_BREAK.LV}else if(t<50948){if(50921<=t&&t<=50947)return f.CLUSTER_BREAK.LVT}else if(t===50948)return f.CLUSTER_BREAK.LV}else if(t<50976){if(50949<=t&&t<=50975)return f.CLUSTER_BREAK.LVT}else if(t<50977){if(t===50976)return f.CLUSTER_BREAK.LV}else if(50977<=t&&t<=51003)return f.CLUSTER_BREAK.LVT}else if(t<51145){if(t<51061){if(t<51032){if(t<51005){if(t===51004)return f.CLUSTER_BREAK.LV}else if(51005<=t&&t<=51031)return f.CLUSTER_BREAK.LVT}else if(t<51033){if(t===51032)return f.CLUSTER_BREAK.LV}else if(t<51060){if(51033<=t&&t<=51059)return f.CLUSTER_BREAK.LVT}else if(t===51060)return f.CLUSTER_BREAK.LV}else if(t<51116){if(t<51088){if(51061<=t&&t<=51087)return f.CLUSTER_BREAK.LVT}else if(t<51089){if(t===51088)return f.CLUSTER_BREAK.LV}else if(51089<=t&&t<=51115)return f.CLUSTER_BREAK.LVT}else if(t<51117){if(t===51116)return f.CLUSTER_BREAK.LV}else if(t<51144){if(51117<=t&&t<=51143)return f.CLUSTER_BREAK.LVT}else if(t===51144)return f.CLUSTER_BREAK.LV}else if(t<51228){if(t<51173){if(t<51172){if(51145<=t&&t<=51171)return f.CLUSTER_BREAK.LVT}else if(t===51172)return f.CLUSTER_BREAK.LV}else if(t<51200){if(51173<=t&&t<=51199)return f.CLUSTER_BREAK.LVT}else if(t<51201){if(t===51200)return f.CLUSTER_BREAK.LV}else if(51201<=t&&t<=51227)return f.CLUSTER_BREAK.LVT}else if(t<51257){if(t<51229){if(t===51228)return f.CLUSTER_BREAK.LV}else if(t<51256){if(51229<=t&&t<=51255)return f.CLUSTER_BREAK.LVT}else if(t===51256)return f.CLUSTER_BREAK.LV}else if(t<51284){if(51257<=t&&t<=51283)return f.CLUSTER_BREAK.LVT}else if(t<51285){if(t===51284)return f.CLUSTER_BREAK.LV}else if(51285<=t&&t<=51311)return f.CLUSTER_BREAK.LVT}else if(t<52516){if(t<51901){if(t<51593){if(t<51452){if(t<51369){if(t<51340){if(t<51313){if(t===51312)return f.CLUSTER_BREAK.LV}else if(51313<=t&&t<=51339)return f.CLUSTER_BREAK.LVT}else if(t<51341){if(t===51340)return f.CLUSTER_BREAK.LV}else if(t<51368){if(51341<=t&&t<=51367)return f.CLUSTER_BREAK.LVT}else if(t===51368)return f.CLUSTER_BREAK.LV}else if(t<51397){if(t<51396){if(51369<=t&&t<=51395)return f.CLUSTER_BREAK.LVT}else if(t===51396)return f.CLUSTER_BREAK.LV}else if(t<51424){if(51397<=t&&t<=51423)return f.CLUSTER_BREAK.LVT}else if(t<51425){if(t===51424)return f.CLUSTER_BREAK.LV}else if(51425<=t&&t<=51451)return f.CLUSTER_BREAK.LVT}else if(t<51509){if(t<51480){if(t<51453){if(t===51452)return f.CLUSTER_BREAK.LV}else if(51453<=t&&t<=51479)return f.CLUSTER_BREAK.LVT}else if(t<51481){if(t===51480)return f.CLUSTER_BREAK.LV}else if(t<51508){if(51481<=t&&t<=51507)return f.CLUSTER_BREAK.LVT}else if(t===51508)return f.CLUSTER_BREAK.LV}else if(t<51564){if(t<51536){if(51509<=t&&t<=51535)return f.CLUSTER_BREAK.LVT}else if(t<51537){if(t===51536)return f.CLUSTER_BREAK.LV}else if(51537<=t&&t<=51563)return f.CLUSTER_BREAK.LVT}else if(t<51565){if(t===51564)return f.CLUSTER_BREAK.LV}else if(t<51592){if(51565<=t&&t<=51591)return f.CLUSTER_BREAK.LVT}else if(t===51592)return f.CLUSTER_BREAK.LV}else if(t<51760){if(t<51676){if(t<51621){if(t<51620){if(51593<=t&&t<=51619)return f.CLUSTER_BREAK.LVT}else if(t===51620)return f.CLUSTER_BREAK.LV}else if(t<51648){if(51621<=t&&t<=51647)return f.CLUSTER_BREAK.LVT}else if(t<51649){if(t===51648)return f.CLUSTER_BREAK.LV}else if(51649<=t&&t<=51675)return f.CLUSTER_BREAK.LVT}else if(t<51705){if(t<51677){if(t===51676)return f.CLUSTER_BREAK.LV}else if(t<51704){if(51677<=t&&t<=51703)return f.CLUSTER_BREAK.LVT}else if(t===51704)return f.CLUSTER_BREAK.LV}else if(t<51732){if(51705<=t&&t<=51731)return f.CLUSTER_BREAK.LVT}else if(t<51733){if(t===51732)return f.CLUSTER_BREAK.LV}else if(51733<=t&&t<=51759)return f.CLUSTER_BREAK.LVT}else if(t<51817){if(t<51788){if(t<51761){if(t===51760)return f.CLUSTER_BREAK.LV}else if(51761<=t&&t<=51787)return f.CLUSTER_BREAK.LVT}else if(t<51789){if(t===51788)return f.CLUSTER_BREAK.LV}else if(t<51816){if(51789<=t&&t<=51815)return f.CLUSTER_BREAK.LVT}else if(t===51816)return f.CLUSTER_BREAK.LV}else if(t<51872){if(t<51844){if(51817<=t&&t<=51843)return f.CLUSTER_BREAK.LVT}else if(t<51845){if(t===51844)return f.CLUSTER_BREAK.LV}else if(51845<=t&&t<=51871)return f.CLUSTER_BREAK.LVT}else if(t<51873){if(t===51872)return f.CLUSTER_BREAK.LV}else if(t<51900){if(51873<=t&&t<=51899)return f.CLUSTER_BREAK.LVT}else if(t===51900)return f.CLUSTER_BREAK.LV}else if(t<52208){if(t<52041){if(t<51984){if(t<51929){if(t<51928){if(51901<=t&&t<=51927)return f.CLUSTER_BREAK.LVT}else if(t===51928)return f.CLUSTER_BREAK.LV}else if(t<51956){if(51929<=t&&t<=51955)return f.CLUSTER_BREAK.LVT}else if(t<51957){if(t===51956)return f.CLUSTER_BREAK.LV}else if(51957<=t&&t<=51983)return f.CLUSTER_BREAK.LVT}else if(t<52012){if(t<51985){if(t===51984)return f.CLUSTER_BREAK.LV}else if(51985<=t&&t<=52011)return f.CLUSTER_BREAK.LVT}else if(t<52013){if(t===52012)return f.CLUSTER_BREAK.LV}else if(t<52040){if(52013<=t&&t<=52039)return f.CLUSTER_BREAK.LVT}else if(t===52040)return f.CLUSTER_BREAK.LV}else if(t<52124){if(t<52069){if(t<52068){if(52041<=t&&t<=52067)return f.CLUSTER_BREAK.LVT}else if(t===52068)return f.CLUSTER_BREAK.LV}else if(t<52096){if(52069<=t&&t<=52095)return f.CLUSTER_BREAK.LVT}else if(t<52097){if(t===52096)return f.CLUSTER_BREAK.LV}else if(52097<=t&&t<=52123)return f.CLUSTER_BREAK.LVT}else if(t<52153){if(t<52125){if(t===52124)return f.CLUSTER_BREAK.LV}else if(t<52152){if(52125<=t&&t<=52151)return f.CLUSTER_BREAK.LVT}else if(t===52152)return f.CLUSTER_BREAK.LV}else if(t<52180){if(52153<=t&&t<=52179)return f.CLUSTER_BREAK.LVT}else if(t<52181){if(t===52180)return f.CLUSTER_BREAK.LV}else if(52181<=t&&t<=52207)return f.CLUSTER_BREAK.LVT}else if(t<52349){if(t<52265){if(t<52236){if(t<52209){if(t===52208)return f.CLUSTER_BREAK.LV}else if(52209<=t&&t<=52235)return f.CLUSTER_BREAK.LVT}else if(t<52237){if(t===52236)return f.CLUSTER_BREAK.LV}else if(t<52264){if(52237<=t&&t<=52263)return f.CLUSTER_BREAK.LVT}else if(t===52264)return f.CLUSTER_BREAK.LV}else if(t<52320){if(t<52292){if(52265<=t&&t<=52291)return f.CLUSTER_BREAK.LVT}else if(t<52293){if(t===52292)return f.CLUSTER_BREAK.LV}else if(52293<=t&&t<=52319)return f.CLUSTER_BREAK.LVT}else if(t<52321){if(t===52320)return f.CLUSTER_BREAK.LV}else if(t<52348){if(52321<=t&&t<=52347)return f.CLUSTER_BREAK.LVT}else if(t===52348)return f.CLUSTER_BREAK.LV}else if(t<52432){if(t<52377){if(t<52376){if(52349<=t&&t<=52375)return f.CLUSTER_BREAK.LVT}else if(t===52376)return f.CLUSTER_BREAK.LV}else if(t<52404){if(52377<=t&&t<=52403)return f.CLUSTER_BREAK.LVT}else if(t<52405){if(t===52404)return f.CLUSTER_BREAK.LV}else if(52405<=t&&t<=52431)return f.CLUSTER_BREAK.LVT}else if(t<52461){if(t<52433){if(t===52432)return f.CLUSTER_BREAK.LV}else if(t<52460){if(52433<=t&&t<=52459)return f.CLUSTER_BREAK.LVT}else if(t===52460)return f.CLUSTER_BREAK.LV}else if(t<52488){if(52461<=t&&t<=52487)return f.CLUSTER_BREAK.LVT}else if(t<52489){if(t===52488)return f.CLUSTER_BREAK.LV}else if(52489<=t&&t<=52515)return f.CLUSTER_BREAK.LVT}else if(t<53105){if(t<52797){if(t<52656){if(t<52573){if(t<52544){if(t<52517){if(t===52516)return f.CLUSTER_BREAK.LV}else if(52517<=t&&t<=52543)return f.CLUSTER_BREAK.LVT}else if(t<52545){if(t===52544)return f.CLUSTER_BREAK.LV}else if(t<52572){if(52545<=t&&t<=52571)return f.CLUSTER_BREAK.LVT}else if(t===52572)return f.CLUSTER_BREAK.LV}else if(t<52601){if(t<52600){if(52573<=t&&t<=52599)return f.CLUSTER_BREAK.LVT}else if(t===52600)return f.CLUSTER_BREAK.LV}else if(t<52628){if(52601<=t&&t<=52627)return f.CLUSTER_BREAK.LVT}else if(t<52629){if(t===52628)return f.CLUSTER_BREAK.LV}else if(52629<=t&&t<=52655)return f.CLUSTER_BREAK.LVT}else if(t<52713){if(t<52684){if(t<52657){if(t===52656)return f.CLUSTER_BREAK.LV}else if(52657<=t&&t<=52683)return f.CLUSTER_BREAK.LVT}else if(t<52685){if(t===52684)return f.CLUSTER_BREAK.LV}else if(t<52712){if(52685<=t&&t<=52711)return f.CLUSTER_BREAK.LVT}else if(t===52712)return f.CLUSTER_BREAK.LV}else if(t<52768){if(t<52740){if(52713<=t&&t<=52739)return f.CLUSTER_BREAK.LVT}else if(t<52741){if(t===52740)return f.CLUSTER_BREAK.LV}else if(52741<=t&&t<=52767)return f.CLUSTER_BREAK.LVT}else if(t<52769){if(t===52768)return f.CLUSTER_BREAK.LV}else if(t<52796){if(52769<=t&&t<=52795)return f.CLUSTER_BREAK.LVT}else if(t===52796)return f.CLUSTER_BREAK.LV}else if(t<52964){if(t<52880){if(t<52825){if(t<52824){if(52797<=t&&t<=52823)return f.CLUSTER_BREAK.LVT}else if(t===52824)return f.CLUSTER_BREAK.LV}else if(t<52852){if(52825<=t&&t<=52851)return f.CLUSTER_BREAK.LVT}else if(t<52853){if(t===52852)return f.CLUSTER_BREAK.LV}else if(52853<=t&&t<=52879)return f.CLUSTER_BREAK.LVT}else if(t<52909){if(t<52881){if(t===52880)return f.CLUSTER_BREAK.LV}else if(t<52908){if(52881<=t&&t<=52907)return f.CLUSTER_BREAK.LVT}else if(t===52908)return f.CLUSTER_BREAK.LV}else if(t<52936){if(52909<=t&&t<=52935)return f.CLUSTER_BREAK.LVT}else if(t<52937){if(t===52936)return f.CLUSTER_BREAK.LV}else if(52937<=t&&t<=52963)return f.CLUSTER_BREAK.LVT}else if(t<53021){if(t<52992){if(t<52965){if(t===52964)return f.CLUSTER_BREAK.LV}else if(52965<=t&&t<=52991)return f.CLUSTER_BREAK.LVT}else if(t<52993){if(t===52992)return f.CLUSTER_BREAK.LV}else if(t<53020){if(52993<=t&&t<=53019)return f.CLUSTER_BREAK.LVT}else if(t===53020)return f.CLUSTER_BREAK.LV}else if(t<53076){if(t<53048){if(53021<=t&&t<=53047)return f.CLUSTER_BREAK.LVT}else if(t<53049){if(t===53048)return f.CLUSTER_BREAK.LV}else if(53049<=t&&t<=53075)return f.CLUSTER_BREAK.LVT}else if(t<53077){if(t===53076)return f.CLUSTER_BREAK.LV}else if(t<53104){if(53077<=t&&t<=53103)return f.CLUSTER_BREAK.LVT}else if(t===53104)return f.CLUSTER_BREAK.LV}else if(t<53412){if(t<53245){if(t<53188){if(t<53133){if(t<53132){if(53105<=t&&t<=53131)return f.CLUSTER_BREAK.LVT}else if(t===53132)return f.CLUSTER_BREAK.LV}else if(t<53160){if(53133<=t&&t<=53159)return f.CLUSTER_BREAK.LVT}else if(t<53161){if(t===53160)return f.CLUSTER_BREAK.LV}else if(53161<=t&&t<=53187)return f.CLUSTER_BREAK.LVT}else if(t<53216){if(t<53189){if(t===53188)return f.CLUSTER_BREAK.LV}else if(53189<=t&&t<=53215)return f.CLUSTER_BREAK.LVT}else if(t<53217){if(t===53216)return f.CLUSTER_BREAK.LV}else if(t<53244){if(53217<=t&&t<=53243)return f.CLUSTER_BREAK.LVT}else if(t===53244)return f.CLUSTER_BREAK.LV}else if(t<53328){if(t<53273){if(t<53272){if(53245<=t&&t<=53271)return f.CLUSTER_BREAK.LVT}else if(t===53272)return f.CLUSTER_BREAK.LV}else if(t<53300){if(53273<=t&&t<=53299)return f.CLUSTER_BREAK.LVT}else if(t<53301){if(t===53300)return f.CLUSTER_BREAK.LV}else if(53301<=t&&t<=53327)return f.CLUSTER_BREAK.LVT}else if(t<53357){if(t<53329){if(t===53328)return f.CLUSTER_BREAK.LV}else if(t<53356){if(53329<=t&&t<=53355)return f.CLUSTER_BREAK.LVT}else if(t===53356)return f.CLUSTER_BREAK.LV}else if(t<53384){if(53357<=t&&t<=53383)return f.CLUSTER_BREAK.LVT}else if(t<53385){if(t===53384)return f.CLUSTER_BREAK.LV}else if(53385<=t&&t<=53411)return f.CLUSTER_BREAK.LVT}else if(t<53553){if(t<53469){if(t<53440){if(t<53413){if(t===53412)return f.CLUSTER_BREAK.LV}else if(53413<=t&&t<=53439)return f.CLUSTER_BREAK.LVT}else if(t<53441){if(t===53440)return f.CLUSTER_BREAK.LV}else if(t<53468){if(53441<=t&&t<=53467)return f.CLUSTER_BREAK.LVT}else if(t===53468)return f.CLUSTER_BREAK.LV}else if(t<53524){if(t<53496){if(53469<=t&&t<=53495)return f.CLUSTER_BREAK.LVT}else if(t<53497){if(t===53496)return f.CLUSTER_BREAK.LV}else if(53497<=t&&t<=53523)return f.CLUSTER_BREAK.LVT}else if(t<53525){if(t===53524)return f.CLUSTER_BREAK.LV}else if(t<53552){if(53525<=t&&t<=53551)return f.CLUSTER_BREAK.LVT}else if(t===53552)return f.CLUSTER_BREAK.LV}else if(t<53636){if(t<53581){if(t<53580){if(53553<=t&&t<=53579)return f.CLUSTER_BREAK.LVT}else if(t===53580)return f.CLUSTER_BREAK.LV}else if(t<53608){if(53581<=t&&t<=53607)return f.CLUSTER_BREAK.LVT}else if(t<53609){if(t===53608)return f.CLUSTER_BREAK.LV}else if(53609<=t&&t<=53635)return f.CLUSTER_BREAK.LVT}else if(t<53665){if(t<53637){if(t===53636)return f.CLUSTER_BREAK.LV}else if(t<53664){if(53637<=t&&t<=53663)return f.CLUSTER_BREAK.LVT}else if(t===53664)return f.CLUSTER_BREAK.LV}else if(t<53692){if(53665<=t&&t<=53691)return f.CLUSTER_BREAK.LVT}else if(t<53693){if(t===53692)return f.CLUSTER_BREAK.LV}else if(53693<=t&&t<=53719)return f.CLUSTER_BREAK.LVT}else if(t<70459){if(t<54897){if(t<54308){if(t<54001){if(t<53860){if(t<53777){if(t<53748){if(t<53721){if(t===53720)return f.CLUSTER_BREAK.LV}else if(53721<=t&&t<=53747)return f.CLUSTER_BREAK.LVT}else if(t<53749){if(t===53748)return f.CLUSTER_BREAK.LV}else if(t<53776){if(53749<=t&&t<=53775)return f.CLUSTER_BREAK.LVT}else if(t===53776)return f.CLUSTER_BREAK.LV}else if(t<53805){if(t<53804){if(53777<=t&&t<=53803)return f.CLUSTER_BREAK.LVT}else if(t===53804)return f.CLUSTER_BREAK.LV}else if(t<53832){if(53805<=t&&t<=53831)return f.CLUSTER_BREAK.LVT}else if(t<53833){if(t===53832)return f.CLUSTER_BREAK.LV}else if(53833<=t&&t<=53859)return f.CLUSTER_BREAK.LVT}else if(t<53917){if(t<53888){if(t<53861){if(t===53860)return f.CLUSTER_BREAK.LV}else if(53861<=t&&t<=53887)return f.CLUSTER_BREAK.LVT}else if(t<53889){if(t===53888)return f.CLUSTER_BREAK.LV}else if(t<53916){if(53889<=t&&t<=53915)return f.CLUSTER_BREAK.LVT}else if(t===53916)return f.CLUSTER_BREAK.LV}else if(t<53972){if(t<53944){if(53917<=t&&t<=53943)return f.CLUSTER_BREAK.LVT}else if(t<53945){if(t===53944)return f.CLUSTER_BREAK.LV}else if(53945<=t&&t<=53971)return f.CLUSTER_BREAK.LVT}else if(t<53973){if(t===53972)return f.CLUSTER_BREAK.LV}else if(t<54e3){if(53973<=t&&t<=53999)return f.CLUSTER_BREAK.LVT}else if(t===54e3)return f.CLUSTER_BREAK.LV}else if(t<54141){if(t<54084){if(t<54029){if(t<54028){if(54001<=t&&t<=54027)return f.CLUSTER_BREAK.LVT}else if(t===54028)return f.CLUSTER_BREAK.LV}else if(t<54056){if(54029<=t&&t<=54055)return f.CLUSTER_BREAK.LVT}else if(t<54057){if(t===54056)return f.CLUSTER_BREAK.LV}else if(54057<=t&&t<=54083)return f.CLUSTER_BREAK.LVT}else if(t<54112){if(t<54085){if(t===54084)return f.CLUSTER_BREAK.LV}else if(54085<=t&&t<=54111)return f.CLUSTER_BREAK.LVT}else if(t<54113){if(t===54112)return f.CLUSTER_BREAK.LV}else if(t<54140){if(54113<=t&&t<=54139)return f.CLUSTER_BREAK.LVT}else if(t===54140)return f.CLUSTER_BREAK.LV}else if(t<54224){if(t<54169){if(t<54168){if(54141<=t&&t<=54167)return f.CLUSTER_BREAK.LVT}else if(t===54168)return f.CLUSTER_BREAK.LV}else if(t<54196){if(54169<=t&&t<=54195)return f.CLUSTER_BREAK.LVT}else if(t<54197){if(t===54196)return f.CLUSTER_BREAK.LV}else if(54197<=t&&t<=54223)return f.CLUSTER_BREAK.LVT}else if(t<54253){if(t<54225){if(t===54224)return f.CLUSTER_BREAK.LV}else if(t<54252){if(54225<=t&&t<=54251)return f.CLUSTER_BREAK.LVT}else if(t===54252)return f.CLUSTER_BREAK.LV}else if(t<54280){if(54253<=t&&t<=54279)return f.CLUSTER_BREAK.LVT}else if(t<54281){if(t===54280)return f.CLUSTER_BREAK.LV}else if(54281<=t&&t<=54307)return f.CLUSTER_BREAK.LVT}else if(t<54589){if(t<54448){if(t<54365){if(t<54336){if(t<54309){if(t===54308)return f.CLUSTER_BREAK.LV}else if(54309<=t&&t<=54335)return f.CLUSTER_BREAK.LVT}else if(t<54337){if(t===54336)return f.CLUSTER_BREAK.LV}else if(t<54364){if(54337<=t&&t<=54363)return f.CLUSTER_BREAK.LVT}else if(t===54364)return f.CLUSTER_BREAK.LV}else if(t<54393){if(t<54392){if(54365<=t&&t<=54391)return f.CLUSTER_BREAK.LVT}else if(t===54392)return f.CLUSTER_BREAK.LV}else if(t<54420){if(54393<=t&&t<=54419)return f.CLUSTER_BREAK.LVT}else if(t<54421){if(t===54420)return f.CLUSTER_BREAK.LV}else if(54421<=t&&t<=54447)return f.CLUSTER_BREAK.LVT}else if(t<54505){if(t<54476){if(t<54449){if(t===54448)return f.CLUSTER_BREAK.LV}else if(54449<=t&&t<=54475)return f.CLUSTER_BREAK.LVT}else if(t<54477){if(t===54476)return f.CLUSTER_BREAK.LV}else if(t<54504){if(54477<=t&&t<=54503)return f.CLUSTER_BREAK.LVT}else if(t===54504)return f.CLUSTER_BREAK.LV}else if(t<54560){if(t<54532){if(54505<=t&&t<=54531)return f.CLUSTER_BREAK.LVT}else if(t<54533){if(t===54532)return f.CLUSTER_BREAK.LV}else if(54533<=t&&t<=54559)return f.CLUSTER_BREAK.LVT}else if(t<54561){if(t===54560)return f.CLUSTER_BREAK.LV}else if(t<54588){if(54561<=t&&t<=54587)return f.CLUSTER_BREAK.LVT}else if(t===54588)return f.CLUSTER_BREAK.LV}else if(t<54756){if(t<54672){if(t<54617){if(t<54616){if(54589<=t&&t<=54615)return f.CLUSTER_BREAK.LVT}else if(t===54616)return f.CLUSTER_BREAK.LV}else if(t<54644){if(54617<=t&&t<=54643)return f.CLUSTER_BREAK.LVT}else if(t<54645){if(t===54644)return f.CLUSTER_BREAK.LV}else if(54645<=t&&t<=54671)return f.CLUSTER_BREAK.LVT}else if(t<54701){if(t<54673){if(t===54672)return f.CLUSTER_BREAK.LV}else if(t<54700){if(54673<=t&&t<=54699)return f.CLUSTER_BREAK.LVT}else if(t===54700)return f.CLUSTER_BREAK.LV}else if(t<54728){if(54701<=t&&t<=54727)return f.CLUSTER_BREAK.LVT}else if(t<54729){if(t===54728)return f.CLUSTER_BREAK.LV}else if(54729<=t&&t<=54755)return f.CLUSTER_BREAK.LVT}else if(t<54813){if(t<54784){if(t<54757){if(t===54756)return f.CLUSTER_BREAK.LV}else if(54757<=t&&t<=54783)return f.CLUSTER_BREAK.LVT}else if(t<54785){if(t===54784)return f.CLUSTER_BREAK.LV}else if(t<54812){if(54785<=t&&t<=54811)return f.CLUSTER_BREAK.LVT}else if(t===54812)return f.CLUSTER_BREAK.LV}else if(t<54868){if(t<54840){if(54813<=t&&t<=54839)return f.CLUSTER_BREAK.LVT}else if(t<54841){if(t===54840)return f.CLUSTER_BREAK.LV}else if(54841<=t&&t<=54867)return f.CLUSTER_BREAK.LVT}else if(t<54869){if(t===54868)return f.CLUSTER_BREAK.LV}else if(t<54896){if(54869<=t&&t<=54895)return f.CLUSTER_BREAK.LVT}else if(t===54896)return f.CLUSTER_BREAK.LV}else if(t<69632){if(t<55216){if(t<55037){if(t<54980){if(t<54925){if(t<54924){if(54897<=t&&t<=54923)return f.CLUSTER_BREAK.LVT}else if(t===54924)return f.CLUSTER_BREAK.LV}else if(t<54952){if(54925<=t&&t<=54951)return f.CLUSTER_BREAK.LVT}else if(t<54953){if(t===54952)return f.CLUSTER_BREAK.LV}else if(54953<=t&&t<=54979)return f.CLUSTER_BREAK.LVT}else if(t<55008){if(t<54981){if(t===54980)return f.CLUSTER_BREAK.LV}else if(54981<=t&&t<=55007)return f.CLUSTER_BREAK.LVT}else if(t<55009){if(t===55008)return f.CLUSTER_BREAK.LV}else if(t<55036){if(55009<=t&&t<=55035)return f.CLUSTER_BREAK.LVT}else if(t===55036)return f.CLUSTER_BREAK.LV}else if(t<55120){if(t<55065){if(t<55064){if(55037<=t&&t<=55063)return f.CLUSTER_BREAK.LVT}else if(t===55064)return f.CLUSTER_BREAK.LV}else if(t<55092){if(55065<=t&&t<=55091)return f.CLUSTER_BREAK.LVT}else if(t<55093){if(t===55092)return f.CLUSTER_BREAK.LV}else if(55093<=t&&t<=55119)return f.CLUSTER_BREAK.LVT}else if(t<55149){if(t<55121){if(t===55120)return f.CLUSTER_BREAK.LV}else if(t<55148){if(55121<=t&&t<=55147)return f.CLUSTER_BREAK.LVT}else if(t===55148)return f.CLUSTER_BREAK.LV}else if(t<55176){if(55149<=t&&t<=55175)return f.CLUSTER_BREAK.LVT}else if(t<55177){if(t===55176)return f.CLUSTER_BREAK.LV}else if(55177<=t&&t<=55203)return f.CLUSTER_BREAK.LVT}else if(t<68097){if(t<65279){if(t<64286){if(t<55243){if(55216<=t&&t<=55238)return f.CLUSTER_BREAK.V}else if(55243<=t&&t<=55291)return f.CLUSTER_BREAK.T}else if(t<65024){if(t===64286)return f.CLUSTER_BREAK.EXTEND}else if(t<65056){if(65024<=t&&t<=65039)return f.CLUSTER_BREAK.EXTEND}else if(65056<=t&&t<=65071)return f.CLUSTER_BREAK.EXTEND}else if(t<66045){if(t<65438){if(t===65279)return f.CLUSTER_BREAK.CONTROL}else if(t<65520){if(65438<=t&&t<=65439)return f.CLUSTER_BREAK.EXTEND}else if(65520<=t&&t<=65531)return f.CLUSTER_BREAK.CONTROL}else if(t<66272){if(t===66045)return f.CLUSTER_BREAK.EXTEND}else if(t<66422){if(t===66272)return f.CLUSTER_BREAK.EXTEND}else if(66422<=t&&t<=66426)return f.CLUSTER_BREAK.EXTEND}else if(t<68325){if(t<68108){if(t<68101){if(68097<=t&&t<=68099)return f.CLUSTER_BREAK.EXTEND}else if(68101<=t&&t<=68102)return f.CLUSTER_BREAK.EXTEND}else if(t<68152){if(68108<=t&&t<=68111)return f.CLUSTER_BREAK.EXTEND}else if(t<68159){if(68152<=t&&t<=68154)return f.CLUSTER_BREAK.EXTEND}else if(t===68159)return f.CLUSTER_BREAK.EXTEND}else if(t<69373){if(t<68900){if(68325<=t&&t<=68326)return f.CLUSTER_BREAK.EXTEND}else if(t<69291){if(68900<=t&&t<=68903)return f.CLUSTER_BREAK.EXTEND}else if(69291<=t&&t<=69292)return f.CLUSTER_BREAK.EXTEND}else if(t<69446){if(69373<=t&&t<=69375)return f.CLUSTER_BREAK.EXTEND}else if(t<69506){if(69446<=t&&t<=69456)return f.CLUSTER_BREAK.EXTEND}else if(69506<=t&&t<=69509)return f.CLUSTER_BREAK.EXTEND}else if(t<70016){if(t<69815){if(t<69747){if(t<69634){if(t===69632)return f.CLUSTER_BREAK.SPACINGMARK;if(t===69633)return f.CLUSTER_BREAK.EXTEND}else if(t<69688){if(t===69634)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<69744){if(69688<=t&&t<=69702)return f.CLUSTER_BREAK.EXTEND}else if(t===69744)return f.CLUSTER_BREAK.EXTEND}else if(t<69762){if(t<69759){if(69747<=t&&t<=69748)return f.CLUSTER_BREAK.EXTEND}else if(69759<=t&&t<=69761)return f.CLUSTER_BREAK.EXTEND}else if(t<69808){if(t===69762)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<69811){if(69808<=t&&t<=69810)return f.CLUSTER_BREAK.SPACINGMARK}else if(69811<=t&&t<=69814)return f.CLUSTER_BREAK.EXTEND}else if(t<69888)if(t<69821){if(t<69817){if(69815<=t&&t<=69816)return f.CLUSTER_BREAK.SPACINGMARK}else if(69817<=t&&t<=69818)return f.CLUSTER_BREAK.EXTEND}else if(t<69826){if(t===69821)return f.CLUSTER_BREAK.PREPEND}else{if(t===69826)return f.CLUSTER_BREAK.EXTEND;if(t===69837)return f.CLUSTER_BREAK.PREPEND}else if(t<69933){if(t<69927){if(69888<=t&&t<=69890)return f.CLUSTER_BREAK.EXTEND}else if(t<69932){if(69927<=t&&t<=69931)return f.CLUSTER_BREAK.EXTEND}else if(t===69932)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<69957){if(69933<=t&&t<=69940)return f.CLUSTER_BREAK.EXTEND}else if(t<70003){if(69957<=t&&t<=69958)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===70003)return f.CLUSTER_BREAK.EXTEND}else if(t<70194){if(t<70082){if(t<70067){if(t<70018){if(70016<=t&&t<=70017)return f.CLUSTER_BREAK.EXTEND}else if(t===70018)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70070){if(70067<=t&&t<=70069)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70079){if(70070<=t&&t<=70078)return f.CLUSTER_BREAK.EXTEND}else if(70079<=t&&t<=70080)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70095){if(t<70089){if(70082<=t&&t<=70083)return f.CLUSTER_BREAK.PREPEND}else if(t<70094){if(70089<=t&&t<=70092)return f.CLUSTER_BREAK.EXTEND}else if(t===70094)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70188){if(t===70095)return f.CLUSTER_BREAK.EXTEND}else if(t<70191){if(70188<=t&&t<=70190)return f.CLUSTER_BREAK.SPACINGMARK}else if(70191<=t&&t<=70193)return f.CLUSTER_BREAK.EXTEND}else if(t<70209){if(t<70197){if(t<70196){if(70194<=t&&t<=70195)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===70196)return f.CLUSTER_BREAK.EXTEND}else if(t<70198){if(t===70197)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70206){if(70198<=t&&t<=70199)return f.CLUSTER_BREAK.EXTEND}else if(t===70206)return f.CLUSTER_BREAK.EXTEND}else if(t<70371){if(t<70367){if(t===70209)return f.CLUSTER_BREAK.EXTEND}else if(t<70368){if(t===70367)return f.CLUSTER_BREAK.EXTEND}else if(70368<=t&&t<=70370)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70400){if(70371<=t&&t<=70378)return f.CLUSTER_BREAK.EXTEND}else if(t<70402){if(70400<=t&&t<=70401)return f.CLUSTER_BREAK.EXTEND}else if(70402<=t&&t<=70403)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72343){if(t<71339){if(t<70841){if(t<70512){if(t<70471){if(t<70463){if(t<70462){if(70459<=t&&t<=70460)return f.CLUSTER_BREAK.EXTEND}else if(t===70462)return f.CLUSTER_BREAK.EXTEND}else if(t<70464){if(t===70463)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70465){if(t===70464)return f.CLUSTER_BREAK.EXTEND}else if(70465<=t&&t<=70468)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70487){if(t<70475){if(70471<=t&&t<=70472)return f.CLUSTER_BREAK.SPACINGMARK}else if(70475<=t&&t<=70477)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70498){if(t===70487)return f.CLUSTER_BREAK.EXTEND}else if(t<70502){if(70498<=t&&t<=70499)return f.CLUSTER_BREAK.SPACINGMARK}else if(70502<=t&&t<=70508)return f.CLUSTER_BREAK.EXTEND}else if(t<70725){if(t<70712){if(t<70709){if(70512<=t&&t<=70516)return f.CLUSTER_BREAK.EXTEND}else if(70709<=t&&t<=70711)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70720){if(70712<=t&&t<=70719)return f.CLUSTER_BREAK.EXTEND}else if(t<70722){if(70720<=t&&t<=70721)return f.CLUSTER_BREAK.SPACINGMARK}else if(70722<=t&&t<=70724)return f.CLUSTER_BREAK.EXTEND}else if(t<70832){if(t<70726){if(t===70725)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===70726||t===70750)return f.CLUSTER_BREAK.EXTEND}else if(t<70833){if(t===70832)return f.CLUSTER_BREAK.EXTEND}else if(t<70835){if(70833<=t&&t<=70834)return f.CLUSTER_BREAK.SPACINGMARK}else if(70835<=t&&t<=70840)return f.CLUSTER_BREAK.EXTEND}else if(t<71096){if(t<70847)if(t<70843){if(t===70841)return f.CLUSTER_BREAK.SPACINGMARK;if(t===70842)return f.CLUSTER_BREAK.EXTEND}else if(t<70845){if(70843<=t&&t<=70844)return f.CLUSTER_BREAK.SPACINGMARK}else{if(t===70845)return f.CLUSTER_BREAK.EXTEND;if(t===70846)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71087){if(t<70849){if(70847<=t&&t<=70848)return f.CLUSTER_BREAK.EXTEND}else if(t<70850){if(t===70849)return f.CLUSTER_BREAK.SPACINGMARK}else if(70850<=t&&t<=70851)return f.CLUSTER_BREAK.EXTEND}else if(t<71088){if(t===71087)return f.CLUSTER_BREAK.EXTEND}else if(t<71090){if(71088<=t&&t<=71089)return f.CLUSTER_BREAK.SPACINGMARK}else if(71090<=t&&t<=71093)return f.CLUSTER_BREAK.EXTEND}else if(t<71216){if(t<71102){if(t<71100){if(71096<=t&&t<=71099)return f.CLUSTER_BREAK.SPACINGMARK}else if(71100<=t&&t<=71101)return f.CLUSTER_BREAK.EXTEND}else if(t<71103){if(t===71102)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71132){if(71103<=t&&t<=71104)return f.CLUSTER_BREAK.EXTEND}else if(71132<=t&&t<=71133)return f.CLUSTER_BREAK.EXTEND}else if(t<71229){if(t<71219){if(71216<=t&&t<=71218)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71227){if(71219<=t&&t<=71226)return f.CLUSTER_BREAK.EXTEND}else if(71227<=t&&t<=71228)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71230){if(t===71229)return f.CLUSTER_BREAK.EXTEND}else if(t<71231){if(t===71230)return f.CLUSTER_BREAK.SPACINGMARK}else if(71231<=t&&t<=71232)return f.CLUSTER_BREAK.EXTEND}else if(t<71999)if(t<71463){if(t<71350){if(t<71341){if(t===71339)return f.CLUSTER_BREAK.EXTEND;if(t===71340)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71342){if(t===71341)return f.CLUSTER_BREAK.EXTEND}else if(t<71344){if(71342<=t&&t<=71343)return f.CLUSTER_BREAK.SPACINGMARK}else if(71344<=t&&t<=71349)return f.CLUSTER_BREAK.EXTEND}else if(t<71453){if(t===71350)return f.CLUSTER_BREAK.SPACINGMARK;if(t===71351)return f.CLUSTER_BREAK.EXTEND}else if(t<71458){if(71453<=t&&t<=71455)return f.CLUSTER_BREAK.EXTEND}else if(t<71462){if(71458<=t&&t<=71461)return f.CLUSTER_BREAK.EXTEND}else if(t===71462)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71984){if(t<71727){if(t<71724){if(71463<=t&&t<=71467)return f.CLUSTER_BREAK.EXTEND}else if(71724<=t&&t<=71726)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71736){if(71727<=t&&t<=71735)return f.CLUSTER_BREAK.EXTEND}else if(t<71737){if(t===71736)return f.CLUSTER_BREAK.SPACINGMARK}else if(71737<=t&&t<=71738)return f.CLUSTER_BREAK.EXTEND}else if(t<71995){if(t<71985){if(t===71984)return f.CLUSTER_BREAK.EXTEND}else if(t<71991){if(71985<=t&&t<=71989)return f.CLUSTER_BREAK.SPACINGMARK}else if(71991<=t&&t<=71992)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71997){if(71995<=t&&t<=71996)return f.CLUSTER_BREAK.EXTEND}else{if(t===71997)return f.CLUSTER_BREAK.SPACINGMARK;if(t===71998)return f.CLUSTER_BREAK.EXTEND}else if(t<72193)if(t<72145)if(t<72001){if(t===71999)return f.CLUSTER_BREAK.PREPEND;if(t===72e3)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72002){if(t===72001)return f.CLUSTER_BREAK.PREPEND}else{if(t===72002)return f.CLUSTER_BREAK.SPACINGMARK;if(t===72003)return f.CLUSTER_BREAK.EXTEND}else if(t<72156){if(t<72148){if(72145<=t&&t<=72147)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72154){if(72148<=t&&t<=72151)return f.CLUSTER_BREAK.EXTEND}else if(72154<=t&&t<=72155)return f.CLUSTER_BREAK.EXTEND}else if(t<72160){if(72156<=t&&t<=72159)return f.CLUSTER_BREAK.SPACINGMARK}else{if(t===72160)return f.CLUSTER_BREAK.EXTEND;if(t===72164)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72263){if(t<72249){if(t<72243){if(72193<=t&&t<=72202)return f.CLUSTER_BREAK.EXTEND}else if(72243<=t&&t<=72248)return f.CLUSTER_BREAK.EXTEND}else if(t<72250){if(t===72249)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72251){if(t===72250)return f.CLUSTER_BREAK.PREPEND}else if(72251<=t&&t<=72254)return f.CLUSTER_BREAK.EXTEND}else if(t<72281){if(t<72273){if(t===72263)return f.CLUSTER_BREAK.EXTEND}else if(t<72279){if(72273<=t&&t<=72278)return f.CLUSTER_BREAK.EXTEND}else if(72279<=t&&t<=72280)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72324){if(72281<=t&&t<=72283)return f.CLUSTER_BREAK.EXTEND}else if(t<72330){if(72324<=t&&t<=72329)return f.CLUSTER_BREAK.PREPEND}else if(72330<=t&&t<=72342)return f.CLUSTER_BREAK.EXTEND}else if(t<94033){if(t<73104){if(t<72881){if(t<72766){if(t<72751){if(t<72344){if(t===72343)return f.CLUSTER_BREAK.SPACINGMARK}else if(72344<=t&&t<=72345)return f.CLUSTER_BREAK.EXTEND}else if(t<72752){if(t===72751)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72760){if(72752<=t&&t<=72758)return f.CLUSTER_BREAK.EXTEND}else if(72760<=t&&t<=72765)return f.CLUSTER_BREAK.EXTEND}else if(t<72850){if(t===72766)return f.CLUSTER_BREAK.SPACINGMARK;if(t===72767)return f.CLUSTER_BREAK.EXTEND}else if(t<72873){if(72850<=t&&t<=72871)return f.CLUSTER_BREAK.EXTEND}else if(t<72874){if(t===72873)return f.CLUSTER_BREAK.SPACINGMARK}else if(72874<=t&&t<=72880)return f.CLUSTER_BREAK.EXTEND}else if(t<73018){if(t<72884){if(t<72882){if(t===72881)return f.CLUSTER_BREAK.SPACINGMARK}else if(72882<=t&&t<=72883)return f.CLUSTER_BREAK.EXTEND}else if(t<72885){if(t===72884)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<73009){if(72885<=t&&t<=72886)return f.CLUSTER_BREAK.EXTEND}else if(73009<=t&&t<=73014)return f.CLUSTER_BREAK.EXTEND}else if(t<73030){if(t<73020){if(t===73018)return f.CLUSTER_BREAK.EXTEND}else if(t<73023){if(73020<=t&&t<=73021)return f.CLUSTER_BREAK.EXTEND}else if(73023<=t&&t<=73029)return f.CLUSTER_BREAK.EXTEND}else if(t<73031){if(t===73030)return f.CLUSTER_BREAK.PREPEND}else if(t<73098){if(t===73031)return f.CLUSTER_BREAK.EXTEND}else if(73098<=t&&t<=73102)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<73526){if(t<73459)if(t<73109){if(t<73107){if(73104<=t&&t<=73105)return f.CLUSTER_BREAK.EXTEND}else if(73107<=t&&t<=73108)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<73110){if(t===73109)return f.CLUSTER_BREAK.EXTEND}else{if(t===73110)return f.CLUSTER_BREAK.SPACINGMARK;if(t===73111)return f.CLUSTER_BREAK.EXTEND}else if(t<73474){if(t<73461){if(73459<=t&&t<=73460)return f.CLUSTER_BREAK.EXTEND}else if(t<73472){if(73461<=t&&t<=73462)return f.CLUSTER_BREAK.SPACINGMARK}else if(73472<=t&&t<=73473)return f.CLUSTER_BREAK.EXTEND}else if(t<73475){if(t===73474)return f.CLUSTER_BREAK.PREPEND}else if(t<73524){if(t===73475)return f.CLUSTER_BREAK.SPACINGMARK}else if(73524<=t&&t<=73525)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<78896)if(t<73536){if(t<73534){if(73526<=t&&t<=73530)return f.CLUSTER_BREAK.EXTEND}else if(73534<=t&&t<=73535)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<73537){if(t===73536)return f.CLUSTER_BREAK.EXTEND}else{if(t===73537)return f.CLUSTER_BREAK.SPACINGMARK;if(t===73538)return f.CLUSTER_BREAK.EXTEND}else if(t<92912){if(t<78912){if(78896<=t&&t<=78911)return f.CLUSTER_BREAK.CONTROL}else if(t<78919){if(t===78912)return f.CLUSTER_BREAK.EXTEND}else if(78919<=t&&t<=78933)return f.CLUSTER_BREAK.EXTEND}else if(t<92976){if(92912<=t&&t<=92916)return f.CLUSTER_BREAK.EXTEND}else if(t<94031){if(92976<=t&&t<=92982)return f.CLUSTER_BREAK.EXTEND}else if(t===94031)return f.CLUSTER_BREAK.EXTEND}else if(t<121476){if(t<119143)if(t<113824){if(t<94180){if(t<94095){if(94033<=t&&t<=94087)return f.CLUSTER_BREAK.SPACINGMARK}else if(94095<=t&&t<=94098)return f.CLUSTER_BREAK.EXTEND}else if(t<94192){if(t===94180)return f.CLUSTER_BREAK.EXTEND}else if(t<113821){if(94192<=t&&t<=94193)return f.CLUSTER_BREAK.SPACINGMARK}else if(113821<=t&&t<=113822)return f.CLUSTER_BREAK.EXTEND}else if(t<118576){if(t<118528){if(113824<=t&&t<=113827)return f.CLUSTER_BREAK.CONTROL}else if(118528<=t&&t<=118573)return f.CLUSTER_BREAK.EXTEND}else if(t<119141){if(118576<=t&&t<=118598)return f.CLUSTER_BREAK.EXTEND}else{if(t===119141)return f.CLUSTER_BREAK.EXTEND;if(t===119142)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<119173){if(t<119150){if(t<119149){if(119143<=t&&t<=119145)return f.CLUSTER_BREAK.EXTEND}else if(t===119149)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<119155){if(119150<=t&&t<=119154)return f.CLUSTER_BREAK.EXTEND}else if(t<119163){if(119155<=t&&t<=119162)return f.CLUSTER_BREAK.CONTROL}else if(119163<=t&&t<=119170)return f.CLUSTER_BREAK.EXTEND}else if(t<121344){if(t<119210){if(119173<=t&&t<=119179)return f.CLUSTER_BREAK.EXTEND}else if(t<119362){if(119210<=t&&t<=119213)return f.CLUSTER_BREAK.EXTEND}else if(119362<=t&&t<=119364)return f.CLUSTER_BREAK.EXTEND}else if(t<121403){if(121344<=t&&t<=121398)return f.CLUSTER_BREAK.EXTEND}else if(t<121461){if(121403<=t&&t<=121452)return f.CLUSTER_BREAK.EXTEND}else if(t===121461)return f.CLUSTER_BREAK.EXTEND}else if(t<123628){if(t<122907){if(t<121505){if(t<121499){if(t===121476)return f.CLUSTER_BREAK.EXTEND}else if(121499<=t&&t<=121503)return f.CLUSTER_BREAK.EXTEND}else if(t<122880){if(121505<=t&&t<=121519)return f.CLUSTER_BREAK.EXTEND}else if(t<122888){if(122880<=t&&t<=122886)return f.CLUSTER_BREAK.EXTEND}else if(122888<=t&&t<=122904)return f.CLUSTER_BREAK.EXTEND}else if(t<123023){if(t<122915){if(122907<=t&&t<=122913)return f.CLUSTER_BREAK.EXTEND}else if(t<122918){if(122915<=t&&t<=122916)return f.CLUSTER_BREAK.EXTEND}else if(122918<=t&&t<=122922)return f.CLUSTER_BREAK.EXTEND}else if(t<123184){if(t===123023)return f.CLUSTER_BREAK.EXTEND}else if(t<123566){if(123184<=t&&t<=123190)return f.CLUSTER_BREAK.EXTEND}else if(t===123566)return f.CLUSTER_BREAK.EXTEND}else if(t<127995){if(t<125136){if(t<124140){if(123628<=t&&t<=123631)return f.CLUSTER_BREAK.EXTEND}else if(124140<=t&&t<=124143)return f.CLUSTER_BREAK.EXTEND}else if(t<125252){if(125136<=t&&t<=125142)return f.CLUSTER_BREAK.EXTEND}else if(t<127462){if(125252<=t&&t<=125258)return f.CLUSTER_BREAK.EXTEND}else if(127462<=t&&t<=127487)return f.CLUSTER_BREAK.REGIONAL_INDICATOR}else if(t<917632){if(t<917504){if(127995<=t&&t<=127999)return f.CLUSTER_BREAK.EXTEND}else if(t<917536){if(917504<=t&&t<=917535)return f.CLUSTER_BREAK.CONTROL}else if(917536<=t&&t<=917631)return f.CLUSTER_BREAK.EXTEND}else if(t<917760){if(917632<=t&&t<=917759)return f.CLUSTER_BREAK.CONTROL}else if(t<918e3){if(917760<=t&&t<=917999)return f.CLUSTER_BREAK.EXTEND}else if(918e3<=t&&t<=921599)return f.CLUSTER_BREAK.CONTROL;return f.CLUSTER_BREAK.OTHER}static getEmojiProperty(t){if(t<10160){if(t<9728){if(t<9e3){if(t<8482){if(t<8252){if(t===169||t===174)return f.EXTENDED_PICTOGRAPHIC}else if(t===8252||t===8265)return f.EXTENDED_PICTOGRAPHIC}else if(t<8596){if(t===8482||t===8505)return f.EXTENDED_PICTOGRAPHIC}else if(t<8617){if(8596<=t&&t<=8601)return f.EXTENDED_PICTOGRAPHIC}else if(t<8986){if(8617<=t&&t<=8618)return f.EXTENDED_PICTOGRAPHIC}else if(8986<=t&&t<=8987)return f.EXTENDED_PICTOGRAPHIC}else if(t<9410){if(t<9167){if(t===9e3||t===9096)return f.EXTENDED_PICTOGRAPHIC}else if(t<9193){if(t===9167)return f.EXTENDED_PICTOGRAPHIC}else if(t<9208){if(9193<=t&&t<=9203)return f.EXTENDED_PICTOGRAPHIC}else if(9208<=t&&t<=9210)return f.EXTENDED_PICTOGRAPHIC}else if(t<9654){if(t<9642){if(t===9410)return f.EXTENDED_PICTOGRAPHIC}else if(9642<=t&&t<=9643)return f.EXTENDED_PICTOGRAPHIC}else if(t<9664){if(t===9654)return f.EXTENDED_PICTOGRAPHIC}else if(t<9723){if(t===9664)return f.EXTENDED_PICTOGRAPHIC}else if(9723<=t&&t<=9726)return f.EXTENDED_PICTOGRAPHIC}else if(t<10035){if(t<10004){if(t<9748){if(t<9735){if(9728<=t&&t<=9733)return f.EXTENDED_PICTOGRAPHIC}else if(9735<=t&&t<=9746)return f.EXTENDED_PICTOGRAPHIC}else if(t<9872){if(9748<=t&&t<=9861)return f.EXTENDED_PICTOGRAPHIC}else if(t<9992){if(9872<=t&&t<=9989)return f.EXTENDED_PICTOGRAPHIC}else if(9992<=t&&t<=10002)return f.EXTENDED_PICTOGRAPHIC}else if(t<10013){if(t===10004||t===10006)return f.EXTENDED_PICTOGRAPHIC}else if(t<10017){if(t===10013)return f.EXTENDED_PICTOGRAPHIC}else if(t===10017||t===10024)return f.EXTENDED_PICTOGRAPHIC}else if(t<10067){if(t<10055){if(t<10052){if(10035<=t&&t<=10036)return f.EXTENDED_PICTOGRAPHIC}else if(t===10052)return f.EXTENDED_PICTOGRAPHIC}else if(t<10060){if(t===10055)return f.EXTENDED_PICTOGRAPHIC}else if(t===10060||t===10062)return f.EXTENDED_PICTOGRAPHIC}else if(t<10083){if(t<10071){if(10067<=t&&t<=10069)return f.EXTENDED_PICTOGRAPHIC}else if(t===10071)return f.EXTENDED_PICTOGRAPHIC}else if(t<10133){if(10083<=t&&t<=10087)return f.EXTENDED_PICTOGRAPHIC}else if(t<10145){if(10133<=t&&t<=10135)return f.EXTENDED_PICTOGRAPHIC}else if(t===10145)return f.EXTENDED_PICTOGRAPHIC}else if(t<127489){if(t<12951){if(t<11035){if(t<10548){if(t===10160||t===10175)return f.EXTENDED_PICTOGRAPHIC}else if(t<11013){if(10548<=t&&t<=10549)return f.EXTENDED_PICTOGRAPHIC}else if(11013<=t&&t<=11015)return f.EXTENDED_PICTOGRAPHIC}else if(t<11093){if(t<11088){if(11035<=t&&t<=11036)return f.EXTENDED_PICTOGRAPHIC}else if(t===11088)return f.EXTENDED_PICTOGRAPHIC}else if(t<12336){if(t===11093)return f.EXTENDED_PICTOGRAPHIC}else if(t===12336||t===12349)return f.EXTENDED_PICTOGRAPHIC}else if(t<127340){if(t<126976){if(t===12951||t===12953)return f.EXTENDED_PICTOGRAPHIC}else if(t<127245){if(126976<=t&&t<=127231)return f.EXTENDED_PICTOGRAPHIC}else if(t<127279){if(127245<=t&&t<=127247)return f.EXTENDED_PICTOGRAPHIC}else if(t===127279)return f.EXTENDED_PICTOGRAPHIC}else if(t<127374){if(t<127358){if(127340<=t&&t<=127345)return f.EXTENDED_PICTOGRAPHIC}else if(127358<=t&&t<=127359)return f.EXTENDED_PICTOGRAPHIC}else if(t<127377){if(t===127374)return f.EXTENDED_PICTOGRAPHIC}else if(t<127405){if(127377<=t&&t<=127386)return f.EXTENDED_PICTOGRAPHIC}else if(127405<=t&&t<=127461)return f.EXTENDED_PICTOGRAPHIC}else if(t<128981){if(t<127561){if(t<127535){if(t<127514){if(127489<=t&&t<=127503)return f.EXTENDED_PICTOGRAPHIC}else if(t===127514)return f.EXTENDED_PICTOGRAPHIC}else if(t<127538){if(t===127535)return f.EXTENDED_PICTOGRAPHIC}else if(t<127548){if(127538<=t&&t<=127546)return f.EXTENDED_PICTOGRAPHIC}else if(127548<=t&&t<=127551)return f.EXTENDED_PICTOGRAPHIC}else if(t<128326){if(t<128e3){if(127561<=t&&t<=127994)return f.EXTENDED_PICTOGRAPHIC}else if(128e3<=t&&t<=128317)return f.EXTENDED_PICTOGRAPHIC}else if(t<128640){if(128326<=t&&t<=128591)return f.EXTENDED_PICTOGRAPHIC}else if(t<128884){if(128640<=t&&t<=128767)return f.EXTENDED_PICTOGRAPHIC}else if(128884<=t&&t<=128895)return f.EXTENDED_PICTOGRAPHIC}else if(t<129198){if(t<129096){if(t<129036){if(128981<=t&&t<=129023)return f.EXTENDED_PICTOGRAPHIC}else if(129036<=t&&t<=129039)return f.EXTENDED_PICTOGRAPHIC}else if(t<129114){if(129096<=t&&t<=129103)return f.EXTENDED_PICTOGRAPHIC}else if(t<129160){if(129114<=t&&t<=129119)return f.EXTENDED_PICTOGRAPHIC}else if(129160<=t&&t<=129167)return f.EXTENDED_PICTOGRAPHIC}else if(t<129340){if(t<129292){if(129198<=t&&t<=129279)return f.EXTENDED_PICTOGRAPHIC}else if(129292<=t&&t<=129338)return f.EXTENDED_PICTOGRAPHIC}else if(t<129351){if(129340<=t&&t<=129349)return f.EXTENDED_PICTOGRAPHIC}else if(t<130048){if(129351<=t&&t<=129791)return f.EXTENDED_PICTOGRAPHIC}else if(130048<=t&&t<=131069)return f.EXTENDED_PICTOGRAPHIC;return f.CLUSTER_BREAK.OTHER}}k1.default=Zi;var v_=Mn&&Mn.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(nB,"__esModule",{value:!0});const B_=v_(k1);var T_=nB.default=B_.default;const y_=new T_,Qs=I("text-offset");function zo(n,t){const e=fi(n);let r=0;for(let i=0;i<e.length;i++){const o=e[i],s=mr(o);if(o===t){const l=r+s;return{start:r,end:l}}r+=s}p(Qs,!1,"can not find child in children")}function Un(n,t){p(Qs,t>=0,`invalid offset: ${t}`);const e=qd(n,t),{prev:r,next:i,offset:o}=e;if(!r&&!i&&p(Qs,!1,"invalid offset, no prev & next child at offset"),r!==i)return!0;const s=r;if(p(Qs,s,"no child"),hr(s))return p(Qs,o===0||o===1,`invalid box child offset: ${o}`),!0;const l=s.textContent;p(Qs,l,"no content for text child");const c=y_.splitGraphemes(l),d=new Set;let h=0;return c.forEach(C=>{d.add(h),h+=C.length}),d.add(h),!!d.has(o)}function Go(n,t){if(t===0)return 0;const e=t-1;if(Un(n,e))return e;let r=e-1;for(;!Un(n,r);)r-=1;return r}function Ys(n,t){const e=fu(n);if(p(Qs,t>=0&&t<=e,`invalid offset: ${t}, ${e}`),t===e)return e;const r=t+1;if(Un(n,r))return r;let i=r+1;for(;!Un(n,i);)i+=1;return i}const k_=I("line-offset");function I1(n){const t=Cu(n),e=[];let r=0;for(let i=0;i<t.length;i++){const o=t[i];e.push({start:r,end:o.offset}),r=o.offset}return e.push({start:r,end:fu(n)}),e}function lh(n,t){const e=I1(n);return p(k_,t>=0&&t<e.length,`invalid line index: ${t}, ${e.length}`),e[t]}function iB(n,t){const{lineIndex:e}=y1(n,t);return lh(n,e)}function R_(n){const t=I1(n),e=n.getBoundingClientRect(),r=[];return t.forEach(({start:i,end:o})=>{const s=lt(n,i,"home");let l=Yn(n,s);const c=lt(n,o,"end"),d=Yn(n,c);l.top+l.height/2<d.top&&(l=new DOMRect(e.left-1e4,d.top,1,d.height));const h=new DOMRect(l.left,d.top,d.left-l.left,d.height),C=new DOMRect(e.left,d.top,e.width,d.height);r.push({start:i,end:o,rect:C,contentRect:h})}),r}function w_(n,t,e){const i=R_(n).find(s=>Ns(s.rect,t,e));if(!i)return null;const o=i.contentRect;return t-o.left<o.right-t?lt(n,i.start,"home"):lt(n,i.end,"end")}function oB(n,t,e){const r=Yn(n,t),i=Yn(n,e),o=r.top+r.height/2,s=i.top+i.height/2,l=i.top<o&&o<i.bottom,c=r.top<s&&s<r.bottom;return l&&c}function sB(n){return I1(n).length}const Js=I("find-text-position");function lB(n,t){const{start:e,end:r}=lh(n,t),i=st(n),o=Yn(n,lt(i,e,"home"));if(!(Yn(n,lt(i,r,"end")).top>o.top+o.height/2))return!1;const c=qd(n,e);return p(Js,c.next,"no next child at offset"),p(Js,!cu(c.next),"next child is not text child"),!0}function S_(n,t){const e=st(n);p(Js,lB(n,t),"line is not wrapped");const{start:r,end:i}=lh(n,t),o=lt(e,r,"home");for(let s=r+1;s<=i;s+=1){let l="normal";s===r?l="home":s===i&&(l="end");const c=lt(e,s,l);if(!oB(n,o,c))return s-1}return p(Js,!1,"failed to find wrapped offset"),0}function ah(n,t,e,r,i,o,s){p(Js,nt(n,t),`not a text kind block: ${St(t)}`);const{start:l,end:c}=lh(t,e);let d=l;const h=st(t);if(t===r&&lB(t,e)){const L=S_(t,e);(o==="up"||o==="down"&&oB(t,i,lt(h,l,"home")))&&(d=L+1)}let C=Number.MAX_SAFE_INTEGER;const E=_r(n,r,i),A=s!=null?s:E.left+E.width/2,v=E.top+E.height/2;let R=lt(h,d,"home");for(let L=d;L<=c;L++){if(!Un(t,L))continue;let M="normal";L===l?M="home":L===c&&(M="end");const U=lt(h,L,M),F=Yn(t,U),G=$i(F,A,v);G<C&&(C=G,R=U)}return R}function L_(n,t,e,r,i){return p(Js,nt(n,t),"not a text block"),ah(n,t,sB(t)-1,e,r,"up",i)}function I_(n,t,e,r,i){return p(Js,nt(n,t),"not a text block"),ah(n,t,0,e,r,"down",i)}function D_(n,t,e,r){const{lineIndex:i}=y1(t,e);if(i===sB(t)-1)return null;const o=ah(n,t,i+1,t,e,"down",r);return o||null}function __(n,t){if(t.offset===0)return null;const e=Cu(n),r=e.find(i=>i.offset===t.offset);if(!r){const i=Go(n,t.offset);return e.find(s=>s.offset===i)?{offset:i,type:"home"}:{offset:i,type:"normal"}}if(r.type==="betweenChild"){if(t.type==="home"&&r.childInfo.wrap==="nowrap")return{offset:t.offset,type:"end"};if(r.childInfo.prevWrapped)return{offset:Go(n,t.offset),type:"normal"}}return{offset:Go(n,t.offset),type:"normal"}}function M_(n,t){const e=fu(n);if(t.offset===e)return null;const r=Cu(n),i=r.find(o=>o.offset===t.offset);if(!i){const o=Ys(n,t.offset),s=r.find(l=>l.offset===o);return s?s.type==="betweenChild"?{offset:o,type:"end"}:{offset:o,type:"home"}:{offset:o,type:"normal"}}return i.type==="betweenChild"?i.childInfo.wrap==="nowrap"&&t.type==="end"?{offset:t.offset,type:"home"}:{offset:Ys(n,t.offset),type:"home"}:{offset:Ys(n,t.offset),type:"normal"}}function U_(n,t,e,r){const{lineIndex:i}=y1(t,e);if(i===0)return null;const o=ah(n,t,i-1,t,e,"up",r);return o||null}const O_=I("move-caret");function N_(n,t,e,r){if(r==="ArrowLeft"){const i=__(t,e);return i?lt(st(t),i.offset,i.type):null}if(r==="ArrowRight"){const i=M_(t,e);return i?lt(st(t),i.offset,i.type):null}if(r==="ArrowUp"){const i=U_(n,t,e,n.selection.getSuggestedCaretX());return i?lt(st(t),i.offset,i.type):null}if(r==="ArrowDown"){const i=D_(n,t,e,n.selection.getSuggestedCaretX());return i?lt(st(t),i.offset,i.type):null}p(O_,!1,`invalid navigation direction: ${r}`)}const D1=I("text-range");function P_(n){const t=[];return fi(n).forEach(r=>{const i=Array.from(r.getClientRects()).map(o=>({rect:o,child:r}));t.push(...i)}),t}function F_(n,t,e){const r=P_(n);for(let i=1;i<r.length;i++){const o=r[i-1],s=r[i];if(t>=o.rect.right&&t<=s.rect.left&&e>=o.rect.top&&e<=o.rect.bottom&&e>=s.rect.top&&e<=s.rect.bottom)return zo(n,s.child).start}return null}function K_(n,t,e,r){const i=document.elementsFromPoint(e,r)[0];if(!i||!t.contains(i)||!n.contains(t))return null;const o=i.closest("div[data-type=block-content]>span");if(!o){const M=t.getBoundingClientRect();if(!Ns(M,e,r))return null;const U=F_(t,e,r);if(U!==null){const G=lt(t,U,"normal");return new tn(n,{anchor:G,focus:G})}const F=w_(t,e,r);return F?new tn(n,{anchor:F,focus:F}):null}const s=fi(t);p(D1,s.indexOf(o)!==-1,"failed to find child in children");const l=zo(t,o);p(D1,l,"failed to get child offset");const{start:c}=l;let d,h;Qi(o)||hr(o)?(d=c,h=0):(p(D1,o.firstChild instanceof Text,"child is not text"),d=c+Mb(o.firstChild,e,r),h=0);const C=st(t),A=Cu(t).find(M=>M.offset===d);let v="normal";if(A){const M=lt(C,d,"home"),U=lt(C,d,"end"),F=Yn(t,M),G=Yn(t,U),W=$i(F,e,r),it=$i(G,e,r);v=W<it?"home":"end"}const R=lt(C,d,v);let L;return h&&(L=lt(C,d+h,v)),new tn(n,{anchor:R,focus:L!=null?L:R})}const V_=I("create-text-op");function gr(n,t){p(V_,n,"text is empty");const e={insert:n};return t&&Object.keys(t).length>0&&(e.attributes=t),e}function _1(n,t){if(n.length===0)return[];if(n.indexOf(`
|
|
15
|
+
*/function F9(n){if(typeof n=="string")return n.length===0?!1:n.charCodeAt(0)>=55296&&n.charCodeAt(0)<=56319;if(n===void 0)return!1;throw new TypeError(`string-character-is-astral-surrogate/isHighSurrogate(): the input is not string but ${typeof n}`)}function K9(n){if(typeof n=="string")return n.length===0?!1:n.charCodeAt(0)>=56320&&n.charCodeAt(0)<=57343;if(n===void 0)return!1;throw new TypeError(`string-character-is-astral-surrogate/isLowSurrogate(): the input is not string but ${typeof n}`)}const Qc="\u200B";function V9(n){return[...n].length}function $9(n,t,e){const i=[...n];let o;return e===void 0?o=i.length:o=t+e,i.slice(t,o).join("")}function H9(n){const t="\xA0";if(!n)return"";if(n===" ")return t;let e=n;return e.startsWith(" ")&&(e=t+e.substr(1)),e.endsWith(" ")&&(e=e.substr(0,e.length-1)+t),e=e.replace(/ {2}/g,` ${t}`),e}function Ud(n){if(!/["'&<>]/.exec(n))return n;const r={'"':""","'":"'","&":"&","<":"<",">":">"};return n.split("").map(l=>r[l]||l).join("")}function Fb(n){const t=document.getElementById(n);t&&t.remove()}function Kb(n,t){const e=document.getElementById(t);if(e)return e.textContent=n,e;const r=document.createElement("style");return r.id=t,r.textContent=n,document.head.append(r),r}function Yc(n){const t="custom-cursor-style";if(n){const e=`body * { cursor: ${n} !important}`;Kb(e,t)}else Fb(t)}const Vb=3,$b=I("drag-drop");class Hb{constructor(t){m(this,"dragStarted",!1);m(this,"mouseDownEvent",null);m(this,"_dragOffsetX",0);m(this,"_dragOffsetY",0);m(this,"handleMouseDown",t=>{t.preventDefault(),t.stopPropagation(),this.mouseDownEvent=t;const e=this.options.elem.getBoundingClientRect();this._dragOffsetX=this.mouseDownEvent.x-e.left,this._dragOffsetY=this.mouseDownEvent.y-e.top,this.bindEvents()});m(this,"handleMouseMove",t=>{var o;t.preventDefault(),t.stopPropagation(),p($b,this.mouseDownEvent,"no mouse down event");const e=t.x-this.mouseDownEvent.x,r=t.y-this.mouseDownEvent.y;if(this.dragStarted){this.onDragging(t,e,r);return}const i=(o=this.options.minThreshold)!=null?o:Vb;(Math.abs(e)>=i||Math.abs(r)>=i)&&this.onDragStart(this.mouseDownEvent)});m(this,"handleMouseUp",t=>{if(t.button===0){p($b,this.mouseDownEvent,"no mouse down event");const e=t.x-this.mouseDownEvent.x,r=t.y-this.mouseDownEvent.y;this.onDragEnd(t,e,r),t.preventDefault(),t.stopPropagation()}});this.options=t,this.options.mouseDownEvent?this.handleMouseDown(this.options.mouseDownEvent):this.trackEvents()}get data(){return this.options.data}get dragOffsetX(){return this._dragOffsetX}get dragOffsetY(){return this._dragOffsetY}get dragOffset(){return{x:this._dragOffsetX,y:this._dragOffsetY}}trackEvents(){this.options.elem.addEventListener("mousedown",this.handleMouseDown)}untrackEvents(){this.options.elem.removeEventListener("mousedown",this.handleMouseDown)}bindEvents(){document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}unbindEvents(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}onDragStart(t){this.dragStarted=!0,this.options.cursor&&Yc(this.options.cursor),this.options.onDragStart(this,t,this.options.elem)}onDragging(t,e,r){this.options.onDragging(this,t,this.options.elem,e,r)}onDragEnd(t,e,r){this.options.cursor&&Yc(null),this.dragStarted&&this.options.onDragEnd(this,t,this.options.elem,e,r),this.unbindEvents(),this.dragStarted=!1}destroy(){this.unbindEvents(),this.untrackEvents()}}function _g(n){return new Hb(n)}const j9=I("character");function jb(n,t){for(let e=0;e<t.length;e++){const r=t[e][0],i=t[e].length>1?t[e][1]:null;if(i===null&&n===r||i!==null&&n>=r&&n<=i)return!0}return!1}function zb(n){const t=n.charAt(0);return t>="0"&&t<="9"}function Gb(n){const t=n.charAt(0);return t>="a"&&t<="z"||t>="A"&&t<="Z"||t.toUpperCase()!==t.toLowerCase()?!0:RegExp(/^\p{L}/,"u").test(t)}function Od(n){const t=[[9,13],[32],[160]];return jb(n.charCodeAt(0),t)}function Wb(n){const t=[[12352,12687],[13056,13183],[13312,15661],[19968,40959],[63744,64255],[44032,55215]];return jb(n.charCodeAt(0),t)}function Mg(n,t){let e=t;return p(j9,e.length===1,"invalid char length"),e==="]"&&(e="\\]"),e==="\\"&&(e="\\\\"),n.replace(new RegExp(`^[${e}]+|[${e}]+$`,"g"),"")}const ji=navigator.userAgent;function ua(){const n=navigator.userAgent.toLowerCase();return n.indexOf("safari")!==-1&&!(n.indexOf("chrome")>-1)}function Jc(){return navigator.userAgent.toLowerCase().indexOf("firefox")>-1}const me={isAndroid:!!ji.match(/Android/i),isIOS:!!ji.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/i),isIPad:!!ji.match(/iPad/i),isIPhone:!!ji.match(/iPhone/i),isLinux:!!ji.match(/Linux/i),isMac:!!ji.match(/Macintosh/i),isMobile:!!ji.match(/AppleWebKit.*Mobile.*/i),isWindows:!!ji.match(/Window/i),isIe:!!ji.match(/msie|trident/i),isSafari:ua(),isFirefox:Jc(),isMobileSafari:!1};me.isMobileSafari=me.isMobile&&me.isSafari;function Ug(n){return n?n.length===1||n==="Process"||n==="Unidentified"&&me.isAndroid:!1}function qb(n){switch(n){case"ArrowDown":case"ArrowUp":case"ArrowLeft":case"ArrowRight":case"End":case"Home":case"PageDown":case"PageUp":return!0;default:return!1}}function z9(n){return qb(n.key)}function G9(n){switch(n){case"ArrowUp":case"ArrowLeft":case"Home":case"PageUp":return!0;default:return!1}}function Ps(n){return n.ctrlKey||n.altKey||n.shiftKey||n.metaKey}function W9(n){return n.key?!!(n.ctrlKey||n.metaKey||n.altKey):!1}function Xb(n){return me.isMac?n.metaKey&&!n.ctrlKey:!n.metaKey&&n.ctrlKey}function q9(n){return Xb(n)&&!n.altKey&&!n.shiftKey}function X9(n){return!n.metaKey&&!n.ctrlKey&&!n.shiftKey&&n.altKey}function Qb(n){return!Ps(n)&&n.key==="Enter"}function Q9(n){return n.key==="Enter"&&n.shiftKey&&!n.altKey&&!n.ctrlKey&&!n.metaKey}function Og(n){return!Ps(n)&&n.key==="Escape"}function Y9(n){return!Ps(n)&&n.key==="Delete"}function Yb(n){return!Ps(n)&&n.key==="Backspace"}function J9(n){return!Ps(n)&&n.key==="Tab"}function Z9(n){return n.shiftKey&&n.key==="Tab"&&!n.ctrlKey&&!n.metaKey}function ze(n){if(!n)return"";if(me.isMac){const t=n.replace("CtrlOrCmd","\u2318").replace("Shift","\u21E7").replace("Ctrl","\u2303").replace("Alt","\u2325").replace(/\+(?!$)/gm,""),e={"\u2318":4,"\u21E7":3,"\u2325":2,"\u2303":1};return t.split(/(?=[\s\S])/u).sort((i,o)=>{var c,d;const s=(c=e[i])!=null?c:5,l=(d=e[o])!=null?d:5;return s-l}).map(i=>i in e?`${i}+`:i).join("")}return n.replace("CtrlOrCmd","Ctrl")}function Jb(n){const t={ctrl:!1,alt:!1,shift:!1,cmd:!1,key:""},e=n.toLocaleUpperCase().split("+");for(let r=0;r<e.length;r++){const i=e[r];i==="CTRL"||i==="CONTROL"?t.ctrl=!0:i==="ALT"||i==="OPTION"?t.alt=!0:i==="SHIFT"?t.shift=!0:i==="CMD"||i==="COMMAND"?t.cmd=!0:i==="CMDORCTRL"||i==="CTRLORCMD"?me.isMac?t.cmd=!0:t.ctrl=!0:i==="SPACE"?t.key=" ":t.key=i.substring(0,1)+i.substring(1).toLocaleLowerCase()}return t}function ai(n,t){const e=Jb(t);return e.ctrl!==n.ctrlKey||e.alt!==n.altKey||e.shift!==n.shiftKey||me.isMac&&e.cmd!==n.metaKey?!1:e.key.length===1?e.key===n.key.toUpperCase():e.key.toUpperCase()===n.key.toUpperCase()}function Ng(n,t){return k6.stringifyUrl({url:n,query:t})}function ci(n){return typeof n=="string"?Wc.Base64.encode(n,!0):Wc.Base64.fromUint8Array(n,!0)}function Zc(n){return Wc.Base64.decode(n)}function tI(n){return Wc.Base64.toUint8Array(n)}function Pg(n){return new Blob([Wc.Base64.toUint8Array(n)])}const eI=Ko.init([Ko.classModule,Ko.styleModule,Ko.datasetModule,Ko.attributesModule,Ko.propsModule]);function tu(n,t){const e=Ko.toVNode(n),r=Ko.toVNode(t);eI(e,r)}async function Fg(n,t){const e=new FileReader,r=new Promise((o,s)=>{e.onload=o,e.onerror=s});return e.readAsDataURL(new Blob([n],{type:t})),await r,e.result}async function fa(n){const t=new FileReader,e=new Promise((i,o)=>{t.onload=i,t.onerror=o});return t.readAsDataURL(n),await e,t.result}function nI(n,...t){const e=n.tagName.toLowerCase();for(let r=0,i=t.length;r<i;r++)if(e===t[r].toLowerCase())return!0;return!1}function En(n,t){let e=n;for(;e;){const r=window.getComputedStyle(e);if(t!=null&&t.horizontal){if(/auto|scroll/i.test(r.overflowX))break}else if(/auto|scroll/i.test(r.overflowY))break;e=e.parentElement}return(!e||nI(e,"body"))&&(e=document.documentElement),e}function Zb(n){n.preventDefault(),n.stopPropagation()}function tv(n){if(document.querySelector(`.editor-disable-scroll[data-scroll-id="${n}"]`))return;const t=B("div",["editor-disable-scroll"],null);t.setAttribute("data-scroll-id",n),t.addEventListener("wheel",Zb,{passive:!1}),document.body.appendChild(t)}function ev(n){const t=document.querySelector(`.editor-disable-scroll[data-scroll-id="${n}"]`);t&&(t.removeEventListener("wheel",Zb),t.remove())}function Kg(n,t,e){const r=new Blob([n]),i=new File([r],e,{type:t});return URL.createObjectURL(i)}function Nd(n){const t=document.createElement("template");if("content"in t)return t.innerHTML=n,document.importNode(t.content,!0);const e=document.createDocumentFragment(),r=document.createElement("div");for(r.innerHTML=n;r.firstChild;)e.appendChild(r.firstChild);return e}function nv(n){const t=document.createElement("div");return t.appendChild(n),t.innerHTML}function rv(n){let t=n.getPropertyValue("font");if(t)return t;const e=n.getPropertyValue("font-style"),r=n.getPropertyValue("font-variant"),i=n.getPropertyValue("font-weight"),o=n.getPropertyValue("font-size"),s=n.getPropertyValue("font-family");return t=`${e} ${r} ${i} ${o} ${s}`.replace(/ +/g," ").trim(),t}function Pd(n,t){const r=(Pd.canvas||(Pd.canvas=document.createElement("canvas"))).getContext("2d");return r?(typeof t=="string"?t?r.font=t:r.font=rv(window.getComputedStyle(document.body)):t instanceof Element&&(r.font=rv(window.getComputedStyle(t))),r.measureText(n).width+4):200}const rI=I("editor-clipboard");async function iI(n,t){if(t.clipboardData){const e=t.clipboardData;for(const r of n)e.setData(r.type,r.data);return!0}return!1}async function da(n){try{const t={};n.forEach(r=>{t[r.type]=r.data});const e=new ClipboardItem(t);return await navigator.clipboard.write([e]),!0}catch(t){return rI.error(t),!1}}function ha(n,t){return new Promise((e,r)=>{const i=document.createElement("input");i.type="file",i.style.display="none",t!=null&&t.multiple&&(i.multiple=!0),i.accept=n,i.onchange=()=>{const o=i.files;if(o){const s=t!=null&&t.multiple?Array.from(o):o[0];e(s)}i.remove()},i.onerror=o=>{r(o),i.remove()},i.click()})}function Fd(n){return Array.isArray(n)?n.every(t=>t instanceof File):!1}function eu(n){const t=n;if(!t)return"";const e=t.lastIndexOf(".");return e===-1?"":t.slice(e+1)}function Kd(n,t){const e=document.createElement("a");e.setAttribute("download",`${t||""}`),e.setAttribute("href",`${n}`),e.click(),e.remove()}const iv=I("auto-scroll");function ov(n,t){return!(n.scrollHeight===n.clientHeight||t==="top"&&n.scrollTop===0||t==="bottom"&&n.scrollTop+n.clientHeight===n.scrollHeight||t==="left"&&n.scrollLeft===0||t==="right"&&n.scrollLeft+n.clientWidth===n.scrollWidth)}function sv(n,{direction:t,step:e}){let r=null;const i=t==="left"||t==="right",o=()=>ov(n,t)?(i?t==="left"?n.scrollLeft=Math.max(n.scrollLeft-e,0):n.scrollLeft=Math.min(n.scrollLeft+e,n.scrollWidth):t==="top"?n.scrollTop=Math.max(n.scrollTop-e,0):n.scrollTop=Math.min(n.scrollTop+e,n.scrollHeight),r=requestAnimationFrame(o),r):(iv.debug("No need for scroll"),null);return r=requestAnimationFrame(o),()=>{r&&cancelAnimationFrame(r)}}class Vd{constructor(t){m(this,"cancelScroll",null);m(this,"options");m(this,"scrollDomInfo");m(this,"scrolling",!1);m(this,"getScrollingDirection",t=>{const{x:e,y:r}=t,{top:i,bottom:o,left:s,right:l}=this.scrollDomInfo,{edge:c}=this.options;return c.top&&r<=c.top+i?"top":c.bottom&&r>=o-c.bottom?"bottom":c.left&&e<=s+c.left?"left":c.right&&e>=l-c.right?"right":null});m(this,"handleMouseMove",t=>{var s;const{scrollElement:e,step:r=10,onDirectionChange:i}=this.options,o=this.getScrollingDirection(t);if(o){if(this.scrolling)return;iv.debug(`scroll direction: ${o}`),this.cancelScroll=sv(e,{direction:o,step:r}),i==null||i(o),this.scrolling=!0}else(s=this.cancelScroll)==null||s.call(this),this.scrolling=!1});this.options=t,this.scrollDomInfo=this.getScrollDomInfo()}getScrollDomInfo(){const{scrollElement:t}=this.options,e=t.getBoundingClientRect(),r=e.top,i=e.left,o=e.bottom,s=e.right;return{left:i,top:r,right:s,bottom:o}}active(){const{trackMouseEvent:t="mousemove"}=this.options;window.addEventListener(t,this.handleMouseMove,!0)}inactive(){var e;const{trackMouseEvent:t="mousemove"}=this.options;window.removeEventListener(t,this.handleMouseMove,!0),(e=this.cancelScroll)==null||e.call(this),this.scrolling=!1}}function lv(n,t){if(n===0)return"0 Bytes";const e=1024,r=t||2,i=["Bytes","KB","MB","GB","TB","PB","EB","ZB","YB"],o=Math.floor(Math.log(n)/Math.log(e));return`${parseFloat((n/e**o).toFixed(r))} ${i[o]}`}function nu(n,t){let e=`${n}`;const r=t-e.length;for(let i=0;i<r;i++)e=`0${e}`;return e}const{t:Fs}=D;function Vg(n,t){const e=new Date(n).getTime()+864e5*t;return new Date(e)}function oI(n,t){const e=n,r=Math.floor(t/12),i=t-r*12;return r&&e.setFullYear(e.getFullYear()+r),i&&e.setMonth(e.getMonth()+i),e}function sI(n,t){return Vg(n,t)}function $g(n,t){const e=new Date(n),r=new Date(t);return e.getDate()===r.getDate()&&e.getMonth()===r.getMonth()&&e.getFullYear()===r.getFullYear()}function av(n){const t=new Date,e=new Date(n);return $g(t,e)}function cv(n){const t=Vg(new Date,-1);return $g(t,n)}function lI(n,t){return Math.round((n.getTime()-t.getTime())/864e5)}function Hg(n,t){const e=new Date(n);if(t){const r=e.getFullYear(),i=e.getMonth()+1,o=e.getDate(),s=e.getHours(),l=e.getMinutes();let c=t;return c=c.replace("YYYY",`${r}`),c=c.replace("MM",nu(i,2)),c=c.replace("DD",nu(o,2)),c=c.replace("M",`${i}`),c=c.replace("D",`${o}`),c=c.replace("hh",nu(s,2)),c=c.replace("mm",nu(l,2)),c=c.replace("h",`${s}`),c=c.replace("m",`${l}`),c}return n.toLocaleDateString()}function jg(n,t){const e=new Date(n),r=new Date;if(e.getTime()-r.getTime()>10*1e3)return D.t("date.dateFromFuture");if(av(e)){const o=(r.getTime()-n.getTime())/1e3;if(o<10*60)return Fs("date.dateJustNow");if(o<60*60)return Fs("date.dateMinutesAgo",{num:`${Math.floor(o/60)}`});const s=Math.floor(o/60/60);return s===1?Fs("date.date1HourAgo"):Fs("date.dateHoursAgo",{num:`${s}`})}if(cv(n))return Fs("date.dateYesterday");const i=Math.floor((r.getTime()-n.getTime())/1e3/24/60/60)+1;return i<14?Fs("date.dateDaysAgo",{num:`${i}`}):i<28?Fs("date.dateWeeksAgo",{num:`${Math.round(i/7)}`}):Hg(n,t)}function zg(n){return n.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function aI(n,t,e){return n.replace(new RegExp(zg(t),"g"),e)}function cI(n,t,e){return n.replace(new RegExp(zg(t),"gi"),e)}function uv(n,t,e){const i=document.createElement("canvas").getContext("2d");if(!i)return null;if(i.font=String(t),i.measureText(n).width>e){let s=0,l=0;for(;l<e;)l=i.measureText(n.slice(0,s)).width,s++;return`${n.slice(0,s-2)}...`}return n}const fv=/[\u3040-\u30ff\u3400-\u4dbf\u4e00-\u9fff\uf900-\ufaff\uff66-\uff9f\uAC00-\uD7AF]/,dv=" -\x7F0-9!-/:-@[-`{-~\u0370-\u03FF\u0400-\u04FF",uI=new RegExp(`[${dv}]`),fI=new RegExp(`([^(${dv})])`,"g"),hv=/(\ud83c[\udf00-\udfff])|(\ud83d[\udc00-\ude4f\ude80-\udeff])|[\u2600-\u2B55]/;function mv(n){return n.length===0?0:n.split("").reduce((t,e)=>{const r=(t<<5)-t+e.charCodeAt(0);return r&r},0)}function dI(n,t=1){var r,i;return(i=((r=Array.from(n))==null?void 0:r.filter(o=>fv.test(o))).slice(-t))==null?void 0:i.join("")}function hI(n,t=1){var i;const e=Array.from((i=n==null?void 0:n.replace(fI,""))==null?void 0:i.split(/\s/));return e.reduce((o,s,l)=>{var c,d;return l===e.length-1&&o.length<t?`${o}${(c=s==null?void 0:s.slice(0,t-o.length))!=null?c:""}`:`${o}${(d=s[0])!=null?d:""}`},"").slice(0,t)}function mI(n,t=1){var r,i;return(i=((r=Array.from(n))==null?void 0:r.filter(o=>hv.test(o))).slice(-t))==null?void 0:i.join("")}function gI(n,t=1){var e,r;return(r=(e=Array.from(n))==null?void 0:e.slice(0,t))==null?void 0:r.join("")}function $d(n,t=1){if(!n||n.length===0)return"";const e=fv.test(n),r=uI.test(n),i=hv.test(n);switch(!0){case e:return dI(n,t);case r:return hI(n,t);case i:return mI(n,t);default:return gI(n,t)}}var gv=(n=>(n.blue="#0064FF",n.cyan="#34AFDE",n.teal="#2CB2AE",n.green="#24B47E",n.kelly="#8AAB3F",n.yellow="#F0A100",n.orange="#EB6414",n.red="#E52727",n.fuchsia="#BE507D",n.purple="#9678D3",n))(gv||{});function Hd(n){const t=Object.values(gv),e=Math.abs(typeof n=="string"&&n.trim()?mv(n.trim()):0)%t.length;return t[e]}const pv=I("element");function Gg(n,t,e){const r=B("div",[t],n);return r.setAttribute("data-type","editor-container"),r.setAttribute("data-container-id",e),B("div",["container-blocks"],r),r}function ui(n,t){const e=n.rootElement.querySelector(`[data-container-id=${t}]`);return p(pv,e,`no container: ${t}`),e}function jd(n,t){return n.rootElement.querySelector(`[data-container-id=${t}]`)}function ru(n){const t=n.querySelector(":scope > .container-blocks");return p(pv,t,"no container blocks element"),t}function pI(n){let t=n.querySelector(":scope > .container-tools");return t||(t=B("div",["container-tools"],n)),t}const Wg=I("container-children");function ue(n){const t=ru(n),e=Array.from(t.children);return p(Wg,e.length>0,"container have not any child block"),e}function we(n){const t=n.querySelector(":scope > .container-blocks > div[data-type=editor-block]");return p(Wg,t,"container have not any child block"),t}function Ze(n){const t=ue(n);return t[t.length-1]}function Lr(n){return ue(n).length}function zi(n,t){const e=ue(n)[t];return p(Wg,e,`container have not block at index ${t}`),e}function Cv(n,t){var e;return(e=ue(n)[t])!=null?e:null}class CI{constructor(t){m(this,"renders",[]);this.editor=t}registerRender(t){this.renders.push(t)}renderBox(t,e){const r={classes:[],attributes:{},styles:{}};return this.renders.forEach(i=>{if(i.renderBox){const o=i.renderBox(this.editor,t,e);o.classes&&r.classes.push(...o.classes),o.attributes&&(r.attributes={...r.attributes,...o.attributes}),o.styles&&(r.styles={...r.styles,...o.styles})}}),r}renderText(t,e){const r={classes:[],attributes:{},styles:{}};return this.renders.forEach(i=>{if(i.renderText){const o=i.renderText(this.editor,t,e);o.classes&&r.classes.push(...o.classes),o.attributes&&(r.attributes={...r.attributes,...o.attributes}),o.styles&&(r.styles={...r.styles,...o.styles})}}),r}renderBlock(t,e,r){const i={classes:[],attributes:{},styles:{}};return this.renders.forEach(o=>{if(o.renderBlock){const s=o.renderBlock(this.editor,e,r);s.classes&&i.classes.push(...s.classes),s.attributes&&(i.attributes={...i.attributes,...s.attributes}),s.styles&&(i.styles={...i.styles,...s.styles})}}),i}updateBlock(t,e,r,i){this.renders.forEach(o=>{var s;(s=o.updateBlock)==null||s.call(o,t,e,r,i)})}}const Ev=I("block-class");function Yt(n,t){return n.editorBlocks.getBlockClass(St(t))}function xv(n,t){const e=n.editorBlocks.getBlockClass(St(t));return p(Ev,e.blockKind==="text",`is not a text block, ${e.blockType}`),e}function Qn(n,t){const e=n.editorBlocks.getBlockClass(St(t));return p(Ev,e.blockKind==="complex",`is not a text block, ${e.blockType}`),e}function Ks(n,t){return n.editorBlocks.getBlockClass(t)}function nt(n,t){return Yt(n,t).blockKind==="text"}function iu(n,t){return n.editorBlocks.getBlockClass(t).blockKind==="text"}function Dt(n,t){return Yt(n,t).blockKind==="complex"}function EI(n,t){return!Dt(n,t)}function Ir(n,t){return Yt(n,t).blockKind}class Be extends Re.TypedEmitter{constructor(e){super();m(this,"hoveringBlock",null);m(this,"hoveringTextChild",null);m(this,"filters",[]);m(this,"finders",[]);m(this,"handleDocumentMouseMove",e=>{if(this.hoveringBlock){for(const s of this.filters)if(s.isInBlock(this.hoveringBlock,e))return}const r=document.elementFromPoint(e.x,e.y);if(!r){this.setHoveringBlock(null,e,null);return}let i=et(r);if((!i||!ne(this.editor.rootContainer,i))&&(i=this.findBlockByFinders(e),!i)){this.setHoveringBlock(null,e,null);return}const o=this.getParentTextContentChild(i,r);this.setHoveringBlock(i,e,o)});this.editor=e,document.addEventListener("mousemove",this.handleDocumentMouseMove)}destroy(){document.removeEventListener("mousemove",this.handleDocumentMouseMove),this.filters.forEach(e=>e.destroy()),this.filters=[],this.finders.forEach(e=>e.destroy()),this.finders=[]}addFilter(e){this.filters.push(e)}addFinder(e){this.finders.push(e)}hoveringBlockId(){return this.hoveringBlock?st(this.hoveringBlock):""}findBlockByFinders(e){for(let r=0;r<this.finders.length;r++){const o=this.finders[r].findTargetBlock(this.editor,e);if(o)return o}return null}setHoveringBlock(e,r,i){if(this.hoveringBlock===e&&this.hoveringTextChild===i)return;if(this.hoveringBlock!==e){const s=this.hoveringBlock&&ne(this.editor.rootContainer,this.hoveringBlock)?this.hoveringBlock:null;s&&ot(s,"hover"),e&&z(e,"hover"),this.hoveringBlock=e,this.emit("change",this.hoveringBlock,s,r)}const o=this.hoveringTextChild;this.hoveringTextChild=i,this.emit("childChange",this.hoveringBlock,i,o,r)}static get(e){return e.addCustom("standard-hovering-block",()=>new Be(e))}getParentTextContentChild(e,r){if(!nt(this.editor,e))return null;const i=Ot(e);return r.parentElement===i?r:qg(r)}}const Av="style-color-",bv="style-bg-color-";class vv{renderText(t,e,r){return this.generateCSSCustomProperties(r)}renderBlock(t,e,r){var l,c;const i={};Object.entries(r).filter(d=>d[0].startsWith("style-")).forEach(([d,h])=>{i[`data-${d}`]=`${h}`});const s=[];return((c=(l=t.selection)==null?void 0:l.range)==null?void 0:c.start.blockId)===r.id&&s.push("focused"),typeof r.align=="string"&&r.align&&(i["data-style-align"]=r.align),r.heading&&(i["data-style-heading"]=String(r.heading)),r.quoted&&(i["data-style-quoted"]="true"),Be.get(t).hoveringBlockId()===r.id&&s.push("hover"),{attributes:i,classes:s}}updateBlock(t,e,r,i){var s,l;Array.from(r.attributes).forEach(c=>{c.name.startsWith("data-style-")&&r.removeAttribute(c.name)}),Object.entries(i).filter(c=>c[0].startsWith("style-")||c[0]==="align").forEach(([c,d])=>{c==="align"&&r.setAttribute(c.startsWith("style-")?`data-${c}`:`data-style-${c}`,`${d}`)}),((l=(s=t.selection)==null?void 0:s.range)==null?void 0:l.start.blockId)===i.id&&z(r,"focused"),Be.get(t).hoveringBlockId()===i.id&&z(r,"hover")}generateCSSCustomProperties(t){const e=[],r={},i={};return Object.entries(t).forEach(([o,s])=>{s===!0?o.startsWith(Av)?r["data-style-color"]=o.substring(Av.length):o.startsWith(bv)?r["data-style-bg-color"]=o.substring(bv.length):o.startsWith("style")&&e.push(o):typeof s=="string"&&(o==="link"&&(e.push("link"),r.link=s),o==="inline-style-color"&&(i.color=s),o==="inline-style-background-color"&&(i.backgroundColor=s))}),{classes:e,attributes:r,styles:i}}}const Dr=I("block-dom");function Vs(n){return n instanceof HTMLDivElement?n.getAttribute("data-type")==="editor-block":!1}function Bv(n){return n instanceof HTMLElement&&n.getAttribute("data-type")==="block-tools"}function Tv(n){z(n,"block-hidden")}function yv(n){ot(n,"block-hidden")}function ou(n){return!Rt(n,"block-hidden")}function st(n){const{id:t}=n;return p(Dr,t,"no block id"),t}function St(n){const t=n.getAttribute("data-block-type");return p(Dr,t,"invalid block dom, no data-type"),t}function et(n){const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest("div[data-type=editor-block]");return e||null}function $s(n){const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest("div[data-type=editor-block]:not(:scope)");return e||null}function rt(n){const t=n.closest("div[data-type=editor-container]");return p(Dr,t,"failed to get block container"),t}function Ot(n){const t=n.querySelector(":scope >div[data-type=block-content]");return p(Dr,t,"no block content"),t}function re(n){let t=n.querySelector(":scope >div[data-type=block-tools]");return t||(t=B("div",[],n),t.setAttribute("data-type","block-tools")),p(Dr,t,"no block tools"),t}function zd(n){const t=n.querySelector(":scope >div[data-type=block-tools]");return t||null}function kv(n){let t=n.querySelector(":scope > div[data-type=block-background]");return t||(t=B("div",[],n),t.setAttribute("data-type","block-background")),t}function Rv(n,t,e){const r=n.editorDecorators.decorateBlock(t,e),{id:i,type:o}=r;p(Dr,i,"no block id");const s=B("div",[`${o}-block`],null);s.id=i,s.setAttribute("data-type","editor-block"),s.setAttribute("data-block-type",o);const l=n.editorBlockRenders.renderBlock(n,t,e);return l.classes&&z(s,...l.classes),l.attributes&&Object.entries(l.attributes).forEach(([c,d])=>{s.setAttribute(c,d)}),l.styles&&Object.entries(l.styles).forEach(([c,d])=>{s.style.setProperty(c,d)}),s}function Hs(n,t){const e=B(t,[],null);return e.setAttribute("data-type","block-content"),n&&n.appendChild(e),e}function wv(n){const t=B("span",[`${n.type}-box`],null);return t.setAttribute("data-type","editor-box"),t.setAttribute("data-box-type",n.type),t.id=n.id,t}function su(n){const t=n.getAttribute("data-box-type");return p(Dr,t,"not a valid box element, no type"),t}function Gd(n){return n instanceof HTMLSpanElement?n.getAttribute("data-type")==="editor-box":!1}function Sv(n){const{id:t}=n;return p(Dr,t,"no box id"),t}function qg(n){const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest("span[data-type=editor-box]");return e||null}function Lv(n){n.innerHTML="",B("span",["box-space-start"],n,Qc);const t=B("span",[],n);return t.setAttribute("data-type","box-content"),B("span",["box-space-start"],n,Qc),t}function lu(n){const t=n.querySelector("span[data-type=box-content]");return p(Dr,t,"invalid box dom, no content"),t}function Iv(n,t,e){const r=B("span",[`${n}-insertion`],null);if(r.setAttribute("data-type","editor-insertion"),r.setAttribute("data-insertion-id",t),e){const i=new vv,{attributes:o}=i.generateCSSCustomProperties(e);o&&[...Object.entries(o)].forEach(s=>{const[l,c]=s;r.setAttribute(l,c)})}return r}function Dv(n,t){return n.rootContainer.querySelector(`[data-insertion-id=${t}]`)}function _v(n){n.innerHTML="",B("span",["insertion-space-start"],n,Qc);const t=B("span",[],n);return t.setAttribute("data-type","insertion-content"),B("span",["insertion-space-start"],n,Qc),t}function Xg(n){const t=n.querySelector("span[data-type=insertion-content]");return p(Dr,t,"invalid insertion-child dom, no content"),t}function ge(n){let t=n.previousElementSibling;for(;t;){if(Vs(t))return t;t=t.nextElementSibling}return null}function qt(n){let t=n.nextElementSibling;for(;t;){if(Vs(t))return t;t=t.nextElementSibling}return null}function js(n){let t=n.previousElementSibling;for(;t;){if(Vs(t)&&ou(t))return t;t=t.previousElementSibling}return null}function zs(n){let t=n.nextElementSibling;for(;t;){if(Vs(t)&&ou(t))return t;t=t.nextElementSibling}return null}function bt(n){const t=rt(n),r=ue(t).indexOf(n);return p(Dr,r!==-1,"invalid block & container dom, failed to get block index"),r}function Qg(n){return!n||!(n instanceof Node)?!1:!!et(n)}function Gs(n){if(!Qg(n))return!1;const t=n,e=t instanceof Element?t:t.parentElement;return e?!!e.closest("div[data-type=block-tools]"):!1}function Gi(n){return n.hasAttribute("data-document-title")}function _r(n,t,e){return Yt(n,t).getCaretRect(t,e)}const Mv=I("container");function Wi(n){return n.getAttribute("data-type")==="editor-container"}function Xt(n){return Rt(n,"root")}function Mr(n){return Rt(n,"child")}function ft(n){const t=n.getAttribute("data-container-id");return p(Mv,t,"no id for container"),Xt(n)&&p(Mv,t==="root",`invalid root container id, : ${t}`),t}function Uv(n,t){const e=ft(n);return t.getContainerBlocks(e)}const Yg=I("block");function dt(n,t){return Yt(n,t).getBlockTextLength(t)}function Ov(n){n.editorBlocks.forEach(t=>{t.clearSelection(n)})}function Nv(n,t,e,r){Yt(n,t).updateSelection(n,t,e,r)}function Jg(n){for(;;){const t=rt(n);if(Xt(t))return n;const e=et(t);p(Yg,e,"no parent block exists for child container"),n=e}}function Pv(n,t){const e=Yt(n,t);if(!!e.getMinWidth)return e.getMinWidth(n,t)}function Fv(n,t,e){const r=Yt(n,t);r.handleBlockElementUpdated&&r.handleBlockElementUpdated(n,t,e)}function Wd(n,t,e,r){try{const i=Ks(n,e).convertFrom;return i?i(n,t,r):null}catch{return Yg.debug(`unsupported block type: ${e}`),null}}function qi(n,t,e){const r=Yt(n,t);return r.getClientRects?r.getClientRects(n,t,e):[t.getBoundingClientRect()]}function xI(n,t){const e=Yt(n,t);if(e.getBlockStyles)return e.getBlockStyles(n,t);const r=n.getBlockData(t),i=Object.fromEntries(Object.entries(r).filter(([o])=>o.startsWith("style-")));return Object.entries(i).forEach(([,o])=>{const s=typeof o;p(Yg,s==="string"||s==="number"||s==="boolean","invalid style value")}),i}function ie(n,t){return Ir(n,t)==="text"?dt(n,t)===0:!1}const Kv=I("block-path");function Vo(n){const t=[];let e=n;for(;e;){const r=rt(e);if(t.unshift({containerId:ft(r),blockIndex:bt(e)}),Xt(r))return t;const i=et(r);p(Kv,i,"no parent block"),e=i}return p(Kv,!1,"no parent block"),[]}function AI(n,t){var i,o;const e=Yt(n,t);return(o=(i=e.getOptions)==null?void 0:i.call(e,n))!=null?o:{name:St(t)}}function dr(n){return Xt(rt(n))}function Vv(n,t){var i;const e=Yt(n,t);return(i=e.getBlockProperties)==null?void 0:i.call(e,n,t)}function Zg(n,t){var o,s;const e=Yt(n,t),r=(o=e.getBlockProperties)==null?void 0:o.call(e,n,t);let i={};r!=null&&r.blockCommands&&(i={...r.blockCommands});for(const l of n.blockHooks){const c=(s=l.commands)==null?void 0:s.call(l,n,t);c&&(i[c.group]=c)}return i}function bI(n,t,e){var s,l,c,d;const r=Yt(n,t),i=(s=r.getBlockProperties)==null?void 0:s.call(r,n,t);let o={};i!=null&&i.blockCommands&&(o={...i.blockCommands});for(const h of n.blockHooks){const C=(l=h.commands)==null?void 0:l.call(h,n,t);C&&(o[C.group]=C)}return(d=(c=o[e])==null?void 0:c.commands)!=null?d:[]}function $v(n,t,e){let r=t;for(;r;){const i=bI(n,r,e);if(i.length>0)return{element:Ot(r),commands:i};if(dr(r))break;r=$s(r)}return{element:null,commands:[]}}const Hv=I("embed-block-common");function pe(n){return St(n)==="embed"}function Ge(n){p(Hv,pe(n),"not an embed block");const t=n.getAttribute("data-embed-type");return p(Hv,t,"no embed data type"),t}function vI(n,t){return n.editorEmbeds.getEmbedClass(Ge(t))}function Ws(n,t){return n.editorEmbeds.getEmbedClass(t)}async function t1(n,t,e,r,i){const o=Ws(n,t);if(!o.getOptions)return null;const s=o.getOptions(n);if(!s.insertEmbedCommandItems||!s.insertEmbedCommandItems||s.insertEmbedCommandItems.length===0||!s.handleInsertEmptyEmbed)return null;const l=s.insertEmbedCommandItems[0];return s.handleInsertEmptyEmbed(n,{item:l,containerId:e,blockIndex:r,data:i})}function BI(n,t,e,r,i){var l,c;const o=(c=(l=Ks(n,t)).getOptions)==null?void 0:c.call(l,n);if(!o||!o.insertBlockCommandItems||o.insertBlockCommandItems.length===0||!o.handleInsertEmptyBlock)return null;const s=o.insertBlockCommandItems[0];return o.handleInsertEmptyBlock(n,{item:s,containerId:e,blockIndex:r,data:i})}const TI=I("execute-block-command");function jv(n,t,e,r){var d;p(TI,pe(t),"not a embed block");const i=Ge(t),o=Ws(n,i);if(!o.getOptions)return;const s=(d=o.getBlockProperties)==null?void 0:d.call(o,n,t),l=s==null?void 0:s.blockCommands;if(!l)return;const c=Object.entries(l);for(const h of c)if(h[0]===e)return h[1].executeCommand(n,t,r)}function zv(n,t,e,r){const i=Zg(n,t);if(!i)return;const o=Object.entries(i);for(const s of o)if(s[0]===e)return s[1].executeCommand(n,t,r)}const Xi=I("text-block-child");function au(n){return n.tagName==="SPAN"}function hr(n){return p(Xi,au(n),"not a valid text child"),n.getAttribute("data-type")==="editor-box"}function Qi(n){return p(Xi,au(n),"not a valid text child"),n.getAttribute("data-type")==="editor-insertion"}function cu(n){return!hr(n)&&!Qi(n)}function Gv(n){return p(Xi,au(n),"not a valid text child"),hr(n)?"box":Qi(n)?"insertion":"text"}function mr(n){const t=Gv(n);return t==="insertion"?0:t==="box"?1:(p(Xi,n.textContent!==null,"text block content is undefined"),p(Xi,n.textContent.length>=0,"text block content length is negative"),n.textContent.length)}function fi(n){const t=Ot(n),e=Array.from(t.children);return e.forEach(r=>{p(Xi,au(r),"not a valid text child")}),e}function qd(n,t){const e=fi(n);let r=0;for(let i=0;i<e.length;i++){const o=e[i],s=mr(o);if(r+s<t){r+=s;continue}if(r===t)return{prev:e[i-1],next:o,offset:0};if(r+s===t)return{prev:o,next:e[i+1],offset:0};const l=t-r;return p(Xi,l>0,"invalid offset value"),p(Xi,!hr(o),"invalid box child"),{prev:o,next:o,offset:l}}p(Xi,!1,`invalid block child at position: ${t}`)}const yI=I("child-container-path");function Wv(n){if(Xt(n))return[];const t=et(n);return p(yI,t,"no parent block"),Vo(t)}const qv=I("load-blocks");function e1(n,t,e){const r=ft(t),i=Uv(t,n.doc);p(qv,i.length>0,"no blocks in container");const o=document.createDocumentFragment();i.forEach((l,c)=>{const d=n.editorBlocks.createBlock([...e,{containerId:r,blockIndex:c}],t,l);o.appendChild(d)}),ru(t).appendChild(o)}function kI(n,t,e){const r=ru(n);if(t===0)return r.insertBefore(e,r.firstChild),e;const i=ue(n);return p(qv,t>=0&&t<=i.length,"invalid block index"),t===i.length?r.appendChild(e):r.insertBefore(e,i[t]),e}function RI(n,t,e,r){const i=Wv(t);i.push({containerId:ft(t),blockIndex:e});const o=n.editorBlocks.createBlock(i,t,r);return kI(t,e,o),o}const Xv=I("root-container");class wI{constructor(t,e){m(this,"resizeObserver");m(this,"isMoved",!1);m(this,"handleContextMenu",t=>{if(me.isSafari){const e=document.getSelection();e&&!e.isCollapsed&&e.collapseToStart()}});m(this,"handleResize",()=>{try{this.editor.selection.updateSelection(null),this.editor.emit("resize",this.editor)}catch(t){Xv.warn(`failed to update selection while container resizing: ${t.message}`)}});m(this,"handleClick",t=>{this.editor.emit("click",this.editor,t);const e=t.target;if(!Gs(e)&&(t.detail===1&&this.editor.input.focus(),t.detail===3&&this.editor.selectionHandler.handleTripleClick(t),t.detail===1&&t.button===0)){const r=document.elementFromPoint(t.clientX,t.clientY);if(r&&ne(this.rootContainer,r)){const i=et(r);i&&ne(i,r)&&this.handleBlockClick(t,i,r)}}});m(this,"handleBlockClick",(t,e,r)=>{var s,l;if(!nt(this.editor,e))return;const i=qg(r);if(i){const c=et(i);p(Xv,c,"no parent block"),(l=(s=this.editor.editorBoxes.getBoxClass(su(i)))==null?void 0:s.handleClickBox)==null||l.call(s,this.editor,i,t);return}const o=r.closest("span.text.link");o&&fi(e).indexOf(o)!==-1&&this.editor.emit("clickLink",this.editor,t,o)});m(this,"handleDblClick",t=>{Gs(t.target)||this.editor.selectionHandler.handleDblClick(t)});m(this,"handleMouseDown",t=>{this.isMoved=!1;const e=t.target;if(!!e&&e instanceof Node&&!Gs(e)){if(e instanceof HTMLElement&&e.draggable){this.editor.selectionHandler.handleMouseDown(t,{autoScroll:!1}),this.editor.selectionHandler.stopSelection(),this.editor.input.focus();return}t.button===0&&(document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp),this.editor.selectionHandler.handleMouseDown(t,{autoScroll:!0})),me.isMobileSafari||this.editor.input.focus(),t.button===2&&t.stopPropagation()}});m(this,"handleMouseMove",t=>{this.editor.selectionHandler.handleMouseMove(t),this.isMoved=!0});m(this,"handleMouseUp",t=>{t.button===0&&(this.editor.selectionHandler.handleMouseUp(t),document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)),this.isMoved&&(document.addEventListener("click",this.handleCaptureClick,!0),document.addEventListener("dblclick",this.handleCaptureDbClick,!0)),this.isMoved=!1});m(this,"handleCaptureClick",t=>{document.removeEventListener("click",this.handleCaptureClick,!0),t.stopPropagation()});m(this,"handleCaptureDbClick",t=>{document.removeEventListener("dblclick",this.handleCaptureDbClick,!0),t.stopPropagation()});this.editor=t,this.rootContainer=e,this.editor=t,this.resizeObserver=new _s(this.handleResize),this.bindEvents(e)}bindEvents(t){this.resizeObserver.observe(t);const e=this.editor.rootElement;e.onmousedown=this.handleMouseDown,e.ondblclick=this.handleDblClick,e.onclick=this.handleClick,e.oncontextmenu=this.handleContextMenu}unbindEvents(){this.resizeObserver.disconnect();const t=this.editor.rootElement;t.onmousedown=null,t.ondblclick=null,t.onclick=null,t.oncontextmenu=null}destroy(){this.unbindEvents()}reload(){const t=this.editor.selection.range,e=ru(this.rootContainer);e.innerHTML="",e1(this.editor,this.rootContainer,[]);const r=this.editor.findBlockById(t.start.blockId);if(r)this.editor.selection.selectBlock(r,0);else{const i=we(this.rootContainer);this.editor.selection.selectBlock(i,0)}}}function Qv(n){const t=Gg(n.contentElement,"root","root");return n.rootContainer=t,e1(n,t,[]),new wI(n,t)}function Yv(n,t,e,r){const i=jd(n,r);if(i)return e.appendChild(i),setTimeout(()=>{n.emit("containerRemount",n,r)}),i;const o=Gg(e,"child",r);return e1(n,o,t),o}function Jv(n,t){const e=n.getBoundingClientRect().width;return t.withPadding?e:e-Sg(n)}function n1(n,t){let e=Number.MAX_SAFE_INTEGER;const r=ue(t);for(let o=0;o<r.length;o++){const s=r[o],l=Pv(n,s);l&&(e=Math.min(e,l))}return e===Number.MAX_SAFE_INTEGER?void 0:e+Sg(t)}function uu(n,t){const e=ue(t);return e.length!==1?!1:ie(n,e[0])}const SI=I("complex-block-position");class Ur{constructor(t,e,r){m(this,"blockId");m(this,"childContainerId");m(this,"custom");t instanceof HTMLElement?this.blockId=st(t):(p(SI,typeof t=="string",`not a valid block id: ${t}`),this.blockId=t),this.childContainerId=e,r!==void 0&&(this.custom=r)}isSimple(){return!1}}const LI=I("simple-block-position");class We{constructor(t,e,r){m(this,"blockId");m(this,"offset");m(this,"type");t instanceof HTMLElement?this.blockId=st(t):(p(LI,typeof t=="string",`not a valid block id: ${t}`),this.blockId=t),this.offset=e,this.type=r}isSimple(){return!0}}const r1=I("editor-position");function lt(n,t,e){return new We(n,t,e)}function xe(n,t,e){return new Ur(n,t,e)}function Or(n){return n instanceof We}function ma(n){return n instanceof Ur}function i1(n,t,e){if(Or(t)&&Or(e)){const r=t,i=e;if(r.blockId===i.blockId)return r.offset-i.offset;const o=n.getBlockById(t.blockId),s=n.getBlockById(e.blockId);return p(r1,o!==s,"comparePosition: blocks are the same"),_d(o,s)}if(ma(t)&&ma(e)){const r=t,i=e;if(r.childContainerId===i.childContainerId)return 0;const o=n.getContainerById(r.childContainerId),s=n.getContainerById(i.childContainerId);return p(r1,o!==s,"comparePosition: containers are the same"),_d(o,s)}return p(r1,!1,"invalid "),0}const Xd=I("simple-range");class tn{constructor(t,e){m(this,"editor");m(this,"_anchor");m(this,"_focus");m(this,"reverse");this.editor=t,this._anchor=e.anchor,this._focus=e.focus,this.reverse=i1(this.editor,this._anchor,this._focus)>0}isCollapsed(){return this.start.blockId===this.end.blockId&&this.start.offset===this.end.offset}isEqual(t){if(!(t instanceof tn))return!1;const e=t,{start:r,end:i}=e;return this.start.blockId===r.blockId&&this.start.offset===r.offset&&this.start.type===r.type&&this.end.blockId===i.blockId&&this.end.offset===i.offset&&this.end.type===i.type}isSimple(){return!0}isReverse(){return this.reverse}getEditor(){return this.editor}get start(){return this.reverse?this._focus:this._anchor}get end(){return this.reverse?this._anchor:this._focus}get anchor(){return this._anchor}get focus(){return this._focus}getSelectedBlocks(){const{editor:t}=this,e=t.getBlockById(this.start.blockId),r=t.getBlockById(this.end.blockId);p(Xd,e,"no start block"),p(Xd,r,"no end block");const i=rt(e),o=rt(r);p(Xd,i===o,"invalid range");const s=[];if(e===r)s.push({block:e,start:this.start,end:this.end});else{const l=bt(e),c=bt(r);p(Xd,l<c,"invalid range, start > index"),s.push({block:e,start:this.start,end:lt(e,dt(this.editor,e),"end")});const d=ue(i);for(let h=l+1;h<c;h+=1){const C=d[h];s.push({block:C,start:lt(C,0,"home"),end:lt(C,dt(this.editor,C),"end")})}s.push({block:r,start:lt(r,0,"home"),end:this.end})}return s}getSelectedContainers(){return[]}getAnchorPos(){return this.isReverse()?this.end:this.start}getFocusedPos(){return this.isReverse()?this.start:this.end}clone(){return new tn(this.editor,this)}toDocRange(){return{anchor:this.anchor,focus:this.focus}}static from(t,e){return new tn(t,e)}}I("unknown-block");function II(n,t,e,r,i){z(r,"unknown-block");const o=Hs(r,"div");return o.innerText=`unknown block (${i.type}): ${JSON.stringify(i)}`,o}function DI(n){return 1}function _I(n,t,e,r){return null}function MI(n,t,e,r){const i=document.elementsFromPoint(e,r)[0];if(!i||!t.contains(i)||!n.contains(t))return null;const o=st(t),s=lt(o,0,"home"),l=lt(o,1,"end");return new tn(n,{anchor:s,focus:l})}function UI(n,t){const r=Ot(n).getBoundingClientRect();return new DOMRect(r.left+r.width/2,r.top,1,r.height)}function OI(n,t,e,r){z(t,"selected")}function NI(n){n.rootContainer.querySelectorAll("div.unknown-block[data-type=editor-block]").forEach(t=>{ot(t,"selected")})}function PI(n,t,e,r){return`[unknown block, ${t.type}]`}const FI={blockType:"unknown-block",blockKind:"embed",createBlockContent:II,getBlockTextLength:DI,getRangeFromPoint:MI,moveCaret:_I,getCaretRect:UI,updateSelection:OI,clearSelection:NI,convertTo:PI},o1=I("editor-blocks");class Zv{constructor(t){m(this,"blocks",new Map);this.editor=t}registerBlockClass(t){const e=t.blockType,r=this.blocks.get(e);p(o1,!r,`duplicated block type: ${e}`),this.blocks.set(e,t)}getBlockClass(t){const e=this.blocks.get(t);return p(o1,e,`unknown block type: ${t}`),e}hasBlock(t){return this.blocks.has(t)}createBlock(t,e,r){const i=Rv(this.editor,t,r);let o;this.hasBlock(r.type)?o=this.getBlockClass(r.type):o=this.registerUnknownBlock(r.type);const s=o.createBlockContent(this.editor,t,e,i,r);return s.parentElement!==i&&(o1.warn("content parent is not block"),i.appendChild(s)),this.editor.blockHooks.forEach(l=>{var c;(c=l.create)==null||c.call(l,this.editor,t,e,i,r)}),i}forEach(t){this.blocks.forEach(t)}registerUnknownBlock(t){const e={...FI,blockType:t};return this.editor.editorBlocks.registerBlockClass(e),e}}const t3=I("editor-embeds");class e3{constructor(t){m(this,"objects",new Map);this.editor=t}registerEmbedClass(t){const e=t.embedType,r=this.objects.get(e);p(t3,!r,`duplicated embed object type: ${e}`),this.objects.set(e,t)}getEmbedClass(t){const e=this.objects.get(t);return p(t3,e,`unknown embed type: ${t}`),e}getEmbedClassFromBlock(t){return this.getEmbedClass(Ge(t))}forEach(t){this.objects.forEach(t)}}const n3=I("embed-block");function KI(n,t,e,r,i){const o=Hs(r,"div");p(n3,i.type==="embed",`not an embed data: ${JSON.stringify(i)}`);const s=i;return p(n3,s.embedType&&s.embedData,`not an embed data: ${JSON.stringify(s)}`),n.editorEmbeds.getEmbedClass(s.embedType).createEmbedContent(n,o,s,t,e,r),r.setAttribute("data-embed-type",s.embedType),o}function VI(n){return 1}function $I(n,t,e,r){return null}function HI(n,t,e,r){const i=document.elementsFromPoint(e,r)[0];if(!i||!t.contains(i)||!n.contains(t))return null;const o=st(t),s=lt(o,0,"home"),l=lt(o,1,"end");return new tn(n,{anchor:s,focus:l})}function jI(n,t){const r=Ot(n).getBoundingClientRect();return new DOMRect(r.left+r.width/2,r.top,1,r.height)}function zI(n,t,e,r){z(t,"selected")}function GI(n){n.rootContainer.querySelectorAll("div.embed-block[data-type=editor-block][data-block-type=embed]").forEach(t=>{ot(t,"selected")})}function WI(n,t,e){let r=null;return n.editorEmbeds.forEach(i=>{var s,l;const o=(l=(s=i.convertFrom)==null?void 0:s.call(i,n,t,e))!=null?l:null;o&&(r=o)}),r}function qI(n,t,e,r){const i=Ws(n,t.embedType);return i.convertTo?i.convertTo(n,t,e,r):""}function XI(n,t){const e=vI(n,t);return e.getBlockProperties?e.getBlockProperties(n,t):{}}function QI(n){const t=new Map,e=[];return n.editorEmbeds.forEach(r=>{if(r.getOptions){const i=r.getOptions(n);i.insertEmbedCommandItems&&i.insertEmbedCommandItems.forEach(o=>{e.push(o),t.set(o.id,r)})}}),{name:"EmbedBlock",insertBlockCommandItems:e,async handleInsertEmptyBlock(r,i){const o=t.get(i.item.id);if(!o||!o.getOptions)return null;const s=o.getOptions(r);return s.handleInsertEmptyEmbed?s.handleInsertEmptyEmbed(r,i):null}}}function YI(n,t,e,r){const i=Ge(t),o=Ws(n,i);!o.handleDeleteBlock||o.handleDeleteBlock(n,t,e,r)}function JI(n,t,e){const r=Ge(t),i=Ws(n,r);return i.handleUpdateBlock?i.handleUpdateBlock(n,t,e):!1}function ZI(n,t,e,r,i){const o=Ge(t),s=Ws(n,o);if(s.handleDropOver)return s.handleDropOver(n,t,e,r,i)}function t7(n,t,e,r,i){const o=Ge(t),s=Ws(n,o);if(s.handleDrop&&n.isWritable())return s.handleDrop(n,t,e,r,i)}async function e7(n,t,e){const r=t.embedType,i=n.editorEmbeds.getEmbedClass(r);if(i.toStandardDoc){const o=n.getBlockById(t.id),s=Vo(o);return i.toStandardDoc(n,t,e,s)}}function n7(n,t){const e=t.embedType,r=n.editorEmbeds.getEmbedClass(e);return r.getResources?r.getResources(n,t):null}const r3={blockType:"embed",blockKind:"embed",createBlockContent:KI,getBlockTextLength:VI,getRangeFromPoint:HI,moveCaret:$I,getCaretRect:jI,updateSelection:zI,clearSelection:GI,convertFrom:WI,convertTo:qI,getBlockProperties:XI,getOptions:QI,handleDeleteBlock:YI,handleUpdateBlock:JI,handleDropOver:ZI,handleDrop:t7,toStandardDoc:e7,getResources:n7},xn=I("complex-block-helper");function An(n,t,e){return Qn(n,t).getChildContainers(n,t,e)}function ga(n,t,e,r){return e.isSimple()?(p(xn,r.isSimple(),"invalid start and end position"),An(n,t)):(p(xn,!e.isSimple(),"invalid start pos"),p(xn,!r.isSimple(),"invalid end pos"),Qn(n,t).getSelectedContainers(n,t,e,r))}function r7(n,t){if(bt(t)!==0)return!1;const e=et(rt(t));if(!e)return!1;p(xn,Dt(n,e),"not a complex block");const r=rt(t),o=An(n,e).indexOf(r);return p(xn,o>=0,"not valid child container"),o===0}function s1(n,t,e){const r=An(n,t,e);if(r.length===0)return null;const i=r[0];if(!i)return null;const o=we(i);return Dt(n,o)?s1(n,o,e):o}function pa(n,t,e){const r=An(n,t,e);if(r.length===0)return null;const i=r[r.length-1];if(!i)return null;const o=Ze(i);return Dt(n,o)?pa(n,o,e):o}function i3(n,t){p(xn,Mr(t),"not a child container");const e=et(t);p(xn,e,"no parent block"),p(xn,Dt(n,e),"not a complex block");const r=An(n,e),i=r.indexOf(t);if(p(xn,i!==-1,"child container not found"),i===0){const l=ge(e);return l?Dt(n,l)?pa(n,l):l:null}const o=r[i-1],s=Ze(o);return Dt(n,s)?pa(n,s):s}function o3(n,t){p(xn,Dt(n,t),"not a complex block");const e=An(n,t);if(p(xn,e.length>0,"no child container"),e.length===1)return e;const r=e[0],i=r.getBoundingClientRect();let o=i.left,s=i.right;const l=[r];for(let c=1;c<e.length;c++){const d=e[c],h=d.getBoundingClientRect();if(h.right<=o){l.push(d),o=h.left;continue}if(h.left>=s){s=h.right;continue}}return l}function s3(n,t){p(xn,Dt(n,t),"not a complex block");const e=An(n,t);if(p(xn,e.length>0,"no child container"),e.length===1)return e;const r=e[e.length-1],i=r.getBoundingClientRect();let o=i.left,s=i.right;const l=[r];for(let c=e.length-2;c>=0;c--){const d=e[c],h=d.getBoundingClientRect();if(h.right<=o){l.push(d),o=h.left;continue}if(h.left>=s){s=h.right;continue}}return l}function l3(n,t,e,r){const i=t.getBoundingClientRect(),o=r<i.top,s=o?o3(n,t):s3(n,t);let l=s[0],c=$i(l.getBoundingClientRect(),e,r);for(let d=1;d<s.length;d++){const h=s[d],C=h.getBoundingClientRect(),E=$i(C,e,r);E<c&&(l=h,c=E)}return o?we(l):Ze(l)}function Qd(n,t,e,r){const i=st(t);p(xn,i===e.blockId,"invalid start pos"),p(xn,i===r.blockId,"invalid end pos");const o=Qn(n,t);return o.adjustSelectionPos?o.adjustSelectionPos(n,t,e,r):{anchor:e,focus:r}}class di{constructor(t,e){m(this,"editor");m(this,"reverse");m(this,"_anchor");m(this,"_focus");this.editor=t,this._anchor=e.anchor,this._focus=e.focus,this.reverse=i1(this.editor,this._anchor,this._focus)>0}isCollapsed(){return!1}isEqual(t){if(!(t instanceof di))return!1;const e=t,{anchor:r,focus:i}=e;return this._anchor.blockId===r.blockId&&this._anchor.childContainerId===r.childContainerId&&this._focus.blockId===i.blockId&&this._focus.childContainerId===i.childContainerId&&this._anchor.custom===r.custom&&this._focus.custom===i.custom}isReverse(){return this.reverse}isSimple(){return!1}getEditor(){return this.editor}get anchor(){return this._anchor}get focus(){return this._focus}get start(){return this.reverse?this._focus:this._anchor}get end(){return this.reverse?this._anchor:this._focus}getSelectedBlocks(){const t=this.start,e=this.end;return[{block:this.editor.getBlockById(t.blockId),start:t,end:e}]}getAnchorPos(){return this._anchor}getFocusedPos(){return this._focus}getSelectedContainers(){const t=this.editor.getBlockById(this._anchor.blockId);return ga(this.editor,t,this.start,this.end)}clone(){return new di(this.editor,this)}toDocRange(){return{anchor:this._anchor,focus:this._focus}}}const i7=I("selection-range");function qe(n,t){const{anchor:e,focus:r}=t;return e instanceof We&&r instanceof We?new tn(n,{anchor:e,focus:r}):(p(i7,e instanceof Ur&&r instanceof Ur,"start position type does not math end type"),new di(n,{anchor:e,focus:r}))}function Te(n,t,e,r){const i=new We(t,e,"normal"),o=new We(t,r!=null?r:e,"normal");return qe(n,{anchor:i,focus:o})}function o7(n){return!!n.anchor.childContainerId}function $o(n,t){var i,o;if(o7(t)){const s=xe(t.anchor.blockId,t.anchor.childContainerId,(i=t.anchor)==null?void 0:i.custom),l=xe(t.focus.blockId,t.focus.childContainerId,(o=t.focus)==null?void 0:o.custom);return qe(n,{anchor:s,focus:l})}const e=lt(t.anchor.blockId,t.anchor.offset,"normal"),r=lt(t.focus.blockId,t.focus.offset,"normal");return qe(n,{anchor:e,focus:r})}const a3=I("range-from-point");function Yd(n,t,e){const r=[0,-12,12];let i=t;const o=e;let s=document.elementsFromPoint(i,o)[0],l=et(s);if(!l&&n.contentElement.contains(s)){const c=n.rootContainer.getBoundingClientRect(),d=c.left+c.width/2;s=document.elementsFromPoint(d,o)[0],l=et(s);let h=c;l&&(h=l.getBoundingClientRect()),t<h.left?i=h.left:t>h.right&&(i=h.right-5)}for(let c=0;c<r.length;c++){const d=document.elementsFromPoint(i,o+r[c])[0];if(!d)continue;const h=d.getBoundingClientRect();if(d.clientWidth&&d.clientHeight&&c===0&&(h.left+d.clientWidth<i||h.top+d.clientHeight<o))return a3.debug("click on scrollbar, out of element rect"),null;if(c===0&&!n.rootContainer.contains(d)&&(i=n.rootContainer.getBoundingClientRect().left),!n.rootContainer.contains(d))continue;const C=et(d);if(!C||!n.contains(C))continue;const E=Yt(n,C).getRangeFromPoint(n,C,i,o+r[c]);if(E)return E}return null}function c3(n,t,e,r){const i=t.getBoundingClientRect();if(r<=i.top){const c=we(t),d=Yt(n,c).getRangeFromPoint(n,c,e,c.getBoundingClientRect().top+4);if(d!=null&&d.isSimple())return tn.from(n,d);const h=lt(c,0,"home");return new tn(n,{anchor:h,focus:h})}const o=Ze(t),s=Yt(n,o).getRangeFromPoint(n,o,e,o.getBoundingClientRect().bottom-4);if(s!=null&&s.isSimple())return tn.from(n,s);if(Dt(n,o))return null;const l=lt(o,dt(n,o),"end");return new tn(n,{anchor:l,focus:l})}function l1(n,t,e){const r=Yd(n,t,e);if(r){if(r instanceof tn)return r;p(a3,r instanceof di,`invalid range type: ${typeof r}`);const c=r,d=n.getContainerById(c.start.childContainerId);return c3(n,d,t,e)}const i=document.elementsFromPoint(t,e)[0];if(!i)return null;const{children:o}=i,s=Array.from(o).filter(c=>Wi(c));if(s.length===0)return null;const l=s.reduce((c,d)=>{const h=c.getBoundingClientRect(),C=d.getBoundingClientRect();return $i(h,t,e)>$i(C,t,e)?d:c});return c3(n,l,t,e)}function a1(n,t){const e=[];return ue(t).forEach(i=>{e.push(i),Dt(n,i)&&An(n,i).forEach(s=>{e.push(...a1(n,s))})}),e}function c1(n,t){let e=a1(n,n.rootContainer);return t!=null&&t.simpleBlockOnly&&(e=e.filter(r=>!Dt(n,r))),e}function hi(n,t){const e=n.selection.range.getSelectedBlocks(),r=[];for(const i of e)r.push(i),Dt(n,i.block)&&ga(n,i.block,i.start,i.end).forEach(s=>{const c=a1(n,s).map(d=>({block:d,start:lt(d,0,"home"),end:lt(d,dt(n,d),"home")}));r.push(...c)});return t!=null&&t.simpleBlockOnly?r.filter(i=>!Dt(n,i.block)):r}const oct="",en=I("text-range");function s7(n,t){const e=(o,s)=>{if(Qi(o))return p(en,s===0,`invalid offset for insertion child: ${s}`),{child:o,container:o,offset:2};if(hr(o))return p(en,s===0||s===1,`invalid offset for box: ${s}`),{child:o,container:o,offset:s===0?1:2};const l=o.firstChild;return p(en,l,"no child node for text child"),p(en,l instanceof Text||l instanceof HTMLBRElement,`invalid child for text child, ${l.nodeName}`),l instanceof HTMLBRElement?(p(en,s>=0&&s<=0,"invalid offset for text child"),{child:o,container:l,offset:s}):(p(en,s>=0&&s<=l.data.length,"invalid offset for text child"),{child:o,container:l,offset:s})};let r=0;const i=fi(n);for(let o=0;o<i.length;o++){const s=i[o],l=mr(s);if(t===r)return[e(s,0)];if(t<r+l)return[e(s,t-r)];if(t===r+l){const c=[];c.push(e(s,mr(s)));const d=i[o+1];return d&&c.push(e(d,0)),c}r+=l}p(en,!1,"failed to get range info")}function l7(n,t,e){if(t===e?p(en,Qi(n),"only insertion child can be zero offset"):p(en,t<e,`invalid start & end: ${t}, ${e}`),Qi(n)){p(en,t===e,`invalid insertion child range offset: ${t}, ${e}`),p(en,t===0,`invalid insertion child range start: ${t}`);const o=n;return p(en,o.children.length===3,`invalid insertion dom, children.length = ${o.children.length}`),Id(o,1,o,2)}if(hr(n)){p(en,t+1===e,`invalid box child range offset: ${t}, ${e}`),p(en,t===0,`invalid box child range start: ${t}`);const o=n;return p(en,o.children.length===3,`invalid box dom, children.length = ${o.children.length}`),Id(o,1,o,2)}const r=mr(n);p(en,e<=r,`invalid child end: ${e}, ${r}`);const i=n.firstChild;return p(en,i instanceof Text,"invalid block text child"),p(en,i.data.length>=e,`invalid range end: ${e}, ${i.data.length}`),Id(i,t,i,e)}const Nr=I("caret-rect");function a7(n,t){if(Gd(t)){const e=t,r=lu(e);if(e.getAttribute("data-box-type")==="br"){const i=Ot(n),o=Number.parseFloat(window.getComputedStyle(i).lineHeight)||r.getBoundingClientRect().height,s=Array.from(r.getClientRects());p(Nr,s.length>0,"no box client rects");const l=i.getBoundingClientRect(),c=s[0],d=new DOMRect(l.left,c.bottom,1,o);return s.push(d),s}return r.getClientRects()}return Xg(t).getClientRects()}function Yn(n,t){var l,c,d;const e=s7(n,t.offset);if(e[1]&&e[0].child!==((l=e[1])==null?void 0:l.child)){if(t.type==="end"){const C=Us(e[0].child);return new DOMRect(C.right,C.top,1,C.height)}p(Nr,e[1],"invalid ranges");const h=Dd(e[1].child);return new DOMRect(h.left,h.top,1,h.height)}let i=e[0];if(p(Nr,e.length>=1,"failed to get block range"),e.length===1)i=e[0];else{if(p(Nr,e.length>=2,`invalid range info length: ${e.length}`),Qi(e[e.length-1].child)){i=e[e.length-1];const h=i.child,E=Xg(h).getClientRects();p(Nr,E.length>=1,"no client rects for box content");const A=E[E.length-1];return new DOMRect(A.right,A.y,1,A.height)}t.type==="home"?i=e[1]:t.type==="end"||cu(e[0].child)?i=e[0]:cu(e[1].child)&&(i=e[1])}if(i.container instanceof HTMLBRElement){p(Nr,t.offset===0,"invalid offset for empty block text");const h=i.container.parentElement;p(Nr,h,"invalid br parent");const C=h.getBoundingClientRect();return new DOMRect(C.left,C.top,1,C.height)}const o=_b(i.container,i.offset),s=Array.from(o.getClientRects());if(s.length===0){p(Nr,!cu(i.child),"only box or insertion child range has zero client rect"),p(Nr,i.offset===1||i.offset===2,"invalid offset for box or insertion child");const h=i.child,C=a7(n,h);if(p(Nr,C.length>=1,"no client rects for box content"),i.offset===1){const A=C[0];return new DOMRect(A.x,A.y,1,A.height)}const E=C[C.length-1];if(t.type==="end"||i.offset===2){if(Gd(h)&&h.getAttribute("data-box-type")==="br"){const A=h.lastChild.getBoundingClientRect();return new DOMRect(E.right,A.top,1,A.height)}return new DOMRect(E.right,E.y,1,E.height)}return new DOMRect(E.x,E.y,1,E.height)}if(Jc()||ua()){const h=document.createRange();h.selectNodeContents(i.container);const C=h.getClientRects();if(i.container.nodeType===Node.TEXT_NODE&&i.offset<((d=(c=i.container.textContent)==null?void 0:c.length)!=null?d:0)){const E=document.createRange();E.setStart(i.container,i.offset+1);const A=E.getClientRects();Array.from(C).forEach((v,R)=>{if(Math.floor(A[0].top)!==Math.floor(s[0].top)&&Math.floor(A[0].top)===Math.floor(v.top)){const{x:L,y:M,height:U}=C[R];s.length===1&&t.type==="home"&&s.push(new DOMRect(L,M,0,U))}})}if(i.container.nodeType===Node.TEXT_NODE&&i.offset>0){const E=document.createRange();E.setStart(i.container,i.offset-1);const A=E.getClientRects();Array.from(C).forEach((v,R)=>{if(Math.floor(A[0].top)!==Math.floor(s[0].top)&&Math.floor(A[0].top)===Math.floor(v.top)){const{y:L,height:M,right:U}=C[R];s.length===1&&t.type==="end"&&s.unshift(new DOMRect(U,L,0,M))}})}}return p(Nr,s.length>0,"no client rects for range"),t.type==="home"?s[s.length-1]:s[0]}const c7=I("core");function Yi(n,t,e,r){const i=re(t);let o=i.querySelector(`.block-anchor[data-id=${e}]`);o||(o=B("div",["block-anchor"],i),o.setAttribute("data-id",e));const s=r!=null?r:t.getBoundingClientRect(),l=t.getBoundingClientRect(),c=new DOMRect(s.left-l.left,s.top-l.top,s.width,s.height);return o.style.left=`${c.left}px`,o.style.top=`${c.top}px`,o.style.width=`${c.width}px`,o.style.height=`${c.height}px`,o}function u3(n,t,e,r){p(c7,nt(n,t),"not a text kind block");const i=Yn(t,lt(t,e,"normal")),o=t.getBoundingClientRect(),s=re(t);let l=s.querySelector(`.block-anchor[data-id=${r}]`);l||(l=B("div",["block-anchor"],s),l.setAttribute("data-id",r));const c=new DOMRect(i.left-o.left,i.top-o.top,i.width,i.height);return l.style.left=`${c.left}px`,l.style.top=`${c.top}px`,l.style.width=`${c.width}px`,l.style.height=`${c.height}px`,l}function fu(n){const t=fi(n);let e=0;return t.forEach(r=>{e+=mr(r)}),e}var u7=typeof global=="object"&&global&&global.Object===Object&&global;const f7=u7;var d7=typeof self=="object"&&self&&self.Object===Object&&self,h7=f7||d7||Function("return this")();const u1=h7;var m7=u1.Symbol;const Ho=m7;var f3=Object.prototype,g7=f3.hasOwnProperty,p7=f3.toString,du=Ho?Ho.toStringTag:void 0;function C7(n){var t=g7.call(n,du),e=n[du];try{n[du]=void 0;var r=!0}catch{}var i=p7.call(n);return r&&(t?n[du]=e:delete n[du]),i}var E7=Object.prototype,x7=E7.toString;function A7(n){return x7.call(n)}var b7="[object Null]",v7="[object Undefined]",d3=Ho?Ho.toStringTag:void 0;function f1(n){return n==null?n===void 0?v7:b7:d3&&d3 in Object(n)?C7(n):A7(n)}function d1(n){return n!=null&&typeof n=="object"}var B7="[object Symbol]";function h1(n){return typeof n=="symbol"||d1(n)&&f1(n)==B7}function T7(n,t){for(var e=-1,r=n==null?0:n.length,i=Array(r);++e<r;)i[e]=t(n[e],e,n);return i}var y7=Array.isArray;const hu=y7;var k7=1/0,h3=Ho?Ho.prototype:void 0,m3=h3?h3.toString:void 0;function g3(n){if(typeof n=="string")return n;if(hu(n))return T7(n,g3)+"";if(h1(n))return m3?m3.call(n):"";var t=n+"";return t=="0"&&1/n==-k7?"-0":t}function Jd(n){var t=typeof n;return n!=null&&(t=="object"||t=="function")}function R7(n){return n}var w7="[object AsyncFunction]",S7="[object Function]",L7="[object GeneratorFunction]",I7="[object Proxy]";function D7(n){if(!Jd(n))return!1;var t=f1(n);return t==S7||t==L7||t==w7||t==I7}var _7=u1["__core-js_shared__"];const m1=_7;var p3=function(){var n=/[^.]+$/.exec(m1&&m1.keys&&m1.keys.IE_PROTO||"");return n?"Symbol(src)_1."+n:""}();function M7(n){return!!p3&&p3 in n}var U7=Function.prototype,O7=U7.toString;function N7(n){if(n!=null){try{return O7.call(n)}catch{}try{return n+""}catch{}}return""}var P7=/[\\^$.*+?()[\]{}|]/g,F7=/^\[object .+?Constructor\]$/,K7=Function.prototype,V7=Object.prototype,$7=K7.toString,H7=V7.hasOwnProperty,j7=RegExp("^"+$7.call(H7).replace(P7,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");function z7(n){if(!Jd(n)||M7(n))return!1;var t=D7(n)?j7:F7;return t.test(N7(n))}function G7(n,t){return n==null?void 0:n[t]}function g1(n,t){var e=G7(n,t);return z7(e)?e:void 0}function W7(n,t,e){switch(e.length){case 0:return n.call(t);case 1:return n.call(t,e[0]);case 2:return n.call(t,e[0],e[1]);case 3:return n.call(t,e[0],e[1],e[2])}return n.apply(t,e)}var q7=800,X7=16,Q7=Date.now;function Y7(n){var t=0,e=0;return function(){var r=Q7(),i=X7-(r-e);if(e=r,i>0){if(++t>=q7)return arguments[0]}else t=0;return n.apply(void 0,arguments)}}function J7(n){return function(){return n}}var Z7=function(){try{var n=g1(Object,"defineProperty");return n({},"",{}),n}catch{}}();const Zd=Z7;var tD=Zd?function(n,t){return Zd(n,"toString",{configurable:!0,enumerable:!1,value:J7(t),writable:!0})}:R7,eD=Y7(tD);const nD=eD;var rD=9007199254740991,iD=/^(?:0|[1-9]\d*)$/;function C3(n,t){var e=typeof n;return t=t==null?rD:t,!!t&&(e=="number"||e!="symbol"&&iD.test(n))&&n>-1&&n%1==0&&n<t}function oD(n,t,e){t=="__proto__"&&Zd?Zd(n,t,{configurable:!0,enumerable:!0,value:e,writable:!0}):n[t]=e}function E3(n,t){return n===t||n!==n&&t!==t}var sD=Object.prototype,lD=sD.hasOwnProperty;function aD(n,t,e){var r=n[t];(!(lD.call(n,t)&&E3(r,e))||e===void 0&&!(t in n))&&oD(n,t,e)}var x3=Math.max;function cD(n,t,e){return t=x3(t===void 0?n.length-1:t,0),function(){for(var r=arguments,i=-1,o=x3(r.length-t,0),s=Array(o);++i<o;)s[i]=r[t+i];i=-1;for(var l=Array(t+1);++i<t;)l[i]=r[i];return l[t]=e(s),W7(n,this,l)}}var uD=9007199254740991;function fD(n){return typeof n=="number"&&n>-1&&n%1==0&&n<=uD}var dD="[object Arguments]";function A3(n){return d1(n)&&f1(n)==dD}var b3=Object.prototype,hD=b3.hasOwnProperty,mD=b3.propertyIsEnumerable,gD=A3(function(){return arguments}())?A3:function(n){return d1(n)&&hD.call(n,"callee")&&!mD.call(n,"callee")};const v3=gD;var pD=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,CD=/^\w*$/;function ED(n,t){if(hu(n))return!1;var e=typeof n;return e=="number"||e=="symbol"||e=="boolean"||n==null||h1(n)?!0:CD.test(n)||!pD.test(n)||t!=null&&n in Object(t)}var xD=g1(Object,"create");const mu=xD;function AD(){this.__data__=mu?mu(null):{},this.size=0}function bD(n){var t=this.has(n)&&delete this.__data__[n];return this.size-=t?1:0,t}var vD="__lodash_hash_undefined__",BD=Object.prototype,TD=BD.hasOwnProperty;function yD(n){var t=this.__data__;if(mu){var e=t[n];return e===vD?void 0:e}return TD.call(t,n)?t[n]:void 0}var kD=Object.prototype,RD=kD.hasOwnProperty;function wD(n){var t=this.__data__;return mu?t[n]!==void 0:RD.call(t,n)}var SD="__lodash_hash_undefined__";function LD(n,t){var e=this.__data__;return this.size+=this.has(n)?0:1,e[n]=mu&&t===void 0?SD:t,this}function qs(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}qs.prototype.clear=AD,qs.prototype.delete=bD,qs.prototype.get=yD,qs.prototype.has=wD,qs.prototype.set=LD;function ID(){this.__data__=[],this.size=0}function th(n,t){for(var e=n.length;e--;)if(E3(n[e][0],t))return e;return-1}var DD=Array.prototype,_D=DD.splice;function MD(n){var t=this.__data__,e=th(t,n);if(e<0)return!1;var r=t.length-1;return e==r?t.pop():_D.call(t,e,1),--this.size,!0}function UD(n){var t=this.__data__,e=th(t,n);return e<0?void 0:t[e][1]}function OD(n){return th(this.__data__,n)>-1}function ND(n,t){var e=this.__data__,r=th(e,n);return r<0?(++this.size,e.push([n,t])):e[r][1]=t,this}function Ca(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Ca.prototype.clear=ID,Ca.prototype.delete=MD,Ca.prototype.get=UD,Ca.prototype.has=OD,Ca.prototype.set=ND;var PD=g1(u1,"Map");const FD=PD;function KD(){this.size=0,this.__data__={hash:new qs,map:new(FD||Ca),string:new qs}}function VD(n){var t=typeof n;return t=="string"||t=="number"||t=="symbol"||t=="boolean"?n!=="__proto__":n===null}function eh(n,t){var e=n.__data__;return VD(t)?e[typeof t=="string"?"string":"hash"]:e.map}function $D(n){var t=eh(this,n).delete(n);return this.size-=t?1:0,t}function HD(n){return eh(this,n).get(n)}function jD(n){return eh(this,n).has(n)}function zD(n,t){var e=eh(this,n),r=e.size;return e.set(n,t),this.size+=e.size==r?0:1,this}function Xs(n){var t=-1,e=n==null?0:n.length;for(this.clear();++t<e;){var r=n[t];this.set(r[0],r[1])}}Xs.prototype.clear=KD,Xs.prototype.delete=$D,Xs.prototype.get=HD,Xs.prototype.has=jD,Xs.prototype.set=zD;var GD="Expected a function";function p1(n,t){if(typeof n!="function"||t!=null&&typeof t!="function")throw new TypeError(GD);var e=function(){var r=arguments,i=t?t.apply(this,r):r[0],o=e.cache;if(o.has(i))return o.get(i);var s=n.apply(this,r);return e.cache=o.set(i,s)||o,s};return e.cache=new(p1.Cache||Xs),e}p1.Cache=Xs;var WD=500;function qD(n){var t=p1(n,function(r){return e.size===WD&&e.clear(),r}),e=t.cache;return t}var XD=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,QD=/\\(\\)?/g,YD=qD(function(n){var t=[];return n.charCodeAt(0)===46&&t.push(""),n.replace(XD,function(e,r,i,o){t.push(i?o.replace(QD,"$1"):r||e)}),t});const JD=YD;function C1(n){return n==null?"":g3(n)}function nh(n,t){return hu(n)?n:ED(n,t)?[n]:JD(C1(n))}var ZD=1/0;function E1(n){if(typeof n=="string"||h1(n))return n;var t=n+"";return t=="0"&&1/n==-ZD?"-0":t}function t8(n,t){t=nh(t,n);for(var e=0,r=t.length;n!=null&&e<r;)n=n[E1(t[e++])];return e&&e==r?n:void 0}function e8(n,t){for(var e=-1,r=t.length,i=n.length;++e<r;)n[i+e]=t[e];return n}var B3=Ho?Ho.isConcatSpreadable:void 0;function n8(n){return hu(n)||v3(n)||!!(B3&&n&&n[B3])}function T3(n,t,e,r,i){var o=-1,s=n.length;for(e||(e=n8),i||(i=[]);++o<s;){var l=n[o];t>0&&e(l)?t>1?T3(l,t-1,e,r,i):e8(i,l):r||(i[i.length]=l)}return i}function r8(n){var t=n==null?0:n.length;return t?T3(n,1):[]}function i8(n){return nD(cD(n,void 0,r8),n+"")}function o8(n,t,e,r){var i=-1,o=n==null?0:n.length;for(r&&o&&(e=n[++i]);++i<o;)e=t(e,n[i],i,n);return e}function s8(n){return function(t){return n==null?void 0:n[t]}}var l8={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},a8=s8(l8);const c8=a8;var u8=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,f8="\\u0300-\\u036f",d8="\\ufe20-\\ufe2f",h8="\\u20d0-\\u20ff",m8=f8+d8+h8,g8="["+m8+"]",p8=RegExp(g8,"g");function C8(n){return n=C1(n),n&&n.replace(u8,c8).replace(p8,"")}var E8=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;function x8(n){return n.match(E8)||[]}var A8=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/;function b8(n){return A8.test(n)}var y3="\\ud800-\\udfff",v8="\\u0300-\\u036f",B8="\\ufe20-\\ufe2f",T8="\\u20d0-\\u20ff",y8=v8+B8+T8,k3="\\u2700-\\u27bf",R3="a-z\\xdf-\\xf6\\xf8-\\xff",k8="\\xac\\xb1\\xd7\\xf7",R8="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",w8="\\u2000-\\u206f",S8=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",w3="A-Z\\xc0-\\xd6\\xd8-\\xde",L8="\\ufe0e\\ufe0f",S3=k8+R8+w8+S8,L3="['\u2019]",I3="["+S3+"]",I8="["+y8+"]",D3="\\d+",D8="["+k3+"]",_3="["+R3+"]",M3="[^"+y3+S3+D3+k3+R3+w3+"]",_8="\\ud83c[\\udffb-\\udfff]",M8="(?:"+I8+"|"+_8+")",U8="[^"+y3+"]",U3="(?:\\ud83c[\\udde6-\\uddff]){2}",O3="[\\ud800-\\udbff][\\udc00-\\udfff]",Ea="["+w3+"]",O8="\\u200d",N3="(?:"+_3+"|"+M3+")",N8="(?:"+Ea+"|"+M3+")",P3="(?:"+L3+"(?:d|ll|m|re|s|t|ve))?",F3="(?:"+L3+"(?:D|LL|M|RE|S|T|VE))?",K3=M8+"?",V3="["+L8+"]?",P8="(?:"+O8+"(?:"+[U8,U3,O3].join("|")+")"+V3+K3+")*",F8="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",K8="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",V8=V3+K3+P8,$8="(?:"+[D8,U3,O3].join("|")+")"+V8,H8=RegExp([Ea+"?"+_3+"+"+P3+"(?="+[I3,Ea,"$"].join("|")+")",N8+"+"+F3+"(?="+[I3,Ea+N3,"$"].join("|")+")",Ea+"?"+N3+"+"+P3,Ea+"+"+F3,K8,F8,D3,$8].join("|"),"g");function j8(n){return n.match(H8)||[]}function z8(n,t,e){return n=C1(n),t=e?void 0:t,t===void 0?b8(n)?j8(n):x8(n):n.match(t)||[]}var G8="['\u2019]",W8=RegExp(G8,"g");function q8(n){return function(t){return o8(z8(C8(t).replace(W8,"")),n,"")}}function X8(n,t){return n!=null&&t in Object(n)}function Q8(n,t,e){t=nh(t,n);for(var r=-1,i=t.length,o=!1;++r<i;){var s=E1(t[r]);if(!(o=n!=null&&e(n,s)))break;n=n[s]}return o||++r!=i?o:(i=n==null?0:n.length,!!i&&fD(i)&&C3(s,i)&&(hu(n)||v3(n)))}function Y8(n,t){return n!=null&&Q8(n,t,X8)}var J8=q8(function(n,t,e){return n+(e?"-":"")+t.toLowerCase()});const Z8=J8;function t_(n,t,e,r){if(!Jd(n))return n;t=nh(t,n);for(var i=-1,o=t.length,s=o-1,l=n;l!=null&&++i<o;){var c=E1(t[i]),d=e;if(c==="__proto__"||c==="constructor"||c==="prototype")return n;if(i!=s){var h=l[c];d=r?r(h,c,l):void 0,d===void 0&&(d=Jd(h)?h:C3(t[i+1])?[]:{})}aD(l,c,d),l=l[c]}return n}function e_(n,t,e){for(var r=-1,i=t.length,o={};++r<i;){var s=t[r],l=t8(n,s);e(l,s)&&t_(o,nh(s,n),l)}return o}function n_(n,t){return e_(n,t,function(e,r){return Y8(n,r)})}var r_=i8(function(n,t){return n==null?{}:n_(n,t)});const i_=r_,$3=I("box");function jo(n){return!n.attributes||!n.attributes.box?!1:(p($3,typeof n.attributes.box=="string"&&n.attributes.box==="true"||n.attributes.box===!0,`invalid op attribute box property, ${n.attributes.box}`),p($3,n.attributes.type,`no box type: ${JSON.stringify(n)}`),!0)}const H3=I("text-op");function rh(n){return p(H3,typeof n.insert=="string","invalid op, no insert"),n.insert.length}function j3(n,t){const e=n;let r=0;for(let i=0;i<e.length;i++){const o=e[i];p(H3,typeof o.insert=="string","invalid text op, no insert");const s=r+rh(o);if(s>t)return[o];if(s===t){const l=[o];return i<e.length-1&&l.push(e[i+1]),l}r=s}return[]}const z3=I("rich-text-length");function x1(n){return p(z3,typeof n.insert=="string","op.insert is not string"),n.insert.length}function un(n){let t=0;return n.forEach(e=>{e.insert&&(p(z3,typeof e.insert=="string","op.insert is not string"),t+=x1(e))}),t}const mi=I("split-text");function _n(n,t,e){if(n=gt.default(n),t===0)return{left:[],right:n};if(t===-1)return{left:n,right:[]};let r=0;for(let i=0;i<n.length;i++){const o=n[i];p(mi,typeof o=="object",`invalid op type, ${typeof o}`),p(mi,typeof o.insert=="string",`invalid op.insert type, ${typeof o.insert}`);const s=x1(o);if(r+s<t)r+=s;else{if(r+s===t)return{left:n.slice(0,i+1),right:n.slice(i+1)};{p(mi,r+s>t,`invalid offset, ${r}, ${s}, ${t}`);const l=t-r,c=gt.default(o);p(mi,c.insert,"no copied.insert"),p(mi,typeof c.insert=="string","invalid copied.insert type"),c.insert=c.insert.substr(0,l),o.insert=o.insert.substr(l),c.insert===""&&p(mi,!1,"invalid copied.insert, is empty string"),o.insert===""&&p(mi,!1,"invalid op.insert, is empty string");const d=[o,...n.slice(i+1)],h=[...n.splice(0,i),c];return e&&(e.sourceOp=o),{left:h,right:d}}}}throw new Error(`invalid split offset: ${t}, ${JSON.stringify(n)}`)}function Xe(n,t,e){p(mi,t>=0,"invalid offset, < 0"),p(mi,e>0,"invalid length, <= 0"),p(mi,t+e<=un(n),"invalid offset + length < text length");const{left:r,right:i}=_n(n,t+e),{left:o,right:s}=_n(r,t);return{left:o,middle:s,right:i}}function G3(n,t){const e=Array.from(new Set(t)).sort((o,s)=>o-s),r=[];let i=n;for(let o=e.length-1;o>=0;o--){const s=e[o],{left:l,right:c}=_n(i,s);i=l,r.unshift(c)}return i.length>0&&r.unshift(i),r}function W3(n,t,e){return Xe(n,t,e).middle}const A1="style-color-",b1="style-bg-color-";function ih(n,t,e){const r=gt.default(n);return r.forEach(i=>{if(!(i.attributes&&i.attributes.box===!0))if(e===void 0){if(!i.attributes||i.attributes[t]===void 0)return;delete i.attributes[t],Object.keys(i.attributes).length===0&&delete i.attributes}else i.attributes||(i.attributes={}),i.attributes[t]=e}),r}function v1(n,t,e,r){const i=gt.default(n);return i.forEach(o=>{o.attributes&&o.attributes.box===!0||o.attributes&&((r==null?void 0:r.ignoreValue)||o.attributes[t]===e)&&(delete o.attributes[t],Object.keys(o.attributes).length===0&&delete o.attributes)}),i}function gu(n,t,e,r,i){if(t===0)return e;const o=Xe(e,n,t);return[...o.left,...ih(o.middle,r,i),...o.right]}function xa(n,t,e,r,i,o){if(t===0)return e;const s=Xe(e,n,t);return[...s.left,...v1(s.middle,r,i,o),...s.right]}function Aa(n,t){const e=j3(n,t);if(e.length===1)return e[0].attributes;if(e.length===2)return e[1].attributes}function q3(n,t,e,r){if(t===0)return e;const i=Xe(e,n,t),o=i.middle.map(s=>r(s));return[...i.left,...o,...i.right]}function X3(n,t){t==="color"?Object.keys(n).forEach(e=>{(e.startsWith("style-color-")||e==="inline-style-color")&&delete n[e]}):t==="backgroundColor"&&Object.keys(n).forEach(e=>{e.startsWith("style-bg-color-")&&delete n[e]})}function o_(n,t){if(!n.attributes||n.attributes.box)return;const e=n.attributes;X3(e,t),Object.keys(e).length===0&&delete n.attributes}function s_(n,t,e){n.attributes||(n.attributes={}),!n.attributes.box&&(t==="color"?n.attributes[`style-color-${e}`]=!0:n.attributes[`style-bg-color-${e}`]=!0)}function Q3(n,t,e,r,i){const o=gt.default(e);return q3(n,t,o,l=>(o_(l,r),i!==null&&s_(l,r,i),l))}function B1(n){var i,o;if(!n||n.box)return[null,null];const t=Array.from(Object.keys(n));let e=null,r=null;for(let s=0;s<t.length;s++){const l=t[s];l.startsWith(A1)?e=(i=Number.parseInt(l.substring(A1.length),10))!=null?i:null:l.startsWith(b1)&&(r=(o=Number.parseInt(l.substring(b1.length),10))!=null?o:null)}return[e,r]}function Y3(n,t,e){X3(n,t),t==="color"?n[`style-color-${e}`]=!0:n[`style-bg-color-${e}`]=!0}function J3(n){return n.attributes?n.attributes.box?[null,null]:B1(n.attributes):[null,null]}function Z3(n,t,e){let r=[];if(t===0?n!==0&&(r=Xe(e,n-1,1).middle):r=Xe(e,n,t).middle,r.length===0)return[null,null];let[i,o]=J3(r[0]);if(i===null&&o===null)return[i,o];for(let s=1;s<r.length;s++){const l=r[s];if(!l.attributes)return[null,null];if(l.attributes.box)continue;const[c,d]=J3(l);c===null||i===null?i=null:i=c===i?i:null,d===null||o===null?o=null:o=d===o?o:null}return[i,o]}const ba=I("text-block-content");function l_(n,t,e,r,i){if(p(ba,r,"no text for block"),r.length===0&&(!i||i.size===0)){e.innerHTML="<span><br></span>";return}const o=[];i&&o.push(...i.keys());const s=C=>n.editorInsertions.createInsertion(e,C),l=(C,E)=>{const A=i==null?void 0:i.get(E);A&&(A.forEach(v=>{C.appendChild(s(v))}),i==null||i.delete(E))},c=document.createDocumentFragment();let d=0;const h=G3(r,o);for(let C=0;C<h.length;C++){l(c,d);const E=h[C];d+=un(E);for(let A=0;A<E.length;A++){const v=E[A];if(jo(v)){p(ba,v.attributes,`op is not an valid box: ${JSON.stringify(v)}`);const L=n.editorBoxes.createBox(e,v.attributes);p(ba,L instanceof HTMLSpanElement,`invalid box element: ${L.tagName}`);const M=n.editorBlockRenders.renderBox(t,v.attributes);M.classes&&z(L,...M.classes),M.attributes&&Object.entries(M.attributes).forEach(([U,F])=>{L.setAttribute(U,F)}),M.styles&&Object.entries(M.styles).forEach(([U,F])=>{L.style.setProperty(U,F)}),c.appendChild(L);continue}p(ba,v.insert,`no insert in op: ${JSON.stringify(v)}`);const R=B("span",["text"],c,v.insert);if(v.attributes){const L=n.editorBlockRenders.renderText(t,v.attributes);L.classes&&z(R,...L.classes),L.attributes&&Object.entries(L.attributes).forEach(([M,U])=>{R.setAttribute(M,U)}),L.styles&&Object.entries(L.styles).forEach(([M,U])=>{R.style.setProperty(Z8(M),U)})}c.appendChild(R)}}l(c,d),e.innerHTML="",e.appendChild(c)}function oh(n,t,e,r,i){const{text:o,insertions:s}=n.editorDecorators.decorateText(t,i),l=n.compositingText;if(l){const c=n.selection.range.start;if(p(ba,c.isSimple(),"not an simple position while compositing"),c.blockId===e){const d=Aa(o,0);s.set(c.offset,[{type:"inputting",id:Z(),text:l,attributes:d}])}}return l_(n,t,r,o,s)}function a_(n){const t=n.rootContainer.querySelectorAll('span[data-type="editor-insertion"].inputting-insertion');t.length&&ba.debug(`remove ${t.length} temp composition span`),Array.from(t).forEach(e=>e.remove())}const gi=I("client-rects");function c_(n){const t=fi(n);let e=0;const r=[];for(let i=0;i<t.length;i++){const o=t[i],s=mr(o);r.push({child:o,startBlockOffset:e,endBlockOffset:e+s}),e+=s}return r}function u_(n,t,e,r){p(gi,e<r,`invalid from & to: ${e}, ${r}`);const i=dt(n,t);p(gi,e>=0&&r>=0&&e<=i&&r<=i,`invalid offset: ${e}, ${r}, length: ${i}`);const o=c_(t),s=o.findIndex(A=>A.startBlockOffset<=e&&e<A.endBlockOffset),l=o.findIndex(A=>A.startBlockOffset<r&&r<=A.endBlockOffset);if(p(gi,s!==-1,"failed to find start child"),p(gi,l!==-1,"failed to find end child"),p(gi,s<=l,`invalid start index & end index: ${s}, ${l}`),s===l){const A=o[s];return[{child:A.child,startChildOffset:e-A.startBlockOffset,endChildOffset:r-A.startBlockOffset}]}const c=[],d=o[s],h={child:d.child,startChildOffset:e-d.startBlockOffset,endChildOffset:mr(d.child)};c.push(h);for(let A=s+1;A<l;A++){const v=o[A],R={child:v.child,startChildOffset:0,endChildOffset:v.endBlockOffset-v.startBlockOffset};c.push(R)}const C=o[l],E={child:C.child,startChildOffset:0,endChildOffset:r-C.startBlockOffset};return c.push(E),c}function f_(n){const t=(r,i)=>r.left<=i.left&&r.top<=i.top&&r.right>=i.right&&r.bottom>=i.bottom&&(r.width!==i.width||r.height!==i.height);n=n.filter(r=>!n.find(o=>t(r,o)));const e=[];return n=n.filter(r=>e.find(i=>i.left===r.left&&i.top===r.top&&i.width===r.width&&i.height===r.height)?!1:(e.push(r),!0)),n}function tB(n,t,e,r){if(dt(n,t)===0){const h=Ot(t).getBoundingClientRect();return[new DOMRect(h.left,h.top,4,h.height)]}const i=e.offset,o=r.offset;if(i===o)return[Yn(t,e)];const l=u_(n,t,i,o).map(d=>l7(d.child,d.startChildOffset,d.endChildOffset)),c=[];return l.forEach(d=>{const h=f_(Array.from(d.getClientRects()));c.push(...h)}),c}function d_(n,t,e){p(gi,e instanceof tn,"invalid range");const r=e.start,i=e.end;return p(gi,r.isSimple(),"text block only allow simple position"),p(gi,i.isSimple(),"text block only allow simple position"),p(gi,r.blockId===i.blockId,"only allow update one text block selection"),p(gi,r.blockId===st(t),"only allow update one text block selection"),tB(n,t,r,i)}const T1=I("selection-background");function h_(n,t,e,r){p(T1,e.isSimple(),"text block only allow simple position"),p(T1,r.isSimple(),"text block only allow simple position"),p(T1,e.blockId===r.blockId,"only allow update one text block selection");const i=e.offset,o=r.offset;if(i===o&&(dt(n,t)!==0||n.selection.range.isCollapsed()))return;const s=tB(n,t,e,r),l=t.getBoundingClientRect(),c=fr(t),d=kv(t);Array.from(d.children).forEach((h,C)=>{if(C<s.length){const E=s[C],A=h;A.style.left=`${(E.left-l.left-t.clientLeft)/c}px`,A.style.top=`${(E.top-l.top-t.clientTop)/c}px`,A.style.width=`${E.width/c}px`,A.style.height=`${E.height/c}px`}else h.remove()}),s.slice(d.children.length).forEach(h=>{const C=B("div",["editor-selection-background"],d);C.style.left=`${(h.left-l.left-t.clientLeft)/c}px`,C.style.top=`${(h.top-l.top-t.clientTop)/c}px`,C.style.width=`${h.width/c}px`,C.style.height=`${h.height/c}px`})}function m_(n){const t=n.selection.range.getSelectedBlocks(),e=n.selection.range.isCollapsed();n.rootContainer.querySelectorAll("div[data-type=block-background]").forEach(r=>{const i=et(r);i&&nt(n,i)&&(!t.find(o=>o.block===i)||e)&&r.remove()})}const pu=I("line-breaker");function eB(n){const t=[];let e=null;for(let r=0;r<n.length;r++){let i=n[r];!!e&&i.top===e.top?(i=new DOMRect(e.left,e.top,e.width+i.width,i.height),t.splice(t.length-1,1,i)):t.push(i),e=i}return t}function g_(n){const t=document.createRange();return t.setStart(n,0),t.setEnd(n,n.data.length),eB(t.getClientRects())}function Cu(n){const t=l=>{if(!l)return!1;const c=Dd(l);return Us(l).top>c.top+c.height/2},e=(l,c)=>{const d=Us(l),h=Dd(c);return Math.floor(h.left)<Math.floor(d.right)},r=(l,c)=>{const d=Us(l),h=Us(c);return h.top+h.height/2>d.bottom},i=[];let o=0;const s=fi(n);for(let l=0;l<s.length;l++){const c=s[l];if(Qi(c)){const v=c,R=s[l+1];if(!R)break;const L=s[l-1];if(L&&r(L,v)&&i.push({offset:o,type:"betweenChild",childInfo:{prevChild:L,nextChild:v,wrap:"nextWrapped",prevWrapped:t(L),nextWrapped:t(v)}}),e(v,R)){i.push({offset:o,type:"betweenChild",childInfo:{prevChild:L,nextChild:v,wrap:"nowrap",prevWrapped:t(L),nextWrapped:t(v)}});continue}continue}if(hr(c)){const v=c,R=s[l+1];if(!R)break;const L=s[l-1];if(L&&r(L,v)&&i.push({offset:o,type:"betweenChild",childInfo:{prevChild:L,nextChild:v,wrap:"nextWrapped",prevWrapped:t(L),nextWrapped:t(v)}}),e(v,R)){o+=1,i.push({offset:o,type:"betweenChild",childInfo:{prevChild:L,nextChild:c,wrap:"nowrap",prevWrapped:t(L),nextWrapped:t(c)}});continue}o+=1;continue}const d=c,h=eB(d.getClientRects());if(p(pu,h.length>0,"invalid text child dom"),h.length===1){const v=s[l+1];if(!v)break;if(e(d,v)){o+=mr(d),i.push({offset:o,type:"betweenChild",childInfo:{prevChild:d,nextChild:v,wrap:"nowrap",prevWrapped:t(d),nextWrapped:t(v)}});continue}o+=mr(d);continue}const C=d.firstChild;p(pu,C,"invalid text child, no text node"),p(pu,C instanceof Text,`invalid text child, not a valid text node: ${typeof C}`);const E=mr(d);p(pu,C.data.length===E,"text node data length not equal child text length");const A=g_(C);for(let v=0;v<A.length-1;v++){const R=A[v],L=wg(R.right,R.top);L.offset>-1&&L.textNode===C&&i.push({offset:o+L.offset,type:"textBreakWord",childInfo:{prevChild:c,nextChild:c,wrap:"nowrap",prevWrapped:t(c),nextWrapped:t(c)}})}o+=E}return i}function y1(n,t){const e=Cu(n);for(let r=0;r<e.length;r++){const{offset:i}=e[r];if(t.offset<i)return{lineIndex:r,lineBreaks:e};if(t.offset===i&&t.type==="end")return{lineIndex:r,lineBreaks:e}}return p(pu,t.offset<=fu(n),"invalid position, offset > block length"),{lineIndex:e.length,lineBreaks:e}}var Mn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},nB={},k1={},R1={};(function(n){Object.defineProperty(n,"__esModule",{value:!0}),n.EXTENDED_PICTOGRAPHIC=n.CLUSTER_BREAK=void 0,function(t){t[t.CR=0]="CR",t[t.LF=1]="LF",t[t.CONTROL=2]="CONTROL",t[t.EXTEND=3]="EXTEND",t[t.REGIONAL_INDICATOR=4]="REGIONAL_INDICATOR",t[t.SPACINGMARK=5]="SPACINGMARK",t[t.L=6]="L",t[t.V=7]="V",t[t.T=8]="T",t[t.LV=9]="LV",t[t.LVT=10]="LVT",t[t.OTHER=11]="OTHER",t[t.PREPEND=12]="PREPEND",t[t.E_BASE=13]="E_BASE",t[t.E_MODIFIER=14]="E_MODIFIER",t[t.ZWJ=15]="ZWJ",t[t.GLUE_AFTER_ZWJ=16]="GLUE_AFTER_ZWJ",t[t.E_BASE_GAZ=17]="E_BASE_GAZ"}(n.CLUSTER_BREAK||(n.CLUSTER_BREAK={})),n.EXTENDED_PICTOGRAPHIC=101})(R1);var w1={};Object.defineProperty(w1,"__esModule",{value:!0});const $t=R1,Ji=0,S1=1,p_=2,C_=3,E_=4;class x_{static isSurrogate(t,e){return 55296<=t.charCodeAt(e)&&t.charCodeAt(e)<=56319&&56320<=t.charCodeAt(e+1)&&t.charCodeAt(e+1)<=57343}static codePointAt(t,e){e===void 0&&(e=0);const r=t.charCodeAt(e);if(55296<=r&&r<=56319&&e<t.length-1){const i=r,o=t.charCodeAt(e+1);return 56320<=o&&o<=57343?(i-55296)*1024+(o-56320)+65536:i}if(56320<=r&&r<=57343&&e>=1){const i=t.charCodeAt(e-1),o=r;return 55296<=i&&i<=56319?(i-55296)*1024+(o-56320)+65536:o}return r}static shouldBreak(t,e,r,i,o,s){const l=[t].concat(e).concat([r]),c=[i].concat(o).concat([s]),d=l[l.length-2],h=r,C=s,E=l.lastIndexOf($t.CLUSTER_BREAK.REGIONAL_INDICATOR);if(E>0&&l.slice(1,E).every(function(v){return v===$t.CLUSTER_BREAK.REGIONAL_INDICATOR})&&[$t.CLUSTER_BREAK.PREPEND,$t.CLUSTER_BREAK.REGIONAL_INDICATOR].indexOf(d)===-1)return l.filter(function(v){return v===$t.CLUSTER_BREAK.REGIONAL_INDICATOR}).length%2===1?C_:E_;if(d===$t.CLUSTER_BREAK.CR&&h===$t.CLUSTER_BREAK.LF)return Ji;if(d===$t.CLUSTER_BREAK.CONTROL||d===$t.CLUSTER_BREAK.CR||d===$t.CLUSTER_BREAK.LF)return S1;if(h===$t.CLUSTER_BREAK.CONTROL||h===$t.CLUSTER_BREAK.CR||h===$t.CLUSTER_BREAK.LF)return S1;if(d===$t.CLUSTER_BREAK.L&&(h===$t.CLUSTER_BREAK.L||h===$t.CLUSTER_BREAK.V||h===$t.CLUSTER_BREAK.LV||h===$t.CLUSTER_BREAK.LVT))return Ji;if((d===$t.CLUSTER_BREAK.LV||d===$t.CLUSTER_BREAK.V)&&(h===$t.CLUSTER_BREAK.V||h===$t.CLUSTER_BREAK.T))return Ji;if((d===$t.CLUSTER_BREAK.LVT||d===$t.CLUSTER_BREAK.T)&&h===$t.CLUSTER_BREAK.T)return Ji;if(h===$t.CLUSTER_BREAK.EXTEND||h===$t.CLUSTER_BREAK.ZWJ)return Ji;if(h===$t.CLUSTER_BREAK.SPACINGMARK)return Ji;if(d===$t.CLUSTER_BREAK.PREPEND)return Ji;const A=c.slice(0,-1).lastIndexOf($t.EXTENDED_PICTOGRAPHIC);return A!==-1&&c[A]===$t.EXTENDED_PICTOGRAPHIC&&l.slice(A+1,-2).every(function(v){return v===$t.CLUSTER_BREAK.EXTEND})&&d===$t.CLUSTER_BREAK.ZWJ&&C===$t.EXTENDED_PICTOGRAPHIC?Ji:e.indexOf($t.CLUSTER_BREAK.REGIONAL_INDICATOR)!==-1?p_:d===$t.CLUSTER_BREAK.REGIONAL_INDICATOR&&h===$t.CLUSTER_BREAK.REGIONAL_INDICATOR?Ji:S1}}w1.default=x_;var L1={};Object.defineProperty(L1,"__esModule",{value:!0});class A_{constructor(t,e){this._index=0,this._str=t,this._nextBreak=e}[Symbol.iterator](){return this}next(){let t;if((t=this._nextBreak(this._str,this._index))<this._str.length){const e=this._str.slice(this._index,t);return this._index=t,{value:e,done:!1}}if(this._index<this._str.length){const e=this._str.slice(this._index);return this._index=this._str.length,{value:e,done:!1}}return{value:void 0,done:!0}}}L1.default=A_;var rB=Mn&&Mn.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(k1,"__esModule",{value:!0});const f=R1,sh=rB(w1),b_=rB(L1);class Zi{static nextBreak(t,e){if(e===void 0&&(e=0),e<0)return 0;if(e>=t.length-1)return t.length;const r=sh.default.codePointAt(t,e),i=Zi.getGraphemeBreakProperty(r),o=Zi.getEmojiProperty(r),s=[],l=[];for(let c=e+1;c<t.length;c++){if(sh.default.isSurrogate(t,c-1))continue;const d=sh.default.codePointAt(t,c),h=Zi.getGraphemeBreakProperty(d),C=Zi.getEmojiProperty(d);if(sh.default.shouldBreak(i,s,h,o,l,C))return c;s.push(h),l.push(C)}return t.length}splitGraphemes(t){const e=[];let r=0,i;for(;(i=Zi.nextBreak(t,r))<t.length;)e.push(t.slice(r,i)),r=i;return r<t.length&&e.push(t.slice(r)),e}iterateGraphemes(t){return new b_.default(t,Zi.nextBreak)}countGraphemes(t){let e=0,r=0,i;for(;(i=Zi.nextBreak(t,r))<t.length;)r=i,e++;return r<t.length&&e++,e}static getGraphemeBreakProperty(t){if(t<48905){if(t<44116){if(t<4141){if(t<2818){if(t<2363)if(t<1759){if(t<1471){if(t<127){if(t<11){if(t<10){if(0<=t&&t<=9)return f.CLUSTER_BREAK.CONTROL}else if(t===10)return f.CLUSTER_BREAK.LF}else if(t<13){if(11<=t&&t<=12)return f.CLUSTER_BREAK.CONTROL}else if(t<14){if(t===13)return f.CLUSTER_BREAK.CR}else if(14<=t&&t<=31)return f.CLUSTER_BREAK.CONTROL}else if(t<768){if(t<173){if(127<=t&&t<=159)return f.CLUSTER_BREAK.CONTROL}else if(t===173)return f.CLUSTER_BREAK.CONTROL}else if(t<1155){if(768<=t&&t<=879)return f.CLUSTER_BREAK.EXTEND}else if(t<1425){if(1155<=t&&t<=1161)return f.CLUSTER_BREAK.EXTEND}else if(1425<=t&&t<=1469)return f.CLUSTER_BREAK.EXTEND}else if(t<1552){if(t<1476){if(t<1473){if(t===1471)return f.CLUSTER_BREAK.EXTEND}else if(1473<=t&&t<=1474)return f.CLUSTER_BREAK.EXTEND}else if(t<1479){if(1476<=t&&t<=1477)return f.CLUSTER_BREAK.EXTEND}else if(t<1536){if(t===1479)return f.CLUSTER_BREAK.EXTEND}else if(1536<=t&&t<=1541)return f.CLUSTER_BREAK.PREPEND}else if(t<1648){if(t<1564){if(1552<=t&&t<=1562)return f.CLUSTER_BREAK.EXTEND}else if(t<1611){if(t===1564)return f.CLUSTER_BREAK.CONTROL}else if(1611<=t&&t<=1631)return f.CLUSTER_BREAK.EXTEND}else if(t<1750){if(t===1648)return f.CLUSTER_BREAK.EXTEND}else if(t<1757){if(1750<=t&&t<=1756)return f.CLUSTER_BREAK.EXTEND}else if(t===1757)return f.CLUSTER_BREAK.PREPEND}else if(t<2075){if(t<1840)if(t<1770){if(t<1767){if(1759<=t&&t<=1764)return f.CLUSTER_BREAK.EXTEND}else if(1767<=t&&t<=1768)return f.CLUSTER_BREAK.EXTEND}else if(t<1807){if(1770<=t&&t<=1773)return f.CLUSTER_BREAK.EXTEND}else{if(t===1807)return f.CLUSTER_BREAK.PREPEND;if(t===1809)return f.CLUSTER_BREAK.EXTEND}else if(t<2027){if(t<1958){if(1840<=t&&t<=1866)return f.CLUSTER_BREAK.EXTEND}else if(1958<=t&&t<=1968)return f.CLUSTER_BREAK.EXTEND}else if(t<2045){if(2027<=t&&t<=2035)return f.CLUSTER_BREAK.EXTEND}else if(t<2070){if(t===2045)return f.CLUSTER_BREAK.EXTEND}else if(2070<=t&&t<=2073)return f.CLUSTER_BREAK.EXTEND}else if(t<2200){if(t<2089){if(t<2085){if(2075<=t&&t<=2083)return f.CLUSTER_BREAK.EXTEND}else if(2085<=t&&t<=2087)return f.CLUSTER_BREAK.EXTEND}else if(t<2137){if(2089<=t&&t<=2093)return f.CLUSTER_BREAK.EXTEND}else if(t<2192){if(2137<=t&&t<=2139)return f.CLUSTER_BREAK.EXTEND}else if(2192<=t&&t<=2193)return f.CLUSTER_BREAK.PREPEND}else if(t<2275){if(t<2250){if(2200<=t&&t<=2207)return f.CLUSTER_BREAK.EXTEND}else if(t<2274){if(2250<=t&&t<=2273)return f.CLUSTER_BREAK.EXTEND}else if(t===2274)return f.CLUSTER_BREAK.PREPEND}else if(t<2307){if(2275<=t&&t<=2306)return f.CLUSTER_BREAK.EXTEND}else{if(t===2307)return f.CLUSTER_BREAK.SPACINGMARK;if(t===2362)return f.CLUSTER_BREAK.EXTEND}else if(t<2561){if(t<2434){if(t<2381){if(t<2366){if(t===2363)return f.CLUSTER_BREAK.SPACINGMARK;if(t===2364)return f.CLUSTER_BREAK.EXTEND}else if(t<2369){if(2366<=t&&t<=2368)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2377){if(2369<=t&&t<=2376)return f.CLUSTER_BREAK.EXTEND}else if(2377<=t&&t<=2380)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2385){if(t<2382){if(t===2381)return f.CLUSTER_BREAK.EXTEND}else if(2382<=t&&t<=2383)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2402){if(2385<=t&&t<=2391)return f.CLUSTER_BREAK.EXTEND}else if(t<2433){if(2402<=t&&t<=2403)return f.CLUSTER_BREAK.EXTEND}else if(t===2433)return f.CLUSTER_BREAK.EXTEND}else if(t<2503){if(t<2494){if(t<2492){if(2434<=t&&t<=2435)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===2492)return f.CLUSTER_BREAK.EXTEND}else if(t<2495){if(t===2494)return f.CLUSTER_BREAK.EXTEND}else if(t<2497){if(2495<=t&&t<=2496)return f.CLUSTER_BREAK.SPACINGMARK}else if(2497<=t&&t<=2500)return f.CLUSTER_BREAK.EXTEND}else if(t<2519){if(t<2507){if(2503<=t&&t<=2504)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2509){if(2507<=t&&t<=2508)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===2509)return f.CLUSTER_BREAK.EXTEND}else if(t<2530){if(t===2519)return f.CLUSTER_BREAK.EXTEND}else if(t<2558){if(2530<=t&&t<=2531)return f.CLUSTER_BREAK.EXTEND}else if(t===2558)return f.CLUSTER_BREAK.EXTEND}else if(t<2691){if(t<2631){if(t<2620){if(t<2563){if(2561<=t&&t<=2562)return f.CLUSTER_BREAK.EXTEND}else if(t===2563)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2622){if(t===2620)return f.CLUSTER_BREAK.EXTEND}else if(t<2625){if(2622<=t&&t<=2624)return f.CLUSTER_BREAK.SPACINGMARK}else if(2625<=t&&t<=2626)return f.CLUSTER_BREAK.EXTEND}else if(t<2672){if(t<2635){if(2631<=t&&t<=2632)return f.CLUSTER_BREAK.EXTEND}else if(t<2641){if(2635<=t&&t<=2637)return f.CLUSTER_BREAK.EXTEND}else if(t===2641)return f.CLUSTER_BREAK.EXTEND}else if(t<2677){if(2672<=t&&t<=2673)return f.CLUSTER_BREAK.EXTEND}else if(t<2689){if(t===2677)return f.CLUSTER_BREAK.EXTEND}else if(2689<=t&&t<=2690)return f.CLUSTER_BREAK.EXTEND}else if(t<2761){if(t<2750){if(t===2691)return f.CLUSTER_BREAK.SPACINGMARK;if(t===2748)return f.CLUSTER_BREAK.EXTEND}else if(t<2753){if(2750<=t&&t<=2752)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2759){if(2753<=t&&t<=2757)return f.CLUSTER_BREAK.EXTEND}else if(2759<=t&&t<=2760)return f.CLUSTER_BREAK.EXTEND}else if(t<2786){if(t<2763){if(t===2761)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2765){if(2763<=t&&t<=2764)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===2765)return f.CLUSTER_BREAK.EXTEND}else if(t<2810){if(2786<=t&&t<=2787)return f.CLUSTER_BREAK.EXTEND}else if(t<2817){if(2810<=t&&t<=2815)return f.CLUSTER_BREAK.EXTEND}else if(t===2817)return f.CLUSTER_BREAK.EXTEND}else if(t<3315){if(t<3076){if(t<2946){if(t<2887){if(t<2878){if(t<2876){if(2818<=t&&t<=2819)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===2876)return f.CLUSTER_BREAK.EXTEND}else if(t<2880){if(2878<=t&&t<=2879)return f.CLUSTER_BREAK.EXTEND}else if(t<2881){if(t===2880)return f.CLUSTER_BREAK.SPACINGMARK}else if(2881<=t&&t<=2884)return f.CLUSTER_BREAK.EXTEND}else if(t<2893){if(t<2891){if(2887<=t&&t<=2888)return f.CLUSTER_BREAK.SPACINGMARK}else if(2891<=t&&t<=2892)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<2901){if(t===2893)return f.CLUSTER_BREAK.EXTEND}else if(t<2914){if(2901<=t&&t<=2903)return f.CLUSTER_BREAK.EXTEND}else if(2914<=t&&t<=2915)return f.CLUSTER_BREAK.EXTEND}else if(t<3014){if(t<3007){if(t===2946||t===3006)return f.CLUSTER_BREAK.EXTEND}else if(t<3008){if(t===3007)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3009){if(t===3008)return f.CLUSTER_BREAK.EXTEND}else if(3009<=t&&t<=3010)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3031){if(t<3018){if(3014<=t&&t<=3016)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3021){if(3018<=t&&t<=3020)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===3021)return f.CLUSTER_BREAK.EXTEND}else if(t<3072){if(t===3031)return f.CLUSTER_BREAK.EXTEND}else if(t<3073){if(t===3072)return f.CLUSTER_BREAK.EXTEND}else if(3073<=t&&t<=3075)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3262){if(t<3146){if(t<3134){if(t===3076||t===3132)return f.CLUSTER_BREAK.EXTEND}else if(t<3137){if(3134<=t&&t<=3136)return f.CLUSTER_BREAK.EXTEND}else if(t<3142){if(3137<=t&&t<=3140)return f.CLUSTER_BREAK.SPACINGMARK}else if(3142<=t&&t<=3144)return f.CLUSTER_BREAK.EXTEND}else if(t<3201){if(t<3157){if(3146<=t&&t<=3149)return f.CLUSTER_BREAK.EXTEND}else if(t<3170){if(3157<=t&&t<=3158)return f.CLUSTER_BREAK.EXTEND}else if(3170<=t&&t<=3171)return f.CLUSTER_BREAK.EXTEND}else if(t<3202){if(t===3201)return f.CLUSTER_BREAK.EXTEND}else if(t<3260){if(3202<=t&&t<=3203)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===3260)return f.CLUSTER_BREAK.EXTEND}else if(t<3270){if(t<3264){if(t===3262)return f.CLUSTER_BREAK.SPACINGMARK;if(t===3263)return f.CLUSTER_BREAK.EXTEND}else if(t<3266){if(3264<=t&&t<=3265)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3267){if(t===3266)return f.CLUSTER_BREAK.EXTEND}else if(3267<=t&&t<=3268)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3276){if(t<3271){if(t===3270)return f.CLUSTER_BREAK.EXTEND}else if(t<3274){if(3271<=t&&t<=3272)return f.CLUSTER_BREAK.SPACINGMARK}else if(3274<=t&&t<=3275)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3285){if(3276<=t&&t<=3277)return f.CLUSTER_BREAK.EXTEND}else if(t<3298){if(3285<=t&&t<=3286)return f.CLUSTER_BREAK.EXTEND}else if(3298<=t&&t<=3299)return f.CLUSTER_BREAK.EXTEND}else if(t<3551){if(t<3406){if(t<3391){if(t<3330){if(t<3328){if(t===3315)return f.CLUSTER_BREAK.SPACINGMARK}else if(3328<=t&&t<=3329)return f.CLUSTER_BREAK.EXTEND}else if(t<3387){if(3330<=t&&t<=3331)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3390){if(3387<=t&&t<=3388)return f.CLUSTER_BREAK.EXTEND}else if(t===3390)return f.CLUSTER_BREAK.EXTEND}else if(t<3398){if(t<3393){if(3391<=t&&t<=3392)return f.CLUSTER_BREAK.SPACINGMARK}else if(3393<=t&&t<=3396)return f.CLUSTER_BREAK.EXTEND}else if(t<3402){if(3398<=t&&t<=3400)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3405){if(3402<=t&&t<=3404)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===3405)return f.CLUSTER_BREAK.EXTEND}else if(t<3530){if(t<3426){if(t===3406)return f.CLUSTER_BREAK.PREPEND;if(t===3415)return f.CLUSTER_BREAK.EXTEND}else if(t<3457){if(3426<=t&&t<=3427)return f.CLUSTER_BREAK.EXTEND}else if(t<3458){if(t===3457)return f.CLUSTER_BREAK.EXTEND}else if(3458<=t&&t<=3459)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3538){if(t<3535){if(t===3530)return f.CLUSTER_BREAK.EXTEND}else if(t<3536){if(t===3535)return f.CLUSTER_BREAK.EXTEND}else if(3536<=t&&t<=3537)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3542){if(3538<=t&&t<=3540)return f.CLUSTER_BREAK.EXTEND}else if(t<3544){if(t===3542)return f.CLUSTER_BREAK.EXTEND}else if(3544<=t&&t<=3550)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3893){if(t<3655){if(t<3633){if(t<3570){if(t===3551)return f.CLUSTER_BREAK.EXTEND}else if(3570<=t&&t<=3571)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3635){if(t===3633)return f.CLUSTER_BREAK.EXTEND}else if(t<3636){if(t===3635)return f.CLUSTER_BREAK.SPACINGMARK}else if(3636<=t&&t<=3642)return f.CLUSTER_BREAK.EXTEND}else if(t<3764)if(t<3761){if(3655<=t&&t<=3662)return f.CLUSTER_BREAK.EXTEND}else{if(t===3761)return f.CLUSTER_BREAK.EXTEND;if(t===3763)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3784){if(3764<=t&&t<=3772)return f.CLUSTER_BREAK.EXTEND}else if(t<3864){if(3784<=t&&t<=3790)return f.CLUSTER_BREAK.EXTEND}else if(3864<=t&&t<=3865)return f.CLUSTER_BREAK.EXTEND}else if(t<3967){if(t<3897){if(t===3893||t===3895)return f.CLUSTER_BREAK.EXTEND}else if(t<3902){if(t===3897)return f.CLUSTER_BREAK.EXTEND}else if(t<3953){if(3902<=t&&t<=3903)return f.CLUSTER_BREAK.SPACINGMARK}else if(3953<=t&&t<=3966)return f.CLUSTER_BREAK.EXTEND}else if(t<3981){if(t<3968){if(t===3967)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<3974){if(3968<=t&&t<=3972)return f.CLUSTER_BREAK.EXTEND}else if(3974<=t&&t<=3975)return f.CLUSTER_BREAK.EXTEND}else if(t<3993){if(3981<=t&&t<=3991)return f.CLUSTER_BREAK.EXTEND}else if(t<4038){if(3993<=t&&t<=4028)return f.CLUSTER_BREAK.EXTEND}else if(t===4038)return f.CLUSTER_BREAK.EXTEND}else if(t<7204){if(t<6448){if(t<5938){if(t<4226){if(t<4157){if(t<4146){if(t<4145){if(4141<=t&&t<=4144)return f.CLUSTER_BREAK.EXTEND}else if(t===4145)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<4153){if(4146<=t&&t<=4151)return f.CLUSTER_BREAK.EXTEND}else if(t<4155){if(4153<=t&&t<=4154)return f.CLUSTER_BREAK.EXTEND}else if(4155<=t&&t<=4156)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<4184){if(t<4182){if(4157<=t&&t<=4158)return f.CLUSTER_BREAK.EXTEND}else if(4182<=t&&t<=4183)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<4190){if(4184<=t&&t<=4185)return f.CLUSTER_BREAK.EXTEND}else if(t<4209){if(4190<=t&&t<=4192)return f.CLUSTER_BREAK.EXTEND}else if(4209<=t&&t<=4212)return f.CLUSTER_BREAK.EXTEND}else if(t<4352){if(t<4229){if(t===4226)return f.CLUSTER_BREAK.EXTEND;if(t===4228)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<4237){if(4229<=t&&t<=4230)return f.CLUSTER_BREAK.EXTEND}else if(t===4237||t===4253)return f.CLUSTER_BREAK.EXTEND}else if(t<4957){if(t<4448){if(4352<=t&&t<=4447)return f.CLUSTER_BREAK.L}else if(t<4520){if(4448<=t&&t<=4519)return f.CLUSTER_BREAK.V}else if(4520<=t&&t<=4607)return f.CLUSTER_BREAK.T}else if(t<5906){if(4957<=t&&t<=4959)return f.CLUSTER_BREAK.EXTEND}else if(t<5909){if(5906<=t&&t<=5908)return f.CLUSTER_BREAK.EXTEND}else if(t===5909)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6089){if(t<6070){if(t<5970){if(t<5940){if(5938<=t&&t<=5939)return f.CLUSTER_BREAK.EXTEND}else if(t===5940)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6002){if(5970<=t&&t<=5971)return f.CLUSTER_BREAK.EXTEND}else if(t<6068){if(6002<=t&&t<=6003)return f.CLUSTER_BREAK.EXTEND}else if(6068<=t&&t<=6069)return f.CLUSTER_BREAK.EXTEND}else if(t<6078){if(t<6071){if(t===6070)return f.CLUSTER_BREAK.SPACINGMARK}else if(6071<=t&&t<=6077)return f.CLUSTER_BREAK.EXTEND}else if(t<6086){if(6078<=t&&t<=6085)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6087){if(t===6086)return f.CLUSTER_BREAK.EXTEND}else if(6087<=t&&t<=6088)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6277)if(t<6155){if(t<6109){if(6089<=t&&t<=6099)return f.CLUSTER_BREAK.EXTEND}else if(t===6109)return f.CLUSTER_BREAK.EXTEND}else if(t<6158){if(6155<=t&&t<=6157)return f.CLUSTER_BREAK.EXTEND}else{if(t===6158)return f.CLUSTER_BREAK.CONTROL;if(t===6159)return f.CLUSTER_BREAK.EXTEND}else if(t<6435){if(t<6313){if(6277<=t&&t<=6278)return f.CLUSTER_BREAK.EXTEND}else if(t<6432){if(t===6313)return f.CLUSTER_BREAK.EXTEND}else if(6432<=t&&t<=6434)return f.CLUSTER_BREAK.EXTEND}else if(t<6439){if(6435<=t&&t<=6438)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6441){if(6439<=t&&t<=6440)return f.CLUSTER_BREAK.EXTEND}else if(6441<=t&&t<=6443)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6971){if(t<6744)if(t<6681){if(t<6451){if(t<6450){if(6448<=t&&t<=6449)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===6450)return f.CLUSTER_BREAK.EXTEND}else if(t<6457){if(6451<=t&&t<=6456)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6679){if(6457<=t&&t<=6459)return f.CLUSTER_BREAK.EXTEND}else if(6679<=t&&t<=6680)return f.CLUSTER_BREAK.EXTEND}else if(t<6741){if(t<6683){if(6681<=t&&t<=6682)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===6683)return f.CLUSTER_BREAK.EXTEND}else if(t<6742){if(t===6741)return f.CLUSTER_BREAK.SPACINGMARK}else{if(t===6742)return f.CLUSTER_BREAK.EXTEND;if(t===6743)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6771){if(t<6754){if(t<6752){if(6744<=t&&t<=6750)return f.CLUSTER_BREAK.EXTEND}else if(t===6752)return f.CLUSTER_BREAK.EXTEND}else if(t<6757){if(t===6754)return f.CLUSTER_BREAK.EXTEND}else if(t<6765){if(6757<=t&&t<=6764)return f.CLUSTER_BREAK.EXTEND}else if(6765<=t&&t<=6770)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6912){if(t<6783){if(6771<=t&&t<=6780)return f.CLUSTER_BREAK.EXTEND}else if(t<6832){if(t===6783)return f.CLUSTER_BREAK.EXTEND}else if(6832<=t&&t<=6862)return f.CLUSTER_BREAK.EXTEND}else if(t<6916){if(6912<=t&&t<=6915)return f.CLUSTER_BREAK.EXTEND}else if(t<6964){if(t===6916)return f.CLUSTER_BREAK.SPACINGMARK}else if(6964<=t&&t<=6970)return f.CLUSTER_BREAK.EXTEND}else if(t<7080){if(t<7019){if(t<6973){if(t===6971)return f.CLUSTER_BREAK.SPACINGMARK;if(t===6972)return f.CLUSTER_BREAK.EXTEND}else if(t<6978){if(6973<=t&&t<=6977)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<6979){if(t===6978)return f.CLUSTER_BREAK.EXTEND}else if(6979<=t&&t<=6980)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7073){if(t<7040){if(7019<=t&&t<=7027)return f.CLUSTER_BREAK.EXTEND}else if(t<7042){if(7040<=t&&t<=7041)return f.CLUSTER_BREAK.EXTEND}else if(t===7042)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7074){if(t===7073)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7078){if(7074<=t&&t<=7077)return f.CLUSTER_BREAK.EXTEND}else if(7078<=t&&t<=7079)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7144)if(t<7083){if(t<7082){if(7080<=t&&t<=7081)return f.CLUSTER_BREAK.EXTEND}else if(t===7082)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7142){if(7083<=t&&t<=7085)return f.CLUSTER_BREAK.EXTEND}else{if(t===7142)return f.CLUSTER_BREAK.EXTEND;if(t===7143)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7150){if(t<7146){if(7144<=t&&t<=7145)return f.CLUSTER_BREAK.EXTEND}else if(t<7149){if(7146<=t&&t<=7148)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===7149)return f.CLUSTER_BREAK.EXTEND}else if(t<7151){if(t===7150)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7154){if(7151<=t&&t<=7153)return f.CLUSTER_BREAK.EXTEND}else if(7154<=t&&t<=7155)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43346){if(t<11647){if(t<7415){if(t<7380){if(t<7220){if(t<7212){if(7204<=t&&t<=7211)return f.CLUSTER_BREAK.SPACINGMARK}else if(7212<=t&&t<=7219)return f.CLUSTER_BREAK.EXTEND}else if(t<7222){if(7220<=t&&t<=7221)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7376){if(7222<=t&&t<=7223)return f.CLUSTER_BREAK.EXTEND}else if(7376<=t&&t<=7378)return f.CLUSTER_BREAK.EXTEND}else if(t<7394){if(t<7393){if(7380<=t&&t<=7392)return f.CLUSTER_BREAK.EXTEND}else if(t===7393)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<7405){if(7394<=t&&t<=7400)return f.CLUSTER_BREAK.EXTEND}else if(t===7405||t===7412)return f.CLUSTER_BREAK.EXTEND}else if(t<8205)if(t<7616){if(t<7416){if(t===7415)return f.CLUSTER_BREAK.SPACINGMARK}else if(7416<=t&&t<=7417)return f.CLUSTER_BREAK.EXTEND}else if(t<8203){if(7616<=t&&t<=7679)return f.CLUSTER_BREAK.EXTEND}else{if(t===8203)return f.CLUSTER_BREAK.CONTROL;if(t===8204)return f.CLUSTER_BREAK.EXTEND}else if(t<8288){if(t<8206){if(t===8205)return f.CLUSTER_BREAK.ZWJ}else if(t<8232){if(8206<=t&&t<=8207)return f.CLUSTER_BREAK.CONTROL}else if(8232<=t&&t<=8238)return f.CLUSTER_BREAK.CONTROL}else if(t<8400){if(8288<=t&&t<=8303)return f.CLUSTER_BREAK.CONTROL}else if(t<11503){if(8400<=t&&t<=8432)return f.CLUSTER_BREAK.EXTEND}else if(11503<=t&&t<=11505)return f.CLUSTER_BREAK.EXTEND}else if(t<43043){if(t<42612){if(t<12330){if(t<11744){if(t===11647)return f.CLUSTER_BREAK.EXTEND}else if(11744<=t&&t<=11775)return f.CLUSTER_BREAK.EXTEND}else if(t<12441){if(12330<=t&&t<=12335)return f.CLUSTER_BREAK.EXTEND}else if(t<42607){if(12441<=t&&t<=12442)return f.CLUSTER_BREAK.EXTEND}else if(42607<=t&&t<=42610)return f.CLUSTER_BREAK.EXTEND}else if(t<43010){if(t<42654){if(42612<=t&&t<=42621)return f.CLUSTER_BREAK.EXTEND}else if(t<42736){if(42654<=t&&t<=42655)return f.CLUSTER_BREAK.EXTEND}else if(42736<=t&&t<=42737)return f.CLUSTER_BREAK.EXTEND}else if(t<43014){if(t===43010)return f.CLUSTER_BREAK.EXTEND}else if(t===43014||t===43019)return f.CLUSTER_BREAK.EXTEND}else if(t<43188){if(t<43047){if(t<43045){if(43043<=t&&t<=43044)return f.CLUSTER_BREAK.SPACINGMARK}else if(43045<=t&&t<=43046)return f.CLUSTER_BREAK.EXTEND}else if(t<43052){if(t===43047)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43136){if(t===43052)return f.CLUSTER_BREAK.EXTEND}else if(43136<=t&&t<=43137)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43263){if(t<43204){if(43188<=t&&t<=43203)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43232){if(43204<=t&&t<=43205)return f.CLUSTER_BREAK.EXTEND}else if(43232<=t&&t<=43249)return f.CLUSTER_BREAK.EXTEND}else if(t<43302){if(t===43263)return f.CLUSTER_BREAK.EXTEND}else if(t<43335){if(43302<=t&&t<=43309)return f.CLUSTER_BREAK.EXTEND}else if(43335<=t&&t<=43345)return f.CLUSTER_BREAK.EXTEND}else if(t<43698){if(t<43493){if(t<43444)if(t<43392){if(t<43360){if(43346<=t&&t<=43347)return f.CLUSTER_BREAK.SPACINGMARK}else if(43360<=t&&t<=43388)return f.CLUSTER_BREAK.L}else if(t<43395){if(43392<=t&&t<=43394)return f.CLUSTER_BREAK.EXTEND}else{if(t===43395)return f.CLUSTER_BREAK.SPACINGMARK;if(t===43443)return f.CLUSTER_BREAK.EXTEND}else if(t<43450){if(t<43446){if(43444<=t&&t<=43445)return f.CLUSTER_BREAK.SPACINGMARK}else if(43446<=t&&t<=43449)return f.CLUSTER_BREAK.EXTEND}else if(t<43452){if(43450<=t&&t<=43451)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43454){if(43452<=t&&t<=43453)return f.CLUSTER_BREAK.EXTEND}else if(43454<=t&&t<=43456)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43573){if(t<43567){if(t<43561){if(t===43493)return f.CLUSTER_BREAK.EXTEND}else if(43561<=t&&t<=43566)return f.CLUSTER_BREAK.EXTEND}else if(t<43569){if(43567<=t&&t<=43568)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43571){if(43569<=t&&t<=43570)return f.CLUSTER_BREAK.EXTEND}else if(43571<=t&&t<=43572)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43597){if(t<43587){if(43573<=t&&t<=43574)return f.CLUSTER_BREAK.EXTEND}else if(t===43587||t===43596)return f.CLUSTER_BREAK.EXTEND}else if(t<43644){if(t===43597)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===43644||t===43696)return f.CLUSTER_BREAK.EXTEND}else if(t<44006){if(t<43756)if(t<43710){if(t<43703){if(43698<=t&&t<=43700)return f.CLUSTER_BREAK.EXTEND}else if(43703<=t&&t<=43704)return f.CLUSTER_BREAK.EXTEND}else if(t<43713){if(43710<=t&&t<=43711)return f.CLUSTER_BREAK.EXTEND}else{if(t===43713)return f.CLUSTER_BREAK.EXTEND;if(t===43755)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<43766){if(t<43758){if(43756<=t&&t<=43757)return f.CLUSTER_BREAK.EXTEND}else if(t<43765){if(43758<=t&&t<=43759)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===43765)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<44003){if(t===43766)return f.CLUSTER_BREAK.EXTEND}else if(t<44005){if(44003<=t&&t<=44004)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===44005)return f.CLUSTER_BREAK.EXTEND}else if(t<44032)if(t<44009){if(t<44008){if(44006<=t&&t<=44007)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===44008)return f.CLUSTER_BREAK.EXTEND}else if(t<44012){if(44009<=t&&t<=44010)return f.CLUSTER_BREAK.SPACINGMARK}else{if(t===44012)return f.CLUSTER_BREAK.SPACINGMARK;if(t===44013)return f.CLUSTER_BREAK.EXTEND}else if(t<44061){if(t<44033){if(t===44032)return f.CLUSTER_BREAK.LV}else if(t<44060){if(44033<=t&&t<=44059)return f.CLUSTER_BREAK.LVT}else if(t===44060)return f.CLUSTER_BREAK.LV}else if(t<44088){if(44061<=t&&t<=44087)return f.CLUSTER_BREAK.LVT}else if(t<44089){if(t===44088)return f.CLUSTER_BREAK.LV}else if(44089<=t&&t<=44115)return f.CLUSTER_BREAK.LVT}else if(t<46497){if(t<45293){if(t<44704){if(t<44397){if(t<44256){if(t<44173){if(t<44144){if(t<44117){if(t===44116)return f.CLUSTER_BREAK.LV}else if(44117<=t&&t<=44143)return f.CLUSTER_BREAK.LVT}else if(t<44145){if(t===44144)return f.CLUSTER_BREAK.LV}else if(t<44172){if(44145<=t&&t<=44171)return f.CLUSTER_BREAK.LVT}else if(t===44172)return f.CLUSTER_BREAK.LV}else if(t<44201){if(t<44200){if(44173<=t&&t<=44199)return f.CLUSTER_BREAK.LVT}else if(t===44200)return f.CLUSTER_BREAK.LV}else if(t<44228){if(44201<=t&&t<=44227)return f.CLUSTER_BREAK.LVT}else if(t<44229){if(t===44228)return f.CLUSTER_BREAK.LV}else if(44229<=t&&t<=44255)return f.CLUSTER_BREAK.LVT}else if(t<44313){if(t<44284){if(t<44257){if(t===44256)return f.CLUSTER_BREAK.LV}else if(44257<=t&&t<=44283)return f.CLUSTER_BREAK.LVT}else if(t<44285){if(t===44284)return f.CLUSTER_BREAK.LV}else if(t<44312){if(44285<=t&&t<=44311)return f.CLUSTER_BREAK.LVT}else if(t===44312)return f.CLUSTER_BREAK.LV}else if(t<44368){if(t<44340){if(44313<=t&&t<=44339)return f.CLUSTER_BREAK.LVT}else if(t<44341){if(t===44340)return f.CLUSTER_BREAK.LV}else if(44341<=t&&t<=44367)return f.CLUSTER_BREAK.LVT}else if(t<44369){if(t===44368)return f.CLUSTER_BREAK.LV}else if(t<44396){if(44369<=t&&t<=44395)return f.CLUSTER_BREAK.LVT}else if(t===44396)return f.CLUSTER_BREAK.LV}else if(t<44537){if(t<44480){if(t<44425){if(t<44424){if(44397<=t&&t<=44423)return f.CLUSTER_BREAK.LVT}else if(t===44424)return f.CLUSTER_BREAK.LV}else if(t<44452){if(44425<=t&&t<=44451)return f.CLUSTER_BREAK.LVT}else if(t<44453){if(t===44452)return f.CLUSTER_BREAK.LV}else if(44453<=t&&t<=44479)return f.CLUSTER_BREAK.LVT}else if(t<44508){if(t<44481){if(t===44480)return f.CLUSTER_BREAK.LV}else if(44481<=t&&t<=44507)return f.CLUSTER_BREAK.LVT}else if(t<44509){if(t===44508)return f.CLUSTER_BREAK.LV}else if(t<44536){if(44509<=t&&t<=44535)return f.CLUSTER_BREAK.LVT}else if(t===44536)return f.CLUSTER_BREAK.LV}else if(t<44620){if(t<44565){if(t<44564){if(44537<=t&&t<=44563)return f.CLUSTER_BREAK.LVT}else if(t===44564)return f.CLUSTER_BREAK.LV}else if(t<44592){if(44565<=t&&t<=44591)return f.CLUSTER_BREAK.LVT}else if(t<44593){if(t===44592)return f.CLUSTER_BREAK.LV}else if(44593<=t&&t<=44619)return f.CLUSTER_BREAK.LVT}else if(t<44649){if(t<44621){if(t===44620)return f.CLUSTER_BREAK.LV}else if(t<44648){if(44621<=t&&t<=44647)return f.CLUSTER_BREAK.LVT}else if(t===44648)return f.CLUSTER_BREAK.LV}else if(t<44676){if(44649<=t&&t<=44675)return f.CLUSTER_BREAK.LVT}else if(t<44677){if(t===44676)return f.CLUSTER_BREAK.LV}else if(44677<=t&&t<=44703)return f.CLUSTER_BREAK.LVT}else if(t<44985){if(t<44844){if(t<44761){if(t<44732){if(t<44705){if(t===44704)return f.CLUSTER_BREAK.LV}else if(44705<=t&&t<=44731)return f.CLUSTER_BREAK.LVT}else if(t<44733){if(t===44732)return f.CLUSTER_BREAK.LV}else if(t<44760){if(44733<=t&&t<=44759)return f.CLUSTER_BREAK.LVT}else if(t===44760)return f.CLUSTER_BREAK.LV}else if(t<44789){if(t<44788){if(44761<=t&&t<=44787)return f.CLUSTER_BREAK.LVT}else if(t===44788)return f.CLUSTER_BREAK.LV}else if(t<44816){if(44789<=t&&t<=44815)return f.CLUSTER_BREAK.LVT}else if(t<44817){if(t===44816)return f.CLUSTER_BREAK.LV}else if(44817<=t&&t<=44843)return f.CLUSTER_BREAK.LVT}else if(t<44901){if(t<44872){if(t<44845){if(t===44844)return f.CLUSTER_BREAK.LV}else if(44845<=t&&t<=44871)return f.CLUSTER_BREAK.LVT}else if(t<44873){if(t===44872)return f.CLUSTER_BREAK.LV}else if(t<44900){if(44873<=t&&t<=44899)return f.CLUSTER_BREAK.LVT}else if(t===44900)return f.CLUSTER_BREAK.LV}else if(t<44956){if(t<44928){if(44901<=t&&t<=44927)return f.CLUSTER_BREAK.LVT}else if(t<44929){if(t===44928)return f.CLUSTER_BREAK.LV}else if(44929<=t&&t<=44955)return f.CLUSTER_BREAK.LVT}else if(t<44957){if(t===44956)return f.CLUSTER_BREAK.LV}else if(t<44984){if(44957<=t&&t<=44983)return f.CLUSTER_BREAK.LVT}else if(t===44984)return f.CLUSTER_BREAK.LV}else if(t<45152){if(t<45068){if(t<45013){if(t<45012){if(44985<=t&&t<=45011)return f.CLUSTER_BREAK.LVT}else if(t===45012)return f.CLUSTER_BREAK.LV}else if(t<45040){if(45013<=t&&t<=45039)return f.CLUSTER_BREAK.LVT}else if(t<45041){if(t===45040)return f.CLUSTER_BREAK.LV}else if(45041<=t&&t<=45067)return f.CLUSTER_BREAK.LVT}else if(t<45097){if(t<45069){if(t===45068)return f.CLUSTER_BREAK.LV}else if(t<45096){if(45069<=t&&t<=45095)return f.CLUSTER_BREAK.LVT}else if(t===45096)return f.CLUSTER_BREAK.LV}else if(t<45124){if(45097<=t&&t<=45123)return f.CLUSTER_BREAK.LVT}else if(t<45125){if(t===45124)return f.CLUSTER_BREAK.LV}else if(45125<=t&&t<=45151)return f.CLUSTER_BREAK.LVT}else if(t<45209){if(t<45180){if(t<45153){if(t===45152)return f.CLUSTER_BREAK.LV}else if(45153<=t&&t<=45179)return f.CLUSTER_BREAK.LVT}else if(t<45181){if(t===45180)return f.CLUSTER_BREAK.LV}else if(t<45208){if(45181<=t&&t<=45207)return f.CLUSTER_BREAK.LVT}else if(t===45208)return f.CLUSTER_BREAK.LV}else if(t<45264){if(t<45236){if(45209<=t&&t<=45235)return f.CLUSTER_BREAK.LVT}else if(t<45237){if(t===45236)return f.CLUSTER_BREAK.LV}else if(45237<=t&&t<=45263)return f.CLUSTER_BREAK.LVT}else if(t<45265){if(t===45264)return f.CLUSTER_BREAK.LV}else if(t<45292){if(45265<=t&&t<=45291)return f.CLUSTER_BREAK.LVT}else if(t===45292)return f.CLUSTER_BREAK.LV}else if(t<45908){if(t<45600){if(t<45433){if(t<45376){if(t<45321){if(t<45320){if(45293<=t&&t<=45319)return f.CLUSTER_BREAK.LVT}else if(t===45320)return f.CLUSTER_BREAK.LV}else if(t<45348){if(45321<=t&&t<=45347)return f.CLUSTER_BREAK.LVT}else if(t<45349){if(t===45348)return f.CLUSTER_BREAK.LV}else if(45349<=t&&t<=45375)return f.CLUSTER_BREAK.LVT}else if(t<45404){if(t<45377){if(t===45376)return f.CLUSTER_BREAK.LV}else if(45377<=t&&t<=45403)return f.CLUSTER_BREAK.LVT}else if(t<45405){if(t===45404)return f.CLUSTER_BREAK.LV}else if(t<45432){if(45405<=t&&t<=45431)return f.CLUSTER_BREAK.LVT}else if(t===45432)return f.CLUSTER_BREAK.LV}else if(t<45516){if(t<45461){if(t<45460){if(45433<=t&&t<=45459)return f.CLUSTER_BREAK.LVT}else if(t===45460)return f.CLUSTER_BREAK.LV}else if(t<45488){if(45461<=t&&t<=45487)return f.CLUSTER_BREAK.LVT}else if(t<45489){if(t===45488)return f.CLUSTER_BREAK.LV}else if(45489<=t&&t<=45515)return f.CLUSTER_BREAK.LVT}else if(t<45545){if(t<45517){if(t===45516)return f.CLUSTER_BREAK.LV}else if(t<45544){if(45517<=t&&t<=45543)return f.CLUSTER_BREAK.LVT}else if(t===45544)return f.CLUSTER_BREAK.LV}else if(t<45572){if(45545<=t&&t<=45571)return f.CLUSTER_BREAK.LVT}else if(t<45573){if(t===45572)return f.CLUSTER_BREAK.LV}else if(45573<=t&&t<=45599)return f.CLUSTER_BREAK.LVT}else if(t<45741){if(t<45657){if(t<45628){if(t<45601){if(t===45600)return f.CLUSTER_BREAK.LV}else if(45601<=t&&t<=45627)return f.CLUSTER_BREAK.LVT}else if(t<45629){if(t===45628)return f.CLUSTER_BREAK.LV}else if(t<45656){if(45629<=t&&t<=45655)return f.CLUSTER_BREAK.LVT}else if(t===45656)return f.CLUSTER_BREAK.LV}else if(t<45712){if(t<45684){if(45657<=t&&t<=45683)return f.CLUSTER_BREAK.LVT}else if(t<45685){if(t===45684)return f.CLUSTER_BREAK.LV}else if(45685<=t&&t<=45711)return f.CLUSTER_BREAK.LVT}else if(t<45713){if(t===45712)return f.CLUSTER_BREAK.LV}else if(t<45740){if(45713<=t&&t<=45739)return f.CLUSTER_BREAK.LVT}else if(t===45740)return f.CLUSTER_BREAK.LV}else if(t<45824){if(t<45769){if(t<45768){if(45741<=t&&t<=45767)return f.CLUSTER_BREAK.LVT}else if(t===45768)return f.CLUSTER_BREAK.LV}else if(t<45796){if(45769<=t&&t<=45795)return f.CLUSTER_BREAK.LVT}else if(t<45797){if(t===45796)return f.CLUSTER_BREAK.LV}else if(45797<=t&&t<=45823)return f.CLUSTER_BREAK.LVT}else if(t<45853){if(t<45825){if(t===45824)return f.CLUSTER_BREAK.LV}else if(t<45852){if(45825<=t&&t<=45851)return f.CLUSTER_BREAK.LVT}else if(t===45852)return f.CLUSTER_BREAK.LV}else if(t<45880){if(45853<=t&&t<=45879)return f.CLUSTER_BREAK.LVT}else if(t<45881){if(t===45880)return f.CLUSTER_BREAK.LV}else if(45881<=t&&t<=45907)return f.CLUSTER_BREAK.LVT}else if(t<46189){if(t<46048){if(t<45965){if(t<45936){if(t<45909){if(t===45908)return f.CLUSTER_BREAK.LV}else if(45909<=t&&t<=45935)return f.CLUSTER_BREAK.LVT}else if(t<45937){if(t===45936)return f.CLUSTER_BREAK.LV}else if(t<45964){if(45937<=t&&t<=45963)return f.CLUSTER_BREAK.LVT}else if(t===45964)return f.CLUSTER_BREAK.LV}else if(t<45993){if(t<45992){if(45965<=t&&t<=45991)return f.CLUSTER_BREAK.LVT}else if(t===45992)return f.CLUSTER_BREAK.LV}else if(t<46020){if(45993<=t&&t<=46019)return f.CLUSTER_BREAK.LVT}else if(t<46021){if(t===46020)return f.CLUSTER_BREAK.LV}else if(46021<=t&&t<=46047)return f.CLUSTER_BREAK.LVT}else if(t<46105){if(t<46076){if(t<46049){if(t===46048)return f.CLUSTER_BREAK.LV}else if(46049<=t&&t<=46075)return f.CLUSTER_BREAK.LVT}else if(t<46077){if(t===46076)return f.CLUSTER_BREAK.LV}else if(t<46104){if(46077<=t&&t<=46103)return f.CLUSTER_BREAK.LVT}else if(t===46104)return f.CLUSTER_BREAK.LV}else if(t<46160){if(t<46132){if(46105<=t&&t<=46131)return f.CLUSTER_BREAK.LVT}else if(t<46133){if(t===46132)return f.CLUSTER_BREAK.LV}else if(46133<=t&&t<=46159)return f.CLUSTER_BREAK.LVT}else if(t<46161){if(t===46160)return f.CLUSTER_BREAK.LV}else if(t<46188){if(46161<=t&&t<=46187)return f.CLUSTER_BREAK.LVT}else if(t===46188)return f.CLUSTER_BREAK.LV}else if(t<46356){if(t<46272){if(t<46217){if(t<46216){if(46189<=t&&t<=46215)return f.CLUSTER_BREAK.LVT}else if(t===46216)return f.CLUSTER_BREAK.LV}else if(t<46244){if(46217<=t&&t<=46243)return f.CLUSTER_BREAK.LVT}else if(t<46245){if(t===46244)return f.CLUSTER_BREAK.LV}else if(46245<=t&&t<=46271)return f.CLUSTER_BREAK.LVT}else if(t<46301){if(t<46273){if(t===46272)return f.CLUSTER_BREAK.LV}else if(t<46300){if(46273<=t&&t<=46299)return f.CLUSTER_BREAK.LVT}else if(t===46300)return f.CLUSTER_BREAK.LV}else if(t<46328){if(46301<=t&&t<=46327)return f.CLUSTER_BREAK.LVT}else if(t<46329){if(t===46328)return f.CLUSTER_BREAK.LV}else if(46329<=t&&t<=46355)return f.CLUSTER_BREAK.LVT}else if(t<46413){if(t<46384){if(t<46357){if(t===46356)return f.CLUSTER_BREAK.LV}else if(46357<=t&&t<=46383)return f.CLUSTER_BREAK.LVT}else if(t<46385){if(t===46384)return f.CLUSTER_BREAK.LV}else if(t<46412){if(46385<=t&&t<=46411)return f.CLUSTER_BREAK.LVT}else if(t===46412)return f.CLUSTER_BREAK.LV}else if(t<46468){if(t<46440){if(46413<=t&&t<=46439)return f.CLUSTER_BREAK.LVT}else if(t<46441){if(t===46440)return f.CLUSTER_BREAK.LV}else if(46441<=t&&t<=46467)return f.CLUSTER_BREAK.LVT}else if(t<46469){if(t===46468)return f.CLUSTER_BREAK.LV}else if(t<46496){if(46469<=t&&t<=46495)return f.CLUSTER_BREAK.LVT}else if(t===46496)return f.CLUSTER_BREAK.LV}else if(t<47701){if(t<47112){if(t<46804){if(t<46637){if(t<46580){if(t<46525){if(t<46524){if(46497<=t&&t<=46523)return f.CLUSTER_BREAK.LVT}else if(t===46524)return f.CLUSTER_BREAK.LV}else if(t<46552){if(46525<=t&&t<=46551)return f.CLUSTER_BREAK.LVT}else if(t<46553){if(t===46552)return f.CLUSTER_BREAK.LV}else if(46553<=t&&t<=46579)return f.CLUSTER_BREAK.LVT}else if(t<46608){if(t<46581){if(t===46580)return f.CLUSTER_BREAK.LV}else if(46581<=t&&t<=46607)return f.CLUSTER_BREAK.LVT}else if(t<46609){if(t===46608)return f.CLUSTER_BREAK.LV}else if(t<46636){if(46609<=t&&t<=46635)return f.CLUSTER_BREAK.LVT}else if(t===46636)return f.CLUSTER_BREAK.LV}else if(t<46720){if(t<46665){if(t<46664){if(46637<=t&&t<=46663)return f.CLUSTER_BREAK.LVT}else if(t===46664)return f.CLUSTER_BREAK.LV}else if(t<46692){if(46665<=t&&t<=46691)return f.CLUSTER_BREAK.LVT}else if(t<46693){if(t===46692)return f.CLUSTER_BREAK.LV}else if(46693<=t&&t<=46719)return f.CLUSTER_BREAK.LVT}else if(t<46749){if(t<46721){if(t===46720)return f.CLUSTER_BREAK.LV}else if(t<46748){if(46721<=t&&t<=46747)return f.CLUSTER_BREAK.LVT}else if(t===46748)return f.CLUSTER_BREAK.LV}else if(t<46776){if(46749<=t&&t<=46775)return f.CLUSTER_BREAK.LVT}else if(t<46777){if(t===46776)return f.CLUSTER_BREAK.LV}else if(46777<=t&&t<=46803)return f.CLUSTER_BREAK.LVT}else if(t<46945){if(t<46861){if(t<46832){if(t<46805){if(t===46804)return f.CLUSTER_BREAK.LV}else if(46805<=t&&t<=46831)return f.CLUSTER_BREAK.LVT}else if(t<46833){if(t===46832)return f.CLUSTER_BREAK.LV}else if(t<46860){if(46833<=t&&t<=46859)return f.CLUSTER_BREAK.LVT}else if(t===46860)return f.CLUSTER_BREAK.LV}else if(t<46916){if(t<46888){if(46861<=t&&t<=46887)return f.CLUSTER_BREAK.LVT}else if(t<46889){if(t===46888)return f.CLUSTER_BREAK.LV}else if(46889<=t&&t<=46915)return f.CLUSTER_BREAK.LVT}else if(t<46917){if(t===46916)return f.CLUSTER_BREAK.LV}else if(t<46944){if(46917<=t&&t<=46943)return f.CLUSTER_BREAK.LVT}else if(t===46944)return f.CLUSTER_BREAK.LV}else if(t<47028){if(t<46973){if(t<46972){if(46945<=t&&t<=46971)return f.CLUSTER_BREAK.LVT}else if(t===46972)return f.CLUSTER_BREAK.LV}else if(t<47e3){if(46973<=t&&t<=46999)return f.CLUSTER_BREAK.LVT}else if(t<47001){if(t===47e3)return f.CLUSTER_BREAK.LV}else if(47001<=t&&t<=47027)return f.CLUSTER_BREAK.LVT}else if(t<47057){if(t<47029){if(t===47028)return f.CLUSTER_BREAK.LV}else if(t<47056){if(47029<=t&&t<=47055)return f.CLUSTER_BREAK.LVT}else if(t===47056)return f.CLUSTER_BREAK.LV}else if(t<47084){if(47057<=t&&t<=47083)return f.CLUSTER_BREAK.LVT}else if(t<47085){if(t===47084)return f.CLUSTER_BREAK.LV}else if(47085<=t&&t<=47111)return f.CLUSTER_BREAK.LVT}else if(t<47393){if(t<47252){if(t<47169){if(t<47140){if(t<47113){if(t===47112)return f.CLUSTER_BREAK.LV}else if(47113<=t&&t<=47139)return f.CLUSTER_BREAK.LVT}else if(t<47141){if(t===47140)return f.CLUSTER_BREAK.LV}else if(t<47168){if(47141<=t&&t<=47167)return f.CLUSTER_BREAK.LVT}else if(t===47168)return f.CLUSTER_BREAK.LV}else if(t<47197){if(t<47196){if(47169<=t&&t<=47195)return f.CLUSTER_BREAK.LVT}else if(t===47196)return f.CLUSTER_BREAK.LV}else if(t<47224){if(47197<=t&&t<=47223)return f.CLUSTER_BREAK.LVT}else if(t<47225){if(t===47224)return f.CLUSTER_BREAK.LV}else if(47225<=t&&t<=47251)return f.CLUSTER_BREAK.LVT}else if(t<47309){if(t<47280){if(t<47253){if(t===47252)return f.CLUSTER_BREAK.LV}else if(47253<=t&&t<=47279)return f.CLUSTER_BREAK.LVT}else if(t<47281){if(t===47280)return f.CLUSTER_BREAK.LV}else if(t<47308){if(47281<=t&&t<=47307)return f.CLUSTER_BREAK.LVT}else if(t===47308)return f.CLUSTER_BREAK.LV}else if(t<47364){if(t<47336){if(47309<=t&&t<=47335)return f.CLUSTER_BREAK.LVT}else if(t<47337){if(t===47336)return f.CLUSTER_BREAK.LV}else if(47337<=t&&t<=47363)return f.CLUSTER_BREAK.LVT}else if(t<47365){if(t===47364)return f.CLUSTER_BREAK.LV}else if(t<47392){if(47365<=t&&t<=47391)return f.CLUSTER_BREAK.LVT}else if(t===47392)return f.CLUSTER_BREAK.LV}else if(t<47560){if(t<47476){if(t<47421){if(t<47420){if(47393<=t&&t<=47419)return f.CLUSTER_BREAK.LVT}else if(t===47420)return f.CLUSTER_BREAK.LV}else if(t<47448){if(47421<=t&&t<=47447)return f.CLUSTER_BREAK.LVT}else if(t<47449){if(t===47448)return f.CLUSTER_BREAK.LV}else if(47449<=t&&t<=47475)return f.CLUSTER_BREAK.LVT}else if(t<47505){if(t<47477){if(t===47476)return f.CLUSTER_BREAK.LV}else if(t<47504){if(47477<=t&&t<=47503)return f.CLUSTER_BREAK.LVT}else if(t===47504)return f.CLUSTER_BREAK.LV}else if(t<47532){if(47505<=t&&t<=47531)return f.CLUSTER_BREAK.LVT}else if(t<47533){if(t===47532)return f.CLUSTER_BREAK.LV}else if(47533<=t&&t<=47559)return f.CLUSTER_BREAK.LVT}else if(t<47617){if(t<47588){if(t<47561){if(t===47560)return f.CLUSTER_BREAK.LV}else if(47561<=t&&t<=47587)return f.CLUSTER_BREAK.LVT}else if(t<47589){if(t===47588)return f.CLUSTER_BREAK.LV}else if(t<47616){if(47589<=t&&t<=47615)return f.CLUSTER_BREAK.LVT}else if(t===47616)return f.CLUSTER_BREAK.LV}else if(t<47672){if(t<47644){if(47617<=t&&t<=47643)return f.CLUSTER_BREAK.LVT}else if(t<47645){if(t===47644)return f.CLUSTER_BREAK.LV}else if(47645<=t&&t<=47671)return f.CLUSTER_BREAK.LVT}else if(t<47673){if(t===47672)return f.CLUSTER_BREAK.LV}else if(t<47700){if(47673<=t&&t<=47699)return f.CLUSTER_BREAK.LVT}else if(t===47700)return f.CLUSTER_BREAK.LV}else if(t<48316){if(t<48008){if(t<47841){if(t<47784){if(t<47729){if(t<47728){if(47701<=t&&t<=47727)return f.CLUSTER_BREAK.LVT}else if(t===47728)return f.CLUSTER_BREAK.LV}else if(t<47756){if(47729<=t&&t<=47755)return f.CLUSTER_BREAK.LVT}else if(t<47757){if(t===47756)return f.CLUSTER_BREAK.LV}else if(47757<=t&&t<=47783)return f.CLUSTER_BREAK.LVT}else if(t<47812){if(t<47785){if(t===47784)return f.CLUSTER_BREAK.LV}else if(47785<=t&&t<=47811)return f.CLUSTER_BREAK.LVT}else if(t<47813){if(t===47812)return f.CLUSTER_BREAK.LV}else if(t<47840){if(47813<=t&&t<=47839)return f.CLUSTER_BREAK.LVT}else if(t===47840)return f.CLUSTER_BREAK.LV}else if(t<47924){if(t<47869){if(t<47868){if(47841<=t&&t<=47867)return f.CLUSTER_BREAK.LVT}else if(t===47868)return f.CLUSTER_BREAK.LV}else if(t<47896){if(47869<=t&&t<=47895)return f.CLUSTER_BREAK.LVT}else if(t<47897){if(t===47896)return f.CLUSTER_BREAK.LV}else if(47897<=t&&t<=47923)return f.CLUSTER_BREAK.LVT}else if(t<47953){if(t<47925){if(t===47924)return f.CLUSTER_BREAK.LV}else if(t<47952){if(47925<=t&&t<=47951)return f.CLUSTER_BREAK.LVT}else if(t===47952)return f.CLUSTER_BREAK.LV}else if(t<47980){if(47953<=t&&t<=47979)return f.CLUSTER_BREAK.LVT}else if(t<47981){if(t===47980)return f.CLUSTER_BREAK.LV}else if(47981<=t&&t<=48007)return f.CLUSTER_BREAK.LVT}else if(t<48149){if(t<48065){if(t<48036){if(t<48009){if(t===48008)return f.CLUSTER_BREAK.LV}else if(48009<=t&&t<=48035)return f.CLUSTER_BREAK.LVT}else if(t<48037){if(t===48036)return f.CLUSTER_BREAK.LV}else if(t<48064){if(48037<=t&&t<=48063)return f.CLUSTER_BREAK.LVT}else if(t===48064)return f.CLUSTER_BREAK.LV}else if(t<48120){if(t<48092){if(48065<=t&&t<=48091)return f.CLUSTER_BREAK.LVT}else if(t<48093){if(t===48092)return f.CLUSTER_BREAK.LV}else if(48093<=t&&t<=48119)return f.CLUSTER_BREAK.LVT}else if(t<48121){if(t===48120)return f.CLUSTER_BREAK.LV}else if(t<48148){if(48121<=t&&t<=48147)return f.CLUSTER_BREAK.LVT}else if(t===48148)return f.CLUSTER_BREAK.LV}else if(t<48232){if(t<48177){if(t<48176){if(48149<=t&&t<=48175)return f.CLUSTER_BREAK.LVT}else if(t===48176)return f.CLUSTER_BREAK.LV}else if(t<48204){if(48177<=t&&t<=48203)return f.CLUSTER_BREAK.LVT}else if(t<48205){if(t===48204)return f.CLUSTER_BREAK.LV}else if(48205<=t&&t<=48231)return f.CLUSTER_BREAK.LVT}else if(t<48261){if(t<48233){if(t===48232)return f.CLUSTER_BREAK.LV}else if(t<48260){if(48233<=t&&t<=48259)return f.CLUSTER_BREAK.LVT}else if(t===48260)return f.CLUSTER_BREAK.LV}else if(t<48288){if(48261<=t&&t<=48287)return f.CLUSTER_BREAK.LVT}else if(t<48289){if(t===48288)return f.CLUSTER_BREAK.LV}else if(48289<=t&&t<=48315)return f.CLUSTER_BREAK.LVT}else if(t<48597){if(t<48456){if(t<48373){if(t<48344){if(t<48317){if(t===48316)return f.CLUSTER_BREAK.LV}else if(48317<=t&&t<=48343)return f.CLUSTER_BREAK.LVT}else if(t<48345){if(t===48344)return f.CLUSTER_BREAK.LV}else if(t<48372){if(48345<=t&&t<=48371)return f.CLUSTER_BREAK.LVT}else if(t===48372)return f.CLUSTER_BREAK.LV}else if(t<48401){if(t<48400){if(48373<=t&&t<=48399)return f.CLUSTER_BREAK.LVT}else if(t===48400)return f.CLUSTER_BREAK.LV}else if(t<48428){if(48401<=t&&t<=48427)return f.CLUSTER_BREAK.LVT}else if(t<48429){if(t===48428)return f.CLUSTER_BREAK.LV}else if(48429<=t&&t<=48455)return f.CLUSTER_BREAK.LVT}else if(t<48513){if(t<48484){if(t<48457){if(t===48456)return f.CLUSTER_BREAK.LV}else if(48457<=t&&t<=48483)return f.CLUSTER_BREAK.LVT}else if(t<48485){if(t===48484)return f.CLUSTER_BREAK.LV}else if(t<48512){if(48485<=t&&t<=48511)return f.CLUSTER_BREAK.LVT}else if(t===48512)return f.CLUSTER_BREAK.LV}else if(t<48568){if(t<48540){if(48513<=t&&t<=48539)return f.CLUSTER_BREAK.LVT}else if(t<48541){if(t===48540)return f.CLUSTER_BREAK.LV}else if(48541<=t&&t<=48567)return f.CLUSTER_BREAK.LVT}else if(t<48569){if(t===48568)return f.CLUSTER_BREAK.LV}else if(t<48596){if(48569<=t&&t<=48595)return f.CLUSTER_BREAK.LVT}else if(t===48596)return f.CLUSTER_BREAK.LV}else if(t<48764){if(t<48680){if(t<48625){if(t<48624){if(48597<=t&&t<=48623)return f.CLUSTER_BREAK.LVT}else if(t===48624)return f.CLUSTER_BREAK.LV}else if(t<48652){if(48625<=t&&t<=48651)return f.CLUSTER_BREAK.LVT}else if(t<48653){if(t===48652)return f.CLUSTER_BREAK.LV}else if(48653<=t&&t<=48679)return f.CLUSTER_BREAK.LVT}else if(t<48709){if(t<48681){if(t===48680)return f.CLUSTER_BREAK.LV}else if(t<48708){if(48681<=t&&t<=48707)return f.CLUSTER_BREAK.LVT}else if(t===48708)return f.CLUSTER_BREAK.LV}else if(t<48736){if(48709<=t&&t<=48735)return f.CLUSTER_BREAK.LVT}else if(t<48737){if(t===48736)return f.CLUSTER_BREAK.LV}else if(48737<=t&&t<=48763)return f.CLUSTER_BREAK.LVT}else if(t<48821){if(t<48792){if(t<48765){if(t===48764)return f.CLUSTER_BREAK.LV}else if(48765<=t&&t<=48791)return f.CLUSTER_BREAK.LVT}else if(t<48793){if(t===48792)return f.CLUSTER_BREAK.LV}else if(t<48820){if(48793<=t&&t<=48819)return f.CLUSTER_BREAK.LVT}else if(t===48820)return f.CLUSTER_BREAK.LV}else if(t<48876){if(t<48848){if(48821<=t&&t<=48847)return f.CLUSTER_BREAK.LVT}else if(t<48849){if(t===48848)return f.CLUSTER_BREAK.LV}else if(48849<=t&&t<=48875)return f.CLUSTER_BREAK.LVT}else if(t<48877){if(t===48876)return f.CLUSTER_BREAK.LV}else if(t<48904){if(48877<=t&&t<=48903)return f.CLUSTER_BREAK.LVT}else if(t===48904)return f.CLUSTER_BREAK.LV}else if(t<53720){if(t<51312){if(t<50108){if(t<49493){if(t<49212){if(t<49045){if(t<48988){if(t<48933){if(t<48932){if(48905<=t&&t<=48931)return f.CLUSTER_BREAK.LVT}else if(t===48932)return f.CLUSTER_BREAK.LV}else if(t<48960){if(48933<=t&&t<=48959)return f.CLUSTER_BREAK.LVT}else if(t<48961){if(t===48960)return f.CLUSTER_BREAK.LV}else if(48961<=t&&t<=48987)return f.CLUSTER_BREAK.LVT}else if(t<49016){if(t<48989){if(t===48988)return f.CLUSTER_BREAK.LV}else if(48989<=t&&t<=49015)return f.CLUSTER_BREAK.LVT}else if(t<49017){if(t===49016)return f.CLUSTER_BREAK.LV}else if(t<49044){if(49017<=t&&t<=49043)return f.CLUSTER_BREAK.LVT}else if(t===49044)return f.CLUSTER_BREAK.LV}else if(t<49128){if(t<49073){if(t<49072){if(49045<=t&&t<=49071)return f.CLUSTER_BREAK.LVT}else if(t===49072)return f.CLUSTER_BREAK.LV}else if(t<49100){if(49073<=t&&t<=49099)return f.CLUSTER_BREAK.LVT}else if(t<49101){if(t===49100)return f.CLUSTER_BREAK.LV}else if(49101<=t&&t<=49127)return f.CLUSTER_BREAK.LVT}else if(t<49157){if(t<49129){if(t===49128)return f.CLUSTER_BREAK.LV}else if(t<49156){if(49129<=t&&t<=49155)return f.CLUSTER_BREAK.LVT}else if(t===49156)return f.CLUSTER_BREAK.LV}else if(t<49184){if(49157<=t&&t<=49183)return f.CLUSTER_BREAK.LVT}else if(t<49185){if(t===49184)return f.CLUSTER_BREAK.LV}else if(49185<=t&&t<=49211)return f.CLUSTER_BREAK.LVT}else if(t<49352){if(t<49269){if(t<49240){if(t<49213){if(t===49212)return f.CLUSTER_BREAK.LV}else if(49213<=t&&t<=49239)return f.CLUSTER_BREAK.LVT}else if(t<49241){if(t===49240)return f.CLUSTER_BREAK.LV}else if(t<49268){if(49241<=t&&t<=49267)return f.CLUSTER_BREAK.LVT}else if(t===49268)return f.CLUSTER_BREAK.LV}else if(t<49297){if(t<49296){if(49269<=t&&t<=49295)return f.CLUSTER_BREAK.LVT}else if(t===49296)return f.CLUSTER_BREAK.LV}else if(t<49324){if(49297<=t&&t<=49323)return f.CLUSTER_BREAK.LVT}else if(t<49325){if(t===49324)return f.CLUSTER_BREAK.LV}else if(49325<=t&&t<=49351)return f.CLUSTER_BREAK.LVT}else if(t<49409){if(t<49380){if(t<49353){if(t===49352)return f.CLUSTER_BREAK.LV}else if(49353<=t&&t<=49379)return f.CLUSTER_BREAK.LVT}else if(t<49381){if(t===49380)return f.CLUSTER_BREAK.LV}else if(t<49408){if(49381<=t&&t<=49407)return f.CLUSTER_BREAK.LVT}else if(t===49408)return f.CLUSTER_BREAK.LV}else if(t<49464){if(t<49436){if(49409<=t&&t<=49435)return f.CLUSTER_BREAK.LVT}else if(t<49437){if(t===49436)return f.CLUSTER_BREAK.LV}else if(49437<=t&&t<=49463)return f.CLUSTER_BREAK.LVT}else if(t<49465){if(t===49464)return f.CLUSTER_BREAK.LV}else if(t<49492){if(49465<=t&&t<=49491)return f.CLUSTER_BREAK.LVT}else if(t===49492)return f.CLUSTER_BREAK.LV}else if(t<49800){if(t<49633){if(t<49576){if(t<49521){if(t<49520){if(49493<=t&&t<=49519)return f.CLUSTER_BREAK.LVT}else if(t===49520)return f.CLUSTER_BREAK.LV}else if(t<49548){if(49521<=t&&t<=49547)return f.CLUSTER_BREAK.LVT}else if(t<49549){if(t===49548)return f.CLUSTER_BREAK.LV}else if(49549<=t&&t<=49575)return f.CLUSTER_BREAK.LVT}else if(t<49604){if(t<49577){if(t===49576)return f.CLUSTER_BREAK.LV}else if(49577<=t&&t<=49603)return f.CLUSTER_BREAK.LVT}else if(t<49605){if(t===49604)return f.CLUSTER_BREAK.LV}else if(t<49632){if(49605<=t&&t<=49631)return f.CLUSTER_BREAK.LVT}else if(t===49632)return f.CLUSTER_BREAK.LV}else if(t<49716){if(t<49661){if(t<49660){if(49633<=t&&t<=49659)return f.CLUSTER_BREAK.LVT}else if(t===49660)return f.CLUSTER_BREAK.LV}else if(t<49688){if(49661<=t&&t<=49687)return f.CLUSTER_BREAK.LVT}else if(t<49689){if(t===49688)return f.CLUSTER_BREAK.LV}else if(49689<=t&&t<=49715)return f.CLUSTER_BREAK.LVT}else if(t<49745){if(t<49717){if(t===49716)return f.CLUSTER_BREAK.LV}else if(t<49744){if(49717<=t&&t<=49743)return f.CLUSTER_BREAK.LVT}else if(t===49744)return f.CLUSTER_BREAK.LV}else if(t<49772){if(49745<=t&&t<=49771)return f.CLUSTER_BREAK.LVT}else if(t<49773){if(t===49772)return f.CLUSTER_BREAK.LV}else if(49773<=t&&t<=49799)return f.CLUSTER_BREAK.LVT}else if(t<49941){if(t<49857){if(t<49828){if(t<49801){if(t===49800)return f.CLUSTER_BREAK.LV}else if(49801<=t&&t<=49827)return f.CLUSTER_BREAK.LVT}else if(t<49829){if(t===49828)return f.CLUSTER_BREAK.LV}else if(t<49856){if(49829<=t&&t<=49855)return f.CLUSTER_BREAK.LVT}else if(t===49856)return f.CLUSTER_BREAK.LV}else if(t<49912){if(t<49884){if(49857<=t&&t<=49883)return f.CLUSTER_BREAK.LVT}else if(t<49885){if(t===49884)return f.CLUSTER_BREAK.LV}else if(49885<=t&&t<=49911)return f.CLUSTER_BREAK.LVT}else if(t<49913){if(t===49912)return f.CLUSTER_BREAK.LV}else if(t<49940){if(49913<=t&&t<=49939)return f.CLUSTER_BREAK.LVT}else if(t===49940)return f.CLUSTER_BREAK.LV}else if(t<50024){if(t<49969){if(t<49968){if(49941<=t&&t<=49967)return f.CLUSTER_BREAK.LVT}else if(t===49968)return f.CLUSTER_BREAK.LV}else if(t<49996){if(49969<=t&&t<=49995)return f.CLUSTER_BREAK.LVT}else if(t<49997){if(t===49996)return f.CLUSTER_BREAK.LV}else if(49997<=t&&t<=50023)return f.CLUSTER_BREAK.LVT}else if(t<50053){if(t<50025){if(t===50024)return f.CLUSTER_BREAK.LV}else if(t<50052){if(50025<=t&&t<=50051)return f.CLUSTER_BREAK.LVT}else if(t===50052)return f.CLUSTER_BREAK.LV}else if(t<50080){if(50053<=t&&t<=50079)return f.CLUSTER_BREAK.LVT}else if(t<50081){if(t===50080)return f.CLUSTER_BREAK.LV}else if(50081<=t&&t<=50107)return f.CLUSTER_BREAK.LVT}else if(t<50697){if(t<50389){if(t<50248){if(t<50165){if(t<50136){if(t<50109){if(t===50108)return f.CLUSTER_BREAK.LV}else if(50109<=t&&t<=50135)return f.CLUSTER_BREAK.LVT}else if(t<50137){if(t===50136)return f.CLUSTER_BREAK.LV}else if(t<50164){if(50137<=t&&t<=50163)return f.CLUSTER_BREAK.LVT}else if(t===50164)return f.CLUSTER_BREAK.LV}else if(t<50193){if(t<50192){if(50165<=t&&t<=50191)return f.CLUSTER_BREAK.LVT}else if(t===50192)return f.CLUSTER_BREAK.LV}else if(t<50220){if(50193<=t&&t<=50219)return f.CLUSTER_BREAK.LVT}else if(t<50221){if(t===50220)return f.CLUSTER_BREAK.LV}else if(50221<=t&&t<=50247)return f.CLUSTER_BREAK.LVT}else if(t<50305){if(t<50276){if(t<50249){if(t===50248)return f.CLUSTER_BREAK.LV}else if(50249<=t&&t<=50275)return f.CLUSTER_BREAK.LVT}else if(t<50277){if(t===50276)return f.CLUSTER_BREAK.LV}else if(t<50304){if(50277<=t&&t<=50303)return f.CLUSTER_BREAK.LVT}else if(t===50304)return f.CLUSTER_BREAK.LV}else if(t<50360){if(t<50332){if(50305<=t&&t<=50331)return f.CLUSTER_BREAK.LVT}else if(t<50333){if(t===50332)return f.CLUSTER_BREAK.LV}else if(50333<=t&&t<=50359)return f.CLUSTER_BREAK.LVT}else if(t<50361){if(t===50360)return f.CLUSTER_BREAK.LV}else if(t<50388){if(50361<=t&&t<=50387)return f.CLUSTER_BREAK.LVT}else if(t===50388)return f.CLUSTER_BREAK.LV}else if(t<50556){if(t<50472){if(t<50417){if(t<50416){if(50389<=t&&t<=50415)return f.CLUSTER_BREAK.LVT}else if(t===50416)return f.CLUSTER_BREAK.LV}else if(t<50444){if(50417<=t&&t<=50443)return f.CLUSTER_BREAK.LVT}else if(t<50445){if(t===50444)return f.CLUSTER_BREAK.LV}else if(50445<=t&&t<=50471)return f.CLUSTER_BREAK.LVT}else if(t<50501){if(t<50473){if(t===50472)return f.CLUSTER_BREAK.LV}else if(t<50500){if(50473<=t&&t<=50499)return f.CLUSTER_BREAK.LVT}else if(t===50500)return f.CLUSTER_BREAK.LV}else if(t<50528){if(50501<=t&&t<=50527)return f.CLUSTER_BREAK.LVT}else if(t<50529){if(t===50528)return f.CLUSTER_BREAK.LV}else if(50529<=t&&t<=50555)return f.CLUSTER_BREAK.LVT}else if(t<50613){if(t<50584){if(t<50557){if(t===50556)return f.CLUSTER_BREAK.LV}else if(50557<=t&&t<=50583)return f.CLUSTER_BREAK.LVT}else if(t<50585){if(t===50584)return f.CLUSTER_BREAK.LV}else if(t<50612){if(50585<=t&&t<=50611)return f.CLUSTER_BREAK.LVT}else if(t===50612)return f.CLUSTER_BREAK.LV}else if(t<50668){if(t<50640){if(50613<=t&&t<=50639)return f.CLUSTER_BREAK.LVT}else if(t<50641){if(t===50640)return f.CLUSTER_BREAK.LV}else if(50641<=t&&t<=50667)return f.CLUSTER_BREAK.LVT}else if(t<50669){if(t===50668)return f.CLUSTER_BREAK.LV}else if(t<50696){if(50669<=t&&t<=50695)return f.CLUSTER_BREAK.LVT}else if(t===50696)return f.CLUSTER_BREAK.LV}else if(t<51004){if(t<50837){if(t<50780){if(t<50725){if(t<50724){if(50697<=t&&t<=50723)return f.CLUSTER_BREAK.LVT}else if(t===50724)return f.CLUSTER_BREAK.LV}else if(t<50752){if(50725<=t&&t<=50751)return f.CLUSTER_BREAK.LVT}else if(t<50753){if(t===50752)return f.CLUSTER_BREAK.LV}else if(50753<=t&&t<=50779)return f.CLUSTER_BREAK.LVT}else if(t<50808){if(t<50781){if(t===50780)return f.CLUSTER_BREAK.LV}else if(50781<=t&&t<=50807)return f.CLUSTER_BREAK.LVT}else if(t<50809){if(t===50808)return f.CLUSTER_BREAK.LV}else if(t<50836){if(50809<=t&&t<=50835)return f.CLUSTER_BREAK.LVT}else if(t===50836)return f.CLUSTER_BREAK.LV}else if(t<50920){if(t<50865){if(t<50864){if(50837<=t&&t<=50863)return f.CLUSTER_BREAK.LVT}else if(t===50864)return f.CLUSTER_BREAK.LV}else if(t<50892){if(50865<=t&&t<=50891)return f.CLUSTER_BREAK.LVT}else if(t<50893){if(t===50892)return f.CLUSTER_BREAK.LV}else if(50893<=t&&t<=50919)return f.CLUSTER_BREAK.LVT}else if(t<50949){if(t<50921){if(t===50920)return f.CLUSTER_BREAK.LV}else if(t<50948){if(50921<=t&&t<=50947)return f.CLUSTER_BREAK.LVT}else if(t===50948)return f.CLUSTER_BREAK.LV}else if(t<50976){if(50949<=t&&t<=50975)return f.CLUSTER_BREAK.LVT}else if(t<50977){if(t===50976)return f.CLUSTER_BREAK.LV}else if(50977<=t&&t<=51003)return f.CLUSTER_BREAK.LVT}else if(t<51145){if(t<51061){if(t<51032){if(t<51005){if(t===51004)return f.CLUSTER_BREAK.LV}else if(51005<=t&&t<=51031)return f.CLUSTER_BREAK.LVT}else if(t<51033){if(t===51032)return f.CLUSTER_BREAK.LV}else if(t<51060){if(51033<=t&&t<=51059)return f.CLUSTER_BREAK.LVT}else if(t===51060)return f.CLUSTER_BREAK.LV}else if(t<51116){if(t<51088){if(51061<=t&&t<=51087)return f.CLUSTER_BREAK.LVT}else if(t<51089){if(t===51088)return f.CLUSTER_BREAK.LV}else if(51089<=t&&t<=51115)return f.CLUSTER_BREAK.LVT}else if(t<51117){if(t===51116)return f.CLUSTER_BREAK.LV}else if(t<51144){if(51117<=t&&t<=51143)return f.CLUSTER_BREAK.LVT}else if(t===51144)return f.CLUSTER_BREAK.LV}else if(t<51228){if(t<51173){if(t<51172){if(51145<=t&&t<=51171)return f.CLUSTER_BREAK.LVT}else if(t===51172)return f.CLUSTER_BREAK.LV}else if(t<51200){if(51173<=t&&t<=51199)return f.CLUSTER_BREAK.LVT}else if(t<51201){if(t===51200)return f.CLUSTER_BREAK.LV}else if(51201<=t&&t<=51227)return f.CLUSTER_BREAK.LVT}else if(t<51257){if(t<51229){if(t===51228)return f.CLUSTER_BREAK.LV}else if(t<51256){if(51229<=t&&t<=51255)return f.CLUSTER_BREAK.LVT}else if(t===51256)return f.CLUSTER_BREAK.LV}else if(t<51284){if(51257<=t&&t<=51283)return f.CLUSTER_BREAK.LVT}else if(t<51285){if(t===51284)return f.CLUSTER_BREAK.LV}else if(51285<=t&&t<=51311)return f.CLUSTER_BREAK.LVT}else if(t<52516){if(t<51901){if(t<51593){if(t<51452){if(t<51369){if(t<51340){if(t<51313){if(t===51312)return f.CLUSTER_BREAK.LV}else if(51313<=t&&t<=51339)return f.CLUSTER_BREAK.LVT}else if(t<51341){if(t===51340)return f.CLUSTER_BREAK.LV}else if(t<51368){if(51341<=t&&t<=51367)return f.CLUSTER_BREAK.LVT}else if(t===51368)return f.CLUSTER_BREAK.LV}else if(t<51397){if(t<51396){if(51369<=t&&t<=51395)return f.CLUSTER_BREAK.LVT}else if(t===51396)return f.CLUSTER_BREAK.LV}else if(t<51424){if(51397<=t&&t<=51423)return f.CLUSTER_BREAK.LVT}else if(t<51425){if(t===51424)return f.CLUSTER_BREAK.LV}else if(51425<=t&&t<=51451)return f.CLUSTER_BREAK.LVT}else if(t<51509){if(t<51480){if(t<51453){if(t===51452)return f.CLUSTER_BREAK.LV}else if(51453<=t&&t<=51479)return f.CLUSTER_BREAK.LVT}else if(t<51481){if(t===51480)return f.CLUSTER_BREAK.LV}else if(t<51508){if(51481<=t&&t<=51507)return f.CLUSTER_BREAK.LVT}else if(t===51508)return f.CLUSTER_BREAK.LV}else if(t<51564){if(t<51536){if(51509<=t&&t<=51535)return f.CLUSTER_BREAK.LVT}else if(t<51537){if(t===51536)return f.CLUSTER_BREAK.LV}else if(51537<=t&&t<=51563)return f.CLUSTER_BREAK.LVT}else if(t<51565){if(t===51564)return f.CLUSTER_BREAK.LV}else if(t<51592){if(51565<=t&&t<=51591)return f.CLUSTER_BREAK.LVT}else if(t===51592)return f.CLUSTER_BREAK.LV}else if(t<51760){if(t<51676){if(t<51621){if(t<51620){if(51593<=t&&t<=51619)return f.CLUSTER_BREAK.LVT}else if(t===51620)return f.CLUSTER_BREAK.LV}else if(t<51648){if(51621<=t&&t<=51647)return f.CLUSTER_BREAK.LVT}else if(t<51649){if(t===51648)return f.CLUSTER_BREAK.LV}else if(51649<=t&&t<=51675)return f.CLUSTER_BREAK.LVT}else if(t<51705){if(t<51677){if(t===51676)return f.CLUSTER_BREAK.LV}else if(t<51704){if(51677<=t&&t<=51703)return f.CLUSTER_BREAK.LVT}else if(t===51704)return f.CLUSTER_BREAK.LV}else if(t<51732){if(51705<=t&&t<=51731)return f.CLUSTER_BREAK.LVT}else if(t<51733){if(t===51732)return f.CLUSTER_BREAK.LV}else if(51733<=t&&t<=51759)return f.CLUSTER_BREAK.LVT}else if(t<51817){if(t<51788){if(t<51761){if(t===51760)return f.CLUSTER_BREAK.LV}else if(51761<=t&&t<=51787)return f.CLUSTER_BREAK.LVT}else if(t<51789){if(t===51788)return f.CLUSTER_BREAK.LV}else if(t<51816){if(51789<=t&&t<=51815)return f.CLUSTER_BREAK.LVT}else if(t===51816)return f.CLUSTER_BREAK.LV}else if(t<51872){if(t<51844){if(51817<=t&&t<=51843)return f.CLUSTER_BREAK.LVT}else if(t<51845){if(t===51844)return f.CLUSTER_BREAK.LV}else if(51845<=t&&t<=51871)return f.CLUSTER_BREAK.LVT}else if(t<51873){if(t===51872)return f.CLUSTER_BREAK.LV}else if(t<51900){if(51873<=t&&t<=51899)return f.CLUSTER_BREAK.LVT}else if(t===51900)return f.CLUSTER_BREAK.LV}else if(t<52208){if(t<52041){if(t<51984){if(t<51929){if(t<51928){if(51901<=t&&t<=51927)return f.CLUSTER_BREAK.LVT}else if(t===51928)return f.CLUSTER_BREAK.LV}else if(t<51956){if(51929<=t&&t<=51955)return f.CLUSTER_BREAK.LVT}else if(t<51957){if(t===51956)return f.CLUSTER_BREAK.LV}else if(51957<=t&&t<=51983)return f.CLUSTER_BREAK.LVT}else if(t<52012){if(t<51985){if(t===51984)return f.CLUSTER_BREAK.LV}else if(51985<=t&&t<=52011)return f.CLUSTER_BREAK.LVT}else if(t<52013){if(t===52012)return f.CLUSTER_BREAK.LV}else if(t<52040){if(52013<=t&&t<=52039)return f.CLUSTER_BREAK.LVT}else if(t===52040)return f.CLUSTER_BREAK.LV}else if(t<52124){if(t<52069){if(t<52068){if(52041<=t&&t<=52067)return f.CLUSTER_BREAK.LVT}else if(t===52068)return f.CLUSTER_BREAK.LV}else if(t<52096){if(52069<=t&&t<=52095)return f.CLUSTER_BREAK.LVT}else if(t<52097){if(t===52096)return f.CLUSTER_BREAK.LV}else if(52097<=t&&t<=52123)return f.CLUSTER_BREAK.LVT}else if(t<52153){if(t<52125){if(t===52124)return f.CLUSTER_BREAK.LV}else if(t<52152){if(52125<=t&&t<=52151)return f.CLUSTER_BREAK.LVT}else if(t===52152)return f.CLUSTER_BREAK.LV}else if(t<52180){if(52153<=t&&t<=52179)return f.CLUSTER_BREAK.LVT}else if(t<52181){if(t===52180)return f.CLUSTER_BREAK.LV}else if(52181<=t&&t<=52207)return f.CLUSTER_BREAK.LVT}else if(t<52349){if(t<52265){if(t<52236){if(t<52209){if(t===52208)return f.CLUSTER_BREAK.LV}else if(52209<=t&&t<=52235)return f.CLUSTER_BREAK.LVT}else if(t<52237){if(t===52236)return f.CLUSTER_BREAK.LV}else if(t<52264){if(52237<=t&&t<=52263)return f.CLUSTER_BREAK.LVT}else if(t===52264)return f.CLUSTER_BREAK.LV}else if(t<52320){if(t<52292){if(52265<=t&&t<=52291)return f.CLUSTER_BREAK.LVT}else if(t<52293){if(t===52292)return f.CLUSTER_BREAK.LV}else if(52293<=t&&t<=52319)return f.CLUSTER_BREAK.LVT}else if(t<52321){if(t===52320)return f.CLUSTER_BREAK.LV}else if(t<52348){if(52321<=t&&t<=52347)return f.CLUSTER_BREAK.LVT}else if(t===52348)return f.CLUSTER_BREAK.LV}else if(t<52432){if(t<52377){if(t<52376){if(52349<=t&&t<=52375)return f.CLUSTER_BREAK.LVT}else if(t===52376)return f.CLUSTER_BREAK.LV}else if(t<52404){if(52377<=t&&t<=52403)return f.CLUSTER_BREAK.LVT}else if(t<52405){if(t===52404)return f.CLUSTER_BREAK.LV}else if(52405<=t&&t<=52431)return f.CLUSTER_BREAK.LVT}else if(t<52461){if(t<52433){if(t===52432)return f.CLUSTER_BREAK.LV}else if(t<52460){if(52433<=t&&t<=52459)return f.CLUSTER_BREAK.LVT}else if(t===52460)return f.CLUSTER_BREAK.LV}else if(t<52488){if(52461<=t&&t<=52487)return f.CLUSTER_BREAK.LVT}else if(t<52489){if(t===52488)return f.CLUSTER_BREAK.LV}else if(52489<=t&&t<=52515)return f.CLUSTER_BREAK.LVT}else if(t<53105){if(t<52797){if(t<52656){if(t<52573){if(t<52544){if(t<52517){if(t===52516)return f.CLUSTER_BREAK.LV}else if(52517<=t&&t<=52543)return f.CLUSTER_BREAK.LVT}else if(t<52545){if(t===52544)return f.CLUSTER_BREAK.LV}else if(t<52572){if(52545<=t&&t<=52571)return f.CLUSTER_BREAK.LVT}else if(t===52572)return f.CLUSTER_BREAK.LV}else if(t<52601){if(t<52600){if(52573<=t&&t<=52599)return f.CLUSTER_BREAK.LVT}else if(t===52600)return f.CLUSTER_BREAK.LV}else if(t<52628){if(52601<=t&&t<=52627)return f.CLUSTER_BREAK.LVT}else if(t<52629){if(t===52628)return f.CLUSTER_BREAK.LV}else if(52629<=t&&t<=52655)return f.CLUSTER_BREAK.LVT}else if(t<52713){if(t<52684){if(t<52657){if(t===52656)return f.CLUSTER_BREAK.LV}else if(52657<=t&&t<=52683)return f.CLUSTER_BREAK.LVT}else if(t<52685){if(t===52684)return f.CLUSTER_BREAK.LV}else if(t<52712){if(52685<=t&&t<=52711)return f.CLUSTER_BREAK.LVT}else if(t===52712)return f.CLUSTER_BREAK.LV}else if(t<52768){if(t<52740){if(52713<=t&&t<=52739)return f.CLUSTER_BREAK.LVT}else if(t<52741){if(t===52740)return f.CLUSTER_BREAK.LV}else if(52741<=t&&t<=52767)return f.CLUSTER_BREAK.LVT}else if(t<52769){if(t===52768)return f.CLUSTER_BREAK.LV}else if(t<52796){if(52769<=t&&t<=52795)return f.CLUSTER_BREAK.LVT}else if(t===52796)return f.CLUSTER_BREAK.LV}else if(t<52964){if(t<52880){if(t<52825){if(t<52824){if(52797<=t&&t<=52823)return f.CLUSTER_BREAK.LVT}else if(t===52824)return f.CLUSTER_BREAK.LV}else if(t<52852){if(52825<=t&&t<=52851)return f.CLUSTER_BREAK.LVT}else if(t<52853){if(t===52852)return f.CLUSTER_BREAK.LV}else if(52853<=t&&t<=52879)return f.CLUSTER_BREAK.LVT}else if(t<52909){if(t<52881){if(t===52880)return f.CLUSTER_BREAK.LV}else if(t<52908){if(52881<=t&&t<=52907)return f.CLUSTER_BREAK.LVT}else if(t===52908)return f.CLUSTER_BREAK.LV}else if(t<52936){if(52909<=t&&t<=52935)return f.CLUSTER_BREAK.LVT}else if(t<52937){if(t===52936)return f.CLUSTER_BREAK.LV}else if(52937<=t&&t<=52963)return f.CLUSTER_BREAK.LVT}else if(t<53021){if(t<52992){if(t<52965){if(t===52964)return f.CLUSTER_BREAK.LV}else if(52965<=t&&t<=52991)return f.CLUSTER_BREAK.LVT}else if(t<52993){if(t===52992)return f.CLUSTER_BREAK.LV}else if(t<53020){if(52993<=t&&t<=53019)return f.CLUSTER_BREAK.LVT}else if(t===53020)return f.CLUSTER_BREAK.LV}else if(t<53076){if(t<53048){if(53021<=t&&t<=53047)return f.CLUSTER_BREAK.LVT}else if(t<53049){if(t===53048)return f.CLUSTER_BREAK.LV}else if(53049<=t&&t<=53075)return f.CLUSTER_BREAK.LVT}else if(t<53077){if(t===53076)return f.CLUSTER_BREAK.LV}else if(t<53104){if(53077<=t&&t<=53103)return f.CLUSTER_BREAK.LVT}else if(t===53104)return f.CLUSTER_BREAK.LV}else if(t<53412){if(t<53245){if(t<53188){if(t<53133){if(t<53132){if(53105<=t&&t<=53131)return f.CLUSTER_BREAK.LVT}else if(t===53132)return f.CLUSTER_BREAK.LV}else if(t<53160){if(53133<=t&&t<=53159)return f.CLUSTER_BREAK.LVT}else if(t<53161){if(t===53160)return f.CLUSTER_BREAK.LV}else if(53161<=t&&t<=53187)return f.CLUSTER_BREAK.LVT}else if(t<53216){if(t<53189){if(t===53188)return f.CLUSTER_BREAK.LV}else if(53189<=t&&t<=53215)return f.CLUSTER_BREAK.LVT}else if(t<53217){if(t===53216)return f.CLUSTER_BREAK.LV}else if(t<53244){if(53217<=t&&t<=53243)return f.CLUSTER_BREAK.LVT}else if(t===53244)return f.CLUSTER_BREAK.LV}else if(t<53328){if(t<53273){if(t<53272){if(53245<=t&&t<=53271)return f.CLUSTER_BREAK.LVT}else if(t===53272)return f.CLUSTER_BREAK.LV}else if(t<53300){if(53273<=t&&t<=53299)return f.CLUSTER_BREAK.LVT}else if(t<53301){if(t===53300)return f.CLUSTER_BREAK.LV}else if(53301<=t&&t<=53327)return f.CLUSTER_BREAK.LVT}else if(t<53357){if(t<53329){if(t===53328)return f.CLUSTER_BREAK.LV}else if(t<53356){if(53329<=t&&t<=53355)return f.CLUSTER_BREAK.LVT}else if(t===53356)return f.CLUSTER_BREAK.LV}else if(t<53384){if(53357<=t&&t<=53383)return f.CLUSTER_BREAK.LVT}else if(t<53385){if(t===53384)return f.CLUSTER_BREAK.LV}else if(53385<=t&&t<=53411)return f.CLUSTER_BREAK.LVT}else if(t<53553){if(t<53469){if(t<53440){if(t<53413){if(t===53412)return f.CLUSTER_BREAK.LV}else if(53413<=t&&t<=53439)return f.CLUSTER_BREAK.LVT}else if(t<53441){if(t===53440)return f.CLUSTER_BREAK.LV}else if(t<53468){if(53441<=t&&t<=53467)return f.CLUSTER_BREAK.LVT}else if(t===53468)return f.CLUSTER_BREAK.LV}else if(t<53524){if(t<53496){if(53469<=t&&t<=53495)return f.CLUSTER_BREAK.LVT}else if(t<53497){if(t===53496)return f.CLUSTER_BREAK.LV}else if(53497<=t&&t<=53523)return f.CLUSTER_BREAK.LVT}else if(t<53525){if(t===53524)return f.CLUSTER_BREAK.LV}else if(t<53552){if(53525<=t&&t<=53551)return f.CLUSTER_BREAK.LVT}else if(t===53552)return f.CLUSTER_BREAK.LV}else if(t<53636){if(t<53581){if(t<53580){if(53553<=t&&t<=53579)return f.CLUSTER_BREAK.LVT}else if(t===53580)return f.CLUSTER_BREAK.LV}else if(t<53608){if(53581<=t&&t<=53607)return f.CLUSTER_BREAK.LVT}else if(t<53609){if(t===53608)return f.CLUSTER_BREAK.LV}else if(53609<=t&&t<=53635)return f.CLUSTER_BREAK.LVT}else if(t<53665){if(t<53637){if(t===53636)return f.CLUSTER_BREAK.LV}else if(t<53664){if(53637<=t&&t<=53663)return f.CLUSTER_BREAK.LVT}else if(t===53664)return f.CLUSTER_BREAK.LV}else if(t<53692){if(53665<=t&&t<=53691)return f.CLUSTER_BREAK.LVT}else if(t<53693){if(t===53692)return f.CLUSTER_BREAK.LV}else if(53693<=t&&t<=53719)return f.CLUSTER_BREAK.LVT}else if(t<70459){if(t<54897){if(t<54308){if(t<54001){if(t<53860){if(t<53777){if(t<53748){if(t<53721){if(t===53720)return f.CLUSTER_BREAK.LV}else if(53721<=t&&t<=53747)return f.CLUSTER_BREAK.LVT}else if(t<53749){if(t===53748)return f.CLUSTER_BREAK.LV}else if(t<53776){if(53749<=t&&t<=53775)return f.CLUSTER_BREAK.LVT}else if(t===53776)return f.CLUSTER_BREAK.LV}else if(t<53805){if(t<53804){if(53777<=t&&t<=53803)return f.CLUSTER_BREAK.LVT}else if(t===53804)return f.CLUSTER_BREAK.LV}else if(t<53832){if(53805<=t&&t<=53831)return f.CLUSTER_BREAK.LVT}else if(t<53833){if(t===53832)return f.CLUSTER_BREAK.LV}else if(53833<=t&&t<=53859)return f.CLUSTER_BREAK.LVT}else if(t<53917){if(t<53888){if(t<53861){if(t===53860)return f.CLUSTER_BREAK.LV}else if(53861<=t&&t<=53887)return f.CLUSTER_BREAK.LVT}else if(t<53889){if(t===53888)return f.CLUSTER_BREAK.LV}else if(t<53916){if(53889<=t&&t<=53915)return f.CLUSTER_BREAK.LVT}else if(t===53916)return f.CLUSTER_BREAK.LV}else if(t<53972){if(t<53944){if(53917<=t&&t<=53943)return f.CLUSTER_BREAK.LVT}else if(t<53945){if(t===53944)return f.CLUSTER_BREAK.LV}else if(53945<=t&&t<=53971)return f.CLUSTER_BREAK.LVT}else if(t<53973){if(t===53972)return f.CLUSTER_BREAK.LV}else if(t<54e3){if(53973<=t&&t<=53999)return f.CLUSTER_BREAK.LVT}else if(t===54e3)return f.CLUSTER_BREAK.LV}else if(t<54141){if(t<54084){if(t<54029){if(t<54028){if(54001<=t&&t<=54027)return f.CLUSTER_BREAK.LVT}else if(t===54028)return f.CLUSTER_BREAK.LV}else if(t<54056){if(54029<=t&&t<=54055)return f.CLUSTER_BREAK.LVT}else if(t<54057){if(t===54056)return f.CLUSTER_BREAK.LV}else if(54057<=t&&t<=54083)return f.CLUSTER_BREAK.LVT}else if(t<54112){if(t<54085){if(t===54084)return f.CLUSTER_BREAK.LV}else if(54085<=t&&t<=54111)return f.CLUSTER_BREAK.LVT}else if(t<54113){if(t===54112)return f.CLUSTER_BREAK.LV}else if(t<54140){if(54113<=t&&t<=54139)return f.CLUSTER_BREAK.LVT}else if(t===54140)return f.CLUSTER_BREAK.LV}else if(t<54224){if(t<54169){if(t<54168){if(54141<=t&&t<=54167)return f.CLUSTER_BREAK.LVT}else if(t===54168)return f.CLUSTER_BREAK.LV}else if(t<54196){if(54169<=t&&t<=54195)return f.CLUSTER_BREAK.LVT}else if(t<54197){if(t===54196)return f.CLUSTER_BREAK.LV}else if(54197<=t&&t<=54223)return f.CLUSTER_BREAK.LVT}else if(t<54253){if(t<54225){if(t===54224)return f.CLUSTER_BREAK.LV}else if(t<54252){if(54225<=t&&t<=54251)return f.CLUSTER_BREAK.LVT}else if(t===54252)return f.CLUSTER_BREAK.LV}else if(t<54280){if(54253<=t&&t<=54279)return f.CLUSTER_BREAK.LVT}else if(t<54281){if(t===54280)return f.CLUSTER_BREAK.LV}else if(54281<=t&&t<=54307)return f.CLUSTER_BREAK.LVT}else if(t<54589){if(t<54448){if(t<54365){if(t<54336){if(t<54309){if(t===54308)return f.CLUSTER_BREAK.LV}else if(54309<=t&&t<=54335)return f.CLUSTER_BREAK.LVT}else if(t<54337){if(t===54336)return f.CLUSTER_BREAK.LV}else if(t<54364){if(54337<=t&&t<=54363)return f.CLUSTER_BREAK.LVT}else if(t===54364)return f.CLUSTER_BREAK.LV}else if(t<54393){if(t<54392){if(54365<=t&&t<=54391)return f.CLUSTER_BREAK.LVT}else if(t===54392)return f.CLUSTER_BREAK.LV}else if(t<54420){if(54393<=t&&t<=54419)return f.CLUSTER_BREAK.LVT}else if(t<54421){if(t===54420)return f.CLUSTER_BREAK.LV}else if(54421<=t&&t<=54447)return f.CLUSTER_BREAK.LVT}else if(t<54505){if(t<54476){if(t<54449){if(t===54448)return f.CLUSTER_BREAK.LV}else if(54449<=t&&t<=54475)return f.CLUSTER_BREAK.LVT}else if(t<54477){if(t===54476)return f.CLUSTER_BREAK.LV}else if(t<54504){if(54477<=t&&t<=54503)return f.CLUSTER_BREAK.LVT}else if(t===54504)return f.CLUSTER_BREAK.LV}else if(t<54560){if(t<54532){if(54505<=t&&t<=54531)return f.CLUSTER_BREAK.LVT}else if(t<54533){if(t===54532)return f.CLUSTER_BREAK.LV}else if(54533<=t&&t<=54559)return f.CLUSTER_BREAK.LVT}else if(t<54561){if(t===54560)return f.CLUSTER_BREAK.LV}else if(t<54588){if(54561<=t&&t<=54587)return f.CLUSTER_BREAK.LVT}else if(t===54588)return f.CLUSTER_BREAK.LV}else if(t<54756){if(t<54672){if(t<54617){if(t<54616){if(54589<=t&&t<=54615)return f.CLUSTER_BREAK.LVT}else if(t===54616)return f.CLUSTER_BREAK.LV}else if(t<54644){if(54617<=t&&t<=54643)return f.CLUSTER_BREAK.LVT}else if(t<54645){if(t===54644)return f.CLUSTER_BREAK.LV}else if(54645<=t&&t<=54671)return f.CLUSTER_BREAK.LVT}else if(t<54701){if(t<54673){if(t===54672)return f.CLUSTER_BREAK.LV}else if(t<54700){if(54673<=t&&t<=54699)return f.CLUSTER_BREAK.LVT}else if(t===54700)return f.CLUSTER_BREAK.LV}else if(t<54728){if(54701<=t&&t<=54727)return f.CLUSTER_BREAK.LVT}else if(t<54729){if(t===54728)return f.CLUSTER_BREAK.LV}else if(54729<=t&&t<=54755)return f.CLUSTER_BREAK.LVT}else if(t<54813){if(t<54784){if(t<54757){if(t===54756)return f.CLUSTER_BREAK.LV}else if(54757<=t&&t<=54783)return f.CLUSTER_BREAK.LVT}else if(t<54785){if(t===54784)return f.CLUSTER_BREAK.LV}else if(t<54812){if(54785<=t&&t<=54811)return f.CLUSTER_BREAK.LVT}else if(t===54812)return f.CLUSTER_BREAK.LV}else if(t<54868){if(t<54840){if(54813<=t&&t<=54839)return f.CLUSTER_BREAK.LVT}else if(t<54841){if(t===54840)return f.CLUSTER_BREAK.LV}else if(54841<=t&&t<=54867)return f.CLUSTER_BREAK.LVT}else if(t<54869){if(t===54868)return f.CLUSTER_BREAK.LV}else if(t<54896){if(54869<=t&&t<=54895)return f.CLUSTER_BREAK.LVT}else if(t===54896)return f.CLUSTER_BREAK.LV}else if(t<69632){if(t<55216){if(t<55037){if(t<54980){if(t<54925){if(t<54924){if(54897<=t&&t<=54923)return f.CLUSTER_BREAK.LVT}else if(t===54924)return f.CLUSTER_BREAK.LV}else if(t<54952){if(54925<=t&&t<=54951)return f.CLUSTER_BREAK.LVT}else if(t<54953){if(t===54952)return f.CLUSTER_BREAK.LV}else if(54953<=t&&t<=54979)return f.CLUSTER_BREAK.LVT}else if(t<55008){if(t<54981){if(t===54980)return f.CLUSTER_BREAK.LV}else if(54981<=t&&t<=55007)return f.CLUSTER_BREAK.LVT}else if(t<55009){if(t===55008)return f.CLUSTER_BREAK.LV}else if(t<55036){if(55009<=t&&t<=55035)return f.CLUSTER_BREAK.LVT}else if(t===55036)return f.CLUSTER_BREAK.LV}else if(t<55120){if(t<55065){if(t<55064){if(55037<=t&&t<=55063)return f.CLUSTER_BREAK.LVT}else if(t===55064)return f.CLUSTER_BREAK.LV}else if(t<55092){if(55065<=t&&t<=55091)return f.CLUSTER_BREAK.LVT}else if(t<55093){if(t===55092)return f.CLUSTER_BREAK.LV}else if(55093<=t&&t<=55119)return f.CLUSTER_BREAK.LVT}else if(t<55149){if(t<55121){if(t===55120)return f.CLUSTER_BREAK.LV}else if(t<55148){if(55121<=t&&t<=55147)return f.CLUSTER_BREAK.LVT}else if(t===55148)return f.CLUSTER_BREAK.LV}else if(t<55176){if(55149<=t&&t<=55175)return f.CLUSTER_BREAK.LVT}else if(t<55177){if(t===55176)return f.CLUSTER_BREAK.LV}else if(55177<=t&&t<=55203)return f.CLUSTER_BREAK.LVT}else if(t<68097){if(t<65279){if(t<64286){if(t<55243){if(55216<=t&&t<=55238)return f.CLUSTER_BREAK.V}else if(55243<=t&&t<=55291)return f.CLUSTER_BREAK.T}else if(t<65024){if(t===64286)return f.CLUSTER_BREAK.EXTEND}else if(t<65056){if(65024<=t&&t<=65039)return f.CLUSTER_BREAK.EXTEND}else if(65056<=t&&t<=65071)return f.CLUSTER_BREAK.EXTEND}else if(t<66045){if(t<65438){if(t===65279)return f.CLUSTER_BREAK.CONTROL}else if(t<65520){if(65438<=t&&t<=65439)return f.CLUSTER_BREAK.EXTEND}else if(65520<=t&&t<=65531)return f.CLUSTER_BREAK.CONTROL}else if(t<66272){if(t===66045)return f.CLUSTER_BREAK.EXTEND}else if(t<66422){if(t===66272)return f.CLUSTER_BREAK.EXTEND}else if(66422<=t&&t<=66426)return f.CLUSTER_BREAK.EXTEND}else if(t<68325){if(t<68108){if(t<68101){if(68097<=t&&t<=68099)return f.CLUSTER_BREAK.EXTEND}else if(68101<=t&&t<=68102)return f.CLUSTER_BREAK.EXTEND}else if(t<68152){if(68108<=t&&t<=68111)return f.CLUSTER_BREAK.EXTEND}else if(t<68159){if(68152<=t&&t<=68154)return f.CLUSTER_BREAK.EXTEND}else if(t===68159)return f.CLUSTER_BREAK.EXTEND}else if(t<69373){if(t<68900){if(68325<=t&&t<=68326)return f.CLUSTER_BREAK.EXTEND}else if(t<69291){if(68900<=t&&t<=68903)return f.CLUSTER_BREAK.EXTEND}else if(69291<=t&&t<=69292)return f.CLUSTER_BREAK.EXTEND}else if(t<69446){if(69373<=t&&t<=69375)return f.CLUSTER_BREAK.EXTEND}else if(t<69506){if(69446<=t&&t<=69456)return f.CLUSTER_BREAK.EXTEND}else if(69506<=t&&t<=69509)return f.CLUSTER_BREAK.EXTEND}else if(t<70016){if(t<69815){if(t<69747){if(t<69634){if(t===69632)return f.CLUSTER_BREAK.SPACINGMARK;if(t===69633)return f.CLUSTER_BREAK.EXTEND}else if(t<69688){if(t===69634)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<69744){if(69688<=t&&t<=69702)return f.CLUSTER_BREAK.EXTEND}else if(t===69744)return f.CLUSTER_BREAK.EXTEND}else if(t<69762){if(t<69759){if(69747<=t&&t<=69748)return f.CLUSTER_BREAK.EXTEND}else if(69759<=t&&t<=69761)return f.CLUSTER_BREAK.EXTEND}else if(t<69808){if(t===69762)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<69811){if(69808<=t&&t<=69810)return f.CLUSTER_BREAK.SPACINGMARK}else if(69811<=t&&t<=69814)return f.CLUSTER_BREAK.EXTEND}else if(t<69888)if(t<69821){if(t<69817){if(69815<=t&&t<=69816)return f.CLUSTER_BREAK.SPACINGMARK}else if(69817<=t&&t<=69818)return f.CLUSTER_BREAK.EXTEND}else if(t<69826){if(t===69821)return f.CLUSTER_BREAK.PREPEND}else{if(t===69826)return f.CLUSTER_BREAK.EXTEND;if(t===69837)return f.CLUSTER_BREAK.PREPEND}else if(t<69933){if(t<69927){if(69888<=t&&t<=69890)return f.CLUSTER_BREAK.EXTEND}else if(t<69932){if(69927<=t&&t<=69931)return f.CLUSTER_BREAK.EXTEND}else if(t===69932)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<69957){if(69933<=t&&t<=69940)return f.CLUSTER_BREAK.EXTEND}else if(t<70003){if(69957<=t&&t<=69958)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===70003)return f.CLUSTER_BREAK.EXTEND}else if(t<70194){if(t<70082){if(t<70067){if(t<70018){if(70016<=t&&t<=70017)return f.CLUSTER_BREAK.EXTEND}else if(t===70018)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70070){if(70067<=t&&t<=70069)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70079){if(70070<=t&&t<=70078)return f.CLUSTER_BREAK.EXTEND}else if(70079<=t&&t<=70080)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70095){if(t<70089){if(70082<=t&&t<=70083)return f.CLUSTER_BREAK.PREPEND}else if(t<70094){if(70089<=t&&t<=70092)return f.CLUSTER_BREAK.EXTEND}else if(t===70094)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70188){if(t===70095)return f.CLUSTER_BREAK.EXTEND}else if(t<70191){if(70188<=t&&t<=70190)return f.CLUSTER_BREAK.SPACINGMARK}else if(70191<=t&&t<=70193)return f.CLUSTER_BREAK.EXTEND}else if(t<70209){if(t<70197){if(t<70196){if(70194<=t&&t<=70195)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===70196)return f.CLUSTER_BREAK.EXTEND}else if(t<70198){if(t===70197)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70206){if(70198<=t&&t<=70199)return f.CLUSTER_BREAK.EXTEND}else if(t===70206)return f.CLUSTER_BREAK.EXTEND}else if(t<70371){if(t<70367){if(t===70209)return f.CLUSTER_BREAK.EXTEND}else if(t<70368){if(t===70367)return f.CLUSTER_BREAK.EXTEND}else if(70368<=t&&t<=70370)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70400){if(70371<=t&&t<=70378)return f.CLUSTER_BREAK.EXTEND}else if(t<70402){if(70400<=t&&t<=70401)return f.CLUSTER_BREAK.EXTEND}else if(70402<=t&&t<=70403)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72343){if(t<71339){if(t<70841){if(t<70512){if(t<70471){if(t<70463){if(t<70462){if(70459<=t&&t<=70460)return f.CLUSTER_BREAK.EXTEND}else if(t===70462)return f.CLUSTER_BREAK.EXTEND}else if(t<70464){if(t===70463)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70465){if(t===70464)return f.CLUSTER_BREAK.EXTEND}else if(70465<=t&&t<=70468)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70487){if(t<70475){if(70471<=t&&t<=70472)return f.CLUSTER_BREAK.SPACINGMARK}else if(70475<=t&&t<=70477)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70498){if(t===70487)return f.CLUSTER_BREAK.EXTEND}else if(t<70502){if(70498<=t&&t<=70499)return f.CLUSTER_BREAK.SPACINGMARK}else if(70502<=t&&t<=70508)return f.CLUSTER_BREAK.EXTEND}else if(t<70725){if(t<70712){if(t<70709){if(70512<=t&&t<=70516)return f.CLUSTER_BREAK.EXTEND}else if(70709<=t&&t<=70711)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<70720){if(70712<=t&&t<=70719)return f.CLUSTER_BREAK.EXTEND}else if(t<70722){if(70720<=t&&t<=70721)return f.CLUSTER_BREAK.SPACINGMARK}else if(70722<=t&&t<=70724)return f.CLUSTER_BREAK.EXTEND}else if(t<70832){if(t<70726){if(t===70725)return f.CLUSTER_BREAK.SPACINGMARK}else if(t===70726||t===70750)return f.CLUSTER_BREAK.EXTEND}else if(t<70833){if(t===70832)return f.CLUSTER_BREAK.EXTEND}else if(t<70835){if(70833<=t&&t<=70834)return f.CLUSTER_BREAK.SPACINGMARK}else if(70835<=t&&t<=70840)return f.CLUSTER_BREAK.EXTEND}else if(t<71096){if(t<70847)if(t<70843){if(t===70841)return f.CLUSTER_BREAK.SPACINGMARK;if(t===70842)return f.CLUSTER_BREAK.EXTEND}else if(t<70845){if(70843<=t&&t<=70844)return f.CLUSTER_BREAK.SPACINGMARK}else{if(t===70845)return f.CLUSTER_BREAK.EXTEND;if(t===70846)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71087){if(t<70849){if(70847<=t&&t<=70848)return f.CLUSTER_BREAK.EXTEND}else if(t<70850){if(t===70849)return f.CLUSTER_BREAK.SPACINGMARK}else if(70850<=t&&t<=70851)return f.CLUSTER_BREAK.EXTEND}else if(t<71088){if(t===71087)return f.CLUSTER_BREAK.EXTEND}else if(t<71090){if(71088<=t&&t<=71089)return f.CLUSTER_BREAK.SPACINGMARK}else if(71090<=t&&t<=71093)return f.CLUSTER_BREAK.EXTEND}else if(t<71216){if(t<71102){if(t<71100){if(71096<=t&&t<=71099)return f.CLUSTER_BREAK.SPACINGMARK}else if(71100<=t&&t<=71101)return f.CLUSTER_BREAK.EXTEND}else if(t<71103){if(t===71102)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71132){if(71103<=t&&t<=71104)return f.CLUSTER_BREAK.EXTEND}else if(71132<=t&&t<=71133)return f.CLUSTER_BREAK.EXTEND}else if(t<71229){if(t<71219){if(71216<=t&&t<=71218)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71227){if(71219<=t&&t<=71226)return f.CLUSTER_BREAK.EXTEND}else if(71227<=t&&t<=71228)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71230){if(t===71229)return f.CLUSTER_BREAK.EXTEND}else if(t<71231){if(t===71230)return f.CLUSTER_BREAK.SPACINGMARK}else if(71231<=t&&t<=71232)return f.CLUSTER_BREAK.EXTEND}else if(t<71999)if(t<71463){if(t<71350){if(t<71341){if(t===71339)return f.CLUSTER_BREAK.EXTEND;if(t===71340)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71342){if(t===71341)return f.CLUSTER_BREAK.EXTEND}else if(t<71344){if(71342<=t&&t<=71343)return f.CLUSTER_BREAK.SPACINGMARK}else if(71344<=t&&t<=71349)return f.CLUSTER_BREAK.EXTEND}else if(t<71453){if(t===71350)return f.CLUSTER_BREAK.SPACINGMARK;if(t===71351)return f.CLUSTER_BREAK.EXTEND}else if(t<71458){if(71453<=t&&t<=71455)return f.CLUSTER_BREAK.EXTEND}else if(t<71462){if(71458<=t&&t<=71461)return f.CLUSTER_BREAK.EXTEND}else if(t===71462)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71984){if(t<71727){if(t<71724){if(71463<=t&&t<=71467)return f.CLUSTER_BREAK.EXTEND}else if(71724<=t&&t<=71726)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71736){if(71727<=t&&t<=71735)return f.CLUSTER_BREAK.EXTEND}else if(t<71737){if(t===71736)return f.CLUSTER_BREAK.SPACINGMARK}else if(71737<=t&&t<=71738)return f.CLUSTER_BREAK.EXTEND}else if(t<71995){if(t<71985){if(t===71984)return f.CLUSTER_BREAK.EXTEND}else if(t<71991){if(71985<=t&&t<=71989)return f.CLUSTER_BREAK.SPACINGMARK}else if(71991<=t&&t<=71992)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<71997){if(71995<=t&&t<=71996)return f.CLUSTER_BREAK.EXTEND}else{if(t===71997)return f.CLUSTER_BREAK.SPACINGMARK;if(t===71998)return f.CLUSTER_BREAK.EXTEND}else if(t<72193)if(t<72145)if(t<72001){if(t===71999)return f.CLUSTER_BREAK.PREPEND;if(t===72e3)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72002){if(t===72001)return f.CLUSTER_BREAK.PREPEND}else{if(t===72002)return f.CLUSTER_BREAK.SPACINGMARK;if(t===72003)return f.CLUSTER_BREAK.EXTEND}else if(t<72156){if(t<72148){if(72145<=t&&t<=72147)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72154){if(72148<=t&&t<=72151)return f.CLUSTER_BREAK.EXTEND}else if(72154<=t&&t<=72155)return f.CLUSTER_BREAK.EXTEND}else if(t<72160){if(72156<=t&&t<=72159)return f.CLUSTER_BREAK.SPACINGMARK}else{if(t===72160)return f.CLUSTER_BREAK.EXTEND;if(t===72164)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72263){if(t<72249){if(t<72243){if(72193<=t&&t<=72202)return f.CLUSTER_BREAK.EXTEND}else if(72243<=t&&t<=72248)return f.CLUSTER_BREAK.EXTEND}else if(t<72250){if(t===72249)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72251){if(t===72250)return f.CLUSTER_BREAK.PREPEND}else if(72251<=t&&t<=72254)return f.CLUSTER_BREAK.EXTEND}else if(t<72281){if(t<72273){if(t===72263)return f.CLUSTER_BREAK.EXTEND}else if(t<72279){if(72273<=t&&t<=72278)return f.CLUSTER_BREAK.EXTEND}else if(72279<=t&&t<=72280)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72324){if(72281<=t&&t<=72283)return f.CLUSTER_BREAK.EXTEND}else if(t<72330){if(72324<=t&&t<=72329)return f.CLUSTER_BREAK.PREPEND}else if(72330<=t&&t<=72342)return f.CLUSTER_BREAK.EXTEND}else if(t<94033){if(t<73104){if(t<72881){if(t<72766){if(t<72751){if(t<72344){if(t===72343)return f.CLUSTER_BREAK.SPACINGMARK}else if(72344<=t&&t<=72345)return f.CLUSTER_BREAK.EXTEND}else if(t<72752){if(t===72751)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<72760){if(72752<=t&&t<=72758)return f.CLUSTER_BREAK.EXTEND}else if(72760<=t&&t<=72765)return f.CLUSTER_BREAK.EXTEND}else if(t<72850){if(t===72766)return f.CLUSTER_BREAK.SPACINGMARK;if(t===72767)return f.CLUSTER_BREAK.EXTEND}else if(t<72873){if(72850<=t&&t<=72871)return f.CLUSTER_BREAK.EXTEND}else if(t<72874){if(t===72873)return f.CLUSTER_BREAK.SPACINGMARK}else if(72874<=t&&t<=72880)return f.CLUSTER_BREAK.EXTEND}else if(t<73018){if(t<72884){if(t<72882){if(t===72881)return f.CLUSTER_BREAK.SPACINGMARK}else if(72882<=t&&t<=72883)return f.CLUSTER_BREAK.EXTEND}else if(t<72885){if(t===72884)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<73009){if(72885<=t&&t<=72886)return f.CLUSTER_BREAK.EXTEND}else if(73009<=t&&t<=73014)return f.CLUSTER_BREAK.EXTEND}else if(t<73030){if(t<73020){if(t===73018)return f.CLUSTER_BREAK.EXTEND}else if(t<73023){if(73020<=t&&t<=73021)return f.CLUSTER_BREAK.EXTEND}else if(73023<=t&&t<=73029)return f.CLUSTER_BREAK.EXTEND}else if(t<73031){if(t===73030)return f.CLUSTER_BREAK.PREPEND}else if(t<73098){if(t===73031)return f.CLUSTER_BREAK.EXTEND}else if(73098<=t&&t<=73102)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<73526){if(t<73459)if(t<73109){if(t<73107){if(73104<=t&&t<=73105)return f.CLUSTER_BREAK.EXTEND}else if(73107<=t&&t<=73108)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<73110){if(t===73109)return f.CLUSTER_BREAK.EXTEND}else{if(t===73110)return f.CLUSTER_BREAK.SPACINGMARK;if(t===73111)return f.CLUSTER_BREAK.EXTEND}else if(t<73474){if(t<73461){if(73459<=t&&t<=73460)return f.CLUSTER_BREAK.EXTEND}else if(t<73472){if(73461<=t&&t<=73462)return f.CLUSTER_BREAK.SPACINGMARK}else if(73472<=t&&t<=73473)return f.CLUSTER_BREAK.EXTEND}else if(t<73475){if(t===73474)return f.CLUSTER_BREAK.PREPEND}else if(t<73524){if(t===73475)return f.CLUSTER_BREAK.SPACINGMARK}else if(73524<=t&&t<=73525)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<78896)if(t<73536){if(t<73534){if(73526<=t&&t<=73530)return f.CLUSTER_BREAK.EXTEND}else if(73534<=t&&t<=73535)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<73537){if(t===73536)return f.CLUSTER_BREAK.EXTEND}else{if(t===73537)return f.CLUSTER_BREAK.SPACINGMARK;if(t===73538)return f.CLUSTER_BREAK.EXTEND}else if(t<92912){if(t<78912){if(78896<=t&&t<=78911)return f.CLUSTER_BREAK.CONTROL}else if(t<78919){if(t===78912)return f.CLUSTER_BREAK.EXTEND}else if(78919<=t&&t<=78933)return f.CLUSTER_BREAK.EXTEND}else if(t<92976){if(92912<=t&&t<=92916)return f.CLUSTER_BREAK.EXTEND}else if(t<94031){if(92976<=t&&t<=92982)return f.CLUSTER_BREAK.EXTEND}else if(t===94031)return f.CLUSTER_BREAK.EXTEND}else if(t<121476){if(t<119143)if(t<113824){if(t<94180){if(t<94095){if(94033<=t&&t<=94087)return f.CLUSTER_BREAK.SPACINGMARK}else if(94095<=t&&t<=94098)return f.CLUSTER_BREAK.EXTEND}else if(t<94192){if(t===94180)return f.CLUSTER_BREAK.EXTEND}else if(t<113821){if(94192<=t&&t<=94193)return f.CLUSTER_BREAK.SPACINGMARK}else if(113821<=t&&t<=113822)return f.CLUSTER_BREAK.EXTEND}else if(t<118576){if(t<118528){if(113824<=t&&t<=113827)return f.CLUSTER_BREAK.CONTROL}else if(118528<=t&&t<=118573)return f.CLUSTER_BREAK.EXTEND}else if(t<119141){if(118576<=t&&t<=118598)return f.CLUSTER_BREAK.EXTEND}else{if(t===119141)return f.CLUSTER_BREAK.EXTEND;if(t===119142)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<119173){if(t<119150){if(t<119149){if(119143<=t&&t<=119145)return f.CLUSTER_BREAK.EXTEND}else if(t===119149)return f.CLUSTER_BREAK.SPACINGMARK}else if(t<119155){if(119150<=t&&t<=119154)return f.CLUSTER_BREAK.EXTEND}else if(t<119163){if(119155<=t&&t<=119162)return f.CLUSTER_BREAK.CONTROL}else if(119163<=t&&t<=119170)return f.CLUSTER_BREAK.EXTEND}else if(t<121344){if(t<119210){if(119173<=t&&t<=119179)return f.CLUSTER_BREAK.EXTEND}else if(t<119362){if(119210<=t&&t<=119213)return f.CLUSTER_BREAK.EXTEND}else if(119362<=t&&t<=119364)return f.CLUSTER_BREAK.EXTEND}else if(t<121403){if(121344<=t&&t<=121398)return f.CLUSTER_BREAK.EXTEND}else if(t<121461){if(121403<=t&&t<=121452)return f.CLUSTER_BREAK.EXTEND}else if(t===121461)return f.CLUSTER_BREAK.EXTEND}else if(t<123628){if(t<122907){if(t<121505){if(t<121499){if(t===121476)return f.CLUSTER_BREAK.EXTEND}else if(121499<=t&&t<=121503)return f.CLUSTER_BREAK.EXTEND}else if(t<122880){if(121505<=t&&t<=121519)return f.CLUSTER_BREAK.EXTEND}else if(t<122888){if(122880<=t&&t<=122886)return f.CLUSTER_BREAK.EXTEND}else if(122888<=t&&t<=122904)return f.CLUSTER_BREAK.EXTEND}else if(t<123023){if(t<122915){if(122907<=t&&t<=122913)return f.CLUSTER_BREAK.EXTEND}else if(t<122918){if(122915<=t&&t<=122916)return f.CLUSTER_BREAK.EXTEND}else if(122918<=t&&t<=122922)return f.CLUSTER_BREAK.EXTEND}else if(t<123184){if(t===123023)return f.CLUSTER_BREAK.EXTEND}else if(t<123566){if(123184<=t&&t<=123190)return f.CLUSTER_BREAK.EXTEND}else if(t===123566)return f.CLUSTER_BREAK.EXTEND}else if(t<127995){if(t<125136){if(t<124140){if(123628<=t&&t<=123631)return f.CLUSTER_BREAK.EXTEND}else if(124140<=t&&t<=124143)return f.CLUSTER_BREAK.EXTEND}else if(t<125252){if(125136<=t&&t<=125142)return f.CLUSTER_BREAK.EXTEND}else if(t<127462){if(125252<=t&&t<=125258)return f.CLUSTER_BREAK.EXTEND}else if(127462<=t&&t<=127487)return f.CLUSTER_BREAK.REGIONAL_INDICATOR}else if(t<917632){if(t<917504){if(127995<=t&&t<=127999)return f.CLUSTER_BREAK.EXTEND}else if(t<917536){if(917504<=t&&t<=917535)return f.CLUSTER_BREAK.CONTROL}else if(917536<=t&&t<=917631)return f.CLUSTER_BREAK.EXTEND}else if(t<917760){if(917632<=t&&t<=917759)return f.CLUSTER_BREAK.CONTROL}else if(t<918e3){if(917760<=t&&t<=917999)return f.CLUSTER_BREAK.EXTEND}else if(918e3<=t&&t<=921599)return f.CLUSTER_BREAK.CONTROL;return f.CLUSTER_BREAK.OTHER}static getEmojiProperty(t){if(t<10160){if(t<9728){if(t<9e3){if(t<8482){if(t<8252){if(t===169||t===174)return f.EXTENDED_PICTOGRAPHIC}else if(t===8252||t===8265)return f.EXTENDED_PICTOGRAPHIC}else if(t<8596){if(t===8482||t===8505)return f.EXTENDED_PICTOGRAPHIC}else if(t<8617){if(8596<=t&&t<=8601)return f.EXTENDED_PICTOGRAPHIC}else if(t<8986){if(8617<=t&&t<=8618)return f.EXTENDED_PICTOGRAPHIC}else if(8986<=t&&t<=8987)return f.EXTENDED_PICTOGRAPHIC}else if(t<9410){if(t<9167){if(t===9e3||t===9096)return f.EXTENDED_PICTOGRAPHIC}else if(t<9193){if(t===9167)return f.EXTENDED_PICTOGRAPHIC}else if(t<9208){if(9193<=t&&t<=9203)return f.EXTENDED_PICTOGRAPHIC}else if(9208<=t&&t<=9210)return f.EXTENDED_PICTOGRAPHIC}else if(t<9654){if(t<9642){if(t===9410)return f.EXTENDED_PICTOGRAPHIC}else if(9642<=t&&t<=9643)return f.EXTENDED_PICTOGRAPHIC}else if(t<9664){if(t===9654)return f.EXTENDED_PICTOGRAPHIC}else if(t<9723){if(t===9664)return f.EXTENDED_PICTOGRAPHIC}else if(9723<=t&&t<=9726)return f.EXTENDED_PICTOGRAPHIC}else if(t<10035){if(t<10004){if(t<9748){if(t<9735){if(9728<=t&&t<=9733)return f.EXTENDED_PICTOGRAPHIC}else if(9735<=t&&t<=9746)return f.EXTENDED_PICTOGRAPHIC}else if(t<9872){if(9748<=t&&t<=9861)return f.EXTENDED_PICTOGRAPHIC}else if(t<9992){if(9872<=t&&t<=9989)return f.EXTENDED_PICTOGRAPHIC}else if(9992<=t&&t<=10002)return f.EXTENDED_PICTOGRAPHIC}else if(t<10013){if(t===10004||t===10006)return f.EXTENDED_PICTOGRAPHIC}else if(t<10017){if(t===10013)return f.EXTENDED_PICTOGRAPHIC}else if(t===10017||t===10024)return f.EXTENDED_PICTOGRAPHIC}else if(t<10067){if(t<10055){if(t<10052){if(10035<=t&&t<=10036)return f.EXTENDED_PICTOGRAPHIC}else if(t===10052)return f.EXTENDED_PICTOGRAPHIC}else if(t<10060){if(t===10055)return f.EXTENDED_PICTOGRAPHIC}else if(t===10060||t===10062)return f.EXTENDED_PICTOGRAPHIC}else if(t<10083){if(t<10071){if(10067<=t&&t<=10069)return f.EXTENDED_PICTOGRAPHIC}else if(t===10071)return f.EXTENDED_PICTOGRAPHIC}else if(t<10133){if(10083<=t&&t<=10087)return f.EXTENDED_PICTOGRAPHIC}else if(t<10145){if(10133<=t&&t<=10135)return f.EXTENDED_PICTOGRAPHIC}else if(t===10145)return f.EXTENDED_PICTOGRAPHIC}else if(t<127489){if(t<12951){if(t<11035){if(t<10548){if(t===10160||t===10175)return f.EXTENDED_PICTOGRAPHIC}else if(t<11013){if(10548<=t&&t<=10549)return f.EXTENDED_PICTOGRAPHIC}else if(11013<=t&&t<=11015)return f.EXTENDED_PICTOGRAPHIC}else if(t<11093){if(t<11088){if(11035<=t&&t<=11036)return f.EXTENDED_PICTOGRAPHIC}else if(t===11088)return f.EXTENDED_PICTOGRAPHIC}else if(t<12336){if(t===11093)return f.EXTENDED_PICTOGRAPHIC}else if(t===12336||t===12349)return f.EXTENDED_PICTOGRAPHIC}else if(t<127340){if(t<126976){if(t===12951||t===12953)return f.EXTENDED_PICTOGRAPHIC}else if(t<127245){if(126976<=t&&t<=127231)return f.EXTENDED_PICTOGRAPHIC}else if(t<127279){if(127245<=t&&t<=127247)return f.EXTENDED_PICTOGRAPHIC}else if(t===127279)return f.EXTENDED_PICTOGRAPHIC}else if(t<127374){if(t<127358){if(127340<=t&&t<=127345)return f.EXTENDED_PICTOGRAPHIC}else if(127358<=t&&t<=127359)return f.EXTENDED_PICTOGRAPHIC}else if(t<127377){if(t===127374)return f.EXTENDED_PICTOGRAPHIC}else if(t<127405){if(127377<=t&&t<=127386)return f.EXTENDED_PICTOGRAPHIC}else if(127405<=t&&t<=127461)return f.EXTENDED_PICTOGRAPHIC}else if(t<128981){if(t<127561){if(t<127535){if(t<127514){if(127489<=t&&t<=127503)return f.EXTENDED_PICTOGRAPHIC}else if(t===127514)return f.EXTENDED_PICTOGRAPHIC}else if(t<127538){if(t===127535)return f.EXTENDED_PICTOGRAPHIC}else if(t<127548){if(127538<=t&&t<=127546)return f.EXTENDED_PICTOGRAPHIC}else if(127548<=t&&t<=127551)return f.EXTENDED_PICTOGRAPHIC}else if(t<128326){if(t<128e3){if(127561<=t&&t<=127994)return f.EXTENDED_PICTOGRAPHIC}else if(128e3<=t&&t<=128317)return f.EXTENDED_PICTOGRAPHIC}else if(t<128640){if(128326<=t&&t<=128591)return f.EXTENDED_PICTOGRAPHIC}else if(t<128884){if(128640<=t&&t<=128767)return f.EXTENDED_PICTOGRAPHIC}else if(128884<=t&&t<=128895)return f.EXTENDED_PICTOGRAPHIC}else if(t<129198){if(t<129096){if(t<129036){if(128981<=t&&t<=129023)return f.EXTENDED_PICTOGRAPHIC}else if(129036<=t&&t<=129039)return f.EXTENDED_PICTOGRAPHIC}else if(t<129114){if(129096<=t&&t<=129103)return f.EXTENDED_PICTOGRAPHIC}else if(t<129160){if(129114<=t&&t<=129119)return f.EXTENDED_PICTOGRAPHIC}else if(129160<=t&&t<=129167)return f.EXTENDED_PICTOGRAPHIC}else if(t<129340){if(t<129292){if(129198<=t&&t<=129279)return f.EXTENDED_PICTOGRAPHIC}else if(129292<=t&&t<=129338)return f.EXTENDED_PICTOGRAPHIC}else if(t<129351){if(129340<=t&&t<=129349)return f.EXTENDED_PICTOGRAPHIC}else if(t<130048){if(129351<=t&&t<=129791)return f.EXTENDED_PICTOGRAPHIC}else if(130048<=t&&t<=131069)return f.EXTENDED_PICTOGRAPHIC;return f.CLUSTER_BREAK.OTHER}}k1.default=Zi;var v_=Mn&&Mn.__importDefault||function(n){return n&&n.__esModule?n:{default:n}};Object.defineProperty(nB,"__esModule",{value:!0});const B_=v_(k1);var T_=nB.default=B_.default;const y_=new T_,Qs=I("text-offset");function zo(n,t){const e=fi(n);let r=0;for(let i=0;i<e.length;i++){const o=e[i],s=mr(o);if(o===t){const l=r+s;return{start:r,end:l}}r+=s}p(Qs,!1,"can not find child in children")}function Un(n,t){p(Qs,t>=0,`invalid offset: ${t}`);const e=qd(n,t),{prev:r,next:i,offset:o}=e;if(!r&&!i&&p(Qs,!1,"invalid offset, no prev & next child at offset"),r!==i)return!0;const s=r;if(p(Qs,s,"no child"),hr(s))return p(Qs,o===0||o===1,`invalid box child offset: ${o}`),!0;const l=s.textContent;p(Qs,l,"no content for text child");const c=y_.splitGraphemes(l),d=new Set;let h=0;return c.forEach(C=>{d.add(h),h+=C.length}),d.add(h),!!d.has(o)}function Go(n,t){if(t===0)return 0;const e=t-1;if(Un(n,e))return e;let r=e-1;for(;!Un(n,r);)r-=1;return r}function Ys(n,t){const e=fu(n);if(p(Qs,t>=0&&t<=e,`invalid offset: ${t}, ${e}`),t===e)return e;const r=t+1;if(Un(n,r))return r;let i=r+1;for(;!Un(n,i);)i+=1;return i}const k_=I("line-offset");function I1(n){const t=Cu(n),e=[];let r=0;for(let i=0;i<t.length;i++){const o=t[i];e.push({start:r,end:o.offset}),r=o.offset}return e.push({start:r,end:fu(n)}),e}function lh(n,t){const e=I1(n);return p(k_,t>=0&&t<e.length,`invalid line index: ${t}, ${e.length}`),e[t]}function iB(n,t){const{lineIndex:e}=y1(n,t);return lh(n,e)}function R_(n){const t=I1(n),e=n.getBoundingClientRect(),r=[];return t.forEach(({start:i,end:o})=>{const s=lt(n,i,"home");let l=Yn(n,s);const c=lt(n,o,"end"),d=Yn(n,c);l.top+l.height/2<d.top&&(l=new DOMRect(e.left-1e4,d.top,1,d.height));const h=new DOMRect(l.left,d.top,d.left-l.left,d.height),C=new DOMRect(e.left,d.top,e.width,d.height);r.push({start:i,end:o,rect:C,contentRect:h})}),r}function w_(n,t,e){const i=R_(n).find(s=>Ns(s.rect,t,e));if(!i)return null;const o=i.contentRect;return t-o.left<o.right-t?lt(n,i.start,"home"):lt(n,i.end,"end")}function oB(n,t,e){const r=Yn(n,t),i=Yn(n,e),o=r.top+r.height/2,s=i.top+i.height/2,l=i.top<o&&o<i.bottom,c=r.top<s&&s<r.bottom;return l&&c}function sB(n){return I1(n).length}const Js=I("find-text-position");function lB(n,t){const{start:e,end:r}=lh(n,t),i=st(n),o=Yn(n,lt(i,e,"home"));if(!(Yn(n,lt(i,r,"end")).top>o.top+o.height/2))return!1;const c=qd(n,e);return p(Js,c.next,"no next child at offset"),p(Js,!cu(c.next),"next child is not text child"),!0}function S_(n,t){const e=st(n);p(Js,lB(n,t),"line is not wrapped");const{start:r,end:i}=lh(n,t),o=lt(e,r,"home");for(let s=r+1;s<=i;s+=1){let l="normal";s===r?l="home":s===i&&(l="end");const c=lt(e,s,l);if(!oB(n,o,c))return s-1}return p(Js,!1,"failed to find wrapped offset"),0}function ah(n,t,e,r,i,o,s){p(Js,nt(n,t),`not a text kind block: ${St(t)}`);const{start:l,end:c}=lh(t,e);let d=l;const h=st(t);if(t===r&&lB(t,e)){const L=S_(t,e);(o==="up"||o==="down"&&oB(t,i,lt(h,l,"home")))&&(d=L+1)}let C=Number.MAX_SAFE_INTEGER;const E=_r(n,r,i),A=s!=null?s:E.left+E.width/2,v=E.top+E.height/2;let R=lt(h,d,"home");for(let L=d;L<=c;L++){if(!Un(t,L))continue;let M="normal";L===l?M="home":L===c&&(M="end");const U=lt(h,L,M),F=Yn(t,U),G=$i(F,A,v);G<C&&(C=G,R=U)}return R}function L_(n,t,e,r,i){return p(Js,nt(n,t),"not a text block"),ah(n,t,sB(t)-1,e,r,"up",i)}function I_(n,t,e,r,i){return p(Js,nt(n,t),"not a text block"),ah(n,t,0,e,r,"down",i)}function D_(n,t,e,r){const{lineIndex:i}=y1(t,e);if(i===sB(t)-1)return null;const o=ah(n,t,i+1,t,e,"down",r);return o||null}function __(n,t){if(t.offset===0)return null;const e=Cu(n),r=e.find(i=>i.offset===t.offset);if(!r){const i=Go(n,t.offset);return e.find(s=>s.offset===i)?{offset:i,type:"home"}:{offset:i,type:"normal"}}if(r.type==="betweenChild"){if(t.type==="home"&&r.childInfo.wrap==="nowrap")return{offset:t.offset,type:"end"};if(r.childInfo.prevWrapped)return{offset:Go(n,t.offset),type:"normal"}}return{offset:Go(n,t.offset),type:"normal"}}function M_(n,t){const e=fu(n);if(t.offset===e)return null;const r=Cu(n),i=r.find(o=>o.offset===t.offset);if(!i){const o=Ys(n,t.offset),s=r.find(l=>l.offset===o);return s?s.type==="betweenChild"?{offset:o,type:"end"}:{offset:o,type:"home"}:{offset:o,type:"normal"}}return i.type==="betweenChild"?i.childInfo.wrap==="nowrap"&&t.type==="end"?{offset:t.offset,type:"home"}:{offset:Ys(n,t.offset),type:"home"}:{offset:Ys(n,t.offset),type:"normal"}}function U_(n,t,e,r){const{lineIndex:i}=y1(t,e);if(i===0)return null;const o=ah(n,t,i-1,t,e,"up",r);return o||null}const O_=I("move-caret");function N_(n,t,e,r){if(r==="ArrowLeft"){const i=__(t,e);return i?lt(st(t),i.offset,i.type):null}if(r==="ArrowRight"){const i=M_(t,e);return i?lt(st(t),i.offset,i.type):null}if(r==="ArrowUp"){const i=U_(n,t,e,n.selection.getSuggestedCaretX());return i?lt(st(t),i.offset,i.type):null}if(r==="ArrowDown"){const i=D_(n,t,e,n.selection.getSuggestedCaretX());return i?lt(st(t),i.offset,i.type):null}p(O_,!1,`invalid navigation direction: ${r}`)}const D1=I("text-range");function P_(n){const t=[];return fi(n).forEach(r=>{const i=Array.from(r.getClientRects()).map(o=>({rect:o,child:r}));t.push(...i)}),t}function F_(n,t,e){const r=P_(n);for(let i=1;i<r.length;i++){const o=r[i-1],s=r[i];if(t>=o.rect.right&&t<=s.rect.left&&e>=o.rect.top&&e<=o.rect.bottom&&e>=s.rect.top&&e<=s.rect.bottom)return zo(n,s.child).start}return null}function K_(n,t,e,r){const i=document.elementsFromPoint(e,r)[0];if(!i||!t.contains(i)||!n.contains(t))return null;const o=i.closest("div[data-type=block-content]>span");if(!o){const M=t.getBoundingClientRect();if(!Ns(M,e,r))return null;const U=F_(t,e,r);if(U!==null){const G=lt(t,U,"normal");return new tn(n,{anchor:G,focus:G})}const F=w_(t,e,r);return F?new tn(n,{anchor:F,focus:F}):null}const s=fi(t);p(D1,s.indexOf(o)!==-1,"failed to find child in children");const l=zo(t,o);p(D1,l,"failed to get child offset");const{start:c}=l;let d,h;Qi(o)||hr(o)?(d=c,h=0):(p(D1,o.firstChild instanceof Text,"child is not text"),d=c+Mb(o.firstChild,e,r),h=0);const C=st(t),A=Cu(t).find(M=>M.offset===d);let v="normal";if(A){const M=lt(C,d,"home"),U=lt(C,d,"end"),F=Yn(t,M),G=Yn(t,U),W=$i(F,e,r),it=$i(G,e,r);v=W<it?"home":"end"}const R=lt(C,d,v);let L;return h&&(L=lt(C,d+h,v)),new tn(n,{anchor:R,focus:L!=null?L:R})}const V_=I("create-text-op");function gr(n,t){p(V_,n,"text is empty");const e={insert:n};return t&&Object.keys(t).length>0&&(e.attributes=t),e}function _1(n,t){if(n.length===0)return[];if(n.indexOf(`
|
|
16
16
|
`)===-1)return[gr(n,t)];const e=n.replace(/\r\n/g,`
|
|
17
17
|
`).replace(/\r/g,`
|
|
18
18
|
`).replace(/\n/g," "),r=[];return e&&r.push(gr(e,t)),r}const ch=I("merge-ops");function M1(n){if(n.length<=1)return n;const t=(i,o)=>i.insert===void 0||o.insert===void 0||i.delete!==void 0||o.delete!==void 0||i.retain!==void 0||o.retain!==void 0||i.attributes!==void 0&&o.attributes===void 0||i.attributes===void 0&&o.attributes!==void 0?!1:i.attributes===void 0?(p(ch,o.attributes===void 0,"op2.attributes is not undefined"),!0):(p(ch,i.attributes&&o.attributes,"op1.attributes && op2.attributes is undefined"),qc.default(i.attributes,o.attributes)),e=[];let r=n[0];e.push(r);for(let i=1;i<n.length;i+=1){const o=n[i];t(r,o)?(p(ch,typeof r.insert=="string","before.insert is not string"),p(ch,typeof o.insert=="string","op.insert is not string"),r.insert+=o.insert):(e.push(o),r=o)}return e}function $_(n){let t;for(t=n.length-1;t>=0;t--){const e=n[t];if(!e.attributes||!e.attributes.box||e.attributes.type!=="br")break}return t===n.length-1?n:n.slice(0,t+1)}const aB=I("delete-text");function U1(n,t,e){const{left:r,right:i}=Xe(n,t,e),o=[...r,...i];return M1(o)}function cB(n,t){p(aB,n>=0,`invalid offset: ${n}`),p(aB,t>=1,`invalid delete count: ${t}`);const e=[];return n!==0&&e.push({retain:n}),e.push({delete:t}),e}const uB=I("delta");function fB(n,t){const e=new cn.default(n),r=new cn.default(t);return e.diff(r).ops}function H_(n,t,e){return new cn.default(t).transformPosition(n,!e)}function j_(n){p(uB,n,"ops is null or undefined");for(let t=0;t<n.length;t++){const e=n[t];if(e.insert===null||e.insert===void 0||e.retain!==void 0||e.delete!==void 0)return!1}return!0}function z_(n,t){const e=new cn.default(n),r=new cn.default(t);return e.compose(r).ops}class fn{static ensureValidText(t){p(uB,j_(t),`text is not a valid text, ${JSON.stringify(t)}`)}static diff(t,e){return this.ensureValidText(t),this.ensureValidText(e),fB(t,e)}static transformCursor(t,e,r){return H_(t,e,r)}static transformOffset(t,e,r){const i=fB(t,e),o=new cn.default(i);return r.map(s=>o.transformPosition(s))}static apply(t,e){this.ensureValidText(t);const r=z_(t,e);return this.ensureValidText(r),r}}const dB=I("insert-text");function to(n,t,e,r){p(dB,e,`invalid text to insert: ${e}`);const{left:i,right:o}=_n(n,t),s=typeof e=="string"?[gr(e,r)]:e,l=[...i,...s,...o];return M1(l)}function hB(n){return{insert:" ",attributes:n}}function uh(n,t,e){if(p(dB,n>=0,`invalid offset: ${n}`),t.length===0)return[];const r=[];if(n>0&&r.push({retain:n}),typeof t!="string")return r.push(...t),r;const o={insert:t.replaceAll(`\r
|
|
@@ -21,14 +21,14 @@ Available method signatures are:
|
|
|
21
21
|
`).map((i,o)=>{const l=o===0&&(t==null?void 0:t.firstLineAsTitle)?{heading:1}:void 0;return pi(i,l)})},meta:{},comments:{}}}function P1(n){const t=n.blocks.root;if(t.length!==1)return!1;const e=t[0];return!(!e.text||un(e.text))}function CB(n,t){const e=Z();return n.localInsertChildContainers([{containerId:e,blocks:t}]),e}function no(n,t){return CB(n,[dh(t)])}function EB(n){return typeof n.offset=="number"}function hh(n){return EB(n.anchor)}function Q_(n){return hh(n)&&n.anchor.offset===n.focus.offset&&n.anchor.blockId===n.focus.blockId}function xB(n,t){return{blockId:n,offset:t}}function mh(n,t){const e=xB(n,t);return{anchor:e,focus:e}}function AB(n,t){return{blockId:n,childContainerId:t}}function Y_(n,t){const e=AB(n,t);return{anchor:e,focus:e}}const J_=I("block-to-text");function Z_(n,t,e){let r="";return t.forEach(i=>{if(p(J_,typeof i.insert=="string","invalid op"),i.attributes&&i.attributes.box===!0){const o=i.attributes,s=n.editorBoxes.getBoxClass(o.type);if(s!=null&&s.convertTo){r+=s.convertTo(n,o,e,"text");return}if(i.attributes.text){r+=i.attributes.text;return}r+=`[${o.type}]`}r+=i.insert}),r}const tM=I("block-to-text");function eM(n,t,e){let r="";return t.forEach(i=>{if(p(tM,typeof i.insert=="string","invalid op"),i.attributes&&i.attributes.box===!0){const s=i.attributes,l=n.editorBoxes.getBoxClass(s.type);if(l!=null&&l.convertTo){r+=l.convertTo(n,s,e,"markdown");return}if(i.attributes.text){r+=i.attributes.text;return}r+=`[${s.type}]`}const o=i.attributes;if(o){let s=i.insert;o.link&&(s=`[${s}](${o.link})`);const l=[];o["style-code"]?l.push("`"):(o["style-bold"]&&l.push("**"),o["style-italic"]&&l.push("*"),o["style-underline"]&&l.push("__"),o["style-strikethrough"]&&l.push("~~"));const c=l.join("");r.endsWith(c.substring(0,1))&&(r+=" ");const d=l.reverse().join("");r+=c+s+d;return}r+=i.insert}),r}function nM(n,t,e){const r=t.text||[];let o=eM(n,r,e);if(t.heading){const s=t.heading;o=`${"#".repeat(s)} ${o}`}return t.quoted&&(o=`> ${o}`),t.type==="text"&&(o=`${o}
|
|
22
22
|
`),o}function rM(n){switch(n){case"style-color-0":return"#e52727";case"style-color-1":return"#eb6414";case"style-color-2":return"#f0a100";case"style-color-3":return"#24b47e";case"style-color-4":return"#0064ff";case"style-color-5":return"#9678d3";case"style-color-6":return"#909090";default:return}}function iM(n){switch(n){case"style-bg-color-0":return"#fad4d4";case"style-bg-color-1":return"#fbe0d0";case"style-bg-color-2":return"#fceccc";case"style-bg-color-3":return"#d3f0e5";case"style-bg-color-4":return"#d6e9fa";case"style-bg-color-5":return"#eae4f6";case"style-bg-color-6":return"#dedede";case"style-bg-color-7":return"#e52727";case"style-bg-color-8":return"#eb6414";case"style-bg-color-9":return"#f0a100";case"style-bg-color-10":return"#24b47e";case"style-bg-color-11":return"#0064ff";case"style-bg-color-12":return"#9678d3";case"style-bg-color-13":return"#909090";case"style-bg-color-14":return"#e8e8e8";default:return}}const oM=I("block-to-text");function sM(n,t,e){let r="";return t.forEach(i=>{if(p(oM,typeof i.insert=="string","invalid op"),i.attributes&&i.attributes.box===!0){const s=i.attributes,l=n.editorBoxes.getBoxClass(s.type);if(l!=null&&l.convertTo){r+=l.convertTo(n,s,e,"html");return}if(i.attributes.text){r+=i.attributes.text;return}r+=`[${s.type}]`}const o=i.attributes;if(o){let s=i.insert;const l=[];let c="";o["style-bold"]&&l.push("strong"),o["style-italic"]&&l.push("em"),o["style-underline"]&&l.push("u"),o["style-strikethrough"]&&l.push("s"),o["style-code"]&&l.push("code");const d=Object.keys(o).find(A=>A.startsWith("style-bg-color-"));d&&(c+=`background-color: ${iM(d)};`);const h=Object.keys(o).find(A=>A.startsWith("style-color-"));h&&(c+=`color: ${rM(h)};`),o.link&&(s=`<a href="${o.link}">${s}</a>`);let C=l.map(A=>`<${A}>`).join(""),E=l.reverse().map(A=>`</${A}>`).join("");c&&(o.link?s=`<a href="${o.link}" style="${c}">${i.insert}</a>`:C?C=C.replace(">",` style="${c}">`):(C=`<span style="${c}">`,E="</span>")),r+=C+s+E;return}r+=i.insert}),r||(r="<br>"),`<p>${r}</p>`}const va=I("text-block");function lM(n,t,e,r,i){const{text:o}=i;p(va,o,"no text for text block");const s=Hs(r,"div");return oh(n,t,i.id,s,o),s}function aM(n,t,e){p(va,e,"no text to update");const r=Hs(null,"div");oh(n,Vo(t),st(t),r,e);const i=Ot(t);tu(i,r)}function cM(n,t,e){return d_(n,t,e)}function bB(n,t){let e="";return t.forEach(r=>{var i,o;if(!!r.insert){if(r.attributes&&r.attributes.box===!0){const s=n.getBoxById(r.attributes.id),l=(o=(i=n.editorBoxes.getBoxClass(r.attributes.type)).getBoxProperties)==null?void 0:o.call(i,n,s);e+=l!=null&&l.abstract?` [${l.abstract}] `:" ";return}e+=r.insert}}),e.trim()}function uM(n,t){p(va,nt(n,t),"block in not textBlock");const e=n.selection.range;let r="";if(e.isCollapsed()){const i=n.getBlockText(t);r=bB(n,i)}else{const i=st(t),o=hi(n,{simpleBlockOnly:!0}).find(s=>st(s.block)===i);if(o&&!ie(n,o.block)){p(va,o.block===t,"block not match");const s=n.getBlockText(t),{start:l,end:c}=o,d=l.offset,h=c.offset-d;if(h>0){const{middle:C}=Xe(s,d,h);r=bB(n,C)}}}return{abstract:r.trim()}}function fM(n,t,e,r){return p(va,t.text,"no text for text block"),r==="text"?Z_(n,t.text,e):r==="markdown"?nM(n,t,e):sM(n,t.text,e)}function dM(n,t){const e=gt.default(t);e.id=Z();const{text:r}=e;return p(va,r,"no text for text block"),r.forEach(i=>{i.insert&&i.attributes&&i.attributes.box===!0&&(i.attributes.id=Z())}),{blocks:{root:[e]},meta:{},comments:{}}}const On={blockType:"text",blockKind:"text",createBlockContent:lM,getBlockTextLength:fu,getRangeFromPoint:K_,moveCaret:N_,updateSelection:h_,clearSelection:m_,getCaretRect:Yn,getClientRects:cM,setBlockText:aM,getBlockProperties:uM,convertTo:fM,blockToDoc:dM},hM=oh,gh=I("action-helper");function Wo(n,t){const e=rt(t),r=ft(e),i=bt(t);return n.doc.getBlockData(r,i)}function bn(n,t){p(gh,nt(n,t),"not a text kind block");const r=Wo(n,t).text;return p(gh,r,"no text in block"),r}function ph(n,t,e){return _n(bn(n,t),e).left}function vB(n,t){const e=et(t);p(gh,e,"no parent block");const r=bn(n,e),i=Sv(t),o=r.find(s=>{const l=s.attributes;return l?l.box&&l.id===i:!1});return p(gh,o,"failed to find box"),o.attributes}const Ae=I("block-text");function mM(n,t,e){p(Ae,nt(n,t),"not a text kind block"),p(Ae,Un(t,e),"not a valid offset"),p(Ae,e>=0&&e<dt(n,t),`invalid offset: ${e}`);const i=Ys(t,e)-e;i===0&&p(Ae,!1,`no text after offset: ${e}`);const o=bn(n,t),{middle:s}=Xe(o,e,i);p(Ae,s.length===1,"failed to split text to 3 parts");const l=s[0];return jo(l)?" ":(p(Ae,l.insert.length===1||l.insert.length===2,"invalid op"),l.insert)}function gM(n,t,e){p(Ae,nt(n,t),"not a text kind block"),p(Ae,Un(t,e),"not a valid offset"),p(Ae,e>0&&e<=dt(n,t),`invalid offset: ${e}`);const r=Go(t,e),i=e-r;i===0&&p(Ae,!1,`no text before offset: ${e}`);const o=bn(n,t),{middle:s}=Xe(o,r,i);p(Ae,s.length===1,"failed to split text to 3 parts");const l=s[0];return jo(l)?" ":(p(Ae,l.insert.length===1||l.insert.length===2,"invalid op"),l.insert)}function Ch(n,t,e){p(Ae,nt(n,t),"not a text kind block"),p(Ae,Un(t,e),"not a valid offset"),p(Ae,e>0&&e<=dt(n,t),`invalid offset: ${e}`);const r=Go(t,e),i=e-r;i===0&&p(Ae,!1,`no text before offset: ${e}`);const o=bn(n,t),{middle:s}=Xe(o,r,i);p(Ae,s.length===1,"failed to split text to 3 parts");const l=s[0];return jo(l)?{op:l,charType:"box",offset:r,length:1}:{op:l,charType:Od(l.insert)?"space":"text",offset:r,length:l.insert.length}}function Eu(n,t,e){p(Ae,nt(n,t),"not a text kind block"),p(Ae,Un(t,e),"not a valid offset"),p(Ae,e>=0&&e<dt(n,t),`invalid offset: ${e}`);const i=Ys(t,e)-e;i===0&&p(Ae,!1,`no text after offset: ${e}`);const o=bn(n,t),{middle:s}=Xe(o,e,i);p(Ae,s.length===1,"failed to split text to 3 parts");const l=s[0];return jo(l)?{op:l,charType:"box",offset:e,length:1}:{op:l,charType:Od(l.insert)?"space":"text",offset:e,length:l.insert.length}}function pM(n,t,e,r){let i=e;for(;i>0;){const o=Ch(n,t,i);if(o.charType===r)return o;i-=o.length}return null}function CM(n,t,e,r){const i=dt(n,t);let o=e;for(;o<i;){const s=Eu(n,t,o);if(s.charType===r)return s;o+=s.length}return null}function F1(n,t,e,r){let i=e;for(;i>0;){const o=Ch(n,t,i);if(o.charType!==r)return o;i-=o.length}return null}function K1(n,t,e,r){const i=dt(n,t);let o=e;for(;o<i;){const s=Eu(n,t,o);if(s.charType!==r)return s;o+=s.length}return null}function V1(n,t,e){if(p(Ae,nt(n,t),"invalid blok type"),ie(n,t))return 0;const r=Ch(n,t,e);if(r.charType==="box")return e-1;let i=e;if(r.charType==="space"){const s=F1(n,t,i,"space");if(!s||s.offset===0)return 0;if(s.charType==="box")return s.offset;i=s.offset}const o=F1(n,t,i,"text");return o?o.offset+o.length:0}function $1(n,t,e){if(p(Ae,nt(n,t),"invalid blok type"),ie(n,t))return 0;const r=Eu(n,t,e);if(r.charType==="box")return e+1;let i=e;if(r.charType==="space"){const s=K1(n,t,i,"space");if(!s||s.offset===0)return dt(n,t);if(s.charType==="box")return s.offset;i=s.offset}const o=K1(n,t,i,"text");return o?o.offset:dt(n,t)}const BB=I("text-box");function EM(n,t,e,r){p(BB,r.text,`no text for text box data: ${JSON.stringify(r)}`),p(BB,typeof r.text=="string",`invalid text type for text box data: ${JSON.stringify(r)}`),B("span",[],e,r.text)}function xM(n,t,e,r){var i;return(i=t.text)!=null?i:""}const TB={boxType:"text",updateBoxContent:EM,convertTo:xM},AM="data:image/svg+xml;base64,Cjxzdmcgdmlld0JveD0iMCAwIDI0IDI0IiB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciPgo8cGF0aCBkPSJNMTguMjQ0NSA2QzE3LjgyNzQgNiAxNy41MzYzIDYuMjkxMTcgMTcuNTM2MyA2LjcwODI2QzE3LjUzNjMgNi45ODM3IDE3LjU1OTkgNy4yMzU1MyAxNy41NTk5IDcuNjEzMjdDMTcuNTU5OSAxMC4yODExIDE2LjYyMzQgMTEuMzc0OSAxMy45NzkyIDExLjM3NDlIOC45NDI2Nkw3LjEyNDc5IDExLjQ4NTFMOS41NDA3NSA5LjI4MTYyTDExLjE5MzQgNy41OTc1M0MxMS4zMjcxIDcuNDcxNjEgMTEuMzk4IDcuMjgyNzQgMTEuMzk4IDcuMDkzODdDMTEuMzk4IDYuNjkyNTIgMTEuMDk4OSA2LjQwMTM1IDEwLjY5NzYgNi40MDEzNUMxMC41MDg3IDYuNDAxMzUgMTAuMzM1NiA2LjQ3MjE4IDEwLjE3ODIgNi42MjE3TDUuMjQzOTYgMTEuNTQ4MUM1LjA4NjU3IDExLjcwNTUgNSAxMS44OTQzIDUgMTIuMDkxMUM1IDEyLjI4NzggNS4wODY1NyAxMi40NzY3IDUuMjQzOTYgMTIuNjI2MkwxMC4xNjI1IDE3LjUzNjhDMTAuMzM1NiAxNy43MDk5IDEwLjUwODcgMTcuNzgwOCAxMC42OTc2IDE3Ljc4MDhDMTEuMDk4OSAxNy43ODA4IDExLjM5OCAxNy40ODk2IDExLjM5OCAxNy4wODgzQzExLjM5OCAxNi44OTE1IDExLjMyNzEgMTYuNzEwNSAxMS4xOTM0IDE2LjU4NDZMOS41NDA3NSAxNC45MDA1TDcuMTMyNjYgMTIuNjk3TDguOTQyNjYgMTIuODA3MkgxNC4wNTc5QzE3LjU1OTkgMTIuODA3MiAxOSAxMS4yNDExIDE5IDcuNjc2MjJDMTkgNy4yMzU1MyAxOC45OTIxIDYuODY1NjUgMTguOTM3IDYuNjEzODNDMTguODc0MSA2LjI5OTA0IDE4LjY3NzMgNiAxOC4yNDQ1IDZaIiBmaWxsPSIjQjJCQ0NEIi8+Cjwvc3ZnPgo=";function bM(n,t,e,r){Rg(AM,[],e),B("br",[],e)}function vM(n,t,e,r){return r==="text"?`
|
|
23
23
|
`:r==="html"?"<br>":r==="markdown"?`
|
|
24
|
-
`:""}const yB={boxType:"br",updateBoxContent:bM,convertTo:vM},kB=I("editor-boxes");class RB{constructor(t){m(this,"boxes",new Map);this.editor=t}registerBoxClass(t){const e=t.boxType,r=this.boxes.get(e);p(kB,!r,`duplicated box type: ${e}`),this.boxes.set(e,t)}getBoxClass(t){const e=this.boxes.get(t);return p(kB,e,`unknown box type: ${t}`),e}createBox(t,e){const r=wv(e),i=Lv(r);return this.getBoxClass(e.type).updateBoxContent(this.editor,r,i,e),r}forEach(t){this.boxes.forEach(t)}}function BM(n,t,e,r){const i=r,{width:o,height:s,src:l}=i,c=["editor-box-image"];i.link&&c.push("editor-box-image-link");const d=B("img",c,e);o&&(d.style.width=`${o}px`),s&&(d.style.height=`${s}px`),d.src=n.doc.buildResourceUrl(l)}const wB={boxType:"image",updateBoxContent:BM},TM="data:image/svg+xml;base64,Cjxzdmcgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiB2aWV3Qm94PSIwIDAgMjQgMjQiIGZpbGw9InJnYigxNzgsIDE4OCwgMjA1KSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0ibTE3IDE1IDEuNTUgMS41NWMtLjk2IDEuNjktMy4zMyAzLjA0LTUuNTUgMy4zN1YxMWgzVjloLTNWNy44MkMxNC4xNiA3LjQgMTUgNi4zIDE1IDVjMC0xLjY1LTEuMzUtMy0zLTNTOSAzLjM1IDkgNWMwIDEuMy44NCAyLjQgMiAyLjgyVjlIOHYyaDN2OC45MmMtMi4yMi0uMzMtNC41OS0xLjY4LTUuNTUtMy4zN0w3IDE1bC00LTN2M2MwIDMuODggNC45MiA3IDkgN3M5LTMuMTIgOS03di0zbC00IDN6TTEyIDRjLjU1IDAgMSAuNDUgMSAxcy0uNDUgMS0xIDEtMS0uNDUtMS0xIC40NS0xIDEtMXoiPjwvcGF0aD4KPC9zdmc+Cg==";function yM(n,t,e){z(e,"editor-box-anchor"),Rg(TM,[],e)}const SB={boxType:"anchor",updateBoxContent:yM};function kM(n,t,e,r){B("span",[],e,r.text)}const LB={insertionType:"inputting",updateInsertionContent:kM},IB=I("editor-insertion");class DB{constructor(t){m(this,"insertions",new Map);this.editor=t}registerInsertionClass(t){const e=t.insertionType,r=this.insertions.get(e);p(IB,!r,`duplicated insertion type: ${e}`),this.insertions.set(e,t)}getInsertionClass(t){const e=this.insertions.get(t);return p(IB,e,`unknown insertion type: ${t}`),e}createInsertion(t,e){const r=Iv(e.type,e.id,e.attributes),i=_v(r);return this.getInsertionClass(e.type).updateInsertionContent(this.editor,r,i,e),r}}class RM{constructor(t){m(this,"cursors",new Map);m(this,"timer");this.editor=t,this.timer=this.startTimer()}add(t,e){this.cursors.set(t,e)}startTimer(){return setInterval(()=>{const t=Date.now();Array.from(this.cursors).forEach(([e,r])=>{if(t-r>3e3){const i=Dv(this.editor,e);i&&ot(i,"active"),this.cursors.delete(e)}})},1e3)}destroy(){clearInterval(this.timer)}}function wM(n,t,e,r){var l;const i=r;Date.now()-i.time<5*1e3&&(n.addCustom("active-cursors",d=>new RM(d)).add(i.id,i.time),z(t,"active")),B("span",[],e,"|").setAttribute("data-cursor-name",i.name),t.style.setProperty("--cursor-color",n.getColor((l=i.rainbowIndex)!=null?l:0))}const H1={insertionType:"remote-cursor",updateInsertionContent:wM};class _B{constructor(t){m(this,"decorators",[]);this.editor=t}registerDecorator(t){this.decorators.push(t)}decorateBlock(t,e){let r=e;return this.decorators.forEach(i=>{if(i.decorateBlock){const o=i.decorateBlock(this.editor,t,e);o&&(r=gt.default(o))}}),r}decorateText(t,e){let r=e;const i=new Map;return this.decorators.forEach(o=>{if(o.decorateText){const s=o.decorateText(this.editor,t,e);if(s){const{insertions:l,text:c}=s;l&&Array.from(l.entries()).forEach(([d,h])=>{const C=i.get(d);C?C.push(...h):i.set(d,h)}),c&&(r=gt.default(c))}}}),{insertions:i,text:r}}}const j1=I("editor-input");class SM{constructor(t,e){m(this,"editor");m(this,"composing",!1);m(this,"callbacks");m(this,"inputElement");m(this,"handleDocumentClick",t=>{const e=this.editor.rootContainer,r=t.target;if(r&&e.contains(r)&&!Gs(r)){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 e;const t=(e=document.getSelection())==null?void 0:e.focusNode;t&&this.editor.contains(t)&&!Gs(t)||(this.editor.emit("blur",this.editor),this.callbacks.onBlur())},100)});m(this,"handleEditorSelectionChanged",()=>{const e=!this.editor.isWritable();this.inputElement.readOnly=e});m(this,"handleReadonlyChanged",()=>{this.handleEditorSelectionChanged()});m(this,"handleCompositionstart",t=>{!this.editor.isWritable()||(this.composing=!0,this.callbacks.onCompositionStart(t))});m(this,"handleCompositionend",t=>{ua()?setTimeout(()=>{this.composing=!1},100):this.composing=!1,this.callbacks.onUpdateCompositionText(t,this.inputElement.value,!0),this.inputElement.value=""});m(this,"handleInput",t=>{if(t instanceof InputEvent&&!!t.data){if(this.editor.readonly||!this.editor.isWritable()){this.inputElement.value="";return}this.composing?this.callbacks.onUpdateCompositionText(t,t.data,!1):(this.callbacks.onInsertText(t,t.data),this.inputElement.value="")}});m(this,"handleKeyDown",t=>{if(!this.composing){if(this.callbacks.onKeyDown(t)){t.preventDefault(),t.stopPropagation();return}!this.editor.isWritable()||setTimeout(()=>{this.composing||(this.inputElement.value="")})}});m(this,"handleCopy",t=>{this.callbacks.onCopy(t)});m(this,"handleCut",t=>{if(this.editor.readonly){t.stopPropagation(),t.preventDefault();return}this.callbacks.onCut(t),j1.debug("on cut")});m(this,"handlePaste",t=>{if(!(t.isTrusted&&(!(t.target instanceof HTMLInputElement)||this.inputElement!==t.target))){if(this.editor.readonly){t.stopPropagation(),t.preventDefault();return}this.callbacks.onPaste(t)}});m(this,"handlePasteText",(t,e)=>{this.callbacks.onPasteText(t,e)});this.editor=t,this.callbacks=e;const r=B("input",["editor-input"],t.contentElement);r.type="text",r.name="editor-input",r.onkeydown=this.handleKeyDown,r.oninput=this.handleInput,r.oncopy=this.handleCopy,document.addEventListener("paste",this.handlePaste),r.oncut=this.handleCut,r.addEventListener("compositionstart",this.handleCompositionstart),r.addEventListener("compositionend",this.handleCompositionend),this.inputElement=r,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 t=this.inputElement;t.removeEventListener("compositionstart",this.handleCompositionstart),t.removeEventListener("compositionend",this.handleCompositionend),t.onkeydown=null,t.oninput=null,t.oncopy=null,document.removeEventListener("paste",this.handlePaste),t.oncut=null}getInput(){return this.inputElement}focus(){this.editor.selection.caret.visible()||this.editor.selection.caret.update(),me.isMobileSafari?(this.inputElement.focus(),z(this.editor.rootElement,"active")):setTimeout(()=>{this.inputElement.focus(),z(this.editor.rootElement,"active")})}handleChanged(t){this.callbacks.onChanged(t)}handleRemoteChanged(t){this.callbacks.onRemoteChanged(t)}addHandler(t){this.callbacks.addHandler(t)}removeHandler(t){this.callbacks.removeHandler(t)}defaultInsertText(t,e,r,i,o){p(j1,t===this.editor,"invalid editor"),this.callbacks.defaultInsertText(t,e,r,i,o)}defaultHandleKeydown(t,e){return p(j1,t===this.editor,"invalid editor"),this.callbacks.defaultHandleKeydown(t,e)}forEach(t){this.callbacks.forEach(t)}}function MB(n){const t=n.rootElement,e=t.getBoundingClientRect(),r=fr(t),i=window.innerWidth,o=window.innerHeight,s=e.left<0?0:e.left,l=e.top<0?0:e.top,c=e.right>i?i:e.right,d=e.bottom>o?o:e.bottom,h=(s+c)/2,C=(l+d)/2,E=0-e.left+h,A=0-e.top+C,v=n.input.inputElement;v.style.left=`${E/r}px`,v.style.top=`${A/r}px`}const z1=I("editor-caret");function LM(){const t=window.navigator.userAgent.match(/Firefox\/(\d+)\./);return t?Number.parseInt(t[1],10):null}class IM{constructor(t){m(this,"editor");m(this,"caretElem");m(this,"handleReadOnlyChanged",()=>{this.update()});if(this.editor=t,this.caretElem=B("div",["editor-cursor"],this.editor.contentElement),me.isFirefox){const e=LM();e&&e<=79&&(this.caretElem.style.transition="none")}this.editor.on("readonlyChanged",this.handleReadOnlyChanged)}destroy(){this.editor.off("readonlyChanged",this.handleReadOnlyChanged)}visible(){const t=window.getComputedStyle(this.caretElem);return t.display!=="none"&&t.opacity!=="0"}hasCaret(){if(this.editor.readonly||!this.editor.selection.range.isCollapsed())return!1;const t=this.editor.selection.range.start;if(!(t instanceof We))return!1;const e=this.editor.getBlockById(t.blockId);return!!nt(this.editor,e)}update(){if(Ub(this.editor.rootElement))return;const t=this.caretElem;if(this.hasCaret())t.style.display="";else{t.style.display="none",MB(this.editor);return}const{range:e}=this.editor.selection;p(z1,e.isCollapsed,"range is not collapsed");const r=e.start;p(z1,r instanceof We,"only simple block position can has caret");const i=this.editor.getBlockById(r.blockId);p(z1,nt(this.editor,i),"only text kind block can has caret");let o;const s=i.querySelector("span.inputting-insertion");s?(o=Us(s),o=new DOMRect(o.right,o.top,1,o.height)):o=Yn(i,r);const l=this.editor.contentElement.getBoundingClientRect(),c=o.left-l.left,d=o.top-l.top;t.style.left=`${c}px`,t.style.top=`${d}px`,t.style.height=`${o.height}px`;const h=this.editor.input.inputElement;h.style.left=`${c}px`,h.style.top=`${d+o.height-24}px`,me.isMobileSafari&&(h.style.left=`${c-4}px`,h.style.height=`${o.height}px`);const E=En(i,{horizontal:!0}).getBoundingClientRect(),A=E.left-l.left,v=A+E.width;c<A||c>v?(MB(this.editor),t.style.display="none"):t.style.display=""}}function DM(n){Ov(n),n.selection.range.getSelectedBlocks().forEach(t=>Nv(n,t.block,t.start,t.end))}const _M=I("editor-dom");function UB(n){return En(n.rootContainer).clientHeight}function MM(n){return n.getFirstBlock().getBoundingClientRect().top}function UM(n){return n.getLastBlock().getBoundingClientRect().bottom}function Eh(n){const e=En(n.rootContainer).getBoundingClientRect(),r=e.x<0?0:e.x,i=e.y<0?0:e.y,o=e.right>window.innerWidth?window.innerWidth:e.right,s=e.bottom>window.innerHeight?window.innerHeight:e.bottom;return new DOMRect(r,i,o-r,s-i)}function OM(n,t){const e=Eh(n),r=n.getBlockById(t.blockId),o=_r(n,r,t);return Ns(e,o.x,o.y)&&Ns(e,o.right,o.bottom)}function OB(n,t){const e=Eh(n),r=t.getBoundingClientRect();return r.top>=e.top&&r.top<=e.bottom||r.bottom<=e.bottom&&r.bottom>=e.top}function NM(n,t){const e=Eh(n),r=t.getBoundingClientRect();if(r.top>=e.top&&r.top<=e.bottom&&r.bottom<=e.bottom&&r.bottom>=e.top)return 100;const i=Math.max(0,Math.min(r.right,e.right)-Math.max(r.left,e.left)),o=Math.max(0,Math.min(r.bottom,e.bottom)-Math.max(r.top,e.top)),s=i*o,l=r.width*r.height;return s/l*100}function PM(n,t){const e=Eh(n),r=t.getBoundingClientRect();return Ns(e,r.x,r.y)||Ns(e,r.right,r.bottom)}function FM(n){if(!Dg(n.rootContainer)){_M.warn("editorScrollIntoView: editor is not visible");return}const t=n.rootContainer.getBoundingClientRect();if(t.height<1&&t.width<1)return;const e=n.selection,r=e.range.focus;if(!r.isSimple()){const C=r,E=n.getContainerById(C.childContainerId);PM(n,E)||E.scrollIntoView();return}if(e.range.start.blockId===e.range.end.blockId){const C=n.getBlockById(e.range.start.blockId);if(pe(C)&&OB(n,C)&&NM(n,C)>=95||_t(n,C)&&OB(n,C))return}const i=r,o=n.getBlockById(i.blockId);if(OM(n,i))return;if(pe(o)){const C=qt(o);if(C){["image"].includes(Ge(o))?setTimeout(()=>{ca(C,{elementToScroll:En(n.rootContainer)})},500):ca(C,{elementToScroll:En(n.rootContainer)});return}}const s=_r(n,o,i),l=o.getBoundingClientRect(),c=re(o),d=B("div",["editor-block-anchor"],c),h=fr(o);d.style.top=`${(s.top-l.top)/h}px`,ca(d,{elementToScroll:En(n.rootContainer)}),setTimeout(()=>{d.remove()},200)}function KM(n,t){if(t.isCollapsed())return!1;const e=we(n.rootContainer),r=Ze(n.rootContainer),{start:i,end:o}=t;return i.blockId===st(e)&&i.offset===0&&o.blockId===st(r)&&o.offset===dt(n,r)}const NB=I("range-in-block");function PB(n,t){const e=t.getEditor(),r=e.getBlockById(t.start.blockId),i=e.getBlockById(t.end.blockId),o=r===n||ne(n,r),s=i===n||ne(n,i);return!!(o||s)}function FB(n,t){const e=n.doc.toJSON(),r=new Set(Object.values(e.blocks).map(s=>s.map(l=>l.id)).flat());let i,o=ge(t);if(o){for(;o&&!r.has(st(o));)o=ge(o);p(NB,o,"no prev block while deleting a block"),i=Te(n,o,dt(n,o))}else{const s=qt(t);p(NB,s,"no prev and next block while deleting a block"),i=Te(n,s,0)}return i}const VM=I("block-to-html");function G1(n,t,e,r){const i=Ks(n,t.type);if(i.convertTo)return i.convertTo(n,t,e,"html",r);if(i.blockKind!=="text")return`[${t.type}]`;p(VM,t.text,"no text");const o=fe(t.text);return`<div>${Ud(o)}</div>`}const KB=I("block-to-text");function $M(n,t,e){let r="";return t.forEach(i=>{if(p(KB,typeof i.insert=="string","invalid op"),i.attributes&&i.attributes.box===!0){const o=i.attributes,s=n.editorBoxes.getBoxClass(o.type);if(s!=null&&s.convertTo){r+=s.convertTo(n,o,e,"text");return}if(i.attributes.text){r+=i.attributes.text;return}r+=`[${o.type}]`}r+=i.insert}),r}function xh(n,t,e,r){const i=Ks(n,t.type);return i.convertTo?i.convertTo(n,t,e,"text",r):i.blockKind!=="text"?`[${t.type}]`:(p(KB,t.text,"no text"),$M(n,t.text,e))}function Ah(n,t,e,r){const i=Ks(n,t.type);return i.convertTo?i.convertTo(n,t,e,"markdown",r):xh(n,t,e,r)}function Ba(n,t){return t.blocks.root.map((i,o)=>G1(n,i,t,[{containerId:"root",blockIndex:o}])).join(`
|
|
24
|
+
`:""}const yB={boxType:"br",updateBoxContent:bM,convertTo:vM},kB=I("editor-boxes");class RB{constructor(t){m(this,"boxes",new Map);this.editor=t}registerBoxClass(t){const e=t.boxType,r=this.boxes.get(e);p(kB,!r,`duplicated box type: ${e}`),this.boxes.set(e,t)}getBoxClass(t){const e=this.boxes.get(t);return p(kB,e,`unknown box type: ${t}`),e}createBox(t,e){const r=wv(e),i=Lv(r);return this.getBoxClass(e.type).updateBoxContent(this.editor,r,i,e),r}forEach(t){this.boxes.forEach(t)}}function BM(n,t,e,r){const i=r,{width:o,height:s,src:l}=i,c=["editor-box-image"];i.link&&c.push("editor-box-image-link");const d=B("img",c,e);o&&(d.style.width=`${o}px`),s&&(d.style.height=`${s}px`),d.src=n.doc.buildResourceUrl(l)}const wB={boxType:"image",updateBoxContent:BM},TM="data:image/svg+xml;base64,Cjxzdmcgd2lkdGg9IjI0IiBoZWlnaHQ9IjI0IiB2aWV3Qm94PSIwIDAgMjQgMjQiIGZpbGw9InJnYigxNzgsIDE4OCwgMjA1KSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPHBhdGggZD0ibTE3IDE1IDEuNTUgMS41NWMtLjk2IDEuNjktMy4zMyAzLjA0LTUuNTUgMy4zN1YxMWgzVjloLTNWNy44MkMxNC4xNiA3LjQgMTUgNi4zIDE1IDVjMC0xLjY1LTEuMzUtMy0zLTNTOSAzLjM1IDkgNWMwIDEuMy44NCAyLjQgMiAyLjgyVjlIOHYyaDN2OC45MmMtMi4yMi0uMzMtNC41OS0xLjY4LTUuNTUtMy4zN0w3IDE1bC00LTN2M2MwIDMuODggNC45MiA3IDkgN3M5LTMuMTIgOS03di0zbC00IDN6TTEyIDRjLjU1IDAgMSAuNDUgMSAxcy0uNDUgMS0xIDEtMS0uNDUtMS0xIC40NS0xIDEtMXoiPjwvcGF0aD4KPC9zdmc+Cg==";function yM(n,t,e){z(e,"editor-box-anchor"),Rg(TM,[],e)}const SB={boxType:"anchor",updateBoxContent:yM};function kM(n,t,e,r){B("span",[],e,r.text)}const LB={insertionType:"inputting",updateInsertionContent:kM},IB=I("editor-insertion");class DB{constructor(t){m(this,"insertions",new Map);this.editor=t}registerInsertionClass(t){const e=t.insertionType,r=this.insertions.get(e);p(IB,!r,`duplicated insertion type: ${e}`),this.insertions.set(e,t)}getInsertionClass(t){const e=this.insertions.get(t);return p(IB,e,`unknown insertion type: ${t}`),e}createInsertion(t,e){const r=Iv(e.type,e.id,e.attributes),i=_v(r);return this.getInsertionClass(e.type).updateInsertionContent(this.editor,r,i,e),r}}class RM{constructor(t){m(this,"cursors",new Map);m(this,"timer");this.editor=t,this.timer=this.startTimer()}add(t,e){this.cursors.set(t,e)}startTimer(){return setInterval(()=>{const t=Date.now();Array.from(this.cursors).forEach(([e,r])=>{if(t-r>3e3){const i=Dv(this.editor,e);i&&ot(i,"active"),this.cursors.delete(e)}})},1e3)}destroy(){clearInterval(this.timer)}}function wM(n,t,e,r){var l;const i=r;Date.now()-i.time<5*1e3&&(n.addCustom("active-cursors",d=>new RM(d)).add(i.id,i.time),z(t,"active")),B("span",[],e,"|").setAttribute("data-cursor-name",i.name),t.style.setProperty("--cursor-color",n.getColor((l=i.rainbowIndex)!=null?l:0))}const H1={insertionType:"remote-cursor",updateInsertionContent:wM};class _B{constructor(t){m(this,"decorators",[]);this.editor=t}registerDecorator(t){this.decorators.push(t)}decorateBlock(t,e){let r=e;return this.decorators.forEach(i=>{if(i.decorateBlock){const o=i.decorateBlock(this.editor,t,e);o&&(r=gt.default(o))}}),r}decorateText(t,e){let r=e;const i=new Map;return this.decorators.forEach(o=>{if(o.decorateText){const s=o.decorateText(this.editor,t,e);if(s){const{insertions:l,text:c}=s;l&&Array.from(l.entries()).forEach(([d,h])=>{const C=i.get(d);C?C.push(...h):i.set(d,h)}),c&&(r=gt.default(c))}}}),{insertions:i,text:r}}}const j1=I("editor-input");class SM{constructor(t,e){m(this,"editor");m(this,"composing",!1);m(this,"callbacks");m(this,"inputElement");m(this,"handleDocumentClick",t=>{const e=this.editor.rootContainer,r=t.target;if(r&&e.contains(r)&&!Gs(r)){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 e;const t=(e=document.getSelection())==null?void 0:e.focusNode;t&&this.editor.contains(t)&&!Gs(t)||(this.editor.emit("blur",this.editor),this.callbacks.onBlur())},100)});m(this,"handleEditorSelectionChanged",()=>{const e=!this.editor.isWritable();this.inputElement.readOnly=e});m(this,"handleReadonlyChanged",()=>{this.handleEditorSelectionChanged()});m(this,"handleCompositionstart",t=>{!this.editor.isWritable()||(this.composing=!0,this.callbacks.onCompositionStart(t))});m(this,"handleCompositionend",t=>{ua()?setTimeout(()=>{this.composing=!1},100):this.composing=!1,this.callbacks.onUpdateCompositionText(t,this.inputElement.value,!0),this.inputElement.value=""});m(this,"handleInput",t=>{if(t instanceof InputEvent&&!!t.data){if(this.editor.readonly||!this.editor.isWritable()){this.inputElement.value="";return}this.composing?this.callbacks.onUpdateCompositionText(t,t.data,!1):(this.callbacks.onInsertText(t,t.data),this.inputElement.value="")}});m(this,"handleKeyDown",t=>{if(!this.composing){if(this.callbacks.onKeyDown(t)){t.preventDefault(),t.stopPropagation();return}!this.editor.isWritable()||setTimeout(()=>{this.composing||(this.inputElement.value="")})}});m(this,"handleCopy",t=>{this.callbacks.onCopy(t)});m(this,"handleCut",t=>{if(this.editor.readonly){t.stopPropagation(),t.preventDefault();return}this.callbacks.onCut(t),j1.debug("on cut")});m(this,"handlePaste",t=>{if(!(t.isTrusted&&(!(t.target instanceof HTMLInputElement)||this.inputElement!==t.target))){if(this.editor.readonly){t.stopPropagation(),t.preventDefault();return}this.callbacks.onPaste(t)}});m(this,"handlePasteText",(t,e)=>{this.callbacks.onPasteText(t,e)});this.editor=t,this.callbacks=e;const r=B("input",["editor-input"],t.contentElement);r.type="text",r.name="editor-input",r.onkeydown=this.handleKeyDown,r.oninput=this.handleInput,r.oncopy=this.handleCopy,document.addEventListener("paste",this.handlePaste),r.oncut=this.handleCut,r.addEventListener("compositionstart",this.handleCompositionstart),r.addEventListener("compositionend",this.handleCompositionend),this.inputElement=r,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 t=this.inputElement;t.removeEventListener("compositionstart",this.handleCompositionstart),t.removeEventListener("compositionend",this.handleCompositionend),t.onkeydown=null,t.oninput=null,t.oncopy=null,document.removeEventListener("paste",this.handlePaste),t.oncut=null}getInput(){return this.inputElement}focus(){this.editor.selection.caret.visible()||this.editor.selection.caret.update(),me.isMobileSafari?(this.inputElement.focus(),z(this.editor.rootElement,"active")):setTimeout(()=>{this.inputElement.focus(),z(this.editor.rootElement,"active")})}handleChanged(t){this.callbacks.onChanged(t)}handleRemoteChanged(t){this.callbacks.onRemoteChanged(t)}addHandler(t){this.callbacks.addHandler(t)}removeHandler(t){this.callbacks.removeHandler(t)}defaultInsertText(t,e,r,i,o){p(j1,t===this.editor,"invalid editor"),this.callbacks.defaultInsertText(t,e,r,i,o)}defaultHandleKeydown(t,e){return p(j1,t===this.editor,"invalid editor"),this.callbacks.defaultHandleKeydown(t,e)}forEach(t){this.callbacks.forEach(t)}}function MB(n){const t=n.rootElement,e=t.getBoundingClientRect(),r=fr(t),i=window.innerWidth,o=window.innerHeight,s=e.left<0?0:e.left,l=e.top<0?0:e.top,c=e.right>i?i:e.right,d=e.bottom>o?o:e.bottom,h=(s+c)/2,C=(l+d)/2,E=0-e.left+h,A=0-e.top+C,v=n.input.inputElement;v.style.left=`${E/r}px`,v.style.top=`${A/r}px`}const z1=I("editor-caret");function LM(){const t=window.navigator.userAgent.match(/Firefox\/(\d+)\./);return t?Number.parseInt(t[1],10):null}class IM{constructor(t){m(this,"editor");m(this,"caretElem");m(this,"handleReadOnlyChanged",()=>{this.update()});if(this.editor=t,this.caretElem=B("div",["editor-cursor"],this.editor.contentElement),me.isFirefox){const e=LM();e&&e<=79&&(this.caretElem.style.transition="none")}this.editor.on("readonlyChanged",this.handleReadOnlyChanged)}destroy(){this.editor.off("readonlyChanged",this.handleReadOnlyChanged)}visible(){const t=window.getComputedStyle(this.caretElem);return t.display!=="none"&&t.opacity!=="0"}hasCaret(){if(this.editor.readonly||!this.editor.selection.range.isCollapsed())return!1;const t=this.editor.selection.range.start;if(!(t instanceof We))return!1;const e=this.editor.getBlockById(t.blockId);return!!nt(this.editor,e)}update(){if(Ub(this.editor.rootElement))return;const t=this.caretElem;if(this.hasCaret())t.style.display="";else{t.style.display="none",MB(this.editor);return}const{range:e}=this.editor.selection;p(z1,e.isCollapsed,"range is not collapsed");const r=e.start;p(z1,r instanceof We,"only simple block position can has caret");const i=this.editor.getBlockById(r.blockId);p(z1,nt(this.editor,i),"only text kind block can has caret");let o;const s=i.querySelector("span.inputting-insertion");s?(o=Us(s),o=new DOMRect(o.right,o.top,1,o.height)):o=Yn(i,r);const l=this.editor.contentElement.getBoundingClientRect(),c=o.left-l.left,d=o.top-l.top;t.style.left=`${c}px`,t.style.top=`${d}px`,t.style.height=`${o.height}px`;const h=this.editor.input.inputElement;h.style.left=`${c}px`,h.style.top=`${d+o.height-24}px`,me.isMobileSafari&&(h.style.left=`${c-4}px`,h.style.height=`${o.height}px`);const E=En(i,{horizontal:!0}).getBoundingClientRect(),A=E.left-l.left,v=A+E.width;c<A||c>v?(MB(this.editor),t.style.display="none"):t.style.display=""}}function DM(n){Ov(n),n.selection.range.getSelectedBlocks().forEach(t=>Nv(n,t.block,t.start,t.end))}const _M=I("editor-dom");function UB(n){return En(n.rootContainer).clientHeight}function MM(n){return n.getFirstBlock().getBoundingClientRect().top}function UM(n){return n.getLastBlock().getBoundingClientRect().bottom}function Eh(n){const e=En(n.rootContainer).getBoundingClientRect(),r=e.x<0?0:e.x,i=e.y<0?0:e.y,o=e.right>window.innerWidth?window.innerWidth:e.right,s=e.bottom>window.innerHeight?window.innerHeight:e.bottom;return new DOMRect(r,i,o-r,s-i)}function OM(n,t){const e=Eh(n),r=n.getBlockById(t.blockId),o=_r(n,r,t);return Ns(e,o.x,o.y)&&Ns(e,o.right,o.bottom)}function OB(n,t){const e=Eh(n),r=t.getBoundingClientRect();return r.top>=e.top&&r.top<=e.bottom||r.bottom<=e.bottom&&r.bottom>=e.top}function NM(n,t){const e=Eh(n),r=t.getBoundingClientRect();if(r.top>=e.top&&r.top<=e.bottom&&r.bottom<=e.bottom&&r.bottom>=e.top)return 100;const i=Math.max(0,Math.min(r.right,e.right)-Math.max(r.left,e.left)),o=Math.max(0,Math.min(r.bottom,e.bottom)-Math.max(r.top,e.top)),s=i*o,l=r.width*r.height;return s/l*100}function PM(n,t){const e=Eh(n),r=t.getBoundingClientRect();return Ns(e,r.x,r.y)||Ns(e,r.right,r.bottom)}function FM(n){if(!Dg(n.rootContainer)){_M.warn("editorScrollIntoView: editor is not visible");return}const t=n.rootContainer.getBoundingClientRect();if(t.height<1&&t.width<1)return;const e=n.selection,r=e.range.focus;if(!r.isSimple()){const C=r,E=n.getContainerById(C.childContainerId);PM(n,E)||E.scrollIntoView();return}if(e.range.start.blockId===e.range.end.blockId){const C=n.getBlockById(e.range.start.blockId);if(pe(C)&&OB(n,C)&&NM(n,C)>=95||Dt(n,C)&&OB(n,C))return}const i=r,o=n.getBlockById(i.blockId);if(OM(n,i))return;if(pe(o)){const C=qt(o);if(C){["image"].includes(Ge(o))?setTimeout(()=>{ca(C,{elementToScroll:En(n.rootContainer)})},500):ca(C,{elementToScroll:En(n.rootContainer)});return}}const s=_r(n,o,i),l=o.getBoundingClientRect(),c=re(o),d=B("div",["editor-block-anchor"],c),h=fr(o);d.style.top=`${(s.top-l.top)/h}px`,ca(d,{elementToScroll:En(n.rootContainer)}),setTimeout(()=>{d.remove()},200)}function KM(n,t){if(t.isCollapsed())return!1;const e=we(n.rootContainer),r=Ze(n.rootContainer),{start:i,end:o}=t;return i.blockId===st(e)&&i.offset===0&&o.blockId===st(r)&&o.offset===dt(n,r)}const NB=I("range-in-block");function PB(n,t){const e=t.getEditor(),r=e.getBlockById(t.start.blockId),i=e.getBlockById(t.end.blockId),o=r===n||ne(n,r),s=i===n||ne(n,i);return!!(o||s)}function FB(n,t){const e=n.doc.toJSON(),r=new Set(Object.values(e.blocks).map(s=>s.map(l=>l.id)).flat());let i,o=ge(t);if(o){for(;o&&!r.has(st(o));)o=ge(o);p(NB,o,"no prev block while deleting a block"),i=Te(n,o,dt(n,o))}else{const s=qt(t);p(NB,s,"no prev and next block while deleting a block"),i=Te(n,s,0)}return i}const VM=I("block-to-html");function G1(n,t,e,r){const i=Ks(n,t.type);if(i.convertTo)return i.convertTo(n,t,e,"html",r);if(i.blockKind!=="text")return`[${t.type}]`;p(VM,t.text,"no text");const o=fe(t.text);return`<div>${Ud(o)}</div>`}const KB=I("block-to-text");function $M(n,t,e){let r="";return t.forEach(i=>{if(p(KB,typeof i.insert=="string","invalid op"),i.attributes&&i.attributes.box===!0){const o=i.attributes,s=n.editorBoxes.getBoxClass(o.type);if(s!=null&&s.convertTo){r+=s.convertTo(n,o,e,"text");return}if(i.attributes.text){r+=i.attributes.text;return}r+=`[${o.type}]`}r+=i.insert}),r}function xh(n,t,e,r){const i=Ks(n,t.type);return i.convertTo?i.convertTo(n,t,e,"text",r):i.blockKind!=="text"?`[${t.type}]`:(p(KB,t.text,"no text"),$M(n,t.text,e))}function Ah(n,t,e,r){const i=Ks(n,t.type);return i.convertTo?i.convertTo(n,t,e,"markdown",r):xh(n,t,e,r)}function Ba(n,t){return t.blocks.root.map((i,o)=>G1(n,i,t,[{containerId:"root",blockIndex:o}])).join(`
|
|
25
25
|
`)}function VB(n,t){return`<!doctype html><html><head><meta charset="utf8" /></head><body>${Ba(n,t)}</body></html>`}function ro(n,t){return t.blocks.root.map((i,o)=>xh(n,i,t,[{containerId:"root",blockIndex:o}])).join(`
|
|
26
26
|
`)}function $B(n,t){const e=t.blocks.root.map((i,o)=>Ah(n,i,t,[{containerId:"root",blockIndex:o}]));return e[e.length-1]=e[e.length-1].trimEnd(),e.join(`
|
|
27
|
-
`)}const HM=I("get-text-position");function Ta(n,t){const e=t!=null?t:n.selection.range.start;e instanceof We||p(HM,!1,`invalid insert pos type: ${typeof e}`);const{blockId:r}=e,i=n.getBlockById(r),o=bt(i),s=rt(i),l=ft(s),{offset:c}=e;return{block:i,container:s,containerId:l,blockIndex:o,offset:c}}const ya=I("insert-text");function W1(n,t,e,r){var s;const i=n.doc.getBlockData(t,e);if(p(ya,i,"no block data"),p(ya,i.text,"no block text"),un(i.text)===0)return p(ya,r===0,"invalid text offset"),n.editorCommandProviders.getEmptyBlockTextAttributes(n,i.id);if(r===0)return;const o=Xe(i.text,r-1,1).middle;if(!((s=o[0].attributes)!=null&&s.box))return o[0].attributes}function jM(n,t,e){const r=rt(t),i=ft(r),o=bt(t);return W1(n,i,o,e)}function HB(n,t,e,r,i){const o=rt(t),s=ft(o),l=bt(t),c=jM(n,t,e),d=uh(e,r,c!=null?c:null);return n.doc.localUpdateBlockText(s,l,d,i),bn(n,t)}function jB(n,t,e,r){const i=rt(t),o=ft(i),s=bt(t),l=uh(e," ",r);return n.doc.localUpdateBlockText(o,s,l),bn(n,t)}function zM(n,t){let e=0;if(t===0)return!1;for(let r=0;r<n.length;r++){const i=n[r];p(ya,typeof i.insert=="string","invalid text op, no insert");const o=e+rh(i);if(o===t)return!1;if(o>t)return!0;e=o}return!1}function q1(n,t,e,r,i){const o=n.doc.getBlockData(e,r);p(ya,o,"no block data"),p(ya,o.text,"no block text");const s=W1(n,e,r,i);s&&Object.keys(s).includes("link")&&(zM(o.text,i)||delete s.link);const l=uh(i,t,s!=null?s:null);return n.doc.localUpdateBlockText(e,r,l),bn(n,n.getBlockById(o.id))}function X1(n,t){n.selection.range.isCollapsed()||n.clearSelectedContents();const{containerId:e,blockIndex:r,offset:i}=Ta(n);q1(n,t,e,r,i)}const bh=I("update-composition-text");function zB(n){const t=n.selection.range.start;t instanceof We||p(bh,!1,`invalid insert pos type: ${typeof t}`);const{blockId:e}=t,r=n.getBlockById(e);p(bh,nt(n,r),"not a text kind block");const i=rt(r),o=ft(i),s=bt(r),l=n.doc.getBlockData(o,s);p(bh,l,"no block data in doc"),p(bh,l.text,"no text data in text block");const c=Ot(r);oh(n,Vo(r),e,c,l.text)}function Q1(n){a_(n)}function ka(n,t,e,r,i,o){return n.doc.localInsertBlock(t,e,r,i,o),n.getBlockById(r.id)}const xu=I("delete-block-text");function Y1(n,t,e,r,i){if(!n.isBlockWritable(t))return xu.error("block is not writable"),0;p(xu,nt(n,t),"block is not a text kind block");const o=rt(t),s=ft(o),l=bt(t),c=n.doc.getBlockData(s,l);p(xu,c,"no block data in doc"),p(xu,c.text,"no text data in text block");let d=e;Un(t,e)||(d=Go(t,d));let h=e+r;p(xu,h<=dt(n,t),`invalid offset and count: ${e}, ${r}`),Un(t,h)||(h=Ys(t,h));const C=h-d,E=cB(d,C);return n.doc.localUpdateBlockText(s,l,E,i),console.log("delete"),C}const J1=I("break-text-block");function GB(n,t){const r=n.getBlockData(t).quoted;return r?{quoted:r}:{}}function Ra(n,t,e,r){p(J1,nt(n,t),`block is not a text kind block: ${St(t)}`),p(J1,e>=0&&e<=dt(n,t),`invalid offset: ${e}`);const i=rt(t),o=ft(i),s=bt(t),l=r!=null&&r.copyBlockAttributes?GB(n,t):{};if(!(r!=null&&r.forceInsertAfter)&&(e===0||e===dt(n,t))){const A=e===0?s:s+1,v={...pi(""),...l,...r==null?void 0:r.newBlockData},R=Te(n,t.id,0),L=ka(n,o,A,v,R);return{block:t,newBlock:L}}p(J1,Un(t,e),"not a valid offset");const c=bn(n,t),{right:d}=_n(c,e),h=un(d);h>0&&Y1(n,t,e,h);const C={...pi(d),...l,...r==null?void 0:r.newBlockData},E=ka(n,o,s+1,C,Te(n,C.id,0));return{block:t,newBlock:E}}const GM=I("prepare-insert-new-block");function WM(n,t,e){if(t&&e!==void 0&&e!==null){const d=n.getContainerById(t),h=ue(d);return p(GM,e>=0&&e<=h.length,`invalid blockIndex: ${e}`),{containerId:t,blockIndex:e}}const r=n.selection.range.start;if(!r.isSimple())return null;const i=n.getBlockById(r.blockId);if(t=ft(rt(i)),e=bt(i),!nt(n,i))return{containerId:t,blockIndex:e+1};const s=r.offset;if(s===0||s===dt(n,i))return{containerId:t,blockIndex:s===0?e:e+1};const c=Ra(n,i,s).newBlock;return{containerId:t,blockIndex:bt(c)}}const qM=I("auto-insert-block");function WB(n,t,e,r,i,o){const s=WM(n,e,r);p(qM,s,`not an valid insert position: ${n.selection.range}`);const l={blockId:t.id,offset:0},c={anchor:l,focus:l};return ka(n,s.containerId,s.blockIndex,t,i!=null?i:c,o)}const XM=I("delete-block");function vh(n,t,e){t.children&&(e.push(...t.children),t.children.forEach(r=>{n.getChildContainerData(r).forEach(o=>{vh(n,o,e)})}))}function Bh(n,t,e){const r=rt(t),i=ft(r),o=bt(t),s=n.doc.getBlockData(i,o);return p(XM,s,"no block data in doc"),n.doc.localDeleteBlock(i,o,qe(n,{anchor:e.start,focus:e.end})),s}function Z1(n,t,e){return n.undoManager.runInGroup(()=>{const r=rt(t);Lr(r)===1&&n.insertTextBlock("",ft(r),0);let i=e?$o(n,e):null;if(!i){const l=n.selection.range;PB(t,l)?i=FB(n,t):i=l}const o=Bh(n,t,i),s=[];return vh(n,o,s),s.length>0&&n.doc.localDeleteChildContainers(s),o})}function QM(n,t){const e=[t];n.doc.getContainerBlocks(t).forEach(i=>{vh(n,i,e)}),n.doc.localDeleteChildContainers(e)}function qB(n,t){const e=[...t];t.forEach(r=>{n.doc.getContainerBlocks(r).forEach(o=>{vh(n,o,e)})}),n.doc.localDeleteChildContainers(e)}const tp=I("merge-text-block");function XB(n,t,e){p(tp,nt(n,t),"only text block can be merged"),p(tp,nt(n,e),"only text block can be merged");const r=Wo(n,t),i=Wo(n,e),o=r.text,s=i.text;p(tp,o&&s,"block data has no text");const l=rt(t),c=ft(l),d=bt(t),h=dt(n,t),C=q1(n,s,c,d,h),E=Te(n,t,un(o));return Z1(n,e,E),C}const Ci=I("clear-selected-contents");function Th(n,t){p(Ci,nt(n,t.block),"not a text kind block");const{start:e,end:r}=t;p(Ci,e.isSimple(),"not a simple block position"),p(Ci,r.isSimple(),"not a simple block position");const i=e.offset,o=r.offset;p(Ci,i<=o,`invalid delete text offset: ${i}, ${o}`),i!==o&&n.deleteTextFromBlock(t.block,i,o-i)}function QB(n,t,e){const r=ft(t),i=ue(t),o=e.focus?void 0:n.selection.range.toDocRange(),s=n.insertTextBlock("",r,0,{newRange:o});e.focus&&n.selection.selectBlock(s,0),i.reverse().forEach(l=>{n.deleteBlock(l)})}function YM(n,t){const{block:e,start:r,end:i}=t;if(nt(n,e)){Th(n,t);return}if(pe(e)||r.isSimple()){p(Ci,i.isSimple(),"invalid range");const s=rt(e),l=bt(e),c=n.insertTextBlock("",ft(s),l);n.selection.selectBlock(c,0),n.deleteBlock(e);return}p(Ci,_t(n,e),"invalid block kind"),p(Ci,!r.isSimple()&&!i.isSimple(),"invalid range"),ga(n,e,r,i),n.selection.range.getSelectedContainers().forEach((s,l)=>{QB(n,s,{focus:l===0})})}function JM(n){if(!n.isWritable())return;const t=n.selection.range;if(t.isCollapsed())return;const e=t.getSelectedBlocks();if(p(Ci,e.length>0,"no selected block"),e.length===1){YM(n,e[0]);return}const r=e[0],i=r.block,o=rt(i);p(Ci,e.length>1,"no selected block");const s=e[e.length-1],l=s.block;if(nt(n,i)){Th(n,r);const h=Te(n,r.block,r.start.offset);if(e.slice(1,e.length-1).reverse().forEach(E=>n.deleteBlock(E.block)),nt(n,l)){Th(n,s),n.mergeTextBlock(i,l,{focus:!0}),n.selection.setRange(h);return}n.deleteBlock(l),n.selection.setRange(h);return}if(nt(n,l)){Th(n,s),e.slice(0,e.length-1).reverse().forEach(h=>n.deleteBlock(h.block)),n.selection.selectBlock(s.block,0);return}if(e.length===Lr(o)){QB(n,o,{focus:!0});return}const c=ge(i),d=qt(l);p(Ci,c||d,"no prev or next block"),e.forEach(h=>n.deleteBlock(h.block))}function yh(n){n.selection.range.isCollapsed()||n.undoManager.runInGroup(()=>{n.emit("beforeClearSelection",n);try{n.doc.beginBatchUpdate(),JM(n)}finally{n.doc.endBatchUpdate()}n.emit("afterClearSelection",n)})}const ZM=I("core");function YB(n,t,e,r){const i=rt(t),o=ft(i),s=bt(t);return n.doc.localUpdateBlockText(o,s,e,r),setTimeout(()=>{n.selection.updateSelection(null)}),bn(n,t)}function JB(n,t,e,r){if(!n.isBlockWritable(t)){ZM.error("block is not writable");return}const i=n.getBlockText(t),o=fn.diff(i,e);YB(n,t,o,r)}function kh(n,t,e){const r=bn(n,t),i=typeof e=="string"?Zs(e):e,o=fn.diff(r,i);return YB(n,t,o)}const Au=I("update-block-data");function Rh(n,t,e,r){const i=rt(t),o=ft(i),s=bt(t),l=n.doc.getBlockData(o,s),c={insert:{},delete:[]},d=new Set(Object.keys(l)),h=new Set(Object.keys(e));return d.forEach(E=>{if(!h.has(E)){if(E==="id"||E==="type"||E==="text")return;Au.debug(`delete key: ${E}`),c.delete.push(E)}}),Object.entries(e).forEach(([E,A])=>{p(Au,E!=="id"&&E!=="type",`invalid block data delta, ${E}`);const v=l[E];if(A==null){v!=null&&(Au.debug(`delete key: ${E}`),c.delete.push(E));return}v!==A&&(qc.default(v,A)||E==="text"&&fn.diff(v,A).length===0||(d.has(E)?(Au.debug(`replace key: ${E}`),c.delete.push(E)):Au.debug(`insert key: ${E}`),c.insert[E]=A))}),n.doc.localUpdateBlockData(o,s,c,r),Wo(n,t)}function ZB(n,t,e,r){const o={...n.getBlockData(t),embedData:e};return n.updateBlockData(t,o,r)}function ep(n,t,e){if(!_t(n,t)||!(e!=null&&e.tryFocusToChildSimpleBlock)){n.selection.selectBlock(t,0);return}const i=Qn(n,t).getChildContainers(n,t)[0],o=we(i);ep(n,o,e)}function tl(n){const t=[];let e={};return n.forEach(r=>{t.push(...r.blocks.root);const{root:i,...o}=r.blocks;e={...e,...o}}),{blocks:{...e,root:t},meta:{},comments:{}}}const bu=I("clone-block");function qo(n,t,e,r){const i=n.getBlockClass(e.type);if(i.blockToDoc)return i.blockToDoc(t,e,(h,C)=>(p(bu,e!==C,"invalid child block"),qo(n,h,e,r)));let o={};const s=new Map,l=gt.default(e);l.children&&(l.children=l.children.map(h=>{const C=Z(),E=t.blocks[h];p(bu,Array.isArray(E),"invalid child blocks");const A=E.map(M=>qo(n,t,M,r)),v=tl(A),{root:R,...L}=v.blocks;return o={...o,...L},o[C]=v.blocks.root,s.set(h,C),C}));const c=Array.from(s.entries()),d=h=>{for(const C of c){const[E,A]=C;{const v=`${E}/`;if(h.startsWith(v)){const R=h.substring(v.length),L=`${A}/${R}`;return bu.debug(`replace key: ${h} -> ${L}`),L}}{const v=`${E}_`;if(h.startsWith(v)){const R=h.substring(v.length),L=`${A}_${R}`;return bu.debug(`replace key: ${h} -> ${L}`),L}}}return h};return Array.from(Object.entries(l)).forEach(([h,C])=>{const E=d(h);E!==h&&delete l.key,l[E]=C}),l.id=Z(),r&&(r.blockIdMap.set(e.id,l.id),s.forEach((h,C)=>r.containerIdMap.set(C,h))),{blocks:{root:[l],...o},meta:{},comments:{}}}function np(n,t,e,r){const i=t.blocks[e];p(bu,Array.isArray(i),"invalid child blocks");const o=i.map(l=>qo(n,t,l,r));return tl(o)}function rp(n,t,e){const r=t.blocks.root.map(i=>qo(n.editorBlocks,t,i,e));return gt.default(tl(r))}const t5=I("insert-doc");function e5(n,t,e,r,i){if(_t(n,t)){t5.warn("failed to insert doc into a complex block");return}const o=rp(n,r,i),s=rt(t),l=bt(t),c=ft(s);n.doc.beginBatchUpdate(),n.undoManager.runInGroup(()=>{var F,G,W,it;const d=[];Object.entries(o.blocks).forEach(([at,xt])=>{at!=="root"&&d.push({containerId:at,blocks:xt})}),d.length>0&&n.doc.localInsertChildContainers(d);const h=o.blocks.root;if(pe(t)){n.deleteBlock(t);let at;h.reverse().forEach(xt=>{const Mt=n.insertBlock(c,l,xt,void 0,{noFocus:!0});at||(at=Mt)}),at&&n.selection.selectBlock(at,dt(n,at));return}if(p(t5,nt(n,t),"not a text block"),ie(n,t)){const at=bt(t);let xt,Mt=!1;for(let Bt=0;Bt<h.length;Bt++){if(Bt===0){const te=n.findBlockByIndex(c,at),kn=h[Bt].type==="text"||h[Bt].type==="list",be=te&&St(te)===h[Bt].type;if(te&&nt(n,te)&&ie(n,te)&&kn&&be){n.insertTextToBlock(t,0,(F=h[Bt].text)!=null?F:[]),Object.keys(h[Bt]).length>3&&n.updateBlockData(te,i_(h[Bt],["id","text","type","heading","quoted"]));continue}te&&Gi(te)&&(Mt=!0)}const le=n.insertBlock(c,at+Bt,h[Bt],void 0,{noFocus:!0});Bt===h.length-1&&(xt=le)}xt&&n.selection.selectBlock(xt,dt(n,xt)),Mt&&n.deleteBlock(t);return}if(h.length===1){const at=h[0];if(iu(n,at.type)){n.insertTextToBlock(t,e,(G=at.text)!=null?G:[]);return}n.breakTextBlock(t,e),n.insertBlock(c,l+1,at);return}const C=e===dt(n,t),E=e===0,A=h[0],v=h[h.length-1];let R;!C&&!E?R=n.breakTextBlock(t,e,{forceInsertAfter:!0}):R=t;const L=E?l:l+1;C?(R=n.insertBlock(c,l+1,v),n.selection.selectBlock(R,dt(n,R))):(n.selection.selectBlock(R,0),iu(n,v.type)?n.insertTextToBlock(R,0,(W=v.text)!=null?W:[]):n.insertBlock(c,L,v));const M=n.selection.range;let U=L;iu(n,A.type)?E?(n.insertBlock(c,L,A),U+=1):n.insertTextToBlock(t,e,(it=A.text)!=null?it:[]):(n.insertBlock(c,L,A),U+=1),h.slice(1,h.length-1).reverse().forEach(at=>{n.insertBlock(c,U,at)}),n.selection.setRange(M)}),n.doc.endBatchUpdate()}function ip(n,t,e,r,i){const o=rp(n,r,i),s=ft(t),l=[];return n.undoManager.runInGroup(()=>{const c=[];Object.entries(o.blocks).forEach(([h,C])=>{h!=="root"&&c.push({containerId:h,blocks:C})}),n.doc.localInsertChildContainers(c),o.blocks.root.reverse().forEach(h=>{const C=n.insertBlock(s,e,h,void 0,{noFocus:!0,noScroll:!0});l.push(C)})}),l}function n5(n,t,e,r){const i=Lr(t);ip(n,t,i,e,r);for(let o=0;o<i;o++){const s=we(t);n.deleteBlock(s)}}const vu=I("add-text-attribute");function tU(n,t,e,r){const{start:i,end:o}=e;p(vu,i.blockId===o.blockId&&i.blockId===st(t),"invalid range"),p(vu,r,"invalid attribute name");const s=n.getBlockText(t),l=xa(i.offset,o.offset-i.offset,s,r,void 0,{ignoreValue:!0});return n.setBlockText(t,l),l}function r5(n,t,e,r,i){const{start:o,end:s}=e;p(vu,o.blockId===s.blockId&&o.blockId===st(t),"invalid range"),p(vu,r,"invalid attribute name");const l=n.getBlockText(t),c=gu(o.offset,s.offset-o.offset,l,r,i);return n.setBlockText(t,c),c}function wa(n,t,e,r,i){const{start:o,end:s}=e;p(vu,o.blockId===s.blockId&&o.blockId===st(t),"invalid range");const l=n.getBlockText(t),c=Q3(o.offset,s.offset-o.offset,l,r,i);return n.setBlockText(t,c),c}function i5(n,t,e,r){const i=hi(n,{simpleBlockOnly:!0});n.undoManager.runInGroup(()=>{i.forEach(o=>{const{block:s,start:l,end:c}=o;if(!nt(n,s))return;if(ie(n,s)){r(n,st(s),t,e);return}const d=qe(n,{anchor:l,focus:c});t==="color"||t==="backgroundColor"?wa(n,s,d,t,e):(wa(n,s,d,"color",null),wa(n,s,d,"backgroundColor",null))})})}function o5(n,t,e){const r=hi(n,{simpleBlockOnly:!0});n.undoManager.runInGroup(()=>{r.forEach(i=>{const{block:o,start:s,end:l}=i;if(!nt(n,o))return;if(ie(n,o)){(t==="clearColor"||t==="clearAll")&&e(n,st(o),"color",null),(t==="clearBackground"||t==="clearAll")&&e(n,st(o),"backgroundColor",null);return}const c=qe(n,{anchor:s,focus:l});(t==="clearColor"||t==="clearAll")&&wa(n,o,c,"color",null),(t==="clearBackground"||t==="clearAll")&&wa(n,o,c,"backgroundColor",null)})})}function s5(n,t,e){const r=t.getSelectedBlocks().filter(l=>nt(n,l.block));if(r.length===0)return[null,null];const i=l=>{if(dt(n,l.block)===0)return e(n,st(l.block));const c=l.start,d=l.end,h=n.getBlockText(l.block);return Z3(c.offset,d.offset-c.offset,h)};let[o,s]=i(r[0]);return o===null&&s===null?[o,s]:(r.forEach(l=>{const[c,d]=i(l);c===null||o===null?o=null:o=c===o?o:null,d===null||s===null?s=null:s=d===s?s:null}),[o,s])}const Jn=I("adjust-selection-pos");function l5(n){const t=[];for(;n;){const e=rt(n);if(t.unshift(e),Xt(e))return t;const r=et(e);p(Jn,r,"child container has not parent container"),n=r}p(Jn,!1,"should not come here: getParentContainers")}function a5(n,t){for(;t;){const e=rt(t);if(e===n)return t;const r=et(e);p(Jn,r,"could not find parent block for a child container"),t=r}p(Jn,!1,"no parent block in specified container")}function eU(n,t){const e=l5(n),r=l5(t);p(Jn,e.length>0&&r.length>0,"block has not parent container"),p(Jn,e[0]===r[0],"root container does not equal");let i=e[0];for(let l=1;l<e.length||r.length;l++)if(e[l]!==r[l]){i=e[l-1];break}const o=a5(i,n),s=a5(i,t);return{parentContainer:i,newBlock1:o,newBlock2:s}}function c5(n,t){let e=et(t);for(p(Jn,e,"element is not in a block");e;){const r=rt(e);p(Jn,Mr(r),"not a child container");const i=et(r);if(p(Jn,i,"child container has not parent block"),i===n)return r;e=i}p(Jn,!1,"failed to find parent container in complex block")}function wh(n,t,e){const r=n.getBlockById(t.blockId),i=n.getBlockById(e.blockId);if(r===i)return t instanceof We&&e instanceof We?{anchor:t,focus:e}:t instanceof Ur&&e instanceof Ur?Qd(n,r,t,e):null;const o=rt(r),s=rt(i);if(o===s)return t instanceof Ur&&(t=lt(r,0,"home")),e instanceof Ur&&(e=lt(i,dt(n,i),"end")),p(Jn,t instanceof We,"not valid position type"),p(Jn,e instanceof We,"not valid position type"),{anchor:t,focus:e};if(r.contains(s))return null;if(i.contains(o)){if(t instanceof We&&e instanceof Ur){const v=n.getContainerById(e.childContainerId);if(v===o)return{anchor:e,focus:e};const R=et(o);if(R&&R===et(v)){const L=xe(R,ft(o)),M=xe(R,ft(v));return Qd(n,R,L,M)}}return null}const l=_d(r,i)>0,{newBlock1:c,newBlock2:d}=eU(r,i);if(c===d){const v=c,R=c5(v,r),L=c5(v,i);return t=xe(c,ft(R)),e=xe(c,ft(L)),Jn.debug(`select in complex block: ${R.id}, ${L.id}`),Qd(n,v,t,e)}let h=l?dt(n,c):0;c===r&&t instanceof We&&(h=t.offset);let E=l?0:dt(n,d);return d===i&&e instanceof We&&(E=e.offset),t=lt(c,h,l?"end":"home"),e=lt(d,E,l?"home":"end"),{anchor:t,focus:e}}const nU=I("move-complex-block-position");function rU(n,t,e){const r=n.getBlockById(t.blockId);p(nU,_t(n,r),"is not a complex block");const i=Qn(n,r),o=n.getContainerById(t.childContainerId),s=i.getNextContainer(n,r,o,e,{noWrap:!0});return s?xe(r,ft(s)):null}const Bu=I("move-simple-block-position");function u5(n,t){const e=An(n,t,{visibleOnly:!0});p(Bu,e.length>0,"complex block has not any child container");const r=e[0];return we(r)}function f5(n,t){const e=An(n,t,{visibleOnly:!0});p(Bu,e.length>0,"complex block has not any child container");const r=e[e.length-1];return Ze(r)}function d5(n,t,e){const r=e?u5(n,t):f5(n,t);return _t(n,r)?d5(n,r,e):r}function iU(n,t){const e=n.getBlockById(t.blockId);return _t(n,e)&&t.offset===0?u5(n,e):zs(e)}function oU(n,t){const e=n.getBlockById(t.blockId);return _t(n,e)&&t.offset===1?f5(n,e):js(e)}function op(n){return n==="ArrowLeft"||n==="ArrowUp"}function sp(n,t,e){const r=rt(t);if(Xt(r))return null;const i=et(r);p(Bu,i,"child container has not parent block"),p(Bu,_t(n,i),"is not a complex block");const o=Qn(n,i).getNextContainer(n,i,r,e);return o?op(e)?Ze(o):we(o):sp(n,i,e)}function sU(n,t,e){const r=rt(t);if(Xt(r))return null;const i=et(r);if(p(Bu,i,"child container has not parent block"),op(e)){const l=ge(i);if(l)return l}else{const l=qt(i);if(l)return l}const o=sp(n,i,e);if(o)return o;let s=i;for(;!Xt(rt(s));)s=et(rt(s));return op(e)?ge(s):qt(s)}function lU(n,t,e){return!_t(n,t)||Qn(n,t).enableKeyboardSelect?t:d5(n,t,e==="ArrowDown"||e==="ArrowRight")}function aU(n,t,e){const r=n.getBlockById(t.blockId),o=Yt(n,r).moveCaret(n,r,t,e);if(o)return o;let s=e==="ArrowDown"||e==="ArrowRight"?iU(n,t):oU(n,t);if(s||(s=sp(n,r,e),s||(s=sU(n,r,e))),!s){if(e==="ArrowDown"||e==="ArrowRight"){if(n.readonly||!Xt(rt(r)))return null;const l=n.insertTextBlock("",ft(n.rootContainer),Lr(n.rootContainer));return lt(l,0,"home")}return null}if(s=lU(n,s,e),nt(n,s)){const l=n.selection.getSuggestedCaretX();if(e==="ArrowDown")return I_(n,s,r,t,l);if(e==="ArrowUp")return L_(n,s,r,t,l)}return e==="ArrowLeft"||e==="ArrowUp"?lt(s,dt(n,s),"end"):e==="ArrowRight"||e==="ArrowDown"?lt(s,0,"home"):null}function cU(n,t,e){if(t==="ArrowLeft")return e.start;const r=e.end,i=n.getBlockById(r.blockId);if(nt(n,i))return r;const o=qt(i);if(o)return lt(o,0,"home");if(!Xt(rt(i))||n.readonly)return r;const s=n.insertTextBlock("",ft(n.rootContainer),Lr(n.rootContainer));return lt(s,0,"home")}function uU(n,t,e){const r=n.selection.range;let i;if(r instanceof tn)e==="move"&&!r.isCollapsed()&&(t==="ArrowLeft"||t==="ArrowRight")?i=cU(n,t,r):i=aU(n,r.getFocusedPos(),t);else if(i=rU(n,r.focus,t),e==="move"){const o=i!=null?i:r.focus,s=n.getContainerById(o.childContainerId);if(t==="ArrowLeft"||t==="ArrowUp"){const l=Ze(s);i=lt(l,0,"home")}else{const l=we(s);i=lt(l,dt(n,l),"end")}}return i?e==="move"?{anchor:i,focus:i}:wh(n,r.anchor,i):null}function Xo(n,t,e){const r=uU(n,t,e);if(!r)return!1;const{anchor:i,focus:o}=r;return n.selection.setSelection(i,o),(t==="ArrowLeft"||t==="ArrowRight")&&n.selection.updateLastCaretRect(),!0}function h5(n){return Xo(n,"ArrowLeft","move"),!0}function m5(n){return Xo(n,"ArrowRight","move"),!0}function g5(n){return Xo(n,"ArrowUp","move"),!0}function p5(n){if(Xo(n,"ArrowDown","move")||n.readonly)return!0;const t=n.getFocusedBlock(),e=rt(t);if(Xt(e)||Ze(e)!==t)return!0;const r=n.rootContainer;return n.insertTextBlock("",ft(r),Lr(r)),!0}function C5(n){return Xo(n,"ArrowDown","select"),!0}function E5(n){return Xo(n,"ArrowLeft","select"),!0}function x5(n){return Xo(n,"ArrowRight","select"),!0}function A5(n){return Xo(n,"ArrowUp","select"),!0}const b5=I("word-offset");function lp(n,t){const e=n.selection.range.focus;p(b5,e.isSimple(),"invalid range type");const r=n.getBlockById(e.blockId);if(ie(n,r))return lt(r,0,"home");if(e.offset===0||!nt(n,r)){const s=ge(r);if(!s)return null;const l=lt(s,dt(n,s),"end");if(t==="select"&&nt(n,s)){const c=V1(n,s,l.offset);return lt(s,c,"normal")}return l}const i=V1(n,r,e.offset);return lt(r,i,"normal")}function ap(n,t){const e=n.selection.range.focus;p(b5,e.isSimple(),"invalid range type");const r=n.getBlockById(e.blockId);if(ie(n,r))return lt(r,0,"end");if(e.offset===dt(n,r)||!nt(n,r)){const s=qt(r);if(!s)return null;const l=lt(s,0,"home");if(t==="select"&&nt(n,s)){const c=$1(n,s,l.offset);return lt(s,c,"end")}return l}const i=$1(n,r,e.offset);return lt(r,i,"normal")}function v5(n){if(!n.selection.range.focus.isSimple())return!1;const e=lp(n,"move");return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function B5(n){if(!n.selection.range.focus.isSimple())return!1;const e=ap(n,"move");return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function T5(n){if(!n.selection.range.focus.isSimple())return!1;const e=lp(n,"select");return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function y5(n){if(!n.selection.range.focus.isSimple())return!1;const e=ap(n,"select");return e?(n.selection.setSelection(n.selection.range.anchor,e),n.selection.updateLastCaretRect(),!0):!1}I("find-block");function cp(n,t){if(!_t(n,t))return t;const r=Qn(n,t).getChildContainers(n,t)[0],o=ue(r)[0];return cp(n,o)}function up(n,t){if(!_t(n,t))return t;const e=Qn(n,t).getChildContainers(n,t),r=e[e.length-1],i=ue(r),o=i[i.length-1];return up(n,o)}function fp(n){const t=up(n,Ze(n.rootContainer)),e=lt(t,dt(n,t),"end");return n.selection.setSelection(e),!0}function k5(n){const t=cp(n,n.getFirstBlock()),e=lt(t,0,"home");return n.selection.setSelection(e),!0}function R5(n){const t=cp(n,n.getFirstBlock()),e=lt(t,0,"home");return n.selection.setSelection(n.selection.getAnchorPos(),e),!0}function dp(n){const t=up(n,Ze(n.rootContainer)),e=lt(t,dt(n,t),"end");return n.selection.setSelection(n.selection.getAnchorPos(),e),!0}const w5=I("line-offset");function S5(n){const t=n.selection.range.focus;p(w5,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId);if(t.offset===0||!nt(n,e))return lt(e,0,"home");let i=iB(e,t).start;const{next:o}=qd(e,i);return o&&hr(o)&&su(o)==="br"&&(i+=1),lt(e,i,"home")}function L5(n){const t=n.selection.range.focus;p(w5,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId);if(t.offset===dt(n,e)||!nt(n,e))return lt(e,dt(n,e),"end");const r=iB(e,t);return lt(e,r.end,"end")}function I5(n){if(!n.selection.range.focus.isSimple())return!1;const e=S5(n);return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function D5(n){if(!n.selection.range.focus.isSimple())return!1;const e=L5(n);return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function _5(n){if(!n.selection.range.focus.isSimple())return!1;const e=S5(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function M5(n){if(!n.selection.range.focus.isSimple())return!1;const e=L5(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}const U5=I("find-block-position");function fU(n,t,e,r){p(U5,_t(n,t),"is not a complex block");const i=Qn(n,t).getChildContainers(n,t);p(U5,i.length>0,"complex block has not any child container");const o=_r(n,e,r),s=o.left+o.width/2,l=o.top+o.height/2,c=l3(n,t,s,l);return hp(n,c,e,r)}function hp(n,t,e,r){if(_t(n,t))return fU(n,t,e,r);const i=st(t);let o=Number.MAX_SAFE_INTEGER;const s=_r(n,e,r),l=s.left+s.width/2,c=s.top+s.height/2;let d=lt(i,0,"home");const h=dt(n,t);for(let C=0;C<=h;C++){const E=lt(i,C,"normal"),A=_r(n,t,E),v=$i(A,l,c);v<o&&(o=v,d=E)}return d}const O5=I("page-offset");function dU(n,t){const e=UB(n)*.9,i=t.getBoundingClientRect().bottom-e;if(i<MM(n))return n.getFirstBlock();const o=ge(t);if(!o)return n.getFirstBlock();let s=o;for(;s;){if(s.getBoundingClientRect().y<i)return s;s=ge(s)}return n.getFirstBlock()}function hU(n,t){const e=UB(n)*.9,r=t.getBoundingClientRect(),i=UM(n),o=r.top+e;if(o>i)return n.getLastBlock();const s=qt(t);if(!s)return n.getLastBlock();let l=s;for(;l;){if(l.getBoundingClientRect().bottom>o)return l;l=qt(l)}return n.getLastBlock()}function N5(n){const t=n.selection.range.focus;p(O5,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId),r=dU(n,e);let i;return r===n.getFirstBlock()?i=lt(r,0,"home"):i=hp(n,r,e,t),i}function P5(n){const t=n.selection.range.focus;p(O5,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId),r=hU(n,e);let i;return r===n.getLastBlock()?i=lt(r,dt(n,r),"end"):i=hp(n,r,e,t),i}function F5(n){if(!n.selection.range.focus.isSimple())return!1;const e=N5(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function K5(n){if(!n.selection.range.focus.isSimple())return!1;const e=P5(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function V5(n){if(!n.selection.range.focus.isSimple())return!1;const e=N5(n);if(!e)return!1;const r=wh(n,n.selection.getAnchorPos(),e);if(!r)return!1;const{anchor:i,focus:o}=r;return n.selection.setSelection(i,o),n.selection.updateLastCaretRect(),!0}function $5(n){if(!n.selection.range.focus.isSimple())return!1;const e=P5(n);if(!e)return!1;const r=wh(n,n.selection.getAnchorPos(),e);if(!r)return!1;const{anchor:i,focus:o}=r;return n.selection.setSelection(i,o),n.selection.updateLastCaretRect(),!0}const Tu=I("select-all");function H5(n,t){const e=we(n),r=Ze(n);return t.start.offset===0&&t.start.blockId===st(e)&&t.end.offset===dt(t.getEditor(),r)&&t.end.blockId===st(r)}function mU(n,t){const e=t.getEditor(),r=Qn(e,n).getChildContainers(e,n),i=r[0],o=r[r.length-1],s=st(n);return t.start.blockId===s&&t.start.childContainerId===ft(i)&&t.end.blockId===s&&t.end.childContainerId===ft(o)}function gU(n,t){p(Tu,t,"no parent block"),p(Tu,_t(n,t),"not a complex block");const e=Qn(n,t).getChildContainers(n,t),r=e[0],i=e[e.length-1];n.selection.setRange(qe(n,{anchor:xe(t,ft(r)),focus:xe(t,ft(i))}))}function j5(n,t){const e=rt(t);Sh(n,e)}function mp(n){const t=n.getFocusedBlock(),e=n.selection.range;if(e.start.isSimple()){if(e.start.blockId===e.end.blockId&&nt(n,t)){const i=e.start,o=e.end,s=dt(n,t);if(i.offset>0||o.offset<s)return n.selection.selectBlock(t,0,s),!1}return z(n.rootContainer,"select-all"),j5(n,we(n.rootContainer)),!1}return p(Tu,!e.isSimple(),"invalid range type"),mU(t,e)?(j5(n,t),!1):(p(Tu,t,"no parent block"),p(Tu,_t(n,t),"not a complex block"),gU(n,t),!0)}function Sh(n,t){const e=ue(t),r=e[0],i=e[e.length-1],o=lt(r,0,"home"),s=lt(i,dt(n,i),"end");n.selection.setSelection(o,s,{noScroll:!0})}function pU(n){dp(n),n.focus()}const gp=I("selected-block-to-doc");function z5(n,t,e){!t.children||t.children.forEach(r=>{const i=n.getChildContainerData(r);i.forEach(o=>{z5(n,o,e)}),e.blocks[r]=gt.default(i)})}function Lh(n,t){const e=Yt(n,t.block);if(e.selectionToDoc)return e.selectionToDoc(n,t);const r=gt.default(Wo(n,t.block));if(nt(n,t.block)){const o=t.start,s=t.end;if(p(gp,r.text,"no block text"),o.offset===s.offset)return{blocks:{root:[{...r,text:[]}]},meta:{},comments:{}};const{middle:l}=Xe(r.text,o.offset,s.offset-o.offset);return{blocks:{root:[{...r,text:l}]},meta:{},comments:{}}}if(pe(t.block))return{blocks:{root:[r]},meta:{},comments:{}};p(gp,_t(n,t.block),"not complex block"),p(gp,r.children,"no children");const i={blocks:{root:[r]},meta:{},comments:{}};return z5(n,r,i),i}function pp(n,t){const e=lt(t,0,"normal"),r=lt(t,dt(n,t),"end");return Lh(n,{block:t,start:e,end:r})}const CU=I("block-to-doc");function EU(n,t){p(CU,t.length>0,"invalid params, no blocks");const e=t.map(r=>pp(n,r));return tl(e)}function Sa(n){const e=n.selection.range.getSelectedBlocks().map(r=>Lh(n,r));return tl(e)}function G5(n,t){const e=n.getContainerById(t),o=ue(e).map(s=>({start:lt(s,0,"home"),end:lt(s,dt(n,s),"end"),block:s})).map(s=>Lh(n,s));return tl(o)}const Ih=I("editor-selection");class xU{constructor(t){m(this,"editor");m(this,"caret");m(this,"_range");m(this,"lastCaretRect");m(this,"handleBlockDelete",(t,e,r,i)=>{if(r||i.child)return;const o=this.range;if(PB(e,o)){Ih.debug("adjust selection because remote deleted current block");const s=FB(t,e);this.setRange(s,{noScroll:!0})}});this.editor=t;const e=t.getFirstBlock(),r=st(e);this.caret=new IM(t);const i=lt(r,0,"normal");this._range=qe(t,{anchor:i,focus:i}),this.lastCaretRect=null,this.editor.addListener("blockDeleted",this.handleBlockDelete),setTimeout(()=>{this.updateFocusedBlock(null)})}destroy(){this.caret.destroy()}get range(){return this._range}get focusedBlock(){return this.getFocusedBlock()}get startBlock(){return this.getStartBlock()}get endBlock(){return this.getEndBlock()}getFocusedBlock(){const t=this.range.focus;return this.editor.getBlockById(t.blockId)}getStartBlock(){const t=this.range.start;return this.editor.getBlockById(t.blockId)}getEndBlock(){const t=this.range.end;return this.editor.getBlockById(t.blockId)}selectBlock(t,e,r,i){const o=lt(t,e,"normal");let s;r&&(s=lt(t,r,"normal")),this.setSelection(o,s,i)}setSelection(t,e,r){if(e||(e=t),this.verifyPos(t),this.verifyPos(e),!this.selectionChanging(t,e))return this.range;const i=qe(this.editor,{anchor:t,focus:e});if(this.range.isEqual(i))return this.range;const o=this._range;return this._range=i,this.selectionChanged(),this.updateFocusedBlock(o),Rt(this.editor.rootContainer,"select-all")&&(!i.isSimple()||!KM(this.editor,i))&&ot(this.editor.rootContainer,"select-all"),r!=null&&r.noScroll||this.scrollIntoView(),this.range}setRange(t,e){return this.setSelection(t.anchor,t.focus,e)}updateSelection(){this.caret.update(),DM(this.editor)}getFocusedPos(){return this.range.focus}getAnchorPos(){return this.range.anchor}selectionChanging(t,e){return!0}selectionChanged(){this.updateSelection(),this.editor.emit("selectionChanged",this.editor)}updateLastCaretRect(){const t=this.range.focus;if(!Or(t))return;const e=this.editor.getBlockById(t.blockId);this.lastCaretRect=_r(this.editor,e,t)}getSuggestedCaretX(){var t;return(t=this.lastCaretRect)==null?void 0:t.x}scrollIntoView(){FM(this.editor)}verifyPos(t){const e=this.editor.getBlockById(t.blockId);if(t.isSimple())t.offset>=0&&t.offset<=dt(this.editor,e)||p(Ih,!1,"invalid block position, out of range");else{const r=t.childContainerId;!!this.editor.getContainerById(r)||p(Ih,!1,"invalid complex block position, no container found")}}updateFocusedBlock(t){if(t&&this.range.start.blockId===t.start.blockId)return;let e;t&&t.start.blockId===t.end.blockId&&(e=this.editor.findBlockById(t.start.blockId));let r;(this.range.isCollapsed()||!this.range.isSimple()||this.range.start.blockId===this.range.end.blockId)&&(r=this.editor.getBlockById(this.range.start.blockId));let i=!1;e&&Rt(e,"focused")&&(ot(e,"focused"),i=!0),this.removeAllBlockFocusedClass(),r&&this.setBlockFocused(r)&&(i=!0),i&&this.editor.emit("focusBlockChanged",this.editor,r!=null?r:null,e!=null?e:null)}verify(){this.verifyPos(this._range.start),this.verifyPos(this._range.end)}to(t){const e=Sa(this.editor);return t==="text"?ro(this.editor,e):t==="markdown"?$B(this.editor,e):VB(this.editor,e)}removeAllBlockFocusedClass(){this.editor.rootContainer.querySelectorAll('div[data-type="editor-block"].focused, div[data-type="editor-block"].child-focused').forEach(t=>{ot(t,"focused"),ot(t,"child-focused")})}setBlockFocused(t){if(Rt(t,"focused"))return!1;z(t,"focused");let e=rt(t);for(;Mr(e);){const r=et(e);p(Ih,r,"parent block not found"),z(r,"child-focused"),e=rt(r)}return!0}}function AU(n){const t=n.selection.range.focus;if(!t.isSimple())return;const e=n.findBlockById(t.blockId);!e||n.selection.selectBlock(e,0,dt(n,e))}function bU(n){const t=n.selection.range.focus;if(!t.isSimple())return;const e=n.findBlockById(t.blockId);if(!e||!nt(n,e))return;let r=lp(n,"select"),i=ap(n,"select");if(!r||!i)return;const o=t.blockId;r.blockId!==o&&(r=lt(e,0,"home")),i.blockId!==o&&(i=lt(e,dt(n,e),"end")),n.selection.setSelection(r,i)}class vU{constructor(t){m(this,"editor");m(this,"startPos",null);m(this,"lastCaretRect");m(this,"mouseDownEvent",null);m(this,"autoScroll",null);m(this,"handleMouseDown",(t,e)=>{var i;this.mouseDownEvent=t;const r=l1(this.editor,t.x,t.y);if(r){if(r instanceof di)return;if(!this.autoScroll&&e.autoScroll){const s=r.getSelectedBlocks(),l=En(s[0].block);this.autoScroll=new Vd({scrollElement:l,edge:{top:50,bottom:50}})}const o=this.editor.selection.range;if(t.shiftKey&&o.isSimple()){const s=o.anchor;this.editor.selection.setSelection(s,r.focus),this.startPos=r.start}else this.editor.selection.setSelection(r.anchor,r.focus),this.startPos=r.start;this.editor.selection.updateLastCaretRect(),e.autoScroll&&((i=this.autoScroll)==null||i.active())}});m(this,"handleMouseMove",t=>{if(!this.startPos||!this.mouseDownEvent||Math.abs(this.mouseDownEvent.x-t.x)<3&&Math.abs(this.mouseDownEvent.y-t.y)<3)return;const e=Yd(this.editor,t.x,t.y);if(!e)return;const r=wh(this.editor,this.startPos,e.end);if(!r)return;const{anchor:i,focus:o}=r;this.editor.selection.setSelection(i,o)});m(this,"handleMouseUp",t=>{var e;(e=this.autoScroll)==null||e.inactive(),this.startPos=null});this.editor=t,this.startPos=null,this.lastCaretRect=new DOMRect}isSelecting(){return this.startPos!==null}stopSelection(){this.startPos=null}handleDblClick(t){bU(this.editor)}handleTripleClick(t){AU(this.editor)}}function BU(n){return n.readonly||!n.isWritable()?!1:(n.undoManager.undo(),!0)}function TU(n){return n.readonly||!n.isWritable()?!1:(n.undoManager.redo(),!0)}const W5=I("delete-text");function q5(n,t,e,r){const i=r!=null?r:n.selection.range.start;i instanceof We||p(W5,!1,`invalid insert pos type: ${typeof i}`);const{blockId:o}=i,s=n.getBlockById(o);p(W5,nt(n,s),"block is not a text kind block");let{offset:l}=i;if(t==="backward"){if(l-e<0)return 0;if(!Un(s,l-e)){const c=Go(s,l);e=l-c}}else if(t==="forward"&&l+e>dt(n,s))return 0;return t==="backward"&&(l-=e),n.deleteTextFromBlock(s,l,e)}function X5(n,t){if(n.getBlockData(t).quoted){const e={quoted:null};return n.updateBlockData(t,e),!0}return!1}const yU=I("handle-backspace");function Cp(n,t){if(!ie(n,t))return;const e=rt(t);Lr(e)!==1&&n.deleteBlock(t)}function kU(n,t){if(!n.selection.range.isCollapsed()){n.clearSelectedContents();return}const e=n.selection.range.start,r=n.getBlockById(e.blockId);if(nt(n,r))if(e.offset===0){if(X5(n,r))return;const i=ge(r);if(i){if(!n.isBlockWritable(i))return;if(nt(n,i))n.mergeTextBlock(i,r,{focus:!0});else if(_t(n,i)){Cp(n,r);const o=pa(n,i);o?n.selection.selectBlock(o,dt(n,o)):n.selection.selectBlock(i,0,dt(n,i))}else Cp(n,r),p(yU,pe(i),"prev block is not embed block"),n.selection.selectBlock(i,1)}else{const o=rt(r);if(Mr(o)){const s=i3(n,o);if(s){if(!n.isBlockWritable(s))return;Cp(n,r),n.selection.selectBlock(s,dt(n,s))}}}}else q5(n,"backward",1,null),n.selection.updateLastCaretRect();else{const i=bt(r),o=rt(r);n.insertTextBlock("",ft(o),i),n.deleteBlock(r)}}function RU(n,t){if(!n.selection.range.isCollapsed()){n.clearSelectedContents();return}const e=n.selection.range.start,r=n.getBlockById(e.blockId);if(nt(n,r))if(e.offset===dt(n,r)){const i=qt(r);if(i){if(!n.isBlockWritable(i))return;nt(n,i)?n.mergeTextBlock(r,i,{focus:!0}):ie(n,r)?n.deleteBlock(r,Te(n,i,0)):n.deleteBlock(i)}}else q5(n,"forward",1,null);else{const i=bt(r),o=rt(r);n.insertTextBlock("",ft(o),i),n.deleteBlock(r)}}function wU(n){const{range:t}=n.selection,{start:e,end:r}=t,i=n.getBlockById(e.blockId),o=n.getBlockById(r.blockId);if(i!==o||!_t(n,i))return!1;if(Or(e))return!0;const s=ga(n,i,e,r),l=An(n,i);return s.length===l.length}function SU(n,t){if(wU(n)){const s=n.getFocusedBlock(),l=bt(s),c=ft(rt(s));n.insertTextBlock("",c,l+1);return}const e=n.getFocusedBlock(),{start:r,end:i}=n.selection.range,o=r.blockId===i.blockId&&pe(e);if(!n.selection.range.isCollapsed()&&!o&&n.clearSelectedContents(),nt(n,e)){if(ie(n,e)&&X5(n,e))return;const s=n.selection.range.start,l=n.breakTextBlock(e,s.offset,{copyBlockAttributes:!0});s.offset!==0?n.selection.selectBlock(l,0):n.selection.scrollIntoView()}else{const s=n.insertTextBlock();n.selection.selectBlock(s,0)}}function LU(n,t){const e=n.selection.range.getSelectedBlocks()[0],{block:r}=e;if(!nt(n,r))return!1;const i=e.end;return n.insertBoxToBlock(r,i.offset,{type:"br",id:Z(),box:!0,created:Date.now()}),!0}function Ep(n,t,e,r){if(e.type==="embed"){const l=e.embedData.src;if(l&&typeof l=="string")for(const c of l.split("|"))r.add(c);return}const i=e.text;i&&i.forEach(s=>{if(s.attributes&&s.attributes.src&&typeof s.attributes.src=="string")if(jo(s)){const l=n.editorBoxes.getBoxClass(s.attributes.type);if(l.getResources){const c=l.getResources(n,s.attributes);c?c.forEach(d=>{r.add(d)}):r.add(s.attributes.src)}else r.add(s.attributes.src)}else r.add(s.attributes.src)});const o=e.children;o&&o.forEach(s=>{t.blocks[s].forEach(c=>{Ep(n,t,c,r)})})}function IU(n,t){const e=new Set;return t.blocks.root.forEach(i=>{const o=n.editorBlocks.getBlockClass(i.type);if(o.getResources){const s=o.getResources(n,i);s?s.forEach(l=>{e.add(l)}):Ep(n,t,i,e)}else Ep(n,t,i,e)}),Array.from(e)}function La(n,t){return me.isFirefox?`<!doctype html><html><head><meta charset="utf8" /></head><body><canvas data-editor-doc="${ci(JSON.stringify(t))}" id="ones-editor-doc">${n}</body></html>`:`<!doctype html><html><head><meta charset="utf8" />${`<meta charset="utf-8"><ones-editor-doc data-source="ones-editor-doc::${ci(JSON.stringify(t))}::ones-editor-doc" />`}</head><body>${n}</body></html>`}function Ia(n,t){var o,s,l;const e=(l=(s=(o=n.doc).getServerMeta)==null?void 0:s.call(o))!=null?l:{},r=IU(n,t),i={};r.forEach(c=>{const d=n.doc.buildResourceUrl(c,{withToken:!0});i[c]=d}),t.meta={...e,resources:i}}function DU(n,t,e){if(t.preventDefault(),t.stopPropagation(),!t.clipboardData)return;let r=Sa(n);const i=e==null?void 0:e(n,t,r);if(i===!0)return;typeof i=="object"&&i!==null&&(r=i),Ia(n,r);const o=Ba(n,r),s=ro(n,r),l=La(o,r);t.clipboardData.setData("text/html",l),t.clipboardData.setData("text/plain",s),t.clipboardData.setData("text/x-ones-editor-doc",JSON.stringify(r))}function _U(n,t){if(n.selection.range.isCollapsed())return;let e=Sa(n);const r=t==null?void 0:t(n,new ClipboardEvent("mock-event"),e);if(r===!0)return;typeof r=="object"&&r!==null&&(e=r),Ia(n,e);const i=Ba(n,e),o=La(i,e),s=ro(n,e),l=new Blob([o],{type:"text/html"});da([{type:"text/plain",data:new Blob([s],{type:"text/plain"})},{type:"text/html",data:l}])}async function Dh(n,t){if(!window.isSecureContext)throw new Error("Can't copy block in insecure context.");const e=pp(n,t);Ia(n,e);const r=Ba(n,e),i=ro(n,e),o=La(r,e);return da([{type:"text/plain",data:new Blob([i],{type:"text/plain"})},{type:"text/html",data:new Blob([o],{type:"text/html"})}])}const MU=I("input-handler-actions");function Q5(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(SU(n),!0))}function Y5(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(RU(n),!0))}function J5(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(kU(n),!0))}function Z5(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(LU(n),!0))}function t2(n){return n.readonly||!n.isWritable()||!window.isSecureContext?!1:(navigator.clipboard.readText().then(t=>{n.input.handlePasteText(t,{toPlainText:!0})}).catch(t=>{MU.error(t)}),!0)}function e2(n){return n.selection.range.getSelectedBlocks().every(e=>{const r=e.block,i=rt(r);if(Xt(i))return!1;const o=et(i);return o&&St(o)==="code"})}function n2(n,t){const e=n.selection.range.getSelectedBlocks(),r=rt(e[0].block),i=et(r);return i?`\`\`\`${n.getBlockData(i).language}
|
|
27
|
+
`)}const HM=I("get-text-position");function Ta(n,t){const e=t!=null?t:n.selection.range.start;e instanceof We||p(HM,!1,`invalid insert pos type: ${typeof e}`);const{blockId:r}=e,i=n.getBlockById(r),o=bt(i),s=rt(i),l=ft(s),{offset:c}=e;return{block:i,container:s,containerId:l,blockIndex:o,offset:c}}const ya=I("insert-text");function W1(n,t,e,r){var s;const i=n.doc.getBlockData(t,e);if(p(ya,i,"no block data"),p(ya,i.text,"no block text"),un(i.text)===0)return p(ya,r===0,"invalid text offset"),n.editorCommandProviders.getEmptyBlockTextAttributes(n,i.id);if(r===0)return;const o=Xe(i.text,r-1,1).middle;if(!((s=o[0].attributes)!=null&&s.box))return o[0].attributes}function jM(n,t,e){const r=rt(t),i=ft(r),o=bt(t);return W1(n,i,o,e)}function HB(n,t,e,r,i){const o=rt(t),s=ft(o),l=bt(t),c=jM(n,t,e),d=uh(e,r,c!=null?c:null);return n.doc.localUpdateBlockText(s,l,d,i),bn(n,t)}function jB(n,t,e,r){const i=rt(t),o=ft(i),s=bt(t),l=uh(e," ",r);return n.doc.localUpdateBlockText(o,s,l),bn(n,t)}function zM(n,t){let e=0;if(t===0)return!1;for(let r=0;r<n.length;r++){const i=n[r];p(ya,typeof i.insert=="string","invalid text op, no insert");const o=e+rh(i);if(o===t)return!1;if(o>t)return!0;e=o}return!1}function q1(n,t,e,r,i){const o=n.doc.getBlockData(e,r);p(ya,o,"no block data"),p(ya,o.text,"no block text");const s=W1(n,e,r,i);s&&Object.keys(s).includes("link")&&(zM(o.text,i)||delete s.link);const l=uh(i,t,s!=null?s:null);return n.doc.localUpdateBlockText(e,r,l),bn(n,n.getBlockById(o.id))}function X1(n,t){n.selection.range.isCollapsed()||n.clearSelectedContents();const{containerId:e,blockIndex:r,offset:i}=Ta(n);q1(n,t,e,r,i)}const bh=I("update-composition-text");function zB(n){const t=n.selection.range.start;t instanceof We||p(bh,!1,`invalid insert pos type: ${typeof t}`);const{blockId:e}=t,r=n.getBlockById(e);p(bh,nt(n,r),"not a text kind block");const i=rt(r),o=ft(i),s=bt(r),l=n.doc.getBlockData(o,s);p(bh,l,"no block data in doc"),p(bh,l.text,"no text data in text block");const c=Ot(r);oh(n,Vo(r),e,c,l.text)}function Q1(n){a_(n)}function ka(n,t,e,r,i,o){return n.doc.localInsertBlock(t,e,r,i,o),n.getBlockById(r.id)}const xu=I("delete-block-text");function Y1(n,t,e,r,i){if(!n.isBlockWritable(t))return xu.error("block is not writable"),0;p(xu,nt(n,t),"block is not a text kind block");const o=rt(t),s=ft(o),l=bt(t),c=n.doc.getBlockData(s,l);p(xu,c,"no block data in doc"),p(xu,c.text,"no text data in text block");let d=e;Un(t,e)||(d=Go(t,d));let h=e+r;p(xu,h<=dt(n,t),`invalid offset and count: ${e}, ${r}`),Un(t,h)||(h=Ys(t,h));const C=h-d,E=cB(d,C);return n.doc.localUpdateBlockText(s,l,E,i),console.log("delete"),C}const J1=I("break-text-block");function GB(n,t){const r=n.getBlockData(t).quoted;return r?{quoted:r}:{}}function Ra(n,t,e,r){p(J1,nt(n,t),`block is not a text kind block: ${St(t)}`),p(J1,e>=0&&e<=dt(n,t),`invalid offset: ${e}`);const i=rt(t),o=ft(i),s=bt(t),l=r!=null&&r.copyBlockAttributes?GB(n,t):{};if(!(r!=null&&r.forceInsertAfter)&&(e===0||e===dt(n,t))){const A=e===0?s:s+1,v={...pi(""),...l,...r==null?void 0:r.newBlockData},R=Te(n,t.id,0),L=ka(n,o,A,v,R);return{block:t,newBlock:L}}p(J1,Un(t,e),"not a valid offset");const c=bn(n,t),{right:d}=_n(c,e),h=un(d);h>0&&Y1(n,t,e,h);const C={...pi(d),...l,...r==null?void 0:r.newBlockData},E=ka(n,o,s+1,C,Te(n,C.id,0));return{block:t,newBlock:E}}const GM=I("prepare-insert-new-block");function WM(n,t,e){if(t&&e!==void 0&&e!==null){const d=n.getContainerById(t),h=ue(d);return p(GM,e>=0&&e<=h.length,`invalid blockIndex: ${e}`),{containerId:t,blockIndex:e}}const r=n.selection.range.start;if(!r.isSimple())return null;const i=n.getBlockById(r.blockId);if(t=ft(rt(i)),e=bt(i),!nt(n,i))return{containerId:t,blockIndex:e+1};const s=r.offset;if(s===0||s===dt(n,i))return{containerId:t,blockIndex:s===0?e:e+1};const c=Ra(n,i,s).newBlock;return{containerId:t,blockIndex:bt(c)}}const qM=I("auto-insert-block");function WB(n,t,e,r,i,o){const s=WM(n,e,r);p(qM,s,`not an valid insert position: ${n.selection.range}`);const l={blockId:t.id,offset:0},c={anchor:l,focus:l};return ka(n,s.containerId,s.blockIndex,t,i!=null?i:c,o)}const XM=I("delete-block");function vh(n,t,e){t.children&&(e.push(...t.children),t.children.forEach(r=>{n.getChildContainerData(r).forEach(o=>{vh(n,o,e)})}))}function Bh(n,t,e){const r=rt(t),i=ft(r),o=bt(t),s=n.doc.getBlockData(i,o);return p(XM,s,"no block data in doc"),n.doc.localDeleteBlock(i,o,qe(n,{anchor:e.start,focus:e.end})),s}function Z1(n,t,e){return n.undoManager.runInGroup(()=>{const r=rt(t);Lr(r)===1&&n.insertTextBlock("",ft(r),0);let i=e?$o(n,e):null;if(!i){const l=n.selection.range;PB(t,l)?i=FB(n,t):i=l}const o=Bh(n,t,i),s=[];return vh(n,o,s),s.length>0&&n.doc.localDeleteChildContainers(s),o})}function QM(n,t){const e=[t];n.doc.getContainerBlocks(t).forEach(i=>{vh(n,i,e)}),n.doc.localDeleteChildContainers(e)}function qB(n,t){const e=[...t];t.forEach(r=>{n.doc.getContainerBlocks(r).forEach(o=>{vh(n,o,e)})}),n.doc.localDeleteChildContainers(e)}const tp=I("merge-text-block");function XB(n,t,e){p(tp,nt(n,t),"only text block can be merged"),p(tp,nt(n,e),"only text block can be merged");const r=Wo(n,t),i=Wo(n,e),o=r.text,s=i.text;p(tp,o&&s,"block data has no text");const l=rt(t),c=ft(l),d=bt(t),h=dt(n,t),C=q1(n,s,c,d,h),E=Te(n,t,un(o));return Z1(n,e,E),C}const Ci=I("clear-selected-contents");function Th(n,t){p(Ci,nt(n,t.block),"not a text kind block");const{start:e,end:r}=t;p(Ci,e.isSimple(),"not a simple block position"),p(Ci,r.isSimple(),"not a simple block position");const i=e.offset,o=r.offset;p(Ci,i<=o,`invalid delete text offset: ${i}, ${o}`),i!==o&&n.deleteTextFromBlock(t.block,i,o-i)}function QB(n,t,e){const r=ft(t),i=ue(t),o=e.focus?void 0:n.selection.range.toDocRange(),s=n.insertTextBlock("",r,0,{newRange:o});e.focus&&n.selection.selectBlock(s,0),i.reverse().forEach(l=>{n.deleteBlock(l)})}function YM(n,t){const{block:e,start:r,end:i}=t;if(nt(n,e)){Th(n,t);return}if(pe(e)||r.isSimple()){p(Ci,i.isSimple(),"invalid range");const s=rt(e),l=bt(e),c=n.insertTextBlock("",ft(s),l);n.selection.selectBlock(c,0),n.deleteBlock(e);return}p(Ci,Dt(n,e),"invalid block kind"),p(Ci,!r.isSimple()&&!i.isSimple(),"invalid range"),ga(n,e,r,i),n.selection.range.getSelectedContainers().forEach((s,l)=>{QB(n,s,{focus:l===0})})}function JM(n){if(!n.isWritable())return;const t=n.selection.range;if(t.isCollapsed())return;const e=t.getSelectedBlocks();if(p(Ci,e.length>0,"no selected block"),e.length===1){YM(n,e[0]);return}const r=e[0],i=r.block,o=rt(i);p(Ci,e.length>1,"no selected block");const s=e[e.length-1],l=s.block;if(nt(n,i)){Th(n,r);const h=Te(n,r.block,r.start.offset);if(e.slice(1,e.length-1).reverse().forEach(E=>n.deleteBlock(E.block)),nt(n,l)){Th(n,s),n.mergeTextBlock(i,l,{focus:!0}),n.selection.setRange(h);return}n.deleteBlock(l),n.selection.setRange(h);return}if(nt(n,l)){Th(n,s),e.slice(0,e.length-1).reverse().forEach(h=>n.deleteBlock(h.block)),n.selection.selectBlock(s.block,0);return}if(e.length===Lr(o)){QB(n,o,{focus:!0});return}const c=ge(i),d=qt(l);p(Ci,c||d,"no prev or next block"),e.forEach(h=>n.deleteBlock(h.block))}function yh(n){n.selection.range.isCollapsed()||n.undoManager.runInGroup(()=>{n.emit("beforeClearSelection",n);try{n.doc.beginBatchUpdate(),JM(n)}finally{n.doc.endBatchUpdate()}n.emit("afterClearSelection",n)})}const ZM=I("core");function YB(n,t,e,r){const i=rt(t),o=ft(i),s=bt(t);return n.doc.localUpdateBlockText(o,s,e,r),setTimeout(()=>{n.selection.updateSelection(null)}),bn(n,t)}function JB(n,t,e,r){if(!n.isBlockWritable(t)){ZM.error("block is not writable");return}const i=n.getBlockText(t),o=fn.diff(i,e);YB(n,t,o,r)}function kh(n,t,e){const r=bn(n,t),i=typeof e=="string"?Zs(e):e,o=fn.diff(r,i);return YB(n,t,o)}const Au=I("update-block-data");function Rh(n,t,e,r){const i=rt(t),o=ft(i),s=bt(t),l=n.doc.getBlockData(o,s),c={insert:{},delete:[]},d=new Set(Object.keys(l)),h=new Set(Object.keys(e));return d.forEach(E=>{if(!h.has(E)){if(E==="id"||E==="type"||E==="text")return;Au.debug(`delete key: ${E}`),c.delete.push(E)}}),Object.entries(e).forEach(([E,A])=>{p(Au,E!=="id"&&E!=="type",`invalid block data delta, ${E}`);const v=l[E];if(A==null){v!=null&&(Au.debug(`delete key: ${E}`),c.delete.push(E));return}v!==A&&(qc.default(v,A)||E==="text"&&fn.diff(v,A).length===0||(d.has(E)?(Au.debug(`replace key: ${E}`),c.delete.push(E)):Au.debug(`insert key: ${E}`),c.insert[E]=A))}),n.doc.localUpdateBlockData(o,s,c,r),Wo(n,t)}function ZB(n,t,e,r){const o={...n.getBlockData(t),embedData:e};return n.updateBlockData(t,o,r)}function ep(n,t,e){if(!Dt(n,t)||!(e!=null&&e.tryFocusToChildSimpleBlock)){n.selection.selectBlock(t,0);return}const i=Qn(n,t).getChildContainers(n,t)[0],o=we(i);ep(n,o,e)}function tl(n){const t=[];let e={};return n.forEach(r=>{t.push(...r.blocks.root);const{root:i,...o}=r.blocks;e={...e,...o}}),{blocks:{...e,root:t},meta:{},comments:{}}}const bu=I("clone-block");function qo(n,t,e,r){const i=n.getBlockClass(e.type);if(i.blockToDoc)return i.blockToDoc(t,e,(h,C)=>(p(bu,e!==C,"invalid child block"),qo(n,h,e,r)));let o={};const s=new Map,l=gt.default(e);l.children&&(l.children=l.children.map(h=>{const C=Z(),E=t.blocks[h];p(bu,Array.isArray(E),"invalid child blocks");const A=E.map(M=>qo(n,t,M,r)),v=tl(A),{root:R,...L}=v.blocks;return o={...o,...L},o[C]=v.blocks.root,s.set(h,C),C}));const c=Array.from(s.entries()),d=h=>{for(const C of c){const[E,A]=C;{const v=`${E}/`;if(h.startsWith(v)){const R=h.substring(v.length),L=`${A}/${R}`;return bu.debug(`replace key: ${h} -> ${L}`),L}}{const v=`${E}_`;if(h.startsWith(v)){const R=h.substring(v.length),L=`${A}_${R}`;return bu.debug(`replace key: ${h} -> ${L}`),L}}}return h};return Array.from(Object.entries(l)).forEach(([h,C])=>{const E=d(h);E!==h&&delete l.key,l[E]=C}),l.id=Z(),r&&(r.blockIdMap.set(e.id,l.id),s.forEach((h,C)=>r.containerIdMap.set(C,h))),{blocks:{root:[l],...o},meta:{},comments:{}}}function np(n,t,e,r){const i=t.blocks[e];p(bu,Array.isArray(i),"invalid child blocks");const o=i.map(l=>qo(n,t,l,r));return tl(o)}function rp(n,t,e){const r=t.blocks.root.map(i=>qo(n.editorBlocks,t,i,e));return gt.default(tl(r))}const t5=I("insert-doc");function e5(n,t,e,r,i){if(Dt(n,t)){t5.warn("failed to insert doc into a complex block");return}const o=rp(n,r,i),s=rt(t),l=bt(t),c=ft(s);n.doc.beginBatchUpdate(),n.undoManager.runInGroup(()=>{var F,G,W,it;const d=[];Object.entries(o.blocks).forEach(([at,xt])=>{at!=="root"&&d.push({containerId:at,blocks:xt})}),d.length>0&&n.doc.localInsertChildContainers(d);const h=o.blocks.root;if(pe(t)){n.deleteBlock(t);let at;h.reverse().forEach(xt=>{const Mt=n.insertBlock(c,l,xt,void 0,{noFocus:!0});at||(at=Mt)}),at&&n.selection.selectBlock(at,dt(n,at));return}if(p(t5,nt(n,t),"not a text block"),ie(n,t)){const at=bt(t);let xt,Mt=!1;for(let Bt=0;Bt<h.length;Bt++){if(Bt===0){const te=n.findBlockByIndex(c,at),kn=h[Bt].type==="text"||h[Bt].type==="list",be=te&&St(te)===h[Bt].type;if(te&&nt(n,te)&&ie(n,te)&&kn&&be){n.insertTextToBlock(t,0,(F=h[Bt].text)!=null?F:[]),Object.keys(h[Bt]).length>3&&n.updateBlockData(te,i_(h[Bt],["id","text","type","heading","quoted"]));continue}te&&Gi(te)&&(Mt=!0)}const le=n.insertBlock(c,at+Bt,h[Bt],void 0,{noFocus:!0});Bt===h.length-1&&(xt=le)}xt&&n.selection.selectBlock(xt,dt(n,xt)),Mt&&n.deleteBlock(t);return}if(h.length===1){const at=h[0];if(iu(n,at.type)){n.insertTextToBlock(t,e,(G=at.text)!=null?G:[]);return}n.breakTextBlock(t,e),n.insertBlock(c,l+1,at);return}const C=e===dt(n,t),E=e===0,A=h[0],v=h[h.length-1];let R;!C&&!E?R=n.breakTextBlock(t,e,{forceInsertAfter:!0}):R=t;const L=E?l:l+1;C?(R=n.insertBlock(c,l+1,v),n.selection.selectBlock(R,dt(n,R))):(n.selection.selectBlock(R,0),iu(n,v.type)?n.insertTextToBlock(R,0,(W=v.text)!=null?W:[]):n.insertBlock(c,L,v));const M=n.selection.range;let U=L;iu(n,A.type)?E?(n.insertBlock(c,L,A),U+=1):n.insertTextToBlock(t,e,(it=A.text)!=null?it:[]):(n.insertBlock(c,L,A),U+=1),h.slice(1,h.length-1).reverse().forEach(at=>{n.insertBlock(c,U,at)}),n.selection.setRange(M)}),n.doc.endBatchUpdate()}function ip(n,t,e,r,i){const o=rp(n,r,i),s=ft(t),l=[];return n.undoManager.runInGroup(()=>{const c=[];Object.entries(o.blocks).forEach(([h,C])=>{h!=="root"&&c.push({containerId:h,blocks:C})}),n.doc.localInsertChildContainers(c),o.blocks.root.reverse().forEach(h=>{const C=n.insertBlock(s,e,h,void 0,{noFocus:!0,noScroll:!0});l.push(C)})}),l}function n5(n,t,e,r){const i=Lr(t);ip(n,t,i,e,r);for(let o=0;o<i;o++){const s=we(t);n.deleteBlock(s)}}const vu=I("add-text-attribute");function tU(n,t,e,r){const{start:i,end:o}=e;p(vu,i.blockId===o.blockId&&i.blockId===st(t),"invalid range"),p(vu,r,"invalid attribute name");const s=n.getBlockText(t),l=xa(i.offset,o.offset-i.offset,s,r,void 0,{ignoreValue:!0});return n.setBlockText(t,l),l}function r5(n,t,e,r,i){const{start:o,end:s}=e;p(vu,o.blockId===s.blockId&&o.blockId===st(t),"invalid range"),p(vu,r,"invalid attribute name");const l=n.getBlockText(t),c=gu(o.offset,s.offset-o.offset,l,r,i);return n.setBlockText(t,c),c}function wa(n,t,e,r,i){const{start:o,end:s}=e;p(vu,o.blockId===s.blockId&&o.blockId===st(t),"invalid range");const l=n.getBlockText(t),c=Q3(o.offset,s.offset-o.offset,l,r,i);return n.setBlockText(t,c),c}function i5(n,t,e,r){const i=hi(n,{simpleBlockOnly:!0});n.undoManager.runInGroup(()=>{i.forEach(o=>{const{block:s,start:l,end:c}=o;if(!nt(n,s))return;if(ie(n,s)){r(n,st(s),t,e);return}const d=qe(n,{anchor:l,focus:c});t==="color"||t==="backgroundColor"?wa(n,s,d,t,e):(wa(n,s,d,"color",null),wa(n,s,d,"backgroundColor",null))})})}function o5(n,t,e){const r=hi(n,{simpleBlockOnly:!0});n.undoManager.runInGroup(()=>{r.forEach(i=>{const{block:o,start:s,end:l}=i;if(!nt(n,o))return;if(ie(n,o)){(t==="clearColor"||t==="clearAll")&&e(n,st(o),"color",null),(t==="clearBackground"||t==="clearAll")&&e(n,st(o),"backgroundColor",null);return}const c=qe(n,{anchor:s,focus:l});(t==="clearColor"||t==="clearAll")&&wa(n,o,c,"color",null),(t==="clearBackground"||t==="clearAll")&&wa(n,o,c,"backgroundColor",null)})})}function s5(n,t,e){const r=t.getSelectedBlocks().filter(l=>nt(n,l.block));if(r.length===0)return[null,null];const i=l=>{if(dt(n,l.block)===0)return e(n,st(l.block));const c=l.start,d=l.end,h=n.getBlockText(l.block);return Z3(c.offset,d.offset-c.offset,h)};let[o,s]=i(r[0]);return o===null&&s===null?[o,s]:(r.forEach(l=>{const[c,d]=i(l);c===null||o===null?o=null:o=c===o?o:null,d===null||s===null?s=null:s=d===s?s:null}),[o,s])}const Jn=I("adjust-selection-pos");function l5(n){const t=[];for(;n;){const e=rt(n);if(t.unshift(e),Xt(e))return t;const r=et(e);p(Jn,r,"child container has not parent container"),n=r}p(Jn,!1,"should not come here: getParentContainers")}function a5(n,t){for(;t;){const e=rt(t);if(e===n)return t;const r=et(e);p(Jn,r,"could not find parent block for a child container"),t=r}p(Jn,!1,"no parent block in specified container")}function eU(n,t){const e=l5(n),r=l5(t);p(Jn,e.length>0&&r.length>0,"block has not parent container"),p(Jn,e[0]===r[0],"root container does not equal");let i=e[0];for(let l=1;l<e.length||r.length;l++)if(e[l]!==r[l]){i=e[l-1];break}const o=a5(i,n),s=a5(i,t);return{parentContainer:i,newBlock1:o,newBlock2:s}}function c5(n,t){let e=et(t);for(p(Jn,e,"element is not in a block");e;){const r=rt(e);p(Jn,Mr(r),"not a child container");const i=et(r);if(p(Jn,i,"child container has not parent block"),i===n)return r;e=i}p(Jn,!1,"failed to find parent container in complex block")}function wh(n,t,e){const r=n.getBlockById(t.blockId),i=n.getBlockById(e.blockId);if(r===i)return t instanceof We&&e instanceof We?{anchor:t,focus:e}:t instanceof Ur&&e instanceof Ur?Qd(n,r,t,e):null;const o=rt(r),s=rt(i);if(o===s)return t instanceof Ur&&(t=lt(r,0,"home")),e instanceof Ur&&(e=lt(i,dt(n,i),"end")),p(Jn,t instanceof We,"not valid position type"),p(Jn,e instanceof We,"not valid position type"),{anchor:t,focus:e};if(r.contains(s))return null;if(i.contains(o)){if(t instanceof We&&e instanceof Ur){const v=n.getContainerById(e.childContainerId);if(v===o)return{anchor:e,focus:e};const R=et(o);if(R&&R===et(v)){const L=xe(R,ft(o)),M=xe(R,ft(v));return Qd(n,R,L,M)}}return null}const l=_d(r,i)>0,{newBlock1:c,newBlock2:d}=eU(r,i);if(c===d){const v=c,R=c5(v,r),L=c5(v,i);return t=xe(c,ft(R)),e=xe(c,ft(L)),Jn.debug(`select in complex block: ${R.id}, ${L.id}`),Qd(n,v,t,e)}let h=l?dt(n,c):0;c===r&&t instanceof We&&(h=t.offset);let E=l?0:dt(n,d);return d===i&&e instanceof We&&(E=e.offset),t=lt(c,h,l?"end":"home"),e=lt(d,E,l?"home":"end"),{anchor:t,focus:e}}const nU=I("move-complex-block-position");function rU(n,t,e){const r=n.getBlockById(t.blockId);p(nU,Dt(n,r),"is not a complex block");const i=Qn(n,r),o=n.getContainerById(t.childContainerId),s=i.getNextContainer(n,r,o,e,{noWrap:!0});return s?xe(r,ft(s)):null}const Bu=I("move-simple-block-position");function u5(n,t){const e=An(n,t,{visibleOnly:!0});p(Bu,e.length>0,"complex block has not any child container");const r=e[0];return we(r)}function f5(n,t){const e=An(n,t,{visibleOnly:!0});p(Bu,e.length>0,"complex block has not any child container");const r=e[e.length-1];return Ze(r)}function d5(n,t,e){const r=e?u5(n,t):f5(n,t);return Dt(n,r)?d5(n,r,e):r}function iU(n,t){const e=n.getBlockById(t.blockId);return Dt(n,e)&&t.offset===0?u5(n,e):zs(e)}function oU(n,t){const e=n.getBlockById(t.blockId);return Dt(n,e)&&t.offset===1?f5(n,e):js(e)}function op(n){return n==="ArrowLeft"||n==="ArrowUp"}function sp(n,t,e){const r=rt(t);if(Xt(r))return null;const i=et(r);p(Bu,i,"child container has not parent block"),p(Bu,Dt(n,i),"is not a complex block");const o=Qn(n,i).getNextContainer(n,i,r,e);return o?op(e)?Ze(o):we(o):sp(n,i,e)}function sU(n,t,e){const r=rt(t);if(Xt(r))return null;const i=et(r);if(p(Bu,i,"child container has not parent block"),op(e)){const l=ge(i);if(l)return l}else{const l=qt(i);if(l)return l}const o=sp(n,i,e);if(o)return o;let s=i;for(;!Xt(rt(s));)s=et(rt(s));return op(e)?ge(s):qt(s)}function lU(n,t,e){return!Dt(n,t)||Qn(n,t).enableKeyboardSelect?t:d5(n,t,e==="ArrowDown"||e==="ArrowRight")}function aU(n,t,e){const r=n.getBlockById(t.blockId),o=Yt(n,r).moveCaret(n,r,t,e);if(o)return o;let s=e==="ArrowDown"||e==="ArrowRight"?iU(n,t):oU(n,t);if(s||(s=sp(n,r,e),s||(s=sU(n,r,e))),!s){if(e==="ArrowDown"||e==="ArrowRight"){if(n.readonly||!Xt(rt(r)))return null;const l=n.insertTextBlock("",ft(n.rootContainer),Lr(n.rootContainer));return lt(l,0,"home")}return null}if(s=lU(n,s,e),nt(n,s)){const l=n.selection.getSuggestedCaretX();if(e==="ArrowDown")return I_(n,s,r,t,l);if(e==="ArrowUp")return L_(n,s,r,t,l)}return e==="ArrowLeft"||e==="ArrowUp"?lt(s,dt(n,s),"end"):e==="ArrowRight"||e==="ArrowDown"?lt(s,0,"home"):null}function cU(n,t,e){if(t==="ArrowLeft")return e.start;const r=e.end,i=n.getBlockById(r.blockId);if(nt(n,i))return r;const o=qt(i);if(o)return lt(o,0,"home");if(!Xt(rt(i))||n.readonly)return r;const s=n.insertTextBlock("",ft(n.rootContainer),Lr(n.rootContainer));return lt(s,0,"home")}function uU(n,t,e){const r=n.selection.range;let i;if(r instanceof tn)e==="move"&&!r.isCollapsed()&&(t==="ArrowLeft"||t==="ArrowRight")?i=cU(n,t,r):i=aU(n,r.getFocusedPos(),t);else if(i=rU(n,r.focus,t),e==="move"){const o=i!=null?i:r.focus,s=n.getContainerById(o.childContainerId);if(t==="ArrowLeft"||t==="ArrowUp"){const l=Ze(s);i=lt(l,0,"home")}else{const l=we(s);i=lt(l,dt(n,l),"end")}}return i?e==="move"?{anchor:i,focus:i}:wh(n,r.anchor,i):null}function Xo(n,t,e){const r=uU(n,t,e);if(!r)return!1;const{anchor:i,focus:o}=r;return n.selection.setSelection(i,o),(t==="ArrowLeft"||t==="ArrowRight")&&n.selection.updateLastCaretRect(),!0}function h5(n){return Xo(n,"ArrowLeft","move"),!0}function m5(n){return Xo(n,"ArrowRight","move"),!0}function g5(n){return Xo(n,"ArrowUp","move"),!0}function p5(n){if(Xo(n,"ArrowDown","move")||n.readonly)return!0;const t=n.getFocusedBlock(),e=rt(t);if(Xt(e)||Ze(e)!==t)return!0;const r=n.rootContainer;return n.insertTextBlock("",ft(r),Lr(r)),!0}function C5(n){return Xo(n,"ArrowDown","select"),!0}function E5(n){return Xo(n,"ArrowLeft","select"),!0}function x5(n){return Xo(n,"ArrowRight","select"),!0}function A5(n){return Xo(n,"ArrowUp","select"),!0}const b5=I("word-offset");function lp(n,t){const e=n.selection.range.focus;p(b5,e.isSimple(),"invalid range type");const r=n.getBlockById(e.blockId);if(ie(n,r))return lt(r,0,"home");if(e.offset===0||!nt(n,r)){const s=ge(r);if(!s)return null;const l=lt(s,dt(n,s),"end");if(t==="select"&&nt(n,s)){const c=V1(n,s,l.offset);return lt(s,c,"normal")}return l}const i=V1(n,r,e.offset);return lt(r,i,"normal")}function ap(n,t){const e=n.selection.range.focus;p(b5,e.isSimple(),"invalid range type");const r=n.getBlockById(e.blockId);if(ie(n,r))return lt(r,0,"end");if(e.offset===dt(n,r)||!nt(n,r)){const s=qt(r);if(!s)return null;const l=lt(s,0,"home");if(t==="select"&&nt(n,s)){const c=$1(n,s,l.offset);return lt(s,c,"end")}return l}const i=$1(n,r,e.offset);return lt(r,i,"normal")}function v5(n){if(!n.selection.range.focus.isSimple())return!1;const e=lp(n,"move");return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function B5(n){if(!n.selection.range.focus.isSimple())return!1;const e=ap(n,"move");return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function T5(n){if(!n.selection.range.focus.isSimple())return!1;const e=lp(n,"select");return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function y5(n){if(!n.selection.range.focus.isSimple())return!1;const e=ap(n,"select");return e?(n.selection.setSelection(n.selection.range.anchor,e),n.selection.updateLastCaretRect(),!0):!1}I("find-block");function cp(n,t){if(!Dt(n,t))return t;const r=Qn(n,t).getChildContainers(n,t)[0],o=ue(r)[0];return cp(n,o)}function up(n,t){if(!Dt(n,t))return t;const e=Qn(n,t).getChildContainers(n,t),r=e[e.length-1],i=ue(r),o=i[i.length-1];return up(n,o)}function fp(n){const t=up(n,Ze(n.rootContainer)),e=lt(t,dt(n,t),"end");return n.selection.setSelection(e),!0}function k5(n){const t=cp(n,n.getFirstBlock()),e=lt(t,0,"home");return n.selection.setSelection(e),!0}function R5(n){const t=cp(n,n.getFirstBlock()),e=lt(t,0,"home");return n.selection.setSelection(n.selection.getAnchorPos(),e),!0}function dp(n){const t=up(n,Ze(n.rootContainer)),e=lt(t,dt(n,t),"end");return n.selection.setSelection(n.selection.getAnchorPos(),e),!0}const w5=I("line-offset");function S5(n){const t=n.selection.range.focus;p(w5,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId);if(t.offset===0||!nt(n,e))return lt(e,0,"home");let i=iB(e,t).start;const{next:o}=qd(e,i);return o&&hr(o)&&su(o)==="br"&&(i+=1),lt(e,i,"home")}function L5(n){const t=n.selection.range.focus;p(w5,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId);if(t.offset===dt(n,e)||!nt(n,e))return lt(e,dt(n,e),"end");const r=iB(e,t);return lt(e,r.end,"end")}function I5(n){if(!n.selection.range.focus.isSimple())return!1;const e=S5(n);return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function D5(n){if(!n.selection.range.focus.isSimple())return!1;const e=L5(n);return e?(n.selection.setSelection(n.selection.getAnchorPos(),e),n.selection.updateLastCaretRect(),!0):!1}function _5(n){if(!n.selection.range.focus.isSimple())return!1;const e=S5(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function M5(n){if(!n.selection.range.focus.isSimple())return!1;const e=L5(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}const U5=I("find-block-position");function fU(n,t,e,r){p(U5,Dt(n,t),"is not a complex block");const i=Qn(n,t).getChildContainers(n,t);p(U5,i.length>0,"complex block has not any child container");const o=_r(n,e,r),s=o.left+o.width/2,l=o.top+o.height/2,c=l3(n,t,s,l);return hp(n,c,e,r)}function hp(n,t,e,r){if(Dt(n,t))return fU(n,t,e,r);const i=st(t);let o=Number.MAX_SAFE_INTEGER;const s=_r(n,e,r),l=s.left+s.width/2,c=s.top+s.height/2;let d=lt(i,0,"home");const h=dt(n,t);for(let C=0;C<=h;C++){const E=lt(i,C,"normal"),A=_r(n,t,E),v=$i(A,l,c);v<o&&(o=v,d=E)}return d}const O5=I("page-offset");function dU(n,t){const e=UB(n)*.9,i=t.getBoundingClientRect().bottom-e;if(i<MM(n))return n.getFirstBlock();const o=ge(t);if(!o)return n.getFirstBlock();let s=o;for(;s;){if(s.getBoundingClientRect().y<i)return s;s=ge(s)}return n.getFirstBlock()}function hU(n,t){const e=UB(n)*.9,r=t.getBoundingClientRect(),i=UM(n),o=r.top+e;if(o>i)return n.getLastBlock();const s=qt(t);if(!s)return n.getLastBlock();let l=s;for(;l;){if(l.getBoundingClientRect().bottom>o)return l;l=qt(l)}return n.getLastBlock()}function N5(n){const t=n.selection.range.focus;p(O5,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId),r=dU(n,e);let i;return r===n.getFirstBlock()?i=lt(r,0,"home"):i=hp(n,r,e,t),i}function P5(n){const t=n.selection.range.focus;p(O5,t.isSimple(),"invalid range type");const e=n.getBlockById(t.blockId),r=hU(n,e);let i;return r===n.getLastBlock()?i=lt(r,dt(n,r),"end"):i=hp(n,r,e,t),i}function F5(n){if(!n.selection.range.focus.isSimple())return!1;const e=N5(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function K5(n){if(!n.selection.range.focus.isSimple())return!1;const e=P5(n);return e?(n.selection.setSelection(e),n.selection.updateLastCaretRect(),!0):!1}function V5(n){if(!n.selection.range.focus.isSimple())return!1;const e=N5(n);if(!e)return!1;const r=wh(n,n.selection.getAnchorPos(),e);if(!r)return!1;const{anchor:i,focus:o}=r;return n.selection.setSelection(i,o),n.selection.updateLastCaretRect(),!0}function $5(n){if(!n.selection.range.focus.isSimple())return!1;const e=P5(n);if(!e)return!1;const r=wh(n,n.selection.getAnchorPos(),e);if(!r)return!1;const{anchor:i,focus:o}=r;return n.selection.setSelection(i,o),n.selection.updateLastCaretRect(),!0}const Tu=I("select-all");function H5(n,t){const e=we(n),r=Ze(n);return t.start.offset===0&&t.start.blockId===st(e)&&t.end.offset===dt(t.getEditor(),r)&&t.end.blockId===st(r)}function mU(n,t){const e=t.getEditor(),r=Qn(e,n).getChildContainers(e,n),i=r[0],o=r[r.length-1],s=st(n);return t.start.blockId===s&&t.start.childContainerId===ft(i)&&t.end.blockId===s&&t.end.childContainerId===ft(o)}function gU(n,t){p(Tu,t,"no parent block"),p(Tu,Dt(n,t),"not a complex block");const e=Qn(n,t).getChildContainers(n,t),r=e[0],i=e[e.length-1];n.selection.setRange(qe(n,{anchor:xe(t,ft(r)),focus:xe(t,ft(i))}))}function j5(n,t){const e=rt(t);Sh(n,e)}function mp(n){const t=n.getFocusedBlock(),e=n.selection.range;if(e.start.isSimple()){if(e.start.blockId===e.end.blockId&&nt(n,t)){const i=e.start,o=e.end,s=dt(n,t);if(i.offset>0||o.offset<s)return n.selection.selectBlock(t,0,s),!1}return z(n.rootContainer,"select-all"),j5(n,we(n.rootContainer)),!1}return p(Tu,!e.isSimple(),"invalid range type"),mU(t,e)?(j5(n,t),!1):(p(Tu,t,"no parent block"),p(Tu,Dt(n,t),"not a complex block"),gU(n,t),!0)}function Sh(n,t){const e=ue(t),r=e[0],i=e[e.length-1],o=lt(r,0,"home"),s=lt(i,dt(n,i),"end");n.selection.setSelection(o,s,{noScroll:!0})}function pU(n){dp(n),n.focus()}const gp=I("selected-block-to-doc");function z5(n,t,e){!t.children||t.children.forEach(r=>{const i=n.getChildContainerData(r);i.forEach(o=>{z5(n,o,e)}),e.blocks[r]=gt.default(i)})}function Lh(n,t){const e=Yt(n,t.block);if(e.selectionToDoc)return e.selectionToDoc(n,t);const r=gt.default(Wo(n,t.block));if(nt(n,t.block)){const o=t.start,s=t.end;if(p(gp,r.text,"no block text"),o.offset===s.offset)return{blocks:{root:[{...r,text:[]}]},meta:{},comments:{}};const{middle:l}=Xe(r.text,o.offset,s.offset-o.offset);return{blocks:{root:[{...r,text:l}]},meta:{},comments:{}}}if(pe(t.block))return{blocks:{root:[r]},meta:{},comments:{}};p(gp,Dt(n,t.block),"not complex block"),p(gp,r.children,"no children");const i={blocks:{root:[r]},meta:{},comments:{}};return z5(n,r,i),i}function pp(n,t){const e=lt(t,0,"normal"),r=lt(t,dt(n,t),"end");return Lh(n,{block:t,start:e,end:r})}const CU=I("block-to-doc");function EU(n,t){p(CU,t.length>0,"invalid params, no blocks");const e=t.map(r=>pp(n,r));return tl(e)}function Sa(n){const e=n.selection.range.getSelectedBlocks().map(r=>Lh(n,r));return tl(e)}function G5(n,t){const e=n.getContainerById(t),o=ue(e).map(s=>({start:lt(s,0,"home"),end:lt(s,dt(n,s),"end"),block:s})).map(s=>Lh(n,s));return tl(o)}const Ih=I("editor-selection");class xU{constructor(t){m(this,"editor");m(this,"caret");m(this,"_range");m(this,"lastCaretRect");m(this,"handleBlockDelete",(t,e,r,i)=>{if(r||i.child)return;const o=this.range;if(PB(e,o)){Ih.debug("adjust selection because remote deleted current block");const s=FB(t,e);this.setRange(s,{noScroll:!0})}});this.editor=t;const e=t.getFirstBlock(),r=st(e);this.caret=new IM(t);const i=lt(r,0,"normal");this._range=qe(t,{anchor:i,focus:i}),this.lastCaretRect=null,this.editor.addListener("blockDeleted",this.handleBlockDelete),setTimeout(()=>{this.updateFocusedBlock(null)})}destroy(){this.caret.destroy()}get range(){return this._range}get focusedBlock(){return this.getFocusedBlock()}get startBlock(){return this.getStartBlock()}get endBlock(){return this.getEndBlock()}getFocusedBlock(){const t=this.range.focus;return this.editor.getBlockById(t.blockId)}getStartBlock(){const t=this.range.start;return this.editor.getBlockById(t.blockId)}getEndBlock(){const t=this.range.end;return this.editor.getBlockById(t.blockId)}selectBlock(t,e,r,i){const o=lt(t,e,"normal");let s;r&&(s=lt(t,r,"normal")),this.setSelection(o,s,i)}setSelection(t,e,r){if(e||(e=t),this.verifyPos(t),this.verifyPos(e),!this.selectionChanging(t,e))return this.range;const i=qe(this.editor,{anchor:t,focus:e});if(this.range.isEqual(i))return this.range;const o=this._range;return this._range=i,this.selectionChanged(),this.updateFocusedBlock(o),Rt(this.editor.rootContainer,"select-all")&&(!i.isSimple()||!KM(this.editor,i))&&ot(this.editor.rootContainer,"select-all"),r!=null&&r.noScroll||this.scrollIntoView(),this.range}setRange(t,e){return this.setSelection(t.anchor,t.focus,e)}updateSelection(){this.caret.update(),DM(this.editor)}getFocusedPos(){return this.range.focus}getAnchorPos(){return this.range.anchor}selectionChanging(t,e){return!0}selectionChanged(){this.updateSelection(),this.editor.emit("selectionChanged",this.editor)}updateLastCaretRect(){const t=this.range.focus;if(!Or(t))return;const e=this.editor.getBlockById(t.blockId);this.lastCaretRect=_r(this.editor,e,t)}getSuggestedCaretX(){var t;return(t=this.lastCaretRect)==null?void 0:t.x}scrollIntoView(){FM(this.editor)}verifyPos(t){const e=this.editor.getBlockById(t.blockId);if(t.isSimple())t.offset>=0&&t.offset<=dt(this.editor,e)||p(Ih,!1,"invalid block position, out of range");else{const r=t.childContainerId;!!this.editor.getContainerById(r)||p(Ih,!1,"invalid complex block position, no container found")}}updateFocusedBlock(t){if(t&&this.range.start.blockId===t.start.blockId)return;let e;t&&t.start.blockId===t.end.blockId&&(e=this.editor.findBlockById(t.start.blockId));let r;(this.range.isCollapsed()||!this.range.isSimple()||this.range.start.blockId===this.range.end.blockId)&&(r=this.editor.getBlockById(this.range.start.blockId));let i=!1;e&&Rt(e,"focused")&&(ot(e,"focused"),i=!0),this.removeAllBlockFocusedClass(),r&&this.setBlockFocused(r)&&(i=!0),i&&this.editor.emit("focusBlockChanged",this.editor,r!=null?r:null,e!=null?e:null)}verify(){this.verifyPos(this._range.start),this.verifyPos(this._range.end)}to(t){const e=Sa(this.editor);return t==="text"?ro(this.editor,e):t==="markdown"?$B(this.editor,e):VB(this.editor,e)}removeAllBlockFocusedClass(){this.editor.rootContainer.querySelectorAll('div[data-type="editor-block"].focused, div[data-type="editor-block"].child-focused').forEach(t=>{ot(t,"focused"),ot(t,"child-focused")})}setBlockFocused(t){if(Rt(t,"focused"))return!1;z(t,"focused");let e=rt(t);for(;Mr(e);){const r=et(e);p(Ih,r,"parent block not found"),z(r,"child-focused"),e=rt(r)}return!0}}function AU(n){const t=n.selection.range.focus;if(!t.isSimple())return;const e=n.findBlockById(t.blockId);!e||n.selection.selectBlock(e,0,dt(n,e))}function bU(n){const t=n.selection.range.focus;if(!t.isSimple())return;const e=n.findBlockById(t.blockId);if(!e||!nt(n,e))return;let r=lp(n,"select"),i=ap(n,"select");if(!r||!i)return;const o=t.blockId;r.blockId!==o&&(r=lt(e,0,"home")),i.blockId!==o&&(i=lt(e,dt(n,e),"end")),n.selection.setSelection(r,i)}class vU{constructor(t){m(this,"editor");m(this,"startPos",null);m(this,"lastCaretRect");m(this,"mouseDownEvent",null);m(this,"autoScroll",null);m(this,"handleMouseDown",(t,e)=>{var i;this.mouseDownEvent=t;const r=l1(this.editor,t.x,t.y);if(r){if(r instanceof di)return;if(!this.autoScroll&&e.autoScroll){const s=r.getSelectedBlocks(),l=En(s[0].block);this.autoScroll=new Vd({scrollElement:l,edge:{top:50,bottom:50}})}const o=this.editor.selection.range;if(t.shiftKey&&o.isSimple()){const s=o.anchor;this.editor.selection.setSelection(s,r.focus),this.startPos=r.start}else this.editor.selection.setSelection(r.anchor,r.focus),this.startPos=r.start;this.editor.selection.updateLastCaretRect(),e.autoScroll&&((i=this.autoScroll)==null||i.active())}});m(this,"handleMouseMove",t=>{if(!this.startPos||!this.mouseDownEvent||Math.abs(this.mouseDownEvent.x-t.x)<3&&Math.abs(this.mouseDownEvent.y-t.y)<3)return;const e=Yd(this.editor,t.x,t.y);if(!e)return;const r=wh(this.editor,this.startPos,e.end);if(!r)return;const{anchor:i,focus:o}=r;this.editor.selection.setSelection(i,o)});m(this,"handleMouseUp",t=>{var e;(e=this.autoScroll)==null||e.inactive(),this.startPos=null});this.editor=t,this.startPos=null,this.lastCaretRect=new DOMRect}isSelecting(){return this.startPos!==null}stopSelection(){this.startPos=null}handleDblClick(t){bU(this.editor)}handleTripleClick(t){AU(this.editor)}}function BU(n){return n.readonly||!n.isWritable()?!1:(n.undoManager.undo(),!0)}function TU(n){return n.readonly||!n.isWritable()?!1:(n.undoManager.redo(),!0)}const W5=I("delete-text");function q5(n,t,e,r){const i=r!=null?r:n.selection.range.start;i instanceof We||p(W5,!1,`invalid insert pos type: ${typeof i}`);const{blockId:o}=i,s=n.getBlockById(o);p(W5,nt(n,s),"block is not a text kind block");let{offset:l}=i;if(t==="backward"){if(l-e<0)return 0;if(!Un(s,l-e)){const c=Go(s,l);e=l-c}}else if(t==="forward"&&l+e>dt(n,s))return 0;return t==="backward"&&(l-=e),n.deleteTextFromBlock(s,l,e)}function X5(n,t){if(n.getBlockData(t).quoted){const e={quoted:null};return n.updateBlockData(t,e),!0}return!1}const yU=I("handle-backspace");function Cp(n,t){if(!ie(n,t))return;const e=rt(t);Lr(e)!==1&&n.deleteBlock(t)}function kU(n,t){if(!n.selection.range.isCollapsed()){n.clearSelectedContents();return}const e=n.selection.range.start,r=n.getBlockById(e.blockId);if(nt(n,r))if(e.offset===0){if(X5(n,r))return;const i=ge(r);if(i){if(!n.isBlockWritable(i))return;if(nt(n,i))n.mergeTextBlock(i,r,{focus:!0});else if(Dt(n,i)){Cp(n,r);const o=pa(n,i);o?n.selection.selectBlock(o,dt(n,o)):n.selection.selectBlock(i,0,dt(n,i))}else Cp(n,r),p(yU,pe(i),"prev block is not embed block"),n.selection.selectBlock(i,1)}else{const o=rt(r);if(Mr(o)){const s=i3(n,o);if(s){if(!n.isBlockWritable(s))return;Cp(n,r),n.selection.selectBlock(s,dt(n,s))}}}}else q5(n,"backward",1,null),n.selection.updateLastCaretRect();else{const i=bt(r),o=rt(r);n.insertTextBlock("",ft(o),i),n.deleteBlock(r)}}function RU(n,t){if(!n.selection.range.isCollapsed()){n.clearSelectedContents();return}const e=n.selection.range.start,r=n.getBlockById(e.blockId);if(nt(n,r))if(e.offset===dt(n,r)){const i=qt(r);if(i){if(!n.isBlockWritable(i))return;nt(n,i)?n.mergeTextBlock(r,i,{focus:!0}):ie(n,r)?n.deleteBlock(r,Te(n,i,0)):n.deleteBlock(i)}}else q5(n,"forward",1,null);else{const i=bt(r),o=rt(r);n.insertTextBlock("",ft(o),i),n.deleteBlock(r)}}function wU(n){const{range:t}=n.selection,{start:e,end:r}=t,i=n.getBlockById(e.blockId),o=n.getBlockById(r.blockId);if(i!==o||!Dt(n,i))return!1;if(Or(e))return!0;const s=ga(n,i,e,r),l=An(n,i);return s.length===l.length}function SU(n,t){if(wU(n)){const s=n.getFocusedBlock(),l=bt(s),c=ft(rt(s));n.insertTextBlock("",c,l+1);return}const e=n.getFocusedBlock(),{start:r,end:i}=n.selection.range,o=r.blockId===i.blockId&&pe(e);if(!n.selection.range.isCollapsed()&&!o&&n.clearSelectedContents(),nt(n,e)){if(ie(n,e)&&X5(n,e))return;const s=n.selection.range.start,l=n.breakTextBlock(e,s.offset,{copyBlockAttributes:!0});s.offset!==0?n.selection.selectBlock(l,0):n.selection.scrollIntoView()}else{const s=n.insertTextBlock();n.selection.selectBlock(s,0)}}function LU(n,t){const e=n.selection.range.getSelectedBlocks()[0],{block:r}=e;if(!nt(n,r))return!1;const i=e.end;return n.insertBoxToBlock(r,i.offset,{type:"br",id:Z(),box:!0,created:Date.now()}),!0}function Ep(n,t,e,r){if(e.type==="embed"){const l=e.embedData.src;if(l&&typeof l=="string")for(const c of l.split("|"))r.add(c);return}const i=e.text;i&&i.forEach(s=>{if(s.attributes&&s.attributes.src&&typeof s.attributes.src=="string")if(jo(s)){const l=n.editorBoxes.getBoxClass(s.attributes.type);if(l.getResources){const c=l.getResources(n,s.attributes);c?c.forEach(d=>{r.add(d)}):r.add(s.attributes.src)}else r.add(s.attributes.src)}else r.add(s.attributes.src)});const o=e.children;o&&o.forEach(s=>{t.blocks[s].forEach(c=>{Ep(n,t,c,r)})})}function IU(n,t){const e=new Set;return t.blocks.root.forEach(i=>{const o=n.editorBlocks.getBlockClass(i.type);if(o.getResources){const s=o.getResources(n,i);s?s.forEach(l=>{e.add(l)}):Ep(n,t,i,e)}else Ep(n,t,i,e)}),Array.from(e)}function La(n,t){return me.isFirefox?`<!doctype html><html><head><meta charset="utf8" /></head><body><canvas data-editor-doc="${ci(JSON.stringify(t))}" id="ones-editor-doc">${n}</body></html>`:`<!doctype html><html><head><meta charset="utf8" />${`<meta charset="utf-8"><ones-editor-doc data-source="ones-editor-doc::${ci(JSON.stringify(t))}::ones-editor-doc" />`}</head><body>${n}</body></html>`}function Ia(n,t){var o,s,l;const e=(l=(s=(o=n.doc).getServerMeta)==null?void 0:s.call(o))!=null?l:{},r=IU(n,t),i={};r.forEach(c=>{const d=n.doc.buildResourceUrl(c,{withToken:!0});i[c]=d}),t.meta={...e,resources:i}}function DU(n,t,e){if(t.preventDefault(),t.stopPropagation(),!t.clipboardData)return;let r=Sa(n);const i=e==null?void 0:e(n,t,r);if(i===!0)return;typeof i=="object"&&i!==null&&(r=i),Ia(n,r);const o=Ba(n,r),s=ro(n,r),l=La(o,r);t.clipboardData.setData("text/html",l),t.clipboardData.setData("text/plain",s),t.clipboardData.setData("text/x-ones-editor-doc",JSON.stringify(r))}function _U(n,t){if(n.selection.range.isCollapsed())return;let e=Sa(n);const r=t==null?void 0:t(n,new ClipboardEvent("mock-event"),e);if(r===!0)return;typeof r=="object"&&r!==null&&(e=r),Ia(n,e);const i=Ba(n,e),o=La(i,e),s=ro(n,e),l=new Blob([o],{type:"text/html"});da([{type:"text/plain",data:new Blob([s],{type:"text/plain"})},{type:"text/html",data:l}])}async function Dh(n,t){if(!window.isSecureContext)throw new Error("Can't copy block in insecure context.");const e=pp(n,t);Ia(n,e);const r=Ba(n,e),i=ro(n,e),o=La(r,e);return da([{type:"text/plain",data:new Blob([i],{type:"text/plain"})},{type:"text/html",data:new Blob([o],{type:"text/html"})}])}const MU=I("input-handler-actions");function Q5(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(SU(n),!0))}function Y5(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(RU(n),!0))}function J5(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(kU(n),!0))}function Z5(n,t){return n.readonly||!n.isWritable()?!1:n.undoManager.runInGroup(()=>(LU(n),!0))}function t2(n){return n.readonly||!n.isWritable()||!window.isSecureContext?!1:(navigator.clipboard.readText().then(t=>{n.input.handlePasteText(t,{toPlainText:!0})}).catch(t=>{MU.error(t)}),!0)}function e2(n){return n.selection.range.getSelectedBlocks().every(e=>{const r=e.block,i=rt(r);if(Xt(i))return!1;const o=et(i);return o&&St(o)==="code"})}function n2(n,t){const e=n.selection.range.getSelectedBlocks(),r=rt(e[0].block),i=et(r);return i?`\`\`\`${n.getBlockData(i).language}
|
|
28
28
|
${t}
|
|
29
29
|
\`\`\`
|
|
30
30
|
`:""}function xp(n){if(!window.isSecureContext||n.selection.range.isCollapsed())return!1;const t=Sa(n);Ia(n,t);const e=Ba(n,t),r=La(e,t);let i="";if(e2(n)){const s=n.selection.range.getSelectedBlocks()[0],l=rt(s.block);et(l)&&(i=n2(n,ro(n,t)))}else{const s=[];t.blocks.root.forEach((l,c)=>{s.push(Ah(n,l,t,[{containerId:"root",blockIndex:c}]))}),s[s.length-1]=s[s.length-1].trimEnd(),i=s.join(`
|
|
31
|
-
`)}const o=new Blob([r],{type:"text/html"});return da([{type:"text/plain",data:new Blob([i],{type:"text/plain"})},{type:"text/html",data:o}]),!0}const UU=Object.freeze(Object.defineProperty({__proto__:null,editorHandleEnter:Q5,editorHandleDelete:Y5,editorHandleBackspace:J5,editorHandleInsertBr:Z5,editorHandlePastePlainText:t2,isSelectedCodeTextBlock:e2,getSelectedCodeBlockMarkdown:n2,editorHandleCopyMarkdown:xp},Symbol.toStringTag,{value:"Module"})),_h={ArrowDown:p5,ArrowUp:g5,ArrowLeft:h5,ArrowRight:m5,"Shift+ArrowDown":C5,"Shift+ArrowUp":A5,"Shift+ArrowLeft":E5,"Shift+ArrowRight":x5,"CtrlOrCmd+ArrowLeft":v5,"CtrlOrCmd+ArrowRight":B5,"CtrlOrCmd+Shift+ArrowLeft":T5,"CtrlOrCmd+Shift+ArrowRight":y5,"CtrlOrCmd+ArrowUp":k5,"CtrlOrCmd+ArrowDown":fp,"CtrlOrCmd+Shift+ArrowUp":R5,"CtrlOrCmd+Shift+ArrowDown":dp,"CtrlOrCmd+A":mp,Home:_5,End:M5,"Shift+Home":I5,"Shift+End":D5,PageUp:F5,PageDown:K5,"Shift+PageUp":V5,"Shift+PageDown":$5,"CtrlOrCmd+Z":BU,"CtrlOrCmd+Shift+Z":TU,Enter:Q5,Delete:Y5,Backspace:J5,"Shift+Enter":Z5,"CtrlOrCmd+Shift+V":t2,"CtrlOrCmd+Shift+C":xp};function r2(n,t){return n.shortcuts.handleKeyboardEvents(n,t)!==void 0}function i2(n,t,e){if(t.type==="embed"){const o=t.embedData,s=o.src;if(s&&typeof s=="string"){const l=e.get(s);if(l)o.src=l;else{let c="";s.split("|").forEach(h=>{const C=e.get(h);C&&(c+=c?`|${C}`:`${C}`)}),c&&(o.src=c)}}return}const r=t.text;r&&r.forEach(o=>{if(o.attributes&&o.attributes.src&&typeof o.attributes.src=="string"){const s=e.get(o.attributes.src);s&&(o.attributes.src=s)}});const i=t.children;i&&i.forEach(o=>{n.blocks[o].forEach(l=>{i2(n,l,e)})})}function o2(n,t,e){if(e.size===0)return;t.blocks.root.forEach(i=>{const o=n.editorBlocks.getBlockClass(i.type);o.replaceResources?o.replaceResources(i,e):i2(t,i,e)})}async function OU(n,t){let e=t.filter(s=>s.indexOf(":")===-1);const r=[];e.forEach(s=>{const l=s.split("|");r.push(...l)}),e=Array.from(new Set(r)),e=r;const i=await n.doc.addResources(e),o=new Map;if(e.length!==i.length)return o;for(let s=0;s<e.length;s++)o.set(e[s],i[s]);return o}function NU(n,t){var l,c,d,h;const r=t.meta.serverId;if(!r||typeof r!="string")return!1;const i=(c=(l=n.doc).getServerMeta)==null?void 0:c.call(l);if(!i)return!1;const o=/.*(?=\/)/;return((d=(i.serverId||"").match(o))==null?void 0:d[0])===((h=r.match(o))==null?void 0:h[0])}async function Ap(n,t){const r=t.meta.resources;if(!r||Object.keys(r).length===0)return;let i=new Map;if(NU(n,t)){const s=Array.from(Object.keys(r));i=await OU(n,s),o2(n,t,i)}const o=new Map;Object.entries(r).forEach(([s,l])=>{i.get(s)===void 0&&s!==l&&o.set(s,l)}),o.size!==0&&o2(n,t,o)}async function PU(n,t,e){await Ap(n,t),n.undoManager.runInGroup(()=>{const{start:r,end:i}=n.selection.range,o=n.getBlockById(r.blockId);if(r.blockId===i.blockId&&pe(o)){const s=rt(o),l=n.getBlockIndex(o),[c]=n.insertDocAt(s,l+1,t,e);c&&n.selection.selectBlock(c,dt(n,c))}else{n.clearSelectedContents();const{block:s,offset:l}=Ta(n);n.insertDoc(s,l,t,e)}})}const FU=["text/x-ones-editor-doc","image/*","text/office-html","text/html","text/plain","text/markdown","*"];function KU(n){let t;for(const e of FU)if(t=n[e],t)break;return t||null}class VU{constructor(t){m(this,"editor");m(this,"handlers",[]);m(this,"hookExecutionAttempt",(t,e,r)=>{for(let i=0;i<this.handlers.length;i++){const o=this.handlers[i];if(o.handleBeforeCopy){const s=o.handleBeforeCopy(this.editor,e,r);if(s===!0)return!0;if(typeof s=="object"&&s!=null)return s}}});m(this,"onPasteText",async(t,e)=>{const r=new DataTransfer;r.setData("text/plain",t);const i=await this.editor.dataConverter.fromData(this.editor,r,e);if(i){const o=[];this.pasteDocs(i,null,o)}});this.editor=t}onInsertText(t,e){if(!nt(this.editor,this.editor.getFocusedBlock()))return;const{containerId:r,blockIndex:i,offset:o}=Ta(this.editor);this.handleBeforeInsertText(r,i,o,e)||(this.defaultInsertText(this.editor,r,i,o,e),this.handleAfterInsertText(r,i,o,e),this.editor.selection.updateLastCaretRect())}onKeyDown(t){if(this.handleBeforeKeyDown(t))return!0;const e=this.defaultHandleKeydown(this.editor,t);return this.handleAfterKeyDown(t)?!0:e}onChanged(t){for(let e=0;e<this.handlers.length;e++){const r=this.handlers[e];r.handleChanged&&r.handleChanged(this.editor,t)}}onRemoteChanged(t){for(let e=0;e<this.handlers.length;e++){const r=this.handlers[e];r.handleRemoteChanged&&r.handleRemoteChanged(this.editor,t)}}onCompositionStart(t){if(!nt(this.editor,this.editor.getFocusedBlock()))return;this.editor.updateCompositionText("",!1);const{containerId:e,blockIndex:r,offset:i}=Ta(this.editor);for(let o=0;o<this.handlers.length;o++){const s=this.handlers[o];s.handleCompositionStart&&s.handleCompositionStart(this.editor,e,r,i)}}onUpdateCompositionText(t,e,r){if(!nt(this.editor,this.editor.getFocusedBlock()))return;this.editor.updateCompositionText(e,r),this.editor.selection.caret.update();const{containerId:i,blockIndex:o,offset:s}=Ta(this.editor);for(let l=0;l<this.handlers.length;l++){const c=this.handlers[l];c.handleUpdateCompositionText&&c.handleUpdateCompositionText(this.editor,i,o,s,r)}this.editor.selection.updateLastCaretRect()}onCopy(t){DU(this.editor,t,this.hookExecutionAttempt)}onCopyWithoutEvent(){_U(this.editor,this.hookExecutionAttempt)}onCut(t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforeCut&&i.handleBeforeCut(this.editor,t)===!0)return}if(this.onCopy(t),this.editor.selection.range.isCollapsed()){const r=this.editor.selection.focusedBlock;pe(r)&&this.editor.deleteBlock(r)}else yh(this.editor)}onPaste(t){if(t.preventDefault(),t.stopPropagation(),!t.clipboardData)return;const e=this.editor.dataConverter.fromData(this.editor,t.clipboardData),r=Array.from(t.clipboardData.files);e.then(async i=>{i&&this.pasteDocs(i,t,r)})}onFocus(){z(this.editor.rootElement,"active")}onBlur(){ot(this.editor.rootElement,"active")}addHandler(t){this.handlers.push(t),this.handlers=this.handlers.sort((e,r)=>{var s,l;const i=(s=e.order)!=null?s:1;return((l=r.order)!=null?l:1)-i})}removeHandler(t){const e=this.handlers.indexOf(t);e!==-1&&this.handlers.splice(e)}handleBeforeInsertText(t,e,r,i){for(let o=0;o<this.handlers.length;o++){const s=this.handlers[o];if(s.handleBeforeInsertText&&s.handleBeforeInsertText(this.editor,t,e,r,i))return!0}return!1}handleAfterInsertText(t,e,r,i){for(let o=0;o<this.handlers.length;o++){const s=this.handlers[o];if(s.handleAfterInsertText&&s.handleAfterInsertText(this.editor,t,e,r,i))return!0}return!1}handleBeforeKeyDown(t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforeKeyDown&&i.handleBeforeKeyDown(this.editor,t))return!0}const e=this.defaultHandleKeydown(this.editor,t);for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleAfterKeyDown&&i.handleAfterKeyDown(this.editor,t))return!0}return e}handleAfterKeyDown(t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforeKeyDown&&i.handleBeforeKeyDown(this.editor,t))return!0}const e=this.defaultHandleKeydown(this.editor,t);for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleAfterKeyDown&&i.handleAfterKeyDown(this.editor,t))return!0}return e}defaultInsertText(t,e,r,i,o){X1(this.editor,o)}defaultHandleKeydown(t,e){return r2(this.editor,e)?(e.preventDefault(),e.stopPropagation(),!0):!1}async pasteDoc(t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforePasteDoc&&await i.handleBeforePasteDoc(this.editor,t))return}const e={blockIdMap:new Map,containerIdMap:new Map,boxIdMap:new Map};await PU(this.editor,t,e);for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleAfterPasteDoc&&await i.handleAfterPasteDoc(this.editor,t,e))return}}async pasteDocs(t,e,r){for(let o=0;o<this.handlers.length;o++){const s=this.handlers[o];if(s.handleBeforePaste&&await s.handleBeforePaste(this.editor,e,t,r))return}const i=KU(t);if(!!i){await this.pasteDoc(i);for(let o=0;o<this.handlers.length;o++){const s=this.handlers[o];if(s.handleAfterPaste&&await s.handleAfterPaste(this.editor,e,t))return}}}destroy(){this.handlers.forEach(t=>{var e;(e=t.destroy)==null||e.call(t,this.editor)}),this.handlers=[]}forEach(t){this.handlers.forEach(t)}}function $U(n,t,e){const r=zi(t,e);return r.remove(),r}I("copy-dom-attributes");const s2=["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 HU(n,t){for(let l=0;l<s2.length;l++){const c=s2[l];t[c]=n[c]}const e=n.attributes,r=t.attributes,i=[],o=[];for(let l=0;l<e.length;l++){const c=e[l],d=r.getNamedItem(c.name);d?d.value!==c.value&&(d.value=c.value,o.push(c)):i.push(c)}const s=[];for(let l=0;l<r.length;l++){const c=r[l];e.getNamedItem(c.name)||s.push(c)}i.forEach(l=>{t.setAttribute(l.name,l.value)}),o.forEach(l=>{t.setAttribute(l.name,l.value)}),s.forEach(l=>{t.removeAttribute(l.name)})}function l2(n){const t=Array.from(n.childNodes).filter(e=>!Bv(e));return t.forEach(e=>{e.remove()}),t}function a2(n,t,e){var d;const r=n.getContainerById(t),i=zi(r,e),o=Vo(i),s=n.doc.getBlockData(t,e),l=Yt(n,i);if((d=l==null?void 0:l.handleUpdateBlock)==null?void 0:d.call(l,n,i,s))n.editorBlockRenders.updateBlock(n,o,i,s);else{const h=n.editorBlocks.createBlock(o,r,s),C=l2(h);l2(i),C.forEach(A=>{i.appendChild(A)});const E=zd(h);if(E){const A=zd(i);A&&A.remove(),i.appendChild(E)}HU(h,i)}Fv(n,i,s),n.blockHooks.forEach(h=>{var C;(C=h.update)==null||C.call(h,n,o,r,i,s)}),setTimeout(()=>{n.selection.updateSelection(null)})}const jU=I("transform-selection");function c2(n,t,e,r){const{range:i}=n.selection,{anchor:o,focus:s}=i;if(o.blockId!==t&&s.blockId!==t)return i;p(jU,o.isSimple()&&s.isSimple(),"invalid text pos type");let l=o;if(o.blockId===t){const d=fn.transformCursor(o.offset,e,r);l=lt(t,d,"normal")}let c=s;if(s.blockId===t){const d=fn.transformCursor(s.offset,e,r);c=lt(t,d,"normal")}return qe(n,{anchor:l,focus:c})}const zU=I("handle-block-text-changed");function GU(n,t,e,r,i){const o=n.getContainerById(t),s=zi(o,e),l=n.doc.getBlockData(t,e);if(p(zU,l.text,"no block text"),xv(n,s).setBlockText(n,s,l.text),!i){const c=c2(n,l.id,r,i);n.selection.setRange(c,{noScroll:!0})}}function WU(n,t){const e=gt.default(n);return t.delete.forEach(i=>{delete e[i]}),{...e,...t.insert}}function u2(n,t,e,r){const i=Yt(n,t);i.handleDeleteBlock&&i.handleDeleteBlock(n,t,e,r),n.emit("blockDeleted",n,t,e,r)}function qU(n,t,e,r){const i=n.getBlockByIndex(t,e);i.querySelectorAll('[data-type="editor-block"]').forEach(o=>{u2(n,o,r,{child:!0})}),u2(n,i,r,{child:!1})}const Pr=I("editor-doc");class XU extends sa{constructor(e,r,i){super();m(this,"localEvents",[]);this.editor=e,this.externalDoc=r,this.externalDoc.registerCallback(this),this.registerLocalEvents(i)}beginBatchUpdate(){return this.externalDoc.beginBatchUpdate()}endBatchUpdate(){return this.externalDoc.endBatchUpdate()}registerLocalEvents(e){this.localEvents.push(e)}toJSON(){return this.externalDoc.toJSON()}getVersionHelper(){var r,i;return(i=(r=this.externalDoc).getVersionHelper)==null?void 0:i.call(r)}getContainerBlocks(e){return this.externalDoc.getContainerBlocks(e)}findContainerBlocks(e){return this.externalDoc.findContainerBlocks(e)}getBlockData(e,r){return this.externalDoc.getBlockData(e,r)}verifyBlockWritable(e,r){const i=this.editor.getBlockByIndex(e,r);p(Pr,this.editor.isBlockWritable(i),`block is not writable, ${e}, ${r}`)}localUpdateBlockText(e,r,i,o){p(Pr,!this.editor.readonly,"editor is readonly"),this.verifyBlockWritable(e,r);const s=this.getBlockData(e,r),l=s.text;p(Pr,l,`no text, ${e}, ${r}`);const c=c2(this.editor,s.id,i,!0),d=fn.apply(l,i);this.localEvents.forEach(C=>C.onBeforeUpdateBlockText(e,s.id,l,d,c.toDocRange()));const h=this.externalDoc.localUpdateBlockText(e,r,i);return this.editor.selection.setRange(c,o),h}localUpdateBlockData(e,r,i,o){p(Pr,!this.editor.readonly,"editor is readonly");const s=this.editor.getBlockByIndex(e,r);if(!this.editor.isBlockWritable(s)){const h=Array.from(i.delete).filter(E=>E!=="comments"),C=Object.keys(i.insert).filter(E=>E!=="comments");(h.length>0||C.length>0)&&p(Pr,!1,`block is not writable, comment supported only, ${JSON.stringify(i)}}`)}const l=gt.default(this.getBlockData(e,r)),c=gt.default(WU(l,i));this.localEvents.forEach(h=>h.onBeforeUpdateBlockData(e,l.id,l,c,o));const d=this.externalDoc.localUpdateBlockData(e,r,i,o);return this.editor.selection.setRange($o(this.editor,o)),d}localInsertBlock(e,r,i,o,s){p(Pr,!this.editor.readonly,"editor is readonly"),this.localEvents.forEach(c=>c.onBeforeInsertBlock(e,r,i,o));const l=this.externalDoc.localInsertBlock(e,r,i,o);return s!=null&&s.noFocus||this.editor.selection.setRange($o(this.editor,o),s),l}localDeleteBlock(e,r,i){p(Pr,!this.editor.readonly,"editor is readonly"),this.verifyBlockWritable(e,r);const o=gt.default(this.getBlockData(e,r));this.localEvents.forEach(l=>l.onBeforeDeleteBlock(e,r,o,i));const s=this.externalDoc.localDeleteBlock(e,r,i);return this.editor.selection.setRange($o(this.editor,i)),s}localDeleteChildContainers(e){return p(Pr,!this.editor.readonly,"editor is readonly"),e.forEach(r=>{const i=gt.default(this.getContainerBlocks(r));this.localEvents.forEach(o=>o.onBeforeDeleteChildContainer(r,i))}),this.externalDoc.localDeleteChildContainers(e)}localInsertChildContainers(e){p(Pr,!this.editor.readonly,"editor is readonly");const r=gt.default(e);r.forEach(i=>{this.localEvents.forEach(o=>o.onBeforeInsertChildContainer(i.containerId,i.blocks))}),this.externalDoc.localInsertChildContainers(r)}onRequestReload(e){Pr.debug(`reload doc: ${e}`),this.editor.reload(),this.callbacks.forEach(i=>{var o;return(o=i.onRequestReload)==null?void 0:o.call(i,e)});const r=!1;this.editor.emit("docChanged",this.editor,r)}onUpdateBlockText(e,r,i,o){this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockText)==null?void 0:l.call(s,e,r,i,o)}),GU(this.editor,e,r,i,o),this.editor.emit("docChanged",this.editor,o)}onUpdateBlockData(e,r,i,o){this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,e,r,i,o)}),a2(this.editor,e,r),this.editor.emit("docChanged",this.editor,o)}onInsertBlock(e,r,i,o){this.callbacks.forEach(l=>{var c;return(c=l.onInsertBlock)==null?void 0:c.call(l,e,r,i,o)});const s=this.editor.getContainerById(e);RI(this.editor,s,r,i),this.editor.emit("docChanged",this.editor,o)}onDeleteBlock(e,r,i){qU(this.editor,e,r,i),this.callbacks.forEach(s=>{var l;return(l=s.onDeleteBlock)==null?void 0:l.call(s,e,r,i)});const o=this.editor.getContainerById(e);$U(this.editor,o,r),this.editor.emit("docChanged",this.editor,i)}onInsertChildContainer(e,r,i){this.callbacks.forEach(o=>{var s;return(s=o.onInsertChildContainer)==null?void 0:s.call(o,e,r,i)})}onDeleteChildContainer(e,r){this.callbacks.forEach(i=>{var o;return(o=i.onDeleteChildContainer)==null?void 0:o.call(i,e,r)})}onCustomMessage(e){this.callbacks.forEach(r=>{var i;return(i=r.onCustomMessage)==null?void 0:i.call(r,e)})}onStatusChanged(e){this.callbacks.forEach(r=>{var i;return(i=r.onStatusChanged)==null?void 0:i.call(r,e)})}onError(e){this.callbacks.forEach(r=>{var i;return(i=r.onError)==null?void 0:i.call(r,e)})}uploadResource(e,r){return this.externalDoc.uploadResource(e,r)}addResources(e){return this.externalDoc.addResources(e)}buildResourceUrl(e,r){return this.externalDoc.buildResourceUrl(e,r)}request(e,r){return this.externalDoc.request(e,r)}broadcastMessage(e){return this.externalDoc.broadcastMessage(e)}getUser(){return this.externalDoc.getUser()}getRemoteUsers(){return this.externalDoc.getRemoteUsers()}destroy(){this.externalDoc.destroy(),this.clearCallbacks()}getServerMeta(){var e,r,i;return(i=(r=(e=this.externalDoc).getServerMeta)==null?void 0:r.call(e))!=null?i:{}}reset(e){Pr.log("reset doc"),this.externalDoc=e,this.externalDoc.registerCallback(this),this.editor.reload()}}function f2(n,t){if(n.length===0){n.push(t);return}const e=n[n.length-1];if(!e.combinable(t)){n.push(t);return}e.combine(t)}const Mh=I("undo-action");class Da{constructor(t,e,r){m(this,"beforeRange");m(this,"afterRange");this.containerId=e,this.beforeRange=t.selection.range.clone().toDocRange(),this.afterRange=r}undo(t){return!1}redo(t){return!1}combinable(t){return p(Mh,t,"no other action"),!1}combine(t){p(Mh,!1,"no other")}setAfterRange(t){this.afterRange&&Mh.warn("after range has already set"),this.afterRange=t}findContainerById(t,e){return!!t.doc.findContainerBlocks(e)}findBlockById(t,e){const r=t.doc.findContainerBlocks(this.containerId);return r?r.some(i=>i.id===e):!1}checkBlockData(t,e){if(Array.isArray(e.children)){const r=t.doc.toJSON();for(let i=0;i<e.children.length;i++){const o=e.children[i];if(!r.blocks[o])return Mh.warn(`container (${o}) not found, deleted by others?`),!1}}return!0}}const _a=I("block-action");class d2 extends Da{constructor(e,r,i,o,s){super(e,r,s);m(this,"blockData");m(this,"blockIndex");this.blockData=gt.default(o),this.blockIndex=i}deleteBlock(e,r){if(!this.findContainerById(e,this.containerId))return _a.warn(`container (${this.containerId}) not found, deleted by others?`),!1;if(!this.findBlockById(e,this.blockData.id))return _a.warn(`block (${this.blockData.id}) not found, deleted by others?`),!1;if(!e.getContainerById(this.containerId))return!1;const o=e.getBlockById(this.blockData.id);if(!o)return!1;try{p(_a,this.blockIndex===bt(o),"invalid block index"),Bh(e,o,$o(e,r))}catch(s){_a.warn(s.message),e.selection.selectBlock(o,0)}return!0}insertBlock(e,r){if(!this.findContainerById(e,this.containerId))return _a.warn(`container (${this.containerId}) not found, deleted by others?`),!1;if(!this.checkBlockData(e,this.blockData))return!1;try{ka(e,this.containerId,this.blockIndex,gt.default(this.blockData),r)}catch(i){_a.warn(i.message);const o=e.doc.getContainerBlocks(this.containerId),s=Math.min(o.length-1,this.blockIndex),l=e.getBlockByIndex(this.containerId,s);e.selection.selectBlock(l,0)}return!0}}I("insert-block-action");class QU extends d2{undo(t){return this.deleteBlock(t,this.beforeRange)}redo(t){return this.insertBlock(t,this.afterRange)}}class YU extends d2{undo(t){return this.insertBlock(t,this.beforeRange)}redo(t){return this.deleteBlock(t,this.afterRange)}}class JU extends Da{constructor(e){super(e,ft(e.rootContainer),e.selection.range.toDocRange());m(this,"actions",[])}addAction(e){f2(this.actions,e),this.afterRange=e.afterRange}undo(e){let r=!1;return this.actions.concat().reverse().forEach(i=>{i.undo(e)&&(r=!0)}),r}redo(e){let r=!1;return this.actions.forEach(i=>{i.redo(e)&&(r=!0)}),r}setAfterRange(e){this.afterRange=e;const r=this.actions[this.actions.length-1];!r||r instanceof Da&&(r.afterRange||r.setAfterRange(e))}}const Qo=I("update-block-data-action");class Uh extends Da{constructor(e,r,i,o,s,l){super(e,r,l);m(this,"beforeBlockData");m(this,"afterBlockData");m(this,"blockId");this.blockId=i,p(Qo,this.blockId===o.id,"invalid block id"),p(Qo,this.blockId===s.id,"invalid block id"),this.beforeBlockData=gt.default(o),this.afterBlockData=gt.default(s),p(Qo,this.beforeBlockData.type===this.afterBlockData.type,"invalid block type")}undo(e){if(!e.findBlockById(this.blockId))return Qo.warn(`block (${this.blockId}) not found, deleted by others?`),!1;const r=e.getBlockById(this.blockId);if(!r||!this.checkBlockData(e,this.beforeBlockData))return!1;const i=e.getContainerById(this.containerId);return p(Qo,i,"no container"),Rh(e,r,Uh.toAttributes(this.beforeBlockData),this.beforeRange),!0}redo(e){if(!e.findBlockById(this.blockId))return Qo.warn(`block (${this.blockId}) not found, deleted by others?`),!1;p(Qo,e,"no editor");const r=e.getBlockById(this.blockId);if(!r||!this.checkBlockData(e,this.beforeBlockData))return!1;const i=e.getContainerById(this.containerId);return p(Qo,i,"no container"),Rh(e,r,Uh.toAttributes(this.afterBlockData),this.afterRange),!0}static toAttributes(e){const r=gt.default(e);return delete r.id,delete r.type,r}}const el=I("update-block-text-action");class yu extends Da{constructor(e,r,i,o,s,l){super(e,r,l);m(this,"beforeRichTextData");m(this,"afterRichTextData");m(this,"blockId");m(this,"type");this.blockId=i,this.beforeRichTextData=gt.default(o),this.afterRichTextData=gt.default(s),this.type=yu.calType(o,s)}static calType(e,r){p(el,e,"no old data"),p(el,r,"no new data");const o=fn.diff(e,r),s=new Set;let l=!1;const c=h=>Wb(h)?`cjk_${h}`:zb(h)?"number":Od(h)?"space":Gb(h)?"letter":"unknown";let d=!1;return o.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_${c(h.insert.substr(1))}`)):s.add(`insert_${c(h.insert)}`):h.delete&&(l?l=!1:s.add("delete"))}),{textType:Array.from(s).join("|"),begin:d}}undo(e){if(!this.findContainerById(e,this.containerId))return el.warn(`container (${this.containerId}) not found, deleted by others?`),!1;if(!this.findBlockById(e,this.blockId))return el.warn(`block (${this.blockId}) not found, deleted by others?`),!1;if(!e.getContainerById(this.containerId))return!1;const i=e.getBlockById(this.blockId);return i?(kh(e,i,this.beforeRichTextData),!0):!1}redo(e){if(!this.findContainerById(e,this.containerId))return el.warn(`container (${this.containerId}) not found, deleted by others?`),!1;if(!this.findBlockById(e,this.blockId))return el.warn(`block (${this.blockId}) not found, deleted by others?`),!1;if(!e.getContainerById(this.containerId))return!1;const i=e.getBlockById(this.blockId);return i?(kh(e,i,this.afterRichTextData),!0):!1}combinable(e){if(!(e instanceof yu)||e.type.begin||this.type.textType!==e.type.textType||e.blockId!==this.blockId)return!1;const r=e.beforeRange,i=r.anchor;if(!i.isSimple())return!1;const o=this.afterRange;if(!o)return!1;const s=o.anchor;return!(!s.isSimple()||s.blockId!==r.anchor.blockId||s.offset!==i.offset)}combine(e){p(el,e instanceof yu,"invalid action type");const r=e;this.afterRichTextData=r.afterRichTextData,this.afterRange=e.afterRange}}const h2=I("child-container-action");class m2 extends Da{constructor(t,e,r){super(t,e,t.selection.range.toDocRange()),this.blocks=r}deleteChildContainer(t){return this.findContainerById(t,this.containerId)?(t.doc.localDeleteChildContainers([this.containerId]),!0):(h2.warn(`container (${this.containerId}) not found, deleted by others?`),!1)}insertChildContainer(t){return this.findContainerById(t,this.containerId)?(h2.warn(`container (${this.containerId}) already exists`),!1):(t.doc.localInsertChildContainers([{containerId:this.containerId,blocks:gt.default(this.blocks)}]),!0)}}class ZU extends m2{undo(t){return this.deleteChildContainer(t)}redo(t){return this.insertChildContainer(t)}}class tO extends m2{undo(t){return this.insertChildContainer(t)}redo(t){return this.deleteChildContainer(t)}}const Fr=I("undo");class eO{constructor(t){m(this,"editor");m(this,"actions",[]);m(this,"undoCursor");m(this,"currentGroup",null);m(this,"groupCounter",0);m(this,"undoRedoing",!1);m(this,"handleSelectionChange",t=>{if(this.currentGroup){this.currentGroup.setAfterRange(t.selection.range.toDocRange());return}const e=this.actions[this.actions.length-1];!e||e.afterRange||e.setAfterRange(t.selection.range.toDocRange())});this.editor=t,this.undoCursor=-1,this.editor.addListener("selectionChanged",this.handleSelectionChange)}reset(){this.actions=[],this.undoCursor=-1}prepareSaveUndoState(){this.undoCursor!==-1&&(this.actions.splice(this.undoCursor),this.undoCursor=-1)}addAction(t){this.currentGroup?this.currentGroup.addAction(t):(f2(this.actions,t),setTimeout(()=>{this.editor.input.handleChanged(t)}))}beginGroup(){this.groupCounter===0?(p(Fr,!this.currentGroup,"current group already exists"),this.currentGroup=new JU(this.editor),this.groupCounter=1):(p(Fr,this.currentGroup,"current group not exists"),this.groupCounter+=1)}endGroup(){p(Fr,this.currentGroup,"current group not exists"),p(Fr,this.groupCounter>0,"group counter === 0"),this.groupCounter-=1,this.groupCounter===0&&(this.currentGroup.actions.length===0?Fr.warn("empty undo group, skip it"):(this.actions.push(this.currentGroup),this.editor.input.handleChanged(this.currentGroup)),this.currentGroup=null)}hasGroup(){return this.groupCounter>0}runInGroup(t){this.beginGroup();try{const e=t();return setTimeout(()=>this.editor.selection.caret.update()),e}catch(e){throw Fr.error(`failed to run action: ${e.message}`),e}finally{this.endGroup()}}undo(){this.undoCursor===-1&&(this.undoCursor=this.actions.length);try{for(this.undoRedoing=!0;this.undoCursor>0;){this.undoCursor-=1;const t=this.actions[this.undoCursor];if(t.undo(this.editor)){try{this.editor.selection.setRange($o(this.editor,t.beforeRange))}catch(e){Fr.error(`undo: failed to restore caret pos: ${e.message}`)}return this.editor.input.handleChanged(t),!0}}return!1}finally{this.undoRedoing=!1}}redo(){this.undoCursor===-1&&(this.undoCursor=this.actions.length);try{for(this.undoRedoing=!0;this.undoCursor<this.actions.length;){const t=this.actions[this.undoCursor];if(this.undoCursor+=1,t.redo(this.editor)){try{const e=t.afterRange;e?this.editor.selection.setRange($o(this.editor,e)):Fr.warn("no after range")}catch(e){Fr.error(`redo: failed to set caret pos after redo: ${e.message}`)}return this.editor.input.handleChanged(t),!0}}return!1}finally{this.undoRedoing=!1}}canUndo(){return!(this.actions.length===0||this.undoCursor===0)}canRedo(){return!(this.actions.length===0||this.undoCursor===-1||this.undoCursor===this.actions.length)}lastAction(){var e;const t=this.undoCursor===-1?this.actions.length-1:this.undoCursor-1;return(e=this.actions[t])!=null?e:null}undoTo(t){for(;;){const e=this.lastAction();if(!e||e===t)return!0;if(!this.undo())return!1}}onBeforeUpdateBlockText(t,e,r,i,o){this.undoRedoing||(this.prepareSaveUndoState(),fn.diff(r,i).length!==0&&this.addAction(new yu(this.editor,t,e,r,i,o)))}onBeforeUpdateBlockData(t,e,r,i,o){if(this.undoRedoing)return;this.prepareSaveUndoState();const s=new Uh(this.editor,t,e,r,i,o);this.addAction(s)}onBeforeInsertBlock(t,e,r,i){this.undoRedoing||(this.prepareSaveUndoState(),p(Fr,e>=0,"invalid block index"),p(Fr,r,"no block data"),this.addAction(new QU(this.editor,t,e,r,i)))}onBeforeDeleteBlock(t,e,r,i){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new YU(this.editor,t,e,r,i)))}onBeforeInsertChildContainer(t,e){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new ZU(this.editor,t,e)))}onBeforeDeleteChildContainer(t,e){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new tO(this.editor,t,e)))}}class nO{async fromData(t,e){const r=e.getData("text/x-ones-editor-doc");if(r)return{"text/x-ones-editor-doc":JSON.parse(r)}}}class rO{constructor(){m(this,"converters",[]);m(this,"converterTypes",["text/plain","text/markdown","text/html","text/x-ones-editor-doc"]);this.addConverter(new nO)}prepareData(t){const e=new DataTransfer;for(let r=0;r<this.converterTypes.length;r++)e.setData(this.converterTypes[r],t.getData(this.converterTypes[r]));return e}async fromData(t,e,r){let i={};const o=this.prepareData(e);for(const s of this.converters){const l=await s.fromData(t,o,r);l&&(i={...i,...l})}return i}addConverter(t){this.converters.push(t)}}function iO(n){n.editorBlocks.registerBlockClass(On),n.editorBlocks.registerBlockClass(r3),n.editorBoxes.registerBoxClass(TB),n.editorBoxes.registerBoxClass(yB),n.editorBoxes.registerBoxClass(wB),n.editorBoxes.registerBoxClass(SB),n.editorInsertions.registerInsertionClass(LB),n.editorBlockRenders.registerRender(new vv)}function oO(n,t){iO(n),t!=null&&t.blocks&&t.blocks.forEach(e=>n.editorBlocks.registerBlockClass(e)),t!=null&&t.boxes&&t.boxes.forEach(e=>n.editorBoxes.registerBoxClass(e)),t!=null&&t.embeds&&t.embeds.forEach(e=>n.editorEmbeds.registerEmbedClass(e)),t!=null&&t.insertions&&t.insertions.forEach(e=>n.editorInsertions.registerInsertionClass(e)),t!=null&&t.decorators&&t.decorators.forEach(e=>n.editorDecorators.registerDecorator(e)),t!=null&&t.dataConverters&&t.dataConverters.forEach(e=>n.dataConverter.addConverter(e)),t!=null&&t.commandProviders&&t.commandProviders.forEach(e=>n.editorCommandProviders.registerCommandProvider(e)),t!=null&&t.textRenders&&t.textRenders.forEach(e=>n.editorBlockRenders.registerRender(e))}const Oh=I("range-commands");function g2(n,t){n.forEach(e=>{e.source=t,e.children&&g2(e.children,t)})}function p2(n,t,e){const r=st(t);p(Oh,r===e.start.blockId,"invalid start range"),p(Oh,r===e.end.blockId,"invalid end range");const i=n.editorCommandProviders.getCommandProviders();let o=[];if(i.forEach(s=>{const l=s.getAvailableCommands(n,t,e);g2(l,s.id),o.push(...l)}),i.forEach(s=>{if(s.filterCommands){const l=s.filterCommands(n,t,e,o);l&&(o=l)}}),_t(n,t)){if(!ma(e.start))return o;p(Oh,!e.start.isSimple(),"invalid start pos"),p(Oh,!e.end.isSimple(),"invalid end pos");const s=e.start.childContainerId,l=ui(n,s),d=ue(l)[0];if(d){const h=dt(n,d),C=qe(n,{anchor:lt(d,0,"home"),focus:lt(d,h,"end")}),E=p2(n,d,C);o.push(...E)}}return o}function C2(n){const t=n.getEditor(),e=n.getSelectedBlocks(),r=[],i=n.isReverse()?e[0]:e[e.length-1],o=qe(t,{anchor:i.start,focus:i.end});return p2(t,i.block,o).forEach(l=>{r.push(l)}),r}function E2(n,t,e,r,i,o){var h;const s=n.editorCommandProviders.getCommandProviders();for(let C=0;C<s.length;C++){const E=s[C];if(E.beforeExecuteCommand&&E.beforeExecuteCommand(n,t,e,r,i))return!1}const l=n.editorCommandProviders.getCommandProvider(r.source),c={};if((h=l.executeCommand)!=null&&h.call(l,n,t,e,r,i,{}))return o[st(t)]=c,!0;let d=!1;return _t(n,t)&&ga(n,t,e.start,e.end).forEach(E=>{ue(E).forEach(v=>{const R=dt(n,v),L=qe(n,{anchor:lt(v,0,"home"),focus:lt(v,R,"end")});E2(n,v,L,r,i,o)&&(d=!0)})}),s.forEach(C=>{C.afterExecuteCommand&&C.afterExecuteCommand(n,t,e,r,i,o)}),d}function x2(n,t,e){const r=n.getEditor(),i={},o=r.editorCommandProviders.getCommandProvider(t.source);return o.executeRangeCommand&&o.executeRangeCommand(r,n,t,e,i)||(n.getSelectedBlocks().forEach(l=>{const c=qe(r,{anchor:l.start,focus:l.end});E2(r,l.block,c,t,e,i)}),r.focus()),i}const sO=I("command-providers");class A2{constructor(t){m(this,"providers",[]);this.editor=t}registerCommandProvider(t){this.providers.push(t)}getCommandProviders(){return this.providers}getCommandProvider(t){const e=this.providers.find(r=>r.id===t);return p(sO,e,`no command provider, id=${t}`),e}getCommands(t){return C2(t)}executeCommand(t,e,r){return this.editor.undoManager.runInGroup(()=>x2(t,e,r))}getEmptyBlockTextAttributes(t,e){let r={};if(this.providers.forEach(i=>{var s;const o=(s=i.getEmptyBlockTextAttributes)==null?void 0:s.call(i,t,e);o&&(r={...r,...o})}),Object.keys(r).length!==0)return r}}function lO(n,t){const e=rt(t),r=ft(e),i=bt(t);a2(n,r,i)}const aO=I("table-scroll");class b2{constructor(t,e,r,i,o){m(this,"handleEvent",t=>{this.handler(this.editor,t,this.data)});this.editor=t,this.dom=e,this.name=r,this.handler=i,this.data=o,e.addEventListener(r,this.handleEvent)}destroy(){this.dom.removeEventListener(this.name,this.handleEvent)}}class cO{constructor(t){m(this,"handlers",new Map);this.editor=t}destroy(){Array.from(this.handlers.entries()).forEach(([t,e])=>{e.forEach(r=>r.destroy()),this.handlers.delete(t)})}addEventListener(t,e,r,i){const o=this.handlers.get(t);if(o){if(o.find(s=>s.handler===r&&s.name===e)){aO.warn(`event has already registered: ${e}`);return}o.push(new b2(this.editor,t,e,r,i))}else{const s=new b2(this.editor,t,e,r,i);this.handlers.set(t,[s])}}removeEventListener(t,e,r){if(!t){for(const[o,s]of Array.from(this.handlers.entries()))for(let l=s.length-1;l>=0;l--){const c=s[l];if(e)e===c.name&&r===c.handler&&s.splice(l,1);else if(r===c.handler){s.splice(l,1),c.destroy(),s.length===0&&this.handlers.delete(o);continue}}return}const i=this.handlers.get(t);if(i){const o=i.findIndex(s=>s.handler===r&&s.name===e);if(o!==-1){const s=i[o];i.splice(o,1),s.destroy(),i.length===0&&this.handlers.delete(t)}}}removeAllListeners(t,e){const r=this.handlers.get(t);if(r)if(e)for(let i=0;i<r.length;i++){const o=r[i];o.name===e&&(r.splice(i,1),o.destroy())}else r.forEach(i=>{i.destroy()}),this.handlers.delete(t)}}const v2=I("update-block-text");function uO(n,t,e){const r=n.getBoxById(t.id),i=et(r);p(v2,i,"no parent block"),p(v2,nt(n,i),"not a text block");const o=n.getBlockText(i),s=gB(o,"id",t.id,t);JB(n,i,s,e)}function fO(n,t){for(const e of n.blockHooks)if(e.writable){const r=e.writable(n,t);if(typeof r=="boolean")return r}return!0}function dO(n){if(n.readonly)return!1;const t=hi(n);return!!n.isBlockWritable(t.map(e=>e.block))}class hO{constructor(t){this.editor=t}getKey(t){return`${this.editor.id}-${t}`}getItem(t){return window.localStorage.getItem(this.getKey(t))}setItem(t,e){if(!e){this.removeItem(t);return}window.localStorage.setItem(this.getKey(t),e)}removeItem(t){window.localStorage.removeItem(this.getKey(t))}}class mO{constructor(){m(this,"shortcuts",[])}handleKeyboardEvents(t,e){const r=this.shortcuts;for(const i of r){const o=Object.entries(i);for(const[s,l]of o)if(ai(e,s)){const c=l(t,e);if(c!==void 0)return c}}}}const io=I("editor");class gO extends Re.TypedEmitter{constructor(e,r,i){var o,s,l,c,d,h,C,E;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 mO);m(this,"dataConverter",new rO);m(this,"editorBlocks",new Zv(this));m(this,"editorBoxes",new RB(this));m(this,"editorInsertions",new DB(this));m(this,"editorEmbeds",new e3(this));m(this,"editorDecorators",new _B(this));m(this,"editorCommandProviders",new A2(this));m(this,"editorBlockRenders",new CI(this));m(this,"blockHooks",[]);m(this,"domEvents",new cO(this));m(this,"customs",new Map);m(this,"options");m(this,"inputHandlers",new VU(this));m(this,"settingsProvider");m(this,"_readonly",!1);m(this,"getColor",e=>{const r=this.options.colors;return r.length===0?"#FF1A75":r[e%r.length]});io.debug("create editor"),this.setMaxListeners(100),this.options={colors:(o=i==null?void 0:i.colors)!=null?o:["#0064FF","#EB3723","#F59300","#00A865","#F25A0A","#70A310","#009CAD","#0990D9","#8851ED","#D62069"],componentsOptions:(l=(s=i==null?void 0:i.components)==null?void 0:s.options)!=null?l:{},scrollContainer:i==null?void 0:i.scrollContainer,enableComments:(c=i==null?void 0:i.enableComments)!=null?c:!0},this.settingsProvider=(d=i==null?void 0:i.settingsProvider)!=null?d:new hO(this),oO(this,i==null?void 0:i.components),this.blockHooks.push(...(C=(h=i==null?void 0:i.components)==null?void 0:h.blockHooks)!=null?C:[]),this.id=(E=i==null?void 0:i.id)!=null?E:Z(),this.clientId=Z(),this.undoManager=new eO(this),this.doc=new XU(this,r,this.undoManager),this.parent=e,this.rootElement=B("div",["editor-root"],this.parent),this.rootElement.setAttribute("data-editor-client-id",this.clientId),this.contentElement=B("div",["editor-content"],this.rootElement),this.rootContainerObject=Qv(this),this.rootContainer=this.rootContainerObject.rootContainer,this.input=new SM(this,this.inputHandlers),this.selection=new xU(this),this.selectionHandler=new vU(this),i!=null&&i.shortcuts&&this.shortcuts.shortcuts.push(...i.shortcuts),me.isMobile&&z(this.rootElement,"mobile"),me.isSafari&&z(this.rootElement,"safari"),this._readonly&&z(this.rootElement,"readonly"),this.emit("load",this,!1)}get readonly(){return this._readonly}set readonly(e){this._readonly=e,e?z(this.rootElement,"readonly"):ot(this.rootElement,"readonly"),this.emit("readonlyChanged",this)}get scrollContainer(){return this.options.scrollContainer?this.options.scrollContainer:En(this.rootContainer)}addCustom(e,r){const i=this.customs.get(e);if(i)return i;const o=r(this);return this.customs.set(e,o),o}getCustom(e){const r=this.customs.get(e);return p(io,r,`${e} does not exists`),r}replaceCustom(e,r){const i=this.customs.get(e);return i&&i.destroy(),this.customs.set(e,r),r}findCustom(e){return this.customs.get(e)}findCustomByType(e){const r=this.customs.values();for(const i of r)if(i instanceof e)return i;return null}destroyCustom(e){const r=this.customs.get(e);r&&(this.customs.delete(e),r.destroy())}getComponentOptions(e){return this.options.componentsOptions[e]}registerLocalEvents(e){this.doc.registerLocalEvents(e)}reload(){this.rootContainerObject.reload(),this.emit("load",this,!0)}createBlock(e,r,i){return this.editorBlocks.createBlock(e,r,i)}createBox(e,r){return this.editorBoxes.createBox(e,r)}createInsertion(e,r){return this.editorInsertions.createInsertion(e,r)}destroy(){io.debug("destroy editor"),this.emit("destroy",this),this.input.destroy(),this.rootContainerObject.destroy(),this.rootElement.remove(),this.doc.destroy(),this.customs.forEach(e=>e.destroy()),this.customs.clear(),this.selection.destroy(),this.domEvents.destroy(),this.removeAllListeners(),this.inputHandlers.destroy()}focus(){this.input.focus()}focusToBlock(e,r){ep(this,e,r)}isWritable(){return dO(this)}isBlockWritable(e){return fO(this,e)}getChildContainerData(e){const r=this.doc.getContainerBlocks(e);return(!r||!Array.isArray(r))&&(p(io,r,`no child container data: ${e}, ${JSON.stringify(this.doc)}`),p(io,Array.isArray(r),`container data is not an array: ${JSON.stringify(r)}`)),r}createChildContainer(e,r,i){return Yv(this,e,r,i)}getFirstBlock(){return this.rootContainer.querySelector("[data-type=editor-block]")}getLastBlock(){const e=Array.from(this.rootContainer.querySelectorAll(":scope [data-type=editor-block]"));return e[e.length-1]}getFocusedBlock(){return this.selection.getFocusedBlock()}findBlockById(e){const r=this.rootContainer.querySelector(`#${e}`);return r&&p(io,Vs(r),"not an valid block element"),r!=null?r:null}findBoxById(e){const r=this.rootContainer.querySelector(`#${e}`);return r&&p(io,Gd(r),"not an valid box element"),r!=null?r:null}getBlockById(e){const r=this.findBlockById(e);return p(io,r,`no block, id=${e}`),r}getBoxById(e){const r=this.findBoxById(e);return p(io,r,`no box, id=${e}`),r}getBlockByIndex(e,r){const i=this.getContainerById(e);return zi(i,r)}findBlockByIndex(e,r){const i=this.getContainerById(e);return Cv(i,r)}getBlockIndex(e){if(typeof e=="string"){const r=this.getBlockById(e);return bt(r)}return bt(e)}getContainerById(e){return ui(this,e)}getParentContainer(e){return rt(e)}reloadBlock(e){lO(this,e)}contains(e){const r=e instanceof Element?e:e.parentElement;return r?r.closest("div.editor-root")===this.rootElement:!1}insertBlock(e,r,i,o,s){const l={blockId:i.id,offset:0},c={anchor:l,focus:l};return ka(this,e,r,i,o!=null?o:c,s)}insertEmbed(e,r,i,o,s){const l={id:Z(),type:"embed",embedType:i,embedData:o};return this.insertBlock(e,r,l,s)}deleteBlock(e,r){Z1(this,e,r)}mergeTextBlock(e,r){return XB(this,e,r)}breakTextBlock(e,r,i){return Ra(this,e,r,i).newBlock}getTextPosition(){return Ta(this)}getBlockString(e,r){const i=this.getBlockText(e);return fe(i,r)}getBlockData(e){return Wo(this,e)}getBoxData(e){return vB(this,e)}getBlockText(e){return bn(this,e)}setBlockText(e,r){JB(this,e,r)}deleteTextFromBlock(e,r,i,o){return Y1(this,e,r,i,o)}insertTextToBlock(e,r,i,o){return HB(this,e,r,i,o)}insertBoxToBlock(e,r,i){return jB(this,e,r,i)}pasteDoc(e){return this.inputHandlers.pasteDoc(e)}insertDoc(e,r,i,o){e5(this,e,r,i,o)}insertDocAt(e,r,i,o){return ip(this,e,r,i,o)}deleteChildContainers(e){qB(this,e)}replaceBlockText(e,r){return kh(this,e,r)}updateBlockData(e,r,i){const o={...this.getBlockData(e),...r},{id:s,type:l,...c}=o;return Rh(this,e,c,(i!=null?i:this.selection.range).toDocRange())}updateEmbedData(e,r,i){return ZB(this,e,r,i)}updateBoxData(e,r){uO(this,e,r)}getSelectedText(){const e=Sa(this);return ro(this,e)}clearSelectedContents(){yh(this)}insertTextBlock(e,r,i,o){const s=pi(e!=null?e:"");return WB(this,s,r,i,o==null?void 0:o.newRange,o==null?void 0:o.insertBlockOptions)}updateCompositionText(e,r){if(e&&!r&&(this.selection.range.isCollapsed()||this.clearSelectedContents()),!e&&!r){Q1(this);return}r?(this.compositingText="",Jc()?e||Q1(this):X1(this,e)):(this.compositingText=e,zB(this))}}function ku(n,t,e){return new gO(n,t,e)}function pO(n){const t=(r,i)=>{const o=r.findIndex(l=>l.id===i.id);if(o===-1){r.push(i);return}const s=r[o];if(s.value!==i.value){r.splice(o,1);return}if(!!s.states){if(!i.states){s.states=[];return}s.states=Tg.default(s.states,i.states)}},e=[];return n.forEach(r=>{r.forEach(i=>{t(e,i)})}),e}const CO=["#0064FF","#EB3723","#F59300","#00A865","#F25A0A","#70A310","#009CAD","#0990D9","#8851ED","#D62069"];class Ru extends Re.TypedEmitter{constructor(e){super();m(this,"users",new Map);m(this,"cursors",new Map);m(this,"addingUser",!1);m(this,"colors");this.colors=e&&e.length>0?e:CO}setCursor(e){this.addUser(e.user);const r=this.cursors.get(e.user.userId);if(r&&qc.default(r,e))return;this.cursors.set(e.user.userId,e);const i=new Set([e.range.anchor.blockId,e.range.focus.blockId]),o=new Set(i);r&&new Set([r.range.anchor.blockId,r.range.focus.blockId]).forEach(l=>{i.has(l)||o.add(l)}),this.emit("remote-carets-change",[...o])}addUsers(e){this.addingUser=!0,e.forEach(r=>this.addUser(r)),this.addingUser=!1,this.emit("change",Array.from(this.users.values()))}addUser(e){this.users.set(e.userId,e),this.addingUser||this.emit("change",Array.from(this.users.values()))}findUser(e){var r;return(r=this.users.get(e))!=null?r:null}removeUser(e){this.users.delete(e),this.emit("change",Array.from(this.users.values()));const r=this.cursors.get(e);if(r){const i=new Set(new Set([r==null?void 0:r.range.anchor.blockId,r==null?void 0:r.range.focus.blockId]));this.cursors.delete(e),this.emit("remote-carets-change",[...i])}}updateUsers(e){this.users.forEach(r=>{e.find(i=>i.userId===r.userId)||this.removeUser(r.userId)}),this.users.clear(),this.addingUser=!0;try{e.forEach(r=>{this.addUser(r)})}finally{this.addingUser=!1}setTimeout(()=>{this.emit("change",Array.from(this.users.values()))},300)}getSimpleCursors(e){const r=new Map;return Array.from(this.cursors.values()).filter(i=>i.range.anchor.blockId===e&&hh(i.range)).forEach(i=>{const o=i.range.focus.offset;let s=r.get(o);s||(s=[],r.set(o,s)),s.push(i)}),r}getCursors(e){return Array.from(this.cursors.values()).filter(r=>r.range.anchor.blockId===e||r.range.focus.blockId===e)}onUpdateBlockText(e,r,i){if(!e.text)return;this.getCursors(e.id).forEach(l=>{if(hh(l.range)){const{anchor:c,focus:d}=l.range;c.blockId===e.id&&(c.offset=fn.transformCursor(c.offset,r,i)),d.blockId===e.id&&(d.offset=fn.transformCursor(d.offset,r,i))}})}getFixedUserColor(e,r){let i=0;Array.from(e).forEach(s=>{i+=s.charCodeAt(0)});const o=i%this.colors.length;return this.colors[o]}destroy(){this.removeAllListeners()}}const rn=I("local-doc");class bp extends sa{constructor(e,r){super();m(this,"doc");m(this,"serviceUrl");e?this.doc=e:this.doc={meta:{},comments:{},blocks:{root:[pi("")]}},this.serviceUrl=(r==null?void 0:r.serverUrl)||""}beginBatchUpdate(){return 0}endBatchUpdate(){return 0}toJSON(){return gt.default(this.doc)}getContainerBlocks(e){return this.doc.blocks[e]}findContainerBlocks(e){return this.doc.blocks[e]}getBlockData(e,r){const i=this.getContainerBlocks(e);p(rn,i,`no container data: ${e}`);const o=i[r];return p(rn,o,`no block data: ${r}`),o}localUpdateBlockText(e,r,i){const o=this.getBlockData(e,r);p(rn,o.text,"no text for data");const s=fn.apply(o.text,i);return o.text=s,p(rn,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(l=>{var c;return(c=l.onUpdateBlockText)==null?void 0:c.call(l,e,r,i,!0)}),s}localUpdateBlockData(e,r,i){const o=this.getBlockData(e,r);return i.delete.forEach(s=>delete o[s]),Object.entries(i.insert).forEach(([s,l])=>{o[s]=l}),p(rn,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,e,r,i,!0)}),o}localInsertBlock(e,r,i){const o=this.getContainerBlocks(e);return p(rn,o,`no container data: ${e}`),p(rn,r>=0&&r<=o.length,`invalid block index: ${r}, ${o.length}`),o.splice(r,0,i),p(rn,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onInsertBlock)==null?void 0:l.call(s,e,r,i,!0)}),i}localDeleteBlock(e,r){const i=this.getContainerBlocks(e);p(rn,i,`no container data: ${e}`),p(rn,r>=0&&r<=i.length,`invalid block index: ${r}, ${i.length}`);const o=i[r];return i.splice(r,1),p(rn,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onDeleteBlock)==null?void 0:l.call(s,e,r,!0)}),o}localInsertChildContainers(e){e.forEach(({containerId:r,blocks:i})=>{this.doc.blocks[r]=i,p(rn,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(o=>{var s;return(s=o.onInsertChildContainer)==null?void 0:s.call(o,r,i,!0)})})}localDeleteChildContainers(e){rn.debug(`delete child containers: ${e}`),e.forEach(r=>{p(rn,this.doc.blocks[r],`no child container: ${r}`),delete this.doc.blocks[r]}),e.forEach(r=>{p(rn,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var o;return(o=i.onDeleteChildContainer)==null?void 0:o.call(i,r,!0)})})}uploadResource(e,r){p(rn,!1,"not implemented")}async addResources(e){return e}buildResourceUrl(e){return e}request(e,r){p(rn,!1,"not implemented")}broadcastMessage(e){}getServerMeta(){return{serverId:this.serviceUrl}}getUser(){return{permission:"w",userId:"-",displayName:"-",avatarUrl:"-",rainbowIndex:0}}getRemoteUsers(){return new Ru}setDoc(e){this.doc=gt.default(e),this.callbacks.forEach(r=>{var i;return(i=r.onRequestReload)==null?void 0:i.call(r,"change doc")})}destroy(){this.clearCallbacks()}}class EO{constructor(t){this.cleanup=t}destroy(){var t;(t=this.cleanup)==null||t.call(this)}}function vp(n,t,e){n.addCustom(t,()=>{var o;const r=(o=e())!=null?o:void 0;return new EO(r)})}const B2=I("find-block");function T2(n,t){const e=js(t);if(!e){if(dr(t))return null;const r=$s(t);return p(B2,r,"no parent block"),T2(n,r)}return _t(n,e)?pa(n,e,{visibleOnly:!0}):e}function y2(n,t){const e=zs(t);if(!e){if(dr(t))return null;const r=$s(t);return p(B2,r,"no parent block"),y2(n,r)}return _t(n,e)?s1(n,e,{visibleOnly:!0}):e}const xO=I("remote-cursor");class AO{constructor(){m(this,"remoteUsers",new Ru)}onCustomMessage(t){const e=t;if(e.type==="onlineUsers"){const r=e;this.handleUpdateUsers(r.users)}else e.type==="caret"?this.handleUpdateCaret(e):xO.debug(`unknown remote message received: ${t}`)}handleUpdateUsers(t){this.remoteUsers.updateUsers(t)}handleUpdateCaret(t){const e=this.remoteUsers.findUser(t.userId);!e||this.remoteUsers.setCursor({oneseditor:"cursor",user:e,range:t.range,time:Date.now()})}destroy(){this.remoteUsers.destroy()}}function bO(n){const{blocks:t,meta:e,comments:r,...i}=n;return{rootBlocks:t,meta:e,comments:r,childBlocks:i}}function vO(n){const{blocks:t,meta:e,comments:r}=n,{root:i,...o}=t;return{blocks:i,meta:e,comments:r,...o}}function oo(n){const{childBlocks:t,meta:e,comments:r,rootBlocks:i}=bO(gt.default(n));return{blocks:{root:i,...t},meta:e,comments:r}}function so(n){return n==="root"?"blocks":n}function Ma(n){return n==="blocks"?"root":n}const BO={type:{name:"rich-text",uri:"http://sharejs.org/types/rich-text/v1",create(n){return new cn.default(n)},apply(n,t){const e=new cn.default(n),r=new cn.default(t);return e.compose(r).ops},compose(n,t){const e=new cn.default(n),r=new cn.default(t);return e.compose(r).ops},diff(n,t){const e=new cn.default(n),r=new cn.default(t);return e.diff(r).ops},transform(n,t,e){const r=new cn.default(n);return new cn.default(t).transform(r,e==="left").ops},transformCursor(n,t,e){return t.transformPosition(n,!e)},normalize(n){return n},serialize(n){return n.ops},deserialize(n){return n},transformPresence(n,t,e){if(!n)return null;const r=new cn.default(t),i=this.transformCursor(n.index,r,e),o=this.transformCursor(n.index+n.length,r,e);return{...n,index:i,length:o-i}}}};var Yo={},Bp=Cb.default.EventEmitter;Yo.EventEmitter=Bp,Yo.mixin=TO;function TO(n){for(var t in Bp.prototype)n.prototype[t]=Bp.prototype[t]}var k2=["info","warn","error"];function R2(){var n={};k2.forEach(function(t){n[t]=console[t].bind(console)}),this.setMethods(n)}var yO=R2;R2.prototype.setMethods=function(n){n=n||{};var t=this;k2.forEach(function(e){typeof n[e]=="function"&&(t[e]=n[e])})};var kO=yO,RO=new kO,w2=RO;function nl(n,t){this.code=n,this.message=t||"",Error.captureStackTrace?Error.captureStackTrace(this,nl):this.stack=new Error().stack}nl.prototype=Object.create(Error.prototype),nl.prototype.constructor=nl,nl.prototype.name="ShareDBError",nl.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 Nh=nl,wu={},S2=wO;function wO(n,t,e,r){var i=function(s,l,c,d){t(c,s,l,"left"),t(d,l,s,"right")},o=n.transformX=function(s,l){e(s),e(l);for(var c=[],d=0;d<l.length;d++){for(var h=l[d],C=[],E=0;E<s.length;){var A=[];if(i(s[E],h,C,A),E++,A.length===1)h=A[0];else if(A.length===0){for(var v=E;v<s.length;v++)r(C,s[v]);h=null;break}else{for(var R=o(s.slice(E),A),L=0;L<R[0].length;L++)r(C,R[0][L]);for(var M=0;M<R[1].length;M++)r(c,R[1][M]);h=null;break}}h!=null&&r(c,h),s=C}return[s,c]};n.transform=function(s,l,c){if(!(c==="left"||c==="right"))throw new Error("type must be 'left' or 'right'");return l.length===0?s:s.length===1&&l.length===1?t([],s[0],l[0],c):c==="left"?o(s,l)[0]:o(l,s)[1]}}var L2={exports:{}},Jo=L2.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||""}},Tp=function(n,t,e){return n.slice(0,t)+e+n.slice(t)},yp=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")},Ph=function(n){for(var t=0;t<n.length;t++)yp(n[t])};Jo.apply=function(n,t){var e;Ph(t);for(var r=0;r<t.length;r++){var i=t[r];if(i.i!=null)n=Tp(n,i.p,i.i);else{if(e=n.slice(i.p,i.p+i.d.length),i.d!==e)throw new Error("Delete component '"+i.d+"' does not match deleted text '"+e+"'");n=n.slice(0,i.p)+n.slice(i.p+i.d.length)}}return n};var lo=Jo._append=function(n,t){if(!(t.i===""||t.d===""))if(n.length===0)n.push(t);else{var e=n[n.length-1];e.i!=null&&t.i!=null&&e.p<=t.p&&t.p<=e.p+e.i.length?n[n.length-1]={i:Tp(e.i,t.p-e.p,t.i),p:e.p}:e.d!=null&&t.d!=null&&t.p<=e.p&&e.p<=t.p+t.d.length?n[n.length-1]={d:Tp(t.d,e.p-t.p,e.d),p:t.p}:n.push(t)}};Jo.compose=function(n,t){Ph(n),Ph(t);for(var e=n.slice(),r=0;r<t.length;r++)lo(e,t[r]);return e},Jo.normalize=function(n){var t=[];(n.i!=null||n.p!=null)&&(n=[n]);for(var e=0;e<n.length;e++){var r=n[e];r.p==null&&(r.p=0),lo(t,r)}return t};var kp=function(n,t,e){return t.i!=null?t.p<n||t.p===n&&e?n+t.i.length:n:n<=t.p?n:n<=t.p+t.d.length?t.p:n-t.d.length};Jo.transformCursor=function(n,t,e){for(var r=e==="right",i=0;i<t.length;i++)n=kp(n,t[i],r);return n};var SO=Jo._tc=function(n,t,e,r){if(yp(t),yp(e),t.i!=null)lo(n,{i:t.i,p:kp(t.p,e,r==="right")});else if(e.i!=null){var i=t.d;t.p<e.p&&(lo(n,{d:i.slice(0,e.p-t.p),p:t.p}),i=i.slice(e.p-t.p)),i!==""&&lo(n,{d:i,p:t.p+e.i.length})}else if(t.p>=e.p+e.d.length)lo(n,{d:t.d,p:t.p-e.d.length});else if(t.p+t.d.length<=e.p)lo(n,t);else{var o={d:"",p:t.p};t.p<e.p&&(o.d=t.d.slice(0,e.p-t.p)),t.p+t.d.length>e.p+e.d.length&&(o.d+=t.d.slice(e.p+e.d.length-t.p));var s=Math.max(t.p,e.p),l=Math.min(t.p+t.d.length,e.p+e.d.length),c=t.d.slice(s-t.p,l-t.p),d=e.d.slice(s-e.p,l-e.p);if(c!==d)throw new Error("Delete ops delete different text in the same region of the document");o.d!==""&&(o.p=kp(o.p,e),lo(n,o))}return n},LO=function(n){return n.i!=null?{d:n.i,p:n.p}:{i:n.d,p:n.p}};Jo.invert=function(n){n=n.slice().reverse();for(var t=0;t<n.length;t++)n[t]=LO(n[t]);return n},S2(Jo,SO,Ph,lo);var Fh=function(n){return Object.prototype.toString.call(n)=="[object Array]"},IO=function(n){return!!n&&n.constructor===Object},Kr=function(n){return JSON.parse(JSON.stringify(n))},Lt={name:"json0",uri:"http://sharejs.org/types/JSONv0"},ao={};Lt.registerSubtype=function(n){ao[n.name]=n},Lt.create=function(n){return n===void 0?null:Kr(n)},Lt.invertComponent=function(n){var t={p:n.p};return n.t&&ao[n.t]&&(t.t=n.t,t.o=ao[n.t].invert(n.o)),n.si!==void 0&&(t.sd=n.si),n.sd!==void 0&&(t.si=n.sd),n.oi!==void 0&&(t.od=n.oi),n.od!==void 0&&(t.oi=n.od),n.li!==void 0&&(t.ld=n.li),n.ld!==void 0&&(t.li=n.ld),n.na!==void 0&&(t.na=-n.na),n.lm!==void 0&&(t.lm=n.p[n.p.length-1],t.p=n.p.slice(0,n.p.length-1).concat([n.lm])),t},Lt.invert=function(n){for(var t=n.slice().reverse(),e=[],r=0;r<t.length;r++)e.push(Lt.invertComponent(t[r]));return e},Lt.checkValidOp=function(n){for(var t=0;t<n.length;t++)if(!Fh(n[t].p))throw new Error("Missing path")},Lt.checkList=function(n){if(!Fh(n))throw new Error("Referenced element not a list")},Lt.checkObj=function(n){if(!IO(n))throw new Error("Referenced element not an object (it was "+JSON.stringify(n)+")")};function Su(n){n.t="text0";var t={p:n.p.pop()};n.si!=null&&(t.i=n.si),n.sd!=null&&(t.d=n.sd),n.o=[t]}function Lu(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}Lt.apply=function(n,t){Lt.checkValidOp(t),t=Kr(t);for(var e={data:n},r=0;r<t.length;r++){var i=t[r];(i.si!=null||i.sd!=null)&&Su(i);for(var o=null,s=e,l="data",c=0;c<i.p.length;c++){var d=i.p[c];if(o=s,s=s[l],l=d,o==null)throw new Error("Path invalid")}if(i.t&&i.o!==void 0&&ao[i.t])s[l]=ao[i.t].apply(s[l],i.o);else if(i.na!==void 0){if(typeof s[l]!="number")throw new Error("Referenced element not a number");s[l]+=i.na}else if(i.li!==void 0&&i.ld!==void 0)Lt.checkList(s),s[l]=i.li;else if(i.li!==void 0)Lt.checkList(s),s.splice(l,0,i.li);else if(i.ld!==void 0)Lt.checkList(s),s.splice(l,1);else if(i.lm!==void 0){if(Lt.checkList(s),i.lm!=l){var h=s[l];s.splice(l,1),s.splice(i.lm,0,h)}}else if(i.oi!==void 0)Lt.checkObj(s),s[l]=i.oi;else if(i.od!==void 0)Lt.checkObj(s),delete s[l];else throw new Error("invalid / missing instruction in op")}return e.data},Lt.shatter=function(n){for(var t=[],e=0;e<n.length;e++)t.push([n[e]]);return t},Lt.incrementalApply=function(n,t,e){for(var r=0;r<t.length;r++){var i=[t[r]];n=Lt.apply(n,i),e(i,n)}return n};var DO=Lt.pathMatches=function(n,t,e){if(n.length!=t.length)return!1;for(var r=0;r<n.length;r++)if(n[r]!==t[r]&&(!e||r!==n.length-1))return!1;return!0};Lt.append=function(n,t){if(t=Kr(t),n.length===0){n.push(t);return}var e=n[n.length-1];if((t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(Su(t),Su(e)),DO(t.p,e.p))if(t.t&&e.t&&t.t===e.t&&ao[t.t]){if(e.o=ao[t.t].compose(e.o,t.o),t.si!=null||t.sd!=null){for(var r=t.p,i=0;i<e.o.length-1;i++)t.o=[e.o.pop()],t.p=r.slice(),Lu(t),n.push(t);Lu(e)}}else e.na!=null&&t.na!=null?n[n.length-1]={p:e.p,na:e.na+t.na}:e.li!==void 0&&t.li===void 0&&t.ld===e.li?e.ld!==void 0?delete e.li:n.pop():e.od!==void 0&&e.oi===void 0&&t.oi!==void 0&&t.od===void 0?e.oi=t.oi:e.oi!==void 0&&t.od!==void 0?t.oi!==void 0?e.oi=t.oi:e.od!==void 0?delete e.oi:n.pop():t.lm!==void 0&&t.p[t.p.length-1]===t.lm||n.push(t);else(t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(Lu(t),Lu(e)),n.push(t)},Lt.compose=function(n,t){Lt.checkValidOp(n),Lt.checkValidOp(t);for(var e=Kr(n),r=0;r<t.length;r++)Lt.append(e,t[r]);return e},Lt.normalize=function(n){var t=[];n=Fh(n)?n:[n];for(var e=0;e<n.length;e++){var r=n[e];r.p==null&&(r.p=[]),Lt.append(t,r)}return t},Lt.commonLengthForOps=function(n,t){var e=n.p.length,r=t.p.length;if((n.na!=null||n.t)&&e++,(t.na!=null||t.t)&&r++,e===0)return-1;if(r===0)return null;e--,r--;for(var i=0;i<e;i++){var o=n.p[i];if(i>=r||o!==t.p[i])return null}return e},Lt.canOpAffectPath=function(n,t){return Lt.commonLengthForOps({p:t},n)!=null},Lt.transformComponent=function(n,t,e,r){t=Kr(t);var i=Lt.commonLengthForOps(e,t),o=Lt.commonLengthForOps(t,e),s=t.p.length,l=e.p.length;if((t.na!=null||t.t)&&s++,(e.na!=null||e.t)&&l++,o!=null&&l>s&&t.p[o]==e.p[o]){if(t.ld!==void 0){var c=Kr(e);c.p=c.p.slice(s),t.ld=Lt.apply(Kr(t.ld),[c])}else if(t.od!==void 0){var c=Kr(e);c.p=c.p.slice(s),t.od=Lt.apply(Kr(t.od),[c])}}if(i!=null){var d=s==l,c=e;if((t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(Su(t),c=Kr(e),Su(c)),c.t&&ao[c.t]){if(t.t&&t.t===c.t){var h=ao[t.t].transform(t.o,c.o,r);if(t.si!=null||t.sd!=null)for(var C=t.p,E=0;E<h.length;E++)t.o=[h[E]],t.p=C.slice(),Lu(t),Lt.append(n,t);else(!Fh(h)||h.length>0)&&(t.o=h,Lt.append(n,t));return n}}else if(e.na===void 0){if(e.li!==void 0&&e.ld!==void 0){if(e.p[i]===t.p[i])if(d){if(t.ld!==void 0)if(t.li!==void 0&&r==="left")t.ld=Kr(e.li);else return n}else return n}else if(e.li!==void 0)t.li!==void 0&&t.ld===void 0&&d&&t.p[i]===e.p[i]?r==="right"&&t.p[i]++:e.p[i]<=t.p[i]&&t.p[i]++,t.lm!==void 0&&d&&e.p[i]<=t.lm&&t.lm++;else if(e.ld!==void 0){if(t.lm!==void 0&&d){if(e.p[i]===t.p[i])return n;var C=e.p[i],A=t.p[i],v=t.lm;(C<v||C===v&&A<v)&&t.lm--}if(e.p[i]<t.p[i])t.p[i]--;else if(e.p[i]===t.p[i]){if(l<s)return n;if(t.ld!==void 0)if(t.li!==void 0)delete t.ld;else return n}}else if(e.lm!==void 0)if(t.lm!==void 0&&s===l){var A=t.p[i],v=t.lm,R=e.p[i],L=e.lm;if(R!==L)if(A===R)if(r==="left")t.p[i]=L,A===v&&(t.lm=L);else return n;else A>R&&t.p[i]--,A>L?t.p[i]++:A===L&&R>L&&(t.p[i]++,A===v&&t.lm++),(v>R||v===R&&v>A)&&t.lm--,v>L?t.lm++:v===L&&(L>R&&v>A||L<R&&v<A?r==="right"&&t.lm++:v>A?t.lm++:v===R&&t.lm--)}else if(t.li!==void 0&&t.ld===void 0&&d){var A=e.p[i],v=e.lm;C=t.p[i],C>A&&t.p[i]--,C>v&&t.p[i]++}else{var A=e.p[i],v=e.lm;C=t.p[i],C===A?t.p[i]=v:(C>A&&t.p[i]--,(C>v||C===v&&A>v)&&t.p[i]++)}else if(e.oi!==void 0&&e.od!==void 0){if(t.p[i]===e.p[i])if(t.oi!==void 0&&d){if(r==="right")return n;t.od=e.oi}else return n}else if(e.oi!==void 0){if(t.oi!==void 0&&t.p[i]===e.p[i])if(r==="left")Lt.append(n,{p:t.p,od:e.oi});else return n}else if(e.od!==void 0&&t.p[i]==e.p[i]){if(!d)return n;if(t.oi!==void 0)delete t.od;else return n}}}return Lt.append(n,t),n},S2(Lt,Lt.transformComponent,Lt.checkValidOp,Lt.append);var _O=L2.exports;Lt.registerSubtype(_O);var MO=Lt,UO={type:MO};(function(n){n.defaultType=UO.type,n.map={},n.register=function(t){t.name&&(n.map[t.name]=t),t.uri&&(n.map[t.uri]=t)},n.register(n.defaultType)})(wu);var Vr={};(function(n){n.doNothing=t;function t(){}n.hasKeys=function(e){for(var r in e)return!0;return!1},n.isInteger=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e},n.isValidVersion=function(e){return e===null?!0:n.isInteger(e)&&e>=0},n.isValidTimestamp=function(e){return n.isValidVersion(e)},n.MAX_SAFE_INTEGER=9007199254740991,n.dig=function(){for(var e=arguments[0],r=1;r<arguments.length;r++){var i=arguments[r];e=e[i]||(r===arguments.length-1?void 0:{})}return e},n.digOrCreate=function(){for(var e=arguments[0],r=arguments[arguments.length-1],i=1;i<arguments.length-1;i++){var o=arguments[i];e=e[o]||(e[o]=i===arguments.length-2?r():{})}return e},n.digAndRemove=function(){for(var e=arguments[0],r=[e],i=1;i<arguments.length-1;i++){var o=arguments[i];if(!e.hasOwnProperty(o))break;e=e[o],r.push(e)}for(var i=r.length-1;i>=0;i--){var s=r[i],o=arguments[i+1],l=s[o];(i===r.length-1||!n.hasKeys(l))&&delete s[o]}},n.supportsPresence=function(e){return e&&typeof e.transformPresence=="function"},n.callEach=function(e,r){var i=!1;return e.forEach(function(o){o&&(o(r),i=!0)}),i},n.truthy=function(e){return!!e},n.nextTick=function(e){if(typeof process<"u"&&process.nextTick)return process.nextTick.apply(null,arguments);for(var r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];setTimeout(function(){e.apply(null,r)})},n.clone=function(e){return e===void 0?void 0:JSON.parse(JSON.stringify(e))}})(Vr);var I2=Array.isArray,D2=Object.keys,OO=Object.prototype.hasOwnProperty,NO=function n(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){var r=I2(t),i=I2(e),o,s,l;if(r&&i){if(s=t.length,s!=e.length)return!1;for(o=s;o--!==0;)if(!n(t[o],e[o]))return!1;return!0}if(r!=i)return!1;var c=t instanceof Date,d=e instanceof Date;if(c!=d)return!1;if(c&&d)return t.getTime()==e.getTime();var h=t instanceof RegExp,C=e instanceof RegExp;if(h!=C)return!1;if(h&&C)return t.toString()==e.toString();var E=D2(t);if(s=E.length,s!==D2(e).length)return!1;for(o=s;o--!==0;)if(!OO.call(e,E[o]))return!1;for(o=s;o--!==0;)if(l=E[o],!n(t[l],e[l]))return!1;return!0}return t!==t&&e!==e},_2=Yo,PO=w2,Zn=Nh,Kh=wu,$r=Vr,FO=$r.clone,KO=NO,Nn=Zn.CODES,VO=Ft;function Ft(n,t,e){_2.EventEmitter.call(this),this.connection=n,this.collection=t,this.id=e,this.version=null,this.type=null,this.data=void 0,this.inflightFetch=[],this.inflightSubscribe=null,this.pendingFetch=[],this.pendingSubscribe=[],this.subscribed=!1,this.wantSubscribe=!1,this._wantsDestroy=!1,this.inflightOp=null,this.pendingOps=[],this.type=null,this.applyStack=null,this.preventCompose=!1,this.submitSource=!1,this.paused=!1,this._dataStateVersion=0}_2.mixin(Ft),Ft.prototype.destroy=function(n){this._wantsDestroy=!0;var t=this;t.whenNothingPending(function(){t.wantSubscribe?t.unsubscribe(function(e){if(e)return n?n(e):t.emit("error",e);t.connection._destroyDoc(t),n&&n()}):(t.connection._destroyDoc(t),n&&n())})},Ft.prototype._setType=function(n){if(typeof n=="string"&&(n=Kh.map[n]),n)this.type=n;else if(n===null)this.type=n,this._setData(void 0);else{var t=new Zn(Nn.ERR_DOC_TYPE_NOT_RECOGNIZED,"Missing type "+n);return this.emit("error",t)}},Ft.prototype._setData=function(n){this.data=n,this._dataStateVersion++},Ft.prototype.ingestSnapshot=function(n,t){if(!n)return t&&t();if(typeof n.v!="number"){var e=new Zn(Nn.ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION,"Missing version in ingested snapshot. "+this.collection+"."+this.id);return t?t(e):this.emit("error",e)}if(this.type||this.hasWritePending()){if(this.version==null){if(this.hasWritePending())return t&&this.once("no write pending",t);var e=new Zn(Nn.ERR_DOC_MISSING_VERSION,"Cannot ingest snapshot in doc with null version. "+this.collection+"."+this.id);return t?t(e):this.emit("error",e)}return n.v>this.version?this.fetch(t):t&&t()}if(this.version>n.v)return t&&t();this.version=n.v;var r=n.type===void 0?Kh.defaultType:n.type;this._setType(r),this._setData(this.type&&this.type.deserialize?this.type.deserialize(n.data):n.data),this.emit("load"),t&&t()},Ft.prototype.whenNothingPending=function(n){var t=this;$r.nextTick(function(){if(t.hasPending()){t.once("nothing pending",n);return}n()})},Ft.prototype.hasPending=function(){return!!(this.inflightOp||this.pendingOps.length||this.inflightFetch.length||this.inflightSubscribe||this.pendingFetch.length||this.pendingSubscribe.length)},Ft.prototype.hasWritePending=function(){return!!(this.inflightOp||this.pendingOps.length)},Ft.prototype._emitNothingPending=function(){this.hasWritePending()||(this.emit("no write pending"),!this.hasPending()&&this.emit("nothing pending"))},Ft.prototype._emitResponseError=function(n,t){if(n&&n.code===Nn.ERR_SNAPSHOT_READ_SILENT_REJECTION){this.wantSubscribe=!1,t&&t(),this._emitNothingPending();return}if(t){t(n),this._emitNothingPending();return}this._emitNothingPending(),this.emit("error",n)},Ft.prototype._handleFetch=function(n,t){var e=this.pendingFetch;this.pendingFetch=[];var r=this.inflightFetch.shift();if(r&&e.push(r),e.length&&(r=function(i){$r.callEach(e,i)}),n)return this._emitResponseError(n,r);this.ingestSnapshot(t,r),this._emitNothingPending()},Ft.prototype._handleSubscribe=function(n,t){var e=this.inflightSubscribe;this.inflightSubscribe=null;var r=this.pendingFetch;this.pendingFetch=[],e.callback&&r.push(e.callback);var i;if(r.length&&(i=function(o){$r.callEach(r,o)}),n)return this._emitResponseError(n,i);this.subscribed=e.wantSubscribe,this.subscribed?this.ingestSnapshot(t,i):i&&i(),this._emitNothingPending(),this._flushSubscribe()},Ft.prototype._handleOp=function(n,t){if(n)return this.inflightOp?(n.code===Nn.ERR_OP_SUBMIT_REJECTED&&(n=null),this._rollback(n)):this.emit("error",n);if(this.inflightOp&&t.src===this.inflightOp.src&&t.seq===this.inflightOp.seq){this._opAcknowledged(t);return}if(this.version==null||t.v>this.version){this.fetch();return}if(!(t.v<this.version)){if(this.inflightOp){var e=Vh(this.inflightOp,t);if(e)return this._hardRollback(e)}for(var r=0;r<this.pendingOps.length;r++){var e=Vh(this.pendingOps[r],t);if(e)return this._hardRollback(e)}this.version++;try{this._otApply(t,!1)}catch(i){return this._hardRollback(i)}}},Ft.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))},Ft.prototype._resubscribe=function(){if(!this.pendingSubscribe.length&&this.wantSubscribe)return this.subscribe();var n=this.pendingSubscribe.some(function(t){return t.wantSubscribe});!n&&this.pendingFetch.length&&this.fetch(),this._flushSubscribe()},Ft.prototype.fetch=function(n){if(this.connection.canSend){var t=this.connection.sendFetch(this);$O(this.inflightFetch,t,n);return}this.pendingFetch.push(n)},Ft.prototype.subscribe=function(n){var t=!0;this._queueSubscribe(t,n)},Ft.prototype.unsubscribe=function(n){var t=!1;this._queueSubscribe(t,n)},Ft.prototype._queueSubscribe=function(n,t){var e=this.pendingSubscribe[this.pendingSubscribe.length-1]||this.inflightSubscribe,r=e&&e.wantSubscribe===n;if(r){e.callback=HO([e.callback,t]);return}this.pendingSubscribe.push({wantSubscribe:!!n,callback:t}),this._flushSubscribe()},Ft.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;$r.nextTick(function(){n._handleSubscribe()})}}};function $O(n,t,e){if(t){var r=n.pop();n.push(function(i){r&&r(i),e&&e(i)})}else n.push(e)}function HO(n){return n=n.filter($r.truthy),n.length?function(t){$r.callEach(n,t)}:null}Ft.prototype.flush=function(){!this.connection.canSend||this.inflightOp||!this.paused&&this.pendingOps.length&&this._sendOp()};function jO(n){delete n.op,delete n.create,delete n.del}function Vh(n,t){if(n.del)return jO(t);if(t.del)return new Zn(Nn.ERR_DOC_WAS_DELETED,"Document was deleted");if(t.create)return new Zn(Nn.ERR_DOC_ALREADY_CREATED,"Document already created");if("op"in t){if(n.create)return new Zn(Nn.ERR_DOC_ALREADY_CREATED,"Document already created");if(n.type.transformX){var e=n.type.transformX(n.op,t.op);n.op=e[0],t.op=e[1]}else{var r=n.type.transform(n.op,t.op,"left"),i=n.type.transform(t.op,n.op,"right");n.op=r,t.op=i}}}Ft.prototype._otApply=function(n,t){if("op"in n){if(!this.type)throw new Zn(Nn.ERR_DOC_DOES_NOT_EXIST,"Cannot apply op to uncreated document. "+this.collection+"."+this.id);if(this.emit("before op batch",n.op,t),!t&&this.type===Kh.defaultType&&n.op.length>1){this.applyStack||(this.applyStack=[]);for(var e=this.applyStack.length,r=0;r<n.op.length;r++){var i=n.op[r],o={op:[i]};this.emit("before op",o.op,t,n.src);for(var s=e;s<this.applyStack.length;s++){var l=Vh(this.applyStack[s],o);if(l)return this._hardRollback(l)}this._setData(this.type.apply(this.data,o.op)),this.emit("op",o.op,t,n.src)}this.emit("op batch",n.op,t),this._popApplyStack(e);return}this.emit("before op",n.op,t,n.src),this._setData(this.type.apply(this.data,n.op)),this.emit("op",n.op,t,n.src),this.emit("op batch",n.op,t);return}if(n.create){this._setType(n.create.type),this.type.deserialize?this.type.createDeserialized?this._setData(this.type.createDeserialized(n.create.data)):this._setData(this.type.deserialize(this.type.create(n.create.data))):this._setData(this.type.create(n.create.data)),this.emit("create",t);return}if(n.del){var c=this.data;this._setType(null),this.emit("del",c,t);return}},Ft.prototype._sendOp=function(){if(!!this.connection.canSend){var n=this.connection.id;this.inflightOp||(this.inflightOp=this.pendingOps.shift());var t=this.inflightOp;if(!t){var e=new Zn(Nn.ERR_INFLIGHT_OP_MISSING,"No op to send on call to _sendOp");return this.emit("error",e)}if(t.sentAt=Date.now(),t.retries=t.retries==null?0:t.retries+1,t.seq==null){if(this.connection.seq>=$r.MAX_SAFE_INTEGER)return this.emit("error",new Zn(Nn.ERR_CONNECTION_SEQ_INTEGER_OVERFLOW,"Connection seq has exceeded the max safe integer, maybe from being open for too long"));t.seq=this.connection.seq++}this.connection.sendOp(this,t),t.src==null&&(t.src=n)}},Ft.prototype._submit=function(n,t,e){if(t||(t=!0),"op"in n){if(!this.type){var r=new Zn(Nn.ERR_DOC_DOES_NOT_EXIST,"Cannot submit op. Document has not been created. "+this.collection+"."+this.id);return e?e(r):this.emit("error",r)}this.type.normalize&&(n.op=this.type.normalize(n.op))}try{this._pushOp(n,t,e),this._otApply(n,t)}catch(o){return this._hardRollback(o)}var i=this;$r.nextTick(function(){i.flush()})},Ft.prototype._pushOp=function(n,t,e){if(n.source=t,this.applyStack)this.applyStack.push(n);else{var r=this._tryCompose(n);if(r){r.callbacks.push(e);return}}n.type=this.type,n.callbacks=[e],this.pendingOps.push(n)},Ft.prototype._popApplyStack=function(n){if(n>0){this.applyStack.length=n;return}var t=this.applyStack[0];if(this.applyStack=null,!!t){var e=this.pendingOps.indexOf(t);if(e!==-1)for(var r=this.pendingOps.splice(e),e=0;e<r.length;e++){var t=r[e],i=this._tryCompose(t);i?i.callbacks=i.callbacks.concat(t.callbacks):this.pendingOps.push(t)}}},Ft.prototype._tryCompose=function(n){if(!this.preventCompose){var t=this.pendingOps[this.pendingOps.length-1];if(!(!t||t.sentAt)&&!(this.submitSource&&!KO(n.source,t.source))){if(t.create&&"op"in n)return t.create.data=this.type.apply(t.create.data,n.op),t;if("op"in t&&"op"in n&&this.type.compose)return t.op=this.type.compose(t.op,n.op),t}}},Ft.prototype.submitOp=function(n,t,e){typeof t=="function"&&(e=t,t=null);var r={op:n},i=t&&t.source;this._submit(r,i,e)},Ft.prototype.create=function(n,t,e,r){if(typeof t=="function"?(r=t,e=null,t=null):typeof e=="function"&&(r=e,e=null),t||(t=Kh.defaultType.uri),this.type){var i=new Zn(Nn.ERR_DOC_ALREADY_CREATED,"Document already exists");return r?r(i):this.emit("error",i)}var o={create:{type:t,data:n}},s=e&&e.source;this._submit(o,s,r)},Ft.prototype.del=function(n,t){if(typeof n=="function"&&(t=n,n=null),!this.type){var e=new Zn(Nn.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");return t?t(e):this.emit("error",e)}var r={del:!0},i=n&&n.source;this._submit(r,i,t)},Ft.prototype.pause=function(){this.paused=!0},Ft.prototype.resume=function(){this.paused=!1,this.flush()},Ft.prototype.toSnapshot=function(){return{v:this.version,data:FO(this.data),type:this.type.uri}},Ft.prototype._opAcknowledged=function(n){if(this.inflightOp.create)this.version=n.v;else if(n.v!==this.version)return PO.warn("Invalid version from server. Expected: "+this.version+" Received: "+n.v,n),this.fetch();this.version++,this._clearInflightOp()},Ft.prototype._rollback=function(n){var t=this.inflightOp;if("op"in t&&t.type.invert){try{t.op=t.type.invert(t.op)}catch{return this._hardRollback(n)}for(var e=0;e<this.pendingOps.length;e++){var r=Vh(this.pendingOps[e],t);if(r)return this._hardRollback(r)}try{this._otApply(t,!1)}catch(i){return this._hardRollback(i)}this._clearInflightOp(n);return}this._hardRollback(n)},Ft.prototype._hardRollback=function(n){var t=[];this.inflightOp&&t.push(this.inflightOp),t=t.concat(this.pendingOps),this._setType(null),this.version=null,this.inflightOp=null,this.pendingOps=[];var e=this;this.fetch(function(){for(var r=!!t.length,i=0;i<t.length;i++)r=$r.callEach(t[i].callbacks,n)&&r;if(n&&!r)return e.emit("error",n)})},Ft.prototype._clearInflightOp=function(n){var t=this.inflightOp;this.inflightOp=null;var e=$r.callEach(t.callbacks,n);if(this.flush(),this._emitNothingPending(),n&&!e)return this.emit("error",n)};var rl={};rl.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 M2=Yo,U2=rl.ACTIONS,zO=Vr,GO=Pn;function Pn(n,t,e,r,i,o,s){M2.EventEmitter.call(this),this.action=n,this.connection=t,this.id=e,this.collection=r,this.query=i,this.results=null,o&&o.results&&(this.results=o.results,delete o.results),this.extra=void 0,this.options=o,this.callback=s,this.ready=!1,this.sent=!1}M2.mixin(Pn),Pn.prototype.hasPending=function(){return!this.ready},Pn.prototype.send=function(){if(!!this.connection.canSend){var n={a:this.action,id:this.id,c:this.collection,q:this.query};if(this.options&&(n.o=this.options),this.results){for(var t=[],e=0;e<this.results.length;e++){var r=this.results[e];t.push([r.id,r.version])}n.r=t}this.connection.send(n),this.sent=!0}},Pn.prototype.destroy=function(n){this.connection.canSend&&this.action===U2.querySubscribe&&this.connection.send({a:U2.queryUnsubscribe,id:this.id}),this.connection._destroyQuery(this),n&&zO.nextTick(n)},Pn.prototype._onConnectionStateChanged=function(){this.connection.canSend&&!this.sent?this.send():this.sent=!1},Pn.prototype._handleFetch=function(n,t,e){this.connection._destroyQuery(this),this._handleResponse(n,t,e)},Pn.prototype._handleSubscribe=function(n,t,e){this._handleResponse(n,t,e)},Pn.prototype._handleResponse=function(n,t,e){var r=this.callback;if(this.callback=null,n)return this._finishResponse(n,r);if(!t)return this._finishResponse(null,r);var i=this,o=1,s=function(h){if(h)return i._finishResponse(h,r);--o||i._finishResponse(null,r)};if(Array.isArray(t))o+=t.length,this.results=this._ingestSnapshots(t,s),this.extra=e;else for(var l in t){o++;var c=t[l],d=this.connection.get(c.c||this.collection,l);d.ingestSnapshot(c,s)}s()},Pn.prototype._ingestSnapshots=function(n,t){for(var e=[],r=0;r<n.length;r++){var i=n[r],o=this.connection.get(i.c||this.collection,i.d);o.ingestSnapshot(i,t),e.push(o)}return e},Pn.prototype._finishResponse=function(n,t){if(this.emit("ready"),this.ready=!0,n)return this.connection._destroyQuery(this),t?t(n):this.emit("error",n);t&&t(null,this.results,this.extra)},Pn.prototype._handleError=function(n){this.emit("error",n)},Pn.prototype._handleDiff=function(n){for(var t=0;t<n.length;t++){var e=n[t];e.type==="insert"&&(e.values=this._ingestSnapshots(e.values))}for(var t=0;t<n.length;t++){var e=n[t];switch(e.type){case"insert":var r=e.values;Array.prototype.splice.apply(this.results,[e.index,0].concat(r)),this.emit("insert",r,e.index);break;case"remove":var o=e.howMany||1,i=this.results.splice(e.index,o);this.emit("remove",i,e.index);break;case"move":var o=e.howMany||1,s=this.results.splice(e.from,o);Array.prototype.splice.apply(this.results,[e.to,0].concat(s)),this.emit("move",s,e.from,e.to);break}}this.emit("changed",this.results)},Pn.prototype._handleExtra=function(n){this.extra=n,this.emit("extra",n)};var O2=Yo,WO=rl.ACTIONS,qO=Vr,N2=Ei;function Ei(n,t){if(O2.EventEmitter.call(this),!t||typeof t!="string")throw new Error("LocalPresence presenceId must be a string");this.presence=n,this.presenceId=t,this.connection=n.connection,this.presenceVersion=0,this.value=null,this._pendingMessages=[],this._callbacksByPresenceVersion={}}O2.mixin(Ei),Ei.prototype.submit=function(n,t){this.value=n,this.send(t)},Ei.prototype.send=function(n){var t=this._message();this._pendingMessages.push(t),this._callbacksByPresenceVersion[t.pv]=n,this._sendPending()},Ei.prototype.destroy=function(n){var t=this;this.submit(null,function(e){if(e)return t._callbackOrEmit(e,n);delete t.presence.localPresences[t.presenceId],n&&n()})},Ei.prototype._sendPending=function(){if(!!this.connection.canSend){var n=this;this._pendingMessages.forEach(function(t){n.connection.send(t)}),this._pendingMessages=[]}},Ei.prototype._ack=function(n,t){var e=this._getCallback(t);this._callbackOrEmit(n,e)},Ei.prototype._message=function(){return{a:WO.presence,ch:this.presence.channel,id:this.presenceId,p:this.value,pv:this.presenceVersion++}},Ei.prototype._getCallback=function(n){var t=this._callbacksByPresenceVersion[n];return delete this._callbacksByPresenceVersion[n],t},Ei.prototype._callbackOrEmit=function(n,t){if(t)return qO.nextTick(t,n);n&&this.emit("error",n)};var XO=Vr,P2=Rp;function Rp(n,t){this.presence=n,this.presenceId=t,this.connection=this.presence.connection,this.value=null,this.presenceVersion=0}Rp.prototype.receiveUpdate=function(n){n.pv<this.presenceVersion||(this.value=n.p,this.presenceVersion=n.pv,this.presence._updateRemotePresence(this))},Rp.prototype.destroy=function(n){delete this.presence._remotePresenceInstances[this.presenceId],delete this.presence.remotePresences[this.presenceId],n&&XO.nextTick(n)};var wp={exports:{}};(function(n,t){(function(e,r){r(t)})(Mn,function(e){function r(y,S){S=S|0;for(var _=Math.max(y.length-S,0),N=Array(_),H=0;H<_;H++)N[H]=y[S+H];return N}var i=function(y){var S=r(arguments,1);return function(){var _=r(arguments);return y.apply(null,S.concat(_))}},o=function(y){return function(){var S=r(arguments),_=S.pop();y.call(this,S,_)}};function s(y){var S=typeof y;return y!=null&&(S=="object"||S=="function")}var l=typeof setImmediate=="function"&&setImmediate,c=typeof process=="object"&&typeof process.nextTick=="function";function d(y){setTimeout(y,0)}function h(y){return function(S){var _=r(arguments,1);y(function(){S.apply(null,_)})}}var C;l?C=setImmediate:c?C=process.nextTick:C=d;var E=h(C);function A(y){return o(function(S,_){var N;try{N=y.apply(this,S)}catch(H){return _(H)}s(N)&&typeof N.then=="function"?N.then(function(H){v(_,null,H)},function(H){v(_,H.message?H:new Error(H))}):_(null,N)})}function v(y,S,_){try{y(S,_)}catch(N){E(R,N)}}function R(y){throw y}var L=typeof Symbol=="function";function M(y){return L&&y[Symbol.toStringTag]==="AsyncFunction"}function U(y){return M(y)?A(y):y}function F(y){return function(S){var _=r(arguments,1),N=o(function(H,$){var X=this;return y(S,function(J,ct){U(J).apply(X,H.concat(ct))},$)});return _.length?N.apply(this,_):N}}var G=typeof Mn=="object"&&Mn&&Mn.Object===Object&&Mn,W=typeof self=="object"&&self&&self.Object===Object&&self,it=G||W||Function("return this")(),at=it.Symbol,xt=Object.prototype,Mt=xt.hasOwnProperty,Bt=xt.toString,le=at?at.toStringTag:void 0;function te(y){var S=Mt.call(y,le),_=y[le];try{y[le]=void 0;var N=!0}catch{}var H=Bt.call(y);return N&&(S?y[le]=_:delete y[le]),H}var kn=Object.prototype,be=kn.toString;function Kn(y){return be.call(y)}var Ii="[object Null]",Rn="[object Undefined]",mn=at?at.toStringTag:void 0;function Di(y){return y==null?y===void 0?Rn:Ii:mn&&mn in Object(y)?te(y):Kn(y)}var go="[object AsyncFunction]",Ar="[object Function]",Tx="[object GeneratorFunction]",yx="[object Proxy]";function kx(y){if(!s(y))return!1;var S=Di(y);return S==Ar||S==Tx||S==go||S==yx}var ps=9007199254740991;function bl(y){return typeof y=="number"&&y>-1&&y%1==0&&y<=ps}function vl(y){return y!=null&&bl(y.length)&&!kx(y)}var po={};function Ht(){}function _i(y){return function(){if(y!==null){var S=y;y=null,S.apply(this,arguments)}}}var Cs=typeof Symbol=="function"&&Symbol.iterator,bc=function(y){return Cs&&y[Cs]&&y[Cs]()};function pm(y,S){for(var _=-1,N=Array(y);++_<y;)N[_]=S(_);return N}function gn(y){return y!=null&&typeof y=="object"}var Bl="[object Arguments]";function Cm(y){return gn(y)&&Di(y)==Bl}var br=Object.prototype,Em=br.hasOwnProperty,Rx=br.propertyIsEnumerable,Tl=Cm(function(){return arguments}())?Cm:function(y){return gn(y)&&Em.call(y,"callee")&&!Rx.call(y,"callee")},ye=Array.isArray;function yl(){return!1}var kl=typeof e=="object"&&e&&!e.nodeType&&e,xm=kl&&!0&&n&&!n.nodeType&&n,Rl=xm&&xm.exports===kl,Am=Rl?it.Buffer:void 0,wl=Am?Am.isBuffer:void 0,Es=wl||yl,Lf=9007199254740991,If=/^(?:0|[1-9]\d*)$/;function Df(y,S){var _=typeof y;return S=S==null?Lf:S,!!S&&(_=="number"||_!="symbol"&&If.test(y))&&y>-1&&y%1==0&&y<S}var _f="[object Arguments]",Mf="[object Array]",Uf="[object Boolean]",Of="[object Date]",Nf="[object Error]",Pf="[object Function]",wx="[object Map]",Sx="[object Number]",Lx="[object Object]",bm="[object RegExp]",vm="[object Set]",Ix="[object String]",Dx="[object WeakMap]",_x="[object ArrayBuffer]",Mx="[object DataView]",Bm="[object Float32Array]",Ux="[object Float64Array]",Ox="[object Int8Array]",Nx="[object Int16Array]",Ff="[object Int32Array]",Px="[object Uint8Array]",Kf="[object Uint8ClampedArray]",Fx="[object Uint16Array]",Kx="[object Uint32Array]",de={};de[Bm]=de[Ux]=de[Ox]=de[Nx]=de[Ff]=de[Px]=de[Kf]=de[Fx]=de[Kx]=!0,de[_f]=de[Mf]=de[_x]=de[Uf]=de[Mx]=de[Of]=de[Nf]=de[Pf]=de[wx]=de[Sx]=de[Lx]=de[bm]=de[vm]=de[Ix]=de[Dx]=!1;function Vx(y){return gn(y)&&bl(y.length)&&!!de[Di(y)]}function $x(y){return function(S){return y(S)}}var Tm=typeof e=="object"&&e&&!e.nodeType&&e,Sl=Tm&&!0&&n&&!n.nodeType&&n,Hx=Sl&&Sl.exports===Tm,vc=Hx&&G.process,ym=function(){try{var y=Sl&&Sl.require&&Sl.require("util").types;return y||vc&&vc.binding&&vc.binding("util")}catch{}}(),km=ym&&ym.isTypedArray,jx=km?$x(km):Vx,zx=Object.prototype,Gx=zx.hasOwnProperty;function Wx(y,S){var _=ye(y),N=!_&&Tl(y),H=!_&&!N&&Es(y),$=!_&&!N&&!H&&jx(y),X=_||N||H||$,J=X?pm(y.length,String):[],ct=J.length;for(var Ct in y)(S||Gx.call(y,Ct))&&!(X&&(Ct=="length"||H&&(Ct=="offset"||Ct=="parent")||$&&(Ct=="buffer"||Ct=="byteLength"||Ct=="byteOffset")||Df(Ct,ct)))&&J.push(Ct);return J}var Bc=Object.prototype;function qx(y){var S=y&&y.constructor,_=typeof S=="function"&&S.prototype||Bc;return y===_}function Tc(y,S){return function(_){return y(S(_))}}var Xx=Tc(Object.keys,Object),Qx=Object.prototype,Yx=Qx.hasOwnProperty;function Rm(y){if(!qx(y))return Xx(y);var S=[];for(var _ in Object(y))Yx.call(y,_)&&_!="constructor"&&S.push(_);return S}function yc(y){return vl(y)?Wx(y):Rm(y)}function wm(y){var S=-1,_=y.length;return function(){return++S<_?{value:y[S],key:S}:null}}function Jx(y){var S=-1;return function(){var N=y.next();return N.done?null:(S++,{value:N.value,key:S})}}function Zx(y){var S=yc(y),_=-1,N=S.length;return function H(){var $=S[++_];return $==="__proto__"?H():_<N?{value:y[$],key:$}:null}}function tA(y){if(vl(y))return wm(y);var S=bc(y);return S?Jx(S):Zx(y)}function vr(y){return function(){if(y===null)throw new Error("Callback was already called.");var S=y;y=null,S.apply(this,arguments)}}function Ll(y){return function(S,_,N){if(N=_i(N||Ht),y<=0||!S)return N(null);var H=tA(S),$=!1,X=0,J=!1;function ct(ut,At){if(X-=1,ut)$=!0,N(ut);else{if(At===po||$&&X<=0)return $=!0,N(null);J||Ct()}}function Ct(){for(J=!0;X<y&&!$;){var ut=H();if(ut===null){$=!0,X<=0&&N(null);return}X+=1,_(ut.value,ut.key,vr(ct))}J=!1}Ct()}}function Mi(y,S,_,N){Ll(S)(y,U(_),N)}function je(y,S){return function(_,N,H){return y(_,S,N,H)}}function Vf(y,S,_){_=_i(_||Ht);var N=0,H=0,$=y.length;$===0&&_(null);function X(J,ct){J?_(J):(++H===$||ct===po)&&_(null)}for(;N<$;N++)S(y[N],N,vr(X))}var eA=je(Mi,1/0),Jr=function(y,S,_){var N=vl(y)?Vf:eA;N(y,U(S),_)};function Zr(y){return function(S,_,N){return y(Jr,S,U(_),N)}}function $f(y,S,_,N){N=N||Ht,S=S||[];var H=[],$=0,X=U(_);y(S,function(J,ct,Ct){var ut=$++;X(J,function(At,Jt){H[ut]=Jt,Ct(At)})},function(J){N(J,H)})}var kc=Zr($f),Hf=F(kc);function Co(y){return function(S,_,N,H){return y(Ll(_),S,U(N),H)}}var Ui=Co($f),jf=je(Ui,1),zf=F(jf);function xs(y,S){for(var _=-1,N=y==null?0:y.length;++_<N&&S(y[_],_,y)!==!1;);return y}function Gf(y){return function(S,_,N){for(var H=-1,$=Object(S),X=N(S),J=X.length;J--;){var ct=X[y?J:++H];if(_($[ct],ct,$)===!1)break}return S}}var As=Gf();function bs(y,S){return y&&As(y,S,yc)}function Sm(y,S,_,N){for(var H=y.length,$=_+(N?1:-1);N?$--:++$<H;)if(S(y[$],$,y))return $;return-1}function nA(y){return y!==y}function Lm(y,S,_){for(var N=_-1,H=y.length;++N<H;)if(y[N]===S)return N;return-1}function Il(y,S,_){return S===S?Lm(y,S,_):Sm(y,nA,_)}var Rc=function(y,S,_){typeof S=="function"&&(_=S,S=null),_=_i(_||Ht);var N=yc(y),H=N.length;if(!H)return _(null);S||(S=H);var $={},X=0,J=!1,ct=Object.create(null),Ct=[],ut=[],At={};bs(y,function(Ee,ce){if(!ye(Ee)){Jt(ce,[Ee]),ut.push(ce);return}var ve=Ee.slice(0,Ee.length-1),Tr=ve.length;if(Tr===0){Jt(ce,Ee),ut.push(ce);return}At[ce]=Tr,xs(ve,function(k){if(!y[k])throw new Error("async.auto task `"+ce+"` has a non-existent dependency `"+k+"` in "+ve.join(", "));ln(k,function(){Tr--,Tr===0&&Jt(ce,Ee)})})}),TA(),Oe();function Jt(Ee,ce){Ct.push(function(){Br(Ee,ce)})}function Oe(){if(Ct.length===0&&X===0)return _(null,$);for(;Ct.length&&X<S;){var Ee=Ct.shift();Ee()}}function ln(Ee,ce){var ve=ct[Ee];ve||(ve=ct[Ee]=[]),ve.push(ce)}function Hn(Ee){var ce=ct[Ee]||[];xs(ce,function(ve){ve()}),Oe()}function Br(Ee,ce){if(!J){var ve=vr(function(k,Pi){if(X--,arguments.length>2&&(Pi=r(arguments,1)),k){var ys={};bs($,function(jn,Vt){ys[Vt]=jn}),ys[Ee]=Pi,J=!0,ct=Object.create(null),_(k,ys)}else $[Ee]=Pi,Hn(Ee)});X++;var Tr=U(ce[ce.length-1]);ce.length>1?Tr($,ve):Tr(ve)}}function TA(){for(var Ee,ce=0;ut.length;)Ee=ut.pop(),ce++,xs(yA(Ee),function(ve){--At[ve]===0&&ut.push(ve)});if(ce!==H)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function yA(Ee){var ce=[];return bs(y,function(ve,Tr){ye(ve)&&Il(ve,Ee,0)>=0&&ce.push(Tr)}),ce}};function Eo(y,S){for(var _=-1,N=y==null?0:y.length,H=Array(N);++_<N;)H[_]=S(y[_],_,y);return H}var rA="[object Symbol]";function iA(y){return typeof y=="symbol"||gn(y)&&Di(y)==rA}var oA=1/0,Wf=at?at.prototype:void 0,Im=Wf?Wf.toString:void 0;function qf(y){if(typeof y=="string")return y;if(ye(y))return Eo(y,qf)+"";if(iA(y))return Im?Im.call(y):"";var S=y+"";return S=="0"&&1/y==-oA?"-0":S}function sA(y,S,_){var N=-1,H=y.length;S<0&&(S=-S>H?0:H+S),_=_>H?H:_,_<0&&(_+=H),H=S>_?0:_-S>>>0,S>>>=0;for(var $=Array(H);++N<H;)$[N]=y[N+S];return $}function lA(y,S,_){var N=y.length;return _=_===void 0?N:_,!S&&_>=N?y:sA(y,S,_)}function Xf(y,S){for(var _=y.length;_--&&Il(S,y[_],0)>-1;);return _}function aA(y,S){for(var _=-1,N=y.length;++_<N&&Il(S,y[_],0)>-1;);return _}function cA(y){return y.split("")}var uA="\\ud800-\\udfff",fA="\\u0300-\\u036f",dA="\\ufe20-\\ufe2f",he="\\u20d0-\\u20ff",ae=fA+dA+he,hA="\\ufe0e\\ufe0f",mA="\\u200d",gA=RegExp("["+mA+uA+ae+hA+"]");function pA(y){return gA.test(y)}var Dm="\\ud800-\\udfff",CA="\\u0300-\\u036f",_m="\\ufe20-\\ufe2f",EA="\\u20d0-\\u20ff",Je=CA+_m+EA,Qf="\\ufe0e\\ufe0f",xo="["+Dm+"]",wc="["+Je+"]",Dl="\\ud83c[\\udffb-\\udfff]",Vn="(?:"+wc+"|"+Dl+")",Yf="[^"+Dm+"]",Jf="(?:\\ud83c[\\udde6-\\uddff]){2}",Zf="[\\ud800-\\udbff][\\udc00-\\udfff]",Mm="\\u200d",td=Vn+"?",ed="["+Qf+"]?",wn="(?:"+Mm+"(?:"+[Yf,Jf,Zf].join("|")+")"+ed+td+")*",xA=ed+td+wn,$n="(?:"+[Yf+wc+"?",wc,Jf,Zf,xo].join("|")+")",AA=RegExp(Dl+"(?="+Dl+")|"+$n+xA,"g");function Um(y){return y.match(AA)||[]}function ti(y){return pA(y)?Um(y):cA(y)}function Sc(y){return y==null?"":qf(y)}var nd=/^\s+|\s+$/g;function Ce(y,S,_){if(y=Sc(y),y&&(_||S===void 0))return y.replace(nd,"");if(!y||!(S=qf(S)))return y;var N=ti(y),H=ti(S),$=aA(N,H),X=Xf(N,H)+1;return lA(N,$,X).join("")}var Oi=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,rd=/,/,bA=/(=.+)?(\s*)$/,id=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;function vA(y){return y=y.toString().replace(id,""),y=y.match(Oi)[2].replace(" ",""),y=y?y.split(rd):[],y=y.map(function(S){return Ce(S.replace(bA,""))}),y}function Om(y,S){var _={};bs(y,function(N,H){var $,X=M(N),J=!X&&N.length===1||X&&N.length===0;if(ye(N))$=N.slice(0,-1),N=N[N.length-1],_[H]=$.concat($.length>0?ct:N);else if(J)_[H]=N;else{if($=vA(N),N.length===0&&!X&&$.length===0)throw new Error("autoInject task functions require explicit parameters.");X||$.pop(),_[H]=$.concat(ct)}function ct(Ct,ut){var At=Eo($,function(Jt){return Ct[Jt]});At.push(ut),U(N).apply(null,At)}}),Rc(_,S)}function ir(){this.head=this.tail=null,this.length=0}function od(y,S){y.length=1,y.head=y.tail=S}ir.prototype.removeLink=function(y){return y.prev?y.prev.next=y.next:this.head=y.next,y.next?y.next.prev=y.prev:this.tail=y.prev,y.prev=y.next=null,this.length-=1,y},ir.prototype.empty=function(){for(;this.head;)this.shift();return this},ir.prototype.insertAfter=function(y,S){S.prev=y,S.next=y.next,y.next?y.next.prev=S:this.tail=S,y.next=S,this.length+=1},ir.prototype.insertBefore=function(y,S){S.prev=y.prev,S.next=y,y.prev?y.prev.next=S:this.head=S,y.prev=S,this.length+=1},ir.prototype.unshift=function(y){this.head?this.insertBefore(this.head,y):od(this,y)},ir.prototype.push=function(y){this.tail?this.insertAfter(this.tail,y):od(this,y)},ir.prototype.shift=function(){return this.head&&this.removeLink(this.head)},ir.prototype.pop=function(){return this.tail&&this.removeLink(this.tail)},ir.prototype.toArray=function(){for(var y=Array(this.length),S=this.head,_=0;_<this.length;_++)y[_]=S.data,S=S.next;return y},ir.prototype.remove=function(y){for(var S=this.head;S;){var _=S.next;y(S)&&this.removeLink(S),S=_}return this};function _l(y,S,_){if(S==null)S=1;else if(S===0)throw new Error("Concurrency must not be zero");var N=U(y),H=0,$=[],X=!1;function J(At,Jt,Oe){if(Oe!=null&&typeof Oe!="function")throw new Error("task callback must be a function");if(ut.started=!0,ye(At)||(At=[At]),At.length===0&&ut.idle())return E(function(){ut.drain()});for(var ln=0,Hn=At.length;ln<Hn;ln++){var Br={data:At[ln],callback:Oe||Ht};Jt?ut._tasks.unshift(Br):ut._tasks.push(Br)}X||(X=!0,E(function(){X=!1,ut.process()}))}function ct(At){return function(Jt){H-=1;for(var Oe=0,ln=At.length;Oe<ln;Oe++){var Hn=At[Oe],Br=Il($,Hn,0);Br===0?$.shift():Br>0&&$.splice(Br,1),Hn.callback.apply(Hn,arguments),Jt!=null&&ut.error(Jt,Hn.data)}H<=ut.concurrency-ut.buffer&&ut.unsaturated(),ut.idle()&&ut.drain(),ut.process()}}var Ct=!1,ut={_tasks:new ir,concurrency:S,payload:_,saturated:Ht,unsaturated:Ht,buffer:S/4,empty:Ht,drain:Ht,error:Ht,started:!1,paused:!1,push:function(At,Jt){J(At,!1,Jt)},kill:function(){ut.drain=Ht,ut._tasks.empty()},unshift:function(At,Jt){J(At,!0,Jt)},remove:function(At){ut._tasks.remove(At)},process:function(){if(!Ct){for(Ct=!0;!ut.paused&&H<ut.concurrency&&ut._tasks.length;){var At=[],Jt=[],Oe=ut._tasks.length;ut.payload&&(Oe=Math.min(Oe,ut.payload));for(var ln=0;ln<Oe;ln++){var Hn=ut._tasks.shift();At.push(Hn),$.push(Hn),Jt.push(Hn.data)}H+=1,ut._tasks.length===0&&ut.empty(),H===ut.concurrency&&ut.saturated();var Br=vr(ct(At));N(Jt,Br)}Ct=!1}},length:function(){return ut._tasks.length},running:function(){return H},workersList:function(){return $},idle:function(){return ut._tasks.length+H===0},pause:function(){ut.paused=!0},resume:function(){ut.paused!==!1&&(ut.paused=!1,E(ut.process))}};return ut}function Ao(y,S){return _l(y,1,S)}var vs=je(Mi,1);function ei(y,S,_,N){N=_i(N||Ht);var H=U(_);vs(y,function($,X,J){H(S,$,function(ct,Ct){S=Ct,J(ct)})},function($){N($,S)})}function Lc(){var y=Eo(arguments,U);return function(){var S=r(arguments),_=this,N=S[S.length-1];typeof N=="function"?S.pop():N=Ht,ei(y,S,function(H,$,X){$.apply(_,H.concat(function(J){var ct=r(arguments,1);X(J,ct)}))},function(H,$){N.apply(_,[H].concat($))})}}var Ic=function(){return Lc.apply(null,r(arguments).reverse())},sd=Array.prototype.concat,Ml=function(y,S,_,N){N=N||Ht;var H=U(_);Ui(y,S,function($,X){H($,function(J){return J?X(J):X(null,r(arguments,1))})},function($,X){for(var J=[],ct=0;ct<X.length;ct++)X[ct]&&(J=sd.apply(J,X[ct]));return N($,J)})},Nm=je(Ml,1/0),Dc=je(Ml,1),_c=function(){var y=r(arguments),S=[null].concat(y);return function(){var _=arguments[arguments.length-1];return _.apply(this,S)}};function Ul(y){return y}function bo(y,S){return function(_,N,H,$){$=$||Ht;var X=!1,J;_(N,function(ct,Ct,ut){H(ct,function(At,Jt){At?ut(At):y(Jt)&&!J?(X=!0,J=S(!0,ct),ut(null,po)):ut()})},function(ct){ct?$(ct):$(null,X?J:S(!1))})}}function pn(y,S){return S}var Bs=Zr(bo(Ul,pn)),ni=Co(bo(Ul,pn)),Ol=je(ni,1);function ld(y){return function(S){var _=r(arguments,1);_.push(function(N){var H=r(arguments,1);typeof console=="object"&&(N?console.error&&console.error(N):console[y]&&xs(H,function($){console[y]($)}))}),U(S).apply(null,_)}}var Pm=ld("dir");function Fm(y,S,_){_=vr(_||Ht);var N=U(y),H=U(S);function $(J){if(J)return _(J);var ct=r(arguments,1);ct.push(X),H.apply(this,ct)}function X(J,ct){if(J)return _(J);if(!ct)return _(null);N($)}X(null,!0)}function ad(y,S,_){_=vr(_||Ht);var N=U(y),H=function($){if($)return _($);var X=r(arguments,1);if(S.apply(this,X))return N(H);_.apply(null,[null].concat(X))};N(H)}function Km(y,S,_){ad(y,function(){return!S.apply(this,arguments)},_)}function Vm(y,S,_){_=vr(_||Ht);var N=U(S),H=U(y);function $(J){if(J)return _(J);H(X)}function X(J,ct){if(J)return _(J);if(!ct)return _(null);N($)}H(X)}function vo(y){return function(S,_,N){return y(S,N)}}function Mc(y,S,_){Jr(y,vo(U(S)),_)}function Nl(y,S,_,N){Ll(S)(y,vo(U(_)),N)}var Bo=je(Nl,1);function Uc(y){return M(y)?y:o(function(S,_){var N=!0;S.push(function(){var H=arguments;N?E(function(){_.apply(null,H)}):_.apply(null,H)}),y.apply(this,S),N=!1})}function or(y){return!y}var To=Zr(bo(or,or)),Pl=Co(bo(or,or)),Oc=je(Pl,1);function $m(y){return function(S){return S==null?void 0:S[y]}}function Ts(y,S,_,N){var H=new Array(S.length);y(S,function($,X,J){_($,function(ct,Ct){H[X]=!!Ct,J(ct)})},function($){if($)return N($);for(var X=[],J=0;J<S.length;J++)H[J]&&X.push(S[J]);N(null,X)})}function sr(y,S,_,N){var H=[];y(S,function($,X,J){_($,function(ct,Ct){ct?J(ct):(Ct&&H.push({index:X,value:$}),J())})},function($){$?N($):N(null,Eo(H.sort(function(X,J){return X.index-J.index}),$m("value")))})}function Nc(y,S,_,N){var H=vl(S)?Ts:sr;H(y,S,U(_),N||Ht)}var Pc=Zr(Nc),Fl=Co(Nc),Fc=je(Fl,1);function Hm(y,S){var _=vr(S||Ht),N=U(Uc(y));function H($){if($)return _($);N(H)}H()}var Kc=function(y,S,_,N){N=N||Ht;var H=U(_);Ui(y,S,function($,X){H($,function(J,ct){return J?X(J):X(null,{key:ct,val:$})})},function($,X){for(var J={},ct=Object.prototype.hasOwnProperty,Ct=0;Ct<X.length;Ct++)if(X[Ct]){var ut=X[Ct].key,At=X[Ct].val;ct.call(J,ut)?J[ut].push(At):J[ut]=[At]}return N($,J)})},yo=je(Kc,1/0),K=je(Kc,1),q=ld("log");function j(y,S,_,N){N=_i(N||Ht);var H={},$=U(_);Mi(y,S,function(X,J,ct){$(X,J,function(Ct,ut){if(Ct)return ct(Ct);H[J]=ut,ct()})},function(X){N(X,H)})}var mt=je(j,1/0),wt=je(j,1);function Gt(y,S){return S in y}function Ie(y,S){var _=Object.create(null),N=Object.create(null);S=S||Ul;var H=U(y),$=o(function(J,ct){var Ct=S.apply(null,J);Gt(_,Ct)?E(function(){ct.apply(null,_[Ct])}):Gt(N,Ct)?N[Ct].push(ct):(N[Ct]=[ct],H.apply(null,J.concat(function(){var ut=r(arguments);_[Ct]=ut;var At=N[Ct];delete N[Ct];for(var Jt=0,Oe=At.length;Jt<Oe;Jt++)At[Jt].apply(null,ut)})))});return $.memo=_,$.unmemoized=y,$}var Qt;c?Qt=process.nextTick:l?Qt=setImmediate:Qt=d;var Vc=h(Qt);function cd(y,S,_){_=_||Ht;var N=vl(S)?[]:{};y(S,function(H,$,X){U(H)(function(J,ct){arguments.length>2&&(ct=r(arguments,1)),N[$]=ct,X(J)})},function(H){_(H,N)})}function Sn(y,S){cd(Jr,y,S)}function Kl(y,S,_){cd(Ll(S),y,_)}var ud=function(y,S){var _=U(y);return _l(function(N,H){_(N[0],H)},S,1)},ko=function(y,S){var _=ud(y,S);return _.push=function(N,H,$){if($==null&&($=Ht),typeof $!="function")throw new Error("task callback must be a function");if(_.started=!0,ye(N)||(N=[N]),N.length===0)return E(function(){_.drain()});H=H||0;for(var X=_._tasks.head;X&&H>=X.priority;)X=X.next;for(var J=0,ct=N.length;J<ct;J++){var Ct={data:N[J],priority:H,callback:$};X?_._tasks.insertBefore(X,Ct):_._tasks.push(Ct)}E(_.process)},delete _.unshift,_};function Vl(y,S){if(S=_i(S||Ht),!ye(y))return S(new TypeError("First argument to race must be an array of functions"));if(!y.length)return S();for(var _=0,N=y.length;_<N;_++)U(y[_])(S)}function Ro(y,S,_,N){var H=r(y).reverse();ei(H,S,_,N)}function Wt(y){var S=U(y);return o(function(N,H){return N.push(function(X,J){if(X)H(null,{error:X});else{var ct;arguments.length<=2?ct=J:ct=r(arguments,1),H(null,{value:ct})}}),S.apply(this,N)})}function jm(y){var S;return ye(y)?S=Eo(y,Wt):(S={},bs(y,function(_,N){S[N]=Wt.call(this,_)})),S}function fd(y,S,_,N){Nc(y,S,function(H,$){_(H,function(X,J){$(X,!J)})},N)}var $l=Zr(fd),dd=Co(fd),zm=je(dd,1);function Gm(y){return function(){return y}}function wo(y,S,_){var N=5,H=0,$={times:N,intervalFunc:Gm(H)};function X(ut,At){if(typeof At=="object")ut.times=+At.times||N,ut.intervalFunc=typeof At.interval=="function"?At.interval:Gm(+At.interval||H),ut.errorFilter=At.errorFilter;else if(typeof At=="number"||typeof At=="string")ut.times=+At||N;else throw new Error("Invalid arguments for async.retry")}if(arguments.length<3&&typeof y=="function"?(_=S||Ht,S=y):(X($,y),_=_||Ht),typeof S!="function")throw new Error("Invalid arguments for async.retry");var J=U(S),ct=1;function Ct(){J(function(ut){ut&&ct++<$.times&&(typeof $.errorFilter!="function"||$.errorFilter(ut))?setTimeout(Ct,$.intervalFunc(ct)):_.apply(null,arguments)})}Ct()}var ri=function(y,S){S||(S=y,y=null);var _=U(S);return o(function(N,H){function $(X){_.apply(null,N.concat(X))}y?wo(y,$,H):wo($,H)})};function Hl(y,S){cd(vs,y,S)}var jl=Zr(bo(Boolean,Ul)),Ni=Co(bo(Boolean,Ul)),zl=je(Ni,1);function hd(y,S,_){var N=U(S);kc(y,function($,X){N($,function(J,ct){if(J)return X(J);X(null,{value:$,criteria:ct})})},function($,X){if($)return _($);_(null,Eo(X.sort(H),$m("value")))});function H($,X){var J=$.criteria,ct=X.criteria;return J<ct?-1:J>ct?1:0}}function Gl(y,S,_){var N=U(y);return o(function(H,$){var X=!1,J;function ct(){var Ct=y.name||"anonymous",ut=new Error('Callback function "'+Ct+'" timed out.');ut.code="ETIMEDOUT",_&&(ut.info=_),X=!0,$(ut)}H.push(function(){X||($.apply(null,arguments),clearTimeout(J))}),J=setTimeout(ct,S),N.apply(null,H)})}var Wm=Math.ceil,Wl=Math.max;function So(y,S,_,N){for(var H=-1,$=Wl(Wm((S-y)/(_||1)),0),X=Array($);$--;)X[N?$:++H]=y,y+=_;return X}function Lo(y,S,_,N){var H=U(_);Ui(So(0,y,1),S,H,N)}var qm=je(Lo,1/0),Xm=je(Lo,1);function Qm(y,S,_,N){arguments.length<=3&&(N=_,_=S,S=ye(y)?[]:{}),N=_i(N||Ht);var H=U(_);Jr(y,function($,X,J){H(S,$,X,J)},function($){N($,S)})}function ql(y,S){var _=null,N;S=S||Ht,Bo(y,function(H,$){U(H)(function(X,J){arguments.length>2?N=r(arguments,1):N=J,_=X,$(!X)})},function(){S(_,N)})}function Xl(y){return function(){return(y.unmemoized||y).apply(null,arguments)}}function Ql(y,S,_){_=vr(_||Ht);var N=U(S);if(!y())return _(null);var H=function($){if($)return _($);if(y())return N(H);var X=r(arguments,1);_.apply(null,[null].concat(X))};N(H)}function Ym(y,S,_){Ql(function(){return!y.apply(this,arguments)},S,_)}var md=function(y,S){if(S=_i(S||Ht),!ye(y))return S(new Error("First argument to waterfall must be an array of functions"));if(!y.length)return S();var _=0;function N($){var X=U(y[_++]);$.push(vr(H)),X.apply(null,$)}function H($){if($||_===y.length)return S.apply(null,arguments);N(r(arguments,1))}N([])},BA={apply:i,applyEach:Hf,applyEachSeries:zf,asyncify:A,auto:Rc,autoInject:Om,cargo:Ao,compose:Ic,concat:Nm,concatLimit:Ml,concatSeries:Dc,constant:_c,detect:Bs,detectLimit:ni,detectSeries:Ol,dir:Pm,doDuring:Fm,doUntil:Km,doWhilst:ad,during:Vm,each:Mc,eachLimit:Nl,eachOf:Jr,eachOfLimit:Mi,eachOfSeries:vs,eachSeries:Bo,ensureAsync:Uc,every:To,everyLimit:Pl,everySeries:Oc,filter:Pc,filterLimit:Fl,filterSeries:Fc,forever:Hm,groupBy:yo,groupByLimit:Kc,groupBySeries:K,log:q,map:kc,mapLimit:Ui,mapSeries:jf,mapValues:mt,mapValuesLimit:j,mapValuesSeries:wt,memoize:Ie,nextTick:Vc,parallel:Sn,parallelLimit:Kl,priorityQueue:ko,queue:ud,race:Vl,reduce:ei,reduceRight:Ro,reflect:Wt,reflectAll:jm,reject:$l,rejectLimit:dd,rejectSeries:zm,retry:wo,retryable:ri,seq:Lc,series:Hl,setImmediate:E,some:jl,someLimit:Ni,someSeries:zl,sortBy:hd,timeout:Gl,times:qm,timesLimit:Lo,timesSeries:Xm,transform:Qm,tryEach:ql,unmemoize:Xl,until:Ym,waterfall:md,whilst:Ql,all:To,allLimit:Pl,allSeries:Oc,any:jl,anyLimit:Ni,anySeries:zl,find:Bs,findLimit:ni,findSeries:Ol,forEach:Mc,forEachSeries:Bo,forEachLimit:Nl,forEachOf:Jr,forEachOfSeries:vs,forEachOfLimit:Mi,inject:ei,foldl:ei,foldr:Ro,select:Pc,selectLimit:Fl,selectSeries:Fc,wrapSync:A};e.default=BA,e.apply=i,e.applyEach=Hf,e.applyEachSeries=zf,e.asyncify=A,e.auto=Rc,e.autoInject=Om,e.cargo=Ao,e.compose=Ic,e.concat=Nm,e.concatLimit=Ml,e.concatSeries=Dc,e.constant=_c,e.detect=Bs,e.detectLimit=ni,e.detectSeries=Ol,e.dir=Pm,e.doDuring=Fm,e.doUntil=Km,e.doWhilst=ad,e.during=Vm,e.each=Mc,e.eachLimit=Nl,e.eachOf=Jr,e.eachOfLimit=Mi,e.eachOfSeries=vs,e.eachSeries=Bo,e.ensureAsync=Uc,e.every=To,e.everyLimit=Pl,e.everySeries=Oc,e.filter=Pc,e.filterLimit=Fl,e.filterSeries=Fc,e.forever=Hm,e.groupBy=yo,e.groupByLimit=Kc,e.groupBySeries=K,e.log=q,e.map=kc,e.mapLimit=Ui,e.mapSeries=jf,e.mapValues=mt,e.mapValuesLimit=j,e.mapValuesSeries=wt,e.memoize=Ie,e.nextTick=Vc,e.parallel=Sn,e.parallelLimit=Kl,e.priorityQueue=ko,e.queue=ud,e.race=Vl,e.reduce=ei,e.reduceRight=Ro,e.reflect=Wt,e.reflectAll=jm,e.reject=$l,e.rejectLimit=dd,e.rejectSeries=zm,e.retry=wo,e.retryable=ri,e.seq=Lc,e.series=Hl,e.setImmediate=E,e.some=jl,e.someLimit=Ni,e.someSeries=zl,e.sortBy=hd,e.timeout=Gl,e.times=qm,e.timesLimit=Lo,e.timesSeries=Xm,e.transform=Qm,e.tryEach=ql,e.unmemoize=Xl,e.until=Ym,e.waterfall=md,e.whilst=Ql,e.all=To,e.allLimit=Pl,e.allSeries=Oc,e.any=jl,e.anyLimit=Ni,e.anySeries=zl,e.find=Bs,e.findLimit=ni,e.findSeries=Ol,e.forEach=Mc,e.forEachSeries=Bo,e.forEachLimit=Nl,e.forEachOf=Jr,e.forEachOfSeries=vs,e.forEachOfLimit=Mi,e.inject=ei,e.foldl=ei,e.foldr=Ro,e.select=Pc,e.selectLimit=Fl,e.selectSeries=Fc,e.wrapSync=A,Object.defineProperty(e,"__esModule",{value:!0})})})(wp,wp.exports);var F2={exports:{}},Sp=F2.exports=function(n,t){if(t||(t=16),n===void 0&&(n=128),n<=0)return"0";for(var e=Math.log(Math.pow(2,n))/Math.log(t),r=2;e===1/0;r*=2)e=Math.log(Math.pow(2,n/r))/Math.log(t)*r;for(var i=e-Math.floor(e),o="",r=0;r<Math.floor(e);r++){var s=Math.floor(Math.random()*t).toString(t);o=s+o}if(i){var l=Math.pow(t,i),s=Math.floor(Math.random()*l).toString(t);o=s+o}var c=parseInt(o,t);return c!==1/0&&c>=Math.pow(2,n)?Sp(n,t):o};Sp.rack=function(n,t,e){var r=function(o){var s=0;do{if(s++>10)if(e)n+=e;else throw new Error("too many ID collisions, use more bits");var l=Sp(n,t)}while(Object.hasOwnProperty.call(i,l));return i[l]=o,l},i=r.hats={};return r.get=function(o){return r.hats[o]},r.set=function(o,s){return r.hats[o]=s,r},r.bits=n||128,r.base=t||16,r};var K2=Yo,QO=N2,YO=P2,$h=Vr,Lp=wp.exports,JO=F2.exports,V2=rl.ACTIONS,$2=Fe;function Fe(n,t){if(K2.EventEmitter.call(this),!t||typeof t!="string")throw new Error("Presence channel must be provided");this.connection=n,this.channel=t,this.wantSubscribe=!1,this.subscribed=!1,this.remotePresences={},this.localPresences={},this._remotePresenceInstances={},this._subscriptionCallbacksBySeq={},this._wantsDestroy=!1}K2.mixin(Fe),Fe.prototype.subscribe=function(n){this._sendSubscriptionAction(!0,n)},Fe.prototype.unsubscribe=function(n){this._sendSubscriptionAction(!1,n)},Fe.prototype.create=function(n){if(this._wantsDestroy)throw new Error("Presence is being destroyed");n=n||JO();var t=this._createLocalPresence(n);return this.localPresences[n]=t,t},Fe.prototype.destroy=function(n){this._wantsDestroy=!0;var t=this,e=Object.keys(t.localPresences);this.unsubscribe(function(r){if(r)return t._callbackOrEmit(r,n);var i=Object.keys(t._remotePresenceInstances);Lp.parallel([function(o){Lp.each(e,function(s,l){t.localPresences[s].destroy(l)},o)},function(o){if(!t._wantsDestroy)return o();Lp.each(i,function(s,l){t._remotePresenceInstances[s].destroy(l)},o)}],function(o){t._wantsDestroy&&delete t.connection._presences[t.channel],t._callbackOrEmit(o,n)})})},Fe.prototype._sendSubscriptionAction=function(n,t){this.wantSubscribe=!!n;var e=this.wantSubscribe?V2.presenceSubscribe:V2.presenceUnsubscribe,r=this.connection._presenceSeq++;this._subscriptionCallbacksBySeq[r]=t,this.connection.canSend&&this.connection._sendPresenceAction(e,r,this)},Fe.prototype._handleSubscribe=function(n,t){this.wantSubscribe&&(this.subscribed=!0);var e=this._subscriptionCallback(t);this._callbackOrEmit(n,e)},Fe.prototype._handleUnsubscribe=function(n,t){this.subscribed=!1;var e=this._subscriptionCallback(t);this._callbackOrEmit(n,e)},Fe.prototype._receiveUpdate=function(n,t){var e=$h.dig(this.localPresences,t.id);if(e)return e._ack(n,t.pv);if(n)return this.emit("error",n);var r=this,i=$h.digOrCreate(this._remotePresenceInstances,t.id,function(){return r._createRemotePresence(t.id)});i.receiveUpdate(t)},Fe.prototype._updateRemotePresence=function(n){this.remotePresences[n.presenceId]=n.value,n.value===null&&this._removeRemotePresence(n.presenceId),this.emit("receive",n.presenceId,n.value)},Fe.prototype._broadcastAllLocalPresence=function(n){if(n)return this.emit("error",n);for(var t in this.localPresences){var e=this.localPresences[t];e.value!==null&&e.send()}},Fe.prototype._removeRemotePresence=function(n){this._remotePresenceInstances[n].destroy(),delete this._remotePresenceInstances[n],delete this.remotePresences[n]},Fe.prototype._onConnectionStateChanged=function(){if(!!this.connection.canSend){this._resubscribe();for(var n in this.localPresences)this.localPresences[n]._sendPending()}},Fe.prototype._resubscribe=function(){var n=[];for(var t in this._subscriptionCallbacksBySeq){var e=this._subscriptionCallback(t);n.push(e)}if(!this.wantSubscribe)return this._callEachOrEmit(n);var r=this;this.subscribe(function(i){r._callEachOrEmit(n,i)})},Fe.prototype._subscriptionCallback=function(n){var t=this._subscriptionCallbacksBySeq[n];return delete this._subscriptionCallbacksBySeq[n],t},Fe.prototype._callbackOrEmit=function(n,t){if(t)return $h.nextTick(t,n);n&&this.emit("error",n)},Fe.prototype._createLocalPresence=function(n){return new QO(this,n)},Fe.prototype._createRemotePresence=function(n){return new YO(this,n)},Fe.prototype._callEachOrEmit=function(n,t){var e=$h.callEach(n,t);!e&&t&&this.emit("error",t)};var Iu=N2,H2=Nh,ZO=Vr,j2=H2.CODES,tN=Hr;function Hr(n,t){Iu.call(this,n,t),this.collection=this.presence.collection,this.id=this.presence.id,this._doc=this.connection.get(this.collection,this.id),this._isSending=!1,this._docDataVersionByPresenceVersion={},this._opHandler=this._transformAgainstOp.bind(this),this._createOrDelHandler=this._handleCreateOrDel.bind(this),this._loadHandler=this._handleLoad.bind(this),this._destroyHandler=this.destroy.bind(this),this._registerWithDoc()}Hr.prototype=Object.create(Iu.prototype),Hr.prototype.submit=function(n,t){if(!this._doc.type){if(n===null)return this._callbackOrEmit(null,t);var e={code:j2.ERR_DOC_DOES_NOT_EXIST,message:"Cannot submit presence. Document has not been created"};return this._callbackOrEmit(e,t)}this._docDataVersionByPresenceVersion[this.presenceVersion]=this._doc._dataStateVersion,Iu.prototype.submit.call(this,n,t)},Hr.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),Iu.prototype.destroy.call(this,n)},Hr.prototype._sendPending=function(){if(!this._isSending){this._isSending=!0;var n=this;this._doc.whenNothingPending(function(){n._isSending=!1,n.connection.canSend&&(n._pendingMessages.forEach(function(t){t.t=n._doc.type.uri,t.v=n._doc.version,n.connection.send(t)}),n._pendingMessages=[],n._docDataVersionByPresenceVersion={})})}},Hr.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)},Hr.prototype._transformAgainstOp=function(n,t){var e=this,r=this._doc._dataStateVersion;this._pendingMessages.forEach(function(i){var o=e._docDataVersionByPresenceVersion[i.pv];if(!(o>=r))try{i.p=e._transformPresence(i.p,n,t),e._docDataVersionByPresenceVersion[i.pv]=r}catch(l){var s=e._getCallback(i.pv);e._callbackOrEmit(l,s)}});try{this.value=this._transformPresence(this.value,n,t)}catch(i){this.emit("error",i)}},Hr.prototype._handleCreateOrDel=function(){this._pendingMessages.forEach(function(n){n.p=null}),this.value=null},Hr.prototype._handleLoad=function(){this.value=null,this._pendingMessages=[],this._docDataVersionByPresenceVersion={}},Hr.prototype._message=function(){var n=Iu.prototype._message.call(this);return n.c=this.collection,n.d=this.id,n.v=null,n.t=null,n},Hr.prototype._transformPresence=function(n,t,e){var r=this._doc.type;if(!ZO.supportsPresence(r))throw new H2(j2.ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE,"Type does not support presence: "+r.name);return r.transformPresence(n,t,e)};var z2={};(function(n){var t=wu,e=Nh,r=Vr,i=e.CODES;n.checkOp=function(l){if(l==null||typeof l!="object")return new e(i.ERR_OT_OP_BADLY_FORMED,"Op must be an object");if(l.create!=null){if(typeof l.create!="object")return new e(i.ERR_OT_OP_BADLY_FORMED,"Create data must be an object");var c=l.create.type;if(typeof c!="string")return new e(i.ERR_OT_OP_BADLY_FORMED,"Missing create type");var d=t.map[c];if(d==null||typeof d!="object")return new e(i.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type")}else if(l.del!=null){if(l.del!==!0)return new e(i.ERR_OT_OP_BADLY_FORMED,"del value must be true")}else if(!("op"in l))return new e(i.ERR_OT_OP_BADLY_FORMED,"Missing op, create, or del");if(l.src!=null&&typeof l.src!="string")return new e(i.ERR_OT_OP_BADLY_FORMED,"src must be a string");if(l.seq!=null&&typeof l.seq!="number")return new e(i.ERR_OT_OP_BADLY_FORMED,"seq must be a number");if(l.src==null&&l.seq!=null||l.src!=null&&l.seq==null)return new e(i.ERR_OT_OP_BADLY_FORMED,"Both src and seq must be set together");if(l.m!=null&&typeof l.m!="object")return new e(i.ERR_OT_OP_BADLY_FORMED,"op.m must be an object or null")},n.normalizeType=function(l){return t.map[l]&&t.map[l].uri},n.apply=function(l,c){if(typeof l!="object")return new e(i.ERR_APPLY_SNAPSHOT_NOT_PROVIDED,"Missing snapshot");if(l.v!=null&&c.v!=null&&l.v!==c.v)return new e(i.ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT,"Version mismatch");if(c.create){if(l.type)return new e(i.ERR_DOC_ALREADY_CREATED,"Document already exists");var d=c.create,h=t.map[d.type];if(!h)return new e(i.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{l.data=h.create(d.data),l.type=h.uri,l.v++}catch(E){return E}}else if(c.del)l.data=void 0,l.type=null,l.v++;else if("op"in c){var C=o(l,c.op);if(C)return C;l.v++}else l.v++};function o(l,c){if(!l.type)return new e(i.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");if(c===void 0)return new e(i.ERR_OT_OP_NOT_PROVIDED,"Missing op");var d=t.map[l.type];if(!d)return new e(i.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{l.data=d.apply(l.data,c)}catch(h){return new e(i.ERR_OT_OP_NOT_APPLIED,h.message)}}n.transform=function(l,c,d){if(c.v!=null&&c.v!==d.v)return new e(i.ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM,"Version mismatch");if(d.del){if(c.create||"op"in c)return new e(i.ERR_DOC_WAS_DELETED,"Document was deleted")}else{if(d.create&&("op"in c||c.create||c.del)||"op"in d&&c.create)return new e(i.ERR_DOC_ALREADY_CREATED,"Document was created remotely");if("op"in d&&"op"in c){if(!l)return new e(i.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");if(typeof l=="string"&&(l=t.map[l],!l))return new e(i.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{c.op=l.transform(c.op,d.op,"left")}catch(h){return h}}}c.v!=null&&c.v++},n.applyOps=function(l,c,d){d=d||{};for(var h=0;h<c.length;h++){var C=c[h];if(d._normalizeLegacyJson0Ops)try{s(l,C)}catch{return new e(i.ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED,"Cannot normalize legacy json0 op")}l.v=C.v;var E=n.apply(l,C);if(E)return E}},n.transformPresence=function(l,c,d){var h=this.checkOp(c);if(h)return h;var C=l.t;if(typeof C=="string"&&(C=t.map[C]),!C)return{code:i.ERR_DOC_TYPE_NOT_RECOGNIZED,message:"Unknown type"};if(!r.supportsPresence(C))return{code:i.ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE,message:"Type does not support presence"};if(c.create||c.del){l.p=null,l.v++;return}try{l.p=l.p===null?null:C.transformPresence(l.p,c.op,d)}catch(E){return{code:i.ERR_PRESENCE_TRANSFORM_FAILED,message:E.message||E}}l.v++};function s(l,c){if(l.type===t.defaultType.uri){var d=c.op;if(!!d){var h=l.data;d.length>1&&(h=r.clone(h));for(var C=0;C<d.length;C++){var E=d[C];typeof E.lm=="string"&&(E.lm=+E.lm);for(var A=E.p,v=h,R=0;R<A.length;R++){var L=A[R];Object.prototype.toString.call(v)=="[object Array]"?A[R]=+L:v.constructor===Object&&(A[R]=L.toString()),v=v[L]}C<d.length-1&&(h=t.defaultType.apply(h,[E]))}}}}})(z2);var Du=P2,eN=z2,nN=pr;function pr(n,t){Du.call(this,n,t),this.collection=this.presence.collection,this.id=this.presence.id,this.src=null,this.presenceVersion=null,this._doc=this.connection.get(this.collection,this.id),this._pending=null,this._opCache=null,this._pendingSetPending=!1,this._opHandler=this._handleOp.bind(this),this._createDelHandler=this._handleCreateDel.bind(this),this._loadHandler=this._handleLoad.bind(this),this._registerWithDoc()}pr.prototype=Object.create(Du.prototype),pr.prototype.receiveUpdate=function(n){this._pending&&n.pv<this._pending.pv||(this.src=n.src,this._pending=n,this._setPendingPresence())},pr.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),Du.prototype.destroy.call(this,n)},pr.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)},pr.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))}})}},pr.prototype._handleOp=function(n,t,e){var r=e===this.src;this._transformAgainstOp(n,r),this._cacheOp(n,r),this._setPendingPresence()},Du.prototype._handleCreateDel=function(){this._cacheOp(null),this._setPendingPresence()},Du.prototype._handleLoad=function(){this.value=null,this._pending=null,this._opCache=null,this.presence._updateRemotePresence(this)},pr.prototype._transformAgainstOp=function(n,t){if(!!this.value){try{this.value=this._doc.type.transformPresence(this.value,n,t)}catch(e){return this.presence.emit("error",e)}this.presence._updateRemotePresence(this)}},pr.prototype._catchUpStalePresence=function(){if(this._pending.v>=this._doc.version)return!0;if(!this._opCache)return this._startCachingOps(),this._doc.fetch(),this.presence.subscribe(),!1;for(;this._opCache[this._pending.v];){var n=this._opCache[this._pending.v],t=n.op,e=n.isOwnOp;t===null?(this._pending.p=null,this._pending.v++):eN.transformPresence(this._pending,t,e)}var r=this._pending.v>=this._doc.version;return r&&this._stopCachingOps(),r},pr.prototype._startCachingOps=function(){this._opCache=[]},pr.prototype._stopCachingOps=function(){this._opCache=null},pr.prototype._cacheOp=function(n,t){this._opCache&&(n=n?{op:n}:null,this._opCache[this._doc.version-1]={op:n,isOwnOp:t})};var G2=$2,rN=tN,iN=nN;function Ua(n,t,e){var r=Ua.channel(t,e);G2.call(this,n,r),this.collection=t,this.id=e}var oN=Ua;Ua.prototype=Object.create(G2.prototype),Ua.channel=function(n,t){return n+"."+t},Ua.prototype._createLocalPresence=function(n){return new rN(this,n)},Ua.prototype._createRemotePresence=function(n){return new iN(this,n)};var sN=lN;function lN(n,t,e,r,i){this.id=n,this.v=t,this.type=e,this.data=r,this.m=i}var aN=sN,W2=Yo,q2=_u;function _u(n,t,e,r,i){if(W2.EventEmitter.call(this),typeof i!="function")throw new Error("Callback is required for SnapshotRequest");this.requestId=t,this.connection=n,this.id=r,this.collection=e,this.callback=i,this.sent=!1}W2.mixin(_u),_u.prototype.send=function(){!this.connection.canSend||(this.connection.send(this._message()),this.sent=!0)},_u.prototype._onConnectionStateChanged=function(){this.connection.canSend?this.sent||this.send():this.sent=!1},_u.prototype._handleResponse=function(n,t){if(this.emit("ready"),n)return this.callback(n);var e=t.meta?t.meta:null,r=new aN(this.id,t.v,t.type,t.data,e);this.callback(null,r)};var X2=q2,cN=Vr,uN=rl.ACTIONS,fN=Ip;function Ip(n,t,e,r,i,o){if(X2.call(this,n,t,e,r,o),!cN.isValidVersion(i))throw new Error("Snapshot version must be a positive integer or null");this.version=i}Ip.prototype=Object.create(X2.prototype),Ip.prototype._message=function(){return{a:uN.snapshotFetch,id:this.requestId,c:this.collection,d:this.id,v:this.version}};var Q2=q2,dN=Vr,hN=rl.ACTIONS,mN=Dp;function Dp(n,t,e,r,i,o){if(Q2.call(this,n,t,e,r,o),!dN.isValidTimestamp(i))throw new Error("Snapshot timestamp must be a positive integer or null");this.timestamp=i}Dp.prototype=Object.create(Q2.prototype),Dp.prototype._message=function(){return{a:hN.snapshotFetchByTimestamp,id:this.requestId,c:this.collection,d:this.id,ts:this.timestamp}};var gN=VO,pN=GO,CN=$2,Y2=oN,EN=fN,xN=mN,J2=Yo,Oa=Nh,oe=rl.ACTIONS,Z2=wu,jr=Vr,Mu=w2,Uu=Oa.CODES;function tT(n){return n.readyState===0||n.readyState===1?"connecting":"disconnected"}var AN=kt;function kt(n){J2.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=tT(n),this.bindToSocket(n)}J2.mixin(kt),kt.prototype.bindToSocket=function(n){this.socket&&(this.socket.close(),this.socket.onmessage=null,this.socket.onopen=null,this.socket.onerror=null,this.socket.onclose=null),this.socket=n;var t=tT(n);this._setState(t),this.canSend=!1;var e=this;n.onmessage=function(r){try{var i=typeof r.data=="string"?JSON.parse(r.data):r.data}catch{Mu.warn("Failed to parse message",r);return}e.debug&&Mu.info("RECV",JSON.stringify(i));var o={data:i};if(e.emit("receive",o),!!o.data)try{e.handleMessage(o.data)}catch(s){jr.nextTick(function(){e.emit("error",s)})}},n.readyState===1&&e._initializeHandshake(),n.onopen=function(){e._setState("connecting"),e._initializeHandshake()},n.onerror=function(r){e.emit("connection error",r)},n.onclose=function(r){r==="closed"||r==="Closed"?e._setState("closed",r):r==="stopped"||r==="Stopped by server"?e._setState("stopped",r):e._setState("disconnected",r)}},kt.prototype.handleMessage=function(n){var t=null;switch(n.error&&(t=eT(n.error,n),delete n.error),n.a){case oe.initLegacy:return this._handleLegacyInit(n);case oe.handshake:return this._handleHandshake(t,n);case oe.queryFetch:var e=this.queries[n.id];e&&e._handleFetch(t,n.data,n.extra);return;case oe.querySubscribe:var e=this.queries[n.id];e&&e._handleSubscribe(t,n.data,n.extra);return;case oe.queryUnsubscribe:return;case oe.queryUpdate:var e=this.queries[n.id];if(!e)return;if(t)return e._handleError(t);n.diff&&e._handleDiff(n.diff),n.hasOwnProperty("extra")&&e._handleExtra(n.extra);return;case oe.bulkFetch:return this._handleBulkMessage(t,n,"_handleFetch");case oe.bulkSubscribe:case oe.bulkUnsubscribe:return this._handleBulkMessage(t,n,"_handleSubscribe");case oe.snapshotFetch:case oe.snapshotFetchByTimestamp:return this._handleSnapshotFetch(t,n);case oe.fetch:var r=this.getExisting(n.c,n.d);r&&r._handleFetch(t,n.data);return;case oe.subscribe:case oe.unsubscribe:var r=this.getExisting(n.c,n.d);r&&r._handleSubscribe(t,n.data);return;case oe.op:var r=this.getExisting(n.c,n.d);r&&r._handleOp(t,n);return;case oe.presence:return this._handlePresence(t,n);case oe.presenceSubscribe:return this._handlePresenceSubscribe(t,n);case oe.presenceUnsubscribe:return this._handlePresenceUnsubscribe(t,n);case oe.presenceRequest:return this._handlePresenceRequest(t,n);case oe.pingPong:return this._handlePingPong(t);default:Mu.warn("Ignoring unrecognized message",n)}};function eT(n,t){var e=new Error(n.message);return e.code=n.code,t&&(e.data=t),e}kt.prototype._handleBulkMessage=function(n,t,e){if(t.data)for(var r in t.data){var i=t.data[r],o=this.getExisting(t.c,r);o&&(n?o[e](n):i.error?o[e](eT(i.error)):o[e](null,i))}else if(Array.isArray(t.b))for(var s=0;s<t.b.length;s++){var r=t.b[s],o=this.getExisting(t.c,r);o&&o[e](n)}else if(t.b)for(var r in t.b){var o=this.getExisting(t.c,r);o&&o[e](n)}else Mu.error("Invalid bulk message",t)},kt.prototype._reset=function(){this.agent=null},kt.prototype._setState=function(n,t){if(this.state!==n){if(n==="connecting"&&this.state!=="disconnected"&&this.state!=="stopped"&&this.state!=="closed"||n==="connected"&&this.state!=="connecting"){var e=new Oa(Uu.ERR_CONNECTION_STATE_TRANSITION_INVALID,"Cannot transition directly from "+this.state+" to "+n);return this.emit("error",e)}this.state=n,this.canSend=n==="connected",(n==="disconnected"||n==="stopped"||n==="closed")&&this._reset(),this.startBulk();for(var r in this.queries){var i=this.queries[r];i._onConnectionStateChanged()}for(var o in this.collections){var s=this.collections[o];for(var r in s)s[r]._onConnectionStateChanged()}for(var l in this._presences)this._presences[l]._onConnectionStateChanged();for(var r in this._snapshotRequests){var c=this._snapshotRequests[r];c._onConnectionStateChanged()}this.endBulk(),this.emit(n,t),this.emit("state",n,t)}},kt.prototype.startBulk=function(){this.bulk||(this.bulk={})},kt.prototype.endBulk=function(){if(this.bulk)for(var n in this.bulk){var t=this.bulk[n];this._sendBulk("f",n,t.f),this._sendBulk("s",n,t.s),this._sendBulk("u",n,t.u)}this.bulk=null},kt.prototype._sendBulk=function(n,t,e){if(!!e){var r=[],i={},o=0,s;for(var l in e){var c=e[l];c==null?r.push(l):(i[l]=c,s=l,o++)}if(r.length===1){var l=r[0];this.send({a:n,c:t,d:l})}else r.length&&this.send({a:"b"+n,c:t,b:r});if(o===1){var d=i[s];this.send({a:n,c:t,d:s,v:d})}else o&&this.send({a:"b"+n,c:t,b:i})}},kt.prototype._sendActions=function(n,t,e){if(this._addDoc(t),this.bulk){var r=this.bulk[t.collection]||(this.bulk[t.collection]={}),i=r[n]||(r[n]={}),o=i.hasOwnProperty(t.id);return i[t.id]=e,o}else{var s={a:n,c:t.collection,d:t.id,v:e};this.send(s)}},kt.prototype.sendFetch=function(n){return this._sendActions(oe.fetch,n,n.version)},kt.prototype.sendSubscribe=function(n){return this._sendActions(oe.subscribe,n,n.version)},kt.prototype.sendUnsubscribe=function(n){return this._sendActions(oe.unsubscribe,n)},kt.prototype.sendOp=function(n,t){this._addDoc(n);var e={a:oe.op,c:n.collection,d:n.id,v:n.version,src:t.src,seq:t.seq,x:{}};"op"in t&&(e.op=t.op),t.create&&(e.create=t.create),t.del&&(e.del=t.del),n.submitSource&&(e.x.source=t.source),this.send(e)},kt.prototype.send=function(n){this.debug&&Mu.info("SEND",JSON.stringify(n)),this.emit("send",n),this.socket.send(JSON.stringify(n))},kt.prototype.ping=function(){if(!this.canSend)throw new Oa(Uu.ERR_CANNOT_PING_OFFLINE,"Socket must be CONNECTED to ping");var n={a:oe.pingPong};this.send(n)},kt.prototype.close=function(){this.socket.close()},kt.prototype.getExisting=function(n,t){if(this.collections[n])return this.collections[n][t]},kt.prototype.get=function(n,t){var e=this.collections[n]||(this.collections[n]={}),r=e[t];return r||(r=e[t]=new gN(this,n,t),this.emit("doc",r)),r._wantsDestroy=!1,r},kt.prototype._destroyDoc=function(n){!n._wantsDestroy||(jr.digAndRemove(this.collections,n.collection,n.id),n.emit("destroy"))},kt.prototype._addDoc=function(n){var t=this.collections[n.collection];t||(t=this.collections[n.collection]={}),t[n.id]!==n&&(t[n.id]=n)},kt.prototype._createQuery=function(n,t,e,r,i){var o=this.nextQueryId++,s=new pN(n,this,o,t,e,r,i);return this.queries[o]=s,s.send(),s},kt.prototype._destroyQuery=function(n){delete this.queries[n.id]},kt.prototype.createFetchQuery=function(n,t,e,r){return this._createQuery(oe.queryFetch,n,t,e,r)},kt.prototype.createSubscribeQuery=function(n,t,e,r){return this._createQuery(oe.querySubscribe,n,t,e,r)},kt.prototype.hasPending=function(){return!!(this._firstDoc(Hh)||this._firstQuery(Hh)||this._firstSnapshotRequest())};function Hh(n){return n.hasPending()}kt.prototype.hasWritePending=function(){return!!this._firstDoc(bN)};function bN(n){return n.hasWritePending()}kt.prototype.whenNothingPending=function(n){var t=this._firstDoc(Hh);if(t){t.once("nothing pending",this._nothingPendingRetry(n));return}var e=this._firstQuery(Hh);if(e){e.once("ready",this._nothingPendingRetry(n));return}var r=this._firstSnapshotRequest();if(r){r.once("ready",this._nothingPendingRetry(n));return}jr.nextTick(n)},kt.prototype._nothingPendingRetry=function(n){var t=this;return function(){jr.nextTick(function(){t.whenNothingPending(n)})}},kt.prototype._firstDoc=function(n){for(var t in this.collections){var e=this.collections[t];for(var r in e){var i=e[r];if(n(i))return i}}},kt.prototype._firstQuery=function(n){for(var t in this.queries){var e=this.queries[t];if(n(e))return e}},kt.prototype._firstSnapshotRequest=function(){for(var n in this._snapshotRequests)return this._snapshotRequests[n]},kt.prototype.fetchSnapshot=function(n,t,e,r){typeof e=="function"&&(r=e,e=null);var i=this.nextSnapshotRequestId++,o=new EN(this,i,n,t,e,r);this._snapshotRequests[o.requestId]=o,o.send()},kt.prototype.fetchSnapshotByTimestamp=function(n,t,e,r){typeof e=="function"&&(r=e,e=null);var i=this.nextSnapshotRequestId++,o=new xN(this,i,n,t,e,r);this._snapshotRequests[o.requestId]=o,o.send()},kt.prototype._handleSnapshotFetch=function(n,t){var e=this._snapshotRequests[t.id];!e||(delete this._snapshotRequests[t.id],e._handleResponse(n,t))},kt.prototype._handleLegacyInit=function(n){if(n.protocolMinor)return this._initializeHandshake();this._initialize(n)},kt.prototype._initializeHandshake=function(){this.send({a:oe.handshake,id:this.id})},kt.prototype._handleHandshake=function(n,t){if(n)return this.emit("error",n);this._initialize(t)},kt.prototype._handlePingPong=function(n){if(n)return this.emit("error",n);this.emit("pong")},kt.prototype._initialize=function(n){if(this.state==="connecting"){if(n.protocol!==1)return this.emit("error",new Oa(Uu.ERR_PROTOCOL_VERSION_NOT_SUPPORTED,"Unsupported protocol version: "+n.protocol));if(Z2.map[n.type]!==Z2.defaultType)return this.emit("error",new Oa(Uu.ERR_DEFAULT_TYPE_MISMATCH,n.type+" does not match the server default type"));if(typeof n.id!="string")return this.emit("error",new Oa(Uu.ERR_CLIENT_ID_BADLY_FORMED,"Client id must be a string"));this.id=n.id,this._setState("connected")}},kt.prototype.getPresence=function(n){var t=this,e=jr.digOrCreate(this._presences,n,function(){return new CN(t,n)});return e._wantsDestroy=!1,e},kt.prototype.getDocPresence=function(n,t){var e=Y2.channel(n,t),r=this,i=jr.digOrCreate(this._presences,e,function(){return new Y2(r,n,t)});return i._wantsDestroy=!1,i},kt.prototype._sendPresenceAction=function(n,t,e){this._addPresence(e);var r={a:n,ch:e.channel,seq:t};return this.send(r),r.seq},kt.prototype._addPresence=function(n){jr.digOrCreate(this._presences,n.channel,function(){return n})},kt.prototype._handlePresenceSubscribe=function(n,t){var e=jr.dig(this._presences,t.ch);e&&e._handleSubscribe(n,t.seq)},kt.prototype._handlePresenceUnsubscribe=function(n,t){var e=jr.dig(this._presences,t.ch);e&&e._handleUnsubscribe(n,t.seq)},kt.prototype._handlePresence=function(n,t){var e=jr.dig(this._presences,t.ch);e&&e._receiveUpdate(n,t)},kt.prototype._handlePresenceRequest=function(n,t){var e=jr.dig(this._presences,t.ch);e&&e._broadcastAllLocalPresence(n,t)};var nT=AN,vN=wu;const jh={err:1001,msg:"user auth error",name:"AuthError"},BN={err:1002,msg:"you don't have required permission",name:"PermissionError"},_p={err:1003,msg:"Too many user connected",name:"MaxUserError"},Ou={err:1004,msg:"document server changed, reload it",name:"RequestReloadError"},TN={err:1005,msg:"app id must be at least 2 chars, doc id must be at least 5 chars",name:"DocIdError"},yN={err:1028,msg:"upload file ext not allowed",name:"FileExtError"},il="x-live-editor-token",Na="x-live-editor-base-url",vn=I("auth-connection");function kN(n){try{n()}catch(t){vn.error(t)}}class RN{constructor(t,e){m(this,"enabled",!0);m(this,"connection");m(this,"ws");m(this,"retryCount");m(this,"events",new pb.EventEmitter);m(this,"token",null);m(this,"resourceToken",null);this.url=t,this.reauthFunc=e,this.retryCount=0}getBaseURL(){const t=new URL(this.url);return`${t.protocol==="wss:"?"https:":"http:"}//${t.host}${t.pathname}`}getBase64BaseURL(){return ci(this.getBaseURL())}async auth(t){p(vn,t.token,"no auth token");const e=`${this.getBaseURL()}/auth`,r=await window.fetch(e,{method:"GET",headers:{[il]:t.token,[Na]:this.getBase64BaseURL()},credentials:"include"});if(r.status!==200)throw new Error("http auth error");return this.enabled?(this.token=t.token,await r.json()):{read:"",user:""}}async logout(){if(!this.token)return;const t=`${this.getBaseURL()}/logout`;await window.fetch(t,{method:"GET",headers:{[Na]:ci(this.getBaseURL())}})}async init(t){const e=await this.auth(t);if(!this.enabled)return;this.resourceToken=e.read,this.ws=new X6.default(this.url,void 0,{maxReconnectionDelay:2500,minReconnectionDelay:1e3}),this.connection=Object.create(nT.prototype),p(vn,this.connection,"no this.connection"),this.ws,this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:t})};const r=this.connection.handleMessage.bind(this.connection);this.connection.handleMessage=i=>{var s;const o=i;if(this.connection&&(this.connection.lastReceiveTime=Date.now()),"err"in o||o.a==="pong")this.handleMessage(o);else{Object.prototype.hasOwnProperty.call(o,"a")&&o.a!=="init"&&o.a!=="hs"&&(this.retryCount=0);try{r(o)}catch(l){if((l==null?void 0:l.type)==="writeConflict"){this.emitWriteConflictError(l,o);return}if((s=l==null?void 0:l.message)!=null&&s.startsWith("Cannot invert subtype")){this.emitWriteConflictError(l,o);return}throw l}}},nT.apply(this.connection,[this.ws])}async handleAuthError(){if(this.reauthFunc&&this.retryCount<5){this.retryCount+=1,vn.info(`retrying re-auth attempt no. ${this.retryCount}`);try{if(this.connection){const t=await this.reauthFunc();if(await this.auth(t),!this.enabled){this.retryCount=10,setTimeout(()=>this.handleAuthError(),0);return}this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:t})}}}catch(t){vn.error(t),setTimeout(()=>this.handleAuthError(),0)}}else vn.error("auth error, cannot retry anymore"),this.emitAuthError(),this.end(!1)}emitAuthError(){const t=new Error(jh.msg);t.code=jh.err,this.events.emit("error",t)}emitRequestReloadError(){const t=new Error(Ou.msg);t.code=Ou.err,this.events.emit("requestReloadError",t)}emitWriteConflictError(t,e){t.orgMsg=e,this.events.emit("writeConflictError",t)}emitMaxUsersError(){this.events.emit("maxUsersError"),this.end(!1)}handleMessage(t){const e=t;if(e.a==="pong")return;const r=e.err;if(r===jh.err)vn.warn("auth error"),this.handleAuthError();else if(r===_p.err)vn.warn(_p.msg),this.emitMaxUsersError();else if(r===Ou.err){vn.warn(Ou.msg);try{this.emitRequestReloadError()}catch(i){vn.error(`error occurred while process reload error: ${JSON.stringify(i)}`)}finally{this.end(!1)}}else vn.error(`unknown message received: ${JSON.stringify(e)}`),this.emitAuthError()}get(t,e){return p(vn,this.connection,"no this.connection"),this.connection.get(t,e)}addEventListener(t,e){t==="error"?this.events.addListener(t,e):(p(vn,this.ws,"no this.ws"),this.ws.addEventListener(t,e))}onAuthError(t){this.events.addListener("error",t)}onWriteConflictError(t){this.events.addListener("writeConflictError",t)}onMaxUsersError(t){p(vn,this.events.listenerCount("maxUsersError")===0,"too many maxUserError listener"),this.events.addListener("maxUsersError",t)}onRequestReloadError(t){p(vn,this.events.listenerCount("requestReloadError")===0,"to many requestReloadError listener"),this.events.addListener("requestReloadError",t)}end(t){var e;this.enabled=!1,this.reauthFunc=void 0,this.events.removeAllListeners(),kN(()=>{var r;return(r=this.connection)==null?void 0:r.close()}),this.connection=void 0,(e=this.ws)==null||e.close(),this.ws=void 0,t&&this.logout()}}I("utils/file");function wN(){function n(){return new Promise(t=>{const e=new FileReader;e.onload=()=>{t(e.result)},e.readAsArrayBuffer(this)})}File.prototype.arrayBuffer=File.prototype.arrayBuffer||n,Blob.prototype.arrayBuffer=Blob.prototype.arrayBuffer||n}wN();async function SN(n){const e=n.size,r=Math.floor((e+102400-1)/102400),i=new Q6.Hash;for(let s=0;s<r;s++){const l=s*102400;let c=l+102400;c>e&&(c=e);const h=await n.slice(l,c,n.type).arrayBuffer();i.update(new Uint8Array(h))}const o=i.digest();return ci(o)}const xi=I("sharedb-doc/client"),LN=Eb.default.create();class IN{constructor(t,e,r){m(this,"connection");m(this,"auth");m(this,"doc",null);m(this,"reauthFunc");m(this,"clientId",Z());m(this,"getDoc",async()=>{const t=r=>new Promise((i,o)=>{r.fetch(s=>{s?o(s):i()})});p(xi,!this.doc,"This websocket has opened a doc."),await this.connection.init(this.auth);const e=this.connection.get(this.auth.appId,this.auth.docId);return this.doc=e,await t(e),xi.debug(e),e});this.auth=t;const i=`${e}/${this.auth.appId}/${this.auth.docId}`;vN.register(yd.type),this.connection=new RN(i,r),this.reauthFunc=r}editorServer(){const t=this.apiServer(),e=`/${this.auth.appId}/${this.auth.docId}`;return p(xi,t.endsWith(e),`invalid api server: ${t}, ${e}`),t.substr(0,t.length-e.length)}close(t){this.connection.end(t),this.doc=null}on(t,e){this.connection.addEventListener(t,r=>{(t==="error"||this.doc)&&e(r)})}onAuthError(t){this.connection.onAuthError(t)}onWriteConflictError(t){this.connection.onWriteConflictError(t)}onMaxUsersError(t){this.connection.onMaxUsersError(t)}onRequestReloadError(t){this.connection.onRequestReloadError(t)}async authOnly(){await this.connection.auth(this.auth)}getResourceToken(){return this.connection.resourceToken}hasDocContainer(){return!!this.doc}apiServer(){const t=this.connection.url;if(t.startsWith("ws://"))return`http://${t.substring(5)}`;if(t.startsWith("wss://"))return`https://${t.substring(6)}`;throw new Error(`invalid server url: ${t}`)}async getFileUrlByHash(t,e,r,i,o){try{const s=`${t}/${e}`,l=await this.request(s,{method:"post",headers:{...o},data:{name:r,size:i}});return l.data&&Array.isArray(l.data)&&l.data.length===1?l.data[0]:""}catch{return""}}async getFileUrlsByHashes(t){const r=`${this.apiServer()}/resources`;try{const i=`${r}/hash`,o=await this.request(i,{method:"post",headers:{[il]:this.connection.token},data:{resources:t}});return o.data&&Array.isArray(o.data)?o.data:[]}catch{return[]}}async uploadFile(t,e,r,i,o){let s=e.size;if(s===0)throw new Error("file is empty");s+=500;const l=A=>{xi.info(`on progress: ${A.loaded}`);let v=A.loaded*100/s;v>100&&(v=100),i(v)},c=await SN(e),d=await this.getFileUrlByHash(t,c,e.name,e.size,r);if(d)return i(-1),d;let h=t;o!=null&&o.thumbnail&&(h+="/thumbnail");const C=new FormData;C.append("file-size",`${e.size}`),C.append("file-hash",c),C.append("file",e,e.name);const E=await this.request(h,{method:"post",data:C,withCredentials:!0,headers:{...r},onUploadProgress:l});return xi.info(E),i(100),Array.isArray(E.data)?E.data[0]:E.data}async uploadResource(t,e=()=>{},r){const o=`${this.apiServer()}/resources`;p(xi,this.connection.token,"no connection token");const s=await this.uploadFile(o,t,{[il]:this.connection.token},e,r);return p(xi,s,"no result"),s}async request(t,e){var o,s;let r=this.connection.token,i;for(let l=0;l<2;l++){const c=e||{};c.url=t,c.headers||(c.headers={}),p(xi,r,"no token"),c.headers={...c.headers,[il]:r,[Na]:this.connection.getBase64BaseURL()};try{return await LN(t,c)}catch(d){if(i=d,((o=d==null?void 0:d.response)==null?void 0:o.status)===403&&this.reauthFunc){const h=await this.reauthFunc();if(await this.connection.auth(h),!h.token)throw d;r=h.token;continue}throw(s=d.response)!=null&&s.data&&(d.responseData=d.response.data),d}}throw p(xi,i,"no error"),i}async getVersions(){const e=`${this.apiServer()}/versions?withExtra=true`,i=(await this.request(e)).data.versions;return i.forEach(o=>{o.extra&&(o.extra=JSON.parse(o.extra))}),i}async getVersion(t){const r=`${this.apiServer()}/versions/${t}`,i=await this.request(r);return JSON.parse(i.data.data)}async getLatestVersion(){const e=`${this.apiServer()}/versions/latest`,r=await this.request(e);return JSON.parse(r.data.data)}async getVersionOps(t,e){let i=`${this.apiServer()}/versions/before/${t}?withOp=true`;e!==void 0&&e!==0&&(i+=`&from=${e}`);const o=await this.request(i),s=o.data.ops,l=xb.default(s,h=>!!h.create);let c=null;l!==-1&&(c=s[l],s.splice(0,l+1));let d;return c?(p(xi,c.create,"no createDoc.create"),d=c.create.data):d=JSON.parse(o.data.data),d.blocks||(d.blocks=[]),{doc:d,ops:o.data.ops}}async updateVersionExtra(t,e,r){const o=`${this.apiServer()}/versions/${t}/tags/${e}`;await this.request(o,{method:"post",data:{extra:JSON.stringify(r)}})}async revertVersion(t){const r=`${this.apiServer()}/versions/revert/${t}`;await this.request(r,{method:"post",data:{}})}async createVersion(t,e){const i=`${this.apiServer()}/versions`;return(await this.request(i,{method:"post",data:{publish:e,tag:t}})).data}async recognizeLink(t){const r=`${this.apiServer()}/resources/external/${ci(t)}`;return(await this.request(r)).data}buildResourceUrl(t,e){if(!t)return"";if(t.startsWith("https:")||t.startsWith("http:")||t.startsWith("file:")||t.startsWith("data:")||t.startsWith("blob:"))return t;let i=`${this.apiServer()}/resources/${encodeURIComponent(t)}`;const o=[];if(e!=null&&e.withToken&&o.push(`token=${this.getResourceToken()}`),e!=null&&e.downloadFileName&&o.push(`&fileName=${encodeURIComponent(e.downloadFileName)}`),o.length>0){const s=o.join("&");i+=`?${s}`}return i}}function DN(){return{blocks:[{id:Z(),type:"text",text:[]}],comments:{},meta:{}}}const Mp=I("block-ids");class _N{constructor(){m(this,"ids",new Map)}onInsertBlock(t){const e=Array.from(this.ids.keys()).sort((i,o)=>o-i);for(let i=0;i<e.length;i++){const o=e[i];if(o>=t){const s=this.ids.get(o);p(Mp,s!==void 0,"old id is not exists"),this.ids.delete(o),this.ids.set(o+1,s)}}const r=Z();this.ids.set(t,r)}onDeleteBlock(t){this.ids.delete(t);const e=Array.from(this.ids.keys()).sort((r,i)=>r-i);for(let r=0;r<e.length;r++){const i=e[r];if(i>t){const o=this.ids.get(i);p(Mp,o!==void 0,"old id is not exists"),this.ids.delete(i),this.ids.set(i-1,o)}}}getId(t){let e=this.ids.get(t);return e||(e=Z(),this.ids.set(t,e)),e}getById(t){return Array.from(this.ids.entries()).find(([,e])=>e===t)}}class MN{constructor(){m(this,"ids",new Map)}getContainerIds(t){let e=this.ids.get(t);return e||(e=new _N,this.ids.set(t,e)),e}onInsertBlock(t,e){this.getContainerIds(t).onInsertBlock(e)}onDeleteBlock(t,e){this.getContainerIds(t).onDeleteBlock(e)}getBlockId(t,e){return this.getContainerIds(t).getId(e)}getBlockIndexById(t){const e=Array.from(this.ids.entries());for(let r=0;r<e.length;r++){const i=e[r],o=i[1].getById(t);if(o)return{containerId:i[0],blockIndex:o[0]}}return p(Mp,!1,"fault error: failed to get block index"),{containerId:"error",blockIndex:-1}}}class rT{constructor(t=new Set,e=new Map){this.deletedKeys=t,this.insertedValues=e}insert(t,e){this.insertedValues.set(t,e)}delete(t){this.deletedKeys.add(t)}toDocBlockDelta(){const t={};return this.insertedValues.forEach((e,r)=>{t[r]=e}),{insert:t,delete:Array.from(this.deletedKeys)}}}const Up=I("op-parse-handler");class UN{constructor(t,e){m(this,"actions",[]);this.outerHandler=t,this.local=e}pushActions(t){if(!t.containerId){this.actions.push(t);return}const r={...t,containerId:(i=>i==="blocks"?"root":i)(t.containerId)};this.actions.push(r)}onDeleteBlock(t,e){this.pushActions({type:"deleteBlock",containerId:t,blockIndex:e})}onInsertBlock(t,e,r){this.pushActions({type:"insertBlock",containerId:t,blockIndex:e,data:r})}onDeleteBlockData(t,e,r){this.pushActions({type:"deleteBlockData",containerId:t,blockIndex:e,key:r})}onInsertBlockData(t,e,r,i){this.pushActions({type:"insertBlockData",containerId:t,blockIndex:e,key:r,value:i})}onUpdateBlockText(t,e,r){this.pushActions({type:"updateBlockText",containerId:t,blockIndex:e,richTextData:r})}onDeleteContainer(t){this.pushActions({type:"deleteContainer",containerId:t})}onCreateContainer(t,e){this.pushActions({type:"createContainer",containerId:t,data:e})}onDeleteComment(t){this.pushActions({type:"deleteComment",commentId:t})}onCreateComment(t){this.pushActions({type:"createComment",commentId:t})}onUpdateComment(t){this.pushActions({type:"updateComment",commentId:t})}end(){const t=this.actions,e=new Set,r=new Map,i=new MN,o=t.filter(s=>s.type==="deleteBlock"||s.type==="deleteBlockData");for(const s of o)if(s.type==="deleteBlock"){const l=s,c=i.getBlockId(l.containerId,l.blockIndex);i.onDeleteBlock(l.containerId,l.blockIndex);const d=r.get(c);d&&(Up.debug(`ignore update object data before delete block: ${JSON.stringify(d)}`),r.delete(c));const h=`${l.containerId}-${l.blockIndex}`;e.add(h),this.outerHandler.onDeleteBlock(l.containerId,l.blockIndex,this.local)}else if(s.type==="deleteBlockData"){const l=s,c=`${l.containerId}-${l.blockIndex}`;if(e.has(c)){Up.warn("delete block data after delete block, ignore it");continue}const d=i.getBlockId(l.containerId,l.blockIndex);let h=r.get(d);h||(h=new rT,r.set(d,h)),h.delete(l.key)}else p(Up,!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,c=i.getBlockId(l.containerId,l.blockIndex);let d=r.get(c);d||(d=new rT,r.set(c,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(r.entries()).forEach(([s,l])=>{const{containerId:c,blockIndex:d}=i.getBlockIndexById(s);this.outerHandler.onUpdateBlockData(c,d,l.toDocBlockDelta(),this.local)})}}const Ke=I("op-parser");class iT{}class Op{constructor(t){m(this,"key");this.key=t}}function ON(n,t,e){const r=t.concat(),i=r[0];if(typeof i!="number"||(r.shift(),r.length===1))return!1;const o=r[0];if(typeof o!="object"||!o.i||Object.keys(o).length!==1)return!1;for(let l=1;l<r.length;l++){const c=r[l];if(!Array.isArray(c)||c.length!==2||typeof c[0]!="string")return!1;const h=c[1];if(typeof h!="object"||h.i===void 0||Object.keys(h).length!==1)return!1}const s=o.i;p(Ke,s.id,"block id is required"),p(Ke,s.type,"block type is required");for(let l=1;l<r.length;l++){const c=r[l],d=c[0],h=c[1];s[d]=h.i}return e.onInsertBlock(n,i,s),!0}function Np(n,t,e,r){if(e==="upsert"&&ON(n,t,r))return;p(Ke,Array.isArray(t),`invalid block op: ${n}, ${JSON.stringify(t)}`);const i=t.concat(),o=i[0];i.shift();const s=[];for(;i.length>0;){const l=i[0];if(l==="text"){const c=i[1];if(p(Ke,typeof c=="object",`invalid block op: ${n}, ${JSON.stringify(t)}`),p(Ke,c.et==="rich-text",`invalid block op: ${n}, ${JSON.stringify(t)}`),i.splice(0,2),e==="upsert"){const h=c.e;r.onUpdateBlockText(n,o,h)}p(Ke,i.length===0,`invalid block ops.length !== 0, ${JSON.stringify(i)}`)}else if(Array.isArray(l)){p(Ke,l.length===2,`invalid block op: data.length !== 2, ${JSON.stringify(l)}`);const c=l[0];p(Ke,typeof c=="string",`invalid block op: key ${JSON.stringify(c)}`);const d=l[1];if(c==="text"){if(p(Ke,typeof d=="object",`invalid opData type, ${JSON.stringify(d)}`),d.i&&e==="upsert"&&r.onInsertBlockData(n,o,c,d.i),d.r&&e==="remove"&&r.onDeleteBlockData(n,o,c),d.et==="rich-text"&&e==="upsert"){const C=d.e;r.onUpdateBlockText(n,o,C)}}else e==="remove"&&d.r&&s.push(new Op(c)),e==="upsert"&&d.i&&r.onInsertBlockData(n,o,c,d.i);i.shift()}else if(typeof l=="object"){const c=l;e==="remove"&&c.r&&s.push(new iT),e==="upsert"&&c.i&&r.onInsertBlock(n,o,c.i),i.shift()}else{p(Ke,typeof l=="string","data is not string"),p(Ke,l!=="text","data !== 'text'"),p(Ke,i.length===2,`invalid block op: ops.length !== 2, ${JSON.stringify(i)}`);const c=l,d=i[1];e==="remove"&&d.r&&s.push(new Op(c)),e==="upsert"&&d.i&&r.onInsertBlockData(n,o,c,d.i),i.splice(0,2)}}s.reverse(),s.forEach(l=>{l instanceof iT?r.onDeleteBlock(n,o):l instanceof Op?r.onDeleteBlockData(n,o,l.key):p(Ke,!1,`invalid action type: ${typeof l}, ${JSON.stringify(l)}`)})}function NN(n,t,e){Ke.warn(`unsupported meta op, ${JSON.stringify(n)}`)}function PN(n,t,e){const r=n[1],i=n[2];p(Ke,r,`invalid comment op, no commentId: ${JSON.stringify(n)}`),p(Ke,i,`invalid comment op, no actions: ${JSON.stringify(n)}`),typeof i=="string"?Ke.error(`unknown comment op, ${JSON.stringify(n)}`):i.i&&i.r?t==="upsert"&&e.onUpdateComment(r):i.i?t==="upsert"&&e.onCreateComment(r):i.r?t==="remove"&&e.onDeleteComment(r):Ke.error(`unknown comment op, ${JSON.stringify(n)}`)}function Pp(n,t,e){const r=n[0];if(Array.isArray(r)){r.forEach(s=>{Pp(s,t,e)});return}const i=r;if(p(Ke,typeof i=="string",`invalid container id: ${JSON.stringify(n)}`),i==="meta"){NN(n);return}if(i==="comments"){PN(n,t,e);return}const o=i;if(Array.isArray(n[1]))t==="remove"?n.slice(1).reverse().forEach(s=>{Np(o,s,t,e)}):n.slice(1).forEach(s=>{Np(o,s,t,e)});else if(typeof n[1]=="object"){const s=n[1];s.r&&t==="remove"&&e.onDeleteContainer(o),s.i&&t==="upsert"&&e.onCreateContainer(o,s.i)}else p(Ke,typeof n[1]=="number",`invalid ops[1], not a number: ${JSON.stringify(n)}`),Np(o,n.slice(1),t,e)}function Fp(n,t,e){const r=new UN(t,e);for(let i=0;i<2;i++){const o=i===0?"remove":"upsert",s=gt.default(n),l=s[0];Array.isArray(l)?s.forEach(c=>{Pp(c,o,r)}):Pp(s,o,r)}r.end()}const FN=I("sharedb-comments");function Kp(n){const t=n.blocks;p(FN,t,"no comment blocks");const e={blocks:{root:t},meta:{},comments:{}};return Object.entries(n).forEach(([r,i])=>{Array.isArray(i)&&(e.blocks[r]=i)}),gt.default(e)}function oT(n){const{id:t,groupId:e,userId:r,displayName:i,avatarUrl:o,abstract:s,created:l,modified:c}=n;return{id:t,groupId:e,userId:r,displayName:i,avatarUrl:o,abstract:s,created:l,modified:c}}function Vp(n,t){const e=vO(t),{comments:r,meta:i,blocks:o,...s}=e,l={...n,blocks:o,...s},c=gt.default(l);return delete c.children,c}const se=I("sharedb-doc/doc-container"),sT="ot-json1";yd.type.registerSubtype(BO.type),yd.type.name=sT,yd.type.invert=null;class Nu extends sa{constructor(e,r,i=!0){super();m(this,"doc");m(this,"client");m(this,"localPresence");m(this,"remoteCaretHandler",new AO);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",e=>{this.callbacks.forEach(r=>{var i;return(i=r.onRequestReload)==null?void 0:i.call(r,e)})});m(this,"handleReset",async e=>{const r=new Error(`reset doc: ${e}`);r.code="ResetDoc",this.callbacks.forEach(i=>{var o;return(o=i.onError)==null?void 0:o.call(i,r)}),this.destroy()});m(this,"handleWriteConflictError",e=>{this.handleReset(`write conflict: ${e.message}, ${JSON.stringify(e.orgMsg)}`)});m(this,"insertObject",async(e,r,i)=>{const o=[e,r,{i}];return this.submitOp(o)});m(this,"deleteObject",async(e,r)=>{const i=[e,r,{r:!0}];return this.submitOp(i)});m(this,"replaceObject",async(e,r,i)=>{const o=[e,r,{r:!0,i}];return this.submitOp(o)});m(this,"updateObject",async(e,r,i)=>{const o=this.data()[e][r],s=[e,r];return Object.entries(i).forEach(([l,c])=>{if(!qc.default(o[l],c))if(o[l]===void 0){if(c!=null){const d={i:c};s.push([l,d])}}else if(c==null){const d={r:!0};s.push([l,d])}else{const d={r:!0,i:c};s.push([l,d])}}),Object.entries(o).forEach(([l,c])=>{if((i[l]===void 0||i[l]===null)&&c!==void 0){const d={r:!0};s.push([l,d])}}),s.length<=2?Promise.resolve():this.submitOp(s)});m(this,"broadcastMessage",async e=>{const r={type:"custom",data:e,clientId:this.client.clientId};this.localPresence&&this.localPresence.submit(r)});m(this,"data",()=>this.doc.data);m(this,"submitOp",async e=>new Promise((r,i)=>{if(this.destroyed){se.warn("submit op after destroyed");return}this.setStatus("dirty"),this.doc.submitOp(e,{},o=>{o?(se.error(`invalid op, ${o.message}, ${JSON.stringify(e)}`),i(o),se.error("Transform detected write conflict, reload editor"),this.handleReset("write conflict")):r()}),this.doc.data||(se.error("no data after submit op, may be the submitted op is invalid"),this.handleReset(`invalid op, ${JSON.stringify(e)}`))}));m(this,"createDoc",async e=>new Promise((r,i)=>{this.doc.create(e,sT,o=>{o?i(o):r()})}));m(this,"submitInsertChildContainers",async e=>{if(e.length===0)return Promise.resolve();const r=e.map(({containerId:i,blocks:o})=>[so(i),{i:o}]);return this.submitOp([r])});m(this,"submitDeleteChildContainer",async e=>{const r=[so(e),{r:!0}];return this.submitOp(r)});m(this,"submitInsertBlock",async(e,r,i)=>{const o=[so(e),r,{i}];return this.submitOp(o)});m(this,"submitDeleteBlock",async(e,r)=>{const i=[so(e),r,{r:!0}];return this.submitOp(i)});m(this,"submitUpdateBlockData",async(e,r,i)=>{if(i.delete.length===0&&Object.keys(i.insert).length===0)return Promise.resolve();const o=[so(e),r],s=new Set(i.delete);Object.entries(i.insert).forEach(([c,d])=>{if(s.has(c)){const h={r:!0,i:d};o.push([c,h])}});const l=new Set(Object.keys(i.insert));return i.delete.forEach(c=>{if(l.has(c))return;const d={r:!0};o.push([c,d])}),Object.entries(i.insert).forEach(([c,d])=>{if(s.has(c))return;const h={i:d};o.push([c,h])}),this.submitOp(o)});m(this,"submitUpdateRichText",async(e,r,i)=>{const o=[so(e),r,"text",{e:i,et:"rich-text"}];return this.submitOp(o)});m(this,"handleOp",(e,r,i)=>{if(this.destroyed){se.warn("handleOp: destroyed");return}try{Fp(e,this,!!r)}catch(o){throw se.error(o),o}});this.client=e,this.doc=r,this.doc.preventCompose=!0,this.disableLogout=i,this.registerCallback(this.remoteCaretHandler)}beginBatchUpdate(){return this.doc.preventCompose=!1,this.batching++,this.batching}endBatchUpdate(){return this.batching--,p(se,this.batching>=0,"invalid call beginBatchUpdate/endBatchUpdate"),this.batching===0&&(this.doc.preventCompose=!0),this.batching}static async load(e){try{const r=new IN(e.auth,e.serverUrl,e.reauthFunc),i=await r.getDoc(),o=new Nu(r,i,e.disableLogout);if(i.type===null){if(e.autoCreateDoc===!1){const s=new Error("doc not exists");throw s.code="DocNotExists",s}await o.createDoc(e.templateData||DN())}return await o.initPresence(),await o.subscribe(),o.initEvents(),o}catch(r){throw se.error(r),se.error(`failed to load doc: ${JSON.stringify(r)}`),r}}setStatus(e){this.status!==e&&(this.status=e,this.callbacks.forEach(r=>{var i;return(i=r.onStatusChanged)==null?void 0:i.call(r,e)}))}initEvents(){this.doc.on("nothing pending",this.handleNothingPending),this.doc.on("create",this.handleCreate),this.doc.on("del",this.handleDel),this.client.onAuthError(e=>{this.callbacks.forEach(r=>{var i;return(i=r.onError)==null?void 0:i.call(r,e)})}),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((e,r)=>{if(this.localPresence)e();else{const i=this.doc.connection.getPresence(`${this.doc.collection}:${this.doc.id}`);i.on("receive",(o,s)=>{this.onCustomMessage(s)}),i.subscribe(o=>{o?r(o):(this.localPresence=i.create(Z()),e())})}})}subscribe(){return new Promise((e,r)=>{this.doc.subscribe(i=>{i?r(i):(this.doc.on("op",this.handleOp),e())})})}toJSON(){return oo(this.data())}getContainerBlocks(e){const r=this.data();p(se,r,"no doc data");const i=r[so(e)];return p(se,i,`no container data: ${e}`),gt.default(i)}findContainerBlocks(e){const r=this.data();p(se,r,"no doc data");const i=r[so(e)];return i!=null?i:null}getBlockData(e,r){const i=this.data();p(se,i,"no doc data");const o=i[so(e)];p(se,o,`no container data: ${e}`);const s=o[r];return p(se,s,`no block data: ${r}`),gt.default(s)}localInsertBlock(e,r,i){return this.submitInsertBlock(e,r,i),this.getBlockData(e,r)}localDeleteBlock(e,r){const i=this.getBlockData(e,r);return this.submitDeleteBlock(e,r),i}localUpdateBlockText(e,r,i){const o=this.getBlockData(e,r);p(se,o.text,"no block text");const s=gt.default(o.text);this.submitUpdateRichText(e,r,i);const l=fn.apply(s,i);return p(se,l,"no block text"),l}localUpdateBlockData(e,r,i){const o=gt.default(this.getBlockData(e,r));return this.submitUpdateBlockData(e,r,i),o}localInsertChildContainers(e){this.submitInsertChildContainers(e)}localDeleteChildContainers(e){this.beginBatchUpdate(),e.forEach(r=>{this.submitDeleteChildContainer(r)}),this.endBatchUpdate()}getComments(){return Object.values(this.data().comments).map(r=>oT(r))}getComment(e){return this.data().comments[e]}getCommentDoc(e){const r=this.data().comments[e];return Kp(r)}localCreateComment(e,r){const i=Vp(e,r),s=["comments",i.id,{i}];return this.submitOp(s)}localDeleteComment(e){const r=["comments",e,{r:!0}];return this.submitOp(r)}localUpdateComment(e,r){const i=Vp(e,r),o=["comments",e.id,{r:!0,i}];return this.submitOp(o)}destroy(){var e;this.destroyed=!0,this.clearEvents(),this.clearCallbacks(),this.doc.destroy(),(e=this.localPresence)==null||e.destroy(),this.client.close(!this.disableLogout),this.remoteCaretHandler.destroy()}onDeleteBlock(e,r,i){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(o=>{var s;return(s=o.onDeleteBlock)==null?void 0:s.call(o,Ma(e),r,i)})}onInsertBlock(e,r,i,o){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onInsertBlock)==null?void 0:l.call(s,Ma(e),r,i,o)})}onUpdateBlockData(e,r,i,o){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,Ma(e),r,i,o)})}onUpdateBlockText(e,r,i,o){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockText)==null?void 0:l.call(s,Ma(e),r,i,o)})}onDeleteContainer(e,r){p(se,this.callbacks.length>0,"no callbacks"),p(se,e!=="root","should not delete root container in doc"),this.callbacks.forEach(i=>{var o;return(o=i.onDeleteChildContainer)==null?void 0:o.call(i,Ma(e),r)})}onCreateContainer(e,r,i){p(se,this.callbacks.length>0,"no callbacks"),p(se,e!=="root","should not create root container in doc"),this.callbacks.forEach(o=>{var s;return(s=o.onInsertChildContainer)==null?void 0:s.call(o,Ma(e),r,i)})}onDeleteComment(e,r){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var o;return(o=i.onDeleteComment)==null?void 0:o.call(i,e,r)})}onCreateComment(e,r){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var o;return(o=i.onCreateComment)==null?void 0:o.call(i,e,r)})}onUpdateComment(e,r){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var o;return(o=i.onUpdateComment)==null?void 0:o.call(i,e,r)})}onCustomMessage(e){const r=e;(r==null?void 0:r.type)==="custom"&&(r==null?void 0:r.clientId)!==this.client.clientId?this.callbacks.forEach(i=>{var o;return(o=i.onCustomMessage)==null?void 0:o.call(i,r.data)}):(r==null?void 0:r.type)==="onlineUsers"&&setTimeout(()=>{const i={type:"custom",data:e,clientId:"-"};this.onCustomMessage(i)})}async addResources(e){let r=[];return e.forEach(o=>{const s=o.split("|");r.push(...s)}),r=Array.from(new Set(r)),await this.client.getFileUrlsByHashes(r)}async uploadResource(e,r){var o;return{resourceId:await this.client.uploadResource(e,(o=r==null?void 0:r.onProgress)!=null?o:()=>{})}}buildResourceUrl(e,r){return this.client.buildResourceUrl(e,r)}request(e,r){return this.client.request(e,r)}getUser(){const e=this.client.clientId,{permission:r,userId:i,displayName:o,avatarUrl:s}=this.client.auth;return{permission:r,clientId:e,userId:i,displayName:o,avatarUrl:s,rainbowIndex:0}}getRemoteUsers(){return this.remoteCaretHandler.remoteUsers}getVersionHelper(){return this}getVersions(){return this.client.getVersions()}async getVersion(e){const r=await this.client.getVersion(e);return oo(r)}async getLatestVersion(){const e=await this.client.getLatestVersion();return oo(e)}async getHistoryData(e,r){const{doc:i,ops:o}=await this.client.getVersionOps(e,r),s=o.map(l=>({user:l.meta.createdBy,data:l}));return{doc:oo(i),historyData:s}}async getVersionData(e,r){const{doc:i,ops:o}=await this.client.getVersionOps(e,r);return{doc:oo(i),versionData:o}}async updateVersionExtra(e,r,i){await this.client.updateVersionExtra(e,r,i)}revertVersion(e){return this.client.revertVersion(e)}createVersion(e,r){return this.client.createVersion(e,r)}async recognizeLink(e){return this.client.recognizeLink(e)}parseHistoryData(e,r){Fp(e.data.op,r,!0)}getServerMeta(){return{appId:this.client.auth.appId,docId:this.client.auth.docId,serverId:this.client.apiServer()}}}I("remote-cursor");class lT{constructor(t){m(this,"handleDocSelectionChange",()=>{this.broadcastCaretPos()});m(this,"broadcastCaretPos",Me.default(()=>{const t={type:"caret",userId:this.editor.doc.getUser().userId,range:this.editor.selection.range.toDocRange()};this.editor.doc.broadcastMessage(t)},300));m(this,"handleRemoteCaretsChanged",t=>{t.forEach(e=>{const r=this.editor.findBlockById(e);r&&this.editor.reloadBlock(r)})});this.editor=t,this.editor.addListener("selectionChanged",this.handleDocSelectionChange),this.editor.doc.getRemoteUsers().addListener("remote-carets-change",this.handleRemoteCaretsChanged)}destroy(){this.editor.removeListener("selectionChanged",this.handleDocSelectionChange),this.editor.doc.getRemoteUsers().removeListener("remote-carets-change",this.handleRemoteCaretsChanged)}}const aT=I("remote-cursor-decorator");class $p{decorateText(t,e,r){const i=t.doc.getRemoteUsers();if(!i)return{};const o=new Map,{containerId:s,blockIndex:l}=e[e.length-1];p(aT,typeof s=="string","invalid path containerId"),p(aT,typeof l=="number","invalid path blockIndex");const c=t.doc.getBlockData(s,l),d=un(r);return i.getSimpleCursors(c.id).forEach((C,E)=>{E>d&&(E=d);const A=C.map(R=>({id:Z(),type:"remote-cursor",name:R.user.displayName,time:R.time,rainbowIndex:R.user.rainbowIndex})),v=o.get(E);v?v.push(...A):o.set(E,A)}),{insertions:o}}}const Hp=I("sharedb-doc/share-db-server"),KN=Eb.default.create();class VN{constructor(t,e){m(this,"auth");m(this,"clientId",Z());this.serverUrl=e,this.auth=t}editorServer(){const t=this.apiServer(),e=`/${this.auth.appId}/${this.auth.docId}`;return p(Hp,t.endsWith(e),`invalid api server: ${t}, ${e}`),t.substr(0,t.length-e.length)}apiServer(){const t=`${this.serverUrl}/${this.auth.appId}/${this.auth.docId}`;if(t.startsWith("ws://"))return`http://${t.substring(5)}`;if(t.startsWith("wss://"))return`https://${t.substring(6)}`;throw new Error(`invalid server url: ${t}`)}getBaseURL(){const t=new URL(this.apiServer());return`${t.protocol}//${t.host}${t.pathname}`}getBase64BaseURL(){return ci(this.getBaseURL())}async request(t,e){var o;const r=this.auth.token,i=e||{};i.url=t,i.headers||(i.headers={}),p(Hp,r,"no token"),i.headers={...i.headers,[il]:r,[Na]:this.getBase64BaseURL()};try{return await KN(t,i)}catch(s){throw(o=s.response)!=null&&o.data&&(s.responseData=s.response.data),s}}async getVersions(){const e=`${this.apiServer()}/versions?withExtra=true`,i=(await this.request(e)).data.versions;return i.forEach(o=>{o.extra&&(o.extra=JSON.parse(o.extra))}),i}async getVersion(t){const r=`${this.apiServer()}/versions/${t}`,i=await this.request(r);return JSON.parse(i.data.data)}async getLatestVersion(){const e=`${this.apiServer()}/versions/latest`,r=await this.request(e);return JSON.parse(r.data.data)}async getVersionOps(t,e){let i=`${this.apiServer()}/versions/before/${t}?withOp=true`;e!==void 0&&e!==0&&(i+=`&from=${e}`);const o=await this.request(i),s=o.data.ops,l=xb.default(s,h=>!!h.create);let c=null;l!==-1&&(c=s[l],s.splice(0,l+1));let d;return c?(p(Hp,c.create,"no createDoc.create"),d=c.create.data):d=JSON.parse(o.data.data),d.blocks||(d.blocks=[]),{doc:d,ops:o.data.ops}}async updateVersionExtra(t,e,r){const o=`${this.apiServer()}/versions/${t}/tags/${e}`;await this.request(o,{method:"post",data:{extra:JSON.stringify(r)}})}async revertVersion(t){const r=`${this.apiServer()}/versions/revert/${t}`;await this.request(r,{method:"post",data:{}})}async createVersion(t,e){const i=`${this.apiServer()}/versions`;return(await this.request(i,{method:"post",data:{publish:e,tag:t}})).data}buildResourceUrl(t,e){if(!t)return"";if(t.startsWith("https:")||t.startsWith("http:")||t.startsWith("file:")||t.startsWith("data:")||t.startsWith("blob:"))return t;let i=`${this.apiServer()}/resources/${encodeURIComponent(t)}`;const o=[];if(e!=null&&e.withToken,e!=null&&e.downloadFileName&&o.push(`&fileName=${encodeURIComponent(e.downloadFileName)}`),o.length>0){const s=o.join("&");i+=`?${s}`}return i}}const $N=I("sharedb-doc/share-db-server");function cT(n){const t=new URL(n);return`${t.protocol==="wss:"?"https:":"http:"}//${t.host}${t.pathname}`}function HN(n){return ci(cT(n))}class zh extends sa{constructor(e){super();m(this,"remoteUsers",new Ru);m(this,"client");this.options=e,this.client=new VN(e.auth,e.serverUrl)}destroy(){}buildResourceUrl(e,r){return this.client.buildResourceUrl(e,r)}getRemoteUsers(){return this.remoteUsers}getVersionHelper(){return this}getVersions(){return this.client.getVersions()}async getVersion(e){const r=await this.client.getVersion(e);return oo(r)}async getLatestVersion(){const e=await this.client.getLatestVersion();return oo(e)}async getHistoryData(e,r){const{doc:i,ops:o}=await this.client.getVersionOps(e,r),s=o.map(l=>({user:l.meta.createdBy,data:l}));return{doc:oo(i),historyData:s}}async getVersionData(e,r){const{doc:i,ops:o}=await this.client.getVersionOps(e,r);return{doc:oo(i),versionData:o}}async updateVersionExtra(e,r,i){await this.client.updateVersionExtra(e,r,i)}revertVersion(e){return this.client.revertVersion(e)}createVersion(e,r){return this.client.createVersion(e,r)}parseHistoryData(e,r){Fp(e.data.op,r,!0)}getServerMeta(){return{appId:this.client.auth.appId,docId:this.client.auth.docId,serverId:this.client.apiServer()}}static async auth(e,r){p($N,e.token,"no auth token");const i=`${cT(r)}/auth`,o=await window.fetch(i,{method:"GET",headers:{[il]:e.token,[Na]:HN(r)},credentials:"include"});if(o.status!==200)throw new Error("http auth error");return await o.json()}static async load(e){const r=`${e.serverUrl}/${e.auth.appId}/${e.auth.docId}`;return await this.auth(e.auth,r),new zh(e)}}class uT extends Re.TypedEmitter{constructor(t){super(),this.editor=t,this.editor.doc.registerCallback(this)}handleChild(t,e,r){if(Xt(ui(this.editor,t)))return;const i=this.editor.getBlockByIndex(t,e),o=et(this.editor.getContainerById(t));o&&this.emit("change",this.editor,o,i,r)}onUpdateBlockData(t,e){this.handleChild(t,e,"data-change")}onUpdateBlockText(t,e){this.handleChild(t,e,"text-change")}onInsertBlock(t,e){setTimeout(()=>{this.handleChild(t,e,"insert")})}onDeleteBlock(t,e){this.handleChild(t,e,"remove")}destroy(){this.editor.doc.unregisterCallback(this)}}function fT(n,t){n.addCustom("child-block-tracker",()=>new uT(n)).addListener("change",t)}function dT(n,t){n.addCustom("child-block-tracker",()=>new uT(n)).removeListener("change",t)}const lct="",jN={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"}},zN={colorPalette:{colorDesc:"Text color",name:"Text color",backgroundDesc:"Background color",reset:"Restore default values"},search:{emptyTips:"No results found"}},GN={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"}};D.mergeLang({"zh-CN":jN,"en-US":zN,"ja-JP":GN});const act="";I("button");function Cr(n,t,e,r,i){const o=B("button",["editor-button"],null);return o.setAttribute("data-button-id",n),i&&o.setAttribute(`data-editor-tooltip-${i}`,t),e?typeof e=="string"?e.startsWith("<")?o.innerHTML=e:o.innerText=e:o.appendChild(e):o.innerText=t,r&&(r.indexOf("checked")!==-1&&z(o,"checked"),r.indexOf("disabled")!==-1&&(o.disabled=!0),r.indexOf("primary")!==-1&&z(o,"primary")),o}const cct="",Gh=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
31
|
+
`)}const o=new Blob([r],{type:"text/html"});return da([{type:"text/plain",data:new Blob([i],{type:"text/plain"})},{type:"text/html",data:o}]),!0}const UU=Object.freeze(Object.defineProperty({__proto__:null,editorHandleEnter:Q5,editorHandleDelete:Y5,editorHandleBackspace:J5,editorHandleInsertBr:Z5,editorHandlePastePlainText:t2,isSelectedCodeTextBlock:e2,getSelectedCodeBlockMarkdown:n2,editorHandleCopyMarkdown:xp},Symbol.toStringTag,{value:"Module"})),_h={ArrowDown:p5,ArrowUp:g5,ArrowLeft:h5,ArrowRight:m5,"Shift+ArrowDown":C5,"Shift+ArrowUp":A5,"Shift+ArrowLeft":E5,"Shift+ArrowRight":x5,"CtrlOrCmd+ArrowLeft":v5,"CtrlOrCmd+ArrowRight":B5,"CtrlOrCmd+Shift+ArrowLeft":T5,"CtrlOrCmd+Shift+ArrowRight":y5,"CtrlOrCmd+ArrowUp":k5,"CtrlOrCmd+ArrowDown":fp,"CtrlOrCmd+Shift+ArrowUp":R5,"CtrlOrCmd+Shift+ArrowDown":dp,"CtrlOrCmd+A":mp,Home:_5,End:M5,"Shift+Home":I5,"Shift+End":D5,PageUp:F5,PageDown:K5,"Shift+PageUp":V5,"Shift+PageDown":$5,"CtrlOrCmd+Z":BU,"CtrlOrCmd+Shift+Z":TU,Enter:Q5,Delete:Y5,Backspace:J5,"Shift+Enter":Z5,"CtrlOrCmd+Shift+V":t2,"CtrlOrCmd+Shift+C":xp};function r2(n,t){return n.shortcuts.handleKeyboardEvents(n,t)!==void 0}function i2(n,t,e){if(t.type==="embed"){const o=t.embedData,s=o.src;if(s&&typeof s=="string"){const l=e.get(s);if(l)o.src=l;else{let c="";s.split("|").forEach(h=>{const C=e.get(h);C&&(c+=c?`|${C}`:`${C}`)}),c&&(o.src=c)}}return}const r=t.text;r&&r.forEach(o=>{if(o.attributes&&o.attributes.src&&typeof o.attributes.src=="string"){const s=e.get(o.attributes.src);s&&(o.attributes.src=s)}});const i=t.children;i&&i.forEach(o=>{n.blocks[o].forEach(l=>{i2(n,l,e)})})}function o2(n,t,e){if(e.size===0)return;t.blocks.root.forEach(i=>{const o=n.editorBlocks.getBlockClass(i.type);o.replaceResources?o.replaceResources(i,e):i2(t,i,e)})}async function OU(n,t){let e=t.filter(s=>s.indexOf(":")===-1);const r=[];e.forEach(s=>{const l=s.split("|");r.push(...l)}),e=Array.from(new Set(r)),e=r;const i=await n.doc.addResources(e),o=new Map;if(e.length!==i.length)return o;for(let s=0;s<e.length;s++)o.set(e[s],i[s]);return o}function NU(n,t){var l,c,d,h;const r=t.meta.serverId;if(!r||typeof r!="string")return!1;const i=(c=(l=n.doc).getServerMeta)==null?void 0:c.call(l);if(!i)return!1;const o=/.*(?=\/)/;return((d=(i.serverId||"").match(o))==null?void 0:d[0])===((h=r.match(o))==null?void 0:h[0])}async function Ap(n,t){const r=t.meta.resources;if(!r||Object.keys(r).length===0)return;let i=new Map;if(NU(n,t)){const s=Array.from(Object.keys(r));i=await OU(n,s),o2(n,t,i)}const o=new Map;Object.entries(r).forEach(([s,l])=>{i.get(s)===void 0&&s!==l&&o.set(s,l)}),o.size!==0&&o2(n,t,o)}async function PU(n,t,e){await Ap(n,t),n.undoManager.runInGroup(()=>{const{start:r,end:i}=n.selection.range,o=n.getBlockById(r.blockId);if(r.blockId===i.blockId&&pe(o)){const s=rt(o),l=n.getBlockIndex(o),[c]=n.insertDocAt(s,l+1,t,e);c&&n.selection.selectBlock(c,dt(n,c))}else{n.clearSelectedContents();const{block:s,offset:l}=Ta(n);n.insertDoc(s,l,t,e)}})}const FU=["text/x-ones-editor-doc","image/*","text/office-html","text/html","text/plain","text/markdown","*"];function KU(n){let t;for(const e of FU)if(t=n[e],t)break;return t||null}class VU{constructor(t){m(this,"editor");m(this,"handlers",[]);m(this,"hookExecutionAttempt",(t,e,r)=>{for(let i=0;i<this.handlers.length;i++){const o=this.handlers[i];if(o.handleBeforeCopy){const s=o.handleBeforeCopy(this.editor,e,r);if(s===!0)return!0;if(typeof s=="object"&&s!=null)return s}}});m(this,"onPasteText",async(t,e)=>{const r=new DataTransfer;r.setData("text/plain",t);const i=await this.editor.dataConverter.fromData(this.editor,r,e);if(i){const o=[];this.pasteDocs(i,null,o)}});this.editor=t}onInsertText(t,e){if(!nt(this.editor,this.editor.getFocusedBlock()))return;const{containerId:r,blockIndex:i,offset:o}=Ta(this.editor);this.handleBeforeInsertText(r,i,o,e)||(this.defaultInsertText(this.editor,r,i,o,e),this.handleAfterInsertText(r,i,o,e),this.editor.selection.updateLastCaretRect())}onKeyDown(t){if(this.handleBeforeKeyDown(t))return!0;const e=this.defaultHandleKeydown(this.editor,t);return this.handleAfterKeyDown(t)?!0:e}onChanged(t){for(let e=0;e<this.handlers.length;e++){const r=this.handlers[e];r.handleChanged&&r.handleChanged(this.editor,t)}}onRemoteChanged(t){for(let e=0;e<this.handlers.length;e++){const r=this.handlers[e];r.handleRemoteChanged&&r.handleRemoteChanged(this.editor,t)}}onCompositionStart(t){if(!nt(this.editor,this.editor.getFocusedBlock()))return;this.editor.updateCompositionText("",!1);const{containerId:e,blockIndex:r,offset:i}=Ta(this.editor);for(let o=0;o<this.handlers.length;o++){const s=this.handlers[o];s.handleCompositionStart&&s.handleCompositionStart(this.editor,e,r,i)}}onUpdateCompositionText(t,e,r){if(!nt(this.editor,this.editor.getFocusedBlock()))return;this.editor.updateCompositionText(e,r),this.editor.selection.caret.update();const{containerId:i,blockIndex:o,offset:s}=Ta(this.editor);for(let l=0;l<this.handlers.length;l++){const c=this.handlers[l];c.handleUpdateCompositionText&&c.handleUpdateCompositionText(this.editor,i,o,s,r)}this.editor.selection.updateLastCaretRect()}onCopy(t){DU(this.editor,t,this.hookExecutionAttempt)}onCopyWithoutEvent(){_U(this.editor,this.hookExecutionAttempt)}onCut(t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforeCut&&i.handleBeforeCut(this.editor,t)===!0)return}if(this.onCopy(t),this.editor.selection.range.isCollapsed()){const r=this.editor.selection.focusedBlock;pe(r)&&this.editor.deleteBlock(r)}else yh(this.editor)}onPaste(t){if(t.preventDefault(),t.stopPropagation(),!t.clipboardData)return;const e=this.editor.dataConverter.fromData(this.editor,t.clipboardData),r=Array.from(t.clipboardData.files);e.then(async i=>{i&&this.pasteDocs(i,t,r)})}onFocus(){z(this.editor.rootElement,"active")}onBlur(){ot(this.editor.rootElement,"active")}addHandler(t){this.handlers.push(t),this.handlers=this.handlers.sort((e,r)=>{var s,l;const i=(s=e.order)!=null?s:1;return((l=r.order)!=null?l:1)-i})}removeHandler(t){const e=this.handlers.indexOf(t);e!==-1&&this.handlers.splice(e)}handleBeforeInsertText(t,e,r,i){for(let o=0;o<this.handlers.length;o++){const s=this.handlers[o];if(s.handleBeforeInsertText&&s.handleBeforeInsertText(this.editor,t,e,r,i))return!0}return!1}handleAfterInsertText(t,e,r,i){for(let o=0;o<this.handlers.length;o++){const s=this.handlers[o];if(s.handleAfterInsertText&&s.handleAfterInsertText(this.editor,t,e,r,i))return!0}return!1}handleBeforeKeyDown(t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforeKeyDown&&i.handleBeforeKeyDown(this.editor,t))return!0}const e=this.defaultHandleKeydown(this.editor,t);for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleAfterKeyDown&&i.handleAfterKeyDown(this.editor,t))return!0}return e}handleAfterKeyDown(t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforeKeyDown&&i.handleBeforeKeyDown(this.editor,t))return!0}const e=this.defaultHandleKeydown(this.editor,t);for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleAfterKeyDown&&i.handleAfterKeyDown(this.editor,t))return!0}return e}defaultInsertText(t,e,r,i,o){X1(this.editor,o)}defaultHandleKeydown(t,e){return r2(this.editor,e)?(e.preventDefault(),e.stopPropagation(),!0):!1}async pasteDoc(t){for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleBeforePasteDoc&&await i.handleBeforePasteDoc(this.editor,t))return}const e={blockIdMap:new Map,containerIdMap:new Map,boxIdMap:new Map};await PU(this.editor,t,e);for(let r=0;r<this.handlers.length;r++){const i=this.handlers[r];if(i.handleAfterPasteDoc&&await i.handleAfterPasteDoc(this.editor,t,e))return}}async pasteDocs(t,e,r){for(let o=0;o<this.handlers.length;o++){const s=this.handlers[o];if(s.handleBeforePaste&&await s.handleBeforePaste(this.editor,e,t,r))return}const i=KU(t);if(!!i){await this.pasteDoc(i);for(let o=0;o<this.handlers.length;o++){const s=this.handlers[o];if(s.handleAfterPaste&&await s.handleAfterPaste(this.editor,e,t))return}}}destroy(){this.handlers.forEach(t=>{var e;(e=t.destroy)==null||e.call(t,this.editor)}),this.handlers=[]}forEach(t){this.handlers.forEach(t)}}function $U(n,t,e){const r=zi(t,e);return r.remove(),r}I("copy-dom-attributes");const s2=["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 HU(n,t){for(let l=0;l<s2.length;l++){const c=s2[l];t[c]=n[c]}const e=n.attributes,r=t.attributes,i=[],o=[];for(let l=0;l<e.length;l++){const c=e[l],d=r.getNamedItem(c.name);d?d.value!==c.value&&(d.value=c.value,o.push(c)):i.push(c)}const s=[];for(let l=0;l<r.length;l++){const c=r[l];e.getNamedItem(c.name)||s.push(c)}i.forEach(l=>{t.setAttribute(l.name,l.value)}),o.forEach(l=>{t.setAttribute(l.name,l.value)}),s.forEach(l=>{t.removeAttribute(l.name)})}function l2(n){const t=Array.from(n.childNodes).filter(e=>!Bv(e));return t.forEach(e=>{e.remove()}),t}function a2(n,t,e){var d;const r=n.getContainerById(t),i=zi(r,e),o=Vo(i),s=n.doc.getBlockData(t,e),l=Yt(n,i);if((d=l==null?void 0:l.handleUpdateBlock)==null?void 0:d.call(l,n,i,s))n.editorBlockRenders.updateBlock(n,o,i,s);else{const h=n.editorBlocks.createBlock(o,r,s),C=l2(h);l2(i),C.forEach(A=>{i.appendChild(A)});const E=zd(h);if(E){const A=zd(i);A&&A.remove(),i.appendChild(E)}HU(h,i)}Fv(n,i,s),n.blockHooks.forEach(h=>{var C;(C=h.update)==null||C.call(h,n,o,r,i,s)}),setTimeout(()=>{n.selection.updateSelection(null)})}const jU=I("transform-selection");function c2(n,t,e,r){const{range:i}=n.selection,{anchor:o,focus:s}=i;if(o.blockId!==t&&s.blockId!==t)return i;p(jU,o.isSimple()&&s.isSimple(),"invalid text pos type");let l=o;if(o.blockId===t){const d=fn.transformCursor(o.offset,e,r);l=lt(t,d,"normal")}let c=s;if(s.blockId===t){const d=fn.transformCursor(s.offset,e,r);c=lt(t,d,"normal")}return qe(n,{anchor:l,focus:c})}const zU=I("handle-block-text-changed");function GU(n,t,e,r,i){const o=n.getContainerById(t),s=zi(o,e),l=n.doc.getBlockData(t,e);if(p(zU,l.text,"no block text"),xv(n,s).setBlockText(n,s,l.text),!i){const c=c2(n,l.id,r,i);n.selection.setRange(c,{noScroll:!0})}}function WU(n,t){const e=gt.default(n);return t.delete.forEach(i=>{delete e[i]}),{...e,...t.insert}}function u2(n,t,e,r){const i=Yt(n,t);i.handleDeleteBlock&&i.handleDeleteBlock(n,t,e,r),n.emit("blockDeleted",n,t,e,r)}function qU(n,t,e,r){const i=n.getBlockByIndex(t,e);i.querySelectorAll('[data-type="editor-block"]').forEach(o=>{u2(n,o,r,{child:!0})}),u2(n,i,r,{child:!1})}const Pr=I("editor-doc");class XU extends sa{constructor(e,r,i){super();m(this,"localEvents",[]);this.editor=e,this.externalDoc=r,this.externalDoc.registerCallback(this),this.registerLocalEvents(i)}beginBatchUpdate(){return this.externalDoc.beginBatchUpdate()}endBatchUpdate(){return this.externalDoc.endBatchUpdate()}registerLocalEvents(e){this.localEvents.push(e)}toJSON(){return this.externalDoc.toJSON()}getVersionHelper(){var r,i;return(i=(r=this.externalDoc).getVersionHelper)==null?void 0:i.call(r)}getContainerBlocks(e){return this.externalDoc.getContainerBlocks(e)}findContainerBlocks(e){return this.externalDoc.findContainerBlocks(e)}getBlockData(e,r){return this.externalDoc.getBlockData(e,r)}verifyBlockWritable(e,r){const i=this.editor.getBlockByIndex(e,r);p(Pr,this.editor.isBlockWritable(i),`block is not writable, ${e}, ${r}`)}localUpdateBlockText(e,r,i,o){p(Pr,!this.editor.readonly,"editor is readonly"),this.verifyBlockWritable(e,r);const s=this.getBlockData(e,r),l=s.text;p(Pr,l,`no text, ${e}, ${r}`);const c=c2(this.editor,s.id,i,!0),d=fn.apply(l,i);this.localEvents.forEach(C=>C.onBeforeUpdateBlockText(e,s.id,l,d,c.toDocRange()));const h=this.externalDoc.localUpdateBlockText(e,r,i);return this.editor.selection.setRange(c,o),h}localUpdateBlockData(e,r,i,o){p(Pr,!this.editor.readonly,"editor is readonly");const s=this.editor.getBlockByIndex(e,r);if(!this.editor.isBlockWritable(s)){const h=Array.from(i.delete).filter(E=>E!=="comments"),C=Object.keys(i.insert).filter(E=>E!=="comments");(h.length>0||C.length>0)&&p(Pr,!1,`block is not writable, comment supported only, ${JSON.stringify(i)}}`)}const l=gt.default(this.getBlockData(e,r)),c=gt.default(WU(l,i));this.localEvents.forEach(h=>h.onBeforeUpdateBlockData(e,l.id,l,c,o));const d=this.externalDoc.localUpdateBlockData(e,r,i,o);return this.editor.selection.setRange($o(this.editor,o)),d}localInsertBlock(e,r,i,o,s){p(Pr,!this.editor.readonly,"editor is readonly"),this.localEvents.forEach(c=>c.onBeforeInsertBlock(e,r,i,o));const l=this.externalDoc.localInsertBlock(e,r,i,o);return s!=null&&s.noFocus||this.editor.selection.setRange($o(this.editor,o),s),l}localDeleteBlock(e,r,i){p(Pr,!this.editor.readonly,"editor is readonly"),this.verifyBlockWritable(e,r);const o=gt.default(this.getBlockData(e,r));this.localEvents.forEach(l=>l.onBeforeDeleteBlock(e,r,o,i));const s=this.externalDoc.localDeleteBlock(e,r,i);return this.editor.selection.setRange($o(this.editor,i)),s}localDeleteChildContainers(e){return p(Pr,!this.editor.readonly,"editor is readonly"),e.forEach(r=>{const i=gt.default(this.getContainerBlocks(r));this.localEvents.forEach(o=>o.onBeforeDeleteChildContainer(r,i))}),this.externalDoc.localDeleteChildContainers(e)}localInsertChildContainers(e){p(Pr,!this.editor.readonly,"editor is readonly");const r=gt.default(e);r.forEach(i=>{this.localEvents.forEach(o=>o.onBeforeInsertChildContainer(i.containerId,i.blocks))}),this.externalDoc.localInsertChildContainers(r)}onRequestReload(e){Pr.debug(`reload doc: ${e}`),this.editor.reload(),this.callbacks.forEach(i=>{var o;return(o=i.onRequestReload)==null?void 0:o.call(i,e)});const r=!1;this.editor.emit("docChanged",this.editor,r)}onUpdateBlockText(e,r,i,o){this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockText)==null?void 0:l.call(s,e,r,i,o)}),GU(this.editor,e,r,i,o),this.editor.emit("docChanged",this.editor,o)}onUpdateBlockData(e,r,i,o){this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,e,r,i,o)}),a2(this.editor,e,r),this.editor.emit("docChanged",this.editor,o)}onInsertBlock(e,r,i,o){this.callbacks.forEach(l=>{var c;return(c=l.onInsertBlock)==null?void 0:c.call(l,e,r,i,o)});const s=this.editor.getContainerById(e);RI(this.editor,s,r,i),this.editor.emit("docChanged",this.editor,o)}onDeleteBlock(e,r,i){qU(this.editor,e,r,i),this.callbacks.forEach(s=>{var l;return(l=s.onDeleteBlock)==null?void 0:l.call(s,e,r,i)});const o=this.editor.getContainerById(e);$U(this.editor,o,r),this.editor.emit("docChanged",this.editor,i)}onInsertChildContainer(e,r,i){this.callbacks.forEach(o=>{var s;return(s=o.onInsertChildContainer)==null?void 0:s.call(o,e,r,i)})}onDeleteChildContainer(e,r){this.callbacks.forEach(i=>{var o;return(o=i.onDeleteChildContainer)==null?void 0:o.call(i,e,r)})}onCustomMessage(e){this.callbacks.forEach(r=>{var i;return(i=r.onCustomMessage)==null?void 0:i.call(r,e)})}onStatusChanged(e){this.callbacks.forEach(r=>{var i;return(i=r.onStatusChanged)==null?void 0:i.call(r,e)})}onError(e){this.callbacks.forEach(r=>{var i;return(i=r.onError)==null?void 0:i.call(r,e)})}uploadResource(e,r){return this.externalDoc.uploadResource(e,r)}addResources(e){return this.externalDoc.addResources(e)}buildResourceUrl(e,r){return this.externalDoc.buildResourceUrl(e,r)}request(e,r){return this.externalDoc.request(e,r)}broadcastMessage(e){return this.externalDoc.broadcastMessage(e)}getUser(){return this.externalDoc.getUser()}getRemoteUsers(){return this.externalDoc.getRemoteUsers()}destroy(){this.externalDoc.destroy(),this.clearCallbacks()}getServerMeta(){var e,r,i;return(i=(r=(e=this.externalDoc).getServerMeta)==null?void 0:r.call(e))!=null?i:{}}reset(e){Pr.log("reset doc"),this.externalDoc=e,this.externalDoc.registerCallback(this),this.editor.reload()}}function f2(n,t){if(n.length===0){n.push(t);return}const e=n[n.length-1];if(!e.combinable(t)){n.push(t);return}e.combine(t)}const Mh=I("undo-action");class Da{constructor(t,e,r){m(this,"beforeRange");m(this,"afterRange");this.containerId=e,this.beforeRange=t.selection.range.clone().toDocRange(),this.afterRange=r}undo(t){return!1}redo(t){return!1}combinable(t){return p(Mh,t,"no other action"),!1}combine(t){p(Mh,!1,"no other")}setAfterRange(t){this.afterRange&&Mh.warn("after range has already set"),this.afterRange=t}findContainerById(t,e){return!!t.doc.findContainerBlocks(e)}findBlockById(t,e){const r=t.doc.findContainerBlocks(this.containerId);return r?r.some(i=>i.id===e):!1}checkBlockData(t,e){if(Array.isArray(e.children)){const r=t.doc.toJSON();for(let i=0;i<e.children.length;i++){const o=e.children[i];if(!r.blocks[o])return Mh.warn(`container (${o}) not found, deleted by others?`),!1}}return!0}}const _a=I("block-action");class d2 extends Da{constructor(e,r,i,o,s){super(e,r,s);m(this,"blockData");m(this,"blockIndex");this.blockData=gt.default(o),this.blockIndex=i}deleteBlock(e,r){if(!this.findContainerById(e,this.containerId))return _a.warn(`container (${this.containerId}) not found, deleted by others?`),!1;if(!this.findBlockById(e,this.blockData.id))return _a.warn(`block (${this.blockData.id}) not found, deleted by others?`),!1;if(!e.getContainerById(this.containerId))return!1;const o=e.getBlockById(this.blockData.id);if(!o)return!1;try{p(_a,this.blockIndex===bt(o),"invalid block index"),Bh(e,o,$o(e,r))}catch(s){_a.warn(s.message),e.selection.selectBlock(o,0)}return!0}insertBlock(e,r){if(!this.findContainerById(e,this.containerId))return _a.warn(`container (${this.containerId}) not found, deleted by others?`),!1;if(!this.checkBlockData(e,this.blockData))return!1;try{ka(e,this.containerId,this.blockIndex,gt.default(this.blockData),r)}catch(i){_a.warn(i.message);const o=e.doc.getContainerBlocks(this.containerId),s=Math.min(o.length-1,this.blockIndex),l=e.getBlockByIndex(this.containerId,s);e.selection.selectBlock(l,0)}return!0}}I("insert-block-action");class QU extends d2{undo(t){return this.deleteBlock(t,this.beforeRange)}redo(t){return this.insertBlock(t,this.afterRange)}}class YU extends d2{undo(t){return this.insertBlock(t,this.beforeRange)}redo(t){return this.deleteBlock(t,this.afterRange)}}class JU extends Da{constructor(e){super(e,ft(e.rootContainer),e.selection.range.toDocRange());m(this,"actions",[])}addAction(e){f2(this.actions,e),this.afterRange=e.afterRange}undo(e){let r=!1;return this.actions.concat().reverse().forEach(i=>{i.undo(e)&&(r=!0)}),r}redo(e){let r=!1;return this.actions.forEach(i=>{i.redo(e)&&(r=!0)}),r}setAfterRange(e){this.afterRange=e;const r=this.actions[this.actions.length-1];!r||r instanceof Da&&(r.afterRange||r.setAfterRange(e))}}const Qo=I("update-block-data-action");class Uh extends Da{constructor(e,r,i,o,s,l){super(e,r,l);m(this,"beforeBlockData");m(this,"afterBlockData");m(this,"blockId");this.blockId=i,p(Qo,this.blockId===o.id,"invalid block id"),p(Qo,this.blockId===s.id,"invalid block id"),this.beforeBlockData=gt.default(o),this.afterBlockData=gt.default(s),p(Qo,this.beforeBlockData.type===this.afterBlockData.type,"invalid block type")}undo(e){if(!e.findBlockById(this.blockId))return Qo.warn(`block (${this.blockId}) not found, deleted by others?`),!1;const r=e.getBlockById(this.blockId);if(!r||!this.checkBlockData(e,this.beforeBlockData))return!1;const i=e.getContainerById(this.containerId);return p(Qo,i,"no container"),Rh(e,r,Uh.toAttributes(this.beforeBlockData),this.beforeRange),!0}redo(e){if(!e.findBlockById(this.blockId))return Qo.warn(`block (${this.blockId}) not found, deleted by others?`),!1;p(Qo,e,"no editor");const r=e.getBlockById(this.blockId);if(!r||!this.checkBlockData(e,this.beforeBlockData))return!1;const i=e.getContainerById(this.containerId);return p(Qo,i,"no container"),Rh(e,r,Uh.toAttributes(this.afterBlockData),this.afterRange),!0}static toAttributes(e){const r=gt.default(e);return delete r.id,delete r.type,r}}const el=I("update-block-text-action");class yu extends Da{constructor(e,r,i,o,s,l){super(e,r,l);m(this,"beforeRichTextData");m(this,"afterRichTextData");m(this,"blockId");m(this,"type");this.blockId=i,this.beforeRichTextData=gt.default(o),this.afterRichTextData=gt.default(s),this.type=yu.calType(o,s)}static calType(e,r){p(el,e,"no old data"),p(el,r,"no new data");const o=fn.diff(e,r),s=new Set;let l=!1;const c=h=>Wb(h)?`cjk_${h}`:zb(h)?"number":Od(h)?"space":Gb(h)?"letter":"unknown";let d=!1;return o.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_${c(h.insert.substr(1))}`)):s.add(`insert_${c(h.insert)}`):h.delete&&(l?l=!1:s.add("delete"))}),{textType:Array.from(s).join("|"),begin:d}}undo(e){if(!this.findContainerById(e,this.containerId))return el.warn(`container (${this.containerId}) not found, deleted by others?`),!1;if(!this.findBlockById(e,this.blockId))return el.warn(`block (${this.blockId}) not found, deleted by others?`),!1;if(!e.getContainerById(this.containerId))return!1;const i=e.getBlockById(this.blockId);return i?(kh(e,i,this.beforeRichTextData),!0):!1}redo(e){if(!this.findContainerById(e,this.containerId))return el.warn(`container (${this.containerId}) not found, deleted by others?`),!1;if(!this.findBlockById(e,this.blockId))return el.warn(`block (${this.blockId}) not found, deleted by others?`),!1;if(!e.getContainerById(this.containerId))return!1;const i=e.getBlockById(this.blockId);return i?(kh(e,i,this.afterRichTextData),!0):!1}combinable(e){if(!(e instanceof yu)||e.type.begin||this.type.textType!==e.type.textType||e.blockId!==this.blockId)return!1;const r=e.beforeRange,i=r.anchor;if(!i.isSimple())return!1;const o=this.afterRange;if(!o)return!1;const s=o.anchor;return!(!s.isSimple()||s.blockId!==r.anchor.blockId||s.offset!==i.offset)}combine(e){p(el,e instanceof yu,"invalid action type");const r=e;this.afterRichTextData=r.afterRichTextData,this.afterRange=e.afterRange}}const h2=I("child-container-action");class m2 extends Da{constructor(t,e,r){super(t,e,t.selection.range.toDocRange()),this.blocks=r}deleteChildContainer(t){return this.findContainerById(t,this.containerId)?(t.doc.localDeleteChildContainers([this.containerId]),!0):(h2.warn(`container (${this.containerId}) not found, deleted by others?`),!1)}insertChildContainer(t){return this.findContainerById(t,this.containerId)?(h2.warn(`container (${this.containerId}) already exists`),!1):(t.doc.localInsertChildContainers([{containerId:this.containerId,blocks:gt.default(this.blocks)}]),!0)}}class ZU extends m2{undo(t){return this.deleteChildContainer(t)}redo(t){return this.insertChildContainer(t)}}class tO extends m2{undo(t){return this.insertChildContainer(t)}redo(t){return this.deleteChildContainer(t)}}const Fr=I("undo");class eO{constructor(t){m(this,"editor");m(this,"actions",[]);m(this,"undoCursor");m(this,"currentGroup",null);m(this,"groupCounter",0);m(this,"undoRedoing",!1);m(this,"handleSelectionChange",t=>{if(this.currentGroup){this.currentGroup.setAfterRange(t.selection.range.toDocRange());return}const e=this.actions[this.actions.length-1];!e||e.afterRange||e.setAfterRange(t.selection.range.toDocRange())});this.editor=t,this.undoCursor=-1,this.editor.addListener("selectionChanged",this.handleSelectionChange)}reset(){this.actions=[],this.undoCursor=-1}prepareSaveUndoState(){this.undoCursor!==-1&&(this.actions.splice(this.undoCursor),this.undoCursor=-1)}addAction(t){this.currentGroup?this.currentGroup.addAction(t):(f2(this.actions,t),setTimeout(()=>{this.editor.input.handleChanged(t)}))}beginGroup(){this.groupCounter===0?(p(Fr,!this.currentGroup,"current group already exists"),this.currentGroup=new JU(this.editor),this.groupCounter=1):(p(Fr,this.currentGroup,"current group not exists"),this.groupCounter+=1)}endGroup(){p(Fr,this.currentGroup,"current group not exists"),p(Fr,this.groupCounter>0,"group counter === 0"),this.groupCounter-=1,this.groupCounter===0&&(this.currentGroup.actions.length===0?Fr.warn("empty undo group, skip it"):(this.actions.push(this.currentGroup),this.editor.input.handleChanged(this.currentGroup)),this.currentGroup=null)}hasGroup(){return this.groupCounter>0}runInGroup(t){this.beginGroup();try{const e=t();return setTimeout(()=>this.editor.selection.caret.update()),e}catch(e){throw Fr.error(`failed to run action: ${e.message}`),e}finally{this.endGroup()}}undo(){this.undoCursor===-1&&(this.undoCursor=this.actions.length);try{for(this.undoRedoing=!0;this.undoCursor>0;){this.undoCursor-=1;const t=this.actions[this.undoCursor];if(t.undo(this.editor)){try{this.editor.selection.setRange($o(this.editor,t.beforeRange))}catch(e){Fr.error(`undo: failed to restore caret pos: ${e.message}`)}return this.editor.input.handleChanged(t),!0}}return!1}finally{this.undoRedoing=!1}}redo(){this.undoCursor===-1&&(this.undoCursor=this.actions.length);try{for(this.undoRedoing=!0;this.undoCursor<this.actions.length;){const t=this.actions[this.undoCursor];if(this.undoCursor+=1,t.redo(this.editor)){try{const e=t.afterRange;e?this.editor.selection.setRange($o(this.editor,e)):Fr.warn("no after range")}catch(e){Fr.error(`redo: failed to set caret pos after redo: ${e.message}`)}return this.editor.input.handleChanged(t),!0}}return!1}finally{this.undoRedoing=!1}}canUndo(){return!(this.actions.length===0||this.undoCursor===0)}canRedo(){return!(this.actions.length===0||this.undoCursor===-1||this.undoCursor===this.actions.length)}lastAction(){var e;const t=this.undoCursor===-1?this.actions.length-1:this.undoCursor-1;return(e=this.actions[t])!=null?e:null}undoTo(t){for(;;){const e=this.lastAction();if(!e||e===t)return!0;if(!this.undo())return!1}}onBeforeUpdateBlockText(t,e,r,i,o){this.undoRedoing||(this.prepareSaveUndoState(),fn.diff(r,i).length!==0&&this.addAction(new yu(this.editor,t,e,r,i,o)))}onBeforeUpdateBlockData(t,e,r,i,o){if(this.undoRedoing)return;this.prepareSaveUndoState();const s=new Uh(this.editor,t,e,r,i,o);this.addAction(s)}onBeforeInsertBlock(t,e,r,i){this.undoRedoing||(this.prepareSaveUndoState(),p(Fr,e>=0,"invalid block index"),p(Fr,r,"no block data"),this.addAction(new QU(this.editor,t,e,r,i)))}onBeforeDeleteBlock(t,e,r,i){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new YU(this.editor,t,e,r,i)))}onBeforeInsertChildContainer(t,e){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new ZU(this.editor,t,e)))}onBeforeDeleteChildContainer(t,e){this.undoRedoing||(this.prepareSaveUndoState(),this.addAction(new tO(this.editor,t,e)))}}class nO{async fromData(t,e){const r=e.getData("text/x-ones-editor-doc");if(r)return{"text/x-ones-editor-doc":JSON.parse(r)}}}class rO{constructor(){m(this,"converters",[]);m(this,"converterTypes",["text/plain","text/markdown","text/html","text/x-ones-editor-doc"]);this.addConverter(new nO)}prepareData(t){const e=new DataTransfer;for(let r=0;r<this.converterTypes.length;r++)e.setData(this.converterTypes[r],t.getData(this.converterTypes[r]));return e}async fromData(t,e,r){let i={};const o=this.prepareData(e);for(const s of this.converters){const l=await s.fromData(t,o,r);l&&(i={...i,...l})}return i}addConverter(t){this.converters.push(t)}}function iO(n){n.editorBlocks.registerBlockClass(On),n.editorBlocks.registerBlockClass(r3),n.editorBoxes.registerBoxClass(TB),n.editorBoxes.registerBoxClass(yB),n.editorBoxes.registerBoxClass(wB),n.editorBoxes.registerBoxClass(SB),n.editorInsertions.registerInsertionClass(LB),n.editorBlockRenders.registerRender(new vv)}function oO(n,t){iO(n),t!=null&&t.blocks&&t.blocks.forEach(e=>n.editorBlocks.registerBlockClass(e)),t!=null&&t.boxes&&t.boxes.forEach(e=>n.editorBoxes.registerBoxClass(e)),t!=null&&t.embeds&&t.embeds.forEach(e=>n.editorEmbeds.registerEmbedClass(e)),t!=null&&t.insertions&&t.insertions.forEach(e=>n.editorInsertions.registerInsertionClass(e)),t!=null&&t.decorators&&t.decorators.forEach(e=>n.editorDecorators.registerDecorator(e)),t!=null&&t.dataConverters&&t.dataConverters.forEach(e=>n.dataConverter.addConverter(e)),t!=null&&t.commandProviders&&t.commandProviders.forEach(e=>n.editorCommandProviders.registerCommandProvider(e)),t!=null&&t.textRenders&&t.textRenders.forEach(e=>n.editorBlockRenders.registerRender(e))}const Oh=I("range-commands");function g2(n,t){n.forEach(e=>{e.source=t,e.children&&g2(e.children,t)})}function p2(n,t,e){const r=st(t);p(Oh,r===e.start.blockId,"invalid start range"),p(Oh,r===e.end.blockId,"invalid end range");const i=n.editorCommandProviders.getCommandProviders();let o=[];if(i.forEach(s=>{const l=s.getAvailableCommands(n,t,e);g2(l,s.id),o.push(...l)}),i.forEach(s=>{if(s.filterCommands){const l=s.filterCommands(n,t,e,o);l&&(o=l)}}),Dt(n,t)){if(!ma(e.start))return o;p(Oh,!e.start.isSimple(),"invalid start pos"),p(Oh,!e.end.isSimple(),"invalid end pos");const s=e.start.childContainerId,l=ui(n,s),d=ue(l)[0];if(d){const h=dt(n,d),C=qe(n,{anchor:lt(d,0,"home"),focus:lt(d,h,"end")}),E=p2(n,d,C);o.push(...E)}}return o}function C2(n){const t=n.getEditor(),e=n.getSelectedBlocks(),r=[],i=n.isReverse()?e[0]:e[e.length-1],o=qe(t,{anchor:i.start,focus:i.end});return p2(t,i.block,o).forEach(l=>{r.push(l)}),r}function E2(n,t,e,r,i,o){var h;const s=n.editorCommandProviders.getCommandProviders();for(let C=0;C<s.length;C++){const E=s[C];if(E.beforeExecuteCommand&&E.beforeExecuteCommand(n,t,e,r,i))return!1}const l=n.editorCommandProviders.getCommandProvider(r.source),c={};if((h=l.executeCommand)!=null&&h.call(l,n,t,e,r,i,{}))return o[st(t)]=c,!0;let d=!1;return Dt(n,t)&&ga(n,t,e.start,e.end).forEach(E=>{ue(E).forEach(v=>{const R=dt(n,v),L=qe(n,{anchor:lt(v,0,"home"),focus:lt(v,R,"end")});E2(n,v,L,r,i,o)&&(d=!0)})}),s.forEach(C=>{C.afterExecuteCommand&&C.afterExecuteCommand(n,t,e,r,i,o)}),d}function x2(n,t,e){const r=n.getEditor(),i={},o=r.editorCommandProviders.getCommandProvider(t.source);return o.executeRangeCommand&&o.executeRangeCommand(r,n,t,e,i)||(n.getSelectedBlocks().forEach(l=>{const c=qe(r,{anchor:l.start,focus:l.end});E2(r,l.block,c,t,e,i)}),r.focus()),i}const sO=I("command-providers");class A2{constructor(t){m(this,"providers",[]);this.editor=t}registerCommandProvider(t){this.providers.push(t)}getCommandProviders(){return this.providers}getCommandProvider(t){const e=this.providers.find(r=>r.id===t);return p(sO,e,`no command provider, id=${t}`),e}getCommands(t){return C2(t)}executeCommand(t,e,r){return this.editor.undoManager.runInGroup(()=>x2(t,e,r))}getEmptyBlockTextAttributes(t,e){let r={};if(this.providers.forEach(i=>{var s;const o=(s=i.getEmptyBlockTextAttributes)==null?void 0:s.call(i,t,e);o&&(r={...r,...o})}),Object.keys(r).length!==0)return r}}function lO(n,t){const e=rt(t),r=ft(e),i=bt(t);a2(n,r,i)}const aO=I("table-scroll");class b2{constructor(t,e,r,i,o){m(this,"handleEvent",t=>{this.handler(this.editor,t,this.data)});this.editor=t,this.dom=e,this.name=r,this.handler=i,this.data=o,e.addEventListener(r,this.handleEvent)}destroy(){this.dom.removeEventListener(this.name,this.handleEvent)}}class cO{constructor(t){m(this,"handlers",new Map);this.editor=t}destroy(){Array.from(this.handlers.entries()).forEach(([t,e])=>{e.forEach(r=>r.destroy()),this.handlers.delete(t)})}addEventListener(t,e,r,i){const o=this.handlers.get(t);if(o){if(o.find(s=>s.handler===r&&s.name===e)){aO.warn(`event has already registered: ${e}`);return}o.push(new b2(this.editor,t,e,r,i))}else{const s=new b2(this.editor,t,e,r,i);this.handlers.set(t,[s])}}removeEventListener(t,e,r){if(!t){for(const[o,s]of Array.from(this.handlers.entries()))for(let l=s.length-1;l>=0;l--){const c=s[l];if(e)e===c.name&&r===c.handler&&s.splice(l,1);else if(r===c.handler){s.splice(l,1),c.destroy(),s.length===0&&this.handlers.delete(o);continue}}return}const i=this.handlers.get(t);if(i){const o=i.findIndex(s=>s.handler===r&&s.name===e);if(o!==-1){const s=i[o];i.splice(o,1),s.destroy(),i.length===0&&this.handlers.delete(t)}}}removeAllListeners(t,e){const r=this.handlers.get(t);if(r)if(e)for(let i=0;i<r.length;i++){const o=r[i];o.name===e&&(r.splice(i,1),o.destroy())}else r.forEach(i=>{i.destroy()}),this.handlers.delete(t)}}const v2=I("update-block-text");function uO(n,t,e){const r=n.getBoxById(t.id),i=et(r);p(v2,i,"no parent block"),p(v2,nt(n,i),"not a text block");const o=n.getBlockText(i),s=gB(o,"id",t.id,t);JB(n,i,s,e)}function fO(n,t){for(const e of n.blockHooks)if(e.writable){const r=e.writable(n,t);if(typeof r=="boolean")return r}return!0}function dO(n){if(n.readonly)return!1;const t=hi(n);return!!n.isBlockWritable(t.map(e=>e.block))}class hO{constructor(t){this.editor=t}getKey(t){return`${this.editor.id}-${t}`}getItem(t){return window.localStorage.getItem(this.getKey(t))}setItem(t,e){if(!e){this.removeItem(t);return}window.localStorage.setItem(this.getKey(t),e)}removeItem(t){window.localStorage.removeItem(this.getKey(t))}}class mO{constructor(){m(this,"shortcuts",[])}handleKeyboardEvents(t,e){const r=this.shortcuts;for(const i of r){const o=Object.entries(i);for(const[s,l]of o)if(ai(e,s)){const c=l(t,e);if(c!==void 0)return c}}}}const io=I("editor");class gO extends Re.TypedEmitter{constructor(e,r,i){var o,s,l,c,d,h,C,E;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 mO);m(this,"dataConverter",new rO);m(this,"editorBlocks",new Zv(this));m(this,"editorBoxes",new RB(this));m(this,"editorInsertions",new DB(this));m(this,"editorEmbeds",new e3(this));m(this,"editorDecorators",new _B(this));m(this,"editorCommandProviders",new A2(this));m(this,"editorBlockRenders",new CI(this));m(this,"blockHooks",[]);m(this,"domEvents",new cO(this));m(this,"customs",new Map);m(this,"options");m(this,"inputHandlers",new VU(this));m(this,"settingsProvider");m(this,"_readonly",!1);m(this,"getColor",e=>{const r=this.options.colors;return r.length===0?"#FF1A75":r[e%r.length]});io.debug("create editor"),this.setMaxListeners(100),this.options={colors:(o=i==null?void 0:i.colors)!=null?o:["#0064FF","#EB3723","#F59300","#00A865","#F25A0A","#70A310","#009CAD","#0990D9","#8851ED","#D62069"],componentsOptions:(l=(s=i==null?void 0:i.components)==null?void 0:s.options)!=null?l:{},scrollContainer:i==null?void 0:i.scrollContainer,enableComments:(c=i==null?void 0:i.enableComments)!=null?c:!0},this.settingsProvider=(d=i==null?void 0:i.settingsProvider)!=null?d:new hO(this),oO(this,i==null?void 0:i.components),this.blockHooks.push(...(C=(h=i==null?void 0:i.components)==null?void 0:h.blockHooks)!=null?C:[]),this.id=(E=i==null?void 0:i.id)!=null?E:Z(),this.clientId=Z(),this.undoManager=new eO(this),this.doc=new XU(this,r,this.undoManager),this.parent=e,this.rootElement=B("div",["editor-root"],this.parent),this.rootElement.setAttribute("data-editor-client-id",this.clientId),this.contentElement=B("div",["editor-content"],this.rootElement),this.rootContainerObject=Qv(this),this.rootContainer=this.rootContainerObject.rootContainer,this.input=new SM(this,this.inputHandlers),this.selection=new xU(this),this.selectionHandler=new vU(this),i!=null&&i.shortcuts&&this.shortcuts.shortcuts.push(...i.shortcuts),me.isMobile&&z(this.rootElement,"mobile"),me.isSafari&&z(this.rootElement,"safari"),this._readonly&&z(this.rootElement,"readonly"),this.emit("load",this,!1)}get readonly(){return this._readonly}set readonly(e){this._readonly=e,e?z(this.rootElement,"readonly"):ot(this.rootElement,"readonly"),this.emit("readonlyChanged",this)}get scrollContainer(){return this.options.scrollContainer?this.options.scrollContainer:En(this.rootContainer)}addCustom(e,r){const i=this.customs.get(e);if(i)return i;const o=r(this);return this.customs.set(e,o),o}getCustom(e){const r=this.customs.get(e);return p(io,r,`${e} does not exists`),r}replaceCustom(e,r){const i=this.customs.get(e);return i&&i.destroy(),this.customs.set(e,r),r}findCustom(e){return this.customs.get(e)}findCustomByType(e){const r=this.customs.values();for(const i of r)if(i instanceof e)return i;return null}destroyCustom(e){const r=this.customs.get(e);r&&(this.customs.delete(e),r.destroy())}getComponentOptions(e){return this.options.componentsOptions[e]}registerLocalEvents(e){this.doc.registerLocalEvents(e)}reload(){this.rootContainerObject.reload(),this.emit("load",this,!0)}createBlock(e,r,i){return this.editorBlocks.createBlock(e,r,i)}createBox(e,r){return this.editorBoxes.createBox(e,r)}createInsertion(e,r){return this.editorInsertions.createInsertion(e,r)}destroy(){io.debug("destroy editor"),this.emit("destroy",this),this.input.destroy(),this.rootContainerObject.destroy(),this.rootElement.remove(),this.doc.destroy(),this.customs.forEach(e=>e.destroy()),this.customs.clear(),this.selection.destroy(),this.domEvents.destroy(),this.removeAllListeners(),this.inputHandlers.destroy()}focus(){this.input.focus()}focusToBlock(e,r){ep(this,e,r)}isWritable(){return dO(this)}isBlockWritable(e){return fO(this,e)}getChildContainerData(e){const r=this.doc.getContainerBlocks(e);return(!r||!Array.isArray(r))&&(p(io,r,`no child container data: ${e}, ${JSON.stringify(this.doc)}`),p(io,Array.isArray(r),`container data is not an array: ${JSON.stringify(r)}`)),r}createChildContainer(e,r,i){return Yv(this,e,r,i)}getFirstBlock(){return this.rootContainer.querySelector("[data-type=editor-block]")}getLastBlock(){const e=Array.from(this.rootContainer.querySelectorAll(":scope [data-type=editor-block]"));return e[e.length-1]}getFocusedBlock(){return this.selection.getFocusedBlock()}findBlockById(e){const r=this.rootContainer.querySelector(`#${e}`);return r&&p(io,Vs(r),"not an valid block element"),r!=null?r:null}findBoxById(e){const r=this.rootContainer.querySelector(`#${e}`);return r&&p(io,Gd(r),"not an valid box element"),r!=null?r:null}getBlockById(e){const r=this.findBlockById(e);return p(io,r,`no block, id=${e}`),r}getBoxById(e){const r=this.findBoxById(e);return p(io,r,`no box, id=${e}`),r}getBlockByIndex(e,r){const i=this.getContainerById(e);return zi(i,r)}findBlockByIndex(e,r){const i=this.getContainerById(e);return Cv(i,r)}getBlockIndex(e){if(typeof e=="string"){const r=this.getBlockById(e);return bt(r)}return bt(e)}getContainerById(e){return ui(this,e)}getParentContainer(e){return rt(e)}reloadBlock(e){lO(this,e)}contains(e){const r=e instanceof Element?e:e.parentElement;return r?r.closest("div.editor-root")===this.rootElement:!1}insertBlock(e,r,i,o,s){const l={blockId:i.id,offset:0},c={anchor:l,focus:l};return ka(this,e,r,i,o!=null?o:c,s)}insertEmbed(e,r,i,o,s){const l={id:Z(),type:"embed",embedType:i,embedData:o};return this.insertBlock(e,r,l,s)}deleteBlock(e,r){Z1(this,e,r)}mergeTextBlock(e,r){return XB(this,e,r)}breakTextBlock(e,r,i){return Ra(this,e,r,i).newBlock}getTextPosition(){return Ta(this)}getBlockString(e,r){const i=this.getBlockText(e);return fe(i,r)}getBlockData(e){return Wo(this,e)}getBoxData(e){return vB(this,e)}getBlockText(e){return bn(this,e)}setBlockText(e,r){JB(this,e,r)}deleteTextFromBlock(e,r,i,o){return Y1(this,e,r,i,o)}insertTextToBlock(e,r,i,o){return HB(this,e,r,i,o)}insertBoxToBlock(e,r,i){return jB(this,e,r,i)}pasteDoc(e){return this.inputHandlers.pasteDoc(e)}insertDoc(e,r,i,o){e5(this,e,r,i,o)}insertDocAt(e,r,i,o){return ip(this,e,r,i,o)}deleteChildContainers(e){qB(this,e)}replaceBlockText(e,r){return kh(this,e,r)}updateBlockData(e,r,i){const o={...this.getBlockData(e),...r},{id:s,type:l,...c}=o;return Rh(this,e,c,(i!=null?i:this.selection.range).toDocRange())}updateEmbedData(e,r,i){return ZB(this,e,r,i)}updateBoxData(e,r){uO(this,e,r)}getSelectedText(){const e=Sa(this);return ro(this,e)}clearSelectedContents(){yh(this)}insertTextBlock(e,r,i,o){const s=pi(e!=null?e:"");return WB(this,s,r,i,o==null?void 0:o.newRange,o==null?void 0:o.insertBlockOptions)}updateCompositionText(e,r){if(e&&!r&&(this.selection.range.isCollapsed()||this.clearSelectedContents()),!e&&!r){Q1(this);return}r?(this.compositingText="",Jc()?e||Q1(this):X1(this,e)):(this.compositingText=e,zB(this))}}function ku(n,t,e){return new gO(n,t,e)}function pO(n){const t=(r,i)=>{const o=r.findIndex(l=>l.id===i.id);if(o===-1){r.push(i);return}const s=r[o];if(s.value!==i.value){r.splice(o,1);return}if(!!s.states){if(!i.states){s.states=[];return}s.states=Tg.default(s.states,i.states)}},e=[];return n.forEach(r=>{r.forEach(i=>{t(e,i)})}),e}const CO=["#0064FF","#EB3723","#F59300","#00A865","#F25A0A","#70A310","#009CAD","#0990D9","#8851ED","#D62069"];class Ru extends Re.TypedEmitter{constructor(e){super();m(this,"users",new Map);m(this,"cursors",new Map);m(this,"addingUser",!1);m(this,"colors");this.colors=e&&e.length>0?e:CO}setCursor(e){this.addUser(e.user);const r=this.cursors.get(e.user.userId);if(r&&qc.default(r,e))return;this.cursors.set(e.user.userId,e);const i=new Set([e.range.anchor.blockId,e.range.focus.blockId]),o=new Set(i);r&&new Set([r.range.anchor.blockId,r.range.focus.blockId]).forEach(l=>{i.has(l)||o.add(l)}),this.emit("remote-carets-change",[...o])}addUsers(e){this.addingUser=!0,e.forEach(r=>this.addUser(r)),this.addingUser=!1,this.emit("change",Array.from(this.users.values()))}addUser(e){this.users.set(e.userId,e),this.addingUser||this.emit("change",Array.from(this.users.values()))}findUser(e){var r;return(r=this.users.get(e))!=null?r:null}removeUser(e){this.users.delete(e),this.emit("change",Array.from(this.users.values()));const r=this.cursors.get(e);if(r){const i=new Set(new Set([r==null?void 0:r.range.anchor.blockId,r==null?void 0:r.range.focus.blockId]));this.cursors.delete(e),this.emit("remote-carets-change",[...i])}}updateUsers(e){this.users.forEach(r=>{e.find(i=>i.userId===r.userId)||this.removeUser(r.userId)}),this.users.clear(),this.addingUser=!0;try{e.forEach(r=>{this.addUser(r)})}finally{this.addingUser=!1}setTimeout(()=>{this.emit("change",Array.from(this.users.values()))},300)}getSimpleCursors(e){const r=new Map;return Array.from(this.cursors.values()).filter(i=>i.range.anchor.blockId===e&&hh(i.range)).forEach(i=>{const o=i.range.focus.offset;let s=r.get(o);s||(s=[],r.set(o,s)),s.push(i)}),r}getCursors(e){return Array.from(this.cursors.values()).filter(r=>r.range.anchor.blockId===e||r.range.focus.blockId===e)}onUpdateBlockText(e,r,i){if(!e.text)return;this.getCursors(e.id).forEach(l=>{if(hh(l.range)){const{anchor:c,focus:d}=l.range;c.blockId===e.id&&(c.offset=fn.transformCursor(c.offset,r,i)),d.blockId===e.id&&(d.offset=fn.transformCursor(d.offset,r,i))}})}getFixedUserColor(e,r){let i=0;Array.from(e).forEach(s=>{i+=s.charCodeAt(0)});const o=i%this.colors.length;return this.colors[o]}destroy(){this.removeAllListeners()}}const rn=I("local-doc");class bp extends sa{constructor(e,r){super();m(this,"doc");m(this,"serviceUrl");e?this.doc=e:this.doc={meta:{},comments:{},blocks:{root:[pi("")]}},this.serviceUrl=(r==null?void 0:r.serverUrl)||""}beginBatchUpdate(){return 0}endBatchUpdate(){return 0}toJSON(){return gt.default(this.doc)}getContainerBlocks(e){return this.doc.blocks[e]}findContainerBlocks(e){return this.doc.blocks[e]}getBlockData(e,r){const i=this.getContainerBlocks(e);p(rn,i,`no container data: ${e}`);const o=i[r];return p(rn,o,`no block data: ${r}`),o}localUpdateBlockText(e,r,i){const o=this.getBlockData(e,r);p(rn,o.text,"no text for data");const s=fn.apply(o.text,i);return o.text=s,p(rn,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(l=>{var c;return(c=l.onUpdateBlockText)==null?void 0:c.call(l,e,r,i,!0)}),s}localUpdateBlockData(e,r,i){const o=this.getBlockData(e,r);return i.delete.forEach(s=>delete o[s]),Object.entries(i.insert).forEach(([s,l])=>{o[s]=l}),p(rn,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,e,r,i,!0)}),o}localInsertBlock(e,r,i){const o=this.getContainerBlocks(e);return p(rn,o,`no container data: ${e}`),p(rn,r>=0&&r<=o.length,`invalid block index: ${r}, ${o.length}`),o.splice(r,0,i),p(rn,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onInsertBlock)==null?void 0:l.call(s,e,r,i,!0)}),i}localDeleteBlock(e,r){const i=this.getContainerBlocks(e);p(rn,i,`no container data: ${e}`),p(rn,r>=0&&r<=i.length,`invalid block index: ${r}, ${i.length}`);const o=i[r];return i.splice(r,1),p(rn,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onDeleteBlock)==null?void 0:l.call(s,e,r,!0)}),o}localInsertChildContainers(e){e.forEach(({containerId:r,blocks:i})=>{this.doc.blocks[r]=i,p(rn,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(o=>{var s;return(s=o.onInsertChildContainer)==null?void 0:s.call(o,r,i,!0)})})}localDeleteChildContainers(e){rn.debug(`delete child containers: ${e}`),e.forEach(r=>{p(rn,this.doc.blocks[r],`no child container: ${r}`),delete this.doc.blocks[r]}),e.forEach(r=>{p(rn,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var o;return(o=i.onDeleteChildContainer)==null?void 0:o.call(i,r,!0)})})}uploadResource(e,r){p(rn,!1,"not implemented")}async addResources(e){return e}buildResourceUrl(e){return e}request(e,r){p(rn,!1,"not implemented")}broadcastMessage(e){}getServerMeta(){return{serverId:this.serviceUrl}}getUser(){return{permission:"w",userId:"-",displayName:"-",avatarUrl:"-",rainbowIndex:0}}getRemoteUsers(){return new Ru}setDoc(e){this.doc=gt.default(e),this.callbacks.forEach(r=>{var i;return(i=r.onRequestReload)==null?void 0:i.call(r,"change doc")})}destroy(){this.clearCallbacks()}}class EO{constructor(t){this.cleanup=t}destroy(){var t;(t=this.cleanup)==null||t.call(this)}}function vp(n,t,e){n.addCustom(t,()=>{var o;const r=(o=e())!=null?o:void 0;return new EO(r)})}const B2=I("find-block");function T2(n,t){const e=js(t);if(!e){if(dr(t))return null;const r=$s(t);return p(B2,r,"no parent block"),T2(n,r)}return Dt(n,e)?pa(n,e,{visibleOnly:!0}):e}function y2(n,t){const e=zs(t);if(!e){if(dr(t))return null;const r=$s(t);return p(B2,r,"no parent block"),y2(n,r)}return Dt(n,e)?s1(n,e,{visibleOnly:!0}):e}const xO=I("remote-cursor");class AO{constructor(){m(this,"remoteUsers",new Ru)}onCustomMessage(t){const e=t;if(e.type==="onlineUsers"){const r=e;this.handleUpdateUsers(r.users)}else e.type==="caret"?this.handleUpdateCaret(e):xO.debug(`unknown remote message received: ${t}`)}handleUpdateUsers(t){this.remoteUsers.updateUsers(t)}handleUpdateCaret(t){const e=this.remoteUsers.findUser(t.userId);!e||this.remoteUsers.setCursor({oneseditor:"cursor",user:e,range:t.range,time:Date.now()})}destroy(){this.remoteUsers.destroy()}}function bO(n){const{blocks:t,meta:e,comments:r,...i}=n;return{rootBlocks:t,meta:e,comments:r,childBlocks:i}}function vO(n){const{blocks:t,meta:e,comments:r}=n,{root:i,...o}=t;return{blocks:i,meta:e,comments:r,...o}}function oo(n){const{childBlocks:t,meta:e,comments:r,rootBlocks:i}=bO(gt.default(n));return{blocks:{root:i,...t},meta:e,comments:r}}function so(n){return n==="root"?"blocks":n}function Ma(n){return n==="blocks"?"root":n}const BO={type:{name:"rich-text",uri:"http://sharejs.org/types/rich-text/v1",create(n){return new cn.default(n)},apply(n,t){const e=new cn.default(n),r=new cn.default(t);return e.compose(r).ops},compose(n,t){const e=new cn.default(n),r=new cn.default(t);return e.compose(r).ops},diff(n,t){const e=new cn.default(n),r=new cn.default(t);return e.diff(r).ops},transform(n,t,e){const r=new cn.default(n);return new cn.default(t).transform(r,e==="left").ops},transformCursor(n,t,e){return t.transformPosition(n,!e)},normalize(n){return n},serialize(n){return n.ops},deserialize(n){return n},transformPresence(n,t,e){if(!n)return null;const r=new cn.default(t),i=this.transformCursor(n.index,r,e),o=this.transformCursor(n.index+n.length,r,e);return{...n,index:i,length:o-i}}}};var Yo={},Bp=Cb.default.EventEmitter;Yo.EventEmitter=Bp,Yo.mixin=TO;function TO(n){for(var t in Bp.prototype)n.prototype[t]=Bp.prototype[t]}var k2=["info","warn","error"];function R2(){var n={};k2.forEach(function(t){n[t]=console[t].bind(console)}),this.setMethods(n)}var yO=R2;R2.prototype.setMethods=function(n){n=n||{};var t=this;k2.forEach(function(e){typeof n[e]=="function"&&(t[e]=n[e])})};var kO=yO,RO=new kO,w2=RO;function nl(n,t){this.code=n,this.message=t||"",Error.captureStackTrace?Error.captureStackTrace(this,nl):this.stack=new Error().stack}nl.prototype=Object.create(Error.prototype),nl.prototype.constructor=nl,nl.prototype.name="ShareDBError",nl.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 Nh=nl,wu={},S2=wO;function wO(n,t,e,r){var i=function(s,l,c,d){t(c,s,l,"left"),t(d,l,s,"right")},o=n.transformX=function(s,l){e(s),e(l);for(var c=[],d=0;d<l.length;d++){for(var h=l[d],C=[],E=0;E<s.length;){var A=[];if(i(s[E],h,C,A),E++,A.length===1)h=A[0];else if(A.length===0){for(var v=E;v<s.length;v++)r(C,s[v]);h=null;break}else{for(var R=o(s.slice(E),A),L=0;L<R[0].length;L++)r(C,R[0][L]);for(var M=0;M<R[1].length;M++)r(c,R[1][M]);h=null;break}}h!=null&&r(c,h),s=C}return[s,c]};n.transform=function(s,l,c){if(!(c==="left"||c==="right"))throw new Error("type must be 'left' or 'right'");return l.length===0?s:s.length===1&&l.length===1?t([],s[0],l[0],c):c==="left"?o(s,l)[0]:o(l,s)[1]}}var L2={exports:{}},Jo=L2.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||""}},Tp=function(n,t,e){return n.slice(0,t)+e+n.slice(t)},yp=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")},Ph=function(n){for(var t=0;t<n.length;t++)yp(n[t])};Jo.apply=function(n,t){var e;Ph(t);for(var r=0;r<t.length;r++){var i=t[r];if(i.i!=null)n=Tp(n,i.p,i.i);else{if(e=n.slice(i.p,i.p+i.d.length),i.d!==e)throw new Error("Delete component '"+i.d+"' does not match deleted text '"+e+"'");n=n.slice(0,i.p)+n.slice(i.p+i.d.length)}}return n};var lo=Jo._append=function(n,t){if(!(t.i===""||t.d===""))if(n.length===0)n.push(t);else{var e=n[n.length-1];e.i!=null&&t.i!=null&&e.p<=t.p&&t.p<=e.p+e.i.length?n[n.length-1]={i:Tp(e.i,t.p-e.p,t.i),p:e.p}:e.d!=null&&t.d!=null&&t.p<=e.p&&e.p<=t.p+t.d.length?n[n.length-1]={d:Tp(t.d,e.p-t.p,e.d),p:t.p}:n.push(t)}};Jo.compose=function(n,t){Ph(n),Ph(t);for(var e=n.slice(),r=0;r<t.length;r++)lo(e,t[r]);return e},Jo.normalize=function(n){var t=[];(n.i!=null||n.p!=null)&&(n=[n]);for(var e=0;e<n.length;e++){var r=n[e];r.p==null&&(r.p=0),lo(t,r)}return t};var kp=function(n,t,e){return t.i!=null?t.p<n||t.p===n&&e?n+t.i.length:n:n<=t.p?n:n<=t.p+t.d.length?t.p:n-t.d.length};Jo.transformCursor=function(n,t,e){for(var r=e==="right",i=0;i<t.length;i++)n=kp(n,t[i],r);return n};var SO=Jo._tc=function(n,t,e,r){if(yp(t),yp(e),t.i!=null)lo(n,{i:t.i,p:kp(t.p,e,r==="right")});else if(e.i!=null){var i=t.d;t.p<e.p&&(lo(n,{d:i.slice(0,e.p-t.p),p:t.p}),i=i.slice(e.p-t.p)),i!==""&&lo(n,{d:i,p:t.p+e.i.length})}else if(t.p>=e.p+e.d.length)lo(n,{d:t.d,p:t.p-e.d.length});else if(t.p+t.d.length<=e.p)lo(n,t);else{var o={d:"",p:t.p};t.p<e.p&&(o.d=t.d.slice(0,e.p-t.p)),t.p+t.d.length>e.p+e.d.length&&(o.d+=t.d.slice(e.p+e.d.length-t.p));var s=Math.max(t.p,e.p),l=Math.min(t.p+t.d.length,e.p+e.d.length),c=t.d.slice(s-t.p,l-t.p),d=e.d.slice(s-e.p,l-e.p);if(c!==d)throw new Error("Delete ops delete different text in the same region of the document");o.d!==""&&(o.p=kp(o.p,e),lo(n,o))}return n},LO=function(n){return n.i!=null?{d:n.i,p:n.p}:{i:n.d,p:n.p}};Jo.invert=function(n){n=n.slice().reverse();for(var t=0;t<n.length;t++)n[t]=LO(n[t]);return n},S2(Jo,SO,Ph,lo);var Fh=function(n){return Object.prototype.toString.call(n)=="[object Array]"},IO=function(n){return!!n&&n.constructor===Object},Kr=function(n){return JSON.parse(JSON.stringify(n))},Lt={name:"json0",uri:"http://sharejs.org/types/JSONv0"},ao={};Lt.registerSubtype=function(n){ao[n.name]=n},Lt.create=function(n){return n===void 0?null:Kr(n)},Lt.invertComponent=function(n){var t={p:n.p};return n.t&&ao[n.t]&&(t.t=n.t,t.o=ao[n.t].invert(n.o)),n.si!==void 0&&(t.sd=n.si),n.sd!==void 0&&(t.si=n.sd),n.oi!==void 0&&(t.od=n.oi),n.od!==void 0&&(t.oi=n.od),n.li!==void 0&&(t.ld=n.li),n.ld!==void 0&&(t.li=n.ld),n.na!==void 0&&(t.na=-n.na),n.lm!==void 0&&(t.lm=n.p[n.p.length-1],t.p=n.p.slice(0,n.p.length-1).concat([n.lm])),t},Lt.invert=function(n){for(var t=n.slice().reverse(),e=[],r=0;r<t.length;r++)e.push(Lt.invertComponent(t[r]));return e},Lt.checkValidOp=function(n){for(var t=0;t<n.length;t++)if(!Fh(n[t].p))throw new Error("Missing path")},Lt.checkList=function(n){if(!Fh(n))throw new Error("Referenced element not a list")},Lt.checkObj=function(n){if(!IO(n))throw new Error("Referenced element not an object (it was "+JSON.stringify(n)+")")};function Su(n){n.t="text0";var t={p:n.p.pop()};n.si!=null&&(t.i=n.si),n.sd!=null&&(t.d=n.sd),n.o=[t]}function Lu(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}Lt.apply=function(n,t){Lt.checkValidOp(t),t=Kr(t);for(var e={data:n},r=0;r<t.length;r++){var i=t[r];(i.si!=null||i.sd!=null)&&Su(i);for(var o=null,s=e,l="data",c=0;c<i.p.length;c++){var d=i.p[c];if(o=s,s=s[l],l=d,o==null)throw new Error("Path invalid")}if(i.t&&i.o!==void 0&&ao[i.t])s[l]=ao[i.t].apply(s[l],i.o);else if(i.na!==void 0){if(typeof s[l]!="number")throw new Error("Referenced element not a number");s[l]+=i.na}else if(i.li!==void 0&&i.ld!==void 0)Lt.checkList(s),s[l]=i.li;else if(i.li!==void 0)Lt.checkList(s),s.splice(l,0,i.li);else if(i.ld!==void 0)Lt.checkList(s),s.splice(l,1);else if(i.lm!==void 0){if(Lt.checkList(s),i.lm!=l){var h=s[l];s.splice(l,1),s.splice(i.lm,0,h)}}else if(i.oi!==void 0)Lt.checkObj(s),s[l]=i.oi;else if(i.od!==void 0)Lt.checkObj(s),delete s[l];else throw new Error("invalid / missing instruction in op")}return e.data},Lt.shatter=function(n){for(var t=[],e=0;e<n.length;e++)t.push([n[e]]);return t},Lt.incrementalApply=function(n,t,e){for(var r=0;r<t.length;r++){var i=[t[r]];n=Lt.apply(n,i),e(i,n)}return n};var DO=Lt.pathMatches=function(n,t,e){if(n.length!=t.length)return!1;for(var r=0;r<n.length;r++)if(n[r]!==t[r]&&(!e||r!==n.length-1))return!1;return!0};Lt.append=function(n,t){if(t=Kr(t),n.length===0){n.push(t);return}var e=n[n.length-1];if((t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(Su(t),Su(e)),DO(t.p,e.p))if(t.t&&e.t&&t.t===e.t&&ao[t.t]){if(e.o=ao[t.t].compose(e.o,t.o),t.si!=null||t.sd!=null){for(var r=t.p,i=0;i<e.o.length-1;i++)t.o=[e.o.pop()],t.p=r.slice(),Lu(t),n.push(t);Lu(e)}}else e.na!=null&&t.na!=null?n[n.length-1]={p:e.p,na:e.na+t.na}:e.li!==void 0&&t.li===void 0&&t.ld===e.li?e.ld!==void 0?delete e.li:n.pop():e.od!==void 0&&e.oi===void 0&&t.oi!==void 0&&t.od===void 0?e.oi=t.oi:e.oi!==void 0&&t.od!==void 0?t.oi!==void 0?e.oi=t.oi:e.od!==void 0?delete e.oi:n.pop():t.lm!==void 0&&t.p[t.p.length-1]===t.lm||n.push(t);else(t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(Lu(t),Lu(e)),n.push(t)},Lt.compose=function(n,t){Lt.checkValidOp(n),Lt.checkValidOp(t);for(var e=Kr(n),r=0;r<t.length;r++)Lt.append(e,t[r]);return e},Lt.normalize=function(n){var t=[];n=Fh(n)?n:[n];for(var e=0;e<n.length;e++){var r=n[e];r.p==null&&(r.p=[]),Lt.append(t,r)}return t},Lt.commonLengthForOps=function(n,t){var e=n.p.length,r=t.p.length;if((n.na!=null||n.t)&&e++,(t.na!=null||t.t)&&r++,e===0)return-1;if(r===0)return null;e--,r--;for(var i=0;i<e;i++){var o=n.p[i];if(i>=r||o!==t.p[i])return null}return e},Lt.canOpAffectPath=function(n,t){return Lt.commonLengthForOps({p:t},n)!=null},Lt.transformComponent=function(n,t,e,r){t=Kr(t);var i=Lt.commonLengthForOps(e,t),o=Lt.commonLengthForOps(t,e),s=t.p.length,l=e.p.length;if((t.na!=null||t.t)&&s++,(e.na!=null||e.t)&&l++,o!=null&&l>s&&t.p[o]==e.p[o]){if(t.ld!==void 0){var c=Kr(e);c.p=c.p.slice(s),t.ld=Lt.apply(Kr(t.ld),[c])}else if(t.od!==void 0){var c=Kr(e);c.p=c.p.slice(s),t.od=Lt.apply(Kr(t.od),[c])}}if(i!=null){var d=s==l,c=e;if((t.si!=null||t.sd!=null)&&(e.si!=null||e.sd!=null)&&(Su(t),c=Kr(e),Su(c)),c.t&&ao[c.t]){if(t.t&&t.t===c.t){var h=ao[t.t].transform(t.o,c.o,r);if(t.si!=null||t.sd!=null)for(var C=t.p,E=0;E<h.length;E++)t.o=[h[E]],t.p=C.slice(),Lu(t),Lt.append(n,t);else(!Fh(h)||h.length>0)&&(t.o=h,Lt.append(n,t));return n}}else if(e.na===void 0){if(e.li!==void 0&&e.ld!==void 0){if(e.p[i]===t.p[i])if(d){if(t.ld!==void 0)if(t.li!==void 0&&r==="left")t.ld=Kr(e.li);else return n}else return n}else if(e.li!==void 0)t.li!==void 0&&t.ld===void 0&&d&&t.p[i]===e.p[i]?r==="right"&&t.p[i]++:e.p[i]<=t.p[i]&&t.p[i]++,t.lm!==void 0&&d&&e.p[i]<=t.lm&&t.lm++;else if(e.ld!==void 0){if(t.lm!==void 0&&d){if(e.p[i]===t.p[i])return n;var C=e.p[i],A=t.p[i],v=t.lm;(C<v||C===v&&A<v)&&t.lm--}if(e.p[i]<t.p[i])t.p[i]--;else if(e.p[i]===t.p[i]){if(l<s)return n;if(t.ld!==void 0)if(t.li!==void 0)delete t.ld;else return n}}else if(e.lm!==void 0)if(t.lm!==void 0&&s===l){var A=t.p[i],v=t.lm,R=e.p[i],L=e.lm;if(R!==L)if(A===R)if(r==="left")t.p[i]=L,A===v&&(t.lm=L);else return n;else A>R&&t.p[i]--,A>L?t.p[i]++:A===L&&R>L&&(t.p[i]++,A===v&&t.lm++),(v>R||v===R&&v>A)&&t.lm--,v>L?t.lm++:v===L&&(L>R&&v>A||L<R&&v<A?r==="right"&&t.lm++:v>A?t.lm++:v===R&&t.lm--)}else if(t.li!==void 0&&t.ld===void 0&&d){var A=e.p[i],v=e.lm;C=t.p[i],C>A&&t.p[i]--,C>v&&t.p[i]++}else{var A=e.p[i],v=e.lm;C=t.p[i],C===A?t.p[i]=v:(C>A&&t.p[i]--,(C>v||C===v&&A>v)&&t.p[i]++)}else if(e.oi!==void 0&&e.od!==void 0){if(t.p[i]===e.p[i])if(t.oi!==void 0&&d){if(r==="right")return n;t.od=e.oi}else return n}else if(e.oi!==void 0){if(t.oi!==void 0&&t.p[i]===e.p[i])if(r==="left")Lt.append(n,{p:t.p,od:e.oi});else return n}else if(e.od!==void 0&&t.p[i]==e.p[i]){if(!d)return n;if(t.oi!==void 0)delete t.od;else return n}}}return Lt.append(n,t),n},S2(Lt,Lt.transformComponent,Lt.checkValidOp,Lt.append);var _O=L2.exports;Lt.registerSubtype(_O);var MO=Lt,UO={type:MO};(function(n){n.defaultType=UO.type,n.map={},n.register=function(t){t.name&&(n.map[t.name]=t),t.uri&&(n.map[t.uri]=t)},n.register(n.defaultType)})(wu);var Vr={};(function(n){n.doNothing=t;function t(){}n.hasKeys=function(e){for(var r in e)return!0;return!1},n.isInteger=Number.isInteger||function(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e},n.isValidVersion=function(e){return e===null?!0:n.isInteger(e)&&e>=0},n.isValidTimestamp=function(e){return n.isValidVersion(e)},n.MAX_SAFE_INTEGER=9007199254740991,n.dig=function(){for(var e=arguments[0],r=1;r<arguments.length;r++){var i=arguments[r];e=e[i]||(r===arguments.length-1?void 0:{})}return e},n.digOrCreate=function(){for(var e=arguments[0],r=arguments[arguments.length-1],i=1;i<arguments.length-1;i++){var o=arguments[i];e=e[o]||(e[o]=i===arguments.length-2?r():{})}return e},n.digAndRemove=function(){for(var e=arguments[0],r=[e],i=1;i<arguments.length-1;i++){var o=arguments[i];if(!e.hasOwnProperty(o))break;e=e[o],r.push(e)}for(var i=r.length-1;i>=0;i--){var s=r[i],o=arguments[i+1],l=s[o];(i===r.length-1||!n.hasKeys(l))&&delete s[o]}},n.supportsPresence=function(e){return e&&typeof e.transformPresence=="function"},n.callEach=function(e,r){var i=!1;return e.forEach(function(o){o&&(o(r),i=!0)}),i},n.truthy=function(e){return!!e},n.nextTick=function(e){if(typeof process<"u"&&process.nextTick)return process.nextTick.apply(null,arguments);for(var r=[],i=1;i<arguments.length;i++)r[i-1]=arguments[i];setTimeout(function(){e.apply(null,r)})},n.clone=function(e){return e===void 0?void 0:JSON.parse(JSON.stringify(e))}})(Vr);var I2=Array.isArray,D2=Object.keys,OO=Object.prototype.hasOwnProperty,NO=function n(t,e){if(t===e)return!0;if(t&&e&&typeof t=="object"&&typeof e=="object"){var r=I2(t),i=I2(e),o,s,l;if(r&&i){if(s=t.length,s!=e.length)return!1;for(o=s;o--!==0;)if(!n(t[o],e[o]))return!1;return!0}if(r!=i)return!1;var c=t instanceof Date,d=e instanceof Date;if(c!=d)return!1;if(c&&d)return t.getTime()==e.getTime();var h=t instanceof RegExp,C=e instanceof RegExp;if(h!=C)return!1;if(h&&C)return t.toString()==e.toString();var E=D2(t);if(s=E.length,s!==D2(e).length)return!1;for(o=s;o--!==0;)if(!OO.call(e,E[o]))return!1;for(o=s;o--!==0;)if(l=E[o],!n(t[l],e[l]))return!1;return!0}return t!==t&&e!==e},_2=Yo,PO=w2,Zn=Nh,Kh=wu,$r=Vr,FO=$r.clone,KO=NO,Nn=Zn.CODES,VO=Ft;function Ft(n,t,e){_2.EventEmitter.call(this),this.connection=n,this.collection=t,this.id=e,this.version=null,this.type=null,this.data=void 0,this.inflightFetch=[],this.inflightSubscribe=null,this.pendingFetch=[],this.pendingSubscribe=[],this.subscribed=!1,this.wantSubscribe=!1,this._wantsDestroy=!1,this.inflightOp=null,this.pendingOps=[],this.type=null,this.applyStack=null,this.preventCompose=!1,this.submitSource=!1,this.paused=!1,this._dataStateVersion=0}_2.mixin(Ft),Ft.prototype.destroy=function(n){this._wantsDestroy=!0;var t=this;t.whenNothingPending(function(){t.wantSubscribe?t.unsubscribe(function(e){if(e)return n?n(e):t.emit("error",e);t.connection._destroyDoc(t),n&&n()}):(t.connection._destroyDoc(t),n&&n())})},Ft.prototype._setType=function(n){if(typeof n=="string"&&(n=Kh.map[n]),n)this.type=n;else if(n===null)this.type=n,this._setData(void 0);else{var t=new Zn(Nn.ERR_DOC_TYPE_NOT_RECOGNIZED,"Missing type "+n);return this.emit("error",t)}},Ft.prototype._setData=function(n){this.data=n,this._dataStateVersion++},Ft.prototype.ingestSnapshot=function(n,t){if(!n)return t&&t();if(typeof n.v!="number"){var e=new Zn(Nn.ERR_INGESTED_SNAPSHOT_HAS_NO_VERSION,"Missing version in ingested snapshot. "+this.collection+"."+this.id);return t?t(e):this.emit("error",e)}if(this.type||this.hasWritePending()){if(this.version==null){if(this.hasWritePending())return t&&this.once("no write pending",t);var e=new Zn(Nn.ERR_DOC_MISSING_VERSION,"Cannot ingest snapshot in doc with null version. "+this.collection+"."+this.id);return t?t(e):this.emit("error",e)}return n.v>this.version?this.fetch(t):t&&t()}if(this.version>n.v)return t&&t();this.version=n.v;var r=n.type===void 0?Kh.defaultType:n.type;this._setType(r),this._setData(this.type&&this.type.deserialize?this.type.deserialize(n.data):n.data),this.emit("load"),t&&t()},Ft.prototype.whenNothingPending=function(n){var t=this;$r.nextTick(function(){if(t.hasPending()){t.once("nothing pending",n);return}n()})},Ft.prototype.hasPending=function(){return!!(this.inflightOp||this.pendingOps.length||this.inflightFetch.length||this.inflightSubscribe||this.pendingFetch.length||this.pendingSubscribe.length)},Ft.prototype.hasWritePending=function(){return!!(this.inflightOp||this.pendingOps.length)},Ft.prototype._emitNothingPending=function(){this.hasWritePending()||(this.emit("no write pending"),!this.hasPending()&&this.emit("nothing pending"))},Ft.prototype._emitResponseError=function(n,t){if(n&&n.code===Nn.ERR_SNAPSHOT_READ_SILENT_REJECTION){this.wantSubscribe=!1,t&&t(),this._emitNothingPending();return}if(t){t(n),this._emitNothingPending();return}this._emitNothingPending(),this.emit("error",n)},Ft.prototype._handleFetch=function(n,t){var e=this.pendingFetch;this.pendingFetch=[];var r=this.inflightFetch.shift();if(r&&e.push(r),e.length&&(r=function(i){$r.callEach(e,i)}),n)return this._emitResponseError(n,r);this.ingestSnapshot(t,r),this._emitNothingPending()},Ft.prototype._handleSubscribe=function(n,t){var e=this.inflightSubscribe;this.inflightSubscribe=null;var r=this.pendingFetch;this.pendingFetch=[],e.callback&&r.push(e.callback);var i;if(r.length&&(i=function(o){$r.callEach(r,o)}),n)return this._emitResponseError(n,i);this.subscribed=e.wantSubscribe,this.subscribed?this.ingestSnapshot(t,i):i&&i(),this._emitNothingPending(),this._flushSubscribe()},Ft.prototype._handleOp=function(n,t){if(n)return this.inflightOp?(n.code===Nn.ERR_OP_SUBMIT_REJECTED&&(n=null),this._rollback(n)):this.emit("error",n);if(this.inflightOp&&t.src===this.inflightOp.src&&t.seq===this.inflightOp.seq){this._opAcknowledged(t);return}if(this.version==null||t.v>this.version){this.fetch();return}if(!(t.v<this.version)){if(this.inflightOp){var e=Vh(this.inflightOp,t);if(e)return this._hardRollback(e)}for(var r=0;r<this.pendingOps.length;r++){var e=Vh(this.pendingOps[r],t);if(e)return this._hardRollback(e)}this.version++;try{this._otApply(t,!1)}catch(i){return this._hardRollback(i)}}},Ft.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))},Ft.prototype._resubscribe=function(){if(!this.pendingSubscribe.length&&this.wantSubscribe)return this.subscribe();var n=this.pendingSubscribe.some(function(t){return t.wantSubscribe});!n&&this.pendingFetch.length&&this.fetch(),this._flushSubscribe()},Ft.prototype.fetch=function(n){if(this.connection.canSend){var t=this.connection.sendFetch(this);$O(this.inflightFetch,t,n);return}this.pendingFetch.push(n)},Ft.prototype.subscribe=function(n){var t=!0;this._queueSubscribe(t,n)},Ft.prototype.unsubscribe=function(n){var t=!1;this._queueSubscribe(t,n)},Ft.prototype._queueSubscribe=function(n,t){var e=this.pendingSubscribe[this.pendingSubscribe.length-1]||this.inflightSubscribe,r=e&&e.wantSubscribe===n;if(r){e.callback=HO([e.callback,t]);return}this.pendingSubscribe.push({wantSubscribe:!!n,callback:t}),this._flushSubscribe()},Ft.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;$r.nextTick(function(){n._handleSubscribe()})}}};function $O(n,t,e){if(t){var r=n.pop();n.push(function(i){r&&r(i),e&&e(i)})}else n.push(e)}function HO(n){return n=n.filter($r.truthy),n.length?function(t){$r.callEach(n,t)}:null}Ft.prototype.flush=function(){!this.connection.canSend||this.inflightOp||!this.paused&&this.pendingOps.length&&this._sendOp()};function jO(n){delete n.op,delete n.create,delete n.del}function Vh(n,t){if(n.del)return jO(t);if(t.del)return new Zn(Nn.ERR_DOC_WAS_DELETED,"Document was deleted");if(t.create)return new Zn(Nn.ERR_DOC_ALREADY_CREATED,"Document already created");if("op"in t){if(n.create)return new Zn(Nn.ERR_DOC_ALREADY_CREATED,"Document already created");if(n.type.transformX){var e=n.type.transformX(n.op,t.op);n.op=e[0],t.op=e[1]}else{var r=n.type.transform(n.op,t.op,"left"),i=n.type.transform(t.op,n.op,"right");n.op=r,t.op=i}}}Ft.prototype._otApply=function(n,t){if("op"in n){if(!this.type)throw new Zn(Nn.ERR_DOC_DOES_NOT_EXIST,"Cannot apply op to uncreated document. "+this.collection+"."+this.id);if(this.emit("before op batch",n.op,t),!t&&this.type===Kh.defaultType&&n.op.length>1){this.applyStack||(this.applyStack=[]);for(var e=this.applyStack.length,r=0;r<n.op.length;r++){var i=n.op[r],o={op:[i]};this.emit("before op",o.op,t,n.src);for(var s=e;s<this.applyStack.length;s++){var l=Vh(this.applyStack[s],o);if(l)return this._hardRollback(l)}this._setData(this.type.apply(this.data,o.op)),this.emit("op",o.op,t,n.src)}this.emit("op batch",n.op,t),this._popApplyStack(e);return}this.emit("before op",n.op,t,n.src),this._setData(this.type.apply(this.data,n.op)),this.emit("op",n.op,t,n.src),this.emit("op batch",n.op,t);return}if(n.create){this._setType(n.create.type),this.type.deserialize?this.type.createDeserialized?this._setData(this.type.createDeserialized(n.create.data)):this._setData(this.type.deserialize(this.type.create(n.create.data))):this._setData(this.type.create(n.create.data)),this.emit("create",t);return}if(n.del){var c=this.data;this._setType(null),this.emit("del",c,t);return}},Ft.prototype._sendOp=function(){if(!!this.connection.canSend){var n=this.connection.id;this.inflightOp||(this.inflightOp=this.pendingOps.shift());var t=this.inflightOp;if(!t){var e=new Zn(Nn.ERR_INFLIGHT_OP_MISSING,"No op to send on call to _sendOp");return this.emit("error",e)}if(t.sentAt=Date.now(),t.retries=t.retries==null?0:t.retries+1,t.seq==null){if(this.connection.seq>=$r.MAX_SAFE_INTEGER)return this.emit("error",new Zn(Nn.ERR_CONNECTION_SEQ_INTEGER_OVERFLOW,"Connection seq has exceeded the max safe integer, maybe from being open for too long"));t.seq=this.connection.seq++}this.connection.sendOp(this,t),t.src==null&&(t.src=n)}},Ft.prototype._submit=function(n,t,e){if(t||(t=!0),"op"in n){if(!this.type){var r=new Zn(Nn.ERR_DOC_DOES_NOT_EXIST,"Cannot submit op. Document has not been created. "+this.collection+"."+this.id);return e?e(r):this.emit("error",r)}this.type.normalize&&(n.op=this.type.normalize(n.op))}try{this._pushOp(n,t,e),this._otApply(n,t)}catch(o){return this._hardRollback(o)}var i=this;$r.nextTick(function(){i.flush()})},Ft.prototype._pushOp=function(n,t,e){if(n.source=t,this.applyStack)this.applyStack.push(n);else{var r=this._tryCompose(n);if(r){r.callbacks.push(e);return}}n.type=this.type,n.callbacks=[e],this.pendingOps.push(n)},Ft.prototype._popApplyStack=function(n){if(n>0){this.applyStack.length=n;return}var t=this.applyStack[0];if(this.applyStack=null,!!t){var e=this.pendingOps.indexOf(t);if(e!==-1)for(var r=this.pendingOps.splice(e),e=0;e<r.length;e++){var t=r[e],i=this._tryCompose(t);i?i.callbacks=i.callbacks.concat(t.callbacks):this.pendingOps.push(t)}}},Ft.prototype._tryCompose=function(n){if(!this.preventCompose){var t=this.pendingOps[this.pendingOps.length-1];if(!(!t||t.sentAt)&&!(this.submitSource&&!KO(n.source,t.source))){if(t.create&&"op"in n)return t.create.data=this.type.apply(t.create.data,n.op),t;if("op"in t&&"op"in n&&this.type.compose)return t.op=this.type.compose(t.op,n.op),t}}},Ft.prototype.submitOp=function(n,t,e){typeof t=="function"&&(e=t,t=null);var r={op:n},i=t&&t.source;this._submit(r,i,e)},Ft.prototype.create=function(n,t,e,r){if(typeof t=="function"?(r=t,e=null,t=null):typeof e=="function"&&(r=e,e=null),t||(t=Kh.defaultType.uri),this.type){var i=new Zn(Nn.ERR_DOC_ALREADY_CREATED,"Document already exists");return r?r(i):this.emit("error",i)}var o={create:{type:t,data:n}},s=e&&e.source;this._submit(o,s,r)},Ft.prototype.del=function(n,t){if(typeof n=="function"&&(t=n,n=null),!this.type){var e=new Zn(Nn.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");return t?t(e):this.emit("error",e)}var r={del:!0},i=n&&n.source;this._submit(r,i,t)},Ft.prototype.pause=function(){this.paused=!0},Ft.prototype.resume=function(){this.paused=!1,this.flush()},Ft.prototype.toSnapshot=function(){return{v:this.version,data:FO(this.data),type:this.type.uri}},Ft.prototype._opAcknowledged=function(n){if(this.inflightOp.create)this.version=n.v;else if(n.v!==this.version)return PO.warn("Invalid version from server. Expected: "+this.version+" Received: "+n.v,n),this.fetch();this.version++,this._clearInflightOp()},Ft.prototype._rollback=function(n){var t=this.inflightOp;if("op"in t&&t.type.invert){try{t.op=t.type.invert(t.op)}catch{return this._hardRollback(n)}for(var e=0;e<this.pendingOps.length;e++){var r=Vh(this.pendingOps[e],t);if(r)return this._hardRollback(r)}try{this._otApply(t,!1)}catch(i){return this._hardRollback(i)}this._clearInflightOp(n);return}this._hardRollback(n)},Ft.prototype._hardRollback=function(n){var t=[];this.inflightOp&&t.push(this.inflightOp),t=t.concat(this.pendingOps),this._setType(null),this.version=null,this.inflightOp=null,this.pendingOps=[];var e=this;this.fetch(function(){for(var r=!!t.length,i=0;i<t.length;i++)r=$r.callEach(t[i].callbacks,n)&&r;if(n&&!r)return e.emit("error",n)})},Ft.prototype._clearInflightOp=function(n){var t=this.inflightOp;this.inflightOp=null;var e=$r.callEach(t.callbacks,n);if(this.flush(),this._emitNothingPending(),n&&!e)return this.emit("error",n)};var rl={};rl.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 M2=Yo,U2=rl.ACTIONS,zO=Vr,GO=Pn;function Pn(n,t,e,r,i,o,s){M2.EventEmitter.call(this),this.action=n,this.connection=t,this.id=e,this.collection=r,this.query=i,this.results=null,o&&o.results&&(this.results=o.results,delete o.results),this.extra=void 0,this.options=o,this.callback=s,this.ready=!1,this.sent=!1}M2.mixin(Pn),Pn.prototype.hasPending=function(){return!this.ready},Pn.prototype.send=function(){if(!!this.connection.canSend){var n={a:this.action,id:this.id,c:this.collection,q:this.query};if(this.options&&(n.o=this.options),this.results){for(var t=[],e=0;e<this.results.length;e++){var r=this.results[e];t.push([r.id,r.version])}n.r=t}this.connection.send(n),this.sent=!0}},Pn.prototype.destroy=function(n){this.connection.canSend&&this.action===U2.querySubscribe&&this.connection.send({a:U2.queryUnsubscribe,id:this.id}),this.connection._destroyQuery(this),n&&zO.nextTick(n)},Pn.prototype._onConnectionStateChanged=function(){this.connection.canSend&&!this.sent?this.send():this.sent=!1},Pn.prototype._handleFetch=function(n,t,e){this.connection._destroyQuery(this),this._handleResponse(n,t,e)},Pn.prototype._handleSubscribe=function(n,t,e){this._handleResponse(n,t,e)},Pn.prototype._handleResponse=function(n,t,e){var r=this.callback;if(this.callback=null,n)return this._finishResponse(n,r);if(!t)return this._finishResponse(null,r);var i=this,o=1,s=function(h){if(h)return i._finishResponse(h,r);--o||i._finishResponse(null,r)};if(Array.isArray(t))o+=t.length,this.results=this._ingestSnapshots(t,s),this.extra=e;else for(var l in t){o++;var c=t[l],d=this.connection.get(c.c||this.collection,l);d.ingestSnapshot(c,s)}s()},Pn.prototype._ingestSnapshots=function(n,t){for(var e=[],r=0;r<n.length;r++){var i=n[r],o=this.connection.get(i.c||this.collection,i.d);o.ingestSnapshot(i,t),e.push(o)}return e},Pn.prototype._finishResponse=function(n,t){if(this.emit("ready"),this.ready=!0,n)return this.connection._destroyQuery(this),t?t(n):this.emit("error",n);t&&t(null,this.results,this.extra)},Pn.prototype._handleError=function(n){this.emit("error",n)},Pn.prototype._handleDiff=function(n){for(var t=0;t<n.length;t++){var e=n[t];e.type==="insert"&&(e.values=this._ingestSnapshots(e.values))}for(var t=0;t<n.length;t++){var e=n[t];switch(e.type){case"insert":var r=e.values;Array.prototype.splice.apply(this.results,[e.index,0].concat(r)),this.emit("insert",r,e.index);break;case"remove":var o=e.howMany||1,i=this.results.splice(e.index,o);this.emit("remove",i,e.index);break;case"move":var o=e.howMany||1,s=this.results.splice(e.from,o);Array.prototype.splice.apply(this.results,[e.to,0].concat(s)),this.emit("move",s,e.from,e.to);break}}this.emit("changed",this.results)},Pn.prototype._handleExtra=function(n){this.extra=n,this.emit("extra",n)};var O2=Yo,WO=rl.ACTIONS,qO=Vr,N2=Ei;function Ei(n,t){if(O2.EventEmitter.call(this),!t||typeof t!="string")throw new Error("LocalPresence presenceId must be a string");this.presence=n,this.presenceId=t,this.connection=n.connection,this.presenceVersion=0,this.value=null,this._pendingMessages=[],this._callbacksByPresenceVersion={}}O2.mixin(Ei),Ei.prototype.submit=function(n,t){this.value=n,this.send(t)},Ei.prototype.send=function(n){var t=this._message();this._pendingMessages.push(t),this._callbacksByPresenceVersion[t.pv]=n,this._sendPending()},Ei.prototype.destroy=function(n){var t=this;this.submit(null,function(e){if(e)return t._callbackOrEmit(e,n);delete t.presence.localPresences[t.presenceId],n&&n()})},Ei.prototype._sendPending=function(){if(!!this.connection.canSend){var n=this;this._pendingMessages.forEach(function(t){n.connection.send(t)}),this._pendingMessages=[]}},Ei.prototype._ack=function(n,t){var e=this._getCallback(t);this._callbackOrEmit(n,e)},Ei.prototype._message=function(){return{a:WO.presence,ch:this.presence.channel,id:this.presenceId,p:this.value,pv:this.presenceVersion++}},Ei.prototype._getCallback=function(n){var t=this._callbacksByPresenceVersion[n];return delete this._callbacksByPresenceVersion[n],t},Ei.prototype._callbackOrEmit=function(n,t){if(t)return qO.nextTick(t,n);n&&this.emit("error",n)};var XO=Vr,P2=Rp;function Rp(n,t){this.presence=n,this.presenceId=t,this.connection=this.presence.connection,this.value=null,this.presenceVersion=0}Rp.prototype.receiveUpdate=function(n){n.pv<this.presenceVersion||(this.value=n.p,this.presenceVersion=n.pv,this.presence._updateRemotePresence(this))},Rp.prototype.destroy=function(n){delete this.presence._remotePresenceInstances[this.presenceId],delete this.presence.remotePresences[this.presenceId],n&&XO.nextTick(n)};var wp={exports:{}};(function(n,t){(function(e,r){r(t)})(Mn,function(e){function r(y,S){S=S|0;for(var _=Math.max(y.length-S,0),N=Array(_),H=0;H<_;H++)N[H]=y[S+H];return N}var i=function(y){var S=r(arguments,1);return function(){var _=r(arguments);return y.apply(null,S.concat(_))}},o=function(y){return function(){var S=r(arguments),_=S.pop();y.call(this,S,_)}};function s(y){var S=typeof y;return y!=null&&(S=="object"||S=="function")}var l=typeof setImmediate=="function"&&setImmediate,c=typeof process=="object"&&typeof process.nextTick=="function";function d(y){setTimeout(y,0)}function h(y){return function(S){var _=r(arguments,1);y(function(){S.apply(null,_)})}}var C;l?C=setImmediate:c?C=process.nextTick:C=d;var E=h(C);function A(y){return o(function(S,_){var N;try{N=y.apply(this,S)}catch(H){return _(H)}s(N)&&typeof N.then=="function"?N.then(function(H){v(_,null,H)},function(H){v(_,H.message?H:new Error(H))}):_(null,N)})}function v(y,S,_){try{y(S,_)}catch(N){E(R,N)}}function R(y){throw y}var L=typeof Symbol=="function";function M(y){return L&&y[Symbol.toStringTag]==="AsyncFunction"}function U(y){return M(y)?A(y):y}function F(y){return function(S){var _=r(arguments,1),N=o(function(H,$){var X=this;return y(S,function(J,ct){U(J).apply(X,H.concat(ct))},$)});return _.length?N.apply(this,_):N}}var G=typeof Mn=="object"&&Mn&&Mn.Object===Object&&Mn,W=typeof self=="object"&&self&&self.Object===Object&&self,it=G||W||Function("return this")(),at=it.Symbol,xt=Object.prototype,Mt=xt.hasOwnProperty,Bt=xt.toString,le=at?at.toStringTag:void 0;function te(y){var S=Mt.call(y,le),_=y[le];try{y[le]=void 0;var N=!0}catch{}var H=Bt.call(y);return N&&(S?y[le]=_:delete y[le]),H}var kn=Object.prototype,be=kn.toString;function Kn(y){return be.call(y)}var Ii="[object Null]",Rn="[object Undefined]",mn=at?at.toStringTag:void 0;function Di(y){return y==null?y===void 0?Rn:Ii:mn&&mn in Object(y)?te(y):Kn(y)}var go="[object AsyncFunction]",Ar="[object Function]",Tx="[object GeneratorFunction]",yx="[object Proxy]";function kx(y){if(!s(y))return!1;var S=Di(y);return S==Ar||S==Tx||S==go||S==yx}var ps=9007199254740991;function bl(y){return typeof y=="number"&&y>-1&&y%1==0&&y<=ps}function vl(y){return y!=null&&bl(y.length)&&!kx(y)}var po={};function Ht(){}function _i(y){return function(){if(y!==null){var S=y;y=null,S.apply(this,arguments)}}}var Cs=typeof Symbol=="function"&&Symbol.iterator,bc=function(y){return Cs&&y[Cs]&&y[Cs]()};function pm(y,S){for(var _=-1,N=Array(y);++_<y;)N[_]=S(_);return N}function gn(y){return y!=null&&typeof y=="object"}var Bl="[object Arguments]";function Cm(y){return gn(y)&&Di(y)==Bl}var br=Object.prototype,Em=br.hasOwnProperty,Rx=br.propertyIsEnumerable,Tl=Cm(function(){return arguments}())?Cm:function(y){return gn(y)&&Em.call(y,"callee")&&!Rx.call(y,"callee")},ye=Array.isArray;function yl(){return!1}var kl=typeof e=="object"&&e&&!e.nodeType&&e,xm=kl&&!0&&n&&!n.nodeType&&n,Rl=xm&&xm.exports===kl,Am=Rl?it.Buffer:void 0,wl=Am?Am.isBuffer:void 0,Es=wl||yl,Lf=9007199254740991,If=/^(?:0|[1-9]\d*)$/;function Df(y,S){var _=typeof y;return S=S==null?Lf:S,!!S&&(_=="number"||_!="symbol"&&If.test(y))&&y>-1&&y%1==0&&y<S}var _f="[object Arguments]",Mf="[object Array]",Uf="[object Boolean]",Of="[object Date]",Nf="[object Error]",Pf="[object Function]",wx="[object Map]",Sx="[object Number]",Lx="[object Object]",bm="[object RegExp]",vm="[object Set]",Ix="[object String]",Dx="[object WeakMap]",_x="[object ArrayBuffer]",Mx="[object DataView]",Bm="[object Float32Array]",Ux="[object Float64Array]",Ox="[object Int8Array]",Nx="[object Int16Array]",Ff="[object Int32Array]",Px="[object Uint8Array]",Kf="[object Uint8ClampedArray]",Fx="[object Uint16Array]",Kx="[object Uint32Array]",de={};de[Bm]=de[Ux]=de[Ox]=de[Nx]=de[Ff]=de[Px]=de[Kf]=de[Fx]=de[Kx]=!0,de[_f]=de[Mf]=de[_x]=de[Uf]=de[Mx]=de[Of]=de[Nf]=de[Pf]=de[wx]=de[Sx]=de[Lx]=de[bm]=de[vm]=de[Ix]=de[Dx]=!1;function Vx(y){return gn(y)&&bl(y.length)&&!!de[Di(y)]}function $x(y){return function(S){return y(S)}}var Tm=typeof e=="object"&&e&&!e.nodeType&&e,Sl=Tm&&!0&&n&&!n.nodeType&&n,Hx=Sl&&Sl.exports===Tm,vc=Hx&&G.process,ym=function(){try{var y=Sl&&Sl.require&&Sl.require("util").types;return y||vc&&vc.binding&&vc.binding("util")}catch{}}(),km=ym&&ym.isTypedArray,jx=km?$x(km):Vx,zx=Object.prototype,Gx=zx.hasOwnProperty;function Wx(y,S){var _=ye(y),N=!_&&Tl(y),H=!_&&!N&&Es(y),$=!_&&!N&&!H&&jx(y),X=_||N||H||$,J=X?pm(y.length,String):[],ct=J.length;for(var Ct in y)(S||Gx.call(y,Ct))&&!(X&&(Ct=="length"||H&&(Ct=="offset"||Ct=="parent")||$&&(Ct=="buffer"||Ct=="byteLength"||Ct=="byteOffset")||Df(Ct,ct)))&&J.push(Ct);return J}var Bc=Object.prototype;function qx(y){var S=y&&y.constructor,_=typeof S=="function"&&S.prototype||Bc;return y===_}function Tc(y,S){return function(_){return y(S(_))}}var Xx=Tc(Object.keys,Object),Qx=Object.prototype,Yx=Qx.hasOwnProperty;function Rm(y){if(!qx(y))return Xx(y);var S=[];for(var _ in Object(y))Yx.call(y,_)&&_!="constructor"&&S.push(_);return S}function yc(y){return vl(y)?Wx(y):Rm(y)}function wm(y){var S=-1,_=y.length;return function(){return++S<_?{value:y[S],key:S}:null}}function Jx(y){var S=-1;return function(){var N=y.next();return N.done?null:(S++,{value:N.value,key:S})}}function Zx(y){var S=yc(y),_=-1,N=S.length;return function H(){var $=S[++_];return $==="__proto__"?H():_<N?{value:y[$],key:$}:null}}function tA(y){if(vl(y))return wm(y);var S=bc(y);return S?Jx(S):Zx(y)}function vr(y){return function(){if(y===null)throw new Error("Callback was already called.");var S=y;y=null,S.apply(this,arguments)}}function Ll(y){return function(S,_,N){if(N=_i(N||Ht),y<=0||!S)return N(null);var H=tA(S),$=!1,X=0,J=!1;function ct(ut,At){if(X-=1,ut)$=!0,N(ut);else{if(At===po||$&&X<=0)return $=!0,N(null);J||Ct()}}function Ct(){for(J=!0;X<y&&!$;){var ut=H();if(ut===null){$=!0,X<=0&&N(null);return}X+=1,_(ut.value,ut.key,vr(ct))}J=!1}Ct()}}function Mi(y,S,_,N){Ll(S)(y,U(_),N)}function je(y,S){return function(_,N,H){return y(_,S,N,H)}}function Vf(y,S,_){_=_i(_||Ht);var N=0,H=0,$=y.length;$===0&&_(null);function X(J,ct){J?_(J):(++H===$||ct===po)&&_(null)}for(;N<$;N++)S(y[N],N,vr(X))}var eA=je(Mi,1/0),Jr=function(y,S,_){var N=vl(y)?Vf:eA;N(y,U(S),_)};function Zr(y){return function(S,_,N){return y(Jr,S,U(_),N)}}function $f(y,S,_,N){N=N||Ht,S=S||[];var H=[],$=0,X=U(_);y(S,function(J,ct,Ct){var ut=$++;X(J,function(At,Jt){H[ut]=Jt,Ct(At)})},function(J){N(J,H)})}var kc=Zr($f),Hf=F(kc);function Co(y){return function(S,_,N,H){return y(Ll(_),S,U(N),H)}}var Ui=Co($f),jf=je(Ui,1),zf=F(jf);function xs(y,S){for(var _=-1,N=y==null?0:y.length;++_<N&&S(y[_],_,y)!==!1;);return y}function Gf(y){return function(S,_,N){for(var H=-1,$=Object(S),X=N(S),J=X.length;J--;){var ct=X[y?J:++H];if(_($[ct],ct,$)===!1)break}return S}}var As=Gf();function bs(y,S){return y&&As(y,S,yc)}function Sm(y,S,_,N){for(var H=y.length,$=_+(N?1:-1);N?$--:++$<H;)if(S(y[$],$,y))return $;return-1}function nA(y){return y!==y}function Lm(y,S,_){for(var N=_-1,H=y.length;++N<H;)if(y[N]===S)return N;return-1}function Il(y,S,_){return S===S?Lm(y,S,_):Sm(y,nA,_)}var Rc=function(y,S,_){typeof S=="function"&&(_=S,S=null),_=_i(_||Ht);var N=yc(y),H=N.length;if(!H)return _(null);S||(S=H);var $={},X=0,J=!1,ct=Object.create(null),Ct=[],ut=[],At={};bs(y,function(Ee,ce){if(!ye(Ee)){Jt(ce,[Ee]),ut.push(ce);return}var ve=Ee.slice(0,Ee.length-1),Tr=ve.length;if(Tr===0){Jt(ce,Ee),ut.push(ce);return}At[ce]=Tr,xs(ve,function(k){if(!y[k])throw new Error("async.auto task `"+ce+"` has a non-existent dependency `"+k+"` in "+ve.join(", "));ln(k,function(){Tr--,Tr===0&&Jt(ce,Ee)})})}),TA(),Oe();function Jt(Ee,ce){Ct.push(function(){Br(Ee,ce)})}function Oe(){if(Ct.length===0&&X===0)return _(null,$);for(;Ct.length&&X<S;){var Ee=Ct.shift();Ee()}}function ln(Ee,ce){var ve=ct[Ee];ve||(ve=ct[Ee]=[]),ve.push(ce)}function Hn(Ee){var ce=ct[Ee]||[];xs(ce,function(ve){ve()}),Oe()}function Br(Ee,ce){if(!J){var ve=vr(function(k,Pi){if(X--,arguments.length>2&&(Pi=r(arguments,1)),k){var ys={};bs($,function(jn,Vt){ys[Vt]=jn}),ys[Ee]=Pi,J=!0,ct=Object.create(null),_(k,ys)}else $[Ee]=Pi,Hn(Ee)});X++;var Tr=U(ce[ce.length-1]);ce.length>1?Tr($,ve):Tr(ve)}}function TA(){for(var Ee,ce=0;ut.length;)Ee=ut.pop(),ce++,xs(yA(Ee),function(ve){--At[ve]===0&&ut.push(ve)});if(ce!==H)throw new Error("async.auto cannot execute tasks due to a recursive dependency")}function yA(Ee){var ce=[];return bs(y,function(ve,Tr){ye(ve)&&Il(ve,Ee,0)>=0&&ce.push(Tr)}),ce}};function Eo(y,S){for(var _=-1,N=y==null?0:y.length,H=Array(N);++_<N;)H[_]=S(y[_],_,y);return H}var rA="[object Symbol]";function iA(y){return typeof y=="symbol"||gn(y)&&Di(y)==rA}var oA=1/0,Wf=at?at.prototype:void 0,Im=Wf?Wf.toString:void 0;function qf(y){if(typeof y=="string")return y;if(ye(y))return Eo(y,qf)+"";if(iA(y))return Im?Im.call(y):"";var S=y+"";return S=="0"&&1/y==-oA?"-0":S}function sA(y,S,_){var N=-1,H=y.length;S<0&&(S=-S>H?0:H+S),_=_>H?H:_,_<0&&(_+=H),H=S>_?0:_-S>>>0,S>>>=0;for(var $=Array(H);++N<H;)$[N]=y[N+S];return $}function lA(y,S,_){var N=y.length;return _=_===void 0?N:_,!S&&_>=N?y:sA(y,S,_)}function Xf(y,S){for(var _=y.length;_--&&Il(S,y[_],0)>-1;);return _}function aA(y,S){for(var _=-1,N=y.length;++_<N&&Il(S,y[_],0)>-1;);return _}function cA(y){return y.split("")}var uA="\\ud800-\\udfff",fA="\\u0300-\\u036f",dA="\\ufe20-\\ufe2f",he="\\u20d0-\\u20ff",ae=fA+dA+he,hA="\\ufe0e\\ufe0f",mA="\\u200d",gA=RegExp("["+mA+uA+ae+hA+"]");function pA(y){return gA.test(y)}var Dm="\\ud800-\\udfff",CA="\\u0300-\\u036f",_m="\\ufe20-\\ufe2f",EA="\\u20d0-\\u20ff",Je=CA+_m+EA,Qf="\\ufe0e\\ufe0f",xo="["+Dm+"]",wc="["+Je+"]",Dl="\\ud83c[\\udffb-\\udfff]",Vn="(?:"+wc+"|"+Dl+")",Yf="[^"+Dm+"]",Jf="(?:\\ud83c[\\udde6-\\uddff]){2}",Zf="[\\ud800-\\udbff][\\udc00-\\udfff]",Mm="\\u200d",td=Vn+"?",ed="["+Qf+"]?",wn="(?:"+Mm+"(?:"+[Yf,Jf,Zf].join("|")+")"+ed+td+")*",xA=ed+td+wn,$n="(?:"+[Yf+wc+"?",wc,Jf,Zf,xo].join("|")+")",AA=RegExp(Dl+"(?="+Dl+")|"+$n+xA,"g");function Um(y){return y.match(AA)||[]}function ti(y){return pA(y)?Um(y):cA(y)}function Sc(y){return y==null?"":qf(y)}var nd=/^\s+|\s+$/g;function Ce(y,S,_){if(y=Sc(y),y&&(_||S===void 0))return y.replace(nd,"");if(!y||!(S=qf(S)))return y;var N=ti(y),H=ti(S),$=aA(N,H),X=Xf(N,H)+1;return lA(N,$,X).join("")}var Oi=/^(?:async\s+)?(function)?\s*[^\(]*\(\s*([^\)]*)\)/m,rd=/,/,bA=/(=.+)?(\s*)$/,id=/((\/\/.*$)|(\/\*[\s\S]*?\*\/))/mg;function vA(y){return y=y.toString().replace(id,""),y=y.match(Oi)[2].replace(" ",""),y=y?y.split(rd):[],y=y.map(function(S){return Ce(S.replace(bA,""))}),y}function Om(y,S){var _={};bs(y,function(N,H){var $,X=M(N),J=!X&&N.length===1||X&&N.length===0;if(ye(N))$=N.slice(0,-1),N=N[N.length-1],_[H]=$.concat($.length>0?ct:N);else if(J)_[H]=N;else{if($=vA(N),N.length===0&&!X&&$.length===0)throw new Error("autoInject task functions require explicit parameters.");X||$.pop(),_[H]=$.concat(ct)}function ct(Ct,ut){var At=Eo($,function(Jt){return Ct[Jt]});At.push(ut),U(N).apply(null,At)}}),Rc(_,S)}function ir(){this.head=this.tail=null,this.length=0}function od(y,S){y.length=1,y.head=y.tail=S}ir.prototype.removeLink=function(y){return y.prev?y.prev.next=y.next:this.head=y.next,y.next?y.next.prev=y.prev:this.tail=y.prev,y.prev=y.next=null,this.length-=1,y},ir.prototype.empty=function(){for(;this.head;)this.shift();return this},ir.prototype.insertAfter=function(y,S){S.prev=y,S.next=y.next,y.next?y.next.prev=S:this.tail=S,y.next=S,this.length+=1},ir.prototype.insertBefore=function(y,S){S.prev=y.prev,S.next=y,y.prev?y.prev.next=S:this.head=S,y.prev=S,this.length+=1},ir.prototype.unshift=function(y){this.head?this.insertBefore(this.head,y):od(this,y)},ir.prototype.push=function(y){this.tail?this.insertAfter(this.tail,y):od(this,y)},ir.prototype.shift=function(){return this.head&&this.removeLink(this.head)},ir.prototype.pop=function(){return this.tail&&this.removeLink(this.tail)},ir.prototype.toArray=function(){for(var y=Array(this.length),S=this.head,_=0;_<this.length;_++)y[_]=S.data,S=S.next;return y},ir.prototype.remove=function(y){for(var S=this.head;S;){var _=S.next;y(S)&&this.removeLink(S),S=_}return this};function _l(y,S,_){if(S==null)S=1;else if(S===0)throw new Error("Concurrency must not be zero");var N=U(y),H=0,$=[],X=!1;function J(At,Jt,Oe){if(Oe!=null&&typeof Oe!="function")throw new Error("task callback must be a function");if(ut.started=!0,ye(At)||(At=[At]),At.length===0&&ut.idle())return E(function(){ut.drain()});for(var ln=0,Hn=At.length;ln<Hn;ln++){var Br={data:At[ln],callback:Oe||Ht};Jt?ut._tasks.unshift(Br):ut._tasks.push(Br)}X||(X=!0,E(function(){X=!1,ut.process()}))}function ct(At){return function(Jt){H-=1;for(var Oe=0,ln=At.length;Oe<ln;Oe++){var Hn=At[Oe],Br=Il($,Hn,0);Br===0?$.shift():Br>0&&$.splice(Br,1),Hn.callback.apply(Hn,arguments),Jt!=null&&ut.error(Jt,Hn.data)}H<=ut.concurrency-ut.buffer&&ut.unsaturated(),ut.idle()&&ut.drain(),ut.process()}}var Ct=!1,ut={_tasks:new ir,concurrency:S,payload:_,saturated:Ht,unsaturated:Ht,buffer:S/4,empty:Ht,drain:Ht,error:Ht,started:!1,paused:!1,push:function(At,Jt){J(At,!1,Jt)},kill:function(){ut.drain=Ht,ut._tasks.empty()},unshift:function(At,Jt){J(At,!0,Jt)},remove:function(At){ut._tasks.remove(At)},process:function(){if(!Ct){for(Ct=!0;!ut.paused&&H<ut.concurrency&&ut._tasks.length;){var At=[],Jt=[],Oe=ut._tasks.length;ut.payload&&(Oe=Math.min(Oe,ut.payload));for(var ln=0;ln<Oe;ln++){var Hn=ut._tasks.shift();At.push(Hn),$.push(Hn),Jt.push(Hn.data)}H+=1,ut._tasks.length===0&&ut.empty(),H===ut.concurrency&&ut.saturated();var Br=vr(ct(At));N(Jt,Br)}Ct=!1}},length:function(){return ut._tasks.length},running:function(){return H},workersList:function(){return $},idle:function(){return ut._tasks.length+H===0},pause:function(){ut.paused=!0},resume:function(){ut.paused!==!1&&(ut.paused=!1,E(ut.process))}};return ut}function Ao(y,S){return _l(y,1,S)}var vs=je(Mi,1);function ei(y,S,_,N){N=_i(N||Ht);var H=U(_);vs(y,function($,X,J){H(S,$,function(ct,Ct){S=Ct,J(ct)})},function($){N($,S)})}function Lc(){var y=Eo(arguments,U);return function(){var S=r(arguments),_=this,N=S[S.length-1];typeof N=="function"?S.pop():N=Ht,ei(y,S,function(H,$,X){$.apply(_,H.concat(function(J){var ct=r(arguments,1);X(J,ct)}))},function(H,$){N.apply(_,[H].concat($))})}}var Ic=function(){return Lc.apply(null,r(arguments).reverse())},sd=Array.prototype.concat,Ml=function(y,S,_,N){N=N||Ht;var H=U(_);Ui(y,S,function($,X){H($,function(J){return J?X(J):X(null,r(arguments,1))})},function($,X){for(var J=[],ct=0;ct<X.length;ct++)X[ct]&&(J=sd.apply(J,X[ct]));return N($,J)})},Nm=je(Ml,1/0),Dc=je(Ml,1),_c=function(){var y=r(arguments),S=[null].concat(y);return function(){var _=arguments[arguments.length-1];return _.apply(this,S)}};function Ul(y){return y}function bo(y,S){return function(_,N,H,$){$=$||Ht;var X=!1,J;_(N,function(ct,Ct,ut){H(ct,function(At,Jt){At?ut(At):y(Jt)&&!J?(X=!0,J=S(!0,ct),ut(null,po)):ut()})},function(ct){ct?$(ct):$(null,X?J:S(!1))})}}function pn(y,S){return S}var Bs=Zr(bo(Ul,pn)),ni=Co(bo(Ul,pn)),Ol=je(ni,1);function ld(y){return function(S){var _=r(arguments,1);_.push(function(N){var H=r(arguments,1);typeof console=="object"&&(N?console.error&&console.error(N):console[y]&&xs(H,function($){console[y]($)}))}),U(S).apply(null,_)}}var Pm=ld("dir");function Fm(y,S,_){_=vr(_||Ht);var N=U(y),H=U(S);function $(J){if(J)return _(J);var ct=r(arguments,1);ct.push(X),H.apply(this,ct)}function X(J,ct){if(J)return _(J);if(!ct)return _(null);N($)}X(null,!0)}function ad(y,S,_){_=vr(_||Ht);var N=U(y),H=function($){if($)return _($);var X=r(arguments,1);if(S.apply(this,X))return N(H);_.apply(null,[null].concat(X))};N(H)}function Km(y,S,_){ad(y,function(){return!S.apply(this,arguments)},_)}function Vm(y,S,_){_=vr(_||Ht);var N=U(S),H=U(y);function $(J){if(J)return _(J);H(X)}function X(J,ct){if(J)return _(J);if(!ct)return _(null);N($)}H(X)}function vo(y){return function(S,_,N){return y(S,N)}}function Mc(y,S,_){Jr(y,vo(U(S)),_)}function Nl(y,S,_,N){Ll(S)(y,vo(U(_)),N)}var Bo=je(Nl,1);function Uc(y){return M(y)?y:o(function(S,_){var N=!0;S.push(function(){var H=arguments;N?E(function(){_.apply(null,H)}):_.apply(null,H)}),y.apply(this,S),N=!1})}function or(y){return!y}var To=Zr(bo(or,or)),Pl=Co(bo(or,or)),Oc=je(Pl,1);function $m(y){return function(S){return S==null?void 0:S[y]}}function Ts(y,S,_,N){var H=new Array(S.length);y(S,function($,X,J){_($,function(ct,Ct){H[X]=!!Ct,J(ct)})},function($){if($)return N($);for(var X=[],J=0;J<S.length;J++)H[J]&&X.push(S[J]);N(null,X)})}function sr(y,S,_,N){var H=[];y(S,function($,X,J){_($,function(ct,Ct){ct?J(ct):(Ct&&H.push({index:X,value:$}),J())})},function($){$?N($):N(null,Eo(H.sort(function(X,J){return X.index-J.index}),$m("value")))})}function Nc(y,S,_,N){var H=vl(S)?Ts:sr;H(y,S,U(_),N||Ht)}var Pc=Zr(Nc),Fl=Co(Nc),Fc=je(Fl,1);function Hm(y,S){var _=vr(S||Ht),N=U(Uc(y));function H($){if($)return _($);N(H)}H()}var Kc=function(y,S,_,N){N=N||Ht;var H=U(_);Ui(y,S,function($,X){H($,function(J,ct){return J?X(J):X(null,{key:ct,val:$})})},function($,X){for(var J={},ct=Object.prototype.hasOwnProperty,Ct=0;Ct<X.length;Ct++)if(X[Ct]){var ut=X[Ct].key,At=X[Ct].val;ct.call(J,ut)?J[ut].push(At):J[ut]=[At]}return N($,J)})},yo=je(Kc,1/0),K=je(Kc,1),q=ld("log");function j(y,S,_,N){N=_i(N||Ht);var H={},$=U(_);Mi(y,S,function(X,J,ct){$(X,J,function(Ct,ut){if(Ct)return ct(Ct);H[J]=ut,ct()})},function(X){N(X,H)})}var mt=je(j,1/0),wt=je(j,1);function Gt(y,S){return S in y}function Ie(y,S){var _=Object.create(null),N=Object.create(null);S=S||Ul;var H=U(y),$=o(function(J,ct){var Ct=S.apply(null,J);Gt(_,Ct)?E(function(){ct.apply(null,_[Ct])}):Gt(N,Ct)?N[Ct].push(ct):(N[Ct]=[ct],H.apply(null,J.concat(function(){var ut=r(arguments);_[Ct]=ut;var At=N[Ct];delete N[Ct];for(var Jt=0,Oe=At.length;Jt<Oe;Jt++)At[Jt].apply(null,ut)})))});return $.memo=_,$.unmemoized=y,$}var Qt;c?Qt=process.nextTick:l?Qt=setImmediate:Qt=d;var Vc=h(Qt);function cd(y,S,_){_=_||Ht;var N=vl(S)?[]:{};y(S,function(H,$,X){U(H)(function(J,ct){arguments.length>2&&(ct=r(arguments,1)),N[$]=ct,X(J)})},function(H){_(H,N)})}function Sn(y,S){cd(Jr,y,S)}function Kl(y,S,_){cd(Ll(S),y,_)}var ud=function(y,S){var _=U(y);return _l(function(N,H){_(N[0],H)},S,1)},ko=function(y,S){var _=ud(y,S);return _.push=function(N,H,$){if($==null&&($=Ht),typeof $!="function")throw new Error("task callback must be a function");if(_.started=!0,ye(N)||(N=[N]),N.length===0)return E(function(){_.drain()});H=H||0;for(var X=_._tasks.head;X&&H>=X.priority;)X=X.next;for(var J=0,ct=N.length;J<ct;J++){var Ct={data:N[J],priority:H,callback:$};X?_._tasks.insertBefore(X,Ct):_._tasks.push(Ct)}E(_.process)},delete _.unshift,_};function Vl(y,S){if(S=_i(S||Ht),!ye(y))return S(new TypeError("First argument to race must be an array of functions"));if(!y.length)return S();for(var _=0,N=y.length;_<N;_++)U(y[_])(S)}function Ro(y,S,_,N){var H=r(y).reverse();ei(H,S,_,N)}function Wt(y){var S=U(y);return o(function(N,H){return N.push(function(X,J){if(X)H(null,{error:X});else{var ct;arguments.length<=2?ct=J:ct=r(arguments,1),H(null,{value:ct})}}),S.apply(this,N)})}function jm(y){var S;return ye(y)?S=Eo(y,Wt):(S={},bs(y,function(_,N){S[N]=Wt.call(this,_)})),S}function fd(y,S,_,N){Nc(y,S,function(H,$){_(H,function(X,J){$(X,!J)})},N)}var $l=Zr(fd),dd=Co(fd),zm=je(dd,1);function Gm(y){return function(){return y}}function wo(y,S,_){var N=5,H=0,$={times:N,intervalFunc:Gm(H)};function X(ut,At){if(typeof At=="object")ut.times=+At.times||N,ut.intervalFunc=typeof At.interval=="function"?At.interval:Gm(+At.interval||H),ut.errorFilter=At.errorFilter;else if(typeof At=="number"||typeof At=="string")ut.times=+At||N;else throw new Error("Invalid arguments for async.retry")}if(arguments.length<3&&typeof y=="function"?(_=S||Ht,S=y):(X($,y),_=_||Ht),typeof S!="function")throw new Error("Invalid arguments for async.retry");var J=U(S),ct=1;function Ct(){J(function(ut){ut&&ct++<$.times&&(typeof $.errorFilter!="function"||$.errorFilter(ut))?setTimeout(Ct,$.intervalFunc(ct)):_.apply(null,arguments)})}Ct()}var ri=function(y,S){S||(S=y,y=null);var _=U(S);return o(function(N,H){function $(X){_.apply(null,N.concat(X))}y?wo(y,$,H):wo($,H)})};function Hl(y,S){cd(vs,y,S)}var jl=Zr(bo(Boolean,Ul)),Ni=Co(bo(Boolean,Ul)),zl=je(Ni,1);function hd(y,S,_){var N=U(S);kc(y,function($,X){N($,function(J,ct){if(J)return X(J);X(null,{value:$,criteria:ct})})},function($,X){if($)return _($);_(null,Eo(X.sort(H),$m("value")))});function H($,X){var J=$.criteria,ct=X.criteria;return J<ct?-1:J>ct?1:0}}function Gl(y,S,_){var N=U(y);return o(function(H,$){var X=!1,J;function ct(){var Ct=y.name||"anonymous",ut=new Error('Callback function "'+Ct+'" timed out.');ut.code="ETIMEDOUT",_&&(ut.info=_),X=!0,$(ut)}H.push(function(){X||($.apply(null,arguments),clearTimeout(J))}),J=setTimeout(ct,S),N.apply(null,H)})}var Wm=Math.ceil,Wl=Math.max;function So(y,S,_,N){for(var H=-1,$=Wl(Wm((S-y)/(_||1)),0),X=Array($);$--;)X[N?$:++H]=y,y+=_;return X}function Lo(y,S,_,N){var H=U(_);Ui(So(0,y,1),S,H,N)}var qm=je(Lo,1/0),Xm=je(Lo,1);function Qm(y,S,_,N){arguments.length<=3&&(N=_,_=S,S=ye(y)?[]:{}),N=_i(N||Ht);var H=U(_);Jr(y,function($,X,J){H(S,$,X,J)},function($){N($,S)})}function ql(y,S){var _=null,N;S=S||Ht,Bo(y,function(H,$){U(H)(function(X,J){arguments.length>2?N=r(arguments,1):N=J,_=X,$(!X)})},function(){S(_,N)})}function Xl(y){return function(){return(y.unmemoized||y).apply(null,arguments)}}function Ql(y,S,_){_=vr(_||Ht);var N=U(S);if(!y())return _(null);var H=function($){if($)return _($);if(y())return N(H);var X=r(arguments,1);_.apply(null,[null].concat(X))};N(H)}function Ym(y,S,_){Ql(function(){return!y.apply(this,arguments)},S,_)}var md=function(y,S){if(S=_i(S||Ht),!ye(y))return S(new Error("First argument to waterfall must be an array of functions"));if(!y.length)return S();var _=0;function N($){var X=U(y[_++]);$.push(vr(H)),X.apply(null,$)}function H($){if($||_===y.length)return S.apply(null,arguments);N(r(arguments,1))}N([])},BA={apply:i,applyEach:Hf,applyEachSeries:zf,asyncify:A,auto:Rc,autoInject:Om,cargo:Ao,compose:Ic,concat:Nm,concatLimit:Ml,concatSeries:Dc,constant:_c,detect:Bs,detectLimit:ni,detectSeries:Ol,dir:Pm,doDuring:Fm,doUntil:Km,doWhilst:ad,during:Vm,each:Mc,eachLimit:Nl,eachOf:Jr,eachOfLimit:Mi,eachOfSeries:vs,eachSeries:Bo,ensureAsync:Uc,every:To,everyLimit:Pl,everySeries:Oc,filter:Pc,filterLimit:Fl,filterSeries:Fc,forever:Hm,groupBy:yo,groupByLimit:Kc,groupBySeries:K,log:q,map:kc,mapLimit:Ui,mapSeries:jf,mapValues:mt,mapValuesLimit:j,mapValuesSeries:wt,memoize:Ie,nextTick:Vc,parallel:Sn,parallelLimit:Kl,priorityQueue:ko,queue:ud,race:Vl,reduce:ei,reduceRight:Ro,reflect:Wt,reflectAll:jm,reject:$l,rejectLimit:dd,rejectSeries:zm,retry:wo,retryable:ri,seq:Lc,series:Hl,setImmediate:E,some:jl,someLimit:Ni,someSeries:zl,sortBy:hd,timeout:Gl,times:qm,timesLimit:Lo,timesSeries:Xm,transform:Qm,tryEach:ql,unmemoize:Xl,until:Ym,waterfall:md,whilst:Ql,all:To,allLimit:Pl,allSeries:Oc,any:jl,anyLimit:Ni,anySeries:zl,find:Bs,findLimit:ni,findSeries:Ol,forEach:Mc,forEachSeries:Bo,forEachLimit:Nl,forEachOf:Jr,forEachOfSeries:vs,forEachOfLimit:Mi,inject:ei,foldl:ei,foldr:Ro,select:Pc,selectLimit:Fl,selectSeries:Fc,wrapSync:A};e.default=BA,e.apply=i,e.applyEach=Hf,e.applyEachSeries=zf,e.asyncify=A,e.auto=Rc,e.autoInject=Om,e.cargo=Ao,e.compose=Ic,e.concat=Nm,e.concatLimit=Ml,e.concatSeries=Dc,e.constant=_c,e.detect=Bs,e.detectLimit=ni,e.detectSeries=Ol,e.dir=Pm,e.doDuring=Fm,e.doUntil=Km,e.doWhilst=ad,e.during=Vm,e.each=Mc,e.eachLimit=Nl,e.eachOf=Jr,e.eachOfLimit=Mi,e.eachOfSeries=vs,e.eachSeries=Bo,e.ensureAsync=Uc,e.every=To,e.everyLimit=Pl,e.everySeries=Oc,e.filter=Pc,e.filterLimit=Fl,e.filterSeries=Fc,e.forever=Hm,e.groupBy=yo,e.groupByLimit=Kc,e.groupBySeries=K,e.log=q,e.map=kc,e.mapLimit=Ui,e.mapSeries=jf,e.mapValues=mt,e.mapValuesLimit=j,e.mapValuesSeries=wt,e.memoize=Ie,e.nextTick=Vc,e.parallel=Sn,e.parallelLimit=Kl,e.priorityQueue=ko,e.queue=ud,e.race=Vl,e.reduce=ei,e.reduceRight=Ro,e.reflect=Wt,e.reflectAll=jm,e.reject=$l,e.rejectLimit=dd,e.rejectSeries=zm,e.retry=wo,e.retryable=ri,e.seq=Lc,e.series=Hl,e.setImmediate=E,e.some=jl,e.someLimit=Ni,e.someSeries=zl,e.sortBy=hd,e.timeout=Gl,e.times=qm,e.timesLimit=Lo,e.timesSeries=Xm,e.transform=Qm,e.tryEach=ql,e.unmemoize=Xl,e.until=Ym,e.waterfall=md,e.whilst=Ql,e.all=To,e.allLimit=Pl,e.allSeries=Oc,e.any=jl,e.anyLimit=Ni,e.anySeries=zl,e.find=Bs,e.findLimit=ni,e.findSeries=Ol,e.forEach=Mc,e.forEachSeries=Bo,e.forEachLimit=Nl,e.forEachOf=Jr,e.forEachOfSeries=vs,e.forEachOfLimit=Mi,e.inject=ei,e.foldl=ei,e.foldr=Ro,e.select=Pc,e.selectLimit=Fl,e.selectSeries=Fc,e.wrapSync=A,Object.defineProperty(e,"__esModule",{value:!0})})})(wp,wp.exports);var F2={exports:{}},Sp=F2.exports=function(n,t){if(t||(t=16),n===void 0&&(n=128),n<=0)return"0";for(var e=Math.log(Math.pow(2,n))/Math.log(t),r=2;e===1/0;r*=2)e=Math.log(Math.pow(2,n/r))/Math.log(t)*r;for(var i=e-Math.floor(e),o="",r=0;r<Math.floor(e);r++){var s=Math.floor(Math.random()*t).toString(t);o=s+o}if(i){var l=Math.pow(t,i),s=Math.floor(Math.random()*l).toString(t);o=s+o}var c=parseInt(o,t);return c!==1/0&&c>=Math.pow(2,n)?Sp(n,t):o};Sp.rack=function(n,t,e){var r=function(o){var s=0;do{if(s++>10)if(e)n+=e;else throw new Error("too many ID collisions, use more bits");var l=Sp(n,t)}while(Object.hasOwnProperty.call(i,l));return i[l]=o,l},i=r.hats={};return r.get=function(o){return r.hats[o]},r.set=function(o,s){return r.hats[o]=s,r},r.bits=n||128,r.base=t||16,r};var K2=Yo,QO=N2,YO=P2,$h=Vr,Lp=wp.exports,JO=F2.exports,V2=rl.ACTIONS,$2=Fe;function Fe(n,t){if(K2.EventEmitter.call(this),!t||typeof t!="string")throw new Error("Presence channel must be provided");this.connection=n,this.channel=t,this.wantSubscribe=!1,this.subscribed=!1,this.remotePresences={},this.localPresences={},this._remotePresenceInstances={},this._subscriptionCallbacksBySeq={},this._wantsDestroy=!1}K2.mixin(Fe),Fe.prototype.subscribe=function(n){this._sendSubscriptionAction(!0,n)},Fe.prototype.unsubscribe=function(n){this._sendSubscriptionAction(!1,n)},Fe.prototype.create=function(n){if(this._wantsDestroy)throw new Error("Presence is being destroyed");n=n||JO();var t=this._createLocalPresence(n);return this.localPresences[n]=t,t},Fe.prototype.destroy=function(n){this._wantsDestroy=!0;var t=this,e=Object.keys(t.localPresences);this.unsubscribe(function(r){if(r)return t._callbackOrEmit(r,n);var i=Object.keys(t._remotePresenceInstances);Lp.parallel([function(o){Lp.each(e,function(s,l){t.localPresences[s].destroy(l)},o)},function(o){if(!t._wantsDestroy)return o();Lp.each(i,function(s,l){t._remotePresenceInstances[s].destroy(l)},o)}],function(o){t._wantsDestroy&&delete t.connection._presences[t.channel],t._callbackOrEmit(o,n)})})},Fe.prototype._sendSubscriptionAction=function(n,t){this.wantSubscribe=!!n;var e=this.wantSubscribe?V2.presenceSubscribe:V2.presenceUnsubscribe,r=this.connection._presenceSeq++;this._subscriptionCallbacksBySeq[r]=t,this.connection.canSend&&this.connection._sendPresenceAction(e,r,this)},Fe.prototype._handleSubscribe=function(n,t){this.wantSubscribe&&(this.subscribed=!0);var e=this._subscriptionCallback(t);this._callbackOrEmit(n,e)},Fe.prototype._handleUnsubscribe=function(n,t){this.subscribed=!1;var e=this._subscriptionCallback(t);this._callbackOrEmit(n,e)},Fe.prototype._receiveUpdate=function(n,t){var e=$h.dig(this.localPresences,t.id);if(e)return e._ack(n,t.pv);if(n)return this.emit("error",n);var r=this,i=$h.digOrCreate(this._remotePresenceInstances,t.id,function(){return r._createRemotePresence(t.id)});i.receiveUpdate(t)},Fe.prototype._updateRemotePresence=function(n){this.remotePresences[n.presenceId]=n.value,n.value===null&&this._removeRemotePresence(n.presenceId),this.emit("receive",n.presenceId,n.value)},Fe.prototype._broadcastAllLocalPresence=function(n){if(n)return this.emit("error",n);for(var t in this.localPresences){var e=this.localPresences[t];e.value!==null&&e.send()}},Fe.prototype._removeRemotePresence=function(n){this._remotePresenceInstances[n].destroy(),delete this._remotePresenceInstances[n],delete this.remotePresences[n]},Fe.prototype._onConnectionStateChanged=function(){if(!!this.connection.canSend){this._resubscribe();for(var n in this.localPresences)this.localPresences[n]._sendPending()}},Fe.prototype._resubscribe=function(){var n=[];for(var t in this._subscriptionCallbacksBySeq){var e=this._subscriptionCallback(t);n.push(e)}if(!this.wantSubscribe)return this._callEachOrEmit(n);var r=this;this.subscribe(function(i){r._callEachOrEmit(n,i)})},Fe.prototype._subscriptionCallback=function(n){var t=this._subscriptionCallbacksBySeq[n];return delete this._subscriptionCallbacksBySeq[n],t},Fe.prototype._callbackOrEmit=function(n,t){if(t)return $h.nextTick(t,n);n&&this.emit("error",n)},Fe.prototype._createLocalPresence=function(n){return new QO(this,n)},Fe.prototype._createRemotePresence=function(n){return new YO(this,n)},Fe.prototype._callEachOrEmit=function(n,t){var e=$h.callEach(n,t);!e&&t&&this.emit("error",t)};var Iu=N2,H2=Nh,ZO=Vr,j2=H2.CODES,tN=Hr;function Hr(n,t){Iu.call(this,n,t),this.collection=this.presence.collection,this.id=this.presence.id,this._doc=this.connection.get(this.collection,this.id),this._isSending=!1,this._docDataVersionByPresenceVersion={},this._opHandler=this._transformAgainstOp.bind(this),this._createOrDelHandler=this._handleCreateOrDel.bind(this),this._loadHandler=this._handleLoad.bind(this),this._destroyHandler=this.destroy.bind(this),this._registerWithDoc()}Hr.prototype=Object.create(Iu.prototype),Hr.prototype.submit=function(n,t){if(!this._doc.type){if(n===null)return this._callbackOrEmit(null,t);var e={code:j2.ERR_DOC_DOES_NOT_EXIST,message:"Cannot submit presence. Document has not been created"};return this._callbackOrEmit(e,t)}this._docDataVersionByPresenceVersion[this.presenceVersion]=this._doc._dataStateVersion,Iu.prototype.submit.call(this,n,t)},Hr.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),Iu.prototype.destroy.call(this,n)},Hr.prototype._sendPending=function(){if(!this._isSending){this._isSending=!0;var n=this;this._doc.whenNothingPending(function(){n._isSending=!1,n.connection.canSend&&(n._pendingMessages.forEach(function(t){t.t=n._doc.type.uri,t.v=n._doc.version,n.connection.send(t)}),n._pendingMessages=[],n._docDataVersionByPresenceVersion={})})}},Hr.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)},Hr.prototype._transformAgainstOp=function(n,t){var e=this,r=this._doc._dataStateVersion;this._pendingMessages.forEach(function(i){var o=e._docDataVersionByPresenceVersion[i.pv];if(!(o>=r))try{i.p=e._transformPresence(i.p,n,t),e._docDataVersionByPresenceVersion[i.pv]=r}catch(l){var s=e._getCallback(i.pv);e._callbackOrEmit(l,s)}});try{this.value=this._transformPresence(this.value,n,t)}catch(i){this.emit("error",i)}},Hr.prototype._handleCreateOrDel=function(){this._pendingMessages.forEach(function(n){n.p=null}),this.value=null},Hr.prototype._handleLoad=function(){this.value=null,this._pendingMessages=[],this._docDataVersionByPresenceVersion={}},Hr.prototype._message=function(){var n=Iu.prototype._message.call(this);return n.c=this.collection,n.d=this.id,n.v=null,n.t=null,n},Hr.prototype._transformPresence=function(n,t,e){var r=this._doc.type;if(!ZO.supportsPresence(r))throw new H2(j2.ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE,"Type does not support presence: "+r.name);return r.transformPresence(n,t,e)};var z2={};(function(n){var t=wu,e=Nh,r=Vr,i=e.CODES;n.checkOp=function(l){if(l==null||typeof l!="object")return new e(i.ERR_OT_OP_BADLY_FORMED,"Op must be an object");if(l.create!=null){if(typeof l.create!="object")return new e(i.ERR_OT_OP_BADLY_FORMED,"Create data must be an object");var c=l.create.type;if(typeof c!="string")return new e(i.ERR_OT_OP_BADLY_FORMED,"Missing create type");var d=t.map[c];if(d==null||typeof d!="object")return new e(i.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type")}else if(l.del!=null){if(l.del!==!0)return new e(i.ERR_OT_OP_BADLY_FORMED,"del value must be true")}else if(!("op"in l))return new e(i.ERR_OT_OP_BADLY_FORMED,"Missing op, create, or del");if(l.src!=null&&typeof l.src!="string")return new e(i.ERR_OT_OP_BADLY_FORMED,"src must be a string");if(l.seq!=null&&typeof l.seq!="number")return new e(i.ERR_OT_OP_BADLY_FORMED,"seq must be a number");if(l.src==null&&l.seq!=null||l.src!=null&&l.seq==null)return new e(i.ERR_OT_OP_BADLY_FORMED,"Both src and seq must be set together");if(l.m!=null&&typeof l.m!="object")return new e(i.ERR_OT_OP_BADLY_FORMED,"op.m must be an object or null")},n.normalizeType=function(l){return t.map[l]&&t.map[l].uri},n.apply=function(l,c){if(typeof l!="object")return new e(i.ERR_APPLY_SNAPSHOT_NOT_PROVIDED,"Missing snapshot");if(l.v!=null&&c.v!=null&&l.v!==c.v)return new e(i.ERR_APPLY_OP_VERSION_DOES_NOT_MATCH_SNAPSHOT,"Version mismatch");if(c.create){if(l.type)return new e(i.ERR_DOC_ALREADY_CREATED,"Document already exists");var d=c.create,h=t.map[d.type];if(!h)return new e(i.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{l.data=h.create(d.data),l.type=h.uri,l.v++}catch(E){return E}}else if(c.del)l.data=void 0,l.type=null,l.v++;else if("op"in c){var C=o(l,c.op);if(C)return C;l.v++}else l.v++};function o(l,c){if(!l.type)return new e(i.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");if(c===void 0)return new e(i.ERR_OT_OP_NOT_PROVIDED,"Missing op");var d=t.map[l.type];if(!d)return new e(i.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{l.data=d.apply(l.data,c)}catch(h){return new e(i.ERR_OT_OP_NOT_APPLIED,h.message)}}n.transform=function(l,c,d){if(c.v!=null&&c.v!==d.v)return new e(i.ERR_OP_VERSION_MISMATCH_DURING_TRANSFORM,"Version mismatch");if(d.del){if(c.create||"op"in c)return new e(i.ERR_DOC_WAS_DELETED,"Document was deleted")}else{if(d.create&&("op"in c||c.create||c.del)||"op"in d&&c.create)return new e(i.ERR_DOC_ALREADY_CREATED,"Document was created remotely");if("op"in d&&"op"in c){if(!l)return new e(i.ERR_DOC_DOES_NOT_EXIST,"Document does not exist");if(typeof l=="string"&&(l=t.map[l],!l))return new e(i.ERR_DOC_TYPE_NOT_RECOGNIZED,"Unknown type");try{c.op=l.transform(c.op,d.op,"left")}catch(h){return h}}}c.v!=null&&c.v++},n.applyOps=function(l,c,d){d=d||{};for(var h=0;h<c.length;h++){var C=c[h];if(d._normalizeLegacyJson0Ops)try{s(l,C)}catch{return new e(i.ERR_OT_LEGACY_JSON0_OP_CANNOT_BE_NORMALIZED,"Cannot normalize legacy json0 op")}l.v=C.v;var E=n.apply(l,C);if(E)return E}},n.transformPresence=function(l,c,d){var h=this.checkOp(c);if(h)return h;var C=l.t;if(typeof C=="string"&&(C=t.map[C]),!C)return{code:i.ERR_DOC_TYPE_NOT_RECOGNIZED,message:"Unknown type"};if(!r.supportsPresence(C))return{code:i.ERR_TYPE_DOES_NOT_SUPPORT_PRESENCE,message:"Type does not support presence"};if(c.create||c.del){l.p=null,l.v++;return}try{l.p=l.p===null?null:C.transformPresence(l.p,c.op,d)}catch(E){return{code:i.ERR_PRESENCE_TRANSFORM_FAILED,message:E.message||E}}l.v++};function s(l,c){if(l.type===t.defaultType.uri){var d=c.op;if(!!d){var h=l.data;d.length>1&&(h=r.clone(h));for(var C=0;C<d.length;C++){var E=d[C];typeof E.lm=="string"&&(E.lm=+E.lm);for(var A=E.p,v=h,R=0;R<A.length;R++){var L=A[R];Object.prototype.toString.call(v)=="[object Array]"?A[R]=+L:v.constructor===Object&&(A[R]=L.toString()),v=v[L]}C<d.length-1&&(h=t.defaultType.apply(h,[E]))}}}}})(z2);var Du=P2,eN=z2,nN=pr;function pr(n,t){Du.call(this,n,t),this.collection=this.presence.collection,this.id=this.presence.id,this.src=null,this.presenceVersion=null,this._doc=this.connection.get(this.collection,this.id),this._pending=null,this._opCache=null,this._pendingSetPending=!1,this._opHandler=this._handleOp.bind(this),this._createDelHandler=this._handleCreateDel.bind(this),this._loadHandler=this._handleLoad.bind(this),this._registerWithDoc()}pr.prototype=Object.create(Du.prototype),pr.prototype.receiveUpdate=function(n){this._pending&&n.pv<this._pending.pv||(this.src=n.src,this._pending=n,this._setPendingPresence())},pr.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),Du.prototype.destroy.call(this,n)},pr.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)},pr.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))}})}},pr.prototype._handleOp=function(n,t,e){var r=e===this.src;this._transformAgainstOp(n,r),this._cacheOp(n,r),this._setPendingPresence()},Du.prototype._handleCreateDel=function(){this._cacheOp(null),this._setPendingPresence()},Du.prototype._handleLoad=function(){this.value=null,this._pending=null,this._opCache=null,this.presence._updateRemotePresence(this)},pr.prototype._transformAgainstOp=function(n,t){if(!!this.value){try{this.value=this._doc.type.transformPresence(this.value,n,t)}catch(e){return this.presence.emit("error",e)}this.presence._updateRemotePresence(this)}},pr.prototype._catchUpStalePresence=function(){if(this._pending.v>=this._doc.version)return!0;if(!this._opCache)return this._startCachingOps(),this._doc.fetch(),this.presence.subscribe(),!1;for(;this._opCache[this._pending.v];){var n=this._opCache[this._pending.v],t=n.op,e=n.isOwnOp;t===null?(this._pending.p=null,this._pending.v++):eN.transformPresence(this._pending,t,e)}var r=this._pending.v>=this._doc.version;return r&&this._stopCachingOps(),r},pr.prototype._startCachingOps=function(){this._opCache=[]},pr.prototype._stopCachingOps=function(){this._opCache=null},pr.prototype._cacheOp=function(n,t){this._opCache&&(n=n?{op:n}:null,this._opCache[this._doc.version-1]={op:n,isOwnOp:t})};var G2=$2,rN=tN,iN=nN;function Ua(n,t,e){var r=Ua.channel(t,e);G2.call(this,n,r),this.collection=t,this.id=e}var oN=Ua;Ua.prototype=Object.create(G2.prototype),Ua.channel=function(n,t){return n+"."+t},Ua.prototype._createLocalPresence=function(n){return new rN(this,n)},Ua.prototype._createRemotePresence=function(n){return new iN(this,n)};var sN=lN;function lN(n,t,e,r,i){this.id=n,this.v=t,this.type=e,this.data=r,this.m=i}var aN=sN,W2=Yo,q2=_u;function _u(n,t,e,r,i){if(W2.EventEmitter.call(this),typeof i!="function")throw new Error("Callback is required for SnapshotRequest");this.requestId=t,this.connection=n,this.id=r,this.collection=e,this.callback=i,this.sent=!1}W2.mixin(_u),_u.prototype.send=function(){!this.connection.canSend||(this.connection.send(this._message()),this.sent=!0)},_u.prototype._onConnectionStateChanged=function(){this.connection.canSend?this.sent||this.send():this.sent=!1},_u.prototype._handleResponse=function(n,t){if(this.emit("ready"),n)return this.callback(n);var e=t.meta?t.meta:null,r=new aN(this.id,t.v,t.type,t.data,e);this.callback(null,r)};var X2=q2,cN=Vr,uN=rl.ACTIONS,fN=Ip;function Ip(n,t,e,r,i,o){if(X2.call(this,n,t,e,r,o),!cN.isValidVersion(i))throw new Error("Snapshot version must be a positive integer or null");this.version=i}Ip.prototype=Object.create(X2.prototype),Ip.prototype._message=function(){return{a:uN.snapshotFetch,id:this.requestId,c:this.collection,d:this.id,v:this.version}};var Q2=q2,dN=Vr,hN=rl.ACTIONS,mN=Dp;function Dp(n,t,e,r,i,o){if(Q2.call(this,n,t,e,r,o),!dN.isValidTimestamp(i))throw new Error("Snapshot timestamp must be a positive integer or null");this.timestamp=i}Dp.prototype=Object.create(Q2.prototype),Dp.prototype._message=function(){return{a:hN.snapshotFetchByTimestamp,id:this.requestId,c:this.collection,d:this.id,ts:this.timestamp}};var gN=VO,pN=GO,CN=$2,Y2=oN,EN=fN,xN=mN,J2=Yo,Oa=Nh,oe=rl.ACTIONS,Z2=wu,jr=Vr,Mu=w2,Uu=Oa.CODES;function tT(n){return n.readyState===0||n.readyState===1?"connecting":"disconnected"}var AN=kt;function kt(n){J2.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=tT(n),this.bindToSocket(n)}J2.mixin(kt),kt.prototype.bindToSocket=function(n){this.socket&&(this.socket.close(),this.socket.onmessage=null,this.socket.onopen=null,this.socket.onerror=null,this.socket.onclose=null),this.socket=n;var t=tT(n);this._setState(t),this.canSend=!1;var e=this;n.onmessage=function(r){try{var i=typeof r.data=="string"?JSON.parse(r.data):r.data}catch{Mu.warn("Failed to parse message",r);return}e.debug&&Mu.info("RECV",JSON.stringify(i));var o={data:i};if(e.emit("receive",o),!!o.data)try{e.handleMessage(o.data)}catch(s){jr.nextTick(function(){e.emit("error",s)})}},n.readyState===1&&e._initializeHandshake(),n.onopen=function(){e._setState("connecting"),e._initializeHandshake()},n.onerror=function(r){e.emit("connection error",r)},n.onclose=function(r){r==="closed"||r==="Closed"?e._setState("closed",r):r==="stopped"||r==="Stopped by server"?e._setState("stopped",r):e._setState("disconnected",r)}},kt.prototype.handleMessage=function(n){var t=null;switch(n.error&&(t=eT(n.error,n),delete n.error),n.a){case oe.initLegacy:return this._handleLegacyInit(n);case oe.handshake:return this._handleHandshake(t,n);case oe.queryFetch:var e=this.queries[n.id];e&&e._handleFetch(t,n.data,n.extra);return;case oe.querySubscribe:var e=this.queries[n.id];e&&e._handleSubscribe(t,n.data,n.extra);return;case oe.queryUnsubscribe:return;case oe.queryUpdate:var e=this.queries[n.id];if(!e)return;if(t)return e._handleError(t);n.diff&&e._handleDiff(n.diff),n.hasOwnProperty("extra")&&e._handleExtra(n.extra);return;case oe.bulkFetch:return this._handleBulkMessage(t,n,"_handleFetch");case oe.bulkSubscribe:case oe.bulkUnsubscribe:return this._handleBulkMessage(t,n,"_handleSubscribe");case oe.snapshotFetch:case oe.snapshotFetchByTimestamp:return this._handleSnapshotFetch(t,n);case oe.fetch:var r=this.getExisting(n.c,n.d);r&&r._handleFetch(t,n.data);return;case oe.subscribe:case oe.unsubscribe:var r=this.getExisting(n.c,n.d);r&&r._handleSubscribe(t,n.data);return;case oe.op:var r=this.getExisting(n.c,n.d);r&&r._handleOp(t,n);return;case oe.presence:return this._handlePresence(t,n);case oe.presenceSubscribe:return this._handlePresenceSubscribe(t,n);case oe.presenceUnsubscribe:return this._handlePresenceUnsubscribe(t,n);case oe.presenceRequest:return this._handlePresenceRequest(t,n);case oe.pingPong:return this._handlePingPong(t);default:Mu.warn("Ignoring unrecognized message",n)}};function eT(n,t){var e=new Error(n.message);return e.code=n.code,t&&(e.data=t),e}kt.prototype._handleBulkMessage=function(n,t,e){if(t.data)for(var r in t.data){var i=t.data[r],o=this.getExisting(t.c,r);o&&(n?o[e](n):i.error?o[e](eT(i.error)):o[e](null,i))}else if(Array.isArray(t.b))for(var s=0;s<t.b.length;s++){var r=t.b[s],o=this.getExisting(t.c,r);o&&o[e](n)}else if(t.b)for(var r in t.b){var o=this.getExisting(t.c,r);o&&o[e](n)}else Mu.error("Invalid bulk message",t)},kt.prototype._reset=function(){this.agent=null},kt.prototype._setState=function(n,t){if(this.state!==n){if(n==="connecting"&&this.state!=="disconnected"&&this.state!=="stopped"&&this.state!=="closed"||n==="connected"&&this.state!=="connecting"){var e=new Oa(Uu.ERR_CONNECTION_STATE_TRANSITION_INVALID,"Cannot transition directly from "+this.state+" to "+n);return this.emit("error",e)}this.state=n,this.canSend=n==="connected",(n==="disconnected"||n==="stopped"||n==="closed")&&this._reset(),this.startBulk();for(var r in this.queries){var i=this.queries[r];i._onConnectionStateChanged()}for(var o in this.collections){var s=this.collections[o];for(var r in s)s[r]._onConnectionStateChanged()}for(var l in this._presences)this._presences[l]._onConnectionStateChanged();for(var r in this._snapshotRequests){var c=this._snapshotRequests[r];c._onConnectionStateChanged()}this.endBulk(),this.emit(n,t),this.emit("state",n,t)}},kt.prototype.startBulk=function(){this.bulk||(this.bulk={})},kt.prototype.endBulk=function(){if(this.bulk)for(var n in this.bulk){var t=this.bulk[n];this._sendBulk("f",n,t.f),this._sendBulk("s",n,t.s),this._sendBulk("u",n,t.u)}this.bulk=null},kt.prototype._sendBulk=function(n,t,e){if(!!e){var r=[],i={},o=0,s;for(var l in e){var c=e[l];c==null?r.push(l):(i[l]=c,s=l,o++)}if(r.length===1){var l=r[0];this.send({a:n,c:t,d:l})}else r.length&&this.send({a:"b"+n,c:t,b:r});if(o===1){var d=i[s];this.send({a:n,c:t,d:s,v:d})}else o&&this.send({a:"b"+n,c:t,b:i})}},kt.prototype._sendActions=function(n,t,e){if(this._addDoc(t),this.bulk){var r=this.bulk[t.collection]||(this.bulk[t.collection]={}),i=r[n]||(r[n]={}),o=i.hasOwnProperty(t.id);return i[t.id]=e,o}else{var s={a:n,c:t.collection,d:t.id,v:e};this.send(s)}},kt.prototype.sendFetch=function(n){return this._sendActions(oe.fetch,n,n.version)},kt.prototype.sendSubscribe=function(n){return this._sendActions(oe.subscribe,n,n.version)},kt.prototype.sendUnsubscribe=function(n){return this._sendActions(oe.unsubscribe,n)},kt.prototype.sendOp=function(n,t){this._addDoc(n);var e={a:oe.op,c:n.collection,d:n.id,v:n.version,src:t.src,seq:t.seq,x:{}};"op"in t&&(e.op=t.op),t.create&&(e.create=t.create),t.del&&(e.del=t.del),n.submitSource&&(e.x.source=t.source),this.send(e)},kt.prototype.send=function(n){this.debug&&Mu.info("SEND",JSON.stringify(n)),this.emit("send",n),this.socket.send(JSON.stringify(n))},kt.prototype.ping=function(){if(!this.canSend)throw new Oa(Uu.ERR_CANNOT_PING_OFFLINE,"Socket must be CONNECTED to ping");var n={a:oe.pingPong};this.send(n)},kt.prototype.close=function(){this.socket.close()},kt.prototype.getExisting=function(n,t){if(this.collections[n])return this.collections[n][t]},kt.prototype.get=function(n,t){var e=this.collections[n]||(this.collections[n]={}),r=e[t];return r||(r=e[t]=new gN(this,n,t),this.emit("doc",r)),r._wantsDestroy=!1,r},kt.prototype._destroyDoc=function(n){!n._wantsDestroy||(jr.digAndRemove(this.collections,n.collection,n.id),n.emit("destroy"))},kt.prototype._addDoc=function(n){var t=this.collections[n.collection];t||(t=this.collections[n.collection]={}),t[n.id]!==n&&(t[n.id]=n)},kt.prototype._createQuery=function(n,t,e,r,i){var o=this.nextQueryId++,s=new pN(n,this,o,t,e,r,i);return this.queries[o]=s,s.send(),s},kt.prototype._destroyQuery=function(n){delete this.queries[n.id]},kt.prototype.createFetchQuery=function(n,t,e,r){return this._createQuery(oe.queryFetch,n,t,e,r)},kt.prototype.createSubscribeQuery=function(n,t,e,r){return this._createQuery(oe.querySubscribe,n,t,e,r)},kt.prototype.hasPending=function(){return!!(this._firstDoc(Hh)||this._firstQuery(Hh)||this._firstSnapshotRequest())};function Hh(n){return n.hasPending()}kt.prototype.hasWritePending=function(){return!!this._firstDoc(bN)};function bN(n){return n.hasWritePending()}kt.prototype.whenNothingPending=function(n){var t=this._firstDoc(Hh);if(t){t.once("nothing pending",this._nothingPendingRetry(n));return}var e=this._firstQuery(Hh);if(e){e.once("ready",this._nothingPendingRetry(n));return}var r=this._firstSnapshotRequest();if(r){r.once("ready",this._nothingPendingRetry(n));return}jr.nextTick(n)},kt.prototype._nothingPendingRetry=function(n){var t=this;return function(){jr.nextTick(function(){t.whenNothingPending(n)})}},kt.prototype._firstDoc=function(n){for(var t in this.collections){var e=this.collections[t];for(var r in e){var i=e[r];if(n(i))return i}}},kt.prototype._firstQuery=function(n){for(var t in this.queries){var e=this.queries[t];if(n(e))return e}},kt.prototype._firstSnapshotRequest=function(){for(var n in this._snapshotRequests)return this._snapshotRequests[n]},kt.prototype.fetchSnapshot=function(n,t,e,r){typeof e=="function"&&(r=e,e=null);var i=this.nextSnapshotRequestId++,o=new EN(this,i,n,t,e,r);this._snapshotRequests[o.requestId]=o,o.send()},kt.prototype.fetchSnapshotByTimestamp=function(n,t,e,r){typeof e=="function"&&(r=e,e=null);var i=this.nextSnapshotRequestId++,o=new xN(this,i,n,t,e,r);this._snapshotRequests[o.requestId]=o,o.send()},kt.prototype._handleSnapshotFetch=function(n,t){var e=this._snapshotRequests[t.id];!e||(delete this._snapshotRequests[t.id],e._handleResponse(n,t))},kt.prototype._handleLegacyInit=function(n){if(n.protocolMinor)return this._initializeHandshake();this._initialize(n)},kt.prototype._initializeHandshake=function(){this.send({a:oe.handshake,id:this.id})},kt.prototype._handleHandshake=function(n,t){if(n)return this.emit("error",n);this._initialize(t)},kt.prototype._handlePingPong=function(n){if(n)return this.emit("error",n);this.emit("pong")},kt.prototype._initialize=function(n){if(this.state==="connecting"){if(n.protocol!==1)return this.emit("error",new Oa(Uu.ERR_PROTOCOL_VERSION_NOT_SUPPORTED,"Unsupported protocol version: "+n.protocol));if(Z2.map[n.type]!==Z2.defaultType)return this.emit("error",new Oa(Uu.ERR_DEFAULT_TYPE_MISMATCH,n.type+" does not match the server default type"));if(typeof n.id!="string")return this.emit("error",new Oa(Uu.ERR_CLIENT_ID_BADLY_FORMED,"Client id must be a string"));this.id=n.id,this._setState("connected")}},kt.prototype.getPresence=function(n){var t=this,e=jr.digOrCreate(this._presences,n,function(){return new CN(t,n)});return e._wantsDestroy=!1,e},kt.prototype.getDocPresence=function(n,t){var e=Y2.channel(n,t),r=this,i=jr.digOrCreate(this._presences,e,function(){return new Y2(r,n,t)});return i._wantsDestroy=!1,i},kt.prototype._sendPresenceAction=function(n,t,e){this._addPresence(e);var r={a:n,ch:e.channel,seq:t};return this.send(r),r.seq},kt.prototype._addPresence=function(n){jr.digOrCreate(this._presences,n.channel,function(){return n})},kt.prototype._handlePresenceSubscribe=function(n,t){var e=jr.dig(this._presences,t.ch);e&&e._handleSubscribe(n,t.seq)},kt.prototype._handlePresenceUnsubscribe=function(n,t){var e=jr.dig(this._presences,t.ch);e&&e._handleUnsubscribe(n,t.seq)},kt.prototype._handlePresence=function(n,t){var e=jr.dig(this._presences,t.ch);e&&e._receiveUpdate(n,t)},kt.prototype._handlePresenceRequest=function(n,t){var e=jr.dig(this._presences,t.ch);e&&e._broadcastAllLocalPresence(n,t)};var nT=AN,vN=wu;const jh={err:1001,msg:"user auth error",name:"AuthError"},BN={err:1002,msg:"you don't have required permission",name:"PermissionError"},_p={err:1003,msg:"Too many user connected",name:"MaxUserError"},Ou={err:1004,msg:"document server changed, reload it",name:"RequestReloadError"},TN={err:1005,msg:"app id must be at least 2 chars, doc id must be at least 5 chars",name:"DocIdError"},yN={err:1028,msg:"upload file ext not allowed",name:"FileExtError"},il="x-live-editor-token",Na="x-live-editor-base-url",vn=I("auth-connection");function kN(n){try{n()}catch(t){vn.error(t)}}class RN{constructor(t,e){m(this,"enabled",!0);m(this,"connection");m(this,"ws");m(this,"retryCount");m(this,"events",new pb.EventEmitter);m(this,"token",null);m(this,"resourceToken",null);this.url=t,this.reauthFunc=e,this.retryCount=0}getBaseURL(){const t=new URL(this.url);return`${t.protocol==="wss:"?"https:":"http:"}//${t.host}${t.pathname}`}getBase64BaseURL(){return ci(this.getBaseURL())}async auth(t){p(vn,t.token,"no auth token");const e=`${this.getBaseURL()}/auth`,r=await window.fetch(e,{method:"GET",headers:{[il]:t.token,[Na]:this.getBase64BaseURL()},credentials:"include"});if(r.status!==200)throw new Error("http auth error");return this.enabled?(this.token=t.token,await r.json()):{read:"",user:""}}async logout(){if(!this.token)return;const t=`${this.getBaseURL()}/logout`;await window.fetch(t,{method:"GET",headers:{[Na]:ci(this.getBaseURL())}})}async init(t){const e=await this.auth(t);if(!this.enabled)return;this.resourceToken=e.read,this.ws=new X6.default(this.url,void 0,{maxReconnectionDelay:2500,minReconnectionDelay:1e3}),this.connection=Object.create(nT.prototype),p(vn,this.connection,"no this.connection"),this.ws,this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:t})};const r=this.connection.handleMessage.bind(this.connection);this.connection.handleMessage=i=>{var s;const o=i;if(this.connection&&(this.connection.lastReceiveTime=Date.now()),"err"in o||o.a==="pong")this.handleMessage(o);else{Object.prototype.hasOwnProperty.call(o,"a")&&o.a!=="init"&&o.a!=="hs"&&(this.retryCount=0);try{r(o)}catch(l){if((l==null?void 0:l.type)==="writeConflict"){this.emitWriteConflictError(l,o);return}if((s=l==null?void 0:l.message)!=null&&s.startsWith("Cannot invert subtype")){this.emitWriteConflictError(l,o);return}throw l}}},nT.apply(this.connection,[this.ws])}async handleAuthError(){if(this.reauthFunc&&this.retryCount<5){this.retryCount+=1,vn.info(`retrying re-auth attempt no. ${this.retryCount}`);try{if(this.connection){const t=await this.reauthFunc();if(await this.auth(t),!this.enabled){this.retryCount=10,setTimeout(()=>this.handleAuthError(),0);return}this.connection._initializeHandshake=function(){this.send({a:"hs",id:this.id,auth:t})}}}catch(t){vn.error(t),setTimeout(()=>this.handleAuthError(),0)}}else vn.error("auth error, cannot retry anymore"),this.emitAuthError(),this.end(!1)}emitAuthError(){const t=new Error(jh.msg);t.code=jh.err,this.events.emit("error",t)}emitRequestReloadError(){const t=new Error(Ou.msg);t.code=Ou.err,this.events.emit("requestReloadError",t)}emitWriteConflictError(t,e){t.orgMsg=e,this.events.emit("writeConflictError",t)}emitMaxUsersError(){this.events.emit("maxUsersError"),this.end(!1)}handleMessage(t){const e=t;if(e.a==="pong")return;const r=e.err;if(r===jh.err)vn.warn("auth error"),this.handleAuthError();else if(r===_p.err)vn.warn(_p.msg),this.emitMaxUsersError();else if(r===Ou.err){vn.warn(Ou.msg);try{this.emitRequestReloadError()}catch(i){vn.error(`error occurred while process reload error: ${JSON.stringify(i)}`)}finally{this.end(!1)}}else vn.error(`unknown message received: ${JSON.stringify(e)}`),this.emitAuthError()}get(t,e){return p(vn,this.connection,"no this.connection"),this.connection.get(t,e)}addEventListener(t,e){t==="error"?this.events.addListener(t,e):(p(vn,this.ws,"no this.ws"),this.ws.addEventListener(t,e))}onAuthError(t){this.events.addListener("error",t)}onWriteConflictError(t){this.events.addListener("writeConflictError",t)}onMaxUsersError(t){p(vn,this.events.listenerCount("maxUsersError")===0,"too many maxUserError listener"),this.events.addListener("maxUsersError",t)}onRequestReloadError(t){p(vn,this.events.listenerCount("requestReloadError")===0,"to many requestReloadError listener"),this.events.addListener("requestReloadError",t)}end(t){var e;this.enabled=!1,this.reauthFunc=void 0,this.events.removeAllListeners(),kN(()=>{var r;return(r=this.connection)==null?void 0:r.close()}),this.connection=void 0,(e=this.ws)==null||e.close(),this.ws=void 0,t&&this.logout()}}I("utils/file");function wN(){function n(){return new Promise(t=>{const e=new FileReader;e.onload=()=>{t(e.result)},e.readAsArrayBuffer(this)})}File.prototype.arrayBuffer=File.prototype.arrayBuffer||n,Blob.prototype.arrayBuffer=Blob.prototype.arrayBuffer||n}wN();async function SN(n){const e=n.size,r=Math.floor((e+102400-1)/102400),i=new Q6.Hash;for(let s=0;s<r;s++){const l=s*102400;let c=l+102400;c>e&&(c=e);const h=await n.slice(l,c,n.type).arrayBuffer();i.update(new Uint8Array(h))}const o=i.digest();return ci(o)}const xi=I("sharedb-doc/client"),LN=Eb.default.create();class IN{constructor(t,e,r){m(this,"connection");m(this,"auth");m(this,"doc",null);m(this,"reauthFunc");m(this,"clientId",Z());m(this,"getDoc",async()=>{const t=r=>new Promise((i,o)=>{r.fetch(s=>{s?o(s):i()})});p(xi,!this.doc,"This websocket has opened a doc."),await this.connection.init(this.auth);const e=this.connection.get(this.auth.appId,this.auth.docId);return this.doc=e,await t(e),xi.debug(e),e});this.auth=t;const i=`${e}/${this.auth.appId}/${this.auth.docId}`;vN.register(yd.type),this.connection=new RN(i,r),this.reauthFunc=r}editorServer(){const t=this.apiServer(),e=`/${this.auth.appId}/${this.auth.docId}`;return p(xi,t.endsWith(e),`invalid api server: ${t}, ${e}`),t.substr(0,t.length-e.length)}close(t){this.connection.end(t),this.doc=null}on(t,e){this.connection.addEventListener(t,r=>{(t==="error"||this.doc)&&e(r)})}onAuthError(t){this.connection.onAuthError(t)}onWriteConflictError(t){this.connection.onWriteConflictError(t)}onMaxUsersError(t){this.connection.onMaxUsersError(t)}onRequestReloadError(t){this.connection.onRequestReloadError(t)}async authOnly(){await this.connection.auth(this.auth)}getResourceToken(){return this.connection.resourceToken}hasDocContainer(){return!!this.doc}apiServer(){const t=this.connection.url;if(t.startsWith("ws://"))return`http://${t.substring(5)}`;if(t.startsWith("wss://"))return`https://${t.substring(6)}`;throw new Error(`invalid server url: ${t}`)}async getFileUrlByHash(t,e,r,i,o){try{const s=`${t}/${e}`,l=await this.request(s,{method:"post",headers:{...o},data:{name:r,size:i}});return l.data&&Array.isArray(l.data)&&l.data.length===1?l.data[0]:""}catch{return""}}async getFileUrlsByHashes(t){const r=`${this.apiServer()}/resources`;try{const i=`${r}/hash`,o=await this.request(i,{method:"post",headers:{[il]:this.connection.token},data:{resources:t}});return o.data&&Array.isArray(o.data)?o.data:[]}catch{return[]}}async uploadFile(t,e,r,i,o){let s=e.size;if(s===0)throw new Error("file is empty");s+=500;const l=A=>{xi.info(`on progress: ${A.loaded}`);let v=A.loaded*100/s;v>100&&(v=100),i(v)},c=await SN(e),d=await this.getFileUrlByHash(t,c,e.name,e.size,r);if(d)return i(-1),d;let h=t;o!=null&&o.thumbnail&&(h+="/thumbnail");const C=new FormData;C.append("file-size",`${e.size}`),C.append("file-hash",c),C.append("file",e,e.name);const E=await this.request(h,{method:"post",data:C,withCredentials:!0,headers:{...r},onUploadProgress:l});return xi.info(E),i(100),Array.isArray(E.data)?E.data[0]:E.data}async uploadResource(t,e=()=>{},r){const o=`${this.apiServer()}/resources`;p(xi,this.connection.token,"no connection token");const s=await this.uploadFile(o,t,{[il]:this.connection.token},e,r);return p(xi,s,"no result"),s}async request(t,e){var o,s;let r=this.connection.token,i;for(let l=0;l<2;l++){const c=e||{};c.url=t,c.headers||(c.headers={}),p(xi,r,"no token"),c.headers={...c.headers,[il]:r,[Na]:this.connection.getBase64BaseURL()};try{return await LN(t,c)}catch(d){if(i=d,((o=d==null?void 0:d.response)==null?void 0:o.status)===403&&this.reauthFunc){const h=await this.reauthFunc();if(await this.connection.auth(h),!h.token)throw d;r=h.token;continue}throw(s=d.response)!=null&&s.data&&(d.responseData=d.response.data),d}}throw p(xi,i,"no error"),i}async getVersions(){const e=`${this.apiServer()}/versions?withExtra=true`,i=(await this.request(e)).data.versions;return i.forEach(o=>{o.extra&&(o.extra=JSON.parse(o.extra))}),i}async getVersion(t){const r=`${this.apiServer()}/versions/${t}`,i=await this.request(r);return JSON.parse(i.data.data)}async getLatestVersion(){const e=`${this.apiServer()}/versions/latest`,r=await this.request(e);return JSON.parse(r.data.data)}async getVersionOps(t,e){let i=`${this.apiServer()}/versions/before/${t}?withOp=true`;e!==void 0&&e!==0&&(i+=`&from=${e}`);const o=await this.request(i),s=o.data.ops,l=xb.default(s,h=>!!h.create);let c=null;l!==-1&&(c=s[l],s.splice(0,l+1));let d;return c?(p(xi,c.create,"no createDoc.create"),d=c.create.data):d=JSON.parse(o.data.data),d.blocks||(d.blocks=[]),{doc:d,ops:o.data.ops}}async updateVersionExtra(t,e,r){const o=`${this.apiServer()}/versions/${t}/tags/${e}`;await this.request(o,{method:"post",data:{extra:JSON.stringify(r)}})}async revertVersion(t){const r=`${this.apiServer()}/versions/revert/${t}`;await this.request(r,{method:"post",data:{}})}async createVersion(t,e){const i=`${this.apiServer()}/versions`;return(await this.request(i,{method:"post",data:{publish:e,tag:t}})).data}async recognizeLink(t){const r=`${this.apiServer()}/resources/external/${ci(t)}`;return(await this.request(r)).data}buildResourceUrl(t,e){if(!t)return"";if(t.startsWith("https:")||t.startsWith("http:")||t.startsWith("file:")||t.startsWith("data:")||t.startsWith("blob:"))return t;let i=`${this.apiServer()}/resources/${encodeURIComponent(t)}`;const o=[];if(e!=null&&e.withToken&&o.push(`token=${this.getResourceToken()}`),e!=null&&e.downloadFileName&&o.push(`&fileName=${encodeURIComponent(e.downloadFileName)}`),o.length>0){const s=o.join("&");i+=`?${s}`}return i}}function DN(){return{blocks:[{id:Z(),type:"text",text:[]}],comments:{},meta:{}}}const Mp=I("block-ids");class _N{constructor(){m(this,"ids",new Map)}onInsertBlock(t){const e=Array.from(this.ids.keys()).sort((i,o)=>o-i);for(let i=0;i<e.length;i++){const o=e[i];if(o>=t){const s=this.ids.get(o);p(Mp,s!==void 0,"old id is not exists"),this.ids.delete(o),this.ids.set(o+1,s)}}const r=Z();this.ids.set(t,r)}onDeleteBlock(t){this.ids.delete(t);const e=Array.from(this.ids.keys()).sort((r,i)=>r-i);for(let r=0;r<e.length;r++){const i=e[r];if(i>t){const o=this.ids.get(i);p(Mp,o!==void 0,"old id is not exists"),this.ids.delete(i),this.ids.set(i-1,o)}}}getId(t){let e=this.ids.get(t);return e||(e=Z(),this.ids.set(t,e)),e}getById(t){return Array.from(this.ids.entries()).find(([,e])=>e===t)}}class MN{constructor(){m(this,"ids",new Map)}getContainerIds(t){let e=this.ids.get(t);return e||(e=new _N,this.ids.set(t,e)),e}onInsertBlock(t,e){this.getContainerIds(t).onInsertBlock(e)}onDeleteBlock(t,e){this.getContainerIds(t).onDeleteBlock(e)}getBlockId(t,e){return this.getContainerIds(t).getId(e)}getBlockIndexById(t){const e=Array.from(this.ids.entries());for(let r=0;r<e.length;r++){const i=e[r],o=i[1].getById(t);if(o)return{containerId:i[0],blockIndex:o[0]}}return p(Mp,!1,"fault error: failed to get block index"),{containerId:"error",blockIndex:-1}}}class rT{constructor(t=new Set,e=new Map){this.deletedKeys=t,this.insertedValues=e}insert(t,e){this.insertedValues.set(t,e)}delete(t){this.deletedKeys.add(t)}toDocBlockDelta(){const t={};return this.insertedValues.forEach((e,r)=>{t[r]=e}),{insert:t,delete:Array.from(this.deletedKeys)}}}const Up=I("op-parse-handler");class UN{constructor(t,e){m(this,"actions",[]);this.outerHandler=t,this.local=e}pushActions(t){if(!t.containerId){this.actions.push(t);return}const r={...t,containerId:(i=>i==="blocks"?"root":i)(t.containerId)};this.actions.push(r)}onDeleteBlock(t,e){this.pushActions({type:"deleteBlock",containerId:t,blockIndex:e})}onInsertBlock(t,e,r){this.pushActions({type:"insertBlock",containerId:t,blockIndex:e,data:r})}onDeleteBlockData(t,e,r){this.pushActions({type:"deleteBlockData",containerId:t,blockIndex:e,key:r})}onInsertBlockData(t,e,r,i){this.pushActions({type:"insertBlockData",containerId:t,blockIndex:e,key:r,value:i})}onUpdateBlockText(t,e,r){this.pushActions({type:"updateBlockText",containerId:t,blockIndex:e,richTextData:r})}onDeleteContainer(t){this.pushActions({type:"deleteContainer",containerId:t})}onCreateContainer(t,e){this.pushActions({type:"createContainer",containerId:t,data:e})}onDeleteComment(t){this.pushActions({type:"deleteComment",commentId:t})}onCreateComment(t){this.pushActions({type:"createComment",commentId:t})}onUpdateComment(t){this.pushActions({type:"updateComment",commentId:t})}end(){const t=this.actions,e=new Set,r=new Map,i=new MN,o=t.filter(s=>s.type==="deleteBlock"||s.type==="deleteBlockData");for(const s of o)if(s.type==="deleteBlock"){const l=s,c=i.getBlockId(l.containerId,l.blockIndex);i.onDeleteBlock(l.containerId,l.blockIndex);const d=r.get(c);d&&(Up.debug(`ignore update object data before delete block: ${JSON.stringify(d)}`),r.delete(c));const h=`${l.containerId}-${l.blockIndex}`;e.add(h),this.outerHandler.onDeleteBlock(l.containerId,l.blockIndex,this.local)}else if(s.type==="deleteBlockData"){const l=s,c=`${l.containerId}-${l.blockIndex}`;if(e.has(c)){Up.warn("delete block data after delete block, ignore it");continue}const d=i.getBlockId(l.containerId,l.blockIndex);let h=r.get(d);h||(h=new rT,r.set(d,h)),h.delete(l.key)}else p(Up,!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,c=i.getBlockId(l.containerId,l.blockIndex);let d=r.get(c);d||(d=new rT,r.set(c,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(r.entries()).forEach(([s,l])=>{const{containerId:c,blockIndex:d}=i.getBlockIndexById(s);this.outerHandler.onUpdateBlockData(c,d,l.toDocBlockDelta(),this.local)})}}const Ke=I("op-parser");class iT{}class Op{constructor(t){m(this,"key");this.key=t}}function ON(n,t,e){const r=t.concat(),i=r[0];if(typeof i!="number"||(r.shift(),r.length===1))return!1;const o=r[0];if(typeof o!="object"||!o.i||Object.keys(o).length!==1)return!1;for(let l=1;l<r.length;l++){const c=r[l];if(!Array.isArray(c)||c.length!==2||typeof c[0]!="string")return!1;const h=c[1];if(typeof h!="object"||h.i===void 0||Object.keys(h).length!==1)return!1}const s=o.i;p(Ke,s.id,"block id is required"),p(Ke,s.type,"block type is required");for(let l=1;l<r.length;l++){const c=r[l],d=c[0],h=c[1];s[d]=h.i}return e.onInsertBlock(n,i,s),!0}function Np(n,t,e,r){if(e==="upsert"&&ON(n,t,r))return;p(Ke,Array.isArray(t),`invalid block op: ${n}, ${JSON.stringify(t)}`);const i=t.concat(),o=i[0];i.shift();const s=[];for(;i.length>0;){const l=i[0];if(l==="text"){const c=i[1];if(p(Ke,typeof c=="object",`invalid block op: ${n}, ${JSON.stringify(t)}`),p(Ke,c.et==="rich-text",`invalid block op: ${n}, ${JSON.stringify(t)}`),i.splice(0,2),e==="upsert"){const h=c.e;r.onUpdateBlockText(n,o,h)}p(Ke,i.length===0,`invalid block ops.length !== 0, ${JSON.stringify(i)}`)}else if(Array.isArray(l)){p(Ke,l.length===2,`invalid block op: data.length !== 2, ${JSON.stringify(l)}`);const c=l[0];p(Ke,typeof c=="string",`invalid block op: key ${JSON.stringify(c)}`);const d=l[1];if(c==="text"){if(p(Ke,typeof d=="object",`invalid opData type, ${JSON.stringify(d)}`),d.i&&e==="upsert"&&r.onInsertBlockData(n,o,c,d.i),d.r&&e==="remove"&&r.onDeleteBlockData(n,o,c),d.et==="rich-text"&&e==="upsert"){const C=d.e;r.onUpdateBlockText(n,o,C)}}else e==="remove"&&d.r&&s.push(new Op(c)),e==="upsert"&&d.i&&r.onInsertBlockData(n,o,c,d.i);i.shift()}else if(typeof l=="object"){const c=l;e==="remove"&&c.r&&s.push(new iT),e==="upsert"&&c.i&&r.onInsertBlock(n,o,c.i),i.shift()}else{p(Ke,typeof l=="string","data is not string"),p(Ke,l!=="text","data !== 'text'"),p(Ke,i.length===2,`invalid block op: ops.length !== 2, ${JSON.stringify(i)}`);const c=l,d=i[1];e==="remove"&&d.r&&s.push(new Op(c)),e==="upsert"&&d.i&&r.onInsertBlockData(n,o,c,d.i),i.splice(0,2)}}s.reverse(),s.forEach(l=>{l instanceof iT?r.onDeleteBlock(n,o):l instanceof Op?r.onDeleteBlockData(n,o,l.key):p(Ke,!1,`invalid action type: ${typeof l}, ${JSON.stringify(l)}`)})}function NN(n,t,e){Ke.warn(`unsupported meta op, ${JSON.stringify(n)}`)}function PN(n,t,e){const r=n[1],i=n[2];p(Ke,r,`invalid comment op, no commentId: ${JSON.stringify(n)}`),p(Ke,i,`invalid comment op, no actions: ${JSON.stringify(n)}`),typeof i=="string"?Ke.error(`unknown comment op, ${JSON.stringify(n)}`):i.i&&i.r?t==="upsert"&&e.onUpdateComment(r):i.i?t==="upsert"&&e.onCreateComment(r):i.r?t==="remove"&&e.onDeleteComment(r):Ke.error(`unknown comment op, ${JSON.stringify(n)}`)}function Pp(n,t,e){const r=n[0];if(Array.isArray(r)){r.forEach(s=>{Pp(s,t,e)});return}const i=r;if(p(Ke,typeof i=="string",`invalid container id: ${JSON.stringify(n)}`),i==="meta"){NN(n);return}if(i==="comments"){PN(n,t,e);return}const o=i;if(Array.isArray(n[1]))t==="remove"?n.slice(1).reverse().forEach(s=>{Np(o,s,t,e)}):n.slice(1).forEach(s=>{Np(o,s,t,e)});else if(typeof n[1]=="object"){const s=n[1];s.r&&t==="remove"&&e.onDeleteContainer(o),s.i&&t==="upsert"&&e.onCreateContainer(o,s.i)}else p(Ke,typeof n[1]=="number",`invalid ops[1], not a number: ${JSON.stringify(n)}`),Np(o,n.slice(1),t,e)}function Fp(n,t,e){const r=new UN(t,e);for(let i=0;i<2;i++){const o=i===0?"remove":"upsert",s=gt.default(n),l=s[0];Array.isArray(l)?s.forEach(c=>{Pp(c,o,r)}):Pp(s,o,r)}r.end()}const FN=I("sharedb-comments");function Kp(n){const t=n.blocks;p(FN,t,"no comment blocks");const e={blocks:{root:t},meta:{},comments:{}};return Object.entries(n).forEach(([r,i])=>{Array.isArray(i)&&(e.blocks[r]=i)}),gt.default(e)}function oT(n){const{id:t,groupId:e,userId:r,displayName:i,avatarUrl:o,abstract:s,created:l,modified:c}=n;return{id:t,groupId:e,userId:r,displayName:i,avatarUrl:o,abstract:s,created:l,modified:c}}function Vp(n,t){const e=vO(t),{comments:r,meta:i,blocks:o,...s}=e,l={...n,blocks:o,...s},c=gt.default(l);return delete c.children,c}const se=I("sharedb-doc/doc-container"),sT="ot-json1";yd.type.registerSubtype(BO.type),yd.type.name=sT,yd.type.invert=null;class Nu extends sa{constructor(e,r,i=!0){super();m(this,"doc");m(this,"client");m(this,"localPresence");m(this,"remoteCaretHandler",new AO);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",e=>{this.callbacks.forEach(r=>{var i;return(i=r.onRequestReload)==null?void 0:i.call(r,e)})});m(this,"handleReset",async e=>{const r=new Error(`reset doc: ${e}`);r.code="ResetDoc",this.callbacks.forEach(i=>{var o;return(o=i.onError)==null?void 0:o.call(i,r)}),this.destroy()});m(this,"handleWriteConflictError",e=>{this.handleReset(`write conflict: ${e.message}, ${JSON.stringify(e.orgMsg)}`)});m(this,"insertObject",async(e,r,i)=>{const o=[e,r,{i}];return this.submitOp(o)});m(this,"deleteObject",async(e,r)=>{const i=[e,r,{r:!0}];return this.submitOp(i)});m(this,"replaceObject",async(e,r,i)=>{const o=[e,r,{r:!0,i}];return this.submitOp(o)});m(this,"updateObject",async(e,r,i)=>{const o=this.data()[e][r],s=[e,r];return Object.entries(i).forEach(([l,c])=>{if(!qc.default(o[l],c))if(o[l]===void 0){if(c!=null){const d={i:c};s.push([l,d])}}else if(c==null){const d={r:!0};s.push([l,d])}else{const d={r:!0,i:c};s.push([l,d])}}),Object.entries(o).forEach(([l,c])=>{if((i[l]===void 0||i[l]===null)&&c!==void 0){const d={r:!0};s.push([l,d])}}),s.length<=2?Promise.resolve():this.submitOp(s)});m(this,"broadcastMessage",async e=>{const r={type:"custom",data:e,clientId:this.client.clientId};this.localPresence&&this.localPresence.submit(r)});m(this,"data",()=>this.doc.data);m(this,"submitOp",async e=>new Promise((r,i)=>{if(this.destroyed){se.warn("submit op after destroyed");return}this.setStatus("dirty"),this.doc.submitOp(e,{},o=>{o?(se.error(`invalid op, ${o.message}, ${JSON.stringify(e)}`),i(o),se.error("Transform detected write conflict, reload editor"),this.handleReset("write conflict")):r()}),this.doc.data||(se.error("no data after submit op, may be the submitted op is invalid"),this.handleReset(`invalid op, ${JSON.stringify(e)}`))}));m(this,"createDoc",async e=>new Promise((r,i)=>{this.doc.create(e,sT,o=>{o?i(o):r()})}));m(this,"submitInsertChildContainers",async e=>{if(e.length===0)return Promise.resolve();const r=e.map(({containerId:i,blocks:o})=>[so(i),{i:o}]);return this.submitOp([r])});m(this,"submitDeleteChildContainer",async e=>{const r=[so(e),{r:!0}];return this.submitOp(r)});m(this,"submitInsertBlock",async(e,r,i)=>{const o=[so(e),r,{i}];return this.submitOp(o)});m(this,"submitDeleteBlock",async(e,r)=>{const i=[so(e),r,{r:!0}];return this.submitOp(i)});m(this,"submitUpdateBlockData",async(e,r,i)=>{if(i.delete.length===0&&Object.keys(i.insert).length===0)return Promise.resolve();const o=[so(e),r],s=new Set(i.delete);Object.entries(i.insert).forEach(([c,d])=>{if(s.has(c)){const h={r:!0,i:d};o.push([c,h])}});const l=new Set(Object.keys(i.insert));return i.delete.forEach(c=>{if(l.has(c))return;const d={r:!0};o.push([c,d])}),Object.entries(i.insert).forEach(([c,d])=>{if(s.has(c))return;const h={i:d};o.push([c,h])}),this.submitOp(o)});m(this,"submitUpdateRichText",async(e,r,i)=>{const o=[so(e),r,"text",{e:i,et:"rich-text"}];return this.submitOp(o)});m(this,"handleOp",(e,r,i)=>{if(this.destroyed){se.warn("handleOp: destroyed");return}try{Fp(e,this,!!r)}catch(o){throw se.error(o),o}});this.client=e,this.doc=r,this.doc.preventCompose=!0,this.disableLogout=i,this.registerCallback(this.remoteCaretHandler)}beginBatchUpdate(){return this.doc.preventCompose=!1,this.batching++,this.batching}endBatchUpdate(){return this.batching--,p(se,this.batching>=0,"invalid call beginBatchUpdate/endBatchUpdate"),this.batching===0&&(this.doc.preventCompose=!0),this.batching}static async load(e){try{const r=new IN(e.auth,e.serverUrl,e.reauthFunc),i=await r.getDoc(),o=new Nu(r,i,e.disableLogout);if(i.type===null){if(e.autoCreateDoc===!1){const s=new Error("doc not exists");throw s.code="DocNotExists",s}await o.createDoc(e.templateData||DN())}return await o.initPresence(),await o.subscribe(),o.initEvents(),o}catch(r){throw se.error(r),se.error(`failed to load doc: ${JSON.stringify(r)}`),r}}setStatus(e){this.status!==e&&(this.status=e,this.callbacks.forEach(r=>{var i;return(i=r.onStatusChanged)==null?void 0:i.call(r,e)}))}initEvents(){this.doc.on("nothing pending",this.handleNothingPending),this.doc.on("create",this.handleCreate),this.doc.on("del",this.handleDel),this.client.onAuthError(e=>{this.callbacks.forEach(r=>{var i;return(i=r.onError)==null?void 0:i.call(r,e)})}),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((e,r)=>{if(this.localPresence)e();else{const i=this.doc.connection.getPresence(`${this.doc.collection}:${this.doc.id}`);i.on("receive",(o,s)=>{this.onCustomMessage(s)}),i.subscribe(o=>{o?r(o):(this.localPresence=i.create(Z()),e())})}})}subscribe(){return new Promise((e,r)=>{this.doc.subscribe(i=>{i?r(i):(this.doc.on("op",this.handleOp),e())})})}toJSON(){return oo(this.data())}getContainerBlocks(e){const r=this.data();p(se,r,"no doc data");const i=r[so(e)];return p(se,i,`no container data: ${e}`),gt.default(i)}findContainerBlocks(e){const r=this.data();p(se,r,"no doc data");const i=r[so(e)];return i!=null?i:null}getBlockData(e,r){const i=this.data();p(se,i,"no doc data");const o=i[so(e)];p(se,o,`no container data: ${e}`);const s=o[r];return p(se,s,`no block data: ${r}`),gt.default(s)}localInsertBlock(e,r,i){return this.submitInsertBlock(e,r,i),this.getBlockData(e,r)}localDeleteBlock(e,r){const i=this.getBlockData(e,r);return this.submitDeleteBlock(e,r),i}localUpdateBlockText(e,r,i){const o=this.getBlockData(e,r);p(se,o.text,"no block text");const s=gt.default(o.text);this.submitUpdateRichText(e,r,i);const l=fn.apply(s,i);return p(se,l,"no block text"),l}localUpdateBlockData(e,r,i){const o=gt.default(this.getBlockData(e,r));return this.submitUpdateBlockData(e,r,i),o}localInsertChildContainers(e){this.submitInsertChildContainers(e)}localDeleteChildContainers(e){this.beginBatchUpdate(),e.forEach(r=>{this.submitDeleteChildContainer(r)}),this.endBatchUpdate()}getComments(){return Object.values(this.data().comments).map(r=>oT(r))}getComment(e){return this.data().comments[e]}getCommentDoc(e){const r=this.data().comments[e];return Kp(r)}localCreateComment(e,r){const i=Vp(e,r),s=["comments",i.id,{i}];return this.submitOp(s)}localDeleteComment(e){const r=["comments",e,{r:!0}];return this.submitOp(r)}localUpdateComment(e,r){const i=Vp(e,r),o=["comments",e.id,{r:!0,i}];return this.submitOp(o)}destroy(){var e;this.destroyed=!0,this.clearEvents(),this.clearCallbacks(),this.doc.destroy(),(e=this.localPresence)==null||e.destroy(),this.client.close(!this.disableLogout),this.remoteCaretHandler.destroy()}onDeleteBlock(e,r,i){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(o=>{var s;return(s=o.onDeleteBlock)==null?void 0:s.call(o,Ma(e),r,i)})}onInsertBlock(e,r,i,o){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onInsertBlock)==null?void 0:l.call(s,Ma(e),r,i,o)})}onUpdateBlockData(e,r,i,o){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockData)==null?void 0:l.call(s,Ma(e),r,i,o)})}onUpdateBlockText(e,r,i,o){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(s=>{var l;return(l=s.onUpdateBlockText)==null?void 0:l.call(s,Ma(e),r,i,o)})}onDeleteContainer(e,r){p(se,this.callbacks.length>0,"no callbacks"),p(se,e!=="root","should not delete root container in doc"),this.callbacks.forEach(i=>{var o;return(o=i.onDeleteChildContainer)==null?void 0:o.call(i,Ma(e),r)})}onCreateContainer(e,r,i){p(se,this.callbacks.length>0,"no callbacks"),p(se,e!=="root","should not create root container in doc"),this.callbacks.forEach(o=>{var s;return(s=o.onInsertChildContainer)==null?void 0:s.call(o,Ma(e),r,i)})}onDeleteComment(e,r){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var o;return(o=i.onDeleteComment)==null?void 0:o.call(i,e,r)})}onCreateComment(e,r){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var o;return(o=i.onCreateComment)==null?void 0:o.call(i,e,r)})}onUpdateComment(e,r){p(se,this.callbacks.length>0,"no callbacks"),this.callbacks.forEach(i=>{var o;return(o=i.onUpdateComment)==null?void 0:o.call(i,e,r)})}onCustomMessage(e){const r=e;(r==null?void 0:r.type)==="custom"&&(r==null?void 0:r.clientId)!==this.client.clientId?this.callbacks.forEach(i=>{var o;return(o=i.onCustomMessage)==null?void 0:o.call(i,r.data)}):(r==null?void 0:r.type)==="onlineUsers"&&setTimeout(()=>{const i={type:"custom",data:e,clientId:"-"};this.onCustomMessage(i)})}async addResources(e){let r=[];return e.forEach(o=>{const s=o.split("|");r.push(...s)}),r=Array.from(new Set(r)),await this.client.getFileUrlsByHashes(r)}async uploadResource(e,r){var o;return{resourceId:await this.client.uploadResource(e,(o=r==null?void 0:r.onProgress)!=null?o:()=>{})}}buildResourceUrl(e,r){return this.client.buildResourceUrl(e,r)}request(e,r){return this.client.request(e,r)}getUser(){const e=this.client.clientId,{permission:r,userId:i,displayName:o,avatarUrl:s}=this.client.auth;return{permission:r,clientId:e,userId:i,displayName:o,avatarUrl:s,rainbowIndex:0}}getRemoteUsers(){return this.remoteCaretHandler.remoteUsers}getVersionHelper(){return this}getVersions(){return this.client.getVersions()}async getVersion(e){const r=await this.client.getVersion(e);return oo(r)}async getLatestVersion(){const e=await this.client.getLatestVersion();return oo(e)}async getHistoryData(e,r){const{doc:i,ops:o}=await this.client.getVersionOps(e,r),s=o.map(l=>({user:l.meta.createdBy,data:l}));return{doc:oo(i),historyData:s}}async getVersionData(e,r){const{doc:i,ops:o}=await this.client.getVersionOps(e,r);return{doc:oo(i),versionData:o}}async updateVersionExtra(e,r,i){await this.client.updateVersionExtra(e,r,i)}revertVersion(e){return this.client.revertVersion(e)}createVersion(e,r){return this.client.createVersion(e,r)}async recognizeLink(e){return this.client.recognizeLink(e)}parseHistoryData(e,r){Fp(e.data.op,r,!0)}getServerMeta(){return{appId:this.client.auth.appId,docId:this.client.auth.docId,serverId:this.client.apiServer()}}}I("remote-cursor");class lT{constructor(t){m(this,"handleDocSelectionChange",()=>{this.broadcastCaretPos()});m(this,"broadcastCaretPos",Me.default(()=>{const t={type:"caret",userId:this.editor.doc.getUser().userId,range:this.editor.selection.range.toDocRange()};this.editor.doc.broadcastMessage(t)},300));m(this,"handleRemoteCaretsChanged",t=>{t.forEach(e=>{const r=this.editor.findBlockById(e);r&&this.editor.reloadBlock(r)})});this.editor=t,this.editor.addListener("selectionChanged",this.handleDocSelectionChange),this.editor.doc.getRemoteUsers().addListener("remote-carets-change",this.handleRemoteCaretsChanged)}destroy(){this.editor.removeListener("selectionChanged",this.handleDocSelectionChange),this.editor.doc.getRemoteUsers().removeListener("remote-carets-change",this.handleRemoteCaretsChanged)}}const aT=I("remote-cursor-decorator");class $p{decorateText(t,e,r){const i=t.doc.getRemoteUsers();if(!i)return{};const o=new Map,{containerId:s,blockIndex:l}=e[e.length-1];p(aT,typeof s=="string","invalid path containerId"),p(aT,typeof l=="number","invalid path blockIndex");const c=t.doc.getBlockData(s,l),d=un(r);return i.getSimpleCursors(c.id).forEach((C,E)=>{E>d&&(E=d);const A=C.map(R=>({id:Z(),type:"remote-cursor",name:R.user.displayName,time:R.time,rainbowIndex:R.user.rainbowIndex})),v=o.get(E);v?v.push(...A):o.set(E,A)}),{insertions:o}}}const Hp=I("sharedb-doc/share-db-server"),KN=Eb.default.create();class VN{constructor(t,e){m(this,"auth");m(this,"clientId",Z());this.serverUrl=e,this.auth=t}editorServer(){const t=this.apiServer(),e=`/${this.auth.appId}/${this.auth.docId}`;return p(Hp,t.endsWith(e),`invalid api server: ${t}, ${e}`),t.substr(0,t.length-e.length)}apiServer(){const t=`${this.serverUrl}/${this.auth.appId}/${this.auth.docId}`;if(t.startsWith("ws://"))return`http://${t.substring(5)}`;if(t.startsWith("wss://"))return`https://${t.substring(6)}`;throw new Error(`invalid server url: ${t}`)}getBaseURL(){const t=new URL(this.apiServer());return`${t.protocol}//${t.host}${t.pathname}`}getBase64BaseURL(){return ci(this.getBaseURL())}async request(t,e){var o;const r=this.auth.token,i=e||{};i.url=t,i.headers||(i.headers={}),p(Hp,r,"no token"),i.headers={...i.headers,[il]:r,[Na]:this.getBase64BaseURL()};try{return await KN(t,i)}catch(s){throw(o=s.response)!=null&&o.data&&(s.responseData=s.response.data),s}}async getVersions(){const e=`${this.apiServer()}/versions?withExtra=true`,i=(await this.request(e)).data.versions;return i.forEach(o=>{o.extra&&(o.extra=JSON.parse(o.extra))}),i}async getVersion(t){const r=`${this.apiServer()}/versions/${t}`,i=await this.request(r);return JSON.parse(i.data.data)}async getLatestVersion(){const e=`${this.apiServer()}/versions/latest`,r=await this.request(e);return JSON.parse(r.data.data)}async getVersionOps(t,e){let i=`${this.apiServer()}/versions/before/${t}?withOp=true`;e!==void 0&&e!==0&&(i+=`&from=${e}`);const o=await this.request(i),s=o.data.ops,l=xb.default(s,h=>!!h.create);let c=null;l!==-1&&(c=s[l],s.splice(0,l+1));let d;return c?(p(Hp,c.create,"no createDoc.create"),d=c.create.data):d=JSON.parse(o.data.data),d.blocks||(d.blocks=[]),{doc:d,ops:o.data.ops}}async updateVersionExtra(t,e,r){const o=`${this.apiServer()}/versions/${t}/tags/${e}`;await this.request(o,{method:"post",data:{extra:JSON.stringify(r)}})}async revertVersion(t){const r=`${this.apiServer()}/versions/revert/${t}`;await this.request(r,{method:"post",data:{}})}async createVersion(t,e){const i=`${this.apiServer()}/versions`;return(await this.request(i,{method:"post",data:{publish:e,tag:t}})).data}buildResourceUrl(t,e){if(!t)return"";if(t.startsWith("https:")||t.startsWith("http:")||t.startsWith("file:")||t.startsWith("data:")||t.startsWith("blob:"))return t;let i=`${this.apiServer()}/resources/${encodeURIComponent(t)}`;const o=[];if(e!=null&&e.withToken,e!=null&&e.downloadFileName&&o.push(`&fileName=${encodeURIComponent(e.downloadFileName)}`),o.length>0){const s=o.join("&");i+=`?${s}`}return i}}const $N=I("sharedb-doc/share-db-server");function cT(n){const t=new URL(n);return`${t.protocol==="wss:"?"https:":"http:"}//${t.host}${t.pathname}`}function HN(n){return ci(cT(n))}class zh extends sa{constructor(e){super();m(this,"remoteUsers",new Ru);m(this,"client");this.options=e,this.client=new VN(e.auth,e.serverUrl)}destroy(){}buildResourceUrl(e,r){return this.client.buildResourceUrl(e,r)}getRemoteUsers(){return this.remoteUsers}getVersionHelper(){return this}getVersions(){return this.client.getVersions()}async getVersion(e){const r=await this.client.getVersion(e);return oo(r)}async getLatestVersion(){const e=await this.client.getLatestVersion();return oo(e)}async getHistoryData(e,r){const{doc:i,ops:o}=await this.client.getVersionOps(e,r),s=o.map(l=>({user:l.meta.createdBy,data:l}));return{doc:oo(i),historyData:s}}async getVersionData(e,r){const{doc:i,ops:o}=await this.client.getVersionOps(e,r);return{doc:oo(i),versionData:o}}async updateVersionExtra(e,r,i){await this.client.updateVersionExtra(e,r,i)}revertVersion(e){return this.client.revertVersion(e)}createVersion(e,r){return this.client.createVersion(e,r)}parseHistoryData(e,r){Fp(e.data.op,r,!0)}getServerMeta(){return{appId:this.client.auth.appId,docId:this.client.auth.docId,serverId:this.client.apiServer()}}static async auth(e,r){p($N,e.token,"no auth token");const i=`${cT(r)}/auth`,o=await window.fetch(i,{method:"GET",headers:{[il]:e.token,[Na]:HN(r)},credentials:"include"});if(o.status!==200)throw new Error("http auth error");return await o.json()}static async load(e){const r=`${e.serverUrl}/${e.auth.appId}/${e.auth.docId}`;return await this.auth(e.auth,r),new zh(e)}}class uT extends Re.TypedEmitter{constructor(t){super(),this.editor=t,this.editor.doc.registerCallback(this)}handleChild(t,e,r){if(Xt(ui(this.editor,t)))return;const i=this.editor.getBlockByIndex(t,e),o=et(this.editor.getContainerById(t));o&&this.emit("change",this.editor,o,i,r)}onUpdateBlockData(t,e){this.handleChild(t,e,"data-change")}onUpdateBlockText(t,e){this.handleChild(t,e,"text-change")}onInsertBlock(t,e){setTimeout(()=>{this.handleChild(t,e,"insert")})}onDeleteBlock(t,e){this.handleChild(t,e,"remove")}destroy(){this.editor.doc.unregisterCallback(this)}}function fT(n,t){n.addCustom("child-block-tracker",()=>new uT(n)).addListener("change",t)}function dT(n,t){n.addCustom("child-block-tracker",()=>new uT(n)).removeListener("change",t)}const lct="",jN={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"}},zN={colorPalette:{colorDesc:"Text color",name:"Text color",backgroundDesc:"Background color",reset:"Restore default values"},search:{emptyTips:"No results found"}},GN={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"}};D.mergeLang({"zh-CN":jN,"en-US":zN,"ja-JP":GN});const act="";I("button");function Cr(n,t,e,r,i){const o=B("button",["editor-button"],null);return o.setAttribute("data-button-id",n),i&&o.setAttribute(`data-editor-tooltip-${i}`,t),e?typeof e=="string"?e.startsWith("<")?o.innerHTML=e:o.innerText=e:o.appendChild(e):o.innerText=t,r&&(r.indexOf("checked")!==-1&&z(o,"checked"),r.indexOf("disabled")!==-1&&(o.disabled=!0),r.indexOf("primary")!==-1&&z(o,"primary")),o}const cct="",Gh=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
32
32
|
<path d="M8.00874 7.89952L12.9497 2.94975M8.00874 7.89952L12.9497 12.8492M8.00874 7.89952L3.05025 12.8492M8.00874 7.89952L3.05025 2.94975" stroke="currentColor" stroke-linejoin="round"/>
|
|
33
33
|
</svg>
|
|
34
34
|
`,hT=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
@@ -610,8 +610,8 @@ ${t}
|
|
|
610
610
|
</clipPath>
|
|
611
611
|
</defs>
|
|
612
612
|
</svg>
|
|
613
|
-
`,uP=Object.freeze(Object.defineProperty({__proto__:null,ClearIcon:YT,CloseIcon:Gh,PrevIcon:hT,NextIcon:mT,MoreIcon:jp,TextColorIcon:zp,ArrowDownIcon:Wh,ArrowUpIcon:WN,ArrowLeftIcon:qN,ArrowRightIcon:Gp,DeleteRowIcon:gT,DeleteColIcon:pT,MergeCellIcon:CT,SplitCellIcon:ET,DeleteTableIcon:xT,Heading1Icon:qh,Heading2Icon:Xh,Heading3Icon:Qh,Heading4Icon:Yh,Heading5Icon:Jh,Heading6Icon:Zh,Heading7Icon:t0,Heading8Icon:e0,HeadingNIcon:XN,OrderedListIcon:AT,UnorderedListIcon:bT,CheckListIcon:vT,BlockquoteIcon:BT,AlignCenterIcon:r0,AlignLeftIcon:Pa,AlignRightIcon:n0,ImageIcon:TT,ImageMenuIcon:yT,ImageErrorIcon:qp,ImageEmptyIcon:RT,LinkIcon:Jp,LinkOffIcon:wT,WarningIcon:Wp,PasteSpecialIcon:kT,LaunchIcon:Xp,CodeIcon:$T,AudioIcon:PT,GraphIcon:QN,VideoIcon:FT,FileIcon:YN,MathIcon:ZN,MathMenuIcon:ST,TableIcon:tP,TableMenuIcon:LT,BilibiliIcon:DT,YoukuIcon:_T,ModaoIcon:UT,FigmaIcon:MT,EditIcon:i0,CommentIcon:ol,RefreshIcon:IT,HelpIcon:Qp,CheckMarkIcon:Yp,TextIcon:Fa,RightArrowIcon:JN,TencentVideoIcon:OT,WebPageIcon:NT,UmlIcon:KT,DividingLineIcon:VT,HeadingH1Icon:eP,HeadingH2Icon:nP,HeadingH3Icon:rP,HeadingH4Icon:iP,HeadingH5Icon:oP,HeadingH6Icon:sP,HeadingH7Icon:lP,HeadingH8Icon:aP,CheckboxIcon:Zp,QuoteIcon:tC,LinkHrefIcon:cP,OrderedIcon:nC,UnorderedIcon:eC,CopyIcon:HT,CutIcon:jT,DeleteIcon:zT,LockBlockIcon:GT,UnLockBlockIcon:WT,InsertBeforeIcon:qT,InsertAfterIcon:XT,MentionIcon:QT,CircleAddIcon:JT,LoadingIcon:ZT,DragIcon:rC,UmlBrandIcon:o0,OnesLoadingIcon:ty,BoldIcon:ey,ItalicIcon:ny,UnderlineIcon:ry,LineThroughIcon:iy,SubscriptIcon:sy,SuperscriptIcon:ly,InlineCodeIcon:oy,ToMindMapIcon:ay,FitIcon:cy,FullScreenIcon:iC,ExitFullScreenIcon:uy,CaretDownIcon:fy,StatusIcon:dy},Symbol.toStringTag,{value:"Module"}));function hy(){const n=B("span",["editor-loading-icon"],null);return n.innerHTML=ty,n}const uct="";function fP(n,t){const e=B("button",["editor-checkbox-wrapper"],null);e.setAttribute("data-button-id",n),t!=null&&t.includes("checked")&&z(e,"checked"),t!=null&&t.includes("disabled")&&(e.disabled=!0);const r=B("span",["editor-checkbox"],e);return B("span",["editor-checkbox-inner"],r),e}const fct="",Ka=I("ui-command-bar-base"),dP={itemElementTag:"div",tippyArrow:!1},vx=class extends Re.TypedEmitter{constructor(e,r,i){var o,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",e=>{if(!!this.isVisible&&!e.isComposing&&!Gs(e.target)){if(this.subBar){this.subBar.handleDocumentKeydown(e);return}if(this.items.length!==0){if(e.key==="Escape"){this.close("cancelBar");return}if(e.key==="ArrowUp"){const r=this.getPrevItemIndex(this.getSelectedItemIndex());this.startPauseMouseEnter(),this.selectItem(this.items[r].id),e.preventDefault(),e.stopPropagation()}else if(e.key==="ArrowDown"){const r=this.getNextItemIndex(this.getSelectedItemIndex());this.startPauseMouseEnter(),this.selectItem(this.items[r].id),e.preventDefault(),e.stopPropagation()}else if(e.key==="ArrowRight"){const r=this.getSelectedItem();r&&r.children&&this.showSubCommandBar(r.childrenMenuId)}else if(e.key==="ArrowLeft")this.parentItem&&this.close("switchItem");else if(e.key==="Enter"){const r=this.getSelectedItemIndex();if(r===-1)return;const i=this.items[r],o=this.getItemElementById(i.id);o&&this.emit("click",this,i,o)}}}});m(this,"handleDocumentMouseDown",e=>{if(e.target instanceof Element&&!this.isInCommandBar(e.target)){const r=this.listeners("closing");for(let i=0;i<r.length;i++)if(r[i](this,e)===!1)return;this.close("clickBackground")}});m(this,"handleHidden",()=>{this.closeReason!=="fromHover"&&this.emit("close",this),this.close(null),ev(this.id)});m(this,"handleShow",()=>{this.popper&&(this.popper.setAttribute("data-command-bar-id",this.id),this.options.classes&&z(this.popper,...this.options.classes),this.options.refuseOverflow&&this.popper.classList.add("reference-hidden")),this.emit("show",this),this.options.disablePageScroll&&tv(this.id)});m(this,"lastEnterPauseTime",0);m(this,"startPauseMouseEnter",()=>{this.lastEnterPauseTime=Date.now()});m(this,"handleItemMouseEnter",e=>{if(Date.now()-this.lastEnterPauseTime<100)return;const r=this.getParentCommandItemElement(e.target);if(!r)return;const i=this.getItemElementId(r),o=this.getItemById(i);if(this.selectItem(i),o.manualShowChildren)return;const s=o.childrenMenuId||"";this.showSubCommandBar(s)});m(this,"handleItemMouseLeave",e=>{var i,o;const r=this.getParentCommandItemElement(e.target);!r||((o=(i=this.subBar)==null?void 0:i.parentItem)==null?void 0:o.id)!==this.getItemElementId(r)&&(ot(r,"selected"),this.emit("selectionChange",this,""))});m(this,"handleItemClick",e=>{const r=this.getParentCommandItemElement(e.target);if(!r)return;const i=this.getItemElementId(r),o=this.items.find(s=>s.id===i);if(!!o&&!(o.states&&o.states.indexOf("disabled")!==-1)){if(o.children&&o.children.length>0&&o.manualShowChildren){this.showSubCommandBar(o.childrenMenuId);return}o.element||(this.emit("click",this,o,r),this.options.autoClose&&this.close("clickItem"))}});m(this,"handleWheel",e=>{if(!this.options.disablePageScroll&&!document.querySelector(".editor-disable-scroll"))return;const r=e.target;if(!r||!(r instanceof Node))return;const i=r instanceof HTMLElement?r:r.parentElement;if(!i)return;const o=En(i);if(!ne(this.content,o)){e.stopPropagation(),e.preventDefault();return}e.deltaY<0?o.scrollTop===0&&(e.stopPropagation(),e.preventDefault()):e.deltaY>0&&o.scrollTop+o.clientHeight>=o.scrollHeight&&(e.stopPropagation(),e.preventDefault())});this.id=(o=i==null?void 0:i.id)!=null?o:Z(),this.options={...dP,...i},this.items=e,this.parentItem=(s=i==null?void 0:i.parentItem)!=null?s:null,this.closeable=r!=null?r:null,this.content=this.createCommandBarContent(e)}close(e){this.closeReason=e,this.subBar&&this.subBar.close(e),document.removeEventListener("keydown",this.handleDocumentKeydown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}click(e,r){this.emit("click",this,e,r)}createPopperOptions(){var i,o;const e={modifiers:[]},r=this.options.overflowBoundary;return r&&((i=e==null?void 0:e.modifiers)==null||i.push({name:"flip",options:{boundary:r,fallbackPlacements:["top","bottom"]}})),this.options.padding&&((o=e==null?void 0:e.modifiers)==null||o.push({name:"preventOverflow",options:{padding:this.options.padding}})),e}destroy(){var e;this.close(null),this.removeAllListeners(),(e=this.subBar)==null||e.destroy(),this.subBar=null,this.closeable=null,this.content.removeEventListener("wheel",this.handleWheel)}get isSubCommandBar(){return!!this.parentItem}updateItems(e){var i;this.subBar&&e.findIndex(s=>{var l,c;return s.id===((c=(l=this.subBar)==null?void 0:l.parentItem)==null?void 0:c.id)})===-1&&((i=this.subBar)==null||i.destroy(),this.subBar=null),this.items=e;const r=this.createCommandBarContent(e);this.content.innerHTML="",Array.from(r.children).forEach(o=>{this.content.appendChild(o)})}get popper(){return this.content.closest("[data-tippy-root]")}getSelectedItemIndex(){const e=this.getSelectedItem();return e?this.items.indexOf(e):-1}getPrevItemIndex(e){if(e<=0)return this.items.length-1;let r=e-1;for(;;){const i=this.items[r],o=i.type,l=!(i.states&&i.states.indexOf("disabled")!==-1);if(o!=="separator"&&o!=="section"&&l)return r;if(r-=1,r<0)return this.items.length-1}}getNextItemIndex(e){let r=e+1;for(;;){if(!this.items[r])return this.getNextItemIndex(-1);const i=this.items[r],o=i.type,l=!(i.states&&i.states.indexOf("disabled")!==-1);if(o!=="separator"&&o!=="section"&&l)return r;if(r+=1,r>this.items.length-1)return 0}}clearSelectedItem(){const e=this.getSelectedItem();if(!e)return;const r=this.getItemElementById(e.id);r&&ot(r,"selected")}selectItem(e){const r=this.getSelectedItem();if(r){if(r.id===e)return;const o=r.id,s=this.getItemElementById(o);s&&ot(s,"selected")}const i=this.getItemElementById(e);i?(z(i,"selected"),this.emit("selectionChange",this,i.getAttribute("data-id")||""),this.options.disableSelectedScroll||i.scrollIntoView({block:"nearest"})):this.emit("selectionChange",this,"")}showSubCommandBar(e){var s,l;const r=this.getSelectedItem();if(!r)return;if(this.subBar){if(((s=this.subBar.parentItem)==null?void 0:s.id)===r.id){r.manualShowChildren&&this.subBar.close("switchItem");return}this.subBar.destroy(),this.subBar=null}if(!r.children)return;const i=this.getItemElementById(r.id);if(!i)return;const o=vx.createSubCommandBar(r,(l=this.closeable)!=null?l:this,e?{id:e}:{});this.subBar=o,this.subBar.on("click",(c,d,h)=>{this.emit("click",c,d,h)}),this.subBar.on("close",()=>{var c;(c=this.subBar)==null||c.destroy(),this.subBar=null,ot(i,"active")}),r.beforePopup&&r.beforePopup(o),this.subBar.manualShow(i,this.getSubBarOptions(r)),z(i,"active")}isInCommandBar(e){if(!e||!(e instanceof Node))return!1;const r=this.getCommandBarRoot();return r&&ne(r,e)||ne(this.content,e)?!0:this.subBar?this.subBar.isInCommandBar(e):!1}createCommandItem(e){var o,s,l,c;let r=(o=this.options.itemElementTag)!=null?o:"div";e.element&&(r="div");const i=B(r,["command-item"],null);return i.setAttribute("data-id",e.id),e.type==="separator"?i.classList.add("separator"):e.type==="section"?(i.classList.add("section","text"),e.element&&(typeof e.element=="function"?i.appendChild(e.element(e)):i.appendChild(e.element))):((s=e.states)!=null&&s.includes("selected")&&i.classList.add("selected"),(l=e.states)!=null&&l.includes("checked")&&i.classList.add("checked"),(c=e.states)!=null&&c.includes("disabled")&&i.classList.add("disabled"),i.onclick=this.handleItemClick,i.onmouseenter=this.handleItemMouseEnter,i.onmouseleave=this.handleItemMouseLeave,e.element?typeof e.element=="function"?i.appendChild(e.element(e)):i.appendChild(e.element):i.classList.add("standard")),this.initItemElement(e,i),i}getItemById(e){const r=this.items.find(i=>i.id===e);return p(Ka,r,`can not find command item for id: ${e}`),r}getSelectedItem(){const e=this.content.querySelector(":scope >.editor-command-bar >.command-item.selected");if(e){const r=this.getItemElementId(e),i=this.items.find(o=>o.id===r);return p(Ka,i,`can not find command item for id: ${r}`),i}return null}getItemElementId(e){const r=e.getAttribute("data-id");return p(Ka,r,"no data-id attribute"),r}getItemElementById(e){const r=this.content.querySelector(`:scope >.editor-command-bar > .command-item[data-id="${e}"]`);return p(Ka,r,`no exists command item, id=${e}`),r}getParentCommandItemElement(e){if(!e||!(e instanceof Element))return null;if(Rt(e,"command-item"))return e;const r=e.closest(".command-item");return r||null}createCommandBarContent(e){this.content&&this.content.removeEventListener("wheel",this.handleWheel);const r=B("div",["editor-command-bar-root"],null);if(this.options.header){const o=B("div",["editor-command-bar-header"],null);if(this.options.header instanceof Function){const s=this.options.header();s&&o.appendChild(s)}else o.appendChild(this.options.header);this.header=o,this.header&&r.appendChild(this.header)}const i=B("div",["editor-command-bar"],r);if(e.forEach(o=>{var l;const s=this.createCommandItem(o);i.appendChild(s),o.element&&o.setCloseable&&o.setCloseable((l=this.closeable)!=null?l:this)}),this.options.footer){const o=B("div",["menu-item","editor-command-bar","footer"],null);if(this.options.footer instanceof Function){const s=this.options.footer();s&&o.appendChild(s)}else o.appendChild(this.options.footer);this.footer=o,this.footer&&r.appendChild(this.footer)}return(this.options.header||this.options.footer)&&z(r,"scrollable-bar"),this.initCommandBarElement(i),r.addEventListener("wheel",this.handleWheel,{passive:!1}),r}getSubBarOptions(e){var r;return{placement:(r=e.childrenPlacement)!=null?r:"right-start",offset:e.childrenOffset,arrow:e.childArrow}}static registerManualCommandBar(e,r){this.commandBarCreators.set(e,r)}static createSubCommandBar(e,r,i){var l;p(Ka,e.children&&e.children.length>0,"no item children");const o=(l=e.childrenType)!=null?l:"menu",s=this.commandBarCreators.get(o);return p(Ka,s,`no creator for command type: ${o}`),s(e,r,i)}static hasExistsCommandBar(){return!!document.querySelector("[data-command-bar-id]")}};let sl=vx;m(sl,"commandBarCreators",new Map),I("ui-command-bar");class s0 extends sl{constructor(){super(...arguments);m(this,"tippyInstance",null)}manualShow(e,r){var i,o,s;if(!this.isVisible){if(this.tippyInstance&&(this.tippyInstance.destroy(),this.tippyInstance=null),this.tippyInstance=Y6.default(e,{interactive:!0,content:this.content,trigger:"manual",triggerTarget:null,hideOnClick:!1,placement:(i=r==null?void 0:r.placement)!=null?i:"bottom-start",maxWidth:650,arrow:(o=r==null?void 0:r.arrow)!=null?o:this.options.tippyArrow,appendTo:document.body,onShow:this.handleShow,onHidden:this.handleHidden,theme:r==null?void 0:r.theme,getReferenceClientRect:r==null?void 0:r.getReferenceClientRect,offset:(s=r==null?void 0:r.offset)!=null?s:[0,0],popperOptions:this.createPopperOptions()}),r!=null&&r.point){const{x:l,y:c}=r.point;this.tippyInstance.setProps({getReferenceClientRect:()=>new DOMRect(l,c,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(e){var r;super.close(e),this.isVisible&&((r=this.tippyInstance)==null||r.hide())}destroy(){var e;(e=this.tippyInstance)==null||e.destroy(),this.tippyInstance=null,super.destroy()}getCommandBarRoot(){return this.content.closest("[data-tippy-root]")}get isVisible(){var e,r;return(r=(e=this.tippyInstance)==null?void 0:e.state.isVisible)!=null?r:!1}get popper(){return this.content.closest("[data-tippy-root]")}}const my=I("ui-base");class Va extends s0{constructor(t,e){var o;const i=[{id:(o=e==null?void 0:e.id)!=null?o:`popup-${Z()}`,name:"",element:t}];super(i,void 0,{disablePageScroll:!0,id:e==null?void 0:e.id})}initCommandBarElement(t){z(t,"popper")}initItemElement(t,e){}get popupContent(){const t=this.items[0];p(my,t,"no dialog item");const e=typeof t.element=="function"?t.element(t):t.element;return p(my,e,"no item element"),e}}const co=I("filterable-list");function gy(n){var e,r;const t=B("div",["list-item"],null);return t.setAttribute("data-id",n.id),t.appendChild(B("div",["list-item-text"],null,n.name)),(e=n.states)!=null&&e.includes("selected")&&(z(t,"selected"),Ms(Yp,["list-item-selected-icon"],t)),(r=n.states)!=null&&r.includes("disabled")&&z(t,"disabled"),t}function py(n){const t=B("div",["list-root"],null);return n.forEach(e=>{t.appendChild(gy(e))}),n.length||t.appendChild(gy({id:"placeholder",states:["disabled"],name:D.t("search.emptyTips")})),t}function Cy(n,t){return n.map(e=>({...e,states:t===e.id?["selected"]:[]}))}function hP(n,t){const e=B("div",["filterable-list"],null),r=B("div",["filter"],e),i=B("div",["filter-container"],r),o=B("input",["filter-input"],i);t&&t.placeholder&&(o.placeholder=t.placeholder);const s=B("div",["list"],e),l=py(Cy(n,t==null?void 0:t.initialSelectedId));return s.appendChild(l),e}function Ey(n,t,e){const r=n.querySelector(".list");p(co,r,"no list root");const i=py(Cy(t,e)),o=r.querySelector(".list-root");if(p(co,o,"no exists menu"),tu(o,i),e){const s=r.querySelector(".list-item.selected");s&&(p(co,s,"no selected menu item"),s.scrollIntoView({block:"nearest"}))}}class mP{constructor(t,e){m(this,"root");m(this,"visibleItems");m(this,"selectedId");m(this,"filter","");m(this,"onSelected",null);m(this,"handleKeydown",t=>{this.processKeyDown(t)});m(this,"handleInputChanged",()=>{const t=this.root.querySelector(".filter-input");p(co,t,"no input");const e=t.value.toLocaleLowerCase();this.setFilter(e)});m(this,"handleClick",t=>{this.processClick(t)});var r;this.items=t,this.options=e,this.root=hP(t,e),this.bindEvents(),this.selectedId=(r=e==null?void 0:e.initialSelectedId)!=null?r:"",this.visibleItems=t}bindEvents(){const t=this.root.querySelector(".filter-input");p(co,t,"no input"),t.addEventListener("keyup",this.handleInputChanged),t.addEventListener("keydown",this.handleKeydown),this.root.addEventListener("click",this.handleClick)}unbindEvents(){const t=this.root.querySelector(".filter-input");p(co,t,"no input"),t.removeEventListener("keyup",this.handleInputChanged),t.removeEventListener("keydown",this.handleKeydown),this.root.removeEventListener("click",this.handleClick)}destroy(){this.unbindEvents(),this.onSelected=null}getSelectedIndex(){return this.selectedId?this.visibleItems.findIndex(t=>t.id===this.selectedId):-1}setSelectedId(t){this.selectedId=t,Ey(this.root,this.visibleItems,t)}focus(){const t=this.root.querySelector(".filter-input");p(co,t,"no input"),t.focus()}moveSelectedItemIntoView(){const t=this.root.querySelector(".list-item.selected");t&&(p(co,t,"no selected menu item"),t.scrollIntoView({block:"nearest"}))}reset(){this.setFilter("");const t=this.root.querySelector(".filter-input");p(co,t,"no input"),t.value=""}setFilter(t){this.filter!==t&&(this.filter=t,this.visibleItems=this.items.filter(e=>e.name.toLocaleLowerCase().includes(t)),Ey(this.root,this.visibleItems,this.selectedId))}processClick(t){var s,l;const e=t.target;if(!(e instanceof HTMLElement))return;const r=e.closest(".list-item");if(!r)return;const i=(s=r.getAttribute("data-id"))!=null?s:"",o=(l=this.visibleItems.find(c=>c.id===i))!=null?l:null;this.onSelected&&this.onSelected(this,o)}processKeyDown(t){var e;if(t.key==="ArrowUp"){let r=this.getSelectedIndex();r===-1?r=this.visibleItems.length-1:r>0&&(r-=1);let i="";r!==-1&&(i=this.visibleItems[r].id),this.setSelectedId(i);return}if(t.key==="ArrowDown"){let r=this.getSelectedIndex();r===-1?r=0:r<this.visibleItems.length-1&&(r+=1);let i="";r!==-1&&(i=this.visibleItems[r].id),this.setSelectedId(i);return}if(t.key==="Enter"){const r=(e=this.visibleItems.find(i=>i.id===this.selectedId))!=null?e:null;this.onSelected&&this.onSelected(this,r)}}}class gP extends mP{constructor(e,r,i){super(e,i);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 Va(this.root)}destroy(){super.destroy(),this.onShow=null,this.onHide=null}show(e){this.reset(),this.popup.manualShow(e,{theme:"dropdown-list"}),this.focus(),this.moveSelectedItemIntoView()}processKeyDown(e){super.processKeyDown(e),(e.key==="Esc"||e.key==="Enter")&&this.popup.close("cancelBar")}processClick(e){super.processClick(e);const r=e.target;!(r instanceof HTMLElement)||!r.closest(".list-item")||this.popup.close("clickItem")}}const dct="",hct="";function pP(n,t){const e=document.createElement("div");e.classList.add("toast","show"),t!=null&&t.theme&&e.setAttribute("data-theme",t.theme),t!=null&&t.id&&e.setAttribute("data-id",t.id),t!=null&&t.html?e.innerHTML=n:e.textContent=n,t!=null&&t.position&&(e.style.left=`${t.position.x}px`,e.style.top=`${t.position.y}px`,e.classList.add("positioned")),document.body.appendChild(e),setTimeout(()=>{e.classList.remove("show"),setTimeout(()=>{e.remove()},500)},(t==null?void 0:t.duration)||3e3)}function CP(n,t){var e,r;if(z(t,"menu-item"),!n.element){if(n.type==="section"){const i=B("div",["section-name"],null,n.name);t.appendChild(i)}else if(n.type!=="separator"){if(n.icon){const o=B("div",["menu-item-icon"],null);n.icon&&(o.innerHTML=n.icon),t.appendChild(o)}const i=B("div",["menu-item-name","text"],null);if(B("span",[],i,n.name),n.ellipsisTooltip&&(t.setAttribute("data-editor-tooltip-allow-markdown","true"),t.setAttribute("data-editor-tooltip-offset-y","25"),t.setAttribute("data-editor-tooltip-placement","right"),t.setAttribute("data-editor-tooltip-common",`<div style="word-break: break-word;">${n.ellipsisTooltip}</div>`)),((e=n.states)==null?void 0:e.includes("disabled"))&&n.disableReason&&(t.setAttribute("data-editor-tooltip-maxwidth","800"),t.setAttribute("data-editor-tooltip-placement","right"),t.setAttribute("data-editor-tooltip-common",n.disableReason)),t.appendChild(i),n.subText&&B("div",["item-subtext","text"],t,n.subText),n.children&&!n.element){const o=B("div",["menu-item-sub-indicator"],null);o.innerHTML=Gp,t.appendChild(o)}if((r=n.states)!=null&&r.includes("checked")){const o=B("div",["menu-item-checked-icon"],null);o.innerHTML=Yp,t.appendChild(o)}}}}class Zo extends s0{constructor(t,e,r){super(t,e,{autoClose:!0,disablePageScroll:!0,...r})}manualShow(t,e){const r={theme:"menu",...e};super.manualShow(t,r)}initCommandBarElement(t){z(t,"menu")}initItemElement(t,e){CP(t,e)}}function EP(n,t,e){var r;return new Zo((r=n.children)!=null?r:[],t,{...e,parentItem:n})}function xy(n,t,e){t.setAttribute("data-button-id",n.id),e.tooltipId&&n.name&&!n.disableTooltip&&(t.setAttribute(`data-editor-tooltip-${e.tooltipId}`,n.name),n.desc&&t.setAttribute(`data-editor-tooltip-desc-${e.tooltipId}`,n.desc));const r=t;if(!n.element)if(n.icon){const i=B("span",["toolbar-item-icon-container"],r);n.icon.trim().startsWith("<")?i.innerHTML=n.icon:i.innerText=n.icon}else{const i=B("span",["toolbar-item-name-container"],r);i.innerText=n.name}if(n.dropdown){t.setAttribute("data-dropdown","true");const i=B("span",["toolbar-item-dropdown-container"],r);i.innerHTML=Wh}n.states&&(n.states.indexOf("checked")!==-1&&z(r,"checked"),n.states.indexOf("disabled")!==-1&&(r.disabled=!0))}class Pu extends s0{constructor(t,e,r){super(t,e,{itemElementTag:"button",tippyArrow:!1,...r})}getSubBarOptions(t){var i,o;const e=()=>{const s=this.getItemElementById(t.id),c=this.content.getBoundingClientRect(),d=s.getBoundingClientRect();return new DOMRect(d.left,c.top,d.width,c.height)};return{placement:(i=t.childrenPlacement)!=null?i:"top",getReferenceClientRect:e,offset:(o=t.childrenOffset)!=null?o:[0,4]}}manualShow(t,e){const r={theme:"toolbar",...e};super.manualShow(t,r)}initCommandBarElement(t){z(t,"toolbar")}initItemElement(t,e){xy(t,e,this.options)}}function xP(n,t,e){var r;return new Pu((r=n.children)!=null?r:[],t,{...e,parentItem:n})}class AP extends sl{constructor(t,e,r){super(e,void 0,r),t.appendChild(this.content),document.addEventListener("keydown",this.handleDocumentKeydown),document.addEventListener("mousedown",this.handleDocumentMouseDown)}initCommandBarElement(t){z(t,"toolbar","fixed")}initItemElement(t,e){xy(t,e,this.options)}close(){this.clearSelectedItem(),this.subBar&&(this.subBar.close("cancelBar"),this.subBar=null)}destroy(){this.content.remove(),super.destroy(),document.removeEventListener("keydown",this.handleDocumentKeydown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}getCommandBarRoot(){return this.content.parentElement}get isVisible(){return!0}}const mct="";sl.registerManualCommandBar("menu",EP),sl.registerManualCommandBar("toolbar",xP);const gct="",Ay=I("ui-base");class Fu extends s0{constructor(e,r){super(Fu.getCommandItems(e,r),void 0,{disablePageScroll:!0,...r});m(this,"handleDocumentMouseDown",e=>{})}initCommandBarElement(e){z(e,"dialog","manual")}initItemElement(e,r){}show(e,r){this.manualShow(e,{...r,theme:"light"})}get dialogContent(){const e=this.items[0];p(Ay,e,"no dialog item");const r=e.element;return p(Ay,r,"no item element"),r}static getCommandItems(e,r){var s;return[{id:(s=r==null?void 0:r.id)!=null?s:`manual-dialog-${Z()}`,name:"",element:e}]}}const pct="",bP=I("ui-base");class by{constructor(t){m(this,"menu");m(this,"currentText","");m(this,"handleSearchText");m(this,"handleClick",Me.default((t,e)=>{this.options.onClickItem(this,e)},300,{leading:!0,trailing:!1}));m(this,"handleShow",t=>{});m(this,"handleClose",()=>{var t,e;(e=(t=this.options).onClose)==null||e.call(t)});m(this,"handleKeydown",t=>{this.menu.handleDocumentKeydown(t)});this.options=t,this.menu=new Zo([],void 0,{id:t.id,header:t.header,footer:t.footer,disableSelectedScroll:t.disableSelectedScroll}),this.menu.addListener("click",this.handleClick),this.menu.addListener("close",this.handleClose),this.menu.addListener("show",this.handleShow),this.options.wait?this.handleSearchText=Me.default(async e=>{this.handleSearchTextPure(e)},this.options.wait):this.handleSearchText=this.handleSearchTextPure}setItems(t){if(this.menu.updateItems(t),t.length>0){const e=t.find(r=>r.type!=="section"&&r.type!=="separator");e&&this.menu.selectItem(e.id)}}async popup(t,e){var i,o;if(!(e!=null&&e.noEvent)&&((o=(i=this.options).onShow)==null?void 0:o.call(i,this))===!1)return;this.menu.manualShow(t),this.options.placeholder&&this.showPlaceholder();const r=await this.options.queryItems(this,"");this.highlightText("",r),this.setItems(r)}showLoading(){!this.options.showLoading||(this.options.loadingElement?this.setItems([{id:"loading",name:"",element:this.options.loadingElement,states:["disabled"]}]):this.setItems([{id:"loading",name:"loading",states:["disabled"]}]))}showPlaceholder(){this.setItems([{id:"placeholder",name:"enter text to search",states:["disabled"]}])}showNoResultMessage(t){if(this.options.noResultMessage){const e={name:"",id:"placeholder",states:["disabled"]};typeof this.options.noResultMessage=="string"?e.name=this.options.noResultMessage:(this.options.noResultMessage instanceof HTMLElement||typeof this.options.noResultMessage=="function")&&(e.element=this.options.noResultMessage),this.setItems([e])}else this.setItems([{id:"placeholder",name:this.options.emptyPlaceholder||D.t("search.emptyTips"),states:["disabled"]}])}close(){this.menu.close("cancelBar")}get isVisible(){return this.menu.isVisible}destroy(){this.menu.close("cancelBar"),this.menu.removeAllListeners(),this.menu.destroy()}isInCommandBar(t){return this.menu.isInCommandBar(t)}async handleSearchTextPure(t){this.currentText=t;const e="auto-suggest";try{await Sr.lock(e),this.showLoading();const r=this.currentText,i=await this.options.queryItems(this,t);if(this.currentText===r&&(this.currentText=""),i.length===0){this.showNoResultMessage(t);return}this.setItems(i),this.options.highlight&&this.highlightText(r.replace(/^\s+|\s+$/g,""),i)}finally{Sr.release(e)}}highlightText(t,e){bP.debug(`highlight menu text: ${t}`);const r=this.menu.content,i=(s,l)=>{if(!l)return s;let c="";const d=l.length,h=l.toLocaleLowerCase();let C=0;for(C=0;C<=s.length-d;C){let E=s.substring(C,C+d);if(E.toLocaleLowerCase()===h){C+=d;const A=s.charAt(C);let v=!1;E.endsWith(" ")&&(v=!0,E=E.trimEnd()),c+=`<span class="highlight">${E}${A===" "||v?" ":""}</span>`}else c+=s.charAt(C),C++}return C<s.length&&(c+=s.substring(C)),c},o=s=>{if(Rt(s,"text")){const l=e==null?void 0:e.find(h=>h.id===s.getAttribute("data-id"));if(l&&l.element)return;const c=s.textContent;if(!c)return;const d=i(c,t);s.innerHTML=d;return}Array.from(s.children).forEach(o)};o(r)}}class oC{constructor(t,e){m(this,"root");m(this,"input");m(this,"text");m(this,"dropdownIcon");m(this,"clearIcon");m(this,"autoSuggest");m(this,"labels");m(this,"items",[]);m(this,"handleClick",()=>{this.autoSuggest.popup(this.root),this.input.focus()});m(this,"handleClickItem",(t,e)=>{var r,i;(i=(r=this.options)==null?void 0:r.onClickItem)==null||i.call(r,e)});m(this,"handleInput",()=>{this.autoSuggest.handleSearchText(this.input.value),this.updatePlaceholder()});m(this,"handleClear",t=>{var e,r;this.clear(),this.autoSuggest.handleSearchText(""),t.preventDefault(),t.stopPropagation(),(r=(e=this.options)==null?void 0:e.onClear)==null||r.call(e)});m(this,"handleQueryItems",async(t,e)=>this.items.filter(i=>{var o;return(o=this.options)!=null&&o.filter?this.options.filter(i,e):!0}));m(this,"handleShow",()=>{z(this.root,"active"),this.input.focus()});m(this,"handleClose",()=>{var t,e;(e=(t=this.options)==null?void 0:t.onClose)==null||e.call(t),ot(this.root,"active")});var c,d,h,C,E;this.options=e,this.labels=(d=(c=this.options)==null?void 0:c.labels)!=null?d:[];const{root:r,input:i,text:o,clearIcon:s,dropdownIcon:l}=oC.createDropdown(t,this.labels);this.root=r,this.input=i,this.text=o,this.clearIcon=s,this.dropdownIcon=l,this.autoSuggest=new by({id:(e==null?void 0:e.popupId)||"dropdown-auto-suggest",header:(h=this.options)==null?void 0:h.header,onClickItem:this.handleClickItem,queryItems:this.handleQueryItems,onClose:this.handleClose,onShow:this.handleShow,highlight:e==null?void 0:e.highlight,emptyPlaceholder:e==null?void 0:e.emptyPlaceholder,disableSelectedScroll:e==null?void 0:e.disableSelectedScroll}),this.items=(E=(C=this.options)==null?void 0:C.items)!=null?E:[],this.root.addEventListener("click",this.handleClick),this.input.addEventListener("input",this.handleInput),this.clearIcon.addEventListener("click",this.handleClear)}close(){this.autoSuggest.close()}destroy(){this.input.removeEventListener("input",this.handleInput),this.root.removeEventListener("click",this.handleClick),this.clearIcon.removeEventListener("click",this.handleClear),this.autoSuggest.destroy()}updateItems(t){this.items=t,this.autoSuggest.handleSearchText("")}setText(t){this.text.innerText=t,this.input.value=t,this.updatePlaceholder()}clear(){this.setText(""),this.setLabels([])}setLabels(t){this.labels=t,this.updateLabels()}static createDropdown(t,e){const r=B("div",["editor-dropdown","empty"],t),i=B("input",["dropdown-input"],r),o=B("div",["dropdown-text"],r),s=B("div",["dropdown-labels"],r);for(let d=0;d<e.length;d+=1){const h=e[d];B("span",["dropdown-label"],s,h)}const l=B("div",["dropdown-clear-icon"],r);l.innerHTML=YT;const c=B("div",["dropdown-icon"],r);return c.innerHTML=Wh,{root:r,input:i,text:o,clearIcon:l,dropdownIcon:c}}updateLabels(){const t=this.root.querySelector(".dropdown-labels");if(t){t.innerHTML="";for(let e=0;e<this.labels.length;e+=1){const r=this.labels[e];B("span",["dropdown-label"],t,r)}}}updatePlaceholder(){var t;if(this.input.value===""){const e=(t=this.options)==null?void 0:t.placeholder;e&&(this.input.placeholder=e,this.text.textContent=e),z(this.root,"empty")}else ot(this.root,"empty")}}const vP=[-1,6,0,1,2,3,4,5],BP=[-1,6,0,1,2,3,4,5,14,13,7,8,9,10,11,12],vy=I("color-palette");function By(n,t,e,r){p(vy,n>0,"no color in palette");const i=t||1;p(vy,i>0,`invalid palette rows: ${i}`);const o=n/i,s=B("div",["palette-container",r],null);for(let l=0;l<i;l++){const c=B("div",["palette-container-row"],s);for(let d=0;d<o;d++){const h=e(l*o+d);c.appendChild(h)}}return s}function TP(n){const t=B("button",["color-button"],null),e=vP[n];return t.setAttribute("data-color-index",`${e}`),t.innerHTML=zp,t}function yP(n){const t=B("button",["background-color-button"],null),e=BP[n];return t.setAttribute("data-color-index",`${e}`),t}function kP(){const n=B("div",["clear-button-container"],null),t=B("button",["clear-button"],n);return t.innerText=D.t("colorPalette.reset"),n}function RP(n){const t=B("div",["color-palette"],null);return n.color!==!1&&(B("div",["bar-desc"],t,D.t("colorPalette.colorDesc")),t.appendChild(By(8,1,TP,"color"))),n.backgroundColor!==!1&&(B("div",["bar-desc"],t,D.t("colorPalette.backgroundDesc")),t.appendChild(By(16,2,yP,"background-color"))),n.clearColorButton!==!1&&t.appendChild(kP()),t}function wP(n,t,e){const r=t==="color"?"color":"background-color",i=n.querySelector(`.${r} button.selected`);i&&ot(i,"selected"),e===null&&(e=-1);const o=n.querySelector(`.${r} button[data-color-index="${e}"]`);o&&z(o,"selected")}const Cct="",SP={};class LP extends Re.TypedEmitter{constructor(e=SP){super();m(this,"root");m(this,"handleClick",e=>{const r=e.target;if(!r||!(r instanceof Element))return;const i=r.closest("button");if(!i)return;if(Rt(i,"clear-button")){this.setColor("backgroundColor",null),this.setColor("color",null),this.emit("onClick","clearColor",0);return}const o=i.getAttribute("data-color-index");if(!o)return;const s=Number.parseInt(o,10);Number.isNaN(s)||(Rt(i,"color-button")?s===-1?(this.setColor("color",null),this.emit("onClick","clearColor",1)):(this.setColor("color",s),this.emit("onClick","color",s)):s===-1?(this.setColor("backgroundColor",null),this.emit("onClick","clearColor",2)):(this.setColor("backgroundColor",s),this.emit("onClick","backgroundColor",s)))});this.options=e,this.root=RP(e),this.root.addEventListener("click",this.handleClick)}destroy(){this.removeAllListeners(),this.root.removeEventListener("click",this.handleClick)}setColor(e,r){wP(this.root,e,r)}}class Ty{constructor(t,e){m(this,"name","Color Palette");m(this,"element");m(this,"palette");m(this,"closeable",null);this.id=t,this.palette=new LP(e),this.element=this.palette.root}setCloseable(t){this.closeable=t}destroy(){this.palette.destroy(),this.closeable=null}}function IP(){const n=B("button",["color-button"],null);return n.innerHTML=zp,n}function sC(n,t){const[e,r]=t;e===null?n.removeAttribute("data-color"):n.setAttribute("data-color",`${e}`),r===null?n.removeAttribute("data-background-color"):n.setAttribute("data-background-color",`${r}`)}class yy extends Re.TypedEmitter{constructor(e){super();m(this,"id","text-color-item");m(this,"name",D.t("colorPalette.name"));m(this,"dropdown",!0);m(this,"manualShowChildren",!0);m(this,"children",[]);m(this,"element");m(this,"colorPaletteItem");m(this,"latestColors",[null,null]);m(this,"handlePaletteClick",(e,r)=>{this.emit("onClick",e,r)});m(this,"setLatestColors",(e,r)=>{e==="color"||e==="backgroundColor"?e==="color"?this.latestColors[0]=r:this.latestColors[1]=r:this.latestColors=[null,null],sC(this.element,this.latestColors)});m(this,"beforePopup",()=>{this.updatePaletteColor(this.latestColors),this.emit("beforePopup")});this.editor=e,this.colorPaletteItem=new Ty("text-color-palette-item"),this.colorPaletteItem.palette.addListener("onClick",this.handlePaletteClick),this.children.push(this.colorPaletteItem),this.element=IP()}destroy(){this.colorPaletteItem.destroy()}updatePaletteColor(e){this.colorPaletteItem.palette.setColor("color",e[0]),this.colorPaletteItem.palette.setColor("backgroundColor",e[1]),this.latestColors=e,sC(this.element,this.latestColors)}updateButtonColor(e){this.latestColors=e,sC(this.element,this.latestColors)}}const Ect="";function l0(n,t){const e=B("div",["editor-input-wrap"],n);if(t!=null&&t.className&&z(e,t==null?void 0:t.className),t.label){const s=B("div",["editor-input-label"],e);B("span",[],s,t.label),t.required&&z(s,"required")}const r=B("div",["editor-input-container"],e),i=B("input",["editor-input"],null);if(t.placeholder&&(i.placeholder=t.placeholder),t.defaultValue&&(i.value=t.defaultValue),t.maxLength&&(i.maxLength=t.maxLength),t.maxLength){const s=B("div",["editor-input-suffix"],r);B("span",[],s,`${i.value.length} / ${t.maxLength}`),i.addEventListener("input",l=>{const c=l.target;s.innerText=`${c.value.length} / ${t.maxLength}`})}r.appendChild(i);const o=B("div",["editor-input-error"],e);return i.addEventListener("input",s=>{var l;(l=t.onChange)==null||l.call(t,s),ot(e,"error")}),i.addEventListener("keydown",s=>{var l;(l=t.onKeyDown)==null||l.call(t,s)}),{getField:()=>i,getInputValue:()=>i.value,setFieldError:s=>{z(e,"error"),o.innerText=s},focus:()=>{setTimeout(()=>{i.focus()})}}}function lC(n){const t=document.getSelection();if(!t)return!0;const e=t.focusNode;if(!e)return!0;const r=t.focusOffset,i=e.childNodes[r];if(!i)return!0;if(i instanceof HTMLElement){const o=i.tagName.toLowerCase();if(i===n.input.inputElement)return!0;if(o==="input"||o==="textarea")return!1}return!0}class DP extends by{constructor(e,r){super(r);m(this,"handleClose",()=>{var e,r;lC(this.editor)&&this.editor.focus(),(r=(e=this.options).onClose)==null||r.call(e)});this.editor=e,this.editorOptions=r}async popupInEditor(e,r,i){var d,h;if(((h=(d=this.editorOptions).onShow)==null?void 0:h.call(d,this,e,r,i))===!1)return;this.options.showLoading&&this.showLoading();const o=this.editor.getBlockByIndex(e,r);if(!ne(this.editor.rootContainer,o)||dt(this.editor,o)<i)return;const s=qi(this.editor,o,Te(this.editor,o,i));if(s.length===0)return;const l=s[0],c=Yi(this.editor,o,"editor-auto-suggest-menu",l);super.popup(c,{noEvent:!0})}}const aC=I("auto-suggest-menu");class cC{constructor(t,e){m(this,"order",100);m(this,"menu");m(this,"anchor",null);m(this,"close",()=>{this.menu.close()});m(this,"handleSelectionChanged",t=>{var r,i;if(!((r=this.menu)!=null&&r.isVisible))return;const e=t.selection.range.start;if(e.isSimple()&&e.blockId===((i=this.anchor)==null?void 0:i.blockId)&&e.offset>=this.anchor.offset){const o=t.getBlockById(e.blockId);if(fe(_n(bn(t,o),e.offset).left).startsWith(this.anchor.leftText))return}this.menu.close()});m(this,"deleteTrigger",()=>{const t=this.editor,e=t.selection.range.start;if(!e.isSimple()||!this.anchor)return!1;const{blockId:r,offset:i}=e,o=t.getBlockById(r),s=fe(ph(t,o,i));if(p(aC,this.anchor,"no anchor"),!s.startsWith(this.anchor.leftText))return!1;const l=this.anchor.offset-this.anchor.trigger.length,c=i-l;return t.selection.selectBlock(o,l),c&&(t.deleteTextFromBlock(o,l,c),this.anchor.offset-=this.anchor.trigger.length),this.anchor.trigger.length||this.menu.close(),!0});m(this,"onClose",()=>{var t,e;(e=(t=this.options).onClose)==null||e.call(t)});m(this,"onShow",(t,e,r,i)=>{var o;if((o=this.options)!=null&&o.onShow)return this.options.onShow(this,e,r,i)});m(this,"onClickItem",(t,e)=>{!this.anchor||(this.options.autoDeleteTrigger&&this.deleteTrigger(),this.options.onClickItem(this,e,this.anchor))});m(this,"queryItems",(t,e)=>this.options.queryItems(this,e));m(this,"renderMenuItem",(t,e)=>{var i,o;return(o=(i=this.options).renderMenuItem)==null?void 0:o.call(i,this,e)});m(this,"hasExistsMenuThemeCommandBar",()=>!!document.querySelector('div.tippy-box[data-theme="menu"]'));this.editor=t,this.options=e,this.menu=new DP(t,{id:e.id,showLoading:e.showLoading,loadingElement:e.loadingElement,placeholder:e.placeholder,header:e.header,footer:e.footer,wait:e.wait,noResultMessage:e.noResultMessage,highlight:e.highlight,onClose:this.onClose,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems,renderMenuItem:this.renderMenuItem}),t.input.addHandler(this),t.addListener("selectionChanged",this.handleSelectionChanged)}handleBeforeKeyDown(t,e){var r;return!((r=this.menu)!=null&&r.isVisible)||Ug(e.key)?!1:Yb(e)&&!Ps(e)?(setTimeout(()=>{this.resetItems()}),!1):Og(e)?(this.menu.close(),!0):(this.menu.handleKeydown(e),!0)}popup(t,e,r,i){this.anchor={blockId:st(t),offset:e,leftText:r,trigger:i};const o=ft(rt(t)),s=bt(t);this.menu.popupInEditor(o,s,e)}handleAfterInsertText(t,e,r,i,o){var h,C;const s=t.selection.range.start;if(!s.isSimple())return!1;const l=t.getBlockByIndex(e,r);if(Gi(l))return!1;const{blockId:c,offset:d}=s;if(st(l)!==c)return!1;if((h=this.menu)!=null&&h.isVisible)this.resetItems();else if(this.options.trigger.indexOf(o)!==-1){if(i>0&&this.options.needSpaceBeforeTrigger&&(((C=t.getBlockData(l).text)==null?void 0:C.reduce((R,L)=>R+L.insert,""))||"")[i-1].trim().length!==0||this.hasExistsMenuThemeCommandBar())return!1;const E=fe(ph(t,l,d));this.popup(l,d,E,o)}return!1}handleUpdateCompositionText(t,e,r,i,o){var d;const s=t.selection.range.start;if(!s.isSimple())return!1;const{blockId:l}=s,c=t.getBlockByIndex(e,r);return st(c)!==l||(d=this.menu)!=null&&d.isVisible&&this.resetItems(),!1}resetItems(){var l;if(!((l=this.menu)!=null&&l.isVisible))return;const t=this.editor,e=t.selection.range.start;if(!e.isSimple())return;const{blockId:r,offset:i}=e,o=t.getBlockById(r),s=fe(ph(t,o,i));if(p(aC,this.anchor,"no anchor"),s.startsWith(this.anchor.leftText)){const c=s.substring(this.anchor.leftText.length);aC.debug(`search text: ${c}`),this.menu.handleSearchText(c)}}destroy(){var t;this.editor.input.removeHandler(this),this.editor.removeListener("selectionChanged",this.handleSelectionChanged),(t=this.menu)==null||t.destroy()}}function _P(){const n={};for(let t=1;t<=8;t++)n[`heading-${t}`]={shortcut:`/h${t}`};return n}const MP={"insert-hr":{shortcut:"/hr"},"insert-uml":{shortcut:"/uml"},"insert-table":{shortcut:"/table"},"insert-image":{shortcut:"/image"},"insert-code":{shortcut:"/code"},"insert-link":{shortcut:"/link"},"insert-drawio":{shortcut:"/uml"},"insert-video":{shortcut:"/video"},"insert-audio":{shortcut:"/audio"},"insert-math":{shortcut:"/math"},"insert-webPage":{shortcut:"/web"},"insert-bilibili":{shortcut:"/bilibili"},"insert-youku":{shortcut:"/youku"},"insert-figma":{shortcut:"/figma"},"insert-modao":{shortcut:"/modao"},"insert-tencent":{shortcut:"/tencent"},"insert-unordered":{shortcut:"/bl"},"insert-ordered":{shortcut:"/nu"},"insert-checkbox":{shortcut:"/todo"},"insert-quote":{shortcut:"/quote"},..._P()};function Bn(n){var t;return(t=MP[n])==null?void 0:t.shortcut}function UP(n){var t;return(t=n.subText)!=null?t:""}const Ai=I("table-dom");function bi(n){return`${st(n)}_scroll`}function Ve(n){const t=n.querySelector("div[data-type=table-content] >table");return p(Ai,t instanceof HTMLTableElement,"invalid table"),t}function vi(n,t){const r=n.getCustom(bi(t)).contentElement.firstElementChild;p(Ai,r instanceof HTMLElement,"invalid table content");let i=r.querySelector(":scope >div[data-type=table-tools]");return i||(i=B("div",[],r),i.setAttribute("data-type","table-tools"),n.domEvents.addEventListener(i,"dblclick",(o,s)=>s.stopPropagation()),n.domEvents.addEventListener(i,"click",(o,s)=>{s.detail===3&&s.stopPropagation()})),p(Ai,i,"no table tools"),i}function OP(n,t){return n.findCustom(bi(t))?vi(n,t):null}function ky(n){const t=[];return Array.from(n.rows).forEach(e=>{t.push(...Array.from(e.cells))}),t}function Ku(n){const t=n.querySelector(":scope div[data-type=editor-container]");return p(Ai,t,"no child container in cell"),t}function NP(n){const r=ky(n).map(i=>{const o=Ku(i),s=ft(o),l=i.colSpan,c=i.rowSpan;return`${s}/${l}/${c}`}).join();return kd.default(r)}function $e(n){return St(n)==="table"}function uC(n){const t=rt(n);if(Xt(t))return null;const e=et(t);return p(Ai,e,"no parent block"),$e(e)?t:uC(e)}function uo(n){if($e(n))return n;const t=rt(n);if(Xt(t))return null;const e=et(t);return p(Ai,e,"no parent block"),$e(e)?e:uo(e)}function PP(n,t){const e=n.querySelector("colgroup");p(Ai,e,"no colgroup");const r=e.children[t];return p(Ai,r,"no col"),p(Ai,r instanceof HTMLTableColElement,`invalid col: ${r.tagName}`),r}function Ry(n){try{return Ve(n),!0}catch{return!1}}function FP(n){return re(n).querySelector(":scope > .block-helper")}function wy(n){const t=et(n.contentElement);p(Ai,t,"no block");const e=FP(t);if(e){const o=Math.min(n.contentElement.offsetLeft+29,n.rootElement.scrollLeft),s=t.getBoundingClientRect().width;e.style.right=`${o+s+5}px`}}const zr=I("doc-table-grid");class KP{constructor(t){m(this,"_cells",[]);for(let e=0;e<t;e++)this._cells.push(void 0)}cols(){return this._cells.length}setCell(t,e){p(zr,t>=0&&t<this.cols(),`set cell, invalid col: ${t}`),this._cells[t]=e}getCell(t){p(zr,t>=0&&t<this.cols(),`get cell, invalid col: ${t}`);const e=this._cells[t];return p(zr,e,"get cell, no cell"),e}getCellAllowEmpty(t){return p(zr,t>=0&&t<this.cols(),`get cell, invalid col, ${t}`),this._cells[t]}getNextNonVirtualCell(t){return this._cells.slice(t+1).find(e=>!e.virtual)}forEach(t){this._cells.forEach(t)}}class a0{constructor(t){m(this,"_data");m(this,"_rows");this._data=t,this._rows=[];for(let e=0;e<this.rowCount;e++)this._rows.push(new KP(this.colCount));this.fillGrid()}get rowCount(){return this._data.rows}get colCount(){return this._data.cols}getNextEmptyCell(t,e){let r=t,i=e;for(;;){if(r+=1,r===this.colCount&&(r=0,i+=1),i>=this.rowCount)return null;if(this._rows[i].getCellAllowEmpty(r)===void 0)return{col:r,row:i}}}fillGrid(){const t=this._data.children;p(zr,t,"no children");let e=0,r=0;t.forEach((i,o)=>{const s=this._data[`${i}_colSpan`]||1,l=this._data[`${i}_rowSpan`]||1;for(let d=0;d<l;d++)for(let h=0;h<s;h++)this._rows[r+d].setCell(e+h,{col:e,row:r,containerId:i,virtual:h!==0||d!==0,colSpan:s,rowSpan:l});const c=this.getNextEmptyCell(e,r);c?(e=c.col,r=c.row):p(zr,o===t.length-1,`invalid table data, no next empty cell: ${JSON.stringify(this._data)}`)}),this._rows.forEach(i=>{i.forEach(o=>{p(zr,o,"no cell"),p(zr,o.containerId,"no containerId")})})}getCell(t){const{col:e,row:r}=t,i=this._rows[r];p(zr,i,`get cell, no row: ${r}`);const o=i.getCell(e);return p(zr,o,`get cell, no cell: ${e}`),o}getRow(t){const e=this._rows[t];return p(zr,e,`get row, no row: ${t}`),e}forEach(t){this._rows.forEach(t)}}const c0=I("table-data");function VP(n){const t=n.firstElementChild;return p(c0,t,"no child element for cell"),p(c0,Wi(t),"cell first child is not a container"),p(c0,Mr(t),"cell first child is not a container"),t}function $P(n){const t=et(n);p(c0,t,"no parent block for table");const e=[],r={};Array.from(n.rows).forEach(l=>{Array.from(l.cells).forEach(c=>{const d=VP(c),h=ft(d);e.push(h),(c.colSpan>1||c.rowSpan>1)&&(r[`${h}_colSpan`]=c.colSpan,r[`${h}_rowSpan`]=c.rowSpan)})});const i=n.rows.length,o=Array.from(n.rows[0].cells).map(l=>l.colSpan).reduce((l,c)=>l+c,0);return{id:st(t),type:St(t),rows:i,cols:o,children:e,colsWidth:Array(o).fill(100),...r}}function ll(n){return new a0(n)}function HP(n){return ll($P(n))}const Qe=I("table-grid"),jP=60;class zP{constructor(t,e){m(this,"containerId");m(this,"row");m(this,"col");m(this,"colSpan");m(this,"rowSpan");m(this,"virtual");m(this,"table");this.table=t,this.containerId=e.containerId,this.row=e.row,this.col=e.col,this.colSpan=e.colSpan,this.rowSpan=e.rowSpan,this.virtual=e.virtual}get cell(){const e=this.container.closest("td");return p(Qe,e,"no parent cell for child container"),e}get container(){const t=this.table.querySelectorAll(`[data-container-id=${this.containerId}]`);p(Qe,t.length===1,"containers !== 1"),p(Qe,Wi(t[0]),"not a container");const e=t[0];return p(Qe,Mr(e),"not a child container"),e}}class GP{constructor(t,e){m(this,"_cells",[]);e.forEach(r=>{this._cells.push(new zP(t,r))})}get cells(){return this._cells}getCell(t){return p(Qe,t<this._cells.length,"get cell, invalid col"),this._cells[t]}getNextNonVirtualCell(t){return this._cells.slice(t+1).find(e=>!e.virtual)}getSpannedCell(){return this._cells.find(t=>t.virtual||t.colSpan>1||t.rowSpan>1)}}const Bx=class{constructor(t){m(this,"_rows",[]);this.table=t,HP(t).forEach(i=>{this._rows.push(new GP(t,i))});const r=this.colCount;this._rows.forEach(i=>{p(Qe,i.cells.length===r,"row.cells.length !== colCount")})}get rowCount(){return this._rows.length}get colCount(){return this._rows.length===0?0:(p(Qe,this.rowCount>0,"rowCount <= 0"),this.getRow(0).cells.length)}getRow(t){return this._rows[t]}getCell(t){const e=this.getRow(t.row);return p(Qe,e,"no row"),e.getCell(t.col)}getCellContainer(t){return this.getCell(t).container}getFirstCellContainer(){return this.getCellContainer({row:0,col:0})}getLastCellContainer(){const t=this.rowCount-1,e=this.colCount-1;return this.getCellContainer({row:t,col:e})}getColumnCells(t){p(Qe,t>=0&&t<this.colCount,"colIndex out of range");const e=this.rowCount,r=[];for(let i=0;i<e;i++){const o=this.getCell({row:i,col:t});r.push(o)}return r}toRealCells(t){const e=[];return t.forEach(r=>{const i=this.getRealCell(r);e.findIndex(o=>o.containerId===i.containerId)===-1&&e.push(i)}),e}getColumnRealCells(t){const e=this.getColumnCells(t);return this.toRealCells(e)}getRowRealCells(t){const e=this.getRow(t).cells;return this.toRealCells(e)}getFirstSpannedCell(t){p(Qe,t>=0&&t<this.colCount,"colIndex out of range");const e=this.rowCount;for(let r=0;r<e;r++){const i=this.getCell({row:r,col:t});if(i.virtual||i.colSpan>1||i.rowSpan>1)return i}}getRealCell(t){const e=this.getCell(t);if(!e.virtual)return e;const r=this.getCellById(e.containerId);return p(Qe,!r.virtual,"found a virtual cell"),r}getColumnSpannedRange(t){const e=this.getColumnRealCells(t);let r=1e5,i=-1;return e.forEach(o=>{r=Math.min(o.col,r),i=Math.max(o.col+o.colSpan-1,i)}),p(Qe,r<=i,"min > max"),p(Qe,r>=0,"min < 0"),p(Qe,i<this.colCount,"max >= colCount"),[r,i]}getRowSpannedRange(t){const e=this.getRowRealCells(t);let r=1e5,i=-1;return e.forEach(o=>{r=Math.min(o.row,r),i=Math.max(o.row+o.rowSpan-1,i)}),p(Qe,r<=i,"min > max"),p(Qe,r>=0,"min < 0"),p(Qe,i<this.rowCount,"max >= rowCount"),[r,i]}getSpannedRange(t,e){const r=Math.min(t.row,e.row),i=Math.max(t.row,e.row),o=Math.min(t.col,e.col),s=Math.max(t.col,e.col),l=[];for(let A=r;A<=i;A++)for(let v=o;v<=s;v++)l.push(this.getCell({row:A,col:v}));const c=this.toRealCells(l);let d=1e4,h=1e4,C=-1,E=-1;return c.forEach(A=>{h=Math.min(A.col,h),d=Math.min(A.row,d),E=Math.max(A.col+A.colSpan-1,E),C=Math.max(A.row+A.rowSpan-1,C)}),[{row:d,col:h},{row:C,col:E}]}getAllCells(){return this.getCells({col:0,row:0},{col:this.colCount-1,row:this.rowCount-1})}sub(t,e){const r=[];for(let i=t.row;i<=e.row;i++){const o=[];for(let s=t.col;s<=e.col;s++){const l=this.getCell({row:i,col:s});o.push(l)}r.push(o)}return r}getAllContainers(){return this.getAllCells().map(e=>e.container)}getCells(t,e){const r=[],i=this.getSpannedRange(t,e),o=i[0],s=i[1],l=Math.min(o.row,s.row),c=Math.max(o.row,s.row),d=Math.min(o.col,s.col),h=Math.max(o.col,s.col);for(let C=l;C<=c;C++)for(let E=d;E<=h;E++){const A=this.getCell({row:C,col:E});A.virtual||r.push(A)}return r}map(t){const e=[];for(let r=0;r<this.rowCount;r++){const i=[];for(let o=0;o<this.colCount;o++){const s=this.getCell({row:r,col:o});i.push(t(s))}e.push(i)}return e}getBottomCell(t){const e=this.rowCount;let r=t,i=t.row;for(;r.containerId===t.containerId;){if(i+=1,i>=e)return null;r=this.getCell({row:i,col:t.col})}return this.getRealCell(r)}getTopCell(t){let e=t,r=t.row;for(;e.containerId===t.containerId;){if(r-=1,r<0)return null;e=this.getCell({row:r,col:t.col})}return this.getRealCell(e)}get cells(){let t=[];return this._rows.forEach(e=>{t=t.concat(e.cells)}),t}getVirtualCellContainersGrid(){return this.map(t=>t.containerId)}static virtualCellContainersGridToChildren(t){const e=t,r=[];return e.forEach(i=>{i.forEach(o=>{r.indexOf(o)===-1&&r.push(o)})}),r}getCellById(t){const r=this.cells.find(i=>i.containerId===t);return p(Qe,r,"cell not found"),r}getCellByCellElement(t){const e=Ku(t);return this.getCellByContainerId(ft(e))}getCellByContainerId(t){return this.getCellById(t)}static fromTable(t){const e=NP(t),r=this.caches.getSync(e,()=>(Qe.debug("create table grid"),new Bx(t)));return r.table!==t?(this.caches.delete(e),this.fromTable(t)):r}static fromBlock(t){return this.fromTable(Ve(t))}};let It=Bx;m(It,"caches",new Db(jP));function u0(n,t){Object.entries(n).forEach(([e])=>{e.startsWith(`${t}/`)&&delete n[e]})}const WP=I("table-selection-range");function Gr(n,t,e){var U,F,G,W;const r=It.fromBlock(n),i=t,o=e,s=r.getCellByContainerId(i.childContainerId),l=r.getCellByContainerId(o.childContainerId),c=i.custom,d=o.custom,h=(U=c==null?void 0:c.rowIndex)!=null?U:s.row,C=(F=c==null?void 0:c.colIndex)!=null?F:s.col,E=(G=d==null?void 0:d.rowIndex)!=null?G:l.row+l.rowSpan-1,A=(W=d==null?void 0:d.colIndex)!=null?W:l.col+l.colSpan-1,v=Math.min(h,E),R=Math.max(h,E),L=Math.min(C,A),M=Math.max(C,A);return{fromRow:v,toRow:R,fromCol:L,toCol:M}}function fC(n,t){const e=new Set,r=new Set,i=n.selection.range;if(!i.isSimple()&&i.start.blockId===st(t)){const o=It.fromBlock(t),{start:s,end:l}=i;p(WP,!s.isSimple()&&!l.isSimple(),"invalid range");const{fromCol:c,toCol:d,fromRow:h,toRow:C}=Gr(t,s,l);if(h===0&&C===o.rowCount-1)for(let E=c;E<=d;E++)r.add(E);if(c===0&&d===o.colCount-1)for(let E=h;E<=C;E++)e.add(E)}return{selectedRows:e,selectedColumns:r}}function Vu(n,t){let e=null;if(t.isCollapsed()&&t.isSimple()){const r=n.getBlockById(t.start.blockId);if($e(r)){const i=rt(r),o=et(i);o&&(e=uo(o))}else e=uo(r)}else{const r=n.getBlockById(t.start.blockId),i=uo(r),o=n.getBlockById(t.end.blockId),s=uo(o);i===s&&(e=i)}return e}const $a=I("delete-columns");function Sy(n,t,e){const{start:r,end:i}=e;if(r.blockId!==i.blockId||e.isSimple()||n.getBlockById(r.blockId)!==t||St(t)!=="table")return!1;const{fromRow:s,toRow:l}=Gr(t,e.start,e.end),c=It.fromBlock(t);return s===0&&l===c.rowCount-1}function dC(n){const t=n.getEditor();t.undoManager.runInGroup(()=>{var F,G;const e=t.getBlockById(n.start.blockId);if(!Sy(t,e,n))return;if(n.isSimple()){t.deleteBlock(e);return}const{fromCol:r,toCol:i}=Gr(e,n.start,n.end),o=It.fromBlock(e);if(r===0&&i===o.colCount-1){t.deleteBlock(e);return}const s=new Set,l=o.map(W=>W.containerId);for(let W=0;W<l.length;W++){const it=l[W];for(let at=r;at<=i;at++){const xt=it[at];s.add(xt)}it.splice(r,i-r+1)}const c=new Set(l.flat()),d=new Set(Array.from(s).filter(W=>!c.has(W))),h=i-r+1,C=new Map,E=new Map;s.forEach(W=>{if(d.has(W))return;const it=o.getCellByContainerId(W);if(p($a,it.colSpan>1,"invalid effected cell, colSpan === 1"),it.col<r){p($a,c.has(W),"invalid effected cell, not exists");let te=it.col+it.colSpan-1;te>i&&(te=i);const kn=te-r+1,be=it.colSpan-kn;C.set(W,be);return}p($a,it.col<=i,"invalid effected cell, col > endCol");const at=it.col,xt=it.col+it.colSpan-1,Mt=it.col-r,Bt=xt-at+1-h+Mt;p($a,Bt>0,"invalid effected cell, newSpanned <= 0");const le=no(t.doc);E.set(W,{newContainerId:le,colSpan:Bt})});for(let W=0;W<l.length;W++){const it=l[W];for(let at=r;at<it.length;at++){const xt=it[at],Mt=E.get(xt);Mt&&(it[at]=Mt.newContainerId)}}const A=gt.default(t.getBlockData(e));((F=A.colsWidth)!=null?F:new Array(A.cols).fill(0)).splice(r,i-r+1),d.forEach(W=>{u0(A,W)}),C.forEach((W,it)=>{p($a,W>=1,"invalid modified colSpan, colSpan < 1"),W===1?A[`${it}_colSpan`]=void 0:A[`${it}_colSpan`]=W}),E.forEach((W,it)=>{u0(A,it);const{newContainerId:at,colSpan:xt}=W;p($a,xt>=1,"invalid newContainerData, colSpan < 1"),xt>1&&(A[`${at}_colSpan`]=xt);const Mt=o.getCellByContainerId(it).rowSpan;Mt>1&&(A[`${at}_rowSpan`]=Mt)});const R=(G=l[0][r])!=null?G:l[0][r-1],L=t.getChildContainerData(R)[0],M=It.virtualCellContainersGridToChildren(l),U={...A,cols:A.cols-h,children:M};ll(U),t.updateBlockData(e,U,Te(t,L.id,0)),t.deleteChildContainers(Array.from(d)),t.deleteChildContainers(Array.from(E.keys()))})}const Ha=I("delete-rows");function Ly(n,t,e){const{start:r,end:i}=e;if(r.blockId!==i.blockId||e.isSimple()||n.getBlockById(r.blockId)!==t||St(t)!=="table")return!1;const{fromCol:s,toCol:l}=Gr(t,e.start,e.end),c=It.fromBlock(t);return s===0&&l===c.colCount-1}function hC(n){const t=n.getEditor();t.undoManager.runInGroup(()=>{const e=t.getBlockById(n.start.blockId);if(!Ly(t,e,n))return;if(n.isSimple()){t.deleteBlock(e);return}const{fromRow:r,toRow:i}=Gr(e,n.start,n.end),o=It.fromBlock(e);if(r===0&&i===o.rowCount-1){t.deleteBlock(e);return}const s=new Set,l=o.map(U=>U.containerId);for(let U=i;U>=r;U--)l[U].forEach(G=>s.add(G)),l.splice(U,1);const c=new Set(l.flat()),d=new Set(Array.from(s).filter(U=>!c.has(U))),h=i-r+1,C=new Map,E=new Map;s.forEach(U=>{if(d.has(U))return;const F=o.getCellByContainerId(U);if(p(Ha,F.rowSpan>1,"invalid effected cell, rowSpan === 1"),F.row<r){p(Ha,c.has(U),"invalid effected cell, not exists");let Mt=F.row+F.rowSpan-1;Mt>i&&(Mt=i);const Bt=Mt-r+1,le=F.rowSpan-Bt;C.set(U,le);return}p(Ha,F.row<=i,"invalid effected cell, col > endCol");const G=F.row,W=F.row+F.rowSpan-1,it=F.row-r,at=W-G+1-h+it;p(Ha,at>0,"invalid effected cell, newSpanned <= 0");const xt=no(t.doc);E.set(U,{newContainerId:xt,rowSpan:at})});for(let U=r;U<l.length;U++){const F=l[U];for(let G=0;G<F.length;G++){const W=F[G],it=E.get(W);it&&(F[G]=it.newContainerId)}}const A=gt.default(t.getBlockData(e));d.forEach(U=>{u0(A,U)}),C.forEach((U,F)=>{p(Ha,U>=1,"invalid modified rowSpan, rowSpan < 1"),U===1?A[`${F}_rowSpan`]=void 0:A[`${F}_rowSpan`]=U}),E.forEach((U,F)=>{u0(A,F);const{newContainerId:G,rowSpan:W}=U;p(Ha,W>=1,"invalid newContainerData, rowSpan < 1"),W>1&&(A[`${G}_rowSpan`]=W);const it=o.getCellByContainerId(F).colSpan;it>1&&(A[`${G}_colSpan`]=it)});const v=l[r]?l[r][0]:l[r-1][0],R=t.getChildContainerData(v)[0],L=It.virtualCellContainersGridToChildren(l),M={...A,rows:A.rows-h,children:L};ll(M),t.updateBlockData(e,M,Te(t,R.id,0)),t.deleteChildContainers(Array.from(d)),t.deleteChildContainers(Array.from(E.keys()))})}const $u=I("table-range");function f0(n){p($u,!n.isSimple(),"must be complex selection range");const{anchor:t,focus:e}=n;p($u,!t.isSimple(),"invalid start pos type"),p($u,!e.isSimple(),"invalid end pos type");const r=n.getEditor();p($u,t.blockId===e.blockId,"invalid range, not same block");const i=r.getBlockById(t.blockId);p($u,St(i)==="table","invalid block type, not a table block");const o=Ve(i),s=It.fromTable(o),l=s.getCellByContainerId(t.childContainerId),c=s.getCellByContainerId(e.childContainerId),d=Math.min(l.row,c.row),h=Math.max(l.row,c.row),C=Math.min(l.col,c.col),E=Math.max(l.col,c.col),A=s.getCell({row:d,col:C}),v=s.getCell({row:h,col:E});return{editor:r,block:i,table:o,startCell:A,endCell:v,startRow:d,startCol:C,endRow:h,endCol:E}}const mC=I("split-cell");function gC(n,t,e){n.undoManager.runInGroup(()=>{const r=It.fromBlock(t),i=r.getRealCell(e);p(mC,!i.virtual,"should not split virtual cell"),p(mC,i.colSpan>1||i.rowSpan>1,"cell does not has span data");const o=r.getVirtualCellContainersGrid();for(let C=0;C<i.rowSpan;C++)for(let E=0;E<i.colSpan;E++){if(C===0&&E===0)continue;const A=C+i.row,v=E+i.col,R=no(n.doc);o[A][v]=R}const s=n.getBlockData(t),l=gt.default(s);l[`${i.containerId}_colSpan`]=null,l[`${i.containerId}_rowSpan`]=null,l.children=It.virtualCellContainersGridToChildren(o);const d=n.getChildContainerData(i.containerId)[0];p(mC,d,"no child block");const h=Te(n,d.id,0);ll(l),n.updateBlockData(t,l,h)})}function qP(n,t,e){e.forEach(r=>{const i=It.fromBlock(t).getCell(r);(i.virtual||i.colSpan>1||i.rowSpan>1)&&gC(n,t,r)})}function Iy(n,t,e){if(e.isSimple())return!1;const{start:r,end:i}=e;if(r.blockId!==i.blockId||n.getBlockById(r.blockId)!==t||St(t)!=="table")return!1;const{startCell:s,endCell:l}=f0(e);return!(s.cell!==l.cell||s.colSpan===1&&s.rowSpan===1)}function pC(n){const{editor:t,block:e,startRow:r,startCol:i,endRow:o,endCol:s}=f0(n),l=[];for(let c=r;c<=o;c++)for(let d=i;d<=s;d++)l.push({row:c,col:d});return qP(t,e,l),!0}const ja=I("merge-cells");function Dy(n,t,e){if(e.isSimple())return!1;const{start:r,end:i}=e;if(r.blockId!==i.blockId||n.getBlockById(r.blockId)!==t||St(t)!=="table")return!1;const{startCell:s,endCell:l}=f0(e);return s.cell!==l.cell}function _y(n){const t=f0(n),e=t.editor;e.undoManager.runInGroup(()=>{const r=t.endCell,i=r.row+r.rowSpan-1,o=r.col+r.colSpan-1,s=st(t.block);pC(n);const l=e.getBlockById(s),c=Ve(l),{startRow:d,startCol:h}=t,C=gt.default(e.getBlockData(l));p(ja,C.children,"no table children");const E=It.fromTable(c),A=[];for(let Mt=d;Mt<=i;Mt++)for(let Bt=h;Bt<=o;Bt++){const le=E.getCell({row:Mt,col:Bt});p(ja,!le.virtual,"cell is virtual"),A.push(le)}p(ja,A.length>0,"no selected cells");const v=A[0],R=A.slice(1),L=E.getCellByContainerId(v.containerId).container,M=[];R.forEach(Mt=>{const Bt=E.getCellByContainerId(Mt.containerId).container,le=ft(Bt);if(!uu(e,Bt)){const te=G5(e,le);if(uu(e,L)){const kn=ue(L)[0];e.insertDocAt(L,0,te),e.deleteBlock(kn)}else e.insertDocAt(L,Lr(L),te)}M.push(le)});const U=ft(L),F=o-h+1,G=i-d+1;C[`${U}_colSpan`]=F,C[`${U}_rowSpan`]=G,M.forEach(Mt=>{p(ja,C.children,"no table children");const Bt=C.children.indexOf(Mt);p(ja,Bt>0,"no deleted container"),C.children.splice(Bt,1)});const W=C,at=e.getChildContainerData(U)[0];p(ja,at,"no child block");const xt=Te(e,at.id,0);ll(W),e.updateBlockData(l,W,xt),e.deleteChildContainers(M)})}const CC=10,XP=["table/merge-cells","table/split-cell","table/insert-column","table/insert-row","table/delete-rows","table/delete-columns","table/delete"];class d0{constructor(){m(this,"id","TableBlockCommandProvider")}getAvailableCommands(t,e,r){if(St(e)!=="table")return[];const i={blockId:st(e),blockKind:Ir(t,e),blockType:St(e)},o=[];Dy(t,e,r)&&o.push({id:"table/merge-cells",name:D.t("table.mergeCell"),icon:CT,groupIndex:CC,...i}),Iy(t,e,r)&&o.push({id:"table/split-cell",name:D.t("table.splitCell"),icon:ET,groupIndex:CC,...i});const s=Sy(t,e,r),l=Ly(t,e,r);return s&&l&&o.push({id:"table/delete",name:D.t("table.deleteTable"),icon:xT,groupIndex:CC,...i}),o}executeCommand(t,e,r,i,o,s){return St(e)!=="table"||!new Set(XP).has(i.id)?!1:i.id==="table/merge-cells"?(_y(r),!0):i.id==="table/split-cell"?(pC(r),!0):i.id==="table/delete-columns"?(dC(r),!0):i.id==="table/delete-rows"?(hC(r),!0):i.id==="table/delete"?(t.deleteBlock(e),!0):!1}}var My=(n=>(n.COL_TITLE_TABLE="col-title-table",n.COL_TITLE_ITEM="col-title-item",n.STRIPE_STYLE_TABLE="stripe-style-table",n.NO_BORDER="table-no-border",n))(My||{});const za=6,Hu=20,EC="table-cell-menu-btn";function QP(n,t){if(!n.isBlockWritable(t))return;const r={...gt.default(n.getBlockData(t)),hasColTitle:!0};n.updateBlockData(t,r)}function YP(n,t){if(!n.isBlockWritable(t))return;const r={...gt.default(n.getBlockData(t)),hasColTitle:!1};n.updateBlockData(t,r)}function JP(n,t){if(!n.isBlockWritable(t))return;const r={...gt.default(n.getBlockData(t)),hasRowTitle:!0};n.updateBlockData(t,r)}function ZP(n,t){if(!n.isBlockWritable(t))return;const r={...gt.default(n.getBlockData(t)),hasRowTitle:!1};n.updateBlockData(t,r)}function tF(n,t){if(!n.isBlockWritable(t))return;const r={...gt.default(n.getBlockData(t)),isStripeStyle:!0};n.updateBlockData(t,r)}function eF(n,t){if(!n.isBlockWritable(t))return;const r={...gt.default(n.getBlockData(t)),isStripeStyle:!1};n.updateBlockData(t,r)}function nF(n,t,e){if(!n.isBlockWritable(t))return;const i={...gt.default(n.getBlockData(t)),noBorder:!e};n.updateBlockData(t,i)}const al=I("table-cell-dom");function rF(n,t,e){let r=n.getBlockById(e);for(;r;){const i=r.closest("td");p(al,i,"no parent cell");const o=et(i);if(p(al,o,"no parent block"),o===t)return i;r=o}return p(al,!1,"filed to get cell by child block id"),null}function ts(n,t,e){if(n.getBlockById(e.blockId)===t&&!e.isSimple())return p(al,e.childContainerId,"block position must have childContainerId attribute"),e;const i=rF(n,t,e.blockId),o=ft(Ku(i));return xe(t,o)}function xC(n,t){const e=n.selection.range,r=ts(n,t,e.start),i=ts(n,t,e.end);return Gr(t,r,i)}function Uy(n,t,e,r){p(al,$e(t),"invalid table block");const i=vi(n,t),o=re(t),s=()=>{const c=i.querySelector(".table-border-bar-container.top");p(al,c,"no top border bar container"),c.querySelectorAll(".table-border-bar-cell.top").forEach(h=>{const C=parseInt(h.getAttribute("data-top-index")||"0",10);r.includes(C)?z(h,"danger"):ot(h,"danger")})},l=()=>{const c=o.querySelector(".table-border-bar-container.left");p(al,c,"no left border bar container"),c.querySelectorAll(".table-border-bar-cell.left").forEach(h=>{const C=parseInt(h.getAttribute("data-left-index")||"0",10);e.includes(C)?z(h,"danger"):ot(h,"danger")})};s(),l()}function es(n,t,e=!0,r){const o=It.fromBlock(t).map(h=>h),{fromCol:s,toCol:l,fromRow:c,toRow:d}=xC(n,t);for(let h=0;h<o.length;h++){const C=o[h];for(let E=0;E<C.length;E++){const A=C[E],v=r?E>=s&&E+A.colSpan-1<=l:h>=c&&h+A.rowSpan-1<=d;e&&v?A.virtual||z(A.cell,"danger"):A.virtual||ot(A.cell,"danger")}}}function ns(n,t,e=!0,r){const i=new Set,o=new Set;if(!e){Uy(n,t,Array.from(i),Array.from(o));return}const{fromCol:s,toCol:l,fromRow:c,toRow:d}=xC(n,t);if(r)for(let h=s;h<=l;h++)o.add(h);else for(let h=c;h<=d;h++)i.add(h);Uy(n,t,Array.from(i),Array.from(o))}function Oy(n,t,e){const{fromCol:r,toCol:i,fromRow:o,toRow:s}=xC(n,t),l=It.fromBlock(t);let c=null,d=null;return e?(c=l.getCell({col:r,row:0}),d=l.getCell({col:i,row:l.rowCount-1}),qe(n,{anchor:xe(t,c.containerId,{colIndex:r,rowIndex:0}),focus:xe(t,d.containerId,{colIndex:i,rowIndex:l.rowCount-1})})):(c=l.getCell({col:0,row:o}),d=l.getCell({col:l.colCount-1,row:s}),qe(n,{anchor:xe(t,c.containerId,{colIndex:0,rowIndex:o}),focus:xe(t,d.containerId,{colIndex:l.colCount-1,rowIndex:s})}))}const Ny=["style-bg-color-0","style-bg-color-1","style-bg-color-2","style-bg-color-3","style-bg-color-4","style-bg-color-5","style-bg-color-6","style-bg-color-7","style-bg-color-8","style-bg-color-9","style-bg-color-10","style-bg-color-11","style-bg-color-12","style-bg-color-13"];function Py(n){return`style-bg-color-${n}`}function ju(n){return`${n}_background`}function iF(n,t,e){const r=Ve(n),s=(e!=null?e:It.fromTable(r)).getCell(t).cell;for(let l=0;l<Ny.length;l++){const c=Ny[l];if(Rt(s,c))return c}}function Fy(n,t,e){if(!n.isBlockWritable(t))return;const r=n.selection.range,o={...gt.default(n.getBlockData(t))},s=ts(n,t,r.start),l=ts(n,t,r.end);if(r.isSimple()){const c=s.childContainerId;e===-1?o[ju(c)]=void 0:o[ju(c)]=Py(e)}else{const c=It.fromBlock(t),d=Gr(t,s,l),h=new Set;for(let C=d.fromRow;C<=d.toRow;C++)for(let E=d.fromCol;E<=d.toCol;E++){const A=c.getCell({row:C,col:E});!h.has(A.containerId)&&A.col>=d.fromCol&&A.row>=d.fromRow&&A.col+A.colSpan-1<=d.toCol&&A.row+A.rowSpan-1<=d.toRow&&(h.add(A.containerId),e===-1?o[ju(A.containerId)]=void 0:o[ju(A.containerId)]=Py(e))}}n.updateBlockData(t,o)}function oF(n,t,e){if(!n.isBlockWritable(t))return;const i={...gt.default(n.getBlockData(t)),chart:e};n.updateBlockData(t,i)}const Ky=I("table-chart");function sF(n,t){const e=OP(n,t);if(e){const r=e.querySelector(".editor-table-chart");if(r){const i=r.chartObject;i&&i.destroy(),r.remove()}}}async function lF(n,t){if(!n.contains(t)||!n.isBlockWritable(t))return;if(!!!n.getBlockData(t).chart){sF(n,t);return}const i=[],o=It.fromBlock(t),s=["line","bar","pie","radar"];let l=o.getCell({row:0,col:0}).container.innerText.trim().toLowerCase();new Set(s).has(l)||(l=s[0]);const c=[];for(let R=1;R<o.colCount;R++)c.push(o.getCell({row:0,col:R}).container.innerText);for(let R=1;R<o.rowCount;R++){const L=o.getCell({row:R,col:0}),U=L.container.innerText,F=[];for(let te=1;te<o.colCount;te++){const kn=o.getCell({row:R,col:te}).container.innerText,be=Number.parseFloat(kn)||0;F.push(be)}let G;const W=iF(t,L,o);W?G=window.getComputedStyle(n.rootElement).getPropertyValue(`--${W}`).trim():G=window.getComputedStyle(n.rootElement).getPropertyValue("--background-color").trim();let[it,at,xt,Mt]=G?bg.fromString(G).toRgbaArray():[];if(!it&&!at&&!xt&&!Mt){const te=(R-1)%n.options.colors.length;G=n.options.colors[te],[it,at,xt,Mt]=bg.fromString(G).toRgbaArray()}const Bt=G,le=bg.fromRgba([it,at,xt,Mt/3]).toHexString();i.push({label:U,data:F,borderColor:Bt,backgroundColor:le,borderWidth:2})}const d=vi(n,t);let h=null,C=d.querySelector(".editor-table-chart");C?h=C.chartObject:C=B("div",["editor-table-chart"],d);const E=C;p(Ky,E,"no chart container");const A=n.getComponentOptions("table"),v=(A==null?void 0:A.chartCdn)||"https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.min.js";try{await Os(v,"editor-chartjs");let R=!1;(h&&h.config.data.datasets.length>i.length||h&&h.config.data.datasets[0].data.length>i[0].data.length)&&(R=!0),h&&(l!==h.config.type||R)&&(h.destroy(),h=null,Array.from(C.querySelectorAll(".editor-chartjs-canvas")).forEach(U=>{U.remove()}));const L=Bg.default({},{type:l,data:{datasets:i,labels:c},options:{onClick:()=>{n.selection.selectBlock(t,0,0)}}});if(h)Bg.default(h.config,L),h.update();else{const U=B("canvas",["editor-chartjs-canvas"],E).getContext("2d");h=new window.Chart(U,L),C.chartObject=h}}catch(R){Ky.error(`failed to resolve chart cdn: ${JSON.stringify(R)}`)}}async function Vy(n,t){await Sr.lock("updateTableChart");try{await lF(n,t)}finally{Sr.release("updateTableChart")}}const $y=Me.default(Vy,1e3);let Hy=null;function AC(n,t,e){if(Hy!==t&&($y.flush(),Hy=t),e.updateNow){Vy(n,t);return}$y(n,t)}function bC(n,t){$e(t)&&AC(n,t,{updateNow:!1})}function aF(n,t){$e(t)&&AC(n,t,{updateNow:!0})}const Er={SCROLL:"container-scroll-tool",COMMON:"container-border-shadow",RIGHT:"container-right-border-shadow",LEFT:"container-left-border-shadow",LAYOUT_SIGN:"container-layout-border-shadow",ACTIVE:"active"},h0={SCROLL_BAR:"container-scrollbar",FIXED:"fixed"},rs={SCROLL_CONTAINER:"scroll-container",TOOL:"container-scroll-tool",CONTAINER:"scroll-container-root",MAC:"mac",SCROLL_AREA:"scroll-area"};function zu(n,t){return n.containers.get(t)}function jy(n){return n.closest(`.${rs.SCROLL_CONTAINER}`)}function Wr(n){return n.firstElementChild}function Tn(n){return n.closest(`.${rs.CONTAINER}`)}function Gu(n){const t=Tn(n);let e=t.querySelector(`:scope >.${rs.TOOL}`);return e||(e=B("div",[rs.TOOL],t)),e}function cF(n){return Tn(n).firstElementChild}function uF(n,t){const e=zu(n,Tn(t));return e!=null&&e.barFloatWindowBottom?typeof e.barFloatWindowBottom=="function"?e.barFloatWindowBottom():e.barFloatWindowBottom:0}function xr(n,t){const e=fr(n);return t/e}function Wu(n){const t=window.getComputedStyle(n),e=fr(n);return{paddingBottom:parseFloat(t.paddingBottom)*e,paddingTop:parseFloat(t.paddingTop)*e,paddingLeft:parseFloat(t.paddingLeft)*e,paddingRight:parseFloat(t.paddingRight)*e}}function Ga(n){const t=fr(n);return{scrollLeft:n.scrollLeft*t,scrollWidth:n.scrollWidth*t,clientWidth:n.clientWidth*t,clientHeight:n.clientHeight*t}}function fF(n,t){const e=fr(n);return n[t]*e}function vC(n,t){const e=Tn(t),r=zu(n,e),i=(r==null?void 0:r.safeRightSpace)||0,o=(r==null?void 0:r.safeLeftSpace)||0,l=(r==null?void 0:r.locatingContainer).getBoundingClientRect(),c=e.getBoundingClientRect(),d=c.width;let h=Math.floor(c.left-l.left-o);h<0&&(h=0);let C=l.right;C-=i;let E=C-c.right;return E<0&&(E=0),h=Math.round(h),E=Math.round(E),{originWidth:d,maxLeft:h,maxRight:E}}function dF(n,t){const e=vC(n,t),{maxLeft:r}=e;t.style.marginLeft=`${xr(t,0-r)}px`,t.style.paddingLeft=`${xr(t,r)}px`}function hF(n,t){const e=vC(n,t);t.style.marginRight=`${xr(t,0-e.maxRight)}px`}function mF(n){if(n!==document.documentElement&&n!==document.body)return n.getBoundingClientRect();const t=0,e=0,r=document.documentElement.clientWidth,i=document.documentElement.clientHeight;return new DOMRect(t,e,r,i)}const zy=I("scroll-bar-handle"),gF=2;function Wa(n){const t=Gu(n);let e=t.querySelector(`.${h0.SCROLL_BAR}`);return e||(e=B("div",[h0.SCROLL_BAR],t)),p(zy,e instanceof HTMLDivElement,"invalid child for container tools"),e.firstElementChild||B("div",[],e),e}function m0(n,t){const e=jy(t),r=Wa(e),{scrollWidth:i,clientWidth:o}=Ga(e),{paddingLeft:s,paddingRight:l}=Wu(t),c=vC(n,e),{originWidth:d,maxRight:h}=c;hF(n,e),dF(n,e);const C=i-o;p(zy,r.firstElementChild instanceof HTMLDivElement,"invalid child for scroll bar"),r.style.width=`${xr(e,d+h-s-l)}px`,r.firstElementChild.style.width=`${xr(e,d+h+C-s-l)}px`}function pF(n,t){const e=Wr(n),{paddingLeft:r}=Wu(e);if(Rt(t,"fixed")){const o=Tn(n).getBoundingClientRect();t.style.left=`${xr(n,o.left+r)}px`}else t.style.left=`${xr(n,r)}px`}function qa(n,t){var U;const e=n.getParentScrollContainer(),r=mF(e),i=t.getBoundingClientRect(),o=Wa(t),s=o.getBoundingClientRect(),l=zu(n,Tn(t)),c=uF(n,t),d=Wr(t),{paddingTop:h,paddingBottom:C}=Wu(d),{scrollWidth:E,clientWidth:A}=Ga(t),v=document.documentElement.clientHeight-c,R=r.top+Ga(e).clientHeight-v,L=v+Math.min(0,R);if(E>A&&i.top+h<L-s.height&&i.bottom>L-s.height+C&&!((U=l==null?void 0:l.isSetScale)!=null&&U.call(l))){l!=null&&l.allowScrollBarFixed&&z(o,h0.FIXED);const F=R>0?c:0;o.style.bottom=`${Math.max(document.documentElement.clientHeight-r.bottom,0)+gF+F}px`}else ot(o,h0.FIXED),o.style.bottom=`${xr(t,C-s.height)}px`;pF(t,o)}class CF{constructor(t,e){m(this,"intersectionObserver");m(this,"handleIntersection",t=>{t.forEach(e=>{this.containers.get(Tn(e.target))?(this.handleIntersectionEntry(e),this.callback(e)):this.intersectionObserver.unobserve(e.target)})});m(this,"handleIntersectionEntry",t=>{const e=t.target;qa(this.scrollCore,e);const r=Wr(e);m0(this.scrollCore,r)});this.scrollCore=t,this.callback=e;const i={root:this.scrollCore.getParentScrollContainer(),rootMargin:"20px",threshold:0};this.intersectionObserver=new IntersectionObserver(this.handleIntersection,i)}get containers(){return this.scrollCore.containers}bind(t){this.unbind(t),this.intersectionObserver.observe(t)}unbind(t){this.intersectionObserver.unobserve(t)}destroy(){this.intersectionObserver.disconnect()}}const cl=I("container-scroll-shadow");function Gy(n,t,e){const r=n,i=t.getBoundingClientRect(),o=e.getBoundingClientRect(),{paddingTop:s,paddingBottom:l}=Wu(e);r.style.top=`${xr(t,o.top-i.top+s)}px`,r.style.bottom=`${xr(t,i.bottom-o.bottom+l)}px`}function Wy(n,t){const e=n;t<24?e.style.width=`${(t/3).toFixed(2)}px`:e.style.width=""}function EF(n){const t=Gu(n);p(cl,t,"no container tools");let e=t.querySelector(`.${Er.LEFT}`);if(!e){const l=Wr(n),c=[Er.COMMON,Er.LEFT];e=B("div",c,t),p(cl,e instanceof HTMLDivElement,"invalid child for container tools"),Gy(e,n,l)}p(cl,e instanceof HTMLElement,"invalid child for container tools");const i=Tn(n).getBoundingClientRect(),o=n.getBoundingClientRect();e.style.left=`${xr(n,o.left-i.left)}px`;const s=Ga(n).scrollLeft;p(cl,e instanceof HTMLDivElement,"invalid child for container tools"),Wy(e,s),z(e,Er.ACTIVE)}function xF(n){const t=Gu(n);let e=t.querySelector(`.${Er.RIGHT}`);if(!e){const h=Wr(n),C=[Er.COMMON,Er.RIGHT];e=B("div",C,t),p(cl,e instanceof HTMLDivElement,"no div, create shadow failed"),Gy(e,n,h)}p(cl,e instanceof HTMLElement,"");const i=Tn(n).getBoundingClientRect(),o=n.getBoundingClientRect();e.style.right=`${xr(n,i.right-o.right)}px`;const{scrollWidth:s,scrollLeft:l,clientWidth:c}=Ga(n),d=s-l-c;p(cl,e instanceof HTMLDivElement,"no shadow element"),Wy(e,d),z(e,Er.ACTIVE)}function AF(n){const e=Gu(n).querySelector(`.${Er.LEFT}`);e&&ot(e,Er.ACTIVE)}function bF(n){const e=Gu(n).querySelector(`.${Er.RIGHT}`);e&&ot(e,Er.ACTIVE)}function qu(n){const{scrollLeft:t,scrollWidth:e,clientWidth:r}=Ga(n),i=Wr(n),{paddingLeft:o,paddingRight:s}=Wu(i),l=fF(i,"offsetLeft");e-o<=r-s||e-o<=t+r-s?bF(n):xF(n),i&&t>=l+o?EF(n):AF(n)}class vF{constructor(t,e){m(this,"resizeObserver");m(this,"handleResizeEntry",t=>{const e=t.target,r=Wr(e);qu(e),m0(this.scrollCore,r),qa(this.scrollCore,e),this.callback(e)});m(this,"handleContentResize",t=>{t.forEach(e=>{this.containers.get(Tn(e.target))?this.handleResizeEntry(e):this.unbind(e.target)})});this.scrollCore=t,this.callback=e,this.resizeObserver=new _s(this.handleContentResize)}get containers(){return this.scrollCore.containers}bind(t){this.unbind(t),this.resizeObserver.observe(t)}unbind(t){this.resizeObserver.unobserve(t)}destroy(){this.resizeObserver.disconnect()}}const qy=I("container-scroll-observer");class BF{constructor(t,e){m(this,"handleContentScroll",t=>{const e=t.target;p(qy,e instanceof Element,"invalid target for scroll event");const r=Wa(e);r.removeEventListener("scroll",this.handleScroll);const i=!0;this.fixScrollXPos(e,e.scrollLeft,i),this.bind(r),qu(e),this.callback(e)});m(this,"handleScroll",t=>{const e=t.target;p(qy,e instanceof HTMLElement,"");const r=e.scrollLeft,i=!1,o=cF(e);this.unbindContentScroll(o),this.fixScrollXPos(o,r,i),this.bindContentScroll(o),qu(o),this.callback(o)});m(this,"handlePrevent",t=>{t.stopPropagation()});m(this,"bindContentScrollCore",t=>{this.unbindContentScroll(t),t.addEventListener("scroll",this.handleContentScroll)});m(this,"unbindContentScroll",t=>{t.removeEventListener("scroll",this.handleContentScroll)});m(this,"bindContentScroll",Me.default(this.bindContentScrollCore,300));m(this,"bind",Me.default(this.bindCore,200));this.scrollCore=t,this.callback=e}fixScrollXPos(t,e,r){const i=Wa(t);r||(t.scrollLeft=e),r&&i.scrollLeft!==e&&(i.scrollLeft=e)}bindCore(t){this.unbind(t),t.addEventListener("scroll",this.handleScroll),t.addEventListener("mousedown",this.handlePrevent)}unbind(t){t.removeEventListener("scroll",this.handleScroll),t.removeEventListener("mousedown",this.handlePrevent)}}class TF{constructor(t){m(this,"scrollContainers",new Set);m(this,"handleParentContainerScroll",()=>{this.scrollContainers.forEach(t=>{qa(this.scrollCore,t)})});m(this,"bindScrollContainer",t=>{const e=this.scrollContainers.size===0;this.scrollContainers.add(t),e&&this.eventTarget.addEventListener("scroll",this.handleParentContainerScroll)});m(this,"unbindScrollContainer",t=>{let e=!1;this.scrollContainers.has(t)&&(this.scrollContainers.delete(t),e=this.scrollContainers.size===0),e&&this.eventTarget.removeEventListener("scroll",this.handleParentContainerScroll)});this.scrollCore=t}get eventTarget(){const t=this.scrollCore.getParentScrollContainer();return t===document.documentElement?document:t}destroy(){this.eventTarget.removeEventListener("scroll",this.handleParentContainerScroll),this.scrollContainers.clear()}}const yF=I("scroll-wrap-resize-observer");class kF{constructor(t){m(this,"resizeObserver");m(this,"handleScrollWrapResize",t=>{t.forEach(e=>{this.containers.get(Tn(e.target))?this.handleScrollWrapResizeEntry(e):this.unbind(e.target)})});m(this,"handleScrollWrapResizeEntry",t=>{const e=t.target;p(yF,e instanceof HTMLElement,"invalid target for observer entry");const r=jy(e);m0(this.scrollCore,e),qu(r),qa(this.scrollCore,r)});this.scrollCore=t,this.resizeObserver=new _s(this.handleScrollWrapResize)}get containers(){return this.scrollCore.containers}bind(t){this.unbind(t),this.resizeObserver.observe(t)}unbind(t){this.resizeObserver.unobserve(t)}destroy(){this.resizeObserver.disconnect()}}class RF{constructor(t,e){m(this,"resizeObserver");m(this,"scrollContainersMap",new Map);m(this,"handleResizeEntry",t=>{t==null||t.forEach(e=>{const r=Wr(e);qu(e),m0(this.scrollCore,r),qa(this.scrollCore,e),this.callback(e)})});m(this,"handleResize",t=>{t.forEach(e=>{const r=this.scrollContainersMap.get(e.target);r!=null&&r.length&&this.handleResizeEntry(r)})});this.scrollCore=t,this.callback=e,this.resizeObserver=new _s(this.handleResize)}bind(t){var i,o;const e=Tn(t),r=(i=zu(this.scrollCore,e))==null?void 0:i.locatingContainer;this.scrollContainersMap.has(r)?(o=this.scrollContainersMap.get(r))==null||o.push(t):(this.scrollContainersMap.set(r,[t]),this.resizeObserver.observe(r))}unbind(t){var o,s;const e=Tn(t),r=(o=zu(this.scrollCore,e))==null?void 0:o.locatingContainer;if(!r)return;const i=this.scrollContainersMap.get(r);this.scrollContainersMap.set(r,(i==null?void 0:i.filter(l=>l!==t))||[]),(s=this.scrollContainersMap.get(r))!=null&&s.length||(this.resizeObserver.unobserve(r),this.scrollContainersMap.delete(r))}destroy(){this.scrollContainersMap.clear(),this.resizeObserver.disconnect()}}const xct="";class wF extends Re.TypedEmitter{constructor(e){super();m(this,"containerIntersectionObserver",null);m(this,"containerResizeObserver",null);m(this,"containerScrollObserver",null);m(this,"parentContainerScrollObserver",null);m(this,"scrollWrapResizeObserve",null);m(this,"locatingContainerResizeObserver",null);m(this,"isWindowEventBind",!1);m(this,"containers",new Map);m(this,"handleScrollContainerScroll",e=>{this.emit("scroll",this,e)});m(this,"handleResize",e=>{this.emit("resize",this,e)});m(this,"handleIntersection",e=>{const r=e.target,i=Wr(r);e.isIntersecting?(this.load(),this.bindCore(r,i)):this.unbindCore(r,i)});m(this,"handleWindowEffect",()=>{var e;(e=this.getScrollContainerInViewable())==null||e.forEach(r=>{qa(this,r)})});this.parentContainer=e}load(){this.containerResizeObserver||(this.containerResizeObserver=new vF(this,this.handleResize)),this.containerScrollObserver||(this.containerScrollObserver=new BF(this,this.handleScrollContainerScroll)),this.parentContainerScrollObserver||(this.parentContainerScrollObserver=new TF(this)),this.scrollWrapResizeObserve||(this.scrollWrapResizeObserve=new kF(this)),this.locatingContainerResizeObserver||(this.locatingContainerResizeObserver=new RF(this,this.handleResize)),this.isWindowEventBind||(window.addEventListener("resize",this.handleWindowEffect),this.getParentScrollContainer()!==document.documentElement&&window.addEventListener("scroll",this.handleWindowEffect))}getParentScrollContainer(){return this.parentContainer}getScrollContainerInViewable(){var e;return(e=this.parentContainerScrollObserver)==null?void 0:e.scrollContainers}unbindCore(e,r){var o,s,l,c,d,h;const i=Wa(e);(o=this.containerScrollObserver)==null||o.unbindContentScroll(e),(s=this.containerScrollObserver)==null||s.unbind(i),(l=this.scrollWrapResizeObserve)==null||l.unbind(r),(c=this.containerResizeObserver)==null||c.unbind(e),(d=this.parentContainerScrollObserver)==null||d.unbindScrollContainer(e),(h=this.locatingContainerResizeObserver)==null||h.unbind(e)}bindCore(e,r){var s,l,c,d,h,C;if(this.unbindCore(e,r),!e.closest("body"))return;const i=Wa(e);(s=this.containerScrollObserver)==null||s.bindContentScrollCore(e),(l=this.containerScrollObserver)==null||l.bindCore(i),(c=this.scrollWrapResizeObserve)==null||c.bind(r),(d=this.containerResizeObserver)==null||d.bind(e);const o=this.containers.get(Tn(e));o!=null&&o.allowScrollBarFixed&&((h=this.parentContainerScrollObserver)==null||h.bindScrollContainer(e)),(C=this.locatingContainerResizeObserver)==null||C.bind(e)}bind(e,r){this.containers.set(e,r);const i=e.firstElementChild;this.containerIntersectionObserver||(this.containerIntersectionObserver=new CF(this,this.handleIntersection)),this.containerIntersectionObserver.bind(i)}unbind(e){var o;const r=e.firstElementChild,i=Wr(r);this.unbindCore(r,i),this.containers.delete(e),(o=this.containerIntersectionObserver)==null||o.unbind(r),this.containers.size||this.destroy()}destroy(){var e,r,i,o,s;this.containers.forEach((l,c)=>{this.unbind(c)}),this.containers.clear(),(e=this.parentContainerScrollObserver)==null||e.destroy(),(r=this.containerIntersectionObserver)==null||r.destroy(),(i=this.containerResizeObserver)==null||i.destroy(),(o=this.scrollWrapResizeObserve)==null||o.destroy(),(s=this.locatingContainerResizeObserver)==null||s.destroy(),window.removeEventListener("resize",this.handleWindowEffect),window.removeEventListener("scroll",this.handleWindowEffect)}}const Xy=I("scroll-container"),g0=new Map;class SF extends Re.TypedEmitter{constructor(){super(...arguments);m(this,"scrollListener");m(this,"options");m(this,"scrollContainerElement");m(this,"init",e=>{this.options=e;const r=B("div",[rs.CONTAINER],e.parentElement);me.isMac&&z(r,rs.MAC);const i=B("div",[rs.SCROLL_CONTAINER],r),o=B("div",[rs.SCROLL_AREA],i);o.style.paddingLeft=e.paddingLeft?`${e.paddingLeft}px`:"",o.style.paddingTop=e.paddingTop?`${e.paddingTop}px`:"",o.style.paddingBottom=e.paddingBottom?`${e.paddingBottom}px`:"",o.style.paddingRight=e.paddingRight?`${e.paddingRight}px`:"",o.appendChild(e.childElement);const s=e.parentContainer;this.scrollListener=g0.get(s),this.scrollListener||(this.scrollListener=new wF(s),g0.set(s,this.scrollListener)),this.scrollListener.unbind(r),this.scrollListener.bind(r,e),this.scrollListener.on("scroll",this.handleContainerScroll),this.scrollListener.on("resize",this.handleResize),this.scrollContainerElement=i});m(this,"handleContainerScroll",(e,r)=>{r===this.scrollContainerElement&&this.emit("scroll",this)});m(this,"handleResize",(e,r)=>{r===this.scrollContainerElement&&this.emit("scroll",this)})}get rootElement(){return this.scrollContainerElement}get contentElement(){return p(Xy,this.scrollContainerElement,"scrollContainerElement cannot be undefined"),Wr(this.scrollContainerElement)}get scrollOptions(){return p(Xy,this.options,"options cannot be undefined"),{...this.options}}handleBaseListenerDestroy(e){e.destroy()}destroy(){var r;(r=this.scrollListener)==null||r.off("scroll",this.handleContainerScroll);const e=Tn(this.contentElement);e&&g0.forEach((i,o)=>{i.unbind(e),i.containers.size===0&&(this.handleBaseListenerDestroy(i),g0.delete(o))})}}function LF(){return new SF}const BC=I("column-width");function IF(n,t,e){PP(n,t).style.width=`${e}px`}function DF(n){const e=Array.from(n.querySelector("colgroup").children).map(c=>c.getBoundingClientRect().width);if(e[0]!==0)return e;const r=It.fromTable(n),i=Array(r.colCount).fill(-1),o=n.getBoundingClientRect().left;r.toRealCells(r.cells).forEach(c=>{const d=c.col+c.colSpan-1;i[d]===-1&&(i[d]=c.cell.getBoundingClientRect().right-o)}),BC.debug(`cellRightOffsets1: ${i.join()}`);for(let c=0;c<i.length;c++){const d=i[c];if(d===-1||c===0)continue;let h=c-1;for(;i[h]===-1&&(h--,h!==-1););const C=h===-1?0:i[h],A=(d-C)/(c-h);for(let v=h+1;v<c;v++)i[v]=C+A*(v-h)}BC.debug(`cellRightOffsets2: ${i.join()}`);const s=[];let l=0;for(let c=0;c<i.length;c++){const d=i[c];s.push(d-l),l=d}return BC.debug(`widths: ${s.join()}`),s}function Xu(n){return Array.from(n.querySelector("colgroup").children).map(r=>r.getBoundingClientRect().width||Number.parseInt(r.style.width,10))}const TC=200,_F=40,MF=I("table-resize-gripper"),Qy=7,yC=(Qy-1)/2,UF=3;function OF(n,t,e){const{rows:r}=n;for(let i=0;i<r.length;i++){const o=r[i],s=Array.from(o.cells);for(let l=0;l<s.length;l++){const c=s[l],d=c.getBoundingClientRect(),h=Math.round(d.right);if(Math.abs(t-h)<=yC&&d.top<=e&&e<=d.bottom)return c}}return null}function NF(n){return!!n.rootContainer.querySelector(".table-resize-gripper")}function kC(n,t){return vi(n,t).querySelector(".table-resize-gripper")}function Yy(n,t){const e=kC(n,t);p(MF,!e,"resize gripper has already exists");const r=vi(n,t),i=B("div",["table-resize-gripper","table-indicator"],r);return B("div",["table-resize-gripper-indicator"],i),i}function Jy(n,t,e){let r=kC(n,t);r||(r=Yy(n,t));const o=Ve(t).getBoundingClientRect(),s=e.getBoundingClientRect(),l=0,c=o.height,d=n.getCustom(bi(t)).contentElement.getBoundingClientRect(),h=s.right-d.left;r.style.left=`${h-yC-za-Hu}px`,r.style.top=`${l}px`,r.style.height=`${c}px`,r.style.width=`${Qy}px`}function RC(n){n.rootContainer.querySelectorAll(".table-resize-gripper").forEach(t=>{t.remove()})}function PF(n,t,e){const i={...n.getBlockData(t),colsWidth:e};n.updateBlockData(t,i)}function FF(n,t,e,r){const i=t,o=It.fromTable(e),s=o.getCellByCellElement(i),l=s.col+s.colSpan-1,c=Xu(e);let d=r;const h=(E,A)=>{const v=A+1,R=E.col+E.colSpan;return c.slice(v,R).reduce((M,U)=>M+U,0)},C=new Set;for(let E=0;E<o.rowCount;E++){const A=o.getCell({row:E,col:l});if(C.has(A.cell))continue;C.add(A.cell);const v=A.cell,R=v.getBoundingClientRect();let L=r-R.left+yC-UF;const M=Ku(v),U=n1(n,M)||_F*A.colSpan,F=h(A,l),G=U-F;L<G&&(L=G);const W=R.left+L;d=Math.max(d,W)}return d}const KF=I("table-resize-drag-drop");class VF{constructor(t,e,r,i){m(this,"cursor","col-resize");this.editor=t,this.elem=e,this.data=r,this.onEnd=i}onDragStart(t,e,r){}onDragging(t,e,r,i,o){const{table:s,block:l,draggingRefCell:c}=t.data,h=FF(this.editor,c,s,e.x-t.dragOffsetX)-s.getBoundingClientRect().left;p(KF,c,"no dragging cell");const E=It.fromTable(s).getCellByCellElement(c),A=E.col+E.colSpan-1,v=Xu(s),R=v.slice(0,A).reduce((M,U)=>M+U,0),L=h-R;if(IF(s,A,L),L){const M=parseFloat(s.style.width);s.style.width=`${M+(L-v[A])}px`}Jy(this.editor,l,c),this.editor.selection.caret.update()}onDragEnd(t,e,r,i,o){const s=Xu(t.data.table);PF(this.editor,t.data.block,s),RC(this.editor),this.onEnd&&(this.onEnd(e),this.onEnd=null)}}function $F(n,t){const e=document.elementFromPoint(t.x,t.y);if(!e)return null;const r=et(e);return!r||!n.contains(r)||!$e(r)?null:r}I("table-resize");class HF{constructor(t){m(this,"draggingRefCell",null);m(this,"handleMouseMove",(t,e)=>{if(t.readonly||t.selectionHandler.isSelecting()&&!this.draggingRefCell||this.draggingRefCell)return;const r=e.target;if(!(r instanceof Element)||r.closest(".table-indicator"))return;const o=e,s=$F(t,o);if(!s||!Ry(s)||!t.isBlockWritable(s)){RC(t);return}this.updateGripper(s,o.x,o.y)});this.editor=t,t.domEvents.addEventListener(document,"mousemove",this.handleMouseMove)}destroy(){this.editor.domEvents.removeEventListener(document,"mousemove",this.handleMouseMove)}updateGripper(t,e,r){const i=Ve(t),o=OF(i,e,r);if(o){if(!kC(this.editor,t)){if(NF(this.editor))return;const l=Yy(this.editor,t),c={block:t,table:i,draggingRefCell:o};_g(new VF(this.editor,l,c,d=>{this.updateGripper(t,d.x,d.y)}))}Jy(this.editor,t,o)}else RC(this.editor)}}function Zy(n){n.addCustom("table-mouse-event-handler",t=>new HF(t))}const tk=I("table-insert-column");function ek(n,t,e){n.undoManager.runInGroup(()=>{var E;const r=Ve(t),i=It.fromTable(r),o=i.colCount;p(tk,e>=0&&e<=o,`insert index ${e} is out of range [0, ${o}]`);const s=i.map(A=>A.containerId),l=new Set;n.doc.beginBatchUpdate();for(let A=0;A<s.length;A++){const v=s[A],R=v[e-1],L=v[e];if(e===0||e===v.length||R!==L){const M=no(n.doc);v.splice(e,0,M)}else v.splice(e,0,R),l.add(R)}n.doc.endBatchUpdate();const c=gt.default(n.getBlockData(t));l.forEach(A=>{const v=`${A}_colSpan`,R=c[v];p(tk,typeof R=="number"&&R>1,`no colSpan for containerId ${A}, ${R}`),c[v]=R+1});const d=((E=c.colsWidth)==null?void 0:E.concat())||new Array(c.cols).fill(0);d.splice(e,0,TC);const h=It.virtualCellContainersGridToChildren(s),C={...c,cols:c.cols+1,children:h,colsWidth:d};ll(C),n.updateBlockData(t,C)})}const p0=I("table-insert-row");function wC(n,t,e){n.undoManager.runInGroup(()=>{const r=Ve(t),i=It.fromTable(r),o=i.rowCount;p(p0,e>=0&&e<=o,`insert index ${e} is out of range [0, ${o}]`);const s=i.map(E=>E.containerId),l=new Set;n.doc.beginBatchUpdate();const c=[];for(let E=0;E<i.colCount;E++){const A=e>0&&s[e-1][E],v=e<i.rowCount&&s[e][E];if(p(p0,A||v,"no top and bottom cell"),e===0||e===i.rowCount||A!==v){const R=no(n.doc);c.push(R)}else p(p0,A,"no top cell"),c.push(A),l.add(A)}n.doc.endBatchUpdate(),s.splice(e,0,c);const d=gt.default(n.getBlockData(t));l.forEach(E=>{const A=`${E}_rowSpan`,v=d[A];p(p0,typeof v=="number"&&v>1,`no rowSpan for containerId ${E}, ${v}`),d[A]=v+1});const h=It.virtualCellContainersGridToChildren(s),C={...d,rows:d.rows+1,children:h};ll(C),n.updateBlockData(t,C)})}const SC=I("paste-table-in-table-block");function jF(n,t,e,r,i){let o=It.fromBlock(e);const s=t.blocks.root[0];p(SC,s,"no table data"),p(SC,s.type==="table",`table data type is not table, but ${s.type}`);const l=s,c=o.getCellByCellElement(r),d=l.cols,h=l.rows,C=c.col,E=c.row,A=C+d,v=E+h,R=[];for(let L=C;L<A&&L<o.colCount;L++)for(let M=E;M<v&&M<o.rowCount;M++){const U=o.getCell({col:L,row:M});U.virtual?U.virtual&&R.push({col:L,row:M}):(U.colSpan>1||U.rowSpan>1)&&R.push({col:L,row:M})}n.undoManager.runInGroup(()=>{if(n.doc.beginBatchUpdate(),R.forEach(F=>{const G=It.fromBlock(e).getCell(F);(G.colSpan>1||G.rowSpan>1)&&gC(n,e,F)}),A>o.colCount)for(let F=o.colCount;F<A;F++)ek(n,e,F);if(v>o.rowCount)for(let F=o.rowCount;F<v;F++)wC(n,e,F);o=It.fromBlock(e);const L=new a0(l);let M;for(let F=0;F<L.colCount;F++)for(let G=0;G<L.rowCount;G++){const W=L.getCell({col:F,row:G});if(!W.virtual){const it=np(n.editorBlocks,t,W.containerId,i),at=C+F,xt=E+G,Mt={col:at,row:xt},Bt=o.getCellContainer(Mt);n5(n,Bt,it,i),M=Bt}}n.doc.endBatchUpdate(),p(SC,M,"no last container");const U=Ze(M);n.selection.selectBlock(U,dt(n,U))})}const LC=I("paste-in-table-block");class zF{constructor(t){m(this,"pasteData");this.editor=t,setTimeout(()=>{t.input.addHandler(this)})}destroy(){this.pasteData=void 0}async handleBeforePaste(t,e,r,i){return this.pasteData={doc:r,files:i,event:e},!1}async handleBeforePasteDoc(t,e){var E,A,v,R;if(!t.selection.range.isSimple())return this.pasteData=void 0,!1;if(t.selection.range.start.offset!==0)return this.pasteData=void 0,!1;const i=t.selection.startBlock,o=rt(i);if(Xt(o))return this.pasteData=void 0,!1;if(!uu(t,o))return this.pasteData=void 0,!1;const s=et(o);if(p(LC,s,"no parent block"),!$e(s))return this.pasteData=void 0,!1;if(e.blocks.root.length!==1)return this.pasteData=void 0,!1;if(e.blocks.root[0].type!=="table")return this.pasteData=void 0,!1;LC.debug("paste child table in table");const d=It.fromBlock(s).getCellByContainerId(ft(o)).cell;Ap(t,e);const h={blockIdMap:new Map,containerIdMap:new Map,boxIdMap:new Map};jF(t,e,s,d,h),p(LC,this.pasteData,"invalid paste data");const C=[];t.input.forEach(L=>{C.push(L)});for(let L=0;L<C.length&&!await((A=(E=C[L]).handleAfterPasteDoc)==null?void 0:A.call(E,t,e,h));L++);for(let L=0;L<C.length&&!await((R=(v=C[L]).handleAfterPaste)==null?void 0:R.call(v,t,this.pasteData.event,this.pasteData.doc));L++);return this.pasteData=void 0,!0}}function nk(n){n.addCustom("table-block-paste-event",t=>new zF(t))}const IC=I("table-select-columns");function GF(n,t,e,r,i){p(IC,$e(t),"is not a table block");const o=It.fromBlock(t);p(IC,e>=0&&e<o.colCount,"invalid from"),p(IC,r>0&&e+r<=o.colCount,"invalid count");const s=o.getCell({row:0,col:e}),l=o.getCell({row:o.rowCount-1,col:e+r-1}),c=xe(t,s.containerId,{colIndex:e,rowIndex:0}),d=xe(t,l.containerId,{colIndex:e+r-1,rowIndex:o.rowCount-1});i!=null&&i.reverse?n.selection.setSelection(d,c):n.selection.setSelection(c,d)}const DC=I("table-select-columns");function WF(n,t,e,r,i){p(DC,$e(t),"is not a table block");const o=It.fromBlock(t);p(DC,e>=0&&e<o.rowCount,"invalid from"),p(DC,r>0&&e+r<=o.rowCount,"invalid count");const s=o.getCell({row:e,col:0}),l=o.getCell({row:e+r-1,col:o.colCount-1}),c=xe(t,s.containerId,{rowIndex:e,colIndex:0}),d=xe(t,l.containerId,{rowIndex:e+r-1,colIndex:o.colCount-1});i!=null&&i.reverse?n.selection.setSelection(d,c):n.selection.setSelection(c,d)}const Act="",rk=I("get-toolbar-reference-client");function ik(n,t){const e=n.selection.range;if(!e.isSimple()){p(rk,e.start.blockId===e.end.blockId,"invalid selection range");const s=n.getBlockById(e.start.blockId);p(rk,_t(n,s),"not a complex block");const l=Yt(n,s);if(l.getTextToolbarReferenceClient){const c=l.getTextToolbarReferenceClient(n,s);if(c)return c}}const r=e.isReverse()?t.start:t.end,i=qe(n,{anchor:r,focus:r}),o=qi(n,t.block,i);if(o.length!==0)return o[0]}function qF(n){var t,e;if(n.children){let r=!1;const i=[];for(const o of n.children){if((t=o.states)!=null&&t.includes("checked")){r=!0;break}(e=n.defaultCheckedChildren)!=null&&e.includes(o.id)&&i.push(o)}if(!r&&(i==null?void 0:i.length))for(const o of i)Array.isArray(o.states)?o.states.push("checked"):o.states=["checked"]}}function C0(n){const t=(i,o)=>{const s=i.findIndex(c=>c.id===o.id);if(s===-1){i.push(o);return}const l=i[s];if(l.value!==o.value&&delete l.value,!!l.states){if(!o.states){l.states=[];return}l.states=Tg.default(l.states,o.states)}},e=[],r=new Map;return n.forEach(i=>{var o,s;(o=i.children)!=null&&o.length&&(r.has(i.id)?(s=r.get(i.id))==null||s.push(...i.children):r.set(i.id,[...i.children])),t(e,i)}),r.forEach((i,o)=>{const s=e.find(l=>l.id===o);s&&(s.children=C0(i),qF(s))}),e}function E0(n){return n.findCustom("toolbar-handler")}const bct="";class XF{constructor(){m(this,"linkPopup",null);m(this,"form",{});m(this,"onFinished",null);m(this,"onClose",null);m(this,"handleOk",async()=>{var t;try{await this.checkValue();const{linkText:e,linkUrl:r}=this.form,i=this.formatUrl(r.getInputValue());(t=this.onFinished)==null||t.call(this,e.getInputValue()||i,i),this._destroy()}catch{}});m(this,"handleClose",()=>{var t;(t=this.onClose)==null||t.call(this),this._destroy()});m(this,"onShow",()=>{setTimeout(()=>{var t;(t=this.form.linkText)==null||t.getField().focus()},400)});m(this,"onChange",()=>{var e;const t=(e=this.linkPopup)==null?void 0:e.content.querySelector('[data-button-id="submit-button"]');t.disabled=!1});m(this,"handleTextKeyboard",t=>{var e;if(!t.isComposing){if(t.key==="Enter"){(e=this.form.linkUrl)==null||e.getField().focus(),t.stopPropagation();return}t.key==="Escape"&&this.handleClose()}});m(this,"handleUrlKeyboard",t=>{if(!t.isComposing){if(t.key==="Enter"){this.handleOk(),t.preventDefault();return}t.key==="Escape"&&this.handleClose()}})}async checkValue(){const{linkUrl:t}=this.form;if(!t.getInputValue())throw t.setFieldError(D.t("link.urlPlaceholder")),new Error(D.t("link.urlPlaceholder"))}formatUrl(t){if(!t)return"";try{new URL(t)}catch{return`${window.location.protocol}//${t}`}return t}editLink(t){var h,C;const{target:e,linkText:r,linkUrl:i,onFinished:o,onClose:s,placement:l="bottom-start"}=t;this.linkPopup=new Va(this.createPopupContent(r,i)),this.linkPopup.addListener("show",this.onShow),this.linkPopup.manualShow(e,{theme:"light",placement:l}),this.onFinished=o,s&&(this.onClose=s);const c=(h=this.linkPopup)==null?void 0:h.content.querySelector('[data-button-id="submit-button"]'),d=(C=this.linkPopup)==null?void 0:C.content.querySelector('[data-button-id="cancel-button"]');c==null||c.addEventListener("click",this.handleOk),d==null||d.addEventListener("click",this.handleClose)}createPopupContent(t,e){const r=B("div",["link-popup-content"],null);this.form.linkText=l0(r,{label:D.t("link.textLabel"),required:!1,placeholder:D.t("link.textPlaceholder"),defaultValue:t,onChange:this.onChange,onKeyDown:this.handleTextKeyboard}),this.form.linkUrl=l0(r,{className:"link-popup-gap",label:D.t("link.urlLabel"),required:!0,placeholder:D.t("link.urlPlaceholder"),defaultValue:e,onChange:this.onChange,onKeyDown:this.handleUrlKeyboard});const i=B("div",["link-popup-footer"],r),o=Cr("cancel-button",D.t("link.cancelText"));i.appendChild(o);const s=Cr("submit-button",D.t("link.submitText"),void 0,["disabled","primary"]);return i.appendChild(s),r}_destroy(){var r,i,o,s;const t=(r=this.linkPopup)==null?void 0:r.content.querySelector('[data-button-id="submit-button"]'),e=(i=this.linkPopup)==null?void 0:i.content.querySelector('[data-button-id="cancel-button"]');t==null||t.removeEventListener("click",this.handleOk),e==null||e.removeEventListener("click",this.handleClose),this.onFinished=null,this.onClose=null,this.form={},(o=this.linkPopup)==null||o.removeAllListeners(),(s=this.linkPopup)==null||s.destroy()}destroy(){this._destroy()}}function Qu(n,t){n.addCustom("link-editor",()=>new XF).editLink(t)}const QF=I("link-popup");function YF(n){return Rt(n,"link")}function Yu(n){var t,e;return(e=(t=n.getAttribute("link"))!=null?t:n.textContent)!=null?e:""}function JF(n,t,e){var i,o,s,l;if(n.isBlockWritable(t)&&e&&hr(e)){const c=e,d=(o=(i=n.editorBoxes.getBoxClass(su(c))).getBoxProperties)==null?void 0:o.call(i,n,c);if(d!=null&&d.boxCommands){const h=(l=(s=d.boxCommands["hovering-toolbar"])==null?void 0:s.commands)!=null?l:[];return{element:e,commands:h}}return{element:null,commands:[]}}if(n.isWritable()&&e&&nt(n,t)&&YF(e)){const c=B("a",["link-href-button"],null,Yu(e));c.href=Yu(e),c.target="_blank",c.rel="noopener noreferrer";const d=[{id:"link-text",name:Yu(e),disableTooltip:!0,element:c},{id:"edit-link",name:D.t("link.edit"),icon:i0},{id:"remove-link",name:D.t("link.remove"),icon:wT}];return{element:e,commands:d}}return $v(n,t,"hovering-toolbar")}function ok(n,t,e){var l;const r=zo(t,e),i=n.getBlockText(t),o={start:0,end:0};let s=(l=e.textContent)!=null?l:"";for(let c=0;c<i.length;c++){const d=i[c];if(o.end+d.insert.length>=r.end){o.end+=d.insert.length,s=d.insert;break}o.start<r.start&&(o.start+=d.insert.length,o.end=o.start)}return[o,s]}function ZF(n,t,e){const[r,i]=ok(n,t,e);n.selection.selectBlock(t,r.start,r.end);const o=Yu(e),s=(h,C)=>{try{const E=n.getBlockText(t),A=U1(E,r.start,r.end-r.start),v=to(A,r.start,h,{link:C});n.setBlockText(t,v),n.selection.selectBlock(t,r.start+h.length),n.focus()}catch(E){QF.error(E)}},l=()=>{n.selection.selectBlock(t,r.end),n.focus()},c=qi(n,t,n.selection.range)[0];if(!c)return;const d=Yi(n,t,"link-button-anchor",c);Qu(n,{target:d,linkText:i,linkUrl:o,onFinished:s,onClose:l})}function tK(n,t,e){const[r]=ok(n,t,e),i=n.getBlockText(t),o=Yu(e),s=xa(r.start,r.end-r.start,i,"link",o);n.setBlockText(t,s),n.selection.selectBlock(t,r.end)}function eK(n,t,e,r){var s,l,c;if(e){if(n.isBlockWritable(t)&&hr(e)){const h=e,C=(l=(s=n.editorBoxes.getBoxClass(su(h))).getBoxProperties)==null?void 0:l.call(s,n,h);if(C!=null&&C.boxCommands){C.boxCommands["hovering-toolbar"].executeCommand(n,t,h,r);return}return}const d=E0(n);d==null||d.disableTextToolbar(),d==null||d.hide(),setTimeout(()=>{d==null||d.enableTextToolbar()},400),r.id==="edit-link"?ZF(n,t,e):r.id==="remove-link"&&tK(n,t,e);return}const i=Vv(n,t);if(!i)return;const o=(c=i.blockCommands)==null?void 0:c["hovering-toolbar"];!o||o.executeCommand(n,t,r)}function x0(){let n=8;for(;n>0&&!document.querySelector(`div[data-style-heading='${n}']`);)n--;return n}const nK=[qh,Xh,Qh,Yh,Jh,Zh,t0,e0];class rK{constructor(t){m(this,"id","BlockTurnIntoCommandProvider");this.editor=t}getHeadingIndex(){let t=x0();return t<=4?t=5:t<8&&(t+=1),t}getAvailableCommands(t,e,r){if(nt(t,e)){const i=st(e),o=St(e),s=Ir(t,e),c=t.getBlockData(e).heading,d=[];for(let C=0;C<this.getHeadingIndex();C++)d.push({id:`heading-${C+1}`,name:D.t("commands.heading",{name:`${C+1}`}),icon:nK[C],states:c===C+1?["checked"]:[],value:`${C+1}`});const h=C=>{var A;const E=B("span",["toolbar-item-name-container"],null);for(const v of C.children)if((A=v.states)!=null&&A.includes("checked"))return E.innerHTML=v.icon||Fa,E;return E.innerHTML=Fa,E};return[{id:"turn-into",name:D.t("commands.headingGroup"),blockId:i,blockType:o,blockKind:s,element:h,groupIndex:200,dropdown:!0,manualShowChildren:!0,childrenPlacement:"bottom-start",defaultCheckedChildren:["text"],children:[{id:"text",name:D.t("commands.text"),icon:Fa,states:c?[]:["checked"]},...d],childrenType:"menu"}]}return[]}applyHeadingStyle(t,e,r){t.updateBlockData(e,{heading:r})}executeCommand(t,e,r,i){if(nt(t,e)&&(i.id.startsWith("heading-")||i.id==="text")){const o=i.value?Number(i.value):null;return this.applyHeadingStyle(t,e,o),!0}return!1}}const iK=8,Se=I("list-block"),A0=I("list-block");function Kt(n){return St(n)==="list"}function Ue(n){p(A0,Kt(n),"not a list block")}function tr(n){Ue(n);const t=n.getAttribute("data-list-type");return p(A0,t,"no list type"),t}function b0(n){return Kt(n)&&tr(n)==="text-only"}function er(n){var t,e;return Ue(n),(e=Number.parseInt((t=n.getAttribute("data-list-start"))!=null?t:"1",10))!=null?e:1}function on(n){var t,e;return Ue(n),(e=Number.parseInt((t=n.getAttribute("data-list-level"))!=null?t:"1",10))!=null?e:1}function Xa(n){Ue(n);const t=n.getAttribute("data-list-group-id");return p(A0,t,"no group id"),t}function is(n){var o,s,l,c,d;Ue(n);const t=(o=n.getAttribute("data-list-type"))!=null?o:"ordered",e=(l=Number.parseInt((s=n.getAttribute("data-list-start"))!=null?s:"1",10))!=null?l:1,r=(d=Number.parseInt((c=n.getAttribute("data-list-level"))!=null?c:"1",10))!=null?d:1,i=n.getAttribute("data-list-group-id");return p(A0,i,"no group id"),{type:t,start:e,level:r,groupId:i}}function _C(n){switch(n){case"ordered":return{ordered:!0,checkbox:null,textOnly:null};case"unordered":return{ordered:!1,checkbox:null,textOnly:null};case"checked":return{checkbox:"checked",ordered:!1,textOnly:null};case"unchecked":return{checkbox:"unchecked",ordered:!1,textOnly:null};case"text-only":return{checkbox:null,ordered:!1,textOnly:!0};default:return{checkbox:null,ordered:!0,textOnly:!1}}}function oK(n){const t={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1};let e="",r=n;return Object.entries(t).forEach(([i,o])=>{for(;r>=o;)e+=i,r-=o}),e.toLowerCase()}const sK="abcdefghijklmnopqrstuvwxyz";function sk(n){if(n<=0)return`${n}`;const t=(n-1)%26,e=Math.floor((n-1)/26),r=sK[t];return e?sk(e)+r:r}function lK(n){return`${n}`}const lk=[lK,sk,oK];function aK(n,t){const e=lk[(n-1)%lk.length];return e(t)}function cK(n){return["\u2022","\u25E6","\u25AA"][(n-1)%3]}function os(n,t){Ue(n);const{level:e,groupId:r,type:i}=is(n);let o=ge(n);for(;o;){if(!Kt(o))return null;const{level:s,groupId:l,type:c}=is(o);if(s<e)return null;if(e===s&&((t==null?void 0:t.ignoreGroupId)||r===l)&&(c==="text-only"||i==="text-only"||i===c))return o;o=ge(o)}return null}function ak(n){return os(n,{ignoreGroupId:!0})}function ul(n){Ue(n);const{level:t,groupId:e,type:r}=is(n);let i=qt(n);for(;i;){if(Kt(i)){const{level:o,groupId:s,type:l}=is(i);if(t===o&&e===s&&(l==="text-only"||r==="text-only"||r===l))return i;if(o<t)return null}i=qt(i)}return null}function ck(n){Ue(n);const t=[];let e=os(n);for(;e;)t.unshift(e),e=os(e);return t}function Qa(n){Ue(n);const t=[];let e=ul(n);for(;e;)t.push(e),e=ul(e);return t}function Ju(n){Ue(n);let t=os(n);for(;t;){const e=os(t);if(!e)return t;t=e}return n}function uK(n){Ue(n);let t=ul(n);for(;t;){const e=ul(t);if(!e)return t;t=e}return null}function uk(n,t){const e=ck(n),r=Qa(n);return t.withSelf?[...e,n,...r]:[...e,...r]}function v0(n){Ue(n);let t=n;const e=ck(n);e.length>0&&(t=e[0]);const r=ge(t);return!r||!Kt(r)?null:on(r)<on(t)?r:null}function fK(n,t){Ue(n);let e=n;for(;e;){const r=on(e);if(r===t)return e;if(r>t)e=v0(e);else if(r<t)return null}return null}function dK(n){let t=Ju(n);for(;;){const e=v0(t);if(!e)return t;t=Ju(e)}}class hK{constructor(){m(this,"nodeMap",new Map);m(this,"rootNodes",[])}addNode(t,e){const r={block:e,children:[]};if(this.nodeMap.set(e,r),t){const i=this.nodeMap.get(t);p(Se,i,"no parent node"),i.children.push(r)}else this.rootNodes.push(r)}}function fk(n,t){const e=dK(t),r=new hK;r.addNode(null,e);let i=qt(e);for(;i&&Kt(i);){if(b0(i)){r.addNode(null,i),i=qt(i);continue}if(on(i)===0&&tr(i)!==tr(e))break;const s=v0(i);r.addNode(s,i),i=qt(i)}return r.rootNodes}function mK(n){const t=document.fullscreenEnabled||document.mozFullScreenEnabled||document.documentElement.webkitRequestFullScreen,e=r=>{if(r.requestFullscreen)return r.requestFullscreen();if(r.mozRequestFullScreen)return r.mozRequestFullScreen();if(r.webkitRequestFullScreen){try{document.fullscreenElement=n}catch{}return r.webkitRequestFullScreen()}return Promise.resolve(0)};return t?e(n):Promise.resolve(0)}function dk(){const e=(document.exitFullscreen||document.webkitExitFullscreen).bind(document)();try{document.fullscreenElement=null}catch{}return e}function MC(n){return Rt(n,"editor-in-mindmap-first")}function UC(n){if(p(Se,Kt(n),"not a list block"),Rt(n,"editor-in-mindmap-first")||!ou(n))return!0;const t=n.classList,e="editor-mindmap-root-";return!!Array.from(t).find(i=>{if(i.startsWith(e))return i})}function gK(n,t,e){const r=rt(n);if(t){const s=rt(t);p(Se,r===s,"invalid block container")}const i=bt(n);if(t){const s=bt(t);p(Se,i<=s,"invalid block index")}if(z(n,...e),!t||t===n)return;let o=qt(n);for(;o!==t;)p(Se,o,"no next button"),z(o,...e),o=qt(o);o&&z(o,...e)}function pK(n){const t=`editor-mindmap-root-${n.id}`,r=rt(n).querySelectorAll(`.${t}`);return r[r.length-1]}async function CK(n,t,e){const r=re(t),i=r.querySelector('[data-button-id="mindmap-fullscreen"]');p(Se,i,"no full screen button");const o=()=>{setTimeout(()=>{e.toMindmap(n,t,{},{reset:!0,mindmapTools:e})},300)},s=()=>{ot(r,"fullscreen"),i.innerHTML=iC,i.setAttribute(`data-editor-tooltip-${n.clientId}-dynamic`,D.t("mindmap.fullScreen")),UC(t)&&setTimeout(()=>{o()},300)};if(document.fullscreenElement===r){try{await dk()}catch(l){Se.error(l)}s()}else{try{z(r,"fullscreen"),await mK(r),o()}catch(l){Se.error(l)}i.innerHTML=uy,i.setAttribute(`data-editor-tooltip-${n.clientId}-dynamic`,D.t("mindmap.exitFullscreen"))}r.onfullscreenchange=()=>{document.fullscreenElement||s()}}function OC(n,t,e,r,i){if(t.querySelector(`[data-button-id="${e}"]`))return null;const s=Cr(e,r,i,[]);return s.setAttribute(`data-editor-tooltip-${n.clientId}-dynamic`,r),z(s,"mindmap-button"),t.appendChild(s),s}function NC(n,t){return n.querySelector(`[data-button-id="${t}"]`)}function EK(n){return NC(n,"mindmap-fullscreen")}function xK(n){return NC(n,"mindmap-fit")}function AK(n){return NC(n,"mindmap-close")}function bK(n,t,e,r){const i=OC(n,t,"mindmap-close",D.t("mindmap.close"),Gh);!i||n.domEvents.addEventListener(i,"click",()=>{r.closeMindmap(n,e)})}function vK(n,t,e,r){const i=OC(n,t,"mindmap-fit",D.t("mindmap.autoFit"),cy);!i||n.domEvents.addEventListener(i,"click",()=>{r.fitMindmap(n,e)})}function BK(n,t,e,r){if(navigator.userAgent.includes("Mobile")&&!navigator.userAgent.includes("iPad"))return;const o=OC(n,t,"mindmap-fullscreen",D.t("mindmap.fullScreen"),iC);!o||n.domEvents.addEventListener(o,"click",()=>{CK(n,e,r)})}function TK(n,t){const e=zd(t);if(!e)return;const r=xK(e);r&&(r.remove(),n.domEvents.removeAllListeners(r));const i=AK(e);i&&(i.remove(),n.domEvents.removeAllListeners(i));const o=EK(e);o&&(o.remove(),n.domEvents.removeAllListeners(o))}const Ya=new Map;function PC(n,t,e){const r=(s,l)=>{s.forEach(c=>{l?z(c.block,"to-mindmap-highlight"):ot(c.block,"to-mindmap-highlight"),r(c.children,l)})},i=fk(n,t);if(i.length===0)return;const o=i[0].block;if(e){const s=Ya.get(o);s&&(s.forEach(l=>l.cancel()),Ya.delete(o)),r(i,!0)}else{const s=setTimeout(()=>{r(i,!1),Ya.delete(o)},300),l=()=>{clearTimeout(s),Ya.delete(o)},c=Ya.get(o);c?c.push({cancel:l}):Ya.set(o,[{cancel:l}])}}const{Markmap:yK}=Z6;function kK(n,t){Ue(t);const e=fk(n,t),r=e[0].block,i=d=>({t:"text",v:Ot(d.block).textContent,d:1,c:d.children.length>0?d.children.map(C=>i(C)):void 0});let o=null;e.length>1?o={t:"root",v:"root",d:0,c:e.length>0?e.map(d=>i(d)):void 0}:o=i(e[0]);const l=d=>{if(d.length===0)return null;const h=d[d.length-1];return h.children&&h.children.length>0?l(h.children):h},c=l(e);return{root:o,block:r,nodes:e,last:c}}function B0(n,t,e,r){const{root:i,block:o,last:s}=kK(n,t);r.selectBlock&&n.selection.selectBlock(o,0,0),PC(n,o,!1),r.saveData&&n.updateBlockData(o,{viewAsMindmap:!0});const l=re(o);let c=l.querySelector(".editor-mindmap-svg");if(r.reset&&(c&&c.remove(),c=null),c)c.innerHTML="";else{const M="http://www.w3.org/2000/svg",U=l.getBoundingClientRect(),F=document.fullscreenElement===l,G=F?`${U.width}`:`${t.getBoundingClientRect().width}`,W=F?`${U.height}`:"600",it=document.createElementNS(M,"svg");it.setAttributeNS(null,"viewBox",`0 0 ${G} ${W}`),it.setAttributeNS(null,"width","100%"),it.setAttributeNS(null,"height",W),it.style.display="block",it.style.width="100%",it.style.height=`${W}px`,it.classList.add("editor-mindmap-svg"),l.appendChild(it),c=it}const d=o,C=`editor-mindmap-root-${st(o)}`;z(d,"editor-in-mindmap-first",C,"readonly"),d.contentEditable="false";const E=qt(o);E&&bt(E)<=bt(s.block)&&gK(E,s.block,["block-hidden",C]);const A=(M,U)=>{if(U.length>0){const F=U[0].parentElement;F&&(F.style.width="100vw",F.style.maxWidth="200px")}U.forEach(F=>{z(F,"editor-mindmap-node")})},v=new yK(c,{...e,autoFit:!0});v.viewHooks.transformHtml.tap(A),v.setData(i),v.fit();const R=re(o);let L=R.querySelector(".mindmap-toolbar");L||(L=B("div",["mindmap-toolbar"],R)),vK(n,L,d,r.mindmapTools),BK(n,L,d,r.mindmapTools),bK(n,L,d,r.mindmapTools),n.domEvents.addEventListener(c,"click",()=>{n.selection.selectBlock(o,0),n.input.focus()}),d.mindMap=v}function RK(n){const t=B("div",["list-to-mindmap-wrap"],null),e=Cr("list-to-mindmap",D.t("mindmap.viewAsMindMap"),ay,[],n.clientId);return t.appendChild(e),t}async function hk(n,t){const e=`editor-mindmap-root-${t.id}`,r=rt(t);ue(r).forEach(l=>{Rt(l,e)&&ot(l,e,"editor-in-mindmap-first","block-hidden")});const o=re(t);document.fullscreenElement===o&&await dk();const s=o.querySelector(".editor-mindmap-svg");!s||(p(Se,s,"no mindmap svg"),s.remove(),n.domEvents.removeAllListeners(s),TK(n,t))}function wK(n){const t=n.classList,e="editor-mindmap-root-";return Array.from(t).find(i=>{if(i.startsWith(e))return i})}async function mk(n,t){!wK(t)||(n.updateBlockData(t,{viewAsMindmap:null}),hk(n,t),n.selection.selectBlock(t,0))}function SK(n,t){const e=t.mindMap;e&&e.fit()}const T0={toMindmap:B0,closeMindmap:mk,fitMindmap:SK},vct="";class y0{constructor(t){m(this,"toMindmapButton");m(this,"currentBlock",null);m(this,"handleHoveringBlock",t=>{t&&Kt(t)&&tr(t)!=="unchecked"&&tr(t)!=="checked"&&this.editor.isWritable()?re(t).appendChild(this.toMindmapButton):this.toMindmapButton.remove()});m(this,"handleMouseEnter",()=>{const t=et(this.toMindmapButton);p(Se,t&&Kt(t),"no parent list"),PC(this.editor,t,!0),this.currentBlock=t});m(this,"handleMouseLeave",()=>{this.currentBlock&&(PC(this.editor,this.currentBlock,!1),this.currentBlock=null)});m(this,"handleClick",()=>{const t=et(this.toMindmapButton);p(Se,t&&Kt(t),"no parent list"),B0(this.editor,t,{},{saveData:!0,selectBlock:!0,mindmapTools:T0})});this.editor=t,Be.get(this.editor).addListener("change",this.handleHoveringBlock),this.toMindmapButton=RK(t),t.domEvents.addEventListener(this.toMindmapButton,"mouseenter",this.handleMouseEnter),t.domEvents.addEventListener(this.toMindmapButton,"mouseleave",this.handleMouseLeave),t.domEvents.addEventListener(this.toMindmapButton,"click",this.handleClick)}static get(t){return t.findCustomByType(y0)}destroy(){Be.get(this.editor).removeListener("change",this.handleHoveringBlock)}hide(){this.currentBlock&&(this.currentBlock=null),this.toMindmapButton.remove()}}function LK(n,t,e){var r;t==="beginDrag"&&((r=y0.get(n))==null||r.hide())}function Ja(n,t,e,r){var o;const i=(o=r==null?void 0:r.groupId)!=null?o:Z();t.forEach(s=>{const l=n.getBlockData(s);if(l.start!==e||(r==null?void 0:r.resetGroupId)){const c={...l,start:e};r!=null&&r.resetGroupId&&(c.groupId=i),n.updateBlockData(s,c)}l.textOnly||(e+=1)})}function FC(n,t,e,r){const i=uk(t,{withSelf:!0});i.length!==0&&Ja(n,i,e,r)}class k0{constructor(t,e){m(this,"listStart",0);m(this,"listBrother",null);if(this.editor=t,b0(e))return;const r=Ju(e),i=er(r);this.listStart=i,r===e?this.listBrother=ul(r):this.listBrother=r}fix(){!this.listBrother||FC(this.editor,this.listBrother,this.listStart)}}class fl{constructor(t,e,r){m(this,"listStart");m(this,"listBrother",null);this.editor=t,this.options=r;const i=Ju(e),o=er(i);this.listStart=o,this.listBrother=i,r!=null&&r.resetStart&&(this.listStart=1)}fix(){!this.listBrother||FC(this.editor,this.listBrother,this.listStart,this.options)}}class gk{constructor(t,e,r){m(this,"listStart");m(this,"listNextBrothers",[]);this.editor=t,this.listNextBrothers=Qa(e);const{start:i,resetStart:o}=r||{};this.listStart=o?1:i!=null?i:1}fix(){!this.listNextBrothers.length||Ja(this.editor,this.listNextBrothers,this.listStart)}}function IK(n,t,e){n.getBlockData(t).quoted&&(e.quoted=!0)}function KC(n,t,e,r){if(Se.debug("drag a block on a list block"),!nt(n,t))return!1;p(Se,Kt(e),"target is not a list block");const{type:i,start:o,level:s,groupId:l}=is(e),c=r==="after"?o+1:o,d=n.getBlockData(t),h={id:Z(),type:"list",groupId:l,level:s,start:c,text:d.text,..._C(i)};IK(n,e,h);let C=bt(e);const E=rt(e);r==="after"&&(C+=1);let A=null;Kt(t)&&(A=new k0(n,t));const v=n.insertBlock(ft(E),C,h,mh(h.id,0));return n.deleteBlock(t),new fl(n,v).fix(),A==null||A.fix(),!0}function DK(n,t,e,r){if(Se.debug("drag a list between text blocks"),r==="after"){const d=qt(e);if(d&&Kt(d))return KC(n,t,d,"before")}if(r==="before"){const d=ge(e);if(d&&Kt(d))return KC(n,t,d,"after")}const o={...n.getBlockData(t),groupId:Z(),start:1,level:1};let s=bt(e);const l=rt(e);r==="after"&&(s+=1),n.insertBlock(ft(l),s,o,mh(o.id,0));const c=new k0(n,t);return n.deleteBlock(t),c.fix(),!0}function _K(n,t,e,r,i){if(Fd(e))return!1;const{blockId:o}=e,s=n.getBlockById(o);p(Se,s,"no dragged block");const{isSourceBlock:l,targetBlock:c}=i;return!l&&c?(p(Se,t===c,"block !== target block"),p(Se,Kt(c),"target is not a list block"),KC(n,s,c,r)):DK(n,s,c,r)}function pk(n,t){if(!n.isWritable())return!1;const e=n.selection.range,i=n.editorCommandProviders.getCommands(e).find(o=>o.id===t);return i?(n.editorCommandProviders.executeCommand(e,i,{}),!0):!1}const MK={"Shift+CtrlOrCmd+L":n=>pk(n,"ordered-list"),"Shift+CtrlOrCmd+U":n=>pk(n,"unordered-list")};function R0(n){const t=n.getAttribute("block-padding-level");return t?Number(t):null}function UK(n,t){let e;const r=R0(t);if(!r)e=1;else{if(r>=12)return e=12,!1;e=r+1}return n.updateBlockData(t,{...n.getBlockData(t),padding:e}),!0}function Ck(n,t){const e=R0(t);if(!e)return!1;const r=n.getBlockData(t);return e>1?(n.updateBlockData(t,{...r,padding:e-1}),!0):(n.updateBlockData(t,{...r,padding:null}),!0)}function VC(n){return n.readonly||!n.isWritable()}function OK(n){return n.selection.range.getSelectedBlocks().forEach(e=>{const r=e.block;nt(n,r)&&UK(n,r)}),!0}function NK(n){return n.selection.range.getSelectedBlocks().forEach(e=>{const r=e.block;nt(n,r)&&Ck(n,r)}),!0}function PK(n){return VC(n)?!1:n.undoManager.runInGroup(()=>(OK(n),!0))}function FK(n){return VC(n)?!1:n.undoManager.runInGroup(()=>(NK(n),!0))}function KK(n){if(VC(n))return!1;if(!n.selection.range.isCollapsed())return;const t=n.selection.focusedBlock;if(!nt(n,t))return;const e=n.selection.range.focus;if(!(!e.isSimple()||e.offset!==0||!R0(t)))return Ck(n,t),!0}class $C{renderBlock(t,e,r){const{padding:i}=r;return i?{attributes:{"block-padding-level":i}}:{}}}const Bct="",VK={Tab:PK,"Shift+Tab":FK,Backspace:KK};function $K(n,t,e=1){if(!t)return null;let r=ge(n);for(;r;){const i=r.getAttribute("data-style-heading"),o=Number(r.getAttribute("data-list-level"));if(i){if(i<t)return null;if(i===t&&o===e)return Kt(r)?r:null}r=ge(r)}return null}function HK(n,t){const e=n.getAttribute("data-style-heading"),r=$K(n,e);if(r)return r;const i=ge(n);if(i&&Kt(i)&&tr(i)===t)return i;const o=qt(n);return o&&Kt(o)&&tr(o)===t?o:null}function jK(n,t,e){var R,L,M;const r=(R=e.data)!=null?R:{};let i=1;if(Kt(t))i=on(t);else{const U=R0(t);U&&(i=U+1),i>8&&(i=8)}const o=(L=r.listType)!=null?L:"ordered";if(o==="text-only")return null;const s=n.getBlockData(t);let l=(M=s.text)!=null?M:[],d=fe(l);const h=e.offset||0;h<=un(l)&&(l=_n(l,h).right,d=d.substring(0,h));let C=1;o==="ordered"&&(C=Number.parseInt(d,10)||1);let E=Z();const A=HK(t,o);if(A)if(on(A)===i){if(bt(t)>bt(A))C=er(A)+1;else{const U=er(A);U>1&&(C=U-1),new gk(n,A,{start:C+1}).fix()}E=Xa(A)}else{const U=fK(A,i);U&&(C=er(U)+1)}else Kt(t)&&new gk(n,t,{start:1}).fix();const v={id:Z(),type:"list",level:i,start:C,groupId:E,ordered:!1,text:l};return s.quoted&&(v.quoted=!0),s.heading&&(v.heading=s.heading),o==="ordered"?v.ordered=!0:(o==="checked"||o==="unchecked")&&(v.checkbox=o),{blockData:v,onConverted:(U,F)=>{new fl(U,F).fix()}}}function Za(n){return n.textOnly?"text-only":n.checkbox?n.checkbox:n.ordered?"ordered":"unordered"}function zK(n){var e,r;if(n.checkbox)return"";const t=(e=n.level)!=null?e:1;return n.ordered?`${aK(t,(r=n.start)!=null?r:1)}.`:cK(t)}function w0(n){return n==="checked"||n==="unchecked"}function Ek(n,t,e,r){const i=t,{containerId:o,blockIndex:s}=r[r.length-1];if(s===0)return!0;const l=e.blocks[o][s-1];if(l.type!=="list")return!0;const c=Za(i),d=Za(l);return c!==d&&(!w0(c)||!w0(d))||(i.level||1)>(l.level||1)}function xk(n,t,e,r){const i=t,{containerId:o,blockIndex:s}=r[r.length-1];if(s===e.blocks[o].length-1)return!0;const l=e.blocks[o][s+1];if(l.type!=="list")return!0;const c=Za(i),d=Za(l);return c!==d&&(!w0(c)||!w0(d))||(i.level||1)>(l.level||1)}function GK(n,t,e,r,i){var s,l,c;const o=t;if(r==="text")return((s=On.convertTo)==null?void 0:s.call(On,n,t,e,"text",i))||"";if(r==="markdown"){let d=((l=On.convertTo)==null?void 0:l.call(On,n,t,e,"markdown",i))||"";o.checkbox==="checked"?d=`[x] ${d}`:o.checkbox==="unchecked"&&(d=`[ ] ${d}`),o.ordered?d=`${o.start}. ${d}`:d=`- ${d}`;const h=o.level||0;return d=(h>0?" ".repeat(h-1):"")+d,Ek(n,t,e,i)&&(d=`${d}`),xk(n,t,e,i)&&(d=`${d}`,h<=1&&(d+=`
|
|
614
|
-
`)),d}if(r==="html"){let d=((c=On.convertTo)==null?void 0:c.call(On,n,t,e,"html",i))||"";d=d.replace("<p>","").replace("</p>",""),o.checkbox==="checked"?d=`<input type="checkbox" checked="checked" disabled="disabled" /> ${d}`:o.checkbox==="unchecked"&&(d=`<input type="checkbox" disabled="disabled" /> ${d}`);let h="ul",C="";if(o.ordered)switch(d=`<li value="${o.start}">${d}</li>`,h="ol",o.level){case 2:case 5:case 8:C="list-style-type: lower-alpha;";break;case 3:case 6:C="list-style-type: lower-roman;";break}else d=`<li>${d}</li>`;return Ek(n,t,e,i)&&(d=`<${h}${C?` style="${C}"`:""}>${d}`),xk(n,t,e,i)&&(d=`${d}</${h}>`),d}return""}function Ak(n){const t=B("label",["editor-check-list-wrapper"],null);n&&z(t,"editor-check-list-wrapper-checked");const e=B("span",["editor-check-box"],t);return B("span",["editor-check-box-inner"],e),t}function WK(n,t){const e=Za(t);if(e!=="text-only"){if(e==="checked"){n.append(Ak(!0));return}if(e==="unchecked"){n.append(Ak(!1));return}n.innerText=zK(t)}}function qK(n){const t=B("div",["list-container"],null),e=B("button",["list-marker"],t);return WK(e,n),t}function tc(n,t){Ue(t);const e=n.getBlockData(t),r={id:Z(),type:"text",text:e.text};e.heading&&(r.heading=e.heading),e.heading&&(r.heading=e.heading);const i=new k0(n,t),o=rt(t),s=bt(t);n.deleteBlock(t);const l=mh(r.id,0);if(uu(n,o)&&!Xt(o)){const c=we(o);n.insertBlock(ft(o),s,r,l),n.deleteBlock(c)}else n.insertBlock(ft(o),s,r,l);i.fix()}function XK(n){if(!n.selection.range.isCollapsed())return!1;const t=n.selection.focusedBlock;if(!Kt(t))return!1;const e=n.selection.range.focus;return!e.isSimple()||e.offset!==0?!1:(tc(n,t),!0)}function bk(n){let t=qt(n);if(!t)return null;const e=ul(n);for(;t!==e;){if(p(Se,t,"no next block"),Kt(t))return on(t)>on(n)?t:null;if(t=qt(t),!t)return null}return null}function HC(n){const t=[];let e=bk(n);if(!e)return t;for(;e;){const r=ul(e);t.push({block:e,children:HC(e)}),e=r}return t}function QK(n){const t=(r,i)=>{i.push(r.block),r.children.forEach(o=>t(o,i))},e=[];return n.forEach(r=>t(r,e)),e}function vk(n,t){return on(t)!==1}function Bk(n,t,e){t.forEach(r=>{const i=n.getBlockData(r.block);n.updateBlockData(r.block,{...i,groupId:e,level:(i.level||1)-1}),r.children.length&&Bk(n,r.children,i.groupId)})}function jC(n,t){if(!vk(n,t))return!1;const e=on(t);if(e===1)return!1;let r=Z(),i=1,o=tr(t);const s=e-1,l=v0(t);l&&(r=Xa(l),i=er(l)+1,o!=="text-only"&&(o=tr(l)));const c=HC(t),d=n.getBlockData(t),h={...d,groupId:r,level:s,start:i,..._C(o)};n.updateBlockData(t,h),n.doc.beginBatchUpdate(),Bk(n,c,d.groupId),n.doc.endBatchUpdate(),new fl(n,t).fix();const E=bk(t);return E&&new fl(n,E,{resetStart:!0,resetGroupId:!0}).fix(),!0}const YK=I("list-block");function JK(n,t,e){p(YK,Kt(t),"not a list block");const r={...n.getBlockData(t),id:Z()};return e!=null&&e.level&&(r.level=e.level),e!=null&&e.start&&(r.start=e.start),e!=null&&e.keepText||delete r.text,(r==null?void 0:r.checkbox)==="checked"&&(r.checkbox="unchecked"),r}function ZK(n){if(Ue(n),!b0(n))return n;let t=os(n);for(;t;){if(!b0(t))return t;t=os(t)}return null}function tV(n,t,e,r){const i=new fl(n,r),o=er(r)+1;Ra(n,t,e,{forceInsertAfter:!0,newBlockData:JK(n,r,{start:o})}),i.fix()}function eV(n){var s;if(n.selection.range.isCollapsed()){const l=n.selection.focusedBlock;if(Kt(l)&&dt(n,l)===0)return on(l)===1?tc(n,l):jC(n,l),!0}n.clearSelectedContents();const t=n.selection.focusedBlock;if(!Kt(t))return!1;const e=n.selection.range.focus;if(!e.isSimple())return!1;const r=e.offset,o=(s=r===dt(n,t)?ZK(t):t)!=null?s:t;return tV(n,t,r,o),!0}function Tk(n){p(Se,Kt(n),"not a list block");const{level:t}=is(n);let e=ge(n);for(;e;){if(Kt(e)){const{level:r}=is(e);if(t===r)return e;if(r<t)return null}e=ge(e)}return null}function yk(n,t){return Ue(t),Tk(t)?on(t)<iK:!1}function nV(n,t,e){let r=ge(t);p(Se,r,"no prev brother");const i=on(e);for(;r;){if(r===e)return null;if(Kt(r)&&on(r)===i+1)return r;r=ge(r)}return null}function kk(n,t){if(!yk(n,t))return!1;Ue(t);const e=Tk(t);p(Se,e,"no list prev brother");const r=e,i=nV(n,t,r),o=on(r)+1;let s=Z(),l=1,c=tr(t);i&&(s=Xa(i),l=er(i)+1,c=tr(i));const d=HC(t),C={...n.getBlockData(t),groupId:s,level:o,start:l,..._C(c)};return n.updateBlockData(t,C),n.doc.beginBatchUpdate(),QK(d).forEach(A=>{const v=n.getBlockData(A);n.updateBlockData(A,{...v,level:(v.level||1)+1})}),n.doc.endBatchUpdate(),!0}function rV(n,t,e){return t.length===0||!t.every(r=>Kt(r.block))?!1:e==="increase"?yk(n,t[0].block):vk(n,t[0].block)}function Rk(n,t,e){if(!rV(n,t,e))return!1;const r=t[0].block,i=on(r),o=t.filter(d=>on(d.block)<=i),s=uk(r,{withSelf:!1}),l=new Set(o.map(d=>d.block)),c=s.filter(d=>!l.has(d));return n.undoManager.runInGroup(()=>{let d=null;c.length>0&&(d=new fl(n,c[0])),o.forEach(h=>{e==="increase"?kk(n,h.block):jC(n,h.block)}),d==null||d.fix()}),!0}function iV(n,t){return kk(n,t)}function oV(n,t){return jC(n,t)}function sV(n){const t=n.selection.range.getSelectedBlocks();if(t.length>1)return Rk(n,t,"increase"),!0;const e=t[0].block;if(!Kt(e))return!1;const r=new k0(n,e);return iV(n,e)&&(r.fix(),new fl(n,e).fix()),!0}function lV(n){const t=n.selection.range.getSelectedBlocks();if(t.length>1)return Rk(n,t,"decrease"),!0;const e=t[0].block;return Kt(e)?(oV(n,e),!0):!1}class aV{constructor(t){this.editor=t}handleBeforeKeyDown(t,e){const r=t.selection.range.getSelectedBlocks();if(r.length===0||!r.some(o=>Kt(o.block)))return!1;switch(e.key){case"Enter":return this.handleEnter(e);case"Backspace":return this.handleBackspace();case"Tab":return this.handleTab(e);default:return!1}}handleEnter(t){const e=this.editor.selection.range.getSelectedBlocks()[0];return!e.block||!Kt(e.block)||ai(t,"Shift+Enter")?!1:this.editor.undoManager.runInGroup(()=>eV(this.editor))}handleBackspace(){return this.editor.undoManager.runInGroup(()=>XK(this.editor))}handleTab(t){return ai(t,"Shift+Tab")?this.editor.undoManager.runInGroup(()=>lV(this.editor)):this.editor.undoManager.runInGroup(()=>sV(this.editor))}}class cV{constructor(t){m(this,"effectedBlockIds",new Map);m(this,"handleBeforeClearSelection",()=>{this.effectedBlockIds.clear();const t=this.editor.selection.range.getSelectedBlocks();if(t.length===0)return;const e=new Set;t.forEach(i=>{const o=i.block;Kt(o)&&e.add(o)});const r=new Map;Array.from(e.values()).forEach(i=>{var c;const o=Ju(i),{start:s}=is(o);r.set(st(o),s);const l=(c=uK(i))!=null?c:i;r.set(st(l),s)}),this.effectedBlockIds=r});m(this,"handleAfterClearSelection",()=>{Array.from(this.effectedBlockIds.entries()).forEach(([t,e])=>{const r=this.editor.findBlockById(t);!r||FC(this.editor,r,e)}),this.effectedBlockIds.clear()});this.editor=t,this.editor.addListener("beforeClearSelection",this.handleBeforeClearSelection),this.editor.addListener("afterClearSelection",this.handleAfterClearSelection)}destroy(){this.editor.removeListener("beforeClearSelection",this.handleBeforeClearSelection),this.editor.removeListener("afterClearSelection",this.handleAfterClearSelection)}}const uV=I("customize-list-start-menu");class fV{constructor(t){m(this,"popup");m(this,"block",null);m(this,"show",(t,e)=>{const r=e.querySelector("div.list-container");p(uV,r,"list-block mark does not exist"),this.block=e,this.popup.manualShow(r,{theme:"light"})});m(this,"createDialogContent",()=>{const t=B("div",["customize-start-panel"],null);B("span",["customize-start-panel-title"],t,D.t("list.numberLabel"));const e=this.createNumericInput();t.appendChild(e);const r=B("button",["customize-start-panel-button"],t,D.t("list.confirm"));return this.editor.domEvents.addEventListener(t,"keydown",this.handleKeydown),this.editor.domEvents.addEventListener(r,"click",this.handleOk),t});m(this,"handleDialogShow",()=>{const t=this.block;if(!t)return;const e=this.popup.popupContent,r=e.querySelector("button.customize-start-panel-button"),i=e.querySelector("input.customize-start-panel-input"),o=er(t);!r||!i||requestAnimationFrame(()=>{i.focus(),i.value=String(o)})});m(this,"handleOk",()=>{const e=this.popup.popupContent.querySelector("input.customize-start-panel-input"),r=this.block;if(!r)return;const i=Number(e.value);!i||(this.editor.undoManager.runInGroup(()=>{Ja(this.editor,[r,...Qa(r)],i,{resetGroupId:!0})}),this.popup.close("clickItem"))});m(this,"handleKeydown",(t,e)=>{const r=e;r.isComposing||(r.key==="Escape"?this.popup.close("cancelBar"):r.key==="Enter"&&this.handleOk())});this.editor=t,this.popup=new Va(this.createDialogContent()),this.popup.on("show",this.handleDialogShow)}destroy(){this.popup.destroy()}createNumericInput(){const t=B("input",["customize-start-panel-input"],null);t.type="number",t.min="1";const e=()=>{const i=t.value.replace(/[^\d]/g,"").replace(/^0+/,""),o=parseInt(i,10);o<=0||Number.isNaN(o)?t.value="":t.value=i};return this.editor.domEvents.addEventListener(t,"input",e),t}}function dV(n,t){return Xa(n)===Xa(t)}function hV(n,t){const e=ak(t);return e?dV(e,t)?er(e)!==er(t)-1:!0:!1}function mV(n,t){return os(t)?!0:er(t)!==1}function gV(n,t){return Ue(t),[{id:"continue-numbering",name:D.t("list.continueList"),states:hV(n,t)?[]:["disabled"]},{id:"start-new-list",name:D.t("list.restartList"),states:mV(n,t)?[]:["disabled"]},{id:"set-numbering-value",name:D.t("list.changeNumber")}]}function pV(n,t,e){var r,i;if(Ue(t),e.id==="continue-numbering"){const o=ak(t);o&&Ja(n,[t,...Qa(t)],er(o)+1,{resetGroupId:!0,groupId:Xa(o)})}if(e.id==="start-new-list"&&n.undoManager.runInGroup(()=>{Ja(n,[t,...Qa(t)],1,{resetGroupId:!0})}),e.id==="set-numbering-value"){const o=(r=n.options.componentsOptions)==null?void 0:r.list;if((i=o==null?void 0:o.onChangeStart)!=null&&i.call(o,n,t,e))return;n.addCustom("list-customize-start-dialog",()=>new fV(n)).show(n,t)}}class CV{constructor(t){m(this,"menu");m(this,"handleClick",(t,e)=>{const r=aa(e,"div.list-container");if(r&&this.editor.isWritable()){const i=et(r);p(Se,i,"no parent block"),Ue(i);const o=t.getBlockData(i);if(o&&o.checkbox){t.updateBlockData(i,{...o,checkbox:o.checkbox==="checked"?"unchecked":"checked"});return}if(tr(i)==="unordered")return;this.menu.updateItems(this.getCommandItems(i)),this.menu.manualShow(r),this.activeList(r,!0)}});m(this,"handleMenuClose",()=>{var e;const t=(e=this.menu.tippyInstance)==null?void 0:e.reference;t&&this.activeList(t,!1)});m(this,"handleMenuClick",(t,e)=>{var i;const r=(i=this.menu.tippyInstance)==null?void 0:i.reference;if(r){const o=et(r);o&&pV(this.editor,o,e)}});this.editor=t,this.editor.addListener("click",this.handleClick),this.menu=new Zo([]),this.menu.addListener("close",this.handleMenuClose),this.menu.addListener("click",this.handleMenuClick)}destroy(){this.editor.removeListener("click",this.handleClick),this.menu.removeListener("close",this.handleMenuClose)}getCommandItems(t){return gV(this.editor,t)}activeList(t,e){const r=et(t);!r||(e?(z(t,"active"),z(r,"active")):(ot(t,"active"),ot(r,"active")))}}class EV{constructor(t){this.editor=t}handleBeforeKeyDown(t,e){const r=t.selection.range.getSelectedBlocks();if(r.length===0)return!1;const i=r[0].block;if(!Kt(i)||!UC(i))return!1;if(e.key==="ArrowUp"||e.key==="ArrowLeft"){const o=js(i);return o&&t.selection.selectBlock(o,dt(t,o)),!0}if(e.key==="ArrowDown"||e.key==="ArrowRight"){const o=zs(i);return o&&t.selection.selectBlock(o,0),!0}return(e.key==="Delete"||e.key==="Backspace"||e.key==="Escape")&&mk(t,i),!0}}function xV(n,t,e,r,i){vp(n,"list-block-init",()=>{setTimeout(()=>{n.input.addHandler(new EV(n)),n.input.addHandler(new aV(n)),n.addCustom("list-clear-selection-handler",()=>new cV(n)),n.addCustom("list-marker-menu",()=>new CV(n))})});const o=On.createBlockContent(n,t,e,r,i),s=i,{level:l,start:c,groupId:d}=s,h=Za(s);r.setAttribute("data-list-level",`${l||1}`),r.setAttribute("data-list-start",`${c||1}`),r.setAttribute("data-list-group-id",`${d}`),r.setAttribute("data-list-type",h);const C=qK(s);return r.insertBefore(C,o),s.viewAsMindmap?setTimeout(()=>{const E=n.getBlockById(i.id);E&&B0(n,E,{},{mindmapTools:T0,saveData:!1})}):setTimeout(()=>{const E=n.getBlockById(i.id);E&&hk(n,E)}),o}const AV={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"}},bV={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"}},vV={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"}};D.mergeLang({"zh-CN":AV,"en-US":bV,"ja-JP":vV});const Tct="",wk={...On,blockType:"list",createBlockContent:xV,convertFrom:jK,convertTo:GK,handleDrop:_K,notify:LK},zC=I("paragraph");class BV{constructor(t){m(this,"id","BlockParagraphProvider");this.editor=t}isChecked(t,e){return!!(t[e]||t.level&&(t.ordered===!0&&!t.checkbox&&e==="ordered-list"||t.ordered===!1&&!t.checkbox&&e==="unordered-list")||e==="check-list"&&t.checkbox)}getAvailableCommands(t,e){const r=[],i={"unordered-list":[D.t("commands.unordered"),ze("CtrlOrCmd+Shift+U"),bT],"ordered-list":[D.t("commands.ordered"),ze("CtrlOrCmd+Shift+L"),AT],"check-list":[D.t("commands.check"),void 0,vT],link:[D.t("commands.link"),ze("CtrlOrCmd+K"),Jp],quoted:[D.t("commands.quote"),void 0,BT]};if(nt(t,e)){const o=st(e),s=St(e),l=Ir(t,e),c=t.getBlockData(e);Object.entries(i).forEach(([d,[h,C,E]])=>{const A=[];if(this.isChecked(c,d)&&A.push("checked"),d==="link"){if(!t.selection.range.isSimple())return;t.selection.range.getSelectedBlocks().length!==1&&A.push("disabled")}r.push({blockId:o,blockType:s,blockKind:l,id:d,name:h,desc:C,states:A,icon:E,groupIndex:600})})}return r}convertLink(t,e,r){p(zC,Or(e.start),""),p(zC,Or(e.start),"");const i="bottom-start",o=e.start.offset,s=e.end.offset,l=(A,v)=>{t.undoManager.runInGroup(()=>{try{const R=t.selection.range.isCollapsed();let L;if(R){L=to(t.getBlockText(r),s,A,{link:v}),t.setBlockText(r,L);return}L=fh(t.getBlockText(r),o,s,A),L=gu(o,A.length,L,"link",v),t.setBlockText(r,L),t.selection.selectBlock(r,o+A.length),t.focus()}catch(R){zC.error(R)}})},c=()=>{t.selection.selectBlock(r,s),t.focus()},d=qi(t,r,e)[0];if(!d)return;const h=Yi(t,r,"link-button-anchor",d),C=t.getBlockText(r),E=Aa(C,o);Qu(t,{target:h,linkText:t.getSelectedText(),linkUrl:(E==null?void 0:E.link)||"",onFinished:l,onClose:c,placement:i})}convertToList(t,e,r){const i=Wd(t,e,"list",{offset:0,data:{listType:r}});i&&t.undoManager.runInGroup(()=>{const o=bt(e),s=rt(e);t.insertBlock(ft(s),o,i.blockData),t.deleteBlock(e)})}executeCommand(t,e,r,i){var c;if(!nt(t,e))return!1;const o=i.id,s=(c=i.states)==null?void 0:c.includes("checked");let l=!1;if(o==="unordered-list"&&(s?tc(t,e):this.convertToList(t,e,"unordered"),l=!0),o==="ordered-list"&&(s?tc(t,e):this.convertToList(t,e,"ordered"),l=!0),o==="check-list"&&(s?tc(t,e):this.convertToList(t,e,"unchecked"),l=!0),o==="quoted"){const h=t.getBlockData(e).quoted;t.updateBlockData(e,{quoted:h?void 0:!0}),l=!0}if(o==="link"){const d=E0(t);d==null||d.disableTextToolbar(),d==null||d.hide(),setTimeout(()=>{d==null||d.enableTextToolbar()},1e3),this.convertLink(t,r,e),l=!0}return l}}const TV={left:Pa,right:n0,center:r0};class yV{constructor(t){m(this,"id","BlockAlignProvider");this.editor=t}applyAlignStyle(t,e,r){Object.keys(TV).includes(r)?t.updateBlockData(e,{align:r}):t.updateBlockData(e,{align:null})}isChecked(t,e){return t.align===e}getAvailableCommands(t,e,r){if(nt(t,e)){const i=st(e),o=St(e),s=Ir(t,e),l=t.getBlockData(e),c=d=>{var C;const h=B("span",["toolbar-item-name-container"],null);for(const E of d.children)if((C=E.states)!=null&&C.includes("checked"))return h.innerHTML=E.icon||Pa,h;return h.innerHTML=Pa,h};return[{id:"align",name:D.t("commands.alignGroup"),blockId:i,blockType:o,blockKind:s,groupIndex:700,dropdown:!0,element:c,manualShowChildren:!0,childrenPlacement:"bottom-start",defaultCheckedChildren:["align-left"],children:[{id:"align-left",name:D.t("commands.alignLeft"),icon:Pa,states:this.isChecked(l,"left")?["checked"]:[]},{id:"align-center",name:D.t("commands.alignCenter"),icon:r0,states:this.isChecked(l,"center")?["checked"]:[]},{id:"align-right",name:D.t("commands.alignRight"),icon:n0,states:this.isChecked(l,"right")?["checked"]:[]}],childrenType:"menu"}]}return[]}executeCommand(t,e,r,i){if(!nt(t,e))return!1;if(i.id.startsWith("align")){const o=i.id.replace(/^align-/,"");return this.applyAlignStyle(t,e,o),!0}return!1}}function Sk(n){const e=n.selection.range;if(e.isCollapsed()||e.start.blockId!==e.end.blockId||!e.start.isSimple()||!e.end.isSimple()||e.end.offset-e.start.offset!==1)return!1;const r=n.getBlockById(e.start.blockId);return Eu(n,r,e.start.offset).charType==="box"}const kV=I("toolbar-handler"),RV={id:"",name:"",type:"separator"};class ec{constructor(t){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,"isInToolbar",t=>this.toolbar.isInCommandBar(t.target));m(this,"handleButtonClick",(t,e)=>{const r=this.editor.getCustom("editor-tooltip");r.lastClickButtonId=e.id,this.toolbarType==="text"?(this.editor.editorCommandProviders.executeCommand(this.editor.selection.range,e,{}),this.editor.isWritable()&&this.showTextToolbar("click")):this.hoveringBlock&&eK(this.editor,this.hoveringBlock,this.hoveringTextChild,e)});m(this,"handleClose",()=>{lC(this.editor)&&this.editor.focus()});m(this,"handleClosing",(t,e)=>{if(this.toolbarType==="object"){const r=Nb(e);if(this.hoveringBlock===r)return!1}return!0});m(this,"handleDocumentMouseDown",t=>{t.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",(t,e,r,i)=>{if(!(this.hoveringBlock===t&&this.hoveringTextChild===e)&&(this.hoveringBlock=t,this.hoveringTextChild=e,!(this.toolbar.isVisible&&this.toolbarType==="text"))){if(!t){this.toolbar.close("fromHover");return}this.showObjectToolbar(i)}});m(this,"handleSelectionChange",Me.default(t=>{var r;if(p(kV,t===this.editor,"editor mismatch"),t.selection.range.isCollapsed()||this.mouseDown){if(this.toolbarType==="object"){const i=(r=this.toolbar.tippyInstance)==null?void 0:r.reference,o=this.editor.selection.focusedBlock;if(i&&ne(i,o))return}this.toolbar.close("selectionChange"),this.oldRange=null;return}if(!this.editor.isWritable()){this.toolbar.close("selectionChange"),this.oldRange=null;return}if(t.selection.range.getSelectedBlocks().length===0){this.toolbar.close("selectionChange"),this.oldRange=null;return}this.oldRange&&this.oldRange.isEqual(t.selection.range)||(this.oldRange=t.selection.range,this.showTextToolbar("selectionChange"))},50));this.editor=t;const e=t.options.componentsOptions.popover;this.toolbar=new Pu([],void 0,{tooltipId:t.clientId,id:"editor-toolbar",overflowBoundary:e==null?void 0:e.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(),t.addListener("selectionChanged",this.handleSelectionChange),Be.get(t).addListener("childChange",this.handleHoveringBlockChildChange),Be.get(t).addFilter(this),t.editorCommandProviders.registerCommandProvider(new rK(t)),t.editorCommandProviders.registerCommandProvider(new BV(t)),t.editorCommandProviders.registerCommandProvider(new yV(t))}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),Be.get(this.editor).removeListener("childChange",this.handleHoveringBlockChildChange)}isInBlock(t,e){return t!==this.hoveringBlock?!1:!!(e.target&&e.target instanceof Node&&this.toolbar.popper&&ne(this.toolbar.popper,e.target))}bindEvents(){document.addEventListener("mousedown",this.handleDocumentMouseDown)}unbindEvents(){document.removeEventListener("mousedown",this.handleDocumentMouseDown)}update(t){!this.editor.isWritable()||this.showTextToolbar(t)}showTextToolbar(t){var R,L;if(this._disableTextToolbar)return;const e=this.editor.selection.range,r=e.getSelectedBlocks();if(r.length===0)return;const i=r[0];if(!i)return;if(r.length===1){if(pe(i.block)){t==="click"&&this.showObjectToolbar(null);return}if(_t(this.editor,i.block)&&e.isSimple())return}if(Sk(this.editor))return;if(Gi(i.block)){this.toolbar.close("selectionChange");return}const o=this.editor.editorCommandProviders.getCommands(this.editor.selection.range),s=new Map;o.forEach(M=>{const U=M.groupIndex,F=s.get(U);F?F.push(M):s.set(U,[M])});const l=[[]],c=Array.from(s.entries()).sort((M,U)=>M[0]-U[0]);for(let M=0;M<c.length;M++){const[,U]=c[M];if(U.length===0)continue;let F=l[l.length-1];F.length>0&&F[F.length-1].groupIndex!==U[U.length-1].groupIndex&&(F=[],l.push(F)),F.push(...C0(U))}if(l.length===0){this.toolbar.close("selectionChange");return}this.toolbarType="text";const d=[];if(l.forEach((M,U)=>{const F=M.sort((G,W)=>{var it,at;return((it=G.order)!=null?it:0)-((at=W.order)!=null?at:0)});d.push(...F),U!==l.length-1&&d.push(RV)}),d.length===0){this.toolbar.close("selectionChange");return}this.toolbar.updateItems(d);const h=r[r.length-1],C=!this.editor.selection.range.isReverse()&&h!==i,E=C?h:i,A=ik(this.editor,E),v=Yi(this.editor,E.block,"editor-quick-menu",A);this.toolbar.manualShow(v,{placement:C?"bottom":"top",offset:[0,C?5:10]}),(L=(R=this.toolbar.tippyInstance)==null?void 0:R.popperInstance)==null||L.update()}showObjectToolbar(t){var l,c,d;if(!this.hoveringBlock||this.mouseDown)return;const e=this.hoveringBlock,r=this.hoveringTextChild,{commands:i,element:o}=JF(this.editor,e,r);if(!i.length||!o){this.toolbar.close("fromHover");return}this.toolbarType="object",this.toolbar.isVisible&&((c=(l=this.toolbar)==null?void 0:l.tippyInstance)==null?void 0:c.reference)!==o&&this.toolbar.close("fromHover");const s=()=>{let h;const C=o.getClientRects(),E=[];if(Array.from(C).forEach(A=>{const{y:v}=A;E.includes(v)||E.push(v)}),E.length>1){if(h=r?C[C.length-1]:C[0],t)for(let A=0;A<C.length;A++){const v=C[A],R=new DOMRect(v.x-4,v.y-4,v.width+8,v.height+8);if(R.x<t.clientX&&t.clientX<R.right&&R.y<t.clientY&&t.clientY<R.bottom){h=v;break}}}else{if(h=o.getBoundingClientRect(),r){const A=r.getBoundingClientRect();return new DOMRect(A.x,A.y,A.width,A.height)}return new DOMRect(C[0].x,C[0].y,C[0].width,C[0].height)}if(t){const A=h.y,v=t.clientX;return new DOMRect(v,A,10,h.height)}return h};this.toolbar.updateItems(i),this.toolbar.isVisible||(this.toolbar.manualShow(o,{placement:r?"bottom":"top",getReferenceClientRect:s}),(d=this.toolbar.tippyInstance)!=null&&d.popper&&(this.toolbar.tippyInstance.popper.style.paddingTop="10px",this.toolbar.tippyInstance.popper.style.paddingBottom="5px"))}static register(t){return t.addCustom("toolbar-handler",e=>new ec(e))}static get(t){return t.getCustom("toolbar-handler")}}function S0(n,t,e){n.getBlockData(t).heading===e?n.updateBlockData(t,{heading:null}):n.updateBlockData(t,{heading:e})}function Lk(n,t,e){["left","center","right"].includes(e)?n.updateBlockData(t,{align:e}):n.updateBlockData(t,{align:null})}function GC(n,t){const r=n.getBlockData(t).quoted;n.updateBlockData(t,{quoted:r?void 0:!0})}function WC(n,t){return!!(n[t]||n.level&&(n.ordered===!0&&!n.checkbox&&t==="ordered-list"||n.ordered===!1&&!n.checkbox&&t==="unordered-list")||t==="check-list"&&n.checkbox)}function qC(n,t,e){if(!n.selection.range.focus.isSimple())return;const i=n.getBlockData(t);let o;switch(e){case"unordered-list":o=WC(i,"unordered-list")?void 0:"unordered";break;case"ordered-list":o=WC(i,"ordered-list")?void 0:"ordered";break;case"check-list":o=WC(i,"check-list")?void 0:"unchecked";break}if(o){const s=Wd(n,t,"list",{offset:0,data:{listType:o}});s&&n.undoManager.runInGroup(()=>{const l=bt(t),c=rt(t);n.deleteBlock(t);const d=n.insertBlock(ft(c),l,s.blockData);s.onConverted&&s.onConverted(n,d)})}else tc(n,t)}const wV=Object.freeze(Object.defineProperty({__proto__:null,applyHeadingStyle:S0,applyAlignStyle:Lk,applyQuoteStyle:GC,applyList:qC},Symbol.toStringTag,{value:"Module"})),SV=[qh,Xh,Qh,Yh,Jh,Zh,t0,e0],LV={Unordered:eC,Ordered:nC,Checkbox:Zp,Quote:tC};function Ik(n,t){const e=n;e.blockOptions=t,e.itemType="insert-block",n.children&&n.children.forEach(r=>Ik(r,t))}function IV(){return{name:"basic",insertBlockCommandItems:[{id:"text",icon:Fa,name:D.t("commands.text"),order:0,group:"basics",value:"text"}]}}function XC(n=1){var i;const t={name:"basic",insertBlockCommandItems:[]};let e=x0();e<=4?e=5:e<8&&(e+=1);let r=n;for(;r<=e;){const o=`heading-${r}`;(i=t.insertBlockCommandItems)==null||i.push({id:o,icon:SV[r-1],name:D.t("quickMenu.basic.heading.title",{heading:String(r)}),order:r,group:"basics",value:String(r),subText:Bn(o)}),r++}return t}function DV(){const n={name:"basic",insertBlockCommandItems:[]};return["Unordered","Ordered","Checkbox","Quote"].forEach((e,r)=>{var o;const i=`insert-${e.toLocaleLowerCase()}`;(o=n.insertBlockCommandItems)==null||o.push({id:i,name:D.t(`quickMenu.basic.${e.toLocaleLowerCase()}`),icon:LV[e],value:e.toLocaleLowerCase(),group:"basics",order:10+r,subText:Bn(i)})}),n}class Dk{constructor(t){this.withPlainText=t}getCommands(){const t=IV(),e=XC(),r=DV();return[...this.withPlainText?t.insertBlockCommandItems||[]:[],...e.insertBlockCommandItems||[],...r.insertBlockCommandItems||[]]}updateBlock(t,e,r,i){const{value:o,id:s}=i;return s.startsWith("heading-")?S0(t,r,Number.parseInt(o!=null?o:"1",10)||1):o==="ordered"||o==="unordered"||o==="checkbox"?qC(t,r,{ordered:"ordered-list",unordered:"unordered-list",checkbox:"check-list"}[o]):o==="quote"&&GC(t,r),null}async handleUpdateBlockCore(t,e){const r=t.getBlockByIndex(e.containerId,e.blockIndex);return this.updateBlock(t,e.containerId,r,e.item)}async handleInsertEmptyBlockCore(t,e){const{containerId:r,blockIndex:i}=e,o=t.insertTextBlock(void 0,r,i);return this.updateBlock(t,e.containerId,o,e.item)}async executeCommand(t,e,r){if(r.from==="quick-menu"){const i=t.getBlockById(r.blockId),o=t.getParentContainer(i),s=ft(o),l=t.getBlockIndex(i);t.undoManager.runInGroup(()=>this.handleUpdateBlockCore(t,{item:e,containerId:s,blockIndex:l})),t.focus()}else r.from==="block-menu"&&(t.undoManager.runInGroup(()=>this.handleInsertEmptyBlockCore(t,{item:e,containerId:r.containerId,blockIndex:r.blockIndex})),t.focus());return null}}const _k={basics:100,system:200,common:300,thirdParty:400};class QC{constructor(){m(this,"dataUrl","");m(this,"error",null)}destroy(){}setDataUrl(t){this.error=null,this.dataUrl=t}setError(t){this.dataUrl="",this.error=t}}const _V=I("mathjax-converter"),MV="MathJax-script",UV=30,Mk=8;async function OV(n){var r;window.MathJax||(window.MathJax={options:{skipHtmlTags:["script","noscript","style","textarea","pre","code","annotation","annotation-xml","body"]}});const t=n.getComponentOptions("mathjax"),e=((r=t==null?void 0:t.cdn)==null?void 0:r.mathjax)||"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js";await Os(e,MV)}function NV(){try{window.MathJax&&window.MathJax.texReset()}catch{}}async function YC(n,t){const e="mathjax2Svg";try{await Sr.lock(e),NV(),await OV(n);const r=await window.MathJax.tex2svgPromise(t),i=r.querySelector("merror");if(i)throw new Error(i.textContent);return r.querySelector("svg").outerHTML}catch(r){throw _V.error(r),r}finally{Sr.release(e)}}function PV(n){const t=new DOMParser().parseFromString(n,"image/svg+xml"),e={width:0,height:0};if(t&&t.firstChild){const r=t.firstChild,i=r.getAttribute("height"),o=r.style.minWidth;i&&(e.width=parseInt(o,10)*Mk+UV,e.height=parseInt(i,10)*Mk)}return e}async function Uk(n,t){const e=await YC(n,t);return e?await Fg(e,"image/svg+xml"):""}async function Ok(n,t){const r=await YC(n,t),i=new File([r],"math.svg");return(await n.doc.uploadResource(i)).resourceId}async function FV(n,t){const e=await YC(n,t),r=PV(e),i=e,o=new File([i],"math.svg");return{resourceId:(await n.doc.uploadResource(o)).resourceId,...r}}const Nk=I("edit-mathjax");class KV{constructor(){m(this,"editMathjaxPopup",null);m(this,"onChange",null);m(this,"tex","");m(this,"observer",null);m(this,"handleClose",t=>{var r;const e=t.content.querySelector("textarea");if(e){const i=e.value;i!==this.tex&&((r=this.onChange)==null||r.call(this,i,!0))}});m(this,"handleKeyup",t=>{var e;t.isComposing||(t.key==="Escape"&&((e=this.editMathjaxPopup)==null||e.close("cancelBar")),this.handleChange(t.target.value))});m(this,"handleChange",Me.default(t=>{var e;(e=this.onChange)==null||e.call(this,t,!1)},300))}editMathjax(t,e,r,i){if(!this.editMathjaxPopup)this.editMathjaxPopup=new Va(this.createPopupContent(e),{id:"mathjax-popover"});else{const o=this.getTextarea();o.value=e}this.tex=e,this.editMathjaxPopup.manualShow(t,{theme:"light",placement:i==null?void 0:i.placement}),this.editMathjaxPopup.removeAllListeners("close"),this.editMathjaxPopup.addListener("close",this.handleClose),this.onChange=r}createPopupContent(t){const e=B("textarea",["mathjax-editor-textarea"],null);return e.value=t,e.addEventListener("keyup",this.handleKeyup),this.textareaWatcher(e),e}textareaWatcher(t){const e=t;e.onblur=()=>{var i;(i=this.editMathjaxPopup)!=null&&i.isVisible&&t.focus()};const r=()=>{setTimeout(()=>{t.focus()})};this.observer=new IntersectionObserver(r,{}),this.observer.observe(t)}getTextarea(){p(Nk,this.editMathjaxPopup,"no exists mathjax editor popup");const t=this.editMathjaxPopup.content.querySelector("textarea");return p(Nk,t,"no textarea"),t}destroy(){var t,e;this.onChange=null,(t=this.observer)==null||t.disconnect(),(e=this.editMathjaxPopup)==null||e.removeAllListeners()}}function Pk(n,t,e,r,i){n.addCustom("mathjax-editor",()=>new KV).editMathjax(t,e.trim(),r,i)}function Fk(){return{insert:" ",attributes:{id:Z(),box:!0,type:"math",tex:" ",src:"",created:Date.now()}}}function L0(n,t){const e=n.getBoxData(t),r=et(t);if(!r)return;const i=zo(r,t);n.selection.selectBlock(r,i.start,i.end);const o=async(s,l)=>{if(!s.trim()){n.updateBoxData({...e,tex:s,src:null});return}try{await Sr.lock("convertAndUploadMathjax");const c=await Ok(n,s);n.updateBoxData({...e,tex:s,src:c})}catch(c){const d=n.getBoxData(t);n.addCustom(`mathjax-box-${d.id}`,()=>new QC).setError(c),n.updateBoxData({...e,tex:s,src:""})}finally{Sr.release("convertAndUploadMathjax"),l&&n.focus()}};Pk(n,t,e.tex,o)}const Kk=I("mathjax-box");function JC(n,t){n.selection.updateSelection(null);const e=t.target;!e||!(e instanceof HTMLElement)||n.domEvents.removeEventListener(e,null,JC)}async function VV(n,t,e){try{if(!t.tex.trim())return;const r=await Uk(n,t.tex),i=n.findBoxById(t.id);if(!i)return;const o=lu(i);o.innerHTML="";const s=B("img",["mathjax"],o);s.src=r,e.setDataUrl(r),n.domEvents.addEventListener(s,"load",JC)}catch(r){e.setError(r);const i=n.findBoxById(t.id);if(!i)return;const o=i.querySelector(".mathjax-tex-text");z(o,"mathjax-error"),o.innerText=r.message,n.selection.updateSelection(null)}}function $V(n,t,e,r){const i=r,o=n.addCustom(`mathjax-box-${i.id}`,()=>new QC);if(i.src||o.dataUrl){const c=B("img",["mathjax"],e);c.src=n.doc.buildResourceUrl(i.src||o.dataUrl),n.domEvents.addEventListener(c,"load",JC);return}const s=["mathjax-tex-text"];let l=i.tex;l.trim()?o.error&&(l=o.error.message,s.push("mathjax-error")):l=D.t("mathjax.emptyText"),B("span",s,e,l),VV(n,i,o)}function HV(n,t){const e={id:Z(),box:!0,type:"math",tex:t,src:"",created:Date.now()};return Ok(n,t).then(r=>{if(!n.findBoxById(e.id))return;const o={...e,src:r};n.updateBoxData(o)}).catch(r=>{Kk.error(`failed to convert and upload mathjax: ${JSON.stringify(r)}`)}),e}function jV(n,t,e,r){const i=t;return r==="text"?i.tex:r==="markdown"?` $${i.tex}$ `:i.src?`<img src="${n.doc.buildResourceUrl(i.src,{withToken:!0})}" />`:`<code>$${i.tex}$</code>`}function zV(n,t,e){const r=et(t);p(Kk,r,"failed to get block"),!(n.readonly||!n.isBlockWritable(r))&&L0(n,t)}function GV(){return{abstract:D.t("mathjax.abstract")}}const Vk={boxType:"math",updateBoxContent:$V,convertFrom:HV,convertTo:jV,handleClickBox:zV,getBoxProperties:GV};async function WV(n,t,e){try{const r=t.embedData,i=await Uk(n,r.mathjaxText),o=n.findBlockById(t.id);if(!o)return;const s=Ot(o);s.innerHTML="";const l=B("img",["mathjax"],s);l.src=i,e.setDataUrl(i)}catch(r){e.setError(r)}}function qV(n,t){if(n.readonly||!t.target||!(t.target instanceof Node))return;const e=et(t.target);if(!e||!pe(e)||Ge(e)!=="math")return;const r=Ot(e),i=r.querySelector("img")||r.querySelector("span.mathjax-tex-text");if(!i||!ne(i,t.target))return;const s=n.getBlockData(e).embedData;Pk(n,i,s.mathjaxText,async l=>{const{resourceId:c,width:d,height:h}=await FV(n,l),C={mathjaxText:l,src:c,width:d,height:h};n.updateEmbedData(e,C)},{placement:"bottom"})}function XV(n,t,e){const r=e.embedData,{src:i,width:o}=r,s=n.addCustom(`mathjax-block-${e.id}`,()=>new QC);if(n.domEvents.addEventListener(t,"click",qV),!r.mathjaxText.trim()){B("span",["mathjax-tex-text"],t,D.t("mathjax.emptyText"));return}if(i||s.dataUrl){const l=B("img",["mathjax"],t);l.src=n.doc.buildResourceUrl(i||s.dataUrl),o&&(l.style.minWidth=`${o}px`,setTimeout(()=>{const c=t.getBoundingClientRect().width;o>c?(z(t,"mathjax-overflow"),t.style.overflow="auto",t.style.setProperty("--mathjax-width",`${o}px`)):(ot(t,"mathjax-overflow"),t.removeAttribute("data-mathjax-width"),t.style.removeProperty("--mathjax-width"))}));return}s.error,B("span",["mathjax-tex-text"],t,r.mathjaxText),WV(n,e,s)}function QV(n,t,e){if(!nt(n,t))return null;const r=n.getBlockString(t).trim();if(!r||!r.startsWith("$$")||!r.endsWith("$$"))return null;const i=Mg(r,"$");if(!i)return null;const o={mathjaxText:i,src:""};return{blockData:{id:Z(),type:"embed",embedType:"math",embedData:o}}}function YV(n){return{name:"Mathjax"}}function JV(n,t){var r;const e=Ot(t);n.domEvents.removeAllListeners(e),n.findCustom("mathjax-editor")&&((r=n.getCustom("mathjax-editor").editMathjaxPopup)==null||r.close("cancelBar"))}function ZV(n,t,e,r){const i=t.embedData;return r==="html"?`<img src="${n.doc.buildResourceUrl(i.src,{withToken:!0})}" />`:r==="markdown"?`
|
|
613
|
+
`,uP=Object.freeze(Object.defineProperty({__proto__:null,ClearIcon:YT,CloseIcon:Gh,PrevIcon:hT,NextIcon:mT,MoreIcon:jp,TextColorIcon:zp,ArrowDownIcon:Wh,ArrowUpIcon:WN,ArrowLeftIcon:qN,ArrowRightIcon:Gp,DeleteRowIcon:gT,DeleteColIcon:pT,MergeCellIcon:CT,SplitCellIcon:ET,DeleteTableIcon:xT,Heading1Icon:qh,Heading2Icon:Xh,Heading3Icon:Qh,Heading4Icon:Yh,Heading5Icon:Jh,Heading6Icon:Zh,Heading7Icon:t0,Heading8Icon:e0,HeadingNIcon:XN,OrderedListIcon:AT,UnorderedListIcon:bT,CheckListIcon:vT,BlockquoteIcon:BT,AlignCenterIcon:r0,AlignLeftIcon:Pa,AlignRightIcon:n0,ImageIcon:TT,ImageMenuIcon:yT,ImageErrorIcon:qp,ImageEmptyIcon:RT,LinkIcon:Jp,LinkOffIcon:wT,WarningIcon:Wp,PasteSpecialIcon:kT,LaunchIcon:Xp,CodeIcon:$T,AudioIcon:PT,GraphIcon:QN,VideoIcon:FT,FileIcon:YN,MathIcon:ZN,MathMenuIcon:ST,TableIcon:tP,TableMenuIcon:LT,BilibiliIcon:DT,YoukuIcon:_T,ModaoIcon:UT,FigmaIcon:MT,EditIcon:i0,CommentIcon:ol,RefreshIcon:IT,HelpIcon:Qp,CheckMarkIcon:Yp,TextIcon:Fa,RightArrowIcon:JN,TencentVideoIcon:OT,WebPageIcon:NT,UmlIcon:KT,DividingLineIcon:VT,HeadingH1Icon:eP,HeadingH2Icon:nP,HeadingH3Icon:rP,HeadingH4Icon:iP,HeadingH5Icon:oP,HeadingH6Icon:sP,HeadingH7Icon:lP,HeadingH8Icon:aP,CheckboxIcon:Zp,QuoteIcon:tC,LinkHrefIcon:cP,OrderedIcon:nC,UnorderedIcon:eC,CopyIcon:HT,CutIcon:jT,DeleteIcon:zT,LockBlockIcon:GT,UnLockBlockIcon:WT,InsertBeforeIcon:qT,InsertAfterIcon:XT,MentionIcon:QT,CircleAddIcon:JT,LoadingIcon:ZT,DragIcon:rC,UmlBrandIcon:o0,OnesLoadingIcon:ty,BoldIcon:ey,ItalicIcon:ny,UnderlineIcon:ry,LineThroughIcon:iy,SubscriptIcon:sy,SuperscriptIcon:ly,InlineCodeIcon:oy,ToMindMapIcon:ay,FitIcon:cy,FullScreenIcon:iC,ExitFullScreenIcon:uy,CaretDownIcon:fy,StatusIcon:dy},Symbol.toStringTag,{value:"Module"}));function hy(){const n=B("span",["editor-loading-icon"],null);return n.innerHTML=ty,n}const uct="";function fP(n,t){const e=B("button",["editor-checkbox-wrapper"],null);e.setAttribute("data-button-id",n),t!=null&&t.includes("checked")&&z(e,"checked"),t!=null&&t.includes("disabled")&&(e.disabled=!0);const r=B("span",["editor-checkbox"],e);return B("span",["editor-checkbox-inner"],r),e}const fct="",Ka=I("ui-command-bar-base"),dP={itemElementTag:"div",tippyArrow:!1},vx=class extends Re.TypedEmitter{constructor(e,r,i){var o,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",e=>{if(!!this.isVisible&&!e.isComposing&&!Gs(e.target)){if(this.subBar){this.subBar.handleDocumentKeydown(e);return}if(this.items.length!==0){if(e.key==="Escape"){this.close("cancelBar");return}if(e.key==="ArrowUp"){const r=this.getPrevItemIndex(this.getSelectedItemIndex());this.startPauseMouseEnter(),this.selectItem(this.items[r].id),e.preventDefault(),e.stopPropagation()}else if(e.key==="ArrowDown"){const r=this.getNextItemIndex(this.getSelectedItemIndex());this.startPauseMouseEnter(),this.selectItem(this.items[r].id),e.preventDefault(),e.stopPropagation()}else if(e.key==="ArrowRight"){const r=this.getSelectedItem();r&&r.children&&this.showSubCommandBar(r.childrenMenuId)}else if(e.key==="ArrowLeft")this.parentItem&&this.close("switchItem");else if(e.key==="Enter"){const r=this.getSelectedItemIndex();if(r===-1)return;const i=this.items[r],o=this.getItemElementById(i.id);o&&this.emit("click",this,i,o)}}}});m(this,"handleDocumentMouseDown",e=>{if(e.target instanceof Element&&!this.isInCommandBar(e.target)){const r=this.listeners("closing");for(let i=0;i<r.length;i++)if(r[i](this,e)===!1)return;this.close("clickBackground")}});m(this,"handleHidden",()=>{this.closeReason!=="fromHover"&&this.emit("close",this),this.close(null),ev(this.id)});m(this,"handleShow",()=>{this.popper&&(this.popper.setAttribute("data-command-bar-id",this.id),this.options.classes&&z(this.popper,...this.options.classes),this.options.refuseOverflow&&this.popper.classList.add("reference-hidden")),this.emit("show",this),this.options.disablePageScroll&&tv(this.id)});m(this,"lastEnterPauseTime",0);m(this,"startPauseMouseEnter",()=>{this.lastEnterPauseTime=Date.now()});m(this,"handleItemMouseEnter",e=>{if(Date.now()-this.lastEnterPauseTime<100)return;const r=this.getParentCommandItemElement(e.target);if(!r)return;const i=this.getItemElementId(r),o=this.getItemById(i);if(this.selectItem(i),o.manualShowChildren)return;const s=o.childrenMenuId||"";this.showSubCommandBar(s)});m(this,"handleItemMouseLeave",e=>{var i,o;const r=this.getParentCommandItemElement(e.target);!r||((o=(i=this.subBar)==null?void 0:i.parentItem)==null?void 0:o.id)!==this.getItemElementId(r)&&(ot(r,"selected"),this.emit("selectionChange",this,""))});m(this,"handleItemClick",e=>{const r=this.getParentCommandItemElement(e.target);if(!r)return;const i=this.getItemElementId(r),o=this.items.find(s=>s.id===i);if(!!o&&!(o.states&&o.states.indexOf("disabled")!==-1)){if(o.children&&o.children.length>0&&o.manualShowChildren){this.showSubCommandBar(o.childrenMenuId);return}o.element||(this.emit("click",this,o,r),this.options.autoClose&&this.close("clickItem"))}});m(this,"handleWheel",e=>{if(!this.options.disablePageScroll&&!document.querySelector(".editor-disable-scroll"))return;const r=e.target;if(!r||!(r instanceof Node))return;const i=r instanceof HTMLElement?r:r.parentElement;if(!i)return;const o=En(i);if(!ne(this.content,o)){e.stopPropagation(),e.preventDefault();return}e.deltaY<0?o.scrollTop===0&&(e.stopPropagation(),e.preventDefault()):e.deltaY>0&&o.scrollTop+o.clientHeight>=o.scrollHeight&&(e.stopPropagation(),e.preventDefault())});this.id=(o=i==null?void 0:i.id)!=null?o:Z(),this.options={...dP,...i},this.items=e,this.parentItem=(s=i==null?void 0:i.parentItem)!=null?s:null,this.closeable=r!=null?r:null,this.content=this.createCommandBarContent(e)}close(e){this.closeReason=e,this.subBar&&this.subBar.close(e),document.removeEventListener("keydown",this.handleDocumentKeydown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}click(e,r){this.emit("click",this,e,r)}createPopperOptions(){var i,o;const e={modifiers:[]},r=this.options.overflowBoundary;return r&&((i=e==null?void 0:e.modifiers)==null||i.push({name:"flip",options:{boundary:r,fallbackPlacements:["top","bottom"]}})),this.options.padding&&((o=e==null?void 0:e.modifiers)==null||o.push({name:"preventOverflow",options:{padding:this.options.padding}})),e}destroy(){var e;this.close(null),this.removeAllListeners(),(e=this.subBar)==null||e.destroy(),this.subBar=null,this.closeable=null,this.content.removeEventListener("wheel",this.handleWheel)}get isSubCommandBar(){return!!this.parentItem}updateItems(e){var i;this.subBar&&e.findIndex(s=>{var l,c;return s.id===((c=(l=this.subBar)==null?void 0:l.parentItem)==null?void 0:c.id)})===-1&&((i=this.subBar)==null||i.destroy(),this.subBar=null),this.items=e;const r=this.createCommandBarContent(e);this.content.innerHTML="",Array.from(r.children).forEach(o=>{this.content.appendChild(o)})}get popper(){return this.content.closest("[data-tippy-root]")}getSelectedItemIndex(){const e=this.getSelectedItem();return e?this.items.indexOf(e):-1}getPrevItemIndex(e){if(e<=0)return this.items.length-1;let r=e-1;for(;;){const i=this.items[r],o=i.type,l=!(i.states&&i.states.indexOf("disabled")!==-1);if(o!=="separator"&&o!=="section"&&l)return r;if(r-=1,r<0)return this.items.length-1}}getNextItemIndex(e){let r=e+1;for(;;){if(!this.items[r])return this.getNextItemIndex(-1);const i=this.items[r],o=i.type,l=!(i.states&&i.states.indexOf("disabled")!==-1);if(o!=="separator"&&o!=="section"&&l)return r;if(r+=1,r>this.items.length-1)return 0}}clearSelectedItem(){const e=this.getSelectedItem();if(!e)return;const r=this.getItemElementById(e.id);r&&ot(r,"selected")}selectItem(e){const r=this.getSelectedItem();if(r){if(r.id===e)return;const o=r.id,s=this.getItemElementById(o);s&&ot(s,"selected")}const i=this.getItemElementById(e);i?(z(i,"selected"),this.emit("selectionChange",this,i.getAttribute("data-id")||""),this.options.disableSelectedScroll||i.scrollIntoView({block:"nearest"})):this.emit("selectionChange",this,"")}showSubCommandBar(e){var s,l;const r=this.getSelectedItem();if(!r)return;if(this.subBar){if(((s=this.subBar.parentItem)==null?void 0:s.id)===r.id){r.manualShowChildren&&this.subBar.close("switchItem");return}this.subBar.destroy(),this.subBar=null}if(!r.children)return;const i=this.getItemElementById(r.id);if(!i)return;const o=vx.createSubCommandBar(r,(l=this.closeable)!=null?l:this,e?{id:e}:{});this.subBar=o,this.subBar.on("click",(c,d,h)=>{this.emit("click",c,d,h)}),this.subBar.on("close",()=>{var c;(c=this.subBar)==null||c.destroy(),this.subBar=null,ot(i,"active")}),r.beforePopup&&r.beforePopup(o),this.subBar.manualShow(i,this.getSubBarOptions(r)),z(i,"active")}isInCommandBar(e){if(!e||!(e instanceof Node))return!1;const r=this.getCommandBarRoot();return r&&ne(r,e)||ne(this.content,e)?!0:this.subBar?this.subBar.isInCommandBar(e):!1}createCommandItem(e){var o,s,l,c;let r=(o=this.options.itemElementTag)!=null?o:"div";e.element&&(r="div");const i=B(r,["command-item"],null);return i.setAttribute("data-id",e.id),e.type==="separator"?i.classList.add("separator"):e.type==="section"?(i.classList.add("section","text"),e.element&&(typeof e.element=="function"?i.appendChild(e.element(e)):i.appendChild(e.element))):((s=e.states)!=null&&s.includes("selected")&&i.classList.add("selected"),(l=e.states)!=null&&l.includes("checked")&&i.classList.add("checked"),(c=e.states)!=null&&c.includes("disabled")&&i.classList.add("disabled"),i.onclick=this.handleItemClick,i.onmouseenter=this.handleItemMouseEnter,i.onmouseleave=this.handleItemMouseLeave,e.element?typeof e.element=="function"?i.appendChild(e.element(e)):i.appendChild(e.element):i.classList.add("standard")),this.initItemElement(e,i),i}getItemById(e){const r=this.items.find(i=>i.id===e);return p(Ka,r,`can not find command item for id: ${e}`),r}getSelectedItem(){const e=this.content.querySelector(":scope >.editor-command-bar >.command-item.selected");if(e){const r=this.getItemElementId(e),i=this.items.find(o=>o.id===r);return p(Ka,i,`can not find command item for id: ${r}`),i}return null}getItemElementId(e){const r=e.getAttribute("data-id");return p(Ka,r,"no data-id attribute"),r}getItemElementById(e){const r=this.content.querySelector(`:scope >.editor-command-bar > .command-item[data-id="${e}"]`);return p(Ka,r,`no exists command item, id=${e}`),r}getParentCommandItemElement(e){if(!e||!(e instanceof Element))return null;if(Rt(e,"command-item"))return e;const r=e.closest(".command-item");return r||null}createCommandBarContent(e){this.content&&this.content.removeEventListener("wheel",this.handleWheel);const r=B("div",["editor-command-bar-root"],null);if(this.options.header){const o=B("div",["editor-command-bar-header"],null);if(this.options.header instanceof Function){const s=this.options.header();s&&o.appendChild(s)}else o.appendChild(this.options.header);this.header=o,this.header&&r.appendChild(this.header)}const i=B("div",["editor-command-bar"],r);if(e.forEach(o=>{var l;const s=this.createCommandItem(o);i.appendChild(s),o.element&&o.setCloseable&&o.setCloseable((l=this.closeable)!=null?l:this)}),this.options.footer){const o=B("div",["menu-item","editor-command-bar","footer"],null);if(this.options.footer instanceof Function){const s=this.options.footer();s&&o.appendChild(s)}else o.appendChild(this.options.footer);this.footer=o,this.footer&&r.appendChild(this.footer)}return(this.options.header||this.options.footer)&&z(r,"scrollable-bar"),this.initCommandBarElement(i),r.addEventListener("wheel",this.handleWheel,{passive:!1}),r}getSubBarOptions(e){var r;return{placement:(r=e.childrenPlacement)!=null?r:"right-start",offset:e.childrenOffset,arrow:e.childArrow}}static registerManualCommandBar(e,r){this.commandBarCreators.set(e,r)}static createSubCommandBar(e,r,i){var l;p(Ka,e.children&&e.children.length>0,"no item children");const o=(l=e.childrenType)!=null?l:"menu",s=this.commandBarCreators.get(o);return p(Ka,s,`no creator for command type: ${o}`),s(e,r,i)}static hasExistsCommandBar(){return!!document.querySelector("[data-command-bar-id]")}};let sl=vx;m(sl,"commandBarCreators",new Map),I("ui-command-bar");class s0 extends sl{constructor(){super(...arguments);m(this,"tippyInstance",null)}manualShow(e,r){var i,o,s;if(!this.isVisible){if(this.tippyInstance&&(this.tippyInstance.destroy(),this.tippyInstance=null),this.tippyInstance=Y6.default(e,{interactive:!0,content:this.content,trigger:"manual",triggerTarget:null,hideOnClick:!1,placement:(i=r==null?void 0:r.placement)!=null?i:"bottom-start",maxWidth:650,arrow:(o=r==null?void 0:r.arrow)!=null?o:this.options.tippyArrow,appendTo:document.body,onShow:this.handleShow,onHidden:this.handleHidden,theme:r==null?void 0:r.theme,getReferenceClientRect:r==null?void 0:r.getReferenceClientRect,offset:(s=r==null?void 0:r.offset)!=null?s:[0,0],popperOptions:this.createPopperOptions()}),r!=null&&r.point){const{x:l,y:c}=r.point;this.tippyInstance.setProps({getReferenceClientRect:()=>new DOMRect(l,c,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(e){var r;super.close(e),this.isVisible&&((r=this.tippyInstance)==null||r.hide())}destroy(){var e;(e=this.tippyInstance)==null||e.destroy(),this.tippyInstance=null,super.destroy()}getCommandBarRoot(){return this.content.closest("[data-tippy-root]")}get isVisible(){var e,r;return(r=(e=this.tippyInstance)==null?void 0:e.state.isVisible)!=null?r:!1}get popper(){return this.content.closest("[data-tippy-root]")}}const my=I("ui-base");class Va extends s0{constructor(t,e){var o;const i=[{id:(o=e==null?void 0:e.id)!=null?o:`popup-${Z()}`,name:"",element:t}];super(i,void 0,{disablePageScroll:!0,id:e==null?void 0:e.id})}initCommandBarElement(t){z(t,"popper")}initItemElement(t,e){}get popupContent(){const t=this.items[0];p(my,t,"no dialog item");const e=typeof t.element=="function"?t.element(t):t.element;return p(my,e,"no item element"),e}}const co=I("filterable-list");function gy(n){var e,r;const t=B("div",["list-item"],null);return t.setAttribute("data-id",n.id),t.appendChild(B("div",["list-item-text"],null,n.name)),(e=n.states)!=null&&e.includes("selected")&&(z(t,"selected"),Ms(Yp,["list-item-selected-icon"],t)),(r=n.states)!=null&&r.includes("disabled")&&z(t,"disabled"),t}function py(n){const t=B("div",["list-root"],null);return n.forEach(e=>{t.appendChild(gy(e))}),n.length||t.appendChild(gy({id:"placeholder",states:["disabled"],name:D.t("search.emptyTips")})),t}function Cy(n,t){return n.map(e=>({...e,states:t===e.id?["selected"]:[]}))}function hP(n,t){const e=B("div",["filterable-list"],null),r=B("div",["filter"],e),i=B("div",["filter-container"],r),o=B("input",["filter-input"],i);t&&t.placeholder&&(o.placeholder=t.placeholder);const s=B("div",["list"],e),l=py(Cy(n,t==null?void 0:t.initialSelectedId));return s.appendChild(l),e}function Ey(n,t,e){const r=n.querySelector(".list");p(co,r,"no list root");const i=py(Cy(t,e)),o=r.querySelector(".list-root");if(p(co,o,"no exists menu"),tu(o,i),e){const s=r.querySelector(".list-item.selected");s&&(p(co,s,"no selected menu item"),s.scrollIntoView({block:"nearest"}))}}class mP{constructor(t,e){m(this,"root");m(this,"visibleItems");m(this,"selectedId");m(this,"filter","");m(this,"onSelected",null);m(this,"handleKeydown",t=>{this.processKeyDown(t)});m(this,"handleInputChanged",()=>{const t=this.root.querySelector(".filter-input");p(co,t,"no input");const e=t.value.toLocaleLowerCase();this.setFilter(e)});m(this,"handleClick",t=>{this.processClick(t)});var r;this.items=t,this.options=e,this.root=hP(t,e),this.bindEvents(),this.selectedId=(r=e==null?void 0:e.initialSelectedId)!=null?r:"",this.visibleItems=t}bindEvents(){const t=this.root.querySelector(".filter-input");p(co,t,"no input"),t.addEventListener("keyup",this.handleInputChanged),t.addEventListener("keydown",this.handleKeydown),this.root.addEventListener("click",this.handleClick)}unbindEvents(){const t=this.root.querySelector(".filter-input");p(co,t,"no input"),t.removeEventListener("keyup",this.handleInputChanged),t.removeEventListener("keydown",this.handleKeydown),this.root.removeEventListener("click",this.handleClick)}destroy(){this.unbindEvents(),this.onSelected=null}getSelectedIndex(){return this.selectedId?this.visibleItems.findIndex(t=>t.id===this.selectedId):-1}setSelectedId(t){this.selectedId=t,Ey(this.root,this.visibleItems,t)}focus(){const t=this.root.querySelector(".filter-input");p(co,t,"no input"),t.focus()}moveSelectedItemIntoView(){const t=this.root.querySelector(".list-item.selected");t&&(p(co,t,"no selected menu item"),t.scrollIntoView({block:"nearest"}))}reset(){this.setFilter("");const t=this.root.querySelector(".filter-input");p(co,t,"no input"),t.value=""}setFilter(t){this.filter!==t&&(this.filter=t,this.visibleItems=this.items.filter(e=>e.name.toLocaleLowerCase().includes(t)),Ey(this.root,this.visibleItems,this.selectedId))}processClick(t){var s,l;const e=t.target;if(!(e instanceof HTMLElement))return;const r=e.closest(".list-item");if(!r)return;const i=(s=r.getAttribute("data-id"))!=null?s:"",o=(l=this.visibleItems.find(c=>c.id===i))!=null?l:null;this.onSelected&&this.onSelected(this,o)}processKeyDown(t){var e;if(t.key==="ArrowUp"){let r=this.getSelectedIndex();r===-1?r=this.visibleItems.length-1:r>0&&(r-=1);let i="";r!==-1&&(i=this.visibleItems[r].id),this.setSelectedId(i);return}if(t.key==="ArrowDown"){let r=this.getSelectedIndex();r===-1?r=0:r<this.visibleItems.length-1&&(r+=1);let i="";r!==-1&&(i=this.visibleItems[r].id),this.setSelectedId(i);return}if(t.key==="Enter"){const r=(e=this.visibleItems.find(i=>i.id===this.selectedId))!=null?e:null;this.onSelected&&this.onSelected(this,r)}}}class gP extends mP{constructor(e,r,i){super(e,i);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 Va(this.root)}destroy(){super.destroy(),this.onShow=null,this.onHide=null}show(e){this.reset(),this.popup.manualShow(e,{theme:"dropdown-list"}),this.focus(),this.moveSelectedItemIntoView()}processKeyDown(e){super.processKeyDown(e),(e.key==="Esc"||e.key==="Enter")&&this.popup.close("cancelBar")}processClick(e){super.processClick(e);const r=e.target;!(r instanceof HTMLElement)||!r.closest(".list-item")||this.popup.close("clickItem")}}const dct="",hct="";function pP(n,t){const e=document.createElement("div");e.classList.add("toast","show"),t!=null&&t.theme&&e.setAttribute("data-theme",t.theme),t!=null&&t.id&&e.setAttribute("data-id",t.id),t!=null&&t.html?e.innerHTML=n:e.textContent=n,t!=null&&t.position&&(e.style.left=`${t.position.x}px`,e.style.top=`${t.position.y}px`,e.classList.add("positioned")),document.body.appendChild(e),setTimeout(()=>{e.classList.remove("show"),setTimeout(()=>{e.remove()},500)},(t==null?void 0:t.duration)||3e3)}function CP(n,t){var e,r;if(z(t,"menu-item"),!n.element){if(n.type==="section"){const i=B("div",["section-name"],null,n.name);t.appendChild(i)}else if(n.type!=="separator"){if(n.icon){const o=B("div",["menu-item-icon"],null);n.icon&&(o.innerHTML=n.icon),t.appendChild(o)}const i=B("div",["menu-item-name","text"],null);if(B("span",[],i,n.name),n.ellipsisTooltip&&(t.setAttribute("data-editor-tooltip-allow-markdown","true"),t.setAttribute("data-editor-tooltip-offset-y","25"),t.setAttribute("data-editor-tooltip-placement","right"),t.setAttribute("data-editor-tooltip-common",`<div style="word-break: break-word;">${n.ellipsisTooltip}</div>`)),((e=n.states)==null?void 0:e.includes("disabled"))&&n.disableReason&&(t.setAttribute("data-editor-tooltip-maxwidth","800"),t.setAttribute("data-editor-tooltip-placement","right"),t.setAttribute("data-editor-tooltip-common",n.disableReason)),t.appendChild(i),n.subText&&B("div",["item-subtext","text"],t,n.subText),n.children&&!n.element){const o=B("div",["menu-item-sub-indicator"],null);o.innerHTML=Gp,t.appendChild(o)}if((r=n.states)!=null&&r.includes("checked")){const o=B("div",["menu-item-checked-icon"],null);o.innerHTML=Yp,t.appendChild(o)}}}}class Zo extends s0{constructor(t,e,r){super(t,e,{autoClose:!0,disablePageScroll:!0,...r})}manualShow(t,e){const r={theme:"menu",...e};super.manualShow(t,r)}initCommandBarElement(t){z(t,"menu")}initItemElement(t,e){CP(t,e)}}function EP(n,t,e){var r;return new Zo((r=n.children)!=null?r:[],t,{...e,parentItem:n})}function xy(n,t,e){t.setAttribute("data-button-id",n.id),e.tooltipId&&n.name&&!n.disableTooltip&&(t.setAttribute(`data-editor-tooltip-${e.tooltipId}`,n.name),n.desc&&t.setAttribute(`data-editor-tooltip-desc-${e.tooltipId}`,n.desc));const r=t;if(!n.element)if(n.icon){const i=B("span",["toolbar-item-icon-container"],r);n.icon.trim().startsWith("<")?i.innerHTML=n.icon:i.innerText=n.icon}else{const i=B("span",["toolbar-item-name-container"],r);i.innerText=n.name}if(n.dropdown){t.setAttribute("data-dropdown","true");const i=B("span",["toolbar-item-dropdown-container"],r);i.innerHTML=Wh}n.states&&(n.states.indexOf("checked")!==-1&&z(r,"checked"),n.states.indexOf("disabled")!==-1&&(r.disabled=!0))}class Pu extends s0{constructor(t,e,r){super(t,e,{itemElementTag:"button",tippyArrow:!1,...r})}getSubBarOptions(t){var i,o;const e=()=>{const s=this.getItemElementById(t.id),c=this.content.getBoundingClientRect(),d=s.getBoundingClientRect();return new DOMRect(d.left,c.top,d.width,c.height)};return{placement:(i=t.childrenPlacement)!=null?i:"top",getReferenceClientRect:e,offset:(o=t.childrenOffset)!=null?o:[0,4]}}manualShow(t,e){const r={theme:"toolbar",...e};super.manualShow(t,r)}initCommandBarElement(t){z(t,"toolbar")}initItemElement(t,e){xy(t,e,this.options)}}function xP(n,t,e){var r;return new Pu((r=n.children)!=null?r:[],t,{...e,parentItem:n})}class AP extends sl{constructor(t,e,r){super(e,void 0,r),t.appendChild(this.content),document.addEventListener("keydown",this.handleDocumentKeydown),document.addEventListener("mousedown",this.handleDocumentMouseDown)}initCommandBarElement(t){z(t,"toolbar","fixed")}initItemElement(t,e){xy(t,e,this.options)}close(){this.clearSelectedItem(),this.subBar&&(this.subBar.close("cancelBar"),this.subBar=null)}destroy(){this.content.remove(),super.destroy(),document.removeEventListener("keydown",this.handleDocumentKeydown),document.removeEventListener("mousedown",this.handleDocumentMouseDown)}getCommandBarRoot(){return this.content.parentElement}get isVisible(){return!0}}const mct="";sl.registerManualCommandBar("menu",EP),sl.registerManualCommandBar("toolbar",xP);const gct="",Ay=I("ui-base");class Fu extends s0{constructor(e,r){super(Fu.getCommandItems(e,r),void 0,{disablePageScroll:!0,...r});m(this,"handleDocumentMouseDown",e=>{})}initCommandBarElement(e){z(e,"dialog","manual")}initItemElement(e,r){}show(e,r){this.manualShow(e,{...r,theme:"light"})}get dialogContent(){const e=this.items[0];p(Ay,e,"no dialog item");const r=e.element;return p(Ay,r,"no item element"),r}static getCommandItems(e,r){var s;return[{id:(s=r==null?void 0:r.id)!=null?s:`manual-dialog-${Z()}`,name:"",element:e}]}}const pct="",bP=I("ui-base");class by{constructor(t){m(this,"menu");m(this,"currentText","");m(this,"handleSearchText");m(this,"handleClick",Me.default((t,e)=>{this.options.onClickItem(this,e)},300,{leading:!0,trailing:!1}));m(this,"handleShow",t=>{});m(this,"handleClose",()=>{var t,e;(e=(t=this.options).onClose)==null||e.call(t)});m(this,"handleKeydown",t=>{this.menu.handleDocumentKeydown(t)});this.options=t,this.menu=new Zo([],void 0,{id:t.id,header:t.header,footer:t.footer,disableSelectedScroll:t.disableSelectedScroll}),this.menu.addListener("click",this.handleClick),this.menu.addListener("close",this.handleClose),this.menu.addListener("show",this.handleShow),this.options.wait?this.handleSearchText=Me.default(async e=>{this.handleSearchTextPure(e)},this.options.wait):this.handleSearchText=this.handleSearchTextPure}setItems(t){if(this.menu.updateItems(t),t.length>0){const e=t.find(r=>r.type!=="section"&&r.type!=="separator");e&&this.menu.selectItem(e.id)}}async popup(t,e){var i,o;if(!(e!=null&&e.noEvent)&&((o=(i=this.options).onShow)==null?void 0:o.call(i,this))===!1)return;this.menu.manualShow(t),this.options.placeholder&&this.showPlaceholder();const r=await this.options.queryItems(this,"");this.highlightText("",r),this.setItems(r)}showLoading(){!this.options.showLoading||(this.options.loadingElement?this.setItems([{id:"loading",name:"",element:this.options.loadingElement,states:["disabled"]}]):this.setItems([{id:"loading",name:"loading",states:["disabled"]}]))}showPlaceholder(){this.setItems([{id:"placeholder",name:"enter text to search",states:["disabled"]}])}showNoResultMessage(t){if(this.options.noResultMessage){const e={name:"",id:"placeholder",states:["disabled"]};typeof this.options.noResultMessage=="string"?e.name=this.options.noResultMessage:(this.options.noResultMessage instanceof HTMLElement||typeof this.options.noResultMessage=="function")&&(e.element=this.options.noResultMessage),this.setItems([e])}else this.setItems([{id:"placeholder",name:this.options.emptyPlaceholder||D.t("search.emptyTips"),states:["disabled"]}])}close(){this.menu.close("cancelBar")}get isVisible(){return this.menu.isVisible}destroy(){this.menu.close("cancelBar"),this.menu.removeAllListeners(),this.menu.destroy()}isInCommandBar(t){return this.menu.isInCommandBar(t)}async handleSearchTextPure(t){this.currentText=t;const e="auto-suggest";try{await Sr.lock(e),this.showLoading();const r=this.currentText,i=await this.options.queryItems(this,t);if(this.currentText===r&&(this.currentText=""),i.length===0){this.showNoResultMessage(t);return}this.setItems(i),this.options.highlight&&this.highlightText(r.replace(/^\s+|\s+$/g,""),i)}finally{Sr.release(e)}}highlightText(t,e){bP.debug(`highlight menu text: ${t}`);const r=this.menu.content,i=(s,l)=>{if(!l)return s;let c="";const d=l.length,h=l.toLocaleLowerCase();let C=0;for(C=0;C<=s.length-d;C){let E=s.substring(C,C+d);if(E.toLocaleLowerCase()===h){C+=d;const A=s.charAt(C);let v=!1;E.endsWith(" ")&&(v=!0,E=E.trimEnd()),c+=`<span class="highlight">${E}${A===" "||v?" ":""}</span>`}else c+=s.charAt(C),C++}return C<s.length&&(c+=s.substring(C)),c},o=s=>{if(Rt(s,"text")){const l=e==null?void 0:e.find(h=>h.id===s.getAttribute("data-id"));if(l&&l.element)return;const c=s.textContent;if(!c)return;const d=i(c,t);s.innerHTML=d;return}Array.from(s.children).forEach(o)};o(r)}}class oC{constructor(t,e){m(this,"root");m(this,"input");m(this,"text");m(this,"dropdownIcon");m(this,"clearIcon");m(this,"autoSuggest");m(this,"labels");m(this,"items",[]);m(this,"handleClick",()=>{this.autoSuggest.popup(this.root),this.input.focus()});m(this,"handleClickItem",(t,e)=>{var r,i;(i=(r=this.options)==null?void 0:r.onClickItem)==null||i.call(r,e)});m(this,"handleInput",()=>{this.autoSuggest.handleSearchText(this.input.value),this.updatePlaceholder()});m(this,"handleClear",t=>{var e,r;this.clear(),this.autoSuggest.handleSearchText(""),t.preventDefault(),t.stopPropagation(),(r=(e=this.options)==null?void 0:e.onClear)==null||r.call(e)});m(this,"handleQueryItems",async(t,e)=>this.items.filter(i=>{var o;return(o=this.options)!=null&&o.filter?this.options.filter(i,e):!0}));m(this,"handleShow",()=>{z(this.root,"active"),this.input.focus()});m(this,"handleClose",()=>{var t,e;(e=(t=this.options)==null?void 0:t.onClose)==null||e.call(t),ot(this.root,"active")});var c,d,h,C,E;this.options=e,this.labels=(d=(c=this.options)==null?void 0:c.labels)!=null?d:[];const{root:r,input:i,text:o,clearIcon:s,dropdownIcon:l}=oC.createDropdown(t,this.labels);this.root=r,this.input=i,this.text=o,this.clearIcon=s,this.dropdownIcon=l,this.autoSuggest=new by({id:(e==null?void 0:e.popupId)||"dropdown-auto-suggest",header:(h=this.options)==null?void 0:h.header,onClickItem:this.handleClickItem,queryItems:this.handleQueryItems,onClose:this.handleClose,onShow:this.handleShow,highlight:e==null?void 0:e.highlight,emptyPlaceholder:e==null?void 0:e.emptyPlaceholder,disableSelectedScroll:e==null?void 0:e.disableSelectedScroll}),this.items=(E=(C=this.options)==null?void 0:C.items)!=null?E:[],this.root.addEventListener("click",this.handleClick),this.input.addEventListener("input",this.handleInput),this.clearIcon.addEventListener("click",this.handleClear)}close(){this.autoSuggest.close()}destroy(){this.input.removeEventListener("input",this.handleInput),this.root.removeEventListener("click",this.handleClick),this.clearIcon.removeEventListener("click",this.handleClear),this.autoSuggest.destroy()}updateItems(t){this.items=t,this.autoSuggest.handleSearchText("")}setText(t){this.text.innerText=t,this.input.value=t,this.updatePlaceholder()}clear(){this.setText(""),this.setLabels([])}setLabels(t){this.labels=t,this.updateLabels()}static createDropdown(t,e){const r=B("div",["editor-dropdown","empty"],t),i=B("input",["dropdown-input"],r),o=B("div",["dropdown-text"],r),s=B("div",["dropdown-labels"],r);for(let d=0;d<e.length;d+=1){const h=e[d];B("span",["dropdown-label"],s,h)}const l=B("div",["dropdown-clear-icon"],r);l.innerHTML=YT;const c=B("div",["dropdown-icon"],r);return c.innerHTML=Wh,{root:r,input:i,text:o,clearIcon:l,dropdownIcon:c}}updateLabels(){const t=this.root.querySelector(".dropdown-labels");if(t){t.innerHTML="";for(let e=0;e<this.labels.length;e+=1){const r=this.labels[e];B("span",["dropdown-label"],t,r)}}}updatePlaceholder(){var t;if(this.input.value===""){const e=(t=this.options)==null?void 0:t.placeholder;e&&(this.input.placeholder=e,this.text.textContent=e),z(this.root,"empty")}else ot(this.root,"empty")}}const vP=[-1,6,0,1,2,3,4,5],BP=[-1,6,0,1,2,3,4,5,14,13,7,8,9,10,11,12],vy=I("color-palette");function By(n,t,e,r){p(vy,n>0,"no color in palette");const i=t||1;p(vy,i>0,`invalid palette rows: ${i}`);const o=n/i,s=B("div",["palette-container",r],null);for(let l=0;l<i;l++){const c=B("div",["palette-container-row"],s);for(let d=0;d<o;d++){const h=e(l*o+d);c.appendChild(h)}}return s}function TP(n){const t=B("button",["color-button"],null),e=vP[n];return t.setAttribute("data-color-index",`${e}`),t.innerHTML=zp,t}function yP(n){const t=B("button",["background-color-button"],null),e=BP[n];return t.setAttribute("data-color-index",`${e}`),t}function kP(){const n=B("div",["clear-button-container"],null),t=B("button",["clear-button"],n);return t.innerText=D.t("colorPalette.reset"),n}function RP(n){const t=B("div",["color-palette"],null);return n.color!==!1&&(B("div",["bar-desc"],t,D.t("colorPalette.colorDesc")),t.appendChild(By(8,1,TP,"color"))),n.backgroundColor!==!1&&(B("div",["bar-desc"],t,D.t("colorPalette.backgroundDesc")),t.appendChild(By(16,2,yP,"background-color"))),n.clearColorButton!==!1&&t.appendChild(kP()),t}function wP(n,t,e){const r=t==="color"?"color":"background-color",i=n.querySelector(`.${r} button.selected`);i&&ot(i,"selected"),e===null&&(e=-1);const o=n.querySelector(`.${r} button[data-color-index="${e}"]`);o&&z(o,"selected")}const Cct="",SP={};class LP extends Re.TypedEmitter{constructor(e=SP){super();m(this,"root");m(this,"handleClick",e=>{const r=e.target;if(!r||!(r instanceof Element))return;const i=r.closest("button");if(!i)return;if(Rt(i,"clear-button")){this.setColor("backgroundColor",null),this.setColor("color",null),this.emit("onClick","clearColor",0);return}const o=i.getAttribute("data-color-index");if(!o)return;const s=Number.parseInt(o,10);Number.isNaN(s)||(Rt(i,"color-button")?s===-1?(this.setColor("color",null),this.emit("onClick","clearColor",1)):(this.setColor("color",s),this.emit("onClick","color",s)):s===-1?(this.setColor("backgroundColor",null),this.emit("onClick","clearColor",2)):(this.setColor("backgroundColor",s),this.emit("onClick","backgroundColor",s)))});this.options=e,this.root=RP(e),this.root.addEventListener("click",this.handleClick)}destroy(){this.removeAllListeners(),this.root.removeEventListener("click",this.handleClick)}setColor(e,r){wP(this.root,e,r)}}class Ty{constructor(t,e){m(this,"name","Color Palette");m(this,"element");m(this,"palette");m(this,"closeable",null);this.id=t,this.palette=new LP(e),this.element=this.palette.root}setCloseable(t){this.closeable=t}destroy(){this.palette.destroy(),this.closeable=null}}function IP(){const n=B("button",["color-button"],null);return n.innerHTML=zp,n}function sC(n,t){const[e,r]=t;e===null?n.removeAttribute("data-color"):n.setAttribute("data-color",`${e}`),r===null?n.removeAttribute("data-background-color"):n.setAttribute("data-background-color",`${r}`)}class yy extends Re.TypedEmitter{constructor(e){super();m(this,"id","text-color-item");m(this,"name",D.t("colorPalette.name"));m(this,"dropdown",!0);m(this,"manualShowChildren",!0);m(this,"children",[]);m(this,"element");m(this,"colorPaletteItem");m(this,"latestColors",[null,null]);m(this,"handlePaletteClick",(e,r)=>{this.emit("onClick",e,r)});m(this,"setLatestColors",(e,r)=>{e==="color"||e==="backgroundColor"?e==="color"?this.latestColors[0]=r:this.latestColors[1]=r:this.latestColors=[null,null],sC(this.element,this.latestColors)});m(this,"beforePopup",()=>{this.updatePaletteColor(this.latestColors),this.emit("beforePopup")});this.editor=e,this.colorPaletteItem=new Ty("text-color-palette-item"),this.colorPaletteItem.palette.addListener("onClick",this.handlePaletteClick),this.children.push(this.colorPaletteItem),this.element=IP()}destroy(){this.colorPaletteItem.destroy()}updatePaletteColor(e){this.colorPaletteItem.palette.setColor("color",e[0]),this.colorPaletteItem.palette.setColor("backgroundColor",e[1]),this.latestColors=e,sC(this.element,this.latestColors)}updateButtonColor(e){this.latestColors=e,sC(this.element,this.latestColors)}}const Ect="";function l0(n,t){const e=B("div",["editor-input-wrap"],n);if(t!=null&&t.className&&z(e,t==null?void 0:t.className),t.label){const s=B("div",["editor-input-label"],e);B("span",[],s,t.label),t.required&&z(s,"required")}const r=B("div",["editor-input-container"],e),i=B("input",["editor-input"],null);if(t.placeholder&&(i.placeholder=t.placeholder),t.defaultValue&&(i.value=t.defaultValue),t.maxLength&&(i.maxLength=t.maxLength),t.maxLength){const s=B("div",["editor-input-suffix"],r);B("span",[],s,`${i.value.length} / ${t.maxLength}`),i.addEventListener("input",l=>{const c=l.target;s.innerText=`${c.value.length} / ${t.maxLength}`})}r.appendChild(i);const o=B("div",["editor-input-error"],e);return i.addEventListener("input",s=>{var l;(l=t.onChange)==null||l.call(t,s),ot(e,"error")}),i.addEventListener("keydown",s=>{var l;(l=t.onKeyDown)==null||l.call(t,s)}),{getField:()=>i,getInputValue:()=>i.value,setFieldError:s=>{z(e,"error"),o.innerText=s},focus:()=>{setTimeout(()=>{i.focus()})}}}function lC(n){const t=document.getSelection();if(!t)return!0;const e=t.focusNode;if(!e)return!0;const r=t.focusOffset,i=e.childNodes[r];if(!i)return!0;if(i instanceof HTMLElement){const o=i.tagName.toLowerCase();if(i===n.input.inputElement)return!0;if(o==="input"||o==="textarea")return!1}return!0}class DP extends by{constructor(e,r){super(r);m(this,"handleClose",()=>{var e,r;lC(this.editor)&&this.editor.focus(),(r=(e=this.options).onClose)==null||r.call(e)});this.editor=e,this.editorOptions=r}async popupInEditor(e,r,i){var d,h;if(((h=(d=this.editorOptions).onShow)==null?void 0:h.call(d,this,e,r,i))===!1)return;this.options.showLoading&&this.showLoading();const o=this.editor.getBlockByIndex(e,r);if(!ne(this.editor.rootContainer,o)||dt(this.editor,o)<i)return;const s=qi(this.editor,o,Te(this.editor,o,i));if(s.length===0)return;const l=s[0],c=Yi(this.editor,o,"editor-auto-suggest-menu",l);super.popup(c,{noEvent:!0})}}const aC=I("auto-suggest-menu");class cC{constructor(t,e){m(this,"order",100);m(this,"menu");m(this,"anchor",null);m(this,"close",()=>{this.menu.close()});m(this,"handleSelectionChanged",t=>{var r,i;if(!((r=this.menu)!=null&&r.isVisible))return;const e=t.selection.range.start;if(e.isSimple()&&e.blockId===((i=this.anchor)==null?void 0:i.blockId)&&e.offset>=this.anchor.offset){const o=t.getBlockById(e.blockId);if(fe(_n(bn(t,o),e.offset).left).startsWith(this.anchor.leftText))return}this.menu.close()});m(this,"deleteTrigger",()=>{const t=this.editor,e=t.selection.range.start;if(!e.isSimple()||!this.anchor)return!1;const{blockId:r,offset:i}=e,o=t.getBlockById(r),s=fe(ph(t,o,i));if(p(aC,this.anchor,"no anchor"),!s.startsWith(this.anchor.leftText))return!1;const l=this.anchor.offset-this.anchor.trigger.length,c=i-l;return t.selection.selectBlock(o,l),c&&(t.deleteTextFromBlock(o,l,c),this.anchor.offset-=this.anchor.trigger.length),this.anchor.trigger.length||this.menu.close(),!0});m(this,"onClose",()=>{var t,e;(e=(t=this.options).onClose)==null||e.call(t)});m(this,"onShow",(t,e,r,i)=>{var o;if((o=this.options)!=null&&o.onShow)return this.options.onShow(this,e,r,i)});m(this,"onClickItem",(t,e)=>{!this.anchor||(this.options.autoDeleteTrigger&&this.deleteTrigger(),this.options.onClickItem(this,e,this.anchor))});m(this,"queryItems",(t,e)=>this.options.queryItems(this,e));m(this,"renderMenuItem",(t,e)=>{var i,o;return(o=(i=this.options).renderMenuItem)==null?void 0:o.call(i,this,e)});m(this,"hasExistsMenuThemeCommandBar",()=>!!document.querySelector('div.tippy-box[data-theme="menu"]'));this.editor=t,this.options=e,this.menu=new DP(t,{id:e.id,showLoading:e.showLoading,loadingElement:e.loadingElement,placeholder:e.placeholder,header:e.header,footer:e.footer,wait:e.wait,noResultMessage:e.noResultMessage,highlight:e.highlight,onClose:this.onClose,onShow:this.onShow,onClickItem:this.onClickItem,queryItems:this.queryItems,renderMenuItem:this.renderMenuItem}),t.input.addHandler(this),t.addListener("selectionChanged",this.handleSelectionChanged)}handleBeforeKeyDown(t,e){var r;return!((r=this.menu)!=null&&r.isVisible)||Ug(e.key)?!1:Yb(e)&&!Ps(e)?(setTimeout(()=>{this.resetItems()}),!1):Og(e)?(this.menu.close(),!0):(this.menu.handleKeydown(e),!0)}popup(t,e,r,i){this.anchor={blockId:st(t),offset:e,leftText:r,trigger:i};const o=ft(rt(t)),s=bt(t);this.menu.popupInEditor(o,s,e)}handleAfterInsertText(t,e,r,i,o){var h,C;const s=t.selection.range.start;if(!s.isSimple())return!1;const l=t.getBlockByIndex(e,r);if(Gi(l))return!1;const{blockId:c,offset:d}=s;if(st(l)!==c)return!1;if((h=this.menu)!=null&&h.isVisible)this.resetItems();else if(this.options.trigger.indexOf(o)!==-1){if(i>0&&this.options.needSpaceBeforeTrigger&&(((C=t.getBlockData(l).text)==null?void 0:C.reduce((R,L)=>R+L.insert,""))||"")[i-1].trim().length!==0||this.hasExistsMenuThemeCommandBar())return!1;const E=fe(ph(t,l,d));this.popup(l,d,E,o)}return!1}handleUpdateCompositionText(t,e,r,i,o){var d;const s=t.selection.range.start;if(!s.isSimple())return!1;const{blockId:l}=s,c=t.getBlockByIndex(e,r);return st(c)!==l||(d=this.menu)!=null&&d.isVisible&&this.resetItems(),!1}resetItems(){var l;if(!((l=this.menu)!=null&&l.isVisible))return;const t=this.editor,e=t.selection.range.start;if(!e.isSimple())return;const{blockId:r,offset:i}=e,o=t.getBlockById(r),s=fe(ph(t,o,i));if(p(aC,this.anchor,"no anchor"),s.startsWith(this.anchor.leftText)){const c=s.substring(this.anchor.leftText.length);aC.debug(`search text: ${c}`),this.menu.handleSearchText(c)}}destroy(){var t;this.editor.input.removeHandler(this),this.editor.removeListener("selectionChanged",this.handleSelectionChanged),(t=this.menu)==null||t.destroy()}}function _P(){const n={};for(let t=1;t<=8;t++)n[`heading-${t}`]={shortcut:`/h${t}`};return n}const MP={"insert-hr":{shortcut:"/hr"},"insert-uml":{shortcut:"/uml"},"insert-table":{shortcut:"/table"},"insert-image":{shortcut:"/image"},"insert-code":{shortcut:"/code"},"insert-link":{shortcut:"/link"},"insert-drawio":{shortcut:"/uml"},"insert-video":{shortcut:"/video"},"insert-audio":{shortcut:"/audio"},"insert-math":{shortcut:"/math"},"insert-webPage":{shortcut:"/web"},"insert-bilibili":{shortcut:"/bilibili"},"insert-youku":{shortcut:"/youku"},"insert-figma":{shortcut:"/figma"},"insert-modao":{shortcut:"/modao"},"insert-tencent":{shortcut:"/tencent"},"insert-unordered":{shortcut:"/bl"},"insert-ordered":{shortcut:"/nu"},"insert-checkbox":{shortcut:"/todo"},"insert-quote":{shortcut:"/quote"},..._P()};function Bn(n){var t;return(t=MP[n])==null?void 0:t.shortcut}function UP(n){var t;return(t=n.subText)!=null?t:""}const Ai=I("table-dom");function bi(n){return`${st(n)}_scroll`}function Ve(n){const t=n.querySelector("div[data-type=table-content] >table");return p(Ai,t instanceof HTMLTableElement,"invalid table"),t}function vi(n,t){const r=n.getCustom(bi(t)).contentElement.firstElementChild;p(Ai,r instanceof HTMLElement,"invalid table content");let i=r.querySelector(":scope >div[data-type=table-tools]");return i||(i=B("div",[],r),i.setAttribute("data-type","table-tools"),n.domEvents.addEventListener(i,"dblclick",(o,s)=>s.stopPropagation()),n.domEvents.addEventListener(i,"click",(o,s)=>{s.detail===3&&s.stopPropagation()})),p(Ai,i,"no table tools"),i}function OP(n,t){return n.findCustom(bi(t))?vi(n,t):null}function ky(n){const t=[];return Array.from(n.rows).forEach(e=>{t.push(...Array.from(e.cells))}),t}function Ku(n){const t=n.querySelector(":scope div[data-type=editor-container]");return p(Ai,t,"no child container in cell"),t}function NP(n){const r=ky(n).map(i=>{const o=Ku(i),s=ft(o),l=i.colSpan,c=i.rowSpan;return`${s}/${l}/${c}`}).join();return kd.default(r)}function $e(n){return St(n)==="table"}function uC(n){const t=rt(n);if(Xt(t))return null;const e=et(t);return p(Ai,e,"no parent block"),$e(e)?t:uC(e)}function uo(n){if($e(n))return n;const t=rt(n);if(Xt(t))return null;const e=et(t);return p(Ai,e,"no parent block"),$e(e)?e:uo(e)}function PP(n,t){const e=n.querySelector("colgroup");p(Ai,e,"no colgroup");const r=e.children[t];return p(Ai,r,"no col"),p(Ai,r instanceof HTMLTableColElement,`invalid col: ${r.tagName}`),r}function Ry(n){try{return Ve(n),!0}catch{return!1}}function FP(n){return re(n).querySelector(":scope > .block-helper")}function wy(n){const t=et(n.contentElement);p(Ai,t,"no block");const e=FP(t);if(e){const o=Math.min(n.contentElement.offsetLeft+29,n.rootElement.scrollLeft),s=t.getBoundingClientRect().width;e.style.right=`${o+s+5}px`}}const zr=I("doc-table-grid");class KP{constructor(t){m(this,"_cells",[]);for(let e=0;e<t;e++)this._cells.push(void 0)}cols(){return this._cells.length}setCell(t,e){p(zr,t>=0&&t<this.cols(),`set cell, invalid col: ${t}`),this._cells[t]=e}getCell(t){p(zr,t>=0&&t<this.cols(),`get cell, invalid col: ${t}`);const e=this._cells[t];return p(zr,e,"get cell, no cell"),e}getCellAllowEmpty(t){return p(zr,t>=0&&t<this.cols(),`get cell, invalid col, ${t}`),this._cells[t]}getNextNonVirtualCell(t){return this._cells.slice(t+1).find(e=>!e.virtual)}forEach(t){this._cells.forEach(t)}}class a0{constructor(t){m(this,"_data");m(this,"_rows");this._data=t,this._rows=[];for(let e=0;e<this.rowCount;e++)this._rows.push(new KP(this.colCount));this.fillGrid()}get rowCount(){return this._data.rows}get colCount(){return this._data.cols}getNextEmptyCell(t,e){let r=t,i=e;for(;;){if(r+=1,r===this.colCount&&(r=0,i+=1),i>=this.rowCount)return null;if(this._rows[i].getCellAllowEmpty(r)===void 0)return{col:r,row:i}}}fillGrid(){const t=this._data.children;p(zr,t,"no children");let e=0,r=0;t.forEach((i,o)=>{const s=this._data[`${i}_colSpan`]||1,l=this._data[`${i}_rowSpan`]||1;for(let d=0;d<l;d++)for(let h=0;h<s;h++)this._rows[r+d].setCell(e+h,{col:e,row:r,containerId:i,virtual:h!==0||d!==0,colSpan:s,rowSpan:l});const c=this.getNextEmptyCell(e,r);c?(e=c.col,r=c.row):p(zr,o===t.length-1,`invalid table data, no next empty cell: ${JSON.stringify(this._data)}`)}),this._rows.forEach(i=>{i.forEach(o=>{p(zr,o,"no cell"),p(zr,o.containerId,"no containerId")})})}getCell(t){const{col:e,row:r}=t,i=this._rows[r];p(zr,i,`get cell, no row: ${r}`);const o=i.getCell(e);return p(zr,o,`get cell, no cell: ${e}`),o}getRow(t){const e=this._rows[t];return p(zr,e,`get row, no row: ${t}`),e}forEach(t){this._rows.forEach(t)}}const c0=I("table-data");function VP(n){const t=n.firstElementChild;return p(c0,t,"no child element for cell"),p(c0,Wi(t),"cell first child is not a container"),p(c0,Mr(t),"cell first child is not a container"),t}function $P(n){const t=et(n);p(c0,t,"no parent block for table");const e=[],r={};Array.from(n.rows).forEach(l=>{Array.from(l.cells).forEach(c=>{const d=VP(c),h=ft(d);e.push(h),(c.colSpan>1||c.rowSpan>1)&&(r[`${h}_colSpan`]=c.colSpan,r[`${h}_rowSpan`]=c.rowSpan)})});const i=n.rows.length,o=Array.from(n.rows[0].cells).map(l=>l.colSpan).reduce((l,c)=>l+c,0);return{id:st(t),type:St(t),rows:i,cols:o,children:e,colsWidth:Array(o).fill(100),...r}}function ll(n){return new a0(n)}function HP(n){return ll($P(n))}const Qe=I("table-grid"),jP=60;class zP{constructor(t,e){m(this,"containerId");m(this,"row");m(this,"col");m(this,"colSpan");m(this,"rowSpan");m(this,"virtual");m(this,"table");this.table=t,this.containerId=e.containerId,this.row=e.row,this.col=e.col,this.colSpan=e.colSpan,this.rowSpan=e.rowSpan,this.virtual=e.virtual}get cell(){const e=this.container.closest("td");return p(Qe,e,"no parent cell for child container"),e}get container(){const t=this.table.querySelectorAll(`[data-container-id=${this.containerId}]`);p(Qe,t.length===1,"containers !== 1"),p(Qe,Wi(t[0]),"not a container");const e=t[0];return p(Qe,Mr(e),"not a child container"),e}}class GP{constructor(t,e){m(this,"_cells",[]);e.forEach(r=>{this._cells.push(new zP(t,r))})}get cells(){return this._cells}getCell(t){return p(Qe,t<this._cells.length,"get cell, invalid col"),this._cells[t]}getNextNonVirtualCell(t){return this._cells.slice(t+1).find(e=>!e.virtual)}getSpannedCell(){return this._cells.find(t=>t.virtual||t.colSpan>1||t.rowSpan>1)}}const Bx=class{constructor(t){m(this,"_rows",[]);this.table=t,HP(t).forEach(i=>{this._rows.push(new GP(t,i))});const r=this.colCount;this._rows.forEach(i=>{p(Qe,i.cells.length===r,"row.cells.length !== colCount")})}get rowCount(){return this._rows.length}get colCount(){return this._rows.length===0?0:(p(Qe,this.rowCount>0,"rowCount <= 0"),this.getRow(0).cells.length)}getRow(t){return this._rows[t]}getCell(t){const e=this.getRow(t.row);return p(Qe,e,"no row"),e.getCell(t.col)}getCellContainer(t){return this.getCell(t).container}getFirstCellContainer(){return this.getCellContainer({row:0,col:0})}getLastCellContainer(){const t=this.rowCount-1,e=this.colCount-1;return this.getCellContainer({row:t,col:e})}getColumnCells(t){p(Qe,t>=0&&t<this.colCount,"colIndex out of range");const e=this.rowCount,r=[];for(let i=0;i<e;i++){const o=this.getCell({row:i,col:t});r.push(o)}return r}toRealCells(t){const e=[];return t.forEach(r=>{const i=this.getRealCell(r);e.findIndex(o=>o.containerId===i.containerId)===-1&&e.push(i)}),e}getColumnRealCells(t){const e=this.getColumnCells(t);return this.toRealCells(e)}getRowRealCells(t){const e=this.getRow(t).cells;return this.toRealCells(e)}getFirstSpannedCell(t){p(Qe,t>=0&&t<this.colCount,"colIndex out of range");const e=this.rowCount;for(let r=0;r<e;r++){const i=this.getCell({row:r,col:t});if(i.virtual||i.colSpan>1||i.rowSpan>1)return i}}getRealCell(t){const e=this.getCell(t);if(!e.virtual)return e;const r=this.getCellById(e.containerId);return p(Qe,!r.virtual,"found a virtual cell"),r}getColumnSpannedRange(t){const e=this.getColumnRealCells(t);let r=1e5,i=-1;return e.forEach(o=>{r=Math.min(o.col,r),i=Math.max(o.col+o.colSpan-1,i)}),p(Qe,r<=i,"min > max"),p(Qe,r>=0,"min < 0"),p(Qe,i<this.colCount,"max >= colCount"),[r,i]}getRowSpannedRange(t){const e=this.getRowRealCells(t);let r=1e5,i=-1;return e.forEach(o=>{r=Math.min(o.row,r),i=Math.max(o.row+o.rowSpan-1,i)}),p(Qe,r<=i,"min > max"),p(Qe,r>=0,"min < 0"),p(Qe,i<this.rowCount,"max >= rowCount"),[r,i]}getSpannedRange(t,e){const r=Math.min(t.row,e.row),i=Math.max(t.row,e.row),o=Math.min(t.col,e.col),s=Math.max(t.col,e.col),l=[];for(let A=r;A<=i;A++)for(let v=o;v<=s;v++)l.push(this.getCell({row:A,col:v}));const c=this.toRealCells(l);let d=1e4,h=1e4,C=-1,E=-1;return c.forEach(A=>{h=Math.min(A.col,h),d=Math.min(A.row,d),E=Math.max(A.col+A.colSpan-1,E),C=Math.max(A.row+A.rowSpan-1,C)}),[{row:d,col:h},{row:C,col:E}]}getAllCells(){return this.getCells({col:0,row:0},{col:this.colCount-1,row:this.rowCount-1})}sub(t,e){const r=[];for(let i=t.row;i<=e.row;i++){const o=[];for(let s=t.col;s<=e.col;s++){const l=this.getCell({row:i,col:s});o.push(l)}r.push(o)}return r}getAllContainers(){return this.getAllCells().map(e=>e.container)}getCells(t,e){const r=[],i=this.getSpannedRange(t,e),o=i[0],s=i[1],l=Math.min(o.row,s.row),c=Math.max(o.row,s.row),d=Math.min(o.col,s.col),h=Math.max(o.col,s.col);for(let C=l;C<=c;C++)for(let E=d;E<=h;E++){const A=this.getCell({row:C,col:E});A.virtual||r.push(A)}return r}map(t){const e=[];for(let r=0;r<this.rowCount;r++){const i=[];for(let o=0;o<this.colCount;o++){const s=this.getCell({row:r,col:o});i.push(t(s))}e.push(i)}return e}getBottomCell(t){const e=this.rowCount;let r=t,i=t.row;for(;r.containerId===t.containerId;){if(i+=1,i>=e)return null;r=this.getCell({row:i,col:t.col})}return this.getRealCell(r)}getTopCell(t){let e=t,r=t.row;for(;e.containerId===t.containerId;){if(r-=1,r<0)return null;e=this.getCell({row:r,col:t.col})}return this.getRealCell(e)}get cells(){let t=[];return this._rows.forEach(e=>{t=t.concat(e.cells)}),t}getVirtualCellContainersGrid(){return this.map(t=>t.containerId)}static virtualCellContainersGridToChildren(t){const e=t,r=[];return e.forEach(i=>{i.forEach(o=>{r.indexOf(o)===-1&&r.push(o)})}),r}getCellById(t){const r=this.cells.find(i=>i.containerId===t);return p(Qe,r,"cell not found"),r}getCellByCellElement(t){const e=Ku(t);return this.getCellByContainerId(ft(e))}getCellByContainerId(t){return this.getCellById(t)}static fromTable(t){const e=NP(t),r=this.caches.getSync(e,()=>(Qe.debug("create table grid"),new Bx(t)));return r.table!==t?(this.caches.delete(e),this.fromTable(t)):r}static fromBlock(t){return this.fromTable(Ve(t))}};let It=Bx;m(It,"caches",new Db(jP));function u0(n,t){Object.entries(n).forEach(([e])=>{e.startsWith(`${t}/`)&&delete n[e]})}const WP=I("table-selection-range");function Gr(n,t,e){var U,F,G,W;const r=It.fromBlock(n),i=t,o=e,s=r.getCellByContainerId(i.childContainerId),l=r.getCellByContainerId(o.childContainerId),c=i.custom,d=o.custom,h=(U=c==null?void 0:c.rowIndex)!=null?U:s.row,C=(F=c==null?void 0:c.colIndex)!=null?F:s.col,E=(G=d==null?void 0:d.rowIndex)!=null?G:l.row+l.rowSpan-1,A=(W=d==null?void 0:d.colIndex)!=null?W:l.col+l.colSpan-1,v=Math.min(h,E),R=Math.max(h,E),L=Math.min(C,A),M=Math.max(C,A);return{fromRow:v,toRow:R,fromCol:L,toCol:M}}function fC(n,t){const e=new Set,r=new Set,i=n.selection.range;if(!i.isSimple()&&i.start.blockId===st(t)){const o=It.fromBlock(t),{start:s,end:l}=i;p(WP,!s.isSimple()&&!l.isSimple(),"invalid range");const{fromCol:c,toCol:d,fromRow:h,toRow:C}=Gr(t,s,l);if(h===0&&C===o.rowCount-1)for(let E=c;E<=d;E++)r.add(E);if(c===0&&d===o.colCount-1)for(let E=h;E<=C;E++)e.add(E)}return{selectedRows:e,selectedColumns:r}}function Vu(n,t){let e=null;if(t.isCollapsed()&&t.isSimple()){const r=n.getBlockById(t.start.blockId);if($e(r)){const i=rt(r),o=et(i);o&&(e=uo(o))}else e=uo(r)}else{const r=n.getBlockById(t.start.blockId),i=uo(r),o=n.getBlockById(t.end.blockId),s=uo(o);i===s&&(e=i)}return e}const $a=I("delete-columns");function Sy(n,t,e){const{start:r,end:i}=e;if(r.blockId!==i.blockId||e.isSimple()||n.getBlockById(r.blockId)!==t||St(t)!=="table")return!1;const{fromRow:s,toRow:l}=Gr(t,e.start,e.end),c=It.fromBlock(t);return s===0&&l===c.rowCount-1}function dC(n){const t=n.getEditor();t.undoManager.runInGroup(()=>{var F,G;const e=t.getBlockById(n.start.blockId);if(!Sy(t,e,n))return;if(n.isSimple()){t.deleteBlock(e);return}const{fromCol:r,toCol:i}=Gr(e,n.start,n.end),o=It.fromBlock(e);if(r===0&&i===o.colCount-1){t.deleteBlock(e);return}const s=new Set,l=o.map(W=>W.containerId);for(let W=0;W<l.length;W++){const it=l[W];for(let at=r;at<=i;at++){const xt=it[at];s.add(xt)}it.splice(r,i-r+1)}const c=new Set(l.flat()),d=new Set(Array.from(s).filter(W=>!c.has(W))),h=i-r+1,C=new Map,E=new Map;s.forEach(W=>{if(d.has(W))return;const it=o.getCellByContainerId(W);if(p($a,it.colSpan>1,"invalid effected cell, colSpan === 1"),it.col<r){p($a,c.has(W),"invalid effected cell, not exists");let te=it.col+it.colSpan-1;te>i&&(te=i);const kn=te-r+1,be=it.colSpan-kn;C.set(W,be);return}p($a,it.col<=i,"invalid effected cell, col > endCol");const at=it.col,xt=it.col+it.colSpan-1,Mt=it.col-r,Bt=xt-at+1-h+Mt;p($a,Bt>0,"invalid effected cell, newSpanned <= 0");const le=no(t.doc);E.set(W,{newContainerId:le,colSpan:Bt})});for(let W=0;W<l.length;W++){const it=l[W];for(let at=r;at<it.length;at++){const xt=it[at],Mt=E.get(xt);Mt&&(it[at]=Mt.newContainerId)}}const A=gt.default(t.getBlockData(e));((F=A.colsWidth)!=null?F:new Array(A.cols).fill(0)).splice(r,i-r+1),d.forEach(W=>{u0(A,W)}),C.forEach((W,it)=>{p($a,W>=1,"invalid modified colSpan, colSpan < 1"),W===1?A[`${it}_colSpan`]=void 0:A[`${it}_colSpan`]=W}),E.forEach((W,it)=>{u0(A,it);const{newContainerId:at,colSpan:xt}=W;p($a,xt>=1,"invalid newContainerData, colSpan < 1"),xt>1&&(A[`${at}_colSpan`]=xt);const Mt=o.getCellByContainerId(it).rowSpan;Mt>1&&(A[`${at}_rowSpan`]=Mt)});const R=(G=l[0][r])!=null?G:l[0][r-1],L=t.getChildContainerData(R)[0],M=It.virtualCellContainersGridToChildren(l),U={...A,cols:A.cols-h,children:M};ll(U),t.updateBlockData(e,U,Te(t,L.id,0)),t.deleteChildContainers(Array.from(d)),t.deleteChildContainers(Array.from(E.keys()))})}const Ha=I("delete-rows");function Ly(n,t,e){const{start:r,end:i}=e;if(r.blockId!==i.blockId||e.isSimple()||n.getBlockById(r.blockId)!==t||St(t)!=="table")return!1;const{fromCol:s,toCol:l}=Gr(t,e.start,e.end),c=It.fromBlock(t);return s===0&&l===c.colCount-1}function hC(n){const t=n.getEditor();t.undoManager.runInGroup(()=>{const e=t.getBlockById(n.start.blockId);if(!Ly(t,e,n))return;if(n.isSimple()){t.deleteBlock(e);return}const{fromRow:r,toRow:i}=Gr(e,n.start,n.end),o=It.fromBlock(e);if(r===0&&i===o.rowCount-1){t.deleteBlock(e);return}const s=new Set,l=o.map(U=>U.containerId);for(let U=i;U>=r;U--)l[U].forEach(G=>s.add(G)),l.splice(U,1);const c=new Set(l.flat()),d=new Set(Array.from(s).filter(U=>!c.has(U))),h=i-r+1,C=new Map,E=new Map;s.forEach(U=>{if(d.has(U))return;const F=o.getCellByContainerId(U);if(p(Ha,F.rowSpan>1,"invalid effected cell, rowSpan === 1"),F.row<r){p(Ha,c.has(U),"invalid effected cell, not exists");let Mt=F.row+F.rowSpan-1;Mt>i&&(Mt=i);const Bt=Mt-r+1,le=F.rowSpan-Bt;C.set(U,le);return}p(Ha,F.row<=i,"invalid effected cell, col > endCol");const G=F.row,W=F.row+F.rowSpan-1,it=F.row-r,at=W-G+1-h+it;p(Ha,at>0,"invalid effected cell, newSpanned <= 0");const xt=no(t.doc);E.set(U,{newContainerId:xt,rowSpan:at})});for(let U=r;U<l.length;U++){const F=l[U];for(let G=0;G<F.length;G++){const W=F[G],it=E.get(W);it&&(F[G]=it.newContainerId)}}const A=gt.default(t.getBlockData(e));d.forEach(U=>{u0(A,U)}),C.forEach((U,F)=>{p(Ha,U>=1,"invalid modified rowSpan, rowSpan < 1"),U===1?A[`${F}_rowSpan`]=void 0:A[`${F}_rowSpan`]=U}),E.forEach((U,F)=>{u0(A,F);const{newContainerId:G,rowSpan:W}=U;p(Ha,W>=1,"invalid newContainerData, rowSpan < 1"),W>1&&(A[`${G}_rowSpan`]=W);const it=o.getCellByContainerId(F).colSpan;it>1&&(A[`${G}_colSpan`]=it)});const v=l[r]?l[r][0]:l[r-1][0],R=t.getChildContainerData(v)[0],L=It.virtualCellContainersGridToChildren(l),M={...A,rows:A.rows-h,children:L};ll(M),t.updateBlockData(e,M,Te(t,R.id,0)),t.deleteChildContainers(Array.from(d)),t.deleteChildContainers(Array.from(E.keys()))})}const $u=I("table-range");function f0(n){p($u,!n.isSimple(),"must be complex selection range");const{anchor:t,focus:e}=n;p($u,!t.isSimple(),"invalid start pos type"),p($u,!e.isSimple(),"invalid end pos type");const r=n.getEditor();p($u,t.blockId===e.blockId,"invalid range, not same block");const i=r.getBlockById(t.blockId);p($u,St(i)==="table","invalid block type, not a table block");const o=Ve(i),s=It.fromTable(o),l=s.getCellByContainerId(t.childContainerId),c=s.getCellByContainerId(e.childContainerId),d=Math.min(l.row,c.row),h=Math.max(l.row,c.row),C=Math.min(l.col,c.col),E=Math.max(l.col,c.col),A=s.getCell({row:d,col:C}),v=s.getCell({row:h,col:E});return{editor:r,block:i,table:o,startCell:A,endCell:v,startRow:d,startCol:C,endRow:h,endCol:E}}const mC=I("split-cell");function gC(n,t,e){n.undoManager.runInGroup(()=>{const r=It.fromBlock(t),i=r.getRealCell(e);p(mC,!i.virtual,"should not split virtual cell"),p(mC,i.colSpan>1||i.rowSpan>1,"cell does not has span data");const o=r.getVirtualCellContainersGrid();for(let C=0;C<i.rowSpan;C++)for(let E=0;E<i.colSpan;E++){if(C===0&&E===0)continue;const A=C+i.row,v=E+i.col,R=no(n.doc);o[A][v]=R}const s=n.getBlockData(t),l=gt.default(s);l[`${i.containerId}_colSpan`]=null,l[`${i.containerId}_rowSpan`]=null,l.children=It.virtualCellContainersGridToChildren(o);const d=n.getChildContainerData(i.containerId)[0];p(mC,d,"no child block");const h=Te(n,d.id,0);ll(l),n.updateBlockData(t,l,h)})}function qP(n,t,e){e.forEach(r=>{const i=It.fromBlock(t).getCell(r);(i.virtual||i.colSpan>1||i.rowSpan>1)&&gC(n,t,r)})}function Iy(n,t,e){if(e.isSimple())return!1;const{start:r,end:i}=e;if(r.blockId!==i.blockId||n.getBlockById(r.blockId)!==t||St(t)!=="table")return!1;const{startCell:s,endCell:l}=f0(e);return!(s.cell!==l.cell||s.colSpan===1&&s.rowSpan===1)}function pC(n){const{editor:t,block:e,startRow:r,startCol:i,endRow:o,endCol:s}=f0(n),l=[];for(let c=r;c<=o;c++)for(let d=i;d<=s;d++)l.push({row:c,col:d});return qP(t,e,l),!0}const ja=I("merge-cells");function Dy(n,t,e){if(e.isSimple())return!1;const{start:r,end:i}=e;if(r.blockId!==i.blockId||n.getBlockById(r.blockId)!==t||St(t)!=="table")return!1;const{startCell:s,endCell:l}=f0(e);return s.cell!==l.cell}function _y(n){const t=f0(n),e=t.editor;e.undoManager.runInGroup(()=>{const r=t.endCell,i=r.row+r.rowSpan-1,o=r.col+r.colSpan-1,s=st(t.block);pC(n);const l=e.getBlockById(s),c=Ve(l),{startRow:d,startCol:h}=t,C=gt.default(e.getBlockData(l));p(ja,C.children,"no table children");const E=It.fromTable(c),A=[];for(let Mt=d;Mt<=i;Mt++)for(let Bt=h;Bt<=o;Bt++){const le=E.getCell({row:Mt,col:Bt});p(ja,!le.virtual,"cell is virtual"),A.push(le)}p(ja,A.length>0,"no selected cells");const v=A[0],R=A.slice(1),L=E.getCellByContainerId(v.containerId).container,M=[];R.forEach(Mt=>{const Bt=E.getCellByContainerId(Mt.containerId).container,le=ft(Bt);if(!uu(e,Bt)){const te=G5(e,le);if(uu(e,L)){const kn=ue(L)[0];e.insertDocAt(L,0,te),e.deleteBlock(kn)}else e.insertDocAt(L,Lr(L),te)}M.push(le)});const U=ft(L),F=o-h+1,G=i-d+1;C[`${U}_colSpan`]=F,C[`${U}_rowSpan`]=G,M.forEach(Mt=>{p(ja,C.children,"no table children");const Bt=C.children.indexOf(Mt);p(ja,Bt>0,"no deleted container"),C.children.splice(Bt,1)});const W=C,at=e.getChildContainerData(U)[0];p(ja,at,"no child block");const xt=Te(e,at.id,0);ll(W),e.updateBlockData(l,W,xt),e.deleteChildContainers(M)})}const CC=10,XP=["table/merge-cells","table/split-cell","table/insert-column","table/insert-row","table/delete-rows","table/delete-columns","table/delete"];class d0{constructor(){m(this,"id","TableBlockCommandProvider")}getAvailableCommands(t,e,r){if(St(e)!=="table")return[];const i={blockId:st(e),blockKind:Ir(t,e),blockType:St(e)},o=[];Dy(t,e,r)&&o.push({id:"table/merge-cells",name:D.t("table.mergeCell"),icon:CT,groupIndex:CC,...i}),Iy(t,e,r)&&o.push({id:"table/split-cell",name:D.t("table.splitCell"),icon:ET,groupIndex:CC,...i});const s=Sy(t,e,r),l=Ly(t,e,r);return s&&l&&o.push({id:"table/delete",name:D.t("table.deleteTable"),icon:xT,groupIndex:CC,...i}),o}executeCommand(t,e,r,i,o,s){return St(e)!=="table"||!new Set(XP).has(i.id)?!1:i.id==="table/merge-cells"?(_y(r),!0):i.id==="table/split-cell"?(pC(r),!0):i.id==="table/delete-columns"?(dC(r),!0):i.id==="table/delete-rows"?(hC(r),!0):i.id==="table/delete"?(t.deleteBlock(e),!0):!1}}var My=(n=>(n.COL_TITLE_TABLE="col-title-table",n.COL_TITLE_ITEM="col-title-item",n.STRIPE_STYLE_TABLE="stripe-style-table",n.NO_BORDER="table-no-border",n))(My||{});const za=6,Hu=20,EC="table-cell-menu-btn";function QP(n,t){if(!n.isBlockWritable(t))return;const r={...gt.default(n.getBlockData(t)),hasColTitle:!0};n.updateBlockData(t,r)}function YP(n,t){if(!n.isBlockWritable(t))return;const r={...gt.default(n.getBlockData(t)),hasColTitle:!1};n.updateBlockData(t,r)}function JP(n,t){if(!n.isBlockWritable(t))return;const r={...gt.default(n.getBlockData(t)),hasRowTitle:!0};n.updateBlockData(t,r)}function ZP(n,t){if(!n.isBlockWritable(t))return;const r={...gt.default(n.getBlockData(t)),hasRowTitle:!1};n.updateBlockData(t,r)}function tF(n,t){if(!n.isBlockWritable(t))return;const r={...gt.default(n.getBlockData(t)),isStripeStyle:!0};n.updateBlockData(t,r)}function eF(n,t){if(!n.isBlockWritable(t))return;const r={...gt.default(n.getBlockData(t)),isStripeStyle:!1};n.updateBlockData(t,r)}function nF(n,t,e){if(!n.isBlockWritable(t))return;const i={...gt.default(n.getBlockData(t)),noBorder:!e};n.updateBlockData(t,i)}const al=I("table-cell-dom");function rF(n,t,e){let r=n.getBlockById(e);for(;r;){const i=r.closest("td");p(al,i,"no parent cell");const o=et(i);if(p(al,o,"no parent block"),o===t)return i;r=o}return p(al,!1,"filed to get cell by child block id"),null}function ts(n,t,e){if(n.getBlockById(e.blockId)===t&&!e.isSimple())return p(al,e.childContainerId,"block position must have childContainerId attribute"),e;const i=rF(n,t,e.blockId),o=ft(Ku(i));return xe(t,o)}function xC(n,t){const e=n.selection.range,r=ts(n,t,e.start),i=ts(n,t,e.end);return Gr(t,r,i)}function Uy(n,t,e,r){p(al,$e(t),"invalid table block");const i=vi(n,t),o=re(t),s=()=>{const c=i.querySelector(".table-border-bar-container.top");p(al,c,"no top border bar container"),c.querySelectorAll(".table-border-bar-cell.top").forEach(h=>{const C=parseInt(h.getAttribute("data-top-index")||"0",10);r.includes(C)?z(h,"danger"):ot(h,"danger")})},l=()=>{const c=o.querySelector(".table-border-bar-container.left");p(al,c,"no left border bar container"),c.querySelectorAll(".table-border-bar-cell.left").forEach(h=>{const C=parseInt(h.getAttribute("data-left-index")||"0",10);e.includes(C)?z(h,"danger"):ot(h,"danger")})};s(),l()}function es(n,t,e=!0,r){const o=It.fromBlock(t).map(h=>h),{fromCol:s,toCol:l,fromRow:c,toRow:d}=xC(n,t);for(let h=0;h<o.length;h++){const C=o[h];for(let E=0;E<C.length;E++){const A=C[E],v=r?E>=s&&E+A.colSpan-1<=l:h>=c&&h+A.rowSpan-1<=d;e&&v?A.virtual||z(A.cell,"danger"):A.virtual||ot(A.cell,"danger")}}}function ns(n,t,e=!0,r){const i=new Set,o=new Set;if(!e){Uy(n,t,Array.from(i),Array.from(o));return}const{fromCol:s,toCol:l,fromRow:c,toRow:d}=xC(n,t);if(r)for(let h=s;h<=l;h++)o.add(h);else for(let h=c;h<=d;h++)i.add(h);Uy(n,t,Array.from(i),Array.from(o))}function Oy(n,t,e){const{fromCol:r,toCol:i,fromRow:o,toRow:s}=xC(n,t),l=It.fromBlock(t);let c=null,d=null;return e?(c=l.getCell({col:r,row:0}),d=l.getCell({col:i,row:l.rowCount-1}),qe(n,{anchor:xe(t,c.containerId,{colIndex:r,rowIndex:0}),focus:xe(t,d.containerId,{colIndex:i,rowIndex:l.rowCount-1})})):(c=l.getCell({col:0,row:o}),d=l.getCell({col:l.colCount-1,row:s}),qe(n,{anchor:xe(t,c.containerId,{colIndex:0,rowIndex:o}),focus:xe(t,d.containerId,{colIndex:l.colCount-1,rowIndex:s})}))}const Ny=["style-bg-color-0","style-bg-color-1","style-bg-color-2","style-bg-color-3","style-bg-color-4","style-bg-color-5","style-bg-color-6","style-bg-color-7","style-bg-color-8","style-bg-color-9","style-bg-color-10","style-bg-color-11","style-bg-color-12","style-bg-color-13"];function Py(n){return`style-bg-color-${n}`}function ju(n){return`${n}_background`}function iF(n,t,e){const r=Ve(n),s=(e!=null?e:It.fromTable(r)).getCell(t).cell;for(let l=0;l<Ny.length;l++){const c=Ny[l];if(Rt(s,c))return c}}function Fy(n,t,e){if(!n.isBlockWritable(t))return;const r=n.selection.range,o={...gt.default(n.getBlockData(t))},s=ts(n,t,r.start),l=ts(n,t,r.end);if(r.isSimple()){const c=s.childContainerId;e===-1?o[ju(c)]=void 0:o[ju(c)]=Py(e)}else{const c=It.fromBlock(t),d=Gr(t,s,l),h=new Set;for(let C=d.fromRow;C<=d.toRow;C++)for(let E=d.fromCol;E<=d.toCol;E++){const A=c.getCell({row:C,col:E});!h.has(A.containerId)&&A.col>=d.fromCol&&A.row>=d.fromRow&&A.col+A.colSpan-1<=d.toCol&&A.row+A.rowSpan-1<=d.toRow&&(h.add(A.containerId),e===-1?o[ju(A.containerId)]=void 0:o[ju(A.containerId)]=Py(e))}}n.updateBlockData(t,o)}function oF(n,t,e){if(!n.isBlockWritable(t))return;const i={...gt.default(n.getBlockData(t)),chart:e};n.updateBlockData(t,i)}const Ky=I("table-chart");function sF(n,t){const e=OP(n,t);if(e){const r=e.querySelector(".editor-table-chart");if(r){const i=r.chartObject;i&&i.destroy(),r.remove()}}}async function lF(n,t){if(!n.contains(t)||!n.isBlockWritable(t))return;if(!!!n.getBlockData(t).chart){sF(n,t);return}const i=[],o=It.fromBlock(t),s=["line","bar","pie","radar"];let l=o.getCell({row:0,col:0}).container.innerText.trim().toLowerCase();new Set(s).has(l)||(l=s[0]);const c=[];for(let R=1;R<o.colCount;R++)c.push(o.getCell({row:0,col:R}).container.innerText);for(let R=1;R<o.rowCount;R++){const L=o.getCell({row:R,col:0}),U=L.container.innerText,F=[];for(let te=1;te<o.colCount;te++){const kn=o.getCell({row:R,col:te}).container.innerText,be=Number.parseFloat(kn)||0;F.push(be)}let G;const W=iF(t,L,o);W?G=window.getComputedStyle(n.rootElement).getPropertyValue(`--${W}`).trim():G=window.getComputedStyle(n.rootElement).getPropertyValue("--background-color").trim();let[it,at,xt,Mt]=G?bg.fromString(G).toRgbaArray():[];if(!it&&!at&&!xt&&!Mt){const te=(R-1)%n.options.colors.length;G=n.options.colors[te],[it,at,xt,Mt]=bg.fromString(G).toRgbaArray()}const Bt=G,le=bg.fromRgba([it,at,xt,Mt/3]).toHexString();i.push({label:U,data:F,borderColor:Bt,backgroundColor:le,borderWidth:2})}const d=vi(n,t);let h=null,C=d.querySelector(".editor-table-chart");C?h=C.chartObject:C=B("div",["editor-table-chart"],d);const E=C;p(Ky,E,"no chart container");const A=n.getComponentOptions("table"),v=(A==null?void 0:A.chartCdn)||"https://cdn.jsdelivr.net/npm/chart.js@2.9.4/dist/Chart.min.js";try{await Os(v,"editor-chartjs");let R=!1;(h&&h.config.data.datasets.length>i.length||h&&h.config.data.datasets[0].data.length>i[0].data.length)&&(R=!0),h&&(l!==h.config.type||R)&&(h.destroy(),h=null,Array.from(C.querySelectorAll(".editor-chartjs-canvas")).forEach(U=>{U.remove()}));const L=Bg.default({},{type:l,data:{datasets:i,labels:c},options:{onClick:()=>{n.selection.selectBlock(t,0,0)}}});if(h)Bg.default(h.config,L),h.update();else{const U=B("canvas",["editor-chartjs-canvas"],E).getContext("2d");h=new window.Chart(U,L),C.chartObject=h}}catch(R){Ky.error(`failed to resolve chart cdn: ${JSON.stringify(R)}`)}}async function Vy(n,t){await Sr.lock("updateTableChart");try{await lF(n,t)}finally{Sr.release("updateTableChart")}}const $y=Me.default(Vy,1e3);let Hy=null;function AC(n,t,e){if(Hy!==t&&($y.flush(),Hy=t),e.updateNow){Vy(n,t);return}$y(n,t)}function bC(n,t){$e(t)&&AC(n,t,{updateNow:!1})}function aF(n,t){$e(t)&&AC(n,t,{updateNow:!0})}const Er={SCROLL:"container-scroll-tool",COMMON:"container-border-shadow",RIGHT:"container-right-border-shadow",LEFT:"container-left-border-shadow",LAYOUT_SIGN:"container-layout-border-shadow",ACTIVE:"active"},h0={SCROLL_BAR:"container-scrollbar",FIXED:"fixed"},rs={SCROLL_CONTAINER:"scroll-container",TOOL:"container-scroll-tool",CONTAINER:"scroll-container-root",MAC:"mac",SCROLL_AREA:"scroll-area"};function zu(n,t){return n.containers.get(t)}function jy(n){return n.closest(`.${rs.SCROLL_CONTAINER}`)}function Wr(n){return n.firstElementChild}function Tn(n){return n.closest(`.${rs.CONTAINER}`)}function Gu(n){const t=Tn(n);let e=t.querySelector(`:scope >.${rs.TOOL}`);return e||(e=B("div",[rs.TOOL],t)),e}function cF(n){return Tn(n).firstElementChild}function uF(n,t){const e=zu(n,Tn(t));return e!=null&&e.barFloatWindowBottom?typeof e.barFloatWindowBottom=="function"?e.barFloatWindowBottom():e.barFloatWindowBottom:0}function xr(n,t){const e=fr(n);return t/e}function Wu(n){const t=window.getComputedStyle(n),e=fr(n);return{paddingBottom:parseFloat(t.paddingBottom)*e,paddingTop:parseFloat(t.paddingTop)*e,paddingLeft:parseFloat(t.paddingLeft)*e,paddingRight:parseFloat(t.paddingRight)*e}}function Ga(n){const t=fr(n);return{scrollLeft:n.scrollLeft*t,scrollWidth:n.scrollWidth*t,clientWidth:n.clientWidth*t,clientHeight:n.clientHeight*t}}function fF(n,t){const e=fr(n);return n[t]*e}function vC(n,t){const e=Tn(t),r=zu(n,e),i=(r==null?void 0:r.safeRightSpace)||0,o=(r==null?void 0:r.safeLeftSpace)||0,l=(r==null?void 0:r.locatingContainer).getBoundingClientRect(),c=e.getBoundingClientRect(),d=c.width;let h=Math.floor(c.left-l.left-o);h<0&&(h=0);let C=l.right;C-=i;let E=C-c.right;return E<0&&(E=0),h=Math.round(h),E=Math.round(E),{originWidth:d,maxLeft:h,maxRight:E}}function dF(n,t){const e=vC(n,t),{maxLeft:r}=e;t.style.marginLeft=`${xr(t,0-r)}px`,t.style.paddingLeft=`${xr(t,r)}px`}function hF(n,t){const e=vC(n,t);t.style.marginRight=`${xr(t,0-e.maxRight)}px`}function mF(n){if(n!==document.documentElement&&n!==document.body)return n.getBoundingClientRect();const t=0,e=0,r=document.documentElement.clientWidth,i=document.documentElement.clientHeight;return new DOMRect(t,e,r,i)}const zy=I("scroll-bar-handle"),gF=2;function Wa(n){const t=Gu(n);let e=t.querySelector(`.${h0.SCROLL_BAR}`);return e||(e=B("div",[h0.SCROLL_BAR],t)),p(zy,e instanceof HTMLDivElement,"invalid child for container tools"),e.firstElementChild||B("div",[],e),e}function m0(n,t){const e=jy(t),r=Wa(e),{scrollWidth:i,clientWidth:o}=Ga(e),{paddingLeft:s,paddingRight:l}=Wu(t),c=vC(n,e),{originWidth:d,maxRight:h}=c;hF(n,e),dF(n,e);const C=i-o;p(zy,r.firstElementChild instanceof HTMLDivElement,"invalid child for scroll bar"),r.style.width=`${xr(e,d+h-s-l)}px`,r.firstElementChild.style.width=`${xr(e,d+h+C-s-l)}px`}function pF(n,t){const e=Wr(n),{paddingLeft:r}=Wu(e);if(Rt(t,"fixed")){const o=Tn(n).getBoundingClientRect();t.style.left=`${xr(n,o.left+r)}px`}else t.style.left=`${xr(n,r)}px`}function qa(n,t){var U;const e=n.getParentScrollContainer(),r=mF(e),i=t.getBoundingClientRect(),o=Wa(t),s=o.getBoundingClientRect(),l=zu(n,Tn(t)),c=uF(n,t),d=Wr(t),{paddingTop:h,paddingBottom:C}=Wu(d),{scrollWidth:E,clientWidth:A}=Ga(t),v=document.documentElement.clientHeight-c,R=r.top+Ga(e).clientHeight-v,L=v+Math.min(0,R);if(E>A&&i.top+h<L-s.height&&i.bottom>L-s.height+C&&!((U=l==null?void 0:l.isSetScale)!=null&&U.call(l))){l!=null&&l.allowScrollBarFixed&&z(o,h0.FIXED);const F=R>0?c:0;o.style.bottom=`${Math.max(document.documentElement.clientHeight-r.bottom,0)+gF+F}px`}else ot(o,h0.FIXED),o.style.bottom=`${xr(t,C-s.height)}px`;pF(t,o)}class CF{constructor(t,e){m(this,"intersectionObserver");m(this,"handleIntersection",t=>{t.forEach(e=>{this.containers.get(Tn(e.target))?(this.handleIntersectionEntry(e),this.callback(e)):this.intersectionObserver.unobserve(e.target)})});m(this,"handleIntersectionEntry",t=>{const e=t.target;qa(this.scrollCore,e);const r=Wr(e);m0(this.scrollCore,r)});this.scrollCore=t,this.callback=e;const i={root:this.scrollCore.getParentScrollContainer(),rootMargin:"20px",threshold:0};this.intersectionObserver=new IntersectionObserver(this.handleIntersection,i)}get containers(){return this.scrollCore.containers}bind(t){this.unbind(t),this.intersectionObserver.observe(t)}unbind(t){this.intersectionObserver.unobserve(t)}destroy(){this.intersectionObserver.disconnect()}}const cl=I("container-scroll-shadow");function Gy(n,t,e){const r=n,i=t.getBoundingClientRect(),o=e.getBoundingClientRect(),{paddingTop:s,paddingBottom:l}=Wu(e);r.style.top=`${xr(t,o.top-i.top+s)}px`,r.style.bottom=`${xr(t,i.bottom-o.bottom+l)}px`}function Wy(n,t){const e=n;t<24?e.style.width=`${(t/3).toFixed(2)}px`:e.style.width=""}function EF(n){const t=Gu(n);p(cl,t,"no container tools");let e=t.querySelector(`.${Er.LEFT}`);if(!e){const l=Wr(n),c=[Er.COMMON,Er.LEFT];e=B("div",c,t),p(cl,e instanceof HTMLDivElement,"invalid child for container tools"),Gy(e,n,l)}p(cl,e instanceof HTMLElement,"invalid child for container tools");const i=Tn(n).getBoundingClientRect(),o=n.getBoundingClientRect();e.style.left=`${xr(n,o.left-i.left)}px`;const s=Ga(n).scrollLeft;p(cl,e instanceof HTMLDivElement,"invalid child for container tools"),Wy(e,s),z(e,Er.ACTIVE)}function xF(n){const t=Gu(n);let e=t.querySelector(`.${Er.RIGHT}`);if(!e){const h=Wr(n),C=[Er.COMMON,Er.RIGHT];e=B("div",C,t),p(cl,e instanceof HTMLDivElement,"no div, create shadow failed"),Gy(e,n,h)}p(cl,e instanceof HTMLElement,"");const i=Tn(n).getBoundingClientRect(),o=n.getBoundingClientRect();e.style.right=`${xr(n,i.right-o.right)}px`;const{scrollWidth:s,scrollLeft:l,clientWidth:c}=Ga(n),d=s-l-c;p(cl,e instanceof HTMLDivElement,"no shadow element"),Wy(e,d),z(e,Er.ACTIVE)}function AF(n){const e=Gu(n).querySelector(`.${Er.LEFT}`);e&&ot(e,Er.ACTIVE)}function bF(n){const e=Gu(n).querySelector(`.${Er.RIGHT}`);e&&ot(e,Er.ACTIVE)}function qu(n){const{scrollLeft:t,scrollWidth:e,clientWidth:r}=Ga(n),i=Wr(n),{paddingLeft:o,paddingRight:s}=Wu(i),l=fF(i,"offsetLeft");e-o<=r-s||e-o<=t+r-s?bF(n):xF(n),i&&t>=l+o?EF(n):AF(n)}class vF{constructor(t,e){m(this,"resizeObserver");m(this,"handleResizeEntry",t=>{const e=t.target,r=Wr(e);qu(e),m0(this.scrollCore,r),qa(this.scrollCore,e),this.callback(e)});m(this,"handleContentResize",t=>{t.forEach(e=>{this.containers.get(Tn(e.target))?this.handleResizeEntry(e):this.unbind(e.target)})});this.scrollCore=t,this.callback=e,this.resizeObserver=new _s(this.handleContentResize)}get containers(){return this.scrollCore.containers}bind(t){this.unbind(t),this.resizeObserver.observe(t)}unbind(t){this.resizeObserver.unobserve(t)}destroy(){this.resizeObserver.disconnect()}}const qy=I("container-scroll-observer");class BF{constructor(t,e){m(this,"handleContentScroll",t=>{const e=t.target;p(qy,e instanceof Element,"invalid target for scroll event");const r=Wa(e);r.removeEventListener("scroll",this.handleScroll);const i=!0;this.fixScrollXPos(e,e.scrollLeft,i),this.bind(r),qu(e),this.callback(e)});m(this,"handleScroll",t=>{const e=t.target;p(qy,e instanceof HTMLElement,"");const r=e.scrollLeft,i=!1,o=cF(e);this.unbindContentScroll(o),this.fixScrollXPos(o,r,i),this.bindContentScroll(o),qu(o),this.callback(o)});m(this,"handlePrevent",t=>{t.stopPropagation()});m(this,"bindContentScrollCore",t=>{this.unbindContentScroll(t),t.addEventListener("scroll",this.handleContentScroll)});m(this,"unbindContentScroll",t=>{t.removeEventListener("scroll",this.handleContentScroll)});m(this,"bindContentScroll",Me.default(this.bindContentScrollCore,300));m(this,"bind",Me.default(this.bindCore,200));this.scrollCore=t,this.callback=e}fixScrollXPos(t,e,r){const i=Wa(t);r||(t.scrollLeft=e),r&&i.scrollLeft!==e&&(i.scrollLeft=e)}bindCore(t){this.unbind(t),t.addEventListener("scroll",this.handleScroll),t.addEventListener("mousedown",this.handlePrevent)}unbind(t){t.removeEventListener("scroll",this.handleScroll),t.removeEventListener("mousedown",this.handlePrevent)}}class TF{constructor(t){m(this,"scrollContainers",new Set);m(this,"handleParentContainerScroll",()=>{this.scrollContainers.forEach(t=>{qa(this.scrollCore,t)})});m(this,"bindScrollContainer",t=>{const e=this.scrollContainers.size===0;this.scrollContainers.add(t),e&&this.eventTarget.addEventListener("scroll",this.handleParentContainerScroll)});m(this,"unbindScrollContainer",t=>{let e=!1;this.scrollContainers.has(t)&&(this.scrollContainers.delete(t),e=this.scrollContainers.size===0),e&&this.eventTarget.removeEventListener("scroll",this.handleParentContainerScroll)});this.scrollCore=t}get eventTarget(){const t=this.scrollCore.getParentScrollContainer();return t===document.documentElement?document:t}destroy(){this.eventTarget.removeEventListener("scroll",this.handleParentContainerScroll),this.scrollContainers.clear()}}const yF=I("scroll-wrap-resize-observer");class kF{constructor(t){m(this,"resizeObserver");m(this,"handleScrollWrapResize",t=>{t.forEach(e=>{this.containers.get(Tn(e.target))?this.handleScrollWrapResizeEntry(e):this.unbind(e.target)})});m(this,"handleScrollWrapResizeEntry",t=>{const e=t.target;p(yF,e instanceof HTMLElement,"invalid target for observer entry");const r=jy(e);m0(this.scrollCore,e),qu(r),qa(this.scrollCore,r)});this.scrollCore=t,this.resizeObserver=new _s(this.handleScrollWrapResize)}get containers(){return this.scrollCore.containers}bind(t){this.unbind(t),this.resizeObserver.observe(t)}unbind(t){this.resizeObserver.unobserve(t)}destroy(){this.resizeObserver.disconnect()}}class RF{constructor(t,e){m(this,"resizeObserver");m(this,"scrollContainersMap",new Map);m(this,"handleResizeEntry",t=>{t==null||t.forEach(e=>{const r=Wr(e);qu(e),m0(this.scrollCore,r),qa(this.scrollCore,e),this.callback(e)})});m(this,"handleResize",t=>{t.forEach(e=>{const r=this.scrollContainersMap.get(e.target);r!=null&&r.length&&this.handleResizeEntry(r)})});this.scrollCore=t,this.callback=e,this.resizeObserver=new _s(this.handleResize)}bind(t){var i,o;const e=Tn(t),r=(i=zu(this.scrollCore,e))==null?void 0:i.locatingContainer;this.scrollContainersMap.has(r)?(o=this.scrollContainersMap.get(r))==null||o.push(t):(this.scrollContainersMap.set(r,[t]),this.resizeObserver.observe(r))}unbind(t){var o,s;const e=Tn(t),r=(o=zu(this.scrollCore,e))==null?void 0:o.locatingContainer;if(!r)return;const i=this.scrollContainersMap.get(r);this.scrollContainersMap.set(r,(i==null?void 0:i.filter(l=>l!==t))||[]),(s=this.scrollContainersMap.get(r))!=null&&s.length||(this.resizeObserver.unobserve(r),this.scrollContainersMap.delete(r))}destroy(){this.scrollContainersMap.clear(),this.resizeObserver.disconnect()}}const xct="";class wF extends Re.TypedEmitter{constructor(e){super();m(this,"containerIntersectionObserver",null);m(this,"containerResizeObserver",null);m(this,"containerScrollObserver",null);m(this,"parentContainerScrollObserver",null);m(this,"scrollWrapResizeObserve",null);m(this,"locatingContainerResizeObserver",null);m(this,"isWindowEventBind",!1);m(this,"containers",new Map);m(this,"handleScrollContainerScroll",e=>{this.emit("scroll",this,e)});m(this,"handleResize",e=>{this.emit("resize",this,e)});m(this,"handleIntersection",e=>{const r=e.target,i=Wr(r);e.isIntersecting?(this.load(),this.bindCore(r,i)):this.unbindCore(r,i)});m(this,"handleWindowEffect",()=>{var e;(e=this.getScrollContainerInViewable())==null||e.forEach(r=>{qa(this,r)})});this.parentContainer=e}load(){this.containerResizeObserver||(this.containerResizeObserver=new vF(this,this.handleResize)),this.containerScrollObserver||(this.containerScrollObserver=new BF(this,this.handleScrollContainerScroll)),this.parentContainerScrollObserver||(this.parentContainerScrollObserver=new TF(this)),this.scrollWrapResizeObserve||(this.scrollWrapResizeObserve=new kF(this)),this.locatingContainerResizeObserver||(this.locatingContainerResizeObserver=new RF(this,this.handleResize)),this.isWindowEventBind||(window.addEventListener("resize",this.handleWindowEffect),this.getParentScrollContainer()!==document.documentElement&&window.addEventListener("scroll",this.handleWindowEffect))}getParentScrollContainer(){return this.parentContainer}getScrollContainerInViewable(){var e;return(e=this.parentContainerScrollObserver)==null?void 0:e.scrollContainers}unbindCore(e,r){var o,s,l,c,d,h;const i=Wa(e);(o=this.containerScrollObserver)==null||o.unbindContentScroll(e),(s=this.containerScrollObserver)==null||s.unbind(i),(l=this.scrollWrapResizeObserve)==null||l.unbind(r),(c=this.containerResizeObserver)==null||c.unbind(e),(d=this.parentContainerScrollObserver)==null||d.unbindScrollContainer(e),(h=this.locatingContainerResizeObserver)==null||h.unbind(e)}bindCore(e,r){var s,l,c,d,h,C;if(this.unbindCore(e,r),!e.closest("body"))return;const i=Wa(e);(s=this.containerScrollObserver)==null||s.bindContentScrollCore(e),(l=this.containerScrollObserver)==null||l.bindCore(i),(c=this.scrollWrapResizeObserve)==null||c.bind(r),(d=this.containerResizeObserver)==null||d.bind(e);const o=this.containers.get(Tn(e));o!=null&&o.allowScrollBarFixed&&((h=this.parentContainerScrollObserver)==null||h.bindScrollContainer(e)),(C=this.locatingContainerResizeObserver)==null||C.bind(e)}bind(e,r){this.containers.set(e,r);const i=e.firstElementChild;this.containerIntersectionObserver||(this.containerIntersectionObserver=new CF(this,this.handleIntersection)),this.containerIntersectionObserver.bind(i)}unbind(e){var o;const r=e.firstElementChild,i=Wr(r);this.unbindCore(r,i),this.containers.delete(e),(o=this.containerIntersectionObserver)==null||o.unbind(r),this.containers.size||this.destroy()}destroy(){var e,r,i,o,s;this.containers.forEach((l,c)=>{this.unbind(c)}),this.containers.clear(),(e=this.parentContainerScrollObserver)==null||e.destroy(),(r=this.containerIntersectionObserver)==null||r.destroy(),(i=this.containerResizeObserver)==null||i.destroy(),(o=this.scrollWrapResizeObserve)==null||o.destroy(),(s=this.locatingContainerResizeObserver)==null||s.destroy(),window.removeEventListener("resize",this.handleWindowEffect),window.removeEventListener("scroll",this.handleWindowEffect)}}const Xy=I("scroll-container"),g0=new Map;class SF extends Re.TypedEmitter{constructor(){super(...arguments);m(this,"scrollListener");m(this,"options");m(this,"scrollContainerElement");m(this,"init",e=>{this.options=e;const r=B("div",[rs.CONTAINER],e.parentElement);me.isMac&&z(r,rs.MAC);const i=B("div",[rs.SCROLL_CONTAINER],r),o=B("div",[rs.SCROLL_AREA],i);o.style.paddingLeft=e.paddingLeft?`${e.paddingLeft}px`:"",o.style.paddingTop=e.paddingTop?`${e.paddingTop}px`:"",o.style.paddingBottom=e.paddingBottom?`${e.paddingBottom}px`:"",o.style.paddingRight=e.paddingRight?`${e.paddingRight}px`:"",o.appendChild(e.childElement);const s=e.parentContainer;this.scrollListener=g0.get(s),this.scrollListener||(this.scrollListener=new wF(s),g0.set(s,this.scrollListener)),this.scrollListener.unbind(r),this.scrollListener.bind(r,e),this.scrollListener.on("scroll",this.handleContainerScroll),this.scrollListener.on("resize",this.handleResize),this.scrollContainerElement=i});m(this,"handleContainerScroll",(e,r)=>{r===this.scrollContainerElement&&this.emit("scroll",this)});m(this,"handleResize",(e,r)=>{r===this.scrollContainerElement&&this.emit("scroll",this)})}get rootElement(){return this.scrollContainerElement}get contentElement(){return p(Xy,this.scrollContainerElement,"scrollContainerElement cannot be undefined"),Wr(this.scrollContainerElement)}get scrollOptions(){return p(Xy,this.options,"options cannot be undefined"),{...this.options}}handleBaseListenerDestroy(e){e.destroy()}destroy(){var r;(r=this.scrollListener)==null||r.off("scroll",this.handleContainerScroll);const e=Tn(this.contentElement);e&&g0.forEach((i,o)=>{i.unbind(e),i.containers.size===0&&(this.handleBaseListenerDestroy(i),g0.delete(o))})}}function LF(){return new SF}const BC=I("column-width");function IF(n,t,e){PP(n,t).style.width=`${e}px`}function DF(n){const e=Array.from(n.querySelector("colgroup").children).map(c=>c.getBoundingClientRect().width);if(e[0]!==0)return e;const r=It.fromTable(n),i=Array(r.colCount).fill(-1),o=n.getBoundingClientRect().left;r.toRealCells(r.cells).forEach(c=>{const d=c.col+c.colSpan-1;i[d]===-1&&(i[d]=c.cell.getBoundingClientRect().right-o)}),BC.debug(`cellRightOffsets1: ${i.join()}`);for(let c=0;c<i.length;c++){const d=i[c];if(d===-1||c===0)continue;let h=c-1;for(;i[h]===-1&&(h--,h!==-1););const C=h===-1?0:i[h],A=(d-C)/(c-h);for(let v=h+1;v<c;v++)i[v]=C+A*(v-h)}BC.debug(`cellRightOffsets2: ${i.join()}`);const s=[];let l=0;for(let c=0;c<i.length;c++){const d=i[c];s.push(d-l),l=d}return BC.debug(`widths: ${s.join()}`),s}function Xu(n){return Array.from(n.querySelector("colgroup").children).map(r=>r.getBoundingClientRect().width||Number.parseInt(r.style.width,10))}const TC=200,_F=40,MF=I("table-resize-gripper"),Qy=7,yC=(Qy-1)/2,UF=3;function OF(n,t,e){const{rows:r}=n;for(let i=0;i<r.length;i++){const o=r[i],s=Array.from(o.cells);for(let l=0;l<s.length;l++){const c=s[l],d=c.getBoundingClientRect(),h=Math.round(d.right);if(Math.abs(t-h)<=yC&&d.top<=e&&e<=d.bottom)return c}}return null}function NF(n){return!!n.rootContainer.querySelector(".table-resize-gripper")}function kC(n,t){return vi(n,t).querySelector(".table-resize-gripper")}function Yy(n,t){const e=kC(n,t);p(MF,!e,"resize gripper has already exists");const r=vi(n,t),i=B("div",["table-resize-gripper","table-indicator"],r);return B("div",["table-resize-gripper-indicator"],i),i}function Jy(n,t,e){let r=kC(n,t);r||(r=Yy(n,t));const o=Ve(t).getBoundingClientRect(),s=e.getBoundingClientRect(),l=0,c=o.height,d=n.getCustom(bi(t)).contentElement.getBoundingClientRect(),h=s.right-d.left;r.style.left=`${h-yC-za-Hu}px`,r.style.top=`${l}px`,r.style.height=`${c}px`,r.style.width=`${Qy}px`}function RC(n){n.rootContainer.querySelectorAll(".table-resize-gripper").forEach(t=>{t.remove()})}function PF(n,t,e){const i={...n.getBlockData(t),colsWidth:e};n.updateBlockData(t,i)}function FF(n,t,e,r){const i=t,o=It.fromTable(e),s=o.getCellByCellElement(i),l=s.col+s.colSpan-1,c=Xu(e);let d=r;const h=(E,A)=>{const v=A+1,R=E.col+E.colSpan;return c.slice(v,R).reduce((M,U)=>M+U,0)},C=new Set;for(let E=0;E<o.rowCount;E++){const A=o.getCell({row:E,col:l});if(C.has(A.cell))continue;C.add(A.cell);const v=A.cell,R=v.getBoundingClientRect();let L=r-R.left+yC-UF;const M=Ku(v),U=n1(n,M)||_F*A.colSpan,F=h(A,l),G=U-F;L<G&&(L=G);const W=R.left+L;d=Math.max(d,W)}return d}const KF=I("table-resize-drag-drop");class VF{constructor(t,e,r,i){m(this,"cursor","col-resize");this.editor=t,this.elem=e,this.data=r,this.onEnd=i}onDragStart(t,e,r){}onDragging(t,e,r,i,o){const{table:s,block:l,draggingRefCell:c}=t.data,h=FF(this.editor,c,s,e.x-t.dragOffsetX)-s.getBoundingClientRect().left;p(KF,c,"no dragging cell");const E=It.fromTable(s).getCellByCellElement(c),A=E.col+E.colSpan-1,v=Xu(s),R=v.slice(0,A).reduce((M,U)=>M+U,0),L=h-R;if(IF(s,A,L),L){const M=parseFloat(s.style.width);s.style.width=`${M+(L-v[A])}px`}Jy(this.editor,l,c),this.editor.selection.caret.update()}onDragEnd(t,e,r,i,o){const s=Xu(t.data.table);PF(this.editor,t.data.block,s),RC(this.editor),this.onEnd&&(this.onEnd(e),this.onEnd=null)}}function $F(n,t){const e=document.elementFromPoint(t.x,t.y);if(!e)return null;const r=et(e);return!r||!n.contains(r)||!$e(r)?null:r}I("table-resize");class HF{constructor(t){m(this,"draggingRefCell",null);m(this,"handleMouseMove",(t,e)=>{if(t.readonly||t.selectionHandler.isSelecting()&&!this.draggingRefCell||this.draggingRefCell)return;const r=e.target;if(!(r instanceof Element)||r.closest(".table-indicator"))return;const o=e,s=$F(t,o);if(!s||!Ry(s)||!t.isBlockWritable(s)){RC(t);return}this.updateGripper(s,o.x,o.y)});this.editor=t,t.domEvents.addEventListener(document,"mousemove",this.handleMouseMove)}destroy(){this.editor.domEvents.removeEventListener(document,"mousemove",this.handleMouseMove)}updateGripper(t,e,r){const i=Ve(t),o=OF(i,e,r);if(o){if(!kC(this.editor,t)){if(NF(this.editor))return;const l=Yy(this.editor,t),c={block:t,table:i,draggingRefCell:o};_g(new VF(this.editor,l,c,d=>{this.updateGripper(t,d.x,d.y)}))}Jy(this.editor,t,o)}else RC(this.editor)}}function Zy(n){n.addCustom("table-mouse-event-handler",t=>new HF(t))}const tk=I("table-insert-column");function ek(n,t,e){n.undoManager.runInGroup(()=>{var E;const r=Ve(t),i=It.fromTable(r),o=i.colCount;p(tk,e>=0&&e<=o,`insert index ${e} is out of range [0, ${o}]`);const s=i.map(A=>A.containerId),l=new Set;n.doc.beginBatchUpdate();for(let A=0;A<s.length;A++){const v=s[A],R=v[e-1],L=v[e];if(e===0||e===v.length||R!==L){const M=no(n.doc);v.splice(e,0,M)}else v.splice(e,0,R),l.add(R)}n.doc.endBatchUpdate();const c=gt.default(n.getBlockData(t));l.forEach(A=>{const v=`${A}_colSpan`,R=c[v];p(tk,typeof R=="number"&&R>1,`no colSpan for containerId ${A}, ${R}`),c[v]=R+1});const d=((E=c.colsWidth)==null?void 0:E.concat())||new Array(c.cols).fill(0);d.splice(e,0,TC);const h=It.virtualCellContainersGridToChildren(s),C={...c,cols:c.cols+1,children:h,colsWidth:d};ll(C),n.updateBlockData(t,C)})}const p0=I("table-insert-row");function wC(n,t,e){n.undoManager.runInGroup(()=>{const r=Ve(t),i=It.fromTable(r),o=i.rowCount;p(p0,e>=0&&e<=o,`insert index ${e} is out of range [0, ${o}]`);const s=i.map(E=>E.containerId),l=new Set;n.doc.beginBatchUpdate();const c=[];for(let E=0;E<i.colCount;E++){const A=e>0&&s[e-1][E],v=e<i.rowCount&&s[e][E];if(p(p0,A||v,"no top and bottom cell"),e===0||e===i.rowCount||A!==v){const R=no(n.doc);c.push(R)}else p(p0,A,"no top cell"),c.push(A),l.add(A)}n.doc.endBatchUpdate(),s.splice(e,0,c);const d=gt.default(n.getBlockData(t));l.forEach(E=>{const A=`${E}_rowSpan`,v=d[A];p(p0,typeof v=="number"&&v>1,`no rowSpan for containerId ${E}, ${v}`),d[A]=v+1});const h=It.virtualCellContainersGridToChildren(s),C={...d,rows:d.rows+1,children:h};ll(C),n.updateBlockData(t,C)})}const SC=I("paste-table-in-table-block");function jF(n,t,e,r,i){let o=It.fromBlock(e);const s=t.blocks.root[0];p(SC,s,"no table data"),p(SC,s.type==="table",`table data type is not table, but ${s.type}`);const l=s,c=o.getCellByCellElement(r),d=l.cols,h=l.rows,C=c.col,E=c.row,A=C+d,v=E+h,R=[];for(let L=C;L<A&&L<o.colCount;L++)for(let M=E;M<v&&M<o.rowCount;M++){const U=o.getCell({col:L,row:M});U.virtual?U.virtual&&R.push({col:L,row:M}):(U.colSpan>1||U.rowSpan>1)&&R.push({col:L,row:M})}n.undoManager.runInGroup(()=>{if(n.doc.beginBatchUpdate(),R.forEach(F=>{const G=It.fromBlock(e).getCell(F);(G.colSpan>1||G.rowSpan>1)&&gC(n,e,F)}),A>o.colCount)for(let F=o.colCount;F<A;F++)ek(n,e,F);if(v>o.rowCount)for(let F=o.rowCount;F<v;F++)wC(n,e,F);o=It.fromBlock(e);const L=new a0(l);let M;for(let F=0;F<L.colCount;F++)for(let G=0;G<L.rowCount;G++){const W=L.getCell({col:F,row:G});if(!W.virtual){const it=np(n.editorBlocks,t,W.containerId,i),at=C+F,xt=E+G,Mt={col:at,row:xt},Bt=o.getCellContainer(Mt);n5(n,Bt,it,i),M=Bt}}n.doc.endBatchUpdate(),p(SC,M,"no last container");const U=Ze(M);n.selection.selectBlock(U,dt(n,U))})}const LC=I("paste-in-table-block");class zF{constructor(t){m(this,"pasteData");this.editor=t,setTimeout(()=>{t.input.addHandler(this)})}destroy(){this.pasteData=void 0}async handleBeforePaste(t,e,r,i){return this.pasteData={doc:r,files:i,event:e},!1}async handleBeforePasteDoc(t,e){var E,A,v,R;if(!t.selection.range.isSimple())return this.pasteData=void 0,!1;if(t.selection.range.start.offset!==0)return this.pasteData=void 0,!1;const i=t.selection.startBlock,o=rt(i);if(Xt(o))return this.pasteData=void 0,!1;if(!uu(t,o))return this.pasteData=void 0,!1;const s=et(o);if(p(LC,s,"no parent block"),!$e(s))return this.pasteData=void 0,!1;if(e.blocks.root.length!==1)return this.pasteData=void 0,!1;if(e.blocks.root[0].type!=="table")return this.pasteData=void 0,!1;LC.debug("paste child table in table");const d=It.fromBlock(s).getCellByContainerId(ft(o)).cell;Ap(t,e);const h={blockIdMap:new Map,containerIdMap:new Map,boxIdMap:new Map};jF(t,e,s,d,h),p(LC,this.pasteData,"invalid paste data");const C=[];t.input.forEach(L=>{C.push(L)});for(let L=0;L<C.length&&!await((A=(E=C[L]).handleAfterPasteDoc)==null?void 0:A.call(E,t,e,h));L++);for(let L=0;L<C.length&&!await((R=(v=C[L]).handleAfterPaste)==null?void 0:R.call(v,t,this.pasteData.event,this.pasteData.doc));L++);return this.pasteData=void 0,!0}}function nk(n){n.addCustom("table-block-paste-event",t=>new zF(t))}const IC=I("table-select-columns");function GF(n,t,e,r,i){p(IC,$e(t),"is not a table block");const o=It.fromBlock(t);p(IC,e>=0&&e<o.colCount,"invalid from"),p(IC,r>0&&e+r<=o.colCount,"invalid count");const s=o.getCell({row:0,col:e}),l=o.getCell({row:o.rowCount-1,col:e+r-1}),c=xe(t,s.containerId,{colIndex:e,rowIndex:0}),d=xe(t,l.containerId,{colIndex:e+r-1,rowIndex:o.rowCount-1});i!=null&&i.reverse?n.selection.setSelection(d,c):n.selection.setSelection(c,d)}const DC=I("table-select-columns");function WF(n,t,e,r,i){p(DC,$e(t),"is not a table block");const o=It.fromBlock(t);p(DC,e>=0&&e<o.rowCount,"invalid from"),p(DC,r>0&&e+r<=o.rowCount,"invalid count");const s=o.getCell({row:e,col:0}),l=o.getCell({row:e+r-1,col:o.colCount-1}),c=xe(t,s.containerId,{rowIndex:e,colIndex:0}),d=xe(t,l.containerId,{rowIndex:e+r-1,colIndex:o.colCount-1});i!=null&&i.reverse?n.selection.setSelection(d,c):n.selection.setSelection(c,d)}const Act="",rk=I("get-toolbar-reference-client");function ik(n,t){const e=n.selection.range;if(!e.isSimple()){p(rk,e.start.blockId===e.end.blockId,"invalid selection range");const s=n.getBlockById(e.start.blockId);p(rk,Dt(n,s),"not a complex block");const l=Yt(n,s);if(l.getTextToolbarReferenceClient){const c=l.getTextToolbarReferenceClient(n,s);if(c)return c}}const r=e.isReverse()?t.start:t.end,i=qe(n,{anchor:r,focus:r}),o=qi(n,t.block,i);if(o.length!==0)return o[0]}function qF(n){var t,e;if(n.children){let r=!1;const i=[];for(const o of n.children){if((t=o.states)!=null&&t.includes("checked")){r=!0;break}(e=n.defaultCheckedChildren)!=null&&e.includes(o.id)&&i.push(o)}if(!r&&(i==null?void 0:i.length))for(const o of i)Array.isArray(o.states)?o.states.push("checked"):o.states=["checked"]}}function C0(n){const t=(i,o)=>{const s=i.findIndex(c=>c.id===o.id);if(s===-1){i.push(o);return}const l=i[s];if(l.value!==o.value&&delete l.value,!!l.states){if(!o.states){l.states=[];return}l.states=Tg.default(l.states,o.states)}},e=[],r=new Map;return n.forEach(i=>{var o,s;(o=i.children)!=null&&o.length&&(r.has(i.id)?(s=r.get(i.id))==null||s.push(...i.children):r.set(i.id,[...i.children])),t(e,i)}),r.forEach((i,o)=>{const s=e.find(l=>l.id===o);s&&(s.children=C0(i),qF(s))}),e}function E0(n){return n.findCustom("toolbar-handler")}const bct="";class XF{constructor(){m(this,"linkPopup",null);m(this,"form",{});m(this,"onFinished",null);m(this,"onClose",null);m(this,"handleOk",async()=>{var t;try{await this.checkValue();const{linkText:e,linkUrl:r}=this.form,i=this.formatUrl(r.getInputValue());(t=this.onFinished)==null||t.call(this,e.getInputValue()||i,i),this._destroy()}catch{}});m(this,"handleClose",()=>{var t;(t=this.onClose)==null||t.call(this),this._destroy()});m(this,"onShow",()=>{setTimeout(()=>{var t;(t=this.form.linkText)==null||t.getField().focus()},400)});m(this,"onChange",()=>{var e;const t=(e=this.linkPopup)==null?void 0:e.content.querySelector('[data-button-id="submit-button"]');t.disabled=!1});m(this,"handleTextKeyboard",t=>{var e;if(!t.isComposing){if(t.key==="Enter"){(e=this.form.linkUrl)==null||e.getField().focus(),t.stopPropagation();return}t.key==="Escape"&&this.handleClose()}});m(this,"handleUrlKeyboard",t=>{if(!t.isComposing){if(t.key==="Enter"){this.handleOk(),t.preventDefault();return}t.key==="Escape"&&this.handleClose()}})}async checkValue(){const{linkUrl:t}=this.form;if(!t.getInputValue())throw t.setFieldError(D.t("link.urlPlaceholder")),new Error(D.t("link.urlPlaceholder"))}formatUrl(t){if(!t)return"";try{new URL(t)}catch{return`${window.location.protocol}//${t}`}return t}editLink(t){var h,C;const{target:e,linkText:r,linkUrl:i,onFinished:o,onClose:s,placement:l="bottom-start"}=t;this.linkPopup=new Va(this.createPopupContent(r,i)),this.linkPopup.addListener("show",this.onShow),this.linkPopup.manualShow(e,{theme:"light",placement:l}),this.onFinished=o,s&&(this.onClose=s);const c=(h=this.linkPopup)==null?void 0:h.content.querySelector('[data-button-id="submit-button"]'),d=(C=this.linkPopup)==null?void 0:C.content.querySelector('[data-button-id="cancel-button"]');c==null||c.addEventListener("click",this.handleOk),d==null||d.addEventListener("click",this.handleClose)}createPopupContent(t,e){const r=B("div",["link-popup-content"],null);this.form.linkText=l0(r,{label:D.t("link.textLabel"),required:!1,placeholder:D.t("link.textPlaceholder"),defaultValue:t,onChange:this.onChange,onKeyDown:this.handleTextKeyboard}),this.form.linkUrl=l0(r,{className:"link-popup-gap",label:D.t("link.urlLabel"),required:!0,placeholder:D.t("link.urlPlaceholder"),defaultValue:e,onChange:this.onChange,onKeyDown:this.handleUrlKeyboard});const i=B("div",["link-popup-footer"],r),o=Cr("cancel-button",D.t("link.cancelText"));i.appendChild(o);const s=Cr("submit-button",D.t("link.submitText"),void 0,["disabled","primary"]);return i.appendChild(s),r}_destroy(){var r,i,o,s;const t=(r=this.linkPopup)==null?void 0:r.content.querySelector('[data-button-id="submit-button"]'),e=(i=this.linkPopup)==null?void 0:i.content.querySelector('[data-button-id="cancel-button"]');t==null||t.removeEventListener("click",this.handleOk),e==null||e.removeEventListener("click",this.handleClose),this.onFinished=null,this.onClose=null,this.form={},(o=this.linkPopup)==null||o.removeAllListeners(),(s=this.linkPopup)==null||s.destroy()}destroy(){this._destroy()}}function Qu(n,t){n.addCustom("link-editor",()=>new XF).editLink(t)}const QF=I("link-popup");function YF(n){return Rt(n,"link")}function Yu(n){var t,e;return(e=(t=n.getAttribute("link"))!=null?t:n.textContent)!=null?e:""}function JF(n,t,e){var i,o,s,l;if(n.isBlockWritable(t)&&e&&hr(e)){const c=e,d=(o=(i=n.editorBoxes.getBoxClass(su(c))).getBoxProperties)==null?void 0:o.call(i,n,c);if(d!=null&&d.boxCommands){const h=(l=(s=d.boxCommands["hovering-toolbar"])==null?void 0:s.commands)!=null?l:[];return{element:e,commands:h}}return{element:null,commands:[]}}if(n.isWritable()&&e&&nt(n,t)&&YF(e)){const c=B("a",["link-href-button"],null,Yu(e));c.href=Yu(e),c.target="_blank",c.rel="noopener noreferrer";const d=[{id:"link-text",name:Yu(e),disableTooltip:!0,element:c},{id:"edit-link",name:D.t("link.edit"),icon:i0},{id:"remove-link",name:D.t("link.remove"),icon:wT}];return{element:e,commands:d}}return $v(n,t,"hovering-toolbar")}function ok(n,t,e){var l;const r=zo(t,e),i=n.getBlockText(t),o={start:0,end:0};let s=(l=e.textContent)!=null?l:"";for(let c=0;c<i.length;c++){const d=i[c];if(o.end+d.insert.length>=r.end){o.end+=d.insert.length,s=d.insert;break}o.start<r.start&&(o.start+=d.insert.length,o.end=o.start)}return[o,s]}function ZF(n,t,e){const[r,i]=ok(n,t,e);n.selection.selectBlock(t,r.start,r.end);const o=Yu(e),s=(h,C)=>{try{const E=n.getBlockText(t),A=U1(E,r.start,r.end-r.start),v=to(A,r.start,h,{link:C});n.setBlockText(t,v),n.selection.selectBlock(t,r.start+h.length),n.focus()}catch(E){QF.error(E)}},l=()=>{n.selection.selectBlock(t,r.end),n.focus()},c=qi(n,t,n.selection.range)[0];if(!c)return;const d=Yi(n,t,"link-button-anchor",c);Qu(n,{target:d,linkText:i,linkUrl:o,onFinished:s,onClose:l})}function tK(n,t,e){const[r]=ok(n,t,e),i=n.getBlockText(t),o=Yu(e),s=xa(r.start,r.end-r.start,i,"link",o);n.setBlockText(t,s),n.selection.selectBlock(t,r.end)}function eK(n,t,e,r){var s,l,c;if(e){if(n.isBlockWritable(t)&&hr(e)){const h=e,C=(l=(s=n.editorBoxes.getBoxClass(su(h))).getBoxProperties)==null?void 0:l.call(s,n,h);if(C!=null&&C.boxCommands){C.boxCommands["hovering-toolbar"].executeCommand(n,t,h,r);return}return}const d=E0(n);d==null||d.disableTextToolbar(),d==null||d.hide(),setTimeout(()=>{d==null||d.enableTextToolbar()},400),r.id==="edit-link"?ZF(n,t,e):r.id==="remove-link"&&tK(n,t,e);return}const i=Vv(n,t);if(!i)return;const o=(c=i.blockCommands)==null?void 0:c["hovering-toolbar"];!o||o.executeCommand(n,t,r)}function x0(){let n=8;for(;n>0&&!document.querySelector(`div[data-style-heading='${n}']`);)n--;return n}const nK=[qh,Xh,Qh,Yh,Jh,Zh,t0,e0];class rK{constructor(t){m(this,"id","BlockTurnIntoCommandProvider");this.editor=t}getHeadingIndex(){let t=x0();return t<=4?t=5:t<8&&(t+=1),t}getAvailableCommands(t,e,r){if(nt(t,e)){const i=st(e),o=St(e),s=Ir(t,e),c=t.getBlockData(e).heading,d=[];for(let C=0;C<this.getHeadingIndex();C++)d.push({id:`heading-${C+1}`,name:D.t("commands.heading",{name:`${C+1}`}),icon:nK[C],states:c===C+1?["checked"]:[],value:`${C+1}`});const h=C=>{var A;const E=B("span",["toolbar-item-name-container"],null);for(const v of C.children)if((A=v.states)!=null&&A.includes("checked"))return E.innerHTML=v.icon||Fa,E;return E.innerHTML=Fa,E};return[{id:"turn-into",name:D.t("commands.headingGroup"),blockId:i,blockType:o,blockKind:s,element:h,groupIndex:200,dropdown:!0,manualShowChildren:!0,childrenPlacement:"bottom-start",defaultCheckedChildren:["text"],children:[{id:"text",name:D.t("commands.text"),icon:Fa,states:c?[]:["checked"]},...d],childrenType:"menu"}]}return[]}applyHeadingStyle(t,e,r){t.updateBlockData(e,{heading:r})}executeCommand(t,e,r,i){if(nt(t,e)&&(i.id.startsWith("heading-")||i.id==="text")){const o=i.value?Number(i.value):null;return this.applyHeadingStyle(t,e,o),!0}return!1}}const iK=8,Se=I("list-block"),A0=I("list-block");function Kt(n){return St(n)==="list"}function Ue(n){p(A0,Kt(n),"not a list block")}function tr(n){Ue(n);const t=n.getAttribute("data-list-type");return p(A0,t,"no list type"),t}function b0(n){return Kt(n)&&tr(n)==="text-only"}function er(n){var t,e;return Ue(n),(e=Number.parseInt((t=n.getAttribute("data-list-start"))!=null?t:"1",10))!=null?e:1}function on(n){var t,e;return Ue(n),(e=Number.parseInt((t=n.getAttribute("data-list-level"))!=null?t:"1",10))!=null?e:1}function Xa(n){Ue(n);const t=n.getAttribute("data-list-group-id");return p(A0,t,"no group id"),t}function is(n){var o,s,l,c,d;Ue(n);const t=(o=n.getAttribute("data-list-type"))!=null?o:"ordered",e=(l=Number.parseInt((s=n.getAttribute("data-list-start"))!=null?s:"1",10))!=null?l:1,r=(d=Number.parseInt((c=n.getAttribute("data-list-level"))!=null?c:"1",10))!=null?d:1,i=n.getAttribute("data-list-group-id");return p(A0,i,"no group id"),{type:t,start:e,level:r,groupId:i}}function _C(n){switch(n){case"ordered":return{ordered:!0,checkbox:null,textOnly:null};case"unordered":return{ordered:!1,checkbox:null,textOnly:null};case"checked":return{checkbox:"checked",ordered:!1,textOnly:null};case"unchecked":return{checkbox:"unchecked",ordered:!1,textOnly:null};case"text-only":return{checkbox:null,ordered:!1,textOnly:!0};default:return{checkbox:null,ordered:!0,textOnly:!1}}}function oK(n){const t={M:1e3,CM:900,D:500,CD:400,C:100,XC:90,L:50,XL:40,X:10,IX:9,V:5,IV:4,I:1};let e="",r=n;return Object.entries(t).forEach(([i,o])=>{for(;r>=o;)e+=i,r-=o}),e.toLowerCase()}const sK="abcdefghijklmnopqrstuvwxyz";function sk(n){if(n<=0)return`${n}`;const t=(n-1)%26,e=Math.floor((n-1)/26),r=sK[t];return e?sk(e)+r:r}function lK(n){return`${n}`}const lk=[lK,sk,oK];function aK(n,t){const e=lk[(n-1)%lk.length];return e(t)}function cK(n){return["\u2022","\u25E6","\u25AA"][(n-1)%3]}function os(n,t){Ue(n);const{level:e,groupId:r,type:i}=is(n);let o=ge(n);for(;o;){if(!Kt(o))return null;const{level:s,groupId:l,type:c}=is(o);if(s<e)return null;if(e===s&&((t==null?void 0:t.ignoreGroupId)||r===l)&&(c==="text-only"||i==="text-only"||i===c))return o;o=ge(o)}return null}function ak(n){return os(n,{ignoreGroupId:!0})}function ul(n){Ue(n);const{level:t,groupId:e,type:r}=is(n);let i=qt(n);for(;i;){if(Kt(i)){const{level:o,groupId:s,type:l}=is(i);if(t===o&&e===s&&(l==="text-only"||r==="text-only"||r===l))return i;if(o<t)return null}i=qt(i)}return null}function ck(n){Ue(n);const t=[];let e=os(n);for(;e;)t.unshift(e),e=os(e);return t}function Qa(n){Ue(n);const t=[];let e=ul(n);for(;e;)t.push(e),e=ul(e);return t}function Ju(n){Ue(n);let t=os(n);for(;t;){const e=os(t);if(!e)return t;t=e}return n}function uK(n){Ue(n);let t=ul(n);for(;t;){const e=ul(t);if(!e)return t;t=e}return null}function uk(n,t){const e=ck(n),r=Qa(n);return t.withSelf?[...e,n,...r]:[...e,...r]}function v0(n){Ue(n);let t=n;const e=ck(n);e.length>0&&(t=e[0]);const r=ge(t);return!r||!Kt(r)?null:on(r)<on(t)?r:null}function fK(n,t){Ue(n);let e=n;for(;e;){const r=on(e);if(r===t)return e;if(r>t)e=v0(e);else if(r<t)return null}return null}function dK(n){let t=Ju(n);for(;;){const e=v0(t);if(!e)return t;t=Ju(e)}}class hK{constructor(){m(this,"nodeMap",new Map);m(this,"rootNodes",[])}addNode(t,e){const r={block:e,children:[]};if(this.nodeMap.set(e,r),t){const i=this.nodeMap.get(t);p(Se,i,"no parent node"),i.children.push(r)}else this.rootNodes.push(r)}}function fk(n,t){const e=dK(t),r=new hK;r.addNode(null,e);let i=qt(e);for(;i&&Kt(i);){if(b0(i)){r.addNode(null,i),i=qt(i);continue}if(on(i)===0&&tr(i)!==tr(e))break;const s=v0(i);r.addNode(s,i),i=qt(i)}return r.rootNodes}function mK(n){const t=document.fullscreenEnabled||document.mozFullScreenEnabled||document.documentElement.webkitRequestFullScreen,e=r=>{if(r.requestFullscreen)return r.requestFullscreen();if(r.mozRequestFullScreen)return r.mozRequestFullScreen();if(r.webkitRequestFullScreen){try{document.fullscreenElement=n}catch{}return r.webkitRequestFullScreen()}return Promise.resolve(0)};return t?e(n):Promise.resolve(0)}function dk(){const e=(document.exitFullscreen||document.webkitExitFullscreen).bind(document)();try{document.fullscreenElement=null}catch{}return e}function MC(n){return Rt(n,"editor-in-mindmap-first")}function UC(n){if(p(Se,Kt(n),"not a list block"),Rt(n,"editor-in-mindmap-first")||!ou(n))return!0;const t=n.classList,e="editor-mindmap-root-";return!!Array.from(t).find(i=>{if(i.startsWith(e))return i})}function gK(n,t,e){const r=rt(n);if(t){const s=rt(t);p(Se,r===s,"invalid block container")}const i=bt(n);if(t){const s=bt(t);p(Se,i<=s,"invalid block index")}if(z(n,...e),!t||t===n)return;let o=qt(n);for(;o!==t;)p(Se,o,"no next button"),z(o,...e),o=qt(o);o&&z(o,...e)}function pK(n){const t=`editor-mindmap-root-${n.id}`,r=rt(n).querySelectorAll(`.${t}`);return r[r.length-1]}async function CK(n,t,e){const r=re(t),i=r.querySelector('[data-button-id="mindmap-fullscreen"]');p(Se,i,"no full screen button");const o=()=>{setTimeout(()=>{e.toMindmap(n,t,{},{reset:!0,mindmapTools:e})},300)},s=()=>{ot(r,"fullscreen"),i.innerHTML=iC,i.setAttribute(`data-editor-tooltip-${n.clientId}-dynamic`,D.t("mindmap.fullScreen")),UC(t)&&setTimeout(()=>{o()},300)};if(document.fullscreenElement===r){try{await dk()}catch(l){Se.error(l)}s()}else{try{z(r,"fullscreen"),await mK(r),o()}catch(l){Se.error(l)}i.innerHTML=uy,i.setAttribute(`data-editor-tooltip-${n.clientId}-dynamic`,D.t("mindmap.exitFullscreen"))}r.onfullscreenchange=()=>{document.fullscreenElement||s()}}function OC(n,t,e,r,i){if(t.querySelector(`[data-button-id="${e}"]`))return null;const s=Cr(e,r,i,[]);return s.setAttribute(`data-editor-tooltip-${n.clientId}-dynamic`,r),z(s,"mindmap-button"),t.appendChild(s),s}function NC(n,t){return n.querySelector(`[data-button-id="${t}"]`)}function EK(n){return NC(n,"mindmap-fullscreen")}function xK(n){return NC(n,"mindmap-fit")}function AK(n){return NC(n,"mindmap-close")}function bK(n,t,e,r){const i=OC(n,t,"mindmap-close",D.t("mindmap.close"),Gh);!i||n.domEvents.addEventListener(i,"click",()=>{r.closeMindmap(n,e)})}function vK(n,t,e,r){const i=OC(n,t,"mindmap-fit",D.t("mindmap.autoFit"),cy);!i||n.domEvents.addEventListener(i,"click",()=>{r.fitMindmap(n,e)})}function BK(n,t,e,r){if(navigator.userAgent.includes("Mobile")&&!navigator.userAgent.includes("iPad"))return;const o=OC(n,t,"mindmap-fullscreen",D.t("mindmap.fullScreen"),iC);!o||n.domEvents.addEventListener(o,"click",()=>{CK(n,e,r)})}function TK(n,t){const e=zd(t);if(!e)return;const r=xK(e);r&&(r.remove(),n.domEvents.removeAllListeners(r));const i=AK(e);i&&(i.remove(),n.domEvents.removeAllListeners(i));const o=EK(e);o&&(o.remove(),n.domEvents.removeAllListeners(o))}const Ya=new Map;function PC(n,t,e){const r=(s,l)=>{s.forEach(c=>{l?z(c.block,"to-mindmap-highlight"):ot(c.block,"to-mindmap-highlight"),r(c.children,l)})},i=fk(n,t);if(i.length===0)return;const o=i[0].block;if(e){const s=Ya.get(o);s&&(s.forEach(l=>l.cancel()),Ya.delete(o)),r(i,!0)}else{const s=setTimeout(()=>{r(i,!1),Ya.delete(o)},300),l=()=>{clearTimeout(s),Ya.delete(o)},c=Ya.get(o);c?c.push({cancel:l}):Ya.set(o,[{cancel:l}])}}const{Markmap:yK}=Z6;function kK(n,t){Ue(t);const e=fk(n,t),r=e[0].block,i=d=>({t:"text",v:Ot(d.block).textContent,d:1,c:d.children.length>0?d.children.map(C=>i(C)):void 0});let o=null;e.length>1?o={t:"root",v:"root",d:0,c:e.length>0?e.map(d=>i(d)):void 0}:o=i(e[0]);const l=d=>{if(d.length===0)return null;const h=d[d.length-1];return h.children&&h.children.length>0?l(h.children):h},c=l(e);return{root:o,block:r,nodes:e,last:c}}function B0(n,t,e,r){const{root:i,block:o,last:s}=kK(n,t);r.selectBlock&&n.selection.selectBlock(o,0,0),PC(n,o,!1),r.saveData&&n.updateBlockData(o,{viewAsMindmap:!0});const l=re(o);let c=l.querySelector(".editor-mindmap-svg");if(r.reset&&(c&&c.remove(),c=null),c)c.innerHTML="";else{const M="http://www.w3.org/2000/svg",U=l.getBoundingClientRect(),F=document.fullscreenElement===l,G=F?`${U.width}`:`${t.getBoundingClientRect().width}`,W=F?`${U.height}`:"600",it=document.createElementNS(M,"svg");it.setAttributeNS(null,"viewBox",`0 0 ${G} ${W}`),it.setAttributeNS(null,"width","100%"),it.setAttributeNS(null,"height",W),it.style.display="block",it.style.width="100%",it.style.height=`${W}px`,it.classList.add("editor-mindmap-svg"),l.appendChild(it),c=it}const d=o,C=`editor-mindmap-root-${st(o)}`;z(d,"editor-in-mindmap-first",C,"readonly"),d.contentEditable="false";const E=qt(o);E&&bt(E)<=bt(s.block)&&gK(E,s.block,["block-hidden",C]);const A=(M,U)=>{if(U.length>0){const F=U[0].parentElement;F&&(F.style.width="100vw",F.style.maxWidth="200px")}U.forEach(F=>{z(F,"editor-mindmap-node")})},v=new yK(c,{...e,autoFit:!0});v.viewHooks.transformHtml.tap(A),v.setData(i),v.fit();const R=re(o);let L=R.querySelector(".mindmap-toolbar");L||(L=B("div",["mindmap-toolbar"],R)),vK(n,L,d,r.mindmapTools),BK(n,L,d,r.mindmapTools),bK(n,L,d,r.mindmapTools),n.domEvents.addEventListener(c,"click",()=>{n.selection.selectBlock(o,0),n.input.focus()}),d.mindMap=v}function RK(n){const t=B("div",["list-to-mindmap-wrap"],null),e=Cr("list-to-mindmap",D.t("mindmap.viewAsMindMap"),ay,[],n.clientId);return t.appendChild(e),t}async function hk(n,t){const e=`editor-mindmap-root-${t.id}`,r=rt(t);ue(r).forEach(l=>{Rt(l,e)&&ot(l,e,"editor-in-mindmap-first","block-hidden")});const o=re(t);document.fullscreenElement===o&&await dk();const s=o.querySelector(".editor-mindmap-svg");!s||(p(Se,s,"no mindmap svg"),s.remove(),n.domEvents.removeAllListeners(s),TK(n,t))}function wK(n){const t=n.classList,e="editor-mindmap-root-";return Array.from(t).find(i=>{if(i.startsWith(e))return i})}async function mk(n,t){!wK(t)||(n.updateBlockData(t,{viewAsMindmap:null}),hk(n,t),n.selection.selectBlock(t,0))}function SK(n,t){const e=t.mindMap;e&&e.fit()}const T0={toMindmap:B0,closeMindmap:mk,fitMindmap:SK},vct="";class y0{constructor(t){m(this,"toMindmapButton");m(this,"currentBlock",null);m(this,"handleHoveringBlock",t=>{t&&Kt(t)&&tr(t)!=="unchecked"&&tr(t)!=="checked"&&this.editor.isWritable()?re(t).appendChild(this.toMindmapButton):this.toMindmapButton.remove()});m(this,"handleMouseEnter",()=>{const t=et(this.toMindmapButton);p(Se,t&&Kt(t),"no parent list"),PC(this.editor,t,!0),this.currentBlock=t});m(this,"handleMouseLeave",()=>{this.currentBlock&&(PC(this.editor,this.currentBlock,!1),this.currentBlock=null)});m(this,"handleClick",()=>{const t=et(this.toMindmapButton);p(Se,t&&Kt(t),"no parent list"),B0(this.editor,t,{},{saveData:!0,selectBlock:!0,mindmapTools:T0})});this.editor=t,Be.get(this.editor).addListener("change",this.handleHoveringBlock),this.toMindmapButton=RK(t),t.domEvents.addEventListener(this.toMindmapButton,"mouseenter",this.handleMouseEnter),t.domEvents.addEventListener(this.toMindmapButton,"mouseleave",this.handleMouseLeave),t.domEvents.addEventListener(this.toMindmapButton,"click",this.handleClick)}static get(t){return t.findCustomByType(y0)}destroy(){Be.get(this.editor).removeListener("change",this.handleHoveringBlock)}hide(){this.currentBlock&&(this.currentBlock=null),this.toMindmapButton.remove()}}function LK(n,t,e){var r;t==="beginDrag"&&((r=y0.get(n))==null||r.hide())}function Ja(n,t,e,r){var o;const i=(o=r==null?void 0:r.groupId)!=null?o:Z();t.forEach(s=>{const l=n.getBlockData(s);if(l.start!==e||(r==null?void 0:r.resetGroupId)){const c={...l,start:e};r!=null&&r.resetGroupId&&(c.groupId=i),n.updateBlockData(s,c)}l.textOnly||(e+=1)})}function FC(n,t,e,r){const i=uk(t,{withSelf:!0});i.length!==0&&Ja(n,i,e,r)}class k0{constructor(t,e){m(this,"listStart",0);m(this,"listBrother",null);if(this.editor=t,b0(e))return;const r=Ju(e),i=er(r);this.listStart=i,r===e?this.listBrother=ul(r):this.listBrother=r}fix(){!this.listBrother||FC(this.editor,this.listBrother,this.listStart)}}class fl{constructor(t,e,r){m(this,"listStart");m(this,"listBrother",null);this.editor=t,this.options=r;const i=Ju(e),o=er(i);this.listStart=o,this.listBrother=i,r!=null&&r.resetStart&&(this.listStart=1)}fix(){!this.listBrother||FC(this.editor,this.listBrother,this.listStart,this.options)}}class gk{constructor(t,e,r){m(this,"listStart");m(this,"listNextBrothers",[]);this.editor=t,this.listNextBrothers=Qa(e);const{start:i,resetStart:o}=r||{};this.listStart=o?1:i!=null?i:1}fix(){!this.listNextBrothers.length||Ja(this.editor,this.listNextBrothers,this.listStart)}}function IK(n,t,e){n.getBlockData(t).quoted&&(e.quoted=!0)}function KC(n,t,e,r){if(Se.debug("drag a block on a list block"),!nt(n,t))return!1;p(Se,Kt(e),"target is not a list block");const{type:i,start:o,level:s,groupId:l}=is(e),c=r==="after"?o+1:o,d=n.getBlockData(t),h={id:Z(),type:"list",groupId:l,level:s,start:c,text:d.text,..._C(i)};IK(n,e,h);let C=bt(e);const E=rt(e);r==="after"&&(C+=1);let A=null;Kt(t)&&(A=new k0(n,t));const v=n.insertBlock(ft(E),C,h,mh(h.id,0));return n.deleteBlock(t),new fl(n,v).fix(),A==null||A.fix(),!0}function DK(n,t,e,r){if(Se.debug("drag a list between text blocks"),r==="after"){const d=qt(e);if(d&&Kt(d))return KC(n,t,d,"before")}if(r==="before"){const d=ge(e);if(d&&Kt(d))return KC(n,t,d,"after")}const o={...n.getBlockData(t),groupId:Z(),start:1,level:1};let s=bt(e);const l=rt(e);r==="after"&&(s+=1),n.insertBlock(ft(l),s,o,mh(o.id,0));const c=new k0(n,t);return n.deleteBlock(t),c.fix(),!0}function _K(n,t,e,r,i){if(Fd(e))return!1;const{blockId:o}=e,s=n.getBlockById(o);p(Se,s,"no dragged block");const{isSourceBlock:l,targetBlock:c}=i;return!l&&c?(p(Se,t===c,"block !== target block"),p(Se,Kt(c),"target is not a list block"),KC(n,s,c,r)):DK(n,s,c,r)}function pk(n,t){if(!n.isWritable())return!1;const e=n.selection.range,i=n.editorCommandProviders.getCommands(e).find(o=>o.id===t);return i?(n.editorCommandProviders.executeCommand(e,i,{}),!0):!1}const MK={"Shift+CtrlOrCmd+L":n=>pk(n,"ordered-list"),"Shift+CtrlOrCmd+U":n=>pk(n,"unordered-list")};function R0(n){const t=n.getAttribute("block-padding-level");return t?Number(t):null}function UK(n,t){let e;const r=R0(t);if(!r)e=1;else{if(r>=12)return e=12,!1;e=r+1}return n.updateBlockData(t,{...n.getBlockData(t),padding:e}),!0}function Ck(n,t){const e=R0(t);if(!e)return!1;const r=n.getBlockData(t);return e>1?(n.updateBlockData(t,{...r,padding:e-1}),!0):(n.updateBlockData(t,{...r,padding:null}),!0)}function VC(n){return n.readonly||!n.isWritable()}function OK(n){return n.selection.range.getSelectedBlocks().forEach(e=>{const r=e.block;nt(n,r)&&UK(n,r)}),!0}function NK(n){return n.selection.range.getSelectedBlocks().forEach(e=>{const r=e.block;nt(n,r)&&Ck(n,r)}),!0}function PK(n){return VC(n)?!1:n.undoManager.runInGroup(()=>(OK(n),!0))}function FK(n){return VC(n)?!1:n.undoManager.runInGroup(()=>(NK(n),!0))}function KK(n){if(VC(n))return!1;if(!n.selection.range.isCollapsed())return;const t=n.selection.focusedBlock;if(!nt(n,t))return;const e=n.selection.range.focus;if(!(!e.isSimple()||e.offset!==0||!R0(t)))return Ck(n,t),!0}class $C{renderBlock(t,e,r){const{padding:i}=r;return i?{attributes:{"block-padding-level":i}}:{}}}const Bct="",VK={Tab:PK,"Shift+Tab":FK,Backspace:KK};function $K(n,t,e=1){if(!t)return null;let r=ge(n);for(;r;){const i=r.getAttribute("data-style-heading"),o=Number(r.getAttribute("data-list-level"));if(i){if(i<t)return null;if(i===t&&o===e)return Kt(r)?r:null}r=ge(r)}return null}function HK(n,t){const e=n.getAttribute("data-style-heading"),r=$K(n,e);if(r)return r;const i=ge(n);if(i&&Kt(i)&&tr(i)===t)return i;const o=qt(n);return o&&Kt(o)&&tr(o)===t?o:null}function jK(n,t,e){var R,L,M;const r=(R=e.data)!=null?R:{};let i=1;if(Kt(t))i=on(t);else{const U=R0(t);U&&(i=U+1),i>8&&(i=8)}const o=(L=r.listType)!=null?L:"ordered";if(o==="text-only")return null;const s=n.getBlockData(t);let l=(M=s.text)!=null?M:[],d=fe(l);const h=e.offset||0;h<=un(l)&&(l=_n(l,h).right,d=d.substring(0,h));let C=1;o==="ordered"&&(C=Number.parseInt(d,10)||1);let E=Z();const A=HK(t,o);if(A)if(on(A)===i){if(bt(t)>bt(A))C=er(A)+1;else{const U=er(A);U>1&&(C=U-1),new gk(n,A,{start:C+1}).fix()}E=Xa(A)}else{const U=fK(A,i);U&&(C=er(U)+1)}else Kt(t)&&new gk(n,t,{start:1}).fix();const v={id:Z(),type:"list",level:i,start:C,groupId:E,ordered:!1,text:l};return s.quoted&&(v.quoted=!0),s.heading&&(v.heading=s.heading),o==="ordered"?v.ordered=!0:(o==="checked"||o==="unchecked")&&(v.checkbox=o),{blockData:v,onConverted:(U,F)=>{new fl(U,F).fix()}}}function Za(n){return n.textOnly?"text-only":n.checkbox?n.checkbox:n.ordered?"ordered":"unordered"}function zK(n){var e,r;if(n.checkbox)return"";const t=(e=n.level)!=null?e:1;return n.ordered?`${aK(t,(r=n.start)!=null?r:1)}.`:cK(t)}function w0(n){return n==="checked"||n==="unchecked"}function Ek(n,t,e,r){const i=t,{containerId:o,blockIndex:s}=r[r.length-1];if(s===0)return!0;const l=e.blocks[o][s-1];if(l.type!=="list")return!0;const c=Za(i),d=Za(l);return c!==d&&(!w0(c)||!w0(d))||(i.level||1)>(l.level||1)}function xk(n,t,e,r){const i=t,{containerId:o,blockIndex:s}=r[r.length-1];if(s===e.blocks[o].length-1)return!0;const l=e.blocks[o][s+1];if(l.type!=="list")return!0;const c=Za(i),d=Za(l);return c!==d&&(!w0(c)||!w0(d))||(i.level||1)>(l.level||1)}function GK(n,t,e,r,i){var s,l,c;const o=t;if(r==="text")return((s=On.convertTo)==null?void 0:s.call(On,n,t,e,"text",i))||"";if(r==="markdown"){let d=((l=On.convertTo)==null?void 0:l.call(On,n,t,e,"markdown",i))||"";o.checkbox==="checked"?d=`[x] ${d}`:o.checkbox==="unchecked"&&(d=`[ ] ${d}`),o.ordered?d=`${o.start}. ${d}`:d=`- ${d}`;const h=o.level||0;return d=(h>0?" ".repeat(h-1):"")+d,Ek(n,t,e,i)&&(d=`${d}`),xk(n,t,e,i)&&(d=`${d}`,h<=1&&(d+=`
|
|
614
|
+
`)),d}if(r==="html"){let d=((c=On.convertTo)==null?void 0:c.call(On,n,t,e,"html",i))||"";d=d.replace("<p>","").replace("</p>",""),o.checkbox==="checked"?d=`<input type="checkbox" checked="checked" disabled="disabled" /> ${d}`:o.checkbox==="unchecked"&&(d=`<input type="checkbox" disabled="disabled" /> ${d}`);let h="ul",C="";if(o.ordered)switch(d=`<li value="${o.start}">${d}</li>`,h="ol",o.level){case 2:case 5:case 8:C="list-style-type: lower-alpha;";break;case 3:case 6:C="list-style-type: lower-roman;";break}else d=`<li>${d}</li>`;return Ek(n,t,e,i)&&(d=`<${h}${C?` style="${C}"`:""}>${d}`),xk(n,t,e,i)&&(d=`${d}</${h}>`),d}return""}function Ak(n){const t=B("label",["editor-check-list-wrapper"],null);n&&z(t,"editor-check-list-wrapper-checked");const e=B("span",["editor-check-box"],t);return B("span",["editor-check-box-inner"],e),t}function WK(n,t){const e=Za(t);if(e!=="text-only"){if(e==="checked"){n.append(Ak(!0));return}if(e==="unchecked"){n.append(Ak(!1));return}n.innerText=zK(t)}}function qK(n){const t=B("div",["list-container"],null),e=B("button",["list-marker"],t);return WK(e,n),t}function tc(n,t){Ue(t);const e=n.getBlockData(t),r={id:Z(),type:"text",text:e.text};e.heading&&(r.heading=e.heading),e.heading&&(r.heading=e.heading);const i=new k0(n,t),o=rt(t),s=bt(t);n.deleteBlock(t);const l=mh(r.id,0);if(uu(n,o)&&!Xt(o)){const c=we(o);n.insertBlock(ft(o),s,r,l),n.deleteBlock(c)}else n.insertBlock(ft(o),s,r,l);i.fix()}function XK(n){if(!n.selection.range.isCollapsed())return!1;const t=n.selection.focusedBlock;if(!Kt(t))return!1;const e=n.selection.range.focus;return!e.isSimple()||e.offset!==0?!1:(tc(n,t),!0)}function bk(n){let t=qt(n);if(!t)return null;const e=ul(n);for(;t!==e;){if(p(Se,t,"no next block"),Kt(t))return on(t)>on(n)?t:null;if(t=qt(t),!t)return null}return null}function HC(n){const t=[];let e=bk(n);if(!e)return t;for(;e;){const r=ul(e);t.push({block:e,children:HC(e)}),e=r}return t}function QK(n){const t=(r,i)=>{i.push(r.block),r.children.forEach(o=>t(o,i))},e=[];return n.forEach(r=>t(r,e)),e}function vk(n,t){return on(t)!==1}function Bk(n,t,e){t.forEach(r=>{const i=n.getBlockData(r.block);n.updateBlockData(r.block,{...i,groupId:e,level:(i.level||1)-1}),r.children.length&&Bk(n,r.children,i.groupId)})}function jC(n,t){if(!vk(n,t))return!1;const e=on(t);if(e===1)return!1;let r=Z(),i=1,o=tr(t);const s=e-1,l=v0(t);l&&(r=Xa(l),i=er(l)+1,o!=="text-only"&&(o=tr(l)));const c=HC(t),d=n.getBlockData(t),h={...d,groupId:r,level:s,start:i,..._C(o)};n.updateBlockData(t,h),n.doc.beginBatchUpdate(),Bk(n,c,d.groupId),n.doc.endBatchUpdate(),new fl(n,t).fix();const E=bk(t);return E&&new fl(n,E,{resetStart:!0,resetGroupId:!0}).fix(),!0}const YK=I("list-block");function JK(n,t,e){p(YK,Kt(t),"not a list block");const r={...n.getBlockData(t),id:Z()};return e!=null&&e.level&&(r.level=e.level),e!=null&&e.start&&(r.start=e.start),e!=null&&e.keepText||delete r.text,(r==null?void 0:r.checkbox)==="checked"&&(r.checkbox="unchecked"),r}function ZK(n){if(Ue(n),!b0(n))return n;let t=os(n);for(;t;){if(!b0(t))return t;t=os(t)}return null}function tV(n,t,e,r){const i=new fl(n,r),o=er(r)+1;Ra(n,t,e,{forceInsertAfter:!0,newBlockData:JK(n,r,{start:o})}),i.fix()}function eV(n){var s;if(n.selection.range.isCollapsed()){const l=n.selection.focusedBlock;if(Kt(l)&&dt(n,l)===0)return on(l)===1?tc(n,l):jC(n,l),!0}n.clearSelectedContents();const t=n.selection.focusedBlock;if(!Kt(t))return!1;const e=n.selection.range.focus;if(!e.isSimple())return!1;const r=e.offset,o=(s=r===dt(n,t)?ZK(t):t)!=null?s:t;return tV(n,t,r,o),!0}function Tk(n){p(Se,Kt(n),"not a list block");const{level:t}=is(n);let e=ge(n);for(;e;){if(Kt(e)){const{level:r}=is(e);if(t===r)return e;if(r<t)return null}e=ge(e)}return null}function yk(n,t){return Ue(t),Tk(t)?on(t)<iK:!1}function nV(n,t,e){let r=ge(t);p(Se,r,"no prev brother");const i=on(e);for(;r;){if(r===e)return null;if(Kt(r)&&on(r)===i+1)return r;r=ge(r)}return null}function kk(n,t){if(!yk(n,t))return!1;Ue(t);const e=Tk(t);p(Se,e,"no list prev brother");const r=e,i=nV(n,t,r),o=on(r)+1;let s=Z(),l=1,c=tr(t);i&&(s=Xa(i),l=er(i)+1,c=tr(i));const d=HC(t),C={...n.getBlockData(t),groupId:s,level:o,start:l,..._C(c)};return n.updateBlockData(t,C),n.doc.beginBatchUpdate(),QK(d).forEach(A=>{const v=n.getBlockData(A);n.updateBlockData(A,{...v,level:(v.level||1)+1})}),n.doc.endBatchUpdate(),!0}function rV(n,t,e){return t.length===0||!t.every(r=>Kt(r.block))?!1:e==="increase"?yk(n,t[0].block):vk(n,t[0].block)}function Rk(n,t,e){if(!rV(n,t,e))return!1;const r=t[0].block,i=on(r),o=t.filter(d=>on(d.block)<=i),s=uk(r,{withSelf:!1}),l=new Set(o.map(d=>d.block)),c=s.filter(d=>!l.has(d));return n.undoManager.runInGroup(()=>{let d=null;c.length>0&&(d=new fl(n,c[0])),o.forEach(h=>{e==="increase"?kk(n,h.block):jC(n,h.block)}),d==null||d.fix()}),!0}function iV(n,t){return kk(n,t)}function oV(n,t){return jC(n,t)}function sV(n){const t=n.selection.range.getSelectedBlocks();if(t.length>1)return Rk(n,t,"increase"),!0;const e=t[0].block;if(!Kt(e))return!1;const r=new k0(n,e);return iV(n,e)&&(r.fix(),new fl(n,e).fix()),!0}function lV(n){const t=n.selection.range.getSelectedBlocks();if(t.length>1)return Rk(n,t,"decrease"),!0;const e=t[0].block;return Kt(e)?(oV(n,e),!0):!1}class aV{constructor(t){this.editor=t}handleBeforeKeyDown(t,e){const r=t.selection.range.getSelectedBlocks();if(r.length===0||!r.some(o=>Kt(o.block)))return!1;switch(e.key){case"Enter":return this.handleEnter(e);case"Backspace":return this.handleBackspace();case"Tab":return this.handleTab(e);default:return!1}}handleEnter(t){const e=this.editor.selection.range.getSelectedBlocks()[0];return!e.block||!Kt(e.block)||ai(t,"Shift+Enter")?!1:this.editor.undoManager.runInGroup(()=>eV(this.editor))}handleBackspace(){return this.editor.undoManager.runInGroup(()=>XK(this.editor))}handleTab(t){return ai(t,"Shift+Tab")?this.editor.undoManager.runInGroup(()=>lV(this.editor)):this.editor.undoManager.runInGroup(()=>sV(this.editor))}}class cV{constructor(t){m(this,"effectedBlockIds",new Map);m(this,"handleBeforeClearSelection",()=>{this.effectedBlockIds.clear();const t=this.editor.selection.range.getSelectedBlocks();if(t.length===0)return;const e=new Set;t.forEach(i=>{const o=i.block;Kt(o)&&e.add(o)});const r=new Map;Array.from(e.values()).forEach(i=>{var c;const o=Ju(i),{start:s}=is(o);r.set(st(o),s);const l=(c=uK(i))!=null?c:i;r.set(st(l),s)}),this.effectedBlockIds=r});m(this,"handleAfterClearSelection",()=>{Array.from(this.effectedBlockIds.entries()).forEach(([t,e])=>{const r=this.editor.findBlockById(t);!r||FC(this.editor,r,e)}),this.effectedBlockIds.clear()});this.editor=t,this.editor.addListener("beforeClearSelection",this.handleBeforeClearSelection),this.editor.addListener("afterClearSelection",this.handleAfterClearSelection)}destroy(){this.editor.removeListener("beforeClearSelection",this.handleBeforeClearSelection),this.editor.removeListener("afterClearSelection",this.handleAfterClearSelection)}}const uV=I("customize-list-start-menu");class fV{constructor(t){m(this,"popup");m(this,"block",null);m(this,"show",(t,e)=>{const r=e.querySelector("div.list-container");p(uV,r,"list-block mark does not exist"),this.block=e,this.popup.manualShow(r,{theme:"light"})});m(this,"createDialogContent",()=>{const t=B("div",["customize-start-panel"],null);B("span",["customize-start-panel-title"],t,D.t("list.numberLabel"));const e=this.createNumericInput();t.appendChild(e);const r=B("button",["customize-start-panel-button"],t,D.t("list.confirm"));return this.editor.domEvents.addEventListener(t,"keydown",this.handleKeydown),this.editor.domEvents.addEventListener(r,"click",this.handleOk),t});m(this,"handleDialogShow",()=>{const t=this.block;if(!t)return;const e=this.popup.popupContent,r=e.querySelector("button.customize-start-panel-button"),i=e.querySelector("input.customize-start-panel-input"),o=er(t);!r||!i||requestAnimationFrame(()=>{i.focus(),i.value=String(o)})});m(this,"handleOk",()=>{const e=this.popup.popupContent.querySelector("input.customize-start-panel-input"),r=this.block;if(!r)return;const i=Number(e.value);!i||(this.editor.undoManager.runInGroup(()=>{Ja(this.editor,[r,...Qa(r)],i,{resetGroupId:!0})}),this.popup.close("clickItem"))});m(this,"handleKeydown",(t,e)=>{const r=e;r.isComposing||(r.key==="Escape"?this.popup.close("cancelBar"):r.key==="Enter"&&this.handleOk())});this.editor=t,this.popup=new Va(this.createDialogContent()),this.popup.on("show",this.handleDialogShow)}destroy(){this.popup.destroy()}createNumericInput(){const t=B("input",["customize-start-panel-input"],null);t.type="number",t.min="1";const e=()=>{const i=t.value.replace(/[^\d]/g,"").replace(/^0+/,""),o=parseInt(i,10);o<=0||Number.isNaN(o)?t.value="":t.value=i};return this.editor.domEvents.addEventListener(t,"input",e),t}}function dV(n,t){return Xa(n)===Xa(t)}function hV(n,t){const e=ak(t);return e?dV(e,t)?er(e)!==er(t)-1:!0:!1}function mV(n,t){return os(t)?!0:er(t)!==1}function gV(n,t){return Ue(t),[{id:"continue-numbering",name:D.t("list.continueList"),states:hV(n,t)?[]:["disabled"]},{id:"start-new-list",name:D.t("list.restartList"),states:mV(n,t)?[]:["disabled"]},{id:"set-numbering-value",name:D.t("list.changeNumber")}]}function pV(n,t,e){var r,i;if(Ue(t),e.id==="continue-numbering"){const o=ak(t);o&&Ja(n,[t,...Qa(t)],er(o)+1,{resetGroupId:!0,groupId:Xa(o)})}if(e.id==="start-new-list"&&n.undoManager.runInGroup(()=>{Ja(n,[t,...Qa(t)],1,{resetGroupId:!0})}),e.id==="set-numbering-value"){const o=(r=n.options.componentsOptions)==null?void 0:r.list;if((i=o==null?void 0:o.onChangeStart)!=null&&i.call(o,n,t,e))return;n.addCustom("list-customize-start-dialog",()=>new fV(n)).show(n,t)}}class CV{constructor(t){m(this,"menu");m(this,"handleClick",(t,e)=>{const r=aa(e,"div.list-container");if(r&&this.editor.isWritable()){const i=et(r);p(Se,i,"no parent block"),Ue(i);const o=t.getBlockData(i);if(o&&o.checkbox){t.updateBlockData(i,{...o,checkbox:o.checkbox==="checked"?"unchecked":"checked"});return}if(tr(i)==="unordered")return;this.menu.updateItems(this.getCommandItems(i)),this.menu.manualShow(r),this.activeList(r,!0)}});m(this,"handleMenuClose",()=>{var e;const t=(e=this.menu.tippyInstance)==null?void 0:e.reference;t&&this.activeList(t,!1)});m(this,"handleMenuClick",(t,e)=>{var i;const r=(i=this.menu.tippyInstance)==null?void 0:i.reference;if(r){const o=et(r);o&&pV(this.editor,o,e)}});this.editor=t,this.editor.addListener("click",this.handleClick),this.menu=new Zo([]),this.menu.addListener("close",this.handleMenuClose),this.menu.addListener("click",this.handleMenuClick)}destroy(){this.editor.removeListener("click",this.handleClick),this.menu.removeListener("close",this.handleMenuClose)}getCommandItems(t){return gV(this.editor,t)}activeList(t,e){const r=et(t);!r||(e?(z(t,"active"),z(r,"active")):(ot(t,"active"),ot(r,"active")))}}class EV{constructor(t){this.editor=t}handleBeforeKeyDown(t,e){const r=t.selection.range.getSelectedBlocks();if(r.length===0)return!1;const i=r[0].block;if(!Kt(i)||!UC(i))return!1;if(e.key==="ArrowUp"||e.key==="ArrowLeft"){const o=js(i);return o&&t.selection.selectBlock(o,dt(t,o)),!0}if(e.key==="ArrowDown"||e.key==="ArrowRight"){const o=zs(i);return o&&t.selection.selectBlock(o,0),!0}return(e.key==="Delete"||e.key==="Backspace"||e.key==="Escape")&&mk(t,i),!0}}function xV(n,t,e,r,i){vp(n,"list-block-init",()=>{setTimeout(()=>{n.input.addHandler(new EV(n)),n.input.addHandler(new aV(n)),n.addCustom("list-clear-selection-handler",()=>new cV(n)),n.addCustom("list-marker-menu",()=>new CV(n))})});const o=On.createBlockContent(n,t,e,r,i),s=i,{level:l,start:c,groupId:d}=s,h=Za(s);r.setAttribute("data-list-level",`${l||1}`),r.setAttribute("data-list-start",`${c||1}`),r.setAttribute("data-list-group-id",`${d}`),r.setAttribute("data-list-type",h);const C=qK(s);return r.insertBefore(C,o),s.viewAsMindmap?setTimeout(()=>{const E=n.getBlockById(i.id);E&&B0(n,E,{},{mindmapTools:T0,saveData:!1})}):setTimeout(()=>{const E=n.getBlockById(i.id);E&&hk(n,E)}),o}const AV={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"}},bV={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"}},vV={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"}};D.mergeLang({"zh-CN":AV,"en-US":bV,"ja-JP":vV});const Tct="",wk={...On,blockType:"list",createBlockContent:xV,convertFrom:jK,convertTo:GK,handleDrop:_K,notify:LK},zC=I("paragraph");class BV{constructor(t){m(this,"id","BlockParagraphProvider");this.editor=t}isChecked(t,e){return!!(t[e]||t.level&&(t.ordered===!0&&!t.checkbox&&e==="ordered-list"||t.ordered===!1&&!t.checkbox&&e==="unordered-list")||e==="check-list"&&t.checkbox)}getAvailableCommands(t,e){const r=[],i={"unordered-list":[D.t("commands.unordered"),ze("CtrlOrCmd+Shift+U"),bT],"ordered-list":[D.t("commands.ordered"),ze("CtrlOrCmd+Shift+L"),AT],"check-list":[D.t("commands.check"),void 0,vT],link:[D.t("commands.link"),ze("CtrlOrCmd+K"),Jp],quoted:[D.t("commands.quote"),void 0,BT]};if(nt(t,e)){const o=st(e),s=St(e),l=Ir(t,e),c=t.getBlockData(e);Object.entries(i).forEach(([d,[h,C,E]])=>{const A=[];if(this.isChecked(c,d)&&A.push("checked"),d==="link"){if(!t.selection.range.isSimple())return;t.selection.range.getSelectedBlocks().length!==1&&A.push("disabled")}r.push({blockId:o,blockType:s,blockKind:l,id:d,name:h,desc:C,states:A,icon:E,groupIndex:600})})}return r}convertLink(t,e,r){p(zC,Or(e.start),""),p(zC,Or(e.start),"");const i="bottom-start",o=e.start.offset,s=e.end.offset,l=(A,v)=>{t.undoManager.runInGroup(()=>{try{const R=t.selection.range.isCollapsed();let L;if(R){L=to(t.getBlockText(r),s,A,{link:v}),t.setBlockText(r,L);return}L=fh(t.getBlockText(r),o,s,A),L=gu(o,A.length,L,"link",v),t.setBlockText(r,L),t.selection.selectBlock(r,o+A.length),t.focus()}catch(R){zC.error(R)}})},c=()=>{t.selection.selectBlock(r,s),t.focus()},d=qi(t,r,e)[0];if(!d)return;const h=Yi(t,r,"link-button-anchor",d),C=t.getBlockText(r),E=Aa(C,o);Qu(t,{target:h,linkText:t.getSelectedText(),linkUrl:(E==null?void 0:E.link)||"",onFinished:l,onClose:c,placement:i})}convertToList(t,e,r){const i=Wd(t,e,"list",{offset:0,data:{listType:r}});i&&t.undoManager.runInGroup(()=>{const o=bt(e),s=rt(e);t.insertBlock(ft(s),o,i.blockData),t.deleteBlock(e)})}executeCommand(t,e,r,i){var c;if(!nt(t,e))return!1;const o=i.id,s=(c=i.states)==null?void 0:c.includes("checked");let l=!1;if(o==="unordered-list"&&(s?tc(t,e):this.convertToList(t,e,"unordered"),l=!0),o==="ordered-list"&&(s?tc(t,e):this.convertToList(t,e,"ordered"),l=!0),o==="check-list"&&(s?tc(t,e):this.convertToList(t,e,"unchecked"),l=!0),o==="quoted"){const h=t.getBlockData(e).quoted;t.updateBlockData(e,{quoted:h?void 0:!0}),l=!0}if(o==="link"){const d=E0(t);d==null||d.disableTextToolbar(),d==null||d.hide(),setTimeout(()=>{d==null||d.enableTextToolbar()},1e3),this.convertLink(t,r,e),l=!0}return l}}const TV={left:Pa,right:n0,center:r0};class yV{constructor(t){m(this,"id","BlockAlignProvider");this.editor=t}applyAlignStyle(t,e,r){Object.keys(TV).includes(r)?t.updateBlockData(e,{align:r}):t.updateBlockData(e,{align:null})}isChecked(t,e){return t.align===e}getAvailableCommands(t,e,r){if(nt(t,e)){const i=st(e),o=St(e),s=Ir(t,e),l=t.getBlockData(e),c=d=>{var C;const h=B("span",["toolbar-item-name-container"],null);for(const E of d.children)if((C=E.states)!=null&&C.includes("checked"))return h.innerHTML=E.icon||Pa,h;return h.innerHTML=Pa,h};return[{id:"align",name:D.t("commands.alignGroup"),blockId:i,blockType:o,blockKind:s,groupIndex:700,dropdown:!0,element:c,manualShowChildren:!0,childrenPlacement:"bottom-start",defaultCheckedChildren:["align-left"],children:[{id:"align-left",name:D.t("commands.alignLeft"),icon:Pa,states:this.isChecked(l,"left")?["checked"]:[]},{id:"align-center",name:D.t("commands.alignCenter"),icon:r0,states:this.isChecked(l,"center")?["checked"]:[]},{id:"align-right",name:D.t("commands.alignRight"),icon:n0,states:this.isChecked(l,"right")?["checked"]:[]}],childrenType:"menu"}]}return[]}executeCommand(t,e,r,i){if(!nt(t,e))return!1;if(i.id.startsWith("align")){const o=i.id.replace(/^align-/,"");return this.applyAlignStyle(t,e,o),!0}return!1}}function Sk(n){const e=n.selection.range;if(e.isCollapsed()||e.start.blockId!==e.end.blockId||!e.start.isSimple()||!e.end.isSimple()||e.end.offset-e.start.offset!==1)return!1;const r=n.getBlockById(e.start.blockId);return Eu(n,r,e.start.offset).charType==="box"}const kV=I("toolbar-handler"),RV={id:"",name:"",type:"separator"};class ec{constructor(t){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,"isInToolbar",t=>this.toolbar.isInCommandBar(t.target));m(this,"handleButtonClick",(t,e)=>{const r=this.editor.getCustom("editor-tooltip");r.lastClickButtonId=e.id,this.toolbarType==="text"?(this.editor.editorCommandProviders.executeCommand(this.editor.selection.range,e,{}),this.editor.isWritable()&&this.showTextToolbar("click")):this.hoveringBlock&&eK(this.editor,this.hoveringBlock,this.hoveringTextChild,e)});m(this,"handleClose",()=>{lC(this.editor)&&this.editor.focus()});m(this,"handleClosing",(t,e)=>{if(this.toolbarType==="object"){const r=Nb(e);if(this.hoveringBlock===r)return!1}return!0});m(this,"handleDocumentMouseDown",t=>{t.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",(t,e,r,i)=>{if(!(this.hoveringBlock===t&&this.hoveringTextChild===e)&&(this.hoveringBlock=t,this.hoveringTextChild=e,!(this.toolbar.isVisible&&this.toolbarType==="text"))){if(!t){this.toolbar.close("fromHover");return}this.showObjectToolbar(i)}});m(this,"handleSelectionChange",Me.default(t=>{var r;if(p(kV,t===this.editor,"editor mismatch"),t.selection.range.isCollapsed()||this.mouseDown){if(this.toolbarType==="object"){const i=(r=this.toolbar.tippyInstance)==null?void 0:r.reference,o=this.editor.selection.focusedBlock;if(i&&ne(i,o))return}this.toolbar.close("selectionChange"),this.oldRange=null;return}if(!this.editor.isWritable()){this.toolbar.close("selectionChange"),this.oldRange=null;return}if(t.selection.range.getSelectedBlocks().length===0){this.toolbar.close("selectionChange"),this.oldRange=null;return}this.oldRange&&this.oldRange.isEqual(t.selection.range)||(this.oldRange=t.selection.range,this.showTextToolbar("selectionChange"))},50));this.editor=t;const e=t.options.componentsOptions.popover;this.toolbar=new Pu([],void 0,{tooltipId:t.clientId,id:"editor-toolbar",overflowBoundary:e==null?void 0:e.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(),t.addListener("selectionChanged",this.handleSelectionChange),Be.get(t).addListener("childChange",this.handleHoveringBlockChildChange),Be.get(t).addFilter(this),t.editorCommandProviders.registerCommandProvider(new rK(t)),t.editorCommandProviders.registerCommandProvider(new BV(t)),t.editorCommandProviders.registerCommandProvider(new yV(t))}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),Be.get(this.editor).removeListener("childChange",this.handleHoveringBlockChildChange)}isInBlock(t,e){return t!==this.hoveringBlock?!1:!!(e.target&&e.target instanceof Node&&this.toolbar.popper&&ne(this.toolbar.popper,e.target))}bindEvents(){document.addEventListener("mousedown",this.handleDocumentMouseDown)}unbindEvents(){document.removeEventListener("mousedown",this.handleDocumentMouseDown)}update(t){!this.editor.isWritable()||this.showTextToolbar(t)}showTextToolbar(t){var R,L;if(this._disableTextToolbar)return;const e=this.editor.selection.range,r=e.getSelectedBlocks();if(r.length===0)return;const i=r[0];if(!i)return;if(r.length===1){if(pe(i.block)){t==="click"&&this.showObjectToolbar(null);return}if(Dt(this.editor,i.block)&&e.isSimple())return}if(Sk(this.editor))return;if(Gi(i.block)){this.toolbar.close("selectionChange");return}const o=this.editor.editorCommandProviders.getCommands(this.editor.selection.range),s=new Map;o.forEach(M=>{const U=M.groupIndex,F=s.get(U);F?F.push(M):s.set(U,[M])});const l=[[]],c=Array.from(s.entries()).sort((M,U)=>M[0]-U[0]);for(let M=0;M<c.length;M++){const[,U]=c[M];if(U.length===0)continue;let F=l[l.length-1];F.length>0&&F[F.length-1].groupIndex!==U[U.length-1].groupIndex&&(F=[],l.push(F)),F.push(...C0(U))}if(l.length===0){this.toolbar.close("selectionChange");return}this.toolbarType="text";const d=[];if(l.forEach((M,U)=>{const F=M.sort((G,W)=>{var it,at;return((it=G.order)!=null?it:0)-((at=W.order)!=null?at:0)});d.push(...F),U!==l.length-1&&d.push(RV)}),d.length===0){this.toolbar.close("selectionChange");return}this.toolbar.updateItems(d);const h=r[r.length-1],C=!this.editor.selection.range.isReverse()&&h!==i,E=C?h:i,A=ik(this.editor,E),v=Yi(this.editor,E.block,"editor-quick-menu",A);this.toolbar.manualShow(v,{placement:C?"bottom":"top",offset:[0,C?5:10]}),(L=(R=this.toolbar.tippyInstance)==null?void 0:R.popperInstance)==null||L.update()}showObjectToolbar(t){var l,c,d;if(!this.hoveringBlock||this.mouseDown)return;const e=this.hoveringBlock,r=this.hoveringTextChild,{commands:i,element:o}=JF(this.editor,e,r);if(!i.length||!o){this.toolbar.close("fromHover");return}this.toolbarType="object",this.toolbar.isVisible&&((c=(l=this.toolbar)==null?void 0:l.tippyInstance)==null?void 0:c.reference)!==o&&this.toolbar.close("fromHover");const s=()=>{let h;const C=o.getClientRects(),E=[];if(Array.from(C).forEach(A=>{const{y:v}=A;E.includes(v)||E.push(v)}),E.length>1){if(h=r?C[C.length-1]:C[0],t)for(let A=0;A<C.length;A++){const v=C[A],R=new DOMRect(v.x-4,v.y-4,v.width+8,v.height+8);if(R.x<t.clientX&&t.clientX<R.right&&R.y<t.clientY&&t.clientY<R.bottom){h=v;break}}}else{if(h=o.getBoundingClientRect(),r){const A=r.getBoundingClientRect();return new DOMRect(A.x,A.y,A.width,A.height)}return new DOMRect(C[0].x,C[0].y,C[0].width,C[0].height)}if(t){const A=h.y,v=t.clientX;return new DOMRect(v,A,10,h.height)}return h};this.toolbar.updateItems(i),this.toolbar.isVisible||(this.toolbar.manualShow(o,{placement:r?"bottom":"top",getReferenceClientRect:s}),(d=this.toolbar.tippyInstance)!=null&&d.popper&&(this.toolbar.tippyInstance.popper.style.paddingTop="10px",this.toolbar.tippyInstance.popper.style.paddingBottom="5px"))}static register(t){return t.addCustom("toolbar-handler",e=>new ec(e))}static get(t){return t.getCustom("toolbar-handler")}}function S0(n,t,e){n.getBlockData(t).heading===e?n.updateBlockData(t,{heading:null}):n.updateBlockData(t,{heading:e})}function Lk(n,t,e){["left","center","right"].includes(e)?n.updateBlockData(t,{align:e}):n.updateBlockData(t,{align:null})}function GC(n,t){const r=n.getBlockData(t).quoted;n.updateBlockData(t,{quoted:r?void 0:!0})}function WC(n,t){return!!(n[t]||n.level&&(n.ordered===!0&&!n.checkbox&&t==="ordered-list"||n.ordered===!1&&!n.checkbox&&t==="unordered-list")||t==="check-list"&&n.checkbox)}function qC(n,t,e){if(!n.selection.range.focus.isSimple())return;const i=n.getBlockData(t);let o;switch(e){case"unordered-list":o=WC(i,"unordered-list")?void 0:"unordered";break;case"ordered-list":o=WC(i,"ordered-list")?void 0:"ordered";break;case"check-list":o=WC(i,"check-list")?void 0:"unchecked";break}if(o){const s=Wd(n,t,"list",{offset:0,data:{listType:o}});s&&n.undoManager.runInGroup(()=>{const l=bt(t),c=rt(t);n.deleteBlock(t);const d=n.insertBlock(ft(c),l,s.blockData);s.onConverted&&s.onConverted(n,d)})}else tc(n,t)}const wV=Object.freeze(Object.defineProperty({__proto__:null,applyHeadingStyle:S0,applyAlignStyle:Lk,applyQuoteStyle:GC,applyList:qC},Symbol.toStringTag,{value:"Module"})),SV=[qh,Xh,Qh,Yh,Jh,Zh,t0,e0],LV={Unordered:eC,Ordered:nC,Checkbox:Zp,Quote:tC};function Ik(n,t){const e=n;e.blockOptions=t,e.itemType="insert-block",n.children&&n.children.forEach(r=>Ik(r,t))}function IV(){return{name:"basic",insertBlockCommandItems:[{id:"text",icon:Fa,name:D.t("commands.text"),order:0,group:"basics",value:"text"}]}}function XC(n=1){var i;const t={name:"basic",insertBlockCommandItems:[]};let e=x0();e<=4?e=5:e<8&&(e+=1);let r=n;for(;r<=e;){const o=`heading-${r}`;(i=t.insertBlockCommandItems)==null||i.push({id:o,icon:SV[r-1],name:D.t("quickMenu.basic.heading.title",{heading:String(r)}),order:r,group:"basics",value:String(r),subText:Bn(o)}),r++}return t}function DV(){const n={name:"basic",insertBlockCommandItems:[]};return["Unordered","Ordered","Checkbox","Quote"].forEach((e,r)=>{var o;const i=`insert-${e.toLocaleLowerCase()}`;(o=n.insertBlockCommandItems)==null||o.push({id:i,name:D.t(`quickMenu.basic.${e.toLocaleLowerCase()}`),icon:LV[e],value:e.toLocaleLowerCase(),group:"basics",order:10+r,subText:Bn(i)})}),n}class Dk{constructor(t){this.withPlainText=t}getCommands(){const t=IV(),e=XC(),r=DV();return[...this.withPlainText?t.insertBlockCommandItems||[]:[],...e.insertBlockCommandItems||[],...r.insertBlockCommandItems||[]]}updateBlock(t,e,r,i){const{value:o,id:s}=i;return s.startsWith("heading-")?S0(t,r,Number.parseInt(o!=null?o:"1",10)||1):o==="ordered"||o==="unordered"||o==="checkbox"?qC(t,r,{ordered:"ordered-list",unordered:"unordered-list",checkbox:"check-list"}[o]):o==="quote"&&GC(t,r),null}async handleUpdateBlockCore(t,e){const r=t.getBlockByIndex(e.containerId,e.blockIndex);return this.updateBlock(t,e.containerId,r,e.item)}async handleInsertEmptyBlockCore(t,e){const{containerId:r,blockIndex:i}=e,o=t.insertTextBlock(void 0,r,i);return this.updateBlock(t,e.containerId,o,e.item)}async executeCommand(t,e,r){if(r.from==="quick-menu"){const i=t.getBlockById(r.blockId),o=t.getParentContainer(i),s=ft(o),l=t.getBlockIndex(i);t.undoManager.runInGroup(()=>this.handleUpdateBlockCore(t,{item:e,containerId:s,blockIndex:l})),t.focus()}else r.from==="block-menu"&&(t.undoManager.runInGroup(()=>this.handleInsertEmptyBlockCore(t,{item:e,containerId:r.containerId,blockIndex:r.blockIndex})),t.focus());return null}}const _k={basics:100,system:200,common:300,thirdParty:400};class QC{constructor(){m(this,"dataUrl","");m(this,"error",null)}destroy(){}setDataUrl(t){this.error=null,this.dataUrl=t}setError(t){this.dataUrl="",this.error=t}}const _V=I("mathjax-converter"),MV="MathJax-script",UV=30,Mk=8;async function OV(n){var r;window.MathJax||(window.MathJax={options:{skipHtmlTags:["script","noscript","style","textarea","pre","code","annotation","annotation-xml","body"]}});const t=n.getComponentOptions("mathjax"),e=((r=t==null?void 0:t.cdn)==null?void 0:r.mathjax)||"https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js";await Os(e,MV)}function NV(){try{window.MathJax&&window.MathJax.texReset()}catch{}}async function YC(n,t){const e="mathjax2Svg";try{await Sr.lock(e),NV(),await OV(n);const r=await window.MathJax.tex2svgPromise(t),i=r.querySelector("merror");if(i)throw new Error(i.textContent);return r.querySelector("svg").outerHTML}catch(r){throw _V.error(r),r}finally{Sr.release(e)}}function PV(n){const t=new DOMParser().parseFromString(n,"image/svg+xml"),e={width:0,height:0};if(t&&t.firstChild){const r=t.firstChild,i=r.getAttribute("height"),o=r.style.minWidth;i&&(e.width=parseInt(o,10)*Mk+UV,e.height=parseInt(i,10)*Mk)}return e}async function Uk(n,t){const e=await YC(n,t);return e?await Fg(e,"image/svg+xml"):""}async function Ok(n,t){const r=await YC(n,t),i=new File([r],"math.svg");return(await n.doc.uploadResource(i)).resourceId}async function FV(n,t){const e=await YC(n,t),r=PV(e),i=e,o=new File([i],"math.svg");return{resourceId:(await n.doc.uploadResource(o)).resourceId,...r}}const Nk=I("edit-mathjax");class KV{constructor(){m(this,"editMathjaxPopup",null);m(this,"onChange",null);m(this,"tex","");m(this,"observer",null);m(this,"handleClose",t=>{var r;const e=t.content.querySelector("textarea");if(e){const i=e.value;i!==this.tex&&((r=this.onChange)==null||r.call(this,i,!0))}});m(this,"handleKeyup",t=>{var e;t.isComposing||(t.key==="Escape"&&((e=this.editMathjaxPopup)==null||e.close("cancelBar")),this.handleChange(t.target.value))});m(this,"handleChange",Me.default(t=>{var e;(e=this.onChange)==null||e.call(this,t,!1)},300))}editMathjax(t,e,r,i){if(!this.editMathjaxPopup)this.editMathjaxPopup=new Va(this.createPopupContent(e),{id:"mathjax-popover"});else{const o=this.getTextarea();o.value=e}this.tex=e,this.editMathjaxPopup.manualShow(t,{theme:"light",placement:i==null?void 0:i.placement}),this.editMathjaxPopup.removeAllListeners("close"),this.editMathjaxPopup.addListener("close",this.handleClose),this.onChange=r}createPopupContent(t){const e=B("textarea",["mathjax-editor-textarea"],null);return e.value=t,e.addEventListener("keyup",this.handleKeyup),this.textareaWatcher(e),e}textareaWatcher(t){const e=t;e.onblur=()=>{var i;(i=this.editMathjaxPopup)!=null&&i.isVisible&&t.focus()};const r=()=>{setTimeout(()=>{t.focus()})};this.observer=new IntersectionObserver(r,{}),this.observer.observe(t)}getTextarea(){p(Nk,this.editMathjaxPopup,"no exists mathjax editor popup");const t=this.editMathjaxPopup.content.querySelector("textarea");return p(Nk,t,"no textarea"),t}destroy(){var t,e;this.onChange=null,(t=this.observer)==null||t.disconnect(),(e=this.editMathjaxPopup)==null||e.removeAllListeners()}}function Pk(n,t,e,r,i){n.addCustom("mathjax-editor",()=>new KV).editMathjax(t,e.trim(),r,i)}function Fk(){return{insert:" ",attributes:{id:Z(),box:!0,type:"math",tex:" ",src:"",created:Date.now()}}}function L0(n,t){const e=n.getBoxData(t),r=et(t);if(!r)return;const i=zo(r,t);n.selection.selectBlock(r,i.start,i.end);const o=async(s,l)=>{if(!s.trim()){n.updateBoxData({...e,tex:s,src:null});return}try{await Sr.lock("convertAndUploadMathjax");const c=await Ok(n,s);n.updateBoxData({...e,tex:s,src:c})}catch(c){const d=n.getBoxData(t);n.addCustom(`mathjax-box-${d.id}`,()=>new QC).setError(c),n.updateBoxData({...e,tex:s,src:""})}finally{Sr.release("convertAndUploadMathjax"),l&&n.focus()}};Pk(n,t,e.tex,o)}const Kk=I("mathjax-box");function JC(n,t){n.selection.updateSelection(null);const e=t.target;!e||!(e instanceof HTMLElement)||n.domEvents.removeEventListener(e,null,JC)}async function VV(n,t,e){try{if(!t.tex.trim())return;const r=await Uk(n,t.tex),i=n.findBoxById(t.id);if(!i)return;const o=lu(i);o.innerHTML="";const s=B("img",["mathjax"],o);s.src=r,e.setDataUrl(r),n.domEvents.addEventListener(s,"load",JC)}catch(r){e.setError(r);const i=n.findBoxById(t.id);if(!i)return;const o=i.querySelector(".mathjax-tex-text");z(o,"mathjax-error"),o.innerText=r.message,n.selection.updateSelection(null)}}function $V(n,t,e,r){const i=r,o=n.addCustom(`mathjax-box-${i.id}`,()=>new QC);if(i.src||o.dataUrl){const c=B("img",["mathjax"],e);c.src=n.doc.buildResourceUrl(i.src||o.dataUrl),n.domEvents.addEventListener(c,"load",JC);return}const s=["mathjax-tex-text"];let l=i.tex;l.trim()?o.error&&(l=o.error.message,s.push("mathjax-error")):l=D.t("mathjax.emptyText"),B("span",s,e,l),VV(n,i,o)}function HV(n,t){const e={id:Z(),box:!0,type:"math",tex:t,src:"",created:Date.now()};return Ok(n,t).then(r=>{if(!n.findBoxById(e.id))return;const o={...e,src:r};n.updateBoxData(o)}).catch(r=>{Kk.error(`failed to convert and upload mathjax: ${JSON.stringify(r)}`)}),e}function jV(n,t,e,r){const i=t;return r==="text"?i.tex:r==="markdown"?` $${i.tex}$ `:i.src?`<img src="${n.doc.buildResourceUrl(i.src,{withToken:!0})}" />`:`<code>$${i.tex}$</code>`}function zV(n,t,e){const r=et(t);p(Kk,r,"failed to get block"),!(n.readonly||!n.isBlockWritable(r))&&L0(n,t)}function GV(){return{abstract:D.t("mathjax.abstract")}}const Vk={boxType:"math",updateBoxContent:$V,convertFrom:HV,convertTo:jV,handleClickBox:zV,getBoxProperties:GV};async function WV(n,t,e){try{const r=t.embedData,i=await Uk(n,r.mathjaxText),o=n.findBlockById(t.id);if(!o)return;const s=Ot(o);s.innerHTML="";const l=B("img",["mathjax"],s);l.src=i,e.setDataUrl(i)}catch(r){e.setError(r)}}function qV(n,t){if(n.readonly||!t.target||!(t.target instanceof Node))return;const e=et(t.target);if(!e||!pe(e)||Ge(e)!=="math")return;const r=Ot(e),i=r.querySelector("img")||r.querySelector("span.mathjax-tex-text");if(!i||!ne(i,t.target))return;const s=n.getBlockData(e).embedData;Pk(n,i,s.mathjaxText,async l=>{const{resourceId:c,width:d,height:h}=await FV(n,l),C={mathjaxText:l,src:c,width:d,height:h};n.updateEmbedData(e,C)},{placement:"bottom"})}function XV(n,t,e){const r=e.embedData,{src:i,width:o}=r,s=n.addCustom(`mathjax-block-${e.id}`,()=>new QC);if(n.domEvents.addEventListener(t,"click",qV),!r.mathjaxText.trim()){B("span",["mathjax-tex-text"],t,D.t("mathjax.emptyText"));return}if(i||s.dataUrl){const l=B("img",["mathjax"],t);l.src=n.doc.buildResourceUrl(i||s.dataUrl),o&&(l.style.minWidth=`${o}px`,setTimeout(()=>{const c=t.getBoundingClientRect().width;o>c?(z(t,"mathjax-overflow"),t.style.overflow="auto",t.style.setProperty("--mathjax-width",`${o}px`)):(ot(t,"mathjax-overflow"),t.removeAttribute("data-mathjax-width"),t.style.removeProperty("--mathjax-width"))}));return}s.error,B("span",["mathjax-tex-text"],t,r.mathjaxText),WV(n,e,s)}function QV(n,t,e){if(!nt(n,t))return null;const r=n.getBlockString(t).trim();if(!r||!r.startsWith("$$")||!r.endsWith("$$"))return null;const i=Mg(r,"$");if(!i)return null;const o={mathjaxText:i,src:""};return{blockData:{id:Z(),type:"embed",embedType:"math",embedData:o}}}function YV(n){return{name:"Mathjax"}}function JV(n,t){var r;const e=Ot(t);n.domEvents.removeAllListeners(e),n.findCustom("mathjax-editor")&&((r=n.getCustom("mathjax-editor").editMathjaxPopup)==null||r.close("cancelBar"))}function ZV(n,t,e,r){const i=t.embedData;return r==="html"?`<img src="${n.doc.buildResourceUrl(i.src,{withToken:!0})}" />`:r==="markdown"?`
|
|
615
615
|
$$${i.mathjaxText}$$
|
|
616
616
|
`:i.mathjaxText}function t$(){return{abstract:D.t("mathjax.abstract")}}const e$={embedType:"math",createEmbedContent:XV,getOptions:YV,convertFrom:QV,handleDeleteBlock:JV,convertTo:ZV,getBlockProperties:t$},yct="",n$={mathjax:{emptyText:"\u7A7A\u7684\u516C\u5F0F",abstract:"\u516C\u5F0F"}},r$={mathjax:{emptyText:"Empty formula",abstract:"Formula"}},i$={mathjax:{emptyText:"\u6570\u5F0F\u306A\u3057",abstract:"\u6570\u5F0F"}};D.mergeLang({"zh-CN":n$,"en-US":r$,"ja-JP":i$});function o$(n,t,e,r){const i=n.getBlockByIndex(t,e),o=n.getBlockText(i),{left:s}=_n(o,r);if(!fe(s).endsWith("$$$$"))return!1;const c=r-4,d=r,h={id:Z(),box:!0,type:"math",tex:" ",src:"",created:Date.now()};return n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(i,c,d-c),n.insertBoxToBlock(i,c,h),setTimeout(()=>{const C=n.getBoxById(h.id);L0(n,C)})}),!0}class s${handleAfterInsertText(t,e,r,i,o){return!!(o===" "&&o$(t,e,r,i))}}var yn={exports:{}};/**
|
|
617
617
|
* @license
|
|
@@ -620,9 +620,9 @@ $$${i.mathjaxText}$$
|
|
|
620
620
|
* Released under MIT license <https://lodash.com/license>
|
|
621
621
|
* Based on Underscore.js 1.8.3 <http://underscorejs.org/LICENSE>
|
|
622
622
|
* Copyright Jeremy Ashkenas, DocumentCloud and Investigative Reporters & Editors
|
|
623
|
-
*/(function(n,t){(function(){var e,r="4.17.21",i=200,o="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",s="Expected a function",l="Invalid `variable` option passed into `_.template`",c="__lodash_hash_undefined__",d=500,h="__lodash_placeholder__",C=1,E=2,A=4,v=1,R=2,L=1,M=2,U=4,F=8,G=16,W=32,it=64,at=128,xt=256,Mt=512,Bt=30,le="...",te=800,kn=16,be=1,Kn=2,Ii=3,Rn=1/0,mn=9007199254740991,Di=17976931348623157e292,go=0/0,Ar=4294967295,Tx=Ar-1,yx=Ar>>>1,kx=[["ary",at],["bind",L],["bindKey",M],["curry",F],["curryRight",G],["flip",Mt],["partial",W],["partialRight",it],["rearg",xt]],ps="[object Arguments]",bl="[object Array]",vl="[object AsyncFunction]",po="[object Boolean]",Ht="[object Date]",_i="[object DOMException]",Cs="[object Error]",bc="[object Function]",pm="[object GeneratorFunction]",gn="[object Map]",Bl="[object Number]",Cm="[object Null]",br="[object Object]",Em="[object Promise]",Rx="[object Proxy]",Tl="[object RegExp]",ye="[object Set]",yl="[object String]",kl="[object Symbol]",xm="[object Undefined]",Rl="[object WeakMap]",Am="[object WeakSet]",wl="[object ArrayBuffer]",Es="[object DataView]",Lf="[object Float32Array]",If="[object Float64Array]",Df="[object Int8Array]",_f="[object Int16Array]",Mf="[object Int32Array]",Uf="[object Uint8Array]",Of="[object Uint8ClampedArray]",Nf="[object Uint16Array]",Pf="[object Uint32Array]",wx=/\b__p \+= '';/g,Sx=/\b(__p \+=) '' \+/g,Lx=/(__e\(.*?\)|\b__t\)) \+\n'';/g,bm=/&(?:amp|lt|gt|quot|#39);/g,vm=/[&<>"']/g,Ix=RegExp(bm.source),Dx=RegExp(vm.source),_x=/<%-([\s\S]+?)%>/g,Mx=/<%([\s\S]+?)%>/g,Bm=/<%=([\s\S]+?)%>/g,Ux=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ox=/^\w*$/,Nx=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ff=/[\\^$.*+?()[\]{}|]/g,Px=RegExp(Ff.source),Kf=/^\s+/,Fx=/\s/,Kx=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,de=/\{\n\/\* \[wrapped with (.+)\] \*/,Vx=/,? & /,$x=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Tm=/[()=,{}\[\]\/\s]/,Sl=/\\(\\)?/g,Hx=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,vc=/\w*$/,ym=/^[-+]0x[0-9a-f]+$/i,km=/^0b[01]+$/i,jx=/^\[object .+?Constructor\]$/,zx=/^0o[0-7]+$/i,Gx=/^(?:0|[1-9]\d*)$/,Wx=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Bc=/($^)/,qx=/['\n\r\u2028\u2029\\]/g,Tc="\\ud800-\\udfff",Xx="\\u0300-\\u036f",Qx="\\ufe20-\\ufe2f",Yx="\\u20d0-\\u20ff",Rm=Xx+Qx+Yx,yc="\\u2700-\\u27bf",wm="a-z\\xdf-\\xf6\\xf8-\\xff",Jx="\\xac\\xb1\\xd7\\xf7",Zx="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",tA="\\u2000-\\u206f",vr=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ll="A-Z\\xc0-\\xd6\\xd8-\\xde",Mi="\\ufe0e\\ufe0f",je=Jx+Zx+tA+vr,Vf="['\u2019]",eA="["+Tc+"]",Jr="["+je+"]",Zr="["+Rm+"]",$f="\\d+",kc="["+yc+"]",Hf="["+wm+"]",Co="[^"+Tc+je+$f+yc+wm+Ll+"]",Ui="\\ud83c[\\udffb-\\udfff]",jf="(?:"+Zr+"|"+Ui+")",zf="[^"+Tc+"]",xs="(?:\\ud83c[\\udde6-\\uddff]){2}",Gf="[\\ud800-\\udbff][\\udc00-\\udfff]",As="["+Ll+"]",bs="\\u200d",Sm="(?:"+Hf+"|"+Co+")",nA="(?:"+As+"|"+Co+")",Lm="(?:"+Vf+"(?:d|ll|m|re|s|t|ve))?",Il="(?:"+Vf+"(?:D|LL|M|RE|S|T|VE))?",Rc=jf+"?",Eo="["+Mi+"]?",rA="(?:"+bs+"(?:"+[zf,xs,Gf].join("|")+")"+Eo+Rc+")*",iA="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",oA="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Wf=Eo+Rc+rA,Im="(?:"+[kc,xs,Gf].join("|")+")"+Wf,qf="(?:"+[zf+Zr+"?",Zr,xs,Gf,eA].join("|")+")",sA=RegExp(Vf,"g"),lA=RegExp(Zr,"g"),Xf=RegExp(Ui+"(?="+Ui+")|"+qf+Wf,"g"),aA=RegExp([As+"?"+Hf+"+"+Lm+"(?="+[Jr,As,"$"].join("|")+")",nA+"+"+Il+"(?="+[Jr,As+Sm,"$"].join("|")+")",As+"?"+Sm+"+"+Lm,As+"+"+Il,oA,iA,$f,Im].join("|"),"g"),cA=RegExp("["+bs+Tc+Rm+Mi+"]"),uA=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,fA=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],dA=-1,he={};he[Lf]=he[If]=he[Df]=he[_f]=he[Mf]=he[Uf]=he[Of]=he[Nf]=he[Pf]=!0,he[ps]=he[bl]=he[wl]=he[po]=he[Es]=he[Ht]=he[Cs]=he[bc]=he[gn]=he[Bl]=he[br]=he[Tl]=he[ye]=he[yl]=he[Rl]=!1;var ae={};ae[ps]=ae[bl]=ae[wl]=ae[Es]=ae[po]=ae[Ht]=ae[Lf]=ae[If]=ae[Df]=ae[_f]=ae[Mf]=ae[gn]=ae[Bl]=ae[br]=ae[Tl]=ae[ye]=ae[yl]=ae[kl]=ae[Uf]=ae[Of]=ae[Nf]=ae[Pf]=!0,ae[Cs]=ae[bc]=ae[Rl]=!1;var hA={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},mA={"&":"&","<":"<",">":">",'"':""","'":"'"},gA={"&":"&","<":"<",">":">",""":'"',"'":"'"},pA={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Dm=parseFloat,CA=parseInt,_m=typeof Mn=="object"&&Mn&&Mn.Object===Object&&Mn,EA=typeof self=="object"&&self&&self.Object===Object&&self,Je=_m||EA||Function("return this")(),Qf=t&&!t.nodeType&&t,xo=Qf&&!0&&n&&!n.nodeType&&n,wc=xo&&xo.exports===Qf,Dl=wc&&_m.process,Vn=function(){try{var K=xo&&xo.require&&xo.require("util").types;return K||Dl&&Dl.binding&&Dl.binding("util")}catch{}}(),Yf=Vn&&Vn.isArrayBuffer,Jf=Vn&&Vn.isDate,Zf=Vn&&Vn.isMap,Mm=Vn&&Vn.isRegExp,td=Vn&&Vn.isSet,ed=Vn&&Vn.isTypedArray;function wn(K,q,j){switch(j.length){case 0:return K.call(q);case 1:return K.call(q,j[0]);case 2:return K.call(q,j[0],j[1]);case 3:return K.call(q,j[0],j[1],j[2])}return K.apply(q,j)}function xA(K,q,j,mt){for(var wt=-1,Gt=K==null?0:K.length;++wt<Gt;){var Ie=K[wt];q(mt,Ie,j(Ie),K)}return mt}function $n(K,q){for(var j=-1,mt=K==null?0:K.length;++j<mt&&q(K[j],j,K)!==!1;);return K}function AA(K,q){for(var j=K==null?0:K.length;j--&&q(K[j],j,K)!==!1;);return K}function Um(K,q){for(var j=-1,mt=K==null?0:K.length;++j<mt;)if(!q(K[j],j,K))return!1;return!0}function ti(K,q){for(var j=-1,mt=K==null?0:K.length,wt=0,Gt=[];++j<mt;){var Ie=K[j];q(Ie,j,K)&&(Gt[wt++]=Ie)}return Gt}function Sc(K,q){var j=K==null?0:K.length;return!!j&&Ao(K,q,0)>-1}function nd(K,q,j){for(var mt=-1,wt=K==null?0:K.length;++mt<wt;)if(j(q,K[mt]))return!0;return!1}function Ce(K,q){for(var j=-1,mt=K==null?0:K.length,wt=Array(mt);++j<mt;)wt[j]=q(K[j],j,K);return wt}function Oi(K,q){for(var j=-1,mt=q.length,wt=K.length;++j<mt;)K[wt+j]=q[j];return K}function rd(K,q,j,mt){var wt=-1,Gt=K==null?0:K.length;for(mt&&Gt&&(j=K[++wt]);++wt<Gt;)j=q(j,K[wt],wt,K);return j}function bA(K,q,j,mt){var wt=K==null?0:K.length;for(mt&&wt&&(j=K[--wt]);wt--;)j=q(j,K[wt],wt,K);return j}function id(K,q){for(var j=-1,mt=K==null?0:K.length;++j<mt;)if(q(K[j],j,K))return!0;return!1}var vA=Ic("length");function Om(K){return K.split("")}function ir(K){return K.match($x)||[]}function od(K,q,j){var mt;return j(K,function(wt,Gt,Ie){if(q(wt,Gt,Ie))return mt=Gt,!1}),mt}function _l(K,q,j,mt){for(var wt=K.length,Gt=j+(mt?1:-1);mt?Gt--:++Gt<wt;)if(q(K[Gt],Gt,K))return Gt;return-1}function Ao(K,q,j){return q===q?Oc(K,q,j):_l(K,ei,j)}function vs(K,q,j,mt){for(var wt=j-1,Gt=K.length;++wt<Gt;)if(mt(K[wt],q))return wt;return-1}function ei(K){return K!==K}function Lc(K,q){var j=K==null?0:K.length;return j?Dc(K,q)/j:go}function Ic(K){return function(q){return q==null?e:q[K]}}function sd(K){return function(q){return K==null?e:K[q]}}function Ml(K,q,j,mt,wt){return wt(K,function(Gt,Ie,Qt){j=mt?(mt=!1,Gt):q(j,Gt,Ie,Qt)}),j}function Nm(K,q){var j=K.length;for(K.sort(q);j--;)K[j]=K[j].value;return K}function Dc(K,q){for(var j,mt=-1,wt=K.length;++mt<wt;){var Gt=q(K[mt]);Gt!==e&&(j=j===e?Gt:j+Gt)}return j}function _c(K,q){for(var j=-1,mt=Array(K);++j<K;)mt[j]=q(j);return mt}function Ul(K,q){return Ce(q,function(j){return[j,K[j]]})}function bo(K){return K&&K.slice(0,Nc(K)+1).replace(Kf,"")}function pn(K){return function(q){return K(q)}}function Bs(K,q){return Ce(q,function(j){return K[j]})}function ni(K,q){return K.has(q)}function Ol(K,q){for(var j=-1,mt=K.length;++j<mt&&Ao(q,K[j],0)>-1;);return j}function ld(K,q){for(var j=K.length;j--&&Ao(q,K[j],0)>-1;);return j}function Pm(K,q){for(var j=K.length,mt=0;j--;)K[j]===q&&++mt;return mt}var Fm=sd(hA),ad=sd(mA);function Km(K){return"\\"+pA[K]}function Vm(K,q){return K==null?e:K[q]}function vo(K){return cA.test(K)}function Mc(K){return uA.test(K)}function Nl(K){for(var q,j=[];!(q=K.next()).done;)j.push(q.value);return j}function Bo(K){var q=-1,j=Array(K.size);return K.forEach(function(mt,wt){j[++q]=[wt,mt]}),j}function Uc(K,q){return function(j){return K(q(j))}}function or(K,q){for(var j=-1,mt=K.length,wt=0,Gt=[];++j<mt;){var Ie=K[j];(Ie===q||Ie===h)&&(K[j]=h,Gt[wt++]=j)}return Gt}function To(K){var q=-1,j=Array(K.size);return K.forEach(function(mt){j[++q]=mt}),j}function Pl(K){var q=-1,j=Array(K.size);return K.forEach(function(mt){j[++q]=[mt,mt]}),j}function Oc(K,q,j){for(var mt=j-1,wt=K.length;++mt<wt;)if(K[mt]===q)return mt;return-1}function $m(K,q,j){for(var mt=j+1;mt--;)if(K[mt]===q)return mt;return mt}function Ts(K){return vo(K)?Fl(K):vA(K)}function sr(K){return vo(K)?Fc(K):Om(K)}function Nc(K){for(var q=K.length;q--&&Fx.test(K.charAt(q)););return q}var Pc=sd(gA);function Fl(K){for(var q=Xf.lastIndex=0;Xf.test(K);)++q;return q}function Fc(K){return K.match(Xf)||[]}function Hm(K){return K.match(aA)||[]}var Kc=function K(q){q=q==null?Je:yo.defaults(Je.Object(),q,yo.pick(Je,fA));var j=q.Array,mt=q.Date,wt=q.Error,Gt=q.Function,Ie=q.Math,Qt=q.Object,Vc=q.RegExp,cd=q.String,Sn=q.TypeError,Kl=j.prototype,ud=Gt.prototype,ko=Qt.prototype,Vl=q["__core-js_shared__"],Ro=ud.toString,Wt=ko.hasOwnProperty,jm=0,fd=function(){var a=/[^.]+$/.exec(Vl&&Vl.keys&&Vl.keys.IE_PROTO||"");return a?"Symbol(src)_1."+a:""}(),$l=ko.toString,dd=Ro.call(Qt),zm=Je._,Gm=Vc("^"+Ro.call(Wt).replace(Ff,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),wo=wc?q.Buffer:e,ri=q.Symbol,Hl=q.Uint8Array,jl=wo?wo.allocUnsafe:e,Ni=Uc(Qt.getPrototypeOf,Qt),zl=Qt.create,hd=ko.propertyIsEnumerable,Gl=Kl.splice,Wm=ri?ri.isConcatSpreadable:e,Wl=ri?ri.iterator:e,So=ri?ri.toStringTag:e,Lo=function(){try{var a=ea(Qt,"defineProperty");return a({},"",{}),a}catch{}}(),qm=q.clearTimeout!==Je.clearTimeout&&q.clearTimeout,Xm=mt&&mt.now!==Je.Date.now&&mt.now,Qm=q.setTimeout!==Je.setTimeout&&q.setTimeout,ql=Ie.ceil,Xl=Ie.floor,Ql=Qt.getOwnPropertySymbols,Ym=wo?wo.isBuffer:e,md=q.isFinite,BA=Kl.join,y=Uc(Qt.keys,Qt),S=Ie.max,_=Ie.min,N=mt.now,H=q.parseInt,$=Ie.random,X=Kl.reverse,J=ea(q,"DataView"),ct=ea(q,"Map"),Ct=ea(q,"Promise"),ut=ea(q,"Set"),At=ea(q,"WeakMap"),Jt=ea(Qt,"create"),Oe=At&&new At,ln={},Hn=na(J),Br=na(ct),TA=na(Ct),yA=na(ut),Ee=na(At),ce=ri?ri.prototype:e,ve=ce?ce.valueOf:e,Tr=ce?ce.toString:e;function k(a){if(De(a)&&!Dt(a)&&!(a instanceof Vt)){if(a instanceof jn)return a;if(Wt.call(a,"__wrapped__"))return HL(a)}return new jn(a)}var Pi=function(){function a(){}return function(u){if(!ke(u))return{};if(zl)return zl(u);a.prototype=u;var g=new a;return a.prototype=e,g}}();function ys(){}function jn(a,u){this.__wrapped__=a,this.__actions__=[],this.__chain__=!!u,this.__index__=0,this.__values__=e}k.templateSettings={escape:_x,evaluate:Mx,interpolate:Bm,variable:"",imports:{_:k}},k.prototype=ys.prototype,k.prototype.constructor=k,jn.prototype=Pi(ys.prototype),jn.prototype.constructor=jn;function Vt(a){this.__wrapped__=a,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Ar,this.__views__=[]}function ent(){var a=new Vt(this.__wrapped__);return a.__actions__=zn(this.__actions__),a.__dir__=this.__dir__,a.__filtered__=this.__filtered__,a.__iteratees__=zn(this.__iteratees__),a.__takeCount__=this.__takeCount__,a.__views__=zn(this.__views__),a}function nnt(){if(this.__filtered__){var a=new Vt(this);a.__dir__=-1,a.__filtered__=!0}else a=this.clone(),a.__dir__*=-1;return a}function rnt(){var a=this.__wrapped__.value(),u=this.__dir__,g=Dt(a),x=u<0,T=g?a.length:0,w=grt(0,T,this.__views__),O=w.start,P=w.end,V=P-O,Q=x?P:O-1,Y=this.__iteratees__,tt=Y.length,ht=0,Et=_(V,this.__takeCount__);if(!g||!x&&T==V&&Et==V)return dL(a,this.__actions__);var Tt=[];t:for(;V--&&ht<Et;){Q+=u;for(var Nt=-1,yt=a[Q];++Nt<tt;){var jt=Y[Nt],zt=jt.iteratee,cr=jt.type,Dn=zt(yt);if(cr==Kn)yt=Dn;else if(!Dn){if(cr==be)continue t;break t}}Tt[ht++]=yt}return Tt}Vt.prototype=Pi(ys.prototype),Vt.prototype.constructor=Vt;function Yl(a){var u=-1,g=a==null?0:a.length;for(this.clear();++u<g;){var x=a[u];this.set(x[0],x[1])}}function int(){this.__data__=Jt?Jt(null):{},this.size=0}function ont(a){var u=this.has(a)&&delete this.__data__[a];return this.size-=u?1:0,u}function snt(a){var u=this.__data__;if(Jt){var g=u[a];return g===c?e:g}return Wt.call(u,a)?u[a]:e}function lnt(a){var u=this.__data__;return Jt?u[a]!==e:Wt.call(u,a)}function ant(a,u){var g=this.__data__;return this.size+=this.has(a)?0:1,g[a]=Jt&&u===e?c:u,this}Yl.prototype.clear=int,Yl.prototype.delete=ont,Yl.prototype.get=snt,Yl.prototype.has=lnt,Yl.prototype.set=ant;function Io(a){var u=-1,g=a==null?0:a.length;for(this.clear();++u<g;){var x=a[u];this.set(x[0],x[1])}}function cnt(){this.__data__=[],this.size=0}function unt(a){var u=this.__data__,g=Jm(u,a);if(g<0)return!1;var x=u.length-1;return g==x?u.pop():Gl.call(u,g,1),--this.size,!0}function fnt(a){var u=this.__data__,g=Jm(u,a);return g<0?e:u[g][1]}function dnt(a){return Jm(this.__data__,a)>-1}function hnt(a,u){var g=this.__data__,x=Jm(g,a);return x<0?(++this.size,g.push([a,u])):g[x][1]=u,this}Io.prototype.clear=cnt,Io.prototype.delete=unt,Io.prototype.get=fnt,Io.prototype.has=dnt,Io.prototype.set=hnt;function Do(a){var u=-1,g=a==null?0:a.length;for(this.clear();++u<g;){var x=a[u];this.set(x[0],x[1])}}function mnt(){this.size=0,this.__data__={hash:new Yl,map:new(ct||Io),string:new Yl}}function gnt(a){var u=ug(this,a).delete(a);return this.size-=u?1:0,u}function pnt(a){return ug(this,a).get(a)}function Cnt(a){return ug(this,a).has(a)}function Ent(a,u){var g=ug(this,a),x=g.size;return g.set(a,u),this.size+=g.size==x?0:1,this}Do.prototype.clear=mnt,Do.prototype.delete=gnt,Do.prototype.get=pnt,Do.prototype.has=Cnt,Do.prototype.set=Ent;function Jl(a){var u=-1,g=a==null?0:a.length;for(this.__data__=new Do;++u<g;)this.add(a[u])}function xnt(a){return this.__data__.set(a,c),this}function Ant(a){return this.__data__.has(a)}Jl.prototype.add=Jl.prototype.push=xnt,Jl.prototype.has=Ant;function ii(a){var u=this.__data__=new Io(a);this.size=u.size}function bnt(){this.__data__=new Io,this.size=0}function vnt(a){var u=this.__data__,g=u.delete(a);return this.size=u.size,g}function Bnt(a){return this.__data__.get(a)}function Tnt(a){return this.__data__.has(a)}function ynt(a,u){var g=this.__data__;if(g instanceof Io){var x=g.__data__;if(!ct||x.length<i-1)return x.push([a,u]),this.size=++g.size,this;g=this.__data__=new Do(x)}return g.set(a,u),this.size=g.size,this}ii.prototype.clear=bnt,ii.prototype.delete=vnt,ii.prototype.get=Bnt,ii.prototype.has=Tnt,ii.prototype.set=ynt;function HS(a,u){var g=Dt(a),x=!g&&ra(a),T=!g&&!x&&Ls(a),w=!g&&!x&&!T&&zc(a),O=g||x||T||w,P=O?_c(a.length,cd):[],V=P.length;for(var Q in a)(u||Wt.call(a,Q))&&!(O&&(Q=="length"||T&&(Q=="offset"||Q=="parent")||w&&(Q=="buffer"||Q=="byteLength"||Q=="byteOffset")||Oo(Q,V)))&&P.push(Q);return P}function jS(a){var u=a.length;return u?a[OA(0,u-1)]:e}function knt(a,u){return fg(zn(a),Zl(u,0,a.length))}function Rnt(a){return fg(zn(a))}function kA(a,u,g){(g!==e&&!oi(a[u],g)||g===e&&!(u in a))&&_o(a,u,g)}function gd(a,u,g){var x=a[u];(!(Wt.call(a,u)&&oi(x,g))||g===e&&!(u in a))&&_o(a,u,g)}function Jm(a,u){for(var g=a.length;g--;)if(oi(a[g][0],u))return g;return-1}function wnt(a,u,g,x){return ks(a,function(T,w,O){u(x,T,g(T),O)}),x}function zS(a,u){return a&&Ki(u,nn(u),a)}function Snt(a,u){return a&&Ki(u,Wn(u),a)}function _o(a,u,g){u=="__proto__"&&Lo?Lo(a,u,{configurable:!0,enumerable:!0,value:g,writable:!0}):a[u]=g}function RA(a,u){for(var g=-1,x=u.length,T=j(x),w=a==null;++g<x;)T[g]=w?e:lb(a,u[g]);return T}function Zl(a,u,g){return a===a&&(g!==e&&(a=a<=g?a:g),u!==e&&(a=a>=u?a:u)),a}function yr(a,u,g,x,T,w){var O,P=u&C,V=u&E,Q=u&A;if(g&&(O=T?g(a,x,T,w):g(a)),O!==e)return O;if(!ke(a))return a;var Y=Dt(a);if(Y){if(O=Crt(a),!P)return zn(a,O)}else{var tt=Cn(a),ht=tt==bc||tt==pm;if(Ls(a))return gL(a,P);if(tt==br||tt==ps||ht&&!T){if(O=V||ht?{}:ML(a),!P)return V?srt(a,Snt(O,a)):ort(a,zS(O,a))}else{if(!ae[tt])return T?a:{};O=Ert(a,tt,P)}}w||(w=new ii);var Et=w.get(a);if(Et)return Et;w.set(a,O),c6(a)?a.forEach(function(yt){O.add(yr(yt,u,g,yt,a,w))}):l6(a)&&a.forEach(function(yt,jt){O.set(jt,yr(yt,u,g,jt,a,w))});var Tt=Q?V?WA:GA:V?Wn:nn,Nt=Y?e:Tt(a);return $n(Nt||a,function(yt,jt){Nt&&(jt=yt,yt=a[jt]),gd(O,jt,yr(yt,u,g,jt,a,w))}),O}function Lnt(a){var u=nn(a);return function(g){return GS(g,a,u)}}function GS(a,u,g){var x=g.length;if(a==null)return!x;for(a=Qt(a);x--;){var T=g[x],w=u[T],O=a[T];if(O===e&&!(T in a)||!w(O))return!1}return!0}function WS(a,u,g){if(typeof a!="function")throw new Sn(s);return vd(function(){a.apply(e,g)},u)}function pd(a,u,g,x){var T=-1,w=Sc,O=!0,P=a.length,V=[],Q=u.length;if(!P)return V;g&&(u=Ce(u,pn(g))),x?(w=nd,O=!1):u.length>=i&&(w=ni,O=!1,u=new Jl(u));t:for(;++T<P;){var Y=a[T],tt=g==null?Y:g(Y);if(Y=x||Y!==0?Y:0,O&&tt===tt){for(var ht=Q;ht--;)if(u[ht]===tt)continue t;V.push(Y)}else w(u,tt,x)||V.push(Y)}return V}var ks=AL(Fi),qS=AL(SA,!0);function Int(a,u){var g=!0;return ks(a,function(x,T,w){return g=!!u(x,T,w),g}),g}function Zm(a,u,g){for(var x=-1,T=a.length;++x<T;){var w=a[x],O=u(w);if(O!=null&&(P===e?O===O&&!ar(O):g(O,P)))var P=O,V=w}return V}function Dnt(a,u,g,x){var T=a.length;for(g=Ut(g),g<0&&(g=-g>T?0:T+g),x=x===e||x>T?T:Ut(x),x<0&&(x+=T),x=g>x?0:f6(x);g<x;)a[g++]=u;return a}function XS(a,u){var g=[];return ks(a,function(x,T,w){u(x,T,w)&&g.push(x)}),g}function an(a,u,g,x,T){var w=-1,O=a.length;for(g||(g=Art),T||(T=[]);++w<O;){var P=a[w];u>0&&g(P)?u>1?an(P,u-1,g,x,T):Oi(T,P):x||(T[T.length]=P)}return T}var wA=bL(),QS=bL(!0);function Fi(a,u){return a&&wA(a,u,nn)}function SA(a,u){return a&&QS(a,u,nn)}function tg(a,u){return ti(u,function(g){return No(a[g])})}function ta(a,u){u=ws(u,a);for(var g=0,x=u.length;a!=null&&g<x;)a=a[Vi(u[g++])];return g&&g==x?a:e}function YS(a,u,g){var x=u(a);return Dt(a)?x:Oi(x,g(a))}function Ln(a){return a==null?a===e?xm:Cm:So&&So in Qt(a)?mrt(a):Rrt(a)}function LA(a,u){return a>u}function _nt(a,u){return a!=null&&Wt.call(a,u)}function Mnt(a,u){return a!=null&&u in Qt(a)}function Unt(a,u,g){return a>=_(u,g)&&a<S(u,g)}function IA(a,u,g){for(var x=g?nd:Sc,T=a[0].length,w=a.length,O=w,P=j(w),V=1/0,Q=[];O--;){var Y=a[O];O&&u&&(Y=Ce(Y,pn(u))),V=_(Y.length,V),P[O]=!g&&(u||T>=120&&Y.length>=120)?new Jl(O&&Y):e}Y=a[0];var tt=-1,ht=P[0];t:for(;++tt<T&&Q.length<V;){var Et=Y[tt],Tt=u?u(Et):Et;if(Et=g||Et!==0?Et:0,!(ht?ni(ht,Tt):x(Q,Tt,g))){for(O=w;--O;){var Nt=P[O];if(!(Nt?ni(Nt,Tt):x(a[O],Tt,g)))continue t}ht&&ht.push(Tt),Q.push(Et)}}return Q}function Ont(a,u,g,x){return Fi(a,function(T,w,O){u(x,g(T),w,O)}),x}function Cd(a,u,g){u=ws(u,a),a=PL(a,u);var x=a==null?a:a[Vi(Rr(u))];return x==null?e:wn(x,a,g)}function JS(a){return De(a)&&Ln(a)==ps}function Nnt(a){return De(a)&&Ln(a)==wl}function Pnt(a){return De(a)&&Ln(a)==Ht}function Ed(a,u,g,x,T){return a===u?!0:a==null||u==null||!De(a)&&!De(u)?a!==a&&u!==u:Fnt(a,u,g,x,Ed,T)}function Fnt(a,u,g,x,T,w){var O=Dt(a),P=Dt(u),V=O?bl:Cn(a),Q=P?bl:Cn(u);V=V==ps?br:V,Q=Q==ps?br:Q;var Y=V==br,tt=Q==br,ht=V==Q;if(ht&&Ls(a)){if(!Ls(u))return!1;O=!0,Y=!1}if(ht&&!Y)return w||(w=new ii),O||zc(a)?IL(a,u,g,x,T,w):drt(a,u,V,g,x,T,w);if(!(g&v)){var Et=Y&&Wt.call(a,"__wrapped__"),Tt=tt&&Wt.call(u,"__wrapped__");if(Et||Tt){var Nt=Et?a.value():a,yt=Tt?u.value():u;return w||(w=new ii),T(Nt,yt,g,x,w)}}return ht?(w||(w=new ii),hrt(a,u,g,x,T,w)):!1}function Knt(a){return De(a)&&Cn(a)==gn}function DA(a,u,g,x){var T=g.length,w=T,O=!x;if(a==null)return!w;for(a=Qt(a);T--;){var P=g[T];if(O&&P[2]?P[1]!==a[P[0]]:!(P[0]in a))return!1}for(;++T<w;){P=g[T];var V=P[0],Q=a[V],Y=P[1];if(O&&P[2]){if(Q===e&&!(V in a))return!1}else{var tt=new ii;if(x)var ht=x(Q,Y,V,a,u,tt);if(!(ht===e?Ed(Y,Q,v|R,x,tt):ht))return!1}}return!0}function ZS(a){if(!ke(a)||vrt(a))return!1;var u=No(a)?Gm:jx;return u.test(na(a))}function Vnt(a){return De(a)&&Ln(a)==Tl}function $nt(a){return De(a)&&Cn(a)==ye}function Hnt(a){return De(a)&&Cg(a.length)&&!!he[Ln(a)]}function tL(a){return typeof a=="function"?a:a==null?qn:typeof a=="object"?Dt(a)?rL(a[0],a[1]):nL(a):v6(a)}function _A(a){if(!bd(a))return y(a);var u=[];for(var g in Qt(a))Wt.call(a,g)&&g!="constructor"&&u.push(g);return u}function jnt(a){if(!ke(a))return krt(a);var u=bd(a),g=[];for(var x in a)x=="constructor"&&(u||!Wt.call(a,x))||g.push(x);return g}function MA(a,u){return a<u}function eL(a,u){var g=-1,x=Gn(a)?j(a.length):[];return ks(a,function(T,w,O){x[++g]=u(T,w,O)}),x}function nL(a){var u=XA(a);return u.length==1&&u[0][2]?OL(u[0][0],u[0][1]):function(g){return g===a||DA(g,a,u)}}function rL(a,u){return YA(a)&&UL(u)?OL(Vi(a),u):function(g){var x=lb(g,a);return x===e&&x===u?ab(g,a):Ed(u,x,v|R)}}function eg(a,u,g,x,T){a!==u&&wA(u,function(w,O){if(T||(T=new ii),ke(w))znt(a,u,O,g,eg,x,T);else{var P=x?x(ZA(a,O),w,O+"",a,u,T):e;P===e&&(P=w),kA(a,O,P)}},Wn)}function znt(a,u,g,x,T,w,O){var P=ZA(a,g),V=ZA(u,g),Q=O.get(V);if(Q){kA(a,g,Q);return}var Y=w?w(P,V,g+"",a,u,O):e,tt=Y===e;if(tt){var ht=Dt(V),Et=!ht&&Ls(V),Tt=!ht&&!Et&&zc(V);Y=V,ht||Et||Tt?Dt(P)?Y=P:Ne(P)?Y=zn(P):Et?(tt=!1,Y=gL(V,!0)):Tt?(tt=!1,Y=pL(V,!0)):Y=[]:Bd(V)||ra(V)?(Y=P,ra(P)?Y=d6(P):(!ke(P)||No(P))&&(Y=ML(V))):tt=!1}tt&&(O.set(V,Y),T(Y,V,x,w,O),O.delete(V)),kA(a,g,Y)}function iL(a,u){var g=a.length;if(!!g)return u+=u<0?g:0,Oo(u,g)?a[u]:e}function oL(a,u,g){u.length?u=Ce(u,function(w){return Dt(w)?function(O){return ta(O,w.length===1?w[0]:w)}:w}):u=[qn];var x=-1;u=Ce(u,pn(vt()));var T=eL(a,function(w,O,P){var V=Ce(u,function(Q){return Q(w)});return{criteria:V,index:++x,value:w}});return Nm(T,function(w,O){return irt(w,O,g)})}function Gnt(a,u){return sL(a,u,function(g,x){return ab(a,x)})}function sL(a,u,g){for(var x=-1,T=u.length,w={};++x<T;){var O=u[x],P=ta(a,O);g(P,O)&&xd(w,ws(O,a),P)}return w}function Wnt(a){return function(u){return ta(u,a)}}function UA(a,u,g,x){var T=x?vs:Ao,w=-1,O=u.length,P=a;for(a===u&&(u=zn(u)),g&&(P=Ce(a,pn(g)));++w<O;)for(var V=0,Q=u[w],Y=g?g(Q):Q;(V=T(P,Y,V,x))>-1;)P!==a&&Gl.call(P,V,1),Gl.call(a,V,1);return a}function lL(a,u){for(var g=a?u.length:0,x=g-1;g--;){var T=u[g];if(g==x||T!==w){var w=T;Oo(T)?Gl.call(a,T,1):FA(a,T)}}return a}function OA(a,u){return a+Xl($()*(u-a+1))}function qnt(a,u,g,x){for(var T=-1,w=S(ql((u-a)/(g||1)),0),O=j(w);w--;)O[x?w:++T]=a,a+=g;return O}function NA(a,u){var g="";if(!a||u<1||u>mn)return g;do u%2&&(g+=a),u=Xl(u/2),u&&(a+=a);while(u);return g}function Pt(a,u){return tb(NL(a,u,qn),a+"")}function Xnt(a){return jS(Gc(a))}function Qnt(a,u){var g=Gc(a);return fg(g,Zl(u,0,g.length))}function xd(a,u,g,x){if(!ke(a))return a;u=ws(u,a);for(var T=-1,w=u.length,O=w-1,P=a;P!=null&&++T<w;){var V=Vi(u[T]),Q=g;if(V==="__proto__"||V==="constructor"||V==="prototype")return a;if(T!=O){var Y=P[V];Q=x?x(Y,V,P):e,Q===e&&(Q=ke(Y)?Y:Oo(u[T+1])?[]:{})}gd(P,V,Q),P=P[V]}return a}var aL=Oe?function(a,u){return Oe.set(a,u),a}:qn,Ynt=Lo?function(a,u){return Lo(a,"toString",{configurable:!0,enumerable:!1,value:ub(u),writable:!0})}:qn;function Jnt(a){return fg(Gc(a))}function kr(a,u,g){var x=-1,T=a.length;u<0&&(u=-u>T?0:T+u),g=g>T?T:g,g<0&&(g+=T),T=u>g?0:g-u>>>0,u>>>=0;for(var w=j(T);++x<T;)w[x]=a[x+u];return w}function Znt(a,u){var g;return ks(a,function(x,T,w){return g=u(x,T,w),!g}),!!g}function ng(a,u,g){var x=0,T=a==null?x:a.length;if(typeof u=="number"&&u===u&&T<=yx){for(;x<T;){var w=x+T>>>1,O=a[w];O!==null&&!ar(O)&&(g?O<=u:O<u)?x=w+1:T=w}return T}return PA(a,u,qn,g)}function PA(a,u,g,x){var T=0,w=a==null?0:a.length;if(w===0)return 0;u=g(u);for(var O=u!==u,P=u===null,V=ar(u),Q=u===e;T<w;){var Y=Xl((T+w)/2),tt=g(a[Y]),ht=tt!==e,Et=tt===null,Tt=tt===tt,Nt=ar(tt);if(O)var yt=x||Tt;else Q?yt=Tt&&(x||ht):P?yt=Tt&&ht&&(x||!Et):V?yt=Tt&&ht&&!Et&&(x||!Nt):Et||Nt?yt=!1:yt=x?tt<=u:tt<u;yt?T=Y+1:w=Y}return _(w,Tx)}function cL(a,u){for(var g=-1,x=a.length,T=0,w=[];++g<x;){var O=a[g],P=u?u(O):O;if(!g||!oi(P,V)){var V=P;w[T++]=O===0?0:O}}return w}function uL(a){return typeof a=="number"?a:ar(a)?go:+a}function lr(a){if(typeof a=="string")return a;if(Dt(a))return Ce(a,lr)+"";if(ar(a))return Tr?Tr.call(a):"";var u=a+"";return u=="0"&&1/a==-Rn?"-0":u}function Rs(a,u,g){var x=-1,T=Sc,w=a.length,O=!0,P=[],V=P;if(g)O=!1,T=nd;else if(w>=i){var Q=u?null:urt(a);if(Q)return To(Q);O=!1,T=ni,V=new Jl}else V=u?[]:P;t:for(;++x<w;){var Y=a[x],tt=u?u(Y):Y;if(Y=g||Y!==0?Y:0,O&&tt===tt){for(var ht=V.length;ht--;)if(V[ht]===tt)continue t;u&&V.push(tt),P.push(Y)}else T(V,tt,g)||(V!==P&&V.push(tt),P.push(Y))}return P}function FA(a,u){return u=ws(u,a),a=PL(a,u),a==null||delete a[Vi(Rr(u))]}function fL(a,u,g,x){return xd(a,u,g(ta(a,u)),x)}function rg(a,u,g,x){for(var T=a.length,w=x?T:-1;(x?w--:++w<T)&&u(a[w],w,a););return g?kr(a,x?0:w,x?w+1:T):kr(a,x?w+1:0,x?T:w)}function dL(a,u){var g=a;return g instanceof Vt&&(g=g.value()),rd(u,function(x,T){return T.func.apply(T.thisArg,Oi([x],T.args))},g)}function KA(a,u,g){var x=a.length;if(x<2)return x?Rs(a[0]):[];for(var T=-1,w=j(x);++T<x;)for(var O=a[T],P=-1;++P<x;)P!=T&&(w[T]=pd(w[T]||O,a[P],u,g));return Rs(an(w,1),u,g)}function hL(a,u,g){for(var x=-1,T=a.length,w=u.length,O={};++x<T;){var P=x<w?u[x]:e;g(O,a[x],P)}return O}function VA(a){return Ne(a)?a:[]}function $A(a){return typeof a=="function"?a:qn}function ws(a,u){return Dt(a)?a:YA(a,u)?[a]:$L(ee(a))}var trt=Pt;function Ss(a,u,g){var x=a.length;return g=g===e?x:g,!u&&g>=x?a:kr(a,u,g)}var mL=qm||function(a){return Je.clearTimeout(a)};function gL(a,u){if(u)return a.slice();var g=a.length,x=jl?jl(g):new a.constructor(g);return a.copy(x),x}function HA(a){var u=new a.constructor(a.byteLength);return new Hl(u).set(new Hl(a)),u}function ert(a,u){var g=u?HA(a.buffer):a.buffer;return new a.constructor(g,a.byteOffset,a.byteLength)}function nrt(a){var u=new a.constructor(a.source,vc.exec(a));return u.lastIndex=a.lastIndex,u}function rrt(a){return ve?Qt(ve.call(a)):{}}function pL(a,u){var g=u?HA(a.buffer):a.buffer;return new a.constructor(g,a.byteOffset,a.length)}function CL(a,u){if(a!==u){var g=a!==e,x=a===null,T=a===a,w=ar(a),O=u!==e,P=u===null,V=u===u,Q=ar(u);if(!P&&!Q&&!w&&a>u||w&&O&&V&&!P&&!Q||x&&O&&V||!g&&V||!T)return 1;if(!x&&!w&&!Q&&a<u||Q&&g&&T&&!x&&!w||P&&g&&T||!O&&T||!V)return-1}return 0}function irt(a,u,g){for(var x=-1,T=a.criteria,w=u.criteria,O=T.length,P=g.length;++x<O;){var V=CL(T[x],w[x]);if(V){if(x>=P)return V;var Q=g[x];return V*(Q=="desc"?-1:1)}}return a.index-u.index}function EL(a,u,g,x){for(var T=-1,w=a.length,O=g.length,P=-1,V=u.length,Q=S(w-O,0),Y=j(V+Q),tt=!x;++P<V;)Y[P]=u[P];for(;++T<O;)(tt||T<w)&&(Y[g[T]]=a[T]);for(;Q--;)Y[P++]=a[T++];return Y}function xL(a,u,g,x){for(var T=-1,w=a.length,O=-1,P=g.length,V=-1,Q=u.length,Y=S(w-P,0),tt=j(Y+Q),ht=!x;++T<Y;)tt[T]=a[T];for(var Et=T;++V<Q;)tt[Et+V]=u[V];for(;++O<P;)(ht||T<w)&&(tt[Et+g[O]]=a[T++]);return tt}function zn(a,u){var g=-1,x=a.length;for(u||(u=j(x));++g<x;)u[g]=a[g];return u}function Ki(a,u,g,x){var T=!g;g||(g={});for(var w=-1,O=u.length;++w<O;){var P=u[w],V=x?x(g[P],a[P],P,g,a):e;V===e&&(V=a[P]),T?_o(g,P,V):gd(g,P,V)}return g}function ort(a,u){return Ki(a,QA(a),u)}function srt(a,u){return Ki(a,DL(a),u)}function ig(a,u){return function(g,x){var T=Dt(g)?xA:wnt,w=u?u():{};return T(g,a,vt(x,2),w)}}function $c(a){return Pt(function(u,g){var x=-1,T=g.length,w=T>1?g[T-1]:e,O=T>2?g[2]:e;for(w=a.length>3&&typeof w=="function"?(T--,w):e,O&&In(g[0],g[1],O)&&(w=T<3?e:w,T=1),u=Qt(u);++x<T;){var P=g[x];P&&a(u,P,x,w)}return u})}function AL(a,u){return function(g,x){if(g==null)return g;if(!Gn(g))return a(g,x);for(var T=g.length,w=u?T:-1,O=Qt(g);(u?w--:++w<T)&&x(O[w],w,O)!==!1;);return g}}function bL(a){return function(u,g,x){for(var T=-1,w=Qt(u),O=x(u),P=O.length;P--;){var V=O[a?P:++T];if(g(w[V],V,w)===!1)break}return u}}function lrt(a,u,g){var x=u&L,T=Ad(a);function w(){var O=this&&this!==Je&&this instanceof w?T:a;return O.apply(x?g:this,arguments)}return w}function vL(a){return function(u){u=ee(u);var g=vo(u)?sr(u):e,x=g?g[0]:u.charAt(0),T=g?Ss(g,1).join(""):u.slice(1);return x[a]()+T}}function Hc(a){return function(u){return rd(A6(x6(u).replace(sA,"")),a,"")}}function Ad(a){return function(){var u=arguments;switch(u.length){case 0:return new a;case 1:return new a(u[0]);case 2:return new a(u[0],u[1]);case 3:return new a(u[0],u[1],u[2]);case 4:return new a(u[0],u[1],u[2],u[3]);case 5:return new a(u[0],u[1],u[2],u[3],u[4]);case 6:return new a(u[0],u[1],u[2],u[3],u[4],u[5]);case 7:return new a(u[0],u[1],u[2],u[3],u[4],u[5],u[6])}var g=Pi(a.prototype),x=a.apply(g,u);return ke(x)?x:g}}function art(a,u,g){var x=Ad(a);function T(){for(var w=arguments.length,O=j(w),P=w,V=jc(T);P--;)O[P]=arguments[P];var Q=w<3&&O[0]!==V&&O[w-1]!==V?[]:or(O,V);if(w-=Q.length,w<g)return RL(a,u,og,T.placeholder,e,O,Q,e,e,g-w);var Y=this&&this!==Je&&this instanceof T?x:a;return wn(Y,this,O)}return T}function BL(a){return function(u,g,x){var T=Qt(u);if(!Gn(u)){var w=vt(g,3);u=nn(u),g=function(P){return w(T[P],P,T)}}var O=a(u,g,x);return O>-1?T[w?u[O]:O]:e}}function TL(a){return Uo(function(u){var g=u.length,x=g,T=jn.prototype.thru;for(a&&u.reverse();x--;){var w=u[x];if(typeof w!="function")throw new Sn(s);if(T&&!O&&cg(w)=="wrapper")var O=new jn([],!0)}for(x=O?x:g;++x<g;){w=u[x];var P=cg(w),V=P=="wrapper"?qA(w):e;V&&JA(V[0])&&V[1]==(at|F|W|xt)&&!V[4].length&&V[9]==1?O=O[cg(V[0])].apply(O,V[3]):O=w.length==1&&JA(w)?O[P]():O.thru(w)}return function(){var Q=arguments,Y=Q[0];if(O&&Q.length==1&&Dt(Y))return O.plant(Y).value();for(var tt=0,ht=g?u[tt].apply(this,Q):Y;++tt<g;)ht=u[tt].call(this,ht);return ht}})}function og(a,u,g,x,T,w,O,P,V,Q){var Y=u&at,tt=u&L,ht=u&M,Et=u&(F|G),Tt=u&Mt,Nt=ht?e:Ad(a);function yt(){for(var jt=arguments.length,zt=j(jt),cr=jt;cr--;)zt[cr]=arguments[cr];if(Et)var Dn=jc(yt),ur=Pm(zt,Dn);if(x&&(zt=EL(zt,x,T,Et)),w&&(zt=xL(zt,w,O,Et)),jt-=ur,Et&&jt<Q){var Pe=or(zt,Dn);return RL(a,u,og,yt.placeholder,g,zt,Pe,P,V,Q-jt)}var si=tt?g:this,Fo=ht?si[a]:a;return jt=zt.length,P?zt=wrt(zt,P):Tt&&jt>1&&zt.reverse(),Y&&V<jt&&(zt.length=V),this&&this!==Je&&this instanceof yt&&(Fo=Nt||Ad(Fo)),Fo.apply(si,zt)}return yt}function yL(a,u){return function(g,x){return Ont(g,a,u(x),{})}}function sg(a,u){return function(g,x){var T;if(g===e&&x===e)return u;if(g!==e&&(T=g),x!==e){if(T===e)return x;typeof g=="string"||typeof x=="string"?(g=lr(g),x=lr(x)):(g=uL(g),x=uL(x)),T=a(g,x)}return T}}function jA(a){return Uo(function(u){return u=Ce(u,pn(vt())),Pt(function(g){var x=this;return a(u,function(T){return wn(T,x,g)})})})}function lg(a,u){u=u===e?" ":lr(u);var g=u.length;if(g<2)return g?NA(u,a):u;var x=NA(u,ql(a/Ts(u)));return vo(u)?Ss(sr(x),0,a).join(""):x.slice(0,a)}function crt(a,u,g,x){var T=u&L,w=Ad(a);function O(){for(var P=-1,V=arguments.length,Q=-1,Y=x.length,tt=j(Y+V),ht=this&&this!==Je&&this instanceof O?w:a;++Q<Y;)tt[Q]=x[Q];for(;V--;)tt[Q++]=arguments[++P];return wn(ht,T?g:this,tt)}return O}function kL(a){return function(u,g,x){return x&&typeof x!="number"&&In(u,g,x)&&(g=x=e),u=Po(u),g===e?(g=u,u=0):g=Po(g),x=x===e?u<g?1:-1:Po(x),qnt(u,g,x,a)}}function ag(a){return function(u,g){return typeof u=="string"&&typeof g=="string"||(u=wr(u),g=wr(g)),a(u,g)}}function RL(a,u,g,x,T,w,O,P,V,Q){var Y=u&F,tt=Y?O:e,ht=Y?e:O,Et=Y?w:e,Tt=Y?e:w;u|=Y?W:it,u&=~(Y?it:W),u&U||(u&=~(L|M));var Nt=[a,u,T,Et,tt,Tt,ht,P,V,Q],yt=g.apply(e,Nt);return JA(a)&&FL(yt,Nt),yt.placeholder=x,KL(yt,a,u)}function zA(a){var u=Ie[a];return function(g,x){if(g=wr(g),x=x==null?0:_(Ut(x),292),x&&md(g)){var T=(ee(g)+"e").split("e"),w=u(T[0]+"e"+(+T[1]+x));return T=(ee(w)+"e").split("e"),+(T[0]+"e"+(+T[1]-x))}return u(g)}}var urt=ut&&1/To(new ut([,-0]))[1]==Rn?function(a){return new ut(a)}:hb;function wL(a){return function(u){var g=Cn(u);return g==gn?Bo(u):g==ye?Pl(u):Ul(u,a(u))}}function Mo(a,u,g,x,T,w,O,P){var V=u&M;if(!V&&typeof a!="function")throw new Sn(s);var Q=x?x.length:0;if(Q||(u&=~(W|it),x=T=e),O=O===e?O:S(Ut(O),0),P=P===e?P:Ut(P),Q-=T?T.length:0,u&it){var Y=x,tt=T;x=T=e}var ht=V?e:qA(a),Et=[a,u,g,x,T,Y,tt,w,O,P];if(ht&&yrt(Et,ht),a=Et[0],u=Et[1],g=Et[2],x=Et[3],T=Et[4],P=Et[9]=Et[9]===e?V?0:a.length:S(Et[9]-Q,0),!P&&u&(F|G)&&(u&=~(F|G)),!u||u==L)var Tt=lrt(a,u,g);else u==F||u==G?Tt=art(a,u,P):(u==W||u==(L|W))&&!T.length?Tt=crt(a,u,g,x):Tt=og.apply(e,Et);var Nt=ht?aL:FL;return KL(Nt(Tt,Et),a,u)}function SL(a,u,g,x){return a===e||oi(a,ko[g])&&!Wt.call(x,g)?u:a}function LL(a,u,g,x,T,w){return ke(a)&&ke(u)&&(w.set(u,a),eg(a,u,e,LL,w),w.delete(u)),a}function frt(a){return Bd(a)?e:a}function IL(a,u,g,x,T,w){var O=g&v,P=a.length,V=u.length;if(P!=V&&!(O&&V>P))return!1;var Q=w.get(a),Y=w.get(u);if(Q&&Y)return Q==u&&Y==a;var tt=-1,ht=!0,Et=g&R?new Jl:e;for(w.set(a,u),w.set(u,a);++tt<P;){var Tt=a[tt],Nt=u[tt];if(x)var yt=O?x(Nt,Tt,tt,u,a,w):x(Tt,Nt,tt,a,u,w);if(yt!==e){if(yt)continue;ht=!1;break}if(Et){if(!id(u,function(jt,zt){if(!ni(Et,zt)&&(Tt===jt||T(Tt,jt,g,x,w)))return Et.push(zt)})){ht=!1;break}}else if(!(Tt===Nt||T(Tt,Nt,g,x,w))){ht=!1;break}}return w.delete(a),w.delete(u),ht}function drt(a,u,g,x,T,w,O){switch(g){case Es:if(a.byteLength!=u.byteLength||a.byteOffset!=u.byteOffset)return!1;a=a.buffer,u=u.buffer;case wl:return!(a.byteLength!=u.byteLength||!w(new Hl(a),new Hl(u)));case po:case Ht:case Bl:return oi(+a,+u);case Cs:return a.name==u.name&&a.message==u.message;case Tl:case yl:return a==u+"";case gn:var P=Bo;case ye:var V=x&v;if(P||(P=To),a.size!=u.size&&!V)return!1;var Q=O.get(a);if(Q)return Q==u;x|=R,O.set(a,u);var Y=IL(P(a),P(u),x,T,w,O);return O.delete(a),Y;case kl:if(ve)return ve.call(a)==ve.call(u)}return!1}function hrt(a,u,g,x,T,w){var O=g&v,P=GA(a),V=P.length,Q=GA(u),Y=Q.length;if(V!=Y&&!O)return!1;for(var tt=V;tt--;){var ht=P[tt];if(!(O?ht in u:Wt.call(u,ht)))return!1}var Et=w.get(a),Tt=w.get(u);if(Et&&Tt)return Et==u&&Tt==a;var Nt=!0;w.set(a,u),w.set(u,a);for(var yt=O;++tt<V;){ht=P[tt];var jt=a[ht],zt=u[ht];if(x)var cr=O?x(zt,jt,ht,u,a,w):x(jt,zt,ht,a,u,w);if(!(cr===e?jt===zt||T(jt,zt,g,x,w):cr)){Nt=!1;break}yt||(yt=ht=="constructor")}if(Nt&&!yt){var Dn=a.constructor,ur=u.constructor;Dn!=ur&&"constructor"in a&&"constructor"in u&&!(typeof Dn=="function"&&Dn instanceof Dn&&typeof ur=="function"&&ur instanceof ur)&&(Nt=!1)}return w.delete(a),w.delete(u),Nt}function Uo(a){return tb(NL(a,e,GL),a+"")}function GA(a){return YS(a,nn,QA)}function WA(a){return YS(a,Wn,DL)}var qA=Oe?function(a){return Oe.get(a)}:hb;function cg(a){for(var u=a.name+"",g=ln[u],x=Wt.call(ln,u)?g.length:0;x--;){var T=g[x],w=T.func;if(w==null||w==a)return T.name}return u}function jc(a){var u=Wt.call(k,"placeholder")?k:a;return u.placeholder}function vt(){var a=k.iteratee||fb;return a=a===fb?tL:a,arguments.length?a(arguments[0],arguments[1]):a}function ug(a,u){var g=a.__data__;return brt(u)?g[typeof u=="string"?"string":"hash"]:g.map}function XA(a){for(var u=nn(a),g=u.length;g--;){var x=u[g],T=a[x];u[g]=[x,T,UL(T)]}return u}function ea(a,u){var g=Vm(a,u);return ZS(g)?g:e}function mrt(a){var u=Wt.call(a,So),g=a[So];try{a[So]=e;var x=!0}catch{}var T=$l.call(a);return x&&(u?a[So]=g:delete a[So]),T}var QA=Ql?function(a){return a==null?[]:(a=Qt(a),ti(Ql(a),function(u){return hd.call(a,u)}))}:mb,DL=Ql?function(a){for(var u=[];a;)Oi(u,QA(a)),a=Ni(a);return u}:mb,Cn=Ln;(J&&Cn(new J(new ArrayBuffer(1)))!=Es||ct&&Cn(new ct)!=gn||Ct&&Cn(Ct.resolve())!=Em||ut&&Cn(new ut)!=ye||At&&Cn(new At)!=Rl)&&(Cn=function(a){var u=Ln(a),g=u==br?a.constructor:e,x=g?na(g):"";if(x)switch(x){case Hn:return Es;case Br:return gn;case TA:return Em;case yA:return ye;case Ee:return Rl}return u});function grt(a,u,g){for(var x=-1,T=g.length;++x<T;){var w=g[x],O=w.size;switch(w.type){case"drop":a+=O;break;case"dropRight":u-=O;break;case"take":u=_(u,a+O);break;case"takeRight":a=S(a,u-O);break}}return{start:a,end:u}}function prt(a){var u=a.match(de);return u?u[1].split(Vx):[]}function _L(a,u,g){u=ws(u,a);for(var x=-1,T=u.length,w=!1;++x<T;){var O=Vi(u[x]);if(!(w=a!=null&&g(a,O)))break;a=a[O]}return w||++x!=T?w:(T=a==null?0:a.length,!!T&&Cg(T)&&Oo(O,T)&&(Dt(a)||ra(a)))}function Crt(a){var u=a.length,g=new a.constructor(u);return u&&typeof a[0]=="string"&&Wt.call(a,"index")&&(g.index=a.index,g.input=a.input),g}function ML(a){return typeof a.constructor=="function"&&!bd(a)?Pi(Ni(a)):{}}function Ert(a,u,g){var x=a.constructor;switch(u){case wl:return HA(a);case po:case Ht:return new x(+a);case Es:return ert(a,g);case Lf:case If:case Df:case _f:case Mf:case Uf:case Of:case Nf:case Pf:return pL(a,g);case gn:return new x;case Bl:case yl:return new x(a);case Tl:return nrt(a);case ye:return new x;case kl:return rrt(a)}}function xrt(a,u){var g=u.length;if(!g)return a;var x=g-1;return u[x]=(g>1?"& ":"")+u[x],u=u.join(g>2?", ":" "),a.replace(Kx,`{
|
|
623
|
+
*/(function(n,t){(function(){var e,r="4.17.21",i=200,o="Unsupported core-js use. Try https://npms.io/search?q=ponyfill.",s="Expected a function",l="Invalid `variable` option passed into `_.template`",c="__lodash_hash_undefined__",d=500,h="__lodash_placeholder__",C=1,E=2,A=4,v=1,R=2,L=1,M=2,U=4,F=8,G=16,W=32,it=64,at=128,xt=256,Mt=512,Bt=30,le="...",te=800,kn=16,be=1,Kn=2,Ii=3,Rn=1/0,mn=9007199254740991,Di=17976931348623157e292,go=0/0,Ar=4294967295,Tx=Ar-1,yx=Ar>>>1,kx=[["ary",at],["bind",L],["bindKey",M],["curry",F],["curryRight",G],["flip",Mt],["partial",W],["partialRight",it],["rearg",xt]],ps="[object Arguments]",bl="[object Array]",vl="[object AsyncFunction]",po="[object Boolean]",Ht="[object Date]",_i="[object DOMException]",Cs="[object Error]",bc="[object Function]",pm="[object GeneratorFunction]",gn="[object Map]",Bl="[object Number]",Cm="[object Null]",br="[object Object]",Em="[object Promise]",Rx="[object Proxy]",Tl="[object RegExp]",ye="[object Set]",yl="[object String]",kl="[object Symbol]",xm="[object Undefined]",Rl="[object WeakMap]",Am="[object WeakSet]",wl="[object ArrayBuffer]",Es="[object DataView]",Lf="[object Float32Array]",If="[object Float64Array]",Df="[object Int8Array]",_f="[object Int16Array]",Mf="[object Int32Array]",Uf="[object Uint8Array]",Of="[object Uint8ClampedArray]",Nf="[object Uint16Array]",Pf="[object Uint32Array]",wx=/\b__p \+= '';/g,Sx=/\b(__p \+=) '' \+/g,Lx=/(__e\(.*?\)|\b__t\)) \+\n'';/g,bm=/&(?:amp|lt|gt|quot|#39);/g,vm=/[&<>"']/g,Ix=RegExp(bm.source),Dx=RegExp(vm.source),_x=/<%-([\s\S]+?)%>/g,Mx=/<%([\s\S]+?)%>/g,Bm=/<%=([\s\S]+?)%>/g,Ux=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Ox=/^\w*$/,Nx=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,Ff=/[\\^$.*+?()[\]{}|]/g,Px=RegExp(Ff.source),Kf=/^\s+/,Fx=/\s/,Kx=/\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,de=/\{\n\/\* \[wrapped with (.+)\] \*/,Vx=/,? & /,$x=/[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g,Tm=/[()=,{}\[\]\/\s]/,Sl=/\\(\\)?/g,Hx=/\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g,vc=/\w*$/,ym=/^[-+]0x[0-9a-f]+$/i,km=/^0b[01]+$/i,jx=/^\[object .+?Constructor\]$/,zx=/^0o[0-7]+$/i,Gx=/^(?:0|[1-9]\d*)$/,Wx=/[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g,Bc=/($^)/,qx=/['\n\r\u2028\u2029\\]/g,Tc="\\ud800-\\udfff",Xx="\\u0300-\\u036f",Qx="\\ufe20-\\ufe2f",Yx="\\u20d0-\\u20ff",Rm=Xx+Qx+Yx,yc="\\u2700-\\u27bf",wm="a-z\\xdf-\\xf6\\xf8-\\xff",Jx="\\xac\\xb1\\xd7\\xf7",Zx="\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf",tA="\\u2000-\\u206f",vr=" \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000",Ll="A-Z\\xc0-\\xd6\\xd8-\\xde",Mi="\\ufe0e\\ufe0f",je=Jx+Zx+tA+vr,Vf="['\u2019]",eA="["+Tc+"]",Jr="["+je+"]",Zr="["+Rm+"]",$f="\\d+",kc="["+yc+"]",Hf="["+wm+"]",Co="[^"+Tc+je+$f+yc+wm+Ll+"]",Ui="\\ud83c[\\udffb-\\udfff]",jf="(?:"+Zr+"|"+Ui+")",zf="[^"+Tc+"]",xs="(?:\\ud83c[\\udde6-\\uddff]){2}",Gf="[\\ud800-\\udbff][\\udc00-\\udfff]",As="["+Ll+"]",bs="\\u200d",Sm="(?:"+Hf+"|"+Co+")",nA="(?:"+As+"|"+Co+")",Lm="(?:"+Vf+"(?:d|ll|m|re|s|t|ve))?",Il="(?:"+Vf+"(?:D|LL|M|RE|S|T|VE))?",Rc=jf+"?",Eo="["+Mi+"]?",rA="(?:"+bs+"(?:"+[zf,xs,Gf].join("|")+")"+Eo+Rc+")*",iA="\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[A-Z_])",oA="\\d*(?:1ST|2ND|3RD|(?![123])\\dTH)(?=\\b|[a-z_])",Wf=Eo+Rc+rA,Im="(?:"+[kc,xs,Gf].join("|")+")"+Wf,qf="(?:"+[zf+Zr+"?",Zr,xs,Gf,eA].join("|")+")",sA=RegExp(Vf,"g"),lA=RegExp(Zr,"g"),Xf=RegExp(Ui+"(?="+Ui+")|"+qf+Wf,"g"),aA=RegExp([As+"?"+Hf+"+"+Lm+"(?="+[Jr,As,"$"].join("|")+")",nA+"+"+Il+"(?="+[Jr,As+Sm,"$"].join("|")+")",As+"?"+Sm+"+"+Lm,As+"+"+Il,oA,iA,$f,Im].join("|"),"g"),cA=RegExp("["+bs+Tc+Rm+Mi+"]"),uA=/[a-z][A-Z]|[A-Z]{2}[a-z]|[0-9][a-zA-Z]|[a-zA-Z][0-9]|[^a-zA-Z0-9 ]/,fA=["Array","Buffer","DataView","Date","Error","Float32Array","Float64Array","Function","Int8Array","Int16Array","Int32Array","Map","Math","Object","Promise","RegExp","Set","String","Symbol","TypeError","Uint8Array","Uint8ClampedArray","Uint16Array","Uint32Array","WeakMap","_","clearTimeout","isFinite","parseInt","setTimeout"],dA=-1,he={};he[Lf]=he[If]=he[Df]=he[_f]=he[Mf]=he[Uf]=he[Of]=he[Nf]=he[Pf]=!0,he[ps]=he[bl]=he[wl]=he[po]=he[Es]=he[Ht]=he[Cs]=he[bc]=he[gn]=he[Bl]=he[br]=he[Tl]=he[ye]=he[yl]=he[Rl]=!1;var ae={};ae[ps]=ae[bl]=ae[wl]=ae[Es]=ae[po]=ae[Ht]=ae[Lf]=ae[If]=ae[Df]=ae[_f]=ae[Mf]=ae[gn]=ae[Bl]=ae[br]=ae[Tl]=ae[ye]=ae[yl]=ae[kl]=ae[Uf]=ae[Of]=ae[Nf]=ae[Pf]=!0,ae[Cs]=ae[bc]=ae[Rl]=!1;var hA={\u00C0:"A",\u00C1:"A",\u00C2:"A",\u00C3:"A",\u00C4:"A",\u00C5:"A",\u00E0:"a",\u00E1:"a",\u00E2:"a",\u00E3:"a",\u00E4:"a",\u00E5:"a",\u00C7:"C",\u00E7:"c",\u00D0:"D",\u00F0:"d",\u00C8:"E",\u00C9:"E",\u00CA:"E",\u00CB:"E",\u00E8:"e",\u00E9:"e",\u00EA:"e",\u00EB:"e",\u00CC:"I",\u00CD:"I",\u00CE:"I",\u00CF:"I",\u00EC:"i",\u00ED:"i",\u00EE:"i",\u00EF:"i",\u00D1:"N",\u00F1:"n",\u00D2:"O",\u00D3:"O",\u00D4:"O",\u00D5:"O",\u00D6:"O",\u00D8:"O",\u00F2:"o",\u00F3:"o",\u00F4:"o",\u00F5:"o",\u00F6:"o",\u00F8:"o",\u00D9:"U",\u00DA:"U",\u00DB:"U",\u00DC:"U",\u00F9:"u",\u00FA:"u",\u00FB:"u",\u00FC:"u",\u00DD:"Y",\u00FD:"y",\u00FF:"y",\u00C6:"Ae",\u00E6:"ae",\u00DE:"Th",\u00FE:"th",\u00DF:"ss",\u0100:"A",\u0102:"A",\u0104:"A",\u0101:"a",\u0103:"a",\u0105:"a",\u0106:"C",\u0108:"C",\u010A:"C",\u010C:"C",\u0107:"c",\u0109:"c",\u010B:"c",\u010D:"c",\u010E:"D",\u0110:"D",\u010F:"d",\u0111:"d",\u0112:"E",\u0114:"E",\u0116:"E",\u0118:"E",\u011A:"E",\u0113:"e",\u0115:"e",\u0117:"e",\u0119:"e",\u011B:"e",\u011C:"G",\u011E:"G",\u0120:"G",\u0122:"G",\u011D:"g",\u011F:"g",\u0121:"g",\u0123:"g",\u0124:"H",\u0126:"H",\u0125:"h",\u0127:"h",\u0128:"I",\u012A:"I",\u012C:"I",\u012E:"I",\u0130:"I",\u0129:"i",\u012B:"i",\u012D:"i",\u012F:"i",\u0131:"i",\u0134:"J",\u0135:"j",\u0136:"K",\u0137:"k",\u0138:"k",\u0139:"L",\u013B:"L",\u013D:"L",\u013F:"L",\u0141:"L",\u013A:"l",\u013C:"l",\u013E:"l",\u0140:"l",\u0142:"l",\u0143:"N",\u0145:"N",\u0147:"N",\u014A:"N",\u0144:"n",\u0146:"n",\u0148:"n",\u014B:"n",\u014C:"O",\u014E:"O",\u0150:"O",\u014D:"o",\u014F:"o",\u0151:"o",\u0154:"R",\u0156:"R",\u0158:"R",\u0155:"r",\u0157:"r",\u0159:"r",\u015A:"S",\u015C:"S",\u015E:"S",\u0160:"S",\u015B:"s",\u015D:"s",\u015F:"s",\u0161:"s",\u0162:"T",\u0164:"T",\u0166:"T",\u0163:"t",\u0165:"t",\u0167:"t",\u0168:"U",\u016A:"U",\u016C:"U",\u016E:"U",\u0170:"U",\u0172:"U",\u0169:"u",\u016B:"u",\u016D:"u",\u016F:"u",\u0171:"u",\u0173:"u",\u0174:"W",\u0175:"w",\u0176:"Y",\u0177:"y",\u0178:"Y",\u0179:"Z",\u017B:"Z",\u017D:"Z",\u017A:"z",\u017C:"z",\u017E:"z",\u0132:"IJ",\u0133:"ij",\u0152:"Oe",\u0153:"oe",\u0149:"'n",\u017F:"s"},mA={"&":"&","<":"<",">":">",'"':""","'":"'"},gA={"&":"&","<":"<",">":">",""":'"',"'":"'"},pA={"\\":"\\","'":"'","\n":"n","\r":"r","\u2028":"u2028","\u2029":"u2029"},Dm=parseFloat,CA=parseInt,_m=typeof Mn=="object"&&Mn&&Mn.Object===Object&&Mn,EA=typeof self=="object"&&self&&self.Object===Object&&self,Je=_m||EA||Function("return this")(),Qf=t&&!t.nodeType&&t,xo=Qf&&!0&&n&&!n.nodeType&&n,wc=xo&&xo.exports===Qf,Dl=wc&&_m.process,Vn=function(){try{var K=xo&&xo.require&&xo.require("util").types;return K||Dl&&Dl.binding&&Dl.binding("util")}catch{}}(),Yf=Vn&&Vn.isArrayBuffer,Jf=Vn&&Vn.isDate,Zf=Vn&&Vn.isMap,Mm=Vn&&Vn.isRegExp,td=Vn&&Vn.isSet,ed=Vn&&Vn.isTypedArray;function wn(K,q,j){switch(j.length){case 0:return K.call(q);case 1:return K.call(q,j[0]);case 2:return K.call(q,j[0],j[1]);case 3:return K.call(q,j[0],j[1],j[2])}return K.apply(q,j)}function xA(K,q,j,mt){for(var wt=-1,Gt=K==null?0:K.length;++wt<Gt;){var Ie=K[wt];q(mt,Ie,j(Ie),K)}return mt}function $n(K,q){for(var j=-1,mt=K==null?0:K.length;++j<mt&&q(K[j],j,K)!==!1;);return K}function AA(K,q){for(var j=K==null?0:K.length;j--&&q(K[j],j,K)!==!1;);return K}function Um(K,q){for(var j=-1,mt=K==null?0:K.length;++j<mt;)if(!q(K[j],j,K))return!1;return!0}function ti(K,q){for(var j=-1,mt=K==null?0:K.length,wt=0,Gt=[];++j<mt;){var Ie=K[j];q(Ie,j,K)&&(Gt[wt++]=Ie)}return Gt}function Sc(K,q){var j=K==null?0:K.length;return!!j&&Ao(K,q,0)>-1}function nd(K,q,j){for(var mt=-1,wt=K==null?0:K.length;++mt<wt;)if(j(q,K[mt]))return!0;return!1}function Ce(K,q){for(var j=-1,mt=K==null?0:K.length,wt=Array(mt);++j<mt;)wt[j]=q(K[j],j,K);return wt}function Oi(K,q){for(var j=-1,mt=q.length,wt=K.length;++j<mt;)K[wt+j]=q[j];return K}function rd(K,q,j,mt){var wt=-1,Gt=K==null?0:K.length;for(mt&&Gt&&(j=K[++wt]);++wt<Gt;)j=q(j,K[wt],wt,K);return j}function bA(K,q,j,mt){var wt=K==null?0:K.length;for(mt&&wt&&(j=K[--wt]);wt--;)j=q(j,K[wt],wt,K);return j}function id(K,q){for(var j=-1,mt=K==null?0:K.length;++j<mt;)if(q(K[j],j,K))return!0;return!1}var vA=Ic("length");function Om(K){return K.split("")}function ir(K){return K.match($x)||[]}function od(K,q,j){var mt;return j(K,function(wt,Gt,Ie){if(q(wt,Gt,Ie))return mt=Gt,!1}),mt}function _l(K,q,j,mt){for(var wt=K.length,Gt=j+(mt?1:-1);mt?Gt--:++Gt<wt;)if(q(K[Gt],Gt,K))return Gt;return-1}function Ao(K,q,j){return q===q?Oc(K,q,j):_l(K,ei,j)}function vs(K,q,j,mt){for(var wt=j-1,Gt=K.length;++wt<Gt;)if(mt(K[wt],q))return wt;return-1}function ei(K){return K!==K}function Lc(K,q){var j=K==null?0:K.length;return j?Dc(K,q)/j:go}function Ic(K){return function(q){return q==null?e:q[K]}}function sd(K){return function(q){return K==null?e:K[q]}}function Ml(K,q,j,mt,wt){return wt(K,function(Gt,Ie,Qt){j=mt?(mt=!1,Gt):q(j,Gt,Ie,Qt)}),j}function Nm(K,q){var j=K.length;for(K.sort(q);j--;)K[j]=K[j].value;return K}function Dc(K,q){for(var j,mt=-1,wt=K.length;++mt<wt;){var Gt=q(K[mt]);Gt!==e&&(j=j===e?Gt:j+Gt)}return j}function _c(K,q){for(var j=-1,mt=Array(K);++j<K;)mt[j]=q(j);return mt}function Ul(K,q){return Ce(q,function(j){return[j,K[j]]})}function bo(K){return K&&K.slice(0,Nc(K)+1).replace(Kf,"")}function pn(K){return function(q){return K(q)}}function Bs(K,q){return Ce(q,function(j){return K[j]})}function ni(K,q){return K.has(q)}function Ol(K,q){for(var j=-1,mt=K.length;++j<mt&&Ao(q,K[j],0)>-1;);return j}function ld(K,q){for(var j=K.length;j--&&Ao(q,K[j],0)>-1;);return j}function Pm(K,q){for(var j=K.length,mt=0;j--;)K[j]===q&&++mt;return mt}var Fm=sd(hA),ad=sd(mA);function Km(K){return"\\"+pA[K]}function Vm(K,q){return K==null?e:K[q]}function vo(K){return cA.test(K)}function Mc(K){return uA.test(K)}function Nl(K){for(var q,j=[];!(q=K.next()).done;)j.push(q.value);return j}function Bo(K){var q=-1,j=Array(K.size);return K.forEach(function(mt,wt){j[++q]=[wt,mt]}),j}function Uc(K,q){return function(j){return K(q(j))}}function or(K,q){for(var j=-1,mt=K.length,wt=0,Gt=[];++j<mt;){var Ie=K[j];(Ie===q||Ie===h)&&(K[j]=h,Gt[wt++]=j)}return Gt}function To(K){var q=-1,j=Array(K.size);return K.forEach(function(mt){j[++q]=mt}),j}function Pl(K){var q=-1,j=Array(K.size);return K.forEach(function(mt){j[++q]=[mt,mt]}),j}function Oc(K,q,j){for(var mt=j-1,wt=K.length;++mt<wt;)if(K[mt]===q)return mt;return-1}function $m(K,q,j){for(var mt=j+1;mt--;)if(K[mt]===q)return mt;return mt}function Ts(K){return vo(K)?Fl(K):vA(K)}function sr(K){return vo(K)?Fc(K):Om(K)}function Nc(K){for(var q=K.length;q--&&Fx.test(K.charAt(q)););return q}var Pc=sd(gA);function Fl(K){for(var q=Xf.lastIndex=0;Xf.test(K);)++q;return q}function Fc(K){return K.match(Xf)||[]}function Hm(K){return K.match(aA)||[]}var Kc=function K(q){q=q==null?Je:yo.defaults(Je.Object(),q,yo.pick(Je,fA));var j=q.Array,mt=q.Date,wt=q.Error,Gt=q.Function,Ie=q.Math,Qt=q.Object,Vc=q.RegExp,cd=q.String,Sn=q.TypeError,Kl=j.prototype,ud=Gt.prototype,ko=Qt.prototype,Vl=q["__core-js_shared__"],Ro=ud.toString,Wt=ko.hasOwnProperty,jm=0,fd=function(){var a=/[^.]+$/.exec(Vl&&Vl.keys&&Vl.keys.IE_PROTO||"");return a?"Symbol(src)_1."+a:""}(),$l=ko.toString,dd=Ro.call(Qt),zm=Je._,Gm=Vc("^"+Ro.call(Wt).replace(Ff,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),wo=wc?q.Buffer:e,ri=q.Symbol,Hl=q.Uint8Array,jl=wo?wo.allocUnsafe:e,Ni=Uc(Qt.getPrototypeOf,Qt),zl=Qt.create,hd=ko.propertyIsEnumerable,Gl=Kl.splice,Wm=ri?ri.isConcatSpreadable:e,Wl=ri?ri.iterator:e,So=ri?ri.toStringTag:e,Lo=function(){try{var a=ea(Qt,"defineProperty");return a({},"",{}),a}catch{}}(),qm=q.clearTimeout!==Je.clearTimeout&&q.clearTimeout,Xm=mt&&mt.now!==Je.Date.now&&mt.now,Qm=q.setTimeout!==Je.setTimeout&&q.setTimeout,ql=Ie.ceil,Xl=Ie.floor,Ql=Qt.getOwnPropertySymbols,Ym=wo?wo.isBuffer:e,md=q.isFinite,BA=Kl.join,y=Uc(Qt.keys,Qt),S=Ie.max,_=Ie.min,N=mt.now,H=q.parseInt,$=Ie.random,X=Kl.reverse,J=ea(q,"DataView"),ct=ea(q,"Map"),Ct=ea(q,"Promise"),ut=ea(q,"Set"),At=ea(q,"WeakMap"),Jt=ea(Qt,"create"),Oe=At&&new At,ln={},Hn=na(J),Br=na(ct),TA=na(Ct),yA=na(ut),Ee=na(At),ce=ri?ri.prototype:e,ve=ce?ce.valueOf:e,Tr=ce?ce.toString:e;function k(a){if(De(a)&&!_t(a)&&!(a instanceof Vt)){if(a instanceof jn)return a;if(Wt.call(a,"__wrapped__"))return HL(a)}return new jn(a)}var Pi=function(){function a(){}return function(u){if(!ke(u))return{};if(zl)return zl(u);a.prototype=u;var g=new a;return a.prototype=e,g}}();function ys(){}function jn(a,u){this.__wrapped__=a,this.__actions__=[],this.__chain__=!!u,this.__index__=0,this.__values__=e}k.templateSettings={escape:_x,evaluate:Mx,interpolate:Bm,variable:"",imports:{_:k}},k.prototype=ys.prototype,k.prototype.constructor=k,jn.prototype=Pi(ys.prototype),jn.prototype.constructor=jn;function Vt(a){this.__wrapped__=a,this.__actions__=[],this.__dir__=1,this.__filtered__=!1,this.__iteratees__=[],this.__takeCount__=Ar,this.__views__=[]}function ent(){var a=new Vt(this.__wrapped__);return a.__actions__=zn(this.__actions__),a.__dir__=this.__dir__,a.__filtered__=this.__filtered__,a.__iteratees__=zn(this.__iteratees__),a.__takeCount__=this.__takeCount__,a.__views__=zn(this.__views__),a}function nnt(){if(this.__filtered__){var a=new Vt(this);a.__dir__=-1,a.__filtered__=!0}else a=this.clone(),a.__dir__*=-1;return a}function rnt(){var a=this.__wrapped__.value(),u=this.__dir__,g=_t(a),x=u<0,T=g?a.length:0,w=grt(0,T,this.__views__),O=w.start,P=w.end,V=P-O,Q=x?P:O-1,Y=this.__iteratees__,tt=Y.length,ht=0,Et=_(V,this.__takeCount__);if(!g||!x&&T==V&&Et==V)return dL(a,this.__actions__);var Tt=[];t:for(;V--&&ht<Et;){Q+=u;for(var Nt=-1,yt=a[Q];++Nt<tt;){var jt=Y[Nt],zt=jt.iteratee,cr=jt.type,Dn=zt(yt);if(cr==Kn)yt=Dn;else if(!Dn){if(cr==be)continue t;break t}}Tt[ht++]=yt}return Tt}Vt.prototype=Pi(ys.prototype),Vt.prototype.constructor=Vt;function Yl(a){var u=-1,g=a==null?0:a.length;for(this.clear();++u<g;){var x=a[u];this.set(x[0],x[1])}}function int(){this.__data__=Jt?Jt(null):{},this.size=0}function ont(a){var u=this.has(a)&&delete this.__data__[a];return this.size-=u?1:0,u}function snt(a){var u=this.__data__;if(Jt){var g=u[a];return g===c?e:g}return Wt.call(u,a)?u[a]:e}function lnt(a){var u=this.__data__;return Jt?u[a]!==e:Wt.call(u,a)}function ant(a,u){var g=this.__data__;return this.size+=this.has(a)?0:1,g[a]=Jt&&u===e?c:u,this}Yl.prototype.clear=int,Yl.prototype.delete=ont,Yl.prototype.get=snt,Yl.prototype.has=lnt,Yl.prototype.set=ant;function Io(a){var u=-1,g=a==null?0:a.length;for(this.clear();++u<g;){var x=a[u];this.set(x[0],x[1])}}function cnt(){this.__data__=[],this.size=0}function unt(a){var u=this.__data__,g=Jm(u,a);if(g<0)return!1;var x=u.length-1;return g==x?u.pop():Gl.call(u,g,1),--this.size,!0}function fnt(a){var u=this.__data__,g=Jm(u,a);return g<0?e:u[g][1]}function dnt(a){return Jm(this.__data__,a)>-1}function hnt(a,u){var g=this.__data__,x=Jm(g,a);return x<0?(++this.size,g.push([a,u])):g[x][1]=u,this}Io.prototype.clear=cnt,Io.prototype.delete=unt,Io.prototype.get=fnt,Io.prototype.has=dnt,Io.prototype.set=hnt;function Do(a){var u=-1,g=a==null?0:a.length;for(this.clear();++u<g;){var x=a[u];this.set(x[0],x[1])}}function mnt(){this.size=0,this.__data__={hash:new Yl,map:new(ct||Io),string:new Yl}}function gnt(a){var u=ug(this,a).delete(a);return this.size-=u?1:0,u}function pnt(a){return ug(this,a).get(a)}function Cnt(a){return ug(this,a).has(a)}function Ent(a,u){var g=ug(this,a),x=g.size;return g.set(a,u),this.size+=g.size==x?0:1,this}Do.prototype.clear=mnt,Do.prototype.delete=gnt,Do.prototype.get=pnt,Do.prototype.has=Cnt,Do.prototype.set=Ent;function Jl(a){var u=-1,g=a==null?0:a.length;for(this.__data__=new Do;++u<g;)this.add(a[u])}function xnt(a){return this.__data__.set(a,c),this}function Ant(a){return this.__data__.has(a)}Jl.prototype.add=Jl.prototype.push=xnt,Jl.prototype.has=Ant;function ii(a){var u=this.__data__=new Io(a);this.size=u.size}function bnt(){this.__data__=new Io,this.size=0}function vnt(a){var u=this.__data__,g=u.delete(a);return this.size=u.size,g}function Bnt(a){return this.__data__.get(a)}function Tnt(a){return this.__data__.has(a)}function ynt(a,u){var g=this.__data__;if(g instanceof Io){var x=g.__data__;if(!ct||x.length<i-1)return x.push([a,u]),this.size=++g.size,this;g=this.__data__=new Do(x)}return g.set(a,u),this.size=g.size,this}ii.prototype.clear=bnt,ii.prototype.delete=vnt,ii.prototype.get=Bnt,ii.prototype.has=Tnt,ii.prototype.set=ynt;function HS(a,u){var g=_t(a),x=!g&&ra(a),T=!g&&!x&&Ls(a),w=!g&&!x&&!T&&zc(a),O=g||x||T||w,P=O?_c(a.length,cd):[],V=P.length;for(var Q in a)(u||Wt.call(a,Q))&&!(O&&(Q=="length"||T&&(Q=="offset"||Q=="parent")||w&&(Q=="buffer"||Q=="byteLength"||Q=="byteOffset")||Oo(Q,V)))&&P.push(Q);return P}function jS(a){var u=a.length;return u?a[OA(0,u-1)]:e}function knt(a,u){return fg(zn(a),Zl(u,0,a.length))}function Rnt(a){return fg(zn(a))}function kA(a,u,g){(g!==e&&!oi(a[u],g)||g===e&&!(u in a))&&_o(a,u,g)}function gd(a,u,g){var x=a[u];(!(Wt.call(a,u)&&oi(x,g))||g===e&&!(u in a))&&_o(a,u,g)}function Jm(a,u){for(var g=a.length;g--;)if(oi(a[g][0],u))return g;return-1}function wnt(a,u,g,x){return ks(a,function(T,w,O){u(x,T,g(T),O)}),x}function zS(a,u){return a&&Ki(u,nn(u),a)}function Snt(a,u){return a&&Ki(u,Wn(u),a)}function _o(a,u,g){u=="__proto__"&&Lo?Lo(a,u,{configurable:!0,enumerable:!0,value:g,writable:!0}):a[u]=g}function RA(a,u){for(var g=-1,x=u.length,T=j(x),w=a==null;++g<x;)T[g]=w?e:lb(a,u[g]);return T}function Zl(a,u,g){return a===a&&(g!==e&&(a=a<=g?a:g),u!==e&&(a=a>=u?a:u)),a}function yr(a,u,g,x,T,w){var O,P=u&C,V=u&E,Q=u&A;if(g&&(O=T?g(a,x,T,w):g(a)),O!==e)return O;if(!ke(a))return a;var Y=_t(a);if(Y){if(O=Crt(a),!P)return zn(a,O)}else{var tt=Cn(a),ht=tt==bc||tt==pm;if(Ls(a))return gL(a,P);if(tt==br||tt==ps||ht&&!T){if(O=V||ht?{}:ML(a),!P)return V?srt(a,Snt(O,a)):ort(a,zS(O,a))}else{if(!ae[tt])return T?a:{};O=Ert(a,tt,P)}}w||(w=new ii);var Et=w.get(a);if(Et)return Et;w.set(a,O),c6(a)?a.forEach(function(yt){O.add(yr(yt,u,g,yt,a,w))}):l6(a)&&a.forEach(function(yt,jt){O.set(jt,yr(yt,u,g,jt,a,w))});var Tt=Q?V?WA:GA:V?Wn:nn,Nt=Y?e:Tt(a);return $n(Nt||a,function(yt,jt){Nt&&(jt=yt,yt=a[jt]),gd(O,jt,yr(yt,u,g,jt,a,w))}),O}function Lnt(a){var u=nn(a);return function(g){return GS(g,a,u)}}function GS(a,u,g){var x=g.length;if(a==null)return!x;for(a=Qt(a);x--;){var T=g[x],w=u[T],O=a[T];if(O===e&&!(T in a)||!w(O))return!1}return!0}function WS(a,u,g){if(typeof a!="function")throw new Sn(s);return vd(function(){a.apply(e,g)},u)}function pd(a,u,g,x){var T=-1,w=Sc,O=!0,P=a.length,V=[],Q=u.length;if(!P)return V;g&&(u=Ce(u,pn(g))),x?(w=nd,O=!1):u.length>=i&&(w=ni,O=!1,u=new Jl(u));t:for(;++T<P;){var Y=a[T],tt=g==null?Y:g(Y);if(Y=x||Y!==0?Y:0,O&&tt===tt){for(var ht=Q;ht--;)if(u[ht]===tt)continue t;V.push(Y)}else w(u,tt,x)||V.push(Y)}return V}var ks=AL(Fi),qS=AL(SA,!0);function Int(a,u){var g=!0;return ks(a,function(x,T,w){return g=!!u(x,T,w),g}),g}function Zm(a,u,g){for(var x=-1,T=a.length;++x<T;){var w=a[x],O=u(w);if(O!=null&&(P===e?O===O&&!ar(O):g(O,P)))var P=O,V=w}return V}function Dnt(a,u,g,x){var T=a.length;for(g=Ut(g),g<0&&(g=-g>T?0:T+g),x=x===e||x>T?T:Ut(x),x<0&&(x+=T),x=g>x?0:f6(x);g<x;)a[g++]=u;return a}function XS(a,u){var g=[];return ks(a,function(x,T,w){u(x,T,w)&&g.push(x)}),g}function an(a,u,g,x,T){var w=-1,O=a.length;for(g||(g=Art),T||(T=[]);++w<O;){var P=a[w];u>0&&g(P)?u>1?an(P,u-1,g,x,T):Oi(T,P):x||(T[T.length]=P)}return T}var wA=bL(),QS=bL(!0);function Fi(a,u){return a&&wA(a,u,nn)}function SA(a,u){return a&&QS(a,u,nn)}function tg(a,u){return ti(u,function(g){return No(a[g])})}function ta(a,u){u=ws(u,a);for(var g=0,x=u.length;a!=null&&g<x;)a=a[Vi(u[g++])];return g&&g==x?a:e}function YS(a,u,g){var x=u(a);return _t(a)?x:Oi(x,g(a))}function Ln(a){return a==null?a===e?xm:Cm:So&&So in Qt(a)?mrt(a):Rrt(a)}function LA(a,u){return a>u}function _nt(a,u){return a!=null&&Wt.call(a,u)}function Mnt(a,u){return a!=null&&u in Qt(a)}function Unt(a,u,g){return a>=_(u,g)&&a<S(u,g)}function IA(a,u,g){for(var x=g?nd:Sc,T=a[0].length,w=a.length,O=w,P=j(w),V=1/0,Q=[];O--;){var Y=a[O];O&&u&&(Y=Ce(Y,pn(u))),V=_(Y.length,V),P[O]=!g&&(u||T>=120&&Y.length>=120)?new Jl(O&&Y):e}Y=a[0];var tt=-1,ht=P[0];t:for(;++tt<T&&Q.length<V;){var Et=Y[tt],Tt=u?u(Et):Et;if(Et=g||Et!==0?Et:0,!(ht?ni(ht,Tt):x(Q,Tt,g))){for(O=w;--O;){var Nt=P[O];if(!(Nt?ni(Nt,Tt):x(a[O],Tt,g)))continue t}ht&&ht.push(Tt),Q.push(Et)}}return Q}function Ont(a,u,g,x){return Fi(a,function(T,w,O){u(x,g(T),w,O)}),x}function Cd(a,u,g){u=ws(u,a),a=PL(a,u);var x=a==null?a:a[Vi(Rr(u))];return x==null?e:wn(x,a,g)}function JS(a){return De(a)&&Ln(a)==ps}function Nnt(a){return De(a)&&Ln(a)==wl}function Pnt(a){return De(a)&&Ln(a)==Ht}function Ed(a,u,g,x,T){return a===u?!0:a==null||u==null||!De(a)&&!De(u)?a!==a&&u!==u:Fnt(a,u,g,x,Ed,T)}function Fnt(a,u,g,x,T,w){var O=_t(a),P=_t(u),V=O?bl:Cn(a),Q=P?bl:Cn(u);V=V==ps?br:V,Q=Q==ps?br:Q;var Y=V==br,tt=Q==br,ht=V==Q;if(ht&&Ls(a)){if(!Ls(u))return!1;O=!0,Y=!1}if(ht&&!Y)return w||(w=new ii),O||zc(a)?IL(a,u,g,x,T,w):drt(a,u,V,g,x,T,w);if(!(g&v)){var Et=Y&&Wt.call(a,"__wrapped__"),Tt=tt&&Wt.call(u,"__wrapped__");if(Et||Tt){var Nt=Et?a.value():a,yt=Tt?u.value():u;return w||(w=new ii),T(Nt,yt,g,x,w)}}return ht?(w||(w=new ii),hrt(a,u,g,x,T,w)):!1}function Knt(a){return De(a)&&Cn(a)==gn}function DA(a,u,g,x){var T=g.length,w=T,O=!x;if(a==null)return!w;for(a=Qt(a);T--;){var P=g[T];if(O&&P[2]?P[1]!==a[P[0]]:!(P[0]in a))return!1}for(;++T<w;){P=g[T];var V=P[0],Q=a[V],Y=P[1];if(O&&P[2]){if(Q===e&&!(V in a))return!1}else{var tt=new ii;if(x)var ht=x(Q,Y,V,a,u,tt);if(!(ht===e?Ed(Y,Q,v|R,x,tt):ht))return!1}}return!0}function ZS(a){if(!ke(a)||vrt(a))return!1;var u=No(a)?Gm:jx;return u.test(na(a))}function Vnt(a){return De(a)&&Ln(a)==Tl}function $nt(a){return De(a)&&Cn(a)==ye}function Hnt(a){return De(a)&&Cg(a.length)&&!!he[Ln(a)]}function tL(a){return typeof a=="function"?a:a==null?qn:typeof a=="object"?_t(a)?rL(a[0],a[1]):nL(a):v6(a)}function _A(a){if(!bd(a))return y(a);var u=[];for(var g in Qt(a))Wt.call(a,g)&&g!="constructor"&&u.push(g);return u}function jnt(a){if(!ke(a))return krt(a);var u=bd(a),g=[];for(var x in a)x=="constructor"&&(u||!Wt.call(a,x))||g.push(x);return g}function MA(a,u){return a<u}function eL(a,u){var g=-1,x=Gn(a)?j(a.length):[];return ks(a,function(T,w,O){x[++g]=u(T,w,O)}),x}function nL(a){var u=XA(a);return u.length==1&&u[0][2]?OL(u[0][0],u[0][1]):function(g){return g===a||DA(g,a,u)}}function rL(a,u){return YA(a)&&UL(u)?OL(Vi(a),u):function(g){var x=lb(g,a);return x===e&&x===u?ab(g,a):Ed(u,x,v|R)}}function eg(a,u,g,x,T){a!==u&&wA(u,function(w,O){if(T||(T=new ii),ke(w))znt(a,u,O,g,eg,x,T);else{var P=x?x(ZA(a,O),w,O+"",a,u,T):e;P===e&&(P=w),kA(a,O,P)}},Wn)}function znt(a,u,g,x,T,w,O){var P=ZA(a,g),V=ZA(u,g),Q=O.get(V);if(Q){kA(a,g,Q);return}var Y=w?w(P,V,g+"",a,u,O):e,tt=Y===e;if(tt){var ht=_t(V),Et=!ht&&Ls(V),Tt=!ht&&!Et&&zc(V);Y=V,ht||Et||Tt?_t(P)?Y=P:Ne(P)?Y=zn(P):Et?(tt=!1,Y=gL(V,!0)):Tt?(tt=!1,Y=pL(V,!0)):Y=[]:Bd(V)||ra(V)?(Y=P,ra(P)?Y=d6(P):(!ke(P)||No(P))&&(Y=ML(V))):tt=!1}tt&&(O.set(V,Y),T(Y,V,x,w,O),O.delete(V)),kA(a,g,Y)}function iL(a,u){var g=a.length;if(!!g)return u+=u<0?g:0,Oo(u,g)?a[u]:e}function oL(a,u,g){u.length?u=Ce(u,function(w){return _t(w)?function(O){return ta(O,w.length===1?w[0]:w)}:w}):u=[qn];var x=-1;u=Ce(u,pn(vt()));var T=eL(a,function(w,O,P){var V=Ce(u,function(Q){return Q(w)});return{criteria:V,index:++x,value:w}});return Nm(T,function(w,O){return irt(w,O,g)})}function Gnt(a,u){return sL(a,u,function(g,x){return ab(a,x)})}function sL(a,u,g){for(var x=-1,T=u.length,w={};++x<T;){var O=u[x],P=ta(a,O);g(P,O)&&xd(w,ws(O,a),P)}return w}function Wnt(a){return function(u){return ta(u,a)}}function UA(a,u,g,x){var T=x?vs:Ao,w=-1,O=u.length,P=a;for(a===u&&(u=zn(u)),g&&(P=Ce(a,pn(g)));++w<O;)for(var V=0,Q=u[w],Y=g?g(Q):Q;(V=T(P,Y,V,x))>-1;)P!==a&&Gl.call(P,V,1),Gl.call(a,V,1);return a}function lL(a,u){for(var g=a?u.length:0,x=g-1;g--;){var T=u[g];if(g==x||T!==w){var w=T;Oo(T)?Gl.call(a,T,1):FA(a,T)}}return a}function OA(a,u){return a+Xl($()*(u-a+1))}function qnt(a,u,g,x){for(var T=-1,w=S(ql((u-a)/(g||1)),0),O=j(w);w--;)O[x?w:++T]=a,a+=g;return O}function NA(a,u){var g="";if(!a||u<1||u>mn)return g;do u%2&&(g+=a),u=Xl(u/2),u&&(a+=a);while(u);return g}function Pt(a,u){return tb(NL(a,u,qn),a+"")}function Xnt(a){return jS(Gc(a))}function Qnt(a,u){var g=Gc(a);return fg(g,Zl(u,0,g.length))}function xd(a,u,g,x){if(!ke(a))return a;u=ws(u,a);for(var T=-1,w=u.length,O=w-1,P=a;P!=null&&++T<w;){var V=Vi(u[T]),Q=g;if(V==="__proto__"||V==="constructor"||V==="prototype")return a;if(T!=O){var Y=P[V];Q=x?x(Y,V,P):e,Q===e&&(Q=ke(Y)?Y:Oo(u[T+1])?[]:{})}gd(P,V,Q),P=P[V]}return a}var aL=Oe?function(a,u){return Oe.set(a,u),a}:qn,Ynt=Lo?function(a,u){return Lo(a,"toString",{configurable:!0,enumerable:!1,value:ub(u),writable:!0})}:qn;function Jnt(a){return fg(Gc(a))}function kr(a,u,g){var x=-1,T=a.length;u<0&&(u=-u>T?0:T+u),g=g>T?T:g,g<0&&(g+=T),T=u>g?0:g-u>>>0,u>>>=0;for(var w=j(T);++x<T;)w[x]=a[x+u];return w}function Znt(a,u){var g;return ks(a,function(x,T,w){return g=u(x,T,w),!g}),!!g}function ng(a,u,g){var x=0,T=a==null?x:a.length;if(typeof u=="number"&&u===u&&T<=yx){for(;x<T;){var w=x+T>>>1,O=a[w];O!==null&&!ar(O)&&(g?O<=u:O<u)?x=w+1:T=w}return T}return PA(a,u,qn,g)}function PA(a,u,g,x){var T=0,w=a==null?0:a.length;if(w===0)return 0;u=g(u);for(var O=u!==u,P=u===null,V=ar(u),Q=u===e;T<w;){var Y=Xl((T+w)/2),tt=g(a[Y]),ht=tt!==e,Et=tt===null,Tt=tt===tt,Nt=ar(tt);if(O)var yt=x||Tt;else Q?yt=Tt&&(x||ht):P?yt=Tt&&ht&&(x||!Et):V?yt=Tt&&ht&&!Et&&(x||!Nt):Et||Nt?yt=!1:yt=x?tt<=u:tt<u;yt?T=Y+1:w=Y}return _(w,Tx)}function cL(a,u){for(var g=-1,x=a.length,T=0,w=[];++g<x;){var O=a[g],P=u?u(O):O;if(!g||!oi(P,V)){var V=P;w[T++]=O===0?0:O}}return w}function uL(a){return typeof a=="number"?a:ar(a)?go:+a}function lr(a){if(typeof a=="string")return a;if(_t(a))return Ce(a,lr)+"";if(ar(a))return Tr?Tr.call(a):"";var u=a+"";return u=="0"&&1/a==-Rn?"-0":u}function Rs(a,u,g){var x=-1,T=Sc,w=a.length,O=!0,P=[],V=P;if(g)O=!1,T=nd;else if(w>=i){var Q=u?null:urt(a);if(Q)return To(Q);O=!1,T=ni,V=new Jl}else V=u?[]:P;t:for(;++x<w;){var Y=a[x],tt=u?u(Y):Y;if(Y=g||Y!==0?Y:0,O&&tt===tt){for(var ht=V.length;ht--;)if(V[ht]===tt)continue t;u&&V.push(tt),P.push(Y)}else T(V,tt,g)||(V!==P&&V.push(tt),P.push(Y))}return P}function FA(a,u){return u=ws(u,a),a=PL(a,u),a==null||delete a[Vi(Rr(u))]}function fL(a,u,g,x){return xd(a,u,g(ta(a,u)),x)}function rg(a,u,g,x){for(var T=a.length,w=x?T:-1;(x?w--:++w<T)&&u(a[w],w,a););return g?kr(a,x?0:w,x?w+1:T):kr(a,x?w+1:0,x?T:w)}function dL(a,u){var g=a;return g instanceof Vt&&(g=g.value()),rd(u,function(x,T){return T.func.apply(T.thisArg,Oi([x],T.args))},g)}function KA(a,u,g){var x=a.length;if(x<2)return x?Rs(a[0]):[];for(var T=-1,w=j(x);++T<x;)for(var O=a[T],P=-1;++P<x;)P!=T&&(w[T]=pd(w[T]||O,a[P],u,g));return Rs(an(w,1),u,g)}function hL(a,u,g){for(var x=-1,T=a.length,w=u.length,O={};++x<T;){var P=x<w?u[x]:e;g(O,a[x],P)}return O}function VA(a){return Ne(a)?a:[]}function $A(a){return typeof a=="function"?a:qn}function ws(a,u){return _t(a)?a:YA(a,u)?[a]:$L(ee(a))}var trt=Pt;function Ss(a,u,g){var x=a.length;return g=g===e?x:g,!u&&g>=x?a:kr(a,u,g)}var mL=qm||function(a){return Je.clearTimeout(a)};function gL(a,u){if(u)return a.slice();var g=a.length,x=jl?jl(g):new a.constructor(g);return a.copy(x),x}function HA(a){var u=new a.constructor(a.byteLength);return new Hl(u).set(new Hl(a)),u}function ert(a,u){var g=u?HA(a.buffer):a.buffer;return new a.constructor(g,a.byteOffset,a.byteLength)}function nrt(a){var u=new a.constructor(a.source,vc.exec(a));return u.lastIndex=a.lastIndex,u}function rrt(a){return ve?Qt(ve.call(a)):{}}function pL(a,u){var g=u?HA(a.buffer):a.buffer;return new a.constructor(g,a.byteOffset,a.length)}function CL(a,u){if(a!==u){var g=a!==e,x=a===null,T=a===a,w=ar(a),O=u!==e,P=u===null,V=u===u,Q=ar(u);if(!P&&!Q&&!w&&a>u||w&&O&&V&&!P&&!Q||x&&O&&V||!g&&V||!T)return 1;if(!x&&!w&&!Q&&a<u||Q&&g&&T&&!x&&!w||P&&g&&T||!O&&T||!V)return-1}return 0}function irt(a,u,g){for(var x=-1,T=a.criteria,w=u.criteria,O=T.length,P=g.length;++x<O;){var V=CL(T[x],w[x]);if(V){if(x>=P)return V;var Q=g[x];return V*(Q=="desc"?-1:1)}}return a.index-u.index}function EL(a,u,g,x){for(var T=-1,w=a.length,O=g.length,P=-1,V=u.length,Q=S(w-O,0),Y=j(V+Q),tt=!x;++P<V;)Y[P]=u[P];for(;++T<O;)(tt||T<w)&&(Y[g[T]]=a[T]);for(;Q--;)Y[P++]=a[T++];return Y}function xL(a,u,g,x){for(var T=-1,w=a.length,O=-1,P=g.length,V=-1,Q=u.length,Y=S(w-P,0),tt=j(Y+Q),ht=!x;++T<Y;)tt[T]=a[T];for(var Et=T;++V<Q;)tt[Et+V]=u[V];for(;++O<P;)(ht||T<w)&&(tt[Et+g[O]]=a[T++]);return tt}function zn(a,u){var g=-1,x=a.length;for(u||(u=j(x));++g<x;)u[g]=a[g];return u}function Ki(a,u,g,x){var T=!g;g||(g={});for(var w=-1,O=u.length;++w<O;){var P=u[w],V=x?x(g[P],a[P],P,g,a):e;V===e&&(V=a[P]),T?_o(g,P,V):gd(g,P,V)}return g}function ort(a,u){return Ki(a,QA(a),u)}function srt(a,u){return Ki(a,DL(a),u)}function ig(a,u){return function(g,x){var T=_t(g)?xA:wnt,w=u?u():{};return T(g,a,vt(x,2),w)}}function $c(a){return Pt(function(u,g){var x=-1,T=g.length,w=T>1?g[T-1]:e,O=T>2?g[2]:e;for(w=a.length>3&&typeof w=="function"?(T--,w):e,O&&In(g[0],g[1],O)&&(w=T<3?e:w,T=1),u=Qt(u);++x<T;){var P=g[x];P&&a(u,P,x,w)}return u})}function AL(a,u){return function(g,x){if(g==null)return g;if(!Gn(g))return a(g,x);for(var T=g.length,w=u?T:-1,O=Qt(g);(u?w--:++w<T)&&x(O[w],w,O)!==!1;);return g}}function bL(a){return function(u,g,x){for(var T=-1,w=Qt(u),O=x(u),P=O.length;P--;){var V=O[a?P:++T];if(g(w[V],V,w)===!1)break}return u}}function lrt(a,u,g){var x=u&L,T=Ad(a);function w(){var O=this&&this!==Je&&this instanceof w?T:a;return O.apply(x?g:this,arguments)}return w}function vL(a){return function(u){u=ee(u);var g=vo(u)?sr(u):e,x=g?g[0]:u.charAt(0),T=g?Ss(g,1).join(""):u.slice(1);return x[a]()+T}}function Hc(a){return function(u){return rd(A6(x6(u).replace(sA,"")),a,"")}}function Ad(a){return function(){var u=arguments;switch(u.length){case 0:return new a;case 1:return new a(u[0]);case 2:return new a(u[0],u[1]);case 3:return new a(u[0],u[1],u[2]);case 4:return new a(u[0],u[1],u[2],u[3]);case 5:return new a(u[0],u[1],u[2],u[3],u[4]);case 6:return new a(u[0],u[1],u[2],u[3],u[4],u[5]);case 7:return new a(u[0],u[1],u[2],u[3],u[4],u[5],u[6])}var g=Pi(a.prototype),x=a.apply(g,u);return ke(x)?x:g}}function art(a,u,g){var x=Ad(a);function T(){for(var w=arguments.length,O=j(w),P=w,V=jc(T);P--;)O[P]=arguments[P];var Q=w<3&&O[0]!==V&&O[w-1]!==V?[]:or(O,V);if(w-=Q.length,w<g)return RL(a,u,og,T.placeholder,e,O,Q,e,e,g-w);var Y=this&&this!==Je&&this instanceof T?x:a;return wn(Y,this,O)}return T}function BL(a){return function(u,g,x){var T=Qt(u);if(!Gn(u)){var w=vt(g,3);u=nn(u),g=function(P){return w(T[P],P,T)}}var O=a(u,g,x);return O>-1?T[w?u[O]:O]:e}}function TL(a){return Uo(function(u){var g=u.length,x=g,T=jn.prototype.thru;for(a&&u.reverse();x--;){var w=u[x];if(typeof w!="function")throw new Sn(s);if(T&&!O&&cg(w)=="wrapper")var O=new jn([],!0)}for(x=O?x:g;++x<g;){w=u[x];var P=cg(w),V=P=="wrapper"?qA(w):e;V&&JA(V[0])&&V[1]==(at|F|W|xt)&&!V[4].length&&V[9]==1?O=O[cg(V[0])].apply(O,V[3]):O=w.length==1&&JA(w)?O[P]():O.thru(w)}return function(){var Q=arguments,Y=Q[0];if(O&&Q.length==1&&_t(Y))return O.plant(Y).value();for(var tt=0,ht=g?u[tt].apply(this,Q):Y;++tt<g;)ht=u[tt].call(this,ht);return ht}})}function og(a,u,g,x,T,w,O,P,V,Q){var Y=u&at,tt=u&L,ht=u&M,Et=u&(F|G),Tt=u&Mt,Nt=ht?e:Ad(a);function yt(){for(var jt=arguments.length,zt=j(jt),cr=jt;cr--;)zt[cr]=arguments[cr];if(Et)var Dn=jc(yt),ur=Pm(zt,Dn);if(x&&(zt=EL(zt,x,T,Et)),w&&(zt=xL(zt,w,O,Et)),jt-=ur,Et&&jt<Q){var Pe=or(zt,Dn);return RL(a,u,og,yt.placeholder,g,zt,Pe,P,V,Q-jt)}var si=tt?g:this,Fo=ht?si[a]:a;return jt=zt.length,P?zt=wrt(zt,P):Tt&&jt>1&&zt.reverse(),Y&&V<jt&&(zt.length=V),this&&this!==Je&&this instanceof yt&&(Fo=Nt||Ad(Fo)),Fo.apply(si,zt)}return yt}function yL(a,u){return function(g,x){return Ont(g,a,u(x),{})}}function sg(a,u){return function(g,x){var T;if(g===e&&x===e)return u;if(g!==e&&(T=g),x!==e){if(T===e)return x;typeof g=="string"||typeof x=="string"?(g=lr(g),x=lr(x)):(g=uL(g),x=uL(x)),T=a(g,x)}return T}}function jA(a){return Uo(function(u){return u=Ce(u,pn(vt())),Pt(function(g){var x=this;return a(u,function(T){return wn(T,x,g)})})})}function lg(a,u){u=u===e?" ":lr(u);var g=u.length;if(g<2)return g?NA(u,a):u;var x=NA(u,ql(a/Ts(u)));return vo(u)?Ss(sr(x),0,a).join(""):x.slice(0,a)}function crt(a,u,g,x){var T=u&L,w=Ad(a);function O(){for(var P=-1,V=arguments.length,Q=-1,Y=x.length,tt=j(Y+V),ht=this&&this!==Je&&this instanceof O?w:a;++Q<Y;)tt[Q]=x[Q];for(;V--;)tt[Q++]=arguments[++P];return wn(ht,T?g:this,tt)}return O}function kL(a){return function(u,g,x){return x&&typeof x!="number"&&In(u,g,x)&&(g=x=e),u=Po(u),g===e?(g=u,u=0):g=Po(g),x=x===e?u<g?1:-1:Po(x),qnt(u,g,x,a)}}function ag(a){return function(u,g){return typeof u=="string"&&typeof g=="string"||(u=wr(u),g=wr(g)),a(u,g)}}function RL(a,u,g,x,T,w,O,P,V,Q){var Y=u&F,tt=Y?O:e,ht=Y?e:O,Et=Y?w:e,Tt=Y?e:w;u|=Y?W:it,u&=~(Y?it:W),u&U||(u&=~(L|M));var Nt=[a,u,T,Et,tt,Tt,ht,P,V,Q],yt=g.apply(e,Nt);return JA(a)&&FL(yt,Nt),yt.placeholder=x,KL(yt,a,u)}function zA(a){var u=Ie[a];return function(g,x){if(g=wr(g),x=x==null?0:_(Ut(x),292),x&&md(g)){var T=(ee(g)+"e").split("e"),w=u(T[0]+"e"+(+T[1]+x));return T=(ee(w)+"e").split("e"),+(T[0]+"e"+(+T[1]-x))}return u(g)}}var urt=ut&&1/To(new ut([,-0]))[1]==Rn?function(a){return new ut(a)}:hb;function wL(a){return function(u){var g=Cn(u);return g==gn?Bo(u):g==ye?Pl(u):Ul(u,a(u))}}function Mo(a,u,g,x,T,w,O,P){var V=u&M;if(!V&&typeof a!="function")throw new Sn(s);var Q=x?x.length:0;if(Q||(u&=~(W|it),x=T=e),O=O===e?O:S(Ut(O),0),P=P===e?P:Ut(P),Q-=T?T.length:0,u&it){var Y=x,tt=T;x=T=e}var ht=V?e:qA(a),Et=[a,u,g,x,T,Y,tt,w,O,P];if(ht&&yrt(Et,ht),a=Et[0],u=Et[1],g=Et[2],x=Et[3],T=Et[4],P=Et[9]=Et[9]===e?V?0:a.length:S(Et[9]-Q,0),!P&&u&(F|G)&&(u&=~(F|G)),!u||u==L)var Tt=lrt(a,u,g);else u==F||u==G?Tt=art(a,u,P):(u==W||u==(L|W))&&!T.length?Tt=crt(a,u,g,x):Tt=og.apply(e,Et);var Nt=ht?aL:FL;return KL(Nt(Tt,Et),a,u)}function SL(a,u,g,x){return a===e||oi(a,ko[g])&&!Wt.call(x,g)?u:a}function LL(a,u,g,x,T,w){return ke(a)&&ke(u)&&(w.set(u,a),eg(a,u,e,LL,w),w.delete(u)),a}function frt(a){return Bd(a)?e:a}function IL(a,u,g,x,T,w){var O=g&v,P=a.length,V=u.length;if(P!=V&&!(O&&V>P))return!1;var Q=w.get(a),Y=w.get(u);if(Q&&Y)return Q==u&&Y==a;var tt=-1,ht=!0,Et=g&R?new Jl:e;for(w.set(a,u),w.set(u,a);++tt<P;){var Tt=a[tt],Nt=u[tt];if(x)var yt=O?x(Nt,Tt,tt,u,a,w):x(Tt,Nt,tt,a,u,w);if(yt!==e){if(yt)continue;ht=!1;break}if(Et){if(!id(u,function(jt,zt){if(!ni(Et,zt)&&(Tt===jt||T(Tt,jt,g,x,w)))return Et.push(zt)})){ht=!1;break}}else if(!(Tt===Nt||T(Tt,Nt,g,x,w))){ht=!1;break}}return w.delete(a),w.delete(u),ht}function drt(a,u,g,x,T,w,O){switch(g){case Es:if(a.byteLength!=u.byteLength||a.byteOffset!=u.byteOffset)return!1;a=a.buffer,u=u.buffer;case wl:return!(a.byteLength!=u.byteLength||!w(new Hl(a),new Hl(u)));case po:case Ht:case Bl:return oi(+a,+u);case Cs:return a.name==u.name&&a.message==u.message;case Tl:case yl:return a==u+"";case gn:var P=Bo;case ye:var V=x&v;if(P||(P=To),a.size!=u.size&&!V)return!1;var Q=O.get(a);if(Q)return Q==u;x|=R,O.set(a,u);var Y=IL(P(a),P(u),x,T,w,O);return O.delete(a),Y;case kl:if(ve)return ve.call(a)==ve.call(u)}return!1}function hrt(a,u,g,x,T,w){var O=g&v,P=GA(a),V=P.length,Q=GA(u),Y=Q.length;if(V!=Y&&!O)return!1;for(var tt=V;tt--;){var ht=P[tt];if(!(O?ht in u:Wt.call(u,ht)))return!1}var Et=w.get(a),Tt=w.get(u);if(Et&&Tt)return Et==u&&Tt==a;var Nt=!0;w.set(a,u),w.set(u,a);for(var yt=O;++tt<V;){ht=P[tt];var jt=a[ht],zt=u[ht];if(x)var cr=O?x(zt,jt,ht,u,a,w):x(jt,zt,ht,a,u,w);if(!(cr===e?jt===zt||T(jt,zt,g,x,w):cr)){Nt=!1;break}yt||(yt=ht=="constructor")}if(Nt&&!yt){var Dn=a.constructor,ur=u.constructor;Dn!=ur&&"constructor"in a&&"constructor"in u&&!(typeof Dn=="function"&&Dn instanceof Dn&&typeof ur=="function"&&ur instanceof ur)&&(Nt=!1)}return w.delete(a),w.delete(u),Nt}function Uo(a){return tb(NL(a,e,GL),a+"")}function GA(a){return YS(a,nn,QA)}function WA(a){return YS(a,Wn,DL)}var qA=Oe?function(a){return Oe.get(a)}:hb;function cg(a){for(var u=a.name+"",g=ln[u],x=Wt.call(ln,u)?g.length:0;x--;){var T=g[x],w=T.func;if(w==null||w==a)return T.name}return u}function jc(a){var u=Wt.call(k,"placeholder")?k:a;return u.placeholder}function vt(){var a=k.iteratee||fb;return a=a===fb?tL:a,arguments.length?a(arguments[0],arguments[1]):a}function ug(a,u){var g=a.__data__;return brt(u)?g[typeof u=="string"?"string":"hash"]:g.map}function XA(a){for(var u=nn(a),g=u.length;g--;){var x=u[g],T=a[x];u[g]=[x,T,UL(T)]}return u}function ea(a,u){var g=Vm(a,u);return ZS(g)?g:e}function mrt(a){var u=Wt.call(a,So),g=a[So];try{a[So]=e;var x=!0}catch{}var T=$l.call(a);return x&&(u?a[So]=g:delete a[So]),T}var QA=Ql?function(a){return a==null?[]:(a=Qt(a),ti(Ql(a),function(u){return hd.call(a,u)}))}:mb,DL=Ql?function(a){for(var u=[];a;)Oi(u,QA(a)),a=Ni(a);return u}:mb,Cn=Ln;(J&&Cn(new J(new ArrayBuffer(1)))!=Es||ct&&Cn(new ct)!=gn||Ct&&Cn(Ct.resolve())!=Em||ut&&Cn(new ut)!=ye||At&&Cn(new At)!=Rl)&&(Cn=function(a){var u=Ln(a),g=u==br?a.constructor:e,x=g?na(g):"";if(x)switch(x){case Hn:return Es;case Br:return gn;case TA:return Em;case yA:return ye;case Ee:return Rl}return u});function grt(a,u,g){for(var x=-1,T=g.length;++x<T;){var w=g[x],O=w.size;switch(w.type){case"drop":a+=O;break;case"dropRight":u-=O;break;case"take":u=_(u,a+O);break;case"takeRight":a=S(a,u-O);break}}return{start:a,end:u}}function prt(a){var u=a.match(de);return u?u[1].split(Vx):[]}function _L(a,u,g){u=ws(u,a);for(var x=-1,T=u.length,w=!1;++x<T;){var O=Vi(u[x]);if(!(w=a!=null&&g(a,O)))break;a=a[O]}return w||++x!=T?w:(T=a==null?0:a.length,!!T&&Cg(T)&&Oo(O,T)&&(_t(a)||ra(a)))}function Crt(a){var u=a.length,g=new a.constructor(u);return u&&typeof a[0]=="string"&&Wt.call(a,"index")&&(g.index=a.index,g.input=a.input),g}function ML(a){return typeof a.constructor=="function"&&!bd(a)?Pi(Ni(a)):{}}function Ert(a,u,g){var x=a.constructor;switch(u){case wl:return HA(a);case po:case Ht:return new x(+a);case Es:return ert(a,g);case Lf:case If:case Df:case _f:case Mf:case Uf:case Of:case Nf:case Pf:return pL(a,g);case gn:return new x;case Bl:case yl:return new x(a);case Tl:return nrt(a);case ye:return new x;case kl:return rrt(a)}}function xrt(a,u){var g=u.length;if(!g)return a;var x=g-1;return u[x]=(g>1?"& ":"")+u[x],u=u.join(g>2?", ":" "),a.replace(Kx,`{
|
|
624
624
|
/* [wrapped with `+u+`] */
|
|
625
|
-
`)}function Art(a){return Dt(a)||ra(a)||!!(Wm&&a&&a[Wm])}function Oo(a,u){var g=typeof a;return u=u==null?mn:u,!!u&&(g=="number"||g!="symbol"&&Gx.test(a))&&a>-1&&a%1==0&&a<u}function In(a,u,g){if(!ke(g))return!1;var x=typeof u;return(x=="number"?Gn(g)&&Oo(u,g.length):x=="string"&&u in g)?oi(g[u],a):!1}function YA(a,u){if(Dt(a))return!1;var g=typeof a;return g=="number"||g=="symbol"||g=="boolean"||a==null||ar(a)?!0:Ox.test(a)||!Ux.test(a)||u!=null&&a in Qt(u)}function brt(a){var u=typeof a;return u=="string"||u=="number"||u=="symbol"||u=="boolean"?a!=="__proto__":a===null}function JA(a){var u=cg(a),g=k[u];if(typeof g!="function"||!(u in Vt.prototype))return!1;if(a===g)return!0;var x=qA(g);return!!x&&a===x[0]}function vrt(a){return!!fd&&fd in a}var Brt=Vl?No:gb;function bd(a){var u=a&&a.constructor,g=typeof u=="function"&&u.prototype||ko;return a===g}function UL(a){return a===a&&!ke(a)}function OL(a,u){return function(g){return g==null?!1:g[a]===u&&(u!==e||a in Qt(g))}}function Trt(a){var u=gg(a,function(x){return g.size===d&&g.clear(),x}),g=u.cache;return u}function yrt(a,u){var g=a[1],x=u[1],T=g|x,w=T<(L|M|at),O=x==at&&g==F||x==at&&g==xt&&a[7].length<=u[8]||x==(at|xt)&&u[7].length<=u[8]&&g==F;if(!(w||O))return a;x&L&&(a[2]=u[2],T|=g&L?0:U);var P=u[3];if(P){var V=a[3];a[3]=V?EL(V,P,u[4]):P,a[4]=V?or(a[3],h):u[4]}return P=u[5],P&&(V=a[5],a[5]=V?xL(V,P,u[6]):P,a[6]=V?or(a[5],h):u[6]),P=u[7],P&&(a[7]=P),x&at&&(a[8]=a[8]==null?u[8]:_(a[8],u[8])),a[9]==null&&(a[9]=u[9]),a[0]=u[0],a[1]=T,a}function krt(a){var u=[];if(a!=null)for(var g in Qt(a))u.push(g);return u}function Rrt(a){return $l.call(a)}function NL(a,u,g){return u=S(u===e?a.length-1:u,0),function(){for(var x=arguments,T=-1,w=S(x.length-u,0),O=j(w);++T<w;)O[T]=x[u+T];T=-1;for(var P=j(u+1);++T<u;)P[T]=x[T];return P[u]=g(O),wn(a,this,P)}}function PL(a,u){return u.length<2?a:ta(a,kr(u,0,-1))}function wrt(a,u){for(var g=a.length,x=_(u.length,g),T=zn(a);x--;){var w=u[x];a[x]=Oo(w,g)?T[w]:e}return a}function ZA(a,u){if(!(u==="constructor"&&typeof a[u]=="function")&&u!="__proto__")return a[u]}var FL=VL(aL),vd=Qm||function(a,u){return Je.setTimeout(a,u)},tb=VL(Ynt);function KL(a,u,g){var x=u+"";return tb(a,xrt(x,Srt(prt(x),g)))}function VL(a){var u=0,g=0;return function(){var x=N(),T=kn-(x-g);if(g=x,T>0){if(++u>=te)return arguments[0]}else u=0;return a.apply(e,arguments)}}function fg(a,u){var g=-1,x=a.length,T=x-1;for(u=u===e?x:u;++g<u;){var w=OA(g,T),O=a[w];a[w]=a[g],a[g]=O}return a.length=u,a}var $L=Trt(function(a){var u=[];return a.charCodeAt(0)===46&&u.push(""),a.replace(Nx,function(g,x,T,w){u.push(T?w.replace(Sl,"$1"):x||g)}),u});function Vi(a){if(typeof a=="string"||ar(a))return a;var u=a+"";return u=="0"&&1/a==-Rn?"-0":u}function na(a){if(a!=null){try{return Ro.call(a)}catch{}try{return a+""}catch{}}return""}function Srt(a,u){return $n(kx,function(g){var x="_."+g[0];u&g[1]&&!Sc(a,x)&&a.push(x)}),a.sort()}function HL(a){if(a instanceof Vt)return a.clone();var u=new jn(a.__wrapped__,a.__chain__);return u.__actions__=zn(a.__actions__),u.__index__=a.__index__,u.__values__=a.__values__,u}function Lrt(a,u,g){(g?In(a,u,g):u===e)?u=1:u=S(Ut(u),0);var x=a==null?0:a.length;if(!x||u<1)return[];for(var T=0,w=0,O=j(ql(x/u));T<x;)O[w++]=kr(a,T,T+=u);return O}function Irt(a){for(var u=-1,g=a==null?0:a.length,x=0,T=[];++u<g;){var w=a[u];w&&(T[x++]=w)}return T}function Drt(){var a=arguments.length;if(!a)return[];for(var u=j(a-1),g=arguments[0],x=a;x--;)u[x-1]=arguments[x];return Oi(Dt(g)?zn(g):[g],an(u,1))}var _rt=Pt(function(a,u){return Ne(a)?pd(a,an(u,1,Ne,!0)):[]}),Mrt=Pt(function(a,u){var g=Rr(u);return Ne(g)&&(g=e),Ne(a)?pd(a,an(u,1,Ne,!0),vt(g,2)):[]}),Urt=Pt(function(a,u){var g=Rr(u);return Ne(g)&&(g=e),Ne(a)?pd(a,an(u,1,Ne,!0),e,g):[]});function Ort(a,u,g){var x=a==null?0:a.length;return x?(u=g||u===e?1:Ut(u),kr(a,u<0?0:u,x)):[]}function Nrt(a,u,g){var x=a==null?0:a.length;return x?(u=g||u===e?1:Ut(u),u=x-u,kr(a,0,u<0?0:u)):[]}function Prt(a,u){return a&&a.length?rg(a,vt(u,3),!0,!0):[]}function Frt(a,u){return a&&a.length?rg(a,vt(u,3),!0):[]}function Krt(a,u,g,x){var T=a==null?0:a.length;return T?(g&&typeof g!="number"&&In(a,u,g)&&(g=0,x=T),Dnt(a,u,g,x)):[]}function jL(a,u,g){var x=a==null?0:a.length;if(!x)return-1;var T=g==null?0:Ut(g);return T<0&&(T=S(x+T,0)),_l(a,vt(u,3),T)}function zL(a,u,g){var x=a==null?0:a.length;if(!x)return-1;var T=x-1;return g!==e&&(T=Ut(g),T=g<0?S(x+T,0):_(T,x-1)),_l(a,vt(u,3),T,!0)}function GL(a){var u=a==null?0:a.length;return u?an(a,1):[]}function Vrt(a){var u=a==null?0:a.length;return u?an(a,Rn):[]}function $rt(a,u){var g=a==null?0:a.length;return g?(u=u===e?1:Ut(u),an(a,u)):[]}function Hrt(a){for(var u=-1,g=a==null?0:a.length,x={};++u<g;){var T=a[u];x[T[0]]=T[1]}return x}function WL(a){return a&&a.length?a[0]:e}function jrt(a,u,g){var x=a==null?0:a.length;if(!x)return-1;var T=g==null?0:Ut(g);return T<0&&(T=S(x+T,0)),Ao(a,u,T)}function zrt(a){var u=a==null?0:a.length;return u?kr(a,0,-1):[]}var Grt=Pt(function(a){var u=Ce(a,VA);return u.length&&u[0]===a[0]?IA(u):[]}),Wrt=Pt(function(a){var u=Rr(a),g=Ce(a,VA);return u===Rr(g)?u=e:g.pop(),g.length&&g[0]===a[0]?IA(g,vt(u,2)):[]}),qrt=Pt(function(a){var u=Rr(a),g=Ce(a,VA);return u=typeof u=="function"?u:e,u&&g.pop(),g.length&&g[0]===a[0]?IA(g,e,u):[]});function Xrt(a,u){return a==null?"":BA.call(a,u)}function Rr(a){var u=a==null?0:a.length;return u?a[u-1]:e}function Qrt(a,u,g){var x=a==null?0:a.length;if(!x)return-1;var T=x;return g!==e&&(T=Ut(g),T=T<0?S(x+T,0):_(T,x-1)),u===u?$m(a,u,T):_l(a,ei,T,!0)}function Yrt(a,u){return a&&a.length?iL(a,Ut(u)):e}var Jrt=Pt(qL);function qL(a,u){return a&&a.length&&u&&u.length?UA(a,u):a}function Zrt(a,u,g){return a&&a.length&&u&&u.length?UA(a,u,vt(g,2)):a}function tit(a,u,g){return a&&a.length&&u&&u.length?UA(a,u,e,g):a}var eit=Uo(function(a,u){var g=a==null?0:a.length,x=RA(a,u);return lL(a,Ce(u,function(T){return Oo(T,g)?+T:T}).sort(CL)),x});function nit(a,u){var g=[];if(!(a&&a.length))return g;var x=-1,T=[],w=a.length;for(u=vt(u,3);++x<w;){var O=a[x];u(O,x,a)&&(g.push(O),T.push(x))}return lL(a,T),g}function eb(a){return a==null?a:X.call(a)}function rit(a,u,g){var x=a==null?0:a.length;return x?(g&&typeof g!="number"&&In(a,u,g)?(u=0,g=x):(u=u==null?0:Ut(u),g=g===e?x:Ut(g)),kr(a,u,g)):[]}function iit(a,u){return ng(a,u)}function oit(a,u,g){return PA(a,u,vt(g,2))}function sit(a,u){var g=a==null?0:a.length;if(g){var x=ng(a,u);if(x<g&&oi(a[x],u))return x}return-1}function lit(a,u){return ng(a,u,!0)}function ait(a,u,g){return PA(a,u,vt(g,2),!0)}function cit(a,u){var g=a==null?0:a.length;if(g){var x=ng(a,u,!0)-1;if(oi(a[x],u))return x}return-1}function uit(a){return a&&a.length?cL(a):[]}function fit(a,u){return a&&a.length?cL(a,vt(u,2)):[]}function dit(a){var u=a==null?0:a.length;return u?kr(a,1,u):[]}function hit(a,u,g){return a&&a.length?(u=g||u===e?1:Ut(u),kr(a,0,u<0?0:u)):[]}function mit(a,u,g){var x=a==null?0:a.length;return x?(u=g||u===e?1:Ut(u),u=x-u,kr(a,u<0?0:u,x)):[]}function git(a,u){return a&&a.length?rg(a,vt(u,3),!1,!0):[]}function pit(a,u){return a&&a.length?rg(a,vt(u,3)):[]}var Cit=Pt(function(a){return Rs(an(a,1,Ne,!0))}),Eit=Pt(function(a){var u=Rr(a);return Ne(u)&&(u=e),Rs(an(a,1,Ne,!0),vt(u,2))}),xit=Pt(function(a){var u=Rr(a);return u=typeof u=="function"?u:e,Rs(an(a,1,Ne,!0),e,u)});function Ait(a){return a&&a.length?Rs(a):[]}function bit(a,u){return a&&a.length?Rs(a,vt(u,2)):[]}function vit(a,u){return u=typeof u=="function"?u:e,a&&a.length?Rs(a,e,u):[]}function nb(a){if(!(a&&a.length))return[];var u=0;return a=ti(a,function(g){if(Ne(g))return u=S(g.length,u),!0}),_c(u,function(g){return Ce(a,Ic(g))})}function XL(a,u){if(!(a&&a.length))return[];var g=nb(a);return u==null?g:Ce(g,function(x){return wn(u,e,x)})}var Bit=Pt(function(a,u){return Ne(a)?pd(a,u):[]}),Tit=Pt(function(a){return KA(ti(a,Ne))}),yit=Pt(function(a){var u=Rr(a);return Ne(u)&&(u=e),KA(ti(a,Ne),vt(u,2))}),kit=Pt(function(a){var u=Rr(a);return u=typeof u=="function"?u:e,KA(ti(a,Ne),e,u)}),Rit=Pt(nb);function wit(a,u){return hL(a||[],u||[],gd)}function Sit(a,u){return hL(a||[],u||[],xd)}var Lit=Pt(function(a){var u=a.length,g=u>1?a[u-1]:e;return g=typeof g=="function"?(a.pop(),g):e,XL(a,g)});function QL(a){var u=k(a);return u.__chain__=!0,u}function Iit(a,u){return u(a),a}function dg(a,u){return u(a)}var Dit=Uo(function(a){var u=a.length,g=u?a[0]:0,x=this.__wrapped__,T=function(w){return RA(w,a)};return u>1||this.__actions__.length||!(x instanceof Vt)||!Oo(g)?this.thru(T):(x=x.slice(g,+g+(u?1:0)),x.__actions__.push({func:dg,args:[T],thisArg:e}),new jn(x,this.__chain__).thru(function(w){return u&&!w.length&&w.push(e),w}))});function _it(){return QL(this)}function Mit(){return new jn(this.value(),this.__chain__)}function Uit(){this.__values__===e&&(this.__values__=u6(this.value()));var a=this.__index__>=this.__values__.length,u=a?e:this.__values__[this.__index__++];return{done:a,value:u}}function Oit(){return this}function Nit(a){for(var u,g=this;g instanceof ys;){var x=HL(g);x.__index__=0,x.__values__=e,u?T.__wrapped__=x:u=x;var T=x;g=g.__wrapped__}return T.__wrapped__=a,u}function Pit(){var a=this.__wrapped__;if(a instanceof Vt){var u=a;return this.__actions__.length&&(u=new Vt(this)),u=u.reverse(),u.__actions__.push({func:dg,args:[eb],thisArg:e}),new jn(u,this.__chain__)}return this.thru(eb)}function Fit(){return dL(this.__wrapped__,this.__actions__)}var Kit=ig(function(a,u,g){Wt.call(a,g)?++a[g]:_o(a,g,1)});function Vit(a,u,g){var x=Dt(a)?Um:Int;return g&&In(a,u,g)&&(u=e),x(a,vt(u,3))}function $it(a,u){var g=Dt(a)?ti:XS;return g(a,vt(u,3))}var Hit=BL(jL),jit=BL(zL);function zit(a,u){return an(hg(a,u),1)}function Git(a,u){return an(hg(a,u),Rn)}function Wit(a,u,g){return g=g===e?1:Ut(g),an(hg(a,u),g)}function YL(a,u){var g=Dt(a)?$n:ks;return g(a,vt(u,3))}function JL(a,u){var g=Dt(a)?AA:qS;return g(a,vt(u,3))}var qit=ig(function(a,u,g){Wt.call(a,g)?a[g].push(u):_o(a,g,[u])});function Xit(a,u,g,x){a=Gn(a)?a:Gc(a),g=g&&!x?Ut(g):0;var T=a.length;return g<0&&(g=S(T+g,0)),Eg(a)?g<=T&&a.indexOf(u,g)>-1:!!T&&Ao(a,u,g)>-1}var Qit=Pt(function(a,u,g){var x=-1,T=typeof u=="function",w=Gn(a)?j(a.length):[];return ks(a,function(O){w[++x]=T?wn(u,O,g):Cd(O,u,g)}),w}),Yit=ig(function(a,u,g){_o(a,g,u)});function hg(a,u){var g=Dt(a)?Ce:eL;return g(a,vt(u,3))}function Jit(a,u,g,x){return a==null?[]:(Dt(u)||(u=u==null?[]:[u]),g=x?e:g,Dt(g)||(g=g==null?[]:[g]),oL(a,u,g))}var Zit=ig(function(a,u,g){a[g?0:1].push(u)},function(){return[[],[]]});function tot(a,u,g){var x=Dt(a)?rd:Ml,T=arguments.length<3;return x(a,vt(u,4),g,T,ks)}function eot(a,u,g){var x=Dt(a)?bA:Ml,T=arguments.length<3;return x(a,vt(u,4),g,T,qS)}function not(a,u){var g=Dt(a)?ti:XS;return g(a,pg(vt(u,3)))}function rot(a){var u=Dt(a)?jS:Xnt;return u(a)}function iot(a,u,g){(g?In(a,u,g):u===e)?u=1:u=Ut(u);var x=Dt(a)?knt:Qnt;return x(a,u)}function oot(a){var u=Dt(a)?Rnt:Jnt;return u(a)}function sot(a){if(a==null)return 0;if(Gn(a))return Eg(a)?Ts(a):a.length;var u=Cn(a);return u==gn||u==ye?a.size:_A(a).length}function lot(a,u,g){var x=Dt(a)?id:Znt;return g&&In(a,u,g)&&(u=e),x(a,vt(u,3))}var aot=Pt(function(a,u){if(a==null)return[];var g=u.length;return g>1&&In(a,u[0],u[1])?u=[]:g>2&&In(u[0],u[1],u[2])&&(u=[u[0]]),oL(a,an(u,1),[])}),mg=Xm||function(){return Je.Date.now()};function cot(a,u){if(typeof u!="function")throw new Sn(s);return a=Ut(a),function(){if(--a<1)return u.apply(this,arguments)}}function ZL(a,u,g){return u=g?e:u,u=a&&u==null?a.length:u,Mo(a,at,e,e,e,e,u)}function t6(a,u){var g;if(typeof u!="function")throw new Sn(s);return a=Ut(a),function(){return--a>0&&(g=u.apply(this,arguments)),a<=1&&(u=e),g}}var rb=Pt(function(a,u,g){var x=L;if(g.length){var T=or(g,jc(rb));x|=W}return Mo(a,x,u,g,T)}),e6=Pt(function(a,u,g){var x=L|M;if(g.length){var T=or(g,jc(e6));x|=W}return Mo(u,x,a,g,T)});function n6(a,u,g){u=g?e:u;var x=Mo(a,F,e,e,e,e,e,u);return x.placeholder=n6.placeholder,x}function r6(a,u,g){u=g?e:u;var x=Mo(a,G,e,e,e,e,e,u);return x.placeholder=r6.placeholder,x}function i6(a,u,g){var x,T,w,O,P,V,Q=0,Y=!1,tt=!1,ht=!0;if(typeof a!="function")throw new Sn(s);u=wr(u)||0,ke(g)&&(Y=!!g.leading,tt="maxWait"in g,w=tt?S(wr(g.maxWait)||0,u):w,ht="trailing"in g?!!g.trailing:ht);function Et(Pe){var si=x,Fo=T;return x=T=e,Q=Pe,O=a.apply(Fo,si),O}function Tt(Pe){return Q=Pe,P=vd(jt,u),Y?Et(Pe):O}function Nt(Pe){var si=Pe-V,Fo=Pe-Q,B6=u-si;return tt?_(B6,w-Fo):B6}function yt(Pe){var si=Pe-V,Fo=Pe-Q;return V===e||si>=u||si<0||tt&&Fo>=w}function jt(){var Pe=mg();if(yt(Pe))return zt(Pe);P=vd(jt,Nt(Pe))}function zt(Pe){return P=e,ht&&x?Et(Pe):(x=T=e,O)}function cr(){P!==e&&mL(P),Q=0,x=V=T=P=e}function Dn(){return P===e?O:zt(mg())}function ur(){var Pe=mg(),si=yt(Pe);if(x=arguments,T=this,V=Pe,si){if(P===e)return Tt(V);if(tt)return mL(P),P=vd(jt,u),Et(V)}return P===e&&(P=vd(jt,u)),O}return ur.cancel=cr,ur.flush=Dn,ur}var uot=Pt(function(a,u){return WS(a,1,u)}),fot=Pt(function(a,u,g){return WS(a,wr(u)||0,g)});function dot(a){return Mo(a,Mt)}function gg(a,u){if(typeof a!="function"||u!=null&&typeof u!="function")throw new Sn(s);var g=function(){var x=arguments,T=u?u.apply(this,x):x[0],w=g.cache;if(w.has(T))return w.get(T);var O=a.apply(this,x);return g.cache=w.set(T,O)||w,O};return g.cache=new(gg.Cache||Do),g}gg.Cache=Do;function pg(a){if(typeof a!="function")throw new Sn(s);return function(){var u=arguments;switch(u.length){case 0:return!a.call(this);case 1:return!a.call(this,u[0]);case 2:return!a.call(this,u[0],u[1]);case 3:return!a.call(this,u[0],u[1],u[2])}return!a.apply(this,u)}}function hot(a){return t6(2,a)}var mot=trt(function(a,u){u=u.length==1&&Dt(u[0])?Ce(u[0],pn(vt())):Ce(an(u,1),pn(vt()));var g=u.length;return Pt(function(x){for(var T=-1,w=_(x.length,g);++T<w;)x[T]=u[T].call(this,x[T]);return wn(a,this,x)})}),ib=Pt(function(a,u){var g=or(u,jc(ib));return Mo(a,W,e,u,g)}),o6=Pt(function(a,u){var g=or(u,jc(o6));return Mo(a,it,e,u,g)}),got=Uo(function(a,u){return Mo(a,xt,e,e,e,u)});function pot(a,u){if(typeof a!="function")throw new Sn(s);return u=u===e?u:Ut(u),Pt(a,u)}function Cot(a,u){if(typeof a!="function")throw new Sn(s);return u=u==null?0:S(Ut(u),0),Pt(function(g){var x=g[u],T=Ss(g,0,u);return x&&Oi(T,x),wn(a,this,T)})}function Eot(a,u,g){var x=!0,T=!0;if(typeof a!="function")throw new Sn(s);return ke(g)&&(x="leading"in g?!!g.leading:x,T="trailing"in g?!!g.trailing:T),i6(a,u,{leading:x,maxWait:u,trailing:T})}function xot(a){return ZL(a,1)}function Aot(a,u){return ib($A(u),a)}function bot(){if(!arguments.length)return[];var a=arguments[0];return Dt(a)?a:[a]}function vot(a){return yr(a,A)}function Bot(a,u){return u=typeof u=="function"?u:e,yr(a,A,u)}function Tot(a){return yr(a,C|A)}function yot(a,u){return u=typeof u=="function"?u:e,yr(a,C|A,u)}function kot(a,u){return u==null||GS(a,u,nn(u))}function oi(a,u){return a===u||a!==a&&u!==u}var Rot=ag(LA),wot=ag(function(a,u){return a>=u}),ra=JS(function(){return arguments}())?JS:function(a){return De(a)&&Wt.call(a,"callee")&&!hd.call(a,"callee")},Dt=j.isArray,Sot=Yf?pn(Yf):Nnt;function Gn(a){return a!=null&&Cg(a.length)&&!No(a)}function Ne(a){return De(a)&&Gn(a)}function Lot(a){return a===!0||a===!1||De(a)&&Ln(a)==po}var Ls=Ym||gb,Iot=Jf?pn(Jf):Pnt;function Dot(a){return De(a)&&a.nodeType===1&&!Bd(a)}function _ot(a){if(a==null)return!0;if(Gn(a)&&(Dt(a)||typeof a=="string"||typeof a.splice=="function"||Ls(a)||zc(a)||ra(a)))return!a.length;var u=Cn(a);if(u==gn||u==ye)return!a.size;if(bd(a))return!_A(a).length;for(var g in a)if(Wt.call(a,g))return!1;return!0}function Mot(a,u){return Ed(a,u)}function Uot(a,u,g){g=typeof g=="function"?g:e;var x=g?g(a,u):e;return x===e?Ed(a,u,e,g):!!x}function ob(a){if(!De(a))return!1;var u=Ln(a);return u==Cs||u==_i||typeof a.message=="string"&&typeof a.name=="string"&&!Bd(a)}function Oot(a){return typeof a=="number"&&md(a)}function No(a){if(!ke(a))return!1;var u=Ln(a);return u==bc||u==pm||u==vl||u==Rx}function s6(a){return typeof a=="number"&&a==Ut(a)}function Cg(a){return typeof a=="number"&&a>-1&&a%1==0&&a<=mn}function ke(a){var u=typeof a;return a!=null&&(u=="object"||u=="function")}function De(a){return a!=null&&typeof a=="object"}var l6=Zf?pn(Zf):Knt;function Not(a,u){return a===u||DA(a,u,XA(u))}function Pot(a,u,g){return g=typeof g=="function"?g:e,DA(a,u,XA(u),g)}function Fot(a){return a6(a)&&a!=+a}function Kot(a){if(Brt(a))throw new wt(o);return ZS(a)}function Vot(a){return a===null}function $ot(a){return a==null}function a6(a){return typeof a=="number"||De(a)&&Ln(a)==Bl}function Bd(a){if(!De(a)||Ln(a)!=br)return!1;var u=Ni(a);if(u===null)return!0;var g=Wt.call(u,"constructor")&&u.constructor;return typeof g=="function"&&g instanceof g&&Ro.call(g)==dd}var sb=Mm?pn(Mm):Vnt;function Hot(a){return s6(a)&&a>=-mn&&a<=mn}var c6=td?pn(td):$nt;function Eg(a){return typeof a=="string"||!Dt(a)&&De(a)&&Ln(a)==yl}function ar(a){return typeof a=="symbol"||De(a)&&Ln(a)==kl}var zc=ed?pn(ed):Hnt;function jot(a){return a===e}function zot(a){return De(a)&&Cn(a)==Rl}function Got(a){return De(a)&&Ln(a)==Am}var Wot=ag(MA),qot=ag(function(a,u){return a<=u});function u6(a){if(!a)return[];if(Gn(a))return Eg(a)?sr(a):zn(a);if(Wl&&a[Wl])return Nl(a[Wl]());var u=Cn(a),g=u==gn?Bo:u==ye?To:Gc;return g(a)}function Po(a){if(!a)return a===0?a:0;if(a=wr(a),a===Rn||a===-Rn){var u=a<0?-1:1;return u*Di}return a===a?a:0}function Ut(a){var u=Po(a),g=u%1;return u===u?g?u-g:u:0}function f6(a){return a?Zl(Ut(a),0,Ar):0}function wr(a){if(typeof a=="number")return a;if(ar(a))return go;if(ke(a)){var u=typeof a.valueOf=="function"?a.valueOf():a;a=ke(u)?u+"":u}if(typeof a!="string")return a===0?a:+a;a=bo(a);var g=km.test(a);return g||zx.test(a)?CA(a.slice(2),g?2:8):ym.test(a)?go:+a}function d6(a){return Ki(a,Wn(a))}function Xot(a){return a?Zl(Ut(a),-mn,mn):a===0?a:0}function ee(a){return a==null?"":lr(a)}var Qot=$c(function(a,u){if(bd(u)||Gn(u)){Ki(u,nn(u),a);return}for(var g in u)Wt.call(u,g)&&gd(a,g,u[g])}),h6=$c(function(a,u){Ki(u,Wn(u),a)}),xg=$c(function(a,u,g,x){Ki(u,Wn(u),a,x)}),Yot=$c(function(a,u,g,x){Ki(u,nn(u),a,x)}),Jot=Uo(RA);function Zot(a,u){var g=Pi(a);return u==null?g:zS(g,u)}var tst=Pt(function(a,u){a=Qt(a);var g=-1,x=u.length,T=x>2?u[2]:e;for(T&&In(u[0],u[1],T)&&(x=1);++g<x;)for(var w=u[g],O=Wn(w),P=-1,V=O.length;++P<V;){var Q=O[P],Y=a[Q];(Y===e||oi(Y,ko[Q])&&!Wt.call(a,Q))&&(a[Q]=w[Q])}return a}),est=Pt(function(a){return a.push(e,LL),wn(m6,e,a)});function nst(a,u){return od(a,vt(u,3),Fi)}function rst(a,u){return od(a,vt(u,3),SA)}function ist(a,u){return a==null?a:wA(a,vt(u,3),Wn)}function ost(a,u){return a==null?a:QS(a,vt(u,3),Wn)}function sst(a,u){return a&&Fi(a,vt(u,3))}function lst(a,u){return a&&SA(a,vt(u,3))}function ast(a){return a==null?[]:tg(a,nn(a))}function cst(a){return a==null?[]:tg(a,Wn(a))}function lb(a,u,g){var x=a==null?e:ta(a,u);return x===e?g:x}function ust(a,u){return a!=null&&_L(a,u,_nt)}function ab(a,u){return a!=null&&_L(a,u,Mnt)}var fst=yL(function(a,u,g){u!=null&&typeof u.toString!="function"&&(u=$l.call(u)),a[u]=g},ub(qn)),dst=yL(function(a,u,g){u!=null&&typeof u.toString!="function"&&(u=$l.call(u)),Wt.call(a,u)?a[u].push(g):a[u]=[g]},vt),hst=Pt(Cd);function nn(a){return Gn(a)?HS(a):_A(a)}function Wn(a){return Gn(a)?HS(a,!0):jnt(a)}function mst(a,u){var g={};return u=vt(u,3),Fi(a,function(x,T,w){_o(g,u(x,T,w),x)}),g}function gst(a,u){var g={};return u=vt(u,3),Fi(a,function(x,T,w){_o(g,T,u(x,T,w))}),g}var pst=$c(function(a,u,g){eg(a,u,g)}),m6=$c(function(a,u,g,x){eg(a,u,g,x)}),Cst=Uo(function(a,u){var g={};if(a==null)return g;var x=!1;u=Ce(u,function(w){return w=ws(w,a),x||(x=w.length>1),w}),Ki(a,WA(a),g),x&&(g=yr(g,C|E|A,frt));for(var T=u.length;T--;)FA(g,u[T]);return g});function Est(a,u){return g6(a,pg(vt(u)))}var xst=Uo(function(a,u){return a==null?{}:Gnt(a,u)});function g6(a,u){if(a==null)return{};var g=Ce(WA(a),function(x){return[x]});return u=vt(u),sL(a,g,function(x,T){return u(x,T[0])})}function Ast(a,u,g){u=ws(u,a);var x=-1,T=u.length;for(T||(T=1,a=e);++x<T;){var w=a==null?e:a[Vi(u[x])];w===e&&(x=T,w=g),a=No(w)?w.call(a):w}return a}function bst(a,u,g){return a==null?a:xd(a,u,g)}function vst(a,u,g,x){return x=typeof x=="function"?x:e,a==null?a:xd(a,u,g,x)}var p6=wL(nn),C6=wL(Wn);function Bst(a,u,g){var x=Dt(a),T=x||Ls(a)||zc(a);if(u=vt(u,4),g==null){var w=a&&a.constructor;T?g=x?new w:[]:ke(a)?g=No(w)?Pi(Ni(a)):{}:g={}}return(T?$n:Fi)(a,function(O,P,V){return u(g,O,P,V)}),g}function Tst(a,u){return a==null?!0:FA(a,u)}function yst(a,u,g){return a==null?a:fL(a,u,$A(g))}function kst(a,u,g,x){return x=typeof x=="function"?x:e,a==null?a:fL(a,u,$A(g),x)}function Gc(a){return a==null?[]:Bs(a,nn(a))}function Rst(a){return a==null?[]:Bs(a,Wn(a))}function wst(a,u,g){return g===e&&(g=u,u=e),g!==e&&(g=wr(g),g=g===g?g:0),u!==e&&(u=wr(u),u=u===u?u:0),Zl(wr(a),u,g)}function Sst(a,u,g){return u=Po(u),g===e?(g=u,u=0):g=Po(g),a=wr(a),Unt(a,u,g)}function Lst(a,u,g){if(g&&typeof g!="boolean"&&In(a,u,g)&&(u=g=e),g===e&&(typeof u=="boolean"?(g=u,u=e):typeof a=="boolean"&&(g=a,a=e)),a===e&&u===e?(a=0,u=1):(a=Po(a),u===e?(u=a,a=0):u=Po(u)),a>u){var x=a;a=u,u=x}if(g||a%1||u%1){var T=$();return _(a+T*(u-a+Dm("1e-"+((T+"").length-1))),u)}return OA(a,u)}var Ist=Hc(function(a,u,g){return u=u.toLowerCase(),a+(g?E6(u):u)});function E6(a){return cb(ee(a).toLowerCase())}function x6(a){return a=ee(a),a&&a.replace(Wx,Fm).replace(lA,"")}function Dst(a,u,g){a=ee(a),u=lr(u);var x=a.length;g=g===e?x:Zl(Ut(g),0,x);var T=g;return g-=u.length,g>=0&&a.slice(g,T)==u}function _st(a){return a=ee(a),a&&Dx.test(a)?a.replace(vm,ad):a}function Mst(a){return a=ee(a),a&&Px.test(a)?a.replace(Ff,"\\$&"):a}var Ust=Hc(function(a,u,g){return a+(g?"-":"")+u.toLowerCase()}),Ost=Hc(function(a,u,g){return a+(g?" ":"")+u.toLowerCase()}),Nst=vL("toLowerCase");function Pst(a,u,g){a=ee(a),u=Ut(u);var x=u?Ts(a):0;if(!u||x>=u)return a;var T=(u-x)/2;return lg(Xl(T),g)+a+lg(ql(T),g)}function Fst(a,u,g){a=ee(a),u=Ut(u);var x=u?Ts(a):0;return u&&x<u?a+lg(u-x,g):a}function Kst(a,u,g){a=ee(a),u=Ut(u);var x=u?Ts(a):0;return u&&x<u?lg(u-x,g)+a:a}function Vst(a,u,g){return g||u==null?u=0:u&&(u=+u),H(ee(a).replace(Kf,""),u||0)}function $st(a,u,g){return(g?In(a,u,g):u===e)?u=1:u=Ut(u),NA(ee(a),u)}function Hst(){var a=arguments,u=ee(a[0]);return a.length<3?u:u.replace(a[1],a[2])}var jst=Hc(function(a,u,g){return a+(g?"_":"")+u.toLowerCase()});function zst(a,u,g){return g&&typeof g!="number"&&In(a,u,g)&&(u=g=e),g=g===e?Ar:g>>>0,g?(a=ee(a),a&&(typeof u=="string"||u!=null&&!sb(u))&&(u=lr(u),!u&&vo(a))?Ss(sr(a),0,g):a.split(u,g)):[]}var Gst=Hc(function(a,u,g){return a+(g?" ":"")+cb(u)});function Wst(a,u,g){return a=ee(a),g=g==null?0:Zl(Ut(g),0,a.length),u=lr(u),a.slice(g,g+u.length)==u}function qst(a,u,g){var x=k.templateSettings;g&&In(a,u,g)&&(u=e),a=ee(a),u=xg({},u,x,SL);var T=xg({},u.imports,x.imports,SL),w=nn(T),O=Bs(T,w),P,V,Q=0,Y=u.interpolate||Bc,tt="__p += '",ht=Vc((u.escape||Bc).source+"|"+Y.source+"|"+(Y===Bm?Hx:Bc).source+"|"+(u.evaluate||Bc).source+"|$","g"),Et="//# sourceURL="+(Wt.call(u,"sourceURL")?(u.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++dA+"]")+`
|
|
625
|
+
`)}function Art(a){return _t(a)||ra(a)||!!(Wm&&a&&a[Wm])}function Oo(a,u){var g=typeof a;return u=u==null?mn:u,!!u&&(g=="number"||g!="symbol"&&Gx.test(a))&&a>-1&&a%1==0&&a<u}function In(a,u,g){if(!ke(g))return!1;var x=typeof u;return(x=="number"?Gn(g)&&Oo(u,g.length):x=="string"&&u in g)?oi(g[u],a):!1}function YA(a,u){if(_t(a))return!1;var g=typeof a;return g=="number"||g=="symbol"||g=="boolean"||a==null||ar(a)?!0:Ox.test(a)||!Ux.test(a)||u!=null&&a in Qt(u)}function brt(a){var u=typeof a;return u=="string"||u=="number"||u=="symbol"||u=="boolean"?a!=="__proto__":a===null}function JA(a){var u=cg(a),g=k[u];if(typeof g!="function"||!(u in Vt.prototype))return!1;if(a===g)return!0;var x=qA(g);return!!x&&a===x[0]}function vrt(a){return!!fd&&fd in a}var Brt=Vl?No:gb;function bd(a){var u=a&&a.constructor,g=typeof u=="function"&&u.prototype||ko;return a===g}function UL(a){return a===a&&!ke(a)}function OL(a,u){return function(g){return g==null?!1:g[a]===u&&(u!==e||a in Qt(g))}}function Trt(a){var u=gg(a,function(x){return g.size===d&&g.clear(),x}),g=u.cache;return u}function yrt(a,u){var g=a[1],x=u[1],T=g|x,w=T<(L|M|at),O=x==at&&g==F||x==at&&g==xt&&a[7].length<=u[8]||x==(at|xt)&&u[7].length<=u[8]&&g==F;if(!(w||O))return a;x&L&&(a[2]=u[2],T|=g&L?0:U);var P=u[3];if(P){var V=a[3];a[3]=V?EL(V,P,u[4]):P,a[4]=V?or(a[3],h):u[4]}return P=u[5],P&&(V=a[5],a[5]=V?xL(V,P,u[6]):P,a[6]=V?or(a[5],h):u[6]),P=u[7],P&&(a[7]=P),x&at&&(a[8]=a[8]==null?u[8]:_(a[8],u[8])),a[9]==null&&(a[9]=u[9]),a[0]=u[0],a[1]=T,a}function krt(a){var u=[];if(a!=null)for(var g in Qt(a))u.push(g);return u}function Rrt(a){return $l.call(a)}function NL(a,u,g){return u=S(u===e?a.length-1:u,0),function(){for(var x=arguments,T=-1,w=S(x.length-u,0),O=j(w);++T<w;)O[T]=x[u+T];T=-1;for(var P=j(u+1);++T<u;)P[T]=x[T];return P[u]=g(O),wn(a,this,P)}}function PL(a,u){return u.length<2?a:ta(a,kr(u,0,-1))}function wrt(a,u){for(var g=a.length,x=_(u.length,g),T=zn(a);x--;){var w=u[x];a[x]=Oo(w,g)?T[w]:e}return a}function ZA(a,u){if(!(u==="constructor"&&typeof a[u]=="function")&&u!="__proto__")return a[u]}var FL=VL(aL),vd=Qm||function(a,u){return Je.setTimeout(a,u)},tb=VL(Ynt);function KL(a,u,g){var x=u+"";return tb(a,xrt(x,Srt(prt(x),g)))}function VL(a){var u=0,g=0;return function(){var x=N(),T=kn-(x-g);if(g=x,T>0){if(++u>=te)return arguments[0]}else u=0;return a.apply(e,arguments)}}function fg(a,u){var g=-1,x=a.length,T=x-1;for(u=u===e?x:u;++g<u;){var w=OA(g,T),O=a[w];a[w]=a[g],a[g]=O}return a.length=u,a}var $L=Trt(function(a){var u=[];return a.charCodeAt(0)===46&&u.push(""),a.replace(Nx,function(g,x,T,w){u.push(T?w.replace(Sl,"$1"):x||g)}),u});function Vi(a){if(typeof a=="string"||ar(a))return a;var u=a+"";return u=="0"&&1/a==-Rn?"-0":u}function na(a){if(a!=null){try{return Ro.call(a)}catch{}try{return a+""}catch{}}return""}function Srt(a,u){return $n(kx,function(g){var x="_."+g[0];u&g[1]&&!Sc(a,x)&&a.push(x)}),a.sort()}function HL(a){if(a instanceof Vt)return a.clone();var u=new jn(a.__wrapped__,a.__chain__);return u.__actions__=zn(a.__actions__),u.__index__=a.__index__,u.__values__=a.__values__,u}function Lrt(a,u,g){(g?In(a,u,g):u===e)?u=1:u=S(Ut(u),0);var x=a==null?0:a.length;if(!x||u<1)return[];for(var T=0,w=0,O=j(ql(x/u));T<x;)O[w++]=kr(a,T,T+=u);return O}function Irt(a){for(var u=-1,g=a==null?0:a.length,x=0,T=[];++u<g;){var w=a[u];w&&(T[x++]=w)}return T}function Drt(){var a=arguments.length;if(!a)return[];for(var u=j(a-1),g=arguments[0],x=a;x--;)u[x-1]=arguments[x];return Oi(_t(g)?zn(g):[g],an(u,1))}var _rt=Pt(function(a,u){return Ne(a)?pd(a,an(u,1,Ne,!0)):[]}),Mrt=Pt(function(a,u){var g=Rr(u);return Ne(g)&&(g=e),Ne(a)?pd(a,an(u,1,Ne,!0),vt(g,2)):[]}),Urt=Pt(function(a,u){var g=Rr(u);return Ne(g)&&(g=e),Ne(a)?pd(a,an(u,1,Ne,!0),e,g):[]});function Ort(a,u,g){var x=a==null?0:a.length;return x?(u=g||u===e?1:Ut(u),kr(a,u<0?0:u,x)):[]}function Nrt(a,u,g){var x=a==null?0:a.length;return x?(u=g||u===e?1:Ut(u),u=x-u,kr(a,0,u<0?0:u)):[]}function Prt(a,u){return a&&a.length?rg(a,vt(u,3),!0,!0):[]}function Frt(a,u){return a&&a.length?rg(a,vt(u,3),!0):[]}function Krt(a,u,g,x){var T=a==null?0:a.length;return T?(g&&typeof g!="number"&&In(a,u,g)&&(g=0,x=T),Dnt(a,u,g,x)):[]}function jL(a,u,g){var x=a==null?0:a.length;if(!x)return-1;var T=g==null?0:Ut(g);return T<0&&(T=S(x+T,0)),_l(a,vt(u,3),T)}function zL(a,u,g){var x=a==null?0:a.length;if(!x)return-1;var T=x-1;return g!==e&&(T=Ut(g),T=g<0?S(x+T,0):_(T,x-1)),_l(a,vt(u,3),T,!0)}function GL(a){var u=a==null?0:a.length;return u?an(a,1):[]}function Vrt(a){var u=a==null?0:a.length;return u?an(a,Rn):[]}function $rt(a,u){var g=a==null?0:a.length;return g?(u=u===e?1:Ut(u),an(a,u)):[]}function Hrt(a){for(var u=-1,g=a==null?0:a.length,x={};++u<g;){var T=a[u];x[T[0]]=T[1]}return x}function WL(a){return a&&a.length?a[0]:e}function jrt(a,u,g){var x=a==null?0:a.length;if(!x)return-1;var T=g==null?0:Ut(g);return T<0&&(T=S(x+T,0)),Ao(a,u,T)}function zrt(a){var u=a==null?0:a.length;return u?kr(a,0,-1):[]}var Grt=Pt(function(a){var u=Ce(a,VA);return u.length&&u[0]===a[0]?IA(u):[]}),Wrt=Pt(function(a){var u=Rr(a),g=Ce(a,VA);return u===Rr(g)?u=e:g.pop(),g.length&&g[0]===a[0]?IA(g,vt(u,2)):[]}),qrt=Pt(function(a){var u=Rr(a),g=Ce(a,VA);return u=typeof u=="function"?u:e,u&&g.pop(),g.length&&g[0]===a[0]?IA(g,e,u):[]});function Xrt(a,u){return a==null?"":BA.call(a,u)}function Rr(a){var u=a==null?0:a.length;return u?a[u-1]:e}function Qrt(a,u,g){var x=a==null?0:a.length;if(!x)return-1;var T=x;return g!==e&&(T=Ut(g),T=T<0?S(x+T,0):_(T,x-1)),u===u?$m(a,u,T):_l(a,ei,T,!0)}function Yrt(a,u){return a&&a.length?iL(a,Ut(u)):e}var Jrt=Pt(qL);function qL(a,u){return a&&a.length&&u&&u.length?UA(a,u):a}function Zrt(a,u,g){return a&&a.length&&u&&u.length?UA(a,u,vt(g,2)):a}function tit(a,u,g){return a&&a.length&&u&&u.length?UA(a,u,e,g):a}var eit=Uo(function(a,u){var g=a==null?0:a.length,x=RA(a,u);return lL(a,Ce(u,function(T){return Oo(T,g)?+T:T}).sort(CL)),x});function nit(a,u){var g=[];if(!(a&&a.length))return g;var x=-1,T=[],w=a.length;for(u=vt(u,3);++x<w;){var O=a[x];u(O,x,a)&&(g.push(O),T.push(x))}return lL(a,T),g}function eb(a){return a==null?a:X.call(a)}function rit(a,u,g){var x=a==null?0:a.length;return x?(g&&typeof g!="number"&&In(a,u,g)?(u=0,g=x):(u=u==null?0:Ut(u),g=g===e?x:Ut(g)),kr(a,u,g)):[]}function iit(a,u){return ng(a,u)}function oit(a,u,g){return PA(a,u,vt(g,2))}function sit(a,u){var g=a==null?0:a.length;if(g){var x=ng(a,u);if(x<g&&oi(a[x],u))return x}return-1}function lit(a,u){return ng(a,u,!0)}function ait(a,u,g){return PA(a,u,vt(g,2),!0)}function cit(a,u){var g=a==null?0:a.length;if(g){var x=ng(a,u,!0)-1;if(oi(a[x],u))return x}return-1}function uit(a){return a&&a.length?cL(a):[]}function fit(a,u){return a&&a.length?cL(a,vt(u,2)):[]}function dit(a){var u=a==null?0:a.length;return u?kr(a,1,u):[]}function hit(a,u,g){return a&&a.length?(u=g||u===e?1:Ut(u),kr(a,0,u<0?0:u)):[]}function mit(a,u,g){var x=a==null?0:a.length;return x?(u=g||u===e?1:Ut(u),u=x-u,kr(a,u<0?0:u,x)):[]}function git(a,u){return a&&a.length?rg(a,vt(u,3),!1,!0):[]}function pit(a,u){return a&&a.length?rg(a,vt(u,3)):[]}var Cit=Pt(function(a){return Rs(an(a,1,Ne,!0))}),Eit=Pt(function(a){var u=Rr(a);return Ne(u)&&(u=e),Rs(an(a,1,Ne,!0),vt(u,2))}),xit=Pt(function(a){var u=Rr(a);return u=typeof u=="function"?u:e,Rs(an(a,1,Ne,!0),e,u)});function Ait(a){return a&&a.length?Rs(a):[]}function bit(a,u){return a&&a.length?Rs(a,vt(u,2)):[]}function vit(a,u){return u=typeof u=="function"?u:e,a&&a.length?Rs(a,e,u):[]}function nb(a){if(!(a&&a.length))return[];var u=0;return a=ti(a,function(g){if(Ne(g))return u=S(g.length,u),!0}),_c(u,function(g){return Ce(a,Ic(g))})}function XL(a,u){if(!(a&&a.length))return[];var g=nb(a);return u==null?g:Ce(g,function(x){return wn(u,e,x)})}var Bit=Pt(function(a,u){return Ne(a)?pd(a,u):[]}),Tit=Pt(function(a){return KA(ti(a,Ne))}),yit=Pt(function(a){var u=Rr(a);return Ne(u)&&(u=e),KA(ti(a,Ne),vt(u,2))}),kit=Pt(function(a){var u=Rr(a);return u=typeof u=="function"?u:e,KA(ti(a,Ne),e,u)}),Rit=Pt(nb);function wit(a,u){return hL(a||[],u||[],gd)}function Sit(a,u){return hL(a||[],u||[],xd)}var Lit=Pt(function(a){var u=a.length,g=u>1?a[u-1]:e;return g=typeof g=="function"?(a.pop(),g):e,XL(a,g)});function QL(a){var u=k(a);return u.__chain__=!0,u}function Iit(a,u){return u(a),a}function dg(a,u){return u(a)}var Dit=Uo(function(a){var u=a.length,g=u?a[0]:0,x=this.__wrapped__,T=function(w){return RA(w,a)};return u>1||this.__actions__.length||!(x instanceof Vt)||!Oo(g)?this.thru(T):(x=x.slice(g,+g+(u?1:0)),x.__actions__.push({func:dg,args:[T],thisArg:e}),new jn(x,this.__chain__).thru(function(w){return u&&!w.length&&w.push(e),w}))});function _it(){return QL(this)}function Mit(){return new jn(this.value(),this.__chain__)}function Uit(){this.__values__===e&&(this.__values__=u6(this.value()));var a=this.__index__>=this.__values__.length,u=a?e:this.__values__[this.__index__++];return{done:a,value:u}}function Oit(){return this}function Nit(a){for(var u,g=this;g instanceof ys;){var x=HL(g);x.__index__=0,x.__values__=e,u?T.__wrapped__=x:u=x;var T=x;g=g.__wrapped__}return T.__wrapped__=a,u}function Pit(){var a=this.__wrapped__;if(a instanceof Vt){var u=a;return this.__actions__.length&&(u=new Vt(this)),u=u.reverse(),u.__actions__.push({func:dg,args:[eb],thisArg:e}),new jn(u,this.__chain__)}return this.thru(eb)}function Fit(){return dL(this.__wrapped__,this.__actions__)}var Kit=ig(function(a,u,g){Wt.call(a,g)?++a[g]:_o(a,g,1)});function Vit(a,u,g){var x=_t(a)?Um:Int;return g&&In(a,u,g)&&(u=e),x(a,vt(u,3))}function $it(a,u){var g=_t(a)?ti:XS;return g(a,vt(u,3))}var Hit=BL(jL),jit=BL(zL);function zit(a,u){return an(hg(a,u),1)}function Git(a,u){return an(hg(a,u),Rn)}function Wit(a,u,g){return g=g===e?1:Ut(g),an(hg(a,u),g)}function YL(a,u){var g=_t(a)?$n:ks;return g(a,vt(u,3))}function JL(a,u){var g=_t(a)?AA:qS;return g(a,vt(u,3))}var qit=ig(function(a,u,g){Wt.call(a,g)?a[g].push(u):_o(a,g,[u])});function Xit(a,u,g,x){a=Gn(a)?a:Gc(a),g=g&&!x?Ut(g):0;var T=a.length;return g<0&&(g=S(T+g,0)),Eg(a)?g<=T&&a.indexOf(u,g)>-1:!!T&&Ao(a,u,g)>-1}var Qit=Pt(function(a,u,g){var x=-1,T=typeof u=="function",w=Gn(a)?j(a.length):[];return ks(a,function(O){w[++x]=T?wn(u,O,g):Cd(O,u,g)}),w}),Yit=ig(function(a,u,g){_o(a,g,u)});function hg(a,u){var g=_t(a)?Ce:eL;return g(a,vt(u,3))}function Jit(a,u,g,x){return a==null?[]:(_t(u)||(u=u==null?[]:[u]),g=x?e:g,_t(g)||(g=g==null?[]:[g]),oL(a,u,g))}var Zit=ig(function(a,u,g){a[g?0:1].push(u)},function(){return[[],[]]});function tot(a,u,g){var x=_t(a)?rd:Ml,T=arguments.length<3;return x(a,vt(u,4),g,T,ks)}function eot(a,u,g){var x=_t(a)?bA:Ml,T=arguments.length<3;return x(a,vt(u,4),g,T,qS)}function not(a,u){var g=_t(a)?ti:XS;return g(a,pg(vt(u,3)))}function rot(a){var u=_t(a)?jS:Xnt;return u(a)}function iot(a,u,g){(g?In(a,u,g):u===e)?u=1:u=Ut(u);var x=_t(a)?knt:Qnt;return x(a,u)}function oot(a){var u=_t(a)?Rnt:Jnt;return u(a)}function sot(a){if(a==null)return 0;if(Gn(a))return Eg(a)?Ts(a):a.length;var u=Cn(a);return u==gn||u==ye?a.size:_A(a).length}function lot(a,u,g){var x=_t(a)?id:Znt;return g&&In(a,u,g)&&(u=e),x(a,vt(u,3))}var aot=Pt(function(a,u){if(a==null)return[];var g=u.length;return g>1&&In(a,u[0],u[1])?u=[]:g>2&&In(u[0],u[1],u[2])&&(u=[u[0]]),oL(a,an(u,1),[])}),mg=Xm||function(){return Je.Date.now()};function cot(a,u){if(typeof u!="function")throw new Sn(s);return a=Ut(a),function(){if(--a<1)return u.apply(this,arguments)}}function ZL(a,u,g){return u=g?e:u,u=a&&u==null?a.length:u,Mo(a,at,e,e,e,e,u)}function t6(a,u){var g;if(typeof u!="function")throw new Sn(s);return a=Ut(a),function(){return--a>0&&(g=u.apply(this,arguments)),a<=1&&(u=e),g}}var rb=Pt(function(a,u,g){var x=L;if(g.length){var T=or(g,jc(rb));x|=W}return Mo(a,x,u,g,T)}),e6=Pt(function(a,u,g){var x=L|M;if(g.length){var T=or(g,jc(e6));x|=W}return Mo(u,x,a,g,T)});function n6(a,u,g){u=g?e:u;var x=Mo(a,F,e,e,e,e,e,u);return x.placeholder=n6.placeholder,x}function r6(a,u,g){u=g?e:u;var x=Mo(a,G,e,e,e,e,e,u);return x.placeholder=r6.placeholder,x}function i6(a,u,g){var x,T,w,O,P,V,Q=0,Y=!1,tt=!1,ht=!0;if(typeof a!="function")throw new Sn(s);u=wr(u)||0,ke(g)&&(Y=!!g.leading,tt="maxWait"in g,w=tt?S(wr(g.maxWait)||0,u):w,ht="trailing"in g?!!g.trailing:ht);function Et(Pe){var si=x,Fo=T;return x=T=e,Q=Pe,O=a.apply(Fo,si),O}function Tt(Pe){return Q=Pe,P=vd(jt,u),Y?Et(Pe):O}function Nt(Pe){var si=Pe-V,Fo=Pe-Q,B6=u-si;return tt?_(B6,w-Fo):B6}function yt(Pe){var si=Pe-V,Fo=Pe-Q;return V===e||si>=u||si<0||tt&&Fo>=w}function jt(){var Pe=mg();if(yt(Pe))return zt(Pe);P=vd(jt,Nt(Pe))}function zt(Pe){return P=e,ht&&x?Et(Pe):(x=T=e,O)}function cr(){P!==e&&mL(P),Q=0,x=V=T=P=e}function Dn(){return P===e?O:zt(mg())}function ur(){var Pe=mg(),si=yt(Pe);if(x=arguments,T=this,V=Pe,si){if(P===e)return Tt(V);if(tt)return mL(P),P=vd(jt,u),Et(V)}return P===e&&(P=vd(jt,u)),O}return ur.cancel=cr,ur.flush=Dn,ur}var uot=Pt(function(a,u){return WS(a,1,u)}),fot=Pt(function(a,u,g){return WS(a,wr(u)||0,g)});function dot(a){return Mo(a,Mt)}function gg(a,u){if(typeof a!="function"||u!=null&&typeof u!="function")throw new Sn(s);var g=function(){var x=arguments,T=u?u.apply(this,x):x[0],w=g.cache;if(w.has(T))return w.get(T);var O=a.apply(this,x);return g.cache=w.set(T,O)||w,O};return g.cache=new(gg.Cache||Do),g}gg.Cache=Do;function pg(a){if(typeof a!="function")throw new Sn(s);return function(){var u=arguments;switch(u.length){case 0:return!a.call(this);case 1:return!a.call(this,u[0]);case 2:return!a.call(this,u[0],u[1]);case 3:return!a.call(this,u[0],u[1],u[2])}return!a.apply(this,u)}}function hot(a){return t6(2,a)}var mot=trt(function(a,u){u=u.length==1&&_t(u[0])?Ce(u[0],pn(vt())):Ce(an(u,1),pn(vt()));var g=u.length;return Pt(function(x){for(var T=-1,w=_(x.length,g);++T<w;)x[T]=u[T].call(this,x[T]);return wn(a,this,x)})}),ib=Pt(function(a,u){var g=or(u,jc(ib));return Mo(a,W,e,u,g)}),o6=Pt(function(a,u){var g=or(u,jc(o6));return Mo(a,it,e,u,g)}),got=Uo(function(a,u){return Mo(a,xt,e,e,e,u)});function pot(a,u){if(typeof a!="function")throw new Sn(s);return u=u===e?u:Ut(u),Pt(a,u)}function Cot(a,u){if(typeof a!="function")throw new Sn(s);return u=u==null?0:S(Ut(u),0),Pt(function(g){var x=g[u],T=Ss(g,0,u);return x&&Oi(T,x),wn(a,this,T)})}function Eot(a,u,g){var x=!0,T=!0;if(typeof a!="function")throw new Sn(s);return ke(g)&&(x="leading"in g?!!g.leading:x,T="trailing"in g?!!g.trailing:T),i6(a,u,{leading:x,maxWait:u,trailing:T})}function xot(a){return ZL(a,1)}function Aot(a,u){return ib($A(u),a)}function bot(){if(!arguments.length)return[];var a=arguments[0];return _t(a)?a:[a]}function vot(a){return yr(a,A)}function Bot(a,u){return u=typeof u=="function"?u:e,yr(a,A,u)}function Tot(a){return yr(a,C|A)}function yot(a,u){return u=typeof u=="function"?u:e,yr(a,C|A,u)}function kot(a,u){return u==null||GS(a,u,nn(u))}function oi(a,u){return a===u||a!==a&&u!==u}var Rot=ag(LA),wot=ag(function(a,u){return a>=u}),ra=JS(function(){return arguments}())?JS:function(a){return De(a)&&Wt.call(a,"callee")&&!hd.call(a,"callee")},_t=j.isArray,Sot=Yf?pn(Yf):Nnt;function Gn(a){return a!=null&&Cg(a.length)&&!No(a)}function Ne(a){return De(a)&&Gn(a)}function Lot(a){return a===!0||a===!1||De(a)&&Ln(a)==po}var Ls=Ym||gb,Iot=Jf?pn(Jf):Pnt;function Dot(a){return De(a)&&a.nodeType===1&&!Bd(a)}function _ot(a){if(a==null)return!0;if(Gn(a)&&(_t(a)||typeof a=="string"||typeof a.splice=="function"||Ls(a)||zc(a)||ra(a)))return!a.length;var u=Cn(a);if(u==gn||u==ye)return!a.size;if(bd(a))return!_A(a).length;for(var g in a)if(Wt.call(a,g))return!1;return!0}function Mot(a,u){return Ed(a,u)}function Uot(a,u,g){g=typeof g=="function"?g:e;var x=g?g(a,u):e;return x===e?Ed(a,u,e,g):!!x}function ob(a){if(!De(a))return!1;var u=Ln(a);return u==Cs||u==_i||typeof a.message=="string"&&typeof a.name=="string"&&!Bd(a)}function Oot(a){return typeof a=="number"&&md(a)}function No(a){if(!ke(a))return!1;var u=Ln(a);return u==bc||u==pm||u==vl||u==Rx}function s6(a){return typeof a=="number"&&a==Ut(a)}function Cg(a){return typeof a=="number"&&a>-1&&a%1==0&&a<=mn}function ke(a){var u=typeof a;return a!=null&&(u=="object"||u=="function")}function De(a){return a!=null&&typeof a=="object"}var l6=Zf?pn(Zf):Knt;function Not(a,u){return a===u||DA(a,u,XA(u))}function Pot(a,u,g){return g=typeof g=="function"?g:e,DA(a,u,XA(u),g)}function Fot(a){return a6(a)&&a!=+a}function Kot(a){if(Brt(a))throw new wt(o);return ZS(a)}function Vot(a){return a===null}function $ot(a){return a==null}function a6(a){return typeof a=="number"||De(a)&&Ln(a)==Bl}function Bd(a){if(!De(a)||Ln(a)!=br)return!1;var u=Ni(a);if(u===null)return!0;var g=Wt.call(u,"constructor")&&u.constructor;return typeof g=="function"&&g instanceof g&&Ro.call(g)==dd}var sb=Mm?pn(Mm):Vnt;function Hot(a){return s6(a)&&a>=-mn&&a<=mn}var c6=td?pn(td):$nt;function Eg(a){return typeof a=="string"||!_t(a)&&De(a)&&Ln(a)==yl}function ar(a){return typeof a=="symbol"||De(a)&&Ln(a)==kl}var zc=ed?pn(ed):Hnt;function jot(a){return a===e}function zot(a){return De(a)&&Cn(a)==Rl}function Got(a){return De(a)&&Ln(a)==Am}var Wot=ag(MA),qot=ag(function(a,u){return a<=u});function u6(a){if(!a)return[];if(Gn(a))return Eg(a)?sr(a):zn(a);if(Wl&&a[Wl])return Nl(a[Wl]());var u=Cn(a),g=u==gn?Bo:u==ye?To:Gc;return g(a)}function Po(a){if(!a)return a===0?a:0;if(a=wr(a),a===Rn||a===-Rn){var u=a<0?-1:1;return u*Di}return a===a?a:0}function Ut(a){var u=Po(a),g=u%1;return u===u?g?u-g:u:0}function f6(a){return a?Zl(Ut(a),0,Ar):0}function wr(a){if(typeof a=="number")return a;if(ar(a))return go;if(ke(a)){var u=typeof a.valueOf=="function"?a.valueOf():a;a=ke(u)?u+"":u}if(typeof a!="string")return a===0?a:+a;a=bo(a);var g=km.test(a);return g||zx.test(a)?CA(a.slice(2),g?2:8):ym.test(a)?go:+a}function d6(a){return Ki(a,Wn(a))}function Xot(a){return a?Zl(Ut(a),-mn,mn):a===0?a:0}function ee(a){return a==null?"":lr(a)}var Qot=$c(function(a,u){if(bd(u)||Gn(u)){Ki(u,nn(u),a);return}for(var g in u)Wt.call(u,g)&&gd(a,g,u[g])}),h6=$c(function(a,u){Ki(u,Wn(u),a)}),xg=$c(function(a,u,g,x){Ki(u,Wn(u),a,x)}),Yot=$c(function(a,u,g,x){Ki(u,nn(u),a,x)}),Jot=Uo(RA);function Zot(a,u){var g=Pi(a);return u==null?g:zS(g,u)}var tst=Pt(function(a,u){a=Qt(a);var g=-1,x=u.length,T=x>2?u[2]:e;for(T&&In(u[0],u[1],T)&&(x=1);++g<x;)for(var w=u[g],O=Wn(w),P=-1,V=O.length;++P<V;){var Q=O[P],Y=a[Q];(Y===e||oi(Y,ko[Q])&&!Wt.call(a,Q))&&(a[Q]=w[Q])}return a}),est=Pt(function(a){return a.push(e,LL),wn(m6,e,a)});function nst(a,u){return od(a,vt(u,3),Fi)}function rst(a,u){return od(a,vt(u,3),SA)}function ist(a,u){return a==null?a:wA(a,vt(u,3),Wn)}function ost(a,u){return a==null?a:QS(a,vt(u,3),Wn)}function sst(a,u){return a&&Fi(a,vt(u,3))}function lst(a,u){return a&&SA(a,vt(u,3))}function ast(a){return a==null?[]:tg(a,nn(a))}function cst(a){return a==null?[]:tg(a,Wn(a))}function lb(a,u,g){var x=a==null?e:ta(a,u);return x===e?g:x}function ust(a,u){return a!=null&&_L(a,u,_nt)}function ab(a,u){return a!=null&&_L(a,u,Mnt)}var fst=yL(function(a,u,g){u!=null&&typeof u.toString!="function"&&(u=$l.call(u)),a[u]=g},ub(qn)),dst=yL(function(a,u,g){u!=null&&typeof u.toString!="function"&&(u=$l.call(u)),Wt.call(a,u)?a[u].push(g):a[u]=[g]},vt),hst=Pt(Cd);function nn(a){return Gn(a)?HS(a):_A(a)}function Wn(a){return Gn(a)?HS(a,!0):jnt(a)}function mst(a,u){var g={};return u=vt(u,3),Fi(a,function(x,T,w){_o(g,u(x,T,w),x)}),g}function gst(a,u){var g={};return u=vt(u,3),Fi(a,function(x,T,w){_o(g,T,u(x,T,w))}),g}var pst=$c(function(a,u,g){eg(a,u,g)}),m6=$c(function(a,u,g,x){eg(a,u,g,x)}),Cst=Uo(function(a,u){var g={};if(a==null)return g;var x=!1;u=Ce(u,function(w){return w=ws(w,a),x||(x=w.length>1),w}),Ki(a,WA(a),g),x&&(g=yr(g,C|E|A,frt));for(var T=u.length;T--;)FA(g,u[T]);return g});function Est(a,u){return g6(a,pg(vt(u)))}var xst=Uo(function(a,u){return a==null?{}:Gnt(a,u)});function g6(a,u){if(a==null)return{};var g=Ce(WA(a),function(x){return[x]});return u=vt(u),sL(a,g,function(x,T){return u(x,T[0])})}function Ast(a,u,g){u=ws(u,a);var x=-1,T=u.length;for(T||(T=1,a=e);++x<T;){var w=a==null?e:a[Vi(u[x])];w===e&&(x=T,w=g),a=No(w)?w.call(a):w}return a}function bst(a,u,g){return a==null?a:xd(a,u,g)}function vst(a,u,g,x){return x=typeof x=="function"?x:e,a==null?a:xd(a,u,g,x)}var p6=wL(nn),C6=wL(Wn);function Bst(a,u,g){var x=_t(a),T=x||Ls(a)||zc(a);if(u=vt(u,4),g==null){var w=a&&a.constructor;T?g=x?new w:[]:ke(a)?g=No(w)?Pi(Ni(a)):{}:g={}}return(T?$n:Fi)(a,function(O,P,V){return u(g,O,P,V)}),g}function Tst(a,u){return a==null?!0:FA(a,u)}function yst(a,u,g){return a==null?a:fL(a,u,$A(g))}function kst(a,u,g,x){return x=typeof x=="function"?x:e,a==null?a:fL(a,u,$A(g),x)}function Gc(a){return a==null?[]:Bs(a,nn(a))}function Rst(a){return a==null?[]:Bs(a,Wn(a))}function wst(a,u,g){return g===e&&(g=u,u=e),g!==e&&(g=wr(g),g=g===g?g:0),u!==e&&(u=wr(u),u=u===u?u:0),Zl(wr(a),u,g)}function Sst(a,u,g){return u=Po(u),g===e?(g=u,u=0):g=Po(g),a=wr(a),Unt(a,u,g)}function Lst(a,u,g){if(g&&typeof g!="boolean"&&In(a,u,g)&&(u=g=e),g===e&&(typeof u=="boolean"?(g=u,u=e):typeof a=="boolean"&&(g=a,a=e)),a===e&&u===e?(a=0,u=1):(a=Po(a),u===e?(u=a,a=0):u=Po(u)),a>u){var x=a;a=u,u=x}if(g||a%1||u%1){var T=$();return _(a+T*(u-a+Dm("1e-"+((T+"").length-1))),u)}return OA(a,u)}var Ist=Hc(function(a,u,g){return u=u.toLowerCase(),a+(g?E6(u):u)});function E6(a){return cb(ee(a).toLowerCase())}function x6(a){return a=ee(a),a&&a.replace(Wx,Fm).replace(lA,"")}function Dst(a,u,g){a=ee(a),u=lr(u);var x=a.length;g=g===e?x:Zl(Ut(g),0,x);var T=g;return g-=u.length,g>=0&&a.slice(g,T)==u}function _st(a){return a=ee(a),a&&Dx.test(a)?a.replace(vm,ad):a}function Mst(a){return a=ee(a),a&&Px.test(a)?a.replace(Ff,"\\$&"):a}var Ust=Hc(function(a,u,g){return a+(g?"-":"")+u.toLowerCase()}),Ost=Hc(function(a,u,g){return a+(g?" ":"")+u.toLowerCase()}),Nst=vL("toLowerCase");function Pst(a,u,g){a=ee(a),u=Ut(u);var x=u?Ts(a):0;if(!u||x>=u)return a;var T=(u-x)/2;return lg(Xl(T),g)+a+lg(ql(T),g)}function Fst(a,u,g){a=ee(a),u=Ut(u);var x=u?Ts(a):0;return u&&x<u?a+lg(u-x,g):a}function Kst(a,u,g){a=ee(a),u=Ut(u);var x=u?Ts(a):0;return u&&x<u?lg(u-x,g)+a:a}function Vst(a,u,g){return g||u==null?u=0:u&&(u=+u),H(ee(a).replace(Kf,""),u||0)}function $st(a,u,g){return(g?In(a,u,g):u===e)?u=1:u=Ut(u),NA(ee(a),u)}function Hst(){var a=arguments,u=ee(a[0]);return a.length<3?u:u.replace(a[1],a[2])}var jst=Hc(function(a,u,g){return a+(g?"_":"")+u.toLowerCase()});function zst(a,u,g){return g&&typeof g!="number"&&In(a,u,g)&&(u=g=e),g=g===e?Ar:g>>>0,g?(a=ee(a),a&&(typeof u=="string"||u!=null&&!sb(u))&&(u=lr(u),!u&&vo(a))?Ss(sr(a),0,g):a.split(u,g)):[]}var Gst=Hc(function(a,u,g){return a+(g?" ":"")+cb(u)});function Wst(a,u,g){return a=ee(a),g=g==null?0:Zl(Ut(g),0,a.length),u=lr(u),a.slice(g,g+u.length)==u}function qst(a,u,g){var x=k.templateSettings;g&&In(a,u,g)&&(u=e),a=ee(a),u=xg({},u,x,SL);var T=xg({},u.imports,x.imports,SL),w=nn(T),O=Bs(T,w),P,V,Q=0,Y=u.interpolate||Bc,tt="__p += '",ht=Vc((u.escape||Bc).source+"|"+Y.source+"|"+(Y===Bm?Hx:Bc).source+"|"+(u.evaluate||Bc).source+"|$","g"),Et="//# sourceURL="+(Wt.call(u,"sourceURL")?(u.sourceURL+"").replace(/\s/g," "):"lodash.templateSources["+ ++dA+"]")+`
|
|
626
626
|
`;a.replace(ht,function(yt,jt,zt,cr,Dn,ur){return zt||(zt=cr),tt+=a.slice(Q,ur).replace(qx,Km),jt&&(P=!0,tt+=`' +
|
|
627
627
|
__e(`+jt+`) +
|
|
628
628
|
'`),Dn&&(V=!0,tt+=`';
|
|
@@ -639,7 +639,7 @@ __p += '`),zt&&(tt+=`' +
|
|
|
639
639
|
function print() { __p += __j.call(arguments, '') }
|
|
640
640
|
`:`;
|
|
641
641
|
`)+tt+`return __p
|
|
642
|
-
}`;var Nt=b6(function(){return Gt(w,Et+"return "+tt).apply(e,O)});if(Nt.source=tt,ob(Nt))throw Nt;return Nt}function Xst(a){return ee(a).toLowerCase()}function Qst(a){return ee(a).toUpperCase()}function Yst(a,u,g){if(a=ee(a),a&&(g||u===e))return bo(a);if(!a||!(u=lr(u)))return a;var x=sr(a),T=sr(u),w=Ol(x,T),O=ld(x,T)+1;return Ss(x,w,O).join("")}function Jst(a,u,g){if(a=ee(a),a&&(g||u===e))return a.slice(0,Nc(a)+1);if(!a||!(u=lr(u)))return a;var x=sr(a),T=ld(x,sr(u))+1;return Ss(x,0,T).join("")}function Zst(a,u,g){if(a=ee(a),a&&(g||u===e))return a.replace(Kf,"");if(!a||!(u=lr(u)))return a;var x=sr(a),T=Ol(x,sr(u));return Ss(x,T).join("")}function tlt(a,u){var g=Bt,x=le;if(ke(u)){var T="separator"in u?u.separator:T;g="length"in u?Ut(u.length):g,x="omission"in u?lr(u.omission):x}a=ee(a);var w=a.length;if(vo(a)){var O=sr(a);w=O.length}if(g>=w)return a;var P=g-Ts(x);if(P<1)return x;var V=O?Ss(O,0,P).join(""):a.slice(0,P);if(T===e)return V+x;if(O&&(P+=V.length-P),sb(T)){if(a.slice(P).search(T)){var Q,Y=V;for(T.global||(T=Vc(T.source,ee(vc.exec(T))+"g")),T.lastIndex=0;Q=T.exec(Y);)var tt=Q.index;V=V.slice(0,tt===e?P:tt)}}else if(a.indexOf(lr(T),P)!=P){var ht=V.lastIndexOf(T);ht>-1&&(V=V.slice(0,ht))}return V+x}function elt(a){return a=ee(a),a&&Ix.test(a)?a.replace(bm,Pc):a}var nlt=Hc(function(a,u,g){return a+(g?" ":"")+u.toUpperCase()}),cb=vL("toUpperCase");function A6(a,u,g){return a=ee(a),u=g?e:u,u===e?Mc(a)?Hm(a):ir(a):a.match(u)||[]}var b6=Pt(function(a,u){try{return wn(a,e,u)}catch(g){return ob(g)?g:new wt(g)}}),rlt=Uo(function(a,u){return $n(u,function(g){g=Vi(g),_o(a,g,rb(a[g],a))}),a});function ilt(a){var u=a==null?0:a.length,g=vt();return a=u?Ce(a,function(x){if(typeof x[1]!="function")throw new Sn(s);return[g(x[0]),x[1]]}):[],Pt(function(x){for(var T=-1;++T<u;){var w=a[T];if(wn(w[0],this,x))return wn(w[1],this,x)}})}function olt(a){return Lnt(yr(a,C))}function ub(a){return function(){return a}}function slt(a,u){return a==null||a!==a?u:a}var llt=TL(),alt=TL(!0);function qn(a){return a}function fb(a){return tL(typeof a=="function"?a:yr(a,C))}function clt(a){return nL(yr(a,C))}function ult(a,u){return rL(a,yr(u,C))}var flt=Pt(function(a,u){return function(g){return Cd(g,a,u)}}),dlt=Pt(function(a,u){return function(g){return Cd(a,g,u)}});function db(a,u,g){var x=nn(u),T=tg(u,x);g==null&&!(ke(u)&&(T.length||!x.length))&&(g=u,u=a,a=this,T=tg(u,nn(u)));var w=!(ke(g)&&"chain"in g)||!!g.chain,O=No(a);return $n(T,function(P){var V=u[P];a[P]=V,O&&(a.prototype[P]=function(){var Q=this.__chain__;if(w||Q){var Y=a(this.__wrapped__),tt=Y.__actions__=zn(this.__actions__);return tt.push({func:V,args:arguments,thisArg:a}),Y.__chain__=Q,Y}return V.apply(a,Oi([this.value()],arguments))})}),a}function hlt(){return Je._===this&&(Je._=zm),this}function hb(){}function mlt(a){return a=Ut(a),Pt(function(u){return iL(u,a)})}var glt=jA(Ce),plt=jA(Um),Clt=jA(id);function v6(a){return YA(a)?Ic(Vi(a)):Wnt(a)}function Elt(a){return function(u){return a==null?e:ta(a,u)}}var xlt=kL(),Alt=kL(!0);function mb(){return[]}function gb(){return!1}function blt(){return{}}function vlt(){return""}function Blt(){return!0}function Tlt(a,u){if(a=Ut(a),a<1||a>mn)return[];var g=Ar,x=_(a,Ar);u=vt(u),a-=Ar;for(var T=_c(x,u);++g<a;)u(g);return T}function ylt(a){return Dt(a)?Ce(a,Vi):ar(a)?[a]:zn($L(ee(a)))}function klt(a){var u=++jm;return ee(a)+u}var Rlt=sg(function(a,u){return a+u},0),wlt=zA("ceil"),Slt=sg(function(a,u){return a/u},1),Llt=zA("floor");function Ilt(a){return a&&a.length?Zm(a,qn,LA):e}function Dlt(a,u){return a&&a.length?Zm(a,vt(u,2),LA):e}function _lt(a){return Lc(a,qn)}function Mlt(a,u){return Lc(a,vt(u,2))}function Ult(a){return a&&a.length?Zm(a,qn,MA):e}function Olt(a,u){return a&&a.length?Zm(a,vt(u,2),MA):e}var Nlt=sg(function(a,u){return a*u},1),Plt=zA("round"),Flt=sg(function(a,u){return a-u},0);function Klt(a){return a&&a.length?Dc(a,qn):0}function Vlt(a,u){return a&&a.length?Dc(a,vt(u,2)):0}return k.after=cot,k.ary=ZL,k.assign=Qot,k.assignIn=h6,k.assignInWith=xg,k.assignWith=Yot,k.at=Jot,k.before=t6,k.bind=rb,k.bindAll=rlt,k.bindKey=e6,k.castArray=bot,k.chain=QL,k.chunk=Lrt,k.compact=Irt,k.concat=Drt,k.cond=ilt,k.conforms=olt,k.constant=ub,k.countBy=Kit,k.create=Zot,k.curry=n6,k.curryRight=r6,k.debounce=i6,k.defaults=tst,k.defaultsDeep=est,k.defer=uot,k.delay=fot,k.difference=_rt,k.differenceBy=Mrt,k.differenceWith=Urt,k.drop=Ort,k.dropRight=Nrt,k.dropRightWhile=Prt,k.dropWhile=Frt,k.fill=Krt,k.filter=$it,k.flatMap=zit,k.flatMapDeep=Git,k.flatMapDepth=Wit,k.flatten=GL,k.flattenDeep=Vrt,k.flattenDepth=$rt,k.flip=dot,k.flow=llt,k.flowRight=alt,k.fromPairs=Hrt,k.functions=ast,k.functionsIn=cst,k.groupBy=qit,k.initial=zrt,k.intersection=Grt,k.intersectionBy=Wrt,k.intersectionWith=qrt,k.invert=fst,k.invertBy=dst,k.invokeMap=Qit,k.iteratee=fb,k.keyBy=Yit,k.keys=nn,k.keysIn=Wn,k.map=hg,k.mapKeys=mst,k.mapValues=gst,k.matches=clt,k.matchesProperty=ult,k.memoize=gg,k.merge=pst,k.mergeWith=m6,k.method=flt,k.methodOf=dlt,k.mixin=db,k.negate=pg,k.nthArg=mlt,k.omit=Cst,k.omitBy=Est,k.once=hot,k.orderBy=Jit,k.over=glt,k.overArgs=mot,k.overEvery=plt,k.overSome=Clt,k.partial=ib,k.partialRight=o6,k.partition=Zit,k.pick=xst,k.pickBy=g6,k.property=v6,k.propertyOf=Elt,k.pull=Jrt,k.pullAll=qL,k.pullAllBy=Zrt,k.pullAllWith=tit,k.pullAt=eit,k.range=xlt,k.rangeRight=Alt,k.rearg=got,k.reject=not,k.remove=nit,k.rest=pot,k.reverse=eb,k.sampleSize=iot,k.set=bst,k.setWith=vst,k.shuffle=oot,k.slice=rit,k.sortBy=aot,k.sortedUniq=uit,k.sortedUniqBy=fit,k.split=zst,k.spread=Cot,k.tail=dit,k.take=hit,k.takeRight=mit,k.takeRightWhile=git,k.takeWhile=pit,k.tap=Iit,k.throttle=Eot,k.thru=dg,k.toArray=u6,k.toPairs=p6,k.toPairsIn=C6,k.toPath=ylt,k.toPlainObject=d6,k.transform=Bst,k.unary=xot,k.union=Cit,k.unionBy=Eit,k.unionWith=xit,k.uniq=Ait,k.uniqBy=bit,k.uniqWith=vit,k.unset=Tst,k.unzip=nb,k.unzipWith=XL,k.update=yst,k.updateWith=kst,k.values=Gc,k.valuesIn=Rst,k.without=Bit,k.words=A6,k.wrap=Aot,k.xor=Tit,k.xorBy=yit,k.xorWith=kit,k.zip=Rit,k.zipObject=wit,k.zipObjectDeep=Sit,k.zipWith=Lit,k.entries=p6,k.entriesIn=C6,k.extend=h6,k.extendWith=xg,db(k,k),k.add=Rlt,k.attempt=b6,k.camelCase=Ist,k.capitalize=E6,k.ceil=wlt,k.clamp=wst,k.clone=vot,k.cloneDeep=Tot,k.cloneDeepWith=yot,k.cloneWith=Bot,k.conformsTo=kot,k.deburr=x6,k.defaultTo=slt,k.divide=Slt,k.endsWith=Dst,k.eq=oi,k.escape=_st,k.escapeRegExp=Mst,k.every=Vit,k.find=Hit,k.findIndex=jL,k.findKey=nst,k.findLast=jit,k.findLastIndex=zL,k.findLastKey=rst,k.floor=Llt,k.forEach=YL,k.forEachRight=JL,k.forIn=ist,k.forInRight=ost,k.forOwn=sst,k.forOwnRight=lst,k.get=lb,k.gt=Rot,k.gte=wot,k.has=ust,k.hasIn=ab,k.head=WL,k.identity=qn,k.includes=Xit,k.indexOf=jrt,k.inRange=Sst,k.invoke=hst,k.isArguments=ra,k.isArray=Dt,k.isArrayBuffer=Sot,k.isArrayLike=Gn,k.isArrayLikeObject=Ne,k.isBoolean=Lot,k.isBuffer=Ls,k.isDate=Iot,k.isElement=Dot,k.isEmpty=_ot,k.isEqual=Mot,k.isEqualWith=Uot,k.isError=ob,k.isFinite=Oot,k.isFunction=No,k.isInteger=s6,k.isLength=Cg,k.isMap=l6,k.isMatch=Not,k.isMatchWith=Pot,k.isNaN=Fot,k.isNative=Kot,k.isNil=$ot,k.isNull=Vot,k.isNumber=a6,k.isObject=ke,k.isObjectLike=De,k.isPlainObject=Bd,k.isRegExp=sb,k.isSafeInteger=Hot,k.isSet=c6,k.isString=Eg,k.isSymbol=ar,k.isTypedArray=zc,k.isUndefined=jot,k.isWeakMap=zot,k.isWeakSet=Got,k.join=Xrt,k.kebabCase=Ust,k.last=Rr,k.lastIndexOf=Qrt,k.lowerCase=Ost,k.lowerFirst=Nst,k.lt=Wot,k.lte=qot,k.max=Ilt,k.maxBy=Dlt,k.mean=_lt,k.meanBy=Mlt,k.min=Ult,k.minBy=Olt,k.stubArray=mb,k.stubFalse=gb,k.stubObject=blt,k.stubString=vlt,k.stubTrue=Blt,k.multiply=Nlt,k.nth=Yrt,k.noConflict=hlt,k.noop=hb,k.now=mg,k.pad=Pst,k.padEnd=Fst,k.padStart=Kst,k.parseInt=Vst,k.random=Lst,k.reduce=tot,k.reduceRight=eot,k.repeat=$st,k.replace=Hst,k.result=Ast,k.round=Plt,k.runInContext=K,k.sample=rot,k.size=sot,k.snakeCase=jst,k.some=lot,k.sortedIndex=iit,k.sortedIndexBy=oit,k.sortedIndexOf=sit,k.sortedLastIndex=lit,k.sortedLastIndexBy=ait,k.sortedLastIndexOf=cit,k.startCase=Gst,k.startsWith=Wst,k.subtract=Flt,k.sum=Klt,k.sumBy=Vlt,k.template=qst,k.times=Tlt,k.toFinite=Po,k.toInteger=Ut,k.toLength=f6,k.toLower=Xst,k.toNumber=wr,k.toSafeInteger=Xot,k.toString=ee,k.toUpper=Qst,k.trim=Yst,k.trimEnd=Jst,k.trimStart=Zst,k.truncate=tlt,k.unescape=elt,k.uniqueId=klt,k.upperCase=nlt,k.upperFirst=cb,k.each=YL,k.eachRight=JL,k.first=WL,db(k,function(){var a={};return Fi(k,function(u,g){Wt.call(k.prototype,g)||(a[g]=u)}),a}(),{chain:!1}),k.VERSION=r,$n(["bind","bindKey","curry","curryRight","partial","partialRight"],function(a){k[a].placeholder=k}),$n(["drop","take"],function(a,u){Vt.prototype[a]=function(g){g=g===e?1:S(Ut(g),0);var x=this.__filtered__&&!u?new Vt(this):this.clone();return x.__filtered__?x.__takeCount__=_(g,x.__takeCount__):x.__views__.push({size:_(g,Ar),type:a+(x.__dir__<0?"Right":"")}),x},Vt.prototype[a+"Right"]=function(g){return this.reverse()[a](g).reverse()}}),$n(["filter","map","takeWhile"],function(a,u){var g=u+1,x=g==be||g==Ii;Vt.prototype[a]=function(T){var w=this.clone();return w.__iteratees__.push({iteratee:vt(T,3),type:g}),w.__filtered__=w.__filtered__||x,w}}),$n(["head","last"],function(a,u){var g="take"+(u?"Right":"");Vt.prototype[a]=function(){return this[g](1).value()[0]}}),$n(["initial","tail"],function(a,u){var g="drop"+(u?"":"Right");Vt.prototype[a]=function(){return this.__filtered__?new Vt(this):this[g](1)}}),Vt.prototype.compact=function(){return this.filter(qn)},Vt.prototype.find=function(a){return this.filter(a).head()},Vt.prototype.findLast=function(a){return this.reverse().find(a)},Vt.prototype.invokeMap=Pt(function(a,u){return typeof a=="function"?new Vt(this):this.map(function(g){return Cd(g,a,u)})}),Vt.prototype.reject=function(a){return this.filter(pg(vt(a)))},Vt.prototype.slice=function(a,u){a=Ut(a);var g=this;return g.__filtered__&&(a>0||u<0)?new Vt(g):(a<0?g=g.takeRight(-a):a&&(g=g.drop(a)),u!==e&&(u=Ut(u),g=u<0?g.dropRight(-u):g.take(u-a)),g)},Vt.prototype.takeRightWhile=function(a){return this.reverse().takeWhile(a).reverse()},Vt.prototype.toArray=function(){return this.take(Ar)},Fi(Vt.prototype,function(a,u){var g=/^(?:filter|find|map|reject)|While$/.test(u),x=/^(?:head|last)$/.test(u),T=k[x?"take"+(u=="last"?"Right":""):u],w=x||/^find/.test(u);!T||(k.prototype[u]=function(){var O=this.__wrapped__,P=x?[1]:arguments,V=O instanceof Vt,Q=P[0],Y=V||Dt(O),tt=function(jt){var zt=T.apply(k,Oi([jt],P));return x&&ht?zt[0]:zt};Y&&g&&typeof Q=="function"&&Q.length!=1&&(V=Y=!1);var ht=this.__chain__,Et=!!this.__actions__.length,Tt=w&&!ht,Nt=V&&!Et;if(!w&&Y){O=Nt?O:new Vt(this);var yt=a.apply(O,P);return yt.__actions__.push({func:dg,args:[tt],thisArg:e}),new jn(yt,ht)}return Tt&&Nt?a.apply(this,P):(yt=this.thru(tt),Tt?x?yt.value()[0]:yt.value():yt)})}),$n(["pop","push","shift","sort","splice","unshift"],function(a){var u=Kl[a],g=/^(?:push|sort|unshift)$/.test(a)?"tap":"thru",x=/^(?:pop|shift)$/.test(a);k.prototype[a]=function(){var T=arguments;if(x&&!this.__chain__){var w=this.value();return u.apply(Dt(w)?w:[],T)}return this[g](function(O){return u.apply(Dt(O)?O:[],T)})}}),Fi(Vt.prototype,function(a,u){var g=k[u];if(g){var x=g.name+"";Wt.call(ln,x)||(ln[x]=[]),ln[x].push({name:u,func:g})}}),ln[og(e,M).name]=[{name:"wrapper",func:e}],Vt.prototype.clone=ent,Vt.prototype.reverse=nnt,Vt.prototype.value=rnt,k.prototype.at=Dit,k.prototype.chain=_it,k.prototype.commit=Mit,k.prototype.next=Uit,k.prototype.plant=Nit,k.prototype.reverse=Pit,k.prototype.toJSON=k.prototype.valueOf=k.prototype.value=Fit,k.prototype.first=k.prototype.head,Wl&&(k.prototype[Wl]=Oit),k},yo=Kc();xo?((xo.exports=yo)._=yo,Qf._=yo):Je._=yo}).call(Mn)})(yn,yn.exports);function l$(n,t,e,r){l0(n,{className:"status-input",defaultValue:t,onChange:e,onKeyDown:r,maxLength:32})}const $k=["Blue","Grey","Yellow","Red","Green","Purple"];function a$(){const n=B("div",["status-color-palette"],null);for(const t of $k){const e=B("button",["status-box-button"],null);e.setAttribute("data-color",yn.exports.lowerCase(t)),e.setAttribute("title",D.t(`status.color.${yn.exports.lowerCase(t)}`)),n.appendChild(e)}return n}class c${constructor(){m(this,"root",a$());m(this,"changeColor",t=>{for(const r of Array.from(this.root.querySelectorAll(":scope > button")))r.classList.remove("selected");const e=this.root.querySelector(`button[data-color="${yn.exports.lowerCase(t)}"]`);e==null||e.classList.add("selected")})}}function Hk(n){var o;const t=$k[0],e=(o=n.settingsProvider.getItem(`statusBox.lastColor.${yn.exports.lowerCase(t)}`))!=null?o:D.t(`status.colorDefaultTitle.${yn.exports.lowerCase(t)}`);return{insert:" ",attributes:{id:Z(),type:"status",box:!0,title:e,subtle:!1,created:Date.now(),color:t}}}function u$(n,t){localStorage.setItem(`statusBox.lastColor.${yn.exports.lowerCase(t.color)}`,t.title)}function f$(n,t){var e;return(e=localStorage.getItem(`statusBox.lastColor.${yn.exports.lowerCase(t)}`))!=null?e:D.t(`status.colorDefaultTitle.${yn.exports.lowerCase(t)}`)}class d${constructor(t,e,r,i){m(this,"root");m(this,"ro");m(this,"mo");this.editor=t;const o=B("a",r,null,this.replaceTitleSpace(e));this.root=o,i.appendChild(o),this.observeResize(),this.observeRemoval()}replaceTitleSpace(t){return t.replace(/\s/g,"\xA0")}check(){return this.root.scrollWidth>this.root.offsetWidth}observeResize(){this.ro=new ResizeObserver(yn.exports.debounce(t=>{for(const e of t)if(this.check()){const r=this.root.textContent||"";e.target.setAttribute(`data-editor-tooltip-${this.editor.clientId}`,r)}else e.target.removeAttribute(`data-editor-tooltip-${this.editor.clientId}`)},200)),this.ro.observe(this.root)}handleContentChange(){if(this.check()){const t=this.root.textContent||"";this.root.setAttribute(`data-editor-tooltip-${this.editor.clientId}`,t)}else this.root.removeAttribute(`data-editor-tooltip-${this.editor.clientId}`)}observeRemoval(){this.mo=new MutationObserver(t=>{t.forEach(e=>{e.target===this.root&&e.type==="childList"&&this.handleContentChange(),e.removedNodes.forEach(r=>{r===this.root&&(this.unbindResizeObserver(),this.unbindMutationObserver())})})}),this.root.parentElement&&(this.mo.observe(this.root.parentElement,{childList:!0}),this.mo.observe(this.root,{childList:!0}))}unbindResizeObserver(){var t;(t=this.ro)==null||t.unobserve(this.root)}unbindMutationObserver(){var t;(t=this.mo)==null||t.disconnect()}rebind(t){this.unbindResizeObserver(),this.unbindMutationObserver(),this.root=t,this.observeResize(),this.observeRemoval()}changeTag(t,e){this.root.textContent=this.replaceTitleSpace(t),this.root.className=e.join(" ")}destroy(){this.unbindResizeObserver(),this.unbindMutationObserver()}}class ZC{static create(t,e,r,i){const{title:o,id:s}=r;if(this.tagRef.has(s)){const c=this.tagRef.get(s);return c==null||c.changeTag(o||D.t("status.empty"),e),i.appendChild(c==null?void 0:c.root),setTimeout(()=>{c==null||c.rebind(lu(t.getBoxById(s)).firstChild)}),c}const l=new d$(t,o,e,i);return this.tagRef.set(s,l),setTimeout(()=>{l.rebind(lu(t.getBoxById(s)).firstChild)}),l}static remove(t){const e=this.tagRef.get(t);this.tagRef.delete(t),e==null||e.destroy()}}m(ZC,"tagRef",new Map);const I0=I("StatusBoxEditor");class tE{constructor(t){m(this,"linkPopup",null);m(this,"boxElement");m(this,"statusPalette",new c$);m(this,"isEditing",!1);m(this,"editorStatus",t=>{if(!this.editor.isWritable())return;const e=this.editor.getBoxData(t);this.linkPopup=new Va(this.createPopupContent(e.title,e.color,e.subtle),{id:"status-box-popup"}),this.linkPopup.on("show",this.handleShow),this.linkPopup.on("close",this.handClose),this.linkPopup.manualShow(t,{theme:"light",placement:"bottom-start",offset:[5,5]}),this.boxElement=t});m(this,"handleShow",()=>{this.focus()});m(this,"handClose",()=>{var r;p(I0,this.boxElement,"boxElement not found");const t=this.editor.getBoxData(this.boxElement),e=et(this.boxElement);if(p(I0,e,"block not found"),t.title)u$(this.editor,t);else{const i=zo(e,this.boxElement);this.editor.deleteTextFromBlock(e,i.start,1),ZC.remove(t.id)}this.editor.focus(),(r=this.linkPopup)==null||r.destroy(),this.linkPopup=null,this.boxElement=void 0,this.isEditing=!1});m(this,"handleKeyDown",t=>{var e;t.key==="Enter"&&((e=this.linkPopup)==null||e.close(null))});m(this,"onColorChange",t=>{var o,s;if(!(t.target instanceof HTMLElement)||t.target.closest("[data-color]")===null)return;const e=yn.exports.upperCase(t.target.getAttribute("data-color"));p(I0,this.boxElement,"boxElement not found");const r=this.editor.getBoxData(this.boxElement);this.statusPalette.changeColor(e);const i={...r,color:e};if(!this.isEditing){const l=(s=(o=this.linkPopup)==null?void 0:o.popper)==null?void 0:s.querySelector("input"),c=f$(this.editor,e);l&&(l.value=c),i.title=c}this.editor.updateBoxData(i,{noFocus:!0}),this.focus()});m(this,"changeTitle",t=>{const e=t.target.value;p(I0,this.boxElement,"boxElement not found");const i={...this.editor.getBoxData(this.boxElement),title:e.trim()};this.editor.updateBoxData(i,{noFocus:!0}),this.isEditing=!0});this.editor=t,this.statusPalette.root.addEventListener("click",this.onColorChange)}focus(){setTimeout(()=>{var t,e,r,i,o,s;(r=(e=(t=this.linkPopup)==null?void 0:t.popper)==null?void 0:e.querySelector("input"))==null||r.focus(),(s=(o=(i=this.linkPopup)==null?void 0:i.popper)==null?void 0:o.querySelector("input"))==null||s.select()},100)}createPopupContent(t,e,r){const i=B("div",["status-box-editor-popup"],null);return l$(i,t,this.changeTitle,this.handleKeyDown),this.isEditing=!1,i.appendChild(this.statusPalette.root),this.statusPalette.changeColor(e),i}destroy(){var t;(t=this.linkPopup)==null||t.destroy()}}const kct="";function h$(n,t,e,r){const i=r,{title:o,subtle:s,color:l}=i,c=s?["box-status-common",`box-status-${yn.exports.lowerCase(l)}-subtle`]:["box-status-common",`box-status-${yn.exports.lowerCase(l)}`];o||c.push("box-status-empty"),ZC.create(n,c,r,e),n.addCustom("status-box",d=>new tE(d))}function m$(n,t){return{abstract:D.t("status.command.name")}}function g$(n,t){n.getCustom("status-box").editorStatus(t)}function p$(n,t){const{title:e}=t;return e!=null?e:""}async function C$(n,t){const{title:e}=t;return[{insert:e!=null?e:""}]}const jk={boxType:"status",updateBoxContent:h$,getBoxProperties:m$,handleClickBox:g$,convertTo:p$,toStandardText:C$},E$=I("status-box-command");class nc{static get commands(){return[{id:this.id,name:D.t("status.command.name"),icon:dy,order:650,group:"common",subText:"/status"}]}static insertStatus(t,e,r){var c;const i=t.getBlockByIndex(e,r),o=Hk(t),{start:s}=t.selection.range;p(E$,Or(s),"invalid block position"),t.insertBoxToBlock(i,s.offset,o.attributes);const l=t.getBoxById((c=o.attributes)==null?void 0:c.id);t.addCustom("status-box",d=>new tE(d)).editorStatus(l)}static insertEmptyBlockStatus(t,e,r){var l;let i=t.getBlockByIndex(e,r);(!i||!ie(t,i))&&(i=t.insertTextBlock([],e,r));const o=Hk(t);t.setBlockText(i,[o]);const s=t.getBoxById((l=o.attributes)==null?void 0:l.id);return t.addCustom("status-box",c=>new tE(c)).editorStatus(s),i}}m(nc,"id","insert-status");const x$={"en-US":{status:{empty:"\u8BBE\u7F6E\u72B6\u6001",command:{name:"\u72B6\u6001"},color:{red:"\u7EA2\u8272",yellow:"\u9EC4\u8272",green:"\u7EFF\u8272",blue:"\u84DD\u8272",purple:"\u7D2B\u8272",grey:"\u7070\u8272"},colorDefaultTitle:{red:"\u5DF2\u5EF6\u671F",yellow:"\u8FDB\u884C\u4E2D",green:"\u5DF2\u5B8C\u6210",blue:"\u672A\u5F00\u59CB",purple:"\u5DF2\u53D6\u6D88",grey:"\u6682\u505C"}}},"zh-CN":{status:{empty:"\u8BBE\u7F6E\u72B6\u6001",command:{name:"\u72B6\u6001"},color:{red:"\u7EA2\u8272",yellow:"\u9EC4\u8272",green:"\u7EFF\u8272",blue:"\u84DD\u8272",purple:"\u7D2B\u8272",grey:"\u7070\u8272"},colorDefaultTitle:{red:"\u5DF2\u5EF6\u671F",yellow:"\u8FDB\u884C\u4E2D",green:"\u5DF2\u5B8C\u6210",blue:"\u672A\u5F00\u59CB",purple:"\u5DF2\u53D6\u6D88",grey:"\u6682\u505C"}}},"ja-JP":{status:{empty:"\u8BBE\u7F6E\u72B6\u6001",command:{name:"\u72B6\u6001"},color:{red:"\u7EA2\u8272",yellow:"\u9EC4\u8272",green:"\u7EFF\u8272",blue:"\u84DD\u8272",purple:"\u7D2B\u8272",grey:"\u7070\u8272"},colorDefaultTitle:{red:"\u5DF2\u5EF6\u671F",yellow:"\u8FDB\u884C\u4E2D",green:"\u5DF2\u5B8C\u6210",blue:"\u672A\u5F00\u59CB",purple:"\u5DF2\u53D6\u6D88",grey:"\u6682\u505C"}}}};D.mergeLang(x$);const dl=I("inline-box-items");function A$(n,t,e){return n.undoManager.runInGroup(()=>{var s;let r=n.findBlockByIndex(t,e);(!r||!ie(n,r))&&(r=n.insertTextBlock([],t,e));const i=Fk();n.setBlockText(r,[i]);const o=(s=i.attributes)==null?void 0:s.id;return p(dl,o,"mathjax box id is empty"),setTimeout(()=>{const l=n.getBoxById(o);L0(n,l)},100),r})}function b$(n,t,e){let r=n.findBlockByIndex(t,e),i="bottom-start";return(!r||!ie(n,r))&&(i="top-start",r=n.insertTextBlock([],t,e)),Qu(n,{target:r,linkText:"",linkUrl:"",onFinished:(l,c)=>{n.undoManager.runInGroup(()=>{try{p(dl,r,"block not found"),ie(n,r)||(r=n.insertTextBlock([],t,e));const d=gr(l,{link:c}),h=gr(" ",null),C=[d,h];n.insertTextToBlock(r,0,C),n.selection.selectBlock(r,un(C)),n.focus()}catch(d){dl.error(d)}})},onClose:()=>{n.focus()},placement:i}),r}function v$(n,t,e){return n.undoManager.runInGroup(()=>{var l;const r=n.getBlockByIndex(t,e),i=n.selection.range;p(dl,Or(i.start),"invalid block position");const o=Fk();n.insertBoxToBlock(r,i.start.offset,o.attributes);const s=(l=o.attributes)==null?void 0:l.id;return p(dl,s,"mathjax box id is empty"),setTimeout(()=>{const c=n.getBoxById(s);L0(n,c)},100),r})}function B$(n,t,e){const r=n.getBlockByIndex(t,e),i=n.selection.range;p(dl,Or(i.start),"invalid block position");const o=qi(n,r,i);if(o.length===0)return;const s=o[0],l=Yi(n,r,"quick-menu-inline-link",s);Qu(n,{target:l,linkText:"",linkUrl:"",onFinished:(h,C)=>{n.undoManager.runInGroup(()=>{try{const E=n.getBlockText(r),A=to(E,i.start.offset,h,{link:C});n.setBlockText(r,A),n.selection.selectBlock(r,i.start.offset+h.length),n.focus()}catch(E){dl.error(E)}})},onClose:()=>{n.focus()},placement:"bottom-start"})}class zk{getCommands(){return[{id:"insert-math",name:D.t("quickMenu.inlineBox.math"),icon:ST,order:900,group:"common",subText:Bn("insert-math")},{id:"insert-link",name:D.t("quickMenu.inlineBox.link"),icon:Jp,order:400,group:"common",subText:Bn("insert-link")},...nc.commands]}async handleUpdateBlockCore(t,e){switch(e.item.id){case"insert-math":return v$(t,e.containerId,e.blockIndex);case"insert-link":return B$(t,e.containerId,e.blockIndex);case nc.id:return nc.insertStatus(t,e.containerId,e.blockIndex);default:return null}}async handleInsertEmptyBlockCore(t,e){switch(e.item.id){case"insert-math":return A$(t,e.containerId,e.blockIndex);case"insert-link":return b$(t,e.containerId,e.blockIndex);case nc.id:return nc.insertEmptyBlockStatus(t,e.containerId,e.blockIndex);default:return null}}async executeCommand(t,e,r){if(r.from==="quick-menu"){const i=t.getBlockById(r.blockId),o=t.getParentContainer(i),s=ft(o),l=t.getBlockIndex(i);t.undoManager.runInGroup(()=>this.handleUpdateBlockCore(t,{item:e,containerId:s,blockIndex:l}))}else r.from==="block-menu"&&t.undoManager.runInGroup(()=>this.handleInsertEmptyBlockCore(t,{item:e,containerId:r.containerId,blockIndex:r.blockIndex}));return null}}function T$(n,t={withPlainText:!1}){var o,s;const{withPlainText:e}=t,r=(s=(o=n.options.componentsOptions)==null?void 0:o.quickMenu)==null?void 0:s.commandProviders;if(!r)return[];const i=[];return[...r,new Dk(e),new zk].forEach(l=>{const c=l.getCommands(n);i.push(...c.map(d=>({...d,itemType:"insert-block",commandProvider:l})))}),i}function y$(n,t={withPlainText:!1}){const e=[];return n.editorBlocks.forEach(r=>{if(!r.getOptions)return;const i=r.getOptions(n);!i.insertBlockCommandItems||(i.insertBlockCommandItems.forEach(o=>{Ik(o,i)}),e.push(...i.insertBlockCommandItems))}),e.push(...T$(n,t)),e}function eE(n,t={withPlainText:!1}){const e=y$(n,t),r=new Map;e.forEach(s=>{var d;const l=(d=s.group)!=null?d:"";let c=r.get(l);c?c.items.push(s):(c={group:l,order:s.groupOrder||_k[l]||1e3,items:[s]},r.set(l,c))});const i=Array.from(r.values());i.sort((s,l)=>s.order-l.order),i.forEach(s=>{s.items.sort((l,c)=>{var d,h;return((d=l.order)!=null?d:0)-((h=c.order)!=null?h:0)})});const o=[];return i.forEach((s,l)=>{const c=`blockMenu.section.${s.group||"common"}`,d=D.t(c),h=d===c?s.group:d;o.push({id:`section-${l}`,name:h,type:"section",group:s.group,itemType:"insert-block"}),o.push(...s.items.map(C=>({...C})))}),o}function k$(n,t,e){const r=n.getFocusedBlock();if(!r)return;const i=n.getParentContainer(r),o=ft(i);let l=n.getBlockIndex(r);if(ie(n,r)||(l+=1),t.commandProvider){t.commandProvider.executeCommand(n,t,{from:"quick-menu",...e});return}!t.blockOptions||!t.blockOptions.handleInsertEmptyBlock||t.blockOptions.handleInsertEmptyBlock(n,{containerId:o,blockIndex:l,item:t})}const Gk=I("quick-menu"),R$={id:"quick-menu",trigger:["/"]},w$=5;class D0{constructor(t,e=R$){m(this,"suggest");m(this,"items");m(this,"maxHeading");m(this,"firstEmptyOffset",-1);m(this,"queryItems",async(t,e)=>{if(this.items.length===0?this.initMenuItems():this.refreshMenuItems(),e){const r=new Set,i=e.toLocaleLowerCase().replace(/^\s+|\s+$/g,""),o=this.items.filter(s=>{if(s.type==="section")return!0;if(s.name.toLocaleLowerCase().indexOf(i)!==-1||UP(s).toLocaleLowerCase().indexOf(i)!==-1)return r.add(s.group),!0;const l=`blockMenu.section.${s.group||"common"}`,c=D.t(l),d=c===l?s.group:c;return(d==null?void 0:d.toLocaleLowerCase().indexOf(i))!==-1?(r.add(s.group),!0):!1}).filter(s=>s.type==="section"?r.has(s.group):!0);return o.length?this.firstEmptyOffset=-1:this.handleEmptySearch(),o}return this.items});m(this,"onClose",()=>{this.firstEmptyOffset=-1});m(this,"onShow",(t,e,r,i)=>{const o=this.editor.getBlockByIndex(e,r);if(!dr(o)){const s=et(rt(o));if(s&&St(s)==="code")return!1}return!0});m(this,"onClickItem",(t,e)=>{const r=e;r.itemType==="insert-block"&&(p(Gk,r.blockOptions||r.commandProvider,"invalid quick item, no block options or command provider"),p(Gk,this.suggest.anchor,"invalid suggest, no anchor"),this.options.id==="empty-block-menu"&&this.editor.focus(),k$(this.editor,r,this.suggest.anchor))});this.editor=t,this.options=e,this.items=[],this.maxHeading=x0(),this.suggest=new cC(t,{id:e.id||"quick-menu",trigger:e.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 t=eE(this.editor);this.items=t}refreshMenuItems(){let t=null,e=0;const r=x0();if(r!==this.maxHeading){const i=new Dk,s=i.getCommands().map(l=>({...l,itemType:"insert-block",commandProvider:i}));for(let l=0;l<this.items.length;l++)this.items[l].group==="basics"&&(t||(t=l),t&&e++);t&&e&&this.items.splice(t,e,...s),this.maxHeading=r}}handleEmptySearch(){const t=this.editor.selection.getFocusedPos();if(this.firstEmptyOffset===-1){if(t.isSimple()){const{offset:e}=t;this.firstEmptyOffset=e-1}}else if(t.isSimple()){const{offset:e}=t;e-this.firstEmptyOffset>w$&&(this.suggest.close(),this.firstEmptyOffset=-1)}}}class _0{constructor(t){m(this,"instance");m(this,"mousedown",!1);m(this,"currentInstance",null);m(this,"attributeName",[]);m(this,"attributeDesc","");m(this,"_lastClickButtonId","");m(this,"observer",null);m(this,"observerCallback",null);m(this,"createContent",t=>{let e="",r=0;for(;r<this.attributeName.length&&!e;)t.hasAttribute(this.attributeName[r])&&(e=t.getAttribute(this.attributeName[r])||""),r++;const i=t.getAttribute(this.attributeDesc);if(!i)return e;const o=B("div",[],null);return B("span",[],o,e),i&&B("span",["editor-tooltip-desc"],o,i),o});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",t=>{this.currentInstance&&this.hide(),this.currentInstance=t,this.createObserver()});m(this,"handleHidden",()=>{this.destroyObserver(),this.currentInstance=null});m(this,"handleShow",t=>{var i;const e=t.reference;if(!e||!ne(document.body,e)||window.isDragging||this.mousedown)return!1;const r=Number.parseInt((i=e.getAttribute("data-tooltip-hide-at"))!=null?i:"",10);if(r&&Date.now()-r<1e3)return!1;if(this._lastClickButtonId===e.getAttribute("data-button-id"))return this._lastClickButtonId="",!1;if(this.attributeName.every(o=>!e.hasAttribute(o)))return!1;if(t.reference){const o={};if(t.reference.hasAttribute("data-editor-tooltip-placement")&&(o.placement=t.reference.getAttribute("data-editor-tooltip-placement")||"top"),t.reference.hasAttribute("data-editor-tooltip-offset-x")||t.reference.hasAttribute("data-editor-tooltip-offset-y")){const l=t.reference.getAttribute("data-editor-tooltip-offset-x"),c=t.reference.getAttribute("data-editor-tooltip-offset-y");o.offset=[l?Number.parseInt(l,10):0,c?Number.parseInt(c,10):0]}t.reference.hasAttribute("data-editor-tooltip-maxwidth")&&(o.maxWidth=Number.parseInt(t.reference.getAttribute("data-editor-tooltip-maxwidth")||"350",10)),t.reference.hasAttribute("data-editor-tooltip-allow-markdown")&&(o.allowHTML=!0);const s=document.body;if(o.appendTo=this.fixContainerForFullscreen(s),Object.keys(o).length&&t.setProps(o),t.reference.hasAttribute(`data-editor-tooltip-${this.editor.clientId}-dynamic`)){const l=t.reference.getAttribute(`data-editor-tooltip-${this.editor.clientId}-dynamic`);t.setContent(l||"")}}return!0});this.editor=t;const e=t.clientId;this.attributeName=[`data-editor-tooltip-${e}`,`data-editor-tooltip-${e}-dynamic`,"data-editor-tooltip-common"],this.attributeDesc=`data-editor-tooltip-desc-${e}`,this.instance=Ag.delegate(document.body,{theme:"editor-tooltip",maxWidth:400,delay:200,target:this.attributeName.map(r=>`[${r}]`).join(","),content:this.createContent,onShow:this.handleShow,onShown:this.handleShown,onHide:this.handleHidden,hideOnClick:!1}),t.domEvents.addEventListener(document,"mousedown",this.handleDocumentMouseDown)}set lastClickButtonId(t){this._lastClickButtonId=t,t&&setTimeout(()=>{this._lastClickButtonId===t&&(this._lastClickButtonId="")},500)}visible(){var t;return(t=this.currentInstance)==null?void 0:t.state.isVisible}hide(){var t;(t=this.currentInstance)!=null&&t.state.isVisible&&this.currentInstance.hide()}destroy(){this.destroyObserver(),this.instance.destroy(),this.editor.domEvents.removeEventListener(document,"mousedown",this.handleDocumentMouseDown),this.editor.domEvents.removeEventListener(document,"mouseup",this.handleDocumentMouseUp)}createObserver(){this.destroyObserver();const t=this.currentInstance;if(!t||!t.reference)return;this.observerCallback=Me.default(()=>{t.reference.closest("body")||(t.hide(),this.destroyObserver())},200),this.observer=new MutationObserver(this.observerCallback);const e=document.body,r={childList:!0,attributes:!1,subtree:!0};this.observer.observe(e,r)}destroyObserver(){this.observer&&(this.observer.disconnect(),this.observer=null),this.observerCallback&&(this.observerCallback.cancel(),this.observerCallback=null)}fixContainerForFullscreen(t){return t.closest("body")&&document.fullscreenElement&&!document.fullscreenElement.contains(t)?document.fullscreenElement:t}}const S$={"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",link:"link"};function L$(n,t){const e=new Set(Object.keys(S$)),r=t.filter(o=>e.has(o.id));return C0(r)}function Zu(n,t){if(!n.isWritable())return!1;const e=n.selection.range,r=n.editorCommandProviders.getCommands(e),o=L$(n,r).find(s=>s.id===`text/${t}`||s.id==="link");return o?(n.editorCommandProviders.executeCommand(e,o,{}),ec.get(n).update("selectionChange"),!0):!1}function I$(n,t){const e=n.selection.focusedBlock;if(!n.isWritable()||!nt(n,e))return!1;const r=n.getBlockData(e).heading,i={id:`heading-${t}`,source:"BlockTurnIntoCommandProvider",value:String(t)};return Number(r)===t&&(i.id="text",i.value=null),n.editorCommandProviders.executeCommand(n.selection.range,i,{}),!0}const nE={"CtrlOrCmd+B":n=>Zu(n,"style-bold"),"CtrlOrCmd+I":n=>Zu(n,"style-italic"),"CtrlOrCmd+U":n=>Zu(n,"style-underline"),"CtrlOrCmd+D":n=>Zu(n,"style-strikethrough"),"CtrlOrCmd+K":n=>Zu(n,"link"),...(()=>{const n={};for(let t=1;t<=8;t++)n[`CtrlOrCmd+${t}`]=e=>I$(e,t);return n})()},D$={quickMenu:{basic:{heading:{title:"\u6807\u9898 {heading}",space:"{markdown}\u7A7A\u683C"},unordered:"\u65E0\u5E8F\u5217\u8868",ordered:"\u6709\u5E8F\u5217\u8868",checkbox:"\u5F85\u529E\u5217\u8868",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"}},_$={quickMenu:{basic:{heading:{title:"Heading {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:"Heading {name}",headingGroup:"Text style",text:"Text"}},M$={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"}};D.mergeLang({"zh-CN":D$,"en-US":_$,"ja-JP":M$});const Ict="";function hl(n,...t){const e=Cr(...t);return e.classList.remove("editor-button"),e.classList.add("editor-text-button"),n.append(e),e}function Wk(n){const t=E0(n);t==null||t.hide();const e=n.findCustom("table-border-bar");e==null||e.closeToolbar()}function U$(n){return B("div",["insert-column-button","drop-marker"],n)}const O$=I("row-height");function qk(n){const t=It.fromTable(n),e=n.rows;p(O$,e.length===t.rowCount,"row count mismatch");const r=Array(t.rowCount).fill(0);for(let i=0;i<e.length;){let o=1,l=e[i].getBoundingClientRect().height,c=i+1;for(;c<e.length;){const d=e[c];if(d.cells.length!==0)break;o++,c++,l+=d.getBoundingClientRect().height}for(let d=0;d<o;d++)r[i+d]=l/o;i=c}return r}const N$=I("table-border-bar-dom");function Xk(n){var c;const t=et(n.contentElement);p(N$,t,"no block");const r=re(t).querySelector(".table-border-bar-container.left"),o=Ot(t).offsetLeft-za,s=((c=n.scrollOptions.paddingLeft)!=null?c:0)+o,l=Math.min(n.contentElement.offsetLeft-o,n.rootElement.scrollLeft-s);r&&(r.style.left=`${-l}px`)}const ss=I("table-border-bar-dom");function rc(n,t){p(ss,$e(t),"invalid table block");const e=Ve(t),r=vi(n,t),i=re(t),o=(C,E,A)=>{const v=B("div",["button-root",E],C),R=B("div",["button-container",E],v);v.setAttribute(`data-${E}-index`,`${A}`),R.setAttribute(`data-editor-tooltip-${n.clientId}`,E==="left"?D.t("table.insertRow"):D.t("table.insertCol")),B("span",["insert-indicator"],R),U$(R)},{selectedRows:s,selectedColumns:l}=fC(n,t),c=()=>{const C=r.querySelector(".table-border-bar-container.top");p(ss,C,"no top border bar container");const E=B("div",["table-border-bar-container","top"],null),A=B("div",["table-border-bar","top"],E),v=DF(e),L=It.fromTable(e).colCount;n.selection.range.isSimple()&&o(A,"top",0);for(let M=0;M<L;M++){const U=M===L-1?v[M]+2:v[M],F=B("span",["table-border-bar-cell","top"],A);l.has(M)&&F.classList.add("selected"),F.setAttribute("data-top-index",`${M}`),F.style.width=`${U}px`,n.selection.range.isSimple()&&o(A,"top",M+1)}tu(C,E)},d=()=>{const C=i.querySelector(".table-border-bar-container.left");p(ss,C,"no left border bar container");const E=B("div",["table-border-bar-container","left"],null),A=B("div",["table-border-bar","left"],E);B("span",["table-border-bar-cell","corner"],A);const v=qk(e);n.selection.range.isSimple()&&o(A,"left",0),Array.from(e.rows).forEach((R,L,M)=>{const U=B("span",["table-border-bar-cell","left"],A);s.has(L)&&U.classList.add("selected"),U.setAttribute("data-left-index",`${L}`);const F=L===M.length-1?v[L]+2:v[L];U.style.height=`${F}px`,n.selection.range.isSimple()&&o(A,"left",L+1)}),tu(C,E)};c(),d();const h=n.findCustom(bi(t));h&&Xk(h)}function Qk(n,t){const e=t.target;if(!(e instanceof Element))return;const r=et(e);p(ss,r&&$e(r),"invalid table block"),rc(n,r),n.selection.caret.update()}function M0(n,t){const e=t.target;if(!(e instanceof Element))return;const r=et(e);p(ss,r&&$e(r),"invalid table block");const i=e.closest(".button-root");if(i){if(i.classList.contains("top")){const o=parseInt(i.getAttribute("data-top-index")||"0",10);ek(n,r,o),rc(n,r)}else if(i.classList.contains("left")){const o=parseInt(i.getAttribute("data-left-index")||"0",10);wC(n,r,o),rc(n,r)}}}function U0(n,t){var s;Wk(n),t.preventDefault(),t.stopPropagation();let e=null,r,i;const o=l=>{var c;if(l.target instanceof HTMLElement&&r&&e&&i!==void 0){const d=et(l.target),h=l.target.closest(".table-border-bar");if(d===e&&h){const C=parseInt((c=l.target.getAttribute(`data-${r}-index`))!=null?c:"0",10),E=Math.min(i,C),A=Math.abs(i-C)+1;Rt(l.target,"top")&&r==="top"?GF(n,d,E,A,{reverse:!0}):Rt(l.target,"left")&&r==="left"&&WF(n,d,E,A,{reverse:!0})}}l.type==="mouseup"&&(e=null,i=void 0,r=void 0,document.body.removeEventListener("mousemove",o),document.body.removeEventListener("mouseup",o))};t.target instanceof HTMLElement&&Rt(t.target,"table-border-bar-cell")&&(e=et(t.target),Rt(t.target,"top")?r="top":Rt(t.target,"left")&&(r="left"),r&&e&&(i=parseInt((s=t.target.getAttribute(`data-${r}-index`))!=null?s:"0",10),document.body.addEventListener("mousemove",o),document.body.addEventListener("mouseup",o)))}function Yk(n){const t=n.selection.range,e=Vu(n,t);e&&rc(n,e)}function P$(n,t){p(ss,$e(t),"invalid table block");const e=vi(n,t),r=re(t),i=B("div",["table-border-bar-container","top"],e),o=B("div",["table-border-bar-container","left"],r);rc(n,t),n.domEvents.addEventListener(Ot(t),"scroll",Qk),n.domEvents.addEventListener(i,"click",M0),n.domEvents.addEventListener(o,"click",M0),n.domEvents.addEventListener(i,"mousedown",U0),n.domEvents.addEventListener(o,"mousedown",U0),n.addListener("afterClearSelection",Yk)}function Jk(n,t){if(!n.isWritable())return;if(vi(n,t).querySelector(".table-border-bar-container")){rc(n,t);return}P$(n,t)}function Zk(n,t){p(ss,$e(t),"invalid table block");const e=vi(n,t),r=re(t),i=e.querySelectorAll(".table-border-bar-container"),o=r.querySelectorAll(".table-border-bar-container");i.forEach(s=>{n.domEvents.removeEventListener(s,"click",M0),n.domEvents.removeEventListener(s,"mousedown",U0),s.remove()}),o.forEach(s=>{n.domEvents.removeEventListener(s,"click",M0),n.domEvents.removeEventListener(s,"mousedown",U0),s.remove()}),n.domEvents.removeEventListener(Ot(t),"scroll",Qk),n.addListener("afterClearSelection",Yk)}function F$(n,t){p(ss,$e(t),"invalid table block");const r=vi(n,t).querySelector(".table-border-bar-container.top");return r?r.getBoundingClientRect().height:0}class K${constructor(t,e){m(this,"toolbar");m(this,"handleSelectionChange",(t,e)=>{!t.isVisible||(e==="delete-columns"?(es(this.editor,this.tableBlock,!0,!0),ns(this.editor,this.tableBlock,!0,!0)):e==="delete-rows"?(es(this.editor,this.tableBlock,!0,!1),ns(this.editor,this.tableBlock,!0,!1)):(es(this.editor,this.tableBlock,!1),ns(this.editor,this.tableBlock,!1)))});m(this,"handleClick",(t,e,r)=>{e.id==="delete-columns"?dC(this.editor.selection.range):e.id==="delete-rows"&&hC(this.editor.selection.range)});m(this,"handleToolbarClose",()=>{this.tableBlock&&Vu(this.editor,this.editor.selection.range)===this.tableBlock&&(es(this.editor,this.tableBlock,!1),ns(this.editor,this.tableBlock,!1))});this.editor=t,this.tableBlock=e;const r=t.options.componentsOptions.popover;this.toolbar=new Pu([],void 0,{id:"table-row-column-toolbar",overflowBoundary:r==null?void 0:r.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 i,o,s;const{selectedColumns:t,selectedRows:e}=fC(this.editor,this.tableBlock);if(!this.editor.isWritable())return;if(t.size>0&&e.size>0){this.toolbar.close("cancelBar");return}if(t.size===0&&e.size===0){this.toolbar.close("cancelBar");return}const r=qi(this.editor,this.tableBlock,this.editor.selection.range)[0];if(!r){this.toolbar.close("cancelBar");return}if(t.size>0){const l={id:"delete-columns",name:D.t("table.deleteSelectCol"),icon:pT};this.toolbar.updateItems([l]);const c=Yi(this.editor,this.tableBlock,"table-row-column-delete",r);this.toolbar.manualShow(c,{placement:"top",offset:[0,5]})}else{const l={id:"delete-rows",name:D.t("table.deleteSelectRow"),icon:gT};this.toolbar.updateItems([l]);const h=re(this.tableBlock).querySelector(".table-border-bar-container.left").getBoundingClientRect(),C=new DOMRect(Math.max(h.left,r.left-za),r.top,za,r.height),E=Yi(this.editor,this.tableBlock,"table-row-column-delete",C);this.toolbar.manualShow(E,{placement:"left",offset:[0,5]});const A=this.editor.options.componentsOptions.popover;(i=this.toolbar.tippyInstance)==null||i.setProps({popperOptions:{modifiers:[{name:"flip",options:{boundary:A==null?void 0:A.overflowBoundary,fallbackPlacements:["left","right"]}}]}})}(s=(o=this.toolbar.tippyInstance)==null?void 0:o.popperInstance)==null||s.update()}destroy(){this.toolbar.destroy(),this.toolbar.removeAllListeners()}}const rE=I("table-border-bar");class V${constructor(t,e){m(this,"toolbar");m(this,"resizeObserver",null);m(this,"handleReadonlyChanged",t=>{t.isWritable()?this.update():Zk(this.editor,this.tableBlock)});m(this,"handleBlockUpdated",()=>{var t;(t=this.resizeObserver)==null||t.disconnect(),setTimeout(()=>{var r;const e=this.editor.getBlockById(st(this.tableBlock));(r=this.resizeObserver)==null||r.observe(Ve(e))})});m(this,"handleScroll",()=>{var t;(t=this.toolbar)==null||t.update()});m(this,"handleTableResize",()=>{!this.editor.isWritable()||this.update()});this.editor=t,this.tableBlock=e,p(rE,this.tableBlock,"no table block"),rE.debug("create table border bar"),Jk(this.editor,this.tableBlock),this.resizeObserver=new _s(this.handleTableResize),this.resizeObserver.observe(Ve(this.tableBlock));const r=t.getComponentOptions("table");r!=null&&r.hideToolbar||(this.toolbar=new K$(this.editor,this.tableBlock)),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}close(){var t;(t=this.toolbar)==null||t.close()}destroy(){var t,e;rE.debug("destroy table border bar"),(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=null,Zk(this.editor,this.tableBlock),(e=this.toolbar)==null||e.destroy(),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged)}update(){var t;Jk(this.editor,this.tableBlock),(t=this.toolbar)==null||t.update()}}const $$=I("table-border-bar");class H${constructor(t){m(this,"activeTableBar",null);m(this,"handleBlockDeleted",(t,e)=>{!this.activeTableBar||(e===this.activeTableBar.tableBlock||ne(e,this.activeTableBar.tableBlock))&&(this.activeTableBar.destroy(),this.activeTableBar=null)});m(this,"handleSelectionChanged",t=>{setTimeout(()=>{var i;const e=t.selection.range,r=Vu(t,e);((i=this.activeTableBar)==null?void 0:i.tableBlock)!==r&&this.activeTableBar&&this.hide(),r&&this.show(r)})});m(this,"handleScroll",()=>{var t;(t=this.activeTableBar)==null||t.handleScroll()});this.editor=t,this.editor.addListener("blockDeleted",this.handleBlockDeleted),this.editor.addListener("selectionChanged",this.handleSelectionChanged)}destroy(){this.editor.removeListener("blockDeleted",this.handleBlockDeleted),this.editor.removeListener("selectionChanged",this.handleSelectionChanged)}show(t){this.activeTableBar?(this.activeTableBar.tableBlock!==t&&this.hide(),this.activeTableBar.update()):this.activeTableBar=new V$(this.editor,t)}update(){var t;(t=this.activeTableBar)==null||t.handleBlockUpdated()}closeToolbar(){var t;(t=this.activeTableBar)==null||t.close()}hide(){!this.activeTableBar||(p($$,this.activeTableBar,"no active table bar"),this.activeTableBar.destroy(),this.activeTableBar=null)}}function tR(n,t){const e=n.addCustom("table-border-bar",r=>new H$(r));t==="update"&&e.update()}const Fn=I("table-cell-menu"),j$="style-bg-color-";class z${constructor(t){m(this,"activeTableBlock",null);m(this,"targetButton",null);m(this,"manualMenu",null);m(this,"colorPaletteItem",null);m(this,"handlePrevent",(t,e)=>{e.stopPropagation()});m(this,"handleReadonlyChanged",t=>{t.isWritable()||this.hide()});m(this,"handleSelectionChanged",t=>{const e=t.selection.range,r=Vu(t,e);if(this.hide(),this.activeTableBlock!==r&&(this.activeTableBlock=r),this.activeTableBlock){const i=It.fromBlock(this.activeTableBlock),o=e.isReverse()?e.start:e.end;let s=null;o instanceof Ur?t.getBlockById(o.blockId)===this.activeTableBlock?s=i.getCellByContainerId(o.childContainerId):s=this.getCellByChildBlockId(i,o.blockId):o.blockId!==this.activeTableBlock.id&&(s=this.getCellByChildBlockId(i,o.blockId)),s&&this.editor.isWritable()&&this.showCellMenuButton(s)}});m(this,"handleBeforePopupPalette",()=>{var e;const t=this.getSelectedBkgColorIndex();(e=this.colorPaletteItem)==null||e.palette.setColor("backgroundColor",t)});m(this,"createBkgColorItem",()=>{const t=B("div",["cell-background-color-item"],null);B("span",[],t,D.t("table.cellBackground"));const e=this.getSelectedBkgColorIndex();B("button",["item-button"],t).setAttribute("data-color-index",`${e}`);const i=B("span",["item-sub-indicator"],t);return i.innerHTML=Gp,t});m(this,"handleCommand",t=>{var i;p(Fn,this.activeTableBlock,"no target table block");const e=((i=t.states)==null?void 0:i.includes("checked"))||!1,r=t.value;switch(t.id){case"delete-select-row":hC(Oy(this.editor,this.activeTableBlock,!1));break;case"delete-select-col":dC(Oy(this.editor,this.activeTableBlock,!0));break;case"merge-cell":_y(this.editor.selection.range);break;case"split-cell":this.handleSplitCell();break;case"row-title":this.handleRowTitle(e);break;case"col-title":this.handleColTitle(e);break;case"stripe-style":this.handleStripeStyle(e);break;case"hide-border":nF(this.editor,this.activeTableBlock,r==="show-border");break;case"show-chart":oF(this.editor,this.activeTableBlock,r==="show-chart"),AC(this.editor,this.activeTableBlock,{updateNow:!0});break}});m(this,"handleToolbarClose",()=>{this.targetButton&&ot(this.targetButton,"active"),this.activeTableBlock&&Vu(this.editor,this.editor.selection.range)===this.activeTableBlock&&(es(this.editor,this.activeTableBlock,!1),ns(this.editor,this.activeTableBlock,!1)),this.editor.focus()});m(this,"handleSelectionChange",(t,e)=>{!t.isVisible||(p(Fn,this.activeTableBlock,"no target table block"),e==="cell-background-color"&&this.handleBeforePopupPalette(),e==="delete-select-row"?(es(this.editor,this.activeTableBlock,!0,!1),ns(this.editor,this.activeTableBlock,!0,!1)):e==="delete-select-col"?(es(this.editor,this.activeTableBlock,!0,!0),ns(this.editor,this.activeTableBlock,!0,!0)):(es(this.editor,this.activeTableBlock,!1),ns(this.editor,this.activeTableBlock,!1)))});m(this,"handleClick",(t,e)=>{var r;p(Fn,this.activeTableBlock,"no target table block"),p(Fn,this.targetButton,"no target button"),Wk(this.editor),Rt(this.targetButton,"active")?(ot(this.targetButton,"active"),(r=this.manualMenu)==null||r.close("clickItem")):(z(this.targetButton,"active"),this.manualMenu?this.manualMenu.updateItems(this.createCommandMenu()):(this.manualMenu=new Zo(this.createCommandMenu(),void 0,{id:"table-cell-menu"}),this.manualMenu.on("click",(i,o)=>{var s;this.handleCommand(o),(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"})),e.stopPropagation()});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChanged),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}destroy(){var t,e;this.activeTableBlock=null,this.targetButton=null,this.editor.removeListener("selectionChanged",this.handleSelectionChanged),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged),(t=this.manualMenu)==null||t.destroy(),(e=this.colorPaletteItem)==null||e.destroy()}hide(){var t;(t=this.manualMenu)==null||t.close("cancelBar"),this.targetButton&&(ot(this.targetButton,"active"),this.targetButton.style.display="none")}getCellByChildBlockId(t,e){let r=this.editor.getBlockById(e);for(;r;){const i=r.closest("td");p(Fn,i,"no parent cell");const o=et(i);if(p(Fn,o,"no parent block"),Ve(o)===t.table)return t.getCellByCellElement(i);r=o}return p(Fn,!1,"filed to get cell by child block id"),null}createTargetButton(t){this.targetButton?t.querySelector(`:scope > .${EC}`)||t.appendChild(this.targetButton):(this.targetButton=B("button",[EC],t),this.targetButton.innerHTML=Wh,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(t){this.createTargetButton(t.cell),p(Fn,this.targetButton,"no target button"),this.targetButton.style.display="inline-block"}handleSplitCell(){if(this.activeTableBlock){const t=It.fromBlock(this.activeTableBlock),e=this.editor.selection.range;if(e.isSimple()){const{col:r,row:i}=this.getCellByChildBlockId(t,e.start.blockId);gC(this.editor,this.activeTableBlock,{col:r,row:i})}else pC(this.editor.selection.range)}}getSelectedBkgColorIndex(){var s;p(Fn,this.activeTableBlock,"no target table block");const t=this.editor.selection.range,e=ts(this.editor,this.activeTableBlock,t.focus),r=this.editor.getBlockData(this.activeTableBlock),i=e.childContainerId,o=r[`${i}_background`];return o?Number.parseInt((s=o.substring(j$.length))!=null?s:"0",10):-1}createCommandMenu(){p(Fn,this.activeTableBlock,"no target table block");const t=this.editor.getBlockData(this.activeTableBlock),e=Dy(this.editor,this.activeTableBlock,this.editor.selection.range);let r=this.editor.selection.range;if(r.isSimple()){const h=ts(this.editor,this.activeTableBlock,r.start);r=qe(this.editor,{anchor:h,focus:h})}const i=Iy(this.editor,this.activeTableBlock,r),o=t.hasRowTitle,s=t.hasColTitle,l=t.isStripeStyle,c=t.noBorder,d=t.chart;return this.colorPaletteItem=new Ty("cell-background-color",{color:!1}),this.colorPaletteItem.palette.on("onClick",(h,C)=>{var E;switch(p(Fn,this.activeTableBlock,"no target table block"),h){case"clearColor":Fy(this.editor,this.activeTableBlock,-1);break;case"backgroundColor":Fy(this.editor,this.activeTableBlock,C);break}(E=this.manualMenu)==null||E.close("clickItem")}),[{id:"cell-background-color",name:D.t("table.cellBackground"),element:this.createBkgColorItem(),children:[this.colorPaletteItem]},{id:"separator",name:"",type:"separator"},{id:"merge-cell",name:D.t("table.mergeCell"),states:e?[]:["disabled"]},{id:"split-cell",name:D.t("table.splitCell"),states:i?[]:["disabled"]},{id:"separator",name:"",type:"separator"},{id:"delete-select-row",name:D.t("table.deleteSelectRow")},{id:"delete-select-col",name:D.t("table.deleteSelectCol")},{id:"separator",name:"",type:"separator"},{id:"table-config",name:D.t("table.tableConfigKey"),children:[{id:"row-title",name:D.t("table.tableConfig.rowTitle"),states:o?["checked"]:[]},{id:"col-title",name:D.t("table.tableConfig.colTitle"),states:s?["checked"]:[]},{id:"stripe-style",name:D.t("table.tableConfig.stripeStyle"),states:l?["checked"]:[]},{id:"hide-border",name:c?D.t("table.tableConfig.showBorder"):D.t("table.tableConfig.hideBorder"),value:c?"show-border":"hide-border"},{id:"show-chart",name:d?D.t("table.tableConfig.hideChart"):D.t("table.tableConfig.showChart"),value:d?"hide-chart":"show-chart"}]}]}handleRowTitle(t){p(Fn,this.activeTableBlock,"no target table block"),t?ZP(this.editor,this.activeTableBlock):JP(this.editor,this.activeTableBlock)}handleColTitle(t){p(Fn,this.activeTableBlock,"no target table block"),t?YP(this.editor,this.activeTableBlock):QP(this.editor,this.activeTableBlock)}handleStripeStyle(t){p(Fn,this.activeTableBlock,"no target table block"),t?eF(this.editor,this.activeTableBlock):tF(this.editor,this.activeTableBlock)}}function eR(n){n.addCustom("table-cell-menu",t=>new z$(t))}const O0=I("table-container");function iE(n){const t=n.closest("td");return p(O0,t,"no parent cell for a table cell container"),t}function nR(n){const t=Ve(n);return Array.from(t.querySelectorAll(':scope > tbody > tr > td > [data-type="editor-container"].child'))}function oE(n,t,e,r){const i=It.fromBlock(n),o=i.getCellByContainerId(ft(t));if(e==="ArrowDown"){const s=i.getBottomCell(o);return s?s.container:null}if(e==="ArrowUp"){const s=i.getTopCell(o);return s?s.container:null}if(e==="ArrowLeft"){const s=i.getAllContainers(),l=s.indexOf(t);if(p(O0,l>=0,"not a valid child container"),l===0)return null;const c=s[l-1];return r!=null&&r.noWrap&&i.getCellByContainerId(ft(c)).row!==o.row?null:c}if(e==="ArrowRight"){const s=i.getAllContainers(),l=s.indexOf(t);if(p(O0,l>=0,"not a valid child container"),l===s.length-1)return null;const c=s[l+1];return r!=null&&r.noWrap&&i.getCellByContainerId(ft(c)).row!==o.row?null:c}p(O0,!1,`invalid navigation type: ${e}`)}const G$=12,W$=90,N0=23,rR=2;class q${constructor(t){m(this,"scrollTableBlock",null);m(this,"autoScrollDir",null);m(this,"autoScrollTimer",null);m(this,"handleMouseDown",t=>{const e=document.elementFromPoint(t.clientX,t.clientY);if(e&&e instanceof HTMLElement){const r=et(e);if(r&&ne(this.editor.rootContainer,r)){const i=uo(r);i&&(this.scrollTableBlock=i,document.addEventListener("mousemove",this.handleAutoScroll))}}});m(this,"handleAutoScroll",t9.default(t=>{if(this.scrollTableBlock){const e=this.editor.getCustom(bi(this.scrollTableBlock)),r=e.rootElement,i=e.scrollOptions.parentContainer,o=r.getBoundingClientRect(),s=window.innerHeight-this.getBarFloatWindowBottom(e),l=i.getBoundingClientRect(),c=Math.min(l.bottom,s),d=Math.max(l.top,0);o.bottom>c&&t.clientY>=c?this.setAutoScroll("bottom"):o.top<d&&t.clientY<=d?this.setAutoScroll("top"):r.scrollLeft>0&&t.clientX<o.left?this.setAutoScroll("left"):r.scrollLeft<r.scrollWidth-r.offsetWidth&&t.clientX>o.right?this.setAutoScroll("right"):this.clearAutoScroll()}},15));m(this,"handleMouseUp",()=>{document.removeEventListener("mousemove",this.handleAutoScroll),setTimeout(()=>{this.scrollTableBlock=null})});m(this,"handleSelectionChanged",t=>{const e=t.selection.range;if(e.isCollapsed()&&e.isSimple()){const r=t.getBlockById(e.start.blockId),i=uo(r);if(i){const o=t.getCustom(bi(i)),s=o.rootElement.getBoundingClientRect(),l=_r(t,r,e.start);if(s.left>l.left){const c=e.start.offset===0?G$:rR;o.rootElement.scrollLeft-=s.left-l.left+c}else if(l.right>s.right){const c=e.start.offset===0?W$:rR;o.rootElement.scrollLeft+=l.right-s.right+c}}}else{const r=t.getBlockById(e.start.blockId),i=uo(r),o=t.getBlockById(e.end.blockId),s=uo(o);if(i&&i===s){const l=t.getCustom(bi(i)),c=l.rootElement.getBoundingClientRect();let d=null;if(e.isSimple())d=e.isReverse()?_r(t,r,e.start):_r(t,o,e.end);else{const h=iE(ui(t,e.start.childContainerId)),C=iE(ui(t,e.end.childContainerId));d=e.isReverse()?h.getBoundingClientRect():C.getBoundingClientRect()}c.left>d.left&&e.isReverse()?l.rootElement.scrollLeft-=c.left-d.left:c.right<d.right&&!e.isReverse()&&(l.rootElement.scrollLeft+=d.right-c.right)}}});m(this,"handleScroll",t=>{wy(t),this.editor.selection.caret.update()});m(this,"handleReset",t=>{wy(t),this.editor.selection.caret.update();const e=this.editor.findCustom("table-border-bar");e&&e.handleScroll(),Xk(t)});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChanged),document.addEventListener("mousedown",this.handleMouseDown),document.addEventListener("mouseup",this.handleMouseUp)}getBarFloatWindowBottom(t){return t.scrollOptions.barFloatWindowBottom?typeof t.scrollOptions.barFloatWindowBottom=="number"?t.scrollOptions.barFloatWindowBottom:t.scrollOptions.barFloatWindowBottom():0}clearAutoScroll(){this.autoScrollTimer&&(clearInterval(this.autoScrollTimer),this.autoScrollTimer=null,this.autoScrollDir=null)}setAutoScroll(t){this.autoScrollDir&&this.autoScrollDir!==t&&this.clearAutoScroll(),this.autoScrollTimer||(this.autoScrollDir=t,this.autoScrollTimer=window.setInterval(()=>{if(this.scrollTableBlock){const e=this.editor.getCustom(bi(this.scrollTableBlock)),r=e.rootElement,i=e.scrollOptions.parentContainer,o=r.getBoundingClientRect(),s=i===document.documentElement?window.innerHeight:i.offsetHeight,l=window.innerHeight-this.getBarFloatWindowBottom(e),c=i.getBoundingClientRect(),d=Math.min(c.bottom,l),h=Math.max(c.top,0);this.autoScrollDir==="left"&&(r.scrollLeft-=N0,r.scrollLeft<=0&&this.clearAutoScroll()),this.autoScrollDir==="right"&&(r.scrollLeft+=N0,r.scrollLeft>=r.scrollWidth-r.offsetWidth&&this.clearAutoScroll()),this.autoScrollDir==="bottom"&&(i.scrollTop+=N0,(i.scrollTop>=i.scrollHeight-s||o.bottom<=d)&&this.clearAutoScroll()),this.autoScrollDir==="top"&&(i.scrollTop-=N0,(i.scrollTop<=0||o.top>=h)&&this.clearAutoScroll())}},100))}destroy(){document.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mouseup",this.handleMouseUp),this.editor.removeListener("selectionChanged",this.handleSelectionChanged)}}function iR(n){return n.addCustom("table-scroll-events",t=>new q$(t))}const X$=I("table-doc-change-handler");class Q${constructor(t){this.editor=t,this.editor.addListener("docChanged",this.handleDocChanged)}handleDocChanged(t,e){if(!e){const{start:r,end:i}=t.selection.range;if(!t.findBlockById(r.blockId)||!t.findBlockById(i.blockId)){t.selection.selectBlock(t.getBlockByIndex("root",0),0);return}if(ma(r)){const o=t.getBlockById(r.blockId);if(!$e(o))return;if(p(X$,ma(i),"invalid range"),!jd(t,r.childContainerId)||!jd(t,i.childContainerId)){t.selection.selectBlock(o,0);return}let s=null,l=null;const c=(d,h)=>{const C=h.getCellById(d.childContainerId),{colIndex:E=0,rowIndex:A=0}=d.custom;let v=-1,R=-1;return(C.col>E||C.col+C.colSpan-1<E)&&(v=C.col),(C.row>A||C.row+C.rowSpan-1<A)&&(R=C.row),v!==-1||R!==-1?xe(o,d.childContainerId,{colIndex:v===-1?E:v,rowIndex:R===-1?A:R}):null};if(r.custom){const d=It.fromBlock(o);s=c(r,d),l=c(i,d)}(s!==null||l!==null)&&(t.selection.range.isReverse()?t.selection.setSelection(l!=null?l:i,s!=null?s:r):t.selection.setSelection(s!=null?s:r,l!=null?l:i))}}}destroy(){this.editor.removeListener("docChanged",this.handleDocChanged)}}function oR(n){n.addCustom("table-doc-change-handler",t=>new Q$(t))}const Bi=I("create-content");function sR(n,t,e){var C;const r=new a0(e),i=e.rows,o=e.cols;p(Bi,i>=1,`invalid rows: ${i}`),p(Bi,o>=1,`invalid cols: ${o}`),p(Bi,e.children,"no table children");const s=B("table",[],null),l=(C=e.colsWidth)!=null?C:new Array(e.cols).fill(0),c=B("colgroup",[],s);for(let E=0;E<r.colCount;E++){const A=B("col",[],c);l[E]&&(A.style.width=`${l[E]}px`)}const d=B("tbody",[],s);let h=0;for(let E=0;E<i;E++){const A=B("tr",[],d);for(let v=0;v<o;v++){const R=r.getCell({col:v,row:E});if(R.virtual)p(Bi,R.colSpan>1||R.rowSpan>1,"virtual cell should have colSpan or rowSpan");else{const L=e.children[h],M=B("td",[],A);R.colSpan>1&&(M.colSpan=R.colSpan),R.rowSpan>1&&(M.rowSpan=R.rowSpan);const U=e[ju(L)];U&&z(M,U),v===0&&e.hasColTitle&&z(M,My.COL_TITLE_ITEM),n.createChildContainer(t,M,L),h+=1}}}return p(Bi,h===e.children.length,"container count mismatch"),s.style.width=`${l.reduce((E,A)=>A+E,0)}px`,e.noBorder&&z(s,"no-border"),e.chart&&z(s,"editor-table-chart"),e.isStripeStyle&&z(s,"stripe"),e.hasRowTitle&&z(s,"row-title"),e.hasColTitle&&z(s,"col-title"),s}function Y$(n,t,e,r,i){p(Bi,i.type==="table","not table data"),p(Bi,ft(e)===t[t.length-1].containerId,"invalid path");const o=i,s=Hs(r,"div");try{const l=B("div",[],null);l.setAttribute("data-type","table-content");const c=sR(n,t,o);c.classList.add("drag-preview-element"),l.appendChild(c);const d=n.getComponentOptions("table");Zy(n),nk(n),tR(n,"create"),oR(n),d!=null&&d.hideCellMenu||eR(n),fT(n,bC);const h=n.addCustom(bi(r),()=>LF());h.init({parentElement:s,childElement:l,safeRightSpace:50,safeLeftSpace:40,parentContainer:Xt(e)?n.scrollContainer:e,locatingContainer:Xt(e)?(d==null?void 0:d.locatingContainer)||n.parent:e,paddingLeft:za+Hu,paddingTop:za+Hu,paddingBottom:Hu/2,paddingRight:Hu/2,barFloatWindowBottom:d==null?void 0:d.barFloatWindowBottom,allowScrollBarFixed:d==null?void 0:d.allowScrollBarFixed,isSetScale:d==null?void 0:d.isSetScale});const C=iR(n);h.on("scroll",C.handleReset),h.on("resize",C.handleReset),setTimeout(()=>{aF(n,r)})}catch{const c=`invalid table data: ${JSON.stringify(o)}`;Bi.error(c);const d=B("div",["error"],s);d.innerText=c}return s}function J$(n,t,e){p(Bi,e.type==="table","not table data");const r=e,i=Ot(t);try{const o=Ve(t),s=Vo(t),l=sR(n,s,r);l.classList.add("drag-preview-element"),o.insertAdjacentElement("afterend",l),o.remove();const c=n.getComponentOptions("table");Zy(n),nk(n),tR(n,"update"),oR(n),c!=null&&c.hideCellMenu||eR(n),bC(n,t)}catch{const s=`invalid table data: ${JSON.stringify(r)}`;Bi.error(s);const l=B("div",["error"],i);l.innerText=s}}function Z$(n,t){let e,r,i=!1;if([...t].every(E=>E==="|")?(r=t.length,e=Array(r).fill(""),i=!0):(e=Mg(t,"|").split("|"),r=e.length),r<2)return null;const o=3,s=r,l=[];for(let E=0;E<3;E++)e.forEach(A=>{l.push(no(n.doc,E===0?A:""))});const c=Array(s).fill(TC),d=l[i?0:s],h=n.doc.getContainerBlocks(d)[0].id;return{blockData:{id:Z(),type:"table",rows:o,cols:s,children:l,colsWidth:c},focusBlockId:h}}function tH(n,t){const e=t.rows,r=t.cols;if(e<1||r<1)return null;const i=[];for(let d=0;d<e;d++)for(let h=0;h<r;h++)i.push(no(n.doc));const o=Array(r).fill(TC),s=i[0],l=n.doc.getContainerBlocks(s)[0].id;return{blockData:{id:Z(),type:"table",rows:e,cols:r,children:i,colsWidth:o},focusBlockId:l}}const sE=I("get-selected-containers");function lR(n,t,e,r){p(sE,e.blockId===r.blockId,"only allow select in single table block"),p(sE,st(t)===e.blockId,"only allow select in single table block");const i=It.fromBlock(t),o=i.getCellByContainerId(e.childContainerId),s=i.getCellByContainerId(r.childContainerId);if(e.custom===void 0||r.custom===void 0)return i.getCells(o,s).map(L=>i.getCellContainer(L));const{fromCol:l,toCol:c,fromRow:d,toRow:h}=Gr(t,e,r),C=new Set,E=[];return i.sub({row:d,col:l},{row:h,col:c}).forEach(v=>{v.forEach(R=>{const L=i.getCellByContainerId(R.containerId);L.col<l||L.row<d||L.col+L.colSpan-1>c||L.row+L.rowSpan-1>h||C.has(R.containerId)||(C.add(R.containerId),E.push(L.container))})}),E}function eH(n,t,e){p(sE,t.blockId===e.blockId,"only allow select in single table block");const r=n.getBlockById(t.blockId);return lR(n,r,t,e)}const aR=I("table-selection-to-doc");function nH(n,t){const{start:e,end:r,block:i}=t,o=St(i);p(aR,o==="table",`invalid block type: ${o}`);const s=n.getBlockData(i);if(e.isSimple()&&r.isSimple())return qo(n.editorBlocks,n.doc.toJSON(),s);p(aR,!e.isSimple()&&!r.isSimple(),"invalid block pos type");const l=It.fromBlock(i),{fromCol:c,toCol:d,fromRow:h,toRow:C}=Gr(i,e,r),E={},A=[],v=n.doc.toJSON();let R={};l.sub({row:h,col:c},{row:C,col:d}).forEach((it,at)=>{it.forEach((xt,Mt)=>{const Bt=xt.containerId;if(A.indexOf(Bt)!==-1)return;A.push(Bt);let le;if(xt.virtual){const be=l.getCellByContainerId(xt.containerId),Kn=c+Mt;let Ii=be.col+be.colSpan-1;Ii>d&&(Ii=d);const Rn=Ii-Kn+1;Rn>1&&(E[`${Bt}_colSpan`]=Rn);const mn=h+at;let Di=be.row+be.rowSpan-1;Di>C&&(Di=C);const go=Di-mn+1;go>1&&(E[`${Bt}_rowSpan`]=go),le=eo()}else{if(le=np(n.editorBlocks,v,Bt),xt.col+xt.colSpan>d+1){const be=d-xt.col+1;be>1&&(E[`${Bt}_colSpan`]=be)}else xt.colSpan>1&&(E[`${Bt}_colSpan`]=xt.colSpan);if(xt.row+xt.rowSpan>C+1){const be=C-xt.row+1;be>1&&(E[`${Bt}_rowSpan`]=be)}else xt.rowSpan>1&&(E[`${Bt}_rowSpan`]=xt.rowSpan)}const{root:te,...kn}=le.blocks;R={...R,...kn,[Bt]:te}})});const M=Xu(Ve(i)).slice(c,d+1);return{blocks:{root:[{id:Z(),type:o,children:A,colsWidth:M,rows:C-h+1,cols:d-c+1,...E}],...R},meta:{},comments:{}}}const rH=I("ajust-selection-pos");function iH(n,t){if(t.top===0)return!0;for(let e=t.left;e<=t.right;e++)if(n[t.top-1][e]===n[t.top][e])return!1;return!0}function oH(n,t){if(t.left===0)return!0;for(let e=t.top;e<=t.bottom;e++)if(n[e][t.left-1]===n[e][t.left])return!1;return!0}function sH(n,t){if(t.bottom===n.length-1)return!0;for(let e=t.left;e<=t.right;e++)if(n[t.bottom][e]===n[t.bottom+1][e])return!1;return!0}function lH(n,t){if(t.right===n[0].length-1)return!0;for(let e=t.top;e<=t.bottom;e++)if(n[e][t.right]===n[e][t.right+1])return!1;return!0}function aH(n,t,e){const r=t.col,i=t.row,o=e.col,s=e.row,l={left:r,top:i,right:o,bottom:s};let c=!1;do{if(c=!1,!iH(n,l)){l.top--,c=!0;continue}if(!oH(n,l)){l.left--,c=!0;continue}if(!sH(n,l)){l.bottom++,c=!0;continue}if(!lH(n,l)){l.right++,c=!0;continue}}while(c);return l}function cH(n,t,e,r){if(e.custom!==void 0||r.custom!==void 0)return{anchor:e,focus:r};const i=It.fromBlock(t),o=i.map(F=>F.containerId),s=i.getCellByContainerId(e.childContainerId),l=i.getCellByContainerId(r.childContainerId),c=Math.min(s.row,l.row),d=Math.max(s.row,l.row),h=Math.min(s.col,l.col),C=Math.max(s.col,l.col),E=aH(o,{row:c,col:h},{row:d,col:C}),A=i.getCell({row:E.top,col:E.left}),v=i.getCell({row:E.bottom,col:E.right}),R=i.getCell({row:E.top,col:E.right}),L=i.getCell({row:E.bottom,col:E.left});let M,U;return s.row<=l.row?s.col<=l.col?(M=A,U=v):(M=R,U=L):s.col<l.col?(M=L,U=R):(M=v,U=A),rH.debug(`move ${M.col}, ${M.row}, -> ${U.col}, ${U.row}`),{anchor:xe(t,M.containerId),focus:xe(t,U.containerId)}}function cR(n,t,e){if(e.isSimple())return[Ve(t).getBoundingClientRect()];const r=Ve(t),i=r.getBoundingClientRect(),{fromCol:o,fromRow:s,toCol:l,toRow:c}=Gr(t,e.start,e.end),d=Xu(r),h=d.slice(0,o).reduce((R,L)=>R+L,0),C=h+d.slice(o,l+1).reduce((R,L)=>R+L,0),E=qk(r);let A=E.slice(0,s).reduce((R,L)=>R+L,0);const v=A+E.slice(s,c+1).reduce((R,L)=>R+L,0);if(s===0){const R=F$(n,t);A-=R}return[new DOMRect(i.left+h,i.top+A,C-h,v-A)]}I("table-size");const uH=40;function P0(n){const t=n.querySelector("td");if(!t)return 0;const e=window.getComputedStyle(t),r=Number.parseInt(e.borderLeft,10),i=Number.parseInt(e.borderRight,10);return(r+i)/2}function fH(n,t,e){const r=n1(n,e.container);return r!==void 0?r+P0(t):uH*e.colSpan-P0(t)}function dH(n,t,e,r){let i=0;const o=e.colCount;for(let s=0;s<o;s++){const l=e.getCell({col:s,row:r});if(l.virtual)continue;let c=fH(n,t,l);const d=Jv(l.container,{withPadding:!0});d&&d>c&&(c=d),i+=c+P0(t)}return i}function hH(n,t){const e=Ve(t),r=It.fromTable(e);let i=0;for(let s=0;s<r.rowCount;s++)i=Math.max(i,dH(n,e,r,s));const o=P0(e);return i+=o,i}const fo=I("table-creator");async function mH(n,t){return n.undoManager.runInGroup(()=>{var c,d;const e=t.item,r=(c=e.colCount)!=null?c:5,i=(d=e.rowCount)!=null?d:3,o=tH(n,{cols:r,rows:i});if(!o)return null;const{blockData:s,focusBlockId:l}=o;return n.insertBlock(t.containerId,t.blockIndex,s,Te(n,l,0))})}class gH{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",t=>{this.closeable=t});m(this,"destroy",()=>{this.closeable=null});m(this,"getTableCreatorCellId",(t,e)=>`table-creator-cell-${t}-${e}`);m(this,"handleTableCreatorClick",t=>{var E,A;t.preventDefault(),t.stopPropagation();const e=t.target;p(fo,e instanceof HTMLElement,"invalid event target");const r=e.closest(".table-creator");p(fo,r,"no table creator");const i=r.querySelectorAll(".active");if(i.length===0)return;const s=i[i.length-1].id;p(fo,s,"no cell id");const l="table-creator-cell-";if(!s.startsWith(l))return;const d=s.substring(l.length).split("-");p(fo,d.length===2,"invalid cell id");const h=Number.parseInt(d[0],10)+1,C=Number.parseInt(d[1],10)+1;fo.debug(`${h}, ${C}`),this.colCount=C,this.rowCount=h,(E=this.closeable)==null||E.click(this,this.element),(A=this.closeable)==null||A.close("clickItem"),this.handleTableCreatorLeave()});m(this,"handleTableCreatorLeave",()=>{for(let t=0;t<9;t++)for(let e=0;e<9;e++){const r=this.getTableCreatorCellId(t,e),i=document.getElementById(r);i&&ot(i,"active")}});m(this,"handleTableCreatorCellEnter",t=>{const e=t.target;p(fo,e instanceof HTMLElement,"invalid event target");const r=e.id,i="table-creator-cell-";p(fo,r.startsWith(i),"invalid cell id");const s=r.substring(i.length).split("-");p(fo,s.length===2,"invalid cell id");let l=Number.parseInt(s[0],10),c=Number.parseInt(s[1],10);l===0&&c===0&&(l=-1,c=-1);for(let d=0;d<9;d++)for(let h=0;h<9;h++){const C=this.getTableCreatorCellId(d,h),E=document.getElementById(C);p(fo,E,"no cell"),d<=l&&h<=c?z(E,"active"):ot(E,"active")}});this.element=this.createTableCreatorElement()}createTableCreatorElement(){const t=B("div",["table-creator"],null),e=(r,i,o)=>{const s=B("div",["table-creator-cell"],r);return s.id=this.getTableCreatorCellId(i,o),s};t.addEventListener("click",this.handleTableCreatorClick),t.addEventListener("mouseleave",this.handleTableCreatorLeave);for(let r=0;r<9;r++){const i=B("div",["table-creator-row"],t);for(let o=0;o<9;o++)e(i,r,o).addEventListener("mouseenter",this.handleTableCreatorCellEnter)}return t}}function pH(){return new gH}function CH(n){const t=/[\u4e00-\u9fff\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g,e=n.match(t);return e?e.length:0}function uR(n){const t=CH(n);return n.length+t}function EH(n,t,e=[]){let r=0;if(!e||e.length===0)return r;for(let i=n;i<n+t;i+=1)r+=e[i]||0;return r}function xH(n,t){const e=uR(n),r=t-e;return r>0?n+" ".repeat(r):n}function AH(n,t,e,r,i){var l;const o=t,s=new a0(o);if(r==="markdown"||r==="text"){const c=M=>e.blocks[M].map((G,W)=>r==="markdown"?Ah(n,G,e,[...i,{containerId:M,blockIndex:W}]):xh(n,G,e,[...i,{containerId:M,blockIndex:W}])),d=M=>c(M).join(" ").replace(/\n/g," ").trim(),h=new Map,C=new Map;for(let M=0;M<s.colCount;M++){let U=0;for(let F=0;F<s.rowCount;F++){const G=s.getCell({row:F,col:M});let W="";G.virtual||(W=d(G.containerId)),h.set(`${F},${M}`,W),U=Math.max(U,uR(W))}C.set(M,U)}const E=M=>{const U=h.get(`${M.row},${M.col}`)||"",F=C.get(M.col)||0;return xH(U,F)};if(r==="text"){const M=[];for(let U=0;U<s.colCount;U++){const F=E({row:0,col:U});M.push(F)}for(let U=1;U<s.rowCount;U++)for(let F=0;F<s.colCount;F++){const G=E({row:U,col:F});M.push(G)}return M.join(`
|
|
642
|
+
}`;var Nt=b6(function(){return Gt(w,Et+"return "+tt).apply(e,O)});if(Nt.source=tt,ob(Nt))throw Nt;return Nt}function Xst(a){return ee(a).toLowerCase()}function Qst(a){return ee(a).toUpperCase()}function Yst(a,u,g){if(a=ee(a),a&&(g||u===e))return bo(a);if(!a||!(u=lr(u)))return a;var x=sr(a),T=sr(u),w=Ol(x,T),O=ld(x,T)+1;return Ss(x,w,O).join("")}function Jst(a,u,g){if(a=ee(a),a&&(g||u===e))return a.slice(0,Nc(a)+1);if(!a||!(u=lr(u)))return a;var x=sr(a),T=ld(x,sr(u))+1;return Ss(x,0,T).join("")}function Zst(a,u,g){if(a=ee(a),a&&(g||u===e))return a.replace(Kf,"");if(!a||!(u=lr(u)))return a;var x=sr(a),T=Ol(x,sr(u));return Ss(x,T).join("")}function tlt(a,u){var g=Bt,x=le;if(ke(u)){var T="separator"in u?u.separator:T;g="length"in u?Ut(u.length):g,x="omission"in u?lr(u.omission):x}a=ee(a);var w=a.length;if(vo(a)){var O=sr(a);w=O.length}if(g>=w)return a;var P=g-Ts(x);if(P<1)return x;var V=O?Ss(O,0,P).join(""):a.slice(0,P);if(T===e)return V+x;if(O&&(P+=V.length-P),sb(T)){if(a.slice(P).search(T)){var Q,Y=V;for(T.global||(T=Vc(T.source,ee(vc.exec(T))+"g")),T.lastIndex=0;Q=T.exec(Y);)var tt=Q.index;V=V.slice(0,tt===e?P:tt)}}else if(a.indexOf(lr(T),P)!=P){var ht=V.lastIndexOf(T);ht>-1&&(V=V.slice(0,ht))}return V+x}function elt(a){return a=ee(a),a&&Ix.test(a)?a.replace(bm,Pc):a}var nlt=Hc(function(a,u,g){return a+(g?" ":"")+u.toUpperCase()}),cb=vL("toUpperCase");function A6(a,u,g){return a=ee(a),u=g?e:u,u===e?Mc(a)?Hm(a):ir(a):a.match(u)||[]}var b6=Pt(function(a,u){try{return wn(a,e,u)}catch(g){return ob(g)?g:new wt(g)}}),rlt=Uo(function(a,u){return $n(u,function(g){g=Vi(g),_o(a,g,rb(a[g],a))}),a});function ilt(a){var u=a==null?0:a.length,g=vt();return a=u?Ce(a,function(x){if(typeof x[1]!="function")throw new Sn(s);return[g(x[0]),x[1]]}):[],Pt(function(x){for(var T=-1;++T<u;){var w=a[T];if(wn(w[0],this,x))return wn(w[1],this,x)}})}function olt(a){return Lnt(yr(a,C))}function ub(a){return function(){return a}}function slt(a,u){return a==null||a!==a?u:a}var llt=TL(),alt=TL(!0);function qn(a){return a}function fb(a){return tL(typeof a=="function"?a:yr(a,C))}function clt(a){return nL(yr(a,C))}function ult(a,u){return rL(a,yr(u,C))}var flt=Pt(function(a,u){return function(g){return Cd(g,a,u)}}),dlt=Pt(function(a,u){return function(g){return Cd(a,g,u)}});function db(a,u,g){var x=nn(u),T=tg(u,x);g==null&&!(ke(u)&&(T.length||!x.length))&&(g=u,u=a,a=this,T=tg(u,nn(u)));var w=!(ke(g)&&"chain"in g)||!!g.chain,O=No(a);return $n(T,function(P){var V=u[P];a[P]=V,O&&(a.prototype[P]=function(){var Q=this.__chain__;if(w||Q){var Y=a(this.__wrapped__),tt=Y.__actions__=zn(this.__actions__);return tt.push({func:V,args:arguments,thisArg:a}),Y.__chain__=Q,Y}return V.apply(a,Oi([this.value()],arguments))})}),a}function hlt(){return Je._===this&&(Je._=zm),this}function hb(){}function mlt(a){return a=Ut(a),Pt(function(u){return iL(u,a)})}var glt=jA(Ce),plt=jA(Um),Clt=jA(id);function v6(a){return YA(a)?Ic(Vi(a)):Wnt(a)}function Elt(a){return function(u){return a==null?e:ta(a,u)}}var xlt=kL(),Alt=kL(!0);function mb(){return[]}function gb(){return!1}function blt(){return{}}function vlt(){return""}function Blt(){return!0}function Tlt(a,u){if(a=Ut(a),a<1||a>mn)return[];var g=Ar,x=_(a,Ar);u=vt(u),a-=Ar;for(var T=_c(x,u);++g<a;)u(g);return T}function ylt(a){return _t(a)?Ce(a,Vi):ar(a)?[a]:zn($L(ee(a)))}function klt(a){var u=++jm;return ee(a)+u}var Rlt=sg(function(a,u){return a+u},0),wlt=zA("ceil"),Slt=sg(function(a,u){return a/u},1),Llt=zA("floor");function Ilt(a){return a&&a.length?Zm(a,qn,LA):e}function Dlt(a,u){return a&&a.length?Zm(a,vt(u,2),LA):e}function _lt(a){return Lc(a,qn)}function Mlt(a,u){return Lc(a,vt(u,2))}function Ult(a){return a&&a.length?Zm(a,qn,MA):e}function Olt(a,u){return a&&a.length?Zm(a,vt(u,2),MA):e}var Nlt=sg(function(a,u){return a*u},1),Plt=zA("round"),Flt=sg(function(a,u){return a-u},0);function Klt(a){return a&&a.length?Dc(a,qn):0}function Vlt(a,u){return a&&a.length?Dc(a,vt(u,2)):0}return k.after=cot,k.ary=ZL,k.assign=Qot,k.assignIn=h6,k.assignInWith=xg,k.assignWith=Yot,k.at=Jot,k.before=t6,k.bind=rb,k.bindAll=rlt,k.bindKey=e6,k.castArray=bot,k.chain=QL,k.chunk=Lrt,k.compact=Irt,k.concat=Drt,k.cond=ilt,k.conforms=olt,k.constant=ub,k.countBy=Kit,k.create=Zot,k.curry=n6,k.curryRight=r6,k.debounce=i6,k.defaults=tst,k.defaultsDeep=est,k.defer=uot,k.delay=fot,k.difference=_rt,k.differenceBy=Mrt,k.differenceWith=Urt,k.drop=Ort,k.dropRight=Nrt,k.dropRightWhile=Prt,k.dropWhile=Frt,k.fill=Krt,k.filter=$it,k.flatMap=zit,k.flatMapDeep=Git,k.flatMapDepth=Wit,k.flatten=GL,k.flattenDeep=Vrt,k.flattenDepth=$rt,k.flip=dot,k.flow=llt,k.flowRight=alt,k.fromPairs=Hrt,k.functions=ast,k.functionsIn=cst,k.groupBy=qit,k.initial=zrt,k.intersection=Grt,k.intersectionBy=Wrt,k.intersectionWith=qrt,k.invert=fst,k.invertBy=dst,k.invokeMap=Qit,k.iteratee=fb,k.keyBy=Yit,k.keys=nn,k.keysIn=Wn,k.map=hg,k.mapKeys=mst,k.mapValues=gst,k.matches=clt,k.matchesProperty=ult,k.memoize=gg,k.merge=pst,k.mergeWith=m6,k.method=flt,k.methodOf=dlt,k.mixin=db,k.negate=pg,k.nthArg=mlt,k.omit=Cst,k.omitBy=Est,k.once=hot,k.orderBy=Jit,k.over=glt,k.overArgs=mot,k.overEvery=plt,k.overSome=Clt,k.partial=ib,k.partialRight=o6,k.partition=Zit,k.pick=xst,k.pickBy=g6,k.property=v6,k.propertyOf=Elt,k.pull=Jrt,k.pullAll=qL,k.pullAllBy=Zrt,k.pullAllWith=tit,k.pullAt=eit,k.range=xlt,k.rangeRight=Alt,k.rearg=got,k.reject=not,k.remove=nit,k.rest=pot,k.reverse=eb,k.sampleSize=iot,k.set=bst,k.setWith=vst,k.shuffle=oot,k.slice=rit,k.sortBy=aot,k.sortedUniq=uit,k.sortedUniqBy=fit,k.split=zst,k.spread=Cot,k.tail=dit,k.take=hit,k.takeRight=mit,k.takeRightWhile=git,k.takeWhile=pit,k.tap=Iit,k.throttle=Eot,k.thru=dg,k.toArray=u6,k.toPairs=p6,k.toPairsIn=C6,k.toPath=ylt,k.toPlainObject=d6,k.transform=Bst,k.unary=xot,k.union=Cit,k.unionBy=Eit,k.unionWith=xit,k.uniq=Ait,k.uniqBy=bit,k.uniqWith=vit,k.unset=Tst,k.unzip=nb,k.unzipWith=XL,k.update=yst,k.updateWith=kst,k.values=Gc,k.valuesIn=Rst,k.without=Bit,k.words=A6,k.wrap=Aot,k.xor=Tit,k.xorBy=yit,k.xorWith=kit,k.zip=Rit,k.zipObject=wit,k.zipObjectDeep=Sit,k.zipWith=Lit,k.entries=p6,k.entriesIn=C6,k.extend=h6,k.extendWith=xg,db(k,k),k.add=Rlt,k.attempt=b6,k.camelCase=Ist,k.capitalize=E6,k.ceil=wlt,k.clamp=wst,k.clone=vot,k.cloneDeep=Tot,k.cloneDeepWith=yot,k.cloneWith=Bot,k.conformsTo=kot,k.deburr=x6,k.defaultTo=slt,k.divide=Slt,k.endsWith=Dst,k.eq=oi,k.escape=_st,k.escapeRegExp=Mst,k.every=Vit,k.find=Hit,k.findIndex=jL,k.findKey=nst,k.findLast=jit,k.findLastIndex=zL,k.findLastKey=rst,k.floor=Llt,k.forEach=YL,k.forEachRight=JL,k.forIn=ist,k.forInRight=ost,k.forOwn=sst,k.forOwnRight=lst,k.get=lb,k.gt=Rot,k.gte=wot,k.has=ust,k.hasIn=ab,k.head=WL,k.identity=qn,k.includes=Xit,k.indexOf=jrt,k.inRange=Sst,k.invoke=hst,k.isArguments=ra,k.isArray=_t,k.isArrayBuffer=Sot,k.isArrayLike=Gn,k.isArrayLikeObject=Ne,k.isBoolean=Lot,k.isBuffer=Ls,k.isDate=Iot,k.isElement=Dot,k.isEmpty=_ot,k.isEqual=Mot,k.isEqualWith=Uot,k.isError=ob,k.isFinite=Oot,k.isFunction=No,k.isInteger=s6,k.isLength=Cg,k.isMap=l6,k.isMatch=Not,k.isMatchWith=Pot,k.isNaN=Fot,k.isNative=Kot,k.isNil=$ot,k.isNull=Vot,k.isNumber=a6,k.isObject=ke,k.isObjectLike=De,k.isPlainObject=Bd,k.isRegExp=sb,k.isSafeInteger=Hot,k.isSet=c6,k.isString=Eg,k.isSymbol=ar,k.isTypedArray=zc,k.isUndefined=jot,k.isWeakMap=zot,k.isWeakSet=Got,k.join=Xrt,k.kebabCase=Ust,k.last=Rr,k.lastIndexOf=Qrt,k.lowerCase=Ost,k.lowerFirst=Nst,k.lt=Wot,k.lte=qot,k.max=Ilt,k.maxBy=Dlt,k.mean=_lt,k.meanBy=Mlt,k.min=Ult,k.minBy=Olt,k.stubArray=mb,k.stubFalse=gb,k.stubObject=blt,k.stubString=vlt,k.stubTrue=Blt,k.multiply=Nlt,k.nth=Yrt,k.noConflict=hlt,k.noop=hb,k.now=mg,k.pad=Pst,k.padEnd=Fst,k.padStart=Kst,k.parseInt=Vst,k.random=Lst,k.reduce=tot,k.reduceRight=eot,k.repeat=$st,k.replace=Hst,k.result=Ast,k.round=Plt,k.runInContext=K,k.sample=rot,k.size=sot,k.snakeCase=jst,k.some=lot,k.sortedIndex=iit,k.sortedIndexBy=oit,k.sortedIndexOf=sit,k.sortedLastIndex=lit,k.sortedLastIndexBy=ait,k.sortedLastIndexOf=cit,k.startCase=Gst,k.startsWith=Wst,k.subtract=Flt,k.sum=Klt,k.sumBy=Vlt,k.template=qst,k.times=Tlt,k.toFinite=Po,k.toInteger=Ut,k.toLength=f6,k.toLower=Xst,k.toNumber=wr,k.toSafeInteger=Xot,k.toString=ee,k.toUpper=Qst,k.trim=Yst,k.trimEnd=Jst,k.trimStart=Zst,k.truncate=tlt,k.unescape=elt,k.uniqueId=klt,k.upperCase=nlt,k.upperFirst=cb,k.each=YL,k.eachRight=JL,k.first=WL,db(k,function(){var a={};return Fi(k,function(u,g){Wt.call(k.prototype,g)||(a[g]=u)}),a}(),{chain:!1}),k.VERSION=r,$n(["bind","bindKey","curry","curryRight","partial","partialRight"],function(a){k[a].placeholder=k}),$n(["drop","take"],function(a,u){Vt.prototype[a]=function(g){g=g===e?1:S(Ut(g),0);var x=this.__filtered__&&!u?new Vt(this):this.clone();return x.__filtered__?x.__takeCount__=_(g,x.__takeCount__):x.__views__.push({size:_(g,Ar),type:a+(x.__dir__<0?"Right":"")}),x},Vt.prototype[a+"Right"]=function(g){return this.reverse()[a](g).reverse()}}),$n(["filter","map","takeWhile"],function(a,u){var g=u+1,x=g==be||g==Ii;Vt.prototype[a]=function(T){var w=this.clone();return w.__iteratees__.push({iteratee:vt(T,3),type:g}),w.__filtered__=w.__filtered__||x,w}}),$n(["head","last"],function(a,u){var g="take"+(u?"Right":"");Vt.prototype[a]=function(){return this[g](1).value()[0]}}),$n(["initial","tail"],function(a,u){var g="drop"+(u?"":"Right");Vt.prototype[a]=function(){return this.__filtered__?new Vt(this):this[g](1)}}),Vt.prototype.compact=function(){return this.filter(qn)},Vt.prototype.find=function(a){return this.filter(a).head()},Vt.prototype.findLast=function(a){return this.reverse().find(a)},Vt.prototype.invokeMap=Pt(function(a,u){return typeof a=="function"?new Vt(this):this.map(function(g){return Cd(g,a,u)})}),Vt.prototype.reject=function(a){return this.filter(pg(vt(a)))},Vt.prototype.slice=function(a,u){a=Ut(a);var g=this;return g.__filtered__&&(a>0||u<0)?new Vt(g):(a<0?g=g.takeRight(-a):a&&(g=g.drop(a)),u!==e&&(u=Ut(u),g=u<0?g.dropRight(-u):g.take(u-a)),g)},Vt.prototype.takeRightWhile=function(a){return this.reverse().takeWhile(a).reverse()},Vt.prototype.toArray=function(){return this.take(Ar)},Fi(Vt.prototype,function(a,u){var g=/^(?:filter|find|map|reject)|While$/.test(u),x=/^(?:head|last)$/.test(u),T=k[x?"take"+(u=="last"?"Right":""):u],w=x||/^find/.test(u);!T||(k.prototype[u]=function(){var O=this.__wrapped__,P=x?[1]:arguments,V=O instanceof Vt,Q=P[0],Y=V||_t(O),tt=function(jt){var zt=T.apply(k,Oi([jt],P));return x&&ht?zt[0]:zt};Y&&g&&typeof Q=="function"&&Q.length!=1&&(V=Y=!1);var ht=this.__chain__,Et=!!this.__actions__.length,Tt=w&&!ht,Nt=V&&!Et;if(!w&&Y){O=Nt?O:new Vt(this);var yt=a.apply(O,P);return yt.__actions__.push({func:dg,args:[tt],thisArg:e}),new jn(yt,ht)}return Tt&&Nt?a.apply(this,P):(yt=this.thru(tt),Tt?x?yt.value()[0]:yt.value():yt)})}),$n(["pop","push","shift","sort","splice","unshift"],function(a){var u=Kl[a],g=/^(?:push|sort|unshift)$/.test(a)?"tap":"thru",x=/^(?:pop|shift)$/.test(a);k.prototype[a]=function(){var T=arguments;if(x&&!this.__chain__){var w=this.value();return u.apply(_t(w)?w:[],T)}return this[g](function(O){return u.apply(_t(O)?O:[],T)})}}),Fi(Vt.prototype,function(a,u){var g=k[u];if(g){var x=g.name+"";Wt.call(ln,x)||(ln[x]=[]),ln[x].push({name:u,func:g})}}),ln[og(e,M).name]=[{name:"wrapper",func:e}],Vt.prototype.clone=ent,Vt.prototype.reverse=nnt,Vt.prototype.value=rnt,k.prototype.at=Dit,k.prototype.chain=_it,k.prototype.commit=Mit,k.prototype.next=Uit,k.prototype.plant=Nit,k.prototype.reverse=Pit,k.prototype.toJSON=k.prototype.valueOf=k.prototype.value=Fit,k.prototype.first=k.prototype.head,Wl&&(k.prototype[Wl]=Oit),k},yo=Kc();xo?((xo.exports=yo)._=yo,Qf._=yo):Je._=yo}).call(Mn)})(yn,yn.exports);function l$(n,t,e,r){l0(n,{className:"status-input",defaultValue:t,onChange:e,onKeyDown:r,maxLength:32})}const $k=["Blue","Grey","Yellow","Red","Green","Purple"];function a$(){const n=B("div",["status-color-palette"],null);for(const t of $k){const e=B("button",["status-box-button"],null);e.setAttribute("data-color",yn.exports.lowerCase(t)),e.setAttribute("title",D.t(`status.color.${yn.exports.lowerCase(t)}`)),n.appendChild(e)}return n}class c${constructor(){m(this,"root",a$());m(this,"changeColor",t=>{for(const r of Array.from(this.root.querySelectorAll(":scope > button")))r.classList.remove("selected");const e=this.root.querySelector(`button[data-color="${yn.exports.lowerCase(t)}"]`);e==null||e.classList.add("selected")})}}function Hk(n){var o;const t=$k[0],e=(o=n.settingsProvider.getItem(`statusBox.lastColor.${yn.exports.lowerCase(t)}`))!=null?o:D.t(`status.colorDefaultTitle.${yn.exports.lowerCase(t)}`);return{insert:" ",attributes:{id:Z(),type:"status",box:!0,title:e,subtle:!1,created:Date.now(),color:t}}}function u$(n,t){localStorage.setItem(`statusBox.lastColor.${yn.exports.lowerCase(t.color)}`,t.title)}function f$(n,t){var e;return(e=localStorage.getItem(`statusBox.lastColor.${yn.exports.lowerCase(t)}`))!=null?e:D.t(`status.colorDefaultTitle.${yn.exports.lowerCase(t)}`)}class d${constructor(t,e,r,i){m(this,"root");m(this,"ro");m(this,"mo");this.editor=t;const o=B("a",r,null,this.replaceTitleSpace(e));this.root=o,i.appendChild(o),this.observeResize(),this.observeRemoval()}replaceTitleSpace(t){return t.replace(/\s/g,"\xA0")}check(){return this.root.scrollWidth>this.root.offsetWidth}observeResize(){this.ro=new ResizeObserver(yn.exports.debounce(t=>{for(const e of t)if(this.check()){const r=this.root.textContent||"";e.target.setAttribute(`data-editor-tooltip-${this.editor.clientId}`,r)}else e.target.removeAttribute(`data-editor-tooltip-${this.editor.clientId}`)},200)),this.ro.observe(this.root)}handleContentChange(){if(this.check()){const t=this.root.textContent||"";this.root.setAttribute(`data-editor-tooltip-${this.editor.clientId}`,t)}else this.root.removeAttribute(`data-editor-tooltip-${this.editor.clientId}`)}observeRemoval(){this.mo=new MutationObserver(t=>{t.forEach(e=>{e.target===this.root&&e.type==="childList"&&this.handleContentChange(),e.removedNodes.forEach(r=>{r===this.root&&(this.unbindResizeObserver(),this.unbindMutationObserver())})})}),this.root.parentElement&&(this.mo.observe(this.root.parentElement,{childList:!0}),this.mo.observe(this.root,{childList:!0}))}unbindResizeObserver(){var t;(t=this.ro)==null||t.unobserve(this.root)}unbindMutationObserver(){var t;(t=this.mo)==null||t.disconnect()}rebind(t){this.unbindResizeObserver(),this.unbindMutationObserver(),this.root=t,this.observeResize(),this.observeRemoval()}changeTag(t,e){this.root.textContent=this.replaceTitleSpace(t),this.root.className=e.join(" ")}destroy(){this.unbindResizeObserver(),this.unbindMutationObserver()}}class ZC{static create(t,e,r,i){const{title:o,id:s}=r;if(this.tagRef.has(s)){const c=this.tagRef.get(s);return c==null||c.changeTag(o||D.t("status.empty"),e),i.appendChild(c==null?void 0:c.root),setTimeout(()=>{c==null||c.rebind(lu(t.getBoxById(s)).firstChild)}),c}const l=new d$(t,o,e,i);return this.tagRef.set(s,l),setTimeout(()=>{l.rebind(lu(t.getBoxById(s)).firstChild)}),l}static remove(t){const e=this.tagRef.get(t);this.tagRef.delete(t),e==null||e.destroy()}}m(ZC,"tagRef",new Map);const I0=I("StatusBoxEditor");class tE{constructor(t){m(this,"linkPopup",null);m(this,"boxElement");m(this,"statusPalette",new c$);m(this,"isEditing",!1);m(this,"editorStatus",t=>{if(!this.editor.isWritable())return;const e=this.editor.getBoxData(t);this.linkPopup=new Va(this.createPopupContent(e.title,e.color,e.subtle),{id:"status-box-popup"}),this.linkPopup.on("show",this.handleShow),this.linkPopup.on("close",this.handClose),this.linkPopup.manualShow(t,{theme:"light",placement:"bottom-start",offset:[5,5]}),this.boxElement=t});m(this,"handleShow",()=>{this.focus()});m(this,"handClose",()=>{var r;p(I0,this.boxElement,"boxElement not found");const t=this.editor.getBoxData(this.boxElement),e=et(this.boxElement);if(p(I0,e,"block not found"),t.title)u$(this.editor,t);else{const i=zo(e,this.boxElement);this.editor.deleteTextFromBlock(e,i.start,1),ZC.remove(t.id)}this.editor.focus(),(r=this.linkPopup)==null||r.destroy(),this.linkPopup=null,this.boxElement=void 0,this.isEditing=!1});m(this,"handleKeyDown",t=>{var e;t.key==="Enter"&&((e=this.linkPopup)==null||e.close(null))});m(this,"onColorChange",t=>{var o,s;if(!(t.target instanceof HTMLElement)||t.target.closest("[data-color]")===null)return;const e=yn.exports.upperCase(t.target.getAttribute("data-color"));p(I0,this.boxElement,"boxElement not found");const r=this.editor.getBoxData(this.boxElement);this.statusPalette.changeColor(e);const i={...r,color:e};if(!this.isEditing){const l=(s=(o=this.linkPopup)==null?void 0:o.popper)==null?void 0:s.querySelector("input"),c=f$(this.editor,e);l&&(l.value=c),i.title=c}this.editor.updateBoxData(i,{noFocus:!0}),this.focus()});m(this,"changeTitle",t=>{const e=t.target.value;p(I0,this.boxElement,"boxElement not found");const i={...this.editor.getBoxData(this.boxElement),title:e.trim()};this.editor.updateBoxData(i,{noFocus:!0}),this.isEditing=!0});this.editor=t,this.statusPalette.root.addEventListener("click",this.onColorChange)}focus(){setTimeout(()=>{var t,e,r,i,o,s;(r=(e=(t=this.linkPopup)==null?void 0:t.popper)==null?void 0:e.querySelector("input"))==null||r.focus(),(s=(o=(i=this.linkPopup)==null?void 0:i.popper)==null?void 0:o.querySelector("input"))==null||s.select()},100)}createPopupContent(t,e,r){const i=B("div",["status-box-editor-popup"],null);return l$(i,t,this.changeTitle,this.handleKeyDown),this.isEditing=!1,i.appendChild(this.statusPalette.root),this.statusPalette.changeColor(e),i}destroy(){var t;(t=this.linkPopup)==null||t.destroy()}}const kct="";function h$(n,t,e,r){const i=r,{title:o,subtle:s,color:l}=i,c=s?["box-status-common",`box-status-${yn.exports.lowerCase(l)}-subtle`]:["box-status-common",`box-status-${yn.exports.lowerCase(l)}`];o||c.push("box-status-empty"),ZC.create(n,c,r,e),n.addCustom("status-box",d=>new tE(d))}function m$(n,t){return{abstract:D.t("status.command.name")}}function g$(n,t){n.getCustom("status-box").editorStatus(t)}function p$(n,t){const{title:e}=t;return e!=null?e:""}async function C$(n,t){const{title:e}=t;return[{insert:e!=null?e:""}]}const jk={boxType:"status",updateBoxContent:h$,getBoxProperties:m$,handleClickBox:g$,convertTo:p$,toStandardText:C$},E$=I("status-box-command");class nc{static get commands(){return[{id:this.id,name:D.t("status.command.name"),icon:dy,order:650,group:"common",subText:"/status"}]}static insertStatus(t,e,r){var c;const i=t.getBlockByIndex(e,r),o=Hk(t),{start:s}=t.selection.range;p(E$,Or(s),"invalid block position"),t.insertBoxToBlock(i,s.offset,o.attributes);const l=t.getBoxById((c=o.attributes)==null?void 0:c.id);t.addCustom("status-box",d=>new tE(d)).editorStatus(l)}static insertEmptyBlockStatus(t,e,r){var l;let i=t.getBlockByIndex(e,r);(!i||!ie(t,i))&&(i=t.insertTextBlock([],e,r));const o=Hk(t);t.setBlockText(i,[o]);const s=t.getBoxById((l=o.attributes)==null?void 0:l.id);return t.addCustom("status-box",c=>new tE(c)).editorStatus(s),i}}m(nc,"id","insert-status");const x$={"en-US":{status:{empty:"\u8BBE\u7F6E\u72B6\u6001",command:{name:"\u72B6\u6001"},color:{red:"\u7EA2\u8272",yellow:"\u9EC4\u8272",green:"\u7EFF\u8272",blue:"\u84DD\u8272",purple:"\u7D2B\u8272",grey:"\u7070\u8272"},colorDefaultTitle:{red:"\u5DF2\u5EF6\u671F",yellow:"\u8FDB\u884C\u4E2D",green:"\u5DF2\u5B8C\u6210",blue:"\u672A\u5F00\u59CB",purple:"\u5DF2\u53D6\u6D88",grey:"\u6682\u505C"}}},"zh-CN":{status:{empty:"\u8BBE\u7F6E\u72B6\u6001",command:{name:"\u72B6\u6001"},color:{red:"\u7EA2\u8272",yellow:"\u9EC4\u8272",green:"\u7EFF\u8272",blue:"\u84DD\u8272",purple:"\u7D2B\u8272",grey:"\u7070\u8272"},colorDefaultTitle:{red:"\u5DF2\u5EF6\u671F",yellow:"\u8FDB\u884C\u4E2D",green:"\u5DF2\u5B8C\u6210",blue:"\u672A\u5F00\u59CB",purple:"\u5DF2\u53D6\u6D88",grey:"\u6682\u505C"}}},"ja-JP":{status:{empty:"\u8BBE\u7F6E\u72B6\u6001",command:{name:"\u72B6\u6001"},color:{red:"\u7EA2\u8272",yellow:"\u9EC4\u8272",green:"\u7EFF\u8272",blue:"\u84DD\u8272",purple:"\u7D2B\u8272",grey:"\u7070\u8272"},colorDefaultTitle:{red:"\u5DF2\u5EF6\u671F",yellow:"\u8FDB\u884C\u4E2D",green:"\u5DF2\u5B8C\u6210",blue:"\u672A\u5F00\u59CB",purple:"\u5DF2\u53D6\u6D88",grey:"\u6682\u505C"}}}};D.mergeLang(x$);const dl=I("inline-box-items");function A$(n,t,e){return n.undoManager.runInGroup(()=>{var s;let r=n.findBlockByIndex(t,e);(!r||!ie(n,r))&&(r=n.insertTextBlock([],t,e));const i=Fk();n.setBlockText(r,[i]);const o=(s=i.attributes)==null?void 0:s.id;return p(dl,o,"mathjax box id is empty"),setTimeout(()=>{const l=n.getBoxById(o);L0(n,l)},100),r})}function b$(n,t,e){let r=n.findBlockByIndex(t,e),i="bottom-start";return(!r||!ie(n,r))&&(i="top-start",r=n.insertTextBlock([],t,e)),Qu(n,{target:r,linkText:"",linkUrl:"",onFinished:(l,c)=>{n.undoManager.runInGroup(()=>{try{p(dl,r,"block not found"),ie(n,r)||(r=n.insertTextBlock([],t,e));const d=gr(l,{link:c}),h=gr(" ",null),C=[d,h];n.insertTextToBlock(r,0,C),n.selection.selectBlock(r,un(C)),n.focus()}catch(d){dl.error(d)}})},onClose:()=>{n.focus()},placement:i}),r}function v$(n,t,e){return n.undoManager.runInGroup(()=>{var l;const r=n.getBlockByIndex(t,e),i=n.selection.range;p(dl,Or(i.start),"invalid block position");const o=Fk();n.insertBoxToBlock(r,i.start.offset,o.attributes);const s=(l=o.attributes)==null?void 0:l.id;return p(dl,s,"mathjax box id is empty"),setTimeout(()=>{const c=n.getBoxById(s);L0(n,c)},100),r})}function B$(n,t,e){const r=n.getBlockByIndex(t,e),i=n.selection.range;p(dl,Or(i.start),"invalid block position");const o=qi(n,r,i);if(o.length===0)return;const s=o[0],l=Yi(n,r,"quick-menu-inline-link",s);Qu(n,{target:l,linkText:"",linkUrl:"",onFinished:(h,C)=>{n.undoManager.runInGroup(()=>{try{const E=n.getBlockText(r),A=to(E,i.start.offset,h,{link:C});n.setBlockText(r,A),n.selection.selectBlock(r,i.start.offset+h.length),n.focus()}catch(E){dl.error(E)}})},onClose:()=>{n.focus()},placement:"bottom-start"})}class zk{getCommands(){return[{id:"insert-math",name:D.t("quickMenu.inlineBox.math"),icon:ST,order:900,group:"common",subText:Bn("insert-math")},{id:"insert-link",name:D.t("quickMenu.inlineBox.link"),icon:Jp,order:400,group:"common",subText:Bn("insert-link")},...nc.commands]}async handleUpdateBlockCore(t,e){switch(e.item.id){case"insert-math":return v$(t,e.containerId,e.blockIndex);case"insert-link":return B$(t,e.containerId,e.blockIndex);case nc.id:return nc.insertStatus(t,e.containerId,e.blockIndex);default:return null}}async handleInsertEmptyBlockCore(t,e){switch(e.item.id){case"insert-math":return A$(t,e.containerId,e.blockIndex);case"insert-link":return b$(t,e.containerId,e.blockIndex);case nc.id:return nc.insertEmptyBlockStatus(t,e.containerId,e.blockIndex);default:return null}}async executeCommand(t,e,r){if(r.from==="quick-menu"){const i=t.getBlockById(r.blockId),o=t.getParentContainer(i),s=ft(o),l=t.getBlockIndex(i);t.undoManager.runInGroup(()=>this.handleUpdateBlockCore(t,{item:e,containerId:s,blockIndex:l}))}else r.from==="block-menu"&&t.undoManager.runInGroup(()=>this.handleInsertEmptyBlockCore(t,{item:e,containerId:r.containerId,blockIndex:r.blockIndex}));return null}}function T$(n,t={withPlainText:!1}){var o,s;const{withPlainText:e}=t,r=(s=(o=n.options.componentsOptions)==null?void 0:o.quickMenu)==null?void 0:s.commandProviders;if(!r)return[];const i=[];return[...r,new Dk(e),new zk].forEach(l=>{const c=l.getCommands(n);i.push(...c.map(d=>({...d,itemType:"insert-block",commandProvider:l})))}),i}function y$(n,t={withPlainText:!1}){const e=[];return n.editorBlocks.forEach(r=>{if(!r.getOptions)return;const i=r.getOptions(n);!i.insertBlockCommandItems||(i.insertBlockCommandItems.forEach(o=>{Ik(o,i)}),e.push(...i.insertBlockCommandItems))}),e.push(...T$(n,t)),e}function eE(n,t={withPlainText:!1}){const e=y$(n,t),r=new Map;e.forEach(s=>{var d;const l=(d=s.group)!=null?d:"";let c=r.get(l);c?c.items.push(s):(c={group:l,order:s.groupOrder||_k[l]||1e3,items:[s]},r.set(l,c))});const i=Array.from(r.values());i.sort((s,l)=>s.order-l.order),i.forEach(s=>{s.items.sort((l,c)=>{var d,h;return((d=l.order)!=null?d:0)-((h=c.order)!=null?h:0)})});const o=[];return i.forEach((s,l)=>{const c=`blockMenu.section.${s.group||"common"}`,d=D.t(c),h=d===c?s.group:d;o.push({id:`section-${l}`,name:h,type:"section",group:s.group,itemType:"insert-block"}),o.push(...s.items.map(C=>({...C})))}),o}function k$(n,t,e){const r=n.getFocusedBlock();if(!r)return;const i=n.getParentContainer(r),o=ft(i);let l=n.getBlockIndex(r);if(ie(n,r)||(l+=1),t.commandProvider){t.commandProvider.executeCommand(n,t,{from:"quick-menu",...e});return}!t.blockOptions||!t.blockOptions.handleInsertEmptyBlock||t.blockOptions.handleInsertEmptyBlock(n,{containerId:o,blockIndex:l,item:t})}const Gk=I("quick-menu"),R$={id:"quick-menu",trigger:["/"]},w$=5;class D0{constructor(t,e=R$){m(this,"suggest");m(this,"items");m(this,"maxHeading");m(this,"firstEmptyOffset",-1);m(this,"queryItems",async(t,e)=>{if(this.items.length===0?this.initMenuItems():this.refreshMenuItems(),e){const r=new Set,i=e.toLocaleLowerCase().replace(/^\s+|\s+$/g,""),o=this.items.filter(s=>{if(s.type==="section")return!0;if(s.name.toLocaleLowerCase().indexOf(i)!==-1||UP(s).toLocaleLowerCase().indexOf(i)!==-1)return r.add(s.group),!0;const l=`blockMenu.section.${s.group||"common"}`,c=D.t(l),d=c===l?s.group:c;return(d==null?void 0:d.toLocaleLowerCase().indexOf(i))!==-1?(r.add(s.group),!0):!1}).filter(s=>s.type==="section"?r.has(s.group):!0);return o.length?this.firstEmptyOffset=-1:this.handleEmptySearch(),o}return this.items});m(this,"onClose",()=>{this.firstEmptyOffset=-1});m(this,"onShow",(t,e,r,i)=>{const o=this.editor.getBlockByIndex(e,r);if(!dr(o)){const s=et(rt(o));if(s&&St(s)==="code")return!1}return!0});m(this,"onClickItem",(t,e)=>{const r=e;r.itemType==="insert-block"&&(p(Gk,r.blockOptions||r.commandProvider,"invalid quick item, no block options or command provider"),p(Gk,this.suggest.anchor,"invalid suggest, no anchor"),this.options.id==="empty-block-menu"&&this.editor.focus(),k$(this.editor,r,this.suggest.anchor))});this.editor=t,this.options=e,this.items=[],this.maxHeading=x0(),this.suggest=new cC(t,{id:e.id||"quick-menu",trigger:e.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 t=eE(this.editor);this.items=t}refreshMenuItems(){let t=null,e=0;const r=x0();if(r!==this.maxHeading){const i=new Dk,s=i.getCommands().map(l=>({...l,itemType:"insert-block",commandProvider:i}));for(let l=0;l<this.items.length;l++)this.items[l].group==="basics"&&(t||(t=l),t&&e++);t&&e&&this.items.splice(t,e,...s),this.maxHeading=r}}handleEmptySearch(){const t=this.editor.selection.getFocusedPos();if(this.firstEmptyOffset===-1){if(t.isSimple()){const{offset:e}=t;this.firstEmptyOffset=e-1}}else if(t.isSimple()){const{offset:e}=t;e-this.firstEmptyOffset>w$&&(this.suggest.close(),this.firstEmptyOffset=-1)}}}class _0{constructor(t){m(this,"instance");m(this,"mousedown",!1);m(this,"currentInstance",null);m(this,"attributeName",[]);m(this,"attributeDesc","");m(this,"_lastClickButtonId","");m(this,"observer",null);m(this,"observerCallback",null);m(this,"createContent",t=>{let e="",r=0;for(;r<this.attributeName.length&&!e;)t.hasAttribute(this.attributeName[r])&&(e=t.getAttribute(this.attributeName[r])||""),r++;const i=t.getAttribute(this.attributeDesc);if(!i)return e;const o=B("div",[],null);return B("span",[],o,e),i&&B("span",["editor-tooltip-desc"],o,i),o});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",t=>{this.currentInstance&&this.hide(),this.currentInstance=t,this.createObserver()});m(this,"handleHidden",()=>{this.destroyObserver(),this.currentInstance=null});m(this,"handleShow",t=>{var i;const e=t.reference;if(!e||!ne(document.body,e)||window.isDragging||this.mousedown)return!1;const r=Number.parseInt((i=e.getAttribute("data-tooltip-hide-at"))!=null?i:"",10);if(r&&Date.now()-r<1e3)return!1;if(this._lastClickButtonId===e.getAttribute("data-button-id"))return this._lastClickButtonId="",!1;if(this.attributeName.every(o=>!e.hasAttribute(o)))return!1;if(t.reference){const o={};if(t.reference.hasAttribute("data-editor-tooltip-placement")&&(o.placement=t.reference.getAttribute("data-editor-tooltip-placement")||"top"),t.reference.hasAttribute("data-editor-tooltip-offset-x")||t.reference.hasAttribute("data-editor-tooltip-offset-y")){const l=t.reference.getAttribute("data-editor-tooltip-offset-x"),c=t.reference.getAttribute("data-editor-tooltip-offset-y");o.offset=[l?Number.parseInt(l,10):0,c?Number.parseInt(c,10):0]}t.reference.hasAttribute("data-editor-tooltip-maxwidth")&&(o.maxWidth=Number.parseInt(t.reference.getAttribute("data-editor-tooltip-maxwidth")||"350",10)),t.reference.hasAttribute("data-editor-tooltip-allow-markdown")&&(o.allowHTML=!0);const s=document.body;if(o.appendTo=this.fixContainerForFullscreen(s),Object.keys(o).length&&t.setProps(o),t.reference.hasAttribute(`data-editor-tooltip-${this.editor.clientId}-dynamic`)){const l=t.reference.getAttribute(`data-editor-tooltip-${this.editor.clientId}-dynamic`);t.setContent(l||"")}}return!0});this.editor=t;const e=t.clientId;this.attributeName=[`data-editor-tooltip-${e}`,`data-editor-tooltip-${e}-dynamic`,"data-editor-tooltip-common"],this.attributeDesc=`data-editor-tooltip-desc-${e}`,this.instance=Ag.delegate(document.body,{theme:"editor-tooltip",maxWidth:400,delay:200,target:this.attributeName.map(r=>`[${r}]`).join(","),content:this.createContent,onShow:this.handleShow,onShown:this.handleShown,onHide:this.handleHidden,hideOnClick:!1}),t.domEvents.addEventListener(document,"mousedown",this.handleDocumentMouseDown)}set lastClickButtonId(t){this._lastClickButtonId=t,t&&setTimeout(()=>{this._lastClickButtonId===t&&(this._lastClickButtonId="")},500)}visible(){var t;return(t=this.currentInstance)==null?void 0:t.state.isVisible}hide(){var t;(t=this.currentInstance)!=null&&t.state.isVisible&&this.currentInstance.hide()}destroy(){this.destroyObserver(),this.instance.destroy(),this.editor.domEvents.removeEventListener(document,"mousedown",this.handleDocumentMouseDown),this.editor.domEvents.removeEventListener(document,"mouseup",this.handleDocumentMouseUp)}createObserver(){this.destroyObserver();const t=this.currentInstance;if(!t||!t.reference)return;this.observerCallback=Me.default(()=>{t.reference.closest("body")||(t.hide(),this.destroyObserver())},200),this.observer=new MutationObserver(this.observerCallback);const e=document.body,r={childList:!0,attributes:!1,subtree:!0};this.observer.observe(e,r)}destroyObserver(){this.observer&&(this.observer.disconnect(),this.observer=null),this.observerCallback&&(this.observerCallback.cancel(),this.observerCallback=null)}fixContainerForFullscreen(t){return t.closest("body")&&document.fullscreenElement&&!document.fullscreenElement.contains(t)?document.fullscreenElement:t}}const S$={"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",link:"link"};function L$(n,t){const e=new Set(Object.keys(S$)),r=t.filter(o=>e.has(o.id));return C0(r)}function Zu(n,t){if(!n.isWritable())return!1;const e=n.selection.range,r=n.editorCommandProviders.getCommands(e),o=L$(n,r).find(s=>s.id===`text/${t}`||s.id==="link");return o?(n.editorCommandProviders.executeCommand(e,o,{}),ec.get(n).update("selectionChange"),!0):!1}function I$(n,t){const e=n.selection.focusedBlock;if(!n.isWritable()||!nt(n,e))return!1;const r=n.getBlockData(e).heading,i={id:`heading-${t}`,source:"BlockTurnIntoCommandProvider",value:String(t)};return Number(r)===t&&(i.id="text",i.value=null),n.editorCommandProviders.executeCommand(n.selection.range,i,{}),!0}const nE={"CtrlOrCmd+B":n=>Zu(n,"style-bold"),"CtrlOrCmd+I":n=>Zu(n,"style-italic"),"CtrlOrCmd+U":n=>Zu(n,"style-underline"),"CtrlOrCmd+D":n=>Zu(n,"style-strikethrough"),"CtrlOrCmd+K":n=>Zu(n,"link"),...(()=>{const n={};for(let t=1;t<=8;t++)n[`CtrlOrCmd+${t}`]=e=>I$(e,t);return n})()},D$={quickMenu:{basic:{heading:{title:"\u6807\u9898 {heading}",space:"{markdown}\u7A7A\u683C"},unordered:"\u65E0\u5E8F\u5217\u8868",ordered:"\u6709\u5E8F\u5217\u8868",checkbox:"\u5F85\u529E\u5217\u8868",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"}},_$={quickMenu:{basic:{heading:{title:"Heading {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:"Heading {name}",headingGroup:"Text style",text:"Text"}},M$={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"}};D.mergeLang({"zh-CN":D$,"en-US":_$,"ja-JP":M$});const Ict="";function hl(n,...t){const e=Cr(...t);return e.classList.remove("editor-button"),e.classList.add("editor-text-button"),n.append(e),e}function Wk(n){const t=E0(n);t==null||t.hide();const e=n.findCustom("table-border-bar");e==null||e.closeToolbar()}function U$(n){return B("div",["insert-column-button","drop-marker"],n)}const O$=I("row-height");function qk(n){const t=It.fromTable(n),e=n.rows;p(O$,e.length===t.rowCount,"row count mismatch");const r=Array(t.rowCount).fill(0);for(let i=0;i<e.length;){let o=1,l=e[i].getBoundingClientRect().height,c=i+1;for(;c<e.length;){const d=e[c];if(d.cells.length!==0)break;o++,c++,l+=d.getBoundingClientRect().height}for(let d=0;d<o;d++)r[i+d]=l/o;i=c}return r}const N$=I("table-border-bar-dom");function Xk(n){var c;const t=et(n.contentElement);p(N$,t,"no block");const r=re(t).querySelector(".table-border-bar-container.left"),o=Ot(t).offsetLeft-za,s=((c=n.scrollOptions.paddingLeft)!=null?c:0)+o,l=Math.min(n.contentElement.offsetLeft-o,n.rootElement.scrollLeft-s);r&&(r.style.left=`${-l}px`)}const ss=I("table-border-bar-dom");function rc(n,t){p(ss,$e(t),"invalid table block");const e=Ve(t),r=vi(n,t),i=re(t),o=(C,E,A)=>{const v=B("div",["button-root",E],C),R=B("div",["button-container",E],v);v.setAttribute(`data-${E}-index`,`${A}`),R.setAttribute(`data-editor-tooltip-${n.clientId}`,E==="left"?D.t("table.insertRow"):D.t("table.insertCol")),B("span",["insert-indicator"],R),U$(R)},{selectedRows:s,selectedColumns:l}=fC(n,t),c=()=>{const C=r.querySelector(".table-border-bar-container.top");p(ss,C,"no top border bar container");const E=B("div",["table-border-bar-container","top"],null),A=B("div",["table-border-bar","top"],E),v=DF(e),L=It.fromTable(e).colCount;n.selection.range.isSimple()&&o(A,"top",0);for(let M=0;M<L;M++){const U=M===L-1?v[M]+2:v[M],F=B("span",["table-border-bar-cell","top"],A);l.has(M)&&F.classList.add("selected"),F.setAttribute("data-top-index",`${M}`),F.style.width=`${U}px`,n.selection.range.isSimple()&&o(A,"top",M+1)}tu(C,E)},d=()=>{const C=i.querySelector(".table-border-bar-container.left");p(ss,C,"no left border bar container");const E=B("div",["table-border-bar-container","left"],null),A=B("div",["table-border-bar","left"],E);B("span",["table-border-bar-cell","corner"],A);const v=qk(e);n.selection.range.isSimple()&&o(A,"left",0),Array.from(e.rows).forEach((R,L,M)=>{const U=B("span",["table-border-bar-cell","left"],A);s.has(L)&&U.classList.add("selected"),U.setAttribute("data-left-index",`${L}`);const F=L===M.length-1?v[L]+2:v[L];U.style.height=`${F}px`,n.selection.range.isSimple()&&o(A,"left",L+1)}),tu(C,E)};c(),d();const h=n.findCustom(bi(t));h&&Xk(h)}function Qk(n,t){const e=t.target;if(!(e instanceof Element))return;const r=et(e);p(ss,r&&$e(r),"invalid table block"),rc(n,r),n.selection.caret.update()}function M0(n,t){const e=t.target;if(!(e instanceof Element))return;const r=et(e);p(ss,r&&$e(r),"invalid table block");const i=e.closest(".button-root");if(i){if(i.classList.contains("top")){const o=parseInt(i.getAttribute("data-top-index")||"0",10);ek(n,r,o),rc(n,r)}else if(i.classList.contains("left")){const o=parseInt(i.getAttribute("data-left-index")||"0",10);wC(n,r,o),rc(n,r)}}}function U0(n,t){var s;Wk(n),t.preventDefault(),t.stopPropagation();let e=null,r,i;const o=l=>{var c;if(l.target instanceof HTMLElement&&r&&e&&i!==void 0){const d=et(l.target),h=l.target.closest(".table-border-bar");if(d===e&&h){const C=parseInt((c=l.target.getAttribute(`data-${r}-index`))!=null?c:"0",10),E=Math.min(i,C),A=Math.abs(i-C)+1;Rt(l.target,"top")&&r==="top"?GF(n,d,E,A,{reverse:!0}):Rt(l.target,"left")&&r==="left"&&WF(n,d,E,A,{reverse:!0})}}l.type==="mouseup"&&(e=null,i=void 0,r=void 0,document.body.removeEventListener("mousemove",o),document.body.removeEventListener("mouseup",o))};t.target instanceof HTMLElement&&Rt(t.target,"table-border-bar-cell")&&(e=et(t.target),Rt(t.target,"top")?r="top":Rt(t.target,"left")&&(r="left"),r&&e&&(i=parseInt((s=t.target.getAttribute(`data-${r}-index`))!=null?s:"0",10),document.body.addEventListener("mousemove",o),document.body.addEventListener("mouseup",o)))}function Yk(n){const t=n.selection.range,e=Vu(n,t);e&&rc(n,e)}function P$(n,t){p(ss,$e(t),"invalid table block");const e=vi(n,t),r=re(t),i=B("div",["table-border-bar-container","top"],e),o=B("div",["table-border-bar-container","left"],r);rc(n,t),n.domEvents.addEventListener(Ot(t),"scroll",Qk),n.domEvents.addEventListener(i,"click",M0),n.domEvents.addEventListener(o,"click",M0),n.domEvents.addEventListener(i,"mousedown",U0),n.domEvents.addEventListener(o,"mousedown",U0),n.addListener("afterClearSelection",Yk)}function Jk(n,t){if(!n.isWritable())return;if(vi(n,t).querySelector(".table-border-bar-container")){rc(n,t);return}P$(n,t)}function Zk(n,t){p(ss,$e(t),"invalid table block");const e=vi(n,t),r=re(t),i=e.querySelectorAll(".table-border-bar-container"),o=r.querySelectorAll(".table-border-bar-container");i.forEach(s=>{n.domEvents.removeEventListener(s,"click",M0),n.domEvents.removeEventListener(s,"mousedown",U0),s.remove()}),o.forEach(s=>{n.domEvents.removeEventListener(s,"click",M0),n.domEvents.removeEventListener(s,"mousedown",U0),s.remove()}),n.domEvents.removeEventListener(Ot(t),"scroll",Qk),n.addListener("afterClearSelection",Yk)}function F$(n,t){p(ss,$e(t),"invalid table block");const r=vi(n,t).querySelector(".table-border-bar-container.top");return r?r.getBoundingClientRect().height:0}class K${constructor(t,e){m(this,"toolbar");m(this,"handleSelectionChange",(t,e)=>{!t.isVisible||(e==="delete-columns"?(es(this.editor,this.tableBlock,!0,!0),ns(this.editor,this.tableBlock,!0,!0)):e==="delete-rows"?(es(this.editor,this.tableBlock,!0,!1),ns(this.editor,this.tableBlock,!0,!1)):(es(this.editor,this.tableBlock,!1),ns(this.editor,this.tableBlock,!1)))});m(this,"handleClick",(t,e,r)=>{e.id==="delete-columns"?dC(this.editor.selection.range):e.id==="delete-rows"&&hC(this.editor.selection.range)});m(this,"handleToolbarClose",()=>{this.tableBlock&&Vu(this.editor,this.editor.selection.range)===this.tableBlock&&(es(this.editor,this.tableBlock,!1),ns(this.editor,this.tableBlock,!1))});this.editor=t,this.tableBlock=e;const r=t.options.componentsOptions.popover;this.toolbar=new Pu([],void 0,{id:"table-row-column-toolbar",overflowBoundary:r==null?void 0:r.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 i,o,s;const{selectedColumns:t,selectedRows:e}=fC(this.editor,this.tableBlock);if(!this.editor.isWritable())return;if(t.size>0&&e.size>0){this.toolbar.close("cancelBar");return}if(t.size===0&&e.size===0){this.toolbar.close("cancelBar");return}const r=qi(this.editor,this.tableBlock,this.editor.selection.range)[0];if(!r){this.toolbar.close("cancelBar");return}if(t.size>0){const l={id:"delete-columns",name:D.t("table.deleteSelectCol"),icon:pT};this.toolbar.updateItems([l]);const c=Yi(this.editor,this.tableBlock,"table-row-column-delete",r);this.toolbar.manualShow(c,{placement:"top",offset:[0,5]})}else{const l={id:"delete-rows",name:D.t("table.deleteSelectRow"),icon:gT};this.toolbar.updateItems([l]);const h=re(this.tableBlock).querySelector(".table-border-bar-container.left").getBoundingClientRect(),C=new DOMRect(Math.max(h.left,r.left-za),r.top,za,r.height),E=Yi(this.editor,this.tableBlock,"table-row-column-delete",C);this.toolbar.manualShow(E,{placement:"left",offset:[0,5]});const A=this.editor.options.componentsOptions.popover;(i=this.toolbar.tippyInstance)==null||i.setProps({popperOptions:{modifiers:[{name:"flip",options:{boundary:A==null?void 0:A.overflowBoundary,fallbackPlacements:["left","right"]}}]}})}(s=(o=this.toolbar.tippyInstance)==null?void 0:o.popperInstance)==null||s.update()}destroy(){this.toolbar.destroy(),this.toolbar.removeAllListeners()}}const rE=I("table-border-bar");class V${constructor(t,e){m(this,"toolbar");m(this,"resizeObserver",null);m(this,"handleReadonlyChanged",t=>{t.isWritable()?this.update():Zk(this.editor,this.tableBlock)});m(this,"handleBlockUpdated",()=>{var t;(t=this.resizeObserver)==null||t.disconnect(),setTimeout(()=>{var r;const e=this.editor.getBlockById(st(this.tableBlock));(r=this.resizeObserver)==null||r.observe(Ve(e))})});m(this,"handleScroll",()=>{var t;(t=this.toolbar)==null||t.update()});m(this,"handleTableResize",()=>{!this.editor.isWritable()||this.update()});this.editor=t,this.tableBlock=e,p(rE,this.tableBlock,"no table block"),rE.debug("create table border bar"),Jk(this.editor,this.tableBlock),this.resizeObserver=new _s(this.handleTableResize),this.resizeObserver.observe(Ve(this.tableBlock));const r=t.getComponentOptions("table");r!=null&&r.hideToolbar||(this.toolbar=new K$(this.editor,this.tableBlock)),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}close(){var t;(t=this.toolbar)==null||t.close()}destroy(){var t,e;rE.debug("destroy table border bar"),(t=this.resizeObserver)==null||t.disconnect(),this.resizeObserver=null,Zk(this.editor,this.tableBlock),(e=this.toolbar)==null||e.destroy(),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged)}update(){var t;Jk(this.editor,this.tableBlock),(t=this.toolbar)==null||t.update()}}const $$=I("table-border-bar");class H${constructor(t){m(this,"activeTableBar",null);m(this,"handleBlockDeleted",(t,e)=>{!this.activeTableBar||(e===this.activeTableBar.tableBlock||ne(e,this.activeTableBar.tableBlock))&&(this.activeTableBar.destroy(),this.activeTableBar=null)});m(this,"handleSelectionChanged",t=>{setTimeout(()=>{var i;const e=t.selection.range,r=Vu(t,e);((i=this.activeTableBar)==null?void 0:i.tableBlock)!==r&&this.activeTableBar&&this.hide(),r&&this.show(r)})});m(this,"handleScroll",()=>{var t;(t=this.activeTableBar)==null||t.handleScroll()});this.editor=t,this.editor.addListener("blockDeleted",this.handleBlockDeleted),this.editor.addListener("selectionChanged",this.handleSelectionChanged)}destroy(){this.editor.removeListener("blockDeleted",this.handleBlockDeleted),this.editor.removeListener("selectionChanged",this.handleSelectionChanged)}show(t){this.activeTableBar?(this.activeTableBar.tableBlock!==t&&this.hide(),this.activeTableBar.update()):this.activeTableBar=new V$(this.editor,t)}update(){var t;(t=this.activeTableBar)==null||t.handleBlockUpdated()}closeToolbar(){var t;(t=this.activeTableBar)==null||t.close()}hide(){!this.activeTableBar||(p($$,this.activeTableBar,"no active table bar"),this.activeTableBar.destroy(),this.activeTableBar=null)}}function tR(n,t){const e=n.addCustom("table-border-bar",r=>new H$(r));t==="update"&&e.update()}const Fn=I("table-cell-menu"),j$="style-bg-color-";class z${constructor(t){m(this,"activeTableBlock",null);m(this,"targetButton",null);m(this,"manualMenu",null);m(this,"colorPaletteItem",null);m(this,"handlePrevent",(t,e)=>{e.stopPropagation()});m(this,"handleReadonlyChanged",t=>{t.isWritable()||this.hide()});m(this,"handleSelectionChanged",t=>{const e=t.selection.range,r=Vu(t,e);if(this.hide(),this.activeTableBlock!==r&&(this.activeTableBlock=r),this.activeTableBlock){const i=It.fromBlock(this.activeTableBlock),o=e.isReverse()?e.start:e.end;let s=null;o instanceof Ur?t.getBlockById(o.blockId)===this.activeTableBlock?s=i.getCellByContainerId(o.childContainerId):s=this.getCellByChildBlockId(i,o.blockId):o.blockId!==this.activeTableBlock.id&&(s=this.getCellByChildBlockId(i,o.blockId)),s&&this.editor.isWritable()&&this.showCellMenuButton(s)}});m(this,"handleBeforePopupPalette",()=>{var e;const t=this.getSelectedBkgColorIndex();(e=this.colorPaletteItem)==null||e.palette.setColor("backgroundColor",t)});m(this,"createBkgColorItem",()=>{const t=B("div",["cell-background-color-item"],null);B("span",[],t,D.t("table.cellBackground"));const e=this.getSelectedBkgColorIndex();B("button",["item-button"],t).setAttribute("data-color-index",`${e}`);const i=B("span",["item-sub-indicator"],t);return i.innerHTML=Gp,t});m(this,"handleCommand",t=>{var i;p(Fn,this.activeTableBlock,"no target table block");const e=((i=t.states)==null?void 0:i.includes("checked"))||!1,r=t.value;switch(t.id){case"delete-select-row":hC(Oy(this.editor,this.activeTableBlock,!1));break;case"delete-select-col":dC(Oy(this.editor,this.activeTableBlock,!0));break;case"merge-cell":_y(this.editor.selection.range);break;case"split-cell":this.handleSplitCell();break;case"row-title":this.handleRowTitle(e);break;case"col-title":this.handleColTitle(e);break;case"stripe-style":this.handleStripeStyle(e);break;case"hide-border":nF(this.editor,this.activeTableBlock,r==="show-border");break;case"show-chart":oF(this.editor,this.activeTableBlock,r==="show-chart"),AC(this.editor,this.activeTableBlock,{updateNow:!0});break}});m(this,"handleToolbarClose",()=>{this.targetButton&&ot(this.targetButton,"active"),this.activeTableBlock&&Vu(this.editor,this.editor.selection.range)===this.activeTableBlock&&(es(this.editor,this.activeTableBlock,!1),ns(this.editor,this.activeTableBlock,!1)),this.editor.focus()});m(this,"handleSelectionChange",(t,e)=>{!t.isVisible||(p(Fn,this.activeTableBlock,"no target table block"),e==="cell-background-color"&&this.handleBeforePopupPalette(),e==="delete-select-row"?(es(this.editor,this.activeTableBlock,!0,!1),ns(this.editor,this.activeTableBlock,!0,!1)):e==="delete-select-col"?(es(this.editor,this.activeTableBlock,!0,!0),ns(this.editor,this.activeTableBlock,!0,!0)):(es(this.editor,this.activeTableBlock,!1),ns(this.editor,this.activeTableBlock,!1)))});m(this,"handleClick",(t,e)=>{var r;p(Fn,this.activeTableBlock,"no target table block"),p(Fn,this.targetButton,"no target button"),Wk(this.editor),Rt(this.targetButton,"active")?(ot(this.targetButton,"active"),(r=this.manualMenu)==null||r.close("clickItem")):(z(this.targetButton,"active"),this.manualMenu?this.manualMenu.updateItems(this.createCommandMenu()):(this.manualMenu=new Zo(this.createCommandMenu(),void 0,{id:"table-cell-menu"}),this.manualMenu.on("click",(i,o)=>{var s;this.handleCommand(o),(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"})),e.stopPropagation()});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChanged),this.editor.addListener("readonlyChanged",this.handleReadonlyChanged)}destroy(){var t,e;this.activeTableBlock=null,this.targetButton=null,this.editor.removeListener("selectionChanged",this.handleSelectionChanged),this.editor.removeListener("readonlyChanged",this.handleReadonlyChanged),(t=this.manualMenu)==null||t.destroy(),(e=this.colorPaletteItem)==null||e.destroy()}hide(){var t;(t=this.manualMenu)==null||t.close("cancelBar"),this.targetButton&&(ot(this.targetButton,"active"),this.targetButton.style.display="none")}getCellByChildBlockId(t,e){let r=this.editor.getBlockById(e);for(;r;){const i=r.closest("td");p(Fn,i,"no parent cell");const o=et(i);if(p(Fn,o,"no parent block"),Ve(o)===t.table)return t.getCellByCellElement(i);r=o}return p(Fn,!1,"filed to get cell by child block id"),null}createTargetButton(t){this.targetButton?t.querySelector(`:scope > .${EC}`)||t.appendChild(this.targetButton):(this.targetButton=B("button",[EC],t),this.targetButton.innerHTML=Wh,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(t){this.createTargetButton(t.cell),p(Fn,this.targetButton,"no target button"),this.targetButton.style.display="inline-block"}handleSplitCell(){if(this.activeTableBlock){const t=It.fromBlock(this.activeTableBlock),e=this.editor.selection.range;if(e.isSimple()){const{col:r,row:i}=this.getCellByChildBlockId(t,e.start.blockId);gC(this.editor,this.activeTableBlock,{col:r,row:i})}else pC(this.editor.selection.range)}}getSelectedBkgColorIndex(){var s;p(Fn,this.activeTableBlock,"no target table block");const t=this.editor.selection.range,e=ts(this.editor,this.activeTableBlock,t.focus),r=this.editor.getBlockData(this.activeTableBlock),i=e.childContainerId,o=r[`${i}_background`];return o?Number.parseInt((s=o.substring(j$.length))!=null?s:"0",10):-1}createCommandMenu(){p(Fn,this.activeTableBlock,"no target table block");const t=this.editor.getBlockData(this.activeTableBlock),e=Dy(this.editor,this.activeTableBlock,this.editor.selection.range);let r=this.editor.selection.range;if(r.isSimple()){const h=ts(this.editor,this.activeTableBlock,r.start);r=qe(this.editor,{anchor:h,focus:h})}const i=Iy(this.editor,this.activeTableBlock,r),o=t.hasRowTitle,s=t.hasColTitle,l=t.isStripeStyle,c=t.noBorder,d=t.chart;return this.colorPaletteItem=new Ty("cell-background-color",{color:!1}),this.colorPaletteItem.palette.on("onClick",(h,C)=>{var E;switch(p(Fn,this.activeTableBlock,"no target table block"),h){case"clearColor":Fy(this.editor,this.activeTableBlock,-1);break;case"backgroundColor":Fy(this.editor,this.activeTableBlock,C);break}(E=this.manualMenu)==null||E.close("clickItem")}),[{id:"cell-background-color",name:D.t("table.cellBackground"),element:this.createBkgColorItem(),children:[this.colorPaletteItem]},{id:"separator",name:"",type:"separator"},{id:"merge-cell",name:D.t("table.mergeCell"),states:e?[]:["disabled"]},{id:"split-cell",name:D.t("table.splitCell"),states:i?[]:["disabled"]},{id:"separator",name:"",type:"separator"},{id:"delete-select-row",name:D.t("table.deleteSelectRow")},{id:"delete-select-col",name:D.t("table.deleteSelectCol")},{id:"separator",name:"",type:"separator"},{id:"table-config",name:D.t("table.tableConfigKey"),children:[{id:"row-title",name:D.t("table.tableConfig.rowTitle"),states:o?["checked"]:[]},{id:"col-title",name:D.t("table.tableConfig.colTitle"),states:s?["checked"]:[]},{id:"stripe-style",name:D.t("table.tableConfig.stripeStyle"),states:l?["checked"]:[]},{id:"hide-border",name:c?D.t("table.tableConfig.showBorder"):D.t("table.tableConfig.hideBorder"),value:c?"show-border":"hide-border"},{id:"show-chart",name:d?D.t("table.tableConfig.hideChart"):D.t("table.tableConfig.showChart"),value:d?"hide-chart":"show-chart"}]}]}handleRowTitle(t){p(Fn,this.activeTableBlock,"no target table block"),t?ZP(this.editor,this.activeTableBlock):JP(this.editor,this.activeTableBlock)}handleColTitle(t){p(Fn,this.activeTableBlock,"no target table block"),t?YP(this.editor,this.activeTableBlock):QP(this.editor,this.activeTableBlock)}handleStripeStyle(t){p(Fn,this.activeTableBlock,"no target table block"),t?eF(this.editor,this.activeTableBlock):tF(this.editor,this.activeTableBlock)}}function eR(n){n.addCustom("table-cell-menu",t=>new z$(t))}const O0=I("table-container");function iE(n){const t=n.closest("td");return p(O0,t,"no parent cell for a table cell container"),t}function nR(n){const t=Ve(n);return Array.from(t.querySelectorAll(':scope > tbody > tr > td > [data-type="editor-container"].child'))}function oE(n,t,e,r){const i=It.fromBlock(n),o=i.getCellByContainerId(ft(t));if(e==="ArrowDown"){const s=i.getBottomCell(o);return s?s.container:null}if(e==="ArrowUp"){const s=i.getTopCell(o);return s?s.container:null}if(e==="ArrowLeft"){const s=i.getAllContainers(),l=s.indexOf(t);if(p(O0,l>=0,"not a valid child container"),l===0)return null;const c=s[l-1];return r!=null&&r.noWrap&&i.getCellByContainerId(ft(c)).row!==o.row?null:c}if(e==="ArrowRight"){const s=i.getAllContainers(),l=s.indexOf(t);if(p(O0,l>=0,"not a valid child container"),l===s.length-1)return null;const c=s[l+1];return r!=null&&r.noWrap&&i.getCellByContainerId(ft(c)).row!==o.row?null:c}p(O0,!1,`invalid navigation type: ${e}`)}const G$=12,W$=90,N0=23,rR=2;class q${constructor(t){m(this,"scrollTableBlock",null);m(this,"autoScrollDir",null);m(this,"autoScrollTimer",null);m(this,"handleMouseDown",t=>{const e=document.elementFromPoint(t.clientX,t.clientY);if(e&&e instanceof HTMLElement){const r=et(e);if(r&&ne(this.editor.rootContainer,r)){const i=uo(r);i&&(this.scrollTableBlock=i,document.addEventListener("mousemove",this.handleAutoScroll))}}});m(this,"handleAutoScroll",t9.default(t=>{if(this.scrollTableBlock){const e=this.editor.getCustom(bi(this.scrollTableBlock)),r=e.rootElement,i=e.scrollOptions.parentContainer,o=r.getBoundingClientRect(),s=window.innerHeight-this.getBarFloatWindowBottom(e),l=i.getBoundingClientRect(),c=Math.min(l.bottom,s),d=Math.max(l.top,0);o.bottom>c&&t.clientY>=c?this.setAutoScroll("bottom"):o.top<d&&t.clientY<=d?this.setAutoScroll("top"):r.scrollLeft>0&&t.clientX<o.left?this.setAutoScroll("left"):r.scrollLeft<r.scrollWidth-r.offsetWidth&&t.clientX>o.right?this.setAutoScroll("right"):this.clearAutoScroll()}},15));m(this,"handleMouseUp",()=>{document.removeEventListener("mousemove",this.handleAutoScroll),setTimeout(()=>{this.scrollTableBlock=null})});m(this,"handleSelectionChanged",t=>{const e=t.selection.range;if(e.isCollapsed()&&e.isSimple()){const r=t.getBlockById(e.start.blockId),i=uo(r);if(i){const o=t.getCustom(bi(i)),s=o.rootElement.getBoundingClientRect(),l=_r(t,r,e.start);if(s.left>l.left){const c=e.start.offset===0?G$:rR;o.rootElement.scrollLeft-=s.left-l.left+c}else if(l.right>s.right){const c=e.start.offset===0?W$:rR;o.rootElement.scrollLeft+=l.right-s.right+c}}}else{const r=t.getBlockById(e.start.blockId),i=uo(r),o=t.getBlockById(e.end.blockId),s=uo(o);if(i&&i===s){const l=t.getCustom(bi(i)),c=l.rootElement.getBoundingClientRect();let d=null;if(e.isSimple())d=e.isReverse()?_r(t,r,e.start):_r(t,o,e.end);else{const h=iE(ui(t,e.start.childContainerId)),C=iE(ui(t,e.end.childContainerId));d=e.isReverse()?h.getBoundingClientRect():C.getBoundingClientRect()}c.left>d.left&&e.isReverse()?l.rootElement.scrollLeft-=c.left-d.left:c.right<d.right&&!e.isReverse()&&(l.rootElement.scrollLeft+=d.right-c.right)}}});m(this,"handleScroll",t=>{wy(t),this.editor.selection.caret.update()});m(this,"handleReset",t=>{wy(t),this.editor.selection.caret.update();const e=this.editor.findCustom("table-border-bar");e&&e.handleScroll(),Xk(t)});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChanged),document.addEventListener("mousedown",this.handleMouseDown),document.addEventListener("mouseup",this.handleMouseUp)}getBarFloatWindowBottom(t){return t.scrollOptions.barFloatWindowBottom?typeof t.scrollOptions.barFloatWindowBottom=="number"?t.scrollOptions.barFloatWindowBottom:t.scrollOptions.barFloatWindowBottom():0}clearAutoScroll(){this.autoScrollTimer&&(clearInterval(this.autoScrollTimer),this.autoScrollTimer=null,this.autoScrollDir=null)}setAutoScroll(t){this.autoScrollDir&&this.autoScrollDir!==t&&this.clearAutoScroll(),this.autoScrollTimer||(this.autoScrollDir=t,this.autoScrollTimer=window.setInterval(()=>{if(this.scrollTableBlock){const e=this.editor.getCustom(bi(this.scrollTableBlock)),r=e.rootElement,i=e.scrollOptions.parentContainer,o=r.getBoundingClientRect(),s=i===document.documentElement?window.innerHeight:i.offsetHeight,l=window.innerHeight-this.getBarFloatWindowBottom(e),c=i.getBoundingClientRect(),d=Math.min(c.bottom,l),h=Math.max(c.top,0);this.autoScrollDir==="left"&&(r.scrollLeft-=N0,r.scrollLeft<=0&&this.clearAutoScroll()),this.autoScrollDir==="right"&&(r.scrollLeft+=N0,r.scrollLeft>=r.scrollWidth-r.offsetWidth&&this.clearAutoScroll()),this.autoScrollDir==="bottom"&&(i.scrollTop+=N0,(i.scrollTop>=i.scrollHeight-s||o.bottom<=d)&&this.clearAutoScroll()),this.autoScrollDir==="top"&&(i.scrollTop-=N0,(i.scrollTop<=0||o.top>=h)&&this.clearAutoScroll())}},100))}destroy(){document.removeEventListener("mousedown",this.handleMouseDown),document.removeEventListener("mouseup",this.handleMouseUp),this.editor.removeListener("selectionChanged",this.handleSelectionChanged)}}function iR(n){return n.addCustom("table-scroll-events",t=>new q$(t))}const X$=I("table-doc-change-handler");class Q${constructor(t){this.editor=t,this.editor.addListener("docChanged",this.handleDocChanged)}handleDocChanged(t,e){if(!e){const{start:r,end:i}=t.selection.range;if(!t.findBlockById(r.blockId)||!t.findBlockById(i.blockId)){t.selection.selectBlock(t.getBlockByIndex("root",0),0);return}if(ma(r)){const o=t.getBlockById(r.blockId);if(!$e(o))return;if(p(X$,ma(i),"invalid range"),!jd(t,r.childContainerId)||!jd(t,i.childContainerId)){t.selection.selectBlock(o,0);return}let s=null,l=null;const c=(d,h)=>{const C=h.getCellById(d.childContainerId),{colIndex:E=0,rowIndex:A=0}=d.custom;let v=-1,R=-1;return(C.col>E||C.col+C.colSpan-1<E)&&(v=C.col),(C.row>A||C.row+C.rowSpan-1<A)&&(R=C.row),v!==-1||R!==-1?xe(o,d.childContainerId,{colIndex:v===-1?E:v,rowIndex:R===-1?A:R}):null};if(r.custom){const d=It.fromBlock(o);s=c(r,d),l=c(i,d)}(s!==null||l!==null)&&(t.selection.range.isReverse()?t.selection.setSelection(l!=null?l:i,s!=null?s:r):t.selection.setSelection(s!=null?s:r,l!=null?l:i))}}}destroy(){this.editor.removeListener("docChanged",this.handleDocChanged)}}function oR(n){n.addCustom("table-doc-change-handler",t=>new Q$(t))}const Bi=I("create-content");function sR(n,t,e){var C;const r=new a0(e),i=e.rows,o=e.cols;p(Bi,i>=1,`invalid rows: ${i}`),p(Bi,o>=1,`invalid cols: ${o}`),p(Bi,e.children,"no table children");const s=B("table",[],null),l=(C=e.colsWidth)!=null?C:new Array(e.cols).fill(0),c=B("colgroup",[],s);for(let E=0;E<r.colCount;E++){const A=B("col",[],c);l[E]&&(A.style.width=`${l[E]}px`)}const d=B("tbody",[],s);let h=0;for(let E=0;E<i;E++){const A=B("tr",[],d);for(let v=0;v<o;v++){const R=r.getCell({col:v,row:E});if(R.virtual)p(Bi,R.colSpan>1||R.rowSpan>1,"virtual cell should have colSpan or rowSpan");else{const L=e.children[h],M=B("td",[],A);R.colSpan>1&&(M.colSpan=R.colSpan),R.rowSpan>1&&(M.rowSpan=R.rowSpan);const U=e[ju(L)];U&&z(M,U),v===0&&e.hasColTitle&&z(M,My.COL_TITLE_ITEM),n.createChildContainer(t,M,L),h+=1}}}return p(Bi,h===e.children.length,"container count mismatch"),s.style.width=`${l.reduce((E,A)=>A+E,0)}px`,e.noBorder&&z(s,"no-border"),e.chart&&z(s,"editor-table-chart"),e.isStripeStyle&&z(s,"stripe"),e.hasRowTitle&&z(s,"row-title"),e.hasColTitle&&z(s,"col-title"),s}function Y$(n,t,e,r,i){p(Bi,i.type==="table","not table data"),p(Bi,ft(e)===t[t.length-1].containerId,"invalid path");const o=i,s=Hs(r,"div");try{const l=B("div",[],null);l.setAttribute("data-type","table-content");const c=sR(n,t,o);c.classList.add("drag-preview-element"),l.appendChild(c);const d=n.getComponentOptions("table");Zy(n),nk(n),tR(n,"create"),oR(n),d!=null&&d.hideCellMenu||eR(n),fT(n,bC);const h=n.addCustom(bi(r),()=>LF());h.init({parentElement:s,childElement:l,safeRightSpace:50,safeLeftSpace:40,parentContainer:Xt(e)?n.scrollContainer:e,locatingContainer:Xt(e)?(d==null?void 0:d.locatingContainer)||n.parent:e,paddingLeft:za+Hu,paddingTop:za+Hu,paddingBottom:Hu/2,paddingRight:Hu/2,barFloatWindowBottom:d==null?void 0:d.barFloatWindowBottom,allowScrollBarFixed:d==null?void 0:d.allowScrollBarFixed,isSetScale:d==null?void 0:d.isSetScale});const C=iR(n);h.on("scroll",C.handleReset),h.on("resize",C.handleReset),setTimeout(()=>{aF(n,r)})}catch{const c=`invalid table data: ${JSON.stringify(o)}`;Bi.error(c);const d=B("div",["error"],s);d.innerText=c}return s}function J$(n,t,e){p(Bi,e.type==="table","not table data");const r=e,i=Ot(t);try{const o=Ve(t),s=Vo(t),l=sR(n,s,r);l.classList.add("drag-preview-element"),o.insertAdjacentElement("afterend",l),o.remove();const c=n.getComponentOptions("table");Zy(n),nk(n),tR(n,"update"),oR(n),c!=null&&c.hideCellMenu||eR(n),bC(n,t)}catch{const s=`invalid table data: ${JSON.stringify(r)}`;Bi.error(s);const l=B("div",["error"],i);l.innerText=s}}function Z$(n,t){let e,r,i=!1;if([...t].every(E=>E==="|")?(r=t.length,e=Array(r).fill(""),i=!0):(e=Mg(t,"|").split("|"),r=e.length),r<2)return null;const o=3,s=r,l=[];for(let E=0;E<3;E++)e.forEach(A=>{l.push(no(n.doc,E===0?A:""))});const c=Array(s).fill(TC),d=l[i?0:s],h=n.doc.getContainerBlocks(d)[0].id;return{blockData:{id:Z(),type:"table",rows:o,cols:s,children:l,colsWidth:c},focusBlockId:h}}function tH(n,t){const e=t.rows,r=t.cols;if(e<1||r<1)return null;const i=[];for(let d=0;d<e;d++)for(let h=0;h<r;h++)i.push(no(n.doc));const o=Array(r).fill(TC),s=i[0],l=n.doc.getContainerBlocks(s)[0].id;return{blockData:{id:Z(),type:"table",rows:e,cols:r,children:i,colsWidth:o},focusBlockId:l}}const sE=I("get-selected-containers");function lR(n,t,e,r){p(sE,e.blockId===r.blockId,"only allow select in single table block"),p(sE,st(t)===e.blockId,"only allow select in single table block");const i=It.fromBlock(t),o=i.getCellByContainerId(e.childContainerId),s=i.getCellByContainerId(r.childContainerId);if(e.custom===void 0||r.custom===void 0)return i.getCells(o,s).map(L=>i.getCellContainer(L));const{fromCol:l,toCol:c,fromRow:d,toRow:h}=Gr(t,e,r),C=new Set,E=[];return i.sub({row:d,col:l},{row:h,col:c}).forEach(v=>{v.forEach(R=>{const L=i.getCellByContainerId(R.containerId);L.col<l||L.row<d||L.col+L.colSpan-1>c||L.row+L.rowSpan-1>h||C.has(R.containerId)||(C.add(R.containerId),E.push(L.container))})}),E}function eH(n,t,e){p(sE,t.blockId===e.blockId,"only allow select in single table block");const r=n.getBlockById(t.blockId);return lR(n,r,t,e)}const aR=I("table-selection-to-doc");function nH(n,t){const{start:e,end:r,block:i}=t,o=St(i);p(aR,o==="table",`invalid block type: ${o}`);const s=n.getBlockData(i);if(e.isSimple()&&r.isSimple())return qo(n.editorBlocks,n.doc.toJSON(),s);p(aR,!e.isSimple()&&!r.isSimple(),"invalid block pos type");const l=It.fromBlock(i),{fromCol:c,toCol:d,fromRow:h,toRow:C}=Gr(i,e,r),E={},A=[],v=n.doc.toJSON();let R={};l.sub({row:h,col:c},{row:C,col:d}).forEach((it,at)=>{it.forEach((xt,Mt)=>{const Bt=xt.containerId;if(A.indexOf(Bt)!==-1)return;A.push(Bt);let le;if(xt.virtual){const be=l.getCellByContainerId(xt.containerId),Kn=c+Mt;let Ii=be.col+be.colSpan-1;Ii>d&&(Ii=d);const Rn=Ii-Kn+1;Rn>1&&(E[`${Bt}_colSpan`]=Rn);const mn=h+at;let Di=be.row+be.rowSpan-1;Di>C&&(Di=C);const go=Di-mn+1;go>1&&(E[`${Bt}_rowSpan`]=go),le=eo()}else{if(le=np(n.editorBlocks,v,Bt),xt.col+xt.colSpan>d+1){const be=d-xt.col+1;be>1&&(E[`${Bt}_colSpan`]=be)}else xt.colSpan>1&&(E[`${Bt}_colSpan`]=xt.colSpan);if(xt.row+xt.rowSpan>C+1){const be=C-xt.row+1;be>1&&(E[`${Bt}_rowSpan`]=be)}else xt.rowSpan>1&&(E[`${Bt}_rowSpan`]=xt.rowSpan)}const{root:te,...kn}=le.blocks;R={...R,...kn,[Bt]:te}})});const M=Xu(Ve(i)).slice(c,d+1);return{blocks:{root:[{id:Z(),type:o,children:A,colsWidth:M,rows:C-h+1,cols:d-c+1,...E}],...R},meta:{},comments:{}}}const rH=I("ajust-selection-pos");function iH(n,t){if(t.top===0)return!0;for(let e=t.left;e<=t.right;e++)if(n[t.top-1][e]===n[t.top][e])return!1;return!0}function oH(n,t){if(t.left===0)return!0;for(let e=t.top;e<=t.bottom;e++)if(n[e][t.left-1]===n[e][t.left])return!1;return!0}function sH(n,t){if(t.bottom===n.length-1)return!0;for(let e=t.left;e<=t.right;e++)if(n[t.bottom][e]===n[t.bottom+1][e])return!1;return!0}function lH(n,t){if(t.right===n[0].length-1)return!0;for(let e=t.top;e<=t.bottom;e++)if(n[e][t.right]===n[e][t.right+1])return!1;return!0}function aH(n,t,e){const r=t.col,i=t.row,o=e.col,s=e.row,l={left:r,top:i,right:o,bottom:s};let c=!1;do{if(c=!1,!iH(n,l)){l.top--,c=!0;continue}if(!oH(n,l)){l.left--,c=!0;continue}if(!sH(n,l)){l.bottom++,c=!0;continue}if(!lH(n,l)){l.right++,c=!0;continue}}while(c);return l}function cH(n,t,e,r){if(e.custom!==void 0||r.custom!==void 0)return{anchor:e,focus:r};const i=It.fromBlock(t),o=i.map(F=>F.containerId),s=i.getCellByContainerId(e.childContainerId),l=i.getCellByContainerId(r.childContainerId),c=Math.min(s.row,l.row),d=Math.max(s.row,l.row),h=Math.min(s.col,l.col),C=Math.max(s.col,l.col),E=aH(o,{row:c,col:h},{row:d,col:C}),A=i.getCell({row:E.top,col:E.left}),v=i.getCell({row:E.bottom,col:E.right}),R=i.getCell({row:E.top,col:E.right}),L=i.getCell({row:E.bottom,col:E.left});let M,U;return s.row<=l.row?s.col<=l.col?(M=A,U=v):(M=R,U=L):s.col<l.col?(M=L,U=R):(M=v,U=A),rH.debug(`move ${M.col}, ${M.row}, -> ${U.col}, ${U.row}`),{anchor:xe(t,M.containerId),focus:xe(t,U.containerId)}}function cR(n,t,e){if(e.isSimple())return[Ve(t).getBoundingClientRect()];const r=Ve(t),i=r.getBoundingClientRect(),{fromCol:o,fromRow:s,toCol:l,toRow:c}=Gr(t,e.start,e.end),d=Xu(r),h=d.slice(0,o).reduce((R,L)=>R+L,0),C=h+d.slice(o,l+1).reduce((R,L)=>R+L,0),E=qk(r);let A=E.slice(0,s).reduce((R,L)=>R+L,0);const v=A+E.slice(s,c+1).reduce((R,L)=>R+L,0);if(s===0){const R=F$(n,t);A-=R}return[new DOMRect(i.left+h,i.top+A,C-h,v-A)]}I("table-size");const uH=40;function P0(n){const t=n.querySelector("td");if(!t)return 0;const e=window.getComputedStyle(t),r=Number.parseInt(e.borderLeft,10),i=Number.parseInt(e.borderRight,10);return(r+i)/2}function fH(n,t,e){const r=n1(n,e.container);return r!==void 0?r+P0(t):uH*e.colSpan-P0(t)}function dH(n,t,e,r){let i=0;const o=e.colCount;for(let s=0;s<o;s++){const l=e.getCell({col:s,row:r});if(l.virtual)continue;let c=fH(n,t,l);const d=Jv(l.container,{withPadding:!0});d&&d>c&&(c=d),i+=c+P0(t)}return i}function hH(n,t){const e=Ve(t),r=It.fromTable(e);let i=0;for(let s=0;s<r.rowCount;s++)i=Math.max(i,dH(n,e,r,s));const o=P0(e);return i+=o,i}const fo=I("table-creator");async function mH(n,t){return n.undoManager.runInGroup(()=>{var c,d;const e=t.item,r=(c=e.colCount)!=null?c:5,i=(d=e.rowCount)!=null?d:3,o=tH(n,{cols:r,rows:i});if(!o)return null;const{blockData:s,focusBlockId:l}=o;return n.insertBlock(t.containerId,t.blockIndex,s,Te(n,l,0))})}class gH{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",t=>{this.closeable=t});m(this,"destroy",()=>{this.closeable=null});m(this,"getTableCreatorCellId",(t,e)=>`table-creator-cell-${t}-${e}`);m(this,"handleTableCreatorClick",t=>{var E,A;t.preventDefault(),t.stopPropagation();const e=t.target;p(fo,e instanceof HTMLElement,"invalid event target");const r=e.closest(".table-creator");p(fo,r,"no table creator");const i=r.querySelectorAll(".active");if(i.length===0)return;const s=i[i.length-1].id;p(fo,s,"no cell id");const l="table-creator-cell-";if(!s.startsWith(l))return;const d=s.substring(l.length).split("-");p(fo,d.length===2,"invalid cell id");const h=Number.parseInt(d[0],10)+1,C=Number.parseInt(d[1],10)+1;fo.debug(`${h}, ${C}`),this.colCount=C,this.rowCount=h,(E=this.closeable)==null||E.click(this,this.element),(A=this.closeable)==null||A.close("clickItem"),this.handleTableCreatorLeave()});m(this,"handleTableCreatorLeave",()=>{for(let t=0;t<9;t++)for(let e=0;e<9;e++){const r=this.getTableCreatorCellId(t,e),i=document.getElementById(r);i&&ot(i,"active")}});m(this,"handleTableCreatorCellEnter",t=>{const e=t.target;p(fo,e instanceof HTMLElement,"invalid event target");const r=e.id,i="table-creator-cell-";p(fo,r.startsWith(i),"invalid cell id");const s=r.substring(i.length).split("-");p(fo,s.length===2,"invalid cell id");let l=Number.parseInt(s[0],10),c=Number.parseInt(s[1],10);l===0&&c===0&&(l=-1,c=-1);for(let d=0;d<9;d++)for(let h=0;h<9;h++){const C=this.getTableCreatorCellId(d,h),E=document.getElementById(C);p(fo,E,"no cell"),d<=l&&h<=c?z(E,"active"):ot(E,"active")}});this.element=this.createTableCreatorElement()}createTableCreatorElement(){const t=B("div",["table-creator"],null),e=(r,i,o)=>{const s=B("div",["table-creator-cell"],r);return s.id=this.getTableCreatorCellId(i,o),s};t.addEventListener("click",this.handleTableCreatorClick),t.addEventListener("mouseleave",this.handleTableCreatorLeave);for(let r=0;r<9;r++){const i=B("div",["table-creator-row"],t);for(let o=0;o<9;o++)e(i,r,o).addEventListener("mouseenter",this.handleTableCreatorCellEnter)}return t}}function pH(){return new gH}function CH(n){const t=/[\u4e00-\u9fff\u3040-\u309f\u30a0-\u30ff\uac00-\ud7af]/g,e=n.match(t);return e?e.length:0}function uR(n){const t=CH(n);return n.length+t}function EH(n,t,e=[]){let r=0;if(!e||e.length===0)return r;for(let i=n;i<n+t;i+=1)r+=e[i]||0;return r}function xH(n,t){const e=uR(n),r=t-e;return r>0?n+" ".repeat(r):n}function AH(n,t,e,r,i){var l;const o=t,s=new a0(o);if(r==="markdown"||r==="text"){const c=M=>e.blocks[M].map((G,W)=>r==="markdown"?Ah(n,G,e,[...i,{containerId:M,blockIndex:W}]):xh(n,G,e,[...i,{containerId:M,blockIndex:W}])),d=M=>c(M).join(" ").replace(/\n/g," ").trim(),h=new Map,C=new Map;for(let M=0;M<s.colCount;M++){let U=0;for(let F=0;F<s.rowCount;F++){const G=s.getCell({row:F,col:M});let W="";G.virtual||(W=d(G.containerId)),h.set(`${F},${M}`,W),U=Math.max(U,uR(W))}C.set(M,U)}const E=M=>{const U=h.get(`${M.row},${M.col}`)||"",F=C.get(M.col)||0;return xH(U,F)};if(r==="text"){const M=[];for(let U=0;U<s.colCount;U++){const F=E({row:0,col:U});M.push(F)}for(let U=1;U<s.rowCount;U++)for(let F=0;F<s.colCount;F++){const G=E({row:U,col:F});M.push(G)}return M.join(`
|
|
643
643
|
`)}const A=[];let v="|",R="|";for(let M=0;M<s.colCount;M++){const U=E({row:0,col:M});v+=` ${U} |`;const F="-".repeat((C.get(M)||0)+2);R+=`${F}|`}A.push(v),A.push(R);for(let M=1;M<s.rowCount;M++){let U="|";for(let F=0;F<s.colCount;F++){const G=E({row:M,col:F});U+=` ${G} |`}A.push(U)}return`${A.join(`
|
|
644
644
|
`)}
|
|
645
645
|
`}if(r==="html"){const c=C=>e.blocks[C].map((v,R)=>G1(n,v,e,[...i,{containerId:C,blockIndex:R}])).join(`
|
|
@@ -663,7 +663,7 @@ ${s}
|
|
|
663
663
|
${l}`:`<p><pre><code>${Ud(s)}</code></pre></p>
|
|
664
664
|
<p>${Ud(l)}</p>`}function Dj(n,t){dT(n,BR)}const mE={blockType:"code",blockKind:"complex",createBlockContent:Cj,getBlockTextLength:Ej,getRangeFromPoint:xj,moveCaret:Aj,getCaretRect:bj,updateSelection:vj,clearSelection:Bj,getChildContainers:Tj,getNextContainer:yj,getSelectedContainers:kj,convertFrom:HH,handleBlockElementUpdated:Rj,getOptions:Sj,getBlockProperties:Lj,convertTo:Ij,handleDeleteBlock:Dj},gE={...On,blockType:"code-line"};class _j{constructor(t){m(this,"handleSelectionChange",()=>{const t=this.editor.selection;if(!t.range.isCollapsed())return;const e=t.focusedBlock;if(!ef(this.editor,e))return;const r=e,i=t.range.focus.offset,o=u3(this.editor,r,i,"code-caret");o.scrollIntoView({block:"nearest"}),setTimeout(()=>{o.remove(),this.editor.selection.caret.update()})});this.editor=t,t.addListener("selectionChanged",this.handleSelectionChange)}destroy(){this.editor.removeListener("selectionChanged",this.handleSelectionChange)}}function Mj(n){if(!n.isWritable())return!1;const t=n.getFocusedBlock();if(!!ef(n,t)){if(n.selection.range.isCollapsed()){const e=n.selection.range.start;return n.insertTextToBlock(t,e.offset," "),!0}return n.undoManager.runInGroup(()=>{hi(n).forEach(r=>{n.insertTextToBlock(r.block,0," ")})}),!0}}function Uj(n){if(!n.isWritable())return!1;const t=n.getFocusedBlock();if(!ef(n,t))return;const e=[" "," "];return n.undoManager.runInGroup(()=>{hi(n).forEach(i=>{const o=fe(n.getBlockText(i.block));for(let s=0;s<e.length;s++){const l=e[s];if(o.startsWith(l)){n.deleteTextFromBlock(i.block,0,l.length);break}}})}),!0}function Oj(n){const t=n.getFocusedBlock(),e=rt(t);if(Xt(e))return;const r=et(e);if(!r||St(r)!=="code")return;const i=n.selection.range;if(!!i.isSimple()&&!H5(e,i))return Sh(n,e),!0}const Nj={Tab:Mj,"Shift+Tab":Uj,"CtrlOrCmd+A":Oj},nf=I("code-text-decorate");class K0{decorateText(t,e,r){if(p(nf,e.length>0,"invalid path"),e.length===1)return{};const i=e[e.length-2];if(t.doc.getBlockData(i.containerId,i.blockIndex).type!=="code")return{};const s=r;if(s.length===0)return{};const l=fe(s),c=t.doc.getBlockData(i.containerId,i.blockIndex),h=(R=>{if(!R)return ia.default.languages.plain;const L=R.replace(/\s/g,"").toLocaleLowerCase();return ia.default.languages[L]||ia.default.languages.plain})(c.language),C=ia.default.tokenize(l,h),E=(R,L)=>{if(p(nf,R,"no token"),typeof R=="string")return[{insert:R,attributes:gt.default(L)}];p(nf,R instanceof ia.default.Token,"invalid token type");const M=R.content,U=gt.default(L);return U[`style-code-${R.type}`]=!0,typeof M=="string"?[{insert:M,attributes:U}]:Array.isArray(M)?M.filter(W=>W.length).map(W=>E(W,U)).flat():(p(nf,M instanceof ia.default.Token,"invalid token"),E(M,U))},v=C.map(R=>E(R,{})).flat();return p(nf,un(v)===un(s),"failed to highlight code, text length mismatch"),{text:v}}}const Pj={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"}},Fj={code:{title:"Code",abstract:"Code",wrap:"Wrap",copy:"Copy",caption:"Caption",search:"Search",copySuccess:"Copied successfully"}},Kj={code:{title:"\u30B3\u30FC\u30C9",abstract:"\u30B3\u30FC\u30C9",wrap:"\u6298\u308A\u8FD4\u3059",copy:"\u8907\u88FD",caption:"\u4F8B\u8A3C\u3059\u308B",search:"\u30AD\u30FC\u30EF\u30FC\u30C9\u3067\u691C\u7D22",copySuccess:"\u30B3\u30D4\u30FC\u3055\u308C\u307E\u3057\u305F"}};D.mergeLang({"zh-CN":Pj,"en-US":Fj,"ja-JP":Kj});function Vj(n,t,e,r){const i=n.getBlockByIndex(t,e);if(dt(n,i)!==r)return!1;const o=fe(n.getBlockText(i));if(![...o].every(h=>h==="|")||o.length<3||!n.editorBlocks.hasBlock("table"))return!1;const s=n.editorBlocks.getBlockClass("table");if(!s.convertFrom)return!1;const l=s.convertFrom(n,i,{offset:r});if(!l)return!1;const{blockData:c,focusBlockId:d}=l;return c?(n.undoManager.runInGroup(()=>{var C;const h=n.insertBlock(t,e,c,Te(n,d!=null?d:c.id,0));n.deleteBlock(i),(C=l.onConverted)==null||C.call(l,n,h)}),!0):!1}const $j={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\]/i,data:{embedType:"toc"}}},Hj={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 V0(n,t,e,r,i){const o=n.getContainerById(t);if(!Xt(o)){const s=et(o);if(s&&qr(s))return!0}return!1}function TR(n,t,e,r,i){if(V0(n,t))return!1;if(i==="enter"&&Vj(n,t,e,r))return!0;const o=n.getBlockByIndex(t,e),s=fe(_n(n.getBlockText(o),r).left),l=i==="enter"?$j:Hj;for(const[,c]of Object.entries(l)){if(!s.match(c.reg))continue;return!!n.undoManager.runInGroup(()=>{var v;const h=Wd(n,o,c.blockType,{offset:r,data:c.data});if(!h)return null;const{blockData:C,focusBlockId:E}=h;if(!C)return null;const A=n.insertBlock(t,e,C,Te(n,E!=null?E:C.id,0));return n.deleteBlock(o),(v=h.onConverted)==null||v.call(h,n,A),{newBlock:A,focusBlockId:E}})}return!1}function jj(n,t,e,r){const i=n.getBlockByIndex(t,e);return n.getBlockString(i,{boxReplacement:" "}).substring(0,r)!==">"?!1:(n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(i,0,r+1),n.updateBlockData(i,{quoted:!0},Te(n,i,0))}),!0)}const zj={"#":1,"##":2,"###":3,"####":4,"#####":5,"######":6,"#######":7,"########":8};function Gj(n,t,e,r){const i=n.getBlockByIndex(t,e),o=n.getBlockString(i,{boxReplacement:" "}).substring(0,r);let s=zj[o];if(!s)return!1;const l=n.getBlockData(i).heading;return l&&l==s&&(s=null),n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(i,0,r+1),n.updateBlockData(i,{heading:s},Te(n,i,0))}),!0}function Wj(n,t,e,r){return!!(Gj(n,t,e,r)||jj(n,t,e,r))}const qj=I("match-text-style");function Xj(n,t){if(n.length<t.length*2+1||!n.endsWith(t)||n.substring(0,n.length-1).endsWith(t))return-1;const e=n.substring(0,n.length-t.length),r=e.lastIndexOf(t);return r===-1?-1:r===0?0:e.substring(r-1).startsWith(t)?-1:r}const Qj={"*":{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 Yj(n,t,e,r){var E,A;const i=n.getBlockByIndex(t,e),o=n.getBlockText(i),{left:s}=_n(o,r),l=O1(s),c=un(s)-l.length,d=Object.entries(Qj);for(const[v,R]of d){const L=Xj(l,v);if(L===-1)continue;const M=c+L,U=r,F=v.length,G=fe(Xe(o,M+F,U-M-F*2).middle);if(R.type==="style"){const W={};R.styles.forEach(at=>{W[at]=!0});const it=Zs(G,W);n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(i,M,U-M),n.insertTextToBlock(i,M,it)})}else if(R.type==="box")try{const W=(A=(E=n.editorBoxes.getBoxClass(R.boxType)).convertFrom)==null?void 0:A.call(E,n,G);if(!W)continue;n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(i,M,U-M),n.insertBoxToBlock(i,M,W)})}catch(W){qj.warn(`failed to convert to box, ${W.message}`);continue}return!0}const h=/\[([^\]]+)\]\((https?:\/\/\S+)\)\s*$/,C=l.match(h);if(C){const v=C.index,R=C[1],L=C[2],M=v,U=r,G={...Aa(o,M),link:L};return n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(i,M,U-M),n.insertTextToBlock(i,M,Zs(R,G))}),!0}return!1}class $0{handleAfterInsertText(t,e,r,i,o){if(o===" "){if(V0(t,e))return!1;if(Wj(t,e,r,i)||Yj(t,e,r,i))return!0}return!1}handleBeforeKeyDown(t,e){if(!t.selection.range.isSimple())return!1;const{containerId:i,blockIndex:o,offset:s}=t.getTextPosition();if(nt(t,t.getBlockByIndex(i,o))){if(ai(e,"Enter")){if(TR(t,i,o,s,"enter"))return!0}else if(ai(e,"Space")&&TR(t,i,o,s,"space"))return!0}return!1}}const Jj={"en-US":{placeholder:{default:"Type / for commands",heading:"Heading {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"}}};D.mergeLang(Jj);function rf(n,t){const e=Wo(n,t);return!!(nt(n,t)&&e.text&&un(e.text)===0&&!t.querySelector(".inputting-insertion"))}function yR(n,t){var r;Ot(t).removeAttribute("data-content-placeholder"),(r=t.querySelector("[data-type=block-tools] .block-placeholder-container"))==null||r.remove()}function of(n,t,e){var i;if(yR(n,t),!rf(n,t))return;const r=Ot(t);if(typeof e=="string")r.setAttribute("data-content-placeholder",e);else{const o=re(t),s=(i=o.querySelector(".block-placeholder-container"))!=null?i:B("div",["block-placeholder-container"],o);s.innerHTML="",s.appendChild(e)}}function Zj(n){const t=n.getAttribute("data-style-heading");return t?D.t("placeholder.heading",{heading:t}):n.getAttribute("data-style-quoted")?D.t("placeholder.quote"):null}function tz(n){const t=n.getAttribute("data-list-type");return t?t==="ordered"||t==="unordered"?D.t("placeholder.list"):D.t("placeholder.mention"):null}function kR(n){switch(St(n)){case"text":return Zj(n);case"list":return tz(n);default:return null}}function ez(n){if(dr(n))return!1;const t=et(rt(n));return t?St(t)==="code":!1}function nz(n){return!dr(n)}function rz(n,t){var h,C;const e=n.selection.focusedBlock,r=St(e),i=t.contentPlaceholder||D.t("placeholder.default");let o=i;if(r&&iu(n,r)&&e){if(!n.isBlockWritable(e)||ez(e))return;nz(e)&&(o=D.t("placeholder.common.contentInTable")),o=(h=kR(e))!=null?h:o}const s=n.getFirstBlock(),l=t.hideTitle?s:qt(s);if(!l)return;const c=qt(l);if(c&&!t.addPlaceholderToAllCurrentEmptyBlock)return;if(!c&&rf(n,l)){of(n,l,(C=kR(l))!=null?C:i);return}const d=n.getFocusedBlock();!rf(n,d)||d===s&&!t.hideTitle||of(n,d,o)}function iz(n,t){var i,o;const e=n.getFirstBlock(),r=Ot(e);rf(n,e)?(r.setAttribute("data-title-placeholder",(i=t.titlePlaceholder)!=null?i:D.t("placeholder.title")),r.setAttribute("data-title-placeholder-readonly",(o=t.readonlyTitlePlaceholder)!=null?o:"")):(r.removeAttribute("data-title-placeholder"),r.removeAttribute("data-title-placeholder-readonly"))}function oz(n){n.rootContainer.querySelectorAll("[data-content-placeholder").forEach(t=>{t.removeAttribute("data-content-placeholder")}),n.rootContainer.querySelectorAll("[data-type=block-tools] .block-placeholder-container").forEach(t=>{t.remove()})}function sz(n,t){oz(n),n.selection.range.isCollapsed()&&(t.hideTitle||iz(n,t),rz(n,t))}const Pct="";function lz(n){for(let t=0;t<n.length;t++){const e=n[t];if(e.attributes&&Object.keys(e.attributes).length)return!0}return!1}const RR=I("enforce-title");class pE{constructor(t,e={headingLevel:1}){m(this,"handleSelectionChange",t=>{setTimeout(()=>{this.applyPlaceholder(t)})});m(this,"reload",t=>{this.handleChanged(t),this.applyPlaceholder(t)});this.options=e,this.handleChanged(t),this.applyPlaceholder(t),t.addListener("selectionChanged",this.handleSelectionChange),setTimeout(()=>{t.addListener("load",this.reload)})}destroy(t){t.removeListener("selectionChanged",this.handleSelectionChange),t.removeListener("load",this.reload)}handleBeforeKeyDown(t,e){if(!t.selection.range.isSimple())return!1;const{containerId:i,blockIndex:o,offset:s}=t.getTextPosition();if(!this.isDocumentTitleBlock(i,o)||!ai(e,"Enter"))return!1;let l=!1,c=null;Lr(t.rootContainer)===2&&(c=zi(t.rootContainer,1),dt(t,c)===0&&(l=!0));const d=t.getFirstBlock();return t.undoManager.runInGroup(()=>{t.breakTextBlock(d,s,{forceInsertAfter:!0}),l&&c&&t.deleteBlock(c)}),!0}handleChanged(t){var e,r;try{const i=t.doc.getContainerBlocks(ft(t.rootContainer));p(RR,i.length>0,"root container is empty");const o=i[0];if(o.type!=="text"&&!this.options.hideTitle){const s=pi("",{heading:(e=this.options.headingLevel)!=null?e:1});t.insertBlock(ft(t.rootContainer),0,s,t.selection.range.toDocRange()).setAttribute("data-document-title","");return}if(!this.options.hideTitle){p(RR,o.text,"invalid text block");const s=t.getBlockById(o.id);if(lz(o.text)||o.quoted||o.heading!==this.options.headingLevel){const l=t.getBlockString(s),c=pi(l,{heading:(r=this.options.headingLevel)!=null?r:1,quoted:!1}),d=t.selection.focusedBlock;let h=t.selection.range;const C=t.insertBlock(ft(t.rootContainer),0,c);C.setAttribute("data-document-title",""),d===s&&(h=Te(t,c.id,dt(t,C))),Bh(t,s,h)}else s.setAttribute("data-document-title","")}if(i.length>1||this.options.hideTitle)return;t.insertTextBlock("",ft(t.rootContainer),1,{newRange:t.selection.range.toDocRange()})}finally{this.applyPlaceholder(t)}}handleRemoteChanged(t){setTimeout(()=>{this.applyPlaceholder(t)})}handleUpdateCompositionText(t){this.applyPlaceholder(t)}applyPlaceholder(t){var e,r;!((e=this.options)!=null&&e.titlePlaceholder)&&!((r=this.options)!=null&&r.contentPlaceholder)||sz(t,this.options)}isDocumentTitleBlock(t,e){return t==="root"&&e===0&&!this.options.hideTitle}}function Xr(n){return St(n)==="embed"&&Ge(n)==="image"}async function wR(n){return new Promise((t,e)=>{const r=new Image;r.onload=()=>{t({width:r.naturalWidth,height:r.naturalHeight})},r.onerror=e,r.src=n})}async function az(n){const t=await fa(n);return wR(t)}function ls(n){return typeof n=="number"}const cz=I("image-data"),sf=1e3,SR=400,uz=10;function oc(n){return n.src.startsWith("empty:")||!n.src}function fz(n){return n.src.startsWith("http:")||n.src.startsWith("https:")}function LR(n){return`${kd.default(n)}_width`}function IR(n){return`${kd.default(n)}_height`}function DR(n){return`${n}_flex`}function _R(n){let t=n.getBoundingClientRect().width;return t-=Number.parseFloat(window.getComputedStyle(n).paddingLeft)+Number.parseFloat(window.getComputedStyle(n).paddingRight),t}function sc(n){if(n.every(i=>typeof i.flex=="number"&&i.flex))return;const t=100,r=n.map(i=>{const o=i.width==="auto"?sf:i.width,s=i.height==="auto"?o/t:i.height/t;return o/s}).reduce((i,o)=>i+o,0);n.forEach(i=>{const o=i.width==="auto"?sf:i.width,s=i.height==="auto"?o/t:i.height/t,l=o/s;i.flex=l/r})}function lc(n){const t=(i,o)=>{i||(i=`empty:${o}`);const s=LR(i),l=IR(i),c=DR(o);let d=n[s],h=n[l],C=n[c];return typeof d=="string"&&(d=Number.parseInt(d,10)),typeof h=="string"&&(h=Number.parseInt(h,10)),typeof C=="string"&&(C=Number.parseInt(C,10)),{src:i,width:d!=null?d:"auto",height:h!=null?h:"auto",flex:C,virtualSize:!d||!h}};let e=[];const r=n.src;return Array.isArray(r)?e=r.map(t):typeof r=="string"&&(e=r.split("|").map(t)),sc(e),e}function Qr(n){const t=n.embedData;return lc(n.embedData).length>1?100:t.widthPercent}function dz(n,t,e,r){const i=lc(t.embedData);if(i.length>1||r)return"100%";const o=Qr(t),s=n.rootContainer.getBoundingClientRect().width;if(o){const l=_R(e);return`${Math.min(s*o/100,l)}px`}return ls(i[0].width)?`${i[0].width}px`:"auto"}function dn(n,t){const r={src:n.map(i=>i.src).join("|"),widthPercent:t};return n.forEach((i,o)=>{const s=i.src||`empty:${o}`,l=LR(s);l&&ls(i.width)&&(r[l]=i.width);const c=IR(s);c&&ls(i.height)&&(r[c]=i.height),p(cz,i.flex,"no image flex");const d=DR(o);r[d]=i.flex}),r}function hz(n,t,e,r){const i=lc(t.embedData),o=i.length===1?n.rootContainer:e;if(i.length===1&&r)return`${SR}px`;if(i.some(h=>h.height==="auto"))return"auto";const s=Qr(t);if(!s){if(i.length!==1||ls(i[0].width))return"";const C=i[0].height;return C==="auto"?"auto":`${C}px`}let l=o.getBoundingClientRect().width*(s/100);if(l-=Number.parseFloat(window.getComputedStyle(o).paddingLeft)+Number.parseFloat(window.getComputedStyle(o).paddingRight),o===n.rootContainer&&o!==e&&(l=Math.min(l,_R(e))),i.length===1){const h=i[0];if(h.virtualSize)return"";const C=h.width==="auto"?sf:h.width;return`${h.height/(C/l)}px`}l-=(i.length-1)*uz;const c=i.reduce((h,C)=>h+C.flex,0);let d=0;for(const h of i){const C=l*h.flex/c,E=h.width==="auto"?sf:h.width,A=C/E*h.height;d=Math.max(A,d)}return`${d}px`}function mz(n){return n.reduce((e,r)=>e+r.flex,0)}function gz(n,t){B("div",["resize-gripper",t],n).setAttribute("data-resize-type",t)}function CE(n){return re(n).querySelector(".block-resizer")}function pz(n){const t=CE(n);t&&ot(t,"active")}function MR(n,t,e){const r=n.getBoundingClientRect(),i=t.getBoundingClientRect(),o=i.top-r.top,s=i.left-r.left,l=i.width,c=i.height;e.style.top=`${o}px`,e.style.left=`${s}px`,e.style.width=`${l}px`,e.style.height=`${c}px`}function Cz(n,t,e,r){const i=CE(n);if(i)return z(i,"active"),MR(n,t,i),i;const o=re(n),s=B("div",["block-resizer"],o);return MR(n,t,s),e.resize.forEach(l=>{gz(s,l)}),s.addEventListener("mousedown",r),z(s,"active"),s}function EE(n,t){const e=CE(n);if(!e||!ne(n,t))return;const r=n.getBoundingClientRect(),i=t.getBoundingClientRect(),o=i.top-r.top,s=i.left-r.left,l=i.width,c=i.height;e.style.top=`${o}px`,e.style.left=`${s}px`,e.style.width=`${l}px`,e.style.height=`${c}px`}const Fct="",Ez=I("block-resizer");class lf extends Re.TypedEmitter{constructor(e,r){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",e=>{e.preventDefault(),e.stopPropagation();const r=this.getResizableElement();if(!r||e.button!==0)return;const i=e.target;if(!i||!(i instanceof HTMLElement))return;const o=i.getAttribute("data-resize-type");!o||(this.bindEvents(),this.startRect=r.getBoundingClientRect(),this.startPos=e,this.resizeType=o,Yc(window.getComputedStyle(i).cursor),this.block&&this.editor.selection.selectBlock(this.block,0))});m(this,"handleMouseMove",e=>{if(!this.startPos||!this.startRect||!this.resizeType||!this.getResizableElement()||!this.block)return;const i=e.x-this.startPos.x,o=e.y-this.startPos.y,s=this.startRect;let{top:l,left:c,right:d,bottom:h}=s;(this.resizeType==="bottom"||this.resizeType==="bottom-left"||this.resizeType==="bottom-right")&&(h+=o),(this.resizeType==="top"||this.resizeType==="top-left"||this.resizeType==="top-right")&&(l+=o),(this.resizeType==="left"||this.resizeType==="top-left"||this.resizeType==="bottom-left")&&(c+=i),(this.resizeType==="right"||this.resizeType==="top-right"||this.resizeType==="bottom-right")&&(d+=i);const C=d>c?d-c:0,E=h>l?h-l:0,A=new DOMRect(c,l,C,E);this.emit("resizing",this,A);const v=this.getResizableElement();v&&EE(this.block,v)});m(this,"handleMouseUp",e=>{if(e.button!==0)return;Yc(""),this.unbindEvents(),this.emit("resized",this);const r=this.getResizableElement();!r||!this.block||EE(this.block,r)});this.editor=e,this.options=r}enableResize(e,r){this.block=e,this.resizableElement=r,this.createResizer(),this.enabled=!0}disableResize(){!this.block||(pz(this.block),this.enabled=!1)}update(e,r){this.block=e,this.resizableElement=r,this.getResizableElement()&&this.enabled&&this.createResizer()}updateResizer(){const e=this.getResizableElement();e&&this.block&&EE(this.block,e)}getBlock(){return this.block}destroy(){}getResizableElement(){return this.resizableElement?this.resizableElement:this.block?Ot(this.block):null}createResizer(){const e=this.getResizableElement();!e||!this.block||(p(Ez,ne(this.block,e),"not a block child element"),Cz(this.block,e,this.options,this.handleMouseDown))}bindEvents(){document.addEventListener("mousemove",this.handleMouseMove),document.addEventListener("mouseup",this.handleMouseUp)}unbindEvents(){document.removeEventListener("mousemove",this.handleMouseMove),document.removeEventListener("mouseup",this.handleMouseUp)}}const xz=I("image-dom");function UR(n){return n.querySelector(".uploading-progress-mask")}function Az(n){const t=UR(n);if(t)return t;const e=B("div",["uploading-progress-mask"],n),r=B("div",["uploading-progress-bar"],e);return B("div",["uploading-progress-bar-value"],r),r}function bz(n){const e=Az(n).querySelector(".uploading-progress-bar-value");return p(xz,e,"no progress value"),e}function OR(n,t){const e=bz(n);e.style.width=`${t}%`}function vz(n){var t;(t=UR(n))==null||t.remove()}function af(n,t,e,r){const i=e!=null?e:n.findBlockById(t.id);if(!i)return;const o=r||rt(i),s=!!i.querySelector(".images > .image-container.error, .images > .image-container.empty "),l=dz(n,t,o,s),c=hz(n,t,o,s),d=Ot(i);l==="auto"?d.style.width=l:(d.style.maxWidth=l,d.style.width="100%");const h=i.querySelector(".images");!h||(h.style.height=c||"none")}function Bz(n){let t;return n.forEach((e,r)=>{r.toLocaleLowerCase()==="content-type"&&(t=e)}),t!=null?t:""}async function Tz(n){try{const t=await fetch(n,{credentials:"same-origin"}),e=await t.blob(),r=Bz(t.headers).toLocaleLowerCase();let i="";if(r){const s=yg.default[r].extensions;s&&s.length>0&&(i=s[0])}return new File([e],`${Date.now()}.${i}`,{type:r})}catch{return null}}function as(n,t){const e=typeof t=="string"?t:st(t);return n.getCustom(`image-${e}`)}function H0(n,t){if(!t||!(t instanceof Node))return null;const e=et(t);return e?as(n,e):null}function yi(n){return Array.from(n.querySelectorAll(".image-container"))}const xE=I("table-resize-drag-drop");class yz{constructor(t,e,r,i){m(this,"cursor","col-resize");m(this,"initWidths");this.editor=t,this.elem=e,this.data=r,this.mouseDownEvent=i;const o=this.data.block,l=as(this.editor,o).getImages(),c=this.data.splitterIndex;p(xE,c>=0&&c<l.length-1,`invalid splitter index: ${c}`);const h=yi(o).map(C=>C.getBoundingClientRect().width);this.initWidths=h}onDragStart(t,e,r){if(!this.editor.isWritable())return;const i=this.data.block;as(this.editor,i).setResizing(!0)}onDragging(t,e,r,i,o){const s=this.data.block,l=as(this.editor,s),c=gt.default(l.getImages()),d=this.data.splitterIndex;p(xE,d>=0&&d<c.length-1,`invalid splitter index: ${d}`);const h=this.initWidths[d],C=this.initWidths[d+1];if(h+C<100)return;let E=i;h+E<50&&(E=50-h),C-E<50&&(E=C-50);const R=[...this.initWidths];R[d]+=E,R[d+1]-=E;const L=yi(s);p(xE,L.length===c.length,"invalid image data");const M=R.reduce((G,W)=>G+W,0);for(let G=0;G<c.length;G++){const W=R[G]/M;c[G].flex=W,L[G].style.flexGrow=`${W}`}const U=gt.default(this.editor.getBlockData(s)),F=dn(c,Qr(U));U.embedData=F,af(this.editor,U,s,null)}onDragEnd(t,e,r,i,o){const s=this.data.block,l=as(this.editor,s),d=yi(s).map(h=>Number.parseFloat(h.style.flexGrow));l.updateFlex(d),l.setResizing(!1)}}function NR(n){var t;return!n||!(n instanceof HTMLElement)?null:Rt(n,"image-splitter")?n:(t=n.closest(".image-splitter"))!=null?t:null}function kz(n,t){var s;const e=NR(t.target);if(!e)return;const r=et(e);if(!r)return;as(n,r).setSelectedIndex(-1),n.selection.selectBlock(r,0);const i=Number.parseInt((s=e.getAttribute("data-index"))!=null?s:"",10);if(Number.isNaN(i)||typeof i!="number")return;const o={block:r,splitterIndex:i};_g(new yz(n,e,o,t))}function Rz(n,t){t.preventDefault(),t.stopPropagation();const e=NR(t.target);if(!e)return;const r=et(e);!r||as(n,r).resetFlex()}function wz(n,t,e,r){const i=B("div",["image-splitter"],e);B("div",["image-splitter-indicator"],i),i.setAttribute("data-index",`${r}`),n.domEvents.addEventListener(i,"mousedown",kz),n.domEvents.addEventListener(i,"dblclick",Rz)}const Sz=I("image-item");function PR(n){return!n||!(n instanceof Node)?null:et(n)}function FR(n){const t=PR(n);return t?yi(t):[]}function AE(n){if(!n||!(n instanceof Node))return null;const t=n instanceof Element?n:n.parentElement;if(!t)return null;const e=t.closest(".image-container");return e||null}function cf(n){const t=AE(n);return t?FR(n).indexOf(t):-1}async function Lz(n,t){const e=H0(n,t.target);if(!e)return;const r=cf(t.target);if(r===-1)return;const i=t.target;if(!(i instanceof HTMLImageElement))return;const o=e.getImages()[r];if(oc(o)||n.readonly||!e.isAutoFix()||(setTimeout(()=>{e.setAutoFix(!1)},400),(o.height==="auto"||o.width==="auto")&&e.fixImageSize(r,i),o.virtualSize&&e.fixImageSize(r,i),!o||!fz(o)||o.downloading))return;o.downloading=!0;const s=await Tz(o.src);s?e.replaceImage(r,s):Sz.warn(`failed to download image: ${o.src}`)}function Iz(n,t,e){if(t.querySelector(".load-error"))return;const i=e.src.startsWith("http:")||e.src.startsWith("https:"),o=B("div",["load-error"],t),s=B("div",["error-icon"],o);s.innerHTML=qp;const l=B("div",["error-message"],o);i?(l.innerHTML=D.t("image.load.remote.failed"),n.domEvents.addEventListener(o,"click",(c,d)=>{d.preventDefault(),d.target instanceof HTMLElement&&d.target.tagName==="A"&&window.open(e.src,"_blank")})):(l.innerHTML=D.t("image.load.failed"),n.domEvents.addEventListener(o,"click",(c,d)=>{d.preventDefault(),d.stopPropagation(),d.target instanceof HTMLElement&&d.target.tagName==="A"&&Uz(c,d.target)}))}function bE(n,t){setTimeout(()=>{if(ne(n.rootContainer,t)){const e=n.getBlockData(t);af(n,e,null,null)}})}function Dz(n,t){const e=H0(n,t.target);if(!e)return;const r=cf(t.target);if(r===-1)return;const i=e.getImages()[r];if(!i)return;const o=AE(t.target);if(!o)return;z(o,"error","error-load");const s=et(o);s&&bE(n,s),o.innerHTML="",Iz(n,o,i)}function _z(n,t,e){if(t.querySelector(".upload-error"))return;const i=B("div",["upload-error"],t),o=B("div",["error-icon"],i);o.innerHTML=qp;const s=B("div",["error-message"],i);s.innerHTML=D.t("image.upload.failed"),n.domEvents.addEventListener(i,"click",(l,c)=>{if(c.preventDefault(),!c.target||!(c.target instanceof Element)||c.target.tagName!=="A")return;const d=H0(l,c.target),h=cf(c.target);!d||h===-1||d.replaceImage(h,e)})}function KR(n,t,e,r,i){const o=yi(t)[e];!o||(z(o,"error","error-upload"),bE(n,t),o.innerHTML="",_z(n,o,i))}function VR(n,t,e,r,i,o,s){const l=B("div",["image-container"],e);if(l.setAttribute("data-src",r.src),s.length>1&&(l.style.flexShrink=`${r.flex}`,l.style.flexGrow=`${r.flex}`),o===i&&z(l,"active"),oc(r)){z(l,"empty");const d=B("div",["upload-image-icon"],l);return d.innerHTML=RT,l}const c=B("img",["editor-image"],l);if(c.src=n.doc.buildResourceUrl(r.src),n.domEvents.addEventListener(c,"load",Lz),n.domEvents.addEventListener(c,"error",Dz),r.src.startsWith("https:")||r.src.startsWith("http:")){const d=B("div",["image-warning"],l);d.innerHTML=Wp,d.setAttribute(`data-editor-tooltip-${n.clientId}`,D.t("image.load.remote.tooltip"))}return l}function Mz(n,t,e,r,i){const o=B("div",["images"],e);return r.forEach((s,l)=>{l>0&&wz(n,t,o,l-1),VR(n,t,o,s,l,i,r)}),r.length>1&&z(t,"multi"),o}function $R(n,t,e,r,i,o){const l=Array.from(t.querySelectorAll(".image-container"))[r];if(!l)return;const c=VR(n,t,null,e,r,i,o);l.insertAdjacentElement("beforebegin",c),l.remove(),bE(n,t)}function uf(n,t){return yi(n)[t]}function Uz(n,t){const e=PR(t);if(!e)return;const r=cf(t);if(r===-1)return;const i=H0(n,t);if(!i)return;const o=i.getImages()[r];$R(n,e,o,r,i.getSelectedIndex(),i.getImages())}function HR(n){var r;let t="image/*";const e=(r=n.getComponentOptions("image"))==null?void 0:r.allowedMedias;return e&&(t=e.map(i=>`.${i}`).join(",")),t}function jR(n,t){var s;const{maxSize:e,allowedMedias:r,callbacks:i}=(s=n.getComponentOptions("image"))!=null?s:{};if(e&&t.size>e){const l=new Error("image is too large");throw l.code="MaxMediaSize",i!=null&&i.onError&&(i==null||i.onError(n,l)),l}const o=eu(t.name);if(r&&!r.includes(o.toLowerCase())){const l=new Error(`media file is not allowed: ${o}`);throw l.code="NotAllowedFile",i!=null&&i.onError&&(i==null||i.onError(n,l)),l}}function zR(n){return n.startsWith("image/")}const GR=I("image-object");class Le{constructor(t,e){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(t,e)=>{const r=cf(e.target);if(r===-1)return;const i=this.images[r];oc(i)||this.setSelectedIndex(r)});m(this,"handleRootContainerResize",()=>{this.handleEditorResize(this.editor.rootContainer)});m(this,"handleEditorResize",t=>{if(this.isEmpty()||this.resizing)return;const e=this.editor.findBlockById(this.blockData.id);!e||rt(e)===t&&af(this.editor,this.blockData,e,null)});m(this,"handleResizing",(t,e)=>{const r=this.editor.findBlockById(this.blockData.id);if(!r)return;this.autoFix||this.setAutoFix(!0);const i=r.querySelector(".images");i.style.height="";const s=this.editor.rootContainer.getBoundingClientRect().width,l=r.getBoundingClientRect();let c=e.width>l.width?l.width:e.width;c<50&&(c=50);const d=c*100/s;this.blockData.embedData.widthPercent=d,af(this.editor,this.blockData,r,null)});m(this,"handleResized",t=>{const e=this.editor.findBlockById(this.blockData.id);if(!e)return;const r=dn(this.images,Qr(this.blockData));this.editor.updateEmbedData(e,r),this.blockResizer.enableResize(e)});m(this,"fixImageSizes",Me.default(()=>{const t=this.editor.findBlockById(this.blockData.id);if(!t)return;const e=dn(this.images,Qr(this.blockData));this.editor.updateEmbedData(t,e)},1e3));this.editor=t,this.blockData=e,this.blockResizer=new lf(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=lc(this.blockData.embedData)}destroy(){var t;this.blockResizer.removeAllListeners(),this.blockResizer.destroy(),this.editor.domEvents.removeEventListener(null,null,this.handleMouseDown),(t=this.parentContainerResizerObserver)==null||t.disconnect()}setAutoFix(t){this.autoFix=t}isAutoFix(){return this.autoFix}createContent(t,e,r){const i=Mz(this.editor,e,r,this.images,this.selectedIndex);if(this.editor.domEvents.addEventListener(r,"mousedown",this.handleMouseDown),this.editor.addListener("resize",this.handleRootContainerResize),Mr(t)){const s=()=>{this.handleEditorResize(t)};this.parentContainerResizerObserver=new _s(s),this.parentContainerResizerObserver.observe(t)}const o=()=>!!(this.images.length===1&&this.images[0].virtualSize);this.isEmpty()&&o()&&z(i,"empty"),af(this.editor,this.blockData,e,t),setTimeout(()=>{const s=this.editor.findBlockById(this.blockData.id);s&&this.blockResizer.update(s)})}getImages(){return this.images}getWidthPercent(){return Qr(this.blockData)}isEmpty(){return this.images.length===1&&oc(this.images[0])}setResizing(t){this.resizing=t}getSelectedIndex(){return this.selectedIndex}getBlock(){return this.editor.findBlockById(this.blockData.id)}setSelectedIndex(t){const e=this.getBlock();if(!e||t===this.selectedIndex)return;if(this.selectedIndex!==-1){const i=uf(e,this.selectedIndex);i&&ot(i,"active")}this.selectedIndex=t;const r=uf(e,t);r&&z(r,"active")}async requestUploadImage(t){const e=this.editor.findBlockById(this.blockData.id);if(!e)return;const r=uf(e,t);if(Rt(r,"error"))return;const i=HR(this.editor),o=await ha(i);await this.replaceImage(t,o)}tryEnableResizer(){const t=this.editor.findBlockById(this.blockData.id);if(!t||!this.editor.isWritable())return;const e=uf(t,0);!this.isEmpty()&&this.images.length===1&&!Rt(e,"error")&&this.blockResizer.enableResize(t)}disableResizer(){this.blockResizer.disableResize()}fixImageSize(t,e){const r=this.images[t];oc(r)||(ls(r.width)&&!ls(r.height)?r.height=r.width/e.naturalWidth*e.naturalHeight:ls(r.height)&&!ls(r.width)?r.width=r.height/e.naturalHeight*e.naturalWidth:(r.width=e.naturalWidth,r.height=e.naturalHeight),r.virtualSize=!1,this.fixImageSizes())}removeImage(t){const e=this.editor.findBlockById(this.blockData.id);if(!e||t===-1||t>=this.images.length)return!1;const r=gt.default(this.images);if(r.splice(t,1),r.length===0)return this.editor.deleteBlock(e),!0;r[0].flex=NaN,sc(r),this.selectedIndex>=r.length&&(this.selectedIndex=r.length-1);const i=dn(r,Qr(this.blockData));return this.editor.updateEmbedData(e,i),!0}async replaceImage(t,e){const r=this.editor.findBlockById(this.blockData.id);if(!r)return!1;try{const o=await fa(e),s=this.images[t];if(s.virtualSize){const{width:c,height:d}=await wR(o);s.width=c,s.height=d,s.virtualSize=!1,this.images[0].flex=NaN,sc(this.images);const h=dn(this.images,Qr(this.blockData));this.editor.updateEmbedData(r,h)}const l={...s,src:o};$R(this.editor,r,l,t,this.selectedIndex,this.images),setTimeout(()=>{this.blockResizer.update(r)})}catch(o){return KR(this.editor,r,t,o,e),!1}const i=uf(r,t);if(!i)return!1;z(i,"uploading"),OR(i,0),z(r,"media-block-uploading");try{const o=await this.editor.doc.uploadResource(e,{onProgress:c=>{OR(i,c)}});ot(i,"uploading"),this.images[t].src=o.resourceId;const s=this.editor.findBlockById(this.blockData.id);if(!s)return!1;ot(s,"media-block-uploading");const l=dn(this.images,Qr(this.blockData));return this.editor.updateEmbedData(s,l),!0}catch(o){GR.error(o);const s=this.editor.findBlockById(this.blockData.id);return s&&(ot(i,"uploading"),vz(i),KR(this.editor,s,t,o,e),ot(s,"media-block-uploading")),!1}}updateFlex(t){const e=this.editor.findBlockById(this.blockData.id);if(!e)return;p(GR,t.length===this.images.length,"invalid flex");for(let i=0;i<this.images.length;i++)this.images[i].flex=t[i];const r=dn(this.images,Qr(this.blockData));this.editor.updateEmbedData(e,r)}resetFlex(){const t=this.editor.findBlockById(this.blockData.id);if(!t)return;const e=gt.default(this.images);e[0].flex=NaN,sc(e);const r=dn(e,Qr(this.blockData));this.editor.updateEmbedData(t,r)}setData(t){this.blockData=t,this.images=lc(t.embedData)}static create(t,e){const r=t.addCustom(`image-${e.id}`,()=>new Le(t,e));return r.setData(e),r}static getImageObject(t,e){let r;return typeof e=="string"?r=e:r=st(e),t.getCustom(`image-${r}`)}}const Kct="",Vct="";function j0(n){const t=re(n);let e=t.querySelector(":scope > .block-helper");return e||(e=B("div",["block-helper"],t),B("span",["helper-sizer"],e,"A")),e}function vE(n,t,e){const r=j0(n),o=Array.from(r.children).find(s=>{var c;return Number.parseInt((c=s.getAttribute("data-index"))!=null?c:"0",10)>e});r.insertBefore(t,o!=null?o:null)}const WR=40,Oz=20;class Nz{findTargetBlock(t,e){const r=e.target;if(r&&r instanceof Element){const c=et(r);if(c&&ne(t.rootContainer,c))return c}let i=e.clientX,o=e.clientY;const s=t.rootContainer.getBoundingClientRect().left;i<s&&s-i<WR&&(i+=WR);let l=document.elementFromPoint(i,o);if(l){const c=et(l);if(c&&ne(t.rootContainer,c))return c}if(o-=Oz,l=document.elementFromPoint(i,o),l){const c=et(l);if(c&&ne(t.rootContainer,c))return c}return null}destroy(){}}class Pz extends D0{constructor(e){super(e,{trigger:[],id:"empty-block-menu"});m(this,"currentBlock",null)}get isVisible(){return this.suggest.menu.isVisible}isInMenu(e){return this.menu.isInCommandBar(e)}show(){const r=this.editor.selection.focusedBlock;this.suggest.popup(r,0,"","")}setBlock(e){this.currentBlock=e}}function Fz(n,t,e){const r=Zg(n,t);if(!r)return[];const i=[];return Object.values(r).forEach(o=>{e!=null&&e.has(o.group)||i.push(...o.commands.map(s=>({...s,source:"block-command",blockMenuItemCustomData:o.group})))}),i}function BE(n,t,e={withPlainText:!1}){const r=eE(n,e),i=o=>{o.forEach(s=>{s.source=t,s.children&&i(s.children)})};return i(r),r}function Kz(n,t,e,r=!1){var h,C,E;const i=rt(t);let o=t;if(o&&Kt(o)&&UC(o)){if(!r){const A=pK(o);o=(h=qt(A))!=null?h:A}T0.closeMindmap(n,t)}let l=bt(o);ie(n,o)||r||(l+=1);const c=ft(i),d=e;return d.commandProvider?d.commandProvider.executeCommand(n,e,{from:"block-menu",containerId:c,blockIndex:l}):(E=(C=d.blockOptions)==null?void 0:C.handleInsertEmptyBlock)==null?void 0:E.call(C,n,{containerId:c,blockIndex:l,item:e})}function Vz(n,t){const e=Ir(n,t),r=n.getBlockData(t);return!(e!=="text"||r.heading)}class qR{constructor(t,e,r){m(this,"source","text-style");m(this,"id","text-style-item");m(this,"name","Text styles");m(this,"element");m(this,"textStylesTooltips",{});m(this,"createHeadingItemElement",(t,e,r)=>{var o;const i=XC();this.createItem("text",Fa,e,Vz(this.editor,t)),(o=i.insertBlockCommandItems)==null||o.forEach(s=>{s.id&&s.icon&&this.createItem(s.id,s.icon,e,r?r===Number(s.value):!1)})});m(this,"createListItemElement",(t,e,r)=>{const{checkbox:i,ordered:o}=r,l=St(t)==="list",c=l&&o===!1&&!i,d=l&&o,h=l&&!!i;this.createItem("unordered-list",eC,e,c),this.createItem("ordered-list",nC,e,d),this.createItem("check-list",Zp,e,h)});m(this,"handleClick",(t,e)=>{var l,c;if(!e.target||!(e.target instanceof Node))return;const r=e.target instanceof Element?e.target:e.target.parentElement;if(!r)return;const i=r.closest(".text-style-item");if(!i)return;const o=i.id,s="heading-";if(o==="text"&&S0(t,this.block,null),o.startsWith(s)){const d=Number.parseInt(o.substring(s.length),10);d&&S0(t,this.block,d)}if(o==="blockquote"&&GC(t,this.block),o.startsWith("align")){const d=o.replace(/^align-/,"");Lk(t,this.block,d)}(o==="unordered-list"||o==="ordered-list"||o==="check-list")&&qC(t,this.block,o),(c=(l=this.options).onAfterStyleItemClick)==null||c.call(l)});m(this,"calcTextStyleItemTooltipsEnum",()=>{this.textStylesTooltips={text:{title:D.t("commands.text")},blockquote:{title:D.t("commands.quote")},"align-left":{title:D.t("commands.alignLeft")},"align-center":{title:D.t("commands.alignCenter")},"align-right":{title:D.t("commands.alignRight")},"unordered-list":{title:D.t("commands.unordered")},"ordered-list":{title:D.t("commands.ordered")},"check-list":{title:D.t("commands.check")}};let t=1;for(;t<=8;)this.textStylesTooltips[`heading-${t}`]={title:D.t("commands.heading",{name:`${t}`})},t++});this.editor=t,this.block=e,this.options=r,this.calcTextStyleItemTooltipsEnum(),this.element=this.createItemElement(t,e),t.domEvents.addEventListener(this.element,"click",this.handleClick)}createItemElement(t,e){const r=B("div",["text-styles"],null),i=B("div",["text-style-section"],r),o=t.getBlockData(e);if(!this.options.fromEmbed){const l=o.heading,c=o.quoted;this.createHeadingItemElement(e,i,l),this.createListItemElement(e,i,o),this.createItem("blockquote",tC,i,!!c)}const s=o.align||"left";return this.createItem("align-left",Pa,i,s==="left"),this.createItem("align-center",r0,i,s==="center"),this.createItem("align-right",n0,i,s==="right"),r}createItem(t,e,r,i=!1){const o=["style-icon","text-style-item"];i&&o.push("active");const s=Ms(e,o,r);s.id=t;const l=this.textStylesTooltips[t];if(!l)return;const{title:c,shortcut:d}=l;s.setAttribute(`data-editor-tooltip-${this.editor.clientId}`,c),d&&s.setAttribute(`data-editor-tooltip-desc-${this.editor.clientId}`,ze(d))}}function XR(){return{source:"separator",type:"separator",id:`section-${Z()}`,name:""}}const QR={copy:HT,cut:jT,delete:zT,"lock-block":GT,"unlock-block":WT,comment:ol},$z=["image","video"];function Hz(n,t,e){const r=[],i=nt(n,t),o=pe(t)&&$z.includes(Ge(t)),s=o&&(Ge(t)!=="image"||Ge(t)==="image"&&yi(t).length===1);if(i?r.push(new qR(n,t,e)):o&&s&&r.push(new qR(n,t,{...e,fromEmbed:!0})),!ie(n,t)||MC(t)){(i||o&&s)&&r.push(XR());const l=Fz(n,t,new Set(["hovering-toolbar"]));l.sort((c,d)=>{var h,C;return((h=c.order)!=null?h:0)-((C=d.order)!=null?C:0)}),l.forEach(c=>{c.id in QR&&(c.icon=QR[c.id])}),r.push(...l)}return ie(n,t)&&!MC(t)?r.push(...BE(n,"insert-block")):r.push(XR(),{id:"insert-block-before",icon:qT,name:D.t("blockMenu.command.insertAbove"),children:BE(n,"insert-block-before",{withPlainText:!0}),childrenMenuId:"quick-menu",source:"insert-block-before"},{id:"insert-block-after",icon:XT,name:D.t("blockMenu.command.insertAfter"),children:BE(n,"insert-block",{withPlainText:!0}),source:"insert-block",childrenMenuId:"quick-menu"}),r}function jz(n,t,e){if(e.source==="block-command"){const r=e.blockMenuItemCustomData;zv(n,t,r,e)}else(e.source==="insert-block"||e.source==="insert-block-before")&&Kz(n,t,e,e.source==="insert-block-before")}const zz=I("exclusive-block");function TE(n,t,e,r){var l;z(t,"block-exclusive");const i=Yt(n,t),o=(l=i.getBlockProperties)==null?void 0:l.call(i,n,t),{abstract:s}=o||{};t.setAttribute("data-user-name",r),t.setAttribute("data-user-id",e),t.setAttribute("data-exclusive-tips",D.t("exclusive.tips",{editor:r,embedType:s||D.t("exclusive.fallbackAbstract")}))}function YR(n){ot(n,"block-exclusive"),n.removeAttribute("data-user-name"),n.removeAttribute("data-user-id"),n.removeAttribute("data-exclusive-tips")}function Gz(n,t,e,r,i){zz.debug(`block ${st(t)} ${e?"exclusive":"unexclusive"}, ${r}, ${i}`),e?TE(n,t,r,i):YR(t)}function ff(n){return n.classList.contains("block-exclusive")}function JR(n,t){t.blockIds.forEach(e=>{const r=n.findBlockById(e);r&&Gz(n,r,t.exclusive,t.userId,t.displayName)})}class cs{constructor(t){m(this,"exclusiveBlockIds",new Set);m(this,"exclusiveBlockTimer",0);m(this,"remoteExclusiveBlockIds",new Map);m(this,"handleUserChanged",t=>{const e=new Set(t.map(i=>i.userId));Array.from(this.remoteExclusiveBlockIds.entries()).forEach(([i,o])=>{if(!e.has(o.userId)){this.remoteExclusiveBlockIds.delete(i);const s={...o,exclusive:!1};JR(this.editor,s)}});const r=Array.from(this.exclusiveBlockIds).map(i=>this.editor.findBlockById(i)).filter(i=>!!i);r.length>0&&this.broadcastExclusiveBlockMessage(r,!0)});this.editor=t,t.doc.registerCallback(this),t.doc.getRemoteUsers().addListener("change",this.handleUserChanged)}destroy(){this.stopExclusiveBlockTimer(),this.editor.doc.unregisterCallback(this),this.editor.doc.getRemoteUsers().addListener("change",this.handleUserChanged)}onCustomMessage(t){if(t.type==="exclusiveBlock"){const e=t;JR(this.editor,e),e.blockIds.forEach(r=>{e.exclusive?this.remoteExclusiveBlockIds.set(r,e):this.remoteExclusiveBlockIds.delete(r)})}}getExclusiveMessage(t){return this.remoteExclusiveBlockIds.get(t)}broadcastExclusiveBlockMessage(t,e){if(this.editor.readonly||t.length===0)return;const r=this.editor.doc.getUser(),i={type:"exclusiveBlock",userId:r.userId,displayName:r.displayName,blockIds:t.map(o=>st(o)),exclusive:e};this.editor.doc.broadcastMessage(i)}exclusiveBlock(t){this.exclusiveBlockIds.has(st(t))||(this.broadcastExclusiveBlockMessage([t],!0),this.exclusiveBlockIds.add(st(t)),this.exclusiveBlockIds.size===1&&this.startExclusiveBlockTimer())}unexclusiveBlock(t){!this.exclusiveBlockIds.has(st(t))||(this.exclusiveBlockIds.delete(st(t)),this.broadcastExclusiveBlockMessage([t],!1),this.exclusiveBlockIds.size===0&&this.stopExclusiveBlockTimer())}startExclusiveBlockTimer(){this.exclusiveBlockTimer=window.setInterval(()=>{Array.from(this.exclusiveBlockIds.keys()).forEach(t=>{this.broadcastExclusiveBlockMessage([this.editor.getBlockById(t)],!0)})},30*1e3)}stopExclusiveBlockTimer(){clearInterval(this.exclusiveBlockTimer),this.exclusiveBlockTimer=0}static get(t){return t.addCustom("exclusiveBlock",()=>new cs(t))}static register(t){return this.get(t)}}function yE(n,t){cs.get(n).exclusiveBlock(t)}function kE(n,t){cs.get(n).unexclusiveBlock(t)}class ZR{writable(t,e){if(Array.isArray(e)){for(const r of e)if(ff(r))return!1;return}if(ff(e))return!1}create(t,e,r,i,o){const s=cs.get(t).getExclusiveMessage(o.id);s&&TE(t,i,s.userId,s.displayName)}update(t,e,r,i,o){const s=cs.get(t).getExclusiveMessage(o.id);s?TE(t,i,s.userId,s.displayName):YR(i)}}const $ct="",Wz={exclusive:{tips:"\u300C{editor}\u300D\u6B63\u5728\u7F16\u8F91\uFF0C\u300C{embedType}\u300D\u4E0D\u652F\u6301\u591A\u4EBA\u7F16\u8F91",fallbackAbstract:"\u8BE5 Block"}},qz={exclusive:{tips:"\u300C{editor}\u300Dis editing\uFF0C\u300C{embedType}\u300Ddoes not support multi-person editing",fallbackAbstract:"This Block"}},Xz={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"}};D.mergeLang({"zh-CN":Wz,"en-US":qz,"ja-JP":Xz});function df(n,t){return n.getBlockData(t).lock}function z0(n,t){return!!df(n,t)}function hf(n,t){const e=df(n,t);return e?e.userId===n.doc.getUser().userId:!1}function RE(n,t){const e=df(n,t);return e?e.userId!==n.doc.getUser().userId:!1}function Qz(n,t){if(n.readonly||!n.isBlockWritable(t)||z0(n,t)&&!hf(n,t))return;const e=n.doc.getUser(),r={userId:e.userId,displayName:e.displayName,locked:Date.now()},o={...n.getBlockData(t),lock:r};n.updateBlockData(t,o)}function Yz(n,t){if(!hf(n,t))return;const e={lock:null};n.updateBlockData(t,e)}const Jz=10,Zz=80,tG=50;class wE{constructor(){m(this,"executeCommand",(t,e,r)=>{const i=r.data;if(!i||!i.blockId)return;const o=t.getBlockById(i.blockId);i.type==="lock"?Qz(t,o):i.type==="unlock"&&Yz(t,o)})}create(t,e,r,i,o){const s=o.lock;s&&(s.userId!==t.doc.getUser().userId?z(i,"locked-by-others"):z(i,"locked-by-self"))}update(t,e,r,i,o){const s=o.lock;if(s)if(s.userId!==t.doc.getUser().userId){z(i,"locked-by-others");const l=t.selection.focusedBlock;(l===i||ne(i,l))&&(nt(t,i)||St(i)==="code")&&t.insertTextBlock("",ft(r),bt(i)+1)}else z(i,"locked-by-self");else ot(i,"locked-by-others"),ot(i,"locked-by-self")}writable(t,e){let r=[];Array.isArray(e)?r=e:r.push(e);for(const i of r){if(RE(t,i))return!1;if(dr(i))return;let o=$s(i);for(;o;){if(RE(t,o))return!1;o=$s(o)}}}commands(t,e){const r=z0(t,e),i=hf(t,e),o=ff(e),s={blockId:st(e),type:"lock"},l={id:"lock-block",name:"",data:s,order:10};if(r)if(i)l.id="unlock-block",l.name=D.t("locker.unlock"),s.type="unlock";else{const c=df(t,e);let d=(c==null?void 0:c.displayName)||"";const h=D.getCurrentLang()==="ja-JP",C=uv(d,Jz,h?tG:Zz);(C==null?void 0:C.length)!==d.length&&(l.ellipsisTooltip=c==null?void 0:c.displayName,d=C||""),l.name=D.t("locker.lockedBy",{name:d}),l.states=["disabled"]}else o?(l.name=D.t("locker.lock"),l.states=["disabled"]):l.name=D.t("locker.lock");return{group:"block-locker",commands:[l],executeCommand:this.executeCommand}}}const Hct="",eG={locker:{lock:"\u9501\u5B9A",unlock:"\u89E3\u9664\u9501\u5B9A",lockedBy:"\u88AB {name} \u9501\u5B9A"}},nG={locker:{lock:"Lock",unlock:"Unlock",lockedBy:"Locked by {name}"}},rG={locker:{lock:"\u30ED\u30C3\u30AF",unlock:"\u30ED\u30C3\u30AF\u89E3\u9664",lockedBy:"{name}\u304C\u30ED\u30C3\u30AF\u3057\u307E\u3057\u305F"}};D.mergeLang({"zh-CN":eG,"en-US":nG,"ja-JP":rG});class G0{async handleBeforePasteDoc(t,e){return Object.values(e.blocks).forEach(r=>{r.forEach(i=>{delete i.lock})}),!1}}const iG=I("standard-block-actions");class oG{constructor(){m(this,"executeCommand",(t,e,r)=>{const i=r.data;try{const o=t.getBlockById(i);if(r.id==="delete"){t.deleteBlock(o);return}r.id==="copy"&&Dh(t,o),r.id==="cut"&&(Dh(t,o),t.deleteBlock(o))}catch(o){iG.error(`failed to execute block command: ${JSON.stringify(o)}`)}})}commands(t,e){const r=z0(t,e),i=r&&hf(t,e),o=st(e),s=window.isSecureContext,l=ff(e),c={id:"copy",name:D.t("blockMenu.command.copy"),data:o,order:1,states:s?[]:["disabled"],disableReason:s?void 0:D.t("copyCutProperty.unsafeEnvTips",{shortCut:ze("CtrlOrCmd+C"),operation:D.t("copyCutProperty.copy")})},d={id:"cut",name:D.t("blockMenu.command.cut"),data:o,order:2,states:r&&!i||!s||l?["disabled"]:[],disableReason:s?void 0:D.t("copyCutProperty.unsafeEnvTips",{shortCut:ze("CtrlOrCmd+X"),operation:D.t("copyCutProperty.cut")})},h={id:"delete",name:D.t("blockMenu.command.delete"),data:o,order:3,states:r&&!i||l?["disabled"]:[]};return{group:"standard-block-actions",commands:[c,d,h],executeCommand:this.executeCommand}}}const tw=I("block-menu");class sG{constructor(t){m(this,"menu");m(this,"currentBlock",null);m(this,"commandBlock",null);m(this,"handleShow",()=>{p(tw,this.currentBlock,"no target block before show block menu");const t=Hz(this.editor,this.currentBlock,{onAfterStyleItemClick:this.close});this.menu.updateItems(t),this.commandBlock=this.currentBlock});m(this,"handleClose",()=>{lC(this.editor)&&this.editor.focus()});m(this,"handleItemClick",(t,e)=>{p(tw,this.commandBlock,"no command block before show block menu"),jz(this.editor,this.commandBlock,e),e.element||this.close()});m(this,"close",()=>{this.menu.close("clickItem")});this.editor=t,this.menu=new Zo([],void 0,{id:"block-menu"}),this.menu.on("show",this.handleShow),this.menu.on("close",this.handleClose),this.menu.on("click",this.handleItemClick),t.blockHooks.push(new oG)}show(t,e){this.menu.manualShow(t,{placement:"bottom-start",...e})}isInMenu(t){return this.menu.isInCommandBar(t)}setBlock(t){this.currentBlock=t}get isVisible(){return this.menu.isVisible}destroy(){this.menu.destroy()}}const lG=1e3;async function aG(n,t){const{width:e}=n.rootContainer.getBoundingClientRect(),r=t.getBoundingClientRect();return r.width>e||r.height>=lG?"":(await Ab.default.toSvg(t)).replace(/margin-block:.*?;/,"").replace(/margin:.*?;/,"")}const cG=I("drag-preview-image");class uG{constructor(t){m(this,"startPosition",null);m(this,"dragContainer",null);m(this,"handleDragStart",async(t,e)=>{const r=t.target;p(cG,r instanceof Element,`Invalid Drag target:${r}`);const{x:i,y:o}=t;this.startPosition={x:i,y:o};const s=B("div",["drag-image-container"],this.editor.rootContainer),l=B("img",["drag-image"],s),c=B("span",["drag-loading"],s);c.innerHTML=ZT;const{x:d,width:h,height:C,y:E}=r.getBoundingClientRect(),A=this.editor.rootContainer.getBoundingClientRect(),v=e.getBoundingClientRect();s.style.left=`${d+h}px`,s.style.top=`${E+C}px`,s.style.width=`${Math.min(A.width/2,v.width)}px`,this.dragContainer=s;const L=await aG(this.editor,e);L?l.src=L:z(s,"drag-placeholder"),Lg(s,{status:"loaded"})});m(this,"handleDrag",t=>{if(this.startPosition&&this.dragContainer){const{x:e,y:r}=t;if(e===0&&r===0){this.dragContainer.style.transition="transform 0.15s, opacity .15s",this.dragContainer.style.transform="",this.dragContainer.style.opacity="0";return}const{x:i,y:o}=this.startPosition,s=e-i,l=r-o;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=t}}const ew="drag-preview-element";function fG(n){if(Rt(n,ew))return n;const t=n.querySelector(`.${ew}`);return t||(pe(n)?Ot(n):n)}const W0=I("block-menu-drag-handler");function SE(n,t){return new DragEvent(t,{bubbles:!0,cancelable:!0,view:window,screenX:n.screenX,screenY:n.screenY,dataTransfer:new DataTransfer,clientX:n.clientX,clientY:n.clientY})}class dG{constructor(t,e){m(this,"dragPreview");m(this,"autoScroll");m(this,"oldPos",{x:0,y:0});m(this,"handleMouseDown",t=>{const e=this.button.blockMenu.currentBlock;if(p(W0,e,"no dragged block"),t.button!==0)return;if(!this.editor.isBlockWritable(e)){t.preventDefault(),t.stopPropagation();return}const{x:r,y:i}=t;this.oldPos={x:r,y:i},document.addEventListener("mouseup",this.handleDragEnd),this.editor.contentElement.addEventListener("mousemove",this.handleDrag)});m(this,"handleDragStart",t=>{var s,l;const e=En(this.button.buttonElement);this.autoScroll||(this.autoScroll=new Vd({scrollElement:e,trackMouseEvent:"mousemove",edge:{top:50,bottom:50}}));const r=this.button.blockMenu.currentBlock;p(W0,r,"no dragged block"),(l=(s=Yt(this.editor,r)).notify)==null||l.call(s,this.editor,"beginDrag");const i=SE(t,"dragstart");CG(this.editor,i,r),window.isDragging=!0,this.button.buttonElement.style.opacity="0";const o=fG(r);this.dragPreview.handleDragStart(t,o),this.autoScroll.active(),z(r,"dragging"),z(this.editor.contentElement,"dragging")});m(this,"handleDrag",t=>{const{target:e,x:r,y:i}=t;if(this.oldPos.x===r&&this.oldPos.y===i)return;window.isDragging||this.handleDragStart(t),this.oldPos={x:r,y:i},p(W0,e instanceof Element,"target is invalid"),this.dragPreview.handleDrag(t);const o=SE(t,"dragover");this.editor.contentElement.dispatchEvent(o)});m(this,"handleDragEnd",t=>{var i;const e=this.button.blockMenu.currentBlock;p(W0,e,"no dragged block"),window.isDragging=!1,this.button.buttonElement.style.opacity="1",this.dragPreview.handleDragEnd(),(i=this.autoScroll)==null||i.inactive(),ot(e,"dragging"),ot(this.editor.contentElement,"dragging"),document.removeEventListener("mouseup",this.handleDragEnd),this.editor.contentElement.removeEventListener("mousemove",this.handleDrag);const r=SE(t,"drop");this.editor.contentElement.dispatchEvent(r)});this.editor=t,this.button=e,this.button.buttonElement.addEventListener("mousedown",this.handleMouseDown),this.dragPreview=new uG(t)}destroy(){this.button.buttonElement.removeEventListener("mousedown",this.handleMouseDown)}}class mf{constructor(t){m(this,"highlightedBlockId","");m(this,"handleSelectionChange",()=>{this.clearHighlightedBlock()});this.editor=t,this.editor.addListener("selectionChanged",this.handleSelectionChange)}highlightBlock(t){this.clearHighlightedBlock(),this.highlightedBlockId=st(t),z(t,"highlighted")}clearHighlightedBlock(){if(this.highlightedBlockId){const t=this.editor.findBlockById(this.highlightedBlockId);t&&ot(t,"highlighted"),this.highlightedBlockId=""}}destroy(){}static register(t){return t.addCustom("editor-block-highlighter",()=>new mf(t))}static get(t){return t.getCustom("editor-block-highlighter")}}class nw{constructor(t){m(this,"buttonElement");m(this,"emptyBlockMenu");m(this,"blockMenu");m(this,"dragHandler");m(this,"handleHoverBlock",(t,e,r)=>{if(this.emptyBlockMenu.isVisible||this.blockMenu.isVisible||!this.editor.isWritable())return;const i=this.editor.getCustom("editor-tooltip");if(i&&i.visible()&&(i.hide(),this.buttonElement.setAttribute("data-tooltip-hide-at",`${Date.now()}`)),!t){this.buttonElement.parentElement&&(this.blockMenu.isInMenu(r.target)||this.buttonElement.remove());return}const o=Jg(t);Gi(o)||(this.updateButton(o),vE(o,this.buttonElement,Number.MAX_SAFE_INTEGER))});m(this,"handleButtonClick",()=>{if(this.buttonElement.getAttribute("data-type")==="move"){const r=this.blockMenu.currentBlock;if(!r)return;this.editor.selection.selectBlock(r,0,void 0,{noScroll:!0}),this.blockMenu.show(this.buttonElement,{placement:"bottom-end"}),setTimeout(()=>{mf.get(this.editor).highlightBlock(r)});return}const e=this.emptyBlockMenu.currentBlock;!e||(this.editor.selection.selectBlock(e,0,void 0,{noScroll:!0}),setTimeout(()=>{this.editor.focus(),this.updatePlaceholder(e),this.emptyBlockMenu.show()}))});m(this,"updatePlaceholder",t=>{of(this.editor,t,D.t("blockMenu.button.searchPlaceholder"))});m(this,"handleChanged",()=>{const t=this.emptyBlockMenu.currentBlock;if(!t)return;if(this.blockMenu.currentBlock){const r=st(this.blockMenu.currentBlock);if(!this.editor.findBlockById(r)&&this.blockMenu.isVisible){this.blockMenu.close();return}}const e=ie(this.editor,t)?"insert":"move";this.buttonElement.getAttribute("data-type")!==e&&this.setButtonType(e)});this.editor=t,this.buttonElement=this.createButton(),this.emptyBlockMenu=new Pz(t),this.blockMenu=new sG(t),this.editor.addListener("docChanged",this.handleChanged),this.buttonElement.addEventListener("click",this.handleButtonClick),this.dragHandler=new dG(this.editor,this);const e=Be.get(t);e.addListener("change",this.handleHoverBlock),e.addFinder(new Nz),mf.register(this.editor)}destroy(){Be.get(this.editor).removeListener("change",this.handleHoverBlock),this.buttonElement.removeEventListener("click",this.handleButtonClick),this.editor.removeListener("docChanged",this.handleChanged),this.emptyBlockMenu.destroy(),this.blockMenu.destroy(),this.buttonElement.remove(),this.dragHandler.destroy()}createButton(){const t=B("button",["block-button"],null);return t.setAttribute(`data-editor-tooltip-${this.editor.clientId}`,D.t("blockMenu.button.tips")),t.innerHTML=rC,t}setButtonType(t){this.buttonElement.setAttribute("data-type",t);const e=`data-editor-tooltip-${this.editor.clientId}-dynamic`;this.buttonElement.hasAttribute(e)&&this.buttonElement.removeAttribute(e),t==="insert"?(this.buttonElement.innerHTML=JT,this.buttonElement.setAttribute(e,D.t("blockMenu.button.insertTips"))):(this.buttonElement.innerHTML=rC,this.buttonElement.setAttribute(e,D.t("blockMenu.button.tips")))}updateButton(t){this.emptyBlockMenu.setBlock(t),this.blockMenu.setBlock(t),ie(this.editor,t)&&!(Kt(t)&&MC(t))?this.setButtonType("insert"):this.setButtonType("move")}}const hG={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
|
|
665
665
|
\u70B9\u51FB\u6253\u5F00\u83DC\u5355`,insertTips:"\u70B9\u51FB\u6DFB\u52A0\u533A\u5757"}}},mG={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
|
|
666
|
-
Click to open the menu`,insertTips:"Click to add block"}}},gG={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:"\u8907\u88FD",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"}}};D.mergeLang({"zh-CN":hG,"en-US":mG,"ja-JP":gG});const jct="";class pG{constructor(){m(this,"dragObject",null)}setData(t){this.dragObject=t}getData(){return this.dragObject}clearData(){this.dragObject=null}destroy(){}}function q0(n){return n.addCustom("drag-data",()=>new pG)}function LE(n,t){if(!t)return null;const e=q0(n).getData();return!e||e.editorId!==n.id?null:e}function rw(n,t){const e=LE(n,t);return e?n.findBlockById(e.blockId):null}function CG(n,t,e){if(!t.dataTransfer)return;const i=rt(e),o=ft(i),s=st(e),l={type:"block",editorId:n.id,containerId:o,blockId:s};q0(n).setData(l)}function EG(n,t,e,r,i){if(!t.dataTransfer)return;const s=rt(e),l=ft(s),c=st(e),d={type:"custom",customType:r,editorId:n.id,containerId:l,blockId:c,data:i};q0(n).setData(d)}function gf(n){q0(n).clearData()}const xG=I("drop-indicator"),pf=2;class AG{constructor(t){m(this,"indicator");m(this,"target",null);this.editor=t,this.indicator=B("div",["editor-drop-indicator"],this.editor.contentElement)}show(t,e){const r=this.getIndicatorRect(t,e),i=this.editor.rootElement.getBoundingClientRect(),o=r.top-i.top,s=r.left-i.left;this.indicator.style.top=`${o}px`,this.indicator.style.left=`${s}px`,this.indicator.style.width=`${r.width}px`,this.indicator.style.height=`${r.height}px`,this.indicator.style.display="",this.target={block:t,insertPos:e}}hide(){this.indicator.style.display="none",this.target=null}getIndicatorRect(t,e){if(typeof e!="string")return e.rect;if(e==="before"){const l=js(t);if(!l){p(xG,Mr(rt(t)),"block does not in a child container");const C=t.getBoundingClientRect(),E=this.getViewRect(t);return new DOMRect(E.x,C.y,E.width,pf)}const c=l.getBoundingClientRect(),d=t.getBoundingClientRect(),h=this.getViewRect(t);return new DOMRect(h.x,(c.bottom+d.top)/2,h.width,pf)}const r=zs(t);if(!r){const l=t.getBoundingClientRect(),c=this.getViewRect(t);return new DOMRect(c.x,l.bottom,c.width,pf)}const i=t.getBoundingClientRect(),o=r.getBoundingClientRect(),s=this.getViewRect(t);return new DOMRect(s.x,(i.bottom+o.top)/2,s.width,pf)}getViewRect(t){const e=En(t,{horizontal:!0}),r=t.getBoundingClientRect(),i=e.getBoundingClientRect(),o=Math.max(i.x-r.x,0),s=Math.max(r.right-i.right,0);return new DOMRect(r.x+o,r.y,Math.max(r.width-o-s,0),pf)}}const bG=I("find-drop-target");function vG(n,t){const e=document.elementFromPoint(n,t);if(!e)return null;if(Wi(e)&&Mr(e))return e;const r=e.firstElementChild;return r&&Wi(r)&&Mr(r)?r:null}function BG(n,t){const s=t,l=n;for(let c=0;c<2;c++){const d=l+c*50;for(let h=0;h<5;h++){const C=s+h*8,E=document.elementFromPoint(d,C);if(E){const R=et(E);if(R)return R}if(h===0)continue;const A=s-h*8,v=document.elementFromPoint(d,A);if(v){const R=et(v);if(R)return R}}}return null}function TG(n,t,e){const r=document.elementFromPoint(t,e);if(r){const h=et(r);if(h&&!_t(n,h))return h}const i=new Set,o=vG(t,e);if(o){const h=o.getBoundingClientRect();e<h.top+h.height/2?i.add(we(o)):i.add(Ze(o))}const s=BG(t,e);s&&i.add(s);const l=Array.from(i),c=h=>{for(let C=0;C<l.length;C++){const E=l[C];if(h!==E&&ne(h,E))return!0}return!1},d=l.filter(h=>!c(h));return d.length>0?d[0]:null}function IE(n,t){if(n.readonly)return!1;const e=rt(t);if(Xt(e))return!0;const r=et(e);return p(bG,r,"no parent block"),n.isBlockWritable(r)?IE(n,r):!1}const yG=I("drop-target");function kG(n,t){let e={};return/image/.test(t.type)?e=n.editorEmbeds.getEmbedClass("image"):/audio/.test(t.type)?e=n.editorEmbeds.getEmbedClass("audio"):/video/.test(t.type)&&(e=n.editorEmbeds.getEmbedClass("video")),p(yG,e,`unSupport file type ${t.type}`),e}async function iw(n,t,e,r){var o,s;let i=r;for(const l of t){const c=kG(n,l);c.getOptions&&await((s=(o=c.getOptions(n)).handleInsertEmptyEmbed)==null?void 0:s.call(o,n,{containerId:e,blockIndex:i,data:{file:l}}))&&(i+=1)}}class RG{constructor(t){m(this,"handleDrop",(t,e,r,i)=>{if(Array.isArray(e)){const o=e;if(o.length>0){const s=ft(r);return iw(t,o,s,i),!0}}return!1});this.editor=t}}class Cf{constructor(t){m(this,"indicator");m(this,"lastDropOverResult");m(this,"handlers",[]);m(this,"handleDragOver",t=>{if(!this.editor.isWritable())return;const e=o=>{var d,h;const s=LE(this.editor,o.dataTransfer),l=rw(this.editor,o.dataTransfer),c=this.findTargetBlock(l,o.x,o.y);if(c&&ne(this.editor.rootContainer,c)){const C=this.findInsertPos(l,c,o.x,o.y,(h=s!=null?s:(d=o.dataTransfer)==null?void 0:d.items)!=null?h:null);if(C)return this.indicator.show(c,C),"move"}return this.indicator.hide(),"none"},r=(o,s)=>{o.dataTransfer&&(o.dataTransfer.dropEffect=s),s==="move"&&o.preventDefault()};if(this.lastDropOverResult&&t.x===this.lastDropOverResult.x&&t.y===this.lastDropOverResult.y){const o=this.lastDropOverResult.dropEffect;r(t,o);return}const i=e(t);r(t,i),this.lastDropOverResult={x:t.x,y:t.y,dropEffect:i}});m(this,"handleDrop",t=>{var o,s;t.stopPropagation(),setTimeout(()=>{this.indicator.hide()});const e=LE(this.editor,t.dataTransfer),r=Array.from((s=(o=t.dataTransfer)==null?void 0:o.files)!=null?s:[]);if(!e&&r.length===0){t.dataTransfer&&(t.dataTransfer.dropEffect="none"),gf(this.editor);return}const i=this.indicator.target;if(i){const{block:l,insertPos:c}=i,d=rw(this.editor,t.dataTransfer);this.editor.undoManager.runInGroup(()=>{const h=Yt(this.editor,l);if(h.handleDrop&&h.handleDrop(this.editor,l,e!=null?e:r,c,{isSourceBlock:!1,targetBlock:l})){t.preventDefault(),this.editor.focus(),gf(this.editor);return}if(d){const C=Yt(this.editor,d);if(C.handleDrop&&C.handleDrop(this.editor,d,e!=null?e:r,c,{isSourceBlock:!0,targetBlock:l})){t.preventDefault(),this.editor.focus(),gf(this.editor);return}}if(typeof c=="string"){const C=rt(l);let E=bt(l);if(c==="after"){E+=1;let A=qt(l);for(;A&&!ou(A);)E+=1,A=qt(A)}t.preventDefault();for(let A=0;A<this.handlers.length;A++)if(this.handlers[A].handleDrop(this.editor,d!=null?d:r,C,E)){this.editor.focus(),gf(this.editor);return}if(d){const A=this.editor.getBlockData(d),v=qo(this.editor.editorBlocks,this.editor.doc.toJSON(),A),[R]=this.editor.insertDocAt(C,E,v);this.editor.selection.selectBlock(R,0),mf.get(this.editor).highlightBlock(R),this.editor.deleteBlock(d),this.editor.focus()}}})}gf(this.editor)});m(this,"handleDragLeave",()=>{this.indicator.hide()});this.editor=t,this.indicator=new AG(this.editor),this.handlers.push(new RG(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(t){this.handlers.push(t)}static register(t){return t.addCustom("drop-target",()=>new Cf(t))}static get(t){return t.getCustom("drop-target")}static find(t){return t.findCustom("drop-target")}canInsertAfter(t,e){return!(this.editor.readonly||zs(e)===t&&t||!IE(this.editor,e))}canInsertBefore(t,e){return!(this.editor.readonly||js(e)===t&&t||!IE(this.editor,e)||Xt(rt(e))&&bt(e)===0)}canDrop(t,e){return t===null||t===e?!0:!ne(t,e)}findTargetBlock(t,e,r){let i=TG(this.editor,e,r);if(!i||!ne(this.editor.rootContainer,i))return null;const o=rt(i),s=et(o);return s&&St(s)==="code"&&(i=s),this.canDrop(t,i)?i:null}findInsertPos(t,e,r,i,o){let s=e;for(;s;){const c=Yt(this.editor,s);if(c.handleDropOver){const d=c.handleDropOver(this.editor,s,o,r,i);if(d)return d;if(d===!1)return null}s=$s(s)}if(t===e)return"";const l=e.getBoundingClientRect();if(l.top<=i&&i<=l.bottom){if(i<l.top+l.height/2){if(this.canInsertBefore(t,e))return"before";if(this.canInsertAfter(t,e))return"after"}else{if(this.canInsertAfter(t,e))return"after";if(this.canInsertBefore(t,e))return"before"}return""}return i<l.top&&this.canInsertBefore(t,e)?"before":l.bottom<i&&this.canInsertAfter(t,e)?"after":""}}function ow(n,t,e){const r=Le.getImageObject(n,t),i=gt.default(r.getImages());if(i.length===1){n.deleteBlock(t);return}if(e===-1||e>=i.length)return;const o=mz(i);if(i.splice(e,1),i.length===1){const l=i[0],c=100*(l.flex/o);l.flex=1;const d=dn([l],c);n.updateEmbedData(t,d);return}i[0].flex=NaN,sc(i);const s=dn(i,r.getWidthPercent());n.updateEmbedData(t,s)}function wG(n,t,e,r){if(t.length===0||r==="after"||r==="before")return!1;let i=r.data;const o=Le.getImageObject(n,e),s=gt.default(o.getImages()),l=[],c=[];t.forEach(C=>{zR(C.type)&&s.length+l.length<6?l.push(C):c.push(C)}),l.forEach(C=>{try{jR(n,C)}catch{return}const E={src:"",flex:1,width:0,height:0,virtualSize:!0};s.splice(i,0,E);const A=dn(s,o.getWidthPercent());n.updateEmbedData(e,A),o.replaceImage(i,C),i+=1});const d=n.getBlockIndex(e)+1,h=ft(rt(e));return iw(n,c,h,d),!0}function SG(n,t,e,r,i){var s,l,c;if(Fd(e))return wG(n,e,t,r);if(e.type!=="custom"||e.customType!=="image"||!e.data)return;const o=e.data;if(i.isSourceBlock){const d=i.targetBlock,h=rt(d);let C=bt(d);r==="after"&&(C+=1);const A=100*(o.boundingRect.width/n.rootContainer.getBoundingClientRect().width),v=dn([o.image],A),R={id:Z(),type:"embed",embedType:"image",embedData:v},L=(l=(s=n.options.componentsOptions)==null?void 0:s.image)==null?void 0:l.defaultAlign;L&&(R.align=L),n.insertBlock(ft(h),C,R),ow(n,t,o.index),(c=n.findCustom("drag-handler"))==null||c.handleDragEnd()}else{if(typeof r=="string")return;const d=t;let h=r.data;const C=Le.getImageObject(n,d),E=gt.default(C.getImages());h>E.length&&(h=E.length),n.undoManager.runInGroup(()=>{var v,R;C.setAutoFix(!0);const A=n.getBlockById(e.blockId);if(A===d){const L=o.index,M=h,U=o.image;if(L===M||M===L+1)return;let F=M;L<M?(E.splice(M,0,U),E.splice(L,1),F-=1):(E.splice(L,1),E.splice(M,0,U));const G=dn(E,C.getWidthPercent());n.updateEmbedData(d,G),C.setSelectedIndex(F),(v=n.findCustom("drag-handler"))==null||v.handleDragEnd()}else{E.splice(h,0,o.image),E[0].flex=NaN,sc(E);const L=dn(E,C.getWidthPercent());n.updateEmbedData(d,L),ow(n,A,o.index),(R=n.findCustom("drag-handler"))==null||R.handleDragEnd(),C.setSelectedIndex(h),n.selection.selectBlock(d,0)}})}return!0}const LG=2;function X0(n,t,e){const r=yi(t);if(e<=0){const s=r[0].getBoundingClientRect();return new DOMRect(s.left-4,s.top,2,s.height)}if(e===r.length){const s=r[e-1].getBoundingClientRect();return new DOMRect(s.right+2,s.top,2,s.height)}const i=r[e-1].getBoundingClientRect(),o=r[e].getBoundingClientRect();return new DOMRect((o.left+i.right)/2-1,i.top,LG,i.height)}function IG(n,t,e,r,i){for(let o=0;o<e.length;o++){const l=e[o].getBoundingClientRect();if(r<=l.right)return r<=l.left+l.width/2?{rect:X0(n,t,o),data:o}:{rect:X0(n,t,o+1),data:o+1}}return r>e[e.length-1].getBoundingClientRect().right?{rect:X0(n,t,e.length),data:e.length}:{rect:X0(n,t,e.length),data:0}}function DG(n,t,e,r,i){const o=yi(t);if(e instanceof DataTransferItemList){if(!Array.from(e).some(s=>zR(s.type))||o.length>=6)return}else{if((e==null?void 0:e.type)==="block"||o.length>=6&&(e==null?void 0:e.blockId)!==st(t))return;const s=st(t);if(o.length===1&&s===(e==null?void 0:e.blockId))return}return IG(n,t,o,r)}async function _G(n){return await Ab.default.toSvg(n)}function DE(n,t){return new DragEvent(t,{bubbles:!0,cancelable:!0,view:window,screenX:n.screenX,screenY:n.screenY,dataTransfer:new DataTransfer,clientX:n.clientX,clientY:n.clientY})}class MG{constructor(t){m(this,"img");m(this,"dragContainer",null);m(this,"autoScroll",null);m(this,"imageContainer",null);m(this,"startPosition",null);m(this,"handleMouseDown",t=>{const e=t.target;if(!e||!(e instanceof HTMLImageElement)||t.button!==0)return;const r=et(e);if(!r||!Xr(r)||!this.editor.isBlockWritable(r)||this.editor.readonly)return;const i=Le.getImageObject(this.editor,r);if(this.imageContainer=AE(t.target),!this.imageContainer)return;const s=FR(t.target).indexOf(this.imageContainer);if(s===-1)return;const l=i.getImages()[s];if(!l)return;const{x:c,y:d}=t;this.startPosition={x:c,y:d};const h={image:l,index:s,boundingRect:this.imageContainer.getBoundingClientRect()},C=DE(t,"dragstart");EG(this.editor,C,r,"image",h),document.addEventListener("mouseup",this.handleDragEnd),this.editor.contentElement.addEventListener("mousemove",this.handleDrag),t.preventDefault()});m(this,"handleDragStart",async t=>{if(!this.imageContainer)return;const e=et(this.imageContainer);if(!e)return;const{x:r,y:i}=t,{width:o,height:s}=t.target.getBoundingClientRect(),l=re(e),c=B("div",["drag-container"],l);c.style.left=`${r-o/4}px`,c.style.top=`${i-s/4}px`,c.style.width=`${Math.max(o/2,16)}px`,c.style.height=`${s/2}px`,this.dragContainer=c,z(this.editor.contentElement,"dragging");const d=En(e);this.autoScroll=new Vd({scrollElement:d,trackMouseEvent:"mousemove",edge:{top:50,bottom:50}}),this.autoScroll.active();const h=B("img",["drag-target"],c),E=await _G(this.imageContainer);E&&(h.src=E)});m(this,"handleDrag",t=>{var o;const{x:e,y:r}=t;if(((o=this.startPosition)==null?void 0:o.x)===e&&this.startPosition.y===r)return;if(window.isDragging||(window.isDragging=!0,this.handleDragStart(t)),this.startPosition&&this.dragContainer){const{x:s,y:l}=t;if(s===0&&l===0){this.dragContainer.style.transform="",this.dragContainer.style.opacity="0";return}const{x:c,y:d}=this.startPosition,h=s-c,C=l-d;this.dragContainer.style.transform=`translate(${h}px, ${C}px)`,this.dragContainer.style.opacity="0.5"}const i=DE(t,"dragover");this.editor.contentElement.dispatchEvent(i)});m(this,"handleDragEnd",t=>{var e;if(window.isDragging=!1,this.dragContainer&&this.dragContainer.remove(),this.dragContainer=null,this.startPosition=null,this.imageContainer=null,(e=this.autoScroll)==null||e.inactive(),ot(this.editor.contentElement,"dragging"),document.removeEventListener("mouseup",this.handleDragEnd),this.editor.contentElement.removeEventListener("mousemove",this.handleDrag),t){const r=DE(t,"drop");this.editor.contentElement.dispatchEvent(r)}});this.editor=t,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 UG{constructor(t){m(this,"handleFocusBlockChanged",(t,e,r)=>{const o=this.editor.getFocusedBlock();if(o&&Xr(o)){const s=Le.getImageObject(this.editor,o);s.getImages().length>0&&s.getSelectedIndex()===-1&&s.setSelectedIndex(0)}r&&Xr(r)&&t.findCustom(`image-${r.id}`)&&Le.getImageObject(this.editor,r).blockResizer.disableResize()});this.editor=t,this.editor.addListener("focusBlockChanged",this.handleFocusBlockChanged)}destroy(){this.editor.removeListener("focusBlockChanged",this.handleFocusBlockChanged)}}class OG{constructor(t){m(this,"currentResizer",null);m(this,"handleHoveringBlockChange",(t,e)=>{window.isDragging||(e&&this.disable(e),t&&(this.currentResizer=t,this.enable(t)))});this.editor=t,Be.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){Be.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}disable(t){Xr(t)&&Le.getImageObject(this.editor,t).disableResizer()}enable(t){if(Xr(t)){const e=Le.getImageObject(this.editor,t);this.editor.isBlockWritable(t)&&e.tryEnableResizer()}}}const NG={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"}},PG={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"}},FG={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"}};D.mergeLang({"zh-CN":NG,"en-US":PG,"ja-JP":FG});function KG(n,t,e,r){const i=n.getBlockByIndex(t,e),o=n.getBlockText(i),{left:s}=_n(o,r),l=fe(s);let c=r;if(l.endsWith("![]()"))c-=5;else if(l.endsWith("![]"))c-=3;else return!1;const d=r;return ha("image/*").then(h=>{n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(i,c,d-c);let C=e+1;fe(n.getBlockText(i)).trim()?(Ra(n,i,c,{forceInsertAfter:!0}),c===0&&(n.deleteBlock(i),C--)):(n.deleteBlock(i),C--),t1(n,"image",t,C,{file:h})})}),!0}class VG{handleAfterInsertText(t,e,r,i,o){if(o===" "){if(V0(t,e))return!1;if(KG(t,e,r,i))return!0}return!1}}const $G=I("copy-image");function HG(n,t,e,r){const i=e.getImages()[r],o=e.getImages().length===1?e.getWidthPercent():i.flex*100,s=dn([i],o),l={id:Z(),type:"embed",embedType:"image",embedData:s},c=n.options.componentsOptions.image;c!=null&&c.defaultAlign&&(l.align=c.defaultAlign);const d={blocks:{root:[l]},comments:{},meta:{}},h=document.createElement("canvas");h.width=t.naturalWidth,h.height=t.naturalHeight;const C=h.getContext("2d");if(!C)return;const E={},A={};try{C.drawImage(t,0,0,h.width,h.height);const F=h.toDataURL("image/png").replace(/^data:image\/(png|jpg);base64,/,""),G=Pg(F),W=new File([G],`${Date.now()}.png`,{type:"image/png"});E["image/png"]=W}catch(U){$G.error(U)}Ia(n,d);const R=`<img src="${n.doc.buildResourceUrl(i.src,{withToken:!0})}" />`,L=La(R,d),M=new Blob([L],{type:"text/html"});return E["text/html"]=M,A["text/html"]=L,[E,A]}function jG(n,t,e,r,i){const o=HG(n,t,e,r);if(!o)return;const[s,l]=o;if(s){const c=Object.entries(s).map(([d,h])=>({type:d,data:h}));return da(c).then(d=>{if(!d&&i){const h=i.clipboardData;h&&(h.setData("text/plain",l["text/plain"]),h.setData("text/html",l["text/html"]))}}),!0}}function Q0(n,t){const e=n.selection.range;if(e.start.blockId!==e.end.blockId)return;const i=n.getFocusedBlock();if(i&&Xr(i)){const o=Le.getImageObject(n,i);if(o.getImages().length>0){const l=o.getSelectedIndex();if(l!==-1){const d=yi(i)[l].querySelector("img");if(d)return jG(n,d,o,l,t)}}}}function zG(n){const t=n.getFocusedBlock(),e=zs(t);if(e&&Xr(e)){n.selection.selectBlock(e,0);const r=Le.getImageObject(n,e);return r.getImages().length>0&&r.setSelectedIndex(0),!0}}function GG(n){const t=n.getFocusedBlock(),e=js(t);if(e&&Xr(e)){n.selection.selectBlock(e,0);const r=Le.getImageObject(n,e);return r.getImages().length>0&&r.setSelectedIndex(0),!0}}function WG(n){const e=n.getFocusedBlock();if(e&&Xr(e)){const r=Le.getImageObject(n,e),i=r.getImages();if(i.length>0){const o=r.getSelectedIndex();if(o===-1)return r.setSelectedIndex(i.length-1),!0;if(o>0)return r.setSelectedIndex(o-1),!0}}}function qG(n){const e=n.getFocusedBlock();if(e&&Xr(e)){const r=Le.getImageObject(n,e),i=r.getImages();if(i.length>0){const o=r.getSelectedIndex();if(o===-1)return r.setSelectedIndex(0),!0;if(o<i.length-1)return r.setSelectedIndex(o+1),!0}}}function Y0(n){const e=n.getFocusedBlock();if(e&&Xr(e)){const r=Le.getImageObject(n,e);if(r.getImages().length>0){const o=r.getSelectedIndex();if(o!==-1)return r.removeImage(o),!0}}}const XG={ArrowLeft:WG,ArrowRight:qG,ArrowUp:GG,ArrowDown:zG,Delete:Y0,Backspace:Y0};class QG{constructor(t){this.editor=t,setTimeout(()=>{this.editor.input.addHandler(this)})}handleBeforeCopy(t,e,r){if(!window.isSecureContext)return;if(Q0(t,e))return!0}handleBeforeCut(t,e){if(Q0(t,e))return Y0(t),!0}destroy(){}}class _E{constructor(t){this.editor=t,setTimeout(()=>{this.editor.input.addHandler(this)})}async handleAfterPasteDoc(t,e,r){return Object.values(e.blocks).forEach(i=>{i.forEach(o=>{if(o.type==="embed"&&o.embedType==="image"){const s=o.embedData;if(Array.isArray(s.src))return;let l=r.blockIdMap.get(o.id);for(;l&&r.blockIdMap.get(l);)l=r.blockIdMap.get(l);l&&as(t,l).setAutoFix(!0)}})}),!1}destroy(){}}const YG=I("image-embed");function JG(n,t,e,r,i,o){Le.create(n,e).createContent(i,o,t),n.addCustom("image-select-handler",()=>new UG(n)),n.addCustom("image-copy-handler",()=>new QG(n)),setTimeout(()=>{n.addCustom("drag-handler",()=>new MG(n));const l=n.addCustom("image-resizer",()=>new OG(n)),c=e.embedData;oc(c)?l.disable(o):l.currentResizer===o&&l.enable(o)})}function ZG(n,t,e,r){const i=t.embedData,o=lc(i);return r==="html"?o.map(s=>`<img src="${n.doc.buildResourceUrl(s.src,{withToken:!0})}">`).join(""):r==="markdown"?`${o.map(l=>`})`).join(`
|
|
666
|
+
Click to open the menu`,insertTips:"Click to add block"}}},gG={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:"\u8907\u88FD",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"}}};D.mergeLang({"zh-CN":hG,"en-US":mG,"ja-JP":gG});const jct="";class pG{constructor(){m(this,"dragObject",null)}setData(t){this.dragObject=t}getData(){return this.dragObject}clearData(){this.dragObject=null}destroy(){}}function q0(n){return n.addCustom("drag-data",()=>new pG)}function LE(n,t){if(!t)return null;const e=q0(n).getData();return!e||e.editorId!==n.id?null:e}function rw(n,t){const e=LE(n,t);return e?n.findBlockById(e.blockId):null}function CG(n,t,e){if(!t.dataTransfer)return;const i=rt(e),o=ft(i),s=st(e),l={type:"block",editorId:n.id,containerId:o,blockId:s};q0(n).setData(l)}function EG(n,t,e,r,i){if(!t.dataTransfer)return;const s=rt(e),l=ft(s),c=st(e),d={type:"custom",customType:r,editorId:n.id,containerId:l,blockId:c,data:i};q0(n).setData(d)}function gf(n){q0(n).clearData()}const xG=I("drop-indicator"),pf=2;class AG{constructor(t){m(this,"indicator");m(this,"target",null);this.editor=t,this.indicator=B("div",["editor-drop-indicator"],this.editor.contentElement)}show(t,e){const r=this.getIndicatorRect(t,e),i=this.editor.rootElement.getBoundingClientRect(),o=r.top-i.top,s=r.left-i.left;this.indicator.style.top=`${o}px`,this.indicator.style.left=`${s}px`,this.indicator.style.width=`${r.width}px`,this.indicator.style.height=`${r.height}px`,this.indicator.style.display="",this.target={block:t,insertPos:e}}hide(){this.indicator.style.display="none",this.target=null}getIndicatorRect(t,e){if(typeof e!="string")return e.rect;if(e==="before"){const l=js(t);if(!l){p(xG,Mr(rt(t)),"block does not in a child container");const C=t.getBoundingClientRect(),E=this.getViewRect(t);return new DOMRect(E.x,C.y,E.width,pf)}const c=l.getBoundingClientRect(),d=t.getBoundingClientRect(),h=this.getViewRect(t);return new DOMRect(h.x,(c.bottom+d.top)/2,h.width,pf)}const r=zs(t);if(!r){const l=t.getBoundingClientRect(),c=this.getViewRect(t);return new DOMRect(c.x,l.bottom,c.width,pf)}const i=t.getBoundingClientRect(),o=r.getBoundingClientRect(),s=this.getViewRect(t);return new DOMRect(s.x,(i.bottom+o.top)/2,s.width,pf)}getViewRect(t){const e=En(t,{horizontal:!0}),r=t.getBoundingClientRect(),i=e.getBoundingClientRect(),o=Math.max(i.x-r.x,0),s=Math.max(r.right-i.right,0);return new DOMRect(r.x+o,r.y,Math.max(r.width-o-s,0),pf)}}const bG=I("find-drop-target");function vG(n,t){const e=document.elementFromPoint(n,t);if(!e)return null;if(Wi(e)&&Mr(e))return e;const r=e.firstElementChild;return r&&Wi(r)&&Mr(r)?r:null}function BG(n,t){const s=t,l=n;for(let c=0;c<2;c++){const d=l+c*50;for(let h=0;h<5;h++){const C=s+h*8,E=document.elementFromPoint(d,C);if(E){const R=et(E);if(R)return R}if(h===0)continue;const A=s-h*8,v=document.elementFromPoint(d,A);if(v){const R=et(v);if(R)return R}}}return null}function TG(n,t,e){const r=document.elementFromPoint(t,e);if(r){const h=et(r);if(h&&!Dt(n,h))return h}const i=new Set,o=vG(t,e);if(o){const h=o.getBoundingClientRect();e<h.top+h.height/2?i.add(we(o)):i.add(Ze(o))}const s=BG(t,e);s&&i.add(s);const l=Array.from(i),c=h=>{for(let C=0;C<l.length;C++){const E=l[C];if(h!==E&&ne(h,E))return!0}return!1},d=l.filter(h=>!c(h));return d.length>0?d[0]:null}function IE(n,t){if(n.readonly)return!1;const e=rt(t);if(Xt(e))return!0;const r=et(e);return p(bG,r,"no parent block"),n.isBlockWritable(r)?IE(n,r):!1}const yG=I("drop-target");function kG(n,t){let e={};return/image/.test(t.type)?e=n.editorEmbeds.getEmbedClass("image"):/audio/.test(t.type)?e=n.editorEmbeds.getEmbedClass("audio"):/video/.test(t.type)&&(e=n.editorEmbeds.getEmbedClass("video")),p(yG,e,`unSupport file type ${t.type}`),e}async function iw(n,t,e,r){var o,s;let i=r;for(const l of t){const c=kG(n,l);c.getOptions&&await((s=(o=c.getOptions(n)).handleInsertEmptyEmbed)==null?void 0:s.call(o,n,{containerId:e,blockIndex:i,data:{file:l}}))&&(i+=1)}}class RG{constructor(t){m(this,"handleDrop",(t,e,r,i)=>{if(Array.isArray(e)){const o=e;if(o.length>0){const s=ft(r);return iw(t,o,s,i),!0}}return!1});this.editor=t}}class Cf{constructor(t){m(this,"indicator");m(this,"lastDropOverResult");m(this,"handlers",[]);m(this,"handleDragOver",t=>{if(!this.editor.isWritable())return;const e=o=>{var d,h;const s=LE(this.editor,o.dataTransfer),l=rw(this.editor,o.dataTransfer),c=this.findTargetBlock(l,o.x,o.y);if(c&&ne(this.editor.rootContainer,c)){const C=this.findInsertPos(l,c,o.x,o.y,(h=s!=null?s:(d=o.dataTransfer)==null?void 0:d.items)!=null?h:null);if(C)return this.indicator.show(c,C),"move"}return this.indicator.hide(),"none"},r=(o,s)=>{o.dataTransfer&&(o.dataTransfer.dropEffect=s),s==="move"&&o.preventDefault()};if(this.lastDropOverResult&&t.x===this.lastDropOverResult.x&&t.y===this.lastDropOverResult.y){const o=this.lastDropOverResult.dropEffect;r(t,o);return}const i=e(t);r(t,i),this.lastDropOverResult={x:t.x,y:t.y,dropEffect:i}});m(this,"handleDrop",t=>{var o,s;t.stopPropagation(),setTimeout(()=>{this.indicator.hide()});const e=LE(this.editor,t.dataTransfer),r=Array.from((s=(o=t.dataTransfer)==null?void 0:o.files)!=null?s:[]);if(!e&&r.length===0){t.dataTransfer&&(t.dataTransfer.dropEffect="none"),gf(this.editor);return}const i=this.indicator.target;if(i){const{block:l,insertPos:c}=i,d=rw(this.editor,t.dataTransfer);this.editor.undoManager.runInGroup(()=>{const h=Yt(this.editor,l);if(h.handleDrop&&h.handleDrop(this.editor,l,e!=null?e:r,c,{isSourceBlock:!1,targetBlock:l})){t.preventDefault(),this.editor.focus(),gf(this.editor);return}if(d){const C=Yt(this.editor,d);if(C.handleDrop&&C.handleDrop(this.editor,d,e!=null?e:r,c,{isSourceBlock:!0,targetBlock:l})){t.preventDefault(),this.editor.focus(),gf(this.editor);return}}if(typeof c=="string"){const C=rt(l);let E=bt(l);if(c==="after"){E+=1;let A=qt(l);for(;A&&!ou(A);)E+=1,A=qt(A)}t.preventDefault();for(let A=0;A<this.handlers.length;A++)if(this.handlers[A].handleDrop(this.editor,d!=null?d:r,C,E)){this.editor.focus(),gf(this.editor);return}if(d){const A=this.editor.getBlockData(d),v=qo(this.editor.editorBlocks,this.editor.doc.toJSON(),A),[R]=this.editor.insertDocAt(C,E,v);this.editor.selection.selectBlock(R,0),mf.get(this.editor).highlightBlock(R),this.editor.deleteBlock(d),this.editor.focus()}}})}gf(this.editor)});m(this,"handleDragLeave",()=>{this.indicator.hide()});this.editor=t,this.indicator=new AG(this.editor),this.handlers.push(new RG(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(t){this.handlers.push(t)}static register(t){return t.addCustom("drop-target",()=>new Cf(t))}static get(t){return t.getCustom("drop-target")}static find(t){return t.findCustom("drop-target")}canInsertAfter(t,e){return!(this.editor.readonly||zs(e)===t&&t||!IE(this.editor,e))}canInsertBefore(t,e){return!(this.editor.readonly||js(e)===t&&t||!IE(this.editor,e)||Xt(rt(e))&&bt(e)===0)}canDrop(t,e){return t===null||t===e?!0:!ne(t,e)}findTargetBlock(t,e,r){let i=TG(this.editor,e,r);if(!i||!ne(this.editor.rootContainer,i))return null;const o=rt(i),s=et(o);return s&&St(s)==="code"&&(i=s),this.canDrop(t,i)?i:null}findInsertPos(t,e,r,i,o){let s=e;for(;s;){const c=Yt(this.editor,s);if(c.handleDropOver){const d=c.handleDropOver(this.editor,s,o,r,i);if(d)return d;if(d===!1)return null}s=$s(s)}if(t===e)return"";const l=e.getBoundingClientRect();if(l.top<=i&&i<=l.bottom){if(i<l.top+l.height/2){if(this.canInsertBefore(t,e))return"before";if(this.canInsertAfter(t,e))return"after"}else{if(this.canInsertAfter(t,e))return"after";if(this.canInsertBefore(t,e))return"before"}return""}return i<l.top&&this.canInsertBefore(t,e)?"before":l.bottom<i&&this.canInsertAfter(t,e)?"after":""}}function ow(n,t,e){const r=Le.getImageObject(n,t),i=gt.default(r.getImages());if(i.length===1){n.deleteBlock(t);return}if(e===-1||e>=i.length)return;const o=mz(i);if(i.splice(e,1),i.length===1){const l=i[0],c=100*(l.flex/o);l.flex=1;const d=dn([l],c);n.updateEmbedData(t,d);return}i[0].flex=NaN,sc(i);const s=dn(i,r.getWidthPercent());n.updateEmbedData(t,s)}function wG(n,t,e,r){if(t.length===0||r==="after"||r==="before")return!1;let i=r.data;const o=Le.getImageObject(n,e),s=gt.default(o.getImages()),l=[],c=[];t.forEach(C=>{zR(C.type)&&s.length+l.length<6?l.push(C):c.push(C)}),l.forEach(C=>{try{jR(n,C)}catch{return}const E={src:"",flex:1,width:0,height:0,virtualSize:!0};s.splice(i,0,E);const A=dn(s,o.getWidthPercent());n.updateEmbedData(e,A),o.replaceImage(i,C),i+=1});const d=n.getBlockIndex(e)+1,h=ft(rt(e));return iw(n,c,h,d),!0}function SG(n,t,e,r,i){var s,l,c;if(Fd(e))return wG(n,e,t,r);if(e.type!=="custom"||e.customType!=="image"||!e.data)return;const o=e.data;if(i.isSourceBlock){const d=i.targetBlock,h=rt(d);let C=bt(d);r==="after"&&(C+=1);const A=100*(o.boundingRect.width/n.rootContainer.getBoundingClientRect().width),v=dn([o.image],A),R={id:Z(),type:"embed",embedType:"image",embedData:v},L=(l=(s=n.options.componentsOptions)==null?void 0:s.image)==null?void 0:l.defaultAlign;L&&(R.align=L),n.insertBlock(ft(h),C,R),ow(n,t,o.index),(c=n.findCustom("drag-handler"))==null||c.handleDragEnd()}else{if(typeof r=="string")return;const d=t;let h=r.data;const C=Le.getImageObject(n,d),E=gt.default(C.getImages());h>E.length&&(h=E.length),n.undoManager.runInGroup(()=>{var v,R;C.setAutoFix(!0);const A=n.getBlockById(e.blockId);if(A===d){const L=o.index,M=h,U=o.image;if(L===M||M===L+1)return;let F=M;L<M?(E.splice(M,0,U),E.splice(L,1),F-=1):(E.splice(L,1),E.splice(M,0,U));const G=dn(E,C.getWidthPercent());n.updateEmbedData(d,G),C.setSelectedIndex(F),(v=n.findCustom("drag-handler"))==null||v.handleDragEnd()}else{E.splice(h,0,o.image),E[0].flex=NaN,sc(E);const L=dn(E,C.getWidthPercent());n.updateEmbedData(d,L),ow(n,A,o.index),(R=n.findCustom("drag-handler"))==null||R.handleDragEnd(),C.setSelectedIndex(h),n.selection.selectBlock(d,0)}})}return!0}const LG=2;function X0(n,t,e){const r=yi(t);if(e<=0){const s=r[0].getBoundingClientRect();return new DOMRect(s.left-4,s.top,2,s.height)}if(e===r.length){const s=r[e-1].getBoundingClientRect();return new DOMRect(s.right+2,s.top,2,s.height)}const i=r[e-1].getBoundingClientRect(),o=r[e].getBoundingClientRect();return new DOMRect((o.left+i.right)/2-1,i.top,LG,i.height)}function IG(n,t,e,r,i){for(let o=0;o<e.length;o++){const l=e[o].getBoundingClientRect();if(r<=l.right)return r<=l.left+l.width/2?{rect:X0(n,t,o),data:o}:{rect:X0(n,t,o+1),data:o+1}}return r>e[e.length-1].getBoundingClientRect().right?{rect:X0(n,t,e.length),data:e.length}:{rect:X0(n,t,e.length),data:0}}function DG(n,t,e,r,i){const o=yi(t);if(e instanceof DataTransferItemList){if(!Array.from(e).some(s=>zR(s.type))||o.length>=6)return}else{if((e==null?void 0:e.type)==="block"||o.length>=6&&(e==null?void 0:e.blockId)!==st(t))return;const s=st(t);if(o.length===1&&s===(e==null?void 0:e.blockId))return}return IG(n,t,o,r)}async function _G(n){return await Ab.default.toSvg(n)}function DE(n,t){return new DragEvent(t,{bubbles:!0,cancelable:!0,view:window,screenX:n.screenX,screenY:n.screenY,dataTransfer:new DataTransfer,clientX:n.clientX,clientY:n.clientY})}class MG{constructor(t){m(this,"img");m(this,"dragContainer",null);m(this,"autoScroll",null);m(this,"imageContainer",null);m(this,"startPosition",null);m(this,"handleMouseDown",t=>{const e=t.target;if(!e||!(e instanceof HTMLImageElement)||t.button!==0)return;const r=et(e);if(!r||!Xr(r)||!this.editor.isBlockWritable(r)||this.editor.readonly)return;const i=Le.getImageObject(this.editor,r);if(this.imageContainer=AE(t.target),!this.imageContainer)return;const s=FR(t.target).indexOf(this.imageContainer);if(s===-1)return;const l=i.getImages()[s];if(!l)return;const{x:c,y:d}=t;this.startPosition={x:c,y:d};const h={image:l,index:s,boundingRect:this.imageContainer.getBoundingClientRect()},C=DE(t,"dragstart");EG(this.editor,C,r,"image",h),document.addEventListener("mouseup",this.handleDragEnd),this.editor.contentElement.addEventListener("mousemove",this.handleDrag),t.preventDefault()});m(this,"handleDragStart",async t=>{if(!this.imageContainer)return;const e=et(this.imageContainer);if(!e)return;const{x:r,y:i}=t,{width:o,height:s}=t.target.getBoundingClientRect(),l=re(e),c=B("div",["drag-container"],l);c.style.left=`${r-o/4}px`,c.style.top=`${i-s/4}px`,c.style.width=`${Math.max(o/2,16)}px`,c.style.height=`${s/2}px`,this.dragContainer=c,z(this.editor.contentElement,"dragging");const d=En(e);this.autoScroll=new Vd({scrollElement:d,trackMouseEvent:"mousemove",edge:{top:50,bottom:50}}),this.autoScroll.active();const h=B("img",["drag-target"],c),E=await _G(this.imageContainer);E&&(h.src=E)});m(this,"handleDrag",t=>{var o;const{x:e,y:r}=t;if(((o=this.startPosition)==null?void 0:o.x)===e&&this.startPosition.y===r)return;if(window.isDragging||(window.isDragging=!0,this.handleDragStart(t)),this.startPosition&&this.dragContainer){const{x:s,y:l}=t;if(s===0&&l===0){this.dragContainer.style.transform="",this.dragContainer.style.opacity="0";return}const{x:c,y:d}=this.startPosition,h=s-c,C=l-d;this.dragContainer.style.transform=`translate(${h}px, ${C}px)`,this.dragContainer.style.opacity="0.5"}const i=DE(t,"dragover");this.editor.contentElement.dispatchEvent(i)});m(this,"handleDragEnd",t=>{var e;if(window.isDragging=!1,this.dragContainer&&this.dragContainer.remove(),this.dragContainer=null,this.startPosition=null,this.imageContainer=null,(e=this.autoScroll)==null||e.inactive(),ot(this.editor.contentElement,"dragging"),document.removeEventListener("mouseup",this.handleDragEnd),this.editor.contentElement.removeEventListener("mousemove",this.handleDrag),t){const r=DE(t,"drop");this.editor.contentElement.dispatchEvent(r)}});this.editor=t,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 UG{constructor(t){m(this,"handleFocusBlockChanged",(t,e,r)=>{const o=this.editor.getFocusedBlock();if(o&&Xr(o)){const s=Le.getImageObject(this.editor,o);s.getImages().length>0&&s.getSelectedIndex()===-1&&s.setSelectedIndex(0)}r&&Xr(r)&&t.findCustom(`image-${r.id}`)&&Le.getImageObject(this.editor,r).blockResizer.disableResize()});this.editor=t,this.editor.addListener("focusBlockChanged",this.handleFocusBlockChanged)}destroy(){this.editor.removeListener("focusBlockChanged",this.handleFocusBlockChanged)}}class OG{constructor(t){m(this,"currentResizer",null);m(this,"handleHoveringBlockChange",(t,e)=>{window.isDragging||(e&&this.disable(e),t&&(this.currentResizer=t,this.enable(t)))});this.editor=t,Be.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){Be.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}disable(t){Xr(t)&&Le.getImageObject(this.editor,t).disableResizer()}enable(t){if(Xr(t)){const e=Le.getImageObject(this.editor,t);this.editor.isBlockWritable(t)&&e.tryEnableResizer()}}}const NG={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"}},PG={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"}},FG={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"}};D.mergeLang({"zh-CN":NG,"en-US":PG,"ja-JP":FG});function KG(n,t,e,r){const i=n.getBlockByIndex(t,e),o=n.getBlockText(i),{left:s}=_n(o,r),l=fe(s);let c=r;if(l.endsWith("![]()"))c-=5;else if(l.endsWith("![]"))c-=3;else return!1;const d=r;return ha("image/*").then(h=>{n.undoManager.runInGroup(()=>{n.deleteTextFromBlock(i,c,d-c);let C=e+1;fe(n.getBlockText(i)).trim()?(Ra(n,i,c,{forceInsertAfter:!0}),c===0&&(n.deleteBlock(i),C--)):(n.deleteBlock(i),C--),t1(n,"image",t,C,{file:h})})}),!0}class VG{handleAfterInsertText(t,e,r,i,o){if(o===" "){if(V0(t,e))return!1;if(KG(t,e,r,i))return!0}return!1}}const $G=I("copy-image");function HG(n,t,e,r){const i=e.getImages()[r],o=e.getImages().length===1?e.getWidthPercent():i.flex*100,s=dn([i],o),l={id:Z(),type:"embed",embedType:"image",embedData:s},c=n.options.componentsOptions.image;c!=null&&c.defaultAlign&&(l.align=c.defaultAlign);const d={blocks:{root:[l]},comments:{},meta:{}},h=document.createElement("canvas");h.width=t.naturalWidth,h.height=t.naturalHeight;const C=h.getContext("2d");if(!C)return;const E={},A={};try{C.drawImage(t,0,0,h.width,h.height);const F=h.toDataURL("image/png").replace(/^data:image\/(png|jpg);base64,/,""),G=Pg(F),W=new File([G],`${Date.now()}.png`,{type:"image/png"});E["image/png"]=W}catch(U){$G.error(U)}Ia(n,d);const R=`<img src="${n.doc.buildResourceUrl(i.src,{withToken:!0})}" />`,L=La(R,d),M=new Blob([L],{type:"text/html"});return E["text/html"]=M,A["text/html"]=L,[E,A]}function jG(n,t,e,r,i){const o=HG(n,t,e,r);if(!o)return;const[s,l]=o;if(s){const c=Object.entries(s).map(([d,h])=>({type:d,data:h}));return da(c).then(d=>{if(!d&&i){const h=i.clipboardData;h&&(h.setData("text/plain",l["text/plain"]),h.setData("text/html",l["text/html"]))}}),!0}}function Q0(n,t){const e=n.selection.range;if(e.start.blockId!==e.end.blockId)return;const i=n.getFocusedBlock();if(i&&Xr(i)){const o=Le.getImageObject(n,i);if(o.getImages().length>0){const l=o.getSelectedIndex();if(l!==-1){const d=yi(i)[l].querySelector("img");if(d)return jG(n,d,o,l,t)}}}}function zG(n){const t=n.getFocusedBlock(),e=zs(t);if(e&&Xr(e)){n.selection.selectBlock(e,0);const r=Le.getImageObject(n,e);return r.getImages().length>0&&r.setSelectedIndex(0),!0}}function GG(n){const t=n.getFocusedBlock(),e=js(t);if(e&&Xr(e)){n.selection.selectBlock(e,0);const r=Le.getImageObject(n,e);return r.getImages().length>0&&r.setSelectedIndex(0),!0}}function WG(n){const e=n.getFocusedBlock();if(e&&Xr(e)){const r=Le.getImageObject(n,e),i=r.getImages();if(i.length>0){const o=r.getSelectedIndex();if(o===-1)return r.setSelectedIndex(i.length-1),!0;if(o>0)return r.setSelectedIndex(o-1),!0}}}function qG(n){const e=n.getFocusedBlock();if(e&&Xr(e)){const r=Le.getImageObject(n,e),i=r.getImages();if(i.length>0){const o=r.getSelectedIndex();if(o===-1)return r.setSelectedIndex(0),!0;if(o<i.length-1)return r.setSelectedIndex(o+1),!0}}}function Y0(n){const e=n.getFocusedBlock();if(e&&Xr(e)){const r=Le.getImageObject(n,e);if(r.getImages().length>0){const o=r.getSelectedIndex();if(o!==-1)return r.removeImage(o),!0}}}const XG={ArrowLeft:WG,ArrowRight:qG,ArrowUp:GG,ArrowDown:zG,Delete:Y0,Backspace:Y0};class QG{constructor(t){this.editor=t,setTimeout(()=>{this.editor.input.addHandler(this)})}handleBeforeCopy(t,e,r){if(!window.isSecureContext)return;if(Q0(t,e))return!0}handleBeforeCut(t,e){if(Q0(t,e))return Y0(t),!0}destroy(){}}class _E{constructor(t){this.editor=t,setTimeout(()=>{this.editor.input.addHandler(this)})}async handleAfterPasteDoc(t,e,r){return Object.values(e.blocks).forEach(i=>{i.forEach(o=>{if(o.type==="embed"&&o.embedType==="image"){const s=o.embedData;if(Array.isArray(s.src))return;let l=r.blockIdMap.get(o.id);for(;l&&r.blockIdMap.get(l);)l=r.blockIdMap.get(l);l&&as(t,l).setAutoFix(!0)}})}),!1}destroy(){}}const YG=I("image-embed");function JG(n,t,e,r,i,o){Le.create(n,e).createContent(i,o,t),n.addCustom("image-select-handler",()=>new UG(n)),n.addCustom("image-copy-handler",()=>new QG(n)),setTimeout(()=>{n.addCustom("drag-handler",()=>new MG(n));const l=n.addCustom("image-resizer",()=>new OG(n)),c=e.embedData;oc(c)?l.disable(o):l.currentResizer===o&&l.enable(o)})}function ZG(n,t,e,r){const i=t.embedData,o=lc(i);return r==="html"?o.map(s=>`<img src="${n.doc.buildResourceUrl(s.src,{withToken:!0})}">`).join(""):r==="markdown"?`${o.map(l=>`})`).join(`
|
|
667
667
|
`)}
|
|
668
668
|
`:""}class tW{constructor(){m(this,"group","image");m(this,"commands",[])}executeCommand(t,e,r){if(r.id==="replace-image"){const{block:i,image:o}=r.data;Le.getImageObject(t,i).replaceImage(0,o)}}}function eW(){return{blockCommands:{image:new tW},abstract:`${D.t("image.abstract")}`}}function nW(){return{name:"Image",insertEmbedCommandItems:[{id:"insert-image",name:D.t("image.abstract"),icon:yT,group:"common",subText:"/image",order:100}],handleInsertEmptyEmbed:async(n,t)=>{var A;let e;(A=t.data)!=null&&A.file&&(e=t.data.file);const r=HR(n);if(e=e!=null?e:await ha(r),!e)return null;try{jR(n,e)}catch{return null}let i={width:sf,height:SR};try{i=await az(e)}catch(v){YG.error(v)}const o=n.rootContainer.clientWidth,s=i.width<o?Math.min(100,i.width/o*100):100,l={src:"",width:i.width,height:i.height,flex:1,virtualSize:!1},c=dn([l],s),d={id:Z(),type:"embed",embedType:"image",embedData:c},h=n.options.componentsOptions.image;h!=null&&h.defaultAlign&&(d.align=h.defaultAlign);const C=n.insertBlock(t.containerId,t.blockIndex,d);return Le.getImageObject(n,C).replaceImage(0,e),C}}}function rW(n,t,e){var h;const{data:r}=e,i=n.getBlockString(t).trim();if(!r||r.embedType!=="image"||!nt(n,t))return null;const o=i.match(/^!\[[^\]]*\]\((?<filename>.*?)(?="|\))(?<optionalPart>".*")?\)/),s=(h=o==null?void 0:o.groups)==null?void 0:h.filename;if(!s)return null;const l={src:s},c={id:Z(),type:"embed",embedType:"image",embedData:l};Le.create(n,c).setAutoFix(!0);const d=n.options.componentsOptions.image.defaultAlign;return d&&(c.align=d),{blockData:c}}function iW(n,t){const e=st(t);n.destroyCustom(`image-${e}`)}const oW={embedType:"image",createEmbedContent:JG,convertTo:ZG,convertFrom:rW,getBlockProperties:eW,getOptions:nW,handleDrop:SG,handleDropOver:DG,handleDeleteBlock:iW};class sW{constructor(t,e){m(this,"toolbar");m(this,"anchor",null);m(this,"item");m(this,"docs",null);m(this,"checkedId");m(this,"handlePasteSpecial",(t,e)=>{!e.data||(this.checkedId===e.id?this.checkedId=void 0:this.checkedId=e.id,this.onPasteSpecial(this.cleaningDoc(e)),setTimeout(()=>{this.docs&&this.show(this.docs),this.editor.focus()}))});m(this,"handleClose",()=>{this.editor.focus()});m(this,"handleSelectionChange",()=>{});this.editor=t,this.onPasteSpecial=e,this.item={id:"paste-special",name:"",icon:kT,dropdown:!0,manualShowChildren:!0,childrenPlacement:"bottom-start",childrenOffset:[-4,4],children:[]},this.toolbar=new Pu([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(t){this.docs=t;const e=this.editor,r=e.selection.range;if(!r.isCollapsed())return;const i=e.getBlockById(r.start.blockId);if(!nt(e,i))return;const o=qi(e,i,r)[0];if(!o)return;this.anchor&&this.anchor.remove(),this.anchor=Yi(e,i,"paste-special-button-anchor",o);const s=this.getCommandItems(t);this.item.children=s,this.toolbar.manualShow(this.anchor)}cleaningDoc(t){const e=t.id,r=t.data;return e!=="text/plain"||Object.values(r.blocks).forEach(i=>{i.forEach(o=>{o.text&&o.text.forEach(s=>{if(s.attributes){const l=s.attributes;Object.keys(l).forEach(c=>{c==="link"&&delete l[c]})}})})}),r}hide(){this.toolbar.close("selectionChange")}clearCheckedState(){this.checkedId=void 0}destroy(){this.toolbar.destroy(),this.editor.removeListener("selectionChanged",this.handleSelectionChange)}getCommandItems(t){const e=o=>({id:o,states:this.checkedId===o?["checked"]:void 0,name:D.t("pasteSpecial.originFormats"),data:t[o]}),r=[];let i=!0;return t["text/x-ones-editor-doc"]?r.push(e("text/x-ones-editor-doc")):t["text/office-html"]?r.push(e("text/office-html")):t["text/html"]?r.push(e("text/html")):t["text/plain"]&&(r.push(e("text/plain")),i=!1),t["text/plain"]&&(i&&r.push({id:"text/plain",states:this.checkedId==="text/plain"?["checked"]:void 0,name:D.t("pasteSpecial.plainText"),data:t["text/plain"]}),r.push({id:"text/markdown",states:this.checkedId==="text/markdown"?["checked"]:void 0,name:D.t("pasteSpecial.markdown"),data:t["text/markdown"]})),r}}const lW=I("paste-special");class ME{constructor(t){m(this,"button");m(this,"lastUndoAction",null);m(this,"lastPos",null);m(this,"event",null);m(this,"handlePasteSpecial",t=>{this.editor.undoManager.runInGroup(()=>{this.editor.undoManager.undoTo(this.lastUndoAction),this.editor.pasteDoc(t)})});this.editor=t,this.button=new sW(t,this.handlePasteSpecial)}destroy(){this.event=null,this.button.destroy()}handleChanged(t,e){this.event=null,this.button.hide()}async handleBeforePaste(t,e){return lW.debug("before paste"),this.lastUndoAction=t.undoManager.lastAction(),this.lastPos=t.selection.range.start,!1}async handleAfterPaste(t,e,r){if(Object.keys(r).length<=1)return!1;const i=t.selection.range;if(i.isCollapsed()){const o=t.getBlockById(i.start.blockId);if(!nt(t,o))return!1;if(this.lastPos&&Or(this.lastPos)){const s=t.getBlockById(this.lastPos.blockId);if(Gi(s))return!1}this.button.clearCheckedState(),this.button.show(r),this.event=e}return!1}}const aW={pasteSpecial:{originFormats:"\u4FDD\u6301\u539F\u6837\u5F0F",plainText:"\u7C98\u8D34\u7EAF\u6587\u672C",markdown:"\u7C98\u8D34\u4E3A Markdown"}},cW={pasteSpecial:{originFormats:"Keep origin formats",plainText:"Paste as plain text",markdown:"Paste as markdown"}},uW={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"}};D.mergeLang({"zh-CN":aW,"en-US":cW,"ja-JP":uW});const zct="",fW=I("html-to-doc");function dW(n){const t=/(<canvas data-editor-doc=")[\s\S]*( id="ones-editor-doc"\s?>)/g;let e=n;ua()&&(e=n.replace(/style="(.*)"/,""));let r=e.match(t);if(!r||!r.length)return null;r=r.map(l=>l.replace(/(<canvas data-editor-doc=")/g,"").replace(/(" id="ones-editor-doc"\s?>)/g,""));const i=r[0],o=Zc(i);return JSON.parse(o)}function hW(n){const t="ones-editor-doc::",e="::ones-editor-doc";let r=n.indexOf(t);if(r!==-1){r+=t.length;const o=n.indexOf(e,r);if(o!==-1){const s=n.substr(r,o-r);try{const l=Zc(s);return JSON.parse(l)}catch(l){fW.error(`invalid doc data: ${l}, ${s}`)}}}const i=dW(n);return i||null}const sw="latex-b172fea480b",mW=n=>({name:"latex-block",level:"block",start(t){var e,r;return(r=(e=t.match(/\$\$[^\$]/))==null?void 0:e.index)!=null?r:-1},tokenizer(t,e){const r=/^\$\$([^\$]+)\$\$/.exec(t);return r?{type:"latex-block",raw:r[0],formula:r[1]}:void 0},renderer(t){return n.lazy?`<span class="${sw}" block>${t.formula}</span>`:n.render(t.formula,!0)}}),gW=n=>({name:"latex",level:"inline",start(t){var e,r;return(r=(e=t.match(/\$[^\$]/))==null?void 0:e.index)!=null?r:-1},tokenizer(t,e){const r=/^\$([^\$]+)\$/.exec(t);return r?{type:"latex",raw:r[0],formula:r[1]}:void 0},renderer(t){return n.lazy?`<span class="${sw}">${t.formula}</span>`:n.render(t.formula,!1)}});var pW=(n={})=>(n.lazy&&n.env!=="test"&&new IntersectionObserver((t,e)=>{for(const r of t){if(!r.isIntersecting)continue;const i=r.target;e.unobserve(i),Promise.resolve(n.render(i.innerText,i.hasAttribute("block"))).then(o=>{i.innerHTML=o}),i.classList.add("latex-rendered")}},{threshold:1}),{extensions:[mW(n),gW(n)]});function ac(n){const t=n.type;if(t==="link")return!!n.tokens.some(ac);switch(t){case"code":case"table":case"hr":case"blockquote":case"list":case"list_item":case"image":case"paragraph":return!0;default:return!1}}function CW(n){return!ac(n)}function EW(n){if(n.length===0)return[];if(n.length===1)return[n];const t=[];let e=[n[0]],r=ac(n[0]);for(let i=1;i<n.length;i++){const o=n[i];r===ac(o)?e.push(o):(t.push(e),e=[o],r=ac(o))}return t.push(e),t}function xW(n,t,e){let r=n.href;r.startsWith("mailto:")&&(r=r.substring(7));let i=e.tokensToText(n.tokens,t,e);return i.length===0&&(i=Zs(r,t)),i=ih(i,"link",r),i}let Ef;function UE(n){Ef||(Ef=document.createElement("textarea")),Ef.innerHTML=n;const t=Ef.childNodes.length===0?"":Ef.childNodes[0].nodeValue;return t!=null?t:""}function AW(n,t){const e=UE(n.text);return[gr(e,{...t,"style-code":!0})]}function bW(n,t,e){const i=n.tokens;return i?e.tokensToText(i,t,e):_1(UE(n.text),t)}const vW=I("token-to-text");function OE(n,t,e){return n.map(i=>i.type==="text"?bW(i,t,e):i.type==="strong"?e.tokensToText(i.tokens,{...t,"style-bold":!0},e):i.type==="em"?e.tokensToText(i.tokens,{...t,"style-italic":!0},e):i.type==="del"?e.tokensToText(i.tokens,{...t,"style-strikethrough":!0},e):i.type==="link"?xW(i,t,e):i.type==="codespan"?AW(i,t):i.type==="br"?[{insert:" ",attributes:{id:Z(),created:Date.now(),box:!0,type:"br"}}]:i.type==="escape"?_1(UE(i.text),t):i.type==="latex"?[{insert:" ",attributes:{id:Z(),created:Date.now(),box:!0,type:"math",tex:i.formula}}]:(vW.warn(`unknown token in text: ${JSON.stringify(i)}`),[])).flat()}function BW(n,t){const e=OE(n.tokens,{},t);return[{id:Z(),type:"text",text:e,heading:n.depth}]}function TW(n,t){const{text:e,children:r}=t.tokensToTextWithChildren(n.tokens,t),i=[];return e.length>0&&i.push({id:Z(),type:"text",text:e}),i.push(...r),i}function yW(n,t){const{text:e,children:r}=t.tokensToTextWithChildren([n],t),i=[];return e.length>0&&i.push({id:Z(),type:"text",text:e}),i.push(...r),i}function kW(n,t){const e=typeof n.start=="number"?n.start:1,r=n.ordered,i=Z(),o=[];return n.items.forEach((l,c)=>{const d={...t,listLevel:t.listLevel+1},{text:h,children:C}=t.tokensToTextWithChildren(l.tokens,d);let E;typeof l.checked=="boolean"&&(E=l.checked?"checked":"unchecked");const A={id:Z(),type:"list",groupId:i,ordered:r,checkbox:E,start:e+c,text:h,level:t.listLevel};o.push(A),o.push(...C)}),o}function RW(n,t){const e=t.tokensToBlocks(n.tokens,t);return e.forEach(r=>{r.quoted=!0}),e}const lw=100,wW=20,SW=600;function LW(n,t){const e=t.text;if(e){const r=fe(e);return Math.min(Pd(r,n)+wW,SW)}return lw}function aw(n,t){let e=lw;return t.forEach(r=>{e=Math.max(e,LW(n,r))}),e}function IW(n,t){var l,c;const e=n.header.length,r=n.rows.length+1,i=[],o=Array(e).fill(100);for(let d=0;d<r;d++){let h;d===0?h=n.header:h=n.rows[d-1];for(let C=0;C<e;C++){const E=h[C],A=(l=E==null?void 0:E.tokens)!=null?l:[],v=Z();i.push(v);let R;if(A.length===0)R=[dh()];else if(ac(A[0]))R=t.tokensToBlocks(E.tokens,t),R.length===0&&R.push(dh());else{const{text:L,children:M}=t.tokensToTextWithChildren(E.tokens,t);R=[{id:Z(),type:"text",text:L},...M]}t.doc.blocks[v]=R,o[C]=Math.max(o[C],aw((c=t.font)!=null?c:"",R))}}return[{id:Z(),type:"table",cols:e,rows:r,colsWidth:o,children:i}]}function DW(n){return[{id:Z(),type:"embed",embedType:"hr",embedData:{}}]}function _W(n,t){var c;const e=n.text;if(!e)return[];try{const d=n.text,h=Zc(d),C=JSON.parse(h);if(C){const{root:E,...A}=C.blocks;return t.doc.blocks={...t.doc.blocks,...A},E}}catch{}const r=(c=n.lang)!=null?c:"Plain Text";if(r==="mermaid")return[{id:Z(),type:"embed",embedType:"mermaid",embedData:{mermaidText:e}}];if(r==="plantuml")return[{id:Z(),type:"embed",embedType:"plantuml",embedData:{plantumlText:e}}];if(r==="flow"||r==="flowchart")return[{id:Z(),type:"embed",embedType:"flowchart",embedData:{flowchartText:e}}];const o=e.split(`
|
|
669
669
|
`).map(d=>({id:Z(),type:"text",text:Zs(d)})),s=t.doc,l=Z();return s.blocks[l]=o,[{id:Z(),type:"code",language:r,children:[l]}]}function MW(n){return[{id:Z(),type:"embed",embedType:"image",embedData:{src:n.href,title:n.title}}]}function UW(n,t){const{text:e,children:r}=t.tokensToTextWithChildren(n.tokens,t),i=[];return e.length>0&&i.push({id:Z(),type:"text",text:e}),i.push(...r),i}function OW(n){const t=n.formula;return t?[{id:Z(),type:"embed",embedType:"math",embedData:{mathjaxText:t}}]:[]}const cw=I("markdown-to-doc");function NW(n,t){var e;if(n.type==="heading")return BW(n,t);if(n.type==="paragraph")return TW(n,t);if(n.type==="list")return kW(n,t);if(n.type==="blockquote")return RW(n,t);if(n.type==="table")return IW(n,t);if(n.type==="hr")return DW();if(n.type==="code")return _W(n,t);if(n.type==="image")return MW(n);if(n.type==="link")return UW(n,t);if(n.type==="latex-block")return OW(n);if(n.type==="text")return yW(n,t);if(n.type==="space"){const r=n.raw.replaceAll(" ",""),i=Math.floor(r.split(`
|
|
@@ -721,7 +721,7 @@ ${s}
|
|
|
721
721
|
`}})}class XW{constructor(t){m(this,"_grid",[]);m(this,"_needFixSpanData",!1);Array.from(t.rows).forEach((e,r)=>{Array.from(e.cells).forEach(i=>{this._addCell(r,i)})})}_addCell(t,e){const r=this._getNextColIndex(t),i=e.colSpan,o=e.rowSpan;for(let s=0;s<o;s++)for(let l=0;l<i;l++){const c=t+s,d=r+l;if(this._getCell({row:c,col:d})){this._needFixSpanData=!0,console.warn(`invalid table data, cell data already exists, ${c}, ${d}`);continue}this._setCell({row:c,col:d},{cell:e,virtual:!(l===0&&s===0)})}}_getNextColIndex(t){const e=this._grid[t];if(!e)return 0;let r=0;for(let i=0;i<e.length;i++)if(e[i])r+=1;else return r;return r}_setCell(t,e){if(!(e.cell.colSpan===0||e.cell.rowSpan===0)){for(;this._grid.length<=t.row;)this._grid.push([]);for(let r=0;r<this._grid.length;r++){const i=this._grid[r];for(;i.length<=t.col;)i.push(null)}this._grid[t.row][t.col]=e}}_getCell(t){var r;const e=this._grid[t.row];return e&&(r=e[t.col])!=null?r:null}get rowCount(){return this._grid.length}get colCount(){return this._grid[0].length}getCellData(t){const e=this._getCell(t);return e||null}getCellSpan(t){const e=this._getCell(t);if(!e)return{colSpan:1,rowSpan:1};if(e.virtual)return{colSpan:1,rowSpan:1};const r=()=>{let l=t.col+1;for(;;){const c=this._getCell({row:t.row,col:l});if(!c||c.cell!==e.cell)return l-t.col;l+=1}},i=()=>{let l=t.row+1;for(;;){const c=this._getCell({row:l,col:t.col});if(!c||c.cell!==e.cell)return l-t.row;l+=1}},o=r(),s=i();return o!==e.cell.colSpan&&console.warn(`invalid colSpan: ${o} -> ${e.cell.colSpan}`),s!==e.cell.rowSpan&&console.warn(`invalid rowSpan: ${s} -> ${e.cell.rowSpan}`),{colSpan:o,rowSpan:s}}getColumnWidth(t){const i=Array(this.rowCount).fill(0).map((s,l)=>{const c=this.getCellData({row:l,col:t});if(c&&!c.virtual){const d=c.cell.getAttribute("width")||c.cell.style.width;if(d){if(d.endsWith("%")){const C=d.substr(0,d.length-1),E=Number.parseInt(C,10);if(E>0&&E<=100)return Math.floor(720*E/100)}const h=Number.parseInt(d,10);if(h)return h}return c.cell.getBoundingClientRect().width}return 1e9}),o=Math.min(...i);return o===1e9||Number.isNaN(o)||o<30?0:o}}function QW(n){return new XW(n)}function dw(n,t){var c;const e=QW(n),r=[],i={},o=e.rowCount,s=e.colCount,l=Array(s).fill(100);for(let d=0;d<o;d++)for(let h=0;h<s;h++){let C;const E=e.getCellData({row:d,col:h});if(E&&E.virtual)continue;E&&!E.virtual&&(C=t.htmlToBlocks(E.cell.innerHTML.trim(),t)),(!C||C.length===0)&&(C=[{id:Z(),type:"text",text:[]}]);const A=Z();r.push(A);const{colSpan:v,rowSpan:R}=e.getCellSpan({row:d,col:h});R>1&&(i[`${A}_rowSpan`]=R),v>1&&(i[`${A}_colSpan`]=v),t.doc.blocks[A]=C,E&&!E.virtual&&(l[h]=Math.max(l[h],aw((c=t.font)!=null?c:"",C)))}for(let d=0;d<e.colCount;d++)l[d]=e.getColumnWidth(d)||l[d];return r.length===0?[]:[{cols:e.colCount,rows:e.rowCount,id:Z(),type:"table",children:r,...i,colsWidth:l}]}function hw(n,t){var e;if(n.tagName==="TABLE"){const r={blocks:{root:[]},meta:{},comments:{}},i=dw(n,{doc:r,...t});if(i.length===0||((e=i[0].children)==null?void 0:e.length)===0)return;r.blocks.root=i;const o=JSON.stringify(r),s=ci(o),l=document.createElement("div");l.classList.add("highlight-text-wizdoc");const c=document.createElement("pre");l.appendChild(c),c.innerText=s,n.insertAdjacentElement("beforebegin",l),n.remove();return}Array.from(n.children).forEach(r=>hw(r,t))}function mw(n){if(n instanceof HTMLStyleElement){n.remove();return}Array.from(n.children).forEach(mw)}function gw(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(gw)}function YW(n,t){const e=Nd(n);return e.querySelectorAll("td.js-line-number").forEach(i=>i.remove()),e.querySelectorAll("div.copy-button").forEach(i=>i.remove()),e.querySelectorAll("div.code-copy-button").forEach(i=>i.remove()),e.querySelectorAll("noscript").forEach(i=>i.remove()),Array.from(e.children).forEach(gw),Array.from(e.children).forEach(i=>hw(i,t)),Array.from(e.children).forEach(mw),fw(e),nv(e)}const ki=new e9.default;ki.use(VW),ki.use($W),ki.use(HW),ki.use(jW),ki.use(zW),ki.use(GW),ki.use(WW),ki.use(qW),ki.use(H6.gfm);function JW(n,t){const e=pw(n,t);if(!e)return[];const{root:r,...i}=e.blocks;return t.doc.blocks={...t.doc.blocks,...i},r}function pw(n,t){let e=n;const r=new DOMParser().parseFromString(n,"text/html").querySelectorAll("meta");if(r.length&&Array.from(r).some(o=>o.getAttribute("content")==="PowerPoint.Slide")){const o=n.indexOf("<!--StartFragment-->"),s=n.indexOf("<!--EndFragment-->");o!==-1&&s!==-1&&(e=n.substring(o+20,s))}const i=ki.turndown(e);return uw(i,{htmlToDoc:o=>Cw(o,t)})}function Cw(n,t){const e=YW(n,{font:t==null?void 0:t.font,htmlToBlocks:JW});return pw(e)}function Ew(n){return n.indexOf('xmlns:o="urn:schemas-microsoft-com:office:office"')!==-1}function PE(n){return["A","B","DEL","I","U","S","SPAN","SUB","SUP","FONT","BR"].indexOf(n.tagName)!==-1}function ZW(n){return["P","H1","H2","H3","H4","H5","H6","H7","H8","LI"].indexOf(n.tagName)!==-1}function xw(n){return n.replace(/\r\n\s*/g,"").replace(/\n\s*/g,"").replace(/\r\s*/g,"")}function tq(n){if(!n.tagName)return!1;if(n.tagName.toLocaleLowerCase()==="img")return!0;const t=n.querySelectorAll("img");for(let e=0;e<t.length;e+=1){const r=t[e];if(!r.src||r.getAttribute("width")==="0"||r.getAttribute("height")==="0")return!1}return t.length}function eq(n){return(n.tagName.toLocaleLowerCase()==="img"?[n]:Array.from(n.querySelectorAll("img"))).map(i=>({id:Z(),type:"embed",embedType:"image",embedData:{src:i.src,width:i.width,height:i.height}}))}function Aw(n){var e;return Array.from(((e=n.getAttribute("style"))!=null?e:"").split(" ")).findIndex(r=>r.startsWith("level"))!==-1}function nq(n){var e;const t=Array.from(((e=n.getAttribute("style"))!=null?e:"").split(" "));for(let r=0;r<t.length;r++){const i=t[r];if(i.startsWith("mso-list:"))return i}return""}function bw(n){var e,r;const t=Array.from(((e=n.getAttribute("style"))!=null?e:"").split(" "));for(let i=0;i<t.length;i++){const o=t[i];if(o.startsWith("level")){const s=(r=Number.parseInt(o.substring(5),10))!=null?r:void 0;if(s)return s}}return 1}function rq(n,t){n.setAttribute("data-group-id",t)}function iq(n){const t={},e=i=>{Array.from(Object.keys(t)).forEach(o=>{Number.parseInt(o,10)>i&&delete t[o]})};let r="";Array.from(n.children).forEach(i=>{if(Aw(i)){const o=nq(i);r!==o&&(e(0),r=o);const s=bw(i);e(s);let l=t[`${s}`];l||(l=Z(),t[`${s}`]=l),rq(i,l)}})}function vw(n){const t=n.querySelector('[style="mso-list:Ignore"]');if(t){const e=t.innerText;return e&&e.trim()!=="-"}return!0}function oq(n){var r;if(!vw(n))return 1;const e=n.querySelector('[style^="mso-list:Ignore"]');if(e){const i=e.innerText;if(i)return(r=Number.parseInt(i,10))!=null?r:1}return 1}function Bw(n){if(!Aw(n))return{};const t=bw(n),e=n.getAttribute("data-group-id")||Z();return{start:oq(n),level:t,groupId:e,ordered:vw(n),type:"list"}}const sq=I("office-list");function Tw(n){return n instanceof HTMLOListElement||n instanceof HTMLUListElement}function lq(n,t){p(sq,Tw(n),"not list group element");let e=!1,r=1;const i=Z();n instanceof HTMLOListElement&&(e=!0,r=n.start);const o=n,s=[];let l;return Array.from(o.children).forEach(c=>{if(c instanceof HTMLLIElement){const h=Bw(c),C=t.textElementToBlocks(c,t);l||(l=h.level);const E=C[0];s.push({...E,type:"list",ordered:e,level:l,groupId:i,start:r}),r+=1,s.push(...C.slice(1));return}const d=t.blockElementToBlocks(c,t);s.push(...d)}),s}function yw(n,t){if(n.nodeName==="META")return[];if(n instanceof HTMLTableElement)return dw(n,t);if(Tw(n))return[...lq(n,t)];if(tq(n))return[...eq(n)];if(ZW(n))return[...t.textElementToBlocks(n,t)];if(!n.children)return[];const e=[];return Array.from(n.children).forEach(r=>{const i=yw(r,t);e.push(...i)}),e}function kw(n,t){const e=[];return n.forEach(r=>{var i;if(r instanceof Element)if(PE(r)){const o=document.createElement("p");o.appendChild(r);const s=t.blockElementToBlocks(o,t);e.push(...s)}else{const o=t.blockElementToBlocks(r,t);e.push(...o)}else if(r instanceof Text){const o=pi(xw((i=r.textContent)!=null?i:""));e.push(o)}}),e}function Rw(n){return n instanceof Element?PE(n):n.nodeType===Node.TEXT_NODE}function aq(n){var t;return n.nodeType===Node.TEXT_NODE&&((t=n.textContent)==null?void 0:t.trim())===""}function ww(n){const t=Array.from(n.childNodes);for(let e=0;e<t.length;e++){const r=t[e];if(!Rw(r))continue;let i=e+1;for(;i<t.length&&Rw(t[i]);)i+=1;if(aq(r)&&i===e+1)continue;const o=document.createElement("p");r instanceof Element?r.insertAdjacentElement("beforebegin",o):n.insertBefore(o,r);for(let s=e;s<i;s++)o.appendChild(t[s]);e=i-1}}function cq(n,t){const e=Nd(n);return ww(e),kw(Array.from(e.childNodes),t)}function uq(n){if(!(n instanceof HTMLElement))return{};const t={};if(n.style.textAlign==="right"?t.align="right":n.style.textAlign==="center"&&(t.align="center"),n.style.marginLeft){const e=Math.ceil(Number.parseInt(n.style.marginLeft,10)/20);e>=1&&e<=12&&(t.padding=e)}return t}function fq(n,t){return t&&Object.keys(t).length>0?{insert:n,attributes:t}:{insert:n}}function dq(n,t){if(n.nodeName==="B")return{...t,"style-bold":!0};if(n.nodeName==="I")return{...t,"style-italic":!0};if(n.nodeName==="U")return{...t,"style-underline":!0};if(n.nodeName==="S"||n.nodeName==="DEL")return{...t,"style-strikethrough":!0};if(n.nodeName==="SUB")return{...t,"style-sub":!0};if(n.nodeName==="SUP")return{...t,"style-super":!0};if(n.nodeName==="BR")return{...t,created:Date.now(),id:Z(),box:!0,type:"br"};if(n.nodeName==="A"&&n.href){const r=n.href;if(r.startsWith("http:")||r.startsWith("https:"))return{...t,link:n.href}}const e={...t};return n instanceof HTMLSpanElement?(n.style.backgroundColor&&(e["inline-style-background-color"]=n.style.backgroundColor),n.style.color&&(e["inline-style-color"]=n.style.color),n.style.fontSize&&(e["inline-style-font-size"]=n.style.fontSize),n.style.fontFamily&&(e["inline-style-font-family"]=n.style.fontFamily),e):t}function Sw(n,t,e){var i;if(n instanceof HTMLSpanElement&&n.getAttribute("style")==="mso-list:Ignore")return;const r=dq(n,t);if(n instanceof Text&&n.nodeValue||n.nodeName==="BR"){const o=xw((i=n.nodeValue)!=null?i:" ");o&&e.push(fq(o,r));return}n.childNodes.length>0&&Array.from(n.childNodes).forEach(o=>{Sw(o,r,e)})}function Lw(n){return n instanceof Element?PE(n):!0}function FE(n){return!Lw(n)}function hq(n){if(n.length===0)return[];if(n.length===1)return[n];const t=[];let e=[n[0]],r=FE(n[0]);for(let i=1;i<n.length;i++){const o=n[i];r===FE(o)?e.push(o):(t.push(e),e=[o],r=FE(o))}return t.push(e),t}function mq(n,t){const e={};if(n.tagName.startsWith("H")){const o=Number.parseInt(n.tagName.substr(1),10);o>=1&&o<=8&&(e.heading=o)}const r=hq(Array.from(n.childNodes)),i=[];return r.forEach((o,s)=>{if(Lw(o[0])){const l=[],c={};Array.from(n.childNodes).forEach(h=>{Sw(h,c,l)});let d={};s===0&&(d=Bw(n)),i.push({id:Z(),type:"text",text:l,...d,...e,...uq(n)})}o.forEach(l=>{const c=t.blockElementToBlocks(l,t);i.push(...c)})}),i}function gq(n,t){const e=Nd(n);iq(e),ww(e);const r={blocks:{root:[]},meta:{},comments:{}},i={font:t==null?void 0:t.font,doc:r,blockElementToBlocks:yw,textElementToBlocks:mq,htmlToBlocks:cq},o=kw(Array.from(e.children),i);if(o.length!==0)return r.blocks.root=o,r}const pq=I("html-to-doc");function Iw(n,t){if(!n)return null;const e=hW(n);if(e)return e;if(Ew(n)){const r=gq(n,t);if(r)return r}try{return Cw(n,t)}catch(r){pq.error(r)}return null}class Cq{async fromData(t,e){const r={},i=e.getData("text/html");if(i){const o=Iw(i,{font:t.rootContainer});o&&(Ew(i)?r["text/office-html"]=o:r["text/html"]=o)}return r}}class Eq{async fromData(t,e){const r=e.getData("text/plain");if(!r)return;const i=uw(r,{font:t.rootContainer,htmlToDoc:Iw});if(!!i)return{"text/markdown":i}}}function xq(n){return/^([\d\w\u4e00-\u9fa5\s]*[\u4e00-\u9fa5\s]{1}|)((https|http|ftp)?:\/\/)[^\s]+/.test(n)}function Aq(n){const t=[],e=n.split(/https|http|ftp/)[0],r=n.substring(e.length).trim();if(e&&e.length){const o=gr(e,null);t.push(o,gr(" ",null))}const i=gr(r,{link:r});return t.push(i,gr(" ",null)),t}class bq{async fromData(t,e,r){const{toPlainText:i=!1}=r||{},o={},s=e.getData("text/plain");if(s){const d={blocks:{root:s.replace(/\r\n/g,`
|
|
722
722
|
`).replace(/\r/g,`
|
|
723
723
|
`).split(`
|
|
724
|
-
`).map(h=>{const C={id:Z(),type:"text"};if(xq(h)&&!i)return C.text=Aq(h),C;const E=h?[gr(h,null)]:[];return C.text=E,C})},meta:{},comments:{}};o["text/plain"]=d}return o}}function vq(n){const t=[];for(let e=0;e<n.length;e++){const r=n[e];r.type.toLocaleLowerCase().startsWith("image/")&&t.push(r)}return t}class KE{constructor(t){t.dataConverter.addConverter(new Cq),t.dataConverter.addConverter(new bq),t.dataConverter.addConverter(new Eq)}async handleBeforePaste(t,e,r,i){if(!e)return!1;const o=e.clipboardData;if(o){if(o.getData("text/html").indexOf("<ones-editor-doc")>0)return!1;const l=o.getData("text/plain"),c=vq(i);if(c.length>0&&!l&&!r["text/office-html"])return await this.handleInsertImages(t,c),!0}return!1}async handleInsertImages(t,e){const{start:r,end:i}=t.selection.range,o=t.selection.focusedBlock;let s=rt(o),c=bt(o);const d=et(s);if(d&&St(d)==="code")return;if(r.blockId===i.blockId&&pe(o))c+=1;else{t.clearSelectedContents();const{blockId:C}=t.selection.range.start,E=t.getBlockById(C);c=bt(E),s=rt(E),ie(t,E)||(c+=1),Xt(s)&&c===0&&(c+=1)}const h=ft(s);for(let C=0;C<e.length;C++){const E=e[C],A=await t1(t,"image",h,c+C,{file:E});A&&jv(t,A,"image",{id:"replace-image",name:"Replace image",data:{block:A,image:E}})}}}class Bq extends Re.TypedEmitter{constructor(t){super(),this.editor=t}onUpdateBlockText(t,e,r){const i=this.editor.getCustom("find-dialog");if(!i||!i.isVisible())return;const o=zi(ui(this.editor,t),e);!nt(this.editor,o)||!r.some(l=>l.insert||l.delete)||this.emit("onDocChanged",o)}onInsertBlock(t,e,r,i){zi(ui(this.editor,t),e),this.emit("onDocInserted")}onDeleteBlock(t,e,r){const i=zi(ui(this.editor,t),e);this.emit("onDocDeleted",i)}}function Dw(n){return me.isSafari&&!!n&&Date.now()-n<100}const _w=I("highlight-data");class J0{constructor(t){m(this,"data",new Map);this.editor=t}add(t,e,r){const i={id:Z(),blockId:st(t),oldText:this.editor.getBlockText(t),start:e,end:r};return this.data.set(i.id,i),i}get(t){const e=this.data.get(t);return p(_w,e,`no highligh data: ${t}`),e}remove(t){this.data.delete(t)}clearBlockData(t){Array.from(this.data.values()).forEach(e=>{e.blockId===t&&this.data.delete(e.id)})}destroy(){}static getData(t){return t.addCustom("highligh-data",()=>new J0(t))}}function Tq(n,t,e,r,i){const s=J0.getData(n).add(t,e,r);return i.setAttribute("data-highlight-id",s.id),s}function Z0(n,t){const e=t.getAttribute("data-highlight-id");return p(_w,e,"invalid highlight elem, no id"),J0.getData(n).get(e)}const cc=I("highligh-dom");function yq(n){return Rt(n,"editor-highlight")}function Ri(n){const t=n.rootContainer.querySelectorAll(".editor-highlight");return Array.from(t)}function kq(n,t){p(cc,t,"invalid block");const e=t.querySelectorAll(".editor-highlight");return Array.from(e)}function Rq(n){const t=n.rootContainer.querySelectorAll(".editor-replace-result-highlight");return Array.from(t)}function tm(n){const t=n.querySelectorAll(".editor-highlight");return Array.from(t)}function wq(n){tm(n).forEach(t=>{t.remove()})}function ho(n){return Ri(n).length}function Sq(n,t){p(cc,t>=0,`invalid highlight index: ${t}`);const e=Ri(n);return e.length===0?null:(p(cc,t<e.length,`invalid highlight index: ${t}/${e.length}`),e[t])}function Lq(n,t,{left:e,top:r,width:i,height:o},s){const l=["editor-highlight-child"];s&&l.push("editor-highlight-readonly");const c=B("div",l,n);c.style.top=`${r}px`,c.style.left=`${e}px`,c.style.width=`${i}px`,c.style.height=`${o}px`}function Mw(n,t,e,r,i){p(cc,r>0,`invalid end: ${r}`);const o=re(t),s=t.getBoundingClientRect(),l=qi(n,t,Te(n,t,e,r)),d=B("div",[i==="find"?"editor-highlight":"editor-replace-result-highlight"],o);l.forEach(h=>{Lq(d,t,{left:h.left-s.left,width:h.width,top:h.top-s.top,height:h.height})}),Tq(n,t,e,r,d)}function Iq(n,t,e,r){return Mw(n,t,e,r,"find")}function Uw(n,t,e,r){return Mw(n,t,e,r,"replace")}function em(n,t){Ri(n).forEach(s=>{Rt(s,"active")&&ot(s,"active")}),z(t,"active"),p(cc,t.firstChild instanceof HTMLElement,"invalid highligh dom, invalid elem child");const r=t.firstChild;let o=r.getBoundingClientRect().y;o===0&&(o=r.getBoundingClientRect().y),ca(r,{elementToScroll:n.scrollContainer})}function Af(n){const t=n.rootContainer.querySelector(".editor-highlight.active");return t||null}function Ow(n){return p(cc,n,"no highlight elem"),Rt(n,"editor-highlight-readonly")}const uc=I("highligh-text");function Nw(n){Rq(n).forEach(e=>{e.remove()})}function nm(n,t){Ri(n).forEach(r=>{r.remove()}),t!=null&&t.keepReplaceResult||Nw(n)}function Pw(n,t,e){kq(n,t).forEach(i=>{i.remove()}),e!=null&&e.keepReplaceResult||Nw(n)}function bf(n){const t=Af(n);if(!t)return-1;const r=Ri(n).indexOf(t);return p(uc,r!==-1,`invalid highlight index: ${r}`),r}function Dq(n){const t=Ri(n);if(t.length===0)return 0;const e=Af(n);let r=e?t.indexOf(e):-1;!e||r===-1||r===t.length-1?r=0:r+=1;const i=t[r];return em(n,i),r}function _q(n){const t=Ri(n);if(t.length===0)return 0;const e=Af(n);let r=e?t.indexOf(e):-1;!e||r===-1||r===0?r=t.length-1:r-=1;const i=t[r];return em(n,i),r}function VE(n,t){const e=Ri(n);e.length>0&&t<e.length&&em(n,e[t])}function Mq(n,t,e){const r=Af(n);if(!r)return!1;const i=et(r);if(p(uc,i,"no parent block"),!n.isBlockWritable(i))return!1;const o=ho(n);let s=bf(n);if(!Ow(r)&&n.isBlockWritable(i)){const d=Z0(n,r),h=n.getBlockText(i),{start:C,end:E}=Z0(n,r),[A,v]=fn.transformOffset(d.oldText,h,[C,E]),R=W3(h,A,v-A);if(fe(R).toLowerCase()!==t.toLowerCase())return!1;const L=fh(h,A,v,e);n.setBlockText(i,L),wq(i),$E(n,i,t),e&&Uw(n,i,A,A+e.length)}const l=ho(n);s>=l?s=0:l>o&&(s+=1);const c=Sq(n,s);return c&&em(n,c),!0}function Uq(n,t,e,r){if(!nt(n,t)||!n.isBlockWritable(t))return 0;const i=n.getBlockText(t);p(uc,i,"no block text");const o={count:0},s=pB(i,e,r,o);return fe(i)===fe(s)?0:(n.setBlockText(t,s),o.count)}function Oq(n,t,e){if(p(uc,yq(t),"not a highlight elem"),Ow(t))return;p(uc,e>0,"invalid highlight length");const r=Z0(n,t),i=et(t);p(uc,i,"no parent block"),Uw(n,i,r.start,r.start+e)}function Nq(n,t){Ri(n).forEach(r=>{Oq(n,r,t)})}function Pq(n,t,e){if(n.readonly)return 0;const r=o=>{let s=0;return ue(o).forEach(c=>{_t(n,c)?An(n,c).forEach(h=>{s+=r(h)}):s+=Uq(n,c,t,e)}),s},i=r(n.rootContainer);return e.length>0&&Nq(n,e.length),i}function Fq(n){const t=n.selection.range.end,e=n.getBlockById(t.blockId),r=t.isSimple()?t.offset:1,i=tm(e);for(let l=0;l<i.length;l++){const c=i[l],{end:d}=Z0(n,c);if(d>=r)return c}const o=c1(n,{simpleBlockOnly:!0}),s=o.indexOf(e);if(s===-1)return null;for(let l=s+1;l<o.length;l++){const c=o[l],d=tm(c);if(d.length>0)return d[0]}return null}function Kq(n){const t=Ri(n),e=Fq(n);return e?t.indexOf(e):0}function $E(n,t,e){if(!!e&&nt(n,t)){const r=n.getBlockText(t),i=N1(r,e);i.length>0&&i.forEach(({start:o,end:s})=>{Iq(n,t,o,s)})}}function Fw(n,t){if(nm(n),!t)return;c1(n,{simpleBlockOnly:!0}).forEach(r=>{$E(n,r,t)})}class Vq{constructor(t){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",t=>{setTimeout(()=>{Pw(this.editor,t),$E(this.editor,t,this.components.findInput.value);const e=ho(this.editor);t.querySelectorAll(".editor-highlight").length===e&&VE(this.editor,0);const r=bf(this.editor);this.updateSearchStatus(r,e)})});m(this,"handleDocInserted",()=>{const t=setTimeout(()=>{clearTimeout(t),nm(this.editor,{keepReplaceResult:!0}),Fw(this.editor,this.components.findInput.value);const e=ho(this.editor),r=bf(this.editor);this.updateSearchStatus(r,e),VE(this.editor,r)})});m(this,"handleDocDeleted",t=>{const e=setTimeout(()=>{if(!tm(t).length){clearTimeout(e);return}Pw(this.editor,t);const i=ho(this.editor),o=bf(this.editor);this.updateSearchStatus(o,i)})});m(this,"handleInput",t=>{if(t.isComposing||Dw(this._compositionEndTime)){this.doSearch.cancel();return}this.handleFindChanged()});m(this,"handleFind",()=>{this.findNext({keepSearchResult:!1})});m(this,"handleReplace",()=>{const t=this.components.findInput.value;if(!t||!Af(this.editor))return;const r=this.components.replaceInput.value;if(t===r)return;if(Mq(this.editor,t,r)){const o=bf(this.editor),s=ho(this.editor);this.updateSearchStatus(o,s)}r.includes(t)&&this.findNext({keepSearchResult:!0})});m(this,"handleReplaceAll",()=>{const t=this.components.findInput.value;if(!t)return;const e=this.components.replaceInput.value;t!==e&&this.editor.undoManager.runInGroup(()=>{Pq(this.editor,t,e)>0&&(this.oldText="",this.doSearchNow({keepReplaceResult:!0,gotoFirstSearchResult:!0}),this.clearFind({keepReplaceResult:!0}))})});m(this,"doSearch",Me.default(this.doSearchNow,300));this.editor=t;const e=B("div",["editor-find-dialog"],null),r=B("div",["editor-find-content"],e),i=B("div",["editor-find-dialog-row"],r),o=Ms(Gh,["editor-find-dialog-button-close"],e),s=B("label",["editor-find-dialog-label"],i,D.t("find.findLabel"));s.htmlFor="";const l=B("div",["editor-find-dialog-input-container"],i),c=B("input",["editor-find-dialog-input"],l);c.type="text",c.placeholder=D.t("find.findPlaceholder");const d=B("div",["editor-find-dialog-status"],l),h=Ms(hT,["editor-find-dialog-icon-button"],d),C=B("div",["editor-find-dialog-curr"],d,"0/0"),E=Ms(mT,["editor-find-dialog-icon-button"],d);let A;D.t("find.moreButton")?A=B("button",["editor-find-dialog-button"],i,D.t("find.moreButton")):A=Ms(jp,["editor-find-dialog-icon-button-border"],i);const v=B("div",["editor-find-dialog-row"],r),R=B("label",["editor-find-dialog-label"],v,D.t("find.replaceLabel"));R.htmlFor="";const L=B("div",["editor-find-dialog-input-container"],v),M=B("input",["editor-find-dialog-input"],L);M.type="text",M.placeholder=D.t("find.replacePlaceholder");const U=B("div",["editor-find-dialog-row","editor-find-dialog-action"],r);B("div",["editor-find-dialog-space"],U);const F=B("button",["editor-find-dialog-button"],U,D.t("find.findButton")),G=B("button",["editor-find-dialog-button"],U,D.t("find.replaceButton")),W=B("button",["editor-find-dialog-button","editor-find-dialog-primary-button"],U,D.t("find.replaceAllButton"));A.onclick=()=>{this.showReplace()},o.onclick=()=>{this.hide()},c.onkeydown=at=>{if(at.isComposing||Dw(this._compositionEndTime)){this.doSearch.cancel();return}Qb(at)?(this.doSearch.cancel(),this.doSearchNow({keepReplaceResult:!1,gotoFirstSearchResult:!0})):Og(at)&&this.hide()},c.oninput=this.handleInput,c.onpaste=this.handleFindChanged,c.oncut=this.handleFindChanged,c.addEventListener("compositionend",this.handleCompositionEnd),c.maxLength=50,F.onclick=this.handleFind,G.onclick=this.handleReplace,W.onclick=this.handleReplaceAll,M.maxLength=50,E.onclick=()=>{this.gotoNext()},h.onclick=()=>{this.gotoPrev()},this.components={findInput:c,findPrev:h,findCurrent:C,findNext:E,replaceInput:M,findButton:F,replaceButton:G,replaceAllButton:W,closeButton:o,showReplaceButton:A,rowReplace:v,rowActions:U,statusContainer:d},this.root=e;const it=new Bq(t);t.doc.registerCallback(it),it.addListener("onDocChanged",this.handleDocChanged),it.addListener("onDocInserted",this.handleDocInserted),it.addListener("onDocDeleted",this.handleDocDeleted)}findNext(t){this.doSearch.cancel(),this.doSearchNow({keepReplaceResult:t.keepSearchResult,gotoFirstSearchResult:!0})}doSearchNow(t){const e=this.components.findInput.value;if(e||this.clearFind(t),this.oldText===e){this.gotoNext();return}this.oldText=e,Fw(this.editor,e);const r=ho(this.editor),i=Kq(this.editor);t.gotoFirstSearchResult&&VE(this.editor,i),this.updateSearchStatus(i,r)}gotoNext(){const t=ho(this.editor),e=Dq(this.editor);this.updateSearchStatus(e,t)}gotoPrev(){const t=ho(this.editor),e=_q(this.editor);this.updateSearchStatus(e,t)}updateSearchStatus(t,e){if(this.oldText?this.components.statusContainer.style.display="flex":this.components.statusContainer.style.display="none",e===0)this.components.findCurrent.innerText="0 / 0",this.components.replaceAllButton.disabled=!0,this.components.replaceButton.disabled=!0,this.components.findButton.disabled=!0;else{this.components.findCurrent.innerText=`${t+1} / ${e}`;const r=this.editor.readonly;this.components.replaceAllButton.disabled=r,this.components.replaceButton.disabled=r,this.components.findButton.disabled=!1}}clearFind(t){nm(this.editor),this.updateSearchStatus(0,0)}showFindOnly(){this.components.rowReplace.style.display="none",this.components.rowActions.style.display="none",this.components.showReplaceButton.style.display="flex"}showReplace(){this.components.rowReplace.style.display="flex",this.components.rowActions.style.display="flex",this.components.showReplaceButton.style.display="none",this.components.replaceInput.focus(),this.components.replaceInput.select()}hideSearchResult(){this.components.statusContainer.style.display="none"}showSearchResult(){this.components.statusContainer.style.display="flex"}show(t){const e=this.editor.getSelectedText();e.length>0&&e.length<50&&(this.components.findInput.value=e),this.root.style.display="flex",t!=null&&t.showFindAndReplace?(this.showReplace(),this.components.findInput.value&&setTimeout(()=>{this.components.replaceInput.focus()})):this.showFindOnly(),this.hideSearchResult(),this.oldText="",this.doSearchNow({keepReplaceResult:!1,gotoFirstSearchResult:!0});const r=this.editor.readonly,i=this.components.findInput.value;this.components.replaceButton.disabled=r||!i,this.components.replaceAllButton.disabled=r||!i,this.components.replaceInput.disabled=r,this.dialog||(this.dialog=new Fu(this.root,{disablePageScroll:!1}));const o=this.editor.options.componentsOptions.findDialog,s=(o==null?void 0:o.popoverTarget)||this.editor.rootContainer,l=()=>{var E,A,v,R;const c=o==null?void 0:o.getReferenceClientRect;if(c&&((A=(E=this.dialog)==null?void 0:E.tippyInstance)==null?void 0:A.popper))return c(s,(R=(v=this.dialog)==null?void 0:v.tippyInstance)==null?void 0:R.popper);const d=s.getBoundingClientRect(),h=d.top<0?12:d.top+12,C=d.right-this.root.clientWidth-12;return new DOMRect(C,h,0,0)};this.dialog.show(s,{getReferenceClientRect:l}),setTimeout(()=>{this.components.findInput.focus(),this.components.findInput.select()},300)}hide(){var t;(t=this.dialog)==null||t.close("cancelBar"),nm(this.editor)}isVisible(){return this.dialog&&this.dialog.isVisible}research(){this.oldText="",this.doSearch({keepReplaceResult:!0,gotoFirstSearchResult:!1})}destroy(){var t;(t=this.dialog)==null||t.destroy()}}const $q={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"}},Hq={find:{findLabel:"Search:",replaceLabel:"Replace:",findButton:"Search",replaceButton:"Replace",replaceAllButton:"Replace all",moreButton:"",findPlaceholder:"Search text in document",replacePlaceholder:"Replace with"}},jq={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"}};D.mergeLang({"zh-CN":$q,"en-US":Hq,"ja-JP":jq});function Kw(n){return n.addCustom("find-dialog",()=>new Vq(n)).show(),!0}const Vw={"CtrlOrCmd+F":Kw},Gct="";function zq(n){Kw(n)}const Gq=I("context-menu-utils");async function Wq(){try{const n=await navigator.clipboard.readText(),e=(await navigator.clipboard.read())[0].types;return!n.trim()&&e.length===1&&e.includes("text/plain")}catch(n){return Gq.warn(`Failed to read clipboard data: ${n}`),!0}}function $w(n,t){const e=document.createElement("a");e.href=n,e.download=t,e.click()}function qq(n){return new Promise((t,e)=>{const r=new FileReader;r.onload=()=>{const i=r.result;t(i)},r.onerror=()=>{e(new Error("Failed to read Blob as string."))},r.readAsText(n)})}async function Xq(){const t=(await navigator.clipboard.read())[0],e=t.types,r=new DataTransfer;for(let i=0;i<e.length;i++){const o=e[i],s=await t.getType(o),l=await qq(s);r.setData(o,l)}return r}const Hw=I("context-menu-actions");async function jw(n){n.inputHandlers.onCopyWithoutEvent()}async function Qq(n){n.selection.range.isCollapsed()||xp(n)}async function Yq(n){jw(n),yh(n)}function Jq(n,t){p(Hw,t,"block can not be null"),p(Hw,pe(t),"block should be embed type");const e=[],r=n.getBlockData(t),i=r.embedType,o=n.editorEmbeds.getEmbedClass(i);if(o.getResources)o.getResources(n,r).forEach(s=>{e.push(s)});else{const l=r.embedData.src;l&&typeof l=="string"&&e.push(l)}return e}async function Zq(n,t){const e=Jq(n,t);if(e&&e.length){const r=e[0],i=n.doc.buildResourceUrl(r);$w(i,r)}}function tX(n){Xq().then(t=>{const e=new ClipboardEvent("paste",{clipboardData:t});document.dispatchEvent(e)})}const eX=I("context-menu");class nX{constructor(t){m(this,"t",D.t);m(this,"clipboardPermission",{read:"prompt",write:"granted"});m(this,"isSecureContext",window.isSecureContext);m(this,"externalActionHandleMap",new Map);m(this,"handleActionByExternal",t=>{const{data:e}=t;if(e&&e.externalType){const r=e.externalType,i=this.externalActionHandleMap.get(r);if(i)return i(this.editor,this.editor.selection.focusedBlock,t)}return!1});m(this,"getPasteCommandItem",async()=>{const t=this.hasClipboardReadPermission;let e;Jc()||ua()?e=!0:e=t?await Wq():!1;const r=this.isSecureContext&&this.clipboardPermission.read!=="denied"&&!e,i=this.t("contextMenu.paste"),o=ze("CtrlOrCmd+V");return{id:"paste",name:i,subText:o,states:r?[]:["disabled"],disableReason:this.isSecureContext&&t?"":this.secureEnvTips(o,i)}});m(this,"getCommandItems",async()=>{const t=await this.getPasteCommandItem(),e=this.editor.readonly?[]:[this.cutCommandItem,t],r=[...this.copyTypeCommandItems,...e];return this.getExternalContextMenuOptions(r),r.push(this.stepItem,...this.selectionCommandItems),r});m(this,"getExternalContextMenuOptions",t=>{const e=this.editor.selection.focusedBlock,r=Yt(this.editor,e);if(r&&r.getBlockProperties){const i=r.getBlockProperties(this.editor,e);if(i){const{blockCommands:o}=i;if(o&&o["context-menu"]){const{commands:s,executeCommand:l,group:c}=o["context-menu"];if(s.length){const d=s.map(h=>({...h,data:{...h.data||{},externalType:c}}));t.push(this.stepItem,...d)}this.externalActionHandleMap.set(c,l)}}}});m(this,"isFocusImageBlock",()=>{const t=this.editor.selection,e=t.focusedBlock;return pe(e)&&Ge(e)==="image"&&t.range.getSelectedBlocks().length===1});m(this,"isFocusImageTypeEmbed",()=>{const e=this.editor.selection.focusedBlock,r=["mermaid","flowchart","drawio"];return pe(e)&&r.includes(Ge(e))});this.editor=t,this.clipboardSupport()}get hasClipboardReadPermission(){return this.clipboardPermission.read==="granted"}get hasClipboardWritePermission(){return this.clipboardPermission.write==="granted"}clipboardSupport(){if(!navigator.clipboard){this.clipboardPermission={write:"denied",read:"denied"};return}if(!navigator.permissions){this.clipboardPermission={write:"granted",read:"denied"};return}try{const t=navigator.permissions.query({name:"clipboard-read"}),e=navigator.permissions.query({name:"clipboard-write"});Promise.all([t,e]).then(r=>{const i=r[0],o=r[1];this.clipboardPermission={read:i.state,write:o.state},i.state!=="granted"&&(i.onchange=s=>{this.clipboardPermission.read=s.target.state}),o.state!=="granted"&&(i.onchange=s=>{this.clipboardPermission.write=s.target.state})}).catch(r=>{this.clipboardPermission.read="denied",eX.log(r)})}catch{this.clipboardPermission={write:"granted",read:"denied"}}}get isRangeCollapsed(){return this.editor.selection.range.isCollapsed()}get imageTypeCommandItems(){const t=this.isSecureContext&&this.hasClipboardWritePermission;return[{id:"copy-image",name:this.t("contextMenu.copyImage"),subText:ze("CtrlOrCmd+C"),states:t?[]:["disabled"],disableReason:this.isSecureContext&&this.hasClipboardWritePermission?"":this.secureEnvTips(this.t("contextMenu.copyImage"),ze("CtrlOrCmd+C"))},{id:"copy-image-url",name:this.t("contextMenu.copyImageUrl"),states:t?[]:["disabled"]},{id:"image-save-as",name:this.t("contextMenu.imageSaveAs")},{id:"new-tab-open-image",name:this.t("contextMenu.newTabOpenImage")}]}get copyTypeCommandItems(){const t=this.isSecureContext&&!this.isRangeCollapsed;if(this.isFocusImageBlock())return this.imageTypeCommandItems;const e=this.t("copyCutProperty.copy"),r=ze("CtrlOrCmd+C"),i=[{id:"copy",name:e,subText:r,states:t?[]:["disabled"],disableReason:this.isSecureContext&&this.hasClipboardWritePermission?"":this.secureEnvTips(r,e)}];this.isFocusImageTypeEmbed()&&i.push({id:"image-save-as",name:this.t("contextMenu.imageSaveAs")});const s=this.t("contextMenu.copyMarkdown"),l=ze("CtrlOrCmd+Shift+C");return i.push({id:"copy-markdown",name:s,subText:l,states:t?[]:["disabled"],disableReason:this.isSecureContext&&this.hasClipboardWritePermission?"":this.secureEnvTips(l,s)}),i}get cutCommandItem(){let t=this.isSecureContext&&!this.isRangeCollapsed;const r=this.editor.selection.range.getSelectedBlocks().some(l=>!this.editor.isBlockWritable(l.block));r&&(t=!1);const i=this.t("copyCutProperty.cut"),o=ze("CtrlOrCmd+X");let s="";return t||(!this.isSecureContext||!this.hasClipboardWritePermission?s=this.secureEnvTips(o,i):r&&(s=this.t("contextMenu.uneditableBlockSelected"))),{id:"cut",name:this.t("copyCutProperty.cut"),subText:ze("CtrlOrCmd+X"),states:t?[]:["disabled"],disableReason:s}}get stepItem(){return{id:"step",name:"",type:"separator"}}get selectionCommandItems(){let t=!1;const e=this.editor.selection;e.range.isCollapsed()&&(t=!0),e.range.start.isSimple()&&e.range.end.isSimple()&&(t=e.range.start.offset>0&&e.range.getSelectedBlocks().length===1);const r=[{id:"select-block",name:this.t("contextMenu.selectBlock"),states:t?[]:["disabled"]}];return r.push({id:"select-all",name:this.t("contextMenu.selectAll")}),r}destroy(){this.externalActionHandleMap.clear()}secureEnvTips(t,e){return this.t("copyCutProperty.unsafeEnvTips",{shortCut:t,operation:e})}}const Wct="";class zw{constructor(t){m(this,"contextMenu");m(this,"contextMenuCommandItems");m(this,"destroy",()=>{this.contextMenuCommandItems.destroy(),this.contextMenu.off("show",this.handleContextMenuShown),this.contextMenu.off("click",this.handleContextMenuClick),document.removeEventListener("contextmenu",this.handleContextMenu)});m(this,"updateEditorCaret",t=>{const{x:e,y:r}=t,i=l1(this.editor,e,r),o=this.editor.selection.range,s=o.getSelectedBlocks().some(l=>l.block.id===(i==null?void 0:i.focus.blockId));o.focus.blockId!==(i==null?void 0:i.focus.blockId)&&o.focus.isSimple()&&!s&&this.editor.selectionHandler.handleMouseDown(t,{autoScroll:!1})});m(this,"handleContextMenu",t=>{if(!this.editor.findCustom("editor-context-menu"))return;const r=t.target;if(this.editor.findCustom("toolbar-handler")&&this.editor.getCustom("toolbar-handler").isInToolbar(t)){t.preventDefault();return}if(this.editor.findCustom("block-menu")){const o=this.editor.getCustom("block-menu");if(o.blockMenu.isInMenu(r)||o.emptyBlockMenu.isInMenu(r)){t.preventDefault();return}}const i=!!r.closest("button.block-button");(this.isInEditor(t)||r.classList.contains("editor-disable-scroll")||i)&&(t.preventDefault(),this.updateEditorCaret(t),this.contextMenu.manualShow(document.body,{theme:"light",point:{x:t.clientX,y:t.clientY}}))});m(this,"isInMenu",t=>this.contextMenu.isInCommandBar(t.target));m(this,"isInEditor",t=>{const{clientX:e,clientY:r}=t,i=this.editor.rootElement,o=i.getBoundingClientRect(),{top:s,left:l,right:c,bottom:d}=o,h=e>=l&&e<=c&&r>=s&&r<=d,C=t.target instanceof HTMLElement&&!(t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement)&&i.contains(t.target);return h&&(this.isInMenu(t)||C)});m(this,"handleContextMenuShown",async()=>{this.editor.findCustom("toolbar-handler")&&this.editor.getCustom("toolbar-handler").hide();const t=await this.contextMenuCommandItems.getCommandItems();this.contextMenu.updateItems(t)});m(this,"handleContextMenuClick",(t,e)=>{if(this.contextMenuCommandItems.handleActionByExternal(e))return;const{id:r}=e;switch(r){case"copy":jw(this.editor);break;case"copy-markdown":Qq(this.editor);break;case"cut":if(this.handleImageEmbedAction(r))break;Yq(this.editor);break;case"paste":tX(this.editor);break;case"copy-image":case"copy-image-url":case"image-save-as":case"new-tab-open-image":this.handleImageEmbedAction(r);break;case"select-all":Sh(this.editor,this.editor.rootContainer);break;case"select-block":mp(this.editor);break}});this.editor=t,this.contextMenu=new Zo([],void 0,{id:"right-context-menu",classes:[D.getCurrentLang()]}),this.contextMenu.on("show",this.handleContextMenuShown),this.contextMenu.on("click",this.handleContextMenuClick),document.addEventListener("contextmenu",this.handleContextMenu),this.contextMenuCommandItems=new nX(t)}handleImageEmbedAction(t){const e=this.editor.selection.focusedBlock;if(pe(e)&&Ge(e)==="image"){const r=e,i=Le.getImageObject(this.editor,r),o=i.getSelectedIndex(),s=i.getImages();if(o!==-1){let l=r.querySelectorAll("img")[o].src;if(l){switch(l=this.editor.doc.buildResourceUrl(l),t){case"cut":Q0(this.editor,null),Y0(this.editor);break;case"copy-image":Q0(this.editor,null);break;case"copy-image-url":da([{type:"text/plain",data:new Blob([l],{type:"text/plain"})}]);break;case"image-save-as":$w(l,s[o].src);break;case"new-tab-open-image":window.open(l);break}return!0}}}else switch(t){case"image-save-as":Zq(this.editor,e);break}return!1}}const rX={contextMenu:{copyMarkdown:"\u590D\u5236\u4E3A Markdown",paste:"\u7C98\u8D34",copyImage:"\u590D\u5236\u56FE\u7247",copyImageUrl:"\u590D\u5236\u56FE\u7247\u5730\u5740",imageSaveAs:"\u56FE\u7247\u53E6\u5B58\u4E3A",newTabOpenImage:"\u65B0\u6807\u7B7E\u9875\u6253\u5F00\u56FE\u7247",selectBlock:"\u9009\u4E2D\u533A\u5757",selectAll:"\u9009\u4E2D\u5168\u6587",uneditableBlockSelected:"\u9009\u4E2D\u533A\u57DF\u5305\u542B\u9501\u5B9A\u533A\u5757\uFF0C\u6682\u4E0D\u652F\u6301\u526A\u5207"}},iX={contextMenu:{copyMarkdown:"Copy as Markdown",paste:"paste",copyImage:"Copy image",copyImageUrl:"Copy image address",imageSaveAs:"Save image as",newTabOpenImage:"Open image in a new tab",selectBlock:"Select the block",selectAll:"Select all",uneditableBlockSelected:"The selected area contains locked blocks, and cutting is not currently supported"}},oX={contextMenu:{copyMarkdown:"Markdown \u3068\u3057\u3066\u30B3\u30D4\u30FC",paste:"\u8CBC\u308A\u4ED8\u3051",copyImage:"\u753B\u50CF\u3092\u30B3\u30D4\u30FC",copyImageUrl:"\u753B\u50CF\u30A2\u30C9\u30EC\u30B9\u3092\u30B3\u30D4\u30FC",imageSaveAs:"\u540D\u524D\u3092\u4ED8\u3051\u3066\u753B\u50CF\u3092\u4FDD\u5B58",newTabOpenImage:"\u65B0\u3057\u3044\u30BF\u30D6\u3067\u753B\u50CF\u3092\u958B\u304F",selectBlock:"\u30D6\u30ED\u30C3\u30AF\u3092\u9078\u629E",selectAll:"\u30C6\u30AD\u30B9\u30C8\u3092\u5168\u9078\u629E",uneditableBlockSelected:"\u9078\u629E\u3057\u305F\u30A8\u30EA\u30A2\u306B\u30ED\u30C3\u30AF\u3055\u308C\u305F\u30D6\u30ED\u30C3\u30AF\u304C\u542B\u307E\u308C\u3066\u3044\u308B\u305F\u3081\u3001\u5207\u308A\u53D6\u308A\u304C\u3067\u304D\u307E\u305B\u3093"}};D.mergeLang({"zh-CN":rX,"en-US":iX,"ja-JP":oX});function HE(n,t){return t.map(e=>{var o,s;const r=Yt(n,e),i=(o=r.getBlockProperties)==null?void 0:o.call(r,n,e);return pe(e)||_t(n,e)?i!=null&&i.abstract?`[${i.abstract}]`:"":(s=i==null?void 0:i.abstract)!=null?s:""}).join(" ")}function rm(n){const{editor:t,commentGroupId:e,abstract:r="text"}=n,i=Z(),o=t.doc.getUser(),s=Date.now(),l=e!=null?e:i;return{id:i,groupId:l,userId:o.userId,displayName:o.displayName,avatarUrl:o.avatarUrl,abstract:r,created:s,modified:s}}function Gw(n,t,e){const r=e.id,o=n.getBlockData(t).comments;let s;o?s=[...o,r]:s=[r];const l={comments:s};n.updateBlockData(t,l)}function jE(n,t,e){const r=HE(n,[t]),i=rm({editor:n,abstract:r});Gw(n,t,i);const o=eo();return e.localCreateComment(i,o),i}const sX=I("standard-block-actions");class lX{constructor(t,e){m(this,"executeCommand",(t,e,r)=>{const i=r.data;try{this.editorComments.showCommentList();const o=t.getBlockById(i);jE(t,o,this.provider)}catch(o){sX.error(`failed to execute block command: ${JSON.stringify(o)}`)}});this.provider=t,this.editorComments=e}commands(t,e){const r=st(e);return{group:"block-comment-actions",commands:[{id:"comment",name:D.t("comment.quickMenuCommand"),data:r,order:100,states:t.readonly?["disabled"]:[]}],executeCommand:this.executeCommand}}}class aX{async handleBeforePasteDoc(t,e){return Object.values(e.blocks).forEach(r=>{r.forEach(i=>{delete i.comments,i.text&&i.text.forEach(o=>{if(o.attributes){const s=o.attributes;Object.keys(s).forEach(l=>{l.startsWith("comment-")&&delete s[l]})}})})}),!1}}var Zt=(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))(Zt||{});const zE="group-item-action",Ww="last-comment-item",cX="disabled",qw=500;function fc(n){return n.id!==n.groupId}function Xw(n,t=".comment-item-root"){return n.querySelectorAll(t).length}function uX(n){const t=n.closest(".comment-item-root");return t?t.id:null}function mo(n,t){n.setAttribute(zE,t)}function fX(n){return n.closest(`[${zE}]`)}function dX(n){var t;return(t=n.getAttribute(zE))!=null?t:""}function hX(n){return n.disabled||n.classList.contains(cX)}function Qw(n,t){const e=n.rootContainer.querySelector(`[comment-${t.toLocaleLowerCase()}=${t}]`);if(!e)return null;const r=e.closest('[data-type="editor-block"]');return r?r.id:null}function Yw(n){return Array.from(n.attributes).map(e=>e.name).filter(e=>e.startsWith("comment-")).map(e=>e.replace("comment-",""))}const Jw=I("doc-comments");function Zw(n,t,e,r){if(t.comments){const o=t.comments;Array.isArray(o)&&o.forEach(s=>{r.has(s)||(r.add(s),e.push(s))})}t.text&&t.text.forEach(s=>{if(s.attributes){const l="comment-";Object.entries(s.attributes).forEach(([c,d])=>{if(c.startsWith(l)){const h=d;r.has(h)||(r.add(h),e.push(h))}})}});const i=t.children;!i||i.forEach(o=>{n.blocks[o].forEach(l=>{Zw(n,l,e,r)})})}function mX(n){const t=[],e=new Set;n.blocks.root.forEach(i=>{Zw(n,i,t,e)});const r=new Map;return t.forEach((i,o)=>r.set(i,o)),r}function gX(n){const t=new Map;n.forEach(i=>{if(fc(i)){const o=t.get(i.groupId);o?o.push(i):t.set(i.groupId,[i])}});const e=[];return n.forEach(i=>{var o;if(!fc(i)){const s=(o=t.get(i.id))!=null?o:[];t.delete(i.id);const l={...i,children:s};e.push(l)}}),Array.from(t.values()).forEach(i=>{const o=i[0],s=i.slice(1),l={...o,children:s};e.push(l)}),e}function us(n,t){const e=n.doc.toJSON(),r=mX(e);return gX(t.getComments()).filter(s=>r.has(s.groupId)).sort((s,l)=>{const c=r.get(s.groupId),d=r.get(l.groupId);return p(Jw,c!==void 0,`comment not exists in doc, ${s.groupId}`),p(Jw,d!==void 0,`comment not exists in doc, ${l.groupId}`),c-d})}function t4(n){const{children:t,...e}=n,r=[e];return t.forEach(i=>{r.push(i)}),r}function pX(n,t){return us(n,t).length}function GE(n,t){const e=[],r=n.getBlockById(t.blockId);if(nt(n,r)){const o=t.blockId,s=t.offset,l=n.getBlockById(o),c=n.getBlockText(l),d=Aa(c,s);d&&Object.entries(d).forEach(([h,C])=>{h.startsWith("comment-")&&e.push(C)})}const i=r.attributes;for(let o=0;o<i.length;o++){const s=i[o];s.name.startsWith("comment-")&&e.push(s.value)}return e}function e4(n){const t=n.selection.range;if(!t.isSimple())return[];if(t.start.blockId!==t.end.blockId)return[];if(t.isCollapsed())return GE(n,t.start);const{start:e,end:r}=t,i=GE(n,e),o=GE(n,r);return Tg.default(i,o)}const CX=I("active-comments");function n4(n,t){n.rootContainer.querySelectorAll(`span.text.comment[comment-${t}],[data-type=editor-block].comment[comment-${t}]`).forEach(r=>{ot(r,"active")})}function r4(n,t,e){const r=n.rootContainer.querySelector("span.text.comment.active,[data-type=editor-block].comment.active");if(!t)r&&Yw(r).forEach(o=>n4(n,o));else{const i=t.toLocaleLowerCase();if(r){const s=Yw(r);if(s.length===1&&s[0]===i)return;s.forEach(l=>n4(n,l))}const o=n.rootContainer.querySelectorAll(`span.text.comment[comment-${i}],[data-type=editor-block].comment[comment-${i}]`);if(o.length){o.forEach(l=>{z(l,"active")});const s=o[0];if(Vs(s)){const l=lt(s,0,"normal");n.selection.setSelection(l,void 0,{noScroll:e==="next"})}else if(e4(n).indexOf(t)===-1){const c=et(s);p(CX,c,"block not found");const d=zo(c,s),h=lt(c,d.start,"normal");n.selection.setSelection(h,void 0,{noScroll:e==="next"})}if(n.focus(),e==="next"){const l=s.getBoundingClientRect(),c=n.scrollContainer.clientHeight;l.top>c/2&&ca(s,{elementToScroll:n.scrollContainer,verticalOffset:-n.scrollContainer.clientHeight/2})}}}}const qct="";I("comment-editor");const{t:EX}=D,WE="comment-editor-readonly",vf="comment-editor-editing";class qE{constructor(t,e,r){m(this,"root");m(this,"components");m(this,"handleEditorBlur",()=>{this.inactiveEditor()});m(this,"handleEditorFocus",()=>{this.editor.readonly||this.activeEditor()});m(this,"activeEditor",()=>{Rt(this.root,vf)||z(this.root,vf)});m(this,"inactiveEditor",()=>{ot(this.root,vf)});m(this,"handleInsertImg",async()=>{const{editor:t}=this.components,e=ft(t.rootContainer),r=await ha("image/*",{}),i={src:"",widthPercent:50},o={id:Z(),type:"embed",embedType:"image",embedData:i},s=t.options.componentsOptions.image;s!=null&&s.defaultAlign&&(o.align=s.defaultAlign);const l=t.getFocusedBlock(),c=t.getBlockIndex(l),d=t.insertBlock(e,c+1,o);Le.getImageObject(t,d).replaceImage(0,r)});m(this,"handleReadonlyChange",t=>{t.readonly?(ot(this.root,vf),z(this.root,WE)):(z(this.root,vf),ot(this.root,WE))});m(this,"setDoc",t=>{const{components:{editor:e}}=this;e.doc.externalDoc.setDoc(t)});m(this,"getDoc",()=>{const{components:{editor:t}}=this;return t.doc.toJSON()});m(this,"isEmpty",()=>P1(this.getDoc()));m(this,"edit",()=>{const{editor:t}=this.components;t.readonly=!1,fp(t),this.activeEditor()});m(this,"clear",()=>{const t=eo();this.setDoc(t)});m(this,"readonly",()=>{const{editor:t}=this.components;t.readonly=!0});m(this,"destroy",()=>{const{root:t,components:{editor:e,insertImgButton:r}}=this;r.onclick=null,e.destroy(),t.remove()});this.mainEditor=t,this.commentsProvider=e,this.doc=r,this.root=B("div",["comment-editor",WE],null),this.components=this.createEditor()}createEditor(){const t=B("div",["comment-editor-root"],this.root),{commentsProvider:e,mainEditor:r}=this,i=e.createCommentEditor(t,new bp(this.doc));i.readonly=!0,i.addListener("readonlyChanged",this.handleReadonlyChange),i.addListener("focus",this.handleEditorFocus),i.addListener("blur",this.handleEditorBlur);const o=hl(this.root,"comment-editor-img",EX("comment.image"),TT,void 0,r.clientId);return o.classList.add("comment-editor-img"),o.onclick=this.handleInsertImg,{editor:i,insertImgButton:o}}get editor(){return this.components.editor}}class xX{constructor(t){m(this,"handleBeforeKeyDown",(t,e)=>{if(ai(e,"Enter")){const{quickReply:r,updateLastCommentItem:i}=this.groupItem;return r.getReplyEditor().isEmpty()?(r.hideReplyEditor(),!0):(r.reply(),i(),!0)}return!1});this.groupItem=t}}class AX{constructor(t,e,r){m(this,"handleBeforeKeyDown",(t,e)=>{if(ai(e,"Enter")){const{quickReply:r}=this.groupItem,{comment:i,getCommentEditor:o}=this.commentItem,s=o();if(s.isEmpty())this.commentsProvider.localDeleteComment(i.id);else{const l=s.getDoc();this.commentsProvider.localUpdateComment(i,l),s.readonly()}return r.show(),!0}return!1});this.commentsProvider=t,this.groupItem=e,this.commentItem=r}}const bX=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
724
|
+
`).map(h=>{const C={id:Z(),type:"text"};if(xq(h)&&!i)return C.text=Aq(h),C;const E=h?[gr(h,null)]:[];return C.text=E,C})},meta:{},comments:{}};o["text/plain"]=d}return o}}function vq(n){const t=[];for(let e=0;e<n.length;e++){const r=n[e];r.type.toLocaleLowerCase().startsWith("image/")&&t.push(r)}return t}class KE{constructor(t){t.dataConverter.addConverter(new Cq),t.dataConverter.addConverter(new bq),t.dataConverter.addConverter(new Eq)}async handleBeforePaste(t,e,r,i){if(!e)return!1;const o=e.clipboardData;if(o){if(o.getData("text/html").indexOf("<ones-editor-doc")>0)return!1;const l=o.getData("text/plain"),c=vq(i);if(c.length>0&&!l&&!r["text/office-html"])return await this.handleInsertImages(t,c),!0}return!1}async handleInsertImages(t,e){const{start:r,end:i}=t.selection.range,o=t.selection.focusedBlock;let s=rt(o),c=bt(o);const d=et(s);if(d&&St(d)==="code")return;if(r.blockId===i.blockId&&pe(o))c+=1;else{t.clearSelectedContents();const{blockId:C}=t.selection.range.start,E=t.getBlockById(C);c=bt(E),s=rt(E),ie(t,E)||(c+=1),Xt(s)&&c===0&&(c+=1)}const h=ft(s);for(let C=0;C<e.length;C++){const E=e[C],A=await t1(t,"image",h,c+C,{file:E});A&&jv(t,A,"image",{id:"replace-image",name:"Replace image",data:{block:A,image:E}})}}}class Bq extends Re.TypedEmitter{constructor(t){super(),this.editor=t}onUpdateBlockText(t,e,r){const i=this.editor.getCustom("find-dialog");if(!i||!i.isVisible())return;const o=zi(ui(this.editor,t),e);!nt(this.editor,o)||!r.some(l=>l.insert||l.delete)||this.emit("onDocChanged",o)}onInsertBlock(t,e,r,i){zi(ui(this.editor,t),e),this.emit("onDocInserted")}onDeleteBlock(t,e,r){const i=zi(ui(this.editor,t),e);this.emit("onDocDeleted",i)}}function Dw(n){return me.isSafari&&!!n&&Date.now()-n<100}const _w=I("highlight-data");class J0{constructor(t){m(this,"data",new Map);this.editor=t}add(t,e,r){const i={id:Z(),blockId:st(t),oldText:this.editor.getBlockText(t),start:e,end:r};return this.data.set(i.id,i),i}get(t){const e=this.data.get(t);return p(_w,e,`no highligh data: ${t}`),e}remove(t){this.data.delete(t)}clearBlockData(t){Array.from(this.data.values()).forEach(e=>{e.blockId===t&&this.data.delete(e.id)})}destroy(){}static getData(t){return t.addCustom("highligh-data",()=>new J0(t))}}function Tq(n,t,e,r,i){const s=J0.getData(n).add(t,e,r);return i.setAttribute("data-highlight-id",s.id),s}function Z0(n,t){const e=t.getAttribute("data-highlight-id");return p(_w,e,"invalid highlight elem, no id"),J0.getData(n).get(e)}const cc=I("highligh-dom");function yq(n){return Rt(n,"editor-highlight")}function Ri(n){const t=n.rootContainer.querySelectorAll(".editor-highlight");return Array.from(t)}function kq(n,t){p(cc,t,"invalid block");const e=t.querySelectorAll(".editor-highlight");return Array.from(e)}function Rq(n){const t=n.rootContainer.querySelectorAll(".editor-replace-result-highlight");return Array.from(t)}function tm(n){const t=n.querySelectorAll(".editor-highlight");return Array.from(t)}function wq(n){tm(n).forEach(t=>{t.remove()})}function ho(n){return Ri(n).length}function Sq(n,t){p(cc,t>=0,`invalid highlight index: ${t}`);const e=Ri(n);return e.length===0?null:(p(cc,t<e.length,`invalid highlight index: ${t}/${e.length}`),e[t])}function Lq(n,t,{left:e,top:r,width:i,height:o},s){const l=["editor-highlight-child"];s&&l.push("editor-highlight-readonly");const c=B("div",l,n);c.style.top=`${r}px`,c.style.left=`${e}px`,c.style.width=`${i}px`,c.style.height=`${o}px`}function Mw(n,t,e,r,i){p(cc,r>0,`invalid end: ${r}`);const o=re(t),s=t.getBoundingClientRect(),l=qi(n,t,Te(n,t,e,r)),d=B("div",[i==="find"?"editor-highlight":"editor-replace-result-highlight"],o);l.forEach(h=>{Lq(d,t,{left:h.left-s.left,width:h.width,top:h.top-s.top,height:h.height})}),Tq(n,t,e,r,d)}function Iq(n,t,e,r){return Mw(n,t,e,r,"find")}function Uw(n,t,e,r){return Mw(n,t,e,r,"replace")}function em(n,t){Ri(n).forEach(s=>{Rt(s,"active")&&ot(s,"active")}),z(t,"active"),p(cc,t.firstChild instanceof HTMLElement,"invalid highligh dom, invalid elem child");const r=t.firstChild;let o=r.getBoundingClientRect().y;o===0&&(o=r.getBoundingClientRect().y),ca(r,{elementToScroll:n.scrollContainer})}function Af(n){const t=n.rootContainer.querySelector(".editor-highlight.active");return t||null}function Ow(n){return p(cc,n,"no highlight elem"),Rt(n,"editor-highlight-readonly")}const uc=I("highligh-text");function Nw(n){Rq(n).forEach(e=>{e.remove()})}function nm(n,t){Ri(n).forEach(r=>{r.remove()}),t!=null&&t.keepReplaceResult||Nw(n)}function Pw(n,t,e){kq(n,t).forEach(i=>{i.remove()}),e!=null&&e.keepReplaceResult||Nw(n)}function bf(n){const t=Af(n);if(!t)return-1;const r=Ri(n).indexOf(t);return p(uc,r!==-1,`invalid highlight index: ${r}`),r}function Dq(n){const t=Ri(n);if(t.length===0)return 0;const e=Af(n);let r=e?t.indexOf(e):-1;!e||r===-1||r===t.length-1?r=0:r+=1;const i=t[r];return em(n,i),r}function _q(n){const t=Ri(n);if(t.length===0)return 0;const e=Af(n);let r=e?t.indexOf(e):-1;!e||r===-1||r===0?r=t.length-1:r-=1;const i=t[r];return em(n,i),r}function VE(n,t){const e=Ri(n);e.length>0&&t<e.length&&em(n,e[t])}function Mq(n,t,e){const r=Af(n);if(!r)return!1;const i=et(r);if(p(uc,i,"no parent block"),!n.isBlockWritable(i))return!1;const o=ho(n);let s=bf(n);if(!Ow(r)&&n.isBlockWritable(i)){const d=Z0(n,r),h=n.getBlockText(i),{start:C,end:E}=Z0(n,r),[A,v]=fn.transformOffset(d.oldText,h,[C,E]),R=W3(h,A,v-A);if(fe(R).toLowerCase()!==t.toLowerCase())return!1;const L=fh(h,A,v,e);n.setBlockText(i,L),wq(i),$E(n,i,t),e&&Uw(n,i,A,A+e.length)}const l=ho(n);s>=l?s=0:l>o&&(s+=1);const c=Sq(n,s);return c&&em(n,c),!0}function Uq(n,t,e,r){if(!nt(n,t)||!n.isBlockWritable(t))return 0;const i=n.getBlockText(t);p(uc,i,"no block text");const o={count:0},s=pB(i,e,r,o);return fe(i)===fe(s)?0:(n.setBlockText(t,s),o.count)}function Oq(n,t,e){if(p(uc,yq(t),"not a highlight elem"),Ow(t))return;p(uc,e>0,"invalid highlight length");const r=Z0(n,t),i=et(t);p(uc,i,"no parent block"),Uw(n,i,r.start,r.start+e)}function Nq(n,t){Ri(n).forEach(r=>{Oq(n,r,t)})}function Pq(n,t,e){if(n.readonly)return 0;const r=o=>{let s=0;return ue(o).forEach(c=>{Dt(n,c)?An(n,c).forEach(h=>{s+=r(h)}):s+=Uq(n,c,t,e)}),s},i=r(n.rootContainer);return e.length>0&&Nq(n,e.length),i}function Fq(n){const t=n.selection.range.end,e=n.getBlockById(t.blockId),r=t.isSimple()?t.offset:1,i=tm(e);for(let l=0;l<i.length;l++){const c=i[l],{end:d}=Z0(n,c);if(d>=r)return c}const o=c1(n,{simpleBlockOnly:!0}),s=o.indexOf(e);if(s===-1)return null;for(let l=s+1;l<o.length;l++){const c=o[l],d=tm(c);if(d.length>0)return d[0]}return null}function Kq(n){const t=Ri(n),e=Fq(n);return e?t.indexOf(e):0}function $E(n,t,e){if(!!e&&nt(n,t)){const r=n.getBlockText(t),i=N1(r,e);i.length>0&&i.forEach(({start:o,end:s})=>{Iq(n,t,o,s)})}}function Fw(n,t){if(nm(n),!t)return;c1(n,{simpleBlockOnly:!0}).forEach(r=>{$E(n,r,t)})}class Vq{constructor(t){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",t=>{setTimeout(()=>{Pw(this.editor,t),$E(this.editor,t,this.components.findInput.value);const e=ho(this.editor);t.querySelectorAll(".editor-highlight").length===e&&VE(this.editor,0);const r=bf(this.editor);this.updateSearchStatus(r,e)})});m(this,"handleDocInserted",()=>{const t=setTimeout(()=>{clearTimeout(t),nm(this.editor,{keepReplaceResult:!0}),Fw(this.editor,this.components.findInput.value);const e=ho(this.editor),r=bf(this.editor);this.updateSearchStatus(r,e),VE(this.editor,r)})});m(this,"handleDocDeleted",t=>{const e=setTimeout(()=>{if(!tm(t).length){clearTimeout(e);return}Pw(this.editor,t);const i=ho(this.editor),o=bf(this.editor);this.updateSearchStatus(o,i)})});m(this,"handleInput",t=>{if(t.isComposing||Dw(this._compositionEndTime)){this.doSearch.cancel();return}this.handleFindChanged()});m(this,"handleFind",()=>{this.findNext({keepSearchResult:!1})});m(this,"handleReplace",()=>{const t=this.components.findInput.value;if(!t||!Af(this.editor))return;const r=this.components.replaceInput.value;if(t===r)return;if(Mq(this.editor,t,r)){const o=bf(this.editor),s=ho(this.editor);this.updateSearchStatus(o,s)}r.includes(t)&&this.findNext({keepSearchResult:!0})});m(this,"handleReplaceAll",()=>{const t=this.components.findInput.value;if(!t)return;const e=this.components.replaceInput.value;t!==e&&this.editor.undoManager.runInGroup(()=>{Pq(this.editor,t,e)>0&&(this.oldText="",this.doSearchNow({keepReplaceResult:!0,gotoFirstSearchResult:!0}),this.clearFind({keepReplaceResult:!0}))})});m(this,"doSearch",Me.default(this.doSearchNow,300));this.editor=t;const e=B("div",["editor-find-dialog"],null),r=B("div",["editor-find-content"],e),i=B("div",["editor-find-dialog-row"],r),o=Ms(Gh,["editor-find-dialog-button-close"],e),s=B("label",["editor-find-dialog-label"],i,D.t("find.findLabel"));s.htmlFor="";const l=B("div",["editor-find-dialog-input-container"],i),c=B("input",["editor-find-dialog-input"],l);c.type="text",c.placeholder=D.t("find.findPlaceholder");const d=B("div",["editor-find-dialog-status"],l),h=Ms(hT,["editor-find-dialog-icon-button"],d),C=B("div",["editor-find-dialog-curr"],d,"0/0"),E=Ms(mT,["editor-find-dialog-icon-button"],d);let A;D.t("find.moreButton")?A=B("button",["editor-find-dialog-button"],i,D.t("find.moreButton")):A=Ms(jp,["editor-find-dialog-icon-button-border"],i);const v=B("div",["editor-find-dialog-row"],r),R=B("label",["editor-find-dialog-label"],v,D.t("find.replaceLabel"));R.htmlFor="";const L=B("div",["editor-find-dialog-input-container"],v),M=B("input",["editor-find-dialog-input"],L);M.type="text",M.placeholder=D.t("find.replacePlaceholder");const U=B("div",["editor-find-dialog-row","editor-find-dialog-action"],r);B("div",["editor-find-dialog-space"],U);const F=B("button",["editor-find-dialog-button"],U,D.t("find.findButton")),G=B("button",["editor-find-dialog-button"],U,D.t("find.replaceButton")),W=B("button",["editor-find-dialog-button","editor-find-dialog-primary-button"],U,D.t("find.replaceAllButton"));A.onclick=()=>{this.showReplace()},o.onclick=()=>{this.hide()},c.onkeydown=at=>{if(at.isComposing||Dw(this._compositionEndTime)){this.doSearch.cancel();return}Qb(at)?(this.doSearch.cancel(),this.doSearchNow({keepReplaceResult:!1,gotoFirstSearchResult:!0})):Og(at)&&this.hide()},c.oninput=this.handleInput,c.onpaste=this.handleFindChanged,c.oncut=this.handleFindChanged,c.addEventListener("compositionend",this.handleCompositionEnd),c.maxLength=50,F.onclick=this.handleFind,G.onclick=this.handleReplace,W.onclick=this.handleReplaceAll,M.maxLength=50,E.onclick=()=>{this.gotoNext()},h.onclick=()=>{this.gotoPrev()},this.components={findInput:c,findPrev:h,findCurrent:C,findNext:E,replaceInput:M,findButton:F,replaceButton:G,replaceAllButton:W,closeButton:o,showReplaceButton:A,rowReplace:v,rowActions:U,statusContainer:d},this.root=e;const it=new Bq(t);t.doc.registerCallback(it),it.addListener("onDocChanged",this.handleDocChanged),it.addListener("onDocInserted",this.handleDocInserted),it.addListener("onDocDeleted",this.handleDocDeleted)}findNext(t){this.doSearch.cancel(),this.doSearchNow({keepReplaceResult:t.keepSearchResult,gotoFirstSearchResult:!0})}doSearchNow(t){const e=this.components.findInput.value;if(e||this.clearFind(t),this.oldText===e){this.gotoNext();return}this.oldText=e,Fw(this.editor,e);const r=ho(this.editor),i=Kq(this.editor);t.gotoFirstSearchResult&&VE(this.editor,i),this.updateSearchStatus(i,r)}gotoNext(){const t=ho(this.editor),e=Dq(this.editor);this.updateSearchStatus(e,t)}gotoPrev(){const t=ho(this.editor),e=_q(this.editor);this.updateSearchStatus(e,t)}updateSearchStatus(t,e){if(this.oldText?this.components.statusContainer.style.display="flex":this.components.statusContainer.style.display="none",e===0)this.components.findCurrent.innerText="0 / 0",this.components.replaceAllButton.disabled=!0,this.components.replaceButton.disabled=!0,this.components.findButton.disabled=!0;else{this.components.findCurrent.innerText=`${t+1} / ${e}`;const r=this.editor.readonly;this.components.replaceAllButton.disabled=r,this.components.replaceButton.disabled=r,this.components.findButton.disabled=!1}}clearFind(t){nm(this.editor),this.updateSearchStatus(0,0)}showFindOnly(){this.components.rowReplace.style.display="none",this.components.rowActions.style.display="none",this.components.showReplaceButton.style.display="flex"}showReplace(){this.components.rowReplace.style.display="flex",this.components.rowActions.style.display="flex",this.components.showReplaceButton.style.display="none",this.components.replaceInput.focus(),this.components.replaceInput.select()}hideSearchResult(){this.components.statusContainer.style.display="none"}showSearchResult(){this.components.statusContainer.style.display="flex"}show(t){const e=this.editor.getSelectedText();e.length>0&&e.length<50&&(this.components.findInput.value=e),this.root.style.display="flex",t!=null&&t.showFindAndReplace?(this.showReplace(),this.components.findInput.value&&setTimeout(()=>{this.components.replaceInput.focus()})):this.showFindOnly(),this.hideSearchResult(),this.oldText="",this.doSearchNow({keepReplaceResult:!1,gotoFirstSearchResult:!0});const r=this.editor.readonly,i=this.components.findInput.value;this.components.replaceButton.disabled=r||!i,this.components.replaceAllButton.disabled=r||!i,this.components.replaceInput.disabled=r,this.dialog||(this.dialog=new Fu(this.root,{disablePageScroll:!1}));const o=this.editor.options.componentsOptions.findDialog,s=(o==null?void 0:o.popoverTarget)||this.editor.rootContainer,l=()=>{var E,A,v,R;const c=o==null?void 0:o.getReferenceClientRect;if(c&&((A=(E=this.dialog)==null?void 0:E.tippyInstance)==null?void 0:A.popper))return c(s,(R=(v=this.dialog)==null?void 0:v.tippyInstance)==null?void 0:R.popper);const d=s.getBoundingClientRect(),h=d.top<0?12:d.top+12,C=d.right-this.root.clientWidth-12;return new DOMRect(C,h,0,0)};this.dialog.show(s,{getReferenceClientRect:l}),setTimeout(()=>{this.components.findInput.focus(),this.components.findInput.select()},300)}hide(){var t;(t=this.dialog)==null||t.close("cancelBar"),nm(this.editor)}isVisible(){return this.dialog&&this.dialog.isVisible}research(){this.oldText="",this.doSearch({keepReplaceResult:!0,gotoFirstSearchResult:!1})}destroy(){var t;(t=this.dialog)==null||t.destroy()}}const $q={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"}},Hq={find:{findLabel:"Search:",replaceLabel:"Replace:",findButton:"Search",replaceButton:"Replace",replaceAllButton:"Replace all",moreButton:"",findPlaceholder:"Search text in document",replacePlaceholder:"Replace with"}},jq={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"}};D.mergeLang({"zh-CN":$q,"en-US":Hq,"ja-JP":jq});function Kw(n){return n.addCustom("find-dialog",()=>new Vq(n)).show(),!0}const Vw={"CtrlOrCmd+F":Kw},Gct="";function zq(n){Kw(n)}const Gq=I("context-menu-utils");async function Wq(){try{const n=await navigator.clipboard.readText(),e=(await navigator.clipboard.read())[0].types;return!n.trim()&&e.length===1&&e.includes("text/plain")}catch(n){return Gq.warn(`Failed to read clipboard data: ${n}`),!0}}function $w(n,t){const e=document.createElement("a");e.href=n,e.download=t,e.click()}function qq(n){return new Promise((t,e)=>{const r=new FileReader;r.onload=()=>{const i=r.result;t(i)},r.onerror=()=>{e(new Error("Failed to read Blob as string."))},r.readAsText(n)})}async function Xq(){const t=(await navigator.clipboard.read())[0],e=t.types,r=new DataTransfer;for(let i=0;i<e.length;i++){const o=e[i],s=await t.getType(o),l=await qq(s);r.setData(o,l)}return r}const Hw=I("context-menu-actions");async function jw(n){n.inputHandlers.onCopyWithoutEvent()}async function Qq(n){n.selection.range.isCollapsed()||xp(n)}async function Yq(n){jw(n),yh(n)}function Jq(n,t){p(Hw,t,"block can not be null"),p(Hw,pe(t),"block should be embed type");const e=[],r=n.getBlockData(t),i=r.embedType,o=n.editorEmbeds.getEmbedClass(i);if(o.getResources)o.getResources(n,r).forEach(s=>{e.push(s)});else{const l=r.embedData.src;l&&typeof l=="string"&&e.push(l)}return e}async function Zq(n,t){const e=Jq(n,t);if(e&&e.length){const r=e[0],i=n.doc.buildResourceUrl(r);$w(i,r)}}function tX(n){Xq().then(t=>{const e=new ClipboardEvent("paste",{clipboardData:t});document.dispatchEvent(e)})}const eX=I("context-menu");class nX{constructor(t){m(this,"t",D.t);m(this,"clipboardPermission",{read:"prompt",write:"granted"});m(this,"isSecureContext",window.isSecureContext);m(this,"externalActionHandleMap",new Map);m(this,"handleActionByExternal",t=>{const{data:e}=t;if(e&&e.externalType){const r=e.externalType,i=this.externalActionHandleMap.get(r);if(i)return i(this.editor,this.editor.selection.focusedBlock,t)}return!1});m(this,"getPasteCommandItem",async()=>{const t=this.hasClipboardReadPermission;let e;Jc()||ua()?e=!0:e=t?await Wq():!1;const r=this.isSecureContext&&this.clipboardPermission.read!=="denied"&&!e,i=this.t("contextMenu.paste"),o=ze("CtrlOrCmd+V");return{id:"paste",name:i,subText:o,states:r?[]:["disabled"],disableReason:this.isSecureContext&&t?"":this.secureEnvTips(o,i)}});m(this,"getCommandItems",async()=>{const t=await this.getPasteCommandItem(),e=this.editor.readonly?[]:[this.cutCommandItem,t],r=[...this.copyTypeCommandItems,...e];return this.getExternalContextMenuOptions(r),r.push(this.stepItem,...this.selectionCommandItems),r});m(this,"getExternalContextMenuOptions",t=>{const e=this.editor.selection.focusedBlock,r=Yt(this.editor,e);if(r&&r.getBlockProperties){const i=r.getBlockProperties(this.editor,e);if(i){const{blockCommands:o}=i;if(o&&o["context-menu"]){const{commands:s,executeCommand:l,group:c}=o["context-menu"];if(s.length){const d=s.map(h=>({...h,data:{...h.data||{},externalType:c}}));t.push(this.stepItem,...d)}this.externalActionHandleMap.set(c,l)}}}});m(this,"isFocusImageBlock",()=>{const t=this.editor.selection,e=t.focusedBlock;return pe(e)&&Ge(e)==="image"&&t.range.getSelectedBlocks().length===1});m(this,"isFocusImageTypeEmbed",()=>{const e=this.editor.selection.focusedBlock,r=["mermaid","flowchart","drawio"];return pe(e)&&r.includes(Ge(e))});this.editor=t,this.clipboardSupport()}get hasClipboardReadPermission(){return this.clipboardPermission.read==="granted"}get hasClipboardWritePermission(){return this.clipboardPermission.write==="granted"}clipboardSupport(){if(!navigator.clipboard){this.clipboardPermission={write:"denied",read:"denied"};return}if(!navigator.permissions){this.clipboardPermission={write:"granted",read:"denied"};return}try{const t=navigator.permissions.query({name:"clipboard-read"}),e=navigator.permissions.query({name:"clipboard-write"});Promise.all([t,e]).then(r=>{const i=r[0],o=r[1];this.clipboardPermission={read:i.state,write:o.state},i.state!=="granted"&&(i.onchange=s=>{this.clipboardPermission.read=s.target.state}),o.state!=="granted"&&(i.onchange=s=>{this.clipboardPermission.write=s.target.state})}).catch(r=>{this.clipboardPermission.read="denied",eX.log(r)})}catch{this.clipboardPermission={write:"granted",read:"denied"}}}get isRangeCollapsed(){return this.editor.selection.range.isCollapsed()}get imageTypeCommandItems(){const t=this.isSecureContext&&this.hasClipboardWritePermission;return[{id:"copy-image",name:this.t("contextMenu.copyImage"),subText:ze("CtrlOrCmd+C"),states:t?[]:["disabled"],disableReason:this.isSecureContext&&this.hasClipboardWritePermission?"":this.secureEnvTips(this.t("contextMenu.copyImage"),ze("CtrlOrCmd+C"))},{id:"copy-image-url",name:this.t("contextMenu.copyImageUrl"),states:t?[]:["disabled"]},{id:"image-save-as",name:this.t("contextMenu.imageSaveAs")},{id:"new-tab-open-image",name:this.t("contextMenu.newTabOpenImage")}]}get copyTypeCommandItems(){const t=this.isSecureContext&&!this.isRangeCollapsed;if(this.isFocusImageBlock())return this.imageTypeCommandItems;const e=this.t("copyCutProperty.copy"),r=ze("CtrlOrCmd+C"),i=[{id:"copy",name:e,subText:r,states:t?[]:["disabled"],disableReason:this.isSecureContext&&this.hasClipboardWritePermission?"":this.secureEnvTips(r,e)}];this.isFocusImageTypeEmbed()&&i.push({id:"image-save-as",name:this.t("contextMenu.imageSaveAs")});const s=this.t("contextMenu.copyMarkdown"),l=ze("CtrlOrCmd+Shift+C");return i.push({id:"copy-markdown",name:s,subText:l,states:t?[]:["disabled"],disableReason:this.isSecureContext&&this.hasClipboardWritePermission?"":this.secureEnvTips(l,s)}),i}get cutCommandItem(){let t=this.isSecureContext&&!this.isRangeCollapsed;const r=this.editor.selection.range.getSelectedBlocks().some(l=>!this.editor.isBlockWritable(l.block));r&&(t=!1);const i=this.t("copyCutProperty.cut"),o=ze("CtrlOrCmd+X");let s="";return t||(!this.isSecureContext||!this.hasClipboardWritePermission?s=this.secureEnvTips(o,i):r&&(s=this.t("contextMenu.uneditableBlockSelected"))),{id:"cut",name:this.t("copyCutProperty.cut"),subText:ze("CtrlOrCmd+X"),states:t?[]:["disabled"],disableReason:s}}get stepItem(){return{id:"step",name:"",type:"separator"}}get selectionCommandItems(){let t=!1;const e=this.editor.selection;e.range.isCollapsed()&&(t=!0),e.range.start.isSimple()&&e.range.end.isSimple()&&(t=e.range.start.offset>0&&e.range.getSelectedBlocks().length===1);const r=[{id:"select-block",name:this.t("contextMenu.selectBlock"),states:t?[]:["disabled"]}];return r.push({id:"select-all",name:this.t("contextMenu.selectAll")}),r}destroy(){this.externalActionHandleMap.clear()}secureEnvTips(t,e){return this.t("copyCutProperty.unsafeEnvTips",{shortCut:t,operation:e})}}const Wct="";class zw{constructor(t){m(this,"contextMenu");m(this,"contextMenuCommandItems");m(this,"destroy",()=>{this.contextMenuCommandItems.destroy(),this.contextMenu.off("show",this.handleContextMenuShown),this.contextMenu.off("click",this.handleContextMenuClick),document.removeEventListener("contextmenu",this.handleContextMenu)});m(this,"updateEditorCaret",t=>{const{x:e,y:r}=t,i=l1(this.editor,e,r),o=this.editor.selection.range,s=o.getSelectedBlocks().some(l=>l.block.id===(i==null?void 0:i.focus.blockId));o.focus.blockId!==(i==null?void 0:i.focus.blockId)&&o.focus.isSimple()&&!s&&this.editor.selectionHandler.handleMouseDown(t,{autoScroll:!1})});m(this,"handleContextMenu",t=>{if(!this.editor.findCustom("editor-context-menu"))return;const r=t.target;if(this.editor.findCustom("toolbar-handler")&&this.editor.getCustom("toolbar-handler").isInToolbar(t)){t.preventDefault();return}if(this.editor.findCustom("block-menu")){const o=this.editor.getCustom("block-menu");if(o.blockMenu.isInMenu(r)||o.emptyBlockMenu.isInMenu(r)){t.preventDefault();return}}const i=!!r.closest("button.block-button");(this.isInEditor(t)||r.classList.contains("editor-disable-scroll")||i)&&(t.preventDefault(),this.updateEditorCaret(t),this.contextMenu.manualShow(document.body,{theme:"light",point:{x:t.clientX,y:t.clientY}}))});m(this,"isInMenu",t=>this.contextMenu.isInCommandBar(t.target));m(this,"isInEditor",t=>{const{clientX:e,clientY:r}=t,i=this.editor.rootElement,o=i.getBoundingClientRect(),{top:s,left:l,right:c,bottom:d}=o,h=e>=l&&e<=c&&r>=s&&r<=d,C=t.target instanceof HTMLElement&&!(t.target instanceof HTMLInputElement||t.target instanceof HTMLTextAreaElement)&&i.contains(t.target);return h&&(this.isInMenu(t)||C)});m(this,"handleContextMenuShown",async()=>{this.editor.findCustom("toolbar-handler")&&this.editor.getCustom("toolbar-handler").hide();const t=await this.contextMenuCommandItems.getCommandItems();this.contextMenu.updateItems(t)});m(this,"handleContextMenuClick",(t,e)=>{if(this.contextMenuCommandItems.handleActionByExternal(e))return;const{id:r}=e;switch(r){case"copy":jw(this.editor);break;case"copy-markdown":Qq(this.editor);break;case"cut":if(this.handleImageEmbedAction(r))break;Yq(this.editor);break;case"paste":tX(this.editor);break;case"copy-image":case"copy-image-url":case"image-save-as":case"new-tab-open-image":this.handleImageEmbedAction(r);break;case"select-all":Sh(this.editor,this.editor.rootContainer);break;case"select-block":mp(this.editor);break}});this.editor=t,this.contextMenu=new Zo([],void 0,{id:"right-context-menu",classes:[D.getCurrentLang()]}),this.contextMenu.on("show",this.handleContextMenuShown),this.contextMenu.on("click",this.handleContextMenuClick),document.addEventListener("contextmenu",this.handleContextMenu),this.contextMenuCommandItems=new nX(t)}handleImageEmbedAction(t){const e=this.editor.selection.focusedBlock;if(pe(e)&&Ge(e)==="image"){const r=e,i=Le.getImageObject(this.editor,r),o=i.getSelectedIndex(),s=i.getImages();if(o!==-1){let l=r.querySelectorAll("img")[o].src;if(l){switch(l=this.editor.doc.buildResourceUrl(l),t){case"cut":Q0(this.editor,null),Y0(this.editor);break;case"copy-image":Q0(this.editor,null);break;case"copy-image-url":da([{type:"text/plain",data:new Blob([l],{type:"text/plain"})}]);break;case"image-save-as":$w(l,s[o].src);break;case"new-tab-open-image":window.open(l);break}return!0}}}else switch(t){case"image-save-as":Zq(this.editor,e);break}return!1}}const rX={contextMenu:{copyMarkdown:"\u590D\u5236\u4E3A Markdown",paste:"\u7C98\u8D34",copyImage:"\u590D\u5236\u56FE\u7247",copyImageUrl:"\u590D\u5236\u56FE\u7247\u5730\u5740",imageSaveAs:"\u56FE\u7247\u53E6\u5B58\u4E3A",newTabOpenImage:"\u65B0\u6807\u7B7E\u9875\u6253\u5F00\u56FE\u7247",selectBlock:"\u9009\u4E2D\u533A\u5757",selectAll:"\u9009\u4E2D\u5168\u6587",uneditableBlockSelected:"\u9009\u4E2D\u533A\u57DF\u5305\u542B\u9501\u5B9A\u533A\u5757\uFF0C\u6682\u4E0D\u652F\u6301\u526A\u5207"}},iX={contextMenu:{copyMarkdown:"Copy as Markdown",paste:"paste",copyImage:"Copy image",copyImageUrl:"Copy image address",imageSaveAs:"Save image as",newTabOpenImage:"Open image in a new tab",selectBlock:"Select the block",selectAll:"Select all",uneditableBlockSelected:"The selected area contains locked blocks, and cutting is not currently supported"}},oX={contextMenu:{copyMarkdown:"Markdown \u3068\u3057\u3066\u30B3\u30D4\u30FC",paste:"\u8CBC\u308A\u4ED8\u3051",copyImage:"\u753B\u50CF\u3092\u30B3\u30D4\u30FC",copyImageUrl:"\u753B\u50CF\u30A2\u30C9\u30EC\u30B9\u3092\u30B3\u30D4\u30FC",imageSaveAs:"\u540D\u524D\u3092\u4ED8\u3051\u3066\u753B\u50CF\u3092\u4FDD\u5B58",newTabOpenImage:"\u65B0\u3057\u3044\u30BF\u30D6\u3067\u753B\u50CF\u3092\u958B\u304F",selectBlock:"\u30D6\u30ED\u30C3\u30AF\u3092\u9078\u629E",selectAll:"\u30C6\u30AD\u30B9\u30C8\u3092\u5168\u9078\u629E",uneditableBlockSelected:"\u9078\u629E\u3057\u305F\u30A8\u30EA\u30A2\u306B\u30ED\u30C3\u30AF\u3055\u308C\u305F\u30D6\u30ED\u30C3\u30AF\u304C\u542B\u307E\u308C\u3066\u3044\u308B\u305F\u3081\u3001\u5207\u308A\u53D6\u308A\u304C\u3067\u304D\u307E\u305B\u3093"}};D.mergeLang({"zh-CN":rX,"en-US":iX,"ja-JP":oX});function HE(n,t){return t.map(e=>{var o,s;const r=Yt(n,e),i=(o=r.getBlockProperties)==null?void 0:o.call(r,n,e);return pe(e)||Dt(n,e)?i!=null&&i.abstract?`[${i.abstract}]`:"":(s=i==null?void 0:i.abstract)!=null?s:""}).join(" ")}function rm(n){const{editor:t,commentGroupId:e,abstract:r="text"}=n,i=Z(),o=t.doc.getUser(),s=Date.now(),l=e!=null?e:i;return{id:i,groupId:l,userId:o.userId,displayName:o.displayName,avatarUrl:o.avatarUrl,abstract:r,created:s,modified:s}}function Gw(n,t,e){const r=e.id,o=n.getBlockData(t).comments;let s;o?s=[...o,r]:s=[r];const l={comments:s};n.updateBlockData(t,l)}function jE(n,t,e){const r=HE(n,[t]),i=rm({editor:n,abstract:r});Gw(n,t,i);const o=eo();return e.localCreateComment(i,o),i}const sX=I("standard-block-actions");class lX{constructor(t,e){m(this,"executeCommand",(t,e,r)=>{const i=r.data;try{this.editorComments.showCommentList();const o=t.getBlockById(i);jE(t,o,this.provider)}catch(o){sX.error(`failed to execute block command: ${JSON.stringify(o)}`)}});this.provider=t,this.editorComments=e}commands(t,e){const r=st(e);return{group:"block-comment-actions",commands:[{id:"comment",name:D.t("comment.quickMenuCommand"),data:r,order:100,states:t.readonly?["disabled"]:[]}],executeCommand:this.executeCommand}}}class aX{async handleBeforePasteDoc(t,e){return Object.values(e.blocks).forEach(r=>{r.forEach(i=>{delete i.comments,i.text&&i.text.forEach(o=>{if(o.attributes){const s=o.attributes;Object.keys(s).forEach(l=>{l.startsWith("comment-")&&delete s[l]})}})})}),!1}}var Zt=(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))(Zt||{});const zE="group-item-action",Ww="last-comment-item",cX="disabled",qw=500;function fc(n){return n.id!==n.groupId}function Xw(n,t=".comment-item-root"){return n.querySelectorAll(t).length}function uX(n){const t=n.closest(".comment-item-root");return t?t.id:null}function mo(n,t){n.setAttribute(zE,t)}function fX(n){return n.closest(`[${zE}]`)}function dX(n){var t;return(t=n.getAttribute(zE))!=null?t:""}function hX(n){return n.disabled||n.classList.contains(cX)}function Qw(n,t){const e=n.rootContainer.querySelector(`[comment-${t.toLocaleLowerCase()}=${t}]`);if(!e)return null;const r=e.closest('[data-type="editor-block"]');return r?r.id:null}function Yw(n){return Array.from(n.attributes).map(e=>e.name).filter(e=>e.startsWith("comment-")).map(e=>e.replace("comment-",""))}const Jw=I("doc-comments");function Zw(n,t,e,r){if(t.comments){const o=t.comments;Array.isArray(o)&&o.forEach(s=>{r.has(s)||(r.add(s),e.push(s))})}t.text&&t.text.forEach(s=>{if(s.attributes){const l="comment-";Object.entries(s.attributes).forEach(([c,d])=>{if(c.startsWith(l)){const h=d;r.has(h)||(r.add(h),e.push(h))}})}});const i=t.children;!i||i.forEach(o=>{n.blocks[o].forEach(l=>{Zw(n,l,e,r)})})}function mX(n){const t=[],e=new Set;n.blocks.root.forEach(i=>{Zw(n,i,t,e)});const r=new Map;return t.forEach((i,o)=>r.set(i,o)),r}function gX(n){const t=new Map;n.forEach(i=>{if(fc(i)){const o=t.get(i.groupId);o?o.push(i):t.set(i.groupId,[i])}});const e=[];return n.forEach(i=>{var o;if(!fc(i)){const s=(o=t.get(i.id))!=null?o:[];t.delete(i.id);const l={...i,children:s};e.push(l)}}),Array.from(t.values()).forEach(i=>{const o=i[0],s=i.slice(1),l={...o,children:s};e.push(l)}),e}function us(n,t){const e=n.doc.toJSON(),r=mX(e);return gX(t.getComments()).filter(s=>r.has(s.groupId)).sort((s,l)=>{const c=r.get(s.groupId),d=r.get(l.groupId);return p(Jw,c!==void 0,`comment not exists in doc, ${s.groupId}`),p(Jw,d!==void 0,`comment not exists in doc, ${l.groupId}`),c-d})}function t4(n){const{children:t,...e}=n,r=[e];return t.forEach(i=>{r.push(i)}),r}function pX(n,t){return us(n,t).length}function GE(n,t){const e=[],r=n.getBlockById(t.blockId);if(nt(n,r)){const o=t.blockId,s=t.offset,l=n.getBlockById(o),c=n.getBlockText(l),d=Aa(c,s);d&&Object.entries(d).forEach(([h,C])=>{h.startsWith("comment-")&&e.push(C)})}const i=r.attributes;for(let o=0;o<i.length;o++){const s=i[o];s.name.startsWith("comment-")&&e.push(s.value)}return e}function e4(n){const t=n.selection.range;if(!t.isSimple())return[];if(t.start.blockId!==t.end.blockId)return[];if(t.isCollapsed())return GE(n,t.start);const{start:e,end:r}=t,i=GE(n,e),o=GE(n,r);return Tg.default(i,o)}const CX=I("active-comments");function n4(n,t){n.rootContainer.querySelectorAll(`span.text.comment[comment-${t}],[data-type=editor-block].comment[comment-${t}]`).forEach(r=>{ot(r,"active")})}function r4(n,t,e){const r=n.rootContainer.querySelector("span.text.comment.active,[data-type=editor-block].comment.active");if(!t)r&&Yw(r).forEach(o=>n4(n,o));else{const i=t.toLocaleLowerCase();if(r){const s=Yw(r);if(s.length===1&&s[0]===i)return;s.forEach(l=>n4(n,l))}const o=n.rootContainer.querySelectorAll(`span.text.comment[comment-${i}],[data-type=editor-block].comment[comment-${i}]`);if(o.length){o.forEach(l=>{z(l,"active")});const s=o[0];if(Vs(s)){const l=lt(s,0,"normal");n.selection.setSelection(l,void 0,{noScroll:e==="next"})}else if(e4(n).indexOf(t)===-1){const c=et(s);p(CX,c,"block not found");const d=zo(c,s),h=lt(c,d.start,"normal");n.selection.setSelection(h,void 0,{noScroll:e==="next"})}if(n.focus(),e==="next"){const l=s.getBoundingClientRect(),c=n.scrollContainer.clientHeight;l.top>c/2&&ca(s,{elementToScroll:n.scrollContainer,verticalOffset:-n.scrollContainer.clientHeight/2})}}}}const qct="";I("comment-editor");const{t:EX}=D,WE="comment-editor-readonly",vf="comment-editor-editing";class qE{constructor(t,e,r){m(this,"root");m(this,"components");m(this,"handleEditorBlur",()=>{this.inactiveEditor()});m(this,"handleEditorFocus",()=>{this.editor.readonly||this.activeEditor()});m(this,"activeEditor",()=>{Rt(this.root,vf)||z(this.root,vf)});m(this,"inactiveEditor",()=>{ot(this.root,vf)});m(this,"handleInsertImg",async()=>{const{editor:t}=this.components,e=ft(t.rootContainer),r=await ha("image/*",{}),i={src:"",widthPercent:50},o={id:Z(),type:"embed",embedType:"image",embedData:i},s=t.options.componentsOptions.image;s!=null&&s.defaultAlign&&(o.align=s.defaultAlign);const l=t.getFocusedBlock(),c=t.getBlockIndex(l),d=t.insertBlock(e,c+1,o);Le.getImageObject(t,d).replaceImage(0,r)});m(this,"handleReadonlyChange",t=>{t.readonly?(ot(this.root,vf),z(this.root,WE)):(z(this.root,vf),ot(this.root,WE))});m(this,"setDoc",t=>{const{components:{editor:e}}=this;e.doc.externalDoc.setDoc(t)});m(this,"getDoc",()=>{const{components:{editor:t}}=this;return t.doc.toJSON()});m(this,"isEmpty",()=>P1(this.getDoc()));m(this,"edit",()=>{const{editor:t}=this.components;t.readonly=!1,fp(t),this.activeEditor()});m(this,"clear",()=>{const t=eo();this.setDoc(t)});m(this,"readonly",()=>{const{editor:t}=this.components;t.readonly=!0});m(this,"destroy",()=>{const{root:t,components:{editor:e,insertImgButton:r}}=this;r.onclick=null,e.destroy(),t.remove()});this.mainEditor=t,this.commentsProvider=e,this.doc=r,this.root=B("div",["comment-editor",WE],null),this.components=this.createEditor()}createEditor(){const t=B("div",["comment-editor-root"],this.root),{commentsProvider:e,mainEditor:r}=this,i=e.createCommentEditor(t,new bp(this.doc));i.readonly=!0,i.addListener("readonlyChanged",this.handleReadonlyChange),i.addListener("focus",this.handleEditorFocus),i.addListener("blur",this.handleEditorBlur);const o=hl(this.root,"comment-editor-img",EX("comment.image"),TT,void 0,r.clientId);return o.classList.add("comment-editor-img"),o.onclick=this.handleInsertImg,{editor:i,insertImgButton:o}}get editor(){return this.components.editor}}class xX{constructor(t){m(this,"handleBeforeKeyDown",(t,e)=>{if(ai(e,"Enter")){const{quickReply:r,updateLastCommentItem:i}=this.groupItem;return r.getReplyEditor().isEmpty()?(r.hideReplyEditor(),!0):(r.reply(),i(),!0)}return!1});this.groupItem=t}}class AX{constructor(t,e,r){m(this,"handleBeforeKeyDown",(t,e)=>{if(ai(e,"Enter")){const{quickReply:r}=this.groupItem,{comment:i,getCommentEditor:o}=this.commentItem,s=o();if(s.isEmpty())this.commentsProvider.localDeleteComment(i.id);else{const l=s.getDoc();this.commentsProvider.localUpdateComment(i,l),s.readonly()}return r.show(),!0}return!1});this.commentsProvider=t,this.groupItem=e,this.commentItem=r}}const bX=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
725
725
|
<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>
|
|
726
726
|
</svg>`,vX=`<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
727
727
|
<path d="M2 4V11C2 11.5523 2.44772 12 3 12H10L12.5528 13.2764C13.2177 13.6088 14 13.1253 14 12.382V4C14 3.44772 13.5523 3 13 3H3C2.44772 3 2 3.44772 2 4Z" stroke="currentColor"/>
|
|
@@ -959,4 +959,4 @@ ${o.mermaidText}
|
|
|
959
959
|
${o.flowchartText}
|
|
960
960
|
\`\`\`\`\`\``}return""}const itt={embedType:"flowchart",convertFrom:ett,handleUpdateBlock:ttt,createEmbedContent:ZZ,getBlockProperties:ntt,convertTo:rtt},ott=I("plantuml-helper");function xS(n,t){var l;let r=((l=(n.getComponentOptions("plantuml")||{}).cdn)==null?void 0:l.plantuml)||OZ;r.endsWith("/")||(r+="/");const i=n9.default.encode(t);p(ott,i,i),r+=i;const s=new URLSearchParams(document.location.search).get("doc");return Ng(r,{id:`${s}-${Z()}`})}async function stt(n,t){try{const e=await dx(n,t);return(await n.doc.uploadResource(e)).resourceId}catch{return Promise.resolve(t)}}class xc extends px{constructor(t){super(t,"plantuml","plantumlText")}static get(t,e){return t.addCustom(`plantuml-${e.id}`,()=>new xc(t))}code2ObjectUrl(t){return Promise.resolve(xS(this.editor,t))}code2ResourceId(t){const e=xS(this.editor,t);return stt(this.editor,e)}destroy(){}}function ltt(n,t,e){xc.get(n,e).createEmbedContent(t,e)}function att(n,t,e){const r=xc.get(n,e),i=Ot(t);return r.updateEmbedContent(i,e),!0}function ctt(n,t,e){const{data:r}=e,i=n.getBlockString(t).trim();if(!r||r.embedType!=="plantuml"||i!=="```plantuml"||!nt(n,t))return null;const o={src:"",plantumlText:""};return{blockData:{id:Z(),type:"embed",embedType:"plantuml",embedData:o},onConverted:(c,d)=>{xc.get(c,c.getBlockData(d)).editGraph(Ot(d))}}}function utt(n,t){return xc.get(n,n.getBlockData(t)).getBlockProperties(t)}function ftt(n,t,e,r){const{embedData:i}=t,o=i;if(r==="html")return o.src?`<img src="${n.doc.buildResourceUrl(o.src,{withToken:!0})}" />`:o.flowchartText?`<div>${o.flowchartText}</div>`:"<p>[plantuml]</p>";if(r==="markdown"){if(o.src)return`})`;if(o.flowchartText)return`\`\`\`plantuml\`\`\`
|
|
961
961
|
${o.flowchartText}
|
|
962
|
-
\`\`\`\`\`\``}return""}const dtt={embedType:"plantuml",convertFrom:ctt,handleUpdateBlock:att,createEmbedContent:ltt,getBlockProperties:utt,convertTo:ftt},Eut="",htt="hr",mtt={dividingLine:{type:"\u5206\u5272\u7EBF",abstract:"\u5206\u5272\u7EBF"}},gtt={dividingLine:{type:"Dividing-Line",abstract:"Dividing-Line"}},ptt={dividingLine:{type:"\u533A\u5207\u308A\u7DDA",abstract:"\u533A\u5207\u308A\u7DDA"}};D.mergeLang({"zh-CN":mtt,"en-US":gtt,"ja-JP":ptt});function Ctt(n,t){const e=B("div",["editor-embed-container"],t);B("hr",["editor-embed-hr"],e)}function Ett(n,t,e,r){return r==="html"?"<hr />":r==="markdown"?"---":"------------"}function xtt(){return{name:"hr",insertEmbedCommandItems:[{id:"insert-hr",name:D.t("dividingLine.type"),icon:VT,order:500,group:"common",subText:Bn("insert-hr")}],handleInsertEmptyEmbed:async(n,t)=>{const{containerId:e,blockIndex:r}=t;return n.insertEmbed(e,r,htt,{})}}}function Att(n,t,e){const{data:r}=e;if(!r||r.embedType!=="dividing-line"||!nt(n,t))return null;const i={};return{blockData:{id:Z(),type:"embed",embedType:"hr",embedData:i}}}function btt(){return{abstract:D.t("dividingLine.abstract")}}const vtt={embedType:"hr",createEmbedContent:Ctt,convertTo:Ett,getOptions:xtt,convertFrom:Att,getBlockProperties:btt},xut="",Aut="",Btt={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>',maxSizeFailed:'<div class="line-1">{name}\u4E0A\u4F20\u5931\u8D25</div><div class="line-2">\u6587\u4EF6\u5927\u5C0F\u8D85\u8FC7\u9650\u5236\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6</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"}}},Ttt={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>',maxSizeFailed:'<div class="line-1">{name} upload failed</div><div class="line-2">The file size exceeds limit. Please choose another file.</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"}}},ytt={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>',maxSizeFailed:'<div class="line-1">{name}\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F</div><div class="line-2">\u30D5\u30A1\u30A4\u30EB\u306E\u30B5\u30A4\u30BA\u304C\u4E0A\u9650\u3092\u8D85\u3048\u3066\u3044\u308B\u305F\u3081\u3001\u4ED6\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044</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"}}};D.mergeLang({"zh-CN":Btt,"en-US":Ttt,"ja-JP":ytt});var Yr=(n=>(n.AUDIO="audio",n.VIDEO="video",n))(Yr||{}),wf=(n=>(n.Empty="empty",n.Progress="progress",n.Error="error",n))(wf||{});const AS=10*1024*1024,ktt=["wav","mp3","aac","ogg","webm","flac"],Rtt=["ogg","mp4","webm"],wtt=()=>{};function bS(n){var h,C,E,A,v,R;const t=(h=n.getComponentOptions("media"))!=null?h:{},{allowedMedias:e,maxSize:r,callbacks:i}=t,o=(C=e==null?void 0:e.audio)!=null?C:ktt,s=(E=e==null?void 0:e.video)!=null?E:Rtt,l=(A=r==null?void 0:r.audio)!=null?A:AS,c=(v=r==null?void 0:r.video)!=null?v:AS,d=(R=i==null?void 0:i.onError)!=null?R:wtt;return{allowedMedias:{audio:o,video:s},maxSize:{audio:l,video:c},callbacks:{onError:d}}}function Stt(n,t){const e=o=>o.map(s=>`.${s}`).join(","),{allowedMedias:r}=bS(n),i=r[t];return i?e(i):"*"}function Ltt(n,t,e){const{maxSize:r,callbacks:i,allowedMedias:o}=bS(t),{[e]:s}=r,{[e]:l}=o;if(s&&n.size>s){const d=new Error("media is too large");throw d.code=`MaxMediaSize-${e}`,i!=null&&i.onError&&(i==null||i.onError(t,d)),d}const c=eu(n.name);if(l&&!l.includes(c.toLowerCase())){const d=new Error(`media file is not allowed: ${c}`);throw d.code="NotAllowedFile",i!=null&&i.onError&&(i==null||i.onError(t,d)),d}}function Itt(n){return n===wf.Empty||n===wf.Error}const Ye=I("media");class Dtt extends Re.TypedEmitter{constructor(e){super();m(this,"mediaContainer",null);m(this,"media",null);m(this,"abstract",null);m(this,"handleMediaLoadError",(e,r)=>{if(!r.target||!(r.target instanceof Node)||!(r.target instanceof Element?r.target:r.target.parentElement))return;const o=et(r.target);if(!o||!o.contains(this.mediaContainer))return;const s=this.renderError();this.updateMediaContent(s),this.emit("mediaError",e,"load_error",st(o))});m(this,"handleUploadFile",async e=>{p(Ye,this.abstract,"no abstract"),p(Ye,this.mediaContainer,"The media element not exist");const{editor:r}=this.options,i=et(this.mediaContainer);p(Ye,i,"The block element not exist");const o=r.getBlockData(i);try{const{resourceId:s}=await r.doc.uploadResource(e,{onProgress:C=>{this.renderProgress(C,e)}}),{name:l,type:c,size:d}=e,h={...o,embedData:{...o.embedData,src:s,fileName:l,fileSize:d,fileType:c}};r.updateBlockData(i,h)}catch(s){Ye.error(s),this.emit("mediaError",r,"upload_error",o.id),this.renderRetry(e,s)}ot(i,"media-block-uploading")});m(this,"destroy",()=>{this.mediaContainer=null});this.options=e}bindMediaEvent(){const{editor:e}=this.options;this.media&&e.domEvents.addEventListener(this.media,"error",this.handleMediaLoadError)}unbindMediaEvent(){const{editor:e}=this.options;this.media&&e.domEvents.removeEventListener(this.media,"error",this.handleMediaLoadError)}updateMediaContent(e){p(Ye,this.mediaContainer,"The media element not exist"),this.mediaContainer.innerHTML="",this.mediaContainer.append(e)}renderError(){p(Ye,this.abstract,"no abstract");const{editor:e,createMediaElement:r}=this.options,{mediaIcon:i,mediaName:o}=this.abstract;p(Ye,this.mediaContainer,"The media element not exist");const s=et(this.mediaContainer);p(Ye,s,"The block element not exist");const l=e.getBlockData(s),c=l.embedData.src,d=B("div",["media-error","embed-selected-content","embed-hover-content"],null),h=B("span",["media-error-icon"],d);h.innerHTML=i;const C=B("div",[],d);C.innerHTML=D.t("media.load.failed",{name:o}),d.appendChild(C);const E=C.querySelector(".retry-upload");return p(Ye,E,"The element not exist"),e.domEvents.addEventListener(E,"click",(A,v)=>{const R=B("div",["media-element"],null),L=this.getResourceUrl(c),M=r(A,R,l,L);this.unbindMediaEvent(),this.media=M,this.bindMediaEvent(),this.updateMediaContent(R)}),this.setFullScreen(),d}renderRetry(e,r){var E,A;p(Ye,this.abstract,"no abstract");const{editor:i}=this.options,{mediaIcon:o,mediaName:s}=this.abstract,l=B("div",["media-error","embed-selected-content","embed-hover-content"],null),c=B("span",["media-error-icon"],l);c.innerHTML=o;const d=B("div",[],l);let h=D.t("media.upload.failed",{name:s});(((E=r.response)==null?void 0:E.status)===420||((A=r.response)==null?void 0:A.status)===413)&&(h=D.t("media.upload.maxSizeFailed",{name:s})),d.innerHTML=h,l.appendChild(d);const C=d.querySelector(".retry-upload");C&&i.domEvents.addEventListener(C,"click",()=>{i.readonly||(p(Ye,this.abstract,"no abstract"),this.handleUploadFile(e))}),this.updateMediaContent(l),this.setFullScreen()}renderProgress(e,r){p(Ye,this.mediaContainer,"The media element not exist");const i=this.mediaContainer.querySelector(":scope .media-progress"),o=e===-1||e===100?100:e;if(i){const{updateProgressElement:s}=this.options;s(i,o)}else{const{createProgressElement:s}=this.options,l=et(this.mediaContainer);p(Ye,l,"The element not exist"),z(l,"media-block-uploading");const c=B("div",["media-progress"],null);s(c,o,r),this.updateMediaContent(c)}this.setFullScreen()}renderMediaElement(e){p(Ye,this.mediaContainer,"The media element not exist");const r=this.mediaContainer.querySelector(":scope > .media-element"),{createMediaElement:i,updateMediaElement:o,editor:s}=this.options,l=this.getResourceUrl(e.embedData.src);if(r){const c=o(s,r,e,l);this.unbindMediaEvent(),this.media=c,this.bindMediaEvent()}else{const c=B("div",["media-element"],null),d=i(s,c,e,l);this.unbindMediaEvent(),this.media=d,this.bindMediaEvent(),this.updateMediaContent(c)}}renderEmpty(e){p(Ye,this.abstract,"no abstract"),p(Ye,this.mediaContainer,"The media element not exist");const r=B("div",["media-empty","embed-selected-content","embed-hover-content"],this.mediaContainer);r.innerHTML=this.abstract.mediaIcon,this.updateMediaContent(r);const{editor:i}=this.options;i.findBlockById(e.id)&&this.emit("mediaError",i,"empty",e.id),this.setFullScreen()}getResourceUrl(e){const{editor:r}=this.options;return r.doc.buildResourceUrl(e)}setFullScreen(){p(Ye,this.mediaContainer,"The media element not exist"),z(this.mediaContainer,"full-screen")}removeFullScreen(){p(Ye,this.mediaContainer,"The media element not exist"),ot(this.mediaContainer,"full-screen")}updateBlockAlign(e,r){const i=et(r);p(Ye,i,"The block element not exist");const{align:o}=e;e.embedType==="video"&&(i.hasAttribute("data-style-align")&&i.removeAttribute("data-style-align"),i.setAttribute("data-style-align",o))}render(e,r){const{src:i}=e.embedData;(!this.mediaContainer||!r.contains(this.mediaContainer))&&(this.mediaContainer=B("div",["media"],r)),this.updateBlockAlign(e,r),Itt(i)?i===wf.Empty&&this.renderEmpty(e):this.renderMediaElement(e)}setAbstract(e){this.abstract=e}}I("media-embed");const _tt="left";class vS{constructor(){m(this,"handleInsertEmptyEmbed",async(t,e)=>{var C;const{containerId:r,blockIndex:i}=e;let o;(C=e.data)!=null&&C.file&&(o=e.data.file);const s=Stt(t,this.embedType);if(o=o!=null?o:await ha(s,{}),!o)return null;const{mediaType:l}=this.getAbstract();try{Ltt(o,t,l)}catch{return null}const c={id:Z(),type:"embed",embedType:this.embedType,embedData:{src:wf.Empty}};l==="video"&&(c.align=_tt);const d=t.insertBlock(r,i,c);return await this.getMedia(t,c.id).handleUploadFile(o),d})}getMedia(t,e){const r=t.addCustom(`media-${e}`,()=>new Dtt({editor:t,createMediaElement:this.createMediaElement,updateMediaElement:this.updateMediaElement,createProgressElement:this.createProgressElement,updateProgressElement:this.updateProgressElement}));return r.setAbstract({...this.getAbstract()}),r}getOptions(){const{menuItem:t,mediaIcon:e,mediaName:r,order:i,group:o}=this.getAbstract();return{name:r,insertEmbedCommandItems:[{id:`insert-${this.embedType}`,name:t,icon:e,order:i,group:o,subText:Bn(`insert-${this.embedType}`)}],handleInsertEmptyEmbed:this.handleInsertEmptyEmbed}}createEmbedContent(t,e,r){const{id:i}=r;this.getMedia(t,i).render(r,e)}handleUpdateBlock(t,e,r){const{id:i}=r,o=this.getMedia(t,i),s=Ot(e);return o.render(r,s),!0}handleDeleteBlock(t,e){const r=e.id,i=this.getMedia(t,r);i.removeAllListeners(),i.destroy()}convertTo(t,e,r,i){const o=e.embedData,s=t.doc.buildResourceUrl(o.src,{withToken:!0});return i==="html"?`<${o.type} src="${s}" />`:i==="markdown"?``:s}}function BS(n,t){const e=B("div",["uploading-progress-mask"],n),r=B("div",["uploading-progress-bar"],e),i=B("div",["uploading-progress-bar-value"],r);i.style.width=`${t}%`}function TS(n,t){const e=n.querySelector(".uploading-progress-bar-value");e&&(e.style.width=`${t}%`)}const Mtt=I("media-audio");class Utt extends vS{constructor(){super(...arguments);m(this,"embedType",Yr.AUDIO);m(this,"updateProgressElement",TS);m(this,"createMediaElement",(e,r,i,o)=>{const s=B("div",["audio-container","embed-hover-content","embed-selected-content"],r),l=B("audio",[],s);return l.innerHTML="Your browser does not support the <code>audio</code> element.",l.controls=!0,l.src=o,setTimeout(()=>{this.getMedia(e,i.id).setFullScreen()}),l})}getAbstract(){return{mediaIcon:PT,mediaName:D.t(`media.${Yr.AUDIO}.menuItem`),menuItem:D.t(`media.${Yr.AUDIO}.menuItem`),order:800,mediaType:Yr.AUDIO,group:"common"}}getBlockProperties(){return{abstract:`${D.t(`media.${Yr.AUDIO}.abstract`)}`}}updateMediaElement(e,r,i,o){const s=r.querySelector(":scope .audio-container > audio");return p(Mtt,s,"The media element not exist"),s.src!==o&&(s.src=o),s}createProgressElement(e,r){const i=B("audio",[],e);i.innerHTML="Your browser does not support the <code>audio</code> element.",i.controls=!0,i.src="about:blank",BS(e,r)}}const Ott=new Utt;I("video-resizer");function yS(n){return n&&pe(n)&&Ge(n)==="video"}const Ntt=50;class Cx{constructor(t){m(this,"currentResizableElement",null);m(this,"resizing",!1);m(this,"handleHoveringBlockChange",(t,e)=>{if(!this.resizing&&!window.isDragging&&(e&&yS(e)&&this.disableBlockResize(e),t&&yS(t)&&this.editor.isBlockWritable(t))){const r=this.getVideoElement(t);if(!r)return;this.enableBlockResize(t,r)}});m(this,"handleResizing",(t,e)=>{if(this.resizing=!0,!this.currentResizableElement)return;const r=t.getBlock();if(!r)return;const i=r.getBoundingClientRect().width,o=Math.min(Math.max(e.width,Ntt),i);this.currentResizableElement.style.width=`${o}px`,this.currentResizableElement.style.pointerEvents="none"});m(this,"handleResized",t=>{this.resizing=!1;const e=t.getBlock();if(!this.currentResizableElement||!e)return;const r=this.editor.getBlockData(e),{width:i}=this.currentResizableElement.getBoundingClientRect();this.currentResizableElement.style.pointerEvents="auto",this.editor.updateBlockData(e,{...r,width:i})});this.editor=t,Be.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){this.currentResizableElement=null,Be.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}getVideoElement(t){return Ot(t).querySelector(":scope .video-container > video")}updateResizer(t){const e=this.editor.findCustom(`${st(t)}-resizer`);e&&e.updateResizer()}disableBlockResize(t){const e=this.editor.findCustom(`${st(t)}-resizer`);e&&e.disableResize()}enableBlockResize(t,e){const r=this.editor.addCustom(`${st(t)}-resizer`,()=>new lf(this.editor,{resize:["top-left","top-right","bottom-left","bottom-right"]}));r.enableResize(t,e),r.removeListener("resizing",this.handleResizing),r.removeListener("resized",this.handleResized),r.addListener("resizing",this.handleResizing),r.addListener("resized",this.handleResized),this.currentResizableElement=e}}const Ptt=I("video");class Ftt extends vS{constructor(){super(...arguments);m(this,"embedType",Yr.VIDEO);m(this,"updateProgressElement",TS);m(this,"createMediaElement",(e,r,i,o)=>{const s=B("div",["video-container","embed-selected-content","drag-preview-element"],r),l=B("video",[],s);return l.innerHTML="Your browser does not support the <code>video</code> element.",l.controls=!0,l.src=o,l.addEventListener("canplay",()=>{e.addCustom("video-resizer",()=>new Cx(e)),this.getMedia(e,i.id).removeListener("mediaError",this.handleMediaError),this.getMedia(e,i.id).addListener("mediaError",this.handleMediaError),this.getMedia(e,i.id).removeFullScreen()}),i.width&&(l.style.width=`${i.width}px`),l});m(this,"createProgressElement",(e,r,i)=>{const o=B("video",["progress-video"],e);o.innerHTML="Your browser does not support the <code>audio</code> element.",o.controls=!0,BS(e,r),fa(i).then(s=>{const l=e.querySelector(".progress-video");l&&Qg(e)&&(l.src=s)})})}getAbstract(){return{mediaName:D.t(`media.${Yr.VIDEO}.menuItem`),mediaIcon:FT,menuItem:D.t(`media.${Yr.VIDEO}.menuItem`),order:700,mediaType:Yr.VIDEO,group:"common"}}getBlockProperties(){return{abstract:`${D.t(`media.${Yr.VIDEO}.abstract`)}`}}handleMediaError(e,r,i){const o=e.addCustom("video-resizer",()=>new Cx(e)),s=e.getBlockById(i);o.disableBlockResize(s)}updateMediaElement(e,r,i,o){const s=r.querySelector(":scope .video-container > video");p(Ptt,s,"The media element not exist"),s.src!==o&&(s.src=o),i.width?s.style.width=`${i.width}px`:s.style.width="";const l=e.getBlockById(i.id);return setTimeout(()=>{e.addCustom("video-resizer",()=>new Cx(e)).updateResizer(l)}),s}}const Ktt=new Ftt,kS=[lE,mE,gE,wk],Ex=[gS,VJ,XZ,itt,dtt,e$,vtt,Ktt,Ott,oW,Y4,KQ],RS=[Vk,tS,T4,jk];function Vtt(n,t,e){var i,o,s,l;li.level=(i=e.logLevel)!=null?i:Ds.DEBUG;const r=ku(n,t,{components:{blocks:[...kS,...((o=e==null?void 0:e.components)==null?void 0:o.blocks)||[]],embeds:[...Ex,...((s=e.components)==null?void 0:s.embeds)||[]],boxes:[...RS,...((l=e.components)==null?void 0:l.boxes)||[]],textRenders:[new $C],options:{...e.componentsOptions}}});return r.readonly=!0,r.addCustom("heading-collapse",()=>new ox(r)),r.addCustom("editor-tooltip",()=>new _0(r)),r.addListener("clickLink",(c,d,h)=>{var E;if((E=e==null?void 0:e.events)!=null&&E.onClickLink){e.events.onClickLink(c,d,h);return}const C=h.getAttribute("link");C&&(c.readonly||d.ctrlKey||d.metaKey)&&window.open(C,"_blank")}),r}class wS{constructor(t){this.createOptions=t,t.lang&&D.setLang(t.lang)}createHistoryEditor(t,e){return Vtt(t,e,this.createOptions)}}I("create-editor");function SS(n,{root:t,childDoc:e,doc:r}){var h,C;e.uploadResource=r.uploadResource.bind(r),e.buildResourceUrl=r.buildResourceUrl.bind(r);const i=n.getComponentOptions("comment"),o={image:{defaultAlign:"left"},table:{locatingContainer:t,hideCellMenu:!0,hideToolbar:!0},...i==null?void 0:i.componentsOptions},s=[];n.editorBlocks.forEach(E=>{E.blockType==="text"||E.blockType==="embed"||s.push(E)});const l=[];n.editorEmbeds.forEach(E=>{l.push(E)});const c=[];n.editorBoxes.forEach(E=>{E.boxType==="text"||E.boxType==="br"||E.boxType==="image"||E.boxType==="anchor"||c.push(E)});const d=ku(t,e,{shortcuts:[_h],components:{blocks:s,commandProviders:[new d0],decorators:[new K0],embeds:l,boxes:c,options:o}});if(d.input.addHandler(new $0),d.input.addHandler(new ME(d)),d.input.addHandler(new KE(d)),d.input.addHandler(new QX(d)),d.input.addHandler(new G0),d.addCustom("image-paste-handler",()=>new _E(d)),(h=n.options.componentsOptions)!=null&&h.mention){const E=n.options.componentsOptions.mention;d.addCustom("mention",()=>new Z4(d,{...E}))}if((C=n.options.componentsOptions)!=null&&C.comment){const E=n.options.componentsOptions.comment;E.onCommentEditorClick&&d.addListener("click",E.onCommentEditorClick)}return d}function $tt(n,t){const e=Array.from(n.rootContainer.querySelectorAll(`[comment-${t.toLocaleLowerCase()}="${t}"]`)),r=new Set;e.forEach(i=>{const o=et(i);o&&r.add(o)}),r.forEach(i=>{YX(n,i,t)})}class Htt{constructor(t){m(this,"listeners",new Set);m(this,"doc");this.editor=t,this.doc=this.editor.doc.externalDoc,this.doc.registerCallback(this)}getComments(){return this.doc.getComments()}getComment(t){return this.doc.getComment(t)}getCommentDoc(t){return this.doc.getCommentDoc(t)}localCreateComment(t,e){this.doc.localCreateComment(t,e)}localDeleteComment(t){const e=this.getComment(t);this.doc.localDeleteComment(t);const r=e.groupId;this.getComments().filter(o=>o.groupId===r).length===0&&$tt(this.editor,r)}localUpdateComment(t,e){this.doc.localUpdateComment(t,e)}onCreateComment(t,e){Array.from(this.listeners.values()).forEach(r=>r.onCreateComment(t,e))}onDeleteComment(t,e){Array.from(this.listeners.values()).forEach(r=>r.onDeleteComment(t,e))}onUpdateComment(t,e){Array.from(this.listeners.values()).forEach(r=>r.onUpdateComment(t,e))}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}createCommentEditor(t,e){return SS(this.editor,{root:t,childDoc:e,doc:this.doc})}allowEdit(t){return t.userId===this.doc.getUser().userId}}class jtt{constructor(t,e){m(this,"listeners",new Set);this.editor=t,this.localDoc=e}get doc(){return this.localDoc.toJSON()}getComments(){return Object.values(this.doc.comments)}getComment(t){return this.doc.comments[t]}getCommentDoc(t){const e=this.doc.comments[t];return Kp(e)}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}localCreateComment(t,e){}localDeleteComment(t){}localUpdateComment(t,e){}createCommentEditor(t,e){return SS(this.editor,{root:t,childDoc:e,doc:this.localDoc})}allowEdit(t){return t.userId===this.localDoc.getUser().userId}}const ztt={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}"}},Gtt={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}"}},Wtt={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"}};D.mergeLang({"zh-CN":ztt,"en-US":Gtt,"ja-JP":Wtt});function qtt(n){const r=new DOMParser().parseFromString(n,"text/html").querySelector("svg");if(!r)return null;const i=r.getAttribute("viewBox");if(!i)return null;const o=i.split(" ");if(o.length===4){const s=o[2],l=o[3];return r.setAttribute("width",s),r.setAttribute("height",l),r.outerHTML}return null}function xx(n,t,e=!0){const r=new Image,i=document.createElement("canvas"),o=i.getContext("2d");if(!o){t(new Error("failed to get context"),null);return}r.onload=()=>{if(i.width=r.naturalWidth,i.height=r.naturalHeight,e&&(i.width===0||i.height===0)){const s=n.substring(26);if(s){const l=atob(s),c=qtt(l);if(c){Fg(c,"image/svg+xml").then(d=>{xx(d,t,!1)});return}}t(null,null);return}o.drawImage(r,0,0),i.toBlob(s=>{t(null,s)},"image/png")},r.src=n}function Xtt(n){return new Promise((t,e)=>{xx(n,(r,i)=>{if(r){e(r);return}if(!i){e(new Error("Failed to get image blob"));return}t(i)})})}async function LS(n){const t=await fa(n);return new Promise((e,r)=>{xx(t,(i,o)=>{if(i){r(i);return}if(!o){r(new Error("Failed to get image blob"));return}e(o)})})}const IS="Untitled";function DS(n){const t=we(n.rootContainer);return!t||!nt(n,t)?IS:n.getBlockString(t)||IS}function Qtt(n){let t;return n.forEach((e,r)=>{r.toLocaleLowerCase()==="content-type"&&(t=e)}),t!=null?t:""}async function _S(n){try{const t=await fetch(n,{credentials:"same-origin"}),e=await t.blob(),r=Qtt(t.headers).toLocaleLowerCase();let i="";if(r){const s=yg.default[r].extensions;s&&s.length>0&&(i=s[0])}return new File([e],`${Date.now()}.${i}`,{type:r})}catch{return null}}const Ytt="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=",Jtt=()=>Pg(Ytt);async function Ztt(n){return new Promise((t,e)=>{const r=new Image;r.onload=()=>{t({width:r.naturalWidth,height:r.naturalHeight})},r.onerror=e,r.src=n})}async function MS(n,t){if(n.width&&n.height)return{width:n.width,height:n.height,buffer:t};const e=await fa(new File([t],"",{})),r=await Ztt(e);return r.width===void 0||r.height===void 0?{width:345,height:230,buffer:t}:n.width||n.height?{width:n.width||r.width*n.height/r.height,height:n.height||r.height*n.width/r.width,buffer:t}:{width:r.width,height:r.height,buffer:t}}function tet(n,t){let e=n.filter(s=>s!=null);const r=t-(e.length-1)*20,i=.87,o=e.reduce((s,l)=>s+l.width,0);return o>r&&(e=e.map(s=>({width:s.width*r/o,height:s.height*r/o,buffer:s.buffer}))),e.map(s=>({width:s.width*i,height:s.height*i,buffer:s.buffer}))}function eet(n,t,e){if(!e||typeof e!="object")return;const r=e,i=n.filter(s=>s!=null),o=t-(i.length-1)*20;i.forEach((s,l)=>{if(i.length===1&&r.widthPercent){const d=r.widthPercent,h=s.width;s.width=o*(d/100),s.height*=s.width/h;return}const c=`${l}_flex`;if(r[c]){const d=r[c],h=s.width;s.width=o*d,s.height*=s.width/h}})}function US(n=[0,1,2,3,4,5,6,7],t=1){return n.map(e=>{let r;switch(e%3){case 0:r=pt.LevelFormat.DECIMAL;break;case 1:r=pt.LevelFormat.LOWER_LETTER;break;default:r=pt.LevelFormat.LOWER_ROMAN;break}return{level:e,format:r,text:`%${e+1}. `,alignment:pt.AlignmentType.START,start:t,style:{paragraph:{indent:{left:pt.convertInchesToTwip(.3*(e+1)),hanging:pt.convertInchesToTwip(.2)}}}}})}function net(){return[0,1,2,3,4,5,6,7].map(n=>{let t;switch(n%3){case 0:t="\u2022";break;case 1:t="\u25E6";break;default:t="\u25AA";break}return{level:n,format:pt.LevelFormat.BULLET,text:t,alignment:pt.AlignmentType.START,style:{paragraph:{indent:{left:pt.convertInchesToTwip(.3*(n+1)),hanging:pt.convertInchesToTwip(.2)}}}}})}function ret(){return[0,1,2,3,4,5,6,7].map(n=>({level:n,format:pt.LevelFormat.BULLET,text:"\u2611",alignment:pt.AlignmentType.START,style:{paragraph:{indent:{left:pt.convertInchesToTwip(.3*(n+1)),hanging:pt.convertInchesToTwip(.2)}}}}))}function iet(){return[0,1,2,3,4,5,6,7].map(n=>({level:n,format:pt.LevelFormat.BULLET,text:"\u2610",alignment:pt.AlignmentType.START,style:{paragraph:{indent:{left:pt.convertInchesToTwip(.3*(n+1)),hanging:pt.convertInchesToTwip(.2)}}}}))}var Sf=(n=>(n.NUMBERING="number-numbering-reference",n.BULLET="number-bullet-reference",n.CHECKED="checked-bullet-reference",n.UNCHECKED="unchecked-bullet-reference",n))(Sf||{});const oet=[{levels:US(),reference:"number-numbering-reference"},{levels:net(),reference:"number-bullet-reference"},{levels:ret(),reference:"checked-bullet-reference"},{levels:iet(),reference:"unchecked-bullet-reference"}];function set(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 aet(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 cet(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 uet=/rgb\((\d+),\s*(\d+),\s*(\d+)\)/;function OS(n){if(typeof n=="string"&&n.length>0){if(n[0]==="#")return n.substring(1);const t=n.match(uet);if(t){const e=s=>{let l=Number(s).toString(16);return l.length<2&&(l=`0${l}`),l},r=e(t[1]),i=e(t[2]),o=e(t[3]);return`${r}${i}${o}`}if(n==="red")return"FF0000";if(n==="green")return"00FF00";if(n==="blue")return"0000FF"}}function sn(n,t){if(n&&n.attributes&&n.attributes[t])return n.attributes[t];if(n&&n.attributes&&n.attributes.box&&n.attributes.inputType&&t==="style-underline")return!0}function NS(n,t,e){for(let r=0;r<=e;++r){const i=`${t}${r}`;if(sn(n,i))return i}}function mm(n,t,e){n.attributes=n.attributes||{},n.attributes[t]=e}function Ax(n){return n==="image"||n==="drawio"||n==="plantuml"||n==="mermaid"||n==="flowchart"}function PS(n){return n&&n.startsWith("//")?`https:${n}`:n&&!n.startsWith("http://")&&!n.startsWith("https://")?`https://${n}`:n}function fet(n){const t=sn(n,"inlineStyle");if(t==null)return;const e=t.split(";");for(const r of e){const i=r.split(":");if(i.length!==2)continue;const o=i[0].trim().toLowerCase(),s=i[1].trim().toLowerCase();o==="font-size"&&mm(n,"inline-style-font-size",s),o==="color"&&mm(n,"inline-style-color",s),o==="background-color"&&mm(n,"inline-style-background-color",s),o==="font-family"&&mm(n,"inline-style-font-family",s)}}function det(n,t){if(t==null)return n==null?void 0:n.normal;if(n)return n[`heading${t}`]}function het(n){const t=`${sn(n,"inline-style-font-size")}`;if(t&&t.indexOf("px")>0)return+t.replace(/px/g,"")}function met(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 get(n){if(n.attributes&&n.attributes.box&&n.attributes.text)return` @${n.attributes.text} `}function pet(n){return sn(n,"inline-style-font-family")}function Cet(n){const t=sn(n,"inline-style-background-color");return OS(t)}function Eet(n){const t=sn(n,"inline-style-color");return OS(t)}function xet(n){fet(n);const t=sn(n,"type")==="mention";return{box:n.attributes&&n.attributes.box?n.attributes:void 0,inlineCode:!!sn(n,"style-code"),link:PS(sn(n,"link")),size:het(n),text:t?get(n):met(n)||n.insert,bold:!!sn(n,"style-bold"),underline:!!sn(n,"style-underline"),italics:!!sn(n,"style-italic"),strike:!!sn(n,"style-strikethrough"),superScript:!!sn(n,"style-super"),subScript:!!sn(n,"style-sub"),math:sn(n,"type")==="math"?sn(n,"src"):void 0,mention:t,fontFamily:pet(n),background:Cet(n),color:t?"338fe5":set(NS(n,"style-color-",6))||Eet(n),highlight:NS(n,"style-bg-color-",13)}}function Aet(){return[new pt.Paragraph({border:{top:{color:"auto",style:pt.BorderStyle.DASHED,size:4,space:1}},spacing:{before:300}}),new pt.Paragraph({spacing:{line:0}})]}function bet(){return new pt.Paragraph({children:[new pt.TextRun({text:"[\u89C6\u9891\u6682\u4E0D\u652F\u6301\u5BFC\u51FA]",shading:{type:pt.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}})]})}function vet(){return new pt.Paragraph({children:[new pt.TextRun({text:"[\u97F3\u9891\u6682\u4E0D\u652F\u6301\u5BFC\u51FA]",shading:{type:pt.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}})]})}function Bet(n,t){return new pt.Paragraph({children:[new pt.ExternalHyperlink({children:[new pt.TextRun({style:"Hyperlink",text:t||n})],link:n})]})}function FS(n){if(n.heading!=null)return`Heading${n.heading}`}function KS(n){if(n.alignment!=null){if(n.alignment==="center")return pt.AlignmentType.CENTER;if(n.alignment==="right")return pt.AlignmentType.RIGHT;if(n.alignment==="left")return pt.AlignmentType.LEFT}}function Tet(n){if(n.indent)return{left:pt.convertInchesToTwip(.3*n.indent-.2)};if(n.padding)return{left:pt.convertInchesToTwip(.3*n.padding)}}function yet(n){return{type:pt.ShadingType.CLEAR,color:"FFFFFF",fill:n}}function ket(n){const t=n.split(",");if(t.length!==0)return t[0].trim()}function VS(n,t){let e;e=n.inlineCode?"InlineCode":void 0,e=n.link?"Hyperlink":e;const r=n.size||t,i=r!=null?Math.floor(r*1.5+.5):void 0;return new pt.TextRun({text:n.text,bold:n.bold||void 0,underline:n.underline?{type:pt.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:i,style:e,font:n.fontFamily?ket(n.fontFamily):void 0,shading:n.background?yet(n.background):void 0,color:n.color,highlight:aet(n.highlight)})}function Ret(n,t){if(n.link)return new pt.ExternalHyperlink({children:[VS(n,t)],link:n.link})}async function $S(n,t,e,r,i){const o=await i(n,t,e);if(o==null)return;const s=await MS({width:r||0,height:0,src:e},o);return new pt.ImageRun({data:o,transformation:{width:s.width||100,height:s.height||20}})}function wet(n){if(n.heading||n.heading)return n.heading}function Let(n){if(n.align&&(n.align==="center"||n.align==="right"||n.align==="left"))return n.align}function Iet(n){if(n.textOnly===!0&&n.level!=null)return n.level}async function Det(n,t){var r;const e=[];if(n.text&&Array.isArray(n.text)){for(let i=0;i<n.text.length;i++){const o=n.text[i];if(((r=o.attributes)==null?void 0:r.box)===!0&&t){const s=await t(o);if(s){n.text.splice(i+1,0,...s);continue}}e.push(xet(o))}return e}}function _et(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 Met(n,t){if(n.type==="embed"&&n.embedType&&Ax(n.embedType)&&n.embedData&&n.embedData.src)return n.embedData.src.split("|").map(r=>{const i=t(r),o=n.embedData[`${i}_width`],s=n.embedData[`${i}_height`];return{src:r,width:o,height:s}})}function Uet(n){if(n.padding)return n.padding}function Oet(n){return!!(n.type==="embed"&&n.embedType&&Ax(n.embedType)&&n.embedData&&n.embedData.src)}async function gm(n,t,e){return{quoted:!!n.quoted,heading:wet(n),alignment:Let(n),indent:Iet(n),padding:Uet(n),texts:await Det(n,e),list:_et(n),images:Met(n,t),border:Oet(n)}}async function Net(n,t,e,r){const i=[];if(!n.children)return[];for(const o of n.children){const s=[];for(const l of t.blocks[o])s.push(await gm(l,e,r));i.push(s)}return i}const Pet=I("to-docx");function Fet(n,t){return Array(n).fill(0).map(()=>Array(t).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 Ket(n,t,e,r){const i=!!n.hasColTitle,o=!!n.hasRowTitle,s=!!n.isStripeStyle,l="F5F8FB";for(let c=0;c<t;c++)for(let d=0;d<e;d++)(i&&d===0||o&&c===0||s&&c%2===1)&&(r[c][d].color=l)}function Vet(n){p(Pet,n.children,"no table children");const t=n.rows,e=n.cols,r=n.colsWidth;if(r)for(let s=0;s<r.length;s++)r[s]===0&&(r[s]=100);const i=Fet(t,e);let o=0;for(let s=0;s<t;++s)for(let l=0;l<e;++l){if(i[s][l].originalWidth=r?r[l]:void 0,i[s][l].from!==void 0)continue;const c=n.children[o];o+=1,i[s][l].cellId=c,i[s][l].color=cet(n[`${c}_background`]),i[s][l].width=r?r[l]:100,i[s][l].align=n[`${c}_align`];const d=n[`${c}_rowSpan`]||1,h=n[`${c}_colSpan`]||1;if(i[s][l].rowSpan=d,i[s][l].colSpan=h,d>1||h>1){let C=0;for(let E=0;E<d;E++)for(let A=0;A<h;A++)E===0&&(C+=r?r[l+A]:80),!(E===0&&A===0)&&(i[s+E][l+A].from=[s,l]);i[s][l].width=C}}return Ket(n,t,e,i),i}async function $et(n,t,e,r,i,o,s,l,c,d){async function h(A){if(l){const v=await l(i,o,A);if(v){await r.addDoc(n,v,d);return}}if(A.type==="text"||A.textOnly===!0){const v=await gm(A,s,c);await r.addTextBlock(v);return}if(A.type==="code"){const v=await Net(A,e,s,c);await r.addCodeBlockObject(v);return}if(A.type==="list"&&A.textOnly!==!0){const v=await gm(A,s,c);await r.addListBlockObject(n,v);return}if(A.type==="embed"&&A.embedType){const v=A,R=v.embedData,L=v.embedType;if(Ax(L)){const M=await gm(A,s,c);await r.addImagesBlockObject(A,M,d)}else A.embedType==="hr"?r.addSeparatorBlock():A.embedType==="video"?r.addVideoPlaceholder():A.embedType==="audio"?r.addAudioPlaceholder():A.embedType==="webpage"?r.addHyperlinkParagraph(PS(R.src),R.title):r.addOtherEmbedBlock(L,A.embedData);return}if(A.type==="table"){let v=[];if(A.colsWidth)v=A.colsWidth;else{const L=A.cols;v=new Array(L);for(let M=0;M<v.length;M++)v[M]=100;A.colsWidth=v}const R=Vet(A);await r.addTableMatrix(v,R,e),r.addEmptyParagraph()}}function C(A){const v=[];for(const{type:R,data:L}of A.embedData.exportSpec){if(R==="text"){const M={id:Z(),text:[{insert:L}],type:"text"};v.push(M);continue}if(R==="image"){const M={id:Z(),type:"embed",embedType:"image",align:"left",embedData:{src:L}};v.push(M);continue}if(R==="link"){const M={id:Z(),type:"embed",embedType:"webpage",embedData:{src:L.url,title:L.title}};v.push(M);continue}}return v}function E(A){var v;return(v=A==null?void 0:A.embedData)!=null&&v.exportSpec?C(A):[A]}for(const A of t)for(const v of E(A))await h(v)}function Het(){return{listMaxInst:1,listInstMap:{},listRefMap:{},levelConfigs:[]}}const jet=I("to-docx");class zet{constructor(t,e,r,i,o,s){m(this,"paragraphs");this.appId=t,this.docId=e,this.state=r,this.readImageFunc=i,this.convertBlocksFunc=o,this.defaultFontSize=s,this.paragraphs=[]}async addTextBlock(t){this.paragraphs.push(new pt.Paragraph({heading:FS(t),alignment:KS(t),children:await this.paragraphsFromBlockTexts(t),indent:Tet(t)}))}async addEmptyImagePlaceHolder(){this.paragraphs.push(new pt.Paragraph({text:`[${D.t("docx.imageExportFailed")}]`,shading:{type:pt.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}}))}async paragraphsFromBlockTexts(t){if(t.texts==null)return;const e=det(this.defaultFontSize,t.heading),r=[];for(const i of t.texts){if(i.link){const o=Ret(i,e);o&&r.push(o);continue}if(i.box&&i.box.type&&i.box.type==="br"){r.push(new pt.TextRun({text:"",break:1}));continue}if(i.box&&i.box.type&&i.box.type==="image"){const o=await $S(this.appId,this.docId,i.box.src,i.box.width,this.readImageFunc);o&&r.push(o);continue}if(i.math){const o=await $S(this.appId,this.docId,i.math,0,this.readImageFunc);o&&r.push(o);continue}r.push(VS(i,e))}return r}async addCodeBlockObject(t){for(const e of t)for(const r of e){const i={style:pt.BorderStyle.SINGLE,color:"#DEDEDE"};this.paragraphs.push(new pt.Paragraph({style:"Code",border:{left:{...i},right:{...i},top:{...i},bottom:{...i}},children:await this.paragraphsFromBlockTexts(r)}))}}async addListBlockObject(t,e){if(e.list==null)return;let r;const i=e.list.checkbox?`${t}-${e.list.groupId}-${e.list.checkbox}`:`${t}-${e.list.groupId}`;if(this.state.listInstMap[i])r=this.state.listInstMap[i];else if(r=this.state.listMaxInst,this.state.listMaxInst+=1,this.state.listInstMap[i]=r,e.list.start>0&&e.list.ordered){const s=`number-numbering-reference-${r}`,l=US([e.list.level-1],e.list.start);this.state.levelConfigs.push({levels:l,reference:s,inst:r}),this.state.listRefMap[i]=s}else e.list.ordered?this.state.listRefMap[i]=Sf.NUMBERING:e.list.checkbox&&e.list.checkbox==="checked"?this.state.listRefMap[i]=Sf.CHECKED:e.list.checkbox&&e.list.checkbox==="unchecked"?this.state.listRefMap[i]=Sf.UNCHECKED:this.state.listRefMap[i]=Sf.BULLET;const o=FS(e);e.texts&&this.paragraphs.push(new pt.Paragraph({heading:o,children:await this.paragraphsFromBlockTexts(e),numbering:{reference:this.state.listRefMap[i],level:e.list.level-1,instance:r}}))}imageDimWithBufferToImageRun(t){return new pt.ImageRun({data:t.buffer,transformation:{width:t.width,height:t.height}})}async addImagesBlockObject(t,e,r){if(e.images==null){if(t.type==="embed"&&t.embedType==="image"){const{src:c}=t.embedData;c||this.addEmptyImagePlaceHolder()}return}const i=[],o=await Promise.all(e.images.map(async c=>{const d=await this.readImageFunc(this.appId,this.docId,c.src);if(d)return MS(c,d);i.push(c.src)}));eet(o,r,t.embedData);const s=tet(o,r),l={style:pt.BorderStyle.SINGLE,color:"#DEDEDE"};s.length&&this.paragraphs.push(new pt.Paragraph({border:e.border?{left:{...l},right:{...l},top:{...l},bottom:{...l}}:void 0,alignment:KS(e)||pt.AlignmentType.CENTER,children:s.map(c=>this.imageDimWithBufferToImageRun(c)).flatMap((c,d,h)=>c==null?[]:h.length-1!==d?[c,new pt.TextRun({text:" "})]:c)})),i.forEach(c=>{this.addHyperlinkParagraph(c)})}addSeparatorBlock(){Aet().forEach(t=>this.paragraphs.push(t))}addEmptyParagraph(){this.paragraphs.push(new pt.Paragraph(""))}addVideoPlaceholder(){this.paragraphs.push(bet())}addAudioPlaceholder(){this.paragraphs.push(vet())}addHyperlinkParagraph(t,e){t!=null&&this.paragraphs.push(Bet(t,e))}async addTableMatrix(t,e,r){const i=t.map(o=>o!==0?o*15:1500);this.paragraphs.push(new pt.Table({rows:await this.generateTableRows(e,r),columnWidths:i}))}async generateRowCells(t,e){const r=[];for(const i of t){const o=i.cellId;if(o===void 0)continue;const s=i.width*.9;r.push(new pt.TableCell({children:await this.convertBlocksFunc(o,e.blocks[o],e,this.appId,this.docId,this.state,s),columnSpan:i.colSpan,rowSpan:i.rowSpan,width:{type:pt.WidthType.DXA,size:i.width*15},shading:i.color?{fill:i.color,type:pt.ShadingType.CLEAR,color:"auto"}:void 0}))}return r}async generateTableRows(t,e){const r=[];for(const i of t)r.push(new pt.TableRow({children:await this.generateRowCells(i,e)}));return r}async addDoc(t,e,r){const i=await this.convertBlocksFunc(t,e.blocks.root,e,this.appId,this.docId,this.state,r);i&&(this.paragraphs=this.paragraphs.concat(i))}async addOtherEmbedBlock(){}}class Get{constructor(t,e,r,i,o,s,l,c){m(this,"convertBlocks",async(t,e,r,i,o,s,l=720)=>{const c=new zet(i,o,s,this.readImage,this.convertBlocks,this.defaultFontSize);return await $et(t,e,r,c,i,o,this.md5HexFunc,this.getDocByBlock,this.getTextsByBox,l||720),c.paragraphs});this.templateData=t,this.docData=e,this.md5HexFunc=r,this.readImage=i,this.defaultFontSize=o,this.getDocByBlock=s,this.getTextsByBox=l,this.backgroundImageOptions=c}async convert(t,e){return this.snapshot2docx(this.docData,t,e)}async snapshot2docx(t,e,r){const i=new pt.ImportDotx,o=this.templateData?await i.extract(this.templateData):void 0,s=t.blocks.root;p(jet,s,"data must have blocks");const l=Het(),c=await this.convertBlocks("blocks",s,t,e,r,l),d=this.backgroundImageOptions?{default:new pt.Header({children:[new pt.Paragraph({children:[new pt.ImageRun(this.backgroundImageOptions)]})]})}:{},h=new pt.Document({numbering:{config:[...oet,...l.levelConfigs]},sections:[{headers:d,children:c,properties:{page:{size:{width:12240,height:15840},margin:{top:1440,bottom:1440,left:1440,right:1440}}}}]},{template:o});return pt.Packer.toBlob(h)}}async function Wet(n,t,e,r){const i=n.doc.buildResourceUrl(r,{withToken:!0});let o=await _S(i);if(!o)return;if(o.type.indexOf("/svg")!==-1){const l=await LS(o);l&&(o=new File([l],o.name))}return await o.arrayBuffer()}async function qet(n,t,e){const r=n.editorBlocks.getBlockClass(e.type);if(r.toStandardDoc)return r.toStandardDoc(n,e,t)}async function Xet(n,t){const e=t.attributes,r=n.editorBoxes.getBoxClass(e.type);if(r.toStandardText)return r.toStandardText(n,e)}async function Qet(n,t){let{template:e,download:r,backgroundImageOptions:i}=t!=null?t:{};e||(e=Jtt());const o=n.doc.toJSON(),s=(C,E,A)=>Wet(n,C,E,A),l=async(C,E,A)=>qet(n,o,A),c=async C=>Xet(n,C),h=await new Get(e,o,kd.default,s,void 0,l,c,i).convert("_appId","_docId");if(r){const C=URL.createObjectURL(h),E=document.createElement("a");E.setAttribute("download",`${DS(n)}.docx`),E.setAttribute("href",`${C}`),E.click(),E.remove()}return h}const bx=I("create-editor");async function Yet(n,t){var s,l,c,d,h,C,E,A,v,R,L,M,U,F;p(bx,n,"app does not exists"),t.lang&&D.setLang(t.lang),li.level=(s=t.logLevel)!=null?s:Ds.DEBUG;const e=t.onReauth?async()=>{var at;const G=t.user.userId,W=t.docId,it=await((at=t.onReauth)==null?void 0:at.call(t,G,W,t.permission));return{userId:G,docId:W,permission:t.permission,appId:t.appId,token:it,displayName:t.user.displayName,avatarUrl:t.user.avatarUrl}}:void 0,r={auth:{appId:t.appId,docId:t.docId,userId:t.user.userId,permission:t.permission,token:t.token,displayName:t.user.displayName,avatarUrl:t.user.avatarUrl},serverUrl:t.serverUrl,reauthFunc:e,disableLogout:t.disableLogout},i=await Nu.load(r),o=ku(n,i,{id:t.id,scrollContainer:t==null?void 0:t.scrollContainer,enableComments:t==null?void 0:t.enableComments,components:{blocks:[...kS,...((l=t==null?void 0:t.components)==null?void 0:l.blocks)||[]],embeds:[...Ex,...((c=t.components)==null?void 0:c.embeds)||[]],boxes:[...RS,...((d=t.components)==null?void 0:d.boxes)||[]],commandProviders:[new d0,...((h=t.components)==null?void 0:h.commandProviders)||[]],decorators:[new K0,new $p],insertions:[H1],blockHooks:[new wE,new ZR,...((C=t.components)==null?void 0:C.blockHooks)||[]],textRenders:[new p4,new $C],options:{...t.componentsOptions}},shortcuts:[aQ,Nj,XG,aE,Vw,VK,nE,GQ,_h,MK,...t.shortcuts||[]],colors:["#0064FF","#EB3723","#F59300","#00A865","#F25A0A","#70A310","#009CAD","#0990D9","#8851ED","#D62069"]});if(o.editorCommandProviders.registerCommandProvider(new wi(o)),o.input.addHandler(new UY),o.input.addHandler(new $0),o.input.addHandler(new s$),o.input.addHandler(new VG),o.input.addHandler(new pE(o,{hideTitle:t.hideTitle,headingLevel:1,titlePlaceholder:D.t("placeholder.common.title"),contentPlaceholder:D.t("placeholder.common.content"),readonlyTitlePlaceholder:D.t("placeholder.common.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0})),o.input.addHandler(new D0(o,(E=t.componentsOptions)==null?void 0:E.quickMenu)),o.input.addHandler(new ME(o)),o.input.addHandler(new KE(o)),o.input.addHandler(new G0),o.doc.registerCallback(new OY(o)),o.addCustom("remote-cursor",()=>new lT(o)),o.addCustom("block-menu",G=>new nw(G)),me.isMobile||o.addCustom("editor-tooltip",()=>new _0(o)),t!=null&&t.enableComments&&o.addCustom("editor-comments",G=>new g4(G,new Htt(G))),t!=null&&t.enableContextMenu&&o.addCustom("editor-context-menu",G=>new zw(G)),o.addCustom("create-options",()=>new Tb(o,t)),o.addCustom("drop-target",()=>new Cf(o)),o.addCustom("list-to-mindmap",()=>new y0(o)),o.addCustom("list-to-mention",()=>new nJ(o)),o.addCustom("mobile-helper",()=>new xJ(o)),o.addCustom("code-caret",()=>new _j(o)),o.addCustom("image-paste-handler",()=>new _E(o)),(A=t.componentsOptions)!=null&&A.mention){const G=t.componentsOptions.mention;o.addCustom("mention",()=>new Z4(o,G))}if(t!=null&&t.enableContextMenu&&o.addCustom("editor-context-menu",G=>new zw(G)),o.addCustom("heading-collapse",()=>new ox(o)),ec.register(o),Cf.register(o),gs.register(o),cs.register(o),o.addListener("clickLink",(G,W,it)=>{var xt;if((xt=t==null?void 0:t.events)!=null&&xt.onClickLink){t.events.onClickLink(G,W,it);return}const at=it.getAttribute("link");at&&(G.readonly||W.ctrlKey||W.metaKey)&&window.open(at,"_blank")}),(R=(v=t.componentsOptions)==null?void 0:v.remoteCarets)!=null&&R.onUserChanged){const G=(M=(L=t.componentsOptions)==null?void 0:L.remoteCarets)==null?void 0:M.onUserChanged;o.doc.getRemoteUsers().on("change",W=>{G(o,W)})}return(F=(U=t.componentsOptions)==null?void 0:U.templates)!=null&&F.templates.length&&(o.addListener("docChanged",()=>{dm(o)}),o.addListener("resize",()=>{dm(o,{reset:!0})}),setTimeout(()=>{dm(o)},100)),o.doc.registerCallback({onError:async G=>{if(G.code==="ResetDoc"){bx.error(`reset doc: ${G.message}`);const W=await Nu.load(r);o.doc.reset(W)}}}),o}function Jet(n){return n.toJSON!==void 0}async function Zet(n,t,e){var o,s,l,c,d,h;p(bx,n,"app does not exists");const r=Jet(t)?t:new bp(t,{serverUrl:e.serverUrl||""});e.lang&&D.setLang(e.lang),li.level=(o=e.logLevel)!=null?o:Ds.DEBUG;const i=ku(n,r,{id:e.id,scrollContainer:e==null?void 0:e.scrollContainer,components:{blocks:[lE,mE,gE,wk],commandProviders:[new d0],decorators:[new K0,new $p],embeds:[...Ex,...((s=e.components)==null?void 0:s.embeds)||[]],boxes:[Vk,tS,T4,jk,...((l=e.components)==null?void 0:l.boxes)||[]],insertions:[H1],blockHooks:[new wE,...((c=e.components)==null?void 0:c.blockHooks)||[]],textRenders:[new p4,new $C,...((d=e.components)==null?void 0:d.textRenders)||[]],options:{...e.componentsOptions}},shortcuts:[aE,Vw,nE,_h]});return i.editorCommandProviders.registerCommandProvider(new wi(i)),i.input.addHandler(new $0),i.input.addHandler(new pE(i,{hideTitle:e.hideTitle,headingLevel:1,titlePlaceholder:D.t("placeholder.common.title"),contentPlaceholder:D.t("placeholder.common.content"),readonlyTitlePlaceholder:D.t("placeholder.local.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0})),i.input.addHandler(new D0(i,(h=e.componentsOptions)==null?void 0:h.quickMenu)),i.input.addHandler(new ME(i)),i.input.addHandler(new KE(i)),i.input.addHandler(new G0),i.addCustom("block-menu",C=>new nw(C)),me.isMobile||i.addCustom("editor-tooltip",()=>new _0(i)),i.addCustom("image-paste-handler",()=>new _E(i)),e!=null&&e.enableComments&&i.addCustom("editor-comments",C=>new g4(C,new jtt(C,r))),i.addCustom("heading-collapse",()=>new ox(i)),i.addListener("clickLink",(C,E,A)=>{var R;if((R=e==null?void 0:e.events)!=null&&R.onClickLink){e.events.onClickLink(C,E,A);return}const v=A.getAttribute("link");v&&(C.readonly||E.ctrlKey||E.metaKey)&&window.open(v,"_blank")}),ec.register(i),i}async function tnt(n,t,e){var h;const r=n.doc.externalDoc.client.auth,i=await zh.load({auth:r,serverUrl:e});if(!((h=i.getVersionHelper)==null?void 0:h.call(i)))throw new Error("the editor does not support to show versions");const s=n.getCustom("create-options");if(!s)throw new Error("the editor does not support to show versions");const l=s.getData(),c=new wS(l),d=n.addCustom("version-dialog",()=>new K4(i,c));return d.show(t),d}b.tippy=J6,b.AnchorBox=SB,b.AuthError=jh,b.AuthHeader=il,b.AutoScroll=Vd,b.BaseURLHeader=Na,b.BasicCommands=wV,b.BlockExclusiveHook=ZR,b.BlockLockerHook=wE,b.BlockLockerPasteHandler=G0,b.BlockResizer=lf,b.BrBox=yB,b.CodeBlock=mE,b.CodeLineBlock=gE,b.CodeTextDecorator=K0,b.DefaultShortcuts=_h,b.DocIdError=TN,b.DragDrop=Hb,b.DrawioEmbed=gS,b.EditorBlocks=Zv,b.EditorBoxes=RB,b.EditorCommandProviders=A2,b.EditorComplexBlockPosition=Ur,b.EditorComplexSelectionRange=di,b.EditorDecorators=_B,b.EditorEmbeds=e3,b.EditorInsertions=DB,b.EditorSimpleBlockPosition=We,b.EditorSimpleSelectionRange=tn,b.EmbedBlock=r3,b.EmbedBlockResizer=yf,b.EnforceWithDocumentTitleHandler=pE,b.EventCallbacks=sa,b.FILL_CHAR=q_,b.FileExtError=yN,b.GroupOrder=_k,b.HeadingBlockScrollListener=QY,b.ImageBox=wB,b.InlineBoxCommandProvider=zk,b.InputtingInsertion=LB,b.LocalDoc=bp,b.LogLevel=Ds,b.Logger=li,b.MIN_DISTANCE_THRESHOLD=Vb,b.ManualCloseDialog=Fu,b.ManualMenu=Zo,b.ManualToolbar=Pu,b.MarkdownInputHandler=$0,b.MaxUserError=_p,b.Mindmap=T0,b.OnesEditorAutoSuggest=cC,b.OnesEditorCustomDataWrapper=Tb,b.OnesEditorExclusiveBlock=cs,b.OnesEditorHoveringBlock=Be,b.OnesEditorIcons=uP,b.OnesEditorQuickMenu=D0,b.OnesEditorToc=Rf,b.OnesEditorTocProvider=gs,b.OnesEditorToolbar=ec,b.OnesEditorTooltip=_0,b.OnesEditorVersionsDialog=K4,b.PermissionError=BN,b.Popup=Va,b.RemoteCarets=lT,b.RemoteCaretsDecorator=$p,b.RemoteCaretsInsertion=H1,b.RemoteUsers=Ru,b.RequestReloadError=Ou,b.RichText=fn,b.ShareDBDoc=Nu,b.ShareDBDocVersionsProvider=wS,b.ShareDBServer=zh,b.SimpleCache=Db,b.StandardEmbedBlockCommands=JE,b.TEXT_STYLE_BACKGROUND_COLOR_PREFIX=b1,b.TEXT_STYLE_COLOR_PREFIX=A1,b.TableBlock=lE,b.TableBlockCommandProvider=d0,b.TableShortcuts=aE,b.TextBlock=On,b.TextBox=TB,b.TextColorItem=yy,b.TextStyleShortcuts=nE,b.TocEmbed=Y4,b.ZERO_WIDTH_SPACE_CHAR=Qc,b.abbreviation=$d,b.addAttribute=ih,b.addClass=z,b.addCommentToBlock=Tf,b.addDays=sI,b.addMetaToDoc=Ia,b.addMonths=oI,b.animateScrollTo=ca,b.applyPlaceholderToBlock=of,b.assert=p,b.autoShowHideTemplates=dm,b.blockToDoc=pp,b.blockToHtml=G1,b.blockToMarkdown=Ah,b.blockToText=xh,b.blocksToDoc=EU,b.clearAllSelection=Ov,b.clientType=me,b.cloneBlock=qo,b.cloneChildContainer=np,b.cloneDoc=rp,b.cloneText=mB,b.commentToShareDbComment=Vp,b.compareElement=_d,b.comparePosition=i1,b.complexBlockAdjustSelectionPos=Qd,b.complexBlockFindNearestChildBlock=l3,b.complexBlockGeFirstSimpleChild=s1,b.complexBlockGetAllChildContainers=An,b.complexBlockGetBottomChildContainers=s3,b.complexBlockGetLastSimpleChild=pa,b.complexBlockGetSelectedContainers=ga,b.complexBlockGetTopChildContainers=o3,b.containerToDoc=G5,b.continuousScroll=sv,b.convertBlockFrom=Wd,b.convertImageFileToPng=LS,b.convertImageSrcToPng=Xtt,b.converterIntercept=V0,b.copyBlockAttributes=GB,b.copyResourcesFromDoc=Ap,b.createBlockAnchor=Yi,b.createBlockCaretAnchor=u3,b.createBlockContentElement=Hs,b.createBlockElement=Rv,b.createBlockSimpleDocRange=mh,b.createBlockSimpleRange=Te,b.createBoxContentElement=Lv,b.createBoxElement=wv,b.createBoxOp=hB,b.createChildContainer=Yv,b.createComplexBlockPosition=xe,b.createComplexDocPos=AB,b.createComplexDocRange=Y_,b.createContainer=CB,b.createContainerElement=Gg,b.createDeleteOps=cB,b.createEditor=ku,b.createEditorSelectionRange=qe,b.createElement=B,b.createEmptyContainer=no,b.createEmptyDoc=eo,b.createEmptyTextBlockData=dh,b.createExpandedRange=Id,b.createIconButton=Ms,b.createImage=Rg,b.createInsertOps=uh,b.createInsertionContentElement=_v,b.createInsertionElement=Iv,b.createLocalEditor=Zet,b.createOnesEditor=Yet,b.createRange=_b,b.createRichText=Zs,b.createRootContainer=Qv,b.createSimpleBlockPosition=lt,b.createSimpleDocPos=xB,b.createTextBlockData=pi,b.createTextButton=hl,b.createTextOp=gr,b.createTextWithReplaceSoftReturn=_1,b.daysAfter=Vg,b.deleteText=U1,b.diffDays=lI,b.disablePageScroll=tv,b.docToHtml=VB,b.docToHtmlFragment=Ba,b.docToMarkdown=$B,b.docToText=ro,b.downloadImageToFile=_S,b.downloadObjectToFile=dx,b.downloadSvgToString=sS,b.editLink=Qu,b.editorAddComment=ZX,b.editorAddTextAttribute=r5,b.editorAutoInsertBlock=WB,b.editorBreakTextBlock=Ra,b.editorClearCompositionText=Q1,b.editorClearSelectedContents=yh,b.editorCopyBlock=Dh,b.editorDeleteBlock=Z1,b.editorDeleteBlockText=Y1,b.editorDeleteBlockWithoutChildren=Bh,b.editorDeleteChildContainer=QM,b.editorDeleteChildContainers=qB,b.editorFocusToBlock=ep,b.editorFocusToEnd=pU,b.editorGetBlockData=Wo,b.editorGetBlockText=bn,b.editorGetBlockTextEx=ph,b.editorGetBoxData=vB,b.editorHandleKeyboardEvent=r2,b.editorInsertBlock=ka,b.editorInsertBoxToBlock=jB,b.editorInsertDoc=e5,b.editorInsertDocAt=ip,b.editorInsertText=X1,b.editorInsertTextToBlock=HB,b.editorInsertTextToBlockEx=q1,b.editorMergeTextBlock=XB,b.editorMoveDown=p5,b.editorMoveEnd=fp,b.editorMoveHome=k5,b.editorMoveLeft=h5,b.editorMoveLineEnd=M5,b.editorMoveLineHome=_5,b.editorMovePageDown=K5,b.editorMovePageUp=F5,b.editorMoveRight=m5,b.editorMoveUp=g5,b.editorMoveWordEnd=B5,b.editorMoveWordLeft=v5,b.editorRangeClearColor=o5,b.editorRangeGetColor=s5,b.editorRangeSetColor=i5,b.editorRemoveTextAttribute=tU,b.editorReplaceBlockText=kh,b.editorReplaceContainer=n5,b.editorRunOnce=vp,b.editorSelectAll=mp,b.editorSelectContainer=Sh,b.editorSelectDown=C5,b.editorSelectEnd=dp,b.editorSelectHome=R5,b.editorSelectLeft=E5,b.editorSelectLineEnd=D5,b.editorSelectLineHome=I5,b.editorSelectPageDown=$5,b.editorSelectPageUp=V5,b.editorSelectRight=x5,b.editorSelectUp=A5,b.editorSelectWordEnd=y5,b.editorSelectWordLeft=T5,b.editorSetTextColor=wa,b.editorShowFindDialog=zq,b.editorToDocx=Qet,b.editorUpdateBlockData=Rh,b.editorUpdateCompositionText=zB,b.editorUpdateEmbedData=ZB,b.enablePageScroll=ev,b.escapeHtmlText=Ud,b.escapeRegExp=zg,b.escapeSpace=H9,b.exclusiveBlock=yE,b.executeBlockCommand=zv,b.executeEmbedBlockCommand=jv,b.executeRangeCommand=x2,b.fileToDataUrl=fa,b.findAfterOffsetNotType=K1,b.findAllText=N1,b.findBlockByIndex=Cv,b.findEventTargetBlock=Nb,b.findInsertionById=Dv,b.findNextOffset=CM,b.findNextVisibleSimpleBlock=y2,b.findPrevOffset=pM,b.findPrevOffsetNotType=F1,b.findPrevSimpleBlockBeforeChildContainer=i3,b.findPrevVisibleSimpleBlock=T2,b.findTarget=aa,b.findWordEnd=$1,b.findWordLeft=V1,b.format=nu,b.formatBytes=lv,b.formatDate=Hg,b.fragmentToHtml=nv,b.fromBase64=Zc,b.fromBase64ToBlob=Pg,b.fromBase64ToUint8Array=tI,b.fromDocRange=$o,b.fromNowString=jg,b.genId=Z,b.getAllChildBlocks=c1,b.getAllQuickMenuItems=eE,b.getAllSelectedBlocks=hi,b.getAttributesAt=Aa,b.getBlockBackground=kv,b.getBlockByIndex=zi,b.getBlockCaretRect=_r,b.getBlockClass=Yt,b.getBlockClassByType=Ks,b.getBlockClientRects=qi,b.getBlockCommandsWithHook=Zg,b.getBlockContent=Ot,b.getBlockId=st,b.getBlockIndex=bt,b.getBlockInfo=df,b.getBlockKind=Ir,b.getBlockMinWidth=Pv,b.getBlockNearestRangeFromPoint=l1,b.getBlockOptions=AI,b.getBlockPath=Vo,b.getBlockProperties=Vv,b.getBlockRangeFromPoint=Yd,b.getBlockStyles=xI,b.getBlockTextLength=dt,b.getBlockTools=re,b.getBlockType=St,b.getBoxContent=lu,b.getBoxId=Sv,b.getBoxTypeFromElement=su,b.getChildBlockCount=Lr,b.getChildBlocks=ue,b.getChildOffset=zo,b.getColorFromAttributes=B1,b.getColorFromContent=Hd,b.getComplexBlockClass=Qn,b.getContainerBlockPath=Wv,b.getContainerBlocks=Uv,b.getContainerBlocksElement=ru,b.getContainerById=ui,b.getContainerId=ft,b.getContainerMinWidth=n1,b.getContainerToolsElement=pI,b.getContainerWidth=Jv,b.getDistanceSquare=$i,b.getElementOffset=Xc,b.getElementScale=fr,b.getEmbedType=Ge,b.getExistsBlockTools=zd,b.getExistsContainerById=jd,b.getFileExt=eu,b.getFirstChildBlock=we,b.getFirstClientRect=Dd,b.getHeadingMenuOptions=XC,b.getHorizontalPadding=Sg,b.getInsertionContent=Xg,b.getLastChildBlock=Ze,b.getLastClientRect=Us,b.getListAllNextBrothers=Qa,b.getLogger=I,b.getNextBlock=qt,b.getNextValidOffset=Ys,b.getNextVisibleBlock=zs,b.getOffsetFromPoint=wg,b.getOffsetInfoAfter=Eu,b.getOffsetInfoBefore=Ch,b.getOpAt=j3,b.getOpLength=rh,b.getParentBlock=et,b.getParentBlockExcludeSelf=$s,b.getParentBox=qg,b.getParentContainer=rt,b.getPrevBlock=ge,b.getPrevValidOffset=Go,b.getPrevVisibleBlock=js,b.getRangeCommands=C2,b.getReferenceClientRect=ik,b.getRootBlock=Jg,b.getScrollContainer=En,b.getSpecialBlockCommands=$v,b.getStandardEmbedBlockProperties=ZE,b.getTextAfterOffset=mM,b.getTextAttributes=W1,b.getTextBeforeOffset=gM,b.getTextBlockChild=qd,b.getTextBlockClass=xv,b.getTextBlockContentChildTextLength=mr,b.getTextBlockContentChildType=Gv,b.getTextBlockContentChildren=fi,b.getTextLength=un,b.getTextOpLength=x1,b.getTextWidth=Pd,b.getToolbar=E0,b.handleBlockElementUpdated=Fv,b.hasAltOnly=X9,b.hasClass=Rt,b.hasCtrlOrCmd=Xb,b.hasCtrlOrCmdOnly=q9,b.hashCode=mv,b.hideBlock=Tv,b.htmlToFragment=Nd,b.i18n=D,b.injectDocToHtmlFragment=La,b.injectStyle=Kb,b.inputActions=UU,b.insertEmptyBlock=BI,b.insertEmptyEmbedBlock=t1,b.insertText=to,b.intersectionCommands=pO,b.isBackspace=Yb,b.isBlock=Vs,b.isBlockLocked=z0,b.isBlockLockedByOthers=RE,b.isBlockLockedBySelf=hf,b.isBlockTools=Bv,b.isBox=Gd,b.isBoxOp=jo,b.isCJK=Wb,b.isChildContainer=Mr,b.isChildNode=ne,b.isCodeBlock=qr,b.isCollapsedRange=Q_,b.isComplexBlockPosition=ma,b.isComplexKindBlock=_t,b.isContainer=Wi,b.isContainerSelectedAllChildBlocks=H5,b.isControlEvent=Ps,b.isDelete=Y9,b.isDraggingFiles=Fd,b.isElementVisible=Dg,b.isEmbedBlock=pe,b.isEmptyContainer=uu,b.isEmptyDoc=P1,b.isEmptyTextBlock=ie,b.isEmptyTextBlockWithoutCompositionText=rf,b.isEnterOnly=Qb,b.isEscape=Og,b.isExclusiveBlock=ff,b.isFirefox=Jc,b.isFirstChildBlockInComplexBlock=r7,b.isHighSurrogate=F9,b.isInBlock=Qg,b.isInBlockTools=Gs,b.isLetter=Gb,b.isLowSurrogate=K9,b.isMatchShortcut=ai,b.isMoveForward=G9,b.isNavigationEvent=z9,b.isNavigationKey=qb,b.isNodeRemoved=Ub,b.isNumber=zb,b.isPrintableKey=Ug,b.isRootBlock=dr,b.isRootContainer=Xt,b.isSafari=ua,b.isSameDay=$g,b.isSelectBoxOnly=Sk,b.isShiftEnter=Q9,b.isShiftTab=Z9,b.isShortcutEvent=W9,b.isSimpleBlock=EI,b.isSimpleBlockPosition=Or,b.isSimplePos=EB,b.isSimpleRange=hh,b.isSpace=Od,b.isTab=J9,b.isTextBlockContentBoxChild=hr,b.isTextBlockContentChild=au,b.isTextBlockContentInsertionChild=Qi,b.isTextBlockContentTextChild=cu,b.isTextKindBlock=nt,b.isTextKindBlockType=iu,b.isTitleBlock=Gi,b.isToday=av,b.isValidOffset=Un,b.isVisibleBlock=ou,b.isYesterday=cv,b.loadJs=Ob,b.loadJsPromise=Os,b.lockers=Sr,b.mergeCommands=C0,b.mergeDocs=tl,b.mergeOps=M1,b.mergeText=G_,b.multiSplitText=G3,b.overflowText=uv,b.parseShortcut=Jb,b.patchNode=tu,b.pointInRect=Ns,b.rangeAddAttribute=gu,b.rangeGetTextColor=Z3,b.rangeRemoveAttribute=xa,b.rangeSetTextColor=Q3,b.rangeTransformText=q3,b.registerDragDrop=_g,b.removeAttribute=v1,b.removeClass=ot,b.removeLastBr=$_,b.removePlaceholderFromBlock=yR,b.removeStyle=Fb,b.replaceAll=aI,b.replaceAllCaseInsensitive=cI,b.replaceAllText=pB,b.replaceText=fh,b.requestDownload=Kd,b.resetListStart=Ja,b.scrollable=ov,b.selectFile=ha,b.selectedBlockToDoc=Lh,b.selectionToDoc=Sa,b.setAttributes=Md,b.setClipboardData=da,b.setClipboardDataByEvent=iI,b.setColorToAttributes=Y3,b.setDataset=Lg,b.setDefaultCursor=Yc,b.setStyles=Ig,b.shareDBCommentToDocObject=Kp,b.shareDBDocCommentToComment=oT,b.shortcutToDisplayText=ze,b.showBlock=yv,b.showDocVersions=tnt,b.splitText=_n,b.splitToThree=Xe,b.stringToDataUrl=Fg,b.stringToObjectUrl=Kg,b.subText=W3,b.textNodeOffsetFromPoint=Mb,b.titleFromEditor=DS,b.toBase64URL=ci,b.toMindmap=B0,b.toPlainText=fe,b.toPlainTextKeepLength=O1,b.trimChar=Mg,b.unexclusiveBlock=kE,b.unicodeLength=V9,b.unicodeSubstr=$9,b.updateBlockSelection=Nv,b.updateOpAttributes=gB,b.updateTextBlockContent=hM,b.updateUrl=Ng;for(const n in Re)n!=="default"&&!b.hasOwnProperty(n)&&Object.defineProperty(b,n,{enumerable:!0,get:()=>Re[n]});Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|
|
962
|
+
\`\`\`\`\`\``}return""}const dtt={embedType:"plantuml",convertFrom:ctt,handleUpdateBlock:att,createEmbedContent:ltt,getBlockProperties:utt,convertTo:ftt},Eut="",htt="hr",mtt={dividingLine:{type:"\u5206\u5272\u7EBF",abstract:"\u5206\u5272\u7EBF"}},gtt={dividingLine:{type:"Dividing-Line",abstract:"Dividing-Line"}},ptt={dividingLine:{type:"\u533A\u5207\u308A\u7DDA",abstract:"\u533A\u5207\u308A\u7DDA"}};D.mergeLang({"zh-CN":mtt,"en-US":gtt,"ja-JP":ptt});function Ctt(n,t){const e=B("div",["editor-embed-container"],t);B("hr",["editor-embed-hr"],e)}function Ett(n,t,e,r){return r==="html"?"<hr />":r==="markdown"?"---":"------------"}function xtt(){return{name:"hr",insertEmbedCommandItems:[{id:"insert-hr",name:D.t("dividingLine.type"),icon:VT,order:500,group:"common",subText:Bn("insert-hr")}],handleInsertEmptyEmbed:async(n,t)=>{const{containerId:e,blockIndex:r}=t;return n.insertEmbed(e,r,htt,{})}}}function Att(n,t,e){const{data:r}=e;if(!r||r.embedType!=="dividing-line"||!nt(n,t))return null;const i={};return{blockData:{id:Z(),type:"embed",embedType:"hr",embedData:i}}}function btt(){return{abstract:D.t("dividingLine.abstract")}}const vtt={embedType:"hr",createEmbedContent:Ctt,convertTo:Ett,getOptions:xtt,convertFrom:Att,getBlockProperties:btt},xut="",Aut="",Btt={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>',maxSizeFailed:'<div class="line-1">{name}\u4E0A\u4F20\u5931\u8D25</div><div class="line-2">\u6587\u4EF6\u5927\u5C0F\u8D85\u8FC7\u9650\u5236\uFF0C\u8BF7\u91CD\u65B0\u9009\u62E9\u6587\u4EF6</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"}}},Ttt={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>',maxSizeFailed:'<div class="line-1">{name} upload failed</div><div class="line-2">The file size exceeds limit. Please choose another file.</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"}}},ytt={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>',maxSizeFailed:'<div class="line-1">{name}\u306E\u30A2\u30C3\u30D7\u30ED\u30FC\u30C9\u306B\u5931\u6557\u3057\u307E\u3057\u305F</div><div class="line-2">\u30D5\u30A1\u30A4\u30EB\u306E\u30B5\u30A4\u30BA\u304C\u4E0A\u9650\u3092\u8D85\u3048\u3066\u3044\u308B\u305F\u3081\u3001\u4ED6\u306E\u30D5\u30A1\u30A4\u30EB\u3092\u9078\u629E\u3057\u3066\u304F\u3060\u3055\u3044</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"}}};D.mergeLang({"zh-CN":Btt,"en-US":Ttt,"ja-JP":ytt});var Yr=(n=>(n.AUDIO="audio",n.VIDEO="video",n))(Yr||{}),wf=(n=>(n.Empty="empty",n.Progress="progress",n.Error="error",n))(wf||{});const AS=10*1024*1024,ktt=["wav","mp3","aac","ogg","webm","flac"],Rtt=["ogg","mp4","webm"],wtt=()=>{};function bS(n){var h,C,E,A,v,R;const t=(h=n.getComponentOptions("media"))!=null?h:{},{allowedMedias:e,maxSize:r,callbacks:i}=t,o=(C=e==null?void 0:e.audio)!=null?C:ktt,s=(E=e==null?void 0:e.video)!=null?E:Rtt,l=(A=r==null?void 0:r.audio)!=null?A:AS,c=(v=r==null?void 0:r.video)!=null?v:AS,d=(R=i==null?void 0:i.onError)!=null?R:wtt;return{allowedMedias:{audio:o,video:s},maxSize:{audio:l,video:c},callbacks:{onError:d}}}function Stt(n,t){const e=o=>o.map(s=>`.${s}`).join(","),{allowedMedias:r}=bS(n),i=r[t];return i?e(i):"*"}function Ltt(n,t,e){const{maxSize:r,callbacks:i,allowedMedias:o}=bS(t),{[e]:s}=r,{[e]:l}=o;if(s&&n.size>s){const d=new Error("media is too large");throw d.code=`MaxMediaSize-${e}`,i!=null&&i.onError&&(i==null||i.onError(t,d)),d}const c=eu(n.name);if(l&&!l.includes(c.toLowerCase())){const d=new Error(`media file is not allowed: ${c}`);throw d.code="NotAllowedFile",i!=null&&i.onError&&(i==null||i.onError(t,d)),d}}function Itt(n){return n===wf.Empty||n===wf.Error}const Ye=I("media");class Dtt extends Re.TypedEmitter{constructor(e){super();m(this,"mediaContainer",null);m(this,"media",null);m(this,"abstract",null);m(this,"handleMediaLoadError",(e,r)=>{if(!r.target||!(r.target instanceof Node)||!(r.target instanceof Element?r.target:r.target.parentElement))return;const o=et(r.target);if(!o||!o.contains(this.mediaContainer))return;const s=this.renderError();this.updateMediaContent(s),this.emit("mediaError",e,"load_error",st(o))});m(this,"handleUploadFile",async e=>{p(Ye,this.abstract,"no abstract"),p(Ye,this.mediaContainer,"The media element not exist");const{editor:r}=this.options,i=et(this.mediaContainer);p(Ye,i,"The block element not exist");const o=r.getBlockData(i);try{const{resourceId:s}=await r.doc.uploadResource(e,{onProgress:C=>{this.renderProgress(C,e)}}),{name:l,type:c,size:d}=e,h={...o,embedData:{...o.embedData,src:s,fileName:l,fileSize:d,fileType:c}};r.updateBlockData(i,h)}catch(s){Ye.error(s),this.emit("mediaError",r,"upload_error",o.id),this.renderRetry(e,s)}ot(i,"media-block-uploading")});m(this,"destroy",()=>{this.mediaContainer=null});this.options=e}bindMediaEvent(){const{editor:e}=this.options;this.media&&e.domEvents.addEventListener(this.media,"error",this.handleMediaLoadError)}unbindMediaEvent(){const{editor:e}=this.options;this.media&&e.domEvents.removeEventListener(this.media,"error",this.handleMediaLoadError)}updateMediaContent(e){p(Ye,this.mediaContainer,"The media element not exist"),this.mediaContainer.innerHTML="",this.mediaContainer.append(e)}renderError(){p(Ye,this.abstract,"no abstract");const{editor:e,createMediaElement:r}=this.options,{mediaIcon:i,mediaName:o}=this.abstract;p(Ye,this.mediaContainer,"The media element not exist");const s=et(this.mediaContainer);p(Ye,s,"The block element not exist");const l=e.getBlockData(s),c=l.embedData.src,d=B("div",["media-error","embed-selected-content","embed-hover-content"],null),h=B("span",["media-error-icon"],d);h.innerHTML=i;const C=B("div",[],d);C.innerHTML=D.t("media.load.failed",{name:o}),d.appendChild(C);const E=C.querySelector(".retry-upload");return p(Ye,E,"The element not exist"),e.domEvents.addEventListener(E,"click",(A,v)=>{const R=B("div",["media-element"],null),L=this.getResourceUrl(c),M=r(A,R,l,L);this.unbindMediaEvent(),this.media=M,this.bindMediaEvent(),this.updateMediaContent(R)}),this.setFullScreen(),d}renderRetry(e,r){var E,A;p(Ye,this.abstract,"no abstract");const{editor:i}=this.options,{mediaIcon:o,mediaName:s}=this.abstract,l=B("div",["media-error","embed-selected-content","embed-hover-content"],null),c=B("span",["media-error-icon"],l);c.innerHTML=o;const d=B("div",[],l);let h=D.t("media.upload.failed",{name:s});(((E=r.response)==null?void 0:E.status)===420||((A=r.response)==null?void 0:A.status)===413)&&(h=D.t("media.upload.maxSizeFailed",{name:s})),d.innerHTML=h,l.appendChild(d);const C=d.querySelector(".retry-upload");C&&i.domEvents.addEventListener(C,"click",()=>{i.readonly||(p(Ye,this.abstract,"no abstract"),this.handleUploadFile(e))}),this.updateMediaContent(l),this.setFullScreen()}renderProgress(e,r){p(Ye,this.mediaContainer,"The media element not exist");const i=this.mediaContainer.querySelector(":scope .media-progress"),o=e===-1||e===100?100:e;if(i){const{updateProgressElement:s}=this.options;s(i,o)}else{const{createProgressElement:s}=this.options,l=et(this.mediaContainer);p(Ye,l,"The element not exist"),z(l,"media-block-uploading");const c=B("div",["media-progress"],null);s(c,o,r),this.updateMediaContent(c)}this.setFullScreen()}renderMediaElement(e){p(Ye,this.mediaContainer,"The media element not exist");const r=this.mediaContainer.querySelector(":scope > .media-element"),{createMediaElement:i,updateMediaElement:o,editor:s}=this.options,l=this.getResourceUrl(e.embedData.src);if(r){const c=o(s,r,e,l);this.unbindMediaEvent(),this.media=c,this.bindMediaEvent()}else{const c=B("div",["media-element"],null),d=i(s,c,e,l);this.unbindMediaEvent(),this.media=d,this.bindMediaEvent(),this.updateMediaContent(c)}}renderEmpty(e){p(Ye,this.abstract,"no abstract"),p(Ye,this.mediaContainer,"The media element not exist");const r=B("div",["media-empty","embed-selected-content","embed-hover-content"],this.mediaContainer);r.innerHTML=this.abstract.mediaIcon,this.updateMediaContent(r);const{editor:i}=this.options;i.findBlockById(e.id)&&this.emit("mediaError",i,"empty",e.id),this.setFullScreen()}getResourceUrl(e){const{editor:r}=this.options;return r.doc.buildResourceUrl(e)}setFullScreen(){p(Ye,this.mediaContainer,"The media element not exist"),z(this.mediaContainer,"full-screen")}removeFullScreen(){p(Ye,this.mediaContainer,"The media element not exist"),ot(this.mediaContainer,"full-screen")}updateBlockAlign(e,r){const i=et(r);p(Ye,i,"The block element not exist");const{align:o}=e;e.embedType==="video"&&(i.hasAttribute("data-style-align")&&i.removeAttribute("data-style-align"),i.setAttribute("data-style-align",o))}render(e,r){const{src:i}=e.embedData;(!this.mediaContainer||!r.contains(this.mediaContainer))&&(this.mediaContainer=B("div",["media"],r)),this.updateBlockAlign(e,r),Itt(i)?i===wf.Empty&&this.renderEmpty(e):this.renderMediaElement(e)}setAbstract(e){this.abstract=e}}I("media-embed");const _tt="left";class vS{constructor(){m(this,"handleInsertEmptyEmbed",async(t,e)=>{var C;const{containerId:r,blockIndex:i}=e;let o;(C=e.data)!=null&&C.file&&(o=e.data.file);const s=Stt(t,this.embedType);if(o=o!=null?o:await ha(s,{}),!o)return null;const{mediaType:l}=this.getAbstract();try{Ltt(o,t,l)}catch{return null}const c={id:Z(),type:"embed",embedType:this.embedType,embedData:{src:wf.Empty}};l==="video"&&(c.align=_tt);const d=t.insertBlock(r,i,c);return await this.getMedia(t,c.id).handleUploadFile(o),d})}getMedia(t,e){const r=t.addCustom(`media-${e}`,()=>new Dtt({editor:t,createMediaElement:this.createMediaElement,updateMediaElement:this.updateMediaElement,createProgressElement:this.createProgressElement,updateProgressElement:this.updateProgressElement}));return r.setAbstract({...this.getAbstract()}),r}getOptions(){const{menuItem:t,mediaIcon:e,mediaName:r,order:i,group:o}=this.getAbstract();return{name:r,insertEmbedCommandItems:[{id:`insert-${this.embedType}`,name:t,icon:e,order:i,group:o,subText:Bn(`insert-${this.embedType}`)}],handleInsertEmptyEmbed:this.handleInsertEmptyEmbed}}createEmbedContent(t,e,r){const{id:i}=r;this.getMedia(t,i).render(r,e)}handleUpdateBlock(t,e,r){const{id:i}=r,o=this.getMedia(t,i),s=Ot(e);return o.render(r,s),!0}handleDeleteBlock(t,e){const r=e.id,i=this.getMedia(t,r);i.removeAllListeners(),i.destroy()}convertTo(t,e,r,i){const o=e.embedData,s=t.doc.buildResourceUrl(o.src,{withToken:!0});return i==="html"?`<${o.type} src="${s}" />`:i==="markdown"?``:s}}function BS(n,t){const e=B("div",["uploading-progress-mask"],n),r=B("div",["uploading-progress-bar"],e),i=B("div",["uploading-progress-bar-value"],r);i.style.width=`${t}%`}function TS(n,t){const e=n.querySelector(".uploading-progress-bar-value");e&&(e.style.width=`${t}%`)}const Mtt=I("media-audio");class Utt extends vS{constructor(){super(...arguments);m(this,"embedType",Yr.AUDIO);m(this,"updateProgressElement",TS);m(this,"createMediaElement",(e,r,i,o)=>{const s=B("div",["audio-container","embed-hover-content","embed-selected-content"],r),l=B("audio",[],s);return l.innerHTML="Your browser does not support the <code>audio</code> element.",l.controls=!0,l.src=o,setTimeout(()=>{this.getMedia(e,i.id).setFullScreen()}),l})}getAbstract(){return{mediaIcon:PT,mediaName:D.t(`media.${Yr.AUDIO}.menuItem`),menuItem:D.t(`media.${Yr.AUDIO}.menuItem`),order:800,mediaType:Yr.AUDIO,group:"common"}}getBlockProperties(){return{abstract:`${D.t(`media.${Yr.AUDIO}.abstract`)}`}}updateMediaElement(e,r,i,o){const s=r.querySelector(":scope .audio-container > audio");return p(Mtt,s,"The media element not exist"),s.src!==o&&(s.src=o),s}createProgressElement(e,r){const i=B("audio",[],e);i.innerHTML="Your browser does not support the <code>audio</code> element.",i.controls=!0,i.src="about:blank",BS(e,r)}}const Ott=new Utt;I("video-resizer");function yS(n){return n&&pe(n)&&Ge(n)==="video"}const Ntt=50;class Cx{constructor(t){m(this,"currentResizableElement",null);m(this,"resizing",!1);m(this,"handleHoveringBlockChange",(t,e)=>{if(!this.resizing&&!window.isDragging&&(e&&yS(e)&&this.disableBlockResize(e),t&&yS(t)&&this.editor.isBlockWritable(t))){const r=this.getVideoElement(t);if(!r)return;this.enableBlockResize(t,r)}});m(this,"handleResizing",(t,e)=>{if(this.resizing=!0,!this.currentResizableElement)return;const r=t.getBlock();if(!r)return;const i=r.getBoundingClientRect().width,o=Math.min(Math.max(e.width,Ntt),i);this.currentResizableElement.style.width=`${o}px`,this.currentResizableElement.style.pointerEvents="none"});m(this,"handleResized",t=>{this.resizing=!1;const e=t.getBlock();if(!this.currentResizableElement||!e)return;const r=this.editor.getBlockData(e),{width:i}=this.currentResizableElement.getBoundingClientRect();this.currentResizableElement.style.pointerEvents="auto",this.editor.updateBlockData(e,{...r,width:i})});this.editor=t,Be.get(t).addListener("change",this.handleHoveringBlockChange)}destroy(){this.currentResizableElement=null,Be.get(this.editor).removeListener("change",this.handleHoveringBlockChange)}getVideoElement(t){return Ot(t).querySelector(":scope .video-container > video")}updateResizer(t){const e=this.editor.findCustom(`${st(t)}-resizer`);e&&e.updateResizer()}disableBlockResize(t){const e=this.editor.findCustom(`${st(t)}-resizer`);e&&e.disableResize()}enableBlockResize(t,e){const r=this.editor.addCustom(`${st(t)}-resizer`,()=>new lf(this.editor,{resize:["top-left","top-right","bottom-left","bottom-right"]}));r.enableResize(t,e),r.removeListener("resizing",this.handleResizing),r.removeListener("resized",this.handleResized),r.addListener("resizing",this.handleResizing),r.addListener("resized",this.handleResized),this.currentResizableElement=e}}const Ptt=I("video");class Ftt extends vS{constructor(){super(...arguments);m(this,"embedType",Yr.VIDEO);m(this,"updateProgressElement",TS);m(this,"createMediaElement",(e,r,i,o)=>{const s=B("div",["video-container","embed-selected-content","drag-preview-element"],r),l=B("video",[],s);return l.innerHTML="Your browser does not support the <code>video</code> element.",l.controls=!0,l.src=o,l.addEventListener("canplay",()=>{e.addCustom("video-resizer",()=>new Cx(e)),this.getMedia(e,i.id).removeListener("mediaError",this.handleMediaError),this.getMedia(e,i.id).addListener("mediaError",this.handleMediaError),this.getMedia(e,i.id).removeFullScreen()}),i.width&&(l.style.width=`${i.width}px`),l});m(this,"createProgressElement",(e,r,i)=>{const o=B("video",["progress-video"],e);o.innerHTML="Your browser does not support the <code>audio</code> element.",o.controls=!0,BS(e,r),fa(i).then(s=>{const l=e.querySelector(".progress-video");l&&Qg(e)&&(l.src=s)})})}getAbstract(){return{mediaName:D.t(`media.${Yr.VIDEO}.menuItem`),mediaIcon:FT,menuItem:D.t(`media.${Yr.VIDEO}.menuItem`),order:700,mediaType:Yr.VIDEO,group:"common"}}getBlockProperties(){return{abstract:`${D.t(`media.${Yr.VIDEO}.abstract`)}`}}handleMediaError(e,r,i){const o=e.addCustom("video-resizer",()=>new Cx(e)),s=e.getBlockById(i);o.disableBlockResize(s)}updateMediaElement(e,r,i,o){const s=r.querySelector(":scope .video-container > video");p(Ptt,s,"The media element not exist"),s.src!==o&&(s.src=o),i.width?s.style.width=`${i.width}px`:s.style.width="";const l=e.getBlockById(i.id);return setTimeout(()=>{e.addCustom("video-resizer",()=>new Cx(e)).updateResizer(l)}),s}}const Ktt=new Ftt,kS=[lE,mE,gE,wk],Ex=[gS,VJ,XZ,itt,dtt,e$,vtt,Ktt,Ott,oW,Y4,KQ],RS=[Vk,tS,T4,jk];function Vtt(n,t,e){var i,o,s,l;li.level=(i=e.logLevel)!=null?i:Ds.DEBUG;const r=ku(n,t,{components:{blocks:[...kS,...((o=e==null?void 0:e.components)==null?void 0:o.blocks)||[]],embeds:[...Ex,...((s=e.components)==null?void 0:s.embeds)||[]],boxes:[...RS,...((l=e.components)==null?void 0:l.boxes)||[]],textRenders:[new $C],options:{...e.componentsOptions}}});return r.readonly=!0,r.addCustom("heading-collapse",()=>new ox(r)),r.addCustom("editor-tooltip",()=>new _0(r)),r.addListener("clickLink",(c,d,h)=>{var E;if((E=e==null?void 0:e.events)!=null&&E.onClickLink){e.events.onClickLink(c,d,h);return}const C=h.getAttribute("link");C&&(c.readonly||d.ctrlKey||d.metaKey)&&window.open(C,"_blank")}),r}class wS{constructor(t){this.createOptions=t,t.lang&&D.setLang(t.lang)}createHistoryEditor(t,e){return Vtt(t,e,this.createOptions)}}I("create-editor");function SS(n,{root:t,childDoc:e,doc:r}){var h,C;e.uploadResource=r.uploadResource.bind(r),e.buildResourceUrl=r.buildResourceUrl.bind(r);const i=n.getComponentOptions("comment"),o={image:{defaultAlign:"left"},table:{locatingContainer:t,hideCellMenu:!0,hideToolbar:!0},...i==null?void 0:i.componentsOptions},s=[];n.editorBlocks.forEach(E=>{E.blockType==="text"||E.blockType==="embed"||s.push(E)});const l=[];n.editorEmbeds.forEach(E=>{l.push(E)});const c=[];n.editorBoxes.forEach(E=>{E.boxType==="text"||E.boxType==="br"||E.boxType==="image"||E.boxType==="anchor"||c.push(E)});const d=ku(t,e,{shortcuts:[_h],components:{blocks:s,commandProviders:[new d0],decorators:[new K0],embeds:l,boxes:c,options:o}});if(d.input.addHandler(new $0),d.input.addHandler(new ME(d)),d.input.addHandler(new KE(d)),d.input.addHandler(new QX(d)),d.input.addHandler(new G0),d.addCustom("image-paste-handler",()=>new _E(d)),(h=n.options.componentsOptions)!=null&&h.mention){const E=n.options.componentsOptions.mention;d.addCustom("mention",()=>new Z4(d,{...E}))}if((C=n.options.componentsOptions)!=null&&C.comment){const E=n.options.componentsOptions.comment;E.onCommentEditorClick&&d.addListener("click",E.onCommentEditorClick)}return d}function $tt(n,t){const e=Array.from(n.rootContainer.querySelectorAll(`[comment-${t.toLocaleLowerCase()}="${t}"]`)),r=new Set;e.forEach(i=>{const o=et(i);o&&r.add(o)}),r.forEach(i=>{YX(n,i,t)})}class Htt{constructor(t){m(this,"listeners",new Set);m(this,"doc");this.editor=t,this.doc=this.editor.doc.externalDoc,this.doc.registerCallback(this)}getComments(){return this.doc.getComments()}getComment(t){return this.doc.getComment(t)}getCommentDoc(t){return this.doc.getCommentDoc(t)}localCreateComment(t,e){this.doc.localCreateComment(t,e)}localDeleteComment(t){const e=this.getComment(t);this.doc.localDeleteComment(t);const r=e.groupId;this.getComments().filter(o=>o.groupId===r).length===0&&$tt(this.editor,r)}localUpdateComment(t,e){this.doc.localUpdateComment(t,e)}onCreateComment(t,e){Array.from(this.listeners.values()).forEach(r=>r.onCreateComment(t,e))}onDeleteComment(t,e){Array.from(this.listeners.values()).forEach(r=>r.onDeleteComment(t,e))}onUpdateComment(t,e){Array.from(this.listeners.values()).forEach(r=>r.onUpdateComment(t,e))}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}createCommentEditor(t,e){return SS(this.editor,{root:t,childDoc:e,doc:this.doc})}allowEdit(t){return t.userId===this.doc.getUser().userId}}class jtt{constructor(t,e){m(this,"listeners",new Set);this.editor=t,this.localDoc=e}get doc(){return this.localDoc.toJSON()}getComments(){return Object.values(this.doc.comments)}getComment(t){return this.doc.comments[t]}getCommentDoc(t){const e=this.doc.comments[t];return Kp(e)}addListener(t){this.listeners.add(t)}removeListener(t){this.listeners.delete(t)}localCreateComment(t,e){}localDeleteComment(t){}localUpdateComment(t,e){}createCommentEditor(t,e){return SS(this.editor,{root:t,childDoc:e,doc:this.localDoc})}allowEdit(t){return t.userId===this.localDoc.getUser().userId}}const ztt={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}"}},Gtt={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}"}},Wtt={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"}};D.mergeLang({"zh-CN":ztt,"en-US":Gtt,"ja-JP":Wtt});function qtt(n){const r=new DOMParser().parseFromString(n,"text/html").querySelector("svg");if(!r)return null;const i=r.getAttribute("viewBox");if(!i)return null;const o=i.split(" ");if(o.length===4){const s=o[2],l=o[3];return r.setAttribute("width",s),r.setAttribute("height",l),r.outerHTML}return null}function xx(n,t,e=!0){const r=new Image,i=document.createElement("canvas"),o=i.getContext("2d");if(!o){t(new Error("failed to get context"),null);return}r.onload=()=>{if(i.width=r.naturalWidth,i.height=r.naturalHeight,e&&(i.width===0||i.height===0)){const s=n.substring(26);if(s){const l=atob(s),c=qtt(l);if(c){Fg(c,"image/svg+xml").then(d=>{xx(d,t,!1)});return}}t(null,null);return}o.drawImage(r,0,0),i.toBlob(s=>{t(null,s)},"image/png")},r.src=n}function Xtt(n){return new Promise((t,e)=>{xx(n,(r,i)=>{if(r){e(r);return}if(!i){e(new Error("Failed to get image blob"));return}t(i)})})}async function LS(n){const t=await fa(n);return new Promise((e,r)=>{xx(t,(i,o)=>{if(i){r(i);return}if(!o){r(new Error("Failed to get image blob"));return}e(o)})})}const IS="Untitled";function DS(n){const t=we(n.rootContainer);return!t||!nt(n,t)?IS:n.getBlockString(t)||IS}function Qtt(n){let t;return n.forEach((e,r)=>{r.toLocaleLowerCase()==="content-type"&&(t=e)}),t!=null?t:""}async function _S(n){try{const t=await fetch(n,{credentials:"same-origin"}),e=await t.blob(),r=Qtt(t.headers).toLocaleLowerCase();let i="";if(r){const s=yg.default[r].extensions;s&&s.length>0&&(i=s[0])}return new File([e],`${Date.now()}.${i}`,{type:r})}catch{return null}}const Ytt="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=",Jtt=()=>Pg(Ytt);async function Ztt(n){return new Promise((t,e)=>{const r=new Image;r.onload=()=>{t({width:r.naturalWidth,height:r.naturalHeight})},r.onerror=e,r.src=n})}async function MS(n,t){if(n.width&&n.height)return{width:n.width,height:n.height,buffer:t};const e=await fa(new File([t],"",{})),r=await Ztt(e);return r.width===void 0||r.height===void 0?{width:345,height:230,buffer:t}:n.width||n.height?{width:n.width||r.width*n.height/r.height,height:n.height||r.height*n.width/r.width,buffer:t}:{width:r.width,height:r.height,buffer:t}}function tet(n,t){let e=n.filter(s=>s!=null);const r=t-(e.length-1)*20,i=.87,o=e.reduce((s,l)=>s+l.width,0);return o>r&&(e=e.map(s=>({width:s.width*r/o,height:s.height*r/o,buffer:s.buffer}))),e.map(s=>({width:s.width*i,height:s.height*i,buffer:s.buffer}))}function eet(n,t,e){if(!e||typeof e!="object")return;const r=e,i=n.filter(s=>s!=null),o=t-(i.length-1)*20;i.forEach((s,l)=>{if(i.length===1&&r.widthPercent){const d=r.widthPercent,h=s.width;s.width=o*(d/100),s.height*=s.width/h;return}const c=`${l}_flex`;if(r[c]){const d=r[c],h=s.width;s.width=o*d,s.height*=s.width/h}})}function US(n=[0,1,2,3,4,5,6,7],t=1){return n.map(e=>{let r;switch(e%3){case 0:r=pt.LevelFormat.DECIMAL;break;case 1:r=pt.LevelFormat.LOWER_LETTER;break;default:r=pt.LevelFormat.LOWER_ROMAN;break}return{level:e,format:r,text:`%${e+1}. `,alignment:pt.AlignmentType.START,start:t,style:{paragraph:{indent:{left:pt.convertInchesToTwip(.3*(e+1)),hanging:pt.convertInchesToTwip(.2)}}}}})}function net(){return[0,1,2,3,4,5,6,7].map(n=>{let t;switch(n%3){case 0:t="\u2022";break;case 1:t="\u25E6";break;default:t="\u25AA";break}return{level:n,format:pt.LevelFormat.BULLET,text:t,alignment:pt.AlignmentType.START,style:{paragraph:{indent:{left:pt.convertInchesToTwip(.3*(n+1)),hanging:pt.convertInchesToTwip(.2)}}}}})}function ret(){return[0,1,2,3,4,5,6,7].map(n=>({level:n,format:pt.LevelFormat.BULLET,text:"\u2611",alignment:pt.AlignmentType.START,style:{paragraph:{indent:{left:pt.convertInchesToTwip(.3*(n+1)),hanging:pt.convertInchesToTwip(.2)}}}}))}function iet(){return[0,1,2,3,4,5,6,7].map(n=>({level:n,format:pt.LevelFormat.BULLET,text:"\u2610",alignment:pt.AlignmentType.START,style:{paragraph:{indent:{left:pt.convertInchesToTwip(.3*(n+1)),hanging:pt.convertInchesToTwip(.2)}}}}))}var Sf=(n=>(n.NUMBERING="number-numbering-reference",n.BULLET="number-bullet-reference",n.CHECKED="checked-bullet-reference",n.UNCHECKED="unchecked-bullet-reference",n))(Sf||{});const oet=[{levels:US(),reference:"number-numbering-reference"},{levels:net(),reference:"number-bullet-reference"},{levels:ret(),reference:"checked-bullet-reference"},{levels:iet(),reference:"unchecked-bullet-reference"}];function set(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 aet(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 cet(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 uet=/rgb\((\d+),\s*(\d+),\s*(\d+)\)/;function OS(n){if(typeof n=="string"&&n.length>0){if(n[0]==="#")return n.substring(1);const t=n.match(uet);if(t){const e=s=>{let l=Number(s).toString(16);return l.length<2&&(l=`0${l}`),l},r=e(t[1]),i=e(t[2]),o=e(t[3]);return`${r}${i}${o}`}if(n==="red")return"FF0000";if(n==="green")return"00FF00";if(n==="blue")return"0000FF"}}function sn(n,t){if(n&&n.attributes&&n.attributes[t])return n.attributes[t];if(n&&n.attributes&&n.attributes.box&&n.attributes.inputType&&t==="style-underline")return!0}function NS(n,t,e){for(let r=0;r<=e;++r){const i=`${t}${r}`;if(sn(n,i))return i}}function mm(n,t,e){n.attributes=n.attributes||{},n.attributes[t]=e}function Ax(n){return n==="image"||n==="drawio"||n==="plantuml"||n==="mermaid"||n==="flowchart"}function PS(n){return n&&n.startsWith("//")?`https:${n}`:n&&!n.startsWith("http://")&&!n.startsWith("https://")?`https://${n}`:n}function fet(n){const t=sn(n,"inlineStyle");if(t==null)return;const e=t.split(";");for(const r of e){const i=r.split(":");if(i.length!==2)continue;const o=i[0].trim().toLowerCase(),s=i[1].trim().toLowerCase();o==="font-size"&&mm(n,"inline-style-font-size",s),o==="color"&&mm(n,"inline-style-color",s),o==="background-color"&&mm(n,"inline-style-background-color",s),o==="font-family"&&mm(n,"inline-style-font-family",s)}}function det(n,t){if(t==null)return n==null?void 0:n.normal;if(n)return n[`heading${t}`]}function het(n){const t=`${sn(n,"inline-style-font-size")}`;if(t&&t.indexOf("px")>0)return+t.replace(/px/g,"")}function met(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 get(n){if(n.attributes&&n.attributes.box&&n.attributes.text)return` @${n.attributes.text} `}function pet(n){return sn(n,"inline-style-font-family")}function Cet(n){const t=sn(n,"inline-style-background-color");return OS(t)}function Eet(n){const t=sn(n,"inline-style-color");return OS(t)}function xet(n){fet(n);const t=sn(n,"type")==="mention";return{box:n.attributes&&n.attributes.box?n.attributes:void 0,inlineCode:!!sn(n,"style-code"),link:PS(sn(n,"link")),size:het(n),text:t?get(n):met(n)||n.insert,bold:!!sn(n,"style-bold"),underline:!!sn(n,"style-underline"),italics:!!sn(n,"style-italic"),strike:!!sn(n,"style-strikethrough"),superScript:!!sn(n,"style-super"),subScript:!!sn(n,"style-sub"),math:sn(n,"type")==="math"?sn(n,"src"):void 0,mention:t,fontFamily:pet(n),background:Cet(n),color:t?"338fe5":set(NS(n,"style-color-",6))||Eet(n),highlight:NS(n,"style-bg-color-",13)}}function Aet(){return[new pt.Paragraph({border:{top:{color:"auto",style:pt.BorderStyle.DASHED,size:4,space:1}},spacing:{before:300}}),new pt.Paragraph({spacing:{line:0}})]}function bet(){return new pt.Paragraph({children:[new pt.TextRun({text:"[\u89C6\u9891\u6682\u4E0D\u652F\u6301\u5BFC\u51FA]",shading:{type:pt.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}})]})}function vet(){return new pt.Paragraph({children:[new pt.TextRun({text:"[\u97F3\u9891\u6682\u4E0D\u652F\u6301\u5BFC\u51FA]",shading:{type:pt.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}})]})}function Bet(n,t){return new pt.Paragraph({children:[new pt.ExternalHyperlink({children:[new pt.TextRun({style:"Hyperlink",text:t||n})],link:n})]})}function FS(n){if(n.heading!=null)return`Heading${n.heading}`}function KS(n){if(n.alignment!=null){if(n.alignment==="center")return pt.AlignmentType.CENTER;if(n.alignment==="right")return pt.AlignmentType.RIGHT;if(n.alignment==="left")return pt.AlignmentType.LEFT}}function Tet(n){if(n.indent)return{left:pt.convertInchesToTwip(.3*n.indent-.2)};if(n.padding)return{left:pt.convertInchesToTwip(.3*n.padding)}}function yet(n){return{type:pt.ShadingType.CLEAR,color:"FFFFFF",fill:n}}function ket(n){const t=n.split(",");if(t.length!==0)return t[0].trim()}function VS(n,t){let e;e=n.inlineCode?"InlineCode":void 0,e=n.link?"Hyperlink":e;const r=n.size||t,i=r!=null?Math.floor(r*1.5+.5):void 0;return new pt.TextRun({text:n.text,bold:n.bold||void 0,underline:n.underline?{type:pt.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:i,style:e,font:n.fontFamily?ket(n.fontFamily):void 0,shading:n.background?yet(n.background):void 0,color:n.color,highlight:aet(n.highlight)})}function Ret(n,t){if(n.link)return new pt.ExternalHyperlink({children:[VS(n,t)],link:n.link})}async function $S(n,t,e,r,i){const o=await i(n,t,e);if(o==null)return;const s=await MS({width:r||0,height:0,src:e},o);return new pt.ImageRun({data:o,transformation:{width:s.width||100,height:s.height||20}})}function wet(n){if(n.heading||n.heading)return n.heading}function Let(n){if(n.align&&(n.align==="center"||n.align==="right"||n.align==="left"))return n.align}function Iet(n){if(n.textOnly===!0&&n.level!=null)return n.level}async function Det(n,t){var r;const e=[];if(n.text&&Array.isArray(n.text)){for(let i=0;i<n.text.length;i++){const o=n.text[i];if(((r=o.attributes)==null?void 0:r.box)===!0&&t){const s=await t(o);if(s){n.text.splice(i+1,0,...s);continue}}e.push(xet(o))}return e}}function _et(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 Met(n,t){if(n.type==="embed"&&n.embedType&&Ax(n.embedType)&&n.embedData&&n.embedData.src)return n.embedData.src.split("|").map(r=>{const i=t(r),o=n.embedData[`${i}_width`],s=n.embedData[`${i}_height`];return{src:r,width:o,height:s}})}function Uet(n){if(n.padding)return n.padding}function Oet(n){return!!(n.type==="embed"&&n.embedType&&Ax(n.embedType)&&n.embedData&&n.embedData.src)}async function gm(n,t,e){return{quoted:!!n.quoted,heading:wet(n),alignment:Let(n),indent:Iet(n),padding:Uet(n),texts:await Det(n,e),list:_et(n),images:Met(n,t),border:Oet(n)}}async function Net(n,t,e,r){const i=[];if(!n.children)return[];for(const o of n.children){const s=[];for(const l of t.blocks[o])s.push(await gm(l,e,r));i.push(s)}return i}const Pet=I("to-docx");function Fet(n,t){return Array(n).fill(0).map(()=>Array(t).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 Ket(n,t,e,r){const i=!!n.hasColTitle,o=!!n.hasRowTitle,s=!!n.isStripeStyle,l="F5F8FB";for(let c=0;c<t;c++)for(let d=0;d<e;d++)(i&&d===0||o&&c===0||s&&c%2===1)&&(r[c][d].color=l)}function Vet(n){p(Pet,n.children,"no table children");const t=n.rows,e=n.cols,r=n.colsWidth;if(r)for(let s=0;s<r.length;s++)r[s]===0&&(r[s]=100);const i=Fet(t,e);let o=0;for(let s=0;s<t;++s)for(let l=0;l<e;++l){if(i[s][l].originalWidth=r?r[l]:void 0,i[s][l].from!==void 0)continue;const c=n.children[o];o+=1,i[s][l].cellId=c,i[s][l].color=cet(n[`${c}_background`]),i[s][l].width=r?r[l]:100,i[s][l].align=n[`${c}_align`];const d=n[`${c}_rowSpan`]||1,h=n[`${c}_colSpan`]||1;if(i[s][l].rowSpan=d,i[s][l].colSpan=h,d>1||h>1){let C=0;for(let E=0;E<d;E++)for(let A=0;A<h;A++)E===0&&(C+=r?r[l+A]:80),!(E===0&&A===0)&&(i[s+E][l+A].from=[s,l]);i[s][l].width=C}}return Ket(n,t,e,i),i}async function $et(n,t,e,r,i,o,s,l,c,d){async function h(A){if(l){const v=await l(i,o,A);if(v){await r.addDoc(n,v,d);return}}if(A.type==="text"||A.textOnly===!0){const v=await gm(A,s,c);await r.addTextBlock(v);return}if(A.type==="code"){const v=await Net(A,e,s,c);await r.addCodeBlockObject(v);return}if(A.type==="list"&&A.textOnly!==!0){const v=await gm(A,s,c);await r.addListBlockObject(n,v);return}if(A.type==="embed"&&A.embedType){const v=A,R=v.embedData,L=v.embedType;if(Ax(L)){const M=await gm(A,s,c);await r.addImagesBlockObject(A,M,d)}else A.embedType==="hr"?r.addSeparatorBlock():A.embedType==="video"?r.addVideoPlaceholder():A.embedType==="audio"?r.addAudioPlaceholder():A.embedType==="webpage"?r.addHyperlinkParagraph(PS(R.src),R.title):r.addOtherEmbedBlock(L,A.embedData);return}if(A.type==="table"){let v=[];if(A.colsWidth)v=A.colsWidth;else{const L=A.cols;v=new Array(L);for(let M=0;M<v.length;M++)v[M]=100;A.colsWidth=v}const R=Vet(A);await r.addTableMatrix(v,R,e),r.addEmptyParagraph()}}function C(A){const v=[];for(const{type:R,data:L}of A.embedData.exportSpec){if(R==="text"){const M={id:Z(),text:[{insert:L}],type:"text"};v.push(M);continue}if(R==="image"){const M={id:Z(),type:"embed",embedType:"image",align:"left",embedData:{src:L}};v.push(M);continue}if(R==="link"){const M={id:Z(),type:"embed",embedType:"webpage",embedData:{src:L.url,title:L.title}};v.push(M);continue}}return v}function E(A){var v;return(v=A==null?void 0:A.embedData)!=null&&v.exportSpec?C(A):[A]}for(const A of t)for(const v of E(A))await h(v)}function Het(){return{listMaxInst:1,listInstMap:{},listRefMap:{},levelConfigs:[]}}const jet=I("to-docx");class zet{constructor(t,e,r,i,o,s){m(this,"paragraphs");this.appId=t,this.docId=e,this.state=r,this.readImageFunc=i,this.convertBlocksFunc=o,this.defaultFontSize=s,this.paragraphs=[]}async addTextBlock(t){this.paragraphs.push(new pt.Paragraph({heading:FS(t),alignment:KS(t),children:await this.paragraphsFromBlockTexts(t),indent:Tet(t)}))}async addEmptyImagePlaceHolder(){this.paragraphs.push(new pt.Paragraph({text:`[${D.t("docx.imageExportFailed")}]`,shading:{type:pt.ShadingType.CLEAR,color:"FFFFFF",fill:"CCCCCC"}}))}async paragraphsFromBlockTexts(t){if(t.texts==null)return;const e=det(this.defaultFontSize,t.heading),r=[];for(const i of t.texts){if(i.link){const o=Ret(i,e);o&&r.push(o);continue}if(i.box&&i.box.type&&i.box.type==="br"){r.push(new pt.TextRun({text:"",break:1}));continue}if(i.box&&i.box.type&&i.box.type==="image"){const o=await $S(this.appId,this.docId,i.box.src,i.box.width,this.readImageFunc);o&&r.push(o);continue}if(i.math){const o=await $S(this.appId,this.docId,i.math,0,this.readImageFunc);o&&r.push(o);continue}r.push(VS(i,e))}return r}async addCodeBlockObject(t){for(const e of t)for(const r of e){const i={style:pt.BorderStyle.SINGLE,color:"#DEDEDE"};this.paragraphs.push(new pt.Paragraph({style:"Code",border:{left:{...i},right:{...i},top:{...i},bottom:{...i}},children:await this.paragraphsFromBlockTexts(r)}))}}async addListBlockObject(t,e){if(e.list==null)return;let r;const i=e.list.checkbox?`${t}-${e.list.groupId}-${e.list.checkbox}`:`${t}-${e.list.groupId}`;if(this.state.listInstMap[i])r=this.state.listInstMap[i];else if(r=this.state.listMaxInst,this.state.listMaxInst+=1,this.state.listInstMap[i]=r,e.list.start>0&&e.list.ordered){const s=`number-numbering-reference-${r}`,l=US([e.list.level-1],e.list.start);this.state.levelConfigs.push({levels:l,reference:s,inst:r}),this.state.listRefMap[i]=s}else e.list.ordered?this.state.listRefMap[i]=Sf.NUMBERING:e.list.checkbox&&e.list.checkbox==="checked"?this.state.listRefMap[i]=Sf.CHECKED:e.list.checkbox&&e.list.checkbox==="unchecked"?this.state.listRefMap[i]=Sf.UNCHECKED:this.state.listRefMap[i]=Sf.BULLET;const o=FS(e);e.texts&&this.paragraphs.push(new pt.Paragraph({heading:o,children:await this.paragraphsFromBlockTexts(e),numbering:{reference:this.state.listRefMap[i],level:e.list.level-1,instance:r}}))}imageDimWithBufferToImageRun(t){return new pt.ImageRun({data:t.buffer,transformation:{width:t.width,height:t.height}})}async addImagesBlockObject(t,e,r){if(e.images==null){if(t.type==="embed"&&t.embedType==="image"){const{src:c}=t.embedData;c||this.addEmptyImagePlaceHolder()}return}const i=[],o=await Promise.all(e.images.map(async c=>{const d=await this.readImageFunc(this.appId,this.docId,c.src);if(d)return MS(c,d);i.push(c.src)}));eet(o,r,t.embedData);const s=tet(o,r),l={style:pt.BorderStyle.SINGLE,color:"#DEDEDE"};s.length&&this.paragraphs.push(new pt.Paragraph({border:e.border?{left:{...l},right:{...l},top:{...l},bottom:{...l}}:void 0,alignment:KS(e)||pt.AlignmentType.CENTER,children:s.map(c=>this.imageDimWithBufferToImageRun(c)).flatMap((c,d,h)=>c==null?[]:h.length-1!==d?[c,new pt.TextRun({text:" "})]:c)})),i.forEach(c=>{this.addHyperlinkParagraph(c)})}addSeparatorBlock(){Aet().forEach(t=>this.paragraphs.push(t))}addEmptyParagraph(){this.paragraphs.push(new pt.Paragraph(""))}addVideoPlaceholder(){this.paragraphs.push(bet())}addAudioPlaceholder(){this.paragraphs.push(vet())}addHyperlinkParagraph(t,e){t!=null&&this.paragraphs.push(Bet(t,e))}async addTableMatrix(t,e,r){const i=t.map(o=>o!==0?o*15:1500);this.paragraphs.push(new pt.Table({rows:await this.generateTableRows(e,r),columnWidths:i}))}async generateRowCells(t,e){const r=[];for(const i of t){const o=i.cellId;if(o===void 0)continue;const s=i.width*.9;r.push(new pt.TableCell({children:await this.convertBlocksFunc(o,e.blocks[o],e,this.appId,this.docId,this.state,s),columnSpan:i.colSpan,rowSpan:i.rowSpan,width:{type:pt.WidthType.DXA,size:i.width*15},shading:i.color?{fill:i.color,type:pt.ShadingType.CLEAR,color:"auto"}:void 0}))}return r}async generateTableRows(t,e){const r=[];for(const i of t)r.push(new pt.TableRow({children:await this.generateRowCells(i,e)}));return r}async addDoc(t,e,r){const i=await this.convertBlocksFunc(t,e.blocks.root,e,this.appId,this.docId,this.state,r);i&&(this.paragraphs=this.paragraphs.concat(i))}async addOtherEmbedBlock(){}}class Get{constructor(t,e,r,i,o,s,l,c){m(this,"convertBlocks",async(t,e,r,i,o,s,l=720)=>{const c=new zet(i,o,s,this.readImage,this.convertBlocks,this.defaultFontSize);return await $et(t,e,r,c,i,o,this.md5HexFunc,this.getDocByBlock,this.getTextsByBox,l||720),c.paragraphs});this.templateData=t,this.docData=e,this.md5HexFunc=r,this.readImage=i,this.defaultFontSize=o,this.getDocByBlock=s,this.getTextsByBox=l,this.backgroundImageOptions=c}async convert(t,e){return this.snapshot2docx(this.docData,t,e)}async snapshot2docx(t,e,r){const i=new pt.ImportDotx,o=this.templateData?await i.extract(this.templateData):void 0,s=t.blocks.root;p(jet,s,"data must have blocks");const l=Het(),c=await this.convertBlocks("blocks",s,t,e,r,l),d=this.backgroundImageOptions?{default:new pt.Header({children:[new pt.Paragraph({children:[new pt.ImageRun(this.backgroundImageOptions)]})]})}:{},h=new pt.Document({numbering:{config:[...oet,...l.levelConfigs]},sections:[{headers:d,children:c,properties:{page:{size:{width:12240,height:15840},margin:{top:1440,bottom:1440,left:1440,right:1440}}}}]},{template:o});return pt.Packer.toBlob(h)}}async function Wet(n,t,e,r){const i=n.doc.buildResourceUrl(r,{withToken:!0});let o=await _S(i);if(!o)return;if(o.type.indexOf("/svg")!==-1){const l=await LS(o);l&&(o=new File([l],o.name))}return await o.arrayBuffer()}async function qet(n,t,e){const r=n.editorBlocks.getBlockClass(e.type);if(r.toStandardDoc)return r.toStandardDoc(n,e,t)}async function Xet(n,t){const e=t.attributes,r=n.editorBoxes.getBoxClass(e.type);if(r.toStandardText)return r.toStandardText(n,e)}async function Qet(n,t){let{template:e,download:r,backgroundImageOptions:i}=t!=null?t:{};e||(e=Jtt());const o=n.doc.toJSON(),s=(C,E,A)=>Wet(n,C,E,A),l=async(C,E,A)=>qet(n,o,A),c=async C=>Xet(n,C),h=await new Get(e,o,kd.default,s,void 0,l,c,i).convert("_appId","_docId");if(r){const C=URL.createObjectURL(h),E=document.createElement("a");E.setAttribute("download",`${DS(n)}.docx`),E.setAttribute("href",`${C}`),E.click(),E.remove()}return h}const bx=I("create-editor");async function Yet(n,t){var s,l,c,d,h,C,E,A,v,R,L,M,U,F;p(bx,n,"app does not exists"),t.lang&&D.setLang(t.lang),li.level=(s=t.logLevel)!=null?s:Ds.DEBUG;const e=t.onReauth?async()=>{var at;const G=t.user.userId,W=t.docId,it=await((at=t.onReauth)==null?void 0:at.call(t,G,W,t.permission));return{userId:G,docId:W,permission:t.permission,appId:t.appId,token:it,displayName:t.user.displayName,avatarUrl:t.user.avatarUrl}}:void 0,r={auth:{appId:t.appId,docId:t.docId,userId:t.user.userId,permission:t.permission,token:t.token,displayName:t.user.displayName,avatarUrl:t.user.avatarUrl},serverUrl:t.serverUrl,reauthFunc:e,disableLogout:t.disableLogout},i=await Nu.load(r),o=ku(n,i,{id:t.id,scrollContainer:t==null?void 0:t.scrollContainer,enableComments:t==null?void 0:t.enableComments,components:{blocks:[...kS,...((l=t==null?void 0:t.components)==null?void 0:l.blocks)||[]],embeds:[...Ex,...((c=t.components)==null?void 0:c.embeds)||[]],boxes:[...RS,...((d=t.components)==null?void 0:d.boxes)||[]],commandProviders:[new d0,...((h=t.components)==null?void 0:h.commandProviders)||[]],decorators:[new K0,new $p],insertions:[H1],blockHooks:[new wE,new ZR,...((C=t.components)==null?void 0:C.blockHooks)||[]],textRenders:[new p4,new $C],options:{...t.componentsOptions}},shortcuts:[aQ,Nj,XG,aE,Vw,VK,nE,GQ,_h,MK,...t.shortcuts||[]],colors:["#0064FF","#EB3723","#F59300","#00A865","#F25A0A","#70A310","#009CAD","#0990D9","#8851ED","#D62069"]});if(o.editorCommandProviders.registerCommandProvider(new wi(o)),o.input.addHandler(new UY),o.input.addHandler(new $0),o.input.addHandler(new s$),o.input.addHandler(new VG),o.input.addHandler(new pE(o,{hideTitle:t.hideTitle,headingLevel:1,titlePlaceholder:D.t("placeholder.common.title"),contentPlaceholder:D.t("placeholder.common.content"),readonlyTitlePlaceholder:D.t("placeholder.common.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0})),o.input.addHandler(new D0(o,(E=t.componentsOptions)==null?void 0:E.quickMenu)),o.input.addHandler(new ME(o)),o.input.addHandler(new KE(o)),o.input.addHandler(new G0),o.doc.registerCallback(new OY(o)),o.addCustom("remote-cursor",()=>new lT(o)),o.addCustom("block-menu",G=>new nw(G)),me.isMobile||o.addCustom("editor-tooltip",()=>new _0(o)),t!=null&&t.enableComments&&o.addCustom("editor-comments",G=>new g4(G,new Htt(G))),t!=null&&t.enableContextMenu&&o.addCustom("editor-context-menu",G=>new zw(G)),o.addCustom("create-options",()=>new Tb(o,t)),o.addCustom("drop-target",()=>new Cf(o)),o.addCustom("list-to-mindmap",()=>new y0(o)),o.addCustom("list-to-mention",()=>new nJ(o)),o.addCustom("mobile-helper",()=>new xJ(o)),o.addCustom("code-caret",()=>new _j(o)),o.addCustom("image-paste-handler",()=>new _E(o)),(A=t.componentsOptions)!=null&&A.mention){const G=t.componentsOptions.mention;o.addCustom("mention",()=>new Z4(o,G))}if(t!=null&&t.enableContextMenu&&o.addCustom("editor-context-menu",G=>new zw(G)),o.addCustom("heading-collapse",()=>new ox(o)),ec.register(o),Cf.register(o),gs.register(o),cs.register(o),o.addListener("clickLink",(G,W,it)=>{var xt;if((xt=t==null?void 0:t.events)!=null&&xt.onClickLink){t.events.onClickLink(G,W,it);return}const at=it.getAttribute("link");at&&(G.readonly||W.ctrlKey||W.metaKey)&&window.open(at,"_blank")}),(R=(v=t.componentsOptions)==null?void 0:v.remoteCarets)!=null&&R.onUserChanged){const G=(M=(L=t.componentsOptions)==null?void 0:L.remoteCarets)==null?void 0:M.onUserChanged;o.doc.getRemoteUsers().on("change",W=>{G(o,W)})}return(F=(U=t.componentsOptions)==null?void 0:U.templates)!=null&&F.templates.length&&(o.addListener("docChanged",()=>{dm(o)}),o.addListener("resize",()=>{dm(o,{reset:!0})}),setTimeout(()=>{dm(o)},100)),o.doc.registerCallback({onError:async G=>{if(G.code==="ResetDoc"){bx.error(`reset doc: ${G.message}`);const W=await Nu.load(r);o.doc.reset(W)}}}),o}function Jet(n){return n.toJSON!==void 0}async function Zet(n,t,e){var o,s,l,c,d,h;p(bx,n,"app does not exists");const r=Jet(t)?t:new bp(t,{serverUrl:e.serverUrl||""});e.lang&&D.setLang(e.lang),li.level=(o=e.logLevel)!=null?o:Ds.DEBUG;const i=ku(n,r,{id:e.id,scrollContainer:e==null?void 0:e.scrollContainer,components:{blocks:[lE,mE,gE,wk],commandProviders:[new d0],decorators:[new K0,new $p],embeds:[...Ex,...((s=e.components)==null?void 0:s.embeds)||[]],boxes:[Vk,tS,T4,jk,...((l=e.components)==null?void 0:l.boxes)||[]],insertions:[H1],blockHooks:[new wE,...((c=e.components)==null?void 0:c.blockHooks)||[]],textRenders:[new p4,new $C,...((d=e.components)==null?void 0:d.textRenders)||[]],options:{...e.componentsOptions}},shortcuts:[aE,Vw,nE,_h]});return i.editorCommandProviders.registerCommandProvider(new wi(i)),i.input.addHandler(new $0),i.input.addHandler(new pE(i,{hideTitle:e.hideTitle,headingLevel:1,titlePlaceholder:D.t("placeholder.common.title"),contentPlaceholder:D.t("placeholder.common.content"),readonlyTitlePlaceholder:D.t("placeholder.local.readonlyTitle"),addPlaceholderToAllCurrentEmptyBlock:!0})),i.input.addHandler(new D0(i,(h=e.componentsOptions)==null?void 0:h.quickMenu)),i.input.addHandler(new ME(i)),i.input.addHandler(new KE(i)),i.input.addHandler(new G0),i.addCustom("block-menu",C=>new nw(C)),me.isMobile||i.addCustom("editor-tooltip",()=>new _0(i)),i.addCustom("image-paste-handler",()=>new _E(i)),e!=null&&e.enableComments&&i.addCustom("editor-comments",C=>new g4(C,new jtt(C,r))),i.addCustom("heading-collapse",()=>new ox(i)),i.addListener("clickLink",(C,E,A)=>{var R;if((R=e==null?void 0:e.events)!=null&&R.onClickLink){e.events.onClickLink(C,E,A);return}const v=A.getAttribute("link");v&&(C.readonly||E.ctrlKey||E.metaKey)&&window.open(v,"_blank")}),ec.register(i),i}async function tnt(n,t,e){var h;const r=n.doc.externalDoc.client.auth,i=await zh.load({auth:r,serverUrl:e});if(!((h=i.getVersionHelper)==null?void 0:h.call(i)))throw new Error("the editor does not support to show versions");const s=n.getCustom("create-options");if(!s)throw new Error("the editor does not support to show versions");const l=s.getData(),c=new wS(l),d=n.addCustom("version-dialog",()=>new K4(i,c));return d.show(t),d}b.tippy=J6,b.AnchorBox=SB,b.AuthError=jh,b.AuthHeader=il,b.AutoScroll=Vd,b.BaseURLHeader=Na,b.BasicCommands=wV,b.BlockExclusiveHook=ZR,b.BlockLockerHook=wE,b.BlockLockerPasteHandler=G0,b.BlockResizer=lf,b.BrBox=yB,b.CodeBlock=mE,b.CodeLineBlock=gE,b.CodeTextDecorator=K0,b.DefaultShortcuts=_h,b.DocIdError=TN,b.DragDrop=Hb,b.DrawioEmbed=gS,b.EditorBlocks=Zv,b.EditorBoxes=RB,b.EditorCommandProviders=A2,b.EditorComplexBlockPosition=Ur,b.EditorComplexSelectionRange=di,b.EditorDecorators=_B,b.EditorEmbeds=e3,b.EditorInsertions=DB,b.EditorSimpleBlockPosition=We,b.EditorSimpleSelectionRange=tn,b.EmbedBlock=r3,b.EmbedBlockResizer=yf,b.EnforceWithDocumentTitleHandler=pE,b.EventCallbacks=sa,b.FILL_CHAR=q_,b.FileExtError=yN,b.GroupOrder=_k,b.HeadingBlockScrollListener=QY,b.ImageBox=wB,b.InlineBoxCommandProvider=zk,b.InputtingInsertion=LB,b.LocalDoc=bp,b.LogLevel=Ds,b.Logger=li,b.MIN_DISTANCE_THRESHOLD=Vb,b.ManualCloseDialog=Fu,b.ManualMenu=Zo,b.ManualToolbar=Pu,b.MarkdownInputHandler=$0,b.MaxUserError=_p,b.Mindmap=T0,b.OnesEditorAutoSuggest=cC,b.OnesEditorCustomDataWrapper=Tb,b.OnesEditorExclusiveBlock=cs,b.OnesEditorHoveringBlock=Be,b.OnesEditorIcons=uP,b.OnesEditorQuickMenu=D0,b.OnesEditorToc=Rf,b.OnesEditorTocProvider=gs,b.OnesEditorToolbar=ec,b.OnesEditorTooltip=_0,b.OnesEditorVersionsDialog=K4,b.PermissionError=BN,b.Popup=Va,b.RemoteCarets=lT,b.RemoteCaretsDecorator=$p,b.RemoteCaretsInsertion=H1,b.RemoteUsers=Ru,b.RequestReloadError=Ou,b.RichText=fn,b.ShareDBDoc=Nu,b.ShareDBDocVersionsProvider=wS,b.ShareDBServer=zh,b.SimpleCache=Db,b.StandardEmbedBlockCommands=JE,b.TEXT_STYLE_BACKGROUND_COLOR_PREFIX=b1,b.TEXT_STYLE_COLOR_PREFIX=A1,b.TableBlock=lE,b.TableBlockCommandProvider=d0,b.TableShortcuts=aE,b.TextBlock=On,b.TextBox=TB,b.TextColorItem=yy,b.TextStyleShortcuts=nE,b.TocEmbed=Y4,b.ZERO_WIDTH_SPACE_CHAR=Qc,b.abbreviation=$d,b.addAttribute=ih,b.addClass=z,b.addCommentToBlock=Tf,b.addDays=sI,b.addMetaToDoc=Ia,b.addMonths=oI,b.animateScrollTo=ca,b.applyPlaceholderToBlock=of,b.assert=p,b.autoShowHideTemplates=dm,b.blockToDoc=pp,b.blockToHtml=G1,b.blockToMarkdown=Ah,b.blockToText=xh,b.blocksToDoc=EU,b.clearAllSelection=Ov,b.clientType=me,b.cloneBlock=qo,b.cloneChildContainer=np,b.cloneDoc=rp,b.cloneText=mB,b.commentToShareDbComment=Vp,b.compareElement=_d,b.comparePosition=i1,b.complexBlockAdjustSelectionPos=Qd,b.complexBlockFindNearestChildBlock=l3,b.complexBlockGeFirstSimpleChild=s1,b.complexBlockGetAllChildContainers=An,b.complexBlockGetBottomChildContainers=s3,b.complexBlockGetLastSimpleChild=pa,b.complexBlockGetSelectedContainers=ga,b.complexBlockGetTopChildContainers=o3,b.containerToDoc=G5,b.continuousScroll=sv,b.convertBlockFrom=Wd,b.convertImageFileToPng=LS,b.convertImageSrcToPng=Xtt,b.converterIntercept=V0,b.copyBlockAttributes=GB,b.copyResourcesFromDoc=Ap,b.createBlockAnchor=Yi,b.createBlockCaretAnchor=u3,b.createBlockContentElement=Hs,b.createBlockElement=Rv,b.createBlockSimpleDocRange=mh,b.createBlockSimpleRange=Te,b.createBoxContentElement=Lv,b.createBoxElement=wv,b.createBoxOp=hB,b.createChildContainer=Yv,b.createComplexBlockPosition=xe,b.createComplexDocPos=AB,b.createComplexDocRange=Y_,b.createContainer=CB,b.createContainerElement=Gg,b.createDeleteOps=cB,b.createEditor=ku,b.createEditorSelectionRange=qe,b.createElement=B,b.createEmptyContainer=no,b.createEmptyDoc=eo,b.createEmptyTextBlockData=dh,b.createExpandedRange=Id,b.createIconButton=Ms,b.createImage=Rg,b.createInsertOps=uh,b.createInsertionContentElement=_v,b.createInsertionElement=Iv,b.createLocalEditor=Zet,b.createOnesEditor=Yet,b.createRange=_b,b.createRichText=Zs,b.createRootContainer=Qv,b.createSimpleBlockPosition=lt,b.createSimpleDocPos=xB,b.createTextBlockData=pi,b.createTextButton=hl,b.createTextOp=gr,b.createTextWithReplaceSoftReturn=_1,b.daysAfter=Vg,b.deleteText=U1,b.diffDays=lI,b.disablePageScroll=tv,b.docToHtml=VB,b.docToHtmlFragment=Ba,b.docToMarkdown=$B,b.docToText=ro,b.downloadImageToFile=_S,b.downloadObjectToFile=dx,b.downloadSvgToString=sS,b.editLink=Qu,b.editorAddComment=ZX,b.editorAddTextAttribute=r5,b.editorAutoInsertBlock=WB,b.editorBreakTextBlock=Ra,b.editorClearCompositionText=Q1,b.editorClearSelectedContents=yh,b.editorCopyBlock=Dh,b.editorDeleteBlock=Z1,b.editorDeleteBlockText=Y1,b.editorDeleteBlockWithoutChildren=Bh,b.editorDeleteChildContainer=QM,b.editorDeleteChildContainers=qB,b.editorFocusToBlock=ep,b.editorFocusToEnd=pU,b.editorGetBlockData=Wo,b.editorGetBlockText=bn,b.editorGetBlockTextEx=ph,b.editorGetBoxData=vB,b.editorHandleKeyboardEvent=r2,b.editorInsertBlock=ka,b.editorInsertBoxToBlock=jB,b.editorInsertDoc=e5,b.editorInsertDocAt=ip,b.editorInsertText=X1,b.editorInsertTextToBlock=HB,b.editorInsertTextToBlockEx=q1,b.editorMergeTextBlock=XB,b.editorMoveDown=p5,b.editorMoveEnd=fp,b.editorMoveHome=k5,b.editorMoveLeft=h5,b.editorMoveLineEnd=M5,b.editorMoveLineHome=_5,b.editorMovePageDown=K5,b.editorMovePageUp=F5,b.editorMoveRight=m5,b.editorMoveUp=g5,b.editorMoveWordEnd=B5,b.editorMoveWordLeft=v5,b.editorRangeClearColor=o5,b.editorRangeGetColor=s5,b.editorRangeSetColor=i5,b.editorRemoveTextAttribute=tU,b.editorReplaceBlockText=kh,b.editorReplaceContainer=n5,b.editorRunOnce=vp,b.editorSelectAll=mp,b.editorSelectContainer=Sh,b.editorSelectDown=C5,b.editorSelectEnd=dp,b.editorSelectHome=R5,b.editorSelectLeft=E5,b.editorSelectLineEnd=D5,b.editorSelectLineHome=I5,b.editorSelectPageDown=$5,b.editorSelectPageUp=V5,b.editorSelectRight=x5,b.editorSelectUp=A5,b.editorSelectWordEnd=y5,b.editorSelectWordLeft=T5,b.editorSetTextColor=wa,b.editorShowFindDialog=zq,b.editorToDocx=Qet,b.editorUpdateBlockData=Rh,b.editorUpdateCompositionText=zB,b.editorUpdateEmbedData=ZB,b.enablePageScroll=ev,b.escapeHtmlText=Ud,b.escapeRegExp=zg,b.escapeSpace=H9,b.exclusiveBlock=yE,b.executeBlockCommand=zv,b.executeEmbedBlockCommand=jv,b.executeRangeCommand=x2,b.fileToDataUrl=fa,b.findAfterOffsetNotType=K1,b.findAllText=N1,b.findBlockByIndex=Cv,b.findEventTargetBlock=Nb,b.findInsertionById=Dv,b.findNextOffset=CM,b.findNextVisibleSimpleBlock=y2,b.findPrevOffset=pM,b.findPrevOffsetNotType=F1,b.findPrevSimpleBlockBeforeChildContainer=i3,b.findPrevVisibleSimpleBlock=T2,b.findTarget=aa,b.findWordEnd=$1,b.findWordLeft=V1,b.format=nu,b.formatBytes=lv,b.formatDate=Hg,b.fragmentToHtml=nv,b.fromBase64=Zc,b.fromBase64ToBlob=Pg,b.fromBase64ToUint8Array=tI,b.fromDocRange=$o,b.fromNowString=jg,b.genId=Z,b.getAllChildBlocks=c1,b.getAllQuickMenuItems=eE,b.getAllSelectedBlocks=hi,b.getAttributesAt=Aa,b.getBlockBackground=kv,b.getBlockByIndex=zi,b.getBlockCaretRect=_r,b.getBlockClass=Yt,b.getBlockClassByType=Ks,b.getBlockClientRects=qi,b.getBlockCommandsWithHook=Zg,b.getBlockContent=Ot,b.getBlockId=st,b.getBlockIndex=bt,b.getBlockInfo=df,b.getBlockKind=Ir,b.getBlockMinWidth=Pv,b.getBlockNearestRangeFromPoint=l1,b.getBlockOptions=AI,b.getBlockPath=Vo,b.getBlockProperties=Vv,b.getBlockRangeFromPoint=Yd,b.getBlockStyles=xI,b.getBlockTextLength=dt,b.getBlockTools=re,b.getBlockType=St,b.getBoxContent=lu,b.getBoxId=Sv,b.getBoxTypeFromElement=su,b.getChildBlockCount=Lr,b.getChildBlocks=ue,b.getChildOffset=zo,b.getColorFromAttributes=B1,b.getColorFromContent=Hd,b.getComplexBlockClass=Qn,b.getContainerBlockPath=Wv,b.getContainerBlocks=Uv,b.getContainerBlocksElement=ru,b.getContainerById=ui,b.getContainerId=ft,b.getContainerMinWidth=n1,b.getContainerToolsElement=pI,b.getContainerWidth=Jv,b.getDistanceSquare=$i,b.getElementOffset=Xc,b.getElementScale=fr,b.getEmbedType=Ge,b.getExistsBlockTools=zd,b.getExistsContainerById=jd,b.getFileExt=eu,b.getFirstChildBlock=we,b.getFirstClientRect=Dd,b.getHeadingMenuOptions=XC,b.getHorizontalPadding=Sg,b.getInsertionContent=Xg,b.getLastChildBlock=Ze,b.getLastClientRect=Us,b.getListAllNextBrothers=Qa,b.getLogger=I,b.getNextBlock=qt,b.getNextValidOffset=Ys,b.getNextVisibleBlock=zs,b.getOffsetFromPoint=wg,b.getOffsetInfoAfter=Eu,b.getOffsetInfoBefore=Ch,b.getOpAt=j3,b.getOpLength=rh,b.getParentBlock=et,b.getParentBlockExcludeSelf=$s,b.getParentBox=qg,b.getParentContainer=rt,b.getPrevBlock=ge,b.getPrevValidOffset=Go,b.getPrevVisibleBlock=js,b.getRangeCommands=C2,b.getReferenceClientRect=ik,b.getRootBlock=Jg,b.getScrollContainer=En,b.getSpecialBlockCommands=$v,b.getStandardEmbedBlockProperties=ZE,b.getTextAfterOffset=mM,b.getTextAttributes=W1,b.getTextBeforeOffset=gM,b.getTextBlockChild=qd,b.getTextBlockClass=xv,b.getTextBlockContentChildTextLength=mr,b.getTextBlockContentChildType=Gv,b.getTextBlockContentChildren=fi,b.getTextLength=un,b.getTextOpLength=x1,b.getTextWidth=Pd,b.getToolbar=E0,b.handleBlockElementUpdated=Fv,b.hasAltOnly=X9,b.hasClass=Rt,b.hasCtrlOrCmd=Xb,b.hasCtrlOrCmdOnly=q9,b.hashCode=mv,b.hideBlock=Tv,b.htmlToFragment=Nd,b.i18n=D,b.injectDocToHtmlFragment=La,b.injectStyle=Kb,b.inputActions=UU,b.insertEmptyBlock=BI,b.insertEmptyEmbedBlock=t1,b.insertText=to,b.intersectionCommands=pO,b.isBackspace=Yb,b.isBlock=Vs,b.isBlockLocked=z0,b.isBlockLockedByOthers=RE,b.isBlockLockedBySelf=hf,b.isBlockTools=Bv,b.isBox=Gd,b.isBoxOp=jo,b.isCJK=Wb,b.isChildContainer=Mr,b.isChildNode=ne,b.isCodeBlock=qr,b.isCollapsedRange=Q_,b.isComplexBlockPosition=ma,b.isComplexKindBlock=Dt,b.isContainer=Wi,b.isContainerSelectedAllChildBlocks=H5,b.isControlEvent=Ps,b.isDelete=Y9,b.isDraggingFiles=Fd,b.isElementVisible=Dg,b.isEmbedBlock=pe,b.isEmptyContainer=uu,b.isEmptyDoc=P1,b.isEmptyTextBlock=ie,b.isEmptyTextBlockWithoutCompositionText=rf,b.isEnterOnly=Qb,b.isEscape=Og,b.isExclusiveBlock=ff,b.isFirefox=Jc,b.isFirstChildBlockInComplexBlock=r7,b.isHighSurrogate=F9,b.isInBlock=Qg,b.isInBlockTools=Gs,b.isLetter=Gb,b.isLowSurrogate=K9,b.isMatchShortcut=ai,b.isMoveForward=G9,b.isNavigationEvent=z9,b.isNavigationKey=qb,b.isNodeRemoved=Ub,b.isNumber=zb,b.isPrintableKey=Ug,b.isRootBlock=dr,b.isRootContainer=Xt,b.isSafari=ua,b.isSameDay=$g,b.isSelectBoxOnly=Sk,b.isShiftEnter=Q9,b.isShiftTab=Z9,b.isShortcutEvent=W9,b.isSimpleBlock=EI,b.isSimpleBlockPosition=Or,b.isSimplePos=EB,b.isSimpleRange=hh,b.isSpace=Od,b.isTab=J9,b.isTextBlockContentBoxChild=hr,b.isTextBlockContentChild=au,b.isTextBlockContentInsertionChild=Qi,b.isTextBlockContentTextChild=cu,b.isTextKindBlock=nt,b.isTextKindBlockType=iu,b.isTitleBlock=Gi,b.isToday=av,b.isValidOffset=Un,b.isVisibleBlock=ou,b.isYesterday=cv,b.loadJs=Ob,b.loadJsPromise=Os,b.lockers=Sr,b.mergeCommands=C0,b.mergeDocs=tl,b.mergeOps=M1,b.mergeText=G_,b.multiSplitText=G3,b.overflowText=uv,b.parseShortcut=Jb,b.patchNode=tu,b.pointInRect=Ns,b.rangeAddAttribute=gu,b.rangeGetTextColor=Z3,b.rangeRemoveAttribute=xa,b.rangeSetTextColor=Q3,b.rangeTransformText=q3,b.registerDragDrop=_g,b.removeAttribute=v1,b.removeClass=ot,b.removeLastBr=$_,b.removePlaceholderFromBlock=yR,b.removeStyle=Fb,b.replaceAll=aI,b.replaceAllCaseInsensitive=cI,b.replaceAllText=pB,b.replaceText=fh,b.requestDownload=Kd,b.resetListStart=Ja,b.scrollable=ov,b.selectFile=ha,b.selectedBlockToDoc=Lh,b.selectionToDoc=Sa,b.setAttributes=Md,b.setClipboardData=da,b.setClipboardDataByEvent=iI,b.setColorToAttributes=Y3,b.setDataset=Lg,b.setDefaultCursor=Yc,b.setStyles=Ig,b.shareDBCommentToDocObject=Kp,b.shareDBDocCommentToComment=oT,b.shortcutToDisplayText=ze,b.showBlock=yv,b.showDocVersions=tnt,b.splitText=_n,b.splitToThree=Xe,b.stringToDataUrl=Fg,b.stringToObjectUrl=Kg,b.subText=W3,b.textNodeOffsetFromPoint=Mb,b.titleFromEditor=DS,b.toBase64URL=ci,b.toMindmap=B0,b.toPlainText=fe,b.toPlainTextKeepLength=O1,b.trimChar=Mg,b.unexclusiveBlock=kE,b.unicodeLength=V9,b.unicodeSubstr=$9,b.updateBlockSelection=Nv,b.updateOpAttributes=gB,b.updateTextBlockContent=hM,b.updateUrl=Ng;for(const n in Re)n!=="default"&&!b.hasOwnProperty(n)&&Object.defineProperty(b,n,{enumerable:!0,get:()=>Re[n]});Object.defineProperties(b,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}})});
|