@qwanyx/stack 0.2.81 → 0.2.83

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
@@ -25,7 +25,7 @@ ${s}
25
25
  `&&(e=" "),(e.charCodeAt(0)>=33||[" "," "].includes(e))&&(this.node.value+=e),this.escaped=!1}}const Gd=50;function Dn(r,e){e=e||{};let t=e._depth||0;if(t>Gd)return[];let s=new Vd(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=Hd(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 Kd(r){for(var e="",t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",n=new Uint8Array(r),s=n.byteLength,i=s%3,o=s-i,l,a,u,c,d,f=0;f<o;f=f+3)d=n[f]<<16|n[f+1]<<8|n[f+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 Yd=256,Qd=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||Yd,maxHeadersSize:this.options.maxHeadersSize||Qd},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,f)=>{n.set(f,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,`
26
26
  `).replace(/\n*$/,`
27
27
  `);c.content=Jr.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(qd(u.value));break;case"plain":e[l].push(Ud(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=Jr.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=Kd(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 su{constructor(e){bt(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 f=a.map(p=>{var w,C,D,E,v;const g=d.get(p);if(!g)return null;const m=((w=g.flags)==null?void 0:w.some(k=>k.includes("Seen")))||!1,x=((D=(C=g.envelope)==null?void 0:C.from)==null?void 0:D.email)||"Unknown",_=((E=g.envelope)==null?void 0:E.subject)||"(No subject)",y=((v=g.envelope)==null?void 0:v.date)||"";return{uid:p,from:x,subject:_,date:y,seen:m}}).filter(Boolean);return{account:{id:e,label:"",email:""},mailbox:{name:t,total:i.exists||0},messages:f}}async getEmail(e,t,n="INBOX"){return this.callMail("get_email",{account_id:e,uid:t,folder:n})}async getAttachment(e,t,n,s="INBOX"){return this.callMail("get_attachment",{account_id:e,uid:t,attachment_index:n,folder:s})}async searchContactEmails(e,t,n=50){return this.callMail("search_contact_emails",{account_id:e,contact_email:t,limit:n})}async getEmailParsed(e,t,n="INBOX"){var g,m,x,_,y,w;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],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(C=>({filename:C.filename,mimeType:C.mimeType,contentId:C.contentId})));const c=new Map;for(const C of u.attachments||[])if(C.contentId){const D=this.contentToBase64(C.content),E=`data:${C.mimeType};base64,${D}`,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,D)=>{const E=c.get(D)||c.get(`<${D}>`);return E?`src="${E}"`:C}));const f=((_=o.flags)==null?void 0:_.some(C=>C.toLowerCase().includes("seen")))||!1,p=((y=u.from)==null?void 0:y.address)||((w=u.from)==null?void 0:w.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:f,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(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.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)}}}}class Xd{constructor(e){bt(this,"config");bt(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){var i;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 s=await this.callLLM("chat",n);return((i=s.result)==null?void 0:i.response)||s.result||""}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 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 vt{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){bt(this,"config");this.config=e}async register(e,t,n){var s,i;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:"register",params:{email:e,password:t,...n}})})).json();return l.success&&((s=l.result)!=null&&s.success)?{success:!0,userId:l.result.user_id,email:l.result.email,requiresVerification:l.result.requiresVerification}:{success:!1,error:((i=l.result)==null?void 0:i.message)||l.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 vt.setToken(u),vt.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 vt.setToken(c),vt.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){var n,s,i,o,l,a;try{const c=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}})})).json();if((n=c.result)!=null&&n.requiresVerification||c.requiresVerification)return{success:!1,error:((s=c.result)==null?void 0:s.error)||c.error||"Please verify your email first",requiresVerification:!0};if(c.success&&((i=c.result)!=null&&i.token)){const{token:d,user:f}=c.result;return vt.setToken(d),vt.setUser(f),(l=(o=this.config).onLogin)==null||l.call(o,f),{success:!0,user:f,token:d}}else return{success:!1,error:((a=c.result)==null?void 0:a.error)||c.error||"Login failed"}}catch(u){return{success:!1,error:u instanceof Error?u.message:"Network error"}}}async resendVerificationCode(e){return this.requestPasswordReset(e)}logout(){var e,t;vt.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",...vt.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 vt.getUser()}isAuthenticated(){return vt.isAuthenticated()}}let As=null;function Jd(r){return As=new Ao(r),As}function Zd(){if(!As)throw new Error("Auth service not initialized. Call initializeAuthService() first.");return As}class iu{constructor(e){bt(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,...vt.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),f=await fetch(l,{...u,signal:c.signal});if(clearTimeout(d),!f.ok){const p=await f.json().catch(()=>({message:f.statusText}));throw new Error(p.message||`HTTP ${f.status}`)}return await f.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 ef(r){return Ts=new iu(r),Ts}function To(){if(!Ts)throw new Error("API client not initialized. Call initializeApiClient() first.");return Ts}var Vi={exports:{}},cn={};/**
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=Jr.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=Kd(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 su{constructor(e){bt(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 f=a.map(p=>{var _,S,E,k,w;const g=d.get(p);if(!g)return null;const m=((_=g.flags)==null?void 0:_.some(D=>D.includes("Seen")))||!1,x=((E=(S=g.envelope)==null?void 0:S.from)==null?void 0:E.email)||"Unknown",v=((k=g.envelope)==null?void 0:k.subject)||"(No subject)",y=((w=g.envelope)==null?void 0:w.date)||"";return{uid:p,from:x,subject:v,date:y,seen:m}}).filter(Boolean);return{account:{id:e,label:"",email:""},mailbox:{name:t,total:i.exists||0},messages:f}}async getEmail(e,t,n="INBOX"){return this.callMail("get_email",{account_id:e,uid:t,folder:n})}async getAttachment(e,t,n,s="INBOX"){return this.callMail("get_attachment",{account_id:e,uid:t,attachment_index:n,folder:s})}async searchContactEmails(e,t,n=50){return this.callMail("search_contact_emails",{account_id:e,contact_email:t,limit:n})}async getEmailParsed(e,t,n="INBOX"){var g,m,x,v,y,_;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 E=this.contentToBase64(S.content),k=`data:${S.mimeType};base64,${E}`,w=S.contentId.replace(/^<|>$/g,"");c.set(w,k),c.set(`<${w}>`,k)}let d=u.html||"";d&&c.size>0&&(d=d.replace(/src=["']cid:([^"']+)["']/gi,(S,E)=>{const k=c.get(E)||c.get(`<${E}>`);return k?`src="${k}"`:S}));const f=((v=o.flags)==null?void 0:v.some(S=>S.toLowerCase().includes("seen")))||!1,p=((y=u.from)==null?void 0:y.address)||((_=u.from)==null?void 0:_.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:f,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.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)}}}}class Xd{constructor(e){bt(this,"config");bt(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){var i;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 s=await this.callLLM("chat",n);return((i=s.result)==null?void 0:i.response)||s.result||""}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 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 vt{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){bt(this,"config");this.config=e}async register(e,t,n){var s,i;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:"register",params:{email:e,password:t,...n}})})).json();return l.success&&((s=l.result)!=null&&s.success)?{success:!0,userId:l.result.user_id,email:l.result.email,requiresVerification:l.result.requiresVerification}:{success:!1,error:((i=l.result)==null?void 0:i.message)||l.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 vt.setToken(u),vt.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 vt.setToken(c),vt.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){var n,s,i,o,l,a;try{const c=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}})})).json();if((n=c.result)!=null&&n.requiresVerification||c.requiresVerification)return{success:!1,error:((s=c.result)==null?void 0:s.error)||c.error||"Please verify your email first",requiresVerification:!0};if(c.success&&((i=c.result)!=null&&i.token)){const{token:d,user:f}=c.result;return vt.setToken(d),vt.setUser(f),(l=(o=this.config).onLogin)==null||l.call(o,f),{success:!0,user:f,token:d}}else return{success:!1,error:((a=c.result)==null?void 0:a.error)||c.error||"Login failed"}}catch(u){return{success:!1,error:u instanceof Error?u.message:"Network error"}}}async resendVerificationCode(e){return this.requestPasswordReset(e)}logout(){var e,t;vt.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",...vt.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 vt.getUser()}isAuthenticated(){return vt.isAuthenticated()}}let As=null;function Jd(r){return As=new Ao(r),As}function Zd(){if(!As)throw new Error("Auth service not initialized. Call initializeAuthService() first.");return As}class iu{constructor(e){bt(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,...vt.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),f=await fetch(l,{...u,signal:c.signal});if(clearTimeout(d),!f.ok){const p=await f.json().catch(()=>({message:f.statusText}));throw new Error(p.message||`HTTP ${f.status}`)}return await f.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 ef(r){return Ts=new iu(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
  *
@@ -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 rf(){return ka||(ka=1,process.env.NODE_ENV!=="production"&&function(){var r=b,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"),f=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 $=g&&A[g]||A[m];return typeof $=="function"?$:null}var _=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y(A){{for(var $=arguments.length,ee=new Array($>1?$-1:0),he=1;he<$;he++)ee[he-1]=arguments[he];w("error",A,ee)}}function w(A,$,ee){{var he=_.ReactDebugCurrentFrame,Re=he.getStackAddendum();Re!==""&&($+="%s",ee=ee.concat([Re]));var Pe=ee.map(function(Te){return String(Te)});Pe.unshift("Warning: "+$),Function.prototype.apply.call(console[A],console,Pe)}}var C=!1,D=!1,E=!1,v=!1,k=!1,M;M=Symbol.for("react.module.reference");function T(A){return!!(typeof A=="string"||typeof A=="function"||A===n||A===i||k||A===s||A===u||A===c||v||A===p||C||D||E||typeof A=="object"&&A!==null&&(A.$$typeof===f||A.$$typeof===d||A.$$typeof===o||A.$$typeof===l||A.$$typeof===a||A.$$typeof===M||A.getModuleId!==void 0))}function N(A,$,ee){var he=A.displayName;if(he)return he;var Re=$.displayName||$.name||"";return Re!==""?ee+"("+Re+")":ee}function R(A){return A.displayName||"Context"}function j(A){if(A==null)return null;if(typeof A.tag=="number"&&y("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 $=A;return R($)+".Consumer";case o:var ee=A;return R(ee._context)+".Provider";case a:return N(A,A.render,"ForwardRef");case d:var he=A.displayName||null;return he!==null?he:j(A.type)||"Memo";case f:{var Re=A,Pe=Re._payload,Te=Re._init;try{return j(Te(Pe))}catch{return null}}}return null}var S=Object.assign,B=0,F,O,V,U,te,q,X;function W(){}W.__reactDisabledLog=!0;function se(){{if(B===0){F=console.log,O=console.info,V=console.warn,U=console.error,te=console.group,q=console.groupCollapsed,X=console.groupEnd;var A={configurable:!0,enumerable:!0,value:W,writable:!0};Object.defineProperties(console,{info:A,log:A,warn:A,error:A,group:A,groupCollapsed:A,groupEnd:A})}B++}}function ue(){{if(B--,B===0){var A={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:S({},A,{value:F}),info:S({},A,{value:O}),warn:S({},A,{value:V}),error:S({},A,{value:U}),group:S({},A,{value:te}),groupCollapsed:S({},A,{value:q}),groupEnd:S({},A,{value:X})})}B<0&&y("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var de=_.ReactCurrentDispatcher,pe;function De(A,$,ee){{if(pe===void 0)try{throw Error()}catch(Re){var he=Re.stack.trim().match(/\n( *(at )?)/);pe=he&&he[1]||""}return`
45
- `+pe+A}}var xe=!1,J;{var Ce=typeof WeakMap=="function"?WeakMap:Map;J=new Ce}function ne(A,$){if(!A||xe)return"";{var ee=J.get(A);if(ee!==void 0)return ee}var he;xe=!0;var Re=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Pe;Pe=de.current,de.current=null,se();try{if($){var Te=function(){throw Error()};if(Object.defineProperty(Te.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Te,[])}catch(xt){he=xt}Reflect.construct(A,[],Te)}else{try{Te.call()}catch(xt){he=xt}A.call(Te.prototype)}}else{try{throw Error()}catch(xt){he=xt}A()}}catch(xt){if(xt&&he&&typeof xt.stack=="string"){for(var Ne=xt.stack.split(`
44
+ */var ka;function rf(){return ka||(ka=1,process.env.NODE_ENV!=="production"&&function(){var r=b,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"),f=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 v=r.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED;function y(A){{for(var q=arguments.length,ee=new Array(q>1?q-1:0),he=1;he<q;he++)ee[he-1]=arguments[he];_("error",A,ee)}}function _(A,q,ee){{var he=v.ReactDebugCurrentFrame,Re=he.getStackAddendum();Re!==""&&(q+="%s",ee=ee.concat([Re]));var Pe=ee.map(function(Te){return String(Te)});Pe.unshift("Warning: "+q),Function.prototype.apply.call(console[A],console,Pe)}}var S=!1,E=!1,k=!1,w=!1,D=!1,j;j=Symbol.for("react.module.reference");function B(A){return!!(typeof A=="string"||typeof A=="function"||A===n||A===i||D||A===s||A===u||A===c||w||A===p||S||E||k||typeof A=="object"&&A!==null&&(A.$$typeof===f||A.$$typeof===d||A.$$typeof===o||A.$$typeof===l||A.$$typeof===a||A.$$typeof===j||A.getModuleId!==void 0))}function T(A,q,ee){var he=A.displayName;if(he)return he;var Re=q.displayName||q.name||"";return Re!==""?ee+"("+Re+")":ee}function R(A){return A.displayName||"Context"}function M(A){if(A==null)return null;if(typeof A.tag=="number"&&y("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 R(q)+".Consumer";case o:var ee=A;return R(ee._context)+".Provider";case a:return T(A,A.render,"ForwardRef");case d:var he=A.displayName||null;return he!==null?he:M(A.type)||"Memo";case f:{var Re=A,Pe=Re._payload,Te=Re._init;try{return M(Te(Pe))}catch{return null}}}return null}var C=Object.assign,N=0,F,I,W,z,te,U,Q;function H(){}H.__reactDisabledLog=!0;function se(){{if(N===0){F=console.log,I=console.info,W=console.warn,z=console.error,te=console.group,U=console.groupCollapsed,Q=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})}N++}}function ue(){{if(N--,N===0){var A={configurable:!0,enumerable:!0,writable:!0};Object.defineProperties(console,{log:C({},A,{value:F}),info:C({},A,{value:I}),warn:C({},A,{value:W}),error:C({},A,{value:z}),group:C({},A,{value:te}),groupCollapsed:C({},A,{value:U}),groupEnd:C({},A,{value:Q})})}N<0&&y("disabledDepth fell below zero. This is a bug in React. Please file an issue.")}}var de=v.ReactCurrentDispatcher,pe;function De(A,q,ee){{if(pe===void 0)try{throw Error()}catch(Re){var he=Re.stack.trim().match(/\n( *(at )?)/);pe=he&&he[1]||""}return`
45
+ `+pe+A}}var xe=!1,J;{var Ce=typeof WeakMap=="function"?WeakMap:Map;J=new Ce}function ne(A,q){if(!A||xe)return"";{var ee=J.get(A);if(ee!==void 0)return ee}var he;xe=!0;var Re=Error.prepareStackTrace;Error.prepareStackTrace=void 0;var Pe;Pe=de.current,de.current=null,se();try{if(q){var Te=function(){throw Error()};if(Object.defineProperty(Te.prototype,"props",{set:function(){throw Error()}}),typeof Reflect=="object"&&Reflect.construct){try{Reflect.construct(Te,[])}catch(xt){he=xt}Reflect.construct(A,[],Te)}else{try{Te.call()}catch(xt){he=xt}A.call(Te.prototype)}}else{try{throw Error()}catch(xt){he=xt}A()}}catch(xt){if(xt&&he&&typeof xt.stack=="string"){for(var Ne=xt.stack.split(`
46
46
  `),ft=he.stack.split(`
47
47
  `),Ze=Ne.length-1,tt=ft.length-1;Ze>=1&&tt>=0&&Ne[Ze]!==ft[tt];)tt--;for(;Ze>=1&&tt>=0;Ze--,tt--)if(Ne[Ze]!==ft[tt]){if(Ze!==1||tt!==1)do if(Ze--,tt--,tt<0||Ne[Ze]!==ft[tt]){var Tt=`
48
- `+Ne[Ze].replace(" at new "," at ");return A.displayName&&Tt.includes("<anonymous>")&&(Tt=Tt.replace("<anonymous>",A.displayName)),typeof A=="function"&&J.set(A,Tt),Tt}while(Ze>=1&&tt>=0);break}}}finally{xe=!1,de.current=Pe,ue(),Error.prepareStackTrace=Re}var zr=A?A.displayName||A.name:"",vr=zr?De(zr):"";return typeof A=="function"&&J.set(A,vr),vr}function Be(A,$,ee){return ne(A,!1)}function Se(A){var $=A.prototype;return!!($&&$.isReactComponent)}function ke(A,$,ee){if(A==null)return"";if(typeof A=="function")return ne(A,Se(A));if(typeof A=="string")return De(A);switch(A){case u:return De("Suspense");case c:return De("SuspenseList")}if(typeof A=="object")switch(A.$$typeof){case a:return Be(A.render);case d:return ke(A.type,$,ee);case f:{var he=A,Re=he._payload,Pe=he._init;try{return ke(Pe(Re),$,ee)}catch{}}}return""}var Ie=Object.prototype.hasOwnProperty,Le={},$e=_.ReactDebugCurrentFrame;function Y(A){if(A){var $=A._owner,ee=ke(A.type,A._source,$?$.type:null);$e.setExtraStackFrame(ee)}else $e.setExtraStackFrame(null)}function P(A,$,ee,he,Re){{var Pe=Function.call.bind(Ie);for(var Te in A)if(Pe(A,Te)){var Ne=void 0;try{if(typeof A[Te]!="function"){var ft=Error((he||"React class")+": "+ee+" type `"+Te+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof A[Te]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ft.name="Invariant Violation",ft}Ne=A[Te]($,Te,he,ee,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Ze){Ne=Ze}Ne&&!(Ne instanceof Error)&&(Y(Re),y("%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).",he||"React class",ee,Te,typeof Ne),Y(null)),Ne instanceof Error&&!(Ne.message in Le)&&(Le[Ne.message]=!0,Y(Re),y("Failed %s type: %s",ee,Ne.message),Y(null))}}}var me=Array.isArray;function We(A){return me(A)}function z(A){{var $=typeof Symbol=="function"&&Symbol.toStringTag,ee=$&&A[Symbol.toStringTag]||A.constructor.name||"Object";return ee}}function ae(A){try{return ge(A),!1}catch{return!0}}function ge(A){return""+A}function ye(A){if(ae(A))return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",z(A)),ge(A)}var Ue=_.ReactCurrentOwner,mt={key:!0,ref:!0,__self:!0,__source:!0},yt,ie;function ce(A){if(Ie.call(A,"ref")){var $=Object.getOwnPropertyDescriptor(A,"ref").get;if($&&$.isReactWarning)return!1}return A.ref!==void 0}function He(A){if(Ie.call(A,"key")){var $=Object.getOwnPropertyDescriptor(A,"key").get;if($&&$.isReactWarning)return!1}return A.key!==void 0}function Xe(A,$){typeof A.ref=="string"&&Ue.current}function Je(A,$){{var ee=function(){yt||(yt=!0,y("%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)",$))};ee.isReactWarning=!0,Object.defineProperty(A,"key",{get:ee,configurable:!0})}}function Bt(A,$){{var ee=function(){ie||(ie=!0,y("%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)",$))};ee.isReactWarning=!0,Object.defineProperty(A,"ref",{get:ee,configurable:!0})}}var Z=function(A,$,ee,he,Re,Pe,Te){var Ne={$$typeof:e,type:A,key:$,ref:ee,props:Te,_owner:Pe};return Ne._store={},Object.defineProperty(Ne._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Ne,"_self",{configurable:!1,enumerable:!1,writable:!1,value:he}),Object.defineProperty(Ne,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Re}),Object.freeze&&(Object.freeze(Ne.props),Object.freeze(Ne)),Ne};function L(A,$,ee,he,Re){{var Pe,Te={},Ne=null,ft=null;ee!==void 0&&(ye(ee),Ne=""+ee),He($)&&(ye($.key),Ne=""+$.key),ce($)&&(ft=$.ref,Xe($,Re));for(Pe in $)Ie.call($,Pe)&&!mt.hasOwnProperty(Pe)&&(Te[Pe]=$[Pe]);if(A&&A.defaultProps){var Ze=A.defaultProps;for(Pe in Ze)Te[Pe]===void 0&&(Te[Pe]=Ze[Pe])}if(Ne||ft){var tt=typeof A=="function"?A.displayName||A.name||"Unknown":A;Ne&&Je(Te,tt),ft&&Bt(Te,tt)}return Z(A,Ne,ft,Re,he,Ue.current,Te)}}var le=_.ReactCurrentOwner,fe=_.ReactDebugCurrentFrame;function G(A){if(A){var $=A._owner,ee=ke(A.type,A._source,$?$.type:null);fe.setExtraStackFrame(ee)}else fe.setExtraStackFrame(null)}var we;we=!1;function be(A){return typeof A=="object"&&A!==null&&A.$$typeof===e}function ve(){{if(le.current){var A=j(le.current.type);if(A)return`
48
+ `+Ne[Ze].replace(" at new "," at ");return A.displayName&&Tt.includes("<anonymous>")&&(Tt=Tt.replace("<anonymous>",A.displayName)),typeof A=="function"&&J.set(A,Tt),Tt}while(Ze>=1&&tt>=0);break}}}finally{xe=!1,de.current=Pe,ue(),Error.prepareStackTrace=Re}var zr=A?A.displayName||A.name:"",vr=zr?De(zr):"";return typeof A=="function"&&J.set(A,vr),vr}function Be(A,q,ee){return ne(A,!1)}function Se(A){var q=A.prototype;return!!(q&&q.isReactComponent)}function ke(A,q,ee){if(A==null)return"";if(typeof A=="function")return ne(A,Se(A));if(typeof A=="string")return De(A);switch(A){case u:return De("Suspense");case c:return De("SuspenseList")}if(typeof A=="object")switch(A.$$typeof){case a:return Be(A.render);case d:return ke(A.type,q,ee);case f:{var he=A,Re=he._payload,Pe=he._init;try{return ke(Pe(Re),q,ee)}catch{}}}return""}var Ie=Object.prototype.hasOwnProperty,Le={},$e=v.ReactDebugCurrentFrame;function Y(A){if(A){var q=A._owner,ee=ke(A.type,A._source,q?q.type:null);$e.setExtraStackFrame(ee)}else $e.setExtraStackFrame(null)}function P(A,q,ee,he,Re){{var Pe=Function.call.bind(Ie);for(var Te in A)if(Pe(A,Te)){var Ne=void 0;try{if(typeof A[Te]!="function"){var ft=Error((he||"React class")+": "+ee+" type `"+Te+"` is invalid; it must be a function, usually from the `prop-types` package, but received `"+typeof A[Te]+"`.This often happens because of typos such as `PropTypes.function` instead of `PropTypes.func`.");throw ft.name="Invariant Violation",ft}Ne=A[Te](q,Te,he,ee,null,"SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED")}catch(Ze){Ne=Ze}Ne&&!(Ne instanceof Error)&&(Y(Re),y("%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).",he||"React class",ee,Te,typeof Ne),Y(null)),Ne instanceof Error&&!(Ne.message in Le)&&(Le[Ne.message]=!0,Y(Re),y("Failed %s type: %s",ee,Ne.message),Y(null))}}}var me=Array.isArray;function We(A){return me(A)}function $(A){{var q=typeof Symbol=="function"&&Symbol.toStringTag,ee=q&&A[Symbol.toStringTag]||A.constructor.name||"Object";return ee}}function ae(A){try{return ge(A),!1}catch{return!0}}function ge(A){return""+A}function ye(A){if(ae(A))return y("The provided key is an unsupported type %s. This value must be coerced to a string before before using it here.",$(A)),ge(A)}var Ue=v.ReactCurrentOwner,mt={key:!0,ref:!0,__self:!0,__source:!0},yt,ie;function ce(A){if(Ie.call(A,"ref")){var q=Object.getOwnPropertyDescriptor(A,"ref").get;if(q&&q.isReactWarning)return!1}return A.ref!==void 0}function He(A){if(Ie.call(A,"key")){var q=Object.getOwnPropertyDescriptor(A,"key").get;if(q&&q.isReactWarning)return!1}return A.key!==void 0}function Xe(A,q){typeof A.ref=="string"&&Ue.current}function Je(A,q){{var ee=function(){yt||(yt=!0,y("%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))};ee.isReactWarning=!0,Object.defineProperty(A,"key",{get:ee,configurable:!0})}}function Bt(A,q){{var ee=function(){ie||(ie=!0,y("%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))};ee.isReactWarning=!0,Object.defineProperty(A,"ref",{get:ee,configurable:!0})}}var Z=function(A,q,ee,he,Re,Pe,Te){var Ne={$$typeof:e,type:A,key:q,ref:ee,props:Te,_owner:Pe};return Ne._store={},Object.defineProperty(Ne._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:!1}),Object.defineProperty(Ne,"_self",{configurable:!1,enumerable:!1,writable:!1,value:he}),Object.defineProperty(Ne,"_source",{configurable:!1,enumerable:!1,writable:!1,value:Re}),Object.freeze&&(Object.freeze(Ne.props),Object.freeze(Ne)),Ne};function L(A,q,ee,he,Re){{var Pe,Te={},Ne=null,ft=null;ee!==void 0&&(ye(ee),Ne=""+ee),He(q)&&(ye(q.key),Ne=""+q.key),ce(q)&&(ft=q.ref,Xe(q,Re));for(Pe in q)Ie.call(q,Pe)&&!mt.hasOwnProperty(Pe)&&(Te[Pe]=q[Pe]);if(A&&A.defaultProps){var Ze=A.defaultProps;for(Pe in Ze)Te[Pe]===void 0&&(Te[Pe]=Ze[Pe])}if(Ne||ft){var tt=typeof A=="function"?A.displayName||A.name||"Unknown":A;Ne&&Je(Te,tt),ft&&Bt(Te,tt)}return Z(A,Ne,ft,Re,he,Ue.current,Te)}}var le=v.ReactCurrentOwner,fe=v.ReactDebugCurrentFrame;function G(A){if(A){var q=A._owner,ee=ke(A.type,A._source,q?q.type:null);fe.setExtraStackFrame(ee)}else fe.setExtraStackFrame(null)}var we;we=!1;function be(A){return typeof A=="object"&&A!==null&&A.$$typeof===e}function ve(){{if(le.current){var A=M(le.current.type);if(A)return`
49
49
 
50
- Check the render method of \``+A+"`."}return""}}function Fe(A){return""}var qe={};function _e(A){{var $=ve();if(!$){var ee=typeof A=="string"?A:A.displayName||A.name;ee&&($=`
50
+ Check the render method of \``+A+"`."}return""}}function Fe(A){return""}var qe={};function _e(A){{var q=ve();if(!q){var ee=typeof A=="string"?A:A.displayName||A.name;ee&&(q=`
51
51
 
52
- Check the top-level render call using <`+ee+">.")}return $}}function Ee(A,$){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var ee=_e($);if(qe[ee])return;qe[ee]=!0;var he="";A&&A._owner&&A._owner!==le.current&&(he=" It was passed a child from "+j(A._owner.type)+"."),G(A),y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',ee,he),G(null)}}function et(A,$){{if(typeof A!="object")return;if(We(A))for(var ee=0;ee<A.length;ee++){var he=A[ee];be(he)&&Ee(he,$)}else if(be(A))A._store&&(A._store.validated=!0);else if(A){var Re=x(A);if(typeof Re=="function"&&Re!==A.entries)for(var Pe=Re.call(A),Te;!(Te=Pe.next()).done;)be(Te.value)&&Ee(Te.value,$)}}}function nt(A){{var $=A.type;if($==null||typeof $=="string")return;var ee;if(typeof $=="function")ee=$.propTypes;else if(typeof $=="object"&&($.$$typeof===a||$.$$typeof===d))ee=$.propTypes;else return;if(ee){var he=j($);P(ee,A.props,"prop",he,A)}else if($.PropTypes!==void 0&&!we){we=!0;var Re=j($);y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Re||"Unknown")}typeof $.getDefaultProps=="function"&&!$.getDefaultProps.isReactClassApproved&&y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ve(A){{for(var $=Object.keys(A.props),ee=0;ee<$.length;ee++){var he=$[ee];if(he!=="children"&&he!=="key"){G(A),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",he),G(null);break}}A.ref!==null&&(G(A),y("Invalid attribute `ref` supplied to `React.Fragment`."),G(null))}}var Oe={};function ut(A,$,ee,he,Re,Pe){{var Te=T(A);if(!Te){var Ne="";(A===void 0||typeof A=="object"&&A!==null&&Object.keys(A).length===0)&&(Ne+=" 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 ft=Fe();ft?Ne+=ft:Ne+=ve();var Ze;A===null?Ze="null":We(A)?Ze="array":A!==void 0&&A.$$typeof===e?(Ze="<"+(j(A.type)||"Unknown")+" />",Ne=" Did you accidentally export a JSX literal instead of a component?"):Ze=typeof A,y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Ze,Ne)}var tt=L(A,$,ee,Re,Pe);if(tt==null)return tt;if(Te){var Tt=$.children;if(Tt!==void 0)if(he)if(We(Tt)){for(var zr=0;zr<Tt.length;zr++)et(Tt[zr],A);Object.freeze&&Object.freeze(Tt)}else y("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 et(Tt,A)}if(Ie.call($,"key")){var vr=j(A),xt=Object.keys($).filter(function(Dd){return Dd!=="key"}),Si=xt.length>0?"{key: someKey, "+xt.join(": ..., ")+": ...}":"{key: someKey}";if(!Oe[vr+Si]){var Ed=xt.length>0?"{"+xt.join(": ..., ")+": ...}":"{}";y(`A props object containing a "key" prop is being spread into JSX:
52
+ Check the top-level render call using <`+ee+">.")}return q}}function Ee(A,q){{if(!A._store||A._store.validated||A.key!=null)return;A._store.validated=!0;var ee=_e(q);if(qe[ee])return;qe[ee]=!0;var he="";A&&A._owner&&A._owner!==le.current&&(he=" It was passed a child from "+M(A._owner.type)+"."),G(A),y('Each child in a list should have a unique "key" prop.%s%s See https://reactjs.org/link/warning-keys for more information.',ee,he),G(null)}}function et(A,q){{if(typeof A!="object")return;if(We(A))for(var ee=0;ee<A.length;ee++){var he=A[ee];be(he)&&Ee(he,q)}else if(be(A))A._store&&(A._store.validated=!0);else if(A){var Re=x(A);if(typeof Re=="function"&&Re!==A.entries)for(var Pe=Re.call(A),Te;!(Te=Pe.next()).done;)be(Te.value)&&Ee(Te.value,q)}}}function nt(A){{var q=A.type;if(q==null||typeof q=="string")return;var ee;if(typeof q=="function")ee=q.propTypes;else if(typeof q=="object"&&(q.$$typeof===a||q.$$typeof===d))ee=q.propTypes;else return;if(ee){var he=M(q);P(ee,A.props,"prop",he,A)}else if(q.PropTypes!==void 0&&!we){we=!0;var Re=M(q);y("Component %s declared `PropTypes` instead of `propTypes`. Did you misspell the property assignment?",Re||"Unknown")}typeof q.getDefaultProps=="function"&&!q.getDefaultProps.isReactClassApproved&&y("getDefaultProps is only used on classic React.createClass definitions. Use a static property named `defaultProps` instead.")}}function Ve(A){{for(var q=Object.keys(A.props),ee=0;ee<q.length;ee++){var he=q[ee];if(he!=="children"&&he!=="key"){G(A),y("Invalid prop `%s` supplied to `React.Fragment`. React.Fragment can only have `key` and `children` props.",he),G(null);break}}A.ref!==null&&(G(A),y("Invalid attribute `ref` supplied to `React.Fragment`."),G(null))}}var Oe={};function ut(A,q,ee,he,Re,Pe){{var Te=B(A);if(!Te){var Ne="";(A===void 0||typeof A=="object"&&A!==null&&Object.keys(A).length===0)&&(Ne+=" 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 ft=Fe();ft?Ne+=ft:Ne+=ve();var Ze;A===null?Ze="null":We(A)?Ze="array":A!==void 0&&A.$$typeof===e?(Ze="<"+(M(A.type)||"Unknown")+" />",Ne=" Did you accidentally export a JSX literal instead of a component?"):Ze=typeof A,y("React.jsx: type is invalid -- expected a string (for built-in components) or a class/function (for composite components) but got: %s.%s",Ze,Ne)}var tt=L(A,q,ee,Re,Pe);if(tt==null)return tt;if(Te){var Tt=q.children;if(Tt!==void 0)if(he)if(We(Tt)){for(var zr=0;zr<Tt.length;zr++)et(Tt[zr],A);Object.freeze&&Object.freeze(Tt)}else y("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 et(Tt,A)}if(Ie.call(q,"key")){var vr=M(A),xt=Object.keys(q).filter(function(Dd){return Dd!=="key"}),Si=xt.length>0?"{key: someKey, "+xt.join(": ..., ")+": ...}":"{key: someKey}";if(!Oe[vr+Si]){var Ed=xt.length>0?"{"+xt.join(": ..., ")+": ...}":"{}";y(`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,Ed,vr),Oe[vr+Si]=!0}}return A===n?Ve(tt):nt(tt),tt}}function ct(A,$,ee){return ut(A,$,ee,!0)}function At(A,$,ee){return ut(A,$,ee,!1)}var Zt=At,Rt=ct;dn.Fragment=n,dn.jsx=Zt,dn.jsxs=Rt}()),dn}process.env.NODE_ENV==="production"?Vi.exports=tf():Vi.exports=rf();var h=Vi.exports;const ou=b.createContext(void 0);function nf({apiUrl:r,systemId:e,children:t}){const[n,s]=b.useState(null),[i,o]=b.useState(null),[l,a]=b.useState(!1),[u,c]=b.useState(!0),[d]=b.useState(()=>new Ao({apiUrl:r,systemId:e})),f=b.useCallback(async D=>{const E=await d.isAdmin(D);a(E)},[d]),p=b.useCallback(()=>{const D=vt.getToken(),E=vt.getUser();D&&E?(o(D),s(E),f(E._id).finally(()=>c(!1))):c(!1)},[f]);b.useEffect(()=>{p()},[p]);const g=b.useCallback(async(D,E)=>{const v=await d.login(D,E);return v.success&&v.user&&v.token&&(o(v.token),s(v.user),await f(v.user._id)),v},[d,f]),m=b.useCallback(async(D,E,v)=>d.register(D,E,v),[d]),x=b.useCallback(async(D,E)=>{const v=await d.verifyEmail(D,E);return v.success&&v.user&&v.token&&(o(v.token),s(v.user),await f(v.user._id)),v},[d,f]),_=b.useCallback(async D=>d.requestPasswordReset(D),[d]),y=b.useCallback(async(D,E,v)=>{const k=await d.setPasswordWithCode(D,E,v);return k.success&&k.user&&k.token&&(o(k.token),s(k.user),await f(k.user._id)),k},[d,f]),w=b.useCallback(async D=>d.resendVerificationCode(D),[d]),C=b.useCallback(()=>{d.logout(),s(null),o(null),a(!1)},[d]);return h.jsx(ou.Provider,{value:{user:n,token:i,isAdmin:l,loading:u,login:g,register:m,verifyEmail:x,requestPasswordReset:_,setPasswordWithCode:y,resendVerificationCode:w,logout:C,refreshUser:p},children:t})}function sf(){const r=b.useContext(ou);if(r===void 0)throw new Error("useAuth must be used within an AuthProvider");return r}const of={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",theme:a,className:u="",isModal:c=!1}){const[d,f]=b.useState(""),[p,g]=b.useState(""),[m,x]=b.useState(""),[_,y]=b.useState(!1),w={...of,...a};async function C(T){T.preventDefault(),y(!0),x("");const N=await r(d,p);N.success?e==null||e():x(N.error||"Connexion impossible"),y(!1)}const D={backgroundColor:w.backgroundColor,borderRadius:w.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...c&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},E={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${w.borderColor}`,borderRadius:w.borderRadius,backgroundColor:w.inputBackground,color:w.textColor,fontSize:"1rem",outline:"none"},v={display:"block",fontSize:"0.875rem",fontWeight:500,color:w.textMutedColor,marginBottom:"0.25rem"},k={width:"100%",padding:"0.75rem",backgroundColor:_?w.textMutedColor:w.primaryColor,color:"#ffffff",border:"none",borderRadius:w.borderRadius,fontSize:"1rem",fontWeight:500,cursor:_?"not-allowed":"pointer",transition:"background-color 0.2s"},M={padding:"0.75rem",backgroundColor:w.errorBackgroundColor,border:`1px solid ${w.errorColor}20`,borderRadius:w.borderRadius,marginBottom:"1rem"};return h.jsxs("div",{style:D,className:u,children:[t&&h.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"1.5rem"},children:t}),h.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:w.textColor,marginBottom:"1rem",textAlign:t?"center":"left"},children:n}),h.jsxs("form",{onSubmit:C,children:[m&&h.jsx("div",{style:M,children:h.jsx("p",{style:{fontSize:"0.875rem",color:w.errorColor,margin:0},children:m})}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:v,children:o}),h.jsx("input",{type:"email",value:d,onChange:T=>f(T.target.value),required:!0,style:E,onFocus:T=>{T.target.style.borderColor=w.primaryColor,T.target.style.boxShadow=`0 0 0 2px ${w.primaryColor}20`},onBlur:T=>{T.target.style.borderColor=w.borderColor,T.target.style.boxShadow="none"}})]}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:v,children:l}),h.jsx("input",{type:"password",value:p,onChange:T=>g(T.target.value),required:!0,style:E,onFocus:T=>{T.target.style.borderColor=w.primaryColor,T.target.style.boxShadow=`0 0 0 2px ${w.primaryColor}20`},onBlur:T=>{T.target.style.borderColor=w.borderColor,T.target.style.boxShadow="none"}})]}),h.jsx("button",{type:"submit",disabled:_,style:k,onMouseEnter:T=>{_||(T.target.style.backgroundColor=w.primaryHoverColor)},onMouseLeave:T=>{_||(T.target.style.backgroundColor=w.primaryColor)},children:_?i:s})]})]})}function af({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 h.jsxs("div",{style:s,children:[h.jsx("div",{style:i,onClick:e}),h.jsxs("div",{style:o,children:[h.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:h.jsx("svg",{width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),h.jsx(No,{...n,isModal:!0})]}),h.jsx("style",{children:`
57
+ <%s key={someKey} {...props} />`,Si,vr,Ed,vr),Oe[vr+Si]=!0}}return A===n?Ve(tt):nt(tt),tt}}function ct(A,q,ee){return ut(A,q,ee,!0)}function At(A,q,ee){return ut(A,q,ee,!1)}var Zt=At,Rt=ct;dn.Fragment=n,dn.jsx=Zt,dn.jsxs=Rt}()),dn}process.env.NODE_ENV==="production"?Vi.exports=tf():Vi.exports=rf();var h=Vi.exports;const ou=b.createContext(void 0);function nf({apiUrl:r,systemId:e,children:t}){const[n,s]=b.useState(null),[i,o]=b.useState(null),[l,a]=b.useState(!1),[u,c]=b.useState(!0),[d]=b.useState(()=>new Ao({apiUrl:r,systemId:e})),f=b.useCallback(async E=>{const k=await d.isAdmin(E);a(k)},[d]),p=b.useCallback(()=>{const E=vt.getToken(),k=vt.getUser();E&&k?(o(E),s(k),f(k._id).finally(()=>c(!1))):c(!1)},[f]);b.useEffect(()=>{p()},[p]);const g=b.useCallback(async(E,k)=>{const w=await d.login(E,k);return w.success&&w.user&&w.token&&(o(w.token),s(w.user),await f(w.user._id)),w},[d,f]),m=b.useCallback(async(E,k,w)=>d.register(E,k,w),[d]),x=b.useCallback(async(E,k)=>{const w=await d.verifyEmail(E,k);return w.success&&w.user&&w.token&&(o(w.token),s(w.user),await f(w.user._id)),w},[d,f]),v=b.useCallback(async E=>d.requestPasswordReset(E),[d]),y=b.useCallback(async(E,k,w)=>{const D=await d.setPasswordWithCode(E,k,w);return D.success&&D.user&&D.token&&(o(D.token),s(D.user),await f(D.user._id)),D},[d,f]),_=b.useCallback(async E=>d.resendVerificationCode(E),[d]),S=b.useCallback(()=>{d.logout(),s(null),o(null),a(!1)},[d]);return h.jsx(ou.Provider,{value:{user:n,token:i,isAdmin:l,loading:u,login:g,register:m,verifyEmail:x,requestPasswordReset:v,setPasswordWithCode:y,resendVerificationCode:_,logout:S,refreshUser:p},children:t})}function sf(){const r=b.useContext(ou);if(r===void 0)throw new Error("useAuth must be used within an AuthProvider");return r}const of={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",theme:a,className:u="",isModal:c=!1}){const[d,f]=b.useState(""),[p,g]=b.useState(""),[m,x]=b.useState(""),[v,y]=b.useState(!1),_={...of,...a};async function S(B){B.preventDefault(),y(!0),x("");const T=await r(d,p);T.success?e==null||e():x(T.error||"Connexion impossible"),y(!1)}const E={backgroundColor:_.backgroundColor,borderRadius:_.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...c&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},k={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${_.borderColor}`,borderRadius:_.borderRadius,backgroundColor:_.inputBackground,color:_.textColor,fontSize:"1rem",outline:"none"},w={display:"block",fontSize:"0.875rem",fontWeight:500,color:_.textMutedColor,marginBottom:"0.25rem"},D={width:"100%",padding:"0.75rem",backgroundColor:v?_.textMutedColor:_.primaryColor,color:"#ffffff",border:"none",borderRadius:_.borderRadius,fontSize:"1rem",fontWeight:500,cursor:v?"not-allowed":"pointer",transition:"background-color 0.2s"},j={padding:"0.75rem",backgroundColor:_.errorBackgroundColor,border:`1px solid ${_.errorColor}20`,borderRadius:_.borderRadius,marginBottom:"1rem"};return h.jsxs("div",{style:E,className:u,children:[t&&h.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"1.5rem"},children:t}),h.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:_.textColor,marginBottom:"1rem",textAlign:t?"center":"left"},children:n}),h.jsxs("form",{onSubmit:S,children:[m&&h.jsx("div",{style:j,children:h.jsx("p",{style:{fontSize:"0.875rem",color:_.errorColor,margin:0},children:m})}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:w,children:o}),h.jsx("input",{type:"email",value:d,onChange:B=>f(B.target.value),required:!0,style:k,onFocus:B=>{B.target.style.borderColor=_.primaryColor,B.target.style.boxShadow=`0 0 0 2px ${_.primaryColor}20`},onBlur:B=>{B.target.style.borderColor=_.borderColor,B.target.style.boxShadow="none"}})]}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:w,children:l}),h.jsx("input",{type:"password",value:p,onChange:B=>g(B.target.value),required:!0,style:k,onFocus:B=>{B.target.style.borderColor=_.primaryColor,B.target.style.boxShadow=`0 0 0 2px ${_.primaryColor}20`},onBlur:B=>{B.target.style.borderColor=_.borderColor,B.target.style.boxShadow="none"}})]}),h.jsx("button",{type:"submit",disabled:v,style:D,onMouseEnter:B=>{v||(B.target.style.backgroundColor=_.primaryHoverColor)},onMouseLeave:B=>{v||(B.target.style.backgroundColor=_.primaryColor)},children:v?i:s})]})]})}function af({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 h.jsxs("div",{style:s,children:[h.jsx("div",{style:i,onClick:e}),h.jsxs("div",{style:o,children:[h.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:h.jsx("svg",{width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),h.jsx(No,{...n,isModal:!0})]}),h.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 lf={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 au({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:f="Déjà un compte ? Se connecter",showNameFields:p=!1,theme:g,className:m="",isModal:x=!1}){const[_,y]=b.useState(""),[w,C]=b.useState(""),[D,E]=b.useState(""),[v,k]=b.useState(""),[M,T]=b.useState(""),[N,R]=b.useState(""),[j,S]=b.useState(!1),B={...lf,...g};async function F(W){if(W.preventDefault(),R(""),w!==D){R("Les mots de passe ne correspondent pas");return}if(w.length<8){R("Le mot de passe doit contenir au moins 8 caractères");return}S(!0);const ue=await r(_,w,p?{firstName:v,lastName:M}:void 0);ue.success?e==null||e(_):R(ue.error||"Erreur lors de l'inscription"),S(!1)}const O={backgroundColor:B.backgroundColor,borderRadius:B.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...x&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},V={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"},U={display:"block",fontSize:"0.875rem",fontWeight:500,color:B.textMutedColor,marginBottom:"0.25rem"},te={width:"100%",padding:"0.75rem",backgroundColor:j?B.textMutedColor:B.primaryColor,color:"#ffffff",border:"none",borderRadius:B.borderRadius,fontSize:"1rem",fontWeight:500,cursor:j?"not-allowed":"pointer",transition:"background-color 0.2s"},q={padding:"0.75rem",backgroundColor:B.errorBackgroundColor,border:`1px solid ${B.errorColor}20`,borderRadius:B.borderRadius,marginBottom:"1rem"},X={color:B.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer"};return h.jsxs("div",{style:O,className:m,children:[n&&h.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"1.5rem"},children:n}),h.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:B.textColor,marginBottom:"1rem",textAlign:n?"center":"left"},children:s}),h.jsxs("form",{onSubmit:F,children:[N&&h.jsx("div",{style:q,children:h.jsx("p",{style:{fontSize:"0.875rem",color:B.errorColor,margin:0},children:N})}),p&&h.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"1rem"},children:[h.jsxs("div",{style:{flex:1},children:[h.jsx("label",{style:U,children:c}),h.jsx("input",{type:"text",value:v,onChange:W=>k(W.target.value),style:V})]}),h.jsxs("div",{style:{flex:1},children:[h.jsx("label",{style:U,children:d}),h.jsx("input",{type:"text",value:M,onChange:W=>T(W.target.value),style:V})]})]}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:U,children:l}),h.jsx("input",{type:"email",value:_,onChange:W=>y(W.target.value),required:!0,style:V})]}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:U,children:a}),h.jsx("input",{type:"password",value:w,onChange:W=>C(W.target.value),required:!0,minLength:8,style:V})]}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:U,children:u}),h.jsx("input",{type:"password",value:D,onChange:W=>E(W.target.value),required:!0,style:V})]}),h.jsx("button",{type:"submit",disabled:j,style:te,onMouseEnter:W=>{j||(W.target.style.backgroundColor=B.primaryHoverColor)},onMouseLeave:W=>{j||(W.target.style.backgroundColor=B.primaryColor)},children:j?o:i}),t&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("span",{style:X,onClick:t,children:f})})]})]})}const uf={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:f=6,theme:p,className:g="",isModal:m=!1}){const[x,_]=b.useState(Array(f).fill("")),[y,w]=b.useState(""),[C,D]=b.useState(!1),[E,v]=b.useState(!1),[k,M]=b.useState(!1),T=b.useRef([]),N={...uf,...p};b.useEffect(()=>{var q;(q=T.current[0])==null||q.focus()},[]);const R=(q,X)=>{var ue;const W=X.replace(/\D/g,"").slice(-1),se=[...x];if(se[q]=W,_(se),w(""),W&&q<f-1&&((ue=T.current[q+1])==null||ue.focus()),W&&q===f-1){const de=se.join("");de.length===f&&B(de)}},j=(q,X)=>{var W;X.key==="Backspace"&&!x[q]&&q>0&&((W=T.current[q-1])==null||W.focus())},S=q=>{var ue;q.preventDefault();const X=q.clipboardData.getData("text").replace(/\D/g,"").slice(0,f),W=[...x];X.split("").forEach((de,pe)=>{pe<f&&(W[pe]=de)}),_(W);const se=Math.min(X.length,f)-1;se>=0&&((ue=T.current[se])==null||ue.focus()),X.length===f&&B(X)};async function B(q){var se;const X=q||x.join("");if(X.length!==f){w("Veuillez entrer le code complet");return}D(!0),w("");const W=await e(r,X);W.success?t==null||t():(w(W.error||"Code invalide"),_(Array(f).fill("")),(se=T.current[0])==null||se.focus()),D(!1)}async function F(){if(!n)return;v(!0),M(!1),w("");const q=await n(r);q.success?(M(!0),setTimeout(()=>M(!1),3e3)):w(q.error||"Erreur lors de l'envoi"),v(!1)}const O={backgroundColor:N.backgroundColor,borderRadius:N.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...m&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},V={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"},U={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 h.jsxs("div",{style:O,className:g,children:[h.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:N.textColor,marginBottom:"0.5rem",textAlign:"center"},children:i}),h.jsx("p",{style:{fontSize:"0.875rem",color:N.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:o||`Un code a été envoyé à ${r}`}),y&&h.jsx("div",{style:{padding:"0.75rem",backgroundColor:N.errorBackgroundColor,border:`1px solid ${N.errorColor}20`,borderRadius:N.borderRadius,marginBottom:"1rem"},children:h.jsx("p",{style:{fontSize:"0.875rem",color:N.errorColor,margin:0,textAlign:"center"},children:y})}),k&&h.jsx("div",{style:{padding:"0.75rem",backgroundColor:"#ECFDF5",border:`1px solid ${N.successColor}20`,borderRadius:N.borderRadius,marginBottom:"1rem"},children:h.jsx("p",{style:{fontSize:"0.875rem",color:N.successColor,margin:0,textAlign:"center"},children:"Code renvoyé !"})}),h.jsx("div",{style:{display:"flex",justifyContent:"center",gap:"0.5rem",marginBottom:"1.5rem"},children:x.map((q,X)=>h.jsx("input",{ref:W=>{T.current[X]=W},type:"text",inputMode:"numeric",maxLength:1,value:q,onChange:W=>R(X,W.target.value),onKeyDown:W=>j(X,W),onPaste:S,disabled:C,style:{...V,borderColor:q?N.primaryColor:N.borderColor},onFocus:W=>{W.target.style.borderColor=N.primaryColor,W.target.style.boxShadow=`0 0 0 3px ${N.primaryColor}20`},onBlur:W=>{W.target.style.borderColor=q?N.primaryColor:N.borderColor,W.target.style.boxShadow="none"}},X))}),h.jsx("button",{type:"button",onClick:()=>B(),disabled:C||x.join("").length!==f,style:{...U,opacity:x.join("").length!==f?.5:1},children:C?a:l}),n&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("button",{type:"button",onClick:F,disabled:E,style:{...te,opacity:E?.5:1},children:E?c:u})}),s&&h.jsx("p",{style:{textAlign:"center",marginTop:"0.75rem",marginBottom:0},children:h.jsx("button",{type:"button",onClick:s,style:te,children:d})})]})}const cf={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 lu({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[f,p]=b.useState(""),[g,m]=b.useState(""),[x,_]=b.useState(!1),y={...cf,...u};async function w(M){M.preventDefault(),_(!0),m("");const T=await r(f);T.success?e==null||e(f):m(T.error||"Erreur lors de l'envoi"),_(!1)}const C={backgroundColor:y.backgroundColor,borderRadius:y.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...d&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},D={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${y.borderColor}`,borderRadius:y.borderRadius,backgroundColor:y.inputBackground,color:y.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},E={display:"block",fontSize:"0.875rem",fontWeight:500,color:y.textMutedColor,marginBottom:"0.25rem"},v={width:"100%",padding:"0.75rem",backgroundColor:x?y.textMutedColor:y.primaryColor,color:"#ffffff",border:"none",borderRadius:y.borderRadius,fontSize:"1rem",fontWeight:500,cursor:x?"not-allowed":"pointer",transition:"background-color 0.2s"},k={color:y.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return h.jsxs("div",{style:C,className:c,children:[h.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:y.textColor,marginBottom:"0.5rem",textAlign:"center"},children:n}),h.jsx("p",{style:{fontSize:"0.875rem",color:y.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:s}),h.jsxs("form",{onSubmit:w,children:[g&&h.jsx("div",{style:{padding:"0.75rem",backgroundColor:y.errorBackgroundColor,border:`1px solid ${y.errorColor}20`,borderRadius:y.borderRadius,marginBottom:"1rem"},children:h.jsx("p",{style:{fontSize:"0.875rem",color:y.errorColor,margin:0},children:g})}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:E,children:l}),h.jsx("input",{type:"email",value:f,onChange:M=>p(M.target.value),required:!0,style:D})]}),h.jsx("button",{type:"submit",disabled:x,style:v,onMouseEnter:M=>{x||(M.target.style.backgroundColor=y.primaryHoverColor)},onMouseLeave:M=>{x||(M.target.style.backgroundColor=y.primaryColor)},children:x?o:i}),t&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("button",{type:"button",onClick:t,style:k,children:a})})]})]})}const df={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",inputBackground:"#ffffff",borderRadius:"0.5rem"};function uu({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:f,className:p="",isModal:g=!1}){const[m,x]=b.useState(""),[_,y]=b.useState(""),[w,C]=b.useState(""),[D,E]=b.useState(!1),v={...df,...f};async function k(S){if(S.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 B=await t(r,e,m);B.success?n==null||n():C(B.error||"Erreur lors de la réinitialisation"),E(!1)}const M={backgroundColor:v.backgroundColor,borderRadius:v.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...g&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},T={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:D?v.textMutedColor:v.primaryColor,color:"#ffffff",border:"none",borderRadius:v.borderRadius,fontSize:"1rem",fontWeight:500,cursor:D?"not-allowed":"pointer",transition:"background-color 0.2s"},j={color:v.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return h.jsxs("div",{style:M,className:p,children:[h.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:v.textColor,marginBottom:"0.5rem",textAlign:"center"},children:i}),o&&h.jsx("p",{style:{fontSize:"0.875rem",color:v.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:o}),h.jsxs("form",{onSubmit:k,children:[w&&h.jsx("div",{style:{padding:"0.75rem",backgroundColor:v.errorBackgroundColor,border:`1px solid ${v.errorColor}20`,borderRadius:v.borderRadius,marginBottom:"1rem"},children:h.jsx("p",{style:{fontSize:"0.875rem",color:v.errorColor,margin:0},children:w})}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:N,children:u}),h.jsx("input",{type:"password",value:m,onChange:S=>x(S.target.value),required:!0,minLength:8,style:T})]}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:N,children:c}),h.jsx("input",{type:"password",value:_,onChange:S=>y(S.target.value),required:!0,style:T})]}),h.jsx("button",{type:"submit",disabled:D,style:R,onMouseEnter:S=>{D||(S.target.style.backgroundColor=v.primaryHoverColor)},onMouseLeave:S=>{D||(S.target.style.backgroundColor=v.primaryColor)},children:D?a:l}),s&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("button",{type:"button",onClick:s,style:j,children:d})})]})]})}function cu({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:f=!1,labels:p={}}){const[g,m]=b.useState(l),[x,_]=b.useState(""),[y,w]=b.useState("");async function C(T,N){const R=await r(T,N);return R.requiresVerification?(_(T),m("verify-email"),{success:!1,error:"Veuillez vérifier votre email"}):R}async function D(T,N,R){const j=await e(T,N,R);return j.success&&j.requiresVerification&&(_(T),m("verify-email")),j}async function E(T){const N=await n(T);return N.success&&(_(T),m("verify-reset-code")),N}async function v(T,N){return w(N),m("reset-password"),{success:!0}}const k=()=>{switch(g){case"login":return h.jsx(No,{onLogin:C,onSuccess:o,logo:a,theme:u,title:p.loginTitle,className:d,isModal:f});case"register":return h.jsx(au,{onRegister:D,onSuccess:()=>{},onLoginClick:()=>m("login"),logo:a,theme:u,title:p.registerTitle,showNameFields:c,className:d,isModal:f});case"verify-email":return h.jsx(Gi,{email:x,onVerify:t,onSuccess:o,onResendCode:i,onBackClick:()=>m("login"),title:p.verifyTitle||"Vérification email",theme:u,className:d,isModal:f});case"forgot-password":return h.jsx(lu,{onRequestReset:E,onBackClick:()=>m("login"),title:p.forgotPasswordTitle,theme:u,className:d,isModal:f});case"verify-reset-code":return h.jsx(Gi,{email:x,onVerify:v,onResendCode:i,onBackClick:()=>m("forgot-password"),title:"Code de réinitialisation",theme:u,className:d,isModal:f});case"reset-password":return h.jsx(uu,{email:x,code:y,onResetPassword:s,onSuccess:o,onBackClick:()=>m("login"),title:p.resetPasswordTitle,theme:u,className:d,isModal:f})}},M=()=>{const T={color:(u==null?void 0:u.primaryColor)||"#1877F2",textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return g==="login"?h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"1rem",padding:"0 1.5rem",maxWidth:"24rem",width:"100%"},children:[h.jsx("button",{type:"button",onClick:()=>m("forgot-password"),style:T,children:"Mot de passe oublié ?"}),h.jsx("button",{type:"button",onClick:()=>m("register"),style:T,children:"Créer un compte"})]}):null};return h.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%"},children:[k(),M()]})}function ff({isOpen:r,onClose:e,backdropBlur:t=!0,...n}){return r?h.jsxs("div",{style:{position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center",padding:"1rem"},children:[h.jsx("div",{style:{position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",...t&&{backdropFilter:"blur(4px)"}},onClick:e}),h.jsxs("div",{style:{position:"relative",animation:"authFlowSlideUp 0.2s ease-out"},children:[h.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:h.jsx("svg",{width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),h.jsx(cu,{...n,isModal:!0})]}),h.jsx("style",{children:`
68
+ `})]})}const lf={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 au({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:f="Déjà un compte ? Se connecter",showNameFields:p=!1,theme:g,className:m="",isModal:x=!1}){const[v,y]=b.useState(""),[_,S]=b.useState(""),[E,k]=b.useState(""),[w,D]=b.useState(""),[j,B]=b.useState(""),[T,R]=b.useState(""),[M,C]=b.useState(!1),N={...lf,...g};async function F(H){if(H.preventDefault(),R(""),_!==E){R("Les mots de passe ne correspondent pas");return}if(_.length<8){R("Le mot de passe doit contenir au moins 8 caractères");return}C(!0);const ue=await r(v,_,p?{firstName:w,lastName:j}:void 0);ue.success?e==null||e(v):R(ue.error||"Erreur lors de l'inscription"),C(!1)}const I={backgroundColor:N.backgroundColor,borderRadius:N.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...x&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},W={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${N.borderColor}`,borderRadius:N.borderRadius,backgroundColor:N.inputBackground,color:N.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},z={display:"block",fontSize:"0.875rem",fontWeight:500,color:N.textMutedColor,marginBottom:"0.25rem"},te={width:"100%",padding:"0.75rem",backgroundColor:M?N.textMutedColor:N.primaryColor,color:"#ffffff",border:"none",borderRadius:N.borderRadius,fontSize:"1rem",fontWeight:500,cursor:M?"not-allowed":"pointer",transition:"background-color 0.2s"},U={padding:"0.75rem",backgroundColor:N.errorBackgroundColor,border:`1px solid ${N.errorColor}20`,borderRadius:N.borderRadius,marginBottom:"1rem"},Q={color:N.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer"};return h.jsxs("div",{style:I,className:m,children:[n&&h.jsx("div",{style:{display:"flex",justifyContent:"center",marginBottom:"1.5rem"},children:n}),h.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:N.textColor,marginBottom:"1rem",textAlign:n?"center":"left"},children:s}),h.jsxs("form",{onSubmit:F,children:[T&&h.jsx("div",{style:U,children:h.jsx("p",{style:{fontSize:"0.875rem",color:N.errorColor,margin:0},children:T})}),p&&h.jsxs("div",{style:{display:"flex",gap:"0.75rem",marginBottom:"1rem"},children:[h.jsxs("div",{style:{flex:1},children:[h.jsx("label",{style:z,children:c}),h.jsx("input",{type:"text",value:w,onChange:H=>D(H.target.value),style:W})]}),h.jsxs("div",{style:{flex:1},children:[h.jsx("label",{style:z,children:d}),h.jsx("input",{type:"text",value:j,onChange:H=>B(H.target.value),style:W})]})]}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:z,children:l}),h.jsx("input",{type:"email",value:v,onChange:H=>y(H.target.value),required:!0,style:W})]}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:z,children:a}),h.jsx("input",{type:"password",value:_,onChange:H=>S(H.target.value),required:!0,minLength:8,style:W})]}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:z,children:u}),h.jsx("input",{type:"password",value:E,onChange:H=>k(H.target.value),required:!0,style:W})]}),h.jsx("button",{type:"submit",disabled:M,style:te,onMouseEnter:H=>{M||(H.target.style.backgroundColor=N.primaryHoverColor)},onMouseLeave:H=>{M||(H.target.style.backgroundColor=N.primaryColor)},children:M?o:i}),t&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("span",{style:Q,onClick:t,children:f})})]})]})}const uf={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:f=6,theme:p,className:g="",isModal:m=!1}){const[x,v]=b.useState(Array(f).fill("")),[y,_]=b.useState(""),[S,E]=b.useState(!1),[k,w]=b.useState(!1),[D,j]=b.useState(!1),B=b.useRef([]),T={...uf,...p};b.useEffect(()=>{var U;(U=B.current[0])==null||U.focus()},[]);const R=(U,Q)=>{var ue;const H=Q.replace(/\D/g,"").slice(-1),se=[...x];if(se[U]=H,v(se),_(""),H&&U<f-1&&((ue=B.current[U+1])==null||ue.focus()),H&&U===f-1){const de=se.join("");de.length===f&&N(de)}},M=(U,Q)=>{var H;Q.key==="Backspace"&&!x[U]&&U>0&&((H=B.current[U-1])==null||H.focus())},C=U=>{var ue;U.preventDefault();const Q=U.clipboardData.getData("text").replace(/\D/g,"").slice(0,f),H=[...x];Q.split("").forEach((de,pe)=>{pe<f&&(H[pe]=de)}),v(H);const se=Math.min(Q.length,f)-1;se>=0&&((ue=B.current[se])==null||ue.focus()),Q.length===f&&N(Q)};async function N(U){var se;const Q=U||x.join("");if(Q.length!==f){_("Veuillez entrer le code complet");return}E(!0),_("");const H=await e(r,Q);H.success?t==null||t():(_(H.error||"Code invalide"),v(Array(f).fill("")),(se=B.current[0])==null||se.focus()),E(!1)}async function F(){if(!n)return;w(!0),j(!1),_("");const U=await n(r);U.success?(j(!0),setTimeout(()=>j(!1),3e3)):_(U.error||"Erreur lors de l'envoi"),w(!1)}const I={backgroundColor:T.backgroundColor,borderRadius:T.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...m&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},W={width:"3rem",height:"3.5rem",textAlign:"center",fontSize:"1.5rem",fontWeight:600,border:`2px solid ${T.borderColor}`,borderRadius:T.borderRadius,backgroundColor:T.inputBackground,color:T.textColor,outline:"none",transition:"border-color 0.2s, box-shadow 0.2s"},z={width:"100%",padding:"0.75rem",backgroundColor:S?T.textMutedColor:T.primaryColor,color:"#ffffff",border:"none",borderRadius:T.borderRadius,fontSize:"1rem",fontWeight:500,cursor:S?"not-allowed":"pointer",transition:"background-color 0.2s"},te={color:T.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return h.jsxs("div",{style:I,className:g,children:[h.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:T.textColor,marginBottom:"0.5rem",textAlign:"center"},children:i}),h.jsx("p",{style:{fontSize:"0.875rem",color:T.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:o||`Un code a été envoyé à ${r}`}),y&&h.jsx("div",{style:{padding:"0.75rem",backgroundColor:T.errorBackgroundColor,border:`1px solid ${T.errorColor}20`,borderRadius:T.borderRadius,marginBottom:"1rem"},children:h.jsx("p",{style:{fontSize:"0.875rem",color:T.errorColor,margin:0,textAlign:"center"},children:y})}),D&&h.jsx("div",{style:{padding:"0.75rem",backgroundColor:"#ECFDF5",border:`1px solid ${T.successColor}20`,borderRadius:T.borderRadius,marginBottom:"1rem"},children:h.jsx("p",{style:{fontSize:"0.875rem",color:T.successColor,margin:0,textAlign:"center"},children:"Code renvoyé !"})}),h.jsx("div",{style:{display:"flex",justifyContent:"center",gap:"0.5rem",marginBottom:"1.5rem"},children:x.map((U,Q)=>h.jsx("input",{ref:H=>{B.current[Q]=H},type:"text",inputMode:"numeric",maxLength:1,value:U,onChange:H=>R(Q,H.target.value),onKeyDown:H=>M(Q,H),onPaste:C,disabled:S,style:{...W,borderColor:U?T.primaryColor:T.borderColor},onFocus:H=>{H.target.style.borderColor=T.primaryColor,H.target.style.boxShadow=`0 0 0 3px ${T.primaryColor}20`},onBlur:H=>{H.target.style.borderColor=U?T.primaryColor:T.borderColor,H.target.style.boxShadow="none"}},Q))}),h.jsx("button",{type:"button",onClick:()=>N(),disabled:S||x.join("").length!==f,style:{...z,opacity:x.join("").length!==f?.5:1},children:S?a:l}),n&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("button",{type:"button",onClick:F,disabled:k,style:{...te,opacity:k?.5:1},children:k?c:u})}),s&&h.jsx("p",{style:{textAlign:"center",marginTop:"0.75rem",marginBottom:0},children:h.jsx("button",{type:"button",onClick:s,style:te,children:d})})]})}const cf={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 lu({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[f,p]=b.useState(""),[g,m]=b.useState(""),[x,v]=b.useState(!1),y={...cf,...u};async function _(j){j.preventDefault(),v(!0),m("");const B=await r(f);B.success?e==null||e(f):m(B.error||"Erreur lors de l'envoi"),v(!1)}const S={backgroundColor:y.backgroundColor,borderRadius:y.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...d&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},E={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${y.borderColor}`,borderRadius:y.borderRadius,backgroundColor:y.inputBackground,color:y.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},k={display:"block",fontSize:"0.875rem",fontWeight:500,color:y.textMutedColor,marginBottom:"0.25rem"},w={width:"100%",padding:"0.75rem",backgroundColor:x?y.textMutedColor:y.primaryColor,color:"#ffffff",border:"none",borderRadius:y.borderRadius,fontSize:"1rem",fontWeight:500,cursor:x?"not-allowed":"pointer",transition:"background-color 0.2s"},D={color:y.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return h.jsxs("div",{style:S,className:c,children:[h.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:y.textColor,marginBottom:"0.5rem",textAlign:"center"},children:n}),h.jsx("p",{style:{fontSize:"0.875rem",color:y.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:s}),h.jsxs("form",{onSubmit:_,children:[g&&h.jsx("div",{style:{padding:"0.75rem",backgroundColor:y.errorBackgroundColor,border:`1px solid ${y.errorColor}20`,borderRadius:y.borderRadius,marginBottom:"1rem"},children:h.jsx("p",{style:{fontSize:"0.875rem",color:y.errorColor,margin:0},children:g})}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:k,children:l}),h.jsx("input",{type:"email",value:f,onChange:j=>p(j.target.value),required:!0,style:E})]}),h.jsx("button",{type:"submit",disabled:x,style:w,onMouseEnter:j=>{x||(j.target.style.backgroundColor=y.primaryHoverColor)},onMouseLeave:j=>{x||(j.target.style.backgroundColor=y.primaryColor)},children:x?o:i}),t&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("button",{type:"button",onClick:t,style:D,children:a})})]})]})}const df={primaryColor:"#1877F2",primaryHoverColor:"#166FE5",backgroundColor:"#ffffff",textColor:"#111827",textMutedColor:"#6B7280",borderColor:"#D1D5DB",errorColor:"#DC2626",errorBackgroundColor:"#FEF2F2",inputBackground:"#ffffff",borderRadius:"0.5rem"};function uu({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:f,className:p="",isModal:g=!1}){const[m,x]=b.useState(""),[v,y]=b.useState(""),[_,S]=b.useState(""),[E,k]=b.useState(!1),w={...df,...f};async function D(C){if(C.preventDefault(),S(""),m!==v){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}k(!0);const N=await t(r,e,m);N.success?n==null||n():S(N.error||"Erreur lors de la réinitialisation"),k(!1)}const j={backgroundColor:w.backgroundColor,borderRadius:w.borderRadius,padding:"1.5rem",width:"100%",maxWidth:"24rem",...g&&{boxShadow:"0 25px 50px -12px rgba(0, 0, 0, 0.25)"}},B={width:"100%",padding:"0.5rem 1rem",border:`1px solid ${w.borderColor}`,borderRadius:w.borderRadius,backgroundColor:w.inputBackground,color:w.textColor,fontSize:"1rem",outline:"none",boxSizing:"border-box"},T={display:"block",fontSize:"0.875rem",fontWeight:500,color:w.textMutedColor,marginBottom:"0.25rem"},R={width:"100%",padding:"0.75rem",backgroundColor:E?w.textMutedColor:w.primaryColor,color:"#ffffff",border:"none",borderRadius:w.borderRadius,fontSize:"1rem",fontWeight:500,cursor:E?"not-allowed":"pointer",transition:"background-color 0.2s"},M={color:w.primaryColor,textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return h.jsxs("div",{style:j,className:p,children:[h.jsx("h2",{style:{fontSize:"1.25rem",fontWeight:700,color:w.textColor,marginBottom:"0.5rem",textAlign:"center"},children:i}),o&&h.jsx("p",{style:{fontSize:"0.875rem",color:w.textMutedColor,textAlign:"center",marginBottom:"1.5rem"},children:o}),h.jsxs("form",{onSubmit:D,children:[_&&h.jsx("div",{style:{padding:"0.75rem",backgroundColor:w.errorBackgroundColor,border:`1px solid ${w.errorColor}20`,borderRadius:w.borderRadius,marginBottom:"1rem"},children:h.jsx("p",{style:{fontSize:"0.875rem",color:w.errorColor,margin:0},children:_})}),h.jsxs("div",{style:{marginBottom:"1rem"},children:[h.jsx("label",{style:T,children:u}),h.jsx("input",{type:"password",value:m,onChange:C=>x(C.target.value),required:!0,minLength:8,style:B})]}),h.jsxs("div",{style:{marginBottom:"1.5rem"},children:[h.jsx("label",{style:T,children:c}),h.jsx("input",{type:"password",value:v,onChange:C=>y(C.target.value),required:!0,style:B})]}),h.jsx("button",{type:"submit",disabled:E,style:R,onMouseEnter:C=>{E||(C.target.style.backgroundColor=w.primaryHoverColor)},onMouseLeave:C=>{E||(C.target.style.backgroundColor=w.primaryColor)},children:E?a:l}),s&&h.jsx("p",{style:{textAlign:"center",marginTop:"1rem",marginBottom:0},children:h.jsx("button",{type:"button",onClick:s,style:M,children:d})})]})]})}function cu({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:f=!1,labels:p={}}){const[g,m]=b.useState(l),[x,v]=b.useState(""),[y,_]=b.useState("");async function S(B,T){const R=await r(B,T);return R.requiresVerification?(v(B),m("verify-email"),{success:!1,error:"Veuillez vérifier votre email"}):R}async function E(B,T,R){const M=await e(B,T,R);return M.success&&M.requiresVerification&&(v(B),m("verify-email")),M}async function k(B){const T=await n(B);return T.success&&(v(B),m("verify-reset-code")),T}async function w(B,T){return _(T),m("reset-password"),{success:!0}}const D=()=>{switch(g){case"login":return h.jsx(No,{onLogin:S,onSuccess:o,logo:a,theme:u,title:p.loginTitle,className:d,isModal:f});case"register":return h.jsx(au,{onRegister:E,onSuccess:()=>{},onLoginClick:()=>m("login"),logo:a,theme:u,title:p.registerTitle,showNameFields:c,className:d,isModal:f});case"verify-email":return h.jsx(Gi,{email:x,onVerify:t,onSuccess:o,onResendCode:i,onBackClick:()=>m("login"),title:p.verifyTitle||"Vérification email",theme:u,className:d,isModal:f});case"forgot-password":return h.jsx(lu,{onRequestReset:k,onBackClick:()=>m("login"),title:p.forgotPasswordTitle,theme:u,className:d,isModal:f});case"verify-reset-code":return h.jsx(Gi,{email:x,onVerify:w,onResendCode:i,onBackClick:()=>m("forgot-password"),title:"Code de réinitialisation",theme:u,className:d,isModal:f});case"reset-password":return h.jsx(uu,{email:x,code:y,onResetPassword:s,onSuccess:o,onBackClick:()=>m("login"),title:p.resetPasswordTitle,theme:u,className:d,isModal:f})}},j=()=>{const B={color:(u==null?void 0:u.primaryColor)||"#1877F2",textDecoration:"none",fontSize:"0.875rem",cursor:"pointer",background:"none",border:"none",padding:0};return g==="login"?h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",marginTop:"1rem",padding:"0 1.5rem",maxWidth:"24rem",width:"100%"},children:[h.jsx("button",{type:"button",onClick:()=>m("forgot-password"),style:B,children:"Mot de passe oublié ?"}),h.jsx("button",{type:"button",onClick:()=>m("register"),style:B,children:"Créer un compte"})]}):null};return h.jsxs("div",{style:{display:"flex",flexDirection:"column",alignItems:"center",width:"100%"},children:[D(),j()]})}function ff({isOpen:r,onClose:e,backdropBlur:t=!0,...n}){return r?h.jsxs("div",{style:{position:"fixed",inset:0,zIndex:100,display:"flex",alignItems:"center",justifyContent:"center",padding:"1rem"},children:[h.jsx("div",{style:{position:"absolute",inset:0,backgroundColor:"rgba(0, 0, 0, 0.5)",...t&&{backdropFilter:"blur(4px)"}},onClick:e}),h.jsxs("div",{style:{position:"relative",animation:"authFlowSlideUp 0.2s ease-out"},children:[h.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:h.jsx("svg",{width:"24",height:"24",fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})}),h.jsx(cu,{...n,isModal:!0})]}),h.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 du(r,e,t={}){const{enabled:n=!0,refetchOnMount:s=!0,onSuccess:i,onError:o}=t,[l,a]=b.useState(null),[u,c]=b.useState(n),[d,f]=b.useState(null),p=b.useCallback(async()=>{if(n){c(!0),f(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");f(m),o==null||o(m)}finally{c(!1)}}},[r,JSON.stringify(e),n,i,o]);return b.useEffect(()=>{s&&p()},[p,s]),{data:l,loading:u,error:d,refetch:p}}function hf(r,e="POST",t={}){const{onSuccess:n,onError:s}=t,[i,o]=b.useState(null),[l,a]=b.useState(!1),[u,c]=b.useState(null),d=b.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]),f=b.useCallback(()=>{o(null),c(null),a(!1)},[]);return{data:i,loading:l,error:u,mutate:d,reset:f}}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 pf({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:f,onRefresh:p,theme:g={}}){const{data:m,loading:x,error:_,refetch:y}=du(r,e),[w,C]=b.useState(""),[D,E]=b.useState({}),[v,k]=b.useState(1),M=b.useMemo(()=>{if(!m)return{data:[],total:0,totalPages:0};let S=m;return l&&w&&a.length>0&&(S=vs.search(S,w,a)),Object.keys(D).length>0&&(S=vs.filterByFields(S,D)),vs.paginate(S,v,d)},[m,w,D,v,d,l,a]);b.useEffect(()=>{k(1)},[w,D]);const T=()=>{C(""),E({}),k(1),y(),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"},j=i||(S=>h.jsxs("div",{style:{padding:"16px",cursor:f?"pointer":"default"},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:N.text},children:S.title||S.name||S.label||"Untitled"}),S.description&&h.jsx("div",{style:{fontSize:"13px",color:N.textSecondary,marginTop:"4px"},children:S.description})]}));return x&&!m?h.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px",color:N.textSecondary},children:"Loading..."}):_?h.jsxs("div",{style:{padding:"24px",textAlign:"center",color:"#ef4444"},children:[h.jsx("div",{style:{fontWeight:500,marginBottom:"8px"},children:"Error"}),h.jsx("div",{style:{fontSize:"14px"},children:_.message}),h.jsx("button",{onClick:T,style:{marginTop:"16px",padding:"8px 16px",background:N.primary,color:"white",border:"none",borderRadius:"6px",cursor:"pointer"},children:"Retry"})]}):h.jsxs("div",{style:{background:N.background,borderRadius:"12px",overflow:"hidden"},children:[(n||l||c.length>0)&&h.jsxs("div",{style:{padding:"16px",borderBottom:`1px solid ${N.border}`},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:l||c.length>0?"12px":"0"},children:[n&&h.jsx("h2",{style:{margin:0,fontSize:"18px",fontWeight:600,color:N.text},children:n}),h.jsx("button",{onClick:T,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${N.border}`,borderRadius:"6px",color:N.textSecondary,cursor:"pointer",fontSize:"13px"},children:"Refresh"})]}),l&&h.jsx("input",{type:"text",placeholder:u,value:w,onChange:S=>C(S.target.value),style:{width:"100%",padding:"8px 12px",border:`1px solid ${N.border}`,borderRadius:"8px",fontSize:"14px",outline:"none"}})]}),h.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:M.data.length===0?h.jsx("div",{style:{padding:"48px",textAlign:"center",color:N.textSecondary},children:s}):M.data.map((S,B)=>h.jsx("div",{onClick:()=>f==null?void 0:f(S),style:{background:N.cardBackground,borderRadius:t==="list"?"0":"8px",borderBottom:t==="list"?`1px solid ${N.border}`:"none",transition:"all 0.15s ease"},onMouseEnter:F=>{f&&(F.currentTarget.style.background=N.border)},onMouseLeave:F=>{F.currentTarget.style.background=N.cardBackground},children:j(S,B)},o(S,B)))}),M.totalPages>1&&h.jsxs("div",{style:{padding:"16px",borderTop:`1px solid ${N.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[h.jsxs("div",{style:{fontSize:"13px",color:N.textSecondary},children:["Page ",v," of ",M.totalPages]}),h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("button",{onClick:()=>k(S=>Math.max(1,S-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"}),h.jsx("button",{onClick:()=>k(S=>Math.min(M.totalPages,S+1)),disabled:v===M.totalPages,style:{padding:"6px 12px",border:`1px solid ${N.border}`,borderRadius:"6px",background:"white",cursor:v===M.totalPages?"not-allowed":"pointer",opacity:v===M.totalPages?.5:1},children:"Next"})]})]})]})}function gf({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 h.jsxs("div",{onClick:e,className:`
79
+ `})]}):null}function du(r,e,t={}){const{enabled:n=!0,refetchOnMount:s=!0,onSuccess:i,onError:o}=t,[l,a]=b.useState(null),[u,c]=b.useState(n),[d,f]=b.useState(null),p=b.useCallback(async()=>{if(n){c(!0),f(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");f(m),o==null||o(m)}finally{c(!1)}}},[r,JSON.stringify(e),n,i,o]);return b.useEffect(()=>{s&&p()},[p,s]),{data:l,loading:u,error:d,refetch:p}}function hf(r,e="POST",t={}){const{onSuccess:n,onError:s}=t,[i,o]=b.useState(null),[l,a]=b.useState(!1),[u,c]=b.useState(null),d=b.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]),f=b.useCallback(()=>{o(null),c(null),a(!1)},[]);return{data:i,loading:l,error:u,mutate:d,reset:f}}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 pf({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:f,onRefresh:p,theme:g={}}){const{data:m,loading:x,error:v,refetch:y}=du(r,e),[_,S]=b.useState(""),[E,k]=b.useState({}),[w,D]=b.useState(1),j=b.useMemo(()=>{if(!m)return{data:[],total:0,totalPages:0};let C=m;return l&&_&&a.length>0&&(C=vs.search(C,_,a)),Object.keys(E).length>0&&(C=vs.filterByFields(C,E)),vs.paginate(C,w,d)},[m,_,E,w,d,l,a]);b.useEffect(()=>{D(1)},[_,E]);const B=()=>{S(""),k({}),D(1),y(),p==null||p()},T={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||(C=>h.jsxs("div",{style:{padding:"16px",cursor:f?"pointer":"default"},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:T.text},children:C.title||C.name||C.label||"Untitled"}),C.description&&h.jsx("div",{style:{fontSize:"13px",color:T.textSecondary,marginTop:"4px"},children:C.description})]}));return x&&!m?h.jsx("div",{style:{display:"flex",alignItems:"center",justifyContent:"center",padding:"48px",color:T.textSecondary},children:"Loading..."}):v?h.jsxs("div",{style:{padding:"24px",textAlign:"center",color:"#ef4444"},children:[h.jsx("div",{style:{fontWeight:500,marginBottom:"8px"},children:"Error"}),h.jsx("div",{style:{fontSize:"14px"},children:v.message}),h.jsx("button",{onClick:B,style:{marginTop:"16px",padding:"8px 16px",background:T.primary,color:"white",border:"none",borderRadius:"6px",cursor:"pointer"},children:"Retry"})]}):h.jsxs("div",{style:{background:T.background,borderRadius:"12px",overflow:"hidden"},children:[(n||l||c.length>0)&&h.jsxs("div",{style:{padding:"16px",borderBottom:`1px solid ${T.border}`},children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",marginBottom:l||c.length>0?"12px":"0"},children:[n&&h.jsx("h2",{style:{margin:0,fontSize:"18px",fontWeight:600,color:T.text},children:n}),h.jsx("button",{onClick:B,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${T.border}`,borderRadius:"6px",color:T.textSecondary,cursor:"pointer",fontSize:"13px"},children:"Refresh"})]}),l&&h.jsx("input",{type:"text",placeholder:u,value:_,onChange:C=>S(C.target.value),style:{width:"100%",padding:"8px 12px",border:`1px solid ${T.border}`,borderRadius:"8px",fontSize:"14px",outline:"none"}})]}),h.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:j.data.length===0?h.jsx("div",{style:{padding:"48px",textAlign:"center",color:T.textSecondary},children:s}):j.data.map((C,N)=>h.jsx("div",{onClick:()=>f==null?void 0:f(C),style:{background:T.cardBackground,borderRadius:t==="list"?"0":"8px",borderBottom:t==="list"?`1px solid ${T.border}`:"none",transition:"all 0.15s ease"},onMouseEnter:F=>{f&&(F.currentTarget.style.background=T.border)},onMouseLeave:F=>{F.currentTarget.style.background=T.cardBackground},children:M(C,N)},o(C,N)))}),j.totalPages>1&&h.jsxs("div",{style:{padding:"16px",borderTop:`1px solid ${T.border}`,display:"flex",alignItems:"center",justifyContent:"space-between"},children:[h.jsxs("div",{style:{fontSize:"13px",color:T.textSecondary},children:["Page ",w," of ",j.totalPages]}),h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("button",{onClick:()=>D(C=>Math.max(1,C-1)),disabled:w===1,style:{padding:"6px 12px",border:`1px solid ${T.border}`,borderRadius:"6px",background:"white",cursor:w===1?"not-allowed":"pointer",opacity:w===1?.5:1},children:"Previous"}),h.jsx("button",{onClick:()=>D(C=>Math.min(j.totalPages,C+1)),disabled:w===j.totalPages,style:{padding:"6px 12px",border:`1px solid ${T.border}`,borderRadius:"6px",background:"white",cursor:w===j.totalPages?"not-allowed":"pointer",opacity:w===j.totalPages?.5:1},children:"Next"})]})]})]})}function gf({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 h.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&&h.jsx("div",{className:"flex-shrink-0",children:h.jsx("img",{src:a,alt:o,className:"w-16 h-16 object-cover rounded-lg"})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h3",{className:"font-medium text-gray-900 truncate",children:o}),u&&h.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-blue-100 text-blue-800 rounded-full",children:u})]}),l&&h.jsx("p",{className:"text-sm text-gray-600 truncate mt-0.5",children:l})]}),e&&h.jsx("div",{className:"flex-shrink-0 text-gray-400",children:h.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})}function mf({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 h.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:h.jsxs("div",{className:"bg-white rounded-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto shadow-2xl",children:[h.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between",children:[h.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:i}),e&&h.jsx("button",{onClick:e,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:h.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),h.jsxs("div",{className:"p-6",children:[o&&h.jsx("div",{className:"mb-6",children:h.jsx("img",{src:o,alt:i,className:"w-full h-64 object-cover rounded-lg"})}),s.length>0&&h.jsx("div",{className:"space-y-4",children:s.map((l,a)=>{const u=l.value(r);return u==null||u===""?null:h.jsxs("div",{children:[h.jsx("div",{className:"text-sm font-medium text-gray-500 mb-1",children:l.label}),h.jsx("div",{className:"text-base text-gray-900",children:typeof u=="object"?JSON.stringify(u,null,2):String(u)})]},a)})}),s.length===0&&h.jsx("pre",{className:"bg-gray-50 p-4 rounded-lg text-sm overflow-x-auto",children:JSON.stringify(r,null,2)})]}),e&&h.jsx("div",{className:"sticky bottom-0 bg-gray-50 border-t border-gray-200 px-6 py-4",children:h.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 yf={small:"w-32 h-32",medium:"w-48 h-48",large:"w-64 h-64"};function xf(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 bf({nodes:r,cardCount:e=2,minInterval:t=1e3,maxInterval:n=3e3,onCardClick:s,cardSize:i="medium",className:o=""}){const l=Math.min(Math.max(e,1),5),a=b.useMemo(()=>{if(r.length===0)return[];const v=xf(r),k=Array.from({length:l},()=>[]);return v.forEach((M,T)=>{k[T%l].push(M)}),k},[r,l]),u=b.useRef(Array(l).fill(0)),[c,d]=b.useState([]),[f,p]=b.useState([]),[g,m]=b.useState(Array(l).fill(!1)),[x,_]=b.useState(Array(l).fill(!1)),y=b.useRef([]),w=b.useCallback(()=>Math.random()*(n-t)+t,[t,n]);b.useEffect(()=>{if(a.length===0){d([]),p([]);return}const v=[],k=[];console.log("[AnimatedCardFlip] Pools created:",a.map((M,T)=>({pool:T,nodes:M.map(N=>N.title)})));for(let M=0;M<l;M++){const T=a[M];if(T&&T.length>0){v.push(T[0]),u.current[M]=0;const N=T.length>1?1:0;k.push(T[N])}}console.log("[AnimatedCardFlip] Initial nodes:",v.map(M=>M.title)),d(v),p(k),m(Array(l).fill(!1)),_(Array(l).fill(!1))},[a,l]);const C=b.useCallback(v=>{const k=w(),M=a[v];if(!M||M.length===0)return;const T=setTimeout(()=>{m(N=>{const R=[...N];return R[v]=!R[v],R}),setTimeout(()=>{_(N=>{const R=[...N];return R[v]=!R[v],R}),setTimeout(()=>{const R=(u.current[v]+1)%M.length;u.current[v]=R,d(S=>{const B=[...S];return B[v]=M[R],B});const j=(R+1)%M.length;p(S=>{const B=[...S];return B[v]=M[j],B}),setTimeout(()=>{C(v)},150)},200)},150)},k);y.current[v]=T},[w,a]),D=b.useRef(!1);b.useEffect(()=>{if(!(c.length===0||a.length===0||!a.some(k=>k&&k.length>1))&&!D.current){D.current=!0;for(let k=0;k<c.length;k++)setTimeout(()=>{C(k)},k*500);return()=>{y.current.forEach(k=>clearTimeout(k)),y.current=[],D.current=!1}}},[c.length,a,C]);const E=v=>{s&&s(v)};return r.length===0?h.jsx("div",{className:`flex items-center justify-center p-8 ${o}`,children:h.jsx("p",{className:"text-gray-500",children:"No nodes available"})}):c.length===0?h.jsx("div",{className:`flex items-center justify-center p-8 ${o}`,children:h.jsx("p",{className:"text-gray-500",children:"Loading..."})}):h.jsx("div",{className:`flex gap-4 justify-center items-center flex-wrap ${o}`,children:c.map((v,k)=>{const M=f[k],T=x[k];return h.jsx("div",{className:`relative ${yf[i]}`,style:{perspective:"1000px"},onClick:()=>E(T?M:v),children:h.jsxs("div",{className:"w-full h-full rounded-lg shadow-lg overflow-hidden cursor-pointer hover:shadow-xl",style:{transform:`rotateY(${g[k]?180:0}deg)`,transition:"transform 0.5s",transformStyle:"preserve-3d"},children:[h.jsx("div",{className:"absolute inset-0 transition-opacity duration-200",style:{opacity:T?0:1},children:h.jsxs("div",{style:{transform:g[k]?"scaleX(-1)":"scaleX(1)",width:"100%",height:"100%"},children:[h.jsx("img",{src:v.data.image,alt:v.title,className:"w-full h-full object-cover"}),h.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:h.jsx("p",{className:"text-white text-sm font-medium truncate",children:v.title})})]})}),M&&h.jsx("div",{className:"absolute inset-0 transition-opacity duration-200",style:{opacity:T?1:0},children:h.jsxs("div",{style:{transform:g[k]?"scaleX(-1)":"scaleX(1)",width:"100%",height:"100%"},children:[h.jsx("img",{src:M.data.image,alt:M.title,className:"w-full h-full object-cover"}),h.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:h.jsx("p",{className:"text-white text-sm font-medium truncate",children:M.title})})]})})]})},`slot-${k}`)})})}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 vf={background:"#ffffff",cardBackground:"#ffffff",selectedBackground:"#f5f5f5",unreadBackground:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",danger:"#ef4444"};function _f({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:f,onSelectionChange:p,onDelete:g,onError:m,onLoad:x,renderItem:_,renderDetail:y,renderActions:w,renderEmpty:C,renderLoading:D,theme:E={}}){const v={...vf,...E},[k,M]=b.useState([]),[T,N]=b.useState(!1),[R,j]=b.useState(null),[S,B]=b.useState(new Set),[F,O]=b.useState(null),[V,U]=b.useState(null),[te,q]=b.useState(null),[X,W]=b.useState(!1),[se,ue]=b.useState(""),de=a!==void 0?a:se,pe=ie=>{u?u(ie):ue(ie)},De=b.useMemo(()=>{if(!de.trim())return k;const ie=de.toLowerCase();return k.filter(ce=>$r(ce.from).toLowerCase().includes(ie)||$r(ce.subject).toLowerCase().includes(ie))},[k,de]),xe=b.useMemo(()=>e?new su({baseUrl:r,system_id:e}):null,[r,e]),J=b.useCallback(async()=>{if(xe){N(!0),j(null);try{const ie=await xe.listEmails(t,n,s);ie!=null&&ie.messages&&(M(ie.messages),x==null||x(ie.messages))}catch(ie){const ce=ie instanceof Error?ie:new Error("Failed to fetch emails");j(ce.message),m==null||m(ce)}N(!1)}},[xe,t,n,s,m,x]);b.useEffect(()=>{M([]),B(new Set),U(null),j(null),a===void 0&&ue(""),d&&J()},[s,d]);const Ce=b.useCallback(async ie=>{if(xe){U(ie),q(null),W(!0);try{const ce=await xe.getEmailParsed(t,ie.uid,s||"INBOX");ce!=null&&ce.body&&q(ce.body)}catch(ce){console.error("Failed to fetch email body:",ce)}W(!1)}},[xe,t,s]),ne=b.useCallback(ie=>{f==null||f(ie),o&&Ce(ie)},[f,o,Ce]),Be=b.useCallback((ie,ce,He)=>{if(!i){f==null||f(ie),o&&Ce(ie);return}const Xe=ie.uid;if(He.shiftKey&&F!==null){const Je=Math.min(F,ce),Bt=Math.max(F,ce),Z=k.slice(Je,Bt+1).map(le=>le.uid),L=new Set(Z);B(L),p==null||p(Array.from(L))}else if(He.ctrlKey||He.metaKey)B(Je=>{const Bt=new Set(Je);return Bt.has(Xe)?Bt.delete(Xe):Bt.add(Xe),p==null||p(Array.from(Bt)),Bt}),O(ce);else{const Je=new Set([Xe]);B(Je),O(ce),p==null||p(Array.from(Je))}},[i,F,k,S,f,p,o]),Se=b.useCallback(async()=>{if(!xe||S.size===0)return;const ie=s||"INBOX";try{const ce=await xe.trashEmails(t,Array.from(S),ie);if(console.log("Trash result:",ce),ce.success&&ce.moved>0){M(Xe=>Xe.filter(Je=>!S.has(Je.uid)));const He=Array.from(S);B(new Set),g==null||g(He)}else j("Failed to move emails to trash")}catch(ce){const He=ce instanceof Error?ce:new Error("Trash failed");console.error("Trash error:",He),j(He.message),m==null||m(He)}},[xe,t,S,s,g,m]),ke=b.useCallback(async()=>{if(!xe||S.size===0)return;const ie=s||"INBOX";try{const ce=await xe.archiveEmails(t,Array.from(S),ie);if(console.log("Archive result:",ce),ce.success&&ce.archived>0){M(Xe=>Xe.filter(Je=>!S.has(Je.uid)));const He=Array.from(S);B(new Set),g==null||g(He)}else j("Failed to archive emails")}catch(ce){const He=ce instanceof Error?ce:new Error("Archive failed");console.error("Archive error:",He),j(He.message),m==null||m(He)}},[xe,t,S,s,g,m]),Ie=b.useCallback(()=>{if(S.size===k.length)B(new Set),p==null||p([]);else{const ie=new Set(k.map(ce=>ce.uid));B(ie),p==null||p(Array.from(ie))}},[k,S.size,p]),Le=b.useCallback(()=>{B(new Set),p==null||p([])},[p]),$e={delete:Se,archive:ke,refresh:J,selectAll:Ie,clearSelection:Le},Y=ie=>{if(!ie)return"";const ce=new Date(ie),He=new Date;return ce.toDateString()===He.toDateString()?ce.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):ce.toLocaleDateString([],{month:"short",day:"numeric"})},P=(ie,ce)=>h.jsx("div",{style:{padding:"12px 16px",background:ce?v.selectedBackground:ie.seen?v.cardBackground:v.unreadBackground,borderBottom:`1px solid ${v.border}`,cursor:"pointer",transition:"background 0.15s ease"},children:h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"12px"},children:[h.jsxs("div",{style:{flex:1,minWidth:0},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:ie.seen?400:600,color:v.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(ie.from).split("@")[0]}),h.jsx("div",{style:{fontSize:"14px",fontWeight:ie.seen?400:500,color:ie.seen?v.textSecondary:v.text,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(ie.subject)||"(No subject)"})]}),h.jsx("div",{style:{fontSize:"12px",color:v.textSecondary,flexShrink:0},children:Y(ie.date)})]})}),me=ie=>h.jsxs("div",{style:{padding:"24px"},children:[h.jsx("h2",{style:{margin:"0 0 8px",fontSize:"20px",color:v.text},children:$r(ie.subject)||"(No subject)"}),h.jsxs("div",{style:{fontSize:"14px",color:v.textSecondary,marginBottom:"16px"},children:["From: ",$r(ie.from)," • ",new Date(ie.date).toLocaleString()]}),X?h.jsx("div",{style:{fontSize:"14px",color:v.textSecondary},children:"Loading..."}):te?h.jsx("div",{style:{fontSize:"14px",color:v.text},dangerouslySetInnerHTML:{__html:te}}):h.jsx("div",{style:{fontSize:"14px",color:v.textSecondary},children:"No content available"})]}),We=(ie,ce)=>h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",background:v.cardBackground,borderBottom:`1px solid ${v.border}`},children:[h.jsx("button",{onClick:ce.selectAll,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${v.border}`,borderRadius:"6px",fontSize:"13px",cursor:"pointer",color:v.text},children:ie.length===k.length?"Deselect All":"Select All"}),ie.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("span",{style:{fontSize:"13px",color:v.textSecondary},children:[ie.length," selected"]}),h.jsx("button",{onClick:ce.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:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"archive"})}),h.jsx("button",{onClick:ce.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:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"delete"})})]}),h.jsx("div",{style:{flex:1}}),h.jsx("button",{onClick:ce.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:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"refresh"})})]}),z=()=>h.jsx("div",{style:{padding:"48px",textAlign:"center",color:v.textSecondary},children:c}),ae=()=>h.jsx("div",{style:{padding:"48px",textAlign:"center",color:v.textSecondary},children:"Loading..."}),ge=_||P,ye=y||me,Ue=w||We,mt=C||z,yt=D||ae;return T&&k.length===0?h.jsx("div",{style:{background:v.background,width:"100%",height:"100%"},children:yt()}):h.jsxs("div",{style:{display:"flex",background:v.background,width:"100%",height:"100%"},children:[h.jsxs("div",{style:{flex:o&&V?"0 0 50%":"1",display:"flex",flexDirection:"column",borderRight:o&&V?`1px solid ${v.border}`:"none",overflow:"hidden"},children:[i&&Ue(Array.from(S),$e),l&&h.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${v.border}`,background:v.background},children:h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 12px",background:"#f5f5f5",borderRadius:"6px"},children:[h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:v.textSecondary,strokeWidth:"2",children:[h.jsx("circle",{cx:"11",cy:"11",r:"8"}),h.jsx("path",{d:"M21 21l-4.35-4.35"})]}),h.jsx("input",{type:"text",placeholder:"Search by email or subject...",value:de,onChange:ie=>pe(ie.target.value),style:{flex:1,border:"none",background:"transparent",outline:"none",fontSize:"13px",color:v.text}}),de&&h.jsx("button",{onClick:()=>pe(""),style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",justifyContent:"center"},children:h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:v.textSecondary,strokeWidth:"2",children:h.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]})}),R&&h.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",color:v.danger,fontSize:"14px",borderBottom:`1px solid ${v.border}`},children:R}),h.jsx("div",{style:{flex:1,overflowY:"auto"},children:De.length===0?mt():De.map((ie,ce)=>h.jsx("div",{onClick:He=>Be(ie,ce,He),onDoubleClick:()=>ne(ie),children:ge(ie,S.has(ie.uid))},ie.uid))})]}),o&&V&&h.jsx("div",{style:{flex:1,overflowY:"auto"},children:ye(V)})]})}function wf({items:r,renderItem:e,onSelectionChange:t,onCurrentChange:n,onAction:s,actions:i=[],emptyMessage:o="No items",showSelectAll:l=!0,className:a=""}){const[u,c]=b.useState(new Set),[d,f]=b.useState(-1),p=r.filter(C=>u.has(C.id)),g=d>=0&&d<p.length?p[d]:null,m=b.useCallback(C=>{c(D=>{const E=new Set(D);return E.has(C)?E.delete(C):E.add(C),t==null||t(Array.from(E)),E})},[t]),x=b.useCallback(()=>{if(u.size===r.length)c(new Set),f(-1),t==null||t([]);else{const C=new Set(r.map(D=>D.id));c(C),r.length>0&&(f(0),n==null||n(r[0],0)),t==null||t(r.map(D=>D.id))}},[r,u.size,t,n]),_=b.useCallback(()=>{if(p.length===0)return;const C=d<=0?p.length-1:d-1;f(C),n==null||n(p[C],C)},[p,d,n]),y=b.useCallback(()=>{if(p.length===0)return;const C=d>=p.length-1?0:d+1;f(C),n==null||n(p[C],C)},[p,d,n]),w=b.useCallback(C=>{s==null||s(C,p,g)},[s,p,g]);return b.useEffect(()=>{p.length===0?f(-1):d>=p.length?f(p.length-1):d<0&&p.length>0&&(f(0),n==null||n(p[0],0))},[p.length,d,n]),r.length===0?h.jsx("div",{className:`text-sm text-neutral-400 text-center py-4 ${a}`,children:o}):h.jsxs("div",{className:`space-y-2 ${a}`,children:[h.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[l&&h.jsxs("button",{onClick:x,className:"flex items-center gap-1 hover:text-neutral-700 transition-colors",children:[h.jsx("span",{className:"material-icons text-sm",children:u.size===r.length?"check_box":u.size>0?"indeterminate_check_box":"check_box_outline_blank"}),h.jsx("span",{children:u.size===r.length?"Deselect all":"Select all"})]}),u.size>0&&h.jsxs("span",{className:"text-neutral-400",children:["(",u.size," selected)"]})]}),p.length>1&&h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("button",{onClick:_,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Previous",children:h.jsx("span",{className:"material-icons text-sm",children:"chevron_left"})}),h.jsxs("span",{className:"text-xs min-w-[3rem] text-center",children:[d+1," / ",p.length]}),h.jsx("button",{onClick:y,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Next",children:h.jsx("span",{className:"material-icons text-sm",children:"chevron_right"})})]})]}),h.jsx("div",{className:"space-y-1",children:r.map(C=>{const D=u.has(C.id),E=(g==null?void 0:g.id)===C.id;return h.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":D?"bg-neutral-100":"hover:bg-neutral-50"}`,onClick:()=>m(C.id),children:[h.jsx("span",{className:`material-icons text-lg ${D?"text-blue-500":"text-neutral-300"}`,children:D?"check_box":"check_box_outline_blank"}),h.jsx("div",{className:"flex-1 min-w-0",children:e(C,D,E)})]},C.id)})}),i.length>0&&u.size>0&&h.jsx("div",{className:"flex items-center gap-2 pt-2 border-t border-neutral-100",children:i.map(C=>{var E;const D=((E=C.disabled)==null?void 0:E.call(C,p))??!1;return h.jsxs("button",{onClick:()=>w(C.id),disabled:D,className:`flex items-center gap-1 px-3 py-1.5 text-xs rounded-lg transition-colors ${D?"bg-neutral-100 text-neutral-400 cursor-not-allowed":"bg-neutral-100 hover:bg-neutral-200 text-neutral-700"}`,children:[C.icon&&h.jsx("span",{className:"material-icons text-sm",children:C.icon}),C.label]},C.id)})})]})}function Cf(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Sf=Cf(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 fu=b.createContext(null);function kf(r,e){return{getTheme:function(){return e??null}}}function zt(){const r=b.useContext(fu);return r==null&&Sf(8),r}function Hn(r){return{}}const Bo={},Ef={},hu={},Er={},Kr={},Fn={},Yr={},si={},Ki={},jn={},Ln={},It={},Ro={},Mo={},Df={},pu={},Af={},gu={},Tf={},mu={},yu={},Ns={},Nf={},xu={},bu={},vu={},Bf={},Rf={},Mf={},Ea={},_u={},Ff={},wu={},Cu={},jf={},ii={},Fo={},Yi={},Lf={},Pf={},as={},ls={},If={},Of={},zf={},$t=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,$f=$t&&"documentMode"in document?document.documentMode:null,Mt=$t&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),mr=$t&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Bs=!(!$t||!("InputEvent"in window)||$f)&&"getTargetRanges"in new window.InputEvent("input"),oi=$t&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Vn=$t&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,qf=$t&&/Android/.test(navigator.userAgent),Su=$t&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Uf=$t&&qf&&Su,jo=$t&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Su,Gn=1,xr=3,Nr=0,ku=1,Zr=2,Wf=0,Hf=1,Vf=2,Rs=4,Ms=8,Lo=128,Gf=112|(3|Rs|Ms)|Lo,Po=1,Io=2,Oo=3,zo=4,$o=5,qo=6,ai=oi||Vn||jo?" ":"​",sr=`
83
+ `,children:[a&&h.jsx("div",{className:"flex-shrink-0",children:h.jsx("img",{src:a,alt:o,className:"w-16 h-16 object-cover rounded-lg"})}),h.jsxs("div",{className:"flex-1 min-w-0",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[h.jsx("h3",{className:"font-medium text-gray-900 truncate",children:o}),u&&h.jsx("span",{className:"px-2 py-0.5 text-xs font-medium bg-blue-100 text-blue-800 rounded-full",children:u})]}),l&&h.jsx("p",{className:"text-sm text-gray-600 truncate mt-0.5",children:l})]}),e&&h.jsx("div",{className:"flex-shrink-0 text-gray-400",children:h.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M9 5l7 7-7 7"})})})]})}function mf({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 h.jsx("div",{className:"fixed inset-0 bg-black/50 z-50 flex items-center justify-center p-4",children:h.jsxs("div",{className:"bg-white rounded-xl max-w-2xl w-full max-h-[90vh] overflow-y-auto shadow-2xl",children:[h.jsxs("div",{className:"sticky top-0 bg-white border-b border-gray-200 px-6 py-4 flex items-center justify-between",children:[h.jsx("h2",{className:"text-xl font-semibold text-gray-900",children:i}),e&&h.jsx("button",{onClick:e,className:"p-2 hover:bg-gray-100 rounded-lg transition-colors",children:h.jsx("svg",{className:"w-5 h-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:h.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),h.jsxs("div",{className:"p-6",children:[o&&h.jsx("div",{className:"mb-6",children:h.jsx("img",{src:o,alt:i,className:"w-full h-64 object-cover rounded-lg"})}),s.length>0&&h.jsx("div",{className:"space-y-4",children:s.map((l,a)=>{const u=l.value(r);return u==null||u===""?null:h.jsxs("div",{children:[h.jsx("div",{className:"text-sm font-medium text-gray-500 mb-1",children:l.label}),h.jsx("div",{className:"text-base text-gray-900",children:typeof u=="object"?JSON.stringify(u,null,2):String(u)})]},a)})}),s.length===0&&h.jsx("pre",{className:"bg-gray-50 p-4 rounded-lg text-sm overflow-x-auto",children:JSON.stringify(r,null,2)})]}),e&&h.jsx("div",{className:"sticky bottom-0 bg-gray-50 border-t border-gray-200 px-6 py-4",children:h.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 yf={small:"w-32 h-32",medium:"w-48 h-48",large:"w-64 h-64"};function xf(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 bf({nodes:r,cardCount:e=2,minInterval:t=1e3,maxInterval:n=3e3,onCardClick:s,cardSize:i="medium",className:o=""}){const l=Math.min(Math.max(e,1),5),a=b.useRef([]),u=b.useRef(""),c=r.map(M=>M._id).sort().join(",");if(c!==u.current&&r.length>0){u.current=c;const M=xf(r),C=Array.from({length:l},()=>[]);M.forEach((N,F)=>{C[F%l].push(N)}),a.current=C,console.log("[AnimatedCardFlip] Pools created (new nodes):",C.map((N,F)=>({pool:F,nodes:N.map(I=>I.title)})))}const d=a.current,f=b.useRef(Array(l).fill(0)),p=b.useRef(Array(l).fill(0)),g=b.useRef(Array(l).fill(-1)),[m,x]=b.useState([]),[v,y]=b.useState([]),[_,S]=b.useState(Array(l).fill(!1)),[E,k]=b.useState(Array(l).fill(!1)),w=b.useRef([]),D=b.useCallback(()=>Math.random()*(n-t)+t,[t,n]),j=b.useRef(!1);b.useEffect(()=>{if(d.length===0){x([]),y([]);return}if(j.current){console.log("[AnimatedCardFlip] Skipping init (already done)");return}j.current=!0;const M=[],C=[];for(let N=0;N<l;N++){const F=d[N];if(F&&F.length>0){M.push(F[0]),f.current[N]=0;const I=F.length>1?1:0;C.push(F[I])}}console.log("[AnimatedCardFlip] Initial nodes:",M.map(N=>N.title)),x(M),y(C),S(Array(l).fill(!1)),k(Array(l).fill(!1))},[d,l]);const B=b.useCallback(M=>{const C=D(),N=d[M];if(!N||N.length===0)return;const F=++p.current[M],I=setTimeout(()=>{S(W=>{const z=[...W];return z[M]=!z[M],z}),setTimeout(()=>{k(W=>{const z=[...W];return z[M]=!z[M],z}),setTimeout(()=>{if(g.current[M]>=F){console.log(`[AnimatedCardFlip] Skipping duplicate flip ${F} for slot ${M}`);return}g.current[M]=F;const W=f.current[M],z=(W+1)%N.length;f.current[M]=z,console.log(`[AnimatedCardFlip] Flip ${F} slot ${M}: index ${W} -> ${z}`),x(U=>{const Q=[...U];return Q[M]=N[z],Q});const te=(z+1)%N.length;y(U=>{const Q=[...U];return Q[M]=N[te],Q}),setTimeout(()=>{B(M)},150)},200)},150)},C);w.current[M]=I},[D,d]),T=b.useRef(!1);b.useEffect(()=>{if(!(m.length===0||d.length===0||!d.some(C=>C&&C.length>1))&&!T.current){T.current=!0;for(let C=0;C<m.length;C++)setTimeout(()=>{B(C)},C*500);return()=>{w.current.forEach(C=>clearTimeout(C)),w.current=[]}}},[m.length,d,B]);const R=M=>{s&&s(M)};return r.length===0?h.jsx("div",{className:`flex items-center justify-center p-8 ${o}`,children:h.jsx("p",{className:"text-gray-500",children:"No nodes available"})}):m.length===0?h.jsx("div",{className:`flex items-center justify-center p-8 ${o}`,children:h.jsx("p",{className:"text-gray-500",children:"Loading..."})}):h.jsx("div",{className:`flex gap-4 justify-center items-center flex-wrap ${o}`,children:m.map((M,C)=>{const N=v[C],F=E[C];return h.jsx("div",{className:`relative ${yf[i]}`,style:{perspective:"1000px"},onClick:()=>R(F?N:M),children:h.jsxs("div",{className:"w-full h-full rounded-lg shadow-lg overflow-hidden cursor-pointer hover:shadow-xl",style:{transform:`rotateY(${_[C]?180:0}deg)`,transition:"transform 0.5s",transformStyle:"preserve-3d"},children:[h.jsx("div",{className:"absolute inset-0 transition-opacity duration-200",style:{opacity:F?0:1},children:h.jsxs("div",{style:{transform:_[C]?"scaleX(-1)":"scaleX(1)",width:"100%",height:"100%"},children:[h.jsx("img",{src:M.data.image,alt:M.title,className:"w-full h-full object-cover"}),h.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:h.jsx("p",{className:"text-white text-sm font-medium truncate",children:M.title})})]})}),N&&h.jsx("div",{className:"absolute inset-0 transition-opacity duration-200",style:{opacity:F?1:0},children:h.jsxs("div",{style:{transform:_[C]?"scaleX(-1)":"scaleX(1)",width:"100%",height:"100%"},children:[h.jsx("img",{src:N.data.image,alt:N.title,className:"w-full h-full object-cover"}),h.jsx("div",{className:"absolute bottom-0 left-0 right-0 bg-gradient-to-t from-black/70 to-transparent p-2",children:h.jsx("p",{className:"text-white text-sm font-medium truncate",children:N.title})})]})})]})},`slot-${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,(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 vf={background:"#ffffff",cardBackground:"#ffffff",selectedBackground:"#f5f5f5",unreadBackground:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",danger:"#ef4444"};function _f({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:f,onSelectionChange:p,onDelete:g,onError:m,onLoad:x,renderItem:v,renderDetail:y,renderActions:_,renderEmpty:S,renderLoading:E,theme:k={}}){const w={...vf,...k},[D,j]=b.useState([]),[B,T]=b.useState(!1),[R,M]=b.useState(null),[C,N]=b.useState(new Set),[F,I]=b.useState(null),[W,z]=b.useState(null),[te,U]=b.useState(null),[Q,H]=b.useState(!1),[se,ue]=b.useState(""),de=a!==void 0?a:se,pe=ie=>{u?u(ie):ue(ie)},De=b.useMemo(()=>{if(!de.trim())return D;const ie=de.toLowerCase();return D.filter(ce=>$r(ce.from).toLowerCase().includes(ie)||$r(ce.subject).toLowerCase().includes(ie))},[D,de]),xe=b.useMemo(()=>e?new su({baseUrl:r,system_id:e}):null,[r,e]),J=b.useCallback(async()=>{if(xe){T(!0),M(null);try{const ie=await xe.listEmails(t,n,s);ie!=null&&ie.messages&&(j(ie.messages),x==null||x(ie.messages))}catch(ie){const ce=ie instanceof Error?ie:new Error("Failed to fetch emails");M(ce.message),m==null||m(ce)}T(!1)}},[xe,t,n,s,m,x]);b.useEffect(()=>{j([]),N(new Set),z(null),M(null),a===void 0&&ue(""),d&&J()},[s,d]);const Ce=b.useCallback(async ie=>{if(xe){z(ie),U(null),H(!0);try{const ce=await xe.getEmailParsed(t,ie.uid,s||"INBOX");ce!=null&&ce.body&&U(ce.body)}catch(ce){console.error("Failed to fetch email body:",ce)}H(!1)}},[xe,t,s]),ne=b.useCallback(ie=>{f==null||f(ie),o&&Ce(ie)},[f,o,Ce]),Be=b.useCallback((ie,ce,He)=>{if(!i){f==null||f(ie),o&&Ce(ie);return}const Xe=ie.uid;if(He.shiftKey&&F!==null){const Je=Math.min(F,ce),Bt=Math.max(F,ce),Z=D.slice(Je,Bt+1).map(le=>le.uid),L=new Set(Z);N(L),p==null||p(Array.from(L))}else if(He.ctrlKey||He.metaKey)N(Je=>{const Bt=new Set(Je);return Bt.has(Xe)?Bt.delete(Xe):Bt.add(Xe),p==null||p(Array.from(Bt)),Bt}),I(ce);else{const Je=new Set([Xe]);N(Je),I(ce),p==null||p(Array.from(Je))}},[i,F,D,C,f,p,o]),Se=b.useCallback(async()=>{if(!xe||C.size===0)return;const ie=s||"INBOX";try{const ce=await xe.trashEmails(t,Array.from(C),ie);if(console.log("Trash result:",ce),ce.success&&ce.moved>0){j(Xe=>Xe.filter(Je=>!C.has(Je.uid)));const He=Array.from(C);N(new Set),g==null||g(He)}else M("Failed to move emails to trash")}catch(ce){const He=ce instanceof Error?ce:new Error("Trash failed");console.error("Trash error:",He),M(He.message),m==null||m(He)}},[xe,t,C,s,g,m]),ke=b.useCallback(async()=>{if(!xe||C.size===0)return;const ie=s||"INBOX";try{const ce=await xe.archiveEmails(t,Array.from(C),ie);if(console.log("Archive result:",ce),ce.success&&ce.archived>0){j(Xe=>Xe.filter(Je=>!C.has(Je.uid)));const He=Array.from(C);N(new Set),g==null||g(He)}else M("Failed to archive emails")}catch(ce){const He=ce instanceof Error?ce:new Error("Archive failed");console.error("Archive error:",He),M(He.message),m==null||m(He)}},[xe,t,C,s,g,m]),Ie=b.useCallback(()=>{if(C.size===D.length)N(new Set),p==null||p([]);else{const ie=new Set(D.map(ce=>ce.uid));N(ie),p==null||p(Array.from(ie))}},[D,C.size,p]),Le=b.useCallback(()=>{N(new Set),p==null||p([])},[p]),$e={delete:Se,archive:ke,refresh:J,selectAll:Ie,clearSelection:Le},Y=ie=>{if(!ie)return"";const ce=new Date(ie),He=new Date;return ce.toDateString()===He.toDateString()?ce.toLocaleTimeString([],{hour:"2-digit",minute:"2-digit"}):ce.toLocaleDateString([],{month:"short",day:"numeric"})},P=(ie,ce)=>h.jsx("div",{style:{padding:"12px 16px",background:ce?w.selectedBackground:ie.seen?w.cardBackground:w.unreadBackground,borderBottom:`1px solid ${w.border}`,cursor:"pointer",transition:"background 0.15s ease"},children:h.jsxs("div",{style:{display:"flex",justifyContent:"space-between",alignItems:"flex-start",gap:"12px"},children:[h.jsxs("div",{style:{flex:1,minWidth:0},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:ie.seen?400:600,color:w.text,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(ie.from).split("@")[0]}),h.jsx("div",{style:{fontSize:"14px",fontWeight:ie.seen?400:500,color:ie.seen?w.textSecondary:w.text,marginTop:"2px",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:$r(ie.subject)||"(No subject)"})]}),h.jsx("div",{style:{fontSize:"12px",color:w.textSecondary,flexShrink:0},children:Y(ie.date)})]})}),me=ie=>h.jsxs("div",{style:{padding:"24px"},children:[h.jsx("h2",{style:{margin:"0 0 8px",fontSize:"20px",color:w.text},children:$r(ie.subject)||"(No subject)"}),h.jsxs("div",{style:{fontSize:"14px",color:w.textSecondary,marginBottom:"16px"},children:["From: ",$r(ie.from)," • ",new Date(ie.date).toLocaleString()]}),Q?h.jsx("div",{style:{fontSize:"14px",color:w.textSecondary},children:"Loading..."}):te?h.jsx("div",{style:{fontSize:"14px",color:w.text},dangerouslySetInnerHTML:{__html:te}}):h.jsx("div",{style:{fontSize:"14px",color:w.textSecondary},children:"No content available"})]}),We=(ie,ce)=>h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 16px",background:w.cardBackground,borderBottom:`1px solid ${w.border}`},children:[h.jsx("button",{onClick:ce.selectAll,style:{padding:"6px 12px",background:"transparent",border:`1px solid ${w.border}`,borderRadius:"6px",fontSize:"13px",cursor:"pointer",color:w.text},children:ie.length===D.length?"Deselect All":"Select All"}),ie.length>0&&h.jsxs(h.Fragment,{children:[h.jsxs("span",{style:{fontSize:"13px",color:w.textSecondary},children:[ie.length," selected"]}),h.jsx("button",{onClick:ce.archive,title:"Archive",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${w.border}`,borderRadius:"6px",cursor:"pointer",color:w.textSecondary},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"archive"})}),h.jsx("button",{onClick:ce.delete,title:"Delete",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${w.border}`,borderRadius:"6px",cursor:"pointer",color:w.textSecondary},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"delete"})})]}),h.jsx("div",{style:{flex:1}}),h.jsx("button",{onClick:ce.refresh,title:"Refresh",style:{display:"flex",alignItems:"center",justifyContent:"center",width:"32px",height:"32px",background:"transparent",border:`1px solid ${w.border}`,borderRadius:"6px",cursor:"pointer",color:w.textSecondary},children:h.jsx("span",{className:"material-icons",style:{fontSize:"18px"},children:"refresh"})})]}),$=()=>h.jsx("div",{style:{padding:"48px",textAlign:"center",color:w.textSecondary},children:c}),ae=()=>h.jsx("div",{style:{padding:"48px",textAlign:"center",color:w.textSecondary},children:"Loading..."}),ge=v||P,ye=y||me,Ue=_||We,mt=S||$,yt=E||ae;return B&&D.length===0?h.jsx("div",{style:{background:w.background,width:"100%",height:"100%"},children:yt()}):h.jsxs("div",{style:{display:"flex",background:w.background,width:"100%",height:"100%"},children:[h.jsxs("div",{style:{flex:o&&W?"0 0 50%":"1",display:"flex",flexDirection:"column",borderRight:o&&W?`1px solid ${w.border}`:"none",overflow:"hidden"},children:[i&&Ue(Array.from(C),$e),l&&h.jsx("div",{style:{padding:"8px 12px",borderBottom:`1px solid ${w.border}`,background:w.background},children:h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"6px 12px",background:"#f5f5f5",borderRadius:"6px"},children:[h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"none",stroke:w.textSecondary,strokeWidth:"2",children:[h.jsx("circle",{cx:"11",cy:"11",r:"8"}),h.jsx("path",{d:"M21 21l-4.35-4.35"})]}),h.jsx("input",{type:"text",placeholder:"Search by email or subject...",value:de,onChange:ie=>pe(ie.target.value),style:{flex:1,border:"none",background:"transparent",outline:"none",fontSize:"13px",color:w.text}}),de&&h.jsx("button",{onClick:()=>pe(""),style:{border:"none",background:"transparent",cursor:"pointer",padding:"2px",display:"flex",alignItems:"center",justifyContent:"center"},children:h.jsx("svg",{width:"14",height:"14",viewBox:"0 0 24 24",fill:"none",stroke:w.textSecondary,strokeWidth:"2",children:h.jsx("path",{d:"M18 6L6 18M6 6l12 12"})})})]})}),R&&h.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",color:w.danger,fontSize:"14px",borderBottom:`1px solid ${w.border}`},children:R}),h.jsx("div",{style:{flex:1,overflowY:"auto"},children:De.length===0?mt():De.map((ie,ce)=>h.jsx("div",{onClick:He=>Be(ie,ce,He),onDoubleClick:()=>ne(ie),children:ge(ie,C.has(ie.uid))},ie.uid))})]}),o&&W&&h.jsx("div",{style:{flex:1,overflowY:"auto"},children:ye(W)})]})}function wf({items:r,renderItem:e,onSelectionChange:t,onCurrentChange:n,onAction:s,actions:i=[],emptyMessage:o="No items",showSelectAll:l=!0,className:a=""}){const[u,c]=b.useState(new Set),[d,f]=b.useState(-1),p=r.filter(S=>u.has(S.id)),g=d>=0&&d<p.length?p[d]:null,m=b.useCallback(S=>{c(E=>{const k=new Set(E);return k.has(S)?k.delete(S):k.add(S),t==null||t(Array.from(k)),k})},[t]),x=b.useCallback(()=>{if(u.size===r.length)c(new Set),f(-1),t==null||t([]);else{const S=new Set(r.map(E=>E.id));c(S),r.length>0&&(f(0),n==null||n(r[0],0)),t==null||t(r.map(E=>E.id))}},[r,u.size,t,n]),v=b.useCallback(()=>{if(p.length===0)return;const S=d<=0?p.length-1:d-1;f(S),n==null||n(p[S],S)},[p,d,n]),y=b.useCallback(()=>{if(p.length===0)return;const S=d>=p.length-1?0:d+1;f(S),n==null||n(p[S],S)},[p,d,n]),_=b.useCallback(S=>{s==null||s(S,p,g)},[s,p,g]);return b.useEffect(()=>{p.length===0?f(-1):d>=p.length?f(p.length-1):d<0&&p.length>0&&(f(0),n==null||n(p[0],0))},[p.length,d,n]),r.length===0?h.jsx("div",{className:`text-sm text-neutral-400 text-center py-4 ${a}`,children:o}):h.jsxs("div",{className:`space-y-2 ${a}`,children:[h.jsxs("div",{className:"flex items-center justify-between text-xs text-neutral-500",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[l&&h.jsxs("button",{onClick:x,className:"flex items-center gap-1 hover:text-neutral-700 transition-colors",children:[h.jsx("span",{className:"material-icons text-sm",children:u.size===r.length?"check_box":u.size>0?"indeterminate_check_box":"check_box_outline_blank"}),h.jsx("span",{children:u.size===r.length?"Deselect all":"Select all"})]}),u.size>0&&h.jsxs("span",{className:"text-neutral-400",children:["(",u.size," selected)"]})]}),p.length>1&&h.jsxs("div",{className:"flex items-center gap-1",children:[h.jsx("button",{onClick:v,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Previous",children:h.jsx("span",{className:"material-icons text-sm",children:"chevron_left"})}),h.jsxs("span",{className:"text-xs min-w-[3rem] text-center",children:[d+1," / ",p.length]}),h.jsx("button",{onClick:y,className:"p-1 hover:bg-neutral-100 rounded transition-colors",title:"Next",children:h.jsx("span",{className:"material-icons text-sm",children:"chevron_right"})})]})]}),h.jsx("div",{className:"space-y-1",children:r.map(S=>{const E=u.has(S.id),k=(g==null?void 0:g.id)===S.id;return h.jsxs("div",{className:`flex items-center gap-2 p-2 rounded-lg cursor-pointer transition-colors ${k?"bg-blue-50 ring-1 ring-blue-200":E?"bg-neutral-100":"hover:bg-neutral-50"}`,onClick:()=>m(S.id),children:[h.jsx("span",{className:`material-icons text-lg ${E?"text-blue-500":"text-neutral-300"}`,children:E?"check_box":"check_box_outline_blank"}),h.jsx("div",{className:"flex-1 min-w-0",children:e(S,E,k)})]},S.id)})}),i.length>0&&u.size>0&&h.jsx("div",{className:"flex items-center gap-2 pt-2 border-t border-neutral-100",children:i.map(S=>{var k;const E=((k=S.disabled)==null?void 0:k.call(S,p))??!1;return h.jsxs("button",{onClick:()=>_(S.id),disabled:E,className:`flex items-center gap-1 px-3 py-1.5 text-xs rounded-lg transition-colors ${E?"bg-neutral-100 text-neutral-400 cursor-not-allowed":"bg-neutral-100 hover:bg-neutral-200 text-neutral-700"}`,children:[S.icon&&h.jsx("span",{className:"material-icons text-sm",children:S.icon}),S.label]},S.id)})})]})}function Cf(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Sf=Cf(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 fu=b.createContext(null);function kf(r,e){return{getTheme:function(){return e??null}}}function zt(){const r=b.useContext(fu);return r==null&&Sf(8),r}function Hn(r){return{}}const Bo={},Ef={},hu={},Er={},Kr={},Fn={},Yr={},si={},Ki={},jn={},Ln={},It={},Ro={},Mo={},Df={},pu={},Af={},gu={},Tf={},mu={},yu={},Ns={},Nf={},xu={},bu={},vu={},Bf={},Rf={},Mf={},Ea={},_u={},Ff={},wu={},Cu={},jf={},ii={},Fo={},Yi={},Lf={},Pf={},as={},ls={},If={},Of={},zf={},$t=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,$f=$t&&"documentMode"in document?document.documentMode:null,Mt=$t&&/Mac|iPod|iPhone|iPad/.test(navigator.platform),mr=$t&&/^(?!.*Seamonkey)(?=.*Firefox).*/i.test(navigator.userAgent),Bs=!(!$t||!("InputEvent"in window)||$f)&&"getTargetRanges"in new window.InputEvent("input"),oi=$t&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),Vn=$t&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,qf=$t&&/Android/.test(navigator.userAgent),Su=$t&&/^(?=.*Chrome).*/i.test(navigator.userAgent),Uf=$t&&qf&&Su,jo=$t&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!Su,Gn=1,xr=3,Nr=0,ku=1,Zr=2,Wf=0,Hf=1,Vf=2,Rs=4,Ms=8,Lo=128,Gf=112|(3|Rs|Ms)|Lo,Po=1,Io=2,Oo=3,zo=4,$o=5,qo=6,ai=oi||Vn||jo?" ":"​",sr=`
84
84
 
85
- `,Kf=mr?" ":ai,Eu="֑-߿יִ-﷽ﹰ-ﻼ",Du="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",Yf=new RegExp("^[^"+Du+"]*["+Eu+"]"),Qf=new RegExp("^[^"+Eu+"]*["+Du+"]"),Br={bold:1,code:16,highlight:Lo,italic:2,strikethrough:Rs,subscript:32,superscript:64,underline:Ms},Xf={directionless:1,unmergeable:2},Da={center:Io,end:qo,justify:zo,left:Po,right:Oo,start:$o},Jf={[Io]:"center",[qo]:"end",[zo]:"justify",[Po]:"left",[Oo]:"right",[$o]:"start"},Zf={normal:0,segmented:2,token:1},eh={[Wf]:"normal",[Vf]:"segmented",[Hf]:"token"};function th(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var K=th(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 Fs(...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 rh=100;let Qi=!1,Uo=0;function nh(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 sh(r,e,t){const n=Nt(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 ih(r,e,t){if(H(r)){const n=r.anchor.getNode();if(n.is(t)&&r.format!==n.getFormat())return!1}return e.nodeType===xr&&t.isAttached()}function oh(r,e,t,n){for(let s=r;s&&!bh(s);s=Yn(s)){const i=ui(s,e);if(i!==void 0){const o=dt(i,t);if(o)return ze(o)?void 0:[s,o]}else if(s===n)return[n,Lu(t)]}}function Au(r,e,t){Qi=!0;const n=performance.now()-Uo>rh;try{kt(r,()=>{const s=oe()||function(f){return f.getEditorState().read(()=>{const p=oe();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 f=0;f<e.length;f++){const p=e[f],g=p.type,m=p.target,x=oh(m,r,l,o);if(!x)continue;const[_,y]=x;if(g==="characterData")n&&Q(y)&&ih(s,m,y)&&sh(m,y,r);else if(g==="childList"){u=!0;const w=p.addedNodes;for(let E=0;E<w.length;E++){const v=w[E],k=Fu(v),M=v.parentNode;if(M!=null&&v!==a&&k===null&&!Bi(v,M,r)){if(mr){const T=v.innerText||v.nodeValue;T&&(c+=T)}M.removeChild(v)}}const C=p.removedNodes,D=C.length;if(D>0){let E=0;for(let v=0;v<D;v++){const k=C[v];(Bi(k,m,r)||a===k)&&(m.appendChild(k),E++)}D!==E&&i.set(_,y)}}}if(i.size>0)for(const[f,p]of i)p.reconcileObservedMutation(f,r);const d=t.takeRecords();if(d.length>0){for(let f=0;f<d.length;f++){const p=d[f],g=p.addedNodes,m=p.target;for(let x=0;x<g.length;x++){const _=g[x],y=_.parentNode;y==null||_.nodeName!=="BR"||Bi(_,m,r)||y.removeChild(_)}}t.takeRecords()}s!==null&&(u&&(s.dirty=!0,Kt(s)),mr&&zu(r)&&s.insertRawText(c))})}finally{Qi=!1}}function Tu(r){const e=r._observer;e!==null&&Au(r,e.takeRecords(),e)}function Nu(r){(function(e){Uo===0&&di(e).addEventListener("textInput",nh,!0)})(r),r._observer=new MutationObserver((e,t)=>{Au(r,e,t)})}function Aa(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 Ta(r,e){const t=r.mergeWithSibling(e),n=Qe()._normalizedNodes;return n.add(r.__key),n.add(e.__key),t}function Na(r){let e,t,n=r;if(n.__text!==""||!n.isSimpleText()||n.isUnmergeable()){for(;(e=n.getPreviousSibling())!==null&&Q(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(e.__text!==""){if(Aa(e,n)){n=Ta(e,n);break}break}e.remove()}for(;(t=n.getNextSibling())!==null&&Q(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==""){if(Aa(n,t)){n=Ta(n,t);break}break}t.remove()}}else n.remove()}function Bu(r){return Ba(r.anchor),Ba(r.focus),r}function Ba(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),Q(n)){r.set(n.__key,s?n.getTextContentSize():0,"text");break}if(!I(n))break;r.set(n.__key,s?n.getChildrenSize():0,"element")}}let ah=1;const lh=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 ze(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 uh(r){return r.nodeType===xr}function js(r){let e=r;for(;e!=null;){if(uh(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 Mu(r){return Q(r)||Ar(r)||ze(r)}function ch(r,e){if(e!=null)return void(r.__key=e);_t(),ac();const t=Qe(),n=ar(),s=""+ah++;n._nodeMap.set(s,r),I(r)?t._dirtyElements.set(s,!0):t._dirtyLeaves.add(s),t._cloneNotNeeded.add(s),t._dirtyType=ku,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){ac();const e=r.getLatest(),t=e.__parent,n=ar(),s=Qe(),i=n._nodeMap,o=s._dirtyElements;t!==null&&function(a,u,c){let d=a;for(;d!==null;){if(c.has(d))return;const f=u.get(d);if(f===void 0)break;c.set(d,!1),d=f.__parent}}(t,i,o);const l=e.__key;s._dirtyType=ku,I(r)?o.set(l,!0):s._dirtyLeaves.add(l)}function lt(r){_t();const e=Qe(),t=e._compositionKey;if(r!==t){if(e._compositionKey=r,t!==null){const n=dt(t);n!==null&&n.getWritable()}if(r!==null){const n=dt(r);n!==null&&n.getWritable()}}}function hr(){return es()?null:Qe()._compositionKey}function dt(r,e){const t=(e||ar())._nodeMap.get(r);return t===void 0?null:t}function Fu(r,e){const t=ui(r,Qe());return t!==void 0?dt(t,e):null}function ui(r,e){return r[`__lexicalKey_${e._key}`]}function en(r,e){let t=r;for(;t!=null;){const n=Fu(t,e);if(n!==null)return n;t=Yn(t)}return null}function ju(r){const e=r._decorators,t=Object.assign({},e);return r._pendingDecorators=t,t}function Ra(r){return r.read(()=>Ge().getTextContent())}function Ge(){return Lu(ar())}function Lu(r){return r._nodeMap.get("root")}function Kt(r){_t();const e=ar();r!==null&&(r.dirty=!0,r.setCachedNodes(null)),e._selection=r}function Hr(r){const e=Qe(),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()?dt("root"):null:dt(t)}function Ma(r,e){return e?r.getTextContentSize():0}function Pu(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 Iu(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function Ou(r){return r.nodeType===xr?r.nodeValue:null}function Go(r,e,t){const n=Nt(e._window);if(n===null)return;const s=n.anchorNode;let{anchorOffset:i,focusOffset:o}=n;if(s!==null){let l=Ou(s);const a=en(s);if(l!==null&&Q(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(lt(null),oi||Vn||jo)i.remove();else{const m=Qe();setTimeout(()=>{m.update(()=>{i.isAttached()&&i.remove()})},20)}return}const u=i.getParent(),c=Zn(),d=i.getTextContentSize(),f=hr(),p=i.getKey();if(i.isToken()||f!==null&&p===f&&!o||H(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=oe();if(!H(g)||t===null||n===null)return void i.setTextContent(l);if(g.setTextNodeRange(i,t,i,n),i.isSegmented()){const m=st(i.getTextContent());i.replace(m),i=m}i.setTextContent(l)}}}function dh(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(Q(o)||I(o)&&o.isInline())&&!o.canInsertTextAfter()}(e):t===e.getTextContentSize()&&(!e.canInsertTextAfter()||!n.canInsertTextAfter()&&!e.isComposing()||s)}function Fa(r){return r==="ArrowLeft"}function ja(r){return r==="ArrowRight"}function vn(r,e){return Mt?r:e}function La(r){return r==="Enter"}function fn(r){return r==="Backspace"}function hn(r){return r==="Delete"}function Pa(r,e,t){return r.toLowerCase()==="a"&&vn(e,t)}function fh(){const r=Ge();Kt(Bu(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=Fs(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&&K(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 Ia(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 Ia(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?Ia(n.getParentOrThrow(),e,n.getIndexWithinParent()+(e?0:1)):s}}return null}function zu(r){const e=di(r).event,t=e&&e.inputType;return t==="insertFromPaste"||t==="insertFromPasteAsQuotation"}function re(r,e,t){return cc(r,e,t)}function ci(r){return!pt(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 hh(r){let e=r.getParentOrThrow();for(;e!==null;){if(Yt(e))return e;e=e.getParentOrThrow()}return e}function Yt(r){return pt(r)||I(r)&&r.isShadowRoot()}function Xt(r){const e=Qe(),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),l=o.constructor;return i!==null?o instanceof i||K(201,i.name,i.getType(),l.name,l.getType(),r.constructor.name,t):o instanceof r.constructor&&l!==r.constructor||K(202,l.name,l.getType(),r.constructor.name,t),o.__key===r.__key&&K(203,r.constructor.name,t,l.name,l.getType()),o}return r}function Ri(r,e){!pt(r.getParent())||I(e)||ze(e)||K(99)}function Mi(r){return(ze(r)||I(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 ph(r,e,t){let n=r._blockCursorElement;if(H(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,f=document.createElement("div");f.contentEditable="false",f.setAttribute("data-lexical-cursor","true");let p=d.blockCursor;if(p!==void 0){if(typeof p=="string"){const g=Fs(p);p=d.blockCursor=g}p!==void 0&&f.classList.add(...p)}return f}(r._config)),e.style.caretColor="transparent",void(a===null?u.appendChild(n):u.insertBefore(n,a))}}n!==null&&Qo(n,r,e)}function Nt(r){return $t?(r||window).getSelection():null}function gh(r){return or(r)&&r.tagName==="A"}function or(r){return r.nodeType===1}function Oa(r){return r.nodeType===11}function Xi(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 Os(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(ze(r)&&!r.isInline())return!0;if(!I(r)||Yt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||Q(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 mh(){return Qe()}const za=new WeakMap,yh=new Map;function xh(r){if(!r._readOnly&&r.isEmpty())return yh;r._readOnly||K(192);let e=za.get(r);if(!e){e=new Map,za.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 Xo(r){const e=r.constructor.clone(r);return e.afterCloneFrom(r),e}function Jo(r,e){const t=(parseInt(r.style.paddingInlineStart,10)||0)/40;e.setIndent(t)}function bh(r){return r.__lexicalUnmanaged===!0}function $u(r,e,t,n,s,i){let o=r.getFirstChild();for(;o!==null;){const l=o.__key;o.__parent===e&&(I(o)&&$u(o,l,t,n,s,i),t.has(l)||i.delete(l),s.push(l)),o=o.getNextSibling()}}let yr,gt,In,fi,Ji,Zi,Rr,Ot,eo,On,it="",ht="",Ut=null,Ft="",rr="",qu=!1,zn=!1,_s=null;function zs(r,e){const t=Rr.get(r);if(e!==null){const n=no(r);n.parentNode===e&&e.removeChild(n)}if(Ot.has(r)||gt._keyToDOMMap.delete(r),I(t)){const n=qs(t,Rr);to(n,0,n.length-1,null)}t!==void 0&&Yo(On,In,fi,t,"destroyed")}function to(r,e,t,n){let s=e;for(;s<=t;++s){const i=r[s];i!==void 0&&zs(i,n)}}function _r(r,e){r.setProperty("text-align",e)}const vh="40px";function Uu(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")||vh;r.style.setProperty("padding-inline-start",e===0?"":`calc(${e} * ${n})`)}function Wu(r,e){const t=r.style;e===0?_r(t,""):e===Po?_r(t,"left"):e===Io?_r(t,"center"):e===Oo?_r(t,"right"):e===zo?_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&&K(60);const n=t.createDOM(yr,gt);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,gt),Q(t)?n.setAttribute("data-lexical-text","true"):ze(t)&&n.setAttribute("data-lexical-decorator","true"),I(t)){const s=t.__indent,i=t.__size;if(s!==0&&Uu(n,s),i!==0){const l=i-1;(function(a,u,c,d){const f=ht;ht="",ro(a,c,0,u,c.getDOMSlot(d)),Vu(c,d),ht=f})(qs(t,Ot),l,t,n)}const o=t.__format;o!==0&&Wu(n,o),t.isInline()||Hu(null,t,n),ci(t)&&(it+=sr,rr+=sr)}else{const s=t.getTextContent();if(ze(t)){const i=t.decorate(gt,yr);i!==null&&Gu(r,i),n.contentEditable="false"}else Q(t)&&(t.isDirectionless()||(ht+=s));it+=s,rr+=s}return e!==null&&e.insertChild(n),Yo(On,In,fi,t,"created"),n}function ro(r,e,t,n,s){const i=it;it="";let o=t;for(;o<=n;++o){$s(r[o],s);const l=Ot.get(r[o]);l!==null&&Q(l)&&(Ut===null&&(Ut=l.getFormat()),Ft===""&&(Ft=l.getStyle()))}ci(e)&&(it+=sr),s.element.__lexicalTextContent=it,it=i+it}function $a(r,e){if(r){const t=r.__last;if(t){const n=e.get(t);if(n)return Ar(n)?"line-break":ze(n)&&n.isInline()?"decorator":null}return"empty"}return null}function Hu(r,e,t){const n=$a(r,Rr),s=$a(e,Ot);n!==s&&e.getDOMSlot(t).setManagedLineBreak(s)}function Vu(r,e){const t=e.__lexicalDirTextContent||"",n=e.__lexicalDir||"";if(t!==ht||n!==_s){const i=ht==="",o=i?_s:(s=ht,Yf.test(s)?"rtl":Qf.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=Fs(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=Fs(c);c=a[o]=d}c!==void 0&&l.add(...c)}e.dir=o}zn||(r.getWritable().__dir=o)}_s=o,e.__lexicalDirTextContent=ht,e.__lexicalDir=o}var s}function _h(r,e,t){const n=ht;var s;ht="",Ut=null,Ft="",function(i,o,l){const a=it,u=i.__size,c=o.__size;it="";const d=l.element;if(u===1&&c===1){const f=i.__first,p=o.__first;if(f===p)_n(f,d);else{const m=no(f),x=$s(p,null);try{d.replaceChild(x,m)}catch(_){if(typeof _=="object"&&_!=null){const y=`${_.toString()} Parent: ${d.tagName}, new child: {tag: ${x.tagName} key: ${p}}, old child: {tag: ${m.tagName}, key: ${f}}.`;throw new Error(y)}throw _}zs(f,null)}const g=Ot.get(p);Q(g)&&(Ut===null&&(Ut=g.getFormat()),Ft===""&&(Ft=g.getStyle()))}else{const f=qs(i,Rr),p=qs(o,Ot);if(f.length!==u&&K(227),p.length!==c&&K(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(f,0,u-1,g?null:d),g&&(d.textContent="")}}else(function(g,m,x,_,y,w){const C=_-1,D=y-1;let E,v,k=w.getFirstChild(),M=0,T=0;for(;M<=C&&T<=D;){const j=m[M],S=x[T];if(j===S)k=Fi(_n(S,w.element)),M++,T++;else{E===void 0&&(E=new Set(m)),v===void 0&&(v=new Set(x));const F=v.has(j),O=E.has(S);if(F)if(O){const V=Is(gt,S);V===k?k=Fi(_n(S,w.element)):(w.withBefore(k).insertChild(V),_n(S,w.element)),M++,T++}else $s(S,w.withBefore(k)),T++;else k=Fi(no(j)),zs(j,w.element),M++}const B=Ot.get(S);B!==null&&Q(B)&&(Ut===null&&(Ut=B.getFormat()),Ft===""&&(Ft=B.getStyle()))}const N=M>C,R=T>D;if(N&&!R){const j=x[D+1],S=j===void 0?null:gt.getElementByKey(j);ro(x,g,T,D,w.withBefore(S))}else R&&!N&&to(m,M,C,w.element)})(o,f,p,u,c,l)}ci(o)&&(it+=sr),d.__lexicalTextContent=it,it=a+it}(r,e,e.getDOMSlot(t)),Vu(e,t),tn(s=e)&&Ut!=null&&Ut!==s.__textFormat&&!zn&&(s.setTextFormat(Ut),s.setTextStyle(Ft)),function(i){tn(i)&&Ft!==""&&Ft!==i.__textStyle&&!zn&&i.setTextStyle(Ft)}(e),ht=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=Rr.get(r);let n=Ot.get(r);t!==void 0&&n!==void 0||K(61);const s=qu||Zi.has(r)||Ji.has(r),i=Is(gt,r);if(t===n&&!s){if(I(t)){const o=i.__lexicalTextContent;o!==void 0&&(it+=o,rr+=o);const l=i.__lexicalDirTextContent;l!==void 0&&(ht+=l)}else{const o=t.getTextContent();Q(t)&&!t.isDirectionless()&&(ht+=o),rr+=o,it+=o}return i}if(t!==n&&s&&Yo(On,In,fi,n,"updated"),n.updateDOM(t,i,yr)){const o=$s(r,null);return e===null&&K(62),e.replaceChild(o,i),zs(r,null),o}if(I(t)&&I(n)){const o=n.__indent;o!==t.__indent&&Uu(i,o);const l=n.__format;l!==t.__format&&Wu(i,l),s&&(_h(t,n,i),pt(n)||n.isInline()||Hu(t,n,i)),ci(n)&&(it+=sr,rr+=sr)}else{const o=n.getTextContent();if(ze(n)){const l=n.decorate(gt,yr);l!==null&&Gu(r,l)}else Q(n)&&!n.isDirectionless()&&(ht+=o);it+=o,rr+=o}if(!zn&&pt(n)&&n.__cachedText!==rr){const o=n.getWritable();o.__cachedText=rr,n=o}return i}function Gu(r,e){let t=gt._pendingDecorators;const n=gt._decorators;if(t===null){if(n[r]===e)return;t=ju(gt)}t[r]=e}function Fi(r){let e=r.nextSibling;return e!==null&&e===gt._blockCursorElement&&(e=e.nextSibling),e}function wh(r,e,t,n,s,i){it="",rr="",ht="",qu=n===Zr,_s=null,gt=t,yr=t._config,In=t._nodes,fi=gt._listeners.mutation,Ji=s,Zi=i,Rr=r._nodeMap,Ot=e._nodeMap,zn=e._readOnly,eo=new Map(t._keyToDOMMap);const o=new Map;return On=o,_n("root",null),gt=void 0,In=void 0,Ji=void 0,Zi=void 0,Rr=void 0,Ot=void 0,yr=void 0,eo=void 0,On=void 0,o}function no(r){const e=eo.get(r);return e===void 0&&K(75,r),e}const er=Object.freeze({}),so=30,io=[["keydown",function(r,e){if(Nn=r.timeStamp,Ku=r.key,e.isComposing())return;const{key:t,shiftKey:n,ctrlKey:s,metaKey:i,altKey:o}=r;if(!re(e,Df,r)&&t!=null){if(function(l,a,u,c){return ja(l)&&!a&&!c&&!u}(t,s,o,i))re(e,pu,r);else if(function(l,a,u,c,d){return ja(l)&&!c&&!u&&(a||d)}(t,s,n,o,i))re(e,Af,r);else if(function(l,a,u,c){return Fa(l)&&!a&&!c&&!u}(t,s,o,i))re(e,gu,r);else if(function(l,a,u,c,d){return Fa(l)&&!c&&!u&&(a||d)}(t,s,n,o,i))re(e,Tf,r);else if(function(l,a,u){return function(c){return c==="ArrowUp"}(l)&&!a&&!u}(t,s,i))re(e,mu,r);else if(function(l,a,u){return function(c){return c==="ArrowDown"}(l)&&!a&&!u}(t,s,i))re(e,yu,r);else if(function(l,a){return La(l)&&a}(t,n))Bn=!0,re(e,Ns,r);else if(function(l){return l===" "}(t))re(e,Nf,r);else if(function(l,a){return Mt&&a&&l.toLowerCase()==="o"}(t,s))r.preventDefault(),Bn=!0,re(e,Kr,!0);else if(function(l,a){return La(l)&&!a}(t,n))Bn=!1,re(e,Ns,r);else if(function(l,a,u,c){return Mt?!a&&!u&&(fn(l)||l.toLowerCase()==="h"&&c):!(c||a||u)&&fn(l)}(t,o,i,s))fn(t)?re(e,xu,r):(r.preventDefault(),re(e,Er,!0));else if(function(l){return l==="Escape"}(t))re(e,bu,r);else if(function(l,a,u,c,d){return Mt?!(u||c||d)&&(hn(l)||l.toLowerCase()==="d"&&a):!(a||c||d)&&hn(l)}(t,s,n,o,i))hn(t)?re(e,vu,r):(r.preventDefault(),re(e,Er,!1));else if(function(l,a,u){return fn(l)&&(Mt?a:u)}(t,o,s))r.preventDefault(),re(e,jn,!0);else if(function(l,a,u){return hn(l)&&(Mt?a:u)}(t,o,s))r.preventDefault(),re(e,jn,!1);else if(function(l,a){return Mt&&a&&fn(l)}(t,i))r.preventDefault(),re(e,Ln,!0);else if(function(l,a){return Mt&&a&&hn(l)}(t,i))r.preventDefault(),re(e,Ln,!1);else if(function(l,a,u,c){return l.toLowerCase()==="b"&&!a&&vn(u,c)}(t,o,i,s))r.preventDefault(),re(e,It,"bold");else if(function(l,a,u,c){return l.toLowerCase()==="u"&&!a&&vn(u,c)}(t,o,i,s))r.preventDefault(),re(e,It,"underline");else if(function(l,a,u,c){return l.toLowerCase()==="i"&&!a&&vn(u,c)}(t,o,i,s))r.preventDefault(),re(e,It,"italic");else if(function(l,a,u,c){return l==="Tab"&&!a&&!u&&!c}(t,o,s,i))re(e,Bf,r);else if(function(l,a,u,c){return l.toLowerCase()==="z"&&!a&&vn(u,c)}(t,n,i,s))r.preventDefault(),re(e,Ro,void 0);else if(function(l,a,u,c){return Mt?l.toLowerCase()==="z"&&u&&a:l.toLowerCase()==="y"&&c||l.toLowerCase()==="z"&&c&&a}(t,n,i,s))r.preventDefault(),re(e,Mo,void 0);else{const l=e._editorState._selection;l===null||H(l)?!mr&&Pa(t,i,s)&&(r.preventDefault(),re(e,Yi,r)):function(a,u,c,d){return!u&&a.toLowerCase()==="c"&&(Mt?c:d)}(t,n,i,s)?(r.preventDefault(),re(e,ii,r)):function(a,u,c,d){return!u&&a.toLowerCase()==="x"&&(Mt?c:d)}(t,n,i,s)?(r.preventDefault(),re(e,Fo,r)):Pa(t,i,s)&&(r.preventDefault(),re(e,Yi,r))}(function(l,a,u,c){return l||a||u||c})(s,n,o,i)&&re(e,zf,r)}}],["pointerdown",function(r,e){const t=r.target,n=r.pointerType;t instanceof Node&&n!=="touch"&&kt(e,()=>{ze(en(t))||(ao=!0)})}],["compositionstart",function(r,e){kt(e,()=>{const t=oe();if(H(t)&&!e.isComposing()){const n=t.anchor,s=t.anchor.getNode();lt(n.key),(r.timeStamp<Nn+so||n.type==="element"||!t.isCollapsed()||s.getFormat()!==t.format||Q(s)&&s.getStyle()!==t.style)&&re(e,Yr,Kf)}})}],["compositionend",function(r,e){mr?gn=!0:kt(e,()=>{ji(e,r.data)})}],["input",function(r,e){r.stopPropagation(),kt(e,()=>{const t=oe(),n=r.data,s=Ju(r);if(n!=null&&H(t)&&Xu(t,s,n,r.timeStamp,!1)){gn&&(ji(e,n),gn=!1);const i=t.anchor.getNode(),o=Nt(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()&&Q(i)&&o.anchorNode!==null&&i.getTextContent().slice(0,a)+n+i.getTextContent().slice(a+u)===Ou(o.anchorNode)||re(e,Yr,n);const c=n.length;mr&&c>1&&r.inputType==="insertCompositionText"&&!e.isComposing()&&(t.anchor.offset-=c),oi||Vn||jo||!e.isComposing()||(Nn=0,lt(null))}else Go(!1,e,n!==null?n:void 0),gn&&(ji(e,n||void 0),gn=!1);_t(),Tu(Qe())}),Wr=null}],["click",function(r,e){kt(e,()=>{const t=oe(),n=Nt(e._window),s=Zn();if(n){if(H(t)){const i=t.anchor,o=i.getNode();i.type==="element"&&i.offset===0&&t.isCollapsed()&&!pt(o)&&Ge().getChildrenSize()===1&&o.getTopLevelElementOrThrow().isEmpty()&&s!==null&&t.is(s)?(n.removeAllRanges(),t.dirty=!0):r.detail===3&&!t.isCollapsed()&&o!==t.focus.getNode()&&(I(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)&&Kt(ea(s,n,e,r))}}}re(e,hu,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=Ju(t);s==="deleteCompositionText"||mr&&zu(n)||s!=="insertCompositionText"&&kt(n,()=>{const o=oe();if(s==="deleteContentBackward"){if(o===null){const p=Zn();if(!H(p))return;Kt(p.clone())}if(H(o)){const p=o.anchor.key===o.focus.key;if(l=t.timeStamp,Ku==="MediaLast"&&l<Nn+so&&n.isComposing()&&p){if(lt(null),Nn=0,setTimeout(()=>{kt(n,()=>{lt(null)})},so),H(o)){const g=o.anchor.getNode();g.markDirty(),o.format=g.getFormat(),Q(g)||K(142),o.style=g.getStyle()}}else{lt(null),t.preventDefault();const g=o.anchor.getNode(),m=g.getTextContent(),x=g.canInsertTextAfter(),_=o.anchor.offset===0&&o.focus.offset===m.length;Uf&&p&&!_&&x||re(n,Er,!0)}return}}var l;if(!H(o))return;const a=t.data;Wr!==null&&Go(!1,n,Wr),o.dirty&&Wr===null||!o.isCollapsed()||pt(o.anchor.getNode())||i===null||o.applyDOMRange(i),Wr=null;const u=o.anchor,c=o.focus,d=u.getNode(),f=c.getNode();if(s!=="insertText"&&s!=="insertTranspose")switch(t.preventDefault(),s){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":re(n,Yr,t);break;case"insertFromComposition":lt(null),re(n,Yr,t);break;case"insertLineBreak":lt(null),re(n,Kr,!1);break;case"insertParagraph":lt(null),Bn&&!Vn?(Bn=!1,re(n,Kr,!1)):re(n,Fn,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":re(n,si,t);break;case"deleteByComposition":(function(p,g){return p!==g||I(p)||I(g)||!p.isToken()||!g.isToken()})(d,f)&&re(n,Ki,t);break;case"deleteByDrag":case"deleteByCut":re(n,Ki,t);break;case"deleteContent":re(n,Er,!1);break;case"deleteWordBackward":re(n,jn,!0);break;case"deleteWordForward":re(n,jn,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":re(n,Ln,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":re(n,Ln,!1);break;case"formatStrikeThrough":re(n,It,"strikethrough");break;case"formatBold":re(n,It,"bold");break;case"formatItalic":re(n,It,"italic");break;case"formatUnderline":re(n,It,"underline");break;case"historyUndo":re(n,Ro,void 0);break;case"historyRedo":re(n,Mo,void 0)}else{if(a===`
86
- `)t.preventDefault(),re(n,Kr,!1);else if(a===sr)t.preventDefault(),re(n,Fn,void 0);else if(a==null&&t.dataTransfer){const p=t.dataTransfer.getData("text/plain");t.preventDefault(),o.insertRawText(p)}else a!=null&&Xu(o,i,a,t.timeStamp,!0)?(t.preventDefault(),re(n,Yr,a)):Wr=a;Yu=t.timeStamp}})}(r,e)]);let Nn=0,Ku=null,Yu=0,Wr=null;const Us=new WeakMap;let oo=!1,ao=!1,Bn=!1,gn=!1,Qu=[0,"",0,"root",0];function Xu(r,e,t,n,s){const i=r.anchor,o=r.focus,l=i.getNode(),a=Qe(),u=Nt(a._window),c=u!==null?u.anchorNode:null,d=i.key,f=a.getElementByKey(d),p=t.length;return d!==o.key||!Q(l)||(!s&&(!Bs||Yu<n+50)||l.isDirty()&&p<2||Pu(t))&&i.offset!==o.offset&&!l.isComposing()||Cr(l)||l.isDirty()&&p>1||(s||!Bs)&&f!==null&&!l.isComposing()&&c!==js(f)||u!==null&&e!==null&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||l.getFormat()!==r.format||l.getStyle()!==r.style||dh(r,l)}function qa(r,e){return r!==null&&r.nodeValue!==null&&r.nodeType===xr&&e!==0&&e!==r.nodeValue.length}function Ua(r,e,t){const{anchorNode:n,anchorOffset:s,focusNode:i,focusOffset:o}=r;oo&&(oo=!1,qa(n,s)&&qa(i,o))||kt(e,()=>{if(!t)return void Kt(null);if(!Kn(e,n,i))return;const l=oe();if(H(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(),[f,p,g,m,x]=Qu,_=Ge(),y=e.isComposing()===!1&&_.getTextContent()==="";if(d<x+200&&a.offset===g&&a.key===m)l.format=f,l.style=p;else if(a.type==="text")Q(u)||K(141),l.format=u.getFormat(),l.style=u.getStyle();else if(a.type==="element"&&!y){const w=a.getNode();l.style="",w instanceof on&&w.getChildrenSize()===0?(l.format=w.getTextFormat(),l.style=w.getTextStyle()):l.format=0}}else{const c=a.key,d=l.focus.key,f=l.getNodes(),p=f.length,g=l.isBackward(),m=g?o:s,x=g?s:o,_=g?d:c,y=g?c:d;let w=Gf,C=!1;for(let D=0;D<p;D++){const E=f[D],v=E.getTextContentSize();if(Q(E)&&v!==0&&!(D===0&&E.__key===_&&m===v||D===p-1&&E.__key===y&&x===0)&&(C=!0,w&=E.getFormat(),w===0))break}l.format=C?w:0}}re(e,Bo,void 0)})}function Ju(r){if(!r.getTargetRanges)return null;const e=r.getTargetRanges();return e.length===0?null:e[0]}function ji(r,e){const t=r._compositionKey;if(lt(null),t!==null&&e!=null){if(e===""){const n=dt(t),s=js(r.getElementByKey(t));return void(s!==null&&s.nodeValue!==null&&Q(n)&&Ko(n,s.nodeValue,null,null,!0))}if(e[e.length-1]===`
87
- `){const n=oe();if(H(n)){const s=n.focus;return n.anchor.set(s.key,s.offset,s.type),void re(r,Ns,null)}}}Go(!0,r,e)}function Zu(r){let e=r.__lexicalEventHandles;return e===void 0&&(e=[],r.__lexicalEventHandles=e),e}const Qr=new Map;function ec(r){const e=r.target,t=Nt(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,kt(n,()=>{const u=Zn(),c=t.anchorNode;if(c===null)return;const d=c.nodeType;d!==Gn&&d!==xr||Kt(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&&Ua(t,a,!1),Ua(t,n,!0),n!==i?Qr.set(o,n):l&&Qr.delete(o)}function Wa(r){r._lexicalHandled=!0}function Ha(r){return r._lexicalHandled===!0}function Ch(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",ec);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&&K(198);const i=Zu(r);for(let o=0;o<i.length;o++)i[o]();r.__lexicalEventHandles=[]}function lo(r,e,t){_t();const n=r.__key,s=r.getParent();if(s===null)return;const i=function(l){const a=oe();if(!H(a)||!I(l))return a;const{anchor:u,focus:c}=a,d=u.getNode(),f=c.getNode();return Tn(d,l)&&u.set(l.__key,0,"element"),Tn(f,l)&&c.set(l.__key,0,"element"),a}(r);let o=!1;if(H(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 Wt(i)&&e&&r.isSelected()&&r.selectPrevious();if(H(i)&&e&&!o){const l=r.getIndexWithinParent();Dr(r),Ws(i,s,l,-1)}else Dr(r);t||Yt(s)||s.canBeEmpty()||!s.isEmpty()||lo(s,e),e&&pt(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,ch(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=dt(e);if(t===null)break;e=t.__parent}return!1}isSelected(e){const t=e||oe();if(t==null)return!1;const n=t.getNodes().some(s=>s.__key===this.__key);if(Q(this))return n;if(H(t)&&t.anchor.type==="element"&&t.focus.type==="element"){if(t.isCollapsed())return!1;const s=this.getParent();if(ze(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:dt(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(Yt(t))return I(e)||e===this&&ze(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:dt(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:dt(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();I(this)&&t.unshift(this),I(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=I(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&&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=Qe()._dirtyLeaves;return e!==null&&e.has(this.__key)}getLatest(){const e=dt(this.__key);return e===null&&K(113),e}getWritable(){_t();const e=ar(),t=Qe(),n=e._nodeMap,s=this.__key,i=this.getLatest(),o=t._cloneNotNeeded,l=oe();if(l!==null&&l.setCachedNodes(null),o.has(s))return Ps(i),i;const a=Xo(i);return o.add(s),Ps(a),n.set(s,a),a}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){_t();let n=oe();n!==null&&(n=n.clone()),Ri(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(),f=s.__prev,p=s.__next,g=s.__parent;if(lo(s,!1,!0),c===null?a.__first=o:c.getWritable().__next=o,l.__prev=f,d===null?a.__last=o:d.getWritable().__prev=o,l.__next=p,l.__parent=g,a.__size=u,t&&(I(this)&&I(l)||K(139),this.getChildren().forEach(m=>{l.append(m)})),H(n)){Kt(n);const m=n.anchor,x=n.focus;m.key===i&&Ya(m,l),x.key===i&&Ya(x,l)}return hr()===i&&lt(o),l}insertAfter(e,t=!0){_t(),Ri(this,e);const n=this.getWritable(),s=e.getWritable(),i=s.getParent(),o=oe();let l=!1,a=!1;if(i!==null){const p=e.getIndexWithinParent();if(Dr(s),H(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,f=n.__next;if(u===null?c.__last=d:u.getWritable().__prev=d,c.__size++,n.__next=d,s.__next=f,s.__prev=n.__key,s.__parent=n.__parent,t&&H(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){_t(),Ri(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=oe();return t&&H(c)&&Ws(c,this.getParentOrThrow(),u),e}isParentRequired(){return!1}createParentElementNode(){return rt()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(e,t){_t();const n=this.getPreviousSibling(),s=this.getParentOrThrow();if(n===null)return s.select(0,0);if(I(n))return n.select();if(!Q(n)){const i=n.getIndexWithinParent()+1;return s.select(i,i)}return n.select(e,t)}selectNext(e,t){_t();const n=this.getNextSibling(),s=this.getParentOrThrow();if(n===null)return s.select();if(I(n))return n.select(0,0);if(!Q(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&&Os(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&&Os(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:Sh,priority:0}}}static importJSON(e){return Mr()}exportJSON(){return{type:"linebreak",version:1}}}function Sh(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 tc(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&Rs;o!==void 0&&(t&Ms&&t&Rs?(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 rc(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 f=c.length,p=d.length;let g=0,m=0;for(;g<f&&g<p&&c[g]===d[g];)g++;for(;m+g<f&&m+g<p&&c[f-m-1]===d[p-m-1];)m++;return[g,f-g-m,d.slice(g,p-m)]}(o,i);a!==0&&n.deleteData(l,a),n.insertData(l,u)}else n.nodeValue=i}}function Va(r,e,t,n,s,i){rc(s,r,e);const o=i.theme.text;o!==void 0&&tc(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 eh[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)),Va(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&&K(48);const x=document.createElement(c);return Va(x,this,0,o,s,n),t.replaceChild(x,m),!1}let d=t;a!==null&&l!==null&&(d=t.firstChild,d==null&&K(49)),rc(s,d,this);const f=n.theme.text;f!==void 0&&i!==o&&tc(0,i,o,d,f);const p=e.__style,g=this.__style;return p!==g&&(t.style.cssText=g),!1}static importDOM(){return{"#text":()=>({conversion:Ah,priority:0}),b:()=>({conversion:Eh,priority:0}),code:()=>({conversion:ur,priority:0}),em:()=>({conversion:ur,priority:0}),i:()=>({conversion:ur,priority:0}),s:()=>({conversion:ur,priority:0}),span:()=>({conversion:kh,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=st(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)||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"?Xf[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=Zf[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){_t();let n=e,s=t;const i=oe(),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(!H(i))return ic(l,n,l,s,"text","text");{const a=hr();a!==i.anchor.key&&a!==i.focus.key||lt(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=oe();if(s&&H(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){_t();const t=this.getLatest(),n=t.getTextContent(),s=t.__key,i=hr(),o=new Set(e),l=[],a=n.length;let u="";for(let D=0;D<a;D++)u!==""&&o.has(D)&&(l.push(u),u=""),u+=n[D];u!==""&&l.push(u);const c=l.length;if(c===0)return[];if(l[0]===n)return[t];const d=l[0],f=t.getParent();let p;const g=t.getFormat(),m=t.getStyle(),x=t.__detail;let _=!1;t.isSegmented()?(p=st(d),p.__format=g,p.__style=m,p.__detail=x,_=!0):(p=t.getWritable(),p.__text=d);const y=oe(),w=[p];let C=d.length;for(let D=1;D<c;D++){const E=l[D],v=E.length,k=st(E).getWritable();k.__format=g,k.__style=m,k.__detail=x;const M=k.__key,T=C+v;if(H(y)){const N=y.anchor,R=y.focus;N.key===s&&N.type==="text"&&N.offset>C&&N.offset<=T&&(N.key=M,N.offset-=C,y.dirty=!0),R.key===s&&R.type==="text"&&R.offset>C&&R.offset<=T&&(R.key=M,R.offset-=C,y.dirty=!0)}i===s&&lt(M),C=T,w.push(k)}if(f!==null){(function(v){const k=v.getPreviousSibling(),M=v.getNextSibling();k!==null&&Ps(k),M!==null&&Ps(M)})(this);const D=f.getWritable(),E=this.getIndexWithinParent();_?(D.splice(E,0,w),this.remove()):D.splice(E,1,w),H(y)&&Ws(y,f,E,c-1)}return w}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;hr()===s&&lt(n);const l=oe();if(H(l)){const d=l.anchor,f=l.focus;d!==null&&d.key===s&&(rl(d,t,n,e,o),l.dirty=!0),f!==null&&f.key===s&&(rl(f,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 kh(r){return{forChild:Zo(r.style),node:null}}function Eh(r){const e=r,t=e.style.fontWeight==="normal";return{forChild:Zo(e.style,t?void 0:"bold"),node:null}}const Ga=new WeakMap;function Dh(r){return r.nodeName==="PRE"||r.nodeType===Gn&&r.style!==void 0&&r.style.whiteSpace!==void 0&&r.style.whiteSpace.startsWith("pre")}function Ah(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=Ga.get(i))===void 0&&!Dh(i);)o.push(i),i=i.parentNode;const l=s===void 0?i:s;for(let a=0;a<o.length;a++)Ga.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===`
85
+ `,Kf=mr?" ":ai,Eu="֑-߿יִ-﷽ﹰ-ﻼ",Du="A-Za-zÀ-ÖØ-öø-ʸ̀-֐ࠀ-῿‎Ⰰ-﬜︀-﹯﻽-￿",Yf=new RegExp("^[^"+Du+"]*["+Eu+"]"),Qf=new RegExp("^[^"+Eu+"]*["+Du+"]"),Br={bold:1,code:16,highlight:Lo,italic:2,strikethrough:Rs,subscript:32,superscript:64,underline:Ms},Xf={directionless:1,unmergeable:2},Da={center:Io,end:qo,justify:zo,left:Po,right:Oo,start:$o},Jf={[Io]:"center",[qo]:"end",[zo]:"justify",[Po]:"left",[Oo]:"right",[$o]:"start"},Zf={normal:0,segmented:2,token:1},eh={[Wf]:"normal",[Vf]:"segmented",[Hf]:"token"};function th(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var K=th(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 Fs(...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 rh=100;let Qi=!1,Uo=0;function nh(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 sh(r,e,t){const n=Nt(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 ih(r,e,t){if(V(r)){const n=r.anchor.getNode();if(n.is(t)&&r.format!==n.getFormat())return!1}return e.nodeType===xr&&t.isAttached()}function oh(r,e,t,n){for(let s=r;s&&!bh(s);s=Yn(s)){const i=ui(s,e);if(i!==void 0){const o=dt(i,t);if(o)return ze(o)?void 0:[s,o]}else if(s===n)return[n,Lu(t)]}}function Au(r,e,t){Qi=!0;const n=performance.now()-Uo>rh;try{kt(r,()=>{const s=oe()||function(f){return f.getEditorState().read(()=>{const p=oe();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 f=0;f<e.length;f++){const p=e[f],g=p.type,m=p.target,x=oh(m,r,l,o);if(!x)continue;const[v,y]=x;if(g==="characterData")n&&X(y)&&ih(s,m,y)&&sh(m,y,r);else if(g==="childList"){u=!0;const _=p.addedNodes;for(let k=0;k<_.length;k++){const w=_[k],D=Fu(w),j=w.parentNode;if(j!=null&&w!==a&&D===null&&!Bi(w,j,r)){if(mr){const B=w.innerText||w.nodeValue;B&&(c+=B)}j.removeChild(w)}}const S=p.removedNodes,E=S.length;if(E>0){let k=0;for(let w=0;w<E;w++){const D=S[w];(Bi(D,m,r)||a===D)&&(m.appendChild(D),k++)}E!==k&&i.set(v,y)}}}if(i.size>0)for(const[f,p]of i)p.reconcileObservedMutation(f,r);const d=t.takeRecords();if(d.length>0){for(let f=0;f<d.length;f++){const p=d[f],g=p.addedNodes,m=p.target;for(let x=0;x<g.length;x++){const v=g[x],y=v.parentNode;y==null||v.nodeName!=="BR"||Bi(v,m,r)||y.removeChild(v)}}t.takeRecords()}s!==null&&(u&&(s.dirty=!0,Kt(s)),mr&&zu(r)&&s.insertRawText(c))})}finally{Qi=!1}}function Tu(r){const e=r._observer;e!==null&&Au(r,e.takeRecords(),e)}function Nu(r){(function(e){Uo===0&&di(e).addEventListener("textInput",nh,!0)})(r),r._observer=new MutationObserver((e,t)=>{Au(r,e,t)})}function Aa(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 Ta(r,e){const t=r.mergeWithSibling(e),n=Qe()._normalizedNodes;return n.add(r.__key),n.add(e.__key),t}function Na(r){let e,t,n=r;if(n.__text!==""||!n.isSimpleText()||n.isUnmergeable()){for(;(e=n.getPreviousSibling())!==null&&X(e)&&e.isSimpleText()&&!e.isUnmergeable();){if(e.__text!==""){if(Aa(e,n)){n=Ta(e,n);break}break}e.remove()}for(;(t=n.getNextSibling())!==null&&X(t)&&t.isSimpleText()&&!t.isUnmergeable();){if(t.__text!==""){if(Aa(n,t)){n=Ta(n,t);break}break}t.remove()}}else n.remove()}function Bu(r){return Ba(r.anchor),Ba(r.focus),r}function Ba(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),X(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 ah=1;const lh=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 ze(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 uh(r){return r.nodeType===xr}function js(r){let e=r;for(;e!=null;){if(uh(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 Mu(r){return X(r)||Ar(r)||ze(r)}function ch(r,e){if(e!=null)return void(r.__key=e);_t(),ac();const t=Qe(),n=ar(),s=""+ah++;n._nodeMap.set(s,r),O(r)?t._dirtyElements.set(s,!0):t._dirtyLeaves.add(s),t._cloneNotNeeded.add(s),t._dirtyType=ku,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){ac();const e=r.getLatest(),t=e.__parent,n=ar(),s=Qe(),i=n._nodeMap,o=s._dirtyElements;t!==null&&function(a,u,c){let d=a;for(;d!==null;){if(c.has(d))return;const f=u.get(d);if(f===void 0)break;c.set(d,!1),d=f.__parent}}(t,i,o);const l=e.__key;s._dirtyType=ku,O(r)?o.set(l,!0):s._dirtyLeaves.add(l)}function lt(r){_t();const e=Qe(),t=e._compositionKey;if(r!==t){if(e._compositionKey=r,t!==null){const n=dt(t);n!==null&&n.getWritable()}if(r!==null){const n=dt(r);n!==null&&n.getWritable()}}}function hr(){return es()?null:Qe()._compositionKey}function dt(r,e){const t=(e||ar())._nodeMap.get(r);return t===void 0?null:t}function Fu(r,e){const t=ui(r,Qe());return t!==void 0?dt(t,e):null}function ui(r,e){return r[`__lexicalKey_${e._key}`]}function en(r,e){let t=r;for(;t!=null;){const n=Fu(t,e);if(n!==null)return n;t=Yn(t)}return null}function ju(r){const e=r._decorators,t=Object.assign({},e);return r._pendingDecorators=t,t}function Ra(r){return r.read(()=>Ge().getTextContent())}function Ge(){return Lu(ar())}function Lu(r){return r._nodeMap.get("root")}function Kt(r){_t();const e=ar();r!==null&&(r.dirty=!0,r.setCachedNodes(null)),e._selection=r}function Hr(r){const e=Qe(),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()?dt("root"):null:dt(t)}function Ma(r,e){return e?r.getTextContentSize():0}function Pu(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 Iu(){return Math.random().toString(36).replace(/[^a-z]+/g,"").substr(0,5)}function Ou(r){return r.nodeType===xr?r.nodeValue:null}function Go(r,e,t){const n=Nt(e._window);if(n===null)return;const s=n.anchorNode;let{anchorOffset:i,focusOffset:o}=n;if(s!==null){let l=Ou(s);const a=en(s);if(l!==null&&X(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(lt(null),oi||Vn||jo)i.remove();else{const m=Qe();setTimeout(()=>{m.update(()=>{i.isAttached()&&i.remove()})},20)}return}const u=i.getParent(),c=Zn(),d=i.getTextContentSize(),f=hr(),p=i.getKey();if(i.isToken()||f!==null&&p===f&&!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=oe();if(!V(g)||t===null||n===null)return void i.setTextContent(l);if(g.setTextNodeRange(i,t,i,n),i.isSegmented()){const m=st(i.getTextContent());i.replace(m),i=m}i.setTextContent(l)}}}function dh(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(X(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 ja(r){return r==="ArrowRight"}function vn(r,e){return Mt?r:e}function La(r){return r==="Enter"}function fn(r){return r==="Backspace"}function hn(r){return r==="Delete"}function Pa(r,e,t){return r.toLowerCase()==="a"&&vn(e,t)}function fh(){const r=Ge();Kt(Bu(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=Fs(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&&K(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 Ia(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 Ia(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?Ia(n.getParentOrThrow(),e,n.getIndexWithinParent()+(e?0:1)):s}}return null}function zu(r){const e=di(r).event,t=e&&e.inputType;return t==="insertFromPaste"||t==="insertFromPasteAsQuotation"}function re(r,e,t){return cc(r,e,t)}function ci(r){return!pt(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 hh(r){let e=r.getParentOrThrow();for(;e!==null;){if(Yt(e))return e;e=e.getParentOrThrow()}return e}function Yt(r){return pt(r)||O(r)&&r.isShadowRoot()}function Xt(r){const e=Qe(),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),l=o.constructor;return i!==null?o instanceof i||K(201,i.name,i.getType(),l.name,l.getType(),r.constructor.name,t):o instanceof r.constructor&&l!==r.constructor||K(202,l.name,l.getType(),r.constructor.name,t),o.__key===r.__key&&K(203,r.constructor.name,t,l.name,l.getType()),o}return r}function Ri(r,e){!pt(r.getParent())||O(e)||ze(e)||K(99)}function Mi(r){return(ze(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 ph(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 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,f=document.createElement("div");f.contentEditable="false",f.setAttribute("data-lexical-cursor","true");let p=d.blockCursor;if(p!==void 0){if(typeof p=="string"){const g=Fs(p);p=d.blockCursor=g}p!==void 0&&f.classList.add(...p)}return f}(r._config)),e.style.caretColor="transparent",void(a===null?u.appendChild(n):u.insertBefore(n,a))}}n!==null&&Qo(n,r,e)}function Nt(r){return $t?(r||window).getSelection():null}function gh(r){return or(r)&&r.tagName==="A"}function or(r){return r.nodeType===1}function Oa(r){return r.nodeType===11}function Xi(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 Os(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(ze(r)&&!r.isInline())return!0;if(!O(r)||Yt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||X(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 mh(){return Qe()}const za=new WeakMap,yh=new Map;function xh(r){if(!r._readOnly&&r.isEmpty())return yh;r._readOnly||K(192);let e=za.get(r);if(!e){e=new Map,za.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 Xo(r){const e=r.constructor.clone(r);return e.afterCloneFrom(r),e}function Jo(r,e){const t=(parseInt(r.style.paddingInlineStart,10)||0)/40;e.setIndent(t)}function bh(r){return r.__lexicalUnmanaged===!0}function $u(r,e,t,n,s,i){let o=r.getFirstChild();for(;o!==null;){const l=o.__key;o.__parent===e&&(O(o)&&$u(o,l,t,n,s,i),t.has(l)||i.delete(l),s.push(l)),o=o.getNextSibling()}}let yr,gt,In,fi,Ji,Zi,Rr,Ot,eo,On,it="",ht="",Ut=null,Ft="",rr="",qu=!1,zn=!1,_s=null;function zs(r,e){const t=Rr.get(r);if(e!==null){const n=no(r);n.parentNode===e&&e.removeChild(n)}if(Ot.has(r)||gt._keyToDOMMap.delete(r),O(t)){const n=qs(t,Rr);to(n,0,n.length-1,null)}t!==void 0&&Yo(On,In,fi,t,"destroyed")}function to(r,e,t,n){let s=e;for(;s<=t;++s){const i=r[s];i!==void 0&&zs(i,n)}}function _r(r,e){r.setProperty("text-align",e)}const vh="40px";function Uu(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")||vh;r.style.setProperty("padding-inline-start",e===0?"":`calc(${e} * ${n})`)}function Wu(r,e){const t=r.style;e===0?_r(t,""):e===Po?_r(t,"left"):e===Io?_r(t,"center"):e===Oo?_r(t,"right"):e===zo?_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&&K(60);const n=t.createDOM(yr,gt);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,gt),X(t)?n.setAttribute("data-lexical-text","true"):ze(t)&&n.setAttribute("data-lexical-decorator","true"),O(t)){const s=t.__indent,i=t.__size;if(s!==0&&Uu(n,s),i!==0){const l=i-1;(function(a,u,c,d){const f=ht;ht="",ro(a,c,0,u,c.getDOMSlot(d)),Vu(c,d),ht=f})(qs(t,Ot),l,t,n)}const o=t.__format;o!==0&&Wu(n,o),t.isInline()||Hu(null,t,n),ci(t)&&(it+=sr,rr+=sr)}else{const s=t.getTextContent();if(ze(t)){const i=t.decorate(gt,yr);i!==null&&Gu(r,i),n.contentEditable="false"}else X(t)&&(t.isDirectionless()||(ht+=s));it+=s,rr+=s}return e!==null&&e.insertChild(n),Yo(On,In,fi,t,"created"),n}function ro(r,e,t,n,s){const i=it;it="";let o=t;for(;o<=n;++o){$s(r[o],s);const l=Ot.get(r[o]);l!==null&&X(l)&&(Ut===null&&(Ut=l.getFormat()),Ft===""&&(Ft=l.getStyle()))}ci(e)&&(it+=sr),s.element.__lexicalTextContent=it,it=i+it}function $a(r,e){if(r){const t=r.__last;if(t){const n=e.get(t);if(n)return Ar(n)?"line-break":ze(n)&&n.isInline()?"decorator":null}return"empty"}return null}function Hu(r,e,t){const n=$a(r,Rr),s=$a(e,Ot);n!==s&&e.getDOMSlot(t).setManagedLineBreak(s)}function Vu(r,e){const t=e.__lexicalDirTextContent||"",n=e.__lexicalDir||"";if(t!==ht||n!==_s){const i=ht==="",o=i?_s:(s=ht,Yf.test(s)?"rtl":Qf.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=Fs(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=Fs(c);c=a[o]=d}c!==void 0&&l.add(...c)}e.dir=o}zn||(r.getWritable().__dir=o)}_s=o,e.__lexicalDirTextContent=ht,e.__lexicalDir=o}var s}function _h(r,e,t){const n=ht;var s;ht="",Ut=null,Ft="",function(i,o,l){const a=it,u=i.__size,c=o.__size;it="";const d=l.element;if(u===1&&c===1){const f=i.__first,p=o.__first;if(f===p)_n(f,d);else{const m=no(f),x=$s(p,null);try{d.replaceChild(x,m)}catch(v){if(typeof v=="object"&&v!=null){const y=`${v.toString()} Parent: ${d.tagName}, new child: {tag: ${x.tagName} key: ${p}}, old child: {tag: ${m.tagName}, key: ${f}}.`;throw new Error(y)}throw v}zs(f,null)}const g=Ot.get(p);X(g)&&(Ut===null&&(Ut=g.getFormat()),Ft===""&&(Ft=g.getStyle()))}else{const f=qs(i,Rr),p=qs(o,Ot);if(f.length!==u&&K(227),p.length!==c&&K(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(f,0,u-1,g?null:d),g&&(d.textContent="")}}else(function(g,m,x,v,y,_){const S=v-1,E=y-1;let k,w,D=_.getFirstChild(),j=0,B=0;for(;j<=S&&B<=E;){const M=m[j],C=x[B];if(M===C)D=Fi(_n(C,_.element)),j++,B++;else{k===void 0&&(k=new Set(m)),w===void 0&&(w=new Set(x));const F=w.has(M),I=k.has(C);if(F)if(I){const W=Is(gt,C);W===D?D=Fi(_n(C,_.element)):(_.withBefore(D).insertChild(W),_n(C,_.element)),j++,B++}else $s(C,_.withBefore(D)),B++;else D=Fi(no(M)),zs(M,_.element),j++}const N=Ot.get(C);N!==null&&X(N)&&(Ut===null&&(Ut=N.getFormat()),Ft===""&&(Ft=N.getStyle()))}const T=j>S,R=B>E;if(T&&!R){const M=x[E+1],C=M===void 0?null:gt.getElementByKey(M);ro(x,g,B,E,_.withBefore(C))}else R&&!T&&to(m,j,S,_.element)})(o,f,p,u,c,l)}ci(o)&&(it+=sr),d.__lexicalTextContent=it,it=a+it}(r,e,e.getDOMSlot(t)),Vu(e,t),tn(s=e)&&Ut!=null&&Ut!==s.__textFormat&&!zn&&(s.setTextFormat(Ut),s.setTextStyle(Ft)),function(i){tn(i)&&Ft!==""&&Ft!==i.__textStyle&&!zn&&i.setTextStyle(Ft)}(e),ht=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=Rr.get(r);let n=Ot.get(r);t!==void 0&&n!==void 0||K(61);const s=qu||Zi.has(r)||Ji.has(r),i=Is(gt,r);if(t===n&&!s){if(O(t)){const o=i.__lexicalTextContent;o!==void 0&&(it+=o,rr+=o);const l=i.__lexicalDirTextContent;l!==void 0&&(ht+=l)}else{const o=t.getTextContent();X(t)&&!t.isDirectionless()&&(ht+=o),rr+=o,it+=o}return i}if(t!==n&&s&&Yo(On,In,fi,n,"updated"),n.updateDOM(t,i,yr)){const o=$s(r,null);return e===null&&K(62),e.replaceChild(o,i),zs(r,null),o}if(O(t)&&O(n)){const o=n.__indent;o!==t.__indent&&Uu(i,o);const l=n.__format;l!==t.__format&&Wu(i,l),s&&(_h(t,n,i),pt(n)||n.isInline()||Hu(t,n,i)),ci(n)&&(it+=sr,rr+=sr)}else{const o=n.getTextContent();if(ze(n)){const l=n.decorate(gt,yr);l!==null&&Gu(r,l)}else X(n)&&!n.isDirectionless()&&(ht+=o);it+=o,rr+=o}if(!zn&&pt(n)&&n.__cachedText!==rr){const o=n.getWritable();o.__cachedText=rr,n=o}return i}function Gu(r,e){let t=gt._pendingDecorators;const n=gt._decorators;if(t===null){if(n[r]===e)return;t=ju(gt)}t[r]=e}function Fi(r){let e=r.nextSibling;return e!==null&&e===gt._blockCursorElement&&(e=e.nextSibling),e}function wh(r,e,t,n,s,i){it="",rr="",ht="",qu=n===Zr,_s=null,gt=t,yr=t._config,In=t._nodes,fi=gt._listeners.mutation,Ji=s,Zi=i,Rr=r._nodeMap,Ot=e._nodeMap,zn=e._readOnly,eo=new Map(t._keyToDOMMap);const o=new Map;return On=o,_n("root",null),gt=void 0,In=void 0,Ji=void 0,Zi=void 0,Rr=void 0,Ot=void 0,yr=void 0,eo=void 0,On=void 0,o}function no(r){const e=eo.get(r);return e===void 0&&K(75,r),e}const er=Object.freeze({}),so=30,io=[["keydown",function(r,e){if(Nn=r.timeStamp,Ku=r.key,e.isComposing())return;const{key:t,shiftKey:n,ctrlKey:s,metaKey:i,altKey:o}=r;if(!re(e,Df,r)&&t!=null){if(function(l,a,u,c){return ja(l)&&!a&&!c&&!u}(t,s,o,i))re(e,pu,r);else if(function(l,a,u,c,d){return ja(l)&&!c&&!u&&(a||d)}(t,s,n,o,i))re(e,Af,r);else if(function(l,a,u,c){return Fa(l)&&!a&&!c&&!u}(t,s,o,i))re(e,gu,r);else if(function(l,a,u,c,d){return Fa(l)&&!c&&!u&&(a||d)}(t,s,n,o,i))re(e,Tf,r);else if(function(l,a,u){return function(c){return c==="ArrowUp"}(l)&&!a&&!u}(t,s,i))re(e,mu,r);else if(function(l,a,u){return function(c){return c==="ArrowDown"}(l)&&!a&&!u}(t,s,i))re(e,yu,r);else if(function(l,a){return La(l)&&a}(t,n))Bn=!0,re(e,Ns,r);else if(function(l){return l===" "}(t))re(e,Nf,r);else if(function(l,a){return Mt&&a&&l.toLowerCase()==="o"}(t,s))r.preventDefault(),Bn=!0,re(e,Kr,!0);else if(function(l,a){return La(l)&&!a}(t,n))Bn=!1,re(e,Ns,r);else if(function(l,a,u,c){return Mt?!a&&!u&&(fn(l)||l.toLowerCase()==="h"&&c):!(c||a||u)&&fn(l)}(t,o,i,s))fn(t)?re(e,xu,r):(r.preventDefault(),re(e,Er,!0));else if(function(l){return l==="Escape"}(t))re(e,bu,r);else if(function(l,a,u,c,d){return Mt?!(u||c||d)&&(hn(l)||l.toLowerCase()==="d"&&a):!(a||c||d)&&hn(l)}(t,s,n,o,i))hn(t)?re(e,vu,r):(r.preventDefault(),re(e,Er,!1));else if(function(l,a,u){return fn(l)&&(Mt?a:u)}(t,o,s))r.preventDefault(),re(e,jn,!0);else if(function(l,a,u){return hn(l)&&(Mt?a:u)}(t,o,s))r.preventDefault(),re(e,jn,!1);else if(function(l,a){return Mt&&a&&fn(l)}(t,i))r.preventDefault(),re(e,Ln,!0);else if(function(l,a){return Mt&&a&&hn(l)}(t,i))r.preventDefault(),re(e,Ln,!1);else if(function(l,a,u,c){return l.toLowerCase()==="b"&&!a&&vn(u,c)}(t,o,i,s))r.preventDefault(),re(e,It,"bold");else if(function(l,a,u,c){return l.toLowerCase()==="u"&&!a&&vn(u,c)}(t,o,i,s))r.preventDefault(),re(e,It,"underline");else if(function(l,a,u,c){return l.toLowerCase()==="i"&&!a&&vn(u,c)}(t,o,i,s))r.preventDefault(),re(e,It,"italic");else if(function(l,a,u,c){return l==="Tab"&&!a&&!u&&!c}(t,o,s,i))re(e,Bf,r);else if(function(l,a,u,c){return l.toLowerCase()==="z"&&!a&&vn(u,c)}(t,n,i,s))r.preventDefault(),re(e,Ro,void 0);else if(function(l,a,u,c){return Mt?l.toLowerCase()==="z"&&u&&a:l.toLowerCase()==="y"&&c||l.toLowerCase()==="z"&&c&&a}(t,n,i,s))r.preventDefault(),re(e,Mo,void 0);else{const l=e._editorState._selection;l===null||V(l)?!mr&&Pa(t,i,s)&&(r.preventDefault(),re(e,Yi,r)):function(a,u,c,d){return!u&&a.toLowerCase()==="c"&&(Mt?c:d)}(t,n,i,s)?(r.preventDefault(),re(e,ii,r)):function(a,u,c,d){return!u&&a.toLowerCase()==="x"&&(Mt?c:d)}(t,n,i,s)?(r.preventDefault(),re(e,Fo,r)):Pa(t,i,s)&&(r.preventDefault(),re(e,Yi,r))}(function(l,a,u,c){return l||a||u||c})(s,n,o,i)&&re(e,zf,r)}}],["pointerdown",function(r,e){const t=r.target,n=r.pointerType;t instanceof Node&&n!=="touch"&&kt(e,()=>{ze(en(t))||(ao=!0)})}],["compositionstart",function(r,e){kt(e,()=>{const t=oe();if(V(t)&&!e.isComposing()){const n=t.anchor,s=t.anchor.getNode();lt(n.key),(r.timeStamp<Nn+so||n.type==="element"||!t.isCollapsed()||s.getFormat()!==t.format||X(s)&&s.getStyle()!==t.style)&&re(e,Yr,Kf)}})}],["compositionend",function(r,e){mr?gn=!0:kt(e,()=>{ji(e,r.data)})}],["input",function(r,e){r.stopPropagation(),kt(e,()=>{const t=oe(),n=r.data,s=Ju(r);if(n!=null&&V(t)&&Xu(t,s,n,r.timeStamp,!1)){gn&&(ji(e,n),gn=!1);const i=t.anchor.getNode(),o=Nt(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()&&X(i)&&o.anchorNode!==null&&i.getTextContent().slice(0,a)+n+i.getTextContent().slice(a+u)===Ou(o.anchorNode)||re(e,Yr,n);const c=n.length;mr&&c>1&&r.inputType==="insertCompositionText"&&!e.isComposing()&&(t.anchor.offset-=c),oi||Vn||jo||!e.isComposing()||(Nn=0,lt(null))}else Go(!1,e,n!==null?n:void 0),gn&&(ji(e,n||void 0),gn=!1);_t(),Tu(Qe())}),Wr=null}],["click",function(r,e){kt(e,()=>{const t=oe(),n=Nt(e._window),s=Zn();if(n){if(V(t)){const i=t.anchor,o=i.getNode();i.type==="element"&&i.offset===0&&t.isCollapsed()&&!pt(o)&&Ge().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)&&Kt(ea(s,n,e,r))}}}re(e,hu,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=Ju(t);s==="deleteCompositionText"||mr&&zu(n)||s!=="insertCompositionText"&&kt(n,()=>{const o=oe();if(s==="deleteContentBackward"){if(o===null){const p=Zn();if(!V(p))return;Kt(p.clone())}if(V(o)){const p=o.anchor.key===o.focus.key;if(l=t.timeStamp,Ku==="MediaLast"&&l<Nn+so&&n.isComposing()&&p){if(lt(null),Nn=0,setTimeout(()=>{kt(n,()=>{lt(null)})},so),V(o)){const g=o.anchor.getNode();g.markDirty(),o.format=g.getFormat(),X(g)||K(142),o.style=g.getStyle()}}else{lt(null),t.preventDefault();const g=o.anchor.getNode(),m=g.getTextContent(),x=g.canInsertTextAfter(),v=o.anchor.offset===0&&o.focus.offset===m.length;Uf&&p&&!v&&x||re(n,Er,!0)}return}}var l;if(!V(o))return;const a=t.data;Wr!==null&&Go(!1,n,Wr),o.dirty&&Wr===null||!o.isCollapsed()||pt(o.anchor.getNode())||i===null||o.applyDOMRange(i),Wr=null;const u=o.anchor,c=o.focus,d=u.getNode(),f=c.getNode();if(s!=="insertText"&&s!=="insertTranspose")switch(t.preventDefault(),s){case"insertFromYank":case"insertFromDrop":case"insertReplacementText":re(n,Yr,t);break;case"insertFromComposition":lt(null),re(n,Yr,t);break;case"insertLineBreak":lt(null),re(n,Kr,!1);break;case"insertParagraph":lt(null),Bn&&!Vn?(Bn=!1,re(n,Kr,!1)):re(n,Fn,void 0);break;case"insertFromPaste":case"insertFromPasteAsQuotation":re(n,si,t);break;case"deleteByComposition":(function(p,g){return p!==g||O(p)||O(g)||!p.isToken()||!g.isToken()})(d,f)&&re(n,Ki,t);break;case"deleteByDrag":case"deleteByCut":re(n,Ki,t);break;case"deleteContent":re(n,Er,!1);break;case"deleteWordBackward":re(n,jn,!0);break;case"deleteWordForward":re(n,jn,!1);break;case"deleteHardLineBackward":case"deleteSoftLineBackward":re(n,Ln,!0);break;case"deleteContentForward":case"deleteHardLineForward":case"deleteSoftLineForward":re(n,Ln,!1);break;case"formatStrikeThrough":re(n,It,"strikethrough");break;case"formatBold":re(n,It,"bold");break;case"formatItalic":re(n,It,"italic");break;case"formatUnderline":re(n,It,"underline");break;case"historyUndo":re(n,Ro,void 0);break;case"historyRedo":re(n,Mo,void 0)}else{if(a===`
86
+ `)t.preventDefault(),re(n,Kr,!1);else if(a===sr)t.preventDefault(),re(n,Fn,void 0);else if(a==null&&t.dataTransfer){const p=t.dataTransfer.getData("text/plain");t.preventDefault(),o.insertRawText(p)}else a!=null&&Xu(o,i,a,t.timeStamp,!0)?(t.preventDefault(),re(n,Yr,a)):Wr=a;Yu=t.timeStamp}})}(r,e)]);let Nn=0,Ku=null,Yu=0,Wr=null;const Us=new WeakMap;let oo=!1,ao=!1,Bn=!1,gn=!1,Qu=[0,"",0,"root",0];function Xu(r,e,t,n,s){const i=r.anchor,o=r.focus,l=i.getNode(),a=Qe(),u=Nt(a._window),c=u!==null?u.anchorNode:null,d=i.key,f=a.getElementByKey(d),p=t.length;return d!==o.key||!X(l)||(!s&&(!Bs||Yu<n+50)||l.isDirty()&&p<2||Pu(t))&&i.offset!==o.offset&&!l.isComposing()||Cr(l)||l.isDirty()&&p>1||(s||!Bs)&&f!==null&&!l.isComposing()&&c!==js(f)||u!==null&&e!==null&&(!e.collapsed||e.startContainer!==u.anchorNode||e.startOffset!==u.anchorOffset)||l.getFormat()!==r.format||l.getStyle()!==r.style||dh(r,l)}function qa(r,e){return r!==null&&r.nodeValue!==null&&r.nodeType===xr&&e!==0&&e!==r.nodeValue.length}function Ua(r,e,t){const{anchorNode:n,anchorOffset:s,focusNode:i,focusOffset:o}=r;oo&&(oo=!1,qa(n,s)&&qa(i,o))||kt(e,()=>{if(!t)return void Kt(null);if(!Kn(e,n,i))return;const l=oe();if(V(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(),[f,p,g,m,x]=Qu,v=Ge(),y=e.isComposing()===!1&&v.getTextContent()==="";if(d<x+200&&a.offset===g&&a.key===m)l.format=f,l.style=p;else if(a.type==="text")X(u)||K(141),l.format=u.getFormat(),l.style=u.getStyle();else if(a.type==="element"&&!y){const _=a.getNode();l.style="",_ instanceof on&&_.getChildrenSize()===0?(l.format=_.getTextFormat(),l.style=_.getTextStyle()):l.format=0}}else{const c=a.key,d=l.focus.key,f=l.getNodes(),p=f.length,g=l.isBackward(),m=g?o:s,x=g?s:o,v=g?d:c,y=g?c:d;let _=Gf,S=!1;for(let E=0;E<p;E++){const k=f[E],w=k.getTextContentSize();if(X(k)&&w!==0&&!(E===0&&k.__key===v&&m===w||E===p-1&&k.__key===y&&x===0)&&(S=!0,_&=k.getFormat(),_===0))break}l.format=S?_:0}}re(e,Bo,void 0)})}function Ju(r){if(!r.getTargetRanges)return null;const e=r.getTargetRanges();return e.length===0?null:e[0]}function ji(r,e){const t=r._compositionKey;if(lt(null),t!==null&&e!=null){if(e===""){const n=dt(t),s=js(r.getElementByKey(t));return void(s!==null&&s.nodeValue!==null&&X(n)&&Ko(n,s.nodeValue,null,null,!0))}if(e[e.length-1]===`
87
+ `){const n=oe();if(V(n)){const s=n.focus;return n.anchor.set(s.key,s.offset,s.type),void re(r,Ns,null)}}}Go(!0,r,e)}function Zu(r){let e=r.__lexicalEventHandles;return e===void 0&&(e=[],r.__lexicalEventHandles=e),e}const Qr=new Map;function ec(r){const e=r.target,t=Nt(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,kt(n,()=>{const u=Zn(),c=t.anchorNode;if(c===null)return;const d=c.nodeType;d!==Gn&&d!==xr||Kt(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&&Ua(t,a,!1),Ua(t,n,!0),n!==i?Qr.set(o,n):l&&Qr.delete(o)}function Wa(r){r._lexicalHandled=!0}function Ha(r){return r._lexicalHandled===!0}function Ch(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",ec);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&&K(198);const i=Zu(r);for(let o=0;o<i.length;o++)i[o]();r.__lexicalEventHandles=[]}function lo(r,e,t){_t();const n=r.__key,s=r.getParent();if(s===null)return;const i=function(l){const a=oe();if(!V(a)||!O(l))return a;const{anchor:u,focus:c}=a,d=u.getNode(),f=c.getNode();return Tn(d,l)&&u.set(l.__key,0,"element"),Tn(f,l)&&c.set(l.__key,0,"element"),a}(r);let o=!1;if(V(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 Wt(i)&&e&&r.isSelected()&&r.selectPrevious();if(V(i)&&e&&!o){const l=r.getIndexWithinParent();Dr(r),Ws(i,s,l,-1)}else Dr(r);t||Yt(s)||s.canBeEmpty()||!s.isEmpty()||lo(s,e),e&&pt(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,ch(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=dt(e);if(t===null)break;e=t.__parent}return!1}isSelected(e){const t=e||oe();if(t==null)return!1;const n=t.getNodes().some(s=>s.__key===this.__key);if(X(this))return n;if(V(t)&&t.anchor.type==="element"&&t.focus.type==="element"){if(t.isCollapsed())return!1;const s=this.getParent();if(ze(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:dt(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(Yt(t))return O(e)||e===this&&ze(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:dt(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:dt(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&&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=Qe()._dirtyLeaves;return e!==null&&e.has(this.__key)}getLatest(){const e=dt(this.__key);return e===null&&K(113),e}getWritable(){_t();const e=ar(),t=Qe(),n=e._nodeMap,s=this.__key,i=this.getLatest(),o=t._cloneNotNeeded,l=oe();if(l!==null&&l.setCachedNodes(null),o.has(s))return Ps(i),i;const a=Xo(i);return o.add(s),Ps(a),n.set(s,a),a}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){_t();let n=oe();n!==null&&(n=n.clone()),Ri(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(),f=s.__prev,p=s.__next,g=s.__parent;if(lo(s,!1,!0),c===null?a.__first=o:c.getWritable().__next=o,l.__prev=f,d===null?a.__last=o:d.getWritable().__prev=o,l.__next=p,l.__parent=g,a.__size=u,t&&(O(this)&&O(l)||K(139),this.getChildren().forEach(m=>{l.append(m)})),V(n)){Kt(n);const m=n.anchor,x=n.focus;m.key===i&&Ya(m,l),x.key===i&&Ya(x,l)}return hr()===i&&lt(o),l}insertAfter(e,t=!0){_t(),Ri(this,e);const n=this.getWritable(),s=e.getWritable(),i=s.getParent(),o=oe();let l=!1,a=!1;if(i!==null){const p=e.getIndexWithinParent();if(Dr(s),V(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,f=n.__next;if(u===null?c.__last=d:u.getWritable().__prev=d,c.__size++,n.__next=d,s.__next=f,s.__prev=n.__key,s.__parent=n.__parent,t&&V(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){_t(),Ri(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=oe();return t&&V(c)&&Ws(c,this.getParentOrThrow(),u),e}isParentRequired(){return!1}createParentElementNode(){return rt()}selectStart(){return this.selectPrevious()}selectEnd(){return this.selectNext(0,0)}selectPrevious(e,t){_t();const n=this.getPreviousSibling(),s=this.getParentOrThrow();if(n===null)return s.select(0,0);if(O(n))return n.select();if(!X(n)){const i=n.getIndexWithinParent()+1;return s.select(i,i)}return n.select(e,t)}selectNext(e,t){_t();const n=this.getNextSibling(),s=this.getParentOrThrow();if(n===null)return s.select();if(O(n))return n.select(0,0);if(!X(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&&Os(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&&Os(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:Sh,priority:0}}}static importJSON(e){return Mr()}exportJSON(){return{type:"linebreak",version:1}}}function Sh(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 tc(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&Rs;o!==void 0&&(t&Ms&&t&Rs?(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 rc(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 f=c.length,p=d.length;let g=0,m=0;for(;g<f&&g<p&&c[g]===d[g];)g++;for(;m+g<f&&m+g<p&&c[f-m-1]===d[p-m-1];)m++;return[g,f-g-m,d.slice(g,p-m)]}(o,i);a!==0&&n.deleteData(l,a),n.insertData(l,u)}else n.nodeValue=i}}function Va(r,e,t,n,s,i){rc(s,r,e);const o=i.theme.text;o!==void 0&&tc(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 eh[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)),Va(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&&K(48);const x=document.createElement(c);return Va(x,this,0,o,s,n),t.replaceChild(x,m),!1}let d=t;a!==null&&l!==null&&(d=t.firstChild,d==null&&K(49)),rc(s,d,this);const f=n.theme.text;f!==void 0&&i!==o&&tc(0,i,o,d,f);const p=e.__style,g=this.__style;return p!==g&&(t.style.cssText=g),!1}static importDOM(){return{"#text":()=>({conversion:Ah,priority:0}),b:()=>({conversion:Eh,priority:0}),code:()=>({conversion:ur,priority:0}),em:()=>({conversion:ur,priority:0}),i:()=>({conversion:ur,priority:0}),s:()=>({conversion:ur,priority:0}),span:()=>({conversion:kh,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=st(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)||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"?Xf[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=Zf[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){_t();let n=e,s=t;const i=oe(),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(!V(i))return ic(l,n,l,s,"text","text");{const a=hr();a!==i.anchor.key&&a!==i.focus.key||lt(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=oe();if(s&&V(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){_t();const t=this.getLatest(),n=t.getTextContent(),s=t.__key,i=hr(),o=new Set(e),l=[],a=n.length;let u="";for(let E=0;E<a;E++)u!==""&&o.has(E)&&(l.push(u),u=""),u+=n[E];u!==""&&l.push(u);const c=l.length;if(c===0)return[];if(l[0]===n)return[t];const d=l[0],f=t.getParent();let p;const g=t.getFormat(),m=t.getStyle(),x=t.__detail;let v=!1;t.isSegmented()?(p=st(d),p.__format=g,p.__style=m,p.__detail=x,v=!0):(p=t.getWritable(),p.__text=d);const y=oe(),_=[p];let S=d.length;for(let E=1;E<c;E++){const k=l[E],w=k.length,D=st(k).getWritable();D.__format=g,D.__style=m,D.__detail=x;const j=D.__key,B=S+w;if(V(y)){const T=y.anchor,R=y.focus;T.key===s&&T.type==="text"&&T.offset>S&&T.offset<=B&&(T.key=j,T.offset-=S,y.dirty=!0),R.key===s&&R.type==="text"&&R.offset>S&&R.offset<=B&&(R.key=j,R.offset-=S,y.dirty=!0)}i===s&&lt(j),S=B,_.push(D)}if(f!==null){(function(w){const D=w.getPreviousSibling(),j=w.getNextSibling();D!==null&&Ps(D),j!==null&&Ps(j)})(this);const E=f.getWritable(),k=this.getIndexWithinParent();v?(E.splice(k,0,_),this.remove()):E.splice(k,1,_),V(y)&&Ws(y,f,k,c-1)}return _}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;hr()===s&&lt(n);const l=oe();if(V(l)){const d=l.anchor,f=l.focus;d!==null&&d.key===s&&(rl(d,t,n,e,o),l.dirty=!0),f!==null&&f.key===s&&(rl(f,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 kh(r){return{forChild:Zo(r.style),node:null}}function Eh(r){const e=r,t=e.style.fontWeight==="normal";return{forChild:Zo(e.style,t?void 0:"bold"),node:null}}const Ga=new WeakMap;function Dh(r){return r.nodeName==="PRE"||r.nodeType===Gn&&r.style!==void 0&&r.style.whiteSpace!==void 0&&r.style.whiteSpace.startsWith("pre")}function Ah(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=Ga.get(i))===void 0&&!Dh(i);)o.push(i),i=i.parentNode;const l=s===void 0?i:s;for(let a=0;a<o.length;a++)Ga.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
89
  `||l===`\r
90
- `?s.push(Mr()):l===" "?s.push(Jn()):l!==""&&s.push(st(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=Ka(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=Ka(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:st(t)}}function Ka(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===""&&!Xi(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 Th={code:"code",em:"italic",i:"italic",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function ur(r){const e=Th[r.nodeName.toLowerCase()];return e===void 0?{node:null}:{forChild:Zo(r.style,e),node:null}}function st(r=""){return Xt(new sn(r))}function Q(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=>(Q(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 Xn extends sn{static getType(){return"tab"}static clone(e){return new Xn(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=Jn();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 Jn(){return Xt(new Xn)}function Nh(r){return r instanceof Xn}class Bh{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(I(t)){const o=t.getDescendantByIndex(s);t=o??t}if(I(n)){const o=n.getDescendantByIndex(i);n=o??n}return t===n?s<i:t.isBefore(n)}getNode(){const e=dt(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()||(hr()===i&&lt(e),s!==null&&(s.setCachedNodes(null),s.dirty=!0))}}function Qt(r,e,t){return new Bh(r,e,t)}function Ii(r,e){let t=e.__key,n=r.offset,s="element";if(Q(e)){s="text";const i=e.getTextContentSize();n>i&&(n=i)}else if(!I(e)){const i=e.getNextSibling();if(Q(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 Ya(r,e){if(I(e)){const t=e.getLastDescendant();I(t)||Q(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(!Wt(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(Q(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=dt(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 H(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!!H(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(I(l)){const f=l.getDescendantByIndex(u);l=f??l}if(I(a)){let f=a.getDescendantByIndex(c);f!==null&&f!==l&&a.getChildAtIndex(c)===f&&(f=f.getPreviousSibling()),a=f??a}let d;return d=l.is(a)?I(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 f=e[d];if(I(f)&&!f.isInline())c||(u+=`
91
- `),c=!f.isEmpty();else if(c=!1,Q(f)){let p=f.getTextContent();f===t?f===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):f===n&&(p=o?p.slice(0,a):p.slice(0,l)),u+=p}else!ze(f)&&!Ar(f)||f===n&&this.isCollapsed()||(u+=f.getTextContent())}return u}applyDOMRange(e){const t=Qe(),n=t.getEditorState()._selection,s=sc(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(Qt(e.key,e.offset,e.type),Qt(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===`
90
+ `?s.push(Mr()):l===" "?s.push(Jn()):l!==""&&s.push(st(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=Ka(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=Ka(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:st(t)}}function Ka(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===""&&!Xi(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 Th={code:"code",em:"italic",i:"italic",s:"strikethrough",strong:"bold",sub:"subscript",sup:"superscript",u:"underline"};function ur(r){const e=Th[r.nodeName.toLowerCase()];return e===void 0?{node:null}:{forChild:Zo(r.style,e),node:null}}function st(r=""){return Xt(new sn(r))}function X(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=>(X(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 Xn extends sn{static getType(){return"tab"}static clone(e){return new Xn(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=Jn();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 Jn(){return Xt(new Xn)}function Nh(r){return r instanceof Xn}class Bh{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=dt(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()||(hr()===i&&lt(e),s!==null&&(s.setCachedNodes(null),s.dirty=!0))}}function Qt(r,e,t){return new Bh(r,e,t)}function Ii(r,e){let t=e.__key,n=r.offset,s="element";if(X(e)){s="text";const i=e.getTextContentSize();n>i&&(n=i)}else if(!O(e)){const i=e.getNextSibling();if(X(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 Ya(r,e){if(O(e)){const t=e.getLastDescendant();O(t)||X(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(!Wt(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(X(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=dt(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 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!!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 l=i.getNode(),a=o.getNode();const u=i.offset,c=o.offset;if(O(l)){const f=l.getDescendantByIndex(u);l=f??l}if(O(a)){let f=a.getDescendantByIndex(c);f!==null&&f!==l&&a.getChildAtIndex(c)===f&&(f=f.getPreviousSibling()),a=f??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 f=e[d];if(O(f)&&!f.isInline())c||(u+=`
91
+ `),c=!f.isEmpty();else if(c=!1,X(f)){let p=f.getTextContent();f===t?f===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):f===n&&(p=o?p.slice(0,a):p.slice(0,l)),u+=p}else!ze(f)&&!Ar(f)||f===n&&this.isCollapsed()||(u+=f.getTextContent())}return u}applyDOMRange(e){const t=Qe(),n=t.getEditorState()._selection,s=sc(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(Qt(e.key,e.offset,e.type),Qt(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(Jn()):n.push(st(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,_,y,w){const C=x.getNode(),D=C.getChildAtIndex(x.offset),E=st(),v=pt(C)?rt().append(E):E;E.setFormat(y),E.setStyle(w),D===null?C.append(v):D.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 f=c[0];Q(f)||K(26);const p=f.getTextContent().length,g=f.getParentOrThrow();let m=c[d-1];if(d===1&&l.type==="element"&&(u=p,l.set(o.key,u,"text")),this.isCollapsed()&&a===p&&(f.isSegmented()||f.isToken()||!f.canInsertTextAfter()||!g.canInsertTextAfter()&&f.getNextSibling()===null)){let x=f.getNextSibling();if(Q(x)&&x.canInsertTextBefore()&&!Cr(x)||(x=st(),x.setFormat(s),x.setStyle(i),g.canInsertTextAfter()?f.insertAfter(x):g.insertAfter(x)),x.select(0,0),f=x,e!=="")return void this.insertText(e)}else if(this.isCollapsed()&&a===0&&(f.isSegmented()||f.isToken()||!f.canInsertTextBefore()||!g.canInsertTextBefore()&&f.getPreviousSibling()===null)){let x=f.getPreviousSibling();if(Q(x)&&!Cr(x)||(x=st(),x.setFormat(s),g.canInsertTextBefore()?f.insertBefore(x):g.insertBefore(x)),x.select(),f=x,e!=="")return void this.insertText(e)}else if(f.isSegmented()&&a!==p){const x=st(f.getTextContent());x.setFormat(s),f.replace(x),f=x}else if(!this.isCollapsed()&&e!==""){const x=m.getParent();if(!g.canInsertTextBefore()||!g.canInsertTextAfter()||I(x)&&(!x.canInsertTextBefore()||!x.canInsertTextAfter()))return this.insertText(""),nc(this.anchor,this.focus,null),void this.insertText(e)}if(d===1){if(f.isToken()){const w=st(e);return w.select(),void f.replace(w)}const x=f.getFormat(),_=f.getStyle();if(a!==u||x===s&&_===i){if(Nh(f)){const w=st(e);return w.setFormat(s),w.setStyle(i),w.select(),void f.replace(w)}}else{if(f.getTextContent()!==""){const w=st(e);if(w.setFormat(s),w.setStyle(i),w.select(),a===0)f.insertBefore(w,!1);else{const[C]=f.splitText(a);C.insertAfter(w,!1)}return void(w.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length))}f.setFormat(s),f.setStyle(i)}const y=u-a;f=f.spliceText(a,y,e,!0),f.getTextContent()===""?f.remove():this.anchor.type==="text"&&(f.isComposing()?this.anchor.offset-=e.length:(this.format=x,this.style=_))}else{const x=new Set([...f.getParentKeys(),...m.getParentKeys()]),_=I(f)?f:f.getParentOrThrow();let y=I(m)?m:m.getParentOrThrow(),w=m;if(!_.is(y)&&y.isInline())do w=y,y=y.getParentOrThrow();while(y.isInline());if(l.type==="text"&&(u!==0||m.getTextContent()==="")||l.type==="element"&&m.getIndexWithinParent()<u)if(Q(m)&&!m.isToken()&&u!==m.getTextContentSize()){if(m.isSegmented()){const k=st(m.getTextContent());m.replace(k),m=k}pt(l.getNode())||l.type!=="text"||(m=m.spliceText(0,u,"")),x.add(m.__key)}else{const k=m.getParentOrThrow();k.canBeEmpty()||k.getChildrenSize()!==1?m.remove():k.remove()}else x.add(m.__key);const C=y.getChildren(),D=new Set(c),E=_.is(y),v=_.isInline()&&f.getNextSibling()===null?_:f;for(let k=C.length-1;k>=0;k--){const M=C[k];if(M.is(f)||I(M)&&M.isParentOf(f))break;M.isAttached()&&(!D.has(M)||M.is(w)?E||v.insertAfter(M,!1):M.remove())}if(!E){let k=y,M=null;for(;k!==null;){const T=k.getChildren(),N=T.length;(N===0||T[N-1].is(M))&&(x.delete(k.__key),M=k),k=k.getParent()}}if(f.isToken())if(a===p)f.select();else{const k=st(e);k.select(),f.replace(k)}else f=f.spliceText(a,p-a,e,!0),f.getTextContent()===""?f.remove():f.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length);for(let k=1;k<d;k++){const M=c[k],T=M.__key;x.has(T)||M.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);Q(o)&&o.isToken()&&s.offset<o.getTextContentSize()&&(s.offset=0),i.offset>0&&Q(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,f)=>{if(d.getTextContent()==="")d.remove();else if(f!==0&&Cr(d)){const p=st(d.getTextContent());return p.setFormat(d.getFormat()),p.setStyle(d.getStyle()),d.replace(p)}};if(o===l&&Q(o)){const d=Math.abs(t.offset-e.offset);return o.spliceText(s.offset,d,"",!0),void c(o,d)}if(Q(o)){const d=o.getTextContentSize()-s.offset;o.spliceText(s.offset,d,""),o=c(o,d)||o}Q(l)&&(l.spliceText(0,i.offset,""),l=c(l,i.offset)||l),o.isAttached()&&Q(o)?o.selectEnd():l.isAttached()&&Q(l)&&l.selectStart(),I(a)&&I(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 lt(null);const n=this.getNodes(),s=[];for(const C of n)Q(C)&&s.push(C);const i=C=>{n.forEach(D=>{if(tn(D)){const E=D.getFormatFlags(e,C);D.setTextFormat(E)}})},o=s.length;if(o===0)return this.toggleFormat(e),lt(null),void i(t);const l=this.anchor,a=this.focus,u=this.isBackward(),c=u?a:l,d=u?l:a;let f=0,p=s[0],g=c.type==="element"?0:c.offset;if(c.type==="text"&&g===p.getTextContentSize()&&(f=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 y=d.type==="text"?d.offset:_.getTextContentSize();if(p.is(_)){if(g===y)return;if(Cr(p)||g===0&&y===p.getTextContentSize())p.setFormat(m);else{const C=p.splitText(g,y),D=g===0?C[0]:C[1];D.setFormat(m),c.type==="text"&&c.set(D.__key,0,"text"),d.type==="text"&&d.set(D.__key,y-g,"text")}return void(this.format=m)}g===0||Cr(p)||([,p]=p.splitText(g),g=0),p.setFormat(m);const w=_.getFormatFlags(e,m);y>0&&(y===_.getTextContentSize()||Cr(_)||([_]=_.splitText(y)),_.setFormat(w));for(let C=f+1;C<x;C++){const D=s[C],E=D.getFormatFlags(e,w);D.setFormat(E)}c.type==="text"&&c.set(p.__key,g,"text"),d.type==="text"&&d.set(_.__key,y,"text"),this.format=m|w}insertNodes(e){if(e.length===0)return;if(this.anchor.key==="root"){this.insertParagraph();const g=oe();return H(g)||K(134),g.insertNodes(e)}const t=(this.isBackward()?this.focus:this.anchor).getNode(),n=pn(t,cr),s=e[e.length-1];if(I(n)&&"__language"in n){if("__language"in e[0])this.insertText(e[0].getTextContent());else{const g=Oi(this);n.splice(g,0,e),s.selectEnd()}return}if(!e.some(g=>(I(g)||ze(g))&&!g.isInline())){I(n)||K(211,t.constructor.name,t.getType());const g=Oi(this);return n.splice(g,0,e),void s.selectEnd()}const i=function(g){const m=rt();let x=null;for(let _=0;_<g.length;_++){const y=g[_],w=Ar(y);if(w||ze(y)&&y.isInline()||I(y)&&y.isInline()||Q(y)||y.isParentRequired()){if(x===null&&(x=y.createParentElementNode(),m.append(x),w))continue;x!==null&&x.append(y)}else m.append(y),x=null}return m}(e),o=i.getLastDescendant(),l=i.getChildren(),a=!I(n)||!n.isEmpty()?this.insertParagraph():null,u=l[l.length-1];let c=l[0];var d;I(d=c)&&cr(d)&&!d.isEmpty()&&I(n)&&(!n.isEmpty()||n.canMergeWhenEmpty())&&(I(n)||K(211,t.constructor.name,t.getType()),n.append(...c.getChildren()),c=l[1]),c&&(n===null&&K(212,t.constructor.name,t.getType()),function(g,m,x){const _=m.getParentOrThrow().getLastChild();let y=m;const w=[m];for(;y!==_;)y.getNextSibling()||K(140),y=y.getNextSibling(),w.push(y);let C=g;for(const D of w)C=C.insertAfter(D)}(n,c));const f=pn(o,cr);a&&I(f)&&(a.canMergeWhenEmpty()||cr(u))&&(f.append(...a.getChildren()),a.remove()),I(n)&&n.isEmpty()&&n.remove(),o.selectEnd();const p=I(n)?n.getLastChild():null;Ar(p)&&f!==n&&p.remove()}insertParagraph(){if(this.anchor.key==="root"){const o=rt();return Ge().splice(this.anchor.offset,0,[o]),o.select(),o}const e=Oi(this),t=pn(this.anchor.getNode(),cr);I(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],l=e[n];const[a,u]=uo(this);if(t===0)return[];if(t===1){if(Q(o)&&!this.isCollapsed()){const d=a>u?u:a,f=a>u?a:u,p=o.splitText(d,f),g=d===0?p[0]:p[1];return g!=null?[g]:[]}return[o]}const c=s.isBefore(i);if(Q(o)){const d=c?a:u;d===o.getTextContentSize()?e.shift():d!==0&&([,o]=o.splitText(d),e[0]=o)}if(Q(l)){const d=l.getTextContent().length,f=c?u:a;f===0?e.pop():f!==d&&([l]=l.splitText(f),e[n]=l)}return e}modify(e,t,n){const s=this.focus,i=this.anchor,o=e==="move",l=Pn(s,t);if(ze(l)&&!l.isIsolated()){if(o&&l.isKeyboardSelectable()){const p=el();return p.add(l.__key),void Kt(p)}const f=t?l.getPreviousSibling():l.getNextSibling();if(Q(f)){const p=f.__key,g=t?f.getTextContent().length:0;return s.set(p,g,"text"),void(o&&i.set(p,g,"text"))}{const p=l.getParentOrThrow();let g,m;return I(f)?(m=f.__key,g=t?f.getChildrenSize():0):(g=l.getIndexWithinParent(),m=p.__key,t||g++),s.set(m,g,"element"),void(o&&i.set(m,g,"element"))}}const a=Qe(),u=Nt(a._window);if(!u)return;const c=a._blockCursorElement,d=a._rootElement;if(d===null||c===null||!I(l)||l.isInline()||l.canBeEmpty()||Qo(c,a,d),function(f,p,g,m){f.modify(p,g,m)}(u,e,t?"backward":"forward",n),u.rangeCount>0){const f=u.getRangeAt(0),p=this.anchor.getNode(),g=pt(p)?p:hh(p);if(this.applyDOMRange(f),this.dirty=!0,!o){const m=this.getNodes(),x=[];let _=!1;for(let y=0;y<m.length;y++){const w=m[y];Tn(w,g)?x.push(w):_=!0}if(_&&x.length>0)if(t){const y=x[0];I(y)?y.selectStart():y.getParentOrThrow().selectStart()}else{const y=x[x.length-1];I(y)?y.selectEnd():y.getParentOrThrow().selectEnd()}u.anchorNode===f.startContainer&&u.anchorOffset===f.startOffset||function(y){const w=y.focus,C=y.anchor,D=C.key,E=C.offset,v=C.type;dr(C,w.key,w.offset,w.type),dr(w,D,E,v),y._cachedNodes=null}(this)}}}forwardDeletion(e,t,n){if(!n&&(e.type==="element"&&I(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)&&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(ze(o)&&!o.isIsolated()){if(o.isKeyboardSelectable()&&I(s)&&s.getChildrenSize()===0){s.remove();const l=el();l.add(o.__key),Kt(l)}else o.remove(),Qe().dispatchCommand(Bo,void 0);return}if(!e&&I(o)&&I(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,f=c.getNode(),p=d.getNode();if(f===p&&c.type==="text"&&d.type==="text"){const g=c.offset,m=d.offset,x=g<m,_=x?g:m,y=x?m:g,w=y-1;_!==w&&(Pu(f.getTextContent().slice(_,y))||(u?d.offset=w:c.offset=w))}})(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type==="element"&&this.anchor.offset===0){const n=this.anchor.getNode();n.isEmpty()&&pt(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 Wt(r){return r instanceof pi}function Qa(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]:[Qa(t),Qa(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 Ja(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 f=u.parentNode;r===f&&e>Array.prototype.indexOf.call(f.children,u)&&i--}if(s=Hr(c),Q(s))i=Ma(s,o);else{let f=Hr(r);if(f===null)return null;if(I(f)){const p=n.getElementByKey(f.getKey());p===null&&K(214),[f,i]=f.getDOMSlot(p).resolveChildIndex(f,p,r,e),I(f)||K(215),o&&i>=f.getChildrenSize()&&(i=Math.max(0,f.getChildrenSize()-1));let m=f.getChildAtIndex(i);if(I(m)&&function(x,_,y){const w=x.getParent();return y===null||w===null||!w.canBeEmpty()||w!==y.getNode()}(m,0,t)){const x=o?m.getLastDescendant():m.getFirstDescendant();x===null?f=m:(m=x,f=I(m)?m:m.getParentOrThrow()),i=0}Q(m)?(s=m,f=null,i=Ma(m,o)):m!==f&&o&&!d&&(I(f)||K(216),i=Math.min(f.getChildrenSize(),i+1))}else{const p=f.getIndexWithinParent();i=e===0&&ze(f)&&Hr(r)===f?p:p+1,f=f.getParentOrThrow()}if(I(f))return Qt(f.__key,i,"element")}}else s=Hr(r);return Q(s)?Qt(s.__key,i,"text"):null}function Za(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&&I(o)&&o.isInline()){const l=o.getPreviousSibling();Q(l)&&(r.key=l.__key,r.offset=l.getTextContent().length)}}else I(i)&&!t&&i.isInline()?(r.key=i.__key,r.offset=i.getChildrenSize(),r.type="element"):Q(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)&&i.isInline())r.key=i.__key,r.offset=0,r.type="element";else if((t||e)&&i===null&&I(o)&&o.isInline()&&!o.canInsertTextAfter()){const l=o.getNextSibling();Q(l)&&(r.key=l.__key,r.offset=0)}}}function nc(r,e,t){if(r.type==="text"&&e.type==="text"){const n=r.isBefore(e),s=r.is(e);Za(r,n,s),Za(e,!n,s),s&&(e.key=r.key,e.offset=r.offset,e.type=r.type);const i=Qe();if(i.isComposing()&&i._compositionKey!==r.key&&H(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 sc(r,e,t,n,s,i){if(r===null||t===null||!Kn(s,r,t))return null;const o=Ja(r,e,H(i)?i.anchor:null,s);if(o===null)return null;const l=Ja(t,n,H(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(ze(a)&&ze(u))return null}return nc(o,l,i),[o,l]}function co(r){return I(r)&&!r.isInline()}function ic(r,e,t,n,s,i){const o=ar(),l=new br(Qt(r,e,s),Qt(t,n,i),0,"");return l.dirty=!0,o._selection=l,l}function Rh(){const r=Qt("root",0,"element"),e=Qt("root",0,"element");return new br(r,e,0,"")}function el(){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,f;if(H(r)&&!a)return r.clone();if(e===null)return null;if(u=e.anchorNode,c=e.focusNode,d=e.anchorOffset,f=e.focusOffset,l&&H(r)&&!Kn(t,u,c))return r.clone();const p=sc(u,d,c,f,t,r);if(p===null)return null;const[g,m]=p;return new br(g,m,H(r)?r.format:0,H(r)?r.style:"")}function oe(){return ar()._selection}function Zn(){return Qe()._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"),tl(r)}}else{const u=r.isBackward(),c=u?i:s,d=c.getNode(),f=u?s:i,p=f.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=f.offset;(t<=g&&n>0||t<g&&n<0)&&f.set(a,Math.max(0,g+n),"element")}}tl(r)}function tl(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(i))return;const l=i.getChildrenSize(),a=t>=l,u=a?i.getChildAtIndex(l-1):i.getChildAtIndex(t);if(Q(u)){let c=0;a&&(c=u.getTextContentSize()),e.set(u.__key,c,"text"),n.set(u.__key,c,"text")}}else{if(I(i)){const l=i.getChildrenSize(),a=t>=l,u=a?i.getChildAtIndex(l-1):i.getChildAtIndex(t);if(Q(u)){let c=0;a&&(c=u.getTextContentSize()),e.set(u.__key,c,"text")}}if(I(o)){const l=o.getChildrenSize(),a=s>=l,u=a?o.getChildAtIndex(l-1):o.getChildAtIndex(s);if(Q(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,Q(n)?(o=n.getTextContentSize(),l="text"):I(n)&&(o=n.getChildrenSize(),l="element")):s!==null&&(i=s.__key,Q(s)?l="text":I(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 rl(r,e,t,n,s){r.type==="text"?(r.key=t,e||(r.offset+=s)):r.offset>n.getIndexWithinParent()&&(r.offset-=1)}function Mh(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(!H(e))return void(r!==null&&Kn(t,l,a)&&n.removeAllRanges());const f=e.anchor,p=e.focus,g=f.key,m=p.key,x=Is(t,g),_=Is(t,m),y=f.offset,w=p.offset,C=e.format,D=e.style,E=e.isCollapsed();let v=x,k=_,M=!1;if(f.type==="text"){v=js(x);const B=f.getNode();M=B.getFormat()!==C||B.getStyle()!==D}else H(r)&&r.anchor.type==="text"&&(M=!0);var T,N,R,j,S;if(p.type==="text"&&(k=js(_)),v!==null&&k!==null&&(E&&(r===null||M||H(r)&&(r.format!==C||r.style!==D))&&(T=C,N=D,R=y,j=g,S=performance.now(),Qu=[T,N,R,j,S]),u!==y||c!==w||l!==v||a!==k||n.type==="Range"&&E||(d!==null&&i.contains(d)||i.focus({preventScroll:!0}),f.type==="element"))){try{n.setBaseAndExtent(v,y,k,w)}catch{}if(!s.has("skip-scroll-into-view")&&e.isCollapsed()&&i!==null&&i===document.activeElement){const B=e instanceof br&&e.anchor.type==="element"?v.childNodes[y]||null:n.rangeCount>0?n.getRangeAt(0):null;if(B!==null){let F;if(B instanceof Text){const O=document.createRange();O.selectNode(B),F=O.getBoundingClientRect()}else F=B.getBoundingClientRect();(function(O,V,U){const te=U.ownerDocument,q=te.defaultView;if(q===null)return;let{top:X,bottom:W}=V,se=0,ue=0,de=U;for(;de!==null;){const pe=de===te.body;if(pe)se=0,ue=di(O).innerHeight;else{const xe=de.getBoundingClientRect();se=xe.top,ue=xe.bottom}let De=0;if(X<se?De=-(se-X):W>ue&&(De=W-ue),De!==0)if(pe)q.scrollBy(0,De);else{const xe=de.scrollTop;de.scrollTop+=De;const J=de.scrollTop-xe;X-=J,W-=J}if(pe)break;de=Yn(de)}})(t,F,i)}}oo=!0}}function oc(r){let e=oe()||Zn();e===null&&(e=Ge().selectEnd()),e.insertNodes(r)}function Oi(r){let e=r;r.isCollapsed()||e.removeText();const t=oe();H(t)&&(e=t),H(e)||K(161);const n=e.anchor;let s=n.getNode(),i=n.offset;for(;!cr(s);)[s,i]=Fh(s,i);return i}function Fh(r,e){const t=r.getParent();if(!t){const s=rt();return Ge().append(s),s.select(),[Ge(),0]}if(Q(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(!I(r)||e===0)return[t,r.getIndexWithinParent()];const n=r.getChildAtIndex(e);if(n){const s=new br(Qt(r.__key,e,"element"),Qt(r.__key,e,"element"),0,""),i=r.insertNewAfter(s);i&&i.append(n,...n.getNextSiblings())}return[t,r.getIndexWithinParent()+1]}let ot=null,at=null,Ct=!1,zi=!1,ws=0;const nl={characterData:!0,childList:!0,subtree:!0};function es(){return Ct||ot!==null&&ot._readOnly}function _t(){Ct&&K(13)}function ac(){ws>99&&K(14)}function ar(){return ot===null&&K(195,lc()),ot}function Qe(){return at===null&&K(196,lc()),at}function lc(){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 jh(){return at}function sl(r,e,t){const n=e.__type,s=function(l,a){const u=l._nodes.get(a);return u===void 0&&K(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 il(r,e){return r!==void 0&&r.__key!==e&&r.isAttached()}function uc(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 Lh(r){return ta(r,Qe()._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(i)&&Array.isArray(o))for(let l=0;l<o.length;l++){const a=ta(o[l],e);i.append(a)}return i}function ol(r,e,t){const n=ot,s=Ct,i=at;ot=e,Ct=!0,at=r;try{return t()}finally{ot=n,Ct=s,at=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=ot,c=Ct,d=at,f=r._updating,p=r._observer;let g=null;if(r._pendingEditorState=null,r._editorState=t,!s&&a&&p!==null){at=r,ot=t,Ct=!1,r._updating=!0;try{const E=r._dirtyType,v=r._dirtyElements,k=r._dirtyLeaves;p.disconnect(),g=wh(i,t,r,E,v,k)}catch(E){if(E instanceof Error&&r._onError(E),zi)throw E;return pc(r,null,n,t),Nu(r),r._dirtyType=Zr,zi=!0,pr(r,i),void(zi=!1)}finally{p.observe(n,nl),r._updating=f,ot=u,Ct=c,at=d}}t._readOnly||(t._readOnly=!0);const m=r._dirtyLeaves,x=r._dirtyElements,_=r._normalizedNodes,y=r._updateTags,w=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 k=E._decorators;let M=E._pendingDecorators||k;const T=v._nodeMap;let N;for(N in M)T.has(N)||(M===k&&(M=ju(E)),delete M[N])}(r,t);const C=s?null:Nt(r._window);if(r._editable&&C!==null&&(a||l===null||l.dirty)){at=r,ot=t;try{if(p!==null&&p.disconnect(),a||l===null||l.dirty){const E=r._blockCursorElement;E!==null&&Qo(E,r,n),Mh(o,l,r,C,y,n)}ph(r,n,l),p!==null&&p.observe(n,nl)}finally{at=d,ot=u}}g!==null&&function(E,v,k,M,T){const N=Array.from(E._listeners.mutation),R=N.length;for(let j=0;j<R;j++){const[S,B]=N[j],F=v.get(B);F!==void 0&&S(F,{dirtyLeaves:M,prevEditorState:T,updateTags:k})}}(r,g,y,m,i),H(l)||l===null||o!==null&&o.is(l)||r.dispatchCommand(Bo,void 0);const D=r._pendingDecorators;D!==null&&(r._decorators=D,r._pendingDecorators=null,Rn("decorator",r,!0,D)),function(E,v,k){const M=Ra(v),T=Ra(k);M!==T&&Rn("textcontent",E,!0,T)}(r,e||i,t),Rn("update",r,!0,{dirtyElements:x,dirtyLeaves:m,editorState:t,normalizedNodes:_,prevEditorState:e||i,tags:y}),function(E,v){if(E._deferred=[],v.length!==0){const k=E._updating;E._updating=!0;try{for(let M=0;M<v.length;M++)v[M]()}finally{E._updating=k}}}(r,w),function(E){const v=E._updates;if(v.length!==0){const k=v.shift();if(k){const[M,T]=k;dc(E,M,T)}}}(r)}function Rn(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 cc(r,e,t){if(r._updating===!1||at!==r){let s=!1;return r.update(()=>{s=cc(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 al(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&&K(191),a._flushSync=!0}l&&r._deferred.push(l),uc(r,o.tag)}i()}}return n}function dc(r,e,t){const n=r._updateTags;let s,i=!1,o=!1;t!==void 0&&(s=t.onUpdate,uc(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=fc(a||l),u=!0),a._flushSync=o;const c=ot,d=Ct,f=at,p=r._updating;ot=a,Ct=!1,r._updating=!0,at=r;try{u&&(r._headless?l._selection!==null&&(a._selection=l._selection.clone()):a._selection=function(_){const y=_.getEditorState()._selection,w=Nt(_._window);return H(y)||y==null?ea(y,w,_,null):y.clone()}(r));const m=r._compositionKey;e(),i=al(r,i),function(_,y){const w=y.getEditorState()._selection,C=_._selection;if(H(C)){const D=C.anchor,E=C.focus;let v;if(D.type==="text"&&(v=D.getNode(),v.selectionTransform(w,C)),E.type==="text"){const k=E.getNode();v!==k&&k.selectionTransform(w,C)}}}(a,r),r._dirtyType!==Nr&&(i?function(_,y){const w=y._dirtyLeaves,C=_._nodeMap;for(const D of w){const E=C.get(D);Q(E)&&E.isAttached()&&E.isSimpleText()&&!E.isUnmergeable()&&Na(E)}}(a,r):function(_,y){const w=y._dirtyLeaves,C=y._dirtyElements,D=_._nodeMap,E=hr(),v=new Map;let k=w,M=k.size,T=C,N=T.size;for(;M>0||N>0;){if(M>0){y._dirtyLeaves=new Set;for(const R of k){const j=D.get(R);Q(j)&&j.isAttached()&&j.isSimpleText()&&!j.isUnmergeable()&&Na(j),j!==void 0&&il(j,E)&&sl(y,j,v),w.add(R)}if(k=y._dirtyLeaves,M=k.size,M>0){ws++;continue}}y._dirtyLeaves=new Set,y._dirtyElements=new Map;for(const R of T){const j=R[0],S=R[1];if(j!=="root"&&!S)continue;const B=D.get(j);B!==void 0&&il(B,E)&&sl(y,B,v),C.set(j,S)}k=y._dirtyLeaves,M=k.size,T=y._dirtyElements,N=T.size,ws++}y._dirtyLeaves=w,y._dirtyElements=C}(a,r),al(r),function(_,y,w,C){const D=_._nodeMap,E=y._nodeMap,v=[];for(const[k]of C){const M=E.get(k);M!==void 0&&(M.isAttached()||(I(M)&&$u(M,k,D,E,v,C),D.has(k)||C.delete(k),v.push(k)))}for(const k of v)E.delete(k);for(const k of w){const M=E.get(k);M===void 0||M.isAttached()||(D.has(k)||w.delete(k),E.delete(k))}}(l,a,r._dirtyLeaves,r._dirtyElements)),m!==r._compositionKey&&(a._flushSync=!0);const x=a._selection;if(H(x)){const _=a._nodeMap,y=x.anchor.key,w=x.focus.key;_.get(y)!==void 0&&_.get(w)!==void 0||K(19)}else Wt(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{ot=c,Ct=d,at=f,r._updating=p,ws=0}r._dirtyType!==Nr||function(m,x){const _=x.getEditorState()._selection,y=m._selection;if(y!==null){if(y.dirty||!y.is(_))return!0}else if(_!==null)return!0;return!1}(a,r)?a._flushSync?(a._flushSync=!1,pr(r)):u&&lh(()=>{pr(r)}):(a._flushSync=!1,u&&(n.clear(),r._deferred=[],r._pendingEditorState=null))}function kt(r,e,t){r._updating?r._updates.push([e,t]):dc(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 a=this.getFirstChildOffset();return[e,Math.min(a+e.getChildrenSize(),Math.max(a,s))]}const i=ll(t,n);i.push(s);const o=ll(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 ll(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 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 Jf[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=Qe()._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(Q(t)&&e.push(t),I(t)){const n=t.getAllTextNodes();e.push(...n)}t=t.getNextSibling()}return e}getFirstDescendant(){let e=this.getFirstChild();for(;I(e);){const t=e.getFirstChild();if(t===null)break;e=t}return e}getLastDescendant(){let e=this.getLastChild();for(;I(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)&&i.getLastDescendant()||i||null}const s=t[e];return I(s)&&s.getFirstDescendant()||s||null}getFirstChild(){const e=this.getLatest().__first;return e===null?null:dt(e)}getFirstChildOrThrow(){const e=this.getFirstChild();return e===null&&K(45,this.__key),e}getLastChild(){const e=this.getLatest().__last;return e===null?null:dt(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(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(),I(i)&&s!==n-1&&!i.isInline()&&(e+=sr.length)}return e}getDirection(){return this.getLatest().__dir}hasFormat(e){if(e!==""){const t=Da[e];return!!(this.getFormat()&t)}return!1}select(e,t){_t();const n=oe();let s=e,i=t;const o=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){const a=this.getFirstChild();if(Q(a)||I(a))return a.select(0,0)}else if(!(e!==void 0&&e!==o||t!==void 0&&t!==o)){const a=this.getLastChild();if(Q(a)||I(a))return a.select()}}s===void 0&&(s=o),i===void 0&&(i=o);const l=this.__key;return H(n)?(n.anchor.set(l,s,"element"),n.focus.set(l,i,"element"),n.dirty=!0,n):ic(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!==""?Da[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 l=o.__key,a=[],u=[],c=this.getChildAtIndex(e+t);let d=null,f=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===l&&f--,Dr(x);const _=m.__key;if(p===null)o.__first=_,x.__prev=null;else{const y=p.getWritable();y.__next=_,x.__prev=y.__key}m.__key===l&&K(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=f,u.length){const g=oe();if(H(g)){const m=new Set(u),x=new Set(a),{anchor:_,focus:y}=g;ul(_,m,x)&&Hs(_,_.getNode(),this,d,c),ul(y,m,x)&&Hs(y,y.getNode(),this,d,c),f!==0||this.canBeEmpty()||Yt(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 I(r){return r instanceof lr}function ul(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 ze(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(){K(51)}getTextContent(){const e=this.__cachedText;return!es()&&Qe()._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];I(n)||ze(n)||K(56)}return super.append(...e)}static importJSON(e){const t=Ge();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 pt(r){return r instanceof ts}function fc(r){return new gi(new Map(r._nodeMap))}function na(){return new gi(new Map([["root",new ts]]))}function hc(r){const e=r.exportJSON(),t=r.constructor;if(e.type!==t.getType()&&K(130,t.name),I(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=hc(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 ol(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 ol(null,this,()=>({root:hc(Ge())}))}}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:Ph,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=rt();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=rt();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||Q(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 Ph(r){const e=rt();return r.style&&(e.setFormat(r.style.textAlign),Jo(r,e)),{node:e}}function rt(){return Xt(new on)}function tn(r){return r instanceof on}const je=0,Vr=1,Ih=4;function pc(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 Oh(r){const e=r||{},t=jh(),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:Iu()),a=e.editorState,u=[ts,sn,Qn,Xn,on,sa,...e.nodes||[]],{onError:c,html:d}=e,f=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,y=null;if(typeof x!="function"){const E=x;x=E.replace,_=E.with,y=E.withKlass||null}const w=x.getType(),C=x.transform(),D=new Set;C!==null&&D.add(C),p.set(w,{exportDOM:d&&d.export?d.export.get(x):void 0,klass:x,replace:_,replaceWithKlass:y,transforms:D})}}const g=new mi(o,s,p,{disableEvents:i,namespace:l,theme:n},c||console.error,function(m,x){const _=new Map,y=new Set,w=C=>{Object.keys(C).forEach(D=>{let E=_.get(D);E===void 0&&(E=[],_.set(D,E)),E.push(C[D])})};return m.forEach(C=>{const D=C.klass.importDOM;if(D==null||y.has(D))return;y.add(D);const E=D.call(C.klass);E!==null&&w(E)}),x&&w(x),_}(p,d?d.import:void 0),f);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=Iu(),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&&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(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&&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=xh(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(),kt(o,()=>{const a=ar();if(a.isEmpty())return;if(l==="root")return void Ge().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 re(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,pc(this,t,e,s),t!==null&&(this._config.disableEvents||Ch(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,Nu(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",ec),Us.set(u,(c||0)+1),l.__lexicalEditor=a;const d=Zu(l);for(let f=0;f<io.length;f++){const[p,g]=io[f],m=typeof g=="function"?x=>{Ha(x)||(Wa(x),(a.isEditable()||p==="click")&&g(x,a))}:x=>{if(Ha(x))return;Wa(x);const _=a.isEditable();switch(p){case"cut":return _&&re(a,Fo,x);case"copy":return re(a,ii,x);case"paste":return _&&re(a,si,x);case"dragstart":return _&&re(a,wu,x);case"dragover":return _&&re(a,Cu,x);case"dragend":return _&&re(a,jf,x);case"focus":return _&&re(a,If,x);case"blur":return _&&re(a,Of,x);case"drop":return _&&re(a,_u,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;Rn("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=fc(e),n._selection=e._selection?e._selection.clone():null),Tu(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=ot,a=Ct,u=at,c=s._dirtyElements,d=s._dirtyLeaves,f=s._cloneNotNeeded,p=s._dirtyType;s._dirtyElements=new Map,s._dirtyLeaves=new Set,s._cloneNotNeeded=new Set,s._dirtyType=0,ot=o,Ct=!1,at=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=f,s._dirtyType=p,ot=l,Ct=a,at=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){kt(this,e,t)}focus(e,t={}){const n=this._rootElement;n!==null&&(n.setAttribute("autocapitalize","off"),kt(this,()=>{const s=oe(),i=Ge();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=Nt(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,Rn("editable",this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}}mi.version="0.21.0+prod.esm";const gc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,zh=gc?b.useLayoutEffect:b.useEffect,ds={tag:"history-merge"};function $h({initialConfig:r,children:e}){const t=b.useMemo(()=>{const{theme:n,namespace:s,nodes:i,onError:o,editorState:l,html:a}=r,u=kf(null,n),c=Oh({editable:r.editable,html:a,namespace:s,nodes:i,onError:d=>o(d,c),theme:n});return function(d,f){if(f!==null){if(f===void 0)d.update(()=>{const p=Ge();if(p.isEmpty()){const g=rt();p.append(g);const m=gc?document.activeElement:null;(oe()!==null||m!==null&&m===d.getRootElement())&&g.select()}},ds);else if(f!==null)switch(typeof f){case"string":{const p=d.parseEditorState(f);d.setEditorState(p,ds);break}case"object":d.setEditorState(f,ds);break;case"function":d.update(()=>{Ge().isEmpty()&&f(d)},ds)}}}(c,l),[c,u]},[]);return zh(()=>{const n=r.editable,[s]=t;s.setEditable(n===void 0||n)},[]),h.jsx(fu.Provider,{value:t,children:e})}const qh=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?b.useLayoutEffect:b.useEffect;function Uh(r){return{initialValueFn:()=>r.isEditable(),subscribe:e=>r.registerEditableListener(e)}}function Wh(){return function(r){const[e]=zt(),t=b.useMemo(()=>r(e),[e,r]),[n,s]=b.useState(()=>t.initialValueFn()),i=b.useRef(n);return qh(()=>{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}(Uh)}function Hh(){return Ge().getTextContent()}function Vh(r,e=!0){if(r)return!1;let t=Hh();return e&&(t=t.trim()),t===""}function Gh(r){if(!Vh(r,!1))return!1;const e=Ge().getChildren(),t=e.length;if(t>1)return!1;for(let n=0;n<t;n++){const s=e[n];if(ze(s))return!1;if(I(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(!Q(a))return!1}}}return!0}function mc(r){return()=>Gh(r)}function Kh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}Kh(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 Yh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Qh=Yh(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 Xh=new Map;function Jh(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 yc(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),f=o.is(l),p=e.is(i?l:o),g=e.is(i?o:l);let m,x=0;return f?(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 Zh(r){const e=r.getStyle(),t=Jh(e);Xh.set(e,t)}function ep(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=Ge(),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(),fl);i&&s.indexOf(i)===-1&&s.push(i);for(let o=0;o<s.length;o++){const l=s[o];if(!fl(l))continue;I(l)||Qh(178);const a=e();a.setFormat(l.getFormatType()),a.setIndent(l.getIndent()),l.replace(a,!0)}}function cl(r,e){const t=Pn(r.focus,e);return ze(t)&&!t.isIsolated()||I(t)&&!t.isInline()&&!t.canBeEmpty()}function tp(r,e,t,n){r.modify(e?"extend":"move",t,n)}function rp(r){const e=r.anchor.getNode();return(pt(e)?e:e.getParentOrThrow()).getDirection()==="rtl"}function dl(r,e,t){const n=rp(r);tp(r,e,t?!n:n,"character")}function fl(r){if(ze(r)||!I(r)||Yt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||Q(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function np(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var sp=np(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 xc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,ip=xc&&"documentMode"in document?document.documentMode:null;!(!xc||!("InputEvent"in window)||ip)&&"getTargetRanges"in new window.InputEvent("input");function bc(...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=bc(...e);t.length>0&&r.classList.add(...t)}function vc(r,...e){const t=bc(...e);t.length>0&&r.classList.remove(...t)}function op(r,e){let t=r;for(;t!=null;){if(t instanceof e)return t;t=t.getParent()}return null}function ap(r){const e=yi(r,t=>I(t)&&!t.isInline());return I(e)||sp(4,r.__key),e}const yi=(r,e)=>{let t=r;for(;t!==Ge()&&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 lp(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,f,p,g]=a;r.update(()=>{const m=oe();if(H(m)){const x=m.anchor;let _=x.getNode(),y=0,w=0;if(Q(_)&&u>=0&&c>=0&&(y=u,w=u+c,m.setTextNodeRange(_,y,_,w)),y===w&&d===""||(m.insertRawText(d),_=x.getNode()),Q(_)){y=f,w=f+p;const C=_.getTextContentSize();y=y>C?C:y,w=w>C?C:w,m.setTextNodeRange(_,y,_,w)}n.stopImmediatePropagation()}})}}}}};return window.addEventListener("message",t,!0),()=>{window.removeEventListener("message",t,!0)}}function _c(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(!Sc.has(o.nodeName)){const l=kc(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 wc(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=Ge().getChildren();for(let s=0;s<n.length;s++)Cc(r,n[s],t,e);return t.innerHTML}function Cc(r,e,t,n=null){let s=n===null||e.isSelected(n);const i=I(e)&&e.excludeFromCopy("html");let o=e;if(n!==null){let p=Xo(e);p=Q(p)&&n!==null?yc(n,p):p,o=p}const l=I(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 f=document.createDocumentFragment();for(let p=0;p<l.length;p++){const g=l[p],m=Cc(r,g,f,n);!s&&I(e)&&m&&e.extractWithChild(g,n,"html")&&(s=!0)}if(s&&!i){if((or(c)||Oa(c))&&c.append(f),t.append(c),d){const p=d.call(o,c);p&&(Oa(c)?c.replaceChildren(p):c.replaceWith(p))}}else t.append(f);return s}const Sc=new Set(["STYLE","SCRIPT"]);function kc(r,e,t,n,s=new Map,i){let o=[];if(Sc.has(r.nodeName))return o;let l=null;const a=function(g,m){const{nodeName:x}=g,_=m._htmlConversions.get(x.toLowerCase());let y=null;if(_!==void 0)for(const w of _){const C=w(g);C!==null&&(y===null||(y.priority||0)<=(C.priority||0))&&(y=C)}return y!==null?y.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 f=[];const p=(l==null||!Yt(l))&&(l!=null&&co(l)||n);for(let g=0;g<d.length;g++)f.push(...kc(d[g],e,t,p,new Map(s),l));return c!=null&&(f=c(f)),Os(r)&&(f=up(r,f,p?()=>{const g=new sa;return t.push(g),g}:rt)),l==null?f.length>0?o=o.concat(f):Os(r)&&function(g){return g.nextSibling==null||g.previousSibling==null?!1:Xi(g.nextSibling)&&Xi(g.previousSibling)}(r)&&(o=o.concat(Mr())):I(l)&&l.append(...f),o}function up(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 cp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Vs=cp(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 dp(r,e=oe()){return e==null&&Vs(166),H(e)&&e.isCollapsed()||e.getNodes().length===0?"":wc(r,e)}function fp(r,e=oe()){return e==null&&Vs(166),H(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(hp(r,e))}function hl(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 pl(t,pp(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 pl(t,_c(t,o),e)}catch{}const i=r.getData("text/plain")||r.getData("text/uri-list");if(i!=null)if(H(e)){const o=i.split(/(\r?\n|\t)/);o[o.length-1]===""&&o.pop();for(let l=0;l<o.length;l++){const a=oe();if(H(a)){const u=o[l];u===`
93
+ `?n.push(Mr()):o===" "?n.push(Jn()):n.push(st(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,v,y,_){const S=x.getNode(),E=S.getChildAtIndex(x.offset),k=st(),w=pt(S)?rt().append(k):k;k.setFormat(y),k.setStyle(_),E===null?S.append(w):E.insertBefore(w),x.is(v)&&v.set(k.__key,0,"text"),x.set(k.__key,0,"text")}(o,l,s,i);const a=o.offset;let u=l.offset;const c=this.getNodes(),d=c.length;let f=c[0];X(f)||K(26);const p=f.getTextContent().length,g=f.getParentOrThrow();let m=c[d-1];if(d===1&&l.type==="element"&&(u=p,l.set(o.key,u,"text")),this.isCollapsed()&&a===p&&(f.isSegmented()||f.isToken()||!f.canInsertTextAfter()||!g.canInsertTextAfter()&&f.getNextSibling()===null)){let x=f.getNextSibling();if(X(x)&&x.canInsertTextBefore()&&!Cr(x)||(x=st(),x.setFormat(s),x.setStyle(i),g.canInsertTextAfter()?f.insertAfter(x):g.insertAfter(x)),x.select(0,0),f=x,e!=="")return void this.insertText(e)}else if(this.isCollapsed()&&a===0&&(f.isSegmented()||f.isToken()||!f.canInsertTextBefore()||!g.canInsertTextBefore()&&f.getPreviousSibling()===null)){let x=f.getPreviousSibling();if(X(x)&&!Cr(x)||(x=st(),x.setFormat(s),g.canInsertTextBefore()?f.insertBefore(x):g.insertBefore(x)),x.select(),f=x,e!=="")return void this.insertText(e)}else if(f.isSegmented()&&a!==p){const x=st(f.getTextContent());x.setFormat(s),f.replace(x),f=x}else if(!this.isCollapsed()&&e!==""){const x=m.getParent();if(!g.canInsertTextBefore()||!g.canInsertTextAfter()||O(x)&&(!x.canInsertTextBefore()||!x.canInsertTextAfter()))return this.insertText(""),nc(this.anchor,this.focus,null),void this.insertText(e)}if(d===1){if(f.isToken()){const _=st(e);return _.select(),void f.replace(_)}const x=f.getFormat(),v=f.getStyle();if(a!==u||x===s&&v===i){if(Nh(f)){const _=st(e);return _.setFormat(s),_.setStyle(i),_.select(),void f.replace(_)}}else{if(f.getTextContent()!==""){const _=st(e);if(_.setFormat(s),_.setStyle(i),_.select(),a===0)f.insertBefore(_,!1);else{const[S]=f.splitText(a);S.insertAfter(_,!1)}return void(_.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length))}f.setFormat(s),f.setStyle(i)}const y=u-a;f=f.spliceText(a,y,e,!0),f.getTextContent()===""?f.remove():this.anchor.type==="text"&&(f.isComposing()?this.anchor.offset-=e.length:(this.format=x,this.style=v))}else{const x=new Set([...f.getParentKeys(),...m.getParentKeys()]),v=O(f)?f:f.getParentOrThrow();let y=O(m)?m:m.getParentOrThrow(),_=m;if(!v.is(y)&&y.isInline())do _=y,y=y.getParentOrThrow();while(y.isInline());if(l.type==="text"&&(u!==0||m.getTextContent()==="")||l.type==="element"&&m.getIndexWithinParent()<u)if(X(m)&&!m.isToken()&&u!==m.getTextContentSize()){if(m.isSegmented()){const D=st(m.getTextContent());m.replace(D),m=D}pt(l.getNode())||l.type!=="text"||(m=m.spliceText(0,u,"")),x.add(m.__key)}else{const D=m.getParentOrThrow();D.canBeEmpty()||D.getChildrenSize()!==1?m.remove():D.remove()}else x.add(m.__key);const S=y.getChildren(),E=new Set(c),k=v.is(y),w=v.isInline()&&f.getNextSibling()===null?v:f;for(let D=S.length-1;D>=0;D--){const j=S[D];if(j.is(f)||O(j)&&j.isParentOf(f))break;j.isAttached()&&(!E.has(j)||j.is(_)?k||w.insertAfter(j,!1):j.remove())}if(!k){let D=y,j=null;for(;D!==null;){const B=D.getChildren(),T=B.length;(T===0||B[T-1].is(j))&&(x.delete(D.__key),j=D),D=D.getParent()}}if(f.isToken())if(a===p)f.select();else{const D=st(e);D.select(),f.replace(D)}else f=f.spliceText(a,p-a,e,!0),f.getTextContent()===""?f.remove():f.isComposing()&&this.anchor.type==="text"&&(this.anchor.offset-=e.length);for(let D=1;D<d;D++){const j=c[D],B=j.__key;x.has(B)||j.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);X(o)&&o.isToken()&&s.offset<o.getTextContentSize()&&(s.offset=0),i.offset>0&&X(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,f)=>{if(d.getTextContent()==="")d.remove();else if(f!==0&&Cr(d)){const p=st(d.getTextContent());return p.setFormat(d.getFormat()),p.setStyle(d.getStyle()),d.replace(p)}};if(o===l&&X(o)){const d=Math.abs(t.offset-e.offset);return o.spliceText(s.offset,d,"",!0),void c(o,d)}if(X(o)){const d=o.getTextContentSize()-s.offset;o.spliceText(s.offset,d,""),o=c(o,d)||o}X(l)&&(l.spliceText(0,i.offset,""),l=c(l,i.offset)||l),o.isAttached()&&X(o)?o.selectEnd():l.isAttached()&&X(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 lt(null);const n=this.getNodes(),s=[];for(const S of n)X(S)&&s.push(S);const i=S=>{n.forEach(E=>{if(tn(E)){const k=E.getFormatFlags(e,S);E.setTextFormat(k)}})},o=s.length;if(o===0)return this.toggleFormat(e),lt(null),void i(t);const l=this.anchor,a=this.focus,u=this.isBackward(),c=u?a:l,d=u?l:a;let f=0,p=s[0],g=c.type==="element"?0:c.offset;if(c.type==="text"&&g===p.getTextContentSize()&&(f=1,p=s[1],g=0),p==null)return;const m=p.getFormatFlags(e,t);i(m);const x=o-1;let v=s[x];const y=d.type==="text"?d.offset:v.getTextContentSize();if(p.is(v)){if(g===y)return;if(Cr(p)||g===0&&y===p.getTextContentSize())p.setFormat(m);else{const S=p.splitText(g,y),E=g===0?S[0]:S[1];E.setFormat(m),c.type==="text"&&c.set(E.__key,0,"text"),d.type==="text"&&d.set(E.__key,y-g,"text")}return void(this.format=m)}g===0||Cr(p)||([,p]=p.splitText(g),g=0),p.setFormat(m);const _=v.getFormatFlags(e,m);y>0&&(y===v.getTextContentSize()||Cr(v)||([v]=v.splitText(y)),v.setFormat(_));for(let S=f+1;S<x;S++){const E=s[S],k=E.getFormatFlags(e,_);E.setFormat(k)}c.type==="text"&&c.set(p.__key,g,"text"),d.type==="text"&&d.set(v.__key,y,"text"),this.format=m|_}insertNodes(e){if(e.length===0)return;if(this.anchor.key==="root"){this.insertParagraph();const g=oe();return V(g)||K(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=Oi(this);n.splice(g,0,e),s.selectEnd()}return}if(!e.some(g=>(O(g)||ze(g))&&!g.isInline())){O(n)||K(211,t.constructor.name,t.getType());const g=Oi(this);return n.splice(g,0,e),void s.selectEnd()}const i=function(g){const m=rt();let x=null;for(let v=0;v<g.length;v++){const y=g[v],_=Ar(y);if(_||ze(y)&&y.isInline()||O(y)&&y.isInline()||X(y)||y.isParentRequired()){if(x===null&&(x=y.createParentElementNode(),m.append(x),_))continue;x!==null&&x.append(y)}else m.append(y),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)||K(211,t.constructor.name,t.getType()),n.append(...c.getChildren()),c=l[1]),c&&(n===null&&K(212,t.constructor.name,t.getType()),function(g,m,x){const v=m.getParentOrThrow().getLastChild();let y=m;const _=[m];for(;y!==v;)y.getNextSibling()||K(140),y=y.getNextSibling(),_.push(y);let S=g;for(const E of _)S=S.insertAfter(E)}(n,c));const f=pn(o,cr);a&&O(f)&&(a.canMergeWhenEmpty()||cr(u))&&(f.append(...a.getChildren()),a.remove()),O(n)&&n.isEmpty()&&n.remove(),o.selectEnd();const p=O(n)?n.getLastChild():null;Ar(p)&&f!==n&&p.remove()}insertParagraph(){if(this.anchor.key==="root"){const o=rt();return Ge().splice(this.anchor.offset,0,[o]),o.select(),o}const e=Oi(this),t=pn(this.anchor.getNode(),cr);O(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],l=e[n];const[a,u]=uo(this);if(t===0)return[];if(t===1){if(X(o)&&!this.isCollapsed()){const d=a>u?u:a,f=a>u?a:u,p=o.splitText(d,f),g=d===0?p[0]:p[1];return g!=null?[g]:[]}return[o]}const c=s.isBefore(i);if(X(o)){const d=c?a:u;d===o.getTextContentSize()?e.shift():d!==0&&([,o]=o.splitText(d),e[0]=o)}if(X(l)){const d=l.getTextContent().length,f=c?u:a;f===0?e.pop():f!==d&&([l]=l.splitText(f),e[n]=l)}return e}modify(e,t,n){const s=this.focus,i=this.anchor,o=e==="move",l=Pn(s,t);if(ze(l)&&!l.isIsolated()){if(o&&l.isKeyboardSelectable()){const p=el();return p.add(l.__key),void Kt(p)}const f=t?l.getPreviousSibling():l.getNextSibling();if(X(f)){const p=f.__key,g=t?f.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(f)?(m=f.__key,g=t?f.getChildrenSize():0):(g=l.getIndexWithinParent(),m=p.__key,t||g++),s.set(m,g,"element"),void(o&&i.set(m,g,"element"))}}const a=Qe(),u=Nt(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(f,p,g,m){f.modify(p,g,m)}(u,e,t?"backward":"forward",n),u.rangeCount>0){const f=u.getRangeAt(0),p=this.anchor.getNode(),g=pt(p)?p:hh(p);if(this.applyDOMRange(f),this.dirty=!0,!o){const m=this.getNodes(),x=[];let v=!1;for(let y=0;y<m.length;y++){const _=m[y];Tn(_,g)?x.push(_):v=!0}if(v&&x.length>0)if(t){const y=x[0];O(y)?y.selectStart():y.getParentOrThrow().selectStart()}else{const y=x[x.length-1];O(y)?y.selectEnd():y.getParentOrThrow().selectEnd()}u.anchorNode===f.startContainer&&u.anchorOffset===f.startOffset||function(y){const _=y.focus,S=y.anchor,E=S.key,k=S.offset,w=S.type;dr(S,_.key,_.offset,_.type),dr(_,E,k,w),y._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(ze(o)&&!o.isIsolated()){if(o.isKeyboardSelectable()&&O(s)&&s.getChildrenSize()===0){s.remove();const l=el();l.add(o.__key),Kt(l)}else o.remove(),Qe().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,f=c.getNode(),p=d.getNode();if(f===p&&c.type==="text"&&d.type==="text"){const g=c.offset,m=d.offset,x=g<m,v=x?g:m,y=x?m:g,_=y-1;v!==_&&(Pu(f.getTextContent().slice(v,y))||(u?d.offset=_:c.offset=_))}})(this,e)}}if(this.removeText(),e&&!t&&this.isCollapsed()&&this.anchor.type==="element"&&this.anchor.offset===0){const n=this.anchor.getNode();n.isEmpty()&&pt(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 Wt(r){return r instanceof pi}function Qa(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]:[Qa(t),Qa(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 Ja(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 f=u.parentNode;r===f&&e>Array.prototype.indexOf.call(f.children,u)&&i--}if(s=Hr(c),X(s))i=Ma(s,o);else{let f=Hr(r);if(f===null)return null;if(O(f)){const p=n.getElementByKey(f.getKey());p===null&&K(214),[f,i]=f.getDOMSlot(p).resolveChildIndex(f,p,r,e),O(f)||K(215),o&&i>=f.getChildrenSize()&&(i=Math.max(0,f.getChildrenSize()-1));let m=f.getChildAtIndex(i);if(O(m)&&function(x,v,y){const _=x.getParent();return y===null||_===null||!_.canBeEmpty()||_!==y.getNode()}(m,0,t)){const x=o?m.getLastDescendant():m.getFirstDescendant();x===null?f=m:(m=x,f=O(m)?m:m.getParentOrThrow()),i=0}X(m)?(s=m,f=null,i=Ma(m,o)):m!==f&&o&&!d&&(O(f)||K(216),i=Math.min(f.getChildrenSize(),i+1))}else{const p=f.getIndexWithinParent();i=e===0&&ze(f)&&Hr(r)===f?p:p+1,f=f.getParentOrThrow()}if(O(f))return Qt(f.__key,i,"element")}}else s=Hr(r);return X(s)?Qt(s.__key,i,"text"):null}function Za(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();X(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"):X(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();X(l)&&(r.key=l.__key,r.offset=0)}}}function nc(r,e,t){if(r.type==="text"&&e.type==="text"){const n=r.isBefore(e),s=r.is(e);Za(r,n,s),Za(e,!n,s),s&&(e.key=r.key,e.offset=r.offset,e.type=r.type);const i=Qe();if(i.isComposing()&&i._compositionKey!==r.key&&V(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 sc(r,e,t,n,s,i){if(r===null||t===null||!Kn(s,r,t))return null;const o=Ja(r,e,V(i)?i.anchor:null,s);if(o===null)return null;const l=Ja(t,n,V(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(ze(a)&&ze(u))return null}return nc(o,l,i),[o,l]}function co(r){return O(r)&&!r.isInline()}function ic(r,e,t,n,s,i){const o=ar(),l=new br(Qt(r,e,s),Qt(t,n,i),0,"");return l.dirty=!0,o._selection=l,l}function Rh(){const r=Qt("root",0,"element"),e=Qt("root",0,"element");return new br(r,e,0,"")}function el(){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,f;if(V(r)&&!a)return r.clone();if(e===null)return null;if(u=e.anchorNode,c=e.focusNode,d=e.anchorOffset,f=e.focusOffset,l&&V(r)&&!Kn(t,u,c))return r.clone();const p=sc(u,d,c,f,t,r);if(p===null)return null;const[g,m]=p;return new br(g,m,V(r)?r.format:0,V(r)?r.style:"")}function oe(){return ar()._selection}function Zn(){return Qe()._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"),tl(r)}}else{const u=r.isBackward(),c=u?i:s,d=c.getNode(),f=u?s:i,p=f.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=f.offset;(t<=g&&n>0||t<g&&n<0)&&f.set(a,Math.max(0,g+n),"element")}}tl(r)}function tl(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(X(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(X(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(X(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,X(n)?(o=n.getTextContentSize(),l="text"):O(n)&&(o=n.getChildrenSize(),l="element")):s!==null&&(i=s.__key,X(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 rl(r,e,t,n,s){r.type==="text"?(r.key=t,e||(r.offset+=s)):r.offset>n.getIndexWithinParent()&&(r.offset-=1)}function Mh(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(!V(e))return void(r!==null&&Kn(t,l,a)&&n.removeAllRanges());const f=e.anchor,p=e.focus,g=f.key,m=p.key,x=Is(t,g),v=Is(t,m),y=f.offset,_=p.offset,S=e.format,E=e.style,k=e.isCollapsed();let w=x,D=v,j=!1;if(f.type==="text"){w=js(x);const N=f.getNode();j=N.getFormat()!==S||N.getStyle()!==E}else V(r)&&r.anchor.type==="text"&&(j=!0);var B,T,R,M,C;if(p.type==="text"&&(D=js(v)),w!==null&&D!==null&&(k&&(r===null||j||V(r)&&(r.format!==S||r.style!==E))&&(B=S,T=E,R=y,M=g,C=performance.now(),Qu=[B,T,R,M,C]),u!==y||c!==_||l!==w||a!==D||n.type==="Range"&&k||(d!==null&&i.contains(d)||i.focus({preventScroll:!0}),f.type==="element"))){try{n.setBaseAndExtent(w,y,D,_)}catch{}if(!s.has("skip-scroll-into-view")&&e.isCollapsed()&&i!==null&&i===document.activeElement){const N=e instanceof br&&e.anchor.type==="element"?w.childNodes[y]||null:n.rangeCount>0?n.getRangeAt(0):null;if(N!==null){let F;if(N instanceof Text){const I=document.createRange();I.selectNode(N),F=I.getBoundingClientRect()}else F=N.getBoundingClientRect();(function(I,W,z){const te=z.ownerDocument,U=te.defaultView;if(U===null)return;let{top:Q,bottom:H}=W,se=0,ue=0,de=z;for(;de!==null;){const pe=de===te.body;if(pe)se=0,ue=di(I).innerHeight;else{const xe=de.getBoundingClientRect();se=xe.top,ue=xe.bottom}let De=0;if(Q<se?De=-(se-Q):H>ue&&(De=H-ue),De!==0)if(pe)U.scrollBy(0,De);else{const xe=de.scrollTop;de.scrollTop+=De;const J=de.scrollTop-xe;Q-=J,H-=J}if(pe)break;de=Yn(de)}})(t,F,i)}}oo=!0}}function oc(r){let e=oe()||Zn();e===null&&(e=Ge().selectEnd()),e.insertNodes(r)}function Oi(r){let e=r;r.isCollapsed()||e.removeText();const t=oe();V(t)&&(e=t),V(e)||K(161);const n=e.anchor;let s=n.getNode(),i=n.offset;for(;!cr(s);)[s,i]=Fh(s,i);return i}function Fh(r,e){const t=r.getParent();if(!t){const s=rt();return Ge().append(s),s.select(),[Ge(),0]}if(X(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(Qt(r.__key,e,"element"),Qt(r.__key,e,"element"),0,""),i=r.insertNewAfter(s);i&&i.append(n,...n.getNextSiblings())}return[t,r.getIndexWithinParent()+1]}let ot=null,at=null,Ct=!1,zi=!1,ws=0;const nl={characterData:!0,childList:!0,subtree:!0};function es(){return Ct||ot!==null&&ot._readOnly}function _t(){Ct&&K(13)}function ac(){ws>99&&K(14)}function ar(){return ot===null&&K(195,lc()),ot}function Qe(){return at===null&&K(196,lc()),at}function lc(){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 jh(){return at}function sl(r,e,t){const n=e.__type,s=function(l,a){const u=l._nodes.get(a);return u===void 0&&K(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 il(r,e){return r!==void 0&&r.__key!==e&&r.isAttached()}function uc(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 Lh(r){return ta(r,Qe()._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(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 ol(r,e,t){const n=ot,s=Ct,i=at;ot=e,Ct=!0,at=r;try{return t()}finally{ot=n,Ct=s,at=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=ot,c=Ct,d=at,f=r._updating,p=r._observer;let g=null;if(r._pendingEditorState=null,r._editorState=t,!s&&a&&p!==null){at=r,ot=t,Ct=!1,r._updating=!0;try{const k=r._dirtyType,w=r._dirtyElements,D=r._dirtyLeaves;p.disconnect(),g=wh(i,t,r,k,w,D)}catch(k){if(k instanceof Error&&r._onError(k),zi)throw k;return pc(r,null,n,t),Nu(r),r._dirtyType=Zr,zi=!0,pr(r,i),void(zi=!1)}finally{p.observe(n,nl),r._updating=f,ot=u,Ct=c,at=d}}t._readOnly||(t._readOnly=!0);const m=r._dirtyLeaves,x=r._dirtyElements,v=r._normalizedNodes,y=r._updateTags,_=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(k,w){const D=k._decorators;let j=k._pendingDecorators||D;const B=w._nodeMap;let T;for(T in j)B.has(T)||(j===D&&(j=ju(k)),delete j[T])}(r,t);const S=s?null:Nt(r._window);if(r._editable&&S!==null&&(a||l===null||l.dirty)){at=r,ot=t;try{if(p!==null&&p.disconnect(),a||l===null||l.dirty){const k=r._blockCursorElement;k!==null&&Qo(k,r,n),Mh(o,l,r,S,y,n)}ph(r,n,l),p!==null&&p.observe(n,nl)}finally{at=d,ot=u}}g!==null&&function(k,w,D,j,B){const T=Array.from(k._listeners.mutation),R=T.length;for(let M=0;M<R;M++){const[C,N]=T[M],F=w.get(N);F!==void 0&&C(F,{dirtyLeaves:j,prevEditorState:B,updateTags:D})}}(r,g,y,m,i),V(l)||l===null||o!==null&&o.is(l)||r.dispatchCommand(Bo,void 0);const E=r._pendingDecorators;E!==null&&(r._decorators=E,r._pendingDecorators=null,Rn("decorator",r,!0,E)),function(k,w,D){const j=Ra(w),B=Ra(D);j!==B&&Rn("textcontent",k,!0,B)}(r,e||i,t),Rn("update",r,!0,{dirtyElements:x,dirtyLeaves:m,editorState:t,normalizedNodes:v,prevEditorState:e||i,tags:y}),function(k,w){if(k._deferred=[],w.length!==0){const D=k._updating;k._updating=!0;try{for(let j=0;j<w.length;j++)w[j]()}finally{k._updating=D}}}(r,_),function(k){const w=k._updates;if(w.length!==0){const D=w.shift();if(D){const[j,B]=D;dc(k,j,B)}}}(r)}function Rn(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 cc(r,e,t){if(r._updating===!1||at!==r){let s=!1;return r.update(()=>{s=cc(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 al(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&&K(191),a._flushSync=!0}l&&r._deferred.push(l),uc(r,o.tag)}i()}}return n}function dc(r,e,t){const n=r._updateTags;let s,i=!1,o=!1;t!==void 0&&(s=t.onUpdate,uc(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=fc(a||l),u=!0),a._flushSync=o;const c=ot,d=Ct,f=at,p=r._updating;ot=a,Ct=!1,r._updating=!0,at=r;try{u&&(r._headless?l._selection!==null&&(a._selection=l._selection.clone()):a._selection=function(v){const y=v.getEditorState()._selection,_=Nt(v._window);return V(y)||y==null?ea(y,_,v,null):y.clone()}(r));const m=r._compositionKey;e(),i=al(r,i),function(v,y){const _=y.getEditorState()._selection,S=v._selection;if(V(S)){const E=S.anchor,k=S.focus;let w;if(E.type==="text"&&(w=E.getNode(),w.selectionTransform(_,S)),k.type==="text"){const D=k.getNode();w!==D&&D.selectionTransform(_,S)}}}(a,r),r._dirtyType!==Nr&&(i?function(v,y){const _=y._dirtyLeaves,S=v._nodeMap;for(const E of _){const k=S.get(E);X(k)&&k.isAttached()&&k.isSimpleText()&&!k.isUnmergeable()&&Na(k)}}(a,r):function(v,y){const _=y._dirtyLeaves,S=y._dirtyElements,E=v._nodeMap,k=hr(),w=new Map;let D=_,j=D.size,B=S,T=B.size;for(;j>0||T>0;){if(j>0){y._dirtyLeaves=new Set;for(const R of D){const M=E.get(R);X(M)&&M.isAttached()&&M.isSimpleText()&&!M.isUnmergeable()&&Na(M),M!==void 0&&il(M,k)&&sl(y,M,w),_.add(R)}if(D=y._dirtyLeaves,j=D.size,j>0){ws++;continue}}y._dirtyLeaves=new Set,y._dirtyElements=new Map;for(const R of B){const M=R[0],C=R[1];if(M!=="root"&&!C)continue;const N=E.get(M);N!==void 0&&il(N,k)&&sl(y,N,w),S.set(M,C)}D=y._dirtyLeaves,j=D.size,B=y._dirtyElements,T=B.size,ws++}y._dirtyLeaves=_,y._dirtyElements=S}(a,r),al(r),function(v,y,_,S){const E=v._nodeMap,k=y._nodeMap,w=[];for(const[D]of S){const j=k.get(D);j!==void 0&&(j.isAttached()||(O(j)&&$u(j,D,E,k,w,S),E.has(D)||S.delete(D),w.push(D)))}for(const D of w)k.delete(D);for(const D of _){const j=k.get(D);j===void 0||j.isAttached()||(E.has(D)||_.delete(D),k.delete(D))}}(l,a,r._dirtyLeaves,r._dirtyElements)),m!==r._compositionKey&&(a._flushSync=!0);const x=a._selection;if(V(x)){const v=a._nodeMap,y=x.anchor.key,_=x.focus.key;v.get(y)!==void 0&&v.get(_)!==void 0||K(19)}else Wt(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{ot=c,Ct=d,at=f,r._updating=p,ws=0}r._dirtyType!==Nr||function(m,x){const v=x.getEditorState()._selection,y=m._selection;if(y!==null){if(y.dirty||!y.is(v))return!0}else if(v!==null)return!0;return!1}(a,r)?a._flushSync?(a._flushSync=!1,pr(r)):u&&lh(()=>{pr(r)}):(a._flushSync=!1,u&&(n.clear(),r._deferred=[],r._pendingEditorState=null))}function kt(r,e,t){r._updating?r._updates.push([e,t]):dc(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 a=this.getFirstChildOffset();return[e,Math.min(a+e.getChildrenSize(),Math.max(a,s))]}const i=ll(t,n);i.push(s);const o=ll(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 ll(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 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 Jf[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=Qe()._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(X(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:dt(e)}getFirstChildOrThrow(){const e=this.getFirstChild();return e===null&&K(45,this.__key),e}getLastChild(){const e=this.getLatest().__last;return e===null?null:dt(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(),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=Da[e];return!!(this.getFormat()&t)}return!1}select(e,t){_t();const n=oe();let s=e,i=t;const o=this.getChildrenSize();if(!this.canBeEmpty()){if(e===0&&t===0){const a=this.getFirstChild();if(X(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(X(a)||O(a))return a.select()}}s===void 0&&(s=o),i===void 0&&(i=o);const l=this.__key;return V(n)?(n.anchor.set(l,s,"element"),n.focus.set(l,i,"element"),n.dirty=!0,n):ic(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!==""?Da[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 l=o.__key,a=[],u=[],c=this.getChildAtIndex(e+t);let d=null,f=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(),v=g.__key;Dr(g.getWritable()),u.push(v),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&&f--,Dr(x);const v=m.__key;if(p===null)o.__first=v,x.__prev=null;else{const y=p.getWritable();y.__next=v,x.__prev=y.__key}m.__key===l&&K(76),x.__parent=l,a.push(v),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=f,u.length){const g=oe();if(V(g)){const m=new Set(u),x=new Set(a),{anchor:v,focus:y}=g;ul(v,m,x)&&Hs(v,v.getNode(),this,d,c),ul(y,m,x)&&Hs(y,y.getNode(),this,d,c),f!==0||this.canBeEmpty()||Yt(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 ul(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 ze(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(){K(51)}getTextContent(){const e=this.__cachedText;return!es()&&Qe()._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];O(n)||ze(n)||K(56)}return super.append(...e)}static importJSON(e){const t=Ge();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 pt(r){return r instanceof ts}function fc(r){return new gi(new Map(r._nodeMap))}function na(){return new gi(new Map([["root",new ts]]))}function hc(r){const e=r.exportJSON(),t=r.constructor;if(e.type!==t.getType()&&K(130,t.name),O(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=hc(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 ol(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 ol(null,this,()=>({root:hc(Ge())}))}}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:Ph,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=rt();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=rt();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||X(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 Ph(r){const e=rt();return r.style&&(e.setFormat(r.style.textAlign),Jo(r,e)),{node:e}}function rt(){return Xt(new on)}function tn(r){return r instanceof on}const je=0,Vr=1,Ih=4;function pc(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 Oh(r){const e=r||{},t=jh(),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:Iu()),a=e.editorState,u=[ts,sn,Qn,Xn,on,sa,...e.nodes||[]],{onError:c,html:d}=e,f=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],v=null,y=null;if(typeof x!="function"){const k=x;x=k.replace,v=k.with,y=k.withKlass||null}const _=x.getType(),S=x.transform(),E=new Set;S!==null&&E.add(S),p.set(_,{exportDOM:d&&d.export?d.export.get(x):void 0,klass:x,replace:v,replaceWithKlass:y,transforms:E})}}const g=new mi(o,s,p,{disableEvents:i,namespace:l,theme:n},c||console.error,function(m,x){const v=new Map,y=new Set,_=S=>{Object.keys(S).forEach(E=>{let k=v.get(E);k===void 0&&(k=[],v.set(E,k)),k.push(S[E])})};return m.forEach(S=>{const E=S.klass.importDOM;if(E==null||y.has(E))return;y.add(E);const k=E.call(S.klass);k!==null&&_(k)}),x&&_(x),v}(p,d?d.import:void 0),f);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=Iu(),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&&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(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&&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=xh(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(),kt(o,()=>{const a=ar();if(a.isEmpty())return;if(l==="root")return void Ge().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 re(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,pc(this,t,e,s),t!==null&&(this._config.disableEvents||Ch(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,Nu(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",ec),Us.set(u,(c||0)+1),l.__lexicalEditor=a;const d=Zu(l);for(let f=0;f<io.length;f++){const[p,g]=io[f],m=typeof g=="function"?x=>{Ha(x)||(Wa(x),(a.isEditable()||p==="click")&&g(x,a))}:x=>{if(Ha(x))return;Wa(x);const v=a.isEditable();switch(p){case"cut":return v&&re(a,Fo,x);case"copy":return re(a,ii,x);case"paste":return v&&re(a,si,x);case"dragstart":return v&&re(a,wu,x);case"dragover":return v&&re(a,Cu,x);case"dragend":return v&&re(a,jf,x);case"focus":return v&&re(a,If,x);case"blur":return v&&re(a,Of,x);case"drop":return v&&re(a,_u,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;Rn("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=fc(e),n._selection=e._selection?e._selection.clone():null),Tu(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=ot,a=Ct,u=at,c=s._dirtyElements,d=s._dirtyLeaves,f=s._cloneNotNeeded,p=s._dirtyType;s._dirtyElements=new Map,s._dirtyLeaves=new Set,s._cloneNotNeeded=new Set,s._dirtyType=0,ot=o,Ct=!1,at=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=f,s._dirtyType=p,ot=l,Ct=a,at=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){kt(this,e,t)}focus(e,t={}){const n=this._rootElement;n!==null&&(n.setAttribute("autocapitalize","off"),kt(this,()=>{const s=oe(),i=Ge();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=Nt(this._window);t!==null&&t.removeAllRanges()}isEditable(){return this._editable}setEditable(e){this._editable!==e&&(this._editable=e,Rn("editable",this,!0,e))}toJSON(){return{editorState:this._editorState.toJSON()}}}mi.version="0.21.0+prod.esm";const gc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,zh=gc?b.useLayoutEffect:b.useEffect,ds={tag:"history-merge"};function $h({initialConfig:r,children:e}){const t=b.useMemo(()=>{const{theme:n,namespace:s,nodes:i,onError:o,editorState:l,html:a}=r,u=kf(null,n),c=Oh({editable:r.editable,html:a,namespace:s,nodes:i,onError:d=>o(d,c),theme:n});return function(d,f){if(f!==null){if(f===void 0)d.update(()=>{const p=Ge();if(p.isEmpty()){const g=rt();p.append(g);const m=gc?document.activeElement:null;(oe()!==null||m!==null&&m===d.getRootElement())&&g.select()}},ds);else if(f!==null)switch(typeof f){case"string":{const p=d.parseEditorState(f);d.setEditorState(p,ds);break}case"object":d.setEditorState(f,ds);break;case"function":d.update(()=>{Ge().isEmpty()&&f(d)},ds)}}}(c,l),[c,u]},[]);return zh(()=>{const n=r.editable,[s]=t;s.setEditable(n===void 0||n)},[]),h.jsx(fu.Provider,{value:t,children:e})}const qh=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?b.useLayoutEffect:b.useEffect;function Uh(r){return{initialValueFn:()=>r.isEditable(),subscribe:e=>r.registerEditableListener(e)}}function Wh(){return function(r){const[e]=zt(),t=b.useMemo(()=>r(e),[e,r]),[n,s]=b.useState(()=>t.initialValueFn()),i=b.useRef(n);return qh(()=>{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}(Uh)}function Hh(){return Ge().getTextContent()}function Vh(r,e=!0){if(r)return!1;let t=Hh();return e&&(t=t.trim()),t===""}function Gh(r){if(!Vh(r,!1))return!1;const e=Ge().getChildren(),t=e.length;if(t>1)return!1;for(let n=0;n<t;n++){const s=e[n];if(ze(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(!X(a))return!1}}}return!0}function mc(r){return()=>Gh(r)}function Kh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}Kh(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 Yh(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Qh=Yh(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 Xh=new Map;function Jh(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 yc(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),f=o.is(l),p=e.is(i?l:o),g=e.is(i?o:l);let m,x=0;return f?(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 Zh(r){const e=r.getStyle(),t=Jh(e);Xh.set(e,t)}function ep(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=Ge(),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(),fl);i&&s.indexOf(i)===-1&&s.push(i);for(let o=0;o<s.length;o++){const l=s[o];if(!fl(l))continue;O(l)||Qh(178);const a=e();a.setFormat(l.getFormatType()),a.setIndent(l.getIndent()),l.replace(a,!0)}}function cl(r,e){const t=Pn(r.focus,e);return ze(t)&&!t.isIsolated()||O(t)&&!t.isInline()&&!t.canBeEmpty()}function tp(r,e,t,n){r.modify(e?"extend":"move",t,n)}function rp(r){const e=r.anchor.getNode();return(pt(e)?e:e.getParentOrThrow()).getDirection()==="rtl"}function dl(r,e,t){const n=rp(r);tp(r,e,t?!n:n,"character")}function fl(r){if(ze(r)||!O(r)||Yt(r))return!1;const e=r.getFirstChild(),t=e===null||Ar(e)||X(e)||e.isInline();return!r.isInline()&&r.canBeEmpty()!==!1&&t}function np(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var sp=np(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 xc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0,ip=xc&&"documentMode"in document?document.documentMode:null;!(!xc||!("InputEvent"in window)||ip)&&"getTargetRanges"in new window.InputEvent("input");function bc(...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=bc(...e);t.length>0&&r.classList.add(...t)}function vc(r,...e){const t=bc(...e);t.length>0&&r.classList.remove(...t)}function op(r,e){let t=r;for(;t!=null;){if(t instanceof e)return t;t=t.getParent()}return null}function ap(r){const e=yi(r,t=>O(t)&&!t.isInline());return O(e)||sp(4,r.__key),e}const yi=(r,e)=>{let t=r;for(;t!==Ge()&&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 lp(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,f,p,g]=a;r.update(()=>{const m=oe();if(V(m)){const x=m.anchor;let v=x.getNode(),y=0,_=0;if(X(v)&&u>=0&&c>=0&&(y=u,_=u+c,m.setTextNodeRange(v,y,v,_)),y===_&&d===""||(m.insertRawText(d),v=x.getNode()),X(v)){y=f,_=f+p;const S=v.getTextContentSize();y=y>S?S:y,_=_>S?S:_,m.setTextNodeRange(v,y,v,_)}n.stopImmediatePropagation()}})}}}}};return window.addEventListener("message",t,!0),()=>{window.removeEventListener("message",t,!0)}}function _c(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(!Sc.has(o.nodeName)){const l=kc(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 wc(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=Ge().getChildren();for(let s=0;s<n.length;s++)Cc(r,n[s],t,e);return t.innerHTML}function Cc(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=Xo(e);p=X(p)&&n!==null?yc(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 f=document.createDocumentFragment();for(let p=0;p<l.length;p++){const g=l[p],m=Cc(r,g,f,n);!s&&O(e)&&m&&e.extractWithChild(g,n,"html")&&(s=!0)}if(s&&!i){if((or(c)||Oa(c))&&c.append(f),t.append(c),d){const p=d.call(o,c);p&&(Oa(c)?c.replaceChildren(p):c.replaceWith(p))}}else t.append(f);return s}const Sc=new Set(["STYLE","SCRIPT"]);function kc(r,e,t,n,s=new Map,i){let o=[];if(Sc.has(r.nodeName))return o;let l=null;const a=function(g,m){const{nodeName:x}=g,v=m._htmlConversions.get(x.toLowerCase());let y=null;if(v!==void 0)for(const _ of v){const S=_(g);S!==null&&(y===null||(y.priority||0)<=(S.priority||0))&&(y=S)}return y!==null?y.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 f=[];const p=(l==null||!Yt(l))&&(l!=null&&co(l)||n);for(let g=0;g<d.length;g++)f.push(...kc(d[g],e,t,p,new Map(s),l));return c!=null&&(f=c(f)),Os(r)&&(f=up(r,f,p?()=>{const g=new sa;return t.push(g),g}:rt)),l==null?f.length>0?o=o.concat(f):Os(r)&&function(g){return g.nextSibling==null||g.previousSibling==null?!1:Xi(g.nextSibling)&&Xi(g.previousSibling)}(r)&&(o=o.concat(Mr())):O(l)&&l.append(...f),o}function up(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 cp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Vs=cp(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 dp(r,e=oe()){return e==null&&Vs(166),V(e)&&e.isCollapsed()||e.getNodes().length===0?"":wc(r,e)}function fp(r,e=oe()){return e==null&&Vs(166),V(e)&&e.isCollapsed()||e.getNodes().length===0?null:JSON.stringify(hp(r,e))}function hl(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 pl(t,pp(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 pl(t,_c(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 l=0;l<o.length;l++){const a=oe();if(V(a)){const u=o[l];u===`
94
94
  `||u===`\r
95
- `?a.insertParagraph():u===" "?a.insertNodes([Jn()]):a.insertText(u)}}}else e.insertRawText(i)}function pl(r,e,t){r.dispatchCommand(Ef,{nodes:e,selection:t})||t.insertNodes(e)}function Ec(r,e,t,n=[]){let s=e===null||t.isSelected(e);const i=I(t)&&t.excludeFromCopy("html");let o=t;if(e!==null){let u=Xo(t);u=Q(u)&&e!==null?yc(e,u):u,o=u}const l=I(o)?o.getChildren():[],a=function(u){const c=u.exportJSON(),d=u.constructor;if(c.type!==d.getType()&&Vs(58,d.name),I(u)){const f=c.children;Array.isArray(f)||Vs(59,d.name)}return c}(o);if(Q(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=Ec(r,e,c,a.children);!s&&I(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 hp(r,e){const t=[],n=Ge().getChildren();for(let s=0;s<n.length;s++)Ec(r,e,n[s],t);return{namespace:r._config.namespace,nodes:t}}function pp(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t],s=Lh(n);Q(s)&&Zh(s),e.push(s)}return e}let qr=null;async function gl(r,e,t){if(qr!==null)return!1;if(e!==null)return new Promise((a,u)=>{r.update(()=>{a(ml(r,e,t))})});const n=r.getRootElement(),s=r._window==null?window.document:r._window.document,i=Nt(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(ml(r,d,t))),!0),Ih);qr=window.setTimeout(()=>{c(),qr=null,a(!1)},50),s.execCommand("copy"),o.remove()})}function ml(r,e,t){if(t===void 0){const s=Nt(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=oe();if(l===null)return!1;t=mp(l)}e.preventDefault();const n=e.clipboardData;return n!==null&&(yp(n,t),!0)}const gp=[["text/html",dp],["application/x-lexical-editor",fp]];function mp(r=oe()){const e={"text/plain":r?r.getTextContent():""};if(r){const t=mh();for(const[n,s]of gp){const i=s(t,r);i!==null&&(e[n]=i)}}return e}function yp(r,e){for(const t in e){const n=e[t];n!==void 0&&r.setData(t,n)}}function yl(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,xp=an&&"documentMode"in document?document.documentMode:null,bp=!(!an||!("InputEvent"in window)||xp)&&"getTargetRanges"in new window.InputEvent("input"),vp=an&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),xl=an&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,_p=an&&/^(?=.*Chrome).*/i.test(navigator.userAgent),wp=an&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!_p,bl=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:Cp,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=rt(),s=this.getDirection();return n.setDirection(s),this.insertAfter(n,t),n}collapseAtStart(){const e=rt();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&&vl(t)?{conversion:()=>({node:null}),priority:3}:null},span:e=>vl(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?rt():wn(this.getTag()),o=this.getDirection();if(i.setDirection(o),this.insertAfter(i,t),n===0&&!this.isEmpty()&&e){const l=rt();l.select(),this.replace(l,!0)}return i}collapseAtStart(){const e=this.isEmpty()?rt():wn(this.getTag());return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}extractWithChild(){return!0}}function vl(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&&(Jo(r,t),t.setFormat(r.style.textAlign))),{node:t}}function Cp(r){const e=ia();return r.style!==null&&(e.setFormat(r.style.textAlign),Jo(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 _l(r){const e=oe();if(!H(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=>I(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 ze(e)}function Sp(r){return Pr(r.registerCommand(hu,e=>{const t=oe();return!!Wt(t)&&(t.clear(),!0)},0),r.registerCommand(Er,e=>{const t=oe();return!!H(t)&&(t.deleteCharacter(e),!0)},je),r.registerCommand(jn,e=>{const t=oe();return!!H(t)&&(t.deleteWord(e),!0)},je),r.registerCommand(Ln,e=>{const t=oe();return!!H(t)&&(t.deleteLine(e),!0)},je),r.registerCommand(Yr,e=>{const t=oe();if(typeof e=="string")t!==null&&t.insertText(e);else{if(t===null)return!1;const n=e.dataTransfer;if(n!=null)hl(n,t,r);else if(H(t)){const s=e.data;return s&&t.insertText(s),!0}}return!0},je),r.registerCommand(Ki,()=>{const e=oe();return!!H(e)&&(e.removeText(),!0)},je),r.registerCommand(It,e=>{const t=oe();return!!H(t)&&(t.formatText(e),!0)},je),r.registerCommand(Ff,e=>{const t=oe();if(!H(t)&&!Wt(t))return!1;const n=t.getNodes();for(const s of n){const i=yi(s,o=>I(o)&&!o.isInline());i!==null&&i.setFormat(e)}return!0},je),r.registerCommand(Kr,e=>{const t=oe();return!!H(t)&&(t.insertLineBreak(e),!0)},je),r.registerCommand(Fn,()=>{const e=oe();return!!H(e)&&(e.insertParagraph(),!0)},je),r.registerCommand(Rf,()=>(oc([Jn()]),!0),je),r.registerCommand(Mf,()=>_l(e=>{const t=e.getIndent();e.setIndent(t+1)}),je),r.registerCommand(Ea,()=>_l(e=>{const t=e.getIndent();t>0&&e.setIndent(t-1)}),je),r.registerCommand(mu,e=>{const t=oe();if(Wt(t)&&!hs(e.target)){const n=t.getNodes();if(n.length>0)return n[0].selectPrevious(),!0}else if(H(t)){const n=Pn(t.focus,!0);if(!e.shiftKey&&ze(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),e.preventDefault(),!0}return!1},je),r.registerCommand(yu,e=>{const t=oe();if(Wt(t)){const n=t.getNodes();if(n.length>0)return n[0].selectNext(0,0),!0}else if(H(t)){if(function(s){const i=s.focus;return i.key==="root"&&i.offset===Ge().getChildrenSize()}(t))return e.preventDefault(),!0;const n=Pn(t.focus,!1);if(!e.shiftKey&&ze(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),e.preventDefault(),!0}return!1},je),r.registerCommand(gu,e=>{const t=oe();if(Wt(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectPrevious(),!0}if(!H(t))return!1;if(cl(t,!0)){const n=e.shiftKey;return e.preventDefault(),dl(t,n,!0),!0}return!1},je),r.registerCommand(pu,e=>{const t=oe();if(Wt(t)&&!hs(e.target)){const s=t.getNodes();if(s.length>0)return e.preventDefault(),s[0].selectNext(0,0),!0}if(!H(t))return!1;const n=e.shiftKey;return!!cl(t,!1)&&(e.preventDefault(),dl(t,n,!1),!0)},je),r.registerCommand(xu,e=>{if(hs(e.target))return!1;const t=oe();if(!H(t))return!1;const{anchor:n}=t,s=n.getNode();return t.isCollapsed()&&n.offset===0&&!pt(s)&&ap(s).getIndent()>0?(e.preventDefault(),r.dispatchCommand(Ea,void 0)):(!xl||navigator.language!=="ko-KR")&&(e.preventDefault(),r.dispatchCommand(Er,!0))},je),r.registerCommand(vu,e=>{if(hs(e.target))return!1;const t=oe();return!!H(t)&&(e.preventDefault(),r.dispatchCommand(Er,!1))},je),r.registerCommand(Ns,e=>{const t=oe();if(!H(t))return!1;if(e!==null){if((xl||vp||wp)&&bp)return!1;if(e.preventDefault(),e.shiftKey)return r.dispatchCommand(Kr,!1)}return r.dispatchCommand(Fn,void 0)},je),r.registerCommand(bu,()=>{const e=oe();return!!H(e)&&(r.blur(),!0)},je),r.registerCommand(_u,e=>{const[,t]=fs(e);if(t.length>0){const s=yl(e.clientX,e.clientY);if(s!==null){const{offset:i,node:o}=s,l=en(o);if(l!==null){const a=Rh();if(Q(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=Bu(a);Kt(u)}r.dispatchCommand(bl,t)}return e.preventDefault(),!0}const n=oe();return!!H(n)},je),r.registerCommand(wu,e=>{const[t]=fs(e),n=oe();return!(t&&!H(n))},je),r.registerCommand(Cu,e=>{const[t]=fs(e),n=oe();if(t&&!H(n))return!1;const s=yl(e.clientX,e.clientY);if(s!==null){const i=en(s.node);ze(i)&&e.preventDefault()}return!0},je),r.registerCommand(Yi,()=>(fh(),!0),je),r.registerCommand(ii,e=>(gl(r,gr(e,ClipboardEvent)?e:null),!0),je),r.registerCommand(Fo,e=>(async function(t,n){await gl(n,gr(t,ClipboardEvent)?t:null),n.update(()=>{const s=oe();H(s)?s.removeText():Wt(s)&&s.getNodes().forEach(i=>i.remove())})}(e,r),!0),je),r.registerCommand(si,e=>{const[,t,n]=fs(e);return t.length>0&&!n?(r.dispatchCommand(bl,t),!0):Wo(e.target)?!1:oe()!==null&&(function(s,i){s.preventDefault(),i.update(()=>{const o=oe(),l=gr(s,InputEvent)||gr(s,KeyboardEvent)?null:s.clipboardData;l!=null&&o!==null&&hl(l,o,i)},{tag:"paste"})}(e,r),!0)},je))}const fo=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?b.useLayoutEffect:b.useEffect;function wl(r){return r.getEditorState().read(mc(r.isComposing()))}function kp({contentEditable:r,placeholder:e=null,ErrorBoundary:t}){const[n]=zt(),s=function(i,o){const[l,a]=b.useState(()=>i.getDecorators());return fo(()=>i.registerDecoratorListener(u=>{ma.flushSync(()=>{a(u)})}),[i]),b.useEffect(()=>{a(i.getDecorators())},[i]),b.useMemo(()=>{const u=[],c=Object.keys(l);for(let d=0;d<c.length;d++){const f=c[d],p=h.jsx(o,{onError:m=>i._onError(m),children:h.jsx(b.Suspense,{fallback:null,children:l[f]})}),g=i.getElementByKey(f);g!==null&&u.push(ma.createPortal(p,g,f))}return u},[o,l,i])}(n,t);return function(i){fo(()=>Pr(Sp(i),lp(i)),[i])}(n),h.jsxs(h.Fragment,{children:[r,h.jsx(Ep,{content:e}),s]})}function Ep({content:r}){const[e]=zt(),t=function(s){const[i,o]=b.useState(()=>wl(s));return fo(()=>{function l(){const a=wl(s);o(a)}return l(),Pr(s.registerUpdateListener(()=>{l()}),s.registerEditableListener(()=>{l()}))},[s]),i}(e),n=Wh();return t?typeof r=="function"?r(n):r:null}const Dc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?b.useLayoutEffect:b.useEffect;function Dp({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:f,autoCapitalize:p,className:g,id:m,role:x="textbox",spellCheck:_=!0,style:y,tabIndex:w,"data-testid":C,...D},E){const[v,k]=b.useState(r.isEditable()),M=b.useCallback(N=>{N&&N.ownerDocument&&N.ownerDocument.defaultView?r.setRootElement(N):r.setRootElement(null)},[r]),T=b.useMemo(()=>function(...N){return R=>{N.forEach(j=>{typeof j=="function"?j(R):j!=null&&(j.current=R)})}}(E,M),[M,E]);return Dc(()=>(k(r.isEditable()),r.registerEditableListener(N=>{k(N)})),[r]),h.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":f,autoCapitalize:p,className:g,contentEditable:v,"data-testid":C,id:m,ref:T,role:v?x:void 0,spellCheck:_,style:y,tabIndex:w,...D})}const Ap=b.forwardRef(Dp);function Cl(r){return r.getEditorState().read(mc(r.isComposing()))}const Tp=b.forwardRef(Np);function Np(r,e){const{placeholder:t,...n}=r,[s]=zt();return h.jsxs(h.Fragment,{children:[h.jsx(Ap,{editor:s,...n,ref:e}),t!=null&&h.jsx(Bp,{editor:s,content:t})]})}function Bp({content:r,editor:e}){const t=function(o){const[l,a]=b.useState(()=>Cl(o));return Dc(()=>{function u(){const c=Cl(o);a(c)}return u(),Pr(o.registerUpdateListener(()=>{u()}),o.registerEditableListener(()=>{u()}))},[o]),l}(e),[n,s]=b.useState(e.isEditable());if(b.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:h.jsx("div",{"aria-hidden":!0,children:i})}const ps=0,ho=1,po=2,jt=0,Rp=1,Sl=2,Mp=3,Fp=4;function jp(r,e,t,n,s){if(r===null||t.size===0&&n.size===0&&!s)return jt;const i=e._selection,o=r._selection;if(s)return Rp;if(!(H(i)&&H(o)&&o.isCollapsed()&&i.isCollapsed()))return jt;const l=function(_,y,w){const C=_._nodeMap,D=[];for(const E of y){const v=C.get(E);v!==void 0&&D.push(v)}for(const[E,v]of w){if(!v)continue;const k=C.get(E);k===void 0||pt(k)||D.push(k)}return D}(e,t,n);if(l.length===0)return jt;if(l.length>1){const _=e._nodeMap,y=_.get(i.anchor.key),w=_.get(o.anchor.key);return y&&w&&!r._nodeMap.has(y.__key)&&Q(y)&&y.__text.length===1&&i.anchor.offset===1?Sl:jt}const a=l[0],u=r._nodeMap.get(a.__key);if(!Q(u)||!Q(a)||u.__mode!==a.__mode)return jt;const c=u.__text,d=a.__text;if(c===d)return jt;const f=i.anchor,p=o.anchor;if(f.key!==p.key||f.type!=="text")return jt;const g=f.offset,m=p.offset,x=d.length-c.length;return x===1&&m===g-1?Sl:x===-1&&m===g+1?Mp:x===-1&&m===g?Fp:jt}function Lp(r,e){let t=Date.now(),n=jt;return(s,i,o,l,a,u)=>{const c=Date.now();if(u.has("historic"))return n=jt,t=c,po;const d=jp(s,i,l,a,r.isComposing()),f=(()=>{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!==jt&&d===n&&c<t+e&&p||l.size===1&&function(x,_,y){const w=_._nodeMap.get(x),C=y._nodeMap.get(x),D=_._selection,E=y._selection;return!(H(D)&&H(E)&&D.anchor.type==="element"&&D.focus.type==="element"&&E.anchor.type==="text"&&E.focus.type==="text"||!Q(w)||!Q(C)||w.__parent!==C.__parent)&&JSON.stringify(_.read(()=>w.exportJSON()))===JSON.stringify(y.read(()=>C.exportJSON()))}(Array.from(l)[0],s,i)?ps:ho:m!==null?ps:po})();return t=c,n=d,f}}function kl(r){r.undoStack=[],r.redoStack=[],r.current=null}function Pp(r,e,t){const n=Lp(r,t);return Pr(r.registerCommand(Ro,()=>(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),je),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),je),r.registerCommand(Lf,()=>(kl(e),!1),je),r.registerCommand(Pf,()=>(kl(e),r.dispatchCommand(as,!1),r.dispatchCommand(ls,!1),!0),je),r.registerUpdateListener(({editorState:i,prevEditorState:o,dirtyLeaves:l,dirtyElements:a,tags:u})=>{const c=e.current,d=e.redoStack,f=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&&(f.push({...c}),r.dispatchCommand(ls,!0));else if(g===po)return;e.current={editor:r,editorState:i}}))}function Ip(){return{current:null,redoStack:[],undoStack:[]}}function Op({delay:r,externalHistoryState:e}){const[t]=zt();return function(n,s,i=1e3){const o=b.useMemo(()=>s||Ip(),[s]);b.useEffect(()=>Pp(n,o,i),[i,n,o])}(t,e,r),null}const zp=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?b.useLayoutEffect:b.useEffect;function $p({ignoreHistoryMergeTagChange:r=!0,ignoreSelectionChange:e=!1,onChange:t}){const[n]=zt();return zp(()=>{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 El={error:null},qp=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=El,i.resetErrorBoundary=function(){for(var u,c=arguments.length,d=new Array(c),f=0;f<c;f++)d[f]=arguments[f];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(El)},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,f=this.props.resetKeys;d!==null&&o.error!==null&&((u=i.resetKeys)===void 0&&(u=[]),(c=f)===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,f),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 Up({children:r,onError:e}){return h.jsx(qp,{fallback:h.jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:e,children:r})}function Wp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ht=Wp(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 Hp(r){let e=1,t=r.getParent();for(;t!=null;){if(Ye(t)){const n=t.getParent();if(Me(n)){e++,t=n.getParent();continue}Ht(40)}return e}return e}function mo(r){let e=r.getParent();Me(e)||Ht(40);let t=e;for(;t!==null;)t=t.getParent(),Me(t)&&(e=t);return e}function Ac(r){let e=[];const t=r.getChildren().filter(Ye);for(let n=0;n<t.length;n++){const s=t[n],i=s.getFirstChild();Me(i)?e=e.concat(Ac(i)):e.push(s)}return e}function Vt(r){return Ye(r)&&Me(r.getFirstChild())}function Dl(r){return Et().append(r)}function Tc(r,e){return Ye(r)&&(e.length===0||e.length===1&&r.is(e[0])&&r.getChildrenSize()===0)}function Al(r,e){r.update(()=>{const t=oe();if(t!==null){const n=t.getNodes();if(H(t)){const i=t.getStartEndPoints();i===null&&Ht(143);const[o]=i,l=o.getNode(),a=l.getParent();if(Tc(l,n)){const u=St(e);if(Yt(a)){l.replace(u);const c=Et();I(l)&&(c.setFormat(l.getFormatType()),c.setIndent(l.getIndent())),u.append(c)}else if(Ye(l)){const c=l.getParentOrThrow();Fr(u,c.getChildren()),c.replace(u)}return}}const s=new Set;for(let i=0;i<n.length;i++){const o=n[i];if(!I(o)||!o.isEmpty()||Ye(o)||s.has(o.getKey())){if(Mu(o)){let l=o.getParent();for(;l!=null;){const a=l.getKey();if(Me(l)){if(!s.has(a)){const u=St(e);Fr(u,l.getChildren()),l.replace(u),s.add(a)}break}{const u=l.getParent();if(Yt(u)&&!s.has(a)){s.add(a),Tl(l,e);break}l=u}}}}else Tl(o,e)}}})}function Fr(r,e){r.splice(r.getChildrenSize(),0,e)}function Tl(r,e){if(Me(r))return r;const t=r.getPreviousSibling(),n=r.getNextSibling(),s=Et();let i;if(Fr(s,r.getChildren()),Me(t)&&e===t.getListType())t.append(s),Me(n)&&e===n.getListType()&&(Fr(t,n.getChildren()),n.remove()),i=t;else if(Me(n)&&e===n.getListType())n.getFirstChildOrThrow().insertBefore(s),i=n;else{const o=St(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&&Vt(t)&&Vt(n)&&(oa(t.getFirstChild(),n.getFirstChild()),n.remove());const s=e.getChildren();s.length>0&&r.append(...s),e.remove()}function Vp(r){r.update(()=>{const e=oe();if(H(e)){const t=new Set,n=e.getNodes(),s=e.anchor.getNode();if(Tc(s,n))t.add(mo(s));else for(let i=0;i<n.length;i++){const o=n[i];if(Mu(o)){const l=op(o,Ir);l!=null&&t.add(mo(l))}}for(const i of t){let o=i;const l=Ac(i);for(const a of l){const u=rt();Fr(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 Gp(r){const e=new Set;if(Vt(r)||e.has(r.getKey()))return;const t=r.getParent(),n=r.getNextSibling(),s=r.getPreviousSibling();if(Vt(n)&&Vt(s)){const i=s.getFirstChild();if(Me(i)){i.append(r);const o=n.getFirstChild();Me(o)&&(Fr(i,o.getChildren()),n.remove(),e.add(n.getKey()))}}else if(Vt(n)){const i=n.getFirstChild();if(Me(i)){const o=i.getFirstChild();o!==null&&o.insertBefore(r)}}else if(Vt(s)){const i=s.getFirstChild();Me(i)&&i.append(r)}else if(Me(t)){const i=Et(),o=St(t.getListType());i.append(o),o.append(r),s?s.insertAfter(i):n?n.insertBefore(i):t.append(i)}}function Kp(r){if(Vt(r))return;const e=r.getParent(),t=e?e.getParent():void 0;if(Me(t?t.getParent():void 0)&&Ye(t)&&Me(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=Et(),l=St(i);o.append(l),r.getPreviousSiblings().forEach(c=>l.append(c));const a=Et(),u=St(i);a.append(u),Fr(u,r.getNextSiblings()),t.insertBefore(o),t.insertAfter(a),t.replace(r)}}}function Yp(){const r=oe();if(!H(r)||!r.isCollapsed())return!1;const e=r.anchor.getNode();if(!Ye(e)||e.getChildrenSize()!==0)return!1;const t=mo(e),n=e.getParent();Me(n)||Ht(40);const s=n.getParent();let i;if(Yt(s))i=rt(),t.insertAfter(i);else{if(!Ye(s))return!1;i=Et(),s.insertAfter(i)}i.select();const o=e.getNextSiblings();if(o.length>0){const l=St(n.getListType());if(tn(i))i.insertAfter(l);else{const a=Et();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||!Ye(a)&&!Me(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 Me(n)&&n.getListType()==="check"&&Bl(t,this,null),t.value=this.__value,Nl(t,e.theme,this),t}updateDOM(e,t,n){const s=this.getParent();return Me(s)&&s.getListType()==="check"&&Bl(t,this,e),t.value=this.__value,Nl(t,n.theme,this),!1}static transform(){return e=>{if(Ye(e)||Ht(144),e.__checked==null)return;const t=e.getParent();Me(t)&&t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:Qp,priority:0})}}static importJSON(e){const t=Et();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(I(n)&&this.canMergeWith(n)){const s=n.getChildren();this.append(...s),n.remove()}else super.append(n)}return this}replace(e,t){if(Ye(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!Me(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{const s=St(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&&(I(e)||Ht(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(Me(n)||Ht(39),Ye(e))return super.insertAfter(e,t);const s=this.getNextSiblings();if(n.insertAfter(e,t),s.length!==0){const i=St(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&&Vt(t)&&Vt(n)&&(oa(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){const n=Et(this.__checked==null&&void 0);return this.insertAfter(n,t),n}collapseAtStart(e){const t=rt();this.getChildren().forEach(o=>t.append(o));const n=this.getParentOrThrow(),s=n.getParentOrThrow(),i=Ye(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 Me(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(;Ye(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){typeof e!="number"&&Ht(117),(e=Math.floor(e))>=0||Ht(199);let t=this.getIndent();for(;t!==e;)t<e?(Gp(this),t++):(Kp(this),t--);return this}canInsertAfter(e){return Ye(e)}canReplaceWith(e){return Ye(e)}canMergeWith(e){return tn(e)||Ye(e)}extractWithChild(e,t){if(!H(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 St("bullet")}canMergeWhenEmpty(){return!0}}function Nl(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=Me(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=>Me(u))?n.push(...a):s.push(...a)}s.length>0&&vc(r,...s),n.length>0&&rs(r,...n)}function Bl(r,e,t,n){Me(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 Qp(r){if(r.classList.contains("task-list-item")){for(const t of r.children)if(t.tagName==="INPUT")return Xp(t)}const e=r.getAttribute("aria-checked");return{node:Et(e==="true"||e!=="false"&&void 0)}}function Xp(r){return r.getAttribute("type")!=="checkbox"?{node:null}:{node:Et(r.hasAttribute("checked"))}}function Et(r){return Xt(new Ir(void 0,r))}function Ye(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,Rl(s,e.theme,this),s}updateDOM(e,t,n){return e.__tag!==this.__tag||(Rl(t,n.theme,this),!1)}static transform(){return e=>{Me(e)||Ht(163),function(t){const n=t.getNextSibling();Me(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())Ye(i)&&(i.getValue()!==s&&i.setValue(s),n&&i.getLatest().__checked!=null&&i.setChecked(void 0),Me(i.getFirstChild())||s++)}(e)}}static importDOM(){return{ol:()=>({conversion:Ml,priority:0}),ul:()=>({conversion:Ml,priority:0})}}static importJSON(e){const t=St(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(Ye(n))super.append(n);else{const s=Et();if(Me(n))s.append(n);else if(I(n))if(n.isInline())s.append(n);else{const i=st(n.getTextContent());s.append(i)}else s.append(n);super.append(s)}}return this}extractWithChild(e){return Ye(e)}}function Rl(r,e,t){const n=[],s=[],i=e.list;if(i!==void 0){const o=i[`${t.__tag}Depth`]||[],l=Hp(t)-1,a=l%o.length,u=o[a],c=i[t.__tag];let d;const f=i.nested,p=i.checklist;if(f!==void 0&&f.list&&(d=f.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&&vc(r,...s),n.length>0&&rs(r,...n)}function Jp(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t];if(Ye(n)){e.push(n);const s=n.getChildren();s.length>1&&s.forEach(i=>{Me(i)&&e.push(Dl(i))})}else e.push(Dl(n))}return e}function Ml(r){const e=r.nodeName.toLowerCase();let t=null;return e==="ol"?t=St("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)?St("check"):St("bullet")),{after:Jp,node:t}}const Fl={ol:"number",ul:"bullet"};function St(r,e=1){return Xt(new ln(r,e))}function Me(r){return r instanceof ln}const Nc=Hn(),Bc=Hn(),Zp=Hn();function eg(r){return Pr(r.registerCommand(Bc,()=>(Al(r,"number"),!0),Vr),r.registerCommand(Nc,()=>(Al(r,"bullet"),!0),Vr),r.registerCommand(Zp,()=>(Vp(r),!0),Vr),r.registerCommand(Fn,()=>!!Yp(),Vr))}function tg(){const[r]=zt();return b.useEffect(()=>{if(!r.hasNodes([ln,Ir]))throw new Error("ListPlugin: ListNode and/or ListItemNode not registered on editor")},[r]),function(e){b.useEffect(()=>eg(e),[e])}(r),null}const rg=new Set(["http:","https:","mailto:","sms:","tel:"]);class Or extends lr{static getType(){return"link"}static clone(e){return new Or(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:ng,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(!rg.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(!H(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 ng(r){let e=null;if(gh(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 Or(r,e))}function mn(r){return r instanceof Or}class ns extends Or{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=jl(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(I(n)){const s=jl(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return n.append(s),s}return null}}function jl(r,e){return Xt(new ns(r,e))}function sg(r){return r instanceof ns}const Ll=Hn();function $i(r,e={}){const{target:t,title:n}=e,s=e.rel===void 0?"noreferrer":e.rel,i=oe();if(!H(i))return;const o=i.extract();if(r===null)o.forEach(l=>{const a=yi(l,u=>!sg(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 f=c;for(;f!==null&&f.getParent()!==null&&!d(f);)f=f.getParentOrThrow();return d(f)?f: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&&(!I(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 f=0;f<d.length;f++)a.append(d[f])}u.remove()}else a!==null&&a.append(u)}})}}function ig({validateUrl:r,attributes:e}){const[t]=zt();return b.useEffect(()=>{if(!t.hasNodes([Or]))throw new Error("LinkPlugin: LinkNode not registered on editor");return Pr(t.registerCommand(Ll,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=oe();if(!H(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=>I(l))&&(t.dispatchCommand(Ll,{...e,url:o}),n.preventDefault(),!0)},Vr):()=>{})},[t,r,e]),null}function og(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 ag({src:r,alt:e,width:t,height:n}){return h.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);bt(this,"__src");bt(this,"__altText");bt(this,"__width");bt(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:og,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 h.jsx(ag,{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 lg=Object.defineProperty,Ys=Object.getOwnPropertySymbols,Mc=Object.prototype.hasOwnProperty,Fc=Object.prototype.propertyIsEnumerable,Pl=(r,e,t)=>e in r?lg(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,yo=(r,e)=>{for(var t in e||(e={}))Mc.call(e,t)&&Pl(r,t,e[t]);if(Ys)for(var t of Ys(e))Fc.call(e,t)&&Pl(r,t,e[t]);return r},xo=(r,e)=>{var t={};for(var n in r)Mc.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&&Fc.call(r,n)&&(t[n]=r[n]);return t};/**
95
+ `?a.insertParagraph():u===" "?a.insertNodes([Jn()]):a.insertText(u)}}}else e.insertRawText(i)}function pl(r,e,t){r.dispatchCommand(Ef,{nodes:e,selection:t})||t.insertNodes(e)}function Ec(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=Xo(t);u=X(u)&&e!==null?yc(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 f=c.children;Array.isArray(f)||Vs(59,d.name)}return c}(o);if(X(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=Ec(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 hp(r,e){const t=[],n=Ge().getChildren();for(let s=0;s<n.length;s++)Ec(r,e,n[s],t);return{namespace:r._config.namespace,nodes:t}}function pp(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t],s=Lh(n);X(s)&&Zh(s),e.push(s)}return e}let qr=null;async function gl(r,e,t){if(qr!==null)return!1;if(e!==null)return new Promise((a,u)=>{r.update(()=>{a(ml(r,e,t))})});const n=r.getRootElement(),s=r._window==null?window.document:r._window.document,i=Nt(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(ml(r,d,t))),!0),Ih);qr=window.setTimeout(()=>{c(),qr=null,a(!1)},50),s.execCommand("copy"),o.remove()})}function ml(r,e,t){if(t===void 0){const s=Nt(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=oe();if(l===null)return!1;t=mp(l)}e.preventDefault();const n=e.clipboardData;return n!==null&&(yp(n,t),!0)}const gp=[["text/html",dp],["application/x-lexical-editor",fp]];function mp(r=oe()){const e={"text/plain":r?r.getTextContent():""};if(r){const t=mh();for(const[n,s]of gp){const i=s(t,r);i!==null&&(e[n]=i)}}return e}function yp(r,e){for(const t in e){const n=e[t];n!==void 0&&r.setData(t,n)}}function yl(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,xp=an&&"documentMode"in document?document.documentMode:null,bp=!(!an||!("InputEvent"in window)||xp)&&"getTargetRanges"in new window.InputEvent("input"),vp=an&&/Version\/[\d.]+.*Safari/.test(navigator.userAgent),xl=an&&/iPad|iPhone|iPod/.test(navigator.userAgent)&&!window.MSStream,_p=an&&/^(?=.*Chrome).*/i.test(navigator.userAgent),wp=an&&/AppleWebKit\/[\d.]+/.test(navigator.userAgent)&&!_p,bl=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:Cp,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=rt(),s=this.getDirection();return n.setDirection(s),this.insertAfter(n,t),n}collapseAtStart(){const e=rt();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&&vl(t)?{conversion:()=>({node:null}),priority:3}:null},span:e=>vl(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?rt():wn(this.getTag()),o=this.getDirection();if(i.setDirection(o),this.insertAfter(i,t),n===0&&!this.isEmpty()&&e){const l=rt();l.select(),this.replace(l,!0)}return i}collapseAtStart(){const e=this.isEmpty()?rt():wn(this.getTag());return this.getChildren().forEach(t=>e.append(t)),this.replace(e),!0}extractWithChild(){return!0}}function vl(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&&(Jo(r,t),t.setFormat(r.style.textAlign))),{node:t}}function Cp(r){const e=ia();return r.style!==null&&(e.setFormat(r.style.textAlign),Jo(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 _l(r){const e=oe();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 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 ze(e)}function Sp(r){return Pr(r.registerCommand(hu,e=>{const t=oe();return!!Wt(t)&&(t.clear(),!0)},0),r.registerCommand(Er,e=>{const t=oe();return!!V(t)&&(t.deleteCharacter(e),!0)},je),r.registerCommand(jn,e=>{const t=oe();return!!V(t)&&(t.deleteWord(e),!0)},je),r.registerCommand(Ln,e=>{const t=oe();return!!V(t)&&(t.deleteLine(e),!0)},je),r.registerCommand(Yr,e=>{const t=oe();if(typeof e=="string")t!==null&&t.insertText(e);else{if(t===null)return!1;const n=e.dataTransfer;if(n!=null)hl(n,t,r);else if(V(t)){const s=e.data;return s&&t.insertText(s),!0}}return!0},je),r.registerCommand(Ki,()=>{const e=oe();return!!V(e)&&(e.removeText(),!0)},je),r.registerCommand(It,e=>{const t=oe();return!!V(t)&&(t.formatText(e),!0)},je),r.registerCommand(Ff,e=>{const t=oe();if(!V(t)&&!Wt(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},je),r.registerCommand(Kr,e=>{const t=oe();return!!V(t)&&(t.insertLineBreak(e),!0)},je),r.registerCommand(Fn,()=>{const e=oe();return!!V(e)&&(e.insertParagraph(),!0)},je),r.registerCommand(Rf,()=>(oc([Jn()]),!0),je),r.registerCommand(Mf,()=>_l(e=>{const t=e.getIndent();e.setIndent(t+1)}),je),r.registerCommand(Ea,()=>_l(e=>{const t=e.getIndent();t>0&&e.setIndent(t-1)}),je),r.registerCommand(mu,e=>{const t=oe();if(Wt(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&&ze(n)&&!n.isIsolated()&&!n.isInline())return n.selectPrevious(),e.preventDefault(),!0}return!1},je),r.registerCommand(yu,e=>{const t=oe();if(Wt(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===Ge().getChildrenSize()}(t))return e.preventDefault(),!0;const n=Pn(t.focus,!1);if(!e.shiftKey&&ze(n)&&!n.isIsolated()&&!n.isInline())return n.selectNext(),e.preventDefault(),!0}return!1},je),r.registerCommand(gu,e=>{const t=oe();if(Wt(t)){const n=t.getNodes();if(n.length>0)return e.preventDefault(),n[0].selectPrevious(),!0}if(!V(t))return!1;if(cl(t,!0)){const n=e.shiftKey;return e.preventDefault(),dl(t,n,!0),!0}return!1},je),r.registerCommand(pu,e=>{const t=oe();if(Wt(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!!cl(t,!1)&&(e.preventDefault(),dl(t,n,!1),!0)},je),r.registerCommand(xu,e=>{if(hs(e.target))return!1;const t=oe();if(!V(t))return!1;const{anchor:n}=t,s=n.getNode();return t.isCollapsed()&&n.offset===0&&!pt(s)&&ap(s).getIndent()>0?(e.preventDefault(),r.dispatchCommand(Ea,void 0)):(!xl||navigator.language!=="ko-KR")&&(e.preventDefault(),r.dispatchCommand(Er,!0))},je),r.registerCommand(vu,e=>{if(hs(e.target))return!1;const t=oe();return!!V(t)&&(e.preventDefault(),r.dispatchCommand(Er,!1))},je),r.registerCommand(Ns,e=>{const t=oe();if(!V(t))return!1;if(e!==null){if((xl||vp||wp)&&bp)return!1;if(e.preventDefault(),e.shiftKey)return r.dispatchCommand(Kr,!1)}return r.dispatchCommand(Fn,void 0)},je),r.registerCommand(bu,()=>{const e=oe();return!!V(e)&&(r.blur(),!0)},je),r.registerCommand(_u,e=>{const[,t]=fs(e);if(t.length>0){const s=yl(e.clientX,e.clientY);if(s!==null){const{offset:i,node:o}=s,l=en(o);if(l!==null){const a=Rh();if(X(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=Bu(a);Kt(u)}r.dispatchCommand(bl,t)}return e.preventDefault(),!0}const n=oe();return!!V(n)},je),r.registerCommand(wu,e=>{const[t]=fs(e),n=oe();return!(t&&!V(n))},je),r.registerCommand(Cu,e=>{const[t]=fs(e),n=oe();if(t&&!V(n))return!1;const s=yl(e.clientX,e.clientY);if(s!==null){const i=en(s.node);ze(i)&&e.preventDefault()}return!0},je),r.registerCommand(Yi,()=>(fh(),!0),je),r.registerCommand(ii,e=>(gl(r,gr(e,ClipboardEvent)?e:null),!0),je),r.registerCommand(Fo,e=>(async function(t,n){await gl(n,gr(t,ClipboardEvent)?t:null),n.update(()=>{const s=oe();V(s)?s.removeText():Wt(s)&&s.getNodes().forEach(i=>i.remove())})}(e,r),!0),je),r.registerCommand(si,e=>{const[,t,n]=fs(e);return t.length>0&&!n?(r.dispatchCommand(bl,t),!0):Wo(e.target)?!1:oe()!==null&&(function(s,i){s.preventDefault(),i.update(()=>{const o=oe(),l=gr(s,InputEvent)||gr(s,KeyboardEvent)?null:s.clipboardData;l!=null&&o!==null&&hl(l,o,i)},{tag:"paste"})}(e,r),!0)},je))}const fo=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?b.useLayoutEffect:b.useEffect;function wl(r){return r.getEditorState().read(mc(r.isComposing()))}function kp({contentEditable:r,placeholder:e=null,ErrorBoundary:t}){const[n]=zt(),s=function(i,o){const[l,a]=b.useState(()=>i.getDecorators());return fo(()=>i.registerDecoratorListener(u=>{ma.flushSync(()=>{a(u)})}),[i]),b.useEffect(()=>{a(i.getDecorators())},[i]),b.useMemo(()=>{const u=[],c=Object.keys(l);for(let d=0;d<c.length;d++){const f=c[d],p=h.jsx(o,{onError:m=>i._onError(m),children:h.jsx(b.Suspense,{fallback:null,children:l[f]})}),g=i.getElementByKey(f);g!==null&&u.push(ma.createPortal(p,g,f))}return u},[o,l,i])}(n,t);return function(i){fo(()=>Pr(Sp(i),lp(i)),[i])}(n),h.jsxs(h.Fragment,{children:[r,h.jsx(Ep,{content:e}),s]})}function Ep({content:r}){const[e]=zt(),t=function(s){const[i,o]=b.useState(()=>wl(s));return fo(()=>{function l(){const a=wl(s);o(a)}return l(),Pr(s.registerUpdateListener(()=>{l()}),s.registerEditableListener(()=>{l()}))},[s]),i}(e),n=Wh();return t?typeof r=="function"?r(n):r:null}const Dc=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?b.useLayoutEffect:b.useEffect;function Dp({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:f,autoCapitalize:p,className:g,id:m,role:x="textbox",spellCheck:v=!0,style:y,tabIndex:_,"data-testid":S,...E},k){const[w,D]=b.useState(r.isEditable()),j=b.useCallback(T=>{T&&T.ownerDocument&&T.ownerDocument.defaultView?r.setRootElement(T):r.setRootElement(null)},[r]),B=b.useMemo(()=>function(...T){return R=>{T.forEach(M=>{typeof M=="function"?M(R):M!=null&&(M.current=R)})}}(k,j),[j,k]);return Dc(()=>(D(r.isEditable()),r.registerEditableListener(T=>{D(T)})),[r]),h.jsx("div",{"aria-activedescendant":w?e:void 0,"aria-autocomplete":w?t:"none","aria-controls":w?n:void 0,"aria-describedby":s,...i!=null?{"aria-errormessage":i}:{},"aria-expanded":w&&x==="combobox"?!!o:void 0,...l!=null?{"aria-invalid":l}:{},"aria-label":a,"aria-labelledby":u,"aria-multiline":c,"aria-owns":w?d:void 0,"aria-readonly":!w||void 0,"aria-required":f,autoCapitalize:p,className:g,contentEditable:w,"data-testid":S,id:m,ref:B,role:w?x:void 0,spellCheck:v,style:y,tabIndex:_,...E})}const Ap=b.forwardRef(Dp);function Cl(r){return r.getEditorState().read(mc(r.isComposing()))}const Tp=b.forwardRef(Np);function Np(r,e){const{placeholder:t,...n}=r,[s]=zt();return h.jsxs(h.Fragment,{children:[h.jsx(Ap,{editor:s,...n,ref:e}),t!=null&&h.jsx(Bp,{editor:s,content:t})]})}function Bp({content:r,editor:e}){const t=function(o){const[l,a]=b.useState(()=>Cl(o));return Dc(()=>{function u(){const c=Cl(o);a(c)}return u(),Pr(o.registerUpdateListener(()=>{u()}),o.registerEditableListener(()=>{u()}))},[o]),l}(e),[n,s]=b.useState(e.isEditable());if(b.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:h.jsx("div",{"aria-hidden":!0,children:i})}const ps=0,ho=1,po=2,jt=0,Rp=1,Sl=2,Mp=3,Fp=4;function jp(r,e,t,n,s){if(r===null||t.size===0&&n.size===0&&!s)return jt;const i=e._selection,o=r._selection;if(s)return Rp;if(!(V(i)&&V(o)&&o.isCollapsed()&&i.isCollapsed()))return jt;const l=function(v,y,_){const S=v._nodeMap,E=[];for(const k of y){const w=S.get(k);w!==void 0&&E.push(w)}for(const[k,w]of _){if(!w)continue;const D=S.get(k);D===void 0||pt(D)||E.push(D)}return E}(e,t,n);if(l.length===0)return jt;if(l.length>1){const v=e._nodeMap,y=v.get(i.anchor.key),_=v.get(o.anchor.key);return y&&_&&!r._nodeMap.has(y.__key)&&X(y)&&y.__text.length===1&&i.anchor.offset===1?Sl:jt}const a=l[0],u=r._nodeMap.get(a.__key);if(!X(u)||!X(a)||u.__mode!==a.__mode)return jt;const c=u.__text,d=a.__text;if(c===d)return jt;const f=i.anchor,p=o.anchor;if(f.key!==p.key||f.type!=="text")return jt;const g=f.offset,m=p.offset,x=d.length-c.length;return x===1&&m===g-1?Sl:x===-1&&m===g+1?Mp:x===-1&&m===g?Fp:jt}function Lp(r,e){let t=Date.now(),n=jt;return(s,i,o,l,a,u)=>{const c=Date.now();if(u.has("historic"))return n=jt,t=c,po;const d=jp(s,i,l,a,r.isComposing()),f=(()=>{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!==jt&&d===n&&c<t+e&&p||l.size===1&&function(x,v,y){const _=v._nodeMap.get(x),S=y._nodeMap.get(x),E=v._selection,k=y._selection;return!(V(E)&&V(k)&&E.anchor.type==="element"&&E.focus.type==="element"&&k.anchor.type==="text"&&k.focus.type==="text"||!X(_)||!X(S)||_.__parent!==S.__parent)&&JSON.stringify(v.read(()=>_.exportJSON()))===JSON.stringify(y.read(()=>S.exportJSON()))}(Array.from(l)[0],s,i)?ps:ho:m!==null?ps:po})();return t=c,n=d,f}}function kl(r){r.undoStack=[],r.redoStack=[],r.current=null}function Pp(r,e,t){const n=Lp(r,t);return Pr(r.registerCommand(Ro,()=>(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),je),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),je),r.registerCommand(Lf,()=>(kl(e),!1),je),r.registerCommand(Pf,()=>(kl(e),r.dispatchCommand(as,!1),r.dispatchCommand(ls,!1),!0),je),r.registerUpdateListener(({editorState:i,prevEditorState:o,dirtyLeaves:l,dirtyElements:a,tags:u})=>{const c=e.current,d=e.redoStack,f=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&&(f.push({...c}),r.dispatchCommand(ls,!0));else if(g===po)return;e.current={editor:r,editorState:i}}))}function Ip(){return{current:null,redoStack:[],undoStack:[]}}function Op({delay:r,externalHistoryState:e}){const[t]=zt();return function(n,s,i=1e3){const o=b.useMemo(()=>s||Ip(),[s]);b.useEffect(()=>Pp(n,o,i),[i,n,o])}(t,e,r),null}const zp=typeof window<"u"&&window.document!==void 0&&window.document.createElement!==void 0?b.useLayoutEffect:b.useEffect;function $p({ignoreHistoryMergeTagChange:r=!0,ignoreSelectionChange:e=!1,onChange:t}){const[n]=zt();return zp(()=>{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 El={error:null},qp=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=El,i.resetErrorBoundary=function(){for(var u,c=arguments.length,d=new Array(c),f=0;f<c;f++)d[f]=arguments[f];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(El)},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,f=this.props.resetKeys;d!==null&&o.error!==null&&((u=i.resetKeys)===void 0&&(u=[]),(c=f)===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,f),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 Up({children:r,onError:e}){return h.jsx(qp,{fallback:h.jsx("div",{style:{border:"1px solid #f00",color:"#f00",padding:"8px"},children:"An error was thrown."}),onError:e,children:r})}function Wp(r){return r&&r.__esModule&&Object.prototype.hasOwnProperty.call(r,"default")?r.default:r}var Ht=Wp(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 Hp(r){let e=1,t=r.getParent();for(;t!=null;){if(Ye(t)){const n=t.getParent();if(Me(n)){e++,t=n.getParent();continue}Ht(40)}return e}return e}function mo(r){let e=r.getParent();Me(e)||Ht(40);let t=e;for(;t!==null;)t=t.getParent(),Me(t)&&(e=t);return e}function Ac(r){let e=[];const t=r.getChildren().filter(Ye);for(let n=0;n<t.length;n++){const s=t[n],i=s.getFirstChild();Me(i)?e=e.concat(Ac(i)):e.push(s)}return e}function Vt(r){return Ye(r)&&Me(r.getFirstChild())}function Dl(r){return Et().append(r)}function Tc(r,e){return Ye(r)&&(e.length===0||e.length===1&&r.is(e[0])&&r.getChildrenSize()===0)}function Al(r,e){r.update(()=>{const t=oe();if(t!==null){const n=t.getNodes();if(V(t)){const i=t.getStartEndPoints();i===null&&Ht(143);const[o]=i,l=o.getNode(),a=l.getParent();if(Tc(l,n)){const u=St(e);if(Yt(a)){l.replace(u);const c=Et();O(l)&&(c.setFormat(l.getFormatType()),c.setIndent(l.getIndent())),u.append(c)}else if(Ye(l)){const c=l.getParentOrThrow();Fr(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()||Ye(o)||s.has(o.getKey())){if(Mu(o)){let l=o.getParent();for(;l!=null;){const a=l.getKey();if(Me(l)){if(!s.has(a)){const u=St(e);Fr(u,l.getChildren()),l.replace(u),s.add(a)}break}{const u=l.getParent();if(Yt(u)&&!s.has(a)){s.add(a),Tl(l,e);break}l=u}}}}else Tl(o,e)}}})}function Fr(r,e){r.splice(r.getChildrenSize(),0,e)}function Tl(r,e){if(Me(r))return r;const t=r.getPreviousSibling(),n=r.getNextSibling(),s=Et();let i;if(Fr(s,r.getChildren()),Me(t)&&e===t.getListType())t.append(s),Me(n)&&e===n.getListType()&&(Fr(t,n.getChildren()),n.remove()),i=t;else if(Me(n)&&e===n.getListType())n.getFirstChildOrThrow().insertBefore(s),i=n;else{const o=St(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&&Vt(t)&&Vt(n)&&(oa(t.getFirstChild(),n.getFirstChild()),n.remove());const s=e.getChildren();s.length>0&&r.append(...s),e.remove()}function Vp(r){r.update(()=>{const e=oe();if(V(e)){const t=new Set,n=e.getNodes(),s=e.anchor.getNode();if(Tc(s,n))t.add(mo(s));else for(let i=0;i<n.length;i++){const o=n[i];if(Mu(o)){const l=op(o,Ir);l!=null&&t.add(mo(l))}}for(const i of t){let o=i;const l=Ac(i);for(const a of l){const u=rt();Fr(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 Gp(r){const e=new Set;if(Vt(r)||e.has(r.getKey()))return;const t=r.getParent(),n=r.getNextSibling(),s=r.getPreviousSibling();if(Vt(n)&&Vt(s)){const i=s.getFirstChild();if(Me(i)){i.append(r);const o=n.getFirstChild();Me(o)&&(Fr(i,o.getChildren()),n.remove(),e.add(n.getKey()))}}else if(Vt(n)){const i=n.getFirstChild();if(Me(i)){const o=i.getFirstChild();o!==null&&o.insertBefore(r)}}else if(Vt(s)){const i=s.getFirstChild();Me(i)&&i.append(r)}else if(Me(t)){const i=Et(),o=St(t.getListType());i.append(o),o.append(r),s?s.insertAfter(i):n?n.insertBefore(i):t.append(i)}}function Kp(r){if(Vt(r))return;const e=r.getParent(),t=e?e.getParent():void 0;if(Me(t?t.getParent():void 0)&&Ye(t)&&Me(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=Et(),l=St(i);o.append(l),r.getPreviousSiblings().forEach(c=>l.append(c));const a=Et(),u=St(i);a.append(u),Fr(u,r.getNextSiblings()),t.insertBefore(o),t.insertAfter(a),t.replace(r)}}}function Yp(){const r=oe();if(!V(r)||!r.isCollapsed())return!1;const e=r.anchor.getNode();if(!Ye(e)||e.getChildrenSize()!==0)return!1;const t=mo(e),n=e.getParent();Me(n)||Ht(40);const s=n.getParent();let i;if(Yt(s))i=rt(),t.insertAfter(i);else{if(!Ye(s))return!1;i=Et(),s.insertAfter(i)}i.select();const o=e.getNextSiblings();if(o.length>0){const l=St(n.getListType());if(tn(i))i.insertAfter(l);else{const a=Et();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||!Ye(a)&&!Me(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 Me(n)&&n.getListType()==="check"&&Bl(t,this,null),t.value=this.__value,Nl(t,e.theme,this),t}updateDOM(e,t,n){const s=this.getParent();return Me(s)&&s.getListType()==="check"&&Bl(t,this,e),t.value=this.__value,Nl(t,n.theme,this),!1}static transform(){return e=>{if(Ye(e)||Ht(144),e.__checked==null)return;const t=e.getParent();Me(t)&&t.getListType()!=="check"&&e.getChecked()!=null&&e.setChecked(void 0)}}static importDOM(){return{li:()=>({conversion:Qp,priority:0})}}static importJSON(e){const t=Et();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(Ye(e))return super.replace(e);this.setIndent(0);const n=this.getParentOrThrow();if(!Me(n))return e;if(n.__first===this.getKey())n.insertBefore(e);else if(n.__last===this.getKey())n.insertAfter(e);else{const s=St(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)||Ht(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(Me(n)||Ht(39),Ye(e))return super.insertAfter(e,t);const s=this.getNextSiblings();if(n.insertAfter(e,t),s.length!==0){const i=St(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&&Vt(t)&&Vt(n)&&(oa(t.getFirstChild(),n.getFirstChild()),n.remove())}insertNewAfter(e,t=!0){const n=Et(this.__checked==null&&void 0);return this.insertAfter(n,t),n}collapseAtStart(e){const t=rt();this.getChildren().forEach(o=>t.append(o));const n=this.getParentOrThrow(),s=n.getParentOrThrow(),i=Ye(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 Me(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(;Ye(t);)t=t.getParentOrThrow().getParentOrThrow(),n++;return n}setIndent(e){typeof e!="number"&&Ht(117),(e=Math.floor(e))>=0||Ht(199);let t=this.getIndent();for(;t!==e;)t<e?(Gp(this),t++):(Kp(this),t--);return this}canInsertAfter(e){return Ye(e)}canReplaceWith(e){return Ye(e)}canMergeWith(e){return tn(e)||Ye(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 St("bullet")}canMergeWhenEmpty(){return!0}}function Nl(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=Me(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=>Me(u))?n.push(...a):s.push(...a)}s.length>0&&vc(r,...s),n.length>0&&rs(r,...n)}function Bl(r,e,t,n){Me(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 Qp(r){if(r.classList.contains("task-list-item")){for(const t of r.children)if(t.tagName==="INPUT")return Xp(t)}const e=r.getAttribute("aria-checked");return{node:Et(e==="true"||e!=="false"&&void 0)}}function Xp(r){return r.getAttribute("type")!=="checkbox"?{node:null}:{node:Et(r.hasAttribute("checked"))}}function Et(r){return Xt(new Ir(void 0,r))}function Ye(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,Rl(s,e.theme,this),s}updateDOM(e,t,n){return e.__tag!==this.__tag||(Rl(t,n.theme,this),!1)}static transform(){return e=>{Me(e)||Ht(163),function(t){const n=t.getNextSibling();Me(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())Ye(i)&&(i.getValue()!==s&&i.setValue(s),n&&i.getLatest().__checked!=null&&i.setChecked(void 0),Me(i.getFirstChild())||s++)}(e)}}static importDOM(){return{ol:()=>({conversion:Ml,priority:0}),ul:()=>({conversion:Ml,priority:0})}}static importJSON(e){const t=St(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(Ye(n))super.append(n);else{const s=Et();if(Me(n))s.append(n);else if(O(n))if(n.isInline())s.append(n);else{const i=st(n.getTextContent());s.append(i)}else s.append(n);super.append(s)}}return this}extractWithChild(e){return Ye(e)}}function Rl(r,e,t){const n=[],s=[],i=e.list;if(i!==void 0){const o=i[`${t.__tag}Depth`]||[],l=Hp(t)-1,a=l%o.length,u=o[a],c=i[t.__tag];let d;const f=i.nested,p=i.checklist;if(f!==void 0&&f.list&&(d=f.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&&vc(r,...s),n.length>0&&rs(r,...n)}function Jp(r){const e=[];for(let t=0;t<r.length;t++){const n=r[t];if(Ye(n)){e.push(n);const s=n.getChildren();s.length>1&&s.forEach(i=>{Me(i)&&e.push(Dl(i))})}else e.push(Dl(n))}return e}function Ml(r){const e=r.nodeName.toLowerCase();let t=null;return e==="ol"?t=St("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)?St("check"):St("bullet")),{after:Jp,node:t}}const Fl={ol:"number",ul:"bullet"};function St(r,e=1){return Xt(new ln(r,e))}function Me(r){return r instanceof ln}const Nc=Hn(),Bc=Hn(),Zp=Hn();function eg(r){return Pr(r.registerCommand(Bc,()=>(Al(r,"number"),!0),Vr),r.registerCommand(Nc,()=>(Al(r,"bullet"),!0),Vr),r.registerCommand(Zp,()=>(Vp(r),!0),Vr),r.registerCommand(Fn,()=>!!Yp(),Vr))}function tg(){const[r]=zt();return b.useEffect(()=>{if(!r.hasNodes([ln,Ir]))throw new Error("ListPlugin: ListNode and/or ListItemNode not registered on editor")},[r]),function(e){b.useEffect(()=>eg(e),[e])}(r),null}const rg=new Set(["http:","https:","mailto:","sms:","tel:"]);class Or extends lr{static getType(){return"link"}static clone(e){return new Or(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:ng,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(!rg.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 ng(r){let e=null;if(gh(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 Or(r,e))}function mn(r){return r instanceof Or}class ns extends Or{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=jl(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=jl(this.__url,{isUnlinked:this.__isUnlinked,rel:this.__rel,target:this.__target,title:this.__title});return n.append(s),s}return null}}function jl(r,e){return Xt(new ns(r,e))}function sg(r){return r instanceof ns}const Ll=Hn();function $i(r,e={}){const{target:t,title:n}=e,s=e.rel===void 0?"noreferrer":e.rel,i=oe();if(!V(i))return;const o=i.extract();if(r===null)o.forEach(l=>{const a=yi(l,u=>!sg(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 f=c;for(;f!==null&&f.getParent()!==null&&!d(f);)f=f.getParentOrThrow();return d(f)?f: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 f=0;f<d.length;f++)a.append(d[f])}u.remove()}else a!==null&&a.append(u)}})}}function ig({validateUrl:r,attributes:e}){const[t]=zt();return b.useEffect(()=>{if(!t.hasNodes([Or]))throw new Error("LinkPlugin: LinkNode not registered on editor");return Pr(t.registerCommand(Ll,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=oe();if(!V(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(Ll,{...e,url:o}),n.preventDefault(),!0)},Vr):()=>{})},[t,r,e]),null}function og(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 ag({src:r,alt:e,width:t,height:n}){return h.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);bt(this,"__src");bt(this,"__altText");bt(this,"__width");bt(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:og,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 h.jsx(ag,{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 lg=Object.defineProperty,Ys=Object.getOwnPropertySymbols,Mc=Object.prototype.hasOwnProperty,Fc=Object.prototype.propertyIsEnumerable,Pl=(r,e,t)=>e in r?lg(r,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):r[e]=t,yo=(r,e)=>{for(var t in e||(e={}))Mc.call(e,t)&&Pl(r,t,e[t]);if(Ys)for(var t of Ys(e))Fc.call(e,t)&&Pl(r,t,e[t]);return r},xo=(r,e)=>{var t={};for(var n in r)Mc.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&&Fc.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 jr;(r=>{const e=class Ae{constructor(a,u,c,d){if(this.version=a,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],a<Ae.MIN_VERSION||a>Ae.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 f=[];for(let g=0;g<this.size;g++)f.push(!1);for(let g=0;g<this.size;g++)this.modules.push(f.slice()),this.isFunction.push(f.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 Ae.encodeSegments(c,u)}static encodeBinary(a,u){const c=r.QrSegment.makeBytes(a);return Ae.encodeSegments([c],u)}static encodeSegments(a,u,c=1,d=40,f=-1,p=!0){if(!(Ae.MIN_VERSION<=c&&c<=d&&d<=Ae.MAX_VERSION)||f<-1||f>7)throw new RangeError("Invalid value");let g,m;for(g=c;;g++){const w=Ae.getNumDataCodewords(g,u)*8,C=o.getTotalBits(a,g);if(C<=w){m=C;break}if(g>=d)throw new RangeError("Data too long")}for(const w of[Ae.Ecc.MEDIUM,Ae.Ecc.QUARTILE,Ae.Ecc.HIGH])p&&m<=Ae.getNumDataCodewords(g,w)*8&&(u=w);let x=[];for(const w of a){t(w.mode.modeBits,4,x),t(w.numChars,w.mode.numCharCountBits(g),x);for(const C of w.getData())x.push(C)}s(x.length==m);const _=Ae.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 w=236;x.length<_;w^=253)t(w,8,x);let y=[];for(;y.length*8<x.length;)y.push(0);return x.forEach((w,C)=>y[C>>>3]|=w<<7-(C&7)),new Ae(g,u,y,f)}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 f=0;f<10;f++)c=c<<1^(c>>>9)*1335;const d=(u<<10|c)^21522;s(d>>>15==0);for(let f=0;f<=5;f++)this.setFunctionModule(8,f,n(d,f));this.setFunctionModule(8,7,n(d,6)),this.setFunctionModule(8,8,n(d,7)),this.setFunctionModule(7,8,n(d,8));for(let f=9;f<15;f++)this.setFunctionModule(14-f,8,n(d,f));for(let f=0;f<8;f++)this.setFunctionModule(this.size-1-f,8,n(d,f));for(let f=8;f<15;f++)this.setFunctionModule(8,this.size-15+f,n(d,f));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),f=this.size-11+c%3,p=Math.floor(c/3);this.setFunctionModule(f,p,d),this.setFunctionModule(p,f,d)}}drawFinderPattern(a,u){for(let c=-4;c<=4;c++)for(let d=-4;d<=4;d++){const f=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,f!=2&&f!=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!=Ae.getNumDataCodewords(u,c))throw new RangeError("Invalid argument");const d=Ae.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][u],f=Ae.ECC_CODEWORDS_PER_BLOCK[c.ordinal][u],p=Math.floor(Ae.getNumRawDataModules(u)/8),g=d-p%d,m=Math.floor(p/d);let x=[];const _=Ae.reedSolomonComputeDivisor(f);for(let w=0,C=0;w<d;w++){let D=a.slice(C,C+m-f+(w<g?0:1));C+=D.length;const E=Ae.reedSolomonComputeRemainder(D,_);w<g&&D.push(0),x.push(D.concat(E))}let y=[];for(let w=0;w<x[0].length;w++)x.forEach((C,D)=>{(w!=m-f||D>=g)&&y.push(C[w])});return s(y.length==p),y}drawCodewords(a){if(a.length!=Math.floor(Ae.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 f=0;f<2;f++){const p=c-f,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 f=0;f<this.size;f++){let p=!1,g=0,m=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[f][x]==p?(g++,g==5?a+=Ae.PENALTY_N1:g>5&&a++):(this.finderPenaltyAddHistory(g,m),p||(a+=this.finderPenaltyCountPatterns(m)*Ae.PENALTY_N3),p=this.modules[f][x],g=1);a+=this.finderPenaltyTerminateAndCount(p,g,m)*Ae.PENALTY_N3}for(let f=0;f<this.size;f++){let p=!1,g=0,m=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[x][f]==p?(g++,g==5?a+=Ae.PENALTY_N1:g>5&&a++):(this.finderPenaltyAddHistory(g,m),p||(a+=this.finderPenaltyCountPatterns(m)*Ae.PENALTY_N3),p=this.modules[x][f],g=1);a+=this.finderPenaltyTerminateAndCount(p,g,m)*Ae.PENALTY_N3}for(let f=0;f<this.size-1;f++)for(let p=0;p<this.size-1;p++){const g=this.modules[f][p];g==this.modules[f][p+1]&&g==this.modules[f+1][p]&&g==this.modules[f+1][p+1]&&(a+=Ae.PENALTY_N2)}let u=0;for(const f of this.modules)u=f.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*Ae.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<Ae.MIN_VERSION||a>Ae.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(Ae.getNumRawDataModules(a)/8)-Ae.ECC_CODEWORDS_PER_BLOCK[u.ordinal][a]*Ae.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 f=0;f<u.length;f++)u[f]=Ae.reedSolomonMultiply(u[f],c),f+1<u.length&&(u[f]^=u[f+1]);c=Ae.reedSolomonMultiply(c,2)}return u}static reedSolomonComputeRemainder(a,u){let c=u.map(d=>0);for(const d of a){const f=d^c.shift();c.push(0),u.forEach((p,g)=>c[g]^=Ae.reedSolomonMultiply(p,f))}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 Ke{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 Ke(Ke.Mode.BYTE,a.length,u)}static makeNumeric(a){if(!Ke.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 Ke(Ke.Mode.NUMERIC,a.length,u)}static makeAlphanumeric(a){if(!Ke.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=Ke.ALPHANUMERIC_CHARSET.indexOf(a.charAt(c))*45;d+=Ke.ALPHANUMERIC_CHARSET.indexOf(a.charAt(c+1)),t(d,11,u)}return c<a.length&&t(Ke.ALPHANUMERIC_CHARSET.indexOf(a.charAt(c)),6,u),new Ke(Ke.Mode.ALPHANUMERIC,a.length,u)}static makeSegments(a){return a==""?[]:Ke.isNumeric(a)?[Ke.makeNumeric(a)]:Ke.isAlphanumeric(a)?[Ke.makeAlphanumeric(a)]:[Ke.makeBytes(Ke.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 Ke(Ke.Mode.ECI,0,u)}static isNumeric(a){return Ke.NUMERIC_REGEX.test(a)}static isAlphanumeric(a){return Ke.ALPHANUMERIC_REGEX.test(a)}getData(){return this.bitData.slice()}static getTotalBits(a,u){let c=0;for(const d of a){const f=d.mode.numCharCountBits(u);if(d.numChars>=1<<f)return 1/0;c+=4+f+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})(jr||(jr={}));(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={}))})(jr||(jr={}));(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={}))})(jr||(jr={}));var Gr=jr;/**
99
+ */var jr;(r=>{const e=class Ae{constructor(a,u,c,d){if(this.version=a,this.errorCorrectionLevel=u,this.modules=[],this.isFunction=[],a<Ae.MIN_VERSION||a>Ae.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 f=[];for(let g=0;g<this.size;g++)f.push(!1);for(let g=0;g<this.size;g++)this.modules.push(f.slice()),this.isFunction.push(f.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 Ae.encodeSegments(c,u)}static encodeBinary(a,u){const c=r.QrSegment.makeBytes(a);return Ae.encodeSegments([c],u)}static encodeSegments(a,u,c=1,d=40,f=-1,p=!0){if(!(Ae.MIN_VERSION<=c&&c<=d&&d<=Ae.MAX_VERSION)||f<-1||f>7)throw new RangeError("Invalid value");let g,m;for(g=c;;g++){const _=Ae.getNumDataCodewords(g,u)*8,S=o.getTotalBits(a,g);if(S<=_){m=S;break}if(g>=d)throw new RangeError("Data too long")}for(const _ of[Ae.Ecc.MEDIUM,Ae.Ecc.QUARTILE,Ae.Ecc.HIGH])p&&m<=Ae.getNumDataCodewords(g,_)*8&&(u=_);let x=[];for(const _ of a){t(_.mode.modeBits,4,x),t(_.numChars,_.mode.numCharCountBits(g),x);for(const S of _.getData())x.push(S)}s(x.length==m);const v=Ae.getNumDataCodewords(g,u)*8;s(x.length<=v),t(0,Math.min(4,v-x.length),x),t(0,(8-x.length%8)%8,x),s(x.length%8==0);for(let _=236;x.length<v;_^=253)t(_,8,x);let y=[];for(;y.length*8<x.length;)y.push(0);return x.forEach((_,S)=>y[S>>>3]|=_<<7-(S&7)),new Ae(g,u,y,f)}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 f=0;f<10;f++)c=c<<1^(c>>>9)*1335;const d=(u<<10|c)^21522;s(d>>>15==0);for(let f=0;f<=5;f++)this.setFunctionModule(8,f,n(d,f));this.setFunctionModule(8,7,n(d,6)),this.setFunctionModule(8,8,n(d,7)),this.setFunctionModule(7,8,n(d,8));for(let f=9;f<15;f++)this.setFunctionModule(14-f,8,n(d,f));for(let f=0;f<8;f++)this.setFunctionModule(this.size-1-f,8,n(d,f));for(let f=8;f<15;f++)this.setFunctionModule(8,this.size-15+f,n(d,f));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),f=this.size-11+c%3,p=Math.floor(c/3);this.setFunctionModule(f,p,d),this.setFunctionModule(p,f,d)}}drawFinderPattern(a,u){for(let c=-4;c<=4;c++)for(let d=-4;d<=4;d++){const f=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,f!=2&&f!=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!=Ae.getNumDataCodewords(u,c))throw new RangeError("Invalid argument");const d=Ae.NUM_ERROR_CORRECTION_BLOCKS[c.ordinal][u],f=Ae.ECC_CODEWORDS_PER_BLOCK[c.ordinal][u],p=Math.floor(Ae.getNumRawDataModules(u)/8),g=d-p%d,m=Math.floor(p/d);let x=[];const v=Ae.reedSolomonComputeDivisor(f);for(let _=0,S=0;_<d;_++){let E=a.slice(S,S+m-f+(_<g?0:1));S+=E.length;const k=Ae.reedSolomonComputeRemainder(E,v);_<g&&E.push(0),x.push(E.concat(k))}let y=[];for(let _=0;_<x[0].length;_++)x.forEach((S,E)=>{(_!=m-f||E>=g)&&y.push(S[_])});return s(y.length==p),y}drawCodewords(a){if(a.length!=Math.floor(Ae.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 f=0;f<2;f++){const p=c-f,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 f=0;f<this.size;f++){let p=!1,g=0,m=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[f][x]==p?(g++,g==5?a+=Ae.PENALTY_N1:g>5&&a++):(this.finderPenaltyAddHistory(g,m),p||(a+=this.finderPenaltyCountPatterns(m)*Ae.PENALTY_N3),p=this.modules[f][x],g=1);a+=this.finderPenaltyTerminateAndCount(p,g,m)*Ae.PENALTY_N3}for(let f=0;f<this.size;f++){let p=!1,g=0,m=[0,0,0,0,0,0,0];for(let x=0;x<this.size;x++)this.modules[x][f]==p?(g++,g==5?a+=Ae.PENALTY_N1:g>5&&a++):(this.finderPenaltyAddHistory(g,m),p||(a+=this.finderPenaltyCountPatterns(m)*Ae.PENALTY_N3),p=this.modules[x][f],g=1);a+=this.finderPenaltyTerminateAndCount(p,g,m)*Ae.PENALTY_N3}for(let f=0;f<this.size-1;f++)for(let p=0;p<this.size-1;p++){const g=this.modules[f][p];g==this.modules[f][p+1]&&g==this.modules[f+1][p]&&g==this.modules[f+1][p+1]&&(a+=Ae.PENALTY_N2)}let u=0;for(const f of this.modules)u=f.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*Ae.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<Ae.MIN_VERSION||a>Ae.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(Ae.getNumRawDataModules(a)/8)-Ae.ECC_CODEWORDS_PER_BLOCK[u.ordinal][a]*Ae.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 f=0;f<u.length;f++)u[f]=Ae.reedSolomonMultiply(u[f],c),f+1<u.length&&(u[f]^=u[f+1]);c=Ae.reedSolomonMultiply(c,2)}return u}static reedSolomonComputeRemainder(a,u){let c=u.map(d=>0);for(const d of a){const f=d^c.shift();c.push(0),u.forEach((p,g)=>c[g]^=Ae.reedSolomonMultiply(p,f))}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 Ke{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 Ke(Ke.Mode.BYTE,a.length,u)}static makeNumeric(a){if(!Ke.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 Ke(Ke.Mode.NUMERIC,a.length,u)}static makeAlphanumeric(a){if(!Ke.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=Ke.ALPHANUMERIC_CHARSET.indexOf(a.charAt(c))*45;d+=Ke.ALPHANUMERIC_CHARSET.indexOf(a.charAt(c+1)),t(d,11,u)}return c<a.length&&t(Ke.ALPHANUMERIC_CHARSET.indexOf(a.charAt(c)),6,u),new Ke(Ke.Mode.ALPHANUMERIC,a.length,u)}static makeSegments(a){return a==""?[]:Ke.isNumeric(a)?[Ke.makeNumeric(a)]:Ke.isAlphanumeric(a)?[Ke.makeAlphanumeric(a)]:[Ke.makeBytes(Ke.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 Ke(Ke.Mode.ECI,0,u)}static isNumeric(a){return Ke.NUMERIC_REGEX.test(a)}static isAlphanumeric(a){return Ke.ALPHANUMERIC_REGEX.test(a)}getData(){return this.bitData.slice()}static getTotalBits(a,u){let c=0;for(const d of a){const f=d.mode.numCharCountBits(u);if(d.numChars>=1<<f)return 1/0;c+=4+f+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})(jr||(jr={}));(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={}))})(jr||(jr={}));(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={}))})(jr||(jr={}));var Gr=jr;/**
100
100
  * @license qrcode.react
101
101
  * Copyright (c) Paul O'Shannessy
102
102
  * SPDX-License-Identifier: ISC
103
- */var ug={L:Gr.QrCode.Ecc.LOW,M:Gr.QrCode.Ecc.MEDIUM,Q:Gr.QrCode.Ecc.QUARTILE,H:Gr.QrCode.Ecc.HIGH},jc=128,Lc="L",Pc="#FFFFFF",Ic="#000000",Oc=!1,zc=1,cg=4,dg=0,fg=.1;function $c(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 qc(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 hg(r,e,t,n){if(n==null)return null;const s=r.length+t*2,i=Math.floor(e*fg),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 f=null;if(n.excavate){let g=Math.floor(u),m=Math.floor(c),x=Math.ceil(l+u-g),_=Math.ceil(a+c-m);f={x:g,y:m,w:x,h:_}}const p=n.crossOrigin;return{x:u,y:c,h:a,w:l,excavation:f,opacity:d,crossOrigin:p}}function pg(r,e){return e!=null?Math.max(Math.floor(e),0):r?cg:dg}function Uc({value:r,level:e,minVersion:t,includeMargin:n,marginSize:s,imageSettings:i,size:o,boostLevel:l}){let a=b.useMemo(()=>{const g=(Array.isArray(r)?r:[r]).reduce((m,x)=>(m.push(...Gr.QrSegment.makeSegments(x)),m),[]);return Gr.QrCode.encodeSegments(g,ug[e],t,void 0,void 0,l)},[r,e,t,l]);const{cells:u,margin:c,numCells:d,calculatedImageSettings:f}=b.useMemo(()=>{let p=a.getModules();const g=pg(n,s),m=p.length+g*2,x=hg(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:f}}var gg=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),mg=b.forwardRef(function(e,t){const n=e,{value:s,size:i=jc,level:o=Lc,bgColor:l=Pc,fgColor:a=Ic,includeMargin:u=Oc,minVersion:c=zc,boostLevel:d,marginSize:f,imageSettings:p}=n,m=xo(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:x}=m,_=xo(m,["style"]),y=p==null?void 0:p.src,w=b.useRef(null),C=b.useRef(null),D=b.useCallback(S=>{w.current=S,typeof t=="function"?t(S):t&&(t.current=S)},[t]),[E,v]=b.useState(!1),{margin:k,cells:M,numCells:T,calculatedImageSettings:N}=Uc({value:s,level:o,minVersion:c,boostLevel:d,includeMargin:u,marginSize:f,imageSettings:p,size:i});b.useEffect(()=>{if(w.current!=null){const S=w.current,B=S.getContext("2d");if(!B)return;let F=M;const O=C.current,V=N!=null&&O!==null&&O.complete&&O.naturalHeight!==0&&O.naturalWidth!==0;V&&N.excavation!=null&&(F=qc(M,N.excavation));const U=window.devicePixelRatio||1;S.height=S.width=i*U;const te=i/T*U;B.scale(te,te),B.fillStyle=l,B.fillRect(0,0,T,T),B.fillStyle=a,gg?B.fill(new Path2D($c(F,k))):M.forEach(function(q,X){q.forEach(function(W,se){W&&B.fillRect(se+k,X+k,1,1)})}),N&&(B.globalAlpha=N.opacity),V&&B.drawImage(O,N.x+k,N.y+k,N.w,N.h)}}),b.useEffect(()=>{v(!1)},[y]);const R=yo({height:i,width:i},x);let j=null;return y!=null&&(j=b.createElement("img",{src:y,key:y,style:{display:"none"},onLoad:()=>{v(!0)},ref:C,crossOrigin:N==null?void 0:N.crossOrigin})),b.createElement(b.Fragment,null,b.createElement("canvas",yo({style:R,height:i,width:i,ref:D,role:"img"},_)),j)});mg.displayName="QRCodeCanvas";var Wc=b.forwardRef(function(e,t){const n=e,{value:s,size:i=jc,level:o=Lc,bgColor:l=Pc,fgColor:a=Ic,includeMargin:u=Oc,minVersion:c=zc,boostLevel:d,title:f,marginSize:p,imageSettings:g}=n,m=xo(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:x,cells:_,numCells:y,calculatedImageSettings:w}=Uc({value:s,level:o,minVersion:c,boostLevel:d,includeMargin:u,marginSize:p,imageSettings:g,size:i});let C=_,D=null;g!=null&&w!=null&&(w.excavation!=null&&(C=qc(_,w.excavation)),D=b.createElement("image",{href:g.src,height:w.h,width:w.w,x:w.x+x,y:w.y+x,preserveAspectRatio:"none",opacity:w.opacity,crossOrigin:w.crossOrigin}));const E=$c(C,x);return b.createElement("svg",yo({height:i,width:i,viewBox:`0 0 ${y} ${y}`,ref:t,role:"img"},m),!!f&&b.createElement("title",null,f),b.createElement("path",{fill:l,d:`M0,0 h${y}v${y}H0z`,shapeRendering:"crispEdges"}),b.createElement("path",{fill:a,d:E,shapeRendering:"crispEdges"}),D)});Wc.displayName="QRCodeSVG";function yg(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 xg({data:r,size:e=150}){return h.jsx("div",{style:{display:"inline-block",background:"#f9f9f9",padding:"12px",borderRadius:"8px",margin:"8px 0"},children:h.jsx(Wc,{value:r,size:e,level:"M"})})}class un extends ra{constructor(t,n=150,s){super(s);bt(this,"__data");bt(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:yg,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 h.jsx(xg,{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 bg(r){return r instanceof un}const vg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",toolbarBackground:"#f9fafb",quoteBorder:"#d1d5db",quoteBackground:"#f3f4f6"},_g={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 wg({theme:r,disabled:e,onAiRestructure:t,onAiProofread:n,onAiRewrite:s,aiProcessing:i,aiProcessingAction:o,onAiAction:l,hasContent:a}){const[u]=zt(),[c,d]=b.useState(!1),f=b.useRef(null),p=t||n||s,g=b.useCallback(()=>{u.dispatchCommand(It,"bold")},[u]),m=b.useCallback(()=>{u.dispatchCommand(It,"italic")},[u]),x=b.useCallback(()=>{u.dispatchCommand(It,"underline")},[u]),_=b.useCallback(()=>{u.dispatchCommand(Nc,void 0)},[u]),y=b.useCallback(()=>{u.dispatchCommand(Bc,void 0)},[u]),w=b.useCallback(()=>{u.update(()=>{const v=oe();H(v)&&ep(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},D=`
103
+ */var ug={L:Gr.QrCode.Ecc.LOW,M:Gr.QrCode.Ecc.MEDIUM,Q:Gr.QrCode.Ecc.QUARTILE,H:Gr.QrCode.Ecc.HIGH},jc=128,Lc="L",Pc="#FFFFFF",Ic="#000000",Oc=!1,zc=1,cg=4,dg=0,fg=.1;function $c(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 qc(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 hg(r,e,t,n){if(n==null)return null;const s=r.length+t*2,i=Math.floor(e*fg),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 f=null;if(n.excavate){let g=Math.floor(u),m=Math.floor(c),x=Math.ceil(l+u-g),v=Math.ceil(a+c-m);f={x:g,y:m,w:x,h:v}}const p=n.crossOrigin;return{x:u,y:c,h:a,w:l,excavation:f,opacity:d,crossOrigin:p}}function pg(r,e){return e!=null?Math.max(Math.floor(e),0):r?cg:dg}function Uc({value:r,level:e,minVersion:t,includeMargin:n,marginSize:s,imageSettings:i,size:o,boostLevel:l}){let a=b.useMemo(()=>{const g=(Array.isArray(r)?r:[r]).reduce((m,x)=>(m.push(...Gr.QrSegment.makeSegments(x)),m),[]);return Gr.QrCode.encodeSegments(g,ug[e],t,void 0,void 0,l)},[r,e,t,l]);const{cells:u,margin:c,numCells:d,calculatedImageSettings:f}=b.useMemo(()=>{let p=a.getModules();const g=pg(n,s),m=p.length+g*2,x=hg(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:f}}var gg=function(){try{new Path2D().addPath(new Path2D)}catch{return!1}return!0}(),mg=b.forwardRef(function(e,t){const n=e,{value:s,size:i=jc,level:o=Lc,bgColor:l=Pc,fgColor:a=Ic,includeMargin:u=Oc,minVersion:c=zc,boostLevel:d,marginSize:f,imageSettings:p}=n,m=xo(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","marginSize","imageSettings"]),{style:x}=m,v=xo(m,["style"]),y=p==null?void 0:p.src,_=b.useRef(null),S=b.useRef(null),E=b.useCallback(C=>{_.current=C,typeof t=="function"?t(C):t&&(t.current=C)},[t]),[k,w]=b.useState(!1),{margin:D,cells:j,numCells:B,calculatedImageSettings:T}=Uc({value:s,level:o,minVersion:c,boostLevel:d,includeMargin:u,marginSize:f,imageSettings:p,size:i});b.useEffect(()=>{if(_.current!=null){const C=_.current,N=C.getContext("2d");if(!N)return;let F=j;const I=S.current,W=T!=null&&I!==null&&I.complete&&I.naturalHeight!==0&&I.naturalWidth!==0;W&&T.excavation!=null&&(F=qc(j,T.excavation));const z=window.devicePixelRatio||1;C.height=C.width=i*z;const te=i/B*z;N.scale(te,te),N.fillStyle=l,N.fillRect(0,0,B,B),N.fillStyle=a,gg?N.fill(new Path2D($c(F,D))):j.forEach(function(U,Q){U.forEach(function(H,se){H&&N.fillRect(se+D,Q+D,1,1)})}),T&&(N.globalAlpha=T.opacity),W&&N.drawImage(I,T.x+D,T.y+D,T.w,T.h)}}),b.useEffect(()=>{w(!1)},[y]);const R=yo({height:i,width:i},x);let M=null;return y!=null&&(M=b.createElement("img",{src:y,key:y,style:{display:"none"},onLoad:()=>{w(!0)},ref:S,crossOrigin:T==null?void 0:T.crossOrigin})),b.createElement(b.Fragment,null,b.createElement("canvas",yo({style:R,height:i,width:i,ref:E,role:"img"},v)),M)});mg.displayName="QRCodeCanvas";var Wc=b.forwardRef(function(e,t){const n=e,{value:s,size:i=jc,level:o=Lc,bgColor:l=Pc,fgColor:a=Ic,includeMargin:u=Oc,minVersion:c=zc,boostLevel:d,title:f,marginSize:p,imageSettings:g}=n,m=xo(n,["value","size","level","bgColor","fgColor","includeMargin","minVersion","boostLevel","title","marginSize","imageSettings"]),{margin:x,cells:v,numCells:y,calculatedImageSettings:_}=Uc({value:s,level:o,minVersion:c,boostLevel:d,includeMargin:u,marginSize:p,imageSettings:g,size:i});let S=v,E=null;g!=null&&_!=null&&(_.excavation!=null&&(S=qc(v,_.excavation)),E=b.createElement("image",{href:g.src,height:_.h,width:_.w,x:_.x+x,y:_.y+x,preserveAspectRatio:"none",opacity:_.opacity,crossOrigin:_.crossOrigin}));const k=$c(S,x);return b.createElement("svg",yo({height:i,width:i,viewBox:`0 0 ${y} ${y}`,ref:t,role:"img"},m),!!f&&b.createElement("title",null,f),b.createElement("path",{fill:l,d:`M0,0 h${y}v${y}H0z`,shapeRendering:"crispEdges"}),b.createElement("path",{fill:a,d:k,shapeRendering:"crispEdges"}),E)});Wc.displayName="QRCodeSVG";function yg(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 xg({data:r,size:e=150}){return h.jsx("div",{style:{display:"inline-block",background:"#f9f9f9",padding:"12px",borderRadius:"8px",margin:"8px 0"},children:h.jsx(Wc,{value:r,size:e,level:"M"})})}class un extends ra{constructor(t,n=150,s){super(s);bt(this,"__data");bt(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:yg,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 h.jsx(xg,{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 bg(r){return r instanceof un}const vg={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",toolbarBackground:"#f9fafb",quoteBorder:"#d1d5db",quoteBackground:"#f3f4f6"},_g={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 wg({theme:r,disabled:e,onAiRestructure:t,onAiProofread:n,onAiRewrite:s,aiProcessing:i,aiProcessingAction:o,onAiAction:l,hasContent:a}){const[u]=zt(),[c,d]=b.useState(!1),f=b.useRef(null),p=t||n||s,g=b.useCallback(()=>{u.dispatchCommand(It,"bold")},[u]),m=b.useCallback(()=>{u.dispatchCommand(It,"italic")},[u]),x=b.useCallback(()=>{u.dispatchCommand(It,"underline")},[u]),v=b.useCallback(()=>{u.dispatchCommand(Nc,void 0)},[u]),y=b.useCallback(()=>{u.dispatchCommand(Bc,void 0)},[u]),_=b.useCallback(()=>{u.update(()=>{const w=oe();V(w)&&ep(w,()=>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},E=`
104
104
  .mail-editor-toolbar-btn:hover:not(:disabled) {
105
105
  background: ${r.border};
106
106
  }
107
- `,E=()=>{setTimeout(()=>{var v;(v=f.current)!=null&&v.contains(document.activeElement)||d(!1)},150)};return h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",borderBottom:`1px solid ${r.border}`,background:r.toolbarBackground},children:[h.jsx("style",{children:D}),h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"2px"},children:[h.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:g,disabled:e,style:C,title:"Bold (Ctrl+B)",children:"B"}),h.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:m,disabled:e,style:{...C,fontStyle:"italic"},title:"Italic (Ctrl+I)",children:"I"}),h.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:x,disabled:e,style:{...C,textDecoration:"underline"},title:"Underline (Ctrl+U)",children:"U"}),h.jsx("div",{style:{width:"1px",height:"20px",background:r.border,margin:"0 6px"}}),h.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:_,disabled:e,style:C,title:"Bullet List",children:h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[h.jsx("circle",{cx:"4",cy:"6",r:"2"}),h.jsx("circle",{cx:"4",cy:"12",r:"2"}),h.jsx("circle",{cx:"4",cy:"18",r:"2"}),h.jsx("rect",{x:"8",y:"5",width:"14",height:"2"}),h.jsx("rect",{x:"8",y:"11",width:"14",height:"2"}),h.jsx("rect",{x:"8",y:"17",width:"14",height:"2"})]})}),h.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:y,disabled:e,style:C,title:"Numbered List",children:h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[h.jsx("text",{x:"2",y:"8",fontSize:"8",fontFamily:"sans-serif",children:"1"}),h.jsx("text",{x:"2",y:"14",fontSize:"8",fontFamily:"sans-serif",children:"2"}),h.jsx("text",{x:"2",y:"20",fontSize:"8",fontFamily:"sans-serif",children:"3"}),h.jsx("rect",{x:"8",y:"5",width:"14",height:"2"}),h.jsx("rect",{x:"8",y:"11",width:"14",height:"2"}),h.jsx("rect",{x:"8",y:"17",width:"14",height:"2"})]})}),h.jsx("div",{style:{width:"1px",height:"20px",background:r.border,margin:"0 6px"}}),h.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:w,disabled:e,style:C,title:"Quote",children:h.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("path",{d:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"})})})]}),p&&h.jsxs("div",{style:{position:"relative"},ref:f,children:[h.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?h.jsxs(h.Fragment,{children:[h.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..."]}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons",style:{fontSize:"16px"},children:"auto_fix_high"}),"AI",h.jsx("span",{className:"material-icons",style:{fontSize:"14px"},children:"expand_more"})]})}),c&&!i&&h.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&&h.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:[h.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#3b82f6"},children:"format_list_bulleted"}),h.jsxs("div",{children:[h.jsx("div",{style:{fontWeight:500},children:"Restructure"}),h.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Organize & clarify"})]})]}),n&&h.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:[h.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#22c55e"},children:"spellcheck"}),h.jsxs("div",{children:[h.jsx("div",{style:{fontWeight:500},children:"Proofread"}),h.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Fix grammar & spelling"})]})]}),s&&h.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:[h.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#9333ea"},children:"brush"}),h.jsxs("div",{children:[h.jsx("div",{style:{fontWeight:500},children:"Rewrite"}),h.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Your voice & style"})]})]})]})]})]})}function Cg({html:r,isExternalUpdate:e,onImportComplete:t}){const[n]=zt(),s=b.useRef(!1);return b.useEffect(()=>{r&&(s.current&&!e||(s.current=!0,n.update(()=>{const i=Ge();i.clear();const o=rt();i.append(o),o.select();const a=new DOMParser().parseFromString(r,"text/html"),c=_c(n,a).filter(d=>d.getParent()===null);c.length>0&&oc(c),o.getTextContent()===""&&i.getChildrenSize()>1&&o.remove(),i.selectEnd()},{discrete:!0}),t(),setTimeout(()=>{n.focus()},0)))},[r,e,n,t]),null}function Sg({text:r,trigger:e}){const[t]=zt(),n=b.useRef(void 0);return b.useEffect(()=>{if(e===void 0||e===n.current||!r)return;n.current=e;const s=r.trim();s&&(t.update(()=>{const i=oe();if(H(i))i.insertText(s);else{const o=Ge(),l=o.getLastChild();if(l){l.selectEnd();const a=oe();H(a)&&a.insertText(s)}else{const a=rt(),u=st(s);a.append(u),o.append(a)}}}),setTimeout(()=>{t.focus()},0))},[r,e,t]),null}function kg({replyTo:r,theme:e}){const t=n=>{try{return new Date(n).toLocaleString()}catch{return n}};return h.jsxs("div",{style:{marginTop:"16px",paddingTop:"16px",borderTop:`1px solid ${e.border}`},children:[h.jsxs("div",{style:{fontSize:"12px",color:e.textSecondary,marginBottom:"8px"},children:["On ",t(r.date),", ",r.from," wrote:"]}),h.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 Hc({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:f,onAiRewrite:p,aiProcessing:g,aiProcessingAction:m,renderAboveToolbar:x}){const _={...vg,...s},[y,w]=b.useState(!1),C=b.useRef(void 0),[D,E]=b.useState(r),[v,k]=b.useState(!1),[M,T]=b.useState(null),N=g??v,R=m??M;b.useEffect(()=>{a!==void 0&&a!==C.current&&(C.current=a,w(!0))},[a]);const j=b.useCallback(()=>{w(!1)},[]),S=q=>q.replace(/<[^>]*>/g,"").trim(),B=q=>q.split(`
108
- `).map(X=>`<p>${X||"<br>"}</p>`).join(""),F=async q=>{const X=S(D);if(!X)return;const W=q==="restructure"?d:q==="proofread"?f:p;if(W){k(!0),T(q);try{const se=await W(X),ue=B(se);E(ue),e==null||e(ue),C.current=Date.now(),w(!0)}catch(se){console.error(`AI ${q} failed:`,se)}finally{k(!1),T(null)}}},O=S(D).length>0,V={namespace:"MailEditor",theme:_g,onError:q=>{console.error("Lexical error:",q)},nodes:[ln,Ir,Or,ns,bi,xi,vi,un],editable:!i},U=b.useCallback((q,X)=>{q.read(()=>{const W=wc(X,null);E(W),e==null||e(W)})},[e]),te=`
107
+ `,k=()=>{setTimeout(()=>{var w;(w=f.current)!=null&&w.contains(document.activeElement)||d(!1)},150)};return h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px",borderBottom:`1px solid ${r.border}`,background:r.toolbarBackground},children:[h.jsx("style",{children:E}),h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"2px"},children:[h.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:g,disabled:e,style:S,title:"Bold (Ctrl+B)",children:"B"}),h.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:m,disabled:e,style:{...S,fontStyle:"italic"},title:"Italic (Ctrl+I)",children:"I"}),h.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:x,disabled:e,style:{...S,textDecoration:"underline"},title:"Underline (Ctrl+U)",children:"U"}),h.jsx("div",{style:{width:"1px",height:"20px",background:r.border,margin:"0 6px"}}),h.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:v,disabled:e,style:S,title:"Bullet List",children:h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[h.jsx("circle",{cx:"4",cy:"6",r:"2"}),h.jsx("circle",{cx:"4",cy:"12",r:"2"}),h.jsx("circle",{cx:"4",cy:"18",r:"2"}),h.jsx("rect",{x:"8",y:"5",width:"14",height:"2"}),h.jsx("rect",{x:"8",y:"11",width:"14",height:"2"}),h.jsx("rect",{x:"8",y:"17",width:"14",height:"2"})]})}),h.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:y,disabled:e,style:S,title:"Numbered List",children:h.jsxs("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:[h.jsx("text",{x:"2",y:"8",fontSize:"8",fontFamily:"sans-serif",children:"1"}),h.jsx("text",{x:"2",y:"14",fontSize:"8",fontFamily:"sans-serif",children:"2"}),h.jsx("text",{x:"2",y:"20",fontSize:"8",fontFamily:"sans-serif",children:"3"}),h.jsx("rect",{x:"8",y:"5",width:"14",height:"2"}),h.jsx("rect",{x:"8",y:"11",width:"14",height:"2"}),h.jsx("rect",{x:"8",y:"17",width:"14",height:"2"})]})}),h.jsx("div",{style:{width:"1px",height:"20px",background:r.border,margin:"0 6px"}}),h.jsx("button",{type:"button",className:"mail-editor-toolbar-btn",onClick:_,disabled:e,style:S,title:"Quote",children:h.jsx("svg",{width:"16",height:"16",viewBox:"0 0 24 24",fill:"currentColor",children:h.jsx("path",{d:"M6 17h3l2-4V7H5v6h3zm8 0h3l2-4V7h-6v6h3z"})})})]}),p&&h.jsxs("div",{style:{position:"relative"},ref:f,children:[h.jsx("button",{type:"button",onClick:()=>d(!c),disabled:i||!a||e,onBlur:k,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?h.jsxs(h.Fragment,{children:[h.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..."]}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons",style:{fontSize:"16px"},children:"auto_fix_high"}),"AI",h.jsx("span",{className:"material-icons",style:{fontSize:"14px"},children:"expand_more"})]})}),c&&!i&&h.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&&h.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:w=>w.currentTarget.style.background="#f3f4f6",onMouseLeave:w=>w.currentTarget.style.background="transparent",children:[h.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#3b82f6"},children:"format_list_bulleted"}),h.jsxs("div",{children:[h.jsx("div",{style:{fontWeight:500},children:"Restructure"}),h.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Organize & clarify"})]})]}),n&&h.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:w=>w.currentTarget.style.background="#f3f4f6",onMouseLeave:w=>w.currentTarget.style.background="transparent",children:[h.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#22c55e"},children:"spellcheck"}),h.jsxs("div",{children:[h.jsx("div",{style:{fontWeight:500},children:"Proofread"}),h.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Fix grammar & spelling"})]})]}),s&&h.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:w=>w.currentTarget.style.background="#f3f4f6",onMouseLeave:w=>w.currentTarget.style.background="transparent",children:[h.jsx("span",{className:"material-icons",style:{fontSize:"18px",color:"#9333ea"},children:"brush"}),h.jsxs("div",{children:[h.jsx("div",{style:{fontWeight:500},children:"Rewrite"}),h.jsx("div",{style:{fontSize:"12px",color:"#6b7280"},children:"Your voice & style"})]})]})]})]})]})}function Cg({html:r,isExternalUpdate:e,onImportComplete:t}){const[n]=zt(),s=b.useRef(!1);return b.useEffect(()=>{r&&(s.current&&!e||(s.current=!0,n.update(()=>{const i=Ge();i.clear();const o=rt();i.append(o),o.select();const a=new DOMParser().parseFromString(r,"text/html"),c=_c(n,a).filter(d=>d.getParent()===null);c.length>0&&oc(c),o.getTextContent()===""&&i.getChildrenSize()>1&&o.remove(),i.selectEnd()},{discrete:!0}),t(),setTimeout(()=>{n.focus()},0)))},[r,e,n,t]),null}function Sg({text:r,trigger:e}){const[t]=zt(),n=b.useRef(void 0);return b.useEffect(()=>{if(e===void 0||e===n.current||!r)return;n.current=e;const s=r.trim();s&&(t.update(()=>{const i=oe();if(V(i))i.insertText(s);else{const o=Ge(),l=o.getLastChild();if(l){l.selectEnd();const a=oe();V(a)&&a.insertText(s)}else{const a=rt(),u=st(s);a.append(u),o.append(a)}}}),setTimeout(()=>{t.focus()},0))},[r,e,t]),null}function kg({replyTo:r,theme:e}){const t=n=>{try{return new Date(n).toLocaleString()}catch{return n}};return h.jsxs("div",{style:{marginTop:"16px",paddingTop:"16px",borderTop:`1px solid ${e.border}`},children:[h.jsxs("div",{style:{fontSize:"12px",color:e.textSecondary,marginBottom:"8px"},children:["On ",t(r.date),", ",r.from," wrote:"]}),h.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 Hc({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:f,onAiRewrite:p,aiProcessing:g,aiProcessingAction:m,renderAboveToolbar:x}){const v={...vg,...s},[y,_]=b.useState(!1),S=b.useRef(void 0),[E,k]=b.useState(r),[w,D]=b.useState(!1),[j,B]=b.useState(null),T=g??w,R=m??j;b.useEffect(()=>{a!==void 0&&a!==S.current&&(S.current=a,_(!0))},[a]);const M=b.useCallback(()=>{_(!1)},[]),C=U=>U.replace(/<[^>]*>/g,"").trim(),N=U=>U.split(`
108
+ `).map(Q=>`<p>${Q||"<br>"}</p>`).join(""),F=async U=>{const Q=C(E);if(!Q)return;const H=U==="restructure"?d:U==="proofread"?f:p;if(H){D(!0),B(U);try{const se=await H(Q),ue=N(se);k(ue),e==null||e(ue),S.current=Date.now(),_(!0)}catch(se){console.error(`AI ${U} failed:`,se)}finally{D(!1),B(null)}}},I=C(E).length>0,W={namespace:"MailEditor",theme:_g,onError:U=>{console.error("Lexical error:",U)},nodes:[ln,Ir,Or,ns,bi,xi,vi,un],editable:!i},z=b.useCallback((U,Q)=>{U.read(()=>{const H=wc(Q,null);k(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;
@@ -127,15 +127,15 @@ React keys must be passed directly to JSX without using spread:
127
127
  margin: 4px 0;
128
128
  }
129
129
  .mail-editor-link {
130
- color: ${_.primary};
130
+ color: ${v.primary};
131
131
  text-decoration: underline;
132
132
  }
133
133
  .mail-editor-quote {
134
134
  margin: 8px 0;
135
135
  padding: 8px 16px;
136
- border-left: 3px solid ${_.quoteBorder};
137
- background: ${_.quoteBackground};
138
- color: ${_.textSecondary};
136
+ border-left: 3px solid ${v.quoteBorder};
137
+ background: ${v.quoteBackground};
138
+ color: ${v.textSecondary};
139
139
  }
140
140
  .mail-editor-h1 {
141
141
  font-size: 24px;
@@ -158,7 +158,7 @@ React keys must be passed directly to JSX without using spread:
158
158
  padding: 16px;
159
159
  font-size: 14px;
160
160
  line-height: 1.6;
161
- color: ${_.text};
161
+ color: ${v.text};
162
162
  }
163
163
  .mail-editor-content:focus {
164
164
  outline: none;
@@ -167,7 +167,7 @@ React keys must be passed directly to JSX without using spread:
167
167
  position: absolute;
168
168
  top: 16px;
169
169
  left: 16px;
170
- color: ${_.textSecondary};
170
+ color: ${v.textSecondary};
171
171
  pointer-events: none;
172
172
  font-size: 14px;
173
173
  }
@@ -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 h.jsxs("div",{className:o,style:{border:`1px solid ${_.border}`,borderRadius:"8px",background:_.background,overflow:"hidden",display:"flex",flexDirection:"column",height:"100%",minHeight:l},children:[h.jsx("style",{children:te}),x,h.jsxs($h,{initialConfig:V,children:[h.jsx(wg,{theme:_,disabled:i,onAiRestructure:d,onAiProofread:f,onAiRewrite:p,aiProcessing:N,aiProcessingAction:R,onAiAction:F,hasContent:O}),h.jsx("div",{style:{position:"relative",flex:1,display:"flex",flexDirection:"column"},children:h.jsx(kp,{contentEditable:h.jsx(Tp,{className:"mail-editor-content",style:{outline:"none",flex:1,minHeight:"100px",padding:"16px",fontSize:"14px",lineHeight:1.6,color:_.text}}),placeholder:h.jsx("div",{className:"mail-editor-placeholder",children:t}),ErrorBoundary:Up})}),h.jsx(tg,{}),h.jsx(ig,{}),h.jsx(Op,{}),h.jsx($p,{onChange:U}),h.jsx(Cg,{html:y?D:r,isExternalUpdate:y,onImportComplete:j}),h.jsx(Sg,{text:u,trigger:c})]}),n&&h.jsx(kg,{replyTo:n,theme:_})]})}const Eg={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 Dg({to:r="",subject:e="",body:t="",replyTo:n,onSend:s,onCancel:i,onBodyChange:o,externalUpdate:l,insertText:a,insertTextTrigger:u,theme:c={},disabled:d=!1,showCcBcc:f=!1,placeholder:p="Write your message...",className:g="",minHeight:m="200px",sendButtonText:x="Send",hideCancelButton:_=!1,onAiRestructure:y,onAiProofread:w,onAiRewrite:C,renderAboveToolbar:D}){const E={...Eg,...c},[v,k]=b.useState(r),[M,T]=b.useState(""),[N,R]=b.useState(""),[j,S]=b.useState(e),[B,F]=b.useState(t),[O,V]=b.useState([]),[U,te]=b.useState(!1),[q,X]=b.useState(""),[W,se]=b.useState(f),[ue,de]=b.useState(!1),pe=b.useRef(void 0);b.useEffect(()=>{l!==void 0&&l!==pe.current&&(pe.current=l,F(t),de(!0))},[l,t]);const De=z=>{F(z),de(!1),o==null||o(z)},xe=b.useRef(null),[J,Ce]=b.useState(!1),ne=z=>{const ae=z.target.files;if(ae){const ge=Array.from(ae);console.log("[MailComposer] Files selected:",ge.map(ye=>({name:ye.name,size:ye.size,type:ye.type}))),V(ye=>[...ye,...ge])}xe.current&&(xe.current.value="")},Be=z=>{z.preventDefault(),z.stopPropagation(),Ce(!0)},Se=z=>{z.preventDefault(),z.stopPropagation(),Ce(!1)},ke=z=>{if(z.preventDefault(),z.stopPropagation(),Ce(!1),z.dataTransfer.files&&z.dataTransfer.files.length>0){const ae=Array.from(z.dataTransfer.files);console.log("[MailComposer] Files dropped:",ae.map(ge=>({name:ge.name,size:ge.size,type:ge.type}))),V(ge=>[...ge,...ae])}else console.log("[MailComposer] Drop event but no files:",z.dataTransfer.types)},Ie=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",Le=z=>{V(ae=>ae.filter((ge,ye)=>ye!==z))},$e=z=>z<1024?`${z} B`:z<1024*1024?`${(z/1024).toFixed(1)} KB`:`${(z/(1024*1024)).toFixed(1)} MB`,Y=async()=>{if(!v.trim()){X("Recipient email is required");return}if(!j.trim()){X("Subject is required");return}te(!0),X("");try{const z=await Promise.all(O.map(async ye=>{const Ue=await ye.arrayBuffer(),mt=btoa(new Uint8Array(Ue).reduce((yt,ie)=>yt+String.fromCharCode(ie),""));return{filename:ye.name,content_type:ye.type||"application/octet-stream",data:mt,size:ye.size}})),ae=B.replace(/>\n+</g,"><").replace(/<p class="[^"]*"><\/p>/g,"<br>").trim(),ge={to:v.trim(),cc:M.trim()||void 0,bcc:N.trim()||void 0,subject:j.trim(),html:ae,attachments:z,inReplyTo:n==null?void 0:n.messageId};console.log("[MailComposer] Sending email - to:",ge.to,"subject:",ge.subject,"attachmentsCount:",ge.attachments.length),ge.attachments.length>0&&ge.attachments.forEach((ye,Ue)=>{var mt;console.log(`[MailComposer] Attachment ${Ue+1}:`,ye.filename,"size:",ye.size,"type:",ye.content_type,"data length:",((mt=ye.data)==null?void 0:mt.length)||0)}),await s(ge),k(""),T(""),R(""),S(""),F(""),V([])}catch(z){X(z instanceof Error?z.message:"Failed to send email")}finally{te(!1)}},P={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${E.inputBorder}`,borderRadius:"6px",background:E.inputBackground,color:E.text,outline:"none"},me={display:"block",fontSize:"12px",fontWeight:500,color:E.textSecondary,marginBottom:"4px",textTransform:"uppercase"},We=(z,ae=!1)=>({padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderRadius:"6px",cursor:ae?"not-allowed":"pointer",opacity:ae?.6:1,background:z?E.buttonPrimary:E.buttonSecondary,color:z?"#ffffff":E.text,display:"flex",alignItems:"center",gap:"8px"});return h.jsxs("div",{className:g,style:{display:"flex",flexDirection:"column",gap:"16px",padding:"16px",background:E.background},children:[q&&h.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:"6px",color:"#dc2626",fontSize:"14px"},children:q}),h.jsxs("div",{children:[h.jsx("label",{style:me,children:"To"}),h.jsx("input",{type:"email",value:v,onChange:z=>k(z.target.value),placeholder:"recipient@example.com",disabled:d||U,style:P})]}),!W&&h.jsx("button",{type:"button",onClick:()=>se(!0),disabled:d||U,style:{background:"none",border:"none",padding:0,fontSize:"12px",color:E.primary,cursor:"pointer",textAlign:"left"},children:"+ Add CC/BCC"}),W&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{children:[h.jsx("label",{style:me,children:"CC"}),h.jsx("input",{type:"email",value:M,onChange:z=>T(z.target.value),placeholder:"cc@example.com",disabled:d||U,style:P})]}),h.jsxs("div",{children:[h.jsx("label",{style:me,children:"BCC"}),h.jsx("input",{type:"email",value:N,onChange:z=>R(z.target.value),placeholder:"bcc@example.com",disabled:d||U,style:P})]})]}),h.jsxs("div",{children:[h.jsx("label",{style:me,children:"Subject"}),h.jsx("input",{type:"text",value:j,onChange:z=>S(z.target.value),placeholder:"Email subject",disabled:d||U,style:P})]}),h.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:h.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:h.jsx(Hc,{value:B,onChange:De,placeholder:p,replyTo:n,theme:E,disabled:d||U,minHeight:m,externalUpdate:ue?l:void 0,insertText:a,insertTextTrigger:u,onAiRestructure:y,onAiProofread:w,onAiRewrite:C,renderAboveToolbar:D})})}),h.jsxs("div",{children:[h.jsx("label",{style:{...me,marginBottom:"8px"},children:"Attachments"}),h.jsx("input",{ref:xe,type:"file",multiple:!0,onChange:ne,style:{display:"none"}}),h.jsxs("div",{onClick:()=>{var z;return(z=xe.current)==null?void 0:z.click()},onDragOver:Be,onDragLeave:Se,onDrop:ke,style:{width:"100%",padding:"24px 16px",border:`2px dashed ${J?E.primary:E.border}`,borderRadius:"8px",background:J?`${E.primary}10`:"transparent",color:J?E.primary:E.textSecondary,cursor:d||U?"not-allowed":"pointer",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s",marginBottom:O.length>0?"12px":0},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"24px"},children:J?"file_download":"attach_file"}),h.jsx("span",{style:{fontSize:"14px"},children:J?"Drop files here":"Drop files or click to add"})]}),O.length>0&&h.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:O.map((z,ae)=>h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:E.attachmentBackground,borderRadius:"8px"},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E.textSecondary},children:Ie(z)}),h.jsxs("div",{style:{flex:1,minWidth:0},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:E.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:z.name}),h.jsx("div",{style:{fontSize:"12px",color:E.textSecondary},children:$e(z.size)})]}),h.jsx("button",{type:"button",onClick:()=>Le(ae),disabled:d||U,style:{background:"none",border:"none",padding:"4px",cursor:"pointer",color:E.textSecondary,display:"flex",borderRadius:"4px"},children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:"close"})})]},`${z.name}-${ae}`))})]}),h.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"12px"},children:[!_&&i&&h.jsx("button",{type:"button",onClick:i,disabled:d||U,style:We(!1,d||U),children:"Cancel"}),h.jsxs("button",{type:"button",onClick:Y,disabled:d||U||!v.trim()||!j.trim(),style:We(!0,d||U||!v.trim()||!j.trim()),children:[h.jsx("span",{className:"material-icons",style:{fontSize:"18px",animation:U?"spin 1s linear infinite":"none"},children:U?"sync":"send"}),U?"Sending...":x]})]}),h.jsx("style",{children:`
178
+ `;return h.jsxs("div",{className:o,style:{border:`1px solid ${v.border}`,borderRadius:"8px",background:v.background,overflow:"hidden",display:"flex",flexDirection:"column",height:"100%",minHeight:l},children:[h.jsx("style",{children:te}),x,h.jsxs($h,{initialConfig:W,children:[h.jsx(wg,{theme:v,disabled:i,onAiRestructure:d,onAiProofread:f,onAiRewrite:p,aiProcessing:T,aiProcessingAction:R,onAiAction:F,hasContent:I}),h.jsx("div",{style:{position:"relative",flex:1,display:"flex",flexDirection:"column"},children:h.jsx(kp,{contentEditable:h.jsx(Tp,{className:"mail-editor-content",style:{outline:"none",flex:1,minHeight:"100px",padding:"16px",fontSize:"14px",lineHeight:1.6,color:v.text}}),placeholder:h.jsx("div",{className:"mail-editor-placeholder",children:t}),ErrorBoundary:Up})}),h.jsx(tg,{}),h.jsx(ig,{}),h.jsx(Op,{}),h.jsx($p,{onChange:z}),h.jsx(Cg,{html:y?E:r,isExternalUpdate:y,onImportComplete:M}),h.jsx(Sg,{text:u,trigger:c})]}),n&&h.jsx(kg,{replyTo:n,theme:v})]})}const Eg={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 Dg({to:r="",subject:e="",body:t="",replyTo:n,onSend:s,onCancel:i,onBodyChange:o,externalUpdate:l,insertText:a,insertTextTrigger:u,theme:c={},disabled:d=!1,showCcBcc:f=!1,placeholder:p="Write your message...",className:g="",minHeight:m="200px",sendButtonText:x="Send",hideCancelButton:v=!1,onAiRestructure:y,onAiProofread:_,onAiRewrite:S,renderAboveToolbar:E}){const k={...Eg,...c},[w,D]=b.useState(r),[j,B]=b.useState(""),[T,R]=b.useState(""),[M,C]=b.useState(e),[N,F]=b.useState(t),[I,W]=b.useState([]),[z,te]=b.useState(!1),[U,Q]=b.useState(""),[H,se]=b.useState(f),[ue,de]=b.useState(!1),pe=b.useRef(void 0);b.useEffect(()=>{l!==void 0&&l!==pe.current&&(pe.current=l,F(t),de(!0))},[l,t]);const De=$=>{F($),de(!1),o==null||o($)},xe=b.useRef(null),[J,Ce]=b.useState(!1),ne=$=>{const ae=$.target.files;if(ae){const ge=Array.from(ae);console.log("[MailComposer] Files selected:",ge.map(ye=>({name:ye.name,size:ye.size,type:ye.type}))),W(ye=>[...ye,...ge])}xe.current&&(xe.current.value="")},Be=$=>{$.preventDefault(),$.stopPropagation(),Ce(!0)},Se=$=>{$.preventDefault(),$.stopPropagation(),Ce(!1)},ke=$=>{if($.preventDefault(),$.stopPropagation(),Ce(!1),$.dataTransfer.files&&$.dataTransfer.files.length>0){const ae=Array.from($.dataTransfer.files);console.log("[MailComposer] Files dropped:",ae.map(ge=>({name:ge.name,size:ge.size,type:ge.type}))),W(ge=>[...ge,...ae])}else console.log("[MailComposer] Drop event but no files:",$.dataTransfer.types)},Ie=$=>$.type.startsWith("image/")?"image":$.type==="application/pdf"?"picture_as_pdf":$.type.includes("spreadsheet")||$.type.includes("excel")?"table_chart":$.type.includes("document")||$.type.includes("word")?"description":"attach_file",Le=$=>{W(ae=>ae.filter((ge,ye)=>ye!==$))},$e=$=>$<1024?`${$} B`:$<1024*1024?`${($/1024).toFixed(1)} KB`:`${($/(1024*1024)).toFixed(1)} MB`,Y=async()=>{if(!w.trim()){Q("Recipient email is required");return}if(!M.trim()){Q("Subject is required");return}te(!0),Q("");try{const $=await Promise.all(I.map(async ye=>{const Ue=await ye.arrayBuffer(),mt=btoa(new Uint8Array(Ue).reduce((yt,ie)=>yt+String.fromCharCode(ie),""));return{filename:ye.name,content_type:ye.type||"application/octet-stream",data:mt,size:ye.size}})),ae=N.replace(/>\n+</g,"><").replace(/<p class="[^"]*"><\/p>/g,"<br>").trim(),ge={to:w.trim(),cc:j.trim()||void 0,bcc:T.trim()||void 0,subject:M.trim(),html:ae,attachments:$,inReplyTo:n==null?void 0:n.messageId};console.log("[MailComposer] Sending email - to:",ge.to,"subject:",ge.subject,"attachmentsCount:",ge.attachments.length),ge.attachments.length>0&&ge.attachments.forEach((ye,Ue)=>{var mt;console.log(`[MailComposer] Attachment ${Ue+1}:`,ye.filename,"size:",ye.size,"type:",ye.content_type,"data length:",((mt=ye.data)==null?void 0:mt.length)||0)}),await s(ge),D(""),B(""),R(""),C(""),F(""),W([])}catch($){Q($ instanceof Error?$.message:"Failed to send email")}finally{te(!1)}},P={width:"100%",padding:"8px 12px",fontSize:"14px",border:`1px solid ${k.inputBorder}`,borderRadius:"6px",background:k.inputBackground,color:k.text,outline:"none"},me={display:"block",fontSize:"12px",fontWeight:500,color:k.textSecondary,marginBottom:"4px",textTransform:"uppercase"},We=($,ae=!1)=>({padding:"10px 20px",fontSize:"14px",fontWeight:500,border:"none",borderRadius:"6px",cursor:ae?"not-allowed":"pointer",opacity:ae?.6:1,background:$?k.buttonPrimary:k.buttonSecondary,color:$?"#ffffff":k.text,display:"flex",alignItems:"center",gap:"8px"});return h.jsxs("div",{className:g,style:{display:"flex",flexDirection:"column",gap:"16px",padding:"16px",background:k.background},children:[U&&h.jsx("div",{style:{padding:"12px 16px",background:"#fef2f2",border:"1px solid #fecaca",borderRadius:"6px",color:"#dc2626",fontSize:"14px"},children:U}),h.jsxs("div",{children:[h.jsx("label",{style:me,children:"To"}),h.jsx("input",{type:"email",value:w,onChange:$=>D($.target.value),placeholder:"recipient@example.com",disabled:d||z,style:P})]}),!H&&h.jsx("button",{type:"button",onClick:()=>se(!0),disabled:d||z,style:{background:"none",border:"none",padding:0,fontSize:"12px",color:k.primary,cursor:"pointer",textAlign:"left"},children:"+ Add CC/BCC"}),H&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{children:[h.jsx("label",{style:me,children:"CC"}),h.jsx("input",{type:"email",value:j,onChange:$=>B($.target.value),placeholder:"cc@example.com",disabled:d||z,style:P})]}),h.jsxs("div",{children:[h.jsx("label",{style:me,children:"BCC"}),h.jsx("input",{type:"email",value:T,onChange:$=>R($.target.value),placeholder:"bcc@example.com",disabled:d||z,style:P})]})]}),h.jsxs("div",{children:[h.jsx("label",{style:me,children:"Subject"}),h.jsx("input",{type:"text",value:M,onChange:$=>C($.target.value),placeholder:"Email subject",disabled:d||z,style:P})]}),h.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column",minHeight:0},children:h.jsx("div",{style:{flex:1,display:"flex",flexDirection:"column"},children:h.jsx(Hc,{value:N,onChange:De,placeholder:p,replyTo:n,theme:k,disabled:d||z,minHeight:m,externalUpdate:ue?l:void 0,insertText:a,insertTextTrigger:u,onAiRestructure:y,onAiProofread:_,onAiRewrite:S,renderAboveToolbar:E})})}),h.jsxs("div",{children:[h.jsx("label",{style:{...me,marginBottom:"8px"},children:"Attachments"}),h.jsx("input",{ref:xe,type:"file",multiple:!0,onChange:ne,style:{display:"none"}}),h.jsxs("div",{onClick:()=>{var $;return($=xe.current)==null?void 0:$.click()},onDragOver:Be,onDragLeave:Se,onDrop:ke,style:{width:"100%",padding:"24px 16px",border:`2px dashed ${J?k.primary:k.border}`,borderRadius:"8px",background:J?`${k.primary}10`:"transparent",color:J?k.primary:k.textSecondary,cursor:d||z?"not-allowed":"pointer",display:"flex",flexDirection:"column",alignItems:"center",justifyContent:"center",gap:"8px",transition:"all 0.2s",marginBottom:I.length>0?"12px":0},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"24px"},children:J?"file_download":"attach_file"}),h.jsx("span",{style:{fontSize:"14px"},children:J?"Drop files here":"Drop files or click to add"})]}),I.length>0&&h.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:I.map(($,ae)=>h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px",padding:"8px 12px",background:k.attachmentBackground,borderRadius:"8px"},children:[h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:k.textSecondary},children:Ie($)}),h.jsxs("div",{style:{flex:1,minWidth:0},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:k.text,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap"},children:$.name}),h.jsx("div",{style:{fontSize:"12px",color:k.textSecondary},children:$e($.size)})]}),h.jsx("button",{type:"button",onClick:()=>Le(ae),disabled:d||z,style:{background:"none",border:"none",padding:"4px",cursor:"pointer",color:k.textSecondary,display:"flex",borderRadius:"4px"},children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px"},children:"close"})})]},`${$.name}-${ae}`))})]}),h.jsxs("div",{style:{display:"flex",justifyContent:"flex-end",gap:"12px"},children:[!v&&i&&h.jsx("button",{type:"button",onClick:i,disabled:d||z,style:We(!1,d||z),children:"Cancel"}),h.jsxs("button",{type:"button",onClick:Y,disabled:d||z||!w.trim()||!M.trim(),style:We(!0,d||z||!w.trim()||!M.trim()),children:[h.jsx("span",{className:"material-icons",style:{fontSize:"18px",animation:z?"spin 1s linear infinite":"none"},children:z?"sync":"send"}),z?"Sending...":x]})]}),h.jsx("style",{children:`
179
179
  @keyframes spin {
180
180
  from { transform: rotate(0deg); }
181
181
  to { transform: rotate(360deg); }
182
182
  }
183
- `})]})}const Ag={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function Tg({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:f=""}){const p={...Ag,...d},[g,m]=b.useState(!1),[x,_]=b.useState(""),y=b.useRef(null),w=b.useRef(null);b.useEffect(()=>{function N(R){y.current&&!y.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)}),D=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=b.useCallback(N=>{var R;c>0&&e.length>=c||(t([...e,N]),_(""),c===1?m(!1):(R=w.current)==null||R.focus())},[e,t,c]),k=b.useCallback(N=>{t(e.filter(R=>R!==N))},[e,t]),M=b.useCallback(async()=>{if(!D)return;const N=await(i==null?void 0:i(x.trim()));N&&v(N.id),_("")},[D,x,i,v]),T=b.useCallback(N=>{N.key==="Enter"?(N.preventDefault(),D?M():C.length>0&&v(C[0].id)):N.key==="Backspace"&&!x&&e.length>0?k(e[e.length-1]):N.key==="Escape"&&(m(!1),_(""))},[D,C,x,e,M,v,k]);return h.jsxs("div",{ref:y,className:f,style:{position:"relative"},children:[a&&h.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:p.textSecondary,marginBottom:"4px"},children:a}),h.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=>h.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&&h.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),k(N.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},N.id)),h.jsx("input",{ref:w,type:"text",value:x,onChange:N=>{_(N.target.value),g||m(!0)},onFocus:()=>m(!0),onKeyDown:T,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&&h.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&&!D?h.jsx("div",{style:{padding:"12px",fontSize:"14px",color:p.textSecondary,textAlign:"center"},children:x?"No matches":"No options available"}):h.jsxs(h.Fragment,{children:[C.map(N=>h.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&&l&&h.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),l(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)),D&&h.jsxs("div",{onClick:M,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 Ng={background:"#ffffff",cardBackground:"#f9fafb",cardHover:"#f3f4f6",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6"};function Bg({options:r,value:e,type:t,placeholder:n="Search...",onItemClick:s,onClear:i,onCreate:o,maxHeight:l=300,className:a="",theme:u={}}){const c={...Ng,...u},[d,f]=b.useState(""),[p,g]=b.useState(!1),m=b.useRef(null),x=b.useRef(null),_=b.useMemo(()=>e&&r.find(k=>k.id===e)||null,[e,r]),y=b.useMemo(()=>{if(!d.trim())return r;const k=d.toLowerCase();return r.filter(M=>{var T,N;return((T=M.label)==null?void 0:T.toLowerCase().includes(k))||((N=M.notes)==null?void 0:N.toLowerCase().includes(k))})},[r,d]);b.useEffect(()=>{const k=M=>{m.current&&!m.current.contains(M.target)&&g(!1)};return document.addEventListener("mousedown",k),()=>document.removeEventListener("mousedown",k)},[]);const w=k=>{s&&s(k),g(!1),f("")},C=()=>{o&&o(d.trim()||void 0),g(!1),f("")},D=()=>{g(!0)},E=k=>{f(k.target.value),p||g(!0)},v=k=>{k.key==="Enter"?(k.preventDefault(),y.length>0&&s?(s(y[0]),g(!1),f("")):o&&d.trim()&&(o(d.trim()),g(!1),f(""))):k.key==="Escape"&&(g(!1),f(""))};return h.jsxs("div",{ref:m,className:`combostack ${a}`,style:{position:"relative",width:"100%"},children:[h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("div",{style:{flex:1,position:"relative"},children:_&&!p?h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 10px",fontSize:"14px",border:`1px solid ${c.border}`,borderRadius:"6px",background:c.cardBackground,color:c.text,cursor:"pointer",minHeight:"36px",boxSizing:"border-box"},onClick:()=>g(!0),children:[h.jsxs("div",{style:{overflow:"hidden"},children:[h.jsx("div",{style:{fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:_.label}),_.notes&&h.jsx("div",{style:{fontSize:"11px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:_.notes})]}),i&&h.jsx("button",{onClick:k=>{k.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:h.jsx("span",{className:"material-icons",style:{fontSize:"16px"},children:"close"})})]}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons",style:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",color:c.textSecondary,fontSize:"18px",pointerEvents:"none"},children:"search"}),h.jsx("input",{ref:x,type:"text",value:d,onChange:E,onFocus:D,onKeyDown:v,placeholder:n,style:{width:"100%",padding:"8px 12px 8px 36px",fontSize:"14px",border:`1px solid ${p?c.primary:c.border}`,borderRadius:"6px",background:c.background,color:c.text,outline:"none",boxSizing:"border-box",transition:"border-color 0.15s"}})]})}),o&&h.jsx("button",{onClick:C,style:{width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${c.border}`,borderRadius:"6px",background:c.background,color:c.primary,cursor:"pointer",fontSize:"18px",fontWeight:"bold",transition:"background 0.15s",flexShrink:0},onMouseEnter:k=>{k.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:k=>{k.currentTarget.style.background=c.background||"#ffffff"},title:`Create ${t||"item"}`,children:"+"})]}),p&&h.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",maxHeight:typeof l=="number"?`${l}px`:l,overflowY:"auto",border:`1px solid ${c.border}`,borderRadius:"8px",background:c.background,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",zIndex:50},children:y.length===0?h.jsx("div",{style:{padding:"16px",textAlign:"center",color:c.textSecondary,fontSize:"14px"},children:d?`No results for "${d}"`:"No items"}):y.map((k,M)=>h.jsxs("div",{onClick:()=>w(k),style:{padding:"10px 14px",cursor:"pointer",borderBottom:M<y.length-1?`1px solid ${c.border}`:"none",background:c.cardBackground,transition:"background 0.15s"},onMouseEnter:T=>{T.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:T=>{T.currentTarget.style.background=c.cardBackground||"#f9fafb"},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:k.color||c.text,marginBottom:k.notes?"2px":0},children:k.label}),k.notes&&h.jsx("div",{style:{fontSize:"12px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:k.notes})]},k.id))})]})}function Rg({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:f="",itemClassName:p=""}){const[g,m]=b.useState(null),[x,_]=b.useState(null),[y,w]=b.useState(null),C=b.useRef(null),D=e.reduce((R,j)=>{let S=r.filter(B=>n(B)===j.id);return s&&(S=S.sort((B,F)=>s(B)-s(F))),R[j.id]=S,R},{}),E=b.useCallback((R,j)=>{const S=t(j),B=n(j);m(S),C.current=B,R.dataTransfer.effectAllowed="move",R.dataTransfer.setData("text/plain",S),requestAnimationFrame(()=>{const F=R.target;F.style.opacity="0.5"})},[t,n]),v=b.useCallback(R=>{const j=R.target;j.style.opacity="1",m(null),_(null),w(null),C.current=null},[]),k=b.useCallback((R,j,S)=>{R.preventDefault(),R.dataTransfer.dropEffect="move",_(j),w(S)},[]),M=b.useCallback(R=>{const j=R.relatedTarget;j!=null&&j.closest("[data-kanban-column]")||(_(null),w(null))},[]),T=b.useCallback((R,j,S)=>{if(R.preventDefault(),!g)return;const B=C.current;B===j?l==null||l(g,j,S):B&&o(g,B,j,S),m(null),_(null),w(null),C.current=null},[g,o,l]),N=(R,j)=>h.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[R.color&&h.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:R.color}}),h.jsx("span",{className:"font-medium text-sm text-neutral-700",children:R.label})]}),h.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:j})]});return h.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${d}`,style:{minHeight:"400px"},children:e.map(R=>{const j=D[R.id]||[],S=x===R.id;return h.jsxs("div",{"data-kanban-column":R.id,className:`flex-1 min-w-[180px] bg-neutral-50 rounded-xl flex flex-col ${f}`,onDragOver:B=>{B.preventDefault(),g&&!S&&_(R.id)},onDragLeave:M,onDrop:B=>T(B,R.id,y??j.length),children:[h.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(R,j.length):N(R,j.length)}),h.jsxs("div",{className:`flex-1 overflow-y-auto p-2 space-y-2 min-h-[100px] transition-colors ${S?"bg-blue-50":""}`,children:[j.map((B,F)=>{const O=t(B),V=g===O,U=S&&y===F&&!V;return h.jsxs("div",{children:[U&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),h.jsx("div",{draggable:!0,onDragStart:te=>E(te,B),onDragEnd:v,onDragOver:te=>k(te,R.id,F),onClick:()=>a==null?void 0:a(B),className:`cursor-grab active:cursor-grabbing transition-all ${V?"opacity-50 scale-95":""} ${p}`,children:i(B,V)})]},O)}),h.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:B=>{B.preventDefault(),k(B,R.id,j.length)},children:S&&y===j.length&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),j.length===0&&S&&h.jsx("div",{className:"h-20 border-2 border-dashed border-blue-300 rounded-lg bg-blue-50/50 flex items-center justify-center",children:h.jsx("span",{className:"text-sm text-blue-400",children:"Drop here"})})]}),c&&h.jsx("div",{className:"flex-shrink-0 border-t border-neutral-200 p-2",children:c(R)})]},R.id)})})}const Mg={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function Fg(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function jg(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function Lg(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function Pg({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:f=!0,className:p="",theme:g={}}){const m={...Mg,...g},{allDayItems:x,timedItems:_}=b.useMemo(()=>{const v=[],k=[];for(const M of r)l(M)?v.push(M):k.push(M);return{allDayItems:v,timedItems:k}},[r,l]),y=b.useMemo(()=>{const v=[];for(let k=t;k<=n;k++)v.push(k);return v},[t,n]),w=(n-t+1)*s,C=b.useCallback(v=>{const k=i(v);if(!k)return null;const M=Fg(k);if(!M)return null;const{hours:T,minutes:N}=M,R=Math.max(t,Math.min(n,T)),j=T<t?0:N,S=(R-t)*s+j/60*s,B=o(v),F=Math.max(20,B/60*s);return{top:S,height:F}},[i,o,t,n,s]),D=b.useMemo(()=>{if(!f||!Lg(e))return null;const v=new Date,k=v.getHours(),M=v.getMinutes();return k<t||k>n?null:(k-t)*s+M/60*s},[e,f,t,n,s]),E=b.useCallback(v=>{if(!d)return;const k=v.currentTarget.getBoundingClientRect(),T=(v.clientY-k.top)/s*60,N=Math.floor(T/60)+t,R=Math.round(T%60/15)*15,j=Math.min(n,Math.max(t,N)),S=R>=60?0:R,B=`${j.toString().padStart(2,"0")}:${S.toString().padStart(2,"0")}`;d(B)},[d,s,t,n]);return h.jsxs("div",{className:p,style:{background:m.background},children:[x.length>0&&h.jsxs("div",{style:{padding:"8px 0 8px 60px",borderBottom:`1px solid ${m.allDayBorder}`,background:m.allDayBackground},children:[h.jsx("div",{style:{fontSize:"11px",color:m.hourTextColor,marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"All Day"}),h.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:x.map(v=>h.jsx("div",{onClick:()=>c==null?void 0:c(v),style:{cursor:c?"pointer":"default"},children:u(v)},a(v)))})]}),h.jsxs("div",{style:{position:"relative",height:w},children:[y.map((v,k)=>h.jsxs("div",{style:{position:"absolute",top:k*s,left:0,right:0},children:[h.jsx("div",{style:{position:"absolute",left:0,top:-8,width:"50px",textAlign:"right",paddingRight:"10px",fontSize:"11px",color:m.hourTextColor},children:jg(v)}),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),k<y.length-1&&h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:s/2,height:"1px",background:m.halfHourLineColor}})]},v)),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:d?"pointer":"default"},onClick:E}),D!==null&&h.jsxs("div",{style:{position:"absolute",left:"55px",right:0,top:D,zIndex:20,pointerEvents:"none"},children:[h.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",background:m.currentTimeColor,marginLeft:"-5px",marginTop:"-5px",position:"absolute"}}),h.jsx("div",{style:{marginLeft:"5px",height:"2px",background:m.currentTimeColor}})]}),_.map(v=>{const k=C(v);return k?h.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:k.top,height:k.height,zIndex:10,cursor:c?"pointer":"default"},onClick:M=>{M.stopPropagation(),c==null||c(v)},children:u(v)},a(v)):null})]})]})}function Vc({onComplete:r,onCancel:e,onTranscribe:t,onTranscriptionComplete:n,variant:s="widget",hideSaveButton:i=!1,maxDuration:o=180}){const l=s==="widget",[a,u]=b.useState("idle"),[c,d]=b.useState(0),[f,p]=b.useState(0),[g,m]=b.useState(!1),[x,_]=b.useState(0),[y,w]=b.useState(null),[C,D]=b.useState(!1),[E,v]=b.useState(null),[k,M]=b.useState(!0),[T,N]=b.useState([]),[R,j]=b.useState({completed:0,total:0}),S=b.useRef(!1),B=b.useRef(!0);b.useEffect(()=>{B.current=k},[k]);const F=b.useRef(null),O=b.useRef(null),V=b.useRef(null),U=b.useRef(null),te=b.useRef(null),q=b.useRef([]),X=b.useRef(null),W=b.useRef(null),se=b.useRef(null),ue=b.useRef(null),de=b.useRef(!1),pe=b.useRef([]),De=b.useRef(null),xe=b.useRef(null),J=b.useRef([]),Ce=b.useRef([]),ne=b.useRef("insert"),Be=b.useRef(!1),Se=b.useRef(0),ke=b.useRef(0),Ie=b.useRef(0),Le=Z=>{const L=Math.floor(Z/60),le=Math.floor(Z%60);return`${L.toString().padStart(2,"0")}:${le.toString().padStart(2,"0")}`},$e=async Z=>{const L=await Z.arrayBuffer(),le=new AudioContext,fe=await le.decodeAudioData(L);return await le.close(),fe},Y=Z=>{const L=Z.numberOfChannels,le=Z.sampleRate,fe=1,G=16,we=G/8,be=L*we,ve=le*be,Fe=Z.length*be,qe=new ArrayBuffer(44+Fe),_e=new DataView(qe),Ee=(Ve,Oe)=>{for(let ut=0;ut<Oe.length;ut++)_e.setUint8(Ve+ut,Oe.charCodeAt(ut))};Ee(0,"RIFF"),_e.setUint32(4,36+Fe,!0),Ee(8,"WAVE"),Ee(12,"fmt "),_e.setUint32(16,16,!0),_e.setUint16(20,fe,!0),_e.setUint16(22,L,!0),_e.setUint32(24,le,!0),_e.setUint32(28,ve,!0),_e.setUint16(32,be,!0),_e.setUint16(34,G,!0),Ee(36,"data"),_e.setUint32(40,Fe,!0);const et=[];for(let Ve=0;Ve<L;Ve++)et.push(Z.getChannelData(Ve));let nt=44;for(let Ve=0;Ve<Z.length;Ve++)for(let Oe=0;Oe<L;Oe++){const ut=Math.max(-1,Math.min(1,et[Oe][Ve])),ct=ut<0?ut*32768:ut*32767;_e.setInt16(nt,ct,!0),nt+=2}return new Blob([qe],{type:"audio/wav"})},P=async(Z,L,le,fe)=>{const G=new AudioContext,we=Z.sampleRate,be=Math.max(Z.numberOfChannels,L.numberOfChannels),ve=Math.min(le,Z.length),Fe=Math.max(0,Z.length-le),qe=fe==="insert"?ve+L.length+Fe:ve+L.length,_e=G.createBuffer(be,qe,we);for(let Ee=0;Ee<be;Ee++){const et=_e.getChannelData(Ee),nt=Ee<Z.numberOfChannels?Z.getChannelData(Ee):Z.getChannelData(0);for(let Oe=0;Oe<ve;Oe++)et[Oe]=nt[Oe];const Ve=Ee<L.numberOfChannels?L.getChannelData(Ee):L.getChannelData(0);for(let Oe=0;Oe<L.length;Oe++)et[ve+Oe]=Ve[Oe];if(fe==="insert")for(let Oe=0;Oe<Fe;Oe++)et[ve+L.length+Oe]=nt[le+Oe]}return await G.close(),_e},me=b.useCallback(()=>{const Z=F.current;if(!Z)return;const L=Z.getContext("2d");if(!L)return;const le=Z.getBoundingClientRect(),fe=le.width,G=le.height,we=pe.current,be=f||c||1,ve=a==="recording"?c:x;L.fillStyle="#2d3b35",L.fillRect(0,0,fe,G);const Fe=8,qe="rgba(0, 0, 0, 0.4)",_e=L.createLinearGradient(0,0,0,Fe);_e.addColorStop(0,qe),_e.addColorStop(1,"transparent"),L.fillStyle=_e,L.fillRect(0,0,fe,Fe);const Ee=L.createLinearGradient(0,G-Fe,0,G);Ee.addColorStop(0,"transparent"),Ee.addColorStop(1,qe),L.fillStyle=Ee,L.fillRect(0,G-Fe,fe,Fe);const et=L.createLinearGradient(0,0,Fe,0);et.addColorStop(0,qe),et.addColorStop(1,"transparent"),L.fillStyle=et,L.fillRect(0,0,Fe,G);const nt=L.createLinearGradient(fe-Fe,0,fe,0);nt.addColorStop(0,"transparent"),nt.addColorStop(1,qe),L.fillStyle=nt,L.fillRect(fe-Fe,0,Fe,G),L.strokeStyle="#5a6b62",L.lineWidth=1,L.beginPath(),L.moveTo(0,G/2),L.lineTo(fe,G/2),L.stroke();const Ve=fe/2;if(we.length>0)if(a==="recording")for(let ct=0;ct<we.length;ct++){const At=we.length-1-ct,Zt=Ve-At*4;if(Zt<-3||Zt>fe)continue;const Rt=we[ct]*(G/2-12),A=G/2-Rt;L.fillStyle="#10b981",L.fillRect(Zt,A,3,Rt*2)}else{const ct=be>0?ve/be*we.length:0;for(let At=0;At<we.length;At++){const Zt=ct-At,Rt=Ve-Zt*4;if(Rt<-3||Rt>fe)continue;const A=we[At]*(G/2-12),$=G/2-A;L.fillStyle=At<=ct?"#10b981":"#4b5563",L.fillRect(Rt,$,3,A*2)}}L.strokeStyle="#ef4444",L.lineWidth=1,L.beginPath(),L.moveTo(Ve,0),L.lineTo(Ve,G),L.stroke(),L.fillStyle="#fff",L.font="bold 18px monospace",L.textAlign="center",L.fillText(Le(ve),Ve,G-6),a==="recording"&&(L.fillStyle="#ef4444",L.beginPath(),L.arc(20,20,8,0,Math.PI*2),L.fill(),L.fillStyle="#fff",L.font="10px sans-serif",L.textAlign="left",L.fillText("REC",34,24)),L.textAlign="left"},[a,x,c,f]),We=()=>{const Z=te.current;if(!Z||!de.current)return;const L=Z.frequencyBinCount,le=new Uint8Array(L);Z.getByteTimeDomainData(le);let fe=0;for(let be=0;be<L;be++){const ve=(le[be]-128)/128;fe+=ve*ve}const G=Math.sqrt(fe/L),we=Math.min(1,G*3);pe.current.push(we),me(),de.current&&(W.current=requestAnimationFrame(We))},z=async()=>{try{w(null),D(!1),De.current===null&&(pe.current=[]);const Z=await navigator.mediaDevices.getUserMedia({audio:!0});V.current=Z;const L=new AudioContext;U.current=L;const le=L.createAnalyser();le.fftSize=2048,te.current=le,L.createMediaStreamSource(Z).connect(le);const G=new MediaRecorder(Z);O.current=G,q.current=[],G.ondataavailable=we=>{we.data.size>0&&q.current.push(we.data)},G.onstop=async()=>{try{if(de.current=!1,q.current.length===0){w("No audio was recorded. Please try again."),u("idle"),Z.getTracks().forEach(_e=>_e.stop());return}const we=new Blob(q.current,{type:"audio/webm"});let be,ve;if(De.current!==null&&xe.current)try{const _e=await $e(we),Ee=xe.current.sampleRate,et=Math.floor(De.current*Ee),nt=await P(xe.current,_e,et,ne.current);be=Y(nt),ve=nt.length/nt.sampleRate,ne.current==="insert"&&(pe.current=[...pe.current,...Ce.current]),De.current=null,xe.current=null,J.current=[],Ce.current=[]}catch{be=we,ve=Se.current>0?Se.current:1}else be=we,ve=Se.current>0?Se.current:1;if(ue.current=be,Z.getTracks().forEach(_e=>_e.stop()),B.current&&t){N(_e=>[..._e,be]),j(_e=>({..._e,total:_e.total+1})),ue.current=null,pe.current=[],_(0),p(0),d(0),u("idle");return}const Fe=URL.createObjectURL(be),qe=new Audio(Fe);qe.ontimeupdate=()=>{_(qe.currentTime)},qe.onended=()=>{m(!1)},se.current=qe,p(ve),_(ve),u("editing")}catch{w("Failed to process recording"),u("idle")}},G.start(100),de.current=!0,u("recording"),d(0),Se.current=0,X.current=setInterval(()=>{Se.current+=1,d(Se.current),Se.current>=o&&(O.current&&O.current.state!=="inactive"&&O.current.stop(),de.current=!1,v(null),X.current&&(clearInterval(X.current),X.current=null),W.current&&(cancelAnimationFrame(W.current),W.current=null),setTimeout(()=>{alert(`Maximum recording time of ${Math.floor(o/60)} minutes reached.`)},100))},1e3)}catch{w("Could not access microphone. Please allow microphone access.")}},ae=()=>{de.current=!1,D(!1),v(null),W.current&&(cancelAnimationFrame(W.current),W.current=null),X.current&&(clearInterval(X.current),X.current=null),O.current&&O.current.state!=="inactive"&&O.current.stop()},ge=Z=>{const L=F.current;if(!L)return;const le=f||c;if(le<=0)return;const fe=pe.current;if(fe.length===0)return;const G=L.getBoundingClientRect(),we=Z-ke.current,be=4,ve=G.width/L.width,Fe=fe.length/le*be,qe=-we/(Fe*ve),_e=Ie.current+qe,Ee=Math.max(0,Math.min(_e,le));se.current&&(se.current.currentTime=Ee),_(Ee)},ye=()=>{se.current&&(se.current.currentTime=0),_(0)},Ue=()=>{const Z=f||c;se.current&&(se.current.currentTime=Z),_(Z)},mt=()=>{const Z=se.current;Z&&(g?(Z.pause(),_(Z.currentTime),m(!1)):(Z.currentTime=x,Z.play().catch(()=>{}),m(!0)))},yt=async Z=>{if(!ue.current){z();return}try{se.current&&(se.current.pause(),m(!1)),ne.current=Z,xe.current=await $e(ue.current);const L=f||c;De.current=x;const le=L>0?x/L:0,fe=Math.floor(le*pe.current.length);J.current=pe.current.slice(0,fe),Ce.current=pe.current.slice(fe),pe.current=[...J.current],z()}catch{w("Failed to prepare recording. Please try again.")}},ie=()=>{se.current&&(se.current.pause(),se.current=null),ue.current=null,xe.current=null,De.current=null,J.current=[],m(!1),_(0),p(0),d(0),z()},ce=()=>{ue.current?r(ue.current,f||c):alert("No audio recorded yet!")};b.useEffect(()=>{a==="recording"&&F.current&&te.current&&de.current&&(W.current=requestAnimationFrame(We))},[a]),b.useEffect(()=>{const Z=F.current;if(!Z)return;const L=()=>{const le=window.devicePixelRatio||1,fe=Z.getBoundingClientRect();Z.width=fe.width*le,Z.height=fe.height*le;const G=Z.getContext("2d");G&&G.scale(le,le)};return L(),window.addEventListener("resize",L),()=>window.removeEventListener("resize",L)},[]),b.useEffect(()=>{if(a==="idle"){const Z=F.current;if(!Z)return;const L=Z.getContext("2d");if(!L)return;const le=Z.getBoundingClientRect(),fe=le.width,G=le.height;L.fillStyle="#2d3b35",L.fillRect(0,0,fe,G);const we=8,be="rgba(0, 0, 0, 0.4)",ve=L.createLinearGradient(0,0,0,we);ve.addColorStop(0,be),ve.addColorStop(1,"transparent"),L.fillStyle=ve,L.fillRect(0,0,fe,we);const Fe=L.createLinearGradient(0,G-we,0,G);Fe.addColorStop(0,"transparent"),Fe.addColorStop(1,be),L.fillStyle=Fe,L.fillRect(0,G-we,fe,we);const qe=L.createLinearGradient(0,0,we,0);qe.addColorStop(0,be),qe.addColorStop(1,"transparent"),L.fillStyle=qe,L.fillRect(0,0,we,G);const _e=L.createLinearGradient(fe-we,0,fe,0);_e.addColorStop(0,"transparent"),_e.addColorStop(1,be),L.fillStyle=_e,L.fillRect(fe-we,0,we,G),L.strokeStyle="#5a6b62",L.lineWidth=1,L.beginPath(),L.moveTo(0,G/2),L.lineTo(fe,G/2),L.stroke();const Ee=fe/2;L.strokeStyle="#ef4444",L.lineWidth=1,L.beginPath(),L.moveTo(Ee,0),L.lineTo(Ee,G),L.stroke(),L.fillStyle="#fff",L.font="bold 18px monospace",L.textAlign="center",L.fillText("00:00",Ee,G-6)}},[a]);const He=b.useCallback(Z=>{N(L=>[...L,Z]),j(L=>({...L,total:L.total+1}))},[]);if(b.useEffect(()=>{(async()=>{if(S.current||T.length===0||!t)return;S.current=!0;const L=T[0];try{const le=await t(L);le&&n&&n(le)}catch(le){console.error("Transcription failed:",le)}finally{N(le=>le.slice(1)),j(le=>({...le,completed:le.completed+1})),S.current=!1}})()},[T,t,n]),b.useEffect(()=>()=>{de.current=!1,X.current&&clearInterval(X.current),W.current&&cancelAnimationFrame(W.current),V.current&&V.current.getTracks().forEach(Z=>Z.stop()),U.current&&U.current.state!=="closed"&&U.current.close()},[]),b.useEffect(()=>{if(a==="editing"&&g){let Z;const L=()=>{const le=se.current;if(le&&g){const fe=F.current;if(fe){const G=fe.getContext("2d");if(G){const we=fe.getBoundingClientRect(),be=we.width,ve=we.height,Fe=pe.current,qe=f||c||1,_e=le.currentTime;G.fillStyle="#2d3b35",G.fillRect(0,0,be,ve);const Ee=8,et="rgba(0, 0, 0, 0.4)",nt=G.createLinearGradient(0,0,0,Ee);nt.addColorStop(0,et),nt.addColorStop(1,"transparent"),G.fillStyle=nt,G.fillRect(0,0,be,Ee);const Ve=G.createLinearGradient(0,ve-Ee,0,ve);Ve.addColorStop(0,"transparent"),Ve.addColorStop(1,et),G.fillStyle=Ve,G.fillRect(0,ve-Ee,be,Ee);const Oe=G.createLinearGradient(0,0,Ee,0);Oe.addColorStop(0,et),Oe.addColorStop(1,"transparent"),G.fillStyle=Oe,G.fillRect(0,0,Ee,ve);const ut=G.createLinearGradient(be-Ee,0,be,0);ut.addColorStop(0,"transparent"),ut.addColorStop(1,et),G.fillStyle=ut,G.fillRect(be-Ee,0,Ee,ve),G.strokeStyle="#5a6b62",G.lineWidth=1,G.beginPath(),G.moveTo(0,ve/2),G.lineTo(be,ve/2),G.stroke();const ct=be/2,At=3,Zt=4,Rt=qe>0?_e/qe*Fe.length:0;for(let ee=0;ee<Fe.length;ee++){const he=Rt-ee,Re=ct-he*Zt;if(Re<-At||Re>be)continue;const Pe=Fe[ee]*(ve/2-12),Te=ve/2-Pe;G.fillStyle=ee<=Rt?"#10b981":"#4b5563",G.fillRect(Re,Te,At,Pe*2)}G.strokeStyle="#ef4444",G.lineWidth=1,G.beginPath(),G.moveTo(ct,0),G.lineTo(ct,ve),G.stroke(),G.fillStyle="#fff",G.font="bold 18px monospace",G.textAlign="center";const A=Math.floor(_e/60),$=Math.floor(_e%60);G.fillText(`${A.toString().padStart(2,"0")}:${$.toString().padStart(2,"0")}`,ct,ve-6),G.textAlign="left"}}Z=requestAnimationFrame(L)}};return Z=requestAnimationFrame(L),()=>cancelAnimationFrame(Z)}},[a,g,f,c]),b.useEffect(()=>{a==="editing"&&!g&&me()},[a,x,g,me]),y)return h.jsxs("div",{style:{border:"1px solid #fecaca",borderRadius:"12px",padding:"16px",background:"#fef2f2"},children:[h.jsx("p",{style:{fontSize:"14px",color:"#dc2626",marginBottom:"12px"},children:y}),h.jsx("button",{onClick:()=>{w(null),z()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const Xe={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},Je={...Xe,opacity:.3,cursor:"not-allowed"},Bt=l?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",flexShrink:0};return h.jsxs("div",{style:Bt,children:[h.jsx("canvas",{ref:F,style:{width:"100%",height:"32px",cursor:"pointer",flexShrink:0},onMouseDown:Z=>{if(a==="editing"){Be.current=!0,ke.current=Z.clientX,Ie.current=x;const L=fe=>{Be.current&&ge(fe.clientX)},le=()=>{Be.current=!1,window.removeEventListener("mousemove",L),window.removeEventListener("mouseup",le)};window.addEventListener("mousemove",L),window.addEventListener("mouseup",le)}}}),h.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:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[h.jsx("button",{onClick:ye,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?Je:Xe,title:"Go to start",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"first_page"})}),h.jsx("button",{onClick:()=>{if(a==="recording"){const Z=O.current;Z&&(Z.state==="recording"?(Z.pause(),D(!0)):Z.state==="paused"&&(Z.resume(),D(!1)))}else mt()},disabled:a==="idle",style:a==="idle"?Je:Xe,title:g||a==="recording"&&!C?"Pause":"Play",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:g||a==="recording"&&!C?"pause":"play_arrow"})}),h.jsx("button",{onClick:Ue,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?Je:Xe,title:"Go to end",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"last_page"})}),h.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))"}}),h.jsx("button",{onClick:()=>{E==="insert"?ae():a==="idle"?(v("insert"),z()):a==="editing"&&(v("insert"),yt("insert"))},disabled:a==="recording"&&E!=="insert"||g,style:a==="recording"&&E!=="insert"||g?Je:Xe,title:E==="insert"?"Stop recording":"Insert recording",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E==="insert"?"#ef4444":"#171717"},children:"add"})}),h.jsx("button",{onClick:()=>{B.current||(E==="mic"?ae():a==="idle"?(v("mic"),z()):a==="editing"&&(v("mic"),yt("replace")))},onMouseDown:()=>{B.current&&a==="idle"&&!g&&(v("mic"),z())},onMouseUp:()=>{B.current&&a==="recording"&&E==="mic"&&ae()},onMouseLeave:()=>{B.current&&a==="recording"&&E==="mic"&&ae()},onTouchStart:()=>{B.current&&a==="idle"&&!g&&(v("mic"),z())},onTouchEnd:()=>{B.current&&a==="recording"&&E==="mic"&&ae()},disabled:a==="recording"&&E!=="mic"||g,style:a==="recording"&&E!=="mic"||g?Je:Xe,title:k?"Hold to record (walkie-talkie)":E==="mic"?"Stop recording":"Record",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E==="mic"?"#ef4444":"#171717"},children:"mic"})}),h.jsx("button",{onClick:()=>{E==="startover"?ae():a==="editing"&&(v("startover"),ie())},disabled:a==="idle"||a==="recording"&&E!=="startover"||g,style:a==="idle"||a==="recording"&&E!=="startover"||g?Je:Xe,title:E==="startover"?"Stop recording":"Start over",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:E==="startover"?"#ef4444":"#171717"},children:"refresh"})})]}),h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[R.total>0&&R.completed<R.total&&h.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:[h.jsx("span",{className:"material-icons",style:{fontSize:"14px",animation:"spin 1s linear infinite"},children:"sync"}),R.completed,"/",R.total]}),t&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginRight:"4px"},children:[h.jsx("button",{onClick:()=>M(!k),style:{width:"28px",height:"16px",borderRadius:"8px",border:"none",background:k?"#10b981":"#9ca3af",cursor:"pointer",position:"relative",transition:"background 0.2s",padding:0},title:k?"Auto-transcribe ON":"Auto-transcribe OFF",children:h.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"50%",background:"white",position:"absolute",top:"2px",left:k?"14px":"2px",transition:"left 0.2s",boxShadow:"0 1px 2px rgba(0,0,0,0.2)"}})}),h.jsx("span",{style:{fontSize:"10px",color:"#666"},children:"auto"})]}),h.jsx("button",{onClick:()=>{a==="editing"&&ue.current&&He(ue.current)},disabled:a!=="editing",style:a!=="editing"?Je:Xe,title:"Transcribe audio",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:k?"#10b981":"#171717"},children:"subtitles"})})]}),!i&&h.jsx("button",{onClick:ce,disabled:a!=="editing",style:a!=="editing"?Je:Xe,title:"Save recording",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"save"})})]})]}),R.total>0&&R.completed<R.total&&h.jsx("div",{style:{height:"3px",background:"#e5e5e5",overflow:"hidden"},children:h.jsx("div",{style:{height:"100%",background:"#10b981",width:`${R.completed/R.total*100}%`,transition:"width 0.3s ease"}})})]})}function Ig({label:r,value:e,onChange:t,onTranscribe:n,onAIAction:s,placeholder:i="Type or record...",className:o="",rows:l}){const[a,u]=b.useState(!1),[c,d]=b.useState(null),[f,p]=b.useState(!1),g=b.useRef(null),m=y=>{t(e?`${e}
183
+ `})]})}const Ag={background:"#ffffff",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6",chipBackground:"#f3f4f6",chipText:"#374151",hoverBackground:"#f9fafb"};function Tg({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:f=""}){const p={...Ag,...d},[g,m]=b.useState(!1),[x,v]=b.useState(""),y=b.useRef(null),_=b.useRef(null);b.useEffect(()=>{function T(R){y.current&&!y.current.contains(R.target)&&(m(!1),v(""))}return document.addEventListener("mousedown",T),()=>document.removeEventListener("mousedown",T)},[]);const S=r.filter(T=>{var R;return((R=T.label)==null?void 0:R.toLowerCase().includes(x.toLowerCase()))&&!e.includes(T.id)}),E=s&&x.trim()&&!r.some(T=>{var R;return((R=T.label)==null?void 0:R.toLowerCase())===x.toLowerCase()}),k=e.map(T=>r.find(R=>R.id===T)).filter(Boolean),w=b.useCallback(T=>{var R;c>0&&e.length>=c||(t([...e,T]),v(""),c===1?m(!1):(R=_.current)==null||R.focus())},[e,t,c]),D=b.useCallback(T=>{t(e.filter(R=>R!==T))},[e,t]),j=b.useCallback(async()=>{if(!E)return;const T=await(i==null?void 0:i(x.trim()));T&&w(T.id),v("")},[E,x,i,w]),B=b.useCallback(T=>{T.key==="Enter"?(T.preventDefault(),E?j():S.length>0&&w(S[0].id)):T.key==="Backspace"&&!x&&e.length>0?D(e[e.length-1]):T.key==="Escape"&&(m(!1),v(""))},[E,S,x,e,j,w,D]);return h.jsxs("div",{ref:y,className:f,style:{position:"relative"},children:[a&&h.jsx("label",{style:{display:"block",fontSize:"12px",textTransform:"uppercase",color:p.textSecondary,marginBottom:"4px"},children:a}),h.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:[k.map(T=>h.jsxs("span",{style:{display:"inline-flex",alignItems:"center",gap:"4px",padding:"2px 8px",borderRadius:"4px",fontSize:"13px",background:T.color||p.chipBackground,color:T.color?"#fff":p.chipText},children:[T.label,!u&&h.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),D(T.id)},style:{border:"none",background:"transparent",cursor:"pointer",padding:"0 2px",fontSize:"14px",color:"inherit",opacity:.7},children:"×"})]},T.id)),h.jsx("input",{ref:_,type:"text",value:x,onChange:T=>{v(T.target.value),g||m(!0)},onFocus:()=>m(!0),onKeyDown:B,placeholder:k.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&&h.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&&!E?h.jsx("div",{style:{padding:"12px",fontSize:"14px",color:p.textSecondary,textAlign:"center"},children:x?"No matches":"No options available"}):h.jsxs(h.Fragment,{children:[S.map(T=>h.jsxs("div",{onClick:()=>w(T.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:[T.label,o&&l&&h.jsx("button",{type:"button",onClick:R=>{R.stopPropagation(),l(T.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:"×"})]},T.id)),E&&h.jsxs("div",{onClick:j,style:{padding:"10px 12px",fontSize:"14px",cursor:"pointer",color:p.primary,borderTop:S.length>0?`1px solid ${p.border}`:"none"},onMouseEnter:T=>{T.currentTarget.style.background=p.hoverBackground||""},onMouseLeave:T=>{T.currentTarget.style.background=""},children:['+ Create "',x.trim(),'"']})]})})]})}const Ng={background:"#ffffff",cardBackground:"#f9fafb",cardHover:"#f3f4f6",text:"#111827",textSecondary:"#6b7280",border:"#e5e7eb",primary:"#3b82f6"};function Bg({options:r,value:e,type:t,placeholder:n="Search...",onItemClick:s,onClear:i,onCreate:o,maxHeight:l=300,className:a="",theme:u={}}){const c={...Ng,...u},[d,f]=b.useState(""),[p,g]=b.useState(!1),m=b.useRef(null),x=b.useRef(null),v=b.useMemo(()=>e&&r.find(D=>D.id===e)||null,[e,r]),y=b.useMemo(()=>{if(!d.trim())return r;const D=d.toLowerCase();return r.filter(j=>{var B,T;return((B=j.label)==null?void 0:B.toLowerCase().includes(D))||((T=j.notes)==null?void 0:T.toLowerCase().includes(D))})},[r,d]);b.useEffect(()=>{const D=j=>{m.current&&!m.current.contains(j.target)&&g(!1)};return document.addEventListener("mousedown",D),()=>document.removeEventListener("mousedown",D)},[]);const _=D=>{s&&s(D),g(!1),f("")},S=()=>{o&&o(d.trim()||void 0),g(!1),f("")},E=()=>{g(!0)},k=D=>{f(D.target.value),p||g(!0)},w=D=>{D.key==="Enter"?(D.preventDefault(),y.length>0&&s?(s(y[0]),g(!1),f("")):o&&d.trim()&&(o(d.trim()),g(!1),f(""))):D.key==="Escape"&&(g(!1),f(""))};return h.jsxs("div",{ref:m,className:`combostack ${a}`,style:{position:"relative",width:"100%"},children:[h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("div",{style:{flex:1,position:"relative"},children:v&&!p?h.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-between",padding:"6px 10px",fontSize:"14px",border:`1px solid ${c.border}`,borderRadius:"6px",background:c.cardBackground,color:c.text,cursor:"pointer",minHeight:"36px",boxSizing:"border-box"},onClick:()=>g(!0),children:[h.jsxs("div",{style:{overflow:"hidden"},children:[h.jsx("div",{style:{fontWeight:500,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.label}),v.notes&&h.jsx("div",{style:{fontSize:"11px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:v.notes})]}),i&&h.jsx("button",{onClick:D=>{D.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:h.jsx("span",{className:"material-icons",style:{fontSize:"16px"},children:"close"})})]}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons",style:{position:"absolute",left:"10px",top:"50%",transform:"translateY(-50%)",color:c.textSecondary,fontSize:"18px",pointerEvents:"none"},children:"search"}),h.jsx("input",{ref:x,type:"text",value:d,onChange:k,onFocus:E,onKeyDown:w,placeholder:n,style:{width:"100%",padding:"8px 12px 8px 36px",fontSize:"14px",border:`1px solid ${p?c.primary:c.border}`,borderRadius:"6px",background:c.background,color:c.text,outline:"none",boxSizing:"border-box",transition:"border-color 0.15s"}})]})}),o&&h.jsx("button",{onClick:S,style:{width:"36px",height:"36px",display:"flex",alignItems:"center",justifyContent:"center",border:`1px solid ${c.border}`,borderRadius:"6px",background:c.background,color:c.primary,cursor:"pointer",fontSize:"18px",fontWeight:"bold",transition:"background 0.15s",flexShrink:0},onMouseEnter:D=>{D.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:D=>{D.currentTarget.style.background=c.background||"#ffffff"},title:`Create ${t||"item"}`,children:"+"})]}),p&&h.jsx("div",{style:{position:"absolute",top:"100%",left:0,right:0,marginTop:"4px",maxHeight:typeof l=="number"?`${l}px`:l,overflowY:"auto",border:`1px solid ${c.border}`,borderRadius:"8px",background:c.background,boxShadow:"0 4px 12px rgba(0, 0, 0, 0.15)",zIndex:50},children:y.length===0?h.jsx("div",{style:{padding:"16px",textAlign:"center",color:c.textSecondary,fontSize:"14px"},children:d?`No results for "${d}"`:"No items"}):y.map((D,j)=>h.jsxs("div",{onClick:()=>_(D),style:{padding:"10px 14px",cursor:"pointer",borderBottom:j<y.length-1?`1px solid ${c.border}`:"none",background:c.cardBackground,transition:"background 0.15s"},onMouseEnter:B=>{B.currentTarget.style.background=c.cardHover||"#f3f4f6"},onMouseLeave:B=>{B.currentTarget.style.background=c.cardBackground||"#f9fafb"},children:[h.jsx("div",{style:{fontSize:"14px",fontWeight:500,color:D.color||c.text,marginBottom:D.notes?"2px":0},children:D.label}),D.notes&&h.jsx("div",{style:{fontSize:"12px",color:c.textSecondary,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:D.notes})]},D.id))})]})}function Rg({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:f="",itemClassName:p=""}){const[g,m]=b.useState(null),[x,v]=b.useState(null),[y,_]=b.useState(null),S=b.useRef(null),E=e.reduce((R,M)=>{let C=r.filter(N=>n(N)===M.id);return s&&(C=C.sort((N,F)=>s(N)-s(F))),R[M.id]=C,R},{}),k=b.useCallback((R,M)=>{const C=t(M),N=n(M);m(C),S.current=N,R.dataTransfer.effectAllowed="move",R.dataTransfer.setData("text/plain",C),requestAnimationFrame(()=>{const F=R.target;F.style.opacity="0.5"})},[t,n]),w=b.useCallback(R=>{const M=R.target;M.style.opacity="1",m(null),v(null),_(null),S.current=null},[]),D=b.useCallback((R,M,C)=>{R.preventDefault(),R.dataTransfer.dropEffect="move",v(M),_(C)},[]),j=b.useCallback(R=>{const M=R.relatedTarget;M!=null&&M.closest("[data-kanban-column]")||(v(null),_(null))},[]),B=b.useCallback((R,M,C)=>{if(R.preventDefault(),!g)return;const N=S.current;N===M?l==null||l(g,M,C):N&&o(g,N,M,C),m(null),v(null),_(null),S.current=null},[g,o,l]),T=(R,M)=>h.jsxs("div",{className:"flex items-center justify-between px-3 py-2",children:[h.jsxs("div",{className:"flex items-center gap-2",children:[R.color&&h.jsx("div",{className:"w-2 h-2 rounded-full",style:{backgroundColor:R.color}}),h.jsx("span",{className:"font-medium text-sm text-neutral-700",children:R.label})]}),h.jsx("span",{className:"text-xs text-neutral-400 bg-neutral-100 px-2 py-0.5 rounded-full",children:M})]});return h.jsx("div",{className:`flex gap-4 overflow-x-auto pb-4 ${d}`,style:{minHeight:"400px"},children:e.map(R=>{const M=E[R.id]||[],C=x===R.id;return h.jsxs("div",{"data-kanban-column":R.id,className:`flex-1 min-w-[180px] bg-neutral-50 rounded-xl flex flex-col ${f}`,onDragOver:N=>{N.preventDefault(),g&&!C&&v(R.id)},onDragLeave:j,onDrop:N=>B(N,R.id,y??M.length),children:[h.jsx("div",{className:"flex-shrink-0 border-b border-neutral-200",children:u?u(R,M.length):T(R,M.length)}),h.jsxs("div",{className:`flex-1 overflow-y-auto p-2 space-y-2 min-h-[100px] transition-colors ${C?"bg-blue-50":""}`,children:[M.map((N,F)=>{const I=t(N),W=g===I,z=C&&y===F&&!W;return h.jsxs("div",{children:[z&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mb-2 mx-1"}),h.jsx("div",{draggable:!0,onDragStart:te=>k(te,N),onDragEnd:w,onDragOver:te=>D(te,R.id,F),onClick:()=>a==null?void 0:a(N),className:`cursor-grab active:cursor-grabbing transition-all ${W?"opacity-50 scale-95":""} ${p}`,children:i(N,W)})]},I)}),h.jsx("div",{className:"min-h-[40px] flex-1",onDragOver:N=>{N.preventDefault(),D(N,R.id,M.length)},children:C&&y===M.length&&h.jsx("div",{className:"h-1 bg-blue-500 rounded-full mx-1 mt-1"})}),M.length===0&&C&&h.jsx("div",{className:"h-20 border-2 border-dashed border-blue-300 rounded-lg bg-blue-50/50 flex items-center justify-center",children:h.jsx("span",{className:"text-sm text-blue-400",children:"Drop here"})})]}),c&&h.jsx("div",{className:"flex-shrink-0 border-t border-neutral-200 p-2",children:c(R)})]},R.id)})})}const Mg={background:"#ffffff",hourLineColor:"#e5e7eb",halfHourLineColor:"#f3f4f6",hourTextColor:"#9ca3af",currentTimeColor:"#ef4444",allDayBackground:"#f9fafb",allDayBorder:"#e5e7eb"};function Fg(r){const e=r.match(/^(\d{1,2}):(\d{2})$/);return e?{hours:parseInt(e[1],10),minutes:parseInt(e[2],10)}:null}function jg(r){const e=r%12||12,t=r<12?"AM":"PM";return`${e} ${t}`}function Lg(r){const e=new Date;return r.getDate()===e.getDate()&&r.getMonth()===e.getMonth()&&r.getFullYear()===e.getFullYear()}function Pg({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:f=!0,className:p="",theme:g={}}){const m={...Mg,...g},{allDayItems:x,timedItems:v}=b.useMemo(()=>{const w=[],D=[];for(const j of r)l(j)?w.push(j):D.push(j);return{allDayItems:w,timedItems:D}},[r,l]),y=b.useMemo(()=>{const w=[];for(let D=t;D<=n;D++)w.push(D);return w},[t,n]),_=(n-t+1)*s,S=b.useCallback(w=>{const D=i(w);if(!D)return null;const j=Fg(D);if(!j)return null;const{hours:B,minutes:T}=j,R=Math.max(t,Math.min(n,B)),M=B<t?0:T,C=(R-t)*s+M/60*s,N=o(w),F=Math.max(20,N/60*s);return{top:C,height:F}},[i,o,t,n,s]),E=b.useMemo(()=>{if(!f||!Lg(e))return null;const w=new Date,D=w.getHours(),j=w.getMinutes();return D<t||D>n?null:(D-t)*s+j/60*s},[e,f,t,n,s]),k=b.useCallback(w=>{if(!d)return;const D=w.currentTarget.getBoundingClientRect(),B=(w.clientY-D.top)/s*60,T=Math.floor(B/60)+t,R=Math.round(B%60/15)*15,M=Math.min(n,Math.max(t,T)),C=R>=60?0:R,N=`${M.toString().padStart(2,"0")}:${C.toString().padStart(2,"0")}`;d(N)},[d,s,t,n]);return h.jsxs("div",{className:p,style:{background:m.background},children:[x.length>0&&h.jsxs("div",{style:{padding:"8px 0 8px 60px",borderBottom:`1px solid ${m.allDayBorder}`,background:m.allDayBackground},children:[h.jsx("div",{style:{fontSize:"11px",color:m.hourTextColor,marginBottom:"4px",textTransform:"uppercase",letterSpacing:"0.05em"},children:"All Day"}),h.jsx("div",{style:{display:"flex",flexWrap:"wrap",gap:"4px"},children:x.map(w=>h.jsx("div",{onClick:()=>c==null?void 0:c(w),style:{cursor:c?"pointer":"default"},children:u(w)},a(w)))})]}),h.jsxs("div",{style:{position:"relative",height:_},children:[y.map((w,D)=>h.jsxs("div",{style:{position:"absolute",top:D*s,left:0,right:0},children:[h.jsx("div",{style:{position:"absolute",left:0,top:-8,width:"50px",textAlign:"right",paddingRight:"10px",fontSize:"11px",color:m.hourTextColor},children:jg(w)}),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,height:"1px",background:m.hourLineColor}}),D<y.length-1&&h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:s/2,height:"1px",background:m.halfHourLineColor}})]},w)),h.jsx("div",{style:{position:"absolute",left:"60px",right:0,top:0,bottom:0,cursor:d?"pointer":"default"},onClick:k}),E!==null&&h.jsxs("div",{style:{position:"absolute",left:"55px",right:0,top:E,zIndex:20,pointerEvents:"none"},children:[h.jsx("div",{style:{width:"10px",height:"10px",borderRadius:"50%",background:m.currentTimeColor,marginLeft:"-5px",marginTop:"-5px",position:"absolute"}}),h.jsx("div",{style:{marginLeft:"5px",height:"2px",background:m.currentTimeColor}})]}),v.map(w=>{const D=S(w);return D?h.jsx("div",{style:{position:"absolute",left:"64px",right:"8px",top:D.top,height:D.height,zIndex:10,cursor:c?"pointer":"default"},onClick:j=>{j.stopPropagation(),c==null||c(w)},children:u(w)},a(w)):null})]})]})}function Vc({onComplete:r,onCancel:e,onTranscribe:t,onTranscriptionComplete:n,variant:s="widget",hideSaveButton:i=!1,maxDuration:o=180}){const l=s==="widget",[a,u]=b.useState("idle"),[c,d]=b.useState(0),[f,p]=b.useState(0),[g,m]=b.useState(!1),[x,v]=b.useState(0),[y,_]=b.useState(null),[S,E]=b.useState(!1),[k,w]=b.useState(null),[D,j]=b.useState(!0),[B,T]=b.useState([]),[R,M]=b.useState({completed:0,total:0}),C=b.useRef(!1),N=b.useRef(!0);b.useEffect(()=>{N.current=D},[D]);const F=b.useRef(null),I=b.useRef(null),W=b.useRef(null),z=b.useRef(null),te=b.useRef(null),U=b.useRef([]),Q=b.useRef(null),H=b.useRef(null),se=b.useRef(null),ue=b.useRef(null),de=b.useRef(!1),pe=b.useRef([]),De=b.useRef(null),xe=b.useRef(null),J=b.useRef([]),Ce=b.useRef([]),ne=b.useRef("insert"),Be=b.useRef(!1),Se=b.useRef(0),ke=b.useRef(0),Ie=b.useRef(0),Le=Z=>{const L=Math.floor(Z/60),le=Math.floor(Z%60);return`${L.toString().padStart(2,"0")}:${le.toString().padStart(2,"0")}`},$e=async Z=>{const L=await Z.arrayBuffer(),le=new AudioContext,fe=await le.decodeAudioData(L);return await le.close(),fe},Y=Z=>{const L=Z.numberOfChannels,le=Z.sampleRate,fe=1,G=16,we=G/8,be=L*we,ve=le*be,Fe=Z.length*be,qe=new ArrayBuffer(44+Fe),_e=new DataView(qe),Ee=(Ve,Oe)=>{for(let ut=0;ut<Oe.length;ut++)_e.setUint8(Ve+ut,Oe.charCodeAt(ut))};Ee(0,"RIFF"),_e.setUint32(4,36+Fe,!0),Ee(8,"WAVE"),Ee(12,"fmt "),_e.setUint32(16,16,!0),_e.setUint16(20,fe,!0),_e.setUint16(22,L,!0),_e.setUint32(24,le,!0),_e.setUint32(28,ve,!0),_e.setUint16(32,be,!0),_e.setUint16(34,G,!0),Ee(36,"data"),_e.setUint32(40,Fe,!0);const et=[];for(let Ve=0;Ve<L;Ve++)et.push(Z.getChannelData(Ve));let nt=44;for(let Ve=0;Ve<Z.length;Ve++)for(let Oe=0;Oe<L;Oe++){const ut=Math.max(-1,Math.min(1,et[Oe][Ve])),ct=ut<0?ut*32768:ut*32767;_e.setInt16(nt,ct,!0),nt+=2}return new Blob([qe],{type:"audio/wav"})},P=async(Z,L,le,fe)=>{const G=new AudioContext,we=Z.sampleRate,be=Math.max(Z.numberOfChannels,L.numberOfChannels),ve=Math.min(le,Z.length),Fe=Math.max(0,Z.length-le),qe=fe==="insert"?ve+L.length+Fe:ve+L.length,_e=G.createBuffer(be,qe,we);for(let Ee=0;Ee<be;Ee++){const et=_e.getChannelData(Ee),nt=Ee<Z.numberOfChannels?Z.getChannelData(Ee):Z.getChannelData(0);for(let Oe=0;Oe<ve;Oe++)et[Oe]=nt[Oe];const Ve=Ee<L.numberOfChannels?L.getChannelData(Ee):L.getChannelData(0);for(let Oe=0;Oe<L.length;Oe++)et[ve+Oe]=Ve[Oe];if(fe==="insert")for(let Oe=0;Oe<Fe;Oe++)et[ve+L.length+Oe]=nt[le+Oe]}return await G.close(),_e},me=b.useCallback(()=>{const Z=F.current;if(!Z)return;const L=Z.getContext("2d");if(!L)return;const le=Z.getBoundingClientRect(),fe=le.width,G=le.height,we=pe.current,be=f||c||1,ve=a==="recording"?c:x;L.fillStyle="#2d3b35",L.fillRect(0,0,fe,G);const Fe=8,qe="rgba(0, 0, 0, 0.4)",_e=L.createLinearGradient(0,0,0,Fe);_e.addColorStop(0,qe),_e.addColorStop(1,"transparent"),L.fillStyle=_e,L.fillRect(0,0,fe,Fe);const Ee=L.createLinearGradient(0,G-Fe,0,G);Ee.addColorStop(0,"transparent"),Ee.addColorStop(1,qe),L.fillStyle=Ee,L.fillRect(0,G-Fe,fe,Fe);const et=L.createLinearGradient(0,0,Fe,0);et.addColorStop(0,qe),et.addColorStop(1,"transparent"),L.fillStyle=et,L.fillRect(0,0,Fe,G);const nt=L.createLinearGradient(fe-Fe,0,fe,0);nt.addColorStop(0,"transparent"),nt.addColorStop(1,qe),L.fillStyle=nt,L.fillRect(fe-Fe,0,Fe,G),L.strokeStyle="#5a6b62",L.lineWidth=1,L.beginPath(),L.moveTo(0,G/2),L.lineTo(fe,G/2),L.stroke();const Ve=fe/2;if(we.length>0)if(a==="recording")for(let ct=0;ct<we.length;ct++){const At=we.length-1-ct,Zt=Ve-At*4;if(Zt<-3||Zt>fe)continue;const Rt=we[ct]*(G/2-12),A=G/2-Rt;L.fillStyle="#10b981",L.fillRect(Zt,A,3,Rt*2)}else{const ct=be>0?ve/be*we.length:0;for(let At=0;At<we.length;At++){const Zt=ct-At,Rt=Ve-Zt*4;if(Rt<-3||Rt>fe)continue;const A=we[At]*(G/2-12),q=G/2-A;L.fillStyle=At<=ct?"#10b981":"#4b5563",L.fillRect(Rt,q,3,A*2)}}L.strokeStyle="#ef4444",L.lineWidth=1,L.beginPath(),L.moveTo(Ve,0),L.lineTo(Ve,G),L.stroke(),L.fillStyle="#fff",L.font="bold 18px monospace",L.textAlign="center",L.fillText(Le(ve),Ve,G-6),a==="recording"&&(L.fillStyle="#ef4444",L.beginPath(),L.arc(20,20,8,0,Math.PI*2),L.fill(),L.fillStyle="#fff",L.font="10px sans-serif",L.textAlign="left",L.fillText("REC",34,24)),L.textAlign="left"},[a,x,c,f]),We=()=>{const Z=te.current;if(!Z||!de.current)return;const L=Z.frequencyBinCount,le=new Uint8Array(L);Z.getByteTimeDomainData(le);let fe=0;for(let be=0;be<L;be++){const ve=(le[be]-128)/128;fe+=ve*ve}const G=Math.sqrt(fe/L),we=Math.min(1,G*3);pe.current.push(we),me(),de.current&&(H.current=requestAnimationFrame(We))},$=async()=>{try{_(null),E(!1),De.current===null&&(pe.current=[]);const Z=await navigator.mediaDevices.getUserMedia({audio:!0});W.current=Z;const L=new AudioContext;z.current=L;const le=L.createAnalyser();le.fftSize=2048,te.current=le,L.createMediaStreamSource(Z).connect(le);const G=new MediaRecorder(Z);I.current=G,U.current=[],G.ondataavailable=we=>{we.data.size>0&&U.current.push(we.data)},G.onstop=async()=>{try{if(de.current=!1,U.current.length===0){_("No audio was recorded. Please try again."),u("idle"),Z.getTracks().forEach(_e=>_e.stop());return}const we=new Blob(U.current,{type:"audio/webm"});let be,ve;if(De.current!==null&&xe.current)try{const _e=await $e(we),Ee=xe.current.sampleRate,et=Math.floor(De.current*Ee),nt=await P(xe.current,_e,et,ne.current);be=Y(nt),ve=nt.length/nt.sampleRate,ne.current==="insert"&&(pe.current=[...pe.current,...Ce.current]),De.current=null,xe.current=null,J.current=[],Ce.current=[]}catch{be=we,ve=Se.current>0?Se.current:1}else be=we,ve=Se.current>0?Se.current:1;if(ue.current=be,Z.getTracks().forEach(_e=>_e.stop()),N.current&&t){T(_e=>[..._e,be]),M(_e=>({..._e,total:_e.total+1})),ue.current=null,pe.current=[],v(0),p(0),d(0),u("idle");return}const Fe=URL.createObjectURL(be),qe=new Audio(Fe);qe.ontimeupdate=()=>{v(qe.currentTime)},qe.onended=()=>{m(!1)},se.current=qe,p(ve),v(ve),u("editing")}catch{_("Failed to process recording"),u("idle")}},G.start(100),de.current=!0,u("recording"),d(0),Se.current=0,Q.current=setInterval(()=>{Se.current+=1,d(Se.current),Se.current>=o&&(I.current&&I.current.state!=="inactive"&&I.current.stop(),de.current=!1,w(null),Q.current&&(clearInterval(Q.current),Q.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{_("Could not access microphone. Please allow microphone access.")}},ae=()=>{de.current=!1,E(!1),w(null),H.current&&(cancelAnimationFrame(H.current),H.current=null),Q.current&&(clearInterval(Q.current),Q.current=null),I.current&&I.current.state!=="inactive"&&I.current.stop()},ge=Z=>{const L=F.current;if(!L)return;const le=f||c;if(le<=0)return;const fe=pe.current;if(fe.length===0)return;const G=L.getBoundingClientRect(),we=Z-ke.current,be=4,ve=G.width/L.width,Fe=fe.length/le*be,qe=-we/(Fe*ve),_e=Ie.current+qe,Ee=Math.max(0,Math.min(_e,le));se.current&&(se.current.currentTime=Ee),v(Ee)},ye=()=>{se.current&&(se.current.currentTime=0),v(0)},Ue=()=>{const Z=f||c;se.current&&(se.current.currentTime=Z),v(Z)},mt=()=>{const Z=se.current;Z&&(g?(Z.pause(),v(Z.currentTime),m(!1)):(Z.currentTime=x,Z.play().catch(()=>{}),m(!0)))},yt=async Z=>{if(!ue.current){$();return}try{se.current&&(se.current.pause(),m(!1)),ne.current=Z,xe.current=await $e(ue.current);const L=f||c;De.current=x;const le=L>0?x/L:0,fe=Math.floor(le*pe.current.length);J.current=pe.current.slice(0,fe),Ce.current=pe.current.slice(fe),pe.current=[...J.current],$()}catch{_("Failed to prepare recording. Please try again.")}},ie=()=>{se.current&&(se.current.pause(),se.current=null),ue.current=null,xe.current=null,De.current=null,J.current=[],m(!1),v(0),p(0),d(0),$()},ce=()=>{ue.current?r(ue.current,f||c):alert("No audio recorded yet!")};b.useEffect(()=>{a==="recording"&&F.current&&te.current&&de.current&&(H.current=requestAnimationFrame(We))},[a]),b.useEffect(()=>{const Z=F.current;if(!Z)return;const L=()=>{const le=window.devicePixelRatio||1,fe=Z.getBoundingClientRect();Z.width=fe.width*le,Z.height=fe.height*le;const G=Z.getContext("2d");G&&G.scale(le,le)};return L(),window.addEventListener("resize",L),()=>window.removeEventListener("resize",L)},[]),b.useEffect(()=>{if(a==="idle"){const Z=F.current;if(!Z)return;const L=Z.getContext("2d");if(!L)return;const le=Z.getBoundingClientRect(),fe=le.width,G=le.height;L.fillStyle="#2d3b35",L.fillRect(0,0,fe,G);const we=8,be="rgba(0, 0, 0, 0.4)",ve=L.createLinearGradient(0,0,0,we);ve.addColorStop(0,be),ve.addColorStop(1,"transparent"),L.fillStyle=ve,L.fillRect(0,0,fe,we);const Fe=L.createLinearGradient(0,G-we,0,G);Fe.addColorStop(0,"transparent"),Fe.addColorStop(1,be),L.fillStyle=Fe,L.fillRect(0,G-we,fe,we);const qe=L.createLinearGradient(0,0,we,0);qe.addColorStop(0,be),qe.addColorStop(1,"transparent"),L.fillStyle=qe,L.fillRect(0,0,we,G);const _e=L.createLinearGradient(fe-we,0,fe,0);_e.addColorStop(0,"transparent"),_e.addColorStop(1,be),L.fillStyle=_e,L.fillRect(fe-we,0,we,G),L.strokeStyle="#5a6b62",L.lineWidth=1,L.beginPath(),L.moveTo(0,G/2),L.lineTo(fe,G/2),L.stroke();const Ee=fe/2;L.strokeStyle="#ef4444",L.lineWidth=1,L.beginPath(),L.moveTo(Ee,0),L.lineTo(Ee,G),L.stroke(),L.fillStyle="#fff",L.font="bold 18px monospace",L.textAlign="center",L.fillText("00:00",Ee,G-6)}},[a]);const He=b.useCallback(Z=>{T(L=>[...L,Z]),M(L=>({...L,total:L.total+1}))},[]);if(b.useEffect(()=>{(async()=>{if(C.current||B.length===0||!t)return;C.current=!0;const L=B[0];try{const le=await t(L);le&&n&&n(le)}catch(le){console.error("Transcription failed:",le)}finally{T(le=>le.slice(1)),M(le=>({...le,completed:le.completed+1})),C.current=!1}})()},[B,t,n]),b.useEffect(()=>()=>{de.current=!1,Q.current&&clearInterval(Q.current),H.current&&cancelAnimationFrame(H.current),W.current&&W.current.getTracks().forEach(Z=>Z.stop()),z.current&&z.current.state!=="closed"&&z.current.close()},[]),b.useEffect(()=>{if(a==="editing"&&g){let Z;const L=()=>{const le=se.current;if(le&&g){const fe=F.current;if(fe){const G=fe.getContext("2d");if(G){const we=fe.getBoundingClientRect(),be=we.width,ve=we.height,Fe=pe.current,qe=f||c||1,_e=le.currentTime;G.fillStyle="#2d3b35",G.fillRect(0,0,be,ve);const Ee=8,et="rgba(0, 0, 0, 0.4)",nt=G.createLinearGradient(0,0,0,Ee);nt.addColorStop(0,et),nt.addColorStop(1,"transparent"),G.fillStyle=nt,G.fillRect(0,0,be,Ee);const Ve=G.createLinearGradient(0,ve-Ee,0,ve);Ve.addColorStop(0,"transparent"),Ve.addColorStop(1,et),G.fillStyle=Ve,G.fillRect(0,ve-Ee,be,Ee);const Oe=G.createLinearGradient(0,0,Ee,0);Oe.addColorStop(0,et),Oe.addColorStop(1,"transparent"),G.fillStyle=Oe,G.fillRect(0,0,Ee,ve);const ut=G.createLinearGradient(be-Ee,0,be,0);ut.addColorStop(0,"transparent"),ut.addColorStop(1,et),G.fillStyle=ut,G.fillRect(be-Ee,0,Ee,ve),G.strokeStyle="#5a6b62",G.lineWidth=1,G.beginPath(),G.moveTo(0,ve/2),G.lineTo(be,ve/2),G.stroke();const ct=be/2,At=3,Zt=4,Rt=qe>0?_e/qe*Fe.length:0;for(let ee=0;ee<Fe.length;ee++){const he=Rt-ee,Re=ct-he*Zt;if(Re<-At||Re>be)continue;const Pe=Fe[ee]*(ve/2-12),Te=ve/2-Pe;G.fillStyle=ee<=Rt?"#10b981":"#4b5563",G.fillRect(Re,Te,At,Pe*2)}G.strokeStyle="#ef4444",G.lineWidth=1,G.beginPath(),G.moveTo(ct,0),G.lineTo(ct,ve),G.stroke(),G.fillStyle="#fff",G.font="bold 18px monospace",G.textAlign="center";const A=Math.floor(_e/60),q=Math.floor(_e%60);G.fillText(`${A.toString().padStart(2,"0")}:${q.toString().padStart(2,"0")}`,ct,ve-6),G.textAlign="left"}}Z=requestAnimationFrame(L)}};return Z=requestAnimationFrame(L),()=>cancelAnimationFrame(Z)}},[a,g,f,c]),b.useEffect(()=>{a==="editing"&&!g&&me()},[a,x,g,me]),y)return h.jsxs("div",{style:{border:"1px solid #fecaca",borderRadius:"12px",padding:"16px",background:"#fef2f2"},children:[h.jsx("p",{style:{fontSize:"14px",color:"#dc2626",marginBottom:"12px"},children:y}),h.jsx("button",{onClick:()=>{_(null),$()},style:{padding:"8px 16px",fontSize:"14px",background:"#171717",color:"white",borderRadius:"8px",border:"none",cursor:"pointer"},children:"Try Again"})]});const Xe={padding:"8px",borderRadius:"8px",border:"none",background:"transparent",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center",transition:"background 0.15s"},Je={...Xe,opacity:.3,cursor:"not-allowed"},Bt=l?{border:"1px solid #e5e5e5",borderRadius:"12px",overflow:"hidden",background:"white"}:{overflow:"hidden",background:"white",flexShrink:0};return h.jsxs("div",{style:Bt,children:[h.jsx("canvas",{ref:F,style:{width:"100%",height:"32px",cursor:"pointer",flexShrink:0},onMouseDown:Z=>{if(a==="editing"){Be.current=!0,ke.current=Z.clientX,Ie.current=x;const L=fe=>{Be.current&&ge(fe.clientX)},le=()=>{Be.current=!1,window.removeEventListener("mousemove",L),window.removeEventListener("mouseup",le)};window.addEventListener("mousemove",L),window.addEventListener("mouseup",le)}}}),h.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:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[h.jsx("button",{onClick:ye,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?Je:Xe,title:"Go to start",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"first_page"})}),h.jsx("button",{onClick:()=>{if(a==="recording"){const Z=I.current;Z&&(Z.state==="recording"?(Z.pause(),E(!0)):Z.state==="paused"&&(Z.resume(),E(!1)))}else mt()},disabled:a==="idle",style:a==="idle"?Je:Xe,title:g||a==="recording"&&!S?"Pause":"Play",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:g||a==="recording"&&!S?"pause":"play_arrow"})}),h.jsx("button",{onClick:Ue,disabled:a==="idle"||a==="recording",style:a==="idle"||a==="recording"?Je:Xe,title:"Go to end",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"last_page"})}),h.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))"}}),h.jsx("button",{onClick:()=>{k==="insert"?ae():a==="idle"?(w("insert"),$()):a==="editing"&&(w("insert"),yt("insert"))},disabled:a==="recording"&&k!=="insert"||g,style:a==="recording"&&k!=="insert"||g?Je:Xe,title:k==="insert"?"Stop recording":"Insert recording",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:k==="insert"?"#ef4444":"#171717"},children:"add"})}),h.jsx("button",{onClick:()=>{N.current||(k==="mic"?ae():a==="idle"?(w("mic"),$()):a==="editing"&&(w("mic"),yt("replace")))},onMouseDown:()=>{N.current&&a==="idle"&&!g&&(w("mic"),$())},onMouseUp:()=>{N.current&&a==="recording"&&k==="mic"&&ae()},onMouseLeave:()=>{N.current&&a==="recording"&&k==="mic"&&ae()},onTouchStart:()=>{N.current&&a==="idle"&&!g&&(w("mic"),$())},onTouchEnd:()=>{N.current&&a==="recording"&&k==="mic"&&ae()},disabled:a==="recording"&&k!=="mic"||g,style:a==="recording"&&k!=="mic"||g?Je:Xe,title:D?"Hold to record (walkie-talkie)":k==="mic"?"Stop recording":"Record",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:k==="mic"?"#ef4444":"#171717"},children:"mic"})}),h.jsx("button",{onClick:()=>{k==="startover"?ae():a==="editing"&&(w("startover"),ie())},disabled:a==="idle"||a==="recording"&&k!=="startover"||g,style:a==="idle"||a==="recording"&&k!=="startover"||g?Je:Xe,title:k==="startover"?"Stop recording":"Start over",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:k==="startover"?"#ef4444":"#171717"},children:"refresh"})})]}),h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px"},children:[R.total>0&&R.completed<R.total&&h.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:[h.jsx("span",{className:"material-icons",style:{fontSize:"14px",animation:"spin 1s linear infinite"},children:"sync"}),R.completed,"/",R.total]}),t&&h.jsxs(h.Fragment,{children:[h.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"4px",marginRight:"4px"},children:[h.jsx("button",{onClick:()=>j(!D),style:{width:"28px",height:"16px",borderRadius:"8px",border:"none",background:D?"#10b981":"#9ca3af",cursor:"pointer",position:"relative",transition:"background 0.2s",padding:0},title:D?"Auto-transcribe ON":"Auto-transcribe OFF",children:h.jsx("div",{style:{width:"12px",height:"12px",borderRadius:"50%",background:"white",position:"absolute",top:"2px",left:D?"14px":"2px",transition:"left 0.2s",boxShadow:"0 1px 2px rgba(0,0,0,0.2)"}})}),h.jsx("span",{style:{fontSize:"10px",color:"#666"},children:"auto"})]}),h.jsx("button",{onClick:()=>{a==="editing"&&ue.current&&He(ue.current)},disabled:a!=="editing",style:a!=="editing"?Je:Xe,title:"Transcribe audio",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:D?"#10b981":"#171717"},children:"subtitles"})})]}),!i&&h.jsx("button",{onClick:ce,disabled:a!=="editing",style:a!=="editing"?Je:Xe,title:"Save recording",children:h.jsx("span",{className:"material-icons",style:{fontSize:"20px",color:"#171717"},children:"save"})})]})]}),R.total>0&&R.completed<R.total&&h.jsx("div",{style:{height:"3px",background:"#e5e5e5",overflow:"hidden"},children:h.jsx("div",{style:{height:"100%",background:"#10b981",width:`${R.completed/R.total*100}%`,transition:"width 0.3s ease"}})})]})}function Ig({label:r,value:e,onChange:t,onTranscribe:n,onAIAction:s,placeholder:i="Type or record...",className:o="",rows:l}){const[a,u]=b.useState(!1),[c,d]=b.useState(null),[f,p]=b.useState(!1),g=b.useRef(null),m=y=>{t(e?`${e}
184
184
 
185
- ${y}`:y)},x=async y=>{if(!(!e.trim()||a||!s)){u(!0),d(y),p(!1);try{const w=await s(y,e);t(w)}catch(w){console.error(`${y} failed:`,w)}finally{u(!1),d(null)}}},_=()=>{setTimeout(()=>{var y;(y=g.current)!=null&&y.contains(document.activeElement)||p(!1)},150)};return h.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${o}`,children:[h.jsx(Vc,{onComplete:()=>{},onTranscribe:n,onTranscriptionComplete:m,hideSaveButton:!0,variant:"div"}),h.jsxs("div",{className:"flex items-center justify-between mt-3 mb-1",children:[h.jsx("label",{className:"text-sm font-medium text-neutral-700",children:r}),h.jsxs("div",{className:"flex items-center gap-1",children:[e.trim()&&h.jsx("button",{type:"button",onClick:()=>navigator.clipboard.writeText(e),className:"p-1 rounded hover:bg-neutral-100 transition-colors",title:"Copy to clipboard",children:h.jsx("span",{className:"material-icons text-neutral-500",style:{fontSize:"16px"},children:"content_copy"})}),s&&h.jsxs("div",{className:"relative",ref:g,children:[h.jsx("button",{type:"button",onClick:()=>p(!f),disabled:a||!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:a?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons text-sm animate-spin",children:"hourglass_empty"}),c==="restructure"&&"Restructuring...",c==="proofread"&&"Proofreading...",c==="rewrite"&&"Rewriting..."]}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons text-sm",children:"auto_fix_high"}),"AI",h.jsx("span",{className:"material-icons text-sm",children:"expand_more"})]})}),f&&!a&&h.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:_,children:[h.jsxs("button",{type:"button",onClick:()=>x("restructure"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-blue-500",children:"format_list_bulleted"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Restructure"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Organize & clarify"})]})]}),h.jsxs("button",{type:"button",onClick:()=>x("proofread"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-green-500",children:"spellcheck"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Proofread"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Fix grammar & spelling"})]})]}),h.jsxs("button",{type:"button",onClick:()=>x("rewrite"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-purple-500",children:"brush"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Rewrite"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Your voice & style"})]})]})]})]})]})]}),h.jsx("textarea",{value:e,onChange:y=>t(y.target.value),onKeyDown:y=>y.stopPropagation(),placeholder:i,rows:l,disabled:a,className:"flex-1 w-full px-3 py-2 border border-neutral-300 rounded-lg focus:ring-2 focus:ring-neutral-900 text-sm disabled:opacity-50 disabled:bg-neutral-50 resize-none"})]})}const gs={"4/3":4/3,"16/9":16/9,"1/1":1,"3/4":3/4,"9/16":9/16,free:null};function Og({src:r,onSave:e,onCancel:t,aspectRatio:n="4/3",outputFormat:s="image/jpeg",outputQuality:i=.9,theme:o="dark"}){const l=b.useRef(null),a=b.useRef(null),u=b.useRef(null),[c,d]=b.useState(!0),[f,p]=b.useState(null),[g,m]=b.useState(n),[x,_]=b.useState(0),[y,w]=b.useState({x:0,y:0,width:100,height:100}),[C,D]=b.useState(!1),[E,v]=b.useState(null),[k,M]=b.useState({x:0,y:0}),[T,N]=b.useState({x:0,y:0,width:100,height:100}),R=o==="dark",j=b.useCallback(()=>{const J=u.current;return J?x===90||x===270?{width:J.height,height:J.width}:{width:J.width,height:J.height}:{width:100,height:100}},[x]),S=b.useCallback((J,Ce)=>{const ne=J/Ce,Be=.05;for(const[Se,ke]of Object.entries(gs))if(ke!==null&&Math.abs(ne-ke)/ke<Be)return Se;return"free"},[]);b.useEffect(()=>{const J=new Image;J.crossOrigin="anonymous",J.onload=()=>{u.current=J;const Ce=S(J.width,J.height);m(Ce),d(!1)},J.onerror=()=>{p("Failed to load image"),d(!1)},J.src=r},[r,S]);const B=b.useCallback(()=>{const{width:J,height:Ce}=j(),ne=gs[g];if(ne===null){w({x:0,y:0,width:100,height:100});return}const Be=J/Ce;let Se,ke;Be>ne?(ke=100,Se=ne/Be*100):(Se=100,ke=Be/ne*100);const Ie=(100-Se)/2,Le=(100-ke)/2;w({x:Ie,y:Le,width:Se,height:ke})},[g,j]);b.useEffect(()=>{u.current&&B()},[g,x,B]),b.useEffect(()=>{const J=a.current,Ce=u.current;if(!J||!Ce||c)return;const ne=J.getContext("2d");if(!ne)return;const Be=l.current;if(!Be)return;const Se=Be.clientWidth,ke=Be.clientHeight-140,{width:Ie,height:Le}=j(),$e=Ie/Le;let Y,P;Se/ke>$e?(P=Math.min(ke,Le),Y=P*$e):(Y=Math.min(Se,Ie),P=Y/$e),Y>Se&&(Y=Se,P=Y/$e),P>ke&&(P=ke,Y=P*$e),J.width=Y,J.height=P,ne.clearRect(0,0,Y,P),ne.save(),ne.translate(Y/2,P/2),ne.rotate(x*Math.PI/180);let me,We;x===90||x===270?(me=P,We=Y):(me=Y,We=P),ne.drawImage(Ce,-me/2,-We/2,me,We),ne.restore(),ne.fillStyle="rgba(0, 0, 0, 0.6)";const z=y.x/100*Y,ae=y.y/100*P,ge=y.width/100*Y,ye=y.height/100*P;ne.fillRect(0,0,Y,ae),ne.fillRect(0,ae+ye,Y,P-ae-ye),ne.fillRect(0,ae,z,ye),ne.fillRect(z+ge,ae,Y-z-ge,ye),ne.strokeStyle="#fff",ne.lineWidth=2,ne.strokeRect(z,ae,ge,ye),ne.strokeStyle="rgba(255, 255, 255, 0.3)",ne.lineWidth=1,ne.beginPath(),ne.moveTo(z+ge/3,ae),ne.lineTo(z+ge/3,ae+ye),ne.moveTo(z+ge*2/3,ae),ne.lineTo(z+ge*2/3,ae+ye),ne.moveTo(z,ae+ye/3),ne.lineTo(z+ge,ae+ye/3),ne.moveTo(z,ae+ye*2/3),ne.lineTo(z+ge,ae+ye*2/3),ne.stroke();const Ue=14;ne.fillStyle="#fff",ne.strokeStyle="#333",ne.lineWidth=1,[{x:z,y:ae},{x:z+ge,y:ae},{x:z,y:ae+ye},{x:z+ge,y:ae+ye}].forEach(yt=>{ne.fillRect(yt.x-Ue/2,yt.y-Ue/2,Ue,Ue),ne.strokeRect(yt.x-Ue/2,yt.y-Ue/2,Ue,Ue)})},[y,x,c,j]);const F=J=>{const Ce=a.current;if(!Ce)return;const ne=Ce.getBoundingClientRect(),Be=(J.clientX-ne.left)/ne.width*100,Se=(J.clientY-ne.top)/ne.height*100,ke=4,Ie=[{name:"nw",x:y.x,y:y.y},{name:"ne",x:y.x+y.width,y:y.y},{name:"sw",x:y.x,y:y.y+y.height},{name:"se",x:y.x+y.width,y:y.y+y.height}];for(const Le of Ie)if(Math.abs(Be-Le.x)<ke&&Math.abs(Se-Le.y)<ke){v(Le.name),M({x:Be,y:Se}),N({...y});return}Be>=y.x&&Be<=y.x+y.width&&Se>=y.y&&Se<=y.y+y.height&&(D(!0),M({x:Be,y:Se}),N({...y}))},O=J=>{const Ce=a.current;if(!Ce)return;const ne=Ce.getBoundingClientRect(),Be=(J.clientX-ne.left)/ne.width*100,Se=(J.clientY-ne.top)/ne.height*100;if(C){const ke=Be-k.x,Ie=Se-k.y;let Le=T.x+ke,$e=T.y+Ie;Le=Math.max(0,Math.min(Le,100-T.width)),$e=Math.max(0,Math.min($e,100-T.height)),w({...T,x:Le,y:$e})}else if(E){const ke=gs[g],{width:Ie,height:Le}=j(),$e=Ie/Le,Y=ke?ke/$e:null;let P={...T};const me=Be-k.x,We=Se-k.y;if(E==="se")P.width=Math.max(10,Math.min(100-P.x,T.width+me)),Y?(P.height=P.width/Y,P.y+P.height>100&&(P.height=100-P.y,P.width=P.height*Y)):P.height=Math.max(10,Math.min(100-P.y,T.height+We));else if(E==="sw"){const z=-me,ae=Math.max(10,T.width+z),ge=T.x+T.width-ae;ge>=0&&(P.width=ae,P.x=ge,Y?(P.height=P.width/Y,P.y+P.height>100&&(P.height=100-P.y,P.width=P.height*Y,P.x=T.x+T.width-P.width)):P.height=Math.max(10,Math.min(100-P.y,T.height+We)))}else if(E==="ne")if(P.width=Math.max(10,Math.min(100-P.x,T.width+me)),Y){const z=P.width/Y,ae=T.y+T.height-z;ae>=0?(P.height=z,P.y=ae):(P.y=0,P.height=T.y+T.height,P.width=P.height*Y)}else{const z=-We,ae=Math.max(10,T.height+z),ge=T.y+T.height-ae;ge>=0&&(P.height=ae,P.y=ge)}else if(E==="nw"){const z=-me,ae=Math.max(10,T.width+z),ge=T.x+T.width-ae;if(ge>=0)if(P.width=ae,P.x=ge,Y){const ye=P.width/Y,Ue=T.y+T.height-ye;Ue>=0?(P.height=ye,P.y=Ue):(P.y=0,P.height=T.y+T.height,P.width=P.height*Y,P.x=T.x+T.width-P.width)}else{const ye=-We,Ue=Math.max(10,T.height+ye),mt=T.y+T.height-Ue;mt>=0&&(P.height=Ue,P.y=mt)}}P.x=Math.max(0,P.x),P.y=Math.max(0,P.y),P.width=Math.min(P.width,100-P.x),P.height=Math.min(P.height,100-P.y),w(P)}},V=()=>{D(!1),v(null)},U=J=>{_(Ce=>J==="right"?(Ce+90)%360:(Ce-90+360)%360)},te=()=>{const J=u.current;if(!J)return;const{width:Ce,height:ne}=j(),Be=y.x/100*Ce,Se=y.y/100*ne,ke=y.width/100*Ce,Ie=y.height/100*ne,Le=document.createElement("canvas"),$e=Le.getContext("2d");if(!$e)return;Le.width=ke,Le.height=Ie;const Y=document.createElement("canvas"),P=Y.getContext("2d");P&&(Y.width=Ce,Y.height=ne,P.save(),P.translate(Ce/2,ne/2),P.rotate(x*Math.PI/180),P.drawImage(J,-J.width/2,-J.height/2,J.width,J.height),P.restore(),$e.drawImage(Y,Be,Se,ke,Ie,0,0,ke,Ie),Le.toBlob(me=>{me&&e(me)},s,i))},q={display:"flex",flexDirection:"column",width:"100%",height:"100%",background:R?"#1a1a1a":"#f5f5f5",overflow:"hidden"},X={flex:1,display:"flex",alignItems:"center",justifyContent:"center",padding:"16px",minHeight:0,overflow:"hidden"},W={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"},ue={padding:"10px 20px",borderRadius:"8px",border:"none",cursor:"pointer",fontSize:"14px",fontWeight:500,transition:"background 0.15s, opacity 0.15s"},de={...ue,background:"#E67E22",color:"#fff"},pe={...ue,background:R?"#333":"#e5e5e5",color:R?"#fff":"#333"},De={padding:"10px",borderRadius:"8px",border:"none",background:R?"#333":"#e5e5e5",color:R?"#fff":"#333",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},xe=J=>({padding:"8px 14px",borderRadius:"6px",border:J?"2px solid #E67E22":"2px solid transparent",background:J?"#E67E22":R?"#333":"#e5e5e5",color:J?"#fff":R?"#ccc":"#666",cursor:"pointer",fontSize:"13px",fontWeight:600,transition:"all 0.15s"});return c?h.jsx("div",{style:{...q,alignItems:"center",justifyContent:"center"},children:h.jsx("div",{style:{color:R?"#aaa":"#666"},children:"Loading image..."})}):f?h.jsxs("div",{style:{...q,alignItems:"center",justifyContent:"center"},children:[h.jsx("div",{style:{color:"#ef4444"},children:f}),t&&h.jsx("button",{onClick:t,style:{...pe,marginTop:"16px"},children:"Close"})]}):h.jsxs("div",{ref:l,style:q,children:[h.jsx("div",{style:X,children:h.jsx("canvas",{ref:a,style:{cursor:C?"grabbing":E?"nwse-resize":"grab",maxWidth:"100%",maxHeight:"100%"},onMouseDown:F,onMouseMove:O,onMouseUp:V,onMouseLeave:V})}),h.jsxs("div",{style:W,children:[h.jsx("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap",justifyContent:"center"},children:Object.keys(gs).map(J=>h.jsx("button",{onClick:()=>m(J),style:xe(g===J),children:J==="free"?"Libre":J},J))}),h.jsxs("div",{style:se,children:[h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("button",{onClick:()=>U("left"),style:De,title:"Rotate left",children:h.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"M2.5 2v6h6M2.66 15.57a10 10 0 1 0 .57-8.38"})})}),h.jsx("button",{onClick:()=>U("right"),style:De,title:"Rotate right",children:h.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"M21.5 2v6h-6M21.34 15.57a10 10 0 1 1-.57-8.38"})})})]}),h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t&&h.jsx("button",{onClick:t,style:pe,children:"Annuler"}),h.jsx("button",{onClick:te,style:de,children:"Enregistrer"})]})]})]})]})}var zg={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 $g(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=$g(r+"",t),s,i=-1,o=n.length;if(arguments.length<2){for(;++i<o;)if((s=(r=n[i]).type)&&(s=qg(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]=Il(t[s],r.name,e);else if(e==null)for(s in t)t[s]=Il(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 qg(r,e){for(var t=0,n=r.length,s;t<n;++t)if((s=r[t]).name===e)return s.value}function Il(r,e,t){for(var n=0,s=r.length;n<s;++n)if(r[n].name===e){r[n]=zg,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 Ug(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 Wg(r){return function(){return this.ownerDocument.createElementNS(r.space,r.local)}}function Gc(r){var e=_i(r);return(e.local?Wg:Ug)(e)}function Hg(){}function ua(r){return r==null?Hg:function(){return this.querySelector(r)}}function Vg(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 Dt(n,this._parents)}function Gg(r){return r==null?[]:Array.isArray(r)?r:Array.from(r)}function Kg(){return[]}function Kc(r){return r==null?Kg:function(){return this.querySelectorAll(r)}}function Yg(r){return function(){return Gg(r.apply(this,arguments))}}function Qg(r){typeof r=="function"?r=Yg(r):r=Kc(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 Dt(n,s)}function Yc(r){return function(){return this.matches(r)}}function Qc(r){return function(e){return e.matches(r)}}var Xg=Array.prototype.find;function Jg(r){return function(){return Xg.call(this.children,r)}}function Zg(){return this.firstElementChild}function e0(r){return this.select(r==null?Zg:Jg(typeof r=="function"?r:Qc(r)))}var t0=Array.prototype.filter;function r0(){return Array.from(this.children)}function n0(r){return function(){return t0.call(this.children,r)}}function s0(r){return this.selectAll(r==null?r0:n0(typeof r=="function"?r:Qc(r)))}function i0(r){typeof r!="function"&&(r=Yc(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 Dt(n,this._parents)}function Xc(r){return new Array(r.length)}function o0(){return new Dt(this._enter||this._groups.map(Xc),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 a0(r){return function(){return r}}function l0(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 u0(r,e,t,n,s,i,o){var l,a,u=new Map,c=e.length,d=i.length,f=new Array(c),p;for(l=0;l<c;++l)(a=e[l])&&(f[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(f[l])===a&&(s[l]=a)}function c0(r){return r.__data__}function d0(r,e){if(!arguments.length)return Array.from(this,c0);var t=e?u0:l0,n=this._parents,s=this._groups;typeof r!="function"&&(r=a0(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],f=d.length,p=f0(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(f);t(c,d,m,x,_,p,e);for(var y=0,w=0,C,D;y<g;++y)if(C=m[y]){for(y>=w&&(w=y+1);!(D=x[w])&&++w<g;);C._next=D||null}}return o=new Dt(o,n),o._enter=l,o._exit=a,o}function f0(r){return typeof r=="object"&&"length"in r?r:Array.from(r)}function h0(){return new Dt(this._exit||this._groups.map(Xc),this._parents)}function p0(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 g0(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,f=l[a]=new Array(d),p,g=0;g<d;++g)(p=u[g]||c[g])&&(f[g]=p);for(;a<s;++a)l[a]=t[a];return new Dt(l,this._parents)}function m0(){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 y0(r){r||(r=x0);function e(d,f){return d&&f?r(d.__data__,f.__data__):!d-!f}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 Dt(s,this._parents).order()}function x0(r,e){return r<e?-1:r>e?1:r>=e?0:NaN}function b0(){var r=arguments[0];return arguments[0]=this,r.apply(null,arguments),this}function v0(){return Array.from(this)}function _0(){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 w0(){let r=0;for(const e of this)++r;return r}function C0(){return!this.node()}function S0(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 k0(r){return function(){this.removeAttribute(r)}}function E0(r){return function(){this.removeAttributeNS(r.space,r.local)}}function D0(r,e){return function(){this.setAttribute(r,e)}}function A0(r,e){return function(){this.setAttributeNS(r.space,r.local,e)}}function T0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(r):this.setAttribute(r,t)}}function N0(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 B0(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?E0:k0:typeof e=="function"?t.local?N0:T0:t.local?A0:D0)(t,e))}function Jc(r){return r.ownerDocument&&r.ownerDocument.defaultView||r.document&&r||r.defaultView}function R0(r){return function(){this.style.removeProperty(r)}}function M0(r,e,t){return function(){this.style.setProperty(r,e,t)}}function F0(r,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(r):this.style.setProperty(r,n,t)}}function j0(r,e,t){return arguments.length>1?this.each((e==null?R0:typeof e=="function"?F0:M0)(r,e,t??"")):rn(this.node(),r)}function rn(r,e){return r.style.getPropertyValue(e)||Jc(r).getComputedStyle(r,null).getPropertyValue(e)}function L0(r){return function(){delete this[r]}}function P0(r,e){return function(){this[r]=e}}function I0(r,e){return function(){var t=e.apply(this,arguments);t==null?delete this[r]:this[r]=t}}function O0(r,e){return arguments.length>1?this.each((e==null?L0:typeof e=="function"?I0:P0)(r,e)):this.node()[r]}function Zc(r){return r.trim().split(/^|\s+/)}function ca(r){return r.classList||new ed(r)}function ed(r){this._node=r,this._names=Zc(r.getAttribute("class")||"")}ed.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 td(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.add(e[n])}function rd(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.remove(e[n])}function z0(r){return function(){td(this,r)}}function $0(r){return function(){rd(this,r)}}function q0(r,e){return function(){(e.apply(this,arguments)?td:rd)(this,r)}}function U0(r,e){var t=Zc(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"?q0:e?z0:$0)(t,e))}function W0(){this.textContent=""}function H0(r){return function(){this.textContent=r}}function V0(r){return function(){var e=r.apply(this,arguments);this.textContent=e??""}}function G0(r){return arguments.length?this.each(r==null?W0:(typeof r=="function"?V0:H0)(r)):this.node().textContent}function K0(){this.innerHTML=""}function Y0(r){return function(){this.innerHTML=r}}function Q0(r){return function(){var e=r.apply(this,arguments);this.innerHTML=e??""}}function X0(r){return arguments.length?this.each(r==null?K0:(typeof r=="function"?Q0:Y0)(r)):this.node().innerHTML}function J0(){this.nextSibling&&this.parentNode.appendChild(this)}function Z0(){return this.each(J0)}function em(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function tm(){return this.each(em)}function rm(r){var e=typeof r=="function"?r:Gc(r);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function nm(){return null}function sm(r,e){var t=typeof r=="function"?r:Gc(r),n=e==null?nm:typeof e=="function"?e:ua(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function im(){var r=this.parentNode;r&&r.removeChild(this)}function om(){return this.each(im)}function am(){var r=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function lm(){var r=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function um(r){return this.select(r?lm:am)}function cm(r){return arguments.length?this.property("__data__",r):this.node().__data__}function dm(r){return function(e){r.call(this,e,this.__data__)}}function fm(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 hm(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 pm(r,e,t){return function(){var n=this.__on,s,i=dm(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 gm(r,e,t){var n=fm(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?pm:hm,s=0;s<i;++s)this.each(l(n[s],e,t));return this}function nd(r,e,t){var n=Jc(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 mm(r,e){return function(){return nd(this,r,e)}}function ym(r,e){return function(){return nd(this,r,e.apply(this,arguments))}}function xm(r,e){return this.each((typeof e=="function"?ym:mm)(r,e))}function*bm(){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 sd=[null];function Dt(r,e){this._groups=r,this._parents=e}function ss(){return new Dt([[document.documentElement]],sd)}function vm(){return this}Dt.prototype=ss.prototype={constructor:Dt,select:Vg,selectAll:Qg,selectChild:e0,selectChildren:s0,filter:i0,data:d0,enter:o0,exit:h0,join:p0,merge:g0,selection:vm,order:m0,sort:y0,call:b0,nodes:v0,node:_0,size:w0,empty:C0,each:S0,attr:B0,style:j0,property:O0,classed:U0,text:G0,html:X0,raise:Z0,lower:tm,append:rm,insert:sm,remove:om,clone:um,datum:cm,on:gm,dispatch:xm,[Symbol.iterator]:bm};function Lt(r){return typeof r=="string"?new Dt([[document.querySelector(r)]],[document.documentElement]):new Dt([[r]],sd)}function _m(r){let e;for(;e=r.sourceEvent;)r=e;return r}function wr(r,e){if(r=_m(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 wm(r){var e=r.document.documentElement,t=Lt(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 Cm(r,e){var t=r.document.documentElement,n=Lt(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 id(r,e){var t=Object.create(r.prototype);for(var n in e)t[n]=e[n];return t}function is(){}var $n=.7,Xs=1/$n,Xr="\\s*([+-]?\\d+)\\s*",qn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Gt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Sm=/^#([0-9a-f]{3,8})$/,km=new RegExp(`^rgb\\(${Xr},${Xr},${Xr}\\)$`),Em=new RegExp(`^rgb\\(${Gt},${Gt},${Gt}\\)$`),Dm=new RegExp(`^rgba\\(${Xr},${Xr},${Xr},${qn}\\)$`),Am=new RegExp(`^rgba\\(${Gt},${Gt},${Gt},${qn}\\)$`),Tm=new RegExp(`^hsl\\(${qn},${Gt},${Gt}\\)$`),Nm=new RegExp(`^hsla\\(${qn},${Gt},${Gt},${qn}\\)$`),zl={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:$l,formatHex:$l,formatHex8:Bm,formatHsl:Rm,formatRgb:ql,toString:ql});function $l(){return this.rgb().formatHex()}function Bm(){return this.rgb().formatHex8()}function Rm(){return od(this).formatHsl()}function ql(){return this.rgb().formatRgb()}function Un(r){var e,t;return r=(r+"").trim().toLowerCase(),(e=Sm.exec(r))?(t=e[1].length,e=parseInt(e[1],16),t===6?Ul(e):t===3?new wt(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=km.exec(r))?new wt(e[1],e[2],e[3],1):(e=Em.exec(r))?new wt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Dm.exec(r))?ms(e[1],e[2],e[3],e[4]):(e=Am.exec(r))?ms(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Tm.exec(r))?Vl(e[1],e[2]/100,e[3]/100,1):(e=Nm.exec(r))?Vl(e[1],e[2]/100,e[3]/100,e[4]):zl.hasOwnProperty(r)?Ul(zl[r]):r==="transparent"?new wt(NaN,NaN,NaN,0):null}function Ul(r){return new wt(r>>16&255,r>>8&255,r&255,1)}function ms(r,e,t,n){return n<=0&&(r=e=t=NaN),new wt(r,e,t,n)}function Mm(r){return r instanceof is||(r=Un(r)),r?(r=r.rgb(),new wt(r.r,r.g,r.b,r.opacity)):new wt}function wo(r,e,t,n){return arguments.length===1?Mm(r):new wt(r,e,t,n??1)}function wt(r,e,t,n){this.r=+r,this.g=+e,this.b=+t,this.opacity=+n}da(wt,wo,id(is,{brighter(r){return r=r==null?Xs:Math.pow(Xs,r),new wt(this.r*r,this.g*r,this.b*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new wt(this.r*r,this.g*r,this.b*r,this.opacity)},rgb(){return this},clamp(){return new wt(Tr(this.r),Tr(this.g),Tr(this.b),Js(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:Wl,formatHex:Wl,formatHex8:Fm,formatRgb:Hl,toString:Hl}));function Wl(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}`}function Fm(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}${Sr((isNaN(this.opacity)?1:this.opacity)*255)}`}function Hl(){const r=Js(this.opacity);return`${r===1?"rgb(":"rgba("}${Tr(this.r)}, ${Tr(this.g)}, ${Tr(this.b)}${r===1?")":`, ${r})`}`}function Js(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 Vl(r,e,t,n){return n<=0?r=e=t=NaN:t<=0||t>=1?r=e=NaN:e<=0&&(r=NaN),new Pt(r,e,t,n)}function od(r){if(r instanceof Pt)return new Pt(r.h,r.s,r.l,r.opacity);if(r instanceof is||(r=Un(r)),!r)return new Pt;if(r instanceof Pt)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 Pt(o,l,a,r.opacity)}function jm(r,e,t,n){return arguments.length===1?od(r):new Pt(r,e,t,n??1)}function Pt(r,e,t,n){this.h=+r,this.s=+e,this.l=+t,this.opacity=+n}da(Pt,jm,id(is,{brighter(r){return r=r==null?Xs:Math.pow(Xs,r),new Pt(this.h,this.s,this.l*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new Pt(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 wt(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 Pt(Gl(this.h),ys(this.s),ys(this.l),Js(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=Js(this.opacity);return`${r===1?"hsl(":"hsla("}${Gl(this.h)}, ${ys(this.s)*100}%, ${ys(this.l)*100}%${r===1?")":`, ${r})`}`}}));function Gl(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 ad=r=>()=>r;function Lm(r,e){return function(t){return r+t*e}}function Pm(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 Im(r){return(r=+r)==1?ld:function(e,t){return t-e?Pm(e,t,r):ad(isNaN(e)?t:e)}}function ld(r,e){var t=e-r;return t?Lm(r,t):ad(isNaN(r)?e:r)}const Kl=function r(e){var t=Im(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=ld(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 Om(r){return function(){return r}}function zm(r){return function(e){return r(e)+""}}function $m(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]?zm(a[0].x):Om(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 Yl=180/Math.PI,So={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ud(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)*Yl,skewX:Math.atan(a)*Yl,scaleX:o,scaleY:l}}var xs;function qm(r){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(r+"");return e.isIdentity?So:ud(e.a,e.b,e.c,e.d,e.e,e.f)}function Um(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,ud(r.a,r.b,r.c,r.d,r.e,r.f))}function cd(r,e,t,n){function s(u){return u.length?u.pop()+" ":""}function i(u,c,d,f,p,g){if(u!==d||c!==f){var m=p.push("translate(",null,e,null,t);g.push({i:m-4,x:fr(u,d)},{i:m-2,x:fr(c,f)})}else(d||f)&&p.push("translate("+d+e+f+t)}function o(u,c,d,f){u!==c?(u-c>180?c+=360:c-u>180&&(u+=360),f.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,f){u!==c?f.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,f,p,g){if(u!==d||c!==f){var m=p.push(s(p)+"scale(",null,",",null,")");g.push({i:m-4,x:fr(u,d)},{i:m-2,x:fr(c,f)})}else(d!==1||f!==1)&&p.push(s(p)+"scale("+d+","+f+")")}return function(u,c){var d=[],f=[];return u=r(u),c=r(c),i(u.translateX,u.translateY,c.translateX,c.translateY,d,f),o(u.rotate,c.rotate,d,f),l(u.skewX,c.skewX,d,f),a(u.scaleX,u.scaleY,c.scaleX,c.scaleY,d,f),u=c=null,function(p){for(var g=-1,m=f.length,x;++g<m;)d[(x=f[g]).i]=x.x(p);return d.join("")}}}var Wm=cd(qm,"px, ","px)","deg)"),Hm=cd(Um,", ",")",")"),Vm=1e-12;function Ql(r){return((r=Math.exp(r))+1/r)/2}function Gm(r){return((r=Math.exp(r))-1/r)/2}function Km(r){return((r=Math.exp(2*r))-1)/(r+1)}const Ym=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],f=o[2],p=c-l,g=d-a,m=p*p+g*g,x,_;if(m<Vm)_=Math.log(f/u)/e,x=function(v){return[l+v*p,a+v*g,u*Math.exp(e*v*_)]};else{var y=Math.sqrt(m),w=(f*f-u*u+n*m)/(2*u*t*y),C=(f*f-u*u-n*m)/(2*f*t*y),D=Math.log(Math.sqrt(w*w+1)-w),E=Math.log(Math.sqrt(C*C+1)-C);_=(E-D)/e,x=function(v){var k=v*_,M=Ql(D),T=u/(t*y)*(M*Km(e*k+D)-Gm(D));return[l+T*p,a+T*g,u*M/Ql(e*k+D)]}}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,dd=1e3,Zs,Sn,ei=0,Lr=0,wi=0,Wn=typeof performance=="object"&&performance.now?performance:Date,fd=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(r){setTimeout(r,17)};function fa(){return Lr||(fd(Qm),Lr=Wn.now()+wi)}function Qm(){Lr=0}function ti(){this._call=this._time=this._next=null}ti.prototype=hd.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 hd(r,e,t){var n=new ti;return n.restart(r,e,t),n}function Xm(){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{Xm()}finally{nn=0,Zm(),Lr=0}}function Jm(){var r=Wn.now(),e=r-ei;e>dd&&(wi-=e,ei=r)}function Zm(){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(Jm,dd)),nn=1,fd(Xl))}}function Jl(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 e2=la("start","end","cancel","interrupt"),t2=[],pd=0,Zl=1,Eo=2,Ss=3,eu=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;r2(r,t,{name:e,index:n,group:s,on:e2,tween:t2,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:pd})}function ha(r,e){var t=qt(r,e);if(t.state>pd)throw new Error("too late; already scheduled");return t}function Jt(r,e){var t=qt(r,e);if(t.state>Ss)throw new Error("too late; already running");return t}function qt(r,e){var t=r.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function r2(r,e,t){var n=r.__transition,s;n[e]=t,t.timer=hd(i,0,t.time);function i(u){t.state=Zl,t.timer.restart(o,t.delay,t.time),t.delay<=u&&o(u-t.delay)}function o(u){var c,d,f,p;if(t.state!==Zl)return a();for(c in n)if(p=n[c],p.name===t.name){if(p.state===Ss)return Jl(o);p.state===eu?(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(Jl(function(){t.state===Ss&&(t.state=eu,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(f=t.tween.length),c=0,d=-1;c<f;++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,f=s.length;++d<f;)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 n2(r){return this.each(function(){Es(this,r)})}function s2(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,l=n.length;o<l;++o)if(n[o].name===e){n=n.slice(),n.splice(o,1);break}}s.tween=n}}function i2(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 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 o2(r,e){var t=this._id;if(r+="",arguments.length<2){for(var n=qt(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?s2:i2)(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 qt(s,n).value[e]}}function gd(r,e){var t;return(typeof e=="number"?fr:e instanceof Un?Kl:(t=Un(e))?(e=t,Kl):$m)(r,e)}function a2(r){return function(){this.removeAttribute(r)}}function l2(r){return function(){this.removeAttributeNS(r.space,r.local)}}function u2(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 c2(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 d2(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 f2(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 h2(r,e){var t=_i(r),n=t==="transform"?Hm:gd;return this.attrTween(r,typeof e=="function"?(t.local?f2:d2)(t,n,pa(this,"attr."+r,e)):e==null?(t.local?l2:a2)(t):(t.local?c2:u2)(t,n,e))}function p2(r,e){return function(t){this.setAttribute(r,e.call(this,t))}}function g2(r,e){return function(t){this.setAttributeNS(r.space,r.local,e.call(this,t))}}function m2(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&g2(r,i)),t}return s._value=e,s}function y2(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&p2(r,i)),t}return s._value=e,s}function x2(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?m2:y2)(n,e))}function b2(r,e){return function(){ha(this,r).delay=+e.apply(this,arguments)}}function v2(r,e){return e=+e,function(){ha(this,r).delay=e}}function _2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?b2:v2)(e,r)):qt(this.node(),e).delay}function w2(r,e){return function(){Jt(this,r).duration=+e.apply(this,arguments)}}function C2(r,e){return e=+e,function(){Jt(this,r).duration=e}}function S2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?w2:C2)(e,r)):qt(this.node(),e).duration}function k2(r,e){if(typeof e!="function")throw new Error;return function(){Jt(this,r).ease=e}}function E2(r){var e=this._id;return arguments.length?this.each(k2(e,r)):qt(this.node(),e).ease}function D2(r,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;Jt(this,r).ease=t}}function A2(r){if(typeof r!="function")throw new Error;return this.each(D2(this._id,r))}function T2(r){typeof r!="function"&&(r=Yc(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 N2(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),f,p=0;p<c;++p)(f=a[p]||u[p])&&(d[p]=f);for(;l<n;++l)o[l]=e[l];return new ir(o,this._parents,this._name,this._id)}function B2(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 R2(r,e,t){var n,s,i=B2(e)?ha:Jt;return function(){var o=i(this,r),l=o.on;l!==n&&(s=(n=l).copy()).on(e,t),o.on=s}}function M2(r,e){var t=this._id;return arguments.length<2?qt(this.node(),t).on.on(r):this.each(R2(t,r,e))}function F2(r){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==r)return;e&&e.removeChild(this)}}function j2(){return this.on("end.remove",F2(this._id))}function L2(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,f=0;f<a;++f)(c=l[f])&&(d=r.call(c,c.__data__,f,l))&&("__data__"in c&&(d.__data__=c.__data__),u[f]=d,Ci(u[f],e,t,f,u,qt(c,t)));return new ir(i,this._parents,e,t)}function P2(r){var e=this._name,t=this._id;typeof r!="function"&&(r=Kc(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 f=r.call(c,c.__data__,d,a),p,g=qt(c,t),m=0,x=f.length;m<x;++m)(p=f[m])&&Ci(p,e,t,m,f,g);i.push(f),o.push(c)}return new ir(i,o,e,t)}var I2=ss.prototype.constructor;function O2(){return new I2(this._groups,this._parents)}function z2(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 md(r){return function(){this.style.removeProperty(r)}}function $2(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 q2(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 U2(r,e){var t,n,s,i="style."+e,o="end."+i,l;return function(){var a=Jt(this,r),u=a.on,c=a.value[i]==null?l||(l=md(e)):void 0;(u!==t||s!==c)&&(n=(t=u).copy()).on(o,s=c),a.on=n}}function W2(r,e,t){var n=(r+="")=="transform"?Wm:gd;return e==null?this.styleTween(r,z2(r,n)).on("end.style."+r,md(r)):typeof e=="function"?this.styleTween(r,q2(r,n,pa(this,"style."+r,e))).each(U2(this._id,r)):this.styleTween(r,$2(r,n,e),t).on("end.style."+r,null)}function H2(r,e,t){return function(n){this.style.setProperty(r,e.call(this,n),t)}}function V2(r,e,t){var n,s;function i(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&H2(r,o,t)),n}return i._value=e,i}function G2(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,V2(r,e,t??""))}function K2(r){return function(){this.textContent=r}}function Y2(r){return function(){var e=r(this);this.textContent=e??""}}function Q2(r){return this.tween("text",typeof r=="function"?Y2(pa(this,"text",r)):K2(r==null?"":r+""))}function X2(r){return function(e){this.textContent=r.call(this,e)}}function J2(r){var e,t;function n(){var s=r.apply(this,arguments);return s!==t&&(e=(t=s)&&X2(s)),e}return n._value=r,n}function Z2(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,J2(r))}function ey(){for(var r=this._name,e=this._id,t=yd(),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=qt(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 ty(){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=Jt(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 ry=0;function ir(r,e,t,n){this._groups=r,this._parents=e,this._name=t,this._id=n}function yd(){return++ry}var tr=ss.prototype;ir.prototype={constructor:ir,select:L2,selectAll:P2,selectChild:tr.selectChild,selectChildren:tr.selectChildren,filter:T2,merge:N2,selection:O2,transition:ey,call:tr.call,nodes:tr.nodes,node:tr.node,size:tr.size,empty:tr.empty,each:tr.each,on:M2,attr:h2,attrTween:x2,style:W2,styleTween:G2,text:Q2,textTween:Z2,remove:j2,tween:o2,delay:_2,duration:S2,ease:E2,easeVarying:A2,end:ty,[Symbol.iterator]:tr[Symbol.iterator]};function ny(r){return((r*=2)<=1?r*r*r:(r-=2)*r*r+2)/2}var sy={time:null,delay:0,duration:250,ease:ny};function iy(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 oy(r){var e,t;r instanceof ir?(e=r._id,r=r._name):(e=yd(),(t=sy).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||iy(a,e));return new ir(n,this._parents,r,e)}ss.prototype.interrupt=n2;ss.prototype.transition=oy;const bs=r=>()=>r;function ay(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 ly(r){return(!r.ctrlKey||r.type==="wheel")&&!r.button}function uy(){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 tu(){return this.__zoom||ri}function cy(r){return-r.deltaY*(r.deltaMode===1?.05:r.deltaMode?1:.002)*(r.ctrlKey?10:1)}function dy(){return navigator.maxTouchPoints||"ontouchstart"in this}function fy(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 hy(){var r=ly,e=uy,t=fy,n=cy,s=dy,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],l=250,a=Ym,u=la("start","zoom","end"),c,d,f,p=500,g=150,m=0,x=10;function _(S){S.property("__zoom",tu).on("wheel.zoom",k,{passive:!1}).on("mousedown.zoom",M).on("dblclick.zoom",T).filter(s).on("touchstart.zoom",N).on("touchmove.zoom",R).on("touchend.zoom touchcancel.zoom",j).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}_.transform=function(S,B,F,O){var V=S.selection?S.selection():S;V.property("__zoom",tu),S!==V?D(S,B,F,O):V.interrupt().each(function(){E(this,arguments).event(O).start().zoom(null,typeof B=="function"?B.apply(this,arguments):B).end()})},_.scaleBy=function(S,B,F,O){_.scaleTo(S,function(){var V=this.__zoom.k,U=typeof B=="function"?B.apply(this,arguments):B;return V*U},F,O)},_.scaleTo=function(S,B,F,O){_.transform(S,function(){var V=e.apply(this,arguments),U=this.__zoom,te=F==null?C(V):typeof F=="function"?F.apply(this,arguments):F,q=U.invert(te),X=typeof B=="function"?B.apply(this,arguments):B;return t(w(y(U,X),te,q),V,o)},F,O)},_.translateBy=function(S,B,F,O){_.transform(S,function(){return t(this.__zoom.translate(typeof B=="function"?B.apply(this,arguments):B,typeof F=="function"?F.apply(this,arguments):F),e.apply(this,arguments),o)},null,O)},_.translateTo=function(S,B,F,O,V){_.transform(S,function(){var U=e.apply(this,arguments),te=this.__zoom,q=O==null?C(U):typeof O=="function"?O.apply(this,arguments):O;return t(ri.translate(q[0],q[1]).scale(te.k).translate(typeof B=="function"?-B.apply(this,arguments):-B,typeof F=="function"?-F.apply(this,arguments):-F),U,o)},O,V)};function y(S,B){return B=Math.max(i[0],Math.min(i[1],B)),B===S.k?S:new nr(B,S.x,S.y)}function w(S,B,F){var O=B[0]-F[0]*S.k,V=B[1]-F[1]*S.k;return O===S.x&&V===S.y?S:new nr(S.k,O,V)}function C(S){return[(+S[0][0]+ +S[1][0])/2,(+S[0][1]+ +S[1][1])/2]}function D(S,B,F,O){S.on("start.zoom",function(){E(this,arguments).event(O).start()}).on("interrupt.zoom end.zoom",function(){E(this,arguments).event(O).end()}).tween("zoom",function(){var V=this,U=arguments,te=E(V,U).event(O),q=e.apply(V,U),X=F==null?C(q):typeof F=="function"?F.apply(V,U):F,W=Math.max(q[1][0]-q[0][0],q[1][1]-q[0][1]),se=V.__zoom,ue=typeof B=="function"?B.apply(V,U):B,de=a(se.invert(X).concat(W/se.k),ue.invert(X).concat(W/ue.k));return function(pe){if(pe===1)pe=ue;else{var De=de(pe),xe=W/De[2];pe=new nr(xe,X[0]-De[0]*xe,X[1]-De[1]*xe)}te.zoom(null,pe)}})}function E(S,B,F){return!F&&S.__zooming||new v(S,B)}function v(S,B){this.that=S,this.args=B,this.active=0,this.sourceEvent=null,this.extent=e.apply(S,B),this.taps=0}v.prototype={event:function(S){return S&&(this.sourceEvent=S),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(S,B){return this.mouse&&S!=="mouse"&&(this.mouse[1]=B.invert(this.mouse[0])),this.touch0&&S!=="touch"&&(this.touch0[1]=B.invert(this.touch0[0])),this.touch1&&S!=="touch"&&(this.touch1[1]=B.invert(this.touch1[0])),this.that.__zoom=B,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(S){var B=Lt(this.that).datum();u.call(S,this.that,new ay(S,{sourceEvent:this.sourceEvent,target:_,transform:this.that.__zoom,dispatch:u}),B)}};function k(S,...B){if(!r.apply(this,arguments))return;var F=E(this,B).event(S),O=this.__zoom,V=Math.max(i[0],Math.min(i[1],O.k*Math.pow(2,n.apply(this,arguments)))),U=wr(S);if(F.wheel)(F.mouse[0][0]!==U[0]||F.mouse[0][1]!==U[1])&&(F.mouse[1]=O.invert(F.mouse[0]=U)),clearTimeout(F.wheel);else{if(O.k===V)return;F.mouse=[U,O.invert(U)],Es(this),F.start()}xn(S),F.wheel=setTimeout(te,g),F.zoom("mouse",t(w(y(O,V),F.mouse[0],F.mouse[1]),F.extent,o));function te(){F.wheel=null,F.end()}}function M(S,...B){if(f||!r.apply(this,arguments))return;var F=S.currentTarget,O=E(this,B,!0).event(S),V=Lt(S.view).on("mousemove.zoom",X,!0).on("mouseup.zoom",W,!0),U=wr(S,F),te=S.clientX,q=S.clientY;wm(S.view),Wi(S),O.mouse=[U,this.__zoom.invert(U)],Es(this),O.start();function X(se){if(xn(se),!O.moved){var ue=se.clientX-te,de=se.clientY-q;O.moved=ue*ue+de*de>m}O.event(se).zoom("mouse",t(w(O.that.__zoom,O.mouse[0]=wr(se,F),O.mouse[1]),O.extent,o))}function W(se){V.on("mousemove.zoom mouseup.zoom",null),Cm(se.view,O.moved),xn(se),O.event(se).end()}}function T(S,...B){if(r.apply(this,arguments)){var F=this.__zoom,O=wr(S.changedTouches?S.changedTouches[0]:S,this),V=F.invert(O),U=F.k*(S.shiftKey?.5:2),te=t(w(y(F,U),O,V),e.apply(this,B),o);xn(S),l>0?Lt(this).transition().duration(l).call(D,te,O,S):Lt(this).call(_.transform,te,O,S)}}function N(S,...B){if(r.apply(this,arguments)){var F=S.touches,O=F.length,V=E(this,B,S.changedTouches.length===O).event(S),U,te,q,X;for(Wi(S),te=0;te<O;++te)q=F[te],X=wr(q,this),X=[X,this.__zoom.invert(X),q.identifier],V.touch0?!V.touch1&&V.touch0[2]!==X[2]&&(V.touch1=X,V.taps=0):(V.touch0=X,U=!0,V.taps=1+!!c);c&&(c=clearTimeout(c)),U&&(V.taps<2&&(d=X[0],c=setTimeout(function(){c=null},p)),Es(this),V.start())}}function R(S,...B){if(this.__zooming){var F=E(this,B).event(S),O=S.changedTouches,V=O.length,U,te,q,X;for(xn(S),U=0;U<V;++U)te=O[U],q=wr(te,this),F.touch0&&F.touch0[2]===te.identifier?F.touch0[0]=q:F.touch1&&F.touch1[2]===te.identifier&&(F.touch1[0]=q);if(te=F.that.__zoom,F.touch1){var W=F.touch0[0],se=F.touch0[1],ue=F.touch1[0],de=F.touch1[1],pe=(pe=ue[0]-W[0])*pe+(pe=ue[1]-W[1])*pe,De=(De=de[0]-se[0])*De+(De=de[1]-se[1])*De;te=y(te,Math.sqrt(pe/De)),q=[(W[0]+ue[0])/2,(W[1]+ue[1])/2],X=[(se[0]+de[0])/2,(se[1]+de[1])/2]}else if(F.touch0)q=F.touch0[0],X=F.touch0[1];else return;F.zoom("touch",t(w(te,q,X),F.extent,o))}}function j(S,...B){if(this.__zooming){var F=E(this,B).event(S),O=S.changedTouches,V=O.length,U,te;for(Wi(S),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),U=0;U<V;++U)te=O[U],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 q=Lt(this).on("dblclick.zoom");q&&q.apply(this,arguments)}}}return _.wheelDelta=function(S){return arguments.length?(n=typeof S=="function"?S:bs(+S),_):n},_.filter=function(S){return arguments.length?(r=typeof S=="function"?S:bs(!!S),_):r},_.touchable=function(S){return arguments.length?(s=typeof S=="function"?S:bs(!!S),_):s},_.extent=function(S){return arguments.length?(e=typeof S=="function"?S:bs([[+S[0][0],+S[0][1]],[+S[1][0],+S[1][1]]]),_):e},_.scaleExtent=function(S){return arguments.length?(i[0]=+S[0],i[1]=+S[1],_):[i[0],i[1]]},_.translateExtent=function(S){return arguments.length?(o[0][0]=+S[0][0],o[1][0]=+S[1][0],o[0][1]=+S[0][1],o[1][1]=+S[1][1],_):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},_.constrain=function(S){return arguments.length?(t=S,_):t},_.duration=function(S){return arguments.length?(l=+S,_):l},_.interpolate=function(S){return arguments.length?(a=S,_):a},_.on=function(){var S=u.on.apply(u,arguments);return S===u?_:S},_.clickDistance=function(S){return arguments.length?(m=(S=+S)*S,_):Math.sqrt(m)},_.tapDistance=function(S){return arguments.length?(x=+S,_):x},_}function xd(r={}){const{minZoom:e=.1,maxZoom:t=4,initialTransform:n,zoomable:s=!0,pannable:i=!0,onTransformChange:o}=r,l=b.useRef(null),a=b.useRef(),[u,c]=b.useState(n||{x:0,y:0,k:1});b.useEffect(()=>{if(!l.current)return;const x=hy().scaleExtent([e,t]).filter(y=>!s&&y.type==="wheel"||!i&&(y.type==="mousedown"||y.type==="touchstart")?!1:y.type==="wheel"?s:y.type==="mousedown"||y.type==="touchstart"?y.target.closest("[data-qmap-node]")?!1:i:!0).on("zoom",y=>{const w={x:y.transform.x,y:y.transform.y,k:y.transform.k};c(w),o==null||o(w)});a.current=x;const _=Lt(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]),b.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=b.useCallback((x,_,y,w=!0)=>{if(!l.current||!a.current)return;const C=Lt(l.current),D=ri.translate(x,_).scale(y);C.call(a.current.transform,D)},[]),f=b.useCallback(()=>{!l.current||!a.current||Lt(l.current).call(a.current.scaleBy,1.3)},[]),p=b.useCallback(()=>{!l.current||!a.current||Lt(l.current).call(a.current.scaleBy,.7)},[]),g=b.useCallback(()=>{d(0,0,1,!0)},[d]),m=b.useCallback((x,_=50)=>{if(!l.current||!a.current||x.length===0)return;const w=l.current.getBoundingClientRect();let C=1/0,D=1/0,E=-1/0,v=-1/0;for(const O of x){const V=O.width||200,U=O.height||100;C=Math.min(C,O.x),D=Math.min(D,O.y),E=Math.max(E,O.x+V),v=Math.max(v,O.y+U)}const k=E-C,M=v-D,T=(w.width-_*2)/k,N=(w.height-_*2)/M,R=Math.min(T,N,t),j=(C+E)/2,S=(D+v)/2,B=w.width/2-j*R,F=w.height/2-S*R;d(B,F,R,!0)},[t,d]);return{transform:u,containerRef:l,zoomTo:d,zoomIn:f,zoomOut:p,resetZoom:g,fitToContent:m}}function bd(r){const{transform:e,onDragStart:t,onDragMove:n,onDragEnd:s,disabled:i=!1}=r,[o,l]=b.useState(null),[a,u]=b.useState(!1),[c,d]=b.useState({x:0,y:0}),f=b.useRef(null),p=b.useRef({x:0,y:0}),g=b.useRef(e);b.useEffect(()=>{g.current=e},[e]);const m=b.useCallback((w,C)=>{const D=g.current;return{x:(w-D.x)/D.k,y:(C-D.y)/D.k}},[]),x=b.useCallback((w,C)=>{if(i)return;C.preventDefault(),C.stopPropagation();const D=C.currentTarget,E=parseFloat(D.dataset.x||"0"),v=parseFloat(D.dataset.y||"0");f.current={x:C.clientX,y:C.clientY,nodeX:E,nodeY:v},p.current={x:E,y:v},l(w),u(!0),d({x:0,y:0}),t==null||t(w)},[i,m,t]),_=b.useCallback(w=>{if(!a||!o||!f.current)return;const C=g.current,D=f.current,E=w.clientX-D.x,v=w.clientY-D.y,k=E/C.k,M=v/C.k,T=D.nodeX+k,N=D.nodeY+M;p.current={x:T,y:N},d({x:k,y:M}),n==null||n(o,T,N,k,M)},[a,o,n]),y=b.useCallback(()=>{if(!a||!o)return;const w=p.current;s==null||s(o,w.x,w.y),l(null),u(!1),d({x:0,y:0}),f.current=null},[a,o,s]);return b.useEffect(()=>{if(!a)return;const w=D=>{_(D)},C=()=>{y()};return window.addEventListener("mousemove",w),window.addEventListener("mouseup",C),()=>{window.removeEventListener("mousemove",w),window.removeEventListener("mouseup",C)}},[a,_,y]),{draggedNodeId:o,isDragging:a,dragOffset:c,startDrag:x,updateDrag:_,endDrag:y}}function vd(r){const{transform:e,nodePositions:t,disabled:n=!1,controlledSelectedIds:s,onSelectionChange:i}=r,[o,l]=b.useState(new Set),a=s!==void 0,u=a?new Set(s):o,c=a?T=>{const N=typeof T=="function"?T(u):T;i==null||i(Array.from(N))}:l,[d,f]=b.useState(null),[p,g]=b.useState(!1),m=b.useRef(null),x=b.useRef(e),_=b.useRef(t);b.useEffect(()=>{x.current=e},[e]),b.useEffect(()=>{_.current=t},[t]);const y=b.useCallback((T,N)=>{const R=x.current;return{x:(T-R.x)/R.k,y:(N-R.y)/R.k}},[]),w=b.useCallback((T,N)=>{const R=_.current.get(T);if(!R)return!1;const j=R.width||200,S=R.height||100;return R.x<N.x+N.width&&R.x+j>N.x&&R.y<N.y+N.height&&R.y+S>N.y},[]),C=b.useCallback(T=>{if(n||T.target.closest("[data-qmap-node]"))return;T.preventDefault();const R=y(T.clientX,T.clientY);m.current=R,f({x:R.x,y:R.y,width:0,height:0}),g(!0),T.shiftKey||c(new Set)},[n,y]),D=b.useCallback(T=>{if(!p||!m.current)return;const N=m.current,R=y(T.clientX,T.clientY),j={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)};f(j);const S=new Set;for(const[B]of _.current)w(B,j)&&S.add(B);c(S)},[p,y,w]),E=b.useCallback(()=>{p&&(i==null||i(Array.from(u)),g(!1),f(null),m.current=null)},[p,u,i]);b.useEffect(()=>{if(!p)return;const T=R=>{D(R)},N=()=>{E()};return window.addEventListener("mousemove",T),window.addEventListener("mouseup",N),()=>{window.removeEventListener("mousemove",T),window.removeEventListener("mouseup",N)}},[p,D,E]);const v=b.useCallback((T,N=!1)=>{c(R=>{const j=new Set(N?R:[]);return R.has(T)&&N?j.delete(T):j.add(T),i==null||i(Array.from(j)),j})},[i]),k=b.useCallback(()=>{const T=new Set(_.current.keys());c(T),i==null||i(Array.from(T))},[i]),M=b.useCallback(()=>{c(new Set),i==null||i([])},[i]);return{selectedIds:u,setSelectedIds:c,selectionBox:d,isSelecting:p,startSelection:C,updateSelection:D,endSelection:E,toggleSelect:v,selectAll:k,clearSelection:M}}const _d=b.memo(function({nodeId:e,position:t,isSelected:n,isDragging:s,draggable:i,onDragStart:o,onClick:l,onDoubleClick:a,onContextMenu:u,children:c}){const d=b.useCallback(y=>{i&&y.button===0&&o(e,y)},[e,i,o]),f=b.useCallback(y=>{s||l==null||l(y)},[s,l]),p=b.useCallback(y=>{y.stopPropagation(),a==null||a(y)},[a]),g=b.useCallback(y=>{y.preventDefault(),y.stopPropagation(),u==null||u(y)},[u]),m=t.width||200,x=t.height||100,_=t.rotation||0;return h.jsx("div",{"data-qmap-node":e,"data-x":t.x,"data-y":t.y,style:{position:"absolute",left:t.x,top:t.y,width:m,height:x,transform:_!==0?`rotate(${_}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:d,onClick:f,onDoubleClick:p,onContextMenu:g,children:c})},(r,e)=>r.nodeId===e.nodeId&&r.position.x===e.position.x&&r.position.y===e.position.y&&r.position.width===e.position.width&&r.position.height===e.position.height&&r.position.rotation===e.position.rotation&&r.isSelected===e.isSelected&&r.isDragging===e.isDragging&&r.draggable===e.draggable&&r.children===e.children);function wd(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 gy(n,s);case"bezier":default:return py(n,s)}}function py(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 gy(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 my(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,f;return u<c?(d=s.x+(i>0?l:-l),f=s.y+o*l/Math.abs(i)):(f=s.y+(o>0?a:-a),d=s.x+i*a/Math.abs(o)),{x:d,y:f}}function yy(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 xy(r,e){return r.x>=e.x&&r.x<=e.x+e.width&&r.y>=e.y&&r.y<=e.y+e.height}function by(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 vy(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 _y(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.sqrt(t*t+n*n)}function wy(r,e){const t=e.x-r.x,n=e.y-r.y;return t*t+n*n}const Cd=b.memo(function({edge:e,sourcePosition:t,targetPosition:n,style:s,color:i,width:o,onClick:l}){const[a,u]=b.useState(!1),c=b.useMemo(()=>wd(t,n,s),[t,n,s]),d=b.useCallback(x=>{x.stopPropagation(),l==null||l(e,x)},[e,l]),f=b.useCallback(()=>{u(!0)},[]),p=b.useCallback(()=>{u(!1)},[]),g=e.color||i,m=e.width||o;return h.jsxs("g",{children:[h.jsx("path",{d:c,fill:"none",stroke:"transparent",strokeWidth:Math.max(m*3,10),style:{cursor:l?"pointer":"default",pointerEvents:"stroke"},onClick:d,onMouseEnter:f,onMouseLeave:p}),h.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&&h.jsx(Cy,{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 Cy({pathD:r,label:e,color:t}){const n=b.useMemo(()=>`edge-label-${Math.random().toString(36).substr(2,9)}`,[]);return h.jsxs(h.Fragment,{children:[h.jsx("defs",{children:h.jsx("path",{id:n,d:r})}),h.jsx("text",{fill:t,fontSize:"12",fontFamily:"system-ui, sans-serif",style:{pointerEvents:"none"},children:h.jsx("textPath",{href:`#${n}`,startOffset:"50%",textAnchor:"middle",children:e})})]})}const Sd=b.memo(function({edges:e,nodePositions:t,defaultStyle:n,defaultColor:s,defaultWidth:i,onEdgeClick:o}){const l=b.useMemo(()=>e.filter(a=>t.has(a.source)&&t.has(a.target)),[e,t]);return h.jsx("svg",{style:{position:"absolute",top:0,left:0,width:1,height:1,overflow:"visible",pointerEvents:"none"},children:h.jsx("g",{style:{pointerEvents:"auto"},children:l.map(a=>{const u=t.get(a.source),c=t.get(a.target);return h.jsx(Cd,{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)),kd=b.memo(function({box:e,transform:t}){const n=b.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 h.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}})}),Sy=200,ky=100,Ey="bezier",Dy="#94a3b8",Ay=2,Ty=.1,Ny=4;function By({viewNode:r,nodes:e,edges:t,renderNode:n,defaultNodeWidth:s=Sy,defaultNodeHeight:i=ky,onNodeMove:o,onNodeClick:l,onNodeDoubleClick:a,onNodeContextMenu:u,selectedIds:c,onSelectionChange:d,onEdgeClick:f,onViewChange:p,onTransformChange:g,minZoom:m=Ty,maxZoom:x=Ny,initialTransform:_,defaultEdgeStyle:y=Ey,defaultEdgeColor:w=Dy,defaultEdgeWidth:C=Ay,draggable:D=!0,selectable:E=!0,zoomable:v=!0,pannable:k=!0,className:M="",style:T,background:N="#f8fafc",showGrid:R=!1,gridSize:j=20}){const S=r.data||{positions:{}},B=S.positions||{},F=b.useMemo(()=>{const Y=new Map;for(const P of e){const me=B[P._id]||{x:0,y:0};Y.set(P._id,{x:me.x,y:me.y,width:me.width||s,height:me.height||i,rotation:me.rotation||0})}return Y},[e,B,s,i]),{transform:O,containerRef:V,zoomIn:U,zoomOut:te,resetZoom:q,fitToContent:X}=xd({minZoom:m,maxZoom:x,initialTransform:_||S.transform,zoomable:v,pannable:k,onTransformChange:Y=>{g==null||g(Y);const P={...S,transform:Y};p==null||p(P)}}),[W,se]=b.useState(new Map),{draggedNodeId:ue,startDrag:de}=bd({transform:O,disabled:!D,onDragStart:Y=>{const P=F.get(Y);P&&se(new Map([[Y,{x:P.x,y:P.y}]]))},onDragMove:(Y,P,me)=>{se(new Map([[Y,{x:P,y:me}]]))},onDragEnd:(Y,P,me)=>{se(new Map),o==null||o(Y,P,me)}}),{selectedIds:pe,selectionBox:De,isSelecting:xe,startSelection:J,toggleSelect:Ce,clearSelection:ne}=vd({transform:O,nodePositions:F,disabled:!E,controlledSelectedIds:c,onSelectionChange:d}),Be=b.useCallback(Y=>{const P=F.get(Y)||{x:0,y:0,width:s,height:i},me=W.get(Y);return me?{...P,x:me.x,y:me.y}:P},[F,W,s,i]),Se=b.useMemo(()=>{const Y=new Map;for(const P of F.keys())Y.set(P,Be(P));return Y},[F,Be]),ke=b.useCallback((Y,P)=>{Ce(Y._id,P.shiftKey),l==null||l(Y,P)},[Ce,l]),Ie=b.useCallback(Y=>{Y.target.closest("[data-qmap-node]")||ne()},[ne]),Le=b.useCallback(Y=>{Y.button===0&&(Y.target.closest("[data-qmap-node]")||J(Y))},[J]),$e=R?`
185
+ ${y}`:y)},x=async y=>{if(!(!e.trim()||a||!s)){u(!0),d(y),p(!1);try{const _=await s(y,e);t(_)}catch(_){console.error(`${y} failed:`,_)}finally{u(!1),d(null)}}},v=()=>{setTimeout(()=>{var y;(y=g.current)!=null&&y.contains(document.activeElement)||p(!1)},150)};return h.jsxs("div",{className:`flex flex-col flex-1 min-h-0 ${o}`,children:[h.jsx(Vc,{onComplete:()=>{},onTranscribe:n,onTranscriptionComplete:m,hideSaveButton:!0,variant:"div"}),h.jsxs("div",{className:"flex items-center justify-between mt-3 mb-1",children:[h.jsx("label",{className:"text-sm font-medium text-neutral-700",children:r}),h.jsxs("div",{className:"flex items-center gap-1",children:[e.trim()&&h.jsx("button",{type:"button",onClick:()=>navigator.clipboard.writeText(e),className:"p-1 rounded hover:bg-neutral-100 transition-colors",title:"Copy to clipboard",children:h.jsx("span",{className:"material-icons text-neutral-500",style:{fontSize:"16px"},children:"content_copy"})}),s&&h.jsxs("div",{className:"relative",ref:g,children:[h.jsx("button",{type:"button",onClick:()=>p(!f),disabled:a||!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:a?h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons text-sm animate-spin",children:"hourglass_empty"}),c==="restructure"&&"Restructuring...",c==="proofread"&&"Proofreading...",c==="rewrite"&&"Rewriting..."]}):h.jsxs(h.Fragment,{children:[h.jsx("span",{className:"material-icons text-sm",children:"auto_fix_high"}),"AI",h.jsx("span",{className:"material-icons text-sm",children:"expand_more"})]})}),f&&!a&&h.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:v,children:[h.jsxs("button",{type:"button",onClick:()=>x("restructure"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-blue-500",children:"format_list_bulleted"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Restructure"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Organize & clarify"})]})]}),h.jsxs("button",{type:"button",onClick:()=>x("proofread"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-green-500",children:"spellcheck"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Proofread"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Fix grammar & spelling"})]})]}),h.jsxs("button",{type:"button",onClick:()=>x("rewrite"),className:"w-full px-3 py-2 text-left text-sm hover:bg-neutral-50 flex items-center gap-2",children:[h.jsx("span",{className:"material-icons text-base text-purple-500",children:"brush"}),h.jsxs("div",{children:[h.jsx("div",{className:"font-medium",children:"Rewrite"}),h.jsx("div",{className:"text-xs text-neutral-500",children:"Your voice & style"})]})]})]})]})]})]}),h.jsx("textarea",{value:e,onChange:y=>t(y.target.value),onKeyDown:y=>y.stopPropagation(),placeholder:i,rows:l,disabled:a,className:"flex-1 w-full px-3 py-2 border border-neutral-300 rounded-lg focus:ring-2 focus:ring-neutral-900 text-sm disabled:opacity-50 disabled:bg-neutral-50 resize-none"})]})}const gs={"4/3":4/3,"16/9":16/9,"1/1":1,"3/4":3/4,"9/16":9/16,free:null};function Og({src:r,onSave:e,onCancel:t,aspectRatio:n="4/3",outputFormat:s="image/jpeg",outputQuality:i=.9,theme:o="dark"}){const l=b.useRef(null),a=b.useRef(null),u=b.useRef(null),[c,d]=b.useState(!0),[f,p]=b.useState(null),[g,m]=b.useState(n),[x,v]=b.useState(0),[y,_]=b.useState({x:0,y:0,width:100,height:100}),[S,E]=b.useState(!1),[k,w]=b.useState(null),[D,j]=b.useState({x:0,y:0}),[B,T]=b.useState({x:0,y:0,width:100,height:100}),R=o==="dark",M=b.useCallback(()=>{const J=u.current;return J?x===90||x===270?{width:J.height,height:J.width}:{width:J.width,height:J.height}:{width:100,height:100}},[x]),C=b.useCallback((J,Ce)=>{const ne=J/Ce,Be=.05;for(const[Se,ke]of Object.entries(gs))if(ke!==null&&Math.abs(ne-ke)/ke<Be)return Se;return"free"},[]);b.useEffect(()=>{const J=new Image;J.crossOrigin="anonymous",J.onload=()=>{u.current=J;const Ce=C(J.width,J.height);m(Ce),d(!1)},J.onerror=()=>{p("Failed to load image"),d(!1)},J.src=r},[r,C]);const N=b.useCallback(()=>{const{width:J,height:Ce}=M(),ne=gs[g];if(ne===null){_({x:0,y:0,width:100,height:100});return}const Be=J/Ce;let Se,ke;Be>ne?(ke=100,Se=ne/Be*100):(Se=100,ke=Be/ne*100);const Ie=(100-Se)/2,Le=(100-ke)/2;_({x:Ie,y:Le,width:Se,height:ke})},[g,M]);b.useEffect(()=>{u.current&&N()},[g,x,N]),b.useEffect(()=>{const J=a.current,Ce=u.current;if(!J||!Ce||c)return;const ne=J.getContext("2d");if(!ne)return;const Be=l.current;if(!Be)return;const Se=Be.clientWidth,ke=Be.clientHeight-140,{width:Ie,height:Le}=M(),$e=Ie/Le;let Y,P;Se/ke>$e?(P=Math.min(ke,Le),Y=P*$e):(Y=Math.min(Se,Ie),P=Y/$e),Y>Se&&(Y=Se,P=Y/$e),P>ke&&(P=ke,Y=P*$e),J.width=Y,J.height=P,ne.clearRect(0,0,Y,P),ne.save(),ne.translate(Y/2,P/2),ne.rotate(x*Math.PI/180);let me,We;x===90||x===270?(me=P,We=Y):(me=Y,We=P),ne.drawImage(Ce,-me/2,-We/2,me,We),ne.restore(),ne.fillStyle="rgba(0, 0, 0, 0.6)";const $=y.x/100*Y,ae=y.y/100*P,ge=y.width/100*Y,ye=y.height/100*P;ne.fillRect(0,0,Y,ae),ne.fillRect(0,ae+ye,Y,P-ae-ye),ne.fillRect(0,ae,$,ye),ne.fillRect($+ge,ae,Y-$-ge,ye),ne.strokeStyle="#fff",ne.lineWidth=2,ne.strokeRect($,ae,ge,ye),ne.strokeStyle="rgba(255, 255, 255, 0.3)",ne.lineWidth=1,ne.beginPath(),ne.moveTo($+ge/3,ae),ne.lineTo($+ge/3,ae+ye),ne.moveTo($+ge*2/3,ae),ne.lineTo($+ge*2/3,ae+ye),ne.moveTo($,ae+ye/3),ne.lineTo($+ge,ae+ye/3),ne.moveTo($,ae+ye*2/3),ne.lineTo($+ge,ae+ye*2/3),ne.stroke();const Ue=14;ne.fillStyle="#fff",ne.strokeStyle="#333",ne.lineWidth=1,[{x:$,y:ae},{x:$+ge,y:ae},{x:$,y:ae+ye},{x:$+ge,y:ae+ye}].forEach(yt=>{ne.fillRect(yt.x-Ue/2,yt.y-Ue/2,Ue,Ue),ne.strokeRect(yt.x-Ue/2,yt.y-Ue/2,Ue,Ue)})},[y,x,c,M]);const F=J=>{const Ce=a.current;if(!Ce)return;const ne=Ce.getBoundingClientRect(),Be=(J.clientX-ne.left)/ne.width*100,Se=(J.clientY-ne.top)/ne.height*100,ke=4,Ie=[{name:"nw",x:y.x,y:y.y},{name:"ne",x:y.x+y.width,y:y.y},{name:"sw",x:y.x,y:y.y+y.height},{name:"se",x:y.x+y.width,y:y.y+y.height}];for(const Le of Ie)if(Math.abs(Be-Le.x)<ke&&Math.abs(Se-Le.y)<ke){w(Le.name),j({x:Be,y:Se}),T({...y});return}Be>=y.x&&Be<=y.x+y.width&&Se>=y.y&&Se<=y.y+y.height&&(E(!0),j({x:Be,y:Se}),T({...y}))},I=J=>{const Ce=a.current;if(!Ce)return;const ne=Ce.getBoundingClientRect(),Be=(J.clientX-ne.left)/ne.width*100,Se=(J.clientY-ne.top)/ne.height*100;if(S){const ke=Be-D.x,Ie=Se-D.y;let Le=B.x+ke,$e=B.y+Ie;Le=Math.max(0,Math.min(Le,100-B.width)),$e=Math.max(0,Math.min($e,100-B.height)),_({...B,x:Le,y:$e})}else if(k){const ke=gs[g],{width:Ie,height:Le}=M(),$e=Ie/Le,Y=ke?ke/$e:null;let P={...B};const me=Be-D.x,We=Se-D.y;if(k==="se")P.width=Math.max(10,Math.min(100-P.x,B.width+me)),Y?(P.height=P.width/Y,P.y+P.height>100&&(P.height=100-P.y,P.width=P.height*Y)):P.height=Math.max(10,Math.min(100-P.y,B.height+We));else if(k==="sw"){const $=-me,ae=Math.max(10,B.width+$),ge=B.x+B.width-ae;ge>=0&&(P.width=ae,P.x=ge,Y?(P.height=P.width/Y,P.y+P.height>100&&(P.height=100-P.y,P.width=P.height*Y,P.x=B.x+B.width-P.width)):P.height=Math.max(10,Math.min(100-P.y,B.height+We)))}else if(k==="ne")if(P.width=Math.max(10,Math.min(100-P.x,B.width+me)),Y){const $=P.width/Y,ae=B.y+B.height-$;ae>=0?(P.height=$,P.y=ae):(P.y=0,P.height=B.y+B.height,P.width=P.height*Y)}else{const $=-We,ae=Math.max(10,B.height+$),ge=B.y+B.height-ae;ge>=0&&(P.height=ae,P.y=ge)}else if(k==="nw"){const $=-me,ae=Math.max(10,B.width+$),ge=B.x+B.width-ae;if(ge>=0)if(P.width=ae,P.x=ge,Y){const ye=P.width/Y,Ue=B.y+B.height-ye;Ue>=0?(P.height=ye,P.y=Ue):(P.y=0,P.height=B.y+B.height,P.width=P.height*Y,P.x=B.x+B.width-P.width)}else{const ye=-We,Ue=Math.max(10,B.height+ye),mt=B.y+B.height-Ue;mt>=0&&(P.height=Ue,P.y=mt)}}P.x=Math.max(0,P.x),P.y=Math.max(0,P.y),P.width=Math.min(P.width,100-P.x),P.height=Math.min(P.height,100-P.y),_(P)}},W=()=>{E(!1),w(null)},z=J=>{v(Ce=>J==="right"?(Ce+90)%360:(Ce-90+360)%360)},te=()=>{const J=u.current;if(!J)return;const{width:Ce,height:ne}=M(),Be=y.x/100*Ce,Se=y.y/100*ne,ke=y.width/100*Ce,Ie=y.height/100*ne,Le=document.createElement("canvas"),$e=Le.getContext("2d");if(!$e)return;Le.width=ke,Le.height=Ie;const Y=document.createElement("canvas"),P=Y.getContext("2d");P&&(Y.width=Ce,Y.height=ne,P.save(),P.translate(Ce/2,ne/2),P.rotate(x*Math.PI/180),P.drawImage(J,-J.width/2,-J.height/2,J.width,J.height),P.restore(),$e.drawImage(Y,Be,Se,ke,Ie,0,0,ke,Ie),Le.toBlob(me=>{me&&e(me)},s,i))},U={display:"flex",flexDirection:"column",width:"100%",height:"100%",background:R?"#1a1a1a":"#f5f5f5",overflow:"hidden"},Q={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"},ue={padding:"10px 20px",borderRadius:"8px",border:"none",cursor:"pointer",fontSize:"14px",fontWeight:500,transition:"background 0.15s, opacity 0.15s"},de={...ue,background:"#E67E22",color:"#fff"},pe={...ue,background:R?"#333":"#e5e5e5",color:R?"#fff":"#333"},De={padding:"10px",borderRadius:"8px",border:"none",background:R?"#333":"#e5e5e5",color:R?"#fff":"#333",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"center"},xe=J=>({padding:"8px 14px",borderRadius:"6px",border:J?"2px solid #E67E22":"2px solid transparent",background:J?"#E67E22":R?"#333":"#e5e5e5",color:J?"#fff":R?"#ccc":"#666",cursor:"pointer",fontSize:"13px",fontWeight:600,transition:"all 0.15s"});return c?h.jsx("div",{style:{...U,alignItems:"center",justifyContent:"center"},children:h.jsx("div",{style:{color:R?"#aaa":"#666"},children:"Loading image..."})}):f?h.jsxs("div",{style:{...U,alignItems:"center",justifyContent:"center"},children:[h.jsx("div",{style:{color:"#ef4444"},children:f}),t&&h.jsx("button",{onClick:t,style:{...pe,marginTop:"16px"},children:"Close"})]}):h.jsxs("div",{ref:l,style:U,children:[h.jsx("div",{style:Q,children:h.jsx("canvas",{ref:a,style:{cursor:S?"grabbing":k?"nwse-resize":"grab",maxWidth:"100%",maxHeight:"100%"},onMouseDown:F,onMouseMove:I,onMouseUp:W,onMouseLeave:W})}),h.jsxs("div",{style:H,children:[h.jsx("div",{style:{display:"flex",gap:"8px",flexWrap:"wrap",justifyContent:"center"},children:Object.keys(gs).map(J=>h.jsx("button",{onClick:()=>m(J),style:xe(g===J),children:J==="free"?"Libre":J},J))}),h.jsxs("div",{style:se,children:[h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[h.jsx("button",{onClick:()=>z("left"),style:De,title:"Rotate left",children:h.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"M2.5 2v6h6M2.66 15.57a10 10 0 1 0 .57-8.38"})})}),h.jsx("button",{onClick:()=>z("right"),style:De,title:"Rotate right",children:h.jsx("svg",{width:"22",height:"22",viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",children:h.jsx("path",{d:"M21.5 2v6h-6M21.34 15.57a10 10 0 1 1-.57-8.38"})})})]}),h.jsxs("div",{style:{display:"flex",gap:"8px"},children:[t&&h.jsx("button",{onClick:t,style:pe,children:"Annuler"}),h.jsx("button",{onClick:te,style:de,children:"Enregistrer"})]})]})]})]})}var zg={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 $g(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=$g(r+"",t),s,i=-1,o=n.length;if(arguments.length<2){for(;++i<o;)if((s=(r=n[i]).type)&&(s=qg(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]=Il(t[s],r.name,e);else if(e==null)for(s in t)t[s]=Il(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 qg(r,e){for(var t=0,n=r.length,s;t<n;++t)if((s=r[t]).name===e)return s.value}function Il(r,e,t){for(var n=0,s=r.length;n<s;++n)if(r[n].name===e){r[n]=zg,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 Ug(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 Wg(r){return function(){return this.ownerDocument.createElementNS(r.space,r.local)}}function Gc(r){var e=_i(r);return(e.local?Wg:Ug)(e)}function Hg(){}function ua(r){return r==null?Hg:function(){return this.querySelector(r)}}function Vg(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 Dt(n,this._parents)}function Gg(r){return r==null?[]:Array.isArray(r)?r:Array.from(r)}function Kg(){return[]}function Kc(r){return r==null?Kg:function(){return this.querySelectorAll(r)}}function Yg(r){return function(){return Gg(r.apply(this,arguments))}}function Qg(r){typeof r=="function"?r=Yg(r):r=Kc(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 Dt(n,s)}function Yc(r){return function(){return this.matches(r)}}function Qc(r){return function(e){return e.matches(r)}}var Xg=Array.prototype.find;function Jg(r){return function(){return Xg.call(this.children,r)}}function Zg(){return this.firstElementChild}function e0(r){return this.select(r==null?Zg:Jg(typeof r=="function"?r:Qc(r)))}var t0=Array.prototype.filter;function r0(){return Array.from(this.children)}function n0(r){return function(){return t0.call(this.children,r)}}function s0(r){return this.selectAll(r==null?r0:n0(typeof r=="function"?r:Qc(r)))}function i0(r){typeof r!="function"&&(r=Yc(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 Dt(n,this._parents)}function Xc(r){return new Array(r.length)}function o0(){return new Dt(this._enter||this._groups.map(Xc),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 a0(r){return function(){return r}}function l0(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 u0(r,e,t,n,s,i,o){var l,a,u=new Map,c=e.length,d=i.length,f=new Array(c),p;for(l=0;l<c;++l)(a=e[l])&&(f[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(f[l])===a&&(s[l]=a)}function c0(r){return r.__data__}function d0(r,e){if(!arguments.length)return Array.from(this,c0);var t=e?u0:l0,n=this._parents,s=this._groups;typeof r!="function"&&(r=a0(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],f=d.length,p=f0(r.call(c,c&&c.__data__,u,n)),g=p.length,m=l[u]=new Array(g),x=o[u]=new Array(g),v=a[u]=new Array(f);t(c,d,m,x,v,p,e);for(var y=0,_=0,S,E;y<g;++y)if(S=m[y]){for(y>=_&&(_=y+1);!(E=x[_])&&++_<g;);S._next=E||null}}return o=new Dt(o,n),o._enter=l,o._exit=a,o}function f0(r){return typeof r=="object"&&"length"in r?r:Array.from(r)}function h0(){return new Dt(this._exit||this._groups.map(Xc),this._parents)}function p0(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 g0(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,f=l[a]=new Array(d),p,g=0;g<d;++g)(p=u[g]||c[g])&&(f[g]=p);for(;a<s;++a)l[a]=t[a];return new Dt(l,this._parents)}function m0(){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 y0(r){r||(r=x0);function e(d,f){return d&&f?r(d.__data__,f.__data__):!d-!f}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 Dt(s,this._parents).order()}function x0(r,e){return r<e?-1:r>e?1:r>=e?0:NaN}function b0(){var r=arguments[0];return arguments[0]=this,r.apply(null,arguments),this}function v0(){return Array.from(this)}function _0(){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 w0(){let r=0;for(const e of this)++r;return r}function C0(){return!this.node()}function S0(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 k0(r){return function(){this.removeAttribute(r)}}function E0(r){return function(){this.removeAttributeNS(r.space,r.local)}}function D0(r,e){return function(){this.setAttribute(r,e)}}function A0(r,e){return function(){this.setAttributeNS(r.space,r.local,e)}}function T0(r,e){return function(){var t=e.apply(this,arguments);t==null?this.removeAttribute(r):this.setAttribute(r,t)}}function N0(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 B0(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?E0:k0:typeof e=="function"?t.local?N0:T0:t.local?A0:D0)(t,e))}function Jc(r){return r.ownerDocument&&r.ownerDocument.defaultView||r.document&&r||r.defaultView}function R0(r){return function(){this.style.removeProperty(r)}}function M0(r,e,t){return function(){this.style.setProperty(r,e,t)}}function F0(r,e,t){return function(){var n=e.apply(this,arguments);n==null?this.style.removeProperty(r):this.style.setProperty(r,n,t)}}function j0(r,e,t){return arguments.length>1?this.each((e==null?R0:typeof e=="function"?F0:M0)(r,e,t??"")):rn(this.node(),r)}function rn(r,e){return r.style.getPropertyValue(e)||Jc(r).getComputedStyle(r,null).getPropertyValue(e)}function L0(r){return function(){delete this[r]}}function P0(r,e){return function(){this[r]=e}}function I0(r,e){return function(){var t=e.apply(this,arguments);t==null?delete this[r]:this[r]=t}}function O0(r,e){return arguments.length>1?this.each((e==null?L0:typeof e=="function"?I0:P0)(r,e)):this.node()[r]}function Zc(r){return r.trim().split(/^|\s+/)}function ca(r){return r.classList||new ed(r)}function ed(r){this._node=r,this._names=Zc(r.getAttribute("class")||"")}ed.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 td(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.add(e[n])}function rd(r,e){for(var t=ca(r),n=-1,s=e.length;++n<s;)t.remove(e[n])}function z0(r){return function(){td(this,r)}}function $0(r){return function(){rd(this,r)}}function q0(r,e){return function(){(e.apply(this,arguments)?td:rd)(this,r)}}function U0(r,e){var t=Zc(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"?q0:e?z0:$0)(t,e))}function W0(){this.textContent=""}function H0(r){return function(){this.textContent=r}}function V0(r){return function(){var e=r.apply(this,arguments);this.textContent=e??""}}function G0(r){return arguments.length?this.each(r==null?W0:(typeof r=="function"?V0:H0)(r)):this.node().textContent}function K0(){this.innerHTML=""}function Y0(r){return function(){this.innerHTML=r}}function Q0(r){return function(){var e=r.apply(this,arguments);this.innerHTML=e??""}}function X0(r){return arguments.length?this.each(r==null?K0:(typeof r=="function"?Q0:Y0)(r)):this.node().innerHTML}function J0(){this.nextSibling&&this.parentNode.appendChild(this)}function Z0(){return this.each(J0)}function em(){this.previousSibling&&this.parentNode.insertBefore(this,this.parentNode.firstChild)}function tm(){return this.each(em)}function rm(r){var e=typeof r=="function"?r:Gc(r);return this.select(function(){return this.appendChild(e.apply(this,arguments))})}function nm(){return null}function sm(r,e){var t=typeof r=="function"?r:Gc(r),n=e==null?nm:typeof e=="function"?e:ua(e);return this.select(function(){return this.insertBefore(t.apply(this,arguments),n.apply(this,arguments)||null)})}function im(){var r=this.parentNode;r&&r.removeChild(this)}function om(){return this.each(im)}function am(){var r=this.cloneNode(!1),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function lm(){var r=this.cloneNode(!0),e=this.parentNode;return e?e.insertBefore(r,this.nextSibling):r}function um(r){return this.select(r?lm:am)}function cm(r){return arguments.length?this.property("__data__",r):this.node().__data__}function dm(r){return function(e){r.call(this,e,this.__data__)}}function fm(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 hm(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 pm(r,e,t){return function(){var n=this.__on,s,i=dm(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 gm(r,e,t){var n=fm(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?pm:hm,s=0;s<i;++s)this.each(l(n[s],e,t));return this}function nd(r,e,t){var n=Jc(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 mm(r,e){return function(){return nd(this,r,e)}}function ym(r,e){return function(){return nd(this,r,e.apply(this,arguments))}}function xm(r,e){return this.each((typeof e=="function"?ym:mm)(r,e))}function*bm(){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 sd=[null];function Dt(r,e){this._groups=r,this._parents=e}function ss(){return new Dt([[document.documentElement]],sd)}function vm(){return this}Dt.prototype=ss.prototype={constructor:Dt,select:Vg,selectAll:Qg,selectChild:e0,selectChildren:s0,filter:i0,data:d0,enter:o0,exit:h0,join:p0,merge:g0,selection:vm,order:m0,sort:y0,call:b0,nodes:v0,node:_0,size:w0,empty:C0,each:S0,attr:B0,style:j0,property:O0,classed:U0,text:G0,html:X0,raise:Z0,lower:tm,append:rm,insert:sm,remove:om,clone:um,datum:cm,on:gm,dispatch:xm,[Symbol.iterator]:bm};function Lt(r){return typeof r=="string"?new Dt([[document.querySelector(r)]],[document.documentElement]):new Dt([[r]],sd)}function _m(r){let e;for(;e=r.sourceEvent;)r=e;return r}function wr(r,e){if(r=_m(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 wm(r){var e=r.document.documentElement,t=Lt(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 Cm(r,e){var t=r.document.documentElement,n=Lt(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 id(r,e){var t=Object.create(r.prototype);for(var n in e)t[n]=e[n];return t}function is(){}var $n=.7,Xs=1/$n,Xr="\\s*([+-]?\\d+)\\s*",qn="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)\\s*",Gt="\\s*([+-]?(?:\\d*\\.)?\\d+(?:[eE][+-]?\\d+)?)%\\s*",Sm=/^#([0-9a-f]{3,8})$/,km=new RegExp(`^rgb\\(${Xr},${Xr},${Xr}\\)$`),Em=new RegExp(`^rgb\\(${Gt},${Gt},${Gt}\\)$`),Dm=new RegExp(`^rgba\\(${Xr},${Xr},${Xr},${qn}\\)$`),Am=new RegExp(`^rgba\\(${Gt},${Gt},${Gt},${qn}\\)$`),Tm=new RegExp(`^hsl\\(${qn},${Gt},${Gt}\\)$`),Nm=new RegExp(`^hsla\\(${qn},${Gt},${Gt},${qn}\\)$`),zl={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:$l,formatHex:$l,formatHex8:Bm,formatHsl:Rm,formatRgb:ql,toString:ql});function $l(){return this.rgb().formatHex()}function Bm(){return this.rgb().formatHex8()}function Rm(){return od(this).formatHsl()}function ql(){return this.rgb().formatRgb()}function Un(r){var e,t;return r=(r+"").trim().toLowerCase(),(e=Sm.exec(r))?(t=e[1].length,e=parseInt(e[1],16),t===6?Ul(e):t===3?new wt(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=km.exec(r))?new wt(e[1],e[2],e[3],1):(e=Em.exec(r))?new wt(e[1]*255/100,e[2]*255/100,e[3]*255/100,1):(e=Dm.exec(r))?ms(e[1],e[2],e[3],e[4]):(e=Am.exec(r))?ms(e[1]*255/100,e[2]*255/100,e[3]*255/100,e[4]):(e=Tm.exec(r))?Vl(e[1],e[2]/100,e[3]/100,1):(e=Nm.exec(r))?Vl(e[1],e[2]/100,e[3]/100,e[4]):zl.hasOwnProperty(r)?Ul(zl[r]):r==="transparent"?new wt(NaN,NaN,NaN,0):null}function Ul(r){return new wt(r>>16&255,r>>8&255,r&255,1)}function ms(r,e,t,n){return n<=0&&(r=e=t=NaN),new wt(r,e,t,n)}function Mm(r){return r instanceof is||(r=Un(r)),r?(r=r.rgb(),new wt(r.r,r.g,r.b,r.opacity)):new wt}function wo(r,e,t,n){return arguments.length===1?Mm(r):new wt(r,e,t,n??1)}function wt(r,e,t,n){this.r=+r,this.g=+e,this.b=+t,this.opacity=+n}da(wt,wo,id(is,{brighter(r){return r=r==null?Xs:Math.pow(Xs,r),new wt(this.r*r,this.g*r,this.b*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new wt(this.r*r,this.g*r,this.b*r,this.opacity)},rgb(){return this},clamp(){return new wt(Tr(this.r),Tr(this.g),Tr(this.b),Js(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:Wl,formatHex:Wl,formatHex8:Fm,formatRgb:Hl,toString:Hl}));function Wl(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}`}function Fm(){return`#${Sr(this.r)}${Sr(this.g)}${Sr(this.b)}${Sr((isNaN(this.opacity)?1:this.opacity)*255)}`}function Hl(){const r=Js(this.opacity);return`${r===1?"rgb(":"rgba("}${Tr(this.r)}, ${Tr(this.g)}, ${Tr(this.b)}${r===1?")":`, ${r})`}`}function Js(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 Vl(r,e,t,n){return n<=0?r=e=t=NaN:t<=0||t>=1?r=e=NaN:e<=0&&(r=NaN),new Pt(r,e,t,n)}function od(r){if(r instanceof Pt)return new Pt(r.h,r.s,r.l,r.opacity);if(r instanceof is||(r=Un(r)),!r)return new Pt;if(r instanceof Pt)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 Pt(o,l,a,r.opacity)}function jm(r,e,t,n){return arguments.length===1?od(r):new Pt(r,e,t,n??1)}function Pt(r,e,t,n){this.h=+r,this.s=+e,this.l=+t,this.opacity=+n}da(Pt,jm,id(is,{brighter(r){return r=r==null?Xs:Math.pow(Xs,r),new Pt(this.h,this.s,this.l*r,this.opacity)},darker(r){return r=r==null?$n:Math.pow($n,r),new Pt(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 wt(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 Pt(Gl(this.h),ys(this.s),ys(this.l),Js(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=Js(this.opacity);return`${r===1?"hsl(":"hsla("}${Gl(this.h)}, ${ys(this.s)*100}%, ${ys(this.l)*100}%${r===1?")":`, ${r})`}`}}));function Gl(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 ad=r=>()=>r;function Lm(r,e){return function(t){return r+t*e}}function Pm(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 Im(r){return(r=+r)==1?ld:function(e,t){return t-e?Pm(e,t,r):ad(isNaN(e)?t:e)}}function ld(r,e){var t=e-r;return t?Lm(r,t):ad(isNaN(r)?e:r)}const Kl=function r(e){var t=Im(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=ld(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 Om(r){return function(){return r}}function zm(r){return function(e){return r(e)+""}}function $m(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]?zm(a[0].x):Om(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 Yl=180/Math.PI,So={translateX:0,translateY:0,rotate:0,skewX:0,scaleX:1,scaleY:1};function ud(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)*Yl,skewX:Math.atan(a)*Yl,scaleX:o,scaleY:l}}var xs;function qm(r){const e=new(typeof DOMMatrix=="function"?DOMMatrix:WebKitCSSMatrix)(r+"");return e.isIdentity?So:ud(e.a,e.b,e.c,e.d,e.e,e.f)}function Um(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,ud(r.a,r.b,r.c,r.d,r.e,r.f))}function cd(r,e,t,n){function s(u){return u.length?u.pop()+" ":""}function i(u,c,d,f,p,g){if(u!==d||c!==f){var m=p.push("translate(",null,e,null,t);g.push({i:m-4,x:fr(u,d)},{i:m-2,x:fr(c,f)})}else(d||f)&&p.push("translate("+d+e+f+t)}function o(u,c,d,f){u!==c?(u-c>180?c+=360:c-u>180&&(u+=360),f.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,f){u!==c?f.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,f,p,g){if(u!==d||c!==f){var m=p.push(s(p)+"scale(",null,",",null,")");g.push({i:m-4,x:fr(u,d)},{i:m-2,x:fr(c,f)})}else(d!==1||f!==1)&&p.push(s(p)+"scale("+d+","+f+")")}return function(u,c){var d=[],f=[];return u=r(u),c=r(c),i(u.translateX,u.translateY,c.translateX,c.translateY,d,f),o(u.rotate,c.rotate,d,f),l(u.skewX,c.skewX,d,f),a(u.scaleX,u.scaleY,c.scaleX,c.scaleY,d,f),u=c=null,function(p){for(var g=-1,m=f.length,x;++g<m;)d[(x=f[g]).i]=x.x(p);return d.join("")}}}var Wm=cd(qm,"px, ","px)","deg)"),Hm=cd(Um,", ",")",")"),Vm=1e-12;function Ql(r){return((r=Math.exp(r))+1/r)/2}function Gm(r){return((r=Math.exp(r))-1/r)/2}function Km(r){return((r=Math.exp(2*r))-1)/(r+1)}const Ym=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],f=o[2],p=c-l,g=d-a,m=p*p+g*g,x,v;if(m<Vm)v=Math.log(f/u)/e,x=function(w){return[l+w*p,a+w*g,u*Math.exp(e*w*v)]};else{var y=Math.sqrt(m),_=(f*f-u*u+n*m)/(2*u*t*y),S=(f*f-u*u-n*m)/(2*f*t*y),E=Math.log(Math.sqrt(_*_+1)-_),k=Math.log(Math.sqrt(S*S+1)-S);v=(k-E)/e,x=function(w){var D=w*v,j=Ql(E),B=u/(t*y)*(j*Km(e*D+E)-Gm(E));return[l+B*p,a+B*g,u*j/Ql(e*D+E)]}}return x.duration=v*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,dd=1e3,Zs,Sn,ei=0,Lr=0,wi=0,Wn=typeof performance=="object"&&performance.now?performance:Date,fd=typeof window=="object"&&window.requestAnimationFrame?window.requestAnimationFrame.bind(window):function(r){setTimeout(r,17)};function fa(){return Lr||(fd(Qm),Lr=Wn.now()+wi)}function Qm(){Lr=0}function ti(){this._call=this._time=this._next=null}ti.prototype=hd.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 hd(r,e,t){var n=new ti;return n.restart(r,e,t),n}function Xm(){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{Xm()}finally{nn=0,Zm(),Lr=0}}function Jm(){var r=Wn.now(),e=r-ei;e>dd&&(wi-=e,ei=r)}function Zm(){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(Jm,dd)),nn=1,fd(Xl))}}function Jl(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 e2=la("start","end","cancel","interrupt"),t2=[],pd=0,Zl=1,Eo=2,Ss=3,eu=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;r2(r,t,{name:e,index:n,group:s,on:e2,tween:t2,time:i.time,delay:i.delay,duration:i.duration,ease:i.ease,timer:null,state:pd})}function ha(r,e){var t=qt(r,e);if(t.state>pd)throw new Error("too late; already scheduled");return t}function Jt(r,e){var t=qt(r,e);if(t.state>Ss)throw new Error("too late; already running");return t}function qt(r,e){var t=r.__transition;if(!t||!(t=t[e]))throw new Error("transition not found");return t}function r2(r,e,t){var n=r.__transition,s;n[e]=t,t.timer=hd(i,0,t.time);function i(u){t.state=Zl,t.timer.restart(o,t.delay,t.time),t.delay<=u&&o(u-t.delay)}function o(u){var c,d,f,p;if(t.state!==Zl)return a();for(c in n)if(p=n[c],p.name===t.name){if(p.state===Ss)return Jl(o);p.state===eu?(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(Jl(function(){t.state===Ss&&(t.state=eu,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(f=t.tween.length),c=0,d=-1;c<f;++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,f=s.length;++d<f;)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 n2(r){return this.each(function(){Es(this,r)})}function s2(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,l=n.length;o<l;++o)if(n[o].name===e){n=n.slice(),n.splice(o,1);break}}s.tween=n}}function i2(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 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 o2(r,e){var t=this._id;if(r+="",arguments.length<2){for(var n=qt(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?s2:i2)(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 qt(s,n).value[e]}}function gd(r,e){var t;return(typeof e=="number"?fr:e instanceof Un?Kl:(t=Un(e))?(e=t,Kl):$m)(r,e)}function a2(r){return function(){this.removeAttribute(r)}}function l2(r){return function(){this.removeAttributeNS(r.space,r.local)}}function u2(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 c2(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 d2(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 f2(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 h2(r,e){var t=_i(r),n=t==="transform"?Hm:gd;return this.attrTween(r,typeof e=="function"?(t.local?f2:d2)(t,n,pa(this,"attr."+r,e)):e==null?(t.local?l2:a2)(t):(t.local?c2:u2)(t,n,e))}function p2(r,e){return function(t){this.setAttribute(r,e.call(this,t))}}function g2(r,e){return function(t){this.setAttributeNS(r.space,r.local,e.call(this,t))}}function m2(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&g2(r,i)),t}return s._value=e,s}function y2(r,e){var t,n;function s(){var i=e.apply(this,arguments);return i!==n&&(t=(n=i)&&p2(r,i)),t}return s._value=e,s}function x2(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?m2:y2)(n,e))}function b2(r,e){return function(){ha(this,r).delay=+e.apply(this,arguments)}}function v2(r,e){return e=+e,function(){ha(this,r).delay=e}}function _2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?b2:v2)(e,r)):qt(this.node(),e).delay}function w2(r,e){return function(){Jt(this,r).duration=+e.apply(this,arguments)}}function C2(r,e){return e=+e,function(){Jt(this,r).duration=e}}function S2(r){var e=this._id;return arguments.length?this.each((typeof r=="function"?w2:C2)(e,r)):qt(this.node(),e).duration}function k2(r,e){if(typeof e!="function")throw new Error;return function(){Jt(this,r).ease=e}}function E2(r){var e=this._id;return arguments.length?this.each(k2(e,r)):qt(this.node(),e).ease}function D2(r,e){return function(){var t=e.apply(this,arguments);if(typeof t!="function")throw new Error;Jt(this,r).ease=t}}function A2(r){if(typeof r!="function")throw new Error;return this.each(D2(this._id,r))}function T2(r){typeof r!="function"&&(r=Yc(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 N2(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),f,p=0;p<c;++p)(f=a[p]||u[p])&&(d[p]=f);for(;l<n;++l)o[l]=e[l];return new ir(o,this._parents,this._name,this._id)}function B2(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 R2(r,e,t){var n,s,i=B2(e)?ha:Jt;return function(){var o=i(this,r),l=o.on;l!==n&&(s=(n=l).copy()).on(e,t),o.on=s}}function M2(r,e){var t=this._id;return arguments.length<2?qt(this.node(),t).on.on(r):this.each(R2(t,r,e))}function F2(r){return function(){var e=this.parentNode;for(var t in this.__transition)if(+t!==r)return;e&&e.removeChild(this)}}function j2(){return this.on("end.remove",F2(this._id))}function L2(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,f=0;f<a;++f)(c=l[f])&&(d=r.call(c,c.__data__,f,l))&&("__data__"in c&&(d.__data__=c.__data__),u[f]=d,Ci(u[f],e,t,f,u,qt(c,t)));return new ir(i,this._parents,e,t)}function P2(r){var e=this._name,t=this._id;typeof r!="function"&&(r=Kc(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 f=r.call(c,c.__data__,d,a),p,g=qt(c,t),m=0,x=f.length;m<x;++m)(p=f[m])&&Ci(p,e,t,m,f,g);i.push(f),o.push(c)}return new ir(i,o,e,t)}var I2=ss.prototype.constructor;function O2(){return new I2(this._groups,this._parents)}function z2(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 md(r){return function(){this.style.removeProperty(r)}}function $2(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 q2(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 U2(r,e){var t,n,s,i="style."+e,o="end."+i,l;return function(){var a=Jt(this,r),u=a.on,c=a.value[i]==null?l||(l=md(e)):void 0;(u!==t||s!==c)&&(n=(t=u).copy()).on(o,s=c),a.on=n}}function W2(r,e,t){var n=(r+="")=="transform"?Wm:gd;return e==null?this.styleTween(r,z2(r,n)).on("end.style."+r,md(r)):typeof e=="function"?this.styleTween(r,q2(r,n,pa(this,"style."+r,e))).each(U2(this._id,r)):this.styleTween(r,$2(r,n,e),t).on("end.style."+r,null)}function H2(r,e,t){return function(n){this.style.setProperty(r,e.call(this,n),t)}}function V2(r,e,t){var n,s;function i(){var o=e.apply(this,arguments);return o!==s&&(n=(s=o)&&H2(r,o,t)),n}return i._value=e,i}function G2(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,V2(r,e,t??""))}function K2(r){return function(){this.textContent=r}}function Y2(r){return function(){var e=r(this);this.textContent=e??""}}function Q2(r){return this.tween("text",typeof r=="function"?Y2(pa(this,"text",r)):K2(r==null?"":r+""))}function X2(r){return function(e){this.textContent=r.call(this,e)}}function J2(r){var e,t;function n(){var s=r.apply(this,arguments);return s!==t&&(e=(t=s)&&X2(s)),e}return n._value=r,n}function Z2(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,J2(r))}function ey(){for(var r=this._name,e=this._id,t=yd(),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=qt(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 ty(){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=Jt(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 ry=0;function ir(r,e,t,n){this._groups=r,this._parents=e,this._name=t,this._id=n}function yd(){return++ry}var tr=ss.prototype;ir.prototype={constructor:ir,select:L2,selectAll:P2,selectChild:tr.selectChild,selectChildren:tr.selectChildren,filter:T2,merge:N2,selection:O2,transition:ey,call:tr.call,nodes:tr.nodes,node:tr.node,size:tr.size,empty:tr.empty,each:tr.each,on:M2,attr:h2,attrTween:x2,style:W2,styleTween:G2,text:Q2,textTween:Z2,remove:j2,tween:o2,delay:_2,duration:S2,ease:E2,easeVarying:A2,end:ty,[Symbol.iterator]:tr[Symbol.iterator]};function ny(r){return((r*=2)<=1?r*r*r:(r-=2)*r*r+2)/2}var sy={time:null,delay:0,duration:250,ease:ny};function iy(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 oy(r){var e,t;r instanceof ir?(e=r._id,r=r._name):(e=yd(),(t=sy).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||iy(a,e));return new ir(n,this._parents,r,e)}ss.prototype.interrupt=n2;ss.prototype.transition=oy;const bs=r=>()=>r;function ay(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 ly(r){return(!r.ctrlKey||r.type==="wheel")&&!r.button}function uy(){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 tu(){return this.__zoom||ri}function cy(r){return-r.deltaY*(r.deltaMode===1?.05:r.deltaMode?1:.002)*(r.ctrlKey?10:1)}function dy(){return navigator.maxTouchPoints||"ontouchstart"in this}function fy(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 hy(){var r=ly,e=uy,t=fy,n=cy,s=dy,i=[0,1/0],o=[[-1/0,-1/0],[1/0,1/0]],l=250,a=Ym,u=la("start","zoom","end"),c,d,f,p=500,g=150,m=0,x=10;function v(C){C.property("__zoom",tu).on("wheel.zoom",D,{passive:!1}).on("mousedown.zoom",j).on("dblclick.zoom",B).filter(s).on("touchstart.zoom",T).on("touchmove.zoom",R).on("touchend.zoom touchcancel.zoom",M).style("-webkit-tap-highlight-color","rgba(0,0,0,0)")}v.transform=function(C,N,F,I){var W=C.selection?C.selection():C;W.property("__zoom",tu),C!==W?E(C,N,F,I):W.interrupt().each(function(){k(this,arguments).event(I).start().zoom(null,typeof N=="function"?N.apply(this,arguments):N).end()})},v.scaleBy=function(C,N,F,I){v.scaleTo(C,function(){var W=this.__zoom.k,z=typeof N=="function"?N.apply(this,arguments):N;return W*z},F,I)},v.scaleTo=function(C,N,F,I){v.transform(C,function(){var W=e.apply(this,arguments),z=this.__zoom,te=F==null?S(W):typeof F=="function"?F.apply(this,arguments):F,U=z.invert(te),Q=typeof N=="function"?N.apply(this,arguments):N;return t(_(y(z,Q),te,U),W,o)},F,I)},v.translateBy=function(C,N,F,I){v.transform(C,function(){return t(this.__zoom.translate(typeof N=="function"?N.apply(this,arguments):N,typeof F=="function"?F.apply(this,arguments):F),e.apply(this,arguments),o)},null,I)},v.translateTo=function(C,N,F,I,W){v.transform(C,function(){var z=e.apply(this,arguments),te=this.__zoom,U=I==null?S(z):typeof I=="function"?I.apply(this,arguments):I;return t(ri.translate(U[0],U[1]).scale(te.k).translate(typeof N=="function"?-N.apply(this,arguments):-N,typeof F=="function"?-F.apply(this,arguments):-F),z,o)},I,W)};function y(C,N){return N=Math.max(i[0],Math.min(i[1],N)),N===C.k?C:new nr(N,C.x,C.y)}function _(C,N,F){var I=N[0]-F[0]*C.k,W=N[1]-F[1]*C.k;return I===C.x&&W===C.y?C:new nr(C.k,I,W)}function S(C){return[(+C[0][0]+ +C[1][0])/2,(+C[0][1]+ +C[1][1])/2]}function E(C,N,F,I){C.on("start.zoom",function(){k(this,arguments).event(I).start()}).on("interrupt.zoom end.zoom",function(){k(this,arguments).event(I).end()}).tween("zoom",function(){var W=this,z=arguments,te=k(W,z).event(I),U=e.apply(W,z),Q=F==null?S(U):typeof F=="function"?F.apply(W,z):F,H=Math.max(U[1][0]-U[0][0],U[1][1]-U[0][1]),se=W.__zoom,ue=typeof N=="function"?N.apply(W,z):N,de=a(se.invert(Q).concat(H/se.k),ue.invert(Q).concat(H/ue.k));return function(pe){if(pe===1)pe=ue;else{var De=de(pe),xe=H/De[2];pe=new nr(xe,Q[0]-De[0]*xe,Q[1]-De[1]*xe)}te.zoom(null,pe)}})}function k(C,N,F){return!F&&C.__zooming||new w(C,N)}function w(C,N){this.that=C,this.args=N,this.active=0,this.sourceEvent=null,this.extent=e.apply(C,N),this.taps=0}w.prototype={event:function(C){return C&&(this.sourceEvent=C),this},start:function(){return++this.active===1&&(this.that.__zooming=this,this.emit("start")),this},zoom:function(C,N){return this.mouse&&C!=="mouse"&&(this.mouse[1]=N.invert(this.mouse[0])),this.touch0&&C!=="touch"&&(this.touch0[1]=N.invert(this.touch0[0])),this.touch1&&C!=="touch"&&(this.touch1[1]=N.invert(this.touch1[0])),this.that.__zoom=N,this.emit("zoom"),this},end:function(){return--this.active===0&&(delete this.that.__zooming,this.emit("end")),this},emit:function(C){var N=Lt(this.that).datum();u.call(C,this.that,new ay(C,{sourceEvent:this.sourceEvent,target:v,transform:this.that.__zoom,dispatch:u}),N)}};function D(C,...N){if(!r.apply(this,arguments))return;var F=k(this,N).event(C),I=this.__zoom,W=Math.max(i[0],Math.min(i[1],I.k*Math.pow(2,n.apply(this,arguments)))),z=wr(C);if(F.wheel)(F.mouse[0][0]!==z[0]||F.mouse[0][1]!==z[1])&&(F.mouse[1]=I.invert(F.mouse[0]=z)),clearTimeout(F.wheel);else{if(I.k===W)return;F.mouse=[z,I.invert(z)],Es(this),F.start()}xn(C),F.wheel=setTimeout(te,g),F.zoom("mouse",t(_(y(I,W),F.mouse[0],F.mouse[1]),F.extent,o));function te(){F.wheel=null,F.end()}}function j(C,...N){if(f||!r.apply(this,arguments))return;var F=C.currentTarget,I=k(this,N,!0).event(C),W=Lt(C.view).on("mousemove.zoom",Q,!0).on("mouseup.zoom",H,!0),z=wr(C,F),te=C.clientX,U=C.clientY;wm(C.view),Wi(C),I.mouse=[z,this.__zoom.invert(z)],Es(this),I.start();function Q(se){if(xn(se),!I.moved){var ue=se.clientX-te,de=se.clientY-U;I.moved=ue*ue+de*de>m}I.event(se).zoom("mouse",t(_(I.that.__zoom,I.mouse[0]=wr(se,F),I.mouse[1]),I.extent,o))}function H(se){W.on("mousemove.zoom mouseup.zoom",null),Cm(se.view,I.moved),xn(se),I.event(se).end()}}function B(C,...N){if(r.apply(this,arguments)){var F=this.__zoom,I=wr(C.changedTouches?C.changedTouches[0]:C,this),W=F.invert(I),z=F.k*(C.shiftKey?.5:2),te=t(_(y(F,z),I,W),e.apply(this,N),o);xn(C),l>0?Lt(this).transition().duration(l).call(E,te,I,C):Lt(this).call(v.transform,te,I,C)}}function T(C,...N){if(r.apply(this,arguments)){var F=C.touches,I=F.length,W=k(this,N,C.changedTouches.length===I).event(C),z,te,U,Q;for(Wi(C),te=0;te<I;++te)U=F[te],Q=wr(U,this),Q=[Q,this.__zoom.invert(Q),U.identifier],W.touch0?!W.touch1&&W.touch0[2]!==Q[2]&&(W.touch1=Q,W.taps=0):(W.touch0=Q,z=!0,W.taps=1+!!c);c&&(c=clearTimeout(c)),z&&(W.taps<2&&(d=Q[0],c=setTimeout(function(){c=null},p)),Es(this),W.start())}}function R(C,...N){if(this.__zooming){var F=k(this,N).event(C),I=C.changedTouches,W=I.length,z,te,U,Q;for(xn(C),z=0;z<W;++z)te=I[z],U=wr(te,this),F.touch0&&F.touch0[2]===te.identifier?F.touch0[0]=U:F.touch1&&F.touch1[2]===te.identifier&&(F.touch1[0]=U);if(te=F.that.__zoom,F.touch1){var H=F.touch0[0],se=F.touch0[1],ue=F.touch1[0],de=F.touch1[1],pe=(pe=ue[0]-H[0])*pe+(pe=ue[1]-H[1])*pe,De=(De=de[0]-se[0])*De+(De=de[1]-se[1])*De;te=y(te,Math.sqrt(pe/De)),U=[(H[0]+ue[0])/2,(H[1]+ue[1])/2],Q=[(se[0]+de[0])/2,(se[1]+de[1])/2]}else if(F.touch0)U=F.touch0[0],Q=F.touch0[1];else return;F.zoom("touch",t(_(te,U,Q),F.extent,o))}}function M(C,...N){if(this.__zooming){var F=k(this,N).event(C),I=C.changedTouches,W=I.length,z,te;for(Wi(C),f&&clearTimeout(f),f=setTimeout(function(){f=null},p),z=0;z<W;++z)te=I[z],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 U=Lt(this).on("dblclick.zoom");U&&U.apply(this,arguments)}}}return v.wheelDelta=function(C){return arguments.length?(n=typeof C=="function"?C:bs(+C),v):n},v.filter=function(C){return arguments.length?(r=typeof C=="function"?C:bs(!!C),v):r},v.touchable=function(C){return arguments.length?(s=typeof C=="function"?C:bs(!!C),v):s},v.extent=function(C){return arguments.length?(e=typeof C=="function"?C:bs([[+C[0][0],+C[0][1]],[+C[1][0],+C[1][1]]]),v):e},v.scaleExtent=function(C){return arguments.length?(i[0]=+C[0],i[1]=+C[1],v):[i[0],i[1]]},v.translateExtent=function(C){return arguments.length?(o[0][0]=+C[0][0],o[1][0]=+C[1][0],o[0][1]=+C[0][1],o[1][1]=+C[1][1],v):[[o[0][0],o[0][1]],[o[1][0],o[1][1]]]},v.constrain=function(C){return arguments.length?(t=C,v):t},v.duration=function(C){return arguments.length?(l=+C,v):l},v.interpolate=function(C){return arguments.length?(a=C,v):a},v.on=function(){var C=u.on.apply(u,arguments);return C===u?v:C},v.clickDistance=function(C){return arguments.length?(m=(C=+C)*C,v):Math.sqrt(m)},v.tapDistance=function(C){return arguments.length?(x=+C,v):x},v}function xd(r={}){const{minZoom:e=.1,maxZoom:t=4,initialTransform:n,zoomable:s=!0,pannable:i=!0,onTransformChange:o}=r,l=b.useRef(null),a=b.useRef(),[u,c]=b.useState(n||{x:0,y:0,k:1});b.useEffect(()=>{if(!l.current)return;const x=hy().scaleExtent([e,t]).filter(y=>!s&&y.type==="wheel"||!i&&(y.type==="mousedown"||y.type==="touchstart")?!1:y.type==="wheel"?s:y.type==="mousedown"||y.type==="touchstart"?y.target.closest("[data-qmap-node]")?!1:i:!0).on("zoom",y=>{const _={x:y.transform.x,y:y.transform.y,k:y.transform.k};c(_),o==null||o(_)});a.current=x;const v=Lt(l.current);return v.call(x),v.on("dblclick.zoom",null),n&&v.call(x.transform,ri.translate(n.x,n.y).scale(n.k)),()=>{v.on(".zoom",null)}},[e,t,s,i]),b.useEffect(()=>{a.current&&a.current.on("zoom",x=>{const v={x:x.transform.x,y:x.transform.y,k:x.transform.k};c(v),o==null||o(v)})},[o]);const d=b.useCallback((x,v,y,_=!0)=>{if(!l.current||!a.current)return;const S=Lt(l.current),E=ri.translate(x,v).scale(y);S.call(a.current.transform,E)},[]),f=b.useCallback(()=>{!l.current||!a.current||Lt(l.current).call(a.current.scaleBy,1.3)},[]),p=b.useCallback(()=>{!l.current||!a.current||Lt(l.current).call(a.current.scaleBy,.7)},[]),g=b.useCallback(()=>{d(0,0,1,!0)},[d]),m=b.useCallback((x,v=50)=>{if(!l.current||!a.current||x.length===0)return;const _=l.current.getBoundingClientRect();let S=1/0,E=1/0,k=-1/0,w=-1/0;for(const I of x){const W=I.width||200,z=I.height||100;S=Math.min(S,I.x),E=Math.min(E,I.y),k=Math.max(k,I.x+W),w=Math.max(w,I.y+z)}const D=k-S,j=w-E,B=(_.width-v*2)/D,T=(_.height-v*2)/j,R=Math.min(B,T,t),M=(S+k)/2,C=(E+w)/2,N=_.width/2-M*R,F=_.height/2-C*R;d(N,F,R,!0)},[t,d]);return{transform:u,containerRef:l,zoomTo:d,zoomIn:f,zoomOut:p,resetZoom:g,fitToContent:m}}function bd(r){const{transform:e,onDragStart:t,onDragMove:n,onDragEnd:s,disabled:i=!1}=r,[o,l]=b.useState(null),[a,u]=b.useState(!1),[c,d]=b.useState({x:0,y:0}),f=b.useRef(null),p=b.useRef({x:0,y:0}),g=b.useRef(e);b.useEffect(()=>{g.current=e},[e]);const m=b.useCallback((_,S)=>{const E=g.current;return{x:(_-E.x)/E.k,y:(S-E.y)/E.k}},[]),x=b.useCallback((_,S)=>{if(i)return;S.preventDefault(),S.stopPropagation();const E=S.currentTarget,k=parseFloat(E.dataset.x||"0"),w=parseFloat(E.dataset.y||"0");f.current={x:S.clientX,y:S.clientY,nodeX:k,nodeY:w},p.current={x:k,y:w},l(_),u(!0),d({x:0,y:0}),t==null||t(_)},[i,m,t]),v=b.useCallback(_=>{if(!a||!o||!f.current)return;const S=g.current,E=f.current,k=_.clientX-E.x,w=_.clientY-E.y,D=k/S.k,j=w/S.k,B=E.nodeX+D,T=E.nodeY+j;p.current={x:B,y:T},d({x:D,y:j}),n==null||n(o,B,T,D,j)},[a,o,n]),y=b.useCallback(()=>{if(!a||!o)return;const _=p.current;s==null||s(o,_.x,_.y),l(null),u(!1),d({x:0,y:0}),f.current=null},[a,o,s]);return b.useEffect(()=>{if(!a)return;const _=E=>{v(E)},S=()=>{y()};return window.addEventListener("mousemove",_),window.addEventListener("mouseup",S),()=>{window.removeEventListener("mousemove",_),window.removeEventListener("mouseup",S)}},[a,v,y]),{draggedNodeId:o,isDragging:a,dragOffset:c,startDrag:x,updateDrag:v,endDrag:y}}function vd(r){const{transform:e,nodePositions:t,disabled:n=!1,controlledSelectedIds:s,onSelectionChange:i}=r,[o,l]=b.useState(new Set),a=s!==void 0,u=a?new Set(s):o,c=a?B=>{const T=typeof B=="function"?B(u):B;i==null||i(Array.from(T))}:l,[d,f]=b.useState(null),[p,g]=b.useState(!1),m=b.useRef(null),x=b.useRef(e),v=b.useRef(t);b.useEffect(()=>{x.current=e},[e]),b.useEffect(()=>{v.current=t},[t]);const y=b.useCallback((B,T)=>{const R=x.current;return{x:(B-R.x)/R.k,y:(T-R.y)/R.k}},[]),_=b.useCallback((B,T)=>{const R=v.current.get(B);if(!R)return!1;const M=R.width||200,C=R.height||100;return R.x<T.x+T.width&&R.x+M>T.x&&R.y<T.y+T.height&&R.y+C>T.y},[]),S=b.useCallback(B=>{if(n||B.target.closest("[data-qmap-node]"))return;B.preventDefault();const R=y(B.clientX,B.clientY);m.current=R,f({x:R.x,y:R.y,width:0,height:0}),g(!0),B.shiftKey||c(new Set)},[n,y]),E=b.useCallback(B=>{if(!p||!m.current)return;const T=m.current,R=y(B.clientX,B.clientY),M={x:Math.min(T.x,R.x),y:Math.min(T.y,R.y),width:Math.abs(R.x-T.x),height:Math.abs(R.y-T.y)};f(M);const C=new Set;for(const[N]of v.current)_(N,M)&&C.add(N);c(C)},[p,y,_]),k=b.useCallback(()=>{p&&(i==null||i(Array.from(u)),g(!1),f(null),m.current=null)},[p,u,i]);b.useEffect(()=>{if(!p)return;const B=R=>{E(R)},T=()=>{k()};return window.addEventListener("mousemove",B),window.addEventListener("mouseup",T),()=>{window.removeEventListener("mousemove",B),window.removeEventListener("mouseup",T)}},[p,E,k]);const w=b.useCallback((B,T=!1)=>{c(R=>{const M=new Set(T?R:[]);return R.has(B)&&T?M.delete(B):M.add(B),i==null||i(Array.from(M)),M})},[i]),D=b.useCallback(()=>{const B=new Set(v.current.keys());c(B),i==null||i(Array.from(B))},[i]),j=b.useCallback(()=>{c(new Set),i==null||i([])},[i]);return{selectedIds:u,setSelectedIds:c,selectionBox:d,isSelecting:p,startSelection:S,updateSelection:E,endSelection:k,toggleSelect:w,selectAll:D,clearSelection:j}}const _d=b.memo(function({nodeId:e,position:t,isSelected:n,isDragging:s,draggable:i,onDragStart:o,onClick:l,onDoubleClick:a,onContextMenu:u,children:c}){const d=b.useCallback(y=>{i&&y.button===0&&o(e,y)},[e,i,o]),f=b.useCallback(y=>{s||l==null||l(y)},[s,l]),p=b.useCallback(y=>{y.stopPropagation(),a==null||a(y)},[a]),g=b.useCallback(y=>{y.preventDefault(),y.stopPropagation(),u==null||u(y)},[u]),m=t.width||200,x=t.height||100,v=t.rotation||0;return h.jsx("div",{"data-qmap-node":e,"data-x":t.x,"data-y":t.y,style:{position:"absolute",left:t.x,top:t.y,width:m,height:x,transform:v!==0?`rotate(${v}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:d,onClick:f,onDoubleClick:p,onContextMenu:g,children:c})},(r,e)=>r.nodeId===e.nodeId&&r.position.x===e.position.x&&r.position.y===e.position.y&&r.position.width===e.position.width&&r.position.height===e.position.height&&r.position.rotation===e.position.rotation&&r.isSelected===e.isSelected&&r.isDragging===e.isDragging&&r.draggable===e.draggable&&r.children===e.children);function wd(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 gy(n,s);case"bezier":default:return py(n,s)}}function py(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 gy(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 my(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,f;return u<c?(d=s.x+(i>0?l:-l),f=s.y+o*l/Math.abs(i)):(f=s.y+(o>0?a:-a),d=s.x+i*a/Math.abs(o)),{x:d,y:f}}function yy(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 xy(r,e){return r.x>=e.x&&r.x<=e.x+e.width&&r.y>=e.y&&r.y<=e.y+e.height}function by(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 vy(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 _y(r,e){const t=e.x-r.x,n=e.y-r.y;return Math.sqrt(t*t+n*n)}function wy(r,e){const t=e.x-r.x,n=e.y-r.y;return t*t+n*n}const Cd=b.memo(function({edge:e,sourcePosition:t,targetPosition:n,style:s,color:i,width:o,onClick:l}){const[a,u]=b.useState(!1),c=b.useMemo(()=>wd(t,n,s),[t,n,s]),d=b.useCallback(x=>{x.stopPropagation(),l==null||l(e,x)},[e,l]),f=b.useCallback(()=>{u(!0)},[]),p=b.useCallback(()=>{u(!1)},[]),g=e.color||i,m=e.width||o;return h.jsxs("g",{children:[h.jsx("path",{d:c,fill:"none",stroke:"transparent",strokeWidth:Math.max(m*3,10),style:{cursor:l?"pointer":"default",pointerEvents:"stroke"},onClick:d,onMouseEnter:f,onMouseLeave:p}),h.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&&h.jsx(Cy,{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 Cy({pathD:r,label:e,color:t}){const n=b.useMemo(()=>`edge-label-${Math.random().toString(36).substr(2,9)}`,[]);return h.jsxs(h.Fragment,{children:[h.jsx("defs",{children:h.jsx("path",{id:n,d:r})}),h.jsx("text",{fill:t,fontSize:"12",fontFamily:"system-ui, sans-serif",style:{pointerEvents:"none"},children:h.jsx("textPath",{href:`#${n}`,startOffset:"50%",textAnchor:"middle",children:e})})]})}const Sd=b.memo(function({edges:e,nodePositions:t,defaultStyle:n,defaultColor:s,defaultWidth:i,onEdgeClick:o}){const l=b.useMemo(()=>e.filter(a=>t.has(a.source)&&t.has(a.target)),[e,t]);return h.jsx("svg",{style:{position:"absolute",top:0,left:0,width:1,height:1,overflow:"visible",pointerEvents:"none"},children:h.jsx("g",{style:{pointerEvents:"auto"},children:l.map(a=>{const u=t.get(a.source),c=t.get(a.target);return h.jsx(Cd,{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)),kd=b.memo(function({box:e,transform:t}){const n=b.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 h.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}})}),Sy=200,ky=100,Ey="bezier",Dy="#94a3b8",Ay=2,Ty=.1,Ny=4;function By({viewNode:r,nodes:e,edges:t,renderNode:n,defaultNodeWidth:s=Sy,defaultNodeHeight:i=ky,onNodeMove:o,onNodeClick:l,onNodeDoubleClick:a,onNodeContextMenu:u,selectedIds:c,onSelectionChange:d,onEdgeClick:f,onViewChange:p,onTransformChange:g,minZoom:m=Ty,maxZoom:x=Ny,initialTransform:v,defaultEdgeStyle:y=Ey,defaultEdgeColor:_=Dy,defaultEdgeWidth:S=Ay,draggable:E=!0,selectable:k=!0,zoomable:w=!0,pannable:D=!0,className:j="",style:B,background:T="#f8fafc",showGrid:R=!1,gridSize:M=20}){const C=r.data||{positions:{}},N=C.positions||{},F=b.useMemo(()=>{const Y=new Map;for(const P of e){const me=N[P._id]||{x:0,y:0};Y.set(P._id,{x:me.x,y:me.y,width:me.width||s,height:me.height||i,rotation:me.rotation||0})}return Y},[e,N,s,i]),{transform:I,containerRef:W,zoomIn:z,zoomOut:te,resetZoom:U,fitToContent:Q}=xd({minZoom:m,maxZoom:x,initialTransform:v||C.transform,zoomable:w,pannable:D,onTransformChange:Y=>{g==null||g(Y);const P={...C,transform:Y};p==null||p(P)}}),[H,se]=b.useState(new Map),{draggedNodeId:ue,startDrag:de}=bd({transform:I,disabled:!E,onDragStart:Y=>{const P=F.get(Y);P&&se(new Map([[Y,{x:P.x,y:P.y}]]))},onDragMove:(Y,P,me)=>{se(new Map([[Y,{x:P,y:me}]]))},onDragEnd:(Y,P,me)=>{se(new Map),o==null||o(Y,P,me)}}),{selectedIds:pe,selectionBox:De,isSelecting:xe,startSelection:J,toggleSelect:Ce,clearSelection:ne}=vd({transform:I,nodePositions:F,disabled:!k,controlledSelectedIds:c,onSelectionChange:d}),Be=b.useCallback(Y=>{const P=F.get(Y)||{x:0,y:0,width:s,height:i},me=H.get(Y);return me?{...P,x:me.x,y:me.y}:P},[F,H,s,i]),Se=b.useMemo(()=>{const Y=new Map;for(const P of F.keys())Y.set(P,Be(P));return Y},[F,Be]),ke=b.useCallback((Y,P)=>{Ce(Y._id,P.shiftKey),l==null||l(Y,P)},[Ce,l]),Ie=b.useCallback(Y=>{Y.target.closest("[data-qmap-node]")||ne()},[ne]),Le=b.useCallback(Y=>{Y.button===0&&(Y.target.closest("[data-qmap-node]")||J(Y))},[J]),$e=R?`
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 h.jsxs("div",{ref:V,className:`qmap-container ${M}`,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",background:N,backgroundImage:$e,backgroundSize:R?`${j}px ${j}px`:void 0,cursor:xe?"crosshair":k?"grab":"default",...T},onMouseDown:Le,onClick:Ie,children:[h.jsxs("div",{className:"qmap-canvas",style:{position:"absolute",transformOrigin:"0 0",transform:`translate(${O.x}px, ${O.y}px) scale(${O.k})`,willChange:"transform"},children:[h.jsx(Sd,{edges:t,nodePositions:Se,defaultStyle:y,defaultColor:w,defaultWidth:C,onEdgeClick:f}),e.map(Y=>{const P=Be(Y._id),me=pe.has(Y._id),We=ue===Y._id;return h.jsx(_d,{nodeId:Y._id,position:P,isSelected:me,isDragging:We,draggable:D,onDragStart:de,onClick:z=>ke(Y,z),onDoubleClick:z=>a==null?void 0:a(Y,z),onContextMenu:z=>u==null?void 0:u(Y,z),children:n(Y,me,P)},Y._id)})]}),De&&h.jsx(kd,{box:De,transform:O}),h.jsxs("div",{className:"qmap-controls",style:{position:"absolute",bottom:16,right:16,display:"flex",flexDirection:"column",gap:4,zIndex:100},children:[h.jsx("button",{onClick:U,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:"+"}),h.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 out",children:"−"}),h.jsx("button",{onClick:q,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"}),h.jsx("button",{onClick:()=>X(Array.from(F.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=bg;exports.AnimatedCardFlip=bf;exports.ApiClient=iu;exports.AudioEditor=Vc;exports.AuthFlow=cu;exports.AuthFlowModal=ff;exports.AuthManager=vt;exports.AuthProvider=nf;exports.AuthService=Ao;exports.Card=gf;exports.ComboBox=Tg;exports.ComboStack=Bg;exports.DataOperations=vs;exports.Detail=mf;exports.ForgotPasswordForm=lu;exports.GraphClient=Bd;exports.ImageEditor=Og;exports.KanbanBoard=Rg;exports.LLMClient=Xd;exports.LoginForm=No;exports.LoginModal=af;exports.Mail=_f;exports.MailClient=su;exports.MailComposer=Dg;exports.MailEditor=Hc;exports.QMap=By;exports.QMapEdgeComponent=Cd;exports.QMapEdgeLayer=Sd;exports.QMapNode=_d;exports.QMapSelectionBox=kd;exports.QRCodeNode=un;exports.RegisterForm=au;exports.ResetPasswordForm=uu;exports.SelectableList=wf;exports.Stack=pf;exports.Timeline=Pg;exports.VerifyCodeForm=Gi;exports.VoiceTextEditor=Ig;exports.calculateBoundingBox=vy;exports.calculateEdgePath=wd;exports.distance=_y;exports.distanceSquared=wy;exports.getApiClient=To;exports.getAuthService=Zd;exports.getConnectionPoint=my;exports.getNodeCenter=ga;exports.getNodeSidePoint=yy;exports.initializeApiClient=ef;exports.initializeAuthService=Jd;exports.pointInRect=xy;exports.rectsIntersect=by;exports.useAuth=sf;exports.useMutation=hf;exports.useNodeDrag=bd;exports.useQuery=du;exports.useSelection=vd;exports.useZoomPan=xd;
188
+ `:void 0;return h.jsxs("div",{ref:W,className:`qmap-container ${j}`,style:{position:"relative",width:"100%",height:"100%",overflow:"hidden",background:T,backgroundImage:$e,backgroundSize:R?`${M}px ${M}px`:void 0,cursor:xe?"crosshair":D?"grab":"default",...B},onMouseDown:Le,onClick:Ie,children:[h.jsxs("div",{className:"qmap-canvas",style:{position:"absolute",transformOrigin:"0 0",transform:`translate(${I.x}px, ${I.y}px) scale(${I.k})`,willChange:"transform"},children:[h.jsx(Sd,{edges:t,nodePositions:Se,defaultStyle:y,defaultColor:_,defaultWidth:S,onEdgeClick:f}),e.map(Y=>{const P=Be(Y._id),me=pe.has(Y._id),We=ue===Y._id;return h.jsx(_d,{nodeId:Y._id,position:P,isSelected:me,isDragging:We,draggable:E,onDragStart:de,onClick:$=>ke(Y,$),onDoubleClick:$=>a==null?void 0:a(Y,$),onContextMenu:$=>u==null?void 0:u(Y,$),children:n(Y,me,P)},Y._id)})]}),De&&h.jsx(kd,{box:De,transform:I}),h.jsxs("div",{className:"qmap-controls",style:{position:"absolute",bottom:16,right:16,display:"flex",flexDirection:"column",gap:4,zIndex:100},children:[h.jsx("button",{onClick:z,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:"+"}),h.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 out",children:"−"}),h.jsx("button",{onClick:U,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"}),h.jsx("button",{onClick:()=>Q(Array.from(F.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=bg;exports.AnimatedCardFlip=bf;exports.ApiClient=iu;exports.AudioEditor=Vc;exports.AuthFlow=cu;exports.AuthFlowModal=ff;exports.AuthManager=vt;exports.AuthProvider=nf;exports.AuthService=Ao;exports.Card=gf;exports.ComboBox=Tg;exports.ComboStack=Bg;exports.DataOperations=vs;exports.Detail=mf;exports.ForgotPasswordForm=lu;exports.GraphClient=Bd;exports.ImageEditor=Og;exports.KanbanBoard=Rg;exports.LLMClient=Xd;exports.LoginForm=No;exports.LoginModal=af;exports.Mail=_f;exports.MailClient=su;exports.MailComposer=Dg;exports.MailEditor=Hc;exports.QMap=By;exports.QMapEdgeComponent=Cd;exports.QMapEdgeLayer=Sd;exports.QMapNode=_d;exports.QMapSelectionBox=kd;exports.QRCodeNode=un;exports.RegisterForm=au;exports.ResetPasswordForm=uu;exports.SelectableList=wf;exports.Stack=pf;exports.Timeline=Pg;exports.VerifyCodeForm=Gi;exports.VoiceTextEditor=Ig;exports.calculateBoundingBox=vy;exports.calculateEdgePath=wd;exports.distance=_y;exports.distanceSquared=wy;exports.getApiClient=To;exports.getAuthService=Zd;exports.getConnectionPoint=my;exports.getNodeCenter=ga;exports.getNodeSidePoint=yy;exports.initializeApiClient=ef;exports.initializeAuthService=Jd;exports.pointInRect=xy;exports.rectsIntersect=by;exports.useAuth=sf;exports.useMutation=hf;exports.useNodeDrag=bd;exports.useQuery=du;exports.useSelection=vd;exports.useZoomPan=xd;