@qwanyx/stack 0.2.27 → 0.2.28
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs.js +19 -19
- package/dist/index.esm.js +11 -6
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Ou=Object.defineProperty;var Mu=(r,e,t)=>e in r?Ou(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var ar=(r,e,t)=>Mu(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react"),Ni=require("react-dom");function Ru(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const us=Ru(k);class $u{constructor(e){ar(this,"config");ar(this,"defaultUploadOptions",{maxSizeMB:10,maxImageDimension:0,imageQuality:.9});if(!e.system_id)throw new Error("GraphClient: system_id is REQUIRED. No system_id → No start.");this.config=e}async callGraph(e,t={}){const n={coprocessor:"graph",method:e,system_id:this.config.system_id,params:t};try{const s=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(n)});if(!s.ok){const i=await s.text();throw new Error(`API error (${s.status}): ${i}`)}const o=await s.json();if(!o.success&&o.error)throw new Error(o.error);return o}catch(s){throw console.error("Graph API call failed:",s),s}}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async getChildren(e){return(await this.callGraph("get_children",{parent_id:e})).result||[]}async getNode(e){return(await this.callGraph("get_node",{node_id:e})).result||null}async addNode(e){const t={...e,created:e.created||new Date().toISOString(),modified:new Date().toISOString()},n=await this.callGraph("add_node",t);if(!n.result)throw new Error("Failed to add node");return n.result}async updateNode(e,t){const n={node_id:e,updates:{...t,modified:new Date().toISOString()}},s=await this.callGraph("update_node",n);if(!s.result)throw new Error("Failed to update node");return s.result}async deleteNode(e,t=!1){return(await this.callGraph("delete_node",{node_id:e,cascade:t})).success===!0}async getChildrenWithEdges(e,t="children",n,s){return(await this.callGraph("get_children_with_edges",{node_id:e,display_mode:t,edge_type:n,node_type:s})).result||[]}async addEdge(e,t,n="link",s){return await this.callGraph("add_edge",{source_id:e,target_id:t,edge_type:n,data:s})}async deleteEdge(e,t,n){return await this.callGraph("delete_edge",{source_id:e,target_id:t,edge_type:n})}async getEdges(e,t,n){return(await this.callGraph("get_edges",{source_id:e,edge_type:t,target_id:n})).result||[]}async getAncestors(e){return(await this.callGraph("get_ancestors",{node_id:e})).ancestors||[]}async getTree(e,t=10){return(await this.callGraph("get_tree",{root_id:e,max_depth:t})).tree||[]}async moveNode(e,t){const n=await this.callGraph("move",{node_id:e,new_parent_id:t});if(!n.node)throw new Error("Failed to move node");return n.node}async searchNodes(e,t){return(await this.callGraph("search",{query:e,type:t})).nodes||[]}async getNodesByType(e){return(await this.callGraph("get_nodes_by_type",{type:e})).result||[]}fileToBase64(e){return new Promise((t,n)=>{const s=new FileReader;s.onload=()=>{const i=s.result.split(",")[1];t(i)},s.onerror=()=>n(new Error("Failed to read file")),s.readAsDataURL(e)})}async resizeImage(e,t,n){return e.type.startsWith("image/")?new Promise(s=>{const o=new Image,i=URL.createObjectURL(e);o.onload=()=>{if(URL.revokeObjectURL(i),o.width<=t&&o.height<=t){s(e);return}let l,u;o.width>o.height?(l=t,u=Math.round(o.height/o.width*t)):(u=t,l=Math.round(o.width/o.height*t));const a=document.createElement("canvas");a.width=l,a.height=u;const c=a.getContext("2d");if(!c){s(e);return}c.drawImage(o,0,0,l,u);const f=e.type==="image/png"?"image/png":"image/jpeg";a.toBlob(d=>{if(d){const h=new File([d],e.name,{type:f});s(h)}else s(e)},f,n)},o.onerror=()=>{URL.revokeObjectURL(i),s(e)},o.src=i}):e}async uploadFile(e,t,n,s={}){const o={...this.defaultUploadOptions,...s};try{let i=n;o.maxImageDimension>0&&n.type.startsWith("image/")&&(i=await this.resizeImage(n,o.maxImageDimension,o.imageQuality));const l=o.maxSizeMB*1024*1024;if(i.size>l)return{success:!1,error:`File too large (${(i.size/1024/1024).toFixed(1)} MB). Max: ${o.maxSizeMB} MB`};const u=await this.fileToBase64(i),a=await this.callGraph("upload_file",{node_id:e,filename:t,content:u});return a.success?{success:!0,path:a.path}:{success:!1,error:a.error||"Upload failed"}}catch(i){return{success:!1,error:i instanceof Error?i.message:"Upload failed"}}}async listFiles(e){var s;return(((s=(await this.callGraph("list_files",{node_id:e})).result)==null?void 0:s.files)||[]).map(o=>({filename:o.name,path:o.path}))}async deleteFile(e,t){return{success:(await this.callGraph("delete_file",{node_id:e,filename:t})).success||!1}}getFileUrl(e,t){return`${this.config.baseUrl}/files/${this.config.system_id}/${e}/${t}`}}const Zt=new TextEncoder,Fi="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",yr=new Uint8Array(256);for(var rn=0;rn<Fi.length;rn++)yr[Fi.charCodeAt(rn)]=rn;function ws(r){let e=Math.ceil(r.length/4)*3;const t=r.length;let n=0;r.length%4===3?e--:r.length%4===2?e-=2:r[r.length-1]==="="&&(e--,r[r.length-2]==="="&&e--);const s=new ArrayBuffer(e),o=new Uint8Array(s);for(let i=0;i<t;i+=4){let l=yr[r.charCodeAt(i)],u=yr[r.charCodeAt(i+1)],a=yr[r.charCodeAt(i+2)],c=yr[r.charCodeAt(i+3)];o[n++]=l<<2|u>>4,o[n++]=(u&15)<<4|a>>2,o[n++]=(a&3)<<6|c&63}return s}function vr(r){r=r||"utf8";let e;try{e=new TextDecoder(r)}catch{e=new TextDecoder("windows-1252")}return e}async function On(r){if("arrayBuffer"in r)return await r.arrayBuffer();const e=new FileReader;return new Promise((t,n)=>{e.onload=function(s){t(s.target.result)},e.onerror=function(s){n(e.error)},e.readAsArrayBuffer(r)})}function Li(r){return r>=48&&r<=57||r>=97&&r<=102||r>=65&&r<=70?String.fromCharCode(r):!1}function Iu(r,e,t){let n=r.indexOf("*");n>=0&&(r=r.substr(0,n)),e=e.toUpperCase();let s;if(e==="Q"){t=t.replace(/=\s+([0-9a-fA-F])/g,"=$1").replace(/[_\s]/g," ");let o=Zt.encode(t),i=[];for(let u=0,a=o.length;u<a;u++){let c=o[u];if(u<=a-2&&c===61){let f=Li(o[u+1]),d=Li(o[u+2]);if(f&&d){let h=parseInt(f+d,16);i.push(h),u+=2;continue}}i.push(c)}s=new ArrayBuffer(i.length);let l=new DataView(s);for(let u=0,a=i.length;u<a;u++)l.setUint8(u,i[u])}else e==="B"?s=ws(t.replace(/[^a-zA-Z0-9\+\/=]+/g,"")):s=Zt.encode(t);return vr(r).decode(s)}function
|
|
1
|
+
"use strict";var Ou=Object.defineProperty;var Mu=(r,e,t)=>e in r?Ou(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var ar=(r,e,t)=>Mu(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=require("react"),Ni=require("react-dom");function Ru(r){const e=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(r){for(const t in r)if(t!=="default"){const n=Object.getOwnPropertyDescriptor(r,t);Object.defineProperty(e,t,n.get?n:{enumerable:!0,get:()=>r[t]})}}return e.default=r,Object.freeze(e)}const us=Ru(k);class $u{constructor(e){ar(this,"config");ar(this,"defaultUploadOptions",{maxSizeMB:10,maxImageDimension:0,imageQuality:.9});if(!e.system_id)throw new Error("GraphClient: system_id is REQUIRED. No system_id → No start.");this.config=e}async callGraph(e,t={}){const n={coprocessor:"graph",method:e,system_id:this.config.system_id,params:t};try{const s=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(n)});if(!s.ok){const i=await s.text();throw new Error(`API error (${s.status}): ${i}`)}const o=await s.json();if(!o.success&&o.error)throw new Error(o.error);return o}catch(s){throw console.error("Graph API call failed:",s),s}}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async getChildren(e){return(await this.callGraph("get_children",{parent_id:e})).result||[]}async getNode(e){return(await this.callGraph("get_node",{node_id:e})).result||null}async addNode(e){const t={...e,created:e.created||new Date().toISOString(),modified:new Date().toISOString()},n=await this.callGraph("add_node",t);if(!n.result)throw new Error("Failed to add node");return n.result}async updateNode(e,t){const n={node_id:e,updates:{...t,modified:new Date().toISOString()}},s=await this.callGraph("update_node",n);if(!s.result)throw new Error("Failed to update node");return s.result}async deleteNode(e,t=!1){return(await this.callGraph("delete_node",{node_id:e,cascade:t})).success===!0}async getChildrenWithEdges(e,t="children",n,s){return(await this.callGraph("get_children_with_edges",{node_id:e,display_mode:t,edge_type:n,node_type:s})).result||[]}async addEdge(e,t,n="link",s){return await this.callGraph("add_edge",{source_id:e,target_id:t,edge_type:n,data:s})}async deleteEdge(e,t,n){return await this.callGraph("delete_edge",{source_id:e,target_id:t,edge_type:n})}async getEdges(e,t,n){return(await this.callGraph("get_edges",{source_id:e,edge_type:t,target_id:n})).result||[]}async getAncestors(e){return(await this.callGraph("get_ancestors",{node_id:e})).ancestors||[]}async getTree(e,t=10){return(await this.callGraph("get_tree",{root_id:e,max_depth:t})).tree||[]}async moveNode(e,t){const n=await this.callGraph("move",{node_id:e,new_parent_id:t});if(!n.node)throw new Error("Failed to move node");return n.node}async searchNodes(e,t){return(await this.callGraph("search",{query:e,type:t})).nodes||[]}async getNodesByType(e){return(await this.callGraph("get_nodes_by_type",{type:e})).result||[]}fileToBase64(e){return new Promise((t,n)=>{const s=new FileReader;s.onload=()=>{const i=s.result.split(",")[1];t(i)},s.onerror=()=>n(new Error("Failed to read file")),s.readAsDataURL(e)})}async resizeImage(e,t,n){return e.type.startsWith("image/")?new Promise(s=>{const o=new Image,i=URL.createObjectURL(e);o.onload=()=>{if(URL.revokeObjectURL(i),o.width<=t&&o.height<=t){s(e);return}let l,u;o.width>o.height?(l=t,u=Math.round(o.height/o.width*t)):(u=t,l=Math.round(o.width/o.height*t));const a=document.createElement("canvas");a.width=l,a.height=u;const c=a.getContext("2d");if(!c){s(e);return}c.drawImage(o,0,0,l,u);const f=e.type==="image/png"?"image/png":"image/jpeg";a.toBlob(d=>{if(d){const h=new File([d],e.name,{type:f});s(h)}else s(e)},f,n)},o.onerror=()=>{URL.revokeObjectURL(i),s(e)},o.src=i}):e}async uploadFile(e,t,n,s={}){const o={...this.defaultUploadOptions,...s};try{let i=n;o.maxImageDimension>0&&n.type.startsWith("image/")&&(i=await this.resizeImage(n,o.maxImageDimension,o.imageQuality));const l=o.maxSizeMB*1024*1024;if(i.size>l)return{success:!1,error:`File too large (${(i.size/1024/1024).toFixed(1)} MB). Max: ${o.maxSizeMB} MB`};const u=await this.fileToBase64(i),a=await this.callGraph("upload_file",{node_id:e,filename:t,content:u});return a.success?{success:!0,path:a.path}:{success:!1,error:a.error||"Upload failed"}}catch(i){return{success:!1,error:i instanceof Error?i.message:"Upload failed"}}}async listFiles(e){var s;return(((s=(await this.callGraph("list_files",{node_id:e})).result)==null?void 0:s.files)||[]).map(o=>({filename:o.name,path:o.path}))}async deleteFile(e,t){return{success:(await this.callGraph("delete_file",{node_id:e,filename:t})).success||!1}}getFileUrl(e,t){return`${this.config.baseUrl}/files/${this.config.system_id}/${e}/${t}`}}const Zt=new TextEncoder,Fi="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",yr=new Uint8Array(256);for(var rn=0;rn<Fi.length;rn++)yr[Fi.charCodeAt(rn)]=rn;function ws(r){let e=Math.ceil(r.length/4)*3;const t=r.length;let n=0;r.length%4===3?e--:r.length%4===2?e-=2:r[r.length-1]==="="&&(e--,r[r.length-2]==="="&&e--);const s=new ArrayBuffer(e),o=new Uint8Array(s);for(let i=0;i<t;i+=4){let l=yr[r.charCodeAt(i)],u=yr[r.charCodeAt(i+1)],a=yr[r.charCodeAt(i+2)],c=yr[r.charCodeAt(i+3)];o[n++]=l<<2|u>>4,o[n++]=(u&15)<<4|a>>2,o[n++]=(a&3)<<6|c&63}return s}function vr(r){r=r||"utf8";let e;try{e=new TextDecoder(r)}catch{e=new TextDecoder("windows-1252")}return e}async function On(r){if("arrayBuffer"in r)return await r.arrayBuffer();const e=new FileReader;return new Promise((t,n)=>{e.onload=function(s){t(s.target.result)},e.onerror=function(s){n(e.error)},e.readAsArrayBuffer(r)})}function Li(r){return r>=48&&r<=57||r>=97&&r<=102||r>=65&&r<=70?String.fromCharCode(r):!1}function Iu(r,e,t){let n=r.indexOf("*");n>=0&&(r=r.substr(0,n)),e=e.toUpperCase();let s;if(e==="Q"){t=t.replace(/=\s+([0-9a-fA-F])/g,"=$1").replace(/[_\s]/g," ");let o=Zt.encode(t),i=[];for(let u=0,a=o.length;u<a;u++){let c=o[u];if(u<=a-2&&c===61){let f=Li(o[u+1]),d=Li(o[u+2]);if(f&&d){let h=parseInt(f+d,16);i.push(h),u+=2;continue}}i.push(c)}s=new ArrayBuffer(i.length);let l=new DataView(s);for(let u=0,a=i.length;u<a;u++)l.setUint8(u,i[u])}else e==="B"?s=ws(t.replace(/[^a-zA-Z0-9\+\/=]+/g,"")):s=Zt.encode(t);return vr(r).decode(s)}function Dr(r){let e=!0;for(;;){let t=(r||"").toString().replace(/(=\?([^?]+)\?[Bb]\?([^?]*)\?=)\s*(?==\?([^?]+)\?[Bb]\?[^?]*\?=)/g,(n,s,o,i,l)=>e&&o===l&&i.length%4===0&&!/=$/.test(i)?s+"__\0JOIN\0__":n).replace(/(=\?([^?]+)\?[Qq]\?[^?]*\?=)\s*(?==\?([^?]+)\?[Qq]\?[^?]*\?=)/g,(n,s,o,i)=>e&&o===i?s+"__\0JOIN\0__":n).replace(/(\?=)?__\x00JOIN\x00__(=\?([^?]+)\?[QqBb]\?)?/g,"").replace(/(=\?[^?]+\?[QqBb]\?[^?]*\?=)\s+(?==\?[^?]+\?[QqBb]\?[^?]*\?=)/g,"$1").replace(/=\?([\w_\-*]+)\?([QqBb])\?([^?]*)\?=/g,(n,s,o,i)=>Iu(s,o,i));if(e&&t.indexOf("�")>=0)e=!1;else return t}}function zu(r,e){e=e||"utf-8";let t=[];for(let o=0;o<r.length;o++){let i=r.charAt(o);if(i==="%"&&/^[a-f0-9]{2}/i.test(r.substr(o+1,2))){let l=r.substr(o+1,2);o+=2,t.push(parseInt(l,16))}else if(i.charCodeAt(0)>126){i=Zt.encode(i);for(let l=0;l<i.length;l++)t.push(i[l])}else t.push(i.charCodeAt(0))}const n=new ArrayBuffer(t.length),s=new DataView(n);for(let o=0,i=t.length;o<i;o++)s.setUint8(o,t[o]);return vr(e).decode(n)}function qu(r){let e=new Map;Object.keys(r.params).forEach(t=>{let n=t.match(/\*((\d+)\*?)?$/);if(!n)return;let s=t.substr(0,n.index).toLowerCase(),o=Number(n[2])||0,i;e.has(s)?i=e.get(s):(i={charset:!1,values:[]},e.set(s,i));let l=r.params[t];o===0&&n[0].charAt(n[0].length-1)==="*"&&(n=l.match(/^([^']*)'[^']*'(.*)$/))&&(i.charset=n[1]||"utf-8",l=n[2]),i.values.push({nr:o,value:l}),delete r.params[t]}),e.forEach((t,n)=>{r.params[n]=zu(t.values.sort((s,o)=>s.nr-o.nr).map(s=>s.value).join(""),t.charset)})}class Uu{constructor(){this.chunks=[]}update(e){this.chunks.push(e),this.chunks.push(`
|
|
2
2
|
`)}finalize(){return On(new Blob(this.chunks,{type:"application/octet-stream"}))}}class Wu{constructor(e){e=e||{},this.decoder=e.decoder||new TextDecoder,this.maxChunkSize=100*1024,this.chunks=[],this.remainder=""}update(e){let t=this.decoder.decode(e);if(/[^a-zA-Z0-9+\/]/.test(t)&&(t=t.replace(/[^a-zA-Z0-9+\/]+/g,"")),this.remainder+=t,this.remainder.length>=this.maxChunkSize){let n=Math.floor(this.remainder.length/4)*4,s;n===this.remainder.length?(s=this.remainder,this.remainder=""):(s=this.remainder.substr(0,n),this.remainder=this.remainder.substr(n)),s.length&&this.chunks.push(ws(s))}}finalize(){return this.remainder&&!/^=+$/.test(this.remainder)&&this.chunks.push(ws(this.remainder)),On(new Blob(this.chunks,{type:"application/octet-stream"}))}}const ji=/^=[a-f0-9]{2}$/i,Ku=/(?==[a-f0-9]{2})/i,Vu=/=\r?\n/g,Gu=/=[a-fA-F0-9]?$/;class Hu{constructor(e){e=e||{},this.decoder=e.decoder||new TextDecoder,this.maxChunkSize=100*1024,this.remainder="",this.chunks=[]}decodeQPBytes(e){let t=new ArrayBuffer(e.length),n=new DataView(t);for(let s=0,o=e.length;s<o;s++)n.setUint8(s,parseInt(e[s],16));return t}decodeChunks(e){e=e.replace(Vu,"");let t=e.split(Ku),n=[];for(let s of t){if(s.charAt(0)!=="="){n.length&&(this.chunks.push(this.decodeQPBytes(n)),n=[]),this.chunks.push(s);continue}if(s.length===3){ji.test(s)?n.push(s.substr(1)):(n.length&&(this.chunks.push(this.decodeQPBytes(n)),n=[]),this.chunks.push(s));continue}if(s.length>3){const o=s.substr(0,3);ji.test(o)?(n.push(s.substr(1,2)),this.chunks.push(this.decodeQPBytes(n)),n=[],s=s.substr(3),this.chunks.push(s)):(n.length&&(this.chunks.push(this.decodeQPBytes(n)),n=[]),this.chunks.push(s))}}n.length&&(this.chunks.push(this.decodeQPBytes(n)),n=[])}update(e){let t=this.decoder.decode(e)+`
|
|
3
3
|
`;if(t=this.remainder+t,t.length<this.maxChunkSize){this.remainder=t;return}this.remainder="";let n=t.match(Gu);if(n){if(n.index===0){this.remainder=t;return}this.remainder=t.substr(n.index),t=t.substr(0,n.index)}this.decodeChunks(t)}finalize(){return this.remainder.length&&(this.decodeChunks(this.remainder),this.remainder=""),On(new Blob(this.chunks,{type:"application/octet-stream"}))}}class Pi{constructor(e){if(this.options=e||{},this.postalMime=this.options.postalMime,this.root=!!this.options.parentNode,this.childNodes=[],this.options.parentNode){if(this.parentNode=this.options.parentNode,this.depth=this.parentNode.depth+1,this.depth>this.options.maxNestingDepth)throw new Error(`Maximum MIME nesting depth of ${this.options.maxNestingDepth} levels exceeded`);this.options.parentNode.childNodes.push(this)}else this.depth=0;this.state="header",this.headerLines=[],this.headerSize=0,this.contentType={value:"text/plain",default:!0},this.contentTransferEncoding={value:"8bit"},this.contentDisposition={value:""},this.headers=[],this.contentDecoder=!1}setupContentDecoder(e){/base64/i.test(e)?this.contentDecoder=new Wu:/quoted-printable/i.test(e)?this.contentDecoder=new Hu({decoder:vr(this.contentType.parsed.params.charset)}):this.contentDecoder=new Uu}async finalize(){if(this.state==="finished")return;this.state==="header"&&this.processHeaders();let e=this.postalMime.boundaries;for(let t=e.length-1;t>=0;t--)if(e[t].node===this){e.splice(t,1);break}await this.finalizeChildNodes(),this.content=this.contentDecoder?await this.contentDecoder.finalize():null,this.state="finished"}async finalizeChildNodes(){for(let e of this.childNodes)await e.finalize()}parseStructuredHeader(e){let t={value:!1,params:{}},n=!1,s="",o="value",i=!1,l=!1,u;for(let a=0,c=e.length;a<c;a++)switch(u=e.charAt(a),o){case"key":if(u==="="){n=s.trim().toLowerCase(),o="value",s="";break}s+=u;break;case"value":if(l)s+=u;else if(u==="\\"){l=!0;continue}else i&&u===i?i=!1:!i&&u==='"'?i=u:!i&&u===";"?(n===!1?t.value=s.trim():t.params[n]=s.trim(),o="key",s=""):s+=u;l=!1;break}return s=s.trim(),o==="value"?n===!1?t.value=s:t.params[n]=s:s&&(t.params[s.toLowerCase()]=""),t.value&&(t.value=t.value.toLowerCase()),qu(t),t}decodeFlowedText(e,t){return e.split(/\r?\n/).reduce((n,s)=>/ $/.test(n)&&!/(^|\n)-- $/.test(n)?t?n.slice(0,-1)+s:n+s:n+`
|
|
4
4
|
`+s).replace(/^ /gm,"")}getTextContent(){if(!this.content)return"";let e=vr(this.contentType.parsed.params.charset).decode(this.content);return/^flowed$/i.test(this.contentType.parsed.params.format)&&(e=this.decodeFlowedText(e,/^yes$/i.test(this.contentType.parsed.params.delsp))),e}processHeaders(){for(let e=this.headerLines.length-1;e>=0;e--){let t=this.headerLines[e];if(e&&/^\s/.test(t))this.headerLines[e-1]+=`
|
|
@@ -20,12 +20,12 @@ ${e.join(`
|
|
|
20
20
|
`)}
|
|
21
21
|
${s}
|
|
22
22
|
`}function Ri(r){let e=[];if(r.from&&e.push(`<div class="postal-email-header-key">From</div><div class="postal-email-header-value">${el(r.from)}</div>`),r.subject&&e.push(`<div class="postal-email-header-key">Subject</div><div class="postal-email-header-value postal-email-header-subject">${St(r.subject)}</div>`),r.date){let n={year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1},s=typeof Intl>"u"?r.date:new Intl.DateTimeFormat("default",n).format(new Date(r.date));e.push(`<div class="postal-email-header-key">Date</div><div class="postal-email-header-value postal-email-header-date" data-date="${St(r.date)}">${St(s)}</div>`)}return r.to&&r.to.length&&e.push(`<div class="postal-email-header-key">To</div><div class="postal-email-header-value">${cs(r.to)}</div>`),r.cc&&r.cc.length&&e.push(`<div class="postal-email-header-key">Cc</div><div class="postal-email-header-value">${cs(r.cc)}</div>`),r.bcc&&r.bcc.length&&e.push(`<div class="postal-email-header-key">Bcc</div><div class="postal-email-header-value">${cs(r.bcc)}</div>`),`<div class="postal-email-header">${e.length?'<div class="postal-email-header-row">':""}${e.join(`</div>
|
|
23
|
-
<div class="postal-email-header-row">`)}${e.length?"</div>":""}</div>`}function Zu(r,e){let t=!1,n="text",s,o=[],i={address:[],comment:[],group:[],text:[],textWasQuoted:[]},l,u,a=!1;for(l=0,u=r.length;l<u;l++){let c=r[l],f=l?r[l-1]:null;if(c.type==="operator")switch(c.value){case"<":n="address",a=!1;break;case"(":n="comment",a=!1;break;case":":n="group",t=!0,a=!1;break;case'"':a=!a,n="text";break;default:n="text",a=!1;break}else c.value&&(n==="address"&&(c.value=c.value.replace(/^[^<]*<\s*/,"")),f&&f.noBreak&&i[n].length?(i[n][i[n].length-1]+=c.value,n==="text"&&a&&(i.textWasQuoted[i.textWasQuoted.length-1]=!0)):(i[n].push(c.value),n==="text"&&i.textWasQuoted.push(a)))}if(!i.text.length&&i.comment.length&&(i.text=i.comment,i.comment=[]),t){i.text=i.text.join(" ");let c=[];i.group.length&&
|
|
23
|
+
<div class="postal-email-header-row">`)}${e.length?"</div>":""}</div>`}function Zu(r,e){let t=!1,n="text",s,o=[],i={address:[],comment:[],group:[],text:[],textWasQuoted:[]},l,u,a=!1;for(l=0,u=r.length;l<u;l++){let c=r[l],f=l?r[l-1]:null;if(c.type==="operator")switch(c.value){case"<":n="address",a=!1;break;case"(":n="comment",a=!1;break;case":":n="group",t=!0,a=!1;break;case'"':a=!a,n="text";break;default:n="text",a=!1;break}else c.value&&(n==="address"&&(c.value=c.value.replace(/^[^<]*<\s*/,"")),f&&f.noBreak&&i[n].length?(i[n][i[n].length-1]+=c.value,n==="text"&&a&&(i.textWasQuoted[i.textWasQuoted.length-1]=!0)):(i[n].push(c.value),n==="text"&&i.textWasQuoted.push(a)))}if(!i.text.length&&i.comment.length&&(i.text=i.comment,i.comment=[]),t){i.text=i.text.join(" ");let c=[];i.group.length&&Cr(i.group.join(","),{_depth:e+1}).forEach(d=>{d.group?c=c.concat(d.group):c.push(d)}),o.push({name:Dr(i.text||s&&s.name),group:c})}else{if(!i.address.length&&i.text.length){for(l=i.text.length-1;l>=0;l--)if(!i.textWasQuoted[l]&&i.text[l].match(/^[^@\s]+@[^@\s]+$/)){i.address=i.text.splice(l,1),i.textWasQuoted.splice(l,1);break}let c=function(f){return i.address.length?f:(i.address=[f.trim()]," ")};if(!i.address.length)for(l=i.text.length-1;l>=0&&!(!i.textWasQuoted[l]&&(i.text[l]=i.text[l].replace(/\s*\b[^@\s]+@[^\s]+\b\s*/,c).trim(),i.address.length));l--);}if(!i.text.length&&i.comment.length&&(i.text=i.comment,i.comment=[]),i.address.length>1&&(i.text=i.text.concat(i.address.splice(1))),i.text=i.text.join(" "),i.address=i.address.join(" "),!i.address&&/^=\?[^=]+?=$/.test(i.text.trim())){const c=Cr(Dr(i.text));if(c&&c.length)return c}if(!i.address&&t)return[];s={address:i.address||i.text||"",name:Dr(i.text||i.address||"")},s.address===s.name&&((s.address||"").match(/@/)?s.name="":s.address=""),o.push(s)}return o}class ea{constructor(e){this.str=(e||"").toString(),this.operatorCurrent="",this.operatorExpecting="",this.node=null,this.escaped=!1,this.list=[],this.operators={'"':'"',"(":")","<":">",",":"",":":";",";":""}}tokenize(){let e=[];for(let t=0,n=this.str.length;t<n;t++){let s=this.str.charAt(t),o=t<n-1?this.str.charAt(t+1):null;this.checkChar(s,o)}return this.list.forEach(t=>{t.value=(t.value||"").toString().trim(),t.value&&e.push(t)}),e}checkChar(e,t){if(!this.escaped){if(e===this.operatorExpecting){this.node={type:"operator",value:e},t&&![" "," ","\r",`
|
|
24
24
|
`,",",";"].includes(t)&&(this.node.noBreak=!0),this.list.push(this.node),this.node=null,this.operatorExpecting="",this.escaped=!1;return}else if(!this.operatorExpecting&&e in this.operators){this.node={type:"operator",value:e},this.list.push(this.node),this.node=null,this.operatorExpecting=this.operators[e],this.escaped=!1;return}else if(['"',"'"].includes(this.operatorExpecting)&&e==="\\"){this.escaped=!0;return}}this.node||(this.node={type:"text",value:""},this.list.push(this.node)),e===`
|
|
25
|
-
`&&(e=" "),(e.charCodeAt(0)>=33||[" "," "].includes(e))&&(this.node.value+=e),this.escaped=!1}}const ta=50;function
|
|
25
|
+
`&&(e=" "),(e.charCodeAt(0)>=33||[" "," "].includes(e))&&(this.node.value+=e),this.escaped=!1}}const ta=50;function Cr(r,e){e=e||{};let t=e._depth||0;if(t>ta)return[];let s=new ea(r).tokenize(),o=[],i=[],l=[];if(s.forEach(u=>{u.type==="operator"&&(u.value===","||u.value===";")?(i.length&&o.push(i),i=[]):i.push(u)}),i.length&&o.push(i),o.forEach(u=>{u=Zu(u,t),u.length&&(l=l.concat(u))}),e.flatten){let u=[],a=c=>{c.forEach(f=>{if(f.group)return a(f.group);u.push(f)})};return a(l),u}return l}function ra(r){for(var e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=new Uint8Array(r),s=n.byteLength,o=s%3,i=s-o,l,u,a,c,f,d=0;d<i;d=d+3)f=n[d]<<16|n[d+1]<<8|n[d+2],l=(f&16515072)>>18,u=(f&258048)>>12,a=(f&4032)>>6,c=f&63,e+=t[l]+t[u]+t[a]+t[c];return o==1?(f=n[i],l=(f&252)>>2,u=(f&3)<<4,e+=t[l]+t[u]+"=="):o==2&&(f=n[i]<<8|n[i+1],l=(f&64512)>>10,u=(f&1008)>>4,a=(f&15)<<2,e+=t[l]+t[u]+t[a]+"="),e}const na=256,sa=2*1024*1024;class gn{static parse(e,t){return new gn(t).parse(e)}constructor(e){this.options=e||{},this.mimeOptions={maxNestingDepth:this.options.maxNestingDepth||na,maxHeadersSize:this.options.maxHeadersSize||sa},this.root=this.currentNode=new Pi({postalMime:this,...this.mimeOptions}),this.boundaries=[],this.textContent={},this.attachments=[],this.attachmentEncoding=(this.options.attachmentEncoding||"").toString().replace(/[-_\s]/g,"").trim().toLowerCase()||"arraybuffer",this.started=!1}async finalize(){await this.root.finalize()}async processLine(e,t){let n=this.boundaries;if(n.length&&e.length>2&&e[0]===45&&e[1]===45)for(let s=n.length-1;s>=0;s--){let o=n[s];if(e.length!==o.value.length+2&&e.length!==o.value.length+4)continue;let i=e.length===o.value.length+4;if(i&&(e[e.length-2]!==45||e[e.length-1]!==45))continue;let l=!0;for(let u=0;u<o.value.length;u++)if(e[u+2]!==o.value[u]){l=!1;break}if(l)return i?(await o.node.finalize(),this.currentNode=o.node.parentNode||this.root):(await o.node.finalizeChildNodes(),this.currentNode=new Pi({postalMime:this,parentNode:o.node,...this.mimeOptions})),t?this.finalize():void 0}if(this.currentNode.feed(e),t)return this.finalize()}readLine(){let e=this.readPos,t=this.readPos,n=()=>({bytes:new Uint8Array(this.buf,e,t-e),done:this.readPos>=this.av.length});for(;this.readPos<this.av.length;){const s=this.av[this.readPos++];if(s!==13&&s!==10&&(t=this.readPos),s===10)return n()}return n()}async processNodeTree(){let e={},t=new Set,n=this.textMap=new Map,s=this.forceRfc822Attachments(),o=async(i,l,u)=>{if(l=l||!1,u=u||!1,i.contentType.multipart)i.contentType.multipart==="alternative"?l=i:i.contentType.multipart==="related"&&(u=i);else if(this.isInlineMessageRfc822(i)&&!s){const a=new gn;i.subMessage=await a.parse(i.content),n.has(i)||n.set(i,{});let c=n.get(i);(i.subMessage.text||!i.subMessage.html)&&(c.plain=c.plain||[],c.plain.push({type:"subMessage",value:i.subMessage}),t.add("plain")),i.subMessage.html&&(c.html=c.html||[],c.html.push({type:"subMessage",value:i.subMessage}),t.add("html")),a.textMap&&a.textMap.forEach((f,d)=>{n.set(d,f)});for(let f of i.subMessage.attachments||[])this.attachments.push(f)}else if(this.isInlineTextNode(i)){let a=i.contentType.parsed.value.substr(i.contentType.parsed.value.indexOf("/")+1),c=l||i;n.has(c)||n.set(c,{});let f=n.get(c);f[a]=f[a]||[],f[a].push({type:"text",value:i.getTextContent()}),t.add(a)}else if(i.content){const a=i.contentDisposition.parsed.params.filename||i.contentType.parsed.params.name||null,c={filename:a?Dr(a):null,mimeType:i.contentType.parsed.value,disposition:i.contentDisposition.parsed.value||null};switch(u&&i.contentId&&(c.related=!0),i.contentDescription&&(c.description=i.contentDescription),i.contentId&&(c.contentId=i.contentId),i.contentType.parsed.value){case"text/calendar":case"application/ics":{i.contentType.parsed.params.method&&(c.method=i.contentType.parsed.params.method.toString().toUpperCase().trim());const f=i.getTextContent().replace(/\r?\n/g,`
|
|
26
26
|
`).replace(/\n*$/,`
|
|
27
27
|
`);c.content=Zt.encode(f);break}default:c.content=i.content}this.attachments.push(c)}for(let a of i.childNodes)await o(a,l,u)};await o(this.root,!1,[]),n.forEach(i=>{t.forEach(l=>{if(e[l]||(e[l]=[]),i[l])i[l].forEach(u=>{switch(u.type){case"text":e[l].push(u.value);break;case"subMessage":switch(l){case"html":e[l].push(Ri(u.value));break;case"plain":e[l].push(Mi(u.value));break}break}});else{let u;switch(l){case"html":u="plain";break;case"plain":u="html";break}(i[u]||[]).forEach(a=>{switch(a.type){case"text":switch(l){case"html":e[l].push(Qu(a.value));break;case"plain":e[l].push(Yu(a.value));break}break;case"subMessage":switch(l){case"html":e[l].push(Ri(a.value));break;case"plain":e[l].push(Mi(a.value));break}break}})}})}),Object.keys(e).forEach(i=>{e[i]=e[i].join(`
|
|
28
|
-
`)}),this.textContent=e}isInlineTextNode(e){if(e.contentDisposition.parsed.value==="attachment")return!1;switch(e.contentType.parsed.value){case"text/html":case"text/plain":return!0;case"text/calendar":case"text/csv":default:return!1}}isInlineMessageRfc822(e){return e.contentType.parsed.value!=="message/rfc822"?!1:(e.contentDisposition.parsed.value||(this.options.rfc822Attachments?"attachment":"inline"))==="inline"}forceRfc822Attachments(){if(this.options.forceRfc822Attachments)return!0;let e=!1,t=n=>{n.contentType.multipart||["message/delivery-status","message/feedback-report"].includes(n.contentType.parsed.value)&&(e=!0);for(let s of n.childNodes)t(s)};return t(this.root),e}async resolveStream(e){let t=0,n=[];const s=e.getReader();for(;;){const{done:l,value:u}=await s.read();if(l)break;n.push(u),t+=u.length}const o=new Uint8Array(t);let i=0;for(let l of n)o.set(l,i),i+=l.length;return o}async parse(e){var s,o;if(this.started)throw new Error("Can not reuse parser, create a new PostalMime object");for(this.started=!0,e&&typeof e.getReader=="function"&&(e=await this.resolveStream(e)),e=e||new ArrayBuffer(0),typeof e=="string"&&(e=Zt.encode(e)),(e instanceof Blob||Object.prototype.toString.call(e)==="[object Blob]")&&(e=await On(e)),e.buffer instanceof ArrayBuffer&&(e=new Uint8Array(e).buffer),this.buf=e,this.av=new Uint8Array(e),this.readPos=0;this.readPos<this.av.length;){const i=this.readLine();await this.processLine(i.bytes,i.done)}await this.processNodeTree();const t={headers:this.root.headers.map(i=>({key:i.key,value:i.value})).reverse()};for(const i of["from","sender"]){const l=this.root.headers.find(u=>u.key===i);if(l&&l.value){const u=Dr(l.value);u&&u.length&&(t[i]=u[0])}}for(const i of["delivered-to","return-path"]){const l=this.root.headers.find(u=>u.key===i);if(l&&l.value){const u=Dr(l.value);if(u&&u.length&&u[0].address){const a=i.replace(/\-(.)/g,(c,f)=>f.toUpperCase());t[a]=u[0].address}}}for(const i of["to","cc","bcc","reply-to"]){const l=this.root.headers.filter(a=>a.key===i);let u=[];if(l.filter(a=>a&&a.value).map(a=>Dr(a.value)).forEach(a=>u=u.concat(a||[])),u&&u.length){const a=i.replace(/\-(.)/g,(c,f)=>f.toUpperCase());t[a]=u}}for(const i of["subject","message-id","in-reply-to","references"]){const l=this.root.headers.find(u=>u.key===i);if(l&&l.value){const u=i.replace(/\-(.)/g,(a,c)=>c.toUpperCase());t[u]=Cr(l.value)}}let n=this.root.headers.find(i=>i.key==="date");if(n){let i=new Date(n.value);!i||i.toString()==="Invalid Date"?i=n.value:i=i.toISOString(),t.date=i}switch((s=this.textContent)!=null&&s.html&&(t.html=this.textContent.html),(o=this.textContent)!=null&&o.plain&&(t.text=this.textContent.plain),t.attachments=this.attachments,this.attachmentEncoding){case"arraybuffer":break;case"base64":for(let l of t.attachments||[])l!=null&&l.content&&(l.content=ra(l.content),l.encoding="base64");break;case"utf8":let i=new TextDecoder("utf8");for(let l of t.attachments||[])l!=null&&l.content&&(l.content=i.decode(l.content),l.encoding="utf8");break;default:throw new Error("Unknwon attachment encoding")}return t}}class tl{constructor(e){ar(this,"config");if(!e.system_id)throw new Error("MailClient: system_id is REQUIRED");this.config=e}async callCoprocessor(e,t,n={}){const s={coprocessor:e,method:t,system_id:this.config.system_id,params:{user_id:this.config.system_id,...n}};try{const o=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(s)});if(!o.ok){const l=await o.text();throw new Error(`API error (${o.status}): ${l}`)}const i=await o.json();if(!i.success&&i.error)throw new Error(i.error);return i.result}catch(o){throw console.error("API call failed:",o),o}}async callMail(e,t={}){return this.callCoprocessor("mail",e,t)}async callEmail(e,t={}){return this.callCoprocessor("email",e,t)}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async getSettings(){try{return await this.callMail("get_email_settings")||{accounts:[]}}catch{return{accounts:[]}}}async saveSettings(e){await this.callMail("save_email_settings",{accounts:e})}async listEmails(e,t=150,n){return this.callMail("list_emails",{account_id:e,limit:t,folder:n})}async deleteEmails(e,t,n=!0){return this.callMail("delete_emails",{account_id:e,uids:t,expunge:n})}async imapExec(e,t){return this.callMail("imap_exec",{account_id:e,commands:t})}async trashEmails(e,t,n="INBOX"){const s=["[Gmail]/Trash","[Gmail]/Corbeille","[Gmail]/Bin","Trash"];for(const o of s){const i=[`SELECT "${n}"`,...t.map(a=>`UID MOVE ${a} "${o}"`)],u=(await this.imapExec(e,i)).responses.filter(a=>a.ok&&a.command==="UID MOVE").length;if(u>0)return{success:!0,moved:u}}return{success:!1,moved:0}}async archiveEmails(e,t,n="INBOX"){const s=[`SELECT "${n}"`,...t.map(l=>`UID STORE ${l} +FLAGS (\\Deleted)`),"EXPUNGE"],i=(await this.imapExec(e,s)).responses.filter(l=>l.ok&&l.command==="UID STORE").length;return{success:i>0,archived:i}}async listFolders(e){const n=(await this.imapExec(e,['LIST "" *'])).responses.find(s=>s.command==="LIST");return n!=null&&n.ok&&n.folders?{success:!0,folders:n.folders}:{success:!1,folders:[]}}async listEmailsSorted(e,t="INBOX",n=150){const s=await this.imapExec(e,[`SELECT ${t}`,"FETCH 1:* (UID INTERNALDATE)"]),o=s.responses.find(h=>h.command==="SELECT");if(!(o!=null&&o.ok))throw new Error(`Failed to select folder: ${(o==null?void 0:o.error)||"Unknown error"}`);const i=s.responses.find(h=>h.command==="FETCH");if(!(i!=null&&i.ok)||!i.messages)return{account:{id:e,label:"",email:""},mailbox:{name:t,total:o.exists||0},messages:[]};const u=[...i.messages].sort((h,p)=>{const m=h.internalDate?new Date(h.internalDate).getTime():0;return(p.internalDate?new Date(p.internalDate).getTime():0)-m}).slice(0,n).map(h=>h.uid).filter(Boolean);if(u.length===0)return{account:{id:e,label:"",email:""},mailbox:{name:t,total:o.exists||0},messages:[]};const c=(await this.imapExec(e,[`SELECT ${t}`,`UID FETCH ${u.join(",")} (UID FLAGS ENVELOPE)`])).responses.find(h=>h.command==="UID FETCH");if(!(c!=null&&c.ok)||!c.messages)throw new Error(`Failed to fetch details: ${(c==null?void 0:c.error)||"Unknown error"}`);const f=new Map;for(const h of c.messages)h.uid&&f.set(h.uid,h);const d=u.map(h=>{var E,C,A,v,b;const p=f.get(h);if(!p)return null;const m=((E=p.flags)==null?void 0:E.some(w=>w.includes("Seen")))||!1,x=((A=(C=p.envelope)==null?void 0:C.from)==null?void 0:A.email)||"Unknown",D=((v=p.envelope)==null?void 0:v.subject)||"(No subject)",_=((b=p.envelope)==null?void 0:b.date)||"";return{uid:h,from:x,subject:D,date:_,seen:m}}).filter(Boolean);return{account:{id:e,label:"",email:""},mailbox:{name:t,total:o.exists||0},messages:d}}async getEmail(e,t,n="INBOX"){return this.callMail("get_email",{account_id:e,uid:t,folder:n})}async getAttachment(e,t,n,s="INBOX"){return this.callMail("get_attachment",{account_id:e,uid:t,attachment_index:n,folder:s})}async searchContactEmails(e,t,n=50){return this.callMail("search_contact_emails",{account_id:e,contact_email:t,limit:n})}async getEmailParsed(e,t,n="INBOX"){var p,m,x,D,_,E;const o=(await this.imapExec(e,[`SELECT "${n}"`,`UID FETCH ${t} (FLAGS BODY[])`])).responses.find(C=>C.command==="UID FETCH");if(!(o!=null&&o.ok)||!((p=o.messages)!=null&&p[0]))return console.error("Failed to fetch raw email:",o==null?void 0:o.error),null;const i=o.messages[0],l=i.body||i.raw;if(!l)return console.error("No raw email content in response"),null;const a=await new gn().parse(l);console.log("[MailClient] Parsed email - attachments count:",((m=a.attachments)==null?void 0:m.length)||0),console.log("[MailClient] Parsed attachments:",(x=a.attachments)==null?void 0:x.map(C=>({filename:C.filename,mimeType:C.mimeType,contentId:C.contentId})));const c=new Map;for(const C of a.attachments||[])if(C.contentId){const A=this.contentToBase64(C.content),v=`data:${C.mimeType};base64,${A}`,b=C.contentId.replace(/^<|>$/g,"");c.set(b,v),c.set(`<${b}>`,v)}let f=a.html||"";f&&c.size>0&&(f=f.replace(/src=["']cid:([^"']+)["']/gi,(C,A)=>{const v=c.get(A)||c.get(`<${A}>`);return v?`src="${v}"`:C}));const d=((D=i.flags)==null?void 0:D.some(C=>C.toLowerCase().includes("seen")))||!1,h=((_=a.from)==null?void 0:_.address)||((E=a.from)==null?void 0:E.name)||"Unknown";return{uid:t,from:h,subject:a.subject||"(No subject)",date:a.date||"",body:f||a.text||"",html:f,text:a.text||"",seen:d,attachments:(a.attachments||[]).map(C=>({filename:C.filename||"attachment",mimeType:C.mimeType||"application/octet-stream",size:this.getContentSize(C.content)}))}}contentToBase64(e){if(typeof e=="string")try{return btoa(e)}catch{return e}const t=e instanceof Uint8Array?e:new Uint8Array(e);let n="";for(let s=0;s<t.byteLength;s++)n+=String.fromCharCode(t[s]);return btoa(n)}getContentSize(e){return e?typeof e=="string"?e.length:(e instanceof Uint8Array,e.byteLength):0}async sendMail(e){const t={to:e.to,subject:e.subject,body:e.body};return e.html&&(t.html=e.html),e.from&&(t.from=e.from),e.smtpConfig&&(t.smtp_config=e.smtpConfig),this.callEmail("send",t)}async sendEmail(e,t){var n,s;try{const o=await this.getSettings(),i=((n=o.accounts)==null?void 0:n.find(a=>a.id===e))||((s=o.accounts)==null?void 0:s[0]);if(!(i!=null&&i.smtp))return{success:!1,error:"No SMTP configuration found for account"};const l={to:Array.isArray(t.to)?t.to:[t.to],subject:t.subject,body:t.text||"",html:t.html,from:i.email,smtp_config:{host:i.smtp.host,port:parseInt(i.smtp.port,10)||587,username:i.smtp.user,password:i.smtp.password}};t.in_reply_to&&(l.in_reply_to=t.in_reply_to),t.attachments&&t.attachments.length>0&&(l.attachments=t.attachments);const u=await this.callEmail("send",l);return{success:(u==null?void 0:u.sent)??!1,message_id:u==null?void 0:u.message_id,error:u==null?void 0:u.error}}catch(o){return{success:!1,error:o instanceof Error?o.message:String(o)}}}}const ds="qwanyx_auth_token",fs="qwanyx_refresh_token";class rl{static setToken(e){typeof window<"u"&&localStorage.setItem(ds,e)}static getToken(){return typeof window<"u"?localStorage.getItem(ds):null}static clearToken(){typeof window<"u"&&(localStorage.removeItem(ds),localStorage.removeItem(fs))}static setRefreshToken(e){typeof window<"u"&&localStorage.setItem(fs,e)}static getRefreshToken(){return typeof window<"u"?localStorage.getItem(fs):null}static isAuthenticated(){return!!this.getToken()}static getAuthHeader(){const e=this.getToken();return e?{Authorization:`Bearer ${e}`}:{}}}class nl{constructor(e){ar(this,"config");this.config={timeout:3e4,headers:{"Content-Type":"application/json"},...e}}buildQueryString(e){if(!e||Object.keys(e).length===0)return"";const t=new URLSearchParams;Object.entries(e).forEach(([s,o])=>{o!=null&&t.append(s,String(o))});const n=t.toString();return n?`?${n}`:""}async request(e,t={}){const{method:n="GET",headers:s={},body:o,params:i}=t,l=`${this.config.baseUrl}/${e}${this.buildQueryString(i)}`,u={...this.config.headers,...rl.getAuthHeader(),...s},a={method:n,headers:u};o&&n!=="GET"&&(a.body=JSON.stringify(o));try{const c=new AbortController,f=setTimeout(()=>c.abort(),this.config.timeout),d=await fetch(l,{...a,signal:c.signal});if(clearTimeout(f),!d.ok){const h=await d.json().catch(()=>({message:d.statusText}));throw new Error(h.message||`HTTP ${d.status}`)}return await d.json()}catch(c){throw c instanceof Error?c:new Error("An unexpected error occurred")}}async get(e,t){return this.request(e,{method:"GET",params:t})}async post(e,t,n){return this.request(e,{method:"POST",body:t,params:n})}async put(e,t,n){return this.request(e,{method:"PUT",body:t,params:n})}async patch(e,t,n){return this.request(e,{method:"PATCH",body:t,params:n})}async delete(e,t){return this.request(e,{method:"DELETE",params:t})}setBaseUrl(e){this.config.baseUrl=e}getBaseUrl(){return this.config.baseUrl}}let mn=null;function ia(r){return mn=new nl(r),mn}function Hs(){if(!mn)throw new Error("API client not initialized. Call initializeApiClient() first.");return mn}function sl(r,e,t={}){const{enabled:n=!0,refetchOnMount:s=!0,onSuccess:o,onError:i}=t,[l,u]=k.useState(null),[a,c]=k.useState(n),[f,d]=k.useState(null),h=k.useCallback(async()=>{if(n){c(!0),d(null);try{const m=await Hs().get(r,e);u(m),o==null||o(m)}catch(p){const m=p instanceof Error?p:new Error("Unknown error");d(m),i==null||i(m)}finally{c(!1)}}},[r,JSON.stringify(e),n,o,i]);return k.useEffect(()=>{s&&h()},[h,s]),{data:l,loading:a,error:f,refetch:h}}function oa(r,e="POST",t={}){const{onSuccess:n,onError:s}=t,[o,i]=k.useState(null),[l,u]=k.useState(!1),[a,c]=k.useState(null),f=k.useCallback(async h=>{u(!0),c(null);try{const p=Hs();let m;switch(e){case"POST":m=await p.post(r,h);break;case"PUT":m=await p.put(r,h);break;case"PATCH":m=await p.patch(r,h);break;case"DELETE":m=await p.delete(r);break;default:throw new Error(`Unsupported method: ${e}`)}return i(m),n==null||n(m,h),m}catch(p){const m=p instanceof Error?p:new Error("Unknown error");return c(m),s==null||s(m,h),null}finally{u(!1)}},[r,e,n,s]),d=k.useCallback(()=>{i(null),c(null),u(!1)},[]);return{data:o,loading:l,error:a,mutate:f,reset:d}}var Es={exports:{}},cr={};/**
|
|
28
|
+
`)}),this.textContent=e}isInlineTextNode(e){if(e.contentDisposition.parsed.value==="attachment")return!1;switch(e.contentType.parsed.value){case"text/html":case"text/plain":return!0;case"text/calendar":case"text/csv":default:return!1}}isInlineMessageRfc822(e){return e.contentType.parsed.value!=="message/rfc822"?!1:(e.contentDisposition.parsed.value||(this.options.rfc822Attachments?"attachment":"inline"))==="inline"}forceRfc822Attachments(){if(this.options.forceRfc822Attachments)return!0;let e=!1,t=n=>{n.contentType.multipart||["message/delivery-status","message/feedback-report"].includes(n.contentType.parsed.value)&&(e=!0);for(let s of n.childNodes)t(s)};return t(this.root),e}async resolveStream(e){let t=0,n=[];const s=e.getReader();for(;;){const{done:l,value:u}=await s.read();if(l)break;n.push(u),t+=u.length}const o=new Uint8Array(t);let i=0;for(let l of n)o.set(l,i),i+=l.length;return o}async parse(e){var s,o;if(this.started)throw new Error("Can not reuse parser, create a new PostalMime object");for(this.started=!0,e&&typeof e.getReader=="function"&&(e=await this.resolveStream(e)),e=e||new ArrayBuffer(0),typeof e=="string"&&(e=Zt.encode(e)),(e instanceof Blob||Object.prototype.toString.call(e)==="[object Blob]")&&(e=await On(e)),e.buffer instanceof ArrayBuffer&&(e=new Uint8Array(e).buffer),this.buf=e,this.av=new Uint8Array(e),this.readPos=0;this.readPos<this.av.length;){const i=this.readLine();await this.processLine(i.bytes,i.done)}await this.processNodeTree();const t={headers:this.root.headers.map(i=>({key:i.key,value:i.value})).reverse()};for(const i of["from","sender"]){const l=this.root.headers.find(u=>u.key===i);if(l&&l.value){const u=Cr(l.value);u&&u.length&&(t[i]=u[0])}}for(const i of["delivered-to","return-path"]){const l=this.root.headers.find(u=>u.key===i);if(l&&l.value){const u=Cr(l.value);if(u&&u.length&&u[0].address){const a=i.replace(/\-(.)/g,(c,f)=>f.toUpperCase());t[a]=u[0].address}}}for(const i of["to","cc","bcc","reply-to"]){const l=this.root.headers.filter(a=>a.key===i);let u=[];if(l.filter(a=>a&&a.value).map(a=>Cr(a.value)).forEach(a=>u=u.concat(a||[])),u&&u.length){const a=i.replace(/\-(.)/g,(c,f)=>f.toUpperCase());t[a]=u}}for(const i of["subject","message-id","in-reply-to","references"]){const l=this.root.headers.find(u=>u.key===i);if(l&&l.value){const u=i.replace(/\-(.)/g,(a,c)=>c.toUpperCase());t[u]=Dr(l.value)}}let n=this.root.headers.find(i=>i.key==="date");if(n){let i=new Date(n.value);!i||i.toString()==="Invalid Date"?i=n.value:i=i.toISOString(),t.date=i}switch((s=this.textContent)!=null&&s.html&&(t.html=this.textContent.html),(o=this.textContent)!=null&&o.plain&&(t.text=this.textContent.plain),t.attachments=this.attachments,this.attachmentEncoding){case"arraybuffer":break;case"base64":for(let l of t.attachments||[])l!=null&&l.content&&(l.content=ra(l.content),l.encoding="base64");break;case"utf8":let i=new TextDecoder("utf8");for(let l of t.attachments||[])l!=null&&l.content&&(l.content=i.decode(l.content),l.encoding="utf8");break;default:throw new Error("Unknwon attachment encoding")}return t}}class tl{constructor(e){ar(this,"config");if(!e.system_id)throw new Error("MailClient: system_id is REQUIRED");this.config=e}async callCoprocessor(e,t,n={}){const s={coprocessor:e,method:t,system_id:this.config.system_id,params:{user_id:this.config.system_id,...n}};try{const o=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(s)});if(!o.ok){const l=await o.text();throw new Error(`API error (${o.status}): ${l}`)}const i=await o.json();if(!i.success&&i.error)throw new Error(i.error);return i.result}catch(o){throw console.error("API call failed:",o),o}}async callMail(e,t={}){return this.callCoprocessor("mail",e,t)}async callEmail(e,t={}){return this.callCoprocessor("email",e,t)}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async getSettings(){try{return await this.callMail("get_email_settings")||{accounts:[]}}catch{return{accounts:[]}}}async saveSettings(e){await this.callMail("save_email_settings",{accounts:e})}async listEmails(e,t=150,n){return this.callMail("list_emails",{account_id:e,limit:t,folder:n})}async deleteEmails(e,t,n=!0){return this.callMail("delete_emails",{account_id:e,uids:t,expunge:n})}async imapExec(e,t){return this.callMail("imap_exec",{account_id:e,commands:t})}async trashEmails(e,t,n="INBOX"){const s=["[Gmail]/Trash","[Gmail]/Corbeille","[Gmail]/Bin","Trash"];for(const o of s){const i=[`SELECT "${n}"`,...t.map(a=>`UID MOVE ${a} "${o}"`)],u=(await this.imapExec(e,i)).responses.filter(a=>a.ok&&a.command==="UID MOVE").length;if(u>0)return{success:!0,moved:u}}return{success:!1,moved:0}}async archiveEmails(e,t,n="INBOX"){const s=[`SELECT "${n}"`,...t.map(l=>`UID STORE ${l} +FLAGS (\\Deleted)`),"EXPUNGE"],i=(await this.imapExec(e,s)).responses.filter(l=>l.ok&&l.command==="UID STORE").length;return{success:i>0,archived:i}}async listFolders(e){const n=(await this.imapExec(e,['LIST "" *'])).responses.find(s=>s.command==="LIST");return n!=null&&n.ok&&n.folders?{success:!0,folders:n.folders}:{success:!1,folders:[]}}async listEmailsSorted(e,t="INBOX",n=150){const s=await this.imapExec(e,[`SELECT ${t}`,"FETCH 1:* (UID INTERNALDATE)"]),o=s.responses.find(h=>h.command==="SELECT");if(!(o!=null&&o.ok))throw new Error(`Failed to select folder: ${(o==null?void 0:o.error)||"Unknown error"}`);const i=s.responses.find(h=>h.command==="FETCH");if(!(i!=null&&i.ok)||!i.messages)return{account:{id:e,label:"",email:""},mailbox:{name:t,total:o.exists||0},messages:[]};const u=[...i.messages].sort((h,p)=>{const m=h.internalDate?new Date(h.internalDate).getTime():0;return(p.internalDate?new Date(p.internalDate).getTime():0)-m}).slice(0,n).map(h=>h.uid).filter(Boolean);if(u.length===0)return{account:{id:e,label:"",email:""},mailbox:{name:t,total:o.exists||0},messages:[]};const c=(await this.imapExec(e,[`SELECT ${t}`,`UID FETCH ${u.join(",")} (UID FLAGS ENVELOPE)`])).responses.find(h=>h.command==="UID FETCH");if(!(c!=null&&c.ok)||!c.messages)throw new Error(`Failed to fetch details: ${(c==null?void 0:c.error)||"Unknown error"}`);const f=new Map;for(const h of c.messages)h.uid&&f.set(h.uid,h);const d=u.map(h=>{var E,D,A,v,b;const p=f.get(h);if(!p)return null;const m=((E=p.flags)==null?void 0:E.some(w=>w.includes("Seen")))||!1,x=((A=(D=p.envelope)==null?void 0:D.from)==null?void 0:A.email)||"Unknown",C=((v=p.envelope)==null?void 0:v.subject)||"(No subject)",_=((b=p.envelope)==null?void 0:b.date)||"";return{uid:h,from:x,subject:C,date:_,seen:m}}).filter(Boolean);return{account:{id:e,label:"",email:""},mailbox:{name:t,total:o.exists||0},messages:d}}async getEmail(e,t,n="INBOX"){return this.callMail("get_email",{account_id:e,uid:t,folder:n})}async getAttachment(e,t,n,s="INBOX"){return this.callMail("get_attachment",{account_id:e,uid:t,attachment_index:n,folder:s})}async searchContactEmails(e,t,n=50){return this.callMail("search_contact_emails",{account_id:e,contact_email:t,limit:n})}async getEmailParsed(e,t,n="INBOX"){var p,m,x,C,_,E;const o=(await this.imapExec(e,[`SELECT "${n}"`,`UID FETCH ${t} (FLAGS BODY[])`])).responses.find(D=>D.command==="UID FETCH");if(!(o!=null&&o.ok)||!((p=o.messages)!=null&&p[0]))return console.error("Failed to fetch raw email:",o==null?void 0:o.error),null;const i=o.messages[0],l=i.body||i.raw;if(!l)return console.error("No raw email content in response"),null;const a=await new gn().parse(l);console.log("[MailClient] Parsed email - attachments count:",((m=a.attachments)==null?void 0:m.length)||0),console.log("[MailClient] Parsed attachments:",(x=a.attachments)==null?void 0:x.map(D=>({filename:D.filename,mimeType:D.mimeType,contentId:D.contentId})));const c=new Map;for(const D of a.attachments||[])if(D.contentId){const A=this.contentToBase64(D.content),v=`data:${D.mimeType};base64,${A}`,b=D.contentId.replace(/^<|>$/g,"");c.set(b,v),c.set(`<${b}>`,v)}let f=a.html||"";f&&c.size>0&&(f=f.replace(/src=["']cid:([^"']+)["']/gi,(D,A)=>{const v=c.get(A)||c.get(`<${A}>`);return v?`src="${v}"`:D}));const d=((C=i.flags)==null?void 0:C.some(D=>D.toLowerCase().includes("seen")))||!1,h=((_=a.from)==null?void 0:_.address)||((E=a.from)==null?void 0:E.name)||"Unknown";return{uid:t,from:h,subject:a.subject||"(No subject)",date:a.date||"",body:f||a.text||"",html:f,text:a.text||"",seen:d,attachments:(a.attachments||[]).map(D=>({filename:D.filename||"attachment",mimeType:D.mimeType||"application/octet-stream",size:this.getContentSize(D.content)}))}}contentToBase64(e){if(typeof e=="string")try{return btoa(e)}catch{return e}const t=e instanceof Uint8Array?e:new Uint8Array(e);let n="";for(let s=0;s<t.byteLength;s++)n+=String.fromCharCode(t[s]);return btoa(n)}getContentSize(e){return e?typeof e=="string"?e.length:(e instanceof Uint8Array,e.byteLength):0}async sendMail(e){const t={to:e.to,subject:e.subject,body:e.body};return e.html&&(t.html=e.html),e.from&&(t.from=e.from),e.smtpConfig&&(t.smtp_config=e.smtpConfig),this.callEmail("send",t)}async sendEmail(e,t){var n,s;try{const o=await this.getSettings(),i=((n=o.accounts)==null?void 0:n.find(a=>a.id===e))||((s=o.accounts)==null?void 0:s[0]);if(!(i!=null&&i.smtp))return{success:!1,error:"No SMTP configuration found for account"};const l={to:Array.isArray(t.to)?t.to:[t.to],subject:t.subject,body:t.text||"",html:t.html,from:i.email,smtp_config:{host:i.smtp.host,port:parseInt(i.smtp.port,10)||587,username:i.smtp.user,password:i.smtp.password}};t.in_reply_to&&(l.in_reply_to=t.in_reply_to),t.attachments&&t.attachments.length>0&&(l.attachments=t.attachments);const u=await this.callEmail("send",l);return{success:(u==null?void 0:u.sent)??!1,message_id:u==null?void 0:u.message_id,error:u==null?void 0:u.error}}catch(o){return{success:!1,error:o instanceof Error?o.message:String(o)}}}}const ds="qwanyx_auth_token",fs="qwanyx_refresh_token";class rl{static setToken(e){typeof window<"u"&&localStorage.setItem(ds,e)}static getToken(){return typeof window<"u"?localStorage.getItem(ds):null}static clearToken(){typeof window<"u"&&(localStorage.removeItem(ds),localStorage.removeItem(fs))}static setRefreshToken(e){typeof window<"u"&&localStorage.setItem(fs,e)}static getRefreshToken(){return typeof window<"u"?localStorage.getItem(fs):null}static isAuthenticated(){return!!this.getToken()}static getAuthHeader(){const e=this.getToken();return e?{Authorization:`Bearer ${e}`}:{}}}class nl{constructor(e){ar(this,"config");this.config={timeout:3e4,headers:{"Content-Type":"application/json"},...e}}buildQueryString(e){if(!e||Object.keys(e).length===0)return"";const t=new URLSearchParams;Object.entries(e).forEach(([s,o])=>{o!=null&&t.append(s,String(o))});const n=t.toString();return n?`?${n}`:""}async request(e,t={}){const{method:n="GET",headers:s={},body:o,params:i}=t,l=`${this.config.baseUrl}/${e}${this.buildQueryString(i)}`,u={...this.config.headers,...rl.getAuthHeader(),...s},a={method:n,headers:u};o&&n!=="GET"&&(a.body=JSON.stringify(o));try{const c=new AbortController,f=setTimeout(()=>c.abort(),this.config.timeout),d=await fetch(l,{...a,signal:c.signal});if(clearTimeout(f),!d.ok){const h=await d.json().catch(()=>({message:d.statusText}));throw new Error(h.message||`HTTP ${d.status}`)}return await d.json()}catch(c){throw c instanceof Error?c:new Error("An unexpected error occurred")}}async get(e,t){return this.request(e,{method:"GET",params:t})}async post(e,t,n){return this.request(e,{method:"POST",body:t,params:n})}async put(e,t,n){return this.request(e,{method:"PUT",body:t,params:n})}async patch(e,t,n){return this.request(e,{method:"PATCH",body:t,params:n})}async delete(e,t){return this.request(e,{method:"DELETE",params:t})}setBaseUrl(e){this.config.baseUrl=e}getBaseUrl(){return this.config.baseUrl}}let mn=null;function ia(r){return mn=new nl(r),mn}function Hs(){if(!mn)throw new Error("API client not initialized. Call initializeApiClient() first.");return mn}function sl(r,e,t={}){const{enabled:n=!0,refetchOnMount:s=!0,onSuccess:o,onError:i}=t,[l,u]=k.useState(null),[a,c]=k.useState(n),[f,d]=k.useState(null),h=k.useCallback(async()=>{if(n){c(!0),d(null);try{const m=await Hs().get(r,e);u(m),o==null||o(m)}catch(p){const m=p instanceof Error?p:new Error("Unknown error");d(m),i==null||i(m)}finally{c(!1)}}},[r,JSON.stringify(e),n,o,i]);return k.useEffect(()=>{s&&h()},[h,s]),{data:l,loading:a,error:f,refetch:h}}function oa(r,e="POST",t={}){const{onSuccess:n,onError:s}=t,[o,i]=k.useState(null),[l,u]=k.useState(!1),[a,c]=k.useState(null),f=k.useCallback(async h=>{u(!0),c(null);try{const p=Hs();let m;switch(e){case"POST":m=await p.post(r,h);break;case"PUT":m=await p.put(r,h);break;case"PATCH":m=await p.patch(r,h);break;case"DELETE":m=await p.delete(r);break;default:throw new Error(`Unsupported method: ${e}`)}return i(m),n==null||n(m,h),m}catch(p){const m=p instanceof Error?p:new Error("Unknown error");return c(m),s==null||s(m,h),null}finally{u(!1)}},[r,e,n,s]),d=k.useCallback(()=>{i(null),c(null),u(!1)},[]);return{data:o,loading:l,error:a,mutate:f,reset:d}}var Es={exports:{}},cr={};/**
|
|
29
29
|
* @license React
|
|
30
30
|
* react-jsx-runtime.production.min.js
|
|
31
31
|
*
|
|
@@ -41,11 +41,11 @@ ${s}
|
|
|
41
41
|
*
|
|
42
42
|
* This source code is licensed under the MIT license found in the
|
|
43
43
|
* LICENSE file in the root directory of this source tree.
|
|
44
|
-
*/var Ii;function ua(){return Ii||(Ii=1,process.env.NODE_ENV!=="production"&&function(){var r=k,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),a=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),h=Symbol.for("react.offscreen"),p=Symbol.iterator,m="@@iterator";function x(y){if(y===null||typeof y!="object")return null;var F=p&&y[p]||y[m];return typeof F=="function"?F:null}var
|
|
44
|
+
*/var Ii;function ua(){return Ii||(Ii=1,process.env.NODE_ENV!=="production"&&function(){var r=k,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),o=Symbol.for("react.profiler"),i=Symbol.for("react.provider"),l=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),a=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),f=Symbol.for("react.memo"),d=Symbol.for("react.lazy"),h=Symbol.for("react.offscreen"),p=Symbol.iterator,m="@@iterator";function x(y){if(y===null||typeof y!="object")return null;var F=p&&y[p]||y[m];return typeof F=="function"?F:null}var C=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function _(y){{for(var F=arguments.length,z=new Array(F>1?F-1:0),V=1;V<F;V++)z[V-1]=arguments[V];E("error",y,z)}}function E(y,F,z){{var V=C.ReactDebugCurrentFrame,X=V.getStackAddendum();X!==""&&(F+="%s",z=z.concat([X]));var te=z.map(function(J){return String(J)});te.unshift("Warning: "+F),Function.prototype.apply.call(console[y],console,te)}}var D=!1,A=!1,v=!1,b=!1,w=!1,S;S=Symbol.for("react.module.reference");function R(y){return!!(typeof y=="string"||typeof y=="function"||y===n||y===o||w||y===s||y===a||y===c||b||y===h||D||A||v||typeof y=="object"&&y!==null&&(y.$$typeof===d||y.$$typeof===f||y.$$typeof===i||y.$$typeof===l||y.$$typeof===u||y.$$typeof===S||y.getModuleId!==void 0))}function T(y,F,z){var V=y.displayName;if(V)return V;var X=F.displayName||F.name||"";return X!==""?z+"("+X+")":z}function N(y){return y.displayName||"Context"}function j(y){if(y==null)return null;if(typeof y.tag=="number"&&_("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof y=="function")return y.displayName||y.name||null;if(typeof y=="string")return y;switch(y){case n:return"Fragment";case t:return"Portal";case o:return"Profiler";case s:return"StrictMode";case a:return"Suspense";case c:return"SuspenseList"}if(typeof y=="object")switch(y.$$typeof){case l:var F=y;return N(F)+".Consumer";case i:var z=y;return N(z._context)+".Provider";case u:return T(y,y.render,"ForwardRef");case f:var V=y.displayName||null;return V!==null?V:j(y.type)||"Memo";case d:{var X=y,te=X._payload,J=X._init;try{return j(J(te))}catch{return null}}}return null}var L=Object.assign,$=0,H,ue,re,we,Ee,Ge,He;function Me(){}Me.__reactDisabledLog=!0;function Je(){{if($===0){H=console.log,ue=console.info,re=console.warn,we=console.error,Ee=console.group,Ge=console.groupCollapsed,He=console.groupEnd;var y={configurable:!0,enumerable:!0,value:Me,writable:!0};Object.defineProperties(console,{info:y,log:y,warn:y,error:y,group:y,groupCollapsed:y,groupEnd:y})}$++}}function Re(){{if($--,$===0){var y={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:L({},y,{value:H}),info:L({},y,{value:ue}),warn:L({},y,{value:re}),error:L({},y,{value:we}),group:L({},y,{value:Ee}),groupCollapsed:L({},y,{value:Ge}),groupEnd:L({},y,{value:He})})}$<0&&_("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ae=C.ReactCurrentDispatcher,Le;function he(y,F,z){{if(Le===void 0)try{throw Error()}catch(X){var V=X.stack.trim().match(/\n( *(at )?)/);Le=V&&V[1]||""}return`
|
|
45
45
|
`+Le+y}}var ee=!1,Be;{var W=typeof WeakMap=="function"?WeakMap:Map;Be=new W}function xe(y,F){if(!y||ee)return"";{var z=Be.get(y);if(z!==void 0)return z}var V;ee=!0;var X=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var te;te=ae.current,ae.current=null,Je();try{if(F){var J=function(){throw Error()};if(Object.defineProperty(J.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(J,[])}catch(Ae){V=Ae}Reflect.construct(y,[],J)}else{try{J.call()}catch(Ae){V=Ae}y.call(J.prototype)}}else{try{throw Error()}catch(Ae){V=Ae}y()}}catch(Ae){if(Ae&&V&&typeof Ae.stack=="string"){for(var G=Ae.stack.split(`
|
|
46
46
|
`),be=V.stack.split(`
|
|
47
47
|
`),le=G.length-1,ce=be.length-1;le>=1&&ce>=0&&G[le]!==be[ce];)ce--;for(;le>=1&&ce>=0;le--,ce--)if(G[le]!==be[ce]){if(le!==1||ce!==1)do if(le--,ce--,ce<0||G[le]!==be[ce]){var Pe=`
|
|
48
|
-
`+G[le].replace(" at new "," at ");return y.displayName&&Pe.includes("<anonymous>")&&(Pe=Pe.replace("<anonymous>",y.displayName)),typeof y=="function"&&Be.set(y,Pe),Pe}while(le>=1&&ce>=0);break}}}finally{ee=!1,ae.current=te,Re(),Error.prepareStackTrace=X}var Ut=y?y.displayName||y.name:"",Et=Ut?he(Ut):"";return typeof y=="function"&&Be.set(y,Et),Et}function $e(y,F,z){return xe(y,!1)}function wt(y){var F=y.prototype;return!!(F&&F.isReactComponent)}function ht(y,F,z){if(y==null)return"";if(typeof y=="function")return xe(y,wt(y));if(typeof y=="string")return he(y);switch(y){case a:return he("Suspense");case c:return he("SuspenseList")}if(typeof y=="object")switch(y.$$typeof){case u:return $e(y.render);case f:return ht(y.type,F,z);case d:{var V=y,X=V._payload,te=V._init;try{return ht(te(X),F,z)}catch{}}}return""}var it=Object.prototype.hasOwnProperty,It={},Qr=
|
|
48
|
+
`+G[le].replace(" at new "," at ");return y.displayName&&Pe.includes("<anonymous>")&&(Pe=Pe.replace("<anonymous>",y.displayName)),typeof y=="function"&&Be.set(y,Pe),Pe}while(le>=1&&ce>=0);break}}}finally{ee=!1,ae.current=te,Re(),Error.prepareStackTrace=X}var Ut=y?y.displayName||y.name:"",Et=Ut?he(Ut):"";return typeof y=="function"&&Be.set(y,Et),Et}function $e(y,F,z){return xe(y,!1)}function wt(y){var F=y.prototype;return!!(F&&F.isReactComponent)}function ht(y,F,z){if(y==null)return"";if(typeof y=="function")return xe(y,wt(y));if(typeof y=="string")return he(y);switch(y){case a:return he("Suspense");case c:return he("SuspenseList")}if(typeof y=="object")switch(y.$$typeof){case u:return $e(y.render);case f:return ht(y.type,F,z);case d:{var V=y,X=V._payload,te=V._init;try{return ht(te(X),F,z)}catch{}}}return""}var it=Object.prototype.hasOwnProperty,It={},Qr=C.ReactDebugCurrentFrame;function zt(y){if(y){var F=y._owner,z=ht(y.type,y._source,F?F.type:null);Qr.setExtraStackFrame(z)}else Qr.setExtraStackFrame(null)}function Zn(y,F,z,V,X){{var te=Function.call.bind(it);for(var J in y)if(te(y,J)){var G=void 0;try{if(typeof y[J]!="function"){var be=Error((V||"React class")+": "+z+" type `"+J+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof y[J]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw be.name="Invariant Violation",be}G=y[J](F,J,V,z,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(le){G=le}G&&!(G instanceof Error)&&(zt(X),_("%s: type specification of %s `%s` is invalid; the type checker function must return `null` or an `Error` but returned a %s. You may have forgotten to pass an argument to the type checker creator (arrayOf, instanceOf, objectOf, oneOf, oneOfType, and shape all require an argument).",V||"React class",z,J,typeof G),zt(null)),G instanceof Error&&!(G.message in It)&&(It[G.message]=!0,zt(X),_("Failed %s type: %s",z,G.message),zt(null))}}}var es=Array.isArray;function lr(y){return es(y)}function ts(y){{var F=typeof Symbol=="function"&&Symbol.toStringTag,z=F&&y[Symbol.toStringTag]||y.constructor.name||"Object";return z}}function rs(y){try{return Yr(y),!1}catch{return!0}}function Yr(y){return""+y}function Xr(y){if(rs(y))return _("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",ts(y)),Yr(y)}var Zr=C.ReactCurrentOwner,ns={key:!0,ref:!0,__self:!0,__source:!0},en,U;function K(y){if(it.call(y,"ref")){var F=Object.getOwnPropertyDescriptor(y,"ref").get;if(F&&F.isReactWarning)return!1}return y.ref!==void 0}function oe(y){if(it.call(y,"key")){var F=Object.getOwnPropertyDescriptor(y,"key").get;if(F&&F.isReactWarning)return!1}return y.key!==void 0}function Ie(y,F){typeof y.ref=="string"&&Zr.current}function je(y,F){{var z=function(){en||(en=!0,_("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",F))};z.isReactWarning=!0,Object.defineProperty(y,"key",{get:z,configurable:!0})}}function ot(y,F){{var z=function(){U||(U=!0,_("%s: `ref` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://reactjs.org/link/special-props)",F))};z.isReactWarning=!0,Object.defineProperty(y,"ref",{get:z,configurable:!0})}}var ss=function(y,F,z,V,X,te,J){var G={$$typeof:e,type:y,key:F,ref:z,props:J,_owner:te};return G._store={},Object.defineProperty(G._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(G,"_self",{configurable:!1,enumerable:!1,writable:!1,value:V}),Object.defineProperty(G,"_source",{configurable:!1,enumerable:!1,writable:!1,value:X}),Object.freeze&&(Object.freeze(G.props),Object.freeze(G)),G};function tn(y,F,z,V,X){{var te,J={},G=null,be=null;z!==void 0&&(Xr(z),G=""+z),oe(F)&&(Xr(F.key),G=""+F.key),K(F)&&(be=F.ref,Ie(F,X));for(te in F)it.call(F,te)&&!ns.hasOwnProperty(te)&&(J[te]=F[te]);if(y&&y.defaultProps){var le=y.defaultProps;for(te in le)J[te]===void 0&&(J[te]=le[te])}if(G||be){var ce=typeof y=="function"?y.displayName||y.name||"Unknown":y;G&&je(J,ce),be&&ot(J,ce)}return ss(y,G,be,X,V,Zr.current,J)}}var ur=C.ReactCurrentOwner,wi=C.ReactDebugCurrentFrame;function qt(y){if(y){var F=y._owner,z=ht(y.type,y._source,F?F.type:null);wi.setExtraStackFrame(z)}else wi.setExtraStackFrame(null)}var is;is=!1;function os(y){return typeof y=="object"&&y!==null&&y.$$typeof===e}function Ei(){{if(ur.current){var y=j(ur.current.type);if(y)return`
|
|
49
49
|
|
|
50
50
|
Check the render method of \``+y+"`."}return""}}function Au(y){return""}var Ai={};function ku(y){{var F=Ei();if(!F){var z=typeof y=="string"?y:y.displayName||y.name;z&&(F=`
|
|
51
51
|
|
|
@@ -54,27 +54,27 @@ Check the top-level render call using <`+z+">.")}return F}}function ki(y,F){{if(
|
|
|
54
54
|
<%s {...props} />
|
|
55
55
|
React keys must be passed directly to JSX without using spread:
|
|
56
56
|
let props = %s;
|
|
57
|
-
<%s key={someKey} {...props} />`,ls,Et,ju,Et),Ti[Et+ls]=!0}}return y===n?Tu(ce):Su(ce),ce}}function Bu(y,F,z){return Bi(y,F,z,!0)}function Nu(y,F,z){return Bi(y,F,z,!1)}var Fu=Nu,Lu=Bu;dr.Fragment=n,dr.jsx=Fu,dr.jsxs=Lu}()),dr}process.env.NODE_ENV==="production"?Es.exports=la():Es.exports=ua();var g=Es.exports;class fn{static filter(e,t){return e.filter(t)}static filterBy(e,t,n){return e.filter(s=>s[t]===n)}static filterByFields(e,t){return e.filter(n=>Object.entries(t).every(([s,o])=>n[s]===o))}static sort(e,t,n="asc"){return[...e].sort((s,o)=>{const i=s[t],l=o[t];if(i===l)return 0;let u=0;return i>l&&(u=1),i<l&&(u=-1),n==="asc"?u:-u})}static search(e,t,n){if(!t.trim())return e;const s=t.toLowerCase();return e.filter(o=>n.some(i=>{const l=o[i];return l==null?!1:String(l).toLowerCase().includes(s)}))}static paginate(e,t,n){const s=(t-1)*n,o=s+n;return{data:e.slice(s,o),total:e.length,page:t,totalPages:Math.ceil(e.length/n)}}static groupBy(e,t){return e.reduce((n,s)=>{const o=String(s[t]);return n[o]||(n[o]=[]),n[o].push(s),n},{})}static unique(e,t){const n=e.map(s=>s[t]);return[...new Set(n)]}static countBy(e,t){return e.reduce((n,s)=>{const o=String(s[t]);return n[o]=(n[o]||0)+1,n},{})}static pipe(e,t){return t.reduce((n,s)=>s(n),e)}}function aa({endpoint:r,params:e,layout:t="list",title:n,emptyMessage:s="No items found",renderItem:o,keyExtractor:i=(m,x)=>m.id||m._id||String(x),searchable:l=!1,searchFields:u=[],searchPlaceholder:a="Search...",filters:c=[],pageSize:f=20,onItemClick:d,onRefresh:h,theme:p={}}){const{data:m,loading:x,error:
|
|
57
|
+
<%s key={someKey} {...props} />`,ls,Et,ju,Et),Ti[Et+ls]=!0}}return y===n?Tu(ce):Su(ce),ce}}function Bu(y,F,z){return Bi(y,F,z,!0)}function Nu(y,F,z){return Bi(y,F,z,!1)}var Fu=Nu,Lu=Bu;dr.Fragment=n,dr.jsx=Fu,dr.jsxs=Lu}()),dr}process.env.NODE_ENV==="production"?Es.exports=la():Es.exports=ua();var g=Es.exports;class fn{static filter(e,t){return e.filter(t)}static filterBy(e,t,n){return e.filter(s=>s[t]===n)}static filterByFields(e,t){return e.filter(n=>Object.entries(t).every(([s,o])=>n[s]===o))}static sort(e,t,n="asc"){return[...e].sort((s,o)=>{const i=s[t],l=o[t];if(i===l)return 0;let u=0;return i>l&&(u=1),i<l&&(u=-1),n==="asc"?u:-u})}static search(e,t,n){if(!t.trim())return e;const s=t.toLowerCase();return e.filter(o=>n.some(i=>{const l=o[i];return l==null?!1:String(l).toLowerCase().includes(s)}))}static paginate(e,t,n){const s=(t-1)*n,o=s+n;return{data:e.slice(s,o),total:e.length,page:t,totalPages:Math.ceil(e.length/n)}}static groupBy(e,t){return e.reduce((n,s)=>{const o=String(s[t]);return n[o]||(n[o]=[]),n[o].push(s),n},{})}static unique(e,t){const n=e.map(s=>s[t]);return[...new Set(n)]}static countBy(e,t){return e.reduce((n,s)=>{const o=String(s[t]);return n[o]=(n[o]||0)+1,n},{})}static pipe(e,t){return t.reduce((n,s)=>s(n),e)}}function aa({endpoint:r,params:e,layout:t="list",title:n,emptyMessage:s="No items found",renderItem:o,keyExtractor:i=(m,x)=>m.id||m._id||String(x),searchable:l=!1,searchFields:u=[],searchPlaceholder:a="Search...",filters:c=[],pageSize:f=20,onItemClick:d,onRefresh:h,theme:p={}}){const{data:m,loading:x,error:C,refetch:_}=sl(r,e),[E,D]=k.useState(""),[A,v]=k.useState({}),[b,w]=k.useState(1),S=k.useMemo(()=>{if(!m)return{data:[],total:0,totalPages:0};let L=m;return l&&E&&u.length>0&&(L=fn.search(L,E,u)),Object.keys(A).length>0&&(L=fn.filterByFields(L,A)),fn.paginate(L,b,f)},[m,E,A,b,f,l,u]);k.useEffect(()=>{w(1)},[E,A]);const R=()=>{D(""),v({}),w(1),_(),h==null||h()},T={background:p.background||"#ffffff",cardBackground:p.cardBackground||"#f9fafb",text:p.text||"#111827",textSecondary:p.textSecondary||"#6b7280",border:p.border||"#e5e7eb",primary:p.primary||"#3b82f6"},j=o||(L=>g.jsxs("div",{style:{padding:"16px",cursor:d?"pointer":"default"},children:[g.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:T.text},children:L.title||L.name||L.label||"Untitled"}),L.description&&g.jsx("div",{style:{fontSize:"13px",color:T.textSecondary,marginTop:"4px"},children:L.description})]}));return x&&!m?g.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px",color:T.textSecondary},children:"Loading..."}):C?g.jsxs("div",{style:{padding:"24px",textAlign:"center",color:"#ef4444"},children:[g.jsx("div",{style:{fontWeight:500,marginBottom:"8px"},children:"Error"}),g.jsx("div",{style:{fontSize:"14px"},children:C.message}),g.jsx("button",{onClick:R,style:{marginTop:"16px",padding:"8px 16px",background:T.primary,color:"white",border:"none",borderRadius:"6px",cursor:"pointer"},children:"Retry"})]}):g.jsxs("div",{style:{background:T.background,borderRadius:"12px",overflow:"hidden"},children:[(n||l||c.length>0)&&g.jsxs("div",{style:{padding:"16px",borderBottom:`1px solid ${T.border}`},children:[g.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:l||c.length>0?"12px":"0"},children:[n&&g.jsx("h2",{style:{margin:0,fontSize:"18px",fontWeight:600,color:T.text},children:n}),g.jsx("button",{onClick:R,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${T.border}`,borderRadius:"6px",color:T.textSecondary,cursor:"pointer",fontSize:"13px"},children:"Refresh"})]}),l&&g.jsx("input",{type:"text",placeholder:a,value:E,onChange:L=>D(L.target.value),style:{width:"100%",padding:"8px 12px",border:`1px solid ${T.border}`,borderRadius:"8px",fontSize:"14px",outline:"none"}})]}),g.jsx("div",{style:{display:t==="grid"?"grid":"flex",flexDirection:t==="list"?"column":void 0,gridTemplateColumns:t==="grid"?"repeat(auto-fill, minmax(250px, 1fr))":void 0,gap:t==="list"?"0":"16px",padding:t==="list"?"0":"16px"},children:S.data.length===0?g.jsx("div",{style:{padding:"48px",textAlign:"center",color:T.textSecondary},children:s}):S.data.map((L,$)=>g.jsx("div",{onClick:()=>d==null?void 0:d(L),style:{background:T.cardBackground,borderRadius:t==="list"?"0":"8px",borderBottom:t==="list"?`1px solid ${T.border}`:"none",transition:"all 0.15s ease"},onMouseEnter:H=>{d&&(H.currentTarget.style.background=T.border)},onMouseLeave:H=>{H.currentTarget.style.background=T.cardBackground},children:j(L,$)},i(L,$)))}),S.totalPages>1&&g.jsxs("div",{style:{padding:"16px",borderTop:`1px solid ${T.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[g.jsxs("div",{style:{fontSize:"13px",color:T.textSecondary},children:["Page ",b," of ",S.totalPages]}),g.jsxs("div",{style:{display:"flex",gap:"8px"},children:[g.jsx("button",{onClick:()=>w(L=>Math.max(1,L-1)),disabled:b===1,style:{padding:"6px 12px",border:`1px solid ${T.border}`,borderRadius:"6px",background:"white",cursor:b===1?"not-allowed":"pointer",opacity:b===1?.5:1},children:"Previous"}),g.jsx("button",{onClick:()=>w(L=>Math.min(S.totalPages,L+1)),disabled:b===S.totalPages,style:{padding:"6px 12px",border:`1px solid ${T.border}`,borderRadius:"6px",background:"white",cursor:b===S.totalPages?"not-allowed":"pointer",opacity:b===S.totalPages?.5:1},children:"Next"})]})]})]})}function ca({item:r,onClick:e,title:t=i=>i.title||i.name||i.label||"Untitled",subtitle:n=i=>i.description||i.subtitle||"",image:s=i=>i.image||i.thumbnail||i.photo,badge:o=i=>i.badge||i.tag||i.type}){const i=t(r),l=n(r),u=s(r),a=o(r);return g.jsxs("div",{onClick:e,className:`
|
|
58
58
|
flex items-center gap-4 p-4 border-b border-gray-200
|
|
59
59
|
hover:bg-gray-50 transition-colors
|
|
60
60
|
${e?"cursor-pointer":""}
|
|
61
|
-
`,children:[u&&g.jsx("div",{className:"flex-shrink-0",children:g.jsx("img",{src:u,alt:i,className:"w-16 h-16 object-cover rounded-lg"})}),g.jsxs("div",{className:"flex-1 min-w-0",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("h3",{className:"font-medium text-gray-900 truncate",children:i}),a&&g.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-blue-100 text-blue-800 rounded-full",children:a})]}),l&&g.jsx("p",{className:"text-sm text-gray-600 truncate mt-0.5",children:l})]}),e&&g.jsx("div",{className:"flex-shrink-0 text-gray-400",children:g.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:g.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})}function da({item:r,onClose:e,title:t=o=>o.title||o.name||o.label||"Detail",image:n=o=>o.image||o.thumbnail||o.photo,fields:s=[]}){if(!r)return null;const o=t(r),i=n(r);return g.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:g.jsxs("div",{className:"bg-white rounded-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto shadow-2xl",children:[g.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between",children:[g.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:o}),e&&g.jsx("button",{onClick:e,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:g.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:g.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),g.jsxs("div",{className:"p-6",children:[i&&g.jsx("div",{className:"mb-6",children:g.jsx("img",{src:i,alt:o,className:"w-full h-64 object-cover rounded-lg"})}),s.length>0&&g.jsx("div",{className:"space-y-4",children:s.map((l,u)=>{const a=l.value(r);return a==null||a===""?null:g.jsxs("div",{children:[g.jsx("div",{className:"text-sm font-medium text-gray-500 mb-1",children:l.label}),g.jsx("div",{className:"text-base text-gray-900",children:typeof a=="object"?JSON.stringify(a,null,2):String(a)})]},u)})}),s.length===0&&g.jsx("pre",{className:"bg-gray-50 p-4 rounded-lg text-sm overflow-x-auto",children:JSON.stringify(r,null,2)})]}),e&&g.jsx("div",{className:"sticky bottom-0 bg-gray-50 border-t border-gray-200 px-6 py-4",children:g.jsx("button",{onClick:e,className:"w-full px-4 py-2 bg-gray-900 text-white rounded-lg hover:bg-gray-800 transition-colors font-medium",children:"Close"})})]})})}const fa={small:"w-32 h-32",medium:"w-48 h-48",large:"w-64 h-64"};function ha({nodes:r,cardCount:e=2,minInterval:t=1e3,maxInterval:n=3e3,onCardClick:s,cardSize:o="medium",className:i=""}){const l=Math.min(Math.max(e,1),5),[u,a]=k.useState([]),[c,f]=k.useState([]),[d,h]=k.useState(Array(l).fill(!1)),[p,m]=k.useState(Array(l).fill(!1)),x=k.useRef([]),D=k.useCallback(v=>{const b=r.filter(S=>!v.includes(S._id));if(b.length===0)return null;const w=Math.floor(Math.random()*b.length);return b[w]},[r]),_=k.useCallback(()=>Math.random()*(n-t)+t,[t,n]);k.useEffect(()=>{if(r.length===0){a([]),f([]);return}const v=[],b=[],w=[];for(let S=0;S<l&&S<r.length;S++){const R=D(w);R&&(v.push(R),w.push(R._id))}for(let S=0;S<v.length;S++){const R=[v[S]._id,...v.filter((N,j)=>j!==S).map(N=>N._id)],T=D(R);T?b.push(T):b.push(v[S])}a(v),f(b)},[r,l,D]);const E=k.useCallback(v=>{const b=_(),w=setTimeout(()=>{h(S=>{const R=[...S];return R[v]=!R[v],R}),setTimeout(()=>{m(S=>{const R=[...S];return R[v]=!R[v],R}),setTimeout(()=>{const S=!p[v];S&&a(R=>{const T=[...R];return T[v]=c[v],T}),f(R=>{const T=[...R],j=[(S?c[v]:u[v])._id,...u.filter(($,H)=>H!==v).map($=>$._id),...R.filter(($,H)=>H!==v).map($=>$._id)],L=D(j);return L&&(T[v]=L),T}),setTimeout(()=>{E(v)},150)},200)},150)},b);x.current[v]=w},[_,D,u,c,p]),C=k.useRef(!1);k.useEffect(()=>{if(!(u.length===0||r.length<=1)&&!C.current){C.current=!0;for(let v=0;v<u.length;v++)E(v);return()=>{x.current.forEach(v=>clearTimeout(v)),x.current=[],C.current=!1}}},[u.length,r.length]);const A=v=>{s&&s(v)};return r.length===0?g.jsx("div",{className:`flex items-center justify-center p-8 ${i}`,children:g.jsx("p",{className:"text-gray-500",children:"No nodes available"})}):u.length===0?g.jsx("div",{className:`flex items-center justify-center p-8 ${i}`,children:g.jsx("p",{className:"text-gray-500",children:"Loading..."})}):g.jsx("div",{className:`flex gap-4 justify-center items-center flex-wrap ${i}`,children:u.map((v,b)=>{const w=c[b],S=p[b];return g.jsx("div",{className:`relative ${fa[o]}`,style:{perspective:"1000px"},onClick:()=>A(S?w:v),children:g.jsxs("div",{className:"w-full h-full rounded-lg shadow-lg overflow-hidden cursor-pointer hover:shadow-xl",style:{transform:`rotateY(${d[b]?180:0}deg)`,transition:"transform 0.5s",transformStyle:"preserve-3d"},children:[g.jsx("div",{className:"absolute inset-0 transition-opacity duration-200",style:{opacity:S?0:1},children:g.jsxs("div",{style:{transform:d[b]?"scaleX(-1)":"scaleX(1)",width:"100%",height:"100%"},children:[g.jsx("img",{src:v.data.image,alt:v.title,className:"w-full h-full object-cover"}),g.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:g.jsx("p",{className:"text-white text-sm font-medium truncate",children:v.title})})]})}),w&&g.jsx("div",{className:"absolute inset-0 transition-opacity duration-200",style:{opacity:S?1:0},children:g.jsxs("div",{style:{transform:d[b]?"scaleX(-1)":"scaleX(1)",width:"100%",height:"100%"},children:[g.jsx("img",{src:w.data.image,alt:w.title,className:"w-full h-full object-cover"}),g.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:g.jsx("p",{className:"text-white text-sm font-medium truncate",children:w.title})})]})})]})},`slot-${b}`)})})}function Wt(r){if(!r)return"";const e=/=\?([^?]+)\?([BQbq])\?([^?]*)\?=/g;return r.replace(e,(t,n,s,o)=>{try{if(s.toUpperCase()==="B"){const i=atob(o);return decodeURIComponent(escape(i))}else if(s.toUpperCase()==="Q"){const i=o.replace(/_/g," ").replace(/=([0-9A-Fa-f]{2})/g,(l,u)=>String.fromCharCode(parseInt(u,16)));return decodeURIComponent(escape(i))}}catch(i){console.warn("MIME decode error:",i)}return t}).replace(/\s+/g," ").trim()}const pa={background:"#ffffff",cardBackground:"#ffffff",selectedBackground:"#f5f5f5",unreadBackground:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",danger:"#ef4444"};function ga({baseUrl:r,systemId:e,accountId:t,limit:n=30,folder:s,selectable:o=!0,showDetail:i=!1,showSearch:l=!0,searchQuery:u,onSearchChange:a,emptyMessage:c="No emails",autoLoad:f=!0,onSelect:d,onSelectionChange:h,onDelete:p,onError:m,onLoad:x,renderItem:D,renderDetail:_,renderActions:E,renderEmpty:C,renderLoading:A,theme:v={}}){const b={...pa,...v},[w,S]=k.useState([]),[R,T]=k.useState(!1),[N,j]=k.useState(null),[L,$]=k.useState(new Set),[H,ue]=k.useState(null),[re,we]=k.useState(null),[Ee,Ge]=k.useState(null),[He,Me]=k.useState(!1),[Je,Re]=k.useState(""),ae=u!==void 0?u:Je,Le=U=>{a?a(U):Re(U)},he=k.useMemo(()=>{if(!ae.trim())return w;const U=ae.toLowerCase();return w.filter(K=>Wt(K.from).toLowerCase().includes(U)||Wt(K.subject).toLowerCase().includes(U))},[w,ae]),ee=k.useMemo(()=>e?new tl({baseUrl:r,system_id:e}):null,[r,e]),Be=k.useCallback(async()=>{if(ee){T(!0),j(null);try{const U=await ee.listEmails(t,n,s);U!=null&&U.messages&&(S(U.messages),x==null||x(U.messages))}catch(U){const K=U instanceof Error?U:new Error("Failed to fetch emails");j(K.message),m==null||m(K)}T(!1)}},[ee,t,n,s,m,x]);k.useEffect(()=>{S([]),$(new Set),we(null),j(null),u===void 0&&Re(""),f&&Be()},[s,f]);const W=k.useCallback(async U=>{if(ee){we(U),Ge(null),Me(!0);try{const K=await ee.getEmailParsed(t,U.uid,s||"INBOX");K!=null&&K.body&&Ge(K.body)}catch(K){console.error("Failed to fetch email body:",K)}Me(!1)}},[ee,t,s]),xe=k.useCallback(U=>{d==null||d(U),i&&W(U)},[d,i,W]),$e=k.useCallback((U,K,oe)=>{if(!o){d==null||d(U),i&&W(U);return}const Ie=U.uid;if(oe.shiftKey&&H!==null){const je=Math.min(H,K),ot=Math.max(H,K),ss=w.slice(je,ot+1).map(ur=>ur.uid),tn=new Set(ss);$(tn),h==null||h(Array.from(tn))}else if(oe.ctrlKey||oe.metaKey)$(je=>{const ot=new Set(je);return ot.has(Ie)?ot.delete(Ie):ot.add(Ie),h==null||h(Array.from(ot)),ot}),ue(K);else{const je=new Set([Ie]);$(je),ue(K),h==null||h(Array.from(je))}},[o,H,w,L,d,h,i]),wt=k.useCallback(async()=>{if(!ee||L.size===0)return;const U=s||"INBOX";try{const K=await ee.trashEmails(t,Array.from(L),U);if(console.log("Trash result:",K),K.success&&K.moved>0){S(Ie=>Ie.filter(je=>!L.has(je.uid)));const oe=Array.from(L);$(new Set),p==null||p(oe)}else j("Failed to move emails to trash")}catch(K){const oe=K instanceof Error?K:new Error("Trash failed");console.error("Trash error:",oe),j(oe.message),m==null||m(oe)}},[ee,t,L,s,p,m]),ht=k.useCallback(async()=>{if(!ee||L.size===0)return;const U=s||"INBOX";try{const K=await ee.archiveEmails(t,Array.from(L),U);if(console.log("Archive result:",K),K.success&&K.archived>0){S(Ie=>Ie.filter(je=>!L.has(je.uid)));const oe=Array.from(L);$(new Set),p==null||p(oe)}else j("Failed to archive emails")}catch(K){const oe=K instanceof Error?K:new Error("Archive failed");console.error("Archive error:",oe),j(oe.message),m==null||m(oe)}},[ee,t,L,s,p,m]),it=k.useCallback(()=>{if(L.size===w.length)$(new Set),h==null||h([]);else{const U=new Set(w.map(K=>K.uid));$(U),h==null||h(Array.from(U))}},[w,L.size,h]),It=k.useCallback(()=>{$(new Set),h==null||h([])},[h]),Qr={delete:wt,archive:ht,refresh:Be,selectAll:it,clearSelection:It},zt=U=>{if(!U)return"";const K=new Date(U),oe=new Date;return K.toDateString()===oe.toDateString()?K.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):K.toLocaleDateString([],{month:"short",day:"numeric"})},Zn=(U,K)=>g.jsx("div",{style:{padding:"12px 16px",background:K?b.selectedBackground:U.seen?b.cardBackground:b.unreadBackground,borderBottom:`1px solid ${b.border}`,cursor:"pointer",transition:"background 0.15s ease"},children:g.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"12px"},children:[g.jsxs("div",{style:{flex:1,minWidth:0},children:[g.jsx("div",{style:{fontSize:"14px",fontWeight:U.seen?400:600,color:b.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Wt(U.from).split("@")[0]}),g.jsx("div",{style:{fontSize:"14px",fontWeight:U.seen?400:500,color:U.seen?b.textSecondary:b.text,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Wt(U.subject)||"(No subject)"})]}),g.jsx("div",{style:{fontSize:"12px",color:b.textSecondary,flexShrink:0},children:zt(U.date)})]})}),es=U=>g.jsxs("div",{style:{padding:"24px"},children:[g.jsx("h2",{style:{margin:"0 0 8px",fontSize:"20px",color:b.text},children:Wt(U.subject)||"(No subject)"}),g.jsxs("div",{style:{fontSize:"14px",color:b.textSecondary,marginBottom:"16px"},children:["From: ",Wt(U.from)," • ",new Date(U.date).toLocaleString()]}),He?g.jsx("div",{style:{fontSize:"14px",color:b.textSecondary},children:"Loading..."}):Ee?g.jsx("div",{style:{fontSize:"14px",color:b.text},dangerouslySetInnerHTML:{__html:Ee}}):g.jsx("div",{style:{fontSize:"14px",color:b.textSecondary},children:"No content available"})]}),lr=(U,K)=>g.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",background:b.cardBackground,borderBottom:`1px solid ${b.border}`},children:[g.jsx("button",{onClick:K.selectAll,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${b.border}`,borderRadius:"6px",fontSize:"13px",cursor:"pointer",color:b.text},children:U.length===w.length?"Deselect All":"Select All"}),U.length>0&&g.jsxs(g.Fragment,{children:[g.jsxs("span",{style:{fontSize:"13px",color:b.textSecondary},children:[U.length," selected"]}),g.jsx("button",{onClick:K.archive,title:"Archive",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${b.border}`,borderRadius:"6px",cursor:"pointer",color:b.textSecondary},children:g.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"archive"})}),g.jsx("button",{onClick:K.delete,title:"Delete",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${b.border}`,borderRadius:"6px",cursor:"pointer",color:b.textSecondary},children:g.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"delete"})})]}),g.jsx("div",{style:{flex:1}}),g.jsx("button",{onClick:K.refresh,title:"Refresh",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${b.border}`,borderRadius:"6px",cursor:"pointer",color:b.textSecondary},children:g.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"refresh"})})]}),ts=()=>g.jsx("div",{style:{padding:"48px",textAlign:"center",color:b.textSecondary},children:c}),rs=()=>g.jsx("div",{style:{padding:"48px",textAlign:"center",color:b.textSecondary},children:"Loading..."}),Yr=D||Zn,Xr=_||es,Zr=E||lr,ns=C||ts,en=A||rs;return R&&w.length===0?g.jsx("div",{style:{background:b.background,width:"100%",height:"100%"},children:en()}):g.jsxs("div",{style:{display:"flex",background:b.background,width:"100%",height:"100%"},children:[g.jsxs("div",{style:{flex:i&&re?"0 0 50%":"1",display:"flex",flexDirection:"column",borderRight:i&&re?`1px solid ${b.border}`:"none",overflow:"hidden"},children:[o&&Zr(Array.from(L),Qr),l&&g.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${b.border}`,background:b.background},children:g.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 12px",background:"#f5f5f5",borderRadius:"6px"},children:[g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:b.textSecondary,strokeWidth:"2",children:[g.jsx("circle",{cx:"11",cy:"11",r:"8"}),g.jsx("path",{d:"M21 21l-4.35-4.35"})]}),g.jsx("input",{type:"text",placeholder:"Search by email or subject...",value:ae,onChange:U=>Le(U.target.value),style:{flex:1,border:"none",background:"transparent",outline:"none",fontSize:"13px",color:b.text}}),ae&&g.jsx("button",{onClick:()=>Le(""),style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",justifyContent:"center"},children:g.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:b.textSecondary,strokeWidth:"2",children:g.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]})}),N&&g.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",color:b.danger,fontSize:"14px",borderBottom:`1px solid ${b.border}`},children:N}),g.jsx("div",{style:{flex:1,overflowY:"auto"},children:he.length===0?ns():he.map((U,K)=>g.jsx("div",{onClick:oe=>$e(U,K,oe),onDoubleClick:()=>xe(U),children:Yr(U,L.has(U.uid))},U.uid))})]}),i&&re&&g.jsx("div",{style:{flex:1,overflowY:"auto"},children:Xr(re)})]})}function ma({items:r,renderItem:e,onSelectionChange:t,onCurrentChange:n,onAction:s,actions:o=[],emptyMessage:i="No items",showSelectAll:l=!0,className:u=""}){const[a,c]=k.useState(new Set),[f,d]=k.useState(-1),h=r.filter(C=>a.has(C.id)),p=f>=0&&f<h.length?h[f]:null,m=k.useCallback(C=>{c(A=>{const v=new Set(A);return v.has(C)?v.delete(C):v.add(C),t==null||t(Array.from(v)),v})},[t]),x=k.useCallback(()=>{if(a.size===r.length)c(new Set),d(-1),t==null||t([]);else{const C=new Set(r.map(A=>A.id));c(C),r.length>0&&(d(0),n==null||n(r[0],0)),t==null||t(r.map(A=>A.id))}},[r,a.size,t,n]),D=k.useCallback(()=>{if(h.length===0)return;const C=f<=0?h.length-1:f-1;d(C),n==null||n(h[C],C)},[h,f,n]),_=k.useCallback(()=>{if(h.length===0)return;const C=f>=h.length-1?0:f+1;d(C),n==null||n(h[C],C)},[h,f,n]),E=k.useCallback(C=>{s==null||s(C,h,p)},[s,h,p]);return k.useEffect(()=>{h.length===0?d(-1):f>=h.length?d(h.length-1):f<0&&h.length>0&&(d(0),n==null||n(h[0],0))},[h.length,f,n]),r.length===0?g.jsx("div",{className:`text-sm text-neutral-400 text-center py-4 ${u}`,children:i}):g.jsxs("div",{className:`space-y-2 ${u}`,children:[g.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[l&&g.jsxs("button",{onClick:x,className:"flex items-center gap-1 hover:text-neutral-700 transition-colors",children:[g.jsx("span",{className:"material-icons text-sm",children:a.size===r.length?"check_box":a.size>0?"indeterminate_check_box":"check_box_outline_blank"}),g.jsx("span",{children:a.size===r.length?"Deselect all":"Select all"})]}),a.size>0&&g.jsxs("span",{className:"text-neutral-400",children:["(",a.size," selected)"]})]}),h.length>1&&g.jsxs("div",{className:"flex items-center gap-1",children:[g.jsx("button",{onClick:D,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Previous",children:g.jsx("span",{className:"material-icons text-sm",children:"chevron_left"})}),g.jsxs("span",{className:"text-xs min-w-[3rem] text-center",children:[f+1," / ",h.length]}),g.jsx("button",{onClick:_,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Next",children:g.jsx("span",{className:"material-icons text-sm",children:"chevron_right"})})]})]}),g.jsx("div",{className:"space-y-1",children:r.map(C=>{const A=a.has(C.id),v=(p==null?void 0:p.id)===C.id;return g.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg cursor-pointer transition-colors ${v?"bg-blue-50 ring-1 ring-blue-200":A?"bg-neutral-100":"hover:bg-neutral-50"}`,onClick:()=>m(C.id),children:[g.jsx("span",{className:`material-icons text-lg ${A?"text-blue-500":"text-neutral-300"}`,children:A?"check_box":"check_box_outline_blank"}),g.jsx("div",{className:"flex-1 min-w-0",children:e(C,A,v)})]},C.id)})}),o.length>0&&a.size>0&&g.jsx("div",{className:"flex items-center gap-2 pt-2 border-t border-neutral-100",children:o.map(C=>{var v;const A=((v=C.disabled)==null?void 0:v.call(C,h))??!1;return g.jsxs("button",{onClick:()=>E(C.id),disabled:A,className:`flex items-center gap-1 px-3 py-1.5 text-xs rounded-lg transition-colors ${A?"bg-neutral-100 text-neutral-400 cursor-not-allowed":"bg-neutral-100 hover:bg-neutral-200 text-neutral-700"}`,children:[C.icon&&g.jsx("span",{className:"material-icons text-sm",children:C.icon}),C.label]},C.id)})})]})}function ya(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var xa=ya(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const il=k.createContext(null);function _a(r,e){return{getTheme:function(){return e??null}}}function nt(){const r=k.useContext(il);return r==null&&xa(8),r}function Mr(r){return{}}const Js={},ba={},ol={},Tt={},Qt={},Br={},Yt={},Mn={},As={},Nr={},Fr={},We={},Qs={},Ys={},va={},ll={},Ca={},ul={},Da={},al={},cl={},yn={},wa={},dl={},fl={},hl={},Ea={},Aa={},ka={},zi={},pl={},Sa={},gl={},ml={},Ta={},Rn={},Xs={},ks={},Ba={},Na={},nn={},sn={},Fa={},La={},ja={},Ve=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Pa=Ve&&"documentMode"in document?document.documentMode:null,ze=Ve&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),bt=Ve&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),xn=!(!Ve||!("InputEvent"in window)||Pa)&&"getTargetRanges"in new window.InputEvent("input"),$n=Ve&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Rr=Ve&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Oa=Ve&&/Android/.test(navigator.userAgent),yl=Ve&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Ma=Ve&&Oa&&yl,Zs=Ve&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!yl,$r=1,Ct=3,Ft=0,xl=1,er=2,Ra=0,$a=1,Ia=2,_n=4,bn=8,ei=128,za=112|(3|_n|bn)|ei,ti=1,ri=2,ni=3,si=4,ii=5,oi=6,In=$n||Rr||Zs?" ":"",at=`
|
|
61
|
+
`,children:[u&&g.jsx("div",{className:"flex-shrink-0",children:g.jsx("img",{src:u,alt:i,className:"w-16 h-16 object-cover rounded-lg"})}),g.jsxs("div",{className:"flex-1 min-w-0",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[g.jsx("h3",{className:"font-medium text-gray-900 truncate",children:i}),a&&g.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-blue-100 text-blue-800 rounded-full",children:a})]}),l&&g.jsx("p",{className:"text-sm text-gray-600 truncate mt-0.5",children:l})]}),e&&g.jsx("div",{className:"flex-shrink-0 text-gray-400",children:g.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:g.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})}function da({item:r,onClose:e,title:t=o=>o.title||o.name||o.label||"Detail",image:n=o=>o.image||o.thumbnail||o.photo,fields:s=[]}){if(!r)return null;const o=t(r),i=n(r);return g.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:g.jsxs("div",{className:"bg-white rounded-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto shadow-2xl",children:[g.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between",children:[g.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:o}),e&&g.jsx("button",{onClick:e,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:g.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:g.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),g.jsxs("div",{className:"p-6",children:[i&&g.jsx("div",{className:"mb-6",children:g.jsx("img",{src:i,alt:o,className:"w-full h-64 object-cover rounded-lg"})}),s.length>0&&g.jsx("div",{className:"space-y-4",children:s.map((l,u)=>{const a=l.value(r);return a==null||a===""?null:g.jsxs("div",{children:[g.jsx("div",{className:"text-sm font-medium text-gray-500 mb-1",children:l.label}),g.jsx("div",{className:"text-base text-gray-900",children:typeof a=="object"?JSON.stringify(a,null,2):String(a)})]},u)})}),s.length===0&&g.jsx("pre",{className:"bg-gray-50 p-4 rounded-lg text-sm overflow-x-auto",children:JSON.stringify(r,null,2)})]}),e&&g.jsx("div",{className:"sticky bottom-0 bg-gray-50 border-t border-gray-200 px-6 py-4",children:g.jsx("button",{onClick:e,className:"w-full px-4 py-2 bg-gray-900 text-white rounded-lg hover:bg-gray-800 transition-colors font-medium",children:"Close"})})]})})}const fa={small:"w-32 h-32",medium:"w-48 h-48",large:"w-64 h-64"};function ha({nodes:r,cardCount:e=2,minInterval:t=1e3,maxInterval:n=3e3,onCardClick:s,cardSize:o="medium",className:i=""}){const l=Math.min(Math.max(e,1),5),[u,a]=k.useState([]),[c,f]=k.useState([]),[d,h]=k.useState(Array(l).fill(!1)),[p,m]=k.useState(Array(l).fill(!1)),x=k.useRef([]),C=k.useCallback(v=>{const b=r.filter(S=>!v.includes(S._id));if(b.length===0)return null;const w=Math.floor(Math.random()*b.length);return b[w]},[r]),_=k.useCallback(()=>Math.random()*(n-t)+t,[t,n]);k.useEffect(()=>{if(r.length===0){a([]),f([]);return}const v=[],b=[],w=[];for(let S=0;S<l&&S<r.length;S++){const R=C(w);R&&(v.push(R),w.push(R._id))}for(let S=0;S<v.length;S++){const R=[v[S]._id,...v.filter((N,j)=>j!==S).map(N=>N._id)],T=C(R);T?b.push(T):b.push(v[S])}a(v),f(b)},[r,l,C]);const E=k.useCallback(v=>{const b=_(),w=setTimeout(()=>{h(S=>{const R=[...S];return R[v]=!R[v],R}),setTimeout(()=>{m(S=>{const R=[...S];return R[v]=!R[v],R}),setTimeout(()=>{const S=!p[v];S&&a(R=>{const T=[...R];return T[v]=c[v],T}),f(R=>{const T=[...R],j=[(S?c[v]:u[v])._id,...u.filter(($,H)=>H!==v).map($=>$._id),...R.filter(($,H)=>H!==v).map($=>$._id)],L=C(j);return L&&(T[v]=L),T}),setTimeout(()=>{E(v)},150)},200)},150)},b);x.current[v]=w},[_,C,u,c,p]),D=k.useRef(!1);k.useEffect(()=>{if(!(u.length===0||r.length<=1)&&!D.current){D.current=!0;for(let v=0;v<u.length;v++)E(v);return()=>{x.current.forEach(v=>clearTimeout(v)),x.current=[],D.current=!1}}},[u.length,r.length]);const A=v=>{s&&s(v)};return r.length===0?g.jsx("div",{className:`flex items-center justify-center p-8 ${i}`,children:g.jsx("p",{className:"text-gray-500",children:"No nodes available"})}):u.length===0?g.jsx("div",{className:`flex items-center justify-center p-8 ${i}`,children:g.jsx("p",{className:"text-gray-500",children:"Loading..."})}):g.jsx("div",{className:`flex gap-4 justify-center items-center flex-wrap ${i}`,children:u.map((v,b)=>{const w=c[b],S=p[b];return g.jsx("div",{className:`relative ${fa[o]}`,style:{perspective:"1000px"},onClick:()=>A(S?w:v),children:g.jsxs("div",{className:"w-full h-full rounded-lg shadow-lg overflow-hidden cursor-pointer hover:shadow-xl",style:{transform:`rotateY(${d[b]?180:0}deg)`,transition:"transform 0.5s",transformStyle:"preserve-3d"},children:[g.jsx("div",{className:"absolute inset-0 transition-opacity duration-200",style:{opacity:S?0:1},children:g.jsxs("div",{style:{transform:d[b]?"scaleX(-1)":"scaleX(1)",width:"100%",height:"100%"},children:[g.jsx("img",{src:v.data.image,alt:v.title,className:"w-full h-full object-cover"}),g.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:g.jsx("p",{className:"text-white text-sm font-medium truncate",children:v.title})})]})}),w&&g.jsx("div",{className:"absolute inset-0 transition-opacity duration-200",style:{opacity:S?1:0},children:g.jsxs("div",{style:{transform:d[b]?"scaleX(-1)":"scaleX(1)",width:"100%",height:"100%"},children:[g.jsx("img",{src:w.data.image,alt:w.title,className:"w-full h-full object-cover"}),g.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:g.jsx("p",{className:"text-white text-sm font-medium truncate",children:w.title})})]})})]})},`slot-${b}`)})})}function Wt(r){if(!r)return"";const e=/=\?([^?]+)\?([BQbq])\?([^?]*)\?=/g;return r.replace(e,(t,n,s,o)=>{try{if(s.toUpperCase()==="B"){const i=atob(o);return decodeURIComponent(escape(i))}else if(s.toUpperCase()==="Q"){const i=o.replace(/_/g," ").replace(/=([0-9A-Fa-f]{2})/g,(l,u)=>String.fromCharCode(parseInt(u,16)));return decodeURIComponent(escape(i))}}catch(i){console.warn("MIME decode error:",i)}return t}).replace(/\s+/g," ").trim()}const pa={background:"#ffffff",cardBackground:"#ffffff",selectedBackground:"#f5f5f5",unreadBackground:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",danger:"#ef4444"};function ga({baseUrl:r,systemId:e,accountId:t,limit:n=30,folder:s,selectable:o=!0,showDetail:i=!1,showSearch:l=!0,searchQuery:u,onSearchChange:a,emptyMessage:c="No emails",autoLoad:f=!0,onSelect:d,onSelectionChange:h,onDelete:p,onError:m,onLoad:x,renderItem:C,renderDetail:_,renderActions:E,renderEmpty:D,renderLoading:A,theme:v={}}){const b={...pa,...v},[w,S]=k.useState([]),[R,T]=k.useState(!1),[N,j]=k.useState(null),[L,$]=k.useState(new Set),[H,ue]=k.useState(null),[re,we]=k.useState(null),[Ee,Ge]=k.useState(null),[He,Me]=k.useState(!1),[Je,Re]=k.useState(""),ae=u!==void 0?u:Je,Le=U=>{a?a(U):Re(U)},he=k.useMemo(()=>{if(!ae.trim())return w;const U=ae.toLowerCase();return w.filter(K=>Wt(K.from).toLowerCase().includes(U)||Wt(K.subject).toLowerCase().includes(U))},[w,ae]),ee=k.useMemo(()=>e?new tl({baseUrl:r,system_id:e}):null,[r,e]),Be=k.useCallback(async()=>{if(ee){T(!0),j(null);try{const U=await ee.listEmails(t,n,s);U!=null&&U.messages&&(S(U.messages),x==null||x(U.messages))}catch(U){const K=U instanceof Error?U:new Error("Failed to fetch emails");j(K.message),m==null||m(K)}T(!1)}},[ee,t,n,s,m,x]);k.useEffect(()=>{S([]),$(new Set),we(null),j(null),u===void 0&&Re(""),f&&Be()},[s,f]);const W=k.useCallback(async U=>{if(ee){we(U),Ge(null),Me(!0);try{const K=await ee.getEmailParsed(t,U.uid,s||"INBOX");K!=null&&K.body&&Ge(K.body)}catch(K){console.error("Failed to fetch email body:",K)}Me(!1)}},[ee,t,s]),xe=k.useCallback(U=>{d==null||d(U),i&&W(U)},[d,i,W]),$e=k.useCallback((U,K,oe)=>{if(!o){d==null||d(U),i&&W(U);return}const Ie=U.uid;if(oe.shiftKey&&H!==null){const je=Math.min(H,K),ot=Math.max(H,K),ss=w.slice(je,ot+1).map(ur=>ur.uid),tn=new Set(ss);$(tn),h==null||h(Array.from(tn))}else if(oe.ctrlKey||oe.metaKey)$(je=>{const ot=new Set(je);return ot.has(Ie)?ot.delete(Ie):ot.add(Ie),h==null||h(Array.from(ot)),ot}),ue(K);else{const je=new Set([Ie]);$(je),ue(K),h==null||h(Array.from(je))}},[o,H,w,L,d,h,i]),wt=k.useCallback(async()=>{if(!ee||L.size===0)return;const U=s||"INBOX";try{const K=await ee.trashEmails(t,Array.from(L),U);if(console.log("Trash result:",K),K.success&&K.moved>0){S(Ie=>Ie.filter(je=>!L.has(je.uid)));const oe=Array.from(L);$(new Set),p==null||p(oe)}else j("Failed to move emails to trash")}catch(K){const oe=K instanceof Error?K:new Error("Trash failed");console.error("Trash error:",oe),j(oe.message),m==null||m(oe)}},[ee,t,L,s,p,m]),ht=k.useCallback(async()=>{if(!ee||L.size===0)return;const U=s||"INBOX";try{const K=await ee.archiveEmails(t,Array.from(L),U);if(console.log("Archive result:",K),K.success&&K.archived>0){S(Ie=>Ie.filter(je=>!L.has(je.uid)));const oe=Array.from(L);$(new Set),p==null||p(oe)}else j("Failed to archive emails")}catch(K){const oe=K instanceof Error?K:new Error("Archive failed");console.error("Archive error:",oe),j(oe.message),m==null||m(oe)}},[ee,t,L,s,p,m]),it=k.useCallback(()=>{if(L.size===w.length)$(new Set),h==null||h([]);else{const U=new Set(w.map(K=>K.uid));$(U),h==null||h(Array.from(U))}},[w,L.size,h]),It=k.useCallback(()=>{$(new Set),h==null||h([])},[h]),Qr={delete:wt,archive:ht,refresh:Be,selectAll:it,clearSelection:It},zt=U=>{if(!U)return"";const K=new Date(U),oe=new Date;return K.toDateString()===oe.toDateString()?K.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):K.toLocaleDateString([],{month:"short",day:"numeric"})},Zn=(U,K)=>g.jsx("div",{style:{padding:"12px 16px",background:K?b.selectedBackground:U.seen?b.cardBackground:b.unreadBackground,borderBottom:`1px solid ${b.border}`,cursor:"pointer",transition:"background 0.15s ease"},children:g.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"12px"},children:[g.jsxs("div",{style:{flex:1,minWidth:0},children:[g.jsx("div",{style:{fontSize:"14px",fontWeight:U.seen?400:600,color:b.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Wt(U.from).split("@")[0]}),g.jsx("div",{style:{fontSize:"14px",fontWeight:U.seen?400:500,color:U.seen?b.textSecondary:b.text,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:Wt(U.subject)||"(No subject)"})]}),g.jsx("div",{style:{fontSize:"12px",color:b.textSecondary,flexShrink:0},children:zt(U.date)})]})}),es=U=>g.jsxs("div",{style:{padding:"24px"},children:[g.jsx("h2",{style:{margin:"0 0 8px",fontSize:"20px",color:b.text},children:Wt(U.subject)||"(No subject)"}),g.jsxs("div",{style:{fontSize:"14px",color:b.textSecondary,marginBottom:"16px"},children:["From: ",Wt(U.from)," • ",new Date(U.date).toLocaleString()]}),He?g.jsx("div",{style:{fontSize:"14px",color:b.textSecondary},children:"Loading..."}):Ee?g.jsx("div",{style:{fontSize:"14px",color:b.text},dangerouslySetInnerHTML:{__html:Ee}}):g.jsx("div",{style:{fontSize:"14px",color:b.textSecondary},children:"No content available"})]}),lr=(U,K)=>g.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",background:b.cardBackground,borderBottom:`1px solid ${b.border}`},children:[g.jsx("button",{onClick:K.selectAll,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${b.border}`,borderRadius:"6px",fontSize:"13px",cursor:"pointer",color:b.text},children:U.length===w.length?"Deselect All":"Select All"}),U.length>0&&g.jsxs(g.Fragment,{children:[g.jsxs("span",{style:{fontSize:"13px",color:b.textSecondary},children:[U.length," selected"]}),g.jsx("button",{onClick:K.archive,title:"Archive",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${b.border}`,borderRadius:"6px",cursor:"pointer",color:b.textSecondary},children:g.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"archive"})}),g.jsx("button",{onClick:K.delete,title:"Delete",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${b.border}`,borderRadius:"6px",cursor:"pointer",color:b.textSecondary},children:g.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"delete"})})]}),g.jsx("div",{style:{flex:1}}),g.jsx("button",{onClick:K.refresh,title:"Refresh",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${b.border}`,borderRadius:"6px",cursor:"pointer",color:b.textSecondary},children:g.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"refresh"})})]}),ts=()=>g.jsx("div",{style:{padding:"48px",textAlign:"center",color:b.textSecondary},children:c}),rs=()=>g.jsx("div",{style:{padding:"48px",textAlign:"center",color:b.textSecondary},children:"Loading..."}),Yr=C||Zn,Xr=_||es,Zr=E||lr,ns=D||ts,en=A||rs;return R&&w.length===0?g.jsx("div",{style:{background:b.background,width:"100%",height:"100%"},children:en()}):g.jsxs("div",{style:{display:"flex",background:b.background,width:"100%",height:"100%"},children:[g.jsxs("div",{style:{flex:i&&re?"0 0 50%":"1",display:"flex",flexDirection:"column",borderRight:i&&re?`1px solid ${b.border}`:"none",overflow:"hidden"},children:[o&&Zr(Array.from(L),Qr),l&&g.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${b.border}`,background:b.background},children:g.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 12px",background:"#f5f5f5",borderRadius:"6px"},children:[g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:b.textSecondary,strokeWidth:"2",children:[g.jsx("circle",{cx:"11",cy:"11",r:"8"}),g.jsx("path",{d:"M21 21l-4.35-4.35"})]}),g.jsx("input",{type:"text",placeholder:"Search by email or subject...",value:ae,onChange:U=>Le(U.target.value),style:{flex:1,border:"none",background:"transparent",outline:"none",fontSize:"13px",color:b.text}}),ae&&g.jsx("button",{onClick:()=>Le(""),style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",justifyContent:"center"},children:g.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:b.textSecondary,strokeWidth:"2",children:g.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]})}),N&&g.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",color:b.danger,fontSize:"14px",borderBottom:`1px solid ${b.border}`},children:N}),g.jsx("div",{style:{flex:1,overflowY:"auto"},children:he.length===0?ns():he.map((U,K)=>g.jsx("div",{onClick:oe=>$e(U,K,oe),onDoubleClick:()=>xe(U),children:Yr(U,L.has(U.uid))},U.uid))})]}),i&&re&&g.jsx("div",{style:{flex:1,overflowY:"auto"},children:Xr(re)})]})}function ma({items:r,renderItem:e,onSelectionChange:t,onCurrentChange:n,onAction:s,actions:o=[],emptyMessage:i="No items",showSelectAll:l=!0,className:u=""}){const[a,c]=k.useState(new Set),[f,d]=k.useState(-1),h=r.filter(D=>a.has(D.id)),p=f>=0&&f<h.length?h[f]:null,m=k.useCallback(D=>{c(A=>{const v=new Set(A);return v.has(D)?v.delete(D):v.add(D),t==null||t(Array.from(v)),v})},[t]),x=k.useCallback(()=>{if(a.size===r.length)c(new Set),d(-1),t==null||t([]);else{const D=new Set(r.map(A=>A.id));c(D),r.length>0&&(d(0),n==null||n(r[0],0)),t==null||t(r.map(A=>A.id))}},[r,a.size,t,n]),C=k.useCallback(()=>{if(h.length===0)return;const D=f<=0?h.length-1:f-1;d(D),n==null||n(h[D],D)},[h,f,n]),_=k.useCallback(()=>{if(h.length===0)return;const D=f>=h.length-1?0:f+1;d(D),n==null||n(h[D],D)},[h,f,n]),E=k.useCallback(D=>{s==null||s(D,h,p)},[s,h,p]);return k.useEffect(()=>{h.length===0?d(-1):f>=h.length?d(h.length-1):f<0&&h.length>0&&(d(0),n==null||n(h[0],0))},[h.length,f,n]),r.length===0?g.jsx("div",{className:`text-sm text-neutral-400 text-center py-4 ${u}`,children:i}):g.jsxs("div",{className:`space-y-2 ${u}`,children:[g.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[l&&g.jsxs("button",{onClick:x,className:"flex items-center gap-1 hover:text-neutral-700 transition-colors",children:[g.jsx("span",{className:"material-icons text-sm",children:a.size===r.length?"check_box":a.size>0?"indeterminate_check_box":"check_box_outline_blank"}),g.jsx("span",{children:a.size===r.length?"Deselect all":"Select all"})]}),a.size>0&&g.jsxs("span",{className:"text-neutral-400",children:["(",a.size," selected)"]})]}),h.length>1&&g.jsxs("div",{className:"flex items-center gap-1",children:[g.jsx("button",{onClick:C,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Previous",children:g.jsx("span",{className:"material-icons text-sm",children:"chevron_left"})}),g.jsxs("span",{className:"text-xs min-w-[3rem] text-center",children:[f+1," / ",h.length]}),g.jsx("button",{onClick:_,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Next",children:g.jsx("span",{className:"material-icons text-sm",children:"chevron_right"})})]})]}),g.jsx("div",{className:"space-y-1",children:r.map(D=>{const A=a.has(D.id),v=(p==null?void 0:p.id)===D.id;return g.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg cursor-pointer transition-colors ${v?"bg-blue-50 ring-1 ring-blue-200":A?"bg-neutral-100":"hover:bg-neutral-50"}`,onClick:()=>m(D.id),children:[g.jsx("span",{className:`material-icons text-lg ${A?"text-blue-500":"text-neutral-300"}`,children:A?"check_box":"check_box_outline_blank"}),g.jsx("div",{className:"flex-1 min-w-0",children:e(D,A,v)})]},D.id)})}),o.length>0&&a.size>0&&g.jsx("div",{className:"flex items-center gap-2 pt-2 border-t border-neutral-100",children:o.map(D=>{var v;const A=((v=D.disabled)==null?void 0:v.call(D,h))??!1;return g.jsxs("button",{onClick:()=>E(D.id),disabled:A,className:`flex items-center gap-1 px-3 py-1.5 text-xs rounded-lg transition-colors ${A?"bg-neutral-100 text-neutral-400 cursor-not-allowed":"bg-neutral-100 hover:bg-neutral-200 text-neutral-700"}`,children:[D.icon&&g.jsx("span",{className:"material-icons text-sm",children:D.icon}),D.label]},D.id)})})]})}function ya(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var xa=ya(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const il=k.createContext(null);function _a(r,e){return{getTheme:function(){return e??null}}}function nt(){const r=k.useContext(il);return r==null&&xa(8),r}function Mr(r){return{}}const Js={},ba={},ol={},Tt={},Qt={},Br={},Yt={},Mn={},As={},Nr={},Fr={},We={},Qs={},Ys={},va={},ll={},Da={},ul={},Ca={},al={},cl={},yn={},wa={},dl={},fl={},hl={},Ea={},Aa={},ka={},zi={},pl={},Sa={},gl={},ml={},Ta={},Rn={},Xs={},ks={},Ba={},Na={},nn={},sn={},Fa={},La={},ja={},Ve=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Pa=Ve&&"documentMode"in document?document.documentMode:null,ze=Ve&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),bt=Ve&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),xn=!(!Ve||!("InputEvent"in window)||Pa)&&"getTargetRanges"in new window.InputEvent("input"),$n=Ve&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Rr=Ve&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Oa=Ve&&/Android/.test(navigator.userAgent),yl=Ve&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Ma=Ve&&Oa&&yl,Zs=Ve&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!yl,$r=1,Dt=3,Ft=0,xl=1,er=2,Ra=0,$a=1,Ia=2,_n=4,bn=8,ei=128,za=112|(3|_n|bn)|ei,ti=1,ri=2,ni=3,si=4,ii=5,oi=6,In=$n||Rr||Zs?" ":"",at=`
|
|
62
62
|
|
|
63
|
-
`,qa=bt?" ":In,_l="֑-߿יִ-﷽ﹰ-ﻼ",bl="A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-︀--",Ua=new RegExp("^[^"+bl+"]*["+_l+"]"),Wa=new RegExp("^[^"+_l+"]*["+bl+"]"),Lt={bold:1,code:16,highlight:ei,italic:2,strikethrough:_n,subscript:32,superscript:64,underline:bn},Ka={directionless:1,unmergeable:2},qi={center:ri,end:oi,justify:si,left:ti,right:ni,start:ii},Va={[ri]:"center",[oi]:"end",[si]:"justify",[ti]:"left",[ni]:"right",[ii]:"start"},Ga={normal:0,segmented:2,token:1},Ha={[Ra]:"normal",[Ia]:"segmented",[$a]:"token"};function Ja(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var O=Ja(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function vn(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}const Qa=100;let Ss=!1,li=0;function Ya(r){li=r.timeStamp}function hs(r,e,t){const n=r.nodeName==="BR",s=e.__lexicalLineBreak;return s&&(r===s||n&&r.previousSibling===s)||n&&qn(r,t)!==void 0}function Xa(r,e,t){const n=Oe(t._window);let s=null,o=null;n!==null&&n.anchorNode===r&&(s=n.anchorOffset,o=n.focusOffset);const i=r.nodeValue;i!==null&&fi(e,i,s,o,!1)}function Za(r,e,t){if(P(r)){const n=r.anchor.getNode();if(n.is(t)&&r.format!==n.getFormat())return!1}return e.nodeType===Ct&&t.isAttached()}function ec(r,e,t,n){for(let s=r;s&&!hc(s);s=zr(s)){const o=qn(s,e);if(o!==void 0){const i=_e(o,t);if(i)return Z(i)?void 0:[s,i]}else if(s===n)return[n,Tl(t)]}}function vl(r,e,t){Ss=!0;const n=performance.now()-li>Qa;try{Ne(r,()=>{const s=q()||function(d){return d.getEditorState().read(()=>{const h=q();return h!==null?h.clone():null})}(r),o=new Map,i=r.getRootElement(),l=r._editorState,u=r._blockCursorElement;let a=!1,c="";for(let d=0;d<e.length;d++){const h=e[d],p=h.type,m=h.target,x=ec(m,r,l,i);if(!x)continue;const[D,_]=x;if(p==="characterData")n&&M(_)&&Za(s,m,_)&&Xa(m,_,r);else if(p==="childList"){a=!0;const E=h.addedNodes;for(let v=0;v<E.length;v++){const b=E[v],w=kl(b),S=b.parentNode;if(S!=null&&b!==u&&w===null&&!hs(b,S,r)){if(bt){const R=b.innerText||b.nodeValue;R&&(c+=R)}S.removeChild(b)}}const C=h.removedNodes,A=C.length;if(A>0){let v=0;for(let b=0;b<A;b++){const w=C[b];(hs(w,m,r)||u===w)&&(m.appendChild(w),v++)}A!==v&&o.set(D,_)}}}if(o.size>0)for(const[d,h]of o)h.reconcileObservedMutation(d,r);const f=t.takeRecords();if(f.length>0){for(let d=0;d<f.length;d++){const h=f[d],p=h.addedNodes,m=h.target;for(let x=0;x<p.length;x++){const D=p[x],_=D.parentNode;_==null||D.nodeName!=="BR"||hs(D,m,r)||_.removeChild(D)}}t.takeRecords()}s!==null&&(a&&(s.dirty=!0,et(s)),bt&&Ll(r)&&s.insertRawText(c))})}finally{Ss=!1}}function Cl(r){const e=r._observer;e!==null&&vl(r,e.takeRecords(),e)}function Dl(r){(function(e){li===0&&Wn(e).addEventListener("textInput",Ya,!0)})(r),r._observer=new MutationObserver((e,t)=>{vl(r,e,t)})}function Ui(r,e){const t=r.__mode,n=r.__format,s=r.__style,o=e.__mode,i=e.__format,l=e.__style;return!(t!==null&&t!==o||n!==null&&n!==i||s!==null&&s!==l)}function Wi(r,e){const t=r.mergeWithSibling(e),n=se()._normalizedNodes;return n.add(r.__key),n.add(e.__key),t}function Ki(r){let e,t,n=r;if(n.__text!==""||!n.isSimpleText()||n.isUnmergeable()){for(;(e=n.getPreviousSibling())!==null&&M(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(e.__text!==""){if(Ui(e,n)){n=Wi(e,n);break}break}e.remove()}for(;(t=n.getNextSibling())!==null&&M(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==""){if(Ui(n,t)){n=Wi(n,t);break}break}t.remove()}}else n.remove()}function wl(r){return Vi(r.anchor),Vi(r.focus),r}function Vi(r){for(;r.type==="element";){const e=r.getNode(),t=r.offset;let n,s;if(t===e.getChildrenSize()?(n=e.getChildAtIndex(t-1),s=!0):(n=e.getChildAtIndex(t),s=!1),M(n)){r.set(n.__key,s?n.getTextContentSize():0,"text");break}if(!B(n))break;r.set(n.__key,s?n.getChildrenSize():0,"element")}}let tc=1;const rc=typeof queueMicrotask=="function"?queueMicrotask:r=>{Promise.resolve().then(r)};function ui(r){const e=document.activeElement;if(e===null)return!1;const t=e.nodeName;return Z(tr(r))&&(t==="INPUT"||t==="TEXTAREA"||e.contentEditable==="true"&&zn(e)==null)}function Ir(r,e,t){const n=r.getRootElement();try{return n!==null&&n.contains(e)&&n.contains(t)&&e!==null&&!ui(e)&&El(e)===r}catch{return!1}}function ai(r){return r instanceof Jn}function El(r){let e=r;for(;e!=null;){const t=zn(e);if(ai(t))return t;e=zr(e)}return null}function zn(r){return r?r.__lexicalEditor:null}function kt(r){return r.isToken()||r.isSegmented()}function nc(r){return r.nodeType===Ct}function Cn(r){let e=r;for(;e!=null;){if(nc(e))return e;e=e.firstChild}return null}function Dn(r,e,t){const n=Lt[e];if(t!==null&&(r&n)==(t&n))return r;let s=r^n;return e==="subscript"?s&=-65:e==="superscript"&&(s&=-33),s}function Al(r){return M(r)||Nt(r)||Z(r)}function sc(r,e){if(e!=null)return void(r.__key=e);ke(),eu();const t=se(),n=dt(),s=""+tc++;n._nodeMap.set(s,r),B(r)?t._dirtyElements.set(s,!0):t._dirtyLeaves.add(s),t._cloneNotNeeded.add(s),t._dirtyType=xl,r.__key=s}function Bt(r){const e=r.getParent();if(e!==null){const t=r.getWritable(),n=e.getWritable(),s=r.getPreviousSibling(),o=r.getNextSibling();if(s===null)if(o!==null){const i=o.getWritable();n.__first=o.__key,i.__prev=null}else n.__first=null;else{const i=s.getWritable();if(o!==null){const l=o.getWritable();l.__prev=i.__key,i.__next=l.__key}else i.__next=null;t.__prev=null}if(o===null)if(s!==null){const i=s.getWritable();n.__last=s.__key,i.__next=null}else n.__last=null;else{const i=o.getWritable();if(s!==null){const l=s.getWritable();l.__next=i.__key,i.__prev=l.__key}else i.__prev=null;t.__next=null}n.__size--,t.__parent=null}}function wn(r){eu();const e=r.getLatest(),t=e.__parent,n=dt(),s=se(),o=n._nodeMap,i=s._dirtyElements;t!==null&&function(u,a,c){let f=u;for(;f!==null;){if(c.has(f))return;const d=a.get(f);if(d===void 0)break;c.set(f,!1),f=d.__parent}}(t,o,i);const l=e.__key;s._dirtyType=xl,B(r)?i.set(l,!0):s._dirtyLeaves.add(l)}function ye(r){ke();const e=se(),t=e._compositionKey;if(r!==t){if(e._compositionKey=r,t!==null){const n=_e(t);n!==null&&n.getWritable()}if(r!==null){const n=_e(r);n!==null&&n.getWritable()}}}function yt(){return Vr()?null:se()._compositionKey}function _e(r,e){const t=(e||dt())._nodeMap.get(r);return t===void 0?null:t}function kl(r,e){const t=qn(r,se());return t!==void 0?_e(t,e):null}function qn(r,e){return r[`__lexicalKey_${e._key}`]}function tr(r,e){let t=r;for(;t!=null;){const n=kl(t,e);if(n!==null)return n;t=zr(t)}return null}function Sl(r){const e=r._decorators,t=Object.assign({},e);return r._pendingDecorators=t,t}function Gi(r){return r.read(()=>ie().getTextContent())}function ie(){return Tl(dt())}function Tl(r){return r._nodeMap.get("root")}function et(r){ke();const e=dt();r!==null&&(r.dirty=!0,r.setCachedNodes(null)),e._selection=r}function Ht(r){const e=se(),t=function(n,s){let o=n;for(;o!=null;){const i=qn(o,s);if(i!==void 0)return i;o=zr(o)}return null}(r,e);return t===null?r===e.getRootElement()?_e("root"):null:_e(t)}function Hi(r,e){return e?r.getTextContentSize():0}function Bl(r){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(r)}function ci(r){const e=[];let t=r;for(;t!==null;)e.push(t),t=t._parentEditor;return e}function Nl(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function Fl(r){return r.nodeType===Ct?r.nodeValue:null}function di(r,e,t){const n=Oe(e._window);if(n===null)return;const s=n.anchorNode;let{anchorOffset:o,focusOffset:i}=n;if(s!==null){let l=Fl(s);const u=tr(s);if(l!==null&&M(u)){if(l===In&&t){const a=t.length;l=t,o=a,i=a}l!==null&&fi(u,l,o,i,r)}}}function fi(r,e,t,n,s){let o=r;if(o.isAttached()&&(s||!o.isDirty())){const i=o.isComposing();let l=e;(i||s)&&e[e.length-1]===In&&(l=e.slice(0,-1));const u=o.getTextContent();if(s||l!==u){if(l===""){if(ye(null),$n||Rr||Zs)o.remove();else{const m=se();setTimeout(()=>{m.update(()=>{o.isAttached()&&o.remove()})},20)}return}const a=o.getParent(),c=Kr(),f=o.getTextContentSize(),d=yt(),h=o.getKey();if(o.isToken()||d!==null&&h===d&&!i||P(c)&&(a!==null&&!a.canInsertTextBefore()&&c.anchor.offset===0||c.anchor.key===r.__key&&c.anchor.offset===0&&!o.canInsertTextBefore()&&!i||c.focus.key===r.__key&&c.focus.offset===f&&!o.canInsertTextAfter()&&!i))return void o.markDirty();const p=q();if(!P(p)||t===null||n===null)return void o.setTextContent(l);if(p.setTextNodeRange(o,t,o,n),o.isSegmented()){const m=pe(o.getTextContent());o.replace(m),o=m}o.setTextContent(l)}}}function ic(r,e){if(e.isSegmented())return!0;if(!r.isCollapsed())return!1;const t=r.anchor.offset,n=e.getParentOrThrow(),s=e.isToken();return t===0?!e.canInsertTextBefore()||!n.canInsertTextBefore()&&!e.isComposing()||s||function(o){const i=o.getPreviousSibling();return(M(i)||B(i)&&i.isInline())&&!i.canInsertTextAfter()}(e):t===e.getTextContentSize()&&(!e.canInsertTextAfter()||!n.canInsertTextAfter()&&!e.isComposing()||s)}function Ji(r){return r==="ArrowLeft"}function Qi(r){return r==="ArrowRight"}function xr(r,e){return ze?r:e}function Yi(r){return r==="Enter"}function fr(r){return r==="Backspace"}function hr(r){return r==="Delete"}function Xi(r,e,t){return r.toLowerCase()==="a"&&xr(e,t)}function oc(){const r=ie();et(wl(r.select(0,r.getChildrenSize())))}function wr(r,e){r.__lexicalClassNameCache===void 0&&(r.__lexicalClassNameCache={});const t=r.__lexicalClassNameCache,n=t[e];if(n!==void 0)return n;const s=r[e];if(typeof s=="string"){const o=vn(s);return t[e]=o,o}return s}function hi(r,e,t,n,s){if(t.size===0)return;const o=n.__type,i=n.__key,l=e.get(o);l===void 0&&O(33,o);const u=l.klass;let a=r.get(u);a===void 0&&(a=new Map,r.set(u,a));const c=a.get(i),f=c==="destroyed"&&s==="created";(c===void 0||f)&&a.set(i,f?"updated":s)}function Zi(r,e,t){const n=r.getParent();let s=t,o=r;return n!==null&&(e&&t===0?(s=o.getIndexWithinParent(),o=n):e||t!==o.getChildrenSize()||(s=o.getIndexWithinParent()+1,o=n)),o.getChildAtIndex(e?s-1:s)}function Lr(r,e){const t=r.offset;if(r.type==="element")return Zi(r.getNode(),e,t);{const n=r.getNode();if(e&&t===0||!e&&t===n.getTextContentSize()){const s=e?n.getPreviousSibling():n.getNextSibling();return s===null?Zi(n.getParentOrThrow(),e,n.getIndexWithinParent()+(e?0:1)):s}}return null}function Ll(r){const e=Wn(r).event,t=e&&e.inputType;return t==="insertFromPaste"||t==="insertFromPasteAsQuotation"}function I(r,e,t){return nu(r,e,t)}function Un(r){return!Ce(r)&&!r.isLastChild()&&!r.isInline()}function En(r,e){const t=r._keyToDOMMap.get(e);return t===void 0&&O(75,e),t}function zr(r){const e=r.assignedSlot||r.parentElement;return e!==null&&e.nodeType===11?e.host:e}function Er(r,e){let t=r.getParent();for(;t!==null;){if(t.is(e))return!0;t=t.getParent()}return!1}function Wn(r){const e=r._window;return e===null&&O(78),e}function lc(r){let e=r.getParentOrThrow();for(;e!==null;){if(tt(e))return e;e=e.getParentOrThrow()}return e}function tt(r){return Ce(r)||B(r)&&r.isShadowRoot()}function st(r){const e=se(),t=r.constructor.getType(),n=e._nodes.get(t);n===void 0&&O(200,r.constructor.name,t);const{replace:s,replaceWithKlass:o}=n;if(s!==null){const i=s(r),l=i.constructor;return o!==null?i instanceof o||O(201,o.name,o.getType(),l.name,l.getType(),r.constructor.name,t):i instanceof r.constructor&&l!==r.constructor||O(202,l.name,l.getType(),r.constructor.name,t),i.__key===r.__key&&O(203,r.constructor.name,t,l.name,l.getType()),i}return r}function ps(r,e){!Ce(r.getParent())||B(e)||Z(e)||O(99)}function gs(r){return(Z(r)||B(r)&&!r.canBeEmpty())&&!r.isInline()}function pi(r,e,t){t.style.removeProperty("caret-color"),e._blockCursorElement=null;const n=r.parentElement;n!==null&&n.removeChild(r)}function uc(r,e,t){let n=r._blockCursorElement;if(P(t)&&t.isCollapsed()&&t.anchor.type==="element"&&e.contains(document.activeElement)){const s=t.anchor,o=s.getNode(),i=s.offset;let l=!1,u=null;if(i===o.getChildrenSize())gs(o.getChildAtIndex(i-1))&&(l=!0);else{const a=o.getChildAtIndex(i);if(a!==null&&gs(a)){const c=a.getPreviousSibling();(c===null||gs(c))&&(l=!0,u=r.getElementByKey(a.__key))}}if(l){const a=r.getElementByKey(o.__key);return n===null&&(r._blockCursorElement=n=function(c){const f=c.theme,d=document.createElement("div");d.contentEditable="false",d.setAttribute("data-lexical-cursor","true");let h=f.blockCursor;if(h!==void 0){if(typeof h=="string"){const p=vn(h);h=f.blockCursor=p}h!==void 0&&d.classList.add(...h)}return d}(r._config)),e.style.caretColor="transparent",void(u===null?a.appendChild(n):a.insertBefore(n,u))}}n!==null&&pi(n,r,e)}function Oe(r){return Ve?(r||window).getSelection():null}function ac(r){return ct(r)&&r.tagName==="A"}function ct(r){return r.nodeType===1}function eo(r){return r.nodeType===11}function Ts(r){const e=new RegExp(/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/,"i");return r.nodeName.match(e)!==null}function An(r){const e=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 r.nodeName.match(e)!==null}function gt(r){if(Z(r)&&!r.isInline())return!0;if(!B(r)||tt(r))return!1;const e=r.getFirstChild(),t=e===null||Nt(e)||M(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function pr(r,e){let t=r;for(;t!==null&&t.getParent()!==null&&!e(t);)t=t.getParentOrThrow();return e(t)?t:null}function cc(){return se()}const to=new WeakMap,dc=new Map;function fc(r){if(!r._readOnly&&r.isEmpty())return dc;r._readOnly||O(192);let e=to.get(r);if(!e){e=new Map,to.set(r,e);for(const[t,n]of r._nodeMap){const s=n.__type;let o=e.get(s);o||(o=new Map,e.set(s,o)),o.set(t,n)}}return e}function gi(r){const e=r.constructor.clone(r);return e.afterCloneFrom(r),e}function mi(r,e){const t=(parseInt(r.style.paddingInlineStart,10)||0)/40;e.setIndent(t)}function hc(r){return r.__lexicalUnmanaged===!0}function jl(r,e,t,n,s,o){let i=r.getFirstChild();for(;i!==null;){const l=i.__key;i.__parent===e&&(B(i)&&jl(i,l,t,n,s,o),t.has(l)||o.delete(l),s.push(l)),i=i.getNextSibling()}}let vt,De,jr,Kn,Bs,Ns,jt,Ke,Fs,Pr,de="",ve="",Qe=null,qe="",ut="",Pl=!1,Or=!1,hn=null;function kn(r,e){const t=jt.get(r);if(e!==null){const n=Ps(r);n.parentNode===e&&e.removeChild(n)}if(Ke.has(r)||De._keyToDOMMap.delete(r),B(t)){const n=Tn(t,jt);Ls(n,0,n.length-1,null)}t!==void 0&&hi(Pr,jr,Kn,t,"destroyed")}function Ls(r,e,t,n){let s=e;for(;s<=t;++s){const o=r[s];o!==void 0&&kn(o,n)}}function At(r,e){r.setProperty("text-align",e)}const pc="40px";function Ol(r,e){const t=vt.theme.indent;if(typeof t=="string"){const s=r.classList.contains(t);e>0&&!s?r.classList.add(t):e<1&&s&&r.classList.remove(t)}const n=getComputedStyle(r).getPropertyValue("--lexical-indent-base-value")||pc;r.style.setProperty("padding-inline-start",e===0?"":`calc(${e} * ${n})`)}function Ml(r,e){const t=r.style;e===0?At(t,""):e===ti?At(t,"left"):e===ri?At(t,"center"):e===ni?At(t,"right"):e===si?At(t,"justify"):e===ii?At(t,"start"):e===oi&&At(t,"end")}function Sn(r,e){const t=Ke.get(r);t===void 0&&O(60);const n=t.createDOM(vt,De);if(function(s,o,i){const l=i._keyToDOMMap;(function(u,a,c){u[`__lexicalKey_${a._key}`]=c})(o,i,s),l.set(s,o)}(r,n,De),M(t)?n.setAttribute("data-lexical-text","true"):Z(t)&&n.setAttribute("data-lexical-decorator","true"),B(t)){const s=t.__indent,o=t.__size;if(s!==0&&Ol(n,s),o!==0){const l=o-1;(function(u,a,c,f){const d=ve;ve="",js(u,c,0,a,c.getDOMSlot(f)),$l(c,f),ve=d})(Tn(t,Ke),l,t,n)}const i=t.__format;i!==0&&Ml(n,i),t.isInline()||Rl(null,t,n),Un(t)&&(de+=at,ut+=at)}else{const s=t.getTextContent();if(Z(t)){const o=t.decorate(De,vt);o!==null&&Il(r,o),n.contentEditable="false"}else M(t)&&(t.isDirectionless()||(ve+=s));de+=s,ut+=s}return e!==null&&e.insertChild(n),hi(Pr,jr,Kn,t,"created"),n}function js(r,e,t,n,s){const o=de;de="";let i=t;for(;i<=n;++i){Sn(r[i],s);const l=Ke.get(r[i]);l!==null&&M(l)&&(Qe===null&&(Qe=l.getFormat()),qe===""&&(qe=l.getStyle()))}Un(e)&&(de+=at),s.element.__lexicalTextContent=de,de=o+de}function ro(r,e){if(r){const t=r.__last;if(t){const n=e.get(t);if(n)return Nt(n)?"line-break":Z(n)&&n.isInline()?"decorator":null}return"empty"}return null}function Rl(r,e,t){const n=ro(r,jt),s=ro(e,Ke);n!==s&&e.getDOMSlot(t).setManagedLineBreak(s)}function $l(r,e){const t=e.__lexicalDirTextContent||"",n=e.__lexicalDir||"";if(t!==ve||n!==hn){const o=ve==="",i=o?hn:(s=ve,Ua.test(s)?"rtl":Wa.test(s)?"ltr":null);if(i!==n){const l=e.classList,u=vt.theme;let a=n!==null?u[n]:void 0,c=i!==null?u[i]:void 0;if(a!==void 0){if(typeof a=="string"){const f=vn(a);a=u[n]=f}l.remove(...a)}if(i===null||o&&i==="ltr")e.removeAttribute("dir");else{if(c!==void 0){if(typeof c=="string"){const f=vn(c);c=u[i]=f}c!==void 0&&l.add(...c)}e.dir=i}Or||(r.getWritable().__dir=i)}hn=i,e.__lexicalDirTextContent=ve,e.__lexicalDir=i}var s}function gc(r,e,t){const n=ve;var s;ve="",Qe=null,qe="",function(o,i,l){const u=de,a=o.__size,c=i.__size;de="";const f=l.element;if(a===1&&c===1){const d=o.__first,h=i.__first;if(d===h)_r(d,f);else{const m=Ps(d),x=Sn(h,null);try{f.replaceChild(x,m)}catch(D){if(typeof D=="object"&&D!=null){const _=`${D.toString()} Parent: ${f.tagName}, new child: {tag: ${x.tagName} key: ${h}}, old child: {tag: ${m.tagName}, key: ${d}}.`;throw new Error(_)}throw D}kn(d,null)}const p=Ke.get(h);M(p)&&(Qe===null&&(Qe=p.getFormat()),qe===""&&(qe=p.getStyle()))}else{const d=Tn(o,jt),h=Tn(i,Ke);if(d.length!==a&&O(227),h.length!==c&&O(228),a===0)c!==0&&js(h,i,0,c-1,l);else if(c===0){if(a!==0){const p=l.after==null&&l.before==null&&l.element.__lexicalLineBreak==null;Ls(d,0,a-1,p?null:f),p&&(f.textContent="")}}else(function(p,m,x,D,_,E){const C=D-1,A=_-1;let v,b,w=E.getFirstChild(),S=0,R=0;for(;S<=C&&R<=A;){const j=m[S],L=x[R];if(j===L)w=ms(_r(L,E.element)),S++,R++;else{v===void 0&&(v=new Set(m)),b===void 0&&(b=new Set(x));const H=b.has(j),ue=v.has(L);if(H)if(ue){const re=En(De,L);re===w?w=ms(_r(L,E.element)):(E.withBefore(w).insertChild(re),_r(L,E.element)),S++,R++}else Sn(L,E.withBefore(w)),R++;else w=ms(Ps(j)),kn(j,E.element),S++}const $=Ke.get(L);$!==null&&M($)&&(Qe===null&&(Qe=$.getFormat()),qe===""&&(qe=$.getStyle()))}const T=S>C,N=R>A;if(T&&!N){const j=x[A+1],L=j===void 0?null:De.getElementByKey(j);js(x,p,R,A,E.withBefore(L))}else N&&!T&&Ls(m,S,C,E.element)})(i,d,h,a,c,l)}Un(i)&&(de+=at),f.__lexicalTextContent=de,de=u+de}(r,e,e.getDOMSlot(t)),$l(e,t),rr(s=e)&&Qe!=null&&Qe!==s.__textFormat&&!Or&&(s.setTextFormat(Qe),s.setTextStyle(qe)),function(o){rr(o)&&qe!==""&&qe!==o.__textStyle&&!Or&&o.setTextStyle(qe)}(e),ve=n}function Tn(r,e){const t=[];let n=r.__first;for(;n!==null;){const s=e.get(n);s===void 0&&O(101),t.push(n),n=s.__next}return t}function _r(r,e){const t=jt.get(r);let n=Ke.get(r);t!==void 0&&n!==void 0||O(61);const s=Pl||Ns.has(r)||Bs.has(r),o=En(De,r);if(t===n&&!s){if(B(t)){const i=o.__lexicalTextContent;i!==void 0&&(de+=i,ut+=i);const l=o.__lexicalDirTextContent;l!==void 0&&(ve+=l)}else{const i=t.getTextContent();M(t)&&!t.isDirectionless()&&(ve+=i),ut+=i,de+=i}return o}if(t!==n&&s&&hi(Pr,jr,Kn,n,"updated"),n.updateDOM(t,o,vt)){const i=Sn(r,null);return e===null&&O(62),e.replaceChild(i,o),kn(r,null),i}if(B(t)&&B(n)){const i=n.__indent;i!==t.__indent&&Ol(o,i);const l=n.__format;l!==t.__format&&Ml(o,l),s&&(gc(t,n,o),Ce(n)||n.isInline()||Rl(t,n,o)),Un(n)&&(de+=at,ut+=at)}else{const i=n.getTextContent();if(Z(n)){const l=n.decorate(De,vt);l!==null&&Il(r,l)}else M(n)&&!n.isDirectionless()&&(ve+=i);de+=i,ut+=i}if(!Or&&Ce(n)&&n.__cachedText!==ut){const i=n.getWritable();i.__cachedText=ut,n=i}return o}function Il(r,e){let t=De._pendingDecorators;const n=De._decorators;if(t===null){if(n[r]===e)return;t=Sl(De)}t[r]=e}function ms(r){let e=r.nextSibling;return e!==null&&e===De._blockCursorElement&&(e=e.nextSibling),e}function mc(r,e,t,n,s,o){de="",ut="",ve="",Pl=n===er,hn=null,De=t,vt=t._config,jr=t._nodes,Kn=De._listeners.mutation,Bs=s,Ns=o,jt=r._nodeMap,Ke=e._nodeMap,Or=e._readOnly,Fs=new Map(t._keyToDOMMap);const i=new Map;return Pr=i,_r("root",null),De=void 0,jr=void 0,Bs=void 0,Ns=void 0,jt=void 0,Ke=void 0,vt=void 0,Fs=void 0,Pr=void 0,i}function Ps(r){const e=Fs.get(r);return e===void 0&&O(75,r),e}const lt=Object.freeze({}),Os=30,Ms=[["keydown",function(r,e){if(Ar=r.timeStamp,zl=r.key,e.isComposing())return;const{key:t,shiftKey:n,ctrlKey:s,metaKey:o,altKey:i}=r;if(!I(e,va,r)&&t!=null){if(function(l,u,a,c){return Qi(l)&&!u&&!c&&!a}(t,s,i,o))I(e,ll,r);else if(function(l,u,a,c,f){return Qi(l)&&!c&&!a&&(u||f)}(t,s,n,i,o))I(e,Ca,r);else if(function(l,u,a,c){return Ji(l)&&!u&&!c&&!a}(t,s,i,o))I(e,ul,r);else if(function(l,u,a,c,f){return Ji(l)&&!c&&!a&&(u||f)}(t,s,n,i,o))I(e,Da,r);else if(function(l,u,a){return function(c){return c==="ArrowUp"}(l)&&!u&&!a}(t,s,o))I(e,al,r);else if(function(l,u,a){return function(c){return c==="ArrowDown"}(l)&&!u&&!a}(t,s,o))I(e,cl,r);else if(function(l,u){return Yi(l)&&u}(t,n))kr=!0,I(e,yn,r);else if(function(l){return l===" "}(t))I(e,wa,r);else if(function(l,u){return ze&&u&&l.toLowerCase()==="o"}(t,s))r.preventDefault(),kr=!0,I(e,Qt,!0);else if(function(l,u){return Yi(l)&&!u}(t,n))kr=!1,I(e,yn,r);else if(function(l,u,a,c){return ze?!u&&!a&&(fr(l)||l.toLowerCase()==="h"&&c):!(c||u||a)&&fr(l)}(t,i,o,s))fr(t)?I(e,dl,r):(r.preventDefault(),I(e,Tt,!0));else if(function(l){return l==="Escape"}(t))I(e,fl,r);else if(function(l,u,a,c,f){return ze?!(a||c||f)&&(hr(l)||l.toLowerCase()==="d"&&u):!(u||c||f)&&hr(l)}(t,s,n,i,o))hr(t)?I(e,hl,r):(r.preventDefault(),I(e,Tt,!1));else if(function(l,u,a){return fr(l)&&(ze?u:a)}(t,i,s))r.preventDefault(),I(e,Nr,!0);else if(function(l,u,a){return hr(l)&&(ze?u:a)}(t,i,s))r.preventDefault(),I(e,Nr,!1);else if(function(l,u){return ze&&u&&fr(l)}(t,o))r.preventDefault(),I(e,Fr,!0);else if(function(l,u){return ze&&u&&hr(l)}(t,o))r.preventDefault(),I(e,Fr,!1);else if(function(l,u,a,c){return l.toLowerCase()==="b"&&!u&&xr(a,c)}(t,i,o,s))r.preventDefault(),I(e,We,"bold");else if(function(l,u,a,c){return l.toLowerCase()==="u"&&!u&&xr(a,c)}(t,i,o,s))r.preventDefault(),I(e,We,"underline");else if(function(l,u,a,c){return l.toLowerCase()==="i"&&!u&&xr(a,c)}(t,i,o,s))r.preventDefault(),I(e,We,"italic");else if(function(l,u,a,c){return l==="Tab"&&!u&&!a&&!c}(t,i,s,o))I(e,Ea,r);else if(function(l,u,a,c){return l.toLowerCase()==="z"&&!u&&xr(a,c)}(t,n,o,s))r.preventDefault(),I(e,Qs,void 0);else if(function(l,u,a,c){return ze?l.toLowerCase()==="z"&&a&&u:l.toLowerCase()==="y"&&c||l.toLowerCase()==="z"&&c&&u}(t,n,o,s))r.preventDefault(),I(e,Ys,void 0);else{const l=e._editorState._selection;l===null||P(l)?!bt&&Xi(t,o,s)&&(r.preventDefault(),I(e,ks,r)):function(u,a,c,f){return!a&&u.toLowerCase()==="c"&&(ze?c:f)}(t,n,o,s)?(r.preventDefault(),I(e,Rn,r)):function(u,a,c,f){return!a&&u.toLowerCase()==="x"&&(ze?c:f)}(t,n,o,s)?(r.preventDefault(),I(e,Xs,r)):Xi(t,o,s)&&(r.preventDefault(),I(e,ks,r))}(function(l,u,a,c){return l||u||a||c})(s,n,i,o)&&I(e,ja,r)}}],["pointerdown",function(r,e){const t=r.target,n=r.pointerType;t instanceof Node&&n!=="touch"&&Ne(e,()=>{Z(tr(t))||($s=!0)})}],["compositionstart",function(r,e){Ne(e,()=>{const t=q();if(P(t)&&!e.isComposing()){const n=t.anchor,s=t.anchor.getNode();ye(n.key),(r.timeStamp<Ar+Os||n.type==="element"||!t.isCollapsed()||s.getFormat()!==t.format||M(s)&&s.getStyle()!==t.style)&&I(e,Yt,qa)}})}],["compositionend",function(r,e){bt?gr=!0:Ne(e,()=>{ys(e,r.data)})}],["input",function(r,e){r.stopPropagation(),Ne(e,()=>{const t=q(),n=r.data,s=Kl(r);if(n!=null&&P(t)&&Wl(t,s,n,r.timeStamp,!1)){gr&&(ys(e,n),gr=!1);const o=t.anchor.getNode(),i=Oe(e._window);if(i===null)return;const l=t.isBackward(),u=l?t.anchor.offset:t.focus.offset,a=l?t.focus.offset:t.anchor.offset;xn&&!t.isCollapsed()&&M(o)&&i.anchorNode!==null&&o.getTextContent().slice(0,u)+n+o.getTextContent().slice(u+a)===Fl(i.anchorNode)||I(e,Yt,n);const c=n.length;bt&&c>1&&r.inputType==="insertCompositionText"&&!e.isComposing()&&(t.anchor.offset-=c),$n||Rr||Zs||!e.isComposing()||(Ar=0,ye(null))}else di(!1,e,n!==null?n:void 0),gr&&(ys(e,n||void 0),gr=!1);ke(),Cl(se())}),Gt=null}],["click",function(r,e){Ne(e,()=>{const t=q(),n=Oe(e._window),s=Kr();if(n){if(P(t)){const o=t.anchor,i=o.getNode();o.type==="element"&&o.offset===0&&t.isCollapsed()&&!Ce(i)&&ie().getChildrenSize()===1&&i.getTopLevelElementOrThrow().isEmpty()&&s!==null&&t.is(s)?(n.removeAllRanges(),t.dirty=!0):r.detail===3&&!t.isCollapsed()&&i!==t.focus.getNode()&&(B(i)?i.select(0):i.getParentOrThrow().select(0))}else if(r.pointerType==="touch"){const o=n.anchorNode;if(o!==null){const i=o.nodeType;(i===$r||i===Ct)&&et(xi(s,n,e,r))}}}I(e,ol,r)})}],["cut",lt],["copy",lt],["dragstart",lt],["dragover",lt],["dragend",lt],["paste",lt],["focus",lt],["blur",lt],["drop",lt]];xn&&Ms.push(["beforeinput",(r,e)=>function(t,n){const s=t.inputType,o=Kl(t);s==="deleteCompositionText"||bt&&Ll(n)||s!=="insertCompositionText"&&Ne(n,()=>{const i=q();if(s==="deleteContentBackward"){if(i===null){const h=Kr();if(!P(h))return;et(h.clone())}if(P(i)){const h=i.anchor.key===i.focus.key;if(l=t.timeStamp,zl==="MediaLast"&&l<Ar+Os&&n.isComposing()&&h){if(ye(null),Ar=0,setTimeout(()=>{Ne(n,()=>{ye(null)})},Os),P(i)){const p=i.anchor.getNode();p.markDirty(),i.format=p.getFormat(),M(p)||O(142),i.style=p.getStyle()}}else{ye(null),t.preventDefault();const p=i.anchor.getNode(),m=p.getTextContent(),x=p.canInsertTextAfter(),D=i.anchor.offset===0&&i.focus.offset===m.length;Ma&&h&&!D&&x||I(n,Tt,!0)}return}}var l;if(!P(i))return;const u=t.data;Gt!==null&&di(!1,n,Gt),i.dirty&&Gt===null||!i.isCollapsed()||Ce(i.anchor.getNode())||o===null||i.applyDOMRange(o),Gt=null;const a=i.anchor,c=i.focus,f=a.getNode(),d=c.getNode();if(s!=="insertText"&&s!=="insertTranspose")switch(t.preventDefault(),s){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":I(n,Yt,t);break;case"insertFromComposition":ye(null),I(n,Yt,t);break;case"insertLineBreak":ye(null),I(n,Qt,!1);break;case"insertParagraph":ye(null),kr&&!Rr?(kr=!1,I(n,Qt,!1)):I(n,Br,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":I(n,Mn,t);break;case"deleteByComposition":(function(h,p){return h!==p||B(h)||B(p)||!h.isToken()||!p.isToken()})(f,d)&&I(n,As,t);break;case"deleteByDrag":case"deleteByCut":I(n,As,t);break;case"deleteContent":I(n,Tt,!1);break;case"deleteWordBackward":I(n,Nr,!0);break;case"deleteWordForward":I(n,Nr,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":I(n,Fr,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":I(n,Fr,!1);break;case"formatStrikeThrough":I(n,We,"strikethrough");break;case"formatBold":I(n,We,"bold");break;case"formatItalic":I(n,We,"italic");break;case"formatUnderline":I(n,We,"underline");break;case"historyUndo":I(n,Qs,void 0);break;case"historyRedo":I(n,Ys,void 0)}else{if(u===`
|
|
64
|
-
`)t.preventDefault(),I(n,Qt,!1);else if(u===at)t.preventDefault(),I(n,Br,void 0);else if(u==null&&t.dataTransfer){const h=t.dataTransfer.getData("text/plain");t.preventDefault(),i.insertRawText(h)}else u!=null&&Wl(i,o,u,t.timeStamp,!0)?(t.preventDefault(),I(n,Yt,u)):Gt=u;ql=t.timeStamp}})}(r,e)]);let Ar=0,zl=null,ql=0,Gt=null;const Bn=new WeakMap;let Rs=!1,$s=!1,kr=!1,gr=!1,Ul=[0,"",0,"root",0];function Wl(r,e,t,n,s){const o=r.anchor,i=r.focus,l=o.getNode(),u=se(),a=Oe(u._window),c=a!==null?a.anchorNode:null,f=o.key,d=u.getElementByKey(f),h=t.length;return f!==i.key||!M(l)||(!s&&(!xn||ql<n+50)||l.isDirty()&&h<2||Bl(t))&&o.offset!==i.offset&&!l.isComposing()||kt(l)||l.isDirty()&&h>1||(s||!xn)&&d!==null&&!l.isComposing()&&c!==
|
|
65
|
-
`){const n=q();if(P(n)){const s=n.focus;return n.anchor.set(s.key,s.offset,s.type),void I(r,yn,null)}}}di(!0,r,e)}function Vl(r){let e=r.__lexicalEventHandles;return e===void 0&&(e=[],r.__lexicalEventHandles=e),e}const Xt=new Map;function Gl(r){const e=r.target,t=Oe(e==null?null:e.nodeType===9?e.defaultView:e.ownerDocument.defaultView);if(t===null)return;const n=El(t.anchorNode);if(n===null)return;$s&&($s=!1,Ne(n,()=>{const a=Kr(),c=t.anchorNode;if(c===null)return;const f=c.nodeType;f!==$r&&f!==
|
|
66
|
-
`}createDOM(){return document.createElement("br")}updateDOM(){return!1}static importDOM(){return{br:e=>function(t){const n=t.parentElement;if(n!==null&&An(n)){const s=n.firstChild;if(s===t||s.nextSibling===t&&on(s)){const o=n.lastChild;if(o===t||o.previousSibling===t&&on(o))return!0}}return!1}(e)||function(t){const n=t.parentElement;if(n!==null&&An(n)){const s=n.firstChild;if(s===t||s.nextSibling===t&&on(s))return!1;const o=n.lastChild;if(o===t||o.previousSibling===t&&on(o))return!0}return!1}(e)?null:{conversion:xc,priority:0}}}static importJSON(e){return Pt()}exportJSON(){return{type:"linebreak",version:1}}}function xc(r){return{node:Pt()}}function Pt(){return st(new qr)}function Nt(r){return r instanceof qr}function on(r){return r.nodeType===
|
|
63
|
+
`,qa=bt?" ":In,_l="֑-߿יִ-﷽ﹰ-ﻼ",bl="A-Za-zÀ-ÖØ-öø-ʸ̀-ࠀ-Ⰰ-︀--",Ua=new RegExp("^[^"+bl+"]*["+_l+"]"),Wa=new RegExp("^[^"+_l+"]*["+bl+"]"),Lt={bold:1,code:16,highlight:ei,italic:2,strikethrough:_n,subscript:32,superscript:64,underline:bn},Ka={directionless:1,unmergeable:2},qi={center:ri,end:oi,justify:si,left:ti,right:ni,start:ii},Va={[ri]:"center",[oi]:"end",[si]:"justify",[ti]:"left",[ni]:"right",[ii]:"start"},Ga={normal:0,segmented:2,token:1},Ha={[Ra]:"normal",[Ia]:"segmented",[$a]:"token"};function Ja(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var O=Ja(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function vn(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}const Qa=100;let Ss=!1,li=0;function Ya(r){li=r.timeStamp}function hs(r,e,t){const n=r.nodeName==="BR",s=e.__lexicalLineBreak;return s&&(r===s||n&&r.previousSibling===s)||n&&qn(r,t)!==void 0}function Xa(r,e,t){const n=Oe(t._window);let s=null,o=null;n!==null&&n.anchorNode===r&&(s=n.anchorOffset,o=n.focusOffset);const i=r.nodeValue;i!==null&&fi(e,i,s,o,!1)}function Za(r,e,t){if(P(r)){const n=r.anchor.getNode();if(n.is(t)&&r.format!==n.getFormat())return!1}return e.nodeType===Dt&&t.isAttached()}function ec(r,e,t,n){for(let s=r;s&&!hc(s);s=zr(s)){const o=qn(s,e);if(o!==void 0){const i=_e(o,t);if(i)return Z(i)?void 0:[s,i]}else if(s===n)return[n,Tl(t)]}}function vl(r,e,t){Ss=!0;const n=performance.now()-li>Qa;try{Ne(r,()=>{const s=q()||function(d){return d.getEditorState().read(()=>{const h=q();return h!==null?h.clone():null})}(r),o=new Map,i=r.getRootElement(),l=r._editorState,u=r._blockCursorElement;let a=!1,c="";for(let d=0;d<e.length;d++){const h=e[d],p=h.type,m=h.target,x=ec(m,r,l,i);if(!x)continue;const[C,_]=x;if(p==="characterData")n&&M(_)&&Za(s,m,_)&&Xa(m,_,r);else if(p==="childList"){a=!0;const E=h.addedNodes;for(let v=0;v<E.length;v++){const b=E[v],w=kl(b),S=b.parentNode;if(S!=null&&b!==u&&w===null&&!hs(b,S,r)){if(bt){const R=b.innerText||b.nodeValue;R&&(c+=R)}S.removeChild(b)}}const D=h.removedNodes,A=D.length;if(A>0){let v=0;for(let b=0;b<A;b++){const w=D[b];(hs(w,m,r)||u===w)&&(m.appendChild(w),v++)}A!==v&&o.set(C,_)}}}if(o.size>0)for(const[d,h]of o)h.reconcileObservedMutation(d,r);const f=t.takeRecords();if(f.length>0){for(let d=0;d<f.length;d++){const h=f[d],p=h.addedNodes,m=h.target;for(let x=0;x<p.length;x++){const C=p[x],_=C.parentNode;_==null||C.nodeName!=="BR"||hs(C,m,r)||_.removeChild(C)}}t.takeRecords()}s!==null&&(a&&(s.dirty=!0,et(s)),bt&&Ll(r)&&s.insertRawText(c))})}finally{Ss=!1}}function Dl(r){const e=r._observer;e!==null&&vl(r,e.takeRecords(),e)}function Cl(r){(function(e){li===0&&Wn(e).addEventListener("textInput",Ya,!0)})(r),r._observer=new MutationObserver((e,t)=>{vl(r,e,t)})}function Ui(r,e){const t=r.__mode,n=r.__format,s=r.__style,o=e.__mode,i=e.__format,l=e.__style;return!(t!==null&&t!==o||n!==null&&n!==i||s!==null&&s!==l)}function Wi(r,e){const t=r.mergeWithSibling(e),n=se()._normalizedNodes;return n.add(r.__key),n.add(e.__key),t}function Ki(r){let e,t,n=r;if(n.__text!==""||!n.isSimpleText()||n.isUnmergeable()){for(;(e=n.getPreviousSibling())!==null&&M(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(e.__text!==""){if(Ui(e,n)){n=Wi(e,n);break}break}e.remove()}for(;(t=n.getNextSibling())!==null&&M(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==""){if(Ui(n,t)){n=Wi(n,t);break}break}t.remove()}}else n.remove()}function wl(r){return Vi(r.anchor),Vi(r.focus),r}function Vi(r){for(;r.type==="element";){const e=r.getNode(),t=r.offset;let n,s;if(t===e.getChildrenSize()?(n=e.getChildAtIndex(t-1),s=!0):(n=e.getChildAtIndex(t),s=!1),M(n)){r.set(n.__key,s?n.getTextContentSize():0,"text");break}if(!B(n))break;r.set(n.__key,s?n.getChildrenSize():0,"element")}}let tc=1;const rc=typeof queueMicrotask=="function"?queueMicrotask:r=>{Promise.resolve().then(r)};function ui(r){const e=document.activeElement;if(e===null)return!1;const t=e.nodeName;return Z(tr(r))&&(t==="INPUT"||t==="TEXTAREA"||e.contentEditable==="true"&&zn(e)==null)}function Ir(r,e,t){const n=r.getRootElement();try{return n!==null&&n.contains(e)&&n.contains(t)&&e!==null&&!ui(e)&&El(e)===r}catch{return!1}}function ai(r){return r instanceof Jn}function El(r){let e=r;for(;e!=null;){const t=zn(e);if(ai(t))return t;e=zr(e)}return null}function zn(r){return r?r.__lexicalEditor:null}function kt(r){return r.isToken()||r.isSegmented()}function nc(r){return r.nodeType===Dt}function Dn(r){let e=r;for(;e!=null;){if(nc(e))return e;e=e.firstChild}return null}function Cn(r,e,t){const n=Lt[e];if(t!==null&&(r&n)==(t&n))return r;let s=r^n;return e==="subscript"?s&=-65:e==="superscript"&&(s&=-33),s}function Al(r){return M(r)||Nt(r)||Z(r)}function sc(r,e){if(e!=null)return void(r.__key=e);ke(),eu();const t=se(),n=dt(),s=""+tc++;n._nodeMap.set(s,r),B(r)?t._dirtyElements.set(s,!0):t._dirtyLeaves.add(s),t._cloneNotNeeded.add(s),t._dirtyType=xl,r.__key=s}function Bt(r){const e=r.getParent();if(e!==null){const t=r.getWritable(),n=e.getWritable(),s=r.getPreviousSibling(),o=r.getNextSibling();if(s===null)if(o!==null){const i=o.getWritable();n.__first=o.__key,i.__prev=null}else n.__first=null;else{const i=s.getWritable();if(o!==null){const l=o.getWritable();l.__prev=i.__key,i.__next=l.__key}else i.__next=null;t.__prev=null}if(o===null)if(s!==null){const i=s.getWritable();n.__last=s.__key,i.__next=null}else n.__last=null;else{const i=o.getWritable();if(s!==null){const l=s.getWritable();l.__next=i.__key,i.__prev=l.__key}else i.__prev=null;t.__next=null}n.__size--,t.__parent=null}}function wn(r){eu();const e=r.getLatest(),t=e.__parent,n=dt(),s=se(),o=n._nodeMap,i=s._dirtyElements;t!==null&&function(u,a,c){let f=u;for(;f!==null;){if(c.has(f))return;const d=a.get(f);if(d===void 0)break;c.set(f,!1),f=d.__parent}}(t,o,i);const l=e.__key;s._dirtyType=xl,B(r)?i.set(l,!0):s._dirtyLeaves.add(l)}function ye(r){ke();const e=se(),t=e._compositionKey;if(r!==t){if(e._compositionKey=r,t!==null){const n=_e(t);n!==null&&n.getWritable()}if(r!==null){const n=_e(r);n!==null&&n.getWritable()}}}function yt(){return Vr()?null:se()._compositionKey}function _e(r,e){const t=(e||dt())._nodeMap.get(r);return t===void 0?null:t}function kl(r,e){const t=qn(r,se());return t!==void 0?_e(t,e):null}function qn(r,e){return r[`__lexicalKey_${e._key}`]}function tr(r,e){let t=r;for(;t!=null;){const n=kl(t,e);if(n!==null)return n;t=zr(t)}return null}function Sl(r){const e=r._decorators,t=Object.assign({},e);return r._pendingDecorators=t,t}function Gi(r){return r.read(()=>ie().getTextContent())}function ie(){return Tl(dt())}function Tl(r){return r._nodeMap.get("root")}function et(r){ke();const e=dt();r!==null&&(r.dirty=!0,r.setCachedNodes(null)),e._selection=r}function Ht(r){const e=se(),t=function(n,s){let o=n;for(;o!=null;){const i=qn(o,s);if(i!==void 0)return i;o=zr(o)}return null}(r,e);return t===null?r===e.getRootElement()?_e("root"):null:_e(t)}function Hi(r,e){return e?r.getTextContentSize():0}function Bl(r){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(r)}function ci(r){const e=[];let t=r;for(;t!==null;)e.push(t),t=t._parentEditor;return e}function Nl(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function Fl(r){return r.nodeType===Dt?r.nodeValue:null}function di(r,e,t){const n=Oe(e._window);if(n===null)return;const s=n.anchorNode;let{anchorOffset:o,focusOffset:i}=n;if(s!==null){let l=Fl(s);const u=tr(s);if(l!==null&&M(u)){if(l===In&&t){const a=t.length;l=t,o=a,i=a}l!==null&&fi(u,l,o,i,r)}}}function fi(r,e,t,n,s){let o=r;if(o.isAttached()&&(s||!o.isDirty())){const i=o.isComposing();let l=e;(i||s)&&e[e.length-1]===In&&(l=e.slice(0,-1));const u=o.getTextContent();if(s||l!==u){if(l===""){if(ye(null),$n||Rr||Zs)o.remove();else{const m=se();setTimeout(()=>{m.update(()=>{o.isAttached()&&o.remove()})},20)}return}const a=o.getParent(),c=Kr(),f=o.getTextContentSize(),d=yt(),h=o.getKey();if(o.isToken()||d!==null&&h===d&&!i||P(c)&&(a!==null&&!a.canInsertTextBefore()&&c.anchor.offset===0||c.anchor.key===r.__key&&c.anchor.offset===0&&!o.canInsertTextBefore()&&!i||c.focus.key===r.__key&&c.focus.offset===f&&!o.canInsertTextAfter()&&!i))return void o.markDirty();const p=q();if(!P(p)||t===null||n===null)return void o.setTextContent(l);if(p.setTextNodeRange(o,t,o,n),o.isSegmented()){const m=pe(o.getTextContent());o.replace(m),o=m}o.setTextContent(l)}}}function ic(r,e){if(e.isSegmented())return!0;if(!r.isCollapsed())return!1;const t=r.anchor.offset,n=e.getParentOrThrow(),s=e.isToken();return t===0?!e.canInsertTextBefore()||!n.canInsertTextBefore()&&!e.isComposing()||s||function(o){const i=o.getPreviousSibling();return(M(i)||B(i)&&i.isInline())&&!i.canInsertTextAfter()}(e):t===e.getTextContentSize()&&(!e.canInsertTextAfter()||!n.canInsertTextAfter()&&!e.isComposing()||s)}function Ji(r){return r==="ArrowLeft"}function Qi(r){return r==="ArrowRight"}function xr(r,e){return ze?r:e}function Yi(r){return r==="Enter"}function fr(r){return r==="Backspace"}function hr(r){return r==="Delete"}function Xi(r,e,t){return r.toLowerCase()==="a"&&xr(e,t)}function oc(){const r=ie();et(wl(r.select(0,r.getChildrenSize())))}function wr(r,e){r.__lexicalClassNameCache===void 0&&(r.__lexicalClassNameCache={});const t=r.__lexicalClassNameCache,n=t[e];if(n!==void 0)return n;const s=r[e];if(typeof s=="string"){const o=vn(s);return t[e]=o,o}return s}function hi(r,e,t,n,s){if(t.size===0)return;const o=n.__type,i=n.__key,l=e.get(o);l===void 0&&O(33,o);const u=l.klass;let a=r.get(u);a===void 0&&(a=new Map,r.set(u,a));const c=a.get(i),f=c==="destroyed"&&s==="created";(c===void 0||f)&&a.set(i,f?"updated":s)}function Zi(r,e,t){const n=r.getParent();let s=t,o=r;return n!==null&&(e&&t===0?(s=o.getIndexWithinParent(),o=n):e||t!==o.getChildrenSize()||(s=o.getIndexWithinParent()+1,o=n)),o.getChildAtIndex(e?s-1:s)}function Lr(r,e){const t=r.offset;if(r.type==="element")return Zi(r.getNode(),e,t);{const n=r.getNode();if(e&&t===0||!e&&t===n.getTextContentSize()){const s=e?n.getPreviousSibling():n.getNextSibling();return s===null?Zi(n.getParentOrThrow(),e,n.getIndexWithinParent()+(e?0:1)):s}}return null}function Ll(r){const e=Wn(r).event,t=e&&e.inputType;return t==="insertFromPaste"||t==="insertFromPasteAsQuotation"}function I(r,e,t){return nu(r,e,t)}function Un(r){return!De(r)&&!r.isLastChild()&&!r.isInline()}function En(r,e){const t=r._keyToDOMMap.get(e);return t===void 0&&O(75,e),t}function zr(r){const e=r.assignedSlot||r.parentElement;return e!==null&&e.nodeType===11?e.host:e}function Er(r,e){let t=r.getParent();for(;t!==null;){if(t.is(e))return!0;t=t.getParent()}return!1}function Wn(r){const e=r._window;return e===null&&O(78),e}function lc(r){let e=r.getParentOrThrow();for(;e!==null;){if(tt(e))return e;e=e.getParentOrThrow()}return e}function tt(r){return De(r)||B(r)&&r.isShadowRoot()}function st(r){const e=se(),t=r.constructor.getType(),n=e._nodes.get(t);n===void 0&&O(200,r.constructor.name,t);const{replace:s,replaceWithKlass:o}=n;if(s!==null){const i=s(r),l=i.constructor;return o!==null?i instanceof o||O(201,o.name,o.getType(),l.name,l.getType(),r.constructor.name,t):i instanceof r.constructor&&l!==r.constructor||O(202,l.name,l.getType(),r.constructor.name,t),i.__key===r.__key&&O(203,r.constructor.name,t,l.name,l.getType()),i}return r}function ps(r,e){!De(r.getParent())||B(e)||Z(e)||O(99)}function gs(r){return(Z(r)||B(r)&&!r.canBeEmpty())&&!r.isInline()}function pi(r,e,t){t.style.removeProperty("caret-color"),e._blockCursorElement=null;const n=r.parentElement;n!==null&&n.removeChild(r)}function uc(r,e,t){let n=r._blockCursorElement;if(P(t)&&t.isCollapsed()&&t.anchor.type==="element"&&e.contains(document.activeElement)){const s=t.anchor,o=s.getNode(),i=s.offset;let l=!1,u=null;if(i===o.getChildrenSize())gs(o.getChildAtIndex(i-1))&&(l=!0);else{const a=o.getChildAtIndex(i);if(a!==null&&gs(a)){const c=a.getPreviousSibling();(c===null||gs(c))&&(l=!0,u=r.getElementByKey(a.__key))}}if(l){const a=r.getElementByKey(o.__key);return n===null&&(r._blockCursorElement=n=function(c){const f=c.theme,d=document.createElement("div");d.contentEditable="false",d.setAttribute("data-lexical-cursor","true");let h=f.blockCursor;if(h!==void 0){if(typeof h=="string"){const p=vn(h);h=f.blockCursor=p}h!==void 0&&d.classList.add(...h)}return d}(r._config)),e.style.caretColor="transparent",void(u===null?a.appendChild(n):a.insertBefore(n,u))}}n!==null&&pi(n,r,e)}function Oe(r){return Ve?(r||window).getSelection():null}function ac(r){return ct(r)&&r.tagName==="A"}function ct(r){return r.nodeType===1}function eo(r){return r.nodeType===11}function Ts(r){const e=new RegExp(/^(a|abbr|acronym|b|cite|code|del|em|i|ins|kbd|label|output|q|ruby|s|samp|span|strong|sub|sup|time|u|tt|var|#text)$/,"i");return r.nodeName.match(e)!==null}function An(r){const e=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 r.nodeName.match(e)!==null}function gt(r){if(Z(r)&&!r.isInline())return!0;if(!B(r)||tt(r))return!1;const e=r.getFirstChild(),t=e===null||Nt(e)||M(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function pr(r,e){let t=r;for(;t!==null&&t.getParent()!==null&&!e(t);)t=t.getParentOrThrow();return e(t)?t:null}function cc(){return se()}const to=new WeakMap,dc=new Map;function fc(r){if(!r._readOnly&&r.isEmpty())return dc;r._readOnly||O(192);let e=to.get(r);if(!e){e=new Map,to.set(r,e);for(const[t,n]of r._nodeMap){const s=n.__type;let o=e.get(s);o||(o=new Map,e.set(s,o)),o.set(t,n)}}return e}function gi(r){const e=r.constructor.clone(r);return e.afterCloneFrom(r),e}function mi(r,e){const t=(parseInt(r.style.paddingInlineStart,10)||0)/40;e.setIndent(t)}function hc(r){return r.__lexicalUnmanaged===!0}function jl(r,e,t,n,s,o){let i=r.getFirstChild();for(;i!==null;){const l=i.__key;i.__parent===e&&(B(i)&&jl(i,l,t,n,s,o),t.has(l)||o.delete(l),s.push(l)),i=i.getNextSibling()}}let vt,Ce,jr,Kn,Bs,Ns,jt,Ke,Fs,Pr,de="",ve="",Qe=null,qe="",ut="",Pl=!1,Or=!1,hn=null;function kn(r,e){const t=jt.get(r);if(e!==null){const n=Ps(r);n.parentNode===e&&e.removeChild(n)}if(Ke.has(r)||Ce._keyToDOMMap.delete(r),B(t)){const n=Tn(t,jt);Ls(n,0,n.length-1,null)}t!==void 0&&hi(Pr,jr,Kn,t,"destroyed")}function Ls(r,e,t,n){let s=e;for(;s<=t;++s){const o=r[s];o!==void 0&&kn(o,n)}}function At(r,e){r.setProperty("text-align",e)}const pc="40px";function Ol(r,e){const t=vt.theme.indent;if(typeof t=="string"){const s=r.classList.contains(t);e>0&&!s?r.classList.add(t):e<1&&s&&r.classList.remove(t)}const n=getComputedStyle(r).getPropertyValue("--lexical-indent-base-value")||pc;r.style.setProperty("padding-inline-start",e===0?"":`calc(${e} * ${n})`)}function Ml(r,e){const t=r.style;e===0?At(t,""):e===ti?At(t,"left"):e===ri?At(t,"center"):e===ni?At(t,"right"):e===si?At(t,"justify"):e===ii?At(t,"start"):e===oi&&At(t,"end")}function Sn(r,e){const t=Ke.get(r);t===void 0&&O(60);const n=t.createDOM(vt,Ce);if(function(s,o,i){const l=i._keyToDOMMap;(function(u,a,c){u[`__lexicalKey_${a._key}`]=c})(o,i,s),l.set(s,o)}(r,n,Ce),M(t)?n.setAttribute("data-lexical-text","true"):Z(t)&&n.setAttribute("data-lexical-decorator","true"),B(t)){const s=t.__indent,o=t.__size;if(s!==0&&Ol(n,s),o!==0){const l=o-1;(function(u,a,c,f){const d=ve;ve="",js(u,c,0,a,c.getDOMSlot(f)),$l(c,f),ve=d})(Tn(t,Ke),l,t,n)}const i=t.__format;i!==0&&Ml(n,i),t.isInline()||Rl(null,t,n),Un(t)&&(de+=at,ut+=at)}else{const s=t.getTextContent();if(Z(t)){const o=t.decorate(Ce,vt);o!==null&&Il(r,o),n.contentEditable="false"}else M(t)&&(t.isDirectionless()||(ve+=s));de+=s,ut+=s}return e!==null&&e.insertChild(n),hi(Pr,jr,Kn,t,"created"),n}function js(r,e,t,n,s){const o=de;de="";let i=t;for(;i<=n;++i){Sn(r[i],s);const l=Ke.get(r[i]);l!==null&&M(l)&&(Qe===null&&(Qe=l.getFormat()),qe===""&&(qe=l.getStyle()))}Un(e)&&(de+=at),s.element.__lexicalTextContent=de,de=o+de}function ro(r,e){if(r){const t=r.__last;if(t){const n=e.get(t);if(n)return Nt(n)?"line-break":Z(n)&&n.isInline()?"decorator":null}return"empty"}return null}function Rl(r,e,t){const n=ro(r,jt),s=ro(e,Ke);n!==s&&e.getDOMSlot(t).setManagedLineBreak(s)}function $l(r,e){const t=e.__lexicalDirTextContent||"",n=e.__lexicalDir||"";if(t!==ve||n!==hn){const o=ve==="",i=o?hn:(s=ve,Ua.test(s)?"rtl":Wa.test(s)?"ltr":null);if(i!==n){const l=e.classList,u=vt.theme;let a=n!==null?u[n]:void 0,c=i!==null?u[i]:void 0;if(a!==void 0){if(typeof a=="string"){const f=vn(a);a=u[n]=f}l.remove(...a)}if(i===null||o&&i==="ltr")e.removeAttribute("dir");else{if(c!==void 0){if(typeof c=="string"){const f=vn(c);c=u[i]=f}c!==void 0&&l.add(...c)}e.dir=i}Or||(r.getWritable().__dir=i)}hn=i,e.__lexicalDirTextContent=ve,e.__lexicalDir=i}var s}function gc(r,e,t){const n=ve;var s;ve="",Qe=null,qe="",function(o,i,l){const u=de,a=o.__size,c=i.__size;de="";const f=l.element;if(a===1&&c===1){const d=o.__first,h=i.__first;if(d===h)_r(d,f);else{const m=Ps(d),x=Sn(h,null);try{f.replaceChild(x,m)}catch(C){if(typeof C=="object"&&C!=null){const _=`${C.toString()} Parent: ${f.tagName}, new child: {tag: ${x.tagName} key: ${h}}, old child: {tag: ${m.tagName}, key: ${d}}.`;throw new Error(_)}throw C}kn(d,null)}const p=Ke.get(h);M(p)&&(Qe===null&&(Qe=p.getFormat()),qe===""&&(qe=p.getStyle()))}else{const d=Tn(o,jt),h=Tn(i,Ke);if(d.length!==a&&O(227),h.length!==c&&O(228),a===0)c!==0&&js(h,i,0,c-1,l);else if(c===0){if(a!==0){const p=l.after==null&&l.before==null&&l.element.__lexicalLineBreak==null;Ls(d,0,a-1,p?null:f),p&&(f.textContent="")}}else(function(p,m,x,C,_,E){const D=C-1,A=_-1;let v,b,w=E.getFirstChild(),S=0,R=0;for(;S<=D&&R<=A;){const j=m[S],L=x[R];if(j===L)w=ms(_r(L,E.element)),S++,R++;else{v===void 0&&(v=new Set(m)),b===void 0&&(b=new Set(x));const H=b.has(j),ue=v.has(L);if(H)if(ue){const re=En(Ce,L);re===w?w=ms(_r(L,E.element)):(E.withBefore(w).insertChild(re),_r(L,E.element)),S++,R++}else Sn(L,E.withBefore(w)),R++;else w=ms(Ps(j)),kn(j,E.element),S++}const $=Ke.get(L);$!==null&&M($)&&(Qe===null&&(Qe=$.getFormat()),qe===""&&(qe=$.getStyle()))}const T=S>D,N=R>A;if(T&&!N){const j=x[A+1],L=j===void 0?null:Ce.getElementByKey(j);js(x,p,R,A,E.withBefore(L))}else N&&!T&&Ls(m,S,D,E.element)})(i,d,h,a,c,l)}Un(i)&&(de+=at),f.__lexicalTextContent=de,de=u+de}(r,e,e.getDOMSlot(t)),$l(e,t),rr(s=e)&&Qe!=null&&Qe!==s.__textFormat&&!Or&&(s.setTextFormat(Qe),s.setTextStyle(qe)),function(o){rr(o)&&qe!==""&&qe!==o.__textStyle&&!Or&&o.setTextStyle(qe)}(e),ve=n}function Tn(r,e){const t=[];let n=r.__first;for(;n!==null;){const s=e.get(n);s===void 0&&O(101),t.push(n),n=s.__next}return t}function _r(r,e){const t=jt.get(r);let n=Ke.get(r);t!==void 0&&n!==void 0||O(61);const s=Pl||Ns.has(r)||Bs.has(r),o=En(Ce,r);if(t===n&&!s){if(B(t)){const i=o.__lexicalTextContent;i!==void 0&&(de+=i,ut+=i);const l=o.__lexicalDirTextContent;l!==void 0&&(ve+=l)}else{const i=t.getTextContent();M(t)&&!t.isDirectionless()&&(ve+=i),ut+=i,de+=i}return o}if(t!==n&&s&&hi(Pr,jr,Kn,n,"updated"),n.updateDOM(t,o,vt)){const i=Sn(r,null);return e===null&&O(62),e.replaceChild(i,o),kn(r,null),i}if(B(t)&&B(n)){const i=n.__indent;i!==t.__indent&&Ol(o,i);const l=n.__format;l!==t.__format&&Ml(o,l),s&&(gc(t,n,o),De(n)||n.isInline()||Rl(t,n,o)),Un(n)&&(de+=at,ut+=at)}else{const i=n.getTextContent();if(Z(n)){const l=n.decorate(Ce,vt);l!==null&&Il(r,l)}else M(n)&&!n.isDirectionless()&&(ve+=i);de+=i,ut+=i}if(!Or&&De(n)&&n.__cachedText!==ut){const i=n.getWritable();i.__cachedText=ut,n=i}return o}function Il(r,e){let t=Ce._pendingDecorators;const n=Ce._decorators;if(t===null){if(n[r]===e)return;t=Sl(Ce)}t[r]=e}function ms(r){let e=r.nextSibling;return e!==null&&e===Ce._blockCursorElement&&(e=e.nextSibling),e}function mc(r,e,t,n,s,o){de="",ut="",ve="",Pl=n===er,hn=null,Ce=t,vt=t._config,jr=t._nodes,Kn=Ce._listeners.mutation,Bs=s,Ns=o,jt=r._nodeMap,Ke=e._nodeMap,Or=e._readOnly,Fs=new Map(t._keyToDOMMap);const i=new Map;return Pr=i,_r("root",null),Ce=void 0,jr=void 0,Bs=void 0,Ns=void 0,jt=void 0,Ke=void 0,vt=void 0,Fs=void 0,Pr=void 0,i}function Ps(r){const e=Fs.get(r);return e===void 0&&O(75,r),e}const lt=Object.freeze({}),Os=30,Ms=[["keydown",function(r,e){if(Ar=r.timeStamp,zl=r.key,e.isComposing())return;const{key:t,shiftKey:n,ctrlKey:s,metaKey:o,altKey:i}=r;if(!I(e,va,r)&&t!=null){if(function(l,u,a,c){return Qi(l)&&!u&&!c&&!a}(t,s,i,o))I(e,ll,r);else if(function(l,u,a,c,f){return Qi(l)&&!c&&!a&&(u||f)}(t,s,n,i,o))I(e,Da,r);else if(function(l,u,a,c){return Ji(l)&&!u&&!c&&!a}(t,s,i,o))I(e,ul,r);else if(function(l,u,a,c,f){return Ji(l)&&!c&&!a&&(u||f)}(t,s,n,i,o))I(e,Ca,r);else if(function(l,u,a){return function(c){return c==="ArrowUp"}(l)&&!u&&!a}(t,s,o))I(e,al,r);else if(function(l,u,a){return function(c){return c==="ArrowDown"}(l)&&!u&&!a}(t,s,o))I(e,cl,r);else if(function(l,u){return Yi(l)&&u}(t,n))kr=!0,I(e,yn,r);else if(function(l){return l===" "}(t))I(e,wa,r);else if(function(l,u){return ze&&u&&l.toLowerCase()==="o"}(t,s))r.preventDefault(),kr=!0,I(e,Qt,!0);else if(function(l,u){return Yi(l)&&!u}(t,n))kr=!1,I(e,yn,r);else if(function(l,u,a,c){return ze?!u&&!a&&(fr(l)||l.toLowerCase()==="h"&&c):!(c||u||a)&&fr(l)}(t,i,o,s))fr(t)?I(e,dl,r):(r.preventDefault(),I(e,Tt,!0));else if(function(l){return l==="Escape"}(t))I(e,fl,r);else if(function(l,u,a,c,f){return ze?!(a||c||f)&&(hr(l)||l.toLowerCase()==="d"&&u):!(u||c||f)&&hr(l)}(t,s,n,i,o))hr(t)?I(e,hl,r):(r.preventDefault(),I(e,Tt,!1));else if(function(l,u,a){return fr(l)&&(ze?u:a)}(t,i,s))r.preventDefault(),I(e,Nr,!0);else if(function(l,u,a){return hr(l)&&(ze?u:a)}(t,i,s))r.preventDefault(),I(e,Nr,!1);else if(function(l,u){return ze&&u&&fr(l)}(t,o))r.preventDefault(),I(e,Fr,!0);else if(function(l,u){return ze&&u&&hr(l)}(t,o))r.preventDefault(),I(e,Fr,!1);else if(function(l,u,a,c){return l.toLowerCase()==="b"&&!u&&xr(a,c)}(t,i,o,s))r.preventDefault(),I(e,We,"bold");else if(function(l,u,a,c){return l.toLowerCase()==="u"&&!u&&xr(a,c)}(t,i,o,s))r.preventDefault(),I(e,We,"underline");else if(function(l,u,a,c){return l.toLowerCase()==="i"&&!u&&xr(a,c)}(t,i,o,s))r.preventDefault(),I(e,We,"italic");else if(function(l,u,a,c){return l==="Tab"&&!u&&!a&&!c}(t,i,s,o))I(e,Ea,r);else if(function(l,u,a,c){return l.toLowerCase()==="z"&&!u&&xr(a,c)}(t,n,o,s))r.preventDefault(),I(e,Qs,void 0);else if(function(l,u,a,c){return ze?l.toLowerCase()==="z"&&a&&u:l.toLowerCase()==="y"&&c||l.toLowerCase()==="z"&&c&&u}(t,n,o,s))r.preventDefault(),I(e,Ys,void 0);else{const l=e._editorState._selection;l===null||P(l)?!bt&&Xi(t,o,s)&&(r.preventDefault(),I(e,ks,r)):function(u,a,c,f){return!a&&u.toLowerCase()==="c"&&(ze?c:f)}(t,n,o,s)?(r.preventDefault(),I(e,Rn,r)):function(u,a,c,f){return!a&&u.toLowerCase()==="x"&&(ze?c:f)}(t,n,o,s)?(r.preventDefault(),I(e,Xs,r)):Xi(t,o,s)&&(r.preventDefault(),I(e,ks,r))}(function(l,u,a,c){return l||u||a||c})(s,n,i,o)&&I(e,ja,r)}}],["pointerdown",function(r,e){const t=r.target,n=r.pointerType;t instanceof Node&&n!=="touch"&&Ne(e,()=>{Z(tr(t))||($s=!0)})}],["compositionstart",function(r,e){Ne(e,()=>{const t=q();if(P(t)&&!e.isComposing()){const n=t.anchor,s=t.anchor.getNode();ye(n.key),(r.timeStamp<Ar+Os||n.type==="element"||!t.isCollapsed()||s.getFormat()!==t.format||M(s)&&s.getStyle()!==t.style)&&I(e,Yt,qa)}})}],["compositionend",function(r,e){bt?gr=!0:Ne(e,()=>{ys(e,r.data)})}],["input",function(r,e){r.stopPropagation(),Ne(e,()=>{const t=q(),n=r.data,s=Kl(r);if(n!=null&&P(t)&&Wl(t,s,n,r.timeStamp,!1)){gr&&(ys(e,n),gr=!1);const o=t.anchor.getNode(),i=Oe(e._window);if(i===null)return;const l=t.isBackward(),u=l?t.anchor.offset:t.focus.offset,a=l?t.focus.offset:t.anchor.offset;xn&&!t.isCollapsed()&&M(o)&&i.anchorNode!==null&&o.getTextContent().slice(0,u)+n+o.getTextContent().slice(u+a)===Fl(i.anchorNode)||I(e,Yt,n);const c=n.length;bt&&c>1&&r.inputType==="insertCompositionText"&&!e.isComposing()&&(t.anchor.offset-=c),$n||Rr||Zs||!e.isComposing()||(Ar=0,ye(null))}else di(!1,e,n!==null?n:void 0),gr&&(ys(e,n||void 0),gr=!1);ke(),Dl(se())}),Gt=null}],["click",function(r,e){Ne(e,()=>{const t=q(),n=Oe(e._window),s=Kr();if(n){if(P(t)){const o=t.anchor,i=o.getNode();o.type==="element"&&o.offset===0&&t.isCollapsed()&&!De(i)&&ie().getChildrenSize()===1&&i.getTopLevelElementOrThrow().isEmpty()&&s!==null&&t.is(s)?(n.removeAllRanges(),t.dirty=!0):r.detail===3&&!t.isCollapsed()&&i!==t.focus.getNode()&&(B(i)?i.select(0):i.getParentOrThrow().select(0))}else if(r.pointerType==="touch"){const o=n.anchorNode;if(o!==null){const i=o.nodeType;(i===$r||i===Dt)&&et(xi(s,n,e,r))}}}I(e,ol,r)})}],["cut",lt],["copy",lt],["dragstart",lt],["dragover",lt],["dragend",lt],["paste",lt],["focus",lt],["blur",lt],["drop",lt]];xn&&Ms.push(["beforeinput",(r,e)=>function(t,n){const s=t.inputType,o=Kl(t);s==="deleteCompositionText"||bt&&Ll(n)||s!=="insertCompositionText"&&Ne(n,()=>{const i=q();if(s==="deleteContentBackward"){if(i===null){const h=Kr();if(!P(h))return;et(h.clone())}if(P(i)){const h=i.anchor.key===i.focus.key;if(l=t.timeStamp,zl==="MediaLast"&&l<Ar+Os&&n.isComposing()&&h){if(ye(null),Ar=0,setTimeout(()=>{Ne(n,()=>{ye(null)})},Os),P(i)){const p=i.anchor.getNode();p.markDirty(),i.format=p.getFormat(),M(p)||O(142),i.style=p.getStyle()}}else{ye(null),t.preventDefault();const p=i.anchor.getNode(),m=p.getTextContent(),x=p.canInsertTextAfter(),C=i.anchor.offset===0&&i.focus.offset===m.length;Ma&&h&&!C&&x||I(n,Tt,!0)}return}}var l;if(!P(i))return;const u=t.data;Gt!==null&&di(!1,n,Gt),i.dirty&&Gt===null||!i.isCollapsed()||De(i.anchor.getNode())||o===null||i.applyDOMRange(o),Gt=null;const a=i.anchor,c=i.focus,f=a.getNode(),d=c.getNode();if(s!=="insertText"&&s!=="insertTranspose")switch(t.preventDefault(),s){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":I(n,Yt,t);break;case"insertFromComposition":ye(null),I(n,Yt,t);break;case"insertLineBreak":ye(null),I(n,Qt,!1);break;case"insertParagraph":ye(null),kr&&!Rr?(kr=!1,I(n,Qt,!1)):I(n,Br,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":I(n,Mn,t);break;case"deleteByComposition":(function(h,p){return h!==p||B(h)||B(p)||!h.isToken()||!p.isToken()})(f,d)&&I(n,As,t);break;case"deleteByDrag":case"deleteByCut":I(n,As,t);break;case"deleteContent":I(n,Tt,!1);break;case"deleteWordBackward":I(n,Nr,!0);break;case"deleteWordForward":I(n,Nr,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":I(n,Fr,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":I(n,Fr,!1);break;case"formatStrikeThrough":I(n,We,"strikethrough");break;case"formatBold":I(n,We,"bold");break;case"formatItalic":I(n,We,"italic");break;case"formatUnderline":I(n,We,"underline");break;case"historyUndo":I(n,Qs,void 0);break;case"historyRedo":I(n,Ys,void 0)}else{if(u===`
|
|
64
|
+
`)t.preventDefault(),I(n,Qt,!1);else if(u===at)t.preventDefault(),I(n,Br,void 0);else if(u==null&&t.dataTransfer){const h=t.dataTransfer.getData("text/plain");t.preventDefault(),i.insertRawText(h)}else u!=null&&Wl(i,o,u,t.timeStamp,!0)?(t.preventDefault(),I(n,Yt,u)):Gt=u;ql=t.timeStamp}})}(r,e)]);let Ar=0,zl=null,ql=0,Gt=null;const Bn=new WeakMap;let Rs=!1,$s=!1,kr=!1,gr=!1,Ul=[0,"",0,"root",0];function Wl(r,e,t,n,s){const o=r.anchor,i=r.focus,l=o.getNode(),u=se(),a=Oe(u._window),c=a!==null?a.anchorNode:null,f=o.key,d=u.getElementByKey(f),h=t.length;return f!==i.key||!M(l)||(!s&&(!xn||ql<n+50)||l.isDirty()&&h<2||Bl(t))&&o.offset!==i.offset&&!l.isComposing()||kt(l)||l.isDirty()&&h>1||(s||!xn)&&d!==null&&!l.isComposing()&&c!==Dn(d)||a!==null&&e!==null&&(!e.collapsed||e.startContainer!==a.anchorNode||e.startOffset!==a.anchorOffset)||l.getFormat()!==r.format||l.getStyle()!==r.style||ic(r,l)}function no(r,e){return r!==null&&r.nodeValue!==null&&r.nodeType===Dt&&e!==0&&e!==r.nodeValue.length}function so(r,e,t){const{anchorNode:n,anchorOffset:s,focusNode:o,focusOffset:i}=r;Rs&&(Rs=!1,no(n,s)&&no(o,i))||Ne(e,()=>{if(!t)return void et(null);if(!Ir(e,n,o))return;const l=q();if(P(l)){const u=l.anchor,a=u.getNode();if(l.isCollapsed()){r.type==="Range"&&r.anchorNode===r.focusNode&&(l.dirty=!0);const c=Wn(e).event,f=c?c.timeStamp:performance.now(),[d,h,p,m,x]=Ul,C=ie(),_=e.isComposing()===!1&&C.getTextContent()==="";if(f<x+200&&u.offset===p&&u.key===m)l.format=d,l.style=h;else if(u.type==="text")M(a)||O(141),l.format=a.getFormat(),l.style=a.getStyle();else if(u.type==="element"&&!_){const E=u.getNode();l.style="",E instanceof sr&&E.getChildrenSize()===0?(l.format=E.getTextFormat(),l.style=E.getTextStyle()):l.format=0}}else{const c=u.key,f=l.focus.key,d=l.getNodes(),h=d.length,p=l.isBackward(),m=p?i:s,x=p?s:i,C=p?f:c,_=p?c:f;let E=za,D=!1;for(let A=0;A<h;A++){const v=d[A],b=v.getTextContentSize();if(M(v)&&b!==0&&!(A===0&&v.__key===C&&m===b||A===h-1&&v.__key===_&&x===0)&&(D=!0,E&=v.getFormat(),E===0))break}l.format=D?E:0}}I(e,Js,void 0)})}function Kl(r){if(!r.getTargetRanges)return null;const e=r.getTargetRanges();return e.length===0?null:e[0]}function ys(r,e){const t=r._compositionKey;if(ye(null),t!==null&&e!=null){if(e===""){const n=_e(t),s=Dn(r.getElementByKey(t));return void(s!==null&&s.nodeValue!==null&&M(n)&&fi(n,s.nodeValue,null,null,!0))}if(e[e.length-1]===`
|
|
65
|
+
`){const n=q();if(P(n)){const s=n.focus;return n.anchor.set(s.key,s.offset,s.type),void I(r,yn,null)}}}di(!0,r,e)}function Vl(r){let e=r.__lexicalEventHandles;return e===void 0&&(e=[],r.__lexicalEventHandles=e),e}const Xt=new Map;function Gl(r){const e=r.target,t=Oe(e==null?null:e.nodeType===9?e.defaultView:e.ownerDocument.defaultView);if(t===null)return;const n=El(t.anchorNode);if(n===null)return;$s&&($s=!1,Ne(n,()=>{const a=Kr(),c=t.anchorNode;if(c===null)return;const f=c.nodeType;f!==$r&&f!==Dt||et(xi(a,t,n,r))}));const s=ci(n),o=s[s.length-1],i=o._key,l=Xt.get(i),u=l||o;u!==n&&so(t,u,!1),so(t,n,!0),n!==o?Xt.set(i,n):l&&Xt.delete(i)}function io(r){r._lexicalHandled=!0}function oo(r){return r._lexicalHandled===!0}function yc(r){const e=r.ownerDocument,t=Bn.get(e);t===void 0&&O(162);const n=t-1;n>=0||O(164),Bn.set(e,n),n===0&&e.removeEventListener("selectionchange",Gl);const s=zn(r);ai(s)?(function(i){if(i._parentEditor!==null){const l=ci(i),u=l[l.length-1]._key;Xt.get(u)===i&&Xt.delete(u)}else Xt.delete(i._key)}(s),r.__lexicalEditor=null):s&&O(198);const o=Vl(r);for(let i=0;i<o.length;i++)o[i]();r.__lexicalEventHandles=[]}function Is(r,e,t){ke();const n=r.__key,s=r.getParent();if(s===null)return;const o=function(l){const u=q();if(!P(u)||!B(l))return u;const{anchor:a,focus:c}=u,f=a.getNode(),d=c.getNode();return Er(f,l)&&a.set(l.__key,0,"element"),Er(d,l)&&c.set(l.__key,0,"element"),u}(r);let i=!1;if(P(o)&&e){const l=o.anchor,u=o.focus;l.key===n&&(Fn(l,r,s,r.getPreviousSibling(),r.getNextSibling()),i=!0),u.key===n&&(Fn(u,r,s,r.getPreviousSibling(),r.getNextSibling()),i=!0)}else Ye(o)&&e&&r.isSelected()&&r.selectPrevious();if(P(o)&&e&&!i){const l=r.getIndexWithinParent();Bt(r),Nn(o,s,l,-1)}else Bt(r);t||tt(s)||s.canBeEmpty()||!s.isEmpty()||Is(s,e),e&&De(s)&&s.isEmpty()&&s.selectEnd()}class Vn{static getType(){O(64,this.name)}static clone(e){O(65,this.name)}afterCloneFrom(e){this.__parent=e.__parent,this.__next=e.__next,this.__prev=e.__prev}constructor(e){this.__type=this.constructor.getType(),this.__parent=null,this.__prev=null,this.__next=null,sc(this,e)}getType(){return this.__type}isInline(){O(137,this.constructor.name)}isAttached(){let e=this.__key;for(;e!==null;){if(e==="root")return!0;const t=_e(e);if(t===null)break;e=t.__parent}return!1}isSelected(e){const t=e||q();if(t==null)return!1;const n=t.getNodes().some(s=>s.__key===this.__key);if(M(this))return n;if(P(t)&&t.anchor.type==="element"&&t.focus.type==="element"){if(t.isCollapsed())return!1;const s=this.getParent();if(Z(this)&&this.isInline()&&s){const o=t.isBackward()?t.focus:t.anchor,i=o.getNode();if(o.offset===i.getChildrenSize()&&i.is(s)&&i.getLastChildOrThrow().is(this))return!1}}return n}getKey(){return this.__key}getIndexWithinParent(){const e=this.getParent();if(e===null)return-1;let t=e.getFirstChild(),n=0;for(;t!==null;){if(this.is(t))return n;n++,t=t.getNextSibling()}return-1}getParent(){const e=this.getLatest().__parent;return e===null?null:_e(e)}getParentOrThrow(){const e=this.getParent();return e===null&&O(66,this.__key),e}getTopLevelElement(){let e=this;for(;e!==null;){const t=e.getParent();if(tt(t))return B(e)||e===this&&Z(e)||O(194),e;e=t}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return e===null&&O(67,this.__key),e}getParents(){const e=[];let t=this.getParent();for(;t!==null;)e.push(t),t=t.getParent();return e}getParentKeys(){const e=[];let t=this.getParent();for(;t!==null;)e.push(t.__key),t=t.getParent();return e}getPreviousSibling(){const e=this.getLatest().__prev;return e===null?null:_e(e)}getPreviousSiblings(){const e=[],t=this.getParent();if(t===null)return e;let n=t.getFirstChild();for(;n!==null&&!n.is(this);)e.push(n),n=n.getNextSibling();return e}getNextSibling(){const e=this.getLatest().__next;return e===null?null:_e(e)}getNextSiblings(){const e=[];let t=this.getNextSibling();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getCommonAncestor(e){const t=this.getParents(),n=e.getParents();B(this)&&t.unshift(this),B(e)&&n.unshift(e);const s=t.length,o=n.length;if(s===0||o===0||t[s-1]!==n[o-1])return null;const i=new Set(n);for(let l=0;l<s;l++){const u=t[l];if(i.has(u))return u}return null}is(e){return e!=null&&this.__key===e.__key}isBefore(e){if(this===e)return!1;if(e.isParentOf(this))return!0;if(this.isParentOf(e))return!1;const t=this.getCommonAncestor(e);let n=0,s=0,o=this;for(;;){const i=o.getParentOrThrow();if(i===t){n=o.getIndexWithinParent();break}o=i}for(o=e;;){const i=o.getParentOrThrow();if(i===t){s=o.getIndexWithinParent();break}o=i}return n<s}isParentOf(e){const t=this.__key;if(t===e.__key)return!1;let n=e;for(;n!==null;){if(n.__key===t)return!0;n=n.getParent()}return!1}getNodesBetween(e){const t=this.isBefore(e),n=[],s=new Set;let o=this;for(;o!==null;){const i=o.__key;if(s.has(i)||(s.add(i),n.push(o)),o===e)break;const l=B(o)?t?o.getFirstChild():o.getLastChild():null;if(l!==null){o=l;continue}const u=t?o.getNextSibling():o.getPreviousSibling();if(u!==null){o=u;continue}const a=o.getParentOrThrow();if(s.has(a.__key)||n.push(a),a===e)break;let c=null,f=a;do{if(f===null&&O(68),c=t?f.getNextSibling():f.getPreviousSibling(),f=f.getParent(),f===null)break;c!==null||s.has(f.__key)||n.push(f)}while(c===null);o=c}return t||n.reverse(),n}isDirty(){const e=se()._dirtyLeaves;return e!==null&&e.has(this.__key)}getLatest(){const e=_e(this.__key);return e===null&&O(113),e}getWritable(){ke();const e=dt(),t=se(),n=e._nodeMap,s=this.__key,o=this.getLatest(),i=t._cloneNotNeeded,l=q();if(l!==null&&l.setCachedNodes(null),i.has(s))return wn(o),o;const u=gi(o);return i.add(s),wn(u),n.set(s,u),u}getTextContent(){return""}getTextContentSize(){return this.getTextContent().length}createDOM(e,t){O(70)}updateDOM(e,t,n){O(71)}exportDOM(e){return{element:this.createDOM(e._config,e)}}exportJSON(){O(72)}static importJSON(e){O(18,this.name)}static transform(){return null}remove(e){Is(this,!0,e)}replace(e,t){ke();let n=q();n!==null&&(n=n.clone()),ps(this,e);const s=this.getLatest(),o=this.__key,i=e.__key,l=e.getWritable(),u=this.getParentOrThrow().getWritable(),a=u.__size;Bt(l);const c=s.getPreviousSibling(),f=s.getNextSibling(),d=s.__prev,h=s.__next,p=s.__parent;if(Is(s,!1,!0),c===null?u.__first=i:c.getWritable().__next=i,l.__prev=d,f===null?u.__last=i:f.getWritable().__prev=i,l.__next=h,l.__parent=p,u.__size=a,t&&(B(this)&&B(l)||O(139),this.getChildren().forEach(m=>{l.append(m)})),P(n)){et(n);const m=n.anchor,x=n.focus;m.key===o&&co(m,l),x.key===o&&co(x,l)}return yt()===o&&ye(i),l}insertAfter(e,t=!0){ke(),ps(this,e);const n=this.getWritable(),s=e.getWritable(),o=s.getParent(),i=q();let l=!1,u=!1;if(o!==null){const h=e.getIndexWithinParent();if(Bt(s),P(i)){const p=o.__key,m=i.anchor,x=i.focus;l=m.type==="element"&&m.key===p&&m.offset===h+1,u=x.type==="element"&&x.key===p&&x.offset===h+1}}const a=this.getNextSibling(),c=this.getParentOrThrow().getWritable(),f=s.__key,d=n.__next;if(a===null?c.__last=f:a.getWritable().__prev=f,c.__size++,n.__next=f,s.__next=d,s.__prev=n.__key,s.__parent=n.__parent,t&&P(i)){const h=this.getIndexWithinParent();Nn(i,c,h+1);const p=c.__key;l&&i.anchor.set(p,h+2,"element"),u&&i.focus.set(p,h+2,"element")}return e}insertBefore(e,t=!0){ke(),ps(this,e);const n=this.getWritable(),s=e.getWritable(),o=s.__key;Bt(s);const i=this.getPreviousSibling(),l=this.getParentOrThrow().getWritable(),u=n.__prev,a=this.getIndexWithinParent();i===null?l.__first=o:i.getWritable().__next=o,l.__size++,n.__prev=o,s.__prev=u,s.__next=n.__key,s.__parent=n.__parent;const c=q();return t&&P(c)&&Nn(c,this.getParentOrThrow(),a),e}isParentRequired(){return!1}createParentElementNode(){return fe()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(e,t){ke();const n=this.getPreviousSibling(),s=this.getParentOrThrow();if(n===null)return s.select(0,0);if(B(n))return n.select();if(!M(n)){const o=n.getIndexWithinParent()+1;return s.select(o,o)}return n.select(e,t)}selectNext(e,t){ke();const n=this.getNextSibling(),s=this.getParentOrThrow();if(n===null)return s.select();if(B(n))return n.select(0,0);if(!M(n)){const o=n.getIndexWithinParent();return s.select(o,o)}return n.select(e,t)}markDirty(){this.getWritable()}reconcileObservedMutation(e,t){this.markDirty()}}class qr extends Vn{static getType(){return"linebreak"}static clone(e){return new qr(e.__key)}constructor(e){super(e)}getTextContent(){return`
|
|
66
|
+
`}createDOM(){return document.createElement("br")}updateDOM(){return!1}static importDOM(){return{br:e=>function(t){const n=t.parentElement;if(n!==null&&An(n)){const s=n.firstChild;if(s===t||s.nextSibling===t&&on(s)){const o=n.lastChild;if(o===t||o.previousSibling===t&&on(o))return!0}}return!1}(e)||function(t){const n=t.parentElement;if(n!==null&&An(n)){const s=n.firstChild;if(s===t||s.nextSibling===t&&on(s))return!1;const o=n.lastChild;if(o===t||o.previousSibling===t&&on(o))return!0}return!1}(e)?null:{conversion:xc,priority:0}}}static importJSON(e){return Pt()}exportJSON(){return{type:"linebreak",version:1}}}function xc(r){return{node:Pt()}}function Pt(){return st(new qr)}function Nt(r){return r instanceof qr}function on(r){return r.nodeType===Dt&&/^( |\t|\r?\n)+$/.test(r.textContent||"")}function xs(r,e){return 16&e?"code":e&ei?"mark":32&e?"sub":64&e?"sup":null}function _s(r,e){return 1&e?"strong":2&e?"em":"span"}function Hl(r,e,t,n,s){const o=n.classList;let i=wr(s,"base");i!==void 0&&o.add(...i),i=wr(s,"underlineStrikethrough");let l=!1;const u=e&bn&&e&_n;i!==void 0&&(t&bn&&t&_n?(l=!0,u||o.add(...i)):u&&o.remove(...i));for(const a in Lt){const c=Lt[a];if(i=wr(s,a),i!==void 0)if(t&c){if(l&&(a==="underline"||a==="strikethrough")){e&c&&o.remove(...i);continue}e&c&&(!u||a!=="underline")&&a!=="strikethrough"||o.add(...i)}else e&c&&o.remove(...i)}}function Jl(r,e,t){const n=e.firstChild,s=t.isComposing(),o=r+(s?In:"");if(n==null)e.textContent=o;else{const i=n.nodeValue;if(i!==o)if(s||bt){const[l,u,a]=function(c,f){const d=c.length,h=f.length;let p=0,m=0;for(;p<d&&p<h&&c[p]===f[p];)p++;for(;m+p<d&&m+p<h&&c[d-m-1]===f[h-m-1];)m++;return[p,d-p-m,f.slice(p,h-m)]}(i,o);u!==0&&n.deleteData(l,u),n.insertData(l,a)}else n.nodeValue=o}}function lo(r,e,t,n,s,o){Jl(s,r,e);const i=o.theme.text;i!==void 0&&Hl(0,0,n,r,i)}function ln(r,e){const t=document.createElement(e);return t.appendChild(r),t}class nr extends Vn{static getType(){return"text"}static clone(e){return new nr(e.__text,e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__format=e.__format,this.__style=e.__style,this.__mode=e.__mode,this.__detail=e.__detail}constructor(e,t){super(t),this.__text=e,this.__format=0,this.__style="",this.__mode=0,this.__detail=0}getFormat(){return this.getLatest().__format}getDetail(){return this.getLatest().__detail}getMode(){const e=this.getLatest();return Ha[e.__mode]}getStyle(){return this.getLatest().__style}isToken(){return this.getLatest().__mode===1}isComposing(){return this.__key===yt()}isSegmented(){return this.getLatest().__mode===2}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(e){const t=Lt[e];return!!(this.getFormat()&t)}isSimpleText(){return this.__type==="text"&&this.__mode===0}getTextContent(){return this.getLatest().__text}getFormatFlags(e,t){return Cn(this.getLatest().__format,e,t)}canHaveFormat(){return!0}createDOM(e,t){const n=this.__format,s=xs(0,n),o=_s(0,n),i=s===null?o:s,l=document.createElement(i);let u=l;this.hasFormat("code")&&l.setAttribute("spellcheck","false"),s!==null&&(u=document.createElement(o),l.appendChild(u)),lo(u,this,0,n,this.__text,e);const a=this.__style;return a!==""&&(l.style.cssText=a),l}updateDOM(e,t,n){const s=this.__text,o=e.__format,i=this.__format,l=xs(0,o),u=xs(0,i),a=_s(0,o),c=_s(0,i);if((l===null?a:l)!==(u===null?c:u))return!0;if(l===u&&a!==c){const m=t.firstChild;m==null&&O(48);const x=document.createElement(c);return lo(x,this,0,i,s,n),t.replaceChild(x,m),!1}let f=t;u!==null&&l!==null&&(f=t.firstChild,f==null&&O(49)),Jl(s,f,this);const d=n.theme.text;d!==void 0&&o!==i&&Hl(0,o,i,f,d);const h=e.__style,p=this.__style;return h!==p&&(t.style.cssText=p),!1}static importDOM(){return{"#text":()=>({conversion:Dc,priority:0}),b:()=>({conversion:bc,priority:0}),code:()=>({conversion:pt,priority:0}),em:()=>({conversion:pt,priority:0}),i:()=>({conversion:pt,priority:0}),s:()=>({conversion:pt,priority:0}),span:()=>({conversion:_c,priority:0}),strong:()=>({conversion:pt,priority:0}),sub:()=>({conversion:pt,priority:0}),sup:()=>({conversion:pt,priority:0}),u:()=>({conversion:pt,priority:0})}}static importJSON(e){const t=pe(e.text);return t.setFormat(e.format),t.setDetail(e.detail),t.setMode(e.mode),t.setStyle(e.style),t}exportDOM(e){let{element:t}=super.exportDOM(e);return t!==null&&ct(t)||O(132),t.style.whiteSpace="pre-wrap",this.hasFormat("bold")&&(t=ln(t,"b")),this.hasFormat("italic")&&(t=ln(t,"i")),this.hasFormat("strikethrough")&&(t=ln(t,"s")),this.hasFormat("underline")&&(t=ln(t,"u")),{element:t}}exportJSON(){return{detail:this.getDetail(),format:this.getFormat(),mode:this.getMode(),style:this.getStyle(),text:this.getTextContent(),type:"text",version:1}}selectionTransform(e,t){}setFormat(e){const t=this.getWritable();return t.__format=typeof e=="string"?Lt[e]:e,t}setDetail(e){const t=this.getWritable();return t.__detail=typeof e=="string"?Ka[e]:e,t}setStyle(e){const t=this.getWritable();return t.__style=e,t}toggleFormat(e){const t=Cn(this.getFormat(),e,null);return this.setFormat(t)}toggleDirectionless(){const e=this.getWritable();return e.__detail^=1,e}toggleUnmergeable(){const e=this.getWritable();return e.__detail^=2,e}setMode(e){const t=Ga[e];if(this.__mode===t)return this;const n=this.getWritable();return n.__mode=t,n}setTextContent(e){if(this.__text===e)return this;const t=this.getWritable();return t.__text=e,t}select(e,t){ke();let n=e,s=t;const o=q(),i=this.getTextContent(),l=this.__key;if(typeof i=="string"){const u=i.length;n===void 0&&(n=u),s===void 0&&(s=u)}else n=0,s=0;if(!P(o))return Xl(l,n,l,s,"text","text");{const u=yt();u!==o.anchor.key&&u!==o.focus.key||ye(l),o.setTextNodeRange(this,n,this,s)}return o}selectStart(){return this.select(0,0)}selectEnd(){const e=this.getTextContentSize();return this.select(e,e)}spliceText(e,t,n,s){const o=this.getWritable(),i=o.__text,l=n.length;let u=e;u<0&&(u=l+u,u<0&&(u=0));const a=q();if(s&&P(a)){const f=e+l;a.setTextNodeRange(o,f,o,f)}const c=i.slice(0,u)+n+i.slice(u+t);return o.__text=c,o}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...e){ke();const t=this.getLatest(),n=t.getTextContent(),s=t.__key,o=yt(),i=new Set(e),l=[],u=n.length;let a="";for(let A=0;A<u;A++)a!==""&&i.has(A)&&(l.push(a),a=""),a+=n[A];a!==""&&l.push(a);const c=l.length;if(c===0)return[];if(l[0]===n)return[t];const f=l[0],d=t.getParent();let h;const p=t.getFormat(),m=t.getStyle(),x=t.__detail;let C=!1;t.isSegmented()?(h=pe(f),h.__format=p,h.__style=m,h.__detail=x,C=!0):(h=t.getWritable(),h.__text=f);const _=q(),E=[h];let D=f.length;for(let A=1;A<c;A++){const v=l[A],b=v.length,w=pe(v).getWritable();w.__format=p,w.__style=m,w.__detail=x;const S=w.__key,R=D+b;if(P(_)){const T=_.anchor,N=_.focus;T.key===s&&T.type==="text"&&T.offset>D&&T.offset<=R&&(T.key=S,T.offset-=D,_.dirty=!0),N.key===s&&N.type==="text"&&N.offset>D&&N.offset<=R&&(N.key=S,N.offset-=D,_.dirty=!0)}o===s&&ye(S),D=R,E.push(w)}if(d!==null){(function(b){const w=b.getPreviousSibling(),S=b.getNextSibling();w!==null&&wn(w),S!==null&&wn(S)})(this);const A=d.getWritable(),v=this.getIndexWithinParent();C?(A.splice(v,0,E),this.remove()):A.splice(v,1,E),P(_)&&Nn(_,d,v,c-1)}return E}mergeWithSibling(e){const t=e===this.getPreviousSibling();t||e===this.getNextSibling()||O(50);const n=this.__key,s=e.__key,o=this.__text,i=o.length;yt()===s&&ye(n);const l=q();if(P(l)){const f=l.anchor,d=l.focus;f!==null&&f.key===s&&(xo(f,t,n,e,i),l.dirty=!0),d!==null&&d.key===s&&(xo(d,t,n,e,i),l.dirty=!0)}const u=e.__text,a=t?u+o:o+u;this.setTextContent(a);const c=this.getWritable();return e.remove(),c}isTextEntity(){return!1}}function _c(r){return{forChild:yi(r.style),node:null}}function bc(r){const e=r,t=e.style.fontWeight==="normal";return{forChild:yi(e.style,t?void 0:"bold"),node:null}}const uo=new WeakMap;function vc(r){return r.nodeName==="PRE"||r.nodeType===$r&&r.style!==void 0&&r.style.whiteSpace!==void 0&&r.style.whiteSpace.startsWith("pre")}function Dc(r){const e=r;r.parentElement===null&&O(129);let t=e.textContent||"";if(function(n){let s,o=n.parentNode;const i=[n];for(;o!==null&&(s=uo.get(o))===void 0&&!vc(o);)i.push(o),o=o.parentNode;const l=s===void 0?o:s;for(let u=0;u<i.length;u++)uo.set(i[u],l);return l}(e)!==null){const n=t.split(/(\r?\n|\t)/),s=[],o=n.length;for(let i=0;i<o;i++){const l=n[i];l===`
|
|
67
67
|
`||l===`\r
|
|
68
|
-
`?s.push(Pt()):l===" "?s.push(Wr()):l!==""&&s.push(pe(l))}return{node:s}}if(t=t.replace(/\r/g,"").replace(/[ \t\n]+/g," "),t==="")return{node:null};if(t[0]===" "){let n=e,s=!0;for(;n!==null&&(n=ao(n,!1))!==null;){const o=n.textContent||"";if(o.length>0){/[ \t\n]$/.test(o)&&(t=t.slice(1)),s=!1;break}}s&&(t=t.slice(1))}if(t[t.length-1]===" "){let n=e,s=!0;for(;n!==null&&(n=ao(n,!0))!==null;)if((n.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){s=!1;break}s&&(t=t.slice(0,t.length-1))}return t===""?{node:null}:{node:pe(t)}}function ao(r,e){let t=r;for(;;){let n;for(;(n=e?t.nextSibling:t.previousSibling)===null;){const o=t.parentElement;if(o===null)return null;t=o}if(t=n,t.nodeType===$r){const o=t.style.display;if(o===""&&!Ts(t)||o!==""&&!o.startsWith("inline"))return null}let s=t;for(;(s=e?t.firstChild:t.lastChild)!==null;)t=s;if(t.nodeType===
|
|
69
|
-
`),c=!d.isEmpty();else if(c=!1,M(d)){let h=d.getTextContent();d===t?d===n?s.type==="element"&&o.type==="element"&&o.offset!==s.offset||(h=l<u?h.slice(l,u):h.slice(u,l)):h=i?h.slice(l):h.slice(u):d===n&&(h=i?h.slice(0,u):h.slice(0,l)),a+=h}else!Z(d)&&!Nt(d)||d===n&&this.isCollapsed()||(a+=d.getTextContent())}return a}applyDOMRange(e){const t=se(),n=t.getEditorState()._selection,s=Yl(e.startContainer,e.startOffset,e.endContainer,e.endOffset,t,n);if(s===null)return;const[o,i]=s;mt(this.anchor,o.key,o.offset,o.type),mt(this.focus,i.key,i.offset,i.type),this._cachedNodes=null}clone(){const e=this.anchor,t=this.focus;return new
|
|
68
|
+
`?s.push(Pt()):l===" "?s.push(Wr()):l!==""&&s.push(pe(l))}return{node:s}}if(t=t.replace(/\r/g,"").replace(/[ \t\n]+/g," "),t==="")return{node:null};if(t[0]===" "){let n=e,s=!0;for(;n!==null&&(n=ao(n,!1))!==null;){const o=n.textContent||"";if(o.length>0){/[ \t\n]$/.test(o)&&(t=t.slice(1)),s=!1;break}}s&&(t=t.slice(1))}if(t[t.length-1]===" "){let n=e,s=!0;for(;n!==null&&(n=ao(n,!0))!==null;)if((n.textContent||"").replace(/^( |\t|\r?\n)+/,"").length>0){s=!1;break}s&&(t=t.slice(0,t.length-1))}return t===""?{node:null}:{node:pe(t)}}function ao(r,e){let t=r;for(;;){let n;for(;(n=e?t.nextSibling:t.previousSibling)===null;){const o=t.parentElement;if(o===null)return null;t=o}if(t=n,t.nodeType===$r){const o=t.style.display;if(o===""&&!Ts(t)||o!==""&&!o.startsWith("inline"))return null}let s=t;for(;(s=e?t.firstChild:t.lastChild)!==null;)t=s;if(t.nodeType===Dt)return t;if(t.nodeName==="BR")return null}}const Cc={code:"code",em:"italic",i:"italic",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function pt(r){const e=Cc[r.nodeName.toLowerCase()];return e===void 0?{node:null}:{forChild:yi(r.style,e),node:null}}function pe(r=""){return st(new nr(r))}function M(r){return r instanceof nr}function yi(r,e){const t=r.fontWeight,n=r.textDecoration.split(" "),s=t==="700"||t==="bold",o=n.includes("line-through"),i=r.fontStyle==="italic",l=n.includes("underline"),u=r.verticalAlign;return a=>(M(a)&&(s&&!a.hasFormat("bold")&&a.toggleFormat("bold"),o&&!a.hasFormat("strikethrough")&&a.toggleFormat("strikethrough"),i&&!a.hasFormat("italic")&&a.toggleFormat("italic"),l&&!a.hasFormat("underline")&&a.toggleFormat("underline"),u!=="sub"||a.hasFormat("subscript")||a.toggleFormat("subscript"),u!=="super"||a.hasFormat("superscript")||a.toggleFormat("superscript"),e&&!a.hasFormat(e)&&a.toggleFormat(e)),a)}class Ur extends nr{static getType(){return"tab"}static clone(e){return new Ur(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__text=e.__text}constructor(e){super(" ",e),this.__detail=2}static importDOM(){return null}static importJSON(e){const t=Wr();return t.setFormat(e.format),t.setStyle(e.style),t}exportJSON(){return{...super.exportJSON(),type:"tab",version:1}}setTextContent(e){O(126)}setDetail(e){O(127)}setMode(e){O(128)}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function Wr(){return st(new Ur)}function wc(r){return r instanceof Ur}class Ec{constructor(e,t,n){this._selection=null,this.key=e,this.offset=t,this.type=n}is(e){return this.key===e.key&&this.offset===e.offset&&this.type===e.type}isBefore(e){let t=this.getNode(),n=e.getNode();const s=this.offset,o=e.offset;if(B(t)){const i=t.getDescendantByIndex(s);t=i??t}if(B(n)){const i=n.getDescendantByIndex(o);n=i??n}return t===n?s<o:t.isBefore(n)}getNode(){const e=_e(this.key);return e===null&&O(20),e}set(e,t,n){const s=this._selection,o=this.key;this.key=e,this.offset=t,this.type=n,Vr()||(yt()===o&&ye(e),s!==null&&(s.setCachedNodes(null),s.dirty=!0))}}function rt(r,e,t){return new Ec(r,e,t)}function bs(r,e){let t=e.__key,n=r.offset,s="element";if(M(e)){s="text";const o=e.getTextContentSize();n>o&&(n=o)}else if(!B(e)){const o=e.getNextSibling();if(M(o))t=o.__key,n=0,s="text";else{const i=e.getParent();i&&(t=i.__key,n=e.getIndexWithinParent()+1)}}r.set(t,n,s)}function co(r,e){if(B(e)){const t=e.getLastDescendant();B(t)||M(t)?bs(r,t):bs(r,e)}else bs(r,e)}function mt(r,e,t,n){r.key=e,r.offset=t,r.type=n}class Gn{constructor(e){this._cachedNodes=null,this._nodes=e,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){if(!Ye(e))return!1;const t=this._nodes,n=e._nodes;return t.size===n.size&&Array.from(t).every(s=>n.has(s))}isCollapsed(){return!1}isBackward(){return!1}getStartEndPoints(){return null}add(e){this.dirty=!0,this._nodes.add(e),this._cachedNodes=null}delete(e){this.dirty=!0,this._nodes.delete(e),this._cachedNodes=null}clear(){this.dirty=!0,this._nodes.clear(),this._cachedNodes=null}has(e){return this._nodes.has(e)}clone(){return new Gn(new Set(this._nodes))}extract(){return this.getNodes()}insertRawText(e){}insertText(){}insertNodes(e){const t=this.getNodes(),n=t.length,s=t[n-1];let o;if(M(s))o=s.select();else{const i=s.getIndexWithinParent()+1;o=s.getParentOrThrow().select(i,i)}o.insertNodes(e);for(let i=0;i<n;i++)t[i].remove()}getNodes(){const e=this._cachedNodes;if(e!==null)return e;const t=this._nodes,n=[];for(const s of t){const o=_e(s);o!==null&&n.push(o)}return Vr()||(this._cachedNodes=n),n}getTextContent(){const e=this.getNodes();let t="";for(let n=0;n<e.length;n++)t+=e[n].getTextContent();return t}}function P(r){return r instanceof Ct}class Ct{constructor(e,t,n,s){this.anchor=e,this.focus=t,e._selection=this,t._selection=this,this._cachedNodes=null,this.format=n,this.style=s,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){return!!P(e)&&this.anchor.is(e.anchor)&&this.focus.is(e.focus)&&this.format===e.format&&this.style===e.style}isCollapsed(){return this.anchor.is(this.focus)}getNodes(){const e=this._cachedNodes;if(e!==null)return e;const t=this.anchor,n=this.focus,s=t.isBefore(n),o=s?t:n,i=s?n:t;let l=o.getNode(),u=i.getNode();const a=o.offset,c=i.offset;if(B(l)){const d=l.getDescendantByIndex(a);l=d??l}if(B(u)){let d=u.getDescendantByIndex(c);d!==null&&d!==l&&u.getChildAtIndex(c)===d&&(d=d.getPreviousSibling()),u=d??u}let f;return f=l.is(u)?B(l)&&l.getChildrenSize()>0?[]:[l]:l.getNodesBetween(u),Vr()||(this._cachedNodes=f),f}setTextNodeRange(e,t,n,s){mt(this.anchor,e.__key,t,"text"),mt(this.focus,n.__key,s,"text"),this._cachedNodes=null,this.dirty=!0}getTextContent(){const e=this.getNodes();if(e.length===0)return"";const t=e[0],n=e[e.length-1],s=this.anchor,o=this.focus,i=s.isBefore(o),[l,u]=zs(this);let a="",c=!0;for(let f=0;f<e.length;f++){const d=e[f];if(B(d)&&!d.isInline())c||(a+=`
|
|
69
|
+
`),c=!d.isEmpty();else if(c=!1,M(d)){let h=d.getTextContent();d===t?d===n?s.type==="element"&&o.type==="element"&&o.offset!==s.offset||(h=l<u?h.slice(l,u):h.slice(u,l)):h=i?h.slice(l):h.slice(u):d===n&&(h=i?h.slice(0,u):h.slice(0,l)),a+=h}else!Z(d)&&!Nt(d)||d===n&&this.isCollapsed()||(a+=d.getTextContent())}return a}applyDOMRange(e){const t=se(),n=t.getEditorState()._selection,s=Yl(e.startContainer,e.startOffset,e.endContainer,e.endOffset,t,n);if(s===null)return;const[o,i]=s;mt(this.anchor,o.key,o.offset,o.type),mt(this.focus,i.key,i.offset,i.type),this._cachedNodes=null}clone(){const e=this.anchor,t=this.focus;return new Ct(rt(e.key,e.offset,e.type),rt(t.key,t.offset,t.type),this.format,this.style)}toggleFormat(e){this.format=Cn(this.format,e,null),this.dirty=!0}setStyle(e){this.style=e,this.dirty=!0}hasFormat(e){const t=Lt[e];return!!(this.format&t)}insertRawText(e){const t=e.split(/(\r?\n|\t)/),n=[],s=t.length;for(let o=0;o<s;o++){const i=t[o];i===`
|
|
70
70
|
`||i===`\r
|
|
71
|
-
`?n.push(Pt()):i===" "?n.push(Wr()):n.push(pe(i))}this.insertNodes(n)}insertText(e){const t=this.anchor,n=this.focus,s=this.format,o=this.style;let i=t,l=n;!this.isCollapsed()&&n.isBefore(t)&&(i=n,l=t),i.type==="element"&&function(x,D,_,E){const C=x.getNode(),A=C.getChildAtIndex(x.offset),v=pe(),b=Ce(C)?fe().append(v):v;v.setFormat(_),v.setStyle(E),A===null?C.append(b):A.insertBefore(b),x.is(D)&&D.set(v.__key,0,"text"),x.set(v.__key,0,"text")}(i,l,s,o);const u=i.offset;let a=l.offset;const c=this.getNodes(),f=c.length;let d=c[0];M(d)||O(26);const h=d.getTextContent().length,p=d.getParentOrThrow();let m=c[f-1];if(f===1&&l.type==="element"&&(a=h,l.set(i.key,a,"text")),this.isCollapsed()&&u===h&&(d.isSegmented()||d.isToken()||!d.canInsertTextAfter()||!p.canInsertTextAfter()&&d.getNextSibling()===null)){let x=d.getNextSibling();if(M(x)&&x.canInsertTextBefore()&&!kt(x)||(x=pe(),x.setFormat(s),x.setStyle(o),p.canInsertTextAfter()?d.insertAfter(x):p.insertAfter(x)),x.select(0,0),d=x,e!=="")return void this.insertText(e)}else if(this.isCollapsed()&&u===0&&(d.isSegmented()||d.isToken()||!d.canInsertTextBefore()||!p.canInsertTextBefore()&&d.getPreviousSibling()===null)){let x=d.getPreviousSibling();if(M(x)&&!kt(x)||(x=pe(),x.setFormat(s),p.canInsertTextBefore()?d.insertBefore(x):p.insertBefore(x)),x.select(),d=x,e!=="")return void this.insertText(e)}else if(d.isSegmented()&&u!==h){const x=pe(d.getTextContent());x.setFormat(s),d.replace(x),d=x}else if(!this.isCollapsed()&&e!==""){const x=m.getParent();if(!p.canInsertTextBefore()||!p.canInsertTextAfter()||B(x)&&(!x.canInsertTextBefore()||!x.canInsertTextAfter()))return this.insertText(""),Ql(this.anchor,this.focus,null),void this.insertText(e)}if(f===1){if(d.isToken()){const E=pe(e);return E.select(),void d.replace(E)}const x=d.getFormat(),D=d.getStyle();if(u!==a||x===s&&D===o){if(wc(d)){const E=pe(e);return E.setFormat(s),E.setStyle(o),E.select(),void d.replace(E)}}else{if(d.getTextContent()!==""){const E=pe(e);if(E.setFormat(s),E.setStyle(o),E.select(),u===0)d.insertBefore(E,!1);else{const[C]=d.splitText(u);C.insertAfter(E,!1)}return void(E.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length))}d.setFormat(s),d.setStyle(o)}const _=a-u;d=d.spliceText(u,_,e,!0),d.getTextContent()===""?d.remove():this.anchor.type==="text"&&(d.isComposing()?this.anchor.offset-=e.length:(this.format=x,this.style=D))}else{const x=new Set([...d.getParentKeys(),...m.getParentKeys()]),D=B(d)?d:d.getParentOrThrow();let _=B(m)?m:m.getParentOrThrow(),E=m;if(!D.is(_)&&_.isInline())do E=_,_=_.getParentOrThrow();while(_.isInline());if(l.type==="text"&&(a!==0||m.getTextContent()==="")||l.type==="element"&&m.getIndexWithinParent()<a)if(M(m)&&!m.isToken()&&a!==m.getTextContentSize()){if(m.isSegmented()){const w=pe(m.getTextContent());m.replace(w),m=w}Ce(l.getNode())||l.type!=="text"||(m=m.spliceText(0,a,"")),x.add(m.__key)}else{const w=m.getParentOrThrow();w.canBeEmpty()||w.getChildrenSize()!==1?m.remove():w.remove()}else x.add(m.__key);const C=_.getChildren(),A=new Set(c),v=D.is(_),b=D.isInline()&&d.getNextSibling()===null?D:d;for(let w=C.length-1;w>=0;w--){const S=C[w];if(S.is(d)||B(S)&&S.isParentOf(d))break;S.isAttached()&&(!A.has(S)||S.is(E)?v||b.insertAfter(S,!1):S.remove())}if(!v){let w=_,S=null;for(;w!==null;){const R=w.getChildren(),T=R.length;(T===0||R[T-1].is(S))&&(x.delete(w.__key),S=w),w=w.getParent()}}if(d.isToken())if(u===h)d.select();else{const w=pe(e);w.select(),d.replace(w)}else d=d.spliceText(u,h-u,e,!0),d.getTextContent()===""?d.remove():d.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length);for(let w=1;w<f;w++){const S=c[w],R=S.__key;x.has(R)||S.remove()}}}removeText(){if(this.isCollapsed())return;const{anchor:e,focus:t}=this,n=this.getNodes(),s=this.isBackward()?t:e,o=this.isBackward()?e:t;let i=s.getNode(),l=o.getNode();const u=pr(i,gt),a=pr(l,gt);M(i)&&i.isToken()&&s.offset<i.getTextContentSize()&&(s.offset=0),o.offset>0&&M(l)&&l.isToken()&&(o.offset=l.getTextContentSize()),n.forEach(f=>{Er(i,f)||Er(l,f)||f.getKey()===i.getKey()||f.getKey()===l.getKey()||f.remove()});const c=(f,d)=>{if(f.getTextContent()==="")f.remove();else if(d!==0&&kt(f)){const h=pe(f.getTextContent());return h.setFormat(f.getFormat()),h.setStyle(f.getStyle()),f.replace(h)}};if(i===l&&M(i)){const f=Math.abs(t.offset-e.offset);return i.spliceText(s.offset,f,"",!0),void c(i,f)}if(M(i)){const f=i.getTextContentSize()-s.offset;i.spliceText(s.offset,f,""),i=c(i,f)||i}M(l)&&(l.spliceText(0,o.offset,""),l=c(l,o.offset)||l),i.isAttached()&&M(i)?i.selectEnd():l.isAttached()&&M(l)&&l.selectStart(),B(u)&&B(a)&&u!==a&&(u.append(...a.getChildren()),a.remove(),o.set(s.key,s.offset,s.type))}formatText(e,t=null){if(this.isCollapsed())return this.toggleFormat(e),void ye(null);const n=this.getNodes(),s=[];for(const C of n)M(C)&&s.push(C);const o=C=>{n.forEach(A=>{if(rr(A)){const v=A.getFormatFlags(e,C);A.setTextFormat(v)}})},i=s.length;if(i===0)return this.toggleFormat(e),ye(null),void o(t);const l=this.anchor,u=this.focus,a=this.isBackward(),c=a?u:l,f=a?l:u;let d=0,h=s[0],p=c.type==="element"?0:c.offset;if(c.type==="text"&&p===h.getTextContentSize()&&(d=1,h=s[1],p=0),h==null)return;const m=h.getFormatFlags(e,t);o(m);const x=i-1;let D=s[x];const _=f.type==="text"?f.offset:D.getTextContentSize();if(h.is(D)){if(p===_)return;if(kt(h)||p===0&&_===h.getTextContentSize())h.setFormat(m);else{const C=h.splitText(p,_),A=p===0?C[0]:C[1];A.setFormat(m),c.type==="text"&&c.set(A.__key,0,"text"),f.type==="text"&&f.set(A.__key,_-p,"text")}return void(this.format=m)}p===0||kt(h)||([,h]=h.splitText(p),p=0),h.setFormat(m);const E=D.getFormatFlags(e,m);_>0&&(_===D.getTextContentSize()||kt(D)||([D]=D.splitText(_)),D.setFormat(E));for(let C=d+1;C<x;C++){const A=s[C],v=A.getFormatFlags(e,E);A.setFormat(v)}c.type==="text"&&c.set(h.__key,p,"text"),f.type==="text"&&f.set(D.__key,_,"text"),this.format=m|E}insertNodes(e){if(e.length===0)return;if(this.anchor.key==="root"){this.insertParagraph();const p=q();return P(p)||O(134),p.insertNodes(e)}const t=(this.isBackward()?this.focus:this.anchor).getNode(),n=pr(t,gt),s=e[e.length-1];if(B(n)&&"__language"in n){if("__language"in e[0])this.insertText(e[0].getTextContent());else{const p=vs(this);n.splice(p,0,e),s.selectEnd()}return}if(!e.some(p=>(B(p)||Z(p))&&!p.isInline())){B(n)||O(211,t.constructor.name,t.getType());const p=vs(this);return n.splice(p,0,e),void s.selectEnd()}const o=function(p){const m=fe();let x=null;for(let D=0;D<p.length;D++){const _=p[D],E=Nt(_);if(E||Z(_)&&_.isInline()||B(_)&&_.isInline()||M(_)||_.isParentRequired()){if(x===null&&(x=_.createParentElementNode(),m.append(x),E))continue;x!==null&&x.append(_)}else m.append(_),x=null}return m}(e),i=o.getLastDescendant(),l=o.getChildren(),u=!B(n)||!n.isEmpty()?this.insertParagraph():null,a=l[l.length-1];let c=l[0];var f;B(f=c)&>(f)&&!f.isEmpty()&&B(n)&&(!n.isEmpty()||n.canMergeWhenEmpty())&&(B(n)||O(211,t.constructor.name,t.getType()),n.append(...c.getChildren()),c=l[1]),c&&(n===null&&O(212,t.constructor.name,t.getType()),function(p,m,x){const D=m.getParentOrThrow().getLastChild();let _=m;const E=[m];for(;_!==D;)_.getNextSibling()||O(140),_=_.getNextSibling(),E.push(_);let C=p;for(const A of E)C=C.insertAfter(A)}(n,c));const d=pr(i,gt);u&&B(d)&&(u.canMergeWhenEmpty()||gt(a))&&(d.append(...u.getChildren()),u.remove()),B(n)&&n.isEmpty()&&n.remove(),i.selectEnd();const h=B(n)?n.getLastChild():null;Nt(h)&&d!==n&&h.remove()}insertParagraph(){if(this.anchor.key==="root"){const i=fe();return ie().splice(this.anchor.offset,0,[i]),i.select(),i}const e=vs(this),t=pr(this.anchor.getNode(),gt);B(t)||O(213);const n=t.getChildAtIndex(e),s=n?[n,...n.getNextSiblings()]:[],o=t.insertNewAfter(this,!1);return o?(o.append(...s),o.selectStart(),o):null}insertLineBreak(e){const t=Pt();if(this.insertNodes([t]),e){const n=t.getParentOrThrow(),s=t.getIndexWithinParent();n.select(s,s)}}extract(){const e=this.getNodes(),t=e.length,n=t-1,s=this.anchor,o=this.focus;let i=e[0],l=e[n];const[u,a]=zs(this);if(t===0)return[];if(t===1){if(M(i)&&!this.isCollapsed()){const f=u>a?a:u,d=u>a?u:a,h=i.splitText(f,d),p=f===0?h[0]:h[1];return p!=null?[p]:[]}return[i]}const c=s.isBefore(o);if(M(i)){const f=c?u:a;f===i.getTextContentSize()?e.shift():f!==0&&([,i]=i.splitText(f),e[0]=i)}if(M(l)){const f=l.getTextContent().length,d=c?a:u;d===0?e.pop():d!==f&&([l]=l.splitText(d),e[n]=l)}return e}modify(e,t,n){const s=this.focus,o=this.anchor,i=e==="move",l=Lr(s,t);if(Z(l)&&!l.isIsolated()){if(i&&l.isKeyboardSelectable()){const h=mo();return h.add(l.__key),void et(h)}const d=t?l.getPreviousSibling():l.getNextSibling();if(M(d)){const h=d.__key,p=t?d.getTextContent().length:0;return s.set(h,p,"text"),void(i&&o.set(h,p,"text"))}{const h=l.getParentOrThrow();let p,m;return B(d)?(m=d.__key,p=t?d.getChildrenSize():0):(p=l.getIndexWithinParent(),m=h.__key,t||p++),s.set(m,p,"element"),void(i&&o.set(m,p,"element"))}}const u=se(),a=Oe(u._window);if(!a)return;const c=u._blockCursorElement,f=u._rootElement;if(f===null||c===null||!B(l)||l.isInline()||l.canBeEmpty()||pi(c,u,f),function(d,h,p,m){d.modify(h,p,m)}(a,e,t?"backward":"forward",n),a.rangeCount>0){const d=a.getRangeAt(0),h=this.anchor.getNode(),p=Ce(h)?h:lc(h);if(this.applyDOMRange(d),this.dirty=!0,!i){const m=this.getNodes(),x=[];let D=!1;for(let _=0;_<m.length;_++){const E=m[_];Er(E,p)?x.push(E):D=!0}if(D&&x.length>0)if(t){const _=x[0];B(_)?_.selectStart():_.getParentOrThrow().selectStart()}else{const _=x[x.length-1];B(_)?_.selectEnd():_.getParentOrThrow().selectEnd()}a.anchorNode===d.startContainer&&a.anchorOffset===d.startOffset||function(_){const E=_.focus,C=_.anchor,A=C.key,v=C.offset,b=C.type;mt(C,E.key,E.offset,E.type),mt(E,A,v,b),_._cachedNodes=null}(this)}}}forwardDeletion(e,t,n){if(!n&&(e.type==="element"&&B(t)&&e.offset===t.getChildrenSize()||e.type==="text"&&e.offset===t.getTextContentSize())){const s=t.getParent(),o=t.getNextSibling()||(s===null?null:s.getNextSibling());if(B(o)&&o.isShadowRoot())return!0}return!1}deleteCharacter(e){const t=this.isCollapsed();if(this.isCollapsed()){const n=this.anchor;let s=n.getNode();if(this.forwardDeletion(n,s,e))return;const o=this.focus,i=Lr(o,e);if(Z(i)&&!i.isIsolated()){if(i.isKeyboardSelectable()&&B(s)&&s.getChildrenSize()===0){s.remove();const l=mo();l.add(i.__key),et(l)}else i.remove(),se().dispatchCommand(Js,void 0);return}if(!e&&B(i)&&B(s)&&s.isEmpty())return s.remove(),void i.selectStart();if(this.modify("extend",e,"character"),this.isCollapsed()){if(e&&n.offset===0&&(n.type==="element"?n.getNode():n.getNode().getParentOrThrow()).collapseAtStart(this))return}else{const l=o.type==="text"?o.getNode():null;if(s=n.type==="text"?n.getNode():null,l!==null&&l.isSegmented()){const u=o.offset,a=l.getTextContentSize();if(l.is(s)||e&&u!==a||!e&&u!==0)return void ho(l,e,u)}else if(s!==null&&s.isSegmented()){const u=n.offset,a=s.getTextContentSize();if(s.is(l)||e&&u!==0||!e&&u!==a)return void ho(s,e,u)}(function(u,a){const c=u.anchor,f=u.focus,d=c.getNode(),h=f.getNode();if(d===h&&c.type==="text"&&f.type==="text"){const p=c.offset,m=f.offset,x=p<m,D=x?p:m,_=x?m:p,E=_-1;D!==E&&(Bl(d.getTextContent().slice(D,_))||(a?f.offset=E:c.offset=E))}})(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type==="element"&&this.anchor.offset===0){const n=this.anchor.getNode();n.isEmpty()&&Ce(n.getParent())&&n.getIndexWithinParent()===0&&n.collapseAtStart(this)}}deleteLine(e){if(this.isCollapsed()){const t=this.anchor.type==="element";if(t&&this.insertText(" "),this.modify("extend",e,"lineboundary"),this.isCollapsed()&&this.anchor.offset===0&&this.modify("extend",e,"character"),t){const n=e?this.anchor:this.focus;n.set(n.key,n.offset+1,n.type)}}this.removeText()}deleteWord(e){if(this.isCollapsed()){const t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;this.modify("extend",e,"word")}this.removeText()}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return[this.anchor,this.focus]}}function Ye(r){return r instanceof Gn}function fo(r){const e=r.offset;if(r.type==="text")return e;const t=r.getNode();return e===t.getChildrenSize()?t.getTextContent().length:0}function zs(r){const e=r.getStartEndPoints();if(e===null)return[0,0];const[t,n]=e;return t.type==="element"&&n.type==="element"&&t.key===n.key&&t.offset===n.offset?[0,0]:[fo(t),fo(n)]}function ho(r,e,t){const n=r,s=n.getTextContent().split(/(?=\s)/g),o=s.length;let i=0,l=0;for(let a=0;a<o;a++){const c=a===o-1;if(l=i,i+=s[a].length,e&&i===t||i>t||c){s.splice(a,1),c&&(l=void 0);break}}const u=s.join("").trim();u===""?n.remove():(n.setTextContent(u),n.select(l,l))}function po(r,e,t,n){let s,o=e;if(r.nodeType===$r){let i=!1;const l=r.childNodes,u=l.length,a=n._blockCursorElement;o===u&&(i=!0,o=u-1);let c=l[o],f=!1;if(c===a)c=l[o+1],f=!0;else if(a!==null){const d=a.parentNode;r===d&&e>Array.prototype.indexOf.call(d.children,a)&&o--}if(s=Ht(c),M(s))o=Hi(s,i);else{let d=Ht(r);if(d===null)return null;if(B(d)){const h=n.getElementByKey(d.getKey());h===null&&O(214),[d,o]=d.getDOMSlot(h).resolveChildIndex(d,h,r,e),B(d)||O(215),i&&o>=d.getChildrenSize()&&(o=Math.max(0,d.getChildrenSize()-1));let m=d.getChildAtIndex(o);if(B(m)&&function(x,D,_){const E=x.getParent();return _===null||E===null||!E.canBeEmpty()||E!==_.getNode()}(m,0,t)){const x=i?m.getLastDescendant():m.getFirstDescendant();x===null?d=m:(m=x,d=B(m)?m:m.getParentOrThrow()),o=0}M(m)?(s=m,d=null,o=Hi(m,i)):m!==d&&i&&!f&&(B(d)||O(216),o=Math.min(d.getChildrenSize(),o+1))}else{const h=d.getIndexWithinParent();o=e===0&&Z(d)&&Ht(r)===d?h:h+1,d=d.getParentOrThrow()}if(B(d))return rt(d.__key,o,"element")}}else s=Ht(r);return M(s)?rt(s.__key,o,"text"):null}function go(r,e,t){const n=r.offset,s=r.getNode();if(n===0){const o=s.getPreviousSibling(),i=s.getParent();if(e){if((t||!e)&&o===null&&B(i)&&i.isInline()){const l=i.getPreviousSibling();M(l)&&(r.key=l.__key,r.offset=l.getTextContent().length)}}else B(o)&&!t&&o.isInline()?(r.key=o.__key,r.offset=o.getChildrenSize(),r.type="element"):M(o)&&(r.key=o.__key,r.offset=o.getTextContent().length)}else if(n===s.getTextContent().length){const o=s.getNextSibling(),i=s.getParent();if(e&&B(o)&&o.isInline())r.key=o.__key,r.offset=0,r.type="element";else if((t||e)&&o===null&&B(i)&&i.isInline()&&!i.canInsertTextAfter()){const l=i.getNextSibling();M(l)&&(r.key=l.__key,r.offset=0)}}}function Ql(r,e,t){if(r.type==="text"&&e.type==="text"){const n=r.isBefore(e),s=r.is(e);go(r,n,s),go(e,!n,s),s&&(e.key=r.key,e.offset=r.offset,e.type=r.type);const o=se();if(o.isComposing()&&o._compositionKey!==r.key&&P(t)){const i=t.anchor,l=t.focus;mt(r,i.key,i.offset,i.type),mt(e,l.key,l.offset,l.type)}}}function Yl(r,e,t,n,s,o){if(r===null||t===null||!Ir(s,r,t))return null;const i=po(r,e,P(o)?o.anchor:null,s);if(i===null)return null;const l=po(t,n,P(o)?o.focus:null,s);if(l===null)return null;if(i.type==="element"&&l.type==="element"){const u=Ht(r),a=Ht(t);if(Z(u)&&Z(a))return null}return Ql(i,l,o),[i,l]}function qs(r){return B(r)&&!r.isInline()}function Xl(r,e,t,n,s,o){const i=dt(),l=new Dt(rt(r,e,s),rt(t,n,o),0,"");return l.dirty=!0,i._selection=l,l}function Ac(){const r=rt("root",0,"element"),e=rt("root",0,"element");return new Dt(r,e,0,"")}function mo(){return new Gn(new Set)}function xi(r,e,t,n){const s=t._window;if(s===null)return null;const o=n||s.event,i=o?o.type:void 0,l=i==="selectionchange",u=!Ss&&(l||i==="beforeinput"||i==="compositionstart"||i==="compositionend"||i==="click"&&o&&o.detail===3||i==="drop"||i===void 0);let a,c,f,d;if(P(r)&&!u)return r.clone();if(e===null)return null;if(a=e.anchorNode,c=e.focusNode,f=e.anchorOffset,d=e.focusOffset,l&&P(r)&&!Ir(t,a,c))return r.clone();const h=Yl(a,f,c,d,t,r);if(h===null)return null;const[p,m]=h;return new Dt(p,m,P(r)?r.format:0,P(r)?r.style:"")}function q(){return dt()._selection}function Kr(){return se()._editorState._selection}function Nn(r,e,t,n=1){const s=r.anchor,o=r.focus,i=s.getNode(),l=o.getNode();if(!e.is(i)&&!e.is(l))return;const u=e.__key;if(r.isCollapsed()){const a=s.offset;if(t<=a&&n>0||t<a&&n<0){const c=Math.max(0,a+n);s.set(u,c,"element"),o.set(u,c,"element"),yo(r)}}else{const a=r.isBackward(),c=a?o:s,f=c.getNode(),d=a?s:o,h=d.getNode();if(e.is(f)){const p=c.offset;(t<=p&&n>0||t<p&&n<0)&&c.set(u,Math.max(0,p+n),"element")}if(e.is(h)){const p=d.offset;(t<=p&&n>0||t<p&&n<0)&&d.set(u,Math.max(0,p+n),"element")}}yo(r)}function yo(r){const e=r.anchor,t=e.offset,n=r.focus,s=n.offset,o=e.getNode(),i=n.getNode();if(r.isCollapsed()){if(!B(o))return;const l=o.getChildrenSize(),u=t>=l,a=u?o.getChildAtIndex(l-1):o.getChildAtIndex(t);if(M(a)){let c=0;u&&(c=a.getTextContentSize()),e.set(a.__key,c,"text"),n.set(a.__key,c,"text")}}else{if(B(o)){const l=o.getChildrenSize(),u=t>=l,a=u?o.getChildAtIndex(l-1):o.getChildAtIndex(t);if(M(a)){let c=0;u&&(c=a.getTextContentSize()),e.set(a.__key,c,"text")}}if(B(i)){const l=i.getChildrenSize(),u=s>=l,a=u?i.getChildAtIndex(l-1):i.getChildAtIndex(s);if(M(a)){let c=0;u&&(c=a.getTextContentSize()),n.set(a.__key,c,"text")}}}}function Fn(r,e,t,n,s){let o=null,i=0,l=null;n!==null?(o=n.__key,M(n)?(i=n.getTextContentSize(),l="text"):B(n)&&(i=n.getChildrenSize(),l="element")):s!==null&&(o=s.__key,M(s)?l="text":B(s)&&(l="element")),o!==null&&l!==null?r.set(o,i,l):(i=e.getIndexWithinParent(),i===-1&&(i=t.getChildrenSize()),r.set(t.__key,i,"element"))}function xo(r,e,t,n,s){r.type==="text"?(r.key=t,e||(r.offset+=s)):r.offset>n.getIndexWithinParent()&&(r.offset-=1)}function kc(r,e,t,n,s,o,i){const l=n.anchorNode,u=n.focusNode,a=n.anchorOffset,c=n.focusOffset,f=document.activeElement;if(s.has("collaboration")&&f!==o||f!==null&&ui(f))return;if(!P(e))return void(r!==null&&Ir(t,l,u)&&n.removeAllRanges());const d=e.anchor,h=e.focus,p=d.key,m=h.key,x=En(t,p),D=En(t,m),_=d.offset,E=h.offset,C=e.format,A=e.style,v=e.isCollapsed();let b=x,w=D,S=!1;if(d.type==="text"){b=Cn(x);const $=d.getNode();S=$.getFormat()!==C||$.getStyle()!==A}else P(r)&&r.anchor.type==="text"&&(S=!0);var R,T,N,j,L;if(h.type==="text"&&(w=Cn(D)),b!==null&&w!==null&&(v&&(r===null||S||P(r)&&(r.format!==C||r.style!==A))&&(R=C,T=A,N=_,j=p,L=performance.now(),Ul=[R,T,N,j,L]),a!==_||c!==E||l!==b||u!==w||n.type==="Range"&&v||(f!==null&&o.contains(f)||o.focus({preventScroll:!0}),d.type==="element"))){try{n.setBaseAndExtent(b,_,w,E)}catch{}if(!s.has("skip-scroll-into-view")&&e.isCollapsed()&&o!==null&&o===document.activeElement){const $=e instanceof Dt&&e.anchor.type==="element"?b.childNodes[_]||null:n.rangeCount>0?n.getRangeAt(0):null;if($!==null){let H;if($ instanceof Text){const ue=document.createRange();ue.selectNode($),H=ue.getBoundingClientRect()}else H=$.getBoundingClientRect();(function(ue,re,we){const Ee=we.ownerDocument,Ge=Ee.defaultView;if(Ge===null)return;let{top:He,bottom:Me}=re,Je=0,Re=0,ae=we;for(;ae!==null;){const Le=ae===Ee.body;if(Le)Je=0,Re=Wn(ue).innerHeight;else{const ee=ae.getBoundingClientRect();Je=ee.top,Re=ee.bottom}let he=0;if(He<Je?he=-(Je-He):Me>Re&&(he=Me-Re),he!==0)if(Le)Ge.scrollBy(0,he);else{const ee=ae.scrollTop;ae.scrollTop+=he;const Be=ae.scrollTop-ee;He-=Be,Me-=Be}if(Le)break;ae=zr(ae)}})(t,H,o)}}Rs=!0}}function Zl(r){let e=q()||Kr();e===null&&(e=ie().selectEnd()),e.insertNodes(r)}function vs(r){let e=r;r.isCollapsed()||e.removeText();const t=q();P(t)&&(e=t),P(e)||O(161);const n=e.anchor;let s=n.getNode(),o=n.offset;for(;!gt(s);)[s,o]=Sc(s,o);return o}function Sc(r,e){const t=r.getParent();if(!t){const s=fe();return ie().append(s),s.select(),[ie(),0]}if(M(r)){const s=r.splitText(e);if(s.length===0)return[t,r.getIndexWithinParent()];const o=e===0?0:1;return[t,s[0].getIndexWithinParent()+o]}if(!B(r)||e===0)return[t,r.getIndexWithinParent()];const n=r.getChildAtIndex(e);if(n){const s=new Dt(rt(r.__key,e,"element"),rt(r.__key,e,"element"),0,""),o=r.insertNewAfter(s);o&&o.append(n,...n.getNextSiblings())}return[t,r.getIndexWithinParent()+1]}let ge=null,me=null,Se=!1,Cs=!1,pn=0;const _o={characterData:!0,childList:!0,subtree:!0};function Vr(){return Se||ge!==null&&ge._readOnly}function ke(){Se&&O(13)}function eu(){pn>99&&O(14)}function dt(){return ge===null&&O(195,tu()),ge}function se(){return me===null&&O(196,tu()),me}function tu(){let r=0;const e=new Set,t=Jn.version;if(typeof window<"u")for(const s of document.querySelectorAll("[contenteditable]")){const o=zn(s);if(ai(o))r++;else if(o){let i=String(o.constructor.version||"<0.17.1");i===t&&(i+=" (separately built, likely a bundler configuration issue)"),e.add(i)}}let n=` Detected on the page: ${r} compatible editor(s) with version ${t}`;return e.size&&(n+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),n}function Tc(){return me}function bo(r,e,t){const n=e.__type,s=function(l,u){const a=l._nodes.get(u);return a===void 0&&O(30,u),a}(r,n);let o=t.get(n);o===void 0&&(o=Array.from(s.transforms),t.set(n,o));const i=o.length;for(let l=0;l<i&&(o[l](e),e.isAttached());l++);}function vo(r,e){return r!==void 0&&r.__key!==e&&r.isAttached()}function ru(r,e){if(!e)return;const t=r._updateTags;let n=e;Array.isArray(e)||(n=[e]);for(const s of n)t.add(s)}function Bc(r){return _i(r,se()._nodes)}function _i(r,e){const t=r.type,n=e.get(t);n===void 0&&O(17,t);const s=n.klass;r.type!==s.getType()&&O(18,s.name);const o=s.importJSON(r),i=r.children;if(B(o)&&Array.isArray(i))for(let l=0;l<i.length;l++){const u=_i(i[l],e);o.append(u)}return o}function Co(r,e,t){const n=ge,s=Se,o=me;ge=e,Se=!0,me=r;try{return t()}finally{ge=n,Se=s,me=o}}function xt(r,e){const t=r._pendingEditorState,n=r._rootElement,s=r._headless||n===null;if(t===null)return;const o=r._editorState,i=o._selection,l=t._selection,u=r._dirtyType!==Ft,a=ge,c=Se,f=me,d=r._updating,h=r._observer;let p=null;if(r._pendingEditorState=null,r._editorState=t,!s&&u&&h!==null){me=r,ge=t,Se=!1,r._updating=!0;try{const v=r._dirtyType,b=r._dirtyElements,w=r._dirtyLeaves;h.disconnect(),p=mc(o,t,r,v,b,w)}catch(v){if(v instanceof Error&&r._onError(v),Cs)throw v;return lu(r,null,n,t),Dl(r),r._dirtyType=er,Cs=!0,xt(r,o),void(Cs=!1)}finally{h.observe(n,_o),r._updating=d,ge=a,Se=c,me=f}}t._readOnly||(t._readOnly=!0);const m=r._dirtyLeaves,x=r._dirtyElements,D=r._normalizedNodes,_=r._updateTags,E=r._deferred;u&&(r._dirtyType=Ft,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements=new Map,r._normalizedNodes=new Set,r._updateTags=new Set),function(v,b){const w=v._decorators;let S=v._pendingDecorators||w;const R=b._nodeMap;let T;for(T in S)R.has(T)||(S===w&&(S=Sl(v)),delete S[T])}(r,t);const C=s?null:Oe(r._window);if(r._editable&&C!==null&&(u||l===null||l.dirty)){me=r,ge=t;try{if(h!==null&&h.disconnect(),u||l===null||l.dirty){const v=r._blockCursorElement;v!==null&&pi(v,r,n),kc(i,l,r,C,_,n)}uc(r,n,l),h!==null&&h.observe(n,_o)}finally{me=f,ge=a}}p!==null&&function(v,b,w,S,R){const T=Array.from(v._listeners.mutation),N=T.length;for(let j=0;j<N;j++){const[L,$]=T[j],H=b.get($);H!==void 0&&L(H,{dirtyLeaves:S,prevEditorState:R,updateTags:w})}}(r,p,_,m,o),P(l)||l===null||i!==null&&i.is(l)||r.dispatchCommand(Js,void 0);const A=r._pendingDecorators;A!==null&&(r._decorators=A,r._pendingDecorators=null,Sr("decorator",r,!0,A)),function(v,b,w){const S=Gi(b),R=Gi(w);S!==R&&Sr("textcontent",v,!0,R)}(r,e||o,t),Sr("update",r,!0,{dirtyElements:x,dirtyLeaves:m,editorState:t,normalizedNodes:D,prevEditorState:e||o,tags:_}),function(v,b){if(v._deferred=[],b.length!==0){const w=v._updating;v._updating=!0;try{for(let S=0;S<b.length;S++)b[S]()}finally{v._updating=w}}}(r,E),function(v){const b=v._updates;if(b.length!==0){const w=b.shift();if(w){const[S,R]=w;su(v,S,R)}}}(r)}function Sr(r,e,t,...n){const s=e._updating;e._updating=t;try{const o=Array.from(e._listeners[r]);for(let i=0;i<o.length;i++)o[i].apply(null,n)}finally{e._updating=s}}function nu(r,e,t){if(r._updating===!1||me!==r){let s=!1;return r.update(()=>{s=nu(r,e,t)}),s}const n=ci(r);for(let s=4;s>=0;s--)for(let o=0;o<n.length;o++){const i=n[o]._commands.get(e);if(i!==void 0){const l=i[s];if(l!==void 0){const u=Array.from(l),a=u.length;for(let c=0;c<a;c++)if(u[c](t,r)===!0)return!0}}}return!1}function Do(r,e){const t=r._updates;let n=e||!1;for(;t.length!==0;){const s=t.shift();if(s){const[o,i]=s;let l;if(i!==void 0){if(l=i.onUpdate,i.skipTransforms&&(n=!0),i.discrete){const u=r._pendingEditorState;u===null&&O(191),u._flushSync=!0}l&&r._deferred.push(l),ru(r,i.tag)}o()}}return n}function su(r,e,t){const n=r._updateTags;let s,o=!1,i=!1;t!==void 0&&(s=t.onUpdate,ru(r,t.tag),o=t.skipTransforms||!1,i=t.discrete||!1),s&&r._deferred.push(s);const l=r._editorState;let u=r._pendingEditorState,a=!1;(u===null||u._readOnly)&&(u=r._pendingEditorState=iu(u||l),a=!0),u._flushSync=i;const c=ge,f=Se,d=me,h=r._updating;ge=u,Se=!1,r._updating=!0,me=r;try{a&&(r._headless?l._selection!==null&&(u._selection=l._selection.clone()):u._selection=function(D){const _=D.getEditorState()._selection,E=Oe(D._window);return P(_)||_==null?xi(_,E,D,null):_.clone()}(r));const m=r._compositionKey;e(),o=Do(r,o),function(D,_){const E=_.getEditorState()._selection,C=D._selection;if(P(C)){const A=C.anchor,v=C.focus;let b;if(A.type==="text"&&(b=A.getNode(),b.selectionTransform(E,C)),v.type==="text"){const w=v.getNode();b!==w&&w.selectionTransform(E,C)}}}(u,r),r._dirtyType!==Ft&&(o?function(D,_){const E=_._dirtyLeaves,C=D._nodeMap;for(const A of E){const v=C.get(A);M(v)&&v.isAttached()&&v.isSimpleText()&&!v.isUnmergeable()&&Ki(v)}}(u,r):function(D,_){const E=_._dirtyLeaves,C=_._dirtyElements,A=D._nodeMap,v=yt(),b=new Map;let w=E,S=w.size,R=C,T=R.size;for(;S>0||T>0;){if(S>0){_._dirtyLeaves=new Set;for(const N of w){const j=A.get(N);M(j)&&j.isAttached()&&j.isSimpleText()&&!j.isUnmergeable()&&Ki(j),j!==void 0&&vo(j,v)&&bo(_,j,b),E.add(N)}if(w=_._dirtyLeaves,S=w.size,S>0){pn++;continue}}_._dirtyLeaves=new Set,_._dirtyElements=new Map;for(const N of R){const j=N[0],L=N[1];if(j!=="root"&&!L)continue;const $=A.get(j);$!==void 0&&vo($,v)&&bo(_,$,b),C.set(j,L)}w=_._dirtyLeaves,S=w.size,R=_._dirtyElements,T=R.size,pn++}_._dirtyLeaves=E,_._dirtyElements=C}(u,r),Do(r),function(D,_,E,C){const A=D._nodeMap,v=_._nodeMap,b=[];for(const[w]of C){const S=v.get(w);S!==void 0&&(S.isAttached()||(B(S)&&jl(S,w,A,v,b,C),A.has(w)||C.delete(w),b.push(w)))}for(const w of b)v.delete(w);for(const w of E){const S=v.get(w);S===void 0||S.isAttached()||(A.has(w)||E.delete(w),v.delete(w))}}(l,u,r._dirtyLeaves,r._dirtyElements)),m!==r._compositionKey&&(u._flushSync=!0);const x=u._selection;if(P(x)){const D=u._nodeMap,_=x.anchor.key,E=x.focus.key;D.get(_)!==void 0&&D.get(E)!==void 0||O(19)}else Ye(x)&&x._nodes.size===0&&(u._selection=null)}catch(m){return m instanceof Error&&r._onError(m),r._pendingEditorState=l,r._dirtyType=er,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),void xt(r)}finally{ge=c,Se=f,me=d,r._updating=h,pn=0}r._dirtyType!==Ft||function(m,x){const D=x.getEditorState()._selection,_=m._selection;if(_!==null){if(_.dirty||!_.is(D))return!0}else if(D!==null)return!0;return!1}(u,r)?u._flushSync?(u._flushSync=!1,xt(r)):a&&rc(()=>{xt(r)}):(u._flushSync=!1,a&&(n.clear(),r._deferred=[],r._pendingEditorState=null))}function Ne(r,e,t){r._updating?r._updates.push([e,t]):su(r,e,t)}class Tr{constructor(e,t,n){this.element=e,this.before=t||null,this.after=n||null}withBefore(e){return new Tr(this.element,e,this.after)}withAfter(e){return new Tr(this.element,this.before,e)}withElement(e){return new Tr(e,this.before,this.after)}insertChild(e){const t=this.before||this.getManagedLineBreak();return t!==null&&t.parentElement!==this.element&&O(222),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&O(223),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&O(224),this.element.replaceChild(e,t),this}getFirstChild(){const e=this.after?this.after.nextSibling:this.element.firstChild;return e===this.before||e===this.getManagedLineBreak()?null:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(e===null)this.removeManagedLineBreak();else{const t=e==="decorator"&&(Rr||$n);this.insertManagedLineBreak(t)}}removeManagedLineBreak(){const e=this.getManagedLineBreak();if(e){const t=this.element,n=e.nodeName==="IMG"?e.nextSibling:null;n&&t.removeChild(n),t.removeChild(e),t.__lexicalLineBreak=void 0}}insertManagedLineBreak(e){const t=this.getManagedLineBreak();if(t){if(e===(t.nodeName==="IMG"))return;this.removeManagedLineBreak()}const n=this.element,s=this.before,o=document.createElement("br");if(n.insertBefore(o,s),e){const i=document.createElement("img");i.setAttribute("data-lexical-linebreak","true"),i.style.cssText="display: inline !important; border: 0px !important; margin: 0px !important;",i.alt="",n.insertBefore(i,o),n.__lexicalLineBreak=i}else n.__lexicalLineBreak=o}getFirstChildOffset(){let e=0;for(let t=this.after;t!==null;t=t.previousSibling)e++;return e}resolveChildIndex(e,t,n,s){if(n===this.element){const u=this.getFirstChildOffset();return[e,Math.min(u+e.getChildrenSize(),Math.max(u,s))]}const o=wo(t,n);o.push(s);const i=wo(t,this.element);let l=e.getIndexWithinParent();for(let u=0;u<i.length;u++){const a=o[u],c=i[u];if(a===void 0||a<c)break;if(a>c){l+=1;break}}return[e.getParentOrThrow(),l]}}function wo(r,e){const t=[];let n=e;for(;n!==r&&n!==null;n=e.parentNode){let s=0;for(let o=n.previousSibling;o!==null;o=n.previousSibling)s++;t.push(s)}return n!==r&&O(225),t.reverse()}class ft extends Vn{constructor(e){super(e),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null}afterCloneFrom(e){super.afterCloneFrom(e),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}getFormat(){return this.getLatest().__format}getFormatType(){const e=this.getFormat();return Va[e]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const e=[];let t=this.getFirstChild();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getChildrenKeys(){const e=[];let t=this.getFirstChild();for(;t!==null;)e.push(t.__key),t=t.getNextSibling();return e}getChildrenSize(){return this.getLatest().__size}isEmpty(){return this.getChildrenSize()===0}isDirty(){const e=se()._dirtyElements;return e!==null&&e.has(this.__key)}isLastChild(){const e=this.getLatest(),t=this.getParentOrThrow().getLastChild();return t!==null&&t.is(e)}getAllTextNodes(){const e=[];let t=this.getFirstChild();for(;t!==null;){if(M(t)&&e.push(t),B(t)){const n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;B(e);){const t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;B(e);){const t=e.getLastChild();if(t===null)break;e=t}return e}getDescendantByIndex(e){const t=this.getChildren(),n=t.length;if(e>=n){const o=t[n-1];return B(o)&&o.getLastDescendant()||o||null}const s=t[e];return B(s)&&s.getFirstDescendant()||s||null}getFirstChild(){const e=this.getLatest().__first;return e===null?null:_e(e)}getFirstChildOrThrow(){const e=this.getFirstChild();return e===null&&O(45,this.__key),e}getLastChild(){const e=this.getLatest().__last;return e===null?null:_e(e)}getLastChildOrThrow(){const e=this.getLastChild();return e===null&&O(96,this.__key),e}getChildAtIndex(e){const t=this.getChildrenSize();let n,s;if(e<t/2){for(n=this.getFirstChild(),s=0;n!==null&&s<=e;){if(s===e)return n;n=n.getNextSibling(),s++}return null}for(n=this.getLastChild(),s=t-1;n!==null&&s>=e;){if(s===e)return n;n=n.getPreviousSibling(),s--}return null}getTextContent(){let e="";const t=this.getChildren(),n=t.length;for(let s=0;s<n;s++){const o=t[s];e+=o.getTextContent(),B(o)&&s!==n-1&&!o.isInline()&&(e+=at)}return e}getTextContentSize(){let e=0;const t=this.getChildren(),n=t.length;for(let s=0;s<n;s++){const o=t[s];e+=o.getTextContentSize(),B(o)&&s!==n-1&&!o.isInline()&&(e+=at.length)}return e}getDirection(){return this.getLatest().__dir}hasFormat(e){if(e!==""){const t=qi[e];return!!(this.getFormat()&t)}return!1}select(e,t){ke();const n=q();let s=e,o=t;const i=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){const u=this.getFirstChild();if(M(u)||B(u))return u.select(0,0)}else if(!(e!==void 0&&e!==i||t!==void 0&&t!==i)){const u=this.getLastChild();if(M(u)||B(u))return u.select()}}s===void 0&&(s=i),o===void 0&&(o=i);const l=this.__key;return P(n)?(n.anchor.set(l,s,"element"),n.focus.set(l,o,"element"),n.dirty=!0,n):Xl(l,s,l,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(t=>t.remove()),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){const t=this.getWritable();return t.__dir=e,t}setFormat(e){return this.getWritable().__format=e!==""?qi[e]:0,this}setStyle(e){return this.getWritable().__style=e||"",this}setIndent(e){return this.getWritable().__indent=e,this}splice(e,t,n){const s=n.length,o=this.getChildrenSize(),i=this.getWritable();e+t<=o||O(226,String(e),String(t),String(o));const l=i.__key,u=[],a=[],c=this.getChildAtIndex(e+t);let f=null,d=o-t+s;if(e!==0)if(e===o)f=this.getLastChild();else{const p=this.getChildAtIndex(e);p!==null&&(f=p.getPreviousSibling())}if(t>0){let p=f===null?this.getFirstChild():f.getNextSibling();for(let m=0;m<t;m++){p===null&&O(100);const x=p.getNextSibling(),D=p.__key;Bt(p.getWritable()),a.push(D),p=x}}let h=f;for(let p=0;p<s;p++){const m=n[p];h!==null&&m.is(h)&&(f=h=h.getPreviousSibling());const x=m.getWritable();x.__parent===l&&d--,Bt(x);const D=m.__key;if(h===null)i.__first=D,x.__prev=null;else{const _=h.getWritable();_.__next=D,x.__prev=_.__key}m.__key===l&&O(76),x.__parent=l,u.push(D),h=m}if(e+t===o)h!==null&&(h.getWritable().__next=null,i.__last=h.__key);else if(c!==null){const p=c.getWritable();if(h!==null){const m=h.getWritable();p.__prev=h.__key,m.__next=c.__key}else p.__prev=null}if(i.__size=d,a.length){const p=q();if(P(p)){const m=new Set(a),x=new Set(u),{anchor:D,focus:_}=p;Eo(D,m,x)&&Fn(D,D.getNode(),this,f,c),Eo(_,m,x)&&Fn(_,_.getNode(),this,f,c),d!==0||this.canBeEmpty()||tt(this)||this.remove()}}return i}getDOMSlot(e){return new Tr(e)}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&ct(t)){const n=this.getIndent();n>0&&(t.style.paddingInlineStart=40*n+"px")}return{element:t}}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"element",version:1}}insertNewAfter(e,t){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,t,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(e,t){const n=this.getDOMSlot(e);let s=n.getFirstChild();for(let o=this.getFirstChild();o;o=o.getNextSibling()){const i=t.getElementByKey(o.getKey());i!==null&&(s==null?(n.insertChild(i),s=i):s!==i&&n.replaceChild(i,s),s=s.nextSibling)}}}function B(r){return r instanceof ft}function Eo(r,e,t){let n=r.getNode();for(;n;){const s=n.__key;if(e.has(s)&&!t.has(s))return!0;n=n.getParent()}return!1}class Nc extends Vn{constructor(e){super(e)}decorate(e,t){O(47)}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function Z(r){return r instanceof Nc}class Gr extends ft{static getType(){return"root"}static clone(){return new Gr}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){O(51)}getTextContent(){const e=this.__cachedText;return!Vr()&&se()._dirtyType!==Ft||e===null?super.getTextContent():e}remove(){O(52)}replace(e){O(53)}insertBefore(e){O(54)}insertAfter(e){O(55)}updateDOM(e,t){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];B(n)||Z(n)||O(56)}return super.append(...e)}static importJSON(e){const t=ie();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"root",version:1}}collapseAtStart(){return!0}}function Ce(r){return r instanceof Gr}function iu(r){return new Hn(new Map(r._nodeMap))}function bi(){return new Hn(new Map([["root",new Gr]]))}function ou(r){const e=r.exportJSON(),t=r.constructor;if(e.type!==t.getType()&&O(130,t.name),B(r)){const n=e.children;Array.isArray(n)||O(59,t.name);const s=r.getChildren();for(let o=0;o<s.length;o++){const i=ou(s[o]);n.push(i)}}return e}class Hn{constructor(e,t){this._nodeMap=e,this._selection=t||null,this._flushSync=!1,this._readOnly=!1}isEmpty(){return this._nodeMap.size===1&&this._selection===null}read(e,t){return Co(t&&t.editor||null,this,e)}clone(e){const t=new Hn(this._nodeMap,e===void 0?this._selection:e);return t._readOnly=!0,t}toJSON(){return Co(null,this,()=>({root:ou(ie())}))}}class vi extends ft{static getType(){return"artificial"}createDOM(e){return document.createElement("div")}}class sr extends ft{constructor(e){super(e),this.__textFormat=0,this.__textStyle=""}static getType(){return"paragraph"}getTextFormat(){return this.getLatest().__textFormat}setTextFormat(e){const t=this.getWritable();return t.__textFormat=e,t}hasTextFormat(e){const t=Lt[e];return!!(this.getTextFormat()&t)}getFormatFlags(e,t){return Dn(this.getLatest().__textFormat,e,t)}getTextStyle(){return this.getLatest().__textStyle}setTextStyle(e){const t=this.getWritable();return t.__textStyle=e,t}static clone(e){return new sr(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}createDOM(e){const t=document.createElement("p"),n=wr(e.theme,"paragraph");return n!==void 0&&t.classList.add(...n),t}updateDOM(e,t,n){return!1}static importDOM(){return{p:e=>({conversion:Fc,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&ct(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=fe();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t.setTextFormat(e.textFormat),t}exportJSON(){return{...super.exportJSON(),textFormat:this.getTextFormat(),textStyle:this.getTextStyle(),type:"paragraph",version:1}}insertNewAfter(e,t){const n=fe();n.setTextFormat(e.format),n.setTextStyle(e.style);const s=this.getDirection();return n.setDirection(s),n.setFormat(this.getFormatType()),n.setStyle(this.getTextStyle()),this.insertAfter(n,t),n}collapseAtStart(){const e=this.getChildren();if(e.length===0||M(e[0])&&e[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 Fc(r){const e=fe();return r.style&&(e.setFormat(r.style.textAlign),mi(r,e)),{node:e}}function fe(){return st(new sr)}function rr(r){return r instanceof sr}const Y=0,Jt=1,Lc=4;function lu(r,e,t,n){const s=r._keyToDOMMap;s.clear(),r._editorState=bi(),r._pendingEditorState=n,r._compositionKey=null,r._dirtyType=Ft,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),r._normalizedNodes=new Set,r._updateTags=new Set,r._updates=[],r._blockCursorElement=null;const o=r._observer;o!==null&&(o.disconnect(),r._observer=null),e!==null&&(e.textContent=""),t!==null&&(t.textContent="",s.set("root",t))}function jc(r){const e=r||{},t=Tc(),n=e.theme||{},s=r===void 0?t:e.parentEditor||null,o=e.disableEvents||!1,i=bi(),l=e.namespace||(s!==null?s._config.namespace:Nl()),u=e.editorState,a=[Gr,nr,qr,Ur,sr,vi,...e.nodes||[]],{onError:c,html:f}=e,d=e.editable===void 0||e.editable;let h;if(r===void 0&&t!==null)h=t._nodes;else{h=new Map;for(let m=0;m<a.length;m++){let x=a[m],D=null,_=null;if(typeof x!="function"){const v=x;x=v.replace,D=v.with,_=v.withKlass||null}const E=x.getType(),C=x.transform(),A=new Set;C!==null&&A.add(C),h.set(E,{exportDOM:f&&f.export?f.export.get(x):void 0,klass:x,replace:D,replaceWithKlass:_,transforms:A})}}const p=new Jn(i,s,h,{disableEvents:o,namespace:l,theme:n},c||console.error,function(m,x){const D=new Map,_=new Set,E=C=>{Object.keys(C).forEach(A=>{let v=D.get(A);v===void 0&&(v=[],D.set(A,v)),v.push(C[A])})};return m.forEach(C=>{const A=C.klass.importDOM;if(A==null||_.has(A))return;_.add(A);const v=A.call(C.klass);v!==null&&E(v)}),x&&E(x),D}(h,f?f.import:void 0),d);return u!==void 0&&(p._pendingEditorState=u,p._dirtyType=er),p}class Jn{constructor(e,t,n,s,o,i,l){this._parentEditor=t,this._rootElement=null,this._editorState=e,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=s,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=Ft,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=Nl(),this._onError=o,this._htmlConversions=i,this._editable=l,this._headless=t!==null&&t._headless,this._window=null,this._blockCursorElement=null}isComposing(){return this._compositionKey!=null}registerUpdateListener(e){const t=this._listeners.update;return t.add(e),()=>{t.delete(e)}}registerEditableListener(e){const t=this._listeners.editable;return t.add(e),()=>{t.delete(e)}}registerDecoratorListener(e){const t=this._listeners.decorator;return t.add(e),()=>{t.delete(e)}}registerTextContentListener(e){const t=this._listeners.textcontent;return t.add(e),()=>{t.delete(e)}}registerRootListener(e){const t=this._listeners.root;return e(this._rootElement,null),t.add(e),()=>{e(null,this._rootElement),t.delete(e)}}registerCommand(e,t,n){n===void 0&&O(35);const s=this._commands;s.has(e)||s.set(e,[new Set,new Set,new Set,new Set,new Set]);const o=s.get(e);o===void 0&&O(36,String(e));const i=o[n];return i.add(t),()=>{i.delete(t),o.every(l=>l.size===0)&&s.delete(e)}}registerMutationListener(e,t,n){const s=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,o=this._listeners.mutation;o.set(t,s);const i=n&&n.skipInitialization;return i!==void 0&&i||this.initializeMutationListener(t,s),()=>{o.delete(t)}}getRegisteredNode(e){const t=this._nodes.get(e.getType());return t===void 0&&O(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){const n=this._editorState,s=fc(n).get(t.getType());if(!s)return;const o=new Map;for(const i of s.keys())o.set(i,"created");o.size>0&&e(o,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(e,t){const n=this.getRegisteredNode(e);return n.transforms.add(t),n}registerNodeTransform(e,t){const n=this.registerNodeTransformToKlass(e,t),s=[n],o=n.replaceWithKlass;if(o!=null){const u=this.registerNodeTransformToKlass(o,t);s.push(u)}var i,l;return i=this,l=e.getType(),Ne(i,()=>{const u=dt();if(u.isEmpty())return;if(l==="root")return void ie().markDirty();const a=u._nodeMap;for(const[,c]of a)c.markDirty()},i._pendingEditorState===null?{tag:"history-merge"}:void 0),()=>{s.forEach(u=>u.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,t){return I(this,e,t)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(e){const t=this._rootElement;if(e!==t){const n=wr(this._config.theme,"root"),s=this._pendingEditorState||this._editorState;if(this._rootElement=e,lu(this,t,e,s),t!==null&&(this._config.disableEvents||yc(t),n!=null&&t.classList.remove(...n)),e!==null){const o=function(l){const u=l.ownerDocument;return u&&u.defaultView||null}(e),i=e.style;i.userSelect="text",i.whiteSpace="pre-wrap",i.wordBreak="break-word",e.setAttribute("data-lexical-editor","true"),this._window=o,this._dirtyType=er,Dl(this),this._updateTags.add("history-merge"),xt(this),this._config.disableEvents||function(l,u){const a=l.ownerDocument,c=Bn.get(a);(c===void 0||c<1)&&a.addEventListener("selectionchange",Gl),Bn.set(a,(c||0)+1),l.__lexicalEditor=u;const f=Vl(l);for(let d=0;d<Ms.length;d++){const[h,p]=Ms[d],m=typeof p=="function"?x=>{oo(x)||(io(x),(u.isEditable()||h==="click")&&p(x,u))}:x=>{if(oo(x))return;io(x);const D=u.isEditable();switch(h){case"cut":return D&&I(u,Xs,x);case"copy":return I(u,Rn,x);case"paste":return D&&I(u,Mn,x);case"dragstart":return D&&I(u,gl,x);case"dragover":return D&&I(u,ml,x);case"dragend":return D&&I(u,Ta,x);case"focus":return D&&I(u,Fa,x);case"blur":return D&&I(u,La,x);case"drop":return D&&I(u,pl,x)}};l.addEventListener(h,m),f.push(()=>{l.removeEventListener(h,m)})}}(e,this),n!=null&&e.classList.add(...n)}else this._editorState=s,this._pendingEditorState=null,this._window=null;Sr("root",this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&O(38);let n=e;n._readOnly&&(n=iu(e),n._selection=e._selection?e._selection.clone():null),Cl(this);const s=this._pendingEditorState,o=this._updateTags,i=t!==void 0?t.tag:null;s===null||s.isEmpty()||(i!=null&&o.add(i),xt(this)),this._pendingEditorState=n,this._dirtyType=er,this._dirtyElements.set("root",!1),this._compositionKey=null,i!=null&&o.add(i),this._updating||xt(this)}parseEditorState(e,t){return function(n,s,o){const i=bi(),l=ge,u=Se,a=me,c=s._dirtyElements,f=s._dirtyLeaves,d=s._cloneNotNeeded,h=s._dirtyType;s._dirtyElements=new Map,s._dirtyLeaves=new Set,s._cloneNotNeeded=new Set,s._dirtyType=0,ge=i,Se=!1,me=s;try{const p=s._nodes;_i(n.root,p),o&&o(),i._readOnly=!0}catch(p){p instanceof Error&&s._onError(p)}finally{s._dirtyElements=c,s._dirtyLeaves=f,s._cloneNotNeeded=d,s._dirtyType=h,ge=l,Se=u,me=a}return i}(typeof e=="string"?JSON.parse(e):e,this,t)}read(e){return xt(this),this.getEditorState().read(e,{editor:this})}update(e,t){Ne(this,e,t)}focus(e,t={}){const n=this._rootElement;n!==null&&(n.setAttribute("autocapitalize","off"),Ne(this,()=>{const s=q(),o=ie();s!==null?s.dirty=!0:o.getChildrenSize()!==0&&(t.defaultSelection==="rootStart"?o.selectStart():o.selectEnd())},{onUpdate:()=>{n.removeAttribute("autocapitalize"),e&&e()},tag:"focus"}),this._pendingEditorState===null&&n.removeAttribute("autocapitalize"))}blur(){const e=this._rootElement;e!==null&&e.blur();const t=Oe(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,Sr("editable",this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}}Jn.version="0.21.0+prod.esm";const uu=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Pc=uu?k.useLayoutEffect:k.useEffect,un={tag:"history-merge"};function Oc({initialConfig:r,children:e}){const t=k.useMemo(()=>{const{theme:n,namespace:s,nodes:o,onError:i,editorState:l,html:u}=r,a=_a(null,n),c=jc({editable:r.editable,html:u,namespace:s,nodes:o,onError:f=>i(f,c),theme:n});return function(f,d){if(d!==null){if(d===void 0)f.update(()=>{const h=ie();if(h.isEmpty()){const p=fe();h.append(p);const m=uu?document.activeElement:null;(q()!==null||m!==null&&m===f.getRootElement())&&p.select()}},un);else if(d!==null)switch(typeof d){case"string":{const h=f.parseEditorState(d);f.setEditorState(h,un);break}case"object":f.setEditorState(d,un);break;case"function":f.update(()=>{ie().isEmpty()&&d(f)},un)}}}(c,l),[c,a]},[]);return Pc(()=>{const n=r.editable,[s]=t;s.setEditable(n===void 0||n)},[]),g.jsx(il.Provider,{value:t,children:e})}const Mc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?k.useLayoutEffect:k.useEffect;function Rc(r){return{initialValueFn:()=>r.isEditable(),subscribe:e=>r.registerEditableListener(e)}}function $c(){return function(r){const[e]=nt(),t=k.useMemo(()=>r(e),[e,r]),[n,s]=k.useState(()=>t.initialValueFn()),o=k.useRef(n);return Mc(()=>{const{initialValueFn:i,subscribe:l}=t,u=i();return o.current!==u&&(o.current=u,s(u)),l(a=>{o.current=a,s(a)})},[t,r]),n}(Rc)}function Ic(){return ie().getTextContent()}function zc(r,e=!0){if(r)return!1;let t=Ic();return e&&(t=t.trim()),t===""}function qc(r){if(!zc(r,!1))return!1;const e=ie().getChildren(),t=e.length;if(t>1)return!1;for(let n=0;n<t;n++){const s=e[n];if(Z(s))return!1;if(B(s)){if(!rr(s)||s.__indent!==0)return!1;const o=s.getChildren(),i=o.length;for(let l=0;l<i;l++){const u=o[n];if(!M(u))return!1}}}return!0}function au(r){return()=>qc(r)}function Uc(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}Uc(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function Wc(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Kc=Wc(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const Vc=new Map;function Gc(r){const e={};if(!r)return e;const t=r.split(";");for(const n of t)if(n!==""){const[s,o]=n.split(/:([^]+)/);s&&o&&(e[s.trim()]=o.trim())}return e}function cu(r,e){const t=r.getStartEndPoints();if(e.isSelected(r)&&!e.isSegmented()&&!e.isToken()&&t!==null){const[n,s]=t,o=r.isBackward(),i=n.getNode(),l=s.getNode(),u=e.is(i),a=e.is(l);if(u||a){const[c,f]=zs(r),d=i.is(l),h=e.is(o?l:i),p=e.is(o?i:l);let m,x=0;return d?(x=c>f?f:c,m=c>f?c:f):h?(x=o?f:c,m=void 0):p&&(x=0,m=o?c:f),e.__text=e.__text.slice(x,m),e}}return e}function Hc(r){const e=r.getStyle(),t=Gc(e);Vc.set(e,t)}function Jc(r,e){if(r===null)return;const t=r.getStartEndPoints(),n=t?t[0]:null;if(n!==null&&n.key==="root"){const i=e(),l=ie(),u=l.getFirstChild();return void(u?u.replace(i,!0):l.append(i))}const s=r.getNodes(),o=n!==null&&function(i,l){let u=i;for(;u!==null&&u.getParent()!==null&&!l(u);)u=u.getParentOrThrow();return l(u)?u:null}(n.getNode(),So);o&&s.indexOf(o)===-1&&s.push(o);for(let i=0;i<s.length;i++){const l=s[i];if(!So(l))continue;B(l)||Kc(178);const u=e();u.setFormat(l.getFormatType()),u.setIndent(l.getIndent()),l.replace(u,!0)}}function Ao(r,e){const t=Lr(r.focus,e);return Z(t)&&!t.isIsolated()||B(t)&&!t.isInline()&&!t.canBeEmpty()}function Qc(r,e,t,n){r.modify(e?"extend":"move",t,n)}function Yc(r){const e=r.anchor.getNode();return(Ce(e)?e:e.getParentOrThrow()).getDirection()==="rtl"}function ko(r,e,t){const n=Yc(r);Qc(r,e,t?!n:n,"character")}function So(r){if(Z(r)||!B(r)||tt(r))return!1;const e=r.getFirstChild(),t=e===null||Nt(e)||M(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function Xc(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Zc=Xc(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const du=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,ed=du&&"documentMode"in document?document.documentMode:null;!(!du||!("InputEvent"in window)||ed)&&"getTargetRanges"in new window.InputEvent("input");function fu(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}function Mt(...r){return()=>{for(let e=r.length-1;e>=0;e--)r[e]();r.length=0}}function Hr(r,...e){const t=fu(...e);t.length>0&&r.classList.add(...t)}function hu(r,...e){const t=fu(...e);t.length>0&&r.classList.remove(...t)}function td(r,e){let t=r;for(;t!=null;){if(t instanceof e)return t;t=t.getParent()}return null}function rd(r){const e=Qn(r,t=>B(t)&&!t.isInline());return B(e)||Zc(4,r.__key),e}const Qn=(r,e)=>{let t=r;for(;t!==ie()&&t!=null;){if(e(t))return t;t=t.getParent()}return null};function _t(r,e){return r!==null&&Object.getPrototypeOf(r).constructor.name===e.name}function nd(r){const e=window.location.origin,t=n=>{if(n.origin!==e)return;const s=r.getRootElement();if(document.activeElement!==s)return;const o=n.data;if(typeof o=="string"){let i;try{i=JSON.parse(o)}catch{return}if(i&&i.protocol==="nuanria_messaging"&&i.type==="request"){const l=i.payload;if(l&&l.functionId==="makeChanges"){const u=l.args;if(u){const[a,c,f,d,h,p]=u;r.update(()=>{const m=q();if(P(m)){const x=m.anchor;let D=x.getNode(),_=0,E=0;if(M(D)&&a>=0&&c>=0&&(_=a,E=a+c,m.setTextNodeRange(D,_,D,E)),_===E&&f===""||(m.insertRawText(f),D=x.getNode()),M(D)){_=d,E=d+h;const C=D.getTextContentSize();_=_>C?C:_,E=E>C?C:E,m.setTextNodeRange(D,_,D,E)}n.stopImmediatePropagation()}})}}}}};return window.addEventListener("message",t,!0),()=>{window.removeEventListener("message",t,!0)}}function pu(r,e){const t=e.body?e.body.childNodes:[];let n=[];const s=[];for(let o=0;o<t.length;o++){const i=t[o];if(!yu.has(i.nodeName)){const l=xu(i,r,s,!1);l!==null&&(n=n.concat(l))}}return function(o){for(const i of o)i.getNextSibling()instanceof vi&&i.insertAfter(Pt());for(const i of o){const l=i.getChildren();for(const u of l)i.insertBefore(u);i.remove()}}(s),n}function gu(r,e){if(typeof document>"u"||typeof window>"u"&&global.window===void 0)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const t=document.createElement("div"),n=ie().getChildren();for(let s=0;s<n.length;s++)mu(r,n[s],t,e);return t.innerHTML}function mu(r,e,t,n=null){let s=n===null||e.isSelected(n);const o=B(e)&&e.excludeFromCopy("html");let i=e;if(n!==null){let h=gi(e);h=M(h)&&n!==null?cu(n,h):h,i=h}const l=B(i)?i.getChildren():[],u=r._nodes.get(i.getType());let a;a=u&&u.exportDOM!==void 0?u.exportDOM(r,i):i.exportDOM(r);const{element:c,after:f}=a;if(!c)return!1;const d=document.createDocumentFragment();for(let h=0;h<l.length;h++){const p=l[h],m=mu(r,p,d,n);!s&&B(e)&&m&&e.extractWithChild(p,n,"html")&&(s=!0)}if(s&&!o){if((ct(c)||eo(c))&&c.append(d),t.append(c),f){const h=f.call(i,c);h&&(eo(c)?c.replaceChildren(h):c.replaceWith(h))}}else t.append(d);return s}const yu=new Set(["STYLE","SCRIPT"]);function xu(r,e,t,n,s=new Map,o){let i=[];if(yu.has(r.nodeName))return i;let l=null;const u=function(p,m){const{nodeName:x}=p,D=m._htmlConversions.get(x.toLowerCase());let _=null;if(D!==void 0)for(const E of D){const C=E(p);C!==null&&(_===null||(_.priority||0)<=(C.priority||0))&&(_=C)}return _!==null?_.conversion:null}(r,e),a=u?u(r):null;let c=null;if(a!==null){c=a.after;const p=a.node;if(l=Array.isArray(p)?p[p.length-1]:p,l!==null){for(const[,m]of s)if(l=m(l,o),!l)break;l&&i.push(...Array.isArray(p)?p:[l])}a.forChild!=null&&s.set(r.nodeName,a.forChild)}const f=r.childNodes;let d=[];const h=(l==null||!tt(l))&&(l!=null&&qs(l)||n);for(let p=0;p<f.length;p++)d.push(...xu(f[p],e,t,h,new Map(s),l));return c!=null&&(d=c(d)),An(r)&&(d=sd(r,d,h?()=>{const p=new vi;return t.push(p),p}:fe)),l==null?d.length>0?i=i.concat(d):An(r)&&function(p){return p.nextSibling==null||p.previousSibling==null?!1:Ts(p.nextSibling)&&Ts(p.previousSibling)}(r)&&(i=i.concat(Pt())):B(l)&&l.append(...d),i}function sd(r,e,t){const n=r.style.textAlign,s=[];let o=[];for(let i=0;i<e.length;i++){const l=e[i];if(qs(l))n&&!l.getFormat()&&l.setFormat(n),s.push(l);else if(o.push(l),i===e.length-1||i<e.length-1&&qs(e[i+1])){const u=t();u.setFormat(n),u.append(...o),s.push(u),o=[]}}return s}function id(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ln=id(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function od(r,e=q()){return e==null&&Ln(166),P(e)&&e.isCollapsed()||e.getNodes().length===0?"":gu(r,e)}function ld(r,e=q()){return e==null&&Ln(166),P(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(ud(r,e))}function To(r,e,t){const n=r.getData("application/x-lexical-editor");if(n)try{const i=JSON.parse(n);if(i.namespace===t._config.namespace&&Array.isArray(i.nodes))return Bo(t,ad(i.nodes),e)}catch{}const s=r.getData("text/html");if(s)try{const i=new DOMParser().parseFromString(function(l){return window.trustedTypes&&window.trustedTypes.createPolicy?window.trustedTypes.createPolicy("lexical",{createHTML:u=>u}).createHTML(l):l}(s),"text/html");return Bo(t,pu(t,i),e)}catch{}const o=r.getData("text/plain")||r.getData("text/uri-list");if(o!=null)if(P(e)){const i=o.split(/(\r?\n|\t)/);i[i.length-1]===""&&i.pop();for(let l=0;l<i.length;l++){const u=q();if(P(u)){const a=i[l];a===`
|
|
71
|
+
`?n.push(Pt()):i===" "?n.push(Wr()):n.push(pe(i))}this.insertNodes(n)}insertText(e){const t=this.anchor,n=this.focus,s=this.format,o=this.style;let i=t,l=n;!this.isCollapsed()&&n.isBefore(t)&&(i=n,l=t),i.type==="element"&&function(x,C,_,E){const D=x.getNode(),A=D.getChildAtIndex(x.offset),v=pe(),b=De(D)?fe().append(v):v;v.setFormat(_),v.setStyle(E),A===null?D.append(b):A.insertBefore(b),x.is(C)&&C.set(v.__key,0,"text"),x.set(v.__key,0,"text")}(i,l,s,o);const u=i.offset;let a=l.offset;const c=this.getNodes(),f=c.length;let d=c[0];M(d)||O(26);const h=d.getTextContent().length,p=d.getParentOrThrow();let m=c[f-1];if(f===1&&l.type==="element"&&(a=h,l.set(i.key,a,"text")),this.isCollapsed()&&u===h&&(d.isSegmented()||d.isToken()||!d.canInsertTextAfter()||!p.canInsertTextAfter()&&d.getNextSibling()===null)){let x=d.getNextSibling();if(M(x)&&x.canInsertTextBefore()&&!kt(x)||(x=pe(),x.setFormat(s),x.setStyle(o),p.canInsertTextAfter()?d.insertAfter(x):p.insertAfter(x)),x.select(0,0),d=x,e!=="")return void this.insertText(e)}else if(this.isCollapsed()&&u===0&&(d.isSegmented()||d.isToken()||!d.canInsertTextBefore()||!p.canInsertTextBefore()&&d.getPreviousSibling()===null)){let x=d.getPreviousSibling();if(M(x)&&!kt(x)||(x=pe(),x.setFormat(s),p.canInsertTextBefore()?d.insertBefore(x):p.insertBefore(x)),x.select(),d=x,e!=="")return void this.insertText(e)}else if(d.isSegmented()&&u!==h){const x=pe(d.getTextContent());x.setFormat(s),d.replace(x),d=x}else if(!this.isCollapsed()&&e!==""){const x=m.getParent();if(!p.canInsertTextBefore()||!p.canInsertTextAfter()||B(x)&&(!x.canInsertTextBefore()||!x.canInsertTextAfter()))return this.insertText(""),Ql(this.anchor,this.focus,null),void this.insertText(e)}if(f===1){if(d.isToken()){const E=pe(e);return E.select(),void d.replace(E)}const x=d.getFormat(),C=d.getStyle();if(u!==a||x===s&&C===o){if(wc(d)){const E=pe(e);return E.setFormat(s),E.setStyle(o),E.select(),void d.replace(E)}}else{if(d.getTextContent()!==""){const E=pe(e);if(E.setFormat(s),E.setStyle(o),E.select(),u===0)d.insertBefore(E,!1);else{const[D]=d.splitText(u);D.insertAfter(E,!1)}return void(E.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length))}d.setFormat(s),d.setStyle(o)}const _=a-u;d=d.spliceText(u,_,e,!0),d.getTextContent()===""?d.remove():this.anchor.type==="text"&&(d.isComposing()?this.anchor.offset-=e.length:(this.format=x,this.style=C))}else{const x=new Set([...d.getParentKeys(),...m.getParentKeys()]),C=B(d)?d:d.getParentOrThrow();let _=B(m)?m:m.getParentOrThrow(),E=m;if(!C.is(_)&&_.isInline())do E=_,_=_.getParentOrThrow();while(_.isInline());if(l.type==="text"&&(a!==0||m.getTextContent()==="")||l.type==="element"&&m.getIndexWithinParent()<a)if(M(m)&&!m.isToken()&&a!==m.getTextContentSize()){if(m.isSegmented()){const w=pe(m.getTextContent());m.replace(w),m=w}De(l.getNode())||l.type!=="text"||(m=m.spliceText(0,a,"")),x.add(m.__key)}else{const w=m.getParentOrThrow();w.canBeEmpty()||w.getChildrenSize()!==1?m.remove():w.remove()}else x.add(m.__key);const D=_.getChildren(),A=new Set(c),v=C.is(_),b=C.isInline()&&d.getNextSibling()===null?C:d;for(let w=D.length-1;w>=0;w--){const S=D[w];if(S.is(d)||B(S)&&S.isParentOf(d))break;S.isAttached()&&(!A.has(S)||S.is(E)?v||b.insertAfter(S,!1):S.remove())}if(!v){let w=_,S=null;for(;w!==null;){const R=w.getChildren(),T=R.length;(T===0||R[T-1].is(S))&&(x.delete(w.__key),S=w),w=w.getParent()}}if(d.isToken())if(u===h)d.select();else{const w=pe(e);w.select(),d.replace(w)}else d=d.spliceText(u,h-u,e,!0),d.getTextContent()===""?d.remove():d.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length);for(let w=1;w<f;w++){const S=c[w],R=S.__key;x.has(R)||S.remove()}}}removeText(){if(this.isCollapsed())return;const{anchor:e,focus:t}=this,n=this.getNodes(),s=this.isBackward()?t:e,o=this.isBackward()?e:t;let i=s.getNode(),l=o.getNode();const u=pr(i,gt),a=pr(l,gt);M(i)&&i.isToken()&&s.offset<i.getTextContentSize()&&(s.offset=0),o.offset>0&&M(l)&&l.isToken()&&(o.offset=l.getTextContentSize()),n.forEach(f=>{Er(i,f)||Er(l,f)||f.getKey()===i.getKey()||f.getKey()===l.getKey()||f.remove()});const c=(f,d)=>{if(f.getTextContent()==="")f.remove();else if(d!==0&&kt(f)){const h=pe(f.getTextContent());return h.setFormat(f.getFormat()),h.setStyle(f.getStyle()),f.replace(h)}};if(i===l&&M(i)){const f=Math.abs(t.offset-e.offset);return i.spliceText(s.offset,f,"",!0),void c(i,f)}if(M(i)){const f=i.getTextContentSize()-s.offset;i.spliceText(s.offset,f,""),i=c(i,f)||i}M(l)&&(l.spliceText(0,o.offset,""),l=c(l,o.offset)||l),i.isAttached()&&M(i)?i.selectEnd():l.isAttached()&&M(l)&&l.selectStart(),B(u)&&B(a)&&u!==a&&(u.append(...a.getChildren()),a.remove(),o.set(s.key,s.offset,s.type))}formatText(e,t=null){if(this.isCollapsed())return this.toggleFormat(e),void ye(null);const n=this.getNodes(),s=[];for(const D of n)M(D)&&s.push(D);const o=D=>{n.forEach(A=>{if(rr(A)){const v=A.getFormatFlags(e,D);A.setTextFormat(v)}})},i=s.length;if(i===0)return this.toggleFormat(e),ye(null),void o(t);const l=this.anchor,u=this.focus,a=this.isBackward(),c=a?u:l,f=a?l:u;let d=0,h=s[0],p=c.type==="element"?0:c.offset;if(c.type==="text"&&p===h.getTextContentSize()&&(d=1,h=s[1],p=0),h==null)return;const m=h.getFormatFlags(e,t);o(m);const x=i-1;let C=s[x];const _=f.type==="text"?f.offset:C.getTextContentSize();if(h.is(C)){if(p===_)return;if(kt(h)||p===0&&_===h.getTextContentSize())h.setFormat(m);else{const D=h.splitText(p,_),A=p===0?D[0]:D[1];A.setFormat(m),c.type==="text"&&c.set(A.__key,0,"text"),f.type==="text"&&f.set(A.__key,_-p,"text")}return void(this.format=m)}p===0||kt(h)||([,h]=h.splitText(p),p=0),h.setFormat(m);const E=C.getFormatFlags(e,m);_>0&&(_===C.getTextContentSize()||kt(C)||([C]=C.splitText(_)),C.setFormat(E));for(let D=d+1;D<x;D++){const A=s[D],v=A.getFormatFlags(e,E);A.setFormat(v)}c.type==="text"&&c.set(h.__key,p,"text"),f.type==="text"&&f.set(C.__key,_,"text"),this.format=m|E}insertNodes(e){if(e.length===0)return;if(this.anchor.key==="root"){this.insertParagraph();const p=q();return P(p)||O(134),p.insertNodes(e)}const t=(this.isBackward()?this.focus:this.anchor).getNode(),n=pr(t,gt),s=e[e.length-1];if(B(n)&&"__language"in n){if("__language"in e[0])this.insertText(e[0].getTextContent());else{const p=vs(this);n.splice(p,0,e),s.selectEnd()}return}if(!e.some(p=>(B(p)||Z(p))&&!p.isInline())){B(n)||O(211,t.constructor.name,t.getType());const p=vs(this);return n.splice(p,0,e),void s.selectEnd()}const o=function(p){const m=fe();let x=null;for(let C=0;C<p.length;C++){const _=p[C],E=Nt(_);if(E||Z(_)&&_.isInline()||B(_)&&_.isInline()||M(_)||_.isParentRequired()){if(x===null&&(x=_.createParentElementNode(),m.append(x),E))continue;x!==null&&x.append(_)}else m.append(_),x=null}return m}(e),i=o.getLastDescendant(),l=o.getChildren(),u=!B(n)||!n.isEmpty()?this.insertParagraph():null,a=l[l.length-1];let c=l[0];var f;B(f=c)&>(f)&&!f.isEmpty()&&B(n)&&(!n.isEmpty()||n.canMergeWhenEmpty())&&(B(n)||O(211,t.constructor.name,t.getType()),n.append(...c.getChildren()),c=l[1]),c&&(n===null&&O(212,t.constructor.name,t.getType()),function(p,m,x){const C=m.getParentOrThrow().getLastChild();let _=m;const E=[m];for(;_!==C;)_.getNextSibling()||O(140),_=_.getNextSibling(),E.push(_);let D=p;for(const A of E)D=D.insertAfter(A)}(n,c));const d=pr(i,gt);u&&B(d)&&(u.canMergeWhenEmpty()||gt(a))&&(d.append(...u.getChildren()),u.remove()),B(n)&&n.isEmpty()&&n.remove(),i.selectEnd();const h=B(n)?n.getLastChild():null;Nt(h)&&d!==n&&h.remove()}insertParagraph(){if(this.anchor.key==="root"){const i=fe();return ie().splice(this.anchor.offset,0,[i]),i.select(),i}const e=vs(this),t=pr(this.anchor.getNode(),gt);B(t)||O(213);const n=t.getChildAtIndex(e),s=n?[n,...n.getNextSiblings()]:[],o=t.insertNewAfter(this,!1);return o?(o.append(...s),o.selectStart(),o):null}insertLineBreak(e){const t=Pt();if(this.insertNodes([t]),e){const n=t.getParentOrThrow(),s=t.getIndexWithinParent();n.select(s,s)}}extract(){const e=this.getNodes(),t=e.length,n=t-1,s=this.anchor,o=this.focus;let i=e[0],l=e[n];const[u,a]=zs(this);if(t===0)return[];if(t===1){if(M(i)&&!this.isCollapsed()){const f=u>a?a:u,d=u>a?u:a,h=i.splitText(f,d),p=f===0?h[0]:h[1];return p!=null?[p]:[]}return[i]}const c=s.isBefore(o);if(M(i)){const f=c?u:a;f===i.getTextContentSize()?e.shift():f!==0&&([,i]=i.splitText(f),e[0]=i)}if(M(l)){const f=l.getTextContent().length,d=c?a:u;d===0?e.pop():d!==f&&([l]=l.splitText(d),e[n]=l)}return e}modify(e,t,n){const s=this.focus,o=this.anchor,i=e==="move",l=Lr(s,t);if(Z(l)&&!l.isIsolated()){if(i&&l.isKeyboardSelectable()){const h=mo();return h.add(l.__key),void et(h)}const d=t?l.getPreviousSibling():l.getNextSibling();if(M(d)){const h=d.__key,p=t?d.getTextContent().length:0;return s.set(h,p,"text"),void(i&&o.set(h,p,"text"))}{const h=l.getParentOrThrow();let p,m;return B(d)?(m=d.__key,p=t?d.getChildrenSize():0):(p=l.getIndexWithinParent(),m=h.__key,t||p++),s.set(m,p,"element"),void(i&&o.set(m,p,"element"))}}const u=se(),a=Oe(u._window);if(!a)return;const c=u._blockCursorElement,f=u._rootElement;if(f===null||c===null||!B(l)||l.isInline()||l.canBeEmpty()||pi(c,u,f),function(d,h,p,m){d.modify(h,p,m)}(a,e,t?"backward":"forward",n),a.rangeCount>0){const d=a.getRangeAt(0),h=this.anchor.getNode(),p=De(h)?h:lc(h);if(this.applyDOMRange(d),this.dirty=!0,!i){const m=this.getNodes(),x=[];let C=!1;for(let _=0;_<m.length;_++){const E=m[_];Er(E,p)?x.push(E):C=!0}if(C&&x.length>0)if(t){const _=x[0];B(_)?_.selectStart():_.getParentOrThrow().selectStart()}else{const _=x[x.length-1];B(_)?_.selectEnd():_.getParentOrThrow().selectEnd()}a.anchorNode===d.startContainer&&a.anchorOffset===d.startOffset||function(_){const E=_.focus,D=_.anchor,A=D.key,v=D.offset,b=D.type;mt(D,E.key,E.offset,E.type),mt(E,A,v,b),_._cachedNodes=null}(this)}}}forwardDeletion(e,t,n){if(!n&&(e.type==="element"&&B(t)&&e.offset===t.getChildrenSize()||e.type==="text"&&e.offset===t.getTextContentSize())){const s=t.getParent(),o=t.getNextSibling()||(s===null?null:s.getNextSibling());if(B(o)&&o.isShadowRoot())return!0}return!1}deleteCharacter(e){const t=this.isCollapsed();if(this.isCollapsed()){const n=this.anchor;let s=n.getNode();if(this.forwardDeletion(n,s,e))return;const o=this.focus,i=Lr(o,e);if(Z(i)&&!i.isIsolated()){if(i.isKeyboardSelectable()&&B(s)&&s.getChildrenSize()===0){s.remove();const l=mo();l.add(i.__key),et(l)}else i.remove(),se().dispatchCommand(Js,void 0);return}if(!e&&B(i)&&B(s)&&s.isEmpty())return s.remove(),void i.selectStart();if(this.modify("extend",e,"character"),this.isCollapsed()){if(e&&n.offset===0&&(n.type==="element"?n.getNode():n.getNode().getParentOrThrow()).collapseAtStart(this))return}else{const l=o.type==="text"?o.getNode():null;if(s=n.type==="text"?n.getNode():null,l!==null&&l.isSegmented()){const u=o.offset,a=l.getTextContentSize();if(l.is(s)||e&&u!==a||!e&&u!==0)return void ho(l,e,u)}else if(s!==null&&s.isSegmented()){const u=n.offset,a=s.getTextContentSize();if(s.is(l)||e&&u!==0||!e&&u!==a)return void ho(s,e,u)}(function(u,a){const c=u.anchor,f=u.focus,d=c.getNode(),h=f.getNode();if(d===h&&c.type==="text"&&f.type==="text"){const p=c.offset,m=f.offset,x=p<m,C=x?p:m,_=x?m:p,E=_-1;C!==E&&(Bl(d.getTextContent().slice(C,_))||(a?f.offset=E:c.offset=E))}})(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type==="element"&&this.anchor.offset===0){const n=this.anchor.getNode();n.isEmpty()&&De(n.getParent())&&n.getIndexWithinParent()===0&&n.collapseAtStart(this)}}deleteLine(e){if(this.isCollapsed()){const t=this.anchor.type==="element";if(t&&this.insertText(" "),this.modify("extend",e,"lineboundary"),this.isCollapsed()&&this.anchor.offset===0&&this.modify("extend",e,"character"),t){const n=e?this.anchor:this.focus;n.set(n.key,n.offset+1,n.type)}}this.removeText()}deleteWord(e){if(this.isCollapsed()){const t=this.anchor,n=t.getNode();if(this.forwardDeletion(t,n,e))return;this.modify("extend",e,"word")}this.removeText()}isBackward(){return this.focus.isBefore(this.anchor)}getStartEndPoints(){return[this.anchor,this.focus]}}function Ye(r){return r instanceof Gn}function fo(r){const e=r.offset;if(r.type==="text")return e;const t=r.getNode();return e===t.getChildrenSize()?t.getTextContent().length:0}function zs(r){const e=r.getStartEndPoints();if(e===null)return[0,0];const[t,n]=e;return t.type==="element"&&n.type==="element"&&t.key===n.key&&t.offset===n.offset?[0,0]:[fo(t),fo(n)]}function ho(r,e,t){const n=r,s=n.getTextContent().split(/(?=\s)/g),o=s.length;let i=0,l=0;for(let a=0;a<o;a++){const c=a===o-1;if(l=i,i+=s[a].length,e&&i===t||i>t||c){s.splice(a,1),c&&(l=void 0);break}}const u=s.join("").trim();u===""?n.remove():(n.setTextContent(u),n.select(l,l))}function po(r,e,t,n){let s,o=e;if(r.nodeType===$r){let i=!1;const l=r.childNodes,u=l.length,a=n._blockCursorElement;o===u&&(i=!0,o=u-1);let c=l[o],f=!1;if(c===a)c=l[o+1],f=!0;else if(a!==null){const d=a.parentNode;r===d&&e>Array.prototype.indexOf.call(d.children,a)&&o--}if(s=Ht(c),M(s))o=Hi(s,i);else{let d=Ht(r);if(d===null)return null;if(B(d)){const h=n.getElementByKey(d.getKey());h===null&&O(214),[d,o]=d.getDOMSlot(h).resolveChildIndex(d,h,r,e),B(d)||O(215),i&&o>=d.getChildrenSize()&&(o=Math.max(0,d.getChildrenSize()-1));let m=d.getChildAtIndex(o);if(B(m)&&function(x,C,_){const E=x.getParent();return _===null||E===null||!E.canBeEmpty()||E!==_.getNode()}(m,0,t)){const x=i?m.getLastDescendant():m.getFirstDescendant();x===null?d=m:(m=x,d=B(m)?m:m.getParentOrThrow()),o=0}M(m)?(s=m,d=null,o=Hi(m,i)):m!==d&&i&&!f&&(B(d)||O(216),o=Math.min(d.getChildrenSize(),o+1))}else{const h=d.getIndexWithinParent();o=e===0&&Z(d)&&Ht(r)===d?h:h+1,d=d.getParentOrThrow()}if(B(d))return rt(d.__key,o,"element")}}else s=Ht(r);return M(s)?rt(s.__key,o,"text"):null}function go(r,e,t){const n=r.offset,s=r.getNode();if(n===0){const o=s.getPreviousSibling(),i=s.getParent();if(e){if((t||!e)&&o===null&&B(i)&&i.isInline()){const l=i.getPreviousSibling();M(l)&&(r.key=l.__key,r.offset=l.getTextContent().length)}}else B(o)&&!t&&o.isInline()?(r.key=o.__key,r.offset=o.getChildrenSize(),r.type="element"):M(o)&&(r.key=o.__key,r.offset=o.getTextContent().length)}else if(n===s.getTextContent().length){const o=s.getNextSibling(),i=s.getParent();if(e&&B(o)&&o.isInline())r.key=o.__key,r.offset=0,r.type="element";else if((t||e)&&o===null&&B(i)&&i.isInline()&&!i.canInsertTextAfter()){const l=i.getNextSibling();M(l)&&(r.key=l.__key,r.offset=0)}}}function Ql(r,e,t){if(r.type==="text"&&e.type==="text"){const n=r.isBefore(e),s=r.is(e);go(r,n,s),go(e,!n,s),s&&(e.key=r.key,e.offset=r.offset,e.type=r.type);const o=se();if(o.isComposing()&&o._compositionKey!==r.key&&P(t)){const i=t.anchor,l=t.focus;mt(r,i.key,i.offset,i.type),mt(e,l.key,l.offset,l.type)}}}function Yl(r,e,t,n,s,o){if(r===null||t===null||!Ir(s,r,t))return null;const i=po(r,e,P(o)?o.anchor:null,s);if(i===null)return null;const l=po(t,n,P(o)?o.focus:null,s);if(l===null)return null;if(i.type==="element"&&l.type==="element"){const u=Ht(r),a=Ht(t);if(Z(u)&&Z(a))return null}return Ql(i,l,o),[i,l]}function qs(r){return B(r)&&!r.isInline()}function Xl(r,e,t,n,s,o){const i=dt(),l=new Ct(rt(r,e,s),rt(t,n,o),0,"");return l.dirty=!0,i._selection=l,l}function Ac(){const r=rt("root",0,"element"),e=rt("root",0,"element");return new Ct(r,e,0,"")}function mo(){return new Gn(new Set)}function xi(r,e,t,n){const s=t._window;if(s===null)return null;const o=n||s.event,i=o?o.type:void 0,l=i==="selectionchange",u=!Ss&&(l||i==="beforeinput"||i==="compositionstart"||i==="compositionend"||i==="click"&&o&&o.detail===3||i==="drop"||i===void 0);let a,c,f,d;if(P(r)&&!u)return r.clone();if(e===null)return null;if(a=e.anchorNode,c=e.focusNode,f=e.anchorOffset,d=e.focusOffset,l&&P(r)&&!Ir(t,a,c))return r.clone();const h=Yl(a,f,c,d,t,r);if(h===null)return null;const[p,m]=h;return new Ct(p,m,P(r)?r.format:0,P(r)?r.style:"")}function q(){return dt()._selection}function Kr(){return se()._editorState._selection}function Nn(r,e,t,n=1){const s=r.anchor,o=r.focus,i=s.getNode(),l=o.getNode();if(!e.is(i)&&!e.is(l))return;const u=e.__key;if(r.isCollapsed()){const a=s.offset;if(t<=a&&n>0||t<a&&n<0){const c=Math.max(0,a+n);s.set(u,c,"element"),o.set(u,c,"element"),yo(r)}}else{const a=r.isBackward(),c=a?o:s,f=c.getNode(),d=a?s:o,h=d.getNode();if(e.is(f)){const p=c.offset;(t<=p&&n>0||t<p&&n<0)&&c.set(u,Math.max(0,p+n),"element")}if(e.is(h)){const p=d.offset;(t<=p&&n>0||t<p&&n<0)&&d.set(u,Math.max(0,p+n),"element")}}yo(r)}function yo(r){const e=r.anchor,t=e.offset,n=r.focus,s=n.offset,o=e.getNode(),i=n.getNode();if(r.isCollapsed()){if(!B(o))return;const l=o.getChildrenSize(),u=t>=l,a=u?o.getChildAtIndex(l-1):o.getChildAtIndex(t);if(M(a)){let c=0;u&&(c=a.getTextContentSize()),e.set(a.__key,c,"text"),n.set(a.__key,c,"text")}}else{if(B(o)){const l=o.getChildrenSize(),u=t>=l,a=u?o.getChildAtIndex(l-1):o.getChildAtIndex(t);if(M(a)){let c=0;u&&(c=a.getTextContentSize()),e.set(a.__key,c,"text")}}if(B(i)){const l=i.getChildrenSize(),u=s>=l,a=u?i.getChildAtIndex(l-1):i.getChildAtIndex(s);if(M(a)){let c=0;u&&(c=a.getTextContentSize()),n.set(a.__key,c,"text")}}}}function Fn(r,e,t,n,s){let o=null,i=0,l=null;n!==null?(o=n.__key,M(n)?(i=n.getTextContentSize(),l="text"):B(n)&&(i=n.getChildrenSize(),l="element")):s!==null&&(o=s.__key,M(s)?l="text":B(s)&&(l="element")),o!==null&&l!==null?r.set(o,i,l):(i=e.getIndexWithinParent(),i===-1&&(i=t.getChildrenSize()),r.set(t.__key,i,"element"))}function xo(r,e,t,n,s){r.type==="text"?(r.key=t,e||(r.offset+=s)):r.offset>n.getIndexWithinParent()&&(r.offset-=1)}function kc(r,e,t,n,s,o,i){const l=n.anchorNode,u=n.focusNode,a=n.anchorOffset,c=n.focusOffset,f=document.activeElement;if(s.has("collaboration")&&f!==o||f!==null&&ui(f))return;if(!P(e))return void(r!==null&&Ir(t,l,u)&&n.removeAllRanges());const d=e.anchor,h=e.focus,p=d.key,m=h.key,x=En(t,p),C=En(t,m),_=d.offset,E=h.offset,D=e.format,A=e.style,v=e.isCollapsed();let b=x,w=C,S=!1;if(d.type==="text"){b=Dn(x);const $=d.getNode();S=$.getFormat()!==D||$.getStyle()!==A}else P(r)&&r.anchor.type==="text"&&(S=!0);var R,T,N,j,L;if(h.type==="text"&&(w=Dn(C)),b!==null&&w!==null&&(v&&(r===null||S||P(r)&&(r.format!==D||r.style!==A))&&(R=D,T=A,N=_,j=p,L=performance.now(),Ul=[R,T,N,j,L]),a!==_||c!==E||l!==b||u!==w||n.type==="Range"&&v||(f!==null&&o.contains(f)||o.focus({preventScroll:!0}),d.type==="element"))){try{n.setBaseAndExtent(b,_,w,E)}catch{}if(!s.has("skip-scroll-into-view")&&e.isCollapsed()&&o!==null&&o===document.activeElement){const $=e instanceof Ct&&e.anchor.type==="element"?b.childNodes[_]||null:n.rangeCount>0?n.getRangeAt(0):null;if($!==null){let H;if($ instanceof Text){const ue=document.createRange();ue.selectNode($),H=ue.getBoundingClientRect()}else H=$.getBoundingClientRect();(function(ue,re,we){const Ee=we.ownerDocument,Ge=Ee.defaultView;if(Ge===null)return;let{top:He,bottom:Me}=re,Je=0,Re=0,ae=we;for(;ae!==null;){const Le=ae===Ee.body;if(Le)Je=0,Re=Wn(ue).innerHeight;else{const ee=ae.getBoundingClientRect();Je=ee.top,Re=ee.bottom}let he=0;if(He<Je?he=-(Je-He):Me>Re&&(he=Me-Re),he!==0)if(Le)Ge.scrollBy(0,he);else{const ee=ae.scrollTop;ae.scrollTop+=he;const Be=ae.scrollTop-ee;He-=Be,Me-=Be}if(Le)break;ae=zr(ae)}})(t,H,o)}}Rs=!0}}function Zl(r){let e=q()||Kr();e===null&&(e=ie().selectEnd()),e.insertNodes(r)}function vs(r){let e=r;r.isCollapsed()||e.removeText();const t=q();P(t)&&(e=t),P(e)||O(161);const n=e.anchor;let s=n.getNode(),o=n.offset;for(;!gt(s);)[s,o]=Sc(s,o);return o}function Sc(r,e){const t=r.getParent();if(!t){const s=fe();return ie().append(s),s.select(),[ie(),0]}if(M(r)){const s=r.splitText(e);if(s.length===0)return[t,r.getIndexWithinParent()];const o=e===0?0:1;return[t,s[0].getIndexWithinParent()+o]}if(!B(r)||e===0)return[t,r.getIndexWithinParent()];const n=r.getChildAtIndex(e);if(n){const s=new Ct(rt(r.__key,e,"element"),rt(r.__key,e,"element"),0,""),o=r.insertNewAfter(s);o&&o.append(n,...n.getNextSiblings())}return[t,r.getIndexWithinParent()+1]}let ge=null,me=null,Se=!1,Ds=!1,pn=0;const _o={characterData:!0,childList:!0,subtree:!0};function Vr(){return Se||ge!==null&&ge._readOnly}function ke(){Se&&O(13)}function eu(){pn>99&&O(14)}function dt(){return ge===null&&O(195,tu()),ge}function se(){return me===null&&O(196,tu()),me}function tu(){let r=0;const e=new Set,t=Jn.version;if(typeof window<"u")for(const s of document.querySelectorAll("[contenteditable]")){const o=zn(s);if(ai(o))r++;else if(o){let i=String(o.constructor.version||"<0.17.1");i===t&&(i+=" (separately built, likely a bundler configuration issue)"),e.add(i)}}let n=` Detected on the page: ${r} compatible editor(s) with version ${t}`;return e.size&&(n+=` and incompatible editors with versions ${Array.from(e).join(", ")}`),n}function Tc(){return me}function bo(r,e,t){const n=e.__type,s=function(l,u){const a=l._nodes.get(u);return a===void 0&&O(30,u),a}(r,n);let o=t.get(n);o===void 0&&(o=Array.from(s.transforms),t.set(n,o));const i=o.length;for(let l=0;l<i&&(o[l](e),e.isAttached());l++);}function vo(r,e){return r!==void 0&&r.__key!==e&&r.isAttached()}function ru(r,e){if(!e)return;const t=r._updateTags;let n=e;Array.isArray(e)||(n=[e]);for(const s of n)t.add(s)}function Bc(r){return _i(r,se()._nodes)}function _i(r,e){const t=r.type,n=e.get(t);n===void 0&&O(17,t);const s=n.klass;r.type!==s.getType()&&O(18,s.name);const o=s.importJSON(r),i=r.children;if(B(o)&&Array.isArray(i))for(let l=0;l<i.length;l++){const u=_i(i[l],e);o.append(u)}return o}function Do(r,e,t){const n=ge,s=Se,o=me;ge=e,Se=!0,me=r;try{return t()}finally{ge=n,Se=s,me=o}}function xt(r,e){const t=r._pendingEditorState,n=r._rootElement,s=r._headless||n===null;if(t===null)return;const o=r._editorState,i=o._selection,l=t._selection,u=r._dirtyType!==Ft,a=ge,c=Se,f=me,d=r._updating,h=r._observer;let p=null;if(r._pendingEditorState=null,r._editorState=t,!s&&u&&h!==null){me=r,ge=t,Se=!1,r._updating=!0;try{const v=r._dirtyType,b=r._dirtyElements,w=r._dirtyLeaves;h.disconnect(),p=mc(o,t,r,v,b,w)}catch(v){if(v instanceof Error&&r._onError(v),Ds)throw v;return lu(r,null,n,t),Cl(r),r._dirtyType=er,Ds=!0,xt(r,o),void(Ds=!1)}finally{h.observe(n,_o),r._updating=d,ge=a,Se=c,me=f}}t._readOnly||(t._readOnly=!0);const m=r._dirtyLeaves,x=r._dirtyElements,C=r._normalizedNodes,_=r._updateTags,E=r._deferred;u&&(r._dirtyType=Ft,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements=new Map,r._normalizedNodes=new Set,r._updateTags=new Set),function(v,b){const w=v._decorators;let S=v._pendingDecorators||w;const R=b._nodeMap;let T;for(T in S)R.has(T)||(S===w&&(S=Sl(v)),delete S[T])}(r,t);const D=s?null:Oe(r._window);if(r._editable&&D!==null&&(u||l===null||l.dirty)){me=r,ge=t;try{if(h!==null&&h.disconnect(),u||l===null||l.dirty){const v=r._blockCursorElement;v!==null&&pi(v,r,n),kc(i,l,r,D,_,n)}uc(r,n,l),h!==null&&h.observe(n,_o)}finally{me=f,ge=a}}p!==null&&function(v,b,w,S,R){const T=Array.from(v._listeners.mutation),N=T.length;for(let j=0;j<N;j++){const[L,$]=T[j],H=b.get($);H!==void 0&&L(H,{dirtyLeaves:S,prevEditorState:R,updateTags:w})}}(r,p,_,m,o),P(l)||l===null||i!==null&&i.is(l)||r.dispatchCommand(Js,void 0);const A=r._pendingDecorators;A!==null&&(r._decorators=A,r._pendingDecorators=null,Sr("decorator",r,!0,A)),function(v,b,w){const S=Gi(b),R=Gi(w);S!==R&&Sr("textcontent",v,!0,R)}(r,e||o,t),Sr("update",r,!0,{dirtyElements:x,dirtyLeaves:m,editorState:t,normalizedNodes:C,prevEditorState:e||o,tags:_}),function(v,b){if(v._deferred=[],b.length!==0){const w=v._updating;v._updating=!0;try{for(let S=0;S<b.length;S++)b[S]()}finally{v._updating=w}}}(r,E),function(v){const b=v._updates;if(b.length!==0){const w=b.shift();if(w){const[S,R]=w;su(v,S,R)}}}(r)}function Sr(r,e,t,...n){const s=e._updating;e._updating=t;try{const o=Array.from(e._listeners[r]);for(let i=0;i<o.length;i++)o[i].apply(null,n)}finally{e._updating=s}}function nu(r,e,t){if(r._updating===!1||me!==r){let s=!1;return r.update(()=>{s=nu(r,e,t)}),s}const n=ci(r);for(let s=4;s>=0;s--)for(let o=0;o<n.length;o++){const i=n[o]._commands.get(e);if(i!==void 0){const l=i[s];if(l!==void 0){const u=Array.from(l),a=u.length;for(let c=0;c<a;c++)if(u[c](t,r)===!0)return!0}}}return!1}function Co(r,e){const t=r._updates;let n=e||!1;for(;t.length!==0;){const s=t.shift();if(s){const[o,i]=s;let l;if(i!==void 0){if(l=i.onUpdate,i.skipTransforms&&(n=!0),i.discrete){const u=r._pendingEditorState;u===null&&O(191),u._flushSync=!0}l&&r._deferred.push(l),ru(r,i.tag)}o()}}return n}function su(r,e,t){const n=r._updateTags;let s,o=!1,i=!1;t!==void 0&&(s=t.onUpdate,ru(r,t.tag),o=t.skipTransforms||!1,i=t.discrete||!1),s&&r._deferred.push(s);const l=r._editorState;let u=r._pendingEditorState,a=!1;(u===null||u._readOnly)&&(u=r._pendingEditorState=iu(u||l),a=!0),u._flushSync=i;const c=ge,f=Se,d=me,h=r._updating;ge=u,Se=!1,r._updating=!0,me=r;try{a&&(r._headless?l._selection!==null&&(u._selection=l._selection.clone()):u._selection=function(C){const _=C.getEditorState()._selection,E=Oe(C._window);return P(_)||_==null?xi(_,E,C,null):_.clone()}(r));const m=r._compositionKey;e(),o=Co(r,o),function(C,_){const E=_.getEditorState()._selection,D=C._selection;if(P(D)){const A=D.anchor,v=D.focus;let b;if(A.type==="text"&&(b=A.getNode(),b.selectionTransform(E,D)),v.type==="text"){const w=v.getNode();b!==w&&w.selectionTransform(E,D)}}}(u,r),r._dirtyType!==Ft&&(o?function(C,_){const E=_._dirtyLeaves,D=C._nodeMap;for(const A of E){const v=D.get(A);M(v)&&v.isAttached()&&v.isSimpleText()&&!v.isUnmergeable()&&Ki(v)}}(u,r):function(C,_){const E=_._dirtyLeaves,D=_._dirtyElements,A=C._nodeMap,v=yt(),b=new Map;let w=E,S=w.size,R=D,T=R.size;for(;S>0||T>0;){if(S>0){_._dirtyLeaves=new Set;for(const N of w){const j=A.get(N);M(j)&&j.isAttached()&&j.isSimpleText()&&!j.isUnmergeable()&&Ki(j),j!==void 0&&vo(j,v)&&bo(_,j,b),E.add(N)}if(w=_._dirtyLeaves,S=w.size,S>0){pn++;continue}}_._dirtyLeaves=new Set,_._dirtyElements=new Map;for(const N of R){const j=N[0],L=N[1];if(j!=="root"&&!L)continue;const $=A.get(j);$!==void 0&&vo($,v)&&bo(_,$,b),D.set(j,L)}w=_._dirtyLeaves,S=w.size,R=_._dirtyElements,T=R.size,pn++}_._dirtyLeaves=E,_._dirtyElements=D}(u,r),Co(r),function(C,_,E,D){const A=C._nodeMap,v=_._nodeMap,b=[];for(const[w]of D){const S=v.get(w);S!==void 0&&(S.isAttached()||(B(S)&&jl(S,w,A,v,b,D),A.has(w)||D.delete(w),b.push(w)))}for(const w of b)v.delete(w);for(const w of E){const S=v.get(w);S===void 0||S.isAttached()||(A.has(w)||E.delete(w),v.delete(w))}}(l,u,r._dirtyLeaves,r._dirtyElements)),m!==r._compositionKey&&(u._flushSync=!0);const x=u._selection;if(P(x)){const C=u._nodeMap,_=x.anchor.key,E=x.focus.key;C.get(_)!==void 0&&C.get(E)!==void 0||O(19)}else Ye(x)&&x._nodes.size===0&&(u._selection=null)}catch(m){return m instanceof Error&&r._onError(m),r._pendingEditorState=l,r._dirtyType=er,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),void xt(r)}finally{ge=c,Se=f,me=d,r._updating=h,pn=0}r._dirtyType!==Ft||function(m,x){const C=x.getEditorState()._selection,_=m._selection;if(_!==null){if(_.dirty||!_.is(C))return!0}else if(C!==null)return!0;return!1}(u,r)?u._flushSync?(u._flushSync=!1,xt(r)):a&&rc(()=>{xt(r)}):(u._flushSync=!1,a&&(n.clear(),r._deferred=[],r._pendingEditorState=null))}function Ne(r,e,t){r._updating?r._updates.push([e,t]):su(r,e,t)}class Tr{constructor(e,t,n){this.element=e,this.before=t||null,this.after=n||null}withBefore(e){return new Tr(this.element,e,this.after)}withAfter(e){return new Tr(this.element,this.before,e)}withElement(e){return new Tr(e,this.before,this.after)}insertChild(e){const t=this.before||this.getManagedLineBreak();return t!==null&&t.parentElement!==this.element&&O(222),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&O(223),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&O(224),this.element.replaceChild(e,t),this}getFirstChild(){const e=this.after?this.after.nextSibling:this.element.firstChild;return e===this.before||e===this.getManagedLineBreak()?null:e}getManagedLineBreak(){return this.element.__lexicalLineBreak||null}setManagedLineBreak(e){if(e===null)this.removeManagedLineBreak();else{const t=e==="decorator"&&(Rr||$n);this.insertManagedLineBreak(t)}}removeManagedLineBreak(){const e=this.getManagedLineBreak();if(e){const t=this.element,n=e.nodeName==="IMG"?e.nextSibling:null;n&&t.removeChild(n),t.removeChild(e),t.__lexicalLineBreak=void 0}}insertManagedLineBreak(e){const t=this.getManagedLineBreak();if(t){if(e===(t.nodeName==="IMG"))return;this.removeManagedLineBreak()}const n=this.element,s=this.before,o=document.createElement("br");if(n.insertBefore(o,s),e){const i=document.createElement("img");i.setAttribute("data-lexical-linebreak","true"),i.style.cssText="display: inline !important; border: 0px !important; margin: 0px !important;",i.alt="",n.insertBefore(i,o),n.__lexicalLineBreak=i}else n.__lexicalLineBreak=o}getFirstChildOffset(){let e=0;for(let t=this.after;t!==null;t=t.previousSibling)e++;return e}resolveChildIndex(e,t,n,s){if(n===this.element){const u=this.getFirstChildOffset();return[e,Math.min(u+e.getChildrenSize(),Math.max(u,s))]}const o=wo(t,n);o.push(s);const i=wo(t,this.element);let l=e.getIndexWithinParent();for(let u=0;u<i.length;u++){const a=o[u],c=i[u];if(a===void 0||a<c)break;if(a>c){l+=1;break}}return[e.getParentOrThrow(),l]}}function wo(r,e){const t=[];let n=e;for(;n!==r&&n!==null;n=e.parentNode){let s=0;for(let o=n.previousSibling;o!==null;o=n.previousSibling)s++;t.push(s)}return n!==r&&O(225),t.reverse()}class ft extends Vn{constructor(e){super(e),this.__first=null,this.__last=null,this.__size=0,this.__format=0,this.__style="",this.__indent=0,this.__dir=null}afterCloneFrom(e){super.afterCloneFrom(e),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}getFormat(){return this.getLatest().__format}getFormatType(){const e=this.getFormat();return Va[e]||""}getStyle(){return this.getLatest().__style}getIndent(){return this.getLatest().__indent}getChildren(){const e=[];let t=this.getFirstChild();for(;t!==null;)e.push(t),t=t.getNextSibling();return e}getChildrenKeys(){const e=[];let t=this.getFirstChild();for(;t!==null;)e.push(t.__key),t=t.getNextSibling();return e}getChildrenSize(){return this.getLatest().__size}isEmpty(){return this.getChildrenSize()===0}isDirty(){const e=se()._dirtyElements;return e!==null&&e.has(this.__key)}isLastChild(){const e=this.getLatest(),t=this.getParentOrThrow().getLastChild();return t!==null&&t.is(e)}getAllTextNodes(){const e=[];let t=this.getFirstChild();for(;t!==null;){if(M(t)&&e.push(t),B(t)){const n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;B(e);){const t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;B(e);){const t=e.getLastChild();if(t===null)break;e=t}return e}getDescendantByIndex(e){const t=this.getChildren(),n=t.length;if(e>=n){const o=t[n-1];return B(o)&&o.getLastDescendant()||o||null}const s=t[e];return B(s)&&s.getFirstDescendant()||s||null}getFirstChild(){const e=this.getLatest().__first;return e===null?null:_e(e)}getFirstChildOrThrow(){const e=this.getFirstChild();return e===null&&O(45,this.__key),e}getLastChild(){const e=this.getLatest().__last;return e===null?null:_e(e)}getLastChildOrThrow(){const e=this.getLastChild();return e===null&&O(96,this.__key),e}getChildAtIndex(e){const t=this.getChildrenSize();let n,s;if(e<t/2){for(n=this.getFirstChild(),s=0;n!==null&&s<=e;){if(s===e)return n;n=n.getNextSibling(),s++}return null}for(n=this.getLastChild(),s=t-1;n!==null&&s>=e;){if(s===e)return n;n=n.getPreviousSibling(),s--}return null}getTextContent(){let e="";const t=this.getChildren(),n=t.length;for(let s=0;s<n;s++){const o=t[s];e+=o.getTextContent(),B(o)&&s!==n-1&&!o.isInline()&&(e+=at)}return e}getTextContentSize(){let e=0;const t=this.getChildren(),n=t.length;for(let s=0;s<n;s++){const o=t[s];e+=o.getTextContentSize(),B(o)&&s!==n-1&&!o.isInline()&&(e+=at.length)}return e}getDirection(){return this.getLatest().__dir}hasFormat(e){if(e!==""){const t=qi[e];return!!(this.getFormat()&t)}return!1}select(e,t){ke();const n=q();let s=e,o=t;const i=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){const u=this.getFirstChild();if(M(u)||B(u))return u.select(0,0)}else if(!(e!==void 0&&e!==i||t!==void 0&&t!==i)){const u=this.getLastChild();if(M(u)||B(u))return u.select()}}s===void 0&&(s=i),o===void 0&&(o=i);const l=this.__key;return P(n)?(n.anchor.set(l,s,"element"),n.focus.set(l,o,"element"),n.dirty=!0,n):Xl(l,s,l,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(t=>t.remove()),e}append(...e){return this.splice(this.getChildrenSize(),0,e)}setDirection(e){const t=this.getWritable();return t.__dir=e,t}setFormat(e){return this.getWritable().__format=e!==""?qi[e]:0,this}setStyle(e){return this.getWritable().__style=e||"",this}setIndent(e){return this.getWritable().__indent=e,this}splice(e,t,n){const s=n.length,o=this.getChildrenSize(),i=this.getWritable();e+t<=o||O(226,String(e),String(t),String(o));const l=i.__key,u=[],a=[],c=this.getChildAtIndex(e+t);let f=null,d=o-t+s;if(e!==0)if(e===o)f=this.getLastChild();else{const p=this.getChildAtIndex(e);p!==null&&(f=p.getPreviousSibling())}if(t>0){let p=f===null?this.getFirstChild():f.getNextSibling();for(let m=0;m<t;m++){p===null&&O(100);const x=p.getNextSibling(),C=p.__key;Bt(p.getWritable()),a.push(C),p=x}}let h=f;for(let p=0;p<s;p++){const m=n[p];h!==null&&m.is(h)&&(f=h=h.getPreviousSibling());const x=m.getWritable();x.__parent===l&&d--,Bt(x);const C=m.__key;if(h===null)i.__first=C,x.__prev=null;else{const _=h.getWritable();_.__next=C,x.__prev=_.__key}m.__key===l&&O(76),x.__parent=l,u.push(C),h=m}if(e+t===o)h!==null&&(h.getWritable().__next=null,i.__last=h.__key);else if(c!==null){const p=c.getWritable();if(h!==null){const m=h.getWritable();p.__prev=h.__key,m.__next=c.__key}else p.__prev=null}if(i.__size=d,a.length){const p=q();if(P(p)){const m=new Set(a),x=new Set(u),{anchor:C,focus:_}=p;Eo(C,m,x)&&Fn(C,C.getNode(),this,f,c),Eo(_,m,x)&&Fn(_,_.getNode(),this,f,c),d!==0||this.canBeEmpty()||tt(this)||this.remove()}}return i}getDOMSlot(e){return new Tr(e)}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&ct(t)){const n=this.getIndent();n>0&&(t.style.paddingInlineStart=40*n+"px")}return{element:t}}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"element",version:1}}insertNewAfter(e,t){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,t,n){return!1}canMergeWhenEmpty(){return!1}reconcileObservedMutation(e,t){const n=this.getDOMSlot(e);let s=n.getFirstChild();for(let o=this.getFirstChild();o;o=o.getNextSibling()){const i=t.getElementByKey(o.getKey());i!==null&&(s==null?(n.insertChild(i),s=i):s!==i&&n.replaceChild(i,s),s=s.nextSibling)}}}function B(r){return r instanceof ft}function Eo(r,e,t){let n=r.getNode();for(;n;){const s=n.__key;if(e.has(s)&&!t.has(s))return!0;n=n.getParent()}return!1}class Nc extends Vn{constructor(e){super(e)}decorate(e,t){O(47)}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function Z(r){return r instanceof Nc}class Gr extends ft{static getType(){return"root"}static clone(){return new Gr}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){O(51)}getTextContent(){const e=this.__cachedText;return!Vr()&&se()._dirtyType!==Ft||e===null?super.getTextContent():e}remove(){O(52)}replace(e){O(53)}insertBefore(e){O(54)}insertAfter(e){O(55)}updateDOM(e,t){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];B(n)||Z(n)||O(56)}return super.append(...e)}static importJSON(e){const t=ie();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{children:[],direction:this.getDirection(),format:this.getFormatType(),indent:this.getIndent(),type:"root",version:1}}collapseAtStart(){return!0}}function De(r){return r instanceof Gr}function iu(r){return new Hn(new Map(r._nodeMap))}function bi(){return new Hn(new Map([["root",new Gr]]))}function ou(r){const e=r.exportJSON(),t=r.constructor;if(e.type!==t.getType()&&O(130,t.name),B(r)){const n=e.children;Array.isArray(n)||O(59,t.name);const s=r.getChildren();for(let o=0;o<s.length;o++){const i=ou(s[o]);n.push(i)}}return e}class Hn{constructor(e,t){this._nodeMap=e,this._selection=t||null,this._flushSync=!1,this._readOnly=!1}isEmpty(){return this._nodeMap.size===1&&this._selection===null}read(e,t){return Do(t&&t.editor||null,this,e)}clone(e){const t=new Hn(this._nodeMap,e===void 0?this._selection:e);return t._readOnly=!0,t}toJSON(){return Do(null,this,()=>({root:ou(ie())}))}}class vi extends ft{static getType(){return"artificial"}createDOM(e){return document.createElement("div")}}class sr extends ft{constructor(e){super(e),this.__textFormat=0,this.__textStyle=""}static getType(){return"paragraph"}getTextFormat(){return this.getLatest().__textFormat}setTextFormat(e){const t=this.getWritable();return t.__textFormat=e,t}hasTextFormat(e){const t=Lt[e];return!!(this.getTextFormat()&t)}getFormatFlags(e,t){return Cn(this.getLatest().__textFormat,e,t)}getTextStyle(){return this.getLatest().__textStyle}setTextStyle(e){const t=this.getWritable();return t.__textStyle=e,t}static clone(e){return new sr(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}createDOM(e){const t=document.createElement("p"),n=wr(e.theme,"paragraph");return n!==void 0&&t.classList.add(...n),t}updateDOM(e,t,n){return!1}static importDOM(){return{p:e=>({conversion:Fc,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&ct(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=fe();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t.setTextFormat(e.textFormat),t}exportJSON(){return{...super.exportJSON(),textFormat:this.getTextFormat(),textStyle:this.getTextStyle(),type:"paragraph",version:1}}insertNewAfter(e,t){const n=fe();n.setTextFormat(e.format),n.setTextStyle(e.style);const s=this.getDirection();return n.setDirection(s),n.setFormat(this.getFormatType()),n.setStyle(this.getTextStyle()),this.insertAfter(n,t),n}collapseAtStart(){const e=this.getChildren();if(e.length===0||M(e[0])&&e[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 Fc(r){const e=fe();return r.style&&(e.setFormat(r.style.textAlign),mi(r,e)),{node:e}}function fe(){return st(new sr)}function rr(r){return r instanceof sr}const Y=0,Jt=1,Lc=4;function lu(r,e,t,n){const s=r._keyToDOMMap;s.clear(),r._editorState=bi(),r._pendingEditorState=n,r._compositionKey=null,r._dirtyType=Ft,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),r._normalizedNodes=new Set,r._updateTags=new Set,r._updates=[],r._blockCursorElement=null;const o=r._observer;o!==null&&(o.disconnect(),r._observer=null),e!==null&&(e.textContent=""),t!==null&&(t.textContent="",s.set("root",t))}function jc(r){const e=r||{},t=Tc(),n=e.theme||{},s=r===void 0?t:e.parentEditor||null,o=e.disableEvents||!1,i=bi(),l=e.namespace||(s!==null?s._config.namespace:Nl()),u=e.editorState,a=[Gr,nr,qr,Ur,sr,vi,...e.nodes||[]],{onError:c,html:f}=e,d=e.editable===void 0||e.editable;let h;if(r===void 0&&t!==null)h=t._nodes;else{h=new Map;for(let m=0;m<a.length;m++){let x=a[m],C=null,_=null;if(typeof x!="function"){const v=x;x=v.replace,C=v.with,_=v.withKlass||null}const E=x.getType(),D=x.transform(),A=new Set;D!==null&&A.add(D),h.set(E,{exportDOM:f&&f.export?f.export.get(x):void 0,klass:x,replace:C,replaceWithKlass:_,transforms:A})}}const p=new Jn(i,s,h,{disableEvents:o,namespace:l,theme:n},c||console.error,function(m,x){const C=new Map,_=new Set,E=D=>{Object.keys(D).forEach(A=>{let v=C.get(A);v===void 0&&(v=[],C.set(A,v)),v.push(D[A])})};return m.forEach(D=>{const A=D.klass.importDOM;if(A==null||_.has(A))return;_.add(A);const v=A.call(D.klass);v!==null&&E(v)}),x&&E(x),C}(h,f?f.import:void 0),d);return u!==void 0&&(p._pendingEditorState=u,p._dirtyType=er),p}class Jn{constructor(e,t,n,s,o,i,l){this._parentEditor=t,this._rootElement=null,this._editorState=e,this._pendingEditorState=null,this._compositionKey=null,this._deferred=[],this._keyToDOMMap=new Map,this._updates=[],this._updating=!1,this._listeners={decorator:new Set,editable:new Set,mutation:new Map,root:new Set,textcontent:new Set,update:new Set},this._commands=new Map,this._config=s,this._nodes=n,this._decorators={},this._pendingDecorators=null,this._dirtyType=Ft,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=Nl(),this._onError=o,this._htmlConversions=i,this._editable=l,this._headless=t!==null&&t._headless,this._window=null,this._blockCursorElement=null}isComposing(){return this._compositionKey!=null}registerUpdateListener(e){const t=this._listeners.update;return t.add(e),()=>{t.delete(e)}}registerEditableListener(e){const t=this._listeners.editable;return t.add(e),()=>{t.delete(e)}}registerDecoratorListener(e){const t=this._listeners.decorator;return t.add(e),()=>{t.delete(e)}}registerTextContentListener(e){const t=this._listeners.textcontent;return t.add(e),()=>{t.delete(e)}}registerRootListener(e){const t=this._listeners.root;return e(this._rootElement,null),t.add(e),()=>{e(null,this._rootElement),t.delete(e)}}registerCommand(e,t,n){n===void 0&&O(35);const s=this._commands;s.has(e)||s.set(e,[new Set,new Set,new Set,new Set,new Set]);const o=s.get(e);o===void 0&&O(36,String(e));const i=o[n];return i.add(t),()=>{i.delete(t),o.every(l=>l.size===0)&&s.delete(e)}}registerMutationListener(e,t,n){const s=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,o=this._listeners.mutation;o.set(t,s);const i=n&&n.skipInitialization;return i!==void 0&&i||this.initializeMutationListener(t,s),()=>{o.delete(t)}}getRegisteredNode(e){const t=this._nodes.get(e.getType());return t===void 0&&O(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){const n=this._editorState,s=fc(n).get(t.getType());if(!s)return;const o=new Map;for(const i of s.keys())o.set(i,"created");o.size>0&&e(o,{dirtyLeaves:new Set,prevEditorState:n,updateTags:new Set(["registerMutationListener"])})}registerNodeTransformToKlass(e,t){const n=this.getRegisteredNode(e);return n.transforms.add(t),n}registerNodeTransform(e,t){const n=this.registerNodeTransformToKlass(e,t),s=[n],o=n.replaceWithKlass;if(o!=null){const u=this.registerNodeTransformToKlass(o,t);s.push(u)}var i,l;return i=this,l=e.getType(),Ne(i,()=>{const u=dt();if(u.isEmpty())return;if(l==="root")return void ie().markDirty();const a=u._nodeMap;for(const[,c]of a)c.markDirty()},i._pendingEditorState===null?{tag:"history-merge"}:void 0),()=>{s.forEach(u=>u.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,t){return I(this,e,t)}getDecorators(){return this._decorators}getRootElement(){return this._rootElement}getKey(){return this._key}setRootElement(e){const t=this._rootElement;if(e!==t){const n=wr(this._config.theme,"root"),s=this._pendingEditorState||this._editorState;if(this._rootElement=e,lu(this,t,e,s),t!==null&&(this._config.disableEvents||yc(t),n!=null&&t.classList.remove(...n)),e!==null){const o=function(l){const u=l.ownerDocument;return u&&u.defaultView||null}(e),i=e.style;i.userSelect="text",i.whiteSpace="pre-wrap",i.wordBreak="break-word",e.setAttribute("data-lexical-editor","true"),this._window=o,this._dirtyType=er,Cl(this),this._updateTags.add("history-merge"),xt(this),this._config.disableEvents||function(l,u){const a=l.ownerDocument,c=Bn.get(a);(c===void 0||c<1)&&a.addEventListener("selectionchange",Gl),Bn.set(a,(c||0)+1),l.__lexicalEditor=u;const f=Vl(l);for(let d=0;d<Ms.length;d++){const[h,p]=Ms[d],m=typeof p=="function"?x=>{oo(x)||(io(x),(u.isEditable()||h==="click")&&p(x,u))}:x=>{if(oo(x))return;io(x);const C=u.isEditable();switch(h){case"cut":return C&&I(u,Xs,x);case"copy":return I(u,Rn,x);case"paste":return C&&I(u,Mn,x);case"dragstart":return C&&I(u,gl,x);case"dragover":return C&&I(u,ml,x);case"dragend":return C&&I(u,Ta,x);case"focus":return C&&I(u,Fa,x);case"blur":return C&&I(u,La,x);case"drop":return C&&I(u,pl,x)}};l.addEventListener(h,m),f.push(()=>{l.removeEventListener(h,m)})}}(e,this),n!=null&&e.classList.add(...n)}else this._editorState=s,this._pendingEditorState=null,this._window=null;Sr("root",this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&O(38);let n=e;n._readOnly&&(n=iu(e),n._selection=e._selection?e._selection.clone():null),Dl(this);const s=this._pendingEditorState,o=this._updateTags,i=t!==void 0?t.tag:null;s===null||s.isEmpty()||(i!=null&&o.add(i),xt(this)),this._pendingEditorState=n,this._dirtyType=er,this._dirtyElements.set("root",!1),this._compositionKey=null,i!=null&&o.add(i),this._updating||xt(this)}parseEditorState(e,t){return function(n,s,o){const i=bi(),l=ge,u=Se,a=me,c=s._dirtyElements,f=s._dirtyLeaves,d=s._cloneNotNeeded,h=s._dirtyType;s._dirtyElements=new Map,s._dirtyLeaves=new Set,s._cloneNotNeeded=new Set,s._dirtyType=0,ge=i,Se=!1,me=s;try{const p=s._nodes;_i(n.root,p),o&&o(),i._readOnly=!0}catch(p){p instanceof Error&&s._onError(p)}finally{s._dirtyElements=c,s._dirtyLeaves=f,s._cloneNotNeeded=d,s._dirtyType=h,ge=l,Se=u,me=a}return i}(typeof e=="string"?JSON.parse(e):e,this,t)}read(e){return xt(this),this.getEditorState().read(e,{editor:this})}update(e,t){Ne(this,e,t)}focus(e,t={}){const n=this._rootElement;n!==null&&(n.setAttribute("autocapitalize","off"),Ne(this,()=>{const s=q(),o=ie();s!==null?s.dirty=!0:o.getChildrenSize()!==0&&(t.defaultSelection==="rootStart"?o.selectStart():o.selectEnd())},{onUpdate:()=>{n.removeAttribute("autocapitalize"),e&&e()},tag:"focus"}),this._pendingEditorState===null&&n.removeAttribute("autocapitalize"))}blur(){const e=this._rootElement;e!==null&&e.blur();const t=Oe(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,Sr("editable",this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}}Jn.version="0.21.0+prod.esm";const uu=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Pc=uu?k.useLayoutEffect:k.useEffect,un={tag:"history-merge"};function Oc({initialConfig:r,children:e}){const t=k.useMemo(()=>{const{theme:n,namespace:s,nodes:o,onError:i,editorState:l,html:u}=r,a=_a(null,n),c=jc({editable:r.editable,html:u,namespace:s,nodes:o,onError:f=>i(f,c),theme:n});return function(f,d){if(d!==null){if(d===void 0)f.update(()=>{const h=ie();if(h.isEmpty()){const p=fe();h.append(p);const m=uu?document.activeElement:null;(q()!==null||m!==null&&m===f.getRootElement())&&p.select()}},un);else if(d!==null)switch(typeof d){case"string":{const h=f.parseEditorState(d);f.setEditorState(h,un);break}case"object":f.setEditorState(d,un);break;case"function":f.update(()=>{ie().isEmpty()&&d(f)},un)}}}(c,l),[c,a]},[]);return Pc(()=>{const n=r.editable,[s]=t;s.setEditable(n===void 0||n)},[]),g.jsx(il.Provider,{value:t,children:e})}const Mc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?k.useLayoutEffect:k.useEffect;function Rc(r){return{initialValueFn:()=>r.isEditable(),subscribe:e=>r.registerEditableListener(e)}}function $c(){return function(r){const[e]=nt(),t=k.useMemo(()=>r(e),[e,r]),[n,s]=k.useState(()=>t.initialValueFn()),o=k.useRef(n);return Mc(()=>{const{initialValueFn:i,subscribe:l}=t,u=i();return o.current!==u&&(o.current=u,s(u)),l(a=>{o.current=a,s(a)})},[t,r]),n}(Rc)}function Ic(){return ie().getTextContent()}function zc(r,e=!0){if(r)return!1;let t=Ic();return e&&(t=t.trim()),t===""}function qc(r){if(!zc(r,!1))return!1;const e=ie().getChildren(),t=e.length;if(t>1)return!1;for(let n=0;n<t;n++){const s=e[n];if(Z(s))return!1;if(B(s)){if(!rr(s)||s.__indent!==0)return!1;const o=s.getChildren(),i=o.length;for(let l=0;l<i;l++){const u=o[n];if(!M(u))return!1}}}return!0}function au(r){return()=>qc(r)}function Uc(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}Uc(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function Wc(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Kc=Wc(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const Vc=new Map;function Gc(r){const e={};if(!r)return e;const t=r.split(";");for(const n of t)if(n!==""){const[s,o]=n.split(/:([^]+)/);s&&o&&(e[s.trim()]=o.trim())}return e}function cu(r,e){const t=r.getStartEndPoints();if(e.isSelected(r)&&!e.isSegmented()&&!e.isToken()&&t!==null){const[n,s]=t,o=r.isBackward(),i=n.getNode(),l=s.getNode(),u=e.is(i),a=e.is(l);if(u||a){const[c,f]=zs(r),d=i.is(l),h=e.is(o?l:i),p=e.is(o?i:l);let m,x=0;return d?(x=c>f?f:c,m=c>f?c:f):h?(x=o?f:c,m=void 0):p&&(x=0,m=o?c:f),e.__text=e.__text.slice(x,m),e}}return e}function Hc(r){const e=r.getStyle(),t=Gc(e);Vc.set(e,t)}function Jc(r,e){if(r===null)return;const t=r.getStartEndPoints(),n=t?t[0]:null;if(n!==null&&n.key==="root"){const i=e(),l=ie(),u=l.getFirstChild();return void(u?u.replace(i,!0):l.append(i))}const s=r.getNodes(),o=n!==null&&function(i,l){let u=i;for(;u!==null&&u.getParent()!==null&&!l(u);)u=u.getParentOrThrow();return l(u)?u:null}(n.getNode(),So);o&&s.indexOf(o)===-1&&s.push(o);for(let i=0;i<s.length;i++){const l=s[i];if(!So(l))continue;B(l)||Kc(178);const u=e();u.setFormat(l.getFormatType()),u.setIndent(l.getIndent()),l.replace(u,!0)}}function Ao(r,e){const t=Lr(r.focus,e);return Z(t)&&!t.isIsolated()||B(t)&&!t.isInline()&&!t.canBeEmpty()}function Qc(r,e,t,n){r.modify(e?"extend":"move",t,n)}function Yc(r){const e=r.anchor.getNode();return(De(e)?e:e.getParentOrThrow()).getDirection()==="rtl"}function ko(r,e,t){const n=Yc(r);Qc(r,e,t?!n:n,"character")}function So(r){if(Z(r)||!B(r)||tt(r))return!1;const e=r.getFirstChild(),t=e===null||Nt(e)||M(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function Xc(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Zc=Xc(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});const du=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,ed=du&&"documentMode"in document?document.documentMode:null;!(!du||!("InputEvent"in window)||ed)&&"getTargetRanges"in new window.InputEvent("input");function fu(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}function Mt(...r){return()=>{for(let e=r.length-1;e>=0;e--)r[e]();r.length=0}}function Hr(r,...e){const t=fu(...e);t.length>0&&r.classList.add(...t)}function hu(r,...e){const t=fu(...e);t.length>0&&r.classList.remove(...t)}function td(r,e){let t=r;for(;t!=null;){if(t instanceof e)return t;t=t.getParent()}return null}function rd(r){const e=Qn(r,t=>B(t)&&!t.isInline());return B(e)||Zc(4,r.__key),e}const Qn=(r,e)=>{let t=r;for(;t!==ie()&&t!=null;){if(e(t))return t;t=t.getParent()}return null};function _t(r,e){return r!==null&&Object.getPrototypeOf(r).constructor.name===e.name}function nd(r){const e=window.location.origin,t=n=>{if(n.origin!==e)return;const s=r.getRootElement();if(document.activeElement!==s)return;const o=n.data;if(typeof o=="string"){let i;try{i=JSON.parse(o)}catch{return}if(i&&i.protocol==="nuanria_messaging"&&i.type==="request"){const l=i.payload;if(l&&l.functionId==="makeChanges"){const u=l.args;if(u){const[a,c,f,d,h,p]=u;r.update(()=>{const m=q();if(P(m)){const x=m.anchor;let C=x.getNode(),_=0,E=0;if(M(C)&&a>=0&&c>=0&&(_=a,E=a+c,m.setTextNodeRange(C,_,C,E)),_===E&&f===""||(m.insertRawText(f),C=x.getNode()),M(C)){_=d,E=d+h;const D=C.getTextContentSize();_=_>D?D:_,E=E>D?D:E,m.setTextNodeRange(C,_,C,E)}n.stopImmediatePropagation()}})}}}}};return window.addEventListener("message",t,!0),()=>{window.removeEventListener("message",t,!0)}}function pu(r,e){const t=e.body?e.body.childNodes:[];let n=[];const s=[];for(let o=0;o<t.length;o++){const i=t[o];if(!yu.has(i.nodeName)){const l=xu(i,r,s,!1);l!==null&&(n=n.concat(l))}}return function(o){for(const i of o)i.getNextSibling()instanceof vi&&i.insertAfter(Pt());for(const i of o){const l=i.getChildren();for(const u of l)i.insertBefore(u);i.remove()}}(s),n}function gu(r,e){if(typeof document>"u"||typeof window>"u"&&global.window===void 0)throw new Error("To use $generateHtmlFromNodes in headless mode please initialize a headless browser implementation such as JSDom before calling this function.");const t=document.createElement("div"),n=ie().getChildren();for(let s=0;s<n.length;s++)mu(r,n[s],t,e);return t.innerHTML}function mu(r,e,t,n=null){let s=n===null||e.isSelected(n);const o=B(e)&&e.excludeFromCopy("html");let i=e;if(n!==null){let h=gi(e);h=M(h)&&n!==null?cu(n,h):h,i=h}const l=B(i)?i.getChildren():[],u=r._nodes.get(i.getType());let a;a=u&&u.exportDOM!==void 0?u.exportDOM(r,i):i.exportDOM(r);const{element:c,after:f}=a;if(!c)return!1;const d=document.createDocumentFragment();for(let h=0;h<l.length;h++){const p=l[h],m=mu(r,p,d,n);!s&&B(e)&&m&&e.extractWithChild(p,n,"html")&&(s=!0)}if(s&&!o){if((ct(c)||eo(c))&&c.append(d),t.append(c),f){const h=f.call(i,c);h&&(eo(c)?c.replaceChildren(h):c.replaceWith(h))}}else t.append(d);return s}const yu=new Set(["STYLE","SCRIPT"]);function xu(r,e,t,n,s=new Map,o){let i=[];if(yu.has(r.nodeName))return i;let l=null;const u=function(p,m){const{nodeName:x}=p,C=m._htmlConversions.get(x.toLowerCase());let _=null;if(C!==void 0)for(const E of C){const D=E(p);D!==null&&(_===null||(_.priority||0)<=(D.priority||0))&&(_=D)}return _!==null?_.conversion:null}(r,e),a=u?u(r):null;let c=null;if(a!==null){c=a.after;const p=a.node;if(l=Array.isArray(p)?p[p.length-1]:p,l!==null){for(const[,m]of s)if(l=m(l,o),!l)break;l&&i.push(...Array.isArray(p)?p:[l])}a.forChild!=null&&s.set(r.nodeName,a.forChild)}const f=r.childNodes;let d=[];const h=(l==null||!tt(l))&&(l!=null&&qs(l)||n);for(let p=0;p<f.length;p++)d.push(...xu(f[p],e,t,h,new Map(s),l));return c!=null&&(d=c(d)),An(r)&&(d=sd(r,d,h?()=>{const p=new vi;return t.push(p),p}:fe)),l==null?d.length>0?i=i.concat(d):An(r)&&function(p){return p.nextSibling==null||p.previousSibling==null?!1:Ts(p.nextSibling)&&Ts(p.previousSibling)}(r)&&(i=i.concat(Pt())):B(l)&&l.append(...d),i}function sd(r,e,t){const n=r.style.textAlign,s=[];let o=[];for(let i=0;i<e.length;i++){const l=e[i];if(qs(l))n&&!l.getFormat()&&l.setFormat(n),s.push(l);else if(o.push(l),i===e.length-1||i<e.length-1&&qs(e[i+1])){const u=t();u.setFormat(n),u.append(...o),s.push(u),o=[]}}return s}function id(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ln=id(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function od(r,e=q()){return e==null&&Ln(166),P(e)&&e.isCollapsed()||e.getNodes().length===0?"":gu(r,e)}function ld(r,e=q()){return e==null&&Ln(166),P(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(ud(r,e))}function To(r,e,t){const n=r.getData("application/x-lexical-editor");if(n)try{const i=JSON.parse(n);if(i.namespace===t._config.namespace&&Array.isArray(i.nodes))return Bo(t,ad(i.nodes),e)}catch{}const s=r.getData("text/html");if(s)try{const i=new DOMParser().parseFromString(function(l){return window.trustedTypes&&window.trustedTypes.createPolicy?window.trustedTypes.createPolicy("lexical",{createHTML:u=>u}).createHTML(l):l}(s),"text/html");return Bo(t,pu(t,i),e)}catch{}const o=r.getData("text/plain")||r.getData("text/uri-list");if(o!=null)if(P(e)){const i=o.split(/(\r?\n|\t)/);i[i.length-1]===""&&i.pop();for(let l=0;l<i.length;l++){const u=q();if(P(u)){const a=i[l];a===`
|
|
72
72
|
`||a===`\r
|
|
73
|
-
`?u.insertParagraph():a===" "?u.insertNodes([Wr()]):u.insertText(a)}}}else e.insertRawText(o)}function Bo(r,e,t){r.dispatchCommand(ba,{nodes:e,selection:t})||t.insertNodes(e)}function _u(r,e,t,n=[]){let s=e===null||t.isSelected(e);const o=B(t)&&t.excludeFromCopy("html");let i=t;if(e!==null){let a=gi(t);a=M(a)&&e!==null?cu(e,a):a,i=a}const l=B(i)?i.getChildren():[],u=function(a){const c=a.exportJSON(),f=a.constructor;if(c.type!==f.getType()&&Ln(58,f.name),B(a)){const d=c.children;Array.isArray(d)||Ln(59,f.name)}return c}(i);if(M(i)){const a=i.__text;a.length>0?u.text=a:s=!1}for(let a=0;a<l.length;a++){const c=l[a],f=_u(r,e,c,u.children);!s&&B(t)&&f&&t.extractWithChild(c,e,"clone")&&(s=!0)}if(s&&!o)n.push(u);else if(Array.isArray(u.children))for(let a=0;a<u.children.length;a++){const c=u.children[a];n.push(c)}return s}function ud(r,e){const t=[],n=ie().getChildren();for(let s=0;s<n.length;s++)_u(r,e,n[s],t);return{namespace:r._config.namespace,nodes:t}}function ad(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t],s=Bc(n);M(s)&&Hc(s),e.push(s)}return e}let Kt=null;async function No(r,e,t){if(Kt!==null)return!1;if(e!==null)return new Promise((u,a)=>{r.update(()=>{u(Fo(r,e,t))})});const n=r.getRootElement(),s=r._window==null?window.document:r._window.document,o=Oe(r._window);if(n===null||o===null)return!1;const i=s.createElement("span");i.style.cssText="position: fixed; top: -1000px;",i.append(s.createTextNode("#")),n.append(i);const l=new Range;return l.setStart(i,0),l.setEnd(i,1),o.removeAllRanges(),o.addRange(l),new Promise((u,a)=>{const c=r.registerCommand(Rn,f=>(_t(f,ClipboardEvent)&&(c(),Kt!==null&&(window.clearTimeout(Kt),Kt=null),u(Fo(r,f,t))),!0),Lc);Kt=window.setTimeout(()=>{c(),Kt=null,u(!1)},50),s.execCommand("copy"),i.remove()})}function Fo(r,e,t){if(t===void 0){const s=Oe(r._window);if(!s)return!1;const o=s.anchorNode,i=s.focusNode;if(o!==null&&i!==null&&!Ir(r,o,i))return!1;const l=q();if(l===null)return!1;t=dd(l)}e.preventDefault();const n=e.clipboardData;return n!==null&&(fd(n,t),!0)}const cd=[["text/html",od],["application/x-lexical-editor",ld]];function dd(r=q()){const e={"text/plain":r?r.getTextContent():""};if(r){const t=cc();for(const[n,s]of cd){const o=s(t,r);o!==null&&(e[n]=o)}}return e}function fd(r,e){for(const t in e){const n=e[t];n!==void 0&&r.setData(t,n)}}function Lo(r,e){if(document.caretRangeFromPoint!==void 0){const t=document.caretRangeFromPoint(r,e);return t===null?null:{node:t.startContainer,offset:t.startOffset}}if(document.caretPositionFromPoint!=="undefined"){const t=document.caretPositionFromPoint(r,e);return t===null?null:{node:t.offsetNode,offset:t.offset}}return null}const ir=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,hd=ir&&"documentMode"in document?document.documentMode:null,pd=!(!ir||!("InputEvent"in window)||hd)&&"getTargetRanges"in new window.InputEvent("input"),gd=ir&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),jo=ir&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,md=ir&&/^(?=.*Chrome).*/i.test(navigator.userAgent),yd=ir&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!md,Po=Mr();class Yn extends ft{static getType(){return"quote"}static clone(e){return new Yn(e.__key)}constructor(e){super(e)}createDOM(e){const t=document.createElement("blockquote");return Hr(t,e.theme.quote),t}updateDOM(e,t){return!1}static importDOM(){return{blockquote:e=>({conversion:xd,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&ct(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=Ci();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(e,t){const n=fe(),s=this.getDirection();return n.setDirection(s),this.insertAfter(n,t),n}collapseAtStart(){const e=fe();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}canMergeWhenEmpty(){return!0}}function Ci(){return st(new Yn)}class Xn extends ft{static getType(){return"heading"}static clone(e){return new Xn(e.__tag,e.__key)}constructor(e,t){super(t),this.__tag=e}getTag(){return this.__tag}createDOM(e){const t=this.__tag,n=document.createElement(t),s=e.theme.heading;if(s!==void 0){const o=s[t];Hr(n,o)}return n}updateDOM(e,t){return!1}static importDOM(){return{h1:e=>({conversion:Vt,priority:0}),h2:e=>({conversion:Vt,priority:0}),h3:e=>({conversion:Vt,priority:0}),h4:e=>({conversion:Vt,priority:0}),h5:e=>({conversion:Vt,priority:0}),h6:e=>({conversion:Vt,priority:0}),p:e=>{const t=e.firstChild;return t!==null&&Oo(t)?{conversion:()=>({node:null}),priority:3}:null},span:e=>Oo(e)?{conversion:t=>({node:br("h1")}),priority:3}:null}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&ct(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=br(e.tag);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(e,t=!0){const n=e?e.anchor.offset:0,s=this.getLastDescendant(),o=!s||e&&e.anchor.key===s.getKey()&&n===s.getTextContentSize()||!e?fe():br(this.getTag()),i=this.getDirection();if(o.setDirection(i),this.insertAfter(o,t),n===0&&!this.isEmpty()&&e){const l=fe();l.select(),this.replace(l,!0)}return o}collapseAtStart(){const e=this.isEmpty()?fe():br(this.getTag());return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}extractWithChild(){return!0}}function Oo(r){return r.nodeName.toLowerCase()==="span"&&r.style.fontSize==="26pt"}function Vt(r){const e=r.nodeName.toLowerCase();let t=null;return e!=="h1"&&e!=="h2"&&e!=="h3"&&e!=="h4"&&e!=="h5"&&e!=="h6"||(t=br(e),r.style!==null&&(mi(r,t),t.setFormat(r.style.textAlign))),{node:t}}function xd(r){const e=Ci();return r.style!==null&&(e.setFormat(r.style.textAlign),mi(r,e)),{node:e}}function br(r){return st(new Xn(r))}function an(r){let e=null;if(_t(r,DragEvent)?e=r.dataTransfer:_t(r,ClipboardEvent)&&(e=r.clipboardData),e===null)return[!1,[],!1];const t=e.types,n=t.includes("Files"),s=t.includes("text/html")||t.includes("text/plain");return[n,Array.from(e.files),s]}function Mo(r){const e=q();if(!P(e))return!1;const t=new Set,n=e.getNodes();for(let s=0;s<n.length;s++){const o=n[s],i=o.getKey();if(t.has(i))continue;const l=Qn(o,a=>B(a)&&!a.isInline());if(l===null)continue;const u=l.getKey();l.canIndent()&&!t.has(u)&&(t.add(u),r(l))}return t.size>0}function cn(r){const e=tr(r);return Z(e)}function _d(r){return Mt(r.registerCommand(ol,e=>{const t=q();return!!Ye(t)&&(t.clear(),!0)},0),r.registerCommand(Tt,e=>{const t=q();return!!P(t)&&(t.deleteCharacter(e),!0)},Y),r.registerCommand(Nr,e=>{const t=q();return!!P(t)&&(t.deleteWord(e),!0)},Y),r.registerCommand(Fr,e=>{const t=q();return!!P(t)&&(t.deleteLine(e),!0)},Y),r.registerCommand(Yt,e=>{const t=q();if(typeof e=="string")t!==null&&t.insertText(e);else{if(t===null)return!1;const n=e.dataTransfer;if(n!=null)To(n,t,r);else if(P(t)){const s=e.data;return s&&t.insertText(s),!0}}return!0},Y),r.registerCommand(As,()=>{const e=q();return!!P(e)&&(e.removeText(),!0)},Y),r.registerCommand(We,e=>{const t=q();return!!P(t)&&(t.formatText(e),!0)},Y),r.registerCommand(Sa,e=>{const t=q();if(!P(t)&&!Ye(t))return!1;const n=t.getNodes();for(const s of n){const o=Qn(s,i=>B(i)&&!i.isInline());o!==null&&o.setFormat(e)}return!0},Y),r.registerCommand(Qt,e=>{const t=q();return!!P(t)&&(t.insertLineBreak(e),!0)},Y),r.registerCommand(Br,()=>{const e=q();return!!P(e)&&(e.insertParagraph(),!0)},Y),r.registerCommand(Aa,()=>(Zl([Wr()]),!0),Y),r.registerCommand(ka,()=>Mo(e=>{const t=e.getIndent();e.setIndent(t+1)}),Y),r.registerCommand(zi,()=>Mo(e=>{const t=e.getIndent();t>0&&e.setIndent(t-1)}),Y),r.registerCommand(al,e=>{const t=q();if(Ye(t)&&!cn(e.target)){const n=t.getNodes();if(n.length>0)return n[0].selectPrevious(),!0}else if(P(t)){const n=Lr(t.focus,!0);if(!e.shiftKey&&Z(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),e.preventDefault(),!0}return!1},Y),r.registerCommand(cl,e=>{const t=q();if(Ye(t)){const n=t.getNodes();if(n.length>0)return n[0].selectNext(0,0),!0}else if(P(t)){if(function(s){const o=s.focus;return o.key==="root"&&o.offset===ie().getChildrenSize()}(t))return e.preventDefault(),!0;const n=Lr(t.focus,!1);if(!e.shiftKey&&Z(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),e.preventDefault(),!0}return!1},Y),r.registerCommand(ul,e=>{const t=q();if(Ye(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectPrevious(),!0}if(!P(t))return!1;if(Ao(t,!0)){const n=e.shiftKey;return e.preventDefault(),ko(t,n,!0),!0}return!1},Y),r.registerCommand(ll,e=>{const t=q();if(Ye(t)&&!cn(e.target)){const s=t.getNodes();if(s.length>0)return e.preventDefault(),s[0].selectNext(0,0),!0}if(!P(t))return!1;const n=e.shiftKey;return!!Ao(t,!1)&&(e.preventDefault(),ko(t,n,!1),!0)},Y),r.registerCommand(dl,e=>{if(cn(e.target))return!1;const t=q();if(!P(t))return!1;const{anchor:n}=t,s=n.getNode();return t.isCollapsed()&&n.offset===0&&!Ce(s)&&rd(s).getIndent()>0?(e.preventDefault(),r.dispatchCommand(zi,void 0)):(!jo||navigator.language!=="ko-KR")&&(e.preventDefault(),r.dispatchCommand(Tt,!0))},Y),r.registerCommand(hl,e=>{if(cn(e.target))return!1;const t=q();return!!P(t)&&(e.preventDefault(),r.dispatchCommand(Tt,!1))},Y),r.registerCommand(yn,e=>{const t=q();if(!P(t))return!1;if(e!==null){if((jo||gd||yd)&&pd)return!1;if(e.preventDefault(),e.shiftKey)return r.dispatchCommand(Qt,!1)}return r.dispatchCommand(Br,void 0)},Y),r.registerCommand(fl,()=>{const e=q();return!!P(e)&&(r.blur(),!0)},Y),r.registerCommand(pl,e=>{const[,t]=an(e);if(t.length>0){const s=Lo(e.clientX,e.clientY);if(s!==null){const{offset:o,node:i}=s,l=tr(i);if(l!==null){const u=Ac();if(M(l))u.anchor.set(l.getKey(),o,"text"),u.focus.set(l.getKey(),o,"text");else{const c=l.getParentOrThrow().getKey(),f=l.getIndexWithinParent()+1;u.anchor.set(c,f,"element"),u.focus.set(c,f,"element")}const a=wl(u);et(a)}r.dispatchCommand(Po,t)}return e.preventDefault(),!0}const n=q();return!!P(n)},Y),r.registerCommand(gl,e=>{const[t]=an(e),n=q();return!(t&&!P(n))},Y),r.registerCommand(ml,e=>{const[t]=an(e),n=q();if(t&&!P(n))return!1;const s=Lo(e.clientX,e.clientY);if(s!==null){const o=tr(s.node);Z(o)&&e.preventDefault()}return!0},Y),r.registerCommand(ks,()=>(oc(),!0),Y),r.registerCommand(Rn,e=>(No(r,_t(e,ClipboardEvent)?e:null),!0),Y),r.registerCommand(Xs,e=>(async function(t,n){await No(n,_t(t,ClipboardEvent)?t:null),n.update(()=>{const s=q();P(s)?s.removeText():Ye(s)&&s.getNodes().forEach(o=>o.remove())})}(e,r),!0),Y),r.registerCommand(Mn,e=>{const[,t,n]=an(e);return t.length>0&&!n?(r.dispatchCommand(Po,t),!0):ui(e.target)?!1:q()!==null&&(function(s,o){s.preventDefault(),o.update(()=>{const i=q(),l=_t(s,InputEvent)||_t(s,KeyboardEvent)?null:s.clipboardData;l!=null&&i!==null&&To(l,i,o)},{tag:"paste"})}(e,r),!0)},Y))}const Us=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?k.useLayoutEffect:k.useEffect;function Ro(r){return r.getEditorState().read(au(r.isComposing()))}function bd({contentEditable:r,placeholder:e=null,ErrorBoundary:t}){const[n]=nt(),s=function(o,i){const[l,u]=k.useState(()=>o.getDecorators());return Us(()=>o.registerDecoratorListener(a=>{Ni.flushSync(()=>{u(a)})}),[o]),k.useEffect(()=>{u(o.getDecorators())},[o]),k.useMemo(()=>{const a=[],c=Object.keys(l);for(let f=0;f<c.length;f++){const d=c[f],h=g.jsx(i,{onError:m=>o._onError(m),children:g.jsx(k.Suspense,{fallback:null,children:l[d]})}),p=o.getElementByKey(d);p!==null&&a.push(Ni.createPortal(h,p,d))}return a},[i,l,o])}(n,t);return function(o){Us(()=>Mt(_d(o),nd(o)),[o])}(n),g.jsxs(g.Fragment,{children:[r,g.jsx(vd,{content:e}),s]})}function vd({content:r}){const[e]=nt(),t=function(s){const[o,i]=k.useState(()=>Ro(s));return Us(()=>{function l(){const u=Ro(s);i(u)}return l(),Mt(s.registerUpdateListener(()=>{l()}),s.registerEditableListener(()=>{l()}))},[s]),o}(e),n=$c();return t?typeof r=="function"?r(n):r:null}const bu=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?k.useLayoutEffect:k.useEffect;function Cd({editor:r,ariaActiveDescendant:e,ariaAutoComplete:t,ariaControls:n,ariaDescribedBy:s,ariaErrorMessage:o,ariaExpanded:i,ariaInvalid:l,ariaLabel:u,ariaLabelledBy:a,ariaMultiline:c,ariaOwns:f,ariaRequired:d,autoCapitalize:h,className:p,id:m,role:x="textbox",spellCheck:D=!0,style:_,tabIndex:E,"data-testid":C,...A},v){const[b,w]=k.useState(r.isEditable()),S=k.useCallback(T=>{T&&T.ownerDocument&&T.ownerDocument.defaultView?r.setRootElement(T):r.setRootElement(null)},[r]),R=k.useMemo(()=>function(...T){return N=>{T.forEach(j=>{typeof j=="function"?j(N):j!=null&&(j.current=N)})}}(v,S),[S,v]);return bu(()=>(w(r.isEditable()),r.registerEditableListener(T=>{w(T)})),[r]),g.jsx("div",{"aria-activedescendant":b?e:void 0,"aria-autocomplete":b?t:"none","aria-controls":b?n:void 0,"aria-describedby":s,...o!=null?{"aria-errormessage":o}:{},"aria-expanded":b&&x==="combobox"?!!i:void 0,...l!=null?{"aria-invalid":l}:{},"aria-label":u,"aria-labelledby":a,"aria-multiline":c,"aria-owns":b?f:void 0,"aria-readonly":!b||void 0,"aria-required":d,autoCapitalize:h,className:p,contentEditable:b,"data-testid":C,id:m,ref:R,role:b?x:void 0,spellCheck:D,style:_,tabIndex:E,...A})}const Dd=k.forwardRef(Cd);function $o(r){return r.getEditorState().read(au(r.isComposing()))}const wd=k.forwardRef(Ed);function Ed(r,e){const{placeholder:t,...n}=r,[s]=nt();return g.jsxs(g.Fragment,{children:[g.jsx(Dd,{editor:s,...n,ref:e}),t!=null&&g.jsx(Ad,{editor:s,content:t})]})}function Ad({content:r,editor:e}){const t=function(i){const[l,u]=k.useState(()=>$o(i));return bu(()=>{function a(){const c=$o(i);u(c)}return a(),Mt(i.registerUpdateListener(()=>{a()}),i.registerEditableListener(()=>{a()}))},[i]),l}(e),[n,s]=k.useState(e.isEditable());if(k.useLayoutEffect(()=>(s(e.isEditable()),e.registerEditableListener(i=>{s(i)})),[e]),!t)return null;let o=null;return typeof r=="function"?o=r(n):r!==null&&(o=r),o===null?null:g.jsx("div",{"aria-hidden":!0,children:o})}const dn=0,Ws=1,Ks=2,Ue=0,kd=1,Io=2,Sd=3,Td=4;function Bd(r,e,t,n,s){if(r===null||t.size===0&&n.size===0&&!s)return Ue;const o=e._selection,i=r._selection;if(s)return kd;if(!(P(o)&&P(i)&&i.isCollapsed()&&o.isCollapsed()))return Ue;const l=function(D,_,E){const C=D._nodeMap,A=[];for(const v of _){const b=C.get(v);b!==void 0&&A.push(b)}for(const[v,b]of E){if(!b)continue;const w=C.get(v);w===void 0||Ce(w)||A.push(w)}return A}(e,t,n);if(l.length===0)return Ue;if(l.length>1){const D=e._nodeMap,_=D.get(o.anchor.key),E=D.get(i.anchor.key);return _&&E&&!r._nodeMap.has(_.__key)&&M(_)&&_.__text.length===1&&o.anchor.offset===1?Io:Ue}const u=l[0],a=r._nodeMap.get(u.__key);if(!M(a)||!M(u)||a.__mode!==u.__mode)return Ue;const c=a.__text,f=u.__text;if(c===f)return Ue;const d=o.anchor,h=i.anchor;if(d.key!==h.key||d.type!=="text")return Ue;const p=d.offset,m=h.offset,x=f.length-c.length;return x===1&&m===p-1?Io:x===-1&&m===p+1?Sd:x===-1&&m===p?Td:Ue}function Nd(r,e){let t=Date.now(),n=Ue;return(s,o,i,l,u,a)=>{const c=Date.now();if(a.has("historic"))return n=Ue,t=c,Ks;const f=Bd(s,o,l,u,r.isComposing()),d=(()=>{const h=i===null||i.editor===r,p=a.has("history-push");if(!p&&h&&a.has("history-merge"))return dn;if(s===null)return Ws;const m=o._selection;return l.size>0||u.size>0?p===!1&&f!==Ue&&f===n&&c<t+e&&h||l.size===1&&function(x,D,_){const E=D._nodeMap.get(x),C=_._nodeMap.get(x),A=D._selection,v=_._selection;return!(P(A)&&P(v)&&A.anchor.type==="element"&&A.focus.type==="element"&&v.anchor.type==="text"&&v.focus.type==="text"||!M(E)||!M(C)||E.__parent!==C.__parent)&&JSON.stringify(D.read(()=>E.exportJSON()))===JSON.stringify(_.read(()=>C.exportJSON()))}(Array.from(l)[0],s,o)?dn:Ws:m!==null?dn:Ks})();return t=c,n=f,d}}function zo(r){r.undoStack=[],r.redoStack=[],r.current=null}function Fd(r,e,t){const n=Nd(r,t);return Mt(r.registerCommand(Qs,()=>(function(o,i){const l=i.redoStack,u=i.undoStack;if(u.length!==0){const a=i.current,c=u.pop();a!==null&&(l.push(a),o.dispatchCommand(nn,!0)),u.length===0&&o.dispatchCommand(sn,!1),i.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),Y),r.registerCommand(Ys,()=>(function(o,i){const l=i.redoStack,u=i.undoStack;if(l.length!==0){const a=i.current;a!==null&&(u.push(a),o.dispatchCommand(sn,!0));const c=l.pop();l.length===0&&o.dispatchCommand(nn,!1),i.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),Y),r.registerCommand(Ba,()=>(zo(e),!1),Y),r.registerCommand(Na,()=>(zo(e),r.dispatchCommand(nn,!1),r.dispatchCommand(sn,!1),!0),Y),r.registerUpdateListener(({editorState:o,prevEditorState:i,dirtyLeaves:l,dirtyElements:u,tags:a})=>{const c=e.current,f=e.redoStack,d=e.undoStack,h=c===null?null:c.editorState;if(c!==null&&o===h)return;const p=n(i,o,c,l,u,a);if(p===Ws)f.length!==0&&(e.redoStack=[],r.dispatchCommand(nn,!1)),c!==null&&(d.push({...c}),r.dispatchCommand(sn,!0));else if(p===Ks)return;e.current={editor:r,editorState:o}}))}function Ld(){return{current:null,redoStack:[],undoStack:[]}}function jd({delay:r,externalHistoryState:e}){const[t]=nt();return function(n,s,o=1e3){const i=k.useMemo(()=>s||Ld(),[s]);k.useEffect(()=>Fd(n,i,o),[o,n,i])}(t,e,r),null}const Pd=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?k.useLayoutEffect:k.useEffect;function Od({ignoreHistoryMergeTagChange:r=!0,ignoreSelectionChange:e=!1,onChange:t}){const[n]=nt();return Pd(()=>{if(t)return n.registerUpdateListener(({editorState:s,dirtyElements:o,dirtyLeaves:i,prevEditorState:l,tags:u})=>{e&&o.size===0&&i.size===0||r&&u.has("history-merge")||l.isEmpty()||t(s,n,u)})},[n,r,e,t]),null}function Vs(r,e){return Vs=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},Vs(r,e)}var qo={error:null},Md=function(r){var e,t;function n(){for(var o,i=arguments.length,l=new Array(i),u=0;u<i;u++)l[u]=arguments[u];return(o=r.call.apply(r,[this].concat(l))||this).state=qo,o.resetErrorBoundary=function(){for(var a,c=arguments.length,f=new Array(c),d=0;d<c;d++)f[d]=arguments[d];o.props.onReset==null||(a=o.props).onReset.apply(a,f),o.reset()},o}t=r,(e=n).prototype=Object.create(t.prototype),e.prototype.constructor=e,Vs(e,t),n.getDerivedStateFromError=function(o){return{error:o}};var s=n.prototype;return s.reset=function(){this.setState(qo)},s.componentDidCatch=function(o,i){var l,u;(l=(u=this.props).onError)==null||l.call(u,o,i)},s.componentDidUpdate=function(o,i){var l,u,a,c,f=this.state.error,d=this.props.resetKeys;f!==null&&i.error!==null&&((a=o.resetKeys)===void 0&&(a=[]),(c=d)===void 0&&(c=[]),a.length!==c.length||a.some(function(h,p){return!Object.is(h,c[p])}))&&((l=(u=this.props).onResetKeysChange)==null||l.call(u,o.resetKeys,d),this.reset())},s.render=function(){var o=this.state.error,i=this.props,l=i.fallbackRender,u=i.FallbackComponent,a=i.fallback;if(o!==null){var c={error:o,resetErrorBoundary:this.resetErrorBoundary};if(us.isValidElement(a))return a;if(typeof l=="function")return l(c);if(u)return us.createElement(u,c);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},n}(us.Component);function Rd({children:r,onError:e}){return g.jsx(Md,{fallback:g.jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:e,children:r})}function $d(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Xe=$d(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function Id(r){let e=1,t=r.getParent();for(;t!=null;){if(ne(t)){const n=t.getParent();if(Q(n)){e++,t=n.getParent();continue}Xe(40)}return e}return e}function Gs(r){let e=r.getParent();Q(e)||Xe(40);let t=e;for(;t!==null;)t=t.getParent(),Q(t)&&(e=t);return e}function vu(r){let e=[];const t=r.getChildren().filter(ne);for(let n=0;n<t.length;n++){const s=t[n],o=s.getFirstChild();Q(o)?e=e.concat(vu(o)):e.push(s)}return e}function Ze(r){return ne(r)&&Q(r.getFirstChild())}function Uo(r){return Fe().append(r)}function Cu(r,e){return ne(r)&&(e.length===0||e.length===1&&r.is(e[0])&&r.getChildrenSize()===0)}function Wo(r,e){r.update(()=>{const t=q();if(t!==null){const n=t.getNodes();if(P(t)){const o=t.getStartEndPoints();o===null&&Xe(143);const[i]=o,l=i.getNode(),u=l.getParent();if(Cu(l,n)){const a=Te(e);if(tt(u)){l.replace(a);const c=Fe();B(l)&&(c.setFormat(l.getFormatType()),c.setIndent(l.getIndent())),a.append(c)}else if(ne(l)){const c=l.getParentOrThrow();Ot(a,c.getChildren()),c.replace(a)}return}}const s=new Set;for(let o=0;o<n.length;o++){const i=n[o];if(!B(i)||!i.isEmpty()||ne(i)||s.has(i.getKey())){if(Al(i)){let l=i.getParent();for(;l!=null;){const u=l.getKey();if(Q(l)){if(!s.has(u)){const a=Te(e);Ot(a,l.getChildren()),l.replace(a),s.add(u)}break}{const a=l.getParent();if(tt(a)&&!s.has(u)){s.add(u),Ko(l,e);break}l=a}}}}else Ko(i,e)}}})}function Ot(r,e){r.splice(r.getChildrenSize(),0,e)}function Ko(r,e){if(Q(r))return r;const t=r.getPreviousSibling(),n=r.getNextSibling(),s=Fe();let o;if(Ot(s,r.getChildren()),Q(t)&&e===t.getListType())t.append(s),Q(n)&&e===n.getListType()&&(Ot(t,n.getChildren()),n.remove()),o=t;else if(Q(n)&&e===n.getListType())n.getFirstChildOrThrow().insertBefore(s),o=n;else{const i=Te(e);i.append(s),r.replace(i),o=i}return s.setFormat(r.getFormatType()),s.setIndent(r.getIndent()),r.remove(),o}function Di(r,e){const t=r.getLastChild(),n=e.getFirstChild();t&&n&&Ze(t)&&Ze(n)&&(Di(t.getFirstChild(),n.getFirstChild()),n.remove());const s=e.getChildren();s.length>0&&r.append(...s),e.remove()}function zd(r){r.update(()=>{const e=q();if(P(e)){const t=new Set,n=e.getNodes(),s=e.anchor.getNode();if(Cu(s,n))t.add(Gs(s));else for(let o=0;o<n.length;o++){const i=n[o];if(Al(i)){const l=td(i,Rt);l!=null&&t.add(Gs(l))}}for(const o of t){let i=o;const l=vu(o);for(const u of l){const a=fe();Ot(a,u.getChildren()),i.insertAfter(a),i=a,u.__key===e.anchor.key&&e.anchor.set(a.getKey(),0,"element"),u.__key===e.focus.key&&e.focus.set(a.getKey(),0,"element"),u.remove()}o.remove()}}})}function qd(r){const e=new Set;if(Ze(r)||e.has(r.getKey()))return;const t=r.getParent(),n=r.getNextSibling(),s=r.getPreviousSibling();if(Ze(n)&&Ze(s)){const o=s.getFirstChild();if(Q(o)){o.append(r);const i=n.getFirstChild();Q(i)&&(Ot(o,i.getChildren()),n.remove(),e.add(n.getKey()))}}else if(Ze(n)){const o=n.getFirstChild();if(Q(o)){const i=o.getFirstChild();i!==null&&i.insertBefore(r)}}else if(Ze(s)){const o=s.getFirstChild();Q(o)&&o.append(r)}else if(Q(t)){const o=Fe(),i=Te(t.getListType());o.append(i),i.append(r),s?s.insertAfter(o):n?n.insertBefore(o):t.append(o)}}function Ud(r){if(Ze(r))return;const e=r.getParent(),t=e?e.getParent():void 0;if(Q(t?t.getParent():void 0)&&ne(t)&&Q(e)){const n=e?e.getFirstChild():void 0,s=e?e.getLastChild():void 0;if(r.is(n))t.insertBefore(r),e.isEmpty()&&t.remove();else if(r.is(s))t.insertAfter(r),e.isEmpty()&&t.remove();else{const o=e.getListType(),i=Fe(),l=Te(o);i.append(l),r.getPreviousSiblings().forEach(c=>l.append(c));const u=Fe(),a=Te(o);u.append(a),Ot(a,r.getNextSiblings()),t.insertBefore(i),t.insertAfter(u),t.replace(r)}}}function Wd(){const r=q();if(!P(r)||!r.isCollapsed())return!1;const e=r.anchor.getNode();if(!ne(e)||e.getChildrenSize()!==0)return!1;const t=Gs(e),n=e.getParent();Q(n)||Xe(40);const s=n.getParent();let o;if(tt(s))o=fe(),t.insertAfter(o);else{if(!ne(s))return!1;o=Fe(),s.insertAfter(o)}o.select();const i=e.getNextSiblings();if(i.length>0){const l=Te(n.getListType());if(rr(o))o.insertAfter(l);else{const u=Fe();u.append(l),o.insertAfter(u)}i.forEach(u=>{u.remove(),l.append(u)})}return function(l){let u=l;for(;u.getNextSibling()==null&&u.getPreviousSibling()==null;){const a=u.getParent();if(a==null||!ne(u)&&!Q(u))break;u=a}u.remove()}(e),!0}function jn(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}class Rt extends ft{static getType(){return"listitem"}static clone(e){return new Rt(e.__value,e.__checked,e.__key)}constructor(e,t,n){super(n),this.__value=e===void 0?1:e,this.__checked=t}createDOM(e){const t=document.createElement("li"),n=this.getParent();return Q(n)&&n.getListType()==="check"&&Go(t,this,null),t.value=this.__value,Vo(t,e.theme,this),t}updateDOM(e,t,n){const s=this.getParent();return Q(s)&&s.getListType()==="check"&&Go(t,this,e),t.value=this.__value,Vo(t,n.theme,this),!1}static transform(){return e=>{if(ne(e)||Xe(144),e.__checked==null)return;const t=e.getParent();Q(t)&&t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:Kd,priority:0})}}static importJSON(e){const t=Fe();return t.setChecked(e.checked),t.setValue(e.value),t.setFormat(e.format),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config);return t.style.textAlign=this.getFormatType(),{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(),version:1}}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(B(n)&&this.canMergeWith(n)){const s=n.getChildren();this.append(...s),n.remove()}else super.append(n)}return this}replace(e,t){if(ne(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!Q(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{const s=Te(n.getListType());let o=this.getNextSibling();for(;o;){const i=o;o=o.getNextSibling(),s.append(i)}n.insertAfter(e),e.insertAfter(s)}return t&&(B(e)||Xe(139),this.getChildren().forEach(s=>{e.append(s)})),this.remove(),n.getChildrenSize()===0&&n.remove(),e}insertAfter(e,t=!0){const n=this.getParentOrThrow();if(Q(n)||Xe(39),ne(e))return super.insertAfter(e,t);const s=this.getNextSiblings();if(n.insertAfter(e,t),s.length!==0){const o=Te(n.getListType());s.forEach(i=>o.append(i)),e.insertAfter(o,t)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&Ze(t)&&Ze(n)&&(Di(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){const n=Fe(this.__checked==null&&void 0);return this.insertAfter(n,t),n}collapseAtStart(e){const t=fe();this.getChildren().forEach(i=>t.append(i));const n=this.getParentOrThrow(),s=n.getParentOrThrow(),o=ne(s);if(n.getChildrenSize()===1)if(o)n.remove(),s.select();else{n.insertBefore(t),n.remove();const i=e.anchor,l=e.focus,u=t.getKey();i.type==="element"&&i.getNode().is(this)&&i.set(u,i.offset,"element"),l.type==="element"&&l.getNode().is(this)&&l.set(u,l.offset,"element")}else n.insertBefore(t),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){this.getWritable().__value=e}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return Q(n)&&(t=n.getListType()),t==="check"?!!e.__checked:void 0}setChecked(e){this.getWritable().__checked=e}toggleChecked(){this.setChecked(!this.__checked)}getIndent(){const e=this.getParent();if(e===null)return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;ne(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){typeof e!="number"&&Xe(117),(e=Math.floor(e))>=0||Xe(199);let t=this.getIndent();for(;t!==e;)t<e?(qd(this),t++):(Ud(this),t--);return this}canInsertAfter(e){return ne(e)}canReplaceWith(e){return ne(e)}canMergeWith(e){return rr(e)||ne(e)}extractWithChild(e,t){if(!P(t))return!1;const n=t.anchor.getNode(),s=t.focus.getNode();return this.isParentOf(n)&&this.isParentOf(s)&&this.getTextContent().length===t.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return Te("bullet")}canMergeWhenEmpty(){return!0}}function Vo(r,e,t){const n=[],s=[],o=e.list,i=o?o.listitem:void 0;let l;if(o&&o.nested&&(l=o.nested.listitem),i!==void 0&&n.push(...jn(i)),o){const u=t.getParent(),a=Q(u)&&u.getListType()==="check",c=t.getChecked();a&&!c||s.push(o.listitemUnchecked),a&&c||s.push(o.listitemChecked),a&&n.push(c?o.listitemChecked:o.listitemUnchecked)}if(l!==void 0){const u=jn(l);t.getChildren().some(a=>Q(a))?n.push(...u):s.push(...u)}s.length>0&&hu(r,...s),n.length>0&&Hr(r,...n)}function Go(r,e,t,n){Q(e.getFirstChild())?(r.removeAttribute("role"),r.removeAttribute("tabIndex"),r.removeAttribute("aria-checked")):(r.setAttribute("role","checkbox"),r.setAttribute("tabIndex","-1"),t&&e.__checked===t.__checked||r.setAttribute("aria-checked",e.getChecked()?"true":"false"))}function Kd(r){if(r.classList.contains("task-list-item")){for(const t of r.children)if(t.tagName==="INPUT")return Vd(t)}const e=r.getAttribute("aria-checked");return{node:Fe(e==="true"||e!=="false"&&void 0)}}function Vd(r){return r.getAttribute("type")!=="checkbox"?{node:null}:{node:Fe(r.hasAttribute("checked"))}}function Fe(r){return st(new Rt(void 0,r))}function ne(r){return r instanceof Rt}class or extends ft{static getType(){return"list"}static clone(e){const t=e.__listType||Qo[e.__tag];return new or(t,e.__start,e.__key)}constructor(e,t,n){super(n);const s=Qo[e]||e;this.__listType=s,this.__tag=s==="number"?"ol":"ul",this.__start=t}getTag(){return this.__tag}setListType(e){const t=this.getWritable();t.__listType=e,t.__tag=e==="number"?"ol":"ul"}getListType(){return this.__listType}getStart(){return this.__start}createDOM(e,t){const n=this.__tag,s=document.createElement(n);return this.__start!==1&&s.setAttribute("start",String(this.__start)),s.__lexicalListType=this.__listType,Ho(s,e.theme,this),s}updateDOM(e,t,n){return e.__tag!==this.__tag||(Ho(t,n.theme,this),!1)}static transform(){return e=>{Q(e)||Xe(163),function(t){const n=t.getNextSibling();Q(n)&&t.getListType()===n.getListType()&&Di(t,n)}(e),function(t){const n=t.getListType()!=="check";let s=t.getStart();for(const o of t.getChildren())ne(o)&&(o.getValue()!==s&&o.setValue(s),n&&o.getLatest().__checked!=null&&o.setChecked(void 0),Q(o.getFirstChild())||s++)}(e)}}static importDOM(){return{ol:()=>({conversion:Jo,priority:0}),ul:()=>({conversion:Jo,priority:0})}}static importJSON(e){const t=Te(e.listType,e.start);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config,e);return t&&ct(t)&&(this.__start!==1&&t.setAttribute("start",String(this.__start)),this.__listType==="check"&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag(),type:"list",version:1}}canBeEmpty(){return!1}canIndent(){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(ne(n))super.append(n);else{const s=Fe();if(Q(n))s.append(n);else if(B(n))if(n.isInline())s.append(n);else{const o=pe(n.getTextContent());s.append(o)}else s.append(n);super.append(s)}}return this}extractWithChild(e){return ne(e)}}function Ho(r,e,t){const n=[],s=[],o=e.list;if(o!==void 0){const i=o[`${t.__tag}Depth`]||[],l=Id(t)-1,u=l%i.length,a=i[u],c=o[t.__tag];let f;const d=o.nested,h=o.checklist;if(d!==void 0&&d.list&&(f=d.list),c!==void 0&&n.push(c),h!==void 0&&t.__listType==="check"&&n.push(h),a!==void 0){n.push(...jn(a));for(let p=0;p<i.length;p++)p!==u&&s.push(t.__tag+p)}if(f!==void 0){const p=jn(f);l>1?n.push(...p):s.push(...p)}}s.length>0&&hu(r,...s),n.length>0&&Hr(r,...n)}function Gd(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t];if(ne(n)){e.push(n);const s=n.getChildren();s.length>1&&s.forEach(o=>{Q(o)&&e.push(Uo(o))})}else e.push(Uo(n))}return e}function Jo(r){const e=r.nodeName.toLowerCase();let t=null;return e==="ol"?t=Te("number",r.start):e==="ul"&&(t=function(n){if(n.getAttribute("__lexicallisttype")==="check"||n.classList.contains("contains-task-list"))return!0;for(const s of n.childNodes)if(ct(s)&&s.hasAttribute("aria-checked"))return!0;return!1}(r)?Te("check"):Te("bullet")),{after:Gd,node:t}}const Qo={ol:"number",ul:"bullet"};function Te(r,e=1){return st(new or(r,e))}function Q(r){return r instanceof or}const Du=Mr(),wu=Mr(),Hd=Mr();function Jd(r){return Mt(r.registerCommand(wu,()=>(Wo(r,"number"),!0),Jt),r.registerCommand(Du,()=>(Wo(r,"bullet"),!0),Jt),r.registerCommand(Hd,()=>(zd(r),!0),Jt),r.registerCommand(Br,()=>!!Wd(),Jt))}function Qd(){const[r]=nt();return k.useEffect(()=>{if(!r.hasNodes([or,Rt]))throw new Error("ListPlugin: ListNode and/or ListItemNode not registered on editor")},[r]),function(e){k.useEffect(()=>Jd(e),[e])}(r),null}const Yd=new Set(["http:","https:","mailto:","sms:","tel:"]);class $t extends ft{static getType(){return"link"}static clone(e){return new $t(e.__url,{rel:e.__rel,target:e.__target,title:e.__title},e.__key)}constructor(e,t={},n){super(n);const{target:s=null,rel:o=null,title:i=null}=t;this.__url=e,this.__target=s,this.__rel=o,this.__title=i}createDOM(e){const t=document.createElement("a");return t.href=this.sanitizeUrl(this.__url),this.__target!==null&&(t.target=this.__target),this.__rel!==null&&(t.rel=this.__rel),this.__title!==null&&(t.title=this.__title),Hr(t,e.theme.link),t}updateDOM(e,t,n){if(t instanceof HTMLAnchorElement){const s=this.__url,o=this.__target,i=this.__rel,l=this.__title;s!==e.__url&&(t.href=s),o!==e.__target&&(o?t.target=o:t.removeAttribute("target")),i!==e.__rel&&(i?t.rel=i:t.removeAttribute("rel")),l!==e.__title&&(l?t.title=l:t.removeAttribute("title"))}return!1}static importDOM(){return{a:e=>({conversion:Xd,priority:1})}}static importJSON(e){const t=Pn(e.url,{rel:e.rel,target:e.target,title:e.title});return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}sanitizeUrl(e){try{const t=new URL(e);if(!Yd.has(t.protocol))return"about:blank"}catch{return e}return e}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),type:"link",url:this.getURL(),version:1}}getURL(){return this.getLatest().__url}setURL(e){this.getWritable().__url=e}getTarget(){return this.getLatest().__target}setTarget(e){this.getWritable().__target=e}getRel(){return this.getLatest().__rel}setRel(e){this.getWritable().__rel=e}getTitle(){return this.getLatest().__title}setTitle(e){this.getWritable().__title=e}insertNewAfter(e,t=!0){const n=Pn(this.__url,{rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(n,t),n}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,t,n){if(!P(t))return!1;const s=t.anchor.getNode(),o=t.focus.getNode();return this.isParentOf(s)&&this.isParentOf(o)&&t.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}}function Xd(r){let e=null;if(ac(r)){const t=r.textContent;(t!==null&&t!==""||r.children.length>0)&&(e=Pn(r.getAttribute("href")||"",{rel:r.getAttribute("rel"),target:r.getAttribute("target"),title:r.getAttribute("title")}))}return{node:e}}function Pn(r,e){return st(new $t(r,e))}function mr(r){return r instanceof $t}class Jr extends $t{constructor(e,t={},n){super(e,t,n),this.__isUnlinked=t.isUnlinked!==void 0&&t.isUnlinked!==null&&t.isUnlinked}static getType(){return"autolink"}static clone(e){return new Jr(e.__url,{isUnlinked:e.__isUnlinked,rel:e.__rel,target:e.__target,title:e.__title},e.__key)}getIsUnlinked(){return this.__isUnlinked}setIsUnlinked(e){const t=this.getWritable();return t.__isUnlinked=e,t}createDOM(e){return this.__isUnlinked?document.createElement("span"):super.createDOM(e)}updateDOM(e,t,n){return super.updateDOM(e,t,n)||e.__isUnlinked!==this.__isUnlinked}static importJSON(e){const t=Yo(e.url,{isUnlinked:e.isUnlinked,rel:e.rel,target:e.target,title:e.title});return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}static importDOM(){return null}exportJSON(){return{...super.exportJSON(),isUnlinked:this.__isUnlinked,type:"autolink",version:1}}insertNewAfter(e,t=!0){const n=this.getParentOrThrow().insertNewAfter(e,t);if(B(n)){const s=Yo(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return n.append(s),s}return null}}function Yo(r,e){return st(new Jr(r,e))}function Zd(r){return r instanceof Jr}const Xo=Mr();function Ds(r,e={}){const{target:t,title:n}=e,s=e.rel===void 0?"noreferrer":e.rel,o=q();if(!P(o))return;const i=o.extract();if(r===null)i.forEach(l=>{const u=Qn(l,a=>!Zd(a)&&mr(a));if(u){const a=u.getChildren();for(let c=0;c<a.length;c++)u.insertBefore(a[c]);u.remove()}});else{if(i.length===1){const a=function(c,f){let d=c;for(;d!==null&&d.getParent()!==null&&!f(d);)d=d.getParentOrThrow();return f(d)?d:null}(i[0],mr);if(a!==null)return a.setURL(r),t!==void 0&&a.setTarget(t),s!==null&&a.setRel(s),void(n!==void 0&&a.setTitle(n))}let l=null,u=null;i.forEach(a=>{const c=a.getParent();if(c!==u&&c!==null&&(!B(a)||a.isInline())){if(mr(c))return u=c,c.setURL(r),t!==void 0&&c.setTarget(t),s!==null&&u.setRel(s),void(n!==void 0&&u.setTitle(n));if(c.is(l)||(l=c,u=Pn(r,{rel:s,target:t,title:n}),mr(c)?a.getPreviousSibling()===null?c.insertBefore(u):c.insertAfter(u):a.insertBefore(u)),mr(a)){if(a.is(u))return;if(u!==null){const f=a.getChildren();for(let d=0;d<f.length;d++)u.append(f[d])}a.remove()}else u!==null&&u.append(a)}})}}function ef({validateUrl:r,attributes:e}){const[t]=nt();return k.useEffect(()=>{if(!t.hasNodes([$t]))throw new Error("LinkPlugin: LinkNode not registered on editor");return Mt(t.registerCommand(Xo,n=>{if(n===null)return Ds(n),!0;if(typeof n=="string")return!(r!==void 0&&!r(n))&&(Ds(n,e),!0);{const{url:s,target:o,rel:i,title:l}=n;return Ds(s,{...e,rel:i,target:o,title:l}),!0}},Jt),r!==void 0?t.registerCommand(Mn,n=>{const s=q();if(!P(s)||s.isCollapsed()||!_t(n,ClipboardEvent))return!1;const o=n;if(o.clipboardData===null)return!1;const i=o.clipboardData.getData("text");return!!r(i)&&!s.getNodes().some(l=>B(l))&&(t.dispatchCommand(Xo,{...e,url:i}),n.preventDefault(),!0)},Jt):()=>{})},[t,r,e]),null}const tf={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",toolbarBackground:"#f9fafb",quoteBorder:"#d1d5db",quoteBackground:"#f3f4f6"},rf={paragraph:"mail-editor-paragraph",text:{bold:"mail-editor-bold",italic:"mail-editor-italic",underline:"mail-editor-underline"},list:{ul:"mail-editor-ul",ol:"mail-editor-ol",listitem:"mail-editor-li"},link:"mail-editor-link",quote:"mail-editor-quote",heading:{h1:"mail-editor-h1",h2:"mail-editor-h2",h3:"mail-editor-h3"}};function nf({theme:r,disabled:e}){const[t]=nt(),n=k.useCallback(()=>{t.dispatchCommand(We,"bold")},[t]),s=k.useCallback(()=>{t.dispatchCommand(We,"italic")},[t]),o=k.useCallback(()=>{t.dispatchCommand(We,"underline")},[t]),i=k.useCallback(()=>{t.dispatchCommand(Du,void 0)},[t]),l=k.useCallback(()=>{t.dispatchCommand(wu,void 0)},[t]),u=k.useCallback(()=>{t.update(()=>{const f=q();P(f)&&Jc(f,()=>Ci())})},[t]),a={display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",border:"none",background:"transparent",borderRadius:"4px",cursor:e?"not-allowed":"pointer",color:e?r.textSecondary:r.text,fontSize:"14px",fontWeight:600,opacity:e?.5:1},c=`
|
|
73
|
+
`?u.insertParagraph():a===" "?u.insertNodes([Wr()]):u.insertText(a)}}}else e.insertRawText(o)}function Bo(r,e,t){r.dispatchCommand(ba,{nodes:e,selection:t})||t.insertNodes(e)}function _u(r,e,t,n=[]){let s=e===null||t.isSelected(e);const o=B(t)&&t.excludeFromCopy("html");let i=t;if(e!==null){let a=gi(t);a=M(a)&&e!==null?cu(e,a):a,i=a}const l=B(i)?i.getChildren():[],u=function(a){const c=a.exportJSON(),f=a.constructor;if(c.type!==f.getType()&&Ln(58,f.name),B(a)){const d=c.children;Array.isArray(d)||Ln(59,f.name)}return c}(i);if(M(i)){const a=i.__text;a.length>0?u.text=a:s=!1}for(let a=0;a<l.length;a++){const c=l[a],f=_u(r,e,c,u.children);!s&&B(t)&&f&&t.extractWithChild(c,e,"clone")&&(s=!0)}if(s&&!o)n.push(u);else if(Array.isArray(u.children))for(let a=0;a<u.children.length;a++){const c=u.children[a];n.push(c)}return s}function ud(r,e){const t=[],n=ie().getChildren();for(let s=0;s<n.length;s++)_u(r,e,n[s],t);return{namespace:r._config.namespace,nodes:t}}function ad(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t],s=Bc(n);M(s)&&Hc(s),e.push(s)}return e}let Kt=null;async function No(r,e,t){if(Kt!==null)return!1;if(e!==null)return new Promise((u,a)=>{r.update(()=>{u(Fo(r,e,t))})});const n=r.getRootElement(),s=r._window==null?window.document:r._window.document,o=Oe(r._window);if(n===null||o===null)return!1;const i=s.createElement("span");i.style.cssText="position: fixed; top: -1000px;",i.append(s.createTextNode("#")),n.append(i);const l=new Range;return l.setStart(i,0),l.setEnd(i,1),o.removeAllRanges(),o.addRange(l),new Promise((u,a)=>{const c=r.registerCommand(Rn,f=>(_t(f,ClipboardEvent)&&(c(),Kt!==null&&(window.clearTimeout(Kt),Kt=null),u(Fo(r,f,t))),!0),Lc);Kt=window.setTimeout(()=>{c(),Kt=null,u(!1)},50),s.execCommand("copy"),i.remove()})}function Fo(r,e,t){if(t===void 0){const s=Oe(r._window);if(!s)return!1;const o=s.anchorNode,i=s.focusNode;if(o!==null&&i!==null&&!Ir(r,o,i))return!1;const l=q();if(l===null)return!1;t=dd(l)}e.preventDefault();const n=e.clipboardData;return n!==null&&(fd(n,t),!0)}const cd=[["text/html",od],["application/x-lexical-editor",ld]];function dd(r=q()){const e={"text/plain":r?r.getTextContent():""};if(r){const t=cc();for(const[n,s]of cd){const o=s(t,r);o!==null&&(e[n]=o)}}return e}function fd(r,e){for(const t in e){const n=e[t];n!==void 0&&r.setData(t,n)}}function Lo(r,e){if(document.caretRangeFromPoint!==void 0){const t=document.caretRangeFromPoint(r,e);return t===null?null:{node:t.startContainer,offset:t.startOffset}}if(document.caretPositionFromPoint!=="undefined"){const t=document.caretPositionFromPoint(r,e);return t===null?null:{node:t.offsetNode,offset:t.offset}}return null}const ir=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,hd=ir&&"documentMode"in document?document.documentMode:null,pd=!(!ir||!("InputEvent"in window)||hd)&&"getTargetRanges"in new window.InputEvent("input"),gd=ir&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),jo=ir&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,md=ir&&/^(?=.*Chrome).*/i.test(navigator.userAgent),yd=ir&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!md,Po=Mr();class Yn extends ft{static getType(){return"quote"}static clone(e){return new Yn(e.__key)}constructor(e){super(e)}createDOM(e){const t=document.createElement("blockquote");return Hr(t,e.theme.quote),t}updateDOM(e,t){return!1}static importDOM(){return{blockquote:e=>({conversion:xd,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&ct(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=Di();return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),type:"quote"}}insertNewAfter(e,t){const n=fe(),s=this.getDirection();return n.setDirection(s),this.insertAfter(n,t),n}collapseAtStart(){const e=fe();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}canMergeWhenEmpty(){return!0}}function Di(){return st(new Yn)}class Xn extends ft{static getType(){return"heading"}static clone(e){return new Xn(e.__tag,e.__key)}constructor(e,t){super(t),this.__tag=e}getTag(){return this.__tag}createDOM(e){const t=this.__tag,n=document.createElement(t),s=e.theme.heading;if(s!==void 0){const o=s[t];Hr(n,o)}return n}updateDOM(e,t){return!1}static importDOM(){return{h1:e=>({conversion:Vt,priority:0}),h2:e=>({conversion:Vt,priority:0}),h3:e=>({conversion:Vt,priority:0}),h4:e=>({conversion:Vt,priority:0}),h5:e=>({conversion:Vt,priority:0}),h6:e=>({conversion:Vt,priority:0}),p:e=>{const t=e.firstChild;return t!==null&&Oo(t)?{conversion:()=>({node:null}),priority:3}:null},span:e=>Oo(e)?{conversion:t=>({node:br("h1")}),priority:3}:null}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&ct(t)){this.isEmpty()&&t.append(document.createElement("br"));const n=this.getFormatType();t.style.textAlign=n;const s=this.getDirection();s&&(t.dir=s)}return{element:t}}static importJSON(e){const t=br(e.tag);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportJSON(){return{...super.exportJSON(),tag:this.getTag(),type:"heading",version:1}}insertNewAfter(e,t=!0){const n=e?e.anchor.offset:0,s=this.getLastDescendant(),o=!s||e&&e.anchor.key===s.getKey()&&n===s.getTextContentSize()||!e?fe():br(this.getTag()),i=this.getDirection();if(o.setDirection(i),this.insertAfter(o,t),n===0&&!this.isEmpty()&&e){const l=fe();l.select(),this.replace(l,!0)}return o}collapseAtStart(){const e=this.isEmpty()?fe():br(this.getTag());return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}extractWithChild(){return!0}}function Oo(r){return r.nodeName.toLowerCase()==="span"&&r.style.fontSize==="26pt"}function Vt(r){const e=r.nodeName.toLowerCase();let t=null;return e!=="h1"&&e!=="h2"&&e!=="h3"&&e!=="h4"&&e!=="h5"&&e!=="h6"||(t=br(e),r.style!==null&&(mi(r,t),t.setFormat(r.style.textAlign))),{node:t}}function xd(r){const e=Di();return r.style!==null&&(e.setFormat(r.style.textAlign),mi(r,e)),{node:e}}function br(r){return st(new Xn(r))}function an(r){let e=null;if(_t(r,DragEvent)?e=r.dataTransfer:_t(r,ClipboardEvent)&&(e=r.clipboardData),e===null)return[!1,[],!1];const t=e.types,n=t.includes("Files"),s=t.includes("text/html")||t.includes("text/plain");return[n,Array.from(e.files),s]}function Mo(r){const e=q();if(!P(e))return!1;const t=new Set,n=e.getNodes();for(let s=0;s<n.length;s++){const o=n[s],i=o.getKey();if(t.has(i))continue;const l=Qn(o,a=>B(a)&&!a.isInline());if(l===null)continue;const u=l.getKey();l.canIndent()&&!t.has(u)&&(t.add(u),r(l))}return t.size>0}function cn(r){const e=tr(r);return Z(e)}function _d(r){return Mt(r.registerCommand(ol,e=>{const t=q();return!!Ye(t)&&(t.clear(),!0)},0),r.registerCommand(Tt,e=>{const t=q();return!!P(t)&&(t.deleteCharacter(e),!0)},Y),r.registerCommand(Nr,e=>{const t=q();return!!P(t)&&(t.deleteWord(e),!0)},Y),r.registerCommand(Fr,e=>{const t=q();return!!P(t)&&(t.deleteLine(e),!0)},Y),r.registerCommand(Yt,e=>{const t=q();if(typeof e=="string")t!==null&&t.insertText(e);else{if(t===null)return!1;const n=e.dataTransfer;if(n!=null)To(n,t,r);else if(P(t)){const s=e.data;return s&&t.insertText(s),!0}}return!0},Y),r.registerCommand(As,()=>{const e=q();return!!P(e)&&(e.removeText(),!0)},Y),r.registerCommand(We,e=>{const t=q();return!!P(t)&&(t.formatText(e),!0)},Y),r.registerCommand(Sa,e=>{const t=q();if(!P(t)&&!Ye(t))return!1;const n=t.getNodes();for(const s of n){const o=Qn(s,i=>B(i)&&!i.isInline());o!==null&&o.setFormat(e)}return!0},Y),r.registerCommand(Qt,e=>{const t=q();return!!P(t)&&(t.insertLineBreak(e),!0)},Y),r.registerCommand(Br,()=>{const e=q();return!!P(e)&&(e.insertParagraph(),!0)},Y),r.registerCommand(Aa,()=>(Zl([Wr()]),!0),Y),r.registerCommand(ka,()=>Mo(e=>{const t=e.getIndent();e.setIndent(t+1)}),Y),r.registerCommand(zi,()=>Mo(e=>{const t=e.getIndent();t>0&&e.setIndent(t-1)}),Y),r.registerCommand(al,e=>{const t=q();if(Ye(t)&&!cn(e.target)){const n=t.getNodes();if(n.length>0)return n[0].selectPrevious(),!0}else if(P(t)){const n=Lr(t.focus,!0);if(!e.shiftKey&&Z(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),e.preventDefault(),!0}return!1},Y),r.registerCommand(cl,e=>{const t=q();if(Ye(t)){const n=t.getNodes();if(n.length>0)return n[0].selectNext(0,0),!0}else if(P(t)){if(function(s){const o=s.focus;return o.key==="root"&&o.offset===ie().getChildrenSize()}(t))return e.preventDefault(),!0;const n=Lr(t.focus,!1);if(!e.shiftKey&&Z(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),e.preventDefault(),!0}return!1},Y),r.registerCommand(ul,e=>{const t=q();if(Ye(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectPrevious(),!0}if(!P(t))return!1;if(Ao(t,!0)){const n=e.shiftKey;return e.preventDefault(),ko(t,n,!0),!0}return!1},Y),r.registerCommand(ll,e=>{const t=q();if(Ye(t)&&!cn(e.target)){const s=t.getNodes();if(s.length>0)return e.preventDefault(),s[0].selectNext(0,0),!0}if(!P(t))return!1;const n=e.shiftKey;return!!Ao(t,!1)&&(e.preventDefault(),ko(t,n,!1),!0)},Y),r.registerCommand(dl,e=>{if(cn(e.target))return!1;const t=q();if(!P(t))return!1;const{anchor:n}=t,s=n.getNode();return t.isCollapsed()&&n.offset===0&&!De(s)&&rd(s).getIndent()>0?(e.preventDefault(),r.dispatchCommand(zi,void 0)):(!jo||navigator.language!=="ko-KR")&&(e.preventDefault(),r.dispatchCommand(Tt,!0))},Y),r.registerCommand(hl,e=>{if(cn(e.target))return!1;const t=q();return!!P(t)&&(e.preventDefault(),r.dispatchCommand(Tt,!1))},Y),r.registerCommand(yn,e=>{const t=q();if(!P(t))return!1;if(e!==null){if((jo||gd||yd)&&pd)return!1;if(e.preventDefault(),e.shiftKey)return r.dispatchCommand(Qt,!1)}return r.dispatchCommand(Br,void 0)},Y),r.registerCommand(fl,()=>{const e=q();return!!P(e)&&(r.blur(),!0)},Y),r.registerCommand(pl,e=>{const[,t]=an(e);if(t.length>0){const s=Lo(e.clientX,e.clientY);if(s!==null){const{offset:o,node:i}=s,l=tr(i);if(l!==null){const u=Ac();if(M(l))u.anchor.set(l.getKey(),o,"text"),u.focus.set(l.getKey(),o,"text");else{const c=l.getParentOrThrow().getKey(),f=l.getIndexWithinParent()+1;u.anchor.set(c,f,"element"),u.focus.set(c,f,"element")}const a=wl(u);et(a)}r.dispatchCommand(Po,t)}return e.preventDefault(),!0}const n=q();return!!P(n)},Y),r.registerCommand(gl,e=>{const[t]=an(e),n=q();return!(t&&!P(n))},Y),r.registerCommand(ml,e=>{const[t]=an(e),n=q();if(t&&!P(n))return!1;const s=Lo(e.clientX,e.clientY);if(s!==null){const o=tr(s.node);Z(o)&&e.preventDefault()}return!0},Y),r.registerCommand(ks,()=>(oc(),!0),Y),r.registerCommand(Rn,e=>(No(r,_t(e,ClipboardEvent)?e:null),!0),Y),r.registerCommand(Xs,e=>(async function(t,n){await No(n,_t(t,ClipboardEvent)?t:null),n.update(()=>{const s=q();P(s)?s.removeText():Ye(s)&&s.getNodes().forEach(o=>o.remove())})}(e,r),!0),Y),r.registerCommand(Mn,e=>{const[,t,n]=an(e);return t.length>0&&!n?(r.dispatchCommand(Po,t),!0):ui(e.target)?!1:q()!==null&&(function(s,o){s.preventDefault(),o.update(()=>{const i=q(),l=_t(s,InputEvent)||_t(s,KeyboardEvent)?null:s.clipboardData;l!=null&&i!==null&&To(l,i,o)},{tag:"paste"})}(e,r),!0)},Y))}const Us=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?k.useLayoutEffect:k.useEffect;function Ro(r){return r.getEditorState().read(au(r.isComposing()))}function bd({contentEditable:r,placeholder:e=null,ErrorBoundary:t}){const[n]=nt(),s=function(o,i){const[l,u]=k.useState(()=>o.getDecorators());return Us(()=>o.registerDecoratorListener(a=>{Ni.flushSync(()=>{u(a)})}),[o]),k.useEffect(()=>{u(o.getDecorators())},[o]),k.useMemo(()=>{const a=[],c=Object.keys(l);for(let f=0;f<c.length;f++){const d=c[f],h=g.jsx(i,{onError:m=>o._onError(m),children:g.jsx(k.Suspense,{fallback:null,children:l[d]})}),p=o.getElementByKey(d);p!==null&&a.push(Ni.createPortal(h,p,d))}return a},[i,l,o])}(n,t);return function(o){Us(()=>Mt(_d(o),nd(o)),[o])}(n),g.jsxs(g.Fragment,{children:[r,g.jsx(vd,{content:e}),s]})}function vd({content:r}){const[e]=nt(),t=function(s){const[o,i]=k.useState(()=>Ro(s));return Us(()=>{function l(){const u=Ro(s);i(u)}return l(),Mt(s.registerUpdateListener(()=>{l()}),s.registerEditableListener(()=>{l()}))},[s]),o}(e),n=$c();return t?typeof r=="function"?r(n):r:null}const bu=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?k.useLayoutEffect:k.useEffect;function Dd({editor:r,ariaActiveDescendant:e,ariaAutoComplete:t,ariaControls:n,ariaDescribedBy:s,ariaErrorMessage:o,ariaExpanded:i,ariaInvalid:l,ariaLabel:u,ariaLabelledBy:a,ariaMultiline:c,ariaOwns:f,ariaRequired:d,autoCapitalize:h,className:p,id:m,role:x="textbox",spellCheck:C=!0,style:_,tabIndex:E,"data-testid":D,...A},v){const[b,w]=k.useState(r.isEditable()),S=k.useCallback(T=>{T&&T.ownerDocument&&T.ownerDocument.defaultView?r.setRootElement(T):r.setRootElement(null)},[r]),R=k.useMemo(()=>function(...T){return N=>{T.forEach(j=>{typeof j=="function"?j(N):j!=null&&(j.current=N)})}}(v,S),[S,v]);return bu(()=>(w(r.isEditable()),r.registerEditableListener(T=>{w(T)})),[r]),g.jsx("div",{"aria-activedescendant":b?e:void 0,"aria-autocomplete":b?t:"none","aria-controls":b?n:void 0,"aria-describedby":s,...o!=null?{"aria-errormessage":o}:{},"aria-expanded":b&&x==="combobox"?!!i:void 0,...l!=null?{"aria-invalid":l}:{},"aria-label":u,"aria-labelledby":a,"aria-multiline":c,"aria-owns":b?f:void 0,"aria-readonly":!b||void 0,"aria-required":d,autoCapitalize:h,className:p,contentEditable:b,"data-testid":D,id:m,ref:R,role:b?x:void 0,spellCheck:C,style:_,tabIndex:E,...A})}const Cd=k.forwardRef(Dd);function $o(r){return r.getEditorState().read(au(r.isComposing()))}const wd=k.forwardRef(Ed);function Ed(r,e){const{placeholder:t,...n}=r,[s]=nt();return g.jsxs(g.Fragment,{children:[g.jsx(Cd,{editor:s,...n,ref:e}),t!=null&&g.jsx(Ad,{editor:s,content:t})]})}function Ad({content:r,editor:e}){const t=function(i){const[l,u]=k.useState(()=>$o(i));return bu(()=>{function a(){const c=$o(i);u(c)}return a(),Mt(i.registerUpdateListener(()=>{a()}),i.registerEditableListener(()=>{a()}))},[i]),l}(e),[n,s]=k.useState(e.isEditable());if(k.useLayoutEffect(()=>(s(e.isEditable()),e.registerEditableListener(i=>{s(i)})),[e]),!t)return null;let o=null;return typeof r=="function"?o=r(n):r!==null&&(o=r),o===null?null:g.jsx("div",{"aria-hidden":!0,children:o})}const dn=0,Ws=1,Ks=2,Ue=0,kd=1,Io=2,Sd=3,Td=4;function Bd(r,e,t,n,s){if(r===null||t.size===0&&n.size===0&&!s)return Ue;const o=e._selection,i=r._selection;if(s)return kd;if(!(P(o)&&P(i)&&i.isCollapsed()&&o.isCollapsed()))return Ue;const l=function(C,_,E){const D=C._nodeMap,A=[];for(const v of _){const b=D.get(v);b!==void 0&&A.push(b)}for(const[v,b]of E){if(!b)continue;const w=D.get(v);w===void 0||De(w)||A.push(w)}return A}(e,t,n);if(l.length===0)return Ue;if(l.length>1){const C=e._nodeMap,_=C.get(o.anchor.key),E=C.get(i.anchor.key);return _&&E&&!r._nodeMap.has(_.__key)&&M(_)&&_.__text.length===1&&o.anchor.offset===1?Io:Ue}const u=l[0],a=r._nodeMap.get(u.__key);if(!M(a)||!M(u)||a.__mode!==u.__mode)return Ue;const c=a.__text,f=u.__text;if(c===f)return Ue;const d=o.anchor,h=i.anchor;if(d.key!==h.key||d.type!=="text")return Ue;const p=d.offset,m=h.offset,x=f.length-c.length;return x===1&&m===p-1?Io:x===-1&&m===p+1?Sd:x===-1&&m===p?Td:Ue}function Nd(r,e){let t=Date.now(),n=Ue;return(s,o,i,l,u,a)=>{const c=Date.now();if(a.has("historic"))return n=Ue,t=c,Ks;const f=Bd(s,o,l,u,r.isComposing()),d=(()=>{const h=i===null||i.editor===r,p=a.has("history-push");if(!p&&h&&a.has("history-merge"))return dn;if(s===null)return Ws;const m=o._selection;return l.size>0||u.size>0?p===!1&&f!==Ue&&f===n&&c<t+e&&h||l.size===1&&function(x,C,_){const E=C._nodeMap.get(x),D=_._nodeMap.get(x),A=C._selection,v=_._selection;return!(P(A)&&P(v)&&A.anchor.type==="element"&&A.focus.type==="element"&&v.anchor.type==="text"&&v.focus.type==="text"||!M(E)||!M(D)||E.__parent!==D.__parent)&&JSON.stringify(C.read(()=>E.exportJSON()))===JSON.stringify(_.read(()=>D.exportJSON()))}(Array.from(l)[0],s,o)?dn:Ws:m!==null?dn:Ks})();return t=c,n=f,d}}function zo(r){r.undoStack=[],r.redoStack=[],r.current=null}function Fd(r,e,t){const n=Nd(r,t);return Mt(r.registerCommand(Qs,()=>(function(o,i){const l=i.redoStack,u=i.undoStack;if(u.length!==0){const a=i.current,c=u.pop();a!==null&&(l.push(a),o.dispatchCommand(nn,!0)),u.length===0&&o.dispatchCommand(sn,!1),i.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),Y),r.registerCommand(Ys,()=>(function(o,i){const l=i.redoStack,u=i.undoStack;if(l.length!==0){const a=i.current;a!==null&&(u.push(a),o.dispatchCommand(sn,!0));const c=l.pop();l.length===0&&o.dispatchCommand(nn,!1),i.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),Y),r.registerCommand(Ba,()=>(zo(e),!1),Y),r.registerCommand(Na,()=>(zo(e),r.dispatchCommand(nn,!1),r.dispatchCommand(sn,!1),!0),Y),r.registerUpdateListener(({editorState:o,prevEditorState:i,dirtyLeaves:l,dirtyElements:u,tags:a})=>{const c=e.current,f=e.redoStack,d=e.undoStack,h=c===null?null:c.editorState;if(c!==null&&o===h)return;const p=n(i,o,c,l,u,a);if(p===Ws)f.length!==0&&(e.redoStack=[],r.dispatchCommand(nn,!1)),c!==null&&(d.push({...c}),r.dispatchCommand(sn,!0));else if(p===Ks)return;e.current={editor:r,editorState:o}}))}function Ld(){return{current:null,redoStack:[],undoStack:[]}}function jd({delay:r,externalHistoryState:e}){const[t]=nt();return function(n,s,o=1e3){const i=k.useMemo(()=>s||Ld(),[s]);k.useEffect(()=>Fd(n,i,o),[o,n,i])}(t,e,r),null}const Pd=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?k.useLayoutEffect:k.useEffect;function Od({ignoreHistoryMergeTagChange:r=!0,ignoreSelectionChange:e=!1,onChange:t}){const[n]=nt();return Pd(()=>{if(t)return n.registerUpdateListener(({editorState:s,dirtyElements:o,dirtyLeaves:i,prevEditorState:l,tags:u})=>{e&&o.size===0&&i.size===0||r&&u.has("history-merge")||l.isEmpty()||t(s,n,u)})},[n,r,e,t]),null}function Vs(r,e){return Vs=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},Vs(r,e)}var qo={error:null},Md=function(r){var e,t;function n(){for(var o,i=arguments.length,l=new Array(i),u=0;u<i;u++)l[u]=arguments[u];return(o=r.call.apply(r,[this].concat(l))||this).state=qo,o.resetErrorBoundary=function(){for(var a,c=arguments.length,f=new Array(c),d=0;d<c;d++)f[d]=arguments[d];o.props.onReset==null||(a=o.props).onReset.apply(a,f),o.reset()},o}t=r,(e=n).prototype=Object.create(t.prototype),e.prototype.constructor=e,Vs(e,t),n.getDerivedStateFromError=function(o){return{error:o}};var s=n.prototype;return s.reset=function(){this.setState(qo)},s.componentDidCatch=function(o,i){var l,u;(l=(u=this.props).onError)==null||l.call(u,o,i)},s.componentDidUpdate=function(o,i){var l,u,a,c,f=this.state.error,d=this.props.resetKeys;f!==null&&i.error!==null&&((a=o.resetKeys)===void 0&&(a=[]),(c=d)===void 0&&(c=[]),a.length!==c.length||a.some(function(h,p){return!Object.is(h,c[p])}))&&((l=(u=this.props).onResetKeysChange)==null||l.call(u,o.resetKeys,d),this.reset())},s.render=function(){var o=this.state.error,i=this.props,l=i.fallbackRender,u=i.FallbackComponent,a=i.fallback;if(o!==null){var c={error:o,resetErrorBoundary:this.resetErrorBoundary};if(us.isValidElement(a))return a;if(typeof l=="function")return l(c);if(u)return us.createElement(u,c);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},n}(us.Component);function Rd({children:r,onError:e}){return g.jsx(Md,{fallback:g.jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:e,children:r})}function $d(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Xe=$d(function(r){const e=new URLSearchParams;e.append("code",r);for(let t=1;t<arguments.length;t++)e.append("v",arguments[t]);throw Error(`Minified Lexical error #${r}; visit https://lexical.dev/docs/error?${e} for the full message or use the non-minified dev environment for full errors and additional helpful warnings.`)});function Id(r){let e=1,t=r.getParent();for(;t!=null;){if(ne(t)){const n=t.getParent();if(Q(n)){e++,t=n.getParent();continue}Xe(40)}return e}return e}function Gs(r){let e=r.getParent();Q(e)||Xe(40);let t=e;for(;t!==null;)t=t.getParent(),Q(t)&&(e=t);return e}function vu(r){let e=[];const t=r.getChildren().filter(ne);for(let n=0;n<t.length;n++){const s=t[n],o=s.getFirstChild();Q(o)?e=e.concat(vu(o)):e.push(s)}return e}function Ze(r){return ne(r)&&Q(r.getFirstChild())}function Uo(r){return Fe().append(r)}function Du(r,e){return ne(r)&&(e.length===0||e.length===1&&r.is(e[0])&&r.getChildrenSize()===0)}function Wo(r,e){r.update(()=>{const t=q();if(t!==null){const n=t.getNodes();if(P(t)){const o=t.getStartEndPoints();o===null&&Xe(143);const[i]=o,l=i.getNode(),u=l.getParent();if(Du(l,n)){const a=Te(e);if(tt(u)){l.replace(a);const c=Fe();B(l)&&(c.setFormat(l.getFormatType()),c.setIndent(l.getIndent())),a.append(c)}else if(ne(l)){const c=l.getParentOrThrow();Ot(a,c.getChildren()),c.replace(a)}return}}const s=new Set;for(let o=0;o<n.length;o++){const i=n[o];if(!B(i)||!i.isEmpty()||ne(i)||s.has(i.getKey())){if(Al(i)){let l=i.getParent();for(;l!=null;){const u=l.getKey();if(Q(l)){if(!s.has(u)){const a=Te(e);Ot(a,l.getChildren()),l.replace(a),s.add(u)}break}{const a=l.getParent();if(tt(a)&&!s.has(u)){s.add(u),Ko(l,e);break}l=a}}}}else Ko(i,e)}}})}function Ot(r,e){r.splice(r.getChildrenSize(),0,e)}function Ko(r,e){if(Q(r))return r;const t=r.getPreviousSibling(),n=r.getNextSibling(),s=Fe();let o;if(Ot(s,r.getChildren()),Q(t)&&e===t.getListType())t.append(s),Q(n)&&e===n.getListType()&&(Ot(t,n.getChildren()),n.remove()),o=t;else if(Q(n)&&e===n.getListType())n.getFirstChildOrThrow().insertBefore(s),o=n;else{const i=Te(e);i.append(s),r.replace(i),o=i}return s.setFormat(r.getFormatType()),s.setIndent(r.getIndent()),r.remove(),o}function Ci(r,e){const t=r.getLastChild(),n=e.getFirstChild();t&&n&&Ze(t)&&Ze(n)&&(Ci(t.getFirstChild(),n.getFirstChild()),n.remove());const s=e.getChildren();s.length>0&&r.append(...s),e.remove()}function zd(r){r.update(()=>{const e=q();if(P(e)){const t=new Set,n=e.getNodes(),s=e.anchor.getNode();if(Du(s,n))t.add(Gs(s));else for(let o=0;o<n.length;o++){const i=n[o];if(Al(i)){const l=td(i,Rt);l!=null&&t.add(Gs(l))}}for(const o of t){let i=o;const l=vu(o);for(const u of l){const a=fe();Ot(a,u.getChildren()),i.insertAfter(a),i=a,u.__key===e.anchor.key&&e.anchor.set(a.getKey(),0,"element"),u.__key===e.focus.key&&e.focus.set(a.getKey(),0,"element"),u.remove()}o.remove()}}})}function qd(r){const e=new Set;if(Ze(r)||e.has(r.getKey()))return;const t=r.getParent(),n=r.getNextSibling(),s=r.getPreviousSibling();if(Ze(n)&&Ze(s)){const o=s.getFirstChild();if(Q(o)){o.append(r);const i=n.getFirstChild();Q(i)&&(Ot(o,i.getChildren()),n.remove(),e.add(n.getKey()))}}else if(Ze(n)){const o=n.getFirstChild();if(Q(o)){const i=o.getFirstChild();i!==null&&i.insertBefore(r)}}else if(Ze(s)){const o=s.getFirstChild();Q(o)&&o.append(r)}else if(Q(t)){const o=Fe(),i=Te(t.getListType());o.append(i),i.append(r),s?s.insertAfter(o):n?n.insertBefore(o):t.append(o)}}function Ud(r){if(Ze(r))return;const e=r.getParent(),t=e?e.getParent():void 0;if(Q(t?t.getParent():void 0)&&ne(t)&&Q(e)){const n=e?e.getFirstChild():void 0,s=e?e.getLastChild():void 0;if(r.is(n))t.insertBefore(r),e.isEmpty()&&t.remove();else if(r.is(s))t.insertAfter(r),e.isEmpty()&&t.remove();else{const o=e.getListType(),i=Fe(),l=Te(o);i.append(l),r.getPreviousSiblings().forEach(c=>l.append(c));const u=Fe(),a=Te(o);u.append(a),Ot(a,r.getNextSiblings()),t.insertBefore(i),t.insertAfter(u),t.replace(r)}}}function Wd(){const r=q();if(!P(r)||!r.isCollapsed())return!1;const e=r.anchor.getNode();if(!ne(e)||e.getChildrenSize()!==0)return!1;const t=Gs(e),n=e.getParent();Q(n)||Xe(40);const s=n.getParent();let o;if(tt(s))o=fe(),t.insertAfter(o);else{if(!ne(s))return!1;o=Fe(),s.insertAfter(o)}o.select();const i=e.getNextSiblings();if(i.length>0){const l=Te(n.getListType());if(rr(o))o.insertAfter(l);else{const u=Fe();u.append(l),o.insertAfter(u)}i.forEach(u=>{u.remove(),l.append(u)})}return function(l){let u=l;for(;u.getNextSibling()==null&&u.getPreviousSibling()==null;){const a=u.getParent();if(a==null||!ne(u)&&!Q(u))break;u=a}u.remove()}(e),!0}function jn(...r){const e=[];for(const t of r)if(t&&typeof t=="string")for(const[n]of t.matchAll(/\S+/g))e.push(n);return e}class Rt extends ft{static getType(){return"listitem"}static clone(e){return new Rt(e.__value,e.__checked,e.__key)}constructor(e,t,n){super(n),this.__value=e===void 0?1:e,this.__checked=t}createDOM(e){const t=document.createElement("li"),n=this.getParent();return Q(n)&&n.getListType()==="check"&&Go(t,this,null),t.value=this.__value,Vo(t,e.theme,this),t}updateDOM(e,t,n){const s=this.getParent();return Q(s)&&s.getListType()==="check"&&Go(t,this,e),t.value=this.__value,Vo(t,n.theme,this),!1}static transform(){return e=>{if(ne(e)||Xe(144),e.__checked==null)return;const t=e.getParent();Q(t)&&t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:Kd,priority:0})}}static importJSON(e){const t=Fe();return t.setChecked(e.checked),t.setValue(e.value),t.setFormat(e.format),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config);return t.style.textAlign=this.getFormatType(),{element:t}}exportJSON(){return{...super.exportJSON(),checked:this.getChecked(),type:"listitem",value:this.getValue(),version:1}}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(B(n)&&this.canMergeWith(n)){const s=n.getChildren();this.append(...s),n.remove()}else super.append(n)}return this}replace(e,t){if(ne(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!Q(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{const s=Te(n.getListType());let o=this.getNextSibling();for(;o;){const i=o;o=o.getNextSibling(),s.append(i)}n.insertAfter(e),e.insertAfter(s)}return t&&(B(e)||Xe(139),this.getChildren().forEach(s=>{e.append(s)})),this.remove(),n.getChildrenSize()===0&&n.remove(),e}insertAfter(e,t=!0){const n=this.getParentOrThrow();if(Q(n)||Xe(39),ne(e))return super.insertAfter(e,t);const s=this.getNextSiblings();if(n.insertAfter(e,t),s.length!==0){const o=Te(n.getListType());s.forEach(i=>o.append(i)),e.insertAfter(o,t)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&Ze(t)&&Ze(n)&&(Ci(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){const n=Fe(this.__checked==null&&void 0);return this.insertAfter(n,t),n}collapseAtStart(e){const t=fe();this.getChildren().forEach(i=>t.append(i));const n=this.getParentOrThrow(),s=n.getParentOrThrow(),o=ne(s);if(n.getChildrenSize()===1)if(o)n.remove(),s.select();else{n.insertBefore(t),n.remove();const i=e.anchor,l=e.focus,u=t.getKey();i.type==="element"&&i.getNode().is(this)&&i.set(u,i.offset,"element"),l.type==="element"&&l.getNode().is(this)&&l.set(u,l.offset,"element")}else n.insertBefore(t),this.remove();return!0}getValue(){return this.getLatest().__value}setValue(e){this.getWritable().__value=e}getChecked(){const e=this.getLatest();let t;const n=this.getParent();return Q(n)&&(t=n.getListType()),t==="check"?!!e.__checked:void 0}setChecked(e){this.getWritable().__checked=e}toggleChecked(){this.setChecked(!this.__checked)}getIndent(){const e=this.getParent();if(e===null)return this.getLatest().__indent;let t=e.getParentOrThrow(),n=0;for(;ne(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){typeof e!="number"&&Xe(117),(e=Math.floor(e))>=0||Xe(199);let t=this.getIndent();for(;t!==e;)t<e?(qd(this),t++):(Ud(this),t--);return this}canInsertAfter(e){return ne(e)}canReplaceWith(e){return ne(e)}canMergeWith(e){return rr(e)||ne(e)}extractWithChild(e,t){if(!P(t))return!1;const n=t.anchor.getNode(),s=t.focus.getNode();return this.isParentOf(n)&&this.isParentOf(s)&&this.getTextContent().length===t.getTextContent().length}isParentRequired(){return!0}createParentElementNode(){return Te("bullet")}canMergeWhenEmpty(){return!0}}function Vo(r,e,t){const n=[],s=[],o=e.list,i=o?o.listitem:void 0;let l;if(o&&o.nested&&(l=o.nested.listitem),i!==void 0&&n.push(...jn(i)),o){const u=t.getParent(),a=Q(u)&&u.getListType()==="check",c=t.getChecked();a&&!c||s.push(o.listitemUnchecked),a&&c||s.push(o.listitemChecked),a&&n.push(c?o.listitemChecked:o.listitemUnchecked)}if(l!==void 0){const u=jn(l);t.getChildren().some(a=>Q(a))?n.push(...u):s.push(...u)}s.length>0&&hu(r,...s),n.length>0&&Hr(r,...n)}function Go(r,e,t,n){Q(e.getFirstChild())?(r.removeAttribute("role"),r.removeAttribute("tabIndex"),r.removeAttribute("aria-checked")):(r.setAttribute("role","checkbox"),r.setAttribute("tabIndex","-1"),t&&e.__checked===t.__checked||r.setAttribute("aria-checked",e.getChecked()?"true":"false"))}function Kd(r){if(r.classList.contains("task-list-item")){for(const t of r.children)if(t.tagName==="INPUT")return Vd(t)}const e=r.getAttribute("aria-checked");return{node:Fe(e==="true"||e!=="false"&&void 0)}}function Vd(r){return r.getAttribute("type")!=="checkbox"?{node:null}:{node:Fe(r.hasAttribute("checked"))}}function Fe(r){return st(new Rt(void 0,r))}function ne(r){return r instanceof Rt}class or extends ft{static getType(){return"list"}static clone(e){const t=e.__listType||Qo[e.__tag];return new or(t,e.__start,e.__key)}constructor(e,t,n){super(n);const s=Qo[e]||e;this.__listType=s,this.__tag=s==="number"?"ol":"ul",this.__start=t}getTag(){return this.__tag}setListType(e){const t=this.getWritable();t.__listType=e,t.__tag=e==="number"?"ol":"ul"}getListType(){return this.__listType}getStart(){return this.__start}createDOM(e,t){const n=this.__tag,s=document.createElement(n);return this.__start!==1&&s.setAttribute("start",String(this.__start)),s.__lexicalListType=this.__listType,Ho(s,e.theme,this),s}updateDOM(e,t,n){return e.__tag!==this.__tag||(Ho(t,n.theme,this),!1)}static transform(){return e=>{Q(e)||Xe(163),function(t){const n=t.getNextSibling();Q(n)&&t.getListType()===n.getListType()&&Ci(t,n)}(e),function(t){const n=t.getListType()!=="check";let s=t.getStart();for(const o of t.getChildren())ne(o)&&(o.getValue()!==s&&o.setValue(s),n&&o.getLatest().__checked!=null&&o.setChecked(void 0),Q(o.getFirstChild())||s++)}(e)}}static importDOM(){return{ol:()=>({conversion:Jo,priority:0}),ul:()=>({conversion:Jo,priority:0})}}static importJSON(e){const t=Te(e.listType,e.start);return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}exportDOM(e){const t=this.createDOM(e._config,e);return t&&ct(t)&&(this.__start!==1&&t.setAttribute("start",String(this.__start)),this.__listType==="check"&&t.setAttribute("__lexicalListType","check")),{element:t}}exportJSON(){return{...super.exportJSON(),listType:this.getListType(),start:this.getStart(),tag:this.getTag(),type:"list",version:1}}canBeEmpty(){return!1}canIndent(){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];if(ne(n))super.append(n);else{const s=Fe();if(Q(n))s.append(n);else if(B(n))if(n.isInline())s.append(n);else{const o=pe(n.getTextContent());s.append(o)}else s.append(n);super.append(s)}}return this}extractWithChild(e){return ne(e)}}function Ho(r,e,t){const n=[],s=[],o=e.list;if(o!==void 0){const i=o[`${t.__tag}Depth`]||[],l=Id(t)-1,u=l%i.length,a=i[u],c=o[t.__tag];let f;const d=o.nested,h=o.checklist;if(d!==void 0&&d.list&&(f=d.list),c!==void 0&&n.push(c),h!==void 0&&t.__listType==="check"&&n.push(h),a!==void 0){n.push(...jn(a));for(let p=0;p<i.length;p++)p!==u&&s.push(t.__tag+p)}if(f!==void 0){const p=jn(f);l>1?n.push(...p):s.push(...p)}}s.length>0&&hu(r,...s),n.length>0&&Hr(r,...n)}function Gd(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t];if(ne(n)){e.push(n);const s=n.getChildren();s.length>1&&s.forEach(o=>{Q(o)&&e.push(Uo(o))})}else e.push(Uo(n))}return e}function Jo(r){const e=r.nodeName.toLowerCase();let t=null;return e==="ol"?t=Te("number",r.start):e==="ul"&&(t=function(n){if(n.getAttribute("__lexicallisttype")==="check"||n.classList.contains("contains-task-list"))return!0;for(const s of n.childNodes)if(ct(s)&&s.hasAttribute("aria-checked"))return!0;return!1}(r)?Te("check"):Te("bullet")),{after:Gd,node:t}}const Qo={ol:"number",ul:"bullet"};function Te(r,e=1){return st(new or(r,e))}function Q(r){return r instanceof or}const Cu=Mr(),wu=Mr(),Hd=Mr();function Jd(r){return Mt(r.registerCommand(wu,()=>(Wo(r,"number"),!0),Jt),r.registerCommand(Cu,()=>(Wo(r,"bullet"),!0),Jt),r.registerCommand(Hd,()=>(zd(r),!0),Jt),r.registerCommand(Br,()=>!!Wd(),Jt))}function Qd(){const[r]=nt();return k.useEffect(()=>{if(!r.hasNodes([or,Rt]))throw new Error("ListPlugin: ListNode and/or ListItemNode not registered on editor")},[r]),function(e){k.useEffect(()=>Jd(e),[e])}(r),null}const Yd=new Set(["http:","https:","mailto:","sms:","tel:"]);class $t extends ft{static getType(){return"link"}static clone(e){return new $t(e.__url,{rel:e.__rel,target:e.__target,title:e.__title},e.__key)}constructor(e,t={},n){super(n);const{target:s=null,rel:o=null,title:i=null}=t;this.__url=e,this.__target=s,this.__rel=o,this.__title=i}createDOM(e){const t=document.createElement("a");return t.href=this.sanitizeUrl(this.__url),this.__target!==null&&(t.target=this.__target),this.__rel!==null&&(t.rel=this.__rel),this.__title!==null&&(t.title=this.__title),Hr(t,e.theme.link),t}updateDOM(e,t,n){if(t instanceof HTMLAnchorElement){const s=this.__url,o=this.__target,i=this.__rel,l=this.__title;s!==e.__url&&(t.href=s),o!==e.__target&&(o?t.target=o:t.removeAttribute("target")),i!==e.__rel&&(i?t.rel=i:t.removeAttribute("rel")),l!==e.__title&&(l?t.title=l:t.removeAttribute("title"))}return!1}static importDOM(){return{a:e=>({conversion:Xd,priority:1})}}static importJSON(e){const t=Pn(e.url,{rel:e.rel,target:e.target,title:e.title});return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}sanitizeUrl(e){try{const t=new URL(e);if(!Yd.has(t.protocol))return"about:blank"}catch{return e}return e}exportJSON(){return{...super.exportJSON(),rel:this.getRel(),target:this.getTarget(),title:this.getTitle(),type:"link",url:this.getURL(),version:1}}getURL(){return this.getLatest().__url}setURL(e){this.getWritable().__url=e}getTarget(){return this.getLatest().__target}setTarget(e){this.getWritable().__target=e}getRel(){return this.getLatest().__rel}setRel(e){this.getWritable().__rel=e}getTitle(){return this.getLatest().__title}setTitle(e){this.getWritable().__title=e}insertNewAfter(e,t=!0){const n=Pn(this.__url,{rel:this.__rel,target:this.__target,title:this.__title});return this.insertAfter(n,t),n}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}canBeEmpty(){return!1}isInline(){return!0}extractWithChild(e,t,n){if(!P(t))return!1;const s=t.anchor.getNode(),o=t.focus.getNode();return this.isParentOf(s)&&this.isParentOf(o)&&t.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}}function Xd(r){let e=null;if(ac(r)){const t=r.textContent;(t!==null&&t!==""||r.children.length>0)&&(e=Pn(r.getAttribute("href")||"",{rel:r.getAttribute("rel"),target:r.getAttribute("target"),title:r.getAttribute("title")}))}return{node:e}}function Pn(r,e){return st(new $t(r,e))}function mr(r){return r instanceof $t}class Jr extends $t{constructor(e,t={},n){super(e,t,n),this.__isUnlinked=t.isUnlinked!==void 0&&t.isUnlinked!==null&&t.isUnlinked}static getType(){return"autolink"}static clone(e){return new Jr(e.__url,{isUnlinked:e.__isUnlinked,rel:e.__rel,target:e.__target,title:e.__title},e.__key)}getIsUnlinked(){return this.__isUnlinked}setIsUnlinked(e){const t=this.getWritable();return t.__isUnlinked=e,t}createDOM(e){return this.__isUnlinked?document.createElement("span"):super.createDOM(e)}updateDOM(e,t,n){return super.updateDOM(e,t,n)||e.__isUnlinked!==this.__isUnlinked}static importJSON(e){const t=Yo(e.url,{isUnlinked:e.isUnlinked,rel:e.rel,target:e.target,title:e.title});return t.setFormat(e.format),t.setIndent(e.indent),t.setDirection(e.direction),t}static importDOM(){return null}exportJSON(){return{...super.exportJSON(),isUnlinked:this.__isUnlinked,type:"autolink",version:1}}insertNewAfter(e,t=!0){const n=this.getParentOrThrow().insertNewAfter(e,t);if(B(n)){const s=Yo(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return n.append(s),s}return null}}function Yo(r,e){return st(new Jr(r,e))}function Zd(r){return r instanceof Jr}const Xo=Mr();function Cs(r,e={}){const{target:t,title:n}=e,s=e.rel===void 0?"noreferrer":e.rel,o=q();if(!P(o))return;const i=o.extract();if(r===null)i.forEach(l=>{const u=Qn(l,a=>!Zd(a)&&mr(a));if(u){const a=u.getChildren();for(let c=0;c<a.length;c++)u.insertBefore(a[c]);u.remove()}});else{if(i.length===1){const a=function(c,f){let d=c;for(;d!==null&&d.getParent()!==null&&!f(d);)d=d.getParentOrThrow();return f(d)?d:null}(i[0],mr);if(a!==null)return a.setURL(r),t!==void 0&&a.setTarget(t),s!==null&&a.setRel(s),void(n!==void 0&&a.setTitle(n))}let l=null,u=null;i.forEach(a=>{const c=a.getParent();if(c!==u&&c!==null&&(!B(a)||a.isInline())){if(mr(c))return u=c,c.setURL(r),t!==void 0&&c.setTarget(t),s!==null&&u.setRel(s),void(n!==void 0&&u.setTitle(n));if(c.is(l)||(l=c,u=Pn(r,{rel:s,target:t,title:n}),mr(c)?a.getPreviousSibling()===null?c.insertBefore(u):c.insertAfter(u):a.insertBefore(u)),mr(a)){if(a.is(u))return;if(u!==null){const f=a.getChildren();for(let d=0;d<f.length;d++)u.append(f[d])}a.remove()}else u!==null&&u.append(a)}})}}function ef({validateUrl:r,attributes:e}){const[t]=nt();return k.useEffect(()=>{if(!t.hasNodes([$t]))throw new Error("LinkPlugin: LinkNode not registered on editor");return Mt(t.registerCommand(Xo,n=>{if(n===null)return Cs(n),!0;if(typeof n=="string")return!(r!==void 0&&!r(n))&&(Cs(n,e),!0);{const{url:s,target:o,rel:i,title:l}=n;return Cs(s,{...e,rel:i,target:o,title:l}),!0}},Jt),r!==void 0?t.registerCommand(Mn,n=>{const s=q();if(!P(s)||s.isCollapsed()||!_t(n,ClipboardEvent))return!1;const o=n;if(o.clipboardData===null)return!1;const i=o.clipboardData.getData("text");return!!r(i)&&!s.getNodes().some(l=>B(l))&&(t.dispatchCommand(Xo,{...e,url:i}),n.preventDefault(),!0)},Jt):()=>{})},[t,r,e]),null}const tf={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",toolbarBackground:"#f9fafb",quoteBorder:"#d1d5db",quoteBackground:"#f3f4f6"},rf={paragraph:"mail-editor-paragraph",text:{bold:"mail-editor-bold",italic:"mail-editor-italic",underline:"mail-editor-underline"},list:{ul:"mail-editor-ul",ol:"mail-editor-ol",listitem:"mail-editor-li"},link:"mail-editor-link",quote:"mail-editor-quote",heading:{h1:"mail-editor-h1",h2:"mail-editor-h2",h3:"mail-editor-h3"}};function nf({theme:r,disabled:e}){const[t]=nt(),n=k.useCallback(()=>{t.dispatchCommand(We,"bold")},[t]),s=k.useCallback(()=>{t.dispatchCommand(We,"italic")},[t]),o=k.useCallback(()=>{t.dispatchCommand(We,"underline")},[t]),i=k.useCallback(()=>{t.dispatchCommand(Cu,void 0)},[t]),l=k.useCallback(()=>{t.dispatchCommand(wu,void 0)},[t]),u=k.useCallback(()=>{t.update(()=>{const f=q();P(f)&&Jc(f,()=>Di())})},[t]),a={display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",border:"none",background:"transparent",borderRadius:"4px",cursor:e?"not-allowed":"pointer",color:e?r.textSecondary:r.text,fontSize:"14px",fontWeight:600,opacity:e?.5:1},c=`
|
|
74
74
|
.mail-editor-toolbar-btn:hover:not(:disabled) {
|
|
75
75
|
background: ${r.border};
|
|
76
76
|
}
|
|
77
|
-
`;return g.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"2px",padding:"8px",borderBottom:`1px solid ${r.border}`,background:r.toolbarBackground},children:[g.jsx("style",{children:c}),g.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:n,disabled:e,style:a,title:"Bold (Ctrl+B)",children:"B"}),g.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:s,disabled:e,style:{...a,fontStyle:"italic"},title:"Italic (Ctrl+I)",children:"I"}),g.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:o,disabled:e,style:{...a,textDecoration:"underline"},title:"Underline (Ctrl+U)",children:"U"}),g.jsx("div",{style:{width:"1px",height:"20px",background:r.border,margin:"0 6px"}}),g.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:i,disabled:e,style:a,title:"Bullet List",children:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[g.jsx("circle",{cx:"4",cy:"6",r:"2"}),g.jsx("circle",{cx:"4",cy:"12",r:"2"}),g.jsx("circle",{cx:"4",cy:"18",r:"2"}),g.jsx("rect",{x:"8",y:"5",width:"14",height:"2"}),g.jsx("rect",{x:"8",y:"11",width:"14",height:"2"}),g.jsx("rect",{x:"8",y:"17",width:"14",height:"2"})]})}),g.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:l,disabled:e,style:a,title:"Numbered List",children:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[g.jsx("text",{x:"2",y:"8",fontSize:"8",fontFamily:"sans-serif",children:"1"}),g.jsx("text",{x:"2",y:"14",fontSize:"8",fontFamily:"sans-serif",children:"2"}),g.jsx("text",{x:"2",y:"20",fontSize:"8",fontFamily:"sans-serif",children:"3"}),g.jsx("rect",{x:"8",y:"5",width:"14",height:"2"}),g.jsx("rect",{x:"8",y:"11",width:"14",height:"2"}),g.jsx("rect",{x:"8",y:"17",width:"14",height:"2"})]})}),g.jsx("div",{style:{width:"1px",height:"20px",background:r.border,margin:"0 6px"}}),g.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:u,disabled:e,style:a,title:"Quote",children:g.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:g.jsx("path",{d:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"})})})]})}function sf({html:r,isExternalUpdate:e,onImportComplete:t}){const[n]=nt(),s=k.useRef(!1);return k.useEffect(()=>{r&&(s.current&&!e||(s.current=!0,n.update(()=>{const o=ie();o.clear();const i=fe();o.append(i),i.select();const u=new DOMParser().parseFromString(r,"text/html"),c=pu(n,u).filter(f=>f.getParent()===null);c.length>0&&Zl(c),i.getTextContent()===""&&o.getChildrenSize()>1&&i.remove(),o.selectEnd()},{discrete:!0}),t(),setTimeout(()=>{n.focus()},0)))},[r,e,n,t]),null}function of({replyTo:r,theme:e}){const t=n=>{try{return new Date(n).toLocaleString()}catch{return n}};return g.jsxs("div",{style:{marginTop:"16px",paddingTop:"16px",borderTop:`1px solid ${e.border}`},children:[g.jsxs("div",{style:{fontSize:"12px",color:e.textSecondary,marginBottom:"8px"},children:["On ",t(r.date),", ",r.from," wrote:"]}),g.jsx("blockquote",{style:{margin:0,padding:"12px 16px",borderLeft:`3px solid ${e.quoteBorder}`,background:e.quoteBackground,fontSize:"14px",color:e.textSecondary,maxHeight:"200px",overflowY:"auto"},dangerouslySetInnerHTML:{__html:r.body}})]})}function Eu({value:r="",onChange:e,placeholder:t="Write your message...",replyTo:n,theme:s={},disabled:o=!1,className:i="",minHeight:l="200px",externalUpdate:u}){const a={...tf,...s},[c,f]=k.useState(!1),d=k.useRef(void 0);k.useEffect(()=>{u!==void 0&&u!==d.current&&(d.current=u,f(!0))},[u]);const h=k.useCallback(()=>{f(!1)},[]),p={namespace:"MailEditor",theme:rf,onError:
|
|
77
|
+
`;return g.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"2px",padding:"8px",borderBottom:`1px solid ${r.border}`,background:r.toolbarBackground},children:[g.jsx("style",{children:c}),g.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:n,disabled:e,style:a,title:"Bold (Ctrl+B)",children:"B"}),g.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:s,disabled:e,style:{...a,fontStyle:"italic"},title:"Italic (Ctrl+I)",children:"I"}),g.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:o,disabled:e,style:{...a,textDecoration:"underline"},title:"Underline (Ctrl+U)",children:"U"}),g.jsx("div",{style:{width:"1px",height:"20px",background:r.border,margin:"0 6px"}}),g.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:i,disabled:e,style:a,title:"Bullet List",children:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[g.jsx("circle",{cx:"4",cy:"6",r:"2"}),g.jsx("circle",{cx:"4",cy:"12",r:"2"}),g.jsx("circle",{cx:"4",cy:"18",r:"2"}),g.jsx("rect",{x:"8",y:"5",width:"14",height:"2"}),g.jsx("rect",{x:"8",y:"11",width:"14",height:"2"}),g.jsx("rect",{x:"8",y:"17",width:"14",height:"2"})]})}),g.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:l,disabled:e,style:a,title:"Numbered List",children:g.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[g.jsx("text",{x:"2",y:"8",fontSize:"8",fontFamily:"sans-serif",children:"1"}),g.jsx("text",{x:"2",y:"14",fontSize:"8",fontFamily:"sans-serif",children:"2"}),g.jsx("text",{x:"2",y:"20",fontSize:"8",fontFamily:"sans-serif",children:"3"}),g.jsx("rect",{x:"8",y:"5",width:"14",height:"2"}),g.jsx("rect",{x:"8",y:"11",width:"14",height:"2"}),g.jsx("rect",{x:"8",y:"17",width:"14",height:"2"})]})}),g.jsx("div",{style:{width:"1px",height:"20px",background:r.border,margin:"0 6px"}}),g.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:u,disabled:e,style:a,title:"Quote",children:g.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:g.jsx("path",{d:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"})})})]})}function sf({html:r,isExternalUpdate:e,onImportComplete:t}){const[n]=nt(),s=k.useRef(!1);return k.useEffect(()=>{r&&(s.current&&!e||(s.current=!0,n.update(()=>{const o=ie();o.clear();const i=fe();o.append(i),i.select();const u=new DOMParser().parseFromString(r,"text/html"),c=pu(n,u).filter(f=>f.getParent()===null);c.length>0&&Zl(c),i.getTextContent()===""&&o.getChildrenSize()>1&&i.remove(),o.selectEnd()},{discrete:!0}),t(),setTimeout(()=>{n.focus()},0)))},[r,e,n,t]),null}function of({replyTo:r,theme:e}){const t=n=>{try{return new Date(n).toLocaleString()}catch{return n}};return g.jsxs("div",{style:{marginTop:"16px",paddingTop:"16px",borderTop:`1px solid ${e.border}`},children:[g.jsxs("div",{style:{fontSize:"12px",color:e.textSecondary,marginBottom:"8px"},children:["On ",t(r.date),", ",r.from," wrote:"]}),g.jsx("blockquote",{style:{margin:0,padding:"12px 16px",borderLeft:`3px solid ${e.quoteBorder}`,background:e.quoteBackground,fontSize:"14px",color:e.textSecondary,maxHeight:"200px",overflowY:"auto"},dangerouslySetInnerHTML:{__html:r.body}})]})}function Eu({value:r="",onChange:e,placeholder:t="Write your message...",replyTo:n,theme:s={},disabled:o=!1,className:i="",minHeight:l="200px",externalUpdate:u}){const a={...tf,...s},[c,f]=k.useState(!1),d=k.useRef(void 0);k.useEffect(()=>{u!==void 0&&u!==d.current&&(d.current=u,f(!0))},[u]);const h=k.useCallback(()=>{f(!1)},[]),p={namespace:"MailEditor",theme:rf,onError:C=>{console.error("Lexical error:",C)},nodes:[or,Rt,$t,Jr,Xn,Yn],editable:!o},m=k.useCallback((C,_)=>{C.read(()=>{const E=gu(_,null);e==null||e(E)})},[e]),x=`
|
|
78
78
|
.mail-editor-paragraph {
|
|
79
79
|
margin: 0 0 8px 0;
|
|
80
80
|
line-height: 1.5;
|
|
@@ -140,9 +140,9 @@ React keys must be passed directly to JSX without using spread:
|
|
|
140
140
|
pointer-events: none;
|
|
141
141
|
font-size: 14px;
|
|
142
142
|
}
|
|
143
|
-
`;return g.jsxs("div",{className:i,style:{border:`1px solid ${a.border}`,borderRadius:"8px",background:a.background,overflow:"hidden"},children:[g.jsx("style",{children:x}),g.jsxs(Oc,{initialConfig:p,children:[g.jsx(nf,{theme:a,disabled:o}),g.jsx("div",{style:{position:"relative"},children:g.jsx(bd,{contentEditable:g.jsx(wd,{className:"mail-editor-content",style:{outline:"none",minHeight:
|
|
143
|
+
`;return g.jsxs("div",{className:i,style:{border:`1px solid ${a.border}`,borderRadius:"8px",background:a.background,overflow:"hidden",display:"flex",flexDirection:"column",height:"100%",minHeight:l},children:[g.jsx("style",{children:x}),g.jsxs(Oc,{initialConfig:p,children:[g.jsx(nf,{theme:a,disabled:o}),g.jsx("div",{style:{position:"relative",flex:1,display:"flex",flexDirection:"column"},children:g.jsx(bd,{contentEditable:g.jsx(wd,{className:"mail-editor-content",style:{outline:"none",flex:1,minHeight:"100px",padding:"16px",fontSize:"14px",lineHeight:1.6,color:a.text}}),placeholder:g.jsx("div",{className:"mail-editor-placeholder",children:t}),ErrorBoundary:Rd})}),g.jsx(Qd,{}),g.jsx(ef,{}),g.jsx(jd,{}),g.jsx(Od,{onChange:m}),g.jsx(sf,{html:r,isExternalUpdate:c,onImportComplete:h})]}),n&&g.jsx(of,{replyTo:n,theme:a})]})}const lf={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",toolbarBackground:"#f9fafb",quoteBorder:"#d1d5db",quoteBackground:"#f3f4f6",inputBackground:"#ffffff",inputBorder:"#d1d5db",inputFocus:"#3b82f6",buttonPrimary:"#3b82f6",buttonPrimaryHover:"#2563eb",buttonSecondary:"#f3f4f6",buttonSecondaryHover:"#e5e7eb",attachmentBackground:"#f9fafb",attachmentBorder:"#e5e7eb"};function uf({to:r="",subject:e="",body:t="",replyTo:n,onSend:s,onCancel:o,theme:i={},disabled:l=!1,showCcBcc:u=!1,placeholder:a="Write your message...",className:c="",minHeight:f="200px",sendButtonText:d="Send",hideCancelButton:h=!1}){const p={...lf,...i},[m,x]=k.useState(r),[C,_]=k.useState(""),[E,D]=k.useState(""),[A,v]=k.useState(e),[b,w]=k.useState(t),[S,R]=k.useState([]),[T,N]=k.useState(!1),[j,L]=k.useState(""),[$,H]=k.useState(u),ue=k.useRef(null),[re,we]=k.useState(!1),Ee=W=>{const xe=W.target.files;xe&&R($e=>[...$e,...Array.from(xe)]),ue.current&&(ue.current.value="")},Ge=W=>{W.preventDefault(),W.stopPropagation(),we(!0)},He=W=>{W.preventDefault(),W.stopPropagation(),we(!1)},Me=W=>{W.preventDefault(),W.stopPropagation(),we(!1),W.dataTransfer.files&&R(xe=>[...xe,...Array.from(W.dataTransfer.files)])},Je=W=>W.type.startsWith("image/")?"image":W.type==="application/pdf"?"picture_as_pdf":W.type.includes("spreadsheet")||W.type.includes("excel")?"table_chart":W.type.includes("document")||W.type.includes("word")?"description":"attach_file",Re=W=>{R(xe=>xe.filter(($e,wt)=>wt!==W))},ae=W=>W<1024?`${W} B`:W<1024*1024?`${(W/1024).toFixed(1)} KB`:`${(W/(1024*1024)).toFixed(1)} MB`,Le=async()=>{if(!m.trim()){L("Recipient email is required");return}if(!A.trim()){L("Subject is required");return}N(!0),L("");try{const W=await Promise.all(S.map(async $e=>{const wt=await $e.arrayBuffer(),ht=btoa(new Uint8Array(wt).reduce((it,It)=>it+String.fromCharCode(It),""));return{filename:$e.name,content_type:$e.type||"application/octet-stream",data:ht,size:$e.size}})),xe=b.replace(/>\n+</g,"><").replace(/<p class="[^"]*"><\/p>/g,"<br>").trim();await s({to:m.trim(),cc:C.trim()||void 0,bcc:E.trim()||void 0,subject:A.trim(),html:xe,attachments:W,inReplyTo:n==null?void 0:n.messageId}),x(""),_(""),D(""),v(""),w(""),R([])}catch(W){L(W instanceof Error?W.message:"Failed to send email")}finally{N(!1)}},he={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${p.inputBorder}`,borderRadius:"6px",background:p.inputBackground,color:p.text,outline:"none"},ee={display:"block",fontSize:"12px",fontWeight:500,color:p.textSecondary,marginBottom:"4px",textTransform:"uppercase"},Be=W=>({padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderRadius:"6px",cursor:l||T?"not-allowed":"pointer",opacity:l||T?.6:1,background:W?p.buttonPrimary:p.buttonSecondary,color:W?"#ffffff":p.text,display:"flex",alignItems:"center",gap:"8px"});return g.jsxs("div",{className:c,style:{display:"flex",flexDirection:"column",gap:"16px",background:p.background},children:[j&&g.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:"6px",color:"#dc2626",fontSize:"14px"},children:j}),g.jsxs("div",{children:[g.jsx("label",{style:ee,children:"To"}),g.jsx("input",{type:"email",value:m,onChange:W=>x(W.target.value),placeholder:"recipient@example.com",disabled:l||T,style:he})]}),!$&&g.jsx("button",{type:"button",onClick:()=>H(!0),disabled:l||T,style:{background:"none",border:"none",padding:0,fontSize:"12px",color:p.primary,cursor:"pointer",textAlign:"left"},children:"+ Add CC/BCC"}),$&&g.jsxs(g.Fragment,{children:[g.jsxs("div",{children:[g.jsx("label",{style:ee,children:"CC"}),g.jsx("input",{type:"email",value:C,onChange:W=>_(W.target.value),placeholder:"cc@example.com",disabled:l||T,style:he})]}),g.jsxs("div",{children:[g.jsx("label",{style:ee,children:"BCC"}),g.jsx("input",{type:"email",value:E,onChange:W=>D(W.target.value),placeholder:"bcc@example.com",disabled:l||T,style:he})]})]}),g.jsxs("div",{children:[g.jsx("label",{style:ee,children:"Subject"}),g.jsx("input",{type:"text",value:A,onChange:W=>v(W.target.value),placeholder:"Email subject",disabled:l||T,style:he})]}),g.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:[g.jsx("label",{style:ee,children:"Message"}),g.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:g.jsx(Eu,{value:b,onChange:w,placeholder:a,replyTo:n,theme:p,disabled:l||T,minHeight:f})})]}),g.jsxs("div",{children:[g.jsx("label",{style:{...ee,marginBottom:"8px"},children:"Attachments"}),g.jsx("input",{ref:ue,type:"file",multiple:!0,onChange:Ee,style:{display:"none"}}),g.jsxs("div",{onClick:()=>{var W;return(W=ue.current)==null?void 0:W.click()},onDragOver:Ge,onDragLeave:He,onDrop:Me,style:{width:"100%",padding:"24px 16px",border:`2px dashed ${re?p.primary:p.border}`,borderRadius:"8px",background:re?`${p.primary}10`:"transparent",color:re?p.primary:p.textSecondary,cursor:l||T?"not-allowed":"pointer",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s",marginBottom:S.length>0?"12px":0},children:[g.jsx("span",{className:"material-icons",style:{fontSize:"24px"},children:re?"file_download":"attach_file"}),g.jsx("span",{style:{fontSize:"14px"},children:re?"Drop files here":"Drop files or click to add"})]}),S.length>0&&g.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:S.map((W,xe)=>g.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:p.attachmentBackground,borderRadius:"8px"},children:[g.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:p.textSecondary},children:Je(W)}),g.jsxs("div",{style:{flex:1,minWidth:0},children:[g.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:p.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:W.name}),g.jsx("div",{style:{fontSize:"12px",color:p.textSecondary},children:ae(W.size)})]}),g.jsx("button",{type:"button",onClick:()=>Re(xe),disabled:l||T,style:{background:"none",border:"none",padding:"4px",cursor:"pointer",color:p.textSecondary,display:"flex",borderRadius:"4px"},children:g.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:"close"})})]},`${W.name}-${xe}`))})]}),g.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"12px"},children:[!h&&o&&g.jsx("button",{type:"button",onClick:o,disabled:l||T,style:Be(!1),children:"Cancel"}),g.jsxs("button",{type:"button",onClick:Le,disabled:l||T||!m.trim()||!A.trim(),style:Be(!0),children:[g.jsx("span",{className:"material-icons",style:{fontSize:"18px",animation:T?"spin 1s linear infinite":"none"},children:T?"sync":"send"}),T?"Sending...":d]})]}),g.jsx("style",{children:`
|
|
144
144
|
@keyframes spin {
|
|
145
145
|
from { transform: rotate(0deg); }
|
|
146
146
|
to { transform: rotate(360deg); }
|
|
147
147
|
}
|
|
148
|
-
`})]})}const af={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function cf({options:r,value:e,onChange:t,placeholder:n="Search or select...",allowCreate:s=!0,onCreate:o,allowDelete:i=!1,onDelete:l,label:u,disabled:a=!1,max:c=0,theme:f={},className:d=""}){const h={...af,...f},[p,m]=k.useState(!1),[x,D]=k.useState(""),_=k.useRef(null),E=k.useRef(null);k.useEffect(()=>{function T(N){_.current&&!_.current.contains(N.target)&&(m(!1),D(""))}return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const C=r.filter(T=>{var N;return((N=T.label)==null?void 0:N.toLowerCase().includes(x.toLowerCase()))&&!e.includes(T.id)}),A=s&&x.trim()&&!r.some(T=>{var N;return((N=T.label)==null?void 0:N.toLowerCase())===x.toLowerCase()}),v=e.map(T=>r.find(N=>N.id===T)).filter(Boolean),b=k.useCallback(T=>{var N;c>0&&e.length>=c||(t([...e,T]),D(""),(N=E.current)==null||N.focus())},[e,t,c]),w=k.useCallback(T=>{t(e.filter(N=>N!==T))},[e,t]),S=k.useCallback(async()=>{if(!A)return;const T=await(o==null?void 0:o(x.trim()));T&&b(T.id),D("")},[A,x,o,b]),R=k.useCallback(T=>{T.key==="Enter"?(T.preventDefault(),A?S():C.length>0&&b(C[0].id)):T.key==="Backspace"&&!x&&e.length>0?w(e[e.length-1]):T.key==="Escape"&&(m(!1),D(""))},[A,C,x,e,S,b,w]);return g.jsxs("div",{ref:_,className:d,style:{position:"relative"},children:[u&&g.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:h.textSecondary,marginBottom:"4px"},children:u}),g.jsxs("div",{onClick:()=>!a&&m(!0),style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px 12px",border:`1px solid ${p?h.primary:h.border}`,borderRadius:"8px",background:a?h.hoverBackground:h.background,cursor:a?"not-allowed":"text",minHeight:"42px",alignItems:"center"},children:[v.map(T=>g.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:T.color||h.chipBackground,color:T.color?"#fff":h.chipText},children:[T.label,!a&&g.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),w(T.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},T.id)),g.jsx("input",{ref:E,type:"text",value:x,onChange:T=>{D(T.target.value),p||m(!0)},onFocus:()=>m(!0),onKeyDown:R,placeholder:v.length===0?n:"",disabled:a||c>0&&e.length>=c,style:{flex:1,minWidth:"60px",border:"none",outline:"none",fontSize:"14px",background:"transparent",color:h.text}})]}),p&&!a&&g.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:h.background,border:`1px solid ${h.border}`,borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",maxHeight:"200px",overflowY:"auto",zIndex:50},children:C.length===0&&!A?g.jsx("div",{style:{padding:"12px",fontSize:"14px",color:h.textSecondary,textAlign:"center"},children:x?"No matches":"No options available"}):g.jsxs(g.Fragment,{children:[C.map(T=>g.jsxs("div",{onClick:()=>b(T.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:h.text,display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:N=>{N.currentTarget.style.background=h.hoverBackground||""},onMouseLeave:N=>{N.currentTarget.style.background=""},children:[T.label,i&&l&&g.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),l(T.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:h.textSecondary,opacity:.5},onMouseEnter:N=>{N.currentTarget.style.opacity="1",N.currentTarget.style.color="#ef4444"},onMouseLeave:N=>{N.currentTarget.style.opacity="0.5",N.currentTarget.style.color=h.textSecondary||""},children:"×"})]},T.id)),A&&g.jsxs("div",{onClick:S,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:h.primary,borderTop:C.length>0?`1px solid ${h.border}`:"none"},onMouseEnter:T=>{T.currentTarget.style.background=h.hoverBackground||""},onMouseLeave:T=>{T.currentTarget.style.background=""},children:['+ Create "',x.trim(),'"']})]})})]})}function df({items:r,columns:e,getItemId:t,getItemColumn:n,getItemOrder:s,renderItem:o,onItemMove:i,onItemReorder:l,onItemClick:u,renderColumnHeader:a,renderColumnFooter:c,className:f="",columnClassName:d="",itemClassName:h=""}){const[p,m]=k.useState(null),[x,D]=k.useState(null),[_,E]=k.useState(null),C=k.useRef(null),A=e.reduce((N,j)=>{let L=r.filter($=>n($)===j.id);return s&&(L=L.sort(($,H)=>s($)-s(H))),N[j.id]=L,N},{}),v=k.useCallback((N,j)=>{const L=t(j),$=n(j);m(L),C.current=$,N.dataTransfer.effectAllowed="move",N.dataTransfer.setData("text/plain",L),requestAnimationFrame(()=>{const H=N.target;H.style.opacity="0.5"})},[t,n]),b=k.useCallback(N=>{const j=N.target;j.style.opacity="1",m(null),D(null),E(null),C.current=null},[]),w=k.useCallback((N,j,L)=>{N.preventDefault(),N.dataTransfer.dropEffect="move",D(j),E(L)},[]),S=k.useCallback(N=>{const j=N.relatedTarget;j!=null&&j.closest("[data-kanban-column]")||(D(null),E(null))},[]),R=k.useCallback((N,j,L)=>{if(N.preventDefault(),!p)return;const $=C.current;$===j?l==null||l(p,j,L):$&&i(p,$,j,L),m(null),D(null),E(null),C.current=null},[p,i,l]),T=(N,j)=>g.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[N.color&&g.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:N.color}}),g.jsx("span",{className:"font-medium text-sm text-neutral-700",children:N.label})]}),g.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:j})]});return g.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${f}`,style:{minHeight:"400px"},children:e.map(N=>{const j=A[N.id]||[],L=x===N.id;return g.jsxs("div",{"data-kanban-column":N.id,className:`flex-1 min-w-[180px] bg-neutral-50 rounded-xl flex flex-col ${d}`,onDragOver:$=>{$.preventDefault(),p&&!L&&D(N.id)},onDragLeave:S,onDrop:$=>R($,N.id,_??j.length),children:[g.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:a?a(N,j.length):T(N,j.length)}),g.jsxs("div",{className:`flex-1 overflow-y-auto p-2 space-y-2 min-h-[100px] transition-colors ${L?"bg-blue-50":""}`,children:[j.map(($,H)=>{const ue=t($),re=p===ue,we=L&&_===H&&!re;return g.jsxs("div",{children:[we&&g.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),g.jsx("div",{draggable:!0,onDragStart:Ee=>v(Ee,$),onDragEnd:b,onDragOver:Ee=>w(Ee,N.id,H),onClick:()=>u==null?void 0:u($),className:`cursor-grab active:cursor-grabbing transition-all ${re?"opacity-50 scale-95":""} ${h}`,children:o($,re)})]},ue)}),g.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:$=>{$.preventDefault(),w($,N.id,j.length)},children:L&&_===j.length&&g.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),j.length===0&&L&&g.jsx("div",{className:"h-20 border-2 border-dashed border-blue-300 rounded-lg bg-blue-50/50 flex items-center justify-center",children:g.jsx("span",{className:"text-sm text-blue-400",children:"Drop here"})})]}),c&&g.jsx("div",{className:"flex-shrink-0 border-t border-neutral-200 p-2",children:c(N)})]},N.id)})})}const ff={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function hf(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function pf(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function gf(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function mf({items:r,date:e,startHour:t=7,endHour:n=22,hourHeight:s=60,getItemTime:o,getItemDuration:i,getItemIsAllDay:l,getItemId:u,renderItem:a,onItemClick:c,onTimeSlotClick:f,showCurrentTime:d=!0,className:h="",theme:p={}}){const m={...ff,...p},{allDayItems:x,timedItems:D}=k.useMemo(()=>{const b=[],w=[];for(const S of r)l(S)?b.push(S):w.push(S);return{allDayItems:b,timedItems:w}},[r,l]),_=k.useMemo(()=>{const b=[];for(let w=t;w<=n;w++)b.push(w);return b},[t,n]),E=(n-t+1)*s,C=k.useCallback(b=>{const w=o(b);if(!w)return null;const S=hf(w);if(!S)return null;const{hours:R,minutes:T}=S,N=Math.max(t,Math.min(n,R)),j=R<t?0:T,L=(N-t)*s+j/60*s,$=i(b),H=Math.max(20,$/60*s);return{top:L,height:H}},[o,i,t,n,s]),A=k.useMemo(()=>{if(!d||!gf(e))return null;const b=new Date,w=b.getHours(),S=b.getMinutes();return w<t||w>n?null:(w-t)*s+S/60*s},[e,d,t,n,s]),v=k.useCallback(b=>{if(!f)return;const w=b.currentTarget.getBoundingClientRect(),R=(b.clientY-w.top)/s*60,T=Math.floor(R/60)+t,N=Math.round(R%60/15)*15,j=Math.min(n,Math.max(t,T)),L=N>=60?0:N,$=`${j.toString().padStart(2,"0")}:${L.toString().padStart(2,"0")}`;f($)},[f,s,t,n]);return g.jsxs("div",{className:h,style:{background:m.background},children:[x.length>0&&g.jsxs("div",{style:{padding:"8px 0 8px 60px",borderBottom:`1px solid ${m.allDayBorder}`,background:m.allDayBackground},children:[g.jsx("div",{style:{fontSize:"11px",color:m.hourTextColor,marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"All Day"}),g.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:x.map(b=>g.jsx("div",{onClick:()=>c==null?void 0:c(b),style:{cursor:c?"pointer":"default"},children:a(b)},u(b)))})]}),g.jsxs("div",{style:{position:"relative",height:E},children:[_.map((b,w)=>g.jsxs("div",{style:{position:"absolute",top:w*s,left:0,right:0},children:[g.jsx("div",{style:{position:"absolute",left:0,top:-8,width:"50px",textAlign:"right",paddingRight:"10px",fontSize:"11px",color:m.hourTextColor},children:pf(b)}),g.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),w<_.length-1&&g.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:s/2,height:"1px",background:m.halfHourLineColor}})]},b)),g.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:f?"pointer":"default"},onClick:v}),A!==null&&g.jsxs("div",{style:{position:"absolute",left:"55px",right:0,top:A,zIndex:20,pointerEvents:"none"},children:[g.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",background:m.currentTimeColor,marginLeft:"-5px",marginTop:"-5px",position:"absolute"}}),g.jsx("div",{style:{marginLeft:"5px",height:"2px",background:m.currentTimeColor}})]}),D.map(b=>{const w=C(b);return w?g.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:w.top,height:w.height,zIndex:10,cursor:c?"pointer":"default"},onClick:S=>{S.stopPropagation(),c==null||c(b)},children:a(b)},u(b)):null})]})]})}exports.AnimatedCardFlip=ha;exports.ApiClient=nl;exports.AuthManager=rl;exports.Card=ca;exports.ComboBox=cf;exports.DataOperations=fn;exports.Detail=da;exports.GraphClient=$u;exports.KanbanBoard=df;exports.Mail=ga;exports.MailClient=tl;exports.MailComposer=uf;exports.MailEditor=Eu;exports.SelectableList=ma;exports.Stack=aa;exports.Timeline=mf;exports.getApiClient=Hs;exports.initializeApiClient=ia;exports.useMutation=oa;exports.useQuery=sl;
|
|
148
|
+
`})]})}const af={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function cf({options:r,value:e,onChange:t,placeholder:n="Search or select...",allowCreate:s=!0,onCreate:o,allowDelete:i=!1,onDelete:l,label:u,disabled:a=!1,max:c=0,theme:f={},className:d=""}){const h={...af,...f},[p,m]=k.useState(!1),[x,C]=k.useState(""),_=k.useRef(null),E=k.useRef(null);k.useEffect(()=>{function T(N){_.current&&!_.current.contains(N.target)&&(m(!1),C(""))}return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const D=r.filter(T=>{var N;return((N=T.label)==null?void 0:N.toLowerCase().includes(x.toLowerCase()))&&!e.includes(T.id)}),A=s&&x.trim()&&!r.some(T=>{var N;return((N=T.label)==null?void 0:N.toLowerCase())===x.toLowerCase()}),v=e.map(T=>r.find(N=>N.id===T)).filter(Boolean),b=k.useCallback(T=>{var N;c>0&&e.length>=c||(t([...e,T]),C(""),(N=E.current)==null||N.focus())},[e,t,c]),w=k.useCallback(T=>{t(e.filter(N=>N!==T))},[e,t]),S=k.useCallback(async()=>{if(!A)return;const T=await(o==null?void 0:o(x.trim()));T&&b(T.id),C("")},[A,x,o,b]),R=k.useCallback(T=>{T.key==="Enter"?(T.preventDefault(),A?S():D.length>0&&b(D[0].id)):T.key==="Backspace"&&!x&&e.length>0?w(e[e.length-1]):T.key==="Escape"&&(m(!1),C(""))},[A,D,x,e,S,b,w]);return g.jsxs("div",{ref:_,className:d,style:{position:"relative"},children:[u&&g.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:h.textSecondary,marginBottom:"4px"},children:u}),g.jsxs("div",{onClick:()=>!a&&m(!0),style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px 12px",border:`1px solid ${p?h.primary:h.border}`,borderRadius:"8px",background:a?h.hoverBackground:h.background,cursor:a?"not-allowed":"text",minHeight:"42px",alignItems:"center"},children:[v.map(T=>g.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:T.color||h.chipBackground,color:T.color?"#fff":h.chipText},children:[T.label,!a&&g.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),w(T.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},T.id)),g.jsx("input",{ref:E,type:"text",value:x,onChange:T=>{C(T.target.value),p||m(!0)},onFocus:()=>m(!0),onKeyDown:R,placeholder:v.length===0?n:"",disabled:a||c>0&&e.length>=c,style:{flex:1,minWidth:"60px",border:"none",outline:"none",fontSize:"14px",background:"transparent",color:h.text}})]}),p&&!a&&g.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:h.background,border:`1px solid ${h.border}`,borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",maxHeight:"200px",overflowY:"auto",zIndex:50},children:D.length===0&&!A?g.jsx("div",{style:{padding:"12px",fontSize:"14px",color:h.textSecondary,textAlign:"center"},children:x?"No matches":"No options available"}):g.jsxs(g.Fragment,{children:[D.map(T=>g.jsxs("div",{onClick:()=>b(T.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:h.text,display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:N=>{N.currentTarget.style.background=h.hoverBackground||""},onMouseLeave:N=>{N.currentTarget.style.background=""},children:[T.label,i&&l&&g.jsx("button",{type:"button",onClick:N=>{N.stopPropagation(),l(T.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:h.textSecondary,opacity:.5},onMouseEnter:N=>{N.currentTarget.style.opacity="1",N.currentTarget.style.color="#ef4444"},onMouseLeave:N=>{N.currentTarget.style.opacity="0.5",N.currentTarget.style.color=h.textSecondary||""},children:"×"})]},T.id)),A&&g.jsxs("div",{onClick:S,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:h.primary,borderTop:D.length>0?`1px solid ${h.border}`:"none"},onMouseEnter:T=>{T.currentTarget.style.background=h.hoverBackground||""},onMouseLeave:T=>{T.currentTarget.style.background=""},children:['+ Create "',x.trim(),'"']})]})})]})}function df({items:r,columns:e,getItemId:t,getItemColumn:n,getItemOrder:s,renderItem:o,onItemMove:i,onItemReorder:l,onItemClick:u,renderColumnHeader:a,renderColumnFooter:c,className:f="",columnClassName:d="",itemClassName:h=""}){const[p,m]=k.useState(null),[x,C]=k.useState(null),[_,E]=k.useState(null),D=k.useRef(null),A=e.reduce((N,j)=>{let L=r.filter($=>n($)===j.id);return s&&(L=L.sort(($,H)=>s($)-s(H))),N[j.id]=L,N},{}),v=k.useCallback((N,j)=>{const L=t(j),$=n(j);m(L),D.current=$,N.dataTransfer.effectAllowed="move",N.dataTransfer.setData("text/plain",L),requestAnimationFrame(()=>{const H=N.target;H.style.opacity="0.5"})},[t,n]),b=k.useCallback(N=>{const j=N.target;j.style.opacity="1",m(null),C(null),E(null),D.current=null},[]),w=k.useCallback((N,j,L)=>{N.preventDefault(),N.dataTransfer.dropEffect="move",C(j),E(L)},[]),S=k.useCallback(N=>{const j=N.relatedTarget;j!=null&&j.closest("[data-kanban-column]")||(C(null),E(null))},[]),R=k.useCallback((N,j,L)=>{if(N.preventDefault(),!p)return;const $=D.current;$===j?l==null||l(p,j,L):$&&i(p,$,j,L),m(null),C(null),E(null),D.current=null},[p,i,l]),T=(N,j)=>g.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[g.jsxs("div",{className:"flex items-center gap-2",children:[N.color&&g.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:N.color}}),g.jsx("span",{className:"font-medium text-sm text-neutral-700",children:N.label})]}),g.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:j})]});return g.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${f}`,style:{minHeight:"400px"},children:e.map(N=>{const j=A[N.id]||[],L=x===N.id;return g.jsxs("div",{"data-kanban-column":N.id,className:`flex-1 min-w-[180px] bg-neutral-50 rounded-xl flex flex-col ${d}`,onDragOver:$=>{$.preventDefault(),p&&!L&&C(N.id)},onDragLeave:S,onDrop:$=>R($,N.id,_??j.length),children:[g.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:a?a(N,j.length):T(N,j.length)}),g.jsxs("div",{className:`flex-1 overflow-y-auto p-2 space-y-2 min-h-[100px] transition-colors ${L?"bg-blue-50":""}`,children:[j.map(($,H)=>{const ue=t($),re=p===ue,we=L&&_===H&&!re;return g.jsxs("div",{children:[we&&g.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),g.jsx("div",{draggable:!0,onDragStart:Ee=>v(Ee,$),onDragEnd:b,onDragOver:Ee=>w(Ee,N.id,H),onClick:()=>u==null?void 0:u($),className:`cursor-grab active:cursor-grabbing transition-all ${re?"opacity-50 scale-95":""} ${h}`,children:o($,re)})]},ue)}),g.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:$=>{$.preventDefault(),w($,N.id,j.length)},children:L&&_===j.length&&g.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),j.length===0&&L&&g.jsx("div",{className:"h-20 border-2 border-dashed border-blue-300 rounded-lg bg-blue-50/50 flex items-center justify-center",children:g.jsx("span",{className:"text-sm text-blue-400",children:"Drop here"})})]}),c&&g.jsx("div",{className:"flex-shrink-0 border-t border-neutral-200 p-2",children:c(N)})]},N.id)})})}const ff={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function hf(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function pf(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function gf(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function mf({items:r,date:e,startHour:t=7,endHour:n=22,hourHeight:s=60,getItemTime:o,getItemDuration:i,getItemIsAllDay:l,getItemId:u,renderItem:a,onItemClick:c,onTimeSlotClick:f,showCurrentTime:d=!0,className:h="",theme:p={}}){const m={...ff,...p},{allDayItems:x,timedItems:C}=k.useMemo(()=>{const b=[],w=[];for(const S of r)l(S)?b.push(S):w.push(S);return{allDayItems:b,timedItems:w}},[r,l]),_=k.useMemo(()=>{const b=[];for(let w=t;w<=n;w++)b.push(w);return b},[t,n]),E=(n-t+1)*s,D=k.useCallback(b=>{const w=o(b);if(!w)return null;const S=hf(w);if(!S)return null;const{hours:R,minutes:T}=S,N=Math.max(t,Math.min(n,R)),j=R<t?0:T,L=(N-t)*s+j/60*s,$=i(b),H=Math.max(20,$/60*s);return{top:L,height:H}},[o,i,t,n,s]),A=k.useMemo(()=>{if(!d||!gf(e))return null;const b=new Date,w=b.getHours(),S=b.getMinutes();return w<t||w>n?null:(w-t)*s+S/60*s},[e,d,t,n,s]),v=k.useCallback(b=>{if(!f)return;const w=b.currentTarget.getBoundingClientRect(),R=(b.clientY-w.top)/s*60,T=Math.floor(R/60)+t,N=Math.round(R%60/15)*15,j=Math.min(n,Math.max(t,T)),L=N>=60?0:N,$=`${j.toString().padStart(2,"0")}:${L.toString().padStart(2,"0")}`;f($)},[f,s,t,n]);return g.jsxs("div",{className:h,style:{background:m.background},children:[x.length>0&&g.jsxs("div",{style:{padding:"8px 0 8px 60px",borderBottom:`1px solid ${m.allDayBorder}`,background:m.allDayBackground},children:[g.jsx("div",{style:{fontSize:"11px",color:m.hourTextColor,marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"All Day"}),g.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:x.map(b=>g.jsx("div",{onClick:()=>c==null?void 0:c(b),style:{cursor:c?"pointer":"default"},children:a(b)},u(b)))})]}),g.jsxs("div",{style:{position:"relative",height:E},children:[_.map((b,w)=>g.jsxs("div",{style:{position:"absolute",top:w*s,left:0,right:0},children:[g.jsx("div",{style:{position:"absolute",left:0,top:-8,width:"50px",textAlign:"right",paddingRight:"10px",fontSize:"11px",color:m.hourTextColor},children:pf(b)}),g.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),w<_.length-1&&g.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:s/2,height:"1px",background:m.halfHourLineColor}})]},b)),g.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:f?"pointer":"default"},onClick:v}),A!==null&&g.jsxs("div",{style:{position:"absolute",left:"55px",right:0,top:A,zIndex:20,pointerEvents:"none"},children:[g.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",background:m.currentTimeColor,marginLeft:"-5px",marginTop:"-5px",position:"absolute"}}),g.jsx("div",{style:{marginLeft:"5px",height:"2px",background:m.currentTimeColor}})]}),C.map(b=>{const w=D(b);return w?g.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:w.top,height:w.height,zIndex:10,cursor:c?"pointer":"default"},onClick:S=>{S.stopPropagation(),c==null||c(b)},children:a(b)},u(b)):null})]})]})}exports.AnimatedCardFlip=ha;exports.ApiClient=nl;exports.AuthManager=rl;exports.Card=ca;exports.ComboBox=cf;exports.DataOperations=fn;exports.Detail=da;exports.GraphClient=$u;exports.KanbanBoard=df;exports.Mail=ga;exports.MailClient=tl;exports.MailComposer=uf;exports.MailEditor=Eu;exports.SelectableList=ma;exports.Stack=aa;exports.Timeline=mf;exports.getApiClient=Hs;exports.initializeApiClient=ia;exports.useMutation=oa;exports.useQuery=sl;
|