@qwanyx/stack 0.2.115 → 0.2.116

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 CHANGED
@@ -1,6 +1,6 @@
1
- "use strict";var Fd=Object.defineProperty;var Ld=(r,e,t)=>e in r?Fd(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var wt=(r,e,t)=>Ld(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react"),ma=require("react-dom");function Pd(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 ki=Pd(y);class Id{constructor(e){wt(this,"config");wt(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 o=await s.text();throw new Error(`API error (${s.status}): ${o}`)}const i=await s.json();if(!i.success&&i.error)throw new Error(i.error);return i}catch(s){throw console.error("Graph API call failed:",s),s}}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_auth_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 updateEdge(e,t,n,s){return await this.callGraph("update_edge",{source_id:e,target_id:t,edge_type:n,data:s})}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 o=s.result.split(",")[1];t(o)},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 i=new Image,o=URL.createObjectURL(e);i.onload=()=>{if(URL.revokeObjectURL(o),i.width<=t&&i.height<=t){s(e);return}let l,a;i.width>i.height?(l=t,a=Math.round(i.height/i.width*t)):(a=t,l=Math.round(i.width/i.height*t));const u=document.createElement("canvas");u.width=l,u.height=a;const c=u.getContext("2d");if(!c){s(e);return}c.drawImage(i,0,0,l,a);const d=e.type==="image/png"?"image/png":"image/jpeg";u.toBlob(h=>{if(h){const p=new File([h],e.name,{type:d});s(p)}else s(e)},d,n)},i.onerror=()=>{URL.revokeObjectURL(o),s(e)},i.src=o}):e}async uploadFile(e,t,n,s={}){const i={...this.defaultUploadOptions,...s};try{let o=n;i.maxImageDimension>0&&n.type.startsWith("image/")&&(o=await this.resizeImage(n,i.maxImageDimension,i.imageQuality));const l=i.maxSizeMB*1024*1024;if(o.size>l)return{success:!1,error:`File too large (${(o.size/1024/1024).toFixed(1)} MB). Max: ${i.maxSizeMB} MB`};const a=await this.fileToBase64(o),u=await this.callGraph("upload_file",{node_id:e,filename:t,content:a});return u.success?{success:!0,path:u.path}:{success:!1,error:u.error||"Upload failed"}}catch(o){return{success:!1,error:o instanceof Error?o.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(i=>({filename:i.name,path:i.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 Xr=new TextEncoder,ya="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bn=new Uint8Array(256);for(var os=0;os<ya.length;os++)bn[ya.charCodeAt(os)]=os;function Hi(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),i=new Uint8Array(s);for(let o=0;o<t;o+=4){let l=bn[r.charCodeAt(o)],a=bn[r.charCodeAt(o+1)],u=bn[r.charCodeAt(o+2)],c=bn[r.charCodeAt(o+3)];i[n++]=l<<2|a>>4,i[n++]=(a&15)<<4|u>>2,i[n++]=(u&3)<<6|c&63}return s}function kn(r){r=r||"utf8";let e;try{e=new TextDecoder(r)}catch{e=new TextDecoder("windows-1252")}return e}async function ni(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 xa(r){return r>=48&&r<=57||r>=97&&r<=102||r>=65&&r<=70?String.fromCharCode(r):!1}function zd(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 i=Xr.encode(t),o=[];for(let a=0,u=i.length;a<u;a++){let c=i[a];if(a<=u-2&&c===61){let d=xa(i[a+1]),h=xa(i[a+2]);if(d&&h){let p=parseInt(d+h,16);o.push(p),a+=2;continue}}o.push(c)}s=new ArrayBuffer(o.length);let l=new DataView(s);for(let a=0,u=o.length;a<u;a++)l.setUint8(a,o[a])}else e==="B"?s=Hi(t.replace(/[^a-zA-Z0-9\+\/=]+/g,"")):s=Xr.encode(t);return kn(r).decode(s)}function En(r){let e=!0;for(;;){let t=(r||"").toString().replace(/(=\?([^?]+)\?[Bb]\?([^?]*)\?=)\s*(?==\?([^?]+)\?[Bb]\?[^?]*\?=)/g,(n,s,i,o,l)=>e&&i===l&&o.length%4===0&&!/=$/.test(o)?s+"__\0JOIN\0__":n).replace(/(=\?([^?]+)\?[Qq]\?[^?]*\?=)\s*(?==\?([^?]+)\?[Qq]\?[^?]*\?=)/g,(n,s,i,o)=>e&&i===o?s+"__\0JOIN\0__":n).replace(/(\?=)?__\x00JOIN\x00__(=\?([^?]+)\?[QqBb]\?)?/g,"").replace(/(=\?[^?]+\?[QqBb]\?[^?]*\?=)\s+(?==\?[^?]+\?[QqBb]\?[^?]*\?=)/g,"$1").replace(/=\?([\w_\-*]+)\?([QqBb])\?([^?]*)\?=/g,(n,s,i,o)=>zd(s,i,o));if(e&&t.indexOf("�")>=0)e=!1;else return t}}function Od(r,e){e=e||"utf-8";let t=[];for(let i=0;i<r.length;i++){let o=r.charAt(i);if(o==="%"&&/^[a-f0-9]{2}/i.test(r.substr(i+1,2))){let l=r.substr(i+1,2);i+=2,t.push(parseInt(l,16))}else if(o.charCodeAt(0)>126){o=Xr.encode(o);for(let l=0;l<o.length;l++)t.push(o[l])}else t.push(o.charCodeAt(0))}const n=new ArrayBuffer(t.length),s=new DataView(n);for(let i=0,o=t.length;i<o;i++)s.setUint8(i,t[i]);return kn(e).decode(n)}function $d(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(),i=Number(n[2])||0,o;e.has(s)?o=e.get(s):(o={charset:!1,values:[]},e.set(s,o));let l=r.params[t];i===0&&n[0].charAt(n[0].length-1)==="*"&&(n=l.match(/^([^']*)'[^']*'(.*)$/))&&(o.charset=n[1]||"utf-8",l=n[2]),o.values.push({nr:i,value:l}),delete r.params[t]}),e.forEach((t,n)=>{r.params[n]=Od(t.values.sort((s,i)=>s.nr-i.nr).map(s=>s.value).join(""),t.charset)})}class qd{constructor(){this.chunks=[]}update(e){this.chunks.push(e),this.chunks.push(`
1
+ "use strict";var Fd=Object.defineProperty;var Ld=(r,e,t)=>e in r?Fd(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t;var _t=(r,e,t)=>Ld(r,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y=require("react"),ma=require("react-dom");function Pd(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 ki=Pd(y);class Id{constructor(e){_t(this,"config");_t(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 o=await s.text();throw new Error(`API error (${s.status}): ${o}`)}const i=await s.json();if(!i.success&&i.error)throw new Error(i.error);return i}catch(s){throw console.error("Graph API call failed:",s),s}}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_auth_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 updateEdge(e,t,n,s){return await this.callGraph("update_edge",{source_id:e,target_id:t,edge_type:n,data:s})}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 o=s.result.split(",")[1];t(o)},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 i=new Image,o=URL.createObjectURL(e);i.onload=()=>{if(URL.revokeObjectURL(o),i.width<=t&&i.height<=t){s(e);return}let a,l;i.width>i.height?(a=t,l=Math.round(i.height/i.width*t)):(l=t,a=Math.round(i.width/i.height*t));const u=document.createElement("canvas");u.width=a,u.height=l;const c=u.getContext("2d");if(!c){s(e);return}c.drawImage(i,0,0,a,l);const d=e.type==="image/png"?"image/png":"image/jpeg";u.toBlob(h=>{if(h){const p=new File([h],e.name,{type:d});s(p)}else s(e)},d,n)},i.onerror=()=>{URL.revokeObjectURL(o),s(e)},i.src=o}):e}async uploadFile(e,t,n,s={}){const i={...this.defaultUploadOptions,...s};try{let o=n;i.maxImageDimension>0&&n.type.startsWith("image/")&&(o=await this.resizeImage(n,i.maxImageDimension,i.imageQuality));const a=i.maxSizeMB*1024*1024;if(o.size>a)return{success:!1,error:`File too large (${(o.size/1024/1024).toFixed(1)} MB). Max: ${i.maxSizeMB} MB`};const l=await this.fileToBase64(o),u=await this.callGraph("upload_file",{node_id:e,filename:t,content:l});return u.success?{success:!0,path:u.path}:{success:!1,error:u.error||"Upload failed"}}catch(o){return{success:!1,error:o instanceof Error?o.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(i=>({filename:i.name,path:i.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 Xr=new TextEncoder,ya="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bn=new Uint8Array(256);for(var os=0;os<ya.length;os++)bn[ya.charCodeAt(os)]=os;function Hi(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),i=new Uint8Array(s);for(let o=0;o<t;o+=4){let a=bn[r.charCodeAt(o)],l=bn[r.charCodeAt(o+1)],u=bn[r.charCodeAt(o+2)],c=bn[r.charCodeAt(o+3)];i[n++]=a<<2|l>>4,i[n++]=(l&15)<<4|u>>2,i[n++]=(u&3)<<6|c&63}return s}function kn(r){r=r||"utf8";let e;try{e=new TextDecoder(r)}catch{e=new TextDecoder("windows-1252")}return e}async function ni(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 xa(r){return r>=48&&r<=57||r>=97&&r<=102||r>=65&&r<=70?String.fromCharCode(r):!1}function zd(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 i=Xr.encode(t),o=[];for(let l=0,u=i.length;l<u;l++){let c=i[l];if(l<=u-2&&c===61){let d=xa(i[l+1]),h=xa(i[l+2]);if(d&&h){let p=parseInt(d+h,16);o.push(p),l+=2;continue}}o.push(c)}s=new ArrayBuffer(o.length);let a=new DataView(s);for(let l=0,u=o.length;l<u;l++)a.setUint8(l,o[l])}else e==="B"?s=Hi(t.replace(/[^a-zA-Z0-9\+\/=]+/g,"")):s=Xr.encode(t);return kn(r).decode(s)}function En(r){let e=!0;for(;;){let t=(r||"").toString().replace(/(=\?([^?]+)\?[Bb]\?([^?]*)\?=)\s*(?==\?([^?]+)\?[Bb]\?[^?]*\?=)/g,(n,s,i,o,a)=>e&&i===a&&o.length%4===0&&!/=$/.test(o)?s+"__\0JOIN\0__":n).replace(/(=\?([^?]+)\?[Qq]\?[^?]*\?=)\s*(?==\?([^?]+)\?[Qq]\?[^?]*\?=)/g,(n,s,i,o)=>e&&i===o?s+"__\0JOIN\0__":n).replace(/(\?=)?__\x00JOIN\x00__(=\?([^?]+)\?[QqBb]\?)?/g,"").replace(/(=\?[^?]+\?[QqBb]\?[^?]*\?=)\s+(?==\?[^?]+\?[QqBb]\?[^?]*\?=)/g,"$1").replace(/=\?([\w_\-*]+)\?([QqBb])\?([^?]*)\?=/g,(n,s,i,o)=>zd(s,i,o));if(e&&t.indexOf("�")>=0)e=!1;else return t}}function Od(r,e){e=e||"utf-8";let t=[];for(let i=0;i<r.length;i++){let o=r.charAt(i);if(o==="%"&&/^[a-f0-9]{2}/i.test(r.substr(i+1,2))){let a=r.substr(i+1,2);i+=2,t.push(parseInt(a,16))}else if(o.charCodeAt(0)>126){o=Xr.encode(o);for(let a=0;a<o.length;a++)t.push(o[a])}else t.push(o.charCodeAt(0))}const n=new ArrayBuffer(t.length),s=new DataView(n);for(let i=0,o=t.length;i<o;i++)s.setUint8(i,t[i]);return kn(e).decode(n)}function $d(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(),i=Number(n[2])||0,o;e.has(s)?o=e.get(s):(o={charset:!1,values:[]},e.set(s,o));let a=r.params[t];i===0&&n[0].charAt(n[0].length-1)==="*"&&(n=a.match(/^([^']*)'[^']*'(.*)$/))&&(o.charset=n[1]||"utf-8",a=n[2]),o.values.push({nr:i,value:a}),delete r.params[t]}),e.forEach((t,n)=>{r.params[n]=Od(t.values.sort((s,i)=>s.nr-i.nr).map(s=>s.value).join(""),t.charset)})}class qd{constructor(){this.chunks=[]}update(e){this.chunks.push(e),this.chunks.push(`
2
2
  `)}finalize(){return ni(new Blob(this.chunks,{type:"application/octet-stream"}))}}class Ud{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(Hi(s))}}finalize(){return this.remainder&&!/^=+$/.test(this.remainder)&&this.chunks.push(Hi(this.remainder)),ni(new Blob(this.chunks,{type:"application/octet-stream"}))}}const ba=/^=[a-f0-9]{2}$/i,Wd=/(?==[a-f0-9]{2})/i,Hd=/=\r?\n/g,Vd=/=[a-fA-F0-9]?$/;class Gd{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,i=e.length;s<i;s++)n.setUint8(s,parseInt(e[s],16));return t}decodeChunks(e){e=e.replace(Hd,"");let t=e.split(Wd),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){ba.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 i=s.substr(0,3);ba.test(i)?(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
- `;if(t=this.remainder+t,t.length<this.maxChunkSize){this.remainder=t;return}this.remainder="";let n=t.match(Vd);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=""),ni(new Blob(this.chunks,{type:"application/octet-stream"}))}}class va{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 Ud:/quoted-printable/i.test(e)?this.contentDecoder=new Gd({decoder:kn(this.contentType.parsed.params.charset)}):this.contentDecoder=new qd}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="",i="value",o=!1,l=!1,a;for(let u=0,c=e.length;u<c;u++)switch(a=e.charAt(u),i){case"key":if(a==="="){n=s.trim().toLowerCase(),i="value",s="";break}s+=a;break;case"value":if(l)s+=a;else if(a==="\\"){l=!0;continue}else o&&a===o?o=!1:!o&&a==='"'?o=a:!o&&a===";"?(n===!1?t.value=s.trim():t.params[n]=s.trim(),i="key",s=""):s+=a;l=!1;break}return s=s.trim(),i==="value"?n===!1?t.value=s:t.params[n]=s:s&&(t.params[s.toLowerCase()]=""),t.value&&(t.value=t.value.toLowerCase()),$d(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+`
3
+ `;if(t=this.remainder+t,t.length<this.maxChunkSize){this.remainder=t;return}this.remainder="";let n=t.match(Vd);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=""),ni(new Blob(this.chunks,{type:"application/octet-stream"}))}}class va{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 Ud:/quoted-printable/i.test(e)?this.contentDecoder=new Gd({decoder:kn(this.contentType.parsed.params.charset)}):this.contentDecoder=new qd}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="",i="value",o=!1,a=!1,l;for(let u=0,c=e.length;u<c;u++)switch(l=e.charAt(u),i){case"key":if(l==="="){n=s.trim().toLowerCase(),i="value",s="";break}s+=l;break;case"value":if(a)s+=l;else if(l==="\\"){a=!0;continue}else o&&l===o?o=!1:!o&&l==='"'?o=l:!o&&l===";"?(n===!1?t.value=s.trim():t.params[n]=s.trim(),i="key",s=""):s+=l;a=!1;break}return s=s.trim(),i==="value"?n===!1?t.value=s:t.params[n]=s:s&&(t.params[s.toLowerCase()]=""),t.value&&(t.value=t.value.toLowerCase()),$d(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=kn(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]+=`
5
5
  `+t,this.headerLines.splice(e,1);else{t=t.replace(/\s+/g," ");let n=t.indexOf(":"),s=n<0?t.trim():t.substr(0,n).trim(),i=n<0?"":t.substr(n+1).trim();switch(this.headers.push({key:s.toLowerCase(),originalKey:s,value:i}),s.toLowerCase()){case"content-type":this.contentType.default&&(this.contentType={value:i,parsed:{}});break;case"content-transfer-encoding":this.contentTransferEncoding={value:i,parsed:{}};break;case"content-disposition":this.contentDisposition={value:i,parsed:{}};break;case"content-id":this.contentId=i;break;case"content-description":this.contentDescription=i;break}}}this.contentType.parsed=this.parseStructuredHeader(this.contentType.value),this.contentType.multipart=/^multipart\//i.test(this.contentType.parsed.value)?this.contentType.parsed.value.substr(this.contentType.parsed.value.indexOf("/")+1):!1,this.contentType.multipart&&this.contentType.parsed.params.boundary&&this.postalMime.boundaries.push({value:Xr.encode(this.contentType.parsed.params.boundary),node:this}),this.contentDisposition.parsed=this.parseStructuredHeader(this.contentDisposition.value),this.contentTransferEncoding.encoding=this.contentTransferEncoding.value.toLowerCase().split(/[^\w-]/).shift(),this.setupContentDecoder(this.contentTransferEncoding.encoding)}feed(e){switch(this.state){case"header":if(!e.length)return this.state="body",this.processHeaders();if(this.headerSize+=e.length,this.headerSize>this.options.maxHeadersSize)throw new Error(`Maximum header size of ${this.options.maxHeadersSize} bytes exceeded`);this.headerLines.push(kn().decode(e));break;case"body":this.contentDecoder.update(e)}}}const _a={"&AElig":"Æ","&AElig;":"Æ","&AMP":"&","&AMP;":"&","&Aacute":"Á","&Aacute;":"Á","&Abreve;":"Ă","&Acirc":"Â","&Acirc;":"Â","&Acy;":"А","&Afr;":"𝔄","&Agrave":"À","&Agrave;":"À","&Alpha;":"Α","&Amacr;":"Ā","&And;":"⩓","&Aogon;":"Ą","&Aopf;":"𝔸","&ApplyFunction;":"⁡","&Aring":"Å","&Aring;":"Å","&Ascr;":"𝒜","&Assign;":"≔","&Atilde":"Ã","&Atilde;":"Ã","&Auml":"Ä","&Auml;":"Ä","&Backslash;":"∖","&Barv;":"⫧","&Barwed;":"⌆","&Bcy;":"Б","&Because;":"∵","&Bernoullis;":"ℬ","&Beta;":"Β","&Bfr;":"𝔅","&Bopf;":"𝔹","&Breve;":"˘","&Bscr;":"ℬ","&Bumpeq;":"≎","&CHcy;":"Ч","&COPY":"©","&COPY;":"©","&Cacute;":"Ć","&Cap;":"⋒","&CapitalDifferentialD;":"ⅅ","&Cayleys;":"ℭ","&Ccaron;":"Č","&Ccedil":"Ç","&Ccedil;":"Ç","&Ccirc;":"Ĉ","&Cconint;":"∰","&Cdot;":"Ċ","&Cedilla;":"¸","&CenterDot;":"·","&Cfr;":"ℭ","&Chi;":"Χ","&CircleDot;":"⊙","&CircleMinus;":"⊖","&CirclePlus;":"⊕","&CircleTimes;":"⊗","&ClockwiseContourIntegral;":"∲","&CloseCurlyDoubleQuote;":"”","&CloseCurlyQuote;":"’","&Colon;":"∷","&Colone;":"⩴","&Congruent;":"≡","&Conint;":"∯","&ContourIntegral;":"∮","&Copf;":"ℂ","&Coproduct;":"∐","&CounterClockwiseContourIntegral;":"∳","&Cross;":"⨯","&Cscr;":"𝒞","&Cup;":"⋓","&CupCap;":"≍","&DD;":"ⅅ","&DDotrahd;":"⤑","&DJcy;":"Ђ","&DScy;":"Ѕ","&DZcy;":"Џ","&Dagger;":"‡","&Darr;":"↡","&Dashv;":"⫤","&Dcaron;":"Ď","&Dcy;":"Д","&Del;":"∇","&Delta;":"Δ","&Dfr;":"𝔇","&DiacriticalAcute;":"´","&DiacriticalDot;":"˙","&DiacriticalDoubleAcute;":"˝","&DiacriticalGrave;":"`","&DiacriticalTilde;":"˜","&Diamond;":"⋄","&DifferentialD;":"ⅆ","&Dopf;":"𝔻","&Dot;":"¨","&DotDot;":"⃜","&DotEqual;":"≐","&DoubleContourIntegral;":"∯","&DoubleDot;":"¨","&DoubleDownArrow;":"⇓","&DoubleLeftArrow;":"⇐","&DoubleLeftRightArrow;":"⇔","&DoubleLeftTee;":"⫤","&DoubleLongLeftArrow;":"⟸","&DoubleLongLeftRightArrow;":"⟺","&DoubleLongRightArrow;":"⟹","&DoubleRightArrow;":"⇒","&DoubleRightTee;":"⊨","&DoubleUpArrow;":"⇑","&DoubleUpDownArrow;":"⇕","&DoubleVerticalBar;":"∥","&DownArrow;":"↓","&DownArrowBar;":"⤓","&DownArrowUpArrow;":"⇵","&DownBreve;":"̑","&DownLeftRightVector;":"⥐","&DownLeftTeeVector;":"⥞","&DownLeftVector;":"↽","&DownLeftVectorBar;":"⥖","&DownRightTeeVector;":"⥟","&DownRightVector;":"⇁","&DownRightVectorBar;":"⥗","&DownTee;":"⊤","&DownTeeArrow;":"↧","&Downarrow;":"⇓","&Dscr;":"𝒟","&Dstrok;":"Đ","&ENG;":"Ŋ","&ETH":"Ð","&ETH;":"Ð","&Eacute":"É","&Eacute;":"É","&Ecaron;":"Ě","&Ecirc":"Ê","&Ecirc;":"Ê","&Ecy;":"Э","&Edot;":"Ė","&Efr;":"𝔈","&Egrave":"È","&Egrave;":"È","&Element;":"∈","&Emacr;":"Ē","&EmptySmallSquare;":"◻","&EmptyVerySmallSquare;":"▫","&Eogon;":"Ę","&Eopf;":"𝔼","&Epsilon;":"Ε","&Equal;":"⩵","&EqualTilde;":"≂","&Equilibrium;":"⇌","&Escr;":"ℰ","&Esim;":"⩳","&Eta;":"Η","&Euml":"Ë","&Euml;":"Ë","&Exists;":"∃","&ExponentialE;":"ⅇ","&Fcy;":"Ф","&Ffr;":"𝔉","&FilledSmallSquare;":"◼","&FilledVerySmallSquare;":"▪","&Fopf;":"𝔽","&ForAll;":"∀","&Fouriertrf;":"ℱ","&Fscr;":"ℱ","&GJcy;":"Ѓ","&GT":">","&GT;":">","&Gamma;":"Γ","&Gammad;":"Ϝ","&Gbreve;":"Ğ","&Gcedil;":"Ģ","&Gcirc;":"Ĝ","&Gcy;":"Г","&Gdot;":"Ġ","&Gfr;":"𝔊","&Gg;":"⋙","&Gopf;":"𝔾","&GreaterEqual;":"≥","&GreaterEqualLess;":"⋛","&GreaterFullEqual;":"≧","&GreaterGreater;":"⪢","&GreaterLess;":"≷","&GreaterSlantEqual;":"⩾","&GreaterTilde;":"≳","&Gscr;":"𝒢","&Gt;":"≫","&HARDcy;":"Ъ","&Hacek;":"ˇ","&Hat;":"^","&Hcirc;":"Ĥ","&Hfr;":"ℌ","&HilbertSpace;":"ℋ","&Hopf;":"ℍ","&HorizontalLine;":"─","&Hscr;":"ℋ","&Hstrok;":"Ħ","&HumpDownHump;":"≎","&HumpEqual;":"≏","&IEcy;":"Е","&IJlig;":"IJ","&IOcy;":"Ё","&Iacute":"Í","&Iacute;":"Í","&Icirc":"Î","&Icirc;":"Î","&Icy;":"И","&Idot;":"İ","&Ifr;":"ℑ","&Igrave":"Ì","&Igrave;":"Ì","&Im;":"ℑ","&Imacr;":"Ī","&ImaginaryI;":"ⅈ","&Implies;":"⇒","&Int;":"∬","&Integral;":"∫","&Intersection;":"⋂","&InvisibleComma;":"⁣","&InvisibleTimes;":"⁢","&Iogon;":"Į","&Iopf;":"𝕀","&Iota;":"Ι","&Iscr;":"ℐ","&Itilde;":"Ĩ","&Iukcy;":"І","&Iuml":"Ï","&Iuml;":"Ï","&Jcirc;":"Ĵ","&Jcy;":"Й","&Jfr;":"𝔍","&Jopf;":"𝕁","&Jscr;":"𝒥","&Jsercy;":"Ј","&Jukcy;":"Є","&KHcy;":"Х","&KJcy;":"Ќ","&Kappa;":"Κ","&Kcedil;":"Ķ","&Kcy;":"К","&Kfr;":"𝔎","&Kopf;":"𝕂","&Kscr;":"𝒦","&LJcy;":"Љ","&LT":"<","&LT;":"<","&Lacute;":"Ĺ","&Lambda;":"Λ","&Lang;":"⟪","&Laplacetrf;":"ℒ","&Larr;":"↞","&Lcaron;":"Ľ","&Lcedil;":"Ļ","&Lcy;":"Л","&LeftAngleBracket;":"⟨","&LeftArrow;":"←","&LeftArrowBar;":"⇤","&LeftArrowRightArrow;":"⇆","&LeftCeiling;":"⌈","&LeftDoubleBracket;":"⟦","&LeftDownTeeVector;":"⥡","&LeftDownVector;":"⇃","&LeftDownVectorBar;":"⥙","&LeftFloor;":"⌊","&LeftRightArrow;":"↔","&LeftRightVector;":"⥎","&LeftTee;":"⊣","&LeftTeeArrow;":"↤","&LeftTeeVector;":"⥚","&LeftTriangle;":"⊲","&LeftTriangleBar;":"⧏","&LeftTriangleEqual;":"⊴","&LeftUpDownVector;":"⥑","&LeftUpTeeVector;":"⥠","&LeftUpVector;":"↿","&LeftUpVectorBar;":"⥘","&LeftVector;":"↼","&LeftVectorBar;":"⥒","&Leftarrow;":"⇐","&Leftrightarrow;":"⇔","&LessEqualGreater;":"⋚","&LessFullEqual;":"≦","&LessGreater;":"≶","&LessLess;":"⪡","&LessSlantEqual;":"⩽","&LessTilde;":"≲","&Lfr;":"𝔏","&Ll;":"⋘","&Lleftarrow;":"⇚","&Lmidot;":"Ŀ","&LongLeftArrow;":"⟵","&LongLeftRightArrow;":"⟷","&LongRightArrow;":"⟶","&Longleftarrow;":"⟸","&Longleftrightarrow;":"⟺","&Longrightarrow;":"⟹","&Lopf;":"𝕃","&LowerLeftArrow;":"↙","&LowerRightArrow;":"↘","&Lscr;":"ℒ","&Lsh;":"↰","&Lstrok;":"Ł","&Lt;":"≪","&Map;":"⤅","&Mcy;":"М","&MediumSpace;":" ","&Mellintrf;":"ℳ","&Mfr;":"𝔐","&MinusPlus;":"∓","&Mopf;":"𝕄","&Mscr;":"ℳ","&Mu;":"Μ","&NJcy;":"Њ","&Nacute;":"Ń","&Ncaron;":"Ň","&Ncedil;":"Ņ","&Ncy;":"Н","&NegativeMediumSpace;":"​","&NegativeThickSpace;":"​","&NegativeThinSpace;":"​","&NegativeVeryThinSpace;":"​","&NestedGreaterGreater;":"≫","&NestedLessLess;":"≪","&NewLine;":`
6
6
  `,"&Nfr;":"𝔑","&NoBreak;":"⁠","&NonBreakingSpace;":" ","&Nopf;":"ℕ","&Not;":"⫬","&NotCongruent;":"≢","&NotCupCap;":"≭","&NotDoubleVerticalBar;":"∦","&NotElement;":"∉","&NotEqual;":"≠","&NotEqualTilde;":"≂̸","&NotExists;":"∄","&NotGreater;":"≯","&NotGreaterEqual;":"≱","&NotGreaterFullEqual;":"≧̸","&NotGreaterGreater;":"≫̸","&NotGreaterLess;":"≹","&NotGreaterSlantEqual;":"⩾̸","&NotGreaterTilde;":"≵","&NotHumpDownHump;":"≎̸","&NotHumpEqual;":"≏̸","&NotLeftTriangle;":"⋪","&NotLeftTriangleBar;":"⧏̸","&NotLeftTriangleEqual;":"⋬","&NotLess;":"≮","&NotLessEqual;":"≰","&NotLessGreater;":"≸","&NotLessLess;":"≪̸","&NotLessSlantEqual;":"⩽̸","&NotLessTilde;":"≴","&NotNestedGreaterGreater;":"⪢̸","&NotNestedLessLess;":"⪡̸","&NotPrecedes;":"⊀","&NotPrecedesEqual;":"⪯̸","&NotPrecedesSlantEqual;":"⋠","&NotReverseElement;":"∌","&NotRightTriangle;":"⋫","&NotRightTriangleBar;":"⧐̸","&NotRightTriangleEqual;":"⋭","&NotSquareSubset;":"⊏̸","&NotSquareSubsetEqual;":"⋢","&NotSquareSuperset;":"⊐̸","&NotSquareSupersetEqual;":"⋣","&NotSubset;":"⊂⃒","&NotSubsetEqual;":"⊈","&NotSucceeds;":"⊁","&NotSucceedsEqual;":"⪰̸","&NotSucceedsSlantEqual;":"⋡","&NotSucceedsTilde;":"≿̸","&NotSuperset;":"⊃⃒","&NotSupersetEqual;":"⊉","&NotTilde;":"≁","&NotTildeEqual;":"≄","&NotTildeFullEqual;":"≇","&NotTildeTilde;":"≉","&NotVerticalBar;":"∤","&Nscr;":"𝒩","&Ntilde":"Ñ","&Ntilde;":"Ñ","&Nu;":"Ν","&OElig;":"Œ","&Oacute":"Ó","&Oacute;":"Ó","&Ocirc":"Ô","&Ocirc;":"Ô","&Ocy;":"О","&Odblac;":"Ő","&Ofr;":"𝔒","&Ograve":"Ò","&Ograve;":"Ò","&Omacr;":"Ō","&Omega;":"Ω","&Omicron;":"Ο","&Oopf;":"𝕆","&OpenCurlyDoubleQuote;":"“","&OpenCurlyQuote;":"‘","&Or;":"⩔","&Oscr;":"𝒪","&Oslash":"Ø","&Oslash;":"Ø","&Otilde":"Õ","&Otilde;":"Õ","&Otimes;":"⨷","&Ouml":"Ö","&Ouml;":"Ö","&OverBar;":"‾","&OverBrace;":"⏞","&OverBracket;":"⎴","&OverParenthesis;":"⏜","&PartialD;":"∂","&Pcy;":"П","&Pfr;":"𝔓","&Phi;":"Φ","&Pi;":"Π","&PlusMinus;":"±","&Poincareplane;":"ℌ","&Popf;":"ℙ","&Pr;":"⪻","&Precedes;":"≺","&PrecedesEqual;":"⪯","&PrecedesSlantEqual;":"≼","&PrecedesTilde;":"≾","&Prime;":"″","&Product;":"∏","&Proportion;":"∷","&Proportional;":"∝","&Pscr;":"𝒫","&Psi;":"Ψ","&QUOT":'"',"&QUOT;":'"',"&Qfr;":"𝔔","&Qopf;":"ℚ","&Qscr;":"𝒬","&RBarr;":"⤐","&REG":"®","&REG;":"®","&Racute;":"Ŕ","&Rang;":"⟫","&Rarr;":"↠","&Rarrtl;":"⤖","&Rcaron;":"Ř","&Rcedil;":"Ŗ","&Rcy;":"Р","&Re;":"ℜ","&ReverseElement;":"∋","&ReverseEquilibrium;":"⇋","&ReverseUpEquilibrium;":"⥯","&Rfr;":"ℜ","&Rho;":"Ρ","&RightAngleBracket;":"⟩","&RightArrow;":"→","&RightArrowBar;":"⇥","&RightArrowLeftArrow;":"⇄","&RightCeiling;":"⌉","&RightDoubleBracket;":"⟧","&RightDownTeeVector;":"⥝","&RightDownVector;":"⇂","&RightDownVectorBar;":"⥕","&RightFloor;":"⌋","&RightTee;":"⊢","&RightTeeArrow;":"↦","&RightTeeVector;":"⥛","&RightTriangle;":"⊳","&RightTriangleBar;":"⧐","&RightTriangleEqual;":"⊵","&RightUpDownVector;":"⥏","&RightUpTeeVector;":"⥜","&RightUpVector;":"↾","&RightUpVectorBar;":"⥔","&RightVector;":"⇀","&RightVectorBar;":"⥓","&Rightarrow;":"⇒","&Ropf;":"ℝ","&RoundImplies;":"⥰","&Rrightarrow;":"⇛","&Rscr;":"ℛ","&Rsh;":"↱","&RuleDelayed;":"⧴","&SHCHcy;":"Щ","&SHcy;":"Ш","&SOFTcy;":"Ь","&Sacute;":"Ś","&Sc;":"⪼","&Scaron;":"Š","&Scedil;":"Ş","&Scirc;":"Ŝ","&Scy;":"С","&Sfr;":"𝔖","&ShortDownArrow;":"↓","&ShortLeftArrow;":"←","&ShortRightArrow;":"→","&ShortUpArrow;":"↑","&Sigma;":"Σ","&SmallCircle;":"∘","&Sopf;":"𝕊","&Sqrt;":"√","&Square;":"□","&SquareIntersection;":"⊓","&SquareSubset;":"⊏","&SquareSubsetEqual;":"⊑","&SquareSuperset;":"⊐","&SquareSupersetEqual;":"⊒","&SquareUnion;":"⊔","&Sscr;":"𝒮","&Star;":"⋆","&Sub;":"⋐","&Subset;":"⋐","&SubsetEqual;":"⊆","&Succeeds;":"≻","&SucceedsEqual;":"⪰","&SucceedsSlantEqual;":"≽","&SucceedsTilde;":"≿","&SuchThat;":"∋","&Sum;":"∑","&Sup;":"⋑","&Superset;":"⊃","&SupersetEqual;":"⊇","&Supset;":"⋑","&THORN":"Þ","&THORN;":"Þ","&TRADE;":"™","&TSHcy;":"Ћ","&TScy;":"Ц","&Tab;":" ","&Tau;":"Τ","&Tcaron;":"Ť","&Tcedil;":"Ţ","&Tcy;":"Т","&Tfr;":"𝔗","&Therefore;":"∴","&Theta;":"Θ","&ThickSpace;":"  ","&ThinSpace;":" ","&Tilde;":"∼","&TildeEqual;":"≃","&TildeFullEqual;":"≅","&TildeTilde;":"≈","&Topf;":"𝕋","&TripleDot;":"⃛","&Tscr;":"𝒯","&Tstrok;":"Ŧ","&Uacute":"Ú","&Uacute;":"Ú","&Uarr;":"↟","&Uarrocir;":"⥉","&Ubrcy;":"Ў","&Ubreve;":"Ŭ","&Ucirc":"Û","&Ucirc;":"Û","&Ucy;":"У","&Udblac;":"Ű","&Ufr;":"𝔘","&Ugrave":"Ù","&Ugrave;":"Ù","&Umacr;":"Ū","&UnderBar;":"_","&UnderBrace;":"⏟","&UnderBracket;":"⎵","&UnderParenthesis;":"⏝","&Union;":"⋃","&UnionPlus;":"⊎","&Uogon;":"Ų","&Uopf;":"𝕌","&UpArrow;":"↑","&UpArrowBar;":"⤒","&UpArrowDownArrow;":"⇅","&UpDownArrow;":"↕","&UpEquilibrium;":"⥮","&UpTee;":"⊥","&UpTeeArrow;":"↥","&Uparrow;":"⇑","&Updownarrow;":"⇕","&UpperLeftArrow;":"↖","&UpperRightArrow;":"↗","&Upsi;":"ϒ","&Upsilon;":"Υ","&Uring;":"Ů","&Uscr;":"𝒰","&Utilde;":"Ũ","&Uuml":"Ü","&Uuml;":"Ü","&VDash;":"⊫","&Vbar;":"⫫","&Vcy;":"В","&Vdash;":"⊩","&Vdashl;":"⫦","&Vee;":"⋁","&Verbar;":"‖","&Vert;":"‖","&VerticalBar;":"∣","&VerticalLine;":"|","&VerticalSeparator;":"❘","&VerticalTilde;":"≀","&VeryThinSpace;":" ","&Vfr;":"𝔙","&Vopf;":"𝕍","&Vscr;":"𝒱","&Vvdash;":"⊪","&Wcirc;":"Ŵ","&Wedge;":"⋀","&Wfr;":"𝔚","&Wopf;":"𝕎","&Wscr;":"𝒲","&Xfr;":"𝔛","&Xi;":"Ξ","&Xopf;":"𝕏","&Xscr;":"𝒳","&YAcy;":"Я","&YIcy;":"Ї","&YUcy;":"Ю","&Yacute":"Ý","&Yacute;":"Ý","&Ycirc;":"Ŷ","&Ycy;":"Ы","&Yfr;":"𝔜","&Yopf;":"𝕐","&Yscr;":"𝒴","&Yuml;":"Ÿ","&ZHcy;":"Ж","&Zacute;":"Ź","&Zcaron;":"Ž","&Zcy;":"З","&Zdot;":"Ż","&ZeroWidthSpace;":"​","&Zeta;":"Ζ","&Zfr;":"ℨ","&Zopf;":"ℤ","&Zscr;":"𝒵","&aacute":"á","&aacute;":"á","&abreve;":"ă","&ac;":"∾","&acE;":"∾̳","&acd;":"∿","&acirc":"â","&acirc;":"â","&acute":"´","&acute;":"´","&acy;":"а","&aelig":"æ","&aelig;":"æ","&af;":"⁡","&afr;":"𝔞","&agrave":"à","&agrave;":"à","&alefsym;":"ℵ","&aleph;":"ℵ","&alpha;":"α","&amacr;":"ā","&amalg;":"⨿","&amp":"&","&amp;":"&","&and;":"∧","&andand;":"⩕","&andd;":"⩜","&andslope;":"⩘","&andv;":"⩚","&ang;":"∠","&ange;":"⦤","&angle;":"∠","&angmsd;":"∡","&angmsdaa;":"⦨","&angmsdab;":"⦩","&angmsdac;":"⦪","&angmsdad;":"⦫","&angmsdae;":"⦬","&angmsdaf;":"⦭","&angmsdag;":"⦮","&angmsdah;":"⦯","&angrt;":"∟","&angrtvb;":"⊾","&angrtvbd;":"⦝","&angsph;":"∢","&angst;":"Å","&angzarr;":"⍼","&aogon;":"ą","&aopf;":"𝕒","&ap;":"≈","&apE;":"⩰","&apacir;":"⩯","&ape;":"≊","&apid;":"≋","&apos;":"'","&approx;":"≈","&approxeq;":"≊","&aring":"å","&aring;":"å","&ascr;":"𝒶","&ast;":"*","&asymp;":"≈","&asympeq;":"≍","&atilde":"ã","&atilde;":"ã","&auml":"ä","&auml;":"ä","&awconint;":"∳","&awint;":"⨑","&bNot;":"⫭","&backcong;":"≌","&backepsilon;":"϶","&backprime;":"‵","&backsim;":"∽","&backsimeq;":"⋍","&barvee;":"⊽","&barwed;":"⌅","&barwedge;":"⌅","&bbrk;":"⎵","&bbrktbrk;":"⎶","&bcong;":"≌","&bcy;":"б","&bdquo;":"„","&becaus;":"∵","&because;":"∵","&bemptyv;":"⦰","&bepsi;":"϶","&bernou;":"ℬ","&beta;":"β","&beth;":"ℶ","&between;":"≬","&bfr;":"𝔟","&bigcap;":"⋂","&bigcirc;":"◯","&bigcup;":"⋃","&bigodot;":"⨀","&bigoplus;":"⨁","&bigotimes;":"⨂","&bigsqcup;":"⨆","&bigstar;":"★","&bigtriangledown;":"▽","&bigtriangleup;":"△","&biguplus;":"⨄","&bigvee;":"⋁","&bigwedge;":"⋀","&bkarow;":"⤍","&blacklozenge;":"⧫","&blacksquare;":"▪","&blacktriangle;":"▴","&blacktriangledown;":"▾","&blacktriangleleft;":"◂","&blacktriangleright;":"▸","&blank;":"␣","&blk12;":"▒","&blk14;":"░","&blk34;":"▓","&block;":"█","&bne;":"=⃥","&bnequiv;":"≡⃥","&bnot;":"⌐","&bopf;":"𝕓","&bot;":"⊥","&bottom;":"⊥","&bowtie;":"⋈","&boxDL;":"╗","&boxDR;":"╔","&boxDl;":"╖","&boxDr;":"╓","&boxH;":"═","&boxHD;":"╦","&boxHU;":"╩","&boxHd;":"╤","&boxHu;":"╧","&boxUL;":"╝","&boxUR;":"╚","&boxUl;":"╜","&boxUr;":"╙","&boxV;":"║","&boxVH;":"╬","&boxVL;":"╣","&boxVR;":"╠","&boxVh;":"╫","&boxVl;":"╢","&boxVr;":"╟","&boxbox;":"⧉","&boxdL;":"╕","&boxdR;":"╒","&boxdl;":"┐","&boxdr;":"┌","&boxh;":"─","&boxhD;":"╥","&boxhU;":"╨","&boxhd;":"┬","&boxhu;":"┴","&boxminus;":"⊟","&boxplus;":"⊞","&boxtimes;":"⊠","&boxuL;":"╛","&boxuR;":"╘","&boxul;":"┘","&boxur;":"└","&boxv;":"│","&boxvH;":"╪","&boxvL;":"╡","&boxvR;":"╞","&boxvh;":"┼","&boxvl;":"┤","&boxvr;":"├","&bprime;":"‵","&breve;":"˘","&brvbar":"¦","&brvbar;":"¦","&bscr;":"𝒷","&bsemi;":"⁏","&bsim;":"∽","&bsime;":"⋍","&bsol;":"\\","&bsolb;":"⧅","&bsolhsub;":"⟈","&bull;":"•","&bullet;":"•","&bump;":"≎","&bumpE;":"⪮","&bumpe;":"≏","&bumpeq;":"≏","&cacute;":"ć","&cap;":"∩","&capand;":"⩄","&capbrcup;":"⩉","&capcap;":"⩋","&capcup;":"⩇","&capdot;":"⩀","&caps;":"∩︀","&caret;":"⁁","&caron;":"ˇ","&ccaps;":"⩍","&ccaron;":"č","&ccedil":"ç","&ccedil;":"ç","&ccirc;":"ĉ","&ccups;":"⩌","&ccupssm;":"⩐","&cdot;":"ċ","&cedil":"¸","&cedil;":"¸","&cemptyv;":"⦲","&cent":"¢","&cent;":"¢","&centerdot;":"·","&cfr;":"𝔠","&chcy;":"ч","&check;":"✓","&checkmark;":"✓","&chi;":"χ","&cir;":"○","&cirE;":"⧃","&circ;":"ˆ","&circeq;":"≗","&circlearrowleft;":"↺","&circlearrowright;":"↻","&circledR;":"®","&circledS;":"Ⓢ","&circledast;":"⊛","&circledcirc;":"⊚","&circleddash;":"⊝","&cire;":"≗","&cirfnint;":"⨐","&cirmid;":"⫯","&cirscir;":"⧂","&clubs;":"♣","&clubsuit;":"♣","&colon;":":","&colone;":"≔","&coloneq;":"≔","&comma;":",","&commat;":"@","&comp;":"∁","&compfn;":"∘","&complement;":"∁","&complexes;":"ℂ","&cong;":"≅","&congdot;":"⩭","&conint;":"∮","&copf;":"𝕔","&coprod;":"∐","&copy":"©","&copy;":"©","&copysr;":"℗","&crarr;":"↵","&cross;":"✗","&cscr;":"𝒸","&csub;":"⫏","&csube;":"⫑","&csup;":"⫐","&csupe;":"⫒","&ctdot;":"⋯","&cudarrl;":"⤸","&cudarrr;":"⤵","&cuepr;":"⋞","&cuesc;":"⋟","&cularr;":"↶","&cularrp;":"⤽","&cup;":"∪","&cupbrcap;":"⩈","&cupcap;":"⩆","&cupcup;":"⩊","&cupdot;":"⊍","&cupor;":"⩅","&cups;":"∪︀","&curarr;":"↷","&curarrm;":"⤼","&curlyeqprec;":"⋞","&curlyeqsucc;":"⋟","&curlyvee;":"⋎","&curlywedge;":"⋏","&curren":"¤","&curren;":"¤","&curvearrowleft;":"↶","&curvearrowright;":"↷","&cuvee;":"⋎","&cuwed;":"⋏","&cwconint;":"∲","&cwint;":"∱","&cylcty;":"⌭","&dArr;":"⇓","&dHar;":"⥥","&dagger;":"†","&daleth;":"ℸ","&darr;":"↓","&dash;":"‐","&dashv;":"⊣","&dbkarow;":"⤏","&dblac;":"˝","&dcaron;":"ď","&dcy;":"д","&dd;":"ⅆ","&ddagger;":"‡","&ddarr;":"⇊","&ddotseq;":"⩷","&deg":"°","&deg;":"°","&delta;":"δ","&demptyv;":"⦱","&dfisht;":"⥿","&dfr;":"𝔡","&dharl;":"⇃","&dharr;":"⇂","&diam;":"⋄","&diamond;":"⋄","&diamondsuit;":"♦","&diams;":"♦","&die;":"¨","&digamma;":"ϝ","&disin;":"⋲","&div;":"÷","&divide":"÷","&divide;":"÷","&divideontimes;":"⋇","&divonx;":"⋇","&djcy;":"ђ","&dlcorn;":"⌞","&dlcrop;":"⌍","&dollar;":"$","&dopf;":"𝕕","&dot;":"˙","&doteq;":"≐","&doteqdot;":"≑","&dotminus;":"∸","&dotplus;":"∔","&dotsquare;":"⊡","&doublebarwedge;":"⌆","&downarrow;":"↓","&downdownarrows;":"⇊","&downharpoonleft;":"⇃","&downharpoonright;":"⇂","&drbkarow;":"⤐","&drcorn;":"⌟","&drcrop;":"⌌","&dscr;":"𝒹","&dscy;":"ѕ","&dsol;":"⧶","&dstrok;":"đ","&dtdot;":"⋱","&dtri;":"▿","&dtrif;":"▾","&duarr;":"⇵","&duhar;":"⥯","&dwangle;":"⦦","&dzcy;":"џ","&dzigrarr;":"⟿","&eDDot;":"⩷","&eDot;":"≑","&eacute":"é","&eacute;":"é","&easter;":"⩮","&ecaron;":"ě","&ecir;":"≖","&ecirc":"ê","&ecirc;":"ê","&ecolon;":"≕","&ecy;":"э","&edot;":"ė","&ee;":"ⅇ","&efDot;":"≒","&efr;":"𝔢","&eg;":"⪚","&egrave":"è","&egrave;":"è","&egs;":"⪖","&egsdot;":"⪘","&el;":"⪙","&elinters;":"⏧","&ell;":"ℓ","&els;":"⪕","&elsdot;":"⪗","&emacr;":"ē","&empty;":"∅","&emptyset;":"∅","&emptyv;":"∅","&emsp13;":" ","&emsp14;":" ","&emsp;":" ","&eng;":"ŋ","&ensp;":" ","&eogon;":"ę","&eopf;":"𝕖","&epar;":"⋕","&eparsl;":"⧣","&eplus;":"⩱","&epsi;":"ε","&epsilon;":"ε","&epsiv;":"ϵ","&eqcirc;":"≖","&eqcolon;":"≕","&eqsim;":"≂","&eqslantgtr;":"⪖","&eqslantless;":"⪕","&equals;":"=","&equest;":"≟","&equiv;":"≡","&equivDD;":"⩸","&eqvparsl;":"⧥","&erDot;":"≓","&erarr;":"⥱","&escr;":"ℯ","&esdot;":"≐","&esim;":"≂","&eta;":"η","&eth":"ð","&eth;":"ð","&euml":"ë","&euml;":"ë","&euro;":"€","&excl;":"!","&exist;":"∃","&expectation;":"ℰ","&exponentiale;":"ⅇ","&fallingdotseq;":"≒","&fcy;":"ф","&female;":"♀","&ffilig;":"ffi","&fflig;":"ff","&ffllig;":"ffl","&ffr;":"𝔣","&filig;":"fi","&fjlig;":"fj","&flat;":"♭","&fllig;":"fl","&fltns;":"▱","&fnof;":"ƒ","&fopf;":"𝕗","&forall;":"∀","&fork;":"⋔","&forkv;":"⫙","&fpartint;":"⨍","&frac12":"½","&frac12;":"½","&frac13;":"⅓","&frac14":"¼","&frac14;":"¼","&frac15;":"⅕","&frac16;":"⅙","&frac18;":"⅛","&frac23;":"⅔","&frac25;":"⅖","&frac34":"¾","&frac34;":"¾","&frac35;":"⅗","&frac38;":"⅜","&frac45;":"⅘","&frac56;":"⅚","&frac58;":"⅝","&frac78;":"⅞","&frasl;":"⁄","&frown;":"⌢","&fscr;":"𝒻","&gE;":"≧","&gEl;":"⪌","&gacute;":"ǵ","&gamma;":"γ","&gammad;":"ϝ","&gap;":"⪆","&gbreve;":"ğ","&gcirc;":"ĝ","&gcy;":"г","&gdot;":"ġ","&ge;":"≥","&gel;":"⋛","&geq;":"≥","&geqq;":"≧","&geqslant;":"⩾","&ges;":"⩾","&gescc;":"⪩","&gesdot;":"⪀","&gesdoto;":"⪂","&gesdotol;":"⪄","&gesl;":"⋛︀","&gesles;":"⪔","&gfr;":"𝔤","&gg;":"≫","&ggg;":"⋙","&gimel;":"ℷ","&gjcy;":"ѓ","&gl;":"≷","&glE;":"⪒","&gla;":"⪥","&glj;":"⪤","&gnE;":"≩","&gnap;":"⪊","&gnapprox;":"⪊","&gne;":"⪈","&gneq;":"⪈","&gneqq;":"≩","&gnsim;":"⋧","&gopf;":"𝕘","&grave;":"`","&gscr;":"ℊ","&gsim;":"≳","&gsime;":"⪎","&gsiml;":"⪐","&gt":">","&gt;":">","&gtcc;":"⪧","&gtcir;":"⩺","&gtdot;":"⋗","&gtlPar;":"⦕","&gtquest;":"⩼","&gtrapprox;":"⪆","&gtrarr;":"⥸","&gtrdot;":"⋗","&gtreqless;":"⋛","&gtreqqless;":"⪌","&gtrless;":"≷","&gtrsim;":"≳","&gvertneqq;":"≩︀","&gvnE;":"≩︀","&hArr;":"⇔","&hairsp;":" ","&half;":"½","&hamilt;":"ℋ","&hardcy;":"ъ","&harr;":"↔","&harrcir;":"⥈","&harrw;":"↭","&hbar;":"ℏ","&hcirc;":"ĥ","&hearts;":"♥","&heartsuit;":"♥","&hellip;":"…","&hercon;":"⊹","&hfr;":"𝔥","&hksearow;":"⤥","&hkswarow;":"⤦","&hoarr;":"⇿","&homtht;":"∻","&hookleftarrow;":"↩","&hookrightarrow;":"↪","&hopf;":"𝕙","&horbar;":"―","&hscr;":"𝒽","&hslash;":"ℏ","&hstrok;":"ħ","&hybull;":"⁃","&hyphen;":"‐","&iacute":"í","&iacute;":"í","&ic;":"⁣","&icirc":"î","&icirc;":"î","&icy;":"и","&iecy;":"е","&iexcl":"¡","&iexcl;":"¡","&iff;":"⇔","&ifr;":"𝔦","&igrave":"ì","&igrave;":"ì","&ii;":"ⅈ","&iiiint;":"⨌","&iiint;":"∭","&iinfin;":"⧜","&iiota;":"℩","&ijlig;":"ij","&imacr;":"ī","&image;":"ℑ","&imagline;":"ℐ","&imagpart;":"ℑ","&imath;":"ı","&imof;":"⊷","&imped;":"Ƶ","&in;":"∈","&incare;":"℅","&infin;":"∞","&infintie;":"⧝","&inodot;":"ı","&int;":"∫","&intcal;":"⊺","&integers;":"ℤ","&intercal;":"⊺","&intlarhk;":"⨗","&intprod;":"⨼","&iocy;":"ё","&iogon;":"į","&iopf;":"𝕚","&iota;":"ι","&iprod;":"⨼","&iquest":"¿","&iquest;":"¿","&iscr;":"𝒾","&isin;":"∈","&isinE;":"⋹","&isindot;":"⋵","&isins;":"⋴","&isinsv;":"⋳","&isinv;":"∈","&it;":"⁢","&itilde;":"ĩ","&iukcy;":"і","&iuml":"ï","&iuml;":"ï","&jcirc;":"ĵ","&jcy;":"й","&jfr;":"𝔧","&jmath;":"ȷ","&jopf;":"𝕛","&jscr;":"𝒿","&jsercy;":"ј","&jukcy;":"є","&kappa;":"κ","&kappav;":"ϰ","&kcedil;":"ķ","&kcy;":"к","&kfr;":"𝔨","&kgreen;":"ĸ","&khcy;":"х","&kjcy;":"ќ","&kopf;":"𝕜","&kscr;":"𝓀","&lAarr;":"⇚","&lArr;":"⇐","&lAtail;":"⤛","&lBarr;":"⤎","&lE;":"≦","&lEg;":"⪋","&lHar;":"⥢","&lacute;":"ĺ","&laemptyv;":"⦴","&lagran;":"ℒ","&lambda;":"λ","&lang;":"⟨","&langd;":"⦑","&langle;":"⟨","&lap;":"⪅","&laquo":"«","&laquo;":"«","&larr;":"←","&larrb;":"⇤","&larrbfs;":"⤟","&larrfs;":"⤝","&larrhk;":"↩","&larrlp;":"↫","&larrpl;":"⤹","&larrsim;":"⥳","&larrtl;":"↢","&lat;":"⪫","&latail;":"⤙","&late;":"⪭","&lates;":"⪭︀","&lbarr;":"⤌","&lbbrk;":"❲","&lbrace;":"{","&lbrack;":"[","&lbrke;":"⦋","&lbrksld;":"⦏","&lbrkslu;":"⦍","&lcaron;":"ľ","&lcedil;":"ļ","&lceil;":"⌈","&lcub;":"{","&lcy;":"л","&ldca;":"⤶","&ldquo;":"“","&ldquor;":"„","&ldrdhar;":"⥧","&ldrushar;":"⥋","&ldsh;":"↲","&le;":"≤","&leftarrow;":"←","&leftarrowtail;":"↢","&leftharpoondown;":"↽","&leftharpoonup;":"↼","&leftleftarrows;":"⇇","&leftrightarrow;":"↔","&leftrightarrows;":"⇆","&leftrightharpoons;":"⇋","&leftrightsquigarrow;":"↭","&leftthreetimes;":"⋋","&leg;":"⋚","&leq;":"≤","&leqq;":"≦","&leqslant;":"⩽","&les;":"⩽","&lescc;":"⪨","&lesdot;":"⩿","&lesdoto;":"⪁","&lesdotor;":"⪃","&lesg;":"⋚︀","&lesges;":"⪓","&lessapprox;":"⪅","&lessdot;":"⋖","&lesseqgtr;":"⋚","&lesseqqgtr;":"⪋","&lessgtr;":"≶","&lesssim;":"≲","&lfisht;":"⥼","&lfloor;":"⌊","&lfr;":"𝔩","&lg;":"≶","&lgE;":"⪑","&lhard;":"↽","&lharu;":"↼","&lharul;":"⥪","&lhblk;":"▄","&ljcy;":"љ","&ll;":"≪","&llarr;":"⇇","&llcorner;":"⌞","&llhard;":"⥫","&lltri;":"◺","&lmidot;":"ŀ","&lmoust;":"⎰","&lmoustache;":"⎰","&lnE;":"≨","&lnap;":"⪉","&lnapprox;":"⪉","&lne;":"⪇","&lneq;":"⪇","&lneqq;":"≨","&lnsim;":"⋦","&loang;":"⟬","&loarr;":"⇽","&lobrk;":"⟦","&longleftarrow;":"⟵","&longleftrightarrow;":"⟷","&longmapsto;":"⟼","&longrightarrow;":"⟶","&looparrowleft;":"↫","&looparrowright;":"↬","&lopar;":"⦅","&lopf;":"𝕝","&loplus;":"⨭","&lotimes;":"⨴","&lowast;":"∗","&lowbar;":"_","&loz;":"◊","&lozenge;":"◊","&lozf;":"⧫","&lpar;":"(","&lparlt;":"⦓","&lrarr;":"⇆","&lrcorner;":"⌟","&lrhar;":"⇋","&lrhard;":"⥭","&lrm;":"‎","&lrtri;":"⊿","&lsaquo;":"‹","&lscr;":"𝓁","&lsh;":"↰","&lsim;":"≲","&lsime;":"⪍","&lsimg;":"⪏","&lsqb;":"[","&lsquo;":"‘","&lsquor;":"‚","&lstrok;":"ł","&lt":"<","&lt;":"<","&ltcc;":"⪦","&ltcir;":"⩹","&ltdot;":"⋖","&lthree;":"⋋","&ltimes;":"⋉","&ltlarr;":"⥶","&ltquest;":"⩻","&ltrPar;":"⦖","&ltri;":"◃","&ltrie;":"⊴","&ltrif;":"◂","&lurdshar;":"⥊","&luruhar;":"⥦","&lvertneqq;":"≨︀","&lvnE;":"≨︀","&mDDot;":"∺","&macr":"¯","&macr;":"¯","&male;":"♂","&malt;":"✠","&maltese;":"✠","&map;":"↦","&mapsto;":"↦","&mapstodown;":"↧","&mapstoleft;":"↤","&mapstoup;":"↥","&marker;":"▮","&mcomma;":"⨩","&mcy;":"м","&mdash;":"—","&measuredangle;":"∡","&mfr;":"𝔪","&mho;":"℧","&micro":"µ","&micro;":"µ","&mid;":"∣","&midast;":"*","&midcir;":"⫰","&middot":"·","&middot;":"·","&minus;":"−","&minusb;":"⊟","&minusd;":"∸","&minusdu;":"⨪","&mlcp;":"⫛","&mldr;":"…","&mnplus;":"∓","&models;":"⊧","&mopf;":"𝕞","&mp;":"∓","&mscr;":"𝓂","&mstpos;":"∾","&mu;":"μ","&multimap;":"⊸","&mumap;":"⊸","&nGg;":"⋙̸","&nGt;":"≫⃒","&nGtv;":"≫̸","&nLeftarrow;":"⇍","&nLeftrightarrow;":"⇎","&nLl;":"⋘̸","&nLt;":"≪⃒","&nLtv;":"≪̸","&nRightarrow;":"⇏","&nVDash;":"⊯","&nVdash;":"⊮","&nabla;":"∇","&nacute;":"ń","&nang;":"∠⃒","&nap;":"≉","&napE;":"⩰̸","&napid;":"≋̸","&napos;":"ʼn","&napprox;":"≉","&natur;":"♮","&natural;":"♮","&naturals;":"ℕ","&nbsp":" ","&nbsp;":" ","&nbump;":"≎̸","&nbumpe;":"≏̸","&ncap;":"⩃","&ncaron;":"ň","&ncedil;":"ņ","&ncong;":"≇","&ncongdot;":"⩭̸","&ncup;":"⩂","&ncy;":"н","&ndash;":"–","&ne;":"≠","&neArr;":"⇗","&nearhk;":"⤤","&nearr;":"↗","&nearrow;":"↗","&nedot;":"≐̸","&nequiv;":"≢","&nesear;":"⤨","&nesim;":"≂̸","&nexist;":"∄","&nexists;":"∄","&nfr;":"𝔫","&ngE;":"≧̸","&nge;":"≱","&ngeq;":"≱","&ngeqq;":"≧̸","&ngeqslant;":"⩾̸","&nges;":"⩾̸","&ngsim;":"≵","&ngt;":"≯","&ngtr;":"≯","&nhArr;":"⇎","&nharr;":"↮","&nhpar;":"⫲","&ni;":"∋","&nis;":"⋼","&nisd;":"⋺","&niv;":"∋","&njcy;":"њ","&nlArr;":"⇍","&nlE;":"≦̸","&nlarr;":"↚","&nldr;":"‥","&nle;":"≰","&nleftarrow;":"↚","&nleftrightarrow;":"↮","&nleq;":"≰","&nleqq;":"≦̸","&nleqslant;":"⩽̸","&nles;":"⩽̸","&nless;":"≮","&nlsim;":"≴","&nlt;":"≮","&nltri;":"⋪","&nltrie;":"⋬","&nmid;":"∤","&nopf;":"𝕟","&not":"¬","&not;":"¬","&notin;":"∉","&notinE;":"⋹̸","&notindot;":"⋵̸","&notinva;":"∉","&notinvb;":"⋷","&notinvc;":"⋶","&notni;":"∌","&notniva;":"∌","&notnivb;":"⋾","&notnivc;":"⋽","&npar;":"∦","&nparallel;":"∦","&nparsl;":"⫽⃥","&npart;":"∂̸","&npolint;":"⨔","&npr;":"⊀","&nprcue;":"⋠","&npre;":"⪯̸","&nprec;":"⊀","&npreceq;":"⪯̸","&nrArr;":"⇏","&nrarr;":"↛","&nrarrc;":"⤳̸","&nrarrw;":"↝̸","&nrightarrow;":"↛","&nrtri;":"⋫","&nrtrie;":"⋭","&nsc;":"⊁","&nsccue;":"⋡","&nsce;":"⪰̸","&nscr;":"𝓃","&nshortmid;":"∤","&nshortparallel;":"∦","&nsim;":"≁","&nsime;":"≄","&nsimeq;":"≄","&nsmid;":"∤","&nspar;":"∦","&nsqsube;":"⋢","&nsqsupe;":"⋣","&nsub;":"⊄","&nsubE;":"⫅̸","&nsube;":"⊈","&nsubset;":"⊂⃒","&nsubseteq;":"⊈","&nsubseteqq;":"⫅̸","&nsucc;":"⊁","&nsucceq;":"⪰̸","&nsup;":"⊅","&nsupE;":"⫆̸","&nsupe;":"⊉","&nsupset;":"⊃⃒","&nsupseteq;":"⊉","&nsupseteqq;":"⫆̸","&ntgl;":"≹","&ntilde":"ñ","&ntilde;":"ñ","&ntlg;":"≸","&ntriangleleft;":"⋪","&ntrianglelefteq;":"⋬","&ntriangleright;":"⋫","&ntrianglerighteq;":"⋭","&nu;":"ν","&num;":"#","&numero;":"№","&numsp;":" ","&nvDash;":"⊭","&nvHarr;":"⤄","&nvap;":"≍⃒","&nvdash;":"⊬","&nvge;":"≥⃒","&nvgt;":">⃒","&nvinfin;":"⧞","&nvlArr;":"⤂","&nvle;":"≤⃒","&nvlt;":"<⃒","&nvltrie;":"⊴⃒","&nvrArr;":"⤃","&nvrtrie;":"⊵⃒","&nvsim;":"∼⃒","&nwArr;":"⇖","&nwarhk;":"⤣","&nwarr;":"↖","&nwarrow;":"↖","&nwnear;":"⤧","&oS;":"Ⓢ","&oacute":"ó","&oacute;":"ó","&oast;":"⊛","&ocir;":"⊚","&ocirc":"ô","&ocirc;":"ô","&ocy;":"о","&odash;":"⊝","&odblac;":"ő","&odiv;":"⨸","&odot;":"⊙","&odsold;":"⦼","&oelig;":"œ","&ofcir;":"⦿","&ofr;":"𝔬","&ogon;":"˛","&ograve":"ò","&ograve;":"ò","&ogt;":"⧁","&ohbar;":"⦵","&ohm;":"Ω","&oint;":"∮","&olarr;":"↺","&olcir;":"⦾","&olcross;":"⦻","&oline;":"‾","&olt;":"⧀","&omacr;":"ō","&omega;":"ω","&omicron;":"ο","&omid;":"⦶","&ominus;":"⊖","&oopf;":"𝕠","&opar;":"⦷","&operp;":"⦹","&oplus;":"⊕","&or;":"∨","&orarr;":"↻","&ord;":"⩝","&order;":"ℴ","&orderof;":"ℴ","&ordf":"ª","&ordf;":"ª","&ordm":"º","&ordm;":"º","&origof;":"⊶","&oror;":"⩖","&orslope;":"⩗","&orv;":"⩛","&oscr;":"ℴ","&oslash":"ø","&oslash;":"ø","&osol;":"⊘","&otilde":"õ","&otilde;":"õ","&otimes;":"⊗","&otimesas;":"⨶","&ouml":"ö","&ouml;":"ö","&ovbar;":"⌽","&par;":"∥","&para":"¶","&para;":"¶","&parallel;":"∥","&parsim;":"⫳","&parsl;":"⫽","&part;":"∂","&pcy;":"п","&percnt;":"%","&period;":".","&permil;":"‰","&perp;":"⊥","&pertenk;":"‱","&pfr;":"𝔭","&phi;":"φ","&phiv;":"ϕ","&phmmat;":"ℳ","&phone;":"☎","&pi;":"π","&pitchfork;":"⋔","&piv;":"ϖ","&planck;":"ℏ","&planckh;":"ℎ","&plankv;":"ℏ","&plus;":"+","&plusacir;":"⨣","&plusb;":"⊞","&pluscir;":"⨢","&plusdo;":"∔","&plusdu;":"⨥","&pluse;":"⩲","&plusmn":"±","&plusmn;":"±","&plussim;":"⨦","&plustwo;":"⨧","&pm;":"±","&pointint;":"⨕","&popf;":"𝕡","&pound":"£","&pound;":"£","&pr;":"≺","&prE;":"⪳","&prap;":"⪷","&prcue;":"≼","&pre;":"⪯","&prec;":"≺","&precapprox;":"⪷","&preccurlyeq;":"≼","&preceq;":"⪯","&precnapprox;":"⪹","&precneqq;":"⪵","&precnsim;":"⋨","&precsim;":"≾","&prime;":"′","&primes;":"ℙ","&prnE;":"⪵","&prnap;":"⪹","&prnsim;":"⋨","&prod;":"∏","&profalar;":"⌮","&profline;":"⌒","&profsurf;":"⌓","&prop;":"∝","&propto;":"∝","&prsim;":"≾","&prurel;":"⊰","&pscr;":"𝓅","&psi;":"ψ","&puncsp;":" ","&qfr;":"𝔮","&qint;":"⨌","&qopf;":"𝕢","&qprime;":"⁗","&qscr;":"𝓆","&quaternions;":"ℍ","&quatint;":"⨖","&quest;":"?","&questeq;":"≟","&quot":'"',"&quot;":'"',"&rAarr;":"⇛","&rArr;":"⇒","&rAtail;":"⤜","&rBarr;":"⤏","&rHar;":"⥤","&race;":"∽̱","&racute;":"ŕ","&radic;":"√","&raemptyv;":"⦳","&rang;":"⟩","&rangd;":"⦒","&range;":"⦥","&rangle;":"⟩","&raquo":"»","&raquo;":"»","&rarr;":"→","&rarrap;":"⥵","&rarrb;":"⇥","&rarrbfs;":"⤠","&rarrc;":"⤳","&rarrfs;":"⤞","&rarrhk;":"↪","&rarrlp;":"↬","&rarrpl;":"⥅","&rarrsim;":"⥴","&rarrtl;":"↣","&rarrw;":"↝","&ratail;":"⤚","&ratio;":"∶","&rationals;":"ℚ","&rbarr;":"⤍","&rbbrk;":"❳","&rbrace;":"}","&rbrack;":"]","&rbrke;":"⦌","&rbrksld;":"⦎","&rbrkslu;":"⦐","&rcaron;":"ř","&rcedil;":"ŗ","&rceil;":"⌉","&rcub;":"}","&rcy;":"р","&rdca;":"⤷","&rdldhar;":"⥩","&rdquo;":"”","&rdquor;":"”","&rdsh;":"↳","&real;":"ℜ","&realine;":"ℛ","&realpart;":"ℜ","&reals;":"ℝ","&rect;":"▭","&reg":"®","&reg;":"®","&rfisht;":"⥽","&rfloor;":"⌋","&rfr;":"𝔯","&rhard;":"⇁","&rharu;":"⇀","&rharul;":"⥬","&rho;":"ρ","&rhov;":"ϱ","&rightarrow;":"→","&rightarrowtail;":"↣","&rightharpoondown;":"⇁","&rightharpoonup;":"⇀","&rightleftarrows;":"⇄","&rightleftharpoons;":"⇌","&rightrightarrows;":"⇉","&rightsquigarrow;":"↝","&rightthreetimes;":"⋌","&ring;":"˚","&risingdotseq;":"≓","&rlarr;":"⇄","&rlhar;":"⇌","&rlm;":"‏","&rmoust;":"⎱","&rmoustache;":"⎱","&rnmid;":"⫮","&roang;":"⟭","&roarr;":"⇾","&robrk;":"⟧","&ropar;":"⦆","&ropf;":"𝕣","&roplus;":"⨮","&rotimes;":"⨵","&rpar;":")","&rpargt;":"⦔","&rppolint;":"⨒","&rrarr;":"⇉","&rsaquo;":"›","&rscr;":"𝓇","&rsh;":"↱","&rsqb;":"]","&rsquo;":"’","&rsquor;":"’","&rthree;":"⋌","&rtimes;":"⋊","&rtri;":"▹","&rtrie;":"⊵","&rtrif;":"▸","&rtriltri;":"⧎","&ruluhar;":"⥨","&rx;":"℞","&sacute;":"ś","&sbquo;":"‚","&sc;":"≻","&scE;":"⪴","&scap;":"⪸","&scaron;":"š","&sccue;":"≽","&sce;":"⪰","&scedil;":"ş","&scirc;":"ŝ","&scnE;":"⪶","&scnap;":"⪺","&scnsim;":"⋩","&scpolint;":"⨓","&scsim;":"≿","&scy;":"с","&sdot;":"⋅","&sdotb;":"⊡","&sdote;":"⩦","&seArr;":"⇘","&searhk;":"⤥","&searr;":"↘","&searrow;":"↘","&sect":"§","&sect;":"§","&semi;":";","&seswar;":"⤩","&setminus;":"∖","&setmn;":"∖","&sext;":"✶","&sfr;":"𝔰","&sfrown;":"⌢","&sharp;":"♯","&shchcy;":"щ","&shcy;":"ш","&shortmid;":"∣","&shortparallel;":"∥","&shy":"­","&shy;":"­","&sigma;":"σ","&sigmaf;":"ς","&sigmav;":"ς","&sim;":"∼","&simdot;":"⩪","&sime;":"≃","&simeq;":"≃","&simg;":"⪞","&simgE;":"⪠","&siml;":"⪝","&simlE;":"⪟","&simne;":"≆","&simplus;":"⨤","&simrarr;":"⥲","&slarr;":"←","&smallsetminus;":"∖","&smashp;":"⨳","&smeparsl;":"⧤","&smid;":"∣","&smile;":"⌣","&smt;":"⪪","&smte;":"⪬","&smtes;":"⪬︀","&softcy;":"ь","&sol;":"/","&solb;":"⧄","&solbar;":"⌿","&sopf;":"𝕤","&spades;":"♠","&spadesuit;":"♠","&spar;":"∥","&sqcap;":"⊓","&sqcaps;":"⊓︀","&sqcup;":"⊔","&sqcups;":"⊔︀","&sqsub;":"⊏","&sqsube;":"⊑","&sqsubset;":"⊏","&sqsubseteq;":"⊑","&sqsup;":"⊐","&sqsupe;":"⊒","&sqsupset;":"⊐","&sqsupseteq;":"⊒","&squ;":"□","&square;":"□","&squarf;":"▪","&squf;":"▪","&srarr;":"→","&sscr;":"𝓈","&ssetmn;":"∖","&ssmile;":"⌣","&sstarf;":"⋆","&star;":"☆","&starf;":"★","&straightepsilon;":"ϵ","&straightphi;":"ϕ","&strns;":"¯","&sub;":"⊂","&subE;":"⫅","&subdot;":"⪽","&sube;":"⊆","&subedot;":"⫃","&submult;":"⫁","&subnE;":"⫋","&subne;":"⊊","&subplus;":"⪿","&subrarr;":"⥹","&subset;":"⊂","&subseteq;":"⊆","&subseteqq;":"⫅","&subsetneq;":"⊊","&subsetneqq;":"⫋","&subsim;":"⫇","&subsub;":"⫕","&subsup;":"⫓","&succ;":"≻","&succapprox;":"⪸","&succcurlyeq;":"≽","&succeq;":"⪰","&succnapprox;":"⪺","&succneqq;":"⪶","&succnsim;":"⋩","&succsim;":"≿","&sum;":"∑","&sung;":"♪","&sup1":"¹","&sup1;":"¹","&sup2":"²","&sup2;":"²","&sup3":"³","&sup3;":"³","&sup;":"⊃","&supE;":"⫆","&supdot;":"⪾","&supdsub;":"⫘","&supe;":"⊇","&supedot;":"⫄","&suphsol;":"⟉","&suphsub;":"⫗","&suplarr;":"⥻","&supmult;":"⫂","&supnE;":"⫌","&supne;":"⊋","&supplus;":"⫀","&supset;":"⊃","&supseteq;":"⊇","&supseteqq;":"⫆","&supsetneq;":"⊋","&supsetneqq;":"⫌","&supsim;":"⫈","&supsub;":"⫔","&supsup;":"⫖","&swArr;":"⇙","&swarhk;":"⤦","&swarr;":"↙","&swarrow;":"↙","&swnwar;":"⤪","&szlig":"ß","&szlig;":"ß","&target;":"⌖","&tau;":"τ","&tbrk;":"⎴","&tcaron;":"ť","&tcedil;":"ţ","&tcy;":"т","&tdot;":"⃛","&telrec;":"⌕","&tfr;":"𝔱","&there4;":"∴","&therefore;":"∴","&theta;":"θ","&thetasym;":"ϑ","&thetav;":"ϑ","&thickapprox;":"≈","&thicksim;":"∼","&thinsp;":" ","&thkap;":"≈","&thksim;":"∼","&thorn":"þ","&thorn;":"þ","&tilde;":"˜","&times":"×","&times;":"×","&timesb;":"⊠","&timesbar;":"⨱","&timesd;":"⨰","&tint;":"∭","&toea;":"⤨","&top;":"⊤","&topbot;":"⌶","&topcir;":"⫱","&topf;":"𝕥","&topfork;":"⫚","&tosa;":"⤩","&tprime;":"‴","&trade;":"™","&triangle;":"▵","&triangledown;":"▿","&triangleleft;":"◃","&trianglelefteq;":"⊴","&triangleq;":"≜","&triangleright;":"▹","&trianglerighteq;":"⊵","&tridot;":"◬","&trie;":"≜","&triminus;":"⨺","&triplus;":"⨹","&trisb;":"⧍","&tritime;":"⨻","&trpezium;":"⏢","&tscr;":"𝓉","&tscy;":"ц","&tshcy;":"ћ","&tstrok;":"ŧ","&twixt;":"≬","&twoheadleftarrow;":"↞","&twoheadrightarrow;":"↠","&uArr;":"⇑","&uHar;":"⥣","&uacute":"ú","&uacute;":"ú","&uarr;":"↑","&ubrcy;":"ў","&ubreve;":"ŭ","&ucirc":"û","&ucirc;":"û","&ucy;":"у","&udarr;":"⇅","&udblac;":"ű","&udhar;":"⥮","&ufisht;":"⥾","&ufr;":"𝔲","&ugrave":"ù","&ugrave;":"ù","&uharl;":"↿","&uharr;":"↾","&uhblk;":"▀","&ulcorn;":"⌜","&ulcorner;":"⌜","&ulcrop;":"⌏","&ultri;":"◸","&umacr;":"ū","&uml":"¨","&uml;":"¨","&uogon;":"ų","&uopf;":"𝕦","&uparrow;":"↑","&updownarrow;":"↕","&upharpoonleft;":"↿","&upharpoonright;":"↾","&uplus;":"⊎","&upsi;":"υ","&upsih;":"ϒ","&upsilon;":"υ","&upuparrows;":"⇈","&urcorn;":"⌝","&urcorner;":"⌝","&urcrop;":"⌎","&uring;":"ů","&urtri;":"◹","&uscr;":"𝓊","&utdot;":"⋰","&utilde;":"ũ","&utri;":"▵","&utrif;":"▴","&uuarr;":"⇈","&uuml":"ü","&uuml;":"ü","&uwangle;":"⦧","&vArr;":"⇕","&vBar;":"⫨","&vBarv;":"⫩","&vDash;":"⊨","&vangrt;":"⦜","&varepsilon;":"ϵ","&varkappa;":"ϰ","&varnothing;":"∅","&varphi;":"ϕ","&varpi;":"ϖ","&varpropto;":"∝","&varr;":"↕","&varrho;":"ϱ","&varsigma;":"ς","&varsubsetneq;":"⊊︀","&varsubsetneqq;":"⫋︀","&varsupsetneq;":"⊋︀","&varsupsetneqq;":"⫌︀","&vartheta;":"ϑ","&vartriangleleft;":"⊲","&vartriangleright;":"⊳","&vcy;":"в","&vdash;":"⊢","&vee;":"∨","&veebar;":"⊻","&veeeq;":"≚","&vellip;":"⋮","&verbar;":"|","&vert;":"|","&vfr;":"𝔳","&vltri;":"⊲","&vnsub;":"⊂⃒","&vnsup;":"⊃⃒","&vopf;":"𝕧","&vprop;":"∝","&vrtri;":"⊳","&vscr;":"𝓋","&vsubnE;":"⫋︀","&vsubne;":"⊊︀","&vsupnE;":"⫌︀","&vsupne;":"⊋︀","&vzigzag;":"⦚","&wcirc;":"ŵ","&wedbar;":"⩟","&wedge;":"∧","&wedgeq;":"≙","&weierp;":"℘","&wfr;":"𝔴","&wopf;":"𝕨","&wp;":"℘","&wr;":"≀","&wreath;":"≀","&wscr;":"𝓌","&xcap;":"⋂","&xcirc;":"◯","&xcup;":"⋃","&xdtri;":"▽","&xfr;":"𝔵","&xhArr;":"⟺","&xharr;":"⟷","&xi;":"ξ","&xlArr;":"⟸","&xlarr;":"⟵","&xmap;":"⟼","&xnis;":"⋻","&xodot;":"⨀","&xopf;":"𝕩","&xoplus;":"⨁","&xotime;":"⨂","&xrArr;":"⟹","&xrarr;":"⟶","&xscr;":"𝓍","&xsqcup;":"⨆","&xuplus;":"⨄","&xutri;":"△","&xvee;":"⋁","&xwedge;":"⋀","&yacute":"ý","&yacute;":"ý","&yacy;":"я","&ycirc;":"ŷ","&ycy;":"ы","&yen":"¥","&yen;":"¥","&yfr;":"𝔶","&yicy;":"ї","&yopf;":"𝕪","&yscr;":"𝓎","&yucy;":"ю","&yuml":"ÿ","&yuml;":"ÿ","&zacute;":"ź","&zcaron;":"ž","&zcy;":"з","&zdot;":"ż","&zeetrf;":"ℨ","&zeta;":"ζ","&zfr;":"𝔷","&zhcy;":"ж","&zigrarr;":"⇝","&zopf;":"𝕫","&zscr;":"𝓏","&zwj;":"‍","&zwnj;":"‌"};function Kd(r){return r.replace(/&(#\d+|#x[a-f0-9]+|[a-z]+\d*);?/gi,(e,t)=>{if(typeof _a[e]=="string")return _a[e];if(t.charAt(0)!=="#"||e.charAt(e.length-1)!==";")return e;let n;t.charAt(1)==="x"?n=parseInt(t.substr(2),16):n=parseInt(t.substr(1),10);var s="";return n>=55296&&n<=57343||n>1114111?"�":(n>65535&&(n-=65536,s+=String.fromCharCode(n>>>10&1023|55296),n=56320|n&1023),s+=String.fromCharCode(n),s)})}function kr(r){return r.trim().replace(/[<>"'?&]/g,e=>{let t=e.charCodeAt(0).toString(16);return t.length<2&&(t="0"+t),"&#x"+t.toUpperCase()+";"})}function Yd(r){return"<div>"+kr(r).replace(/\n/g,"<br />")+"</div>"}function Qd(r){return r=r.replace(/\r?\n/g,"").replace(/<\!\-\-.*?\-\->/gi," ").replace(/<br\b[^>]*>/gi,`
@@ -13,19 +13,19 @@
13
13
 
14
14
  `).replace(/^\n+/,`
15
15
  `).replace(/\n+$/,`
16
- `),r=Kd(r),r}function nu(r){return[].concat(r.name||[]).concat(r.name?`<${r.address}>`:r.address).join(" ")}function Ei(r){let e=[],t=(n,s)=>{if(s&&e.push(", "),n.group){let i=`${n.name}:`,o=";";e.push(i),n.group.forEach(t),e.push(o)}else e.push(nu(n))};return r.forEach(t),e.join("")}function su(r){return`<a href="mailto:${kr(r.address)}" class="postal-email-address">${kr(r.name||`<${r.address}>`)}</a>`}function Di(r){let e=[],t=(n,s)=>{if(s&&e.push('<span class="postal-email-address-separator">, </span>'),n.group){let i=`<span class="postal-email-address-group">${kr(n.name)}:</span>`,o='<span class="postal-email-address-group">;</span>';e.push(i),n.group.forEach(t),e.push(o)}else e.push(su(n))};return r.forEach(t),e.join(" ")}function Jd(r,e,t){r=(r||"").toString(),e=e||76;let n=0,s=r.length,i="",o,l;for(;n<s;){if(o=r.substr(n,e),o.length<e){i+=o;break}if(l=o.match(/^[^\n\r]*(\r?\n|\r)/)){o=l[0],i+=o,n+=o.length;continue}else(l=o.match(/(\s+)[^\s]*$/))&&l[0].length-(l[1]||"").length<o.length?o=o.substr(0,o.length-(l[0].length-(l[1]||"").length)):(l=r.substr(n+o.length).match(/^[^\s]+(\s*)/))&&(o=o+l[0].substr(0,l[0].length-0));i+=o,n+=o.length,n<s&&(i+=`\r
17
- `)}return i}function wa(r){let e=[];if(r.from&&e.push({key:"From",val:nu(r.from)}),r.subject&&e.push({key:"Subject",val:r.subject}),r.date){let o={year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1},l=typeof Intl>"u"?r.date:new Intl.DateTimeFormat("default",o).format(new Date(r.date));e.push({key:"Date",val:l})}r.to&&r.to.length&&e.push({key:"To",val:Ei(r.to)}),r.cc&&r.cc.length&&e.push({key:"Cc",val:Ei(r.cc)}),r.bcc&&r.bcc.length&&e.push({key:"Bcc",val:Ei(r.bcc)});let t=e.map(o=>o.key.length).reduce((o,l)=>l>o?l:o,0);e=e.flatMap(o=>{let l=t-o.key.length,a=`${o.key}: ${" ".repeat(l)}`,u=`${" ".repeat(o.key.length+1)} ${" ".repeat(l)}`;return Jd(o.val,80).split(/\r?\n/).map(d=>d.trim()).map((d,h)=>`${h?u:a}${d}`)});let n=e.map(o=>o.length).reduce((o,l)=>l>o?l:o,0),s="-".repeat(n);return`
16
+ `),r=Kd(r),r}function nu(r){return[].concat(r.name||[]).concat(r.name?`<${r.address}>`:r.address).join(" ")}function Ei(r){let e=[],t=(n,s)=>{if(s&&e.push(", "),n.group){let i=`${n.name}:`,o=";";e.push(i),n.group.forEach(t),e.push(o)}else e.push(nu(n))};return r.forEach(t),e.join("")}function su(r){return`<a href="mailto:${kr(r.address)}" class="postal-email-address">${kr(r.name||`<${r.address}>`)}</a>`}function Di(r){let e=[],t=(n,s)=>{if(s&&e.push('<span class="postal-email-address-separator">, </span>'),n.group){let i=`<span class="postal-email-address-group">${kr(n.name)}:</span>`,o='<span class="postal-email-address-group">;</span>';e.push(i),n.group.forEach(t),e.push(o)}else e.push(su(n))};return r.forEach(t),e.join(" ")}function Jd(r,e,t){r=(r||"").toString(),e=e||76;let n=0,s=r.length,i="",o,a;for(;n<s;){if(o=r.substr(n,e),o.length<e){i+=o;break}if(a=o.match(/^[^\n\r]*(\r?\n|\r)/)){o=a[0],i+=o,n+=o.length;continue}else(a=o.match(/(\s+)[^\s]*$/))&&a[0].length-(a[1]||"").length<o.length?o=o.substr(0,o.length-(a[0].length-(a[1]||"").length)):(a=r.substr(n+o.length).match(/^[^\s]+(\s*)/))&&(o=o+a[0].substr(0,a[0].length-0));i+=o,n+=o.length,n<s&&(i+=`\r
17
+ `)}return i}function wa(r){let e=[];if(r.from&&e.push({key:"From",val:nu(r.from)}),r.subject&&e.push({key:"Subject",val:r.subject}),r.date){let o={year:"numeric",month:"numeric",day:"numeric",hour:"numeric",minute:"numeric",second:"numeric",hour12:!1},a=typeof Intl>"u"?r.date:new Intl.DateTimeFormat("default",o).format(new Date(r.date));e.push({key:"Date",val:a})}r.to&&r.to.length&&e.push({key:"To",val:Ei(r.to)}),r.cc&&r.cc.length&&e.push({key:"Cc",val:Ei(r.cc)}),r.bcc&&r.bcc.length&&e.push({key:"Bcc",val:Ei(r.bcc)});let t=e.map(o=>o.key.length).reduce((o,a)=>a>o?a:o,0);e=e.flatMap(o=>{let a=t-o.key.length,l=`${o.key}: ${" ".repeat(a)}`,u=`${" ".repeat(o.key.length+1)} ${" ".repeat(a)}`;return Jd(o.val,80).split(/\r?\n/).map(d=>d.trim()).map((d,h)=>`${h?u:l}${d}`)});let n=e.map(o=>o.length).reduce((o,a)=>a>o?a:o,0),s="-".repeat(n);return`
18
18
  ${s}
19
19
  ${e.join(`
20
20
  `)}
21
21
  ${s}
22
22
  `}function Ca(r){let e=[];if(r.from&&e.push(`<div class="postal-email-header-key">From</div><div class="postal-email-header-value">${su(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">${kr(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="${kr(r.date)}">${kr(s)}</div>`)}return r.to&&r.to.length&&e.push(`<div class="postal-email-header-key">To</div><div class="postal-email-header-value">${Di(r.to)}</div>`),r.cc&&r.cc.length&&e.push(`<div class="postal-email-header-key">Cc</div><div class="postal-email-header-value">${Di(r.cc)}</div>`),r.bcc&&r.bcc.length&&e.push(`<div class="postal-email-header-key">Bcc</div><div class="postal-email-header-value">${Di(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 Xd(r,e){let t=!1,n="text",s,i=[],o={address:[],comment:[],group:[],text:[],textWasQuoted:[]},l,a,u=!1;for(l=0,a=r.length;l<a;l++){let c=r[l],d=l?r[l-1]:null;if(c.type==="operator")switch(c.value){case"<":n="address",u=!1;break;case"(":n="comment",u=!1;break;case":":n="group",t=!0,u=!1;break;case'"':u=!u,n="text";break;default:n="text",u=!1;break}else c.value&&(n==="address"&&(c.value=c.value.replace(/^[^<]*<\s*/,"")),d&&d.noBreak&&o[n].length?(o[n][o[n].length-1]+=c.value,n==="text"&&u&&(o.textWasQuoted[o.textWasQuoted.length-1]=!0)):(o[n].push(c.value),n==="text"&&o.textWasQuoted.push(u)))}if(!o.text.length&&o.comment.length&&(o.text=o.comment,o.comment=[]),t){o.text=o.text.join(" ");let c=[];o.group.length&&Dn(o.group.join(","),{_depth:e+1}).forEach(h=>{h.group?c=c.concat(h.group):c.push(h)}),i.push({name:En(o.text||s&&s.name),group:c})}else{if(!o.address.length&&o.text.length){for(l=o.text.length-1;l>=0;l--)if(!o.textWasQuoted[l]&&o.text[l].match(/^[^@\s]+@[^@\s]+$/)){o.address=o.text.splice(l,1),o.textWasQuoted.splice(l,1);break}let c=function(d){return o.address.length?d:(o.address=[d.trim()]," ")};if(!o.address.length)for(l=o.text.length-1;l>=0&&!(!o.textWasQuoted[l]&&(o.text[l]=o.text[l].replace(/\s*\b[^@\s]+@[^\s]+\b\s*/,c).trim(),o.address.length));l--);}if(!o.text.length&&o.comment.length&&(o.text=o.comment,o.comment=[]),o.address.length>1&&(o.text=o.text.concat(o.address.splice(1))),o.text=o.text.join(" "),o.address=o.address.join(" "),!o.address&&/^=\?[^=]+?=$/.test(o.text.trim())){const c=Dn(En(o.text));if(c&&c.length)return c}if(!o.address&&t)return[];s={address:o.address||o.text||"",name:En(o.text||o.address||"")},s.address===s.name&&((s.address||"").match(/@/)?s.name="":s.address=""),i.push(s)}return i}class Zd{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),i=t<n-1?this.str.charAt(t+1):null;this.checkChar(s,i)}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",`
23
+ <div class="postal-email-header-row">`)}${e.length?"</div>":""}</div>`}function Xd(r,e){let t=!1,n="text",s,i=[],o={address:[],comment:[],group:[],text:[],textWasQuoted:[]},a,l,u=!1;for(a=0,l=r.length;a<l;a++){let c=r[a],d=a?r[a-1]:null;if(c.type==="operator")switch(c.value){case"<":n="address",u=!1;break;case"(":n="comment",u=!1;break;case":":n="group",t=!0,u=!1;break;case'"':u=!u,n="text";break;default:n="text",u=!1;break}else c.value&&(n==="address"&&(c.value=c.value.replace(/^[^<]*<\s*/,"")),d&&d.noBreak&&o[n].length?(o[n][o[n].length-1]+=c.value,n==="text"&&u&&(o.textWasQuoted[o.textWasQuoted.length-1]=!0)):(o[n].push(c.value),n==="text"&&o.textWasQuoted.push(u)))}if(!o.text.length&&o.comment.length&&(o.text=o.comment,o.comment=[]),t){o.text=o.text.join(" ");let c=[];o.group.length&&Dn(o.group.join(","),{_depth:e+1}).forEach(h=>{h.group?c=c.concat(h.group):c.push(h)}),i.push({name:En(o.text||s&&s.name),group:c})}else{if(!o.address.length&&o.text.length){for(a=o.text.length-1;a>=0;a--)if(!o.textWasQuoted[a]&&o.text[a].match(/^[^@\s]+@[^@\s]+$/)){o.address=o.text.splice(a,1),o.textWasQuoted.splice(a,1);break}let c=function(d){return o.address.length?d:(o.address=[d.trim()]," ")};if(!o.address.length)for(a=o.text.length-1;a>=0&&!(!o.textWasQuoted[a]&&(o.text[a]=o.text[a].replace(/\s*\b[^@\s]+@[^\s]+\b\s*/,c).trim(),o.address.length));a--);}if(!o.text.length&&o.comment.length&&(o.text=o.comment,o.comment=[]),o.address.length>1&&(o.text=o.text.concat(o.address.splice(1))),o.text=o.text.join(" "),o.address=o.address.join(" "),!o.address&&/^=\?[^=]+?=$/.test(o.text.trim())){const c=Dn(En(o.text));if(c&&c.length)return c}if(!o.address&&t)return[];s={address:o.address||o.text||"",name:En(o.text||o.address||"")},s.address===s.name&&((s.address||"").match(/@/)?s.name="":s.address=""),i.push(s)}return i}class Zd{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),i=t<n-1?this.str.charAt(t+1):null;this.checkChar(s,i)}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 ef=50;function Dn(r,e){e=e||{};let t=e._depth||0;if(t>ef)return[];let s=new Zd(r).tokenize(),i=[],o=[],l=[];if(s.forEach(a=>{a.type==="operator"&&(a.value===","||a.value===";")?(o.length&&i.push(o),o=[]):o.push(a)}),o.length&&i.push(o),i.forEach(a=>{a=Xd(a,t),a.length&&(l=l.concat(a))}),e.flatten){let a=[],u=c=>{c.forEach(d=>{if(d.group)return u(d.group);a.push(d)})};return u(l),a}return l}function tf(r){for(var e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=new Uint8Array(r),s=n.byteLength,i=s%3,o=s-i,l,a,u,c,d,h=0;h<o;h=h+3)d=n[h]<<16|n[h+1]<<8|n[h+2],l=(d&16515072)>>18,a=(d&258048)>>12,u=(d&4032)>>6,c=d&63,e+=t[l]+t[a]+t[u]+t[c];return i==1?(d=n[o],l=(d&252)>>2,a=(d&3)<<4,e+=t[l]+t[a]+"=="):i==2&&(d=n[o]<<8|n[o+1],l=(d&64512)>>10,a=(d&1008)>>4,u=(d&15)<<2,e+=t[l]+t[a]+t[u]+"="),e}const rf=256,nf=2*1024*1024;class Ds{static parse(e,t){return new Ds(t).parse(e)}constructor(e){this.options=e||{},this.mimeOptions={maxNestingDepth:this.options.maxNestingDepth||rf,maxHeadersSize:this.options.maxHeadersSize||nf},this.root=this.currentNode=new va({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 i=n[s];if(e.length!==i.value.length+2&&e.length!==i.value.length+4)continue;let o=e.length===i.value.length+4;if(o&&(e[e.length-2]!==45||e[e.length-1]!==45))continue;let l=!0;for(let a=0;a<i.value.length;a++)if(e[a+2]!==i.value[a]){l=!1;break}if(l)return o?(await i.node.finalize(),this.currentNode=i.node.parentNode||this.root):(await i.node.finalizeChildNodes(),this.currentNode=new va({postalMime:this,parentNode:i.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(),i=async(o,l,a)=>{if(l=l||!1,a=a||!1,o.contentType.multipart)o.contentType.multipart==="alternative"?l=o:o.contentType.multipart==="related"&&(a=o);else if(this.isInlineMessageRfc822(o)&&!s){const u=new Ds;o.subMessage=await u.parse(o.content),n.has(o)||n.set(o,{});let c=n.get(o);(o.subMessage.text||!o.subMessage.html)&&(c.plain=c.plain||[],c.plain.push({type:"subMessage",value:o.subMessage}),t.add("plain")),o.subMessage.html&&(c.html=c.html||[],c.html.push({type:"subMessage",value:o.subMessage}),t.add("html")),u.textMap&&u.textMap.forEach((d,h)=>{n.set(h,d)});for(let d of o.subMessage.attachments||[])this.attachments.push(d)}else if(this.isInlineTextNode(o)){let u=o.contentType.parsed.value.substr(o.contentType.parsed.value.indexOf("/")+1),c=l||o;n.has(c)||n.set(c,{});let d=n.get(c);d[u]=d[u]||[],d[u].push({type:"text",value:o.getTextContent()}),t.add(u)}else if(o.content){const u=o.contentDisposition.parsed.params.filename||o.contentType.parsed.params.name||null,c={filename:u?En(u):null,mimeType:o.contentType.parsed.value,disposition:o.contentDisposition.parsed.value||null};switch(a&&o.contentId&&(c.related=!0),o.contentDescription&&(c.description=o.contentDescription),o.contentId&&(c.contentId=o.contentId),o.contentType.parsed.value){case"text/calendar":case"application/ics":{o.contentType.parsed.params.method&&(c.method=o.contentType.parsed.params.method.toString().toUpperCase().trim());const d=o.getTextContent().replace(/\r?\n/g,`
25
+ `&&(e=" "),(e.charCodeAt(0)>=33||[" "," "].includes(e))&&(this.node.value+=e),this.escaped=!1}}const ef=50;function Dn(r,e){e=e||{};let t=e._depth||0;if(t>ef)return[];let s=new Zd(r).tokenize(),i=[],o=[],a=[];if(s.forEach(l=>{l.type==="operator"&&(l.value===","||l.value===";")?(o.length&&i.push(o),o=[]):o.push(l)}),o.length&&i.push(o),i.forEach(l=>{l=Xd(l,t),l.length&&(a=a.concat(l))}),e.flatten){let l=[],u=c=>{c.forEach(d=>{if(d.group)return u(d.group);l.push(d)})};return u(a),l}return a}function tf(r){for(var e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=new Uint8Array(r),s=n.byteLength,i=s%3,o=s-i,a,l,u,c,d,h=0;h<o;h=h+3)d=n[h]<<16|n[h+1]<<8|n[h+2],a=(d&16515072)>>18,l=(d&258048)>>12,u=(d&4032)>>6,c=d&63,e+=t[a]+t[l]+t[u]+t[c];return i==1?(d=n[o],a=(d&252)>>2,l=(d&3)<<4,e+=t[a]+t[l]+"=="):i==2&&(d=n[o]<<8|n[o+1],a=(d&64512)>>10,l=(d&1008)>>4,u=(d&15)<<2,e+=t[a]+t[l]+t[u]+"="),e}const rf=256,nf=2*1024*1024;class Ds{static parse(e,t){return new Ds(t).parse(e)}constructor(e){this.options=e||{},this.mimeOptions={maxNestingDepth:this.options.maxNestingDepth||rf,maxHeadersSize:this.options.maxHeadersSize||nf},this.root=this.currentNode=new va({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 i=n[s];if(e.length!==i.value.length+2&&e.length!==i.value.length+4)continue;let o=e.length===i.value.length+4;if(o&&(e[e.length-2]!==45||e[e.length-1]!==45))continue;let a=!0;for(let l=0;l<i.value.length;l++)if(e[l+2]!==i.value[l]){a=!1;break}if(a)return o?(await i.node.finalize(),this.currentNode=i.node.parentNode||this.root):(await i.node.finalizeChildNodes(),this.currentNode=new va({postalMime:this,parentNode:i.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(),i=async(o,a,l)=>{if(a=a||!1,l=l||!1,o.contentType.multipart)o.contentType.multipart==="alternative"?a=o:o.contentType.multipart==="related"&&(l=o);else if(this.isInlineMessageRfc822(o)&&!s){const u=new Ds;o.subMessage=await u.parse(o.content),n.has(o)||n.set(o,{});let c=n.get(o);(o.subMessage.text||!o.subMessage.html)&&(c.plain=c.plain||[],c.plain.push({type:"subMessage",value:o.subMessage}),t.add("plain")),o.subMessage.html&&(c.html=c.html||[],c.html.push({type:"subMessage",value:o.subMessage}),t.add("html")),u.textMap&&u.textMap.forEach((d,h)=>{n.set(h,d)});for(let d of o.subMessage.attachments||[])this.attachments.push(d)}else if(this.isInlineTextNode(o)){let u=o.contentType.parsed.value.substr(o.contentType.parsed.value.indexOf("/")+1),c=a||o;n.has(c)||n.set(c,{});let d=n.get(c);d[u]=d[u]||[],d[u].push({type:"text",value:o.getTextContent()}),t.add(u)}else if(o.content){const u=o.contentDisposition.parsed.params.filename||o.contentType.parsed.params.name||null,c={filename:u?En(u):null,mimeType:o.contentType.parsed.value,disposition:o.contentDisposition.parsed.value||null};switch(l&&o.contentId&&(c.related=!0),o.contentDescription&&(c.description=o.contentDescription),o.contentId&&(c.contentId=o.contentId),o.contentType.parsed.value){case"text/calendar":case"application/ics":{o.contentType.parsed.params.method&&(c.method=o.contentType.parsed.params.method.toString().toUpperCase().trim());const d=o.getTextContent().replace(/\r?\n/g,`
26
26
  `).replace(/\n*$/,`
27
- `);c.content=Xr.encode(d);break}default:c.content=o.content}this.attachments.push(c)}for(let u of o.childNodes)await i(u,l,a)};await i(this.root,!1,[]),n.forEach(o=>{t.forEach(l=>{if(e[l]||(e[l]=[]),o[l])o[l].forEach(a=>{switch(a.type){case"text":e[l].push(a.value);break;case"subMessage":switch(l){case"html":e[l].push(Ca(a.value));break;case"plain":e[l].push(wa(a.value));break}break}});else{let a;switch(l){case"html":a="plain";break;case"plain":a="html";break}(o[a]||[]).forEach(u=>{switch(u.type){case"text":switch(l){case"html":e[l].push(Yd(u.value));break;case"plain":e[l].push(Qd(u.value));break}break;case"subMessage":switch(l){case"html":e[l].push(Ca(u.value));break;case"plain":e[l].push(wa(u.value));break}break}})}})}),Object.keys(e).forEach(o=>{e[o]=e[o].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:a}=await s.read();if(l)break;n.push(a),t+=a.length}const i=new Uint8Array(t);let o=0;for(let l of n)i.set(l,o),o+=l.length;return i}async parse(e){var s,i;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=Xr.encode(e)),(e instanceof Blob||Object.prototype.toString.call(e)==="[object Blob]")&&(e=await ni(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 o=this.readLine();await this.processLine(o.bytes,o.done)}await this.processNodeTree();const t={headers:this.root.headers.map(o=>({key:o.key,value:o.value})).reverse()};for(const o of["from","sender"]){const l=this.root.headers.find(a=>a.key===o);if(l&&l.value){const a=Dn(l.value);a&&a.length&&(t[o]=a[0])}}for(const o of["delivered-to","return-path"]){const l=this.root.headers.find(a=>a.key===o);if(l&&l.value){const a=Dn(l.value);if(a&&a.length&&a[0].address){const u=o.replace(/\-(.)/g,(c,d)=>d.toUpperCase());t[u]=a[0].address}}}for(const o of["to","cc","bcc","reply-to"]){const l=this.root.headers.filter(u=>u.key===o);let a=[];if(l.filter(u=>u&&u.value).map(u=>Dn(u.value)).forEach(u=>a=a.concat(u||[])),a&&a.length){const u=o.replace(/\-(.)/g,(c,d)=>d.toUpperCase());t[u]=a}}for(const o of["subject","message-id","in-reply-to","references"]){const l=this.root.headers.find(a=>a.key===o);if(l&&l.value){const a=o.replace(/\-(.)/g,(u,c)=>c.toUpperCase());t[a]=En(l.value)}}let n=this.root.headers.find(o=>o.key==="date");if(n){let o=new Date(n.value);!o||o.toString()==="Invalid Date"?o=n.value:o=o.toISOString(),t.date=o}switch((s=this.textContent)!=null&&s.html&&(t.html=this.textContent.html),(i=this.textContent)!=null&&i.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=tf(l.content),l.encoding="base64");break;case"utf8":let o=new TextDecoder("utf8");for(let l of t.attachments||[])l!=null&&l.content&&(l.content=o.decode(l.content),l.encoding="utf8");break;default:throw new Error("Unknwon attachment encoding")}return t}}class iu{constructor(e){wt(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 i=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(s)});if(!i.ok){const l=await i.text();throw new Error(`API error (${i.status}): ${l}`)}const o=await i.json();if(!o.success&&o.error)throw new Error(o.error);return o.result}catch(i){throw console.error("API call failed:",i),i}}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 i of s){const o=[`SELECT "${n}"`,...t.map(u=>`UID MOVE ${u} "${i}"`)],a=(await this.imapExec(e,o)).responses.filter(u=>u.ok&&u.command==="UID MOVE").length;if(a>0)return{success:!0,moved:a}}return{success:!1,moved:0}}async archiveEmails(e,t,n="INBOX"){const s=[`SELECT "${n}"`,...t.map(l=>`UID STORE ${l} +FLAGS (\\Deleted)`),"EXPUNGE"],o=(await this.imapExec(e,s)).responses.filter(l=>l.ok&&l.command==="UID STORE").length;return{success:o>0,archived:o}}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)"]),i=s.responses.find(p=>p.command==="SELECT");if(!(i!=null&&i.ok))throw new Error(`Failed to select folder: ${(i==null?void 0:i.error)||"Unknown error"}`);const o=s.responses.find(p=>p.command==="FETCH");if(!(o!=null&&o.ok)||!o.messages)return{account:{id:e,label:"",email:""},mailbox:{name:t,total:i.exists||0},messages:[]};const a=[...o.messages].sort((p,g)=>{const m=p.internalDate?new Date(p.internalDate).getTime():0;return(g.internalDate?new Date(g.internalDate).getTime():0)-m}).slice(0,n).map(p=>p.uid).filter(Boolean);if(a.length===0)return{account:{id:e,label:"",email:""},mailbox:{name:t,total:i.exists||0},messages:[]};const c=(await this.imapExec(e,[`SELECT ${t}`,`UID FETCH ${a.join(",")} (UID FLAGS ENVELOPE)`])).responses.find(p=>p.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 d=new Map;for(const p of c.messages)p.uid&&d.set(p.uid,p);const h=a.map(p=>{var C,S,k,E,v;const g=d.get(p);if(!g)return null;const m=((C=g.flags)==null?void 0:C.some(T=>T.includes("Seen")))||!1,x=((k=(S=g.envelope)==null?void 0:S.from)==null?void 0:k.email)||"Unknown",_=((E=g.envelope)==null?void 0:E.subject)||"(No subject)",b=((v=g.envelope)==null?void 0:v.date)||"";return{uid:p,from:x,subject:_,date:b,seen:m}}).filter(Boolean);return{account:{id:e,label:"",email:""},mailbox:{name:t,total:i.exists||0},messages:h}}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:typeof n=="number"?n:void 0,attachment_id:typeof n=="string"?n:void 0,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 g,m,x,_,b,C;const i=(await this.imapExec(e,[`SELECT "${n}"`,`UID FETCH ${t} (FLAGS BODY[])`])).responses.find(S=>S.command==="UID FETCH");if(!(i!=null&&i.ok)||!((g=i.messages)!=null&&g[0]))return console.error("Failed to fetch raw email:",i==null?void 0:i.error),null;const o=i.messages[0],l=o.body||o.raw;if(!l)return console.error("No raw email content in response"),null;const u=await new Ds().parse(l);console.log("[MailClient] Parsed email - attachments count:",((m=u.attachments)==null?void 0:m.length)||0),console.log("[MailClient] Parsed attachments:",(x=u.attachments)==null?void 0:x.map(S=>({filename:S.filename,mimeType:S.mimeType,contentId:S.contentId})));const c=new Map;for(const S of u.attachments||[])if(S.contentId){const k=this.contentToBase64(S.content),E=`data:${S.mimeType};base64,${k}`,v=S.contentId.replace(/^<|>$/g,"");c.set(v,E),c.set(`<${v}>`,E)}let d=u.html||"";d&&c.size>0&&(d=d.replace(/src=["']cid:([^"']+)["']/gi,(S,k)=>{const E=c.get(k)||c.get(`<${k}>`);return E?`src="${E}"`:S}));const h=((_=o.flags)==null?void 0:_.some(S=>S.toLowerCase().includes("seen")))||!1,p=((b=u.from)==null?void 0:b.address)||((C=u.from)==null?void 0:C.name)||"Unknown";return{uid:t,from:p,subject:u.subject||"(No subject)",date:u.date||"",body:d||u.text||"",html:d,text:u.text||"",seen:h,attachments:(u.attachments||[]).map(S=>({filename:S.filename||"attachment",mimeType:S.mimeType||"application/octet-stream",size:this.getContentSize(S.content)}))}}async findEmailInAllMail(e,t){var i,o;const n=await this.getSettings(),s=((i=n.accounts)==null?void 0:i.find(l=>l.id===e))||((o=n.accounts)==null?void 0:o[0]);if(!(s!=null&&s.imap))return console.error("[MailClient] No IMAP configuration found for account"),{found:!1};try{return await this.callEmail("findEmailInAllMail",{message_id:t.message_id,from:t.from,subject:t.subject,folder:t.folder,imap_config:{host:s.imap.host,port:parseInt(s.imap.port,10)||993,username:s.imap.user,password:s.imap.password}})}catch(l){return console.error("[MailClient] findEmailInAllMail failed:",l),{found:!1}}}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 i=await this.getSettings(),o=((n=i.accounts)==null?void 0:n.find(u=>u.id===e))||((s=i.accounts)==null?void 0:s[0]);if(!(o!=null&&o.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:o.email,smtp_config:{host:o.smtp.host,port:parseInt(o.smtp.port,10)||587,username:o.smtp.user,password:o.smtp.password}};t.cc&&(l.cc=Array.isArray(t.cc)?t.cc:[t.cc]),t.bcc&&(l.bcc=Array.isArray(t.bcc)?t.bcc:[t.bcc]),t.in_reply_to&&(l.in_reply_to=t.in_reply_to),t.attachments&&t.attachments.length>0&&(l.attachments=t.attachments);const a=await this.callEmail("send",l);return{success:(a==null?void 0:a.sent)??!1,message_id:a==null?void 0:a.message_id,error:a==null?void 0:a.error}}catch(i){return{success:!1,error:i instanceof Error?i.message:String(i)}}}async getGmailAuthUrl(e,t){return this.callMail("gmail_get_auth_url",{account_id:e||"gmail",redirect_uri:t||"https://api.qwanyx.com/oauth/gmail/callback"})}async isGmailConnected(e){var t;try{const s=(t=(await this.getSettings()).accounts)==null?void 0:t.find(i=>i.id===e);return(s==null?void 0:s.auth_type)==="gmail_api"&&!!(s!=null&&s.gmail_tokens)}catch{return!1}}async disconnectGmail(e){try{return await this.callMail("gmail_disconnect",{account_id:e}),{success:!0}}catch(t){return{success:!1,error:t instanceof Error?t.message:String(t)}}}async gmailSearchMessage(e,t,n){try{const s=await this.callMail("gmail_search_message",{account_id:e,subject:t,from:n});return(s==null?void 0:s.found)===!1?null:s}catch(s){return console.error("[MailClient] gmailSearchMessage failed:",s),null}}async connectGmail(e){return new Promise(async t=>{try{const{auth_url:n}=await this.getGmailAuthUrl(e),s=600,i=700,o=window.screenX+(window.outerWidth-s)/2,l=window.screenY+(window.outerHeight-i)/2,a=window.open(n,"gmail_oauth",`width=${s},height=${i},left=${o},top=${l},scrollbars=yes`);if(!a){t({success:!1,error:"Popup blocked. Please allow popups for this site."});return}const u=d=>{var h,p;((h=d.data)==null?void 0:h.type)==="gmail_oauth_success"?(window.removeEventListener("message",u),t({success:!0,email:d.data.email})):((p=d.data)==null?void 0:p.type)==="gmail_oauth_error"&&(window.removeEventListener("message",u),t({success:!1,error:d.data.description||d.data.error}))};window.addEventListener("message",u);const c=setInterval(()=>{a.closed&&(clearInterval(c),window.removeEventListener("message",u),setTimeout(()=>{},500))},500)}catch(n){t({success:!1,error:n instanceof Error?n.message:String(n)})}})}}const ou=[{id:"marin",name:"Marin",description:"⭐ Féminin, naturel et fluide"},{id:"cedar",name:"Cedar",description:"⭐ Masculin, expressif et vivant"},{id:"coral",name:"Coral",description:"Féminin, chaleureux et doux"},{id:"alloy",name:"Alloy",description:"Neutre, polyvalent"},{id:"ash",name:"Ash",description:"Masculin, calme et posé"},{id:"ballad",name:"Ballad",description:"Neutre, expressif et narratif"},{id:"echo",name:"Echo",description:"Masculin, profond et résonant"},{id:"fable",name:"Fable",description:"Masculin, accent britannique"},{id:"onyx",name:"Onyx",description:"Masculin, grave et autoritaire"},{id:"nova",name:"Nova",description:"Féminin, dynamique et énergique"},{id:"sage",name:"Sage",description:"Neutre, calme et apaisant"},{id:"shimmer",name:"Shimmer",description:"Féminin, léger et aérien"},{id:"verse",name:"Verse",description:"Neutre, poétique et mélodieux"}];class sf{constructor(e){wt(this,"config");wt(this,"promptCache",{});if(!e.system_id)throw new Error("LLMClient: system_id is REQUIRED");this.config=e}async callLLM(e,t={}){const n={coprocessor:"llm",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 o=await s.text();throw new Error(`LLM API error (${s.status}): ${o}`)}const i=await s.json();if(!i.success&&i.error)throw new Error(i.error);return i}catch(s){throw console.error("LLM API call failed:",s),s}}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async complete(e,t){var i;const n={model:(t==null?void 0:t.model)??"mlm",prompt:e,max_completion_tokens:(t==null?void 0:t.maxTokens)??2e3};t!=null&&t.systemPrompt&&(n.system=t.systemPrompt),(t==null?void 0:t.temperature)!==void 0&&(n.temperature=t.temperature);const s=await this.callLLM("complete",n);return((i=s.result)==null?void 0:i.text)||s.result||""}async chat(e,t){const n={model:(t==null?void 0:t.model)??"mlm",messages:e};(t==null?void 0:t.temperature)!==void 0&&(n.temperature=t.temperature),(t==null?void 0:t.maxTokens)!==void 0&&(n.max_completion_tokens=t.maxTokens);const i=(await this.callLLM("chat",n)).result;return typeof i=="string"?i:typeof(i==null?void 0:i.response)=="string"?i.response:typeof(i==null?void 0:i.text)=="string"?i.text:typeof(i==null?void 0:i.content)=="string"?i.content:typeof(i==null?void 0:i.message)=="string"?i.message:(console.warn("LLMClient.chat: unexpected result format",JSON.stringify(i,null,2)),"")}async chatJson(e,t,n){const s=[{role:"system",content:e},{role:"user",content:t}];let o=await this.chat(s,n);return typeof o=="string"&&(o=o.trim(),o.startsWith("```json")?o=o.slice(7):o.startsWith("```")&&(o=o.slice(3)),o.endsWith("```")&&(o=o.slice(0,-3)),o=o.trim()),JSON.parse(o)}async analyzeDocuments(e,t,n){var o;const s={prompt:e,files:t,model:(n==null?void 0:n.model)??"xlm"};return(n==null?void 0:n.temperature)!==void 0&&(s.temperature=n.temperature),(n==null?void 0:n.maxTokens)!==void 0&&(s.max_tokens=n.maxTokens),((o=(await this.callLLM("analyze",s)).result)==null?void 0:o.text)||""}async tts(e,t){var i;const n={model:"gpt-4o-mini-tts",voice:(t==null?void 0:t.voice)??"coral",input:e,response_format:"mp3"},s=await this.callLLM("tts",n);return((i=s.result)==null?void 0:i.audio)||s.result||""}async generateImage(e,t){var i;const n={prompt:e,size:(t==null?void 0:t.size)??"1536x1024",quality:(t==null?void 0:t.quality)??"medium"};return((i=(await this.callLLM("generate_image",n)).result)==null?void 0:i.image)||""}async transcribe(e,t){var i;const n={audio_data:e};return t!=null&&t.filename&&(n.filename=t.filename),t!=null&&t.language&&(n.language=t.language),((i=(await this.callLLM("transcribe",n)).result)==null?void 0:i.text)||""}async getPrompt(e){var s;if(this.promptCache[e])return this.promptCache[e];const n=((s=(await this.callLLM("get_prompt",{name:e})).result)==null?void 0:s.content)||"";return this.promptCache[e]=n,n}clearPromptCache(){this.promptCache={}}buildPrompt(e,t){let n=e;for(const[s,i]of Object.entries(t))n=n.replace(new RegExp(`\\{\\{${s}\\}\\}`,"g"),i);return n}}const Ai="qwanyx_auth_token",Ti="qwanyx_refresh_token",Ni="qwanyx_auth_user";class Ze{static setToken(e){typeof window<"u"&&localStorage.setItem(Ai,e)}static getToken(){return typeof window<"u"?localStorage.getItem(Ai):null}static clearToken(){typeof window<"u"&&(localStorage.removeItem(Ai),localStorage.removeItem(Ti))}static setRefreshToken(e){typeof window<"u"&&localStorage.setItem(Ti,e)}static getRefreshToken(){return typeof window<"u"?localStorage.getItem(Ti):null}static isAuthenticated(){return!!this.getToken()}static getAuthHeader(){const e=this.getToken();return e?{Authorization:`Bearer ${e}`}:{}}static setUser(e){typeof window<"u"&&localStorage.setItem(Ni,JSON.stringify(e))}static getUser(){if(typeof window<"u"){const e=localStorage.getItem(Ni);if(e)try{return JSON.parse(e)}catch{return null}}return null}static clearUser(){typeof window<"u"&&localStorage.removeItem(Ni)}static clearAll(){this.clearToken(),this.clearUser()}}class Ao{constructor(e){wt(this,"config");this.config=e}async register(e,t,n){var s,i;try{const o=n!=null&&n.tenantDomain?[n.tenantDomain]:[],l=(n==null?void 0:n.tenantDomain)||null,u=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"register",params:{email:e,password:t,...n,domains:o,primaryDomain:l,system_id:this.config.systemId}})})).json();return u.success&&((s=u.result)!=null&&s.success)?{success:!0,userId:u.result.user_id,email:u.result.email,requiresVerification:u.result.requiresVerification}:{success:!1,error:((i=u.result)==null?void 0:i.message)||u.error||"Registration failed"}}catch(o){return{success:!1,error:o instanceof Error?o.message:"Network error"}}}async verifyEmail(e,t){var n,s,i,o;try{const a=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"verify_email",params:{email:e,code:t}})})).json();if(a.success&&((n=a.result)!=null&&n.token)){const{token:u,user:c}=a.result;return Ze.setToken(u),Ze.setUser(c),(i=(s=this.config).onLogin)==null||i.call(s,c),{success:!0,user:c,token:u}}else return{success:!1,error:((o=a.result)==null?void 0:o.error)||a.error||"Verification failed"}}catch(l){return{success:!1,error:l instanceof Error?l.message:"Network error"}}}async requestPasswordReset(e){var t,n;try{const i=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"request_password_reset",params:{email:e}})})).json();return i.success&&((t=i.result)!=null&&t.success)?{success:!0,message:i.result.message}:{success:!1,error:((n=i.result)==null?void 0:n.message)||i.error||"Request failed"}}catch(s){return{success:!1,error:s instanceof Error?s.message:"Network error"}}}async setPasswordWithCode(e,t,n){var s,i,o,l;try{const u=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"set_password_with_code",params:{email:e,code:t,password:n}})})).json();if(u.success&&((s=u.result)!=null&&s.token)){const{token:c,user:d}=u.result;return Ze.setToken(c),Ze.setUser(d),(o=(i=this.config).onLogin)==null||o.call(i,d),{success:!0,user:d,token:c}}else return{success:!1,error:((l=u.result)==null?void 0:l.message)||u.error||"Password reset failed"}}catch(a){return{success:!1,error:a instanceof Error?a.message:"Network error"}}}async login(e,t,n){var s,i,o,l,a,u,c;try{const h=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"login",params:{email:e,password:t,system_id:this.config.systemId,...n}})})).json();if((s=h.result)!=null&&s.requiresVerification||h.requiresVerification)return{success:!1,error:((i=h.result)==null?void 0:i.error)||h.error||"Please verify your email first",requiresVerification:!0};if(h.success&&((o=h.result)!=null&&o.token)){const{token:p,user:g}=h.result;return Ze.setToken(p),Ze.setUser(g),n!=null&&n.tenantDomain&&!((l=g.domains)!=null&&l.includes(n.tenantDomain))&&this.addDomainToUser(g._id||g.id,n.tenantDomain).catch(()=>{}),(u=(a=this.config).onLogin)==null||u.call(a,g),{success:!0,user:g,token:p}}else return{success:!1,error:((c=h.result)==null?void 0:c.error)||h.error||"Login failed"}}catch(d){return{success:!1,error:d instanceof Error?d.message:"Network error"}}}async resendVerificationCode(e){return this.requestPasswordReset(e)}logout(){var e,t;Ze.clearAll(),(t=(e=this.config).onLogout)==null||t.call(e)}async checkRole(e,t){var n;try{const i=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Ze.getAuthHeader()},body:JSON.stringify({system_id:this.config.systemId||"system",coprocessor:"graph",method:"get_user_role",params:{group_id:e,target_user_id:t}})})).json();return i.success&&((n=i.result)!=null&&n.role)?i.result.role:null}catch{return null}}async isAdmin(e){return this.config.systemId?await this.checkRole(`${this.config.systemId}__admins`,e)==="admin":!1}getCurrentUser(){return Ze.getUser()}isAuthenticated(){return Ze.isAuthenticated()}async addDomainToUser(e,t){try{const s=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Ze.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"add_domain_to_user",params:{user_id:e,domain:t}})})).json();return{success:s.success||!1,error:s.error}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Network error"}}}async listAllUsers(e){try{const n=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Ze.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"list_users",params:{...(e==null?void 0:e.limit)&&{limit:e.limit},...(e==null?void 0:e.offset)&&{offset:e.offset}}})})).json();return n.success&&n.result?{success:!0,users:n.result.users||[],total:n.result.total||0}:{success:!1,error:n.error||"Failed to list users"}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Network error"}}}async listSystemUsers(e){if(!this.config.systemId)return{success:!1,error:"System ID not configured"};try{const n=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Ze.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"list_system_users",params:{system_id:this.config.systemId,...(e==null?void 0:e.limit)&&{limit:e.limit},...(e==null?void 0:e.offset)&&{offset:e.offset}}})})).json();return n.success&&n.result?{success:!0,users:n.result.users||[],total:n.result.total||0}:{success:!1,error:n.error||"Failed to list users"}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Network error"}}}async addUserToSystem(e,t="member"){if(!this.config.systemId)return{success:!1,error:"System ID not configured"};try{const s=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Ze.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"add_system_to_user",params:{user_id:e,system_id:this.config.systemId,role:t}})})).json();return{success:s.success||!1,error:s.error}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Network error"}}}async updateMembershipRole(e,t){if(!this.config.systemId)return{success:!1,error:"System ID not configured"};try{const s=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Ze.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"add_system_to_user",params:{user_id:e,system_id:this.config.systemId,role:t}})})).json();return{success:s.success||!1,error:s.error}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Network error"}}}async listUserSystems(e){try{const n=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Ze.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"list_systems",params:{user_id:e}})})).json();return n.success&&n.result?{success:!0,systems:n.result.systems||[]}:{success:!1,error:n.error||"Failed to list user systems"}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Network error"}}}async updateUser(e,t){try{const s=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Ze.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"update_user",params:{user_id:e,updates:t}})})).json();if(s.success&&s.result){const i=Ze.getUser();if(i&&(i._id===e||i.id===e)){const o={...i,...t};Ze.setUser(o)}return{success:!0}}return{success:!1,error:s.error||"Update failed"}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Network error"}}}async removeUserFromSystem(e){if(!this.config.systemId)return{success:!1,error:"System ID not configured"};try{const n=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Ze.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"remove_system_from_user",params:{user_id:e,system_id:this.config.systemId}})})).json();return{success:n.success||!1,error:n.error}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Network error"}}}}let As=null;function of(r){return As=new Ao(r),As}function af(){if(!As)throw new Error("Auth service not initialized. Call initializeAuthService() first.");return As}class au{constructor(e){wt(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,i])=>{i!=null&&t.append(s,String(i))});const n=t.toString();return n?`?${n}`:""}async request(e,t={}){const{method:n="GET",headers:s={},body:i,params:o}=t,l=`${this.config.baseUrl}/${e}${this.buildQueryString(o)}`,a={...this.config.headers,...Ze.getAuthHeader(),...s},u={method:n,headers:a};i&&n!=="GET"&&(u.body=JSON.stringify(i));try{const c=new AbortController,d=setTimeout(()=>c.abort(),this.config.timeout),h=await fetch(l,{...u,signal:c.signal});if(clearTimeout(d),!h.ok){const p=await h.json().catch(()=>({message:h.statusText}));throw new Error(p.message||`HTTP ${h.status}`)}return await h.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 Ts=null;function lf(r){return Ts=new au(r),Ts}function To(){if(!Ts)throw new Error("API client not initialized. Call initializeApiClient() first.");return Ts}var Vi={exports:{}},cn={};/**
27
+ `);c.content=Xr.encode(d);break}default:c.content=o.content}this.attachments.push(c)}for(let u of o.childNodes)await i(u,a,l)};await i(this.root,!1,[]),n.forEach(o=>{t.forEach(a=>{if(e[a]||(e[a]=[]),o[a])o[a].forEach(l=>{switch(l.type){case"text":e[a].push(l.value);break;case"subMessage":switch(a){case"html":e[a].push(Ca(l.value));break;case"plain":e[a].push(wa(l.value));break}break}});else{let l;switch(a){case"html":l="plain";break;case"plain":l="html";break}(o[l]||[]).forEach(u=>{switch(u.type){case"text":switch(a){case"html":e[a].push(Yd(u.value));break;case"plain":e[a].push(Qd(u.value));break}break;case"subMessage":switch(a){case"html":e[a].push(Ca(u.value));break;case"plain":e[a].push(wa(u.value));break}break}})}})}),Object.keys(e).forEach(o=>{e[o]=e[o].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:a,value:l}=await s.read();if(a)break;n.push(l),t+=l.length}const i=new Uint8Array(t);let o=0;for(let a of n)i.set(a,o),o+=a.length;return i}async parse(e){var s,i;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=Xr.encode(e)),(e instanceof Blob||Object.prototype.toString.call(e)==="[object Blob]")&&(e=await ni(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 o=this.readLine();await this.processLine(o.bytes,o.done)}await this.processNodeTree();const t={headers:this.root.headers.map(o=>({key:o.key,value:o.value})).reverse()};for(const o of["from","sender"]){const a=this.root.headers.find(l=>l.key===o);if(a&&a.value){const l=Dn(a.value);l&&l.length&&(t[o]=l[0])}}for(const o of["delivered-to","return-path"]){const a=this.root.headers.find(l=>l.key===o);if(a&&a.value){const l=Dn(a.value);if(l&&l.length&&l[0].address){const u=o.replace(/\-(.)/g,(c,d)=>d.toUpperCase());t[u]=l[0].address}}}for(const o of["to","cc","bcc","reply-to"]){const a=this.root.headers.filter(u=>u.key===o);let l=[];if(a.filter(u=>u&&u.value).map(u=>Dn(u.value)).forEach(u=>l=l.concat(u||[])),l&&l.length){const u=o.replace(/\-(.)/g,(c,d)=>d.toUpperCase());t[u]=l}}for(const o of["subject","message-id","in-reply-to","references"]){const a=this.root.headers.find(l=>l.key===o);if(a&&a.value){const l=o.replace(/\-(.)/g,(u,c)=>c.toUpperCase());t[l]=En(a.value)}}let n=this.root.headers.find(o=>o.key==="date");if(n){let o=new Date(n.value);!o||o.toString()==="Invalid Date"?o=n.value:o=o.toISOString(),t.date=o}switch((s=this.textContent)!=null&&s.html&&(t.html=this.textContent.html),(i=this.textContent)!=null&&i.plain&&(t.text=this.textContent.plain),t.attachments=this.attachments,this.attachmentEncoding){case"arraybuffer":break;case"base64":for(let a of t.attachments||[])a!=null&&a.content&&(a.content=tf(a.content),a.encoding="base64");break;case"utf8":let o=new TextDecoder("utf8");for(let a of t.attachments||[])a!=null&&a.content&&(a.content=o.decode(a.content),a.encoding="utf8");break;default:throw new Error("Unknwon attachment encoding")}return t}}class iu{constructor(e){_t(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 i=await fetch(`${this.config.baseUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",Authorization:`Bearer ${this.getToken()}`},body:JSON.stringify(s)});if(!i.ok){const a=await i.text();throw new Error(`API error (${i.status}): ${a}`)}const o=await i.json();if(!o.success&&o.error)throw new Error(o.error);return o.result}catch(i){throw console.error("API call failed:",i),i}}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 i of s){const o=[`SELECT "${n}"`,...t.map(u=>`UID MOVE ${u} "${i}"`)],l=(await this.imapExec(e,o)).responses.filter(u=>u.ok&&u.command==="UID MOVE").length;if(l>0)return{success:!0,moved:l}}return{success:!1,moved:0}}async archiveEmails(e,t,n="INBOX"){const s=[`SELECT "${n}"`,...t.map(a=>`UID STORE ${a} +FLAGS (\\Deleted)`),"EXPUNGE"],o=(await this.imapExec(e,s)).responses.filter(a=>a.ok&&a.command==="UID STORE").length;return{success:o>0,archived:o}}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)"]),i=s.responses.find(p=>p.command==="SELECT");if(!(i!=null&&i.ok))throw new Error(`Failed to select folder: ${(i==null?void 0:i.error)||"Unknown error"}`);const o=s.responses.find(p=>p.command==="FETCH");if(!(o!=null&&o.ok)||!o.messages)return{account:{id:e,label:"",email:""},mailbox:{name:t,total:i.exists||0},messages:[]};const l=[...o.messages].sort((p,g)=>{const m=p.internalDate?new Date(p.internalDate).getTime():0;return(g.internalDate?new Date(g.internalDate).getTime():0)-m}).slice(0,n).map(p=>p.uid).filter(Boolean);if(l.length===0)return{account:{id:e,label:"",email:""},mailbox:{name:t,total:i.exists||0},messages:[]};const c=(await this.imapExec(e,[`SELECT ${t}`,`UID FETCH ${l.join(",")} (UID FLAGS ENVELOPE)`])).responses.find(p=>p.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 d=new Map;for(const p of c.messages)p.uid&&d.set(p.uid,p);const h=l.map(p=>{var S,C,k,E,v;const g=d.get(p);if(!g)return null;const m=((S=g.flags)==null?void 0:S.some(T=>T.includes("Seen")))||!1,x=((k=(C=g.envelope)==null?void 0:C.from)==null?void 0:k.email)||"Unknown",_=((E=g.envelope)==null?void 0:E.subject)||"(No subject)",b=((v=g.envelope)==null?void 0:v.date)||"";return{uid:p,from:x,subject:_,date:b,seen:m}}).filter(Boolean);return{account:{id:e,label:"",email:""},mailbox:{name:t,total:i.exists||0},messages:h}}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:typeof n=="number"?n:void 0,attachment_id:typeof n=="string"?n:void 0,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 g,m,x,_,b,S;const i=(await this.imapExec(e,[`SELECT "${n}"`,`UID FETCH ${t} (FLAGS BODY[])`])).responses.find(C=>C.command==="UID FETCH");if(!(i!=null&&i.ok)||!((g=i.messages)!=null&&g[0]))return console.error("Failed to fetch raw email:",i==null?void 0:i.error),null;const o=i.messages[0],a=o.body||o.raw;if(!a)return console.error("No raw email content in response"),null;const u=await new Ds().parse(a);console.log("[MailClient] Parsed email - attachments count:",((m=u.attachments)==null?void 0:m.length)||0),console.log("[MailClient] Parsed attachments:",(x=u.attachments)==null?void 0:x.map(C=>({filename:C.filename,mimeType:C.mimeType,contentId:C.contentId})));const c=new Map;for(const C of u.attachments||[])if(C.contentId){const k=this.contentToBase64(C.content),E=`data:${C.mimeType};base64,${k}`,v=C.contentId.replace(/^<|>$/g,"");c.set(v,E),c.set(`<${v}>`,E)}let d=u.html||"";d&&c.size>0&&(d=d.replace(/src=["']cid:([^"']+)["']/gi,(C,k)=>{const E=c.get(k)||c.get(`<${k}>`);return E?`src="${E}"`:C}));const h=((_=o.flags)==null?void 0:_.some(C=>C.toLowerCase().includes("seen")))||!1,p=((b=u.from)==null?void 0:b.address)||((S=u.from)==null?void 0:S.name)||"Unknown";return{uid:t,from:p,subject:u.subject||"(No subject)",date:u.date||"",body:d||u.text||"",html:d,text:u.text||"",seen:h,attachments:(u.attachments||[]).map(C=>({filename:C.filename||"attachment",mimeType:C.mimeType||"application/octet-stream",size:this.getContentSize(C.content)}))}}async findEmailInAllMail(e,t){var i,o;const n=await this.getSettings(),s=((i=n.accounts)==null?void 0:i.find(a=>a.id===e))||((o=n.accounts)==null?void 0:o[0]);if(!(s!=null&&s.imap))return console.error("[MailClient] No IMAP configuration found for account"),{found:!1};try{return await this.callEmail("findEmailInAllMail",{message_id:t.message_id,from:t.from,subject:t.subject,folder:t.folder,imap_config:{host:s.imap.host,port:parseInt(s.imap.port,10)||993,username:s.imap.user,password:s.imap.password}})}catch(a){return console.error("[MailClient] findEmailInAllMail failed:",a),{found:!1}}}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 i=await this.getSettings(),o=((n=i.accounts)==null?void 0:n.find(u=>u.id===e))||((s=i.accounts)==null?void 0:s[0]);if(!(o!=null&&o.smtp))return{success:!1,error:"No SMTP configuration found for account"};const a={to:Array.isArray(t.to)?t.to:[t.to],subject:t.subject,body:t.text||"",html:t.html,from:o.email,smtp_config:{host:o.smtp.host,port:parseInt(o.smtp.port,10)||587,username:o.smtp.user,password:o.smtp.password}};t.cc&&(a.cc=Array.isArray(t.cc)?t.cc:[t.cc]),t.bcc&&(a.bcc=Array.isArray(t.bcc)?t.bcc:[t.bcc]),t.in_reply_to&&(a.in_reply_to=t.in_reply_to),t.attachments&&t.attachments.length>0&&(a.attachments=t.attachments);const l=await this.callEmail("send",a);return{success:(l==null?void 0:l.sent)??!1,message_id:l==null?void 0:l.message_id,error:l==null?void 0:l.error}}catch(i){return{success:!1,error:i instanceof Error?i.message:String(i)}}}async getGmailAuthUrl(e,t){return this.callMail("gmail_get_auth_url",{account_id:e||"gmail",redirect_uri:t||"https://api.qwanyx.com/oauth/gmail/callback"})}async isGmailConnected(e){var t;try{const s=(t=(await this.getSettings()).accounts)==null?void 0:t.find(i=>i.id===e);return(s==null?void 0:s.auth_type)==="gmail_api"&&!!(s!=null&&s.gmail_tokens)}catch{return!1}}async disconnectGmail(e){try{return await this.callMail("gmail_disconnect",{account_id:e}),{success:!0}}catch(t){return{success:!1,error:t instanceof Error?t.message:String(t)}}}async gmailSearchMessage(e,t,n){try{const s=await this.callMail("gmail_search_message",{account_id:e,subject:t,from:n});return(s==null?void 0:s.found)===!1?null:s}catch(s){return console.error("[MailClient] gmailSearchMessage failed:",s),null}}async connectGmail(e){return new Promise(async t=>{try{const{auth_url:n}=await this.getGmailAuthUrl(e),s=600,i=700,o=window.screenX+(window.outerWidth-s)/2,a=window.screenY+(window.outerHeight-i)/2,l=window.open(n,"gmail_oauth",`width=${s},height=${i},left=${o},top=${a},scrollbars=yes`);if(!l){t({success:!1,error:"Popup blocked. Please allow popups for this site."});return}const u=d=>{var h,p;((h=d.data)==null?void 0:h.type)==="gmail_oauth_success"?(window.removeEventListener("message",u),t({success:!0,email:d.data.email})):((p=d.data)==null?void 0:p.type)==="gmail_oauth_error"&&(window.removeEventListener("message",u),t({success:!1,error:d.data.description||d.data.error}))};window.addEventListener("message",u);const c=setInterval(()=>{l.closed&&(clearInterval(c),window.removeEventListener("message",u),setTimeout(()=>{},500))},500)}catch(n){t({success:!1,error:n instanceof Error?n.message:String(n)})}})}}const ou=[{id:"marin",name:"Marin",description:"⭐ Féminin, naturel et fluide"},{id:"cedar",name:"Cedar",description:"⭐ Masculin, expressif et vivant"},{id:"coral",name:"Coral",description:"Féminin, chaleureux et doux"},{id:"alloy",name:"Alloy",description:"Neutre, polyvalent"},{id:"ash",name:"Ash",description:"Masculin, calme et posé"},{id:"ballad",name:"Ballad",description:"Neutre, expressif et narratif"},{id:"echo",name:"Echo",description:"Masculin, profond et résonant"},{id:"fable",name:"Fable",description:"Masculin, accent britannique"},{id:"onyx",name:"Onyx",description:"Masculin, grave et autoritaire"},{id:"nova",name:"Nova",description:"Féminin, dynamique et énergique"},{id:"sage",name:"Sage",description:"Neutre, calme et apaisant"},{id:"shimmer",name:"Shimmer",description:"Féminin, léger et aérien"},{id:"verse",name:"Verse",description:"Neutre, poétique et mélodieux"}];class sf{constructor(e){_t(this,"config");_t(this,"promptCache",{});if(!e.system_id)throw new Error("LLMClient: system_id is REQUIRED");this.config=e}async callLLM(e,t={}){const n={coprocessor:"llm",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 o=await s.text();throw new Error(`LLM API error (${s.status}): ${o}`)}const i=await s.json();if(!i.success&&i.error)throw new Error(i.error);return i}catch(s){throw console.error("LLM API call failed:",s),s}}getToken(){return typeof window<"u"&&window.localStorage&&localStorage.getItem("qwanyx_token")||""}async complete(e,t){var i;const n={model:(t==null?void 0:t.model)??"mlm",prompt:e,max_completion_tokens:(t==null?void 0:t.maxTokens)??2e3};t!=null&&t.systemPrompt&&(n.system=t.systemPrompt),(t==null?void 0:t.temperature)!==void 0&&(n.temperature=t.temperature);const s=await this.callLLM("complete",n);return((i=s.result)==null?void 0:i.text)||s.result||""}async chat(e,t){const n={model:(t==null?void 0:t.model)??"mlm",messages:e};(t==null?void 0:t.temperature)!==void 0&&(n.temperature=t.temperature),(t==null?void 0:t.maxTokens)!==void 0&&(n.max_completion_tokens=t.maxTokens);const i=(await this.callLLM("chat",n)).result;return typeof i=="string"?i:typeof(i==null?void 0:i.response)=="string"?i.response:typeof(i==null?void 0:i.text)=="string"?i.text:typeof(i==null?void 0:i.content)=="string"?i.content:typeof(i==null?void 0:i.message)=="string"?i.message:(console.warn("LLMClient.chat: unexpected result format",JSON.stringify(i,null,2)),"")}async chatJson(e,t,n){const s=[{role:"system",content:e},{role:"user",content:t}];let o=await this.chat(s,n);return typeof o=="string"&&(o=o.trim(),o.startsWith("```json")?o=o.slice(7):o.startsWith("```")&&(o=o.slice(3)),o.endsWith("```")&&(o=o.slice(0,-3)),o=o.trim()),JSON.parse(o)}async analyzeDocuments(e,t,n){var o;const s={prompt:e,files:t,model:(n==null?void 0:n.model)??"xlm"};return(n==null?void 0:n.temperature)!==void 0&&(s.temperature=n.temperature),(n==null?void 0:n.maxTokens)!==void 0&&(s.max_tokens=n.maxTokens),((o=(await this.callLLM("analyze",s)).result)==null?void 0:o.text)||""}async tts(e,t){var i;const n={model:"gpt-4o-mini-tts",voice:(t==null?void 0:t.voice)??"coral",input:e,response_format:"mp3"},s=await this.callLLM("tts",n);return((i=s.result)==null?void 0:i.audio)||s.result||""}async generateImage(e,t){var i;const n={prompt:e,size:(t==null?void 0:t.size)??"1536x1024",quality:(t==null?void 0:t.quality)??"medium"};return((i=(await this.callLLM("generate_image",n)).result)==null?void 0:i.image)||""}async transcribe(e,t){var i;const n={audio_data:e};return t!=null&&t.filename&&(n.filename=t.filename),t!=null&&t.language&&(n.language=t.language),((i=(await this.callLLM("transcribe",n)).result)==null?void 0:i.text)||""}async getPrompt(e){var s;if(this.promptCache[e])return this.promptCache[e];const n=((s=(await this.callLLM("get_prompt",{name:e})).result)==null?void 0:s.content)||"";return this.promptCache[e]=n,n}clearPromptCache(){this.promptCache={}}buildPrompt(e,t){let n=e;for(const[s,i]of Object.entries(t))n=n.replace(new RegExp(`\\{\\{${s}\\}\\}`,"g"),i);return n}}const Ai="qwanyx_auth_token",Ti="qwanyx_refresh_token",Ni="qwanyx_auth_user";class Je{static setToken(e){typeof window<"u"&&localStorage.setItem(Ai,e)}static getToken(){return typeof window<"u"?localStorage.getItem(Ai):null}static clearToken(){typeof window<"u"&&(localStorage.removeItem(Ai),localStorage.removeItem(Ti))}static setRefreshToken(e){typeof window<"u"&&localStorage.setItem(Ti,e)}static getRefreshToken(){return typeof window<"u"?localStorage.getItem(Ti):null}static isAuthenticated(){return!!this.getToken()}static getAuthHeader(){const e=this.getToken();return e?{Authorization:`Bearer ${e}`}:{}}static setUser(e){typeof window<"u"&&localStorage.setItem(Ni,JSON.stringify(e))}static getUser(){if(typeof window<"u"){const e=localStorage.getItem(Ni);if(e)try{return JSON.parse(e)}catch{return null}}return null}static clearUser(){typeof window<"u"&&localStorage.removeItem(Ni)}static clearAll(){this.clearToken(),this.clearUser()}}class Ao{constructor(e){_t(this,"config");this.config=e}async register(e,t,n){var s,i;try{const o=n!=null&&n.tenantDomain?[n.tenantDomain]:[],a=(n==null?void 0:n.tenantDomain)||null,u=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"register",params:{email:e,password:t,...n,domains:o,primaryDomain:a,system_id:this.config.systemId}})})).json();return u.success&&((s=u.result)!=null&&s.success)?{success:!0,userId:u.result.user_id,email:u.result.email,requiresVerification:u.result.requiresVerification}:{success:!1,error:((i=u.result)==null?void 0:i.message)||u.error||"Registration failed"}}catch(o){return{success:!1,error:o instanceof Error?o.message:"Network error"}}}async verifyEmail(e,t){var n,s,i,o;try{const l=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"verify_email",params:{email:e,code:t}})})).json();if(l.success&&((n=l.result)!=null&&n.token)){const{token:u,user:c}=l.result;return Je.setToken(u),Je.setUser(c),(i=(s=this.config).onLogin)==null||i.call(s,c),{success:!0,user:c,token:u}}else return{success:!1,error:((o=l.result)==null?void 0:o.error)||l.error||"Verification failed"}}catch(a){return{success:!1,error:a instanceof Error?a.message:"Network error"}}}async requestPasswordReset(e){var t,n;try{const i=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"request_password_reset",params:{email:e}})})).json();return i.success&&((t=i.result)!=null&&t.success)?{success:!0,message:i.result.message}:{success:!1,error:((n=i.result)==null?void 0:n.message)||i.error||"Request failed"}}catch(s){return{success:!1,error:s instanceof Error?s.message:"Network error"}}}async setPasswordWithCode(e,t,n){var s,i,o,a;try{const u=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"set_password_with_code",params:{email:e,code:t,password:n}})})).json();if(u.success&&((s=u.result)!=null&&s.token)){const{token:c,user:d}=u.result;return Je.setToken(c),Je.setUser(d),(o=(i=this.config).onLogin)==null||o.call(i,d),{success:!0,user:d,token:c}}else return{success:!1,error:((a=u.result)==null?void 0:a.message)||u.error||"Password reset failed"}}catch(l){return{success:!1,error:l instanceof Error?l.message:"Network error"}}}async login(e,t,n){var s,i,o,a,l,u,c;try{const h=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"login",params:{email:e,password:t,system_id:this.config.systemId,...n}})})).json();if((s=h.result)!=null&&s.requiresVerification||h.requiresVerification)return{success:!1,error:((i=h.result)==null?void 0:i.error)||h.error||"Please verify your email first",requiresVerification:!0};if(h.success&&((o=h.result)!=null&&o.token)){const{token:p,user:g}=h.result;return Je.setToken(p),Je.setUser(g),n!=null&&n.tenantDomain&&!((a=g.domains)!=null&&a.includes(n.tenantDomain))&&this.addDomainToUser(g._id||g.id,n.tenantDomain).catch(()=>{}),(u=(l=this.config).onLogin)==null||u.call(l,g),{success:!0,user:g,token:p}}else return{success:!1,error:((c=h.result)==null?void 0:c.error)||h.error||"Login failed"}}catch(d){return{success:!1,error:d instanceof Error?d.message:"Network error"}}}async resendVerificationCode(e){return this.requestPasswordReset(e)}logout(){var e,t;Je.clearAll(),(t=(e=this.config).onLogout)==null||t.call(e)}async checkRole(e,t){var n;try{const i=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Je.getAuthHeader()},body:JSON.stringify({system_id:this.config.systemId||"system",coprocessor:"graph",method:"get_user_role",params:{group_id:e,target_user_id:t}})})).json();return i.success&&((n=i.result)!=null&&n.role)?i.result.role:null}catch{return null}}async isAdmin(e){return this.config.systemId?await this.checkRole(`${this.config.systemId}__admins`,e)==="admin":!1}getCurrentUser(){return Je.getUser()}isAuthenticated(){return Je.isAuthenticated()}async addDomainToUser(e,t){try{const s=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Je.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"add_domain_to_user",params:{user_id:e,domain:t}})})).json();return{success:s.success||!1,error:s.error}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Network error"}}}async listAllUsers(e){try{const n=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Je.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"list_users",params:{...(e==null?void 0:e.limit)&&{limit:e.limit},...(e==null?void 0:e.offset)&&{offset:e.offset}}})})).json();return n.success&&n.result?{success:!0,users:n.result.users||[],total:n.result.total||0}:{success:!1,error:n.error||"Failed to list users"}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Network error"}}}async listSystemUsers(e){if(!this.config.systemId)return{success:!1,error:"System ID not configured"};try{const n=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Je.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"list_system_users",params:{system_id:this.config.systemId,...(e==null?void 0:e.limit)&&{limit:e.limit},...(e==null?void 0:e.offset)&&{offset:e.offset}}})})).json();return n.success&&n.result?{success:!0,users:n.result.users||[],total:n.result.total||0}:{success:!1,error:n.error||"Failed to list users"}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Network error"}}}async addUserToSystem(e,t="member"){if(!this.config.systemId)return{success:!1,error:"System ID not configured"};try{const s=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Je.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"add_system_to_user",params:{user_id:e,system_id:this.config.systemId,role:t}})})).json();return{success:s.success||!1,error:s.error}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Network error"}}}async updateMembershipRole(e,t){if(!this.config.systemId)return{success:!1,error:"System ID not configured"};try{const s=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Je.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"add_system_to_user",params:{user_id:e,system_id:this.config.systemId,role:t}})})).json();return{success:s.success||!1,error:s.error}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Network error"}}}async listUserSystems(e){try{const n=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Je.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"list_systems",params:{user_id:e}})})).json();return n.success&&n.result?{success:!0,systems:n.result.systems||[]}:{success:!1,error:n.error||"Failed to list user systems"}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Network error"}}}async updateUser(e,t){try{const s=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Je.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"update_user",params:{user_id:e,updates:t}})})).json();if(s.success&&s.result){const i=Je.getUser();if(i&&(i._id===e||i.id===e)){const o={...i,...t};Je.setUser(o)}return{success:!0}}return{success:!1,error:s.error||"Update failed"}}catch(n){return{success:!1,error:n instanceof Error?n.message:"Network error"}}}async removeUserFromSystem(e){if(!this.config.systemId)return{success:!1,error:"System ID not configured"};try{const n=await(await fetch(`${this.config.apiUrl}/spu/invoke`,{method:"POST",headers:{"Content-Type":"application/json",...Je.getAuthHeader()},body:JSON.stringify({system_id:"system",coprocessor:"auth",method:"remove_system_from_user",params:{user_id:e,system_id:this.config.systemId}})})).json();return{success:n.success||!1,error:n.error}}catch(t){return{success:!1,error:t instanceof Error?t.message:"Network error"}}}}let As=null;function of(r){return As=new Ao(r),As}function af(){if(!As)throw new Error("Auth service not initialized. Call initializeAuthService() first.");return As}class au{constructor(e){_t(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,i])=>{i!=null&&t.append(s,String(i))});const n=t.toString();return n?`?${n}`:""}async request(e,t={}){const{method:n="GET",headers:s={},body:i,params:o}=t,a=`${this.config.baseUrl}/${e}${this.buildQueryString(o)}`,l={...this.config.headers,...Je.getAuthHeader(),...s},u={method:n,headers:l};i&&n!=="GET"&&(u.body=JSON.stringify(i));try{const c=new AbortController,d=setTimeout(()=>c.abort(),this.config.timeout),h=await fetch(a,{...u,signal:c.signal});if(clearTimeout(d),!h.ok){const p=await h.json().catch(()=>({message:h.statusText}));throw new Error(p.message||`HTTP ${h.status}`)}return await h.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 Ts=null;function lf(r){return Ts=new au(r),Ts}function To(){if(!Ts)throw new Error("API client not initialized. Call initializeApiClient() first.");return Ts}var Vi={exports:{}},cn={};/**
29
29
  * @license React
30
30
  * react-jsx-runtime.production.min.js
31
31
  *
@@ -33,7 +33,7 @@ ${s}
33
33
  *
34
34
  * This source code is licensed under the MIT license found in the
35
35
  * LICENSE file in the root directory of this source tree.
36
- */var Sa;function uf(){if(Sa)return cn;Sa=1;var r=y,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,s=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(l,a,u){var c,d={},h=null,p=null;u!==void 0&&(h=""+u),a.key!==void 0&&(h=""+a.key),a.ref!==void 0&&(p=a.ref);for(c in a)n.call(a,c)&&!i.hasOwnProperty(c)&&(d[c]=a[c]);if(l&&l.defaultProps)for(c in a=l.defaultProps,a)d[c]===void 0&&(d[c]=a[c]);return{$$typeof:e,type:l,key:h,ref:p,props:d,_owner:s.current}}return cn.Fragment=t,cn.jsx=o,cn.jsxs=o,cn}var dn={};/**
36
+ */var Sa;function uf(){if(Sa)return cn;Sa=1;var r=y,e=Symbol.for("react.element"),t=Symbol.for("react.fragment"),n=Object.prototype.hasOwnProperty,s=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,i={key:!0,ref:!0,__self:!0,__source:!0};function o(a,l,u){var c,d={},h=null,p=null;u!==void 0&&(h=""+u),l.key!==void 0&&(h=""+l.key),l.ref!==void 0&&(p=l.ref);for(c in l)n.call(l,c)&&!i.hasOwnProperty(c)&&(d[c]=l[c]);if(a&&a.defaultProps)for(c in l=a.defaultProps,l)d[c]===void 0&&(d[c]=l[c]);return{$$typeof:e,type:a,key:h,ref:p,props:d,_owner:s.current}}return cn.Fragment=t,cn.jsx=o,cn.jsxs=o,cn}var dn={};/**
37
37
  * @license React
38
38
  * react-jsx-runtime.development.js
39
39
  *
@@ -41,20 +41,20 @@ ${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 ka;function cf(){return ka||(ka=1,process.env.NODE_ENV!=="production"&&function(){var r=y,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),l=Symbol.for("react.context"),a=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),g=Symbol.iterator,m="@@iterator";function x(A){if(A===null||typeof A!="object")return null;var q=g&&A[g]||A[m];return typeof q=="function"?q:null}var _=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(A){{for(var q=arguments.length,re=new Array(q>1?q-1:0),ve=1;ve<q;ve++)re[ve-1]=arguments[ve];C("error",A,re)}}function C(A,q,re){{var ve=_.ReactDebugCurrentFrame,Oe=ve.getStackAddendum();Oe!==""&&(q+="%s",re=re.concat([Oe]));var He=re.map(function(Pe){return String(Pe)});He.unshift("Warning: "+q),Function.prototype.apply.call(console[A],console,He)}}var S=!1,k=!1,E=!1,v=!1,T=!1,B;B=Symbol.for("react.module.reference");function j(A){return!!(typeof A=="string"||typeof A=="function"||A===n||A===i||T||A===s||A===u||A===c||v||A===p||S||k||E||typeof A=="object"&&A!==null&&(A.$$typeof===h||A.$$typeof===d||A.$$typeof===o||A.$$typeof===l||A.$$typeof===a||A.$$typeof===B||A.getModuleId!==void 0))}function N(A,q,re){var ve=A.displayName;if(ve)return ve;var Oe=q.displayName||q.name||"";return Oe!==""?re+"("+Oe+")":re}function M(A){return A.displayName||"Context"}function R(A){if(A==null)return null;if(typeof A.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof A=="function")return A.displayName||A.name||null;if(typeof A=="string")return A;switch(A){case n:return"Fragment";case t:return"Portal";case i:return"Profiler";case s:return"StrictMode";case u:return"Suspense";case c:return"SuspenseList"}if(typeof A=="object")switch(A.$$typeof){case l:var q=A;return M(q)+".Consumer";case o:var re=A;return M(re._context)+".Provider";case a:return N(A,A.render,"ForwardRef");case d:var ve=A.displayName||null;return ve!==null?ve:R(A.type)||"Memo";case h:{var Oe=A,He=Oe._payload,Pe=Oe._init;try{return R(Pe(He))}catch{return null}}}return null}var w=Object.assign,D=0,F,I,U,J,te,W,V;function H(){}H.__reactDisabledLog=!0;function ne(){{if(D===0){F=console.log,I=console.info,U=console.warn,J=console.error,te=console.group,W=console.groupCollapsed,V=console.groupEnd;var A={configurable:!0,enumerable:!0,value:H,writable:!0};Object.defineProperties(console,{info:A,log:A,warn:A,error:A,group:A,groupCollapsed:A,groupEnd:A})}D++}}function ce(){{if(D--,D===0){var A={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:w({},A,{value:F}),info:w({},A,{value:I}),warn:w({},A,{value:U}),error:w({},A,{value:J}),group:w({},A,{value:te}),groupCollapsed:w({},A,{value:W}),groupEnd:w({},A,{value:V})})}D<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var le=_.ReactCurrentDispatcher,pe;function be(A,q,re){{if(pe===void 0)try{throw Error()}catch(Oe){var ve=Oe.stack.trim().match(/\n( *(at )?)/);pe=ve&&ve[1]||""}return`
45
- `+pe+A}}var Te=!1,$;{var ke=typeof WeakMap=="function"?WeakMap:Map;$=new ke}function se(A,q){if(!A||Te)return"";{var re=$.get(A);if(re!==void 0)return re}var ve;Te=!0;var Oe=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var He;He=le.current,le.current=null,ne();try{if(q){var Pe=function(){throw Error()};if(Object.defineProperty(Pe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Pe,[])}catch(_t){ve=_t}Reflect.construct(A,[],Pe)}else{try{Pe.call()}catch(_t){ve=_t}A.call(Pe.prototype)}}else{try{throw Error()}catch(_t){ve=_t}A()}}catch(_t){if(_t&&ve&&typeof _t.stack=="string"){for(var Ie=_t.stack.split(`
46
- `),gt=ve.stack.split(`
47
- `),it=Ie.length-1,ot=gt.length-1;it>=1&&ot>=0&&Ie[it]!==gt[ot];)ot--;for(;it>=1&&ot>=0;it--,ot--)if(Ie[it]!==gt[ot]){if(it!==1||ot!==1)do if(it--,ot--,ot<0||Ie[it]!==gt[ot]){var Nt=`
48
- `+Ie[it].replace(" at new "," at ");return A.displayName&&Nt.includes("<anonymous>")&&(Nt=Nt.replace("<anonymous>",A.displayName)),typeof A=="function"&&$.set(A,Nt),Nt}while(it>=1&&ot>=0);break}}}finally{Te=!1,le.current=He,ce(),Error.prepareStackTrace=Oe}var Or=A?A.displayName||A.name:"",vr=Or?be(Or):"";return typeof A=="function"&&$.set(A,vr),vr}function Re(A,q,re){return se(A,!1)}function Ce(A){var q=A.prototype;return!!(q&&q.isReactComponent)}function Ee(A,q,re){if(A==null)return"";if(typeof A=="function")return se(A,Ce(A));if(typeof A=="string")return be(A);switch(A){case u:return be("Suspense");case c:return be("SuspenseList")}if(typeof A=="object")switch(A.$$typeof){case a:return Re(A.render);case d:return Ee(A.type,q,re);case h:{var ve=A,Oe=ve._payload,He=ve._init;try{return Ee(He(Oe),q,re)}catch{}}}return""}var Se=Object.prototype.hasOwnProperty,Fe={},ze=_.ReactDebugCurrentFrame;function ge(A){if(A){var q=A._owner,re=Ee(A.type,A._source,q?q.type:null);ze.setExtraStackFrame(re)}else ze.setExtraStackFrame(null)}function L(A,q,re,ve,Oe){{var He=Function.call.bind(Se);for(var Pe in A)if(He(A,Pe)){var Ie=void 0;try{if(typeof A[Pe]!="function"){var gt=Error((ve||"React class")+": "+re+" type `"+Pe+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof A[Pe]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw gt.name="Invariant Violation",gt}Ie=A[Pe](q,Pe,ve,re,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(it){Ie=it}Ie&&!(Ie instanceof Error)&&(ge(Oe),b("%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).",ve||"React class",re,Pe,typeof Ie),ge(null)),Ie instanceof Error&&!(Ie.message in Fe)&&(Fe[Ie.message]=!0,ge(Oe),b("Failed %s type: %s",re,Ie.message),ge(null))}}}var Me=Array.isArray;function Qe(A){return Me(A)}function G(A){{var q=typeof Symbol=="function"&&Symbol.toStringTag,re=q&&A[Symbol.toStringTag]||A.constructor.name||"Object";return re}}function ee(A){try{return me(A),!1}catch{return!0}}function me(A){return""+A}function _e(A){if(ee(A))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",G(A)),me(A)}var Be=_.ReactCurrentOwner,Xe={key:!0,ref:!0,__self:!0,__source:!0},bt,oe;function fe(A){if(Se.call(A,"ref")){var q=Object.getOwnPropertyDescriptor(A,"ref").get;if(q&&q.isReactWarning)return!1}return A.ref!==void 0}function Je(A){if(Se.call(A,"key")){var q=Object.getOwnPropertyDescriptor(A,"key").get;if(q&&q.isReactWarning)return!1}return A.key!==void 0}function Ke(A,q){typeof A.ref=="string"&&Be.current}function Ye(A,q){{var re=function(){bt||(bt=!0,b("%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)",q))};re.isReactWarning=!0,Object.defineProperty(A,"key",{get:re,configurable:!0})}}function pt(A,q){{var re=function(){oe||(oe=!0,b("%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)",q))};re.isReactWarning=!0,Object.defineProperty(A,"ref",{get:re,configurable:!0})}}var X=function(A,q,re,ve,Oe,He,Pe){var Ie={$$typeof:e,type:A,key:q,ref:re,props:Pe,_owner:He};return Ie._store={},Object.defineProperty(Ie._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Ie,"_self",{configurable:!1,enumerable:!1,writable:!1,value:ve}),Object.defineProperty(Ie,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Oe}),Object.freeze&&(Object.freeze(Ie.props),Object.freeze(Ie)),Ie};function P(A,q,re,ve,Oe){{var He,Pe={},Ie=null,gt=null;re!==void 0&&(_e(re),Ie=""+re),Je(q)&&(_e(q.key),Ie=""+q.key),fe(q)&&(gt=q.ref,Ke(q,Oe));for(He in q)Se.call(q,He)&&!Xe.hasOwnProperty(He)&&(Pe[He]=q[He]);if(A&&A.defaultProps){var it=A.defaultProps;for(He in it)Pe[He]===void 0&&(Pe[He]=it[He])}if(Ie||gt){var ot=typeof A=="function"?A.displayName||A.name||"Unknown":A;Ie&&Ye(Pe,ot),gt&&pt(Pe,ot)}return X(A,Ie,gt,Oe,ve,Be.current,Pe)}}var ue=_.ReactCurrentOwner,ye=_.ReactDebugCurrentFrame;function Y(A){if(A){var q=A._owner,re=Ee(A.type,A._source,q?q.type:null);ye.setExtraStackFrame(re)}else ye.setExtraStackFrame(null)}var Ne;Ne=!1;function Ae(A){return typeof A=="object"&&A!==null&&A.$$typeof===e}function De(){{if(ue.current){var A=R(ue.current.type);if(A)return`
44
+ */var ka;function cf(){return ka||(ka=1,process.env.NODE_ENV!=="production"&&function(){var r=y,e=Symbol.for("react.element"),t=Symbol.for("react.portal"),n=Symbol.for("react.fragment"),s=Symbol.for("react.strict_mode"),i=Symbol.for("react.profiler"),o=Symbol.for("react.provider"),a=Symbol.for("react.context"),l=Symbol.for("react.forward_ref"),u=Symbol.for("react.suspense"),c=Symbol.for("react.suspense_list"),d=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),p=Symbol.for("react.offscreen"),g=Symbol.iterator,m="@@iterator";function x(A){if(A===null||typeof A!="object")return null;var U=g&&A[g]||A[m];return typeof U=="function"?U:null}var _=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function b(A){{for(var U=arguments.length,ne=new Array(U>1?U-1:0),me=1;me<U;me++)ne[me-1]=arguments[me];S("error",A,ne)}}function S(A,U,ne){{var me=_.ReactDebugCurrentFrame,qe=me.getStackAddendum();qe!==""&&(U+="%s",ne=ne.concat([qe]));var Ue=ne.map(function(Pe){return String(Pe)});Ue.unshift("Warning: "+U),Function.prototype.apply.call(console[A],console,Ue)}}var C=!1,k=!1,E=!1,v=!1,T=!1,B;B=Symbol.for("react.module.reference");function j(A){return!!(typeof A=="string"||typeof A=="function"||A===n||A===i||T||A===s||A===u||A===c||v||A===p||C||k||E||typeof A=="object"&&A!==null&&(A.$$typeof===h||A.$$typeof===d||A.$$typeof===o||A.$$typeof===a||A.$$typeof===l||A.$$typeof===B||A.getModuleId!==void 0))}function N(A,U,ne){var me=A.displayName;if(me)return me;var qe=U.displayName||U.name||"";return qe!==""?ne+"("+qe+")":ne}function R(A){return A.displayName||"Context"}function M(A){if(A==null)return null;if(typeof A.tag=="number"&&b("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),typeof A=="function")return A.displayName||A.name||null;if(typeof A=="string")return A;switch(A){case n:return"Fragment";case t:return"Portal";case i:return"Profiler";case s:return"StrictMode";case u:return"Suspense";case c:return"SuspenseList"}if(typeof A=="object")switch(A.$$typeof){case a:var U=A;return R(U)+".Consumer";case o:var ne=A;return R(ne._context)+".Provider";case l:return N(A,A.render,"ForwardRef");case d:var me=A.displayName||null;return me!==null?me:M(A.type)||"Memo";case h:{var qe=A,Ue=qe._payload,Pe=qe._init;try{return M(Pe(Ue))}catch{return null}}}return null}var w=Object.assign,D=0,F,z,q,J,te,W,G;function H(){}H.__reactDisabledLog=!0;function se(){{if(D===0){F=console.log,z=console.info,q=console.warn,J=console.error,te=console.group,W=console.groupCollapsed,G=console.groupEnd;var A={configurable:!0,enumerable:!0,value:H,writable:!0};Object.defineProperties(console,{info:A,log:A,warn:A,error:A,group:A,groupCollapsed:A,groupEnd:A})}D++}}function le(){{if(D--,D===0){var A={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:w({},A,{value:F}),info:w({},A,{value:z}),warn:w({},A,{value:q}),error:w({},A,{value:J}),group:w({},A,{value:te}),groupCollapsed:w({},A,{value:W}),groupEnd:w({},A,{value:G})})}D<0&&b("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var ue=_.ReactCurrentDispatcher,_e;function fe(A,U,ne){{if(_e===void 0)try{throw Error()}catch(qe){var me=qe.stack.trim().match(/\n( *(at )?)/);_e=me&&me[1]||""}return`
45
+ `+_e+A}}var De=!1,O;{var Ce=typeof WeakMap=="function"?WeakMap:Map;O=new Ce}function re(A,U){if(!A||De)return"";{var ne=O.get(A);if(ne!==void 0)return ne}var me;De=!0;var qe=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Ue;Ue=ue.current,ue.current=null,se();try{if(U){var Pe=function(){throw Error()};if(Object.defineProperty(Pe.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Pe,[])}catch(vt){me=vt}Reflect.construct(A,[],Pe)}else{try{Pe.call()}catch(vt){me=vt}A.call(Pe.prototype)}}else{try{throw Error()}catch(vt){me=vt}A()}}catch(vt){if(vt&&me&&typeof vt.stack=="string"){for(var Re=vt.stack.split(`
46
+ `),gt=me.stack.split(`
47
+ `),nt=Re.length-1,it=gt.length-1;nt>=1&&it>=0&&Re[nt]!==gt[it];)it--;for(;nt>=1&&it>=0;nt--,it--)if(Re[nt]!==gt[it]){if(nt!==1||it!==1)do if(nt--,it--,it<0||Re[nt]!==gt[it]){var Nt=`
48
+ `+Re[nt].replace(" at new "," at ");return A.displayName&&Nt.includes("<anonymous>")&&(Nt=Nt.replace("<anonymous>",A.displayName)),typeof A=="function"&&O.set(A,Nt),Nt}while(nt>=1&&it>=0);break}}}finally{De=!1,ue.current=Ue,le(),Error.prepareStackTrace=qe}var Or=A?A.displayName||A.name:"",vr=Or?fe(Or):"";return typeof A=="function"&&O.set(A,vr),vr}function Fe(A,U,ne){return re(A,!1)}function je(A){var U=A.prototype;return!!(U&&U.isReactComponent)}function ye(A,U,ne){if(A==null)return"";if(typeof A=="function")return re(A,je(A));if(typeof A=="string")return fe(A);switch(A){case u:return fe("Suspense");case c:return fe("SuspenseList")}if(typeof A=="object")switch(A.$$typeof){case l:return Fe(A.render);case d:return ye(A.type,U,ne);case h:{var me=A,qe=me._payload,Ue=me._init;try{return ye(Ue(qe),U,ne)}catch{}}}return""}var Se=Object.prototype.hasOwnProperty,Me={},Oe=_.ReactDebugCurrentFrame;function ge(A){if(A){var U=A._owner,ne=ye(A.type,A._source,U?U.type:null);Oe.setExtraStackFrame(ne)}else Oe.setExtraStackFrame(null)}function L(A,U,ne,me,qe){{var Ue=Function.call.bind(Se);for(var Pe in A)if(Ue(A,Pe)){var Re=void 0;try{if(typeof A[Pe]!="function"){var gt=Error((me||"React class")+": "+ne+" type `"+Pe+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof A[Pe]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw gt.name="Invariant Violation",gt}Re=A[Pe](U,Pe,me,ne,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(nt){Re=nt}Re&&!(Re instanceof Error)&&(ge(qe),b("%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).",me||"React class",ne,Pe,typeof Re),ge(null)),Re instanceof Error&&!(Re.message in Me)&&(Me[Re.message]=!0,ge(qe),b("Failed %s type: %s",ne,Re.message),ge(null))}}}var ze=Array.isArray;function Ke(A){return ze(A)}function X(A){{var U=typeof Symbol=="function"&&Symbol.toStringTag,ne=U&&A[Symbol.toStringTag]||A.constructor.name||"Object";return ne}}function Z(A){try{return ce(A),!1}catch{return!0}}function ce(A){return""+A}function we(A){if(Z(A))return b("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",X(A)),ce(A)}var Be=_.ReactCurrentOwner,Qe={key:!0,ref:!0,__self:!0,__source:!0},Et,oe;function pe(A){if(Se.call(A,"ref")){var U=Object.getOwnPropertyDescriptor(A,"ref").get;if(U&&U.isReactWarning)return!1}return A.ref!==void 0}function Ye(A){if(Se.call(A,"key")){var U=Object.getOwnPropertyDescriptor(A,"key").get;if(U&&U.isReactWarning)return!1}return A.key!==void 0}function at(A,U){typeof A.ref=="string"&&Be.current}function Ve(A,U){{var ne=function(){Et||(Et=!0,b("%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)",U))};ne.isReactWarning=!0,Object.defineProperty(A,"key",{get:ne,configurable:!0})}}function Xe(A,U){{var ne=function(){oe||(oe=!0,b("%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)",U))};ne.isReactWarning=!0,Object.defineProperty(A,"ref",{get:ne,configurable:!0})}}var br=function(A,U,ne,me,qe,Ue,Pe){var Re={$$typeof:e,type:A,key:U,ref:ne,props:Pe,_owner:Ue};return Re._store={},Object.defineProperty(Re._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Re,"_self",{configurable:!1,enumerable:!1,writable:!1,value:me}),Object.defineProperty(Re,"_source",{configurable:!1,enumerable:!1,writable:!1,value:qe}),Object.freeze&&(Object.freeze(Re.props),Object.freeze(Re)),Re};function Q(A,U,ne,me,qe){{var Ue,Pe={},Re=null,gt=null;ne!==void 0&&(we(ne),Re=""+ne),Ye(U)&&(we(U.key),Re=""+U.key),pe(U)&&(gt=U.ref,at(U,qe));for(Ue in U)Se.call(U,Ue)&&!Qe.hasOwnProperty(Ue)&&(Pe[Ue]=U[Ue]);if(A&&A.defaultProps){var nt=A.defaultProps;for(Ue in nt)Pe[Ue]===void 0&&(Pe[Ue]=nt[Ue])}if(Re||gt){var it=typeof A=="function"?A.displayName||A.name||"Unknown":A;Re&&Ve(Pe,it),gt&&Xe(Pe,it)}return br(A,Re,gt,qe,me,Be.current,Pe)}}var I=_.ReactCurrentOwner,de=_.ReactDebugCurrentFrame;function he(A){if(A){var U=A._owner,ne=ye(A.type,A._source,U?U.type:null);de.setExtraStackFrame(ne)}else de.setExtraStackFrame(null)}var Y;Y=!1;function Ae(A){return typeof A=="object"&&A!==null&&A.$$typeof===e}function Ee(){{if(I.current){var A=M(I.current.type);if(A)return`
49
49
 
50
- Check the render method of \``+A+"`."}return""}}function $e(A){return""}var Ue={};function we(A){{var q=De();if(!q){var re=typeof A=="string"?A:A.displayName||A.name;re&&(q=`
50
+ Check the render method of \``+A+"`."}return""}}function Te(A){return""}var Le={};function He(A){{var U=Ee();if(!U){var ne=typeof A=="string"?A:A.displayName||A.name;ne&&(U=`
51
51
 
52
- Check the top-level render call using <`+re+">.")}return q}}function je(A,q){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var re=we(q);if(Ue[re])return;Ue[re]=!0;var ve="";A&&A._owner&&A._owner!==ue.current&&(ve=" It was passed a child from "+R(A._owner.type)+"."),Y(A),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',re,ve),Y(null)}}function z(A,q){{if(typeof A!="object")return;if(Qe(A))for(var re=0;re<A.length;re++){var ve=A[re];Ae(ve)&&je(ve,q)}else if(Ae(A))A._store&&(A._store.validated=!0);else if(A){var Oe=x(A);if(typeof Oe=="function"&&Oe!==A.entries)for(var He=Oe.call(A),Pe;!(Pe=He.next()).done;)Ae(Pe.value)&&je(Pe.value,q)}}}function xe(A){{var q=A.type;if(q==null||typeof q=="string")return;var re;if(typeof q=="function")re=q.propTypes;else if(typeof q=="object"&&(q.$$typeof===a||q.$$typeof===d))re=q.propTypes;else return;if(re){var ve=R(q);L(re,A.props,"prop",ve,A)}else if(q.PropTypes!==void 0&&!Ne){Ne=!0;var Oe=R(q);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Oe||"Unknown")}typeof q.getDefaultProps=="function"&&!q.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function he(A){{for(var q=Object.keys(A.props),re=0;re<q.length;re++){var ve=q[re];if(ve!=="children"&&ve!=="key"){Y(A),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",ve),Y(null);break}}A.ref!==null&&(Y(A),b("Invalid attribute `ref` supplied to `React.Fragment`."),Y(null))}}var de={};function Ve(A,q,re,ve,Oe,He){{var Pe=j(A);if(!Pe){var Ie="";(A===void 0||typeof A=="object"&&A!==null&&Object.keys(A).length===0)&&(Ie+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var gt=$e();gt?Ie+=gt:Ie+=De();var it;A===null?it="null":Qe(A)?it="array":A!==void 0&&A.$$typeof===e?(it="<"+(R(A.type)||"Unknown")+" />",Ie=" Did you accidentally export a JSX literal instead of a component?"):it=typeof A,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",it,Ie)}var ot=P(A,q,re,Oe,He);if(ot==null)return ot;if(Pe){var Nt=q.children;if(Nt!==void 0)if(ve)if(Qe(Nt)){for(var Or=0;Or<Nt.length;Or++)z(Nt[Or],A);Object.freeze&&Object.freeze(Nt)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else z(Nt,A)}if(Se.call(q,"key")){var vr=R(A),_t=Object.keys(q).filter(function(Rd){return Rd!=="key"}),Si=_t.length>0?"{key: someKey, "+_t.join(": ..., ")+": ...}":"{key: someKey}";if(!de[vr+Si]){var Md=_t.length>0?"{"+_t.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
52
+ Check the top-level render call using <`+ne+">.")}return U}}function ke(A,U){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var ne=He(U);if(Le[ne])return;Le[ne]=!0;var me="";A&&A._owner&&A._owner!==I.current&&(me=" It was passed a child from "+M(A._owner.type)+"."),he(A),b('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',ne,me),he(null)}}function P(A,U){{if(typeof A!="object")return;if(Ke(A))for(var ne=0;ne<A.length;ne++){var me=A[ne];Ae(me)&&ke(me,U)}else if(Ae(A))A._store&&(A._store.validated=!0);else if(A){var qe=x(A);if(typeof qe=="function"&&qe!==A.entries)for(var Ue=qe.call(A),Pe;!(Pe=Ue.next()).done;)Ae(Pe.value)&&ke(Pe.value,U)}}}function xe(A){{var U=A.type;if(U==null||typeof U=="string")return;var ne;if(typeof U=="function")ne=U.propTypes;else if(typeof U=="object"&&(U.$$typeof===l||U.$$typeof===d))ne=U.propTypes;else return;if(ne){var me=M(U);L(ne,A.props,"prop",me,A)}else if(U.PropTypes!==void 0&&!Y){Y=!0;var qe=M(U);b("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",qe||"Unknown")}typeof U.getDefaultProps=="function"&&!U.getDefaultProps.isReactClassApproved&&b("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function ve(A){{for(var U=Object.keys(A.props),ne=0;ne<U.length;ne++){var me=U[ne];if(me!=="children"&&me!=="key"){he(A),b("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",me),he(null);break}}A.ref!==null&&(he(A),b("Invalid attribute `ref` supplied to `React.Fragment`."),he(null))}}var be={};function Ne(A,U,ne,me,qe,Ue){{var Pe=j(A);if(!Pe){var Re="";(A===void 0||typeof A=="object"&&A!==null&&Object.keys(A).length===0)&&(Re+=" You likely forgot to export your component from the file it's defined in, or you might have mixed up default and named imports.");var gt=Te();gt?Re+=gt:Re+=Ee();var nt;A===null?nt="null":Ke(A)?nt="array":A!==void 0&&A.$$typeof===e?(nt="<"+(M(A.type)||"Unknown")+" />",Re=" Did you accidentally export a JSX literal instead of a component?"):nt=typeof A,b("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",nt,Re)}var it=Q(A,U,ne,qe,Ue);if(it==null)return it;if(Pe){var Nt=U.children;if(Nt!==void 0)if(me)if(Ke(Nt)){for(var Or=0;Or<Nt.length;Or++)P(Nt[Or],A);Object.freeze&&Object.freeze(Nt)}else b("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else P(Nt,A)}if(Se.call(U,"key")){var vr=M(A),vt=Object.keys(U).filter(function(Rd){return Rd!=="key"}),Si=vt.length>0?"{key: someKey, "+vt.join(": ..., ")+": ...}":"{key: someKey}";if(!be[vr+Si]){var Md=vt.length>0?"{"+vt.join(": ..., ")+": ...}":"{}";b(`A props object containing a "key" prop is being spread into JSX:
53
53
  let props = %s;
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} />`,Si,vr,Md,vr),de[vr+Si]=!0}}return A===n?he(ot):xe(ot),ot}}function st(A,q,re){return Ve(A,q,re,!0)}function vt(A,q,re){return Ve(A,q,re,!1)}var jt=vt,Mt=st;dn.Fragment=n,dn.jsx=jt,dn.jsxs=Mt}()),dn}process.env.NODE_ENV==="production"?Vi.exports=uf():Vi.exports=cf();var f=Vi.exports;const lu=y.createContext(void 0);function df({apiUrl:r,systemId:e,children:t}){const[n,s]=y.useState(null),[i,o]=y.useState(null),[l,a]=y.useState(!1),[u,c]=y.useState(!0),[d]=y.useState(()=>new Ao({apiUrl:r,systemId:e})),h=y.useCallback(async k=>{const E=await d.isAdmin(k);a(E)},[d]),p=y.useCallback(()=>{const k=Ze.getToken(),E=Ze.getUser();k&&E?(o(k),s(E),h(E._id).finally(()=>c(!1))):c(!1)},[h]);y.useEffect(()=>{p()},[p]);const g=y.useCallback(async(k,E)=>{const v=await d.login(k,E);return v.success&&v.user&&v.token&&(o(v.token),s(v.user),await h(v.user._id)),v},[d,h]),m=y.useCallback(async(k,E,v)=>d.register(k,E,v),[d]),x=y.useCallback(async(k,E)=>{const v=await d.verifyEmail(k,E);return v.success&&v.user&&v.token&&(o(v.token),s(v.user),await h(v.user._id)),v},[d,h]),_=y.useCallback(async k=>d.requestPasswordReset(k),[d]),b=y.useCallback(async(k,E,v)=>{const T=await d.setPasswordWithCode(k,E,v);return T.success&&T.user&&T.token&&(o(T.token),s(T.user),await h(T.user._id)),T},[d,h]),C=y.useCallback(async k=>d.resendVerificationCode(k),[d]),S=y.useCallback(()=>{d.logout(),s(null),o(null),a(!1)},[d]);return f.jsx(lu.Provider,{value:{user:n,token:i,isAdmin:l,loading:u,login:g,register:m,verifyEmail:x,requestPasswordReset:_,setPasswordWithCode:b,resendVerificationCode:C,logout:S,refreshUser:p},children:t})}function ff(){const r=y.useContext(lu);if(r===void 0)throw new Error("useAuth must be used within an AuthProvider");return r}const hf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",inputBackground:"#ffffff",borderRadius:"0.5rem"};function No({onLogin:r,onSuccess:e,logo:t,title:n="Connexion",submitText:s="Se connecter",loadingText:i="Connexion...",emailLabel:o="Email",passwordLabel:l="Mot de passe",onForgotPasswordClick:a,onRegisterClick:u,forgotPasswordText:c="Mot de passe oublie ?",registerText:d="Creer un compte",theme:h,className:p="",isModal:g=!1}){const[m,x]=y.useState(""),[_,b]=y.useState(""),[C,S]=y.useState(""),[k,E]=y.useState(!1),v={...hf,...h};async function T(w){w.preventDefault(),E(!0),S("");const D=await r(m,_);D.success?e==null||e():S(D.error||"Connexion impossible"),E(!1)}const B={backgroundColor:v.backgroundColor,borderRadius:v.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"28rem",...g&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},j={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${v.borderColor}`,borderRadius:v.borderRadius,backgroundColor:v.inputBackground,color:v.textColor,fontSize:"1rem",outline:"none"},N={display:"block",fontSize:"0.875rem",fontWeight:500,color:v.textMutedColor,marginBottom:"0.25rem"},M={width:"100%",padding:"0.75rem",backgroundColor:k?v.textMutedColor:v.primaryColor,color:"#ffffff",border:"none",borderRadius:v.borderRadius,fontSize:"1rem",fontWeight:500,cursor:k?"not-allowed":"pointer",transition:"background-color 0.2s"},R={padding:"0.75rem",backgroundColor:v.errorBackgroundColor,border:`1px solid ${v.errorColor}20`,borderRadius:v.borderRadius,marginBottom:"1rem"};return f.jsxs("div",{style:B,className:p,children:[t&&f.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"1.5rem"},children:t}),f.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:v.textColor,marginBottom:"1rem",textAlign:t?"center":"left"},children:n}),f.jsxs("form",{onSubmit:T,children:[C&&f.jsx("div",{style:R,children:f.jsx("p",{style:{fontSize:"0.875rem",color:v.errorColor,margin:0},children:C})}),f.jsxs("div",{style:{marginBottom:"1rem"},children:[f.jsx("label",{style:N,children:o}),f.jsx("input",{type:"email",value:m,onChange:w=>x(w.target.value),required:!0,style:j,onFocus:w=>{w.target.style.borderColor=v.primaryColor,w.target.style.boxShadow=`0 0 0 2px ${v.primaryColor}20`},onBlur:w=>{w.target.style.borderColor=v.borderColor,w.target.style.boxShadow="none"}})]}),f.jsxs("div",{style:{marginBottom:"1.5rem"},children:[f.jsx("label",{style:N,children:l}),f.jsx("input",{type:"password",value:_,onChange:w=>b(w.target.value),required:!0,style:j,onFocus:w=>{w.target.style.borderColor=v.primaryColor,w.target.style.boxShadow=`0 0 0 2px ${v.primaryColor}20`},onBlur:w=>{w.target.style.borderColor=v.borderColor,w.target.style.boxShadow="none"}})]}),f.jsx("button",{type:"submit",disabled:k,style:M,onMouseEnter:w=>{k||(w.target.style.backgroundColor=v.primaryHoverColor)},onMouseLeave:w=>{k||(w.target.style.backgroundColor=v.primaryColor)},children:k?i:s}),(a||u)&&f.jsxs("div",{style:{display:"flex",justifyContent:a&&u?"space-between":"center",marginTop:"1rem"},children:[a&&f.jsx("button",{type:"button",onClick:a,style:{color:v.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0},children:c}),u&&f.jsx("button",{type:"button",onClick:u,style:{color:v.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0},children:d})]})]})]})}function pf({isOpen:r,onClose:e,backdropBlur:t=!0,...n}){if(!r)return null;const s={position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center",padding:"1rem"},i={position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",...t&&{backdropFilter:"blur(4px)"}},o={position:"relative",animation:"slideUp 0.2s ease-out"};return f.jsxs("div",{style:s,children:[f.jsx("div",{style:i,onClick:e}),f.jsxs("div",{style:o,children:[f.jsx("button",{onClick:e,style:{position:"absolute",top:"0.75rem",right:"0.75rem",zIndex:10,background:"none",border:"none",padding:"0.25rem",cursor:"pointer",color:"#9CA3AF"},onMouseEnter:l=>{l.target.style.color="#4B5563"},onMouseLeave:l=>{l.target.style.color="#9CA3AF"},children:f.jsx("svg",{width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),f.jsx(No,{...n,isModal:!0})]}),f.jsx("style",{children:`
57
+ <%s key={someKey} {...props} />`,Si,vr,Md,vr),be[vr+Si]=!0}}return A===n?ve(it):xe(it),it}}function st(A,U,ne){return Ne(A,U,ne,!0)}function ct(A,U,ne){return Ne(A,U,ne,!1)}var bt=ct,Xt=st;dn.Fragment=n,dn.jsx=bt,dn.jsxs=Xt}()),dn}process.env.NODE_ENV==="production"?Vi.exports=uf():Vi.exports=cf();var f=Vi.exports;const lu=y.createContext(void 0);function df({apiUrl:r,systemId:e,children:t}){const[n,s]=y.useState(null),[i,o]=y.useState(null),[a,l]=y.useState(!1),[u,c]=y.useState(!0),[d]=y.useState(()=>new Ao({apiUrl:r,systemId:e})),h=y.useCallback(async k=>{const E=await d.isAdmin(k);l(E)},[d]),p=y.useCallback(()=>{const k=Je.getToken(),E=Je.getUser();k&&E?(o(k),s(E),h(E._id).finally(()=>c(!1))):c(!1)},[h]);y.useEffect(()=>{p()},[p]);const g=y.useCallback(async(k,E)=>{const v=await d.login(k,E);return v.success&&v.user&&v.token&&(o(v.token),s(v.user),await h(v.user._id)),v},[d,h]),m=y.useCallback(async(k,E,v)=>d.register(k,E,v),[d]),x=y.useCallback(async(k,E)=>{const v=await d.verifyEmail(k,E);return v.success&&v.user&&v.token&&(o(v.token),s(v.user),await h(v.user._id)),v},[d,h]),_=y.useCallback(async k=>d.requestPasswordReset(k),[d]),b=y.useCallback(async(k,E,v)=>{const T=await d.setPasswordWithCode(k,E,v);return T.success&&T.user&&T.token&&(o(T.token),s(T.user),await h(T.user._id)),T},[d,h]),S=y.useCallback(async k=>d.resendVerificationCode(k),[d]),C=y.useCallback(()=>{d.logout(),s(null),o(null),l(!1)},[d]);return f.jsx(lu.Provider,{value:{user:n,token:i,isAdmin:a,loading:u,login:g,register:m,verifyEmail:x,requestPasswordReset:_,setPasswordWithCode:b,resendVerificationCode:S,logout:C,refreshUser:p},children:t})}function ff(){const r=y.useContext(lu);if(r===void 0)throw new Error("useAuth must be used within an AuthProvider");return r}const hf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",inputBackground:"#ffffff",borderRadius:"0.5rem"};function No({onLogin:r,onSuccess:e,logo:t,title:n="Connexion",submitText:s="Se connecter",loadingText:i="Connexion...",emailLabel:o="Email",passwordLabel:a="Mot de passe",onForgotPasswordClick:l,onRegisterClick:u,forgotPasswordText:c="Mot de passe oublie ?",registerText:d="Creer un compte",theme:h,className:p="",isModal:g=!1}){const[m,x]=y.useState(""),[_,b]=y.useState(""),[S,C]=y.useState(""),[k,E]=y.useState(!1),v={...hf,...h};async function T(w){w.preventDefault(),E(!0),C("");const D=await r(m,_);D.success?e==null||e():C(D.error||"Connexion impossible"),E(!1)}const B={backgroundColor:v.backgroundColor,borderRadius:v.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"28rem",...g&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},j={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${v.borderColor}`,borderRadius:v.borderRadius,backgroundColor:v.inputBackground,color:v.textColor,fontSize:"1rem",outline:"none"},N={display:"block",fontSize:"0.875rem",fontWeight:500,color:v.textMutedColor,marginBottom:"0.25rem"},R={width:"100%",padding:"0.75rem",backgroundColor:k?v.textMutedColor:v.primaryColor,color:"#ffffff",border:"none",borderRadius:v.borderRadius,fontSize:"1rem",fontWeight:500,cursor:k?"not-allowed":"pointer",transition:"background-color 0.2s"},M={padding:"0.75rem",backgroundColor:v.errorBackgroundColor,border:`1px solid ${v.errorColor}20`,borderRadius:v.borderRadius,marginBottom:"1rem"};return f.jsxs("div",{style:B,className:p,children:[t&&f.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"1.5rem"},children:t}),f.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:v.textColor,marginBottom:"1rem",textAlign:t?"center":"left"},children:n}),f.jsxs("form",{onSubmit:T,children:[S&&f.jsx("div",{style:M,children:f.jsx("p",{style:{fontSize:"0.875rem",color:v.errorColor,margin:0},children:S})}),f.jsxs("div",{style:{marginBottom:"1rem"},children:[f.jsx("label",{style:N,children:o}),f.jsx("input",{type:"email",value:m,onChange:w=>x(w.target.value),required:!0,style:j,onFocus:w=>{w.target.style.borderColor=v.primaryColor,w.target.style.boxShadow=`0 0 0 2px ${v.primaryColor}20`},onBlur:w=>{w.target.style.borderColor=v.borderColor,w.target.style.boxShadow="none"}})]}),f.jsxs("div",{style:{marginBottom:"1.5rem"},children:[f.jsx("label",{style:N,children:a}),f.jsx("input",{type:"password",value:_,onChange:w=>b(w.target.value),required:!0,style:j,onFocus:w=>{w.target.style.borderColor=v.primaryColor,w.target.style.boxShadow=`0 0 0 2px ${v.primaryColor}20`},onBlur:w=>{w.target.style.borderColor=v.borderColor,w.target.style.boxShadow="none"}})]}),f.jsx("button",{type:"submit",disabled:k,style:R,onMouseEnter:w=>{k||(w.target.style.backgroundColor=v.primaryHoverColor)},onMouseLeave:w=>{k||(w.target.style.backgroundColor=v.primaryColor)},children:k?i:s}),(l||u)&&f.jsxs("div",{style:{display:"flex",justifyContent:l&&u?"space-between":"center",marginTop:"1rem"},children:[l&&f.jsx("button",{type:"button",onClick:l,style:{color:v.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0},children:c}),u&&f.jsx("button",{type:"button",onClick:u,style:{color:v.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0},children:d})]})]})]})}function pf({isOpen:r,onClose:e,backdropBlur:t=!0,...n}){if(!r)return null;const s={position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center",padding:"1rem"},i={position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",...t&&{backdropFilter:"blur(4px)"}},o={position:"relative",animation:"slideUp 0.2s ease-out"};return f.jsxs("div",{style:s,children:[f.jsx("div",{style:i,onClick:e}),f.jsxs("div",{style:o,children:[f.jsx("button",{onClick:e,style:{position:"absolute",top:"0.75rem",right:"0.75rem",zIndex:10,background:"none",border:"none",padding:"0.25rem",cursor:"pointer",color:"#9CA3AF"},onMouseEnter:a=>{a.target.style.color="#4B5563"},onMouseLeave:a=>{a.target.style.color="#9CA3AF"},children:f.jsx("svg",{width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),f.jsx(No,{...n,isModal:!0})]}),f.jsx("style",{children:`
58
58
  @keyframes slideUp {
59
59
  from {
60
60
  opacity: 0;
@@ -65,7 +65,7 @@ React keys must be passed directly to JSX without using spread:
65
65
  transform: translateY(0);
66
66
  }
67
67
  }
68
- `})]})}const gf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",successColor:"#059669",successBackgroundColor:"#ECFDF5",inputBackground:"#ffffff",borderRadius:"0.5rem"};function uu({onRegister:r,onSuccess:e,onLoginClick:t,logo:n,title:s="Créer un compte",submitText:i="S'inscrire",loadingText:o="Inscription...",emailLabel:l="Email",passwordLabel:a="Mot de passe",confirmPasswordLabel:u="Confirmer le mot de passe",firstNameLabel:c="Prénom",lastNameLabel:d="Nom",loginLinkText:h="Déjà un compte ? Se connecter",showNameFields:p=!1,theme:g,className:m="",isModal:x=!1}){const[_,b]=y.useState(""),[C,S]=y.useState(""),[k,E]=y.useState(""),[v,T]=y.useState(""),[B,j]=y.useState(""),[N,M]=y.useState(""),[R,w]=y.useState(!1),D={...gf,...g};async function F(H){if(H.preventDefault(),M(""),C!==k){M("Les mots de passe ne correspondent pas");return}if(C.length<8){M("Le mot de passe doit contenir au moins 8 caractères");return}w(!0);const ce=await r(_,C,p?{firstName:v,lastName:B}:void 0);ce.success?e==null||e(_):M(ce.error||"Erreur lors de l'inscription"),w(!1)}const I={backgroundColor:D.backgroundColor,borderRadius:D.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"28rem",...x&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},U={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${D.borderColor}`,borderRadius:D.borderRadius,backgroundColor:D.inputBackground,color:D.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},J={display:"block",fontSize:"0.875rem",fontWeight:500,color:D.textMutedColor,marginBottom:"0.25rem"},te={width:"100%",padding:"0.75rem",backgroundColor:R?D.textMutedColor:D.primaryColor,color:"#ffffff",border:"none",borderRadius:D.borderRadius,fontSize:"1rem",fontWeight:500,cursor:R?"not-allowed":"pointer",transition:"background-color 0.2s"},W={padding:"0.75rem",backgroundColor:D.errorBackgroundColor,border:`1px solid ${D.errorColor}20`,borderRadius:D.borderRadius,marginBottom:"1rem"},V={color:D.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer"};return f.jsxs("div",{style:I,className:m,children:[n&&f.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"1.5rem"},children:n}),f.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:D.textColor,marginBottom:"1rem",textAlign:n?"center":"left"},children:s}),f.jsxs("form",{onSubmit:F,children:[N&&f.jsx("div",{style:W,children:f.jsx("p",{style:{fontSize:"0.875rem",color:D.errorColor,margin:0},children:N})}),p&&f.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"1rem"},children:[f.jsxs("div",{style:{flex:1},children:[f.jsx("label",{style:J,children:c}),f.jsx("input",{type:"text",value:v,onChange:H=>T(H.target.value),style:U})]}),f.jsxs("div",{style:{flex:1},children:[f.jsx("label",{style:J,children:d}),f.jsx("input",{type:"text",value:B,onChange:H=>j(H.target.value),style:U})]})]}),f.jsxs("div",{style:{marginBottom:"1rem"},children:[f.jsx("label",{style:J,children:l}),f.jsx("input",{type:"email",value:_,onChange:H=>b(H.target.value),required:!0,style:U})]}),f.jsxs("div",{style:{marginBottom:"1rem"},children:[f.jsx("label",{style:J,children:a}),f.jsx("input",{type:"password",value:C,onChange:H=>S(H.target.value),required:!0,minLength:8,style:U})]}),f.jsxs("div",{style:{marginBottom:"1.5rem"},children:[f.jsx("label",{style:J,children:u}),f.jsx("input",{type:"password",value:k,onChange:H=>E(H.target.value),required:!0,style:U})]}),f.jsx("button",{type:"submit",disabled:R,style:te,onMouseEnter:H=>{R||(H.target.style.backgroundColor=D.primaryHoverColor)},onMouseLeave:H=>{R||(H.target.style.backgroundColor=D.primaryColor)},children:R?o:i}),t&&f.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:f.jsx("span",{style:V,onClick:t,children:h})})]})]})}const mf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",successColor:"#059669",inputBackground:"#ffffff",borderRadius:"0.5rem"};function Gi({email:r,onVerify:e,onSuccess:t,onResendCode:n,onBackClick:s,title:i="Vérification",subtitle:o,submitText:l="Vérifier",loadingText:a="Vérification...",resendText:u="Renvoyer le code",resendingText:c="Envoi...",backText:d="← Retour",codeLength:h=6,theme:p,className:g="",isModal:m=!1}){const[x,_]=y.useState(Array(h).fill("")),[b,C]=y.useState(""),[S,k]=y.useState(!1),[E,v]=y.useState(!1),[T,B]=y.useState(!1),j=y.useRef([]),N={...mf,...p};y.useEffect(()=>{var W;(W=j.current[0])==null||W.focus()},[]);const M=(W,V)=>{var ce;const H=V.replace(/\D/g,"").slice(-1),ne=[...x];if(ne[W]=H,_(ne),C(""),H&&W<h-1&&((ce=j.current[W+1])==null||ce.focus()),H&&W===h-1){const le=ne.join("");le.length===h&&D(le)}},R=(W,V)=>{var H;V.key==="Backspace"&&!x[W]&&W>0&&((H=j.current[W-1])==null||H.focus())},w=W=>{var ce;W.preventDefault();const V=W.clipboardData.getData("text").replace(/\D/g,"").slice(0,h),H=[...x];V.split("").forEach((le,pe)=>{pe<h&&(H[pe]=le)}),_(H);const ne=Math.min(V.length,h)-1;ne>=0&&((ce=j.current[ne])==null||ce.focus()),V.length===h&&D(V)};async function D(W){var ne;const V=W||x.join("");if(V.length!==h){C("Veuillez entrer le code complet");return}k(!0),C("");const H=await e(r,V);H.success?t==null||t():(C(H.error||"Code invalide"),_(Array(h).fill("")),(ne=j.current[0])==null||ne.focus()),k(!1)}async function F(){if(!n)return;v(!0),B(!1),C("");const W=await n(r);W.success?(B(!0),setTimeout(()=>B(!1),3e3)):C(W.error||"Erreur lors de l'envoi"),v(!1)}const I={backgroundColor:N.backgroundColor,borderRadius:N.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"28rem",...m&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},U={width:"3rem",height:"3.5rem",textAlign:"center",fontSize:"1.5rem",fontWeight:600,border:`2px solid ${N.borderColor}`,borderRadius:N.borderRadius,backgroundColor:N.inputBackground,color:N.textColor,outline:"none",transition:"border-color 0.2s, box-shadow 0.2s"},J={width:"100%",padding:"0.75rem",backgroundColor:S?N.textMutedColor:N.primaryColor,color:"#ffffff",border:"none",borderRadius:N.borderRadius,fontSize:"1rem",fontWeight:500,cursor:S?"not-allowed":"pointer",transition:"background-color 0.2s"},te={color:N.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return f.jsxs("div",{style:I,className:g,children:[f.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:N.textColor,marginBottom:"0.5rem",textAlign:"center"},children:i}),f.jsx("p",{style:{fontSize:"0.875rem",color:N.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:o||`Un code a été envoyé à ${r}`}),b&&f.jsx("div",{style:{padding:"0.75rem",backgroundColor:N.errorBackgroundColor,border:`1px solid ${N.errorColor}20`,borderRadius:N.borderRadius,marginBottom:"1rem"},children:f.jsx("p",{style:{fontSize:"0.875rem",color:N.errorColor,margin:0,textAlign:"center"},children:b})}),T&&f.jsx("div",{style:{padding:"0.75rem",backgroundColor:"#ECFDF5",border:`1px solid ${N.successColor}20`,borderRadius:N.borderRadius,marginBottom:"1rem"},children:f.jsx("p",{style:{fontSize:"0.875rem",color:N.successColor,margin:0,textAlign:"center"},children:"Code renvoyé !"})}),f.jsx("div",{style:{display:"flex",justifyContent:"center",gap:"0.5rem",marginBottom:"1.5rem"},children:x.map((W,V)=>f.jsx("input",{ref:H=>{j.current[V]=H},type:"text",inputMode:"numeric",maxLength:1,value:W,onChange:H=>M(V,H.target.value),onKeyDown:H=>R(V,H),onPaste:w,disabled:S,style:{...U,borderColor:W?N.primaryColor:N.borderColor},onFocus:H=>{H.target.style.borderColor=N.primaryColor,H.target.style.boxShadow=`0 0 0 3px ${N.primaryColor}20`},onBlur:H=>{H.target.style.borderColor=W?N.primaryColor:N.borderColor,H.target.style.boxShadow="none"}},V))}),f.jsx("button",{type:"button",onClick:()=>D(),disabled:S||x.join("").length!==h,style:{...J,opacity:x.join("").length!==h?.5:1},children:S?a:l}),n&&f.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:f.jsx("button",{type:"button",onClick:F,disabled:E,style:{...te,opacity:E?.5:1},children:E?c:u})}),s&&f.jsx("p",{style:{textAlign:"center",marginTop:"0.75rem",marginBottom:0},children:f.jsx("button",{type:"button",onClick:s,style:te,children:d})})]})}const yf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",successColor:"#059669",successBackgroundColor:"#ECFDF5",inputBackground:"#ffffff",borderRadius:"0.5rem"};function cu({onRequestReset:r,onSuccess:e,onBackClick:t,title:n="Mot de passe oublié",subtitle:s="Entrez votre email pour recevoir un code de réinitialisation",submitText:i="Envoyer le code",loadingText:o="Envoi...",emailLabel:l="Email",backText:a="← Retour à la connexion",theme:u,className:c="",isModal:d=!1}){const[h,p]=y.useState(""),[g,m]=y.useState(""),[x,_]=y.useState(!1),b={...yf,...u};async function C(B){B.preventDefault(),_(!0),m("");const j=await r(h);j.success?e==null||e(h):m(j.error||"Erreur lors de l'envoi"),_(!1)}const S={backgroundColor:b.backgroundColor,borderRadius:b.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"28rem",...d&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},k={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${b.borderColor}`,borderRadius:b.borderRadius,backgroundColor:b.inputBackground,color:b.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},E={display:"block",fontSize:"0.875rem",fontWeight:500,color:b.textMutedColor,marginBottom:"0.25rem"},v={width:"100%",padding:"0.75rem",backgroundColor:x?b.textMutedColor:b.primaryColor,color:"#ffffff",border:"none",borderRadius:b.borderRadius,fontSize:"1rem",fontWeight:500,cursor:x?"not-allowed":"pointer",transition:"background-color 0.2s"},T={color:b.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return f.jsxs("div",{style:S,className:c,children:[f.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:b.textColor,marginBottom:"0.5rem",textAlign:"center"},children:n}),f.jsx("p",{style:{fontSize:"0.875rem",color:b.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:s}),f.jsxs("form",{onSubmit:C,children:[g&&f.jsx("div",{style:{padding:"0.75rem",backgroundColor:b.errorBackgroundColor,border:`1px solid ${b.errorColor}20`,borderRadius:b.borderRadius,marginBottom:"1rem"},children:f.jsx("p",{style:{fontSize:"0.875rem",color:b.errorColor,margin:0},children:g})}),f.jsxs("div",{style:{marginBottom:"1.5rem"},children:[f.jsx("label",{style:E,children:l}),f.jsx("input",{type:"email",value:h,onChange:B=>p(B.target.value),required:!0,style:k})]}),f.jsx("button",{type:"submit",disabled:x,style:v,onMouseEnter:B=>{x||(B.target.style.backgroundColor=b.primaryHoverColor)},onMouseLeave:B=>{x||(B.target.style.backgroundColor=b.primaryColor)},children:x?o:i}),t&&f.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:f.jsx("button",{type:"button",onClick:t,style:T,children:a})})]})]})}const xf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",inputBackground:"#ffffff",borderRadius:"0.5rem"};function du({email:r,code:e,onResetPassword:t,onSuccess:n,onBackClick:s,title:i="Nouveau mot de passe",subtitle:o,submitText:l="Réinitialiser",loadingText:a="Réinitialisation...",passwordLabel:u="Nouveau mot de passe",confirmPasswordLabel:c="Confirmer le mot de passe",backText:d="← Retour",theme:h,className:p="",isModal:g=!1}){const[m,x]=y.useState(""),[_,b]=y.useState(""),[C,S]=y.useState(""),[k,E]=y.useState(!1),v={...xf,...h};async function T(w){if(w.preventDefault(),S(""),m!==_){S("Les mots de passe ne correspondent pas");return}if(m.length<8){S("Le mot de passe doit contenir au moins 8 caractères");return}E(!0);const D=await t(r,e,m);D.success?n==null||n():S(D.error||"Erreur lors de la réinitialisation"),E(!1)}const B={backgroundColor:v.backgroundColor,borderRadius:v.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"28rem",...g&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},j={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${v.borderColor}`,borderRadius:v.borderRadius,backgroundColor:v.inputBackground,color:v.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},N={display:"block",fontSize:"0.875rem",fontWeight:500,color:v.textMutedColor,marginBottom:"0.25rem"},M={width:"100%",padding:"0.75rem",backgroundColor:k?v.textMutedColor:v.primaryColor,color:"#ffffff",border:"none",borderRadius:v.borderRadius,fontSize:"1rem",fontWeight:500,cursor:k?"not-allowed":"pointer",transition:"background-color 0.2s"},R={color:v.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return f.jsxs("div",{style:B,className:p,children:[f.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:v.textColor,marginBottom:"0.5rem",textAlign:"center"},children:i}),o&&f.jsx("p",{style:{fontSize:"0.875rem",color:v.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:o}),f.jsxs("form",{onSubmit:T,children:[C&&f.jsx("div",{style:{padding:"0.75rem",backgroundColor:v.errorBackgroundColor,border:`1px solid ${v.errorColor}20`,borderRadius:v.borderRadius,marginBottom:"1rem"},children:f.jsx("p",{style:{fontSize:"0.875rem",color:v.errorColor,margin:0},children:C})}),f.jsxs("div",{style:{marginBottom:"1rem"},children:[f.jsx("label",{style:N,children:u}),f.jsx("input",{type:"password",value:m,onChange:w=>x(w.target.value),required:!0,minLength:8,style:j})]}),f.jsxs("div",{style:{marginBottom:"1.5rem"},children:[f.jsx("label",{style:N,children:c}),f.jsx("input",{type:"password",value:_,onChange:w=>b(w.target.value),required:!0,style:j})]}),f.jsx("button",{type:"submit",disabled:k,style:M,onMouseEnter:w=>{k||(w.target.style.backgroundColor=v.primaryHoverColor)},onMouseLeave:w=>{k||(w.target.style.backgroundColor=v.primaryColor)},children:k?a:l}),s&&f.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:f.jsx("button",{type:"button",onClick:s,style:R,children:d})})]})]})}function fu({onLogin:r,onRegister:e,onVerifyEmail:t,onRequestPasswordReset:n,onResetPassword:s,onResendCode:i,onSuccess:o,initialState:l="login",logo:a,theme:u,showNameFields:c=!1,className:d="",isModal:h=!1,labels:p={}}){const[g,m]=y.useState(l),[x,_]=y.useState(""),[b,C]=y.useState("");async function S(B,j){const N=await r(B,j);return N.requiresVerification?(_(B),m("verify-email"),{success:!1,error:"Veuillez vérifier votre email"}):N}async function k(B,j,N){const M=await e(B,j,N);return M.success&&(M.requiresVerification?(_(B),m("verify-email")):o==null||o()),M}async function E(B){const j=await n(B);return j.success&&(_(B),m("verify-reset-code")),j}async function v(B,j){return C(j),m("reset-password"),{success:!0}}const T=()=>{switch(g){case"login":return f.jsx(No,{onLogin:S,onSuccess:o,onForgotPasswordClick:()=>m("forgot-password"),onRegisterClick:()=>m("register"),logo:a,theme:u,title:p.loginTitle,className:d,isModal:h});case"register":return f.jsx(uu,{onRegister:k,onSuccess:()=>{},onLoginClick:()=>m("login"),logo:a,theme:u,title:p.registerTitle,showNameFields:c,className:d,isModal:h});case"verify-email":return f.jsx(Gi,{email:x,onVerify:t,onSuccess:o,onResendCode:i,onBackClick:()=>m("login"),title:p.verifyTitle||"Vérification email",theme:u,className:d,isModal:h});case"forgot-password":return f.jsx(cu,{onRequestReset:E,onBackClick:()=>m("login"),title:p.forgotPasswordTitle,theme:u,className:d,isModal:h});case"verify-reset-code":return f.jsx(Gi,{email:x,onVerify:v,onResendCode:i,onBackClick:()=>m("forgot-password"),title:"Code de réinitialisation",theme:u,className:d,isModal:h});case"reset-password":return f.jsx(du,{email:x,code:b,onResetPassword:s,onSuccess:o,onBackClick:()=>m("login"),title:p.resetPasswordTitle,theme:u,className:d,isModal:h})}};return f.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%"},children:T()})}function bf({isOpen:r,onClose:e,backdropBlur:t=!0,...n}){return r?f.jsxs("div",{style:{position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center",padding:"1rem"},children:[f.jsx("div",{style:{position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",...t&&{backdropFilter:"blur(4px)"}},onClick:e}),f.jsxs("div",{style:{position:"relative",animation:"authFlowSlideUp 0.2s ease-out"},children:[f.jsx("button",{onClick:e,style:{position:"absolute",top:"0.75rem",right:"0.75rem",zIndex:10,background:"none",border:"none",padding:"0.25rem",cursor:"pointer",color:"#9CA3AF"},children:f.jsx("svg",{width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),f.jsx(fu,{...n,isModal:!0})]}),f.jsx("style",{children:`
68
+ `})]})}const gf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",successColor:"#059669",successBackgroundColor:"#ECFDF5",inputBackground:"#ffffff",borderRadius:"0.5rem"};function uu({onRegister:r,onSuccess:e,onLoginClick:t,logo:n,title:s="Créer un compte",submitText:i="S'inscrire",loadingText:o="Inscription...",emailLabel:a="Email",passwordLabel:l="Mot de passe",confirmPasswordLabel:u="Confirmer le mot de passe",firstNameLabel:c="Prénom",lastNameLabel:d="Nom",loginLinkText:h="Déjà un compte ? Se connecter",showNameFields:p=!1,theme:g,className:m="",isModal:x=!1}){const[_,b]=y.useState(""),[S,C]=y.useState(""),[k,E]=y.useState(""),[v,T]=y.useState(""),[B,j]=y.useState(""),[N,R]=y.useState(""),[M,w]=y.useState(!1),D={...gf,...g};async function F(H){if(H.preventDefault(),R(""),S!==k){R("Les mots de passe ne correspondent pas");return}if(S.length<8){R("Le mot de passe doit contenir au moins 8 caractères");return}w(!0);const le=await r(_,S,p?{firstName:v,lastName:B}:void 0);le.success?e==null||e(_):R(le.error||"Erreur lors de l'inscription"),w(!1)}const z={backgroundColor:D.backgroundColor,borderRadius:D.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"28rem",...x&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},q={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${D.borderColor}`,borderRadius:D.borderRadius,backgroundColor:D.inputBackground,color:D.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},J={display:"block",fontSize:"0.875rem",fontWeight:500,color:D.textMutedColor,marginBottom:"0.25rem"},te={width:"100%",padding:"0.75rem",backgroundColor:M?D.textMutedColor:D.primaryColor,color:"#ffffff",border:"none",borderRadius:D.borderRadius,fontSize:"1rem",fontWeight:500,cursor:M?"not-allowed":"pointer",transition:"background-color 0.2s"},W={padding:"0.75rem",backgroundColor:D.errorBackgroundColor,border:`1px solid ${D.errorColor}20`,borderRadius:D.borderRadius,marginBottom:"1rem"},G={color:D.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer"};return f.jsxs("div",{style:z,className:m,children:[n&&f.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"1.5rem"},children:n}),f.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:D.textColor,marginBottom:"1rem",textAlign:n?"center":"left"},children:s}),f.jsxs("form",{onSubmit:F,children:[N&&f.jsx("div",{style:W,children:f.jsx("p",{style:{fontSize:"0.875rem",color:D.errorColor,margin:0},children:N})}),p&&f.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"1rem"},children:[f.jsxs("div",{style:{flex:1},children:[f.jsx("label",{style:J,children:c}),f.jsx("input",{type:"text",value:v,onChange:H=>T(H.target.value),style:q})]}),f.jsxs("div",{style:{flex:1},children:[f.jsx("label",{style:J,children:d}),f.jsx("input",{type:"text",value:B,onChange:H=>j(H.target.value),style:q})]})]}),f.jsxs("div",{style:{marginBottom:"1rem"},children:[f.jsx("label",{style:J,children:a}),f.jsx("input",{type:"email",value:_,onChange:H=>b(H.target.value),required:!0,style:q})]}),f.jsxs("div",{style:{marginBottom:"1rem"},children:[f.jsx("label",{style:J,children:l}),f.jsx("input",{type:"password",value:S,onChange:H=>C(H.target.value),required:!0,minLength:8,style:q})]}),f.jsxs("div",{style:{marginBottom:"1.5rem"},children:[f.jsx("label",{style:J,children:u}),f.jsx("input",{type:"password",value:k,onChange:H=>E(H.target.value),required:!0,style:q})]}),f.jsx("button",{type:"submit",disabled:M,style:te,onMouseEnter:H=>{M||(H.target.style.backgroundColor=D.primaryHoverColor)},onMouseLeave:H=>{M||(H.target.style.backgroundColor=D.primaryColor)},children:M?o:i}),t&&f.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:f.jsx("span",{style:G,onClick:t,children:h})})]})]})}const mf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",successColor:"#059669",inputBackground:"#ffffff",borderRadius:"0.5rem"};function Gi({email:r,onVerify:e,onSuccess:t,onResendCode:n,onBackClick:s,title:i="Vérification",subtitle:o,submitText:a="Vérifier",loadingText:l="Vérification...",resendText:u="Renvoyer le code",resendingText:c="Envoi...",backText:d="← Retour",codeLength:h=6,theme:p,className:g="",isModal:m=!1}){const[x,_]=y.useState(Array(h).fill("")),[b,S]=y.useState(""),[C,k]=y.useState(!1),[E,v]=y.useState(!1),[T,B]=y.useState(!1),j=y.useRef([]),N={...mf,...p};y.useEffect(()=>{var W;(W=j.current[0])==null||W.focus()},[]);const R=(W,G)=>{var le;const H=G.replace(/\D/g,"").slice(-1),se=[...x];if(se[W]=H,_(se),S(""),H&&W<h-1&&((le=j.current[W+1])==null||le.focus()),H&&W===h-1){const ue=se.join("");ue.length===h&&D(ue)}},M=(W,G)=>{var H;G.key==="Backspace"&&!x[W]&&W>0&&((H=j.current[W-1])==null||H.focus())},w=W=>{var le;W.preventDefault();const G=W.clipboardData.getData("text").replace(/\D/g,"").slice(0,h),H=[...x];G.split("").forEach((ue,_e)=>{_e<h&&(H[_e]=ue)}),_(H);const se=Math.min(G.length,h)-1;se>=0&&((le=j.current[se])==null||le.focus()),G.length===h&&D(G)};async function D(W){var se;const G=W||x.join("");if(G.length!==h){S("Veuillez entrer le code complet");return}k(!0),S("");const H=await e(r,G);H.success?t==null||t():(S(H.error||"Code invalide"),_(Array(h).fill("")),(se=j.current[0])==null||se.focus()),k(!1)}async function F(){if(!n)return;v(!0),B(!1),S("");const W=await n(r);W.success?(B(!0),setTimeout(()=>B(!1),3e3)):S(W.error||"Erreur lors de l'envoi"),v(!1)}const z={backgroundColor:N.backgroundColor,borderRadius:N.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"28rem",...m&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},q={width:"3rem",height:"3.5rem",textAlign:"center",fontSize:"1.5rem",fontWeight:600,border:`2px solid ${N.borderColor}`,borderRadius:N.borderRadius,backgroundColor:N.inputBackground,color:N.textColor,outline:"none",transition:"border-color 0.2s, box-shadow 0.2s"},J={width:"100%",padding:"0.75rem",backgroundColor:C?N.textMutedColor:N.primaryColor,color:"#ffffff",border:"none",borderRadius:N.borderRadius,fontSize:"1rem",fontWeight:500,cursor:C?"not-allowed":"pointer",transition:"background-color 0.2s"},te={color:N.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return f.jsxs("div",{style:z,className:g,children:[f.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:N.textColor,marginBottom:"0.5rem",textAlign:"center"},children:i}),f.jsx("p",{style:{fontSize:"0.875rem",color:N.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:o||`Un code a été envoyé à ${r}`}),b&&f.jsx("div",{style:{padding:"0.75rem",backgroundColor:N.errorBackgroundColor,border:`1px solid ${N.errorColor}20`,borderRadius:N.borderRadius,marginBottom:"1rem"},children:f.jsx("p",{style:{fontSize:"0.875rem",color:N.errorColor,margin:0,textAlign:"center"},children:b})}),T&&f.jsx("div",{style:{padding:"0.75rem",backgroundColor:"#ECFDF5",border:`1px solid ${N.successColor}20`,borderRadius:N.borderRadius,marginBottom:"1rem"},children:f.jsx("p",{style:{fontSize:"0.875rem",color:N.successColor,margin:0,textAlign:"center"},children:"Code renvoyé !"})}),f.jsx("div",{style:{display:"flex",justifyContent:"center",gap:"0.5rem",marginBottom:"1.5rem"},children:x.map((W,G)=>f.jsx("input",{ref:H=>{j.current[G]=H},type:"text",inputMode:"numeric",maxLength:1,value:W,onChange:H=>R(G,H.target.value),onKeyDown:H=>M(G,H),onPaste:w,disabled:C,style:{...q,borderColor:W?N.primaryColor:N.borderColor},onFocus:H=>{H.target.style.borderColor=N.primaryColor,H.target.style.boxShadow=`0 0 0 3px ${N.primaryColor}20`},onBlur:H=>{H.target.style.borderColor=W?N.primaryColor:N.borderColor,H.target.style.boxShadow="none"}},G))}),f.jsx("button",{type:"button",onClick:()=>D(),disabled:C||x.join("").length!==h,style:{...J,opacity:x.join("").length!==h?.5:1},children:C?l:a}),n&&f.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:f.jsx("button",{type:"button",onClick:F,disabled:E,style:{...te,opacity:E?.5:1},children:E?c:u})}),s&&f.jsx("p",{style:{textAlign:"center",marginTop:"0.75rem",marginBottom:0},children:f.jsx("button",{type:"button",onClick:s,style:te,children:d})})]})}const yf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",successColor:"#059669",successBackgroundColor:"#ECFDF5",inputBackground:"#ffffff",borderRadius:"0.5rem"};function cu({onRequestReset:r,onSuccess:e,onBackClick:t,title:n="Mot de passe oublié",subtitle:s="Entrez votre email pour recevoir un code de réinitialisation",submitText:i="Envoyer le code",loadingText:o="Envoi...",emailLabel:a="Email",backText:l="← Retour à la connexion",theme:u,className:c="",isModal:d=!1}){const[h,p]=y.useState(""),[g,m]=y.useState(""),[x,_]=y.useState(!1),b={...yf,...u};async function S(B){B.preventDefault(),_(!0),m("");const j=await r(h);j.success?e==null||e(h):m(j.error||"Erreur lors de l'envoi"),_(!1)}const C={backgroundColor:b.backgroundColor,borderRadius:b.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"28rem",...d&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},k={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${b.borderColor}`,borderRadius:b.borderRadius,backgroundColor:b.inputBackground,color:b.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},E={display:"block",fontSize:"0.875rem",fontWeight:500,color:b.textMutedColor,marginBottom:"0.25rem"},v={width:"100%",padding:"0.75rem",backgroundColor:x?b.textMutedColor:b.primaryColor,color:"#ffffff",border:"none",borderRadius:b.borderRadius,fontSize:"1rem",fontWeight:500,cursor:x?"not-allowed":"pointer",transition:"background-color 0.2s"},T={color:b.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return f.jsxs("div",{style:C,className:c,children:[f.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:b.textColor,marginBottom:"0.5rem",textAlign:"center"},children:n}),f.jsx("p",{style:{fontSize:"0.875rem",color:b.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:s}),f.jsxs("form",{onSubmit:S,children:[g&&f.jsx("div",{style:{padding:"0.75rem",backgroundColor:b.errorBackgroundColor,border:`1px solid ${b.errorColor}20`,borderRadius:b.borderRadius,marginBottom:"1rem"},children:f.jsx("p",{style:{fontSize:"0.875rem",color:b.errorColor,margin:0},children:g})}),f.jsxs("div",{style:{marginBottom:"1.5rem"},children:[f.jsx("label",{style:E,children:a}),f.jsx("input",{type:"email",value:h,onChange:B=>p(B.target.value),required:!0,style:k})]}),f.jsx("button",{type:"submit",disabled:x,style:v,onMouseEnter:B=>{x||(B.target.style.backgroundColor=b.primaryHoverColor)},onMouseLeave:B=>{x||(B.target.style.backgroundColor=b.primaryColor)},children:x?o:i}),t&&f.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:f.jsx("button",{type:"button",onClick:t,style:T,children:l})})]})]})}const xf={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",inputBackground:"#ffffff",borderRadius:"0.5rem"};function du({email:r,code:e,onResetPassword:t,onSuccess:n,onBackClick:s,title:i="Nouveau mot de passe",subtitle:o,submitText:a="Réinitialiser",loadingText:l="Réinitialisation...",passwordLabel:u="Nouveau mot de passe",confirmPasswordLabel:c="Confirmer le mot de passe",backText:d="← Retour",theme:h,className:p="",isModal:g=!1}){const[m,x]=y.useState(""),[_,b]=y.useState(""),[S,C]=y.useState(""),[k,E]=y.useState(!1),v={...xf,...h};async function T(w){if(w.preventDefault(),C(""),m!==_){C("Les mots de passe ne correspondent pas");return}if(m.length<8){C("Le mot de passe doit contenir au moins 8 caractères");return}E(!0);const D=await t(r,e,m);D.success?n==null||n():C(D.error||"Erreur lors de la réinitialisation"),E(!1)}const B={backgroundColor:v.backgroundColor,borderRadius:v.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"28rem",...g&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},j={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${v.borderColor}`,borderRadius:v.borderRadius,backgroundColor:v.inputBackground,color:v.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},N={display:"block",fontSize:"0.875rem",fontWeight:500,color:v.textMutedColor,marginBottom:"0.25rem"},R={width:"100%",padding:"0.75rem",backgroundColor:k?v.textMutedColor:v.primaryColor,color:"#ffffff",border:"none",borderRadius:v.borderRadius,fontSize:"1rem",fontWeight:500,cursor:k?"not-allowed":"pointer",transition:"background-color 0.2s"},M={color:v.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return f.jsxs("div",{style:B,className:p,children:[f.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:v.textColor,marginBottom:"0.5rem",textAlign:"center"},children:i}),o&&f.jsx("p",{style:{fontSize:"0.875rem",color:v.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:o}),f.jsxs("form",{onSubmit:T,children:[S&&f.jsx("div",{style:{padding:"0.75rem",backgroundColor:v.errorBackgroundColor,border:`1px solid ${v.errorColor}20`,borderRadius:v.borderRadius,marginBottom:"1rem"},children:f.jsx("p",{style:{fontSize:"0.875rem",color:v.errorColor,margin:0},children:S})}),f.jsxs("div",{style:{marginBottom:"1rem"},children:[f.jsx("label",{style:N,children:u}),f.jsx("input",{type:"password",value:m,onChange:w=>x(w.target.value),required:!0,minLength:8,style:j})]}),f.jsxs("div",{style:{marginBottom:"1.5rem"},children:[f.jsx("label",{style:N,children:c}),f.jsx("input",{type:"password",value:_,onChange:w=>b(w.target.value),required:!0,style:j})]}),f.jsx("button",{type:"submit",disabled:k,style:R,onMouseEnter:w=>{k||(w.target.style.backgroundColor=v.primaryHoverColor)},onMouseLeave:w=>{k||(w.target.style.backgroundColor=v.primaryColor)},children:k?l:a}),s&&f.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:f.jsx("button",{type:"button",onClick:s,style:M,children:d})})]})]})}function fu({onLogin:r,onRegister:e,onVerifyEmail:t,onRequestPasswordReset:n,onResetPassword:s,onResendCode:i,onSuccess:o,initialState:a="login",logo:l,theme:u,showNameFields:c=!1,className:d="",isModal:h=!1,labels:p={}}){const[g,m]=y.useState(a),[x,_]=y.useState(""),[b,S]=y.useState("");async function C(B,j){const N=await r(B,j);return N.requiresVerification?(_(B),m("verify-email"),{success:!1,error:"Veuillez vérifier votre email"}):N}async function k(B,j,N){const R=await e(B,j,N);return R.success&&(R.requiresVerification?(_(B),m("verify-email")):o==null||o()),R}async function E(B){const j=await n(B);return j.success&&(_(B),m("verify-reset-code")),j}async function v(B,j){return S(j),m("reset-password"),{success:!0}}const T=()=>{switch(g){case"login":return f.jsx(No,{onLogin:C,onSuccess:o,onForgotPasswordClick:()=>m("forgot-password"),onRegisterClick:()=>m("register"),logo:l,theme:u,title:p.loginTitle,className:d,isModal:h});case"register":return f.jsx(uu,{onRegister:k,onSuccess:()=>{},onLoginClick:()=>m("login"),logo:l,theme:u,title:p.registerTitle,showNameFields:c,className:d,isModal:h});case"verify-email":return f.jsx(Gi,{email:x,onVerify:t,onSuccess:o,onResendCode:i,onBackClick:()=>m("login"),title:p.verifyTitle||"Vérification email",theme:u,className:d,isModal:h});case"forgot-password":return f.jsx(cu,{onRequestReset:E,onBackClick:()=>m("login"),title:p.forgotPasswordTitle,theme:u,className:d,isModal:h});case"verify-reset-code":return f.jsx(Gi,{email:x,onVerify:v,onResendCode:i,onBackClick:()=>m("forgot-password"),title:"Code de réinitialisation",theme:u,className:d,isModal:h});case"reset-password":return f.jsx(du,{email:x,code:b,onResetPassword:s,onSuccess:o,onBackClick:()=>m("login"),title:p.resetPasswordTitle,theme:u,className:d,isModal:h})}};return f.jsx("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%"},children:T()})}function bf({isOpen:r,onClose:e,backdropBlur:t=!0,...n}){return r?f.jsxs("div",{style:{position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center",padding:"1rem"},children:[f.jsx("div",{style:{position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",...t&&{backdropFilter:"blur(4px)"}},onClick:e}),f.jsxs("div",{style:{position:"relative",animation:"authFlowSlideUp 0.2s ease-out"},children:[f.jsx("button",{onClick:e,style:{position:"absolute",top:"0.75rem",right:"0.75rem",zIndex:10,background:"none",border:"none",padding:"0.25rem",cursor:"pointer",color:"#9CA3AF"},children:f.jsx("svg",{width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),f.jsx(fu,{...n,isModal:!0})]}),f.jsx("style",{children:`
69
69
  @keyframes authFlowSlideUp {
70
70
  from {
71
71
  opacity: 0;
@@ -76,36 +76,36 @@ React keys must be passed directly to JSX without using spread:
76
76
  transform: translateY(0);
77
77
  }
78
78
  }
79
- `})]}):null}function hu(r,e,t={}){const{enabled:n=!0,refetchOnMount:s=!0,onSuccess:i,onError:o}=t,[l,a]=y.useState(null),[u,c]=y.useState(n),[d,h]=y.useState(null),p=y.useCallback(async()=>{if(n){c(!0),h(null);try{const m=await To().get(r,e);a(m),i==null||i(m)}catch(g){const m=g instanceof Error?g:new Error("Unknown error");h(m),o==null||o(m)}finally{c(!1)}}},[r,JSON.stringify(e),n,i,o]);return y.useEffect(()=>{s&&p()},[p,s]),{data:l,loading:u,error:d,refetch:p}}function vf(r,e="POST",t={}){const{onSuccess:n,onError:s}=t,[i,o]=y.useState(null),[l,a]=y.useState(!1),[u,c]=y.useState(null),d=y.useCallback(async p=>{a(!0),c(null);try{const g=To();let m;switch(e){case"POST":m=await g.post(r,p);break;case"PUT":m=await g.put(r,p);break;case"PATCH":m=await g.patch(r,p);break;case"DELETE":m=await g.delete(r);break;default:throw new Error(`Unsupported method: ${e}`)}return o(m),n==null||n(m,p),m}catch(g){const m=g instanceof Error?g:new Error("Unknown error");return c(m),s==null||s(m,p),null}finally{a(!1)}},[r,e,n,s]),h=y.useCallback(()=>{o(null),c(null),a(!1)},[]);return{data:i,loading:l,error:u,mutate:d,reset:h}}class vs{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,i])=>n[s]===i))}static sort(e,t,n="asc"){return[...e].sort((s,i)=>{const o=s[t],l=i[t];if(o===l)return 0;let a=0;return o>l&&(a=1),o<l&&(a=-1),n==="asc"?a:-a})}static search(e,t,n){if(!t.trim())return e;const s=t.toLowerCase();return e.filter(i=>n.some(o=>{const l=i[o];return l==null?!1:String(l).toLowerCase().includes(s)}))}static paginate(e,t,n){const s=(t-1)*n,i=s+n;return{data:e.slice(s,i),total:e.length,page:t,totalPages:Math.ceil(e.length/n)}}static groupBy(e,t){return e.reduce((n,s)=>{const i=String(s[t]);return n[i]||(n[i]=[]),n[i].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 i=String(s[t]);return n[i]=(n[i]||0)+1,n},{})}static pipe(e,t){return t.reduce((n,s)=>s(n),e)}}function _f({endpoint:r,params:e,layout:t="list",title:n,emptyMessage:s="No items found",renderItem:i,keyExtractor:o=(m,x)=>m.id||m._id||String(x),searchable:l=!1,searchFields:a=[],searchPlaceholder:u="Search...",filters:c=[],pageSize:d=20,onItemClick:h,onRefresh:p,theme:g={}}){const{data:m,loading:x,error:_,refetch:b}=hu(r,e),[C,S]=y.useState(""),[k,E]=y.useState({}),[v,T]=y.useState(1),B=y.useMemo(()=>{if(!m)return{data:[],total:0,totalPages:0};let w=m;return l&&C&&a.length>0&&(w=vs.search(w,C,a)),Object.keys(k).length>0&&(w=vs.filterByFields(w,k)),vs.paginate(w,v,d)},[m,C,k,v,d,l,a]);y.useEffect(()=>{T(1)},[C,k]);const j=()=>{S(""),E({}),T(1),b(),p==null||p()},N={background:g.background||"#ffffff",cardBackground:g.cardBackground||"#f9fafb",text:g.text||"#111827",textSecondary:g.textSecondary||"#6b7280",border:g.border||"#e5e7eb",primary:g.primary||"#3b82f6"},R=i||(w=>f.jsxs("div",{style:{padding:"16px",cursor:h?"pointer":"default"},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:N.text},children:w.title||w.name||w.label||"Untitled"}),w.description&&f.jsx("div",{style:{fontSize:"13px",color:N.textSecondary,marginTop:"4px"},children:w.description})]}));return x&&!m?f.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px",color:N.textSecondary},children:"Loading..."}):_?f.jsxs("div",{style:{padding:"24px",textAlign:"center",color:"#ef4444"},children:[f.jsx("div",{style:{fontWeight:500,marginBottom:"8px"},children:"Error"}),f.jsx("div",{style:{fontSize:"14px"},children:_.message}),f.jsx("button",{onClick:j,style:{marginTop:"16px",padding:"8px 16px",background:N.primary,color:"white",border:"none",borderRadius:"6px",cursor:"pointer"},children:"Retry"})]}):f.jsxs("div",{style:{background:N.background,borderRadius:"12px",overflow:"hidden"},children:[(n||l||c.length>0)&&f.jsxs("div",{style:{padding:"16px",borderBottom:`1px solid ${N.border}`},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:l||c.length>0?"12px":"0"},children:[n&&f.jsx("h2",{style:{margin:0,fontSize:"18px",fontWeight:600,color:N.text},children:n}),f.jsx("button",{onClick:j,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${N.border}`,borderRadius:"6px",color:N.textSecondary,cursor:"pointer",fontSize:"13px"},children:"Refresh"})]}),l&&f.jsx("input",{type:"text",placeholder:u,value:C,onChange:w=>S(w.target.value),style:{width:"100%",padding:"8px 12px",border:`1px solid ${N.border}`,borderRadius:"8px",fontSize:"14px",outline:"none"}})]}),f.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:B.data.length===0?f.jsx("div",{style:{padding:"48px",textAlign:"center",color:N.textSecondary},children:s}):B.data.map((w,D)=>f.jsx("div",{onClick:()=>h==null?void 0:h(w),style:{background:N.cardBackground,borderRadius:t==="list"?"0":"8px",borderBottom:t==="list"?`1px solid ${N.border}`:"none",transition:"all 0.15s ease"},onMouseEnter:F=>{h&&(F.currentTarget.style.background=N.border)},onMouseLeave:F=>{F.currentTarget.style.background=N.cardBackground},children:R(w,D)},o(w,D)))}),B.totalPages>1&&f.jsxs("div",{style:{padding:"16px",borderTop:`1px solid ${N.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[f.jsxs("div",{style:{fontSize:"13px",color:N.textSecondary},children:["Page ",v," of ",B.totalPages]}),f.jsxs("div",{style:{display:"flex",gap:"8px"},children:[f.jsx("button",{onClick:()=>T(w=>Math.max(1,w-1)),disabled:v===1,style:{padding:"6px 12px",border:`1px solid ${N.border}`,borderRadius:"6px",background:"white",cursor:v===1?"not-allowed":"pointer",opacity:v===1?.5:1},children:"Previous"}),f.jsx("button",{onClick:()=>T(w=>Math.min(B.totalPages,w+1)),disabled:v===B.totalPages,style:{padding:"6px 12px",border:`1px solid ${N.border}`,borderRadius:"6px",background:"white",cursor:v===B.totalPages?"not-allowed":"pointer",opacity:v===B.totalPages?.5:1},children:"Next"})]})]})]})}function wf({item:r,onClick:e,title:t=o=>o.title||o.name||o.label||"Untitled",subtitle:n=o=>o.description||o.subtitle||"",image:s=o=>o.image||o.thumbnail||o.photo,badge:i=o=>o.badge||o.tag||o.type}){const o=t(r),l=n(r),a=s(r),u=i(r);return f.jsxs("div",{onClick:e,className:`
79
+ `})]}):null}function hu(r,e,t={}){const{enabled:n=!0,refetchOnMount:s=!0,onSuccess:i,onError:o}=t,[a,l]=y.useState(null),[u,c]=y.useState(n),[d,h]=y.useState(null),p=y.useCallback(async()=>{if(n){c(!0),h(null);try{const m=await To().get(r,e);l(m),i==null||i(m)}catch(g){const m=g instanceof Error?g:new Error("Unknown error");h(m),o==null||o(m)}finally{c(!1)}}},[r,JSON.stringify(e),n,i,o]);return y.useEffect(()=>{s&&p()},[p,s]),{data:a,loading:u,error:d,refetch:p}}function vf(r,e="POST",t={}){const{onSuccess:n,onError:s}=t,[i,o]=y.useState(null),[a,l]=y.useState(!1),[u,c]=y.useState(null),d=y.useCallback(async p=>{l(!0),c(null);try{const g=To();let m;switch(e){case"POST":m=await g.post(r,p);break;case"PUT":m=await g.put(r,p);break;case"PATCH":m=await g.patch(r,p);break;case"DELETE":m=await g.delete(r);break;default:throw new Error(`Unsupported method: ${e}`)}return o(m),n==null||n(m,p),m}catch(g){const m=g instanceof Error?g:new Error("Unknown error");return c(m),s==null||s(m,p),null}finally{l(!1)}},[r,e,n,s]),h=y.useCallback(()=>{o(null),c(null),l(!1)},[]);return{data:i,loading:a,error:u,mutate:d,reset:h}}class vs{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,i])=>n[s]===i))}static sort(e,t,n="asc"){return[...e].sort((s,i)=>{const o=s[t],a=i[t];if(o===a)return 0;let l=0;return o>a&&(l=1),o<a&&(l=-1),n==="asc"?l:-l})}static search(e,t,n){if(!t.trim())return e;const s=t.toLowerCase();return e.filter(i=>n.some(o=>{const a=i[o];return a==null?!1:String(a).toLowerCase().includes(s)}))}static paginate(e,t,n){const s=(t-1)*n,i=s+n;return{data:e.slice(s,i),total:e.length,page:t,totalPages:Math.ceil(e.length/n)}}static groupBy(e,t){return e.reduce((n,s)=>{const i=String(s[t]);return n[i]||(n[i]=[]),n[i].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 i=String(s[t]);return n[i]=(n[i]||0)+1,n},{})}static pipe(e,t){return t.reduce((n,s)=>s(n),e)}}function _f({endpoint:r,params:e,layout:t="list",title:n,emptyMessage:s="No items found",renderItem:i,keyExtractor:o=(m,x)=>m.id||m._id||String(x),searchable:a=!1,searchFields:l=[],searchPlaceholder:u="Search...",filters:c=[],pageSize:d=20,onItemClick:h,onRefresh:p,theme:g={}}){const{data:m,loading:x,error:_,refetch:b}=hu(r,e),[S,C]=y.useState(""),[k,E]=y.useState({}),[v,T]=y.useState(1),B=y.useMemo(()=>{if(!m)return{data:[],total:0,totalPages:0};let w=m;return a&&S&&l.length>0&&(w=vs.search(w,S,l)),Object.keys(k).length>0&&(w=vs.filterByFields(w,k)),vs.paginate(w,v,d)},[m,S,k,v,d,a,l]);y.useEffect(()=>{T(1)},[S,k]);const j=()=>{C(""),E({}),T(1),b(),p==null||p()},N={background:g.background||"#ffffff",cardBackground:g.cardBackground||"#f9fafb",text:g.text||"#111827",textSecondary:g.textSecondary||"#6b7280",border:g.border||"#e5e7eb",primary:g.primary||"#3b82f6"},M=i||(w=>f.jsxs("div",{style:{padding:"16px",cursor:h?"pointer":"default"},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:N.text},children:w.title||w.name||w.label||"Untitled"}),w.description&&f.jsx("div",{style:{fontSize:"13px",color:N.textSecondary,marginTop:"4px"},children:w.description})]}));return x&&!m?f.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px",color:N.textSecondary},children:"Loading..."}):_?f.jsxs("div",{style:{padding:"24px",textAlign:"center",color:"#ef4444"},children:[f.jsx("div",{style:{fontWeight:500,marginBottom:"8px"},children:"Error"}),f.jsx("div",{style:{fontSize:"14px"},children:_.message}),f.jsx("button",{onClick:j,style:{marginTop:"16px",padding:"8px 16px",background:N.primary,color:"white",border:"none",borderRadius:"6px",cursor:"pointer"},children:"Retry"})]}):f.jsxs("div",{style:{background:N.background,borderRadius:"12px",overflow:"hidden"},children:[(n||a||c.length>0)&&f.jsxs("div",{style:{padding:"16px",borderBottom:`1px solid ${N.border}`},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:a||c.length>0?"12px":"0"},children:[n&&f.jsx("h2",{style:{margin:0,fontSize:"18px",fontWeight:600,color:N.text},children:n}),f.jsx("button",{onClick:j,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${N.border}`,borderRadius:"6px",color:N.textSecondary,cursor:"pointer",fontSize:"13px"},children:"Refresh"})]}),a&&f.jsx("input",{type:"text",placeholder:u,value:S,onChange:w=>C(w.target.value),style:{width:"100%",padding:"8px 12px",border:`1px solid ${N.border}`,borderRadius:"8px",fontSize:"14px",outline:"none"}})]}),f.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:B.data.length===0?f.jsx("div",{style:{padding:"48px",textAlign:"center",color:N.textSecondary},children:s}):B.data.map((w,D)=>f.jsx("div",{onClick:()=>h==null?void 0:h(w),style:{background:N.cardBackground,borderRadius:t==="list"?"0":"8px",borderBottom:t==="list"?`1px solid ${N.border}`:"none",transition:"all 0.15s ease"},onMouseEnter:F=>{h&&(F.currentTarget.style.background=N.border)},onMouseLeave:F=>{F.currentTarget.style.background=N.cardBackground},children:M(w,D)},o(w,D)))}),B.totalPages>1&&f.jsxs("div",{style:{padding:"16px",borderTop:`1px solid ${N.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[f.jsxs("div",{style:{fontSize:"13px",color:N.textSecondary},children:["Page ",v," of ",B.totalPages]}),f.jsxs("div",{style:{display:"flex",gap:"8px"},children:[f.jsx("button",{onClick:()=>T(w=>Math.max(1,w-1)),disabled:v===1,style:{padding:"6px 12px",border:`1px solid ${N.border}`,borderRadius:"6px",background:"white",cursor:v===1?"not-allowed":"pointer",opacity:v===1?.5:1},children:"Previous"}),f.jsx("button",{onClick:()=>T(w=>Math.min(B.totalPages,w+1)),disabled:v===B.totalPages,style:{padding:"6px 12px",border:`1px solid ${N.border}`,borderRadius:"6px",background:"white",cursor:v===B.totalPages?"not-allowed":"pointer",opacity:v===B.totalPages?.5:1},children:"Next"})]})]})]})}function wf({item:r,onClick:e,title:t=o=>o.title||o.name||o.label||"Untitled",subtitle:n=o=>o.description||o.subtitle||"",image:s=o=>o.image||o.thumbnail||o.photo,badge:i=o=>o.badge||o.tag||o.type}){const o=t(r),a=n(r),l=s(r),u=i(r);return f.jsxs("div",{onClick:e,className:`
80
80
  flex items-center gap-4 p-4 border-b border-gray-200
81
81
  hover:bg-gray-50 transition-colors
82
82
  ${e?"cursor-pointer":""}
83
- `,children:[a&&f.jsx("div",{className:"flex-shrink-0",children:f.jsx("img",{src:a,alt:o,className:"w-16 h-16 object-cover rounded-lg"})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"font-medium text-gray-900 truncate",children:o}),u&&f.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-blue-100 text-blue-800 rounded-full",children:u})]}),l&&f.jsx("p",{className:"text-sm text-gray-600 truncate mt-0.5",children:l})]}),e&&f.jsx("div",{className:"flex-shrink-0 text-gray-400",children:f.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})}function Cf({item:r,onClose:e,title:t=i=>i.title||i.name||i.label||"Detail",image:n=i=>i.image||i.thumbnail||i.photo,fields:s=[]}){if(!r)return null;const i=t(r),o=n(r);return f.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:f.jsxs("div",{className:"bg-white rounded-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto shadow-2xl",children:[f.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between",children:[f.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:i}),e&&f.jsx("button",{onClick:e,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:f.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),f.jsxs("div",{className:"p-6",children:[o&&f.jsx("div",{className:"mb-6",children:f.jsx("img",{src:o,alt:i,className:"w-full h-64 object-cover rounded-lg"})}),s.length>0&&f.jsx("div",{className:"space-y-4",children:s.map((l,a)=>{const u=l.value(r);return u==null||u===""?null:f.jsxs("div",{children:[f.jsx("div",{className:"text-sm font-medium text-gray-500 mb-1",children:l.label}),f.jsx("div",{className:"text-base text-gray-900",children:typeof u=="object"?JSON.stringify(u,null,2):String(u)})]},a)})}),s.length===0&&f.jsx("pre",{className:"bg-gray-50 p-4 rounded-lg text-sm overflow-x-auto",children:JSON.stringify(r,null,2)})]}),e&&f.jsx("div",{className:"sticky bottom-0 bg-gray-50 border-t border-gray-200 px-6 py-4",children:f.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 Ea={small:{base:96,sm:112,md:128},medium:{base:128,sm:160,md:192},large:{base:160,sm:224,md:256,lg:288}};function Sf(r){const e=[...r];for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e}function kf({nodes:r,minInterval:e=3e3,maxInterval:t=6e3,onCardClick:n,cardSize:s="medium",aspectRatio:i="1:1",className:o=""}){var j,N;const[l]=y.useState(()=>{if(r.length===0)return[[],[]];const M=Sf(r),R=Math.ceil(M.length/2);return console.log("[AnimatedCardFlip] Pools:",{left:M.slice(0,R).map(w=>w.title),right:M.slice(R).map(w=>w.title)}),[M.slice(0,R),M.slice(R)]}),[a,u]=y.useState(()=>{const M=Ea[s];if(typeof window>"u")return M.base;const R=window.innerWidth;return"lg"in M&&R>=1024?M.lg:R>=768?M.md:R>=640?M.sm:M.base});y.useEffect(()=>{const M=()=>{const R=Ea[s],w=window.innerWidth;"lg"in R&&w>=1024?u(R.lg):w>=768?u(R.md):w>=640?u(R.sm):u(R.base)};return window.addEventListener("resize",M),M(),()=>window.removeEventListener("resize",M)},[s]);const[c,d]=y.useState(0),[h,p]=y.useState(0),[g,m]=y.useState(!1),[x,_]=y.useState(!1),[b,C]=y.useState(!1),[S,k]=y.useState(!1);y.useEffect(()=>{if(l[0].length<=1)return;const M=setInterval(()=>{m(R=>!R),setTimeout(()=>{d(R=>(R+1)%l[0].length),C(R=>!R)},250)},e+Math.random()*(t-e));return()=>clearInterval(M)},[l,e,t]),y.useEffect(()=>{if(l[1].length<=1)return;let M=null;const R=setTimeout(()=>{M=setInterval(()=>{_(w=>!w),setTimeout(()=>{p(w=>(w+1)%l[1].length),k(w=>!w)},250)},e+Math.random()*(t-e))},500);return()=>{clearTimeout(R),M&&clearInterval(M)}},[l,e,t]);const E=(j=l[0])==null?void 0:j[c],v=(N=l[1])==null?void 0:N[h];if(r.length===0||!E)return f.jsx("div",{className:`flex items-center justify-center p-8 ${o}`,children:f.jsx("p",{className:"text-gray-500",children:"No images available"})});const T=i==="2:3"?a*1.5:a,B=(M,R,w)=>f.jsx("div",{className:"relative",style:{width:a,height:T,perspective:"1000px"},onClick:()=>n==null?void 0:n(M),children:f.jsx("div",{className:"w-full h-full rounded-lg shadow-lg overflow-hidden cursor-pointer hover:shadow-xl",style:{transform:`rotateY(${R?180:0}deg)`,transition:"transform 0.5s ease-in-out",transformStyle:"preserve-3d"},children:f.jsxs("div",{className:"w-full h-full",style:{transform:w?"scaleX(-1)":"none"},children:[f.jsx("img",{src:M.data.image,alt:M.title,className:"w-full h-full object-cover"}),f.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:f.jsx("p",{className:"text-white text-sm font-medium truncate",children:M.title})})]})})});return f.jsxs("div",{className:`flex gap-4 justify-center items-center ${o}`,children:[B(E,g,b),v&&B(v,x,S)]})}function $r(r){if(!r)return"";const e=/=\?([^?]+)\?([BQbq])\?([^?]*)\?=/g;return r.replace(e,(t,n,s,i)=>{try{if(s.toUpperCase()==="B"){const o=atob(i);return decodeURIComponent(escape(o))}else if(s.toUpperCase()==="Q"){const o=i.replace(/_/g," ").replace(/=([0-9A-Fa-f]{2})/g,(l,a)=>String.fromCharCode(parseInt(a,16)));return decodeURIComponent(escape(o))}}catch(o){console.warn("MIME decode error:",o)}return t}).replace(/\s+/g," ").trim()}const Ef={background:"#ffffff",cardBackground:"#ffffff",selectedBackground:"#f5f5f5",unreadBackground:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",danger:"#ef4444"};function Df({baseUrl:r,systemId:e,accountId:t,limit:n=30,folder:s,selectable:i=!0,showDetail:o=!1,showSearch:l=!0,searchQuery:a,onSearchChange:u,emptyMessage:c="No emails",autoLoad:d=!0,onSelect:h,onSelectionChange:p,onDelete:g,onError:m,onLoad:x,renderItem:_,renderDetail:b,renderActions:C,renderEmpty:S,renderLoading:k,theme:E={}}){const v={...Ef,...E},[T,B]=y.useState([]),[j,N]=y.useState(!1),[M,R]=y.useState(null),[w,D]=y.useState(new Set),[F,I]=y.useState(null),[U,J]=y.useState(null),[te,W]=y.useState(null),[V,H]=y.useState(!1),[ne,ce]=y.useState(""),le=a!==void 0?a:ne,pe=oe=>{u?u(oe):ce(oe)},be=y.useMemo(()=>{if(!le.trim())return T;const oe=le.toLowerCase();return T.filter(fe=>$r(fe.from).toLowerCase().includes(oe)||$r(fe.subject).toLowerCase().includes(oe))},[T,le]),Te=y.useMemo(()=>e?new iu({baseUrl:r,system_id:e}):null,[r,e]),$=y.useCallback(async()=>{if(Te){N(!0),R(null);try{const oe=await Te.listEmails(t,n,s);oe!=null&&oe.messages&&(B(oe.messages),x==null||x(oe.messages))}catch(oe){const fe=oe instanceof Error?oe:new Error("Failed to fetch emails");R(fe.message),m==null||m(fe)}N(!1)}},[Te,t,n,s,m,x]);y.useEffect(()=>{B([]),D(new Set),J(null),R(null),a===void 0&&ce(""),d&&$()},[s,d]);const ke=y.useCallback(async oe=>{if(Te){J(oe),W(null),H(!0);try{const fe=await Te.getEmailParsed(t,oe.uid,s||"INBOX");fe!=null&&fe.body&&W(fe.body)}catch(fe){console.error("Failed to fetch email body:",fe)}H(!1)}},[Te,t,s]),se=y.useCallback(oe=>{h==null||h(oe),o&&ke(oe)},[h,o,ke]),Re=y.useCallback((oe,fe,Je)=>{if(!i){h==null||h(oe),o&&ke(oe);return}const Ke=oe.uid;if(Je.shiftKey&&F!==null){const Ye=Math.min(F,fe),pt=Math.max(F,fe),X=T.slice(Ye,pt+1).map(ue=>ue.uid),P=new Set(X);D(P),p==null||p(Array.from(P))}else if(Je.ctrlKey||Je.metaKey)D(Ye=>{const pt=new Set(Ye);return pt.has(Ke)?pt.delete(Ke):pt.add(Ke),p==null||p(Array.from(pt)),pt}),I(fe);else{const Ye=new Set([Ke]);D(Ye),I(fe),p==null||p(Array.from(Ye))}},[i,F,T,w,h,p,o]),Ce=y.useCallback(async()=>{if(!Te||w.size===0)return;const oe=s||"INBOX";try{const fe=await Te.trashEmails(t,Array.from(w),oe);if(console.log("Trash result:",fe),fe.success&&fe.moved>0){B(Ke=>Ke.filter(Ye=>!w.has(Ye.uid)));const Je=Array.from(w);D(new Set),g==null||g(Je)}else R("Failed to move emails to trash")}catch(fe){const Je=fe instanceof Error?fe:new Error("Trash failed");console.error("Trash error:",Je),R(Je.message),m==null||m(Je)}},[Te,t,w,s,g,m]),Ee=y.useCallback(async()=>{if(!Te||w.size===0)return;const oe=s||"INBOX";try{const fe=await Te.archiveEmails(t,Array.from(w),oe);if(console.log("Archive result:",fe),fe.success&&fe.archived>0){B(Ke=>Ke.filter(Ye=>!w.has(Ye.uid)));const Je=Array.from(w);D(new Set),g==null||g(Je)}else R("Failed to archive emails")}catch(fe){const Je=fe instanceof Error?fe:new Error("Archive failed");console.error("Archive error:",Je),R(Je.message),m==null||m(Je)}},[Te,t,w,s,g,m]),Se=y.useCallback(()=>{if(w.size===T.length)D(new Set),p==null||p([]);else{const oe=new Set(T.map(fe=>fe.uid));D(oe),p==null||p(Array.from(oe))}},[T,w.size,p]),Fe=y.useCallback(()=>{D(new Set),p==null||p([])},[p]),ze={delete:Ce,archive:Ee,refresh:$,selectAll:Se,clearSelection:Fe},ge=oe=>{if(!oe)return"";const fe=new Date(oe),Je=new Date;return fe.toDateString()===Je.toDateString()?fe.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):fe.toLocaleDateString([],{month:"short",day:"numeric"})},L=(oe,fe)=>f.jsx("div",{style:{padding:"12px 16px",background:fe?v.selectedBackground:oe.seen?v.cardBackground:v.unreadBackground,borderBottom:`1px solid ${v.border}`,cursor:"pointer",transition:"background 0.15s ease"},children:f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"12px"},children:[f.jsxs("div",{style:{flex:1,minWidth:0},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:oe.seen?400:600,color:v.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(oe.from).split("@")[0]}),f.jsx("div",{style:{fontSize:"14px",fontWeight:oe.seen?400:500,color:oe.seen?v.textSecondary:v.text,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(oe.subject)||"(No subject)"})]}),f.jsx("div",{style:{fontSize:"12px",color:v.textSecondary,flexShrink:0},children:ge(oe.date)})]})}),Me=oe=>f.jsxs("div",{style:{padding:"24px"},children:[f.jsx("h2",{style:{margin:"0 0 8px",fontSize:"20px",color:v.text},children:$r(oe.subject)||"(No subject)"}),f.jsxs("div",{style:{fontSize:"14px",color:v.textSecondary,marginBottom:"16px"},children:["From: ",$r(oe.from)," • ",new Date(oe.date).toLocaleString()]}),V?f.jsx("div",{style:{fontSize:"14px",color:v.textSecondary},children:"Loading..."}):te?f.jsx("div",{style:{fontSize:"14px",color:v.text},dangerouslySetInnerHTML:{__html:te}}):f.jsx("div",{style:{fontSize:"14px",color:v.textSecondary},children:"No content available"})]}),Qe=(oe,fe)=>f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",background:v.cardBackground,borderBottom:`1px solid ${v.border}`},children:[f.jsx("button",{onClick:fe.selectAll,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",fontSize:"13px",cursor:"pointer",color:v.text},children:oe.length===T.length?"Deselect All":"Select All"}),oe.length>0&&f.jsxs(f.Fragment,{children:[f.jsxs("span",{style:{fontSize:"13px",color:v.textSecondary},children:[oe.length," selected"]}),f.jsx("button",{onClick:fe.archive,title:"Archive",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",cursor:"pointer",color:v.textSecondary},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"archive"})}),f.jsx("button",{onClick:fe.delete,title:"Delete",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",cursor:"pointer",color:v.textSecondary},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"delete"})})]}),f.jsx("div",{style:{flex:1}}),f.jsx("button",{onClick:fe.refresh,title:"Refresh",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",cursor:"pointer",color:v.textSecondary},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"refresh"})})]}),G=()=>f.jsx("div",{style:{padding:"48px",textAlign:"center",color:v.textSecondary},children:c}),ee=()=>f.jsx("div",{style:{padding:"48px",textAlign:"center",color:v.textSecondary},children:"Loading..."}),me=_||L,_e=b||Me,Be=C||Qe,Xe=S||G,bt=k||ee;return j&&T.length===0?f.jsx("div",{style:{background:v.background,width:"100%",height:"100%"},children:bt()}):f.jsxs("div",{style:{display:"flex",background:v.background,width:"100%",height:"100%"},children:[f.jsxs("div",{style:{flex:o&&U?"0 0 50%":"1",display:"flex",flexDirection:"column",borderRight:o&&U?`1px solid ${v.border}`:"none",overflow:"hidden"},children:[i&&Be(Array.from(w),ze),l&&f.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${v.border}`,background:v.background},children:f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 12px",background:"#f5f5f5",borderRadius:"6px"},children:[f.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:v.textSecondary,strokeWidth:"2",children:[f.jsx("circle",{cx:"11",cy:"11",r:"8"}),f.jsx("path",{d:"M21 21l-4.35-4.35"})]}),f.jsx("input",{type:"text",placeholder:"Search by email or subject...",value:le,onChange:oe=>pe(oe.target.value),style:{flex:1,border:"none",background:"transparent",outline:"none",fontSize:"13px",color:v.text}}),le&&f.jsx("button",{onClick:()=>pe(""),style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",justifyContent:"center"},children:f.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:v.textSecondary,strokeWidth:"2",children:f.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]})}),M&&f.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",color:v.danger,fontSize:"14px",borderBottom:`1px solid ${v.border}`},children:M}),f.jsx("div",{style:{flex:1,overflowY:"auto"},children:be.length===0?Xe():be.map((oe,fe)=>f.jsx("div",{onClick:Je=>Re(oe,fe,Je),onDoubleClick:()=>se(oe),children:me(oe,w.has(oe.uid))},oe.uid))})]}),o&&U&&f.jsx("div",{style:{flex:1,overflowY:"auto"},children:_e(U)})]})}function Af({items:r,renderItem:e,onSelectionChange:t,onCurrentChange:n,onAction:s,actions:i=[],emptyMessage:o="No items",showSelectAll:l=!0,className:a=""}){const[u,c]=y.useState(new Set),[d,h]=y.useState(-1),p=r.filter(S=>u.has(S.id)),g=d>=0&&d<p.length?p[d]:null,m=y.useCallback(S=>{c(k=>{const E=new Set(k);return E.has(S)?E.delete(S):E.add(S),t==null||t(Array.from(E)),E})},[t]),x=y.useCallback(()=>{if(u.size===r.length)c(new Set),h(-1),t==null||t([]);else{const S=new Set(r.map(k=>k.id));c(S),r.length>0&&(h(0),n==null||n(r[0],0)),t==null||t(r.map(k=>k.id))}},[r,u.size,t,n]),_=y.useCallback(()=>{if(p.length===0)return;const S=d<=0?p.length-1:d-1;h(S),n==null||n(p[S],S)},[p,d,n]),b=y.useCallback(()=>{if(p.length===0)return;const S=d>=p.length-1?0:d+1;h(S),n==null||n(p[S],S)},[p,d,n]),C=y.useCallback(S=>{s==null||s(S,p,g)},[s,p,g]);return y.useEffect(()=>{p.length===0?h(-1):d>=p.length?h(p.length-1):d<0&&p.length>0&&(h(0),n==null||n(p[0],0))},[p.length,d,n]),r.length===0?f.jsx("div",{className:`text-sm text-neutral-400 text-center py-4 ${a}`,children:o}):f.jsxs("div",{className:`space-y-2 ${a}`,children:[f.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[l&&f.jsxs("button",{onClick:x,className:"flex items-center gap-1 hover:text-neutral-700 transition-colors",children:[f.jsx("span",{className:"material-icons text-sm",children:u.size===r.length?"check_box":u.size>0?"indeterminate_check_box":"check_box_outline_blank"}),f.jsx("span",{children:u.size===r.length?"Deselect all":"Select all"})]}),u.size>0&&f.jsxs("span",{className:"text-neutral-400",children:["(",u.size," selected)"]})]}),p.length>1&&f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("button",{onClick:_,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Previous",children:f.jsx("span",{className:"material-icons text-sm",children:"chevron_left"})}),f.jsxs("span",{className:"text-xs min-w-[3rem] text-center",children:[d+1," / ",p.length]}),f.jsx("button",{onClick:b,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Next",children:f.jsx("span",{className:"material-icons text-sm",children:"chevron_right"})})]})]}),f.jsx("div",{className:"space-y-1",children:r.map(S=>{const k=u.has(S.id),E=(g==null?void 0:g.id)===S.id;return f.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg cursor-pointer transition-colors ${E?"bg-blue-50 ring-1 ring-blue-200":k?"bg-neutral-100":"hover:bg-neutral-50"}`,onClick:()=>m(S.id),children:[f.jsx("span",{className:`material-icons text-lg ${k?"text-blue-500":"text-neutral-300"}`,children:k?"check_box":"check_box_outline_blank"}),f.jsx("div",{className:"flex-1 min-w-0",children:e(S,k,E)})]},S.id)})}),i.length>0&&u.size>0&&f.jsx("div",{className:"flex items-center gap-2 pt-2 border-t border-neutral-100",children:i.map(S=>{var E;const k=((E=S.disabled)==null?void 0:E.call(S,p))??!1;return f.jsxs("button",{onClick:()=>C(S.id),disabled:k,className:`flex items-center gap-1 px-3 py-1.5 text-xs rounded-lg transition-colors ${k?"bg-neutral-100 text-neutral-400 cursor-not-allowed":"bg-neutral-100 hover:bg-neutral-200 text-neutral-700"}`,children:[S.icon&&f.jsx("span",{className:"material-icons text-sm",children:S.icon}),S.label]},S.id)})})]})}function Tf(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Nf=Tf(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 pu=y.createContext(null);function Bf(r,e){return{getTheme:function(){return e??null}}}function $t(){const r=y.useContext(pu);return r==null&&Nf(8),r}function Hn(r){return{}}const Bo={},jf={},gu={},Er={},Kr={},Rn={},Yr={},si={},Ki={},Fn={},Ln={},zt={},jo={},Mo={},Mf={},mu={},Rf={},yu={},Ff={},xu={},bu={},Ns={},Lf={},vu={},_u={},wu={},Pf={},If={},zf={},Da={},Cu={},Of={},Su={},ku={},$f={},ii={},Ro={},Yi={},qf={},Uf={},as={},ls={},Wf={},Hf={},Vf={},qt=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Gf=qt&&"documentMode"in document?document.documentMode:null,Rt=qt&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),mr=qt&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Bs=!(!qt||!("InputEvent"in window)||Gf)&&"getTargetRanges"in new window.InputEvent("input"),oi=qt&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Vn=qt&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Kf=qt&&/Android/.test(navigator.userAgent),Eu=qt&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Yf=qt&&Kf&&Eu,Fo=qt&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Eu,Gn=1,xr=3,Nr=0,Du=1,Zr=2,Qf=0,Jf=1,Xf=2,js=4,Ms=8,Lo=128,Zf=112|(3|js|Ms)|Lo,Po=1,Io=2,zo=3,Oo=4,$o=5,qo=6,ai=oi||Vn||Fo?" ":"​",sr=`
83
+ `,children:[l&&f.jsx("div",{className:"flex-shrink-0",children:f.jsx("img",{src:l,alt:o,className:"w-16 h-16 object-cover rounded-lg"})}),f.jsxs("div",{className:"flex-1 min-w-0",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[f.jsx("h3",{className:"font-medium text-gray-900 truncate",children:o}),u&&f.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-blue-100 text-blue-800 rounded-full",children:u})]}),a&&f.jsx("p",{className:"text-sm text-gray-600 truncate mt-0.5",children:a})]}),e&&f.jsx("div",{className:"flex-shrink-0 text-gray-400",children:f.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})}function Cf({item:r,onClose:e,title:t=i=>i.title||i.name||i.label||"Detail",image:n=i=>i.image||i.thumbnail||i.photo,fields:s=[]}){if(!r)return null;const i=t(r),o=n(r);return f.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:f.jsxs("div",{className:"bg-white rounded-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto shadow-2xl",children:[f.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between",children:[f.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:i}),e&&f.jsx("button",{onClick:e,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:f.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:f.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),f.jsxs("div",{className:"p-6",children:[o&&f.jsx("div",{className:"mb-6",children:f.jsx("img",{src:o,alt:i,className:"w-full h-64 object-cover rounded-lg"})}),s.length>0&&f.jsx("div",{className:"space-y-4",children:s.map((a,l)=>{const u=a.value(r);return u==null||u===""?null:f.jsxs("div",{children:[f.jsx("div",{className:"text-sm font-medium text-gray-500 mb-1",children:a.label}),f.jsx("div",{className:"text-base text-gray-900",children:typeof u=="object"?JSON.stringify(u,null,2):String(u)})]},l)})}),s.length===0&&f.jsx("pre",{className:"bg-gray-50 p-4 rounded-lg text-sm overflow-x-auto",children:JSON.stringify(r,null,2)})]}),e&&f.jsx("div",{className:"sticky bottom-0 bg-gray-50 border-t border-gray-200 px-6 py-4",children:f.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 Ea={small:{base:96,sm:112,md:128},medium:{base:128,sm:160,md:192},large:{base:160,sm:224,md:256,lg:288}};function Sf(r){const e=[...r];for(let t=e.length-1;t>0;t--){const n=Math.floor(Math.random()*(t+1));[e[t],e[n]]=[e[n],e[t]]}return e}function kf({nodes:r,minInterval:e=3e3,maxInterval:t=6e3,onCardClick:n,cardSize:s="medium",aspectRatio:i="1:1",className:o=""}){var j,N;const[a]=y.useState(()=>{if(r.length===0)return[[],[]];const R=Sf(r),M=Math.ceil(R.length/2);return console.log("[AnimatedCardFlip] Pools:",{left:R.slice(0,M).map(w=>w.title),right:R.slice(M).map(w=>w.title)}),[R.slice(0,M),R.slice(M)]}),[l,u]=y.useState(()=>{const R=Ea[s];if(typeof window>"u")return R.base;const M=window.innerWidth;return"lg"in R&&M>=1024?R.lg:M>=768?R.md:M>=640?R.sm:R.base});y.useEffect(()=>{const R=()=>{const M=Ea[s],w=window.innerWidth;"lg"in M&&w>=1024?u(M.lg):w>=768?u(M.md):w>=640?u(M.sm):u(M.base)};return window.addEventListener("resize",R),R(),()=>window.removeEventListener("resize",R)},[s]);const[c,d]=y.useState(0),[h,p]=y.useState(0),[g,m]=y.useState(!1),[x,_]=y.useState(!1),[b,S]=y.useState(!1),[C,k]=y.useState(!1);y.useEffect(()=>{if(a[0].length<=1)return;const R=setInterval(()=>{m(M=>!M),setTimeout(()=>{d(M=>(M+1)%a[0].length),S(M=>!M)},250)},e+Math.random()*(t-e));return()=>clearInterval(R)},[a,e,t]),y.useEffect(()=>{if(a[1].length<=1)return;let R=null;const M=setTimeout(()=>{R=setInterval(()=>{_(w=>!w),setTimeout(()=>{p(w=>(w+1)%a[1].length),k(w=>!w)},250)},e+Math.random()*(t-e))},500);return()=>{clearTimeout(M),R&&clearInterval(R)}},[a,e,t]);const E=(j=a[0])==null?void 0:j[c],v=(N=a[1])==null?void 0:N[h];if(r.length===0||!E)return f.jsx("div",{className:`flex items-center justify-center p-8 ${o}`,children:f.jsx("p",{className:"text-gray-500",children:"No images available"})});const T=i==="2:3"?l*1.5:l,B=(R,M,w)=>f.jsx("div",{className:"relative",style:{width:l,height:T,perspective:"1000px"},onClick:()=>n==null?void 0:n(R),children:f.jsx("div",{className:"w-full h-full rounded-lg shadow-lg overflow-hidden cursor-pointer hover:shadow-xl",style:{transform:`rotateY(${M?180:0}deg)`,transition:"transform 0.5s ease-in-out",transformStyle:"preserve-3d"},children:f.jsxs("div",{className:"w-full h-full",style:{transform:w?"scaleX(-1)":"none"},children:[f.jsx("img",{src:R.data.image,alt:R.title,className:"w-full h-full object-cover"}),f.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:f.jsx("p",{className:"text-white text-sm font-medium truncate",children:R.title})})]})})});return f.jsxs("div",{className:`flex gap-4 justify-center items-center ${o}`,children:[B(E,g,b),v&&B(v,x,C)]})}function $r(r){if(!r)return"";const e=/=\?([^?]+)\?([BQbq])\?([^?]*)\?=/g;return r.replace(e,(t,n,s,i)=>{try{if(s.toUpperCase()==="B"){const o=atob(i);return decodeURIComponent(escape(o))}else if(s.toUpperCase()==="Q"){const o=i.replace(/_/g," ").replace(/=([0-9A-Fa-f]{2})/g,(a,l)=>String.fromCharCode(parseInt(l,16)));return decodeURIComponent(escape(o))}}catch(o){console.warn("MIME decode error:",o)}return t}).replace(/\s+/g," ").trim()}const Ef={background:"#ffffff",cardBackground:"#ffffff",selectedBackground:"#f5f5f5",unreadBackground:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",danger:"#ef4444"};function Df({baseUrl:r,systemId:e,accountId:t,limit:n=30,folder:s,selectable:i=!0,showDetail:o=!1,showSearch:a=!0,searchQuery:l,onSearchChange:u,emptyMessage:c="No emails",autoLoad:d=!0,onSelect:h,onSelectionChange:p,onDelete:g,onError:m,onLoad:x,renderItem:_,renderDetail:b,renderActions:S,renderEmpty:C,renderLoading:k,theme:E={}}){const v={...Ef,...E},[T,B]=y.useState([]),[j,N]=y.useState(!1),[R,M]=y.useState(null),[w,D]=y.useState(new Set),[F,z]=y.useState(null),[q,J]=y.useState(null),[te,W]=y.useState(null),[G,H]=y.useState(!1),[se,le]=y.useState(""),ue=l!==void 0?l:se,_e=oe=>{u?u(oe):le(oe)},fe=y.useMemo(()=>{if(!ue.trim())return T;const oe=ue.toLowerCase();return T.filter(pe=>$r(pe.from).toLowerCase().includes(oe)||$r(pe.subject).toLowerCase().includes(oe))},[T,ue]),De=y.useMemo(()=>e?new iu({baseUrl:r,system_id:e}):null,[r,e]),O=y.useCallback(async()=>{if(De){N(!0),M(null);try{const oe=await De.listEmails(t,n,s);oe!=null&&oe.messages&&(B(oe.messages),x==null||x(oe.messages))}catch(oe){const pe=oe instanceof Error?oe:new Error("Failed to fetch emails");M(pe.message),m==null||m(pe)}N(!1)}},[De,t,n,s,m,x]);y.useEffect(()=>{B([]),D(new Set),J(null),M(null),l===void 0&&le(""),d&&O()},[s,d]);const Ce=y.useCallback(async oe=>{if(De){J(oe),W(null),H(!0);try{const pe=await De.getEmailParsed(t,oe.uid,s||"INBOX");pe!=null&&pe.body&&W(pe.body)}catch(pe){console.error("Failed to fetch email body:",pe)}H(!1)}},[De,t,s]),re=y.useCallback(oe=>{h==null||h(oe),o&&Ce(oe)},[h,o,Ce]),Fe=y.useCallback((oe,pe,Ye)=>{if(!i){h==null||h(oe),o&&Ce(oe);return}const at=oe.uid;if(Ye.shiftKey&&F!==null){const Ve=Math.min(F,pe),Xe=Math.max(F,pe),br=T.slice(Ve,Xe+1).map(I=>I.uid),Q=new Set(br);D(Q),p==null||p(Array.from(Q))}else if(Ye.ctrlKey||Ye.metaKey)D(Ve=>{const Xe=new Set(Ve);return Xe.has(at)?Xe.delete(at):Xe.add(at),p==null||p(Array.from(Xe)),Xe}),z(pe);else{const Ve=new Set([at]);D(Ve),z(pe),p==null||p(Array.from(Ve))}},[i,F,T,w,h,p,o]),je=y.useCallback(async()=>{if(!De||w.size===0)return;const oe=s||"INBOX";try{const pe=await De.trashEmails(t,Array.from(w),oe);if(console.log("Trash result:",pe),pe.success&&pe.moved>0){B(at=>at.filter(Ve=>!w.has(Ve.uid)));const Ye=Array.from(w);D(new Set),g==null||g(Ye)}else M("Failed to move emails to trash")}catch(pe){const Ye=pe instanceof Error?pe:new Error("Trash failed");console.error("Trash error:",Ye),M(Ye.message),m==null||m(Ye)}},[De,t,w,s,g,m]),ye=y.useCallback(async()=>{if(!De||w.size===0)return;const oe=s||"INBOX";try{const pe=await De.archiveEmails(t,Array.from(w),oe);if(console.log("Archive result:",pe),pe.success&&pe.archived>0){B(at=>at.filter(Ve=>!w.has(Ve.uid)));const Ye=Array.from(w);D(new Set),g==null||g(Ye)}else M("Failed to archive emails")}catch(pe){const Ye=pe instanceof Error?pe:new Error("Archive failed");console.error("Archive error:",Ye),M(Ye.message),m==null||m(Ye)}},[De,t,w,s,g,m]),Se=y.useCallback(()=>{if(w.size===T.length)D(new Set),p==null||p([]);else{const oe=new Set(T.map(pe=>pe.uid));D(oe),p==null||p(Array.from(oe))}},[T,w.size,p]),Me=y.useCallback(()=>{D(new Set),p==null||p([])},[p]),Oe={delete:je,archive:ye,refresh:O,selectAll:Se,clearSelection:Me},ge=oe=>{if(!oe)return"";const pe=new Date(oe),Ye=new Date;return pe.toDateString()===Ye.toDateString()?pe.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):pe.toLocaleDateString([],{month:"short",day:"numeric"})},L=(oe,pe)=>f.jsx("div",{style:{padding:"12px 16px",background:pe?v.selectedBackground:oe.seen?v.cardBackground:v.unreadBackground,borderBottom:`1px solid ${v.border}`,cursor:"pointer",transition:"background 0.15s ease"},children:f.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"12px"},children:[f.jsxs("div",{style:{flex:1,minWidth:0},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:oe.seen?400:600,color:v.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(oe.from).split("@")[0]}),f.jsx("div",{style:{fontSize:"14px",fontWeight:oe.seen?400:500,color:oe.seen?v.textSecondary:v.text,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(oe.subject)||"(No subject)"})]}),f.jsx("div",{style:{fontSize:"12px",color:v.textSecondary,flexShrink:0},children:ge(oe.date)})]})}),ze=oe=>f.jsxs("div",{style:{padding:"24px"},children:[f.jsx("h2",{style:{margin:"0 0 8px",fontSize:"20px",color:v.text},children:$r(oe.subject)||"(No subject)"}),f.jsxs("div",{style:{fontSize:"14px",color:v.textSecondary,marginBottom:"16px"},children:["From: ",$r(oe.from)," • ",new Date(oe.date).toLocaleString()]}),G?f.jsx("div",{style:{fontSize:"14px",color:v.textSecondary},children:"Loading..."}):te?f.jsx("div",{style:{fontSize:"14px",color:v.text},dangerouslySetInnerHTML:{__html:te}}):f.jsx("div",{style:{fontSize:"14px",color:v.textSecondary},children:"No content available"})]}),Ke=(oe,pe)=>f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",background:v.cardBackground,borderBottom:`1px solid ${v.border}`},children:[f.jsx("button",{onClick:pe.selectAll,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",fontSize:"13px",cursor:"pointer",color:v.text},children:oe.length===T.length?"Deselect All":"Select All"}),oe.length>0&&f.jsxs(f.Fragment,{children:[f.jsxs("span",{style:{fontSize:"13px",color:v.textSecondary},children:[oe.length," selected"]}),f.jsx("button",{onClick:pe.archive,title:"Archive",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",cursor:"pointer",color:v.textSecondary},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"archive"})}),f.jsx("button",{onClick:pe.delete,title:"Delete",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",cursor:"pointer",color:v.textSecondary},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"delete"})})]}),f.jsx("div",{style:{flex:1}}),f.jsx("button",{onClick:pe.refresh,title:"Refresh",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",cursor:"pointer",color:v.textSecondary},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"refresh"})})]}),X=()=>f.jsx("div",{style:{padding:"48px",textAlign:"center",color:v.textSecondary},children:c}),Z=()=>f.jsx("div",{style:{padding:"48px",textAlign:"center",color:v.textSecondary},children:"Loading..."}),ce=_||L,we=b||ze,Be=S||Ke,Qe=C||X,Et=k||Z;return j&&T.length===0?f.jsx("div",{style:{background:v.background,width:"100%",height:"100%"},children:Et()}):f.jsxs("div",{style:{display:"flex",background:v.background,width:"100%",height:"100%"},children:[f.jsxs("div",{style:{flex:o&&q?"0 0 50%":"1",display:"flex",flexDirection:"column",borderRight:o&&q?`1px solid ${v.border}`:"none",overflow:"hidden"},children:[i&&Be(Array.from(w),Oe),a&&f.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${v.border}`,background:v.background},children:f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 12px",background:"#f5f5f5",borderRadius:"6px"},children:[f.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:v.textSecondary,strokeWidth:"2",children:[f.jsx("circle",{cx:"11",cy:"11",r:"8"}),f.jsx("path",{d:"M21 21l-4.35-4.35"})]}),f.jsx("input",{type:"text",placeholder:"Search by email or subject...",value:ue,onChange:oe=>_e(oe.target.value),style:{flex:1,border:"none",background:"transparent",outline:"none",fontSize:"13px",color:v.text}}),ue&&f.jsx("button",{onClick:()=>_e(""),style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",justifyContent:"center"},children:f.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:v.textSecondary,strokeWidth:"2",children:f.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]})}),R&&f.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",color:v.danger,fontSize:"14px",borderBottom:`1px solid ${v.border}`},children:R}),f.jsx("div",{style:{flex:1,overflowY:"auto"},children:fe.length===0?Qe():fe.map((oe,pe)=>f.jsx("div",{onClick:Ye=>Fe(oe,pe,Ye),onDoubleClick:()=>re(oe),children:ce(oe,w.has(oe.uid))},oe.uid))})]}),o&&q&&f.jsx("div",{style:{flex:1,overflowY:"auto"},children:we(q)})]})}function Af({items:r,renderItem:e,onSelectionChange:t,onCurrentChange:n,onAction:s,actions:i=[],emptyMessage:o="No items",showSelectAll:a=!0,className:l=""}){const[u,c]=y.useState(new Set),[d,h]=y.useState(-1),p=r.filter(C=>u.has(C.id)),g=d>=0&&d<p.length?p[d]:null,m=y.useCallback(C=>{c(k=>{const E=new Set(k);return E.has(C)?E.delete(C):E.add(C),t==null||t(Array.from(E)),E})},[t]),x=y.useCallback(()=>{if(u.size===r.length)c(new Set),h(-1),t==null||t([]);else{const C=new Set(r.map(k=>k.id));c(C),r.length>0&&(h(0),n==null||n(r[0],0)),t==null||t(r.map(k=>k.id))}},[r,u.size,t,n]),_=y.useCallback(()=>{if(p.length===0)return;const C=d<=0?p.length-1:d-1;h(C),n==null||n(p[C],C)},[p,d,n]),b=y.useCallback(()=>{if(p.length===0)return;const C=d>=p.length-1?0:d+1;h(C),n==null||n(p[C],C)},[p,d,n]),S=y.useCallback(C=>{s==null||s(C,p,g)},[s,p,g]);return y.useEffect(()=>{p.length===0?h(-1):d>=p.length?h(p.length-1):d<0&&p.length>0&&(h(0),n==null||n(p[0],0))},[p.length,d,n]),r.length===0?f.jsx("div",{className:`text-sm text-neutral-400 text-center py-4 ${l}`,children:o}):f.jsxs("div",{className:`space-y-2 ${l}`,children:[f.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[a&&f.jsxs("button",{onClick:x,className:"flex items-center gap-1 hover:text-neutral-700 transition-colors",children:[f.jsx("span",{className:"material-icons text-sm",children:u.size===r.length?"check_box":u.size>0?"indeterminate_check_box":"check_box_outline_blank"}),f.jsx("span",{children:u.size===r.length?"Deselect all":"Select all"})]}),u.size>0&&f.jsxs("span",{className:"text-neutral-400",children:["(",u.size," selected)"]})]}),p.length>1&&f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("button",{onClick:_,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Previous",children:f.jsx("span",{className:"material-icons text-sm",children:"chevron_left"})}),f.jsxs("span",{className:"text-xs min-w-[3rem] text-center",children:[d+1," / ",p.length]}),f.jsx("button",{onClick:b,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Next",children:f.jsx("span",{className:"material-icons text-sm",children:"chevron_right"})})]})]}),f.jsx("div",{className:"space-y-1",children:r.map(C=>{const k=u.has(C.id),E=(g==null?void 0:g.id)===C.id;return f.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg cursor-pointer transition-colors ${E?"bg-blue-50 ring-1 ring-blue-200":k?"bg-neutral-100":"hover:bg-neutral-50"}`,onClick:()=>m(C.id),children:[f.jsx("span",{className:`material-icons text-lg ${k?"text-blue-500":"text-neutral-300"}`,children:k?"check_box":"check_box_outline_blank"}),f.jsx("div",{className:"flex-1 min-w-0",children:e(C,k,E)})]},C.id)})}),i.length>0&&u.size>0&&f.jsx("div",{className:"flex items-center gap-2 pt-2 border-t border-neutral-100",children:i.map(C=>{var E;const k=((E=C.disabled)==null?void 0:E.call(C,p))??!1;return f.jsxs("button",{onClick:()=>S(C.id),disabled:k,className:`flex items-center gap-1 px-3 py-1.5 text-xs rounded-lg transition-colors ${k?"bg-neutral-100 text-neutral-400 cursor-not-allowed":"bg-neutral-100 hover:bg-neutral-200 text-neutral-700"}`,children:[C.icon&&f.jsx("span",{className:"material-icons text-sm",children:C.icon}),C.label]},C.id)})})]})}function Tf(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Nf=Tf(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 pu=y.createContext(null);function Bf(r,e){return{getTheme:function(){return e??null}}}function zt(){const r=y.useContext(pu);return r==null&&Nf(8),r}function Hn(r){return{}}const Bo={},jf={},gu={},Er={},Kr={},Rn={},Yr={},si={},Ki={},Fn={},Ln={},Pt={},jo={},Mo={},Mf={},mu={},Rf={},yu={},Ff={},xu={},bu={},Ns={},Lf={},vu={},_u={},wu={},Pf={},If={},zf={},Da={},Cu={},Of={},Su={},ku={},$f={},ii={},Ro={},Yi={},qf={},Uf={},as={},ls={},Wf={},Hf={},Vf={},Ot=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Gf=Ot&&"documentMode"in document?document.documentMode:null,jt=Ot&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),gr=Ot&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Bs=!(!Ot||!("InputEvent"in window)||Gf)&&"getTargetRanges"in new window.InputEvent("input"),oi=Ot&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Vn=Ot&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Kf=Ot&&/Android/.test(navigator.userAgent),Eu=Ot&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Yf=Ot&&Kf&&Eu,Fo=Ot&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Eu,Gn=1,yr=3,Nr=0,Du=1,Zr=2,Qf=0,Jf=1,Xf=2,js=4,Ms=8,Lo=128,Zf=112|(3|js|Ms)|Lo,Po=1,Io=2,zo=3,Oo=4,$o=5,qo=6,ai=oi||Vn||Fo?" ":"​",nr=`
84
84
 
85
- `,eh=mr?" ":ai,Au="֑-߿יִ-﷽ﹰ-ﻼ",Tu="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",th=new RegExp("^[^"+Tu+"]*["+Au+"]"),rh=new RegExp("^[^"+Au+"]*["+Tu+"]"),Br={bold:1,code:16,highlight:Lo,italic:2,strikethrough:js,subscript:32,superscript:64,underline:Ms},nh={directionless:1,unmergeable:2},Aa={center:Io,end:qo,justify:Oo,left:Po,right:zo,start:$o},sh={[Io]:"center",[qo]:"end",[Oo]:"justify",[Po]:"left",[zo]:"right",[$o]:"start"},ih={normal:0,segmented:2,token:1},oh={[Qf]:"normal",[Xf]:"segmented",[Jf]:"token"};function ah(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Q=ah(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 Rs(...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 lh=100;let Qi=!1,Uo=0;function uh(r){Uo=r.timeStamp}function Bi(r,e,t){const n=r.nodeName==="BR",s=e.__lexicalLineBreak;return s&&(r===s||n&&r.previousSibling===s)||n&&ui(r,t)!==void 0}function ch(r,e,t){const n=Bt(t._window);let s=null,i=null;n!==null&&n.anchorNode===r&&(s=n.anchorOffset,i=n.focusOffset);const o=r.nodeValue;o!==null&&Ko(e,o,s,i,!1)}function dh(r,e,t){if(K(r)){const n=r.anchor.getNode();if(n.is(t)&&r.format!==n.getFormat())return!1}return e.nodeType===xr&&t.isAttached()}function fh(r,e,t,n){for(let s=r;s&&!kh(s);s=Yn(s)){const i=ui(s,e);if(i!==void 0){const o=ht(i,t);if(o)return Ge(o)?void 0:[s,o]}else if(s===n)return[n,Iu(t)]}}function Nu(r,e,t){Qi=!0;const n=performance.now()-Uo>lh;try{Dt(r,()=>{const s=ae()||function(h){return h.getEditorState().read(()=>{const p=ae();return p!==null?p.clone():null})}(r),i=new Map,o=r.getRootElement(),l=r._editorState,a=r._blockCursorElement;let u=!1,c="";for(let h=0;h<e.length;h++){const p=e[h],g=p.type,m=p.target,x=fh(m,r,l,o);if(!x)continue;const[_,b]=x;if(g==="characterData")n&&Z(b)&&dh(s,m,b)&&ch(m,b,r);else if(g==="childList"){u=!0;const C=p.addedNodes;for(let E=0;E<C.length;E++){const v=C[E],T=Lu(v),B=v.parentNode;if(B!=null&&v!==a&&T===null&&!Bi(v,B,r)){if(mr){const j=v.innerText||v.nodeValue;j&&(c+=j)}B.removeChild(v)}}const S=p.removedNodes,k=S.length;if(k>0){let E=0;for(let v=0;v<k;v++){const T=S[v];(Bi(T,m,r)||a===T)&&(m.appendChild(T),E++)}k!==E&&i.set(_,b)}}}if(i.size>0)for(const[h,p]of i)p.reconcileObservedMutation(h,r);const d=t.takeRecords();if(d.length>0){for(let h=0;h<d.length;h++){const p=d[h],g=p.addedNodes,m=p.target;for(let x=0;x<g.length;x++){const _=g[x],b=_.parentNode;b==null||_.nodeName!=="BR"||Bi(_,m,r)||b.removeChild(_)}}t.takeRecords()}s!==null&&(u&&(s.dirty=!0,Yt(s)),mr&&qu(r)&&s.insertRawText(c))})}finally{Qi=!1}}function Bu(r){const e=r._observer;e!==null&&Nu(r,e.takeRecords(),e)}function ju(r){(function(e){Uo===0&&di(e).addEventListener("textInput",uh,!0)})(r),r._observer=new MutationObserver((e,t)=>{Nu(r,e,t)})}function Ta(r,e){const t=r.__mode,n=r.__format,s=r.__style,i=e.__mode,o=e.__format,l=e.__style;return!(t!==null&&t!==i||n!==null&&n!==o||s!==null&&s!==l)}function Na(r,e){const t=r.mergeWithSibling(e),n=nt()._normalizedNodes;return n.add(r.__key),n.add(e.__key),t}function Ba(r){let e,t,n=r;if(n.__text!==""||!n.isSimpleText()||n.isUnmergeable()){for(;(e=n.getPreviousSibling())!==null&&Z(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(e.__text!==""){if(Ta(e,n)){n=Na(e,n);break}break}e.remove()}for(;(t=n.getNextSibling())!==null&&Z(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==""){if(Ta(n,t)){n=Na(n,t);break}break}t.remove()}}else n.remove()}function Mu(r){return ja(r.anchor),ja(r.focus),r}function ja(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),Z(n)){r.set(n.__key,s?n.getTextContentSize():0,"text");break}if(!O(n))break;r.set(n.__key,s?n.getChildrenSize():0,"element")}}let hh=1;const ph=typeof queueMicrotask=="function"?queueMicrotask:r=>{Promise.resolve().then(r)};function Wo(r){const e=document.activeElement;if(e===null)return!1;const t=e.nodeName;return Ge(en(r))&&(t==="INPUT"||t==="TEXTAREA"||e.contentEditable==="true"&&li(e)==null)}function Kn(r,e,t){const n=r.getRootElement();try{return n!==null&&n.contains(e)&&n.contains(t)&&e!==null&&!Wo(e)&&Ru(e)===r}catch{return!1}}function Ho(r){return r instanceof mi}function Ru(r){let e=r;for(;e!=null;){const t=li(e);if(Ho(t))return t;e=Yn(e)}return null}function li(r){return r?r.__lexicalEditor:null}function Cr(r){return r.isToken()||r.isSegmented()}function gh(r){return r.nodeType===xr}function Fs(r){let e=r;for(;e!=null;){if(gh(e))return e;e=e.firstChild}return null}function Ls(r,e,t){const n=Br[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 Fu(r){return Z(r)||Ar(r)||Ge(r)}function mh(r,e){if(e!=null)return void(r.__key=e);Ct(),uc();const t=nt(),n=ar(),s=""+hh++;n._nodeMap.set(s,r),O(r)?t._dirtyElements.set(s,!0):t._dirtyLeaves.add(s),t._cloneNotNeeded.add(s),t._dirtyType=Du,r.__key=s}function Dr(r){const e=r.getParent();if(e!==null){const t=r.getWritable(),n=e.getWritable(),s=r.getPreviousSibling(),i=r.getNextSibling();if(s===null)if(i!==null){const o=i.getWritable();n.__first=i.__key,o.__prev=null}else n.__first=null;else{const o=s.getWritable();if(i!==null){const l=i.getWritable();l.__prev=o.__key,o.__next=l.__key}else o.__next=null;t.__prev=null}if(i===null)if(s!==null){const o=s.getWritable();n.__last=s.__key,o.__next=null}else n.__last=null;else{const o=i.getWritable();if(s!==null){const l=s.getWritable();l.__next=o.__key,o.__prev=l.__key}else o.__prev=null;t.__next=null}n.__size--,t.__parent=null}}function Ps(r){uc();const e=r.getLatest(),t=e.__parent,n=ar(),s=nt(),i=n._nodeMap,o=s._dirtyElements;t!==null&&function(a,u,c){let d=a;for(;d!==null;){if(c.has(d))return;const h=u.get(d);if(h===void 0)break;c.set(d,!1),d=h.__parent}}(t,i,o);const l=e.__key;s._dirtyType=Du,O(r)?o.set(l,!0):s._dirtyLeaves.add(l)}function ft(r){Ct();const e=nt(),t=e._compositionKey;if(r!==t){if(e._compositionKey=r,t!==null){const n=ht(t);n!==null&&n.getWritable()}if(r!==null){const n=ht(r);n!==null&&n.getWritable()}}}function hr(){return es()?null:nt()._compositionKey}function ht(r,e){const t=(e||ar())._nodeMap.get(r);return t===void 0?null:t}function Lu(r,e){const t=ui(r,nt());return t!==void 0?ht(t,e):null}function ui(r,e){return r[`__lexicalKey_${e._key}`]}function en(r,e){let t=r;for(;t!=null;){const n=Lu(t,e);if(n!==null)return n;t=Yn(t)}return null}function Pu(r){const e=r._decorators,t=Object.assign({},e);return r._pendingDecorators=t,t}function Ma(r){return r.read(()=>et().getTextContent())}function et(){return Iu(ar())}function Iu(r){return r._nodeMap.get("root")}function Yt(r){Ct();const e=ar();r!==null&&(r.dirty=!0,r.setCachedNodes(null)),e._selection=r}function Hr(r){const e=nt(),t=function(n,s){let i=n;for(;i!=null;){const o=ui(i,s);if(o!==void 0)return o;i=Yn(i)}return null}(r,e);return t===null?r===e.getRootElement()?ht("root"):null:ht(t)}function Ra(r,e){return e?r.getTextContentSize():0}function zu(r){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(r)}function Vo(r){const e=[];let t=r;for(;t!==null;)e.push(t),t=t._parentEditor;return e}function Ou(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function $u(r){return r.nodeType===xr?r.nodeValue:null}function Go(r,e,t){const n=Bt(e._window);if(n===null)return;const s=n.anchorNode;let{anchorOffset:i,focusOffset:o}=n;if(s!==null){let l=$u(s);const a=en(s);if(l!==null&&Z(a)){if(l===ai&&t){const u=t.length;l=t,i=u,o=u}l!==null&&Ko(a,l,i,o,r)}}}function Ko(r,e,t,n,s){let i=r;if(i.isAttached()&&(s||!i.isDirty())){const o=i.isComposing();let l=e;(o||s)&&e[e.length-1]===ai&&(l=e.slice(0,-1));const a=i.getTextContent();if(s||l!==a){if(l===""){if(ft(null),oi||Vn||Fo)i.remove();else{const m=nt();setTimeout(()=>{m.update(()=>{i.isAttached()&&i.remove()})},20)}return}const u=i.getParent(),c=Zn(),d=i.getTextContentSize(),h=hr(),p=i.getKey();if(i.isToken()||h!==null&&p===h&&!o||K(c)&&(u!==null&&!u.canInsertTextBefore()&&c.anchor.offset===0||c.anchor.key===r.__key&&c.anchor.offset===0&&!i.canInsertTextBefore()&&!o||c.focus.key===r.__key&&c.focus.offset===d&&!i.canInsertTextAfter()&&!o))return void i.markDirty();const g=ae();if(!K(g)||t===null||n===null)return void i.setTextContent(l);if(g.setTextNodeRange(i,t,i,n),i.isSegmented()){const m=lt(i.getTextContent());i.replace(m),i=m}i.setTextContent(l)}}}function yh(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(i){const o=i.getPreviousSibling();return(Z(o)||O(o)&&o.isInline())&&!o.canInsertTextAfter()}(e):t===e.getTextContentSize()&&(!e.canInsertTextAfter()||!n.canInsertTextAfter()&&!e.isComposing()||s)}function Fa(r){return r==="ArrowLeft"}function La(r){return r==="ArrowRight"}function vn(r,e){return Rt?r:e}function Pa(r){return r==="Enter"}function fn(r){return r==="Backspace"}function hn(r){return r==="Delete"}function Ia(r,e,t){return r.toLowerCase()==="a"&&vn(e,t)}function xh(){const r=et();Yt(Mu(r.select(0,r.getChildrenSize())))}function An(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 i=Rs(s);return t[e]=i,i}return s}function Yo(r,e,t,n,s){if(t.size===0)return;const i=n.__type,o=n.__key,l=e.get(i);l===void 0&&Q(33,i);const a=l.klass;let u=r.get(a);u===void 0&&(u=new Map,r.set(a,u));const c=u.get(o),d=c==="destroyed"&&s==="created";(c===void 0||d)&&u.set(o,d?"updated":s)}function za(r,e,t){const n=r.getParent();let s=t,i=r;return n!==null&&(e&&t===0?(s=i.getIndexWithinParent(),i=n):e||t!==i.getChildrenSize()||(s=i.getIndexWithinParent()+1,i=n)),i.getChildAtIndex(e?s-1:s)}function Pn(r,e){const t=r.offset;if(r.type==="element")return za(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?za(n.getParentOrThrow(),e,n.getIndexWithinParent()+(e?0:1)):s}}return null}function qu(r){const e=di(r).event,t=e&&e.inputType;return t==="insertFromPaste"||t==="insertFromPasteAsQuotation"}function ie(r,e,t){return fc(r,e,t)}function ci(r){return!yt(r)&&!r.isLastChild()&&!r.isInline()}function Is(r,e){const t=r._keyToDOMMap.get(e);return t===void 0&&Q(75,e),t}function Yn(r){const e=r.assignedSlot||r.parentElement;return e!==null&&e.nodeType===11?e.host:e}function Tn(r,e){let t=r.getParent();for(;t!==null;){if(t.is(e))return!0;t=t.getParent()}return!1}function di(r){const e=r._window;return e===null&&Q(78),e}function bh(r){let e=r.getParentOrThrow();for(;e!==null;){if(Qt(e))return e;e=e.getParentOrThrow()}return e}function Qt(r){return yt(r)||O(r)&&r.isShadowRoot()}function Xt(r){const e=nt(),t=r.constructor.getType(),n=e._nodes.get(t);n===void 0&&Q(200,r.constructor.name,t);const{replace:s,replaceWithKlass:i}=n;if(s!==null){const o=s(r),l=o.constructor;return i!==null?o instanceof i||Q(201,i.name,i.getType(),l.name,l.getType(),r.constructor.name,t):o instanceof r.constructor&&l!==r.constructor||Q(202,l.name,l.getType(),r.constructor.name,t),o.__key===r.__key&&Q(203,r.constructor.name,t,l.name,l.getType()),o}return r}function ji(r,e){!yt(r.getParent())||O(e)||Ge(e)||Q(99)}function Mi(r){return(Ge(r)||O(r)&&!r.canBeEmpty())&&!r.isInline()}function Qo(r,e,t){t.style.removeProperty("caret-color"),e._blockCursorElement=null;const n=r.parentElement;n!==null&&n.removeChild(r)}function vh(r,e,t){let n=r._blockCursorElement;if(K(t)&&t.isCollapsed()&&t.anchor.type==="element"&&e.contains(document.activeElement)){const s=t.anchor,i=s.getNode(),o=s.offset;let l=!1,a=null;if(o===i.getChildrenSize())Mi(i.getChildAtIndex(o-1))&&(l=!0);else{const u=i.getChildAtIndex(o);if(u!==null&&Mi(u)){const c=u.getPreviousSibling();(c===null||Mi(c))&&(l=!0,a=r.getElementByKey(u.__key))}}if(l){const u=r.getElementByKey(i.__key);return n===null&&(r._blockCursorElement=n=function(c){const d=c.theme,h=document.createElement("div");h.contentEditable="false",h.setAttribute("data-lexical-cursor","true");let p=d.blockCursor;if(p!==void 0){if(typeof p=="string"){const g=Rs(p);p=d.blockCursor=g}p!==void 0&&h.classList.add(...p)}return h}(r._config)),e.style.caretColor="transparent",void(a===null?u.appendChild(n):u.insertBefore(n,a))}}n!==null&&Qo(n,r,e)}function Bt(r){return qt?(r||window).getSelection():null}function _h(r){return or(r)&&r.tagName==="A"}function or(r){return r.nodeType===1}function Oa(r){return r.nodeType===11}function Ji(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 zs(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 cr(r){if(Ge(r)&&!r.isInline())return!0;if(!O(r)||Qt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||Z(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function pn(r,e){let t=r;for(;t!==null&&t.getParent()!==null&&!e(t);)t=t.getParentOrThrow();return e(t)?t:null}function wh(){return nt()}const $a=new WeakMap,Ch=new Map;function Sh(r){if(!r._readOnly&&r.isEmpty())return Ch;r._readOnly||Q(192);let e=$a.get(r);if(!e){e=new Map,$a.set(r,e);for(const[t,n]of r._nodeMap){const s=n.__type;let i=e.get(s);i||(i=new Map,e.set(s,i)),i.set(t,n)}}return e}function Jo(r){const e=r.constructor.clone(r);return e.afterCloneFrom(r),e}function Xo(r,e){const t=(parseInt(r.style.paddingInlineStart,10)||0)/40;e.setIndent(t)}function kh(r){return r.__lexicalUnmanaged===!0}function Uu(r,e,t,n,s,i){let o=r.getFirstChild();for(;o!==null;){const l=o.__key;o.__parent===e&&(O(o)&&Uu(o,l,t,n,s,i),t.has(l)||i.delete(l),s.push(l)),o=o.getNextSibling()}}let yr,xt,In,fi,Xi,Zi,jr,Ot,eo,zn,ut="",mt="",Wt=null,Ft="",rr="",Wu=!1,On=!1,_s=null;function Os(r,e){const t=jr.get(r);if(e!==null){const n=no(r);n.parentNode===e&&e.removeChild(n)}if(Ot.has(r)||xt._keyToDOMMap.delete(r),O(t)){const n=qs(t,jr);to(n,0,n.length-1,null)}t!==void 0&&Yo(zn,In,fi,t,"destroyed")}function to(r,e,t,n){let s=e;for(;s<=t;++s){const i=r[s];i!==void 0&&Os(i,n)}}function _r(r,e){r.setProperty("text-align",e)}const Eh="40px";function Hu(r,e){const t=yr.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")||Eh;r.style.setProperty("padding-inline-start",e===0?"":`calc(${e} * ${n})`)}function Vu(r,e){const t=r.style;e===0?_r(t,""):e===Po?_r(t,"left"):e===Io?_r(t,"center"):e===zo?_r(t,"right"):e===Oo?_r(t,"justify"):e===$o?_r(t,"start"):e===qo&&_r(t,"end")}function $s(r,e){const t=Ot.get(r);t===void 0&&Q(60);const n=t.createDOM(yr,xt);if(function(s,i,o){const l=o._keyToDOMMap;(function(a,u,c){a[`__lexicalKey_${u._key}`]=c})(i,o,s),l.set(s,i)}(r,n,xt),Z(t)?n.setAttribute("data-lexical-text","true"):Ge(t)&&n.setAttribute("data-lexical-decorator","true"),O(t)){const s=t.__indent,i=t.__size;if(s!==0&&Hu(n,s),i!==0){const l=i-1;(function(a,u,c,d){const h=mt;mt="",ro(a,c,0,u,c.getDOMSlot(d)),Ku(c,d),mt=h})(qs(t,Ot),l,t,n)}const o=t.__format;o!==0&&Vu(n,o),t.isInline()||Gu(null,t,n),ci(t)&&(ut+=sr,rr+=sr)}else{const s=t.getTextContent();if(Ge(t)){const i=t.decorate(xt,yr);i!==null&&Yu(r,i),n.contentEditable="false"}else Z(t)&&(t.isDirectionless()||(mt+=s));ut+=s,rr+=s}return e!==null&&e.insertChild(n),Yo(zn,In,fi,t,"created"),n}function ro(r,e,t,n,s){const i=ut;ut="";let o=t;for(;o<=n;++o){$s(r[o],s);const l=Ot.get(r[o]);l!==null&&Z(l)&&(Wt===null&&(Wt=l.getFormat()),Ft===""&&(Ft=l.getStyle()))}ci(e)&&(ut+=sr),s.element.__lexicalTextContent=ut,ut=i+ut}function qa(r,e){if(r){const t=r.__last;if(t){const n=e.get(t);if(n)return Ar(n)?"line-break":Ge(n)&&n.isInline()?"decorator":null}return"empty"}return null}function Gu(r,e,t){const n=qa(r,jr),s=qa(e,Ot);n!==s&&e.getDOMSlot(t).setManagedLineBreak(s)}function Ku(r,e){const t=e.__lexicalDirTextContent||"",n=e.__lexicalDir||"";if(t!==mt||n!==_s){const i=mt==="",o=i?_s:(s=mt,th.test(s)?"rtl":rh.test(s)?"ltr":null);if(o!==n){const l=e.classList,a=yr.theme;let u=n!==null?a[n]:void 0,c=o!==null?a[o]:void 0;if(u!==void 0){if(typeof u=="string"){const d=Rs(u);u=a[n]=d}l.remove(...u)}if(o===null||i&&o==="ltr")e.removeAttribute("dir");else{if(c!==void 0){if(typeof c=="string"){const d=Rs(c);c=a[o]=d}c!==void 0&&l.add(...c)}e.dir=o}On||(r.getWritable().__dir=o)}_s=o,e.__lexicalDirTextContent=mt,e.__lexicalDir=o}var s}function Dh(r,e,t){const n=mt;var s;mt="",Wt=null,Ft="",function(i,o,l){const a=ut,u=i.__size,c=o.__size;ut="";const d=l.element;if(u===1&&c===1){const h=i.__first,p=o.__first;if(h===p)_n(h,d);else{const m=no(h),x=$s(p,null);try{d.replaceChild(x,m)}catch(_){if(typeof _=="object"&&_!=null){const b=`${_.toString()} Parent: ${d.tagName}, new child: {tag: ${x.tagName} key: ${p}}, old child: {tag: ${m.tagName}, key: ${h}}.`;throw new Error(b)}throw _}Os(h,null)}const g=Ot.get(p);Z(g)&&(Wt===null&&(Wt=g.getFormat()),Ft===""&&(Ft=g.getStyle()))}else{const h=qs(i,jr),p=qs(o,Ot);if(h.length!==u&&Q(227),p.length!==c&&Q(228),u===0)c!==0&&ro(p,o,0,c-1,l);else if(c===0){if(u!==0){const g=l.after==null&&l.before==null&&l.element.__lexicalLineBreak==null;to(h,0,u-1,g?null:d),g&&(d.textContent="")}}else(function(g,m,x,_,b,C){const S=_-1,k=b-1;let E,v,T=C.getFirstChild(),B=0,j=0;for(;B<=S&&j<=k;){const R=m[B],w=x[j];if(R===w)T=Ri(_n(w,C.element)),B++,j++;else{E===void 0&&(E=new Set(m)),v===void 0&&(v=new Set(x));const F=v.has(R),I=E.has(w);if(F)if(I){const U=Is(xt,w);U===T?T=Ri(_n(w,C.element)):(C.withBefore(T).insertChild(U),_n(w,C.element)),B++,j++}else $s(w,C.withBefore(T)),j++;else T=Ri(no(R)),Os(R,C.element),B++}const D=Ot.get(w);D!==null&&Z(D)&&(Wt===null&&(Wt=D.getFormat()),Ft===""&&(Ft=D.getStyle()))}const N=B>S,M=j>k;if(N&&!M){const R=x[k+1],w=R===void 0?null:xt.getElementByKey(R);ro(x,g,j,k,C.withBefore(w))}else M&&!N&&to(m,B,S,C.element)})(o,h,p,u,c,l)}ci(o)&&(ut+=sr),d.__lexicalTextContent=ut,ut=a+ut}(r,e,e.getDOMSlot(t)),Ku(e,t),tn(s=e)&&Wt!=null&&Wt!==s.__textFormat&&!On&&(s.setTextFormat(Wt),s.setTextStyle(Ft)),function(i){tn(i)&&Ft!==""&&Ft!==i.__textStyle&&!On&&i.setTextStyle(Ft)}(e),mt=n}function qs(r,e){const t=[];let n=r.__first;for(;n!==null;){const s=e.get(n);s===void 0&&Q(101),t.push(n),n=s.__next}return t}function _n(r,e){const t=jr.get(r);let n=Ot.get(r);t!==void 0&&n!==void 0||Q(61);const s=Wu||Zi.has(r)||Xi.has(r),i=Is(xt,r);if(t===n&&!s){if(O(t)){const o=i.__lexicalTextContent;o!==void 0&&(ut+=o,rr+=o);const l=i.__lexicalDirTextContent;l!==void 0&&(mt+=l)}else{const o=t.getTextContent();Z(t)&&!t.isDirectionless()&&(mt+=o),rr+=o,ut+=o}return i}if(t!==n&&s&&Yo(zn,In,fi,n,"updated"),n.updateDOM(t,i,yr)){const o=$s(r,null);return e===null&&Q(62),e.replaceChild(o,i),Os(r,null),o}if(O(t)&&O(n)){const o=n.__indent;o!==t.__indent&&Hu(i,o);const l=n.__format;l!==t.__format&&Vu(i,l),s&&(Dh(t,n,i),yt(n)||n.isInline()||Gu(t,n,i)),ci(n)&&(ut+=sr,rr+=sr)}else{const o=n.getTextContent();if(Ge(n)){const l=n.decorate(xt,yr);l!==null&&Yu(r,l)}else Z(n)&&!n.isDirectionless()&&(mt+=o);ut+=o,rr+=o}if(!On&&yt(n)&&n.__cachedText!==rr){const o=n.getWritable();o.__cachedText=rr,n=o}return i}function Yu(r,e){let t=xt._pendingDecorators;const n=xt._decorators;if(t===null){if(n[r]===e)return;t=Pu(xt)}t[r]=e}function Ri(r){let e=r.nextSibling;return e!==null&&e===xt._blockCursorElement&&(e=e.nextSibling),e}function Ah(r,e,t,n,s,i){ut="",rr="",mt="",Wu=n===Zr,_s=null,xt=t,yr=t._config,In=t._nodes,fi=xt._listeners.mutation,Xi=s,Zi=i,jr=r._nodeMap,Ot=e._nodeMap,On=e._readOnly,eo=new Map(t._keyToDOMMap);const o=new Map;return zn=o,_n("root",null),xt=void 0,In=void 0,Xi=void 0,Zi=void 0,jr=void 0,Ot=void 0,yr=void 0,eo=void 0,zn=void 0,o}function no(r){const e=eo.get(r);return e===void 0&&Q(75,r),e}const er=Object.freeze({}),so=30,io=[["keydown",function(r,e){if(Nn=r.timeStamp,Qu=r.key,e.isComposing())return;const{key:t,shiftKey:n,ctrlKey:s,metaKey:i,altKey:o}=r;if(!ie(e,Mf,r)&&t!=null){if(function(l,a,u,c){return La(l)&&!a&&!c&&!u}(t,s,o,i))ie(e,mu,r);else if(function(l,a,u,c,d){return La(l)&&!c&&!u&&(a||d)}(t,s,n,o,i))ie(e,Rf,r);else if(function(l,a,u,c){return Fa(l)&&!a&&!c&&!u}(t,s,o,i))ie(e,yu,r);else if(function(l,a,u,c,d){return Fa(l)&&!c&&!u&&(a||d)}(t,s,n,o,i))ie(e,Ff,r);else if(function(l,a,u){return function(c){return c==="ArrowUp"}(l)&&!a&&!u}(t,s,i))ie(e,xu,r);else if(function(l,a,u){return function(c){return c==="ArrowDown"}(l)&&!a&&!u}(t,s,i))ie(e,bu,r);else if(function(l,a){return Pa(l)&&a}(t,n))Bn=!0,ie(e,Ns,r);else if(function(l){return l===" "}(t))ie(e,Lf,r);else if(function(l,a){return Rt&&a&&l.toLowerCase()==="o"}(t,s))r.preventDefault(),Bn=!0,ie(e,Kr,!0);else if(function(l,a){return Pa(l)&&!a}(t,n))Bn=!1,ie(e,Ns,r);else if(function(l,a,u,c){return Rt?!a&&!u&&(fn(l)||l.toLowerCase()==="h"&&c):!(c||a||u)&&fn(l)}(t,o,i,s))fn(t)?ie(e,vu,r):(r.preventDefault(),ie(e,Er,!0));else if(function(l){return l==="Escape"}(t))ie(e,_u,r);else if(function(l,a,u,c,d){return Rt?!(u||c||d)&&(hn(l)||l.toLowerCase()==="d"&&a):!(a||c||d)&&hn(l)}(t,s,n,o,i))hn(t)?ie(e,wu,r):(r.preventDefault(),ie(e,Er,!1));else if(function(l,a,u){return fn(l)&&(Rt?a:u)}(t,o,s))r.preventDefault(),ie(e,Fn,!0);else if(function(l,a,u){return hn(l)&&(Rt?a:u)}(t,o,s))r.preventDefault(),ie(e,Fn,!1);else if(function(l,a){return Rt&&a&&fn(l)}(t,i))r.preventDefault(),ie(e,Ln,!0);else if(function(l,a){return Rt&&a&&hn(l)}(t,i))r.preventDefault(),ie(e,Ln,!1);else if(function(l,a,u,c){return l.toLowerCase()==="b"&&!a&&vn(u,c)}(t,o,i,s))r.preventDefault(),ie(e,zt,"bold");else if(function(l,a,u,c){return l.toLowerCase()==="u"&&!a&&vn(u,c)}(t,o,i,s))r.preventDefault(),ie(e,zt,"underline");else if(function(l,a,u,c){return l.toLowerCase()==="i"&&!a&&vn(u,c)}(t,o,i,s))r.preventDefault(),ie(e,zt,"italic");else if(function(l,a,u,c){return l==="Tab"&&!a&&!u&&!c}(t,o,s,i))ie(e,Pf,r);else if(function(l,a,u,c){return l.toLowerCase()==="z"&&!a&&vn(u,c)}(t,n,i,s))r.preventDefault(),ie(e,jo,void 0);else if(function(l,a,u,c){return Rt?l.toLowerCase()==="z"&&u&&a:l.toLowerCase()==="y"&&c||l.toLowerCase()==="z"&&c&&a}(t,n,i,s))r.preventDefault(),ie(e,Mo,void 0);else{const l=e._editorState._selection;l===null||K(l)?!mr&&Ia(t,i,s)&&(r.preventDefault(),ie(e,Yi,r)):function(a,u,c,d){return!u&&a.toLowerCase()==="c"&&(Rt?c:d)}(t,n,i,s)?(r.preventDefault(),ie(e,ii,r)):function(a,u,c,d){return!u&&a.toLowerCase()==="x"&&(Rt?c:d)}(t,n,i,s)?(r.preventDefault(),ie(e,Ro,r)):Ia(t,i,s)&&(r.preventDefault(),ie(e,Yi,r))}(function(l,a,u,c){return l||a||u||c})(s,n,o,i)&&ie(e,Vf,r)}}],["pointerdown",function(r,e){const t=r.target,n=r.pointerType;t instanceof Node&&n!=="touch"&&Dt(e,()=>{Ge(en(t))||(ao=!0)})}],["compositionstart",function(r,e){Dt(e,()=>{const t=ae();if(K(t)&&!e.isComposing()){const n=t.anchor,s=t.anchor.getNode();ft(n.key),(r.timeStamp<Nn+so||n.type==="element"||!t.isCollapsed()||s.getFormat()!==t.format||Z(s)&&s.getStyle()!==t.style)&&ie(e,Yr,eh)}})}],["compositionend",function(r,e){mr?gn=!0:Dt(e,()=>{Fi(e,r.data)})}],["input",function(r,e){r.stopPropagation(),Dt(e,()=>{const t=ae(),n=r.data,s=ec(r);if(n!=null&&K(t)&&Zu(t,s,n,r.timeStamp,!1)){gn&&(Fi(e,n),gn=!1);const i=t.anchor.getNode(),o=Bt(e._window);if(o===null)return;const l=t.isBackward(),a=l?t.anchor.offset:t.focus.offset,u=l?t.focus.offset:t.anchor.offset;Bs&&!t.isCollapsed()&&Z(i)&&o.anchorNode!==null&&i.getTextContent().slice(0,a)+n+i.getTextContent().slice(a+u)===$u(o.anchorNode)||ie(e,Yr,n);const c=n.length;mr&&c>1&&r.inputType==="insertCompositionText"&&!e.isComposing()&&(t.anchor.offset-=c),oi||Vn||Fo||!e.isComposing()||(Nn=0,ft(null))}else Go(!1,e,n!==null?n:void 0),gn&&(Fi(e,n||void 0),gn=!1);Ct(),Bu(nt())}),Wr=null}],["click",function(r,e){Dt(e,()=>{const t=ae(),n=Bt(e._window),s=Zn();if(n){if(K(t)){const i=t.anchor,o=i.getNode();i.type==="element"&&i.offset===0&&t.isCollapsed()&&!yt(o)&&et().getChildrenSize()===1&&o.getTopLevelElementOrThrow().isEmpty()&&s!==null&&t.is(s)?(n.removeAllRanges(),t.dirty=!0):r.detail===3&&!t.isCollapsed()&&o!==t.focus.getNode()&&(O(o)?o.select(0):o.getParentOrThrow().select(0))}else if(r.pointerType==="touch"){const i=n.anchorNode;if(i!==null){const o=i.nodeType;(o===Gn||o===xr)&&Yt(ea(s,n,e,r))}}}ie(e,gu,r)})}],["cut",er],["copy",er],["dragstart",er],["dragover",er],["dragend",er],["paste",er],["focus",er],["blur",er],["drop",er]];Bs&&io.push(["beforeinput",(r,e)=>function(t,n){const s=t.inputType,i=ec(t);s==="deleteCompositionText"||mr&&qu(n)||s!=="insertCompositionText"&&Dt(n,()=>{const o=ae();if(s==="deleteContentBackward"){if(o===null){const p=Zn();if(!K(p))return;Yt(p.clone())}if(K(o)){const p=o.anchor.key===o.focus.key;if(l=t.timeStamp,Qu==="MediaLast"&&l<Nn+so&&n.isComposing()&&p){if(ft(null),Nn=0,setTimeout(()=>{Dt(n,()=>{ft(null)})},so),K(o)){const g=o.anchor.getNode();g.markDirty(),o.format=g.getFormat(),Z(g)||Q(142),o.style=g.getStyle()}}else{ft(null),t.preventDefault();const g=o.anchor.getNode(),m=g.getTextContent(),x=g.canInsertTextAfter(),_=o.anchor.offset===0&&o.focus.offset===m.length;Yf&&p&&!_&&x||ie(n,Er,!0)}return}}var l;if(!K(o))return;const a=t.data;Wr!==null&&Go(!1,n,Wr),o.dirty&&Wr===null||!o.isCollapsed()||yt(o.anchor.getNode())||i===null||o.applyDOMRange(i),Wr=null;const u=o.anchor,c=o.focus,d=u.getNode(),h=c.getNode();if(s!=="insertText"&&s!=="insertTranspose")switch(t.preventDefault(),s){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":ie(n,Yr,t);break;case"insertFromComposition":ft(null),ie(n,Yr,t);break;case"insertLineBreak":ft(null),ie(n,Kr,!1);break;case"insertParagraph":ft(null),Bn&&!Vn?(Bn=!1,ie(n,Kr,!1)):ie(n,Rn,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":ie(n,si,t);break;case"deleteByComposition":(function(p,g){return p!==g||O(p)||O(g)||!p.isToken()||!g.isToken()})(d,h)&&ie(n,Ki,t);break;case"deleteByDrag":case"deleteByCut":ie(n,Ki,t);break;case"deleteContent":ie(n,Er,!1);break;case"deleteWordBackward":ie(n,Fn,!0);break;case"deleteWordForward":ie(n,Fn,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":ie(n,Ln,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":ie(n,Ln,!1);break;case"formatStrikeThrough":ie(n,zt,"strikethrough");break;case"formatBold":ie(n,zt,"bold");break;case"formatItalic":ie(n,zt,"italic");break;case"formatUnderline":ie(n,zt,"underline");break;case"historyUndo":ie(n,jo,void 0);break;case"historyRedo":ie(n,Mo,void 0)}else{if(a===`
86
- `)t.preventDefault(),ie(n,Kr,!1);else if(a===sr)t.preventDefault(),ie(n,Rn,void 0);else if(a==null&&t.dataTransfer){const p=t.dataTransfer.getData("text/plain");t.preventDefault(),o.insertRawText(p)}else a!=null&&Zu(o,i,a,t.timeStamp,!0)?(t.preventDefault(),ie(n,Yr,a)):Wr=a;Ju=t.timeStamp}})}(r,e)]);let Nn=0,Qu=null,Ju=0,Wr=null;const Us=new WeakMap;let oo=!1,ao=!1,Bn=!1,gn=!1,Xu=[0,"",0,"root",0];function Zu(r,e,t,n,s){const i=r.anchor,o=r.focus,l=i.getNode(),a=nt(),u=Bt(a._window),c=u!==null?u.anchorNode:null,d=i.key,h=a.getElementByKey(d),p=t.length;return d!==o.key||!Z(l)||(!s&&(!Bs||Ju<n+50)||l.isDirty()&&p<2||zu(t))&&i.offset!==o.offset&&!l.isComposing()||Cr(l)||l.isDirty()&&p>1||(s||!Bs)&&h!==null&&!l.isComposing()&&c!==Fs(h)||u!==null&&e!==null&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||l.getFormat()!==r.format||l.getStyle()!==r.style||yh(r,l)}function Ua(r,e){return r!==null&&r.nodeValue!==null&&r.nodeType===xr&&e!==0&&e!==r.nodeValue.length}function Wa(r,e,t){const{anchorNode:n,anchorOffset:s,focusNode:i,focusOffset:o}=r;oo&&(oo=!1,Ua(n,s)&&Ua(i,o))||Dt(e,()=>{if(!t)return void Yt(null);if(!Kn(e,n,i))return;const l=ae();if(K(l)){const a=l.anchor,u=a.getNode();if(l.isCollapsed()){r.type==="Range"&&r.anchorNode===r.focusNode&&(l.dirty=!0);const c=di(e).event,d=c?c.timeStamp:performance.now(),[h,p,g,m,x]=Xu,_=et(),b=e.isComposing()===!1&&_.getTextContent()==="";if(d<x+200&&a.offset===g&&a.key===m)l.format=h,l.style=p;else if(a.type==="text")Z(u)||Q(141),l.format=u.getFormat(),l.style=u.getStyle();else if(a.type==="element"&&!b){const C=a.getNode();l.style="",C instanceof on&&C.getChildrenSize()===0?(l.format=C.getTextFormat(),l.style=C.getTextStyle()):l.format=0}}else{const c=a.key,d=l.focus.key,h=l.getNodes(),p=h.length,g=l.isBackward(),m=g?o:s,x=g?s:o,_=g?d:c,b=g?c:d;let C=Zf,S=!1;for(let k=0;k<p;k++){const E=h[k],v=E.getTextContentSize();if(Z(E)&&v!==0&&!(k===0&&E.__key===_&&m===v||k===p-1&&E.__key===b&&x===0)&&(S=!0,C&=E.getFormat(),C===0))break}l.format=S?C:0}}ie(e,Bo,void 0)})}function ec(r){if(!r.getTargetRanges)return null;const e=r.getTargetRanges();return e.length===0?null:e[0]}function Fi(r,e){const t=r._compositionKey;if(ft(null),t!==null&&e!=null){if(e===""){const n=ht(t),s=Fs(r.getElementByKey(t));return void(s!==null&&s.nodeValue!==null&&Z(n)&&Ko(n,s.nodeValue,null,null,!0))}if(e[e.length-1]===`
87
- `){const n=ae();if(K(n)){const s=n.focus;return n.anchor.set(s.key,s.offset,s.type),void ie(r,Ns,null)}}}Go(!0,r,e)}function tc(r){let e=r.__lexicalEventHandles;return e===void 0&&(e=[],r.__lexicalEventHandles=e),e}const Qr=new Map;function rc(r){const e=r.target,t=Bt(e==null?null:e.nodeType===9?e.defaultView:e.ownerDocument.defaultView);if(t===null)return;const n=Ru(t.anchorNode);if(n===null)return;ao&&(ao=!1,Dt(n,()=>{const u=Zn(),c=t.anchorNode;if(c===null)return;const d=c.nodeType;d!==Gn&&d!==xr||Yt(ea(u,t,n,r))}));const s=Vo(n),i=s[s.length-1],o=i._key,l=Qr.get(o),a=l||i;a!==n&&Wa(t,a,!1),Wa(t,n,!0),n!==i?Qr.set(o,n):l&&Qr.delete(o)}function Ha(r){r._lexicalHandled=!0}function Va(r){return r._lexicalHandled===!0}function Th(r){const e=r.ownerDocument,t=Us.get(e);t===void 0&&Q(162);const n=t-1;n>=0||Q(164),Us.set(e,n),n===0&&e.removeEventListener("selectionchange",rc);const s=li(r);Ho(s)?(function(o){if(o._parentEditor!==null){const l=Vo(o),a=l[l.length-1]._key;Qr.get(a)===o&&Qr.delete(a)}else Qr.delete(o._key)}(s),r.__lexicalEditor=null):s&&Q(198);const i=tc(r);for(let o=0;o<i.length;o++)i[o]();r.__lexicalEventHandles=[]}function lo(r,e,t){Ct();const n=r.__key,s=r.getParent();if(s===null)return;const i=function(l){const a=ae();if(!K(a)||!O(l))return a;const{anchor:u,focus:c}=a,d=u.getNode(),h=c.getNode();return Tn(d,l)&&u.set(l.__key,0,"element"),Tn(h,l)&&c.set(l.__key,0,"element"),a}(r);let o=!1;if(K(i)&&e){const l=i.anchor,a=i.focus;l.key===n&&(Hs(l,r,s,r.getPreviousSibling(),r.getNextSibling()),o=!0),a.key===n&&(Hs(a,r,s,r.getPreviousSibling(),r.getNextSibling()),o=!0)}else Ht(i)&&e&&r.isSelected()&&r.selectPrevious();if(K(i)&&e&&!o){const l=r.getIndexWithinParent();Dr(r),Ws(i,s,l,-1)}else Dr(r);t||Qt(s)||s.canBeEmpty()||!s.isEmpty()||lo(s,e),e&&yt(s)&&s.isEmpty()&&s.selectEnd()}class hi{static getType(){Q(64,this.name)}static clone(e){Q(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,mh(this,e)}getType(){return this.__type}isInline(){Q(137,this.constructor.name)}isAttached(){let e=this.__key;for(;e!==null;){if(e==="root")return!0;const t=ht(e);if(t===null)break;e=t.__parent}return!1}isSelected(e){const t=e||ae();if(t==null)return!1;const n=t.getNodes().some(s=>s.__key===this.__key);if(Z(this))return n;if(K(t)&&t.anchor.type==="element"&&t.focus.type==="element"){if(t.isCollapsed())return!1;const s=this.getParent();if(Ge(this)&&this.isInline()&&s){const i=t.isBackward()?t.focus:t.anchor,o=i.getNode();if(i.offset===o.getChildrenSize()&&o.is(s)&&o.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:ht(e)}getParentOrThrow(){const e=this.getParent();return e===null&&Q(66,this.__key),e}getTopLevelElement(){let e=this;for(;e!==null;){const t=e.getParent();if(Qt(t))return O(e)||e===this&&Ge(e)||Q(194),e;e=t}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return e===null&&Q(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:ht(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:ht(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();O(this)&&t.unshift(this),O(e)&&n.unshift(e);const s=t.length,i=n.length;if(s===0||i===0||t[s-1]!==n[i-1])return null;const o=new Set(n);for(let l=0;l<s;l++){const a=t[l];if(o.has(a))return a}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,i=this;for(;;){const o=i.getParentOrThrow();if(o===t){n=i.getIndexWithinParent();break}i=o}for(i=e;;){const o=i.getParentOrThrow();if(o===t){s=i.getIndexWithinParent();break}i=o}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 i=this;for(;i!==null;){const o=i.__key;if(s.has(o)||(s.add(o),n.push(i)),i===e)break;const l=O(i)?t?i.getFirstChild():i.getLastChild():null;if(l!==null){i=l;continue}const a=t?i.getNextSibling():i.getPreviousSibling();if(a!==null){i=a;continue}const u=i.getParentOrThrow();if(s.has(u.__key)||n.push(u),u===e)break;let c=null,d=u;do{if(d===null&&Q(68),c=t?d.getNextSibling():d.getPreviousSibling(),d=d.getParent(),d===null)break;c!==null||s.has(d.__key)||n.push(d)}while(c===null);i=c}return t||n.reverse(),n}isDirty(){const e=nt()._dirtyLeaves;return e!==null&&e.has(this.__key)}getLatest(){const e=ht(this.__key);return e===null&&Q(113),e}getWritable(){Ct();const e=ar(),t=nt(),n=e._nodeMap,s=this.__key,i=this.getLatest(),o=t._cloneNotNeeded,l=ae();if(l!==null&&l.setCachedNodes(null),o.has(s))return Ps(i),i;const a=Jo(i);return o.add(s),Ps(a),n.set(s,a),a}getTextContent(){return""}getTextContentSize(){return this.getTextContent().length}createDOM(e,t){Q(70)}updateDOM(e,t,n){Q(71)}exportDOM(e){return{element:this.createDOM(e._config,e)}}exportJSON(){Q(72)}static importJSON(e){Q(18,this.name)}static transform(){return null}remove(e){lo(this,!0,e)}replace(e,t){Ct();let n=ae();n!==null&&(n=n.clone()),ji(this,e);const s=this.getLatest(),i=this.__key,o=e.__key,l=e.getWritable(),a=this.getParentOrThrow().getWritable(),u=a.__size;Dr(l);const c=s.getPreviousSibling(),d=s.getNextSibling(),h=s.__prev,p=s.__next,g=s.__parent;if(lo(s,!1,!0),c===null?a.__first=o:c.getWritable().__next=o,l.__prev=h,d===null?a.__last=o:d.getWritable().__prev=o,l.__next=p,l.__parent=g,a.__size=u,t&&(O(this)&&O(l)||Q(139),this.getChildren().forEach(m=>{l.append(m)})),K(n)){Yt(n);const m=n.anchor,x=n.focus;m.key===i&&Qa(m,l),x.key===i&&Qa(x,l)}return hr()===i&&ft(o),l}insertAfter(e,t=!0){Ct(),ji(this,e);const n=this.getWritable(),s=e.getWritable(),i=s.getParent(),o=ae();let l=!1,a=!1;if(i!==null){const p=e.getIndexWithinParent();if(Dr(s),K(o)){const g=i.__key,m=o.anchor,x=o.focus;l=m.type==="element"&&m.key===g&&m.offset===p+1,a=x.type==="element"&&x.key===g&&x.offset===p+1}}const u=this.getNextSibling(),c=this.getParentOrThrow().getWritable(),d=s.__key,h=n.__next;if(u===null?c.__last=d:u.getWritable().__prev=d,c.__size++,n.__next=d,s.__next=h,s.__prev=n.__key,s.__parent=n.__parent,t&&K(o)){const p=this.getIndexWithinParent();Ws(o,c,p+1);const g=c.__key;l&&o.anchor.set(g,p+2,"element"),a&&o.focus.set(g,p+2,"element")}return e}insertBefore(e,t=!0){Ct(),ji(this,e);const n=this.getWritable(),s=e.getWritable(),i=s.__key;Dr(s);const o=this.getPreviousSibling(),l=this.getParentOrThrow().getWritable(),a=n.__prev,u=this.getIndexWithinParent();o===null?l.__first=i:o.getWritable().__next=i,l.__size++,n.__prev=i,s.__prev=a,s.__next=n.__key,s.__parent=n.__parent;const c=ae();return t&&K(c)&&Ws(c,this.getParentOrThrow(),u),e}isParentRequired(){return!1}createParentElementNode(){return at()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(e,t){Ct();const n=this.getPreviousSibling(),s=this.getParentOrThrow();if(n===null)return s.select(0,0);if(O(n))return n.select();if(!Z(n)){const i=n.getIndexWithinParent()+1;return s.select(i,i)}return n.select(e,t)}selectNext(e,t){Ct();const n=this.getNextSibling(),s=this.getParentOrThrow();if(n===null)return s.select();if(O(n))return n.select(0,0);if(!Z(n)){const i=n.getIndexWithinParent();return s.select(i,i)}return n.select(e,t)}markDirty(){this.getWritable()}reconcileObservedMutation(e,t){this.markDirty()}}class Qn extends hi{static getType(){return"linebreak"}static clone(e){return new Qn(e.__key)}constructor(e){super(e)}getTextContent(){return`
88
- `}createDOM(){return document.createElement("br")}updateDOM(){return!1}static importDOM(){return{br:e=>function(t){const n=t.parentElement;if(n!==null&&zs(n)){const s=n.firstChild;if(s===t||s.nextSibling===t&&us(s)){const i=n.lastChild;if(i===t||i.previousSibling===t&&us(i))return!0}}return!1}(e)||function(t){const n=t.parentElement;if(n!==null&&zs(n)){const s=n.firstChild;if(s===t||s.nextSibling===t&&us(s))return!1;const i=n.lastChild;if(i===t||i.previousSibling===t&&us(i))return!0}return!1}(e)?null:{conversion:Nh,priority:0}}}static importJSON(e){return Mr()}exportJSON(){return{type:"linebreak",version:1}}}function Nh(r){return{node:Mr()}}function Mr(){return Xt(new Qn)}function Ar(r){return r instanceof Qn}function us(r){return r.nodeType===xr&&/^( |\t|\r?\n)+$/.test(r.textContent||"")}function Li(r,e){return 16&e?"code":e&Lo?"mark":32&e?"sub":64&e?"sup":null}function Pi(r,e){return 1&e?"strong":2&e?"em":"span"}function nc(r,e,t,n,s){const i=n.classList;let o=An(s,"base");o!==void 0&&i.add(...o),o=An(s,"underlineStrikethrough");let l=!1;const a=e&Ms&&e&js;o!==void 0&&(t&Ms&&t&js?(l=!0,a||i.add(...o)):a&&i.remove(...o));for(const u in Br){const c=Br[u];if(o=An(s,u),o!==void 0)if(t&c){if(l&&(u==="underline"||u==="strikethrough")){e&c&&i.remove(...o);continue}e&c&&(!a||u!=="underline")&&u!=="strikethrough"||i.add(...o)}else e&c&&i.remove(...o)}}function sc(r,e,t){const n=e.firstChild,s=t.isComposing(),i=r+(s?ai:"");if(n==null)e.textContent=i;else{const o=n.nodeValue;if(o!==i)if(s||mr){const[l,a,u]=function(c,d){const h=c.length,p=d.length;let g=0,m=0;for(;g<h&&g<p&&c[g]===d[g];)g++;for(;m+g<h&&m+g<p&&c[h-m-1]===d[p-m-1];)m++;return[g,h-g-m,d.slice(g,p-m)]}(o,i);a!==0&&n.deleteData(l,a),n.insertData(l,u)}else n.nodeValue=i}}function Ga(r,e,t,n,s,i){sc(s,r,e);const o=i.theme.text;o!==void 0&&nc(0,0,n,r,o)}function cs(r,e){const t=document.createElement(e);return t.appendChild(r),t}class sn extends hi{static getType(){return"text"}static clone(e){return new sn(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 oh[e.__mode]}getStyle(){return this.getLatest().__style}isToken(){return this.getLatest().__mode===1}isComposing(){return this.__key===hr()}isSegmented(){return this.getLatest().__mode===2}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(e){const t=Br[e];return!!(this.getFormat()&t)}isSimpleText(){return this.__type==="text"&&this.__mode===0}getTextContent(){return this.getLatest().__text}getFormatFlags(e,t){return Ls(this.getLatest().__format,e,t)}canHaveFormat(){return!0}createDOM(e,t){const n=this.__format,s=Li(0,n),i=Pi(0,n),o=s===null?i:s,l=document.createElement(o);let a=l;this.hasFormat("code")&&l.setAttribute("spellcheck","false"),s!==null&&(a=document.createElement(i),l.appendChild(a)),Ga(a,this,0,n,this.__text,e);const u=this.__style;return u!==""&&(l.style.cssText=u),l}updateDOM(e,t,n){const s=this.__text,i=e.__format,o=this.__format,l=Li(0,i),a=Li(0,o),u=Pi(0,i),c=Pi(0,o);if((l===null?u:l)!==(a===null?c:a))return!0;if(l===a&&u!==c){const m=t.firstChild;m==null&&Q(48);const x=document.createElement(c);return Ga(x,this,0,o,s,n),t.replaceChild(x,m),!1}let d=t;a!==null&&l!==null&&(d=t.firstChild,d==null&&Q(49)),sc(s,d,this);const h=n.theme.text;h!==void 0&&i!==o&&nc(0,i,o,d,h);const p=e.__style,g=this.__style;return p!==g&&(t.style.cssText=g),!1}static importDOM(){return{"#text":()=>({conversion:Rh,priority:0}),b:()=>({conversion:jh,priority:0}),code:()=>({conversion:ur,priority:0}),em:()=>({conversion:ur,priority:0}),i:()=>({conversion:ur,priority:0}),s:()=>({conversion:ur,priority:0}),span:()=>({conversion:Bh,priority:0}),strong:()=>({conversion:ur,priority:0}),sub:()=>({conversion:ur,priority:0}),sup:()=>({conversion:ur,priority:0}),u:()=>({conversion:ur,priority:0})}}static importJSON(e){const t=lt(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&&or(t)||Q(132),t.style.whiteSpace="pre-wrap",this.hasFormat("bold")&&(t=cs(t,"b")),this.hasFormat("italic")&&(t=cs(t,"i")),this.hasFormat("strikethrough")&&(t=cs(t,"s")),this.hasFormat("underline")&&(t=cs(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"?Br[e]:e,t}setDetail(e){const t=this.getWritable();return t.__detail=typeof e=="string"?nh[e]:e,t}setStyle(e){const t=this.getWritable();return t.__style=e,t}toggleFormat(e){const t=Ls(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=ih[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){Ct();let n=e,s=t;const i=ae(),o=this.getTextContent(),l=this.__key;if(typeof o=="string"){const a=o.length;n===void 0&&(n=a),s===void 0&&(s=a)}else n=0,s=0;if(!K(i))return ac(l,n,l,s,"text","text");{const a=hr();a!==i.anchor.key&&a!==i.focus.key||ft(l),i.setTextNodeRange(this,n,this,s)}return i}selectStart(){return this.select(0,0)}selectEnd(){const e=this.getTextContentSize();return this.select(e,e)}spliceText(e,t,n,s){const i=this.getWritable(),o=i.__text,l=n.length;let a=e;a<0&&(a=l+a,a<0&&(a=0));const u=ae();if(s&&K(u)){const d=e+l;u.setTextNodeRange(i,d,i,d)}const c=o.slice(0,a)+n+o.slice(a+t);return i.__text=c,i}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...e){Ct();const t=this.getLatest(),n=t.getTextContent(),s=t.__key,i=hr(),o=new Set(e),l=[],a=n.length;let u="";for(let k=0;k<a;k++)u!==""&&o.has(k)&&(l.push(u),u=""),u+=n[k];u!==""&&l.push(u);const c=l.length;if(c===0)return[];if(l[0]===n)return[t];const d=l[0],h=t.getParent();let p;const g=t.getFormat(),m=t.getStyle(),x=t.__detail;let _=!1;t.isSegmented()?(p=lt(d),p.__format=g,p.__style=m,p.__detail=x,_=!0):(p=t.getWritable(),p.__text=d);const b=ae(),C=[p];let S=d.length;for(let k=1;k<c;k++){const E=l[k],v=E.length,T=lt(E).getWritable();T.__format=g,T.__style=m,T.__detail=x;const B=T.__key,j=S+v;if(K(b)){const N=b.anchor,M=b.focus;N.key===s&&N.type==="text"&&N.offset>S&&N.offset<=j&&(N.key=B,N.offset-=S,b.dirty=!0),M.key===s&&M.type==="text"&&M.offset>S&&M.offset<=j&&(M.key=B,M.offset-=S,b.dirty=!0)}i===s&&ft(B),S=j,C.push(T)}if(h!==null){(function(v){const T=v.getPreviousSibling(),B=v.getNextSibling();T!==null&&Ps(T),B!==null&&Ps(B)})(this);const k=h.getWritable(),E=this.getIndexWithinParent();_?(k.splice(E,0,C),this.remove()):k.splice(E,1,C),K(b)&&Ws(b,h,E,c-1)}return C}mergeWithSibling(e){const t=e===this.getPreviousSibling();t||e===this.getNextSibling()||Q(50);const n=this.__key,s=e.__key,i=this.__text,o=i.length;hr()===s&&ft(n);const l=ae();if(K(l)){const d=l.anchor,h=l.focus;d!==null&&d.key===s&&(nl(d,t,n,e,o),l.dirty=!0),h!==null&&h.key===s&&(nl(h,t,n,e,o),l.dirty=!0)}const a=e.__text,u=t?a+i:i+a;this.setTextContent(u);const c=this.getWritable();return e.remove(),c}isTextEntity(){return!1}}function Bh(r){return{forChild:Zo(r.style),node:null}}function jh(r){const e=r,t=e.style.fontWeight==="normal";return{forChild:Zo(e.style,t?void 0:"bold"),node:null}}const Ka=new WeakMap;function Mh(r){return r.nodeName==="PRE"||r.nodeType===Gn&&r.style!==void 0&&r.style.whiteSpace!==void 0&&r.style.whiteSpace.startsWith("pre")}function Rh(r){const e=r;r.parentElement===null&&Q(129);let t=e.textContent||"";if(function(n){let s,i=n.parentNode;const o=[n];for(;i!==null&&(s=Ka.get(i))===void 0&&!Mh(i);)o.push(i),i=i.parentNode;const l=s===void 0?i:s;for(let a=0;a<o.length;a++)Ka.set(o[a],l);return l}(e)!==null){const n=t.split(/(\r?\n|\t)/),s=[],i=n.length;for(let o=0;o<i;o++){const l=n[o];l===`
89
- `||l===`\r
90
- `?s.push(Mr()):l===" "?s.push(Xn()):l!==""&&s.push(lt(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=Ya(n,!1))!==null;){const i=n.textContent||"";if(i.length>0){/[ \t\n]$/.test(i)&&(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=Ya(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:lt(t)}}function Ya(r,e){let t=r;for(;;){let n;for(;(n=e?t.nextSibling:t.previousSibling)===null;){const i=t.parentElement;if(i===null)return null;t=i}if(t=n,t.nodeType===Gn){const i=t.style.display;if(i===""&&!Ji(t)||i!==""&&!i.startsWith("inline"))return null}let s=t;for(;(s=e?t.firstChild:t.lastChild)!==null;)t=s;if(t.nodeType===xr)return t;if(t.nodeName==="BR")return null}}const Fh={code:"code",em:"italic",i:"italic",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function ur(r){const e=Fh[r.nodeName.toLowerCase()];return e===void 0?{node:null}:{forChild:Zo(r.style,e),node:null}}function lt(r=""){return Xt(new sn(r))}function Z(r){return r instanceof sn}function Zo(r,e){const t=r.fontWeight,n=r.textDecoration.split(" "),s=t==="700"||t==="bold",i=n.includes("line-through"),o=r.fontStyle==="italic",l=n.includes("underline"),a=r.verticalAlign;return u=>(Z(u)&&(s&&!u.hasFormat("bold")&&u.toggleFormat("bold"),i&&!u.hasFormat("strikethrough")&&u.toggleFormat("strikethrough"),o&&!u.hasFormat("italic")&&u.toggleFormat("italic"),l&&!u.hasFormat("underline")&&u.toggleFormat("underline"),a!=="sub"||u.hasFormat("subscript")||u.toggleFormat("subscript"),a!=="super"||u.hasFormat("superscript")||u.toggleFormat("superscript"),e&&!u.hasFormat(e)&&u.toggleFormat(e)),u)}class Jn extends sn{static getType(){return"tab"}static clone(e){return new Jn(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=Xn();return t.setFormat(e.format),t.setStyle(e.style),t}exportJSON(){return{...super.exportJSON(),type:"tab",version:1}}setTextContent(e){Q(126)}setDetail(e){Q(127)}setMode(e){Q(128)}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function Xn(){return Xt(new Jn)}function Lh(r){return r instanceof Jn}class Ph{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,i=e.offset;if(O(t)){const o=t.getDescendantByIndex(s);t=o??t}if(O(n)){const o=n.getDescendantByIndex(i);n=o??n}return t===n?s<i:t.isBefore(n)}getNode(){const e=ht(this.key);return e===null&&Q(20),e}set(e,t,n){const s=this._selection,i=this.key;this.key=e,this.offset=t,this.type=n,es()||(hr()===i&&ft(e),s!==null&&(s.setCachedNodes(null),s.dirty=!0))}}function Jt(r,e,t){return new Ph(r,e,t)}function Ii(r,e){let t=e.__key,n=r.offset,s="element";if(Z(e)){s="text";const i=e.getTextContentSize();n>i&&(n=i)}else if(!O(e)){const i=e.getNextSibling();if(Z(i))t=i.__key,n=0,s="text";else{const o=e.getParent();o&&(t=o.__key,n=e.getIndexWithinParent()+1)}}r.set(t,n,s)}function Qa(r,e){if(O(e)){const t=e.getLastDescendant();O(t)||Z(t)?Ii(r,t):Ii(r,e)}else Ii(r,e)}function dr(r,e,t,n){r.key=e,r.offset=t,r.type=n}class pi{constructor(e){this._cachedNodes=null,this._nodes=e,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){if(!Ht(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 pi(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 i;if(Z(s))i=s.select();else{const o=s.getIndexWithinParent()+1;i=s.getParentOrThrow().select(o,o)}i.insertNodes(e);for(let o=0;o<n;o++)t[o].remove()}getNodes(){const e=this._cachedNodes;if(e!==null)return e;const t=this._nodes,n=[];for(const s of t){const i=ht(s);i!==null&&n.push(i)}return es()||(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 K(r){return r instanceof br}class br{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!!K(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),i=s?t:n,o=s?n:t;let l=i.getNode(),a=o.getNode();const u=i.offset,c=o.offset;if(O(l)){const h=l.getDescendantByIndex(u);l=h??l}if(O(a)){let h=a.getDescendantByIndex(c);h!==null&&h!==l&&a.getChildAtIndex(c)===h&&(h=h.getPreviousSibling()),a=h??a}let d;return d=l.is(a)?O(l)&&l.getChildrenSize()>0?[]:[l]:l.getNodesBetween(a),es()||(this._cachedNodes=d),d}setTextNodeRange(e,t,n,s){dr(this.anchor,e.__key,t,"text"),dr(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,i=this.focus,o=s.isBefore(i),[l,a]=uo(this);let u="",c=!0;for(let d=0;d<e.length;d++){const h=e[d];if(O(h)&&!h.isInline())c||(u+=`
91
- `),c=!h.isEmpty();else if(c=!1,Z(h)){let p=h.getTextContent();h===t?h===n?s.type==="element"&&i.type==="element"&&i.offset!==s.offset||(p=l<a?p.slice(l,a):p.slice(a,l)):p=o?p.slice(l):p.slice(a):h===n&&(p=o?p.slice(0,a):p.slice(0,l)),u+=p}else!Ge(h)&&!Ar(h)||h===n&&this.isCollapsed()||(u+=h.getTextContent())}return u}applyDOMRange(e){const t=nt(),n=t.getEditorState()._selection,s=oc(e.startContainer,e.startOffset,e.endContainer,e.endOffset,t,n);if(s===null)return;const[i,o]=s;dr(this.anchor,i.key,i.offset,i.type),dr(this.focus,o.key,o.offset,o.type),this._cachedNodes=null}clone(){const e=this.anchor,t=this.focus;return new br(Jt(e.key,e.offset,e.type),Jt(t.key,t.offset,t.type),this.format,this.style)}toggleFormat(e){this.format=Ls(this.format,e,null),this.dirty=!0}setStyle(e){this.style=e,this.dirty=!0}hasFormat(e){const t=Br[e];return!!(this.format&t)}insertRawText(e){const t=e.split(/(\r?\n|\t)/),n=[],s=t.length;for(let i=0;i<s;i++){const o=t[i];o===`
85
+ `,eh=gr?" ":ai,Au="֑-߿יִ-﷽ﹰ-ﻼ",Tu="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",th=new RegExp("^[^"+Tu+"]*["+Au+"]"),rh=new RegExp("^[^"+Au+"]*["+Tu+"]"),Br={bold:1,code:16,highlight:Lo,italic:2,strikethrough:js,subscript:32,superscript:64,underline:Ms},nh={directionless:1,unmergeable:2},Aa={center:Io,end:qo,justify:Oo,left:Po,right:zo,start:$o},sh={[Io]:"center",[qo]:"end",[Oo]:"justify",[Po]:"left",[zo]:"right",[$o]:"start"},ih={normal:0,segmented:2,token:1},oh={[Qf]:"normal",[Xf]:"segmented",[Jf]:"token"};function ah(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var K=ah(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 Rs(...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 lh=100;let Qi=!1,Uo=0;function uh(r){Uo=r.timeStamp}function Bi(r,e,t){const n=r.nodeName==="BR",s=e.__lexicalLineBreak;return s&&(r===s||n&&r.previousSibling===s)||n&&ui(r,t)!==void 0}function ch(r,e,t){const n=Bt(t._window);let s=null,i=null;n!==null&&n.anchorNode===r&&(s=n.anchorOffset,i=n.focusOffset);const o=r.nodeValue;o!==null&&Ko(e,o,s,i,!1)}function dh(r,e,t){if(V(r)){const n=r.anchor.getNode();if(n.is(t)&&r.format!==n.getFormat())return!1}return e.nodeType===yr&&t.isAttached()}function fh(r,e,t,n){for(let s=r;s&&!kh(s);s=Yn(s)){const i=ui(s,e);if(i!==void 0){const o=pt(i,t);if(o)return Ge(o)?void 0:[s,o]}else if(s===n)return[n,Iu(t)]}}function Nu(r,e,t){Qi=!0;const n=performance.now()-Uo>lh;try{Dt(r,()=>{const s=ae()||function(h){return h.getEditorState().read(()=>{const p=ae();return p!==null?p.clone():null})}(r),i=new Map,o=r.getRootElement(),a=r._editorState,l=r._blockCursorElement;let u=!1,c="";for(let h=0;h<e.length;h++){const p=e[h],g=p.type,m=p.target,x=fh(m,r,a,o);if(!x)continue;const[_,b]=x;if(g==="characterData")n&&ee(b)&&dh(s,m,b)&&ch(m,b,r);else if(g==="childList"){u=!0;const S=p.addedNodes;for(let E=0;E<S.length;E++){const v=S[E],T=Lu(v),B=v.parentNode;if(B!=null&&v!==l&&T===null&&!Bi(v,B,r)){if(gr){const j=v.innerText||v.nodeValue;j&&(c+=j)}B.removeChild(v)}}const C=p.removedNodes,k=C.length;if(k>0){let E=0;for(let v=0;v<k;v++){const T=C[v];(Bi(T,m,r)||l===T)&&(m.appendChild(T),E++)}k!==E&&i.set(_,b)}}}if(i.size>0)for(const[h,p]of i)p.reconcileObservedMutation(h,r);const d=t.takeRecords();if(d.length>0){for(let h=0;h<d.length;h++){const p=d[h],g=p.addedNodes,m=p.target;for(let x=0;x<g.length;x++){const _=g[x],b=_.parentNode;b==null||_.nodeName!=="BR"||Bi(_,m,r)||b.removeChild(_)}}t.takeRecords()}s!==null&&(u&&(s.dirty=!0,Gt(s)),gr&&qu(r)&&s.insertRawText(c))})}finally{Qi=!1}}function Bu(r){const e=r._observer;e!==null&&Nu(r,e.takeRecords(),e)}function ju(r){(function(e){Uo===0&&di(e).addEventListener("textInput",uh,!0)})(r),r._observer=new MutationObserver((e,t)=>{Nu(r,e,t)})}function Ta(r,e){const t=r.__mode,n=r.__format,s=r.__style,i=e.__mode,o=e.__format,a=e.__style;return!(t!==null&&t!==i||n!==null&&n!==o||s!==null&&s!==a)}function Na(r,e){const t=r.mergeWithSibling(e),n=rt()._normalizedNodes;return n.add(r.__key),n.add(e.__key),t}function Ba(r){let e,t,n=r;if(n.__text!==""||!n.isSimpleText()||n.isUnmergeable()){for(;(e=n.getPreviousSibling())!==null&&ee(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(e.__text!==""){if(Ta(e,n)){n=Na(e,n);break}break}e.remove()}for(;(t=n.getNextSibling())!==null&&ee(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==""){if(Ta(n,t)){n=Na(n,t);break}break}t.remove()}}else n.remove()}function Mu(r){return ja(r.anchor),ja(r.focus),r}function ja(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),ee(n)){r.set(n.__key,s?n.getTextContentSize():0,"text");break}if(!$(n))break;r.set(n.__key,s?n.getChildrenSize():0,"element")}}let hh=1;const ph=typeof queueMicrotask=="function"?queueMicrotask:r=>{Promise.resolve().then(r)};function Wo(r){const e=document.activeElement;if(e===null)return!1;const t=e.nodeName;return Ge(en(r))&&(t==="INPUT"||t==="TEXTAREA"||e.contentEditable==="true"&&li(e)==null)}function Kn(r,e,t){const n=r.getRootElement();try{return n!==null&&n.contains(e)&&n.contains(t)&&e!==null&&!Wo(e)&&Ru(e)===r}catch{return!1}}function Ho(r){return r instanceof mi}function Ru(r){let e=r;for(;e!=null;){const t=li(e);if(Ho(t))return t;e=Yn(e)}return null}function li(r){return r?r.__lexicalEditor:null}function Cr(r){return r.isToken()||r.isSegmented()}function gh(r){return r.nodeType===yr}function Fs(r){let e=r;for(;e!=null;){if(gh(e))return e;e=e.firstChild}return null}function Ls(r,e,t){const n=Br[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 Fu(r){return ee(r)||Ar(r)||Ge(r)}function mh(r,e){if(e!=null)return void(r.__key=e);wt(),uc();const t=rt(),n=or(),s=""+hh++;n._nodeMap.set(s,r),$(r)?t._dirtyElements.set(s,!0):t._dirtyLeaves.add(s),t._cloneNotNeeded.add(s),t._dirtyType=Du,r.__key=s}function Dr(r){const e=r.getParent();if(e!==null){const t=r.getWritable(),n=e.getWritable(),s=r.getPreviousSibling(),i=r.getNextSibling();if(s===null)if(i!==null){const o=i.getWritable();n.__first=i.__key,o.__prev=null}else n.__first=null;else{const o=s.getWritable();if(i!==null){const a=i.getWritable();a.__prev=o.__key,o.__next=a.__key}else o.__next=null;t.__prev=null}if(i===null)if(s!==null){const o=s.getWritable();n.__last=s.__key,o.__next=null}else n.__last=null;else{const o=i.getWritable();if(s!==null){const a=s.getWritable();a.__next=o.__key,o.__prev=a.__key}else o.__prev=null;t.__next=null}n.__size--,t.__parent=null}}function Ps(r){uc();const e=r.getLatest(),t=e.__parent,n=or(),s=rt(),i=n._nodeMap,o=s._dirtyElements;t!==null&&function(l,u,c){let d=l;for(;d!==null;){if(c.has(d))return;const h=u.get(d);if(h===void 0)break;c.set(d,!1),d=h.__parent}}(t,i,o);const a=e.__key;s._dirtyType=Du,$(r)?o.set(a,!0):s._dirtyLeaves.add(a)}function ht(r){wt();const e=rt(),t=e._compositionKey;if(r!==t){if(e._compositionKey=r,t!==null){const n=pt(t);n!==null&&n.getWritable()}if(r!==null){const n=pt(r);n!==null&&n.getWritable()}}}function fr(){return es()?null:rt()._compositionKey}function pt(r,e){const t=(e||or())._nodeMap.get(r);return t===void 0?null:t}function Lu(r,e){const t=ui(r,rt());return t!==void 0?pt(t,e):null}function ui(r,e){return r[`__lexicalKey_${e._key}`]}function en(r,e){let t=r;for(;t!=null;){const n=Lu(t,e);if(n!==null)return n;t=Yn(t)}return null}function Pu(r){const e=r._decorators,t=Object.assign({},e);return r._pendingDecorators=t,t}function Ma(r){return r.read(()=>Ze().getTextContent())}function Ze(){return Iu(or())}function Iu(r){return r._nodeMap.get("root")}function Gt(r){wt();const e=or();r!==null&&(r.dirty=!0,r.setCachedNodes(null)),e._selection=r}function Hr(r){const e=rt(),t=function(n,s){let i=n;for(;i!=null;){const o=ui(i,s);if(o!==void 0)return o;i=Yn(i)}return null}(r,e);return t===null?r===e.getRootElement()?pt("root"):null:pt(t)}function Ra(r,e){return e?r.getTextContentSize():0}function zu(r){return/[\uD800-\uDBFF][\uDC00-\uDFFF]/g.test(r)}function Vo(r){const e=[];let t=r;for(;t!==null;)e.push(t),t=t._parentEditor;return e}function Ou(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function $u(r){return r.nodeType===yr?r.nodeValue:null}function Go(r,e,t){const n=Bt(e._window);if(n===null)return;const s=n.anchorNode;let{anchorOffset:i,focusOffset:o}=n;if(s!==null){let a=$u(s);const l=en(s);if(a!==null&&ee(l)){if(a===ai&&t){const u=t.length;a=t,i=u,o=u}a!==null&&Ko(l,a,i,o,r)}}}function Ko(r,e,t,n,s){let i=r;if(i.isAttached()&&(s||!i.isDirty())){const o=i.isComposing();let a=e;(o||s)&&e[e.length-1]===ai&&(a=e.slice(0,-1));const l=i.getTextContent();if(s||a!==l){if(a===""){if(ht(null),oi||Vn||Fo)i.remove();else{const m=rt();setTimeout(()=>{m.update(()=>{i.isAttached()&&i.remove()})},20)}return}const u=i.getParent(),c=Zn(),d=i.getTextContentSize(),h=fr(),p=i.getKey();if(i.isToken()||h!==null&&p===h&&!o||V(c)&&(u!==null&&!u.canInsertTextBefore()&&c.anchor.offset===0||c.anchor.key===r.__key&&c.anchor.offset===0&&!i.canInsertTextBefore()&&!o||c.focus.key===r.__key&&c.focus.offset===d&&!i.canInsertTextAfter()&&!o))return void i.markDirty();const g=ae();if(!V(g)||t===null||n===null)return void i.setTextContent(a);if(g.setTextNodeRange(i,t,i,n),i.isSegmented()){const m=lt(i.getTextContent());i.replace(m),i=m}i.setTextContent(a)}}}function yh(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(i){const o=i.getPreviousSibling();return(ee(o)||$(o)&&o.isInline())&&!o.canInsertTextAfter()}(e):t===e.getTextContentSize()&&(!e.canInsertTextAfter()||!n.canInsertTextAfter()&&!e.isComposing()||s)}function Fa(r){return r==="ArrowLeft"}function La(r){return r==="ArrowRight"}function vn(r,e){return jt?r:e}function Pa(r){return r==="Enter"}function fn(r){return r==="Backspace"}function hn(r){return r==="Delete"}function Ia(r,e,t){return r.toLowerCase()==="a"&&vn(e,t)}function xh(){const r=Ze();Gt(Mu(r.select(0,r.getChildrenSize())))}function An(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 i=Rs(s);return t[e]=i,i}return s}function Yo(r,e,t,n,s){if(t.size===0)return;const i=n.__type,o=n.__key,a=e.get(i);a===void 0&&K(33,i);const l=a.klass;let u=r.get(l);u===void 0&&(u=new Map,r.set(l,u));const c=u.get(o),d=c==="destroyed"&&s==="created";(c===void 0||d)&&u.set(o,d?"updated":s)}function za(r,e,t){const n=r.getParent();let s=t,i=r;return n!==null&&(e&&t===0?(s=i.getIndexWithinParent(),i=n):e||t!==i.getChildrenSize()||(s=i.getIndexWithinParent()+1,i=n)),i.getChildAtIndex(e?s-1:s)}function Pn(r,e){const t=r.offset;if(r.type==="element")return za(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?za(n.getParentOrThrow(),e,n.getIndexWithinParent()+(e?0:1)):s}}return null}function qu(r){const e=di(r).event,t=e&&e.inputType;return t==="insertFromPaste"||t==="insertFromPasteAsQuotation"}function ie(r,e,t){return fc(r,e,t)}function ci(r){return!yt(r)&&!r.isLastChild()&&!r.isInline()}function Is(r,e){const t=r._keyToDOMMap.get(e);return t===void 0&&K(75,e),t}function Yn(r){const e=r.assignedSlot||r.parentElement;return e!==null&&e.nodeType===11?e.host:e}function Tn(r,e){let t=r.getParent();for(;t!==null;){if(t.is(e))return!0;t=t.getParent()}return!1}function di(r){const e=r._window;return e===null&&K(78),e}function bh(r){let e=r.getParentOrThrow();for(;e!==null;){if(Kt(e))return e;e=e.getParentOrThrow()}return e}function Kt(r){return yt(r)||$(r)&&r.isShadowRoot()}function Qt(r){const e=rt(),t=r.constructor.getType(),n=e._nodes.get(t);n===void 0&&K(200,r.constructor.name,t);const{replace:s,replaceWithKlass:i}=n;if(s!==null){const o=s(r),a=o.constructor;return i!==null?o instanceof i||K(201,i.name,i.getType(),a.name,a.getType(),r.constructor.name,t):o instanceof r.constructor&&a!==r.constructor||K(202,a.name,a.getType(),r.constructor.name,t),o.__key===r.__key&&K(203,r.constructor.name,t,a.name,a.getType()),o}return r}function ji(r,e){!yt(r.getParent())||$(e)||Ge(e)||K(99)}function Mi(r){return(Ge(r)||$(r)&&!r.canBeEmpty())&&!r.isInline()}function Qo(r,e,t){t.style.removeProperty("caret-color"),e._blockCursorElement=null;const n=r.parentElement;n!==null&&n.removeChild(r)}function vh(r,e,t){let n=r._blockCursorElement;if(V(t)&&t.isCollapsed()&&t.anchor.type==="element"&&e.contains(document.activeElement)){const s=t.anchor,i=s.getNode(),o=s.offset;let a=!1,l=null;if(o===i.getChildrenSize())Mi(i.getChildAtIndex(o-1))&&(a=!0);else{const u=i.getChildAtIndex(o);if(u!==null&&Mi(u)){const c=u.getPreviousSibling();(c===null||Mi(c))&&(a=!0,l=r.getElementByKey(u.__key))}}if(a){const u=r.getElementByKey(i.__key);return n===null&&(r._blockCursorElement=n=function(c){const d=c.theme,h=document.createElement("div");h.contentEditable="false",h.setAttribute("data-lexical-cursor","true");let p=d.blockCursor;if(p!==void 0){if(typeof p=="string"){const g=Rs(p);p=d.blockCursor=g}p!==void 0&&h.classList.add(...p)}return h}(r._config)),e.style.caretColor="transparent",void(l===null?u.appendChild(n):u.insertBefore(n,l))}}n!==null&&Qo(n,r,e)}function Bt(r){return Ot?(r||window).getSelection():null}function _h(r){return ir(r)&&r.tagName==="A"}function ir(r){return r.nodeType===1}function Oa(r){return r.nodeType===11}function Ji(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 zs(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 ur(r){if(Ge(r)&&!r.isInline())return!0;if(!$(r)||Kt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||ee(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function pn(r,e){let t=r;for(;t!==null&&t.getParent()!==null&&!e(t);)t=t.getParentOrThrow();return e(t)?t:null}function wh(){return rt()}const $a=new WeakMap,Ch=new Map;function Sh(r){if(!r._readOnly&&r.isEmpty())return Ch;r._readOnly||K(192);let e=$a.get(r);if(!e){e=new Map,$a.set(r,e);for(const[t,n]of r._nodeMap){const s=n.__type;let i=e.get(s);i||(i=new Map,e.set(s,i)),i.set(t,n)}}return e}function Jo(r){const e=r.constructor.clone(r);return e.afterCloneFrom(r),e}function Xo(r,e){const t=(parseInt(r.style.paddingInlineStart,10)||0)/40;e.setIndent(t)}function kh(r){return r.__lexicalUnmanaged===!0}function Uu(r,e,t,n,s,i){let o=r.getFirstChild();for(;o!==null;){const a=o.__key;o.__parent===e&&($(o)&&Uu(o,a,t,n,s,i),t.has(a)||i.delete(a),s.push(a)),o=o.getNextSibling()}}let mr,xt,In,fi,Xi,Zi,jr,It,eo,zn,ut="",mt="",qt=null,Mt="",tr="",Wu=!1,On=!1,_s=null;function Os(r,e){const t=jr.get(r);if(e!==null){const n=no(r);n.parentNode===e&&e.removeChild(n)}if(It.has(r)||xt._keyToDOMMap.delete(r),$(t)){const n=qs(t,jr);to(n,0,n.length-1,null)}t!==void 0&&Yo(zn,In,fi,t,"destroyed")}function to(r,e,t,n){let s=e;for(;s<=t;++s){const i=r[s];i!==void 0&&Os(i,n)}}function _r(r,e){r.setProperty("text-align",e)}const Eh="40px";function Hu(r,e){const t=mr.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")||Eh;r.style.setProperty("padding-inline-start",e===0?"":`calc(${e} * ${n})`)}function Vu(r,e){const t=r.style;e===0?_r(t,""):e===Po?_r(t,"left"):e===Io?_r(t,"center"):e===zo?_r(t,"right"):e===Oo?_r(t,"justify"):e===$o?_r(t,"start"):e===qo&&_r(t,"end")}function $s(r,e){const t=It.get(r);t===void 0&&K(60);const n=t.createDOM(mr,xt);if(function(s,i,o){const a=o._keyToDOMMap;(function(l,u,c){l[`__lexicalKey_${u._key}`]=c})(i,o,s),a.set(s,i)}(r,n,xt),ee(t)?n.setAttribute("data-lexical-text","true"):Ge(t)&&n.setAttribute("data-lexical-decorator","true"),$(t)){const s=t.__indent,i=t.__size;if(s!==0&&Hu(n,s),i!==0){const a=i-1;(function(l,u,c,d){const h=mt;mt="",ro(l,c,0,u,c.getDOMSlot(d)),Ku(c,d),mt=h})(qs(t,It),a,t,n)}const o=t.__format;o!==0&&Vu(n,o),t.isInline()||Gu(null,t,n),ci(t)&&(ut+=nr,tr+=nr)}else{const s=t.getTextContent();if(Ge(t)){const i=t.decorate(xt,mr);i!==null&&Yu(r,i),n.contentEditable="false"}else ee(t)&&(t.isDirectionless()||(mt+=s));ut+=s,tr+=s}return e!==null&&e.insertChild(n),Yo(zn,In,fi,t,"created"),n}function ro(r,e,t,n,s){const i=ut;ut="";let o=t;for(;o<=n;++o){$s(r[o],s);const a=It.get(r[o]);a!==null&&ee(a)&&(qt===null&&(qt=a.getFormat()),Mt===""&&(Mt=a.getStyle()))}ci(e)&&(ut+=nr),s.element.__lexicalTextContent=ut,ut=i+ut}function qa(r,e){if(r){const t=r.__last;if(t){const n=e.get(t);if(n)return Ar(n)?"line-break":Ge(n)&&n.isInline()?"decorator":null}return"empty"}return null}function Gu(r,e,t){const n=qa(r,jr),s=qa(e,It);n!==s&&e.getDOMSlot(t).setManagedLineBreak(s)}function Ku(r,e){const t=e.__lexicalDirTextContent||"",n=e.__lexicalDir||"";if(t!==mt||n!==_s){const i=mt==="",o=i?_s:(s=mt,th.test(s)?"rtl":rh.test(s)?"ltr":null);if(o!==n){const a=e.classList,l=mr.theme;let u=n!==null?l[n]:void 0,c=o!==null?l[o]:void 0;if(u!==void 0){if(typeof u=="string"){const d=Rs(u);u=l[n]=d}a.remove(...u)}if(o===null||i&&o==="ltr")e.removeAttribute("dir");else{if(c!==void 0){if(typeof c=="string"){const d=Rs(c);c=l[o]=d}c!==void 0&&a.add(...c)}e.dir=o}On||(r.getWritable().__dir=o)}_s=o,e.__lexicalDirTextContent=mt,e.__lexicalDir=o}var s}function Dh(r,e,t){const n=mt;var s;mt="",qt=null,Mt="",function(i,o,a){const l=ut,u=i.__size,c=o.__size;ut="";const d=a.element;if(u===1&&c===1){const h=i.__first,p=o.__first;if(h===p)_n(h,d);else{const m=no(h),x=$s(p,null);try{d.replaceChild(x,m)}catch(_){if(typeof _=="object"&&_!=null){const b=`${_.toString()} Parent: ${d.tagName}, new child: {tag: ${x.tagName} key: ${p}}, old child: {tag: ${m.tagName}, key: ${h}}.`;throw new Error(b)}throw _}Os(h,null)}const g=It.get(p);ee(g)&&(qt===null&&(qt=g.getFormat()),Mt===""&&(Mt=g.getStyle()))}else{const h=qs(i,jr),p=qs(o,It);if(h.length!==u&&K(227),p.length!==c&&K(228),u===0)c!==0&&ro(p,o,0,c-1,a);else if(c===0){if(u!==0){const g=a.after==null&&a.before==null&&a.element.__lexicalLineBreak==null;to(h,0,u-1,g?null:d),g&&(d.textContent="")}}else(function(g,m,x,_,b,S){const C=_-1,k=b-1;let E,v,T=S.getFirstChild(),B=0,j=0;for(;B<=C&&j<=k;){const M=m[B],w=x[j];if(M===w)T=Ri(_n(w,S.element)),B++,j++;else{E===void 0&&(E=new Set(m)),v===void 0&&(v=new Set(x));const F=v.has(M),z=E.has(w);if(F)if(z){const q=Is(xt,w);q===T?T=Ri(_n(w,S.element)):(S.withBefore(T).insertChild(q),_n(w,S.element)),B++,j++}else $s(w,S.withBefore(T)),j++;else T=Ri(no(M)),Os(M,S.element),B++}const D=It.get(w);D!==null&&ee(D)&&(qt===null&&(qt=D.getFormat()),Mt===""&&(Mt=D.getStyle()))}const N=B>C,R=j>k;if(N&&!R){const M=x[k+1],w=M===void 0?null:xt.getElementByKey(M);ro(x,g,j,k,S.withBefore(w))}else R&&!N&&to(m,B,C,S.element)})(o,h,p,u,c,a)}ci(o)&&(ut+=nr),d.__lexicalTextContent=ut,ut=l+ut}(r,e,e.getDOMSlot(t)),Ku(e,t),tn(s=e)&&qt!=null&&qt!==s.__textFormat&&!On&&(s.setTextFormat(qt),s.setTextStyle(Mt)),function(i){tn(i)&&Mt!==""&&Mt!==i.__textStyle&&!On&&i.setTextStyle(Mt)}(e),mt=n}function qs(r,e){const t=[];let n=r.__first;for(;n!==null;){const s=e.get(n);s===void 0&&K(101),t.push(n),n=s.__next}return t}function _n(r,e){const t=jr.get(r);let n=It.get(r);t!==void 0&&n!==void 0||K(61);const s=Wu||Zi.has(r)||Xi.has(r),i=Is(xt,r);if(t===n&&!s){if($(t)){const o=i.__lexicalTextContent;o!==void 0&&(ut+=o,tr+=o);const a=i.__lexicalDirTextContent;a!==void 0&&(mt+=a)}else{const o=t.getTextContent();ee(t)&&!t.isDirectionless()&&(mt+=o),tr+=o,ut+=o}return i}if(t!==n&&s&&Yo(zn,In,fi,n,"updated"),n.updateDOM(t,i,mr)){const o=$s(r,null);return e===null&&K(62),e.replaceChild(o,i),Os(r,null),o}if($(t)&&$(n)){const o=n.__indent;o!==t.__indent&&Hu(i,o);const a=n.__format;a!==t.__format&&Vu(i,a),s&&(Dh(t,n,i),yt(n)||n.isInline()||Gu(t,n,i)),ci(n)&&(ut+=nr,tr+=nr)}else{const o=n.getTextContent();if(Ge(n)){const a=n.decorate(xt,mr);a!==null&&Yu(r,a)}else ee(n)&&!n.isDirectionless()&&(mt+=o);ut+=o,tr+=o}if(!On&&yt(n)&&n.__cachedText!==tr){const o=n.getWritable();o.__cachedText=tr,n=o}return i}function Yu(r,e){let t=xt._pendingDecorators;const n=xt._decorators;if(t===null){if(n[r]===e)return;t=Pu(xt)}t[r]=e}function Ri(r){let e=r.nextSibling;return e!==null&&e===xt._blockCursorElement&&(e=e.nextSibling),e}function Ah(r,e,t,n,s,i){ut="",tr="",mt="",Wu=n===Zr,_s=null,xt=t,mr=t._config,In=t._nodes,fi=xt._listeners.mutation,Xi=s,Zi=i,jr=r._nodeMap,It=e._nodeMap,On=e._readOnly,eo=new Map(t._keyToDOMMap);const o=new Map;return zn=o,_n("root",null),xt=void 0,In=void 0,Xi=void 0,Zi=void 0,jr=void 0,It=void 0,mr=void 0,eo=void 0,zn=void 0,o}function no(r){const e=eo.get(r);return e===void 0&&K(75,r),e}const Zt=Object.freeze({}),so=30,io=[["keydown",function(r,e){if(Nn=r.timeStamp,Qu=r.key,e.isComposing())return;const{key:t,shiftKey:n,ctrlKey:s,metaKey:i,altKey:o}=r;if(!ie(e,Mf,r)&&t!=null){if(function(a,l,u,c){return La(a)&&!l&&!c&&!u}(t,s,o,i))ie(e,mu,r);else if(function(a,l,u,c,d){return La(a)&&!c&&!u&&(l||d)}(t,s,n,o,i))ie(e,Rf,r);else if(function(a,l,u,c){return Fa(a)&&!l&&!c&&!u}(t,s,o,i))ie(e,yu,r);else if(function(a,l,u,c,d){return Fa(a)&&!c&&!u&&(l||d)}(t,s,n,o,i))ie(e,Ff,r);else if(function(a,l,u){return function(c){return c==="ArrowUp"}(a)&&!l&&!u}(t,s,i))ie(e,xu,r);else if(function(a,l,u){return function(c){return c==="ArrowDown"}(a)&&!l&&!u}(t,s,i))ie(e,bu,r);else if(function(a,l){return Pa(a)&&l}(t,n))Bn=!0,ie(e,Ns,r);else if(function(a){return a===" "}(t))ie(e,Lf,r);else if(function(a,l){return jt&&l&&a.toLowerCase()==="o"}(t,s))r.preventDefault(),Bn=!0,ie(e,Kr,!0);else if(function(a,l){return Pa(a)&&!l}(t,n))Bn=!1,ie(e,Ns,r);else if(function(a,l,u,c){return jt?!l&&!u&&(fn(a)||a.toLowerCase()==="h"&&c):!(c||l||u)&&fn(a)}(t,o,i,s))fn(t)?ie(e,vu,r):(r.preventDefault(),ie(e,Er,!0));else if(function(a){return a==="Escape"}(t))ie(e,_u,r);else if(function(a,l,u,c,d){return jt?!(u||c||d)&&(hn(a)||a.toLowerCase()==="d"&&l):!(l||c||d)&&hn(a)}(t,s,n,o,i))hn(t)?ie(e,wu,r):(r.preventDefault(),ie(e,Er,!1));else if(function(a,l,u){return fn(a)&&(jt?l:u)}(t,o,s))r.preventDefault(),ie(e,Fn,!0);else if(function(a,l,u){return hn(a)&&(jt?l:u)}(t,o,s))r.preventDefault(),ie(e,Fn,!1);else if(function(a,l){return jt&&l&&fn(a)}(t,i))r.preventDefault(),ie(e,Ln,!0);else if(function(a,l){return jt&&l&&hn(a)}(t,i))r.preventDefault(),ie(e,Ln,!1);else if(function(a,l,u,c){return a.toLowerCase()==="b"&&!l&&vn(u,c)}(t,o,i,s))r.preventDefault(),ie(e,Pt,"bold");else if(function(a,l,u,c){return a.toLowerCase()==="u"&&!l&&vn(u,c)}(t,o,i,s))r.preventDefault(),ie(e,Pt,"underline");else if(function(a,l,u,c){return a.toLowerCase()==="i"&&!l&&vn(u,c)}(t,o,i,s))r.preventDefault(),ie(e,Pt,"italic");else if(function(a,l,u,c){return a==="Tab"&&!l&&!u&&!c}(t,o,s,i))ie(e,Pf,r);else if(function(a,l,u,c){return a.toLowerCase()==="z"&&!l&&vn(u,c)}(t,n,i,s))r.preventDefault(),ie(e,jo,void 0);else if(function(a,l,u,c){return jt?a.toLowerCase()==="z"&&u&&l:a.toLowerCase()==="y"&&c||a.toLowerCase()==="z"&&c&&l}(t,n,i,s))r.preventDefault(),ie(e,Mo,void 0);else{const a=e._editorState._selection;a===null||V(a)?!gr&&Ia(t,i,s)&&(r.preventDefault(),ie(e,Yi,r)):function(l,u,c,d){return!u&&l.toLowerCase()==="c"&&(jt?c:d)}(t,n,i,s)?(r.preventDefault(),ie(e,ii,r)):function(l,u,c,d){return!u&&l.toLowerCase()==="x"&&(jt?c:d)}(t,n,i,s)?(r.preventDefault(),ie(e,Ro,r)):Ia(t,i,s)&&(r.preventDefault(),ie(e,Yi,r))}(function(a,l,u,c){return a||l||u||c})(s,n,o,i)&&ie(e,Vf,r)}}],["pointerdown",function(r,e){const t=r.target,n=r.pointerType;t instanceof Node&&n!=="touch"&&Dt(e,()=>{Ge(en(t))||(ao=!0)})}],["compositionstart",function(r,e){Dt(e,()=>{const t=ae();if(V(t)&&!e.isComposing()){const n=t.anchor,s=t.anchor.getNode();ht(n.key),(r.timeStamp<Nn+so||n.type==="element"||!t.isCollapsed()||s.getFormat()!==t.format||ee(s)&&s.getStyle()!==t.style)&&ie(e,Yr,eh)}})}],["compositionend",function(r,e){gr?gn=!0:Dt(e,()=>{Fi(e,r.data)})}],["input",function(r,e){r.stopPropagation(),Dt(e,()=>{const t=ae(),n=r.data,s=ec(r);if(n!=null&&V(t)&&Zu(t,s,n,r.timeStamp,!1)){gn&&(Fi(e,n),gn=!1);const i=t.anchor.getNode(),o=Bt(e._window);if(o===null)return;const a=t.isBackward(),l=a?t.anchor.offset:t.focus.offset,u=a?t.focus.offset:t.anchor.offset;Bs&&!t.isCollapsed()&&ee(i)&&o.anchorNode!==null&&i.getTextContent().slice(0,l)+n+i.getTextContent().slice(l+u)===$u(o.anchorNode)||ie(e,Yr,n);const c=n.length;gr&&c>1&&r.inputType==="insertCompositionText"&&!e.isComposing()&&(t.anchor.offset-=c),oi||Vn||Fo||!e.isComposing()||(Nn=0,ht(null))}else Go(!1,e,n!==null?n:void 0),gn&&(Fi(e,n||void 0),gn=!1);wt(),Bu(rt())}),Wr=null}],["click",function(r,e){Dt(e,()=>{const t=ae(),n=Bt(e._window),s=Zn();if(n){if(V(t)){const i=t.anchor,o=i.getNode();i.type==="element"&&i.offset===0&&t.isCollapsed()&&!yt(o)&&Ze().getChildrenSize()===1&&o.getTopLevelElementOrThrow().isEmpty()&&s!==null&&t.is(s)?(n.removeAllRanges(),t.dirty=!0):r.detail===3&&!t.isCollapsed()&&o!==t.focus.getNode()&&($(o)?o.select(0):o.getParentOrThrow().select(0))}else if(r.pointerType==="touch"){const i=n.anchorNode;if(i!==null){const o=i.nodeType;(o===Gn||o===yr)&&Gt(ea(s,n,e,r))}}}ie(e,gu,r)})}],["cut",Zt],["copy",Zt],["dragstart",Zt],["dragover",Zt],["dragend",Zt],["paste",Zt],["focus",Zt],["blur",Zt],["drop",Zt]];Bs&&io.push(["beforeinput",(r,e)=>function(t,n){const s=t.inputType,i=ec(t);s==="deleteCompositionText"||gr&&qu(n)||s!=="insertCompositionText"&&Dt(n,()=>{const o=ae();if(s==="deleteContentBackward"){if(o===null){const p=Zn();if(!V(p))return;Gt(p.clone())}if(V(o)){const p=o.anchor.key===o.focus.key;if(a=t.timeStamp,Qu==="MediaLast"&&a<Nn+so&&n.isComposing()&&p){if(ht(null),Nn=0,setTimeout(()=>{Dt(n,()=>{ht(null)})},so),V(o)){const g=o.anchor.getNode();g.markDirty(),o.format=g.getFormat(),ee(g)||K(142),o.style=g.getStyle()}}else{ht(null),t.preventDefault();const g=o.anchor.getNode(),m=g.getTextContent(),x=g.canInsertTextAfter(),_=o.anchor.offset===0&&o.focus.offset===m.length;Yf&&p&&!_&&x||ie(n,Er,!0)}return}}var a;if(!V(o))return;const l=t.data;Wr!==null&&Go(!1,n,Wr),o.dirty&&Wr===null||!o.isCollapsed()||yt(o.anchor.getNode())||i===null||o.applyDOMRange(i),Wr=null;const u=o.anchor,c=o.focus,d=u.getNode(),h=c.getNode();if(s!=="insertText"&&s!=="insertTranspose")switch(t.preventDefault(),s){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":ie(n,Yr,t);break;case"insertFromComposition":ht(null),ie(n,Yr,t);break;case"insertLineBreak":ht(null),ie(n,Kr,!1);break;case"insertParagraph":ht(null),Bn&&!Vn?(Bn=!1,ie(n,Kr,!1)):ie(n,Rn,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":ie(n,si,t);break;case"deleteByComposition":(function(p,g){return p!==g||$(p)||$(g)||!p.isToken()||!g.isToken()})(d,h)&&ie(n,Ki,t);break;case"deleteByDrag":case"deleteByCut":ie(n,Ki,t);break;case"deleteContent":ie(n,Er,!1);break;case"deleteWordBackward":ie(n,Fn,!0);break;case"deleteWordForward":ie(n,Fn,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":ie(n,Ln,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":ie(n,Ln,!1);break;case"formatStrikeThrough":ie(n,Pt,"strikethrough");break;case"formatBold":ie(n,Pt,"bold");break;case"formatItalic":ie(n,Pt,"italic");break;case"formatUnderline":ie(n,Pt,"underline");break;case"historyUndo":ie(n,jo,void 0);break;case"historyRedo":ie(n,Mo,void 0)}else{if(l===`
86
+ `)t.preventDefault(),ie(n,Kr,!1);else if(l===nr)t.preventDefault(),ie(n,Rn,void 0);else if(l==null&&t.dataTransfer){const p=t.dataTransfer.getData("text/plain");t.preventDefault(),o.insertRawText(p)}else l!=null&&Zu(o,i,l,t.timeStamp,!0)?(t.preventDefault(),ie(n,Yr,l)):Wr=l;Ju=t.timeStamp}})}(r,e)]);let Nn=0,Qu=null,Ju=0,Wr=null;const Us=new WeakMap;let oo=!1,ao=!1,Bn=!1,gn=!1,Xu=[0,"",0,"root",0];function Zu(r,e,t,n,s){const i=r.anchor,o=r.focus,a=i.getNode(),l=rt(),u=Bt(l._window),c=u!==null?u.anchorNode:null,d=i.key,h=l.getElementByKey(d),p=t.length;return d!==o.key||!ee(a)||(!s&&(!Bs||Ju<n+50)||a.isDirty()&&p<2||zu(t))&&i.offset!==o.offset&&!a.isComposing()||Cr(a)||a.isDirty()&&p>1||(s||!Bs)&&h!==null&&!a.isComposing()&&c!==Fs(h)||u!==null&&e!==null&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||a.getFormat()!==r.format||a.getStyle()!==r.style||yh(r,a)}function Ua(r,e){return r!==null&&r.nodeValue!==null&&r.nodeType===yr&&e!==0&&e!==r.nodeValue.length}function Wa(r,e,t){const{anchorNode:n,anchorOffset:s,focusNode:i,focusOffset:o}=r;oo&&(oo=!1,Ua(n,s)&&Ua(i,o))||Dt(e,()=>{if(!t)return void Gt(null);if(!Kn(e,n,i))return;const a=ae();if(V(a)){const l=a.anchor,u=l.getNode();if(a.isCollapsed()){r.type==="Range"&&r.anchorNode===r.focusNode&&(a.dirty=!0);const c=di(e).event,d=c?c.timeStamp:performance.now(),[h,p,g,m,x]=Xu,_=Ze(),b=e.isComposing()===!1&&_.getTextContent()==="";if(d<x+200&&l.offset===g&&l.key===m)a.format=h,a.style=p;else if(l.type==="text")ee(u)||K(141),a.format=u.getFormat(),a.style=u.getStyle();else if(l.type==="element"&&!b){const S=l.getNode();a.style="",S instanceof on&&S.getChildrenSize()===0?(a.format=S.getTextFormat(),a.style=S.getTextStyle()):a.format=0}}else{const c=l.key,d=a.focus.key,h=a.getNodes(),p=h.length,g=a.isBackward(),m=g?o:s,x=g?s:o,_=g?d:c,b=g?c:d;let S=Zf,C=!1;for(let k=0;k<p;k++){const E=h[k],v=E.getTextContentSize();if(ee(E)&&v!==0&&!(k===0&&E.__key===_&&m===v||k===p-1&&E.__key===b&&x===0)&&(C=!0,S&=E.getFormat(),S===0))break}a.format=C?S:0}}ie(e,Bo,void 0)})}function ec(r){if(!r.getTargetRanges)return null;const e=r.getTargetRanges();return e.length===0?null:e[0]}function Fi(r,e){const t=r._compositionKey;if(ht(null),t!==null&&e!=null){if(e===""){const n=pt(t),s=Fs(r.getElementByKey(t));return void(s!==null&&s.nodeValue!==null&&ee(n)&&Ko(n,s.nodeValue,null,null,!0))}if(e[e.length-1]===`
87
+ `){const n=ae();if(V(n)){const s=n.focus;return n.anchor.set(s.key,s.offset,s.type),void ie(r,Ns,null)}}}Go(!0,r,e)}function tc(r){let e=r.__lexicalEventHandles;return e===void 0&&(e=[],r.__lexicalEventHandles=e),e}const Qr=new Map;function rc(r){const e=r.target,t=Bt(e==null?null:e.nodeType===9?e.defaultView:e.ownerDocument.defaultView);if(t===null)return;const n=Ru(t.anchorNode);if(n===null)return;ao&&(ao=!1,Dt(n,()=>{const u=Zn(),c=t.anchorNode;if(c===null)return;const d=c.nodeType;d!==Gn&&d!==yr||Gt(ea(u,t,n,r))}));const s=Vo(n),i=s[s.length-1],o=i._key,a=Qr.get(o),l=a||i;l!==n&&Wa(t,l,!1),Wa(t,n,!0),n!==i?Qr.set(o,n):a&&Qr.delete(o)}function Ha(r){r._lexicalHandled=!0}function Va(r){return r._lexicalHandled===!0}function Th(r){const e=r.ownerDocument,t=Us.get(e);t===void 0&&K(162);const n=t-1;n>=0||K(164),Us.set(e,n),n===0&&e.removeEventListener("selectionchange",rc);const s=li(r);Ho(s)?(function(o){if(o._parentEditor!==null){const a=Vo(o),l=a[a.length-1]._key;Qr.get(l)===o&&Qr.delete(l)}else Qr.delete(o._key)}(s),r.__lexicalEditor=null):s&&K(198);const i=tc(r);for(let o=0;o<i.length;o++)i[o]();r.__lexicalEventHandles=[]}function lo(r,e,t){wt();const n=r.__key,s=r.getParent();if(s===null)return;const i=function(a){const l=ae();if(!V(l)||!$(a))return l;const{anchor:u,focus:c}=l,d=u.getNode(),h=c.getNode();return Tn(d,a)&&u.set(a.__key,0,"element"),Tn(h,a)&&c.set(a.__key,0,"element"),l}(r);let o=!1;if(V(i)&&e){const a=i.anchor,l=i.focus;a.key===n&&(Hs(a,r,s,r.getPreviousSibling(),r.getNextSibling()),o=!0),l.key===n&&(Hs(l,r,s,r.getPreviousSibling(),r.getNextSibling()),o=!0)}else Ut(i)&&e&&r.isSelected()&&r.selectPrevious();if(V(i)&&e&&!o){const a=r.getIndexWithinParent();Dr(r),Ws(i,s,a,-1)}else Dr(r);t||Kt(s)||s.canBeEmpty()||!s.isEmpty()||lo(s,e),e&&yt(s)&&s.isEmpty()&&s.selectEnd()}class hi{static getType(){K(64,this.name)}static clone(e){K(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,mh(this,e)}getType(){return this.__type}isInline(){K(137,this.constructor.name)}isAttached(){let e=this.__key;for(;e!==null;){if(e==="root")return!0;const t=pt(e);if(t===null)break;e=t.__parent}return!1}isSelected(e){const t=e||ae();if(t==null)return!1;const n=t.getNodes().some(s=>s.__key===this.__key);if(ee(this))return n;if(V(t)&&t.anchor.type==="element"&&t.focus.type==="element"){if(t.isCollapsed())return!1;const s=this.getParent();if(Ge(this)&&this.isInline()&&s){const i=t.isBackward()?t.focus:t.anchor,o=i.getNode();if(i.offset===o.getChildrenSize()&&o.is(s)&&o.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:pt(e)}getParentOrThrow(){const e=this.getParent();return e===null&&K(66,this.__key),e}getTopLevelElement(){let e=this;for(;e!==null;){const t=e.getParent();if(Kt(t))return $(e)||e===this&&Ge(e)||K(194),e;e=t}return null}getTopLevelElementOrThrow(){const e=this.getTopLevelElement();return e===null&&K(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:pt(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:pt(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();$(this)&&t.unshift(this),$(e)&&n.unshift(e);const s=t.length,i=n.length;if(s===0||i===0||t[s-1]!==n[i-1])return null;const o=new Set(n);for(let a=0;a<s;a++){const l=t[a];if(o.has(l))return l}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,i=this;for(;;){const o=i.getParentOrThrow();if(o===t){n=i.getIndexWithinParent();break}i=o}for(i=e;;){const o=i.getParentOrThrow();if(o===t){s=i.getIndexWithinParent();break}i=o}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 i=this;for(;i!==null;){const o=i.__key;if(s.has(o)||(s.add(o),n.push(i)),i===e)break;const a=$(i)?t?i.getFirstChild():i.getLastChild():null;if(a!==null){i=a;continue}const l=t?i.getNextSibling():i.getPreviousSibling();if(l!==null){i=l;continue}const u=i.getParentOrThrow();if(s.has(u.__key)||n.push(u),u===e)break;let c=null,d=u;do{if(d===null&&K(68),c=t?d.getNextSibling():d.getPreviousSibling(),d=d.getParent(),d===null)break;c!==null||s.has(d.__key)||n.push(d)}while(c===null);i=c}return t||n.reverse(),n}isDirty(){const e=rt()._dirtyLeaves;return e!==null&&e.has(this.__key)}getLatest(){const e=pt(this.__key);return e===null&&K(113),e}getWritable(){wt();const e=or(),t=rt(),n=e._nodeMap,s=this.__key,i=this.getLatest(),o=t._cloneNotNeeded,a=ae();if(a!==null&&a.setCachedNodes(null),o.has(s))return Ps(i),i;const l=Jo(i);return o.add(s),Ps(l),n.set(s,l),l}getTextContent(){return""}getTextContentSize(){return this.getTextContent().length}createDOM(e,t){K(70)}updateDOM(e,t,n){K(71)}exportDOM(e){return{element:this.createDOM(e._config,e)}}exportJSON(){K(72)}static importJSON(e){K(18,this.name)}static transform(){return null}remove(e){lo(this,!0,e)}replace(e,t){wt();let n=ae();n!==null&&(n=n.clone()),ji(this,e);const s=this.getLatest(),i=this.__key,o=e.__key,a=e.getWritable(),l=this.getParentOrThrow().getWritable(),u=l.__size;Dr(a);const c=s.getPreviousSibling(),d=s.getNextSibling(),h=s.__prev,p=s.__next,g=s.__parent;if(lo(s,!1,!0),c===null?l.__first=o:c.getWritable().__next=o,a.__prev=h,d===null?l.__last=o:d.getWritable().__prev=o,a.__next=p,a.__parent=g,l.__size=u,t&&($(this)&&$(a)||K(139),this.getChildren().forEach(m=>{a.append(m)})),V(n)){Gt(n);const m=n.anchor,x=n.focus;m.key===i&&Qa(m,a),x.key===i&&Qa(x,a)}return fr()===i&&ht(o),a}insertAfter(e,t=!0){wt(),ji(this,e);const n=this.getWritable(),s=e.getWritable(),i=s.getParent(),o=ae();let a=!1,l=!1;if(i!==null){const p=e.getIndexWithinParent();if(Dr(s),V(o)){const g=i.__key,m=o.anchor,x=o.focus;a=m.type==="element"&&m.key===g&&m.offset===p+1,l=x.type==="element"&&x.key===g&&x.offset===p+1}}const u=this.getNextSibling(),c=this.getParentOrThrow().getWritable(),d=s.__key,h=n.__next;if(u===null?c.__last=d:u.getWritable().__prev=d,c.__size++,n.__next=d,s.__next=h,s.__prev=n.__key,s.__parent=n.__parent,t&&V(o)){const p=this.getIndexWithinParent();Ws(o,c,p+1);const g=c.__key;a&&o.anchor.set(g,p+2,"element"),l&&o.focus.set(g,p+2,"element")}return e}insertBefore(e,t=!0){wt(),ji(this,e);const n=this.getWritable(),s=e.getWritable(),i=s.__key;Dr(s);const o=this.getPreviousSibling(),a=this.getParentOrThrow().getWritable(),l=n.__prev,u=this.getIndexWithinParent();o===null?a.__first=i:o.getWritable().__next=i,a.__size++,n.__prev=i,s.__prev=l,s.__next=n.__key,s.__parent=n.__parent;const c=ae();return t&&V(c)&&Ws(c,this.getParentOrThrow(),u),e}isParentRequired(){return!1}createParentElementNode(){return ot()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(e,t){wt();const n=this.getPreviousSibling(),s=this.getParentOrThrow();if(n===null)return s.select(0,0);if($(n))return n.select();if(!ee(n)){const i=n.getIndexWithinParent()+1;return s.select(i,i)}return n.select(e,t)}selectNext(e,t){wt();const n=this.getNextSibling(),s=this.getParentOrThrow();if(n===null)return s.select();if($(n))return n.select(0,0);if(!ee(n)){const i=n.getIndexWithinParent();return s.select(i,i)}return n.select(e,t)}markDirty(){this.getWritable()}reconcileObservedMutation(e,t){this.markDirty()}}class Qn extends hi{static getType(){return"linebreak"}static clone(e){return new Qn(e.__key)}constructor(e){super(e)}getTextContent(){return`
88
+ `}createDOM(){return document.createElement("br")}updateDOM(){return!1}static importDOM(){return{br:e=>function(t){const n=t.parentElement;if(n!==null&&zs(n)){const s=n.firstChild;if(s===t||s.nextSibling===t&&us(s)){const i=n.lastChild;if(i===t||i.previousSibling===t&&us(i))return!0}}return!1}(e)||function(t){const n=t.parentElement;if(n!==null&&zs(n)){const s=n.firstChild;if(s===t||s.nextSibling===t&&us(s))return!1;const i=n.lastChild;if(i===t||i.previousSibling===t&&us(i))return!0}return!1}(e)?null:{conversion:Nh,priority:0}}}static importJSON(e){return Mr()}exportJSON(){return{type:"linebreak",version:1}}}function Nh(r){return{node:Mr()}}function Mr(){return Qt(new Qn)}function Ar(r){return r instanceof Qn}function us(r){return r.nodeType===yr&&/^( |\t|\r?\n)+$/.test(r.textContent||"")}function Li(r,e){return 16&e?"code":e&Lo?"mark":32&e?"sub":64&e?"sup":null}function Pi(r,e){return 1&e?"strong":2&e?"em":"span"}function nc(r,e,t,n,s){const i=n.classList;let o=An(s,"base");o!==void 0&&i.add(...o),o=An(s,"underlineStrikethrough");let a=!1;const l=e&Ms&&e&js;o!==void 0&&(t&Ms&&t&js?(a=!0,l||i.add(...o)):l&&i.remove(...o));for(const u in Br){const c=Br[u];if(o=An(s,u),o!==void 0)if(t&c){if(a&&(u==="underline"||u==="strikethrough")){e&c&&i.remove(...o);continue}e&c&&(!l||u!=="underline")&&u!=="strikethrough"||i.add(...o)}else e&c&&i.remove(...o)}}function sc(r,e,t){const n=e.firstChild,s=t.isComposing(),i=r+(s?ai:"");if(n==null)e.textContent=i;else{const o=n.nodeValue;if(o!==i)if(s||gr){const[a,l,u]=function(c,d){const h=c.length,p=d.length;let g=0,m=0;for(;g<h&&g<p&&c[g]===d[g];)g++;for(;m+g<h&&m+g<p&&c[h-m-1]===d[p-m-1];)m++;return[g,h-g-m,d.slice(g,p-m)]}(o,i);l!==0&&n.deleteData(a,l),n.insertData(a,u)}else n.nodeValue=i}}function Ga(r,e,t,n,s,i){sc(s,r,e);const o=i.theme.text;o!==void 0&&nc(0,0,n,r,o)}function cs(r,e){const t=document.createElement(e);return t.appendChild(r),t}class sn extends hi{static getType(){return"text"}static clone(e){return new sn(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 oh[e.__mode]}getStyle(){return this.getLatest().__style}isToken(){return this.getLatest().__mode===1}isComposing(){return this.__key===fr()}isSegmented(){return this.getLatest().__mode===2}isDirectionless(){return!!(1&this.getLatest().__detail)}isUnmergeable(){return!!(2&this.getLatest().__detail)}hasFormat(e){const t=Br[e];return!!(this.getFormat()&t)}isSimpleText(){return this.__type==="text"&&this.__mode===0}getTextContent(){return this.getLatest().__text}getFormatFlags(e,t){return Ls(this.getLatest().__format,e,t)}canHaveFormat(){return!0}createDOM(e,t){const n=this.__format,s=Li(0,n),i=Pi(0,n),o=s===null?i:s,a=document.createElement(o);let l=a;this.hasFormat("code")&&a.setAttribute("spellcheck","false"),s!==null&&(l=document.createElement(i),a.appendChild(l)),Ga(l,this,0,n,this.__text,e);const u=this.__style;return u!==""&&(a.style.cssText=u),a}updateDOM(e,t,n){const s=this.__text,i=e.__format,o=this.__format,a=Li(0,i),l=Li(0,o),u=Pi(0,i),c=Pi(0,o);if((a===null?u:a)!==(l===null?c:l))return!0;if(a===l&&u!==c){const m=t.firstChild;m==null&&K(48);const x=document.createElement(c);return Ga(x,this,0,o,s,n),t.replaceChild(x,m),!1}let d=t;l!==null&&a!==null&&(d=t.firstChild,d==null&&K(49)),sc(s,d,this);const h=n.theme.text;h!==void 0&&i!==o&&nc(0,i,o,d,h);const p=e.__style,g=this.__style;return p!==g&&(t.style.cssText=g),!1}static importDOM(){return{"#text":()=>({conversion:Rh,priority:0}),b:()=>({conversion:jh,priority:0}),code:()=>({conversion:lr,priority:0}),em:()=>({conversion:lr,priority:0}),i:()=>({conversion:lr,priority:0}),s:()=>({conversion:lr,priority:0}),span:()=>({conversion:Bh,priority:0}),strong:()=>({conversion:lr,priority:0}),sub:()=>({conversion:lr,priority:0}),sup:()=>({conversion:lr,priority:0}),u:()=>({conversion:lr,priority:0})}}static importJSON(e){const t=lt(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&&ir(t)||K(132),t.style.whiteSpace="pre-wrap",this.hasFormat("bold")&&(t=cs(t,"b")),this.hasFormat("italic")&&(t=cs(t,"i")),this.hasFormat("strikethrough")&&(t=cs(t,"s")),this.hasFormat("underline")&&(t=cs(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"?Br[e]:e,t}setDetail(e){const t=this.getWritable();return t.__detail=typeof e=="string"?nh[e]:e,t}setStyle(e){const t=this.getWritable();return t.__style=e,t}toggleFormat(e){const t=Ls(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=ih[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){wt();let n=e,s=t;const i=ae(),o=this.getTextContent(),a=this.__key;if(typeof o=="string"){const l=o.length;n===void 0&&(n=l),s===void 0&&(s=l)}else n=0,s=0;if(!V(i))return ac(a,n,a,s,"text","text");{const l=fr();l!==i.anchor.key&&l!==i.focus.key||ht(a),i.setTextNodeRange(this,n,this,s)}return i}selectStart(){return this.select(0,0)}selectEnd(){const e=this.getTextContentSize();return this.select(e,e)}spliceText(e,t,n,s){const i=this.getWritable(),o=i.__text,a=n.length;let l=e;l<0&&(l=a+l,l<0&&(l=0));const u=ae();if(s&&V(u)){const d=e+a;u.setTextNodeRange(i,d,i,d)}const c=o.slice(0,l)+n+o.slice(l+t);return i.__text=c,i}canInsertTextBefore(){return!0}canInsertTextAfter(){return!0}splitText(...e){wt();const t=this.getLatest(),n=t.getTextContent(),s=t.__key,i=fr(),o=new Set(e),a=[],l=n.length;let u="";for(let k=0;k<l;k++)u!==""&&o.has(k)&&(a.push(u),u=""),u+=n[k];u!==""&&a.push(u);const c=a.length;if(c===0)return[];if(a[0]===n)return[t];const d=a[0],h=t.getParent();let p;const g=t.getFormat(),m=t.getStyle(),x=t.__detail;let _=!1;t.isSegmented()?(p=lt(d),p.__format=g,p.__style=m,p.__detail=x,_=!0):(p=t.getWritable(),p.__text=d);const b=ae(),S=[p];let C=d.length;for(let k=1;k<c;k++){const E=a[k],v=E.length,T=lt(E).getWritable();T.__format=g,T.__style=m,T.__detail=x;const B=T.__key,j=C+v;if(V(b)){const N=b.anchor,R=b.focus;N.key===s&&N.type==="text"&&N.offset>C&&N.offset<=j&&(N.key=B,N.offset-=C,b.dirty=!0),R.key===s&&R.type==="text"&&R.offset>C&&R.offset<=j&&(R.key=B,R.offset-=C,b.dirty=!0)}i===s&&ht(B),C=j,S.push(T)}if(h!==null){(function(v){const T=v.getPreviousSibling(),B=v.getNextSibling();T!==null&&Ps(T),B!==null&&Ps(B)})(this);const k=h.getWritable(),E=this.getIndexWithinParent();_?(k.splice(E,0,S),this.remove()):k.splice(E,1,S),V(b)&&Ws(b,h,E,c-1)}return S}mergeWithSibling(e){const t=e===this.getPreviousSibling();t||e===this.getNextSibling()||K(50);const n=this.__key,s=e.__key,i=this.__text,o=i.length;fr()===s&&ht(n);const a=ae();if(V(a)){const d=a.anchor,h=a.focus;d!==null&&d.key===s&&(nl(d,t,n,e,o),a.dirty=!0),h!==null&&h.key===s&&(nl(h,t,n,e,o),a.dirty=!0)}const l=e.__text,u=t?l+i:i+l;this.setTextContent(u);const c=this.getWritable();return e.remove(),c}isTextEntity(){return!1}}function Bh(r){return{forChild:Zo(r.style),node:null}}function jh(r){const e=r,t=e.style.fontWeight==="normal";return{forChild:Zo(e.style,t?void 0:"bold"),node:null}}const Ka=new WeakMap;function Mh(r){return r.nodeName==="PRE"||r.nodeType===Gn&&r.style!==void 0&&r.style.whiteSpace!==void 0&&r.style.whiteSpace.startsWith("pre")}function Rh(r){const e=r;r.parentElement===null&&K(129);let t=e.textContent||"";if(function(n){let s,i=n.parentNode;const o=[n];for(;i!==null&&(s=Ka.get(i))===void 0&&!Mh(i);)o.push(i),i=i.parentNode;const a=s===void 0?i:s;for(let l=0;l<o.length;l++)Ka.set(o[l],a);return a}(e)!==null){const n=t.split(/(\r?\n|\t)/),s=[],i=n.length;for(let o=0;o<i;o++){const a=n[o];a===`
89
+ `||a===`\r
90
+ `?s.push(Mr()):a===" "?s.push(Xn()):a!==""&&s.push(lt(a))}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=Ya(n,!1))!==null;){const i=n.textContent||"";if(i.length>0){/[ \t\n]$/.test(i)&&(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=Ya(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:lt(t)}}function Ya(r,e){let t=r;for(;;){let n;for(;(n=e?t.nextSibling:t.previousSibling)===null;){const i=t.parentElement;if(i===null)return null;t=i}if(t=n,t.nodeType===Gn){const i=t.style.display;if(i===""&&!Ji(t)||i!==""&&!i.startsWith("inline"))return null}let s=t;for(;(s=e?t.firstChild:t.lastChild)!==null;)t=s;if(t.nodeType===yr)return t;if(t.nodeName==="BR")return null}}const Fh={code:"code",em:"italic",i:"italic",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function lr(r){const e=Fh[r.nodeName.toLowerCase()];return e===void 0?{node:null}:{forChild:Zo(r.style,e),node:null}}function lt(r=""){return Qt(new sn(r))}function ee(r){return r instanceof sn}function Zo(r,e){const t=r.fontWeight,n=r.textDecoration.split(" "),s=t==="700"||t==="bold",i=n.includes("line-through"),o=r.fontStyle==="italic",a=n.includes("underline"),l=r.verticalAlign;return u=>(ee(u)&&(s&&!u.hasFormat("bold")&&u.toggleFormat("bold"),i&&!u.hasFormat("strikethrough")&&u.toggleFormat("strikethrough"),o&&!u.hasFormat("italic")&&u.toggleFormat("italic"),a&&!u.hasFormat("underline")&&u.toggleFormat("underline"),l!=="sub"||u.hasFormat("subscript")||u.toggleFormat("subscript"),l!=="super"||u.hasFormat("superscript")||u.toggleFormat("superscript"),e&&!u.hasFormat(e)&&u.toggleFormat(e)),u)}class Jn extends sn{static getType(){return"tab"}static clone(e){return new Jn(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=Xn();return t.setFormat(e.format),t.setStyle(e.style),t}exportJSON(){return{...super.exportJSON(),type:"tab",version:1}}setTextContent(e){K(126)}setDetail(e){K(127)}setMode(e){K(128)}canInsertTextBefore(){return!1}canInsertTextAfter(){return!1}}function Xn(){return Qt(new Jn)}function Lh(r){return r instanceof Jn}class Ph{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,i=e.offset;if($(t)){const o=t.getDescendantByIndex(s);t=o??t}if($(n)){const o=n.getDescendantByIndex(i);n=o??n}return t===n?s<i:t.isBefore(n)}getNode(){const e=pt(this.key);return e===null&&K(20),e}set(e,t,n){const s=this._selection,i=this.key;this.key=e,this.offset=t,this.type=n,es()||(fr()===i&&ht(e),s!==null&&(s.setCachedNodes(null),s.dirty=!0))}}function Yt(r,e,t){return new Ph(r,e,t)}function Ii(r,e){let t=e.__key,n=r.offset,s="element";if(ee(e)){s="text";const i=e.getTextContentSize();n>i&&(n=i)}else if(!$(e)){const i=e.getNextSibling();if(ee(i))t=i.__key,n=0,s="text";else{const o=e.getParent();o&&(t=o.__key,n=e.getIndexWithinParent()+1)}}r.set(t,n,s)}function Qa(r,e){if($(e)){const t=e.getLastDescendant();$(t)||ee(t)?Ii(r,t):Ii(r,e)}else Ii(r,e)}function cr(r,e,t,n){r.key=e,r.offset=t,r.type=n}class pi{constructor(e){this._cachedNodes=null,this._nodes=e,this.dirty=!1}getCachedNodes(){return this._cachedNodes}setCachedNodes(e){this._cachedNodes=e}is(e){if(!Ut(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 pi(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 i;if(ee(s))i=s.select();else{const o=s.getIndexWithinParent()+1;i=s.getParentOrThrow().select(o,o)}i.insertNodes(e);for(let o=0;o<n;o++)t[o].remove()}getNodes(){const e=this._cachedNodes;if(e!==null)return e;const t=this._nodes,n=[];for(const s of t){const i=pt(s);i!==null&&n.push(i)}return es()||(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 V(r){return r instanceof xr}class xr{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!!V(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),i=s?t:n,o=s?n:t;let a=i.getNode(),l=o.getNode();const u=i.offset,c=o.offset;if($(a)){const h=a.getDescendantByIndex(u);a=h??a}if($(l)){let h=l.getDescendantByIndex(c);h!==null&&h!==a&&l.getChildAtIndex(c)===h&&(h=h.getPreviousSibling()),l=h??l}let d;return d=a.is(l)?$(a)&&a.getChildrenSize()>0?[]:[a]:a.getNodesBetween(l),es()||(this._cachedNodes=d),d}setTextNodeRange(e,t,n,s){cr(this.anchor,e.__key,t,"text"),cr(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,i=this.focus,o=s.isBefore(i),[a,l]=uo(this);let u="",c=!0;for(let d=0;d<e.length;d++){const h=e[d];if($(h)&&!h.isInline())c||(u+=`
91
+ `),c=!h.isEmpty();else if(c=!1,ee(h)){let p=h.getTextContent();h===t?h===n?s.type==="element"&&i.type==="element"&&i.offset!==s.offset||(p=a<l?p.slice(a,l):p.slice(l,a)):p=o?p.slice(a):p.slice(l):h===n&&(p=o?p.slice(0,l):p.slice(0,a)),u+=p}else!Ge(h)&&!Ar(h)||h===n&&this.isCollapsed()||(u+=h.getTextContent())}return u}applyDOMRange(e){const t=rt(),n=t.getEditorState()._selection,s=oc(e.startContainer,e.startOffset,e.endContainer,e.endOffset,t,n);if(s===null)return;const[i,o]=s;cr(this.anchor,i.key,i.offset,i.type),cr(this.focus,o.key,o.offset,o.type),this._cachedNodes=null}clone(){const e=this.anchor,t=this.focus;return new xr(Yt(e.key,e.offset,e.type),Yt(t.key,t.offset,t.type),this.format,this.style)}toggleFormat(e){this.format=Ls(this.format,e,null),this.dirty=!0}setStyle(e){this.style=e,this.dirty=!0}hasFormat(e){const t=Br[e];return!!(this.format&t)}insertRawText(e){const t=e.split(/(\r?\n|\t)/),n=[],s=t.length;for(let i=0;i<s;i++){const o=t[i];o===`
92
92
  `||o===`\r
93
- `?n.push(Mr()):o===" "?n.push(Xn()):n.push(lt(o))}this.insertNodes(n)}insertText(e){const t=this.anchor,n=this.focus,s=this.format,i=this.style;let o=t,l=n;!this.isCollapsed()&&n.isBefore(t)&&(o=n,l=t),o.type==="element"&&function(x,_,b,C){const S=x.getNode(),k=S.getChildAtIndex(x.offset),E=lt(),v=yt(S)?at().append(E):E;E.setFormat(b),E.setStyle(C),k===null?S.append(v):k.insertBefore(v),x.is(_)&&_.set(E.__key,0,"text"),x.set(E.__key,0,"text")}(o,l,s,i);const a=o.offset;let u=l.offset;const c=this.getNodes(),d=c.length;let h=c[0];Z(h)||Q(26);const p=h.getTextContent().length,g=h.getParentOrThrow();let m=c[d-1];if(d===1&&l.type==="element"&&(u=p,l.set(o.key,u,"text")),this.isCollapsed()&&a===p&&(h.isSegmented()||h.isToken()||!h.canInsertTextAfter()||!g.canInsertTextAfter()&&h.getNextSibling()===null)){let x=h.getNextSibling();if(Z(x)&&x.canInsertTextBefore()&&!Cr(x)||(x=lt(),x.setFormat(s),x.setStyle(i),g.canInsertTextAfter()?h.insertAfter(x):g.insertAfter(x)),x.select(0,0),h=x,e!=="")return void this.insertText(e)}else if(this.isCollapsed()&&a===0&&(h.isSegmented()||h.isToken()||!h.canInsertTextBefore()||!g.canInsertTextBefore()&&h.getPreviousSibling()===null)){let x=h.getPreviousSibling();if(Z(x)&&!Cr(x)||(x=lt(),x.setFormat(s),g.canInsertTextBefore()?h.insertBefore(x):g.insertBefore(x)),x.select(),h=x,e!=="")return void this.insertText(e)}else if(h.isSegmented()&&a!==p){const x=lt(h.getTextContent());x.setFormat(s),h.replace(x),h=x}else if(!this.isCollapsed()&&e!==""){const x=m.getParent();if(!g.canInsertTextBefore()||!g.canInsertTextAfter()||O(x)&&(!x.canInsertTextBefore()||!x.canInsertTextAfter()))return this.insertText(""),ic(this.anchor,this.focus,null),void this.insertText(e)}if(d===1){if(h.isToken()){const C=lt(e);return C.select(),void h.replace(C)}const x=h.getFormat(),_=h.getStyle();if(a!==u||x===s&&_===i){if(Lh(h)){const C=lt(e);return C.setFormat(s),C.setStyle(i),C.select(),void h.replace(C)}}else{if(h.getTextContent()!==""){const C=lt(e);if(C.setFormat(s),C.setStyle(i),C.select(),a===0)h.insertBefore(C,!1);else{const[S]=h.splitText(a);S.insertAfter(C,!1)}return void(C.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length))}h.setFormat(s),h.setStyle(i)}const b=u-a;h=h.spliceText(a,b,e,!0),h.getTextContent()===""?h.remove():this.anchor.type==="text"&&(h.isComposing()?this.anchor.offset-=e.length:(this.format=x,this.style=_))}else{const x=new Set([...h.getParentKeys(),...m.getParentKeys()]),_=O(h)?h:h.getParentOrThrow();let b=O(m)?m:m.getParentOrThrow(),C=m;if(!_.is(b)&&b.isInline())do C=b,b=b.getParentOrThrow();while(b.isInline());if(l.type==="text"&&(u!==0||m.getTextContent()==="")||l.type==="element"&&m.getIndexWithinParent()<u)if(Z(m)&&!m.isToken()&&u!==m.getTextContentSize()){if(m.isSegmented()){const T=lt(m.getTextContent());m.replace(T),m=T}yt(l.getNode())||l.type!=="text"||(m=m.spliceText(0,u,"")),x.add(m.__key)}else{const T=m.getParentOrThrow();T.canBeEmpty()||T.getChildrenSize()!==1?m.remove():T.remove()}else x.add(m.__key);const S=b.getChildren(),k=new Set(c),E=_.is(b),v=_.isInline()&&h.getNextSibling()===null?_:h;for(let T=S.length-1;T>=0;T--){const B=S[T];if(B.is(h)||O(B)&&B.isParentOf(h))break;B.isAttached()&&(!k.has(B)||B.is(C)?E||v.insertAfter(B,!1):B.remove())}if(!E){let T=b,B=null;for(;T!==null;){const j=T.getChildren(),N=j.length;(N===0||j[N-1].is(B))&&(x.delete(T.__key),B=T),T=T.getParent()}}if(h.isToken())if(a===p)h.select();else{const T=lt(e);T.select(),h.replace(T)}else h=h.spliceText(a,p-a,e,!0),h.getTextContent()===""?h.remove():h.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length);for(let T=1;T<d;T++){const B=c[T],j=B.__key;x.has(j)||B.remove()}}}removeText(){if(this.isCollapsed())return;const{anchor:e,focus:t}=this,n=this.getNodes(),s=this.isBackward()?t:e,i=this.isBackward()?e:t;let o=s.getNode(),l=i.getNode();const a=pn(o,cr),u=pn(l,cr);Z(o)&&o.isToken()&&s.offset<o.getTextContentSize()&&(s.offset=0),i.offset>0&&Z(l)&&l.isToken()&&(i.offset=l.getTextContentSize()),n.forEach(d=>{Tn(o,d)||Tn(l,d)||d.getKey()===o.getKey()||d.getKey()===l.getKey()||d.remove()});const c=(d,h)=>{if(d.getTextContent()==="")d.remove();else if(h!==0&&Cr(d)){const p=lt(d.getTextContent());return p.setFormat(d.getFormat()),p.setStyle(d.getStyle()),d.replace(p)}};if(o===l&&Z(o)){const d=Math.abs(t.offset-e.offset);return o.spliceText(s.offset,d,"",!0),void c(o,d)}if(Z(o)){const d=o.getTextContentSize()-s.offset;o.spliceText(s.offset,d,""),o=c(o,d)||o}Z(l)&&(l.spliceText(0,i.offset,""),l=c(l,i.offset)||l),o.isAttached()&&Z(o)?o.selectEnd():l.isAttached()&&Z(l)&&l.selectStart(),O(a)&&O(u)&&a!==u&&(a.append(...u.getChildren()),u.remove(),i.set(s.key,s.offset,s.type))}formatText(e,t=null){if(this.isCollapsed())return this.toggleFormat(e),void ft(null);const n=this.getNodes(),s=[];for(const S of n)Z(S)&&s.push(S);const i=S=>{n.forEach(k=>{if(tn(k)){const E=k.getFormatFlags(e,S);k.setTextFormat(E)}})},o=s.length;if(o===0)return this.toggleFormat(e),ft(null),void i(t);const l=this.anchor,a=this.focus,u=this.isBackward(),c=u?a:l,d=u?l:a;let h=0,p=s[0],g=c.type==="element"?0:c.offset;if(c.type==="text"&&g===p.getTextContentSize()&&(h=1,p=s[1],g=0),p==null)return;const m=p.getFormatFlags(e,t);i(m);const x=o-1;let _=s[x];const b=d.type==="text"?d.offset:_.getTextContentSize();if(p.is(_)){if(g===b)return;if(Cr(p)||g===0&&b===p.getTextContentSize())p.setFormat(m);else{const S=p.splitText(g,b),k=g===0?S[0]:S[1];k.setFormat(m),c.type==="text"&&c.set(k.__key,0,"text"),d.type==="text"&&d.set(k.__key,b-g,"text")}return void(this.format=m)}g===0||Cr(p)||([,p]=p.splitText(g),g=0),p.setFormat(m);const C=_.getFormatFlags(e,m);b>0&&(b===_.getTextContentSize()||Cr(_)||([_]=_.splitText(b)),_.setFormat(C));for(let S=h+1;S<x;S++){const k=s[S],E=k.getFormatFlags(e,C);k.setFormat(E)}c.type==="text"&&c.set(p.__key,g,"text"),d.type==="text"&&d.set(_.__key,b,"text"),this.format=m|C}insertNodes(e){if(e.length===0)return;if(this.anchor.key==="root"){this.insertParagraph();const g=ae();return K(g)||Q(134),g.insertNodes(e)}const t=(this.isBackward()?this.focus:this.anchor).getNode(),n=pn(t,cr),s=e[e.length-1];if(O(n)&&"__language"in n){if("__language"in e[0])this.insertText(e[0].getTextContent());else{const g=zi(this);n.splice(g,0,e),s.selectEnd()}return}if(!e.some(g=>(O(g)||Ge(g))&&!g.isInline())){O(n)||Q(211,t.constructor.name,t.getType());const g=zi(this);return n.splice(g,0,e),void s.selectEnd()}const i=function(g){const m=at();let x=null;for(let _=0;_<g.length;_++){const b=g[_],C=Ar(b);if(C||Ge(b)&&b.isInline()||O(b)&&b.isInline()||Z(b)||b.isParentRequired()){if(x===null&&(x=b.createParentElementNode(),m.append(x),C))continue;x!==null&&x.append(b)}else m.append(b),x=null}return m}(e),o=i.getLastDescendant(),l=i.getChildren(),a=!O(n)||!n.isEmpty()?this.insertParagraph():null,u=l[l.length-1];let c=l[0];var d;O(d=c)&&cr(d)&&!d.isEmpty()&&O(n)&&(!n.isEmpty()||n.canMergeWhenEmpty())&&(O(n)||Q(211,t.constructor.name,t.getType()),n.append(...c.getChildren()),c=l[1]),c&&(n===null&&Q(212,t.constructor.name,t.getType()),function(g,m,x){const _=m.getParentOrThrow().getLastChild();let b=m;const C=[m];for(;b!==_;)b.getNextSibling()||Q(140),b=b.getNextSibling(),C.push(b);let S=g;for(const k of C)S=S.insertAfter(k)}(n,c));const h=pn(o,cr);a&&O(h)&&(a.canMergeWhenEmpty()||cr(u))&&(h.append(...a.getChildren()),a.remove()),O(n)&&n.isEmpty()&&n.remove(),o.selectEnd();const p=O(n)?n.getLastChild():null;Ar(p)&&h!==n&&p.remove()}insertParagraph(){if(this.anchor.key==="root"){const o=at();return et().splice(this.anchor.offset,0,[o]),o.select(),o}const e=zi(this),t=pn(this.anchor.getNode(),cr);O(t)||Q(213);const n=t.getChildAtIndex(e),s=n?[n,...n.getNextSiblings()]:[],i=t.insertNewAfter(this,!1);return i?(i.append(...s),i.selectStart(),i):null}insertLineBreak(e){const t=Mr();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,i=this.focus;let o=e[0],l=e[n];const[a,u]=uo(this);if(t===0)return[];if(t===1){if(Z(o)&&!this.isCollapsed()){const d=a>u?u:a,h=a>u?a:u,p=o.splitText(d,h),g=d===0?p[0]:p[1];return g!=null?[g]:[]}return[o]}const c=s.isBefore(i);if(Z(o)){const d=c?a:u;d===o.getTextContentSize()?e.shift():d!==0&&([,o]=o.splitText(d),e[0]=o)}if(Z(l)){const d=l.getTextContent().length,h=c?u:a;h===0?e.pop():h!==d&&([l]=l.splitText(h),e[n]=l)}return e}modify(e,t,n){const s=this.focus,i=this.anchor,o=e==="move",l=Pn(s,t);if(Ge(l)&&!l.isIsolated()){if(o&&l.isKeyboardSelectable()){const p=tl();return p.add(l.__key),void Yt(p)}const h=t?l.getPreviousSibling():l.getNextSibling();if(Z(h)){const p=h.__key,g=t?h.getTextContent().length:0;return s.set(p,g,"text"),void(o&&i.set(p,g,"text"))}{const p=l.getParentOrThrow();let g,m;return O(h)?(m=h.__key,g=t?h.getChildrenSize():0):(g=l.getIndexWithinParent(),m=p.__key,t||g++),s.set(m,g,"element"),void(o&&i.set(m,g,"element"))}}const a=nt(),u=Bt(a._window);if(!u)return;const c=a._blockCursorElement,d=a._rootElement;if(d===null||c===null||!O(l)||l.isInline()||l.canBeEmpty()||Qo(c,a,d),function(h,p,g,m){h.modify(p,g,m)}(u,e,t?"backward":"forward",n),u.rangeCount>0){const h=u.getRangeAt(0),p=this.anchor.getNode(),g=yt(p)?p:bh(p);if(this.applyDOMRange(h),this.dirty=!0,!o){const m=this.getNodes(),x=[];let _=!1;for(let b=0;b<m.length;b++){const C=m[b];Tn(C,g)?x.push(C):_=!0}if(_&&x.length>0)if(t){const b=x[0];O(b)?b.selectStart():b.getParentOrThrow().selectStart()}else{const b=x[x.length-1];O(b)?b.selectEnd():b.getParentOrThrow().selectEnd()}u.anchorNode===h.startContainer&&u.anchorOffset===h.startOffset||function(b){const C=b.focus,S=b.anchor,k=S.key,E=S.offset,v=S.type;dr(S,C.key,C.offset,C.type),dr(C,k,E,v),b._cachedNodes=null}(this)}}}forwardDeletion(e,t,n){if(!n&&(e.type==="element"&&O(t)&&e.offset===t.getChildrenSize()||e.type==="text"&&e.offset===t.getTextContentSize())){const s=t.getParent(),i=t.getNextSibling()||(s===null?null:s.getNextSibling());if(O(i)&&i.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 i=this.focus,o=Pn(i,e);if(Ge(o)&&!o.isIsolated()){if(o.isKeyboardSelectable()&&O(s)&&s.getChildrenSize()===0){s.remove();const l=tl();l.add(o.__key),Yt(l)}else o.remove(),nt().dispatchCommand(Bo,void 0);return}if(!e&&O(o)&&O(s)&&s.isEmpty())return s.remove(),void o.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=i.type==="text"?i.getNode():null;if(s=n.type==="text"?n.getNode():null,l!==null&&l.isSegmented()){const a=i.offset,u=l.getTextContentSize();if(l.is(s)||e&&a!==u||!e&&a!==0)return void Xa(l,e,a)}else if(s!==null&&s.isSegmented()){const a=n.offset,u=s.getTextContentSize();if(s.is(l)||e&&a!==0||!e&&a!==u)return void Xa(s,e,a)}(function(a,u){const c=a.anchor,d=a.focus,h=c.getNode(),p=d.getNode();if(h===p&&c.type==="text"&&d.type==="text"){const g=c.offset,m=d.offset,x=g<m,_=x?g:m,b=x?m:g,C=b-1;_!==C&&(zu(h.getTextContent().slice(_,b))||(u?d.offset=C:c.offset=C))}})(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type==="element"&&this.anchor.offset===0){const n=this.anchor.getNode();n.isEmpty()&&yt(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 Ht(r){return r instanceof pi}function Ja(r){const e=r.offset;if(r.type==="text")return e;const t=r.getNode();return e===t.getChildrenSize()?t.getTextContent().length:0}function uo(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]:[Ja(t),Ja(n)]}function Xa(r,e,t){const n=r,s=n.getTextContent().split(/(?=\s)/g),i=s.length;let o=0,l=0;for(let u=0;u<i;u++){const c=u===i-1;if(l=o,o+=s[u].length,e&&o===t||o>t||c){s.splice(u,1),c&&(l=void 0);break}}const a=s.join("").trim();a===""?n.remove():(n.setTextContent(a),n.select(l,l))}function Za(r,e,t,n){let s,i=e;if(r.nodeType===Gn){let o=!1;const l=r.childNodes,a=l.length,u=n._blockCursorElement;i===a&&(o=!0,i=a-1);let c=l[i],d=!1;if(c===u)c=l[i+1],d=!0;else if(u!==null){const h=u.parentNode;r===h&&e>Array.prototype.indexOf.call(h.children,u)&&i--}if(s=Hr(c),Z(s))i=Ra(s,o);else{let h=Hr(r);if(h===null)return null;if(O(h)){const p=n.getElementByKey(h.getKey());p===null&&Q(214),[h,i]=h.getDOMSlot(p).resolveChildIndex(h,p,r,e),O(h)||Q(215),o&&i>=h.getChildrenSize()&&(i=Math.max(0,h.getChildrenSize()-1));let m=h.getChildAtIndex(i);if(O(m)&&function(x,_,b){const C=x.getParent();return b===null||C===null||!C.canBeEmpty()||C!==b.getNode()}(m,0,t)){const x=o?m.getLastDescendant():m.getFirstDescendant();x===null?h=m:(m=x,h=O(m)?m:m.getParentOrThrow()),i=0}Z(m)?(s=m,h=null,i=Ra(m,o)):m!==h&&o&&!d&&(O(h)||Q(216),i=Math.min(h.getChildrenSize(),i+1))}else{const p=h.getIndexWithinParent();i=e===0&&Ge(h)&&Hr(r)===h?p:p+1,h=h.getParentOrThrow()}if(O(h))return Jt(h.__key,i,"element")}}else s=Hr(r);return Z(s)?Jt(s.__key,i,"text"):null}function el(r,e,t){const n=r.offset,s=r.getNode();if(n===0){const i=s.getPreviousSibling(),o=s.getParent();if(e){if((t||!e)&&i===null&&O(o)&&o.isInline()){const l=o.getPreviousSibling();Z(l)&&(r.key=l.__key,r.offset=l.getTextContent().length)}}else O(i)&&!t&&i.isInline()?(r.key=i.__key,r.offset=i.getChildrenSize(),r.type="element"):Z(i)&&(r.key=i.__key,r.offset=i.getTextContent().length)}else if(n===s.getTextContent().length){const i=s.getNextSibling(),o=s.getParent();if(e&&O(i)&&i.isInline())r.key=i.__key,r.offset=0,r.type="element";else if((t||e)&&i===null&&O(o)&&o.isInline()&&!o.canInsertTextAfter()){const l=o.getNextSibling();Z(l)&&(r.key=l.__key,r.offset=0)}}}function ic(r,e,t){if(r.type==="text"&&e.type==="text"){const n=r.isBefore(e),s=r.is(e);el(r,n,s),el(e,!n,s),s&&(e.key=r.key,e.offset=r.offset,e.type=r.type);const i=nt();if(i.isComposing()&&i._compositionKey!==r.key&&K(t)){const o=t.anchor,l=t.focus;dr(r,o.key,o.offset,o.type),dr(e,l.key,l.offset,l.type)}}}function oc(r,e,t,n,s,i){if(r===null||t===null||!Kn(s,r,t))return null;const o=Za(r,e,K(i)?i.anchor:null,s);if(o===null)return null;const l=Za(t,n,K(i)?i.focus:null,s);if(l===null)return null;if(o.type==="element"&&l.type==="element"){const a=Hr(r),u=Hr(t);if(Ge(a)&&Ge(u))return null}return ic(o,l,i),[o,l]}function co(r){return O(r)&&!r.isInline()}function ac(r,e,t,n,s,i){const o=ar(),l=new br(Jt(r,e,s),Jt(t,n,i),0,"");return l.dirty=!0,o._selection=l,l}function Ih(){const r=Jt("root",0,"element"),e=Jt("root",0,"element");return new br(r,e,0,"")}function tl(){return new pi(new Set)}function ea(r,e,t,n){const s=t._window;if(s===null)return null;const i=n||s.event,o=i?i.type:void 0,l=o==="selectionchange",a=!Qi&&(l||o==="beforeinput"||o==="compositionstart"||o==="compositionend"||o==="click"&&i&&i.detail===3||o==="drop"||o===void 0);let u,c,d,h;if(K(r)&&!a)return r.clone();if(e===null)return null;if(u=e.anchorNode,c=e.focusNode,d=e.anchorOffset,h=e.focusOffset,l&&K(r)&&!Kn(t,u,c))return r.clone();const p=oc(u,d,c,h,t,r);if(p===null)return null;const[g,m]=p;return new br(g,m,K(r)?r.format:0,K(r)?r.style:"")}function ae(){return ar()._selection}function Zn(){return nt()._editorState._selection}function Ws(r,e,t,n=1){const s=r.anchor,i=r.focus,o=s.getNode(),l=i.getNode();if(!e.is(o)&&!e.is(l))return;const a=e.__key;if(r.isCollapsed()){const u=s.offset;if(t<=u&&n>0||t<u&&n<0){const c=Math.max(0,u+n);s.set(a,c,"element"),i.set(a,c,"element"),rl(r)}}else{const u=r.isBackward(),c=u?i:s,d=c.getNode(),h=u?s:i,p=h.getNode();if(e.is(d)){const g=c.offset;(t<=g&&n>0||t<g&&n<0)&&c.set(a,Math.max(0,g+n),"element")}if(e.is(p)){const g=h.offset;(t<=g&&n>0||t<g&&n<0)&&h.set(a,Math.max(0,g+n),"element")}}rl(r)}function rl(r){const e=r.anchor,t=e.offset,n=r.focus,s=n.offset,i=e.getNode(),o=n.getNode();if(r.isCollapsed()){if(!O(i))return;const l=i.getChildrenSize(),a=t>=l,u=a?i.getChildAtIndex(l-1):i.getChildAtIndex(t);if(Z(u)){let c=0;a&&(c=u.getTextContentSize()),e.set(u.__key,c,"text"),n.set(u.__key,c,"text")}}else{if(O(i)){const l=i.getChildrenSize(),a=t>=l,u=a?i.getChildAtIndex(l-1):i.getChildAtIndex(t);if(Z(u)){let c=0;a&&(c=u.getTextContentSize()),e.set(u.__key,c,"text")}}if(O(o)){const l=o.getChildrenSize(),a=s>=l,u=a?o.getChildAtIndex(l-1):o.getChildAtIndex(s);if(Z(u)){let c=0;a&&(c=u.getTextContentSize()),n.set(u.__key,c,"text")}}}}function Hs(r,e,t,n,s){let i=null,o=0,l=null;n!==null?(i=n.__key,Z(n)?(o=n.getTextContentSize(),l="text"):O(n)&&(o=n.getChildrenSize(),l="element")):s!==null&&(i=s.__key,Z(s)?l="text":O(s)&&(l="element")),i!==null&&l!==null?r.set(i,o,l):(o=e.getIndexWithinParent(),o===-1&&(o=t.getChildrenSize()),r.set(t.__key,o,"element"))}function nl(r,e,t,n,s){r.type==="text"?(r.key=t,e||(r.offset+=s)):r.offset>n.getIndexWithinParent()&&(r.offset-=1)}function zh(r,e,t,n,s,i,o){const l=n.anchorNode,a=n.focusNode,u=n.anchorOffset,c=n.focusOffset,d=document.activeElement;if(s.has("collaboration")&&d!==i||d!==null&&Wo(d))return;if(!K(e))return void(r!==null&&Kn(t,l,a)&&n.removeAllRanges());const h=e.anchor,p=e.focus,g=h.key,m=p.key,x=Is(t,g),_=Is(t,m),b=h.offset,C=p.offset,S=e.format,k=e.style,E=e.isCollapsed();let v=x,T=_,B=!1;if(h.type==="text"){v=Fs(x);const D=h.getNode();B=D.getFormat()!==S||D.getStyle()!==k}else K(r)&&r.anchor.type==="text"&&(B=!0);var j,N,M,R,w;if(p.type==="text"&&(T=Fs(_)),v!==null&&T!==null&&(E&&(r===null||B||K(r)&&(r.format!==S||r.style!==k))&&(j=S,N=k,M=b,R=g,w=performance.now(),Xu=[j,N,M,R,w]),u!==b||c!==C||l!==v||a!==T||n.type==="Range"&&E||(d!==null&&i.contains(d)||i.focus({preventScroll:!0}),h.type==="element"))){try{n.setBaseAndExtent(v,b,T,C)}catch{}if(!s.has("skip-scroll-into-view")&&e.isCollapsed()&&i!==null&&i===document.activeElement){const D=e instanceof br&&e.anchor.type==="element"?v.childNodes[b]||null:n.rangeCount>0?n.getRangeAt(0):null;if(D!==null){let F;if(D instanceof Text){const I=document.createRange();I.selectNode(D),F=I.getBoundingClientRect()}else F=D.getBoundingClientRect();(function(I,U,J){const te=J.ownerDocument,W=te.defaultView;if(W===null)return;let{top:V,bottom:H}=U,ne=0,ce=0,le=J;for(;le!==null;){const pe=le===te.body;if(pe)ne=0,ce=di(I).innerHeight;else{const Te=le.getBoundingClientRect();ne=Te.top,ce=Te.bottom}let be=0;if(V<ne?be=-(ne-V):H>ce&&(be=H-ce),be!==0)if(pe)W.scrollBy(0,be);else{const Te=le.scrollTop;le.scrollTop+=be;const $=le.scrollTop-Te;V-=$,H-=$}if(pe)break;le=Yn(le)}})(t,F,i)}}oo=!0}}function lc(r){let e=ae()||Zn();e===null&&(e=et().selectEnd()),e.insertNodes(r)}function zi(r){let e=r;r.isCollapsed()||e.removeText();const t=ae();K(t)&&(e=t),K(e)||Q(161);const n=e.anchor;let s=n.getNode(),i=n.offset;for(;!cr(s);)[s,i]=Oh(s,i);return i}function Oh(r,e){const t=r.getParent();if(!t){const s=at();return et().append(s),s.select(),[et(),0]}if(Z(r)){const s=r.splitText(e);if(s.length===0)return[t,r.getIndexWithinParent()];const i=e===0?0:1;return[t,s[0].getIndexWithinParent()+i]}if(!O(r)||e===0)return[t,r.getIndexWithinParent()];const n=r.getChildAtIndex(e);if(n){const s=new br(Jt(r.__key,e,"element"),Jt(r.__key,e,"element"),0,""),i=r.insertNewAfter(s);i&&i.append(n,...n.getNextSiblings())}return[t,r.getIndexWithinParent()+1]}let ct=null,dt=null,kt=!1,Oi=!1,ws=0;const sl={characterData:!0,childList:!0,subtree:!0};function es(){return kt||ct!==null&&ct._readOnly}function Ct(){kt&&Q(13)}function uc(){ws>99&&Q(14)}function ar(){return ct===null&&Q(195,cc()),ct}function nt(){return dt===null&&Q(196,cc()),dt}function cc(){let r=0;const e=new Set,t=mi.version;if(typeof window<"u")for(const s of document.querySelectorAll("[contenteditable]")){const i=li(s);if(Ho(i))r++;else if(i){let o=String(i.constructor.version||"<0.17.1");o===t&&(o+=" (separately built, likely a bundler configuration issue)"),e.add(o)}}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 $h(){return dt}function il(r,e,t){const n=e.__type,s=function(l,a){const u=l._nodes.get(a);return u===void 0&&Q(30,a),u}(r,n);let i=t.get(n);i===void 0&&(i=Array.from(s.transforms),t.set(n,i));const o=i.length;for(let l=0;l<o&&(i[l](e),e.isAttached());l++);}function ol(r,e){return r!==void 0&&r.__key!==e&&r.isAttached()}function dc(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 qh(r){return ta(r,nt()._nodes)}function ta(r,e){const t=r.type,n=e.get(t);n===void 0&&Q(17,t);const s=n.klass;r.type!==s.getType()&&Q(18,s.name);const i=s.importJSON(r),o=r.children;if(O(i)&&Array.isArray(o))for(let l=0;l<o.length;l++){const a=ta(o[l],e);i.append(a)}return i}function al(r,e,t){const n=ct,s=kt,i=dt;ct=e,kt=!0,dt=r;try{return t()}finally{ct=n,kt=s,dt=i}}function pr(r,e){const t=r._pendingEditorState,n=r._rootElement,s=r._headless||n===null;if(t===null)return;const i=r._editorState,o=i._selection,l=t._selection,a=r._dirtyType!==Nr,u=ct,c=kt,d=dt,h=r._updating,p=r._observer;let g=null;if(r._pendingEditorState=null,r._editorState=t,!s&&a&&p!==null){dt=r,ct=t,kt=!1,r._updating=!0;try{const E=r._dirtyType,v=r._dirtyElements,T=r._dirtyLeaves;p.disconnect(),g=Ah(i,t,r,E,v,T)}catch(E){if(E instanceof Error&&r._onError(E),Oi)throw E;return mc(r,null,n,t),ju(r),r._dirtyType=Zr,Oi=!0,pr(r,i),void(Oi=!1)}finally{p.observe(n,sl),r._updating=h,ct=u,kt=c,dt=d}}t._readOnly||(t._readOnly=!0);const m=r._dirtyLeaves,x=r._dirtyElements,_=r._normalizedNodes,b=r._updateTags,C=r._deferred;a&&(r._dirtyType=Nr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements=new Map,r._normalizedNodes=new Set,r._updateTags=new Set),function(E,v){const T=E._decorators;let B=E._pendingDecorators||T;const j=v._nodeMap;let N;for(N in B)j.has(N)||(B===T&&(B=Pu(E)),delete B[N])}(r,t);const S=s?null:Bt(r._window);if(r._editable&&S!==null&&(a||l===null||l.dirty)){dt=r,ct=t;try{if(p!==null&&p.disconnect(),a||l===null||l.dirty){const E=r._blockCursorElement;E!==null&&Qo(E,r,n),zh(o,l,r,S,b,n)}vh(r,n,l),p!==null&&p.observe(n,sl)}finally{dt=d,ct=u}}g!==null&&function(E,v,T,B,j){const N=Array.from(E._listeners.mutation),M=N.length;for(let R=0;R<M;R++){const[w,D]=N[R],F=v.get(D);F!==void 0&&w(F,{dirtyLeaves:B,prevEditorState:j,updateTags:T})}}(r,g,b,m,i),K(l)||l===null||o!==null&&o.is(l)||r.dispatchCommand(Bo,void 0);const k=r._pendingDecorators;k!==null&&(r._decorators=k,r._pendingDecorators=null,jn("decorator",r,!0,k)),function(E,v,T){const B=Ma(v),j=Ma(T);B!==j&&jn("textcontent",E,!0,j)}(r,e||i,t),jn("update",r,!0,{dirtyElements:x,dirtyLeaves:m,editorState:t,normalizedNodes:_,prevEditorState:e||i,tags:b}),function(E,v){if(E._deferred=[],v.length!==0){const T=E._updating;E._updating=!0;try{for(let B=0;B<v.length;B++)v[B]()}finally{E._updating=T}}}(r,C),function(E){const v=E._updates;if(v.length!==0){const T=v.shift();if(T){const[B,j]=T;hc(E,B,j)}}}(r)}function jn(r,e,t,...n){const s=e._updating;e._updating=t;try{const i=Array.from(e._listeners[r]);for(let o=0;o<i.length;o++)i[o].apply(null,n)}finally{e._updating=s}}function fc(r,e,t){if(r._updating===!1||dt!==r){let s=!1;return r.update(()=>{s=fc(r,e,t)}),s}const n=Vo(r);for(let s=4;s>=0;s--)for(let i=0;i<n.length;i++){const o=n[i]._commands.get(e);if(o!==void 0){const l=o[s];if(l!==void 0){const a=Array.from(l),u=a.length;for(let c=0;c<u;c++)if(a[c](t,r)===!0)return!0}}}return!1}function ll(r,e){const t=r._updates;let n=e||!1;for(;t.length!==0;){const s=t.shift();if(s){const[i,o]=s;let l;if(o!==void 0){if(l=o.onUpdate,o.skipTransforms&&(n=!0),o.discrete){const a=r._pendingEditorState;a===null&&Q(191),a._flushSync=!0}l&&r._deferred.push(l),dc(r,o.tag)}i()}}return n}function hc(r,e,t){const n=r._updateTags;let s,i=!1,o=!1;t!==void 0&&(s=t.onUpdate,dc(r,t.tag),i=t.skipTransforms||!1,o=t.discrete||!1),s&&r._deferred.push(s);const l=r._editorState;let a=r._pendingEditorState,u=!1;(a===null||a._readOnly)&&(a=r._pendingEditorState=pc(a||l),u=!0),a._flushSync=o;const c=ct,d=kt,h=dt,p=r._updating;ct=a,kt=!1,r._updating=!0,dt=r;try{u&&(r._headless?l._selection!==null&&(a._selection=l._selection.clone()):a._selection=function(_){const b=_.getEditorState()._selection,C=Bt(_._window);return K(b)||b==null?ea(b,C,_,null):b.clone()}(r));const m=r._compositionKey;e(),i=ll(r,i),function(_,b){const C=b.getEditorState()._selection,S=_._selection;if(K(S)){const k=S.anchor,E=S.focus;let v;if(k.type==="text"&&(v=k.getNode(),v.selectionTransform(C,S)),E.type==="text"){const T=E.getNode();v!==T&&T.selectionTransform(C,S)}}}(a,r),r._dirtyType!==Nr&&(i?function(_,b){const C=b._dirtyLeaves,S=_._nodeMap;for(const k of C){const E=S.get(k);Z(E)&&E.isAttached()&&E.isSimpleText()&&!E.isUnmergeable()&&Ba(E)}}(a,r):function(_,b){const C=b._dirtyLeaves,S=b._dirtyElements,k=_._nodeMap,E=hr(),v=new Map;let T=C,B=T.size,j=S,N=j.size;for(;B>0||N>0;){if(B>0){b._dirtyLeaves=new Set;for(const M of T){const R=k.get(M);Z(R)&&R.isAttached()&&R.isSimpleText()&&!R.isUnmergeable()&&Ba(R),R!==void 0&&ol(R,E)&&il(b,R,v),C.add(M)}if(T=b._dirtyLeaves,B=T.size,B>0){ws++;continue}}b._dirtyLeaves=new Set,b._dirtyElements=new Map;for(const M of j){const R=M[0],w=M[1];if(R!=="root"&&!w)continue;const D=k.get(R);D!==void 0&&ol(D,E)&&il(b,D,v),S.set(R,w)}T=b._dirtyLeaves,B=T.size,j=b._dirtyElements,N=j.size,ws++}b._dirtyLeaves=C,b._dirtyElements=S}(a,r),ll(r),function(_,b,C,S){const k=_._nodeMap,E=b._nodeMap,v=[];for(const[T]of S){const B=E.get(T);B!==void 0&&(B.isAttached()||(O(B)&&Uu(B,T,k,E,v,S),k.has(T)||S.delete(T),v.push(T)))}for(const T of v)E.delete(T);for(const T of C){const B=E.get(T);B===void 0||B.isAttached()||(k.has(T)||C.delete(T),E.delete(T))}}(l,a,r._dirtyLeaves,r._dirtyElements)),m!==r._compositionKey&&(a._flushSync=!0);const x=a._selection;if(K(x)){const _=a._nodeMap,b=x.anchor.key,C=x.focus.key;_.get(b)!==void 0&&_.get(C)!==void 0||Q(19)}else Ht(x)&&x._nodes.size===0&&(a._selection=null)}catch(m){return m instanceof Error&&r._onError(m),r._pendingEditorState=l,r._dirtyType=Zr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),void pr(r)}finally{ct=c,kt=d,dt=h,r._updating=p,ws=0}r._dirtyType!==Nr||function(m,x){const _=x.getEditorState()._selection,b=m._selection;if(b!==null){if(b.dirty||!b.is(_))return!0}else if(_!==null)return!0;return!1}(a,r)?a._flushSync?(a._flushSync=!1,pr(r)):u&&ph(()=>{pr(r)}):(a._flushSync=!1,u&&(n.clear(),r._deferred=[],r._pendingEditorState=null))}function Dt(r,e,t){r._updating?r._updates.push([e,t]):hc(r,e,t)}class Mn{constructor(e,t,n){this.element=e,this.before=t||null,this.after=n||null}withBefore(e){return new Mn(this.element,e,this.after)}withAfter(e){return new Mn(this.element,this.before,e)}withElement(e){return new Mn(e,this.before,this.after)}insertChild(e){const t=this.before||this.getManagedLineBreak();return t!==null&&t.parentElement!==this.element&&Q(222),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&Q(223),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&Q(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"&&(Vn||oi);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,i=document.createElement("br");if(n.insertBefore(i,s),e){const o=document.createElement("img");o.setAttribute("data-lexical-linebreak","true"),o.style.cssText="display: inline !important; border: 0px !important; margin: 0px !important;",o.alt="",n.insertBefore(o,i),n.__lexicalLineBreak=o}else n.__lexicalLineBreak=i}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 a=this.getFirstChildOffset();return[e,Math.min(a+e.getChildrenSize(),Math.max(a,s))]}const i=ul(t,n);i.push(s);const o=ul(t,this.element);let l=e.getIndexWithinParent();for(let a=0;a<o.length;a++){const u=i[a],c=o[a];if(u===void 0||u<c)break;if(u>c){l+=1;break}}return[e.getParentOrThrow(),l]}}function ul(r,e){const t=[];let n=e;for(;n!==r&&n!==null;n=e.parentNode){let s=0;for(let i=n.previousSibling;i!==null;i=n.previousSibling)s++;t.push(s)}return n!==r&&Q(225),t.reverse()}class lr extends hi{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 sh[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=nt()._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(Z(t)&&e.push(t),O(t)){const n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;O(e);){const t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;O(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 i=t[n-1];return O(i)&&i.getLastDescendant()||i||null}const s=t[e];return O(s)&&s.getFirstDescendant()||s||null}getFirstChild(){const e=this.getLatest().__first;return e===null?null:ht(e)}getFirstChildOrThrow(){const e=this.getFirstChild();return e===null&&Q(45,this.__key),e}getLastChild(){const e=this.getLatest().__last;return e===null?null:ht(e)}getLastChildOrThrow(){const e=this.getLastChild();return e===null&&Q(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 i=t[s];e+=i.getTextContent(),O(i)&&s!==n-1&&!i.isInline()&&(e+=sr)}return e}getTextContentSize(){let e=0;const t=this.getChildren(),n=t.length;for(let s=0;s<n;s++){const i=t[s];e+=i.getTextContentSize(),O(i)&&s!==n-1&&!i.isInline()&&(e+=sr.length)}return e}getDirection(){return this.getLatest().__dir}hasFormat(e){if(e!==""){const t=Aa[e];return!!(this.getFormat()&t)}return!1}select(e,t){Ct();const n=ae();let s=e,i=t;const o=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){const a=this.getFirstChild();if(Z(a)||O(a))return a.select(0,0)}else if(!(e!==void 0&&e!==o||t!==void 0&&t!==o)){const a=this.getLastChild();if(Z(a)||O(a))return a.select()}}s===void 0&&(s=o),i===void 0&&(i=o);const l=this.__key;return K(n)?(n.anchor.set(l,s,"element"),n.focus.set(l,i,"element"),n.dirty=!0,n):ac(l,s,l,i,"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!==""?Aa[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,i=this.getChildrenSize(),o=this.getWritable();e+t<=i||Q(226,String(e),String(t),String(i));const l=o.__key,a=[],u=[],c=this.getChildAtIndex(e+t);let d=null,h=i-t+s;if(e!==0)if(e===i)d=this.getLastChild();else{const g=this.getChildAtIndex(e);g!==null&&(d=g.getPreviousSibling())}if(t>0){let g=d===null?this.getFirstChild():d.getNextSibling();for(let m=0;m<t;m++){g===null&&Q(100);const x=g.getNextSibling(),_=g.__key;Dr(g.getWritable()),u.push(_),g=x}}let p=d;for(let g=0;g<s;g++){const m=n[g];p!==null&&m.is(p)&&(d=p=p.getPreviousSibling());const x=m.getWritable();x.__parent===l&&h--,Dr(x);const _=m.__key;if(p===null)o.__first=_,x.__prev=null;else{const b=p.getWritable();b.__next=_,x.__prev=b.__key}m.__key===l&&Q(76),x.__parent=l,a.push(_),p=m}if(e+t===i)p!==null&&(p.getWritable().__next=null,o.__last=p.__key);else if(c!==null){const g=c.getWritable();if(p!==null){const m=p.getWritable();g.__prev=p.__key,m.__next=c.__key}else g.__prev=null}if(o.__size=h,u.length){const g=ae();if(K(g)){const m=new Set(u),x=new Set(a),{anchor:_,focus:b}=g;cl(_,m,x)&&Hs(_,_.getNode(),this,d,c),cl(b,m,x)&&Hs(b,b.getNode(),this,d,c),h!==0||this.canBeEmpty()||Qt(this)||this.remove()}}return o}getDOMSlot(e){return new Mn(e)}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&or(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 i=this.getFirstChild();i;i=i.getNextSibling()){const o=t.getElementByKey(i.getKey());o!==null&&(s==null?(n.insertChild(o),s=o):s!==o&&n.replaceChild(o,s),s=s.nextSibling)}}}function O(r){return r instanceof lr}function cl(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 ra extends hi{constructor(e){super(e)}decorate(e,t){Q(47)}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function Ge(r){return r instanceof ra}class ts extends lr{static getType(){return"root"}static clone(){return new ts}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){Q(51)}getTextContent(){const e=this.__cachedText;return!es()&&nt()._dirtyType!==Nr||e===null?super.getTextContent():e}remove(){Q(52)}replace(e){Q(53)}insertBefore(e){Q(54)}insertAfter(e){Q(55)}updateDOM(e,t){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];O(n)||Ge(n)||Q(56)}return super.append(...e)}static importJSON(e){const t=et();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 yt(r){return r instanceof ts}function pc(r){return new gi(new Map(r._nodeMap))}function na(){return new gi(new Map([["root",new ts]]))}function gc(r){const e=r.exportJSON(),t=r.constructor;if(e.type!==t.getType()&&Q(130,t.name),O(r)){const n=e.children;Array.isArray(n)||Q(59,t.name);const s=r.getChildren();for(let i=0;i<s.length;i++){const o=gc(s[i]);n.push(o)}}return e}class gi{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 al(t&&t.editor||null,this,e)}clone(e){const t=new gi(this._nodeMap,e===void 0?this._selection:e);return t._readOnly=!0,t}toJSON(){return al(null,this,()=>({root:gc(et())}))}}class sa extends lr{static getType(){return"artificial"}createDOM(e){return document.createElement("div")}}class on extends lr{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=Br[e];return!!(this.getTextFormat()&t)}getFormatFlags(e,t){return Ls(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 on(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}createDOM(e){const t=document.createElement("p"),n=An(e.theme,"paragraph");return n!==void 0&&t.classList.add(...n),t}updateDOM(e,t,n){return!1}static importDOM(){return{p:e=>({conversion:Uh,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&or(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=at();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=at();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||Z(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 Uh(r){const e=at();return r.style&&(e.setFormat(r.style.textAlign),Xo(r,e)),{node:e}}function at(){return Xt(new on)}function tn(r){return r instanceof on}const We=0,Vr=1,Wh=4;function mc(r,e,t,n){const s=r._keyToDOMMap;s.clear(),r._editorState=na(),r._pendingEditorState=n,r._compositionKey=null,r._dirtyType=Nr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),r._normalizedNodes=new Set,r._updateTags=new Set,r._updates=[],r._blockCursorElement=null;const i=r._observer;i!==null&&(i.disconnect(),r._observer=null),e!==null&&(e.textContent=""),t!==null&&(t.textContent="",s.set("root",t))}function Hh(r){const e=r||{},t=$h(),n=e.theme||{},s=r===void 0?t:e.parentEditor||null,i=e.disableEvents||!1,o=na(),l=e.namespace||(s!==null?s._config.namespace:Ou()),a=e.editorState,u=[ts,sn,Qn,Jn,on,sa,...e.nodes||[]],{onError:c,html:d}=e,h=e.editable===void 0||e.editable;let p;if(r===void 0&&t!==null)p=t._nodes;else{p=new Map;for(let m=0;m<u.length;m++){let x=u[m],_=null,b=null;if(typeof x!="function"){const E=x;x=E.replace,_=E.with,b=E.withKlass||null}const C=x.getType(),S=x.transform(),k=new Set;S!==null&&k.add(S),p.set(C,{exportDOM:d&&d.export?d.export.get(x):void 0,klass:x,replace:_,replaceWithKlass:b,transforms:k})}}const g=new mi(o,s,p,{disableEvents:i,namespace:l,theme:n},c||console.error,function(m,x){const _=new Map,b=new Set,C=S=>{Object.keys(S).forEach(k=>{let E=_.get(k);E===void 0&&(E=[],_.set(k,E)),E.push(S[k])})};return m.forEach(S=>{const k=S.klass.importDOM;if(k==null||b.has(k))return;b.add(k);const E=k.call(S.klass);E!==null&&C(E)}),x&&C(x),_}(p,d?d.import:void 0),h);return a!==void 0&&(g._pendingEditorState=a,g._dirtyType=Zr),g}class mi{constructor(e,t,n,s,i,o,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=Nr,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=Ou(),this._onError=i,this._htmlConversions=o,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&&Q(35);const s=this._commands;s.has(e)||s.set(e,[new Set,new Set,new Set,new Set,new Set]);const i=s.get(e);i===void 0&&Q(36,String(e));const o=i[n];return o.add(t),()=>{o.delete(t),i.every(l=>l.size===0)&&s.delete(e)}}registerMutationListener(e,t,n){const s=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,i=this._listeners.mutation;i.set(t,s);const o=n&&n.skipInitialization;return o!==void 0&&o||this.initializeMutationListener(t,s),()=>{i.delete(t)}}getRegisteredNode(e){const t=this._nodes.get(e.getType());return t===void 0&&Q(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){const n=this._editorState,s=Sh(n).get(t.getType());if(!s)return;const i=new Map;for(const o of s.keys())i.set(o,"created");i.size>0&&e(i,{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],i=n.replaceWithKlass;if(i!=null){const a=this.registerNodeTransformToKlass(i,t);s.push(a)}var o,l;return o=this,l=e.getType(),Dt(o,()=>{const a=ar();if(a.isEmpty())return;if(l==="root")return void et().markDirty();const u=a._nodeMap;for(const[,c]of u)c.markDirty()},o._pendingEditorState===null?{tag:"history-merge"}:void 0),()=>{s.forEach(a=>a.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,t){return ie(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=An(this._config.theme,"root"),s=this._pendingEditorState||this._editorState;if(this._rootElement=e,mc(this,t,e,s),t!==null&&(this._config.disableEvents||Th(t),n!=null&&t.classList.remove(...n)),e!==null){const i=function(l){const a=l.ownerDocument;return a&&a.defaultView||null}(e),o=e.style;o.userSelect="text",o.whiteSpace="pre-wrap",o.wordBreak="break-word",e.setAttribute("data-lexical-editor","true"),this._window=i,this._dirtyType=Zr,ju(this),this._updateTags.add("history-merge"),pr(this),this._config.disableEvents||function(l,a){const u=l.ownerDocument,c=Us.get(u);(c===void 0||c<1)&&u.addEventListener("selectionchange",rc),Us.set(u,(c||0)+1),l.__lexicalEditor=a;const d=tc(l);for(let h=0;h<io.length;h++){const[p,g]=io[h],m=typeof g=="function"?x=>{Va(x)||(Ha(x),(a.isEditable()||p==="click")&&g(x,a))}:x=>{if(Va(x))return;Ha(x);const _=a.isEditable();switch(p){case"cut":return _&&ie(a,Ro,x);case"copy":return ie(a,ii,x);case"paste":return _&&ie(a,si,x);case"dragstart":return _&&ie(a,Su,x);case"dragover":return _&&ie(a,ku,x);case"dragend":return _&&ie(a,$f,x);case"focus":return _&&ie(a,Wf,x);case"blur":return _&&ie(a,Hf,x);case"drop":return _&&ie(a,Cu,x)}};l.addEventListener(p,m),d.push(()=>{l.removeEventListener(p,m)})}}(e,this),n!=null&&e.classList.add(...n)}else this._editorState=s,this._pendingEditorState=null,this._window=null;jn("root",this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&Q(38);let n=e;n._readOnly&&(n=pc(e),n._selection=e._selection?e._selection.clone():null),Bu(this);const s=this._pendingEditorState,i=this._updateTags,o=t!==void 0?t.tag:null;s===null||s.isEmpty()||(o!=null&&i.add(o),pr(this)),this._pendingEditorState=n,this._dirtyType=Zr,this._dirtyElements.set("root",!1),this._compositionKey=null,o!=null&&i.add(o),this._updating||pr(this)}parseEditorState(e,t){return function(n,s,i){const o=na(),l=ct,a=kt,u=dt,c=s._dirtyElements,d=s._dirtyLeaves,h=s._cloneNotNeeded,p=s._dirtyType;s._dirtyElements=new Map,s._dirtyLeaves=new Set,s._cloneNotNeeded=new Set,s._dirtyType=0,ct=o,kt=!1,dt=s;try{const g=s._nodes;ta(n.root,g),i&&i(),o._readOnly=!0}catch(g){g instanceof Error&&s._onError(g)}finally{s._dirtyElements=c,s._dirtyLeaves=d,s._cloneNotNeeded=h,s._dirtyType=p,ct=l,kt=a,dt=u}return o}(typeof e=="string"?JSON.parse(e):e,this,t)}read(e){return pr(this),this.getEditorState().read(e,{editor:this})}update(e,t){Dt(this,e,t)}focus(e,t={}){const n=this._rootElement;n!==null&&(n.setAttribute("autocapitalize","off"),Dt(this,()=>{const s=ae(),i=et();s!==null?s.dirty=!0:i.getChildrenSize()!==0&&(t.defaultSelection==="rootStart"?i.selectStart():i.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=Bt(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,jn("editable",this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}}mi.version="0.21.0+prod.esm";const yc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Vh=yc?y.useLayoutEffect:y.useEffect,ds={tag:"history-merge"};function Gh({initialConfig:r,children:e}){const t=y.useMemo(()=>{const{theme:n,namespace:s,nodes:i,onError:o,editorState:l,html:a}=r,u=Bf(null,n),c=Hh({editable:r.editable,html:a,namespace:s,nodes:i,onError:d=>o(d,c),theme:n});return function(d,h){if(h!==null){if(h===void 0)d.update(()=>{const p=et();if(p.isEmpty()){const g=at();p.append(g);const m=yc?document.activeElement:null;(ae()!==null||m!==null&&m===d.getRootElement())&&g.select()}},ds);else if(h!==null)switch(typeof h){case"string":{const p=d.parseEditorState(h);d.setEditorState(p,ds);break}case"object":d.setEditorState(h,ds);break;case"function":d.update(()=>{et().isEmpty()&&h(d)},ds)}}}(c,l),[c,u]},[]);return Vh(()=>{const n=r.editable,[s]=t;s.setEditable(n===void 0||n)},[]),f.jsx(pu.Provider,{value:t,children:e})}const Kh=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Yh(r){return{initialValueFn:()=>r.isEditable(),subscribe:e=>r.registerEditableListener(e)}}function Qh(){return function(r){const[e]=$t(),t=y.useMemo(()=>r(e),[e,r]),[n,s]=y.useState(()=>t.initialValueFn()),i=y.useRef(n);return Kh(()=>{const{initialValueFn:o,subscribe:l}=t,a=o();return i.current!==a&&(i.current=a,s(a)),l(u=>{i.current=u,s(u)})},[t,r]),n}(Yh)}function Jh(){return et().getTextContent()}function Xh(r,e=!0){if(r)return!1;let t=Jh();return e&&(t=t.trim()),t===""}function Zh(r){if(!Xh(r,!1))return!1;const e=et().getChildren(),t=e.length;if(t>1)return!1;for(let n=0;n<t;n++){const s=e[n];if(Ge(s))return!1;if(O(s)){if(!tn(s)||s.__indent!==0)return!1;const i=s.getChildren(),o=i.length;for(let l=0;l<o;l++){const a=i[n];if(!Z(a))return!1}}}return!0}function xc(r){return()=>Zh(r)}function ep(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}ep(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 tp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var rp=tp(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 np=new Map;function sp(r){const e={};if(!r)return e;const t=r.split(";");for(const n of t)if(n!==""){const[s,i]=n.split(/:([^]+)/);s&&i&&(e[s.trim()]=i.trim())}return e}function bc(r,e){const t=r.getStartEndPoints();if(e.isSelected(r)&&!e.isSegmented()&&!e.isToken()&&t!==null){const[n,s]=t,i=r.isBackward(),o=n.getNode(),l=s.getNode(),a=e.is(o),u=e.is(l);if(a||u){const[c,d]=uo(r),h=o.is(l),p=e.is(i?l:o),g=e.is(i?o:l);let m,x=0;return h?(x=c>d?d:c,m=c>d?c:d):p?(x=i?d:c,m=void 0):g&&(x=0,m=i?c:d),e.__text=e.__text.slice(x,m),e}}return e}function ip(r){const e=r.getStyle(),t=sp(e);np.set(e,t)}function op(r,e){if(r===null)return;const t=r.getStartEndPoints(),n=t?t[0]:null;if(n!==null&&n.key==="root"){const o=e(),l=et(),a=l.getFirstChild();return void(a?a.replace(o,!0):l.append(o))}const s=r.getNodes(),i=n!==null&&function(o,l){let a=o;for(;a!==null&&a.getParent()!==null&&!l(a);)a=a.getParentOrThrow();return l(a)?a:null}(n.getNode(),hl);i&&s.indexOf(i)===-1&&s.push(i);for(let o=0;o<s.length;o++){const l=s[o];if(!hl(l))continue;O(l)||rp(178);const a=e();a.setFormat(l.getFormatType()),a.setIndent(l.getIndent()),l.replace(a,!0)}}function dl(r,e){const t=Pn(r.focus,e);return Ge(t)&&!t.isIsolated()||O(t)&&!t.isInline()&&!t.canBeEmpty()}function ap(r,e,t,n){r.modify(e?"extend":"move",t,n)}function lp(r){const e=r.anchor.getNode();return(yt(e)?e:e.getParentOrThrow()).getDirection()==="rtl"}function fl(r,e,t){const n=lp(r);ap(r,e,t?!n:n,"character")}function hl(r){if(Ge(r)||!O(r)||Qt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||Z(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function up(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var cp=up(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=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,dp=vc&&"documentMode"in document?document.documentMode:null;!(!vc||!("InputEvent"in window)||dp)&&"getTargetRanges"in new window.InputEvent("input");function _c(...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 Pr(...r){return()=>{for(let e=r.length-1;e>=0;e--)r[e]();r.length=0}}function rs(r,...e){const t=_c(...e);t.length>0&&r.classList.add(...t)}function wc(r,...e){const t=_c(...e);t.length>0&&r.classList.remove(...t)}function fp(r,e){let t=r;for(;t!=null;){if(t instanceof e)return t;t=t.getParent()}return null}function hp(r){const e=yi(r,t=>O(t)&&!t.isInline());return O(e)||cp(4,r.__key),e}const yi=(r,e)=>{let t=r;for(;t!==et()&&t!=null;){if(e(t))return t;t=t.getParent()}return null};function gr(r,e){return r!==null&&Object.getPrototypeOf(r).constructor.name===e.name}function pp(r){const e=window.location.origin,t=n=>{if(n.origin!==e)return;const s=r.getRootElement();if(document.activeElement!==s)return;const i=n.data;if(typeof i=="string"){let o;try{o=JSON.parse(i)}catch{return}if(o&&o.protocol==="nuanria_messaging"&&o.type==="request"){const l=o.payload;if(l&&l.functionId==="makeChanges"){const a=l.args;if(a){const[u,c,d,h,p,g]=a;r.update(()=>{const m=ae();if(K(m)){const x=m.anchor;let _=x.getNode(),b=0,C=0;if(Z(_)&&u>=0&&c>=0&&(b=u,C=u+c,m.setTextNodeRange(_,b,_,C)),b===C&&d===""||(m.insertRawText(d),_=x.getNode()),Z(_)){b=h,C=h+p;const S=_.getTextContentSize();b=b>S?S:b,C=C>S?S:C,m.setTextNodeRange(_,b,_,C)}n.stopImmediatePropagation()}})}}}}};return window.addEventListener("message",t,!0),()=>{window.removeEventListener("message",t,!0)}}function Cc(r,e){const t=e.body?e.body.childNodes:[];let n=[];const s=[];for(let i=0;i<t.length;i++){const o=t[i];if(!Ec.has(o.nodeName)){const l=Dc(o,r,s,!1);l!==null&&(n=n.concat(l))}}return function(i){for(const o of i)o.getNextSibling()instanceof sa&&o.insertAfter(Mr());for(const o of i){const l=o.getChildren();for(const a of l)o.insertBefore(a);o.remove()}}(s),n}function Sc(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=et().getChildren();for(let s=0;s<n.length;s++)kc(r,n[s],t,e);return t.innerHTML}function kc(r,e,t,n=null){let s=n===null||e.isSelected(n);const i=O(e)&&e.excludeFromCopy("html");let o=e;if(n!==null){let p=Jo(e);p=Z(p)&&n!==null?bc(n,p):p,o=p}const l=O(o)?o.getChildren():[],a=r._nodes.get(o.getType());let u;u=a&&a.exportDOM!==void 0?a.exportDOM(r,o):o.exportDOM(r);const{element:c,after:d}=u;if(!c)return!1;const h=document.createDocumentFragment();for(let p=0;p<l.length;p++){const g=l[p],m=kc(r,g,h,n);!s&&O(e)&&m&&e.extractWithChild(g,n,"html")&&(s=!0)}if(s&&!i){if((or(c)||Oa(c))&&c.append(h),t.append(c),d){const p=d.call(o,c);p&&(Oa(c)?c.replaceChildren(p):c.replaceWith(p))}}else t.append(h);return s}const Ec=new Set(["STYLE","SCRIPT"]);function Dc(r,e,t,n,s=new Map,i){let o=[];if(Ec.has(r.nodeName))return o;let l=null;const a=function(g,m){const{nodeName:x}=g,_=m._htmlConversions.get(x.toLowerCase());let b=null;if(_!==void 0)for(const C of _){const S=C(g);S!==null&&(b===null||(b.priority||0)<=(S.priority||0))&&(b=S)}return b!==null?b.conversion:null}(r,e),u=a?a(r):null;let c=null;if(u!==null){c=u.after;const g=u.node;if(l=Array.isArray(g)?g[g.length-1]:g,l!==null){for(const[,m]of s)if(l=m(l,i),!l)break;l&&o.push(...Array.isArray(g)?g:[l])}u.forChild!=null&&s.set(r.nodeName,u.forChild)}const d=r.childNodes;let h=[];const p=(l==null||!Qt(l))&&(l!=null&&co(l)||n);for(let g=0;g<d.length;g++)h.push(...Dc(d[g],e,t,p,new Map(s),l));return c!=null&&(h=c(h)),zs(r)&&(h=gp(r,h,p?()=>{const g=new sa;return t.push(g),g}:at)),l==null?h.length>0?o=o.concat(h):zs(r)&&function(g){return g.nextSibling==null||g.previousSibling==null?!1:Ji(g.nextSibling)&&Ji(g.previousSibling)}(r)&&(o=o.concat(Mr())):O(l)&&l.append(...h),o}function gp(r,e,t){const n=r.style.textAlign,s=[];let i=[];for(let o=0;o<e.length;o++){const l=e[o];if(co(l))n&&!l.getFormat()&&l.setFormat(n),s.push(l);else if(i.push(l),o===e.length-1||o<e.length-1&&co(e[o+1])){const a=t();a.setFormat(n),a.append(...i),s.push(a),i=[]}}return s}function mp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Vs=mp(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 yp(r,e=ae()){return e==null&&Vs(166),K(e)&&e.isCollapsed()||e.getNodes().length===0?"":Sc(r,e)}function xp(r,e=ae()){return e==null&&Vs(166),K(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(bp(r,e))}function pl(r,e,t){const n=r.getData("application/x-lexical-editor");if(n)try{const o=JSON.parse(n);if(o.namespace===t._config.namespace&&Array.isArray(o.nodes))return gl(t,vp(o.nodes),e)}catch{}const s=r.getData("text/html");if(s)try{const o=new DOMParser().parseFromString(function(l){return window.trustedTypes&&window.trustedTypes.createPolicy?window.trustedTypes.createPolicy("lexical",{createHTML:a=>a}).createHTML(l):l}(s),"text/html");return gl(t,Cc(t,o),e)}catch{}const i=r.getData("text/plain")||r.getData("text/uri-list");if(i!=null)if(K(e)){const o=i.split(/(\r?\n|\t)/);o[o.length-1]===""&&o.pop();for(let l=0;l<o.length;l++){const a=ae();if(K(a)){const u=o[l];u===`
93
+ `?n.push(Mr()):o===" "?n.push(Xn()):n.push(lt(o))}this.insertNodes(n)}insertText(e){const t=this.anchor,n=this.focus,s=this.format,i=this.style;let o=t,a=n;!this.isCollapsed()&&n.isBefore(t)&&(o=n,a=t),o.type==="element"&&function(x,_,b,S){const C=x.getNode(),k=C.getChildAtIndex(x.offset),E=lt(),v=yt(C)?ot().append(E):E;E.setFormat(b),E.setStyle(S),k===null?C.append(v):k.insertBefore(v),x.is(_)&&_.set(E.__key,0,"text"),x.set(E.__key,0,"text")}(o,a,s,i);const l=o.offset;let u=a.offset;const c=this.getNodes(),d=c.length;let h=c[0];ee(h)||K(26);const p=h.getTextContent().length,g=h.getParentOrThrow();let m=c[d-1];if(d===1&&a.type==="element"&&(u=p,a.set(o.key,u,"text")),this.isCollapsed()&&l===p&&(h.isSegmented()||h.isToken()||!h.canInsertTextAfter()||!g.canInsertTextAfter()&&h.getNextSibling()===null)){let x=h.getNextSibling();if(ee(x)&&x.canInsertTextBefore()&&!Cr(x)||(x=lt(),x.setFormat(s),x.setStyle(i),g.canInsertTextAfter()?h.insertAfter(x):g.insertAfter(x)),x.select(0,0),h=x,e!=="")return void this.insertText(e)}else if(this.isCollapsed()&&l===0&&(h.isSegmented()||h.isToken()||!h.canInsertTextBefore()||!g.canInsertTextBefore()&&h.getPreviousSibling()===null)){let x=h.getPreviousSibling();if(ee(x)&&!Cr(x)||(x=lt(),x.setFormat(s),g.canInsertTextBefore()?h.insertBefore(x):g.insertBefore(x)),x.select(),h=x,e!=="")return void this.insertText(e)}else if(h.isSegmented()&&l!==p){const x=lt(h.getTextContent());x.setFormat(s),h.replace(x),h=x}else if(!this.isCollapsed()&&e!==""){const x=m.getParent();if(!g.canInsertTextBefore()||!g.canInsertTextAfter()||$(x)&&(!x.canInsertTextBefore()||!x.canInsertTextAfter()))return this.insertText(""),ic(this.anchor,this.focus,null),void this.insertText(e)}if(d===1){if(h.isToken()){const S=lt(e);return S.select(),void h.replace(S)}const x=h.getFormat(),_=h.getStyle();if(l!==u||x===s&&_===i){if(Lh(h)){const S=lt(e);return S.setFormat(s),S.setStyle(i),S.select(),void h.replace(S)}}else{if(h.getTextContent()!==""){const S=lt(e);if(S.setFormat(s),S.setStyle(i),S.select(),l===0)h.insertBefore(S,!1);else{const[C]=h.splitText(l);C.insertAfter(S,!1)}return void(S.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length))}h.setFormat(s),h.setStyle(i)}const b=u-l;h=h.spliceText(l,b,e,!0),h.getTextContent()===""?h.remove():this.anchor.type==="text"&&(h.isComposing()?this.anchor.offset-=e.length:(this.format=x,this.style=_))}else{const x=new Set([...h.getParentKeys(),...m.getParentKeys()]),_=$(h)?h:h.getParentOrThrow();let b=$(m)?m:m.getParentOrThrow(),S=m;if(!_.is(b)&&b.isInline())do S=b,b=b.getParentOrThrow();while(b.isInline());if(a.type==="text"&&(u!==0||m.getTextContent()==="")||a.type==="element"&&m.getIndexWithinParent()<u)if(ee(m)&&!m.isToken()&&u!==m.getTextContentSize()){if(m.isSegmented()){const T=lt(m.getTextContent());m.replace(T),m=T}yt(a.getNode())||a.type!=="text"||(m=m.spliceText(0,u,"")),x.add(m.__key)}else{const T=m.getParentOrThrow();T.canBeEmpty()||T.getChildrenSize()!==1?m.remove():T.remove()}else x.add(m.__key);const C=b.getChildren(),k=new Set(c),E=_.is(b),v=_.isInline()&&h.getNextSibling()===null?_:h;for(let T=C.length-1;T>=0;T--){const B=C[T];if(B.is(h)||$(B)&&B.isParentOf(h))break;B.isAttached()&&(!k.has(B)||B.is(S)?E||v.insertAfter(B,!1):B.remove())}if(!E){let T=b,B=null;for(;T!==null;){const j=T.getChildren(),N=j.length;(N===0||j[N-1].is(B))&&(x.delete(T.__key),B=T),T=T.getParent()}}if(h.isToken())if(l===p)h.select();else{const T=lt(e);T.select(),h.replace(T)}else h=h.spliceText(l,p-l,e,!0),h.getTextContent()===""?h.remove():h.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length);for(let T=1;T<d;T++){const B=c[T],j=B.__key;x.has(j)||B.remove()}}}removeText(){if(this.isCollapsed())return;const{anchor:e,focus:t}=this,n=this.getNodes(),s=this.isBackward()?t:e,i=this.isBackward()?e:t;let o=s.getNode(),a=i.getNode();const l=pn(o,ur),u=pn(a,ur);ee(o)&&o.isToken()&&s.offset<o.getTextContentSize()&&(s.offset=0),i.offset>0&&ee(a)&&a.isToken()&&(i.offset=a.getTextContentSize()),n.forEach(d=>{Tn(o,d)||Tn(a,d)||d.getKey()===o.getKey()||d.getKey()===a.getKey()||d.remove()});const c=(d,h)=>{if(d.getTextContent()==="")d.remove();else if(h!==0&&Cr(d)){const p=lt(d.getTextContent());return p.setFormat(d.getFormat()),p.setStyle(d.getStyle()),d.replace(p)}};if(o===a&&ee(o)){const d=Math.abs(t.offset-e.offset);return o.spliceText(s.offset,d,"",!0),void c(o,d)}if(ee(o)){const d=o.getTextContentSize()-s.offset;o.spliceText(s.offset,d,""),o=c(o,d)||o}ee(a)&&(a.spliceText(0,i.offset,""),a=c(a,i.offset)||a),o.isAttached()&&ee(o)?o.selectEnd():a.isAttached()&&ee(a)&&a.selectStart(),$(l)&&$(u)&&l!==u&&(l.append(...u.getChildren()),u.remove(),i.set(s.key,s.offset,s.type))}formatText(e,t=null){if(this.isCollapsed())return this.toggleFormat(e),void ht(null);const n=this.getNodes(),s=[];for(const C of n)ee(C)&&s.push(C);const i=C=>{n.forEach(k=>{if(tn(k)){const E=k.getFormatFlags(e,C);k.setTextFormat(E)}})},o=s.length;if(o===0)return this.toggleFormat(e),ht(null),void i(t);const a=this.anchor,l=this.focus,u=this.isBackward(),c=u?l:a,d=u?a:l;let h=0,p=s[0],g=c.type==="element"?0:c.offset;if(c.type==="text"&&g===p.getTextContentSize()&&(h=1,p=s[1],g=0),p==null)return;const m=p.getFormatFlags(e,t);i(m);const x=o-1;let _=s[x];const b=d.type==="text"?d.offset:_.getTextContentSize();if(p.is(_)){if(g===b)return;if(Cr(p)||g===0&&b===p.getTextContentSize())p.setFormat(m);else{const C=p.splitText(g,b),k=g===0?C[0]:C[1];k.setFormat(m),c.type==="text"&&c.set(k.__key,0,"text"),d.type==="text"&&d.set(k.__key,b-g,"text")}return void(this.format=m)}g===0||Cr(p)||([,p]=p.splitText(g),g=0),p.setFormat(m);const S=_.getFormatFlags(e,m);b>0&&(b===_.getTextContentSize()||Cr(_)||([_]=_.splitText(b)),_.setFormat(S));for(let C=h+1;C<x;C++){const k=s[C],E=k.getFormatFlags(e,S);k.setFormat(E)}c.type==="text"&&c.set(p.__key,g,"text"),d.type==="text"&&d.set(_.__key,b,"text"),this.format=m|S}insertNodes(e){if(e.length===0)return;if(this.anchor.key==="root"){this.insertParagraph();const g=ae();return V(g)||K(134),g.insertNodes(e)}const t=(this.isBackward()?this.focus:this.anchor).getNode(),n=pn(t,ur),s=e[e.length-1];if($(n)&&"__language"in n){if("__language"in e[0])this.insertText(e[0].getTextContent());else{const g=zi(this);n.splice(g,0,e),s.selectEnd()}return}if(!e.some(g=>($(g)||Ge(g))&&!g.isInline())){$(n)||K(211,t.constructor.name,t.getType());const g=zi(this);return n.splice(g,0,e),void s.selectEnd()}const i=function(g){const m=ot();let x=null;for(let _=0;_<g.length;_++){const b=g[_],S=Ar(b);if(S||Ge(b)&&b.isInline()||$(b)&&b.isInline()||ee(b)||b.isParentRequired()){if(x===null&&(x=b.createParentElementNode(),m.append(x),S))continue;x!==null&&x.append(b)}else m.append(b),x=null}return m}(e),o=i.getLastDescendant(),a=i.getChildren(),l=!$(n)||!n.isEmpty()?this.insertParagraph():null,u=a[a.length-1];let c=a[0];var d;$(d=c)&&ur(d)&&!d.isEmpty()&&$(n)&&(!n.isEmpty()||n.canMergeWhenEmpty())&&($(n)||K(211,t.constructor.name,t.getType()),n.append(...c.getChildren()),c=a[1]),c&&(n===null&&K(212,t.constructor.name,t.getType()),function(g,m,x){const _=m.getParentOrThrow().getLastChild();let b=m;const S=[m];for(;b!==_;)b.getNextSibling()||K(140),b=b.getNextSibling(),S.push(b);let C=g;for(const k of S)C=C.insertAfter(k)}(n,c));const h=pn(o,ur);l&&$(h)&&(l.canMergeWhenEmpty()||ur(u))&&(h.append(...l.getChildren()),l.remove()),$(n)&&n.isEmpty()&&n.remove(),o.selectEnd();const p=$(n)?n.getLastChild():null;Ar(p)&&h!==n&&p.remove()}insertParagraph(){if(this.anchor.key==="root"){const o=ot();return Ze().splice(this.anchor.offset,0,[o]),o.select(),o}const e=zi(this),t=pn(this.anchor.getNode(),ur);$(t)||K(213);const n=t.getChildAtIndex(e),s=n?[n,...n.getNextSiblings()]:[],i=t.insertNewAfter(this,!1);return i?(i.append(...s),i.selectStart(),i):null}insertLineBreak(e){const t=Mr();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,i=this.focus;let o=e[0],a=e[n];const[l,u]=uo(this);if(t===0)return[];if(t===1){if(ee(o)&&!this.isCollapsed()){const d=l>u?u:l,h=l>u?l:u,p=o.splitText(d,h),g=d===0?p[0]:p[1];return g!=null?[g]:[]}return[o]}const c=s.isBefore(i);if(ee(o)){const d=c?l:u;d===o.getTextContentSize()?e.shift():d!==0&&([,o]=o.splitText(d),e[0]=o)}if(ee(a)){const d=a.getTextContent().length,h=c?u:l;h===0?e.pop():h!==d&&([a]=a.splitText(h),e[n]=a)}return e}modify(e,t,n){const s=this.focus,i=this.anchor,o=e==="move",a=Pn(s,t);if(Ge(a)&&!a.isIsolated()){if(o&&a.isKeyboardSelectable()){const p=tl();return p.add(a.__key),void Gt(p)}const h=t?a.getPreviousSibling():a.getNextSibling();if(ee(h)){const p=h.__key,g=t?h.getTextContent().length:0;return s.set(p,g,"text"),void(o&&i.set(p,g,"text"))}{const p=a.getParentOrThrow();let g,m;return $(h)?(m=h.__key,g=t?h.getChildrenSize():0):(g=a.getIndexWithinParent(),m=p.__key,t||g++),s.set(m,g,"element"),void(o&&i.set(m,g,"element"))}}const l=rt(),u=Bt(l._window);if(!u)return;const c=l._blockCursorElement,d=l._rootElement;if(d===null||c===null||!$(a)||a.isInline()||a.canBeEmpty()||Qo(c,l,d),function(h,p,g,m){h.modify(p,g,m)}(u,e,t?"backward":"forward",n),u.rangeCount>0){const h=u.getRangeAt(0),p=this.anchor.getNode(),g=yt(p)?p:bh(p);if(this.applyDOMRange(h),this.dirty=!0,!o){const m=this.getNodes(),x=[];let _=!1;for(let b=0;b<m.length;b++){const S=m[b];Tn(S,g)?x.push(S):_=!0}if(_&&x.length>0)if(t){const b=x[0];$(b)?b.selectStart():b.getParentOrThrow().selectStart()}else{const b=x[x.length-1];$(b)?b.selectEnd():b.getParentOrThrow().selectEnd()}u.anchorNode===h.startContainer&&u.anchorOffset===h.startOffset||function(b){const S=b.focus,C=b.anchor,k=C.key,E=C.offset,v=C.type;cr(C,S.key,S.offset,S.type),cr(S,k,E,v),b._cachedNodes=null}(this)}}}forwardDeletion(e,t,n){if(!n&&(e.type==="element"&&$(t)&&e.offset===t.getChildrenSize()||e.type==="text"&&e.offset===t.getTextContentSize())){const s=t.getParent(),i=t.getNextSibling()||(s===null?null:s.getNextSibling());if($(i)&&i.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 i=this.focus,o=Pn(i,e);if(Ge(o)&&!o.isIsolated()){if(o.isKeyboardSelectable()&&$(s)&&s.getChildrenSize()===0){s.remove();const a=tl();a.add(o.__key),Gt(a)}else o.remove(),rt().dispatchCommand(Bo,void 0);return}if(!e&&$(o)&&$(s)&&s.isEmpty())return s.remove(),void o.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 a=i.type==="text"?i.getNode():null;if(s=n.type==="text"?n.getNode():null,a!==null&&a.isSegmented()){const l=i.offset,u=a.getTextContentSize();if(a.is(s)||e&&l!==u||!e&&l!==0)return void Xa(a,e,l)}else if(s!==null&&s.isSegmented()){const l=n.offset,u=s.getTextContentSize();if(s.is(a)||e&&l!==0||!e&&l!==u)return void Xa(s,e,l)}(function(l,u){const c=l.anchor,d=l.focus,h=c.getNode(),p=d.getNode();if(h===p&&c.type==="text"&&d.type==="text"){const g=c.offset,m=d.offset,x=g<m,_=x?g:m,b=x?m:g,S=b-1;_!==S&&(zu(h.getTextContent().slice(_,b))||(u?d.offset=S:c.offset=S))}})(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type==="element"&&this.anchor.offset===0){const n=this.anchor.getNode();n.isEmpty()&&yt(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 Ut(r){return r instanceof pi}function Ja(r){const e=r.offset;if(r.type==="text")return e;const t=r.getNode();return e===t.getChildrenSize()?t.getTextContent().length:0}function uo(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]:[Ja(t),Ja(n)]}function Xa(r,e,t){const n=r,s=n.getTextContent().split(/(?=\s)/g),i=s.length;let o=0,a=0;for(let u=0;u<i;u++){const c=u===i-1;if(a=o,o+=s[u].length,e&&o===t||o>t||c){s.splice(u,1),c&&(a=void 0);break}}const l=s.join("").trim();l===""?n.remove():(n.setTextContent(l),n.select(a,a))}function Za(r,e,t,n){let s,i=e;if(r.nodeType===Gn){let o=!1;const a=r.childNodes,l=a.length,u=n._blockCursorElement;i===l&&(o=!0,i=l-1);let c=a[i],d=!1;if(c===u)c=a[i+1],d=!0;else if(u!==null){const h=u.parentNode;r===h&&e>Array.prototype.indexOf.call(h.children,u)&&i--}if(s=Hr(c),ee(s))i=Ra(s,o);else{let h=Hr(r);if(h===null)return null;if($(h)){const p=n.getElementByKey(h.getKey());p===null&&K(214),[h,i]=h.getDOMSlot(p).resolveChildIndex(h,p,r,e),$(h)||K(215),o&&i>=h.getChildrenSize()&&(i=Math.max(0,h.getChildrenSize()-1));let m=h.getChildAtIndex(i);if($(m)&&function(x,_,b){const S=x.getParent();return b===null||S===null||!S.canBeEmpty()||S!==b.getNode()}(m,0,t)){const x=o?m.getLastDescendant():m.getFirstDescendant();x===null?h=m:(m=x,h=$(m)?m:m.getParentOrThrow()),i=0}ee(m)?(s=m,h=null,i=Ra(m,o)):m!==h&&o&&!d&&($(h)||K(216),i=Math.min(h.getChildrenSize(),i+1))}else{const p=h.getIndexWithinParent();i=e===0&&Ge(h)&&Hr(r)===h?p:p+1,h=h.getParentOrThrow()}if($(h))return Yt(h.__key,i,"element")}}else s=Hr(r);return ee(s)?Yt(s.__key,i,"text"):null}function el(r,e,t){const n=r.offset,s=r.getNode();if(n===0){const i=s.getPreviousSibling(),o=s.getParent();if(e){if((t||!e)&&i===null&&$(o)&&o.isInline()){const a=o.getPreviousSibling();ee(a)&&(r.key=a.__key,r.offset=a.getTextContent().length)}}else $(i)&&!t&&i.isInline()?(r.key=i.__key,r.offset=i.getChildrenSize(),r.type="element"):ee(i)&&(r.key=i.__key,r.offset=i.getTextContent().length)}else if(n===s.getTextContent().length){const i=s.getNextSibling(),o=s.getParent();if(e&&$(i)&&i.isInline())r.key=i.__key,r.offset=0,r.type="element";else if((t||e)&&i===null&&$(o)&&o.isInline()&&!o.canInsertTextAfter()){const a=o.getNextSibling();ee(a)&&(r.key=a.__key,r.offset=0)}}}function ic(r,e,t){if(r.type==="text"&&e.type==="text"){const n=r.isBefore(e),s=r.is(e);el(r,n,s),el(e,!n,s),s&&(e.key=r.key,e.offset=r.offset,e.type=r.type);const i=rt();if(i.isComposing()&&i._compositionKey!==r.key&&V(t)){const o=t.anchor,a=t.focus;cr(r,o.key,o.offset,o.type),cr(e,a.key,a.offset,a.type)}}}function oc(r,e,t,n,s,i){if(r===null||t===null||!Kn(s,r,t))return null;const o=Za(r,e,V(i)?i.anchor:null,s);if(o===null)return null;const a=Za(t,n,V(i)?i.focus:null,s);if(a===null)return null;if(o.type==="element"&&a.type==="element"){const l=Hr(r),u=Hr(t);if(Ge(l)&&Ge(u))return null}return ic(o,a,i),[o,a]}function co(r){return $(r)&&!r.isInline()}function ac(r,e,t,n,s,i){const o=or(),a=new xr(Yt(r,e,s),Yt(t,n,i),0,"");return a.dirty=!0,o._selection=a,a}function Ih(){const r=Yt("root",0,"element"),e=Yt("root",0,"element");return new xr(r,e,0,"")}function tl(){return new pi(new Set)}function ea(r,e,t,n){const s=t._window;if(s===null)return null;const i=n||s.event,o=i?i.type:void 0,a=o==="selectionchange",l=!Qi&&(a||o==="beforeinput"||o==="compositionstart"||o==="compositionend"||o==="click"&&i&&i.detail===3||o==="drop"||o===void 0);let u,c,d,h;if(V(r)&&!l)return r.clone();if(e===null)return null;if(u=e.anchorNode,c=e.focusNode,d=e.anchorOffset,h=e.focusOffset,a&&V(r)&&!Kn(t,u,c))return r.clone();const p=oc(u,d,c,h,t,r);if(p===null)return null;const[g,m]=p;return new xr(g,m,V(r)?r.format:0,V(r)?r.style:"")}function ae(){return or()._selection}function Zn(){return rt()._editorState._selection}function Ws(r,e,t,n=1){const s=r.anchor,i=r.focus,o=s.getNode(),a=i.getNode();if(!e.is(o)&&!e.is(a))return;const l=e.__key;if(r.isCollapsed()){const u=s.offset;if(t<=u&&n>0||t<u&&n<0){const c=Math.max(0,u+n);s.set(l,c,"element"),i.set(l,c,"element"),rl(r)}}else{const u=r.isBackward(),c=u?i:s,d=c.getNode(),h=u?s:i,p=h.getNode();if(e.is(d)){const g=c.offset;(t<=g&&n>0||t<g&&n<0)&&c.set(l,Math.max(0,g+n),"element")}if(e.is(p)){const g=h.offset;(t<=g&&n>0||t<g&&n<0)&&h.set(l,Math.max(0,g+n),"element")}}rl(r)}function rl(r){const e=r.anchor,t=e.offset,n=r.focus,s=n.offset,i=e.getNode(),o=n.getNode();if(r.isCollapsed()){if(!$(i))return;const a=i.getChildrenSize(),l=t>=a,u=l?i.getChildAtIndex(a-1):i.getChildAtIndex(t);if(ee(u)){let c=0;l&&(c=u.getTextContentSize()),e.set(u.__key,c,"text"),n.set(u.__key,c,"text")}}else{if($(i)){const a=i.getChildrenSize(),l=t>=a,u=l?i.getChildAtIndex(a-1):i.getChildAtIndex(t);if(ee(u)){let c=0;l&&(c=u.getTextContentSize()),e.set(u.__key,c,"text")}}if($(o)){const a=o.getChildrenSize(),l=s>=a,u=l?o.getChildAtIndex(a-1):o.getChildAtIndex(s);if(ee(u)){let c=0;l&&(c=u.getTextContentSize()),n.set(u.__key,c,"text")}}}}function Hs(r,e,t,n,s){let i=null,o=0,a=null;n!==null?(i=n.__key,ee(n)?(o=n.getTextContentSize(),a="text"):$(n)&&(o=n.getChildrenSize(),a="element")):s!==null&&(i=s.__key,ee(s)?a="text":$(s)&&(a="element")),i!==null&&a!==null?r.set(i,o,a):(o=e.getIndexWithinParent(),o===-1&&(o=t.getChildrenSize()),r.set(t.__key,o,"element"))}function nl(r,e,t,n,s){r.type==="text"?(r.key=t,e||(r.offset+=s)):r.offset>n.getIndexWithinParent()&&(r.offset-=1)}function zh(r,e,t,n,s,i,o){const a=n.anchorNode,l=n.focusNode,u=n.anchorOffset,c=n.focusOffset,d=document.activeElement;if(s.has("collaboration")&&d!==i||d!==null&&Wo(d))return;if(!V(e))return void(r!==null&&Kn(t,a,l)&&n.removeAllRanges());const h=e.anchor,p=e.focus,g=h.key,m=p.key,x=Is(t,g),_=Is(t,m),b=h.offset,S=p.offset,C=e.format,k=e.style,E=e.isCollapsed();let v=x,T=_,B=!1;if(h.type==="text"){v=Fs(x);const D=h.getNode();B=D.getFormat()!==C||D.getStyle()!==k}else V(r)&&r.anchor.type==="text"&&(B=!0);var j,N,R,M,w;if(p.type==="text"&&(T=Fs(_)),v!==null&&T!==null&&(E&&(r===null||B||V(r)&&(r.format!==C||r.style!==k))&&(j=C,N=k,R=b,M=g,w=performance.now(),Xu=[j,N,R,M,w]),u!==b||c!==S||a!==v||l!==T||n.type==="Range"&&E||(d!==null&&i.contains(d)||i.focus({preventScroll:!0}),h.type==="element"))){try{n.setBaseAndExtent(v,b,T,S)}catch{}if(!s.has("skip-scroll-into-view")&&e.isCollapsed()&&i!==null&&i===document.activeElement){const D=e instanceof xr&&e.anchor.type==="element"?v.childNodes[b]||null:n.rangeCount>0?n.getRangeAt(0):null;if(D!==null){let F;if(D instanceof Text){const z=document.createRange();z.selectNode(D),F=z.getBoundingClientRect()}else F=D.getBoundingClientRect();(function(z,q,J){const te=J.ownerDocument,W=te.defaultView;if(W===null)return;let{top:G,bottom:H}=q,se=0,le=0,ue=J;for(;ue!==null;){const _e=ue===te.body;if(_e)se=0,le=di(z).innerHeight;else{const De=ue.getBoundingClientRect();se=De.top,le=De.bottom}let fe=0;if(G<se?fe=-(se-G):H>le&&(fe=H-le),fe!==0)if(_e)W.scrollBy(0,fe);else{const De=ue.scrollTop;ue.scrollTop+=fe;const O=ue.scrollTop-De;G-=O,H-=O}if(_e)break;ue=Yn(ue)}})(t,F,i)}}oo=!0}}function lc(r){let e=ae()||Zn();e===null&&(e=Ze().selectEnd()),e.insertNodes(r)}function zi(r){let e=r;r.isCollapsed()||e.removeText();const t=ae();V(t)&&(e=t),V(e)||K(161);const n=e.anchor;let s=n.getNode(),i=n.offset;for(;!ur(s);)[s,i]=Oh(s,i);return i}function Oh(r,e){const t=r.getParent();if(!t){const s=ot();return Ze().append(s),s.select(),[Ze(),0]}if(ee(r)){const s=r.splitText(e);if(s.length===0)return[t,r.getIndexWithinParent()];const i=e===0?0:1;return[t,s[0].getIndexWithinParent()+i]}if(!$(r)||e===0)return[t,r.getIndexWithinParent()];const n=r.getChildAtIndex(e);if(n){const s=new xr(Yt(r.__key,e,"element"),Yt(r.__key,e,"element"),0,""),i=r.insertNewAfter(s);i&&i.append(n,...n.getNextSiblings())}return[t,r.getIndexWithinParent()+1]}let dt=null,ft=null,St=!1,Oi=!1,ws=0;const sl={characterData:!0,childList:!0,subtree:!0};function es(){return St||dt!==null&&dt._readOnly}function wt(){St&&K(13)}function uc(){ws>99&&K(14)}function or(){return dt===null&&K(195,cc()),dt}function rt(){return ft===null&&K(196,cc()),ft}function cc(){let r=0;const e=new Set,t=mi.version;if(typeof window<"u")for(const s of document.querySelectorAll("[contenteditable]")){const i=li(s);if(Ho(i))r++;else if(i){let o=String(i.constructor.version||"<0.17.1");o===t&&(o+=" (separately built, likely a bundler configuration issue)"),e.add(o)}}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 $h(){return ft}function il(r,e,t){const n=e.__type,s=function(a,l){const u=a._nodes.get(l);return u===void 0&&K(30,l),u}(r,n);let i=t.get(n);i===void 0&&(i=Array.from(s.transforms),t.set(n,i));const o=i.length;for(let a=0;a<o&&(i[a](e),e.isAttached());a++);}function ol(r,e){return r!==void 0&&r.__key!==e&&r.isAttached()}function dc(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 qh(r){return ta(r,rt()._nodes)}function ta(r,e){const t=r.type,n=e.get(t);n===void 0&&K(17,t);const s=n.klass;r.type!==s.getType()&&K(18,s.name);const i=s.importJSON(r),o=r.children;if($(i)&&Array.isArray(o))for(let a=0;a<o.length;a++){const l=ta(o[a],e);i.append(l)}return i}function al(r,e,t){const n=dt,s=St,i=ft;dt=e,St=!0,ft=r;try{return t()}finally{dt=n,St=s,ft=i}}function hr(r,e){const t=r._pendingEditorState,n=r._rootElement,s=r._headless||n===null;if(t===null)return;const i=r._editorState,o=i._selection,a=t._selection,l=r._dirtyType!==Nr,u=dt,c=St,d=ft,h=r._updating,p=r._observer;let g=null;if(r._pendingEditorState=null,r._editorState=t,!s&&l&&p!==null){ft=r,dt=t,St=!1,r._updating=!0;try{const E=r._dirtyType,v=r._dirtyElements,T=r._dirtyLeaves;p.disconnect(),g=Ah(i,t,r,E,v,T)}catch(E){if(E instanceof Error&&r._onError(E),Oi)throw E;return mc(r,null,n,t),ju(r),r._dirtyType=Zr,Oi=!0,hr(r,i),void(Oi=!1)}finally{p.observe(n,sl),r._updating=h,dt=u,St=c,ft=d}}t._readOnly||(t._readOnly=!0);const m=r._dirtyLeaves,x=r._dirtyElements,_=r._normalizedNodes,b=r._updateTags,S=r._deferred;l&&(r._dirtyType=Nr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements=new Map,r._normalizedNodes=new Set,r._updateTags=new Set),function(E,v){const T=E._decorators;let B=E._pendingDecorators||T;const j=v._nodeMap;let N;for(N in B)j.has(N)||(B===T&&(B=Pu(E)),delete B[N])}(r,t);const C=s?null:Bt(r._window);if(r._editable&&C!==null&&(l||a===null||a.dirty)){ft=r,dt=t;try{if(p!==null&&p.disconnect(),l||a===null||a.dirty){const E=r._blockCursorElement;E!==null&&Qo(E,r,n),zh(o,a,r,C,b,n)}vh(r,n,a),p!==null&&p.observe(n,sl)}finally{ft=d,dt=u}}g!==null&&function(E,v,T,B,j){const N=Array.from(E._listeners.mutation),R=N.length;for(let M=0;M<R;M++){const[w,D]=N[M],F=v.get(D);F!==void 0&&w(F,{dirtyLeaves:B,prevEditorState:j,updateTags:T})}}(r,g,b,m,i),V(a)||a===null||o!==null&&o.is(a)||r.dispatchCommand(Bo,void 0);const k=r._pendingDecorators;k!==null&&(r._decorators=k,r._pendingDecorators=null,jn("decorator",r,!0,k)),function(E,v,T){const B=Ma(v),j=Ma(T);B!==j&&jn("textcontent",E,!0,j)}(r,e||i,t),jn("update",r,!0,{dirtyElements:x,dirtyLeaves:m,editorState:t,normalizedNodes:_,prevEditorState:e||i,tags:b}),function(E,v){if(E._deferred=[],v.length!==0){const T=E._updating;E._updating=!0;try{for(let B=0;B<v.length;B++)v[B]()}finally{E._updating=T}}}(r,S),function(E){const v=E._updates;if(v.length!==0){const T=v.shift();if(T){const[B,j]=T;hc(E,B,j)}}}(r)}function jn(r,e,t,...n){const s=e._updating;e._updating=t;try{const i=Array.from(e._listeners[r]);for(let o=0;o<i.length;o++)i[o].apply(null,n)}finally{e._updating=s}}function fc(r,e,t){if(r._updating===!1||ft!==r){let s=!1;return r.update(()=>{s=fc(r,e,t)}),s}const n=Vo(r);for(let s=4;s>=0;s--)for(let i=0;i<n.length;i++){const o=n[i]._commands.get(e);if(o!==void 0){const a=o[s];if(a!==void 0){const l=Array.from(a),u=l.length;for(let c=0;c<u;c++)if(l[c](t,r)===!0)return!0}}}return!1}function ll(r,e){const t=r._updates;let n=e||!1;for(;t.length!==0;){const s=t.shift();if(s){const[i,o]=s;let a;if(o!==void 0){if(a=o.onUpdate,o.skipTransforms&&(n=!0),o.discrete){const l=r._pendingEditorState;l===null&&K(191),l._flushSync=!0}a&&r._deferred.push(a),dc(r,o.tag)}i()}}return n}function hc(r,e,t){const n=r._updateTags;let s,i=!1,o=!1;t!==void 0&&(s=t.onUpdate,dc(r,t.tag),i=t.skipTransforms||!1,o=t.discrete||!1),s&&r._deferred.push(s);const a=r._editorState;let l=r._pendingEditorState,u=!1;(l===null||l._readOnly)&&(l=r._pendingEditorState=pc(l||a),u=!0),l._flushSync=o;const c=dt,d=St,h=ft,p=r._updating;dt=l,St=!1,r._updating=!0,ft=r;try{u&&(r._headless?a._selection!==null&&(l._selection=a._selection.clone()):l._selection=function(_){const b=_.getEditorState()._selection,S=Bt(_._window);return V(b)||b==null?ea(b,S,_,null):b.clone()}(r));const m=r._compositionKey;e(),i=ll(r,i),function(_,b){const S=b.getEditorState()._selection,C=_._selection;if(V(C)){const k=C.anchor,E=C.focus;let v;if(k.type==="text"&&(v=k.getNode(),v.selectionTransform(S,C)),E.type==="text"){const T=E.getNode();v!==T&&T.selectionTransform(S,C)}}}(l,r),r._dirtyType!==Nr&&(i?function(_,b){const S=b._dirtyLeaves,C=_._nodeMap;for(const k of S){const E=C.get(k);ee(E)&&E.isAttached()&&E.isSimpleText()&&!E.isUnmergeable()&&Ba(E)}}(l,r):function(_,b){const S=b._dirtyLeaves,C=b._dirtyElements,k=_._nodeMap,E=fr(),v=new Map;let T=S,B=T.size,j=C,N=j.size;for(;B>0||N>0;){if(B>0){b._dirtyLeaves=new Set;for(const R of T){const M=k.get(R);ee(M)&&M.isAttached()&&M.isSimpleText()&&!M.isUnmergeable()&&Ba(M),M!==void 0&&ol(M,E)&&il(b,M,v),S.add(R)}if(T=b._dirtyLeaves,B=T.size,B>0){ws++;continue}}b._dirtyLeaves=new Set,b._dirtyElements=new Map;for(const R of j){const M=R[0],w=R[1];if(M!=="root"&&!w)continue;const D=k.get(M);D!==void 0&&ol(D,E)&&il(b,D,v),C.set(M,w)}T=b._dirtyLeaves,B=T.size,j=b._dirtyElements,N=j.size,ws++}b._dirtyLeaves=S,b._dirtyElements=C}(l,r),ll(r),function(_,b,S,C){const k=_._nodeMap,E=b._nodeMap,v=[];for(const[T]of C){const B=E.get(T);B!==void 0&&(B.isAttached()||($(B)&&Uu(B,T,k,E,v,C),k.has(T)||C.delete(T),v.push(T)))}for(const T of v)E.delete(T);for(const T of S){const B=E.get(T);B===void 0||B.isAttached()||(k.has(T)||S.delete(T),E.delete(T))}}(a,l,r._dirtyLeaves,r._dirtyElements)),m!==r._compositionKey&&(l._flushSync=!0);const x=l._selection;if(V(x)){const _=l._nodeMap,b=x.anchor.key,S=x.focus.key;_.get(b)!==void 0&&_.get(S)!==void 0||K(19)}else Ut(x)&&x._nodes.size===0&&(l._selection=null)}catch(m){return m instanceof Error&&r._onError(m),r._pendingEditorState=a,r._dirtyType=Zr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),void hr(r)}finally{dt=c,St=d,ft=h,r._updating=p,ws=0}r._dirtyType!==Nr||function(m,x){const _=x.getEditorState()._selection,b=m._selection;if(b!==null){if(b.dirty||!b.is(_))return!0}else if(_!==null)return!0;return!1}(l,r)?l._flushSync?(l._flushSync=!1,hr(r)):u&&ph(()=>{hr(r)}):(l._flushSync=!1,u&&(n.clear(),r._deferred=[],r._pendingEditorState=null))}function Dt(r,e,t){r._updating?r._updates.push([e,t]):hc(r,e,t)}class Mn{constructor(e,t,n){this.element=e,this.before=t||null,this.after=n||null}withBefore(e){return new Mn(this.element,e,this.after)}withAfter(e){return new Mn(this.element,this.before,e)}withElement(e){return new Mn(e,this.before,this.after)}insertChild(e){const t=this.before||this.getManagedLineBreak();return t!==null&&t.parentElement!==this.element&&K(222),this.element.insertBefore(e,t),this}removeChild(e){return e.parentElement!==this.element&&K(223),this.element.removeChild(e),this}replaceChild(e,t){return t.parentElement!==this.element&&K(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"&&(Vn||oi);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,i=document.createElement("br");if(n.insertBefore(i,s),e){const o=document.createElement("img");o.setAttribute("data-lexical-linebreak","true"),o.style.cssText="display: inline !important; border: 0px !important; margin: 0px !important;",o.alt="",n.insertBefore(o,i),n.__lexicalLineBreak=o}else n.__lexicalLineBreak=i}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 l=this.getFirstChildOffset();return[e,Math.min(l+e.getChildrenSize(),Math.max(l,s))]}const i=ul(t,n);i.push(s);const o=ul(t,this.element);let a=e.getIndexWithinParent();for(let l=0;l<o.length;l++){const u=i[l],c=o[l];if(u===void 0||u<c)break;if(u>c){a+=1;break}}return[e.getParentOrThrow(),a]}}function ul(r,e){const t=[];let n=e;for(;n!==r&&n!==null;n=e.parentNode){let s=0;for(let i=n.previousSibling;i!==null;i=n.previousSibling)s++;t.push(s)}return n!==r&&K(225),t.reverse()}class ar extends hi{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 sh[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=rt()._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(ee(t)&&e.push(t),$(t)){const n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;$(e);){const t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;$(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 i=t[n-1];return $(i)&&i.getLastDescendant()||i||null}const s=t[e];return $(s)&&s.getFirstDescendant()||s||null}getFirstChild(){const e=this.getLatest().__first;return e===null?null:pt(e)}getFirstChildOrThrow(){const e=this.getFirstChild();return e===null&&K(45,this.__key),e}getLastChild(){const e=this.getLatest().__last;return e===null?null:pt(e)}getLastChildOrThrow(){const e=this.getLastChild();return e===null&&K(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 i=t[s];e+=i.getTextContent(),$(i)&&s!==n-1&&!i.isInline()&&(e+=nr)}return e}getTextContentSize(){let e=0;const t=this.getChildren(),n=t.length;for(let s=0;s<n;s++){const i=t[s];e+=i.getTextContentSize(),$(i)&&s!==n-1&&!i.isInline()&&(e+=nr.length)}return e}getDirection(){return this.getLatest().__dir}hasFormat(e){if(e!==""){const t=Aa[e];return!!(this.getFormat()&t)}return!1}select(e,t){wt();const n=ae();let s=e,i=t;const o=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){const l=this.getFirstChild();if(ee(l)||$(l))return l.select(0,0)}else if(!(e!==void 0&&e!==o||t!==void 0&&t!==o)){const l=this.getLastChild();if(ee(l)||$(l))return l.select()}}s===void 0&&(s=o),i===void 0&&(i=o);const a=this.__key;return V(n)?(n.anchor.set(a,s,"element"),n.focus.set(a,i,"element"),n.dirty=!0,n):ac(a,s,a,i,"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!==""?Aa[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,i=this.getChildrenSize(),o=this.getWritable();e+t<=i||K(226,String(e),String(t),String(i));const a=o.__key,l=[],u=[],c=this.getChildAtIndex(e+t);let d=null,h=i-t+s;if(e!==0)if(e===i)d=this.getLastChild();else{const g=this.getChildAtIndex(e);g!==null&&(d=g.getPreviousSibling())}if(t>0){let g=d===null?this.getFirstChild():d.getNextSibling();for(let m=0;m<t;m++){g===null&&K(100);const x=g.getNextSibling(),_=g.__key;Dr(g.getWritable()),u.push(_),g=x}}let p=d;for(let g=0;g<s;g++){const m=n[g];p!==null&&m.is(p)&&(d=p=p.getPreviousSibling());const x=m.getWritable();x.__parent===a&&h--,Dr(x);const _=m.__key;if(p===null)o.__first=_,x.__prev=null;else{const b=p.getWritable();b.__next=_,x.__prev=b.__key}m.__key===a&&K(76),x.__parent=a,l.push(_),p=m}if(e+t===i)p!==null&&(p.getWritable().__next=null,o.__last=p.__key);else if(c!==null){const g=c.getWritable();if(p!==null){const m=p.getWritable();g.__prev=p.__key,m.__next=c.__key}else g.__prev=null}if(o.__size=h,u.length){const g=ae();if(V(g)){const m=new Set(u),x=new Set(l),{anchor:_,focus:b}=g;cl(_,m,x)&&Hs(_,_.getNode(),this,d,c),cl(b,m,x)&&Hs(b,b.getNode(),this,d,c),h!==0||this.canBeEmpty()||Kt(this)||this.remove()}}return o}getDOMSlot(e){return new Mn(e)}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&ir(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 i=this.getFirstChild();i;i=i.getNextSibling()){const o=t.getElementByKey(i.getKey());o!==null&&(s==null?(n.insertChild(o),s=o):s!==o&&n.replaceChild(o,s),s=s.nextSibling)}}}function $(r){return r instanceof ar}function cl(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 ra extends hi{constructor(e){super(e)}decorate(e,t){K(47)}isIsolated(){return!1}isInline(){return!0}isKeyboardSelectable(){return!0}}function Ge(r){return r instanceof ra}class ts extends ar{static getType(){return"root"}static clone(){return new ts}constructor(){super("root"),this.__cachedText=null}getTopLevelElementOrThrow(){K(51)}getTextContent(){const e=this.__cachedText;return!es()&&rt()._dirtyType!==Nr||e===null?super.getTextContent():e}remove(){K(52)}replace(e){K(53)}insertBefore(e){K(54)}insertAfter(e){K(55)}updateDOM(e,t){return!1}append(...e){for(let t=0;t<e.length;t++){const n=e[t];$(n)||Ge(n)||K(56)}return super.append(...e)}static importJSON(e){const t=Ze();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 yt(r){return r instanceof ts}function pc(r){return new gi(new Map(r._nodeMap))}function na(){return new gi(new Map([["root",new ts]]))}function gc(r){const e=r.exportJSON(),t=r.constructor;if(e.type!==t.getType()&&K(130,t.name),$(r)){const n=e.children;Array.isArray(n)||K(59,t.name);const s=r.getChildren();for(let i=0;i<s.length;i++){const o=gc(s[i]);n.push(o)}}return e}class gi{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 al(t&&t.editor||null,this,e)}clone(e){const t=new gi(this._nodeMap,e===void 0?this._selection:e);return t._readOnly=!0,t}toJSON(){return al(null,this,()=>({root:gc(Ze())}))}}class sa extends ar{static getType(){return"artificial"}createDOM(e){return document.createElement("div")}}class on extends ar{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=Br[e];return!!(this.getTextFormat()&t)}getFormatFlags(e,t){return Ls(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 on(e.__key)}afterCloneFrom(e){super.afterCloneFrom(e),this.__textFormat=e.__textFormat,this.__textStyle=e.__textStyle}createDOM(e){const t=document.createElement("p"),n=An(e.theme,"paragraph");return n!==void 0&&t.classList.add(...n),t}updateDOM(e,t,n){return!1}static importDOM(){return{p:e=>({conversion:Uh,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&ir(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=ot();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=ot();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||ee(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 Uh(r){const e=ot();return r.style&&(e.setFormat(r.style.textAlign),Xo(r,e)),{node:e}}function ot(){return Qt(new on)}function tn(r){return r instanceof on}const We=0,Vr=1,Wh=4;function mc(r,e,t,n){const s=r._keyToDOMMap;s.clear(),r._editorState=na(),r._pendingEditorState=n,r._compositionKey=null,r._dirtyType=Nr,r._cloneNotNeeded.clear(),r._dirtyLeaves=new Set,r._dirtyElements.clear(),r._normalizedNodes=new Set,r._updateTags=new Set,r._updates=[],r._blockCursorElement=null;const i=r._observer;i!==null&&(i.disconnect(),r._observer=null),e!==null&&(e.textContent=""),t!==null&&(t.textContent="",s.set("root",t))}function Hh(r){const e=r||{},t=$h(),n=e.theme||{},s=r===void 0?t:e.parentEditor||null,i=e.disableEvents||!1,o=na(),a=e.namespace||(s!==null?s._config.namespace:Ou()),l=e.editorState,u=[ts,sn,Qn,Jn,on,sa,...e.nodes||[]],{onError:c,html:d}=e,h=e.editable===void 0||e.editable;let p;if(r===void 0&&t!==null)p=t._nodes;else{p=new Map;for(let m=0;m<u.length;m++){let x=u[m],_=null,b=null;if(typeof x!="function"){const E=x;x=E.replace,_=E.with,b=E.withKlass||null}const S=x.getType(),C=x.transform(),k=new Set;C!==null&&k.add(C),p.set(S,{exportDOM:d&&d.export?d.export.get(x):void 0,klass:x,replace:_,replaceWithKlass:b,transforms:k})}}const g=new mi(o,s,p,{disableEvents:i,namespace:a,theme:n},c||console.error,function(m,x){const _=new Map,b=new Set,S=C=>{Object.keys(C).forEach(k=>{let E=_.get(k);E===void 0&&(E=[],_.set(k,E)),E.push(C[k])})};return m.forEach(C=>{const k=C.klass.importDOM;if(k==null||b.has(k))return;b.add(k);const E=k.call(C.klass);E!==null&&S(E)}),x&&S(x),_}(p,d?d.import:void 0),h);return l!==void 0&&(g._pendingEditorState=l,g._dirtyType=Zr),g}class mi{constructor(e,t,n,s,i,o,a){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=Nr,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=Ou(),this._onError=i,this._htmlConversions=o,this._editable=a,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&&K(35);const s=this._commands;s.has(e)||s.set(e,[new Set,new Set,new Set,new Set,new Set]);const i=s.get(e);i===void 0&&K(36,String(e));const o=i[n];return o.add(t),()=>{o.delete(t),i.every(a=>a.size===0)&&s.delete(e)}}registerMutationListener(e,t,n){const s=this.resolveRegisteredNodeAfterReplacements(this.getRegisteredNode(e)).klass,i=this._listeners.mutation;i.set(t,s);const o=n&&n.skipInitialization;return o!==void 0&&o||this.initializeMutationListener(t,s),()=>{i.delete(t)}}getRegisteredNode(e){const t=this._nodes.get(e.getType());return t===void 0&&K(37,e.name),t}resolveRegisteredNodeAfterReplacements(e){for(;e.replaceWithKlass;)e=this.getRegisteredNode(e.replaceWithKlass);return e}initializeMutationListener(e,t){const n=this._editorState,s=Sh(n).get(t.getType());if(!s)return;const i=new Map;for(const o of s.keys())i.set(o,"created");i.size>0&&e(i,{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],i=n.replaceWithKlass;if(i!=null){const l=this.registerNodeTransformToKlass(i,t);s.push(l)}var o,a;return o=this,a=e.getType(),Dt(o,()=>{const l=or();if(l.isEmpty())return;if(a==="root")return void Ze().markDirty();const u=l._nodeMap;for(const[,c]of u)c.markDirty()},o._pendingEditorState===null?{tag:"history-merge"}:void 0),()=>{s.forEach(l=>l.transforms.delete(t))}}hasNode(e){return this._nodes.has(e.getType())}hasNodes(e){return e.every(this.hasNode.bind(this))}dispatchCommand(e,t){return ie(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=An(this._config.theme,"root"),s=this._pendingEditorState||this._editorState;if(this._rootElement=e,mc(this,t,e,s),t!==null&&(this._config.disableEvents||Th(t),n!=null&&t.classList.remove(...n)),e!==null){const i=function(a){const l=a.ownerDocument;return l&&l.defaultView||null}(e),o=e.style;o.userSelect="text",o.whiteSpace="pre-wrap",o.wordBreak="break-word",e.setAttribute("data-lexical-editor","true"),this._window=i,this._dirtyType=Zr,ju(this),this._updateTags.add("history-merge"),hr(this),this._config.disableEvents||function(a,l){const u=a.ownerDocument,c=Us.get(u);(c===void 0||c<1)&&u.addEventListener("selectionchange",rc),Us.set(u,(c||0)+1),a.__lexicalEditor=l;const d=tc(a);for(let h=0;h<io.length;h++){const[p,g]=io[h],m=typeof g=="function"?x=>{Va(x)||(Ha(x),(l.isEditable()||p==="click")&&g(x,l))}:x=>{if(Va(x))return;Ha(x);const _=l.isEditable();switch(p){case"cut":return _&&ie(l,Ro,x);case"copy":return ie(l,ii,x);case"paste":return _&&ie(l,si,x);case"dragstart":return _&&ie(l,Su,x);case"dragover":return _&&ie(l,ku,x);case"dragend":return _&&ie(l,$f,x);case"focus":return _&&ie(l,Wf,x);case"blur":return _&&ie(l,Hf,x);case"drop":return _&&ie(l,Cu,x)}};a.addEventListener(p,m),d.push(()=>{a.removeEventListener(p,m)})}}(e,this),n!=null&&e.classList.add(...n)}else this._editorState=s,this._pendingEditorState=null,this._window=null;jn("root",this,!1,e,t)}}getElementByKey(e){return this._keyToDOMMap.get(e)||null}getEditorState(){return this._editorState}setEditorState(e,t){e.isEmpty()&&K(38);let n=e;n._readOnly&&(n=pc(e),n._selection=e._selection?e._selection.clone():null),Bu(this);const s=this._pendingEditorState,i=this._updateTags,o=t!==void 0?t.tag:null;s===null||s.isEmpty()||(o!=null&&i.add(o),hr(this)),this._pendingEditorState=n,this._dirtyType=Zr,this._dirtyElements.set("root",!1),this._compositionKey=null,o!=null&&i.add(o),this._updating||hr(this)}parseEditorState(e,t){return function(n,s,i){const o=na(),a=dt,l=St,u=ft,c=s._dirtyElements,d=s._dirtyLeaves,h=s._cloneNotNeeded,p=s._dirtyType;s._dirtyElements=new Map,s._dirtyLeaves=new Set,s._cloneNotNeeded=new Set,s._dirtyType=0,dt=o,St=!1,ft=s;try{const g=s._nodes;ta(n.root,g),i&&i(),o._readOnly=!0}catch(g){g instanceof Error&&s._onError(g)}finally{s._dirtyElements=c,s._dirtyLeaves=d,s._cloneNotNeeded=h,s._dirtyType=p,dt=a,St=l,ft=u}return o}(typeof e=="string"?JSON.parse(e):e,this,t)}read(e){return hr(this),this.getEditorState().read(e,{editor:this})}update(e,t){Dt(this,e,t)}focus(e,t={}){const n=this._rootElement;n!==null&&(n.setAttribute("autocapitalize","off"),Dt(this,()=>{const s=ae(),i=Ze();s!==null?s.dirty=!0:i.getChildrenSize()!==0&&(t.defaultSelection==="rootStart"?i.selectStart():i.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=Bt(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,jn("editable",this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}}mi.version="0.21.0+prod.esm";const yc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Vh=yc?y.useLayoutEffect:y.useEffect,ds={tag:"history-merge"};function Gh({initialConfig:r,children:e}){const t=y.useMemo(()=>{const{theme:n,namespace:s,nodes:i,onError:o,editorState:a,html:l}=r,u=Bf(null,n),c=Hh({editable:r.editable,html:l,namespace:s,nodes:i,onError:d=>o(d,c),theme:n});return function(d,h){if(h!==null){if(h===void 0)d.update(()=>{const p=Ze();if(p.isEmpty()){const g=ot();p.append(g);const m=yc?document.activeElement:null;(ae()!==null||m!==null&&m===d.getRootElement())&&g.select()}},ds);else if(h!==null)switch(typeof h){case"string":{const p=d.parseEditorState(h);d.setEditorState(p,ds);break}case"object":d.setEditorState(h,ds);break;case"function":d.update(()=>{Ze().isEmpty()&&h(d)},ds)}}}(c,a),[c,u]},[]);return Vh(()=>{const n=r.editable,[s]=t;s.setEditable(n===void 0||n)},[]),f.jsx(pu.Provider,{value:t,children:e})}const Kh=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Yh(r){return{initialValueFn:()=>r.isEditable(),subscribe:e=>r.registerEditableListener(e)}}function Qh(){return function(r){const[e]=zt(),t=y.useMemo(()=>r(e),[e,r]),[n,s]=y.useState(()=>t.initialValueFn()),i=y.useRef(n);return Kh(()=>{const{initialValueFn:o,subscribe:a}=t,l=o();return i.current!==l&&(i.current=l,s(l)),a(u=>{i.current=u,s(u)})},[t,r]),n}(Yh)}function Jh(){return Ze().getTextContent()}function Xh(r,e=!0){if(r)return!1;let t=Jh();return e&&(t=t.trim()),t===""}function Zh(r){if(!Xh(r,!1))return!1;const e=Ze().getChildren(),t=e.length;if(t>1)return!1;for(let n=0;n<t;n++){const s=e[n];if(Ge(s))return!1;if($(s)){if(!tn(s)||s.__indent!==0)return!1;const i=s.getChildren(),o=i.length;for(let a=0;a<o;a++){const l=i[n];if(!ee(l))return!1}}}return!0}function xc(r){return()=>Zh(r)}function ep(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}ep(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 tp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var rp=tp(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 np=new Map;function sp(r){const e={};if(!r)return e;const t=r.split(";");for(const n of t)if(n!==""){const[s,i]=n.split(/:([^]+)/);s&&i&&(e[s.trim()]=i.trim())}return e}function bc(r,e){const t=r.getStartEndPoints();if(e.isSelected(r)&&!e.isSegmented()&&!e.isToken()&&t!==null){const[n,s]=t,i=r.isBackward(),o=n.getNode(),a=s.getNode(),l=e.is(o),u=e.is(a);if(l||u){const[c,d]=uo(r),h=o.is(a),p=e.is(i?a:o),g=e.is(i?o:a);let m,x=0;return h?(x=c>d?d:c,m=c>d?c:d):p?(x=i?d:c,m=void 0):g&&(x=0,m=i?c:d),e.__text=e.__text.slice(x,m),e}}return e}function ip(r){const e=r.getStyle(),t=sp(e);np.set(e,t)}function op(r,e){if(r===null)return;const t=r.getStartEndPoints(),n=t?t[0]:null;if(n!==null&&n.key==="root"){const o=e(),a=Ze(),l=a.getFirstChild();return void(l?l.replace(o,!0):a.append(o))}const s=r.getNodes(),i=n!==null&&function(o,a){let l=o;for(;l!==null&&l.getParent()!==null&&!a(l);)l=l.getParentOrThrow();return a(l)?l:null}(n.getNode(),hl);i&&s.indexOf(i)===-1&&s.push(i);for(let o=0;o<s.length;o++){const a=s[o];if(!hl(a))continue;$(a)||rp(178);const l=e();l.setFormat(a.getFormatType()),l.setIndent(a.getIndent()),a.replace(l,!0)}}function dl(r,e){const t=Pn(r.focus,e);return Ge(t)&&!t.isIsolated()||$(t)&&!t.isInline()&&!t.canBeEmpty()}function ap(r,e,t,n){r.modify(e?"extend":"move",t,n)}function lp(r){const e=r.anchor.getNode();return(yt(e)?e:e.getParentOrThrow()).getDirection()==="rtl"}function fl(r,e,t){const n=lp(r);ap(r,e,t?!n:n,"character")}function hl(r){if(Ge(r)||!$(r)||Kt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||ee(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function up(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var cp=up(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=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,dp=vc&&"documentMode"in document?document.documentMode:null;!(!vc||!("InputEvent"in window)||dp)&&"getTargetRanges"in new window.InputEvent("input");function _c(...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 Pr(...r){return()=>{for(let e=r.length-1;e>=0;e--)r[e]();r.length=0}}function rs(r,...e){const t=_c(...e);t.length>0&&r.classList.add(...t)}function wc(r,...e){const t=_c(...e);t.length>0&&r.classList.remove(...t)}function fp(r,e){let t=r;for(;t!=null;){if(t instanceof e)return t;t=t.getParent()}return null}function hp(r){const e=yi(r,t=>$(t)&&!t.isInline());return $(e)||cp(4,r.__key),e}const yi=(r,e)=>{let t=r;for(;t!==Ze()&&t!=null;){if(e(t))return t;t=t.getParent()}return null};function pr(r,e){return r!==null&&Object.getPrototypeOf(r).constructor.name===e.name}function pp(r){const e=window.location.origin,t=n=>{if(n.origin!==e)return;const s=r.getRootElement();if(document.activeElement!==s)return;const i=n.data;if(typeof i=="string"){let o;try{o=JSON.parse(i)}catch{return}if(o&&o.protocol==="nuanria_messaging"&&o.type==="request"){const a=o.payload;if(a&&a.functionId==="makeChanges"){const l=a.args;if(l){const[u,c,d,h,p,g]=l;r.update(()=>{const m=ae();if(V(m)){const x=m.anchor;let _=x.getNode(),b=0,S=0;if(ee(_)&&u>=0&&c>=0&&(b=u,S=u+c,m.setTextNodeRange(_,b,_,S)),b===S&&d===""||(m.insertRawText(d),_=x.getNode()),ee(_)){b=h,S=h+p;const C=_.getTextContentSize();b=b>C?C:b,S=S>C?C:S,m.setTextNodeRange(_,b,_,S)}n.stopImmediatePropagation()}})}}}}};return window.addEventListener("message",t,!0),()=>{window.removeEventListener("message",t,!0)}}function Cc(r,e){const t=e.body?e.body.childNodes:[];let n=[];const s=[];for(let i=0;i<t.length;i++){const o=t[i];if(!Ec.has(o.nodeName)){const a=Dc(o,r,s,!1);a!==null&&(n=n.concat(a))}}return function(i){for(const o of i)o.getNextSibling()instanceof sa&&o.insertAfter(Mr());for(const o of i){const a=o.getChildren();for(const l of a)o.insertBefore(l);o.remove()}}(s),n}function Sc(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=Ze().getChildren();for(let s=0;s<n.length;s++)kc(r,n[s],t,e);return t.innerHTML}function kc(r,e,t,n=null){let s=n===null||e.isSelected(n);const i=$(e)&&e.excludeFromCopy("html");let o=e;if(n!==null){let p=Jo(e);p=ee(p)&&n!==null?bc(n,p):p,o=p}const a=$(o)?o.getChildren():[],l=r._nodes.get(o.getType());let u;u=l&&l.exportDOM!==void 0?l.exportDOM(r,o):o.exportDOM(r);const{element:c,after:d}=u;if(!c)return!1;const h=document.createDocumentFragment();for(let p=0;p<a.length;p++){const g=a[p],m=kc(r,g,h,n);!s&&$(e)&&m&&e.extractWithChild(g,n,"html")&&(s=!0)}if(s&&!i){if((ir(c)||Oa(c))&&c.append(h),t.append(c),d){const p=d.call(o,c);p&&(Oa(c)?c.replaceChildren(p):c.replaceWith(p))}}else t.append(h);return s}const Ec=new Set(["STYLE","SCRIPT"]);function Dc(r,e,t,n,s=new Map,i){let o=[];if(Ec.has(r.nodeName))return o;let a=null;const l=function(g,m){const{nodeName:x}=g,_=m._htmlConversions.get(x.toLowerCase());let b=null;if(_!==void 0)for(const S of _){const C=S(g);C!==null&&(b===null||(b.priority||0)<=(C.priority||0))&&(b=C)}return b!==null?b.conversion:null}(r,e),u=l?l(r):null;let c=null;if(u!==null){c=u.after;const g=u.node;if(a=Array.isArray(g)?g[g.length-1]:g,a!==null){for(const[,m]of s)if(a=m(a,i),!a)break;a&&o.push(...Array.isArray(g)?g:[a])}u.forChild!=null&&s.set(r.nodeName,u.forChild)}const d=r.childNodes;let h=[];const p=(a==null||!Kt(a))&&(a!=null&&co(a)||n);for(let g=0;g<d.length;g++)h.push(...Dc(d[g],e,t,p,new Map(s),a));return c!=null&&(h=c(h)),zs(r)&&(h=gp(r,h,p?()=>{const g=new sa;return t.push(g),g}:ot)),a==null?h.length>0?o=o.concat(h):zs(r)&&function(g){return g.nextSibling==null||g.previousSibling==null?!1:Ji(g.nextSibling)&&Ji(g.previousSibling)}(r)&&(o=o.concat(Mr())):$(a)&&a.append(...h),o}function gp(r,e,t){const n=r.style.textAlign,s=[];let i=[];for(let o=0;o<e.length;o++){const a=e[o];if(co(a))n&&!a.getFormat()&&a.setFormat(n),s.push(a);else if(i.push(a),o===e.length-1||o<e.length-1&&co(e[o+1])){const l=t();l.setFormat(n),l.append(...i),s.push(l),i=[]}}return s}function mp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Vs=mp(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 yp(r,e=ae()){return e==null&&Vs(166),V(e)&&e.isCollapsed()||e.getNodes().length===0?"":Sc(r,e)}function xp(r,e=ae()){return e==null&&Vs(166),V(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(bp(r,e))}function pl(r,e,t){const n=r.getData("application/x-lexical-editor");if(n)try{const o=JSON.parse(n);if(o.namespace===t._config.namespace&&Array.isArray(o.nodes))return gl(t,vp(o.nodes),e)}catch{}const s=r.getData("text/html");if(s)try{const o=new DOMParser().parseFromString(function(a){return window.trustedTypes&&window.trustedTypes.createPolicy?window.trustedTypes.createPolicy("lexical",{createHTML:l=>l}).createHTML(a):a}(s),"text/html");return gl(t,Cc(t,o),e)}catch{}const i=r.getData("text/plain")||r.getData("text/uri-list");if(i!=null)if(V(e)){const o=i.split(/(\r?\n|\t)/);o[o.length-1]===""&&o.pop();for(let a=0;a<o.length;a++){const l=ae();if(V(l)){const u=o[a];u===`
94
94
  `||u===`\r
95
- `?a.insertParagraph():u===" "?a.insertNodes([Xn()]):a.insertText(u)}}}else e.insertRawText(i)}function gl(r,e,t){r.dispatchCommand(jf,{nodes:e,selection:t})||t.insertNodes(e)}function Ac(r,e,t,n=[]){let s=e===null||t.isSelected(e);const i=O(t)&&t.excludeFromCopy("html");let o=t;if(e!==null){let u=Jo(t);u=Z(u)&&e!==null?bc(e,u):u,o=u}const l=O(o)?o.getChildren():[],a=function(u){const c=u.exportJSON(),d=u.constructor;if(c.type!==d.getType()&&Vs(58,d.name),O(u)){const h=c.children;Array.isArray(h)||Vs(59,d.name)}return c}(o);if(Z(o)){const u=o.__text;u.length>0?a.text=u:s=!1}for(let u=0;u<l.length;u++){const c=l[u],d=Ac(r,e,c,a.children);!s&&O(t)&&d&&t.extractWithChild(c,e,"clone")&&(s=!0)}if(s&&!i)n.push(a);else if(Array.isArray(a.children))for(let u=0;u<a.children.length;u++){const c=a.children[u];n.push(c)}return s}function bp(r,e){const t=[],n=et().getChildren();for(let s=0;s<n.length;s++)Ac(r,e,n[s],t);return{namespace:r._config.namespace,nodes:t}}function vp(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t],s=qh(n);Z(s)&&ip(s),e.push(s)}return e}let qr=null;async function ml(r,e,t){if(qr!==null)return!1;if(e!==null)return new Promise((a,u)=>{r.update(()=>{a(yl(r,e,t))})});const n=r.getRootElement(),s=r._window==null?window.document:r._window.document,i=Bt(r._window);if(n===null||i===null)return!1;const o=s.createElement("span");o.style.cssText="position: fixed; top: -1000px;",o.append(s.createTextNode("#")),n.append(o);const l=new Range;return l.setStart(o,0),l.setEnd(o,1),i.removeAllRanges(),i.addRange(l),new Promise((a,u)=>{const c=r.registerCommand(ii,d=>(gr(d,ClipboardEvent)&&(c(),qr!==null&&(window.clearTimeout(qr),qr=null),a(yl(r,d,t))),!0),Wh);qr=window.setTimeout(()=>{c(),qr=null,a(!1)},50),s.execCommand("copy"),o.remove()})}function yl(r,e,t){if(t===void 0){const s=Bt(r._window);if(!s)return!1;const i=s.anchorNode,o=s.focusNode;if(i!==null&&o!==null&&!Kn(r,i,o))return!1;const l=ae();if(l===null)return!1;t=wp(l)}e.preventDefault();const n=e.clipboardData;return n!==null&&(Cp(n,t),!0)}const _p=[["text/html",yp],["application/x-lexical-editor",xp]];function wp(r=ae()){const e={"text/plain":r?r.getTextContent():""};if(r){const t=wh();for(const[n,s]of _p){const i=s(t,r);i!==null&&(e[n]=i)}}return e}function Cp(r,e){for(const t in e){const n=e[t];n!==void 0&&r.setData(t,n)}}function xl(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 an=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Sp=an&&"documentMode"in document?document.documentMode:null,kp=!(!an||!("InputEvent"in window)||Sp)&&"getTargetRanges"in new window.InputEvent("input"),Ep=an&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),bl=an&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Dp=an&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Ap=an&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Dp,vl=Hn();class xi extends lr{static getType(){return"quote"}static clone(e){return new xi(e.__key)}constructor(e){super(e)}createDOM(e){const t=document.createElement("blockquote");return rs(t,e.theme.quote),t}updateDOM(e,t){return!1}static importDOM(){return{blockquote:e=>({conversion:Tp,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&or(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=ia();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=at(),s=this.getDirection();return n.setDirection(s),this.insertAfter(n,t),n}collapseAtStart(){const e=at();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}canMergeWhenEmpty(){return!0}}function ia(){return Xt(new xi)}class bi extends lr{static getType(){return"heading"}static clone(e){return new bi(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 i=s[t];rs(n,i)}return n}updateDOM(e,t){return!1}static importDOM(){return{h1:e=>({conversion:Ur,priority:0}),h2:e=>({conversion:Ur,priority:0}),h3:e=>({conversion:Ur,priority:0}),h4:e=>({conversion:Ur,priority:0}),h5:e=>({conversion:Ur,priority:0}),h6:e=>({conversion:Ur,priority:0}),p:e=>{const t=e.firstChild;return t!==null&&_l(t)?{conversion:()=>({node:null}),priority:3}:null},span:e=>_l(e)?{conversion:t=>({node:wn("h1")}),priority:3}:null}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&or(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=wn(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(),i=!s||e&&e.anchor.key===s.getKey()&&n===s.getTextContentSize()||!e?at():wn(this.getTag()),o=this.getDirection();if(i.setDirection(o),this.insertAfter(i,t),n===0&&!this.isEmpty()&&e){const l=at();l.select(),this.replace(l,!0)}return i}collapseAtStart(){const e=this.isEmpty()?at():wn(this.getTag());return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}extractWithChild(){return!0}}function _l(r){return r.nodeName.toLowerCase()==="span"&&r.style.fontSize==="26pt"}function Ur(r){const e=r.nodeName.toLowerCase();let t=null;return e!=="h1"&&e!=="h2"&&e!=="h3"&&e!=="h4"&&e!=="h5"&&e!=="h6"||(t=wn(e),r.style!==null&&(Xo(r,t),t.setFormat(r.style.textAlign))),{node:t}}function Tp(r){const e=ia();return r.style!==null&&(e.setFormat(r.style.textAlign),Xo(r,e)),{node:e}}function wn(r){return Xt(new bi(r))}function fs(r){let e=null;if(gr(r,DragEvent)?e=r.dataTransfer:gr(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 wl(r){const e=ae();if(!K(e))return!1;const t=new Set,n=e.getNodes();for(let s=0;s<n.length;s++){const i=n[s],o=i.getKey();if(t.has(o))continue;const l=yi(i,u=>O(u)&&!u.isInline());if(l===null)continue;const a=l.getKey();l.canIndent()&&!t.has(a)&&(t.add(a),r(l))}return t.size>0}function hs(r){const e=en(r);return Ge(e)}function Np(r){return Pr(r.registerCommand(gu,e=>{const t=ae();return!!Ht(t)&&(t.clear(),!0)},0),r.registerCommand(Er,e=>{const t=ae();return!!K(t)&&(t.deleteCharacter(e),!0)},We),r.registerCommand(Fn,e=>{const t=ae();return!!K(t)&&(t.deleteWord(e),!0)},We),r.registerCommand(Ln,e=>{const t=ae();return!!K(t)&&(t.deleteLine(e),!0)},We),r.registerCommand(Yr,e=>{const t=ae();if(typeof e=="string")t!==null&&t.insertText(e);else{if(t===null)return!1;const n=e.dataTransfer;if(n!=null)pl(n,t,r);else if(K(t)){const s=e.data;return s&&t.insertText(s),!0}}return!0},We),r.registerCommand(Ki,()=>{const e=ae();return!!K(e)&&(e.removeText(),!0)},We),r.registerCommand(zt,e=>{const t=ae();return!!K(t)&&(t.formatText(e),!0)},We),r.registerCommand(Of,e=>{const t=ae();if(!K(t)&&!Ht(t))return!1;const n=t.getNodes();for(const s of n){const i=yi(s,o=>O(o)&&!o.isInline());i!==null&&i.setFormat(e)}return!0},We),r.registerCommand(Kr,e=>{const t=ae();return!!K(t)&&(t.insertLineBreak(e),!0)},We),r.registerCommand(Rn,()=>{const e=ae();return!!K(e)&&(e.insertParagraph(),!0)},We),r.registerCommand(If,()=>(lc([Xn()]),!0),We),r.registerCommand(zf,()=>wl(e=>{const t=e.getIndent();e.setIndent(t+1)}),We),r.registerCommand(Da,()=>wl(e=>{const t=e.getIndent();t>0&&e.setIndent(t-1)}),We),r.registerCommand(xu,e=>{const t=ae();if(Ht(t)&&!hs(e.target)){const n=t.getNodes();if(n.length>0)return n[0].selectPrevious(),!0}else if(K(t)){const n=Pn(t.focus,!0);if(!e.shiftKey&&Ge(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),e.preventDefault(),!0}return!1},We),r.registerCommand(bu,e=>{const t=ae();if(Ht(t)){const n=t.getNodes();if(n.length>0)return n[0].selectNext(0,0),!0}else if(K(t)){if(function(s){const i=s.focus;return i.key==="root"&&i.offset===et().getChildrenSize()}(t))return e.preventDefault(),!0;const n=Pn(t.focus,!1);if(!e.shiftKey&&Ge(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),e.preventDefault(),!0}return!1},We),r.registerCommand(yu,e=>{const t=ae();if(Ht(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectPrevious(),!0}if(!K(t))return!1;if(dl(t,!0)){const n=e.shiftKey;return e.preventDefault(),fl(t,n,!0),!0}return!1},We),r.registerCommand(mu,e=>{const t=ae();if(Ht(t)&&!hs(e.target)){const s=t.getNodes();if(s.length>0)return e.preventDefault(),s[0].selectNext(0,0),!0}if(!K(t))return!1;const n=e.shiftKey;return!!dl(t,!1)&&(e.preventDefault(),fl(t,n,!1),!0)},We),r.registerCommand(vu,e=>{if(hs(e.target))return!1;const t=ae();if(!K(t))return!1;const{anchor:n}=t,s=n.getNode();return t.isCollapsed()&&n.offset===0&&!yt(s)&&hp(s).getIndent()>0?(e.preventDefault(),r.dispatchCommand(Da,void 0)):(!bl||navigator.language!=="ko-KR")&&(e.preventDefault(),r.dispatchCommand(Er,!0))},We),r.registerCommand(wu,e=>{if(hs(e.target))return!1;const t=ae();return!!K(t)&&(e.preventDefault(),r.dispatchCommand(Er,!1))},We),r.registerCommand(Ns,e=>{const t=ae();if(!K(t))return!1;if(e!==null){if((bl||Ep||Ap)&&kp)return!1;if(e.preventDefault(),e.shiftKey)return r.dispatchCommand(Kr,!1)}return r.dispatchCommand(Rn,void 0)},We),r.registerCommand(_u,()=>{const e=ae();return!!K(e)&&(r.blur(),!0)},We),r.registerCommand(Cu,e=>{const[,t]=fs(e);if(t.length>0){const s=xl(e.clientX,e.clientY);if(s!==null){const{offset:i,node:o}=s,l=en(o);if(l!==null){const a=Ih();if(Z(l))a.anchor.set(l.getKey(),i,"text"),a.focus.set(l.getKey(),i,"text");else{const c=l.getParentOrThrow().getKey(),d=l.getIndexWithinParent()+1;a.anchor.set(c,d,"element"),a.focus.set(c,d,"element")}const u=Mu(a);Yt(u)}r.dispatchCommand(vl,t)}return e.preventDefault(),!0}const n=ae();return!!K(n)},We),r.registerCommand(Su,e=>{const[t]=fs(e),n=ae();return!(t&&!K(n))},We),r.registerCommand(ku,e=>{const[t]=fs(e),n=ae();if(t&&!K(n))return!1;const s=xl(e.clientX,e.clientY);if(s!==null){const i=en(s.node);Ge(i)&&e.preventDefault()}return!0},We),r.registerCommand(Yi,()=>(xh(),!0),We),r.registerCommand(ii,e=>(ml(r,gr(e,ClipboardEvent)?e:null),!0),We),r.registerCommand(Ro,e=>(async function(t,n){await ml(n,gr(t,ClipboardEvent)?t:null),n.update(()=>{const s=ae();K(s)?s.removeText():Ht(s)&&s.getNodes().forEach(i=>i.remove())})}(e,r),!0),We),r.registerCommand(si,e=>{const[,t,n]=fs(e);return t.length>0&&!n?(r.dispatchCommand(vl,t),!0):Wo(e.target)?!1:ae()!==null&&(function(s,i){s.preventDefault(),i.update(()=>{const o=ae(),l=gr(s,InputEvent)||gr(s,KeyboardEvent)?null:s.clipboardData;l!=null&&o!==null&&pl(l,o,i)},{tag:"paste"})}(e,r),!0)},We))}const fo=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Cl(r){return r.getEditorState().read(xc(r.isComposing()))}function Bp({contentEditable:r,placeholder:e=null,ErrorBoundary:t}){const[n]=$t(),s=function(i,o){const[l,a]=y.useState(()=>i.getDecorators());return fo(()=>i.registerDecoratorListener(u=>{ma.flushSync(()=>{a(u)})}),[i]),y.useEffect(()=>{a(i.getDecorators())},[i]),y.useMemo(()=>{const u=[],c=Object.keys(l);for(let d=0;d<c.length;d++){const h=c[d],p=f.jsx(o,{onError:m=>i._onError(m),children:f.jsx(y.Suspense,{fallback:null,children:l[h]})}),g=i.getElementByKey(h);g!==null&&u.push(ma.createPortal(p,g,h))}return u},[o,l,i])}(n,t);return function(i){fo(()=>Pr(Np(i),pp(i)),[i])}(n),f.jsxs(f.Fragment,{children:[r,f.jsx(jp,{content:e}),s]})}function jp({content:r}){const[e]=$t(),t=function(s){const[i,o]=y.useState(()=>Cl(s));return fo(()=>{function l(){const a=Cl(s);o(a)}return l(),Pr(s.registerUpdateListener(()=>{l()}),s.registerEditableListener(()=>{l()}))},[s]),i}(e),n=Qh();return t?typeof r=="function"?r(n):r:null}const Tc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Mp({editor:r,ariaActiveDescendant:e,ariaAutoComplete:t,ariaControls:n,ariaDescribedBy:s,ariaErrorMessage:i,ariaExpanded:o,ariaInvalid:l,ariaLabel:a,ariaLabelledBy:u,ariaMultiline:c,ariaOwns:d,ariaRequired:h,autoCapitalize:p,className:g,id:m,role:x="textbox",spellCheck:_=!0,style:b,tabIndex:C,"data-testid":S,...k},E){const[v,T]=y.useState(r.isEditable()),B=y.useCallback(N=>{N&&N.ownerDocument&&N.ownerDocument.defaultView?r.setRootElement(N):r.setRootElement(null)},[r]),j=y.useMemo(()=>function(...N){return M=>{N.forEach(R=>{typeof R=="function"?R(M):R!=null&&(R.current=M)})}}(E,B),[B,E]);return Tc(()=>(T(r.isEditable()),r.registerEditableListener(N=>{T(N)})),[r]),f.jsx("div",{"aria-activedescendant":v?e:void 0,"aria-autocomplete":v?t:"none","aria-controls":v?n:void 0,"aria-describedby":s,...i!=null?{"aria-errormessage":i}:{},"aria-expanded":v&&x==="combobox"?!!o:void 0,...l!=null?{"aria-invalid":l}:{},"aria-label":a,"aria-labelledby":u,"aria-multiline":c,"aria-owns":v?d:void 0,"aria-readonly":!v||void 0,"aria-required":h,autoCapitalize:p,className:g,contentEditable:v,"data-testid":S,id:m,ref:j,role:v?x:void 0,spellCheck:_,style:b,tabIndex:C,...k})}const Rp=y.forwardRef(Mp);function Sl(r){return r.getEditorState().read(xc(r.isComposing()))}const Fp=y.forwardRef(Lp);function Lp(r,e){const{placeholder:t,...n}=r,[s]=$t();return f.jsxs(f.Fragment,{children:[f.jsx(Rp,{editor:s,...n,ref:e}),t!=null&&f.jsx(Pp,{editor:s,content:t})]})}function Pp({content:r,editor:e}){const t=function(o){const[l,a]=y.useState(()=>Sl(o));return Tc(()=>{function u(){const c=Sl(o);a(c)}return u(),Pr(o.registerUpdateListener(()=>{u()}),o.registerEditableListener(()=>{u()}))},[o]),l}(e),[n,s]=y.useState(e.isEditable());if(y.useLayoutEffect(()=>(s(e.isEditable()),e.registerEditableListener(o=>{s(o)})),[e]),!t)return null;let i=null;return typeof r=="function"?i=r(n):r!==null&&(i=r),i===null?null:f.jsx("div",{"aria-hidden":!0,children:i})}const ps=0,ho=1,po=2,Lt=0,Ip=1,kl=2,zp=3,Op=4;function $p(r,e,t,n,s){if(r===null||t.size===0&&n.size===0&&!s)return Lt;const i=e._selection,o=r._selection;if(s)return Ip;if(!(K(i)&&K(o)&&o.isCollapsed()&&i.isCollapsed()))return Lt;const l=function(_,b,C){const S=_._nodeMap,k=[];for(const E of b){const v=S.get(E);v!==void 0&&k.push(v)}for(const[E,v]of C){if(!v)continue;const T=S.get(E);T===void 0||yt(T)||k.push(T)}return k}(e,t,n);if(l.length===0)return Lt;if(l.length>1){const _=e._nodeMap,b=_.get(i.anchor.key),C=_.get(o.anchor.key);return b&&C&&!r._nodeMap.has(b.__key)&&Z(b)&&b.__text.length===1&&i.anchor.offset===1?kl:Lt}const a=l[0],u=r._nodeMap.get(a.__key);if(!Z(u)||!Z(a)||u.__mode!==a.__mode)return Lt;const c=u.__text,d=a.__text;if(c===d)return Lt;const h=i.anchor,p=o.anchor;if(h.key!==p.key||h.type!=="text")return Lt;const g=h.offset,m=p.offset,x=d.length-c.length;return x===1&&m===g-1?kl:x===-1&&m===g+1?zp:x===-1&&m===g?Op:Lt}function qp(r,e){let t=Date.now(),n=Lt;return(s,i,o,l,a,u)=>{const c=Date.now();if(u.has("historic"))return n=Lt,t=c,po;const d=$p(s,i,l,a,r.isComposing()),h=(()=>{const p=o===null||o.editor===r,g=u.has("history-push");if(!g&&p&&u.has("history-merge"))return ps;if(s===null)return ho;const m=i._selection;return l.size>0||a.size>0?g===!1&&d!==Lt&&d===n&&c<t+e&&p||l.size===1&&function(x,_,b){const C=_._nodeMap.get(x),S=b._nodeMap.get(x),k=_._selection,E=b._selection;return!(K(k)&&K(E)&&k.anchor.type==="element"&&k.focus.type==="element"&&E.anchor.type==="text"&&E.focus.type==="text"||!Z(C)||!Z(S)||C.__parent!==S.__parent)&&JSON.stringify(_.read(()=>C.exportJSON()))===JSON.stringify(b.read(()=>S.exportJSON()))}(Array.from(l)[0],s,i)?ps:ho:m!==null?ps:po})();return t=c,n=d,h}}function El(r){r.undoStack=[],r.redoStack=[],r.current=null}function Up(r,e,t){const n=qp(r,t);return Pr(r.registerCommand(jo,()=>(function(i,o){const l=o.redoStack,a=o.undoStack;if(a.length!==0){const u=o.current,c=a.pop();u!==null&&(l.push(u),i.dispatchCommand(as,!0)),a.length===0&&i.dispatchCommand(ls,!1),o.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),We),r.registerCommand(Mo,()=>(function(i,o){const l=o.redoStack,a=o.undoStack;if(l.length!==0){const u=o.current;u!==null&&(a.push(u),i.dispatchCommand(ls,!0));const c=l.pop();l.length===0&&i.dispatchCommand(as,!1),o.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),We),r.registerCommand(qf,()=>(El(e),!1),We),r.registerCommand(Uf,()=>(El(e),r.dispatchCommand(as,!1),r.dispatchCommand(ls,!1),!0),We),r.registerUpdateListener(({editorState:i,prevEditorState:o,dirtyLeaves:l,dirtyElements:a,tags:u})=>{const c=e.current,d=e.redoStack,h=e.undoStack,p=c===null?null:c.editorState;if(c!==null&&i===p)return;const g=n(o,i,c,l,a,u);if(g===ho)d.length!==0&&(e.redoStack=[],r.dispatchCommand(as,!1)),c!==null&&(h.push({...c}),r.dispatchCommand(ls,!0));else if(g===po)return;e.current={editor:r,editorState:i}}))}function Wp(){return{current:null,redoStack:[],undoStack:[]}}function Hp({delay:r,externalHistoryState:e}){const[t]=$t();return function(n,s,i=1e3){const o=y.useMemo(()=>s||Wp(),[s]);y.useEffect(()=>Up(n,o,i),[i,n,o])}(t,e,r),null}const Vp=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Gp({ignoreHistoryMergeTagChange:r=!0,ignoreSelectionChange:e=!1,onChange:t}){const[n]=$t();return Vp(()=>{if(t)return n.registerUpdateListener(({editorState:s,dirtyElements:i,dirtyLeaves:o,prevEditorState:l,tags:a})=>{e&&i.size===0&&o.size===0||r&&a.has("history-merge")||l.isEmpty()||t(s,n,a)})},[n,r,e,t]),null}function go(r,e){return go=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},go(r,e)}var Dl={error:null},Kp=function(r){var e,t;function n(){for(var i,o=arguments.length,l=new Array(o),a=0;a<o;a++)l[a]=arguments[a];return(i=r.call.apply(r,[this].concat(l))||this).state=Dl,i.resetErrorBoundary=function(){for(var u,c=arguments.length,d=new Array(c),h=0;h<c;h++)d[h]=arguments[h];i.props.onReset==null||(u=i.props).onReset.apply(u,d),i.reset()},i}t=r,(e=n).prototype=Object.create(t.prototype),e.prototype.constructor=e,go(e,t),n.getDerivedStateFromError=function(i){return{error:i}};var s=n.prototype;return s.reset=function(){this.setState(Dl)},s.componentDidCatch=function(i,o){var l,a;(l=(a=this.props).onError)==null||l.call(a,i,o)},s.componentDidUpdate=function(i,o){var l,a,u,c,d=this.state.error,h=this.props.resetKeys;d!==null&&o.error!==null&&((u=i.resetKeys)===void 0&&(u=[]),(c=h)===void 0&&(c=[]),u.length!==c.length||u.some(function(p,g){return!Object.is(p,c[g])}))&&((l=(a=this.props).onResetKeysChange)==null||l.call(a,i.resetKeys,h),this.reset())},s.render=function(){var i=this.state.error,o=this.props,l=o.fallbackRender,a=o.FallbackComponent,u=o.fallback;if(i!==null){var c={error:i,resetErrorBoundary:this.resetErrorBoundary};if(ki.isValidElement(u))return u;if(typeof l=="function")return l(c);if(a)return ki.createElement(a,c);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},n}(ki.Component);function Yp({children:r,onError:e}){return f.jsx(Kp,{fallback:f.jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:e,children:r})}function Qp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Vt=Qp(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 Jp(r){let e=1,t=r.getParent();for(;t!=null;){if(rt(t)){const n=t.getParent();if(qe(n)){e++,t=n.getParent();continue}Vt(40)}return e}return e}function mo(r){let e=r.getParent();qe(e)||Vt(40);let t=e;for(;t!==null;)t=t.getParent(),qe(t)&&(e=t);return e}function Nc(r){let e=[];const t=r.getChildren().filter(rt);for(let n=0;n<t.length;n++){const s=t[n],i=s.getFirstChild();qe(i)?e=e.concat(Nc(i)):e.push(s)}return e}function Gt(r){return rt(r)&&qe(r.getFirstChild())}function Al(r){return At().append(r)}function Bc(r,e){return rt(r)&&(e.length===0||e.length===1&&r.is(e[0])&&r.getChildrenSize()===0)}function Tl(r,e){r.update(()=>{const t=ae();if(t!==null){const n=t.getNodes();if(K(t)){const i=t.getStartEndPoints();i===null&&Vt(143);const[o]=i,l=o.getNode(),a=l.getParent();if(Bc(l,n)){const u=Et(e);if(Qt(a)){l.replace(u);const c=At();O(l)&&(c.setFormat(l.getFormatType()),c.setIndent(l.getIndent())),u.append(c)}else if(rt(l)){const c=l.getParentOrThrow();Rr(u,c.getChildren()),c.replace(u)}return}}const s=new Set;for(let i=0;i<n.length;i++){const o=n[i];if(!O(o)||!o.isEmpty()||rt(o)||s.has(o.getKey())){if(Fu(o)){let l=o.getParent();for(;l!=null;){const a=l.getKey();if(qe(l)){if(!s.has(a)){const u=Et(e);Rr(u,l.getChildren()),l.replace(u),s.add(a)}break}{const u=l.getParent();if(Qt(u)&&!s.has(a)){s.add(a),Nl(l,e);break}l=u}}}}else Nl(o,e)}}})}function Rr(r,e){r.splice(r.getChildrenSize(),0,e)}function Nl(r,e){if(qe(r))return r;const t=r.getPreviousSibling(),n=r.getNextSibling(),s=At();let i;if(Rr(s,r.getChildren()),qe(t)&&e===t.getListType())t.append(s),qe(n)&&e===n.getListType()&&(Rr(t,n.getChildren()),n.remove()),i=t;else if(qe(n)&&e===n.getListType())n.getFirstChildOrThrow().insertBefore(s),i=n;else{const o=Et(e);o.append(s),r.replace(o),i=o}return s.setFormat(r.getFormatType()),s.setIndent(r.getIndent()),r.remove(),i}function oa(r,e){const t=r.getLastChild(),n=e.getFirstChild();t&&n&&Gt(t)&&Gt(n)&&(oa(t.getFirstChild(),n.getFirstChild()),n.remove());const s=e.getChildren();s.length>0&&r.append(...s),e.remove()}function Xp(r){r.update(()=>{const e=ae();if(K(e)){const t=new Set,n=e.getNodes(),s=e.anchor.getNode();if(Bc(s,n))t.add(mo(s));else for(let i=0;i<n.length;i++){const o=n[i];if(Fu(o)){const l=fp(o,Ir);l!=null&&t.add(mo(l))}}for(const i of t){let o=i;const l=Nc(i);for(const a of l){const u=at();Rr(u,a.getChildren()),o.insertAfter(u),o=u,a.__key===e.anchor.key&&e.anchor.set(u.getKey(),0,"element"),a.__key===e.focus.key&&e.focus.set(u.getKey(),0,"element"),a.remove()}i.remove()}}})}function Zp(r){const e=new Set;if(Gt(r)||e.has(r.getKey()))return;const t=r.getParent(),n=r.getNextSibling(),s=r.getPreviousSibling();if(Gt(n)&&Gt(s)){const i=s.getFirstChild();if(qe(i)){i.append(r);const o=n.getFirstChild();qe(o)&&(Rr(i,o.getChildren()),n.remove(),e.add(n.getKey()))}}else if(Gt(n)){const i=n.getFirstChild();if(qe(i)){const o=i.getFirstChild();o!==null&&o.insertBefore(r)}}else if(Gt(s)){const i=s.getFirstChild();qe(i)&&i.append(r)}else if(qe(t)){const i=At(),o=Et(t.getListType());i.append(o),o.append(r),s?s.insertAfter(i):n?n.insertBefore(i):t.append(i)}}function eg(r){if(Gt(r))return;const e=r.getParent(),t=e?e.getParent():void 0;if(qe(t?t.getParent():void 0)&&rt(t)&&qe(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 i=e.getListType(),o=At(),l=Et(i);o.append(l),r.getPreviousSiblings().forEach(c=>l.append(c));const a=At(),u=Et(i);a.append(u),Rr(u,r.getNextSiblings()),t.insertBefore(o),t.insertAfter(a),t.replace(r)}}}function tg(){const r=ae();if(!K(r)||!r.isCollapsed())return!1;const e=r.anchor.getNode();if(!rt(e)||e.getChildrenSize()!==0)return!1;const t=mo(e),n=e.getParent();qe(n)||Vt(40);const s=n.getParent();let i;if(Qt(s))i=at(),t.insertAfter(i);else{if(!rt(s))return!1;i=At(),s.insertAfter(i)}i.select();const o=e.getNextSiblings();if(o.length>0){const l=Et(n.getListType());if(tn(i))i.insertAfter(l);else{const a=At();a.append(l),i.insertAfter(a)}o.forEach(a=>{a.remove(),l.append(a)})}return function(l){let a=l;for(;a.getNextSibling()==null&&a.getPreviousSibling()==null;){const u=a.getParent();if(u==null||!rt(a)&&!qe(a))break;a=u}a.remove()}(e),!0}function Gs(...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 Ir extends lr{static getType(){return"listitem"}static clone(e){return new Ir(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 qe(n)&&n.getListType()==="check"&&jl(t,this,null),t.value=this.__value,Bl(t,e.theme,this),t}updateDOM(e,t,n){const s=this.getParent();return qe(s)&&s.getListType()==="check"&&jl(t,this,e),t.value=this.__value,Bl(t,n.theme,this),!1}static transform(){return e=>{if(rt(e)||Vt(144),e.__checked==null)return;const t=e.getParent();qe(t)&&t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:rg,priority:0})}}static importJSON(e){const t=At();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(O(n)&&this.canMergeWith(n)){const s=n.getChildren();this.append(...s),n.remove()}else super.append(n)}return this}replace(e,t){if(rt(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!qe(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{const s=Et(n.getListType());let i=this.getNextSibling();for(;i;){const o=i;i=i.getNextSibling(),s.append(o)}n.insertAfter(e),e.insertAfter(s)}return t&&(O(e)||Vt(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(qe(n)||Vt(39),rt(e))return super.insertAfter(e,t);const s=this.getNextSiblings();if(n.insertAfter(e,t),s.length!==0){const i=Et(n.getListType());s.forEach(o=>i.append(o)),e.insertAfter(i,t)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&Gt(t)&&Gt(n)&&(oa(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){const n=At(this.__checked==null&&void 0);return this.insertAfter(n,t),n}collapseAtStart(e){const t=at();this.getChildren().forEach(o=>t.append(o));const n=this.getParentOrThrow(),s=n.getParentOrThrow(),i=rt(s);if(n.getChildrenSize()===1)if(i)n.remove(),s.select();else{n.insertBefore(t),n.remove();const o=e.anchor,l=e.focus,a=t.getKey();o.type==="element"&&o.getNode().is(this)&&o.set(a,o.offset,"element"),l.type==="element"&&l.getNode().is(this)&&l.set(a,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 qe(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(;rt(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){typeof e!="number"&&Vt(117),(e=Math.floor(e))>=0||Vt(199);let t=this.getIndent();for(;t!==e;)t<e?(Zp(this),t++):(eg(this),t--);return this}canInsertAfter(e){return rt(e)}canReplaceWith(e){return rt(e)}canMergeWith(e){return tn(e)||rt(e)}extractWithChild(e,t){if(!K(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 Et("bullet")}canMergeWhenEmpty(){return!0}}function Bl(r,e,t){const n=[],s=[],i=e.list,o=i?i.listitem:void 0;let l;if(i&&i.nested&&(l=i.nested.listitem),o!==void 0&&n.push(...Gs(o)),i){const a=t.getParent(),u=qe(a)&&a.getListType()==="check",c=t.getChecked();u&&!c||s.push(i.listitemUnchecked),u&&c||s.push(i.listitemChecked),u&&n.push(c?i.listitemChecked:i.listitemUnchecked)}if(l!==void 0){const a=Gs(l);t.getChildren().some(u=>qe(u))?n.push(...a):s.push(...a)}s.length>0&&wc(r,...s),n.length>0&&rs(r,...n)}function jl(r,e,t,n){qe(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 rg(r){if(r.classList.contains("task-list-item")){for(const t of r.children)if(t.tagName==="INPUT")return ng(t)}const e=r.getAttribute("aria-checked");return{node:At(e==="true"||e!=="false"&&void 0)}}function ng(r){return r.getAttribute("type")!=="checkbox"?{node:null}:{node:At(r.hasAttribute("checked"))}}function At(r){return Xt(new Ir(void 0,r))}function rt(r){return r instanceof Ir}class ln extends lr{static getType(){return"list"}static clone(e){const t=e.__listType||Fl[e.__tag];return new ln(t,e.__start,e.__key)}constructor(e,t,n){super(n);const s=Fl[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,Ml(s,e.theme,this),s}updateDOM(e,t,n){return e.__tag!==this.__tag||(Ml(t,n.theme,this),!1)}static transform(){return e=>{qe(e)||Vt(163),function(t){const n=t.getNextSibling();qe(n)&&t.getListType()===n.getListType()&&oa(t,n)}(e),function(t){const n=t.getListType()!=="check";let s=t.getStart();for(const i of t.getChildren())rt(i)&&(i.getValue()!==s&&i.setValue(s),n&&i.getLatest().__checked!=null&&i.setChecked(void 0),qe(i.getFirstChild())||s++)}(e)}}static importDOM(){return{ol:()=>({conversion:Rl,priority:0}),ul:()=>({conversion:Rl,priority:0})}}static importJSON(e){const t=Et(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&&or(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(rt(n))super.append(n);else{const s=At();if(qe(n))s.append(n);else if(O(n))if(n.isInline())s.append(n);else{const i=lt(n.getTextContent());s.append(i)}else s.append(n);super.append(s)}}return this}extractWithChild(e){return rt(e)}}function Ml(r,e,t){const n=[],s=[],i=e.list;if(i!==void 0){const o=i[`${t.__tag}Depth`]||[],l=Jp(t)-1,a=l%o.length,u=o[a],c=i[t.__tag];let d;const h=i.nested,p=i.checklist;if(h!==void 0&&h.list&&(d=h.list),c!==void 0&&n.push(c),p!==void 0&&t.__listType==="check"&&n.push(p),u!==void 0){n.push(...Gs(u));for(let g=0;g<o.length;g++)g!==a&&s.push(t.__tag+g)}if(d!==void 0){const g=Gs(d);l>1?n.push(...g):s.push(...g)}}s.length>0&&wc(r,...s),n.length>0&&rs(r,...n)}function sg(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t];if(rt(n)){e.push(n);const s=n.getChildren();s.length>1&&s.forEach(i=>{qe(i)&&e.push(Al(i))})}else e.push(Al(n))}return e}function Rl(r){const e=r.nodeName.toLowerCase();let t=null;return e==="ol"?t=Et("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(or(s)&&s.hasAttribute("aria-checked"))return!0;return!1}(r)?Et("check"):Et("bullet")),{after:sg,node:t}}const Fl={ol:"number",ul:"bullet"};function Et(r,e=1){return Xt(new ln(r,e))}function qe(r){return r instanceof ln}const jc=Hn(),Mc=Hn(),ig=Hn();function og(r){return Pr(r.registerCommand(Mc,()=>(Tl(r,"number"),!0),Vr),r.registerCommand(jc,()=>(Tl(r,"bullet"),!0),Vr),r.registerCommand(ig,()=>(Xp(r),!0),Vr),r.registerCommand(Rn,()=>!!tg(),Vr))}function ag(){const[r]=$t();return y.useEffect(()=>{if(!r.hasNodes([ln,Ir]))throw new Error("ListPlugin: ListNode and/or ListItemNode not registered on editor")},[r]),function(e){y.useEffect(()=>og(e),[e])}(r),null}const lg=new Set(["http:","https:","mailto:","sms:","tel:"]);class zr extends lr{static getType(){return"link"}static clone(e){return new zr(e.__url,{rel:e.__rel,target:e.__target,title:e.__title},e.__key)}constructor(e,t={},n){super(n);const{target:s=null,rel:i=null,title:o=null}=t;this.__url=e,this.__target=s,this.__rel=i,this.__title=o}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),rs(t,e.theme.link),t}updateDOM(e,t,n){if(t instanceof HTMLAnchorElement){const s=this.__url,i=this.__target,o=this.__rel,l=this.__title;s!==e.__url&&(t.href=s),i!==e.__target&&(i?t.target=i:t.removeAttribute("target")),o!==e.__rel&&(o?t.rel=o:t.removeAttribute("rel")),l!==e.__title&&(l?t.title=l:t.removeAttribute("title"))}return!1}static importDOM(){return{a:e=>({conversion:ug,priority:1})}}static importJSON(e){const t=Ks(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(!lg.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=Ks(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(!K(t))return!1;const s=t.anchor.getNode(),i=t.focus.getNode();return this.isParentOf(s)&&this.isParentOf(i)&&t.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}}function ug(r){let e=null;if(_h(r)){const t=r.textContent;(t!==null&&t!==""||r.children.length>0)&&(e=Ks(r.getAttribute("href")||"",{rel:r.getAttribute("rel"),target:r.getAttribute("target"),title:r.getAttribute("title")}))}return{node:e}}function Ks(r,e){return Xt(new zr(r,e))}function mn(r){return r instanceof zr}class ns extends zr{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 ns(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=Ll(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(O(n)){const s=Ll(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return n.append(s),s}return null}}function Ll(r,e){return Xt(new ns(r,e))}function cg(r){return r instanceof ns}const Pl=Hn();function $i(r,e={}){const{target:t,title:n}=e,s=e.rel===void 0?"noreferrer":e.rel,i=ae();if(!K(i))return;const o=i.extract();if(r===null)o.forEach(l=>{const a=yi(l,u=>!cg(u)&&mn(u));if(a){const u=a.getChildren();for(let c=0;c<u.length;c++)a.insertBefore(u[c]);a.remove()}});else{if(o.length===1){const u=function(c,d){let h=c;for(;h!==null&&h.getParent()!==null&&!d(h);)h=h.getParentOrThrow();return d(h)?h:null}(o[0],mn);if(u!==null)return u.setURL(r),t!==void 0&&u.setTarget(t),s!==null&&u.setRel(s),void(n!==void 0&&u.setTitle(n))}let l=null,a=null;o.forEach(u=>{const c=u.getParent();if(c!==a&&c!==null&&(!O(u)||u.isInline())){if(mn(c))return a=c,c.setURL(r),t!==void 0&&c.setTarget(t),s!==null&&a.setRel(s),void(n!==void 0&&a.setTitle(n));if(c.is(l)||(l=c,a=Ks(r,{rel:s,target:t,title:n}),mn(c)?u.getPreviousSibling()===null?c.insertBefore(a):c.insertAfter(a):u.insertBefore(a)),mn(u)){if(u.is(a))return;if(a!==null){const d=u.getChildren();for(let h=0;h<d.length;h++)a.append(d[h])}u.remove()}else a!==null&&a.append(u)}})}}function dg({validateUrl:r,attributes:e}){const[t]=$t();return y.useEffect(()=>{if(!t.hasNodes([zr]))throw new Error("LinkPlugin: LinkNode not registered on editor");return Pr(t.registerCommand(Pl,n=>{if(n===null)return $i(n),!0;if(typeof n=="string")return!(r!==void 0&&!r(n))&&($i(n,e),!0);{const{url:s,target:i,rel:o,title:l}=n;return $i(s,{...e,rel:o,target:i,title:l}),!0}},Vr),r!==void 0?t.registerCommand(si,n=>{const s=ae();if(!K(s)||s.isCollapsed()||!gr(n,ClipboardEvent))return!1;const i=n;if(i.clipboardData===null)return!1;const o=i.clipboardData.getData("text");return!!r(o)&&!s.getNodes().some(l=>O(l))&&(t.dispatchCommand(Pl,{...e,url:o}),n.preventDefault(),!0)},Vr):()=>{})},[t,r,e]),null}function fg(r){if(r instanceof HTMLImageElement){const e=r.getAttribute("src")||"",t=r.getAttribute("alt")||"",n=r.getAttribute("width"),s=r.getAttribute("height");return{node:Rc({src:e,altText:t,width:n?parseInt(n,10):void 0,height:s?parseInt(s,10):void 0})}}return null}function hg({src:r,alt:e,width:t,height:n}){return f.jsx("img",{src:r,alt:e,width:t,height:n,style:{maxWidth:"100%",height:"auto",display:"block",margin:"8px 0",borderRadius:"4px"}})}class vi extends ra{constructor(t,n,s,i,o){super(o);wt(this,"__src");wt(this,"__altText");wt(this,"__width");wt(this,"__height");this.__src=t,this.__altText=n||"",this.__width=s,this.__height=i}static getType(){return"image"}static clone(t){return new vi(t.__src,t.__altText,t.__width,t.__height,t.__key)}static importJSON(t){const{src:n,altText:s,width:i,height:o}=t;return Rc({src:n,altText:s,width:i,height:o})}exportJSON(){return{type:"image",version:1,src:this.__src,altText:this.__altText,width:this.__width,height:this.__height}}static importDOM(){return{img:()=>({conversion:fg,priority:0})}}exportDOM(){const t=document.createElement("img");return t.setAttribute("src",this.__src),this.__altText&&t.setAttribute("alt",this.__altText),this.__width&&t.setAttribute("width",String(this.__width)),this.__height&&t.setAttribute("height",String(this.__height)),t.style.maxWidth="100%",t.style.height="auto",{element:t}}createDOM(){const t=document.createElement("span");return t.style.display="inline-block",t}updateDOM(){return!1}decorate(){return f.jsx(hg,{src:this.__src,alt:this.__altText,width:this.__width,height:this.__height})}}function Rc(r){return new vi(r.src,r.altText,r.width,r.height)}var pg=Object.defineProperty,Ys=Object.getOwnPropertySymbols,Fc=Object.prototype.hasOwnProperty,Lc=Object.prototype.propertyIsEnumerable,Il=(r,e,t)=>e in r?pg(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,yo=(r,e)=>{for(var t in e||(e={}))Fc.call(e,t)&&Il(r,t,e[t]);if(Ys)for(var t of Ys(e))Lc.call(e,t)&&Il(r,t,e[t]);return r},xo=(r,e)=>{var t={};for(var n in r)Fc.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&Ys)for(var n of Ys(r))e.indexOf(n)<0&&Lc.call(r,n)&&(t[n]=r[n]);return t};/**
95
+ `?l.insertParagraph():u===" "?l.insertNodes([Xn()]):l.insertText(u)}}}else e.insertRawText(i)}function gl(r,e,t){r.dispatchCommand(jf,{nodes:e,selection:t})||t.insertNodes(e)}function Ac(r,e,t,n=[]){let s=e===null||t.isSelected(e);const i=$(t)&&t.excludeFromCopy("html");let o=t;if(e!==null){let u=Jo(t);u=ee(u)&&e!==null?bc(e,u):u,o=u}const a=$(o)?o.getChildren():[],l=function(u){const c=u.exportJSON(),d=u.constructor;if(c.type!==d.getType()&&Vs(58,d.name),$(u)){const h=c.children;Array.isArray(h)||Vs(59,d.name)}return c}(o);if(ee(o)){const u=o.__text;u.length>0?l.text=u:s=!1}for(let u=0;u<a.length;u++){const c=a[u],d=Ac(r,e,c,l.children);!s&&$(t)&&d&&t.extractWithChild(c,e,"clone")&&(s=!0)}if(s&&!i)n.push(l);else if(Array.isArray(l.children))for(let u=0;u<l.children.length;u++){const c=l.children[u];n.push(c)}return s}function bp(r,e){const t=[],n=Ze().getChildren();for(let s=0;s<n.length;s++)Ac(r,e,n[s],t);return{namespace:r._config.namespace,nodes:t}}function vp(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t],s=qh(n);ee(s)&&ip(s),e.push(s)}return e}let qr=null;async function ml(r,e,t){if(qr!==null)return!1;if(e!==null)return new Promise((l,u)=>{r.update(()=>{l(yl(r,e,t))})});const n=r.getRootElement(),s=r._window==null?window.document:r._window.document,i=Bt(r._window);if(n===null||i===null)return!1;const o=s.createElement("span");o.style.cssText="position: fixed; top: -1000px;",o.append(s.createTextNode("#")),n.append(o);const a=new Range;return a.setStart(o,0),a.setEnd(o,1),i.removeAllRanges(),i.addRange(a),new Promise((l,u)=>{const c=r.registerCommand(ii,d=>(pr(d,ClipboardEvent)&&(c(),qr!==null&&(window.clearTimeout(qr),qr=null),l(yl(r,d,t))),!0),Wh);qr=window.setTimeout(()=>{c(),qr=null,l(!1)},50),s.execCommand("copy"),o.remove()})}function yl(r,e,t){if(t===void 0){const s=Bt(r._window);if(!s)return!1;const i=s.anchorNode,o=s.focusNode;if(i!==null&&o!==null&&!Kn(r,i,o))return!1;const a=ae();if(a===null)return!1;t=wp(a)}e.preventDefault();const n=e.clipboardData;return n!==null&&(Cp(n,t),!0)}const _p=[["text/html",yp],["application/x-lexical-editor",xp]];function wp(r=ae()){const e={"text/plain":r?r.getTextContent():""};if(r){const t=wh();for(const[n,s]of _p){const i=s(t,r);i!==null&&(e[n]=i)}}return e}function Cp(r,e){for(const t in e){const n=e[t];n!==void 0&&r.setData(t,n)}}function xl(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 an=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,Sp=an&&"documentMode"in document?document.documentMode:null,kp=!(!an||!("InputEvent"in window)||Sp)&&"getTargetRanges"in new window.InputEvent("input"),Ep=an&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),bl=an&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,Dp=an&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Ap=an&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Dp,vl=Hn();class xi extends ar{static getType(){return"quote"}static clone(e){return new xi(e.__key)}constructor(e){super(e)}createDOM(e){const t=document.createElement("blockquote");return rs(t,e.theme.quote),t}updateDOM(e,t){return!1}static importDOM(){return{blockquote:e=>({conversion:Tp,priority:0})}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&ir(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=ia();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=ot(),s=this.getDirection();return n.setDirection(s),this.insertAfter(n,t),n}collapseAtStart(){const e=ot();return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}canMergeWhenEmpty(){return!0}}function ia(){return Qt(new xi)}class bi extends ar{static getType(){return"heading"}static clone(e){return new bi(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 i=s[t];rs(n,i)}return n}updateDOM(e,t){return!1}static importDOM(){return{h1:e=>({conversion:Ur,priority:0}),h2:e=>({conversion:Ur,priority:0}),h3:e=>({conversion:Ur,priority:0}),h4:e=>({conversion:Ur,priority:0}),h5:e=>({conversion:Ur,priority:0}),h6:e=>({conversion:Ur,priority:0}),p:e=>{const t=e.firstChild;return t!==null&&_l(t)?{conversion:()=>({node:null}),priority:3}:null},span:e=>_l(e)?{conversion:t=>({node:wn("h1")}),priority:3}:null}}exportDOM(e){const{element:t}=super.exportDOM(e);if(t&&ir(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=wn(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(),i=!s||e&&e.anchor.key===s.getKey()&&n===s.getTextContentSize()||!e?ot():wn(this.getTag()),o=this.getDirection();if(i.setDirection(o),this.insertAfter(i,t),n===0&&!this.isEmpty()&&e){const a=ot();a.select(),this.replace(a,!0)}return i}collapseAtStart(){const e=this.isEmpty()?ot():wn(this.getTag());return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}extractWithChild(){return!0}}function _l(r){return r.nodeName.toLowerCase()==="span"&&r.style.fontSize==="26pt"}function Ur(r){const e=r.nodeName.toLowerCase();let t=null;return e!=="h1"&&e!=="h2"&&e!=="h3"&&e!=="h4"&&e!=="h5"&&e!=="h6"||(t=wn(e),r.style!==null&&(Xo(r,t),t.setFormat(r.style.textAlign))),{node:t}}function Tp(r){const e=ia();return r.style!==null&&(e.setFormat(r.style.textAlign),Xo(r,e)),{node:e}}function wn(r){return Qt(new bi(r))}function fs(r){let e=null;if(pr(r,DragEvent)?e=r.dataTransfer:pr(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 wl(r){const e=ae();if(!V(e))return!1;const t=new Set,n=e.getNodes();for(let s=0;s<n.length;s++){const i=n[s],o=i.getKey();if(t.has(o))continue;const a=yi(i,u=>$(u)&&!u.isInline());if(a===null)continue;const l=a.getKey();a.canIndent()&&!t.has(l)&&(t.add(l),r(a))}return t.size>0}function hs(r){const e=en(r);return Ge(e)}function Np(r){return Pr(r.registerCommand(gu,e=>{const t=ae();return!!Ut(t)&&(t.clear(),!0)},0),r.registerCommand(Er,e=>{const t=ae();return!!V(t)&&(t.deleteCharacter(e),!0)},We),r.registerCommand(Fn,e=>{const t=ae();return!!V(t)&&(t.deleteWord(e),!0)},We),r.registerCommand(Ln,e=>{const t=ae();return!!V(t)&&(t.deleteLine(e),!0)},We),r.registerCommand(Yr,e=>{const t=ae();if(typeof e=="string")t!==null&&t.insertText(e);else{if(t===null)return!1;const n=e.dataTransfer;if(n!=null)pl(n,t,r);else if(V(t)){const s=e.data;return s&&t.insertText(s),!0}}return!0},We),r.registerCommand(Ki,()=>{const e=ae();return!!V(e)&&(e.removeText(),!0)},We),r.registerCommand(Pt,e=>{const t=ae();return!!V(t)&&(t.formatText(e),!0)},We),r.registerCommand(Of,e=>{const t=ae();if(!V(t)&&!Ut(t))return!1;const n=t.getNodes();for(const s of n){const i=yi(s,o=>$(o)&&!o.isInline());i!==null&&i.setFormat(e)}return!0},We),r.registerCommand(Kr,e=>{const t=ae();return!!V(t)&&(t.insertLineBreak(e),!0)},We),r.registerCommand(Rn,()=>{const e=ae();return!!V(e)&&(e.insertParagraph(),!0)},We),r.registerCommand(If,()=>(lc([Xn()]),!0),We),r.registerCommand(zf,()=>wl(e=>{const t=e.getIndent();e.setIndent(t+1)}),We),r.registerCommand(Da,()=>wl(e=>{const t=e.getIndent();t>0&&e.setIndent(t-1)}),We),r.registerCommand(xu,e=>{const t=ae();if(Ut(t)&&!hs(e.target)){const n=t.getNodes();if(n.length>0)return n[0].selectPrevious(),!0}else if(V(t)){const n=Pn(t.focus,!0);if(!e.shiftKey&&Ge(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),e.preventDefault(),!0}return!1},We),r.registerCommand(bu,e=>{const t=ae();if(Ut(t)){const n=t.getNodes();if(n.length>0)return n[0].selectNext(0,0),!0}else if(V(t)){if(function(s){const i=s.focus;return i.key==="root"&&i.offset===Ze().getChildrenSize()}(t))return e.preventDefault(),!0;const n=Pn(t.focus,!1);if(!e.shiftKey&&Ge(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),e.preventDefault(),!0}return!1},We),r.registerCommand(yu,e=>{const t=ae();if(Ut(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectPrevious(),!0}if(!V(t))return!1;if(dl(t,!0)){const n=e.shiftKey;return e.preventDefault(),fl(t,n,!0),!0}return!1},We),r.registerCommand(mu,e=>{const t=ae();if(Ut(t)&&!hs(e.target)){const s=t.getNodes();if(s.length>0)return e.preventDefault(),s[0].selectNext(0,0),!0}if(!V(t))return!1;const n=e.shiftKey;return!!dl(t,!1)&&(e.preventDefault(),fl(t,n,!1),!0)},We),r.registerCommand(vu,e=>{if(hs(e.target))return!1;const t=ae();if(!V(t))return!1;const{anchor:n}=t,s=n.getNode();return t.isCollapsed()&&n.offset===0&&!yt(s)&&hp(s).getIndent()>0?(e.preventDefault(),r.dispatchCommand(Da,void 0)):(!bl||navigator.language!=="ko-KR")&&(e.preventDefault(),r.dispatchCommand(Er,!0))},We),r.registerCommand(wu,e=>{if(hs(e.target))return!1;const t=ae();return!!V(t)&&(e.preventDefault(),r.dispatchCommand(Er,!1))},We),r.registerCommand(Ns,e=>{const t=ae();if(!V(t))return!1;if(e!==null){if((bl||Ep||Ap)&&kp)return!1;if(e.preventDefault(),e.shiftKey)return r.dispatchCommand(Kr,!1)}return r.dispatchCommand(Rn,void 0)},We),r.registerCommand(_u,()=>{const e=ae();return!!V(e)&&(r.blur(),!0)},We),r.registerCommand(Cu,e=>{const[,t]=fs(e);if(t.length>0){const s=xl(e.clientX,e.clientY);if(s!==null){const{offset:i,node:o}=s,a=en(o);if(a!==null){const l=Ih();if(ee(a))l.anchor.set(a.getKey(),i,"text"),l.focus.set(a.getKey(),i,"text");else{const c=a.getParentOrThrow().getKey(),d=a.getIndexWithinParent()+1;l.anchor.set(c,d,"element"),l.focus.set(c,d,"element")}const u=Mu(l);Gt(u)}r.dispatchCommand(vl,t)}return e.preventDefault(),!0}const n=ae();return!!V(n)},We),r.registerCommand(Su,e=>{const[t]=fs(e),n=ae();return!(t&&!V(n))},We),r.registerCommand(ku,e=>{const[t]=fs(e),n=ae();if(t&&!V(n))return!1;const s=xl(e.clientX,e.clientY);if(s!==null){const i=en(s.node);Ge(i)&&e.preventDefault()}return!0},We),r.registerCommand(Yi,()=>(xh(),!0),We),r.registerCommand(ii,e=>(ml(r,pr(e,ClipboardEvent)?e:null),!0),We),r.registerCommand(Ro,e=>(async function(t,n){await ml(n,pr(t,ClipboardEvent)?t:null),n.update(()=>{const s=ae();V(s)?s.removeText():Ut(s)&&s.getNodes().forEach(i=>i.remove())})}(e,r),!0),We),r.registerCommand(si,e=>{const[,t,n]=fs(e);return t.length>0&&!n?(r.dispatchCommand(vl,t),!0):Wo(e.target)?!1:ae()!==null&&(function(s,i){s.preventDefault(),i.update(()=>{const o=ae(),a=pr(s,InputEvent)||pr(s,KeyboardEvent)?null:s.clipboardData;a!=null&&o!==null&&pl(a,o,i)},{tag:"paste"})}(e,r),!0)},We))}const fo=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Cl(r){return r.getEditorState().read(xc(r.isComposing()))}function Bp({contentEditable:r,placeholder:e=null,ErrorBoundary:t}){const[n]=zt(),s=function(i,o){const[a,l]=y.useState(()=>i.getDecorators());return fo(()=>i.registerDecoratorListener(u=>{ma.flushSync(()=>{l(u)})}),[i]),y.useEffect(()=>{l(i.getDecorators())},[i]),y.useMemo(()=>{const u=[],c=Object.keys(a);for(let d=0;d<c.length;d++){const h=c[d],p=f.jsx(o,{onError:m=>i._onError(m),children:f.jsx(y.Suspense,{fallback:null,children:a[h]})}),g=i.getElementByKey(h);g!==null&&u.push(ma.createPortal(p,g,h))}return u},[o,a,i])}(n,t);return function(i){fo(()=>Pr(Np(i),pp(i)),[i])}(n),f.jsxs(f.Fragment,{children:[r,f.jsx(jp,{content:e}),s]})}function jp({content:r}){const[e]=zt(),t=function(s){const[i,o]=y.useState(()=>Cl(s));return fo(()=>{function a(){const l=Cl(s);o(l)}return a(),Pr(s.registerUpdateListener(()=>{a()}),s.registerEditableListener(()=>{a()}))},[s]),i}(e),n=Qh();return t?typeof r=="function"?r(n):r:null}const Tc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Mp({editor:r,ariaActiveDescendant:e,ariaAutoComplete:t,ariaControls:n,ariaDescribedBy:s,ariaErrorMessage:i,ariaExpanded:o,ariaInvalid:a,ariaLabel:l,ariaLabelledBy:u,ariaMultiline:c,ariaOwns:d,ariaRequired:h,autoCapitalize:p,className:g,id:m,role:x="textbox",spellCheck:_=!0,style:b,tabIndex:S,"data-testid":C,...k},E){const[v,T]=y.useState(r.isEditable()),B=y.useCallback(N=>{N&&N.ownerDocument&&N.ownerDocument.defaultView?r.setRootElement(N):r.setRootElement(null)},[r]),j=y.useMemo(()=>function(...N){return R=>{N.forEach(M=>{typeof M=="function"?M(R):M!=null&&(M.current=R)})}}(E,B),[B,E]);return Tc(()=>(T(r.isEditable()),r.registerEditableListener(N=>{T(N)})),[r]),f.jsx("div",{"aria-activedescendant":v?e:void 0,"aria-autocomplete":v?t:"none","aria-controls":v?n:void 0,"aria-describedby":s,...i!=null?{"aria-errormessage":i}:{},"aria-expanded":v&&x==="combobox"?!!o:void 0,...a!=null?{"aria-invalid":a}:{},"aria-label":l,"aria-labelledby":u,"aria-multiline":c,"aria-owns":v?d:void 0,"aria-readonly":!v||void 0,"aria-required":h,autoCapitalize:p,className:g,contentEditable:v,"data-testid":C,id:m,ref:j,role:v?x:void 0,spellCheck:_,style:b,tabIndex:S,...k})}const Rp=y.forwardRef(Mp);function Sl(r){return r.getEditorState().read(xc(r.isComposing()))}const Fp=y.forwardRef(Lp);function Lp(r,e){const{placeholder:t,...n}=r,[s]=zt();return f.jsxs(f.Fragment,{children:[f.jsx(Rp,{editor:s,...n,ref:e}),t!=null&&f.jsx(Pp,{editor:s,content:t})]})}function Pp({content:r,editor:e}){const t=function(o){const[a,l]=y.useState(()=>Sl(o));return Tc(()=>{function u(){const c=Sl(o);l(c)}return u(),Pr(o.registerUpdateListener(()=>{u()}),o.registerEditableListener(()=>{u()}))},[o]),a}(e),[n,s]=y.useState(e.isEditable());if(y.useLayoutEffect(()=>(s(e.isEditable()),e.registerEditableListener(o=>{s(o)})),[e]),!t)return null;let i=null;return typeof r=="function"?i=r(n):r!==null&&(i=r),i===null?null:f.jsx("div",{"aria-hidden":!0,children:i})}const ps=0,ho=1,po=2,Rt=0,Ip=1,kl=2,zp=3,Op=4;function $p(r,e,t,n,s){if(r===null||t.size===0&&n.size===0&&!s)return Rt;const i=e._selection,o=r._selection;if(s)return Ip;if(!(V(i)&&V(o)&&o.isCollapsed()&&i.isCollapsed()))return Rt;const a=function(_,b,S){const C=_._nodeMap,k=[];for(const E of b){const v=C.get(E);v!==void 0&&k.push(v)}for(const[E,v]of S){if(!v)continue;const T=C.get(E);T===void 0||yt(T)||k.push(T)}return k}(e,t,n);if(a.length===0)return Rt;if(a.length>1){const _=e._nodeMap,b=_.get(i.anchor.key),S=_.get(o.anchor.key);return b&&S&&!r._nodeMap.has(b.__key)&&ee(b)&&b.__text.length===1&&i.anchor.offset===1?kl:Rt}const l=a[0],u=r._nodeMap.get(l.__key);if(!ee(u)||!ee(l)||u.__mode!==l.__mode)return Rt;const c=u.__text,d=l.__text;if(c===d)return Rt;const h=i.anchor,p=o.anchor;if(h.key!==p.key||h.type!=="text")return Rt;const g=h.offset,m=p.offset,x=d.length-c.length;return x===1&&m===g-1?kl:x===-1&&m===g+1?zp:x===-1&&m===g?Op:Rt}function qp(r,e){let t=Date.now(),n=Rt;return(s,i,o,a,l,u)=>{const c=Date.now();if(u.has("historic"))return n=Rt,t=c,po;const d=$p(s,i,a,l,r.isComposing()),h=(()=>{const p=o===null||o.editor===r,g=u.has("history-push");if(!g&&p&&u.has("history-merge"))return ps;if(s===null)return ho;const m=i._selection;return a.size>0||l.size>0?g===!1&&d!==Rt&&d===n&&c<t+e&&p||a.size===1&&function(x,_,b){const S=_._nodeMap.get(x),C=b._nodeMap.get(x),k=_._selection,E=b._selection;return!(V(k)&&V(E)&&k.anchor.type==="element"&&k.focus.type==="element"&&E.anchor.type==="text"&&E.focus.type==="text"||!ee(S)||!ee(C)||S.__parent!==C.__parent)&&JSON.stringify(_.read(()=>S.exportJSON()))===JSON.stringify(b.read(()=>C.exportJSON()))}(Array.from(a)[0],s,i)?ps:ho:m!==null?ps:po})();return t=c,n=d,h}}function El(r){r.undoStack=[],r.redoStack=[],r.current=null}function Up(r,e,t){const n=qp(r,t);return Pr(r.registerCommand(jo,()=>(function(i,o){const a=o.redoStack,l=o.undoStack;if(l.length!==0){const u=o.current,c=l.pop();u!==null&&(a.push(u),i.dispatchCommand(as,!0)),l.length===0&&i.dispatchCommand(ls,!1),o.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),We),r.registerCommand(Mo,()=>(function(i,o){const a=o.redoStack,l=o.undoStack;if(a.length!==0){const u=o.current;u!==null&&(l.push(u),i.dispatchCommand(ls,!0));const c=a.pop();a.length===0&&i.dispatchCommand(as,!1),o.current=c||null,c&&c.editor.setEditorState(c.editorState,{tag:"historic"})}}(r,e),!0),We),r.registerCommand(qf,()=>(El(e),!1),We),r.registerCommand(Uf,()=>(El(e),r.dispatchCommand(as,!1),r.dispatchCommand(ls,!1),!0),We),r.registerUpdateListener(({editorState:i,prevEditorState:o,dirtyLeaves:a,dirtyElements:l,tags:u})=>{const c=e.current,d=e.redoStack,h=e.undoStack,p=c===null?null:c.editorState;if(c!==null&&i===p)return;const g=n(o,i,c,a,l,u);if(g===ho)d.length!==0&&(e.redoStack=[],r.dispatchCommand(as,!1)),c!==null&&(h.push({...c}),r.dispatchCommand(ls,!0));else if(g===po)return;e.current={editor:r,editorState:i}}))}function Wp(){return{current:null,redoStack:[],undoStack:[]}}function Hp({delay:r,externalHistoryState:e}){const[t]=zt();return function(n,s,i=1e3){const o=y.useMemo(()=>s||Wp(),[s]);y.useEffect(()=>Up(n,o,i),[i,n,o])}(t,e,r),null}const Vp=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?y.useLayoutEffect:y.useEffect;function Gp({ignoreHistoryMergeTagChange:r=!0,ignoreSelectionChange:e=!1,onChange:t}){const[n]=zt();return Vp(()=>{if(t)return n.registerUpdateListener(({editorState:s,dirtyElements:i,dirtyLeaves:o,prevEditorState:a,tags:l})=>{e&&i.size===0&&o.size===0||r&&l.has("history-merge")||a.isEmpty()||t(s,n,l)})},[n,r,e,t]),null}function go(r,e){return go=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(t,n){return t.__proto__=n,t},go(r,e)}var Dl={error:null},Kp=function(r){var e,t;function n(){for(var i,o=arguments.length,a=new Array(o),l=0;l<o;l++)a[l]=arguments[l];return(i=r.call.apply(r,[this].concat(a))||this).state=Dl,i.resetErrorBoundary=function(){for(var u,c=arguments.length,d=new Array(c),h=0;h<c;h++)d[h]=arguments[h];i.props.onReset==null||(u=i.props).onReset.apply(u,d),i.reset()},i}t=r,(e=n).prototype=Object.create(t.prototype),e.prototype.constructor=e,go(e,t),n.getDerivedStateFromError=function(i){return{error:i}};var s=n.prototype;return s.reset=function(){this.setState(Dl)},s.componentDidCatch=function(i,o){var a,l;(a=(l=this.props).onError)==null||a.call(l,i,o)},s.componentDidUpdate=function(i,o){var a,l,u,c,d=this.state.error,h=this.props.resetKeys;d!==null&&o.error!==null&&((u=i.resetKeys)===void 0&&(u=[]),(c=h)===void 0&&(c=[]),u.length!==c.length||u.some(function(p,g){return!Object.is(p,c[g])}))&&((a=(l=this.props).onResetKeysChange)==null||a.call(l,i.resetKeys,h),this.reset())},s.render=function(){var i=this.state.error,o=this.props,a=o.fallbackRender,l=o.FallbackComponent,u=o.fallback;if(i!==null){var c={error:i,resetErrorBoundary:this.resetErrorBoundary};if(ki.isValidElement(u))return u;if(typeof a=="function")return a(c);if(l)return ki.createElement(l,c);throw new Error("react-error-boundary requires either a fallback, fallbackRender, or FallbackComponent prop")}return this.props.children},n}(ki.Component);function Yp({children:r,onError:e}){return f.jsx(Kp,{fallback:f.jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:e,children:r})}function Qp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Wt=Qp(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 Jp(r){let e=1,t=r.getParent();for(;t!=null;){if(tt(t)){const n=t.getParent();if($e(n)){e++,t=n.getParent();continue}Wt(40)}return e}return e}function mo(r){let e=r.getParent();$e(e)||Wt(40);let t=e;for(;t!==null;)t=t.getParent(),$e(t)&&(e=t);return e}function Nc(r){let e=[];const t=r.getChildren().filter(tt);for(let n=0;n<t.length;n++){const s=t[n],i=s.getFirstChild();$e(i)?e=e.concat(Nc(i)):e.push(s)}return e}function Ht(r){return tt(r)&&$e(r.getFirstChild())}function Al(r){return At().append(r)}function Bc(r,e){return tt(r)&&(e.length===0||e.length===1&&r.is(e[0])&&r.getChildrenSize()===0)}function Tl(r,e){r.update(()=>{const t=ae();if(t!==null){const n=t.getNodes();if(V(t)){const i=t.getStartEndPoints();i===null&&Wt(143);const[o]=i,a=o.getNode(),l=a.getParent();if(Bc(a,n)){const u=kt(e);if(Kt(l)){a.replace(u);const c=At();$(a)&&(c.setFormat(a.getFormatType()),c.setIndent(a.getIndent())),u.append(c)}else if(tt(a)){const c=a.getParentOrThrow();Rr(u,c.getChildren()),c.replace(u)}return}}const s=new Set;for(let i=0;i<n.length;i++){const o=n[i];if(!$(o)||!o.isEmpty()||tt(o)||s.has(o.getKey())){if(Fu(o)){let a=o.getParent();for(;a!=null;){const l=a.getKey();if($e(a)){if(!s.has(l)){const u=kt(e);Rr(u,a.getChildren()),a.replace(u),s.add(l)}break}{const u=a.getParent();if(Kt(u)&&!s.has(l)){s.add(l),Nl(a,e);break}a=u}}}}else Nl(o,e)}}})}function Rr(r,e){r.splice(r.getChildrenSize(),0,e)}function Nl(r,e){if($e(r))return r;const t=r.getPreviousSibling(),n=r.getNextSibling(),s=At();let i;if(Rr(s,r.getChildren()),$e(t)&&e===t.getListType())t.append(s),$e(n)&&e===n.getListType()&&(Rr(t,n.getChildren()),n.remove()),i=t;else if($e(n)&&e===n.getListType())n.getFirstChildOrThrow().insertBefore(s),i=n;else{const o=kt(e);o.append(s),r.replace(o),i=o}return s.setFormat(r.getFormatType()),s.setIndent(r.getIndent()),r.remove(),i}function oa(r,e){const t=r.getLastChild(),n=e.getFirstChild();t&&n&&Ht(t)&&Ht(n)&&(oa(t.getFirstChild(),n.getFirstChild()),n.remove());const s=e.getChildren();s.length>0&&r.append(...s),e.remove()}function Xp(r){r.update(()=>{const e=ae();if(V(e)){const t=new Set,n=e.getNodes(),s=e.anchor.getNode();if(Bc(s,n))t.add(mo(s));else for(let i=0;i<n.length;i++){const o=n[i];if(Fu(o)){const a=fp(o,Ir);a!=null&&t.add(mo(a))}}for(const i of t){let o=i;const a=Nc(i);for(const l of a){const u=ot();Rr(u,l.getChildren()),o.insertAfter(u),o=u,l.__key===e.anchor.key&&e.anchor.set(u.getKey(),0,"element"),l.__key===e.focus.key&&e.focus.set(u.getKey(),0,"element"),l.remove()}i.remove()}}})}function Zp(r){const e=new Set;if(Ht(r)||e.has(r.getKey()))return;const t=r.getParent(),n=r.getNextSibling(),s=r.getPreviousSibling();if(Ht(n)&&Ht(s)){const i=s.getFirstChild();if($e(i)){i.append(r);const o=n.getFirstChild();$e(o)&&(Rr(i,o.getChildren()),n.remove(),e.add(n.getKey()))}}else if(Ht(n)){const i=n.getFirstChild();if($e(i)){const o=i.getFirstChild();o!==null&&o.insertBefore(r)}}else if(Ht(s)){const i=s.getFirstChild();$e(i)&&i.append(r)}else if($e(t)){const i=At(),o=kt(t.getListType());i.append(o),o.append(r),s?s.insertAfter(i):n?n.insertBefore(i):t.append(i)}}function eg(r){if(Ht(r))return;const e=r.getParent(),t=e?e.getParent():void 0;if($e(t?t.getParent():void 0)&&tt(t)&&$e(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 i=e.getListType(),o=At(),a=kt(i);o.append(a),r.getPreviousSiblings().forEach(c=>a.append(c));const l=At(),u=kt(i);l.append(u),Rr(u,r.getNextSiblings()),t.insertBefore(o),t.insertAfter(l),t.replace(r)}}}function tg(){const r=ae();if(!V(r)||!r.isCollapsed())return!1;const e=r.anchor.getNode();if(!tt(e)||e.getChildrenSize()!==0)return!1;const t=mo(e),n=e.getParent();$e(n)||Wt(40);const s=n.getParent();let i;if(Kt(s))i=ot(),t.insertAfter(i);else{if(!tt(s))return!1;i=At(),s.insertAfter(i)}i.select();const o=e.getNextSiblings();if(o.length>0){const a=kt(n.getListType());if(tn(i))i.insertAfter(a);else{const l=At();l.append(a),i.insertAfter(l)}o.forEach(l=>{l.remove(),a.append(l)})}return function(a){let l=a;for(;l.getNextSibling()==null&&l.getPreviousSibling()==null;){const u=l.getParent();if(u==null||!tt(l)&&!$e(l))break;l=u}l.remove()}(e),!0}function Gs(...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 Ir extends ar{static getType(){return"listitem"}static clone(e){return new Ir(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 $e(n)&&n.getListType()==="check"&&jl(t,this,null),t.value=this.__value,Bl(t,e.theme,this),t}updateDOM(e,t,n){const s=this.getParent();return $e(s)&&s.getListType()==="check"&&jl(t,this,e),t.value=this.__value,Bl(t,n.theme,this),!1}static transform(){return e=>{if(tt(e)||Wt(144),e.__checked==null)return;const t=e.getParent();$e(t)&&t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:rg,priority:0})}}static importJSON(e){const t=At();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($(n)&&this.canMergeWith(n)){const s=n.getChildren();this.append(...s),n.remove()}else super.append(n)}return this}replace(e,t){if(tt(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!$e(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{const s=kt(n.getListType());let i=this.getNextSibling();for(;i;){const o=i;i=i.getNextSibling(),s.append(o)}n.insertAfter(e),e.insertAfter(s)}return t&&($(e)||Wt(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($e(n)||Wt(39),tt(e))return super.insertAfter(e,t);const s=this.getNextSiblings();if(n.insertAfter(e,t),s.length!==0){const i=kt(n.getListType());s.forEach(o=>i.append(o)),e.insertAfter(i,t)}return e}remove(e){const t=this.getPreviousSibling(),n=this.getNextSibling();super.remove(e),t&&n&&Ht(t)&&Ht(n)&&(oa(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){const n=At(this.__checked==null&&void 0);return this.insertAfter(n,t),n}collapseAtStart(e){const t=ot();this.getChildren().forEach(o=>t.append(o));const n=this.getParentOrThrow(),s=n.getParentOrThrow(),i=tt(s);if(n.getChildrenSize()===1)if(i)n.remove(),s.select();else{n.insertBefore(t),n.remove();const o=e.anchor,a=e.focus,l=t.getKey();o.type==="element"&&o.getNode().is(this)&&o.set(l,o.offset,"element"),a.type==="element"&&a.getNode().is(this)&&a.set(l,a.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 $e(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(;tt(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){typeof e!="number"&&Wt(117),(e=Math.floor(e))>=0||Wt(199);let t=this.getIndent();for(;t!==e;)t<e?(Zp(this),t++):(eg(this),t--);return this}canInsertAfter(e){return tt(e)}canReplaceWith(e){return tt(e)}canMergeWith(e){return tn(e)||tt(e)}extractWithChild(e,t){if(!V(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 kt("bullet")}canMergeWhenEmpty(){return!0}}function Bl(r,e,t){const n=[],s=[],i=e.list,o=i?i.listitem:void 0;let a;if(i&&i.nested&&(a=i.nested.listitem),o!==void 0&&n.push(...Gs(o)),i){const l=t.getParent(),u=$e(l)&&l.getListType()==="check",c=t.getChecked();u&&!c||s.push(i.listitemUnchecked),u&&c||s.push(i.listitemChecked),u&&n.push(c?i.listitemChecked:i.listitemUnchecked)}if(a!==void 0){const l=Gs(a);t.getChildren().some(u=>$e(u))?n.push(...l):s.push(...l)}s.length>0&&wc(r,...s),n.length>0&&rs(r,...n)}function jl(r,e,t,n){$e(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 rg(r){if(r.classList.contains("task-list-item")){for(const t of r.children)if(t.tagName==="INPUT")return ng(t)}const e=r.getAttribute("aria-checked");return{node:At(e==="true"||e!=="false"&&void 0)}}function ng(r){return r.getAttribute("type")!=="checkbox"?{node:null}:{node:At(r.hasAttribute("checked"))}}function At(r){return Qt(new Ir(void 0,r))}function tt(r){return r instanceof Ir}class ln extends ar{static getType(){return"list"}static clone(e){const t=e.__listType||Fl[e.__tag];return new ln(t,e.__start,e.__key)}constructor(e,t,n){super(n);const s=Fl[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,Ml(s,e.theme,this),s}updateDOM(e,t,n){return e.__tag!==this.__tag||(Ml(t,n.theme,this),!1)}static transform(){return e=>{$e(e)||Wt(163),function(t){const n=t.getNextSibling();$e(n)&&t.getListType()===n.getListType()&&oa(t,n)}(e),function(t){const n=t.getListType()!=="check";let s=t.getStart();for(const i of t.getChildren())tt(i)&&(i.getValue()!==s&&i.setValue(s),n&&i.getLatest().__checked!=null&&i.setChecked(void 0),$e(i.getFirstChild())||s++)}(e)}}static importDOM(){return{ol:()=>({conversion:Rl,priority:0}),ul:()=>({conversion:Rl,priority:0})}}static importJSON(e){const t=kt(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&&ir(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(tt(n))super.append(n);else{const s=At();if($e(n))s.append(n);else if($(n))if(n.isInline())s.append(n);else{const i=lt(n.getTextContent());s.append(i)}else s.append(n);super.append(s)}}return this}extractWithChild(e){return tt(e)}}function Ml(r,e,t){const n=[],s=[],i=e.list;if(i!==void 0){const o=i[`${t.__tag}Depth`]||[],a=Jp(t)-1,l=a%o.length,u=o[l],c=i[t.__tag];let d;const h=i.nested,p=i.checklist;if(h!==void 0&&h.list&&(d=h.list),c!==void 0&&n.push(c),p!==void 0&&t.__listType==="check"&&n.push(p),u!==void 0){n.push(...Gs(u));for(let g=0;g<o.length;g++)g!==l&&s.push(t.__tag+g)}if(d!==void 0){const g=Gs(d);a>1?n.push(...g):s.push(...g)}}s.length>0&&wc(r,...s),n.length>0&&rs(r,...n)}function sg(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t];if(tt(n)){e.push(n);const s=n.getChildren();s.length>1&&s.forEach(i=>{$e(i)&&e.push(Al(i))})}else e.push(Al(n))}return e}function Rl(r){const e=r.nodeName.toLowerCase();let t=null;return e==="ol"?t=kt("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(ir(s)&&s.hasAttribute("aria-checked"))return!0;return!1}(r)?kt("check"):kt("bullet")),{after:sg,node:t}}const Fl={ol:"number",ul:"bullet"};function kt(r,e=1){return Qt(new ln(r,e))}function $e(r){return r instanceof ln}const jc=Hn(),Mc=Hn(),ig=Hn();function og(r){return Pr(r.registerCommand(Mc,()=>(Tl(r,"number"),!0),Vr),r.registerCommand(jc,()=>(Tl(r,"bullet"),!0),Vr),r.registerCommand(ig,()=>(Xp(r),!0),Vr),r.registerCommand(Rn,()=>!!tg(),Vr))}function ag(){const[r]=zt();return y.useEffect(()=>{if(!r.hasNodes([ln,Ir]))throw new Error("ListPlugin: ListNode and/or ListItemNode not registered on editor")},[r]),function(e){y.useEffect(()=>og(e),[e])}(r),null}const lg=new Set(["http:","https:","mailto:","sms:","tel:"]);class zr extends ar{static getType(){return"link"}static clone(e){return new zr(e.__url,{rel:e.__rel,target:e.__target,title:e.__title},e.__key)}constructor(e,t={},n){super(n);const{target:s=null,rel:i=null,title:o=null}=t;this.__url=e,this.__target=s,this.__rel=i,this.__title=o}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),rs(t,e.theme.link),t}updateDOM(e,t,n){if(t instanceof HTMLAnchorElement){const s=this.__url,i=this.__target,o=this.__rel,a=this.__title;s!==e.__url&&(t.href=s),i!==e.__target&&(i?t.target=i:t.removeAttribute("target")),o!==e.__rel&&(o?t.rel=o:t.removeAttribute("rel")),a!==e.__title&&(a?t.title=a:t.removeAttribute("title"))}return!1}static importDOM(){return{a:e=>({conversion:ug,priority:1})}}static importJSON(e){const t=Ks(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(!lg.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=Ks(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(!V(t))return!1;const s=t.anchor.getNode(),i=t.focus.getNode();return this.isParentOf(s)&&this.isParentOf(i)&&t.getTextContent().length>0}isEmailURI(){return this.__url.startsWith("mailto:")}isWebSiteURI(){return this.__url.startsWith("https://")||this.__url.startsWith("http://")}}function ug(r){let e=null;if(_h(r)){const t=r.textContent;(t!==null&&t!==""||r.children.length>0)&&(e=Ks(r.getAttribute("href")||"",{rel:r.getAttribute("rel"),target:r.getAttribute("target"),title:r.getAttribute("title")}))}return{node:e}}function Ks(r,e){return Qt(new zr(r,e))}function mn(r){return r instanceof zr}class ns extends zr{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 ns(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=Ll(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($(n)){const s=Ll(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return n.append(s),s}return null}}function Ll(r,e){return Qt(new ns(r,e))}function cg(r){return r instanceof ns}const Pl=Hn();function $i(r,e={}){const{target:t,title:n}=e,s=e.rel===void 0?"noreferrer":e.rel,i=ae();if(!V(i))return;const o=i.extract();if(r===null)o.forEach(a=>{const l=yi(a,u=>!cg(u)&&mn(u));if(l){const u=l.getChildren();for(let c=0;c<u.length;c++)l.insertBefore(u[c]);l.remove()}});else{if(o.length===1){const u=function(c,d){let h=c;for(;h!==null&&h.getParent()!==null&&!d(h);)h=h.getParentOrThrow();return d(h)?h:null}(o[0],mn);if(u!==null)return u.setURL(r),t!==void 0&&u.setTarget(t),s!==null&&u.setRel(s),void(n!==void 0&&u.setTitle(n))}let a=null,l=null;o.forEach(u=>{const c=u.getParent();if(c!==l&&c!==null&&(!$(u)||u.isInline())){if(mn(c))return l=c,c.setURL(r),t!==void 0&&c.setTarget(t),s!==null&&l.setRel(s),void(n!==void 0&&l.setTitle(n));if(c.is(a)||(a=c,l=Ks(r,{rel:s,target:t,title:n}),mn(c)?u.getPreviousSibling()===null?c.insertBefore(l):c.insertAfter(l):u.insertBefore(l)),mn(u)){if(u.is(l))return;if(l!==null){const d=u.getChildren();for(let h=0;h<d.length;h++)l.append(d[h])}u.remove()}else l!==null&&l.append(u)}})}}function dg({validateUrl:r,attributes:e}){const[t]=zt();return y.useEffect(()=>{if(!t.hasNodes([zr]))throw new Error("LinkPlugin: LinkNode not registered on editor");return Pr(t.registerCommand(Pl,n=>{if(n===null)return $i(n),!0;if(typeof n=="string")return!(r!==void 0&&!r(n))&&($i(n,e),!0);{const{url:s,target:i,rel:o,title:a}=n;return $i(s,{...e,rel:o,target:i,title:a}),!0}},Vr),r!==void 0?t.registerCommand(si,n=>{const s=ae();if(!V(s)||s.isCollapsed()||!pr(n,ClipboardEvent))return!1;const i=n;if(i.clipboardData===null)return!1;const o=i.clipboardData.getData("text");return!!r(o)&&!s.getNodes().some(a=>$(a))&&(t.dispatchCommand(Pl,{...e,url:o}),n.preventDefault(),!0)},Vr):()=>{})},[t,r,e]),null}function fg(r){if(r instanceof HTMLImageElement){const e=r.getAttribute("src")||"",t=r.getAttribute("alt")||"",n=r.getAttribute("width"),s=r.getAttribute("height");return{node:Rc({src:e,altText:t,width:n?parseInt(n,10):void 0,height:s?parseInt(s,10):void 0})}}return null}function hg({src:r,alt:e,width:t,height:n}){return f.jsx("img",{src:r,alt:e,width:t,height:n,style:{maxWidth:"100%",height:"auto",display:"block",margin:"8px 0",borderRadius:"4px"}})}class vi extends ra{constructor(t,n,s,i,o){super(o);_t(this,"__src");_t(this,"__altText");_t(this,"__width");_t(this,"__height");this.__src=t,this.__altText=n||"",this.__width=s,this.__height=i}static getType(){return"image"}static clone(t){return new vi(t.__src,t.__altText,t.__width,t.__height,t.__key)}static importJSON(t){const{src:n,altText:s,width:i,height:o}=t;return Rc({src:n,altText:s,width:i,height:o})}exportJSON(){return{type:"image",version:1,src:this.__src,altText:this.__altText,width:this.__width,height:this.__height}}static importDOM(){return{img:()=>({conversion:fg,priority:0})}}exportDOM(){const t=document.createElement("img");return t.setAttribute("src",this.__src),this.__altText&&t.setAttribute("alt",this.__altText),this.__width&&t.setAttribute("width",String(this.__width)),this.__height&&t.setAttribute("height",String(this.__height)),t.style.maxWidth="100%",t.style.height="auto",{element:t}}createDOM(){const t=document.createElement("span");return t.style.display="inline-block",t}updateDOM(){return!1}decorate(){return f.jsx(hg,{src:this.__src,alt:this.__altText,width:this.__width,height:this.__height})}}function Rc(r){return new vi(r.src,r.altText,r.width,r.height)}var pg=Object.defineProperty,Ys=Object.getOwnPropertySymbols,Fc=Object.prototype.hasOwnProperty,Lc=Object.prototype.propertyIsEnumerable,Il=(r,e,t)=>e in r?pg(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,yo=(r,e)=>{for(var t in e||(e={}))Fc.call(e,t)&&Il(r,t,e[t]);if(Ys)for(var t of Ys(e))Lc.call(e,t)&&Il(r,t,e[t]);return r},xo=(r,e)=>{var t={};for(var n in r)Fc.call(r,n)&&e.indexOf(n)<0&&(t[n]=r[n]);if(r!=null&&Ys)for(var n of Ys(r))e.indexOf(n)<0&&Lc.call(r,n)&&(t[n]=r[n]);return t};/**
96
96
  * @license QR Code generator library (TypeScript)
97
97
  * Copyright (c) Project Nayuki.
98
98
  * SPDX-License-Identifier: MIT
99
- */var Fr;(r=>{const e=class Le{constructor(a,u,c,d){if(this.version=a,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],a<Le.MIN_VERSION||a>Le.MAX_VERSION)throw new RangeError("Version value out of range");if(d<-1||d>7)throw new RangeError("Mask value out of range");this.size=a*4+17;let h=[];for(let g=0;g<this.size;g++)h.push(!1);for(let g=0;g<this.size;g++)this.modules.push(h.slice()),this.isFunction.push(h.slice());this.drawFunctionPatterns();const p=this.addEccAndInterleave(c);if(this.drawCodewords(p),d==-1){let g=1e9;for(let m=0;m<8;m++){this.applyMask(m),this.drawFormatBits(m);const x=this.getPenaltyScore();x<g&&(d=m,g=x),this.applyMask(m)}}s(0<=d&&d<=7),this.mask=d,this.applyMask(d),this.drawFormatBits(d),this.isFunction=[]}static encodeText(a,u){const c=r.QrSegment.makeSegments(a);return Le.encodeSegments(c,u)}static encodeBinary(a,u){const c=r.QrSegment.makeBytes(a);return Le.encodeSegments([c],u)}static encodeSegments(a,u,c=1,d=40,h=-1,p=!0){if(!(Le.MIN_VERSION<=c&&c<=d&&d<=Le.MAX_VERSION)||h<-1||h>7)throw new RangeError("Invalid value");let g,m;for(g=c;;g++){const C=Le.getNumDataCodewords(g,u)*8,S=o.getTotalBits(a,g);if(S<=C){m=S;break}if(g>=d)throw new RangeError("Data too long")}for(const C of[Le.Ecc.MEDIUM,Le.Ecc.QUARTILE,Le.Ecc.HIGH])p&&m<=Le.getNumDataCodewords(g,C)*8&&(u=C);let x=[];for(const C of a){t(C.mode.modeBits,4,x),t(C.numChars,C.mode.numCharCountBits(g),x);for(const S of C.getData())x.push(S)}s(x.length==m);const _=Le.getNumDataCodewords(g,u)*8;s(x.length<=_),t(0,Math.min(4,_-x.length),x),t(0,(8-x.length%8)%8,x),s(x.length%8==0);for(let C=236;x.length<_;C^=253)t(C,8,x);let b=[];for(;b.length*8<x.length;)b.push(0);return x.forEach((C,S)=>b[S>>>3]|=C<<7-(S&7)),new Le(g,u,b,h)}getModule(a,u){return 0<=a&&a<this.size&&0<=u&&u<this.size&&this.modules[u][a]}getModules(){return this.modules}drawFunctionPatterns(){for(let c=0;c<this.size;c++)this.setFunctionModule(6,c,c%2==0),this.setFunctionModule(c,6,c%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const a=this.getAlignmentPatternPositions(),u=a.length;for(let c=0;c<u;c++)for(let d=0;d<u;d++)c==0&&d==0||c==0&&d==u-1||c==u-1&&d==0||this.drawAlignmentPattern(a[c],a[d]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(a){const u=this.errorCorrectionLevel.formatBits<<3|a;let c=u;for(let h=0;h<10;h++)c=c<<1^(c>>>9)*1335;const d=(u<<10|c)^21522;s(d>>>15==0);for(let h=0;h<=5;h++)this.setFunctionModule(8,h,n(d,h));this.setFunctionModule(8,7,n(d,6)),this.setFunctionModule(8,8,n(d,7)),this.setFunctionModule(7,8,n(d,8));for(let h=9;h<15;h++)this.setFunctionModule(14-h,8,n(d,h));for(let h=0;h<8;h++)this.setFunctionModule(this.size-1-h,8,n(d,h));for(let h=8;h<15;h++)this.setFunctionModule(8,this.size-15+h,n(d,h));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let a=this.version;for(let c=0;c<12;c++)a=a<<1^(a>>>11)*7973;const u=this.version<<12|a;s(u>>>18==0);for(let c=0;c<18;c++){const d=n(u,c),h=this.size-11+c%3,p=Math.floor(c/3);this.setFunctionModule(h,p,d),this.setFunctionModule(p,h,d)}}drawFinderPattern(a,u){for(let c=-4;c<=4;c++)for(let d=-4;d<=4;d++){const h=Math.max(Math.abs(d),Math.abs(c)),p=a+d,g=u+c;0<=p&&p<this.size&&0<=g&&g<this.size&&this.setFunctionModule(p,g,h!=2&&h!=4)}}drawAlignmentPattern(a,u){for(let c=-2;c<=2;c++)for(let d=-2;d<=2;d++)this.setFunctionModule(a+d,u+c,Math.max(Math.abs(d),Math.abs(c))!=1)}setFunctionModule(a,u,c){this.modules[u][a]=c,this.isFunction[u][a]=!0}addEccAndInterleave(a){const u=this.version,c=this.errorCorrectionLevel;if(a.length!=Le.getNumDataCodewords(u,c))throw new RangeError("Invalid argument");const d=Le.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][u],h=Le.ECC_CODEWORDS_PER_BLOCK[c.ordinal][u],p=Math.floor(Le.getNumRawDataModules(u)/8),g=d-p%d,m=Math.floor(p/d);let x=[];const _=Le.reedSolomonComputeDivisor(h);for(let C=0,S=0;C<d;C++){let k=a.slice(S,S+m-h+(C<g?0:1));S+=k.length;const E=Le.reedSolomonComputeRemainder(k,_);C<g&&k.push(0),x.push(k.concat(E))}let b=[];for(let C=0;C<x[0].length;C++)x.forEach((S,k)=>{(C!=m-h||k>=g)&&b.push(S[C])});return s(b.length==p),b}drawCodewords(a){if(a.length!=Math.floor(Le.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let u=0;for(let c=this.size-1;c>=1;c-=2){c==6&&(c=5);for(let d=0;d<this.size;d++)for(let h=0;h<2;h++){const p=c-h,m=(c+1&2)==0?this.size-1-d:d;!this.isFunction[m][p]&&u<a.length*8&&(this.modules[m][p]=n(a[u>>>3],7-(u&7)),u++)}}s(u==a.length*8)}applyMask(a){if(a<0||a>7)throw new RangeError("Mask value out of range");for(let u=0;u<this.size;u++)for(let c=0;c<this.size;c++){let d;switch(a){case 0:d=(c+u)%2==0;break;case 1:d=u%2==0;break;case 2:d=c%3==0;break;case 3:d=(c+u)%3==0;break;case 4:d=(Math.floor(c/3)+Math.floor(u/2))%2==0;break;case 5:d=c*u%2+c*u%3==0;break;case 6:d=(c*u%2+c*u%3)%2==0;break;case 7:d=((c+u)%2+c*u%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[u][c]&&d&&(this.modules[u][c]=!this.modules[u][c])}}getPenaltyScore(){let a=0;for(let h=0;h<this.size;h++){let p=!1,g=0,m=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[h][x]==p?(g++,g==5?a+=Le.PENALTY_N1:g>5&&a++):(this.finderPenaltyAddHistory(g,m),p||(a+=this.finderPenaltyCountPatterns(m)*Le.PENALTY_N3),p=this.modules[h][x],g=1);a+=this.finderPenaltyTerminateAndCount(p,g,m)*Le.PENALTY_N3}for(let h=0;h<this.size;h++){let p=!1,g=0,m=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[x][h]==p?(g++,g==5?a+=Le.PENALTY_N1:g>5&&a++):(this.finderPenaltyAddHistory(g,m),p||(a+=this.finderPenaltyCountPatterns(m)*Le.PENALTY_N3),p=this.modules[x][h],g=1);a+=this.finderPenaltyTerminateAndCount(p,g,m)*Le.PENALTY_N3}for(let h=0;h<this.size-1;h++)for(let p=0;p<this.size-1;p++){const g=this.modules[h][p];g==this.modules[h][p+1]&&g==this.modules[h+1][p]&&g==this.modules[h+1][p+1]&&(a+=Le.PENALTY_N2)}let u=0;for(const h of this.modules)u=h.reduce((p,g)=>p+(g?1:0),u);const c=this.size*this.size,d=Math.ceil(Math.abs(u*20-c*10)/c)-1;return s(0<=d&&d<=9),a+=d*Le.PENALTY_N4,s(0<=a&&a<=2568888),a}getAlignmentPatternPositions(){if(this.version==1)return[];{const a=Math.floor(this.version/7)+2,u=this.version==32?26:Math.ceil((this.version*4+4)/(a*2-2))*2;let c=[6];for(let d=this.size-7;c.length<a;d-=u)c.splice(1,0,d);return c}}static getNumRawDataModules(a){if(a<Le.MIN_VERSION||a>Le.MAX_VERSION)throw new RangeError("Version number out of range");let u=(16*a+128)*a+64;if(a>=2){const c=Math.floor(a/7)+2;u-=(25*c-10)*c-55,a>=7&&(u-=36)}return s(208<=u&&u<=29648),u}static getNumDataCodewords(a,u){return Math.floor(Le.getNumRawDataModules(a)/8)-Le.ECC_CODEWORDS_PER_BLOCK[u.ordinal][a]*Le.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][a]}static reedSolomonComputeDivisor(a){if(a<1||a>255)throw new RangeError("Degree out of range");let u=[];for(let d=0;d<a-1;d++)u.push(0);u.push(1);let c=1;for(let d=0;d<a;d++){for(let h=0;h<u.length;h++)u[h]=Le.reedSolomonMultiply(u[h],c),h+1<u.length&&(u[h]^=u[h+1]);c=Le.reedSolomonMultiply(c,2)}return u}static reedSolomonComputeRemainder(a,u){let c=u.map(d=>0);for(const d of a){const h=d^c.shift();c.push(0),u.forEach((p,g)=>c[g]^=Le.reedSolomonMultiply(p,h))}return c}static reedSolomonMultiply(a,u){if(a>>>8||u>>>8)throw new RangeError("Byte out of range");let c=0;for(let d=7;d>=0;d--)c=c<<1^(c>>>7)*285,c^=(u>>>d&1)*a;return s(c>>>8==0),c}finderPenaltyCountPatterns(a){const u=a[1];s(u<=this.size*3);const c=u>0&&a[2]==u&&a[3]==u*3&&a[4]==u&&a[5]==u;return(c&&a[0]>=u*4&&a[6]>=u?1:0)+(c&&a[6]>=u*4&&a[0]>=u?1:0)}finderPenaltyTerminateAndCount(a,u,c){return a&&(this.finderPenaltyAddHistory(u,c),u=0),u+=this.size,this.finderPenaltyAddHistory(u,c),this.finderPenaltyCountPatterns(c)}finderPenaltyAddHistory(a,u){u[0]==0&&(a+=this.size),u.pop(),u.unshift(a)}};e.MIN_VERSION=1,e.MAX_VERSION=40,e.PENALTY_N1=3,e.PENALTY_N2=3,e.PENALTY_N3=40,e.PENALTY_N4=10,e.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],e.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],r.QrCode=e;function t(l,a,u){if(a<0||a>31||l>>>a)throw new RangeError("Value out of range");for(let c=a-1;c>=0;c--)u.push(l>>>c&1)}function n(l,a){return(l>>>a&1)!=0}function s(l){if(!l)throw new Error("Assertion error")}const i=class tt{constructor(a,u,c){if(this.mode=a,this.numChars=u,this.bitData=c,u<0)throw new RangeError("Invalid argument");this.bitData=c.slice()}static makeBytes(a){let u=[];for(const c of a)t(c,8,u);return new tt(tt.Mode.BYTE,a.length,u)}static makeNumeric(a){if(!tt.isNumeric(a))throw new RangeError("String contains non-numeric characters");let u=[];for(let c=0;c<a.length;){const d=Math.min(a.length-c,3);t(parseInt(a.substring(c,c+d),10),d*3+1,u),c+=d}return new tt(tt.Mode.NUMERIC,a.length,u)}static makeAlphanumeric(a){if(!tt.isAlphanumeric(a))throw new RangeError("String contains unencodable characters in alphanumeric mode");let u=[],c;for(c=0;c+2<=a.length;c+=2){let d=tt.ALPHANUMERIC_CHARSET.indexOf(a.charAt(c))*45;d+=tt.ALPHANUMERIC_CHARSET.indexOf(a.charAt(c+1)),t(d,11,u)}return c<a.length&&t(tt.ALPHANUMERIC_CHARSET.indexOf(a.charAt(c)),6,u),new tt(tt.Mode.ALPHANUMERIC,a.length,u)}static makeSegments(a){return a==""?[]:tt.isNumeric(a)?[tt.makeNumeric(a)]:tt.isAlphanumeric(a)?[tt.makeAlphanumeric(a)]:[tt.makeBytes(tt.toUtf8ByteArray(a))]}static makeEci(a){let u=[];if(a<0)throw new RangeError("ECI assignment value out of range");if(a<128)t(a,8,u);else if(a<16384)t(2,2,u),t(a,14,u);else if(a<1e6)t(6,3,u),t(a,21,u);else throw new RangeError("ECI assignment value out of range");return new tt(tt.Mode.ECI,0,u)}static isNumeric(a){return tt.NUMERIC_REGEX.test(a)}static isAlphanumeric(a){return tt.ALPHANUMERIC_REGEX.test(a)}getData(){return this.bitData.slice()}static getTotalBits(a,u){let c=0;for(const d of a){const h=d.mode.numCharCountBits(u);if(d.numChars>=1<<h)return 1/0;c+=4+h+d.bitData.length}return c}static toUtf8ByteArray(a){a=encodeURI(a);let u=[];for(let c=0;c<a.length;c++)a.charAt(c)!="%"?u.push(a.charCodeAt(c)):(u.push(parseInt(a.substring(c+1,c+3),16)),c+=2);return u}};i.NUMERIC_REGEX=/^[0-9]*$/,i.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,i.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let o=i;r.QrSegment=i})(Fr||(Fr={}));(r=>{(e=>{const t=class{constructor(s,i){this.ordinal=s,this.formatBits=i}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(r.QrCode||(r.QrCode={}))})(Fr||(Fr={}));(r=>{(e=>{const t=class{constructor(s,i){this.modeBits=s,this.numBitsCharCount=i}numCharCountBits(s){return this.numBitsCharCount[Math.floor((s+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(r.QrSegment||(r.QrSegment={}))})(Fr||(Fr={}));var Gr=Fr;/**
99
+ */var Fr;(r=>{const e=class Ie{constructor(l,u,c,d){if(this.version=l,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],l<Ie.MIN_VERSION||l>Ie.MAX_VERSION)throw new RangeError("Version value out of range");if(d<-1||d>7)throw new RangeError("Mask value out of range");this.size=l*4+17;let h=[];for(let g=0;g<this.size;g++)h.push(!1);for(let g=0;g<this.size;g++)this.modules.push(h.slice()),this.isFunction.push(h.slice());this.drawFunctionPatterns();const p=this.addEccAndInterleave(c);if(this.drawCodewords(p),d==-1){let g=1e9;for(let m=0;m<8;m++){this.applyMask(m),this.drawFormatBits(m);const x=this.getPenaltyScore();x<g&&(d=m,g=x),this.applyMask(m)}}s(0<=d&&d<=7),this.mask=d,this.applyMask(d),this.drawFormatBits(d),this.isFunction=[]}static encodeText(l,u){const c=r.QrSegment.makeSegments(l);return Ie.encodeSegments(c,u)}static encodeBinary(l,u){const c=r.QrSegment.makeBytes(l);return Ie.encodeSegments([c],u)}static encodeSegments(l,u,c=1,d=40,h=-1,p=!0){if(!(Ie.MIN_VERSION<=c&&c<=d&&d<=Ie.MAX_VERSION)||h<-1||h>7)throw new RangeError("Invalid value");let g,m;for(g=c;;g++){const S=Ie.getNumDataCodewords(g,u)*8,C=o.getTotalBits(l,g);if(C<=S){m=C;break}if(g>=d)throw new RangeError("Data too long")}for(const S of[Ie.Ecc.MEDIUM,Ie.Ecc.QUARTILE,Ie.Ecc.HIGH])p&&m<=Ie.getNumDataCodewords(g,S)*8&&(u=S);let x=[];for(const S of l){t(S.mode.modeBits,4,x),t(S.numChars,S.mode.numCharCountBits(g),x);for(const C of S.getData())x.push(C)}s(x.length==m);const _=Ie.getNumDataCodewords(g,u)*8;s(x.length<=_),t(0,Math.min(4,_-x.length),x),t(0,(8-x.length%8)%8,x),s(x.length%8==0);for(let S=236;x.length<_;S^=253)t(S,8,x);let b=[];for(;b.length*8<x.length;)b.push(0);return x.forEach((S,C)=>b[C>>>3]|=S<<7-(C&7)),new Ie(g,u,b,h)}getModule(l,u){return 0<=l&&l<this.size&&0<=u&&u<this.size&&this.modules[u][l]}getModules(){return this.modules}drawFunctionPatterns(){for(let c=0;c<this.size;c++)this.setFunctionModule(6,c,c%2==0),this.setFunctionModule(c,6,c%2==0);this.drawFinderPattern(3,3),this.drawFinderPattern(this.size-4,3),this.drawFinderPattern(3,this.size-4);const l=this.getAlignmentPatternPositions(),u=l.length;for(let c=0;c<u;c++)for(let d=0;d<u;d++)c==0&&d==0||c==0&&d==u-1||c==u-1&&d==0||this.drawAlignmentPattern(l[c],l[d]);this.drawFormatBits(0),this.drawVersion()}drawFormatBits(l){const u=this.errorCorrectionLevel.formatBits<<3|l;let c=u;for(let h=0;h<10;h++)c=c<<1^(c>>>9)*1335;const d=(u<<10|c)^21522;s(d>>>15==0);for(let h=0;h<=5;h++)this.setFunctionModule(8,h,n(d,h));this.setFunctionModule(8,7,n(d,6)),this.setFunctionModule(8,8,n(d,7)),this.setFunctionModule(7,8,n(d,8));for(let h=9;h<15;h++)this.setFunctionModule(14-h,8,n(d,h));for(let h=0;h<8;h++)this.setFunctionModule(this.size-1-h,8,n(d,h));for(let h=8;h<15;h++)this.setFunctionModule(8,this.size-15+h,n(d,h));this.setFunctionModule(8,this.size-8,!0)}drawVersion(){if(this.version<7)return;let l=this.version;for(let c=0;c<12;c++)l=l<<1^(l>>>11)*7973;const u=this.version<<12|l;s(u>>>18==0);for(let c=0;c<18;c++){const d=n(u,c),h=this.size-11+c%3,p=Math.floor(c/3);this.setFunctionModule(h,p,d),this.setFunctionModule(p,h,d)}}drawFinderPattern(l,u){for(let c=-4;c<=4;c++)for(let d=-4;d<=4;d++){const h=Math.max(Math.abs(d),Math.abs(c)),p=l+d,g=u+c;0<=p&&p<this.size&&0<=g&&g<this.size&&this.setFunctionModule(p,g,h!=2&&h!=4)}}drawAlignmentPattern(l,u){for(let c=-2;c<=2;c++)for(let d=-2;d<=2;d++)this.setFunctionModule(l+d,u+c,Math.max(Math.abs(d),Math.abs(c))!=1)}setFunctionModule(l,u,c){this.modules[u][l]=c,this.isFunction[u][l]=!0}addEccAndInterleave(l){const u=this.version,c=this.errorCorrectionLevel;if(l.length!=Ie.getNumDataCodewords(u,c))throw new RangeError("Invalid argument");const d=Ie.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][u],h=Ie.ECC_CODEWORDS_PER_BLOCK[c.ordinal][u],p=Math.floor(Ie.getNumRawDataModules(u)/8),g=d-p%d,m=Math.floor(p/d);let x=[];const _=Ie.reedSolomonComputeDivisor(h);for(let S=0,C=0;S<d;S++){let k=l.slice(C,C+m-h+(S<g?0:1));C+=k.length;const E=Ie.reedSolomonComputeRemainder(k,_);S<g&&k.push(0),x.push(k.concat(E))}let b=[];for(let S=0;S<x[0].length;S++)x.forEach((C,k)=>{(S!=m-h||k>=g)&&b.push(C[S])});return s(b.length==p),b}drawCodewords(l){if(l.length!=Math.floor(Ie.getNumRawDataModules(this.version)/8))throw new RangeError("Invalid argument");let u=0;for(let c=this.size-1;c>=1;c-=2){c==6&&(c=5);for(let d=0;d<this.size;d++)for(let h=0;h<2;h++){const p=c-h,m=(c+1&2)==0?this.size-1-d:d;!this.isFunction[m][p]&&u<l.length*8&&(this.modules[m][p]=n(l[u>>>3],7-(u&7)),u++)}}s(u==l.length*8)}applyMask(l){if(l<0||l>7)throw new RangeError("Mask value out of range");for(let u=0;u<this.size;u++)for(let c=0;c<this.size;c++){let d;switch(l){case 0:d=(c+u)%2==0;break;case 1:d=u%2==0;break;case 2:d=c%3==0;break;case 3:d=(c+u)%3==0;break;case 4:d=(Math.floor(c/3)+Math.floor(u/2))%2==0;break;case 5:d=c*u%2+c*u%3==0;break;case 6:d=(c*u%2+c*u%3)%2==0;break;case 7:d=((c+u)%2+c*u%3)%2==0;break;default:throw new Error("Unreachable")}!this.isFunction[u][c]&&d&&(this.modules[u][c]=!this.modules[u][c])}}getPenaltyScore(){let l=0;for(let h=0;h<this.size;h++){let p=!1,g=0,m=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[h][x]==p?(g++,g==5?l+=Ie.PENALTY_N1:g>5&&l++):(this.finderPenaltyAddHistory(g,m),p||(l+=this.finderPenaltyCountPatterns(m)*Ie.PENALTY_N3),p=this.modules[h][x],g=1);l+=this.finderPenaltyTerminateAndCount(p,g,m)*Ie.PENALTY_N3}for(let h=0;h<this.size;h++){let p=!1,g=0,m=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[x][h]==p?(g++,g==5?l+=Ie.PENALTY_N1:g>5&&l++):(this.finderPenaltyAddHistory(g,m),p||(l+=this.finderPenaltyCountPatterns(m)*Ie.PENALTY_N3),p=this.modules[x][h],g=1);l+=this.finderPenaltyTerminateAndCount(p,g,m)*Ie.PENALTY_N3}for(let h=0;h<this.size-1;h++)for(let p=0;p<this.size-1;p++){const g=this.modules[h][p];g==this.modules[h][p+1]&&g==this.modules[h+1][p]&&g==this.modules[h+1][p+1]&&(l+=Ie.PENALTY_N2)}let u=0;for(const h of this.modules)u=h.reduce((p,g)=>p+(g?1:0),u);const c=this.size*this.size,d=Math.ceil(Math.abs(u*20-c*10)/c)-1;return s(0<=d&&d<=9),l+=d*Ie.PENALTY_N4,s(0<=l&&l<=2568888),l}getAlignmentPatternPositions(){if(this.version==1)return[];{const l=Math.floor(this.version/7)+2,u=this.version==32?26:Math.ceil((this.version*4+4)/(l*2-2))*2;let c=[6];for(let d=this.size-7;c.length<l;d-=u)c.splice(1,0,d);return c}}static getNumRawDataModules(l){if(l<Ie.MIN_VERSION||l>Ie.MAX_VERSION)throw new RangeError("Version number out of range");let u=(16*l+128)*l+64;if(l>=2){const c=Math.floor(l/7)+2;u-=(25*c-10)*c-55,l>=7&&(u-=36)}return s(208<=u&&u<=29648),u}static getNumDataCodewords(l,u){return Math.floor(Ie.getNumRawDataModules(l)/8)-Ie.ECC_CODEWORDS_PER_BLOCK[u.ordinal][l]*Ie.NUM_ERROR_CORRECTION_BLOCKS[u.ordinal][l]}static reedSolomonComputeDivisor(l){if(l<1||l>255)throw new RangeError("Degree out of range");let u=[];for(let d=0;d<l-1;d++)u.push(0);u.push(1);let c=1;for(let d=0;d<l;d++){for(let h=0;h<u.length;h++)u[h]=Ie.reedSolomonMultiply(u[h],c),h+1<u.length&&(u[h]^=u[h+1]);c=Ie.reedSolomonMultiply(c,2)}return u}static reedSolomonComputeRemainder(l,u){let c=u.map(d=>0);for(const d of l){const h=d^c.shift();c.push(0),u.forEach((p,g)=>c[g]^=Ie.reedSolomonMultiply(p,h))}return c}static reedSolomonMultiply(l,u){if(l>>>8||u>>>8)throw new RangeError("Byte out of range");let c=0;for(let d=7;d>=0;d--)c=c<<1^(c>>>7)*285,c^=(u>>>d&1)*l;return s(c>>>8==0),c}finderPenaltyCountPatterns(l){const u=l[1];s(u<=this.size*3);const c=u>0&&l[2]==u&&l[3]==u*3&&l[4]==u&&l[5]==u;return(c&&l[0]>=u*4&&l[6]>=u?1:0)+(c&&l[6]>=u*4&&l[0]>=u?1:0)}finderPenaltyTerminateAndCount(l,u,c){return l&&(this.finderPenaltyAddHistory(u,c),u=0),u+=this.size,this.finderPenaltyAddHistory(u,c),this.finderPenaltyCountPatterns(c)}finderPenaltyAddHistory(l,u){u[0]==0&&(l+=this.size),u.pop(),u.unshift(l)}};e.MIN_VERSION=1,e.MAX_VERSION=40,e.PENALTY_N1=3,e.PENALTY_N2=3,e.PENALTY_N3=40,e.PENALTY_N4=10,e.ECC_CODEWORDS_PER_BLOCK=[[-1,7,10,15,20,26,18,20,24,30,18,20,24,26,30,22,24,28,30,28,28,28,28,30,30,26,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,10,16,26,18,24,16,18,22,22,26,30,22,22,24,24,28,28,26,26,26,26,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28,28],[-1,13,22,18,26,18,24,18,22,20,24,28,26,24,20,30,24,28,28,26,30,28,30,30,30,30,28,30,30,30,30,30,30,30,30,30,30,30,30,30,30],[-1,17,28,22,16,22,28,26,26,24,28,24,28,22,24,24,30,28,28,26,28,30,24,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30,30]],e.NUM_ERROR_CORRECTION_BLOCKS=[[-1,1,1,1,1,1,2,2,2,2,4,4,4,4,4,6,6,6,6,7,8,8,9,9,10,12,12,12,13,14,15,16,17,18,19,19,20,21,22,24,25],[-1,1,1,1,2,2,4,4,4,5,5,5,8,9,9,10,10,11,13,14,16,17,17,18,20,21,23,25,26,28,29,31,33,35,37,38,40,43,45,47,49],[-1,1,1,2,2,4,4,6,6,8,8,8,10,12,16,12,17,16,18,21,20,23,23,25,27,29,34,34,35,38,40,43,45,48,51,53,56,59,62,65,68],[-1,1,1,2,4,4,4,5,6,8,8,11,11,16,16,18,16,19,21,25,25,25,34,30,32,35,37,40,42,45,48,51,54,57,60,63,66,70,74,77,81]],r.QrCode=e;function t(a,l,u){if(l<0||l>31||a>>>l)throw new RangeError("Value out of range");for(let c=l-1;c>=0;c--)u.push(a>>>c&1)}function n(a,l){return(a>>>l&1)!=0}function s(a){if(!a)throw new Error("Assertion error")}const i=class et{constructor(l,u,c){if(this.mode=l,this.numChars=u,this.bitData=c,u<0)throw new RangeError("Invalid argument");this.bitData=c.slice()}static makeBytes(l){let u=[];for(const c of l)t(c,8,u);return new et(et.Mode.BYTE,l.length,u)}static makeNumeric(l){if(!et.isNumeric(l))throw new RangeError("String contains non-numeric characters");let u=[];for(let c=0;c<l.length;){const d=Math.min(l.length-c,3);t(parseInt(l.substring(c,c+d),10),d*3+1,u),c+=d}return new et(et.Mode.NUMERIC,l.length,u)}static makeAlphanumeric(l){if(!et.isAlphanumeric(l))throw new RangeError("String contains unencodable characters in alphanumeric mode");let u=[],c;for(c=0;c+2<=l.length;c+=2){let d=et.ALPHANUMERIC_CHARSET.indexOf(l.charAt(c))*45;d+=et.ALPHANUMERIC_CHARSET.indexOf(l.charAt(c+1)),t(d,11,u)}return c<l.length&&t(et.ALPHANUMERIC_CHARSET.indexOf(l.charAt(c)),6,u),new et(et.Mode.ALPHANUMERIC,l.length,u)}static makeSegments(l){return l==""?[]:et.isNumeric(l)?[et.makeNumeric(l)]:et.isAlphanumeric(l)?[et.makeAlphanumeric(l)]:[et.makeBytes(et.toUtf8ByteArray(l))]}static makeEci(l){let u=[];if(l<0)throw new RangeError("ECI assignment value out of range");if(l<128)t(l,8,u);else if(l<16384)t(2,2,u),t(l,14,u);else if(l<1e6)t(6,3,u),t(l,21,u);else throw new RangeError("ECI assignment value out of range");return new et(et.Mode.ECI,0,u)}static isNumeric(l){return et.NUMERIC_REGEX.test(l)}static isAlphanumeric(l){return et.ALPHANUMERIC_REGEX.test(l)}getData(){return this.bitData.slice()}static getTotalBits(l,u){let c=0;for(const d of l){const h=d.mode.numCharCountBits(u);if(d.numChars>=1<<h)return 1/0;c+=4+h+d.bitData.length}return c}static toUtf8ByteArray(l){l=encodeURI(l);let u=[];for(let c=0;c<l.length;c++)l.charAt(c)!="%"?u.push(l.charCodeAt(c)):(u.push(parseInt(l.substring(c+1,c+3),16)),c+=2);return u}};i.NUMERIC_REGEX=/^[0-9]*$/,i.ALPHANUMERIC_REGEX=/^[A-Z0-9 $%*+.\/:-]*$/,i.ALPHANUMERIC_CHARSET="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ $%*+-./:";let o=i;r.QrSegment=i})(Fr||(Fr={}));(r=>{(e=>{const t=class{constructor(s,i){this.ordinal=s,this.formatBits=i}};t.LOW=new t(0,1),t.MEDIUM=new t(1,0),t.QUARTILE=new t(2,3),t.HIGH=new t(3,2),e.Ecc=t})(r.QrCode||(r.QrCode={}))})(Fr||(Fr={}));(r=>{(e=>{const t=class{constructor(s,i){this.modeBits=s,this.numBitsCharCount=i}numCharCountBits(s){return this.numBitsCharCount[Math.floor((s+7)/17)]}};t.NUMERIC=new t(1,[10,12,14]),t.ALPHANUMERIC=new t(2,[9,11,13]),t.BYTE=new t(4,[8,16,16]),t.KANJI=new t(8,[8,10,12]),t.ECI=new t(7,[0,0,0]),e.Mode=t})(r.QrSegment||(r.QrSegment={}))})(Fr||(Fr={}));var Gr=Fr;/**
100
100
  * @license qrcode.react
101
101
  * Copyright (c) Paul O'Shannessy
102
102
  * SPDX-License-Identifier: ISC
103
- */var gg={L:Gr.QrCode.Ecc.LOW,M:Gr.QrCode.Ecc.MEDIUM,Q:Gr.QrCode.Ecc.QUARTILE,H:Gr.QrCode.Ecc.HIGH},Pc=128,Ic="L",zc="#FFFFFF",Oc="#000000",$c=!1,qc=1,mg=4,yg=0,xg=.1;function Uc(r,e=0){const t=[];return r.forEach(function(n,s){let i=null;n.forEach(function(o,l){if(!o&&i!==null){t.push(`M${i+e} ${s+e}h${l-i}v1H${i+e}z`),i=null;return}if(l===n.length-1){if(!o)return;i===null?t.push(`M${l+e},${s+e} h1v1H${l+e}z`):t.push(`M${i+e},${s+e} h${l+1-i}v1H${i+e}z`);return}o&&i===null&&(i=l)})}),t.join("")}function Wc(r,e){return r.slice().map((t,n)=>n<e.y||n>=e.y+e.h?t:t.map((s,i)=>i<e.x||i>=e.x+e.w?s:!1))}function bg(r,e,t,n){if(n==null)return null;const s=r.length+t*2,i=Math.floor(e*xg),o=s/e,l=(n.width||i)*o,a=(n.height||i)*o,u=n.x==null?r.length/2-l/2:n.x*o,c=n.y==null?r.length/2-a/2:n.y*o,d=n.opacity==null?1:n.opacity;let h=null;if(n.excavate){let g=Math.floor(u),m=Math.floor(c),x=Math.ceil(l+u-g),_=Math.ceil(a+c-m);h={x:g,y:m,w:x,h:_}}const p=n.crossOrigin;return{x:u,y:c,h:a,w:l,excavation:h,opacity:d,crossOrigin:p}}function vg(r,e){return e!=null?Math.max(Math.floor(e),0):r?mg:yg}function Hc({value:r,level:e,minVersion:t,includeMargin:n,marginSize:s,imageSettings:i,size:o,boostLevel:l}){let a=y.useMemo(()=>{const g=(Array.isArray(r)?r:[r]).reduce((m,x)=>(m.push(...Gr.QrSegment.makeSegments(x)),m),[]);return Gr.QrCode.encodeSegments(g,gg[e],t,void 0,void 0,l)},[r,e,t,l]);const{cells:u,margin:c,numCells:d,calculatedImageSettings:h}=y.useMemo(()=>{let p=a.getModules();const g=vg(n,s),m=p.length+g*2,x=bg(p,o,g,i);return{cells:p,margin:g,numCells:m,calculatedImageSettings:x}},[a,o,i,n,s]);return{qrcode:a,margin:c,cells:u,numCells:d,calculatedImageSettings:h}}var _g=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),wg=y.forwardRef(function(e,t){const n=e,{value:s,size:i=Pc,level:o=Ic,bgColor:l=zc,fgColor:a=Oc,includeMargin:u=$c,minVersion:c=qc,boostLevel:d,marginSize:h,imageSettings:p}=n,m=xo(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:x}=m,_=xo(m,["style"]),b=p==null?void 0:p.src,C=y.useRef(null),S=y.useRef(null),k=y.useCallback(w=>{C.current=w,typeof t=="function"?t(w):t&&(t.current=w)},[t]),[E,v]=y.useState(!1),{margin:T,cells:B,numCells:j,calculatedImageSettings:N}=Hc({value:s,level:o,minVersion:c,boostLevel:d,includeMargin:u,marginSize:h,imageSettings:p,size:i});y.useEffect(()=>{if(C.current!=null){const w=C.current,D=w.getContext("2d");if(!D)return;let F=B;const I=S.current,U=N!=null&&I!==null&&I.complete&&I.naturalHeight!==0&&I.naturalWidth!==0;U&&N.excavation!=null&&(F=Wc(B,N.excavation));const J=window.devicePixelRatio||1;w.height=w.width=i*J;const te=i/j*J;D.scale(te,te),D.fillStyle=l,D.fillRect(0,0,j,j),D.fillStyle=a,_g?D.fill(new Path2D(Uc(F,T))):B.forEach(function(W,V){W.forEach(function(H,ne){H&&D.fillRect(ne+T,V+T,1,1)})}),N&&(D.globalAlpha=N.opacity),U&&D.drawImage(I,N.x+T,N.y+T,N.w,N.h)}}),y.useEffect(()=>{v(!1)},[b]);const M=yo({height:i,width:i},x);let R=null;return b!=null&&(R=y.createElement("img",{src:b,key:b,style:{display:"none"},onLoad:()=>{v(!0)},ref:S,crossOrigin:N==null?void 0:N.crossOrigin})),y.createElement(y.Fragment,null,y.createElement("canvas",yo({style:M,height:i,width:i,ref:k,role:"img"},_)),R)});wg.displayName="QRCodeCanvas";var Vc=y.forwardRef(function(e,t){const n=e,{value:s,size:i=Pc,level:o=Ic,bgColor:l=zc,fgColor:a=Oc,includeMargin:u=$c,minVersion:c=qc,boostLevel:d,title:h,marginSize:p,imageSettings:g}=n,m=xo(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:x,cells:_,numCells:b,calculatedImageSettings:C}=Hc({value:s,level:o,minVersion:c,boostLevel:d,includeMargin:u,marginSize:p,imageSettings:g,size:i});let S=_,k=null;g!=null&&C!=null&&(C.excavation!=null&&(S=Wc(_,C.excavation)),k=y.createElement("image",{href:g.src,height:C.h,width:C.w,x:C.x+x,y:C.y+x,preserveAspectRatio:"none",opacity:C.opacity,crossOrigin:C.crossOrigin}));const E=Uc(S,x);return y.createElement("svg",yo({height:i,width:i,viewBox:`0 0 ${b} ${b}`,ref:t,role:"img"},m),!!h&&y.createElement("title",null,h),y.createElement("path",{fill:l,d:`M0,0 h${b}v${b}H0z`,shapeRendering:"crispEdges"}),y.createElement("path",{fill:a,d:E,shapeRendering:"crispEdges"}),k)});Vc.displayName="QRCodeSVG";function Cg(r){if(r instanceof HTMLElement&&r.dataset.qrcodeData){const e=r.dataset.qrcodeData,t=r.dataset.qrcodeSize?parseInt(r.dataset.qrcodeSize,10):void 0;return{node:aa({data:e,size:t})}}return null}function Sg({data:r,size:e=150}){return f.jsx("div",{style:{display:"inline-block",background:"#f9f9f9",padding:"12px",borderRadius:"8px",margin:"8px 0"},children:f.jsx(Vc,{value:r,size:e,level:"M"})})}class un extends ra{constructor(t,n=150,s){super(s);wt(this,"__data");wt(this,"__size");this.__data=t,this.__size=n}static getType(){return"qrcode"}static clone(t){return new un(t.__data,t.__size,t.__key)}static importJSON(t){const{data:n,size:s}=t;return aa({data:n,size:s})}exportJSON(){return{type:"qrcode",version:1,data:this.__data,size:this.__size}}static importDOM(){return{div:t=>t.dataset.qrcodeData?{conversion:Cg,priority:1}:null}}exportDOM(){const t=document.createElement("div");return t.dataset.qrcodeData=this.__data,t.dataset.qrcodeSize=String(this.__size),t.style.display="inline-block",t.style.background="#f9f9f9",t.style.padding="12px",t.style.borderRadius="8px",t.textContent="[QR Code]",{element:t}}createDOM(){const t=document.createElement("span");return t.style.display="inline-block",t}updateDOM(){return!1}decorate(){return f.jsx(Sg,{data:this.__data,size:this.__size})}getData(){return this.__data}getSize(){return this.__size}}function aa(r){return new un(r.data,r.size)}function kg(r){return r instanceof un}const Eg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",toolbarBackground:"#f9fafb",quoteBorder:"#d1d5db",quoteBackground:"#f3f4f6"},Dg={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 Ag({theme:r,disabled:e,onAiRestructure:t,onAiProofread:n,onAiRewrite:s,aiProcessing:i,aiProcessingAction:o,onAiAction:l,hasContent:a}){const[u]=$t(),[c,d]=y.useState(!1),h=y.useRef(null),p=t||n||s,g=y.useCallback(()=>{u.dispatchCommand(zt,"bold")},[u]),m=y.useCallback(()=>{u.dispatchCommand(zt,"italic")},[u]),x=y.useCallback(()=>{u.dispatchCommand(zt,"underline")},[u]),_=y.useCallback(()=>{u.dispatchCommand(jc,void 0)},[u]),b=y.useCallback(()=>{u.dispatchCommand(Mc,void 0)},[u]),C=y.useCallback(()=>{u.update(()=>{const v=ae();K(v)&&op(v,()=>ia())})},[u]),S={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},k=`
103
+ */var gg={L:Gr.QrCode.Ecc.LOW,M:Gr.QrCode.Ecc.MEDIUM,Q:Gr.QrCode.Ecc.QUARTILE,H:Gr.QrCode.Ecc.HIGH},Pc=128,Ic="L",zc="#FFFFFF",Oc="#000000",$c=!1,qc=1,mg=4,yg=0,xg=.1;function Uc(r,e=0){const t=[];return r.forEach(function(n,s){let i=null;n.forEach(function(o,a){if(!o&&i!==null){t.push(`M${i+e} ${s+e}h${a-i}v1H${i+e}z`),i=null;return}if(a===n.length-1){if(!o)return;i===null?t.push(`M${a+e},${s+e} h1v1H${a+e}z`):t.push(`M${i+e},${s+e} h${a+1-i}v1H${i+e}z`);return}o&&i===null&&(i=a)})}),t.join("")}function Wc(r,e){return r.slice().map((t,n)=>n<e.y||n>=e.y+e.h?t:t.map((s,i)=>i<e.x||i>=e.x+e.w?s:!1))}function bg(r,e,t,n){if(n==null)return null;const s=r.length+t*2,i=Math.floor(e*xg),o=s/e,a=(n.width||i)*o,l=(n.height||i)*o,u=n.x==null?r.length/2-a/2:n.x*o,c=n.y==null?r.length/2-l/2:n.y*o,d=n.opacity==null?1:n.opacity;let h=null;if(n.excavate){let g=Math.floor(u),m=Math.floor(c),x=Math.ceil(a+u-g),_=Math.ceil(l+c-m);h={x:g,y:m,w:x,h:_}}const p=n.crossOrigin;return{x:u,y:c,h:l,w:a,excavation:h,opacity:d,crossOrigin:p}}function vg(r,e){return e!=null?Math.max(Math.floor(e),0):r?mg:yg}function Hc({value:r,level:e,minVersion:t,includeMargin:n,marginSize:s,imageSettings:i,size:o,boostLevel:a}){let l=y.useMemo(()=>{const g=(Array.isArray(r)?r:[r]).reduce((m,x)=>(m.push(...Gr.QrSegment.makeSegments(x)),m),[]);return Gr.QrCode.encodeSegments(g,gg[e],t,void 0,void 0,a)},[r,e,t,a]);const{cells:u,margin:c,numCells:d,calculatedImageSettings:h}=y.useMemo(()=>{let p=l.getModules();const g=vg(n,s),m=p.length+g*2,x=bg(p,o,g,i);return{cells:p,margin:g,numCells:m,calculatedImageSettings:x}},[l,o,i,n,s]);return{qrcode:l,margin:c,cells:u,numCells:d,calculatedImageSettings:h}}var _g=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),wg=y.forwardRef(function(e,t){const n=e,{value:s,size:i=Pc,level:o=Ic,bgColor:a=zc,fgColor:l=Oc,includeMargin:u=$c,minVersion:c=qc,boostLevel:d,marginSize:h,imageSettings:p}=n,m=xo(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:x}=m,_=xo(m,["style"]),b=p==null?void 0:p.src,S=y.useRef(null),C=y.useRef(null),k=y.useCallback(w=>{S.current=w,typeof t=="function"?t(w):t&&(t.current=w)},[t]),[E,v]=y.useState(!1),{margin:T,cells:B,numCells:j,calculatedImageSettings:N}=Hc({value:s,level:o,minVersion:c,boostLevel:d,includeMargin:u,marginSize:h,imageSettings:p,size:i});y.useEffect(()=>{if(S.current!=null){const w=S.current,D=w.getContext("2d");if(!D)return;let F=B;const z=C.current,q=N!=null&&z!==null&&z.complete&&z.naturalHeight!==0&&z.naturalWidth!==0;q&&N.excavation!=null&&(F=Wc(B,N.excavation));const J=window.devicePixelRatio||1;w.height=w.width=i*J;const te=i/j*J;D.scale(te,te),D.fillStyle=a,D.fillRect(0,0,j,j),D.fillStyle=l,_g?D.fill(new Path2D(Uc(F,T))):B.forEach(function(W,G){W.forEach(function(H,se){H&&D.fillRect(se+T,G+T,1,1)})}),N&&(D.globalAlpha=N.opacity),q&&D.drawImage(z,N.x+T,N.y+T,N.w,N.h)}}),y.useEffect(()=>{v(!1)},[b]);const R=yo({height:i,width:i},x);let M=null;return b!=null&&(M=y.createElement("img",{src:b,key:b,style:{display:"none"},onLoad:()=>{v(!0)},ref:C,crossOrigin:N==null?void 0:N.crossOrigin})),y.createElement(y.Fragment,null,y.createElement("canvas",yo({style:R,height:i,width:i,ref:k,role:"img"},_)),M)});wg.displayName="QRCodeCanvas";var Vc=y.forwardRef(function(e,t){const n=e,{value:s,size:i=Pc,level:o=Ic,bgColor:a=zc,fgColor:l=Oc,includeMargin:u=$c,minVersion:c=qc,boostLevel:d,title:h,marginSize:p,imageSettings:g}=n,m=xo(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:x,cells:_,numCells:b,calculatedImageSettings:S}=Hc({value:s,level:o,minVersion:c,boostLevel:d,includeMargin:u,marginSize:p,imageSettings:g,size:i});let C=_,k=null;g!=null&&S!=null&&(S.excavation!=null&&(C=Wc(_,S.excavation)),k=y.createElement("image",{href:g.src,height:S.h,width:S.w,x:S.x+x,y:S.y+x,preserveAspectRatio:"none",opacity:S.opacity,crossOrigin:S.crossOrigin}));const E=Uc(C,x);return y.createElement("svg",yo({height:i,width:i,viewBox:`0 0 ${b} ${b}`,ref:t,role:"img"},m),!!h&&y.createElement("title",null,h),y.createElement("path",{fill:a,d:`M0,0 h${b}v${b}H0z`,shapeRendering:"crispEdges"}),y.createElement("path",{fill:l,d:E,shapeRendering:"crispEdges"}),k)});Vc.displayName="QRCodeSVG";function Cg(r){if(r instanceof HTMLElement&&r.dataset.qrcodeData){const e=r.dataset.qrcodeData,t=r.dataset.qrcodeSize?parseInt(r.dataset.qrcodeSize,10):void 0;return{node:aa({data:e,size:t})}}return null}function Sg({data:r,size:e=150}){return f.jsx("div",{style:{display:"inline-block",background:"#f9f9f9",padding:"12px",borderRadius:"8px",margin:"8px 0"},children:f.jsx(Vc,{value:r,size:e,level:"M"})})}class un extends ra{constructor(t,n=150,s){super(s);_t(this,"__data");_t(this,"__size");this.__data=t,this.__size=n}static getType(){return"qrcode"}static clone(t){return new un(t.__data,t.__size,t.__key)}static importJSON(t){const{data:n,size:s}=t;return aa({data:n,size:s})}exportJSON(){return{type:"qrcode",version:1,data:this.__data,size:this.__size}}static importDOM(){return{div:t=>t.dataset.qrcodeData?{conversion:Cg,priority:1}:null}}exportDOM(){const t=document.createElement("div");return t.dataset.qrcodeData=this.__data,t.dataset.qrcodeSize=String(this.__size),t.style.display="inline-block",t.style.background="#f9f9f9",t.style.padding="12px",t.style.borderRadius="8px",t.textContent="[QR Code]",{element:t}}createDOM(){const t=document.createElement("span");return t.style.display="inline-block",t}updateDOM(){return!1}decorate(){return f.jsx(Sg,{data:this.__data,size:this.__size})}getData(){return this.__data}getSize(){return this.__size}}function aa(r){return new un(r.data,r.size)}function kg(r){return r instanceof un}const Eg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",toolbarBackground:"#f9fafb",quoteBorder:"#d1d5db",quoteBackground:"#f3f4f6"},Dg={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 Ag({theme:r,disabled:e,onAiRestructure:t,onAiProofread:n,onAiRewrite:s,aiProcessing:i,aiProcessingAction:o,onAiAction:a,hasContent:l}){const[u]=zt(),[c,d]=y.useState(!1),h=y.useRef(null),p=t||n||s,g=y.useCallback(()=>{u.dispatchCommand(Pt,"bold")},[u]),m=y.useCallback(()=>{u.dispatchCommand(Pt,"italic")},[u]),x=y.useCallback(()=>{u.dispatchCommand(Pt,"underline")},[u]),_=y.useCallback(()=>{u.dispatchCommand(jc,void 0)},[u]),b=y.useCallback(()=>{u.dispatchCommand(Mc,void 0)},[u]),S=y.useCallback(()=>{u.update(()=>{const v=ae();V(v)&&op(v,()=>ia())})},[u]),C={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},k=`
104
104
  .mail-editor-toolbar-btn:hover:not(:disabled) {
105
105
  background: ${r.border};
106
106
  }
107
- `,E=()=>{setTimeout(()=>{var v;(v=h.current)!=null&&v.contains(document.activeElement)||d(!1)},150)};return f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",borderBottom:`1px solid ${r.border}`,background:r.toolbarBackground},children:[f.jsx("style",{children:k}),f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"2px"},children:[f.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:g,disabled:e,style:S,title:"Bold (Ctrl+B)",children:"B"}),f.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:m,disabled:e,style:{...S,fontStyle:"italic"},title:"Italic (Ctrl+I)",children:"I"}),f.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:x,disabled:e,style:{...S,textDecoration:"underline"},title:"Underline (Ctrl+U)",children:"U"}),f.jsx("div",{style:{width:"1px",height:"20px",background:r.border,margin:"0 6px"}}),f.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:_,disabled:e,style:S,title:"Bullet List",children:f.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[f.jsx("circle",{cx:"4",cy:"6",r:"2"}),f.jsx("circle",{cx:"4",cy:"12",r:"2"}),f.jsx("circle",{cx:"4",cy:"18",r:"2"}),f.jsx("rect",{x:"8",y:"5",width:"14",height:"2"}),f.jsx("rect",{x:"8",y:"11",width:"14",height:"2"}),f.jsx("rect",{x:"8",y:"17",width:"14",height:"2"})]})}),f.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:b,disabled:e,style:S,title:"Numbered List",children:f.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[f.jsx("text",{x:"2",y:"8",fontSize:"8",fontFamily:"sans-serif",children:"1"}),f.jsx("text",{x:"2",y:"14",fontSize:"8",fontFamily:"sans-serif",children:"2"}),f.jsx("text",{x:"2",y:"20",fontSize:"8",fontFamily:"sans-serif",children:"3"}),f.jsx("rect",{x:"8",y:"5",width:"14",height:"2"}),f.jsx("rect",{x:"8",y:"11",width:"14",height:"2"}),f.jsx("rect",{x:"8",y:"17",width:"14",height:"2"})]})}),f.jsx("div",{style:{width:"1px",height:"20px",background:r.border,margin:"0 6px"}}),f.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:C,disabled:e,style:S,title:"Quote",children:f.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:f.jsx("path",{d:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"})})})]}),p&&f.jsxs("div",{style:{position:"relative"},ref:h,children:[f.jsx("button",{type:"button",onClick:()=>d(!c),disabled:i||!a||e,onBlur:E,style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",fontSize:"13px",color:i||!a?r.textSecondary:"#9333ea",background:"transparent",border:"none",borderRadius:"4px",cursor:i||!a||e?"not-allowed":"pointer",opacity:i||!a?.5:1},children:i?f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"material-icons",style:{fontSize:"16px",animation:"spin 1s linear infinite"},children:"hourglass_empty"}),o==="restructure"&&"Restructuring...",o==="proofread"&&"Proofreading...",o==="rewrite"&&"Rewriting..."]}):f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"material-icons",style:{fontSize:"16px"},children:"auto_fix_high"}),"AI",f.jsx("span",{className:"material-icons",style:{fontSize:"14px"},children:"expand_more"})]})}),c&&!i&&f.jsxs("div",{style:{position:"absolute",right:0,top:"100%",marginTop:"4px",background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",zIndex:50,minWidth:"200px",padding:"4px 0"},children:[t&&f.jsxs("button",{type:"button",onClick:()=>{l==null||l("restructure"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:v=>v.currentTarget.style.background="#f3f4f6",onMouseLeave:v=>v.currentTarget.style.background="transparent",children:[f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#3b82f6"},children:"format_list_bulleted"}),f.jsxs("div",{children:[f.jsx("div",{style:{fontWeight:500},children:"Restructure"}),f.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Organize & clarify"})]})]}),n&&f.jsxs("button",{type:"button",onClick:()=>{l==null||l("proofread"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:v=>v.currentTarget.style.background="#f3f4f6",onMouseLeave:v=>v.currentTarget.style.background="transparent",children:[f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#22c55e"},children:"spellcheck"}),f.jsxs("div",{children:[f.jsx("div",{style:{fontWeight:500},children:"Proofread"}),f.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Fix grammar & spelling"})]})]}),s&&f.jsxs("button",{type:"button",onClick:()=>{l==null||l("rewrite"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:v=>v.currentTarget.style.background="#f3f4f6",onMouseLeave:v=>v.currentTarget.style.background="transparent",children:[f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#9333ea"},children:"brush"}),f.jsxs("div",{children:[f.jsx("div",{style:{fontWeight:500},children:"Rewrite"}),f.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Your voice & style"})]})]})]})]})]})}function Tg({html:r,isExternalUpdate:e,onImportComplete:t}){const[n]=$t(),s=y.useRef(!1);return y.useEffect(()=>{r&&(s.current&&!e||(s.current=!0,n.update(()=>{const i=et();i.clear();const o=at();i.append(o),o.select();const a=new DOMParser().parseFromString(r,"text/html"),c=Cc(n,a).filter(d=>d.getParent()===null);c.length>0&&lc(c),o.getTextContent()===""&&i.getChildrenSize()>1&&o.remove(),i.selectEnd()},{discrete:!0}),t(),setTimeout(()=>{n.focus()},0)))},[r,e,n,t]),null}function Ng({text:r,trigger:e}){const[t]=$t(),n=y.useRef(void 0);return y.useEffect(()=>{if(e===void 0||e===n.current||!r)return;n.current=e;const s=r.trim();s&&(t.update(()=>{const i=ae();if(K(i))i.insertText(s);else{const o=et(),l=o.getLastChild();if(l){l.selectEnd();const a=ae();K(a)&&a.insertText(s)}else{const a=at(),u=lt(s);a.append(u),o.append(a)}}}),setTimeout(()=>{t.focus()},0))},[r,e,t]),null}function Bg({replyTo:r,theme:e}){const t=n=>{try{return new Date(n).toLocaleString()}catch{return n}};return f.jsxs("div",{style:{marginTop:"16px",paddingTop:"16px",borderTop:`1px solid ${e.border}`},children:[f.jsxs("div",{style:{fontSize:"12px",color:e.textSecondary,marginBottom:"8px"},children:["On ",t(r.date),", ",r.from," wrote:"]}),f.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 Gc({value:r="",onChange:e,placeholder:t="Write your message...",replyTo:n,theme:s={},disabled:i=!1,className:o="",minHeight:l="200px",externalUpdate:a,insertText:u,insertTextTrigger:c,onAiRestructure:d,onAiProofread:h,onAiRewrite:p,aiProcessing:g,aiProcessingAction:m,renderAboveToolbar:x}){const _={...Eg,...s},[b,C]=y.useState(!1),S=y.useRef(void 0),[k,E]=y.useState(r),[v,T]=y.useState(!1),[B,j]=y.useState(null),N=g??v,M=m??B;y.useEffect(()=>{a!==void 0&&a!==S.current&&(S.current=a,C(!0))},[a]);const R=y.useCallback(()=>{C(!1)},[]),w=W=>W.replace(/<[^>]*>/g,"").trim(),D=W=>W.split(`
108
- `).map(V=>`<p>${V||"<br>"}</p>`).join(""),F=async W=>{const V=w(k);if(!V)return;const H=W==="restructure"?d:W==="proofread"?h:p;if(H){T(!0),j(W);try{const ne=await H(V),ce=D(ne);E(ce),e==null||e(ce),S.current=Date.now(),C(!0)}catch(ne){console.error(`AI ${W} failed:`,ne)}finally{T(!1),j(null)}}},I=w(k).length>0,U={namespace:"MailEditor",theme:Dg,onError:W=>{console.error("Lexical error:",W)},nodes:[ln,Ir,zr,ns,bi,xi,vi,un],editable:!i},J=y.useCallback((W,V)=>{W.read(()=>{const H=Sc(V,null);E(H),e==null||e(H)})},[e]),te=`
107
+ `,E=()=>{setTimeout(()=>{var v;(v=h.current)!=null&&v.contains(document.activeElement)||d(!1)},150)};return f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",borderBottom:`1px solid ${r.border}`,background:r.toolbarBackground},children:[f.jsx("style",{children:k}),f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"2px"},children:[f.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:g,disabled:e,style:C,title:"Bold (Ctrl+B)",children:"B"}),f.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:m,disabled:e,style:{...C,fontStyle:"italic"},title:"Italic (Ctrl+I)",children:"I"}),f.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:x,disabled:e,style:{...C,textDecoration:"underline"},title:"Underline (Ctrl+U)",children:"U"}),f.jsx("div",{style:{width:"1px",height:"20px",background:r.border,margin:"0 6px"}}),f.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:_,disabled:e,style:C,title:"Bullet List",children:f.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[f.jsx("circle",{cx:"4",cy:"6",r:"2"}),f.jsx("circle",{cx:"4",cy:"12",r:"2"}),f.jsx("circle",{cx:"4",cy:"18",r:"2"}),f.jsx("rect",{x:"8",y:"5",width:"14",height:"2"}),f.jsx("rect",{x:"8",y:"11",width:"14",height:"2"}),f.jsx("rect",{x:"8",y:"17",width:"14",height:"2"})]})}),f.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:b,disabled:e,style:C,title:"Numbered List",children:f.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[f.jsx("text",{x:"2",y:"8",fontSize:"8",fontFamily:"sans-serif",children:"1"}),f.jsx("text",{x:"2",y:"14",fontSize:"8",fontFamily:"sans-serif",children:"2"}),f.jsx("text",{x:"2",y:"20",fontSize:"8",fontFamily:"sans-serif",children:"3"}),f.jsx("rect",{x:"8",y:"5",width:"14",height:"2"}),f.jsx("rect",{x:"8",y:"11",width:"14",height:"2"}),f.jsx("rect",{x:"8",y:"17",width:"14",height:"2"})]})}),f.jsx("div",{style:{width:"1px",height:"20px",background:r.border,margin:"0 6px"}}),f.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:S,disabled:e,style:C,title:"Quote",children:f.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:f.jsx("path",{d:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"})})})]}),p&&f.jsxs("div",{style:{position:"relative"},ref:h,children:[f.jsx("button",{type:"button",onClick:()=>d(!c),disabled:i||!l||e,onBlur:E,style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",fontSize:"13px",color:i||!l?r.textSecondary:"#9333ea",background:"transparent",border:"none",borderRadius:"4px",cursor:i||!l||e?"not-allowed":"pointer",opacity:i||!l?.5:1},children:i?f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"material-icons",style:{fontSize:"16px",animation:"spin 1s linear infinite"},children:"hourglass_empty"}),o==="restructure"&&"Restructuring...",o==="proofread"&&"Proofreading...",o==="rewrite"&&"Rewriting..."]}):f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"material-icons",style:{fontSize:"16px"},children:"auto_fix_high"}),"AI",f.jsx("span",{className:"material-icons",style:{fontSize:"14px"},children:"expand_more"})]})}),c&&!i&&f.jsxs("div",{style:{position:"absolute",right:0,top:"100%",marginTop:"4px",background:"#ffffff",border:"1px solid #e5e7eb",borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.15)",zIndex:50,minWidth:"200px",padding:"4px 0"},children:[t&&f.jsxs("button",{type:"button",onClick:()=>{a==null||a("restructure"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:v=>v.currentTarget.style.background="#f3f4f6",onMouseLeave:v=>v.currentTarget.style.background="transparent",children:[f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#3b82f6"},children:"format_list_bulleted"}),f.jsxs("div",{children:[f.jsx("div",{style:{fontWeight:500},children:"Restructure"}),f.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Organize & clarify"})]})]}),n&&f.jsxs("button",{type:"button",onClick:()=>{a==null||a("proofread"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:v=>v.currentTarget.style.background="#f3f4f6",onMouseLeave:v=>v.currentTarget.style.background="transparent",children:[f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#22c55e"},children:"spellcheck"}),f.jsxs("div",{children:[f.jsx("div",{style:{fontWeight:500},children:"Proofread"}),f.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Fix grammar & spelling"})]})]}),s&&f.jsxs("button",{type:"button",onClick:()=>{a==null||a("rewrite"),d(!1)},style:{width:"100%",padding:"8px 12px",textAlign:"left",fontSize:"14px",background:"transparent",border:"none",cursor:"pointer",display:"flex",alignItems:"center",gap:"8px"},onMouseEnter:v=>v.currentTarget.style.background="#f3f4f6",onMouseLeave:v=>v.currentTarget.style.background="transparent",children:[f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#9333ea"},children:"brush"}),f.jsxs("div",{children:[f.jsx("div",{style:{fontWeight:500},children:"Rewrite"}),f.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Your voice & style"})]})]})]})]})]})}function Tg({html:r,isExternalUpdate:e,onImportComplete:t}){const[n]=zt(),s=y.useRef(!1);return y.useEffect(()=>{r&&(s.current&&!e||(s.current=!0,n.update(()=>{const i=Ze();i.clear();const o=ot();i.append(o),o.select();const l=new DOMParser().parseFromString(r,"text/html"),c=Cc(n,l).filter(d=>d.getParent()===null);c.length>0&&lc(c),o.getTextContent()===""&&i.getChildrenSize()>1&&o.remove(),i.selectEnd()},{discrete:!0}),t(),setTimeout(()=>{n.focus()},0)))},[r,e,n,t]),null}function Ng({text:r,trigger:e}){const[t]=zt(),n=y.useRef(void 0);return y.useEffect(()=>{if(e===void 0||e===n.current||!r)return;n.current=e;const s=r.trim();s&&(t.update(()=>{const i=ae();if(V(i))i.insertText(s);else{const o=Ze(),a=o.getLastChild();if(a){a.selectEnd();const l=ae();V(l)&&l.insertText(s)}else{const l=ot(),u=lt(s);l.append(u),o.append(l)}}}),setTimeout(()=>{t.focus()},0))},[r,e,t]),null}function Bg({replyTo:r,theme:e}){const t=n=>{try{return new Date(n).toLocaleString()}catch{return n}};return f.jsxs("div",{style:{marginTop:"16px",paddingTop:"16px",borderTop:`1px solid ${e.border}`},children:[f.jsxs("div",{style:{fontSize:"12px",color:e.textSecondary,marginBottom:"8px"},children:["On ",t(r.date),", ",r.from," wrote:"]}),f.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 Gc({value:r="",onChange:e,placeholder:t="Write your message...",replyTo:n,theme:s={},disabled:i=!1,className:o="",minHeight:a="200px",externalUpdate:l,insertText:u,insertTextTrigger:c,onAiRestructure:d,onAiProofread:h,onAiRewrite:p,aiProcessing:g,aiProcessingAction:m,renderAboveToolbar:x}){const _={...Eg,...s},[b,S]=y.useState(!1),C=y.useRef(void 0),[k,E]=y.useState(r),[v,T]=y.useState(!1),[B,j]=y.useState(null),N=g??v,R=m??B;y.useEffect(()=>{l!==void 0&&l!==C.current&&(C.current=l,S(!0))},[l]);const M=y.useCallback(()=>{S(!1)},[]),w=W=>W.replace(/<[^>]*>/g,"").trim(),D=W=>W.split(`
108
+ `).map(G=>`<p>${G||"<br>"}</p>`).join(""),F=async W=>{const G=w(k);if(!G)return;const H=W==="restructure"?d:W==="proofread"?h:p;if(H){T(!0),j(W);try{const se=await H(G),le=D(se);E(le),e==null||e(le),C.current=Date.now(),S(!0)}catch(se){console.error(`AI ${W} failed:`,se)}finally{T(!1),j(null)}}},z=w(k).length>0,q={namespace:"MailEditor",theme:Dg,onError:W=>{console.error("Lexical error:",W)},nodes:[ln,Ir,zr,ns,bi,xi,vi,un],editable:!i},J=y.useCallback((W,G)=>{W.read(()=>{const H=Sc(G,null);E(H),e==null||e(H)})},[e]),te=`
109
109
  .mail-editor-paragraph {
110
110
  margin: 0 0 8px 0;
111
111
  line-height: 1.5;
@@ -154,7 +154,7 @@ React keys must be passed directly to JSX without using spread:
154
154
  }
155
155
  .mail-editor-content {
156
156
  outline: none;
157
- min-height: ${l};
157
+ min-height: ${a};
158
158
  padding: 16px;
159
159
  font-size: 14px;
160
160
  line-height: 1.6;
@@ -175,14 +175,14 @@ React keys must be passed directly to JSX without using spread:
175
175
  from { transform: rotate(0deg); }
176
176
  to { transform: rotate(360deg); }
177
177
  }
178
- `;return f.jsxs("div",{className:o,style:{border:`1px solid ${_.border}`,borderRadius:"8px",background:_.background,overflow:"hidden",display:"flex",flexDirection:"column",height:"100%",minHeight:l},children:[f.jsx("style",{children:te}),x,f.jsxs(Gh,{initialConfig:U,children:[f.jsx(Ag,{theme:_,disabled:i,onAiRestructure:d,onAiProofread:h,onAiRewrite:p,aiProcessing:N,aiProcessingAction:M,onAiAction:F,hasContent:I}),f.jsx("div",{style:{position:"relative",flex:1,display:"flex",flexDirection:"column"},children:f.jsx(Bp,{contentEditable:f.jsx(Fp,{className:"mail-editor-content",style:{outline:"none",flex:1,minHeight:"100px",padding:"16px",fontSize:"14px",lineHeight:1.6,color:_.text}}),placeholder:f.jsx("div",{className:"mail-editor-placeholder",children:t}),ErrorBoundary:Yp})}),f.jsx(ag,{}),f.jsx(dg,{}),f.jsx(Hp,{}),f.jsx(Gp,{onChange:J}),f.jsx(Tg,{html:b?k:r,isExternalUpdate:b,onImportComplete:R}),f.jsx(Ng,{text:u,trigger:c})]}),n&&f.jsx(Bg,{replyTo:n,theme:_})]})}const jg={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 Mg({to:r="",cc:e="",bcc:t="",subject:n="",body:s="",replyTo:i,onSend:o,onCancel:l,onBodyChange:a,externalUpdate:u,insertText:c,insertTextTrigger:d,theme:h={},disabled:p=!1,showCcBcc:g=!1,placeholder:m="Write your message...",className:x="",hideToField:_=!1,hideSubjectField:b=!1,minHeight:C="200px",hideCancelButton:S=!1,onAiRestructure:k,onAiProofread:E,onAiRewrite:v,onAiGenerate:T,renderAboveToolbar:B,onPickContact:j,initialPrompt:N="",onPromptChange:M,initialAttachments:R,onAttachmentsChange:w}){const D={...jg,...h},[F,I]=y.useState(r),[U,J]=y.useState(e),[te,W]=y.useState(t),[V,H]=y.useState(n),[ne,ce]=y.useState(s),[le,pe]=y.useState([]),[be,Te]=y.useState(R||[]),[$,ke]=y.useState(!1),[se,Re]=y.useState(""),[Ce,Ee]=y.useState(g||!!e||!!t),[Se,Fe]=y.useState("message"),[ze,ge]=y.useState(N),[L,Me]=y.useState(!1),[Qe,G]=y.useState(!0),[ee,me]=y.useState(!0);y.useEffect(()=>{I(r)},[r]),y.useEffect(()=>{J(e),e&&Ee(!0)},[e]),y.useEffect(()=>{W(t),t&&Ee(!0)},[t]),y.useEffect(()=>{ge(N)},[N]),y.useEffect(()=>{Te(R||[])},[R]);const _e=z=>{ge(z),M==null||M(z)},Be=async z=>new Promise((xe,he)=>{const de=new FileReader;de.onload=()=>{const Ve=de.result.split(",")[1]||"";xe({filename:z.name,content_type:z.type||"application/octet-stream",data:Ve,size:z.size})},de.onerror=he,de.readAsDataURL(z)}),Xe=async(z,xe)=>{if(!w)return;const he=await Promise.all(z.map(Be));w([...xe,...he])},[bt,oe]=y.useState(!1),fe=y.useRef(void 0);y.useEffect(()=>{u!==void 0&&u!==fe.current&&(fe.current=u,ce(s),oe(!0))},[u,s]);const Je=z=>{ce(z),oe(!1),a==null||a(z)},Ke=y.useRef(null),[Ye,pt]=y.useState(!1),X=z=>{const xe=z.target.files;if(xe){const he=Array.from(xe);console.log("[MailComposer] Files selected:",he.map(de=>({name:de.name,size:de.size,type:de.type}))),pe(de=>{const Ve=[...de,...he];return Xe(Ve,be),Ve})}Ke.current&&(Ke.current.value="")},P=z=>{z.preventDefault(),z.stopPropagation(),pt(!0)},ue=z=>{z.preventDefault(),z.stopPropagation(),pt(!1)},ye=z=>{if(z.preventDefault(),z.stopPropagation(),pt(!1),z.dataTransfer.files&&z.dataTransfer.files.length>0){const xe=Array.from(z.dataTransfer.files);console.log("[MailComposer] Files dropped:",xe.map(he=>({name:he.name,size:he.size,type:he.type}))),pe(he=>{const de=[...he,...xe];return Xe(de,be),de})}else console.log("[MailComposer] Drop event but no files:",z.dataTransfer.types)},Y=z=>z.type.startsWith("image/")?"image":z.type==="application/pdf"?"picture_as_pdf":z.type.includes("spreadsheet")||z.type.includes("excel")?"table_chart":z.type.includes("document")||z.type.includes("word")?"description":"attach_file",Ne=z=>{pe(xe=>{const he=xe.filter((de,Ve)=>Ve!==z);return Xe(he,be),he})},Ae=z=>{Te(xe=>{const he=xe.filter((de,Ve)=>Ve!==z);return Xe(le,he),he})},De=z=>z<1024?`${z} B`:z<1024*1024?`${(z/1024).toFixed(1)} KB`:`${(z/(1024*1024)).toFixed(1)} MB`,$e=async()=>{if(!F.trim()){Re("Recipient email is required");return}if(!V.trim()){Re("Subject is required");return}ke(!0),Re("");try{const z=await Promise.all(le.map(async de=>{const Ve=await de.arrayBuffer(),st=btoa(new Uint8Array(Ve).reduce((vt,jt)=>vt+String.fromCharCode(jt),""));return{filename:de.name,content_type:de.type||"application/octet-stream",data:st,size:de.size}})),xe=ne.replace(/>\n+</g,"><").replace(/<p class="[^"]*"><\/p>/g,"<br>").trim(),he={to:F.trim(),cc:U.trim()||void 0,bcc:te.trim()||void 0,subject:V.trim(),html:xe,attachments:[...be,...z],inReplyTo:i==null?void 0:i.messageId};console.log("[MailComposer] Sending email - to:",he.to,"subject:",he.subject,"attachmentsCount:",he.attachments.length),he.attachments.length>0&&he.attachments.forEach((de,Ve)=>{var st;console.log(`[MailComposer] Attachment ${Ve+1}:`,de.filename,"size:",de.size,"type:",de.content_type,"data length:",((st=de.data)==null?void 0:st.length)||0)}),await o(he),I(""),J(""),W(""),H(""),ce(""),pe([])}catch(z){Re(z instanceof Error?z.message:"Failed to send email")}finally{ke(!1)}},Ue={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${D.inputBorder}`,borderRadius:"6px",background:D.inputBackground,color:D.text,outline:"none"},we={display:"block",fontSize:"12px",fontWeight:500,color:D.textSecondary,marginBottom:"4px",textTransform:"uppercase"},je=(z,xe=!1)=>({padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderRadius:"6px",cursor:xe?"not-allowed":"pointer",opacity:xe?.6:1,background:z?D.buttonPrimary:D.buttonSecondary,color:z?"#ffffff":D.text,display:"flex",alignItems:"center",gap:"8px"});return f.jsxs("div",{className:x,style:{display:"flex",flexDirection:"column",gap:"16px",padding:"16px",background:D.background},children:[se&&f.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:"6px",color:"#dc2626",fontSize:"14px"},children:se}),!_&&f.jsxs("div",{children:[f.jsx("label",{style:we,children:"To"}),f.jsx("input",{type:"email",value:F,onChange:z=>I(z.target.value),placeholder:"recipient@example.com",disabled:p||$,style:Ue})]}),!Ce&&f.jsx("button",{type:"button",onClick:()=>Ee(!0),disabled:p||$,style:{background:"none",border:"none",padding:0,fontSize:"12px",color:D.primary,cursor:"pointer",textAlign:"left"},children:"+ Add CC/BCC"}),Ce&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{children:[f.jsx("label",{style:we,children:"CC"}),f.jsxs("div",{style:{display:"flex",gap:"8px"},children:[f.jsx("input",{type:"email",value:U,onChange:z=>J(z.target.value),placeholder:"cc@example.com",disabled:p||$,style:{...Ue,flex:1}}),j&&f.jsx("button",{type:"button",onClick:async()=>{const z=await j("cc");z&&J(xe=>xe?`${xe}, ${z}`:z)},disabled:p||$,title:"Add from contacts",style:{padding:"8px 12px",border:`1px solid ${D.inputBorder}`,borderRadius:"6px",background:D.buttonSecondary,cursor:p||$?"not-allowed":"pointer",display:"flex",alignItems:"center"},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:D.textSecondary},children:"person_add"})})]})]}),f.jsxs("div",{children:[f.jsx("label",{style:we,children:"BCC"}),f.jsxs("div",{style:{display:"flex",gap:"8px"},children:[f.jsx("input",{type:"email",value:te,onChange:z=>W(z.target.value),placeholder:"bcc@example.com",disabled:p||$,style:{...Ue,flex:1}}),j&&f.jsx("button",{type:"button",onClick:async()=>{const z=await j("bcc");z&&W(xe=>xe?`${xe}, ${z}`:z)},disabled:p||$,title:"Add from contacts",style:{padding:"8px 12px",border:`1px solid ${D.inputBorder}`,borderRadius:"6px",background:D.buttonSecondary,cursor:p||$?"not-allowed":"pointer",display:"flex",alignItems:"center"},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:D.textSecondary},children:"person_add"})})]})]})]}),!b&&f.jsxs("div",{children:[f.jsx("label",{style:we,children:"Subject"}),f.jsx("input",{type:"text",value:V,onChange:z=>H(z.target.value),placeholder:"Email subject",disabled:p||$,style:Ue})]}),f.jsx("input",{ref:Ke,type:"file",multiple:!0,onChange:X,style:{display:"none"}}),f.jsxs("div",{style:{display:"flex",gap:"8px",borderBottom:`1px solid ${D.border}`,marginBottom:"0"},children:[f.jsx("button",{type:"button",onClick:()=>Fe("message"),disabled:p||$,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:Se==="message"?`2px solid ${D.primary}`:"2px solid transparent",color:Se==="message"?D.primary:D.textSecondary,fontWeight:Se==="message"?600:400,cursor:p||$?"not-allowed":"pointer",fontSize:"14px"},children:"Message"}),f.jsxs("button",{type:"button",onClick:()=>Fe("attachments"),disabled:p||$,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:Se==="attachments"?`2px solid ${D.primary}`:"2px solid transparent",color:Se==="attachments"?D.primary:D.textSecondary,fontWeight:Se==="attachments"?600:400,cursor:p||$?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"6px",fontSize:"14px"},children:["Attachments",le.length+be.length>0&&f.jsx("span",{style:{background:D.primary,color:"#ffffff",borderRadius:"10px",padding:"2px 7px",fontSize:"11px",fontWeight:600},children:le.length+be.length})]}),T&&f.jsx("button",{type:"button",onClick:()=>Fe("prompt"),disabled:p||$,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:Se==="prompt"?`2px solid ${D.primary}`:"2px solid transparent",color:Se==="prompt"?D.primary:D.textSecondary,fontWeight:Se==="prompt"?600:400,cursor:p||$?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"6px",fontSize:"14px"},children:"Prompt"}),Se==="message"&&f.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"4px"},children:[f.jsx("button",{type:"button",onClick:()=>{var z;return(z=Ke.current)==null?void 0:z.click()},disabled:p||$,title:"Add attachment",style:{padding:"6px 10px",border:"none",background:"none",color:D.textSecondary,cursor:p||$?"not-allowed":"pointer",display:"flex",alignItems:"center",borderRadius:"4px"},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"attach_file"})}),f.jsx("button",{type:"button",onClick:$e,disabled:p||$||!F.trim()||!V.trim()||!ne.replace(/<[^>]*>/g,"").trim(),title:"Send email",style:{padding:"6px 10px",border:"none",background:"none",color:p||$||!F.trim()||!V.trim()||!ne.replace(/<[^>]*>/g,"").trim()?D.textSecondary:D.primary,cursor:p||$||!F.trim()||!V.trim()||!ne.replace(/<[^>]*>/g,"").trim()?"not-allowed":"pointer",opacity:p||$||!F.trim()||!V.trim()||!ne.replace(/<[^>]*>/g,"").trim()?.4:1,display:"flex",alignItems:"center",borderRadius:"4px"},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px",animation:$?"spin 1s linear infinite":"none"},children:$?"sync":"send"})})]})]}),Se==="message"&&f.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:f.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:f.jsx(Gc,{value:ne,onChange:Je,placeholder:m,replyTo:i,theme:D,disabled:p||$,minHeight:C,externalUpdate:bt?u:void 0,insertText:c,insertTextTrigger:d,onAiRestructure:k,onAiProofread:E,onAiRewrite:v,renderAboveToolbar:B})})}),Se==="attachments"&&f.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden"},children:[f.jsxs("div",{onClick:()=>{var z;return(z=Ke.current)==null?void 0:z.click()},onDragOver:P,onDragLeave:ue,onDrop:ye,style:{width:"100%",padding:"24px 16px",border:`2px dashed ${Ye?D.primary:D.border}`,borderRadius:"8px",background:Ye?`${D.primary}10`:"transparent",color:Ye?D.primary:D.textSecondary,cursor:p||$?"not-allowed":"pointer",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s",marginBottom:"12px",flexShrink:0},children:[f.jsx("span",{className:"material-icons",style:{fontSize:"24px"},children:Ye?"file_download":"cloud_upload"}),f.jsx("span",{style:{fontSize:"14px"},children:Ye?"Drop files here":"Drop files or click to add"})]}),f.jsx("div",{style:{flex:1,overflowY:"auto",padding:"4px 0"},children:le.length+be.length>0?f.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:[be.map((z,xe)=>{var he;return f.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 12px",borderBottom:`1px solid ${D.border}`,gap:"12px"},children:[f.jsx("span",{className:"material-icons",style:{fontSize:"22px",color:D.textSecondary},children:(he=z.content_type)!=null&&he.startsWith("image/")?"image":z.content_type==="application/pdf"?"picture_as_pdf":"attach_file"}),f.jsxs("div",{style:{flex:1,minWidth:0},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:D.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.filename}),f.jsx("div",{style:{fontSize:"12px",color:D.textSecondary},children:De(z.size)})]}),f.jsx("button",{type:"button",onClick:()=>Ae(xe),disabled:p||$,title:"Remove attachment",style:{background:"none",border:"none",padding:"6px",cursor:p||$?"not-allowed":"pointer",color:D.textSecondary,display:"flex",borderRadius:"4px"},children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:"close"})})]},`saved-${z.filename}-${xe}`)}),le.map((z,xe)=>f.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 12px",borderBottom:`1px solid ${D.border}`,gap:"12px"},children:[f.jsx("span",{className:"material-icons",style:{fontSize:"22px",color:D.textSecondary},children:Y(z)}),f.jsxs("div",{style:{flex:1,minWidth:0},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:D.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.name}),f.jsx("div",{style:{fontSize:"12px",color:D.textSecondary},children:De(z.size)})]}),f.jsx("button",{type:"button",onClick:()=>Ne(xe),disabled:p||$,title:"Remove attachment",style:{background:"none",border:"none",padding:"6px",cursor:p||$?"not-allowed":"pointer",color:D.textSecondary,display:"flex",borderRadius:"4px"},children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:"close"})})]},`${z.name}-${xe}`))]}):f.jsx("div",{style:{textAlign:"center",padding:"40px 20px",color:D.textSecondary,fontSize:"14px"},children:"No attachments yet"})})]}),Se==="prompt"&&T&&f.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0,gap:"12px"},children:[f.jsxs("div",{style:{display:"flex",gap:"16px",fontSize:"14px",color:D.text},children:[f.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[f.jsx("input",{type:"checkbox",checked:Qe,onChange:z=>G(z.target.checked),disabled:p||$||L,style:{width:"16px",height:"16px",cursor:"pointer"}}),"Utiliser notes"]}),f.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[f.jsx("input",{type:"checkbox",checked:ee,onChange:z=>me(z.target.checked),disabled:p||$||L,style:{width:"16px",height:"16px",cursor:"pointer"}}),"Ajouter signature"]})]}),f.jsx("textarea",{value:ze,onChange:z=>_e(z.target.value),placeholder:"Décrivez le mail que vous souhaitez envoyer...",disabled:p||$||L,style:{flex:1,padding:"12px",fontSize:"14px",border:`1px solid ${D.inputBorder}`,borderRadius:"6px",background:D.inputBackground,color:D.text,outline:"none",resize:"none",minHeight:"150px"}}),f.jsxs("button",{type:"button",onClick:async()=>{if(!(!ze.trim()||!T)){Me(!0);try{const z=await T(ze,{to:F,subject:V},{useNotes:Qe,addSignature:ee});ce(z),Fe("message")}catch(z){console.error("AI generation failed:",z)}finally{Me(!1)}}},disabled:p||$||L||!ze.trim(),style:{padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderRadius:"6px",cursor:p||$||L||!ze.trim()?"not-allowed":"pointer",opacity:p||$||L||!ze.trim()?.6:1,background:D.buttonPrimary,color:"#ffffff",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[f.jsx("span",{className:"material-icons",style:{fontSize:"18px",animation:L?"spin 1s linear infinite":"none"},children:L?"sync":"auto_awesome"}),L?"Génération...":"Générer"]})]}),!S&&l&&f.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:f.jsx("button",{type:"button",onClick:l,disabled:p||$,style:je(!1,p||$),children:"Cancel"})}),f.jsx("style",{children:`
178
+ `;return f.jsxs("div",{className:o,style:{border:`1px solid ${_.border}`,borderRadius:"8px",background:_.background,overflow:"hidden",display:"flex",flexDirection:"column",height:"100%",minHeight:a},children:[f.jsx("style",{children:te}),x,f.jsxs(Gh,{initialConfig:q,children:[f.jsx(Ag,{theme:_,disabled:i,onAiRestructure:d,onAiProofread:h,onAiRewrite:p,aiProcessing:N,aiProcessingAction:R,onAiAction:F,hasContent:z}),f.jsx("div",{style:{position:"relative",flex:1,display:"flex",flexDirection:"column"},children:f.jsx(Bp,{contentEditable:f.jsx(Fp,{className:"mail-editor-content",style:{outline:"none",flex:1,minHeight:"100px",padding:"16px",fontSize:"14px",lineHeight:1.6,color:_.text}}),placeholder:f.jsx("div",{className:"mail-editor-placeholder",children:t}),ErrorBoundary:Yp})}),f.jsx(ag,{}),f.jsx(dg,{}),f.jsx(Hp,{}),f.jsx(Gp,{onChange:J}),f.jsx(Tg,{html:b?k:r,isExternalUpdate:b,onImportComplete:M}),f.jsx(Ng,{text:u,trigger:c})]}),n&&f.jsx(Bg,{replyTo:n,theme:_})]})}const jg={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 Mg({to:r="",cc:e="",bcc:t="",subject:n="",body:s="",replyTo:i,onSend:o,onCancel:a,onBodyChange:l,externalUpdate:u,insertText:c,insertTextTrigger:d,theme:h={},disabled:p=!1,showCcBcc:g=!1,placeholder:m="Write your message...",className:x="",hideToField:_=!1,hideSubjectField:b=!1,minHeight:S="200px",hideCancelButton:C=!1,onAiRestructure:k,onAiProofread:E,onAiRewrite:v,onAiGenerate:T,renderAboveToolbar:B,onPickContact:j,initialPrompt:N="",onPromptChange:R,initialAttachments:M,onAttachmentsChange:w}){const D={...jg,...h},[F,z]=y.useState(r),[q,J]=y.useState(e),[te,W]=y.useState(t),[G,H]=y.useState(n),[se,le]=y.useState(s),[ue,_e]=y.useState([]),[fe,De]=y.useState(M||[]),[O,Ce]=y.useState(!1),[re,Fe]=y.useState(""),[je,ye]=y.useState(g||!!e||!!t),[Se,Me]=y.useState("message"),[Oe,ge]=y.useState(N),[L,ze]=y.useState(!1),[Ke,X]=y.useState(!0),[Z,ce]=y.useState(!0);y.useEffect(()=>{z(r)},[r]),y.useEffect(()=>{J(e),e&&ye(!0)},[e]),y.useEffect(()=>{W(t),t&&ye(!0)},[t]),y.useEffect(()=>{ge(N)},[N]),y.useEffect(()=>{De(M||[])},[M]);const we=P=>{ge(P),R==null||R(P)},Be=async P=>new Promise((xe,ve)=>{const be=new FileReader;be.onload=()=>{const Ne=be.result.split(",")[1]||"";xe({filename:P.name,content_type:P.type||"application/octet-stream",data:Ne,size:P.size})},be.onerror=ve,be.readAsDataURL(P)}),Qe=async(P,xe)=>{if(!w)return;const ve=await Promise.all(P.map(Be));w([...xe,...ve])},[Et,oe]=y.useState(!1),pe=y.useRef(void 0);y.useEffect(()=>{u!==void 0&&u!==pe.current&&(pe.current=u,le(s),oe(!0))},[u,s]);const Ye=P=>{le(P),oe(!1),l==null||l(P)},at=y.useRef(null),[Ve,Xe]=y.useState(!1),br=P=>{const xe=P.target.files;if(xe){const ve=Array.from(xe);console.log("[MailComposer] Files selected:",ve.map(be=>({name:be.name,size:be.size,type:be.type}))),_e(be=>{const Ne=[...be,...ve];return Qe(Ne,fe),Ne})}at.current&&(at.current.value="")},Q=P=>{P.preventDefault(),P.stopPropagation(),Xe(!0)},I=P=>{P.preventDefault(),P.stopPropagation(),Xe(!1)},de=P=>{if(P.preventDefault(),P.stopPropagation(),Xe(!1),P.dataTransfer.files&&P.dataTransfer.files.length>0){const xe=Array.from(P.dataTransfer.files);console.log("[MailComposer] Files dropped:",xe.map(ve=>({name:ve.name,size:ve.size,type:ve.type}))),_e(ve=>{const be=[...ve,...xe];return Qe(be,fe),be})}else console.log("[MailComposer] Drop event but no files:",P.dataTransfer.types)},he=P=>P.type.startsWith("image/")?"image":P.type==="application/pdf"?"picture_as_pdf":P.type.includes("spreadsheet")||P.type.includes("excel")?"table_chart":P.type.includes("document")||P.type.includes("word")?"description":"attach_file",Y=P=>{_e(xe=>{const ve=xe.filter((be,Ne)=>Ne!==P);return Qe(ve,fe),ve})},Ae=P=>{De(xe=>{const ve=xe.filter((be,Ne)=>Ne!==P);return Qe(ue,ve),ve})},Ee=P=>P<1024?`${P} B`:P<1024*1024?`${(P/1024).toFixed(1)} KB`:`${(P/(1024*1024)).toFixed(1)} MB`,Te=async()=>{if(!F.trim()){Fe("Recipient email is required");return}if(!G.trim()){Fe("Subject is required");return}Ce(!0),Fe("");try{const P=await Promise.all(ue.map(async be=>{const Ne=await be.arrayBuffer(),st=btoa(new Uint8Array(Ne).reduce((ct,bt)=>ct+String.fromCharCode(bt),""));return{filename:be.name,content_type:be.type||"application/octet-stream",data:st,size:be.size}})),xe=se.replace(/>\n+</g,"><").replace(/<p class="[^"]*"><\/p>/g,"<br>").trim(),ve={to:F.trim(),cc:q.trim()||void 0,bcc:te.trim()||void 0,subject:G.trim(),html:xe,attachments:[...fe,...P],inReplyTo:i==null?void 0:i.messageId};console.log("[MailComposer] Sending email - to:",ve.to,"subject:",ve.subject,"attachmentsCount:",ve.attachments.length),ve.attachments.length>0&&ve.attachments.forEach((be,Ne)=>{var st;console.log(`[MailComposer] Attachment ${Ne+1}:`,be.filename,"size:",be.size,"type:",be.content_type,"data length:",((st=be.data)==null?void 0:st.length)||0)}),await o(ve),z(""),J(""),W(""),H(""),le(""),_e([])}catch(P){Fe(P instanceof Error?P.message:"Failed to send email")}finally{Ce(!1)}},Le={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${D.inputBorder}`,borderRadius:"6px",background:D.inputBackground,color:D.text,outline:"none"},He={display:"block",fontSize:"12px",fontWeight:500,color:D.textSecondary,marginBottom:"4px",textTransform:"uppercase"},ke=(P,xe=!1)=>({padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderRadius:"6px",cursor:xe?"not-allowed":"pointer",opacity:xe?.6:1,background:P?D.buttonPrimary:D.buttonSecondary,color:P?"#ffffff":D.text,display:"flex",alignItems:"center",gap:"8px"});return f.jsxs("div",{className:x,style:{display:"flex",flexDirection:"column",gap:"16px",padding:"16px",background:D.background},children:[re&&f.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:"6px",color:"#dc2626",fontSize:"14px"},children:re}),!_&&f.jsxs("div",{children:[f.jsx("label",{style:He,children:"To"}),f.jsx("input",{type:"email",value:F,onChange:P=>z(P.target.value),placeholder:"recipient@example.com",disabled:p||O,style:Le})]}),!je&&f.jsx("button",{type:"button",onClick:()=>ye(!0),disabled:p||O,style:{background:"none",border:"none",padding:0,fontSize:"12px",color:D.primary,cursor:"pointer",textAlign:"left"},children:"+ Add CC/BCC"}),je&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{children:[f.jsx("label",{style:He,children:"CC"}),f.jsxs("div",{style:{display:"flex",gap:"8px"},children:[f.jsx("input",{type:"email",value:q,onChange:P=>J(P.target.value),placeholder:"cc@example.com",disabled:p||O,style:{...Le,flex:1}}),j&&f.jsx("button",{type:"button",onClick:async()=>{const P=await j("cc");P&&J(xe=>xe?`${xe}, ${P}`:P)},disabled:p||O,title:"Add from contacts",style:{padding:"8px 12px",border:`1px solid ${D.inputBorder}`,borderRadius:"6px",background:D.buttonSecondary,cursor:p||O?"not-allowed":"pointer",display:"flex",alignItems:"center"},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:D.textSecondary},children:"person_add"})})]})]}),f.jsxs("div",{children:[f.jsx("label",{style:He,children:"BCC"}),f.jsxs("div",{style:{display:"flex",gap:"8px"},children:[f.jsx("input",{type:"email",value:te,onChange:P=>W(P.target.value),placeholder:"bcc@example.com",disabled:p||O,style:{...Le,flex:1}}),j&&f.jsx("button",{type:"button",onClick:async()=>{const P=await j("bcc");P&&W(xe=>xe?`${xe}, ${P}`:P)},disabled:p||O,title:"Add from contacts",style:{padding:"8px 12px",border:`1px solid ${D.inputBorder}`,borderRadius:"6px",background:D.buttonSecondary,cursor:p||O?"not-allowed":"pointer",display:"flex",alignItems:"center"},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:D.textSecondary},children:"person_add"})})]})]})]}),!b&&f.jsxs("div",{children:[f.jsx("label",{style:He,children:"Subject"}),f.jsx("input",{type:"text",value:G,onChange:P=>H(P.target.value),placeholder:"Email subject",disabled:p||O,style:Le})]}),f.jsx("input",{ref:at,type:"file",multiple:!0,onChange:br,style:{display:"none"}}),f.jsxs("div",{style:{display:"flex",gap:"8px",borderBottom:`1px solid ${D.border}`,marginBottom:"0"},children:[f.jsx("button",{type:"button",onClick:()=>Me("message"),disabled:p||O,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:Se==="message"?`2px solid ${D.primary}`:"2px solid transparent",color:Se==="message"?D.primary:D.textSecondary,fontWeight:Se==="message"?600:400,cursor:p||O?"not-allowed":"pointer",fontSize:"14px"},children:"Message"}),f.jsxs("button",{type:"button",onClick:()=>Me("attachments"),disabled:p||O,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:Se==="attachments"?`2px solid ${D.primary}`:"2px solid transparent",color:Se==="attachments"?D.primary:D.textSecondary,fontWeight:Se==="attachments"?600:400,cursor:p||O?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"6px",fontSize:"14px"},children:["Attachments",ue.length+fe.length>0&&f.jsx("span",{style:{background:D.primary,color:"#ffffff",borderRadius:"10px",padding:"2px 7px",fontSize:"11px",fontWeight:600},children:ue.length+fe.length})]}),T&&f.jsx("button",{type:"button",onClick:()=>Me("prompt"),disabled:p||O,style:{padding:"8px 16px",border:"none",background:"none",borderBottom:Se==="prompt"?`2px solid ${D.primary}`:"2px solid transparent",color:Se==="prompt"?D.primary:D.textSecondary,fontWeight:Se==="prompt"?600:400,cursor:p||O?"not-allowed":"pointer",display:"flex",alignItems:"center",gap:"6px",fontSize:"14px"},children:"Prompt"}),Se==="message"&&f.jsxs("div",{style:{marginLeft:"auto",display:"flex",alignItems:"center",gap:"4px"},children:[f.jsx("button",{type:"button",onClick:()=>{var P;return(P=at.current)==null?void 0:P.click()},disabled:p||O,title:"Add attachment",style:{padding:"6px 10px",border:"none",background:"none",color:D.textSecondary,cursor:p||O?"not-allowed":"pointer",display:"flex",alignItems:"center",borderRadius:"4px"},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"attach_file"})}),f.jsx("button",{type:"button",onClick:Te,disabled:p||O||!F.trim()||!G.trim()||!se.replace(/<[^>]*>/g,"").trim(),title:"Send email",style:{padding:"6px 10px",border:"none",background:"none",color:p||O||!F.trim()||!G.trim()||!se.replace(/<[^>]*>/g,"").trim()?D.textSecondary:D.primary,cursor:p||O||!F.trim()||!G.trim()||!se.replace(/<[^>]*>/g,"").trim()?"not-allowed":"pointer",opacity:p||O||!F.trim()||!G.trim()||!se.replace(/<[^>]*>/g,"").trim()?.4:1,display:"flex",alignItems:"center",borderRadius:"4px"},children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px",animation:O?"spin 1s linear infinite":"none"},children:O?"sync":"send"})})]})]}),Se==="message"&&f.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:f.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:f.jsx(Gc,{value:se,onChange:Ye,placeholder:m,replyTo:i,theme:D,disabled:p||O,minHeight:S,externalUpdate:Et?u:void 0,insertText:c,insertTextTrigger:d,onAiRestructure:k,onAiProofread:E,onAiRewrite:v,renderAboveToolbar:B})})}),Se==="attachments"&&f.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0,overflow:"hidden"},children:[f.jsxs("div",{onClick:()=>{var P;return(P=at.current)==null?void 0:P.click()},onDragOver:Q,onDragLeave:I,onDrop:de,style:{width:"100%",padding:"24px 16px",border:`2px dashed ${Ve?D.primary:D.border}`,borderRadius:"8px",background:Ve?`${D.primary}10`:"transparent",color:Ve?D.primary:D.textSecondary,cursor:p||O?"not-allowed":"pointer",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s",marginBottom:"12px",flexShrink:0},children:[f.jsx("span",{className:"material-icons",style:{fontSize:"24px"},children:Ve?"file_download":"cloud_upload"}),f.jsx("span",{style:{fontSize:"14px"},children:Ve?"Drop files here":"Drop files or click to add"})]}),f.jsx("div",{style:{flex:1,overflowY:"auto",padding:"4px 0"},children:ue.length+fe.length>0?f.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"2px"},children:[fe.map((P,xe)=>{var ve;return f.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 12px",borderBottom:`1px solid ${D.border}`,gap:"12px"},children:[f.jsx("span",{className:"material-icons",style:{fontSize:"22px",color:D.textSecondary},children:(ve=P.content_type)!=null&&ve.startsWith("image/")?"image":P.content_type==="application/pdf"?"picture_as_pdf":"attach_file"}),f.jsxs("div",{style:{flex:1,minWidth:0},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:D.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:P.filename}),f.jsx("div",{style:{fontSize:"12px",color:D.textSecondary},children:Ee(P.size)})]}),f.jsx("button",{type:"button",onClick:()=>Ae(xe),disabled:p||O,title:"Remove attachment",style:{background:"none",border:"none",padding:"6px",cursor:p||O?"not-allowed":"pointer",color:D.textSecondary,display:"flex",borderRadius:"4px"},children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:"close"})})]},`saved-${P.filename}-${xe}`)}),ue.map((P,xe)=>f.jsxs("div",{style:{display:"flex",alignItems:"center",padding:"10px 12px",borderBottom:`1px solid ${D.border}`,gap:"12px"},children:[f.jsx("span",{className:"material-icons",style:{fontSize:"22px",color:D.textSecondary},children:he(P)}),f.jsxs("div",{style:{flex:1,minWidth:0},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:D.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:P.name}),f.jsx("div",{style:{fontSize:"12px",color:D.textSecondary},children:Ee(P.size)})]}),f.jsx("button",{type:"button",onClick:()=>Y(xe),disabled:p||O,title:"Remove attachment",style:{background:"none",border:"none",padding:"6px",cursor:p||O?"not-allowed":"pointer",color:D.textSecondary,display:"flex",borderRadius:"4px"},children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:"close"})})]},`${P.name}-${xe}`))]}):f.jsx("div",{style:{textAlign:"center",padding:"40px 20px",color:D.textSecondary,fontSize:"14px"},children:"No attachments yet"})})]}),Se==="prompt"&&T&&f.jsxs("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0,gap:"12px"},children:[f.jsxs("div",{style:{display:"flex",gap:"16px",fontSize:"14px",color:D.text},children:[f.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[f.jsx("input",{type:"checkbox",checked:Ke,onChange:P=>X(P.target.checked),disabled:p||O||L,style:{width:"16px",height:"16px",cursor:"pointer"}}),"Utiliser notes"]}),f.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"6px",cursor:"pointer"},children:[f.jsx("input",{type:"checkbox",checked:Z,onChange:P=>ce(P.target.checked),disabled:p||O||L,style:{width:"16px",height:"16px",cursor:"pointer"}}),"Ajouter signature"]})]}),f.jsx("textarea",{value:Oe,onChange:P=>we(P.target.value),placeholder:"Décrivez le mail que vous souhaitez envoyer...",disabled:p||O||L,style:{flex:1,padding:"12px",fontSize:"14px",border:`1px solid ${D.inputBorder}`,borderRadius:"6px",background:D.inputBackground,color:D.text,outline:"none",resize:"none",minHeight:"150px"}}),f.jsxs("button",{type:"button",onClick:async()=>{if(!(!Oe.trim()||!T)){ze(!0);try{const P=await T(Oe,{to:F,subject:G},{useNotes:Ke,addSignature:Z});le(P),Me("message")}catch(P){console.error("AI generation failed:",P)}finally{ze(!1)}}},disabled:p||O||L||!Oe.trim(),style:{padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderRadius:"6px",cursor:p||O||L||!Oe.trim()?"not-allowed":"pointer",opacity:p||O||L||!Oe.trim()?.6:1,background:D.buttonPrimary,color:"#ffffff",display:"flex",alignItems:"center",justifyContent:"center",gap:"8px"},children:[f.jsx("span",{className:"material-icons",style:{fontSize:"18px",animation:L?"spin 1s linear infinite":"none"},children:L?"sync":"auto_awesome"}),L?"Génération...":"Générer"]})]}),!C&&a&&f.jsx("div",{style:{display:"flex",justifyContent:"flex-end"},children:f.jsx("button",{type:"button",onClick:a,disabled:p||O,style:ke(!1,p||O),children:"Cancel"})}),f.jsx("style",{children:`
179
179
  @keyframes spin {
180
180
  from { transform: rotate(0deg); }
181
181
  to { transform: rotate(360deg); }
182
182
  }
183
- `})]})}const Rg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function Fg({options:r,value:e,onChange:t,placeholder:n="Search or select...",allowCreate:s=!0,onCreate:i,allowDelete:o=!1,onDelete:l,label:a,disabled:u=!1,max:c=0,theme:d={},className:h=""}){const p={...Rg,...d},[g,m]=y.useState(!1),[x,_]=y.useState(""),b=y.useRef(null),C=y.useRef(null);y.useEffect(()=>{function N(M){b.current&&!b.current.contains(M.target)&&(m(!1),_(""))}return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]);const S=r.filter(N=>{var M;return((M=N.label)==null?void 0:M.toLowerCase().includes(x.toLowerCase()))&&!e.includes(N.id)}),k=s&&x.trim()&&!r.some(N=>{var M;return((M=N.label)==null?void 0:M.toLowerCase())===x.toLowerCase()}),E=e.map(N=>r.find(M=>M.id===N)).filter(Boolean),v=y.useCallback(N=>{var M;c>0&&e.length>=c||(t([...e,N]),_(""),c===1?m(!1):(M=C.current)==null||M.focus())},[e,t,c]),T=y.useCallback(N=>{t(e.filter(M=>M!==N))},[e,t]),B=y.useCallback(async()=>{if(!k)return;const N=await(i==null?void 0:i(x.trim()));N&&v(N.id),_("")},[k,x,i,v]),j=y.useCallback(N=>{N.key==="Enter"?(N.preventDefault(),k?B():S.length>0&&v(S[0].id)):N.key==="Backspace"&&!x&&e.length>0?T(e[e.length-1]):N.key==="Escape"&&(m(!1),_(""))},[k,S,x,e,B,v,T]);return f.jsxs("div",{ref:b,className:h,style:{position:"relative"},children:[a&&f.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:p.textSecondary,marginBottom:"4px"},children:a}),f.jsxs("div",{onClick:()=>!u&&m(!0),style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px 12px",border:`1px solid ${g?p.primary:p.border}`,borderRadius:"8px",background:u?p.hoverBackground:p.background,cursor:u?"not-allowed":"text",minHeight:"42px",alignItems:"center"},children:[E.map(N=>f.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:N.color||p.chipBackground,color:N.color?"#fff":p.chipText},children:[N.label,!u&&f.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),T(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},N.id)),f.jsx("input",{ref:C,type:"text",value:x,onChange:N=>{_(N.target.value),g||m(!0)},onFocus:()=>m(!0),onKeyDown:j,placeholder:E.length===0?n:"",disabled:u||c>0&&e.length>=c,style:{flex:1,minWidth:"60px",border:"none",outline:"none",fontSize:"14px",background:"transparent",color:p.text}})]}),g&&!u&&f.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:p.background,border:`1px solid ${p.border}`,borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",maxHeight:"200px",overflowY:"auto",zIndex:50},children:S.length===0&&!k?f.jsx("div",{style:{padding:"12px",fontSize:"14px",color:p.textSecondary,textAlign:"center"},children:x?"No matches":"No options available"}):f.jsxs(f.Fragment,{children:[S.map(N=>f.jsxs("div",{onClick:()=>v(N.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.text,display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:M=>{M.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:M=>{M.currentTarget.style.background=""},children:[N.label,o&&l&&f.jsx("button",{type:"button",onClick:M=>{M.stopPropagation(),l(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:p.textSecondary,opacity:.5},onMouseEnter:M=>{M.currentTarget.style.opacity="1",M.currentTarget.style.color="#ef4444"},onMouseLeave:M=>{M.currentTarget.style.opacity="0.5",M.currentTarget.style.color=p.textSecondary||""},children:"×"})]},N.id)),k&&f.jsxs("div",{onClick:B,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.primary,borderTop:S.length>0?`1px solid ${p.border}`:"none"},onMouseEnter:N=>{N.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:N=>{N.currentTarget.style.background=""},children:['+ Create "',x.trim(),'"']})]})})]})}const Lg={background:"#f9fafb",cardBackground:"#ffffff",cardHover:"#f3f4f6",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#374151"},Kc=y.forwardRef(({filteredOptions:r,search:e,theme:t,maxHeight:n,onCardClick:s},i)=>{const o=y.useRef(null),[l,a]=y.useState(typeof n=="number"?`${n}px`:n);return y.useEffect(()=>{const u=o.current;if(!u)return;const c=u.getBoundingClientRect(),d=window.innerHeight-c.top-16;a(`${Math.max(120,Math.min(d,typeof n=="number"?n:9999))}px`)},[n,r.length]),y.useEffect(()=>{typeof i=="function"?i(o.current):i&&(i.current=o.current)}),f.jsx("div",{ref:o,style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",maxHeight:l,overflowY:"auto",border:`1px solid ${t.border}`,borderRadius:"8px",background:t.background,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",zIndex:50},children:r.length===0?f.jsx("div",{style:{padding:"16px",textAlign:"center",color:t.textSecondary,fontSize:"14px"},children:e?`No results for "${e}"`:"No items"}):r.map((u,c)=>f.jsxs("div",{onClick:()=>s(u),style:{padding:"10px 14px",cursor:"pointer",borderBottom:c<r.length-1?`1px solid ${t.border}`:"none",background:t.cardBackground,transition:"background 0.15s",display:"flex",alignItems:"center",gap:"10px"},onMouseEnter:d=>{d.currentTarget.style.background=t.cardHover||"#f3f4f6"},onMouseLeave:d=>{d.currentTarget.style.background=t.cardBackground||"#f9fafb"},children:[u.icon&&f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:u.color||t.textSecondary,flexShrink:0},children:u.icon}),f.jsxs("div",{style:{flex:1,minWidth:0},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:u.color||t.text,marginBottom:u.notes?"2px":0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:u.label}),u.notes&&f.jsx("div",{style:{fontSize:"12px",color:t.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:u.notes})]})]},u.id))})});Kc.displayName="DropdownList";function Pg({options:r,value:e,type:t,placeholder:n="Search...",onItemClick:s,onClear:i,onCreate:o,maxHeight:l=300,className:a="",theme:u={}}){const c={...Lg,...u},[d,h]=y.useState(""),[p,g]=y.useState(!1),m=y.useRef(null),x=y.useRef(null),_=y.useRef(null),b=y.useMemo(()=>e&&r.find(B=>B.id===e)||null,[e,r]),C=y.useMemo(()=>{if(!d.trim())return r;const B=d.toLowerCase();return r.filter(j=>{var N,M;return((N=j.label)==null?void 0:N.toLowerCase().includes(B))||((M=j.notes)==null?void 0:M.toLowerCase().includes(B))})},[r,d]);y.useEffect(()=>{const B=j=>{m.current&&!m.current.contains(j.target)&&g(!1)};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[]);const S=B=>{s&&s(B),g(!1),h("")},k=()=>{o&&o(d.trim()||void 0),g(!1),h("")},E=()=>{g(!0)},v=B=>{h(B.target.value),p||g(!0)},T=B=>{B.key==="Enter"?(B.preventDefault(),C.length>0&&s?(s(C[0]),g(!1),h("")):o&&d.trim()&&(o(d.trim()),g(!1),h(""))):B.key==="Escape"&&(g(!1),h(""))};return f.jsxs("div",{ref:m,className:`combostack ${a}`,style:{position:"relative",width:"100%",height:"32px"},children:[f.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center",height:"100%"},children:[f.jsx("div",{style:{flex:1,position:"relative"},children:b&&!p?f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 10px",fontSize:"13px",border:`1px solid ${c.border}`,borderRadius:"8px",background:c.background,color:c.text,cursor:"pointer",height:"32px",boxSizing:"border-box"},onClick:()=>g(!0),children:[f.jsxs("div",{style:{overflow:"hidden"},children:[f.jsx("div",{style:{fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:b.label}),b.notes&&f.jsx("div",{style:{fontSize:"11px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:b.notes})]}),i&&f.jsx("button",{onClick:B=>{B.stopPropagation(),i()},style:{marginLeft:"8px",padding:"2px",background:"none",border:"none",cursor:"pointer",color:c.textSecondary,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",flexShrink:0},title:"Clear selection",children:f.jsx("span",{className:"material-icons",style:{fontSize:"16px"},children:"close"})})]}):f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"material-icons",style:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",color:c.textSecondary,fontSize:"16px",pointerEvents:"none"},children:"search"}),f.jsx("input",{ref:x,type:"text",value:d,onChange:v,onFocus:E,onKeyDown:T,placeholder:n,style:{width:"100%",height:"32px",padding:"0 12px 0 36px",fontSize:"13px",border:`1px solid ${p?c.primary:c.border}`,borderRadius:"8px",background:c.background,color:c.text,outline:"none",boxSizing:"border-box",transition:"border-color 0.15s"}})]})}),o&&f.jsx("button",{onClick:k,style:{display:"flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",color:c.text,cursor:"pointer",padding:"4px",borderRadius:"4px",transition:"opacity 0.15s",flexShrink:0,opacity:.7},onMouseEnter:B=>{B.currentTarget.style.opacity="1"},onMouseLeave:B=>{B.currentTarget.style.opacity="0.7"},title:`Create ${t||"item"}`,children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:"add"})})]}),p&&f.jsx(Kc,{ref:_,filteredOptions:C,search:d,theme:c,maxHeight:l,onCardClick:S})]})}function Ig({items:r,columns:e,getItemId:t,getItemColumn:n,getItemOrder:s,renderItem:i,onItemMove:o,onItemReorder:l,onItemClick:a,renderColumnHeader:u,renderColumnFooter:c,className:d="",columnClassName:h="",columnStyle:p,itemClassName:g=""}){const[m,x]=y.useState(null),[_,b]=y.useState(null),[C,S]=y.useState(null),k=y.useRef(null),E=e.reduce((R,w)=>{let D=r.filter(F=>n(F)===w.id);return s&&(D=D.sort((F,I)=>s(F)-s(I))),R[w.id]=D,R},{}),v=y.useCallback((R,w)=>{const D=t(w),F=n(w);x(D),k.current=F,R.dataTransfer.effectAllowed="move",R.dataTransfer.setData("text/plain",D),requestAnimationFrame(()=>{const I=R.target;I.style.opacity="0.5"})},[t,n]),T=y.useCallback(R=>{const w=R.target;w.style.opacity="1",x(null),b(null),S(null),k.current=null},[]),B=y.useCallback((R,w,D)=>{R.preventDefault(),R.dataTransfer.dropEffect="move",b(w),S(D)},[]),j=y.useCallback(R=>{const w=R.relatedTarget;w!=null&&w.closest("[data-kanban-column]")||(b(null),S(null))},[]),N=y.useCallback((R,w,D)=>{if(R.preventDefault(),!m)return;const F=k.current;F===w?l==null||l(m,w,D):F&&o(m,F,w,D),x(null),b(null),S(null),k.current=null},[m,o,l]),M=(R,w)=>f.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[R.color&&f.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:R.color}}),f.jsx("span",{className:"font-medium text-sm text-neutral-700",children:R.label})]}),f.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:w})]});return f.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 h-full ${d}`,style:{alignItems:"flex-start"},children:e.map(R=>{const w=E[R.id]||[],D=_===R.id,F=w.length>0||D;return f.jsxs("div",{"data-kanban-column":R.id,className:`flex-1 min-w-[180px] rounded-xl flex flex-col ${h||"bg-neutral-50"}`,style:{...p,maxHeight:"100%",...F?{}:{}},onDragOver:I=>{I.preventDefault(),m&&!D&&b(R.id)},onDragLeave:j,onDrop:I=>N(I,R.id,C??w.length),children:[f.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(R,w.length):M(R,w.length)}),f.jsxs("div",{className:`overflow-y-auto p-2 space-y-2 transition-colors ${D?"bg-blue-50":""}`,style:{minHeight:F?100:40},children:[w.map((I,U)=>{const J=t(I),te=m===J,W=D&&C===U&&!te;return f.jsxs("div",{children:[W&&f.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),f.jsx("div",{draggable:!0,onDragStart:V=>v(V,I),onDragEnd:T,onDragOver:V=>B(V,R.id,U),onClick:()=>a==null?void 0:a(I),className:`cursor-grab active:cursor-grabbing transition-all ${te?"opacity-50 scale-95":""} ${g}`,children:i(I,te)})]},J)}),f.jsx("div",{className:"min-h-[40px]",onDragOver:I=>{I.preventDefault(),B(I,R.id,w.length)},children:D&&C===w.length&&f.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),w.length===0&&D&&f.jsx("div",{className:"h-20 border-2 border-dashed border-blue-300 rounded-lg bg-blue-50/50 flex items-center justify-center",children:f.jsx("span",{className:"text-sm text-blue-400",children:"Drop here"})})]}),c&&f.jsx("div",{className:"flex-shrink-0 border-t border-neutral-200 p-2",children:c(R)})]},R.id)})})}function Yc(r){const e=r.data||{};return e.image||e.poster||e.thumbnail||e.cover||e.photo}function zg(r){const e=r.data||{};return e.subtitle||e.director||e.author||e.creator}function Og(r){const e=r.data||{};return e.description||r.description||e.synopsis||e.summary}function $g(r){const e=r.data||{},t=[];return e.year&&t.push(String(e.year)),e.duration&&t.push(`${e.duration} min`),e.country&&t.push(e.country),e.category&&t.push(e.category),t.join(" • ")}const qg={"1:1":1,"2:3":1.5,"16:9":.5625};function Qc({node:r,aspectRatio:e,onClick:t}){const[n,s]=y.useState(!1),i=Yc(r),o=qg[e],l=e==="2:3"?160:e==="16:9"?280:180,a=e==="2:3"||e==="16:9"?l*o:l;return f.jsxs("div",{onClick:t,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{position:"relative",width:l,height:a,flexShrink:0,borderRadius:6,overflow:"hidden",cursor:"pointer",transform:n?"scale(1.08)":"scale(1)",transition:"transform 0.2s ease-out",zIndex:n?10:1,boxShadow:n?"0 8px 24px rgba(0,0,0,0.5)":"0 2px 8px rgba(0,0,0,0.3)"},children:[i?f.jsx("img",{src:i,alt:r.title||"Item",style:{width:"100%",height:"100%",objectFit:"cover"}}):f.jsx("div",{style:{width:"100%",height:"100%",background:"linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%)",display:"flex",alignItems:"center",justifyContent:"center"},children:f.jsx("span",{style:{fontSize:32,opacity:.3},children:"📄"})}),f.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,padding:"24px 8px 8px",background:"linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 100%)",opacity:n?1:.8,transition:"opacity 0.2s ease"},children:f.jsx("p",{style:{margin:0,fontSize:13,fontWeight:600,color:"white",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.title||"Untitled"})})]})}function Jc({title:r,nodes:e,cardAspectRatio:t,onNodeClick:n}){const s=y.useRef(null),[i,o]=y.useState(!1),[l,a]=y.useState(!1),[u,c]=y.useState(!1),d=()=>{const p=s.current;p&&(a(p.scrollLeft>0),c(p.scrollLeft<p.scrollWidth-p.clientWidth-10))};y.useEffect(()=>{d();const p=s.current;if(p)return p.addEventListener("scroll",d),()=>p.removeEventListener("scroll",d)},[e]);const h=p=>{const g=s.current;if(!g)return;const m=g.clientWidth*.8;g.scrollBy({left:p==="left"?-m:m,behavior:"smooth"})};return e.length===0?null:f.jsxs("div",{style:{marginBottom:32},onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[f.jsx("h3",{style:{margin:"0 0 12px 48px",fontSize:20,fontWeight:700,color:"white"},children:r}),f.jsxs("div",{style:{position:"relative"},children:[l&&f.jsx("button",{onClick:()=>h("left"),style:{position:"absolute",left:0,top:0,bottom:0,width:48,border:"none",background:"linear-gradient(to right, rgba(20,20,20,0.95) 0%, transparent 100%)",color:"white",cursor:"pointer",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:i?1:0,transition:"opacity 0.2s ease"},children:f.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:f.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),u&&f.jsx("button",{onClick:()=>h("right"),style:{position:"absolute",right:0,top:0,bottom:0,width:48,border:"none",background:"linear-gradient(to left, rgba(20,20,20,0.95) 0%, transparent 100%)",color:"white",cursor:"pointer",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:i?1:0,transition:"opacity 0.2s ease"},children:f.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:f.jsx("path",{d:"M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z"})})}),f.jsx("div",{ref:s,style:{display:"flex",gap:8,overflowX:"auto",overflowY:"hidden",padding:"8px 48px",scrollbarWidth:"none",msOverflowStyle:"none"},children:e.map(p=>f.jsx(Qc,{node:p,aspectRatio:t,onClick:()=>n(p)},p._id))})]})]})}function Xc({node:r,onClose:e}){const t=Yc(r),n=zg(r),s=Og(r),i=$g(r);return y.useEffect(()=>{const o=l=>{l.key==="Escape"&&e()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e]),y.useEffect(()=>(document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[]),f.jsx("div",{onClick:e,style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0, 0, 0, 0.85)",display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:f.jsxs("div",{onClick:o=>o.stopPropagation(),style:{position:"relative",width:"100%",maxWidth:850,maxHeight:"90vh",background:"#181818",borderRadius:8,overflow:"hidden",boxShadow:"0 16px 64px rgba(0,0,0,0.6)"},children:[f.jsx("button",{onClick:e,style:{position:"absolute",top:12,right:12,width:36,height:36,borderRadius:"50%",border:"none",background:"#181818",color:"white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,fontSize:20},children:"✕"}),f.jsxs("div",{style:{overflowY:"auto",maxHeight:"90vh"},children:[f.jsxs("div",{style:{position:"relative",width:"100%",aspectRatio:"16/9",background:"#0a0a0a"},children:[t?f.jsx("img",{src:t,alt:r.title||"Item",style:{width:"100%",height:"100%",objectFit:"cover"}}):f.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:f.jsx("span",{style:{fontSize:64,opacity:.2},children:"📄"})}),f.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"50%",background:"linear-gradient(to top, #181818 0%, transparent 100%)"}}),f.jsx("div",{style:{position:"absolute",bottom:24,left:32,right:32},children:f.jsx("h1",{style:{margin:0,fontSize:32,fontWeight:700,color:"white",textShadow:"0 2px 8px rgba(0,0,0,0.5)"},children:r.title||"Untitled"})})]}),f.jsxs("div",{style:{padding:"0 32px 32px"},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:16},children:[n&&f.jsx("span",{style:{color:"#a3a3a3",fontSize:15},children:n}),i&&f.jsx("span",{style:{color:"#737373",fontSize:14},children:i})]}),s&&f.jsx("p",{style:{margin:0,fontSize:15,lineHeight:1.6,color:"#d4d4d4"},children:s}),r.data&&Object.keys(r.data).length>0&&f.jsxs("div",{style:{marginTop:24},children:[f.jsx("h4",{style:{margin:"0 0 12px",fontSize:14,fontWeight:600,color:"#737373",textTransform:"uppercase",letterSpacing:1},children:"Details"}),f.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:12},children:Object.entries(r.data).filter(([o])=>!["image","poster","thumbnail","cover","photo","description","subtitle","synopsis","summary"].includes(o)).slice(0,8).map(([o,l])=>f.jsxs("div",{children:[f.jsx("span",{style:{color:"#737373",fontSize:12,textTransform:"capitalize"},children:o.replace(/_/g," ")}),f.jsx("p",{style:{margin:"4px 0 0",color:"#d4d4d4",fontSize:14},children:String(l)})]},o))})]})]})]})]})})}function Ug({nodes:r,lanes:e,cardAspectRatio:t="2:3",onNodeClick:n}){const[s,i]=y.useState(null),o=y.useMemo(()=>e.map(u=>({...u,nodes:r.filter(u.filter)})),[r,e]),l=u=>{n?n(u):i(u)},a=()=>{i(null)};return f.jsxs("div",{style:{minHeight:"100vh",background:"#141414",paddingTop:24,paddingBottom:48},children:[o.map(u=>f.jsx(Jc,{title:u.title,nodes:u.nodes,cardAspectRatio:t,onNodeClick:l},u.id)),o.every(u=>u.nodes.length===0)&&f.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,color:"#737373"},children:[f.jsx("span",{style:{fontSize:48,marginBottom:16},children:"📭"}),f.jsx("p",{style:{margin:0,fontSize:18},children:"No items to display"})]}),s&&f.jsx(Xc,{node:s,onClose:a})]})}const Wg={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function Hg(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function Vg(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function Gg(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function Kg({items:r,date:e,startHour:t=7,endHour:n=22,hourHeight:s=60,getItemTime:i,getItemDuration:o,getItemIsAllDay:l,getItemId:a,renderItem:u,onItemClick:c,onTimeSlotClick:d,showCurrentTime:h=!0,className:p="",theme:g={}}){const m={...Wg,...g},{allDayItems:x,timedItems:_}=y.useMemo(()=>{const v=[],T=[];for(const B of r)l(B)?v.push(B):T.push(B);return{allDayItems:v,timedItems:T}},[r,l]),b=y.useMemo(()=>{const v=[];for(let T=t;T<=n;T++)v.push(T);return v},[t,n]),C=(n-t+1)*s,S=y.useCallback(v=>{const T=i(v);if(!T)return null;const B=Hg(T);if(!B)return null;const{hours:j,minutes:N}=B,M=Math.max(t,Math.min(n,j)),R=j<t?0:N,w=(M-t)*s+R/60*s,D=o(v),F=Math.max(20,D/60*s);return{top:w,height:F}},[i,o,t,n,s]),k=y.useMemo(()=>{if(!h||!Gg(e))return null;const v=new Date,T=v.getHours(),B=v.getMinutes();return T<t||T>n?null:(T-t)*s+B/60*s},[e,h,t,n,s]),E=y.useCallback(v=>{if(!d)return;const T=v.currentTarget.getBoundingClientRect(),j=(v.clientY-T.top)/s*60,N=Math.floor(j/60)+t,M=Math.round(j%60/15)*15,R=Math.min(n,Math.max(t,N)),w=M>=60?0:M,D=`${R.toString().padStart(2,"0")}:${w.toString().padStart(2,"0")}`;d(D)},[d,s,t,n]);return f.jsxs("div",{className:p,style:{background:m.background},children:[x.length>0&&f.jsxs("div",{style:{padding:"8px 0 8px 60px",borderBottom:`1px solid ${m.allDayBorder}`,background:m.allDayBackground},children:[f.jsx("div",{style:{fontSize:"11px",color:m.hourTextColor,marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"All Day"}),f.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:x.map(v=>f.jsx("div",{onClick:()=>c==null?void 0:c(v),style:{cursor:c?"pointer":"default"},children:u(v)},a(v)))})]}),f.jsxs("div",{style:{position:"relative",height:C},children:[b.map((v,T)=>f.jsxs("div",{style:{position:"absolute",top:T*s,left:0,right:0},children:[f.jsx("div",{style:{position:"absolute",left:0,top:-8,width:"50px",textAlign:"right",paddingRight:"10px",fontSize:"11px",color:m.hourTextColor},children:Vg(v)}),f.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),T<b.length-1&&f.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:s/2,height:"1px",background:m.halfHourLineColor}})]},v)),f.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:d?"pointer":"default"},onClick:E}),k!==null&&f.jsxs("div",{style:{position:"absolute",left:"55px",right:0,top:k,zIndex:20,pointerEvents:"none"},children:[f.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",background:m.currentTimeColor,marginLeft:"-5px",marginTop:"-5px",position:"absolute"}}),f.jsx("div",{style:{marginLeft:"5px",height:"2px",background:m.currentTimeColor}})]}),_.map(v=>{const T=S(v);return T?f.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:T.top,height:T.height,zIndex:10,cursor:c?"pointer":"default"},onClick:B=>{B.stopPropagation(),c==null||c(v)},children:u(v)},a(v)):null})]})]})}function Zc({onComplete:r,onCancel:e,onTranscribe:t,onTranscriptionComplete:n,variant:s="widget",hideSaveButton:i=!1,maxDuration:o=180}){const l=s==="widget",[a,u]=y.useState("idle"),[c,d]=y.useState(0),[h,p]=y.useState(0),[g,m]=y.useState(!1),[x,_]=y.useState(0),[b,C]=y.useState(null),[S,k]=y.useState(!1),[E,v]=y.useState(null),[T,B]=y.useState(!0),[j,N]=y.useState([]),[M,R]=y.useState({completed:0,total:0}),w=y.useRef(!1),D=y.useRef(!0);y.useEffect(()=>{D.current=T},[T]);const F=y.useRef(null),I=y.useRef(null),U=y.useRef(null),J=y.useRef(null),te=y.useRef(null),W=y.useRef([]),V=y.useRef(null),H=y.useRef(null),ne=y.useRef(null),ce=y.useRef(null),le=y.useRef(!1),pe=y.useRef([]),be=y.useRef(null),Te=y.useRef(null),$=y.useRef([]),ke=y.useRef([]),se=y.useRef("insert"),Re=y.useRef(!1),Ce=y.useRef(0),Ee=y.useRef(0),Se=y.useRef(0),Fe=X=>{const P=Math.floor(X/60),ue=Math.floor(X%60);return`${P.toString().padStart(2,"0")}:${ue.toString().padStart(2,"0")}`},ze=async X=>{const P=await X.arrayBuffer(),ue=new AudioContext,ye=await ue.decodeAudioData(P);return await ue.close(),ye},ge=X=>{const P=X.numberOfChannels,ue=X.sampleRate,ye=1,Y=16,Ne=Y/8,Ae=P*Ne,De=ue*Ae,$e=X.length*Ae,Ue=new ArrayBuffer(44+$e),we=new DataView(Ue),je=(he,de)=>{for(let Ve=0;Ve<de.length;Ve++)we.setUint8(he+Ve,de.charCodeAt(Ve))};je(0,"RIFF"),we.setUint32(4,36+$e,!0),je(8,"WAVE"),je(12,"fmt "),we.setUint32(16,16,!0),we.setUint16(20,ye,!0),we.setUint16(22,P,!0),we.setUint32(24,ue,!0),we.setUint32(28,De,!0),we.setUint16(32,Ae,!0),we.setUint16(34,Y,!0),je(36,"data"),we.setUint32(40,$e,!0);const z=[];for(let he=0;he<P;he++)z.push(X.getChannelData(he));let xe=44;for(let he=0;he<X.length;he++)for(let de=0;de<P;de++){const Ve=Math.max(-1,Math.min(1,z[de][he])),st=Ve<0?Ve*32768:Ve*32767;we.setInt16(xe,st,!0),xe+=2}return new Blob([Ue],{type:"audio/wav"})},L=async(X,P,ue,ye)=>{const Y=new AudioContext,Ne=X.sampleRate,Ae=Math.max(X.numberOfChannels,P.numberOfChannels),De=Math.min(ue,X.length),$e=Math.max(0,X.length-ue),Ue=ye==="insert"?De+P.length+$e:De+P.length,we=Y.createBuffer(Ae,Ue,Ne);for(let je=0;je<Ae;je++){const z=we.getChannelData(je),xe=je<X.numberOfChannels?X.getChannelData(je):X.getChannelData(0);for(let de=0;de<De;de++)z[de]=xe[de];const he=je<P.numberOfChannels?P.getChannelData(je):P.getChannelData(0);for(let de=0;de<P.length;de++)z[De+de]=he[de];if(ye==="insert")for(let de=0;de<$e;de++)z[De+P.length+de]=xe[ue+de]}return await Y.close(),we},Me=y.useCallback(()=>{const X=F.current;if(!X)return;const P=X.getContext("2d");if(!P)return;const ue=X.getBoundingClientRect(),ye=ue.width,Y=ue.height,Ne=pe.current,Ae=h||c||1,De=a==="recording"?c:x;P.fillStyle="#2d3b35",P.fillRect(0,0,ye,Y);const $e=8,Ue="rgba(0, 0, 0, 0.4)",we=P.createLinearGradient(0,0,0,$e);we.addColorStop(0,Ue),we.addColorStop(1,"transparent"),P.fillStyle=we,P.fillRect(0,0,ye,$e);const je=P.createLinearGradient(0,Y-$e,0,Y);je.addColorStop(0,"transparent"),je.addColorStop(1,Ue),P.fillStyle=je,P.fillRect(0,Y-$e,ye,$e);const z=P.createLinearGradient(0,0,$e,0);z.addColorStop(0,Ue),z.addColorStop(1,"transparent"),P.fillStyle=z,P.fillRect(0,0,$e,Y);const xe=P.createLinearGradient(ye-$e,0,ye,0);xe.addColorStop(0,"transparent"),xe.addColorStop(1,Ue),P.fillStyle=xe,P.fillRect(ye-$e,0,$e,Y),P.strokeStyle="#5a6b62",P.lineWidth=1,P.beginPath(),P.moveTo(0,Y/2),P.lineTo(ye,Y/2),P.stroke();const he=ye/2;if(Ne.length>0)if(a==="recording")for(let st=0;st<Ne.length;st++){const vt=Ne.length-1-st,jt=he-vt*4;if(jt<-3||jt>ye)continue;const Mt=Ne[st]*(Y/2-12),A=Y/2-Mt;P.fillStyle="#10b981",P.fillRect(jt,A,3,Mt*2)}else{const st=Ae>0?De/Ae*Ne.length:0;for(let vt=0;vt<Ne.length;vt++){const jt=st-vt,Mt=he-jt*4;if(Mt<-3||Mt>ye)continue;const A=Ne[vt]*(Y/2-12),q=Y/2-A;P.fillStyle=vt<=st?"#10b981":"#4b5563",P.fillRect(Mt,q,3,A*2)}}P.strokeStyle="#ef4444",P.lineWidth=1,P.beginPath(),P.moveTo(he,0),P.lineTo(he,Y),P.stroke(),P.fillStyle="#fff",P.font="bold 18px monospace",P.textAlign="center",P.fillText(Fe(De),he,Y-6),a==="recording"&&(P.fillStyle="#ef4444",P.beginPath(),P.arc(20,20,8,0,Math.PI*2),P.fill(),P.fillStyle="#fff",P.font="10px sans-serif",P.textAlign="left",P.fillText("REC",34,24)),P.textAlign="left"},[a,x,c,h]),Qe=()=>{const X=te.current;if(!X||!le.current)return;const P=X.frequencyBinCount,ue=new Uint8Array(P);X.getByteTimeDomainData(ue);let ye=0;for(let Ae=0;Ae<P;Ae++){const De=(ue[Ae]-128)/128;ye+=De*De}const Y=Math.sqrt(ye/P),Ne=Math.min(1,Y*3);pe.current.push(Ne),Me(),le.current&&(H.current=requestAnimationFrame(Qe))},G=async()=>{try{C(null),k(!1),be.current===null&&(pe.current=[]);const X=await navigator.mediaDevices.getUserMedia({audio:!0});U.current=X;const P=new AudioContext;J.current=P;const ue=P.createAnalyser();ue.fftSize=2048,te.current=ue,P.createMediaStreamSource(X).connect(ue);const Y=new MediaRecorder(X);I.current=Y,W.current=[],Y.ondataavailable=Ne=>{Ne.data.size>0&&W.current.push(Ne.data)},Y.onstop=async()=>{try{if(le.current=!1,W.current.length===0){C("No audio was recorded. Please try again."),u("idle"),X.getTracks().forEach(we=>we.stop());return}const Ne=new Blob(W.current,{type:"audio/webm"});let Ae,De;if(be.current!==null&&Te.current)try{const we=await ze(Ne),je=Te.current.sampleRate,z=Math.floor(be.current*je),xe=await L(Te.current,we,z,se.current);Ae=ge(xe),De=xe.length/xe.sampleRate,se.current==="insert"&&(pe.current=[...pe.current,...ke.current]),be.current=null,Te.current=null,$.current=[],ke.current=[]}catch{Ae=Ne,De=Ce.current>0?Ce.current:1}else Ae=Ne,De=Ce.current>0?Ce.current:1;if(ce.current=Ae,X.getTracks().forEach(we=>we.stop()),D.current&&t){N(we=>[...we,Ae]),R(we=>({...we,total:we.total+1})),ce.current=null,pe.current=[],_(0),p(0),d(0),u("idle");return}const $e=URL.createObjectURL(Ae),Ue=new Audio($e);Ue.ontimeupdate=()=>{_(Ue.currentTime)},Ue.onended=()=>{m(!1)},ne.current=Ue,p(De),_(De),u("editing")}catch{C("Failed to process recording"),u("idle")}},Y.start(100),le.current=!0,u("recording"),d(0),Ce.current=0,V.current=setInterval(()=>{Ce.current+=1,d(Ce.current),Ce.current>=o&&(I.current&&I.current.state!=="inactive"&&I.current.stop(),le.current=!1,v(null),V.current&&(clearInterval(V.current),V.current=null),H.current&&(cancelAnimationFrame(H.current),H.current=null),setTimeout(()=>{alert(`Maximum recording time of ${Math.floor(o/60)} minutes reached.`)},100))},1e3)}catch{C("Could not access microphone. Please allow microphone access.")}},ee=()=>{le.current=!1,k(!1),v(null),H.current&&(cancelAnimationFrame(H.current),H.current=null),V.current&&(clearInterval(V.current),V.current=null),I.current&&I.current.state!=="inactive"&&I.current.stop()},me=X=>{const P=F.current;if(!P)return;const ue=h||c;if(ue<=0)return;const ye=pe.current;if(ye.length===0)return;const Y=P.getBoundingClientRect(),Ne=X-Ee.current,Ae=4,De=Y.width/P.width,$e=ye.length/ue*Ae,Ue=-Ne/($e*De),we=Se.current+Ue,je=Math.max(0,Math.min(we,ue));ne.current&&(ne.current.currentTime=je),_(je)},_e=()=>{ne.current&&(ne.current.currentTime=0),_(0)},Be=()=>{const X=h||c;ne.current&&(ne.current.currentTime=X),_(X)},Xe=()=>{const X=ne.current;X&&(g?(X.pause(),_(X.currentTime),m(!1)):(X.currentTime=x,X.play().catch(()=>{}),m(!0)))},bt=async X=>{if(!ce.current){G();return}try{ne.current&&(ne.current.pause(),m(!1)),se.current=X,Te.current=await ze(ce.current);const P=h||c;be.current=x;const ue=P>0?x/P:0,ye=Math.floor(ue*pe.current.length);$.current=pe.current.slice(0,ye),ke.current=pe.current.slice(ye),pe.current=[...$.current],G()}catch{C("Failed to prepare recording. Please try again.")}},oe=()=>{ne.current&&(ne.current.pause(),ne.current=null),ce.current=null,Te.current=null,be.current=null,$.current=[],m(!1),_(0),p(0),d(0),G()},fe=()=>{ce.current?r(ce.current,h||c):alert("No audio recorded yet!")};y.useEffect(()=>{a==="recording"&&F.current&&te.current&&le.current&&(H.current=requestAnimationFrame(Qe))},[a]),y.useEffect(()=>{const X=F.current;if(!X)return;const P=()=>{const ue=window.devicePixelRatio||1,ye=X.getBoundingClientRect();X.width=ye.width*ue,X.height=ye.height*ue;const Y=X.getContext("2d");Y&&Y.scale(ue,ue)};return P(),window.addEventListener("resize",P),()=>window.removeEventListener("resize",P)},[]),y.useEffect(()=>{if(a==="idle"){const X=F.current;if(!X)return;const P=X.getContext("2d");if(!P)return;const ue=X.getBoundingClientRect(),ye=ue.width,Y=ue.height;P.fillStyle="#2d3b35",P.fillRect(0,0,ye,Y);const Ne=8,Ae="rgba(0, 0, 0, 0.4)",De=P.createLinearGradient(0,0,0,Ne);De.addColorStop(0,Ae),De.addColorStop(1,"transparent"),P.fillStyle=De,P.fillRect(0,0,ye,Ne);const $e=P.createLinearGradient(0,Y-Ne,0,Y);$e.addColorStop(0,"transparent"),$e.addColorStop(1,Ae),P.fillStyle=$e,P.fillRect(0,Y-Ne,ye,Ne);const Ue=P.createLinearGradient(0,0,Ne,0);Ue.addColorStop(0,Ae),Ue.addColorStop(1,"transparent"),P.fillStyle=Ue,P.fillRect(0,0,Ne,Y);const we=P.createLinearGradient(ye-Ne,0,ye,0);we.addColorStop(0,"transparent"),we.addColorStop(1,Ae),P.fillStyle=we,P.fillRect(ye-Ne,0,Ne,Y),P.strokeStyle="#5a6b62",P.lineWidth=1,P.beginPath(),P.moveTo(0,Y/2),P.lineTo(ye,Y/2),P.stroke();const je=ye/2;P.strokeStyle="#ef4444",P.lineWidth=1,P.beginPath(),P.moveTo(je,0),P.lineTo(je,Y),P.stroke(),P.fillStyle="#fff",P.font="bold 18px monospace",P.textAlign="center",P.fillText("00:00",je,Y-6)}},[a]);const Je=y.useCallback(X=>{N(P=>[...P,X]),R(P=>({...P,total:P.total+1}))},[]);if(y.useEffect(()=>{(async()=>{if(w.current||j.length===0||!t)return;w.current=!0;const P=j[0];try{const ue=await t(P);ue&&n&&n(ue)}catch(ue){console.error("Transcription failed:",ue)}finally{N(ue=>ue.slice(1)),R(ue=>({...ue,completed:ue.completed+1})),w.current=!1}})()},[j,t,n]),y.useEffect(()=>()=>{le.current=!1,V.current&&clearInterval(V.current),H.current&&cancelAnimationFrame(H.current),U.current&&U.current.getTracks().forEach(X=>X.stop()),J.current&&J.current.state!=="closed"&&J.current.close()},[]),y.useEffect(()=>{if(a==="editing"&&g){let X;const P=()=>{const ue=ne.current;if(ue&&g){const ye=F.current;if(ye){const Y=ye.getContext("2d");if(Y){const Ne=ye.getBoundingClientRect(),Ae=Ne.width,De=Ne.height,$e=pe.current,Ue=h||c||1,we=ue.currentTime;Y.fillStyle="#2d3b35",Y.fillRect(0,0,Ae,De);const je=8,z="rgba(0, 0, 0, 0.4)",xe=Y.createLinearGradient(0,0,0,je);xe.addColorStop(0,z),xe.addColorStop(1,"transparent"),Y.fillStyle=xe,Y.fillRect(0,0,Ae,je);const he=Y.createLinearGradient(0,De-je,0,De);he.addColorStop(0,"transparent"),he.addColorStop(1,z),Y.fillStyle=he,Y.fillRect(0,De-je,Ae,je);const de=Y.createLinearGradient(0,0,je,0);de.addColorStop(0,z),de.addColorStop(1,"transparent"),Y.fillStyle=de,Y.fillRect(0,0,je,De);const Ve=Y.createLinearGradient(Ae-je,0,Ae,0);Ve.addColorStop(0,"transparent"),Ve.addColorStop(1,z),Y.fillStyle=Ve,Y.fillRect(Ae-je,0,je,De),Y.strokeStyle="#5a6b62",Y.lineWidth=1,Y.beginPath(),Y.moveTo(0,De/2),Y.lineTo(Ae,De/2),Y.stroke();const st=Ae/2,vt=3,jt=4,Mt=Ue>0?we/Ue*$e.length:0;for(let re=0;re<$e.length;re++){const ve=Mt-re,Oe=st-ve*jt;if(Oe<-vt||Oe>Ae)continue;const He=$e[re]*(De/2-12),Pe=De/2-He;Y.fillStyle=re<=Mt?"#10b981":"#4b5563",Y.fillRect(Oe,Pe,vt,He*2)}Y.strokeStyle="#ef4444",Y.lineWidth=1,Y.beginPath(),Y.moveTo(st,0),Y.lineTo(st,De),Y.stroke(),Y.fillStyle="#fff",Y.font="bold 18px monospace",Y.textAlign="center";const A=Math.floor(we/60),q=Math.floor(we%60);Y.fillText(`${A.toString().padStart(2,"0")}:${q.toString().padStart(2,"0")}`,st,De-6),Y.textAlign="left"}}X=requestAnimationFrame(P)}};return X=requestAnimationFrame(P),()=>cancelAnimationFrame(X)}},[a,g,h,c]),y.useEffect(()=>{a==="editing"&&!g&&Me()},[a,x,g,Me]),b)return f.jsxs("div",{style:{border:"1px solid #fecaca",borderRadius:"12px",padding:"16px",background:"#fef2f2"},children:[f.jsx("p",{style:{fontSize:"14px",color:"#dc2626",marginBottom:"12px"},children:b}),f.jsx("button",{onClick:()=>{C(null),G()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const Ke={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},Ye={...Ke,opacity:.3,cursor:"not-allowed"},pt=l?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",flexShrink:0};return f.jsxs("div",{style:pt,children:[f.jsx("canvas",{ref:F,style:{width:"100%",height:"32px",cursor:"pointer",flexShrink:0},onMouseDown:X=>{if(a==="editing"){Re.current=!0,Ee.current=X.clientX,Se.current=x;const P=ye=>{Re.current&&me(ye.clientX)},ue=()=>{Re.current=!1,window.removeEventListener("mousemove",P),window.removeEventListener("mouseup",ue)};window.addEventListener("mousemove",P),window.addEventListener("mouseup",ue)}}}),f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:l?"6px 8px":"4px",borderTop:"1px solid #d4d4d4",background:"linear-gradient(to bottom, #e0e0e0 0%, #c8c8c8 100%)",boxShadow:"inset 0 1px 0 rgba(255,255,255,0.6), inset 0 -1px 0 rgba(0,0,0,0.1)",flexShrink:0},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[f.jsx("button",{onClick:_e,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?Ye:Ke,title:"Go to start",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"first_page"})}),f.jsx("button",{onClick:()=>{if(a==="recording"){const X=I.current;X&&(X.state==="recording"?(X.pause(),k(!0)):X.state==="paused"&&(X.resume(),k(!1)))}else Xe()},disabled:a==="idle",style:a==="idle"?Ye:Ke,title:g||a==="recording"&&!S?"Pause":"Play",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:g||a==="recording"&&!S?"pause":"play_arrow"})}),f.jsx("button",{onClick:Be,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?Ye:Ke,title:"Go to end",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"last_page"})}),f.jsx("div",{style:{width:"1px",height:"24px",margin:"0 4px",background:"linear-gradient(to bottom, rgba(255,255,255,0.5), rgba(0,0,0,0.15))"}}),f.jsx("button",{onClick:()=>{E==="insert"?ee():a==="idle"?(v("insert"),G()):a==="editing"&&(v("insert"),bt("insert"))},disabled:a==="recording"&&E!=="insert"||g,style:a==="recording"&&E!=="insert"||g?Ye:Ke,title:E==="insert"?"Stop recording":"Insert recording",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E==="insert"?"#ef4444":"#171717"},children:"add"})}),f.jsx("button",{onClick:()=>{D.current||(E==="mic"?ee():a==="idle"?(v("mic"),G()):a==="editing"&&(v("mic"),bt("replace")))},onMouseDown:()=>{D.current&&a==="idle"&&!g&&(v("mic"),G())},onMouseUp:()=>{D.current&&a==="recording"&&E==="mic"&&ee()},onMouseLeave:()=>{D.current&&a==="recording"&&E==="mic"&&ee()},onTouchStart:X=>{X.preventDefault(),D.current&&a==="idle"&&!g&&(v("mic"),G())},onTouchEnd:X=>{X.preventDefault(),D.current&&a==="recording"&&E==="mic"&&ee()},disabled:a==="recording"&&E!=="mic"||g,style:a==="recording"&&E!=="mic"||g?Ye:Ke,title:T?"Hold to record (walkie-talkie)":E==="mic"?"Stop recording":"Record",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E==="mic"?"#ef4444":"#171717"},children:"mic"})}),f.jsx("button",{onClick:()=>{a==="idle"&&!g?(v("round"),G()):a==="recording"&&E==="round"&&ee()},disabled:a==="editing"||a==="recording"&&E!=="round"||g,style:a==="editing"||a==="recording"&&E!=="round"||g?Ye:{...Ke,width:"28px",height:"28px",borderRadius:"50%",padding:0},title:"Click to record / click to stop",children:f.jsx("span",{style:{display:"block",width:"14px",height:"14px",borderRadius:"50%",background:a==="recording"&&E==="round"?"#171717":"#ef4444",transition:"background 0.15s"}})}),f.jsx("button",{onClick:()=>{E==="startover"?ee():a==="editing"&&(v("startover"),oe())},disabled:a==="idle"||a==="recording"&&E!=="startover"||g,style:a==="idle"||a==="recording"&&E!=="startover"||g?Ye:Ke,title:E==="startover"?"Stop recording":"Start over",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E==="startover"?"#ef4444":"#171717"},children:"refresh"})})]}),f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[M.total>0&&M.completed<M.total&&f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",background:"rgba(16, 185, 129, 0.1)",borderRadius:"4px",fontSize:"11px",color:"#10b981"},children:[f.jsx("span",{className:"material-icons",style:{fontSize:"14px",animation:"spin 1s linear infinite"},children:"sync"}),M.completed,"/",M.total]}),t&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginRight:"4px"},children:[f.jsx("button",{onClick:()=>B(!T),style:{width:"28px",height:"16px",borderRadius:"8px",border:"none",background:T?"#10b981":"#9ca3af",cursor:"pointer",position:"relative",transition:"background 0.2s",padding:0},title:T?"Auto-transcribe ON":"Auto-transcribe OFF",children:f.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"50%",background:"white",position:"absolute",top:"2px",left:T?"14px":"2px",transition:"left 0.2s",boxShadow:"0 1px 2px rgba(0,0,0,0.2)"}})}),f.jsx("span",{style:{fontSize:"10px",color:"#666"},children:"auto"})]}),f.jsx("button",{onClick:()=>{a==="editing"&&ce.current&&Je(ce.current)},disabled:a!=="editing",style:a!=="editing"?Ye:Ke,title:"Transcribe audio",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:T?"#10b981":"#171717"},children:"subtitles"})})]}),!i&&f.jsx("button",{onClick:fe,disabled:a!=="editing",style:a!=="editing"?Ye:Ke,title:"Save recording",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"save"})})]})]}),M.total>0&&M.completed<M.total&&f.jsx("div",{style:{height:"3px",background:"#e5e5e5",overflow:"hidden"},children:f.jsx("div",{style:{height:"100%",background:"#10b981",width:`${M.completed/M.total*100}%`,transition:"width 0.3s ease"}})})]})}function Yg({label:r,value:e,onChange:t,onTranscribe:n,onAIAction:s,onAIPrompt:i,onAudioSave:o,placeholder:l="Type or record...",className:a="",rows:u,llmClient:c,graphClient:d,nodeId:h,audioFilename:p,existingAudio:g,existingVoice:m,onAudioGenerated:x,onGenerateTTS:_,audioUrl:b,voice:C="coral",onVoiceChange:S,generateButton:k,generatePrompt:E,generateSourceText:v,generateSourceError:T}){const[B,j]=y.useState(!1),[N,M]=y.useState(null),[R,w]=y.useState(!1),[D,F]=y.useState(""),[I,U]=y.useState(!1),[J,te]=y.useState(!1),[W,V]=y.useState(null),[H,ne]=y.useState(m||C),[ce,le]=y.useState(g),[pe,be]=y.useState(Date.now()),Te=y.useRef(null),$=y.useRef(null),ke=!!(c&&d&&h&&p);y.useEffect(()=>{g!==void 0&&le(g)},[g]),y.useEffect(()=>{m!==void 0&&ne(m)},[m]);const se=ke&&ce&&d&&h?`${d.getFileUrl(h,ce)}?v=${pe}`:b,Re=L=>{t(e?`${e}
183
+ `})]})}const Rg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function Fg({options:r,value:e,onChange:t,placeholder:n="Search or select...",allowCreate:s=!0,onCreate:i,allowDelete:o=!1,onDelete:a,label:l,disabled:u=!1,max:c=0,theme:d={},className:h=""}){const p={...Rg,...d},[g,m]=y.useState(!1),[x,_]=y.useState(""),b=y.useRef(null),S=y.useRef(null);y.useEffect(()=>{function N(R){b.current&&!b.current.contains(R.target)&&(m(!1),_(""))}return document.addEventListener("mousedown",N),()=>document.removeEventListener("mousedown",N)},[]);const C=r.filter(N=>{var R;return((R=N.label)==null?void 0:R.toLowerCase().includes(x.toLowerCase()))&&!e.includes(N.id)}),k=s&&x.trim()&&!r.some(N=>{var R;return((R=N.label)==null?void 0:R.toLowerCase())===x.toLowerCase()}),E=e.map(N=>r.find(R=>R.id===N)).filter(Boolean),v=y.useCallback(N=>{var R;c>0&&e.length>=c||(t([...e,N]),_(""),c===1?m(!1):(R=S.current)==null||R.focus())},[e,t,c]),T=y.useCallback(N=>{t(e.filter(R=>R!==N))},[e,t]),B=y.useCallback(async()=>{if(!k)return;const N=await(i==null?void 0:i(x.trim()));N&&v(N.id),_("")},[k,x,i,v]),j=y.useCallback(N=>{N.key==="Enter"?(N.preventDefault(),k?B():C.length>0&&v(C[0].id)):N.key==="Backspace"&&!x&&e.length>0?T(e[e.length-1]):N.key==="Escape"&&(m(!1),_(""))},[k,C,x,e,B,v,T]);return f.jsxs("div",{ref:b,className:h,style:{position:"relative"},children:[l&&f.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:p.textSecondary,marginBottom:"4px"},children:l}),f.jsxs("div",{onClick:()=>!u&&m(!0),style:{display:"flex",flexWrap:"wrap",gap:"6px",padding:"8px 12px",border:`1px solid ${g?p.primary:p.border}`,borderRadius:"8px",background:u?p.hoverBackground:p.background,cursor:u?"not-allowed":"text",minHeight:"42px",alignItems:"center"},children:[E.map(N=>f.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:N.color||p.chipBackground,color:N.color?"#fff":p.chipText},children:[N.label,!u&&f.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),T(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},N.id)),f.jsx("input",{ref:S,type:"text",value:x,onChange:N=>{_(N.target.value),g||m(!0)},onFocus:()=>m(!0),onKeyDown:j,placeholder:E.length===0?n:"",disabled:u||c>0&&e.length>=c,style:{flex:1,minWidth:"60px",border:"none",outline:"none",fontSize:"14px",background:"transparent",color:p.text}})]}),g&&!u&&f.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",background:p.background,border:`1px solid ${p.border}`,borderRadius:"8px",boxShadow:"0 4px 12px rgba(0,0,0,0.1)",maxHeight:"200px",overflowY:"auto",zIndex:50},children:C.length===0&&!k?f.jsx("div",{style:{padding:"12px",fontSize:"14px",color:p.textSecondary,textAlign:"center"},children:x?"No matches":"No options available"}):f.jsxs(f.Fragment,{children:[C.map(N=>f.jsxs("div",{onClick:()=>v(N.id),style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.text,display:"flex",alignItems:"center",justifyContent:"space-between"},onMouseEnter:R=>{R.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:R=>{R.currentTarget.style.background=""},children:[N.label,o&&a&&f.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),a(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",fontSize:"14px",color:p.textSecondary,opacity:.5},onMouseEnter:R=>{R.currentTarget.style.opacity="1",R.currentTarget.style.color="#ef4444"},onMouseLeave:R=>{R.currentTarget.style.opacity="0.5",R.currentTarget.style.color=p.textSecondary||""},children:"×"})]},N.id)),k&&f.jsxs("div",{onClick:B,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.primary,borderTop:C.length>0?`1px solid ${p.border}`:"none"},onMouseEnter:N=>{N.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:N=>{N.currentTarget.style.background=""},children:['+ Create "',x.trim(),'"']})]})})]})}const Lg={background:"#f9fafb",cardBackground:"#ffffff",cardHover:"#f3f4f6",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#374151"},Kc=y.forwardRef(({filteredOptions:r,search:e,theme:t,maxHeight:n,onCardClick:s},i)=>{const o=y.useRef(null),[a,l]=y.useState(typeof n=="number"?`${n}px`:n);return y.useEffect(()=>{const u=o.current;if(!u)return;const c=u.getBoundingClientRect(),d=window.innerHeight-c.top-16;l(`${Math.max(120,Math.min(d,typeof n=="number"?n:9999))}px`)},[n,r.length]),y.useEffect(()=>{typeof i=="function"?i(o.current):i&&(i.current=o.current)}),f.jsx("div",{ref:o,style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",maxHeight:a,overflowY:"auto",border:`1px solid ${t.border}`,borderRadius:"8px",background:t.background,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",zIndex:50},children:r.length===0?f.jsx("div",{style:{padding:"16px",textAlign:"center",color:t.textSecondary,fontSize:"14px"},children:e?`No results for "${e}"`:"No items"}):r.map((u,c)=>f.jsxs("div",{onClick:()=>s(u),style:{padding:"10px 14px",cursor:"pointer",borderBottom:c<r.length-1?`1px solid ${t.border}`:"none",background:t.cardBackground,transition:"background 0.15s",display:"flex",alignItems:"center",gap:"10px"},onMouseEnter:d=>{d.currentTarget.style.background=t.cardHover||"#f3f4f6"},onMouseLeave:d=>{d.currentTarget.style.background=t.cardBackground||"#f9fafb"},children:[u.icon&&f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:u.color||t.textSecondary,flexShrink:0},children:u.icon}),f.jsxs("div",{style:{flex:1,minWidth:0},children:[f.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:u.color||t.text,marginBottom:u.notes?"2px":0,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:u.label}),u.notes&&f.jsx("div",{style:{fontSize:"12px",color:t.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:u.notes})]})]},u.id))})});Kc.displayName="DropdownList";function Pg({options:r,value:e,type:t,placeholder:n="Search...",onItemClick:s,onClear:i,onCreate:o,maxHeight:a=300,className:l="",theme:u={}}){const c={...Lg,...u},[d,h]=y.useState(""),[p,g]=y.useState(!1),m=y.useRef(null),x=y.useRef(null),_=y.useRef(null),b=y.useMemo(()=>e&&r.find(B=>B.id===e)||null,[e,r]),S=y.useMemo(()=>{if(!d.trim())return r;const B=d.toLowerCase();return r.filter(j=>{var N,R;return((N=j.label)==null?void 0:N.toLowerCase().includes(B))||((R=j.notes)==null?void 0:R.toLowerCase().includes(B))})},[r,d]);y.useEffect(()=>{const B=j=>{m.current&&!m.current.contains(j.target)&&g(!1)};return document.addEventListener("mousedown",B),()=>document.removeEventListener("mousedown",B)},[]);const C=B=>{s&&s(B),g(!1),h("")},k=()=>{o&&o(d.trim()||void 0),g(!1),h("")},E=()=>{g(!0)},v=B=>{h(B.target.value),p||g(!0)},T=B=>{B.key==="Enter"?(B.preventDefault(),S.length>0&&s?(s(S[0]),g(!1),h("")):o&&d.trim()&&(o(d.trim()),g(!1),h(""))):B.key==="Escape"&&(g(!1),h(""))};return f.jsxs("div",{ref:m,className:`combostack ${l}`,style:{position:"relative",width:"100%",height:"32px"},children:[f.jsxs("div",{style:{display:"flex",gap:"8px",alignItems:"center",height:"100%"},children:[f.jsx("div",{style:{flex:1,position:"relative"},children:b&&!p?f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"0 10px",fontSize:"13px",border:`1px solid ${c.border}`,borderRadius:"8px",background:c.background,color:c.text,cursor:"pointer",height:"32px",boxSizing:"border-box"},onClick:()=>g(!0),children:[f.jsxs("div",{style:{overflow:"hidden"},children:[f.jsx("div",{style:{fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:b.label}),b.notes&&f.jsx("div",{style:{fontSize:"11px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:b.notes})]}),i&&f.jsx("button",{onClick:B=>{B.stopPropagation(),i()},style:{marginLeft:"8px",padding:"2px",background:"none",border:"none",cursor:"pointer",color:c.textSecondary,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:"50%",flexShrink:0},title:"Clear selection",children:f.jsx("span",{className:"material-icons",style:{fontSize:"16px"},children:"close"})})]}):f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"material-icons",style:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",color:c.textSecondary,fontSize:"16px",pointerEvents:"none"},children:"search"}),f.jsx("input",{ref:x,type:"text",value:d,onChange:v,onFocus:E,onKeyDown:T,placeholder:n,style:{width:"100%",height:"32px",padding:"0 12px 0 36px",fontSize:"13px",border:`1px solid ${p?c.primary:c.border}`,borderRadius:"8px",background:c.background,color:c.text,outline:"none",boxSizing:"border-box",transition:"border-color 0.15s"}})]})}),o&&f.jsx("button",{onClick:k,style:{display:"flex",alignItems:"center",justifyContent:"center",background:"none",border:"none",color:c.text,cursor:"pointer",padding:"4px",borderRadius:"4px",transition:"opacity 0.15s",flexShrink:0,opacity:.7},onMouseEnter:B=>{B.currentTarget.style.opacity="1"},onMouseLeave:B=>{B.currentTarget.style.opacity="0.7"},title:`Create ${t||"item"}`,children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:"add"})})]}),p&&f.jsx(Kc,{ref:_,filteredOptions:S,search:d,theme:c,maxHeight:a,onCardClick:C})]})}function Ig({items:r,columns:e,getItemId:t,getItemColumn:n,getItemOrder:s,renderItem:i,onItemMove:o,onItemReorder:a,onItemClick:l,renderColumnHeader:u,renderColumnFooter:c,className:d="",columnClassName:h="",columnStyle:p,itemClassName:g=""}){const[m,x]=y.useState(null),[_,b]=y.useState(null),[S,C]=y.useState(null),k=y.useRef(null),E=e.reduce((M,w)=>{let D=r.filter(F=>n(F)===w.id);return s&&(D=D.sort((F,z)=>s(F)-s(z))),M[w.id]=D,M},{}),v=y.useCallback((M,w)=>{const D=t(w),F=n(w);x(D),k.current=F,M.dataTransfer.effectAllowed="move",M.dataTransfer.setData("text/plain",D),requestAnimationFrame(()=>{const z=M.target;z.style.opacity="0.5"})},[t,n]),T=y.useCallback(M=>{const w=M.target;w.style.opacity="1",x(null),b(null),C(null),k.current=null},[]),B=y.useCallback((M,w,D)=>{M.preventDefault(),M.dataTransfer.dropEffect="move",b(w),C(D)},[]),j=y.useCallback(M=>{const w=M.relatedTarget;w!=null&&w.closest("[data-kanban-column]")||(b(null),C(null))},[]),N=y.useCallback((M,w,D)=>{if(M.preventDefault(),!m)return;const F=k.current;F===w?a==null||a(m,w,D):F&&o(m,F,w,D),x(null),b(null),C(null),k.current=null},[m,o,a]),R=(M,w)=>f.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[M.color&&f.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:M.color}}),f.jsx("span",{className:"font-medium text-sm text-neutral-700",children:M.label})]}),f.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:w})]});return f.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 h-full ${d}`,style:{alignItems:"flex-start"},children:e.map(M=>{const w=E[M.id]||[],D=_===M.id,F=w.length>0||D;return f.jsxs("div",{"data-kanban-column":M.id,className:`flex-1 min-w-[180px] rounded-xl flex flex-col ${h||"bg-neutral-50"}`,style:{...p,maxHeight:"100%",...F?{}:{}},onDragOver:z=>{z.preventDefault(),m&&!D&&b(M.id)},onDragLeave:j,onDrop:z=>N(z,M.id,S??w.length),children:[f.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(M,w.length):R(M,w.length)}),f.jsxs("div",{className:`overflow-y-auto p-2 space-y-2 transition-colors ${D?"bg-blue-50":""}`,style:{minHeight:F?100:40},children:[w.map((z,q)=>{const J=t(z),te=m===J,W=D&&S===q&&!te;return f.jsxs("div",{children:[W&&f.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),f.jsx("div",{draggable:!0,onDragStart:G=>v(G,z),onDragEnd:T,onDragOver:G=>B(G,M.id,q),onClick:()=>l==null?void 0:l(z),className:`cursor-grab active:cursor-grabbing transition-all ${te?"opacity-50 scale-95":""} ${g}`,children:i(z,te)})]},J)}),f.jsx("div",{className:"min-h-[40px]",onDragOver:z=>{z.preventDefault(),B(z,M.id,w.length)},children:D&&S===w.length&&f.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),w.length===0&&D&&f.jsx("div",{className:"h-20 border-2 border-dashed border-blue-300 rounded-lg bg-blue-50/50 flex items-center justify-center",children:f.jsx("span",{className:"text-sm text-blue-400",children:"Drop here"})})]}),c&&f.jsx("div",{className:"flex-shrink-0 border-t border-neutral-200 p-2",children:c(M)})]},M.id)})})}function Yc(r){const e=r.data||{};return e.image||e.poster||e.thumbnail||e.cover||e.photo}function zg(r){const e=r.data||{};return e.subtitle||e.director||e.author||e.creator}function Og(r){const e=r.data||{};return e.description||r.description||e.synopsis||e.summary}function $g(r){const e=r.data||{},t=[];return e.year&&t.push(String(e.year)),e.duration&&t.push(`${e.duration} min`),e.country&&t.push(e.country),e.category&&t.push(e.category),t.join(" • ")}const qg={"1:1":1,"2:3":1.5,"16:9":.5625};function Qc({node:r,aspectRatio:e,onClick:t}){const[n,s]=y.useState(!1),i=Yc(r),o=qg[e],a=e==="2:3"?160:e==="16:9"?280:180,l=e==="2:3"||e==="16:9"?a*o:a;return f.jsxs("div",{onClick:t,onMouseEnter:()=>s(!0),onMouseLeave:()=>s(!1),style:{position:"relative",width:a,height:l,flexShrink:0,borderRadius:6,overflow:"hidden",cursor:"pointer",transform:n?"scale(1.08)":"scale(1)",transition:"transform 0.2s ease-out",zIndex:n?10:1,boxShadow:n?"0 8px 24px rgba(0,0,0,0.5)":"0 2px 8px rgba(0,0,0,0.3)"},children:[i?f.jsx("img",{src:i,alt:r.title||"Item",style:{width:"100%",height:"100%",objectFit:"cover"}}):f.jsx("div",{style:{width:"100%",height:"100%",background:"linear-gradient(135deg, #2a2a2a 0%, #1a1a1a 100%)",display:"flex",alignItems:"center",justifyContent:"center"},children:f.jsx("span",{style:{fontSize:32,opacity:.3},children:"📄"})}),f.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,padding:"24px 8px 8px",background:"linear-gradient(to top, rgba(0,0,0,0.9) 0%, transparent 100%)",opacity:n?1:.8,transition:"opacity 0.2s ease"},children:f.jsx("p",{style:{margin:0,fontSize:13,fontWeight:600,color:"white",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:r.title||"Untitled"})})]})}function Jc({title:r,nodes:e,cardAspectRatio:t,onNodeClick:n}){const s=y.useRef(null),[i,o]=y.useState(!1),[a,l]=y.useState(!1),[u,c]=y.useState(!1),d=()=>{const p=s.current;p&&(l(p.scrollLeft>0),c(p.scrollLeft<p.scrollWidth-p.clientWidth-10))};y.useEffect(()=>{d();const p=s.current;if(p)return p.addEventListener("scroll",d),()=>p.removeEventListener("scroll",d)},[e]);const h=p=>{const g=s.current;if(!g)return;const m=g.clientWidth*.8;g.scrollBy({left:p==="left"?-m:m,behavior:"smooth"})};return e.length===0?null:f.jsxs("div",{style:{marginBottom:32},onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),children:[f.jsx("h3",{style:{margin:"0 0 12px 48px",fontSize:20,fontWeight:700,color:"white"},children:r}),f.jsxs("div",{style:{position:"relative"},children:[a&&f.jsx("button",{onClick:()=>h("left"),style:{position:"absolute",left:0,top:0,bottom:0,width:48,border:"none",background:"linear-gradient(to right, rgba(20,20,20,0.95) 0%, transparent 100%)",color:"white",cursor:"pointer",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:i?1:0,transition:"opacity 0.2s ease"},children:f.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:f.jsx("path",{d:"M15.41 7.41L14 6l-6 6 6 6 1.41-1.41L10.83 12z"})})}),u&&f.jsx("button",{onClick:()=>h("right"),style:{position:"absolute",right:0,top:0,bottom:0,width:48,border:"none",background:"linear-gradient(to left, rgba(20,20,20,0.95) 0%, transparent 100%)",color:"white",cursor:"pointer",zIndex:20,display:"flex",alignItems:"center",justifyContent:"center",opacity:i?1:0,transition:"opacity 0.2s ease"},children:f.jsx("svg",{width:"24",height:"24",viewBox:"0 0 24 24",fill:"currentColor",children:f.jsx("path",{d:"M8.59 16.59L10 18l6-6-6-6-1.41 1.41L13.17 12z"})})}),f.jsx("div",{ref:s,style:{display:"flex",gap:8,overflowX:"auto",overflowY:"hidden",padding:"8px 48px",scrollbarWidth:"none",msOverflowStyle:"none"},children:e.map(p=>f.jsx(Qc,{node:p,aspectRatio:t,onClick:()=>n(p)},p._id))})]})]})}function Xc({node:r,onClose:e}){const t=Yc(r),n=zg(r),s=Og(r),i=$g(r);return y.useEffect(()=>{const o=a=>{a.key==="Escape"&&e()};return window.addEventListener("keydown",o),()=>window.removeEventListener("keydown",o)},[e]),y.useEffect(()=>(document.body.style.overflow="hidden",()=>{document.body.style.overflow=""}),[]),f.jsx("div",{onClick:e,style:{position:"fixed",inset:0,zIndex:1e3,background:"rgba(0, 0, 0, 0.85)",display:"flex",alignItems:"center",justifyContent:"center",padding:24},children:f.jsxs("div",{onClick:o=>o.stopPropagation(),style:{position:"relative",width:"100%",maxWidth:850,maxHeight:"90vh",background:"#181818",borderRadius:8,overflow:"hidden",boxShadow:"0 16px 64px rgba(0,0,0,0.6)"},children:[f.jsx("button",{onClick:e,style:{position:"absolute",top:12,right:12,width:36,height:36,borderRadius:"50%",border:"none",background:"#181818",color:"white",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",zIndex:10,fontSize:20},children:"✕"}),f.jsxs("div",{style:{overflowY:"auto",maxHeight:"90vh"},children:[f.jsxs("div",{style:{position:"relative",width:"100%",aspectRatio:"16/9",background:"#0a0a0a"},children:[t?f.jsx("img",{src:t,alt:r.title||"Item",style:{width:"100%",height:"100%",objectFit:"cover"}}):f.jsx("div",{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},children:f.jsx("span",{style:{fontSize:64,opacity:.2},children:"📄"})}),f.jsx("div",{style:{position:"absolute",bottom:0,left:0,right:0,height:"50%",background:"linear-gradient(to top, #181818 0%, transparent 100%)"}}),f.jsx("div",{style:{position:"absolute",bottom:24,left:32,right:32},children:f.jsx("h1",{style:{margin:0,fontSize:32,fontWeight:700,color:"white",textShadow:"0 2px 8px rgba(0,0,0,0.5)"},children:r.title||"Untitled"})})]}),f.jsxs("div",{style:{padding:"0 32px 32px"},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16,marginBottom:16},children:[n&&f.jsx("span",{style:{color:"#a3a3a3",fontSize:15},children:n}),i&&f.jsx("span",{style:{color:"#737373",fontSize:14},children:i})]}),s&&f.jsx("p",{style:{margin:0,fontSize:15,lineHeight:1.6,color:"#d4d4d4"},children:s}),r.data&&Object.keys(r.data).length>0&&f.jsxs("div",{style:{marginTop:24},children:[f.jsx("h4",{style:{margin:"0 0 12px",fontSize:14,fontWeight:600,color:"#737373",textTransform:"uppercase",letterSpacing:1},children:"Details"}),f.jsx("div",{style:{display:"grid",gridTemplateColumns:"repeat(auto-fill, minmax(200px, 1fr))",gap:12},children:Object.entries(r.data).filter(([o])=>!["image","poster","thumbnail","cover","photo","description","subtitle","synopsis","summary"].includes(o)).slice(0,8).map(([o,a])=>f.jsxs("div",{children:[f.jsx("span",{style:{color:"#737373",fontSize:12,textTransform:"capitalize"},children:o.replace(/_/g," ")}),f.jsx("p",{style:{margin:"4px 0 0",color:"#d4d4d4",fontSize:14},children:String(a)})]},o))})]})]})]})]})})}function Ug({nodes:r,lanes:e,cardAspectRatio:t="2:3",onNodeClick:n}){const[s,i]=y.useState(null),o=y.useMemo(()=>e.map(u=>({...u,nodes:r.filter(u.filter)})),[r,e]),a=u=>{n?n(u):i(u)},l=()=>{i(null)};return f.jsxs("div",{style:{minHeight:"100vh",background:"#141414",paddingTop:24,paddingBottom:48},children:[o.map(u=>f.jsx(Jc,{title:u.title,nodes:u.nodes,cardAspectRatio:t,onNodeClick:a},u.id)),o.every(u=>u.nodes.length===0)&&f.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",minHeight:400,color:"#737373"},children:[f.jsx("span",{style:{fontSize:48,marginBottom:16},children:"📭"}),f.jsx("p",{style:{margin:0,fontSize:18},children:"No items to display"})]}),s&&f.jsx(Xc,{node:s,onClose:l})]})}const Wg={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function Hg(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function Vg(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function Gg(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function Kg({items:r,date:e,startHour:t=7,endHour:n=22,hourHeight:s=60,getItemTime:i,getItemDuration:o,getItemIsAllDay:a,getItemId:l,renderItem:u,onItemClick:c,onTimeSlotClick:d,showCurrentTime:h=!0,className:p="",theme:g={}}){const m={...Wg,...g},{allDayItems:x,timedItems:_}=y.useMemo(()=>{const v=[],T=[];for(const B of r)a(B)?v.push(B):T.push(B);return{allDayItems:v,timedItems:T}},[r,a]),b=y.useMemo(()=>{const v=[];for(let T=t;T<=n;T++)v.push(T);return v},[t,n]),S=(n-t+1)*s,C=y.useCallback(v=>{const T=i(v);if(!T)return null;const B=Hg(T);if(!B)return null;const{hours:j,minutes:N}=B,R=Math.max(t,Math.min(n,j)),M=j<t?0:N,w=(R-t)*s+M/60*s,D=o(v),F=Math.max(20,D/60*s);return{top:w,height:F}},[i,o,t,n,s]),k=y.useMemo(()=>{if(!h||!Gg(e))return null;const v=new Date,T=v.getHours(),B=v.getMinutes();return T<t||T>n?null:(T-t)*s+B/60*s},[e,h,t,n,s]),E=y.useCallback(v=>{if(!d)return;const T=v.currentTarget.getBoundingClientRect(),j=(v.clientY-T.top)/s*60,N=Math.floor(j/60)+t,R=Math.round(j%60/15)*15,M=Math.min(n,Math.max(t,N)),w=R>=60?0:R,D=`${M.toString().padStart(2,"0")}:${w.toString().padStart(2,"0")}`;d(D)},[d,s,t,n]);return f.jsxs("div",{className:p,style:{background:m.background},children:[x.length>0&&f.jsxs("div",{style:{padding:"8px 0 8px 60px",borderBottom:`1px solid ${m.allDayBorder}`,background:m.allDayBackground},children:[f.jsx("div",{style:{fontSize:"11px",color:m.hourTextColor,marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"All Day"}),f.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:x.map(v=>f.jsx("div",{onClick:()=>c==null?void 0:c(v),style:{cursor:c?"pointer":"default"},children:u(v)},l(v)))})]}),f.jsxs("div",{style:{position:"relative",height:S},children:[b.map((v,T)=>f.jsxs("div",{style:{position:"absolute",top:T*s,left:0,right:0},children:[f.jsx("div",{style:{position:"absolute",left:0,top:-8,width:"50px",textAlign:"right",paddingRight:"10px",fontSize:"11px",color:m.hourTextColor},children:Vg(v)}),f.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),T<b.length-1&&f.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:s/2,height:"1px",background:m.halfHourLineColor}})]},v)),f.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:d?"pointer":"default"},onClick:E}),k!==null&&f.jsxs("div",{style:{position:"absolute",left:"55px",right:0,top:k,zIndex:20,pointerEvents:"none"},children:[f.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",background:m.currentTimeColor,marginLeft:"-5px",marginTop:"-5px",position:"absolute"}}),f.jsx("div",{style:{marginLeft:"5px",height:"2px",background:m.currentTimeColor}})]}),_.map(v=>{const T=C(v);return T?f.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:T.top,height:T.height,zIndex:10,cursor:c?"pointer":"default"},onClick:B=>{B.stopPropagation(),c==null||c(v)},children:u(v)},l(v)):null})]})]})}function Zc({onComplete:r,onCancel:e,onTranscribe:t,onTranscriptionComplete:n,variant:s="widget",hideSaveButton:i=!1,maxDuration:o=180,extraControls:a}){const l=s==="widget",[u,c]=y.useState("idle"),[d,h]=y.useState(0),[p,g]=y.useState(0),[m,x]=y.useState(!1),[_,b]=y.useState(0),[S,C]=y.useState(null),[k,E]=y.useState(!1),[v,T]=y.useState(null),[B,j]=y.useState(!0),[N,R]=y.useState([]),[M,w]=y.useState({completed:0,total:0}),D=y.useRef(!1),F=y.useRef(!0);y.useEffect(()=>{F.current=B},[B]);const z=y.useRef(null),q=y.useRef(null),J=y.useRef(null),te=y.useRef(null),W=y.useRef(null),G=y.useRef([]),H=y.useRef(null),se=y.useRef(null),le=y.useRef(null),ue=y.useRef(null),_e=y.useRef(!1),fe=y.useRef([]),De=y.useRef(null),O=y.useRef(null),Ce=y.useRef([]),re=y.useRef([]),Fe=y.useRef("insert"),je=y.useRef(!1),ye=y.useRef(0),Se=y.useRef(0),Me=y.useRef(0),Oe=Q=>{const I=Math.floor(Q/60),de=Math.floor(Q%60);return`${I.toString().padStart(2,"0")}:${de.toString().padStart(2,"0")}`},ge=async Q=>{const I=await Q.arrayBuffer(),de=new AudioContext,he=await de.decodeAudioData(I);return await de.close(),he},L=Q=>{const I=Q.numberOfChannels,de=Q.sampleRate,he=1,Y=16,Ae=Y/8,Ee=I*Ae,Te=de*Ee,Le=Q.length*Ee,He=new ArrayBuffer(44+Le),ke=new DataView(He),P=(be,Ne)=>{for(let st=0;st<Ne.length;st++)ke.setUint8(be+st,Ne.charCodeAt(st))};P(0,"RIFF"),ke.setUint32(4,36+Le,!0),P(8,"WAVE"),P(12,"fmt "),ke.setUint32(16,16,!0),ke.setUint16(20,he,!0),ke.setUint16(22,I,!0),ke.setUint32(24,de,!0),ke.setUint32(28,Te,!0),ke.setUint16(32,Ee,!0),ke.setUint16(34,Y,!0),P(36,"data"),ke.setUint32(40,Le,!0);const xe=[];for(let be=0;be<I;be++)xe.push(Q.getChannelData(be));let ve=44;for(let be=0;be<Q.length;be++)for(let Ne=0;Ne<I;Ne++){const st=Math.max(-1,Math.min(1,xe[Ne][be])),ct=st<0?st*32768:st*32767;ke.setInt16(ve,ct,!0),ve+=2}return new Blob([He],{type:"audio/wav"})},ze=async(Q,I,de,he)=>{const Y=new AudioContext,Ae=Q.sampleRate,Ee=Math.max(Q.numberOfChannels,I.numberOfChannels),Te=Math.min(de,Q.length),Le=Math.max(0,Q.length-de),He=he==="insert"?Te+I.length+Le:Te+I.length,ke=Y.createBuffer(Ee,He,Ae);for(let P=0;P<Ee;P++){const xe=ke.getChannelData(P),ve=P<Q.numberOfChannels?Q.getChannelData(P):Q.getChannelData(0);for(let Ne=0;Ne<Te;Ne++)xe[Ne]=ve[Ne];const be=P<I.numberOfChannels?I.getChannelData(P):I.getChannelData(0);for(let Ne=0;Ne<I.length;Ne++)xe[Te+Ne]=be[Ne];if(he==="insert")for(let Ne=0;Ne<Le;Ne++)xe[Te+I.length+Ne]=ve[de+Ne]}return await Y.close(),ke},Ke=y.useCallback(()=>{const Q=z.current;if(!Q)return;const I=Q.getContext("2d");if(!I)return;const de=Q.getBoundingClientRect(),he=de.width,Y=de.height,Ae=fe.current,Ee=p||d||1,Te=u==="recording"?d:_;I.fillStyle="#2d3b35",I.fillRect(0,0,he,Y);const Le=8,He="rgba(0, 0, 0, 0.4)",ke=I.createLinearGradient(0,0,0,Le);ke.addColorStop(0,He),ke.addColorStop(1,"transparent"),I.fillStyle=ke,I.fillRect(0,0,he,Le);const P=I.createLinearGradient(0,Y-Le,0,Y);P.addColorStop(0,"transparent"),P.addColorStop(1,He),I.fillStyle=P,I.fillRect(0,Y-Le,he,Le);const xe=I.createLinearGradient(0,0,Le,0);xe.addColorStop(0,He),xe.addColorStop(1,"transparent"),I.fillStyle=xe,I.fillRect(0,0,Le,Y);const ve=I.createLinearGradient(he-Le,0,he,0);ve.addColorStop(0,"transparent"),ve.addColorStop(1,He),I.fillStyle=ve,I.fillRect(he-Le,0,Le,Y),I.strokeStyle="#5a6b62",I.lineWidth=1,I.beginPath(),I.moveTo(0,Y/2),I.lineTo(he,Y/2),I.stroke();const be=he/2;if(Ae.length>0)if(u==="recording")for(let ct=0;ct<Ae.length;ct++){const bt=Ae.length-1-ct,Xt=be-bt*4;if(Xt<-3||Xt>he)continue;const A=Ae[ct]*(Y/2-12),U=Y/2-A;I.fillStyle="#10b981",I.fillRect(Xt,U,3,A*2)}else{const ct=Ee>0?Te/Ee*Ae.length:0;for(let bt=0;bt<Ae.length;bt++){const Xt=ct-bt,A=be-Xt*4;if(A<-3||A>he)continue;const U=Ae[bt]*(Y/2-12),ne=Y/2-U;I.fillStyle=bt<=ct?"#10b981":"#4b5563",I.fillRect(A,ne,3,U*2)}}I.strokeStyle="#ef4444",I.lineWidth=1,I.beginPath(),I.moveTo(be,0),I.lineTo(be,Y),I.stroke(),I.fillStyle="#fff",I.font="bold 18px monospace",I.textAlign="center",I.fillText(Oe(Te),be,Y-6),u==="recording"&&(I.fillStyle="#ef4444",I.beginPath(),I.arc(20,20,8,0,Math.PI*2),I.fill(),I.fillStyle="#fff",I.font="10px sans-serif",I.textAlign="left",I.fillText("REC",34,24)),I.textAlign="left"},[u,_,d,p]),X=()=>{const Q=W.current;if(!Q||!_e.current)return;const I=Q.frequencyBinCount,de=new Uint8Array(I);Q.getByteTimeDomainData(de);let he=0;for(let Ee=0;Ee<I;Ee++){const Te=(de[Ee]-128)/128;he+=Te*Te}const Y=Math.sqrt(he/I),Ae=Math.min(1,Y*3);fe.current.push(Ae),Ke(),_e.current&&(se.current=requestAnimationFrame(X))},Z=async()=>{try{C(null),E(!1),De.current===null&&(fe.current=[]);const Q=await navigator.mediaDevices.getUserMedia({audio:!0});J.current=Q;const I=new AudioContext;te.current=I;const de=I.createAnalyser();de.fftSize=2048,W.current=de,I.createMediaStreamSource(Q).connect(de);const Y=new MediaRecorder(Q);q.current=Y,G.current=[],Y.ondataavailable=Ae=>{Ae.data.size>0&&G.current.push(Ae.data)},Y.onstop=async()=>{try{if(_e.current=!1,G.current.length===0){C("No audio was recorded. Please try again."),c("idle"),Q.getTracks().forEach(ke=>ke.stop());return}const Ae=new Blob(G.current,{type:"audio/webm"});let Ee,Te;if(De.current!==null&&O.current)try{const ke=await ge(Ae),P=O.current.sampleRate,xe=Math.floor(De.current*P),ve=await ze(O.current,ke,xe,Fe.current);Ee=L(ve),Te=ve.length/ve.sampleRate,Fe.current==="insert"&&(fe.current=[...fe.current,...re.current]),De.current=null,O.current=null,Ce.current=[],re.current=[]}catch{Ee=Ae,Te=ye.current>0?ye.current:1}else Ee=Ae,Te=ye.current>0?ye.current:1;if(ue.current=Ee,Q.getTracks().forEach(ke=>ke.stop()),F.current&&t){R(ke=>[...ke,Ee]),w(ke=>({...ke,total:ke.total+1})),ue.current=null,fe.current=[],b(0),g(0),h(0),c("idle");return}const Le=URL.createObjectURL(Ee),He=new Audio(Le);He.ontimeupdate=()=>{b(He.currentTime)},He.onended=()=>{x(!1)},le.current=He,g(Te),b(Te),c("editing")}catch{C("Failed to process recording"),c("idle")}},Y.start(100),_e.current=!0,c("recording"),h(0),ye.current=0,H.current=setInterval(()=>{ye.current+=1,h(ye.current),ye.current>=o&&(q.current&&q.current.state!=="inactive"&&q.current.stop(),_e.current=!1,T(null),H.current&&(clearInterval(H.current),H.current=null),se.current&&(cancelAnimationFrame(se.current),se.current=null),setTimeout(()=>{alert(`Maximum recording time of ${Math.floor(o/60)} minutes reached.`)},100))},1e3)}catch{C("Could not access microphone. Please allow microphone access.")}},ce=()=>{_e.current=!1,E(!1),T(null),se.current&&(cancelAnimationFrame(se.current),se.current=null),H.current&&(clearInterval(H.current),H.current=null),q.current&&q.current.state!=="inactive"&&q.current.stop()},we=Q=>{const I=z.current;if(!I)return;const de=p||d;if(de<=0)return;const he=fe.current;if(he.length===0)return;const Y=I.getBoundingClientRect(),Ae=Q-Se.current,Ee=4,Te=Y.width/I.width,Le=he.length/de*Ee,He=-Ae/(Le*Te),ke=Me.current+He,P=Math.max(0,Math.min(ke,de));le.current&&(le.current.currentTime=P),b(P)},Be=()=>{le.current&&(le.current.currentTime=0),b(0)},Qe=()=>{const Q=p||d;le.current&&(le.current.currentTime=Q),b(Q)},Et=()=>{const Q=le.current;Q&&(m?(Q.pause(),b(Q.currentTime),x(!1)):(Q.currentTime=_,Q.play().catch(()=>{}),x(!0)))},oe=async Q=>{if(!ue.current){Z();return}try{le.current&&(le.current.pause(),x(!1)),Fe.current=Q,O.current=await ge(ue.current);const I=p||d;De.current=_;const de=I>0?_/I:0,he=Math.floor(de*fe.current.length);Ce.current=fe.current.slice(0,he),re.current=fe.current.slice(he),fe.current=[...Ce.current],Z()}catch{C("Failed to prepare recording. Please try again.")}},pe=()=>{le.current&&(le.current.pause(),le.current=null),ue.current=null,O.current=null,De.current=null,Ce.current=[],x(!1),b(0),g(0),h(0),Z()},Ye=()=>{ue.current?r(ue.current,p||d):alert("No audio recorded yet!")};y.useEffect(()=>{u==="recording"&&z.current&&W.current&&_e.current&&(se.current=requestAnimationFrame(X))},[u]),y.useEffect(()=>{const Q=z.current;if(!Q)return;const I=()=>{const de=window.devicePixelRatio||1,he=Q.getBoundingClientRect();Q.width=he.width*de,Q.height=he.height*de;const Y=Q.getContext("2d");Y&&Y.scale(de,de)};return I(),window.addEventListener("resize",I),()=>window.removeEventListener("resize",I)},[]),y.useEffect(()=>{if(u==="idle"){const Q=z.current;if(!Q)return;const I=Q.getContext("2d");if(!I)return;const de=Q.getBoundingClientRect(),he=de.width,Y=de.height;I.fillStyle="#2d3b35",I.fillRect(0,0,he,Y);const Ae=8,Ee="rgba(0, 0, 0, 0.4)",Te=I.createLinearGradient(0,0,0,Ae);Te.addColorStop(0,Ee),Te.addColorStop(1,"transparent"),I.fillStyle=Te,I.fillRect(0,0,he,Ae);const Le=I.createLinearGradient(0,Y-Ae,0,Y);Le.addColorStop(0,"transparent"),Le.addColorStop(1,Ee),I.fillStyle=Le,I.fillRect(0,Y-Ae,he,Ae);const He=I.createLinearGradient(0,0,Ae,0);He.addColorStop(0,Ee),He.addColorStop(1,"transparent"),I.fillStyle=He,I.fillRect(0,0,Ae,Y);const ke=I.createLinearGradient(he-Ae,0,he,0);ke.addColorStop(0,"transparent"),ke.addColorStop(1,Ee),I.fillStyle=ke,I.fillRect(he-Ae,0,Ae,Y),I.strokeStyle="#5a6b62",I.lineWidth=1,I.beginPath(),I.moveTo(0,Y/2),I.lineTo(he,Y/2),I.stroke();const P=he/2;I.strokeStyle="#ef4444",I.lineWidth=1,I.beginPath(),I.moveTo(P,0),I.lineTo(P,Y),I.stroke(),I.fillStyle="#fff",I.font="bold 18px monospace",I.textAlign="center",I.fillText("00:00",P,Y-6)}},[u]);const at=y.useCallback(Q=>{R(I=>[...I,Q]),w(I=>({...I,total:I.total+1}))},[]);if(y.useEffect(()=>{(async()=>{if(D.current||N.length===0||!t)return;D.current=!0;const I=N[0];try{const de=await t(I);de&&n&&n(de)}catch(de){console.error("Transcription failed:",de)}finally{R(de=>de.slice(1)),w(de=>({...de,completed:de.completed+1})),D.current=!1}})()},[N,t,n]),y.useEffect(()=>()=>{_e.current=!1,H.current&&clearInterval(H.current),se.current&&cancelAnimationFrame(se.current),J.current&&J.current.getTracks().forEach(Q=>Q.stop()),te.current&&te.current.state!=="closed"&&te.current.close()},[]),y.useEffect(()=>{if(u==="editing"&&m){let Q;const I=()=>{const de=le.current;if(de&&m){const he=z.current;if(he){const Y=he.getContext("2d");if(Y){const Ae=he.getBoundingClientRect(),Ee=Ae.width,Te=Ae.height,Le=fe.current,He=p||d||1,ke=de.currentTime;Y.fillStyle="#2d3b35",Y.fillRect(0,0,Ee,Te);const P=8,xe="rgba(0, 0, 0, 0.4)",ve=Y.createLinearGradient(0,0,0,P);ve.addColorStop(0,xe),ve.addColorStop(1,"transparent"),Y.fillStyle=ve,Y.fillRect(0,0,Ee,P);const be=Y.createLinearGradient(0,Te-P,0,Te);be.addColorStop(0,"transparent"),be.addColorStop(1,xe),Y.fillStyle=be,Y.fillRect(0,Te-P,Ee,P);const Ne=Y.createLinearGradient(0,0,P,0);Ne.addColorStop(0,xe),Ne.addColorStop(1,"transparent"),Y.fillStyle=Ne,Y.fillRect(0,0,P,Te);const st=Y.createLinearGradient(Ee-P,0,Ee,0);st.addColorStop(0,"transparent"),st.addColorStop(1,xe),Y.fillStyle=st,Y.fillRect(Ee-P,0,P,Te),Y.strokeStyle="#5a6b62",Y.lineWidth=1,Y.beginPath(),Y.moveTo(0,Te/2),Y.lineTo(Ee,Te/2),Y.stroke();const ct=Ee/2,bt=3,Xt=4,A=He>0?ke/He*Le.length:0;for(let me=0;me<Le.length;me++){const qe=A-me,Ue=ct-qe*Xt;if(Ue<-bt||Ue>Ee)continue;const Pe=Le[me]*(Te/2-12),Re=Te/2-Pe;Y.fillStyle=me<=A?"#10b981":"#4b5563",Y.fillRect(Ue,Re,bt,Pe*2)}Y.strokeStyle="#ef4444",Y.lineWidth=1,Y.beginPath(),Y.moveTo(ct,0),Y.lineTo(ct,Te),Y.stroke(),Y.fillStyle="#fff",Y.font="bold 18px monospace",Y.textAlign="center";const U=Math.floor(ke/60),ne=Math.floor(ke%60);Y.fillText(`${U.toString().padStart(2,"0")}:${ne.toString().padStart(2,"0")}`,ct,Te-6),Y.textAlign="left"}}Q=requestAnimationFrame(I)}};return Q=requestAnimationFrame(I),()=>cancelAnimationFrame(Q)}},[u,m,p,d]),y.useEffect(()=>{u==="editing"&&!m&&Ke()},[u,_,m,Ke]),S)return f.jsxs("div",{style:{border:"1px solid #fecaca",borderRadius:"12px",padding:"16px",background:"#fef2f2"},children:[f.jsx("p",{style:{fontSize:"14px",color:"#dc2626",marginBottom:"12px"},children:S}),f.jsx("button",{onClick:()=>{C(null),Z()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const Ve={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},Xe={...Ve,opacity:.3,cursor:"not-allowed"},br=l?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",flexShrink:0};return f.jsxs("div",{style:br,children:[f.jsx("canvas",{ref:z,style:{width:"100%",height:"32px",cursor:"pointer",flexShrink:0},onMouseDown:Q=>{if(u==="editing"){je.current=!0,Se.current=Q.clientX,Me.current=_;const I=he=>{je.current&&we(he.clientX)},de=()=>{je.current=!1,window.removeEventListener("mousemove",I),window.removeEventListener("mouseup",de)};window.addEventListener("mousemove",I),window.addEventListener("mouseup",de)}}}),f.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:l?"6px 8px":"4px",borderTop:"1px solid #d4d4d4",background:"linear-gradient(to bottom, #e0e0e0 0%, #c8c8c8 100%)",boxShadow:"inset 0 1px 0 rgba(255,255,255,0.6), inset 0 -1px 0 rgba(0,0,0,0.1)",flexShrink:0},children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[f.jsx("button",{onClick:Be,disabled:u==="idle"||u==="recording",style:u==="idle"||u==="recording"?Xe:Ve,title:"Go to start",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"first_page"})}),f.jsx("button",{onClick:()=>{if(u==="recording"){const Q=q.current;Q&&(Q.state==="recording"?(Q.pause(),E(!0)):Q.state==="paused"&&(Q.resume(),E(!1)))}else Et()},disabled:u==="idle",style:u==="idle"?Xe:Ve,title:m||u==="recording"&&!k?"Pause":"Play",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:m||u==="recording"&&!k?"pause":"play_arrow"})}),f.jsx("button",{onClick:Qe,disabled:u==="idle"||u==="recording",style:u==="idle"||u==="recording"?Xe:Ve,title:"Go to end",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"last_page"})}),f.jsx("div",{style:{width:"1px",height:"24px",margin:"0 4px",background:"linear-gradient(to bottom, rgba(255,255,255,0.5), rgba(0,0,0,0.15))"}}),f.jsx("button",{onClick:()=>{v==="insert"?ce():u==="idle"?(T("insert"),Z()):u==="editing"&&(T("insert"),oe("insert"))},disabled:u==="recording"&&v!=="insert"||m,style:u==="recording"&&v!=="insert"||m?Xe:Ve,title:v==="insert"?"Stop recording":"Insert recording",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:v==="insert"?"#ef4444":"#171717"},children:"add"})}),f.jsx("button",{onClick:()=>{F.current||(v==="mic"?ce():u==="idle"?(T("mic"),Z()):u==="editing"&&(T("mic"),oe("replace")))},onMouseDown:()=>{F.current&&u==="idle"&&!m&&(T("mic"),Z())},onMouseUp:()=>{F.current&&u==="recording"&&v==="mic"&&ce()},onMouseLeave:()=>{F.current&&u==="recording"&&v==="mic"&&ce()},onTouchStart:Q=>{Q.preventDefault(),F.current&&u==="idle"&&!m&&(T("mic"),Z())},onTouchEnd:Q=>{Q.preventDefault(),F.current&&u==="recording"&&v==="mic"&&ce()},disabled:u==="recording"&&v!=="mic"||m,style:u==="recording"&&v!=="mic"||m?Xe:Ve,title:B?"Hold to record (walkie-talkie)":v==="mic"?"Stop recording":"Record",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:v==="mic"?"#ef4444":"#171717"},children:"mic"})}),f.jsx("button",{onClick:()=>{u==="idle"&&!m?(T("round"),Z()):u==="recording"&&v==="round"&&ce()},disabled:u==="editing"||u==="recording"&&v!=="round"||m,style:u==="editing"||u==="recording"&&v!=="round"||m?Xe:{...Ve,width:"28px",height:"28px",borderRadius:"50%",padding:0},title:"Click to record / click to stop",children:f.jsx("span",{style:{display:"block",width:"14px",height:"14px",borderRadius:"50%",background:u==="recording"&&v==="round"?"#171717":"#ef4444",transition:"background 0.15s"}})}),f.jsx("button",{onClick:()=>{v==="startover"?ce():u==="editing"&&(T("startover"),pe())},disabled:u==="idle"||u==="recording"&&v!=="startover"||m,style:u==="idle"||u==="recording"&&v!=="startover"||m?Xe:Ve,title:v==="startover"?"Stop recording":"Start over",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:v==="startover"?"#ef4444":"#171717"},children:"refresh"})})]}),f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[a,M.total>0&&M.completed<M.total&&f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",padding:"4px 8px",background:"rgba(16, 185, 129, 0.1)",borderRadius:"4px",fontSize:"11px",color:"#10b981"},children:[f.jsx("span",{className:"material-icons",style:{fontSize:"14px",animation:"spin 1s linear infinite"},children:"sync"}),M.completed,"/",M.total]}),t&&f.jsxs(f.Fragment,{children:[f.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginRight:"4px"},children:[f.jsx("button",{onClick:()=>j(!B),style:{width:"28px",height:"16px",borderRadius:"8px",border:"none",background:B?"#10b981":"#9ca3af",cursor:"pointer",position:"relative",transition:"background 0.2s",padding:0},title:B?"Auto-transcribe ON":"Auto-transcribe OFF",children:f.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"50%",background:"white",position:"absolute",top:"2px",left:B?"14px":"2px",transition:"left 0.2s",boxShadow:"0 1px 2px rgba(0,0,0,0.2)"}})}),f.jsx("span",{style:{fontSize:"10px",color:"#666"},children:"auto"})]}),f.jsx("button",{onClick:()=>{u==="editing"&&ue.current&&at(ue.current)},disabled:u!=="editing",style:u!=="editing"?Xe:Ve,title:"Transcribe audio",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:B?"#10b981":"#171717"},children:"subtitles"})})]}),!i&&f.jsx("button",{onClick:Ye,disabled:u!=="editing",style:u!=="editing"?Xe:Ve,title:"Save recording",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"save"})})]})]}),M.total>0&&M.completed<M.total&&f.jsx("div",{style:{height:"3px",background:"#e5e5e5",overflow:"hidden"},children:f.jsx("div",{style:{height:"100%",background:"#10b981",width:`${M.completed/M.total*100}%`,transition:"width 0.3s ease"}})})]})}function Yg({label:r,value:e,onChange:t,onTranscribe:n,onAIAction:s,onAIPrompt:i,onAudioSave:o,placeholder:a="Type or record...",className:l="",rows:u,llmClient:c,graphClient:d,nodeId:h,audioFilename:p,existingAudio:g,existingVoice:m,onAudioGenerated:x,onGenerateTTS:_,audioUrl:b,voice:S="coral",onVoiceChange:C,generateButton:k,generatePrompt:E,generateSourceText:v,generateSourceError:T}){const[B,j]=y.useState(!1),[N,R]=y.useState(!1),[M,w]=y.useState(!1),[D,F]=y.useState(""),[z,q]=y.useState(!1),[J,te]=y.useState(!1),[W,G]=y.useState(null),[H,se]=y.useState(m||S),[le,ue]=y.useState(g),[_e,fe]=y.useState(Date.now()),De=y.useRef(null),O=y.useRef(null),Ce=!!(c&&d&&h&&p);y.useEffect(()=>{g!==void 0&&ue(g)},[g]),y.useEffect(()=>{m!==void 0&&se(m)},[m]);const re=Ce&&le&&d&&h?`${d.getFileUrl(h,le)}?v=${_e}`:b,Fe=L=>{t(e?`${e}
184
184
 
185
- ${L}`:L)},Ce=async L=>{if(!(!(typeof e=="string"?e:"").trim()||B||!s)){j(!0),M(L),w(!1);try{const Me=await s(L,e);t(Me)}catch(Me){console.error(`${L} failed:`,Me)}finally{j(!1),M(null)}}},Ee=()=>{setTimeout(()=>{var L;(L=Te.current)!=null&&L.contains(document.activeElement)||w(!1)},150)},Se=async()=>{if(!(!D.trim()||B||!i)){j(!0),M(D);try{const L=await i(D,e);t(L),F("")}catch(L){console.error("AI prompt failed:",L)}finally{j(!1),M(null)}}},Fe=async()=>{if(!(typeof e=="string"?e:"").trim()||I)return;if(!(ke||_)){console.warn("TTS: No generation mode available",{integratedTTS:ke,hasCallback:!!_,llmClient:!!c,graphClient:!!d,nodeId:h,audioFilename:p}),alert("TTS non disponible. Sauvegardez d'abord le cours.");return}$.current&&($.current.pause(),$.current.currentTime=0),U(!0);try{if(ke&&c&&d&&h&&p){console.log("TTS: Generating audio...",{voice:H,textLength:e.length});const Me=await c.tts(e,{voice:H});console.log("TTS: Audio generated, uploading...",{audioLength:Me==null?void 0:Me.length});const Qe=atob(Me),G=new Uint8Array(Qe.length);for(let _e=0;_e<Qe.length;_e++)G[_e]=Qe.charCodeAt(_e);const ee=new Blob([G],{type:"audio/mpeg"}),me=new File([ee],p,{type:"audio/mpeg"});await d.uploadFile(h,p,me),console.log("TTS: Upload complete",{nodeId:h,audioFilename:p}),be(Date.now()),le(p),x==null||x(p,H)}else _&&(await _(e,H),be(Date.now()))}catch(Me){console.error("TTS generation failed:",Me),alert("Erreur TTS: "+(Me instanceof Error?Me.message:"Erreur inconnue"))}finally{U(!1)}},ze=async()=>{if(!(!c||!E||J)){if(!(v!=null&&v.trim())){V(T||"Le texte source est requis pour la génération.");return}te(!0),V(null);try{const L=await c.chat([{role:"system",content:E},{role:"user",content:v}]);t(L)}catch(L){V(L instanceof Error?L.message:"Erreur de génération")}finally{te(!1)}}},ge=L=>{ne(L),S==null||S(L)};return f.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${a}`,children:[f.jsx(Zc,{onComplete:o||(()=>{}),onTranscribe:n,onTranscriptionComplete:Re,hideSaveButton:!o,variant:"div"}),i&&f.jsxs("div",{className:"flex items-start gap-2 bg-neutral-50 border-b border-neutral-200",children:[f.jsx("textarea",{value:D,onChange:L=>F(L.target.value),onKeyDown:L=>{L.stopPropagation(),L.key==="Enter"&&L.ctrlKey&&(L.preventDefault(),Se())},placeholder:"Instructions AI... (Ctrl+Enter pour envoyer)",disabled:B,rows:5,className:"flex-1 pl-0 pr-2 py-2 text-sm border-0 resize-y min-h-[80px] focus:ring-0 focus:outline-none bg-transparent disabled:opacity-50"}),f.jsx("button",{type:"button",onClick:Se,disabled:B||!D.trim(),className:"self-start p-2 text-neutral-700 hover:text-neutral-900 transition-colors disabled:opacity-30",title:"Envoyer (Ctrl+Enter)",children:f.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:B?"hourglass_empty":"smart_toy"})})]}),(r||s||(typeof e=="string"?e:"").trim()||ke||_||k)&&f.jsxs("div",{className:"flex items-center justify-between px-2 py-1",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[r&&f.jsx("label",{className:"text-sm font-medium text-neutral-700",children:r}),k&&c&&E&&f.jsxs("button",{type:"button",onClick:ze,disabled:J,className:"flex items-center gap-1 px-2 py-1 text-xs bg-purple-100 text-purple-700 hover:bg-purple-200 rounded transition-colors disabled:opacity-50",title:k.label,children:[f.jsx("span",{className:"material-icons",style:{fontSize:"14px"},children:J?"hourglass_empty":k.icon||"auto_awesome"}),k.label]})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[(typeof e=="string"?e:"").trim()&&f.jsx("button",{type:"button",onClick:()=>navigator.clipboard.writeText(e),className:"p-1 rounded hover:bg-neutral-100 transition-colors",title:"Copy to clipboard",children:f.jsx("span",{className:"material-icons text-neutral-500",style:{fontSize:"16px"},children:"content_copy"})}),(ke||_)&&f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("select",{value:H,onChange:L=>ge(L.target.value),disabled:I,className:"px-1.5 py-0.5 text-xs border border-neutral-200 rounded bg-white focus:outline-none focus:ring-1 focus:ring-blue-500 disabled:opacity-50",title:"Choisir la voix",children:ou.map(L=>f.jsxs("option",{value:L.id,children:[L.name," - ",L.description]},L.id))}),f.jsx("button",{type:"button",onClick:Fe,disabled:I||!(typeof e=="string"?e:"").trim(),className:"p-1 rounded hover:bg-blue-50 transition-colors disabled:opacity-40",title:I?"Génération en cours...":"Générer audio TTS",children:f.jsx("span",{className:`material-icons ${I?"animate-pulse text-blue-600":se?"text-green-600":"text-neutral-400"}`,style:{fontSize:"16px"},children:I?"hourglass_empty":"record_voice_over"})}),se&&f.jsxs(f.Fragment,{children:[f.jsx("audio",{ref:$,src:se,controls:!0,className:"h-6 w-32"},pe),f.jsx("button",{type:"button",onClick:()=>{$.current&&$.current.pause(),le(void 0),x==null||x("",H)},className:"p-1 rounded hover:bg-red-50 transition-colors",title:"Supprimer l'audio",children:f.jsx("span",{className:"material-icons text-red-400 hover:text-red-600",style:{fontSize:"14px"},children:"delete"})})]})]}),s&&f.jsxs("div",{className:"relative",ref:Te,children:[f.jsx("button",{type:"button",onClick:()=>w(!R),disabled:B||!(typeof e=="string"?e:"").trim(),className:"flex items-center gap-1 text-xs text-purple-600 hover:text-purple-700 disabled:opacity-40 disabled:hover:text-purple-600 px-2 py-1 rounded hover:bg-purple-50 transition-colors",children:B?f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"material-icons text-sm animate-spin",children:"hourglass_empty"}),N==="restructure"&&"Restructuring...",N==="proofread"&&"Proofreading...",N==="rewrite"&&"Rewriting..."]}):f.jsxs(f.Fragment,{children:[f.jsx("span",{className:"material-icons text-sm",children:"auto_fix_high"}),"AI",f.jsx("span",{className:"material-icons text-sm",children:"expand_more"})]})}),R&&!B&&f.jsxs("div",{className:"absolute right-0 top-full mt-1 bg-white border border-neutral-200 rounded-lg shadow-lg z-50 min-w-[180px] py-1",onBlur:Ee,children:[f.jsxs("button",{type:"button",onClick:()=>Ce("restructure"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[f.jsx("span",{className:"material-icons text-base text-blue-500",children:"format_list_bulleted"}),f.jsxs("div",{children:[f.jsx("div",{className:"font-medium",children:"Restructure"}),f.jsx("div",{className:"text-xs text-neutral-500",children:"Organize & clarify"})]})]}),f.jsxs("button",{type:"button",onClick:()=>Ce("proofread"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[f.jsx("span",{className:"material-icons text-base text-green-500",children:"spellcheck"}),f.jsxs("div",{children:[f.jsx("div",{className:"font-medium",children:"Proofread"}),f.jsx("div",{className:"text-xs text-neutral-500",children:"Fix grammar & spelling"})]})]}),f.jsxs("button",{type:"button",onClick:()=>Ce("rewrite"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[f.jsx("span",{className:"material-icons text-base text-purple-500",children:"brush"}),f.jsxs("div",{children:[f.jsx("div",{className:"font-medium",children:"Rewrite"}),f.jsx("div",{className:"text-xs text-neutral-500",children:"Your voice & style"})]})]})]})]})]})]}),f.jsx("textarea",{value:e,onChange:L=>t(L.target.value),onKeyDown:L=>L.stopPropagation(),placeholder:l,rows:u,disabled:B||J,className:"flex-1 w-full px-3 py-2 border-0 focus:ring-0 focus:outline-none text-sm disabled:opacity-50 disabled:bg-neutral-50 resize-none"}),W&&f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:f.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("span",{className:"material-icons text-amber-500",style:{fontSize:"24px"},children:"warning"}),f.jsxs("div",{className:"flex-1",children:[f.jsx("h3",{className:"font-medium text-neutral-900 mb-2",children:"Génération impossible"}),f.jsx("p",{className:"text-sm text-neutral-600",children:W})]})]}),f.jsx("div",{className:"mt-4 flex justify-end",children:f.jsx("button",{type:"button",onClick:()=>V(null),className:"px-4 py-2 bg-neutral-100 hover:bg-neutral-200 text-neutral-700 rounded transition-colors text-sm",children:"Compris"})})]})})]})}const gs={"4/3":4/3,"16/9":16/9,"1/1":1,"3/4":3/4,"9/16":9/16,free:null};function Qg({src:r,onSave:e,onCancel:t,aspectRatio:n="4/3",outputFormat:s="image/jpeg",outputQuality:i=.9,theme:o="dark"}){const l=y.useRef(null),a=y.useRef(null),u=y.useRef(null),[c,d]=y.useState(!0),[h,p]=y.useState(null),[g,m]=y.useState(n),[x,_]=y.useState(0),[b,C]=y.useState({x:0,y:0,width:100,height:100}),[S,k]=y.useState(!1),[E,v]=y.useState(null),[T,B]=y.useState({x:0,y:0}),[j,N]=y.useState({x:0,y:0,width:100,height:100}),M=o==="dark",R=y.useCallback(()=>{const $=u.current;return $?x===90||x===270?{width:$.height,height:$.width}:{width:$.width,height:$.height}:{width:100,height:100}},[x]),w=y.useCallback(($,ke)=>{const se=$/ke,Re=.05;for(const[Ce,Ee]of Object.entries(gs))if(Ee!==null&&Math.abs(se-Ee)/Ee<Re)return Ce;return"free"},[]);y.useEffect(()=>{const $=new Image;$.crossOrigin="anonymous",$.onload=()=>{u.current=$;const ke=w($.width,$.height);m(ke),d(!1)},$.onerror=()=>{p("Failed to load image"),d(!1)},$.src=r},[r,w]);const D=y.useCallback(()=>{const{width:$,height:ke}=R(),se=gs[g];if(se===null){C({x:0,y:0,width:100,height:100});return}const Re=$/ke;let Ce,Ee;Re>se?(Ee=100,Ce=se/Re*100):(Ce=100,Ee=Re/se*100);const Se=(100-Ce)/2,Fe=(100-Ee)/2;C({x:Se,y:Fe,width:Ce,height:Ee})},[g,R]);y.useEffect(()=>{u.current&&D()},[g,x,D]),y.useEffect(()=>{const $=a.current,ke=u.current;if(!$||!ke||c)return;const se=$.getContext("2d");if(!se)return;const Re=l.current;if(!Re)return;const Ce=Re.clientWidth,Ee=Re.clientHeight-140,{width:Se,height:Fe}=R(),ze=Se/Fe;let ge,L;Ce/Ee>ze?(L=Math.min(Ee,Fe),ge=L*ze):(ge=Math.min(Ce,Se),L=ge/ze),ge>Ce&&(ge=Ce,L=ge/ze),L>Ee&&(L=Ee,ge=L*ze),$.width=ge,$.height=L,se.clearRect(0,0,ge,L),se.save(),se.translate(ge/2,L/2),se.rotate(x*Math.PI/180);let Me,Qe;x===90||x===270?(Me=L,Qe=ge):(Me=ge,Qe=L),se.drawImage(ke,-Me/2,-Qe/2,Me,Qe),se.restore(),se.fillStyle="rgba(0, 0, 0, 0.6)";const G=b.x/100*ge,ee=b.y/100*L,me=b.width/100*ge,_e=b.height/100*L;se.fillRect(0,0,ge,ee),se.fillRect(0,ee+_e,ge,L-ee-_e),se.fillRect(0,ee,G,_e),se.fillRect(G+me,ee,ge-G-me,_e),se.strokeStyle="#fff",se.lineWidth=2,se.strokeRect(G,ee,me,_e),se.strokeStyle="rgba(255, 255, 255, 0.3)",se.lineWidth=1,se.beginPath(),se.moveTo(G+me/3,ee),se.lineTo(G+me/3,ee+_e),se.moveTo(G+me*2/3,ee),se.lineTo(G+me*2/3,ee+_e),se.moveTo(G,ee+_e/3),se.lineTo(G+me,ee+_e/3),se.moveTo(G,ee+_e*2/3),se.lineTo(G+me,ee+_e*2/3),se.stroke();const Be=14;se.fillStyle="#fff",se.strokeStyle="#333",se.lineWidth=1,[{x:G,y:ee},{x:G+me,y:ee},{x:G,y:ee+_e},{x:G+me,y:ee+_e}].forEach(bt=>{se.fillRect(bt.x-Be/2,bt.y-Be/2,Be,Be),se.strokeRect(bt.x-Be/2,bt.y-Be/2,Be,Be)})},[b,x,c,R]);const F=$=>{const ke=a.current;if(!ke)return;const se=ke.getBoundingClientRect(),Re=($.clientX-se.left)/se.width*100,Ce=($.clientY-se.top)/se.height*100,Ee=4,Se=[{name:"nw",x:b.x,y:b.y},{name:"ne",x:b.x+b.width,y:b.y},{name:"sw",x:b.x,y:b.y+b.height},{name:"se",x:b.x+b.width,y:b.y+b.height}];for(const Fe of Se)if(Math.abs(Re-Fe.x)<Ee&&Math.abs(Ce-Fe.y)<Ee){v(Fe.name),B({x:Re,y:Ce}),N({...b});return}Re>=b.x&&Re<=b.x+b.width&&Ce>=b.y&&Ce<=b.y+b.height&&(k(!0),B({x:Re,y:Ce}),N({...b}))},I=$=>{const ke=a.current;if(!ke)return;const se=ke.getBoundingClientRect(),Re=($.clientX-se.left)/se.width*100,Ce=($.clientY-se.top)/se.height*100;if(S){const Ee=Re-T.x,Se=Ce-T.y;let Fe=j.x+Ee,ze=j.y+Se;Fe=Math.max(0,Math.min(Fe,100-j.width)),ze=Math.max(0,Math.min(ze,100-j.height)),C({...j,x:Fe,y:ze})}else if(E){const Ee=gs[g],{width:Se,height:Fe}=R(),ze=Se/Fe,ge=Ee?Ee/ze:null;let L={...j};const Me=Re-T.x,Qe=Ce-T.y;if(E==="se")L.width=Math.max(10,Math.min(100-L.x,j.width+Me)),ge?(L.height=L.width/ge,L.y+L.height>100&&(L.height=100-L.y,L.width=L.height*ge)):L.height=Math.max(10,Math.min(100-L.y,j.height+Qe));else if(E==="sw"){const G=-Me,ee=Math.max(10,j.width+G),me=j.x+j.width-ee;me>=0&&(L.width=ee,L.x=me,ge?(L.height=L.width/ge,L.y+L.height>100&&(L.height=100-L.y,L.width=L.height*ge,L.x=j.x+j.width-L.width)):L.height=Math.max(10,Math.min(100-L.y,j.height+Qe)))}else if(E==="ne")if(L.width=Math.max(10,Math.min(100-L.x,j.width+Me)),ge){const G=L.width/ge,ee=j.y+j.height-G;ee>=0?(L.height=G,L.y=ee):(L.y=0,L.height=j.y+j.height,L.width=L.height*ge)}else{const G=-Qe,ee=Math.max(10,j.height+G),me=j.y+j.height-ee;me>=0&&(L.height=ee,L.y=me)}else if(E==="nw"){const G=-Me,ee=Math.max(10,j.width+G),me=j.x+j.width-ee;if(me>=0)if(L.width=ee,L.x=me,ge){const _e=L.width/ge,Be=j.y+j.height-_e;Be>=0?(L.height=_e,L.y=Be):(L.y=0,L.height=j.y+j.height,L.width=L.height*ge,L.x=j.x+j.width-L.width)}else{const _e=-Qe,Be=Math.max(10,j.height+_e),Xe=j.y+j.height-Be;Xe>=0&&(L.height=Be,L.y=Xe)}}L.x=Math.max(0,L.x),L.y=Math.max(0,L.y),L.width=Math.min(L.width,100-L.x),L.height=Math.min(L.height,100-L.y),C(L)}},U=()=>{k(!1),v(null)},J=$=>{_(ke=>$==="right"?(ke+90)%360:(ke-90+360)%360)},te=()=>{const $=u.current;if(!$)return;const{width:ke,height:se}=R(),Re=b.x/100*ke,Ce=b.y/100*se,Ee=b.width/100*ke,Se=b.height/100*se,Fe=document.createElement("canvas"),ze=Fe.getContext("2d");if(!ze)return;Fe.width=Ee,Fe.height=Se;const ge=document.createElement("canvas"),L=ge.getContext("2d");L&&(ge.width=ke,ge.height=se,L.save(),L.translate(ke/2,se/2),L.rotate(x*Math.PI/180),L.drawImage($,-$.width/2,-$.height/2,$.width,$.height),L.restore(),ze.drawImage(ge,Re,Ce,Ee,Se,0,0,Ee,Se),Fe.toBlob(Me=>{Me&&e(Me)},s,i))},W={display:"flex",flexDirection:"column",width:"100%",height:"100%",background:M?"#1a1a1a":"#f5f5f5",overflow:"hidden"},V={flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",minHeight:0,overflow:"hidden"},H={display:"flex",flexDirection:"column",gap:"12px",padding:"16px",borderTop:`1px solid ${M?"#333":"#ddd"}`,background:M?"#242424":"#fff",flexShrink:0},ne={display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"},ce={padding:"10px 20px",borderRadius:"8px",border:"none",cursor:"pointer",fontSize:"14px",fontWeight:500,transition:"background 0.15s, opacity 0.15s"},le={...ce,background:"#E67E22",color:"#fff"},pe={...ce,background:M?"#333":"#e5e5e5",color:M?"#fff":"#333"},be={padding:"10px",borderRadius:"8px",border:"none",background:M?"#333":"#e5e5e5",color:M?"#fff":"#333",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},Te=$=>({padding:"8px 14px",borderRadius:"6px",border:$?"2px solid #E67E22":"2px solid transparent",background:$?"#E67E22":M?"#333":"#e5e5e5",color:$?"#fff":M?"#ccc":"#666",cursor:"pointer",fontSize:"13px",fontWeight:600,transition:"all 0.15s"});return c?f.jsx("div",{style:{...W,alignItems:"center",justifyContent:"center"},children:f.jsx("div",{style:{color:M?"#aaa":"#666"},children:"Loading image..."})}):h?f.jsxs("div",{style:{...W,alignItems:"center",justifyContent:"center"},children:[f.jsx("div",{style:{color:"#ef4444"},children:h}),t&&f.jsx("button",{onClick:t,style:{...pe,marginTop:"16px"},children:"Close"})]}):f.jsxs("div",{ref:l,style:W,children:[f.jsx("div",{style:V,children:f.jsx("canvas",{ref:a,style:{cursor:S?"grabbing":E?"nwse-resize":"grab",maxWidth:"100%",maxHeight:"100%"},onMouseDown:F,onMouseMove:I,onMouseUp:U,onMouseLeave:U})}),f.jsxs("div",{style:H,children:[f.jsx("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap",justifyContent:"center"},children:Object.keys(gs).map($=>f.jsx("button",{onClick:()=>m($),style:Te(g===$),children:$==="free"?"Libre":$},$))}),f.jsxs("div",{style:ne,children:[f.jsxs("div",{style:{display:"flex",gap:"8px"},children:[f.jsx("button",{onClick:()=>J("left"),style:be,title:"Rotate left",children:f.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:f.jsx("path",{d:"M2.5 2v6h6M2.66 15.57a10 10 0 1 0 .57-8.38"})})}),f.jsx("button",{onClick:()=>J("right"),style:be,title:"Rotate right",children:f.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:f.jsx("path",{d:"M21.5 2v6h-6M21.34 15.57a10 10 0 1 1-.57-8.38"})})})]}),f.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t&&f.jsx("button",{onClick:t,style:pe,children:"Annuler"}),f.jsx("button",{onClick:te,style:le,children:"Enregistrer"})]})]})]})]})}var Jg={value:()=>{}};function la(){for(var r=0,e=arguments.length,t={},n;r<e;++r){if(!(n=arguments[r]+"")||n in t||/[\s.]/.test(n))throw new Error("illegal type: "+n);t[n]=[]}return new Cs(t)}function Cs(r){this._=r}function Xg(r,e){return r.trim().split(/^|\s+/).map(function(t){var n="",s=t.indexOf(".");if(s>=0&&(n=t.slice(s+1),t=t.slice(0,s)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}Cs.prototype=la.prototype={constructor:Cs,on:function(r,e){var t=this._,n=Xg(r+"",t),s,i=-1,o=n.length;if(arguments.length<2){for(;++i<o;)if((s=(r=n[i]).type)&&(s=Zg(t[s],r.name)))return s;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++i<o;)if(s=(r=n[i]).type)t[s]=zl(t[s],r.name,e);else if(e==null)for(s in t)t[s]=zl(t[s],r.name,null);return this},copy:function(){var r={},e=this._;for(var t in e)r[t]=e[t].slice();return new Cs(r)},call:function(r,e){if((s=arguments.length-2)>0)for(var t=new Array(s),n=0,s,i;n<s;++n)t[n]=arguments[n+2];if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(i=this._[r],n=0,s=i.length;n<s;++n)i[n].value.apply(e,t)},apply:function(r,e,t){if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(var n=this._[r],s=0,i=n.length;s<i;++s)n[s].value.apply(e,t)}};function Zg(r,e){for(var t=0,n=r.length,s;t<n;++t)if((s=r[t]).name===e)return s.value}function zl(r,e,t){for(var n=0,s=r.length;n<s;++n)if(r[n].name===e){r[n]=Jg,r=r.slice(0,n).concat(r.slice(n+1));break}return t!=null&&r.push({name:e,value:t}),r}var bo="http://www.w3.org/1999/xhtml";const Ol={svg:"http://www.w3.org/2000/svg",xhtml:bo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function _i(r){var e=r+="",t=e.indexOf(":");return t>=0&&(e=r.slice(0,t))!=="xmlns"&&(r=r.slice(t+1)),Ol.hasOwnProperty(e)?{space:Ol[e],local:r}:r}function e0(r){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===bo&&e.documentElement.namespaceURI===bo?e.createElement(r):e.createElementNS(t,r)}}function t0(r){return function(){return this.ownerDocument.createElementNS(r.space,r.local)}}function ed(r){var e=_i(r);return(e.local?t0:e0)(e)}function r0(){}function ua(r){return r==null?r0:function(){return this.querySelector(r)}}function n0(r){typeof r!="function"&&(r=ua(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,l=n[s]=new Array(o),a,u,c=0;c<o;++c)(a=i[c])&&(u=r.call(a,a.__data__,c,i))&&("__data__"in a&&(u.__data__=a.__data__),l[c]=u);return new Tt(n,this._parents)}function s0(r){return r==null?[]:Array.isArray(r)?r:Array.from(r)}function i0(){return[]}function td(r){return r==null?i0:function(){return this.querySelectorAll(r)}}function o0(r){return function(){return s0(r.apply(this,arguments))}}function a0(r){typeof r=="function"?r=o0(r):r=td(r);for(var e=this._groups,t=e.length,n=[],s=[],i=0;i<t;++i)for(var o=e[i],l=o.length,a,u=0;u<l;++u)(a=o[u])&&(n.push(r.call(a,a.__data__,u,o)),s.push(a));return new Tt(n,s)}function rd(r){return function(){return this.matches(r)}}function nd(r){return function(e){return e.matches(r)}}var l0=Array.prototype.find;function u0(r){return function(){return l0.call(this.children,r)}}function c0(){return this.firstElementChild}function d0(r){return this.select(r==null?c0:u0(typeof r=="function"?r:nd(r)))}var f0=Array.prototype.filter;function h0(){return Array.from(this.children)}function p0(r){return function(){return f0.call(this.children,r)}}function g0(r){return this.selectAll(r==null?h0:p0(typeof r=="function"?r:nd(r)))}function m0(r){typeof r!="function"&&(r=rd(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,l=n[s]=[],a,u=0;u<o;++u)(a=i[u])&&r.call(a,a.__data__,u,i)&&l.push(a);return new Tt(n,this._parents)}function sd(r){return new Array(r.length)}function y0(){return new Tt(this._enter||this._groups.map(sd),this._parents)}function Qs(r,e){this.ownerDocument=r.ownerDocument,this.namespaceURI=r.namespaceURI,this._next=null,this._parent=r,this.__data__=e}Qs.prototype={constructor:Qs,appendChild:function(r){return this._parent.insertBefore(r,this._next)},insertBefore:function(r,e){return this._parent.insertBefore(r,e)},querySelector:function(r){return this._parent.querySelector(r)},querySelectorAll:function(r){return this._parent.querySelectorAll(r)}};function x0(r){return function(){return r}}function b0(r,e,t,n,s,i){for(var o=0,l,a=e.length,u=i.length;o<u;++o)(l=e[o])?(l.__data__=i[o],n[o]=l):t[o]=new Qs(r,i[o]);for(;o<a;++o)(l=e[o])&&(s[o]=l)}function v0(r,e,t,n,s,i,o){var l,a,u=new Map,c=e.length,d=i.length,h=new Array(c),p;for(l=0;l<c;++l)(a=e[l])&&(h[l]=p=o.call(a,a.__data__,l,e)+"",u.has(p)?s[l]=a:u.set(p,a));for(l=0;l<d;++l)p=o.call(r,i[l],l,i)+"",(a=u.get(p))?(n[l]=a,a.__data__=i[l],u.delete(p)):t[l]=new Qs(r,i[l]);for(l=0;l<c;++l)(a=e[l])&&u.get(h[l])===a&&(s[l]=a)}function _0(r){return r.__data__}function w0(r,e){if(!arguments.length)return Array.from(this,_0);var t=e?v0:b0,n=this._parents,s=this._groups;typeof r!="function"&&(r=x0(r));for(var i=s.length,o=new Array(i),l=new Array(i),a=new Array(i),u=0;u<i;++u){var c=n[u],d=s[u],h=d.length,p=C0(r.call(c,c&&c.__data__,u,n)),g=p.length,m=l[u]=new Array(g),x=o[u]=new Array(g),_=a[u]=new Array(h);t(c,d,m,x,_,p,e);for(var b=0,C=0,S,k;b<g;++b)if(S=m[b]){for(b>=C&&(C=b+1);!(k=x[C])&&++C<g;);S._next=k||null}}return o=new Tt(o,n),o._enter=l,o._exit=a,o}function C0(r){return typeof r=="object"&&"length"in r?r:Array.from(r)}function S0(){return new Tt(this._exit||this._groups.map(sd),this._parents)}function k0(r,e,t){var n=this.enter(),s=this,i=this.exit();return typeof r=="function"?(n=r(n),n&&(n=n.selection())):n=n.append(r+""),e!=null&&(s=e(s),s&&(s=s.selection())),t==null?i.remove():t(i),n&&s?n.merge(s).order():s}function E0(r){for(var e=r.selection?r.selection():r,t=this._groups,n=e._groups,s=t.length,i=n.length,o=Math.min(s,i),l=new Array(s),a=0;a<o;++a)for(var u=t[a],c=n[a],d=u.length,h=l[a]=new Array(d),p,g=0;g<d;++g)(p=u[g]||c[g])&&(h[g]=p);for(;a<s;++a)l[a]=t[a];return new Tt(l,this._parents)}function D0(){for(var r=this._groups,e=-1,t=r.length;++e<t;)for(var n=r[e],s=n.length-1,i=n[s],o;--s>=0;)(o=n[s])&&(i&&o.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(o,i),i=o);return this}function A0(r){r||(r=T0);function e(d,h){return d&&h?r(d.__data__,h.__data__):!d-!h}for(var t=this._groups,n=t.length,s=new Array(n),i=0;i<n;++i){for(var o=t[i],l=o.length,a=s[i]=new Array(l),u,c=0;c<l;++c)(u=o[c])&&(a[c]=u);a.sort(e)}return new Tt(s,this._parents).order()}function T0(r,e){return r<e?-1:r>e?1:r>=e?0:NaN}function N0(){var r=arguments[0];return arguments[0]=this,r.apply(null,arguments),this}function B0(){return Array.from(this)}function j0(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],s=0,i=n.length;s<i;++s){var o=n[s];if(o)return o}return null}function M0(){let r=0;for(const e of this)++r;return r}function R0(){return!this.node()}function F0(r){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],i=0,o=s.length,l;i<o;++i)(l=s[i])&&r.call(l,l.__data__,i,s);return this}function L0(r){return function(){this.removeAttribute(r)}}function P0(r){return function(){this.removeAttributeNS(r.space,r.local)}}function I0(r,e){return function(){this.setAttribute(r,e)}}function z0(r,e){return function(){this.setAttributeNS(r.space,r.local,e)}}function O0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(r):this.setAttribute(r,t)}}function $0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttributeNS(r.space,r.local):this.setAttributeNS(r.space,r.local,t)}}function q0(r,e){var t=_i(r);if(arguments.length<2){var n=this.node();return t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}return this.each((e==null?t.local?P0:L0:typeof e=="function"?t.local?$0:O0:t.local?z0:I0)(t,e))}function id(r){return r.ownerDocument&&r.ownerDocument.defaultView||r.document&&r||r.defaultView}function U0(r){return function(){this.style.removeProperty(r)}}function W0(r,e,t){return function(){this.style.setProperty(r,e,t)}}function H0(r,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(r):this.style.setProperty(r,n,t)}}function V0(r,e,t){return arguments.length>1?this.each((e==null?U0:typeof e=="function"?H0:W0)(r,e,t??"")):rn(this.node(),r)}function rn(r,e){return r.style.getPropertyValue(e)||id(r).getComputedStyle(r,null).getPropertyValue(e)}function G0(r){return function(){delete this[r]}}function K0(r,e){return function(){this[r]=e}}function Y0(r,e){return function(){var t=e.apply(this,arguments);t==null?delete this[r]:this[r]=t}}function Q0(r,e){return arguments.length>1?this.each((e==null?G0:typeof e=="function"?Y0:K0)(r,e)):this.node()[r]}function od(r){return r.trim().split(/^|\s+/)}function ca(r){return r.classList||new ad(r)}function ad(r){this._node=r,this._names=od(r.getAttribute("class")||"")}ad.prototype={add:function(r){var e=this._names.indexOf(r);e<0&&(this._names.push(r),this._node.setAttribute("class",this._names.join(" ")))},remove:function(r){var e=this._names.indexOf(r);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(r){return this._names.indexOf(r)>=0}};function ld(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.add(e[n])}function ud(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.remove(e[n])}function J0(r){return function(){ld(this,r)}}function X0(r){return function(){ud(this,r)}}function Z0(r,e){return function(){(e.apply(this,arguments)?ld:ud)(this,r)}}function em(r,e){var t=od(r+"");if(arguments.length<2){for(var n=ca(this.node()),s=-1,i=t.length;++s<i;)if(!n.contains(t[s]))return!1;return!0}return this.each((typeof e=="function"?Z0:e?J0:X0)(t,e))}function tm(){this.textContent=""}function rm(r){return function(){this.textContent=r}}function nm(r){return function(){var e=r.apply(this,arguments);this.textContent=e??""}}function sm(r){return arguments.length?this.each(r==null?tm:(typeof r=="function"?nm:rm)(r)):this.node().textContent}function im(){this.innerHTML=""}function om(r){return function(){this.innerHTML=r}}function am(r){return function(){var e=r.apply(this,arguments);this.innerHTML=e??""}}function lm(r){return arguments.length?this.each(r==null?im:(typeof r=="function"?am:om)(r)):this.node().innerHTML}function um(){this.nextSibling&&this.parentNode.appendChild(this)}function cm(){return this.each(um)}function dm(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function fm(){return this.each(dm)}function hm(r){var e=typeof r=="function"?r:ed(r);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function pm(){return null}function gm(r,e){var t=typeof r=="function"?r:ed(r),n=e==null?pm:typeof e=="function"?e:ua(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function mm(){var r=this.parentNode;r&&r.removeChild(this)}function ym(){return this.each(mm)}function xm(){var r=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function bm(){var r=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function vm(r){return this.select(r?bm:xm)}function _m(r){return arguments.length?this.property("__data__",r):this.node().__data__}function wm(r){return function(e){r.call(this,e,this.__data__)}}function Cm(r){return r.trim().split(/^|\s+/).map(function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function Sm(r){return function(){var e=this.__on;if(e){for(var t=0,n=-1,s=e.length,i;t<s;++t)i=e[t],(!r.type||i.type===r.type)&&i.name===r.name?this.removeEventListener(i.type,i.listener,i.options):e[++n]=i;++n?e.length=n:delete this.__on}}}function km(r,e,t){return function(){var n=this.__on,s,i=wm(e);if(n){for(var o=0,l=n.length;o<l;++o)if((s=n[o]).type===r.type&&s.name===r.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=i,s.options=t),s.value=e;return}}this.addEventListener(r.type,i,t),s={type:r.type,name:r.name,value:e,listener:i,options:t},n?n.push(s):this.__on=[s]}}function Em(r,e,t){var n=Cm(r+""),s,i=n.length,o;if(arguments.length<2){var l=this.node().__on;if(l){for(var a=0,u=l.length,c;a<u;++a)for(s=0,c=l[a];s<i;++s)if((o=n[s]).type===c.type&&o.name===c.name)return c.value}return}for(l=e?km:Sm,s=0;s<i;++s)this.each(l(n[s],e,t));return this}function cd(r,e,t){var n=id(r),s=n.CustomEvent;typeof s=="function"?s=new s(e,t):(s=n.document.createEvent("Event"),t?(s.initEvent(e,t.bubbles,t.cancelable),s.detail=t.detail):s.initEvent(e,!1,!1)),r.dispatchEvent(s)}function Dm(r,e){return function(){return cd(this,r,e)}}function Am(r,e){return function(){return cd(this,r,e.apply(this,arguments))}}function Tm(r,e){return this.each((typeof e=="function"?Am:Dm)(r,e))}function*Nm(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],s=0,i=n.length,o;s<i;++s)(o=n[s])&&(yield o)}var dd=[null];function Tt(r,e){this._groups=r,this._parents=e}function ss(){return new Tt([[document.documentElement]],dd)}function Bm(){return this}Tt.prototype=ss.prototype={constructor:Tt,select:n0,selectAll:a0,selectChild:d0,selectChildren:g0,filter:m0,data:w0,enter:y0,exit:S0,join:k0,merge:E0,selection:Bm,order:D0,sort:A0,call:N0,nodes:B0,node:j0,size:M0,empty:R0,each:F0,attr:q0,style:V0,property:Q0,classed:em,text:sm,html:lm,raise:cm,lower:fm,append:hm,insert:gm,remove:ym,clone:vm,datum:_m,on:Em,dispatch:Tm,[Symbol.iterator]:Nm};function Pt(r){return typeof r=="string"?new Tt([[document.querySelector(r)]],[document.documentElement]):new Tt([[r]],dd)}function jm(r){let e;for(;e=r.sourceEvent;)r=e;return r}function wr(r,e){if(r=jm(r),e===void 0&&(e=r.currentTarget),e){var t=e.ownerSVGElement||e;if(t.createSVGPoint){var n=t.createSVGPoint();return n.x=r.clientX,n.y=r.clientY,n=n.matrixTransform(e.getScreenCTM().inverse()),[n.x,n.y]}if(e.getBoundingClientRect){var s=e.getBoundingClientRect();return[r.clientX-s.left-e.clientLeft,r.clientY-s.top-e.clientTop]}}return[r.pageX,r.pageY]}const vo={capture:!0,passive:!1};function _o(r){r.preventDefault(),r.stopImmediatePropagation()}function Mm(r){var e=r.document.documentElement,t=Pt(r).on("dragstart.drag",_o,vo);"onselectstart"in e?t.on("selectstart.drag",_o,vo):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Rm(r,e){var t=r.document.documentElement,n=Pt(r).on("dragstart.drag",null);e&&(n.on("click.drag",_o,vo),setTimeout(function(){n.on("click.drag",null)},0)),"onselectstart"in t?n.on("selectstart.drag",null):(t.style.MozUserSelect=t.__noselect,delete t.__noselect)}function da(r,e,t){r.prototype=e.prototype=t,t.constructor=r}function fd(r,e){var t=Object.create(r.prototype);for(var n in e)t[n]=e[n];return t}function is(){}var $n=.7,Js=1/$n,Jr="\\s*([+-]?\\d+)\\s*",qn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Kt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Fm=/^#([0-9a-f]{3,8})$/,Lm=new RegExp(`^rgb\\(${Jr},${Jr},${Jr}\\)$`),Pm=new RegExp(`^rgb\\(${Kt},${Kt},${Kt}\\)$`),Im=new RegExp(`^rgba\\(${Jr},${Jr},${Jr},${qn}\\)$`),zm=new RegExp(`^rgba\\(${Kt},${Kt},${Kt},${qn}\\)$`),Om=new RegExp(`^hsl\\(${qn},${Kt},${Kt}\\)$`),$m=new RegExp(`^hsla\\(${qn},${Kt},${Kt},${qn}\\)$`),$l={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};da(is,Un,{copy(r){return Object.assign(new this.constructor,this,r)},displayable(){return this.rgb().displayable()},hex:ql,formatHex:ql,formatHex8:qm,formatHsl:Um,formatRgb:Ul,toString:Ul});function ql(){return this.rgb().formatHex()}function qm(){return this.rgb().formatHex8()}function Um(){return hd(this).formatHsl()}function Ul(){return this.rgb().formatRgb()}function Un(r){var e,t;return r=(r+"").trim().toLowerCase(),(e=Fm.exec(r))?(t=e[1].length,e=parseInt(e[1],16),t===6?Wl(e):t===3?new St(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?ms(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?ms(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=Lm.exec(r))?new St(e[1],e[2],e[3],1):(e=Pm.exec(r))?new St(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Im.exec(r))?ms(e[1],e[2],e[3],e[4]):(e=zm.exec(r))?ms(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Om.exec(r))?Gl(e[1],e[2]/100,e[3]/100,1):(e=$m.exec(r))?Gl(e[1],e[2]/100,e[3]/100,e[4]):$l.hasOwnProperty(r)?Wl($l[r]):r==="transparent"?new St(NaN,NaN,NaN,0):null}function Wl(r){return new St(r>>16&255,r>>8&255,r&255,1)}function ms(r,e,t,n){return n<=0&&(r=e=t=NaN),new St(r,e,t,n)}function Wm(r){return r instanceof is||(r=Un(r)),r?(r=r.rgb(),new St(r.r,r.g,r.b,r.opacity)):new St}function wo(r,e,t,n){return arguments.length===1?Wm(r):new St(r,e,t,n??1)}function St(r,e,t,n){this.r=+r,this.g=+e,this.b=+t,this.opacity=+n}da(St,wo,fd(is,{brighter(r){return r=r==null?Js:Math.pow(Js,r),new St(this.r*r,this.g*r,this.b*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new St(this.r*r,this.g*r,this.b*r,this.opacity)},rgb(){return this},clamp(){return new St(Tr(this.r),Tr(this.g),Tr(this.b),Xs(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Hl,formatHex:Hl,formatHex8:Hm,formatRgb:Vl,toString:Vl}));function Hl(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}`}function Hm(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}${Sr((isNaN(this.opacity)?1:this.opacity)*255)}`}function Vl(){const r=Xs(this.opacity);return`${r===1?"rgb(":"rgba("}${Tr(this.r)}, ${Tr(this.g)}, ${Tr(this.b)}${r===1?")":`, ${r})`}`}function Xs(r){return isNaN(r)?1:Math.max(0,Math.min(1,r))}function Tr(r){return Math.max(0,Math.min(255,Math.round(r)||0))}function Sr(r){return r=Tr(r),(r<16?"0":"")+r.toString(16)}function Gl(r,e,t,n){return n<=0?r=e=t=NaN:t<=0||t>=1?r=e=NaN:e<=0&&(r=NaN),new It(r,e,t,n)}function hd(r){if(r instanceof It)return new It(r.h,r.s,r.l,r.opacity);if(r instanceof is||(r=Un(r)),!r)return new It;if(r instanceof It)return r;r=r.rgb();var e=r.r/255,t=r.g/255,n=r.b/255,s=Math.min(e,t,n),i=Math.max(e,t,n),o=NaN,l=i-s,a=(i+s)/2;return l?(e===i?o=(t-n)/l+(t<n)*6:t===i?o=(n-e)/l+2:o=(e-t)/l+4,l/=a<.5?i+s:2-i-s,o*=60):l=a>0&&a<1?0:o,new It(o,l,a,r.opacity)}function Vm(r,e,t,n){return arguments.length===1?hd(r):new It(r,e,t,n??1)}function It(r,e,t,n){this.h=+r,this.s=+e,this.l=+t,this.opacity=+n}da(It,Vm,fd(is,{brighter(r){return r=r==null?Js:Math.pow(Js,r),new It(this.h,this.s,this.l*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new It(this.h,this.s,this.l*r,this.opacity)},rgb(){var r=this.h%360+(this.h<0)*360,e=isNaN(r)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*e,s=2*t-n;return new St(qi(r>=240?r-240:r+120,s,n),qi(r,s,n),qi(r<120?r+240:r-120,s,n),this.opacity)},clamp(){return new It(Kl(this.h),ys(this.s),ys(this.l),Xs(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const r=Xs(this.opacity);return`${r===1?"hsl(":"hsla("}${Kl(this.h)}, ${ys(this.s)*100}%, ${ys(this.l)*100}%${r===1?")":`, ${r})`}`}}));function Kl(r){return r=(r||0)%360,r<0?r+360:r}function ys(r){return Math.max(0,Math.min(1,r||0))}function qi(r,e,t){return(r<60?e+(t-e)*r/60:r<180?t:r<240?e+(t-e)*(240-r)/60:e)*255}const pd=r=>()=>r;function Gm(r,e){return function(t){return r+t*e}}function Km(r,e,t){return r=Math.pow(r,t),e=Math.pow(e,t)-r,t=1/t,function(n){return Math.pow(r+n*e,t)}}function Ym(r){return(r=+r)==1?gd:function(e,t){return t-e?Km(e,t,r):pd(isNaN(e)?t:e)}}function gd(r,e){var t=e-r;return t?Gm(r,t):pd(isNaN(r)?e:r)}const Yl=function r(e){var t=Ym(e);function n(s,i){var o=t((s=wo(s)).r,(i=wo(i)).r),l=t(s.g,i.g),a=t(s.b,i.b),u=gd(s.opacity,i.opacity);return function(c){return s.r=o(c),s.g=l(c),s.b=a(c),s.opacity=u(c),s+""}}return n.gamma=r,n}(1);function fr(r,e){return r=+r,e=+e,function(t){return r*(1-t)+e*t}}var Co=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ui=new RegExp(Co.source,"g");function Qm(r){return function(){return r}}function Jm(r){return function(e){return r(e)+""}}function Xm(r,e){var t=Co.lastIndex=Ui.lastIndex=0,n,s,i,o=-1,l=[],a=[];for(r=r+"",e=e+"";(n=Co.exec(r))&&(s=Ui.exec(e));)(i=s.index)>t&&(i=e.slice(t,i),l[o]?l[o]+=i:l[++o]=i),(n=n[0])===(s=s[0])?l[o]?l[o]+=s:l[++o]=s:(l[++o]=null,a.push({i:o,x:fr(n,s)})),t=Ui.lastIndex;return t<e.length&&(i=e.slice(t),l[o]?l[o]+=i:l[++o]=i),l.length<2?a[0]?Jm(a[0].x):Qm(e):(e=a.length,function(u){for(var c=0,d;c<e;++c)l[(d=a[c]).i]=d.x(u);return l.join("")})}var Ql=180/Math.PI,So={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function md(r,e,t,n,s,i){var o,l,a;return(o=Math.sqrt(r*r+e*e))&&(r/=o,e/=o),(a=r*t+e*n)&&(t-=r*a,n-=e*a),(l=Math.sqrt(t*t+n*n))&&(t/=l,n/=l,a/=l),r*n<e*t&&(r=-r,e=-e,a=-a,o=-o),{translateX:s,translateY:i,rotate:Math.atan2(e,r)*Ql,skewX:Math.atan(a)*Ql,scaleX:o,scaleY:l}}var xs;function Zm(r){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(r+"");return e.isIdentity?So:md(e.a,e.b,e.c,e.d,e.e,e.f)}function ey(r){return r==null||(xs||(xs=document.createElementNS("http://www.w3.org/2000/svg","g")),xs.setAttribute("transform",r),!(r=xs.transform.baseVal.consolidate()))?So:(r=r.matrix,md(r.a,r.b,r.c,r.d,r.e,r.f))}function yd(r,e,t,n){function s(u){return u.length?u.pop()+" ":""}function i(u,c,d,h,p,g){if(u!==d||c!==h){var m=p.push("translate(",null,e,null,t);g.push({i:m-4,x:fr(u,d)},{i:m-2,x:fr(c,h)})}else(d||h)&&p.push("translate("+d+e+h+t)}function o(u,c,d,h){u!==c?(u-c>180?c+=360:c-u>180&&(u+=360),h.push({i:d.push(s(d)+"rotate(",null,n)-2,x:fr(u,c)})):c&&d.push(s(d)+"rotate("+c+n)}function l(u,c,d,h){u!==c?h.push({i:d.push(s(d)+"skewX(",null,n)-2,x:fr(u,c)}):c&&d.push(s(d)+"skewX("+c+n)}function a(u,c,d,h,p,g){if(u!==d||c!==h){var m=p.push(s(p)+"scale(",null,",",null,")");g.push({i:m-4,x:fr(u,d)},{i:m-2,x:fr(c,h)})}else(d!==1||h!==1)&&p.push(s(p)+"scale("+d+","+h+")")}return function(u,c){var d=[],h=[];return u=r(u),c=r(c),i(u.translateX,u.translateY,c.translateX,c.translateY,d,h),o(u.rotate,c.rotate,d,h),l(u.skewX,c.skewX,d,h),a(u.scaleX,u.scaleY,c.scaleX,c.scaleY,d,h),u=c=null,function(p){for(var g=-1,m=h.length,x;++g<m;)d[(x=h[g]).i]=x.x(p);return d.join("")}}}var ty=yd(Zm,"px, ","px)","deg)"),ry=yd(ey,", ",")",")"),ny=1e-12;function Jl(r){return((r=Math.exp(r))+1/r)/2}function sy(r){return((r=Math.exp(r))-1/r)/2}function iy(r){return((r=Math.exp(2*r))-1)/(r+1)}const oy=function r(e,t,n){function s(i,o){var l=i[0],a=i[1],u=i[2],c=o[0],d=o[1],h=o[2],p=c-l,g=d-a,m=p*p+g*g,x,_;if(m<ny)_=Math.log(h/u)/e,x=function(v){return[l+v*p,a+v*g,u*Math.exp(e*v*_)]};else{var b=Math.sqrt(m),C=(h*h-u*u+n*m)/(2*u*t*b),S=(h*h-u*u-n*m)/(2*h*t*b),k=Math.log(Math.sqrt(C*C+1)-C),E=Math.log(Math.sqrt(S*S+1)-S);_=(E-k)/e,x=function(v){var T=v*_,B=Jl(k),j=u/(t*b)*(B*iy(e*T+k)-sy(k));return[l+j*p,a+j*g,u*B/Jl(e*T+k)]}}return x.duration=_*1e3*e/Math.SQRT2,x}return s.rho=function(i){var o=Math.max(.001,+i),l=o*o,a=l*l;return r(o,l,a)},s}(Math.SQRT2,2,4);var nn=0,Cn=0,yn=0,xd=1e3,Zs,Sn,ei=0,Lr=0,wi=0,Wn=typeof performance=="object"&&performance.now?performance:Date,bd=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(r){setTimeout(r,17)};function fa(){return Lr||(bd(ay),Lr=Wn.now()+wi)}function ay(){Lr=0}function ti(){this._call=this._time=this._next=null}ti.prototype=vd.prototype={constructor:ti,restart:function(r,e,t){if(typeof r!="function")throw new TypeError("callback is not a function");t=(t==null?fa():+t)+(e==null?0:+e),!this._next&&Sn!==this&&(Sn?Sn._next=this:Zs=this,Sn=this),this._call=r,this._time=t,ko()},stop:function(){this._call&&(this._call=null,this._time=1/0,ko())}};function vd(r,e,t){var n=new ti;return n.restart(r,e,t),n}function ly(){fa(),++nn;for(var r=Zs,e;r;)(e=Lr-r._time)>=0&&r._call.call(void 0,e),r=r._next;--nn}function Xl(){Lr=(ei=Wn.now())+wi,nn=Cn=0;try{ly()}finally{nn=0,cy(),Lr=0}}function uy(){var r=Wn.now(),e=r-ei;e>xd&&(wi-=e,ei=r)}function cy(){for(var r,e=Zs,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),r=e,e=e._next):(t=e._next,e._next=null,e=r?r._next=t:Zs=t);Sn=r,ko(n)}function ko(r){if(!nn){Cn&&(Cn=clearTimeout(Cn));var e=r-Lr;e>24?(r<1/0&&(Cn=setTimeout(Xl,r-Wn.now()-wi)),yn&&(yn=clearInterval(yn))):(yn||(ei=Wn.now(),yn=setInterval(uy,xd)),nn=1,bd(Xl))}}function Zl(r,e,t){var n=new ti;return e=e==null?0:+e,n.restart(s=>{n.stop(),r(s+e)},e,t),n}var dy=la("start","end","cancel","interrupt"),fy=[],_d=0,eu=1,Eo=2,Ss=3,tu=4,Do=5,ks=6;function Ci(r,e,t,n,s,i){var o=r.__transition;if(!o)r.__transition={};else if(t in o)return;hy(r,t,{name:e,index:n,group:s,on:dy,tween:fy,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:_d})}function ha(r,e){var t=Ut(r,e);if(t.state>_d)throw new Error("too late; already scheduled");return t}function Zt(r,e){var t=Ut(r,e);if(t.state>Ss)throw new Error("too late; already running");return t}function Ut(r,e){var t=r.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function hy(r,e,t){var n=r.__transition,s;n[e]=t,t.timer=vd(i,0,t.time);function i(u){t.state=eu,t.timer.restart(o,t.delay,t.time),t.delay<=u&&o(u-t.delay)}function o(u){var c,d,h,p;if(t.state!==eu)return a();for(c in n)if(p=n[c],p.name===t.name){if(p.state===Ss)return Zl(o);p.state===tu?(p.state=ks,p.timer.stop(),p.on.call("interrupt",r,r.__data__,p.index,p.group),delete n[c]):+c<e&&(p.state=ks,p.timer.stop(),p.on.call("cancel",r,r.__data__,p.index,p.group),delete n[c])}if(Zl(function(){t.state===Ss&&(t.state=tu,t.timer.restart(l,t.delay,t.time),l(u))}),t.state=Eo,t.on.call("start",r,r.__data__,t.index,t.group),t.state===Eo){for(t.state=Ss,s=new Array(h=t.tween.length),c=0,d=-1;c<h;++c)(p=t.tween[c].value.call(r,r.__data__,t.index,t.group))&&(s[++d]=p);s.length=d+1}}function l(u){for(var c=u<t.duration?t.ease.call(null,u/t.duration):(t.timer.restart(a),t.state=Do,1),d=-1,h=s.length;++d<h;)s[d].call(r,c);t.state===Do&&(t.on.call("end",r,r.__data__,t.index,t.group),a())}function a(){t.state=ks,t.timer.stop(),delete n[e];for(var u in n)return;delete r.__transition}}function Es(r,e){var t=r.__transition,n,s,i=!0,o;if(t){e=e==null?null:e+"";for(o in t){if((n=t[o]).name!==e){i=!1;continue}s=n.state>Eo&&n.state<Do,n.state=ks,n.timer.stop(),n.on.call(s?"interrupt":"cancel",r,r.__data__,n.index,n.group),delete t[o]}i&&delete r.__transition}}function py(r){return this.each(function(){Es(this,r)})}function gy(r,e){var t,n;return function(){var s=Zt(this,r),i=s.tween;if(i!==t){n=t=i;for(var o=0,l=n.length;o<l;++o)if(n[o].name===e){n=n.slice(),n.splice(o,1);break}}s.tween=n}}function my(r,e,t){var n,s;if(typeof t!="function")throw new Error;return function(){var i=Zt(this,r),o=i.tween;if(o!==n){s=(n=o).slice();for(var l={name:e,value:t},a=0,u=s.length;a<u;++a)if(s[a].name===e){s[a]=l;break}a===u&&s.push(l)}i.tween=s}}function yy(r,e){var t=this._id;if(r+="",arguments.length<2){for(var n=Ut(this.node(),t).tween,s=0,i=n.length,o;s<i;++s)if((o=n[s]).name===r)return o.value;return null}return this.each((e==null?gy:my)(t,r,e))}function pa(r,e,t){var n=r._id;return r.each(function(){var s=Zt(this,n);(s.value||(s.value={}))[e]=t.apply(this,arguments)}),function(s){return Ut(s,n).value[e]}}function wd(r,e){var t;return(typeof e=="number"?fr:e instanceof Un?Yl:(t=Un(e))?(e=t,Yl):Xm)(r,e)}function xy(r){return function(){this.removeAttribute(r)}}function by(r){return function(){this.removeAttributeNS(r.space,r.local)}}function vy(r,e,t){var n,s=t+"",i;return function(){var o=this.getAttribute(r);return o===s?null:o===n?i:i=e(n=o,t)}}function _y(r,e,t){var n,s=t+"",i;return function(){var o=this.getAttributeNS(r.space,r.local);return o===s?null:o===n?i:i=e(n=o,t)}}function wy(r,e,t){var n,s,i;return function(){var o,l=t(this),a;return l==null?void this.removeAttribute(r):(o=this.getAttribute(r),a=l+"",o===a?null:o===n&&a===s?i:(s=a,i=e(n=o,l)))}}function Cy(r,e,t){var n,s,i;return function(){var o,l=t(this),a;return l==null?void this.removeAttributeNS(r.space,r.local):(o=this.getAttributeNS(r.space,r.local),a=l+"",o===a?null:o===n&&a===s?i:(s=a,i=e(n=o,l)))}}function Sy(r,e){var t=_i(r),n=t==="transform"?ry:wd;return this.attrTween(r,typeof e=="function"?(t.local?Cy:wy)(t,n,pa(this,"attr."+r,e)):e==null?(t.local?by:xy)(t):(t.local?_y:vy)(t,n,e))}function ky(r,e){return function(t){this.setAttribute(r,e.call(this,t))}}function Ey(r,e){return function(t){this.setAttributeNS(r.space,r.local,e.call(this,t))}}function Dy(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&Ey(r,i)),t}return s._value=e,s}function Ay(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&ky(r,i)),t}return s._value=e,s}function Ty(r,e){var t="attr."+r;if(arguments.length<2)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;var n=_i(r);return this.tween(t,(n.local?Dy:Ay)(n,e))}function Ny(r,e){return function(){ha(this,r).delay=+e.apply(this,arguments)}}function By(r,e){return e=+e,function(){ha(this,r).delay=e}}function jy(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?Ny:By)(e,r)):Ut(this.node(),e).delay}function My(r,e){return function(){Zt(this,r).duration=+e.apply(this,arguments)}}function Ry(r,e){return e=+e,function(){Zt(this,r).duration=e}}function Fy(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?My:Ry)(e,r)):Ut(this.node(),e).duration}function Ly(r,e){if(typeof e!="function")throw new Error;return function(){Zt(this,r).ease=e}}function Py(r){var e=this._id;return arguments.length?this.each(Ly(e,r)):Ut(this.node(),e).ease}function Iy(r,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;Zt(this,r).ease=t}}function zy(r){if(typeof r!="function")throw new Error;return this.each(Iy(this._id,r))}function Oy(r){typeof r!="function"&&(r=rd(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,l=n[s]=[],a,u=0;u<o;++u)(a=i[u])&&r.call(a,a.__data__,u,i)&&l.push(a);return new ir(n,this._parents,this._name,this._id)}function $y(r){if(r._id!==this._id)throw new Error;for(var e=this._groups,t=r._groups,n=e.length,s=t.length,i=Math.min(n,s),o=new Array(n),l=0;l<i;++l)for(var a=e[l],u=t[l],c=a.length,d=o[l]=new Array(c),h,p=0;p<c;++p)(h=a[p]||u[p])&&(d[p]=h);for(;l<n;++l)o[l]=e[l];return new ir(o,this._parents,this._name,this._id)}function qy(r){return(r+"").trim().split(/^|\s+/).every(function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||e==="start"})}function Uy(r,e,t){var n,s,i=qy(e)?ha:Zt;return function(){var o=i(this,r),l=o.on;l!==n&&(s=(n=l).copy()).on(e,t),o.on=s}}function Wy(r,e){var t=this._id;return arguments.length<2?Ut(this.node(),t).on.on(r):this.each(Uy(t,r,e))}function Hy(r){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==r)return;e&&e.removeChild(this)}}function Vy(){return this.on("end.remove",Hy(this._id))}function Gy(r){var e=this._name,t=this._id;typeof r!="function"&&(r=ua(r));for(var n=this._groups,s=n.length,i=new Array(s),o=0;o<s;++o)for(var l=n[o],a=l.length,u=i[o]=new Array(a),c,d,h=0;h<a;++h)(c=l[h])&&(d=r.call(c,c.__data__,h,l))&&("__data__"in c&&(d.__data__=c.__data__),u[h]=d,Ci(u[h],e,t,h,u,Ut(c,t)));return new ir(i,this._parents,e,t)}function Ky(r){var e=this._name,t=this._id;typeof r!="function"&&(r=td(r));for(var n=this._groups,s=n.length,i=[],o=[],l=0;l<s;++l)for(var a=n[l],u=a.length,c,d=0;d<u;++d)if(c=a[d]){for(var h=r.call(c,c.__data__,d,a),p,g=Ut(c,t),m=0,x=h.length;m<x;++m)(p=h[m])&&Ci(p,e,t,m,h,g);i.push(h),o.push(c)}return new ir(i,o,e,t)}var Yy=ss.prototype.constructor;function Qy(){return new Yy(this._groups,this._parents)}function Jy(r,e){var t,n,s;return function(){var i=rn(this,r),o=(this.style.removeProperty(r),rn(this,r));return i===o?null:i===t&&o===n?s:s=e(t=i,n=o)}}function Cd(r){return function(){this.style.removeProperty(r)}}function Xy(r,e,t){var n,s=t+"",i;return function(){var o=rn(this,r);return o===s?null:o===n?i:i=e(n=o,t)}}function Zy(r,e,t){var n,s,i;return function(){var o=rn(this,r),l=t(this),a=l+"";return l==null&&(a=l=(this.style.removeProperty(r),rn(this,r))),o===a?null:o===n&&a===s?i:(s=a,i=e(n=o,l))}}function e2(r,e){var t,n,s,i="style."+e,o="end."+i,l;return function(){var a=Zt(this,r),u=a.on,c=a.value[i]==null?l||(l=Cd(e)):void 0;(u!==t||s!==c)&&(n=(t=u).copy()).on(o,s=c),a.on=n}}function t2(r,e,t){var n=(r+="")=="transform"?ty:wd;return e==null?this.styleTween(r,Jy(r,n)).on("end.style."+r,Cd(r)):typeof e=="function"?this.styleTween(r,Zy(r,n,pa(this,"style."+r,e))).each(e2(this._id,r)):this.styleTween(r,Xy(r,n,e),t).on("end.style."+r,null)}function r2(r,e,t){return function(n){this.style.setProperty(r,e.call(this,n),t)}}function n2(r,e,t){var n,s;function i(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&r2(r,o,t)),n}return i._value=e,i}function s2(r,e,t){var n="style."+(r+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,n2(r,e,t??""))}function i2(r){return function(){this.textContent=r}}function o2(r){return function(){var e=r(this);this.textContent=e??""}}function a2(r){return this.tween("text",typeof r=="function"?o2(pa(this,"text",r)):i2(r==null?"":r+""))}function l2(r){return function(e){this.textContent=r.call(this,e)}}function u2(r){var e,t;function n(){var s=r.apply(this,arguments);return s!==t&&(e=(t=s)&&l2(s)),e}return n._value=r,n}function c2(r){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(r==null)return this.tween(e,null);if(typeof r!="function")throw new Error;return this.tween(e,u2(r))}function d2(){for(var r=this._name,e=this._id,t=Sd(),n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],l=o.length,a,u=0;u<l;++u)if(a=o[u]){var c=Ut(a,e);Ci(a,r,t,u,o,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new ir(n,this._parents,r,t)}function f2(){var r,e,t=this,n=t._id,s=t.size();return new Promise(function(i,o){var l={value:o},a={value:function(){--s===0&&i()}};t.each(function(){var u=Zt(this,n),c=u.on;c!==r&&(e=(r=c).copy(),e._.cancel.push(l),e._.interrupt.push(l),e._.end.push(a)),u.on=e}),s===0&&i()})}var h2=0;function ir(r,e,t,n){this._groups=r,this._parents=e,this._name=t,this._id=n}function Sd(){return++h2}var tr=ss.prototype;ir.prototype={constructor:ir,select:Gy,selectAll:Ky,selectChild:tr.selectChild,selectChildren:tr.selectChildren,filter:Oy,merge:$y,selection:Qy,transition:d2,call:tr.call,nodes:tr.nodes,node:tr.node,size:tr.size,empty:tr.empty,each:tr.each,on:Wy,attr:Sy,attrTween:Ty,style:t2,styleTween:s2,text:a2,textTween:c2,remove:Vy,tween:yy,delay:jy,duration:Fy,ease:Py,easeVarying:zy,end:f2,[Symbol.iterator]:tr[Symbol.iterator]};function p2(r){return((r*=2)<=1?r*r*r:(r-=2)*r*r+2)/2}var g2={time:null,delay:0,duration:250,ease:p2};function m2(r,e){for(var t;!(t=r.__transition)||!(t=t[e]);)if(!(r=r.parentNode))throw new Error(`transition ${e} not found`);return t}function y2(r){var e,t;r instanceof ir?(e=r._id,r=r._name):(e=Sd(),(t=g2).time=fa(),r=r==null?null:r+"");for(var n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],l=o.length,a,u=0;u<l;++u)(a=o[u])&&Ci(a,r,e,u,o,t||m2(a,e));return new ir(n,this._parents,r,e)}ss.prototype.interrupt=py;ss.prototype.transition=y2;const bs=r=>()=>r;function x2(r,{sourceEvent:e,target:t,transform:n,dispatch:s}){Object.defineProperties(this,{type:{value:r,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:t,enumerable:!0,configurable:!0},transform:{value:n,enumerable:!0,configurable:!0},_:{value:s}})}function nr(r,e,t){this.k=r,this.x=e,this.y=t}nr.prototype={constructor:nr,scale:function(r){return r===1?this:new nr(this.k*r,this.x,this.y)},translate:function(r,e){return r===0&e===0?this:new nr(this.k,this.x+this.k*r,this.y+this.k*e)},apply:function(r){return[r[0]*this.k+this.x,r[1]*this.k+this.y]},applyX:function(r){return r*this.k+this.x},applyY:function(r){return r*this.k+this.y},invert:function(r){return[(r[0]-this.x)/this.k,(r[1]-this.y)/this.k]},invertX:function(r){return(r-this.x)/this.k},invertY:function(r){return(r-this.y)/this.k},rescaleX:function(r){return r.copy().domain(r.range().map(this.invertX,this).map(r.invert,r))},rescaleY:function(r){return r.copy().domain(r.range().map(this.invertY,this).map(r.invert,r))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ri=new nr(1,0,0);nr.prototype;function Wi(r){r.stopImmediatePropagation()}function xn(r){r.preventDefault(),r.stopImmediatePropagation()}function b2(r){return(!r.ctrlKey||r.type==="wheel")&&!r.button}function v2(){var r=this;return r instanceof SVGElement?(r=r.ownerSVGElement||r,r.hasAttribute("viewBox")?(r=r.viewBox.baseVal,[[r.x,r.y],[r.x+r.width,r.y+r.height]]):[[0,0],[r.width.baseVal.value,r.height.baseVal.value]]):[[0,0],[r.clientWidth,r.clientHeight]]}function ru(){return this.__zoom||ri}function _2(r){return-r.deltaY*(r.deltaMode===1?.05:r.deltaMode?1:.002)*(r.ctrlKey?10:1)}function w2(){return navigator.maxTouchPoints||"ontouchstart"in this}function C2(r,e,t){var n=r.invertX(e[0][0])-t[0][0],s=r.invertX(e[1][0])-t[1][0],i=r.invertY(e[0][1])-t[0][1],o=r.invertY(e[1][1])-t[1][1];return r.translate(s>n?(n+s)/2:Math.min(0,n)||Math.max(0,s),o>i?(i+o)/2:Math.min(0,i)||Math.max(0,o))}function S2(){var r=b2,e=v2,t=C2,n=_2,s=w2,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],l=250,a=oy,u=la("start","zoom","end"),c,d,h,p=500,g=150,m=0,x=10;function _(w){w.property("__zoom",ru).on("wheel.zoom",T,{passive:!1}).on("mousedown.zoom",B).on("dblclick.zoom",j).filter(s).on("touchstart.zoom",N).on("touchmove.zoom",M).on("touchend.zoom touchcancel.zoom",R).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(w,D,F,I){var U=w.selection?w.selection():w;U.property("__zoom",ru),w!==U?k(w,D,F,I):U.interrupt().each(function(){E(this,arguments).event(I).start().zoom(null,typeof D=="function"?D.apply(this,arguments):D).end()})},_.scaleBy=function(w,D,F,I){_.scaleTo(w,function(){var U=this.__zoom.k,J=typeof D=="function"?D.apply(this,arguments):D;return U*J},F,I)},_.scaleTo=function(w,D,F,I){_.transform(w,function(){var U=e.apply(this,arguments),J=this.__zoom,te=F==null?S(U):typeof F=="function"?F.apply(this,arguments):F,W=J.invert(te),V=typeof D=="function"?D.apply(this,arguments):D;return t(C(b(J,V),te,W),U,o)},F,I)},_.translateBy=function(w,D,F,I){_.transform(w,function(){return t(this.__zoom.translate(typeof D=="function"?D.apply(this,arguments):D,typeof F=="function"?F.apply(this,arguments):F),e.apply(this,arguments),o)},null,I)},_.translateTo=function(w,D,F,I,U){_.transform(w,function(){var J=e.apply(this,arguments),te=this.__zoom,W=I==null?S(J):typeof I=="function"?I.apply(this,arguments):I;return t(ri.translate(W[0],W[1]).scale(te.k).translate(typeof D=="function"?-D.apply(this,arguments):-D,typeof F=="function"?-F.apply(this,arguments):-F),J,o)},I,U)};function b(w,D){return D=Math.max(i[0],Math.min(i[1],D)),D===w.k?w:new nr(D,w.x,w.y)}function C(w,D,F){var I=D[0]-F[0]*w.k,U=D[1]-F[1]*w.k;return I===w.x&&U===w.y?w:new nr(w.k,I,U)}function S(w){return[(+w[0][0]+ +w[1][0])/2,(+w[0][1]+ +w[1][1])/2]}function k(w,D,F,I){w.on("start.zoom",function(){E(this,arguments).event(I).start()}).on("interrupt.zoom end.zoom",function(){E(this,arguments).event(I).end()}).tween("zoom",function(){var U=this,J=arguments,te=E(U,J).event(I),W=e.apply(U,J),V=F==null?S(W):typeof F=="function"?F.apply(U,J):F,H=Math.max(W[1][0]-W[0][0],W[1][1]-W[0][1]),ne=U.__zoom,ce=typeof D=="function"?D.apply(U,J):D,le=a(ne.invert(V).concat(H/ne.k),ce.invert(V).concat(H/ce.k));return function(pe){if(pe===1)pe=ce;else{var be=le(pe),Te=H/be[2];pe=new nr(Te,V[0]-be[0]*Te,V[1]-be[1]*Te)}te.zoom(null,pe)}})}function E(w,D,F){return!F&&w.__zooming||new v(w,D)}function v(w,D){this.that=w,this.args=D,this.active=0,this.sourceEvent=null,this.extent=e.apply(w,D),this.taps=0}v.prototype={event:function(w){return w&&(this.sourceEvent=w),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(w,D){return this.mouse&&w!=="mouse"&&(this.mouse[1]=D.invert(this.mouse[0])),this.touch0&&w!=="touch"&&(this.touch0[1]=D.invert(this.touch0[0])),this.touch1&&w!=="touch"&&(this.touch1[1]=D.invert(this.touch1[0])),this.that.__zoom=D,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(w){var D=Pt(this.that).datum();u.call(w,this.that,new x2(w,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:u}),D)}};function T(w,...D){if(!r.apply(this,arguments))return;var F=E(this,D).event(w),I=this.__zoom,U=Math.max(i[0],Math.min(i[1],I.k*Math.pow(2,n.apply(this,arguments)))),J=wr(w);if(F.wheel)(F.mouse[0][0]!==J[0]||F.mouse[0][1]!==J[1])&&(F.mouse[1]=I.invert(F.mouse[0]=J)),clearTimeout(F.wheel);else{if(I.k===U)return;F.mouse=[J,I.invert(J)],Es(this),F.start()}xn(w),F.wheel=setTimeout(te,g),F.zoom("mouse",t(C(b(I,U),F.mouse[0],F.mouse[1]),F.extent,o));function te(){F.wheel=null,F.end()}}function B(w,...D){if(h||!r.apply(this,arguments))return;var F=w.currentTarget,I=E(this,D,!0).event(w),U=Pt(w.view).on("mousemove.zoom",V,!0).on("mouseup.zoom",H,!0),J=wr(w,F),te=w.clientX,W=w.clientY;Mm(w.view),Wi(w),I.mouse=[J,this.__zoom.invert(J)],Es(this),I.start();function V(ne){if(xn(ne),!I.moved){var ce=ne.clientX-te,le=ne.clientY-W;I.moved=ce*ce+le*le>m}I.event(ne).zoom("mouse",t(C(I.that.__zoom,I.mouse[0]=wr(ne,F),I.mouse[1]),I.extent,o))}function H(ne){U.on("mousemove.zoom mouseup.zoom",null),Rm(ne.view,I.moved),xn(ne),I.event(ne).end()}}function j(w,...D){if(r.apply(this,arguments)){var F=this.__zoom,I=wr(w.changedTouches?w.changedTouches[0]:w,this),U=F.invert(I),J=F.k*(w.shiftKey?.5:2),te=t(C(b(F,J),I,U),e.apply(this,D),o);xn(w),l>0?Pt(this).transition().duration(l).call(k,te,I,w):Pt(this).call(_.transform,te,I,w)}}function N(w,...D){if(r.apply(this,arguments)){var F=w.touches,I=F.length,U=E(this,D,w.changedTouches.length===I).event(w),J,te,W,V;for(Wi(w),te=0;te<I;++te)W=F[te],V=wr(W,this),V=[V,this.__zoom.invert(V),W.identifier],U.touch0?!U.touch1&&U.touch0[2]!==V[2]&&(U.touch1=V,U.taps=0):(U.touch0=V,J=!0,U.taps=1+!!c);c&&(c=clearTimeout(c)),J&&(U.taps<2&&(d=V[0],c=setTimeout(function(){c=null},p)),Es(this),U.start())}}function M(w,...D){if(this.__zooming){var F=E(this,D).event(w),I=w.changedTouches,U=I.length,J,te,W,V;for(xn(w),J=0;J<U;++J)te=I[J],W=wr(te,this),F.touch0&&F.touch0[2]===te.identifier?F.touch0[0]=W:F.touch1&&F.touch1[2]===te.identifier&&(F.touch1[0]=W);if(te=F.that.__zoom,F.touch1){var H=F.touch0[0],ne=F.touch0[1],ce=F.touch1[0],le=F.touch1[1],pe=(pe=ce[0]-H[0])*pe+(pe=ce[1]-H[1])*pe,be=(be=le[0]-ne[0])*be+(be=le[1]-ne[1])*be;te=b(te,Math.sqrt(pe/be)),W=[(H[0]+ce[0])/2,(H[1]+ce[1])/2],V=[(ne[0]+le[0])/2,(ne[1]+le[1])/2]}else if(F.touch0)W=F.touch0[0],V=F.touch0[1];else return;F.zoom("touch",t(C(te,W,V),F.extent,o))}}function R(w,...D){if(this.__zooming){var F=E(this,D).event(w),I=w.changedTouches,U=I.length,J,te;for(Wi(w),h&&clearTimeout(h),h=setTimeout(function(){h=null},p),J=0;J<U;++J)te=I[J],F.touch0&&F.touch0[2]===te.identifier?delete F.touch0:F.touch1&&F.touch1[2]===te.identifier&&delete F.touch1;if(F.touch1&&!F.touch0&&(F.touch0=F.touch1,delete F.touch1),F.touch0)F.touch0[1]=this.__zoom.invert(F.touch0[0]);else if(F.end(),F.taps===2&&(te=wr(te,this),Math.hypot(d[0]-te[0],d[1]-te[1])<x)){var W=Pt(this).on("dblclick.zoom");W&&W.apply(this,arguments)}}}return _.wheelDelta=function(w){return arguments.length?(n=typeof w=="function"?w:bs(+w),_):n},_.filter=function(w){return arguments.length?(r=typeof w=="function"?w:bs(!!w),_):r},_.touchable=function(w){return arguments.length?(s=typeof w=="function"?w:bs(!!w),_):s},_.extent=function(w){return arguments.length?(e=typeof w=="function"?w:bs([[+w[0][0],+w[0][1]],[+w[1][0],+w[1][1]]]),_):e},_.scaleExtent=function(w){return arguments.length?(i[0]=+w[0],i[1]=+w[1],_):[i[0],i[1]]},_.translateExtent=function(w){return arguments.length?(o[0][0]=+w[0][0],o[1][0]=+w[1][0],o[0][1]=+w[0][1],o[1][1]=+w[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(w){return arguments.length?(t=w,_):t},_.duration=function(w){return arguments.length?(l=+w,_):l},_.interpolate=function(w){return arguments.length?(a=w,_):a},_.on=function(){var w=u.on.apply(u,arguments);return w===u?_:w},_.clickDistance=function(w){return arguments.length?(m=(w=+w)*w,_):Math.sqrt(m)},_.tapDistance=function(w){return arguments.length?(x=+w,_):x},_}function kd(r={}){const{minZoom:e=.1,maxZoom:t=4,initialTransform:n,zoomable:s=!0,pannable:i=!0,onTransformChange:o}=r,l=y.useRef(null),a=y.useRef(),[u,c]=y.useState(n||{x:0,y:0,k:1});y.useEffect(()=>{if(!l.current)return;const x=S2().scaleExtent([e,t]).filter(b=>!s&&b.type==="wheel"||!i&&(b.type==="mousedown"||b.type==="touchstart")?!1:b.type==="wheel"?s:b.type==="mousedown"||b.type==="touchstart"?b.target.closest("[data-qmap-node]")?!1:i:!0).on("zoom",b=>{const C={x:b.transform.x,y:b.transform.y,k:b.transform.k};c(C),o==null||o(C)});a.current=x;const _=Pt(l.current);return _.call(x),_.on("dblclick.zoom",null),n&&_.call(x.transform,ri.translate(n.x,n.y).scale(n.k)),()=>{_.on(".zoom",null)}},[e,t,s,i]),y.useEffect(()=>{a.current&&a.current.on("zoom",x=>{const _={x:x.transform.x,y:x.transform.y,k:x.transform.k};c(_),o==null||o(_)})},[o]);const d=y.useCallback((x,_,b,C=!0)=>{if(!l.current||!a.current)return;const S=Pt(l.current),k=ri.translate(x,_).scale(b);S.call(a.current.transform,k)},[]),h=y.useCallback(()=>{!l.current||!a.current||Pt(l.current).call(a.current.scaleBy,1.3)},[]),p=y.useCallback(()=>{!l.current||!a.current||Pt(l.current).call(a.current.scaleBy,.7)},[]),g=y.useCallback(()=>{d(0,0,1,!0)},[d]),m=y.useCallback((x,_=50)=>{if(!l.current||!a.current||x.length===0)return;const b=l.current,C=b.clientWidth,S=b.clientHeight;let k=1/0,E=1/0,v=-1/0,T=-1/0;for(const U of x){const J=U.width||200,te=U.height||100;k=Math.min(k,U.x),E=Math.min(E,U.y),v=Math.max(v,U.x+J),T=Math.max(T,U.y+te)}const B=v-k,j=T-E,N=(C-_*2)/B,M=(S-_*2)/j,R=Math.min(N,M,t),w=(k+v)/2,D=(E+T)/2,F=C/2-w*R,I=S/2-D*R;d(F,I,R,!0)},[t,d]);return{transform:u,containerRef:l,zoomTo:d,zoomIn:h,zoomOut:p,resetZoom:g,fitToContent:m}}function Ed(r){const{transform:e,onDragStart:t,onDragMove:n,onDragEnd:s,disabled:i=!1}=r,[o,l]=y.useState(null),[a,u]=y.useState(!1),[c,d]=y.useState({x:0,y:0}),h=y.useRef(null),p=y.useRef({x:0,y:0}),g=y.useRef(e);y.useEffect(()=>{g.current=e},[e]);const m=y.useCallback((C,S)=>{const k=g.current;return{x:(C-k.x)/k.k,y:(S-k.y)/k.k}},[]),x=y.useCallback((C,S)=>{if(i)return;S.preventDefault(),S.stopPropagation();const k=S.currentTarget,E=parseFloat(k.dataset.x||"0"),v=parseFloat(k.dataset.y||"0");h.current={x:S.clientX,y:S.clientY,nodeX:E,nodeY:v},p.current={x:E,y:v},l(C),u(!0),d({x:0,y:0}),t==null||t(C)},[i,m,t]),_=y.useCallback(C=>{if(!a||!o||!h.current)return;const S=g.current,k=h.current,E=C.clientX-k.x,v=C.clientY-k.y,T=E/S.k,B=v/S.k,j=k.nodeX+T,N=k.nodeY+B;p.current={x:j,y:N},d({x:T,y:B}),n==null||n(o,j,N,T,B)},[a,o,n]),b=y.useCallback(()=>{if(!a||!o)return;const C=p.current;s==null||s(o,C.x,C.y),l(null),u(!1),d({x:0,y:0}),h.current=null},[a,o,s]);return y.useEffect(()=>{if(!a)return;const C=k=>{_(k)},S=()=>{b()};return window.addEventListener("mousemove",C),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",C),window.removeEventListener("mouseup",S)}},[a,_,b]),{draggedNodeId:o,isDragging:a,dragOffset:c,startDrag:x,updateDrag:_,endDrag:b}}function Dd(r){const{transform:e,nodePositions:t,disabled:n=!1,controlledSelectedIds:s,onSelectionChange:i}=r,[o,l]=y.useState(new Set),a=s!==void 0,u=a?new Set(s):o,c=a?j=>{const N=typeof j=="function"?j(u):j;i==null||i(Array.from(N))}:l,[d,h]=y.useState(null),[p,g]=y.useState(!1),m=y.useRef(null),x=y.useRef(e),_=y.useRef(t);y.useEffect(()=>{x.current=e},[e]),y.useEffect(()=>{_.current=t},[t]);const b=y.useCallback((j,N)=>{const M=x.current;return{x:(j-M.x)/M.k,y:(N-M.y)/M.k}},[]),C=y.useCallback((j,N)=>{const M=_.current.get(j);if(!M)return!1;const R=M.width||200,w=M.height||100;return M.x<N.x+N.width&&M.x+R>N.x&&M.y<N.y+N.height&&M.y+w>N.y},[]),S=y.useCallback(j=>{if(n||j.target.closest("[data-qmap-node]"))return;j.preventDefault();const M=b(j.clientX,j.clientY);m.current=M,h({x:M.x,y:M.y,width:0,height:0}),g(!0),j.shiftKey||c(new Set)},[n,b]),k=y.useCallback(j=>{if(!p||!m.current)return;const N=m.current,M=b(j.clientX,j.clientY),R={x:Math.min(N.x,M.x),y:Math.min(N.y,M.y),width:Math.abs(M.x-N.x),height:Math.abs(M.y-N.y)};h(R);const w=new Set;for(const[D]of _.current)C(D,R)&&w.add(D);c(w)},[p,b,C]),E=y.useCallback(()=>{p&&(i==null||i(Array.from(u)),g(!1),h(null),m.current=null)},[p,u,i]);y.useEffect(()=>{if(!p)return;const j=M=>{k(M)},N=()=>{E()};return window.addEventListener("mousemove",j),window.addEventListener("mouseup",N),()=>{window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",N)}},[p,k,E]);const v=y.useCallback((j,N=!1)=>{c(M=>{const R=new Set(N?M:[]);return M.has(j)&&N?R.delete(j):R.add(j),i==null||i(Array.from(R)),R})},[i]),T=y.useCallback(()=>{const j=new Set(_.current.keys());c(j),i==null||i(Array.from(j))},[i]),B=y.useCallback(()=>{c(new Set),i==null||i([])},[i]);return{selectedIds:u,setSelectedIds:c,selectionBox:d,isSelecting:p,startSelection:S,updateSelection:k,endSelection:E,toggleSelect:v,selectAll:T,clearSelection:B}}const Ad=y.memo(function({nodeId:e,position:t,isSelected:n,isDragging:s,draggable:i,onDragStart:o,onClick:l,onDoubleClick:a,onContextMenu:u,nodeRef:c,children:d}){const h=y.useCallback(_=>{i&&_.button===0&&o(e,_)},[e,i,o]),p=y.useCallback(_=>{s||l==null||l(_)},[s,l]),g=y.useCallback(_=>{_.stopPropagation(),a==null||a(_)},[a]),m=y.useCallback(_=>{_.preventDefault(),_.stopPropagation(),u==null||u(_)},[u]),x=t.rotation||0;return f.jsx("div",{ref:c,"data-qmap-node":e,"data-x":t.x,"data-y":t.y,style:{position:"absolute",left:t.x,top:t.y,transform:x!==0?`rotate(${x}deg)`:void 0,transformOrigin:"center center",cursor:i?s?"grabbing":"grab":"pointer",userSelect:"none",opacity:s?.8:1,zIndex:s?1e3:n?100:1,WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},onMouseDown:h,onClick:p,onDoubleClick:g,onContextMenu:m,children:d})},(r,e)=>r.nodeId===e.nodeId&&r.position.x===e.position.x&&r.position.y===e.position.y&&r.position.rotation===e.position.rotation&&r.isSelected===e.isSelected&&r.isDragging===e.isDragging&&r.draggable===e.draggable&&r.children===e.children);function Td(r,e,t="bezier"){const n={x:r.x+(r.width||200)/2,y:r.y+(r.height||100)/2},s={x:e.x+(e.width||200)/2,y:e.y+(e.height||100)/2};switch(t){case"straight":return`M ${n.x} ${n.y} L ${s.x} ${s.y}`;case"orthogonal":return E2(n,s);case"bezier":default:return k2(n,s)}}function k2(r,e){const t=e.x-r.x,n=e.y-r.y,s=Math.sqrt(t*t+n*n),i=Math.min(s*.4,150),o=Math.abs(t)>Math.abs(n);let l,a,u,c;return o?(l=r.x+i*Math.sign(t),a=r.y,u=e.x-i*Math.sign(t),c=e.y):(l=r.x,a=r.y+i*Math.sign(n),u=e.x,c=e.y-i*Math.sign(n)),`M ${r.x} ${r.y} C ${l} ${a}, ${u} ${c}, ${e.x} ${e.y}`}function E2(r,e){const t=e.x-r.x,n=e.y-r.y;if(Math.abs(t)>Math.abs(n)){const i=r.x+t/2;return`M ${r.x} ${r.y} H ${i} V ${e.y} H ${e.x}`}else{const i=r.y+n/2;return`M ${r.x} ${r.y} V ${i} H ${e.x} V ${e.y}`}}function ga(r){const e=r.width||200,t=r.height||100;return{x:r.x+e/2,y:r.y+t/2}}function D2(r,e){const t=r.width||200,n=r.height||100,s=ga(r),i=e.x-s.x,o=e.y-s.y;if(i===0&&o===0)return s;const l=t/2,a=n/2,u=Math.abs(o/(i||.001)),c=a/l;let d,h;return u<c?(d=s.x+(i>0?l:-l),h=s.y+o*l/Math.abs(i)):(h=s.y+(o>0?a:-a),d=s.x+i*a/Math.abs(o)),{x:d,y:h}}function A2(r,e){const t=r.width||200,n=r.height||100;switch(e){case"left":return{x:r.x,y:r.y+n/2};case"right":return{x:r.x+t,y:r.y+n/2};case"top":return{x:r.x+t/2,y:r.y};case"bottom":return{x:r.x+t/2,y:r.y+n};case"center":default:return ga(r)}}function T2(r,e){return r.x>=e.x&&r.x<=e.x+e.width&&r.y>=e.y&&r.y<=e.y+e.height}function N2(r,e){return r.x<e.x+e.width&&r.x+r.width>e.x&&r.y<e.y+e.height&&r.y+r.height>e.y}function B2(r){if(r.length===0)return null;let e=1/0,t=1/0,n=-1/0,s=-1/0;for(const i of r){const o=i.width||200,l=i.height||100;e=Math.min(e,i.x),t=Math.min(t,i.y),n=Math.max(n,i.x+o),s=Math.max(s,i.y+l)}return{x:e,y:t,width:n-e,height:s-t}}function j2(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.sqrt(t*t+n*n)}function M2(r,e){const t=e.x-r.x,n=e.y-r.y;return t*t+n*n}const Nd=y.memo(function({edge:e,sourcePosition:t,targetPosition:n,style:s,color:i,width:o,onClick:l}){const[a,u]=y.useState(!1),c=y.useMemo(()=>Td(t,n,s),[t,n,s]),d=y.useCallback(x=>{x.stopPropagation(),l==null||l(e,x)},[e,l]),h=y.useCallback(()=>{u(!0)},[]),p=y.useCallback(()=>{u(!1)},[]),g=e.color||i,m=e.width||o;return f.jsxs("g",{children:[f.jsx("path",{d:c,fill:"none",stroke:"transparent",strokeWidth:Math.max(m*3,10),style:{cursor:l?"pointer":"default",pointerEvents:"stroke"},onClick:d,onMouseEnter:h,onMouseLeave:p}),f.jsx("path",{d:c,fill:"none",stroke:g,strokeWidth:a?m*1.5:m,strokeLinecap:"round",strokeLinejoin:"round",style:{pointerEvents:"none",transition:"stroke-width 0.15s ease"}}),e.label&&f.jsx(R2,{pathD:c,label:e.label,color:g})]})},(r,e)=>r.edge.id===e.edge.id&&r.sourcePosition.x===e.sourcePosition.x&&r.sourcePosition.y===e.sourcePosition.y&&r.sourcePosition.width===e.sourcePosition.width&&r.sourcePosition.height===e.sourcePosition.height&&r.targetPosition.x===e.targetPosition.x&&r.targetPosition.y===e.targetPosition.y&&r.targetPosition.width===e.targetPosition.width&&r.targetPosition.height===e.targetPosition.height&&r.style===e.style&&r.color===e.color&&r.width===e.width&&r.edge.label===e.edge.label&&r.edge.color===e.edge.color&&r.edge.width===e.edge.width);function R2({pathD:r,label:e,color:t}){const n=y.useMemo(()=>`edge-label-${Math.random().toString(36).substr(2,9)}`,[]);return f.jsxs(f.Fragment,{children:[f.jsx("defs",{children:f.jsx("path",{id:n,d:r})}),f.jsx("text",{fill:t,fontSize:"12",fontFamily:"system-ui, sans-serif",style:{pointerEvents:"none"},children:f.jsx("textPath",{href:`#${n}`,startOffset:"50%",textAnchor:"middle",children:e})})]})}const Bd=y.memo(function({edges:e,nodePositions:t,defaultStyle:n,defaultColor:s,defaultWidth:i,onEdgeClick:o}){const l=y.useMemo(()=>e.filter(a=>t.has(a.source)&&t.has(a.target)),[e,t]);return f.jsx("svg",{style:{position:"absolute",top:0,left:0,width:1,height:1,overflow:"visible",pointerEvents:"none"},children:f.jsx("g",{style:{pointerEvents:"auto"},children:l.map(a=>{const u=t.get(a.source),c=t.get(a.target);return f.jsx(Nd,{edge:a,sourcePosition:u,targetPosition:c,style:a.style||n,color:a.color||s,width:a.width||i,onClick:o},a.id)})})})},(r,e)=>!(r.edges!==e.edges||r.nodePositions!==e.nodePositions||r.defaultStyle!==e.defaultStyle||r.defaultColor!==e.defaultColor||r.defaultWidth!==e.defaultWidth)),jd=y.memo(function({box:e,transform:t}){const n=y.useMemo(()=>({x:e.x*t.k+t.x,y:e.y*t.k+t.y,width:e.width*t.k,height:e.height*t.k}),[e,t]);return f.jsx("div",{style:{position:"absolute",left:n.x,top:n.y,width:n.width,height:n.height,backgroundColor:"rgba(59, 130, 246, 0.1)",border:"1px solid rgba(59, 130, 246, 0.5)",borderRadius:2,pointerEvents:"none",zIndex:9999}})}),F2=200,L2=100,P2="bezier",I2="#94a3b8",z2=2,O2=.1,$2=4;function q2({viewNode:r,nodes:e,edges:t,renderNode:n,defaultNodeWidth:s=F2,defaultNodeHeight:i=L2,onNodeMove:o,onNodeDrag:l,onNodeClick:a,onNodeDoubleClick:u,onNodeContextMenu:c,selectedIds:d,onSelectionChange:h,onEdgeClick:p,onViewChange:g,onTransformChange:m,minZoom:x=O2,maxZoom:_=$2,initialTransform:b,defaultEdgeStyle:C=P2,defaultEdgeColor:S=I2,defaultEdgeWidth:k=z2,draggable:E=!0,selectable:v=!0,zoomable:T=!0,pannable:B=!0,className:j="",style:N,background:M="#f8fafc",showGrid:R=!1,gridSize:w=20}){const D=r.data||{positions:{}},F=D.positions||{},I=y.useMemo(()=>{const G=new Map;for(const ee of e){const me=F[ee._id]||{x:0,y:0};G.set(ee._id,{x:me.x,y:me.y,width:me.width||s,height:me.height||i,rotation:me.rotation||0})}return G},[e,F,s,i]),{transform:U,containerRef:J,zoomIn:te,zoomOut:W,resetZoom:V,fitToContent:H}=kd({minZoom:x,maxZoom:_,initialTransform:b||D.transform,zoomable:T,pannable:B,onTransformChange:G=>{m==null||m(G);const ee={...D,transform:G};g==null||g(ee)}}),[ne,ce]=y.useState(new Map),[le,pe]=y.useState(new Map),be=y.useRef(new Map);y.useEffect(()=>{const G=U.k||1,ee=new Map;be.current.forEach((_e,Be)=>{if(_e){const Xe=_e.getBoundingClientRect();ee.set(Be,{width:Math.round(Xe.width/G),height:Math.round(Xe.height/G)})}}),e.some(_e=>{const Be=ee.get(_e._id),Xe=le.get(_e._id);return Be?Xe?Be.width!==Xe.width||Be.height!==Xe.height:!0:!1})&&pe(ee)},[e,le,U.k]);const{draggedNodeId:Te,startDrag:$}=Ed({transform:U,disabled:!E,onDragStart:G=>{const ee=I.get(G);ee&&ce(new Map([[G,{x:ee.x,y:ee.y}]]))},onDragMove:(G,ee,me)=>{ce(new Map([[G,{x:ee,y:me}]])),l==null||l(G,ee,me)},onDragEnd:(G,ee,me)=>{ce(new Map),o==null||o(G,ee,me)}}),{selectedIds:ke,selectionBox:se,isSelecting:Re,startSelection:Ce,toggleSelect:Ee,clearSelection:Se}=Dd({transform:U,nodePositions:I,disabled:!v,controlledSelectedIds:d,onSelectionChange:h}),Fe=y.useCallback(G=>{const ee=I.get(G)||{x:0,y:0,width:s,height:i},me=ne.get(G),_e=le.get(G),Be=(_e==null?void 0:_e.width)||ee.width||s,Xe=(_e==null?void 0:_e.height)||ee.height||i;return me?{...ee,x:me.x,y:me.y,width:Be,height:Xe}:{...ee,width:Be,height:Xe}},[I,ne,le,s,i]),ze=y.useMemo(()=>{const G=new Map;for(const ee of I.keys())G.set(ee,Fe(ee));return G},[I,Fe]),ge=y.useCallback((G,ee)=>{Ee(G._id,ee.shiftKey),a==null||a(G,ee)},[Ee,a]),L=y.useCallback(G=>{G.target.closest("[data-qmap-node]")||Se()},[Se]),Me=y.useCallback(G=>{G.button===0&&(G.target.closest("[data-qmap-node]")||Ce(G))},[Ce]),Qe=R?`
185
+ ${L}`:L)},je=async L=>{if(!(!(typeof e=="string"?e:"").trim()||B||!s)){j(!0),R(!1);try{const ze=await s(L,e);t(ze)}catch(ze){console.error(`${L} failed:`,ze)}finally{j(!1)}}},ye=()=>{setTimeout(()=>{var L;(L=De.current)!=null&&L.contains(document.activeElement)||R(!1)},150)},Se=async()=>{if(!(!D.trim()||B||!i)){j(!0);try{const L=await i(D,e);t(L),F("")}catch(L){console.error("AI prompt failed:",L)}finally{j(!1)}}},Me=async()=>{if(!(typeof e=="string"?e:"").trim()||z)return;if(!(Ce||_)){console.warn("TTS: No generation mode available",{integratedTTS:Ce,hasCallback:!!_,llmClient:!!c,graphClient:!!d,nodeId:h,audioFilename:p}),alert("TTS non disponible. Sauvegardez d'abord le cours.");return}O.current&&(O.current.pause(),O.current.currentTime=0),q(!0);try{if(Ce&&c&&d&&h&&p){console.log("TTS: Generating audio...",{voice:H,textLength:e.length});const ze=await c.tts(e,{voice:H});console.log("TTS: Audio generated, uploading...",{audioLength:ze==null?void 0:ze.length});const Ke=atob(ze),X=new Uint8Array(Ke.length);for(let we=0;we<Ke.length;we++)X[we]=Ke.charCodeAt(we);const Z=new Blob([X],{type:"audio/mpeg"}),ce=new File([Z],p,{type:"audio/mpeg"});await d.uploadFile(h,p,ce),console.log("TTS: Upload complete",{nodeId:h,audioFilename:p}),fe(Date.now()),ue(p),x==null||x(p,H)}else _&&(await _(e,H),fe(Date.now()))}catch(ze){console.error("TTS generation failed:",ze),alert("Erreur TTS: "+(ze instanceof Error?ze.message:"Erreur inconnue"))}finally{q(!1)}},Oe=async()=>{if(!(!c||!E||J)){if(!(v!=null&&v.trim())){G(T||"Le texte source est requis pour la génération.");return}te(!0),G(null);try{const L=await c.chat([{role:"system",content:E},{role:"user",content:v}]);t(L)}catch(L){G(L instanceof Error?L.message:"Erreur de génération")}finally{te(!1)}}},ge=L=>{se(L),C==null||C(L)};return f.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${l}`,children:[f.jsx(Zc,{onComplete:o||(()=>{}),onTranscribe:n,onTranscriptionComplete:Fe,hideSaveButton:!o,variant:"div",extraControls:f.jsxs(f.Fragment,{children:[i&&f.jsx("button",{type:"button",onClick:Se,disabled:B||!D.trim(),style:{padding:"4px",borderRadius:"4px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",opacity:B||!D.trim()?.3:1},title:"Envoyer le prompt AI",children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:B?"#9333ea":"#171717"},children:B?"hourglass_empty":"smart_toy"})}),i&&f.jsx("button",{type:"button",onClick:()=>w(!M),style:{padding:"4px",borderRadius:"4px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},title:M?"Masquer le prompt":"Afficher le prompt AI",children:f.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#171717",transform:M?"rotate(90deg)":"rotate(0deg)",transition:"transform 0.15s"},children:"chevron_right"})}),s&&f.jsxs("div",{className:"relative",ref:De,style:{display:"inline-flex"},children:[f.jsx("button",{type:"button",onClick:()=>R(!N),disabled:B||!(typeof e=="string"?e:"").trim(),style:{padding:"4px 6px",borderRadius:"4px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",gap:"2px",fontSize:"11px",color:"#9333ea",opacity:B||!(typeof e=="string"?e:"").trim()?.4:1},children:f.jsx("span",{className:"material-icons",style:{fontSize:"16px"},children:"auto_fix_high"})}),N&&!B&&f.jsxs("div",{className:"absolute right-0 top-full mt-1 bg-white border border-neutral-200 rounded-lg shadow-lg z-50 min-w-[180px] py-1",onBlur:ye,children:[f.jsxs("button",{type:"button",onClick:()=>je("restructure"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[f.jsx("span",{className:"material-icons text-base text-blue-500",children:"format_list_bulleted"}),f.jsxs("div",{children:[f.jsx("div",{className:"font-medium",children:"Restructure"}),f.jsx("div",{className:"text-xs text-neutral-500",children:"Organize & clarify"})]})]}),f.jsxs("button",{type:"button",onClick:()=>je("proofread"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[f.jsx("span",{className:"material-icons text-base text-green-500",children:"spellcheck"}),f.jsxs("div",{children:[f.jsx("div",{className:"font-medium",children:"Proofread"}),f.jsx("div",{className:"text-xs text-neutral-500",children:"Fix grammar & spelling"})]})]}),f.jsxs("button",{type:"button",onClick:()=>je("rewrite"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[f.jsx("span",{className:"material-icons text-base text-purple-500",children:"brush"}),f.jsxs("div",{children:[f.jsx("div",{className:"font-medium",children:"Rewrite"}),f.jsx("div",{className:"text-xs text-neutral-500",children:"Your voice & style"})]})]})]})]})]})}),i&&M&&f.jsx("div",{className:"flex items-start gap-2 bg-neutral-50 border-b border-neutral-200 px-2",children:f.jsx("textarea",{value:D,onChange:L=>F(L.target.value),onKeyDown:L=>{L.stopPropagation(),L.key==="Enter"&&L.ctrlKey&&(L.preventDefault(),Se())},placeholder:"Instructions AI... (Ctrl+Enter)",disabled:B,rows:3,className:"flex-1 py-2 text-sm border-0 resize-y min-h-[60px] focus:ring-0 focus:outline-none bg-transparent disabled:opacity-50",autoFocus:!0})}),(r||(typeof e=="string"?e:"").trim()||Ce||_||k)&&f.jsxs("div",{className:"flex items-center justify-between px-2 py-1",children:[f.jsxs("div",{className:"flex items-center gap-2",children:[r&&f.jsx("label",{className:"text-sm font-medium text-neutral-700",children:r}),k&&c&&E&&f.jsxs("button",{type:"button",onClick:Oe,disabled:J,className:"flex items-center gap-1 px-2 py-1 text-xs bg-purple-100 text-purple-700 hover:bg-purple-200 rounded transition-colors disabled:opacity-50",title:k.label,children:[f.jsx("span",{className:"material-icons",style:{fontSize:"14px"},children:J?"hourglass_empty":k.icon||"auto_awesome"}),k.label]})]}),f.jsxs("div",{className:"flex items-center gap-1",children:[(typeof e=="string"?e:"").trim()&&f.jsx("button",{type:"button",onClick:()=>navigator.clipboard.writeText(e),className:"p-1 rounded hover:bg-neutral-100 transition-colors",title:"Copy to clipboard",children:f.jsx("span",{className:"material-icons text-neutral-500",style:{fontSize:"16px"},children:"content_copy"})}),(Ce||_)&&f.jsxs("div",{className:"flex items-center gap-1",children:[f.jsx("select",{value:H,onChange:L=>ge(L.target.value),disabled:z,className:"px-1.5 py-0.5 text-xs border border-neutral-200 rounded bg-white focus:outline-none focus:ring-1 focus:ring-blue-500 disabled:opacity-50",title:"Choisir la voix",children:ou.map(L=>f.jsxs("option",{value:L.id,children:[L.name," - ",L.description]},L.id))}),f.jsx("button",{type:"button",onClick:Me,disabled:z||!(typeof e=="string"?e:"").trim(),className:"p-1 rounded hover:bg-blue-50 transition-colors disabled:opacity-40",title:z?"Génération en cours...":"Générer audio TTS",children:f.jsx("span",{className:`material-icons ${z?"animate-pulse text-blue-600":re?"text-green-600":"text-neutral-400"}`,style:{fontSize:"16px"},children:z?"hourglass_empty":"record_voice_over"})}),re&&f.jsxs(f.Fragment,{children:[f.jsx("audio",{ref:O,src:re,controls:!0,className:"h-6 w-32"},_e),f.jsx("button",{type:"button",onClick:()=>{O.current&&O.current.pause(),ue(void 0),x==null||x("",H)},className:"p-1 rounded hover:bg-red-50 transition-colors",title:"Supprimer l'audio",children:f.jsx("span",{className:"material-icons text-red-400 hover:text-red-600",style:{fontSize:"14px"},children:"delete"})})]})]})]})]}),f.jsx("textarea",{value:e,onChange:L=>t(L.target.value),onKeyDown:L=>L.stopPropagation(),placeholder:a,rows:u,disabled:B||J,className:"flex-1 w-full px-3 py-2 border-0 focus:ring-0 focus:outline-none text-sm disabled:opacity-50 disabled:bg-neutral-50 resize-none"}),W&&f.jsx("div",{className:"fixed inset-0 bg-black/50 flex items-center justify-center z-50",children:f.jsxs("div",{className:"bg-white rounded-lg shadow-xl p-6 max-w-md mx-4",children:[f.jsxs("div",{className:"flex items-start gap-3",children:[f.jsx("span",{className:"material-icons text-amber-500",style:{fontSize:"24px"},children:"warning"}),f.jsxs("div",{className:"flex-1",children:[f.jsx("h3",{className:"font-medium text-neutral-900 mb-2",children:"Génération impossible"}),f.jsx("p",{className:"text-sm text-neutral-600",children:W})]})]}),f.jsx("div",{className:"mt-4 flex justify-end",children:f.jsx("button",{type:"button",onClick:()=>G(null),className:"px-4 py-2 bg-neutral-100 hover:bg-neutral-200 text-neutral-700 rounded transition-colors text-sm",children:"Compris"})})]})})]})}const gs={"4/3":4/3,"16/9":16/9,"1/1":1,"3/4":3/4,"9/16":9/16,free:null};function Qg({src:r,onSave:e,onCancel:t,aspectRatio:n="4/3",outputFormat:s="image/jpeg",outputQuality:i=.9,theme:o="dark"}){const a=y.useRef(null),l=y.useRef(null),u=y.useRef(null),[c,d]=y.useState(!0),[h,p]=y.useState(null),[g,m]=y.useState(n),[x,_]=y.useState(0),[b,S]=y.useState({x:0,y:0,width:100,height:100}),[C,k]=y.useState(!1),[E,v]=y.useState(null),[T,B]=y.useState({x:0,y:0}),[j,N]=y.useState({x:0,y:0,width:100,height:100}),R=o==="dark",M=y.useCallback(()=>{const O=u.current;return O?x===90||x===270?{width:O.height,height:O.width}:{width:O.width,height:O.height}:{width:100,height:100}},[x]),w=y.useCallback((O,Ce)=>{const re=O/Ce,Fe=.05;for(const[je,ye]of Object.entries(gs))if(ye!==null&&Math.abs(re-ye)/ye<Fe)return je;return"free"},[]);y.useEffect(()=>{const O=new Image;O.crossOrigin="anonymous",O.onload=()=>{u.current=O;const Ce=w(O.width,O.height);m(Ce),d(!1)},O.onerror=()=>{p("Failed to load image"),d(!1)},O.src=r},[r,w]);const D=y.useCallback(()=>{const{width:O,height:Ce}=M(),re=gs[g];if(re===null){S({x:0,y:0,width:100,height:100});return}const Fe=O/Ce;let je,ye;Fe>re?(ye=100,je=re/Fe*100):(je=100,ye=Fe/re*100);const Se=(100-je)/2,Me=(100-ye)/2;S({x:Se,y:Me,width:je,height:ye})},[g,M]);y.useEffect(()=>{u.current&&D()},[g,x,D]),y.useEffect(()=>{const O=l.current,Ce=u.current;if(!O||!Ce||c)return;const re=O.getContext("2d");if(!re)return;const Fe=a.current;if(!Fe)return;const je=Fe.clientWidth,ye=Fe.clientHeight-140,{width:Se,height:Me}=M(),Oe=Se/Me;let ge,L;je/ye>Oe?(L=Math.min(ye,Me),ge=L*Oe):(ge=Math.min(je,Se),L=ge/Oe),ge>je&&(ge=je,L=ge/Oe),L>ye&&(L=ye,ge=L*Oe),O.width=ge,O.height=L,re.clearRect(0,0,ge,L),re.save(),re.translate(ge/2,L/2),re.rotate(x*Math.PI/180);let ze,Ke;x===90||x===270?(ze=L,Ke=ge):(ze=ge,Ke=L),re.drawImage(Ce,-ze/2,-Ke/2,ze,Ke),re.restore(),re.fillStyle="rgba(0, 0, 0, 0.6)";const X=b.x/100*ge,Z=b.y/100*L,ce=b.width/100*ge,we=b.height/100*L;re.fillRect(0,0,ge,Z),re.fillRect(0,Z+we,ge,L-Z-we),re.fillRect(0,Z,X,we),re.fillRect(X+ce,Z,ge-X-ce,we),re.strokeStyle="#fff",re.lineWidth=2,re.strokeRect(X,Z,ce,we),re.strokeStyle="rgba(255, 255, 255, 0.3)",re.lineWidth=1,re.beginPath(),re.moveTo(X+ce/3,Z),re.lineTo(X+ce/3,Z+we),re.moveTo(X+ce*2/3,Z),re.lineTo(X+ce*2/3,Z+we),re.moveTo(X,Z+we/3),re.lineTo(X+ce,Z+we/3),re.moveTo(X,Z+we*2/3),re.lineTo(X+ce,Z+we*2/3),re.stroke();const Be=14;re.fillStyle="#fff",re.strokeStyle="#333",re.lineWidth=1,[{x:X,y:Z},{x:X+ce,y:Z},{x:X,y:Z+we},{x:X+ce,y:Z+we}].forEach(Et=>{re.fillRect(Et.x-Be/2,Et.y-Be/2,Be,Be),re.strokeRect(Et.x-Be/2,Et.y-Be/2,Be,Be)})},[b,x,c,M]);const F=O=>{const Ce=l.current;if(!Ce)return;const re=Ce.getBoundingClientRect(),Fe=(O.clientX-re.left)/re.width*100,je=(O.clientY-re.top)/re.height*100,ye=4,Se=[{name:"nw",x:b.x,y:b.y},{name:"ne",x:b.x+b.width,y:b.y},{name:"sw",x:b.x,y:b.y+b.height},{name:"se",x:b.x+b.width,y:b.y+b.height}];for(const Me of Se)if(Math.abs(Fe-Me.x)<ye&&Math.abs(je-Me.y)<ye){v(Me.name),B({x:Fe,y:je}),N({...b});return}Fe>=b.x&&Fe<=b.x+b.width&&je>=b.y&&je<=b.y+b.height&&(k(!0),B({x:Fe,y:je}),N({...b}))},z=O=>{const Ce=l.current;if(!Ce)return;const re=Ce.getBoundingClientRect(),Fe=(O.clientX-re.left)/re.width*100,je=(O.clientY-re.top)/re.height*100;if(C){const ye=Fe-T.x,Se=je-T.y;let Me=j.x+ye,Oe=j.y+Se;Me=Math.max(0,Math.min(Me,100-j.width)),Oe=Math.max(0,Math.min(Oe,100-j.height)),S({...j,x:Me,y:Oe})}else if(E){const ye=gs[g],{width:Se,height:Me}=M(),Oe=Se/Me,ge=ye?ye/Oe:null;let L={...j};const ze=Fe-T.x,Ke=je-T.y;if(E==="se")L.width=Math.max(10,Math.min(100-L.x,j.width+ze)),ge?(L.height=L.width/ge,L.y+L.height>100&&(L.height=100-L.y,L.width=L.height*ge)):L.height=Math.max(10,Math.min(100-L.y,j.height+Ke));else if(E==="sw"){const X=-ze,Z=Math.max(10,j.width+X),ce=j.x+j.width-Z;ce>=0&&(L.width=Z,L.x=ce,ge?(L.height=L.width/ge,L.y+L.height>100&&(L.height=100-L.y,L.width=L.height*ge,L.x=j.x+j.width-L.width)):L.height=Math.max(10,Math.min(100-L.y,j.height+Ke)))}else if(E==="ne")if(L.width=Math.max(10,Math.min(100-L.x,j.width+ze)),ge){const X=L.width/ge,Z=j.y+j.height-X;Z>=0?(L.height=X,L.y=Z):(L.y=0,L.height=j.y+j.height,L.width=L.height*ge)}else{const X=-Ke,Z=Math.max(10,j.height+X),ce=j.y+j.height-Z;ce>=0&&(L.height=Z,L.y=ce)}else if(E==="nw"){const X=-ze,Z=Math.max(10,j.width+X),ce=j.x+j.width-Z;if(ce>=0)if(L.width=Z,L.x=ce,ge){const we=L.width/ge,Be=j.y+j.height-we;Be>=0?(L.height=we,L.y=Be):(L.y=0,L.height=j.y+j.height,L.width=L.height*ge,L.x=j.x+j.width-L.width)}else{const we=-Ke,Be=Math.max(10,j.height+we),Qe=j.y+j.height-Be;Qe>=0&&(L.height=Be,L.y=Qe)}}L.x=Math.max(0,L.x),L.y=Math.max(0,L.y),L.width=Math.min(L.width,100-L.x),L.height=Math.min(L.height,100-L.y),S(L)}},q=()=>{k(!1),v(null)},J=O=>{_(Ce=>O==="right"?(Ce+90)%360:(Ce-90+360)%360)},te=()=>{const O=u.current;if(!O)return;const{width:Ce,height:re}=M(),Fe=b.x/100*Ce,je=b.y/100*re,ye=b.width/100*Ce,Se=b.height/100*re,Me=document.createElement("canvas"),Oe=Me.getContext("2d");if(!Oe)return;Me.width=ye,Me.height=Se;const ge=document.createElement("canvas"),L=ge.getContext("2d");L&&(ge.width=Ce,ge.height=re,L.save(),L.translate(Ce/2,re/2),L.rotate(x*Math.PI/180),L.drawImage(O,-O.width/2,-O.height/2,O.width,O.height),L.restore(),Oe.drawImage(ge,Fe,je,ye,Se,0,0,ye,Se),Me.toBlob(ze=>{ze&&e(ze)},s,i))},W={display:"flex",flexDirection:"column",width:"100%",height:"100%",background:R?"#1a1a1a":"#f5f5f5",overflow:"hidden"},G={flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",minHeight:0,overflow:"hidden"},H={display:"flex",flexDirection:"column",gap:"12px",padding:"16px",borderTop:`1px solid ${R?"#333":"#ddd"}`,background:R?"#242424":"#fff",flexShrink:0},se={display:"flex",alignItems:"center",justifyContent:"space-between",gap:"8px"},le={padding:"10px 20px",borderRadius:"8px",border:"none",cursor:"pointer",fontSize:"14px",fontWeight:500,transition:"background 0.15s, opacity 0.15s"},ue={...le,background:"#E67E22",color:"#fff"},_e={...le,background:R?"#333":"#e5e5e5",color:R?"#fff":"#333"},fe={padding:"10px",borderRadius:"8px",border:"none",background:R?"#333":"#e5e5e5",color:R?"#fff":"#333",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},De=O=>({padding:"8px 14px",borderRadius:"6px",border:O?"2px solid #E67E22":"2px solid transparent",background:O?"#E67E22":R?"#333":"#e5e5e5",color:O?"#fff":R?"#ccc":"#666",cursor:"pointer",fontSize:"13px",fontWeight:600,transition:"all 0.15s"});return c?f.jsx("div",{style:{...W,alignItems:"center",justifyContent:"center"},children:f.jsx("div",{style:{color:R?"#aaa":"#666"},children:"Loading image..."})}):h?f.jsxs("div",{style:{...W,alignItems:"center",justifyContent:"center"},children:[f.jsx("div",{style:{color:"#ef4444"},children:h}),t&&f.jsx("button",{onClick:t,style:{..._e,marginTop:"16px"},children:"Close"})]}):f.jsxs("div",{ref:a,style:W,children:[f.jsx("div",{style:G,children:f.jsx("canvas",{ref:l,style:{cursor:C?"grabbing":E?"nwse-resize":"grab",maxWidth:"100%",maxHeight:"100%"},onMouseDown:F,onMouseMove:z,onMouseUp:q,onMouseLeave:q})}),f.jsxs("div",{style:H,children:[f.jsx("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap",justifyContent:"center"},children:Object.keys(gs).map(O=>f.jsx("button",{onClick:()=>m(O),style:De(g===O),children:O==="free"?"Libre":O},O))}),f.jsxs("div",{style:se,children:[f.jsxs("div",{style:{display:"flex",gap:"8px"},children:[f.jsx("button",{onClick:()=>J("left"),style:fe,title:"Rotate left",children:f.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:f.jsx("path",{d:"M2.5 2v6h6M2.66 15.57a10 10 0 1 0 .57-8.38"})})}),f.jsx("button",{onClick:()=>J("right"),style:fe,title:"Rotate right",children:f.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:f.jsx("path",{d:"M21.5 2v6h-6M21.34 15.57a10 10 0 1 1-.57-8.38"})})})]}),f.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t&&f.jsx("button",{onClick:t,style:_e,children:"Annuler"}),f.jsx("button",{onClick:te,style:ue,children:"Enregistrer"})]})]})]})]})}var Jg={value:()=>{}};function la(){for(var r=0,e=arguments.length,t={},n;r<e;++r){if(!(n=arguments[r]+"")||n in t||/[\s.]/.test(n))throw new Error("illegal type: "+n);t[n]=[]}return new Cs(t)}function Cs(r){this._=r}function Xg(r,e){return r.trim().split(/^|\s+/).map(function(t){var n="",s=t.indexOf(".");if(s>=0&&(n=t.slice(s+1),t=t.slice(0,s)),t&&!e.hasOwnProperty(t))throw new Error("unknown type: "+t);return{type:t,name:n}})}Cs.prototype=la.prototype={constructor:Cs,on:function(r,e){var t=this._,n=Xg(r+"",t),s,i=-1,o=n.length;if(arguments.length<2){for(;++i<o;)if((s=(r=n[i]).type)&&(s=Zg(t[s],r.name)))return s;return}if(e!=null&&typeof e!="function")throw new Error("invalid callback: "+e);for(;++i<o;)if(s=(r=n[i]).type)t[s]=zl(t[s],r.name,e);else if(e==null)for(s in t)t[s]=zl(t[s],r.name,null);return this},copy:function(){var r={},e=this._;for(var t in e)r[t]=e[t].slice();return new Cs(r)},call:function(r,e){if((s=arguments.length-2)>0)for(var t=new Array(s),n=0,s,i;n<s;++n)t[n]=arguments[n+2];if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(i=this._[r],n=0,s=i.length;n<s;++n)i[n].value.apply(e,t)},apply:function(r,e,t){if(!this._.hasOwnProperty(r))throw new Error("unknown type: "+r);for(var n=this._[r],s=0,i=n.length;s<i;++s)n[s].value.apply(e,t)}};function Zg(r,e){for(var t=0,n=r.length,s;t<n;++t)if((s=r[t]).name===e)return s.value}function zl(r,e,t){for(var n=0,s=r.length;n<s;++n)if(r[n].name===e){r[n]=Jg,r=r.slice(0,n).concat(r.slice(n+1));break}return t!=null&&r.push({name:e,value:t}),r}var bo="http://www.w3.org/1999/xhtml";const Ol={svg:"http://www.w3.org/2000/svg",xhtml:bo,xlink:"http://www.w3.org/1999/xlink",xml:"http://www.w3.org/XML/1998/namespace",xmlns:"http://www.w3.org/2000/xmlns/"};function _i(r){var e=r+="",t=e.indexOf(":");return t>=0&&(e=r.slice(0,t))!=="xmlns"&&(r=r.slice(t+1)),Ol.hasOwnProperty(e)?{space:Ol[e],local:r}:r}function e0(r){return function(){var e=this.ownerDocument,t=this.namespaceURI;return t===bo&&e.documentElement.namespaceURI===bo?e.createElement(r):e.createElementNS(t,r)}}function t0(r){return function(){return this.ownerDocument.createElementNS(r.space,r.local)}}function ed(r){var e=_i(r);return(e.local?t0:e0)(e)}function r0(){}function ua(r){return r==null?r0:function(){return this.querySelector(r)}}function n0(r){typeof r!="function"&&(r=ua(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,a=n[s]=new Array(o),l,u,c=0;c<o;++c)(l=i[c])&&(u=r.call(l,l.__data__,c,i))&&("__data__"in l&&(u.__data__=l.__data__),a[c]=u);return new Tt(n,this._parents)}function s0(r){return r==null?[]:Array.isArray(r)?r:Array.from(r)}function i0(){return[]}function td(r){return r==null?i0:function(){return this.querySelectorAll(r)}}function o0(r){return function(){return s0(r.apply(this,arguments))}}function a0(r){typeof r=="function"?r=o0(r):r=td(r);for(var e=this._groups,t=e.length,n=[],s=[],i=0;i<t;++i)for(var o=e[i],a=o.length,l,u=0;u<a;++u)(l=o[u])&&(n.push(r.call(l,l.__data__,u,o)),s.push(l));return new Tt(n,s)}function rd(r){return function(){return this.matches(r)}}function nd(r){return function(e){return e.matches(r)}}var l0=Array.prototype.find;function u0(r){return function(){return l0.call(this.children,r)}}function c0(){return this.firstElementChild}function d0(r){return this.select(r==null?c0:u0(typeof r=="function"?r:nd(r)))}var f0=Array.prototype.filter;function h0(){return Array.from(this.children)}function p0(r){return function(){return f0.call(this.children,r)}}function g0(r){return this.selectAll(r==null?h0:p0(typeof r=="function"?r:nd(r)))}function m0(r){typeof r!="function"&&(r=rd(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,a=n[s]=[],l,u=0;u<o;++u)(l=i[u])&&r.call(l,l.__data__,u,i)&&a.push(l);return new Tt(n,this._parents)}function sd(r){return new Array(r.length)}function y0(){return new Tt(this._enter||this._groups.map(sd),this._parents)}function Qs(r,e){this.ownerDocument=r.ownerDocument,this.namespaceURI=r.namespaceURI,this._next=null,this._parent=r,this.__data__=e}Qs.prototype={constructor:Qs,appendChild:function(r){return this._parent.insertBefore(r,this._next)},insertBefore:function(r,e){return this._parent.insertBefore(r,e)},querySelector:function(r){return this._parent.querySelector(r)},querySelectorAll:function(r){return this._parent.querySelectorAll(r)}};function x0(r){return function(){return r}}function b0(r,e,t,n,s,i){for(var o=0,a,l=e.length,u=i.length;o<u;++o)(a=e[o])?(a.__data__=i[o],n[o]=a):t[o]=new Qs(r,i[o]);for(;o<l;++o)(a=e[o])&&(s[o]=a)}function v0(r,e,t,n,s,i,o){var a,l,u=new Map,c=e.length,d=i.length,h=new Array(c),p;for(a=0;a<c;++a)(l=e[a])&&(h[a]=p=o.call(l,l.__data__,a,e)+"",u.has(p)?s[a]=l:u.set(p,l));for(a=0;a<d;++a)p=o.call(r,i[a],a,i)+"",(l=u.get(p))?(n[a]=l,l.__data__=i[a],u.delete(p)):t[a]=new Qs(r,i[a]);for(a=0;a<c;++a)(l=e[a])&&u.get(h[a])===l&&(s[a]=l)}function _0(r){return r.__data__}function w0(r,e){if(!arguments.length)return Array.from(this,_0);var t=e?v0:b0,n=this._parents,s=this._groups;typeof r!="function"&&(r=x0(r));for(var i=s.length,o=new Array(i),a=new Array(i),l=new Array(i),u=0;u<i;++u){var c=n[u],d=s[u],h=d.length,p=C0(r.call(c,c&&c.__data__,u,n)),g=p.length,m=a[u]=new Array(g),x=o[u]=new Array(g),_=l[u]=new Array(h);t(c,d,m,x,_,p,e);for(var b=0,S=0,C,k;b<g;++b)if(C=m[b]){for(b>=S&&(S=b+1);!(k=x[S])&&++S<g;);C._next=k||null}}return o=new Tt(o,n),o._enter=a,o._exit=l,o}function C0(r){return typeof r=="object"&&"length"in r?r:Array.from(r)}function S0(){return new Tt(this._exit||this._groups.map(sd),this._parents)}function k0(r,e,t){var n=this.enter(),s=this,i=this.exit();return typeof r=="function"?(n=r(n),n&&(n=n.selection())):n=n.append(r+""),e!=null&&(s=e(s),s&&(s=s.selection())),t==null?i.remove():t(i),n&&s?n.merge(s).order():s}function E0(r){for(var e=r.selection?r.selection():r,t=this._groups,n=e._groups,s=t.length,i=n.length,o=Math.min(s,i),a=new Array(s),l=0;l<o;++l)for(var u=t[l],c=n[l],d=u.length,h=a[l]=new Array(d),p,g=0;g<d;++g)(p=u[g]||c[g])&&(h[g]=p);for(;l<s;++l)a[l]=t[l];return new Tt(a,this._parents)}function D0(){for(var r=this._groups,e=-1,t=r.length;++e<t;)for(var n=r[e],s=n.length-1,i=n[s],o;--s>=0;)(o=n[s])&&(i&&o.compareDocumentPosition(i)^4&&i.parentNode.insertBefore(o,i),i=o);return this}function A0(r){r||(r=T0);function e(d,h){return d&&h?r(d.__data__,h.__data__):!d-!h}for(var t=this._groups,n=t.length,s=new Array(n),i=0;i<n;++i){for(var o=t[i],a=o.length,l=s[i]=new Array(a),u,c=0;c<a;++c)(u=o[c])&&(l[c]=u);l.sort(e)}return new Tt(s,this._parents).order()}function T0(r,e){return r<e?-1:r>e?1:r>=e?0:NaN}function N0(){var r=arguments[0];return arguments[0]=this,r.apply(null,arguments),this}function B0(){return Array.from(this)}function j0(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],s=0,i=n.length;s<i;++s){var o=n[s];if(o)return o}return null}function M0(){let r=0;for(const e of this)++r;return r}function R0(){return!this.node()}function F0(r){for(var e=this._groups,t=0,n=e.length;t<n;++t)for(var s=e[t],i=0,o=s.length,a;i<o;++i)(a=s[i])&&r.call(a,a.__data__,i,s);return this}function L0(r){return function(){this.removeAttribute(r)}}function P0(r){return function(){this.removeAttributeNS(r.space,r.local)}}function I0(r,e){return function(){this.setAttribute(r,e)}}function z0(r,e){return function(){this.setAttributeNS(r.space,r.local,e)}}function O0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(r):this.setAttribute(r,t)}}function $0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttributeNS(r.space,r.local):this.setAttributeNS(r.space,r.local,t)}}function q0(r,e){var t=_i(r);if(arguments.length<2){var n=this.node();return t.local?n.getAttributeNS(t.space,t.local):n.getAttribute(t)}return this.each((e==null?t.local?P0:L0:typeof e=="function"?t.local?$0:O0:t.local?z0:I0)(t,e))}function id(r){return r.ownerDocument&&r.ownerDocument.defaultView||r.document&&r||r.defaultView}function U0(r){return function(){this.style.removeProperty(r)}}function W0(r,e,t){return function(){this.style.setProperty(r,e,t)}}function H0(r,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(r):this.style.setProperty(r,n,t)}}function V0(r,e,t){return arguments.length>1?this.each((e==null?U0:typeof e=="function"?H0:W0)(r,e,t??"")):rn(this.node(),r)}function rn(r,e){return r.style.getPropertyValue(e)||id(r).getComputedStyle(r,null).getPropertyValue(e)}function G0(r){return function(){delete this[r]}}function K0(r,e){return function(){this[r]=e}}function Y0(r,e){return function(){var t=e.apply(this,arguments);t==null?delete this[r]:this[r]=t}}function Q0(r,e){return arguments.length>1?this.each((e==null?G0:typeof e=="function"?Y0:K0)(r,e)):this.node()[r]}function od(r){return r.trim().split(/^|\s+/)}function ca(r){return r.classList||new ad(r)}function ad(r){this._node=r,this._names=od(r.getAttribute("class")||"")}ad.prototype={add:function(r){var e=this._names.indexOf(r);e<0&&(this._names.push(r),this._node.setAttribute("class",this._names.join(" ")))},remove:function(r){var e=this._names.indexOf(r);e>=0&&(this._names.splice(e,1),this._node.setAttribute("class",this._names.join(" ")))},contains:function(r){return this._names.indexOf(r)>=0}};function ld(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.add(e[n])}function ud(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.remove(e[n])}function J0(r){return function(){ld(this,r)}}function X0(r){return function(){ud(this,r)}}function Z0(r,e){return function(){(e.apply(this,arguments)?ld:ud)(this,r)}}function em(r,e){var t=od(r+"");if(arguments.length<2){for(var n=ca(this.node()),s=-1,i=t.length;++s<i;)if(!n.contains(t[s]))return!1;return!0}return this.each((typeof e=="function"?Z0:e?J0:X0)(t,e))}function tm(){this.textContent=""}function rm(r){return function(){this.textContent=r}}function nm(r){return function(){var e=r.apply(this,arguments);this.textContent=e??""}}function sm(r){return arguments.length?this.each(r==null?tm:(typeof r=="function"?nm:rm)(r)):this.node().textContent}function im(){this.innerHTML=""}function om(r){return function(){this.innerHTML=r}}function am(r){return function(){var e=r.apply(this,arguments);this.innerHTML=e??""}}function lm(r){return arguments.length?this.each(r==null?im:(typeof r=="function"?am:om)(r)):this.node().innerHTML}function um(){this.nextSibling&&this.parentNode.appendChild(this)}function cm(){return this.each(um)}function dm(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function fm(){return this.each(dm)}function hm(r){var e=typeof r=="function"?r:ed(r);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function pm(){return null}function gm(r,e){var t=typeof r=="function"?r:ed(r),n=e==null?pm:typeof e=="function"?e:ua(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function mm(){var r=this.parentNode;r&&r.removeChild(this)}function ym(){return this.each(mm)}function xm(){var r=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function bm(){var r=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function vm(r){return this.select(r?bm:xm)}function _m(r){return arguments.length?this.property("__data__",r):this.node().__data__}function wm(r){return function(e){r.call(this,e,this.__data__)}}function Cm(r){return r.trim().split(/^|\s+/).map(function(e){var t="",n=e.indexOf(".");return n>=0&&(t=e.slice(n+1),e=e.slice(0,n)),{type:e,name:t}})}function Sm(r){return function(){var e=this.__on;if(e){for(var t=0,n=-1,s=e.length,i;t<s;++t)i=e[t],(!r.type||i.type===r.type)&&i.name===r.name?this.removeEventListener(i.type,i.listener,i.options):e[++n]=i;++n?e.length=n:delete this.__on}}}function km(r,e,t){return function(){var n=this.__on,s,i=wm(e);if(n){for(var o=0,a=n.length;o<a;++o)if((s=n[o]).type===r.type&&s.name===r.name){this.removeEventListener(s.type,s.listener,s.options),this.addEventListener(s.type,s.listener=i,s.options=t),s.value=e;return}}this.addEventListener(r.type,i,t),s={type:r.type,name:r.name,value:e,listener:i,options:t},n?n.push(s):this.__on=[s]}}function Em(r,e,t){var n=Cm(r+""),s,i=n.length,o;if(arguments.length<2){var a=this.node().__on;if(a){for(var l=0,u=a.length,c;l<u;++l)for(s=0,c=a[l];s<i;++s)if((o=n[s]).type===c.type&&o.name===c.name)return c.value}return}for(a=e?km:Sm,s=0;s<i;++s)this.each(a(n[s],e,t));return this}function cd(r,e,t){var n=id(r),s=n.CustomEvent;typeof s=="function"?s=new s(e,t):(s=n.document.createEvent("Event"),t?(s.initEvent(e,t.bubbles,t.cancelable),s.detail=t.detail):s.initEvent(e,!1,!1)),r.dispatchEvent(s)}function Dm(r,e){return function(){return cd(this,r,e)}}function Am(r,e){return function(){return cd(this,r,e.apply(this,arguments))}}function Tm(r,e){return this.each((typeof e=="function"?Am:Dm)(r,e))}function*Nm(){for(var r=this._groups,e=0,t=r.length;e<t;++e)for(var n=r[e],s=0,i=n.length,o;s<i;++s)(o=n[s])&&(yield o)}var dd=[null];function Tt(r,e){this._groups=r,this._parents=e}function ss(){return new Tt([[document.documentElement]],dd)}function Bm(){return this}Tt.prototype=ss.prototype={constructor:Tt,select:n0,selectAll:a0,selectChild:d0,selectChildren:g0,filter:m0,data:w0,enter:y0,exit:S0,join:k0,merge:E0,selection:Bm,order:D0,sort:A0,call:N0,nodes:B0,node:j0,size:M0,empty:R0,each:F0,attr:q0,style:V0,property:Q0,classed:em,text:sm,html:lm,raise:cm,lower:fm,append:hm,insert:gm,remove:ym,clone:vm,datum:_m,on:Em,dispatch:Tm,[Symbol.iterator]:Nm};function Ft(r){return typeof r=="string"?new Tt([[document.querySelector(r)]],[document.documentElement]):new Tt([[r]],dd)}function jm(r){let e;for(;e=r.sourceEvent;)r=e;return r}function wr(r,e){if(r=jm(r),e===void 0&&(e=r.currentTarget),e){var t=e.ownerSVGElement||e;if(t.createSVGPoint){var n=t.createSVGPoint();return n.x=r.clientX,n.y=r.clientY,n=n.matrixTransform(e.getScreenCTM().inverse()),[n.x,n.y]}if(e.getBoundingClientRect){var s=e.getBoundingClientRect();return[r.clientX-s.left-e.clientLeft,r.clientY-s.top-e.clientTop]}}return[r.pageX,r.pageY]}const vo={capture:!0,passive:!1};function _o(r){r.preventDefault(),r.stopImmediatePropagation()}function Mm(r){var e=r.document.documentElement,t=Ft(r).on("dragstart.drag",_o,vo);"onselectstart"in e?t.on("selectstart.drag",_o,vo):(e.__noselect=e.style.MozUserSelect,e.style.MozUserSelect="none")}function Rm(r,e){var t=r.document.documentElement,n=Ft(r).on("dragstart.drag",null);e&&(n.on("click.drag",_o,vo),setTimeout(function(){n.on("click.drag",null)},0)),"onselectstart"in t?n.on("selectstart.drag",null):(t.style.MozUserSelect=t.__noselect,delete t.__noselect)}function da(r,e,t){r.prototype=e.prototype=t,t.constructor=r}function fd(r,e){var t=Object.create(r.prototype);for(var n in e)t[n]=e[n];return t}function is(){}var $n=.7,Js=1/$n,Jr="\\s*([+-]?\\d+)\\s*",qn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Vt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Fm=/^#([0-9a-f]{3,8})$/,Lm=new RegExp(`^rgb\\(${Jr},${Jr},${Jr}\\)$`),Pm=new RegExp(`^rgb\\(${Vt},${Vt},${Vt}\\)$`),Im=new RegExp(`^rgba\\(${Jr},${Jr},${Jr},${qn}\\)$`),zm=new RegExp(`^rgba\\(${Vt},${Vt},${Vt},${qn}\\)$`),Om=new RegExp(`^hsl\\(${qn},${Vt},${Vt}\\)$`),$m=new RegExp(`^hsla\\(${qn},${Vt},${Vt},${qn}\\)$`),$l={aliceblue:15792383,antiquewhite:16444375,aqua:65535,aquamarine:8388564,azure:15794175,beige:16119260,bisque:16770244,black:0,blanchedalmond:16772045,blue:255,blueviolet:9055202,brown:10824234,burlywood:14596231,cadetblue:6266528,chartreuse:8388352,chocolate:13789470,coral:16744272,cornflowerblue:6591981,cornsilk:16775388,crimson:14423100,cyan:65535,darkblue:139,darkcyan:35723,darkgoldenrod:12092939,darkgray:11119017,darkgreen:25600,darkgrey:11119017,darkkhaki:12433259,darkmagenta:9109643,darkolivegreen:5597999,darkorange:16747520,darkorchid:10040012,darkred:9109504,darksalmon:15308410,darkseagreen:9419919,darkslateblue:4734347,darkslategray:3100495,darkslategrey:3100495,darkturquoise:52945,darkviolet:9699539,deeppink:16716947,deepskyblue:49151,dimgray:6908265,dimgrey:6908265,dodgerblue:2003199,firebrick:11674146,floralwhite:16775920,forestgreen:2263842,fuchsia:16711935,gainsboro:14474460,ghostwhite:16316671,gold:16766720,goldenrod:14329120,gray:8421504,green:32768,greenyellow:11403055,grey:8421504,honeydew:15794160,hotpink:16738740,indianred:13458524,indigo:4915330,ivory:16777200,khaki:15787660,lavender:15132410,lavenderblush:16773365,lawngreen:8190976,lemonchiffon:16775885,lightblue:11393254,lightcoral:15761536,lightcyan:14745599,lightgoldenrodyellow:16448210,lightgray:13882323,lightgreen:9498256,lightgrey:13882323,lightpink:16758465,lightsalmon:16752762,lightseagreen:2142890,lightskyblue:8900346,lightslategray:7833753,lightslategrey:7833753,lightsteelblue:11584734,lightyellow:16777184,lime:65280,limegreen:3329330,linen:16445670,magenta:16711935,maroon:8388608,mediumaquamarine:6737322,mediumblue:205,mediumorchid:12211667,mediumpurple:9662683,mediumseagreen:3978097,mediumslateblue:8087790,mediumspringgreen:64154,mediumturquoise:4772300,mediumvioletred:13047173,midnightblue:1644912,mintcream:16121850,mistyrose:16770273,moccasin:16770229,navajowhite:16768685,navy:128,oldlace:16643558,olive:8421376,olivedrab:7048739,orange:16753920,orangered:16729344,orchid:14315734,palegoldenrod:15657130,palegreen:10025880,paleturquoise:11529966,palevioletred:14381203,papayawhip:16773077,peachpuff:16767673,peru:13468991,pink:16761035,plum:14524637,powderblue:11591910,purple:8388736,rebeccapurple:6697881,red:16711680,rosybrown:12357519,royalblue:4286945,saddlebrown:9127187,salmon:16416882,sandybrown:16032864,seagreen:3050327,seashell:16774638,sienna:10506797,silver:12632256,skyblue:8900331,slateblue:6970061,slategray:7372944,slategrey:7372944,snow:16775930,springgreen:65407,steelblue:4620980,tan:13808780,teal:32896,thistle:14204888,tomato:16737095,turquoise:4251856,violet:15631086,wheat:16113331,white:16777215,whitesmoke:16119285,yellow:16776960,yellowgreen:10145074};da(is,Un,{copy(r){return Object.assign(new this.constructor,this,r)},displayable(){return this.rgb().displayable()},hex:ql,formatHex:ql,formatHex8:qm,formatHsl:Um,formatRgb:Ul,toString:Ul});function ql(){return this.rgb().formatHex()}function qm(){return this.rgb().formatHex8()}function Um(){return hd(this).formatHsl()}function Ul(){return this.rgb().formatRgb()}function Un(r){var e,t;return r=(r+"").trim().toLowerCase(),(e=Fm.exec(r))?(t=e[1].length,e=parseInt(e[1],16),t===6?Wl(e):t===3?new Ct(e>>8&15|e>>4&240,e>>4&15|e&240,(e&15)<<4|e&15,1):t===8?ms(e>>24&255,e>>16&255,e>>8&255,(e&255)/255):t===4?ms(e>>12&15|e>>8&240,e>>8&15|e>>4&240,e>>4&15|e&240,((e&15)<<4|e&15)/255):null):(e=Lm.exec(r))?new Ct(e[1],e[2],e[3],1):(e=Pm.exec(r))?new Ct(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Im.exec(r))?ms(e[1],e[2],e[3],e[4]):(e=zm.exec(r))?ms(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Om.exec(r))?Gl(e[1],e[2]/100,e[3]/100,1):(e=$m.exec(r))?Gl(e[1],e[2]/100,e[3]/100,e[4]):$l.hasOwnProperty(r)?Wl($l[r]):r==="transparent"?new Ct(NaN,NaN,NaN,0):null}function Wl(r){return new Ct(r>>16&255,r>>8&255,r&255,1)}function ms(r,e,t,n){return n<=0&&(r=e=t=NaN),new Ct(r,e,t,n)}function Wm(r){return r instanceof is||(r=Un(r)),r?(r=r.rgb(),new Ct(r.r,r.g,r.b,r.opacity)):new Ct}function wo(r,e,t,n){return arguments.length===1?Wm(r):new Ct(r,e,t,n??1)}function Ct(r,e,t,n){this.r=+r,this.g=+e,this.b=+t,this.opacity=+n}da(Ct,wo,fd(is,{brighter(r){return r=r==null?Js:Math.pow(Js,r),new Ct(this.r*r,this.g*r,this.b*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new Ct(this.r*r,this.g*r,this.b*r,this.opacity)},rgb(){return this},clamp(){return new Ct(Tr(this.r),Tr(this.g),Tr(this.b),Xs(this.opacity))},displayable(){return-.5<=this.r&&this.r<255.5&&-.5<=this.g&&this.g<255.5&&-.5<=this.b&&this.b<255.5&&0<=this.opacity&&this.opacity<=1},hex:Hl,formatHex:Hl,formatHex8:Hm,formatRgb:Vl,toString:Vl}));function Hl(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}`}function Hm(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}${Sr((isNaN(this.opacity)?1:this.opacity)*255)}`}function Vl(){const r=Xs(this.opacity);return`${r===1?"rgb(":"rgba("}${Tr(this.r)}, ${Tr(this.g)}, ${Tr(this.b)}${r===1?")":`, ${r})`}`}function Xs(r){return isNaN(r)?1:Math.max(0,Math.min(1,r))}function Tr(r){return Math.max(0,Math.min(255,Math.round(r)||0))}function Sr(r){return r=Tr(r),(r<16?"0":"")+r.toString(16)}function Gl(r,e,t,n){return n<=0?r=e=t=NaN:t<=0||t>=1?r=e=NaN:e<=0&&(r=NaN),new Lt(r,e,t,n)}function hd(r){if(r instanceof Lt)return new Lt(r.h,r.s,r.l,r.opacity);if(r instanceof is||(r=Un(r)),!r)return new Lt;if(r instanceof Lt)return r;r=r.rgb();var e=r.r/255,t=r.g/255,n=r.b/255,s=Math.min(e,t,n),i=Math.max(e,t,n),o=NaN,a=i-s,l=(i+s)/2;return a?(e===i?o=(t-n)/a+(t<n)*6:t===i?o=(n-e)/a+2:o=(e-t)/a+4,a/=l<.5?i+s:2-i-s,o*=60):a=l>0&&l<1?0:o,new Lt(o,a,l,r.opacity)}function Vm(r,e,t,n){return arguments.length===1?hd(r):new Lt(r,e,t,n??1)}function Lt(r,e,t,n){this.h=+r,this.s=+e,this.l=+t,this.opacity=+n}da(Lt,Vm,fd(is,{brighter(r){return r=r==null?Js:Math.pow(Js,r),new Lt(this.h,this.s,this.l*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new Lt(this.h,this.s,this.l*r,this.opacity)},rgb(){var r=this.h%360+(this.h<0)*360,e=isNaN(r)||isNaN(this.s)?0:this.s,t=this.l,n=t+(t<.5?t:1-t)*e,s=2*t-n;return new Ct(qi(r>=240?r-240:r+120,s,n),qi(r,s,n),qi(r<120?r+240:r-120,s,n),this.opacity)},clamp(){return new Lt(Kl(this.h),ys(this.s),ys(this.l),Xs(this.opacity))},displayable(){return(0<=this.s&&this.s<=1||isNaN(this.s))&&0<=this.l&&this.l<=1&&0<=this.opacity&&this.opacity<=1},formatHsl(){const r=Xs(this.opacity);return`${r===1?"hsl(":"hsla("}${Kl(this.h)}, ${ys(this.s)*100}%, ${ys(this.l)*100}%${r===1?")":`, ${r})`}`}}));function Kl(r){return r=(r||0)%360,r<0?r+360:r}function ys(r){return Math.max(0,Math.min(1,r||0))}function qi(r,e,t){return(r<60?e+(t-e)*r/60:r<180?t:r<240?e+(t-e)*(240-r)/60:e)*255}const pd=r=>()=>r;function Gm(r,e){return function(t){return r+t*e}}function Km(r,e,t){return r=Math.pow(r,t),e=Math.pow(e,t)-r,t=1/t,function(n){return Math.pow(r+n*e,t)}}function Ym(r){return(r=+r)==1?gd:function(e,t){return t-e?Km(e,t,r):pd(isNaN(e)?t:e)}}function gd(r,e){var t=e-r;return t?Gm(r,t):pd(isNaN(r)?e:r)}const Yl=function r(e){var t=Ym(e);function n(s,i){var o=t((s=wo(s)).r,(i=wo(i)).r),a=t(s.g,i.g),l=t(s.b,i.b),u=gd(s.opacity,i.opacity);return function(c){return s.r=o(c),s.g=a(c),s.b=l(c),s.opacity=u(c),s+""}}return n.gamma=r,n}(1);function dr(r,e){return r=+r,e=+e,function(t){return r*(1-t)+e*t}}var Co=/[-+]?(?:\d+\.?\d*|\.?\d+)(?:[eE][-+]?\d+)?/g,Ui=new RegExp(Co.source,"g");function Qm(r){return function(){return r}}function Jm(r){return function(e){return r(e)+""}}function Xm(r,e){var t=Co.lastIndex=Ui.lastIndex=0,n,s,i,o=-1,a=[],l=[];for(r=r+"",e=e+"";(n=Co.exec(r))&&(s=Ui.exec(e));)(i=s.index)>t&&(i=e.slice(t,i),a[o]?a[o]+=i:a[++o]=i),(n=n[0])===(s=s[0])?a[o]?a[o]+=s:a[++o]=s:(a[++o]=null,l.push({i:o,x:dr(n,s)})),t=Ui.lastIndex;return t<e.length&&(i=e.slice(t),a[o]?a[o]+=i:a[++o]=i),a.length<2?l[0]?Jm(l[0].x):Qm(e):(e=l.length,function(u){for(var c=0,d;c<e;++c)a[(d=l[c]).i]=d.x(u);return a.join("")})}var Ql=180/Math.PI,So={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function md(r,e,t,n,s,i){var o,a,l;return(o=Math.sqrt(r*r+e*e))&&(r/=o,e/=o),(l=r*t+e*n)&&(t-=r*l,n-=e*l),(a=Math.sqrt(t*t+n*n))&&(t/=a,n/=a,l/=a),r*n<e*t&&(r=-r,e=-e,l=-l,o=-o),{translateX:s,translateY:i,rotate:Math.atan2(e,r)*Ql,skewX:Math.atan(l)*Ql,scaleX:o,scaleY:a}}var xs;function Zm(r){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(r+"");return e.isIdentity?So:md(e.a,e.b,e.c,e.d,e.e,e.f)}function ey(r){return r==null||(xs||(xs=document.createElementNS("http://www.w3.org/2000/svg","g")),xs.setAttribute("transform",r),!(r=xs.transform.baseVal.consolidate()))?So:(r=r.matrix,md(r.a,r.b,r.c,r.d,r.e,r.f))}function yd(r,e,t,n){function s(u){return u.length?u.pop()+" ":""}function i(u,c,d,h,p,g){if(u!==d||c!==h){var m=p.push("translate(",null,e,null,t);g.push({i:m-4,x:dr(u,d)},{i:m-2,x:dr(c,h)})}else(d||h)&&p.push("translate("+d+e+h+t)}function o(u,c,d,h){u!==c?(u-c>180?c+=360:c-u>180&&(u+=360),h.push({i:d.push(s(d)+"rotate(",null,n)-2,x:dr(u,c)})):c&&d.push(s(d)+"rotate("+c+n)}function a(u,c,d,h){u!==c?h.push({i:d.push(s(d)+"skewX(",null,n)-2,x:dr(u,c)}):c&&d.push(s(d)+"skewX("+c+n)}function l(u,c,d,h,p,g){if(u!==d||c!==h){var m=p.push(s(p)+"scale(",null,",",null,")");g.push({i:m-4,x:dr(u,d)},{i:m-2,x:dr(c,h)})}else(d!==1||h!==1)&&p.push(s(p)+"scale("+d+","+h+")")}return function(u,c){var d=[],h=[];return u=r(u),c=r(c),i(u.translateX,u.translateY,c.translateX,c.translateY,d,h),o(u.rotate,c.rotate,d,h),a(u.skewX,c.skewX,d,h),l(u.scaleX,u.scaleY,c.scaleX,c.scaleY,d,h),u=c=null,function(p){for(var g=-1,m=h.length,x;++g<m;)d[(x=h[g]).i]=x.x(p);return d.join("")}}}var ty=yd(Zm,"px, ","px)","deg)"),ry=yd(ey,", ",")",")"),ny=1e-12;function Jl(r){return((r=Math.exp(r))+1/r)/2}function sy(r){return((r=Math.exp(r))-1/r)/2}function iy(r){return((r=Math.exp(2*r))-1)/(r+1)}const oy=function r(e,t,n){function s(i,o){var a=i[0],l=i[1],u=i[2],c=o[0],d=o[1],h=o[2],p=c-a,g=d-l,m=p*p+g*g,x,_;if(m<ny)_=Math.log(h/u)/e,x=function(v){return[a+v*p,l+v*g,u*Math.exp(e*v*_)]};else{var b=Math.sqrt(m),S=(h*h-u*u+n*m)/(2*u*t*b),C=(h*h-u*u-n*m)/(2*h*t*b),k=Math.log(Math.sqrt(S*S+1)-S),E=Math.log(Math.sqrt(C*C+1)-C);_=(E-k)/e,x=function(v){var T=v*_,B=Jl(k),j=u/(t*b)*(B*iy(e*T+k)-sy(k));return[a+j*p,l+j*g,u*B/Jl(e*T+k)]}}return x.duration=_*1e3*e/Math.SQRT2,x}return s.rho=function(i){var o=Math.max(.001,+i),a=o*o,l=a*a;return r(o,a,l)},s}(Math.SQRT2,2,4);var nn=0,Cn=0,yn=0,xd=1e3,Zs,Sn,ei=0,Lr=0,wi=0,Wn=typeof performance=="object"&&performance.now?performance:Date,bd=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(r){setTimeout(r,17)};function fa(){return Lr||(bd(ay),Lr=Wn.now()+wi)}function ay(){Lr=0}function ti(){this._call=this._time=this._next=null}ti.prototype=vd.prototype={constructor:ti,restart:function(r,e,t){if(typeof r!="function")throw new TypeError("callback is not a function");t=(t==null?fa():+t)+(e==null?0:+e),!this._next&&Sn!==this&&(Sn?Sn._next=this:Zs=this,Sn=this),this._call=r,this._time=t,ko()},stop:function(){this._call&&(this._call=null,this._time=1/0,ko())}};function vd(r,e,t){var n=new ti;return n.restart(r,e,t),n}function ly(){fa(),++nn;for(var r=Zs,e;r;)(e=Lr-r._time)>=0&&r._call.call(void 0,e),r=r._next;--nn}function Xl(){Lr=(ei=Wn.now())+wi,nn=Cn=0;try{ly()}finally{nn=0,cy(),Lr=0}}function uy(){var r=Wn.now(),e=r-ei;e>xd&&(wi-=e,ei=r)}function cy(){for(var r,e=Zs,t,n=1/0;e;)e._call?(n>e._time&&(n=e._time),r=e,e=e._next):(t=e._next,e._next=null,e=r?r._next=t:Zs=t);Sn=r,ko(n)}function ko(r){if(!nn){Cn&&(Cn=clearTimeout(Cn));var e=r-Lr;e>24?(r<1/0&&(Cn=setTimeout(Xl,r-Wn.now()-wi)),yn&&(yn=clearInterval(yn))):(yn||(ei=Wn.now(),yn=setInterval(uy,xd)),nn=1,bd(Xl))}}function Zl(r,e,t){var n=new ti;return e=e==null?0:+e,n.restart(s=>{n.stop(),r(s+e)},e,t),n}var dy=la("start","end","cancel","interrupt"),fy=[],_d=0,eu=1,Eo=2,Ss=3,tu=4,Do=5,ks=6;function Ci(r,e,t,n,s,i){var o=r.__transition;if(!o)r.__transition={};else if(t in o)return;hy(r,t,{name:e,index:n,group:s,on:dy,tween:fy,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:_d})}function ha(r,e){var t=$t(r,e);if(t.state>_d)throw new Error("too late; already scheduled");return t}function Jt(r,e){var t=$t(r,e);if(t.state>Ss)throw new Error("too late; already running");return t}function $t(r,e){var t=r.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function hy(r,e,t){var n=r.__transition,s;n[e]=t,t.timer=vd(i,0,t.time);function i(u){t.state=eu,t.timer.restart(o,t.delay,t.time),t.delay<=u&&o(u-t.delay)}function o(u){var c,d,h,p;if(t.state!==eu)return l();for(c in n)if(p=n[c],p.name===t.name){if(p.state===Ss)return Zl(o);p.state===tu?(p.state=ks,p.timer.stop(),p.on.call("interrupt",r,r.__data__,p.index,p.group),delete n[c]):+c<e&&(p.state=ks,p.timer.stop(),p.on.call("cancel",r,r.__data__,p.index,p.group),delete n[c])}if(Zl(function(){t.state===Ss&&(t.state=tu,t.timer.restart(a,t.delay,t.time),a(u))}),t.state=Eo,t.on.call("start",r,r.__data__,t.index,t.group),t.state===Eo){for(t.state=Ss,s=new Array(h=t.tween.length),c=0,d=-1;c<h;++c)(p=t.tween[c].value.call(r,r.__data__,t.index,t.group))&&(s[++d]=p);s.length=d+1}}function a(u){for(var c=u<t.duration?t.ease.call(null,u/t.duration):(t.timer.restart(l),t.state=Do,1),d=-1,h=s.length;++d<h;)s[d].call(r,c);t.state===Do&&(t.on.call("end",r,r.__data__,t.index,t.group),l())}function l(){t.state=ks,t.timer.stop(),delete n[e];for(var u in n)return;delete r.__transition}}function Es(r,e){var t=r.__transition,n,s,i=!0,o;if(t){e=e==null?null:e+"";for(o in t){if((n=t[o]).name!==e){i=!1;continue}s=n.state>Eo&&n.state<Do,n.state=ks,n.timer.stop(),n.on.call(s?"interrupt":"cancel",r,r.__data__,n.index,n.group),delete t[o]}i&&delete r.__transition}}function py(r){return this.each(function(){Es(this,r)})}function gy(r,e){var t,n;return function(){var s=Jt(this,r),i=s.tween;if(i!==t){n=t=i;for(var o=0,a=n.length;o<a;++o)if(n[o].name===e){n=n.slice(),n.splice(o,1);break}}s.tween=n}}function my(r,e,t){var n,s;if(typeof t!="function")throw new Error;return function(){var i=Jt(this,r),o=i.tween;if(o!==n){s=(n=o).slice();for(var a={name:e,value:t},l=0,u=s.length;l<u;++l)if(s[l].name===e){s[l]=a;break}l===u&&s.push(a)}i.tween=s}}function yy(r,e){var t=this._id;if(r+="",arguments.length<2){for(var n=$t(this.node(),t).tween,s=0,i=n.length,o;s<i;++s)if((o=n[s]).name===r)return o.value;return null}return this.each((e==null?gy:my)(t,r,e))}function pa(r,e,t){var n=r._id;return r.each(function(){var s=Jt(this,n);(s.value||(s.value={}))[e]=t.apply(this,arguments)}),function(s){return $t(s,n).value[e]}}function wd(r,e){var t;return(typeof e=="number"?dr:e instanceof Un?Yl:(t=Un(e))?(e=t,Yl):Xm)(r,e)}function xy(r){return function(){this.removeAttribute(r)}}function by(r){return function(){this.removeAttributeNS(r.space,r.local)}}function vy(r,e,t){var n,s=t+"",i;return function(){var o=this.getAttribute(r);return o===s?null:o===n?i:i=e(n=o,t)}}function _y(r,e,t){var n,s=t+"",i;return function(){var o=this.getAttributeNS(r.space,r.local);return o===s?null:o===n?i:i=e(n=o,t)}}function wy(r,e,t){var n,s,i;return function(){var o,a=t(this),l;return a==null?void this.removeAttribute(r):(o=this.getAttribute(r),l=a+"",o===l?null:o===n&&l===s?i:(s=l,i=e(n=o,a)))}}function Cy(r,e,t){var n,s,i;return function(){var o,a=t(this),l;return a==null?void this.removeAttributeNS(r.space,r.local):(o=this.getAttributeNS(r.space,r.local),l=a+"",o===l?null:o===n&&l===s?i:(s=l,i=e(n=o,a)))}}function Sy(r,e){var t=_i(r),n=t==="transform"?ry:wd;return this.attrTween(r,typeof e=="function"?(t.local?Cy:wy)(t,n,pa(this,"attr."+r,e)):e==null?(t.local?by:xy)(t):(t.local?_y:vy)(t,n,e))}function ky(r,e){return function(t){this.setAttribute(r,e.call(this,t))}}function Ey(r,e){return function(t){this.setAttributeNS(r.space,r.local,e.call(this,t))}}function Dy(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&Ey(r,i)),t}return s._value=e,s}function Ay(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&ky(r,i)),t}return s._value=e,s}function Ty(r,e){var t="attr."+r;if(arguments.length<2)return(t=this.tween(t))&&t._value;if(e==null)return this.tween(t,null);if(typeof e!="function")throw new Error;var n=_i(r);return this.tween(t,(n.local?Dy:Ay)(n,e))}function Ny(r,e){return function(){ha(this,r).delay=+e.apply(this,arguments)}}function By(r,e){return e=+e,function(){ha(this,r).delay=e}}function jy(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?Ny:By)(e,r)):$t(this.node(),e).delay}function My(r,e){return function(){Jt(this,r).duration=+e.apply(this,arguments)}}function Ry(r,e){return e=+e,function(){Jt(this,r).duration=e}}function Fy(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?My:Ry)(e,r)):$t(this.node(),e).duration}function Ly(r,e){if(typeof e!="function")throw new Error;return function(){Jt(this,r).ease=e}}function Py(r){var e=this._id;return arguments.length?this.each(Ly(e,r)):$t(this.node(),e).ease}function Iy(r,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;Jt(this,r).ease=t}}function zy(r){if(typeof r!="function")throw new Error;return this.each(Iy(this._id,r))}function Oy(r){typeof r!="function"&&(r=rd(r));for(var e=this._groups,t=e.length,n=new Array(t),s=0;s<t;++s)for(var i=e[s],o=i.length,a=n[s]=[],l,u=0;u<o;++u)(l=i[u])&&r.call(l,l.__data__,u,i)&&a.push(l);return new sr(n,this._parents,this._name,this._id)}function $y(r){if(r._id!==this._id)throw new Error;for(var e=this._groups,t=r._groups,n=e.length,s=t.length,i=Math.min(n,s),o=new Array(n),a=0;a<i;++a)for(var l=e[a],u=t[a],c=l.length,d=o[a]=new Array(c),h,p=0;p<c;++p)(h=l[p]||u[p])&&(d[p]=h);for(;a<n;++a)o[a]=e[a];return new sr(o,this._parents,this._name,this._id)}function qy(r){return(r+"").trim().split(/^|\s+/).every(function(e){var t=e.indexOf(".");return t>=0&&(e=e.slice(0,t)),!e||e==="start"})}function Uy(r,e,t){var n,s,i=qy(e)?ha:Jt;return function(){var o=i(this,r),a=o.on;a!==n&&(s=(n=a).copy()).on(e,t),o.on=s}}function Wy(r,e){var t=this._id;return arguments.length<2?$t(this.node(),t).on.on(r):this.each(Uy(t,r,e))}function Hy(r){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==r)return;e&&e.removeChild(this)}}function Vy(){return this.on("end.remove",Hy(this._id))}function Gy(r){var e=this._name,t=this._id;typeof r!="function"&&(r=ua(r));for(var n=this._groups,s=n.length,i=new Array(s),o=0;o<s;++o)for(var a=n[o],l=a.length,u=i[o]=new Array(l),c,d,h=0;h<l;++h)(c=a[h])&&(d=r.call(c,c.__data__,h,a))&&("__data__"in c&&(d.__data__=c.__data__),u[h]=d,Ci(u[h],e,t,h,u,$t(c,t)));return new sr(i,this._parents,e,t)}function Ky(r){var e=this._name,t=this._id;typeof r!="function"&&(r=td(r));for(var n=this._groups,s=n.length,i=[],o=[],a=0;a<s;++a)for(var l=n[a],u=l.length,c,d=0;d<u;++d)if(c=l[d]){for(var h=r.call(c,c.__data__,d,l),p,g=$t(c,t),m=0,x=h.length;m<x;++m)(p=h[m])&&Ci(p,e,t,m,h,g);i.push(h),o.push(c)}return new sr(i,o,e,t)}var Yy=ss.prototype.constructor;function Qy(){return new Yy(this._groups,this._parents)}function Jy(r,e){var t,n,s;return function(){var i=rn(this,r),o=(this.style.removeProperty(r),rn(this,r));return i===o?null:i===t&&o===n?s:s=e(t=i,n=o)}}function Cd(r){return function(){this.style.removeProperty(r)}}function Xy(r,e,t){var n,s=t+"",i;return function(){var o=rn(this,r);return o===s?null:o===n?i:i=e(n=o,t)}}function Zy(r,e,t){var n,s,i;return function(){var o=rn(this,r),a=t(this),l=a+"";return a==null&&(l=a=(this.style.removeProperty(r),rn(this,r))),o===l?null:o===n&&l===s?i:(s=l,i=e(n=o,a))}}function e2(r,e){var t,n,s,i="style."+e,o="end."+i,a;return function(){var l=Jt(this,r),u=l.on,c=l.value[i]==null?a||(a=Cd(e)):void 0;(u!==t||s!==c)&&(n=(t=u).copy()).on(o,s=c),l.on=n}}function t2(r,e,t){var n=(r+="")=="transform"?ty:wd;return e==null?this.styleTween(r,Jy(r,n)).on("end.style."+r,Cd(r)):typeof e=="function"?this.styleTween(r,Zy(r,n,pa(this,"style."+r,e))).each(e2(this._id,r)):this.styleTween(r,Xy(r,n,e),t).on("end.style."+r,null)}function r2(r,e,t){return function(n){this.style.setProperty(r,e.call(this,n),t)}}function n2(r,e,t){var n,s;function i(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&r2(r,o,t)),n}return i._value=e,i}function s2(r,e,t){var n="style."+(r+="");if(arguments.length<2)return(n=this.tween(n))&&n._value;if(e==null)return this.tween(n,null);if(typeof e!="function")throw new Error;return this.tween(n,n2(r,e,t??""))}function i2(r){return function(){this.textContent=r}}function o2(r){return function(){var e=r(this);this.textContent=e??""}}function a2(r){return this.tween("text",typeof r=="function"?o2(pa(this,"text",r)):i2(r==null?"":r+""))}function l2(r){return function(e){this.textContent=r.call(this,e)}}function u2(r){var e,t;function n(){var s=r.apply(this,arguments);return s!==t&&(e=(t=s)&&l2(s)),e}return n._value=r,n}function c2(r){var e="text";if(arguments.length<1)return(e=this.tween(e))&&e._value;if(r==null)return this.tween(e,null);if(typeof r!="function")throw new Error;return this.tween(e,u2(r))}function d2(){for(var r=this._name,e=this._id,t=Sd(),n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],a=o.length,l,u=0;u<a;++u)if(l=o[u]){var c=$t(l,e);Ci(l,r,t,u,o,{time:c.time+c.delay+c.duration,delay:0,duration:c.duration,ease:c.ease})}return new sr(n,this._parents,r,t)}function f2(){var r,e,t=this,n=t._id,s=t.size();return new Promise(function(i,o){var a={value:o},l={value:function(){--s===0&&i()}};t.each(function(){var u=Jt(this,n),c=u.on;c!==r&&(e=(r=c).copy(),e._.cancel.push(a),e._.interrupt.push(a),e._.end.push(l)),u.on=e}),s===0&&i()})}var h2=0;function sr(r,e,t,n){this._groups=r,this._parents=e,this._name=t,this._id=n}function Sd(){return++h2}var er=ss.prototype;sr.prototype={constructor:sr,select:Gy,selectAll:Ky,selectChild:er.selectChild,selectChildren:er.selectChildren,filter:Oy,merge:$y,selection:Qy,transition:d2,call:er.call,nodes:er.nodes,node:er.node,size:er.size,empty:er.empty,each:er.each,on:Wy,attr:Sy,attrTween:Ty,style:t2,styleTween:s2,text:a2,textTween:c2,remove:Vy,tween:yy,delay:jy,duration:Fy,ease:Py,easeVarying:zy,end:f2,[Symbol.iterator]:er[Symbol.iterator]};function p2(r){return((r*=2)<=1?r*r*r:(r-=2)*r*r+2)/2}var g2={time:null,delay:0,duration:250,ease:p2};function m2(r,e){for(var t;!(t=r.__transition)||!(t=t[e]);)if(!(r=r.parentNode))throw new Error(`transition ${e} not found`);return t}function y2(r){var e,t;r instanceof sr?(e=r._id,r=r._name):(e=Sd(),(t=g2).time=fa(),r=r==null?null:r+"");for(var n=this._groups,s=n.length,i=0;i<s;++i)for(var o=n[i],a=o.length,l,u=0;u<a;++u)(l=o[u])&&Ci(l,r,e,u,o,t||m2(l,e));return new sr(n,this._parents,r,e)}ss.prototype.interrupt=py;ss.prototype.transition=y2;const bs=r=>()=>r;function x2(r,{sourceEvent:e,target:t,transform:n,dispatch:s}){Object.defineProperties(this,{type:{value:r,enumerable:!0,configurable:!0},sourceEvent:{value:e,enumerable:!0,configurable:!0},target:{value:t,enumerable:!0,configurable:!0},transform:{value:n,enumerable:!0,configurable:!0},_:{value:s}})}function rr(r,e,t){this.k=r,this.x=e,this.y=t}rr.prototype={constructor:rr,scale:function(r){return r===1?this:new rr(this.k*r,this.x,this.y)},translate:function(r,e){return r===0&e===0?this:new rr(this.k,this.x+this.k*r,this.y+this.k*e)},apply:function(r){return[r[0]*this.k+this.x,r[1]*this.k+this.y]},applyX:function(r){return r*this.k+this.x},applyY:function(r){return r*this.k+this.y},invert:function(r){return[(r[0]-this.x)/this.k,(r[1]-this.y)/this.k]},invertX:function(r){return(r-this.x)/this.k},invertY:function(r){return(r-this.y)/this.k},rescaleX:function(r){return r.copy().domain(r.range().map(this.invertX,this).map(r.invert,r))},rescaleY:function(r){return r.copy().domain(r.range().map(this.invertY,this).map(r.invert,r))},toString:function(){return"translate("+this.x+","+this.y+") scale("+this.k+")"}};var ri=new rr(1,0,0);rr.prototype;function Wi(r){r.stopImmediatePropagation()}function xn(r){r.preventDefault(),r.stopImmediatePropagation()}function b2(r){return(!r.ctrlKey||r.type==="wheel")&&!r.button}function v2(){var r=this;return r instanceof SVGElement?(r=r.ownerSVGElement||r,r.hasAttribute("viewBox")?(r=r.viewBox.baseVal,[[r.x,r.y],[r.x+r.width,r.y+r.height]]):[[0,0],[r.width.baseVal.value,r.height.baseVal.value]]):[[0,0],[r.clientWidth,r.clientHeight]]}function ru(){return this.__zoom||ri}function _2(r){return-r.deltaY*(r.deltaMode===1?.05:r.deltaMode?1:.002)*(r.ctrlKey?10:1)}function w2(){return navigator.maxTouchPoints||"ontouchstart"in this}function C2(r,e,t){var n=r.invertX(e[0][0])-t[0][0],s=r.invertX(e[1][0])-t[1][0],i=r.invertY(e[0][1])-t[0][1],o=r.invertY(e[1][1])-t[1][1];return r.translate(s>n?(n+s)/2:Math.min(0,n)||Math.max(0,s),o>i?(i+o)/2:Math.min(0,i)||Math.max(0,o))}function S2(){var r=b2,e=v2,t=C2,n=_2,s=w2,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],a=250,l=oy,u=la("start","zoom","end"),c,d,h,p=500,g=150,m=0,x=10;function _(w){w.property("__zoom",ru).on("wheel.zoom",T,{passive:!1}).on("mousedown.zoom",B).on("dblclick.zoom",j).filter(s).on("touchstart.zoom",N).on("touchmove.zoom",R).on("touchend.zoom touchcancel.zoom",M).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(w,D,F,z){var q=w.selection?w.selection():w;q.property("__zoom",ru),w!==q?k(w,D,F,z):q.interrupt().each(function(){E(this,arguments).event(z).start().zoom(null,typeof D=="function"?D.apply(this,arguments):D).end()})},_.scaleBy=function(w,D,F,z){_.scaleTo(w,function(){var q=this.__zoom.k,J=typeof D=="function"?D.apply(this,arguments):D;return q*J},F,z)},_.scaleTo=function(w,D,F,z){_.transform(w,function(){var q=e.apply(this,arguments),J=this.__zoom,te=F==null?C(q):typeof F=="function"?F.apply(this,arguments):F,W=J.invert(te),G=typeof D=="function"?D.apply(this,arguments):D;return t(S(b(J,G),te,W),q,o)},F,z)},_.translateBy=function(w,D,F,z){_.transform(w,function(){return t(this.__zoom.translate(typeof D=="function"?D.apply(this,arguments):D,typeof F=="function"?F.apply(this,arguments):F),e.apply(this,arguments),o)},null,z)},_.translateTo=function(w,D,F,z,q){_.transform(w,function(){var J=e.apply(this,arguments),te=this.__zoom,W=z==null?C(J):typeof z=="function"?z.apply(this,arguments):z;return t(ri.translate(W[0],W[1]).scale(te.k).translate(typeof D=="function"?-D.apply(this,arguments):-D,typeof F=="function"?-F.apply(this,arguments):-F),J,o)},z,q)};function b(w,D){return D=Math.max(i[0],Math.min(i[1],D)),D===w.k?w:new rr(D,w.x,w.y)}function S(w,D,F){var z=D[0]-F[0]*w.k,q=D[1]-F[1]*w.k;return z===w.x&&q===w.y?w:new rr(w.k,z,q)}function C(w){return[(+w[0][0]+ +w[1][0])/2,(+w[0][1]+ +w[1][1])/2]}function k(w,D,F,z){w.on("start.zoom",function(){E(this,arguments).event(z).start()}).on("interrupt.zoom end.zoom",function(){E(this,arguments).event(z).end()}).tween("zoom",function(){var q=this,J=arguments,te=E(q,J).event(z),W=e.apply(q,J),G=F==null?C(W):typeof F=="function"?F.apply(q,J):F,H=Math.max(W[1][0]-W[0][0],W[1][1]-W[0][1]),se=q.__zoom,le=typeof D=="function"?D.apply(q,J):D,ue=l(se.invert(G).concat(H/se.k),le.invert(G).concat(H/le.k));return function(_e){if(_e===1)_e=le;else{var fe=ue(_e),De=H/fe[2];_e=new rr(De,G[0]-fe[0]*De,G[1]-fe[1]*De)}te.zoom(null,_e)}})}function E(w,D,F){return!F&&w.__zooming||new v(w,D)}function v(w,D){this.that=w,this.args=D,this.active=0,this.sourceEvent=null,this.extent=e.apply(w,D),this.taps=0}v.prototype={event:function(w){return w&&(this.sourceEvent=w),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(w,D){return this.mouse&&w!=="mouse"&&(this.mouse[1]=D.invert(this.mouse[0])),this.touch0&&w!=="touch"&&(this.touch0[1]=D.invert(this.touch0[0])),this.touch1&&w!=="touch"&&(this.touch1[1]=D.invert(this.touch1[0])),this.that.__zoom=D,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(w){var D=Ft(this.that).datum();u.call(w,this.that,new x2(w,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:u}),D)}};function T(w,...D){if(!r.apply(this,arguments))return;var F=E(this,D).event(w),z=this.__zoom,q=Math.max(i[0],Math.min(i[1],z.k*Math.pow(2,n.apply(this,arguments)))),J=wr(w);if(F.wheel)(F.mouse[0][0]!==J[0]||F.mouse[0][1]!==J[1])&&(F.mouse[1]=z.invert(F.mouse[0]=J)),clearTimeout(F.wheel);else{if(z.k===q)return;F.mouse=[J,z.invert(J)],Es(this),F.start()}xn(w),F.wheel=setTimeout(te,g),F.zoom("mouse",t(S(b(z,q),F.mouse[0],F.mouse[1]),F.extent,o));function te(){F.wheel=null,F.end()}}function B(w,...D){if(h||!r.apply(this,arguments))return;var F=w.currentTarget,z=E(this,D,!0).event(w),q=Ft(w.view).on("mousemove.zoom",G,!0).on("mouseup.zoom",H,!0),J=wr(w,F),te=w.clientX,W=w.clientY;Mm(w.view),Wi(w),z.mouse=[J,this.__zoom.invert(J)],Es(this),z.start();function G(se){if(xn(se),!z.moved){var le=se.clientX-te,ue=se.clientY-W;z.moved=le*le+ue*ue>m}z.event(se).zoom("mouse",t(S(z.that.__zoom,z.mouse[0]=wr(se,F),z.mouse[1]),z.extent,o))}function H(se){q.on("mousemove.zoom mouseup.zoom",null),Rm(se.view,z.moved),xn(se),z.event(se).end()}}function j(w,...D){if(r.apply(this,arguments)){var F=this.__zoom,z=wr(w.changedTouches?w.changedTouches[0]:w,this),q=F.invert(z),J=F.k*(w.shiftKey?.5:2),te=t(S(b(F,J),z,q),e.apply(this,D),o);xn(w),a>0?Ft(this).transition().duration(a).call(k,te,z,w):Ft(this).call(_.transform,te,z,w)}}function N(w,...D){if(r.apply(this,arguments)){var F=w.touches,z=F.length,q=E(this,D,w.changedTouches.length===z).event(w),J,te,W,G;for(Wi(w),te=0;te<z;++te)W=F[te],G=wr(W,this),G=[G,this.__zoom.invert(G),W.identifier],q.touch0?!q.touch1&&q.touch0[2]!==G[2]&&(q.touch1=G,q.taps=0):(q.touch0=G,J=!0,q.taps=1+!!c);c&&(c=clearTimeout(c)),J&&(q.taps<2&&(d=G[0],c=setTimeout(function(){c=null},p)),Es(this),q.start())}}function R(w,...D){if(this.__zooming){var F=E(this,D).event(w),z=w.changedTouches,q=z.length,J,te,W,G;for(xn(w),J=0;J<q;++J)te=z[J],W=wr(te,this),F.touch0&&F.touch0[2]===te.identifier?F.touch0[0]=W:F.touch1&&F.touch1[2]===te.identifier&&(F.touch1[0]=W);if(te=F.that.__zoom,F.touch1){var H=F.touch0[0],se=F.touch0[1],le=F.touch1[0],ue=F.touch1[1],_e=(_e=le[0]-H[0])*_e+(_e=le[1]-H[1])*_e,fe=(fe=ue[0]-se[0])*fe+(fe=ue[1]-se[1])*fe;te=b(te,Math.sqrt(_e/fe)),W=[(H[0]+le[0])/2,(H[1]+le[1])/2],G=[(se[0]+ue[0])/2,(se[1]+ue[1])/2]}else if(F.touch0)W=F.touch0[0],G=F.touch0[1];else return;F.zoom("touch",t(S(te,W,G),F.extent,o))}}function M(w,...D){if(this.__zooming){var F=E(this,D).event(w),z=w.changedTouches,q=z.length,J,te;for(Wi(w),h&&clearTimeout(h),h=setTimeout(function(){h=null},p),J=0;J<q;++J)te=z[J],F.touch0&&F.touch0[2]===te.identifier?delete F.touch0:F.touch1&&F.touch1[2]===te.identifier&&delete F.touch1;if(F.touch1&&!F.touch0&&(F.touch0=F.touch1,delete F.touch1),F.touch0)F.touch0[1]=this.__zoom.invert(F.touch0[0]);else if(F.end(),F.taps===2&&(te=wr(te,this),Math.hypot(d[0]-te[0],d[1]-te[1])<x)){var W=Ft(this).on("dblclick.zoom");W&&W.apply(this,arguments)}}}return _.wheelDelta=function(w){return arguments.length?(n=typeof w=="function"?w:bs(+w),_):n},_.filter=function(w){return arguments.length?(r=typeof w=="function"?w:bs(!!w),_):r},_.touchable=function(w){return arguments.length?(s=typeof w=="function"?w:bs(!!w),_):s},_.extent=function(w){return arguments.length?(e=typeof w=="function"?w:bs([[+w[0][0],+w[0][1]],[+w[1][0],+w[1][1]]]),_):e},_.scaleExtent=function(w){return arguments.length?(i[0]=+w[0],i[1]=+w[1],_):[i[0],i[1]]},_.translateExtent=function(w){return arguments.length?(o[0][0]=+w[0][0],o[1][0]=+w[1][0],o[0][1]=+w[0][1],o[1][1]=+w[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(w){return arguments.length?(t=w,_):t},_.duration=function(w){return arguments.length?(a=+w,_):a},_.interpolate=function(w){return arguments.length?(l=w,_):l},_.on=function(){var w=u.on.apply(u,arguments);return w===u?_:w},_.clickDistance=function(w){return arguments.length?(m=(w=+w)*w,_):Math.sqrt(m)},_.tapDistance=function(w){return arguments.length?(x=+w,_):x},_}function kd(r={}){const{minZoom:e=.1,maxZoom:t=4,initialTransform:n,zoomable:s=!0,pannable:i=!0,onTransformChange:o}=r,a=y.useRef(null),l=y.useRef(),[u,c]=y.useState(n||{x:0,y:0,k:1});y.useEffect(()=>{if(!a.current)return;const x=S2().scaleExtent([e,t]).filter(b=>!s&&b.type==="wheel"||!i&&(b.type==="mousedown"||b.type==="touchstart")?!1:b.type==="wheel"?s:b.type==="mousedown"||b.type==="touchstart"?b.target.closest("[data-qmap-node]")?!1:i:!0).on("zoom",b=>{const S={x:b.transform.x,y:b.transform.y,k:b.transform.k};c(S),o==null||o(S)});l.current=x;const _=Ft(a.current);return _.call(x),_.on("dblclick.zoom",null),n&&_.call(x.transform,ri.translate(n.x,n.y).scale(n.k)),()=>{_.on(".zoom",null)}},[e,t,s,i]),y.useEffect(()=>{l.current&&l.current.on("zoom",x=>{const _={x:x.transform.x,y:x.transform.y,k:x.transform.k};c(_),o==null||o(_)})},[o]);const d=y.useCallback((x,_,b,S=!0)=>{if(!a.current||!l.current)return;const C=Ft(a.current),k=ri.translate(x,_).scale(b);C.call(l.current.transform,k)},[]),h=y.useCallback(()=>{!a.current||!l.current||Ft(a.current).call(l.current.scaleBy,1.3)},[]),p=y.useCallback(()=>{!a.current||!l.current||Ft(a.current).call(l.current.scaleBy,.7)},[]),g=y.useCallback(()=>{d(0,0,1,!0)},[d]),m=y.useCallback((x,_=50)=>{if(!a.current||!l.current||x.length===0)return;const b=a.current,S=b.clientWidth,C=b.clientHeight;let k=1/0,E=1/0,v=-1/0,T=-1/0;for(const q of x){const J=q.width||200,te=q.height||100;k=Math.min(k,q.x),E=Math.min(E,q.y),v=Math.max(v,q.x+J),T=Math.max(T,q.y+te)}const B=v-k,j=T-E,N=(S-_*2)/B,R=(C-_*2)/j,M=Math.min(N,R,t),w=(k+v)/2,D=(E+T)/2,F=S/2-w*M,z=C/2-D*M;d(F,z,M,!0)},[t,d]);return{transform:u,containerRef:a,zoomTo:d,zoomIn:h,zoomOut:p,resetZoom:g,fitToContent:m}}function Ed(r){const{transform:e,onDragStart:t,onDragMove:n,onDragEnd:s,disabled:i=!1}=r,[o,a]=y.useState(null),[l,u]=y.useState(!1),[c,d]=y.useState({x:0,y:0}),h=y.useRef(null),p=y.useRef({x:0,y:0}),g=y.useRef(e);y.useEffect(()=>{g.current=e},[e]);const m=y.useCallback((S,C)=>{const k=g.current;return{x:(S-k.x)/k.k,y:(C-k.y)/k.k}},[]),x=y.useCallback((S,C)=>{if(i)return;C.preventDefault(),C.stopPropagation();const k=C.currentTarget,E=parseFloat(k.dataset.x||"0"),v=parseFloat(k.dataset.y||"0");h.current={x:C.clientX,y:C.clientY,nodeX:E,nodeY:v},p.current={x:E,y:v},a(S),u(!0),d({x:0,y:0}),t==null||t(S)},[i,m,t]),_=y.useCallback(S=>{if(!l||!o||!h.current)return;const C=g.current,k=h.current,E=S.clientX-k.x,v=S.clientY-k.y,T=E/C.k,B=v/C.k,j=k.nodeX+T,N=k.nodeY+B;p.current={x:j,y:N},d({x:T,y:B}),n==null||n(o,j,N,T,B)},[l,o,n]),b=y.useCallback(()=>{if(!l||!o)return;const S=p.current;s==null||s(o,S.x,S.y),a(null),u(!1),d({x:0,y:0}),h.current=null},[l,o,s]);return y.useEffect(()=>{if(!l)return;const S=k=>{_(k)},C=()=>{b()};return window.addEventListener("mousemove",S),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",S),window.removeEventListener("mouseup",C)}},[l,_,b]),{draggedNodeId:o,isDragging:l,dragOffset:c,startDrag:x,updateDrag:_,endDrag:b}}function Dd(r){const{transform:e,nodePositions:t,disabled:n=!1,controlledSelectedIds:s,onSelectionChange:i}=r,[o,a]=y.useState(new Set),l=s!==void 0,u=l?new Set(s):o,c=l?j=>{const N=typeof j=="function"?j(u):j;i==null||i(Array.from(N))}:a,[d,h]=y.useState(null),[p,g]=y.useState(!1),m=y.useRef(null),x=y.useRef(e),_=y.useRef(t);y.useEffect(()=>{x.current=e},[e]),y.useEffect(()=>{_.current=t},[t]);const b=y.useCallback((j,N)=>{const R=x.current;return{x:(j-R.x)/R.k,y:(N-R.y)/R.k}},[]),S=y.useCallback((j,N)=>{const R=_.current.get(j);if(!R)return!1;const M=R.width||200,w=R.height||100;return R.x<N.x+N.width&&R.x+M>N.x&&R.y<N.y+N.height&&R.y+w>N.y},[]),C=y.useCallback(j=>{if(n||j.target.closest("[data-qmap-node]"))return;j.preventDefault();const R=b(j.clientX,j.clientY);m.current=R,h({x:R.x,y:R.y,width:0,height:0}),g(!0),j.shiftKey||c(new Set)},[n,b]),k=y.useCallback(j=>{if(!p||!m.current)return;const N=m.current,R=b(j.clientX,j.clientY),M={x:Math.min(N.x,R.x),y:Math.min(N.y,R.y),width:Math.abs(R.x-N.x),height:Math.abs(R.y-N.y)};h(M);const w=new Set;for(const[D]of _.current)S(D,M)&&w.add(D);c(w)},[p,b,S]),E=y.useCallback(()=>{p&&(i==null||i(Array.from(u)),g(!1),h(null),m.current=null)},[p,u,i]);y.useEffect(()=>{if(!p)return;const j=R=>{k(R)},N=()=>{E()};return window.addEventListener("mousemove",j),window.addEventListener("mouseup",N),()=>{window.removeEventListener("mousemove",j),window.removeEventListener("mouseup",N)}},[p,k,E]);const v=y.useCallback((j,N=!1)=>{c(R=>{const M=new Set(N?R:[]);return R.has(j)&&N?M.delete(j):M.add(j),i==null||i(Array.from(M)),M})},[i]),T=y.useCallback(()=>{const j=new Set(_.current.keys());c(j),i==null||i(Array.from(j))},[i]),B=y.useCallback(()=>{c(new Set),i==null||i([])},[i]);return{selectedIds:u,setSelectedIds:c,selectionBox:d,isSelecting:p,startSelection:C,updateSelection:k,endSelection:E,toggleSelect:v,selectAll:T,clearSelection:B}}const Ad=y.memo(function({nodeId:e,position:t,isSelected:n,isDragging:s,draggable:i,onDragStart:o,onClick:a,onDoubleClick:l,onContextMenu:u,nodeRef:c,children:d}){const h=y.useCallback(_=>{i&&_.button===0&&o(e,_)},[e,i,o]),p=y.useCallback(_=>{s||a==null||a(_)},[s,a]),g=y.useCallback(_=>{_.stopPropagation(),l==null||l(_)},[l]),m=y.useCallback(_=>{_.preventDefault(),_.stopPropagation(),u==null||u(_)},[u]),x=t.rotation||0;return f.jsx("div",{ref:c,"data-qmap-node":e,"data-x":t.x,"data-y":t.y,style:{position:"absolute",left:t.x,top:t.y,transform:x!==0?`rotate(${x}deg)`:void 0,transformOrigin:"center center",cursor:i?s?"grabbing":"grab":"pointer",userSelect:"none",opacity:s?.8:1,zIndex:s?1e3:n?100:1,WebkitUserSelect:"none",MozUserSelect:"none",msUserSelect:"none"},onMouseDown:h,onClick:p,onDoubleClick:g,onContextMenu:m,children:d})},(r,e)=>r.nodeId===e.nodeId&&r.position.x===e.position.x&&r.position.y===e.position.y&&r.position.rotation===e.position.rotation&&r.isSelected===e.isSelected&&r.isDragging===e.isDragging&&r.draggable===e.draggable&&r.children===e.children);function Td(r,e,t="bezier"){const n={x:r.x+(r.width||200)/2,y:r.y+(r.height||100)/2},s={x:e.x+(e.width||200)/2,y:e.y+(e.height||100)/2};switch(t){case"straight":return`M ${n.x} ${n.y} L ${s.x} ${s.y}`;case"orthogonal":return E2(n,s);case"bezier":default:return k2(n,s)}}function k2(r,e){const t=e.x-r.x,n=e.y-r.y,s=Math.sqrt(t*t+n*n),i=Math.min(s*.4,150),o=Math.abs(t)>Math.abs(n);let a,l,u,c;return o?(a=r.x+i*Math.sign(t),l=r.y,u=e.x-i*Math.sign(t),c=e.y):(a=r.x,l=r.y+i*Math.sign(n),u=e.x,c=e.y-i*Math.sign(n)),`M ${r.x} ${r.y} C ${a} ${l}, ${u} ${c}, ${e.x} ${e.y}`}function E2(r,e){const t=e.x-r.x,n=e.y-r.y;if(Math.abs(t)>Math.abs(n)){const i=r.x+t/2;return`M ${r.x} ${r.y} H ${i} V ${e.y} H ${e.x}`}else{const i=r.y+n/2;return`M ${r.x} ${r.y} V ${i} H ${e.x} V ${e.y}`}}function ga(r){const e=r.width||200,t=r.height||100;return{x:r.x+e/2,y:r.y+t/2}}function D2(r,e){const t=r.width||200,n=r.height||100,s=ga(r),i=e.x-s.x,o=e.y-s.y;if(i===0&&o===0)return s;const a=t/2,l=n/2,u=Math.abs(o/(i||.001)),c=l/a;let d,h;return u<c?(d=s.x+(i>0?a:-a),h=s.y+o*a/Math.abs(i)):(h=s.y+(o>0?l:-l),d=s.x+i*l/Math.abs(o)),{x:d,y:h}}function A2(r,e){const t=r.width||200,n=r.height||100;switch(e){case"left":return{x:r.x,y:r.y+n/2};case"right":return{x:r.x+t,y:r.y+n/2};case"top":return{x:r.x+t/2,y:r.y};case"bottom":return{x:r.x+t/2,y:r.y+n};case"center":default:return ga(r)}}function T2(r,e){return r.x>=e.x&&r.x<=e.x+e.width&&r.y>=e.y&&r.y<=e.y+e.height}function N2(r,e){return r.x<e.x+e.width&&r.x+r.width>e.x&&r.y<e.y+e.height&&r.y+r.height>e.y}function B2(r){if(r.length===0)return null;let e=1/0,t=1/0,n=-1/0,s=-1/0;for(const i of r){const o=i.width||200,a=i.height||100;e=Math.min(e,i.x),t=Math.min(t,i.y),n=Math.max(n,i.x+o),s=Math.max(s,i.y+a)}return{x:e,y:t,width:n-e,height:s-t}}function j2(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.sqrt(t*t+n*n)}function M2(r,e){const t=e.x-r.x,n=e.y-r.y;return t*t+n*n}const Nd=y.memo(function({edge:e,sourcePosition:t,targetPosition:n,style:s,color:i,width:o,onClick:a}){const[l,u]=y.useState(!1),c=y.useMemo(()=>Td(t,n,s),[t,n,s]),d=y.useCallback(x=>{x.stopPropagation(),a==null||a(e,x)},[e,a]),h=y.useCallback(()=>{u(!0)},[]),p=y.useCallback(()=>{u(!1)},[]),g=e.color||i,m=e.width||o;return f.jsxs("g",{children:[f.jsx("path",{d:c,fill:"none",stroke:"transparent",strokeWidth:Math.max(m*3,10),style:{cursor:a?"pointer":"default",pointerEvents:"stroke"},onClick:d,onMouseEnter:h,onMouseLeave:p}),f.jsx("path",{d:c,fill:"none",stroke:g,strokeWidth:l?m*1.5:m,strokeLinecap:"round",strokeLinejoin:"round",style:{pointerEvents:"none",transition:"stroke-width 0.15s ease"}}),e.label&&f.jsx(R2,{pathD:c,label:e.label,color:g})]})},(r,e)=>r.edge.id===e.edge.id&&r.sourcePosition.x===e.sourcePosition.x&&r.sourcePosition.y===e.sourcePosition.y&&r.sourcePosition.width===e.sourcePosition.width&&r.sourcePosition.height===e.sourcePosition.height&&r.targetPosition.x===e.targetPosition.x&&r.targetPosition.y===e.targetPosition.y&&r.targetPosition.width===e.targetPosition.width&&r.targetPosition.height===e.targetPosition.height&&r.style===e.style&&r.color===e.color&&r.width===e.width&&r.edge.label===e.edge.label&&r.edge.color===e.edge.color&&r.edge.width===e.edge.width);function R2({pathD:r,label:e,color:t}){const n=y.useMemo(()=>`edge-label-${Math.random().toString(36).substr(2,9)}`,[]);return f.jsxs(f.Fragment,{children:[f.jsx("defs",{children:f.jsx("path",{id:n,d:r})}),f.jsx("text",{fill:t,fontSize:"12",fontFamily:"system-ui, sans-serif",style:{pointerEvents:"none"},children:f.jsx("textPath",{href:`#${n}`,startOffset:"50%",textAnchor:"middle",children:e})})]})}const Bd=y.memo(function({edges:e,nodePositions:t,defaultStyle:n,defaultColor:s,defaultWidth:i,onEdgeClick:o}){const a=y.useMemo(()=>e.filter(l=>t.has(l.source)&&t.has(l.target)),[e,t]);return f.jsx("svg",{style:{position:"absolute",top:0,left:0,width:1,height:1,overflow:"visible",pointerEvents:"none"},children:f.jsx("g",{style:{pointerEvents:"auto"},children:a.map(l=>{const u=t.get(l.source),c=t.get(l.target);return f.jsx(Nd,{edge:l,sourcePosition:u,targetPosition:c,style:l.style||n,color:l.color||s,width:l.width||i,onClick:o},l.id)})})})},(r,e)=>!(r.edges!==e.edges||r.nodePositions!==e.nodePositions||r.defaultStyle!==e.defaultStyle||r.defaultColor!==e.defaultColor||r.defaultWidth!==e.defaultWidth)),jd=y.memo(function({box:e,transform:t}){const n=y.useMemo(()=>({x:e.x*t.k+t.x,y:e.y*t.k+t.y,width:e.width*t.k,height:e.height*t.k}),[e,t]);return f.jsx("div",{style:{position:"absolute",left:n.x,top:n.y,width:n.width,height:n.height,backgroundColor:"rgba(59, 130, 246, 0.1)",border:"1px solid rgba(59, 130, 246, 0.5)",borderRadius:2,pointerEvents:"none",zIndex:9999}})}),F2=200,L2=100,P2="bezier",I2="#94a3b8",z2=2,O2=.1,$2=4;function q2({viewNode:r,nodes:e,edges:t,renderNode:n,defaultNodeWidth:s=F2,defaultNodeHeight:i=L2,onNodeMove:o,onNodeDrag:a,onNodeClick:l,onNodeDoubleClick:u,onNodeContextMenu:c,selectedIds:d,onSelectionChange:h,onEdgeClick:p,onViewChange:g,onTransformChange:m,minZoom:x=O2,maxZoom:_=$2,initialTransform:b,defaultEdgeStyle:S=P2,defaultEdgeColor:C=I2,defaultEdgeWidth:k=z2,draggable:E=!0,selectable:v=!0,zoomable:T=!0,pannable:B=!0,className:j="",style:N,background:R="#f8fafc",showGrid:M=!1,gridSize:w=20}){const D=r.data||{positions:{}},F=D.positions||{},z=y.useMemo(()=>{const X=new Map;for(const Z of e){const ce=F[Z._id]||{x:0,y:0};X.set(Z._id,{x:ce.x,y:ce.y,width:ce.width||s,height:ce.height||i,rotation:ce.rotation||0})}return X},[e,F,s,i]),{transform:q,containerRef:J,zoomIn:te,zoomOut:W,resetZoom:G,fitToContent:H}=kd({minZoom:x,maxZoom:_,initialTransform:b||D.transform,zoomable:T,pannable:B,onTransformChange:X=>{m==null||m(X);const Z={...D,transform:X};g==null||g(Z)}}),[se,le]=y.useState(new Map),[ue,_e]=y.useState(new Map),fe=y.useRef(new Map);y.useEffect(()=>{const X=q.k||1,Z=new Map;fe.current.forEach((we,Be)=>{if(we){const Qe=we.getBoundingClientRect();Z.set(Be,{width:Math.round(Qe.width/X),height:Math.round(Qe.height/X)})}}),e.some(we=>{const Be=Z.get(we._id),Qe=ue.get(we._id);return Be?Qe?Be.width!==Qe.width||Be.height!==Qe.height:!0:!1})&&_e(Z)},[e,ue,q.k]);const{draggedNodeId:De,startDrag:O}=Ed({transform:q,disabled:!E,onDragStart:X=>{const Z=z.get(X);Z&&le(new Map([[X,{x:Z.x,y:Z.y}]]))},onDragMove:(X,Z,ce)=>{le(new Map([[X,{x:Z,y:ce}]])),a==null||a(X,Z,ce)},onDragEnd:(X,Z,ce)=>{le(new Map),o==null||o(X,Z,ce)}}),{selectedIds:Ce,selectionBox:re,isSelecting:Fe,startSelection:je,toggleSelect:ye,clearSelection:Se}=Dd({transform:q,nodePositions:z,disabled:!v,controlledSelectedIds:d,onSelectionChange:h}),Me=y.useCallback(X=>{const Z=z.get(X)||{x:0,y:0,width:s,height:i},ce=se.get(X),we=ue.get(X),Be=(we==null?void 0:we.width)||Z.width||s,Qe=(we==null?void 0:we.height)||Z.height||i;return ce?{...Z,x:ce.x,y:ce.y,width:Be,height:Qe}:{...Z,width:Be,height:Qe}},[z,se,ue,s,i]),Oe=y.useMemo(()=>{const X=new Map;for(const Z of z.keys())X.set(Z,Me(Z));return X},[z,Me]),ge=y.useCallback((X,Z)=>{ye(X._id,Z.shiftKey),l==null||l(X,Z)},[ye,l]),L=y.useCallback(X=>{X.target.closest("[data-qmap-node]")||Se()},[Se]),ze=y.useCallback(X=>{X.button===0&&(X.target.closest("[data-qmap-node]")||je(X))},[je]),Ke=M?`
186
186
  linear-gradient(to right, rgba(0,0,0,0.05) 1px, transparent 1px),
187
187
  linear-gradient(to bottom, rgba(0,0,0,0.05) 1px, transparent 1px)
188
- `:void 0;return f.jsxs("div",{ref:J,className:`qmap-container ${j}`,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",background:M,backgroundImage:Qe,backgroundSize:R?`${w}px ${w}px`:void 0,cursor:Re?"crosshair":B?"grab":"default",...N},onMouseDown:Me,onClick:L,children:[f.jsxs("div",{className:"qmap-canvas",style:{position:"absolute",transformOrigin:"0 0",transform:`translate(${U.x}px, ${U.y}px) scale(${U.k})`,willChange:"transform"},children:[f.jsx(Bd,{edges:t,nodePositions:ze,defaultStyle:C,defaultColor:S,defaultWidth:k,onEdgeClick:p}),e.map(G=>{const ee=Fe(G._id),me=ke.has(G._id),_e=Te===G._id;return f.jsx(Ad,{nodeId:G._id,position:ee,isSelected:me,isDragging:_e,draggable:E,onDragStart:$,onClick:Be=>ge(G,Be),onDoubleClick:Be=>u==null?void 0:u(G,Be),onContextMenu:Be=>c==null?void 0:c(G,Be),nodeRef:Be=>{Be?be.current.set(G._id,Be):be.current.delete(G._id)},children:n(G,me,ee)},G._id)})]}),se&&f.jsx(jd,{box:se,transform:U}),f.jsxs("div",{className:"qmap-controls",style:{position:"absolute",bottom:16,right:16,display:"flex",flexDirection:"column",gap:4,zIndex:100},children:[f.jsx("button",{onClick:te,style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:18,display:"flex",alignItems:"center",justifyContent:"center"},title:"Zoom in",children:"+"}),f.jsx("button",{onClick:W,style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:18,display:"flex",alignItems:"center",justifyContent:"center"},title:"Zoom out",children:"−"}),f.jsx("button",{onClick:V,style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:12,display:"flex",alignItems:"center",justifyContent:"center"},title:"Reset zoom",children:"1:1"}),f.jsx("button",{onClick:()=>H(Array.from(ze.values())),style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:12,display:"flex",alignItems:"center",justifyContent:"center"},title:"Fit to content",children:"⊡"})]})]})}exports.$createQRCodeNode=aa;exports.$isQRCodeNode=kg;exports.AnimatedCardFlip=kf;exports.ApiClient=au;exports.AudioEditor=Zc;exports.AuthFlow=fu;exports.AuthFlowModal=bf;exports.AuthManager=Ze;exports.AuthProvider=df;exports.AuthService=Ao;exports.Card=wf;exports.ComboBox=Fg;exports.ComboStack=Pg;exports.DataOperations=vs;exports.Detail=Cf;exports.ForgotPasswordForm=cu;exports.GraphClient=Id;exports.ImageEditor=Qg;exports.KanbanBoard=Ig;exports.LLMClient=sf;exports.LoginForm=No;exports.LoginModal=pf;exports.Mail=Df;exports.MailClient=iu;exports.MailComposer=Mg;exports.MailEditor=Gc;exports.NetflixCard=Qc;exports.NetflixDetail=Xc;exports.NetflixLane=Jc;exports.NetflixStack=Ug;exports.QMap=q2;exports.QMapEdgeComponent=Nd;exports.QMapEdgeLayer=Bd;exports.QMapNode=Ad;exports.QMapSelectionBox=jd;exports.QRCodeNode=un;exports.RegisterForm=uu;exports.ResetPasswordForm=du;exports.SelectableList=Af;exports.Stack=_f;exports.TTS_VOICES=ou;exports.Timeline=Kg;exports.VerifyCodeForm=Gi;exports.VoiceTextEditor=Yg;exports.calculateBoundingBox=B2;exports.calculateEdgePath=Td;exports.distance=j2;exports.distanceSquared=M2;exports.getApiClient=To;exports.getAuthService=af;exports.getConnectionPoint=D2;exports.getNodeCenter=ga;exports.getNodeSidePoint=A2;exports.initializeApiClient=lf;exports.initializeAuthService=of;exports.pointInRect=T2;exports.rectsIntersect=N2;exports.useAuth=ff;exports.useMutation=vf;exports.useNodeDrag=Ed;exports.useQuery=hu;exports.useSelection=Dd;exports.useZoomPan=kd;
188
+ `:void 0;return f.jsxs("div",{ref:J,className:`qmap-container ${j}`,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",background:R,backgroundImage:Ke,backgroundSize:M?`${w}px ${w}px`:void 0,cursor:Fe?"crosshair":B?"grab":"default",...N},onMouseDown:ze,onClick:L,children:[f.jsxs("div",{className:"qmap-canvas",style:{position:"absolute",transformOrigin:"0 0",transform:`translate(${q.x}px, ${q.y}px) scale(${q.k})`,willChange:"transform"},children:[f.jsx(Bd,{edges:t,nodePositions:Oe,defaultStyle:S,defaultColor:C,defaultWidth:k,onEdgeClick:p}),e.map(X=>{const Z=Me(X._id),ce=Ce.has(X._id),we=De===X._id;return f.jsx(Ad,{nodeId:X._id,position:Z,isSelected:ce,isDragging:we,draggable:E,onDragStart:O,onClick:Be=>ge(X,Be),onDoubleClick:Be=>u==null?void 0:u(X,Be),onContextMenu:Be=>c==null?void 0:c(X,Be),nodeRef:Be=>{Be?fe.current.set(X._id,Be):fe.current.delete(X._id)},children:n(X,ce,Z)},X._id)})]}),re&&f.jsx(jd,{box:re,transform:q}),f.jsxs("div",{className:"qmap-controls",style:{position:"absolute",bottom:16,right:16,display:"flex",flexDirection:"column",gap:4,zIndex:100},children:[f.jsx("button",{onClick:te,style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:18,display:"flex",alignItems:"center",justifyContent:"center"},title:"Zoom in",children:"+"}),f.jsx("button",{onClick:W,style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:18,display:"flex",alignItems:"center",justifyContent:"center"},title:"Zoom out",children:"−"}),f.jsx("button",{onClick:G,style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:12,display:"flex",alignItems:"center",justifyContent:"center"},title:"Reset zoom",children:"1:1"}),f.jsx("button",{onClick:()=>H(Array.from(Oe.values())),style:{width:32,height:32,border:"1px solid #e2e8f0",borderRadius:4,background:"white",cursor:"pointer",fontSize:12,display:"flex",alignItems:"center",justifyContent:"center"},title:"Fit to content",children:"⊡"})]})]})}exports.$createQRCodeNode=aa;exports.$isQRCodeNode=kg;exports.AnimatedCardFlip=kf;exports.ApiClient=au;exports.AudioEditor=Zc;exports.AuthFlow=fu;exports.AuthFlowModal=bf;exports.AuthManager=Je;exports.AuthProvider=df;exports.AuthService=Ao;exports.Card=wf;exports.ComboBox=Fg;exports.ComboStack=Pg;exports.DataOperations=vs;exports.Detail=Cf;exports.ForgotPasswordForm=cu;exports.GraphClient=Id;exports.ImageEditor=Qg;exports.KanbanBoard=Ig;exports.LLMClient=sf;exports.LoginForm=No;exports.LoginModal=pf;exports.Mail=Df;exports.MailClient=iu;exports.MailComposer=Mg;exports.MailEditor=Gc;exports.NetflixCard=Qc;exports.NetflixDetail=Xc;exports.NetflixLane=Jc;exports.NetflixStack=Ug;exports.QMap=q2;exports.QMapEdgeComponent=Nd;exports.QMapEdgeLayer=Bd;exports.QMapNode=Ad;exports.QMapSelectionBox=jd;exports.QRCodeNode=un;exports.RegisterForm=uu;exports.ResetPasswordForm=du;exports.SelectableList=Af;exports.Stack=_f;exports.TTS_VOICES=ou;exports.Timeline=Kg;exports.VerifyCodeForm=Gi;exports.VoiceTextEditor=Yg;exports.calculateBoundingBox=B2;exports.calculateEdgePath=Td;exports.distance=j2;exports.distanceSquared=M2;exports.getApiClient=To;exports.getAuthService=af;exports.getConnectionPoint=D2;exports.getNodeCenter=ga;exports.getNodeSidePoint=A2;exports.initializeApiClient=lf;exports.initializeAuthService=of;exports.pointInRect=T2;exports.rectsIntersect=N2;exports.useAuth=ff;exports.useMutation=vf;exports.useNodeDrag=Ed;exports.useQuery=hu;exports.useSelection=Dd;exports.useZoomPan=kd;