lakelib 0.1.3 → 0.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/lake.css CHANGED
@@ -37,7 +37,7 @@
37
37
  font-family: var(--font-family);
38
38
  font-size: 16px;
39
39
  font-weight: normal;
40
- line-height: normal;
40
+ line-height: 1.45;
41
41
  padding: 16px 24px;
42
42
  }
43
43
  .lake-container:focus {
package/dist/lake.min.js CHANGED
@@ -15,7 +15,7 @@ var Lake=function(t){"use strict";class e extends HTMLElement{}void 0!==customEl
15
15
  <li value="${r(i.value)}">
16
16
  <div class="lake-dropdown-menu-text">${o}</div>
17
17
  </li>
18
- `);if(t.append(a),"color"===e.menuType&&(a.attr("title",o),a.find(".lake-dropdown-menu-text").css("background-color",i.value)),i.icon){const t=I('<div class="lake-dropdown-menu-icon"></div>');t.append(i.icon),a.prepend(t)}const l=n.get("check");if(l){const t=I('<div class="lake-dropdown-menu-check"></div>');t.append(l),a.prepend(t)}}}showMenu(){const t=this.config,e=this.node,i=e.find(".lake-dropdown-menu");if(e.attr("disabled"))return;const n=De.getValue(e);i.find(".lake-dropdown-menu-check").css("visibility","hidden"),i.find("li").each((t=>{const e=I(t);e.on("mouseenter",(()=>{e.hasClass("lake-dropdown-item-selected")||e.addClass("lake-dropdown-item-hovered")})),e.on("mouseleave",(()=>{e.removeClass("lake-dropdown-item-hovered")})),n.indexOf(e.attr("value"))>=0&&e.find(".lake-dropdown-menu-check").css("visibility","visible")})),i.css("visibility","hidden"),i.show("color"===t.menuType?"flex":"block");e.get(0).getBoundingClientRect().x+i.width()+50>window.innerWidth?(i.css("left","auto"),i.css("right","0")):(i.css("left",""),i.css("right","")),i.css("visibility",""),document.addEventListener("click",this.documentClickListener)}bindEvents(){const t=this.config,e=this.node,i=e.find(".lake-dropdown-title"),n=i.find(".lake-dropdown-text"),s=i.find(".lake-dropdown-icon"),o=i.find(".lake-dropdown-down-icon"),r=e.find(".lake-dropdown-menu");"color"===t.menuType?(s.on("mouseenter",(()=>{e.attr("disabled")||s.addClass("lake-dropdown-icon-hovered")})),s.on("mouseleave",(()=>{s.removeClass("lake-dropdown-icon-hovered")})),o.on("mouseenter",(()=>{e.attr("disabled")||o.addClass("lake-dropdown-down-icon-hovered")})),o.on("mouseleave",(()=>{o.removeClass("lake-dropdown-down-icon-hovered")}))):(i.on("mouseenter",(()=>{e.attr("disabled")||i.addClass("lake-dropdown-title-hovered")})),i.on("mouseleave",(()=>{i.removeClass("lake-dropdown-title-hovered")}))),"color"===t.menuType&&s.on("click",(i=>{if(i.preventDefault(),e.attr("disabled"))return;const n=e.attr("color")||t.defaultValue;t.onSelect(n)}));("color"===t.menuType&&o?o:i).on("click",(t=>{t.preventDefault(),this.showMenu()})),r.on("click",(s=>{s.preventDefault();const o=I(s.target).closest("li"),a=o.attr("value");De.setValue(e,[a]),n.length>0&&n.text(o.text()),"color"===t.menuType&&""!==a&&(e.attr("color",a),this.updateColorAccent(i,a)),t.onSelect(a),r.hide(),document.removeEventListener("click",this.documentClickListener)}))}render(){var t;const e=this.config,i=this.node,n=i.find(".lake-dropdown-title");e.downIcon||n.addClass("lake-dropdown-title-no-down"),n.css("width",e.width);const s="string"==typeof e.tooltip?e.tooltip:e.tooltip(this.locale);n.attr("title",s);const o=n.find(".lake-dropdown-text"),r=n.find(".lake-dropdown-icon");e.icon&&r.append(e.icon),e.accentIcon&&r.append(e.accentIcon);const a=n.find(".lake-dropdown-down-icon");e.downIcon&&a.append(e.downIcon);const l=I('<ul class="lake-dropdown-menu" />');if(l.addClass(`lake-${e.menuType}-dropdown-menu`),De.setValue(i,[e.defaultValue]),o.length>0){const i=De.getMenuMap(e.menuItems,this.locale);o.text(null!==(t=i.get(e.defaultValue))&&void 0!==t?t:e.defaultValue)}"color"===e.menuType&&this.updateColorAccent(n,e.defaultValue),this.apppendMenuItems(l),i.append(n),i.append(l),this.root.append(i),this.bindEvents()}unmount(){this.node.remove(),document.removeEventListener("click",this.documentClickListener)}}var $e=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},Ve="object"==typeof Rt&&Rt&&Rt.Object===Object&&Rt,Fe=Ve,je="object"==typeof self&&self&&self.Object===Object&&self,Re=Fe||je||Function("return this")(),We=Re,Ue=function(){return We.Date.now()},qe=/\s/;var Ke=function(t){for(var e=t.length;e--&&qe.test(t.charAt(e)););return e},Ge=Ke,Xe=/^\s+/;var Je=function(t){return t?t.slice(0,Ge(t)+1).replace(Xe,""):t},Qe=Re.Symbol,Ye=Qe,ti=Object.prototype,ei=ti.hasOwnProperty,ii=ti.toString,ni=Ye?Ye.toStringTag:void 0;var si=function(t){var e=ei.call(t,ni),i=t[ni];try{t[ni]=void 0;var n=!0}catch(t){}var s=ii.call(t);return n&&(e?t[ni]=i:delete t[ni]),s},oi=Object.prototype.toString;var ri=si,ai=function(t){return oi.call(t)},li=Qe?Qe.toStringTag:void 0;var ci=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":li&&li in Object(t)?ri(t):ai(t)};var hi=function(t){return null!=t&&"object"==typeof t},di=ci,pi=hi;var ui=Je,mi=$e,fi=function(t){return"symbol"==typeof t||pi(t)&&"[object Symbol]"==di(t)},gi=/^[-+]0x[0-9a-f]+$/i,vi=/^0b[01]+$/i,yi=/^0o[0-7]+$/i,wi=parseInt;var xi=$e,bi=Ue,ki=function(t){if("number"==typeof t)return t;if(fi(t))return NaN;if(mi(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=mi(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=ui(t);var i=vi.test(t);return i||yi.test(t)?wi(t.slice(2),i?2:8):gi.test(t)?NaN:+t},_i=Math.max,Si=Math.min;var Ci=function(t,e,i){var n,s,o,r,a,l,c=0,h=!1,d=!1,p=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function u(e){var i=n,o=s;return n=s=void 0,c=e,r=t.apply(o,i)}function m(t){var i=t-l;return void 0===l||i>=e||i<0||d&&t-c>=o}function f(){var t=bi();if(m(t))return g(t);a=setTimeout(f,function(t){var i=e-(t-l);return d?Si(i,o-(t-c)):i}(t))}function g(t){return a=void 0,p&&n?u(t):(n=s=void 0,r)}function v(){var t=bi(),i=m(t);if(n=arguments,s=this,l=t,i){if(void 0===a)return function(t){return c=t,a=setTimeout(f,e),h?u(t):r}(l);if(d)return clearTimeout(a),a=setTimeout(f,e),u(l)}return void 0===a&&(a=setTimeout(f,e)),r}return e=ki(e)||0,xi(i)&&(h=!!i.leading,o=(d="maxWait"in i)?_i(ki(i.maxWait)||0,e):o,p="trailing"in i?!!i.trailing:p),v.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=l=s=a=void 0},v.flush=function(){return void 0===a?r:g(bi())},v},Ai=Wt(Ci);var Bi=function(){this.__data__=[],this.size=0};var Ti=function(t,e){return t===e||t!=t&&e!=e},Ei=Ti;var Ii=function(t,e){for(var i=t.length;i--;)if(Ei(t[i][0],e))return i;return-1},Li=Ii,Mi=Array.prototype.splice;var Pi=function(t){var e=this.__data__,i=Li(e,t);return!(i<0)&&(i==e.length-1?e.pop():Mi.call(e,i,1),--this.size,!0)},Oi=Ii;var zi=function(t){var e=this.__data__,i=Oi(e,t);return i<0?void 0:e[i][1]},Zi=Ii;var Ni=Ii;var Hi=function(t,e){var i=this.__data__,n=Ni(i,t);return n<0?(++this.size,i.push([t,e])):i[n][1]=e,this},Di=Bi,$i=Pi,Vi=zi,Fi=function(t){return Zi(this.__data__,t)>-1},ji=Hi;function Ri(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}Ri.prototype.clear=Di,Ri.prototype.delete=$i,Ri.prototype.get=Vi,Ri.prototype.has=Fi,Ri.prototype.set=ji;var Wi=Ri,Ui=Wi;var qi=function(){this.__data__=new Ui,this.size=0};var Ki=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i};var Gi=function(t){return this.__data__.get(t)};var Xi=function(t){return this.__data__.has(t)},Ji=ci,Qi=$e;var Yi,tn=function(t){if(!Qi(t))return!1;var e=Ji(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e},en=Re["__core-js_shared__"],nn=(Yi=/[^.]+$/.exec(en&&en.keys&&en.keys.IE_PROTO||""))?"Symbol(src)_1."+Yi:"";var sn=function(t){return!!nn&&nn in t},on=Function.prototype.toString;var rn=function(t){if(null!=t){try{return on.call(t)}catch(t){}try{return t+""}catch(t){}}return""},an=tn,ln=sn,cn=$e,hn=rn,dn=/^\[object .+?Constructor\]$/,pn=Function.prototype,un=Object.prototype,mn=pn.toString,fn=un.hasOwnProperty,gn=RegExp("^"+mn.call(fn).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var vn=function(t){return!(!cn(t)||ln(t))&&(an(t)?gn:dn).test(hn(t))},yn=function(t,e){return null==t?void 0:t[e]};var wn=function(t,e){var i=yn(t,e);return vn(i)?i:void 0},xn=wn(Re,"Map"),bn=wn(Object,"create"),kn=bn;var _n=function(){this.__data__=kn?kn(null):{},this.size=0};var Sn=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Cn=bn,An=Object.prototype.hasOwnProperty;var Bn=function(t){var e=this.__data__;if(Cn){var i=e[t];return"__lodash_hash_undefined__"===i?void 0:i}return An.call(e,t)?e[t]:void 0},Tn=bn,En=Object.prototype.hasOwnProperty;var In=bn;var Ln=_n,Mn=Sn,Pn=Bn,On=function(t){var e=this.__data__;return Tn?void 0!==e[t]:En.call(e,t)},zn=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=In&&void 0===e?"__lodash_hash_undefined__":e,this};function Zn(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}Zn.prototype.clear=Ln,Zn.prototype.delete=Mn,Zn.prototype.get=Pn,Zn.prototype.has=On,Zn.prototype.set=zn;var Nn=Zn,Hn=Wi,Dn=xn;var $n=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};var Vn=function(t,e){var i=t.__data__;return $n(e)?i["string"==typeof e?"string":"hash"]:i.map},Fn=Vn;var jn=Vn;var Rn=Vn;var Wn=Vn;var Un=function(){this.size=0,this.__data__={hash:new Nn,map:new(Dn||Hn),string:new Nn}},qn=function(t){var e=Fn(this,t).delete(t);return this.size-=e?1:0,e},Kn=function(t){return jn(this,t).get(t)},Gn=function(t){return Rn(this,t).has(t)},Xn=function(t,e){var i=Wn(this,t),n=i.size;return i.set(t,e),this.size+=i.size==n?0:1,this};function Jn(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}Jn.prototype.clear=Un,Jn.prototype.delete=qn,Jn.prototype.get=Kn,Jn.prototype.has=Gn,Jn.prototype.set=Xn;var Qn=Jn,Yn=Wi,ts=xn,es=Qn;var is=Wi,ns=qi,ss=Ki,os=Gi,rs=Xi,as=function(t,e){var i=this.__data__;if(i instanceof Yn){var n=i.__data__;if(!ts||n.length<199)return n.push([t,e]),this.size=++i.size,this;i=this.__data__=new es(n)}return i.set(t,e),this.size=i.size,this};function ls(t){var e=this.__data__=new is(t);this.size=e.size}ls.prototype.clear=ns,ls.prototype.delete=ss,ls.prototype.get=os,ls.prototype.has=rs,ls.prototype.set=as;var cs=ls;var hs=Qn,ds=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},ps=function(t){return this.__data__.has(t)};function us(t){var e=-1,i=null==t?0:t.length;for(this.__data__=new hs;++e<i;)this.add(t[e])}us.prototype.add=us.prototype.push=ds,us.prototype.has=ps;var ms=function(t,e){for(var i=-1,n=null==t?0:t.length;++i<n;)if(e(t[i],i,t))return!0;return!1};var fs=us,gs=ms,vs=function(t,e){return t.has(e)};var ys=function(t,e,i,n,s,o){var r=1&i,a=t.length,l=e.length;if(a!=l&&!(r&&l>a))return!1;var c=o.get(t),h=o.get(e);if(c&&h)return c==e&&h==t;var d=-1,p=!0,u=2&i?new fs:void 0;for(o.set(t,e),o.set(e,t);++d<a;){var m=t[d],f=e[d];if(n)var g=r?n(f,m,d,e,t,o):n(m,f,d,t,e,o);if(void 0!==g){if(g)continue;p=!1;break}if(u){if(!gs(e,(function(t,e){if(!vs(u,e)&&(m===t||s(m,t,i,n,o)))return u.push(e)}))){p=!1;break}}else if(m!==f&&!s(m,f,i,n,o)){p=!1;break}}return o.delete(t),o.delete(e),p};var ws=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t,n){i[++e]=[n,t]})),i};var xs=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t){i[++e]=t})),i},bs=Re.Uint8Array,ks=Ti,_s=ys,Ss=ws,Cs=xs,As=Qe?Qe.prototype:void 0,Bs=As?As.valueOf:void 0;var Ts=function(t,e,i,n,s,o,r){switch(i){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!o(new bs(t),new bs(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return ks(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=Ss;case"[object Set]":var l=1&n;if(a||(a=Cs),t.size!=e.size&&!l)return!1;var c=r.get(t);if(c)return c==e;n|=2,r.set(t,e);var h=_s(a(t),a(e),n,s,o,r);return r.delete(t),h;case"[object Symbol]":if(Bs)return Bs.call(t)==Bs.call(e)}return!1};var Es=function(t,e){for(var i=-1,n=e.length,s=t.length;++i<n;)t[s+i]=e[i];return t},Is=Array.isArray,Ls=Es,Ms=Is;var Ps=function(t,e,i){var n=e(t);return Ms(t)?n:Ls(n,i(t))};var Os=function(t,e){for(var i=-1,n=null==t?0:t.length,s=0,o=[];++i<n;){var r=t[i];e(r,i,t)&&(o[s++]=r)}return o};var zs=Os,Zs=function(){return[]},Ns=Object.prototype.propertyIsEnumerable,Hs=Object.getOwnPropertySymbols,Ds=Hs?function(t){return null==t?[]:(t=Object(t),zs(Hs(t),(function(e){return Ns.call(t,e)})))}:Zs;var $s=function(t,e){for(var i=-1,n=Array(t);++i<t;)n[i]=e(i);return n},Vs=ci,Fs=hi;var js=function(t){return Fs(t)&&"[object Arguments]"==Vs(t)},Rs=hi,Ws=Object.prototype,Us=Ws.hasOwnProperty,qs=Ws.propertyIsEnumerable,Ks=js(function(){return arguments}())?js:function(t){return Rs(t)&&Us.call(t,"callee")&&!qs.call(t,"callee")},Gs=Ks,Xs={exports:{}};var Js=function(){return!1};!function(t,e){var i=Re,n=Js,s=e&&!e.nodeType&&e,o=s&&t&&!t.nodeType&&t,r=o&&o.exports===s?i.Buffer:void 0,a=(r?r.isBuffer:void 0)||n;t.exports=a}(Xs,Xs.exports);var Qs=Xs.exports,Ys=/^(?:0|[1-9]\d*)$/;var to=function(t,e){var i=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&Ys.test(t))&&t>-1&&t%1==0&&t<e};var eo=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991},io=ci,no=eo,so=hi,oo={};oo["[object Float32Array]"]=oo["[object Float64Array]"]=oo["[object Int8Array]"]=oo["[object Int16Array]"]=oo["[object Int32Array]"]=oo["[object Uint8Array]"]=oo["[object Uint8ClampedArray]"]=oo["[object Uint16Array]"]=oo["[object Uint32Array]"]=!0,oo["[object Arguments]"]=oo["[object Array]"]=oo["[object ArrayBuffer]"]=oo["[object Boolean]"]=oo["[object DataView]"]=oo["[object Date]"]=oo["[object Error]"]=oo["[object Function]"]=oo["[object Map]"]=oo["[object Number]"]=oo["[object Object]"]=oo["[object RegExp]"]=oo["[object Set]"]=oo["[object String]"]=oo["[object WeakMap]"]=!1;var ro=function(t){return so(t)&&no(t.length)&&!!oo[io(t)]};var ao=function(t){return function(e){return t(e)}},lo={exports:{}};!function(t,e){var i=Ve,n=e&&!e.nodeType&&e,s=n&&t&&!t.nodeType&&t,o=s&&s.exports===n&&i.process,r=function(){try{var t=s&&s.require&&s.require("util").types;return t||o&&o.binding&&o.binding("util")}catch(t){}}();t.exports=r}(lo,lo.exports);var co=lo.exports,ho=ro,po=ao,uo=co&&co.isTypedArray,mo=uo?po(uo):ho,fo=$s,go=Gs,vo=Is,yo=Qs,wo=to,xo=mo,bo=Object.prototype.hasOwnProperty;var ko=function(t,e){var i=vo(t),n=!i&&go(t),s=!i&&!n&&yo(t),o=!i&&!n&&!s&&xo(t),r=i||n||s||o,a=r?fo(t.length,String):[],l=a.length;for(var c in t)!e&&!bo.call(t,c)||r&&("length"==c||s&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||wo(c,l))||a.push(c);return a},_o=Object.prototype;var So=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||_o)};var Co=function(t,e){return function(i){return t(e(i))}}(Object.keys,Object),Ao=So,Bo=Co,To=Object.prototype.hasOwnProperty;var Eo=tn,Io=eo;var Lo=ko,Mo=function(t){if(!Ao(t))return Bo(t);var e=[];for(var i in Object(t))To.call(t,i)&&"constructor"!=i&&e.push(i);return e},Po=function(t){return null!=t&&Io(t.length)&&!Eo(t)};var Oo=Ps,zo=Ds,Zo=function(t){return Po(t)?Lo(t):Mo(t)};var No=function(t){return Oo(t,Zo,zo)},Ho=Object.prototype.hasOwnProperty;var Do=function(t,e,i,n,s,o){var r=1&i,a=No(t),l=a.length;if(l!=No(e).length&&!r)return!1;for(var c=l;c--;){var h=a[c];if(!(r?h in e:Ho.call(e,h)))return!1}var d=o.get(t),p=o.get(e);if(d&&p)return d==e&&p==t;var u=!0;o.set(t,e),o.set(e,t);for(var m=r;++c<l;){var f=t[h=a[c]],g=e[h];if(n)var v=r?n(g,f,h,e,t,o):n(f,g,h,t,e,o);if(!(void 0===v?f===g||s(f,g,i,n,o):v)){u=!1;break}m||(m="constructor"==h)}if(u&&!m){var y=t.constructor,w=e.constructor;y==w||!("constructor"in t)||!("constructor"in e)||"function"==typeof y&&y instanceof y&&"function"==typeof w&&w instanceof w||(u=!1)}return o.delete(t),o.delete(e),u},$o=wn(Re,"DataView"),Vo=xn,Fo=wn(Re,"Promise"),jo=wn(Re,"Set"),Ro=wn(Re,"WeakMap"),Wo=ci,Uo=rn,qo="[object Map]",Ko="[object Promise]",Go="[object Set]",Xo="[object WeakMap]",Jo="[object DataView]",Qo=Uo($o),Yo=Uo(Vo),tr=Uo(Fo),er=Uo(jo),ir=Uo(Ro),nr=Wo;($o&&nr(new $o(new ArrayBuffer(1)))!=Jo||Vo&&nr(new Vo)!=qo||Fo&&nr(Fo.resolve())!=Ko||jo&&nr(new jo)!=Go||Ro&&nr(new Ro)!=Xo)&&(nr=function(t){var e=Wo(t),i="[object Object]"==e?t.constructor:void 0,n=i?Uo(i):"";if(n)switch(n){case Qo:return Jo;case Yo:return qo;case tr:return Ko;case er:return Go;case ir:return Xo}return e});var sr=cs,or=ys,rr=Ts,ar=Do,lr=nr,cr=Is,hr=Qs,dr=mo,pr="[object Arguments]",ur="[object Array]",mr="[object Object]",fr=Object.prototype.hasOwnProperty;var gr=function(t,e,i,n,s,o){var r=cr(t),a=cr(e),l=r?ur:lr(t),c=a?ur:lr(e),h=(l=l==pr?mr:l)==mr,d=(c=c==pr?mr:c)==mr,p=l==c;if(p&&hr(t)){if(!hr(e))return!1;r=!0,h=!1}if(p&&!h)return o||(o=new sr),r||dr(t)?or(t,e,i,n,s,o):rr(t,e,l,i,n,s,o);if(!(1&i)){var u=h&&fr.call(t,"__wrapped__"),m=d&&fr.call(e,"__wrapped__");if(u||m){var f=u?t.value():t,g=m?e.value():e;return o||(o=new sr),s(f,g,i,n,o)}}return!!p&&(o||(o=new sr),ar(t,e,i,n,s,o))},vr=hi;var yr=function t(e,i,n,s,o){return e===i||(null==e||null==i||!vr(e)&&!vr(i)?e!=e&&i!=i:gr(e,i,n,s,t,o))},wr=yr;var xr=Wt((function(t,e){return wr(t,e)}));function br(t){const e=t.get(0),i={};if(e.hasAttributes())for(const t of e.attributes)i[t.name]=t.value;return i}class kr{constructor(t){const e=window.getSelection();if(!e)throw new Error("Selection object is null.");this.selection=e,this.container=t,this.range=this.getRangeFromNativeSelection()}getRangeFromNativeSelection(){if(this.selection.rangeCount>0){const t=this.selection.getRangeAt(0);return new L(t)}return new L}addRangeToNativeSelection(){this.selection.removeAllRanges(),this.selection.addRange(this.range.get())}syncByRange(){const t=this.getRangeFromNativeSelection();this.range.get()!==t.get()&&(this.range=t)}synByBookmark(){const t=this.range,e=this.container,i=e.find("lake-box[focus]");if(i.length>0)return ae(t,{anchor:new E,focus:i}),void this.addRangeToNativeSelection();ae(t,{anchor:e.find('lake-bookmark[type="anchor"]'),focus:e.find('lake-bookmark[type="focus"]')}),this.addRangeToNativeSelection()}getAppliedItems(){const t=[];return function(t,e){let i=e.startNode;for(i.isText&&(i=i.parent());i.length>0&&i.isInside;)t.push({node:i,name:i.name,attributes:br(i),styles:p(i.attr("style"))}),i=i.parent()}(t,this.range),function(t,e){const i=e.startNode;let n;if(i.isText&&i.text().length===e.startOffset){const t=i.next();t.length>0&&t.isElement&&(n=t)}if(i.isElement){const t=i.children();if(t.length>0){const i=t[e.startOffset];i&&i.isElement&&(n=i)}}if(n){let e=n;for(;e.length>0;)e.isElement&&t.push({node:e,name:e.name,attributes:br(e),styles:p(e.attr("style"))}),e=e.first()}}(t,this.range),t}insertBookmark(){return oe(this.range)}toBookmark(t){return ae(this.range,t)}insertNode(t){return se(this.range,t)}insertFragment(t){return he(this.range,t)}insertContents(t){return de(this.range,t)}deleteContents(){return ce(this.range)}setBlocks(t){return pe(this.range,t)}splitBlock(){return ue(this.range)}splitMarks(t){return ge(this.range,t)}addMark(t){return ye(this.range,t)}removeMark(t){return xe(this.range,t)}fixList(){return le(this.range)}insertLink(t){return be(this.range,t)}}class _r{constructor(t){this.commandMap=new Map,this.event=new qt,this.selection=t}add(t,e){this.commandMap.set(t,e)}delete(t){this.commandMap.delete(t)}getNames(){return Array.from(this.commandMap.keys())}has(t){return void 0!==this.commandMap.get(t)}getItem(t){const e=this.commandMap.get(t);if(void 0===e)throw new Error(`Command '${t}' does not exist.`);return e}isDisabled(t){const e=this.getItem(t);if(!e.isDisabled)return!1;const i=this.selection.getAppliedItems();return e.isDisabled(i)}isSelected(t){const e=this.getItem(t);if(!e.isSelected)return!1;const i=this.selection.getAppliedItems();return e.isSelected(i)}selectedValues(t){const e=this.getItem(t);if(!e.selectedValues)return[];const i=this.selection.getAppliedItems();return e.selectedValues(i)}execute(t,...e){const i=this.getItem(t);this.event.emit("beforeexecute",t),i.execute.apply(this,e),this.event.emit("execute",t),A(`Command '${t}' executed`)}}var Sr,Cr={exports:{}};Sr=Cr,function(t){function e(t,e){var i=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(i>>16)<<16|65535&i}function i(t,i,n,s,o,r){return e((a=e(e(i,t),e(s,r)))<<(l=o)|a>>>32-l,n);var a,l}function n(t,e,n,s,o,r,a){return i(e&n|~e&s,t,e,o,r,a)}function s(t,e,n,s,o,r,a){return i(e&s|n&~s,t,e,o,r,a)}function o(t,e,n,s,o,r,a){return i(e^n^s,t,e,o,r,a)}function r(t,e,n,s,o,r,a){return i(n^(e|~s),t,e,o,r,a)}function a(t,i){var a,l,c,h,d;t[i>>5]|=128<<i%32,t[14+(i+64>>>9<<4)]=i;var p=1732584193,u=-271733879,m=-1732584194,f=271733878;for(a=0;a<t.length;a+=16)l=p,c=u,h=m,d=f,p=n(p,u,m,f,t[a],7,-680876936),f=n(f,p,u,m,t[a+1],12,-389564586),m=n(m,f,p,u,t[a+2],17,606105819),u=n(u,m,f,p,t[a+3],22,-1044525330),p=n(p,u,m,f,t[a+4],7,-176418897),f=n(f,p,u,m,t[a+5],12,1200080426),m=n(m,f,p,u,t[a+6],17,-1473231341),u=n(u,m,f,p,t[a+7],22,-45705983),p=n(p,u,m,f,t[a+8],7,1770035416),f=n(f,p,u,m,t[a+9],12,-1958414417),m=n(m,f,p,u,t[a+10],17,-42063),u=n(u,m,f,p,t[a+11],22,-1990404162),p=n(p,u,m,f,t[a+12],7,1804603682),f=n(f,p,u,m,t[a+13],12,-40341101),m=n(m,f,p,u,t[a+14],17,-1502002290),p=s(p,u=n(u,m,f,p,t[a+15],22,1236535329),m,f,t[a+1],5,-165796510),f=s(f,p,u,m,t[a+6],9,-1069501632),m=s(m,f,p,u,t[a+11],14,643717713),u=s(u,m,f,p,t[a],20,-373897302),p=s(p,u,m,f,t[a+5],5,-701558691),f=s(f,p,u,m,t[a+10],9,38016083),m=s(m,f,p,u,t[a+15],14,-660478335),u=s(u,m,f,p,t[a+4],20,-405537848),p=s(p,u,m,f,t[a+9],5,568446438),f=s(f,p,u,m,t[a+14],9,-1019803690),m=s(m,f,p,u,t[a+3],14,-187363961),u=s(u,m,f,p,t[a+8],20,1163531501),p=s(p,u,m,f,t[a+13],5,-1444681467),f=s(f,p,u,m,t[a+2],9,-51403784),m=s(m,f,p,u,t[a+7],14,1735328473),p=o(p,u=s(u,m,f,p,t[a+12],20,-1926607734),m,f,t[a+5],4,-378558),f=o(f,p,u,m,t[a+8],11,-2022574463),m=o(m,f,p,u,t[a+11],16,1839030562),u=o(u,m,f,p,t[a+14],23,-35309556),p=o(p,u,m,f,t[a+1],4,-1530992060),f=o(f,p,u,m,t[a+4],11,1272893353),m=o(m,f,p,u,t[a+7],16,-155497632),u=o(u,m,f,p,t[a+10],23,-1094730640),p=o(p,u,m,f,t[a+13],4,681279174),f=o(f,p,u,m,t[a],11,-358537222),m=o(m,f,p,u,t[a+3],16,-722521979),u=o(u,m,f,p,t[a+6],23,76029189),p=o(p,u,m,f,t[a+9],4,-640364487),f=o(f,p,u,m,t[a+12],11,-421815835),m=o(m,f,p,u,t[a+15],16,530742520),p=r(p,u=o(u,m,f,p,t[a+2],23,-995338651),m,f,t[a],6,-198630844),f=r(f,p,u,m,t[a+7],10,1126891415),m=r(m,f,p,u,t[a+14],15,-1416354905),u=r(u,m,f,p,t[a+5],21,-57434055),p=r(p,u,m,f,t[a+12],6,1700485571),f=r(f,p,u,m,t[a+3],10,-1894986606),m=r(m,f,p,u,t[a+10],15,-1051523),u=r(u,m,f,p,t[a+1],21,-2054922799),p=r(p,u,m,f,t[a+8],6,1873313359),f=r(f,p,u,m,t[a+15],10,-30611744),m=r(m,f,p,u,t[a+6],15,-1560198380),u=r(u,m,f,p,t[a+13],21,1309151649),p=r(p,u,m,f,t[a+4],6,-145523070),f=r(f,p,u,m,t[a+11],10,-1120210379),m=r(m,f,p,u,t[a+2],15,718787259),u=r(u,m,f,p,t[a+9],21,-343485551),p=e(p,l),u=e(u,c),m=e(m,h),f=e(f,d);return[p,u,m,f]}function l(t){var e,i="",n=32*t.length;for(e=0;e<n;e+=8)i+=String.fromCharCode(t[e>>5]>>>e%32&255);return i}function c(t){var e,i=[];for(i[(t.length>>2)-1]=void 0,e=0;e<i.length;e+=1)i[e]=0;var n=8*t.length;for(e=0;e<n;e+=8)i[e>>5]|=(255&t.charCodeAt(e/8))<<e%32;return i}function h(t){var e,i,n="0123456789abcdef",s="";for(i=0;i<t.length;i+=1)e=t.charCodeAt(i),s+=n.charAt(e>>>4&15)+n.charAt(15&e);return s}function d(t){return unescape(encodeURIComponent(t))}function p(t){return function(t){return l(a(c(t),8*t.length))}(d(t))}function u(t,e){return function(t,e){var i,n,s=c(t),o=[],r=[];for(o[15]=r[15]=void 0,s.length>16&&(s=a(s,8*t.length)),i=0;i<16;i+=1)o[i]=909522486^s[i],r[i]=1549556828^s[i];return n=a(o.concat(c(e)),512+8*e.length),l(a(r.concat(n),640))}(d(t),d(e))}function m(t,e,i){return e?i?u(e,t):h(u(e,t)):i?p(t):h(p(t))}Sr.exports?Sr.exports=m:t.md5=m}(Rt);var Ar=Wt(Cr.exports);const Br=new Map;class Tr{constructor(t){this.list=[],this.index=0,this.canSave=!0,this.limit=100,this.event=new qt,this.selection=t,this.container=t.container}removeBookmark(t){return t.replace(/(<lake-box[^>]+)\s+focus="\w+"([^>]*>)/gi,"$1$2").replace(/<lake-bookmark\s+type="anchor">\s*<\/lake-bookmark>/gi,"").replace(/<lake-bookmark\s+type="focus">\s*<\/lake-bookmark>/gi,"")}getValue(t){return new ie(t).getHTML()}addIdToBoxes(t){t.find("lake-box").each((t=>{const e=new E(t),i=Ar(`${e.attr("type")}-${e.attr("name")}-${e.attr("value")}`);e.attr("id",i)}))}removeIdfromBoxes(t){t.find("lake-box").each((t=>{new E(t).removeAttr("id")}))}morphContainer(t){const e=this.container,i={beforeChildrenUpdated:t=>{if("lake-box"===new E(t).name)return!1},afterAttributeUpdated:(t,i)=>{const n=new E(i);if("value"===t&&"lake-box"===n.name){const t=Br.get(e.id);if(!t)return;t.delete(n.id)}}},n=t.clone(!0);this.addIdToBoxes(e),this.addIdToBoxes(n),ht(e,n,{callbacks:i}),this.removeIdfromBoxes(e),this.removeIdfromBoxes(n)}cloneContainer(){const t=this.selection.range,e=this.container.clone(!0);if(e.find("lake-box").each((t=>{new Yt(t).getContainer().empty()})),t.commonAncestor.isOutside)return e;if(t.isInsideBox)return e;const i=t.startNode.path(),n=t.endNode.path(),s=e.find(i),o=e.find(n),r=t.clone();return r.setStart(s,t.startOffset),r.setEnd(o,t.endOffset),oe(r),e}get count(){return this.list.length}get canUndo(){return this.index>1&&!!this.list[this.index-1]}get canRedo(){return!!this.list[this.index]}undo(){if(!this.list[this.index-1])return;this.selection.insertBookmark();const t=this.getValue(this.container);for(;this.index>0;){const e=this.list[this.index-1];if(!e)break;const i=this.getValue(e);if(this.removeBookmark(i)!==this.removeBookmark(t)){this.morphContainer(e),this.event.emit("undo",i);break}if(1===this.index)break;this.index--}this.selection.synByBookmark(),A(`History undone, the last index is ${this.index}`)}redo(){if(!this.list[this.index])return;this.selection.insertBookmark();const t=this.getValue(this.container);for(;this.index<this.list.length;){const e=this.list[this.index];if(!e)break;this.index++;const i=this.getValue(e);if(this.removeBookmark(i)!==this.removeBookmark(t)){this.morphContainer(e),this.event.emit("redo",i);break}}this.selection.synByBookmark(),A(`History redone, the last index is ${this.index}`)}continue(){this.canSave=!0}pause(){this.canSave=!1}save(t=!0){if(!this.canSave)return;const e=this.cloneContainer(),i=this.getValue(e);this.list[this.index-1]&&this.removeBookmark(this.getValue(this.list[this.index-1]))===this.removeBookmark(i)||(this.list.splice(this.index,1/0,e),this.index++,this.list.length>this.limit&&(this.list.shift(),this.index=this.list.length),t&&this.event.emit("save",m(i)),A(`History saved, the last index is ${this.index}`))}}var Er=["Shift","Meta","Alt","Control"],Ir="object"==typeof navigator?navigator.platform:"",Lr=/Mac|iPod|iPhone|iPad/.test(Ir),Mr=Lr?"Meta":"Control",Pr="Win32"===Ir?["Control","Alt"]:Lr?["Alt"]:[];function Or(t,e){return"function"==typeof t.getModifierState&&(t.getModifierState(e)||Pr.includes(e)&&t.getModifierState("AltGraph"))}function zr(t){return t.trim().split(" ").map((function(t){var e=t.split(/\b\+/),i=e.pop();return[e=e.map((function(t){return"$mod"===t?Mr:t})),i]}))}function Zr(t,e){var i;void 0===e&&(e={});var n=null!=(i=e.timeout)?i:1e3,s=Object.keys(t).map((function(e){return[zr(e),t[e]]})),o=new Map,r=null;return function(t){t instanceof KeyboardEvent&&(s.forEach((function(e){var i=e[0],n=e[1],s=o.get(i)||i;!function(t,e){return!(e[1].toUpperCase()!==t.key.toUpperCase()&&e[1]!==t.code||e[0].find((function(e){return!Or(t,e)}))||Er.find((function(i){return!e[0].includes(i)&&e[1]!==i&&Or(t,i)})))}(t,s[0])?Or(t,t.key)||o.delete(i):s.length>1?o.set(i,s.slice(1)):(o.delete(i),n(t))})),r&&clearTimeout(r),r=setTimeout(o.clear.bind(o),n))}}const Nr=new Map([["#","shift+#"]]);class Hr{constructor(t){this.keydownEventList=[],this.keyupEventList=[],this.container=t}normalizeType(t){var e;return t=(t=null!==(e=Nr.get(t))&&void 0!==e?e:t).replace(/(^|\+|\s)mod(\+|\s|$)/g,"$1$mod$2").replace(/shift|control|alt|meta|enter|tab|backspace|delete|space|escape|arrow-left|arrow-right|arrow-up|arrow-down/,(t=>t.charAt(0).toUpperCase()+l(t.substring(1)))).replace(/(^|\+|\s)([a-z])(\+|\s|$)/g,((t,e,i,n)=>`${e}Key${i.toUpperCase()}${n}`))}setKeydown(t,e){t=this.normalizeType(t);const i=Zr({[t]:t=>e(t)});this.keydownEventList.push({type:t,listener:e}),this.container.on("keydown",i)}setKeyup(t,e){t=this.normalizeType(t);const i=Zr({[t]:t=>e(t)});this.keyupEventList.push({type:t,listener:e}),this.container.on("keyup",i)}keydown(t){t=this.normalizeType(t);for(const e of this.keydownEventList)if(e.type===t&&!1===e.listener(new Event(t)))break}keyup(t){t=this.normalizeType(t);for(const e of this.keyupEventList)if(e.type===t&&!1===e.listener(new Event(t)))break}}const Dr={value:"<p><br /><focus /></p>",readonly:!1,spellcheck:!1,tabIndex:0,indentWithTab:!0,lang:"en-US",minChangeSize:5};class $r{constructor(t){if(this.unsavedInputData="",this.stateData={appliedItems:[],disabledNameMap:new Map,selectedNameMap:new Map,selectedValuesMap:new Map},this.isComposing=!1,this.event=new qt,this.box=$r.box,this.beforeunloadListener=()=>{this.history.save()},this.selectionchangeListener=()=>{this.selection.syncByRange(),this.updateBoxSelectionStyle(),this.emitStateChangeEvent()},this.clickListener=t=>{const e=new E(t.target);e.closest(".lake-popup").length>0||this.event.emit("click",e)},this.resizeListener=()=>{this.event.emit("resize")},this.updateBoxSelectionStyle=Ai((()=>{if(0===this.root.first().length)return;const t=this.selection.range,e=t.clone();e.adaptBox(),this.box.findAll(this).each((i=>{const n=new Yt(i),s=n.getContainer();if(0!==s.length){if(t.compareBeforeNode(s)<0&&t.compareAfterNode(s)>0&&(!t.isCollapsed||t.startNode.get(0)!==s.get(0)||0!==t.startOffset))return s.removeClass("lake-box-hovered"),s.removeClass("lake-box-selected"),s.removeClass("lake-box-focused"),void s.addClass("lake-box-activated");if(e.intersectsNode(n.node))return s.removeClass("lake-box-activated"),void(t.isCollapsed?(s.removeClass("lake-box-hovered"),s.removeClass("lake-box-selected"),s.addClass("lake-box-focused")):(s.removeClass("lake-box-focused"),s.addClass("lake-box-selected")));s.removeClass("lake-box-activated"),s.removeClass("lake-box-focused"),s.removeClass("lake-box-selected")}})),this.event.emit("boxselectionstylechange")}),50,{leading:!1,trailing:!0,maxWait:50}),this.emitStateChangeEvent=Ai((()=>{const t=this.command.getNames();let e=this.selection.getAppliedItems();e.length>0&&e[0].node.closestContainer().get(0)!==this.container.get(0)&&(e=[]);const i=new Map,n=new Map,s=new Map;if(e.length>0)for(const o of t){const t=this.command.getItem(o);if(t.isDisabled&&t.isDisabled(e)&&i.set(o,!0),t.isSelected&&t.isSelected(e)&&n.set(o,!0),t.selectedValues){const i=t.selectedValues(e);i.length>0&&s.set(o,i)}}const o={appliedItems:e,disabledNameMap:i,selectedNameMap:n,selectedValuesMap:s};xr(o,this.stateData)||(this.toolbar&&this.toolbar.updateState(o),this.event.emit("statechange",o),this.stateData=o)}),100,{leading:!1,trailing:!0,maxWait:100}),this.emitChangeEvent=t=>{this.rectifyContent(),this.emitStateChangeEvent(),this.event.emit("change",t)},!t.root)throw new Error("The root of the config must be specified.");this.root=I(t.root),this.toolbar=t.toolbar,this.config=Object.assign({},Dr);for(const e of Object.keys(t))this.config[e]=t[e];this.containerWrapper=I('<div class="lake-container-wrapper" />'),this.container=I('<div class="lake-container" />'),this.overlayContainer=I('<div class="lake-overlay" />'),this.popupContainer=I('<div class="lake-popup lake-custom-properties" />'),this.readonly=this.config.readonly,this.root.addClass("lake-custom-properties"),this.container.attr({contenteditable:this.readonly?"false":"true",spellcheck:this.config.spellcheck?"true":"false",tabindex:this.config.tabIndex.toString()}),this.selection=new kr(this.container),this.command=new _r(this.selection),this.history=new Tr(this.selection),this.keystroke=new Hr(this.container),Gt.set(this.container.id,this)}inputInBoxStrip(){const t=this.selection,e=t.range,i=e.startNode.closest(".lake-box-strip"),n=i.closest("lake-box");if("inline"===new Yt(n).type)e.isBoxStart?(e.setStartBefore(n),e.collapseToStart()):(e.setStartAfter(n),e.collapseToStart());else{const t=I("<p />");e.isBoxStart?n.before(t):n.after(t),e.shrinkAfter(t)}const s=i.text();i.html("<br />"),t.insertNode(document.createTextNode(s))}bindInputEvents(){this.container.on("compositionstart",(()=>{this.isComposing=!0})),this.container.on("compositionend",(()=>{this.isComposing=!1})),this.container.on("beforeinput",(t=>{const e=t,i=this.selection.range;(i.isBoxStart||i.isBoxEnd||"insertText"!==e.inputType&&"insertCompositionText"!==e.inputType)&&this.commitUnsavedInputData()})),this.container.on("input",(t=>{const e=t;window.setTimeout((()=>{var t;const i=this.selection.range;if(!i.isInsideBox)if(this.isComposing)this.event.emit("input",e);else{if(i.isBoxStart||i.isBoxEnd)return this.inputInBoxStrip(),this.history.save(),void this.event.emit("input",e);if(("insertText"===e.inputType||"insertCompositionText"===e.inputType)&&(this.unsavedInputData+=null!==(t=e.data)&&void 0!==t?t:"",this.unsavedInputData.length<this.config.minChangeSize))return this.event.emit("input",e),void this.emitChangeEvent(this.getValue());this.history.save(),this.event.emit("input",e)}}),0)})),this.command.event.on("beforeexecute",(()=>this.commitUnsavedInputData()))}bindHistoryEvents(){this.history.event.on("undo",(t=>{this.box.renderAll(this),this.emitChangeEvent(t)})),this.history.event.on("redo",(t=>{this.box.renderAll(this),this.emitChangeEvent(t)})),this.history.event.on("save",(t=>{this.box.rectifyInstances(this),this.emitChangeEvent(t)}))}bindFocusEvents(){this.container.on("focus",(()=>{this.root.addClass("lake-root-focused")})),this.container.on("blur",(()=>{this.root.removeClass("lake-root-focused")}))}get locale(){return He(this.config.lang)}rectifyContent(){let t=this.container.children();for(const e of t)(e.isBlock||e.isMark)&&""===e.html()&&(e.remove(),A("Rectifying content: empty tag was removed"));if(t=this.container.children(),0===t.length)return this.container.html("<p><br /></p>"),this.selection.range.shrinkAfter(this.container),void A("Rectifying content: default paragraph was added");if(1===t.length){const e=t[0];if(e.isVoid){const t=I("<p />");e.before(t),t.append(e),this.selection.range.shrinkAfter(t),A("Rectifying content: void element was wrapped in paragraph")}}}commitUnsavedInputData(){this.unsavedInputData.length>0&&(this.history.save(!1),this.unsavedInputData="")}prepareOperation(){this.commitUnsavedInputData(),this.history.pause()}commitOperation(){this.history.continue(),this.history.save()}setPluginConfig(t,e){this.config[t]||(this.config[t]={});for(const i of Object.keys(e))void 0===this.config[t][i]&&(this.config[t][i]=e[i])}focus(){this.container.focus()}blur(){this.container.blur()}setValue(t){t=u(t);const e=new ie(t).getFragment();this.container.empty(),this.container.append(e),$r.box.renderAll(this),this.selection.synByBookmark()}getValue(){const t=this.selection.insertBookmark();let e=new ie(this.container).getHTML();return e=m(e),this.selection.toBookmark(t),e}insertBox(t,e){const i=function(t,e,i){if(t.commonAncestor.isOutside)return null;const n=new Yt(e);i&&(n.value=i);const s=document.createDocumentFragment();if(s.appendChild(n.node.get(0)),"inline"===n.type)return he(t,s),n.render(),t.selectBoxEnd(n.node),n;const o=ue(t);return o.start&&(t.setEndAfter(o.start),t.collapseToEnd()),o.end&&o.end.isEmpty&&o.end.remove(),he(t,s),n.render(),t.selectBoxEnd(n.node),o.start&&o.start.isEmpty&&o.start.remove(),n}(this.selection.range,t,e);if(!i)throw new Error(`Box '${t}' cannot be inserted outside the editor.`);return this.box.getInstances(this).set(i.node.id,i),i}removeBox(){const t=function(t){if(t.commonAncestor.isOutside)return null;const e=t.commonAncestor.closest("lake-box");if(0===e.length)return null;const i=new Yt(e);if("block"===i.type){const n=I("<p><br /></p>");return e.before(n),t.shrinkAfter(n),i.unmount(),e.remove(),i}t.setStartBefore(e),t.collapseToStart();const n=e.parent();return i.unmount(),e.remove(),n.isEmpty&&(P(n,I("<br />")),t.shrinkAfter(n)),i}(this.selection.range);if(t){this.box.getInstances(this).delete(t.node.id)}return t}render(){const t=u(this.config.value),e=new ie(t).getFragment();this.root.empty(),this.root.append(this.containerWrapper),this.containerWrapper.append(this.container),this.containerWrapper.append(this.overlayContainer),I(document.body).append(this.popupContainer),this.container.append(e),$r.plugin.loadAll(this),this.readonly||(this.bindFocusEvents(),this.selection.synByBookmark(),this.history.save()),$r.box.renderAll(this),this.toolbar&&this.toolbar.render(this),this.readonly||(window.addEventListener("beforeunload",this.beforeunloadListener),document.addEventListener("selectionchange",this.selectionchangeListener),document.addEventListener("click",this.clickListener),window.addEventListener("resize",this.resizeListener),this.bindInputEvents(),this.bindHistoryEvents())}unmount(){this.root.empty(),this.popupContainer.remove(),this.readonly||(window.removeEventListener("beforeunload",this.beforeunloadListener),document.removeEventListener("selectionchange",this.selectionchangeListener),document.removeEventListener("click",this.clickListener),window.removeEventListener("resize",this.resizeListener))}}$r.version="0.1.3",$r.box=new class{add(t){Kt.set(t.name,t)}remove(t){Kt.delete(t)}getNames(){return Array.from(Kt.keys())}getInstances(t){let e=Br.get(t.container.id);return e||(e=new Map,Br.set(t.container.id,e),e)}rectifyInstances(t){const e=this.getInstances(t);for(const t of e.values())t.node.get(0).isConnected||(t.unmount(),e.delete(t.node.id))}findAll(t){return t.container.find("lake-box")}renderAll(t){this.rectifyInstances(t);const e=this.getInstances(t);this.findAll(t).each((t=>{const i=new E(t);if(e.get(i.id))return;const n=new Yt(i);n.render(),e.set(n.node.id,n)}))}},$r.plugin=new class{constructor(){this.pluginList=[]}add(t){this.pluginList.push(t)}loadAll(t){this.pluginList.forEach((e=>{e(t)}))}};const Vr=[{icon:n.get("numberedList"),value:"numbered",text:t=>t.toolbar.numberedList()},{icon:n.get("bulletedList"),value:"bulleted",text:t=>t.toolbar.bulletedList()},{icon:n.get("checklist"),value:"checklist",text:t=>t.toolbar.checklist()}],Fr=[{icon:n.get("alignLeft"),value:"left",text:t=>t.toolbar.alignLeft()},{icon:n.get("alignCenter"),value:"center",text:t=>t.toolbar.alignCenter()},{icon:n.get("alignRight"),value:"right",text:t=>t.toolbar.alignRight()},{icon:n.get("alignJustify"),value:"justify",text:t=>t.toolbar.alignJustify()}],jr=[{icon:n.get("increaseIndent"),value:"increase",text:t=>t.toolbar.increaseIndent()},{icon:n.get("decreaseIndent"),value:"decrease",text:t=>t.toolbar.decreaseIndent()}],Rr=[{icon:n.get("italic"),value:"italic",text:t=>t.toolbar.italic()},{icon:n.get("underline"),value:"underline",text:t=>t.toolbar.underline()},{icon:n.get("strikethrough"),value:"strikethrough",text:t=>t.toolbar.strikethrough()},{icon:n.get("superscript"),value:"superscript",text:t=>t.toolbar.superscript()},{icon:n.get("subscript"),value:"subscript",text:t=>t.toolbar.subscript()},{icon:n.get("code"),value:"code",text:t=>t.toolbar.code()}],Wr=["#f5222d","#fa541c","#fa8c16","#faad14","#fadb14","#a0d911","#52c41a","#13c2c2","#1677ff","#2f54eb","#722ed1","#eb2f96","#fff1f0","#fff2e8","#fff7e6","#fffbe6","#feffe6","#fcffe6","#f6ffed","#e6fffb","#e6f4ff","#f0f5ff","#f9f0ff","#fff0f6","#ffccc7","#ffd8bf","#ffe7ba","#fff1b8","#ffffb8","#f4ffb8","#d9f7be","#b5f5ec","#bae0ff","#d6e4ff","#efdbff","#ffd6e7","#ffa39e","#ffbb96","#ffd591","#ffe58f","#fffb8f","#eaff8f","#b7eb8f","#87e8de","#91caff","#adc6ff","#d3adf7","#ffadd2","#ff7875","#ff9c6e","#ffc069","#ffd666","#fff566","#d3f261","#95de64","#5cdbd3","#69b1ff","#85a5ff","#b37feb","#ff85c0","#ff4d4f","#ff7a45","#ffa940","#ffc53d","#ffec3d","#bae637","#73d13d","#36cfc9","#4096ff","#597ef7","#9254de","#f759ab","#cf1322","#d4380d","#d46b08","#d48806","#d4b106","#7cb305","#389e0d","#08979c","#0958d9","#1d39c4","#531dab","#c41d7f","#a8071a","#ad2102","#ad4e00","#ad6800","#ad8b00","#5b8c00","#237804","#006d75","#003eb3","#10239e","#391085","#9e1068","#820014","#871400","#873800","#874d00","#876800","#3f6600","#135200","#00474f","#002c8c","#061178","#22075e","#780650","#5c0011","#610b00","#612500","#613400","#614700","#254000","#092b00","#002329","#001d66","#030852","#120338","#520339","#000000","#1f1f1f","#262626","#434343","#595959","#8c8c8c","#bfbfbf","#d9d9d9","#f0f0f0","#f5f5f5","#fafafa","#ffffff"],Ur=[{icon:n.get("removeFormat"),value:"",text:t=>t.toolbar.removeColor()}];for(const t of Wr)Ur.push({value:t.toLowerCase(),text:t.toUpperCase()});const qr=new Map([["strong","bold"],["em","italic"],["i","italic"],["u","underline"],["s","strikethrough"],["sup","superscript"],["sub","subscript"],["code","code"]]),Kr=[{name:"undo",type:"button",icon:n.get("undo"),tooltip:t=>t.toolbar.undo(),onClick:(t,e)=>{t.command.execute(e)}},{name:"redo",type:"button",icon:n.get("redo"),tooltip:t=>t.toolbar.redo(),onClick:(t,e)=>{t.command.execute(e)}},{name:"selectAll",type:"button",icon:n.get("selectAll"),tooltip:t=>t.toolbar.selectAll(),onClick:(t,e)=>{t.command.execute(e)}},{name:"paragraph",type:"button",icon:n.get("paragraph"),tooltip:t=>t.toolbar.paragraph(),isSelected:t=>!!t.find((t=>"p"===t.name)),onClick:t=>{t.command.execute("heading","p")}},{name:"blockQuote",type:"button",icon:n.get("blockQuote"),tooltip:t=>t.toolbar.blockQuote(),onClick:(t,e)=>{t.command.execute(e)}},{name:"numberedList",type:"button",icon:n.get("numberedList"),tooltip:t=>t.toolbar.numberedList(),isSelected:t=>!!t.find((t=>"ol"===t.name)),onClick:t=>{t.command.execute("list","numbered")}},{name:"bulletedList",type:"button",icon:n.get("bulletedList"),tooltip:t=>t.toolbar.bulletedList(),isSelected:t=>!!t.find((t=>"ul"===t.name&&!t.node.hasAttr("type"))),onClick:t=>{t.command.execute("list","bulleted")}},{name:"checklist",type:"button",icon:n.get("checklist"),tooltip:t=>t.toolbar.checklist(),isSelected:t=>!!t.find((t=>"ul"===t.name&&"checklist"===t.node.attr("type"))),onClick:t=>{t.command.execute("list","checklist")}},{name:"alignLeft",type:"button",icon:n.get("alignLeft"),tooltip:t=>t.toolbar.alignLeft(),isSelected:t=>!!t.find((t=>t.node.isBlock&&"left"===t.node.css("text-align"))),onClick:t=>{t.command.execute("align","left")}},{name:"alignCenter",type:"button",icon:n.get("alignCenter"),tooltip:t=>t.toolbar.alignCenter(),isSelected:t=>!!t.find((t=>t.node.isBlock&&"center"===t.node.css("text-align"))),onClick:t=>{t.command.execute("align","center")}},{name:"alignRight",type:"button",icon:n.get("alignRight"),tooltip:t=>t.toolbar.alignRight(),isSelected:t=>!!t.find((t=>t.node.isBlock&&"right"===t.node.css("text-align"))),onClick:t=>{t.command.execute("align","right")}},{name:"alignJustify",type:"button",icon:n.get("alignJustify"),tooltip:t=>t.toolbar.alignJustify(),isSelected:t=>!!t.find((t=>t.node.isBlock&&"justify"===t.node.css("text-align"))),onClick:t=>{t.command.execute("align","justify")}},{name:"increaseIndent",type:"button",icon:n.get("increaseIndent"),tooltip:t=>t.toolbar.increaseIndent(),onClick:t=>{t.command.execute("indent","increase")}},{name:"decreaseIndent",type:"button",icon:n.get("decreaseIndent"),tooltip:t=>t.toolbar.decreaseIndent(),onClick:t=>{t.command.execute("indent","decrease")}},{name:"bold",type:"button",icon:n.get("bold"),tooltip:t=>t.toolbar.bold(),onClick:(t,e)=>{t.command.execute(e)}},{name:"italic",type:"button",icon:n.get("italic"),tooltip:t=>t.toolbar.italic(),onClick:(t,e)=>{t.command.execute(e)}},{name:"underline",type:"button",icon:n.get("underline"),tooltip:t=>t.toolbar.underline(),onClick:(t,e)=>{t.command.execute(e)}},{name:"strikethrough",type:"button",icon:n.get("strikethrough"),tooltip:t=>t.toolbar.strikethrough(),onClick:(t,e)=>{t.command.execute(e)}},{name:"superscript",type:"button",icon:n.get("superscript"),tooltip:t=>t.toolbar.superscript(),onClick:(t,e)=>{t.command.execute(e)}},{name:"subscript",type:"button",icon:n.get("subscript"),tooltip:t=>t.toolbar.subscript(),onClick:(t,e)=>{t.command.execute(e)}},{name:"code",type:"button",icon:n.get("code"),tooltip:t=>t.toolbar.code(),onClick:(t,e)=>{t.command.execute(e)}},{name:"removeFormat",type:"button",icon:n.get("removeFormat"),tooltip:t=>t.toolbar.removeFormat(),onClick:(t,e)=>{t.command.execute(e)}},{name:"formatPainter",type:"button",icon:n.get("formatPainter"),tooltip:t=>t.toolbar.formatPainter(),onClick:(t,e)=>{t.command.execute(e)}},{name:"link",type:"button",icon:n.get("link"),tooltip:t=>t.toolbar.link(),onClick:(t,e)=>{t.command.execute(e)}},{name:"hr",type:"button",icon:n.get("hr"),tooltip:t=>t.toolbar.hr(),onClick:(t,e)=>{t.command.execute(e)}},{name:"codeBlock",type:"button",icon:n.get("codeBlock"),tooltip:t=>t.toolbar.codeBlock(),onClick:(t,e)=>{t.command.execute(e)}},{name:"heading",type:"dropdown",downIcon:n.get("down"),defaultValue:"p",tooltip:t=>t.toolbar.heading(),width:"100px",menuType:"list",menuItems:[{value:"h1",text:t=>`<span style="font-weight: bold; font-size: 26px;">${t.toolbar.heading1()}</span>`},{value:"h2",text:t=>`<span style="font-weight: bold; font-size: 24px;">${t.toolbar.heading2()}</span>`},{value:"h3",text:t=>`<span style="font-weight: bold; font-size: 22px;">${t.toolbar.heading3()}</span>`},{value:"h4",text:t=>`<span style="font-weight: bold; font-size: 20px;">${t.toolbar.heading4()}</span>`},{value:"h5",text:t=>`<span style="font-weight: bold; font-size: 18px;">${t.toolbar.heading5()}</span>`},{value:"h6",text:t=>`<span style="font-weight: bold; font-size: 16px;">${t.toolbar.heading6()}</span>`},{value:"p",text:t=>t.toolbar.paragraph()}],onSelect:(t,e)=>{t.command.execute("heading",e)}},{name:"list",type:"dropdown",downIcon:n.get("down"),icon:n.get("list"),defaultValue:"",tooltip:t=>t.toolbar.list(),width:"auto",menuType:"list",menuItems:Vr,onSelect:(t,e)=>{t.command.execute("list",e)}},{name:"align",type:"dropdown",downIcon:n.get("down"),icon:n.get("alignLeft"),defaultValue:"",tooltip:t=>t.toolbar.align(),width:"auto",menuType:"list",menuItems:Fr,onSelect:(t,e)=>{t.command.execute("align",e)}},{name:"indent",type:"dropdown",downIcon:n.get("down"),icon:n.get("increaseIndent"),defaultValue:"",tooltip:t=>t.toolbar.indent(),width:"auto",menuType:"list",menuItems:jr,onSelect:(t,e)=>{t.command.execute("indent",e)}},{name:"fontFamily",type:"dropdown",downIcon:n.get("down"),defaultValue:"Segoe UI",tooltip:t=>t.toolbar.fontFamily(),width:"100px",menuType:"list",menuItems:[{value:"Arial",text:'<span style="font-family: Arial;">Arial</span>'},{value:"Arial Black",text:"<span style=\"font-family: 'Arial Black';\">Arial Black</span>"},{value:"Comic Sans MS",text:"<span style=\"font-family: 'Comic Sans MS';\">Comic Sans MS</span>"},{value:"Courier New",text:"<span style=\"font-family: 'Courier New';\">Courier New</span>"},{value:"Georgia",text:'<span style="font-family: Georgia;">Georgia</span>'},{value:"Helvetica",text:'<span style="font-family: Helvetica;">Helvetica</span>'},{value:"Impact",text:'<span style="font-family: Impact;">Impact</span>'},{value:"Segoe UI",text:"<span style=\"font-family: 'Segoe UI';\">Segoe UI</span>"},{value:"Tahoma",text:'<span style="font-family: Tahoma;">Tahoma</span>'},{value:"Times New Roman",text:"<span style=\"font-family: 'Times New Roman';\">Times New Roman</span>"},{value:"Trebuchet MS",text:"<span style=\"font-family: 'Trebuchet MS';\">Trebuchet MS</span>"},{value:"Verdana",text:'<span style="font-family: Verdana;">Verdana</span>'}],onSelect:(t,e)=>{t.command.execute("fontFamily",e)}},{name:"fontSize",type:"dropdown",downIcon:n.get("down"),defaultValue:"16px",tooltip:t=>t.toolbar.fontSize(),width:"65px",menuType:"list",menuItems:[{value:"12px",text:"12px"},{value:"14px",text:"14px"},{value:"16px",text:"16px"},{value:"18px",text:"18px"},{value:"22px",text:"22px"},{value:"24px",text:"24px"},{value:"32px",text:"32px"}],onSelect:(t,e)=>{t.command.execute("fontSize",e)}},{name:"moreStyle",type:"dropdown",icon:n.get("more"),defaultValue:"",tooltip:t=>t.toolbar.moreStyle(),width:"auto",menuType:"list",menuItems:Rr,selectedValues:t=>{var e;const i=[];for(const n of t)if(n.node.isMark){const t=null!==(e=qr.get(n.name))&&void 0!==e?e:n.name;i.push(t)}return i},onSelect:(t,e)=>{t.command.execute(e)}},{name:"fontColor",type:"dropdown",downIcon:n.get("down"),icon:n.get("fontColor"),accentIcon:n.get("fontColorAccent"),defaultValue:"#f5222d",tooltip:t=>t.toolbar.fontColor(),width:"auto",menuType:"color",menuItems:Ur,onSelect:(t,e)=>{t.command.execute("fontColor",e)}},{name:"highlight",type:"dropdown",downIcon:n.get("down"),icon:n.get("highlight"),accentIcon:n.get("highlightAccent"),defaultValue:"#fadb14",tooltip:t=>t.toolbar.highlight(),width:"auto",menuType:"color",menuItems:Ur,onSelect:(t,e)=>{t.command.execute("highlight",e)}},{name:"image",type:"upload",icon:n.get("image"),tooltip:t=>t.toolbar.image(),accept:"image/*",multiple:!0}];function Gr(t){const{editor:e,file:i,onError:n,onSuccess:s}=t,{requestMethod:o,requestAction:r,requestTypes:a}=e.config.image;if(a.indexOf(i.type)<0)throw new Error(`Cannot upload file because its type '${i.type}' is not found in ['${a.join("', '")}'].`);const l=e.insertBox("image",{url:URL.createObjectURL(i),status:"uploading",name:i.name,size:i.size,type:i.type,lastModified:i.lastModified}),c=pt({onProgress:t=>{const e=l.node.find(".lake-percent"),i=Math.round(t.percent);e.text(`${i<100?i:99} %`)},onError:(t,e)=>{A(t.toString(),e),l.updateValue("status","error"),l.render(),n&&n()},onSuccess:t=>{if(!t.url)return l.updateValue("status","error"),l.render(),void(n&&n());l.updateValue({status:"done",url:t.url}),l.render(),e.history.save(),s&&s()},file:i,action:r,method:o});return l.setData("xhr",c),l}const Xr=["undo","redo","|","heading","|","formatPainter","removeFormat","bold","moreStyle","|","fontColor","highlight","|","align","list","indent","link","blockQuote","hr"],Jr=new Map;Kr.forEach((t=>{Jr.set(t.name,t)}));function Qr(t,e,i,n){return new(i||(i=Promise))((function(s,o){function r(t){try{l(n.next(t))}catch(t){o(t)}}function a(t){try{l(n.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}l((n=n.apply(t,e||[])).next())}))}
18
+ `);if(t.append(a),"color"===e.menuType&&(a.attr("title",o),a.find(".lake-dropdown-menu-text").css("background-color",i.value)),i.icon){const t=I('<div class="lake-dropdown-menu-icon"></div>');t.append(i.icon),a.prepend(t)}const l=n.get("check");if(l){const t=I('<div class="lake-dropdown-menu-check"></div>');t.append(l),a.prepend(t)}}}showMenu(){const t=this.config,e=this.node,i=e.find(".lake-dropdown-menu");if(e.attr("disabled"))return;const n=De.getValue(e);i.find(".lake-dropdown-menu-check").css("visibility","hidden"),i.find("li").each((t=>{const e=I(t);e.on("mouseenter",(()=>{e.hasClass("lake-dropdown-item-selected")||e.addClass("lake-dropdown-item-hovered")})),e.on("mouseleave",(()=>{e.removeClass("lake-dropdown-item-hovered")})),n.indexOf(e.attr("value"))>=0&&e.find(".lake-dropdown-menu-check").css("visibility","visible")})),i.css("visibility","hidden"),i.show("color"===t.menuType?"flex":"block");e.get(0).getBoundingClientRect().x+i.width()+50>window.innerWidth?(i.css("left","auto"),i.css("right","0")):(i.css("left",""),i.css("right","")),i.css("visibility",""),document.addEventListener("click",this.documentClickListener)}bindEvents(){const t=this.config,e=this.node,i=e.find(".lake-dropdown-title"),n=i.find(".lake-dropdown-text"),s=i.find(".lake-dropdown-icon"),o=i.find(".lake-dropdown-down-icon"),r=e.find(".lake-dropdown-menu");"color"===t.menuType?(s.on("mouseenter",(()=>{e.attr("disabled")||s.addClass("lake-dropdown-icon-hovered")})),s.on("mouseleave",(()=>{s.removeClass("lake-dropdown-icon-hovered")})),o.on("mouseenter",(()=>{e.attr("disabled")||o.addClass("lake-dropdown-down-icon-hovered")})),o.on("mouseleave",(()=>{o.removeClass("lake-dropdown-down-icon-hovered")}))):(i.on("mouseenter",(()=>{e.attr("disabled")||i.addClass("lake-dropdown-title-hovered")})),i.on("mouseleave",(()=>{i.removeClass("lake-dropdown-title-hovered")}))),"color"===t.menuType&&s.on("click",(i=>{if(i.preventDefault(),e.attr("disabled"))return;const n=e.attr("color")||t.defaultValue;t.onSelect(n)}));("color"===t.menuType&&o?o:i).on("click",(t=>{t.preventDefault(),this.showMenu()})),r.on("click",(s=>{s.preventDefault();const o=I(s.target).closest("li"),a=o.attr("value");De.setValue(e,[a]),n.length>0&&n.text(o.text()),"color"===t.menuType&&""!==a&&(e.attr("color",a),this.updateColorAccent(i,a)),t.onSelect(a),r.hide(),document.removeEventListener("click",this.documentClickListener)}))}render(){var t;const e=this.config,i=this.node,n=i.find(".lake-dropdown-title");e.downIcon||n.addClass("lake-dropdown-title-no-down"),n.css("width",e.width);const s="string"==typeof e.tooltip?e.tooltip:e.tooltip(this.locale);n.attr("title",s);const o=n.find(".lake-dropdown-text"),r=n.find(".lake-dropdown-icon");e.icon&&r.append(e.icon),e.accentIcon&&r.append(e.accentIcon);const a=n.find(".lake-dropdown-down-icon");e.downIcon&&a.append(e.downIcon);const l=I('<ul class="lake-dropdown-menu" />');if(l.addClass(`lake-${e.menuType}-dropdown-menu`),De.setValue(i,[e.defaultValue]),o.length>0){const i=De.getMenuMap(e.menuItems,this.locale);o.text(null!==(t=i.get(e.defaultValue))&&void 0!==t?t:e.defaultValue)}"color"===e.menuType&&this.updateColorAccent(n,e.defaultValue),this.apppendMenuItems(l),i.append(n),i.append(l),this.root.append(i),this.bindEvents()}unmount(){this.node.remove(),document.removeEventListener("click",this.documentClickListener)}}var $e=function(t){var e=typeof t;return null!=t&&("object"==e||"function"==e)},Ve="object"==typeof Rt&&Rt&&Rt.Object===Object&&Rt,Fe=Ve,je="object"==typeof self&&self&&self.Object===Object&&self,Re=Fe||je||Function("return this")(),We=Re,Ue=function(){return We.Date.now()},qe=/\s/;var Ke=function(t){for(var e=t.length;e--&&qe.test(t.charAt(e)););return e},Ge=Ke,Xe=/^\s+/;var Je=function(t){return t?t.slice(0,Ge(t)+1).replace(Xe,""):t},Qe=Re.Symbol,Ye=Qe,ti=Object.prototype,ei=ti.hasOwnProperty,ii=ti.toString,ni=Ye?Ye.toStringTag:void 0;var si=function(t){var e=ei.call(t,ni),i=t[ni];try{t[ni]=void 0;var n=!0}catch(t){}var s=ii.call(t);return n&&(e?t[ni]=i:delete t[ni]),s},oi=Object.prototype.toString;var ri=si,ai=function(t){return oi.call(t)},li=Qe?Qe.toStringTag:void 0;var ci=function(t){return null==t?void 0===t?"[object Undefined]":"[object Null]":li&&li in Object(t)?ri(t):ai(t)};var hi=function(t){return null!=t&&"object"==typeof t},di=ci,pi=hi;var ui=Je,mi=$e,fi=function(t){return"symbol"==typeof t||pi(t)&&"[object Symbol]"==di(t)},gi=/^[-+]0x[0-9a-f]+$/i,vi=/^0b[01]+$/i,yi=/^0o[0-7]+$/i,wi=parseInt;var xi=$e,bi=Ue,ki=function(t){if("number"==typeof t)return t;if(fi(t))return NaN;if(mi(t)){var e="function"==typeof t.valueOf?t.valueOf():t;t=mi(e)?e+"":e}if("string"!=typeof t)return 0===t?t:+t;t=ui(t);var i=vi.test(t);return i||yi.test(t)?wi(t.slice(2),i?2:8):gi.test(t)?NaN:+t},_i=Math.max,Si=Math.min;var Ci=function(t,e,i){var n,s,o,r,a,l,c=0,h=!1,d=!1,p=!0;if("function"!=typeof t)throw new TypeError("Expected a function");function u(e){var i=n,o=s;return n=s=void 0,c=e,r=t.apply(o,i)}function m(t){var i=t-l;return void 0===l||i>=e||i<0||d&&t-c>=o}function f(){var t=bi();if(m(t))return g(t);a=setTimeout(f,function(t){var i=e-(t-l);return d?Si(i,o-(t-c)):i}(t))}function g(t){return a=void 0,p&&n?u(t):(n=s=void 0,r)}function v(){var t=bi(),i=m(t);if(n=arguments,s=this,l=t,i){if(void 0===a)return function(t){return c=t,a=setTimeout(f,e),h?u(t):r}(l);if(d)return clearTimeout(a),a=setTimeout(f,e),u(l)}return void 0===a&&(a=setTimeout(f,e)),r}return e=ki(e)||0,xi(i)&&(h=!!i.leading,o=(d="maxWait"in i)?_i(ki(i.maxWait)||0,e):o,p="trailing"in i?!!i.trailing:p),v.cancel=function(){void 0!==a&&clearTimeout(a),c=0,n=l=s=a=void 0},v.flush=function(){return void 0===a?r:g(bi())},v},Ai=Wt(Ci);var Bi=function(){this.__data__=[],this.size=0};var Ti=function(t,e){return t===e||t!=t&&e!=e},Ei=Ti;var Ii=function(t,e){for(var i=t.length;i--;)if(Ei(t[i][0],e))return i;return-1},Li=Ii,Mi=Array.prototype.splice;var Pi=function(t){var e=this.__data__,i=Li(e,t);return!(i<0)&&(i==e.length-1?e.pop():Mi.call(e,i,1),--this.size,!0)},Oi=Ii;var zi=function(t){var e=this.__data__,i=Oi(e,t);return i<0?void 0:e[i][1]},Zi=Ii;var Ni=Ii;var Hi=function(t,e){var i=this.__data__,n=Ni(i,t);return n<0?(++this.size,i.push([t,e])):i[n][1]=e,this},Di=Bi,$i=Pi,Vi=zi,Fi=function(t){return Zi(this.__data__,t)>-1},ji=Hi;function Ri(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}Ri.prototype.clear=Di,Ri.prototype.delete=$i,Ri.prototype.get=Vi,Ri.prototype.has=Fi,Ri.prototype.set=ji;var Wi=Ri,Ui=Wi;var qi=function(){this.__data__=new Ui,this.size=0};var Ki=function(t){var e=this.__data__,i=e.delete(t);return this.size=e.size,i};var Gi=function(t){return this.__data__.get(t)};var Xi=function(t){return this.__data__.has(t)},Ji=ci,Qi=$e;var Yi,tn=function(t){if(!Qi(t))return!1;var e=Ji(t);return"[object Function]"==e||"[object GeneratorFunction]"==e||"[object AsyncFunction]"==e||"[object Proxy]"==e},en=Re["__core-js_shared__"],nn=(Yi=/[^.]+$/.exec(en&&en.keys&&en.keys.IE_PROTO||""))?"Symbol(src)_1."+Yi:"";var sn=function(t){return!!nn&&nn in t},on=Function.prototype.toString;var rn=function(t){if(null!=t){try{return on.call(t)}catch(t){}try{return t+""}catch(t){}}return""},an=tn,ln=sn,cn=$e,hn=rn,dn=/^\[object .+?Constructor\]$/,pn=Function.prototype,un=Object.prototype,mn=pn.toString,fn=un.hasOwnProperty,gn=RegExp("^"+mn.call(fn).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$");var vn=function(t){return!(!cn(t)||ln(t))&&(an(t)?gn:dn).test(hn(t))},yn=function(t,e){return null==t?void 0:t[e]};var wn=function(t,e){var i=yn(t,e);return vn(i)?i:void 0},xn=wn(Re,"Map"),bn=wn(Object,"create"),kn=bn;var _n=function(){this.__data__=kn?kn(null):{},this.size=0};var Sn=function(t){var e=this.has(t)&&delete this.__data__[t];return this.size-=e?1:0,e},Cn=bn,An=Object.prototype.hasOwnProperty;var Bn=function(t){var e=this.__data__;if(Cn){var i=e[t];return"__lodash_hash_undefined__"===i?void 0:i}return An.call(e,t)?e[t]:void 0},Tn=bn,En=Object.prototype.hasOwnProperty;var In=bn;var Ln=_n,Mn=Sn,Pn=Bn,On=function(t){var e=this.__data__;return Tn?void 0!==e[t]:En.call(e,t)},zn=function(t,e){var i=this.__data__;return this.size+=this.has(t)?0:1,i[t]=In&&void 0===e?"__lodash_hash_undefined__":e,this};function Zn(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}Zn.prototype.clear=Ln,Zn.prototype.delete=Mn,Zn.prototype.get=Pn,Zn.prototype.has=On,Zn.prototype.set=zn;var Nn=Zn,Hn=Wi,Dn=xn;var $n=function(t){var e=typeof t;return"string"==e||"number"==e||"symbol"==e||"boolean"==e?"__proto__"!==t:null===t};var Vn=function(t,e){var i=t.__data__;return $n(e)?i["string"==typeof e?"string":"hash"]:i.map},Fn=Vn;var jn=Vn;var Rn=Vn;var Wn=Vn;var Un=function(){this.size=0,this.__data__={hash:new Nn,map:new(Dn||Hn),string:new Nn}},qn=function(t){var e=Fn(this,t).delete(t);return this.size-=e?1:0,e},Kn=function(t){return jn(this,t).get(t)},Gn=function(t){return Rn(this,t).has(t)},Xn=function(t,e){var i=Wn(this,t),n=i.size;return i.set(t,e),this.size+=i.size==n?0:1,this};function Jn(t){var e=-1,i=null==t?0:t.length;for(this.clear();++e<i;){var n=t[e];this.set(n[0],n[1])}}Jn.prototype.clear=Un,Jn.prototype.delete=qn,Jn.prototype.get=Kn,Jn.prototype.has=Gn,Jn.prototype.set=Xn;var Qn=Jn,Yn=Wi,ts=xn,es=Qn;var is=Wi,ns=qi,ss=Ki,os=Gi,rs=Xi,as=function(t,e){var i=this.__data__;if(i instanceof Yn){var n=i.__data__;if(!ts||n.length<199)return n.push([t,e]),this.size=++i.size,this;i=this.__data__=new es(n)}return i.set(t,e),this.size=i.size,this};function ls(t){var e=this.__data__=new is(t);this.size=e.size}ls.prototype.clear=ns,ls.prototype.delete=ss,ls.prototype.get=os,ls.prototype.has=rs,ls.prototype.set=as;var cs=ls;var hs=Qn,ds=function(t){return this.__data__.set(t,"__lodash_hash_undefined__"),this},ps=function(t){return this.__data__.has(t)};function us(t){var e=-1,i=null==t?0:t.length;for(this.__data__=new hs;++e<i;)this.add(t[e])}us.prototype.add=us.prototype.push=ds,us.prototype.has=ps;var ms=function(t,e){for(var i=-1,n=null==t?0:t.length;++i<n;)if(e(t[i],i,t))return!0;return!1};var fs=us,gs=ms,vs=function(t,e){return t.has(e)};var ys=function(t,e,i,n,s,o){var r=1&i,a=t.length,l=e.length;if(a!=l&&!(r&&l>a))return!1;var c=o.get(t),h=o.get(e);if(c&&h)return c==e&&h==t;var d=-1,p=!0,u=2&i?new fs:void 0;for(o.set(t,e),o.set(e,t);++d<a;){var m=t[d],f=e[d];if(n)var g=r?n(f,m,d,e,t,o):n(m,f,d,t,e,o);if(void 0!==g){if(g)continue;p=!1;break}if(u){if(!gs(e,(function(t,e){if(!vs(u,e)&&(m===t||s(m,t,i,n,o)))return u.push(e)}))){p=!1;break}}else if(m!==f&&!s(m,f,i,n,o)){p=!1;break}}return o.delete(t),o.delete(e),p};var ws=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t,n){i[++e]=[n,t]})),i};var xs=function(t){var e=-1,i=Array(t.size);return t.forEach((function(t){i[++e]=t})),i},bs=Re.Uint8Array,ks=Ti,_s=ys,Ss=ws,Cs=xs,As=Qe?Qe.prototype:void 0,Bs=As?As.valueOf:void 0;var Ts=function(t,e,i,n,s,o,r){switch(i){case"[object DataView]":if(t.byteLength!=e.byteLength||t.byteOffset!=e.byteOffset)return!1;t=t.buffer,e=e.buffer;case"[object ArrayBuffer]":return!(t.byteLength!=e.byteLength||!o(new bs(t),new bs(e)));case"[object Boolean]":case"[object Date]":case"[object Number]":return ks(+t,+e);case"[object Error]":return t.name==e.name&&t.message==e.message;case"[object RegExp]":case"[object String]":return t==e+"";case"[object Map]":var a=Ss;case"[object Set]":var l=1&n;if(a||(a=Cs),t.size!=e.size&&!l)return!1;var c=r.get(t);if(c)return c==e;n|=2,r.set(t,e);var h=_s(a(t),a(e),n,s,o,r);return r.delete(t),h;case"[object Symbol]":if(Bs)return Bs.call(t)==Bs.call(e)}return!1};var Es=function(t,e){for(var i=-1,n=e.length,s=t.length;++i<n;)t[s+i]=e[i];return t},Is=Array.isArray,Ls=Es,Ms=Is;var Ps=function(t,e,i){var n=e(t);return Ms(t)?n:Ls(n,i(t))};var Os=function(t,e){for(var i=-1,n=null==t?0:t.length,s=0,o=[];++i<n;){var r=t[i];e(r,i,t)&&(o[s++]=r)}return o};var zs=Os,Zs=function(){return[]},Ns=Object.prototype.propertyIsEnumerable,Hs=Object.getOwnPropertySymbols,Ds=Hs?function(t){return null==t?[]:(t=Object(t),zs(Hs(t),(function(e){return Ns.call(t,e)})))}:Zs;var $s=function(t,e){for(var i=-1,n=Array(t);++i<t;)n[i]=e(i);return n},Vs=ci,Fs=hi;var js=function(t){return Fs(t)&&"[object Arguments]"==Vs(t)},Rs=hi,Ws=Object.prototype,Us=Ws.hasOwnProperty,qs=Ws.propertyIsEnumerable,Ks=js(function(){return arguments}())?js:function(t){return Rs(t)&&Us.call(t,"callee")&&!qs.call(t,"callee")},Gs=Ks,Xs={exports:{}};var Js=function(){return!1};!function(t,e){var i=Re,n=Js,s=e&&!e.nodeType&&e,o=s&&t&&!t.nodeType&&t,r=o&&o.exports===s?i.Buffer:void 0,a=(r?r.isBuffer:void 0)||n;t.exports=a}(Xs,Xs.exports);var Qs=Xs.exports,Ys=/^(?:0|[1-9]\d*)$/;var to=function(t,e){var i=typeof t;return!!(e=null==e?9007199254740991:e)&&("number"==i||"symbol"!=i&&Ys.test(t))&&t>-1&&t%1==0&&t<e};var eo=function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=9007199254740991},io=ci,no=eo,so=hi,oo={};oo["[object Float32Array]"]=oo["[object Float64Array]"]=oo["[object Int8Array]"]=oo["[object Int16Array]"]=oo["[object Int32Array]"]=oo["[object Uint8Array]"]=oo["[object Uint8ClampedArray]"]=oo["[object Uint16Array]"]=oo["[object Uint32Array]"]=!0,oo["[object Arguments]"]=oo["[object Array]"]=oo["[object ArrayBuffer]"]=oo["[object Boolean]"]=oo["[object DataView]"]=oo["[object Date]"]=oo["[object Error]"]=oo["[object Function]"]=oo["[object Map]"]=oo["[object Number]"]=oo["[object Object]"]=oo["[object RegExp]"]=oo["[object Set]"]=oo["[object String]"]=oo["[object WeakMap]"]=!1;var ro=function(t){return so(t)&&no(t.length)&&!!oo[io(t)]};var ao=function(t){return function(e){return t(e)}},lo={exports:{}};!function(t,e){var i=Ve,n=e&&!e.nodeType&&e,s=n&&t&&!t.nodeType&&t,o=s&&s.exports===n&&i.process,r=function(){try{var t=s&&s.require&&s.require("util").types;return t||o&&o.binding&&o.binding("util")}catch(t){}}();t.exports=r}(lo,lo.exports);var co=lo.exports,ho=ro,po=ao,uo=co&&co.isTypedArray,mo=uo?po(uo):ho,fo=$s,go=Gs,vo=Is,yo=Qs,wo=to,xo=mo,bo=Object.prototype.hasOwnProperty;var ko=function(t,e){var i=vo(t),n=!i&&go(t),s=!i&&!n&&yo(t),o=!i&&!n&&!s&&xo(t),r=i||n||s||o,a=r?fo(t.length,String):[],l=a.length;for(var c in t)!e&&!bo.call(t,c)||r&&("length"==c||s&&("offset"==c||"parent"==c)||o&&("buffer"==c||"byteLength"==c||"byteOffset"==c)||wo(c,l))||a.push(c);return a},_o=Object.prototype;var So=function(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||_o)};var Co=function(t,e){return function(i){return t(e(i))}}(Object.keys,Object),Ao=So,Bo=Co,To=Object.prototype.hasOwnProperty;var Eo=tn,Io=eo;var Lo=ko,Mo=function(t){if(!Ao(t))return Bo(t);var e=[];for(var i in Object(t))To.call(t,i)&&"constructor"!=i&&e.push(i);return e},Po=function(t){return null!=t&&Io(t.length)&&!Eo(t)};var Oo=Ps,zo=Ds,Zo=function(t){return Po(t)?Lo(t):Mo(t)};var No=function(t){return Oo(t,Zo,zo)},Ho=Object.prototype.hasOwnProperty;var Do=function(t,e,i,n,s,o){var r=1&i,a=No(t),l=a.length;if(l!=No(e).length&&!r)return!1;for(var c=l;c--;){var h=a[c];if(!(r?h in e:Ho.call(e,h)))return!1}var d=o.get(t),p=o.get(e);if(d&&p)return d==e&&p==t;var u=!0;o.set(t,e),o.set(e,t);for(var m=r;++c<l;){var f=t[h=a[c]],g=e[h];if(n)var v=r?n(g,f,h,e,t,o):n(f,g,h,t,e,o);if(!(void 0===v?f===g||s(f,g,i,n,o):v)){u=!1;break}m||(m="constructor"==h)}if(u&&!m){var y=t.constructor,w=e.constructor;y==w||!("constructor"in t)||!("constructor"in e)||"function"==typeof y&&y instanceof y&&"function"==typeof w&&w instanceof w||(u=!1)}return o.delete(t),o.delete(e),u},$o=wn(Re,"DataView"),Vo=xn,Fo=wn(Re,"Promise"),jo=wn(Re,"Set"),Ro=wn(Re,"WeakMap"),Wo=ci,Uo=rn,qo="[object Map]",Ko="[object Promise]",Go="[object Set]",Xo="[object WeakMap]",Jo="[object DataView]",Qo=Uo($o),Yo=Uo(Vo),tr=Uo(Fo),er=Uo(jo),ir=Uo(Ro),nr=Wo;($o&&nr(new $o(new ArrayBuffer(1)))!=Jo||Vo&&nr(new Vo)!=qo||Fo&&nr(Fo.resolve())!=Ko||jo&&nr(new jo)!=Go||Ro&&nr(new Ro)!=Xo)&&(nr=function(t){var e=Wo(t),i="[object Object]"==e?t.constructor:void 0,n=i?Uo(i):"";if(n)switch(n){case Qo:return Jo;case Yo:return qo;case tr:return Ko;case er:return Go;case ir:return Xo}return e});var sr=cs,or=ys,rr=Ts,ar=Do,lr=nr,cr=Is,hr=Qs,dr=mo,pr="[object Arguments]",ur="[object Array]",mr="[object Object]",fr=Object.prototype.hasOwnProperty;var gr=function(t,e,i,n,s,o){var r=cr(t),a=cr(e),l=r?ur:lr(t),c=a?ur:lr(e),h=(l=l==pr?mr:l)==mr,d=(c=c==pr?mr:c)==mr,p=l==c;if(p&&hr(t)){if(!hr(e))return!1;r=!0,h=!1}if(p&&!h)return o||(o=new sr),r||dr(t)?or(t,e,i,n,s,o):rr(t,e,l,i,n,s,o);if(!(1&i)){var u=h&&fr.call(t,"__wrapped__"),m=d&&fr.call(e,"__wrapped__");if(u||m){var f=u?t.value():t,g=m?e.value():e;return o||(o=new sr),s(f,g,i,n,o)}}return!!p&&(o||(o=new sr),ar(t,e,i,n,s,o))},vr=hi;var yr=function t(e,i,n,s,o){return e===i||(null==e||null==i||!vr(e)&&!vr(i)?e!=e&&i!=i:gr(e,i,n,s,t,o))},wr=yr;var xr=Wt((function(t,e){return wr(t,e)}));function br(t){const e=t.get(0),i={};if(e.hasAttributes())for(const t of e.attributes)i[t.name]=t.value;return i}class kr{constructor(t){const e=window.getSelection();if(!e)throw new Error("Selection object is null.");this.selection=e,this.container=t,this.range=this.getRangeFromNativeSelection()}getRangeFromNativeSelection(){if(this.selection.rangeCount>0){const t=this.selection.getRangeAt(0);return new L(t)}return new L}addRangeToNativeSelection(){this.selection.removeAllRanges(),this.selection.addRange(this.range.get())}syncByRange(){const t=this.getRangeFromNativeSelection();this.range.get()!==t.get()&&(this.range=t)}synByBookmark(){const t=this.range,e=this.container,i=e.find("lake-box[focus]");if(i.length>0)return ae(t,{anchor:new E,focus:i}),void this.addRangeToNativeSelection();ae(t,{anchor:e.find('lake-bookmark[type="anchor"]'),focus:e.find('lake-bookmark[type="focus"]')}),this.addRangeToNativeSelection()}getAppliedItems(){const t=[];return function(t,e){let i=e.startNode;for(i.isText&&(i=i.parent());i.length>0&&i.isInside;)t.push({node:i,name:i.name,attributes:br(i),styles:p(i.attr("style"))}),i=i.parent()}(t,this.range),function(t,e){const i=e.startNode;let n;if(i.isText&&i.text().length===e.startOffset){const t=i.next();t.length>0&&t.isElement&&(n=t)}if(i.isElement){const t=i.children();if(t.length>0){const i=t[e.startOffset];i&&i.isElement&&(n=i)}}if(n){let e=n;for(;e.length>0;)e.isElement&&t.push({node:e,name:e.name,attributes:br(e),styles:p(e.attr("style"))}),e=e.first()}}(t,this.range),t}insertBookmark(){return oe(this.range)}toBookmark(t){return ae(this.range,t)}insertNode(t){return se(this.range,t)}insertFragment(t){return he(this.range,t)}insertContents(t){return de(this.range,t)}deleteContents(){return ce(this.range)}setBlocks(t){return pe(this.range,t)}splitBlock(){return ue(this.range)}splitMarks(t){return ge(this.range,t)}addMark(t){return ye(this.range,t)}removeMark(t){return xe(this.range,t)}fixList(){return le(this.range)}insertLink(t){return be(this.range,t)}}class _r{constructor(t){this.commandMap=new Map,this.event=new qt,this.selection=t}add(t,e){this.commandMap.set(t,e)}delete(t){this.commandMap.delete(t)}getNames(){return Array.from(this.commandMap.keys())}has(t){return void 0!==this.commandMap.get(t)}getItem(t){const e=this.commandMap.get(t);if(void 0===e)throw new Error(`Command '${t}' does not exist.`);return e}isDisabled(t){const e=this.getItem(t);if(!e.isDisabled)return!1;const i=this.selection.getAppliedItems();return e.isDisabled(i)}isSelected(t){const e=this.getItem(t);if(!e.isSelected)return!1;const i=this.selection.getAppliedItems();return e.isSelected(i)}selectedValues(t){const e=this.getItem(t);if(!e.selectedValues)return[];const i=this.selection.getAppliedItems();return e.selectedValues(i)}execute(t,...e){const i=this.getItem(t);this.event.emit("beforeexecute",t),i.execute.apply(this,e),this.event.emit("execute",t),A(`Command '${t}' executed`)}}var Sr,Cr={exports:{}};Sr=Cr,function(t){function e(t,e){var i=(65535&t)+(65535&e);return(t>>16)+(e>>16)+(i>>16)<<16|65535&i}function i(t,i,n,s,o,r){return e((a=e(e(i,t),e(s,r)))<<(l=o)|a>>>32-l,n);var a,l}function n(t,e,n,s,o,r,a){return i(e&n|~e&s,t,e,o,r,a)}function s(t,e,n,s,o,r,a){return i(e&s|n&~s,t,e,o,r,a)}function o(t,e,n,s,o,r,a){return i(e^n^s,t,e,o,r,a)}function r(t,e,n,s,o,r,a){return i(n^(e|~s),t,e,o,r,a)}function a(t,i){var a,l,c,h,d;t[i>>5]|=128<<i%32,t[14+(i+64>>>9<<4)]=i;var p=1732584193,u=-271733879,m=-1732584194,f=271733878;for(a=0;a<t.length;a+=16)l=p,c=u,h=m,d=f,p=n(p,u,m,f,t[a],7,-680876936),f=n(f,p,u,m,t[a+1],12,-389564586),m=n(m,f,p,u,t[a+2],17,606105819),u=n(u,m,f,p,t[a+3],22,-1044525330),p=n(p,u,m,f,t[a+4],7,-176418897),f=n(f,p,u,m,t[a+5],12,1200080426),m=n(m,f,p,u,t[a+6],17,-1473231341),u=n(u,m,f,p,t[a+7],22,-45705983),p=n(p,u,m,f,t[a+8],7,1770035416),f=n(f,p,u,m,t[a+9],12,-1958414417),m=n(m,f,p,u,t[a+10],17,-42063),u=n(u,m,f,p,t[a+11],22,-1990404162),p=n(p,u,m,f,t[a+12],7,1804603682),f=n(f,p,u,m,t[a+13],12,-40341101),m=n(m,f,p,u,t[a+14],17,-1502002290),p=s(p,u=n(u,m,f,p,t[a+15],22,1236535329),m,f,t[a+1],5,-165796510),f=s(f,p,u,m,t[a+6],9,-1069501632),m=s(m,f,p,u,t[a+11],14,643717713),u=s(u,m,f,p,t[a],20,-373897302),p=s(p,u,m,f,t[a+5],5,-701558691),f=s(f,p,u,m,t[a+10],9,38016083),m=s(m,f,p,u,t[a+15],14,-660478335),u=s(u,m,f,p,t[a+4],20,-405537848),p=s(p,u,m,f,t[a+9],5,568446438),f=s(f,p,u,m,t[a+14],9,-1019803690),m=s(m,f,p,u,t[a+3],14,-187363961),u=s(u,m,f,p,t[a+8],20,1163531501),p=s(p,u,m,f,t[a+13],5,-1444681467),f=s(f,p,u,m,t[a+2],9,-51403784),m=s(m,f,p,u,t[a+7],14,1735328473),p=o(p,u=s(u,m,f,p,t[a+12],20,-1926607734),m,f,t[a+5],4,-378558),f=o(f,p,u,m,t[a+8],11,-2022574463),m=o(m,f,p,u,t[a+11],16,1839030562),u=o(u,m,f,p,t[a+14],23,-35309556),p=o(p,u,m,f,t[a+1],4,-1530992060),f=o(f,p,u,m,t[a+4],11,1272893353),m=o(m,f,p,u,t[a+7],16,-155497632),u=o(u,m,f,p,t[a+10],23,-1094730640),p=o(p,u,m,f,t[a+13],4,681279174),f=o(f,p,u,m,t[a],11,-358537222),m=o(m,f,p,u,t[a+3],16,-722521979),u=o(u,m,f,p,t[a+6],23,76029189),p=o(p,u,m,f,t[a+9],4,-640364487),f=o(f,p,u,m,t[a+12],11,-421815835),m=o(m,f,p,u,t[a+15],16,530742520),p=r(p,u=o(u,m,f,p,t[a+2],23,-995338651),m,f,t[a],6,-198630844),f=r(f,p,u,m,t[a+7],10,1126891415),m=r(m,f,p,u,t[a+14],15,-1416354905),u=r(u,m,f,p,t[a+5],21,-57434055),p=r(p,u,m,f,t[a+12],6,1700485571),f=r(f,p,u,m,t[a+3],10,-1894986606),m=r(m,f,p,u,t[a+10],15,-1051523),u=r(u,m,f,p,t[a+1],21,-2054922799),p=r(p,u,m,f,t[a+8],6,1873313359),f=r(f,p,u,m,t[a+15],10,-30611744),m=r(m,f,p,u,t[a+6],15,-1560198380),u=r(u,m,f,p,t[a+13],21,1309151649),p=r(p,u,m,f,t[a+4],6,-145523070),f=r(f,p,u,m,t[a+11],10,-1120210379),m=r(m,f,p,u,t[a+2],15,718787259),u=r(u,m,f,p,t[a+9],21,-343485551),p=e(p,l),u=e(u,c),m=e(m,h),f=e(f,d);return[p,u,m,f]}function l(t){var e,i="",n=32*t.length;for(e=0;e<n;e+=8)i+=String.fromCharCode(t[e>>5]>>>e%32&255);return i}function c(t){var e,i=[];for(i[(t.length>>2)-1]=void 0,e=0;e<i.length;e+=1)i[e]=0;var n=8*t.length;for(e=0;e<n;e+=8)i[e>>5]|=(255&t.charCodeAt(e/8))<<e%32;return i}function h(t){var e,i,n="0123456789abcdef",s="";for(i=0;i<t.length;i+=1)e=t.charCodeAt(i),s+=n.charAt(e>>>4&15)+n.charAt(15&e);return s}function d(t){return unescape(encodeURIComponent(t))}function p(t){return function(t){return l(a(c(t),8*t.length))}(d(t))}function u(t,e){return function(t,e){var i,n,s=c(t),o=[],r=[];for(o[15]=r[15]=void 0,s.length>16&&(s=a(s,8*t.length)),i=0;i<16;i+=1)o[i]=909522486^s[i],r[i]=1549556828^s[i];return n=a(o.concat(c(e)),512+8*e.length),l(a(r.concat(n),640))}(d(t),d(e))}function m(t,e,i){return e?i?u(e,t):h(u(e,t)):i?p(t):h(p(t))}Sr.exports?Sr.exports=m:t.md5=m}(Rt);var Ar=Wt(Cr.exports);const Br=new Map;class Tr{constructor(t){this.list=[],this.index=0,this.canSave=!0,this.limit=100,this.event=new qt,this.selection=t,this.container=t.container}removeBookmark(t){return t.replace(/(<lake-box[^>]+)\s+focus="\w+"([^>]*>)/gi,"$1$2").replace(/<lake-bookmark\s+type="anchor">\s*<\/lake-bookmark>/gi,"").replace(/<lake-bookmark\s+type="focus">\s*<\/lake-bookmark>/gi,"")}getValue(t){return new ie(t).getHTML()}addIdToBoxes(t){t.find("lake-box").each((t=>{const e=new E(t),i=Ar(`${e.attr("type")}-${e.attr("name")}-${e.attr("value")}`);e.attr("id",i)}))}removeIdfromBoxes(t){t.find("lake-box").each((t=>{new E(t).removeAttr("id")}))}morphContainer(t){const e=this.container,i={beforeChildrenUpdated:t=>{if("lake-box"===new E(t).name)return!1},afterAttributeUpdated:(t,i)=>{const n=new E(i);if("value"===t&&"lake-box"===n.name){const t=Br.get(e.id);if(!t)return;t.delete(n.id)}}},n=t.clone(!0);this.addIdToBoxes(e),this.addIdToBoxes(n),ht(e,n,{callbacks:i}),this.removeIdfromBoxes(e),this.removeIdfromBoxes(n)}cloneContainer(){const t=this.selection.range,e=this.container.clone(!0);if(e.find("lake-box").each((t=>{new Yt(t).getContainer().empty()})),t.commonAncestor.isOutside)return e;if(t.isInsideBox)return e;const i=t.startNode.path(),n=t.endNode.path(),s=e.find(i),o=e.find(n),r=t.clone();return r.setStart(s,t.startOffset),r.setEnd(o,t.endOffset),oe(r),e}get count(){return this.list.length}get canUndo(){return this.index>1&&!!this.list[this.index-1]}get canRedo(){return!!this.list[this.index]}undo(){if(!this.list[this.index-1])return;this.selection.insertBookmark();const t=this.getValue(this.container);for(;this.index>0;){const e=this.list[this.index-1];if(!e)break;const i=this.getValue(e);if(this.removeBookmark(i)!==this.removeBookmark(t)){this.morphContainer(e),this.event.emit("undo",i);break}if(1===this.index)break;this.index--}this.selection.synByBookmark(),A(`History undone, the last index is ${this.index}`)}redo(){if(!this.list[this.index])return;this.selection.insertBookmark();const t=this.getValue(this.container);for(;this.index<this.list.length;){const e=this.list[this.index];if(!e)break;this.index++;const i=this.getValue(e);if(this.removeBookmark(i)!==this.removeBookmark(t)){this.morphContainer(e),this.event.emit("redo",i);break}}this.selection.synByBookmark(),A(`History redone, the last index is ${this.index}`)}continue(){this.canSave=!0}pause(){this.canSave=!1}save(t=!0){if(!this.canSave)return;const e=this.cloneContainer(),i=this.getValue(e);this.list[this.index-1]&&this.removeBookmark(this.getValue(this.list[this.index-1]))===this.removeBookmark(i)||(this.list.splice(this.index,1/0,e),this.index++,this.list.length>this.limit&&(this.list.shift(),this.index=this.list.length),t&&this.event.emit("save",m(i)),A(`History saved, the last index is ${this.index}`))}}var Er=["Shift","Meta","Alt","Control"],Ir="object"==typeof navigator?navigator.platform:"",Lr=/Mac|iPod|iPhone|iPad/.test(Ir),Mr=Lr?"Meta":"Control",Pr="Win32"===Ir?["Control","Alt"]:Lr?["Alt"]:[];function Or(t,e){return"function"==typeof t.getModifierState&&(t.getModifierState(e)||Pr.includes(e)&&t.getModifierState("AltGraph"))}function zr(t){return t.trim().split(" ").map((function(t){var e=t.split(/\b\+/),i=e.pop();return[e=e.map((function(t){return"$mod"===t?Mr:t})),i]}))}function Zr(t,e){var i;void 0===e&&(e={});var n=null!=(i=e.timeout)?i:1e3,s=Object.keys(t).map((function(e){return[zr(e),t[e]]})),o=new Map,r=null;return function(t){t instanceof KeyboardEvent&&(s.forEach((function(e){var i=e[0],n=e[1],s=o.get(i)||i;!function(t,e){return!(e[1].toUpperCase()!==t.key.toUpperCase()&&e[1]!==t.code||e[0].find((function(e){return!Or(t,e)}))||Er.find((function(i){return!e[0].includes(i)&&e[1]!==i&&Or(t,i)})))}(t,s[0])?Or(t,t.key)||o.delete(i):s.length>1?o.set(i,s.slice(1)):(o.delete(i),n(t))})),r&&clearTimeout(r),r=setTimeout(o.clear.bind(o),n))}}const Nr=new Map([["#","shift+#"]]);class Hr{constructor(t){this.keydownEventList=[],this.keyupEventList=[],this.container=t}normalizeType(t){var e;return t=(t=null!==(e=Nr.get(t))&&void 0!==e?e:t).replace(/(^|\+|\s)mod(\+|\s|$)/g,"$1$mod$2").replace(/shift|control|alt|meta|enter|tab|backspace|delete|space|escape|arrow-left|arrow-right|arrow-up|arrow-down/,(t=>t.charAt(0).toUpperCase()+l(t.substring(1)))).replace(/(^|\+|\s)([a-z])(\+|\s|$)/g,((t,e,i,n)=>`${e}Key${i.toUpperCase()}${n}`))}setKeydown(t,e){t=this.normalizeType(t);const i=Zr({[t]:t=>e(t)});this.keydownEventList.push({type:t,listener:e}),this.container.on("keydown",i)}setKeyup(t,e){t=this.normalizeType(t);const i=Zr({[t]:t=>e(t)});this.keyupEventList.push({type:t,listener:e}),this.container.on("keyup",i)}keydown(t){t=this.normalizeType(t);for(const e of this.keydownEventList)if(e.type===t&&!1===e.listener(new Event(t)))break}keyup(t){t=this.normalizeType(t);for(const e of this.keyupEventList)if(e.type===t&&!1===e.listener(new Event(t)))break}}const Dr={value:"<p><br /><focus /></p>",readonly:!1,spellcheck:!1,tabIndex:0,indentWithTab:!0,lang:"en-US",minChangeSize:5};class $r{constructor(t){if(this.unsavedInputData="",this.stateData={appliedItems:[],disabledNameMap:new Map,selectedNameMap:new Map,selectedValuesMap:new Map},this.isComposing=!1,this.event=new qt,this.box=$r.box,this.beforeunloadListener=()=>{this.history.save()},this.selectionchangeListener=()=>{this.selection.syncByRange(),this.updateBoxSelectionStyle(),this.emitStateChangeEvent()},this.clickListener=t=>{const e=new E(t.target);e.closest(".lake-popup").length>0||this.event.emit("click",e)},this.resizeListener=()=>{this.event.emit("resize")},this.updateBoxSelectionStyle=Ai((()=>{if(0===this.root.first().length)return;const t=this.selection.range,e=t.clone();e.adaptBox(),this.box.findAll(this).each((i=>{const n=new Yt(i),s=n.getContainer();if(0!==s.length){if(t.compareBeforeNode(s)<0&&t.compareAfterNode(s)>0&&(!t.isCollapsed||t.startNode.get(0)!==s.get(0)||0!==t.startOffset))return s.removeClass("lake-box-hovered"),s.removeClass("lake-box-selected"),s.removeClass("lake-box-focused"),void s.addClass("lake-box-activated");if(e.intersectsNode(n.node))return s.removeClass("lake-box-activated"),void(t.isCollapsed?(s.removeClass("lake-box-hovered"),s.removeClass("lake-box-selected"),s.addClass("lake-box-focused")):(s.removeClass("lake-box-focused"),s.addClass("lake-box-selected")));s.removeClass("lake-box-activated"),s.removeClass("lake-box-focused"),s.removeClass("lake-box-selected")}})),this.event.emit("boxselectionstylechange")}),50,{leading:!1,trailing:!0,maxWait:50}),this.emitStateChangeEvent=Ai((()=>{const t=this.command.getNames();let e=this.selection.getAppliedItems();e.length>0&&e[0].node.closestContainer().get(0)!==this.container.get(0)&&(e=[]);const i=new Map,n=new Map,s=new Map;if(e.length>0)for(const o of t){const t=this.command.getItem(o);if(t.isDisabled&&t.isDisabled(e)&&i.set(o,!0),t.isSelected&&t.isSelected(e)&&n.set(o,!0),t.selectedValues){const i=t.selectedValues(e);i.length>0&&s.set(o,i)}}const o={appliedItems:e,disabledNameMap:i,selectedNameMap:n,selectedValuesMap:s};xr(o,this.stateData)||(this.toolbar&&this.toolbar.updateState(o),this.event.emit("statechange",o),this.stateData=o)}),100,{leading:!1,trailing:!0,maxWait:100}),this.emitChangeEvent=t=>{this.rectifyContent(),this.emitStateChangeEvent(),this.event.emit("change",t)},!t.root)throw new Error("The root of the config must be specified.");this.root=I(t.root),this.toolbar=t.toolbar,this.config=Object.assign({},Dr);for(const e of Object.keys(t))this.config[e]=t[e];this.containerWrapper=I('<div class="lake-container-wrapper" />'),this.container=I('<div class="lake-container" />'),this.overlayContainer=I('<div class="lake-overlay" />'),this.popupContainer=I('<div class="lake-popup lake-custom-properties" />'),this.readonly=this.config.readonly,this.root.addClass("lake-custom-properties"),this.container.attr({contenteditable:this.readonly?"false":"true",spellcheck:this.config.spellcheck?"true":"false",tabindex:this.config.tabIndex.toString()}),this.selection=new kr(this.container),this.command=new _r(this.selection),this.history=new Tr(this.selection),this.keystroke=new Hr(this.container),Gt.set(this.container.id,this)}inputInBoxStrip(){const t=this.selection,e=t.range,i=e.startNode.closest(".lake-box-strip"),n=i.closest("lake-box");if("inline"===new Yt(n).type)e.isBoxStart?(e.setStartBefore(n),e.collapseToStart()):(e.setStartAfter(n),e.collapseToStart());else{const t=I("<p />");e.isBoxStart?n.before(t):n.after(t),e.shrinkAfter(t)}const s=i.text();i.html("<br />"),t.insertNode(document.createTextNode(s))}bindInputEvents(){this.container.on("compositionstart",(()=>{this.isComposing=!0})),this.container.on("compositionend",(()=>{this.isComposing=!1})),this.container.on("beforeinput",(t=>{const e=t,i=this.selection.range;(i.isBoxStart||i.isBoxEnd||"insertText"!==e.inputType&&"insertCompositionText"!==e.inputType)&&this.commitUnsavedInputData()})),this.container.on("input",(t=>{const e=t;window.setTimeout((()=>{var t;const i=this.selection.range;if(!i.isInsideBox)if(this.isComposing)this.event.emit("input",e);else{if(i.isBoxStart||i.isBoxEnd)return this.inputInBoxStrip(),this.history.save(),void this.event.emit("input",e);if(("insertText"===e.inputType||"insertCompositionText"===e.inputType)&&(this.unsavedInputData+=null!==(t=e.data)&&void 0!==t?t:"",this.unsavedInputData.length<this.config.minChangeSize))return this.event.emit("input",e),void this.emitChangeEvent(this.getValue());this.history.save(),this.event.emit("input",e)}}),0)})),this.command.event.on("beforeexecute",(()=>this.commitUnsavedInputData()))}bindHistoryEvents(){this.history.event.on("undo",(t=>{this.box.renderAll(this),this.emitChangeEvent(t)})),this.history.event.on("redo",(t=>{this.box.renderAll(this),this.emitChangeEvent(t)})),this.history.event.on("save",(t=>{this.box.rectifyInstances(this),this.emitChangeEvent(t)}))}get hasFocus(){const t=document.activeElement;return!!t&&I(t).closest(".lake-container").get(0)===this.container.get(0)}get locale(){return He(this.config.lang)}rectifyContent(){let t=this.container.children();for(const e of t)(e.isBlock||e.isMark)&&""===e.html()&&(e.remove(),A("Rectifying content: empty tag was removed"));if(t=this.container.children(),0===t.length)return this.container.html("<p><br /></p>"),this.selection.range.shrinkAfter(this.container),void A("Rectifying content: default paragraph was added");if(1===t.length){const e=t[0];if(e.isVoid){const t=I("<p />");e.before(t),t.append(e),this.selection.range.shrinkAfter(t),A("Rectifying content: void element was wrapped in paragraph")}}}commitUnsavedInputData(){this.unsavedInputData.length>0&&(this.history.save(!1),this.unsavedInputData="")}prepareOperation(){this.commitUnsavedInputData(),this.history.pause()}commitOperation(){this.history.continue(),this.history.save()}setPluginConfig(t,e){this.config[t]||(this.config[t]={});for(const i of Object.keys(e))void 0===this.config[t][i]&&(this.config[t][i]=e[i])}focus(){this.container.focus()}blur(){this.container.blur()}setValue(t){t=u(t);const e=new ie(t).getFragment();this.container.empty(),this.container.append(e),$r.box.renderAll(this),this.selection.synByBookmark()}getValue(){const t=this.selection.insertBookmark();let e=new ie(this.container).getHTML();return e=m(e),this.selection.toBookmark(t),e}insertBox(t,e){const i=function(t,e,i){if(t.commonAncestor.isOutside)return null;const n=new Yt(e);i&&(n.value=i);const s=document.createDocumentFragment();if(s.appendChild(n.node.get(0)),"inline"===n.type)return he(t,s),n.render(),t.selectBoxEnd(n.node),n;const o=ue(t);return o.start&&(t.setEndAfter(o.start),t.collapseToEnd()),o.end&&o.end.isEmpty&&o.end.remove(),he(t,s),n.render(),t.selectBoxEnd(n.node),o.start&&o.start.isEmpty&&o.start.remove(),n}(this.selection.range,t,e);if(!i)throw new Error(`Box '${t}' cannot be inserted outside the editor.`);return this.box.getInstances(this).set(i.node.id,i),i}removeBox(){const t=function(t){if(t.commonAncestor.isOutside)return null;const e=t.commonAncestor.closest("lake-box");if(0===e.length)return null;const i=new Yt(e);if("block"===i.type){const n=I("<p><br /></p>");return e.before(n),t.shrinkAfter(n),i.unmount(),e.remove(),i}t.setStartBefore(e),t.collapseToStart();const n=e.parent();return i.unmount(),e.remove(),n.isEmpty&&(P(n,I("<br />")),t.shrinkAfter(n)),i}(this.selection.range);if(t){this.box.getInstances(this).delete(t.node.id)}return t}render(){const t=u(this.config.value),e=new ie(t).getFragment();this.root.empty(),this.root.append(this.containerWrapper),this.containerWrapper.append(this.container),this.containerWrapper.append(this.overlayContainer),I(document.body).append(this.popupContainer),this.container.append(e),$r.plugin.loadAll(this),this.readonly||(this.selection.synByBookmark(),this.history.save()),$r.box.renderAll(this),this.toolbar&&this.toolbar.render(this),this.readonly||(window.addEventListener("beforeunload",this.beforeunloadListener),document.addEventListener("selectionchange",this.selectionchangeListener),document.addEventListener("click",this.clickListener),window.addEventListener("resize",this.resizeListener),this.bindInputEvents(),this.bindHistoryEvents())}unmount(){this.root.empty(),this.popupContainer.remove(),this.readonly||(window.removeEventListener("beforeunload",this.beforeunloadListener),document.removeEventListener("selectionchange",this.selectionchangeListener),document.removeEventListener("click",this.clickListener),window.removeEventListener("resize",this.resizeListener))}}$r.version="0.1.4",$r.box=new class{add(t){Kt.set(t.name,t)}remove(t){Kt.delete(t)}getNames(){return Array.from(Kt.keys())}getInstances(t){let e=Br.get(t.container.id);return e||(e=new Map,Br.set(t.container.id,e),e)}rectifyInstances(t){const e=this.getInstances(t);for(const t of e.values())t.node.get(0).isConnected||(t.unmount(),e.delete(t.node.id))}findAll(t){return t.container.find("lake-box")}renderAll(t){this.rectifyInstances(t);const e=this.getInstances(t);this.findAll(t).each((t=>{const i=new E(t);if(e.get(i.id))return;const n=new Yt(i);n.render(),e.set(n.node.id,n)}))}},$r.plugin=new class{constructor(){this.pluginList=[]}add(t){this.pluginList.push(t)}loadAll(t){this.pluginList.forEach((e=>{e(t)}))}};const Vr=[{icon:n.get("numberedList"),value:"numbered",text:t=>t.toolbar.numberedList()},{icon:n.get("bulletedList"),value:"bulleted",text:t=>t.toolbar.bulletedList()},{icon:n.get("checklist"),value:"checklist",text:t=>t.toolbar.checklist()}],Fr=[{icon:n.get("alignLeft"),value:"left",text:t=>t.toolbar.alignLeft()},{icon:n.get("alignCenter"),value:"center",text:t=>t.toolbar.alignCenter()},{icon:n.get("alignRight"),value:"right",text:t=>t.toolbar.alignRight()},{icon:n.get("alignJustify"),value:"justify",text:t=>t.toolbar.alignJustify()}],jr=[{icon:n.get("increaseIndent"),value:"increase",text:t=>t.toolbar.increaseIndent()},{icon:n.get("decreaseIndent"),value:"decrease",text:t=>t.toolbar.decreaseIndent()}],Rr=[{icon:n.get("italic"),value:"italic",text:t=>t.toolbar.italic()},{icon:n.get("underline"),value:"underline",text:t=>t.toolbar.underline()},{icon:n.get("strikethrough"),value:"strikethrough",text:t=>t.toolbar.strikethrough()},{icon:n.get("superscript"),value:"superscript",text:t=>t.toolbar.superscript()},{icon:n.get("subscript"),value:"subscript",text:t=>t.toolbar.subscript()},{icon:n.get("code"),value:"code",text:t=>t.toolbar.code()}],Wr=["#f5222d","#fa541c","#fa8c16","#faad14","#fadb14","#a0d911","#52c41a","#13c2c2","#1677ff","#2f54eb","#722ed1","#eb2f96","#fff1f0","#fff2e8","#fff7e6","#fffbe6","#feffe6","#fcffe6","#f6ffed","#e6fffb","#e6f4ff","#f0f5ff","#f9f0ff","#fff0f6","#ffccc7","#ffd8bf","#ffe7ba","#fff1b8","#ffffb8","#f4ffb8","#d9f7be","#b5f5ec","#bae0ff","#d6e4ff","#efdbff","#ffd6e7","#ffa39e","#ffbb96","#ffd591","#ffe58f","#fffb8f","#eaff8f","#b7eb8f","#87e8de","#91caff","#adc6ff","#d3adf7","#ffadd2","#ff7875","#ff9c6e","#ffc069","#ffd666","#fff566","#d3f261","#95de64","#5cdbd3","#69b1ff","#85a5ff","#b37feb","#ff85c0","#ff4d4f","#ff7a45","#ffa940","#ffc53d","#ffec3d","#bae637","#73d13d","#36cfc9","#4096ff","#597ef7","#9254de","#f759ab","#cf1322","#d4380d","#d46b08","#d48806","#d4b106","#7cb305","#389e0d","#08979c","#0958d9","#1d39c4","#531dab","#c41d7f","#a8071a","#ad2102","#ad4e00","#ad6800","#ad8b00","#5b8c00","#237804","#006d75","#003eb3","#10239e","#391085","#9e1068","#820014","#871400","#873800","#874d00","#876800","#3f6600","#135200","#00474f","#002c8c","#061178","#22075e","#780650","#5c0011","#610b00","#612500","#613400","#614700","#254000","#092b00","#002329","#001d66","#030852","#120338","#520339","#000000","#1f1f1f","#262626","#434343","#595959","#8c8c8c","#bfbfbf","#d9d9d9","#f0f0f0","#f5f5f5","#fafafa","#ffffff"],Ur=[{icon:n.get("removeFormat"),value:"",text:t=>t.toolbar.removeColor()}];for(const t of Wr)Ur.push({value:t.toLowerCase(),text:t.toUpperCase()});const qr=new Map([["strong","bold"],["em","italic"],["i","italic"],["u","underline"],["s","strikethrough"],["sup","superscript"],["sub","subscript"],["code","code"]]),Kr=[{name:"undo",type:"button",icon:n.get("undo"),tooltip:t=>t.toolbar.undo(),onClick:(t,e)=>{t.command.execute(e)}},{name:"redo",type:"button",icon:n.get("redo"),tooltip:t=>t.toolbar.redo(),onClick:(t,e)=>{t.command.execute(e)}},{name:"selectAll",type:"button",icon:n.get("selectAll"),tooltip:t=>t.toolbar.selectAll(),onClick:(t,e)=>{t.command.execute(e)}},{name:"paragraph",type:"button",icon:n.get("paragraph"),tooltip:t=>t.toolbar.paragraph(),isSelected:t=>!!t.find((t=>"p"===t.name)),onClick:t=>{t.command.execute("heading","p")}},{name:"blockQuote",type:"button",icon:n.get("blockQuote"),tooltip:t=>t.toolbar.blockQuote(),onClick:(t,e)=>{t.command.execute(e)}},{name:"numberedList",type:"button",icon:n.get("numberedList"),tooltip:t=>t.toolbar.numberedList(),isSelected:t=>!!t.find((t=>"ol"===t.name)),onClick:t=>{t.command.execute("list","numbered")}},{name:"bulletedList",type:"button",icon:n.get("bulletedList"),tooltip:t=>t.toolbar.bulletedList(),isSelected:t=>!!t.find((t=>"ul"===t.name&&!t.node.hasAttr("type"))),onClick:t=>{t.command.execute("list","bulleted")}},{name:"checklist",type:"button",icon:n.get("checklist"),tooltip:t=>t.toolbar.checklist(),isSelected:t=>!!t.find((t=>"ul"===t.name&&"checklist"===t.node.attr("type"))),onClick:t=>{t.command.execute("list","checklist")}},{name:"alignLeft",type:"button",icon:n.get("alignLeft"),tooltip:t=>t.toolbar.alignLeft(),isSelected:t=>!!t.find((t=>t.node.isBlock&&"left"===t.node.css("text-align"))),onClick:t=>{t.command.execute("align","left")}},{name:"alignCenter",type:"button",icon:n.get("alignCenter"),tooltip:t=>t.toolbar.alignCenter(),isSelected:t=>!!t.find((t=>t.node.isBlock&&"center"===t.node.css("text-align"))),onClick:t=>{t.command.execute("align","center")}},{name:"alignRight",type:"button",icon:n.get("alignRight"),tooltip:t=>t.toolbar.alignRight(),isSelected:t=>!!t.find((t=>t.node.isBlock&&"right"===t.node.css("text-align"))),onClick:t=>{t.command.execute("align","right")}},{name:"alignJustify",type:"button",icon:n.get("alignJustify"),tooltip:t=>t.toolbar.alignJustify(),isSelected:t=>!!t.find((t=>t.node.isBlock&&"justify"===t.node.css("text-align"))),onClick:t=>{t.command.execute("align","justify")}},{name:"increaseIndent",type:"button",icon:n.get("increaseIndent"),tooltip:t=>t.toolbar.increaseIndent(),onClick:t=>{t.command.execute("indent","increase")}},{name:"decreaseIndent",type:"button",icon:n.get("decreaseIndent"),tooltip:t=>t.toolbar.decreaseIndent(),onClick:t=>{t.command.execute("indent","decrease")}},{name:"bold",type:"button",icon:n.get("bold"),tooltip:t=>t.toolbar.bold(),onClick:(t,e)=>{t.command.execute(e)}},{name:"italic",type:"button",icon:n.get("italic"),tooltip:t=>t.toolbar.italic(),onClick:(t,e)=>{t.command.execute(e)}},{name:"underline",type:"button",icon:n.get("underline"),tooltip:t=>t.toolbar.underline(),onClick:(t,e)=>{t.command.execute(e)}},{name:"strikethrough",type:"button",icon:n.get("strikethrough"),tooltip:t=>t.toolbar.strikethrough(),onClick:(t,e)=>{t.command.execute(e)}},{name:"superscript",type:"button",icon:n.get("superscript"),tooltip:t=>t.toolbar.superscript(),onClick:(t,e)=>{t.command.execute(e)}},{name:"subscript",type:"button",icon:n.get("subscript"),tooltip:t=>t.toolbar.subscript(),onClick:(t,e)=>{t.command.execute(e)}},{name:"code",type:"button",icon:n.get("code"),tooltip:t=>t.toolbar.code(),onClick:(t,e)=>{t.command.execute(e)}},{name:"removeFormat",type:"button",icon:n.get("removeFormat"),tooltip:t=>t.toolbar.removeFormat(),onClick:(t,e)=>{t.command.execute(e)}},{name:"formatPainter",type:"button",icon:n.get("formatPainter"),tooltip:t=>t.toolbar.formatPainter(),onClick:(t,e)=>{t.command.execute(e)}},{name:"link",type:"button",icon:n.get("link"),tooltip:t=>t.toolbar.link(),onClick:(t,e)=>{t.command.execute(e)}},{name:"hr",type:"button",icon:n.get("hr"),tooltip:t=>t.toolbar.hr(),onClick:(t,e)=>{t.command.execute(e)}},{name:"codeBlock",type:"button",icon:n.get("codeBlock"),tooltip:t=>t.toolbar.codeBlock(),onClick:(t,e)=>{t.command.execute(e)}},{name:"heading",type:"dropdown",downIcon:n.get("down"),defaultValue:"p",tooltip:t=>t.toolbar.heading(),width:"100px",menuType:"list",menuItems:[{value:"h1",text:t=>`<span style="font-weight: bold; font-size: 26px;">${t.toolbar.heading1()}</span>`},{value:"h2",text:t=>`<span style="font-weight: bold; font-size: 24px;">${t.toolbar.heading2()}</span>`},{value:"h3",text:t=>`<span style="font-weight: bold; font-size: 22px;">${t.toolbar.heading3()}</span>`},{value:"h4",text:t=>`<span style="font-weight: bold; font-size: 20px;">${t.toolbar.heading4()}</span>`},{value:"h5",text:t=>`<span style="font-weight: bold; font-size: 18px;">${t.toolbar.heading5()}</span>`},{value:"h6",text:t=>`<span style="font-weight: bold; font-size: 16px;">${t.toolbar.heading6()}</span>`},{value:"p",text:t=>t.toolbar.paragraph()}],onSelect:(t,e)=>{t.command.execute("heading",e)}},{name:"list",type:"dropdown",downIcon:n.get("down"),icon:n.get("list"),defaultValue:"",tooltip:t=>t.toolbar.list(),width:"auto",menuType:"list",menuItems:Vr,onSelect:(t,e)=>{t.command.execute("list",e)}},{name:"align",type:"dropdown",downIcon:n.get("down"),icon:n.get("alignLeft"),defaultValue:"",tooltip:t=>t.toolbar.align(),width:"auto",menuType:"list",menuItems:Fr,onSelect:(t,e)=>{t.command.execute("align",e)}},{name:"indent",type:"dropdown",downIcon:n.get("down"),icon:n.get("increaseIndent"),defaultValue:"",tooltip:t=>t.toolbar.indent(),width:"auto",menuType:"list",menuItems:jr,onSelect:(t,e)=>{t.command.execute("indent",e)}},{name:"fontFamily",type:"dropdown",downIcon:n.get("down"),defaultValue:"Segoe UI",tooltip:t=>t.toolbar.fontFamily(),width:"100px",menuType:"list",menuItems:[{value:"Arial",text:'<span style="font-family: Arial;">Arial</span>'},{value:"Arial Black",text:"<span style=\"font-family: 'Arial Black';\">Arial Black</span>"},{value:"Comic Sans MS",text:"<span style=\"font-family: 'Comic Sans MS';\">Comic Sans MS</span>"},{value:"Courier New",text:"<span style=\"font-family: 'Courier New';\">Courier New</span>"},{value:"Georgia",text:'<span style="font-family: Georgia;">Georgia</span>'},{value:"Helvetica",text:'<span style="font-family: Helvetica;">Helvetica</span>'},{value:"Impact",text:'<span style="font-family: Impact;">Impact</span>'},{value:"Segoe UI",text:"<span style=\"font-family: 'Segoe UI';\">Segoe UI</span>"},{value:"Tahoma",text:'<span style="font-family: Tahoma;">Tahoma</span>'},{value:"Times New Roman",text:"<span style=\"font-family: 'Times New Roman';\">Times New Roman</span>"},{value:"Trebuchet MS",text:"<span style=\"font-family: 'Trebuchet MS';\">Trebuchet MS</span>"},{value:"Verdana",text:'<span style="font-family: Verdana;">Verdana</span>'}],onSelect:(t,e)=>{t.command.execute("fontFamily",e)}},{name:"fontSize",type:"dropdown",downIcon:n.get("down"),defaultValue:"16px",tooltip:t=>t.toolbar.fontSize(),width:"65px",menuType:"list",menuItems:[{value:"12px",text:"12px"},{value:"14px",text:"14px"},{value:"16px",text:"16px"},{value:"18px",text:"18px"},{value:"22px",text:"22px"},{value:"24px",text:"24px"},{value:"32px",text:"32px"}],onSelect:(t,e)=>{t.command.execute("fontSize",e)}},{name:"moreStyle",type:"dropdown",icon:n.get("more"),defaultValue:"",tooltip:t=>t.toolbar.moreStyle(),width:"auto",menuType:"list",menuItems:Rr,selectedValues:t=>{var e;const i=[];for(const n of t)if(n.node.isMark){const t=null!==(e=qr.get(n.name))&&void 0!==e?e:n.name;i.push(t)}return i},onSelect:(t,e)=>{t.command.execute(e)}},{name:"fontColor",type:"dropdown",downIcon:n.get("down"),icon:n.get("fontColor"),accentIcon:n.get("fontColorAccent"),defaultValue:"#f5222d",tooltip:t=>t.toolbar.fontColor(),width:"auto",menuType:"color",menuItems:Ur,onSelect:(t,e)=>{t.command.execute("fontColor",e)}},{name:"highlight",type:"dropdown",downIcon:n.get("down"),icon:n.get("highlight"),accentIcon:n.get("highlightAccent"),defaultValue:"#fadb14",tooltip:t=>t.toolbar.highlight(),width:"auto",menuType:"color",menuItems:Ur,onSelect:(t,e)=>{t.command.execute("highlight",e)}},{name:"image",type:"upload",icon:n.get("image"),tooltip:t=>t.toolbar.image(),accept:"image/*",multiple:!0}];function Gr(t){const{editor:e,file:i,onError:n,onSuccess:s}=t,{requestMethod:o,requestAction:r,requestTypes:a}=e.config.image;if(a.indexOf(i.type)<0)throw new Error(`Cannot upload file because its type '${i.type}' is not found in ['${a.join("', '")}'].`);const l=e.insertBox("image",{url:URL.createObjectURL(i),status:"uploading",name:i.name,size:i.size,type:i.type,lastModified:i.lastModified}),c=pt({onProgress:t=>{const e=l.node.find(".lake-percent"),i=Math.round(t.percent);e.text(`${i<100?i:99} %`)},onError:(t,e)=>{A(t.toString(),e),l.updateValue("status","error"),l.render(),n&&n()},onSuccess:t=>{if(!t.url)return l.updateValue("status","error"),l.render(),void(n&&n());l.updateValue({status:"done",url:t.url}),l.render(),e.history.save(),s&&s()},file:i,action:r,method:o});return l.setData("xhr",c),l}const Xr=["undo","redo","|","heading","|","formatPainter","removeFormat","bold","moreStyle","|","fontColor","highlight","|","align","list","indent","link","blockQuote","hr"],Jr=new Map;Kr.forEach((t=>{Jr.set(t.name,t)}));function Qr(t,e,i,n){return new(i||(i=Promise))((function(s,o){function r(t){try{l(n.next(t))}catch(t){o(t)}}function a(t){try{l(n.throw(t))}catch(t){o(t)}}function l(t){var e;t.done?s(t.value):(e=t.value,e instanceof i?e:new i((function(t){t(e)}))).then(r,a)}l((n=n.apply(t,e||[])).next())}))}
19
19
  /*!
20
20
  * PhotoSwipe Lightbox 5.4.3 - https://photoswipe.com
21
21
  * (c) 2023 Dmytro Semenov
@@ -66,7 +66,7 @@ function Yr(t,e,i){const n=document.createElement(e);return t&&(n.className=t),i
66
66
  </div>
67
67
  <div class="lake-row lake-button-row"></div>
68
68
  </div>
69
- `)}writeClipboardText(t){return Qr(this,void 0,void 0,(function*(){let e=!1;try{window.LAKE_TEST?e=window.LAKE_ERROR:yield navigator.clipboard.writeText(t)}catch(t){e=!0}return new Promise((t=>{t(e)}))}))}appendCopyButton(){let t=null;const e=new ke({root:this.container.find(".lake-url-row"),name:"copy",icon:n.get("copy"),tooltip:this.locale.link.copy(),onClick:()=>{if(!this.linkNode)return;const e=this.getInputValue("url");this.writeClipboardText(e).then((e=>{const i=this.container.find('button[name="copy"] svg');if(i.hide(),e)return i.eq(2).show("inline"),void this.event.emit("copy",e);i.eq(1).show("inline"),this.event.emit("copy",e),t&&window.clearTimeout(t),t=window.setTimeout((()=>{i.hide(),i.eq(0).show("inline")}),2e3)}))}});e.render();const i=n.get("checkCircle");i&&e.node.append(i);const s=n.get("warningCircle");s&&e.node.append(s)}appendOpenButton(){new ke({root:this.container.find(".lake-url-row"),name:"open",icon:n.get("open"),tooltip:this.locale.link.open(),onClick:()=>{if(!this.linkNode)return;const t=this.getInputValue("url");window.open(t)}}).render()}appendSaveButton(){new ke({root:this.container.find(".lake-button-row"),name:"save",icon:n.get("check"),text:this.locale.link.save(),onClick:()=>{if(!this.linkNode)return;const t=this.linkNode;this.save(),this.hide(),this.event.emit("save",t)}}).render()}appendUnlinkButton(){new ke({root:this.container.find(".lake-button-row"),name:"unlink",icon:n.get("unlink"),text:this.locale.link.unlink(),onClick:()=>{if(!this.linkNode)return;const t=this.linkNode.last();this.linkNode.remove(!0),this.hide(),this.event.emit("remove",t)}}).render()}getInputValue(t){return this.container.find(`input[name="${t}"]`).get(0).value}setInputValue(t,e){this.container.find(`input[name="${t}"]`).get(0).value=e}save(){if(!this.linkNode)return;const t=this.getInputValue("url");let e=this.getInputValue("title");""!==t||""!==e?(""===e&&(e=t),this.linkNode.attr("href",t),this.linkNode.text(e)):this.linkNode.remove()}updatePosition(){if(!this.linkNode)return;const t=this.linkNode.get(0).getBoundingClientRect(),e=t.x+window.scrollX,i=t.y+window.scrollY;e<0||i<0?this.hide():(t.x+this.container.width()>window.innerWidth?this.container.css("left",`${e-this.container.width()+t.width}px`):this.container.css("left",`${e}px`),t.y+t.height+this.container.height()>window.innerHeight?this.container.css("top",i-this.container.height()+"px"):this.container.css("top",`${i+t.height}px`))}render(){this.appendCopyButton(),this.appendOpenButton(),this.appendSaveButton(),this.appendUnlinkButton(),this.root.append(this.container)}show(t){if(0===this.root.find(".lake-link-popup").length&&this.render(),this.linkNode&&this.linkNode.get(0)===t.get(0))return;this.linkNode=t;const e=t.attr("href"),i=t.text();this.setInputValue("url",e),i!==e&&this.setInputValue("title",i),this.container.css("visibility","hidden"),this.container.show(),this.updatePosition(),this.container.css("visibility",""),this.container.find('input[name="url"]').focus()}hide(){this.linkNode=null,this.container.hide()}}const yc=["text","c","csharp","cpp","css","go","html","java","javascript","json","markdown","php","python","rust","sql","typescript","xml","yaml"];const wc=new Map([["#","h1"],["##","h2"],["###","h3"],["####","h4"],["#####","h5"],["######","h6"]]),xc=new Map([["js","javascript"],["ts","typescript"],["md","markdown"],["htm","html"]]),bc=[{re:/\*\*(.+?)\*\*$/,getParameters:()=>["bold"]},{re:/__(.+?)__$/,getParameters:()=>["bold"]},{re:/_(.+?)_$/,getParameters:()=>["italic"]},{re:/\*(.+?)\*$/,getParameters:()=>["italic"]},{re:/==(.+?)==$/,getParameters:()=>["highlight","#fff566"]},{re:/~~(.+?)~~$/,getParameters:()=>["strikethrough"]},{re:/`(.+?)`$/,getParameters:()=>["code"]}],kc=[{re:/^#+$/,getParameters:t=>{var e;return["heading",null!==(e=wc.get(t[0]))&&void 0!==e?e:"h6"]}},{re:/^\d+\.$/,getParameters:()=>["list","numbered"]},{re:/^[*\-+]$/,getParameters:()=>["list","bulleted"]},{re:/^\[\s?\]$/,getParameters:()=>["list","checklist",!1]},{re:/^\[x\]$/i,getParameters:()=>["list","checklist",!0]},{re:/^>$/,getParameters:()=>["blockQuote"]}],_c=[{re:/^:{3,}([a-z]*)$/i,getParameters:t=>t[1]?["blockQuote",t[1]]:["blockQuote","info"]},{re:/^-{3,}$/,getParameters:()=>["hr"]},{re:/^`+([a-z]*)$/i,getParameters:t=>{var e;return t[1]?["codeBlock",{lang:null!==(e=xc.get(t[1]))&&void 0!==e?e:t[1]}]:["codeBlock"]}}];function Sc(t){const e=t.clone(!0);e.find("lake-bookmark").remove(),""===e.html()&&t.prepend("<br />")}function Cc(t,e){const i=t.selection.range,n=i.getEndText();if(t.selection.splitBlock(),e=i.getBlocks()[0])return""!==n||!e.isHeading&&"blockquote"!==e.name?void(e.isList&&"checklist"===e.attr("type")&&e.find("li").attr("value","false")):(t.selection.setBlocks("<p />"),void t.history.save());t.history.save()}function Ac(t){const e=t.selection.range,i=e.startNode.closest("lake-box"),n=i.closestBlock();if(n.length>0&&!n.isContainer)return void(e.isBoxStart?(e.setStartBefore(i),e.collapseToStart(),Cc(t,n)):e.isBoxEnd?(e.setStartAfter(i),e.collapseToStart(),Cc(t,n)):t.removeBox());const s=I("<p><br /></p>");e.isBoxStart?i.before(s):e.isBoxEnd?(i.after(s),e.shrinkAfter(s)):t.removeBox()}function Bc(t){const e=t.selection.range,i=e.startNode.closestBlock();if(i.length>0&&!i.isContainer){const i=e.getPrevNode(),n=e.getEndText();if("br"!==i.name&&""===n)return t.selection.insertContents("<br /><br />"),void t.history.save()}t.selection.insertNode(I("<br />"))}function Tc(t){const e=t.selection.range,i=e.startNode.closest("lake-box"),n=i.closestBlock();if(n.length>0&&!n.isContainer)return void(e.isBoxStart?(e.setStartBefore(i),e.collapseToStart(),Bc(t)):e.isBoxEnd?(e.setStartAfter(i),e.collapseToStart(),Bc(t)):t.removeBox());const s=I("<p><br /></p>");e.isBoxStart?i.before(s):e.isBoxEnd?(i.after(s),e.shrinkAfter(s)):t.removeBox()}function Ec(t,e){const i=t.selection.range;let n=e.prev();if(0===n.length)return void("p"!==e.name&&t.selection.setBlocks("<p />"));if(n.isBox)return e.isEmpty&&e.remove(),void i.selectBoxEnd(n);if("br"===n.name)return void n.remove();if(!n.isBlock){const t=new L;t.selectNodeContents(n),pe(t,"<p />"),n=t.startNode.closestBlock()}if(n.isEmpty)return void n.remove();const s=t.selection.insertBookmark();Z(n,e),t.selection.toBookmark(s),t.selection.fixList()}function Ic(t,e){const i=t.selection.range;let n=e.next();if(0===n.length)return void t.history.save();if(n.isBox)return e.isEmpty&&e.remove(),i.selectBoxStart(n),void t.history.save();if(!n.isBlock){const t=new L;t.selectNodeContents(n),pe(t,"<p />"),n=n.closestBlock()}const s=t.selection.insertBookmark();Z(e,n),t.selection.toBookmark(s),t.selection.fixList()}return $r.box.add({type:"block",name:"hr",render:t=>{const e=t.getEditor();if(e)return t.useEffect((()=>{t.getContainer().find(".lake-hr").on("click",(()=>{e.selection.range.selectBox(t.node)}))})),'<div class="lake-hr"><hr /></div>'},html:()=>"<hr />"}),$r.box.add(Al),$r.box.add(ic),$r.plugin.add((t=>{t.readonly||t.container.on("copy",(e=>{const i=t.selection.range;if(i.isInsideBox)return;const n=i.startNode.closest("lake-box");if(0===n.length)return;if(i.isBoxStart||i.isBoxEnd)return;e.preventDefault();const s=e.clipboardData;if(!s)return;const o=new Yt(n).getHTML();s.setData("text/html",o)}))})),$r.plugin.add((t=>{t.readonly||t.container.on("cut",(e=>{const i=t.selection.range;if(i.isInsideBox)return;const n=i.startNode.closest("lake-box");if(0===n.length)return;if(i.isBoxStart||i.isBoxEnd)return;e.preventDefault();const s=e.clipboardData;if(!s)return;const o=new Yt(n).getHTML();s.setData("text/html",o),t.removeBox(),t.history.save()}))})),$r.plugin.add((t=>{t.readonly||t.container.on("paste",(e=>{const{requestTypes:i}=t.config.image;if(t.selection.range.isInsideBox)return;e.preventDefault();const n=e.clipboardData;if(!n)return;if(t.selection.deleteContents(),n.files.length>0){for(const e of n.files)i.indexOf(e.type)>=0&&Gr({editor:t,file:e});return}const s=n.types;if(1===s.length&&"text/plain"===s[0]){const e=n.getData("text/plain"),i=new ne(e).getFragment();return t.event.emit("beforepaste",i),void oc(t,i)}const o=u(n.getData("text/html")),r=function(){const t=ee();return t.div=t.p,g(t,((t,e)=>{delete e.id,delete e.class})),t}(),a=new ie(o,r).getFragment();t.event.emit("beforepaste",a),function(t){let e=new E(t.firstChild);for(;e.length>0;){const t=e.next();e.isBlock&&sc(e),e=t}let i=[];for(e=new E(t.firstChild);e.length>0;){const t=e.next();e.isMark||e.isText||e.isBookmark||e.isInlineBox?i.push(e):(H(i),i=[]),e=t}H(i)}(a),oc(t,a),t.box.renderAll(t)}))})),$r.plugin.add((t=>{t.readonly||(t.command.add("undo",{execute:()=>{t.history.undo()}}),t.keystroke.setKeydown("mod+z",(e=>{t.selection.range.isInsideBox||(e.preventDefault(),t.command.execute("undo"))})))})),$r.plugin.add((t=>{if(t.readonly)return;t.command.add("redo",{execute:()=>{t.history.redo()}});const e=e=>{t.selection.range.isInsideBox||(e.preventDefault(),t.command.execute("redo"))};t.keystroke.setKeydown("mod+y",e),t.keystroke.setKeydown("mod+shift+z",e)})),$r.plugin.add((t=>{t.readonly||t.command.add("selectAll",{execute:()=>{const e=t.selection.range;e.selectNodeContents(t.container),e.shrink()}})})),$r.plugin.add((t=>{t.readonly||t.command.add("heading",{selectedValues:t=>{const e=t.find((t=>t.node.isHeading||"p"===t.name));return e?[e.name]:[]},execute:e=>{t.selection.setBlocks(`<${e} />`),t.history.save()}})})),$r.plugin.add((t=>{t.readonly||t.command.add("blockQuote",{isSelected:t=>!!t.find((t=>"blockquote"===t.name)),execute:e=>{e&&rc.indexOf(e)>=0?t.selection.setBlocks(a`<blockquote type="${e}" />`):t.selection.setBlocks("<blockquote />"),t.history.save()}})})),$r.plugin.add((t=>{t.readonly||(t.command.add("list",{selectedValues:t=>{let e;for(const i of t){if("ol"===i.name){e="numbered";break}if("ul"===i.name&&!i.node.hasAttr("type")){e="bulleted";break}if("ul"===i.name&&"checklist"===i.node.attr("type")){e="checklist";break}}return e?[e]:[]},execute:(e,i=!1)=>{const n=t.selection.range.getBlocks();let s=!1,o=!1,r=!1;for(const t of n)s||"ol"!==t.name||(s=!0),o||"ul"!==t.name||t.hasAttr("type")||(o=!0),r||"ul"!==t.name||"checklist"!==t.attr("type")||(r=!0);s?("numbered"===e&&ac(t),"bulleted"===e&&cc(t),"checklist"===e&&hc(t,i)):o?("numbered"===e&&lc(t),"bulleted"===e&&ac(t),"checklist"===e&&hc(t,i)):r?("numbered"===e&&lc(t),"bulleted"===e&&cc(t),"checklist"===e&&ac(t)):("numbered"===e&&lc(t),"bulleted"===e&&cc(t),"checklist"===e&&hc(t,i)),t.history.save()}}),t.container.on("click",(e=>{const i=e;if(!i.target)return;const n=I(i.target);"li"===n.name&&""!==n.attr("value")&&i.offsetX<=18&&(n.attr("value",("true"!==n.attr("value")).toString()),t.history.save())})))})),$r.plugin.add((t=>{t.readonly||t.command.add("align",{selectedValues:t=>{let e;for(const i of t)if(i.node.isBlock){e=i.node.computedCSS("text-align");break}return e?[dc[e]||e]:[]},execute:e=>{t.selection.setBlocks({"text-align":e}),t.history.save()}})})),$r.plugin.add((t=>{t.readonly||t.command.add("indent",{execute:e=>{const i=t.selection.range.getBlocks();for(const t of i)F(t,e);t.history.save()}})})),$r.plugin.add((t=>{t.readonly||(t.command.add("bold",{isDisabled:t=>!!t.find((t=>t.node.isHeading)),isSelected:t=>!!t.find((t=>t.name===pc)),execute:()=>{t.command.isSelected("bold")?t.selection.removeMark(`<${pc} />`):t.selection.addMark(`<${pc} />`),t.history.save()}}),t.keystroke.setKeydown("mod+b",(e=>{e.preventDefault(),t.command.execute("bold")})))})),$r.plugin.add((t=>{t.readonly||(t.command.add("italic",{isSelected:t=>!!t.find((t=>"i"===t.name)),execute:()=>{t.command.isSelected("italic")?t.selection.removeMark("<i />"):t.selection.addMark("<i />"),t.history.save()}}),t.keystroke.setKeydown("mod+i",(e=>{e.preventDefault(),t.command.execute("italic")})))})),$r.plugin.add((t=>{t.readonly||(t.command.add("underline",{isSelected:t=>!!t.find((t=>"u"===t.name)),execute:()=>{t.command.isSelected("underline")?t.selection.removeMark("<u />"):t.selection.addMark("<u />"),t.history.save()}}),t.keystroke.setKeydown("mod+u",(e=>{e.preventDefault(),t.command.execute("underline")})))})),$r.plugin.add((t=>{t.readonly||(t.command.add("strikethrough",{isSelected:t=>!!t.find((t=>"s"===t.name)),execute:()=>{t.command.isSelected("strikethrough")?t.selection.removeMark("<s />"):t.selection.addMark("<s />"),t.history.save()}}),t.keystroke.setKeydown("mod+shift+x",(e=>{e.preventDefault(),t.command.execute("strikethrough")})))})),$r.plugin.add((t=>{t.readonly||t.command.add("subscript",{isSelected:t=>!!t.find((t=>t.name===uc)),execute:()=>{t.command.isSelected("subscript")?t.selection.removeMark(`<${uc} />`):t.selection.addMark(`<${uc} />`),t.history.save()}})})),$r.plugin.add((t=>{t.readonly||t.command.add("superscript",{isSelected:t=>!!t.find((t=>t.name===mc)),execute:()=>{t.command.isSelected("superscript")?t.selection.removeMark(`<${mc} />`):t.selection.addMark(`<${mc} />`),t.history.save()}})})),$r.plugin.add((t=>{t.readonly||t.command.add("code",{isSelected:t=>!!t.find((t=>t.name===fc)),execute:()=>{t.command.isSelected("code")?t.selection.removeMark(`<${fc} />`):t.selection.addMark(`<${fc} />`),t.history.save()}})})),$r.plugin.add((t=>{t.readonly||t.command.add("fontFamily",{selectedValues:t=>{for(const e of t)if("span"===e.name){return[e.node.css("font-family").replace(/['"]/g,"")]}return[]},execute:e=>{t.selection.addMark(`<span style="font-family: ${e};" />`),t.history.save()}})})),$r.plugin.add((t=>{t.readonly||t.command.add("fontSize",{isDisabled:t=>!!t.find((t=>t.node.isHeading)),selectedValues:t=>{for(const e of t)if("span"===e.name){return[e.node.css("font-size").replace(/\.\d+/,"")]}return[]},execute:e=>{t.selection.addMark(`<span style="font-size: ${e};" />`),t.history.save()}})})),$r.plugin.add((t=>{t.readonly||t.command.add("fontColor",{selectedValues:t=>{for(const e of t)if("span"===e.name){return[d(e.node.computedCSS("color"))]}return[]},execute:e=>{t.selection.addMark(`<span style="color: ${e};" />`),t.history.save()}})})),$r.plugin.add((t=>{t.readonly||t.command.add("highlight",{selectedValues:t=>{for(const e of t)if("span"===e.name){return[d(e.node.computedCSS("background-color"))]}return[]},execute:e=>{t.selection.addMark(`<span style="background-color: ${e};" />`),t.history.save()}})})),$r.plugin.add((t=>{t.readonly||t.command.add("removeFormat",{execute:()=>{t.selection.removeMark(),t.history.save()}})})),$r.plugin.add((t=>{if(t.readonly)return;let e=[];t.command.add("formatPainter",{execute:()=>{t.container.addClass(gc);const i=t.selection.getAppliedItems();for(const t of i){const i=t.node.clone();i.isMark&&"a"!==i.name&&e.push(i)}}}),t.container.on("click",(()=>{if(t.container.removeClass(gc),0!==e.length){for(const i of e)t.selection.addMark(i);e=[],t.history.save()}})),t.event.on("click",(i=>{if(i.isInside&&i.closestContainer().get(0)===t.container.get(0))return;i.closest('button[name="formatPainter"]').length>0||(t.container.removeClass(gc),e=[])}))})),$r.plugin.add((t=>{if(t.readonly)return;const e=new vc({root:t.popupContainer,locale:t.locale});e.event.on("save",(e=>{const i=t.selection.range;i.setStartAfter(e),i.collapseToStart(),t.selection.addRangeToNativeSelection(),t.history.save()})),e.event.on("remove",(e=>{const i=t.selection.range;i.setStartAfter(e),i.collapseToStart(),t.selection.addRangeToNativeSelection(),t.history.save()})),t.root.on("scroll",(()=>{e.updatePosition()})),t.event.on("resize",(()=>{e.updatePosition()})),t.event.on("click",(i=>{if(i.closest('button[name="link"]').length>0)return;const n=i.closest("a");0!==n.length?n.isOutside||n.closestContainer().get(0)!==t.container.get(0)||n.closest("lake-box").length>0?e.hide():e.show(n):e.hide()})),t.command.add("link",{execute:()=>{const i=t.selection.insertLink(`<a href="">${t.locale.link.newLink()}</a>`);i&&(t.history.save(),e.show(i))}})})),$r.plugin.add((t=>{t.readonly||(t.event.on("beforepaste",(t=>{new mt(t).find("hr").each((t=>{const e=I(t),i=new Yt("hr");e.replaceWith(i.node)}))})),t.command.add("hr",{execute:()=>{t.insertBox("hr"),t.history.save()}}))})),$r.plugin.add((t=>{t.setPluginConfig("image",{requestMethod:"POST",requestTypes:["image/gif","image/jpeg","image/png","image/svg+xml"]}),t.readonly||(t.event.on("beforepaste",(t=>{new mt(t).find("img").each((t=>{const e=I(t),i=new Yt("image"),n=e.attr("data-lake-value");""===n?i.value={url:e.attr("src"),status:"done"}:i.node.attr("value",n),e.replaceWith(i.node)}))})),t.command.add("image",{execute:e=>{t.insertBox("image",e),t.history.save()}}))})),$r.plugin.add((t=>{window.LakeCodeMirror&&(t.setPluginConfig("codeBlock",{langList:yc,defaultLang:"text"}),t.readonly||t.command.add("codeBlock",{execute:e=>{const i=t.insertBox("codeBlock",e);t.history.save();i.getData("codeEditor").focus()}}))})),$r.plugin.add((t=>{t.readonly||(t.keystroke.setKeydown("space",(e=>{const i=t.selection.range;if(i.isBox)return;const n=function(t){const e=t.selection.range;let i=e.startNode,n=e.startOffset;if(0!==n){if(i.isElement){const t=i.children()[n-1];if(!t||!t.isText)return;i=t,n=i.text().length}if(!(n<1))return{node:i,offset:n}}}(t);if(!n)return;if(function(t,e){const i=t.selection,n=i.range,s=e.offset,o=e.node.text().slice(0,s);for(const e of bc){const r=e.re.exec(o);if(null!==r){const o=e.getParameters(),a=o.shift();if(!t.command.has(a))return!1;t.prepareOperation();const l=i.insertBookmark(),c=l.focus.prev(),h=c.text(),d=`${h.replace(e.re,"$1")}​`;return c.get(0).nodeValue=d,n.setStart(c,s-r[0].length),n.setEnd(c,s-(h.length-d.length)-1),t.command.execute(a,...o),i.toBookmark(l),t.commitOperation(),!0}}return!1}(t,n))return void e.preventDefault();const s=i.getBlocks()[0];s&&(s.isHeading||"p"===s.name)&&function(t,e){const i=t.selection,n=e.offset;let s=e.node.text().slice(0,n);s=s.replace(/[\u200B\u2060]/g,"");for(const e of kc){const n=e.re.exec(s);if(null!==n){const s=e.getParameters(n),o=s.shift();if(!t.command.has(o))return!1;t.prepareOperation();const r=i.insertBookmark();r.focus.prev().remove();const a=r.focus.closestBlock();return Sc(a),i.range.shrinkAfter(a),t.command.execute(o,...s),i.toBookmark(r),t.commitOperation(),!0}}return!1}(t,n)&&e.preventDefault()})),t.keystroke.setKeydown("enter",(e=>{const i=t.selection.range;if(i.isBox)return;const n=i.getBlocks()[0];return!n||!n.isHeading&&"p"!==n.name||n.find("lake-box").length>0||""!==i.getEndText()?void 0:function(t,e){const i=t.selection;let n=e.text();n=n.replace(/[\u200B\u2060]/g,"");for(const s of _c){const o=s.re.exec(n);if(null!==o){const n=s.getParameters(o),r=n.shift();return!!t.command.has(r)&&(t.prepareOperation(),e.empty(),Sc(e),i.range.shrinkAfter(e),t.command.execute(r,...n),t.commitOperation(),!0)}}return!1}(t,n)?(e.preventDefault(),e.stopImmediatePropagation(),!1):void 0})))})),$r.plugin.add((t=>{t.readonly||t.keystroke.setKeydown("enter",(e=>{const i=t.selection.range;if(i.isInsideBox)return;if(e.preventDefault(),t.rectifyContent(),i.isBox)return Ac(t),void t.history.save();if(i.adapt(),i.isInoperative)return;if(i.isBox)return Ac(t),void t.history.save();let n=i.getBlocks()[0];if(n||(t.selection.setBlocks("<p />"),n=i.getBlocks()[0]),n.isEmpty&&"p"!==n.name)return t.selection.setBlocks("<p />"),void t.history.save();Cc(t,n),t.history.save()}))})),$r.plugin.add((t=>{t.readonly||t.keystroke.setKeydown("shift+enter",(e=>{const i=t.selection.range;if(!i.isInsideBox){if(t.rectifyContent(),e.preventDefault(),i.isBox)return Tc(t),void t.history.save();if(i.adapt(),!i.isInoperative){if(i.isBox)return Tc(t),void t.history.save();Bc(t),t.history.save()}}}))})),$r.plugin.add((t=>{t.readonly||t.keystroke.setKeydown("backspace",(e=>{const i=t.selection.range;if(i.isInsideBox)return;if(t.rectifyContent(),i.isBoxStart){const n=i.startNode.closest("lake-box"),s=n.prev();if(0===s.length){const i=n.closestBlock();return void(i.length>0&&!i.isContainer&&(e.preventDefault(),Ec(t,i),t.history.save()))}if(s.isBlock)return s.isEmpty?(e.preventDefault(),s.remove(),t.selection.fixList(),void t.history.save()):(e.preventDefault(),void i.shrinkAfter(s));i.adaptBox()}if(i.isBox)return e.preventDefault(),t.removeBox(),void t.history.save();if(!i.isCollapsed)return e.preventDefault(),t.selection.deleteContents(),""===t.container.html().trim()&&t.setValue("<p><br /><focus /></p>"),void t.history.save();i.adapt();const n=i.getPrevNode();if(n.isBox)return e.preventDefault(),i.selectBox(n),t.removeBox(),void t.history.save();if("br"===n.name&&n.prev().length>0)return e.preventDefault(),i.setStartBefore(n),i.collapseToStart(),n.remove(),void t.history.save();if(""===i.getStartText()){e.preventDefault();let n=i.getBlocks()[0];if(n||(t.selection.setBlocks("<p />"),n=i.getBlocks()[0]),""!==n.css("margin-left")||""!==n.css("text-indent")||""!==n.attr("indent"))return F(n,"decrease"),void t.history.save();if(n.isList||"blockquote"===n.name)return t.selection.setBlocks("<p />"),void t.history.save();Ec(t,n),t.history.save()}}))})),$r.plugin.add((t=>{t.readonly||t.keystroke.setKeydown("delete",(e=>{const i=t.selection.range;if(i.isInsideBox)return;if(t.rectifyContent(),i.isBoxEnd){const n=i.startNode.closest("lake-box"),s=n.next();if(0===s.length){const i=n.closestBlock();return void(i.length>0&&!i.isContainer&&(e.preventDefault(),Ic(t,i),t.history.save()))}if(s.isBlock)return s.isEmpty?(e.preventDefault(),s.remove(),t.selection.fixList(),void t.history.save()):(e.preventDefault(),void i.shrinkBefore(s));i.adaptBox()}if(i.isBox)return e.preventDefault(),t.removeBox(),void t.history.save();if(!i.isCollapsed)return e.preventDefault(),t.selection.deleteContents(),""===t.container.html().trim()&&t.setValue("<p><br /><focus /></p>"),void t.history.save();i.adapt();const n=i.getNextNode();if(n.isBox)return e.preventDefault(),i.selectBox(n),t.removeBox(),void t.history.save();"br"===n.name&&n.next().length>0&&(e.preventDefault(),i.setStartBefore(n),i.collapseToStart(),n.remove(),t.history.save());if(""===i.getEndText()){e.preventDefault();let n=i.getBlocks()[0];n||(t.selection.setBlocks("<p />"),n=i.getBlocks()[0]),Ic(t,n),t.history.save()}}))})),$r.plugin.add((t=>{t.readonly||t.keystroke.setKeydown("tab",(e=>{if(!1===t.config.indentWithTab)return;e.preventDefault();t.selection.range.getBlocks().forEach((t=>{"p"===t.name&&"2em"!==t.css("text-indent")?t.css("text-indent","2em"):F(t,"increase")})),t.history.save()}))})),$r.plugin.add((t=>{t.readonly||(t.keystroke.setKeydown("arrow-left",(e=>{const i=t.selection.range;if(i.isInsideBox)return;const n=i.commonAncestor.closest("lake-box");if(n.length>0){if(i.isBoxStart){const t=n.prev();return t.isBlock||t.isBox?(e.preventDefault(),t.isInlineBox?void i.selectBox(t):void i.shrinkAfter(t)):(i.setStartBefore(n),void i.collapseToStart())}return i.isBoxEnd?(e.preventDefault(),void i.selectBox(n)):(e.preventDefault(),void i.selectBoxStart(n))}if(!i.isCollapsed)return;const s=i.getPrevNode();s.isBox&&(e.preventDefault(),i.selectBox(s))})),t.keystroke.setKeydown("arrow-right",(e=>{const i=t.selection.range;if(i.isInsideBox)return;const n=i.commonAncestor.closest("lake-box");if(n.length>0){if(i.isBoxStart)return e.preventDefault(),void i.selectBox(n);if(i.isBoxEnd){const t=n.next();return t.isBlock||t.isBox?(e.preventDefault(),t.isInlineBox?void i.selectBox(t):void i.shrinkBefore(t)):(i.setStartAfter(n),void i.collapseToStart())}return e.preventDefault(),void i.selectBoxEnd(n)}if(!i.isCollapsed)return;const s=i.getNextNode();s.isBox&&(e.preventDefault(),i.selectBox(s))})),t.keystroke.setKeydown("arrow-up",(e=>{const i=t.selection.range;if(i.isInsideBox)return;const n=i.commonAncestor.closest("lake-box");if(n.length>0){if(n.isBlockBox){const t=n.prev();if(t.isBlock||t.isBox)return e.preventDefault(),void i.shrinkAfter(t)}i.setStartBefore(n),i.collapseToStart()}})),t.keystroke.setKeydown("arrow-down",(e=>{const i=t.selection.range;if(i.isInsideBox)return;const n=i.commonAncestor.closest("lake-box");if(n.length>0){if(n.isBlockBox){const t=n.next();if(t.isBlock||t.isBox)return e.preventDefault(),void i.shrinkBefore(t)}i.setStartAfter(n),i.collapseToStart()}})))})),$r.plugin.add((t=>{t.readonly||t.keystroke.setKeydown("escape",(e=>{const i=t.selection,n=i.range;if(n.isBoxCenter||n.isInsideBox){e.preventDefault();const t=n.commonAncestor.closest("lake-box");return n.selectBoxEnd(t),void i.addRangeToNativeSelection()}t.root.hasClass("lake-root-focused")&&(e.preventDefault(),t.blur())}))})),t.Box=Yt,t.Button=ke,t.Dropdown=De,t.Editor=$r,t.Fragment=mt,t.HTMLParser=ie,t.Nodes=E,t.Range=L,t.TextParser=ne,t.Toolbar=class{constructor(t){this.allMenuMap=new Map,this.buttonItemList=[],this.dropdownItemList=[],this.items=t.items||Xr,this.root=I(t.root),this.container=I('<div class="lake-toolbar" />'),this.root.addClass("lake-custom-properties")}appendDivider(){this.container.append('<div class="lake-toolbar-divider" />')}appendButton(t,e){new ke({root:this.container,name:e.name,icon:e.icon,tooltip:"string"==typeof e.tooltip?e.tooltip:e.tooltip(t.locale),tabIndex:-1,onClick:()=>{t.focus(),e.onClick(t,e.name)}}).render()}appendDropdown(t,e){new De({root:this.container,locale:t.locale,name:e.name,icon:e.icon,accentIcon:e.accentIcon,downIcon:e.downIcon,defaultValue:e.defaultValue,tooltip:e.tooltip,width:e.width,menuType:e.menuType,menuItems:e.menuItems,tabIndex:-1,onSelect:i=>{t.focus(),e.onSelect(t,i)}}).render()}appendUpload(t,e){const i=I(a`
69
+ `)}writeClipboardText(t){return Qr(this,void 0,void 0,(function*(){let e=!1;try{window.LAKE_TEST?e=window.LAKE_ERROR:yield navigator.clipboard.writeText(t)}catch(t){e=!0}return new Promise((t=>{t(e)}))}))}appendCopyButton(){let t=null;const e=new ke({root:this.container.find(".lake-url-row"),name:"copy",icon:n.get("copy"),tooltip:this.locale.link.copy(),onClick:()=>{if(!this.linkNode)return;const e=this.getInputValue("url");this.writeClipboardText(e).then((e=>{const i=this.container.find('button[name="copy"] svg');if(i.hide(),e)return i.eq(2).show("inline"),void this.event.emit("copy",e);i.eq(1).show("inline"),this.event.emit("copy",e),t&&window.clearTimeout(t),t=window.setTimeout((()=>{i.hide(),i.eq(0).show("inline")}),2e3)}))}});e.render();const i=n.get("checkCircle");i&&e.node.append(i);const s=n.get("warningCircle");s&&e.node.append(s)}appendOpenButton(){new ke({root:this.container.find(".lake-url-row"),name:"open",icon:n.get("open"),tooltip:this.locale.link.open(),onClick:()=>{if(!this.linkNode)return;const t=this.getInputValue("url");window.open(t)}}).render()}appendSaveButton(){new ke({root:this.container.find(".lake-button-row"),name:"save",icon:n.get("check"),text:this.locale.link.save(),onClick:()=>{if(!this.linkNode)return;const t=this.linkNode;this.save(),this.hide(),this.event.emit("save",t)}}).render()}appendUnlinkButton(){new ke({root:this.container.find(".lake-button-row"),name:"unlink",icon:n.get("unlink"),text:this.locale.link.unlink(),onClick:()=>{if(!this.linkNode)return;const t=this.linkNode.last();this.linkNode.remove(!0),this.hide(),this.event.emit("remove",t)}}).render()}getInputValue(t){return this.container.find(`input[name="${t}"]`).get(0).value}setInputValue(t,e){this.container.find(`input[name="${t}"]`).get(0).value=e}save(){if(!this.linkNode)return;const t=this.getInputValue("url");let e=this.getInputValue("title");""!==t||""!==e?(""===e&&(e=t),this.linkNode.attr("href",t),this.linkNode.text(e)):this.linkNode.remove()}updatePosition(){if(!this.linkNode)return;const t=this.linkNode.get(0).getBoundingClientRect(),e=t.x+window.scrollX,i=t.y+window.scrollY;e<0||i<0?this.hide():(t.x+this.container.width()>window.innerWidth?this.container.css("left",`${e-this.container.width()+t.width}px`):this.container.css("left",`${e}px`),t.y+t.height+this.container.height()>window.innerHeight?this.container.css("top",i-this.container.height()+"px"):this.container.css("top",`${i+t.height}px`))}render(){this.appendCopyButton(),this.appendOpenButton(),this.appendSaveButton(),this.appendUnlinkButton(),this.root.append(this.container)}show(t){if(0===this.root.find(".lake-link-popup").length&&this.render(),this.linkNode&&this.linkNode.get(0)===t.get(0))return;this.linkNode=t;const e=t.attr("href"),i=t.text();this.setInputValue("url",e),i!==e&&this.setInputValue("title",i),this.container.css("visibility","hidden"),this.container.show(),this.updatePosition(),this.container.css("visibility",""),this.container.find('input[name="url"]').focus()}hide(){this.linkNode=null,this.container.hide()}}const yc=["text","c","csharp","cpp","css","go","html","java","javascript","json","markdown","php","python","rust","sql","typescript","xml","yaml"];const wc=new Map([["#","h1"],["##","h2"],["###","h3"],["####","h4"],["#####","h5"],["######","h6"]]),xc=new Map([["js","javascript"],["ts","typescript"],["md","markdown"],["htm","html"]]),bc=[{re:/\*\*(.+?)\*\*$/,getParameters:()=>["bold"]},{re:/__(.+?)__$/,getParameters:()=>["bold"]},{re:/_(.+?)_$/,getParameters:()=>["italic"]},{re:/\*(.+?)\*$/,getParameters:()=>["italic"]},{re:/==(.+?)==$/,getParameters:()=>["highlight","#fff566"]},{re:/~~(.+?)~~$/,getParameters:()=>["strikethrough"]},{re:/`(.+?)`$/,getParameters:()=>["code"]}],kc=[{re:/^#+$/,getParameters:t=>{var e;return["heading",null!==(e=wc.get(t[0]))&&void 0!==e?e:"h6"]}},{re:/^\d+\.$/,getParameters:()=>["list","numbered"]},{re:/^[*\-+]$/,getParameters:()=>["list","bulleted"]},{re:/^\[\s?\]$/,getParameters:()=>["list","checklist",!1]},{re:/^\[x\]$/i,getParameters:()=>["list","checklist",!0]},{re:/^>$/,getParameters:()=>["blockQuote"]}],_c=[{re:/^:{3,}([a-z]*)$/i,getParameters:t=>t[1]?["blockQuote",t[1]]:["blockQuote","info"]},{re:/^-{3,}$/,getParameters:()=>["hr"]},{re:/^`+([a-z]*)$/i,getParameters:t=>{var e;return t[1]?["codeBlock",{lang:null!==(e=xc.get(t[1]))&&void 0!==e?e:t[1]}]:["codeBlock"]}}];function Sc(t){const e=t.clone(!0);e.find("lake-bookmark").remove(),""===e.html()&&t.prepend("<br />")}function Cc(t,e){const i=t.selection.range,n=i.getEndText();if(t.selection.splitBlock(),e=i.getBlocks()[0])return""!==n||!e.isHeading&&"blockquote"!==e.name?void(e.isList&&"checklist"===e.attr("type")&&e.find("li").attr("value","false")):(t.selection.setBlocks("<p />"),void t.history.save());t.history.save()}function Ac(t){const e=t.selection.range,i=e.startNode.closest("lake-box"),n=i.closestBlock();if(n.length>0&&!n.isContainer)return void(e.isBoxStart?(e.setStartBefore(i),e.collapseToStart(),Cc(t,n)):e.isBoxEnd?(e.setStartAfter(i),e.collapseToStart(),Cc(t,n)):t.removeBox());const s=I("<p><br /></p>");e.isBoxStart?i.before(s):e.isBoxEnd?(i.after(s),e.shrinkAfter(s)):t.removeBox()}function Bc(t){const e=t.selection.range,i=e.startNode.closestBlock();if(i.length>0&&!i.isContainer){const i=e.getPrevNode(),n=e.getEndText();if("br"!==i.name&&""===n)return t.selection.insertContents("<br /><br />"),void t.history.save()}t.selection.insertNode(I("<br />"))}function Tc(t){const e=t.selection.range,i=e.startNode.closest("lake-box"),n=i.closestBlock();if(n.length>0&&!n.isContainer)return void(e.isBoxStart?(e.setStartBefore(i),e.collapseToStart(),Bc(t)):e.isBoxEnd?(e.setStartAfter(i),e.collapseToStart(),Bc(t)):t.removeBox());const s=I("<p><br /></p>");e.isBoxStart?i.before(s):e.isBoxEnd?(i.after(s),e.shrinkAfter(s)):t.removeBox()}function Ec(t,e){const i=t.selection.range;let n=e.prev();if(0===n.length)return void("p"!==e.name&&t.selection.setBlocks("<p />"));if(n.isBox)return e.isEmpty&&e.remove(),void i.selectBoxEnd(n);if("br"===n.name)return void n.remove();if(!n.isBlock){const t=new L;t.selectNodeContents(n),pe(t,"<p />"),n=t.startNode.closestBlock()}if(n.isEmpty)return void n.remove();const s=t.selection.insertBookmark();Z(n,e),t.selection.toBookmark(s),t.selection.fixList()}function Ic(t,e){const i=t.selection.range;let n=e.next();if(0===n.length)return void t.history.save();if(n.isBox)return e.isEmpty&&e.remove(),i.selectBoxStart(n),void t.history.save();if(!n.isBlock){const t=new L;t.selectNodeContents(n),pe(t,"<p />"),n=n.closestBlock()}const s=t.selection.insertBookmark();Z(e,n),t.selection.toBookmark(s),t.selection.fixList()}return $r.box.add({type:"block",name:"hr",render:t=>{const e=t.getEditor();if(e)return t.useEffect((()=>{t.getContainer().find(".lake-hr").on("click",(()=>{e.selection.range.selectBox(t.node)}))})),'<div class="lake-hr"><hr /></div>'},html:()=>"<hr />"}),$r.box.add(Al),$r.box.add(ic),$r.plugin.add((t=>{t.readonly||t.container.on("copy",(e=>{const i=t.selection.range;if(i.isInsideBox)return;const n=i.startNode.closest("lake-box");if(0===n.length)return;if(i.isBoxStart||i.isBoxEnd)return;e.preventDefault();const s=e.clipboardData;if(!s)return;const o=new Yt(n).getHTML();s.setData("text/html",o)}))})),$r.plugin.add((t=>{t.readonly||t.container.on("cut",(e=>{const i=t.selection.range;if(i.isInsideBox)return;const n=i.startNode.closest("lake-box");if(0===n.length)return;if(i.isBoxStart||i.isBoxEnd)return;e.preventDefault();const s=e.clipboardData;if(!s)return;const o=new Yt(n).getHTML();s.setData("text/html",o),t.removeBox(),t.history.save()}))})),$r.plugin.add((t=>{t.readonly||t.container.on("paste",(e=>{const{requestTypes:i}=t.config.image;if(t.selection.range.isInsideBox)return;e.preventDefault();const n=e.clipboardData;if(!n)return;if(t.selection.deleteContents(),n.files.length>0){for(const e of n.files)i.indexOf(e.type)>=0&&Gr({editor:t,file:e});return}const s=n.types;if(1===s.length&&"text/plain"===s[0]){const e=n.getData("text/plain"),i=new ne(e).getFragment();return t.event.emit("beforepaste",i),void oc(t,i)}const o=u(n.getData("text/html")),r=function(){const t=ee();return t.div=t.p,g(t,((t,e)=>{delete e.id,delete e.class})),t}(),a=new ie(o,r).getFragment();t.event.emit("beforepaste",a),function(t){let e=new E(t.firstChild);for(;e.length>0;){const t=e.next();e.isBlock&&sc(e),e=t}let i=[];for(e=new E(t.firstChild);e.length>0;){const t=e.next();e.isMark||e.isText||e.isBookmark||e.isInlineBox?i.push(e):(H(i),i=[]),e=t}H(i)}(a),oc(t,a),t.box.renderAll(t)}))})),$r.plugin.add((t=>{t.readonly||(t.command.add("undo",{execute:()=>{t.history.undo()}}),t.keystroke.setKeydown("mod+z",(e=>{t.selection.range.isInsideBox||(e.preventDefault(),t.command.execute("undo"))})))})),$r.plugin.add((t=>{if(t.readonly)return;t.command.add("redo",{execute:()=>{t.history.redo()}});const e=e=>{t.selection.range.isInsideBox||(e.preventDefault(),t.command.execute("redo"))};t.keystroke.setKeydown("mod+y",e),t.keystroke.setKeydown("mod+shift+z",e)})),$r.plugin.add((t=>{t.readonly||t.command.add("selectAll",{execute:()=>{const e=t.selection.range;e.selectNodeContents(t.container),e.shrink()}})})),$r.plugin.add((t=>{t.readonly||t.command.add("heading",{selectedValues:t=>{const e=t.find((t=>t.node.isHeading||"p"===t.name));return e?[e.name]:[]},execute:e=>{t.selection.setBlocks(`<${e} />`),t.history.save()}})})),$r.plugin.add((t=>{t.readonly||t.command.add("blockQuote",{isSelected:t=>!!t.find((t=>"blockquote"===t.name)),execute:e=>{e&&rc.indexOf(e)>=0?t.selection.setBlocks(a`<blockquote type="${e}" />`):t.selection.setBlocks("<blockquote />"),t.history.save()}})})),$r.plugin.add((t=>{t.readonly||(t.command.add("list",{selectedValues:t=>{let e;for(const i of t){if("ol"===i.name){e="numbered";break}if("ul"===i.name&&!i.node.hasAttr("type")){e="bulleted";break}if("ul"===i.name&&"checklist"===i.node.attr("type")){e="checklist";break}}return e?[e]:[]},execute:(e,i=!1)=>{const n=t.selection.range.getBlocks();let s=!1,o=!1,r=!1;for(const t of n)s||"ol"!==t.name||(s=!0),o||"ul"!==t.name||t.hasAttr("type")||(o=!0),r||"ul"!==t.name||"checklist"!==t.attr("type")||(r=!0);s?("numbered"===e&&ac(t),"bulleted"===e&&cc(t),"checklist"===e&&hc(t,i)):o?("numbered"===e&&lc(t),"bulleted"===e&&ac(t),"checklist"===e&&hc(t,i)):r?("numbered"===e&&lc(t),"bulleted"===e&&cc(t),"checklist"===e&&ac(t)):("numbered"===e&&lc(t),"bulleted"===e&&cc(t),"checklist"===e&&hc(t,i)),t.history.save()}}),t.container.on("click",(e=>{const i=e;if(!i.target)return;const n=I(i.target);"li"===n.name&&""!==n.attr("value")&&i.offsetX<=18&&(n.attr("value",("true"!==n.attr("value")).toString()),t.history.save())})))})),$r.plugin.add((t=>{t.readonly||t.command.add("align",{selectedValues:t=>{let e;for(const i of t)if(i.node.isBlock){e=i.node.computedCSS("text-align");break}return e?[dc[e]||e]:[]},execute:e=>{t.selection.setBlocks({"text-align":e}),t.history.save()}})})),$r.plugin.add((t=>{t.readonly||t.command.add("indent",{execute:e=>{const i=t.selection.range.getBlocks();for(const t of i)F(t,e);t.history.save()}})})),$r.plugin.add((t=>{t.readonly||(t.command.add("bold",{isDisabled:t=>!!t.find((t=>t.node.isHeading)),isSelected:t=>!!t.find((t=>t.name===pc)),execute:()=>{t.command.isSelected("bold")?t.selection.removeMark(`<${pc} />`):t.selection.addMark(`<${pc} />`),t.history.save()}}),t.keystroke.setKeydown("mod+b",(e=>{e.preventDefault(),t.command.execute("bold")})))})),$r.plugin.add((t=>{t.readonly||(t.command.add("italic",{isSelected:t=>!!t.find((t=>"i"===t.name)),execute:()=>{t.command.isSelected("italic")?t.selection.removeMark("<i />"):t.selection.addMark("<i />"),t.history.save()}}),t.keystroke.setKeydown("mod+i",(e=>{e.preventDefault(),t.command.execute("italic")})))})),$r.plugin.add((t=>{t.readonly||(t.command.add("underline",{isSelected:t=>!!t.find((t=>"u"===t.name)),execute:()=>{t.command.isSelected("underline")?t.selection.removeMark("<u />"):t.selection.addMark("<u />"),t.history.save()}}),t.keystroke.setKeydown("mod+u",(e=>{e.preventDefault(),t.command.execute("underline")})))})),$r.plugin.add((t=>{t.readonly||(t.command.add("strikethrough",{isSelected:t=>!!t.find((t=>"s"===t.name)),execute:()=>{t.command.isSelected("strikethrough")?t.selection.removeMark("<s />"):t.selection.addMark("<s />"),t.history.save()}}),t.keystroke.setKeydown("mod+shift+x",(e=>{e.preventDefault(),t.command.execute("strikethrough")})))})),$r.plugin.add((t=>{t.readonly||t.command.add("subscript",{isSelected:t=>!!t.find((t=>t.name===uc)),execute:()=>{t.command.isSelected("subscript")?t.selection.removeMark(`<${uc} />`):t.selection.addMark(`<${uc} />`),t.history.save()}})})),$r.plugin.add((t=>{t.readonly||t.command.add("superscript",{isSelected:t=>!!t.find((t=>t.name===mc)),execute:()=>{t.command.isSelected("superscript")?t.selection.removeMark(`<${mc} />`):t.selection.addMark(`<${mc} />`),t.history.save()}})})),$r.plugin.add((t=>{t.readonly||t.command.add("code",{isSelected:t=>!!t.find((t=>t.name===fc)),execute:()=>{t.command.isSelected("code")?t.selection.removeMark(`<${fc} />`):t.selection.addMark(`<${fc} />`),t.history.save()}})})),$r.plugin.add((t=>{t.readonly||t.command.add("fontFamily",{selectedValues:t=>{for(const e of t)if("span"===e.name){return[e.node.css("font-family").replace(/['"]/g,"")]}return[]},execute:e=>{t.selection.addMark(`<span style="font-family: ${e};" />`),t.history.save()}})})),$r.plugin.add((t=>{t.readonly||t.command.add("fontSize",{isDisabled:t=>!!t.find((t=>t.node.isHeading)),selectedValues:t=>{for(const e of t)if("span"===e.name){return[e.node.css("font-size").replace(/\.\d+/,"")]}return[]},execute:e=>{t.selection.addMark(`<span style="font-size: ${e};" />`),t.history.save()}})})),$r.plugin.add((t=>{t.readonly||t.command.add("fontColor",{selectedValues:t=>{for(const e of t)if("span"===e.name){return[d(e.node.computedCSS("color"))]}return[]},execute:e=>{t.selection.addMark(`<span style="color: ${e};" />`),t.history.save()}})})),$r.plugin.add((t=>{t.readonly||t.command.add("highlight",{selectedValues:t=>{for(const e of t)if("span"===e.name){return[d(e.node.computedCSS("background-color"))]}return[]},execute:e=>{t.selection.addMark(`<span style="background-color: ${e};" />`),t.history.save()}})})),$r.plugin.add((t=>{t.readonly||t.command.add("removeFormat",{execute:()=>{t.selection.removeMark(),t.history.save()}})})),$r.plugin.add((t=>{if(t.readonly)return;let e=[];t.command.add("formatPainter",{execute:()=>{t.container.addClass(gc);const i=t.selection.getAppliedItems();for(const t of i){const i=t.node.clone();i.isMark&&"a"!==i.name&&e.push(i)}}}),t.container.on("click",(()=>{if(t.container.removeClass(gc),0!==e.length){for(const i of e)t.selection.addMark(i);e=[],t.history.save()}})),t.event.on("click",(i=>{if(i.isInside&&i.closestContainer().get(0)===t.container.get(0))return;i.closest('button[name="formatPainter"]').length>0||(t.container.removeClass(gc),e=[])}))})),$r.plugin.add((t=>{if(t.readonly)return;const e=new vc({root:t.popupContainer,locale:t.locale});e.event.on("save",(e=>{const i=t.selection.range;i.setStartAfter(e),i.collapseToStart(),t.selection.addRangeToNativeSelection(),t.history.save()})),e.event.on("remove",(e=>{const i=t.selection.range;i.setStartAfter(e),i.collapseToStart(),t.selection.addRangeToNativeSelection(),t.history.save()})),t.root.on("scroll",(()=>{e.updatePosition()})),t.event.on("resize",(()=>{e.updatePosition()})),t.event.on("click",(i=>{if(i.closest('button[name="link"]').length>0)return;const n=i.closest("a");0!==n.length?n.isOutside||n.closestContainer().get(0)!==t.container.get(0)||n.closest("lake-box").length>0?e.hide():e.show(n):e.hide()})),t.command.add("link",{execute:()=>{const i=t.selection.insertLink(`<a href="">${t.locale.link.newLink()}</a>`);i&&(t.history.save(),e.show(i))}})})),$r.plugin.add((t=>{t.readonly||(t.event.on("beforepaste",(t=>{new mt(t).find("hr").each((t=>{const e=I(t),i=new Yt("hr");e.replaceWith(i.node)}))})),t.command.add("hr",{execute:()=>{t.insertBox("hr"),t.history.save()}}))})),$r.plugin.add((t=>{t.setPluginConfig("image",{requestMethod:"POST",requestTypes:["image/gif","image/jpeg","image/png","image/svg+xml"]}),t.readonly||(t.event.on("beforepaste",(t=>{new mt(t).find("img").each((t=>{const e=I(t),i=new Yt("image"),n=e.attr("data-lake-value");""===n?i.value={url:e.attr("src"),status:"done"}:i.node.attr("value",n),e.replaceWith(i.node)}))})),t.command.add("image",{execute:e=>{t.insertBox("image",e),t.history.save()}}))})),$r.plugin.add((t=>{window.LakeCodeMirror&&(t.setPluginConfig("codeBlock",{langList:yc,defaultLang:"text"}),t.readonly||t.command.add("codeBlock",{execute:e=>{const i=t.insertBox("codeBlock",e);t.history.save();i.getData("codeEditor").focus()}}))})),$r.plugin.add((t=>{t.readonly||(t.keystroke.setKeydown("space",(e=>{const i=t.selection.range;if(i.isBox)return;const n=function(t){const e=t.selection.range;let i=e.startNode,n=e.startOffset;if(0!==n){if(i.isElement){const t=i.children()[n-1];if(!t||!t.isText)return;i=t,n=i.text().length}if(!(n<1))return{node:i,offset:n}}}(t);if(!n)return;if(function(t,e){const i=t.selection,n=i.range,s=e.offset,o=e.node.text().slice(0,s);for(const e of bc){const r=e.re.exec(o);if(null!==r){const o=e.getParameters(),a=o.shift();if(!t.command.has(a))return!1;t.prepareOperation();const l=i.insertBookmark(),c=l.focus.prev(),h=c.text(),d=`${h.replace(e.re,"$1")}​`;return c.get(0).nodeValue=d,n.setStart(c,s-r[0].length),n.setEnd(c,s-(h.length-d.length)-1),t.command.execute(a,...o),i.toBookmark(l),t.commitOperation(),!0}}return!1}(t,n))return void e.preventDefault();const s=i.getBlocks()[0];s&&(s.isHeading||"p"===s.name)&&function(t,e){const i=t.selection,n=e.offset;let s=e.node.text().slice(0,n);s=s.replace(/[\u200B\u2060]/g,"");for(const e of kc){const n=e.re.exec(s);if(null!==n){const s=e.getParameters(n),o=s.shift();if(!t.command.has(o))return!1;t.prepareOperation();const r=i.insertBookmark();r.focus.prev().remove();const a=r.focus.closestBlock();return Sc(a),i.range.shrinkAfter(a),t.command.execute(o,...s),i.toBookmark(r),t.commitOperation(),!0}}return!1}(t,n)&&e.preventDefault()})),t.keystroke.setKeydown("enter",(e=>{const i=t.selection.range;if(i.isBox)return;const n=i.getBlocks()[0];return!n||!n.isHeading&&"p"!==n.name||n.find("lake-box").length>0||""!==i.getEndText()?void 0:function(t,e){const i=t.selection;let n=e.text();n=n.replace(/[\u200B\u2060]/g,"");for(const s of _c){const o=s.re.exec(n);if(null!==o){const n=s.getParameters(o),r=n.shift();return!!t.command.has(r)&&(t.prepareOperation(),e.empty(),Sc(e),i.range.shrinkAfter(e),t.command.execute(r,...n),t.commitOperation(),!0)}}return!1}(t,n)?(e.preventDefault(),e.stopImmediatePropagation(),!1):void 0})))})),$r.plugin.add((t=>{t.readonly||t.keystroke.setKeydown("enter",(e=>{const i=t.selection.range;if(i.isInsideBox)return;if(e.preventDefault(),t.rectifyContent(),i.isBox)return Ac(t),void t.history.save();if(i.adapt(),i.isInoperative)return;if(i.isBox)return Ac(t),void t.history.save();let n=i.getBlocks()[0];if(n||(t.selection.setBlocks("<p />"),n=i.getBlocks()[0]),n.isEmpty&&"p"!==n.name)return t.selection.setBlocks("<p />"),void t.history.save();Cc(t,n),t.history.save()}))})),$r.plugin.add((t=>{t.readonly||t.keystroke.setKeydown("shift+enter",(e=>{const i=t.selection.range;if(!i.isInsideBox){if(t.rectifyContent(),e.preventDefault(),i.isBox)return Tc(t),void t.history.save();if(i.adapt(),!i.isInoperative){if(i.isBox)return Tc(t),void t.history.save();Bc(t),t.history.save()}}}))})),$r.plugin.add((t=>{t.readonly||t.keystroke.setKeydown("backspace",(e=>{const i=t.selection.range;if(i.isInsideBox)return;if(t.rectifyContent(),i.isBoxStart){const n=i.startNode.closest("lake-box"),s=n.prev();if(0===s.length){const i=n.closestBlock();return void(i.length>0&&!i.isContainer&&(e.preventDefault(),Ec(t,i),t.history.save()))}if(s.isBlock)return s.isEmpty?(e.preventDefault(),s.remove(),t.selection.fixList(),void t.history.save()):(e.preventDefault(),void i.shrinkAfter(s));i.adaptBox()}if(i.isBox)return e.preventDefault(),t.removeBox(),void t.history.save();if(!i.isCollapsed)return e.preventDefault(),t.selection.deleteContents(),""===t.container.html().trim()&&t.setValue("<p><br /><focus /></p>"),void t.history.save();i.adapt();const n=i.getPrevNode();if(n.isBox)return e.preventDefault(),i.selectBox(n),t.removeBox(),void t.history.save();if("br"===n.name&&n.prev().length>0)return e.preventDefault(),i.setStartBefore(n),i.collapseToStart(),n.remove(),void t.history.save();if(""===i.getStartText()){e.preventDefault();let n=i.getBlocks()[0];if(n||(t.selection.setBlocks("<p />"),n=i.getBlocks()[0]),""!==n.css("margin-left")||""!==n.css("text-indent")||""!==n.attr("indent"))return F(n,"decrease"),void t.history.save();if(n.isList||"blockquote"===n.name)return t.selection.setBlocks("<p />"),void t.history.save();Ec(t,n),t.history.save()}}))})),$r.plugin.add((t=>{t.readonly||t.keystroke.setKeydown("delete",(e=>{const i=t.selection.range;if(i.isInsideBox)return;if(t.rectifyContent(),i.isBoxEnd){const n=i.startNode.closest("lake-box"),s=n.next();if(0===s.length){const i=n.closestBlock();return void(i.length>0&&!i.isContainer&&(e.preventDefault(),Ic(t,i),t.history.save()))}if(s.isBlock)return s.isEmpty?(e.preventDefault(),s.remove(),t.selection.fixList(),void t.history.save()):(e.preventDefault(),void i.shrinkBefore(s));i.adaptBox()}if(i.isBox)return e.preventDefault(),t.removeBox(),void t.history.save();if(!i.isCollapsed)return e.preventDefault(),t.selection.deleteContents(),""===t.container.html().trim()&&t.setValue("<p><br /><focus /></p>"),void t.history.save();i.adapt();const n=i.getNextNode();if(n.isBox)return e.preventDefault(),i.selectBox(n),t.removeBox(),void t.history.save();"br"===n.name&&n.next().length>0&&(e.preventDefault(),i.setStartBefore(n),i.collapseToStart(),n.remove(),t.history.save());if(""===i.getEndText()){e.preventDefault();let n=i.getBlocks()[0];n||(t.selection.setBlocks("<p />"),n=i.getBlocks()[0]),Ic(t,n),t.history.save()}}))})),$r.plugin.add((t=>{t.readonly||t.keystroke.setKeydown("tab",(e=>{if(!1===t.config.indentWithTab)return;e.preventDefault();t.selection.range.getBlocks().forEach((t=>{"p"===t.name&&"2em"!==t.css("text-indent")?t.css("text-indent","2em"):F(t,"increase")})),t.history.save()}))})),$r.plugin.add((t=>{t.readonly||(t.keystroke.setKeydown("arrow-left",(e=>{const i=t.selection.range;if(i.isInsideBox)return;const n=i.commonAncestor.closest("lake-box");if(n.length>0){if(i.isBoxStart){const t=n.prev();return t.isBlock||t.isBox?(e.preventDefault(),t.isInlineBox?void i.selectBox(t):void i.shrinkAfter(t)):(i.setStartBefore(n),void i.collapseToStart())}return i.isBoxEnd?(e.preventDefault(),void i.selectBox(n)):(e.preventDefault(),void i.selectBoxStart(n))}if(!i.isCollapsed)return;const s=i.getPrevNode();s.isBox&&(e.preventDefault(),i.selectBox(s))})),t.keystroke.setKeydown("arrow-right",(e=>{const i=t.selection.range;if(i.isInsideBox)return;const n=i.commonAncestor.closest("lake-box");if(n.length>0){if(i.isBoxStart)return e.preventDefault(),void i.selectBox(n);if(i.isBoxEnd){const t=n.next();return t.isBlock||t.isBox?(e.preventDefault(),t.isInlineBox?void i.selectBox(t):void i.shrinkBefore(t)):(i.setStartAfter(n),void i.collapseToStart())}return e.preventDefault(),void i.selectBoxEnd(n)}if(!i.isCollapsed)return;const s=i.getNextNode();s.isBox&&(e.preventDefault(),i.selectBox(s))})),t.keystroke.setKeydown("arrow-up",(e=>{const i=t.selection.range;if(i.isInsideBox)return;const n=i.commonAncestor.closest("lake-box");if(n.length>0){if(n.isBlockBox){const t=n.prev();if(t.isBlock||t.isBox)return e.preventDefault(),void i.shrinkAfter(t)}i.setStartBefore(n),i.collapseToStart()}})),t.keystroke.setKeydown("arrow-down",(e=>{const i=t.selection.range;if(i.isInsideBox)return;const n=i.commonAncestor.closest("lake-box");if(n.length>0){if(n.isBlockBox){const t=n.next();if(t.isBlock||t.isBox)return e.preventDefault(),void i.shrinkBefore(t)}i.setStartAfter(n),i.collapseToStart()}})))})),$r.plugin.add((t=>{t.readonly||t.keystroke.setKeydown("escape",(e=>{const i=t.selection,n=i.range;if(n.isBoxCenter||n.isInsideBox){e.preventDefault();const t=n.commonAncestor.closest("lake-box");return n.selectBoxEnd(t),void i.addRangeToNativeSelection()}t.hasFocus&&(e.preventDefault(),t.blur())}))})),t.Box=Yt,t.Button=ke,t.Dropdown=De,t.Editor=$r,t.Fragment=mt,t.HTMLParser=ie,t.Nodes=E,t.Range=L,t.TextParser=ne,t.Toolbar=class{constructor(t){this.allMenuMap=new Map,this.buttonItemList=[],this.dropdownItemList=[],this.items=t.items||Xr,this.root=I(t.root),this.container=I('<div class="lake-toolbar" />'),this.root.addClass("lake-custom-properties")}appendDivider(){this.container.append('<div class="lake-toolbar-divider" />')}appendButton(t,e){new ke({root:this.container,name:e.name,icon:e.icon,tooltip:"string"==typeof e.tooltip?e.tooltip:e.tooltip(t.locale),tabIndex:-1,onClick:()=>{t.focus(),e.onClick(t,e.name)}}).render()}appendDropdown(t,e){new De({root:this.container,locale:t.locale,name:e.name,icon:e.icon,accentIcon:e.accentIcon,downIcon:e.downIcon,defaultValue:e.defaultValue,tooltip:e.tooltip,width:e.width,menuType:e.menuType,menuItems:e.menuItems,tabIndex:-1,onSelect:i=>{t.focus(),e.onSelect(t,i)}}).render()}appendUpload(t,e){const i=I(a`
70
70
  <div class="lake-upload" name="${e.name}">
71
71
  <input type="file" />
72
72
  </div>