PageSourceSearch

https://partners.hswf.co.uk/assets/CRMIndex-CteweC4V.js

js hswf.co.uk collected 2026-09-25 10:25:14 UTC 260,935 bytes, 2 lines download raw bytes

1var Ou=Object.defineProperty;var Mu=(n,t,e)=>t in n?Ou(n,t,{enumerable:!0,configurable:!0,writable:!0,value:e}):n[t]=e;var w=(n,t,e)=>Mu(n,typeof t!="symbol"?t+"":t,e);import{r as P,j as u,bW as fo,ci as Au,cj as Du,ck as Pu,cl as Fu,cm as $u,cn as Lu,co as Iu,cp as Ru,cq as Bu,cr as zu,cs as Ku,ct as Wu,cu as Uu,cv as Ju,cw as Vu,cx as qu,az as Hu,cy as Yu,D as it,e as Je,d as Ts,an as Gu,aR as ti,p as Wn,z as V,I as oe,t as Ie,h as Wt,q as ft,L as Zl,aP as ea,_ as at,E as Dr,a3 as fn,c9 as Qu,aS as ta,aT as ct,bi as Xu,u as Es,cz as Zu,x as Ui,by as na,y as ed,ac as td,aK as ra,cA as nd,f as rd,a7 as ho,bJ as id,cB as go,cC as sd,bG as od,A as ld,F as ad,B as cd}from"./index-1ZwnxBtP.js";import{B as sn}from"./BackButton-gsucH3Mk.js";import{u as Ln,p as ud}from"./index-uWq9hbIA.js";import{P as dd}from"./StateBasedPagination-GXnzMTTz.js";import fd from"./AffiliateSalesDetails-BH04xjem.js";import"./AffiliateSalesLineItemsModalNew-C90JqFvV.js";import"./useDebounce-DfXLfP9X.js";import"./Dropdown-Za-Ta5Bo.js";import"./ThemeProvider-DppOPtX1.js";import"./use-isomorphic-layout-effect.browser.esm-Dlv4p7Sx.js";import"./index-v2WCNqB0.js";import"./RenderCommission-CAGJj7T-.js";import"./BootStrapTable-BGWd0CKh.js";function O(n,...t){const e=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const i of t)r.append("v",i);throw e.search=r.toString(),Error("Minified Lexical error #".concat(n,"; visit ").concat(e.toString()," for the full message or use the non-minified dev environment for full errors and additional helpful warnings."))}function ia(n,...t){const e=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const i of t)r.append("v",i);e.search=r.toString(),console.warn("Minified Lexical warning #".concat(n,"; visit ").concat(e.toString()," for the full message or use the non-minified dev environment for full errors and additional helpful warnings."))}const Fe=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,hd=Fe&&"documentMode"in document?document.documentMode:null,Oe=Fe&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),ht=Fe&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Pr=!(!Fe||!("InputEvent"in window)||hd)&&"getTargetRanges"in new window.InputEvent("input"),er=Fe&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,sa=Fe&&/Android/.test(navigator.userAgent),ni=Fe&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!sa,oa=Fe&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Ji=Fe&&sa&&oa,ri=Fe&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&Oe&&!oa,gd=0,md=1,pd=2,la=128,_d=1,yd=2,xd=3,vd=4,bd=5,Cd=6,Un=ni||er||ri?" ":"​",ii="\n\n",js=ht?" ":Un,Dt={bold:1,capitalize:1024,code:16,highlight:la,italic:2,lowercase:256,strikethrough:4,subscript:32,superscript:64,underline:8,uppercase:512},Sd={directionless:1,unmergeable:2},Vi={center:2,end:6,justify:4,left:1,right:3,start:5},Nd={[yd]:"center",[Cd]:"end",[vd]:"justify",[_d]:"left",[xd]:"right",[bd]:"start"},kd={normal:0,segmented:2,token:1},wd={[gd]:"normal",[pd]:"segmented",[md]:"token"},mo="$config";let Tn=class{constructor(){w(this,"_front",new Set);w(this,"_back",new Set);w(this,"_cache")}get size(){return this._front.size+this._back.size}addBack(t){return delete this._cache,this._front.has(t)||this._back.add(t),this}addFront(t){return delete this._cache,this._back.has(t)||this._front.add(t),this}delete(t){return delete this._cache,this._front.delete(t)||this._back.delete(t)}toArray(){const t=Array.from(this._front).reverse();for(const e of this._back)t.push(e);return t}toReadonlyArray(){return this._cache=this._cache||this.toArray(),this._cache}[Symbol.iterator](){return this.toReadonlyArray()[Symbol.iterator]()}};function aa(n,t,e,r,i,s){let o=n.getFirstChild();for(;o!==null;){const l=o.__key;o.__parent===t&&(C(o)&&aa(o,l,e,r,i,s),e.has(l)||s.delete(l),i.push(l)),o=o.getNextSibling()}}let qi=!1,Os=0;function Td(n){Os=n.timeStamp}function Si(n,t,e){const r=n.nodeName==="BR",i=t.__lexicalLineBreak;return i&&(n===i||r&&n.previousSibling===i)||r&&hi(n,e)!==void 0}function Ed(n,t,e){const r=Ee(Ce(e));let i=null,s=null;r!==null&&r.anchorNode===n&&(i=r.anchorOffset,s=r.focusOffset);const o=n.nodeValue;o!==null&&Vs(t,o,i,s,!1)}
1function jd(n,t,e){if(E(n)){const r=n.anchor.getNode();if(r.is(e)&&n.format!==r.getFormat())return!1}return st(t)&&e.isAttached()}function Od(n,t,e,r){for(let i=n;i&&!$f(i);i=sr(i)){const s=hi(i,t);if(s!==void 0){const o=ne(s,e);if(o)return J(o)||!te(i)?void 0:[i,o]}else if(i===r)return[r,xc(e)]}}function ca(n,t,e){qi=!0;const r=performance.now()-Os>100;try{ze(n,()=>{const i=D()||function(h){return h.getEditorState().read(()=>{const m=D();return m!==null?m.clone():null})}(n),s=new Map,o=n.getRootElement(),l=n._editorState,a=n._blockCursorElement;let c=!1,d="";for(let h=0;h<t.length;h++){const m=t[h],g=m.type,y=m.target,p=Od(y,n,l,o);if(!p)continue;const[_,x]=p;if(g==="characterData")r&&M(x)&&st(y)&&jd(i,y,x)&&Ed(y,x,n);else if(g==="childList"){c=!0;const b=m.addedNodes;for(let v=0;v<b.length;v++){const k=b[v],S=_c(k),T=k.parentNode;if(T!=null&&k!==a&&S===null&&!Si(k,T,n)){if(ht){const A=(te(k)?k.innerText:null)||k.nodeValue;A&&(d+=A)}T.removeChild(k)}}const N=m.removedNodes,j=N.length;if(j>0){let v=0;for(let k=0;k<j;k++){const S=N[k];(Si(S,y,n)||a===S)&&(y.appendChild(S),v++)}j!==v&&s.set(_,x)}}}if(s.size>0)for(const[h,m]of s)m.reconcileObservedMutation(h,n);const f=e.takeRecords();if(f.length>0){for(let h=0;h<f.length;h++){const m=f[h],g=m.addedNodes,y=m.target;for(let p=0;p<g.length;p++){const _=g[p],x=_.parentNode;x==null||_.nodeName!=="BR"||Si(_,y,n)||x.removeChild(_)}}e.takeRecords()}i!==null&&(c&&me(i),ht&&Sc(n)&&i.insertRawText(d))})}finally{qi=!1}}function ua(n){const t=n._observer;t!==null&&ca(n,t.takeRecords(),t)}function da(n){(function(t){Os===0&&Ce(t).addEventListener("textInput",Td,!0)})(n),n._observer=new MutationObserver((t,e)=>{ca(n,t,e)})}let Md=class{constructor(t,e){w(this,"key");w(this,"parse");w(this,"unparse");w(this,"isEqual");w(this,"defaultValue");w(this,"resetOnCopyNode");this.key=t,this.parse=e.parse.bind(e),this.unparse=(e.unparse||Fd).bind(e),this.isEqual=(e.isEqual||Object.is).bind(e),this.defaultValue=this.parse(void 0),this.resetOnCopyNode=e.resetOnCopyNode||!1}};function fa(n,t){return new Md(n,t)}function Ad(n){const t=new Map,e=new Set;for(let r=typeof n=="function"?n:n.replace;r.prototype&&r.prototype.getType!==void 0;r=Object.getPrototypeOf(r)){const{ownNodeConfig:i}=vn(r);if(i&&i.stateConfigs)for(const s of i.stateConfigs){let o;"stateConfig"in s?(o=s.stateConfig,s.flat&&e.add(o.key)):o=s,t.set(o.key,o)}}return{flatKeys:e,sharedConfigMap:t}}let Dd=class ha{constructor(t,e,r=void 0,i=new Map,s=void 0){w(this,"node");w(this,"knownState");w(this,"unknownState");w(this,"sharedNodeState");w(this,"size");this.node=t,this.sharedNodeState=e,this.unknownState=r,this.knownState=i;const{sharedConfigMap:o}=this.sharedNodeState,l=s!==void 0?s:function(a,c,d){let f=d.size;if(c)for(const h in c){const m=a.get(h);m&&d.has(m)||f++}return f}(o,r,i);this.size=l}getValue(t){const e=this.knownState.get(t);if(e!==void 0)return e;this.sharedNodeState.sharedConfigMap.set(t.key,t);let r=t.defaultValue;if(this.unknownState&&t.key in this.unknownState){const i=this.unknownState[t.key];i!==void 0&&(r=t.parse(i)),this.updateFromKnown(t,r)}return r}getInternalState(){return[this.unknownState,this.knownState]}toJSON(){const t={...this.unknownState},e={};for(const[r,i]of this.knownState)r.isEqual(i,r.defaultValue)?delete t[r.key]:t[r.key]=r.unparse(i);for(const r of this.sharedNodeState.flatKeys)r in t&&(e[r]=t[r],delete t[r]);return po(t)&&(e.$=t),e}getWritable(t){if(this.node===t)return this;const{sharedNodeState:e,unknownState:r}=this,i=new Map(this.knownState);return new ha(t,e,function(s,o,l){let a;if(l)for(const[c,d]of Object.entries(l)){const f=s.get(c);f?o.has(f)||o.set(f,f.parse(d)):(a=a||{},a[c]=d)}return a}(e.sharedConfigMap,i,r),i,this.size)}resetOnCopyNode(){for(const t of this.knownState.keys())t.resetOnCopyNode&&this.knownState.set(t,t.defaultValue);return this}updateFromKnown(t,e){const r=t.key;this.sharedNodeState.sharedConfigMap.set(r,t);const{knownState:i,unknownState:s}=this;i.has(t)||s&&r in s||(s&&(delete s[r],this.unknownState=po(s)),this.size++),i.set(t,e)}updateFromUnknown(t,e){const r=this.sharedNodeState.sharedConfigMap.get(t);r?this.updateFromKnown(r,r.parse(e)):(this.unknownState=this.unknownState||{},t in this.unknownState||this.size++,this.unknownState[t]=e)}updateFromJSON(t){const{knownState:e}=this;for(const r of e.keys())e.set(r,r.defaultValue);if(this.size=e.size,this.unknownState=void 0,t)for(const[r,i]of Object.entries(t))this.updateFromUnknown(r,i)}};function Pd(n){const t=n.getWritable(),e=t.__state?t.__state.getWritable(t):new Dd(t,ga(t));return t.__state=e,e}function ga(n){return n.__state?n.__state.sharedNodeState:fc(nt(),n.getType()).sharedNodeState}function po(n){if(n)for(const t in n)return n}function Fd(n){return n}function _o(n,t,e){for(const[r,i]of t.knownState){if(n.has(r.key))continue;n.add(r.key);const s=e?e.getValue(r):r.defaultValue;if(s!==i&&!r.isEqual(s,i))return!0}return!1}function yo(n,t,e){const{unknownState:r}=t,i=e?e.unknownState:void 0;if(r){for(const[s,o]of Object.entries(r))if(!n.has(s)&&(n.add(s),o!==(i?i[s]:void 0)))return!0}return!1}function xo(n,t){const e=n.__state;return e&&e.node===n?e.getWritable(t):e}function vo(n,t){const e=n.__mode,r=n.__format,i=n.__style,s=t.__mode,o=t.__format,l=t.__style,a=n.__state,c=t.__state;return(e===null||e===s)&&(r===null||r===o)&&(i===null||i===l)&&(n.__state===null||a===c||function(d,f){if(d===f)return!0;const h=new Set;return!(d&&_o(h,d,f)||f&&_o(h,f,d)||d&&yo(h,d,f)||f&&yo(h,f,d))}(a,c))}function bo(n,t){const e=n.mergeWithSibling(t),r=G()._normalizedNodes;return r.add(n.__key),r.add(t.__key),e}function Co(n){let t,e,r=n;if(r.__text!==""||!r.isSimpleText()||r.isUnmergeable()){for(;(t=r.getPreviousSibling())!==null&&M(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==""){if(vo(t,r)){r=bo(t,r);break}break}t.remove()}for(;(e=r.getNextSibling())!==null&&M(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(e.__text!==""){if(vo(r,e)){r=bo(r,e);break}break}e.remove()}}else r.remove()}function Pt(n){return So(n.anchor),So(n.focus),n}function So(n){for(;n.type==="element";){const t=n.getNode(),e=n.offset;let r,i;if(e===t.getChildrenSize()?(r=t.getChildAtIndex(e-1),i=!0):(r=t.getChildAtIndex(e),i=!1),M(r)){n.set(r.__key,i?r.getTextContentSize():0,"text",!0);break}if(!C(r))break;n.set(r.__key,i?r.getChildrenSize():0,"element",!0)}}let Jn,X,Vn,si,Hi,Yi,Ft,Ae,Gi,qn,et,re="",Re=null,wt=null,Zt=!1,Fr=!1;function $r(n,t){const e=Ft.get(n);if(t!==null){const r=es(n);r.parentNode===t&&t.removeChild(r)}if(Ae.has(n)||X._keyToDOMMap.delete(n),C(e)){const r=qr(e,Ft);Qi(r,0,r.length-1,null)}e!==void 0&&qs(qn,Vn,si,e,"destroyed")}function Qi(n,t,e,r){for(let i=t;i<=e;++i){const s=n[i];s!==void 0&&$r(s,r)}}function kt(n,t){n.setProperty("text-align",t)}const $d="40px";function ma(n,t){const e=Jn.theme.indent;if(typeof e=="string"){const i=n.classList.contains(e);t>0&&!i?n.classList.add(e):t<1&&i&&n.classList.remove(e)}if(t===0)return void n.style.setProperty("padding-inline-start","");const r=getComputedStyle(X._rootElement||n).getPropertyValue("--lexical-indent-base-value")||$d;n.style.setProperty("padding-inline-start","calc(".concat(t," * ").concat(r,")"))}function pa(n,t){const e=n.style;
1t===0?kt(e,""):t===1?kt(e,"left"):t===2?kt(e,"center"):t===3?kt(e,"right"):t===4?kt(e,"justify"):t===5?kt(e,"start"):t===6&&kt(e,"end")}function Xi(n,t){const e=function(r){const i=r.__dir;if(i!==null)return i;if(ie(r))return null;const s=r.getParentOrThrow();return ie(s)&&s.__dir===null?"auto":null}(t);e!==null?n.dir=e:n.removeAttribute("dir")}function Lr(n,t){const e=Ae.get(n);e===void 0&&O(60);const r=et.$createDOM(e,X);if(function(i,s,o){const l=o._keyToDOMMap;(function(a,c,d){const f="__lexicalKey_".concat(c._key);a[f]=d})(s,o,i),l.set(i,s)}(n,r,X),M(e)?r.setAttribute("data-lexical-text","true"):J(e)&&r.setAttribute("data-lexical-decorator","true"),C(e)){const i=e.__indent,s=e.__size;if(Xi(r,e),i!==0&&ma(r,i),s!==0){const l=s-1;Zi(qr(e,Ae),e,0,l,et.$getDOMSlot(e,r,X))}const o=e.__format;o!==0&&pa(r,o),e.isInline()||_a(null,e,r)}else{const i=e.getTextContent();if(J(e)){const s=e.decorate(X,Jn);s!==null&&ya(n,s),r.contentEditable="false"}re+=i}return t!==null&&t.insertChild(r),et.$decorateDOM(e,null,r,X),qs(qn,Vn,si,e,"created"),r}function Zi(n,t,e,r,i){const s=re;re="";let o=e;for(;o<=r;++o){Lr(n[o],i);const l=Ae.get(n[o]);l!==null&&M(l)?Re===null&&(Re=l.getFormat(),wt=l.getStyle()):C(l)&&o<r&&!l.isInline()&&(re+=ii)}i.element.__lexicalTextContent=re,re=s+re}function No(n,t){if(n){const e=n.__last;if(e){const r=t.get(e);if(r)return cn(r)?"line-break":J(r)&&r.isInline()?"decorator":null}return"empty"}return null}function _a(n,t,e){const r=No(n,Ft),i=No(t,Ae);r!==i&&et.$getDOMSlot(t,e,X).setManagedLineBreak(i)}function Ld(n,t,e){var r;Re=null,wt=null,function(i,s,o){const l=re,a=i.__size,c=s.__size;re="";const d=o.element;if(a===1&&c===1){const f=i.__first,h=s.__first;if(f===h)Sr(f,d);else{const g=es(f),y=Lr(h,null);try{d.replaceChild(y,g)}catch(p){if(typeof p=="object"&&p!=null){const _="".concat(p.toString()," Parent: ").concat(d.tagName,", new child: {tag: ").concat(y.tagName," key: ").concat(h,"}, old child: {tag: ").concat(g.tagName,", key: ").concat(f,"}.");throw new Error(_)}throw p}$r(f,null)}const m=Ae.get(h);M(m)&&Re===null&&(Re=m.getFormat(),wt=m.getStyle())}else{const f=qr(i,Ft),h=qr(s,Ae);if(f.length!==a&&O(227),h.length!==c&&O(228),a===0)c!==0&&Zi(h,0,0,c-1,o);else if(c===0){if(a!==0){const m=o.after==null&&o.before==null&&o.element.__lexicalLineBreak==null;Qi(f,0,a-1,m?null:d),m&&(d.textContent="")}}else(function(m,g,y,p,_,x){const b=p-1,N=_-1;let j,v,k=x.getFirstChild(),S=0,T=0;for(;S<=b&&T<=N;){const z=g[S],R=y[T];if(z===R)k=Ni(Sr(R,x.element)),S++,T++;else{if(v===void 0&&(v=ko(y,T)),j===void 0)j=ko(g,S);else if(!j.has(z)){S++;continue}if(!v.has(z)){k=Ni(es(z)),$r(z,x.element),S++,j.delete(z);continue}if(j.has(R)){const K=gn(X,R);K!==k&&x.withBefore(k).insertChild(K),k=Ni(Sr(R,x.element)),S++,T++}else Lr(R,x.withBefore(k)),T++}const U=Ae.get(R);U!==null&&M(U)?Re===null&&(Re=U.getFormat(),wt=U.getStyle()):C(U)&&T<=N&&!U.isInline()&&(re+=ii)}const A=S>b,$=T>N;if(A&&!$){const z=y[N+1],R=z===void 0?null:X.getElementByKey(z);Zi(y,0,T,N,x.withBefore(R))}else $&&!A&&Qi(g,S,b,x.element)})(0,f,h,a,c,o)}d.__lexicalTextContent=re,re=l+re}(n,t,et.$getDOMSlot(t,e,X)),r=t,Re==null||Re===r.__textFormat||Fr||r.setTextFormat(Re),function(i){wt==null||wt===i.__textStyle||Fr||i.setTextStyle(wt)}(t)}function Sr(n,t){const e=Ft.get(n);let r=Ae.get(n);e!==void 0&&r!==void 0||O(61);const i=Zt||Yi.has(n)||Hi.has(n),s=gn(X,n);if(e===r&&!i){let o;if(C(e)){const l=s.__lexicalTextContent;typeof l=="string"?o=l:(o=e.getTextContent(),s.__lexicalTextContent=o)}else o=e.getTextContent();return re+=o,s}if(e!==r&&i&&qs(qn,Vn,si,r,"updated"),et.$updateDOM(r,e,s,X)){const o=Lr(n,null);return t===null&&O(62),t.replaceChild(o,s),$r(n,null),o}if(C(e)){C(r)||O(334,n);const o=r.__indent;(Zt||o!==e.__indent)&&ma(s,o);const l=r.__format;if((Zt||l!==e.__format)&&pa(s,l),i)Ld(e,r,s),ie(r)||r.isInline()||_a(e,r,s);else{const a=s.__lexicalTextContent;let c;typeof a=="string"?c=a:(c=e.getTextContent(),s.__lexicalTextContent=c),re+=c}if((Zt||r.__dir!==e.__dir)&&(Xi(s,r),ie(r)&&!Zt))for(const a of r.getChildren())C(a)&&Xi(gn(X,a.getKey()),a)}else{const o=r.getTextContent();if(J(r)){const l=r.decorate(X,Jn);l!==null&&ya(n,l)}re+=o}if(!Fr&&ie(r)&&r.__cachedText!==re){const o=r.getWritable();o.__cachedText=re,r=o}return et.$decorateDOM(r,e,s,X),s}function ya(n,t){let e=X._pendingDecorators;const r=X._decorators;if(e===null){if(r[n]===t)return;e=yc(X)}e[n]=t}function Ni(n){let t=n.nextSibling;return t!==null&&t===X._blockCursorElement&&(t=t.nextSibling),t}function ko(n,t){const e=new Set;for(let r=t;r<n.length;r++)e.add(n[r]);return e}function Id(n,t,e,r,i,s){re="",Zt=r===2,X=e,Jn=e._config,et=e._config.dom||Xn,Vn=e._nodes,si=X._listeners.mutation,Hi=i,Yi=s,Ft=n._nodeMap,Ae=t._nodeMap,Fr=t._readOnly,Gi=new Map(e._keyToDOMMap);const o=new Map;return qn=o,Sr("root",null),X=void 0,Vn=void 0,Hi=void 0,Yi=void 0,Ft=void 0,Ae=void 0,Jn=void 0,Gi=void 0,qn=void 0,et=Xn,o}function es(n){const t=Gi.get(n);return t===void 0&&O(75,n),t}function L(n){return{type:n}}const Ms=L("SELECTION_CHANGE_COMMAND"),Rd=L("SELECTION_INSERT_CLIPBOARD_NODES_COMMAND"),xa=L("CLICK_COMMAND"),va=L("BEFORE_INPUT_COMMAND"),ba=L("INPUT_COMMAND"),Ca=L("COMPOSITION_START_COMMAND"),Sa=L("
1COMPOSITION_END_COMMAND"),Et=L("DELETE_CHARACTER_COMMAND"),on=L("INSERT_LINE_BREAK_COMMAND"),Hn=L("INSERT_PARAGRAPH_COMMAND"),ln=L("CONTROLLED_TEXT_INSERTION_COMMAND"),oi=L("PASTE_COMMAND"),Nr=L("REMOVE_TEXT_COMMAND"),Yn=L("DELETE_WORD_COMMAND"),Gn=L("DELETE_LINE_COMMAND"),Ne=L("FORMAT_TEXT_COMMAND"),li=L("UNDO_COMMAND"),ai=L("REDO_COMMAND"),Na=L("KEYDOWN_COMMAND"),ka=L("KEY_ARROW_RIGHT_COMMAND"),Bd=L("MOVE_TO_END"),wa=L("KEY_ARROW_LEFT_COMMAND"),zd=L("MOVE_TO_START"),Ta=L("KEY_ARROW_UP_COMMAND"),Ea=L("KEY_ARROW_DOWN_COMMAND"),Ir=L("KEY_ENTER_COMMAND"),ja=L("KEY_SPACE_COMMAND"),Oa=L("KEY_BACKSPACE_COMMAND"),Ma=L("KEY_ESCAPE_COMMAND"),Aa=L("KEY_DELETE_COMMAND"),Da=L("KEY_TAB_COMMAND"),Kd=L("INSERT_TAB_COMMAND"),Pa=L("INDENT_CONTENT_COMMAND"),ts=L("OUTDENT_CONTENT_COMMAND"),Fa=L("DROP_COMMAND"),Dn=L("FORMAT_ELEMENT_COMMAND"),$a=L("DRAGSTART_COMMAND"),La=L("DRAGOVER_COMMAND"),Wd=L("DRAGEND_COMMAND"),ci=L("COPY_COMMAND"),As=L("CUT_COMMAND"),ns=L("SELECT_ALL_COMMAND"),Ud=L("CLEAR_EDITOR_COMMAND"),Jd=L("CLEAR_HISTORY_COMMAND"),Pn=L("CAN_REDO_COMMAND"),Fn=L("CAN_UNDO_COMMAND"),Vd=L("FOCUS_COMMAND"),qd=L("BLUR_COMMAND"),Hd=L("KEY_MODIFIER_COMMAND"),He=Object.freeze({}),rs=[["keydown",function(n,t){Qn=n.timeStamp,Ia=n.key,!t.isComposing()&&F(t,Na,n)}],["pointerdown",function(n,t){const e=n.target,r=n.pointerType;xn(e)&&r!=="touch"&&r!=="pen"&&n.button===0&&ze(t,()=>{hc(e)||(os=!0)})}],["compositionstart",function(n,t){F(t,Ca,n)}],["compositionend",function(n,t){ht?$n=!0:er||!ni&&!ri?F(t,Sa,n):(kr=!0,wr=n.data)}],["input",function(n,t){n.stopPropagation(),ze(t,()=>{t.dispatchCommand(ba,n)},{event:n}),en=null}],["click",function(n,t){ze(t,()=>{const e=D(),r=Ee(Ce(t)),i=_n();if(r){if(E(e)){const s=e.anchor,o=s.getNode();if(s.type==="element"&&s.offset===0&&e.isCollapsed()&&!ie(o)&&ee().getChildrenSize()===1&&o.getTopLevelElementOrThrow().isEmpty()&&i!==null&&e.is(i))r.removeAllRanges(),e.dirty=!0;else if(n.detail===3&&!e.isCollapsed()&&o!==e.focus.getNode()){const l=de(o,a=>C(a)&&!a.isInline());C(l)&&l.select(0)}}else if(n.pointerType==="touch"||n.pointerType==="pen"){const s=r.anchorNode;(te(s)||st(s))&&me(Fs(i,r,t,n))}}F(t,xa,n)})}],["cut",He],["copy",He],["dragstart",He],["dragover",He],["dragend",He],["paste",He],["focus",He],["blur",He],["drop",He]];Pr&&rs.push(["beforeinput",(n,t)=>function(e,r){const i=e.inputType;i==="deleteCompositionText"||ht&&Sc(r)||i!=="insertCompositionText"&&F(r,va,e)}(n,t)]);let Qn=0,Ia=null,Ra=0,en=null;const is=new WeakMap,Rr=new WeakMap;let ss=!1,os=!1,In=!1,$n=!1,kr=!1,wr="",Tt=null,Ba=[0,"",0,"root",0];function za(n,t,e,r,i){const s=n.anchor,o=n.focus,l=s.getNode(),a=G(),c=Ee(Ce(a)),d=c!==null?c.anchorNode:null,f=s.key,h=a.getElementByKey(f),m=e.length;return f!==o.key||!M(l)||(!i&&(!Pr||Ra<r+50)||l.isDirty()&&m<2||vc(e))&&s.offset!==o.offset&&!l.isComposing()||Be(l)||l.isDirty()&&m>1||(i||!Pr)&&h!==null&&!l.isComposing()&&d!==hn(h)||c!==null&&t!==null&&(!t.collapsed||t.startContainer!==c.anchorNode||t.startOffset!==c.anchorOffset)||!l.isComposing()&&(l.getFormat()!==n.format||l.getStyle()!==n.style)||function(g,y){if(y.isSegmented())return!0;if(!g.isCollapsed())return!1;const p=g.anchor.offset,_=y.getParentOrThrow(),x=Ot(y);return p===0?!y.canInsertTextBefore()||!_.canInsertTextBefore()&&!y.isComposing()||x||function(b){const N=b.getPreviousSibling();return(M(N)||C(N)&&N.isInline())&&!N.canInsertTextAfter()}(y):p===y.getTextContentSize()&&(!y.canInsertTextAfter()||!_.canInsertTextAfter()&&!y.isComposing()||x)}(n,l)}function wo(n,t){return st(n)&&n.nodeValue!==null&&t!==0&&t!==n.nodeValue.length}function To(n,t,e){const{anchorNode:r,anchorOffset:i,focusNode:s,focusOffset:o}=n;ss&&(ss=!1,wo(r,i)&&wo(s,o)&&!Tt)||ze(t,()=>{if(!e)return void me(null);if(!ir(t,r,s))return;let l=D();if(Tt&&E(l)&&l.isCollapsed()){const a=l.anchor,c=Tt.anchor;(a.key===c.key&&a.offset===c.offset+1||a.offset===1&&c.getNode().is(a.getNode().getPreviousSibling()))&&(l=Tt.clone(),me(l))}if(Tt=null,E(l)){const a=l.anchor,c=a.getNode();if(l.isCollapsed()){n.type==="Range"&&n.anchorNode===n.focusNode&&(l.dirty=!0);const d=Ce(t).event,f=d?d.timeStamp:performance.now(),[h,m,g,y,p]=Ba,_=ee(),x=t.isComposing()===!1&&_.getTextContent()==="";if(f<p+200&&a.offset===g&&a.key===y)Tr(l,h,m);else if(a.type==="text")M(c)||O(141),Ka(l,c);else if(a.type==="element"&&!x){C(c)||O(259);const b=a.getNode();b.isEmpty()?function(N,j){const v=j.getTextFormat(),k=j.getTextStyle();Tr(N,v,k)}(l,b):Tr(l,l.format,"")}}else{const d=a.key,f=l.focus.key,h=l.getNodes(),m=h.length,g=l.isBackward(),y=g?o:i,p=g?i:o,_=g?f:d,x=g?d:f;let b=2047,N=!1;for(let j=0;j<m;j++){const v=h[j],k=v.getTextContentSize();if(M(v)&&k!==0&&!(j===0&&v.__key===_&&y===k||j===m-1&&v.__key===x&&p===0)&&(N=!0,b&=v.getFormat(),b===0))break}l.format=N?b:0}}F(t,Ms,void 0)})}function Tr(n,t,e){n.format===t&&n.style===e||(n.format=t,n.style=e,n.dirty=!0)}function Ka(n,t){Tr(n,t.getFormat(),t.getStyle())}function Wa(n){if(!n.getTargetRanges)return null;const t=n.getTargetRanges();return t.length===0?null:t[0]}function Yd(n){const t=n.inputType,e=Wa(n),r=G(),i=D();if(t==="deleteContentBackward"){if(i===null){const f=_n();if(!E(f))return!0;me(f.clone())}if(E(i)){const f=i.anchor.key===i.focus.key;if(s=n.timeStamp,Ia==="MediaLast"&&s<Qn+30&&r.isComposing()&&f){if(ue(null),Qn=0,setTimeout(()=>{ze(r,()=>{ue(null)})},30),E(i)){const h=i.anchor.getNode();h.markDirty(),M(h)||O(142),Ka(i,h)}}else{ue(null),n.preventDefault();const h=i.anchor.getNode(),m=h.getTextContent(),g=h.canInsertTextAfter(),y=i.anchor.offset===0&&i.focus.offset===m.length;let p=Ji&&f&&!y&&g;if(p&&i.isCollapsed()&&(p=!J(ms(i.anchor,!0))),!p){F(r,Et,!0);const _=D();Ji&&E(_)&&_.isCollapsed()&&(Tt=_,setTimeout(()=>Tt=null))}}return!0}}var s;if(!E(i))return!0;const o=n.data;en!==null&&Js(!1,r,en),i.dirty&&en===null||!i.isCollapsed()||ie(i.anch
1or.getNode())||e===null||i.applyDOMRange(e),en=null;const l=i.anchor,a=i.focus,c=l.getNode(),d=a.getNode();if(t==="insertText"||t==="insertTranspose"){if(o==="\n")n.preventDefault(),F(r,on,!1);else if(o===ii)n.preventDefault(),F(r,Hn,void 0);else if(o==null&&n.dataTransfer){const f=n.dataTransfer.getData("text/plain");n.preventDefault(),i.insertRawText(f)}else o!=null&&za(i,e,o,n.timeStamp,!0)?(n.preventDefault(),F(r,ln,o)):en=o;return Ra=n.timeStamp,!0}switch(n.preventDefault(),t){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":F(r,ln,n);break;case"insertFromComposition":ue(null),F(r,ln,n);break;case"insertLineBreak":ue(null),F(r,on,!1);break;case"insertParagraph":ue(null),In&&!er?(In=!1,F(r,on,!1)):F(r,Hn,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":F(r,oi,n);break;case"deleteByComposition":(function(f,h){return f!==h||C(f)||C(h)||!Ot(f)||!Ot(h)})(c,d)&&F(r,Nr,n);break;case"deleteByDrag":gi(cs),F(r,Nr,n);break;case"deleteByCut":F(r,Nr,n);break;case"deleteContent":F(r,Et,!1);break;case"deleteWordBackward":F(r,Yn,!0);break;
1case"deleteWordForward":F(r,Yn,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":F(r,Gn,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":F(r,Gn,!1);break;case"formatStrikeThrough":F(r,Ne,"strikethrough");break;case"formatBold":F(r,Ne,"bold");break;case"formatItalic":F(r,Ne,"italic");break;case"formatUnderline":F(r,Ne,"underline");break;case"historyUndo":F(r,li,void 0);break;case"historyRedo":F(r,ai,void 0)}return!0}function Gd(n){if(te(n.target)&&hc(n.target))return!0;const t=G(),e=D(),r=n.data,i=Wa(n);if(r!=null&&E(e)&&za(e,i,r,n.timeStamp,!1)){$n&&(Br(t,r),$n=!1);const s=e.anchor.getNode(),o=Ee(Ce(t));if(o===null)return!0;const l=e.isBackward(),a=l?e.anchor.offset:e.focus.offset,c=l?e.focus.offset:e.anchor.offset;Pr&&!e.isCollapsed()&&M(s)&&o.anchorNode!==null&&s.getTextContent().slice(0,a)+r+s.getTextContent().slice(a+c)===Cc(o.anchorNode)||F(t,ln,r);const d=r.length;ht&&d>1&&n.inputType==="insertCompositionText"&&!t.isComposing()&&(e.anchor.offset-=d),Ji&&t.isComposing()&&(Qn=0,ue(null))}else Js(!1,t,r!==null?r:void 0),$n&&(Br(t,r||void 0),$n=!1);return function(){ge();const s=G();ua(s)}(),!0}function Qd(n){const t=G(),e=D();if(E(e)&&!t.isComposing()){const r=e.anchor,i=e.anchor.getNode();ue(r.key),gi(qa),(n.timeStamp<Qn+30||r.type==="element"||!e.isCollapsed()||i.getFormat()!==e.format||M(i)&&i.getStyle()!==e.style)&&F(t,ln,js)}return!0}function Xd(n){return Br(G(),n.data),gi(Ha),!0}function Br(n,t){const e=n._compositionKey;if(ue(null),e!==null&&t!=null){if(t===""){const r=ne(e),i=hn(n.getElementByKey(e));if(i!==null&&i.nodeValue!==null&&M(r)){const s=Ee(Ce(n));let o=null,l=null;s!==null&&s.anchorNode===i&&(o=s.anchorOffset,l=s.focusOffset),Vs(r,i.nodeValue,o,l,!0)}return}if(t[t.length-1]==="\n"){const r=D();if(E(r)||he(r)){if(E(r)){const i=r.focus;r.anchor.set(i.key,i.offset,i.type)}return void F(n,Ir,null)}}}Js(!0,n,t)}function Zd(n){const t=G();if(n.key==null)return!0;if(kr){if(tl(n))return ze(t,()=>{Br(t,wr)}),kr=!1,wr="",!0;kr=!1,wr=""}if(function(e){return H(e,"ArrowRight",{shiftKey:"any"})}(n))F(t,ka,n);else if(function(e){return H(e,"ArrowRight",Ge)}(n))F(t,Bd,n);else if(function(e){return H(e,"ArrowLeft",{shiftKey:"any"})}(n))F(t,wa,n);else if(function(e){return H(e,"ArrowLeft",Ge)}(n))F(t,zd,n);else if(function(e){return H(e,"ArrowUp",{altKey:"any",shiftKey:"any"})}(n))F(t,Ta,n);else if(function(e){return H(e,"ArrowDown",{altKey:"any",shiftKey:"any"})}(n))F(t,Ea,n);else if(function(e){return H(e,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any",shiftKey:!0})}(n))In=!0,F(t,Ir,n);else if(function(e){return e.key===" "}(n))F(t,ja,n);else if(function(e){return Oe&&H(e,"o",{ctrlKey:!0})}(n))n.preventDefault(),In=!0,F(t,on,!0);else if(function(e){return H(e,"Enter",{altKey:"any",ctrlKey:"any",metaKey:"any"})}(n))In=!1,F(t,Ir,n);else if(function(e){return H(e,"Backspace",{shiftKey:"any"})||Oe&&H(e,"h",{ctrlKey:!0})}(n))tl(n)?F(t,Oa,n):(n.preventDefault(),F(t,Et,!0));else if(function(e){return e.key==="Escape"}(n))F(t,Ma,n);else if(function(e){return H(e,"Delete",{})||Oe&&H(e,"d",{ctrlKey:!0})}(n))(function(e){return e.key==="Delete"})(n)?F(t,Aa,n):(n.preventDefault(),F(t,Et,!1));else if(function(e){return H(e,"Backspace",el)}(n))n.preventDefault(),F(t,Yn,!0);else if(function(e){return H(e,"Delete",el)}(n))n.preventDefault(),F(t,Yn,!1);else if(function(e){return Oe&&H(e,"Backspace",{metaKey:!0})}(n))n.preventDefault(),F(t,Gn,!0);else if(function(e){return Oe&&(H(e,"Delete",{metaKey:!0})||H(e,"k",{ctrlKey:!0}))}(n))n.preventDefault(),F(t,Gn,!1);else if(function(e){return H(e,"b",Ge)}(n))n.preventDefault(),F(t,Ne,"bold");else if(function(e){return H(e,"u",Ge)}(n))n.preventDefault(),F(t,Ne,"underline");else if(function(e){return H(e,"i",Ge)}(n))n.preventDefault(),F(t,Ne,"italic");else if(function(e){return H(e,"Tab",{shiftKey:"any"})}(n))F(t,Da,n);else if(function(e){return H(e,"z",Ge)}(n))n.preventDefault(),F(t,li,void 0);else if(function(e){return Oe?H(e,"z",{metaKey:!0,shiftKey:!0}):H(e,"y",{ctrlKey:!0})||H(e,"z",{ctrlKey:!0,shiftKey:!0})}(n))n.preventDefault(),F(t,ai,void 0);else{const e=t._editorState._selection;e===null||E(e)?nl(n)&&(n.preventDefault(),F(t,ns,n)):function(r){return H(r,"c",Ge)}(n)?(n.preventDefault(),F(t,ci,n)):function(r){return H(r,"x",Ge)}(n)?(n.preventDefault(),F(t,As,n)):nl(n)&&(n.preventDefault(),F(t,ns,n))}return function(e){return e.ctrlKey||e.shiftKey||e.altKey||e.metaKey}(n)&&t.dispatchCommand(Hd,n),!0}function Ua(n){let t=n.__lexicalEventHandles;return t===void 0&&(t=[],n.__lexicalEventHandles=t),t}const an=new Map;function Ja(n){const t=Df(n.target);if(t===null)return;const e=gc(t.anchorNode);
1if(e===null)return;os&&(os=!1,ze(e,()=>{const a=_n(),c=t.anchorNode;(te(c)||st(c))&&me(Fs(a,t,e,n))}));const r=Us(e),i=r[r.length-1],s=i._key,o=an.get(s),l=o||i;l!==e&&To(t,l,!1),To(t,e,!0),e!==i?an.set(s,e):o&&an.delete(s)}function Eo(n){n._lexicalHandled=!0}function jo(n){return n._lexicalHandled===!0}function ef(n){const t=is.get(n);if(t===void 0)return;const e=Rr.get(t);if(e===void 0)return;const r=e-1;r>=0||O(164),is.delete(n),Rr.set(t,r),r===0&&t.removeEventListener("selectionchange",Ja);const i=fi(n);Ws(i)?(function(o){if(o._parentEditor!==null){const l=Us(o),a=l[l.length-1]._key;an.get(a)===o&&an.delete(a)}else an.delete(o._key)}(i),n.__lexicalEditor=null):i&&O(198);const s=Ua(n);for(let o=0;o<s.length;o++)s[o]();n.__lexicalEventHandles=[]}function ls(n,t,e){ge();const r=n.__key,i=n.getParent();if(i===null)return;const s=function(l){const a=D();if(!E(a)||!C(l))return a;const{anchor:c,focus:d}=a,f=c.getNode(),h=d.getNode();return ps(f,l)&&c.set(l.__key,0,"element"),ps(h,l)&&d.set(l.__key,0,"element"),a}(n);let o=!1;if(E(s)&&t){const l=s.anchor,a=s.focus;l.key===r&&(Wr(l,n,i,n.getPreviousSibling(),n.getNextSibling()),o=!0),a.key===r&&(Wr(a,n,i,n.getPreviousSibling(),n.getNextSibling()),o=!0)}else he(s)&&t&&n.isSelected()&&n.selectPrevious();if(E(s)&&t&&!o){const l=n.getIndexWithinParent();Mt(n),Kr(s,i,l,-1)}else Mt(n);e||_e(i)||i.canBeEmpty()||!i.isEmpty()||ls(i,t),t&&s&&ie(i)&&i.isEmpty()&&i.selectEnd()}const Va=Symbol.for("ephemeral");function zr(n){return n[Va]||!1}class ke{constructor(t){w(this,"__type");w(this,"__key");w(this,"__parent");w(this,"__prev");w(this,"__next");w(this,"__state");this.__type=this.constructor.getType(),this.__parent=null,this.__prev=null,this.__next=null,Object.defineProperty(this,"__state",{configurable:!0,enumerable:!1,value:void 0,writable:!0}),pc(this,t)}static getType(){const{ownNodeType:t}=vn(this);return t===void 0&&O(64,this.name),t}static clone(t){O(65,this.name)}$config(){return{}}config(t,e){const r=e.extends||Object.getPrototypeOf(this.constructor);return Object.assign(e,{extends:r,type:t}),{[t]:e}}afterCloneFrom(t){this.__key===t.__key?(this.__parent=t.__parent,this.__next=t.__next,this.__prev=t.__prev,this.__state=t.__state):t.__state&&(this.__state=t.__state.getWritable(this))}resetOnCopyNodeFrom(t){this.__state&&(this.__state=this.__state.getWritable(this).resetOnCopyNode())}getType(){return this.__type}isInline(){O(137,this.constructor.name)}isAttached(){let t=this.__key;for(;t!==null;){if(t==="root")return!0;const e=ne(t);if(e===null)break;t=e.__parent}return!1}isSelected(t){const e=t||D();if(e==null)return!1;const r=e.getNodes().some(i=>i.__key===this.__key);if(M(this))return r;if(E(e)&&e.anchor.type==="element"&&e.focus.type==="element"){if(e.isCollapsed())return!1;const i=this.getParent();if(J(this)&&this.isInline()&&i){const s=e.isBackward()?e.focus:e.anchor;if(i.is(s.getNode())&&s.offset===i.getChildrenSize()&&this.is(i.getLastChild()))return!1}}return r}getKey(){return this.__key}getIndexWithinParent(){const t=this.getParent();if(t===null)return-1;let e=t.getFirstChild(),r=0;for(;e!==null;){if(this.is(e))return r;r++,e=e.getNextSibling()}return-1}getParent(){const t=this.getLatest().__parent;return t===null?null:ne(t)}getParentOrThrow(){const t=this.getParent();return t===null&&O(66,this.__key),t}getTopLevelElement(){let t=this;for(;t!==null;){const e=t.getParent();if(_e(e))return C(t)||t===this&&J(t)||O(194),t;t=e}return null}getTopLevelElementOrThrow(){const t=this.getTopLevelElement();return t===null&&O(67,this.__key),t}getParents(){const t=[];let e=this.getParent();for(;e!==null;)t.push(e),e=e.getParent();return t}getParentKeys(){const t=[];let e=this.getParent();for(;e!==null;)t.push(e.__key),e=e.getParent();return t}getPreviousSibling(){const t=this.getLatest().__prev;return t===null?null:ne(t)}getPreviousSiblings(){const t=[],e=this.getParent();if(e===null)return t;let r=e.getFirstChild();for(;r!==null&&!r.is(this);)t.push(r),r=r.getNextSibling();return t}getNextSibling(){const t=this.getLatest().__next;return t===null?null:ne(t)}getNextSiblings(){const t=[];let e=this.getNextSibling();for(;e!==null;)t.push(e),e=e.getNextSibling();return t}getCommonAncestor(t){const e=C(this)?this:this.getParent(),r=C(t)?t:t.getParent(),i=e&&r?jr(e,r):null;return i?i.commonAncestor:null}is(t){return t!=null&&this.__key===t.__key}isBefore(t){const e=jr(this,t);return e!==null&&(e.type==="descendant"||(e.type==="branch"?jc(e)===-1:(e.type!=="same"&&e.type!=="ancestor"&&O(279),!1)))}isParentOf(t){const e=jr(this,t);return e!==null&&e.type==="ancestor"}getNodesBetween(t){const e=this.isBefore(t),r=[],i=new Set;let s=this;for(;s!==null;){const o=s.__key;
1if(i.has(o)||(i.add(o),r.push(s)),s===t)break;const l=C(s)?e?s.getFirstChild():s.getLastChild():null;if(l!==null){s=l;continue}const a=e?s.getNextSibling():s.getPreviousSibling();if(a!==null){s=a;continue}const c=s.getParentOrThrow();if(i.has(c.__key)||r.push(c),c===t)break;let d=null,f=c;do{if(f===null&&O(68),d=e?f.getNextSibling():f.getPreviousSibling(),f=f.getParent(),f===null)break;d!==null||i.has(f.__key)||r.push(f)}while(d===null);s=d}return e||r.reverse(),r}isDirty(){const t=G()._dirtyLeaves;return t!==null&&t.has(this.__key)}getLatest(){if(zr(this))return this;const t=ne(this.__key);return t===null&&O(113),t}getWritable(){if(zr(this))return this;ge();const t=vt(),e=G(),r=t._nodeMap,i=this.__key,s=this.getLatest(),o=e._cloneNotNeeded,l=D();if(l!==null&&l.setCachedNodes(null),o.has(i))return Jr(s),s;const a=wc(s);return o.add(i),Jr(a),r.set(i,a),a}getTextContent(){return""}getTextContentSize(){return this.getTextContent().length}createDOM(t,e){O(70)}updateDOM(t,e,r){O(71)}exportDOM(t){return{element:this.createDOM(t._config,t)}}exportJSON(){const t=this.__state?this.__state.toJSON():void 0;return{type:this.__type,version:1,...t}}static importJSON(t){O(18,this.name)}updateFromJSON(t){return function(e,r){const i=e.getWritable(),s=r.$;let o=s;for(const l of ga(i).flatKeys)l in r&&(o!==void 0&&o!==s||(o={...s}),o[l]=r[l]);return(i.__state||o)&&Pd(e).updateFromJSON(o),i}(this,t)}static transform(){return null}remove(t){ls(this,!0,t)}replace(t,e){ge();let r=D();r!==null&&(r=r.clone()),Mi(this,t);const i=this.getLatest(),s=this.__key,o=t.__key,l=t.getWritable(),a=this.getParentOrThrow().getWritable(),c=a.__size;Mt(l);const d=i.getPreviousSibling(),f=i.getNextSibling(),h=i.__prev,m=i.__next,g=i.__parent;if(ls(i,!1,!0),d===null?a.__first=o:d.getWritable().__next=o,l.__prev=h,f===null?a.__last=o:f.getWritable().__prev=o,l.__next=m,l.__parent=g,a.__size=c,e&&(C(this)&&C(l)||O(139),this.getChildren().forEac
1h(y=>{l.append(y)})),E(r)){me(r);const y=r.anchor,p=r.focus;y.key===s&&Po(y,l),p.key===s&&Po(p,l)}return ut()===s&&ue(o),l}insertAfter(t,e=!0){ge(),Mi(this,t);const r=this.getWritable(),i=t.getWritable(),s=i.getParent(),o=D();let l=!1,a=!1;if(s!==null){const m=t.getIndexWithinParent();if(Mt(i),E(o)){const g=s.__key,y=o.anchor,p=o.focus;l=y.type==="element"&&y.key===g&&y.offset===m+1,a=p.type==="element"&&p.key===g&&p.offset===m+1}}const c=this.getNextSibling(),d=this.getParentOrThrow().getWritable(),f=i.__key,h=r.__next;if(c===null?d.__last=f:c.getWritable().__prev=f,d.__size++,r.__next=f,i.__next=h,i.__prev=r.__key,i.__parent=r.__parent,e&&E(o)){const m=this.getIndexWithinParent();Kr(o,d,m+1);const g=d.__key;l&&o.anchor.set(g,m+2,"element"),a&&o.focus.set(g,m+2,"element")}return t}insertBefore(t,e=!0){ge(),Mi(this,t);const r=this.getWritable(),i=t.getWritable(),s=i.__key;Mt(i);const o=this.getPreviousSibling(),l=this.getParentOrThrow().getWritable(),a=r.__prev,c=this.getIndexWithinParent();o===null?l.__first=s:o.getWritable().__next=s,l.__size++,r.__prev=s,i.__prev=a,i.__next=r.__key,i.__parent=r.__parent;const d=D();return e&&E(d)&&Kr(d,this.getParentOrThrow(),c),t}isParentRequired(){return!1}createParentElementNode(){return Q()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(t,e){ge();const r=this.getPreviousSibling(),i=this.getParentOrThrow();if(r===null)return i.select(0,0);if(C(r))return r.select();if(!M(r)){const s=r.getIndexWithinParent()+1;return i.select(s,s)}return r.select(t,e)}selectNext(t,e){ge();const r=this.getNextSibling(),i=this.getParentOrThrow();if(r===null)return i.select();if(C(r))return r.select(0,0);if(!M(r)){const s=r.getIndexWithinParent();return i.select(s,s)}return r.select(t,e)}markDirty(){this.getWritable()}reconcileObservedMutation(t,e){this.markDirty()}}w(ke,"importDOM");function ki(n){return n instanceof ke}const as="historic",tf="history-push",jt="history-merge",nf="paste",rf="collaboration",sf="skip-scroll-into-view",of="skip-dom-selection",cs="skip-selection-focus",qa="composition-start",Ha="composition-end",Oo=/\s*!important\s*$/i;function $t(n){const t={};if(!n)return t;let e="",r="",i=null,s=!1,o=!1,l=!1,a=0;for(let f=0;f<n.length;f++){const h=n[f];if(s)h==="*"&&n[f+1]==="/"&&(s=!1,f++);else if(o)l?r+=h:e+=h,o=!1;else if(i===null)if(h!=="/"||n[f+1]!=="*")if(h!=='"'&&h!=="'")if(h!=="(")if(h!==")")if(l||h!==":"||a!==0){if(h===";"&&a===0){const m=e.trim(),g=r.trim();m!==""&&g!==""&&(t[m]=g),e="",r="",l=!1;continue}l?r+=h:e+=h}else l=!0;else a=Math.max(0,a-1),l?r+=h:e+=h;else a++,l?r+=h:e+=h;else i=h,l?r+=h:e+=h;else s=!0,f++;else l?r+=h:e+=h,h==="\\"?o=!0:h===i&&(i=null)}const c=e.trim(),d=r.trim();return c!==""&&d!==""&&(t[c]=d),t}function lf(n,t,e){const r=Oo.test(e)?"important":"",i=r===""?e:e.replace(Oo,"").trim();n.setProperty(t,i,r)}function us(n,t,e=""){if(t===e)return;const r=$t(e),i=$t(t);for(const s in i)delete r[s],lf(n,s,i[s]);for(const s in r)n.removeProperty(s)}class mn extends ke{static getType(){return"linebreak"}static clone(t){return new mn(t.__key)}constructor(t){super(t)}getTextContent(){return"\n"}createDOM(){return document.createElement("br")}updateDOM(){return!1}isInline(){return!0}static importDOM(){return{br:t=>function(e){const r=e.parentElement;if(r!==null&&Vr(r)){const i=r.firstChild;if(i===e||i.nextSibling===e&&fr(i)){const s=r.lastChild;if(s===e||s.previousSibling===e&&fr(s))return!0}}return!1}(t)||function(e){const r=e.parentElement;if(r!==null&&Vr(r)){const i=r.firstChild;if(i===e||i.nextSibling===e&&fr(i))return!1;const s=r.lastChild;if(s===e||s.previousSibling===e&&fr(s))return!0}return!1}(t)?null:{conversion:af,priority:0}}}static importJSON(t){return Lt().updateFromJSON(t)}}function af(n){return{node:Lt()}}function Lt(){return Ve(new mn)}function cn(n){return n instanceof mn}function fr(n){return st(n)&&/^( |\t|\r?\n)+$/.test(n.textContent||"")}function wi(n,t){return 16&t?"code":t&la?"mark":32&t?"sub":64&t?"sup":null}function Ti(n,t){return 1&t?"strong":2&t?"em":"span"}function Ya(n,t,e,r,i){const s=r.classList;let o=un(i,"base");o!==void 0&&s.add(...o),o=un(i,"underlineStrikethrough");let l=!1;const a=8&t&&4&t;o!==void 0&&(8&e&&4&e?(l=!0,a||s.add(...o)):a&&s.remove(...o));for(const c in Dt){const d=Dt[c];if(o=un(i,c),o!==void 0)if(e&d){if(l&&(c==="underline"||c==="str
1ikethrough")){t&d&&s.remove(...o);continue}((t&d)===0||a&&c==="underline"||c==="strikethrough")&&s.add(...o)}else t&d&&s.remove(...o)}}function Ga(n,t,e){const r=t.firstChild,i=e.isComposing(),s=n+(i?Un:"");if(r==null)t.textContent=s;else{const o=r.nodeValue;if(o!==s)if(i||ht){const[l,a,c]=function(d,f){const h=d.length,m=f.length;let g=0,y=0;for(;g<h&&g<m&&d[g]===f[g];)g++;for(;y+g<h&&y+g<m&&d[h-y-1]===f[m-y-1];)y++;return[g,h-g-y,f.slice(g,m-y)]}(o,s);a!==0&&r.deleteData(l,a),r.insertData(l,c)}else r.nodeValue=s}}function Mo(n,t,e,r,i,s){Ga(i,n,t);const o=s.theme.text;o!==void 0&&Ya(0,0,r,n,o)}function hr(n,t){const e=document.createElement(t);return e.appendChild(n),e}class xt extends ke{constructor(e="",r){super(r);w(this,"__text");w(this,"__format");w(this,"__style");w(this,"__mode");w(this,"__detail");this.__text=e,this.__format=0,this.__style="",this.__mode=0,this.__detail=0}static getType(){return"text"}static clone(e){return new xt(e.__text,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__text=e.__text,this.__format=e.__format,this.__style=e.__style,this.__mode=e.__mode,this.__detail=e.__detail}getFormat(){return this.getLatest().__format}getDetail(){return this.getLatest().__detail}getMode(){const e=this.getLatest();return wd[e.__mode]}getStyle(){return this.getLatest().__style}isToken(){return this.getLatest().__mode===1}isComposing(){return this.__key===ut()}isSegmented(){return this.getLatest().__mode===2}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(e){const r=Dt[e];return(this.getFormat()&r)!==0}isSimpleText(){return this.__type==="text"&&this.__mode===0}getTextContent(){return this.getLatest().__text}getFormatFlags(e,r){return Ur(this.getLatest().__format,e,r)}canHaveFormat(){return!0}isInline(){return!0}createDOM(e,r){const i=this.__format,s=wi(0,i),o=Ti(0,i),l=s===null?o:s,a=document.createElement(l);let c=a;this.hasFormat("code")&&a.setAttribute("spellcheck","false"),s!==null&&(c=document.createElement(o),a.appendChild(c)),Mo(c,this,0,i,this.__text,e);const d=this.__style;return d!==""&&us(a.style,d),a}updateDOM(e,r,i){const s=this.__text,o=e.__format,l=this.__format,a=wi(0,o),c=wi(0,l),d=Ti(0,o),f=Ti(0,l);if((a===null?d:a)!==(c===null?f:c))return!0;if(a===c&&d!==f){const p=r.firstChild;p==null&&O(48);const _=document.createElement(f);return Mo(_,this,0,l,s,i),r.replaceChild(_,p),!1}let h=r;c!==null&&a!==null&&(h=r.firstChild,h==null&&O(49)),Ga(s,h,this);const m=i.theme.text;m!==void 0&&o!==l&&Ya(0,o,l,h,m);const g=e.__style,y=this.__style;return g!==y&&us(r.style,y,g),!1}static importDOM(){return{"#text":()=>({conversion:ff,priority:0}),b:()=>({conversion:uf,priority:0}),code:()=>({conversion:Ye,priority:0}),em:()=>({conversion:Ye,priority:0}),i:()=>({conversion:Ye,priority:0}),mark:()=>({conversion:Ye,priority:0}),s:()=>({conversion:Ye,priority:0}),span:()=>({conversion:cf,priority:0}),strong:()=>({conversion:Ye,priority:0}),sub:()=>({conversion:Ye,priority:0}),sup:()=>({conversion:Ye,priority:0}),u:()=>({conversion:Ye,priority:0})}}static importJSON(e){return se().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setTextContent(e.text).setFormat(e.format).setDetail(e.detail).setMode(e.mode).setStyle(e.style)}
1exportDOM(e){let{element:r}=super.exportDOM(e);return te(r)||O(132),r.style.whiteSpace="pre-wrap",this.hasFormat("lowercase")?r.style.textTransform="lowercase":this.hasFormat("uppercase")?r.style.textTransform="uppercase":this.hasFormat("capitalize")&&(r.style.textTransform="capitalize"),this.hasFormat("bold")&&(r=hr(r,"b")),this.hasFormat("italic")&&(r=hr(r,"i")),this.hasFormat("strikethrough")&&(r=hr(r,"s")),this.hasFormat("underline")&&(r=hr(r,"u")),{element:r}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),...super.exportJSON()}}selectionTransform(e,r){}setFormat(e){const r=this.getWritable();return r.__format=typeof e=="string"?Dt[e]:e,r}setDetail(e){const r=this.getWritable();return r.__detail=typeof e=="string"?Sd[e]:e,r}setStyle(e){const r=this.getWritable();return r.__style=e,r}toggleFormat(e){const r=Ur(this.getFormat(),e,null);return this.setFormat(r)}toggleDirectionless(){const e=this.getWritable();return e.__detail^=1,e}toggleUnmergeable(){const e=this.getWritable();return e.__detail^=2,e}setMode(e){const r=kd[e];if(this.__mode===r)return this;const i=this.getWritable();return i.__mode=r,i}setTextContent(e){if(this.__text===e)return this;const r=this.getWritable();return r.__text=e,r}select(e,r){ge();let i=e,s=r;const o=D(),l=this.getTextContent(),a=this.__key;if(typeof l=="string"){const c=l.length;i===void 0&&(i=c),s===void 0&&(s=c)}else i=0,s=0;if(!E(o))return ec(a,i,a,s,"text","text");{const c=ut();c!==o.anchor.key&&c!==o.focus.key||ue(a),o.setTextNodeRange(this,i,this,s)}return o}selectStart(){return this.select(0,0)}selectEnd(){const e=this.getTextContentSize();return this.select(e,e)}spliceText(e,r,i,s){const o=this.getWritable(),l=o.__text,a=i.length;let c=e;c<0&&(c=a+c,c<0&&(c=0));const d=D();if(s&&E(d)){const h=e+a;d.setTextNodeRange(o,h,o,h)}const f=l.slice(0,c)+i+l.slice(c+r);return o.__text=f,o}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...e){ge();const r=this.getLatest(),i=r.getTextContent();if(i==="")return[];const s=r.__key,o=ut(),l=i.length;e.sort((T,A)=>T-A),e.push(l);const a=[],c=e.length;for(let T=0,A=0;T<l&&A<=c;A++){const $=e[A];$>T&&(a.push(i.slice(T,$)),T=$)}const d=a.length;if(d===1)return[r];const f=a[0],h=r.getParent();let m;const g=r.getFormat(),y=r.getStyle(),p=r.__detail;let _=!1,x=null,b=null;const N=D();if(E(N)){const[T,A]=N.isBackward()?[N.focus,N.anchor]:[N.anchor,N.focus];T.type==="text"&&T.key===s&&(x=T),A.type==="text"&&A.key===s&&(b=A)}r.isSegmented()?(m=se(f),m.__format=g,m.__style=y,m.__detail=p,m.__state=xo(r,m),_=!0):m=r.setTextContent(f);const j=[m];for(let T=1;T<d;T++){const A=se(a[T]);A.__format=g,A.__style=y,A.__detail=p,A.__state=xo(r,A);const $=A.__key;o===s&&ue($),j.push(A)}const v=x?x.offset:null,k=b?b.offset:null;let S=0;for(const T of j){if(!x&&!b)break;const A=S+T.getTextContentSize();if(x!==null&&v!==null&&v<=A&&v>=S&&(x.set(T.getKey(),v-S,"text"),v<A&&(x=null)),b!==null&&k!==null&&k<=A&&k>=S){b.set(T.getKey(),k-S,"text");break}S=A}if(h!==null){(function($){const z=$.getPreviousSibling(),R=$.getNextSibling();z!==null&&Jr(z),R!==null&&Jr(R)})(this);const T=h.getWritable(),A=this.getIndexWithinParent();_?(T.splice(A,0,j),this.remove()):T.splice(A,1,j),E(N)&&Kr(N,h,A,d-1)}return j}mergeWithSibling(e){const r=e===this.getPreviousSibling();r||e===this.getNextSibling()||O(50);const i=this.__key,s=e.__key,o=this.__text,l=o.length;ut()===s&&ue(i);const a=D();if(E(a)){const h=a.anchor,m=a.focus;h!==null&&h.key===s&&zo(h,r,i,e,l),m!==null&&m.key===s&&zo(m,r,i,e,l)}const c=e.__text,d=r?c+o:o+c;this.setTextContent(d);const f=this.getWritable();return e.remove(),f}isTextEntity(){return!1}}function cf(n){return{forChild:Ds(n.style),node:null}}function uf(n){const t=n,e=t.style.fontWeight==="normal";return{forChild:Ds(t.style,e?void 0:"bold"),node:null}}const Ao=new WeakMap;function df(n){if(!te(n))return!1;if(n.nodeName==="PRE")return!0;const t=n.style.whiteSpace;return typeof t=="string"&&t.startsWith("pre")}function ff(n){const t=n;n.parentElement===null&&O(129);let e=t.textContent||"";if(function(r){let i,s=r.parentNode;const o=[r];for(;s!==null&&(i=Ao.get(s))===void 0&&!df(s);)o.push(s),s=s.parentNode;const l=i===void 0?s:i;for(let a=0;a<o.length;a++)Ao.set(o[a],l);return l}(t)!==null){const r=e.split(/(\r?\n|\t)/),i=[],s=r.length;for(let o=0;o<s;
1o++){const l=r[o];l==="\n"||l==="\r\n"?i.push(Lt()):l==="	"?i.push(tr()):l!==""&&i.push(se(l))}return{node:i}}if(e=e.replace(/\r/g,"").replace(/[ \t\n]+/g," "),e==="")return{node:null};if(e[0]===" "){let r=t,i=!0;for(;r!==null&&(r=Do(r,!1))!==null;){const s=r.textContent||"";if(s.length>0){/[ \t\n]$/.test(s)&&(e=e.slice(1)),i=!1;break}}i&&(e=e.slice(1))}if(e[e.length-1]===" "){let r=t,i=!0;for(;r!==null&&(r=Do(r,!0))!==null;)if((r.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){i=!1;break}i&&(e=e.slice(0,e.length-1))}return e===""?{node:null}:{node:se(e)}}function Do(n,t){let e=n;for(;;){let r;for(;(r=t?e.nextSibling:e.previousSibling)===null;){const s=e.parentElement;if(s===null)return null;e=s}if(e=r,te(e)){const s=e.style.display;if(s===""&&!xs(e)||s!==""&&!s.startsWith("inline"))return null}let i=e;for(;(i=t?e.firstChild:e.lastChild)!==null;)e=i;if(st(e))return e;if(e.nodeName==="BR")return null}}const hf={code:"code",em:"italic",i:"italic",mark:"highlight",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function Ye(n){const t=hf[n.nodeName.toLowerCase()];return t===void 0?{node:null}:{forChild:Ds(n.style,t),node:null}}function se(n=""){return Ve(new xt(n))}function M(n){return n instanceof xt}function Ds(n,t){const e=n.fontWeight,r=n.textDecoration.split(" "),i=e==="700"||e==="bold",s=r.includes("line-through"),o=n.fontStyle==="italic",l=r.includes("underline"),a=n.verticalAlign;return c=>(M(c)&&(i&&!c.hasFormat("bold")&&c.toggleFormat("bold"),s&&!c.hasFormat("strikethrough")&&c.toggleFormat("strikethrough"),o&&!c.hasFormat("italic")&&c.toggleFormat("italic"),l&&!c.hasFormat("underline")&&c.toggleFormat("underline"),a!=="sub"||c.hasFormat("subscript")||c.toggleFormat("subscript"),a!=="super"||c.hasFormat("superscript")||c.toggleFormat("superscript"),t&&!c.hasFormat(t)&&c.toggleFormat(t)),c)}class pn extends xt{static getType(){return"tab"}static clone(t){return new pn(t.__key)}constructor(t){super("	",t),this.__detail=2}static importDOM(){return null}createDOM(t){const e=super.createDOM(t),r=un(t.theme,"tab");return r!==void 0&&e.classList.add(...r),e}static importJSON(t){return tr().updateFromJSON(t)}setTextContent(t){return t!=="	"&&t!==""&&ia(126),super.setTextContent("	")}spliceText(t,e,r,i){return r===""&&e===0||r==="	"&&e===1||O(286),this}setDetail(t){return t!==2&&O(127),this}setMode(t){return t!=="normal"&&O(128),this}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function tr(){return Ve(new pn)}function Qa(n){return n instanceof pn}class gf{constructor(t,e,r){w(this,"key");w(this,"offset");w(this,"type");w(this,"_selection");this._selection=null,this.key=t,this.offset=e,this.type=r}is(t){return this.key===t.key&&this.offset===t.offset&&this.type===t.type}isBefore(t){return this.key===t.key?this.offset<t.offset:Hr(xe(Ue(this,"next")),xe(Ue(t,"next")))<0}getNode(){const t=ne(this.key);return t===null&&O(20),t}set(t,e,r,i){const s=this._selection,o=this.key;i&&this.key===t&&this.offset===e&&this.type===r||(this.key=t,this.offset=e,this.type=r,nr()||(ut()===o&&ue(t),s!==null&&(s.setCachedNodes(null),s.dirty=!0)))}}function We(n,t,e){return new gf(n,t,e)}function Ei(n,t){let e=t.__key,r=n.offset,i="element";if(M(t)){i="text";const s=t.getTextContentSize();r>s&&(r=s)}else if(!C(t)){const s=t.getNextSibling();if(M(s))e=s.__key,r=0,i="text";else{const o=t.getParent();o&&(e=o.__key,r=t.getIndexWithinParent()+1)}}n.set(e,r,i)}function Po(n,t){if(C(t)){const e=t.getLastDescendant();C(e)||M(e)?Ei(n,e):Ei(n,t)}else Ei(n,t)}class ui{constructor(t){w(this,"_nodes");w(this,"_cachedNodes");w(this,"dirty");this._cachedNodes=null,this._nodes=t,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){if(!he(t))return!1;const e=this._nodes,r=t._nodes;return e.size===r.size&&Array.from(e).every(i=>r.has(i))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(t){this.dirty=!0,this._nodes.add(t),this._cachedNodes=null}delete(t){this.dirty=!0,this._nodes.delete(t),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(t){return this._nodes.has(t)}clone(){return new ui(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(t){}insertText(){}insertNodes(t){const e=this.getNodes(),r=e.length,i=e[r-1];let s;if(M(i))s=i.select();else{const o=i.getIndexWithinParent()+1;s=i.getParentOrThrow().select(o,o)}s.insertNodes(t);for(let o=0;o<r;o++)e[o].remove()}getNodes(){const t=this._cachedNodes;if(t!==null)return t;const e=this._nodes,r=[];for(const i of e){const s=ne(i);s!==null&&r.push(s)}return nr()||(this._cachedNodes=r),r}getTextContent(){const t=this.getNodes();let e="";for(let r=0;r<t.length;r++)e+=t[r].getTextContent();return e}deleteNodes(){const t=this.getNodes();if((D()||_n())===this&&t[0]){const e=Z(t[0],"next");Oc(pt(e,e))}for(const e of t)e.remove()}}function E(n){return n instanceof Ut}class Ut{constructor(t,e,r,i){w(this,"format");w(this,"style");w(this,"anchor");w(this,"focus");w(this,"_cachedNodes");w(this,"dirty");this.anchor=t,this.focus=e,t._selection=this,e._selection=this,this._cachedNodes=null,this.format=r,this.style=i,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(t){this._cachedNodes=t}is(t){return!!E(t)&&this.anchor.is(t.anchor)&&this.focus.is(t.focus)&&this.format===t.format&&this.style===t.style}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){const t=this._cachedNodes;if(t!==null)return t;const e=function(r){const i=[],[s,o]=r.getTextSlices();s&&i.push(s.caret.origin);const l=new Set,a=new Set;for(const c of r)if(Pe(c)){const{origin:d}=c;i.length===0?l.add(d):(a.add(d),i.push(d))}else{const{origin:d}=c;C(d)&&a.has(d)||i.push(d)}if(o&&i.push(o.caret.origin),gt(r.focus)&&C(r.focus.origin)&&r.focus.getNodeAtCaret()===null)for(let c=be(r.focus.origin,"previous");Pe(c)&&l.has(c.origin)&&!c.origin.isEmpty()&&c.origin.is(i[i.length-1]);c=Xs(c))l.delete(c.origin),i.pop();for(;i.length>1;){const c=i[i.length-1];if(!C(c)||a.has(c)||c.isEmpty()||l.has(c))break;i.pop()}if(i.length===0&&r.isCollapsed()){const c=xe(r.anchor),d=xe(r.anchor.getFlipped()),f=m=>De(m)?m.origin:m.getNodeAtCaret(),h=f(c)||f(d)||(r.anchor.getNodeAtCaret()?c.origin:d.origin);i.push(h)}return i}(to(Yr(this),"next"));return nr()||(this._cachedNodes=e),e}setTextNodeRange(t,e,r,i){this.anchor.set(t.__key,e,"text"),this.focus.set(r.__key,i,"text")}getTextContent(){const t=this.getNodes();if(t.length===0)return"";const e=t[0],r=t[t.length-1],i=this.anchor,s=this.focus,o=i.isBefore(s),[l,a]=ds(this);let c="",d=!0;for(let f=0;f<t.length;f++){const h=t[f];if(C(h)&&!h.isInline())d||(c+="\n"),d=!h.isEmpty();else if(d=!1,M(h)){let m=h.getTextContent();h===e?h===r?i.type==="element"&&s.type==="element"&&s.offset!==i.offset||(m=l<a?m.slice(l,a):m.slice(a,l)):m=o?m.slice(l):m.slice(a):h===r&&(m=o?m.slice(0,a):m.slice(0,l)),c+=m}else!J(h)&&!cn(h)||h===r&&this.isCollapsed()||(c+=h.getTextContent())}return c}applyDOMRange(t){const e=G(),r=e.getEditorState()._selection,i=Za(t.startContainer,t.startOffset,t.endContainer,t.endOffset,e,r);
1if(i===null)return;const[s,o]=i;this.anchor.set(s.key,s.offset,s.type,!0),this.focus.set(o.key,o.offset,o.type,!0),Pt(this)}clone(){const t=this.anchor,e=this.focus;return new Ut(We(t.key,t.offset,t.type),We(e.key,e.offset,e.type),this.format,this.style)}toggleFormat(t){this.format=Ur(this.format,t,null),this.dirty=!0}setFormat(t){this.format=t,this.dirty=!0}setStyle(t){this.style=t,this.dirty=!0}hasFormat(t){const e=Dt[t];return(this.format&e)!==0}insertRawText(t){const e=t.split(/(\r?\n|\t)/),r=[],i=e.length;for(let s=0;s<i;s++){const o=e[s];o==="\n"||o==="\r\n"?r.push(Lt()):o==="	"?r.push(tr()):r.push(se(o))}this.insertNodes(r)}insertText(t){const e=this.anchor,r=this.focus,i=this.format,s=this.style;let o=e,l=r;!this.isCollapsed()&&r.isBefore(e)&&(o=r,l=e),o.type==="element"&&function(p,_,x,b){const N=p.getNode(),j=N.getChildAtIndex(p.offset),v=se();if(v.setFormat(x),v.setStyle(b),Rs(j))j.splice(0,0,[v]);else{const k=ie(N)?Q().append(v):v;j===null?N.append(k):j.insertBefore(k)}p.is(_)&&_.set(v.__key,0,"text"),p.set(v.__key,0,"text")}(o,l,i,s),l.type==="element"&&_t(l,xe(Ue(l,"next")));const a=o.offset;let c=l.offset;const d=this.getNodes(),f=d.length;let h=d[0];M(h)||O(26);const m=h.getTextContent().length,g=h.getParentOrThrow();let y=d[f-1];if(f===1&&l.type==="element"&&(c=m,l.set(o.key,c,"text")),this.isCollapsed()&&a===m&&(Be(h)||!h.canInsertTextAfter()||!g.canInsertTextAfter()&&h.getNextSibling()===null)){let p=h.getNextSibling();if(M(p)&&p.canInsertTextBefore()&&!Be(p)||(p=se(),p.setFormat(i),p.setStyle(s),g.canInsertTextAfter()?h.insertAfter(p):g.insertAfter(p)),p.select(0,0),h=p,t!=="")return void this.insertText(t)}else if(this.isCollapsed()&&a===0&&(Be(h)||!h.canInsertTextBefore()||!g.canInsertTextBefore()&&h.getPreviousSibling()===null)){let p=h.getPreviousSibling();if(M(p)&&!Be(p)||(p=se(),p.setFormat(i),g.canInsertTextBefore()?h.insertBefore(p):g.insertBefore(p)),p.select(),h=p,t!=="")return void this.insertText(t)}else if(h.isSegmented()&&a!==m){const p=se(h.getTextContent());p.setFormat(i),h.replace(p),h=p}else if(!this.isCollapsed()&&t!==""){const p=y.getParent();if(!g.canInsertTextBefore()||!g.canInsertTextAfter()||C(p)&&(!p.canInsertTextBefore()||!p.canInsertTextAfter()))return this.insertText(""),Xa(this.anchor,this.focus),void this.insertText(t)}if(f===1){if(Ot(h)){const b=se(t);return b.select(),void h.replace(b)}const p=h.getFormat(),_=h.getStyle();if(a!==c||p===i&&_===s){if(Qa(h)){const b=se(t);return b.setFormat(i),b.setStyle(s),b.select(),void h.replace(b)}}else{if(h.getTextContent()!==""){const b=se(t);if(b.setFormat(i),b.setStyle(s),b.select(),a===0)h.insertBefore(b,!1);else{const[N]=h.splitText(a);N.insertAfter(b,!1)}return void(b.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=t.length))}h.setFormat(i),h.setStyle(s)}const x=c-a;h=h.spliceText(a,x,t,!0),h.getTextContent()===""?h.remove():this.anchor.type==="text"&&(this.format=p,this.style=_,h.isComposing()&&(this.anchor.offset-=t.length))}else{const p=new Set([...h.getParentKeys(),...y.getParentKeys()]),_=C(h)?h:h.getParentOrThrow();let x=C(y)?y:y.getParentOrThrow(),b=y;if(!_.is(x)&&x.isInline())do b=x,x=x.getParentOrThrow();while(x.isInline());if(l.type==="text"&&(c!==0||y.getTextContent()==="")||l.type==="element"&&y.getIndexWithinParent()<c)if(M(y)&&!Ot(y)&&c!==y.getTextContentSize()){if(y.isSegmented()){const S=se(y.getTextContent());y.replace(S),y=S}ie(l.getNode())||l.type!=="text"||(y=y.spliceText(0,c,"")),p.add(y.__key)}else{const S=y.getParentOrThrow();S.canBeEmpty()||S.getChildrenSize()!==1?y.remove():S.remove()}else p.add(y.__key);const N=x.getChildren(),j=new Set(d),v=_.is(x),k=_.isInline()&&h.getNextSibling()===null?_:h;for(let S=N.length-1;S>=0;S--){const T=N[S];if(T.is(h)||C(T)&&T.isParentOf(h))break;T.isAttached()&&(!j.has(T)||T.is(b)?v||k.insertAfter(T,!1):T.remove())}if(!v){let S=x,T=null;for(;S!==null;){const A=S.getChildren(),$=A.length;($===0||A[$-1].is(T))&&(p.delete(S.__key),T=S),S=S.getParent()}}if(Ot(h))if(a===m)h.select();else{const S=se(t);S.select(),h.replace(S)}else h=h.spliceText(a,m-a,t,!0),h.getTextContent()===""?h.remove():this.anchor.type==="text"&&(this.format=h.getFormat(),this.style=h.getStyle(),h.isComposing()&&(this.anchor.offset-=t.length));for(let S=1;S<f;S++){const T=d[S],A=T.__key;p.has(A)||T.remove()}}}removeText(){const t=D()===this;Or(this,Uf(Yr(this))),t&&D()!==this&&me(this)}formatText(t,e=null){if(this.isCollapsed())return this.toggleFormat(t),void ue(null);const r=this.getNodes(),i=[];for(const N of r)M(N)&&i.push(N);const s=N=>{r.forEach(j=>{if(C(j)){const v=j.getFormatFlags(t,N);j.setTextFormat(v)}})},o=i.length;if(o===0)return this.toggleFormat(t),ue(null),void s(e);const l=this.anchor,a=this.focus,c=this.isBackward(),d=c?a:l,f=c?l:a;let h=0,m=i[0],g=d.type==="element"?0:d.offset;if(d.type==="text"&&g===m.getTextContentSize()&&(h=1,m=i[1],g=0),m==null)return;const y=m.getFormatFlags(t,e);s(y);const p=o-1;let _=i[p];const x=f.type==="text"?f.offset:_.getTextContentSize();if(m.is(_)){if(g===x)return;if(Be(m)||g===0&&x===m.getTextContentSize())m.setFormat(y);else{const N=m.splitText(g,x),j=g===0?N[0]:N[1];j.setFormat(y),d.type==="text"&&d.set(j.__key,0,"text"),f.type==="text"&&f.set(j.__key,x-g,"text")}return void(this.format=y)}g===0||Be(m)||([,m]=m.splitText(g),g=0),m.setFormat(y);const b=_.getFormatFlags(t,y);x>0&&(x===_.getTextContentSize()||Be(_)||([_]=_.splitText(x)),_.setFormat(b));for(let N=h+1;N<p;N++){const j=i[N],v=j.getFormatFlags(t,b);j.setFormat(v)}d.type==="text"&&d.set(m.__key,g,"text"),f.type==="text"&&f.set(_.__key,x,"text"),this.format=y|b}insertNodes(t){if(t.length===0)return;if(this.isCollapsed()||this.removeText(),this.anchor.key==="root"){this.insertParagraph();const g=D();
1return E(g)||O(134),g.insertNodes(t)}const e=(this.isBackward()?this.focus:this.anchor).getNode(),r=de(e,Se),i=t[t.length-1];if(C(r)&&"__language"in r){if("__language"in t[0])this.insertText(t[0].getTextContent());else{const g=ji(this);r.splice(g,0,t),i.selectEnd()}return}if(!t.some(g=>(C(g)||J(g))&&!g.isInline())){C(r)||O(211,e.constructor.name,e.getType());const g=ji(this);return r.splice(g,0,t),void i.selectEnd()}const s=function(g){const y=Q();let p=null;for(let _=0;_<g.length;_++){const x=g[_],b=cn(x);if(b||J(x)&&x.isInline()||C(x)&&x.isInline()||M(x)||x.isParentRequired()){if(p===null&&(p=x.createParentElementNode(),y.append(p),b))continue;p!==null&&p.append(x)}else y.append(x),p=null}return y}(t),o=s.getLastDescendant(),l=s.getChildren(),a=!C(r)||!r.isEmpty()?this.insertParagraph():null,c=l[l.length-1];let d=l[0];var f;C(f=d)&&Se(f)&&!f.isEmpty()&&C(r)&&(!r.isEmpty()||r.canMergeWhenEmpty())&&(C(r)||O(211,e.constructor.name,e.getType()),r.append(...d.getChildren()),d=l[1]),d&&(r===null&&O(212,e.constructor.name,e.getType()),function(g,y){const p=y.getParentOrThrow().getLastChild();let _=y;const x=[y];for(;_!==p;)_.getNextSibling()||O(140),_=_.getNextSibling(),x.push(_);let b=g;for(const N of x)b=b.insertAfter(N)}(r,d));const h=de(o,Se);a&&C(h)&&(a.canMergeWhenEmpty()||Se(c))&&(h.append(...a.getChildren()),a.remove()),C(r)&&r.isEmpty()&&r.remove(),o.selectEnd();const m=C(r)?r.getLastChild():null;cn(m)&&h!==r&&m.remove()}insertParagraph(){if(this.anchor.key==="root"){const o=Q();return ee().splice(this.anchor.offset,0,[o]),o.select(),o}const t=ji(this),e=de(this.anchor.getNode(),Se);C(e)||O(213);const r=e.getChildAtIndex(t),i=r?[r,...r.getNextSiblings()]:[],s=e.insertNewAfter(this,!1);return s?(s.append(...i),s.selectStart(),s):null}insertLineBreak(t){const e=Lt();if(this.insertNodes([e]),t){const r=e.getParentOrThrow(),i=e.getIndexWithinParent();r.select(i,i)}}extract(){const t=[...this.getNodes()],e=t.length;let r=t[0],i=t[e-1];const[s,o]=ds(this),l=this.isBackward(),[a,c]=l?[this.focus,this.anchor]:[this.anchor,this.focus],[d,f]=l?[o,s]:[s,o];if(e===0)return[];if(e===1){if(M(r)&&!this.isCollapsed()){const h=r.splitText(d,f),m=d===0?h[0]:h[1];return m?(a.set(m.getKey(),0,"text"),c.set(m.getKey(),m.getTextContentSize(),"text"),[m]):[]}return[r]}if(M(r)&&(d===r.getTextContentSize()?t.shift():d!==0&&([,r]=r.splitText(d),t[0]=r,a.set(r.getKey(),0,"text"))),M(i)){const h=i.getTextContent().length;f===0?t.pop():f!==h&&([i]=i.splitText(f),t[t.length-1]=i,c.set(i.getKey(),i.getTextContentSize(),"text"))}return t}modify(t,e,r){if(Wo(this,t,e,r))return;const i=t==="move",s=G(),o=Ee(Ce(s));if(!o)return;const l=s._blockCursorElement,a=s._rootElement,c=this.focus.getNode();if(a===null||l===null||!C(c)||c.isInline()||c.canBeEmpty()||_s(l,s,a),this.dirty){let d=gn(s,this.anchor.key),f=gn(s,this.focus.key);this.anchor.type==="text"&&(d=hn(d)),this.focus.type==="text"&&(f=hn(f)),d&&f&&nc(o,d,this.anchor.offset,f,this.focus.offset)}if(function(d,f,h,m){d.modify(f,h,m)}(o,t,e?"backward":"forward",r),o.rangeCount>0){const d=o.getRangeAt(0),f=this.anchor.getNode(),h=ie(f)?f:Mf(f);if(this.applyDOMRange(d),this.dirty=!0,!i){const m=this.getNodes(),g=[];let y=!1;for(let p=0;p<m.length;p++){const _=m[p];ps(_,h)?g.push(_):y=!0}if(y&&g.length>0)if(e){const p=g[0];C(p)?p.selectStart():p.getParentOrThrow().selectStart()}else{const p=g[g.length-1];C(p)?p.selectEnd():p.getParentOrThrow().selectEnd()}o.anchorNode===d.startContainer&&o.anchorOffset===d.startOffset||function(p){const _=p.focus,x=p.anchor,b=x.key,N=x.offset,j=x.type;x.set(_.key,_.offset,_.type,!0),_.set(b,N,j,!0)}(this)}}r==="lineboundary"&&Wo(this,t,e,r,"decorators")}forwardDeletion(t,e,r){if(!r&&(t.type==="element"&&C(e)&&t.offset===e.getChildrenSize()||t.type==="text"&&t.offset===e.getTextContentSize())){const i=e.getParent(),s=e.getNextSibling()||(i===null?null:i.getNextSibling());if(C(s)&&s.isShadowRoot())return!0}return!1}deleteCharacter(t){const e=this.isCollapsed();if(this.isCollapsed()){const r=this.anchor;let i=r.getNode();if(this.forwardDeletion(r,i,t))return;const s=eo(Ue(r,t?"previous":"next"));if(s.getTextSlices().every(l=>l===null||l.distance===0)){let l={type:"initial"};for(const a of s.iterNodeCarets("shadowRoot"))if(Pe(a)){if(!a.origin.isInline()){if(a.origin.isShadowRoot()){if(l.type==="merge-block")break;
1if(C(s.anchor.origin)&&s.anchor.origin.isEmpty()){const c=xe(a);Or(this,pt(c,c)),s.anchor.origin.remove()}return}l.type!=="merge-next-block"&&l.type!=="merge-block"||(l={block:l.block,caret:a,type:"merge-block"})}}else{if(l.type==="merge-block")break;if(gt(a)){if(C(a.origin)){if(a.origin.isInline()){if(!a.origin.isParentOf(s.anchor.origin))break}else l={block:a.origin,type:"merge-next-block"};continue}if(J(a.origin)){if(!a.origin.isIsolated())if(l.type==="merge-next-block"&&(a.origin.isKeyboardSelectable()||!a.origin.isInline())&&C(s.anchor.origin)&&s.anchor.origin.isEmpty()){s.anchor.origin.remove();const c=tc();c.add(a.origin.getKey()),me(c)}else a.origin.remove();return}break}}if(l.type==="merge-block"){const{caret:a,block:c}=l;return Or(this,pt(!a.origin.isEmpty()&&c.isEmpty()?bt(Z(c,a.direction)):s.anchor,a)),this.removeText()}}const o=this.focus;if(this.modify("extend",t,"character"),this.isCollapsed()){if(t&&r.offset===0&&$o(this,r.getNode()))return}else{const l=o.type==="text"?o.getNode():null;if(i=r.type==="text"?r.getNode():null,l!==null&&l.isSegmented()){const a=o.offset,c=l.getTextContentSize();if(l.is(i)||t&&a!==c||!t&&a!==0)return void Lo(l,t,a)}else if(i!==null&&i.isSegmented()){const a=r.offset,c=i.getTextContentSize();if(i.is(l)||t&&a!==0||!t&&a!==c)return void Lo(i,t,a)}(function(a,c){const d=a.anchor,f=a.focus,h=d.getNode(),m=f.getNode();if(h===m&&d.type==="text"&&f.type==="text"){const g=d.offset,y=f.offset,p=g<y,_=p?g:y,x=p?y:g,b=x-1;_!==b&&function(N){return!(vc(N)||mf(N))}(h.getTextContent().slice(_,x))&&(c?f.set(f.key,b,f.type):d.set(d.key,b,d.type))}})(this,t)}}if(this.removeText(),t&&!e&&this.isCollapsed()&&this.anchor.type==="element"&&this.anchor.offset===0){const r=this.anchor.getNode();r.isEmpty()&&ie(r.getParent())&&r.getPreviousSibling()===null&&$o(this,r)}}deleteLine(t){this.isCollapsed()&&this.modify("extend",t,"lineboundary"),this.isCollapsed()?this.deleteCharacter(t):this.removeText()}deleteWord(t){if(this.isCollapsed()){const e=this.anchor,r=e.getNode();if(this.forwardDeletion(e,r,t))return;this.modify("extend",t,"word")}this.isCollapsed()?this.deleteCharacter(t):this.removeText()}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return[this.anchor,this.focus]}}function he(n){return n instanceof ui}function Fo(n){const t=n.offset;if(n.type==="text")return t;const e=n.getNode();return t===e.getChildrenSize()?e.getTextContent().length:0}function ds(n){const t=n.getStartEndPoints();if(t===null)return[0,0];const[e,r]=t;return e.type==="element"&&r.type==="element"&&e.key===r.key&&e.offset===r.offset?[0,0]:[Fo(e),Fo(r)]}function $o(n,t){for(let e=t;e;e=e.getParent()){if(C(e)){if(e.collapseAtStart(n))return!0;if(_e(e))break}if(e.getPreviousSibling())break}return!1}const mf=(()=>{try{const n=new RegExp("\\p{Emoji}","u"),t=n.test.bind(n);if(t("❤️")&&t("#️⃣")&&t("👍"))return t}catch(n){}return()=>!1})();function Lo(n,t,e){const r=n,i=r.getTextContent().split(/(?=\s)/g),s=i.length;let o=0,l=0;for(let c=0;c<s;c++){const d=c===s-1;if(l=o,o+=i[c].length,t&&o===e||o>e||d){i.splice(c,1),d&&(l=void 0);break}}const a=i.join("").trim();a===""?r.remove():(r.setTextContent(a),r.select(l,l))}function Io(n,t,e,r){let i,s=t;if(te(n)){let o=!1;const l=n.childNodes,a=l.length,c=r._blockCursorElement;s===a&&(o=!0,s=a-1);let d=l[s],f=!1;if(d===c)d=l[s+1],f=!0;else if(c!==null){const h=c.parentNode;n===h&&t>Array.prototype.indexOf.call(h.children,c)&&s--}if(i=nn(d),M(i))s=Ke(i,o?"next":"previous");else{let h=nn(n);if(h===null)return null;if(C(h)){const m=r.getElementByKey(h.getKey());m===null&&O(214),[h,s]=or(r).$getDOMSlot(h,m,r).resolveChildIndex(h,m,n,t),C(h)||O(215),o&&s>=h.getChildrenSize()&&(s=Math.max(0,h.getChildrenSize()-1));let y=h.getChildAtIndex(s);if(C(y)&&function(p,_,x){const b=p.getParent();return x===null||b===null||!b.canBeEmpty()||b!==x.getNode()}(y,0,e)){const p=o?y.getLastDescendant():y.getFirstDescendant();p===null?h=y:(y=p,h=C(y)?y:y.getParentOrThrow()),s=0}M(y)?(i=y,h=null,s=Ke(y,o?"next":"previous")):y!==h&&o&&!f&&(C(h)||O(216),s=Math.min(h.getChildrenSize(),s+1))}else{const m=h.getIndexWithinParent();s=t===0&&J(h)&&nn(n)===h?m:m+1,h=h.getParentOrThrow()}if(C(h))return We(h.__key,s,"element")}}else i=nn(n);return M(i)?We(i.__key,Ke(i,s,"clamp"),"text"):null}function Ro(n,t,e){const r=n.offset,i=n.getNode();if(r===0){const s=i.getPreviousSibling(),o=i.getParent();if(t){if((e||!t)&&s===null&&C(o)&&o.isInline()){const l=o.getPreviousSibling();M(l)&&n.set(l.__key,l.getTextContent().length,"text")}}else C(s)&&!e&&s.isInline()?n.set(s.__key,s.getChildrenSize(),"element"):M(s)&&n.set(s.__key,s.getTextContent().length,"text")}else if(r===i.getTextContent().length){const s=i.getNextSibling(),o=i.getParent();if(t&&C(s)&&s.isInline())n.set(s.__key,0,"element");else if((e||t)&&s===null&&C(o)&&o.isInline()&&!o.canInsertTextAfter()){const l=o.getNextSibling();M(l)&&n.set(l.__key,0,"text")}}}function Xa(n,t,e){if(n.type==="text"&&t.type==="text"){const r=n.isBefore(t),i=n.is(t);Ro(n,r,i),Ro(t,!r,i),i&&t.set(n.key,n.offset,n.type)}}function Za(n,t,e,r,i,s){if(n===null||e===null||!ir(i,n,e))return null;const o=Io(n,t,E(s)?s.anchor:null,i);if(o===null)return null;const l=Io(e,r,E(s)?s.focus:null,i);if(l===null)return null;if(o.type==="element"&&l.type==="element"){const a=nn(n),c=nn(e);if(J(a)&&J(c))return null}return Xa(o,l),[o,l]}function fs(n){return C(n)&&!n.isInline()}function ec(n,t,e,r,i,s){const o=vt(),l=new Ut(We(n,t,i),We(e,r,s),0,"");return l.dirty=!0,o._selection=l,l}function Ps(){const n=We("root",0,"element"),t=We("root",0,"element");return new Ut(n,t,0,"")}function tc(){return new ui(new Set)}function Fs(n,t,e,r){const i=e._window;if(i===null)return null;const s=r||i.event,o=s?s.type:void 0,l=o==="selectionchange",a=!qi&&(l||o==="beforeinput"||o==="compositionstart"||o==="compositionend"||o==="click"&&s&&s.detail===3||o==="drop"||o===void 0);let c,d,f,h;if(E(n)&&!a)return n.clone();if(t===null)return null;if(c=t.anchorNode,d=t.focusNode,f=t.anchorOffset,h=t.focusOffset,(l||o===void 0)&&E(n)&&!ir(e,c,d))return n.clone();const m=Za(c,f,d,h,e,n);if(m===null)return null;const[g,y]=m;let p=0,_="";if(E(n)){const x=n.anchor;if(g.key===x.key)p=n.format,_=n.style;else{const b=g.getNode();M(b)?(p=b.getFormat(),_=b.getStyle()):C(b)&&(p=b.getTextFormat(),_=b.getTextStyle())}}return new Ut(g,y,p,_)}function D(){return vt()._selection}function _n(){return G()._editorState._selection}function Kr(n,t,e,r=1){const i=n.anchor,s=n.focus,o=i.getNode(),l=s.getNode();if(!t.is(o)&&!t.is(l))return;const a=t.__key;if(n.isCollapsed()){const c=i.offset;if(e<=c&&r>0||e<c&&r<0){const d=Math.max(0,c+r);i.set(a,d,"element"),s.set(a,d,"element"),Bo(n)}}else{const c=n.isBackward(),d=c?s:i,f=d.getNode(),h=c?i:s,m=h.getNode();if(t.is(f)){const g=d.offset;(e<=g&&r>0||e<g&&r<0)&&d.set(a,Math.max(0,g+r),"element")}if(t.is(m)){const g=h.offset;(e<=g&&r>0||e<g&&r<0)&&h.set(a,Math.max(0,g+r),"element")}}Bo(n)}function Bo(n){const t=n.anchor,e=t.offset,r=n.focus,i=r.offset,s=t.getNode(),o=r.getNode();if(n.isCollapsed()){if(!C(s))return;const l=s.getChildrenSize(),a=e>=l,c=a?s.getChildAtIndex(l-1):s.getChildAtIndex(e);if(M(c)){let d=0;a&&(d=c.getTextContentSize()),t.set(c.__key,d,"text"),r.set(c.__key,d,"text")}return}if(C(s)){const l=s.getChildrenSize(),a=e>=l,c=a?s.getChildAtIndex(l-1):s.getChildAtIndex(e);if(M(c)){let d=0;a&&(d=c.getTextContentSize()),t.set(c.__key,d,"text")}}if(C(o)){const l=o.getChildrenSize(),a=i>=l,c=a?o.getChildAtIndex(l-1):o.getChildAtIndex(i);if(M(c)){let d=0;a&&(d=c.getTextContentSize()),r.set(c.__key,d,"text")}}}function Wr(n,t,e,r,i){let s=null,o=0,l=null;r!==null?(s=r.__key,M(r)?(o=r.getTextContentSize(),l="text"):C(r)&&(o=r.getChildrenSize(),l="element")):i!==null&&(s=i.__key,M(i)?l="text":C(i)&&(l="element")),s!==null&&l!==null?n.set(s,o,l):(o=t.getIndexWithinParent(),o===-1&&(o=e.getChildrenSize()),n.set(e.__key,o,"element"))}function zo(n,t,e,r,i){n.type==="text"?n.set(e,n.offset+(t?0:i),"text"):n.offset>r.getIndexWithinParent()&&n.set(n.key,n.offset-1,"element")}function nc(n,t,e,r,i){try{n.setBaseAndExtent(t,e,r,i)}catch(s){}}function Ko(n,t,e){const r=gn(n,t.getKey());if(C(t)){const i=or(n).$getDOMSlot(t,r,n);return[i.element,e+i.getFirstChildOffset()]}return[r,e]}function pf(n,t,e,r,i,s,o){const l=r.anchorNode,a=r.focusNode,c=r.anchorOffset,d=r.focusOffset,f=document.activeElement;if(i.has(rf)&&f!==s||f!==null&&Ks(f))return;if(!E(t))return void(n!==null&&ir(e,l,a)&&r.removeAllRanges());const h=t.anchor,m=t.focus,g=h.getNode(),y=m.getNode(),[p,_]=Ko(e,g,h.offset),[x,b]=Ko(e,y,m.offset),N=t.format,j=t.style,v=t.isCollapsed();let k=p,S=x,T=!1;var A,$,z,R,U;if(h.type==="text"?(k=hn(p),T=g.getFormat()!==N||g.getStyle()!==j):E(n)&&n.anchor.type==="text"&&(T=!0),m.type==="text"&&(S=hn(x)),k!==null&&S!==null&&(v&&(n===null||T||E(n)&&(n.format!==N||n.style!==j))&&(A=N,$=j,z=_,R=h.key,U=performance.now(),Ba=[A,$,z,R,U]),c!==_||d!==b||l!==k||a!==S||r.type==="Range"&&v||(f!==null&&s.contains(f)||i.has(cs)||s.focus({preventScroll:!0}),h.type==="element"))){if(nc(r,k,_,S,b),!ht||!t.isCollapsed()||s===null||i.has(cs)||document.activeElement!==null&&s.contains(document.activeElement)||s.focus({preventScroll:!0}),!i.has(sf)&&t.isCollapsed()&&s!==null&&s===document.activeElement){const K=E(t)&&t.anchor.type==="element"?k.childNodes[_]||null:r.rangeCount>0?r.getRangeAt(0):null;if(K!==null){let ye;if(K instanceof Text){const Le=document.createRange();Le.selectNode(K),ye=Le.getBoundingClientRect()}else ye=K.getBoundingClientRect();(function(Le,qt,qe){const Ht=Nc(qe),xi=Hs(Ht);if(Ht===null||xi===null)return;let{top:vi,bottom:bi}=qt,Sn=0,Nn=0,ot=qe;for(;ot!==null;){const Ci=ot===Ht.body;if(Ci){Sn=0,Nn=Ce(Le).innerHeight;const Nt=xi.getComputedStyle(Ht.documentElement),wn=parseFloat(Nt.scrollPaddingTop),uo=parseFloat(Nt.scrollPaddingBottom);
1isFinite(wn)&&(Sn+=wn),isFinite(uo)&&(Nn-=uo)}else{const Nt=ot.getBoundingClientRect();Sn=Nt.top,Nn=Nt.bottom}let kn=0;if(vi<Sn?kn=-(Sn-vi):bi>Nn&&(kn=bi-Nn),kn!==0)if(Ci)xi.scrollBy(0,kn);else{const Nt=ot.scrollTop;ot.scrollTop+=kn;const wn=ot.scrollTop-Nt;vi-=wn,bi-=wn}if(Ci)break;ot=sr(ot)}})(e,ye,s)}}ss=!0}}function _f(n){let t=D()||_n();t===null&&(t=ee().selectEnd()),t.insertNodes(n)}function ji(n){let t=n;n.isCollapsed()||t.removeText();const e=D();E(e)&&(t=e),E(t)||O(161);const r=t.anchor;let i=r.getNode(),s=r.offset;for(;!Se(i);){const o=i;if([i,s]=yf(i,s),o.is(i))break}return s}function yf(n,t){const e=n.getParent();if(!e){const i=Q();return ee().append(i),i.select(),[ee(),0]}if(M(n)){const i=n.splitText(t);if(i.length===0)return[e,n.getIndexWithinParent()];const s=t===0?0:1;return[e,i[0].getIndexWithinParent()+s]}if(!C(n)||t===0)return[e,n.getIndexWithinParent()];const r=n.getChildAtIndex(t);if(r){const i=new Ut(We(n.__key,t,"element"),We(n.__key,t,"element"),0,""),s=n.insertNewAfter(i);s&&s.append(r,...r.getNextSiblings())}return[e,n.getIndexWithinParent()+1]}function Wo(n,t,e,r,i="decorators-and-blocks"){if(t==="move"&&r==="character"&&!n.isCollapsed()){const[d,f]=e===n.isBackward()?[n.focus,n.anchor]:[n.anchor,n.focus];return f.set(d.key,d.offset,d.type),!0}const s=Ue(n.focus,e?"previous":"next"),o=r==="lineboundary",l=t==="move";let a=s,c=i==="decorators-and-blocks";if(!Mc(a)){for(const d of a){c=!1;const{origin:f}=d;if(!J(f)||f.isIsolated()||(a=d,!o||!f.isInline()))break}if(c)for(const d of eo(s).iterNodeCarets(t==="extend"?"shadowRoot":"root")){if(Pe(d))d.origin.isInline()||(a=d);else{if(C(d.origin))continue;J(d.origin)&&!d.origin.isInline()&&(a=d)}break}}if(a===s)return!1;if(l&&!o&&J(a.origin)&&a.origin.isKeyboardSelectable()){const d=tc();return d.add(a.origin.getKey()),me(d),!0}return a=xe(a),l&&_t(n.anchor,a),_t(n.focus,a),c||!o}let le=null,ae=null,ve=!1,Oi=!1,Er=0;const Uo={characterData:!0,childList:!0,subtree:!0};function nr(){return ve||le!==null&&le._readOnly}function ge(){ve&&O(13)}function rc(){Er>99&&O(14)}function vt(){return le===null&&O(195,ic()),le}function G(){return ae===null&&O(337,ic()),ae}function ic(){let n=0;const t=new Set,e=It.version;if(typeof window<"u")for(const i of document.querySelectorAll("[contenteditable]")){const s=fi(i);if(Ws(s))n++;else if(s){let o=String(s.constructor.version||"<0.17.1");o===e&&(o+=" (separately built, likely a bundler configuration issue)"),t.add(o)}}let r=" Detected on the page: ".concat(n," compatible editor(s) with version ").concat(e);return t.size&&(r+=" and incompatible editors with versions ".concat(Array.from(t).join(", "))),r}function xf(){return ae}function Jo(n,t,e){const r=t.__type,i=fc(n,r);let s=e.get(r);s===void 0&&(s=Array.from(i.transforms),e.set(r,s));const o=s.length;for(let l=0;l<o&&(s[l](t),t.isAttached());l++);}function Vo(n,t){return n!==void 0&&n.__key!==t&&n.isAttached()}function sc(n,t){if(!t)return;const e=n._updateTags;let r=t;Array.isArray(t)||(r=[t]);for(const i of r)e.add(i)}function vf(n){return $s(n,G()._nodes)}function $s(n,t){const e=n.type,r=t.get(e);r===void 0&&O(17,e);const i=r.klass;n.type!==i.getType()&&O(18,i.name);const s=i.importJSON(n),o=n.children;if(C(s)&&Array.isArray(o))for(let l=0;l<o.length;l++){const a=$s(o[l],t);s.append(a)}return s}function qo(n,t,e){const r=le,i=ve,s=ae;le=t,ve=!0,ae=n;try{return e()}finally{le=r,ve=i,ae=s}}function Qe(n,t){const e=n._pendingEditorState,r=n._rootElement,i=n._headless||r===null;if(e===null)return void(n._deferred.length>0&&Ho(n,n._deferred));const s=n._editorState,o=s._selection,l=e._selection,a=n._dirtyType!==0,c=le,d=ve,f=ae,h=n._updating,m=n._observer;let g=null;if(n._pendingEditorState=null,n._editorState=e,!i&&a&&m!==null){ae=n,le=e,ve=!1,n._updating=!0;try{const v=n._dirtyType,k=n._dirtyElements,S=n._dirtyLeaves;m.disconnect(),g=Id(s,e,n,v,k,S)}catch(v){if(v instanceof Error&&n._onError(v),Oi)throw v;return uc(n,null,r,e),da(n),n._dirtyType=2,Oi=!0,Qe(n,s),void(Oi=!1)}finally{m.observe(r,Uo),n._updating=h,le=c,ve=d,ae=f}}e._readOnly||(e._readOnly=!0);const y=n._dirtyLeaves,p=n._dirtyElements,_=n._normalizedNodes,x=n._updateTags,b=n._deferred;a&&(n._dirtyType=0,n._cloneNotNeeded.clear(),n._dirtyLeaves=new Set,n._dirtyElements=new Map,n._normalizedNodes=new Set,n._updateTags=new Set),function(v,k){const S=v._decorators;let T=v._pendingDecorators||S;const A=k._nodeMap;let $;for($ in T)A.has($)||(T===S&&(T=yc(v)),delete T[$])}(n,e);const N=i?null:Ee(Ce(n));if(n._editable&&N!==null&&(a||l===null||l.dirty||!l.is(o))&&r!==null&&!x.has(of)){ae=n,le=e;try{if(m!==null&&m.disconnect(),a||l===null||l.dirty){const v=n._blockCursorElement;v!==null&&_s(v,n,r),pf(o,l,n,N,x,r)}(function(v,k,S){let T=v._blockCursorElement;if(E(S)&&S.isCollapsed()&&S.anchor.type==="element"&&k.contains(document.activeElement)){const A=S.anchor,$=A.getNode(),z=A.offset;let R=!1,U=null;if(z===$.getChildrenSize())Ai($.getChildAtIndex(z-1))&&(R=!0);else{const K=$.getChildAtIndex(z);if(K!==null&&Ai(K)){const ye=K.getPreviousSibling();(ye===null||Ai(ye))&&(R=!0,U=v.getElementByKey(K.__key))}}if(R){const K=v.getElementByKey($.__key);return T===null&&(v._blockCursorElement=T=function(ye){const Le=ye.theme,qt=document.createElement("div");qt.contentEditable="false",qt.setAttribute("data-lexical-cursor","true");let qe=Le.blockCursor;if(qe!==void 0){if(typeof qe=="string"){const Ht=yt(qe);qe=Le.blockCursor=Ht}qe!==void 0&&qt.classList.add(...qe)}return qt}(v._config)),k.style.caretColor="transparent",void(U===null?K.appendChild(T):K.insertBefore(T,U))}}T!==null&&_s(T,v,k)})(n,r,l)}finally{m!==null&&m.observe(r,Uo),ae=f,le=c}}g!==null&&function(v,k,S,T,A){const $=Array.from(v._listeners.mutation),z=$.length;for(let R=0;R<z;
1R++){const[U,K]=$[R];for(const ye of K){const Le=k.get(ye);Le!==void 0&&U(Le,{dirtyLeaves:T,prevEditorState:A,updateTags:S})}}}(n,g,x,y,s),E(l)||l===null||o!==null&&o.is(l)||n.dispatchCommand(Ms,void 0);const j=n._pendingDecorators;j!==null&&(n._decorators=j,n._pendingDecorators=null,Rn("decorator",n,!0,j)),function(v,k,S){const T=Xo(k),A=Xo(S);T!==A&&Rn("textcontent",v,!0,A)}(n,t||s,e),Rn("update",n,!0,{dirtyElements:p,dirtyLeaves:y,editorState:e,mutatedNodes:g,normalizedNodes:_,prevEditorState:t||s,tags:x}),Ho(n,b),function(v){const k=v._updates;if(k.length!==0){const S=k.shift();if(S){const[T,A]=S;di(v,T,A)}}}(n)}function Rn(n,t,e,...r){const i=t._updating;t._updating=e;try{const s=t._listeners[n],o=Array.from(s);for(const[l,a]of o){a&&a();const c=l(...r);s.has(l)?s.set(l,c):c&&c()}}finally{t._updating=i}}function oc(n,t,e,r){const i=Us(n);let s;for(let o=4;o>=0;o--)for(let l=0;l<i.length;l++){const a=i[l];if(l>0&&a._updating){s=a;break}const c=a._commands.get(t);if(c!==void 0){const d=c[o];if(d.size>0){let f=!1;if(ze(a,()=>{for(const h of d)if(h(e,r))return void(f=!0)}),f)return f}}}return s&&s.update(()=>{oc(s,t,e,r)}),!1}function Ho(n,t){if(n._deferred=[],t.length!==0){const e=n._updating;n._updating=!0;try{for(let r=0;r<t.length;r++)t[r]()}finally{n._updating=e}}}function Yo(n,t){const e=n._updates;let r=t||!1;for(;e.length!==0;){const i=e.shift();if(i){const[s,o]=i,l=n._pendingEditorState;let a;o!==void 0&&(a=o.onUpdate,o.skipTransforms&&(r=!0),o.discrete&&(l===null&&O(191),l._flushSync=!0),a&&n._deferred.push(a),sc(n,o.tag)),l==null?di(n,s,o):s()}}return r}function di(n,t,e){const r=n._updateTags;let i,s=!1,o=!1;e!==void 0&&(i=e.onUpdate,sc(n,e.tag),s=e.skipTransforms||!1,o=e.discrete||!1),i&&n._deferred.push(i);const l=n._editorState;let a=n._pendingEditorState,c=!1;(a===null||a._readOnly)&&(a=n._pendingEditorState=ac(a||l),c=!0),a._flushSync=o;const d=le,f=ve,h=ae,m=n._updating;le=a,ve=!1,n._updating=!0,ae=n;const g=n._headless||n.getRootElement()===null;Bs(null);try{c&&(g?l._selection!==null&&(a._selection=l._selection.clone()):a._selection=function(x,b){const N=x.getEditorState()._selection,j=Ee(Ce(x));return E(N)||N==null?Fs(N,j,x,b):N.clone()}(n,e&&e.event||null));const p=n._compositionKey;t(),s=Yo(n,s),function(x,b){const N=b.getEditorState()._selection,j=x._selection;
1if(E(j)){const v=j.anchor,k=j.focus;let S;if(v.type==="text"&&(S=v.getNode(),S.selectionTransform(N,j)),k.type==="text"){const T=k.getNode();S!==T&&T.selectionTransform(N,j)}}}(a,n),n._dirtyType!==0&&(s?function(x,b){const N=b._dirtyLeaves,j=x._nodeMap;for(const v of N){const k=j.get(v);M(k)&&k.isAttached()&&k.isSimpleText()&&!k.isUnmergeable()&&Co(k)}}(a,n):function(x,b){const N=b._dirtyLeaves,j=b._dirtyElements,v=x._nodeMap,k=ut(),S=new Map;let T=N,A=T.size,$=j,z=$.size;for(;A>0||z>0;){if(A>0){b._dirtyLeaves=new Set;for(const R of T){const U=v.get(R);M(U)&&U.isAttached()&&U.isSimpleText()&&!U.isUnmergeable()&&Co(U),U!==void 0&&Vo(U,k)&&Jo(b,U,S),N.add(R)}if(T=b._dirtyLeaves,A=T.size,A>0){Er++;continue}}b._dirtyLeaves=new Set,b._dirtyElements=new Map,$.delete("root")&&$.set("root",!0);for(const R of $){const U=R[0],K=R[1];if(j.set(U,K),!K)continue;const ye=v.get(U);ye!==void 0&&Vo(ye,k)&&Jo(b,ye,S)}T=b._dirtyLeaves,A=T.size,$=b._dirtyElements,z=$.size,Er++}b._dirtyLeaves=N,b._dirtyElements=j}(a,n),Yo(n),function(x,b,N,j){const v=x._nodeMap,k=b._nodeMap,S=[];for(const[T]of j){const A=k.get(T);A!==void 0&&(A.isAttached()||(C(A)&&aa(A,T,v,k,S,j),v.has(T)||j.delete(T),S.push(T)))}for(const T of S)k.delete(T);for(const T of N){const A=k.get(T);A===void 0||A.isAttached()||(v.has(T)||N.delete(T),k.delete(T))}}(l,a,n._dirtyLeaves,n._dirtyElements)),p!==n._compositionKey&&(a._flushSync=!0);const _=a._selection;if(E(_)){const x=a._nodeMap,b=_.anchor.key,N=_.focus.key;x.get(b)!==void 0&&x.get(N)!==void 0||O(19)}else he(_)&&_._nodes.size===0&&(a._selection=null)}catch(p){return p instanceof Error&&n._onError(p),n._pendingEditorState=l,n._dirtyType=2,n._cloneNotNeeded.clear(),n._dirtyLeaves=new Set,n._dirtyElements.clear(),void Qe(n)}finally{le=d,ve=f,ae=h,n._updating=m,Er=0}n._dirtyType!==0||n._deferred.length>0||function(p,_){const x=_.getEditorState()._selection,b=p._selection;if(b!==null){if(b.dirty||!b.is(x))return!0}else if(x!==null)return!0;return!1}(a,n)?a._flushSync?(a._flushSync=!1,Qe(n)):c&&Tf(()=>{Qe(n)}):(a._flushSync=!1,c&&(r.clear(),n._deferred=[],n._pendingEditorState=null))}function ze(n,t,e){ae===n&&e===void 0?t():di(n,t,e)}class Bn{constructor(t,e,r){w(this,"element");w(this,"before");w(this,"after");this.element=t,this.before=e||null,this.after=r||null}withBefore(t){return new Bn(this.element,t,this.after)}withAfter(t){return new Bn(this.element,this.before,t)}withElement(t){return this.element===t?this:new Bn(t,this.before,this.after)}insertChild(t){const e=this.before||this.getManagedLineBreak();return e!==null&&e.parentElement!==this.element&&O(222),this.element.insertBefore(t,e),this}removeChild(t){return t.parentElement!==this.element&&O(223),this.element.removeChild(t),this}replaceChild(t,e){return e.parentElement!==this.element&&O(224),this.element.replaceChild(t,e),this}getFirstChild(){const t=this.after?this.after.nextSibling:this.element.firstChild;return t===this.before||t===this.getManagedLineBreak()?null:t}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(t){if(t===null)this.removeManagedLineBreak();else{const e=t==="decorator"&&(ri||er||ni);this.insertManagedLineBreak(e)}}removeManagedLineBreak(){const t=this.getManagedLineBreak();if(t){const e=this.element,r=t.nodeName==="IMG"?t.nextSibling:null;r&&e.removeChild(r),e.removeChild(t),e.__lexicalLineBreak=void 0}}insertManagedLineBreak(t){const e=this.getManagedLineBreak();if(e){if(t===(e.nodeName==="IMG"))return;this.removeManagedLineBreak()}const r=this.element,i=this.before,s=document.createElement("br");if(r.insertBefore(s,i),t){const o=document.createElement("img");o.setAttribute("data-lexical-linebreak","true"),o.style.setProperty("display","inline","important"),o.style.setProperty("border","0px","important"),o.style.setProperty("margin","0px","important"),o.alt="",r.insertBefore(o,s),r.__lexicalLineBreak=o}else r.__lexicalLineBreak=s}getFirstChildOffset(){let t=0;for(let e=this.after;e!==null;e=e.previousSibling)t++;return t}resolveChildIndex(t,e,r,i){if(r===this.element){const a=this.getFirstChildOffset();return[t,Math.min(a+t.getChildrenSize(),Math.max(a,i))]}const s=Go(e,r);s.push(i);const o=Go(e,this.element);let l=t.getIndexWithinParent();for(let a=0;a<o.length;a++){const c=s[a],d=o[a];if(c===void 0||c<d)break;if(c>d){l+=1;break}}return[t.getParentOrThrow(),l]}}function Go(n,t){const e=[];let r=t;for(;r!==n&&r!==null;r=r.parentNode){let i=0;for(let s=r.previousSibling;s!==null;s=s.previousSibling)i++;e.push(i)}return r!==n&&O(225),e.reverse()}class we extends ke{constructor(e){super(e);w(this,"__first");w(this,"__last");w(this,"__size");w(this,"__format");w(this,"__style");w(this,"__indent");w(this,"__dir");w(this,"__textFormat");w(this,"__textStyle");this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null,this.__textFormat=0,this.__textStyle=""}afterCloneFrom(e){super.afterCloneFrom(e),this.__key===e.__key&&(this.__first=e.__first,this.__last=e.__last,this.__size=e.__size),this.__indent=e.__indent,this.__format=e.__format,this.__style=e.__style,this.__dir=e.__dir,this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}getFormat(){return this.getLatest().__format}getFormatType(){const e=this.getFormat();return Nd[e]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const e=[];let r=this.getFirstChild();for(;r!==null;)e.push(r),r=r.getNextSibling();return e}getChildrenKeys(){const e=[];let r=this.getFirstChild();for(;r!==null;)e.push(r.__key),r=r.getNextSibling();return e}getChildrenSize(){return this.getLatest().__size}isEmpty(){return this.getChildrenSize()===0}isDirty(){const e=G()._dirtyElements;return e!==null&&e.has(this.__key)}isLastChild(){const e=this.getLatest(),r=this.getParentOrThrow().getLastChild();return r!==null&&r.is(e)}getAllTextNodes(){const e=[];let r=this.getFirstChild();for(;r!==null;){if(M(r)&&e.push(r),C(r)){const i=r.getAllTextNodes();e.push(...i)}r=r.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;C(e);){const r=e.getFirstChild();if(r===null)break;e=r}return e}getLastDescendant(){let e=this.getLastChild();for(;C(e);){const r=e.getLastChild();if(r===null)break;e=r}return e}getDescendantByIndex(e){const r=this.getChildren(),i=r.length;if(e>=i){const o=r[i-1];return C(o)&&o.getLastDescendant()||o||null}const s=r[e];return C(s)&&s.getFirstDescendant()||s||null}getFirstChild(){const e=this.getLatest().__first;return e===null?null:ne(e)}getFirstChildOrThrow(){const e=this.getFirstChild();return e===null&&O(45,this.__key),e}getLastChild(){const e=this.getLatest().__last;return e===null?null:ne(e)}getLastChildOrThrow(){const e=this.getLastChild();return e===null&&O(96,this.__key),e}getChildAtIndex(e){const r=this.getChildrenSize();let i,s;if(e<r/2){for(i=this.getFirstChild(),s=0;i!==null&&s<=e;){if(s===e)return i;i=i.getNextSibling(),s++}return null}for(i=this.getLastChild(),s=r-1;i!==null&&s>=e;){if(s===e)return i;i=i.getPreviousSibling(),s--}return null}getTextContent(){let e="";const r=this.getChildren(),i=r.length;for(let s=0;s<i;s++){const o=r[s];e+=o.getTextContent(),C(o)&&s!==i-1&&!o.isInline()&&(e+=ii)}return e}getTextContentSize(){let e=0;const r=this.getChildren(),i=r.length;for(let s=0;s<i;s++){const o=r[s];e+=o.getTextContentSize(),C(o)&&s!==i-1&&!o.isInline()&&(e+=2)}return e}getDirection(){return this.getLatest().__dir}getTextFormat(){return this.getLatest().__textFormat}hasFormat(e){if(e!==""){const r=Vi[e];return(this.getFormat()&r)!==0}return!1}hasTextFormat(e){const r=Dt[e];return(this.getTextFormat()&r)!==0}getFormatFlags(e,r){return Ur(this.getLatest().__textFormat,e,r)}getTextStyle(){return this.getLatest().__textStyle}select(e,r){ge();const i=D();let s=e,o=r;
1const l=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&r===0){const c=this.getFirstChild();if(M(c)||C(c))return c.select(0,0)}else if(!(e!==void 0&&e!==l||r!==void 0&&r!==l)){const c=this.getLastChild();if(M(c)||C(c))return c.select()}}s===void 0&&(s=l),o===void 0&&(o=l);const a=this.__key;return E(i)?(i.anchor.set(a,s,"element"),i.focus.set(a,o,"element"),i.dirty=!0,i):ec(a,s,a,o,"element","element")}selectStart(){const e=this.getFirstDescendant();return e?e.selectStart():this.select()}selectEnd(){const e=this.getLastDescendant();return e?e.selectEnd():this.select()}clear(){const e=this.getWritable();return this.getChildren().forEach(r=>r.remove()),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){const r=this.getWritable();return r.__dir=e,r}setFormat(e){return this.getWritable().__format=e!==""&&Vi[e]||0,this}setStyle(e){return this.getWritable().__style=e||"",this}setTextFormat(e){const r=this.getWritable();return r.__textFormat=e,r}setTextStyle(e){const r=this.getWritable();return r.__textStyle=e,r}setIndent(e){return this.getWritable().__indent=e,this}splice(e,r,i){zr(this)&&O(324,this.__key,this.__type);const s=this.getChildrenSize(),o=this.getWritable();e+r<=s||O(226,String(e),String(r),String(s));const l=o.__key,a=[],c=[],d=this.getChildAtIndex(e+r);let f=null,h=s-r+i.length;if(e!==0)if(e===s)f=this.getLastChild();else{const g=this.getChildAtIndex(e);g!==null&&(f=g.getPreviousSibling())}if(r>0){let g=f===null?this.getFirstChild():f.getNextSibling();for(let y=0;y<r;y++){g===null&&O(100);const p=g.getNextSibling(),_=g.__key;Mt(g.getWritable()),c.push(_),g=p}}let m=f;for(const g of i){m!==null&&g.is(m)&&(f=m=m.getPreviousSibling());const y=g.getWritable();y.__parent===l&&h--,Mt(y);const p=g.__key;if(m===null)o.__first=p,y.__prev=null;else{const _=m.getWritable();_.__next=p,y.__prev=_.__key}g.__key===l&&O(76),y.__parent=l,a.push(p),m=g}if(e+r===s)m!==null&&(m.getWritable().__next=null,o.__last=m.__key);else if(d!==null){const g=d.getWritable();if(m!==null){const y=m.getWritable();g.__prev=m.__key,y.__next=d.__key}else g.__prev=null}if(o.__size=h,c.length){const g=D();if(E(g)){const y=new Set(c),p=new Set(a),{anchor:_,focus:x}=g;Qo(_,y,p)&&Wr(_,_.getNode(),this,f,d),Qo(x,y,p)&&Wr(x,x.getNode(),this,f,d),h!==0||this.canBeEmpty()||_e(this)||this.remove()}}return o}getDOMSlot(e){return new Bn(e)}exportDOM(e){const{element:r}=super.exportDOM(e);if(te(r)){const i=this.getIndent();i>0&&(r.style.paddingInlineStart=40*i+"px");const s=this.getDirection();s&&(r.dir=s)}return{element:r}}exportJSON(){const e={children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),...super.exportJSON()},r=this.getTextFormat(),i=this.getTextStyle();return r===0&&i===""||_e(this)||this.getChildren().some(M)||(r!==0&&(e.textFormat=r),i!==""&&(e.textStyle=i)),e}updateFromJSON(e){return super.updateFromJSON(e).setFormat(e.format).setIndent(e.indent).setDirection(e.direction).setTextFormat(e.textFormat||0).setTextStyle(e.textStyle||"")}insertNewAfter(e,r){return null}canIndent(){return!0}collapseAtStart(e){return!1}excludeFromCopy(e){return!1}canReplaceWith(e){return!0}canInsertAfter(e){return!0}canBeEmpty(){return!0}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}isInline(){return!1}isShadowRoot(){return!1}canMergeWith(e){return!1}extractWithChild(e,r,i){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(e,r){const i=or(r).$getDOMSlot(this,e,r);let s=i.getFirstChild();for(let o=this.getFirstChild();o;o=o.getNextSibling()){const l=r.getElementByKey(o.getKey());l!==null&&(s==null?(i.insertChild(l),s=l):s!==l&&i.replaceChild(l,s),s=s.nextSibling)}}}function C(n){return n instanceof we}function Qo(n,t,e){let r=n.getNode();for(;r;){const i=r.__key;if(t.has(i)&&!e.has(i))return!0;r=r.getParent()}return!1}class lc extends ke{decorate(t,e){return null}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function J(n){return n instanceof lc}class Jt extends we{constructor(){super("root");w(this,"__cachedText");this.__cachedText=null}static getType(){return"root"}static clone(){return new Jt}getTopLevelElementOrThrow(){O(51)}getTextContent(){const e=this.__cachedText;return!nr()&&G()._dirtyType!==0||e===null?super.getTextContent():e}remove(){O(52)}replace(e){O(53)}insertBefore(e){O(54)}insertAfter(e){O(55)}updateDOM(e,r){return!1}splice(e,r,i){for(const s of i)C(s)||J(s)||O(282);return super.splice(e,r,i)}static importJSON(e){return ee().updateFromJSON(e)}collapseAtStart(){return!0}}function ie(n){return n instanceof Jt}function ac(n){return new rr(new Map(n._nodeMap))}
1function Ls(){return new rr(new Map([["root",new Jt]]))}function cc(n){const t=n.exportJSON(),e=n.constructor;if(t.type!==e.getType()&&O(130,e.name),C(n)){const r=t.children;Array.isArray(r)||O(59,e.name);const i=n.getChildren();for(let s=0;s<i.length;s++){const o=cc(i[s]);r.push(o)}}return t}function bf(n){return n instanceof rr}class rr{constructor(t,e){w(this,"_nodeMap");w(this,"_selection");w(this,"_flushSync");w(this,"_readOnly");this._nodeMap=t,this._selection=e||null,this._flushSync=!1,this._readOnly=!1}isEmpty(){return this._nodeMap.size===1&&this._selection===null}read(t,e){return qo(e&&e.editor||null,this,t)}clone(t){const e=new rr(this._nodeMap,t===void 0?this._selection:t);return e._readOnly=!0,e}toJSON(){return qo(null,this,()=>({root:cc(ee())}))}}class Is extends we{static getType(){return"artificial"}createDOM(t){return document.createElement("div")}}class yn extends we{static getType(){return"paragraph"}static clone(t){return new yn(t.__key)}createDOM(t){const e=document.createElement("p"),r=un(t.theme,"paragraph");return r!==void 0&&e.classList.add(...r),e}updateDOM(t,e,r){return!1}static importDOM(){return{p:t=>({conversion:Cf,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(te(e)){this.isEmpty()&&e.append(document.createElement("br"));const r=this.getFormatType();r&&(e.style.textAlign=r)}return{element:e}}static importJSON(t){return Q().updateFromJSON(t)}exportJSON(){const t=super.exportJSON();if(t.textFormat===void 0||t.textStyle===void 0){const e=this.getChildren().find(M);e?(t.textFormat=e.getFormat(),t.textStyle=e.getStyle()):(t.textFormat=this.getTextFormat(),t.textStyle=this.getTextStyle())}return t}insertNewAfter(t,e){const r=Q();r.setTextFormat(t.format),r.setTextStyle(t.style);const i=this.getDirection();return r.setDirection(i),r.setFormat(this.getFormatType()),r.setStyle(this.getStyle()),this.insertAfter(r,e),r}collapseAtStart(){const t=this.getChildren();if(t.length===0||M(t[0])&&t[0].getTextContent().trim()===""){if(this.getNextSibling()!==null)return this.selectNext(),this.remove(),!0;if(this.getPreviousSibling()!==null)return this.selectPrevious(),this.remove(),!0}return!1}}function Cf(n){const t=Q();if(n.style&&(t.setFormat(n.style.textAlign),Ys(n,t)),t.getFormatType()===""){const e=n.getAttribute("align");e&&e&&e in Vi&&t.setFormat(e)}return{node:t}}function Q(){return Ve(new yn)}function Rs(n){return n instanceof yn}const B=0,Xe=1,Sf=4;function uc(n,t,e,r){const i=n._keyToDOMMap;i.clear(),n._editorState=Ls(),n._pendingEditorState=r,n._compositionKey=null,n._dirtyType=0,n._cloneNotNeeded.clear(),n._dirtyLeaves=new Set,n._dirtyElements.clear(),n._normalizedNodes=new Set,n._updateTags=new Set,n._updates=[],n._blockCursorElement=null;const s=n._observer;s!==null&&(s.disconnect(),n._observer=null),t!==null&&(t.textContent=""),e!==null&&(e.textContent="",i.set("root",e))}function Nf(n){const t=new Set,e=new Set;let r=n;for(;r;){const{ownNodeConfig:i}=vn(r),s=r.transform;if(!e.has(s)){e.add(s);const o=r.transform();o&&t.add(o)}if(i){const o=i.$transform;o&&t.add(o),r=i.extends}else{const o=Object.getPrototypeOf(r);r=o.prototype instanceof ke&&o!==ke?o:void 0}}return t}const Xn={$createDOM:(n,t)=>n.createDOM(t._config,t),$decorateDOM:(n,t,e,r)=>{},$exportDOM:(n,t)=>{const e=zs(t,n.getType());return e&&e.exportDOM!==void 0?e.exportDOM(t,n):n.exportDOM(t)},$extractWithChild:(n,t,e,r,i)=>C(n)&&n.extractWithChild(t,e,r),$getDOMSlot:(n,t,e)=>(C(n)||O(336,n.getKey(),n.getType()),n.getDOMSlot(t)),$shouldExclude:(n,t,e)=>C(n)&&n.excludeFromCopy("html"),$shouldInclude:(n,t,e)=>!t||n.isSelected(t),$updateDOM:(n,t,e,r)=>n.updateDOM(t,e,r._config)};function dc(n){const t=n||{},e=xf(),r=t.theme||{},i=n===void 0?e:t.parentEditor||null,s=t.disableEvents||!1,o=Ls(),l=t.namespace||(i!==null?i._config.namespace:bc()),a=t.editorState,c=[Jt,xt,mn,pn,yn,Is,...t.nodes||[]],{onError:d,html:f}=t,h=t.editable===void 0||t.editable;let m;if(n===void 0&&e!==null)m=e._nodes;else{m=new Map;for(let y=0;y<c.length;y++){let p=c[y],_=null,x=null;if(typeof p!="function"){const j=p;p=j.replace,_=j.with,x=j.withKlass||null}vn(p);const b=p.getType(),N=Nf(p);m.set(b,{exportDOM:f&&f.export?f.export.get(p):void 0,klass:p,replace:_,replaceWithKlass:x,sharedNodeState:Ad(c[y]),transforms:N})}}const g=new It(o,i,m,{disableEvents:s,dom:{...Xn,...n&&n.dom},namespace:l,theme:r},d||console.error,function(y,p){const _=new Map,x=new Set,b=N=>
1{Object.keys(N).forEach(j=>{let v=_.get(j);v===void 0&&(v=[],_.set(j,v)),v.push(N[j])})};return y.forEach(N=>{const j=N.klass.importDOM;if(j==null||x.has(j))return;x.add(j);const v=j.call(N.klass);v!==null&&b(v)}),p&&b(p),_}(m,f?f.import:void 0),h,n);return a!==void 0&&(g._pendingEditorState=a,g._dirtyType=2),function(y){y.registerCommand(va,Yd,B),y.registerCommand(ba,Gd,B),y.registerCommand(Ca,Qd,B),y.registerCommand(Sa,Xd,B),y.registerCommand(Na,Zd,B)}(g),g}function kf(n,t){const e=n.get(t);n.delete(t),e&&e()}function En(n,t,e){return n.set(t,e),kf.bind(null,n,t)}class It{constructor(t,e,r,i,s,o,l,a){w(this,"_headless");w(this,"_parentEditor");w(this,"_rootElement");w(this,"_editorState");w(this,"_pendingEditorState");w(this,"_compositionKey");w(this,"_deferred");w(this,"_keyToDOMMap");w(this,"_updates");w(this,"_updating");w(this,"_listeners");w(this,"_commands");w(this,"_nodes");w(this,"_decorators");w(this,"_pendingDecorators");w(this,"_config");w(this,"_dirtyType");w(this,"_cloneNotNeeded");w(this,"_dirtyLeaves");w(this,"_dirtyElements");w(this,"_normalizedNodes");w(this,"_updateTags");w(this,"_observer");w(this,"_key");w(this,"_onError");w(this,"_htmlConversions");w(this,"_window");w(this,"_editable");w(this,"_blockCursorElement");w(this,"_createEditorArgs");this._createEditorArgs=a,this._parentEditor=e,this._rootElement=null,this._editorState=t,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Map,editable:new Map,mutation:new Map,root:new Map,textcontent:new Map,update:new Map},this._commands=new Map,this._config=i,this._nodes=r,this._decorators={},this._pendingDecorators=null,this._dirtyType=0,this._cloneNotNeeded=new Set,this._dirtyLeaves=new Set,this._dirtyElements=new Map,this._normalizedNodes=new Set,this._updateTags=new Set,this._observer=null,this._key=bc(),this._onError=s,this._htmlConversions=o,this._editable=l,this._headless=e!==null&&e._headless,this._window=null,this._blockCursorElement=null}isComposing(){return this._compositionKey!=null}registerUpdateListener(t){return En(this._listeners.update,t)}registerEditableListener(t){return En(this._listeners.editable,t)}registerDecoratorListener(t){return En(this._listeners.decorator,t)}registerTextContentListener(t){return En(this._listeners.textcontent,t)}registerRootListener(t){const e=this._listeners.root;return Te(En(e,t,t(this._rootElement,null)||void 0),()=>function(r,i,s){const o=r.get(i);o&&o(),r.set(i,i(...s)||void 0)}(e,t,[null,this._rootElement]))}registerCommand(t,e,r){r===void 0&&O(35);const i=this._commands;i.has(t)||i.set(t,[new Tn,new Tn,new Tn,new Tn,new Tn]);const s=i.get(t);s===void 0&&O(36,String(t));const o=function(a){return 7&a}(r),l=s[o];return o!==r?l.addFront(e):l.addBack(e),()=>{l.delete(e),s.every(a=>a.size===0)&&i.delete(t)}}registerMutationListener(t,e,r){const i=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(t)).klass,s=this._listeners.mutation;let o=s.get(e);o===void 0&&(o=new Set,s.set(e,o)),o.add(i);const l=r&&r.skipInitialization;return l!==void 0&&l||this.initializeMutationListener(e,i),()=>{o.delete(i),o.size===0&&s.delete(e)}}getRegisteredNode(t){const e=this._nodes.get(t.getType());return e===void 0&&O(37,t.name),e}resolveRegisteredNodeAfterReplacements(t){for(;t.replaceWithKlass;)t=this.getRegisteredNode(t.replaceWithKlass);return t}initializeMutationListener(t,e){const r=this._editorState,i=sl(r).get(e.getType());if(!i)return;const s=new Map;for(const o of i.keys())s.set(o,"created");s.size>0&&t(s,{dirtyLeaves:new Set,prevEditorState:r,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(t,e){const r=this.getRegisteredNode(t);return r.transforms.add(e),r}registerNodeTransform(t,e){const r=this.registerNodeTransformToKlass(t,e),i=[r],s=r.replaceWithKlass;if(s!=null){const o=this.registerNodeTransformToKlass(s,e);i.push(o)}return function(o,l){const a=sl(o.getEditorState()),c=[];for(const d of l){const f=a.get(d);f&&c.push(f)}c.length!==0&&o.update(()=>{for(const d of c)for(const f of d.keys()){const h=ne(f);h&&h.markDirty()}},o._pendingEditorState===null?{tag:jt}:void 0)}(this,i.map(o=>o.klass.getType())),()=>
1{i.forEach(o=>o.transforms.delete(e))}}hasNode(t){return this._nodes.has(t.getType())}hasNodes(t){return t.every(this.hasNode.bind(this))}dispatchCommand(t,e){return F(this,t,e)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(t){const e=this._rootElement;if(t!==e){const r=un(this._config.theme,"root"),i=this._pendingEditorState||this._editorState;if(this._rootElement=t,uc(this,e,t,i),e!==null&&(this._config.disableEvents||ef(e),r!=null&&e.classList.remove(...r)),t!==null){const s=Hs(t),o=t.style;o.userSelect="text",o.whiteSpace="pre-wrap",o.wordBreak="break-word",t.setAttribute("data-lexical-editor","true"),this._window=s,this._dirtyType=2,da(this),this._updateTags.add(jt),Qe(this),this._config.disableEvents||function(l,a){var h;const c=l.ownerDocument;is.set(l,c);const d=(h=Rr.get(c))!=null?h:0;d<1&&c.addEventListener("selectionchange",Ja),Rr.set(c,d+1),l.__lexicalEditor=a;const f=Ua(l);for(let m=0;m<rs.length;m++){const[g,y]=rs[m],p=typeof y=="function"?_=>{jo(_)||(Eo(_),(a.isEditable()||g==="click")&&y(_,a))}:_=>{if(jo(_))return;Eo(_);const x=a.isEditable();switch(g){case"cut":return x&&F(a,As,_);case"copy":return F(a,ci,_);case"paste":return x&&F(a,oi,_);case"dragstart":return x&&F(a,$a,_);case"dragover":return x&&F(a,La,_);case"dragend":return x&&F(a,Wd,_);case"focus":return x&&F(a,Vd,_);case"blur":return x&&F(a,qd,_);case"drop":return x&&F(a,Fa,_)}};l.addEventListener(g,p),f.push(()=>{l.removeEventListener(g,p)})}}(t,this),r!=null&&t.classList.add(...r)}else this._window=null,this._updateTags.add(jt),Qe(this);Rn("root",this,!1,t,e)}}getElementByKey(t){return this._keyToDOMMap.get(t)||null}getEditorState(){return this._editorState}setEditorState(t,e){t.isEmpty()&&O(38);let r=t;r._readOnly&&(r=ac(t),r._selection=t._selection?t._selection.clone():null),ua(this);const i=this._pendingEditorState,s=this._updateTags,o=e!==void 0?e.tag:null;i===null||i.isEmpty()||(o!=null&&s.add(o),Qe(this)),this._pendingEditorState=r,this._dirtyType=2,this._dirtyElements.set("root",!1),this._compositionKey=null,o!=null&&s.add(o),this._updating||Qe(this)}parseEditorState(t,e){return function(r,i,s){const o=Ls(),l=le,a=ve,c=ae,d=i._dirtyElements,f=i._dirtyLeaves,h=i._cloneNotNeeded,m=i._dirtyType;i._dirtyElements=new Map,i._dirtyLeaves=new Set,i._cloneNotNeeded=new Set,i._dirtyType=0,le=o,ve=!1,ae=i,Bs(null);try{const g=i._nodes;$s(r.root,g),s&&s(),o._readOnly=!0}catch(g){g instanceof Error&&i._onError(g)}finally{i._dirtyElements=d,i._dirtyLeaves=f,i._cloneNotNeeded=h,i._dirtyType=m,le=l,ve=a,ae=c}return o}(typeof t=="string"?JSON.parse(t):t,this,e)}read(t){return Qe(this),this.getEditorState().read(t,{editor:this})}update(t,e){(function(r,i,s){r._updating?r._updates.push([i,s]):di(r,i,s)})(this,t,e)}focus(t,e={}){const r=this._rootElement;r!==null&&(r.setAttribute("autocapitalize","off"),ze(this,()=>{const i=D(),s=ee();i!==null?i.dirty||me(i.clone()):s.getChildrenSize()!==0&&(e.defaultSelection==="rootStart"?s.selectStart():s.selectEnd()),gi("focus"),Of(()=>{r.removeAttribute("autocapitalize"),t&&t()})}),this._pendingEditorState===null&&r.removeAttribute("autocapitalize"))}blur(){const t=this._rootElement;t!==null&&t.blur();const e=Ee(this._window);e!==null&&e.removeAllRanges()}isEditable(){return this._editable}setEditable(t){this._editable!==t&&(this._editable=t,Rn("editable",this,!0,t))}toJSON(){return{editorState:this._editorState.toJSON()}}}w(It,"version");It.version="0.44.0+prod.esm";let hs=null;function Bs(n){hs=n}let wf=1;function fc(n,t){const e=zs(n,t);return e===void 0&&O(30,t),e}function zs(n,t){return n._nodes.get(t)}const Tf=typeof queueMicrotask=="function"?queueMicrotask:n=>{Promise.resolve().then(n)};function hc(n){return J(Rt(n))}function Ks(n){const t=document.activeElement;if(!te(t))return!1;const e=t.nodeName;return J(Rt(n))&&(e==="INPUT"||e==="TEXTAREA"||t.contentEditable==="true"&&fi(t)==null)}function ir(n,t,e){const r=n.getRootElement();try{return r!==null&&r.contains(t)&&r.contains(e)&&t!==null&&!Ks(t)&&gc(t)===n}catch(i){return!1}}function Ws(n){return n instanceof It}function gc(n){let t=n;for(;t!=null;){const e=fi(t);if(Ws(e))return e;t=sr(t)}return null}function fi(n){return n?n.__lexicalEditor:null}function Ot(n){return Qa(n)||n.isToken()}function Be(n){return Ot(n)||n.isSegmented()}function st(n){return xn(n)&&n.nodeType===3}function gs(n){return xn(n)&&n.nodeType===9}function hn(n){let t=n;for(;t!=null;){if(st(t))return t;t=t.firstChild}return null}function Ur(n,t,e){const r=Dt[t];if(e!==null&&(n&r)===(e&r))return n;let i=n^r;return t==="subscript"?i&=-65:t==="superscript"?i&=-33:t==="lowercase"?(i&=-513,i&=-1025):t==="uppercase"?(i&=-257,i&=-1025):t==="capitalize"&&(i&=-257,i&=-513),i}function mc(n){return M(n)||cn(n)||J(n)}function pc(n,t){const e=function(){const o=hs;return hs=null,o}();if((t=t||e&&e.__key)!=null)return void(n.__key=t);ge(),rc();const r=G(),i=vt(),s=""+wf++;i._nodeMap.set(s,n),C(n)?r._dirtyElements.set(s,!0):r._dirtyLeaves.add(s),r._cloneNotNeeded.add(s),r._dirtyType=1,n.__key=s}function Mt(n){const t=n.getParent();if(t!==null){const e=n.getWritable(),r=t.getWritable(),i=n.getPreviousSibling(),s=n.getNextSibling(),o=s!==null?s.__key:null,l=i!==null?i.__key:null,a=i!==null?i.getWritable():null,c=s!==null?s.getWritable():null;i===null&&(r.__first=o),s===null&&(r.__last=l),a!==null&&(a.__next=o),c!==null&&(c.__prev=l),e.__prev=null,e.__next=null,e.__parent=null,r.__size--}}function Jr(n){rc(),zr(n)&&O(323,n.__key,n.__type);const t=n.getLatest(),e=t.__parent,r=vt(),i=G(),s=r._nodeMap,o=i._dirtyElements;e!==null&&function(a,c,d){let f=a;for(;f!==null;){if(d.has(f))return;const h=c.get(f);if(h===void 0)break;d.set(f,!1),f=h.__parent}}(e,s,o);const l=t.__key;i._dirtyType=1,C(n)?o.set(l,!0):i._dirtyLeaves.add(l)}function ue(n){ge();const t=G(),e=t._compositionKey;if(n!==e){if(t._compositionKey=n,e!==null){const r=ne(e);r!==null&&r.getWritable()}if(n!==null){const r=ne(n);r!==null&&r.getWritable()}}}function ut(){return nr()?null:G()._compositionKey}function ne(n,t){const e=(t||vt())._nodeMap.get(n);return e===void 0?null:e}function _c(n,t){const e=hi(n,G());return e!==void 0?ne(e,t):null}function hi(n,t){return n["__lexicalKey_".concat(t._key)]}function Rt(n,t){let e=n;for(;e!=null;){const r=_c(e,t);if(r!==null)return r;e=sr(e)}return null}function yc(n){const t=n._decorators,e=Object.assign({},t);return n._pendingDecorators=e,e}function Xo(n){return n.read(()=>ee().getTextContent())}function ee(){return xc(vt())}function xc(n){return n._nodeMap.get("root")}function me(n){ge();const t=vt();n!==null&&(n.dirty=!0,n.setCachedNodes(null)),t._selection=n}function nn(n){const t=G(),e=function(r,i){let s=r;for(;s!=null;){const o=hi(s,i);if(o!==void 0)return o;s=sr(s)}return null}(n,t);return e===null?n===t.getRootElement()?ne("root"):null:ne(e)}function vc(n){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(n)}function Us(n){const t=[];for(let e=n;e!==null;e=e._parentEditor)t.push(e);return t}function bc(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substring(0,5)}function Cc(n){return st(n)?n.nodeValue:null}function Js(n,t,e){const r=Ee(Ce(t));if(r===null)return;const i=r.anchorNode;let{anchorOffset:s,focusOffset:o}=r;if(i!==null){let l=Cc(i);const a=Rt(i);if(l!==null&&M(a)){if((l===Un||l===js)&&e){const c=e.length;l=e,s=c,o=c}l!==null&&Vs(a,l,s,o,n)}}}function Vs(n,t,e,r,i){let s=n;if(s.isAttached()&&(i||!s.isDirty())){const o=s.isComposing();let l=t;if((o||i)&&(t.endsWith(Un)&&(l=t.slice(0,-Un.length)),i)){const c=js;let d;for(;(d=l.indexOf(c))!==-1;)l=l.slice(0,d)+l.slice(d+c.length),e!==null&&e>d&&(e=Math.max(d,e-c.length)),r!==null&&r>d&&(r=Math.max(d,r-c.length))}const a=s.getTextContent();if(i||l!==a){if(l===""){if(ue(null),ni||er||ri)s.remove();else{const y=G();setTimeout(()=>{y.update(()=>{s.isAttached()&&s.remove()})},20)}return}const c=s.getParent(),d=_n(),f=s.getTextContentSize(),h=ut(),m=s.getKey();if(s.isToken()||h!==null&&m===h&&!o||E(d)&&(c!==null&&!c.canInsertTextBefore()&&d.anchor.offset===0||d.anchor.key===n.__key&&d.anchor.offset===0&&!s.canInsertTextBefore()&&!o||d.focus.key===n.__key&&d.focus.offset===f&&!s.canInsertTextAfter()&&!o))return void s.markDirty();const g=D();if(!E(g)||e===null||r===null)return void Zo(s,l,g);if(g.setTextNodeRange(s,e,s,r),s.isSegmented()){const y=se(s.getTextContent());s.replace(y),s=y}Zo(s,l,g)}}}function Zo(n,t,e){if(n.setTextContent(t),E(e)){const r=n.getKey();for(const i of["anchor","focus"]){const s=e[i];s.type==="text"&&s.key===r&&(s.offset=Ke(n,s.offset,"clamp"))}}}function gr(n,t,e){const r=t[e]||!1;return r==="any"||r===n[e]}function Ef(n,t){return gr(n,t,"altKey")&&gr(n,t,"ctrlKey")&&gr(n,t,"shiftKey")&&gr(n,t,"metaKey")}function H(n,t,e){if(!Ef(n,e))return!1;if(n.key.toLowerCase()===t.toLowerCase())return!0;
1if(t.length>1||n.key.length===1&&n.key.charCodeAt(0)<=127)return!1;if(n.code.startsWith("Digit")&&/^\d$/.test(t))return n.code==="Digit".concat(t);const r="Key"+t.toUpperCase();return n.code===r}const Ge={ctrlKey:!Oe,metaKey:Oe},el={altKey:Oe,ctrlKey:!Oe};function tl(n){return n.key==="Backspace"}function nl(n){return H(n,"a",Ge)}function jf(n){const t=ee();if(E(n)){const e=n.anchor,r=n.focus,i=e.getNode().getTopLevelElementOrThrow().getParentOrThrow();return e.set(i.getKey(),0,"element"),r.set(i.getKey(),i.getChildrenSize(),"element"),Pt(n),n}{const e=t.select(0,t.getChildrenSize());return me(Pt(e)),e}}function un(n,t){n.__lexicalClassNameCache===void 0&&(n.__lexicalClassNameCache={});const e=n.__lexicalClassNameCache,r=e[t];if(r!==void 0)return r;const i=n[t];if(typeof i=="string"){const s=yt(i);return e[t]=s,s}return i}function qs(n,t,e,r,i){if(e.size===0)return;const s=r.__type,o=r.__key,l=t.get(s);l===void 0&&O(33,s);const a=l.klass;let c=n.get(a);c===void 0&&(c=new Map,n.set(a,c));const d=c.get(o),f=d==="destroyed"&&i==="created";(d===void 0||f)&&c.set(o,f?"updated":i)}function rl(n,t,e){const r=n.getParent();let i=e,s=n;return r!==null&&(t&&e===0?(i=s.getIndexWithinParent(),s=r):t||e!==s.getChildrenSize()||(i=s.getIndexWithinParent()+1,s=r)),s.getChildAtIndex(t?i-1:i)}function ms(n,t){const e=n.offset;if(n.type==="element")return rl(n.getNode(),t,e);{const r=n.getNode();if(t&&e===0||!t&&e===r.getTextContentSize()){const i=t?r.getPreviousSibling():r.getNextSibling();return i===null?rl(r.getParentOrThrow(),t,r.getIndexWithinParent()+(t?0:1)):i}}return null}function Sc(n){const t=Ce(n).event,e=t&&t.inputType;return e==="insertFromPaste"||e==="insertFromPasteAsQuotation"}function F(n,t,e){return oc(n,t,e,n)}function gn(n,t){const e=n._keyToDOMMap.get(t);return e===void 0&&O(75,t),e}function sr(n){const t=n.assignedSlot||n.parentElement;return ys(t)?t.host:t}function Nc(n){return gs(n)?n:te(n)?n.ownerDocument:null}function gi(n){ge(),G()._updateTags.add(n)}function Of(n){ge(),G()._deferred.push(n)}function ps(n,t){let e=n.getParent();for(;e!==null;){if(e.is(t))return!0;e=e.getParent()}return!1}function Hs(n){const t=Nc(n);return t?t.defaultView:null}function Ce(n){const t=n._window;return t===null&&O(78),t}function Mf(n){let t=n.getParentOrThrow();for(;t!==null;){if(_e(t))return t;t=t.getParentOrThrow()}return t}function _e(n){return ie(n)||C(n)&&n.isShadowRoot()}function fe(n,t=!1){const e=n.constructor.clone(n);return pc(e,null),e.afterCloneFrom(n),t||e.resetOnCopyNodeFrom(n),e}function Ve(n){const t=G(),e=n.getType(),r=zs(t,e);r===void 0&&O(200,n.constructor.name,e);const{replace:i,replaceWithKlass:s}=r;if(i!==null){const o=i(n),l=o.constructor;return s!==null?o instanceof s||O(201,s.name,s.getType(),l.name,l.getType(),n.constructor.name,e):o instanceof n.constructor&&l!==n.constructor||O(202,l.name,l.getType(),n.constructor.name,e),o.__key===n.__key&&O(203,n.constructor.name,e,l.name,l.getType()),o}return n}function Mi(n,t){!ie(n.getParent())||C(t)||J(t)||O(99)}function Af(n){const t=ne(n);return t===null&&O(63,n),t}function Ai(n){return(J(n)||C(n)&&!n.canBeEmpty())&&!n.isInline()}function _s(n,t,e){e.style.removeProperty("caret-color"),t._blockCursorElement=null;const r=n.parentElement;r!==null&&r.removeChild(n)}function Ee(n){return Fe?(n||window).getSelection():null}function Df(n){const t=Hs(n);return t?t.getSelection():null}function kc(n){return te(n)&&n.tagName==="A"}function te(n){return xn(n)&&n.nodeType===1}function xn(n){return typeof n=="object"&&n!==null&&"nodeType"in n&&typeof n.nodeType=="number"}function ys(n){return xn(n)&&n.nodeType===11}function xs(n){const t=new RegExp(/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|mark|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/,"i");return n.nodeName.match(t)!==null}function Vr(n){const t=new RegExp(/^(address|article|aside|blockquote|canvas|dd|div|dl|dt|fieldset|figcaption|figure|footer|form|h1|h2|h3|h4|h5|h6|header|hr|li|main|nav|noscript|ol|p|pre|section|table|td|tfoot|ul|video)$/,"i");return n.nodeName.match(t)!==null}function Se(n){if(J(n)&&!n.isInline())return!0;
1if(!C(n)||_e(n))return!1;const t=n.getFirstChild(),e=t===null||cn(t)||M(t)||t.isInline();return!n.isInline()&&n.canBeEmpty()!==!1&&e}function nt(){return G()}function or(n=nt()){return n._config.dom||Xn}const il=new WeakMap,Pf=new Map;function sl(n){if(!n._readOnly&&n.isEmpty())return Pf;n._readOnly||O(192);let t=il.get(n);return t||(t=function(e){const r=new Map;for(const[i,s]of e._nodeMap){const o=s.__type;let l=r.get(o);l||(l=new Map,r.set(o,l)),l.set(i,s)}return r}(n),il.set(n,t)),t}function wc(n){const t=n.constructor.clone(n);return t.afterCloneFrom(n),t}function Ff(n){return(t=wc(n))[Va]=!0,t;var t}function Ys(n,t){const e=parseInt(n.style.paddingInlineStart,10)||0,r=Math.round(e/40);t.setIndent(r)}function $f(n){return n.__lexicalUnmanaged===!0}function jn(n,t){return function(e,r){return Object.prototype.hasOwnProperty.call(e,r)}(n,t)&&n[t]!==ke[t]}function vn(n){const t=mo in n.prototype?n.prototype[mo]():void 0,e=function(o){if(!(o===ke||o.prototype instanceof ke)){let l="<unknown>",a="<unknown>";try{l=o.getType()}catch(c){}try{It.version&&(a=JSON.parse(It.version))}catch(c){}O(290,o.name,l,a)}return o===lc||o===we||o===ke}(n),r=!e&&jn(n,"getType")?n.getType():void 0;let i,s=r;if(t)if(r)i=t[r];else for(const[o,l]of Object.entries(t))s=o,i=l;if(!e&&s&&(jn(n,"getType")||(n.getType=()=>s),jn(n,"clone")||(n.clone=o=>(Bs(o),new n)),jn(n,"importJSON")||(n.importJSON=i&&i.$importJSON||(o=>new n().updateFromJSON(o))),!jn(n,"importDOM")&&i)){const{importDOM:o}=i;o&&(n.importDOM=()=>o)}return{ownNodeConfig:i,ownNodeType:s}}const de=(n,t)=>{let e=n;for(;e!=null&&!ie(e);){if(t(e))return e;e=e.getParent()}return null};function qr(n,t){const e=[];let r=n.__first;for(;r!==null;){const i=t===null?ne(r):t.get(r);i==null&&O(174),e.push(r),r=i.__next}return e}const Lf={next:"previous",previous:"next"};class Gs{constructor(t){w(this,"origin");this.origin=t}[Symbol.iterator](){return Ec({hasNext:gt,initial:this.getAdjacentCaret(),map:t=>t,step:t=>t.getAdjacentCaret()})}getAdjacentCaret(){return Z(this.getNodeAtCaret(),this.direction)}getSiblingCaret(){return Z(this.origin,this.direction)}remove(){const t=this.getNodeAtCaret();return t&&t.remove(),this}replaceOrInsert(t,e){const r=this.getNodeAtCaret();return t.is(this.origin)||t.is(r)||(r===null?this.insert(t):r.replace(t,e)),this}splice(t,e,r="next"){const i=r===this.direction?e:Array.from(e).reverse();let s=this;const o=this.getParentAtCaret(),l=new Map;for(let a=s.getAdjacentCaret();a!==null&&l.size<t;a=a.getAdjacentCaret()){const c=a.origin.getWritable();l.set(c.getKey(),c)}for(const a of i){if(l.size>0){const c=s.getNodeAtCaret();if(c){if(l.delete(c.getKey()),l.delete(a.getKey()),!(c.is(a)||s.origin.is(a))){const d=a.getParent();d&&d.is(o)&&a.remove(),c.replace(a)}}else c===null&&O(263,Array.from(l).join(" "))}else s.insert(a);s=Z(a,this.direction)}for(const a of l.values())a.remove();return this}}class Zn extends Gs{constructor(){super(...arguments);w(this,"type","child")}getLatest(){const e=this.origin.getLatest();return e===this.origin?this:be(e,this.direction)}getParentCaret(e="root"){return Z(Qs(this.getParentAtCaret(),e),this.direction)}getFlipped(){const e=Vt(this.direction);return Z(this.getNodeAtCaret(),e)||be(this.origin,e)}getParentAtCaret(){return this.origin}getChildCaret(){return this}isSameNodeCaret(e){return e instanceof Zn&&this.direction===e.direction&&this.origin.is(e.origin)}isSamePointCaret(e){return this.isSameNodeCaret(e)}}const If={root:ie,shadowRoot:_e};function Vt(n){return Lf[n]}function Qs(n,t="root"){return If[t](n)?null:n}class Bt extends Gs{constructor(){super(...arguments);w(this,"type","sibling")}getLatest(){const e=this.origin.getLatest();return e===this.origin?this:Z(e,this.direction)}getSiblingCaret(){return this}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return C(this.origin)?be(this.origin,this.direction):null}getParentCaret(e="root"){return Z(Qs(this.getParentAtCaret(),e),this.direction)}getFlipped(){const e=Vt(this.direction);return Z(this.getNodeAtCaret(),e)||be(this.origin.getParentOrThrow(),e)}isSamePointCaret(e){return e instanceof Bt&&this.direction===e.direction&&this.origin.is(e.origin)}isSameNodeCaret(e){return(e instanceof Bt||e instanceof zt)&&this.direction===e.direction&&this.origin.is(e.origin)}}class zt extends Gs{constructor(e,r){super(e);w(this,"type","text");w(this,"offset");this.offset=r}getLatest(){const e=this.origin.getLatest();return e===this.origin?this:mt(e,this.direction,this.offset)}getParentAtCaret(){return this.origin.getParent()}getChildCaret(){return null}getParentCaret(e="root"){return Z(Qs(this.getParentAtCaret(),e),this.direction)}getFlipped(){return mt(this.origin,Vt(this.direction),this.offset)}isSamePointCaret(e){return e instanceof zt&&this.direction===e.direction&&this.origin.is(e.origin)&&this.offset===e.offset}isSameNodeCaret(e){return(e instanceof Bt||e instanceof zt)&&this.direction===e.direction&&this.origin.is(e.origin)}getSiblingCaret(){return Z(this.origin,this.direction)}}function De(n){return n instanceof zt}function gt(n){return n instanceof Bt}function Pe(n){return n instanceof Zn}const Rf={next:class extends zt{constructor(){super(...arguments);w(this,"direction","next")}getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends zt{constructor(){super(...arguments);w(this,"direction","previous")}
1getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},Bf={next:class extends Bt{constructor(){super(...arguments);w(this,"direction","next")}getNodeAtCaret(){return this.origin.getNextSibling()}insert(t){return this.origin.insertAfter(t),this}},previous:class extends Bt{constructor(){super(...arguments);w(this,"direction","previous")}getNodeAtCaret(){return this.origin.getPreviousSibling()}insert(t){return this.origin.insertBefore(t),this}}},zf={next:class extends Zn{constructor(){super(...arguments);w(this,"direction","next")}getNodeAtCaret(){return this.origin.getFirstChild()}insert(t){return this.origin.splice(0,0,[t]),this}},previous:class extends Zn{constructor(){super(...arguments);w(this,"direction","previous")}getNodeAtCaret(){return this.origin.getLastChild()}insert(t){return this.origin.splice(this.origin.getChildrenSize(),0,[t]),this}}};function Z(n,t){return n?new Bf[t](n):null}function mt(n,t,e){return n?new Rf[t](n,Ke(n,e)):null}function Ke(n,t,e="error"){const r=n.getTextContentSize();let i=t==="next"?r:t==="previous"?0:t;return(i<0||i>r)&&(e!=="clamp"&&ia(284,String(t),String(r),n.getKey()),i=i<0?0:r),i}function ol(n,t){return new Wf(n,t)}function be(n,t){return C(n)?new zf[t](n):null}function Kf(n){return n&&n.getChildCaret()||n}function Xs(n){return n&&Kf(n.getAdjacentCaret())}class Zs{constructor(t,e,r){w(this,"type","node-caret-range");w(this,"direction");w(this,"anchor");w(this,"focus");this.anchor=t,this.focus=e,this.direction=r}getLatest(){const t=this.anchor.getLatest(),e=this.focus.getLatest();return t===this.anchor&&e===this.focus?this:new Zs(t,e,this.direction)}isCollapsed(){return this.anchor.isSamePointCaret(this.focus)}getTextSlices(){const t=i=>{const s=this[i].getLatest();return De(s)?function(o,l){const{direction:a,origin:c}=o,d=Ke(c,l==="focus"?Vt(a):a);return ol(o,d-o.offset)}(s,i):null},e=t("anchor"),r=t("focus");if(e&&r){const{caret:i}=e,{caret:s}=r;if(i.isSameNodeCaret(s))return[ol(i,s.offset-i.offset),null]}return[e,r]}iterNodeCarets(t="root"){const e=De(this.anchor)?this.anchor.getSiblingCaret():this.anchor.getLatest(),r=this.focus.getLatest(),i=De(r),s=o=>o.isSameNodeCaret(r)?null:Xs(o)||o.getParentCaret(t);return Ec({hasNext:o=>o!==null&&!(i&&r.isSameNodeCaret(o)),initial:e.isSameNodeCaret(r)?null:s(e),map:o=>o,step:s})}[Symbol.iterator](){return this.iterNodeCarets("root")}}class Wf{constructor(t,e){w(this,"type","slice");w(this,"caret");w(this,"distance");this.caret=t,this.distance=e}getSliceIndices(){const{distance:t,caret:{offset:e}}=this,r=e+t;return r<e?[r,e]:[e,r]}getTextContent(){const[t,e]=this.getSliceIndices();return this.caret.origin.getTextContent().slice(t,e)}getTextContentSize(){return Math.abs(this.distance)}removeTextSlice(){const{caret:{origin:t,direction:e}}=this,[r,i]=this.getSliceIndices(),s=t.getTextContent();return mt(t.setTextContent(s.slice(0,r)+s.slice(i)),e,r)}}function eo(n){return pt(n,Z(ee(),n.direction))}function Tc(n){return pt(n,n)}function pt(n,t){return n.direction!==t.direction&&O(265),new Zs(n,t,n.direction)}function Ec(n){const{initial:t,hasNext:e,step:r,map:i}=n;let s=t;return{[Symbol.iterator](){return this},next(){if(!e(s))return{done:!0,value:void 0};const o={done:!1,value:i(s)};return s=r(s),o}}}function Hr(n,t){const e=jr(n.origin,t.origin);switch(e===null&&O(275,n.origin.getKey(),t.origin.getKey()),e.type){case"same":{const r=n.type==="text",i=t.type==="text";return r&&i?function(s,o){return Math.sign(s-o)}(n.offset,t.offset):n.type===t.type?0:r?-1:i?1:n.type==="child"?-1:1}case"ancestor":return n.type==="child"?-1:1;case"descendant":return t.type==="child"?1:-1;case"branch":return jc(e)}}function jc(n){const{a:t,b:e}=n,r=t.__key,i=e.__key;let s=t,o=e;for(;s&&o;s=s.getNextSibling(),o=o.getNextSibling()){if(s.__key===i)return-1;if(o.__key===r)return 1}return s===null?1:-1}function mr(n,t){return t.is(n)}function ll(n){return C(n)?[n.getLatest(),null]:[n.getParent(),n.getLatest()]}function jr(n,t){if(n.is(t))return{commonAncestor:n,type:"same"};const e=new Map;for(let[r,i]=ll(n);r;i=r,r=r.getParent())e.set(r,i);for(let[r,i]=ll(t);r;i=r,r=r.getParent()){const s=e.get(r);if(s!==void 0)return s===null?(mr(n,r)||O(276),{commonAncestor:r,type:"ancestor"}):i===null?(mr(t,r)||O(277),{commonAncestor:r,type:"descendant"}):((C(s)||mr(n,s))&&(C(i)||mr(t,i))&&r.is(s.getParent())&&r.is(i.getParent())||O(278),{a:s,b:i,commonAncestor:r,type:"branch"})}return null}function Ue(n,t){const{type:e,key:r,offset:i}=n,s=Af(n.key);
1return e==="text"?(M(s)||O(266,s.getType(),r),mt(s,t,i)):(C(s)||O(267,s.getType(),r),vs(s,n.offset,t))}function _t(n,t){const{origin:e,direction:r}=t,i=r==="next";De(t)?n.set(e.getKey(),t.offset,"text"):gt(t)?M(e)?n.set(e.getKey(),Ke(e,r),"text"):n.set(e.getParentOrThrow().getKey(),e.getIndexWithinParent()+(i?1:0),"element"):(Pe(t)&&C(e)||O(268),n.set(e.getKey(),i?0:e.getChildrenSize(),"element"))}function Oc(n){const t=D(),e=E(t)?t:Ps();return Or(e,n),me(e),e}function Or(n,t){_t(n.anchor,t.anchor),_t(n.focus,t.focus)}function Yr(n){const{anchor:t,focus:e}=n,r=Ue(t,"next"),i=Ue(e,"next"),s=Hr(r,i)<=0?"next":"previous";return pt(rt(r,s),rt(i,s))}function bt(n){const{direction:t,origin:e}=n,r=Z(e,Vt(t)).getNodeAtCaret();return r?Z(r,t):be(e.getParentOrThrow(),t)}function al(n,t="root"){const e=[n];for(let r=Pe(n)?n.getParentCaret(t):n.getSiblingCaret();r!==null;r=r.getParentCaret(t))e.push(bt(r));return e}function Di(n){return!!n&&n.origin.isAttached()}function Uf(n,t="removeEmptySlices"){if(n.isCollapsed())return n;const e="root",r="next";let i=t;const s=to(n,r),o=al(s.anchor,e),l=al(s.focus.getFlipped(),e),a=new Set,c=[];for(const g of s.iterNodeCarets(e))if(Pe(g))a.add(g.origin.getKey());else if(gt(g)){const{origin:y}=g;C(y)&&!a.has(y.getKey())||c.push(y)}for(const g of c)g.remove();for(const g of s.getTextSlices()){if(!g)continue;const{origin:y}=g.caret,p=y.getTextContentSize(),_=bt(Z(y,r)),x=y.getMode();if(Math.abs(g.distance)===p&&i==="removeEmptySlices"||x==="token"&&g.distance!==0)_.remove();else if(g.distance!==0){i="removeEmptySlices";let b=g.removeTextSlice();const N=g.caret.origin;if(x==="segmented"){const j=b.origin,v=se(j.getTextContent()).setStyle(j.getStyle()).setFormat(j.getFormat());_.replaceOrInsert(v),b=mt(v,r,b.offset)}N.is(o[0].origin)&&(o[0]=b),N.is(l[0].origin)&&(l[0]=b.getFlipped())}}let d,f;for(const g of o)if(Di(g)){d=xe(g);break}for(const g of l)if(Di(g)){f=xe(g);break}const h=function(g,y,p){if(!g||!y)return null;const _=g.getParentAtCaret(),x=y.getParentAtCaret();if(!_||!x)return null;const b=_.getParents().reverse();b.push(_);const N=x.getParents().reverse();N.push(x);const j=Math.min(b.length,N.length);let v;for(v=0;v<j&&b[v]===N[v];v++);const k=(A,$)=>{let z;for(let R=v;R<A.length;R++){const U=A[R];if(_e(U))return;!z&&$(U)&&(z=U)}return z},S=k(b,Se),T=S&&k(N,A=>p.has(A.getKey())&&Se(A));return S&&T?[S,T]:null}(d,f,a);if(h){const[g,y]=h;be(g,"previous").splice(0,y.getChildren());let p=y.getParent();for(y.remove(!0);p&&p.isEmpty();){const _=p;p=p.getParent(),_.remove(!0)}}const m=[d,f,...o,...l].find(Di);if(m)return Tc(rt(xe(m),n.direction));O(269,JSON.stringify(o.map(g=>g.origin.__key)))}function xe(n){const t=function(i){let s=i;for(;Pe(s);){const o=Xs(s);if(!Pe(o))break;s=o}return s}(n.getLatest()),{direction:e}=t;if(M(t.origin))return De(t)?t:mt(t.origin,e,e);const r=t.getAdjacentCaret();return gt(r)&&M(r.origin)?mt(r.origin,e,Vt(e)):t}function Mc(n){return De(n)&&n.offset!==Ke(n.origin,n.direction)}function rt(n,t){return n.direction===t?n:n.getFlipped()}function to(n,t){return n.direction===t?n:pt(rt(n.focus,t),rt(n.anchor,t))}function vs(n,t,e){let r=be(n,"next");for(let i=0;i<t;i++){const s=r.getAdjacentCaret();if(s===null)break;r=s}return rt(r,e)}function Jf(n){const{origin:t,offset:e,direction:r}=n;if(e===Ke(t,r))return n.getSiblingCaret();if(e===Ke(t,Vt(r)))return bt(n.getSiblingCaret());const[i]=t.splitText(e);return M(i)||O(281),rt(Z(i,"next"),r)}function Vf(n,t){return!0}function Ac(n,{$copyElementNode:t=fe,$splitTextPointCaretNext:e=Jf,rootMode:r="shadowRoot",$shouldSplit:i=Vf,removeEmptyDestination:s=!1}={}){if(De(n))return e(n);const o=n.getParentCaret(r);if(o){const{origin:l}=o;if(Pe(n)){const c=bt(o);if(s&&l.isEmpty())return l.remove(),c;if(!l.canBeEmpty()||!i(l,"first"))return c}const a=function(c){const d=[];for(let f=c.getAdjacentCaret();f;f=f.getAdjacentCaret())d.push(f.origin);return d}(n);(a.length>0||!s&&l.canBeEmpty()&&i(l,"last"))&&o.insert(t(l).splice(0,0,a))}return o}function qf(...n){return n}function no(n,t){if(!t||n===t)return n;for(const e in t)if(n[e]!==t[e])return{...n,...t};return n}function yt(...n){const t=[];for(const e of n)if(e&&typeof e=="string")for(const[r]of e.matchAll(/\S+/g))t.push(r);return t}function lr(n,...t){const e=yt(...t);e.length>0&&n.classList.add(...e)}function Dc(n,...t){const e=yt(...t);e.length>0&&n.classList.remove(...e)}function Te(...n){return()=>{for(let t=n.length-1;t>=0;t--)n[t]();n.length=0}}function Hf(n,...t){const e=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const i of t)r.append("v",i);throw e.search=r.toString(),Error("Minified Lexical error #".concat(n,"; visit ").concat(e.toString()," for the full message or use the non-minified dev environment for full errors and additional helpful warnings."))}function Yf(n){let t="";for(const e in n)e&&(t+="".concat(e,": ").concat(n[e],";"));return t}function Pc(n){const t=nt().getElementByKey(n.getKey());if(t===null)return null;const e=t.ownerDocument.defaultView;return e===null?null:e.getComputedStyle(t)}function Fc(n){return Pc(ie(n)?n:n.getParentOrThrow())}function cl(n){const t=Fc(n);return t!==null&&t.direction==="rtl"}function $c(n,t,e="self"){const r=n.getStartEndPoints();if(t.isSelected(n)&&!Be(t)&&r!==null){const[i,s]=r,o=n.isBackward(),l=i.getNode(),a=s.getNode(),c=t.is(l),d=t.is(a);if(c||d){const[f,h]=ds(n),m=l.is(a),g=t.is(o?a:l),y=t.is(o?l:a);let p,_=0;m?(_=f>h?h:f,p=f>h?f:h):g?(_=o?h:f,p=void 0):y&&(_=0,p=o?f:h);const x=t.__text.slice(_,p);x!==t.__text&&(e==="clone"&&(t=Ff(t)),t.__text=x)}}return t}function pr(n,t){(E(n)?n.isCollapsed():M(n)||C(n))||Hf(280);const e=$t(E(n)?n.style:M(n)?n.getStyle():n.getTextStyle()),r=Yf(Object.entries(t).reduce((i,[s,o])=>(typeof o=="function"?i[s]=o(e[s],n):o===null?delete i[s]:i[s]=o,i),{...e}));E(n)||M(n)?n.setStyle(r):n.setTextStyle(r)}function ul(n,t){if(E(n)&&n.isCollapsed()){pr(n,t);const r=n.anchor.getNode();C(r)&&r.isEmpty()&&pr(r,t)}Gf(r=>{pr(r,t)});const e=n.getNodes();if(e.length>0){const r=new Set;
1for(const i of e){if(!C(i)||!i.canBeEmpty()||i.getChildrenSize()!==0)continue;const s=i.getKey();r.has(s)||(r.add(s),pr(i,t))}}}function Gf(n){const t=D();if(!t)return;const e=new Map,r=s=>e.get(s.getKey())||[0,s.getTextContentSize()];if(E(t))for(const s of Yr(t).getTextSlices())s&&e.set(s.caret.origin.getKey(),s.getSliceIndices());const i=t.getNodes();for(const s of i){if(!M(s)||!s.canHaveFormat())continue;const[o,l]=r(s);l!==o&&(Be(s)||o===0&&l===s.getTextContentSize()?n(s):n(s.splitText(o,l)[o===0?0:1]))}E(t)&&t.anchor.type==="text"&&t.focus.type==="text"&&t.anchor.key===t.focus.key&&Qf(t)}function Qf(n){if(n.isBackward()){const{anchor:t,focus:e}=n,{key:r,offset:i,type:s}=t;t.set(e.key,e.offset,e.type),e.set(r,i,s)}}function Xf(n,t){const e=n.getFormatType(),r=n.getIndent();e!==t.getFormatType()&&t.setFormat(e),r!==t.getIndent()&&t.setIndent(r)}function _r(n,t,e=Xf){if(n===null)return;const r=n.getStartEndPoints(),i=new Map;let s=null;if(r){const[o,l]=r;s=Ps(),s.anchor.set(o.key,o.offset,o.type),s.focus.set(l.key,l.offset,l.type);const a=de(o.getNode(),Se),c=de(l.getNode(),Se);C(a)&&i.set(a.getKey(),a),C(c)&&i.set(c.getKey(),c)}for(const o of n.getNodes())if(C(o)&&Se(o))i.set(o.getKey(),o);else if(r===null){const l=de(o,Se);C(l)&&i.set(l.getKey(),l)}for(const[o,l]of i){const a=t();e(l,a),l.replace(a,!0),s&&(o===s.anchor.key&&s.anchor.set(a.getKey(),s.anchor.offset,s.anchor.type),o===s.focus.key&&s.focus.set(a.getKey(),s.focus.offset,s.focus.type))}s&&n.is(D())&&me(s)}function Lc(n){const t=Ic(n);return t!==null&&t.writingMode==="vertical-rl"}function Ic(n){const t=n.anchor.getNode();return C(t)?Pc(t):Fc(t)}function dl(n,t){let e=Lc(n)?!t:t;Rc(n)&&(e=!e);const r=Ue(n.focus,e?"previous":"next");if(Mc(r))return!1;for(const i of eo(r)){if(Pe(i))return!i.origin.isInline();if(!C(i.origin)){if(J(i.origin))return!0;break}}return!1}function Zf(n,t,e,r){n.modify(t?"extend":"move",e,r)}function Rc(n){const t=Ic(n);return t!==null&&t.direction==="rtl"}function fl(n,t,e){const r=Rc(n);let i;i=Lc(n)||r?!e:e,Zf(n,t,i,"character")}function eh(n,t,e){const r=n.getStyle(),i=$t(r);return i!==null&&i[t]||e}function yr(n,t,e=""){let r=null;const i=n.getNodes(),s=n.anchor,o=n.focus,l=n.isBackward(),a=l?o.getNode():s.getNode(),c=l?s.getNode():o.getNode(),d=l?o.offset:s.offset,f=l?s.offset:o.offset;if(E(n)&&n.isCollapsed()&&n.style!==""){const h=n.style,m=$t(h);if(m!==null&&t in m)return m[t]}for(let h=0;h<i.length;h++){const m=i[h];if((h!==0||!m.is(a)||!M(m)||d!==m.getTextContentSize())&&(h===0||!m.is(c)||f!==0)&&M(m)){const g=eh(m,t,e);if(r===null)r=g;else if(r!==g){r="";break}}}return r===null?e:r}function bs(n,...t){const e=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const i of t)r.append("v",i);throw e.search=r.toString(),Error("Minified Lexical error #".concat(n,"; visit ").concat(e.toString()," for the full message or use the non-minified dev environment for full errors and additional helpful warnings."))}const Bc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,th=Bc&&"documentMode"in document?document.documentMode:null;!(!Bc||!("InputEvent"in window)||th)&&"getTargetRanges"in new window.InputEvent("input");function nh(n,t){let e=n;for(;e!=null;){if(e instanceof t)return e;e=e.getParent()}return null}function rh(n){const t=de(n,e=>C(e)&&!e.isInline());return C(t)||bs(4,n.__key),t}function zc(n,t,e){let r=rt(t,"next");De(r)&&(r.offset===0?r=Z(r.origin,"previous").getFlipped():r.offset===r.origin.getTextContentSize()&&(r=Z(r.origin,"next"))),r.origin.is(n)&&(gt(r)||bs(342,n.getKey(),n.getType()),r=bt(r)),(n.is(r.getNodeAtCaret())||n.is(r.getFlipped().getNodeAtCaret()))&&n.remove(!0);for(let i=r;i;i=Ac(i,e))r=i;return De(r)&&bs(283),r.insert(n.isInline()?Q().append(n):n),rt(Z(n.getLatest(),"next"),t.direction)}function dt(n,t){return n!==null&&Object.getPrototypeOf(n).constructor.name===t.name}function hl(n){const t=D();if(!E(t))return!1;const e=new Set,r=t.getNodes();for(let i=0;i<r.length;i++){const s=r[i],o=s.getKey();if(e.has(o))continue;const l=de(s,c=>C(c)&&!c.isInline());if(l===null)continue;const a=l.getKey();l.canIndent()&&!e.has(a)&&(e.add(a),n(l))}return e.size>0}const ih=Symbol.for("preact-signals");function mi(){if(tt>1)return void tt--;let n,t=!1;for(!function(){let e=Gr;for(Gr=void 0;e!==void 0;)e.S.v===e.v&&(e.S.i=e.i),e=e.o}();zn!==void 0;){let e=zn;for(zn=void 0,Qr++;e!==void 0;){const r=e.u;if(e.u=void 0,e.f&=-3,!(8&e.f)&&Kc(e))try{e.c()}catch(i){t||(n=i,t=!0)}e=r}}if(Qr=0,tt--,t)throw n}function sh(n){if(tt>0)return n();Cs=++oh,tt++;try{return n()}finally{mi()}}let q,zn;function gl(n){const t=q;q=void 0;try{return n()}finally{q=t}}let Gr,tt=0,Qr=0,oh=0,Cs=0,Mr=0;function ml(n){if(q===void 0)return;let t=n.n;return t===void 0||t.t!==q?(t={i:0,S:n,p:q.s,n:void 0,t:q,e:void 0,x:void 0,r:t},q.s!==void 0&&(q.s.n=t),q.s=t,n.n=t,32&q.f&&n.S(t),t):t.i===-1?(t.i=0,t.n!==void 0&&(t.n.p=t.p,t.p!==void 0&&(t.p.n=t.n),t.p=q.s,t.n=void 0,q.s.n=t,q.s=t),t):void 0}function pe(n,t){this.v=n,this.i=0,this.n=void 0,this.t=void 0,this.l=0,this.W=t==null?void 0:t.watched,this.Z=t==null?void 0:t.unwatched,this.name=t==null?void 0:t.name}function lh(n,t){return new pe(n,t)}function Kc(n){for(let t=n.s;t!==void 0;t=t.n)if(t.S.i!==t.i||!t.S.h()||t.S.i!==t.i)return!0;return!1}function pl(n){for(let t=n.s;t!==void 0;t=t.n){const e=t.S.n;if(e!==void 0&&(t.r=e),t.S.n=t,t.i=-1,t.n===void 0){n.s=t;break}}}function Wc(n){let t,e=n.s;for(;e!==void 0;){const r=e.p;e.i===-1?(e.S.U(e),r!==void 0&&(r.n=e.n),e.n!==void 0&&(e.n.p=r)):t=e,e.S.n=e.r,e.r!==void 0&&(e.r=void 0),e=r}n.s=t}function Yt(n,t){pe.call(this,void 0),this.x=n,this.s=void 0,this.g=Mr-1,this.f=4,this.W=t==null?void 0:t.watched,this.Z=t==null?void 0:t.unwatched,this.name=t==null?void 0:t.name}function Uc(n){const t=n.m;if(n.m=void 0,typeof t=="function"){tt++;const e=q;q=void 0;try{t()}catch(r){throw n.f&=-2,n.f|=8,ro(n),r}finally{q=e,mi()}}}function ro(n){for(let t=n.s;t!==void 0;t=t.n)t.S.U(t);n.x=void 0,n.s=void 0,Uc(n)}function ah(n){if(q!==this)throw new Error("Out-of-order effect");Wc(this),q=n,this.f&=-2,8&this.f&&ro(this),mi()}function tn(n,t){this.x=n,this.m=void 0,this.s=void 0,this.u=void 0,this.f=32,this.name=t==null?void 0:t.name}function pi(n,t){const e=new tn(n,t);try{e.c()}catch(i){throw e.d(),i}const r=e.d.bind(e);return r[Symbol.dispose]=r,r}function io(n,t={}){const e={};for(const r in n){const i=t[r],s=lh(i===void 0?n[r]:i);e[r]=s}return e}pe.prototype.brand=ih,pe.prototype.h=function(){return!0},pe.prototype.S=function(n){const t=this.t;t!==n&&n.e===void 0&&(n.x=t,this.t=n,t!==void 0?t.e=n:gl(()=>{var e;(e=this.W)==null||e.call(this)}))},pe.prototype.U=function(n){if(this.t!==void 0){const t=n.e,e=n.x;t!==void 0&&(t.x=e,n.e=void 0),e!==void 0&&(e.e=t,n.x=void 0),n===this.t&&(this.t=e,e===void 0&&gl(()=>{var r;(r=this.Z)==null||r.call(this)}))}},pe.prototype.subscribe=function(n){return pi(()=>{const t=this.value,e=q;q=void 0;try{n(t)}finally{q=e}},{name:"sub"})},pe.prototype.valueOf=function(){return this.value},pe.prototype.toString=function(){return this.value+""},pe.prototype.toJSON=function(){return this.value},pe.prototype.peek=function(){const n=q;q=void 0;try{return this.value}finally{q=n}},Object.defineProperty(pe.prototype,"value",{get(){const n=ml(this);return n!==void 0&&(n.i=this.i),this.v},set(n){if(n!==this.v){if(Qr>100)throw new Error("Cycle detected");
1(function(t){tt!==0&&Qr===0&&t.l!==Cs&&(t.l=Cs,Gr={S:t,v:t.v,i:t.i,o:Gr})})(this),this.v=n,this.i++,Mr++,tt++;try{for(let t=this.t;t!==void 0;t=t.x)t.t.N()}finally{mi()}}}}),Yt.prototype=new pe,Yt.prototype.h=function(){if(this.f&=-3,1&this.f)return!1;if((36&this.f)==32||(this.f&=-5,this.g===Mr))return!0;if(this.g=Mr,this.f|=1,this.i>0&&!Kc(this))return this.f&=-2,!0;const n=q;try{pl(this),q=this;const t=this.x();(16&this.f||this.v!==t||this.i===0)&&(this.v=t,this.f&=-17,this.i++)}catch(t){this.v=t,this.f|=16,this.i++}return q=n,Wc(this),this.f&=-2,!0},Yt.prototype.S=function(n){if(this.t===void 0){this.f|=36;for(let t=this.s;t!==void 0;t=t.n)t.S.S(t)}pe.prototype.S.call(this,n)},Yt.prototype.U=function(n){if(this.t!==void 0&&(pe.prototype.U.call(this,n),this.t===void 0)){this.f&=-33;for(let t=this.s;t!==void 0;t=t.n)t.S.U(t)}},Yt.prototype.N=function(){if(!(2&this.f)){this.f|=6;for(let n=this.t;n!==void 0;n=n.x)n.t.N()}},Object.defineProperty(Yt.prototype,"value",{get(){if(1&this.f)throw new Error("Cycle detected");const n=ml(this);if(this.h(),n!==void 0&&(n.i=this.i),16&this.f)throw this.v;return this.v}}),tn.prototype.c=function(){const n=this.S();try{if(8&this.f||this.x===void 0)return;const t=this.x();typeof t=="function"&&(this.m=t)}finally{n()}},tn.prototype.S=function(){if(1&this.f)throw new Error("Cycle detected");this.f|=1,this.f&=-9,Uc(this),pl(this),tt++;const n=q;return q=this,ah.bind(this,n)},tn.prototype.N=function(){2&this.f||(this.f|=2,this.u=zn,zn=this)},tn.prototype.d=function(){this.f|=8,1&this.f||ro(this)},tn.prototype.dispose=function(){this.d()};function ch(n){const t=new Set,e=new Set;for(const r of Jc(n)){const i=typeof r=="function"?r:r.replace;vn(i),t.add(i.getType()),e.add(i)}return{nodes:e,types:t}}function Jc(n){return(typeof n.nodes=="function"?n.nodes():n.nodes)||[]}fa("format",{parse:n=>typeof n=="number"?n:0});function Y(n,...t){const e=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const i of t)r.append("v",i);throw e.search=r.toString(),Error("Minified Lexical error #".concat(n,"; visit ").concat(e.toString()," for the full message or use the non-minified dev environment for full errors and additional helpful warnings."))}function Vc(n,t){if(n&&t&&!Array.isArray(t)&&typeof n=="object"&&typeof t=="object"){const e=n,r=t;for(const i in r)e[i]=Vc(e[i],r[i]);return n}return t}const so=0,Ss=1,qc=2,Pi=3,xr=4,Gt=5,Fi=6,On=7;function $i(n){return n.id===so}function Hc(n){return n.id===qc}function uh(n){return function(t){return t.id===Ss}(n)||Y(305,String(n.id),String(Ss)),Object.assign(n,{id:qc})}const dh=new Set;class fh{constructor(t,e){w(this,"builder");w(this,"configs");w(this,"_dependency");w(this,"_peerNameSet");w(this,"extension");w(this,"state");w(this,"_signal");this.builder=t,this.extension=e,this.configs=new Set,this.state={id:so}}mergeConfigs(){let t=this.extension.config||{};const e=this.extension.mergeConfig?this.extension.mergeConfig.bind(this.extension):no;for(const r of this.configs)t=e(t,r);return t}init(t){const e=this.state;Hc(e)||Y(306,String(e.id));const r={getDependency:this.getInitDependency.bind(this),getDirectDependentNames:this.getDirectDependentNames.bind(this),getPeer:this.getInitPeer.bind(this),getPeerNameSet:this.getPeerNameSet.bind(this)},i={...r,getDependency:this.getDependency.bind(this),getInitResult:this.getInitResult.bind(this),getPeer:this.getPeer.bind(this)},s=function(l,a,c){return Object.assign(l,{config:a,id:Pi,registerState:c})}(e,this.mergeConfigs(),r);let o;this.state=s,this.extension.init&&(o=this.extension.init(t,s.config,r)),this.state=function(l,a,c){return Object.assign(l,{id:xr,initResult:a,registerState:c})}(s,o,i)}build(t){const e=this.state;let r;e.id!==xr&&Y(307,String(e.id),String(Gt)),this.extension.build&&(r=this.extension.build(t,e.config,e.registerState));const i={...e.registerState,getOutput:()=>r,getSignal:this.getSignal.bind(this)};this.state=function(s,o,l){return Object.assign(s,{id:Gt,output:o,registerState:l})}(e,r,i)}register(t,e){this._signal=e;const r=this.state;r.id!==Gt&&Y(308,String(r.id),String(Gt));const i=this.extension.register&&this.extension.register(t,r.config,r.registerState);return this.state=function(s){return Object.assign(s,{id:Fi})}(r),()=>{const s=this.state;s.id!==On&&Y(309,String(r.id),String(On)),this.state=function(o){return Object.assign(o,{id:Gt})}(s),i&&i()}}afterRegistration(t){const e=this.state;let r;return e.id!==Fi&&Y(310,String(e.id),String(Fi)),this.extension.afterRegistration&&(r=this.extension.afterRegistration(t,e.config,e.registerState)),this.state=function(i){return Object.assign(i,{id:On})}(e),r}getSignal(){return this._signal===void 0&&Y(311),this._signal}getInitResult(){this.extension.init===void 0&&Y(312,this.extension.name);const t=this.state;return function(e){return e.id>=xr}(t)||Y(313,String(t.id),String(xr)),t.initResult}getInitPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionInitDependency():void 0}getExtensionInitDependency(){const t=this.state;return function(e){return e.id>=Pi}(t)||Y(314,String(t.id),String(Pi)),{config:t.config}}getPeer(t){const e=this.builder.extensionNameMap.get(t);return e?e.getExtensionDependency():void 0}getInitDependency(t){const e=this.builder.getExtensionRep(t);return e===void 0&&Y(315,this.extension.name,t.name),e.getExtensionInitDependency()}getDependency(t){const e=this.builder.getExtensionRep(t);return e===void 0&&Y(315,this.extension.name,t.name),e.getExtensionDependency()}getState(){const t=this.state;return function(e){return e.id>=On}(t)||Y(316,String(t.id),String(On)),t}getDirectDependentNames(){return this.builder.incomingEdges.get(this.extension.name)||dh}getPeerNameSet(){let t=this._peerNameSet;
1return t||(t=new Set((this.extension.peerDependencies||[]).map(([e])=>e)),this._peerNameSet=t),t}getExtensionDependency(){if(!this._dependency){const t=this.state;(function(e){return e.id>=Gt})(t)||Y(317,this.extension.name),this._dependency={config:t.config,init:t.initResult,output:t.output}}return this._dependency}}const _l={tag:jt};function hh(){const n=ee();n.isEmpty()&&n.append(Q())}const gh={config:{setOptions:_l,updateOptions:_l},init:({$initialEditorState:n=hh})=>({$initialEditorState:n,initialized:!1}),afterRegistration(n,{updateOptions:t,setOptions:e},r){const i=r.getInitResult();if(!i.initialized){i.initialized=!0;const{$initialEditorState:s}=i;if(bf(s))n.setEditorState(s,e);else if(typeof s=="function")n.update(()=>{s(n)},t);else if(s&&(typeof s=="string"||typeof s=="object")){const o=n.parseEditorState(s);n.setEditorState(o,e)}}return()=>{}},name:"@lexical/extension/InitialState",nodes:[Jt,xt,mn,pn,yn]},yl=Symbol.for("@lexical/extension/LexicalBuilder");function xl(){}function mh(n){throw n}function vr(n){return Array.isArray(n)?n:[n]}const Li="0.44.0+prod.esm";let ar=class Ar{constructor(t){w(this,"roots");w(this,"extensionNameMap");w(this,"outgoingConfigEdges");w(this,"incomingEdges");w(this,"conflicts");w(this,"_sortedExtensionReps");w(this,"PACKAGE_VERSION");this.outgoingConfigEdges=new Map,this.incomingEdges=new Map,this.extensionNameMap=new Map,this.conflicts=new Map,this.PACKAGE_VERSION=Li,this.roots=t;for(const e of t)this.addExtension(e)}static fromExtensions(t){const e=[vr(gh)];for(const r of t)e.push(vr(r));return new Ar(e)}static maybeFromEditor(t){const e=t[yl];return e&&(e.PACKAGE_VERSION!==Li&&Y(292,e.PACKAGE_VERSION,Li),e instanceof Ar||Y(293)),e}static fromEditor(t){const e=Ar.maybeFromEditor(t);return e===void 0&&Y(294),e}constructEditor(){const{$initialEditorState:t,onError:e,...r}=this.buildCreateEditorArgs(),i=Object.assign(dc({...r,...e?{onError:s=>{e(s,i)}}:{}}),{[yl]:this});for(const s of this.sortedExtensionReps())s.build(i);return i}buildEditor(){let t=xl;function e(){try{t()}finally{t=xl}}const r=Object.assign(this.constructEditor(),{dispose:e,[Symbol.dispose]:e});
1return t=Te(this.registerEditor(r),()=>r.setRootElement(null)),r}hasExtensionByName(t){return this.extensionNameMap.has(t)}getExtensionRep(t){const e=this.extensionNameMap.get(t.name);if(e)return e.extension!==t&&Y(295,t.name),e}addEdge(t,e,r){const i=this.outgoingConfigEdges.get(t);i?i.set(e,r):this.outgoingConfigEdges.set(t,new Map([[e,r]]));const s=this.incomingEdges.get(e);s?s.add(t):this.incomingEdges.set(e,new Set([t]))}addExtension(t){this._sortedExtensionReps!==void 0&&Y(296);const e=vr(t),[r]=e;typeof r.name!="string"&&Y(297,typeof r.name);let i=this.extensionNameMap.get(r.name);if(i!==void 0&&i.extension!==r&&Y(298,r.name),!i){i=new fh(this,r),this.extensionNameMap.set(r.name,i);const s=this.conflicts.get(r.name);typeof s=="string"&&Y(299,r.name,s);for(const o of r.conflictsWith||[])this.extensionNameMap.has(o)&&Y(299,r.name,o),this.conflicts.set(o,r.name);for(const o of r.dependencies||[]){const l=vr(o);this.addEdge(r.name,l[0].name,l.slice(1)),this.addExtension(l)}for(const[o,l]of r.peerDependencies||[])this.addEdge(r.name,o,l?[l]:[])}}sortedExtensionReps(){if(this._sortedExtensionReps)return this._sortedExtensionReps;const t=[],e=(r,i)=>{let s=r.state;if(Hc(s))return;const o=r.extension.name;var l;$i(s)||Y(300,o,i||"[unknown]"),$i(l=s)||Y(304,String(l.id),String(so)),s=Object.assign(l,{id:Ss}),r.state=s;const a=this.outgoingConfigEdges.get(o);if(a)for(const c of a.keys()){const d=this.extensionNameMap.get(c);d&&e(d,o)}s=uh(s),r.state=s,t.push(r)};for(const r of this.extensionNameMap.values())$i(r.state)&&e(r);for(const r of t)for(const[i,s]of this.outgoingConfigEdges.get(r.extension.name)||[])if(s.length>0){const o=this.extensionNameMap.get(i);if(o)for(const l of s)o.configs.add(l)}for(const[r,...i]of this.roots)if(i.length>0){const s=this.extensionNameMap.get(r.name);s===void 0&&Y(301,r.name);for(const o of i)s.configs.add(o)}return this._sortedExtensionReps=t,this._sortedExtensionReps}registerEditor(t){const e=this.sortedExtensionReps(),r=new AbortController,i=[()=>r.abort()],s=r.signal;for(const o of e){const l=o.register(t,s);l&&i.push(l)}for(const o of e){const l=o.afterRegistration(t);l&&i.push(l)}return Te(...i)}buildCreateEditorArgs(){const t={},e=new Set,r=new Map,i=new Map,s={},o={},l=this.sortedExtensionReps();for(const d of l){const{extension:f}=d;if(f.onError!==void 0&&(t.onError=f.onError),f.disableEvents!==void 0&&(t.disableEvents=f.disableEvents),f.parentEditor!==void 0&&(t.parentEditor=f.parentEditor),f.editable!==void 0&&(t.editable=f.editable),f.namespace!==void 0&&(t.namespace=f.namespace),f.$initialEditorState!==void 0&&(t.$initialEditorState=f.$initialEditorState),f.nodes)for(const h of Jc(f)){if(typeof h!="function"){const m=r.get(h.replace);m&&Y(302,f.name,h.replace.name,m.extension.name),r.set(h.replace,d)}e.add(h)}if(f.html){if(f.html.export)for(const[h,m]of f.html.export.entries())i.set(h,m);f.html.import&&Object.assign(s,f.html.import)}f.theme&&Vc(o,f.theme)}Object.keys(o).length>0&&(t.theme=o),e.size&&(t.nodes=[...e]);const a=Object.keys(s).length>0,c=i.size>0;(a||c)&&(t.html={},a&&(t.html.import=s),c&&(t.html.export=i));for(const d of l)d.init(t);return t.onError||(t.onError=mh),t}};function Yc(n,t){const e=ar.fromEditor(n).getExtensionRep(t);return e===void 0&&Y(303,t.name),e.getExtensionDependency()}function ph(n,t){const e=ar.maybeFromEditor(n);if(!e)return;const r=e.extensionNameMap.get(t);return r?r.getExtensionDependency():void 0}function Gc(n,...t){const e=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const i of t)r.append("v",i);throw e.search=r.toString(),Error("Minified Lexical error #".concat(n,"; visit ").concat(e.toString()," for the full message or use the non-minified dev environment for full errors and additional helpful warnings."))}let dn;function Qc(n,t){const{key:e}=t;return n&&e in n?n[e]:t.defaultValue}function vl(n){return dn&&dn.editor===n?dn:void 0}function _h(n,t){if("cfg"in t){const{cfg:e,updater:r}=t;return[e,r(Qc(n,e))]}return t}function Xc(n,t){let e=t;for(const r of n){const[i,s]=_h(e,r),o=i.key;if(e===t&&Qc(e,i)===s)continue;const l=e||yh(t);l[o]=s,e=l}return e}function yh(n){return Object.create(n||null)}function xh(n,t){return[n,t]}const Zc="@lexical/html/DOM",eu=Symbol.for("@lexical/html/DOMExportContext"),vh=()=>!0;function bh(n){return t=>t instanceof n}function Ch(n,{nodes:t}){if(t==="*")return vh;let e={};const r=[];for(const i of t)if("getType"in i){const s=i.getType();if(e){const o=n[s];o===void 0&&Gc(339,i.name,s),e=Object.assign(e,o.types)}r.push(bh(i))}else e=void 0,r.push(i);return e||(r.length===1?r[0]:i=>{for(const s of r)if(s(i))return!0;return!1})}function bl(n){return(t,e,r)=>n(t,r)}function Ii(n){return(t,e,r,i)=>
1n(t,e,i)}function Sh(n){return(t,e,r,i,s)=>n(t,e,r,s)}function Nh(n){return(t,e,r,i,s,o)=>n(t,e,r,i,o)}function Cl(n,t){return(e,r)=>{const i=()=>n(e,r),s=t(e);return s?s(e,i,r):i()}}function Ri(n,t){return(e,r,i)=>{const s=()=>n(e,r,i),o=t(e);return o?o(e,r,s,i):s()}}function kh(n,t){return(e,r,i,s)=>{const o=()=>n(e,r,i,s),l=t(e);return l?l(e,r,i,o,s):o()}}function wh(n,t){return(e,r,i,s,o)=>{const l=()=>n(e,r,i,s,o),a=t(e);return a?a(e,r,i,s,l,o):l()}}function Th(n,t){return(e,r,i,s)=>{n(e,r,i,s);const o=t(e);o&&o(e,r,i,s)}}function lt(n,t,e,r,i){let s=e[t];for(const o of n[t])if(typeof o[0]=="function"){const[l,a]=o;s=r(s,c=>l(c)&&a||void 0)}else{const l=o[1],a={};for(const c in l){const d=l[c];d&&(a[c]=d.reduce((f,h)=>r(f,()=>h),s))}s=r(s,c=>{const d=a[c.getType()];return d&&i(d)})}e[t]=s}function Eh(n,t,e,r){if(!r)return;const i=n[t];if(typeof e=="function")i.push([e,r]);else{const s=i[i.length-1];let o;s&&s[0]==="types"?o=s[1]:(o={},i.push(["types",o]));for(const l in e){const a=o[l]||[];o[l]=a,a.push(r)}}}function jh(n){return n.nodes==="*"}function Oh(n,t){const e=function(i){const s={},{nodes:o}=ch(i);for(const l of o)s[l.getType()]={klass:l,types:{}};for(const l of Object.values(s))if(l){const a=l.klass.getType();for(let{klass:c}=l;ki(c.prototype);c=Object.getPrototypeOf(c)){const{ownNodeType:d}=vn(c),f=d&&s[d];f&&(f.types[a]=!0)}}return s}(n),r={$createDOM:[],$decorateDOM:[],$exportDOM:[],$extractWithChild:[],$getDOMSlot:[],$shouldExclude:[],$shouldInclude:[],$updateDOM:[]};for(const i of function(s){const o=[],l=[],a=[];for(const f of s)if(jh(f))o.push(f);else if(Array.isArray(f.nodes))for(const h of f.nodes)ki(h.prototype)?a.push(f.nodes.length===1?f:{...f,nodes:[h]}):l.push(f.nodes.length===1?f:{...f,nodes:[h]});const c=new Map,d=f=>{let h=c.get(f);if(h===void 0){h=0;for(let m=f;ki(m.prototype);m=Object.getPrototypeOf(m))h++;c.set(f,h)}return h};return a.sort((f,h)=>d(f.nodes[0])-d(h.nodes[0])),[...a,...l,...o]}(t)){const s=Ch(e,i);for(const o in r)Eh(r,o,s,i[o])}return r}function Mh(n){return n}const Ah={build:(n,t,e)=>({defaults:Xc(t.contextDefaults,void 0)}),config:{contextDefaults:[],overrides:[]},html:{export:new Map([[Jt,()=>{const n=document.createElement("div");return n.role="textbox",{element:n}}]])},init(n,t){n.dom=function(e,{overrides:r}){const i=Oh(e,r),s={...Xn,...e.dom};return lt(i,"$createDOM",s,Cl,bl),lt(i,"$exportDOM",s,Cl,bl),lt(i,"$extractWithChild",s,wh,Nh),lt(i,"$getDOMSlot",s,Ri,Ii),lt(i,"$shouldExclude",s,Ri,Ii),lt(i,"$shouldInclude",s,Ri,Ii),lt(i,"$updateDOM",s,kh,Sh),lt(i,"$decorateDOM",s,Th,Mh),s}(n,t)},mergeConfig(n,t){const e=no(n,t);for(const r of["overrides","contextDefaults"])t[r]&&(e[r]=[...n[r],...t[r]]);return e},name:Zc};function tu(n,t,e){return function(r,i,s,o){return Object.assign(fa(Symbol(i),{isEqual:o,parse:s}),{[r]:!0})}(eu,n,t,e)}tu("root",Boolean);const Dh=tu("isExport",Boolean);function Ph(n){const t=ar.maybeFromEditor(n);return t&&t.hasExtensionByName(Zc)?Yc(n,Ah).output.defaults:void 0}const Fh=function(n,t=()=>{}){return(e,r=nt())=>i=>{const s=vl(r),o=s&&s[n],l=Xc(e,o||t(r));return l&&l!==o?function(a,c,d,f=nt()){const h=dn,m=vl(f);try{return dn={...m,editor:f,[a]:c},d()}finally{dn=h}}(n,l,i,r):i()}}(eu,Ph);function $h(n){return n.constructor.name===CSSStyleRule.name}const nu=new Set(["STYLE","SCRIPT"]);function ru(n,t){gs(t)&&function(s){if(s.querySelector("style")===null)return;const o=new Map;function l(a){let c=o.get(a);if(c===void 0){c=new Set;for(let d=0;d<a.style.length;d++)c.add(a.style[d]);o.set(a,c)}return c}try{for(const a of Array.from(s.styleSheets)){let c;try{c=a.cssRules}catch(d){continue}for(const d of Array.from(c)){if(!$h(d))continue;let f;try{f=s.querySelectorAll(d.selectorText)}catch(h){continue}for(const h of Array.from(f)){if(!te(h))continue;const m=l(h);for(let g=0;g<d.style.length;g++){const y=d.style[g];m.has(y)||h.style.setProperty(y,d.style.getPropertyValue(y),d.style.getPropertyPriority(y))}}}}}catch(a){}}(t);const e=gs(t)?t.body.childNodes:t.childNodes,r=[],i=[];for(const s of e)if(!nu.has(s.nodeName)){const o=ou(s,n,i,!1);if(o!==null)for(const l of o)r.push(l)}return function(s){for(const o of s)o.getParent()&&o.getNextSibling()instanceof Is&&o.insertAfter(Lt());for(const o of s){const l=o.getParent();l&&l.splice(o.getIndexWithinParent(),1,o.getChildren())}}(i),r}function Lh(n,t=null,e=nt()){return Fh([xh(Dh,!0)],e)(()=>{const r=ee(),i=or(e),s=n.append.bind(n);for(const o of r.getChildren())su(e,o,s,t,i);return n})}function iu(n,t=null){return(typeof document>"u"||typeof window>"u"&&global.window===void 0)&&Gc(338),Lh(document.createElement("div"),t,n).innerHTML}function su(n,t,e,r=null,i=or(n)){let s=i.$shouldInclude(t,r,n);const o=i.$shouldExclude(t,r,n);let l=t;r!==null&&M(t)&&(l=$c(r,t,"clone"));const a=i.$exportDOM(l,n),{element:c,after:d,append:f,$getChildNodes:h}=a;if(!c)return!1;
1const m=document.createDocumentFragment(),g=h?h():C(l)?l.getChildren():[],y=m.append.bind(m);for(const p of g){const _=su(n,p,y,r,i);!s&&_&&i.$extractWithChild(t,p,r,"html",n)&&(s=!0)}if(s&&!o){if((te(c)||ys(c))&&(f?f(m):c.append(m)),e(c),d){const p=d.call(l,c);p&&(ys(c)?c.replaceChildren(p):c.replaceWith(p))}}else e(m);return s}function ou(n,t,e,r,i=new Map,s){const o=[];if(nu.has(n.nodeName))return o;let l=null;const a=function(g,y){const{nodeName:p}=g,_=y._htmlConversions.get(p.toLowerCase());let x=null;if(_!==void 0)for(const b of _){const N=b(g);N!==null&&(x===null||(x.priority||0)<=(N.priority||0))&&(x=N)}return x!==null?x.conversion:null}(n,t),c=a?a(n):null;let d=null;if(c!==null){d=c.after;const g=c.node;if(l=Array.isArray(g)?g[g.length-1]:g,l!==null){for(const[,y]of i)if(l=y(l,s),!l)break;l&&o.push(...Array.isArray(g)?g:[l])}c.forChild!=null&&i.set(n.nodeName,c.forChild)}const f=n.childNodes;let h=[];const m=(l==null||!_e(l))&&(l!=null&&fs(l)||r);for(let g=0;g<f.length;g++)h.push(...ou(f[g],t,e,m,new Map(i),l));if(d!=null&&(h=d(h)),Vr(n)&&(h=Ih(n,h,m?()=>{const g=new Is;return e.push(g),g}:Q)),l==null)if(h.length>0)for(const g of h)o.push(g);else Vr(n)&&function(g){return g.nextSibling==null||g.previousSibling==null?!1:xs(g.nextSibling)&&xs(g.previousSibling)}(n)&&o.push(Lt());else C(l)&&l.append(...h);return o}function Ih(n,t,e){const r=n.style.textAlign,i=[];let s=[];for(let o=0;o<t.length;o++){const l=t[o];if(fs(l))r&&!l.getFormat()&&l.setFormat(r),i.push(l);else if(s.push(l),o===t.length-1||o<t.length-1&&fs(t[o+1])){const a=e();a.setFormat(r),a.append(...s),i.push(a),s=[]}}return i}const Rh=new Set(["http:","https:","mailto:","sms:","tel:"]);class Ct extends we{constructor(e="",r={},i){super(i);w(this,"__url");w(this,"__target");w(this,"__rel");w(this,"__title");const{target:s=null,rel:o=null,title:l=null}=r;this.__url=e,this.__target=s,this.__rel=o,this.__title=l}static getType(){return"link"}static clone(e){return new Ct(e.__url,{rel:e.__rel,target:e.__target,title:e.__title},e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__url=e.__url,this.__rel=e.__rel,this.__target=e.__target,this.__title=e.__title}createDOM(e){const r=document.createElement("a");return this.updateLinkDOM(null,r,e),lr(r,e.theme.link),r}updateLinkDOM(e,r,i){if(kc(r)){e&&e.__url===this.__url||(r.href=this.sanitizeUrl(this.__url));for(const s of["target","rel","title"]){const o="__".concat(s),l=this[o];e&&e[o]===l||(l?r[s]=l:r.removeAttribute(s))}}}updateDOM(e,r,i){return this.updateLinkDOM(e,r,i),!1}static importDOM(){return{a:e=>({conversion:zh,priority:1})}}static importJSON(e){return Xr().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setURL(e.url).setRel(e.rel||null).setTarget(e.target||null).setTitle(e.title||null)}sanitizeUrl(e){e=Tl(e);try{const r=new URL(Tl(e));if(!Rh.has(r.protocol))return"about:blank"}catch(r){return e}return e}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),url:this.getURL()}}getURL(){return this.getLatest().__url}setURL(e){const r=this.getWritable();return r.__url=e,r}getTarget(){return this.getLatest().__target}setTarget(e){const r=this.getWritable();return r.__target=e,r}getRel(){return this.getLatest().__rel}setRel(e){const r=this.getWritable();return r.__rel=e,r}getTitle(){return this.getLatest().__title}setTitle(e){const r=this.getWritable();return r.__title=e,r}insertNewAfter(e,r=!0){const i=fe(this);return this.insertAfter(i,r),i}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,r,i){if(!E(r))return!1;const s=r.anchor.getNode(),o=r.focus.getNode();return this.isParentOf(s)&&this.isParentOf(o)&&r.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}shouldMergeAdjacentLink(e){return this.getType()===e.getType()&&this.__url===e.__url&&this.__target===e.__target&&this.__rel===e.__rel&&this.__title===e.__title}}function Sl(n){const t=Ue(n,"next");return[t,t.getFlipped()]}function Nl(n,t){for(const e of t)if(e.origin.isAttached()){const r=xe(e);return void _t(n,r)}}function Bh(n){const t=D();let e=null,r=null;function i(){E(t)&&(Nl(t.anchor,e),Nl(t.focus,r),Pt(t))}E(t)&&(e=Sl(t.anchor),r=Sl(t.focus));let s=!1;for(const l of be(n,"next")){const a=l.origin;if(C(a)&&!a.isInline()){const c=a.getChildren();if(c.length>0){const d=fe(n);d.append(...c),a.append(d),s=!0}zc(a,bt(l),{$shouldSplit:()=>!1})}}function o(l,a,c){const[d,f]=l,h=g=>gt(g)&&g.origin.is(a);if(!h(d)&&!h(f))return l;const m=xe(be(c,"next"));return[m,m.getFlipped()]}if(n.isAttached()){const l=n.getPreviousSibling();if(je(l)&&l.shouldMergeAdjacentLink(n))return e&&(e=o(e,l,n)),r&&(r=o(r,l,n)),l.append(...n.getChildren()),n.remove(),void i();const a=n.getNextSibling();je(a)&&n.shouldMergeAdjacentLink(a)&&(e&&(e=o(e,n,a)),r&&(r=o(r,n,a)),n.append(...a.getChildren()),a.remove(),s=!0)}if(s){if(!n.canBeEmpty()&&n.isEmpty()){const l=n.getParent();
1n.remove(),l&&l.isEmpty()&&l.remove()}i()}}function zh(n){let t=null;if(kc(n)){const e=n.textContent;(e!==null&&e!==""||n.children.length>0)&&(t=Xr(n.getAttribute("href")||"",{rel:n.getAttribute("rel"),target:n.getAttribute("target"),title:n.getAttribute("title")}))}return{node:t}}function Xr(n="",t){return Ve(new Ct(n,t))}function je(n){return n instanceof Ct}class _i extends Ct{constructor(e="",r={},i){super(e,r,i);w(this,"__isUnlinked");this.__isUnlinked=r.isUnlinked!==void 0&&r.isUnlinked!==null&&r.isUnlinked}afterCloneFrom(e){super.afterCloneFrom(e),this.__isUnlinked=e.__isUnlinked}static getType(){return"autolink"}static clone(e){return new _i(e.__url,{isUnlinked:e.__isUnlinked,rel:e.__rel,target:e.__target,title:e.__title},e.__key)}shouldMergeAdjacentLink(e){return!1}getIsUnlinked(){return this.__isUnlinked}setIsUnlinked(e){const r=this.getWritable();return r.__isUnlinked=e,r}createDOM(e){return this.__isUnlinked?document.createElement("span"):super.createDOM(e)}updateDOM(e,r,i){return super.updateDOM(e,r,i)||e.__isUnlinked!==this.__isUnlinked}static importJSON(e){return kl().updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setIsUnlinked(e.isUnlinked||!1)}static importDOM(){return null}exportJSON(){return{...super.exportJSON(),isUnlinked:this.__isUnlinked}}insertNewAfter(e,r=!0){const i=kl(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(i,r),i}}function kl(n="",t){return Ve(new _i(n,t))}function Mn(n){return n instanceof _i}const Zr=L("TOGGLE_LINK_COMMAND");function wl(n,t){if(n.type==="element"){const e=n.getNode();return C(e)||function(r,...i){const s=new URL("https://lexical.dev/docs/error"),o=new URLSearchParams;o.append("code",r);for(const l of i)o.append("v",l);throw s.search=o.toString(),Error("Minified Lexical error #".concat(r,"; visit ").concat(s.toString()," for the full message or use the non-minified dev environment for full errors and additional helpful warnings."))}(252),e.getChildren()[n.offset+t]||null}return null}function Bi(n,t={}){let e;if(n&&typeof n=="object"){const{url:d,...f}=n;e=d,t={...f,...t}}else e=n;const{target:r,title:i}=t,s=t.rel===void 0?"noreferrer":t.rel,o=D();if(o===null||!E(o)&&!he(o))return;if(he(o)){const d=o.getNodes();return d.length===0?void 0:void d.forEach(f=>{if(e===null){const h=de(f,m=>!Mn(m)&&je(m));h&&(h.insertBefore(f),h.getChildren().length===0&&h.remove())}else{const h=de(f,m=>!Mn(m)&&je(m));if(h)h.setURL(e),r!==void 0&&h.setTarget(r),s!==void 0&&h.setRel(s);else{const m=Xr(e,{rel:s,target:r});f.insertBefore(m),m.append(f)}}})}if(o.isCollapsed()&&e===null)for(const d of o.getNodes()){const f=de(d,h=>!Mn(h)&&je(h));
1return void(f!==null&&(f.getChildren().forEach(h=>{f.insertBefore(h)}),f.remove()))}const l=o.extract();if(e===null){const d=new Set;return void l.forEach(f=>{const h=de(f,m=>!Mn(m)&&je(m));if(h!==null){const m=h.getKey();if(d.has(m))return;(function(g,y){const p=new Set(y.filter(S=>g.isParentOf(S)).map(S=>S.getKey())),_=g.getChildren(),x=S=>p.has(S.getKey())||C(S)&&y.some(T=>g.isParentOf(T)&&S.isParentOf(T)),b=_.filter(x);if(b.length===_.length)return _.forEach(S=>g.insertBefore(S)),void g.remove();const N=_.findIndex(x),j=_.findLastIndex(x),v=N===0,k=j===_.length-1;if(v)b.forEach(S=>g.insertBefore(S));else if(k)for(let S=b.length-1;S>=0;S--)g.insertAfter(b[S]);else{for(let T=b.length-1;T>=0;T--)g.insertAfter(b[T]);const S=_.slice(j+1);if(S.length>0){const T=fe(g);b[b.length-1].insertAfter(T),S.forEach(A=>T.append(A))}}})(h,l),d.add(m)}})}const a=new Set,c=d=>{a.has(d.getKey())||(a.add(d.getKey()),d.setURL(e),r!==void 0&&d.setTarget(r),s!==void 0&&d.setRel(s),i!==void 0&&d.setTitle(i))};if(l.length===1){const d=l[0],f=de(d,je);if(f!==null)return c(f)}(function(d){const f=D();if(!E(f))return d();const h=Pt(f),m=h.isBackward(),g=wl(h.anchor,m?-1:0),y=wl(h.focus,m?0:-1);if(d(),g||y){const p=D();if(E(p)){const _=p.clone();if(g){const x=g.getParent();x&&_.anchor.set(x.getKey(),g.getIndexWithinParent()+(m?1:0),"element")}if(y){const x=y.getParent();x&&_.focus.set(x.getKey(),y.getIndexWithinParent()+(m?0:1),"element")}me(Pt(_))}}})(()=>{let d=null;for(const f of l){if(!f.isAttached())continue;const h=de(f,je);if(h){c(h);continue}if(C(f)){if(!f.isInline())continue;if(je(f)){if(!(Mn(f)||d!==null&&d.getParentOrThrow().isParentOf(f))){c(f),d=f;continue}for(const g of f.getChildren())f.insertBefore(g);f.remove();continue}}const m=f.getPreviousSibling();je(m)&&m.is(d)?m.append(f):(d=Xr(e,{rel:s,target:r,title:i}),f.insertAfter(d),d.append(f))}})}const Kh=/^\+?[0-9\s()-]{5,}$/;function Tl(n){return n.match(/^[a-z][a-z0-9+.-]*:/i)||n.match(/^[/#.]/)?n:n.includes("@")?"mailto:".concat(n):Kh.test(n)?"tel:".concat(n):"https://".concat(n)}function Wh(n,t){return Te(n.registerNodeTransform(Ct,Bh),n.registerCommand(Zr,e=>{const r=t.validateUrl.peek(),i=t.attributes.peek();if(e===null)return Bi(null),!0;if(typeof e=="string")return!(r!==void 0&&!r(e))&&(Bi(e,i),!0);{const{url:s,target:o,rel:l,title:a}=e;return Bi(s,{...i,rel:l,target:o,title:a}),!0}},B),pi(()=>{const e=t.validateUrl.value;if(!e)return;const r=t.attributes.value;return n.registerCommand(oi,i=>{const s=D();if(!E(s)||s.isCollapsed()||!dt(i,ClipboardEvent)||i.clipboardData===null)return!1;const o=i.clipboardData.getData("text");return!!e(o)&&!s.getNodes().some(l=>C(l))&&(n.dispatchCommand(Zr,{...r,url:o}),i.preventDefault(),!0)},Xe)}))}function Ze(n,...t){const e=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const i of t)r.append("v",i);throw e.search=r.toString(),Error("Minified Lexical error #".concat(n,"; visit ").concat(e.toString()," for the full message or use the non-minified dev environment for full errors and additional helpful warnings."))}function Ns(n){let t=1,e=n.getParent();for(;e!=null;){if(W(e)){const r=e.getParent();if(I(r)){t++,e=r.getParent();continue}Ze(40)}return t}return t}function ks(n){let t=n.getParent();I(t)||Ze(40);let e=t;for(;e!==null;)e=e.getParent(),I(e)&&(t=e);return t}function lu(n){let t=[];const e=n.getChildren().filter(W);for(let r=0;r<e.length;r++){const i=e[r],s=i.getFirstChild();I(s)?t=t.concat(lu(s)):t.push(i)}return t}function Me(n){return W(n)&&I(n.getFirstChild())}function El(n){return Cn().append(n)}function au(n,t){return W(n)&&(t.length===0||t.length===1&&n.is(t[0])&&n.getChildrenSize()===0)}function jl(n){const t=D();if(t!==null){let e=t.getNodes();if(E(t)){const i=t.getStartEndPoints();i===null&&Ze(143);const[s]=i,o=s.getNode(),l=o.getParent();if(_e(o)){const a=o.getFirstChild();if(a)e=a.selectStart().getNodes();else{const c=Q();o.append(c),e=c.select().getNodes()}}else if(au(o,e)){const a=At(n);if(_e(l)){o.replace(a);const c=Cn();C(o)&&(c.setFormat(o.getFormatType()),c.setIndent(o.getIndent())),a.append(c)}
1else if(W(o)){const c=o.getParentOrThrow();Kt(a,c.getChildren()),c.replace(a)}return}}const r=new Set;for(let i=0;i<e.length;i++){const s=e[i];if(C(s)&&s.isEmpty()&&!W(s)&&!r.has(s.getKey())){Ol(s,n);continue}let o=mc(s)?s.getParent():W(s)&&s.isEmpty()?s:null;for(;o!=null;){const l=o.getKey();if(I(o)){if(!r.has(l)){const a=At(n);Kt(a,o.getChildren()),o.replace(a),r.add(l)}break}{const a=o.getParent();if(_e(a)&&!r.has(l)){r.add(l),Ol(o,n);break}o=a}}}}}function Kt(n,t){n.splice(n.getChildrenSize(),0,t)}function Ol(n,t){if(I(n))return n;const e=n.getPreviousSibling(),r=n.getNextSibling(),i=Cn();let s;if(Kt(i,n.getChildren()),I(e)&&t===e.getListType())e.append(i),I(r)&&t===r.getListType()&&(Kt(e,r.getChildren()),r.remove()),s=e;else if(I(r)&&t===r.getListType())r.getFirstChildOrThrow().insertBefore(i),s=r;else{const l=At(t);l.append(i),n.replace(l),s=l}i.setFormat(n.getFormatType()),i.setIndent(n.getIndent());const o=D();return E(o)&&(s.getKey()===o.anchor.key&&o.anchor.set(i.getKey(),o.anchor.offset,"element"),s.getKey()===o.focus.key&&o.focus.set(i.getKey(),o.focus.offset,"element")),n.remove(),s}function oo(n,t){const e=n.getLastChild(),r=t.getFirstChild();e&&r&&Me(e)&&Me(r)&&(oo(e.getFirstChild(),r.getFirstChild()),r.remove());const i=t.getChildren();i.length>0&&n.append(...i),t.remove()}function Uh(){const n=D();if(E(n)){const t=new Set,e=n.getNodes(),r=n.anchor.getNode();if(au(r,e))t.add(ks(r));else for(let i=0;i<e.length;i++){const s=e[i];if(mc(s)){const o=nh(s,bn);o!=null&&t.add(ks(o))}}for(const i of t){let s=i;const o=lu(i);for(const l of o){const a=Q().setTextStyle(n.style).setTextFormat(n.format);Kt(a,l.getChildren()),s.insertAfter(a),s=a,l.__key===n.anchor.key&&_t(n.anchor,xe(be(a,"next"))),l.__key===n.focus.key&&_t(n.focus,xe(be(a,"next"))),l.remove()}i.remove()}}}function cu(n){const t=n.getListType()!=="check";let e=n.getStart();for(const r of n.getChildren())W(r)&&(r.getValue()!==e&&r.setValue(e),t&&r.getLatest().__checked!=null&&r.setChecked(void 0),I(r.getFirstChild())||e++)}function Jh(n){const t=new Set;if(Me(n)||t.has(n.getKey()))return;const e=n.getParent(),r=n.getNextSibling(),i=n.getPreviousSibling();if(Me(r)&&Me(i)){const s=i.getFirstChild();if(I(s)){s.append(n);const o=r.getFirstChild();I(o)&&(Kt(s,o.getChildren()),r.remove(),t.add(r.getKey()))}}else if(Me(r)){const s=r.getFirstChild();if(I(s)){const o=s.getFirstChild();o!==null&&o.insertBefore(n)}}else if(Me(i)){const s=i.getFirstChild();I(s)&&s.append(n)}else if(I(e)){const s=fe(n),o=fe(e);s.append(o),o.append(n),i?i.insertAfter(s):r?r.insertBefore(s):e.append(s)}}function Vh(n){if(Me(n))return;const t=n.getParent(),e=t?t.getParent():void 0;if(I(e?e.getParent():void 0)&&W(e)&&I(t)){const r=t?t.getFirstChild():void 0,i=t?t.getLastChild():void 0;if(n.is(r))e.insertBefore(n),t.isEmpty()&&e.remove();else if(n.is(i))e.insertAfter(n),t.isEmpty()&&e.remove();else{const s=fe(n),o=fe(t);
1s.append(o),n.getPreviousSiblings().forEach(c=>o.append(c));const l=fe(n),a=fe(t);l.append(a),Kt(a,n.getNextSiblings()),e.insertBefore(s),e.insertAfter(l),e.replace(n)}}}function qh(n=!1){const t=D();if(!E(t)||!t.isCollapsed())return!1;const e=t.anchor.getNode();let r=null;if(W(e)&&e.getChildrenSize()===0)r=e;else if(M(e)){const c=e.getParent();W(c)&&c.getChildren().every(d=>M(d)&&d.getTextContent().trim()==="")&&(r=c)}if(r===null)return!1;const i=ks(r),s=r.getParent();I(s)||Ze(40);const o=s.getParent();let l;if(_e(o))l=Q(),i.insertAfter(l);else{if(!W(o))return!1;l=fe(o),o.insertAfter(l)}l.setTextStyle(t.style).setTextFormat(t.format).select();const a=r.getNextSiblings();if(a.length>0){const c=n?function(f,h){return f.getStart()+h.getIndexWithinParent()}(s,r):1,d=fe(s).setStart(c);if(W(l)){const f=fe(l);f.append(d),l.insertAfter(f)}else l.insertAfter(d);d.append(...a)}return function(c){let d=c;for(;d.getNextSibling()==null&&d.getPreviousSibling()==null;){const f=d.getParent();if(f==null||!W(f)&&!I(f))break;d=f}d.remove()}(r),!0}class bn extends we{constructor(e=1,r=void 0,i){super(i);w(this,"__value");w(this,"__checked");this.__value=e===void 0?1:e,this.__checked=r}$config(){return this.config("listitem",{$transform:e=>{const r=e.getParent();if(I(r))r.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0);else if(r){const i=e.createParentElementNode();I(i)||Ze(340);const s=[e];for(const o of["previous","next"]){s.reverse();for(const{origin:l}of Z(e,o)){if(!W(l))break;s.push(l)}}e.insertBefore(i),i.splice(0,0,s),_e(r)||(zc(i,bt(Z(i,"next")),{$shouldSplit:()=>!1,removeEmptyDestination:!0}),r.isEmpty()&&r.isAttached()&&r.remove())}},extends:we,importDOM:{li:()=>({conversion:Hh,priority:0})}})}afterCloneFrom(e){super.afterCloneFrom(e),this.__value=e.__value,this.__checked=e.__checked}createDOM(e){const r=document.createElement("li");return this.updateListItemDOM(null,r,e),r}updateListItemDOM(e,r,i){(function(l,a,c){const d=a.getParent();!I(d)||d.getListType()!=="check"||I(a.getFirstChild())?(l.removeAttribute("role"),l.removeAttribute("tabIndex"),l.removeAttribute("aria-checked")):(l.setAttribute("role","checkbox"),l.setAttribute("tabIndex","-1"),c&&a.__checked===c.__checked||l.setAttribute("aria-checked",a.getChecked()?"true":"false"))})(r,this,e),r.value=this.__value,function(l,a,c){const d=[],f=[],h=a.list,m=h?h.listitem:void 0;let g;if(h&&h.nested&&(g=h.nested.listitem),m!==void 0&&d.push(...yt(m)),h){const y=c.getParent(),p=I(y)&&y.getListType()==="check",_=c.getChecked();p&&!_||f.push(h.listitemUnchecked),p&&_||f.push(h.listitemChecked),p&&d.push(_?h.listitemChecked:h.listitemUnchecked)}if(g!==void 0){const y=yt(g);c.getChildren().some(p=>I(p))?d.push(...y):f.push(...y)}f.length>0&&Dc(l,...f),d.length>0&&lr(l,...d)}(r,i.theme,this);const s=e?e.__style:"",o=this.__style;s!==o&&us(r.style,o,s),function(l,a,c){const d=a.__textStyle,f=c?c.__textStyle:"";if(c!==null&&f===d)return;const h=$t(d);for(const m in h)l.style.setProperty("--listitem-marker-".concat(m),h[m]);if(f!=="")for(const m in $t(f))m in h||l.style.removeProperty("--listitem-marker-".concat(m))}(r,this,e)}updateDOM(e,r,i){const s=r;return this.updateListItemDOM(e,s,i),!1}updateFromJSON(e){return super.updateFromJSON(e).setValue(e.value).setChecked(e.checked)}exportDOM(e){const r=this.createDOM(e._config),i=this.getFormatType();i&&(r.style.textAlign=i);const s=this.getDirection();return s&&(r.dir=s),Me(this)?{after(o){if(te(o)){const l=o.previousElementSibling;if(te(l)&&l.nodeName==="LI"){for(;o.firstChild;)l.append(o.firstChild);o.remove()}}return o},element:r}:{element:r}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),value:this.getValue()}}append(...e){for(let r=0;r<e.length;r++){const i=e[r];if(C(i)&&this.canMergeWith(i)){const s=i.getChildren();this.append(...s),i.remove()}else super.append(i)}return this}replace(e,r){if(W(e))return super.replace(e);this.setIndent(0);const i=this.getParentOrThrow();if(!I(i))return e;if(i.__first===this.getKey())i.insertBefore(e);else if(i.__last===this.getKey())i.insertAfter(e);else{const s=fe(i);let o=this.getNextSibling();for(;o;){const l=o;o=o.getNextSibling(),s.append(l)}i.insertAfter(e),e.insertAfter(s)}
1return r&&(C(e)||Ze(139),this.getChildren().forEach(s=>{e.append(s)})),this.remove(),i.getChildrenSize()===0&&i.remove(),e}insertAfter(e,r=!0){const i=this.getParentOrThrow();if(I(i)||Ze(39),W(e))return super.insertAfter(e,r);const s=this.getNextSiblings();if(i.insertAfter(e,r),s.length!==0){const o=fe(i);s.forEach(l=>o.append(l)),e.insertAfter(o,r)}return e}remove(e){const r=this.getPreviousSibling(),i=this.getNextSibling();super.remove(e),r&&i&&Me(r)&&Me(i)&&(oo(r.getFirstChild(),i.getFirstChild()),i.remove())}resetOnCopyNodeFrom(e){super.resetOnCopyNodeFrom(e),e.getChecked()&&this.setChecked(!1)}insertNewAfter(e,r=!0){const i=fe(this);return this.insertAfter(i,r),i}collapseAtStart(e){const r=Q();this.getChildren().forEach(l=>r.append(l));const i=this.getParentOrThrow(),s=i.getParentOrThrow(),o=W(s);if(i.getChildrenSize()===1)if(o)i.remove(),s.select();else{i.insertBefore(r),i.remove();const l=e.anchor,a=e.focus,c=r.getKey();l.type==="element"&&l.getNode().is(this)&&l.set(c,l.offset,"element"),a.type==="element"&&a.getNode().is(this)&&a.set(c,a.offset,"element")}else i.insertBefore(r),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){const r=this.getWritable();return r.__value=e,r}getChecked(){const e=this.getLatest();let r;const i=this.getParent();return I(i)&&(r=i.getListType()),r==="check"?!!e.__checked:void 0}setChecked(e){const r=this.getWritable();return r.__checked=e,r}toggleChecked(){const e=this.getWritable();return e.setChecked(!e.__checked)}getIndent(){const e=this.getParent();if(e===null||!this.isAttached())return this.getLatest().__indent;let r=e.getParentOrThrow(),i=0;for(;W(r);)r=r.getParentOrThrow().getParentOrThrow(),i++;return i}setIndent(e){typeof e!="number"&&Ze(117),(e=Math.floor(e))>=0||Ze(199);let r=this.getIndent();for(;r!==e;)r<e?(Jh(this),r++):(Vh(this),r--);return this}canInsertAfter(e){return W(e)}canReplaceWith(e){return W(e)}canMergeWith(e){return W(e)||Rs(e)}extractWithChild(e,r){if(!E(r))return!1;const i=r.anchor.getNode(),s=r.focus.getNode();return this.isParentOf(i)&&this.isParentOf(s)&&this.getTextContent().length===r.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return At("bullet")}canMergeWhenEmpty(){return!0}}function Hh(n){if(n.classList.contains("task-list-item")){for(const e of n.children)if(e.tagName==="INPUT")return Ml(e)}if(n.classList.contains("joplin-checkbox")){for(const e of n.children)if(e.classList.contains("checkbox-wrapper")&&e.children.length>0&&e.children[0].tagName==="INPUT")return Ml(e.children[0])}const t=n.getAttribute("aria-checked");return{node:Cn(t==="true"||t!=="false"&&void 0)}}function Ml(n){return n.getAttribute("type")!=="checkbox"?{node:null}:{node:Cn(n.hasAttribute("checked"))}}function Cn(n){return Ve(new bn(void 0,n))}function W(n){return n instanceof bn}class cr extends we{constructor(e="number",r=1,i){super(i);w(this,"__tag");w(this,"__start");w(this,"__listType");const s=Gh[e]||e;this.__listType=s,this.__tag=s==="number"?"ol":"ul",this.__start=r}$config(){return this.config("list",{$transform:e=>{(function(r){const i=r.getNextSibling();I(i)&&r.getListType()===i.getListType()&&oo(r,i)})(e),cu(e)},extends:we,importDOM:{ol:()=>({conversion:Dl,priority:0}),ul:()=>({conversion:Dl,priority:0})}})}afterCloneFrom(e){super.afterCloneFrom(e),this.__listType=e.__listType,this.__tag=e.__tag,this.__start=e.__start}getTag(){return this.getLatest().__tag}setListType(e){const r=this.getWritable();return r.__listType=e,r.__tag=e==="number"?"ol":"ul",r}getListType(){return this.getLatest().__listType}getStart(){return this.getLatest().__start}setStart(e){const r=this.getWritable();return r.__start=e,r}createDOM(e,r){const i=this.__tag,s=document.createElement(i);return this.__start!==1&&s.setAttribute("start",String(this.__start)),s.__lexicalListType=this.__listType,Al(s,e.theme,this),s}updateDOM(e,r,i){return e.__tag!==this.__tag||e.__listType!==this.__listType||(Al(r,i.theme,this),e.__start!==this.__start&&r.setAttribute("start",String(this.__start)),!1)}updateFromJSON(e){return super.updateFromJSON(e).setListType(e.listType).setStart(e.start)}exportDOM(e){const r=this.createDOM(e._config,e);return te(r)&&(this.__start!==1&&r.setAttribute("start",String(this.__start)),this.__listType==="check"&&r.setAttribute("__lexicalListType","check")),{element:r}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag()}}canBeEmpty(){return!1}canIndent(){return!1}splice(e,r,i){var a;const s=(a=i.find(W))!=null?a:this.getChildren().find(W),o=s?()=>fe(s):Cn;let l=i;for(let c=0;c<i.length;c++){const d=i[c];W(d)||(l===i&&(l=[...i]),l[c]=o().append(!C(d)||I(d)||d.isInline()?d:se(d.getTextContent())))}return super.splice(e,r,l)}
1extractWithChild(e){return W(e)}}function Al(n,t,e){const r=[],i=[],s=t.list;if(s!==void 0){const o=s["".concat(e.__tag,"Depth")]||[],l=Ns(e)-1,a=l%o.length,c=o[a],d=s[e.__tag];let f;const h=s.nested,m=s.checklist;if(h!==void 0&&h.list&&(f=h.list),d!==void 0&&r.push(d),m!==void 0&&e.__listType==="check"&&r.push(m),c!==void 0){r.push(...yt(c));for(let g=0;g<o.length;g++)g!==a&&i.push(e.__tag+g)}if(f!==void 0){const g=yt(f);l>1?r.push(...g):i.push(...g)}}i.length>0&&Dc(n,...i),r.length>0&&lr(n,...r)}function Yh(n){const t=[];for(let e=0;e<n.length;e++){const r=n[e];if(W(r)){t.push(r);const i=r.getChildren();i.length>1&&i.forEach(s=>{I(s)&&t.push(El(s))})}else t.push(El(r))}return t}function Dl(n){const t=n.nodeName.toLowerCase();let e=null;return t==="ol"?e=At("number",n.start):t==="ul"&&(e=function(r){if(r.getAttribute("__lexicallisttype")==="check"||r.classList.contains("contains-task-list")||r.getAttribute("data-is-checklist")==="1")return!0;for(const i of r.childNodes)if(te(i)&&i.hasAttribute("aria-checked"))return!0;return!1}(n)?At("check"):At("bullet")),{after:Yh,node:e}}const Gh={ol:"number",ul:"bullet"};function At(n="number",t=1){return Ve(new cr(n,t))}function I(n){return n instanceof cr}const Qh=L("UPDATE_LIST_START_COMMAND"),uu=L("INSERT_UNORDERED_LIST_COMMAND"),du=L("INSERT_ORDERED_LIST_COMMAND"),fu=L("REMOVE_LIST_COMMAND");function Pl(n,t){return Te(n.registerCommand(du,()=>(jl("number"),!0),Xe),n.registerCommand(Qh,e=>{const{listNodeKey:r,newStart:i}=e,s=ne(r);return!!I(s)&&(s.getListType()==="number"&&(s.setStart(i),cu(s)),!0)},Xe),n.registerCommand(uu,()=>(jl("bullet"),!0),Xe),n.registerCommand(fu,()=>(Uh(),!0),Xe),n.registerCommand(Hn,()=>qh(!!(t&&t.restoreNumbering)),Xe),n.registerNodeTransform(bn,e=>{const r=e.getFirstChild();if(r){if(M(r)){const i=r.getStyle(),s=r.getFormat();e.getTextStyle()!==i&&e.setTextStyle(i),e.getTextFormat()!==s&&e.setTextFormat(s)}}else{const i=D();E(i)&&(i.style!==e.getTextStyle()||i.format!==e.getTextFormat())&&i.isCollapsed()&&e.is(i.anchor.getNode())&&e.setTextStyle(i.style).setTextFormat(i.format)}}),n.registerNodeTransform(xt,e=>{const r=e.getParent();if(W(r)&&e.is(r.getFirstChild())){const i=e.getStyle(),s=e.getFormat();i===r.getTextStyle()&&s===r.getTextFormat()||r.setTextStyle(i).setTextFormat(s)}}))}function Xh(n){const t=e=>{const r=e.getParent();if(I(e.getFirstChild())||!I(r))return;const i=de(e,s=>W(s)&&I(s.getParent())&&W(s.getPreviousSibling()));if(i===null&&e.getIndent()>0)e.setIndent(0);else if(W(i)){const s=i.getPreviousSibling();if(W(s)){const o=function(a){let c=a,d=c.getFirstChild();for(;I(d);){const f=d.getLastChild();if(!W(f))break;c=f,d=c.getFirstChild()}return c}(s),l=o.getParent();if(I(l)){const a=Ns(l);a+1<Ns(r)&&e.setIndent(a)}}}};return n.registerNodeTransform(cr,e=>{const r=[e];for(;r.length>0;){const i=r.shift();if(I(i)){for(const s of i.getChildren())if(W(s)){t(s);const o=s.getFirstChild();I(o)&&r.push(o)}}}})}const hu=P.createContext(null);function Zh(n,t){return{getTheme:function(){return t!=null?t:null}}}function $e(){const n=P.useContext(hu);return n==null&&function(t,...e){const r=new URL("https://lexical.dev/docs/error"),i=new URLSearchParams;i.append("code",t);for(const s of e)i.append("v",s);throw r.search=i.toString(),Error("Minified Lexical error #".concat(t,"; visit ").concat(r.toString()," for the full message or use the non-minified dev environment for full errors and additional helpful warnings."))}(8),n}function eg({defaultSelection:n}){const[t]=$e();return P.useEffect(()=>{t.focus(()=>{const e=document.activeElement,r=t.getRootElement();r===null||e!==null&&r.contains(e)||r.focus({preventScroll:!0})},{defaultSelection:n})},[n,t]),null}const gu=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,tg=gu?P.useLayoutEffect:P.useEffect,br={tag:jt};function ng({initialConfig:n,children:t}){const e=P.useMemo(()=>{const{theme:r,namespace:i,nodes:s,onError:o,editorState:l,html:a}=n,c=Zh(null,r),d=dc({editable:n.editable,html:a,namespace:i,nodes:s,onError:f=>o(f,d),theme:r});return function(f,h){if(h!==null){if(h===void 0)f.update(()=>{const m=ee();if(m.isEmpty()){const g=Q();m.append(g);const y=gu?document.activeElement:null;(D()!==null||y!==null&&y===f.getRootElement())&&g.select()}},br);else if(h!==null)switch(typeof h){case"string":{const m=f.parseEditorState(h);
1f.setEditorState(m,br);break}case"object":f.setEditorState(h,br);break;case"function":f.update(()=>{ee().isEmpty()&&h(f)},br)}}}(d,l),[d,c]},[]);return tg(()=>{const r=n.editable,[i]=e;i.setEditable(r===void 0||r)},[]),u.jsx(hu.Provider,{value:e,children:t})}function rg(){return ee().getTextContent()}function ig(n,t=!0){if(n)return!1;let e=rg();return t&&(e=e.trim()),e===""}function sg(n){if(!ig(n,!1))return!1;const t=ee().getChildren(),e=t.length;if(e>1)return!1;for(let r=0;r<e;r++){const i=t[r];if(J(i))return!1;if(C(i)){if(!Rs(i)||i.__indent!==0)return!1;const s=i.getChildren(),o=s.length;for(let l=0;l<o;l++){const a=s[r];if(!M(a))return!1}}}return!0}function mu(n){return()=>sg(n)}const pu=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?P.useLayoutEffect:P.useEffect;function og({editor:n,ariaActiveDescendant:t,ariaAutoComplete:e,ariaControls:r,ariaDescribedBy:i,ariaErrorMessage:s,ariaExpanded:o,ariaInvalid:l,ariaLabel:a,ariaLabelledBy:c,ariaMultiline:d,ariaOwns:f,ariaRequired:h,autoCapitalize:m,className:g,id:y,role:p="textbox",spellCheck:_=!0,style:x,tabIndex:b,"data-testid":N,...j},v){const[k,S]=P.useState(n.isEditable()),T=P.useCallback($=>{$&&$.ownerDocument&&$.ownerDocument.defaultView?n.setRootElement($):n.setRootElement(null)},[n]),A=P.useMemo(()=>function(...$){return z=>{for(const R of $)typeof R=="function"?R(z):R!=null&&(R.current=z)}}(v,T),[T,v]);return pu(()=>(S(n.isEditable()),n.registerEditableListener($=>{S($)})),[n]),u.jsx("div",{"aria-activedescendant":k?t:void 0,"aria-autocomplete":k?e:"none","aria-controls":k?r:void 0,"aria-describedby":i,...s!=null?{"aria-errormessage":s}:{},"aria-expanded":k&&p==="combobox"?!!o:void 0,...l!=null?{"aria-invalid":l}:{},"aria-label":a,"aria-labelledby":c,"aria-multiline":d,"aria-owns":k?f:void 0,"aria-readonly":!k||void 0,"aria-required":h,autoCapitalize:m,className:g,contentEditable:k,"data-testid":N,id:y,ref:A,role:p,spellCheck:_,style:x,tabIndex:b,...j})}const lg=P.forwardRef(og);function Fl(n){return n.getEditorState().read(mu(n.isComposing()))}const ag=P.forwardRef(cg);function cg(n,t){const{placeholder:e,...r}=n,[i]=$e();return u.jsxs(u.Fragment,{children:[u.jsx(lg,{editor:i,...r,ref:t}),e!=null&&u.jsx(ug,{editor:i,content:e})]})}function ug({content:n,editor:t}){const e=function(o){const[l,a]=P.useState(()=>Fl(o));return pu(()=>{function c(){const d=Fl(o);a(d)}return c(),Te(o.registerUpdateListener(()=>{c()}),o.registerEditableListener(()=>{c()}))},[o]),l}(t),[r,i]=P.useState(t.isEditable());if(P.useLayoutEffect(()=>(i(t.isEditable()),t.registerEditableListener(o=>{i(o)})),[t]),!e)return null;let s=null;return typeof n=="function"?s=n(r):n!==null&&(s=n),s===null?null:u.jsx("div",{"aria-hidden":!0,children:s})}const dg=P.createContext(null),zi={didCatch:!1,error:null};class fg extends P.Component{constructor(t){super(t),this.resetErrorBoundary=this.resetErrorBoundary.bind(this),this.state=zi}static getDerivedStateFromError(t){return{didCatch:!0,error:t}}resetErrorBoundary(...t){var r,i;const{error:e}=this.state;e!==null&&((i=(r=this.props).onReset)==null||i.call(r,{args:t,reason:"imperative-api"}),this.setState(zi))}componentDidCatch(t,e){var r,i;(i=(r=this.props).onError)==null||i.call(r,t,e)}componentDidUpdate(t,e){var s,o;const{didCatch:r}=this.state,{resetKeys:i}=this.props;r&&e.error!==null&&hg(t.resetKeys,i)&&((o=(s=this.props).onReset)==null||o.call(s,{next:i,prev:t.resetKeys,reason:"keys"}),this.setState(zi))}render(){const{children:t,fallbackRender:e,FallbackComponent:r,fallback:i}=this.props,{didCatch:s,error:o}=this.state;let l=t;if(s){const a={error:o,resetErrorBoundary:this.resetErrorBoundary};if(typeof e=="function")l=e(a);else if(r)l=P.createElement(r,a);else if(i!==void 0)l=i;else throw o}return P.createElement(dg.Provider,{value:{didCatch:s,error:o,resetErrorBoundary:this.resetErrorBoundary}},l)}}function hg(n=[],t=[]){return n.length!==t.length||n.some((e,r)=>!Object.is(e,t[r]))}function gg({children:n,onError:t}){return u.jsx(fg,{fallback:u.jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:t,children:n})}function mg(n,t,e,r,i){if(n===null||e.size===0&&r.size===0&&!i)return 0;const s=t._selection,o=n._selection;if(i)return 1;if(!(E(s)&&E(o)&&o.isCollapsed()&&s.isCollapsed()))return 0;const l=function(_,x,b){const N=_._nodeMap,j=[];for(const v of x){const k=N.get(v);k!==void 0&&j.push(k)}for(const[v,k]of b){if(!k)continue;const S=N.get(v);S===void 0||ie(S)||j.push(S)}return j}(t,e,r);
1if(l.length===0)return 0;if(l.length>1){const _=t._nodeMap,x=_.get(s.anchor.key),b=_.get(o.anchor.key);return x&&b&&!n._nodeMap.has(x.__key)&&M(x)&&x.__text.length===1&&s.anchor.offset===1?2:0}const a=l[0],c=n._nodeMap.get(a.__key);if(!M(c)||!M(a)||c.__mode!==a.__mode)return 0;const d=c.__text,f=a.__text;if(d===f)return 0;const h=s.anchor,m=o.anchor;if(h.key!==m.key||h.type!=="text")return 0;const g=h.offset,y=m.offset,p=f.length-d.length;return p===1&&y===g-1?2:p===-1&&y===g+1?3:p===-1&&y===g?4:0}function pg(n,t,e){let r=e(),i=0,s=r,o=0,l=null;return(a,c,d,f,h,m)=>{const g=e();if(m.has(qa)&&(s=r,o=i,l=a),m.has(as))return i=0,r=g,2;m.has(Ha)&&l&&(r=s,i=o,a=l);const y=mg(a,c,f,h,n.isComposing()),p=(()=>{const _=d===null||d.editor===n,x=m.has(tf);if(!x&&_&&m.has(jt))return 0;if(y===1)return 2;if(a===null)return 1;const b=c._selection;if(!(f.size>0||h.size>0))return b!==null?0:2;const N=typeof t=="number"?t:t.peek();return x===!1&&y!==0&&y===i&&g<r+N&&_||f.size===1&&function(j,v,k){const S=v._nodeMap.get(j),T=k._nodeMap.get(j),A=v._selection,$=k._selection;return!(E(A)&&E($)&&A.anchor.type==="element"&&A.focus.type==="element"&&$.anchor.type==="text"&&$.focus.type==="text"||!M(S)||!M(T)||S.__parent!==T.__parent)&&JSON.stringify(v.read(()=>S.exportJSON()))===JSON.stringify(k.read(()=>T.exportJSON()))}(Array.from(f)[0],a,c)?0:1})();return r=g,i=y,p}}function $l(n){n.undoStack=[],n.redoStack=[],n.current=null}function _u(n,t,e,r=Date.now){const i=pg(n,e,r);return Te(n.registerCommand(li,()=>(function(s,o){const l=o.redoStack,a=o.undoStack;if(a.length!==0){const c=o.current,d=a.pop();c!==null&&(l.push(c),s.dispatchCommand(Pn,!0)),a.length===0&&s.dispatchCommand(Fn,!1),o.current=d||null,d&&d.editor.setEditorState(d.editorState,{tag:as})}}(n,t),!0),B),n.registerCommand(ai,()=>(function(s,o){const l=o.redoStack,a=o.undoStack;if(l.length!==0){const c=o.current;c!==null&&(a.push(c),s.dispatchCommand(Fn,!0));const d=l.pop();l.length===0&&s.dispatchCommand(Pn,!1),o.current=d||null,d&&d.editor.setEditorState(d.editorState,{tag:as})}}(n,t),!0),B),n.registerCommand(Ud,()=>($l(t),!1),B),n.registerCommand(Jd,()=>($l(t),n.dispatchCommand(Pn,!1),n.dispatchCommand(Fn,!1),!0),B),n.registerUpdateListener(({editorState:s,prevEditorState:o,dirtyLeaves:l,dirtyElements:a,tags:c})=>{const d=t.current,f=t.redoStack,h=t.undoStack,m=d===null?null:d.editorState;if(d!==null&&s===m)return;const g=i(o,s,d,l,a,c);if(g===1)f.length!==0&&(t.redoStack=[],n.dispatchCommand(Pn,!1)),d!==null&&(h.push({...d}),n.dispatchCommand(Fn,!0));else if(g===2)return;t.current={editor:n,editorState:s}}))}function yu(){return{current:null,redoStack:[],undoStack:[]}}const Ki={build:(n,{delay:t,createInitialHistoryState:e,disabled:r,now:i})=>io({delay:t,disabled:r,historyState:e(n),now:i}),config:{createInitialHistoryState:yu,delay:300,disabled:typeof window>"u",now:Date.now},name:"@lexical/history/History",register:(n,t,e)=>{const r=e.getOutput();return pi(()=>r.disabled.value?void 0:_u(n,r.historyState.value,r.delay,()=>r.now.peek()()))}};qf(Ki,{disabled:!0});function _g({delay:n,externalHistoryState:t}){const[e]=$e();return function(r,i,s=1e3){const o=P.useMemo(()=>i||yu(),[i]);P.useEffect(()=>_u(r,o,s),[s,r,o])}(e,t,n),null}function yg({validateUrl:n,attributes:t}){const[e]=$e();return P.useEffect(()=>{if(!e.hasNodes([Ct]))throw new Error("LinkPlugin: LinkNode not registered on editor")}),P.useEffect(()=>Wh(e,io({attributes:t,validateUrl:n})),[e,n,t]),null}function xg({hasStrictIndent:n=!1,shouldPreserveNumbering:t=!1}){const[e]=$e();return P.useEffect(()=>{if(!e.hasNodes([cr,bn]))throw new Error("ListPlugin: ListNode and/or ListItemNode not registered on editor")},[e]),P.useEffect(()=>Te(Pl(e,{restoreNumbering:t}),n?Xh(e):()=>{}),[e,n,t]),function(r){P.useEffect(()=>Pl(r),[r])}(e),null}const vg=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?P.useLayoutEffect:P.useEffect;function bg({ignoreHistoryMergeTagChange:n=!0,ignoreSelectionChange:t=!1,onChange:e}){const[r]=$e();return vg(()=>{if(e)return r.registerUpdateListener(({editorState:i,dirtyElements:s,dirtyLeaves:o,prevEditorState:l,tags:a})=>{t&&s.size===0&&o.size===0||n&&a.has(jt)||l.isEmpty()||e(i,r,a)})},[r,n,t,e]),null}const Cg=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?P.useLayoutEffect:P.useEffect;function Sg(n){return{initialValueFn:()=>n.isEditable(),subscribe:t=>
1n.registerEditableListener(t)}}function Ng(){return function(n){const[t]=$e(),e=P.useMemo(()=>n(t),[t,n]),[r,i]=P.useState(()=>e.initialValueFn()),s=P.useRef(r);return Cg(()=>{const{initialValueFn:o,subscribe:l}=e,a=o();return s.current!==a&&(s.current=a,i(a)),l(c=>{s.current=c,i(c)})},[e,n]),r}(Sg)}const kg={name:"@lexical/react/ReactProvider"};function wg(n){const t=window.location.origin,e=r=>{if(r.origin!==t)return;const i=n.getRootElement();if(document.activeElement!==i)return;const s=r.data;if(typeof s=="string"){let o;try{o=JSON.parse(s)}catch(l){return}if(o&&o.protocol==="nuanria_messaging"&&o.type==="request"){const l=o.payload;if(l&&l.functionId==="makeChanges"){const a=l.args;if(a){const[c,d,f,h,m]=a;n.update(()=>{const g=D();if(E(g)){const y=g.anchor;let p=y.getNode(),_=0,x=0;if(M(p)&&c>=0&&d>=0&&(_=c,x=c+d,g.setTextNodeRange(p,_,p,x)),_===x&&f===""||(g.insertRawText(f),p=y.getNode()),M(p)){_=h,x=h+m;const b=p.getTextContentSize();_=_>b?b:_,x=x>b?b:x,g.setTextNodeRange(p,_,p,x)}r.stopImmediatePropagation()}})}}}}};return window.addEventListener("message",e,!0),()=>{window.removeEventListener("message",e,!0)}}function ei(n,...t){const e=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const i of t)r.append("v",i);throw e.search=r.toString(),Error("Minified Lexical error #".concat(n,"; visit ").concat(e.toString()," for the full message or use the non-minified dev environment for full errors and additional helpful warnings."))}function xu(n,t=D()){return t==null&&ei(166),E(t)&&t.isCollapsed()||t.getNodes().length===0?"":iu(n,t)}function vu(n,t=D()){return t==null&&ei(166),E(t)&&t.isCollapsed()||t.getNodes().length===0?null:JSON.stringify(Mg(n,t))}function ws(n,t,e){const r=n.getData("application/x-lexical-editor");if(r)try{const l=JSON.parse(r);if(l.namespace===e._config.namespace&&Array.isArray(l.nodes))return Ll(e,Ag(l.nodes),t)}catch(l){console.error(l)}const i=n.getData("text/html"),s=n.getData("text/plain");if(i&&s!==i)try{const l=new DOMParser().parseFromString(function(a){return window.trustedTypes&&window.trustedTypes.createPolicy?window.trustedTypes.createPolicy("lexical",{createHTML:c=>c}).createHTML(a):a}(i),"text/html");return Ll(e,ru(e,l),t)}catch(l){console.error(l)}const o=s||n.getData("text/uri-list");if(o!=null)if(E(t)){const l=o.split(/(\r?\n|\t)/);l[l.length-1]===""&&l.pop();for(let a=0;a<l.length;a++){const c=D();if(E(c)){const d=l[a];d==="\n"||d==="\r\n"?c.insertParagraph():d==="	"?c.insertNodes([tr()]):c.insertText(d)}}}else t.insertRawText(o)}const bu="application/x-lexical-drag";function Tg(n,t){const e={editorKey:t.getKey()};n.setData(bu,JSON.stringify(e))}function Eg(n){const t=function(i,s){if(document.caretRangeFromPoint!==void 0){const o=document.caretRangeFromPoint(i,s);return o===null?null:{node:o.startContainer,offset:o.startOffset}}if(document.caretPositionFromPoint!=="undefined"){const o=document.caretPositionFromPoint(i,s);return o===null?null:{node:o.offsetNode,offset:o.offset}}return null}(n.clientX,n.clientY);if(t===null)return null;const e=Rt(t.node);if(e===null)return null;if(M(e))return mt(e,"next",t.offset);if(C(e))return vs(e,t.offset,"next");const r=e.getParent();return r===null?null:vs(r,e.getIndexWithinParent()+1,"next")}function jg(n,t,e){const r=n.dataTransfer;if(r===null)return!1;const i=function(c){const d=c.getData(bu);if(!d)return null;let f;try{f=JSON.parse(d)}catch(m){return null}return(h=f)!==null&&typeof h=="object"&&"editorKey"in h&&typeof h.editorKey=="string"?f:null;var h}(r);if(i===null)return!1;const s=Eg(n);if(s===null)return!1;const o=Ac(s);if(o===null)return!1;const l=i.editorKey===t.getKey(),a=D();if(l){if(!E(a)||a.isCollapsed())return!1;if(function(c,d){const{anchor:f,focus:h}=to(Yr(d),"next");return Hr(f,c)<0&&Hr(c,h)<0}(s,a))return n.preventDefault(),!0;a.removeText()}if(!o.origin.isAttached())return n.preventDefault(),!0;if(e(r,Oc(Tc(o)),t),!l){const c=t.getRootElement(),d=c?c.ownerDocument:null,f=d?function(h,m){const g=m.querySelectorAll('[data-lexical-editor="true"]');for(const y of Array.from(g)){const p=y.__lexicalEditor;if(p&&p.getKey()===h)return y}return null}(i.editorKey,d):null;f!==null&&f.dispatchEvent(new InputEvent("beforeinput",{bubbles:!0,cancelable:!0,inputType:"deleteByDrag"}))}return n.preventDefault(),!0}function Og(n,t){return jg(n,t,ws)}function Ll(n,t,e){n.dispatchCommand(Rd,{nodes:t,selection:e}
1)||(e.insertNodes(t),function(r){if(E(r)&&r.isCollapsed()){const i=r.anchor;let s=null;const o=Ue(i,"previous");if(o)if(De(o))s=o.origin;else{const l=pt(o,be(ee(),"next").getFlipped());for(const a of l){if(M(a.origin)){s=a.origin;break}if(C(a.origin)&&!a.origin.isInline())break}}if(s&&M(s)){const l=s.getFormat(),a=s.getStyle();r.format===l&&r.style===a||(r.format=l,r.style=a,r.dirty=!0)}}}(e))}function Cu(n,t,e,r=[]){let i=t===null||e.isSelected(t);const s=C(e)&&e.excludeFromCopy("html");let o=e;t!==null&&M(o)&&(o=$c(t,o,"clone"));const l=C(o)?o.getChildren():[],a=function(c){const d=c.exportJSON(),f=c.constructor;if(d.type!==f.getType()&&ei(58,f.name),C(c)){const h=d.children;Array.isArray(h)||ei(59,f.name)}return d}(o);M(o)&&o.getTextContentSize()===0&&(i=!1);for(let c=0;c<l.length;c++){const d=l[c],f=Cu(n,t,d,a.children);!i&&C(e)&&f&&e.extractWithChild(d,t,"clone")&&(i=!0)}if(i&&!s)r.push(a);else if(Array.isArray(a.children))for(let c=0;c<a.children.length;c++){const d=a.children[c];r.push(d)}return i}function Mg(n,t){const e=[],r=ee().getChildren();for(let i=0;i<r.length;i++)Cu(n,t,r[i],e);return{namespace:n._config.namespace,nodes:e}}function Ag(n){const t=[];for(let e=0;e<n.length;e++){const r=n[e],i=vf(r);t.push(i)}return t}let Qt=null;async function Il(n,t,e){if(Qt!==null)return!1;if(t!==null)return new Promise((c,d)=>{n.update(()=>{c(Rl(n,t,e))})});const r=n.getRootElement(),i=n._window||window,s=i.document,o=Ee(i);if(r===null||o===null)return!1;const l=s.createElement("span");l.style.position="fixed",l.style.top="-1000px",l.append(s.createTextNode("#")),r.append(l);const a=new Range;return a.setStart(l,0),a.setEnd(l,1),o.removeAllRanges(),o.addRange(a),new Promise((c,d)=>{const f=n.registerCommand(ci,h=>(dt(h,ClipboardEvent)&&(f(),Qt!==null&&(i.clearTimeout(Qt),Qt=null),c(Rl(n,h,e))),!0),Sf);Qt=i.setTimeout(()=>{f(),Qt=null,c(!1)},50),s.execCommand("copy"),l.remove()})}function Rl(n,t,e){if(e===void 0){const i=Ee(n._window),s=D();if(!s||s.isCollapsed()||!i)return!1;const o=i.anchorNode,l=i.focusNode;if(o!==null&&l!==null&&!ir(n,o,l))return!1;e=Su(s)}t.preventDefault();const r=t.clipboardData;return r!==null&&(Nu(r,e),!0)}const Dg=[["text/html",xu],["application/x-lexical-editor",vu]];function Su(n=D()){return function(t,e){const r={"text/plain":""};for(const[i,s]of Object.entries(t)){const o=Pg(s,e);o!==null&&(r[i]=o)}return r}(function(){const t=nt(),e=ar.maybeFromEditor(t);return e&&e.hasExtensionByName(Bl.name)?Yc(t,Bl).output:ku}(),n)}function Nu(n,t){for(const[e]of Dg)t[e]===void 0&&n.setData(e,"");for(const e in t){const r=t[e];r!==void 0&&n.setData(e,r)}}const ku={"application/x-lexical-editor":[(n,t)=>n?vu(nt(),n):t()],"text/html":[(n,t)=>n?xu(nt(),n):t()],"text/plain":[(n,t)=>n?n.getTextContent():t()]};function Pg(n,t){const e=r=>n[r]?n[r](t,e.bind(null,r-1)):null;return e(n.length-1)}const Bl={build:(n,t,e)=>t.$exportMimeType,config:{$exportMimeType:ku},mergeConfig(n,t){const e=no(n,t);if(t.$exportMimeType){const r={...n.$exportMimeType};for(const[i,s]of Object.entries(t.$exportMimeType))r[i]=[...r[i],...s];e.$exportMimeType=r}return e},name:"@lexical/clipboard/GetClipboardData"};function zl(n,t){if(document.caretRangeFromPoint!==void 0){const e=document.caretRangeFromPoint(n,t);return e===null?null:{node:e.startContainer,offset:e.startOffset}}if(document.caretPositionFromPoint!=="undefined"){const e=document.caretPositionFromPoint(n,t);return e===null?null:{node:e.offsetNode,offset:e.offset}}return null}const St=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Fg=St&&"documentMode"in document?document.documentMode:null,$g=St&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),Lg=!(!St||!("InputEvent"in window)||Fg)&&"getTargetRanges"in new window.InputEvent("input"),Kl=St&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Ig=St&&/Android/.test(navigator.userAgent),Rg=St&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent)&&!Ig,Bg=St&&/^(?=.*Chrome).*/i.test(navigator.userAgent),zg=St&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&$g&&!Bg,Wl=L("DRAG_DROP_PASTE_FILE");class ur extends we{static getType(){return"quote"}static clone(t){return new ur(t.__key)}createDOM(t){const e=document.createElement("blockquote");return lr(e,t.theme.quote),e}updateDOM(t,e){return!1}static importDOM(){return{blockquote:t=>({conversion:Wg,priority:0})}}exportDOM(t){const{element:e}=super.exportDOM(t);if(te(e)){this.isEmpty()&&e.append(document.createElement("br"));const r=this.getFormatType();r&&(e.style.textAlign=r);const i=this.getDirection();i&&(e.dir=i)}return{element:e}}static importJSON(t){return lo().updateFromJSON(t)}insertNewAfter(t,e){const r=Q(),i=this.getDirection();return r.setDirection(i),this.insertAfter(r,e),r}collapseAtStart(){const t=Q();
1return this.getChildren().forEach(e=>t.append(e)),this.replace(t),!0}canMergeWhenEmpty(){return!0}}function lo(){return Ve(new ur)}function Kg(n){return n instanceof ur}class dr extends we{constructor(e="h1",r){super(r);w(this,"__tag");this.__tag=e}static getType(){return"heading"}static clone(e){return new dr(e.__tag,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__tag=e.__tag}getTag(){return this.getLatest().__tag}setTag(e){const r=this.getWritable();return r.__tag=e,r}createDOM(e){const r=this.__tag,i=document.createElement(r),s=e.theme.heading;if(s!==void 0){const o=s[r];lr(i,o)}return i}updateDOM(e,r,i){return e.__tag!==this.__tag}static importDOM(){return{h1:e=>({conversion:Xt,priority:0}),h2:e=>({conversion:Xt,priority:0}),h3:e=>({conversion:Xt,priority:0}),h4:e=>({conversion:Xt,priority:0}),h5:e=>({conversion:Xt,priority:0}),h6:e=>({conversion:Xt,priority:0}),p:e=>{const r=e.firstChild;return r!==null&&Ul(r)?{conversion:()=>({node:null}),priority:3}:null},span:e=>Ul(e)?{conversion:r=>({node:rn("h1")}),priority:3}:null}}exportDOM(e){const{element:r}=super.exportDOM(e);if(te(r)){this.isEmpty()&&r.append(document.createElement("br"));const i=this.getFormatType();i&&(r.style.textAlign=i);const s=this.getDirection();s&&(r.dir=s)}return{element:r}}static importJSON(e){return rn(e.tag).updateFromJSON(e)}updateFromJSON(e){return super.updateFromJSON(e).setTag(e.tag)}exportJSON(){return{...super.exportJSON(),tag:this.getTag()}}insertNewAfter(e,r=!0){const i=e?e.anchor.offset:0,s=this.getLastDescendant(),o=!s||e&&e.anchor.key===s.getKey()&&i===s.getTextContentSize()||!e?Q():rn(this.getTag()),l=this.getDirection();if(o.setDirection(l),this.insertAfter(o,r),i===0&&!this.isEmpty()&&e){const a=Q();a.select(),this.replace(a,!0)}return o}collapseAtStart(){const e=this.isEmpty()?Q():rn(this.getTag());
1return this.getChildren().forEach(r=>e.append(r)),this.replace(e),!0}extractWithChild(){return!0}}function Ul(n){return n.nodeName.toLowerCase()==="span"&&n.style.fontSize==="26pt"}function Xt(n){const t=n.nodeName.toLowerCase();let e=null;return t!=="h1"&&t!=="h2"&&t!=="h3"&&t!=="h4"&&t!=="h5"&&t!=="h6"||(e=rn(t),n.style!==null&&(Ys(n,e),e.setFormat(n.style.textAlign))),{node:e}}function Wg(n){const t=lo();return n.style!==null&&(t.setFormat(n.style.textAlign),Ys(n,t)),{node:t}}function rn(n="h1"){return Ve(new dr(n))}function Ug(n){return n instanceof dr}function Cr(n){let t=null;if(dt(n,DragEvent)?t=n.dataTransfer:dt(n,ClipboardEvent)&&(t=n.clipboardData),t===null)return[!1,[],!1];const e=t.types,r=e.includes("Files"),i=e.includes("text/html")||e.includes("text/plain");return[r,Array.from(t.files),i]}function Jl(n){const t=Rt(n);return J(t)}function Wi(n){for(const t of["lowercase","uppercase","capitalize"])n.hasFormat(t)&&n.toggleFormat(t)}function Jg(n){return Te(n.registerCommand(xa,t=>{const e=D();return!!he(e)&&(e.clear(),!0)},B),n.registerCommand(Et,t=>{const e=D();return E(e)?(e.deleteCharacter(t),!0):!!he(e)&&(e.deleteNodes(),!0)},B),n.registerCommand(Yn,t=>{const e=D();return!!E(e)&&(e.deleteWord(t),!0)},B),n.registerCommand(Gn,t=>{const e=D();return!!E(e)&&(e.deleteLine(t),!0)},B),n.registerCommand(ln,t=>{const e=D();if(typeof t=="string")e!==null&&e.insertText(t);else{if(e===null)return!1;const r=t.dataTransfer;if(r!=null)ws(r,e,n);else if(E(e)){const i=t.data;return i&&e.insertText(i),!0}}return!0},B),n.registerCommand(Nr,()=>{const t=D();return!!E(t)&&(t.removeText(),!0)},B),n.registerCommand(Ne,t=>{const e=D();return!!E(e)&&(e.formatText(t),!0)},B),n.registerCommand(Dn,t=>{const e=D();if(!E(e)&&!he(e))return!1;const r=e.getNodes();for(const i of r){const s=de(i,o=>C(o)&&!o.isInline());s!==null&&s.setFormat(t)}return!0},B),n.registerCommand(on,t=>{const e=D();return!!E(e)&&(e.insertLineBreak(t),!0)},B),n.registerCommand(Hn,()=>{const t=D();return!!E(t)&&(t.insertParagraph(),!0)},B),n.registerCommand(Kd,()=>{const t=tr(),e=D();return E(e)&&(t.setFormat(e.format),t.setStyle(e.style)),_f([t]),!0},B),n.registerCommand(Pa,()=>hl(t=>{const e=t.getIndent();t.setIndent(e+1)}),B),n.registerCommand(ts,()=>hl(t=>{const e=t.getIndent();e>0&&t.setIndent(Math.max(0,e-1))}),B),n.registerCommand(Ta,t=>{const e=D();if(he(e)){const r=e.getNodes();if(r.length>0)return t.preventDefault(),r[0].selectPrevious(),!0}else if(E(e)){const r=ms(e.focus,!0);if(!t.shiftKey&&J(r)&&!r.isIsolated()&&!r.isInline())return r.selectPrevious(),t.preventDefault(),!0}return!1},B),n.registerCommand(Ea,t=>{const e=D();if(he(e)){const r=e.getNodes();if(r.length>0)return t.preventDefault(),r[0].selectNext(0,0),!0}else if(E(e)){if(function(i){const s=i.focus;return s.key==="root"&&s.offset===ee().getChildrenSize()}(e))return t.preventDefault(),!0;const r=ms(e.focus,!1);if(!t.shiftKey&&J(r)&&!r.isIsolated()&&!r.isInline())return r.selectNext(),t.preventDefault(),!0}return!1},B),n.registerCommand(wa,t=>{const e=D();if(he(e)){const r=e.getNodes();if(r.length>0)return t.preventDefault(),cl(r[0])?r[0].selectNext(0,0):r[0].selectPrevious(),!0}if(!E(e))return!1;if(dl(e,!0)){const r=t.shiftKey;return t.preventDefault(),fl(e,r,!0),!0}return!1},B),n.registerCommand(ka,t=>{const e=D();if(he(e)){const i=e.getNodes();if(i.length>0)return t.preventDefault(),cl(i[0])?i[0].selectPrevious():i[0].selectNext(0,0),!0}if(!E(e))return!1;const r=t.shiftKey;return!!dl(e,!1)&&(t.preventDefault(),fl(e,r,!1),!0)},B),n.registerCommand(Oa,t=>{if(Jl(t.target))return!1;const e=D();if(E(e)){if(function(r){if(!r.isCollapsed())return!1;const{anchor:i}=r;if(i.offset!==0)return!1;const s=i.getNode();if(ie(s))return!1;const o=rh(s);return o.getIndent()>0&&(o.is(s)||s.is(o.getFirstDescendant()))}(e))return t.preventDefault(),n.dispatchCommand(ts,void 0);if(Kl&&navigator.language==="ko-KR")return!1}else if(!he(e))return!1;return t.preventDefault(),n.dispatchCommand(Et,!0)},B),n.registerCommand(Aa,t=>{if(Jl(t.target))return!1;const e=D();return!(!E(e)&&!he(e))&&(t.preventDefault(),n.dispatchCommand(Et,!1))},B),n.registerCommand(Ir,t=>{const e=D();if(!E(e))return!1;if(Wi(e),t!==null){if((Kl||Rg||zg)&&Lg)return!1;if(t.preventDefault(),t.shiftKey)return n.dispatchCommand(on,!1)}return n.dispatchCommand(Hn,void 0)},B),n.registerCommand(Ma,()=>{const t=D();return!!E(t)&&(n.blur(),!0)},B),n.registerCommand(Fa,t=>{const[,e]=Cr(t);if(e.length>0){const r=zl(t.clientX,t.clientY);if(r!==null){const{offset:i,node:s}=r,o=Rt(s);if(o!==null){const l=Ps();if(M(o))l.anchor.set(o.getKey(),i,"text"),l.focus.set(o.getKey(),i,"text");else{const c=o.getParentOrThrow().getKey(),d=o.getIndexWithinParent()+1;l.anchor.set(c,d,"element"),l.focus.set(c,d,"element")}const a=Pt(l);me(a)}n.dispatchCommand(Wl,e)}return t.preventDefault(),!0}return Og(t,n)},B),n.registerCommand($a,t=>{const[e]=Cr(t),r=D();return!(e&&!E(r))&&(E(r)&&!r.isCollapsed()&&t.dataTransfer!==null&&(Nu(t.dataTransfer,Su(r)),Tg(t.dataTransfer,n
1)),!0)},B),n.registerCommand(La,t=>{const[e]=Cr(t),r=D();if(e&&!E(r))return!1;const i=zl(t.clientX,t.clientY);if(i!==null){const s=Rt(i.node);J(s)&&t.preventDefault()}return!0},B),n.registerCommand(ns,()=>(jf(),!0),B),n.registerCommand(ci,t=>(Il(n,dt(t,ClipboardEvent)?t:null),!0),B),n.registerCommand(As,t=>(async function(e,r){await Il(r,dt(e,ClipboardEvent)?e:null),r.update(()=>{const i=D();E(i)?i.removeText():he(i)&&i.getNodes().forEach(s=>s.remove())})}(t,n),!0),B),n.registerCommand(oi,t=>{const[,e,r]=Cr(t);return e.length>0&&!r?(n.dispatchCommand(Wl,e),!0):xn(t.target)&&Ks(t.target)?!1:D()!==null&&(function(i,s){i.preventDefault(),s.update(()=>{const o=D(),l=dt(i,InputEvent)||dt(i,KeyboardEvent)?null:i.clipboardData;l!=null&&o!==null&&ws(l,o,s)},{tag:nf})}(t,n),!0)},B),n.registerCommand(ja,t=>{const e=D();return E(e)&&Wi(e),!1},B),n.registerCommand(Da,t=>{const e=D();return E(e)&&Wi(e),!1},B))}function Vg(n,...t){const e=new URL("https://lexical.dev/docs/error"),r=new URLSearchParams;r.append("code",n);for(const i of t)r.append("v",i);throw e.search=r.toString(),Error("Minified Lexical error #".concat(n,"; visit ").concat(e.toString()," for the full message or use the non-minified dev environment for full errors and additional helpful warnings."))}const ao=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?P.useLayoutEffect:P.useEffect;function qg({editor:n,ErrorBoundary:t}){return function(e,r){const[i,s]=P.useState(()=>e.getDecorators());return ao(()=>e.registerDecoratorListener(o=>{fo.flushSync(()=>{s(o)})}),[e]),P.useEffect(()=>{s(e.getDecorators())},[e]),P.useMemo(()=>{const o=[],l=Object.keys(i);for(let a=0;a<l.length;a++){const c=l[a],d=u.jsx(r,{onError:h=>e._onError(h),children:u.jsx(P.Suspense,{fallback:null,children:i[c]})}),f=e.getElementByKey(c);f!==null&&o.push(fo.createPortal(d,f,c))}return o},[r,i,e])}(n,t)}function Hg({editor:n,ErrorBoundary:t}){return function(e){const r=ar.maybeFromEditor(e);if(r&&r.hasExtensionByName(kg.name)){for(const i of["@lexical/plain-text","@lexical/rich-text"])r.hasExtensionByName(i)&&Vg(320,i);return!0}return!1}(n)?null:u.jsx(qg,{editor:n,ErrorBoundary:t})}function Vl(n){return n.getEditorState().read(mu(n.isComposing()))}function Yg({contentEditable:n,placeholder:t=null,ErrorBoundary:e}){const[r]=$e();return function(i){ao(()=>Te(Jg(i),wg(i)),[i])}(r),u.jsxs(u.Fragment,{children:[n,u.jsx(Gg,{content:t}),u.jsx(Hg,{editor:r,ErrorBoundary:e})]})}function Gg({content:n}){const[t]=$e(),e=function(i){const[s,o]=P.useState(()=>Vl(i));return ao(()=>{function l(){const a=Vl(i);o(a)}return l(),Te(i.registerUpdateListener(()=>{l()}),i.registerEditableListener(()=>{l()}))},[i]),s}(t),r=Ng();return e?typeof n=="function"?n(r):n:null}const wu="Arial, sans-serif",Tu="16px",Eu="#1d2a45",ju="#ffffff",Qg=[{label:"Sans",value:"Arial, sans-serif"},{label:"Serif",value:"Georgia, serif"},{label:"Mono",value:'"Courier New", monospace'},{label:"Clean",value:'"Trebuchet MS", sans-serif'},{label:"Classic",value:'"Times New Roman", serif'}],Xg=["12px","14px","16px","18px","20px","24px","30px"],Kn={blockType:"paragraph",elementFormat:"left",fontFamily:wu,fontSize:Tu,textColor:Eu,highlightColor:ju,listType:null,isBold:!1,isItalic:!1,isUnderline:!1,isStrikethrough:!1,isLink:!1,canUndo:!1,canRedo:!1},Zg={paragraph:"email-editor__paragraph",quote:"email-editor__quote",heading:{h1:"email-editor__heading email-editor__heading--h1",h2:"email-editor__heading email-editor__heading--h2",h3:"email-editor__heading email-editor__heading--h3"},text:{bold:"email-editor__text--bold",italic:"email-editor__text--italic",underline:"email-editor__text--underline",strikethrough:"email-editor__text--strikethrough",underlineStrikethrough:"email-editor__text--underline-strikethrough"}};function ql(n){return n==="<p><br></p>"?"":n}function em(n){return n?/^(https?:|mailto:|tel:)/i.test(n)?n:"https://".concat(n):""}function tm(){const n=D();if(!E(n))return Kn.blockType;const t=n.anchor.getNode(),e=t.getKey()==="root"?t:t.getTopLevelElementOrThrow();return Ug(e)?e.getTag():Kg(e)?"quote":"paragraph"}function nm(){const n=D();if(!E(n))return Kn.elementFormat;const t=n.anchor.getNode();return(t.getKey()==="root"?t:t.getTopLevelElementOrThrow()).getFormatType()||"left"}function rm(){const n=D();if(!E(n))return null;let t=n.anchor.getNode();for(;t;){if(I(t))return t.getListType()==="number"?"number":"bullet";t=t.getParent()}return null}function im(){const n=D();if(!E(n))return!1;let t=n.anchor.getNode();for(;t;){if(je(t))return!0;t=t.getParent()}return!1}function sm({value:n,onChange:t}){const[e]=$e(),r=P.useRef("");return P.useEffect(()=>{const i=ql(n);i!==r.current&&e.update(()=>{const s=ee();if(s.clear(),!i){s.append(Q()),r.current="";return}const l=new DOMParser().parseFromString(i,"text/html"),a=ru(e,l);a.length===0?s.append(Q()):s.append(...a),r.current=i})},[e,n]),u.jsx(bg,{ignoreSelectionChange:!0,onChange:(i,s)=>{i.read(()=>{const o=ql(iu(s,null));r.current=o,t(o)})}})}function ce({active:n,ariaLabel:t,disabled:e,onClick:r,children:i}){return u.jsx("button",{type:"button",className:"email-editor__button".concat(n?" email-editor__button--active":""),"aria-label":t,title:t,disabled:e,onClick:r,children:i})}function om(){const[n]=$e(),[t,e]=P.useState(Kn);P.useEffect(()=>{const a=()=>{n.getEditorState().read(()=>{const c=D();if(!E(c)){e(f=>({...f,blockType:Kn.blockType,elementFormat:Kn.elementFormat,listType:null,isBold:!1,isItalic:!1,isUnderline:!1,isStrikethrough:!1,isLink:!1}));return}const d={blockType:tm(),elementFormat:nm(),fontFamily:yr(c,"font-family",wu),fontSize:yr(c,"font-size",Tu),textColor:yr(c,"color",Eu),highlightColor:yr(c,"background-color",ju),listType:rm(),isBold:c.hasFormat("bold"),isItalic:c.hasFormat("italic"),isUnderline:c.hasFormat("underline"),isStrikethrough:c.hasFormat("strikethrough"),isLink:im()};e(f=>({...f,...d}))})};return Te(n.registerUpdateListener(()=>{a()}),n.registerCommand(Ms,()=>(a(),!1),Xe),n.registerCommand(Fn,c=>(e(d=>({...d,canUndo:c})),!1),Xe),n.registerCommand(Pn,c=>(e(d=>({...d,canRedo:c})),!1),Xe))},[n]);const r=a=>{n.update(()=>{const c=D();E(c)&&ul(c,a)})},i=a=>{n.update(()=>{const c=D();
1if(E(c)){if(a==="paragraph"){_r(c,()=>Q());return}if(a==="quote"){_r(c,()=>lo());return}_r(c,()=>rn(a))}})},s=()=>{n.update(()=>{const a=D();E(a)&&(a.getNodes().forEach(c=>{M(c)&&(c.setFormat(0),c.setStyle(""))}),ul(a,{"font-family":null,"font-size":null,color:null,"background-color":null}),_r(a,()=>Q()))})},o=()=>{if(t.isLink){n.dispatchCommand(Zr,null);return}const a=window.prompt("Enter a link URL","https://");if(a===null)return;const c=em(a.trim());c&&n.dispatchCommand(Zr,c)},l=a=>{if(a){if(t.listType===a){n.dispatchCommand(fu,void 0);return}n.dispatchCommand(a==="number"?du:uu,void 0)}};return u.jsxs("div",{className:"email-editor__toolbar",children:[u.jsxs("div",{className:"email-editor__group",children:[u.jsx(ce,{ariaLabel:"Undo",disabled:!t.canUndo,onClick:()=>n.dispatchCommand(li,void 0),children:u.jsx(Au,{})}),u.jsx(ce,{ariaLabel:"Redo",disabled:!t.canRedo,onClick:()=>n.dispatchCommand(ai,void 0),children:u.jsx(Du,{})})]}),u.jsxs("div",{className:"email-editor__group",children:[u.jsxs("select",{className:"email-editor__select","aria-label":"Text style",value:t.blockType,onChange:a=>i(a.target.value),children:[u.jsx("option",{value:"paragraph",children:"Normal text"}),u.jsx("option",{value:"h1",children:"Large heading"}),u.jsx("option",{value:"h2",children:"Medium heading"}),u.jsx("option",{value:"h3",children:"Small heading"}),u.jsx("option",{value:"quote",children:"Quote"})]}),u.jsx("select",{className:"email-editor__select","aria-label":"Font family",value:t.fontFamily,onChange:a=>r({"font-family":a.target.value}),children:Qg.map(a=>u.jsx("option",{value:a.value,children:a.label},a.value))}),u.jsx("select",{className:"email-editor__select","aria-label":"Font size",value:t.fontSize,onChange:a=>r({"font-size":a.target.value}),children:Xg.map(a=>u.jsx("option",{value:a,children:a.replace("px","")},a))})]}),u.jsxs("div",{className:"email-editor__group",children:[u.jsx(ce,{active:t.isBold,ariaLabel:"Bold",onClick:()=>n.dispatchCommand(Ne,"bold"),children:u.jsx(Pu,{})}),u.jsx(ce,{active:t.isItalic,ariaLabel:"Italic",onClick:()=>n.dispatchCommand(Ne,"italic"),children:u.jsx("em",{children:"I"})}),u.jsx(ce,{active:t.isUnderline,ariaLabel:"Underline",onClick:()=>n.dispatchCommand(Ne,"underline"),children:u.jsx(Fu,{style:{textDecoration:"underline"}})}),u.jsx(ce,{active:t.isStrikethrough,ariaLabel:"Strikethrough",onClick:()=>n.dispatchCommand(Ne,"strikethrough"),children:u.jsx($u,{})})]}),u.jsxs("div",{className:"email-editor__group",children:[u.jsxs("div",{className:"email-editor__swatch-wrap",title:"Text color",children:[u.jsx("input",{type:"color",className:"email-editor__swatch","aria-label":"Text color",value:t.textColor,onChange:a=>r({color:a.target.value})}),u.jsx(Lu,{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",pointerEvents:"none",fontSize:"1rem",color:"#475569"}}),u.jsx("span",{className:"email-editor__swatch-indicator",style:{backgroundColor:t.textColor}})]}),u.jsxs("div",{className:"email-editor__swatch-wrap",title:"Highlight color",children:[u.jsx("input",{type:"color",className:"email-editor__swatch","aria-label":"Highlight color",value:t.highlightColor,onChange:a=>r({"background-color":a.target.value})}),u.jsx(Iu,{style:{position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",pointerEvents:"none",fontSize:"1rem",color:"#475569"}}),u.jsx("span",{className:"email-editor__swatch-indicator",style:{backgroundColor:t.highlightColor}})]})]}),u.jsxs("div",{className:"email-editor__group",children:[u.jsx(ce,{active:t.elementFormat==="left",ariaLabel:"Align left",onClick:()=>n.dispatchCommand(Dn,"left"),children:u.jsx(Ru,{})}),u.jsx(ce,{active:t.elementFormat==="center",ariaLabel:"Align center",onClick:()=>n.dispatchCommand(Dn,"center"),children:u.jsx(Bu,{})}),u.jsx(ce,{active:t.elementFormat==="right",ariaLabel:"Align right",onClick:()=>n.dispatchCommand(Dn,"right"),children:u.jsx(zu,{})}),u.jsx(ce,{active:t.elementFormat==="justify",ariaLabel:"Justify",onClick:()=>n.dispatchCommand(Dn,"justify"),children:u.jsx(Ku,{})})]}),u.jsxs("div",{className:"email-editor__group",children:[u.jsx(ce,{active:t.listType==="bullet",ariaLabel:"Bulleted list",onClick:()=>l("bullet"),children:u.jsx(Wu,{})}),u.jsx(ce,{active:t.listType==="number",ariaLabel:"Numbered list",onClick:()=>l("number"),children:u.jsx(Uu,{})}),u.jsx(ce,{ariaLabel:"Outdent",onClick:()=>n.dispatchCommand(ts,void 0),children:u.jsx(Ju,{})}),u.jsx(ce,{ariaLabel:"Indent",onClick:()=>n.dispatchCommand(Pa,void 0),children:u.jsx(Vu,{})})]}),u.jsxs("div",{className:"email-editor__group",children:[u.jsx(ce,{active:t.blockType==="quote",ariaLabel:"Quote",onClick:()=>i(t.blockType==="quote"?"paragraph":"quote"),children:u.jsx(qu,{})}),u.jsx(ce,{active:t.isLink,ariaLabel:t.isLink?"Remove link":"Insert link",onClick:o,children:u.jsx(Hu,{})}),u.jsx(ce,{ariaLabel:"Clear formatting",onClick:s,children:u.jsx(Yu,{})})]})]})}function lm({html:n}){const t=P.useMemo(()=>n&&new DOMParser().parseFromString(n,"text/html").body.textContent||"",[n]);return u.jsx("div",{className:"email-editor__footer",children:u.jsxs("span",{children:[t.trim().length," characters"]})})}function am({value:n,onChange:t,placeholder:e="Write your email content here...",minHeight:r=320}){const i=P.useMemo(()=>({namespace:"EmailWysiwygEditor",theme:Zg,nodes:[dr,ur,cr,bn,Ct],onError(s){throw s}}),[]);return u.jsxs("div",{className:"email-editor",children:[u.jsxs(ng,{initialConfig:i,children:[u.jsx(om,{}),u.jsxs("div",{className:"email-editor__surface",children:[u.jsx(Yg,{contentEditable:u.jsx(ag,{className:"email-editor__content",style:{minHeight:r}}),placeholder:u.jsx("div",{className:"email-editor__placeholder",children:e}),ErrorBoundary:gg}),u.jsx(_g,{}),u.jsx(eg,{}),u.jsx(xg,{}),u.jsx(yg,{}),u.jsx(sm,{value:n,onChange:t})]})]}),u.jsx(lm,{html:n})]})}const yi=()=>{const{data:n,mutate:t}=it("/marketing/audience/options",Je);return{options:(n==null?void 0:n.options)||[],mutate:t}},cm={title:"",audience:"all_customers",subject:"",html:"",send_mode:"now",scheduled_at:""};function Hl(){const{id:n}=Ts(),[t]=Ln("audienceId",{defaultValue:""}),[e,r]=P.useState({title:"",audience:t||"all_customers",subject:"",html:"",send_mode:"now",scheduled_at:""}),i=yi(),{data:s,isLoading:o}=it(n&&n!=="new"?"/marketing/campaigns?id=".concat(n):null,Je);P.useEffect(()=>{const p={title:"",subject:"",html:""};if(s){const _=s==null?void 0:s.campaigns[0],{title:x,subject:b,html:N,metadata:j,to_send_at:v}=_||p;r({title:x,subject:b,html:N,audience:j.audience||t,send_mode:v?"schedule":"now",scheduled_at:Gu(v).format("YYYY-MM-DDTHH:mm:ss")})}},[s,t]);const l=!!n,a=ti(),[c,d]=P.useState(!1),[f,h]=P.useState(null),m=P.useCallback((p,_)=>{r(x=>({...x!=null?x:cm,[p]:_}))},[]),g=p=>{const _=[];return e.title.trim()||_.push("Campaign name is required."),e.subject.trim()||_.push("Subject line is required."),e.html.trim()||_.push("Email body is required."),p&&(e.send_mode==="schedule"&&!e.scheduled_at&&_.push("Please pick a date and time to schedule the send."),e.send_mode==="schedule"&&e.scheduled_at&&new Date(e.scheduled_at)<=new Date&&_.push("Scheduled time must be in the future.")),_.length>0?_.join("\n"):null},y=P.useCallback(p=>{const _=g(p);if(_){h(_);return}h(null),d(!0),Wn("/marketing/campaigns",{title:e.title,subject:e.subject,html:e.html,audie
1nce:e.audience,id:n&&n!=="new"?n:void 0}).then(({id:x})=>{if(p)return Wn("/marketing/campaigns/".concat(x,"/schedule"),{to_send_at:e.send_mode==="now"?Date.now():new Date(e.scheduled_at).getTime()}).then(()=>{a("/contacts/marketing",{replace:!0})})}).catch(x=>{}).finally(()=>{d(!1)})},[e,n,l,a]);return o?u.jsx("div",{className:"text-center py-5",children:u.jsx("span",{className:"spinner-border text-primary",role:"status"})}):u.jsxs("div",{children:[u.jsx(sn,{}),u.jsx("h3",{className:"mb-1",children:l?"Edit Campaign":"New Campaign"}),u.jsx("p",{children:l?"Update the campaign details below.":"Fill in the details below to create a new email campaign."}),u.jsxs("div",{className:"border rounded shadow-sm",children:[u.jsx("div",{className:"px-3 py-2 border-bottom",children:u.jsxs("div",{className:"row",children:[u.jsx("div",{className:"col-md-6",children:u.jsx(V,{label:"Campaign name",required:!0,htmlFor:"campaign-name",children:u.jsx(oe,{id:"campaign-name",placeholder:"e.g. Spring sale announcement",value:e.title,onChange:p=>m("title",p)})})}),u.jsxs("div",{className:"col-md-6",children:[u.jsx(V,{label:"Audience",required:!0,children:/[0-9+]/.test(e.audience)?u.jsxs("span",{className:"text-muted d-block mb-1",children:["Contact ID: ",e.audience]}):u.jsx(Ie,{options:(i==null?void 0:i.options)||[],value:e.audience,onChange:p=>m("audience",p)})}),u.jsxs("span",{className:"d-inline-flex align-items-center gap-1",children:["Estimated Recipients:"," ",u.jsx(um,{audience:e.audience}),u.jsx(dm,{audience:e.audience})]})]})]})}),u.jsxs("div",{className:"px-3 py-2 border-bottom",children:[u.jsx(V,{label:"Subject line",required:!0,htmlFor:"campaign-subject",children:u.jsx(oe,{id:"campaign-subject",placeholder:"e.g. Exciting news — our spring sale is live!",value:e.subject,onChange:p=>m("subject",p)})}),u.jsx("div",{className:"mt-3",children:u.jsx(V,{label:"Email body",required:!0,children:u.jsx(am,{value:e.html,onChange:p=>{m("html",p)},placeholder:"Write your email content here...",minHeight:360})})})]}),u.jsxs("div",{className:"px-3 py-2",children:[u.jsx("div",{className:"mt-3",children:u.jsx(V,{label:"Send options",required:!0,children:u.jsxs("div",{className:"d-flex gap-3",children:[u.jsxs("label",{className:"d-flex align-items-center gap-2",style:{cursor:"pointer"},children:[u.jsx("input",{type:"radio",name:"send_mode",value:"now",className:"form-check-input mt-0",checked:e.send_mode==="now",onChange:()=>m("send_mode","now")}),"Send immediately"]}),u.jsxs("label",{className:"d-flex align-items-center gap-2",style:{cursor:"pointer"},children:[u.jsx("input",{type:"radio",name:"send_mode",value:"schedule",className:"form-check-input mt-0",checked:e.send_mode==="schedule",onChange:()=>m("send_mode","schedule")}),"Schedule for later"]})]})})}),e.send_mode==="schedule"&&u.jsx("div",{className:"mt-3",children:u.jsx(V,{label:"Send date & time",required:!0,htmlFor:"scheduled-at",children:u.jsx("input",{id:"scheduled-at",type:"datetime-local",className:"form-control",value:e.scheduled_at,min:new Date(Date.now()+6e4).toISOString().slice(0,16),onChange:p=>m("scheduled_at",p.target.value)})})})]}),f&&u.jsx("div",{className:"text-danger px-3 py-2",role:"alert",children:u.jsx("ol",{children:f.split("\n").map(p=>u.jsx("li",{children:p},String(p)))})}),u.jsxs("div",{className:"d-flex px-3 py-2 gap-2",children:[e.send_mode==="schedule"?u.jsxs("button",{className:"btn btn-primary",disabled:c,onClick:()=>y(!0),children:[c?u.jsx("span",{className:"spinner-border spinner-border-sm me-2",role:"status"}):null,"Schedule Campaign"]}):u.jsxs("button",{className:"btn btn-primary",disabled:c,onClick:()=>y(!0),children:[c?u.jsx("span",{className:"spinner-border spinner-border-sm me-2",role:"status"}):null,"Send Now"]}),u.jsx("button",{className:"btn btn-outline-secondary",disabled:c,onClick:()=>y(!1),children:"Save as Draft"}),u.jsx("button",{className:"btn btn-link text-muted ms-auto",disabled:c,onClick:()=>a("..",{relative:"path"}),children:"Cancel"})]})]})]})}function um({audience:n}){const{data:t,isLoading:e}=it("/marketing/audience/size?audience=".concat(n),Je);return e?u.jsx("span",{className:"spinner-border spinner-border-sm",role:"status"}):u.jsx("span",{className:"text-primary font-weight-bold",children:(t==null?void 0:t.size)||0})}function dm({audience:n}){const[t,e]=Wt(),{data:r,isLoading:i}=it("/marketing/audience/size?audience=".concat(n),Je),s=(r==null?void 0:r.sample)||[];return u.jsxs(u.Fragment,{children:[u.jsx("button",{onClick:e,className:"btn btn-sm",children:"See Sample"}),u.jsx(ft,{visible:t,title:"Audience sample",onClose:e,children:i?u.jsx(Zl,{count:5,height:60.5}):u.jsx("ul",{className:"list-group",children:s.map((o,l)=>{var a;return u.jsxs("li",{className:"list-group-item",children:[(a=o.data)==null?void 0:a.name,u.jsx("br",{}),u.jsx("small",{className:"text-muted",children:o.email})]},o.email)})})})]})}const Yl={draft:{label:"Draft",cls:"secondary"},scheduled:{label:"Scheduled",cls:"warning"},pending:{label:"Pending",cls:"warning"},sent:{label:"Sent",cls:"success"}};function fm(){const{options:n}=yi(),{data:t,isLoading:e,mutate:r}=it("/marketing/campaigns",Je),i=(t==null?void 0:t.campaigns)||[],[s,o]=P.useState(null),l=P.useCallback(a=>{window.confirm("Delete this campaign? This cannot be undone.")&&(o(a),ea("/marketing/campaigns/".concat(a)).then(()=>{r(),o(null)}))},[]);return u.jsxs(u.Fragment,{children:[u.jsx(sn,{}),u.jsxs("div",{className:"d-flex align-items-center justify-content-between mb-4",children:[u.jsxs("div",{children:[u.jsx("h3",{children:"Email Campaigns"}),u.jsx("p",{className:"mb-0",children:"Create and manage email campaigns to your customers."})]}),u.jsx(at,{to:"/contacts/marketing/new",children:"+ New Campaign"})]}),e?u.jsx("div",{className:"text-center py-5",children:u.jsx("span",{className:"spinner-border text-primary",role:"status"})}):i.length===0?u.jsx("div",{className:"card border-0 shadow-sm",children:u.jsxs("div",{className:"card-body text-center py-5",children:[u.jsx("p",{className:"text-muted mb-3",children:"No campaigns yet."}),u.jsx(at,{to:"/contacts/marketing/new",className:"btn btn-outline-primary",children:"Create your first campaign"})]})}):u.jsx("div",{className:"row g-3",children:i.map(a=>{var f,h,m,g;const c=(f=Yl[a.status])!=null?f:Yl.draft,d=(h=a.scheduled_at)!=null?h:a.sent_at;return u.jsx("div",{className:"col-12 col-md-6 col-xl-4",children:u.jsx("div",{className:"card h-100",children:u.jsxs("div",{className:"card-body d-flex flex-column gap-2",children:[u.jsxs("div",{className:"d-flex align-items-start justify-content-between gap-2",children:[u.jsx("strong",{className:"fs-6",children:a.title}),u.jsx("span",{className:"badge bg-".concat(c.cls," flex-shrink-0"),children:c.label})]}),u.jsx("p",{className:"small text-muted mb-0",children:a.subject}),u.jsxs("div",{className:"small text-muted",children:[u.jsx("span",{className:"fw-medium text-body",children:"Audience: "}),(g=(m=n.find(({label:y,value:p})=>p===a.metadata.audience))==null?void 0:m.label)!=null?g:a.metadata.audience]}),d&&u.jsxs("div",{className:"small text-muted",children:[u.jsx("span",{className:"fw-medium text-body",children:a.status==="sent"?"Sent: ":"Scheduled: "}),u.jsx(Dr,{value:d,month:"short",year:"numeric",day:"numeric",hour12:!0,hour:"numeric",minute:"numeric"})]}),u.jsxs("div",{className:"d-flex gap-2 mt-auto pt-2",children:[a.status!=="sent"&&u.jsx(at,{className:"btn btn-sm btn-outline-secondary",to:"/contacts/marketing/"+a.id,children:"Edit"}),a.status!=="sent"?u.jsx("button",{className:"btn btn-sm btn-outline-danger",disabled:s===a.id,onClick:()=>l(a.id),children:s===a.id?u.jsx("span",{className:"spinner-border spinner-border-sm",role:"status"}):"Delete"}):null]}
1),d?u.jsx(at,{to:"/contacts/marketing/view/"+a.id,className:"stretched-link",children:"View Details"}):null]})})},a.id)})})]})}function hm(n){const{id:t}=Ts(),{data:e,isLoading:r}=it(t?"/marketing/campaigns?id=".concat(t):null,Je);if(!t)return null;const i=e==null?void 0:e.campaigns[0];return u.jsxs("div",{children:[u.jsx(sn,{}),u.jsx("h3",{children:i==null?void 0:i.title}),u.jsxs("div",{className:"row mb-2",children:[u.jsx("div",{className:"col-md-6",children:u.jsxs("div",{className:"card",children:[u.jsx("div",{className:"card-header",children:"Campaign Details"}),u.jsxs("div",{className:"card-body",children:[u.jsx("div",{className:"lead",children:"Sent at"}),u.jsx(Dr,{value:i==null?void 0:i.sent_at,year:"numeric",month:"long",day:"numeric",hour:"numeric",minute:"numeric",hour12:!0}),u.jsx("hr",{}),u.jsx(ym,{campaignId:t})]})]})}),u.jsx("div",{className:"col-md-6",children:u.jsx(pm,{id:t})})]}),u.jsx(mm,{subject:i==null?void 0:i.subject,html:i==null?void 0:i.html}),u.jsx("div",{className:"mb-2"}),u.jsx(_m,{campaignId:t})]})}const gm='<style>\nbody {\n  margin: 0 auto !important;\n  padding: 30px 20px !important;\n  max-width: 600px !important; /* Standard email layout width */\n  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif !important;\n  font-size: 16px !important;\n  line-height: 1.6 !important;\n  color: #202124 !important; /* Soft dark gray for high readability */\n  background-color: #ffffff !important;\n  -webkit-font-smoothing: antialiased;\n}\n\n/* Ensure headings have distinct spacing and scale */\nh1, h2, h3, h4 {\n  color: #111827 !important;\n  margin-top: 24px !important;\n  margin-bottom: 12px !important;\n  line-height: 1.3 !important;\n}\n\nh1 { font-size: 24px !important; font-weight: 700; }\nh2 { font-size: 20px !important; font-weight: 600; }\n\n/* Control paragraph and list block spacing */\np, ul, ol {\n  margin-top: 0 !important;\n  margin-bottom: 16px !important;\n}\n\nli {\n  margin-bottom: 6px !important;\n}\n\n/* Prevent embedded images from overflowing the 600px frame */\nimg {\n  max-width: 100% !important;\n  height: auto !important;\n  display: block !important;\n  margin: 20px auto !important;\n}\n\n/* Style default hyperlinks cleanly */\na {\n  color: #1a73e8 !important;\n  text-decoration: underline !important;\n}\n\n/* Smooth out standard utility lines/dividers */\nhr {\n  border: 0 !important;\n  border-top: 1px solid #e5e7eb !important;\n  margin: 24px 0 !important;\n}\n</style>\n';function mm({subject:n,html:t}){return u.jsx(u.Fragment,{children:u.jsxs("div",{className:"card",children:[u.jsxs("div",{className:"card-header",children:[u.jsx("strong",{children:"Subject:"})," ",n]}),u.jsx("iframe",{srcDoc:"<!DOCTYPE html>    <html>      <head>   ".concat(gm,"      </head>      <body>").concat(t,"</body></html>"),className:"w-100",style:{height:"400px"}})]})})}function pm({id:n}){var e,r,i,s,o,l,a,c,d,f;const{data:t}=it("/marketing/campaign/stats/".concat(n),Je);return u.jsxs("div",{className:"card",children:[u.jsx("div",{className:"card-header",children:"Statistics"}),u.jsxs("ul",{className:"list-group list-group-flush",children:[u.jsx(An,{label:"Recipients",count:((e=t==null?void 0:t.stats)==null?void 0:e.recipients)||0,total:((r=t==null?void 0:t.stats)==null?void 0:r.recipients)||0}),u.jsx(An,{label:"Sent",count:((i=t==null?void 0:t.stats)==null?void 0:i.sent)||0,total:((s=t==null?void 0:t.stats)==null?void 0:s.recipients)||0}),u.jsx(An,{label:"Delivered",count:((o=t==null?void 0:t.stats)==null?void 0:o.delivered)||0,total:((l=t==null?void 0:t.stats)==null?void 0:l.recipients)||0}),u.jsx(An,{label:"Opened",count:((a=t==null?void 0:t.stats)==null?void 0:a.opened)||0,total:((c=t==null?void 0:t.stats)==null?void 0:c.recipients)||0}),u.jsx(An,{label:"Clicked",count:((d=t==null?void 0:t.stats)==null?void 0:d.clicked)||0,total:((f=t==null?void 0:t.stats)==null?void 0:f.recipients)||0})]})]})}function An({label:n,count:t,total:e}){return u.jsxs("li",{className:"list-group-item",children:[u.jsxs("div",{className:"d-flex justify-content-between mb-1",children:[u.jsx("span",{children:n}),u.jsxs("span",{children:[t,"/",e]})]}),u.jsx(Qu,{height:4,max:e,current:t})]})}function _m({campaignId:n}){const t=ti(),[e,r]=fn.useState(!1),i=()=>{r(!0),ea("/marketing/campaigns/".concat(n)).then(()=>{o(),r(!1),t("/contacts/marketing")})},[s,o]=Wt();return u.jsxs(u.Fragment,{children:[u.jsx(ft,{confirmLoading:e,visible:s,onClose:o,onCancel:o,title:"Delete Campaign",onOk:i,okText:"Delete",submitBtnClass:"btn btn-danger",children:u.jsx("p",{children:"Are you sure you want to delete this campaign ?"})}),u.jsx("button",{className:"btn btn-link text-danger",onClick:o,children:"Delete Campaign"})]})}function ym({campaignId:n}){const[t,e]=fn.useState(0),r=30,[i,s]=Wt(),{data:o,isLoading:l}=it(i?"/marketing/campaign/contacts/".concat(n,"?offset=").concat(t,"&limit=").concat(r):null,Je);return u.jsxs("div",{children:[u.jsx(ft,{title:"Recipients",onClose:s,visible:i,children:l?u.jsx(Zl,{height:24}):u.jsx("div",{children:u.jsx("ul",{className:"list-group",children:o==null?void 0:o.contacts.map(({contact:a,sent_at:c,delivered_at:d,clicked_at:f,opened_at:h,errored_at:m,metadata:g},y)=>{var p;return u.jsxs("li",{className:"list-group-item",children:[(p=a==null?void 0:a.data)==null?void 0:p.name,u.jsx("br",{}),u.jsx("small",{children:(a==null?void 0:a.email)||(a==null?void 0:a.customer_email)}),u.jsxs("div",{className:"d-flex gap-1",children:[c?u.jsx("span",{className:"badge bg-success",children:"Sent"}):null,d?u.jsx("span",{className:"badge bg-warning",children:"Delivered"}):null,h?u.jsx("span",{className:"badge bg-info",children:"Opened"}):null,f?u.jsx("span",{className:"badge bg-primary",children:"Clicked"}):null,m?u.jsx("span",{className:"badge bg-danger",children:"Error"}):null]}),m?u.jsx("small",{className:"text-danger opacity-75",children:g==null?void 0:g.error}):null]})})})})}),u.jsx("button",{onClick:s,className:"btn btn-link",children:"View recipients"})]})}function xm(){return u.jsxs(ta,{children:[u.jsx(ct,{index:!0,element:u.jsx(fm,{})}),u.jsx(ct,{path:"view/:id",element:u.jsx(hm,{})}),u.jsx(ct,{path:"new",element:u.jsx(Hl,{})}),u.jsx(ct,{path:":id",element:u.jsx(Hl,{})})]})}function vm(n,t=300){const[e,r]=Ln(n,ud.withDefault("")),[i,s]=P.useState(e);return P.useEffect(()=>{const o=setTimeout(()=>{e!==i&&r(i)},t);return()=>{clearTimeout(o)}},[i,t]),[i,s,e]}function bm(n){return Je("/marketing/contacts/".concat(n))}function co(n,t){return Xu("/marketing/contacts/".concat(n),{data:t})}function Cm(n,t){return Wn("/marketing/contacts",{customer_email:n,data:t})}function Sm(){const n=Es(K=>K.settings.contacts_email_enabled),[t,e]=Ln("audience",{defaultValue:""}),[r,i]=P.useState(!1),[s,o,l]=vm("search",500),{options:a}=yi(),[c,d]=Ln("limit",{defaultValue:30,parse:Number,serialize:String}),[f,h]=Ln("page",{defaultValue:0,parse:Number,serialize:String}),[m,g]=Wt(!1),[y,p]=P.useState(""),[_,x]=P.useState(!1),b=new URLSearchParams;l&&b.set("search",l),t&&b.set("audience",t),b.set("limit",String(c)),b.set("offset",String(f*c));const{data:N,isLoading:j,mutate:v}=it("/marketing/contacts?".concat(b.toString()),Je),k=(N==null?void 0:N.contacts)||[],S=(N==null?void 0:N.total)||0;P.useEffect(()=>{T()},[]);function T(){i(!0),Wn("/marketing/contacts/sync",{}).then(()=>{v()}).catch(K=>{console.error(K)}).finally(()=>{i(!1)})}const[A,$]=P.useState(!1),[z,R]=P.useState("");function U(K){$(!A),K&&R(K)}return u.jsxs("div",{children:[u.jsx("style",{children:"@keyframes spin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }"}),u.jsxs("div",{className:"space-between gap-3 mb-4",children:[u.jsxs("div",{children:[u.jsx("h3",{className:"mb-1",children:"Contacts"}),r?u.jsxs("div",{className:"text-muted small d-flex align-items-center gap-2",children:[u.jsx(Zu,{style:{animation:"spin 1s linear infinite"}}),"Syncing contacts with orders and revenue..."]}):null]}),n?u.jsxs("div",{className:"d-flex gap-2",children:[u.jsxs(at,{to:"marketing",className:"btn btn-outline-secondary d-inline-flex align-items-center gap-2",children:[u.jsx(Ui,{}),"Send Message"]}),u.jsx(at,{to:"/contacts/new",className:"btn btn-primary",children:"+ New Contact"})]}):null]}),u.jsx("div",{className:"card border-0 shadow-sm mb-4",children:u.jsxs("div",{className:"card-body d-flex flex-column flex-md-row align-items-md-center justify-content-between gap-3",children:[u.jsxs("div",{children:[u.jsx("div",{className:"small text-uppercase text-muted",children:"Contacts"}),u.jsx("div",{className:"h4 mb-0",children:S})]}),u.jsxs("div",{className:"d-flex gap-2 align-items-center",children:[u.jsxs("div",{className:"d-flex gap-1 align-items-center",style:{minWidth:200},children:[u.jsx(Ie,{options:[...a,{label:"Manage segments",value:"manage"}],value:t,onChange:K=>{K==="manage"?g():e(K)},placeholder:"Filter by audience..."}),u.jsx(wm,{visible:m,toggle:g})]}),u.jsx("div",{style:{maxWidth:260},children:u.jsx(oe,{placeholder:"Search contacts...",value:s,onChange:o})})]})]})}),k.length===0?u.jsx("div",{className:"card border-0 shadow-sm",children:u.jsxs("div",{className:"card-body py-5 text-center",children:[u.jsx("p",{className:"text-muted mb-3",children:l?"No contacts match your search.":"No contacts saved yet."}),!l&&k.length===0?u.jsx(at,{to:"/contacts/new",className:"btn btn-outline-primary",children:"Create your first contact"}):null]})}):u.jsxs(u.Fragment,{children:[u.jsx("div",{className:"row g-3",children:k.map(K=>u.jsx(Nm,{onSalesOpen:()=>{U(K.email)},mutate:v,contact:K},K.id))}),u.jsx("div",{className:"d-flex justify-content-end mt-4",children:u.jsx(dd,{count:S,limit:c,page:f,goToPage:h,setLimit:d})})]}),u.jsx(ft,{title:"Sales",visible:A,size:"lg",onClose:()=>$(!1),children:z?u.jsx(fd,{customer_email:z}):null})]})}function Nm({contact:n,mutate:t,onSalesOpen:e}){var p;const r=Es(_=>_.settings.contacts_email_enabled),i=ti(),s=n.data||{},o=s.tags?s.tags.split(",").map(_=>
1_.trim()).filter(Boolean):[],[l,a]=P.useState(!1);function c(_){return[_.address_1,_.address_2,"".concat(_.city||"").concat(_.city&&(_.state||_.zip)?",":""," ").concat(_.state||""," ").concat(_.zip||"").trim(),_.country].filter(x=>!!x&&x.trim()!=="").join("\n")}const d=s.addresses||[],f=d[0],h=d.slice(1),m=f?c(f):"";function g(_){window.confirm("Delete this contact ?")&&Wn("/marketing/contacts/delete",{ids:[_]}).then(x=>{t()})}function y(_,x){i("/contacts/marketing/new?audienceId=".concat(x.join(",")))}return u.jsx("div",{className:"col-12 col-lg-6",children:u.jsx("div",{className:"card h-100 border-0 shadow-sm",children:u.jsxs("div",{className:"card-body d-flex flex-column gap-3",children:[u.jsx("div",{className:"d-flex align-items-start justify-content-between gap-3",children:u.jsx("div",{children:u.jsx("h5",{className:"mb-1",children:s.name||n.email})})}),u.jsxs("div",{className:"small d-flex flex-column gap-2",children:[u.jsxs("div",{className:"d-flex align-items-center gap-2",children:[u.jsx(Ui,{className:"text-muted"}),u.jsx("span",{children:n.email||"No email"})]}),s.phone?u.jsxs("div",{className:"d-flex align-items-center gap-2",children:[u.jsx(ed,{className:"text-muted"}),u.jsx("span",{children:s.phone||"No phone"})]}):null,m?u.jsxs("div",{className:"d-flex align-items-start gap-2",children:[u.jsx(td,{className:"text-muted mt-1"}),u.jsxs("span",{children:[u.jsx("span",{style:{whiteSpace:"pre-line"},children:m}),h.length>0&&u.jsxs(u.Fragment,{children:[l&&h.map((_,x)=>u.jsx("span",{style:{whiteSpace:"pre-line"},className:"d-block mt-2 pt-2 border-top",children:c(_)},x)),u.jsx("button",{className:"btn btn-link btn-sm p-0 d-block mt-1",style:{fontSize:"inherit"},onClick:()=>a(_=>!_),children:l?"Show less":"+".concat(h.length," more address").concat(h.length>1?"es":"")})]})]})]}):null,s.notes?u.jsx("blockquote",{className:"mb-0 ps-2 border-start border-2",style:{whiteSpace:"pre-line"},children:s.notes}):null]}),o.length>0?u.jsx("div",{className:"d-flex flex-wrap gap-2",children:o.map(_=>u.jsxs("span",{className:"badge rounded-pill text-bg-light border",children:[u.jsx(ra,{className:"me-1"}),_]},_))}):null,(n.total_orders>0||n.customer_since)&&u.jsxs("div",{onClick:e,className:"row g-2 py-2 border-top border-bottom",children:[u.jsxs("div",{className:"col-6",children:[u.jsx("div",{className:"small text-muted",children:"Total Orders"}),u.jsxs("div",{className:"fw-semibold small d-flex align-items-center gap-1",children:[u.jsx(nd,{className:"text-muted",size:12}),(p=n.total_orders)!=null?p:0]})]}),u.jsxs("div",{className:"col-6",children:[u.jsx("div",{className:"small text-muted",children:"Revenue"}),u.jsx("div",{className:"fw-semibold small",children:n.total_revenue!=null?u.jsx(rd,{value:n.total_revenue}):"—"})]}),n.total_orders>1?u.jsxs("div",{className:"col-6",children:[u.jsx("div",{className:"small text-muted",children:"First Order"}),u.jsxs("div",{className:"fw-semibold small d-flex align-items-center gap-1",children:[u.jsx(ho,{className:"text-muted",size:12}),n.first_order_at?u.jsx(Dr,{value:new Date(n.first_order_at),month:"short",day:"numeric",year:"numeric"}):"—"]})]}):null,u.jsxs("div",{className:"col-6",children:[u.jsx("div",{className:"small text-muted",children:"Last Order"}),u.jsxs("div",{className:"fw-semibold small d-flex align-items-center gap-1",children:[u.jsx(ho,{className:"text-muted",size:12}),n.last_order_at?u.jsx(Dr,{value:new Date(n.last_order_at),month:"short",day:"numeric",year:"numeric"}):"—"]})]})]}),u.jsxs("div",{className:"d-flex align-items-center gap-2 mt-auto pt-2",children:[u.jsx(at,{to:"/contacts/".concat(n.id),className:"btn btn-sm btn-link d-inline-flex align-items-center",title:"Edit",children:u.jsx(id,{})}),u.jsx(Em,{contactId:n.id,note:s.notes,mutate:t}
1),u.jsx(km,{contactId:n.id,mutate:t,tags:s.tags}),r?u.jsx("button",{className:"btn btn-sm btn-outline-primary d-inline-flex align-items-center",onClick:()=>y(s.name||n.email,[n.id]),title:"Send Email",children:u.jsx(Ui,{})}):null,u.jsx("button",{className:"btn btn-sm text-danger ms-auto d-inline-flex align-items-center",onClick:()=>g(n.id),title:"Delete",children:u.jsx(na,{})})]})]})})})}function km({contactId:n,mutate:t,tags:e}){const[r,i]=Wt(!1),[s,o]=P.useState(e),[l,a]=P.useState(!1);function c(d){d&&(d.preventDefault(),d.stopPropagation()),a(!0),co(n,{tags:s}).then(()=>{t(),i()}).catch(f=>{console.log(f)}).finally(()=>{a(!1)})}return u.jsxs(fn.Fragment,{children:[u.jsx("button",{title:"Update tags",className:"btn btn-sm btn-link d-inline-flex align-items-center",onClick:i,children:u.jsx(ra,{})}),u.jsx(ft,{visible:r,okText:"Submit",confirmLoading:l,onSubmit:c,onCancel:i,onClose:i,title:"Update Tag",children:u.jsx("div",{className:"d-flex flex-column gap-3",children:u.jsx(oe,{placeholder:"Add comma separated tags...",value:s,onChange:o})})})]})}function wm({visible:n,toggle:t}){const e=Es(_=>_.settings.default_currency),{options:r,mutate:i}=yi(),[s,o]=Wt(!1),[l,a]=P.useState(!1),c=_=>{a(!0),_&&(_.preventDefault(),_.stopPropagation());const x=r.filter(N=>N.value.startsWith("custom:")),b=f?x.map(N=>N.value===f?{...N,label:g.label,data:g}:N):[...x,{value:"custom:".concat(sd()),label:g.label,data:g}];console.log("updated",b),go("/marketing/audience/options",{options:b}).then(()=>{i(),o(),a(!1)})},d=_=>{const b=r.filter(N=>N.value.startsWith("custom:")).filter(N=>N.value!==_);go("/marketing/audience/options",{options:b}).then(()=>{i()})},[f,h]=P.useState(""),m=r.filter(_=>_.value.startsWith("custom:")),[g,y]=P.useState({label:"",_orderParam:"",_orderMatch:"",_orderMatcher:"",_orderTimeframe:"",_customerMatcher:"",_customerTimeframeValue:"",_customerTimeframeUnit:"",_customerTimeframePeriod:"",_customerTimeframePeriodValue:"",_orderTimeframeValue:"",_orderTimeframeUnit:"",_orderTimeframePeriod:"",_customerParam:"",_customerMatch:""});P.useEffect(()=>{var _;f&&y(((_=m.find(x=>x.value===f))==null?void 0:_.data)||{label:"",_customerMatcher:"",_orderTimeframe:"",_orderParam:"",_orderMatch:"",_orderMatcher:"",_customerTimeframeUnit:"",_customerTimeframePeriod:"",_customerTimeframePeriodValue:"",_orderTimeframeValue:"",_orderTimeframeUnit:"",_orderTimeframePeriod:"",_customerParam:"",_customerMatch:""})},[f]);const p=_=>x=>y(b=>({...b,[_]:x}));return u.jsxs(u.Fragment,{children:[u.jsxs(ft,{visible:n,title:"Manage",onClose:t,children:[u.jsx("div",{className:"text-end",children:u.jsx("button",{className:"btn btn-link",onClick:o,children:"+ Create new segment"})}),u.jsxs("div",{className:"d-flex flex-column gap-2",children:["`",m.map(_=>u.jsxs("div",{className:"d-flex align-items-center gap-2",children:[u.jsx("span",{children:_.label||_.value}),u.jsx("button",{onClick:()=>d(_.value),className:"btn btn-link text-danger",children:u.jsx(na,{})})]},_.value))]}),m.length===0?u.jsx("div",{className:"text-center",children:"No custom segments yet"}):null]}),u.jsxs(ft,{onSubmit:c,confirmLoading:l,okText:"Submit",size:"lg",visible:s,onClose:o,title:"Create new segment",children:[u.jsx(V,{children:u.jsx(oe,{placeholder:"Segment name...",value:g.label,onChange:p("label")})}),u.jsx("div",{className:"bg-light border d-none rounded p-2 mb-2",children:u.jsxs("div",{className:"row",children:[u.jsx("div",{className:"col-md-6",children:u.jsx(V,{label:"Customers",children:u.jsx(Ie,{options:[{label:"All Customers",value:""},{label:"Older than",value:"older_than"},{label:"Younger than",value:"younger_than"}],onChange:p("_customerMatcher"),value:g._customerMatcher})})}),g._customerMatcher?u.jsxs(fn.Fragment,{children:[u.jsx("div",{className:"col-md-3",children:u.jsx(V,{label:"Time Period",children:u.jsx(oe,{value:g._customerTimeframeValue,onChange:p("_customerTimeframeValue")})})}),u.jsx("div",{className:"col-md-3",children:u.jsx(V,{label:"Time Unit",children:u.jsx(Ie,{value:g._customerTimeframeUnit,onChange:p("_customerTimeframeUnit"),options:[{label:"Days",value:"days"},{label:"Weeks",value:"weeks"},{label:"Months",value:"months"}]})})})]}):null]})}),u.jsxs("div",{className:"rounded border p-2 bg-light",children:[u.jsxs("div",{className:"row",children:[u.jsx("div",{className:"col-md-6",children:u.jsx(V,{label:"Customer has",children:u.jsx(Ie,{hasEmpty:!0,options:[{label:"Spent",value:"volume"},{label:"Placed",value:"count"},{label:"Purchased",value:"purchased"}],value:g._orderParam,onChange:p("_orderParam")})})}),u.jsxs("div",{className:"col-md-6",children:[g._orderParam==="volume"||g._orderParam==="count"?u.jsxs(V,{label:"Comparator",children:[" ",u.jsx(Ie,{onChange:p("_orderMatcher"),value:g._orderMatcher,options:Tm})]}):null,g._orderParam==="purchased"?u.jsx(V,{label:"Product ID or SKU of Name",children:u.jsx(oe,{value:g._orderMatch,onChange:p("_orderMatch"),placeholder:"e.g. 123 or SKU123"})}):null]}),g._orderParam==="volume"||g._orderParam==="count"?u.jsx("div",{className:"col-md-6",children:u.jsx(V,{label:"Value",children:u.jsx(oe,{value:g._orderMatch,onChange:p("_orderMatch"),suffix:g._orderParam==="volume"?e:"orders"})})}):null,g._orderParam?u.jsx("div",{className:"col-md-6",children:u.jsx(V,{label:"In",children:u.jsx(Ie,{value:g._orderTimeframe,onChange:p("_orderTimeframe"),options:[{label:"Lifetime",value:"lifetime"},{label:"Last X days",value:"last_x"}]})})}):null,g._orderParam&&g._orderTimeframe==="last_x"?u.jsxs(fn.Fragment,{children:[u.jsx("div",{className:"col-md-6",children:u.jsx(V,{label:"Time Period",children:u.jsx(oe,{value:g._orderTimeframeSize,onChange:p("_orderTimeframeValue")})})}),u.jsx("div",{className:"col-md-6",children:u.jsx(V,{label:"Time Unit",children:u.jsx(Ie,{value:g._orderTimeframeUnit,onChange:p("_orderTimeframeUnit"),options:[{label:"Days",value:"days"},{label:"Weeks",value:"weeks"},{label:"Months",value:"months"}]})})})]}):null]}),u.jsx("div",{className:"bg-light rounded p-2 mb-2",children:u.jsxs("div",{className:"row",children:[u.jsx("div",{className:"col-md-4",children:u.jsx(V,{label:"Customer field",children:u.jsx(Ie,{hasEmpty:!0,options:[{label:"Tags",value:"tags"}],onChange:p("_customerParam"),value:g._customerParam})})}),u.jsx("div",{className:"col-md-4",children:u.jsx(V,{label:"Matcher",children:u.jsx(Ie,{hasEmpty:!0,options:[{label:"Is",value:"is"},{label:"Is not",value:"is_not"},{label:"Contains",value:"contains"},{label:"Does not contain",value:"does_not_contain"},{label:"Contains (regex)",value:"contains_regex"},{label:"Starts with",value:"starts_with"},{label:"Ends with",value:"ends_with"}],onChange:p("_customerMatcher"),value:g._customerMatcher})})}),u.jsx("div",{className:"col-md-4",children:u.jsx(V,{label:"Match value",children:u.jsx(oe,{value:g._customerMatch,onChange:p("_customerMatch"),placeholder:"e.g. vip"})})})]})})]})]})]})}const Tm=[{label:"Greater than",value:"gt"},{label:"Less than",value:"lt"},{label:"Equals",value:"eq"},{label:"Not equals",value:"neq"}];
1function Em({note:n,contactId:t,mutate:e}){const[r,i]=Wt(!1),[s,o]=P.useState(n),[l,a]=P.useState(!1);function c(d){d&&(d.preventDefault(),d.stopPropagation()),a(!0),co(t,{notes:s}).then(()=>{e(),i()}).catch(f=>{console.log(f)}).finally(()=>{a(!1)})}return u.jsxs(fn.Fragment,{children:[u.jsx("button",{title:"Update note",className:"btn btn-sm btn-link d-inline-flex align-items-center",onClick:i,children:u.jsx(od,{})}),u.jsx(ft,{visible:r,okText:"Submit",confirmLoading:l,onSubmit:c,onCancel:i,onClose:i,title:"Update note",children:u.jsx("div",{className:"d-flex flex-column gap-3",children:u.jsx("textarea",{placeholder:"Add notes about this contact...",className:"form-control",rows:5,value:s,onChange:d=>o(d.target.value)})})})]})}function jm(){return{address_1:"",address_2:"",city:"",state:"",country:"",zip:""}}function Gl(){return{name:"",email:"",phone:"",tagsText:"",addresses:[]}}function Om(n){var t,e,r,i,s;return{name:(t=n.data.name)!=null?t:"",email:(e=n.email)!=null?e:"",phone:(r=n.data.phone)!=null?r:"",tagsText:(i=n.data.tags)!=null?i:"",addresses:((s=n.data.addresses)!=null?s:[]).map(o=>{var l,a,c,d,f,h;return{address_1:(l=o.address_1)!=null?l:"",address_2:(a=o.address_2)!=null?a:"",city:(c=o.city)!=null?c:"",state:(d=o.state)!=null?d:"",country:(f=o.country)!=null?f:"",zip:(h=o.zip)!=null?h:""}})}}function Ql(n){const t=n.addresses.filter(e=>[e.address_1,e.address_2,e.city,e.state,e.country,e.zip].some(Boolean)).map(e=>({address_1:e.address_1.trim(),address_2:e.address_2.trim(),city:e.city.trim(),state:e.state.trim(),country:e.country.trim(),zip:e.zip.trim()}));return{name:n.name.trim(),phone:n.phone.trim(),tags:n.tagsText.trim(),addresses:t}}function Xl(){const{id:n}=Ts(),t=ti(),e=!!(n&&n!=="new"),[r,i]=P.useState(Gl),[s,o]=P.useState(null),[l,a]=P.useState(!0),[c,d]=P.useState(!1),[f,h]=P.useState(!1);P.useEffect(()=>{if(!e||!n){i(Gl()),a(!0);return}d(!0),bm(Number(n)).then(v=>{i(Om(v)),a(!0)}).catch(v=>{console.error(v),a(!1)}).finally(()=>{d(!1)})},[n,e]);const m=P.useMemo(()=>r.tagsText.split(",").map(v=>v.trim()).filter(Boolean),[r.tagsText]),[g,y]=P.useState(!1);function p(v,k){y(!0),i(S=>({...S,[v]:k}))}function _(v,k,S){y(!0),i(T=>{const A=T.addresses.map(($,z)=>z===v?{...$,[k]:S}:$);return{...T,addresses:A}})}function x(){y(!0),i(v=>({...v,addresses:[...v.addresses,jm()]}))}function b(v){y(!0),i(k=>({...k,addresses:k.addresses.filter((S,T)=>T!==v)}))}function N(){return r.name.trim()?r.email.trim()?null:"Email is required.":"Contact name is required."}async function j(){const v=N();if(v){o(v);return}o(null),h(!0);try{e&&n?(await co(Number(n),Ql(r)),y(!1)):(await Cm(r.email.trim(),Ql(r)),t("/contacts",{replace:!0}))}catch(k){o("Failed to save contact. Please try again.")}finally{h(!1)}}return c?u.jsxs("div",{children:[u.jsx(sn,{to:"/contacts"}),u.jsx("div",{className:"mt-3 text-muted",children:"Loading…"})]}):l?u.jsxs("div",{children:[u.jsx(sn,{to:"/contacts"}),u.jsxs("div",{className:"space-between",children:[u.jsxs("div",{children:[u.jsx("h3",{className:"mb-1",children:e?"Review Contact":"New Contact"}),u.jsx("p",{className:"mb-0 text-muted",children:e?"Update the saved details below.":"Add a new contact"})]}),u.jsx("div",{className:"d-flex gap-2",children:u.jsx("button",{className:"btn btn-primary",onClick:j,disabled:f||!g,children:f?"Saving…":e?"Save Changes":"Create Contact"})})]}),s?u.jsx("div",{className:"alert alert-danger py-2",role:"alert",children:s}):null,u.jsxs("div",{className:"row g-4",children:[u.jsx("div",{className:"col-12 col-xl-8",children:u.jsx("div",{className:"card border-0 shadow-sm",children:u.jsxs("div",{className:"card-body d-flex flex-column gap-3",children:[u.jsx(V,{label:"Name",required:!0,htmlFor:"crm-contact-name",children:u.jsx(oe,{id:"crm-contact-name",value:r.name,placeholder:"e.g. Taylor Brooks",onChange:v=>p("name",v)})}),u.jsxs("div",{className:"row g-3",children:[u.jsx("div",{className:"col-12 col-md-6",children:u.jsx(V,{label:"Email",required:!0,htmlFor:"crm-contact-email",children:u.jsx(oe,{id:"crm-contact-email",type:"email",value:r.email,placeholder:"[email protected]",onChange:v=>p("email",v)})})}),u.jsx("div",{className:"col-12 col-md-6",children:u.jsx(V,{label:"Phone",htmlFor:"crm-contact-phone",children:u.jsx(ld,{value:r.phone,onChange:v=>
1p("phone",v.target.value)})})})]}),u.jsxs("div",{children:[u.jsxs("div",{className:"d-flex align-items-center justify-content-between mb-2",children:[u.jsx("span",{className:"fw-semibold",children:"Addresses"}),r.addresses.length===0&&u.jsx("button",{type:"button",className:"btn btn-sm btn-outline-secondary",onClick:x,children:"+ Add Address"})]}),r.addresses.length===0&&u.jsx("div",{className:"text-muted small",children:"No addresses added."}),r.addresses.map((v,k)=>u.jsxs("div",{className:"border rounded p-3 mb-3 position-relative",children:[u.jsx("button",{type:"button",className:"btn btn-sm btn-link text-danger position-absolute top-0 end-0 m-2",onClick:()=>b(k),"aria-label":"Remove address",children:u.jsx(ad,{})}),u.jsxs("div",{className:"small text-muted text-uppercase mb-2",children:["Address ",k+1]}),u.jsx(V,{label:"Address Line 1",htmlFor:"crm-address-1-".concat(k),children:u.jsx(oe,{id:"crm-address-1-".concat(k),value:v.address_1,placeholder:"123 Main Street",onChange:S=>_(k,"address_1",S)})}),u.jsx(V,{label:"Address Line 2",htmlFor:"crm-address-2-".concat(k),children:u.jsx(oe,{id:"crm-address-2-".concat(k),value:v.address_2,placeholder:"Apt 4B",onChange:S=>_(k,"address_2",S)})}),u.jsxs("div",{className:"row g-3",children:[u.jsx("div",{className:"col-12 col-md-4",children:u.jsx(V,{label:"City",htmlFor:"crm-city-".concat(k),children:u.jsx(oe,{id:"crm-city-".concat(k),value:v.city,placeholder:"Austin",onChange:S=>_(k,"city",S)})})}),u.jsx("div",{className:"col-12 col-md-4",children:u.jsx(V,{label:"State / Province",htmlFor:"crm-state-".concat(k),children:u.jsx(oe,{id:"crm-state-".concat(k),value:v.state,placeholder:"TX",onChange:S=>_(k,"state",S)})})}),u.jsx("div",{className:"col-12 col-md-4",children:u.jsx(V,{label:"ZIP / Postal Code",htmlFor:"crm-zip-".concat(k),children:u.jsx(oe,{id:"crm-zip-".concat(k),value:v.zip,placeholder:"78701",onChange:S=>_(k,"zip",S)})})})]}),u.jsx(V,{label:"Country",htmlFor:"crm-country-".concat(k),children:u.jsx(cd,{id:"crm-country-".concat(k),hasEmpty:!0,value:v.country,onChange:S=>_(k,"country",S.target.value)})})]},k)),r.addresses.length>0&&u.jsx("div",{className:"d-flex justify-content-center mt-1",children:u.jsx("button",{type:"button",className:"btn btn-sm btn-outline-secondary",onClick:x,children:"+ Add Address"})})]}),u.jsx(V,{label:"Tags",info:"Separate tags with commas, for example: vip, retail, newsletter",children:u.jsx(oe,{value:r.tagsText,placeholder:"vip, retail, newsletter",onChange:v=>p("tagsText",v)})})]})})}),u.jsx("div",{className:"col-12 col-xl-4",children:u.jsx("div",{className:"card border-0 shadow-sm sticky-xl-top",children:u.jsxs("div",{className:"card-body",children:[u.jsx("div",{className:"small text-uppercase text-muted mb-2",children:"Review"}),u.jsx("h4",{className:"mb-1",children:r.name||"Unnamed contact"}),u.jsx("div",{className:"text-muted mb-3",children:r.email||"No email"}),u.jsxs("div",{className:"mb-3",children:[u.jsx("div",{className:"fw-semibold mb-1",children:"Phone"}),u.jsx("div",{className:"text-muted",children:r.phone||"No phone"})]}),u.jsxs("div",{className:"mb-3",children:[u.jsx("div",{className:"fw-semibold mb-1",children:"Addresses"}),r.addresses.length===0?u.jsx("div",{className:"text-muted",children:"No addresses"}):r.addresses.map((v,k)=>{const S=[v.address_1,v.address_2,[v.city,v.state,v.zip].filter(Boolean).join(", "),v.country].filter(Boolean).join("\n");return S?u.jsx("div",{className:"rounded border bg-light-subtle p-2 small mb-2",style:{whiteSpace:"pre-line"},children:S},k):null})]}),u.jsxs("div",{children:[u.jsx("div",{className:"fw-semibold mb-1",children:"Tags"}),u.jsx("div",{className:"d-flex flex-wrap gap-2",children:m.length>0?m.map(v=>u.jsx("span",{className:"badge rounded-pill text-bg-light border",children:v},v)):u.jsx("span",{className:"text-muted",children:"No tags"})})]})]})})})]})]}):u.jsxs("div",{children:[u.jsx(sn,{to:"/contacts"}),u.jsx("div",{className:"alert alert-warning mt-3 mb-0",role:"alert",children:"That contact was not found."})]})}function qm(){return u.jsxs(ta,{children:[u.jsx(ct,{index:!0,element:u.jsx(Sm,{})}),u.jsx(ct,{path:"marketing/*",element:u.jsx(xm,{})}),u.jsx(ct,{path:"new",element:u.jsx(Xl,{})}),u.jsx(ct,{path:":id",element:u.jsx(Xl,{})})]})}export{qm as default};
2//# sourceMappingURL=CRMIndex-CteweC4V.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.